@huanban/rulego-editor-core 1.4.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +20 -8
  2. package/dist/ai/ai-chat-options.d.ts +12 -0
  3. package/dist/api/AIAssistantAPI.d.ts +29 -0
  4. package/dist/api/AIManager.d.ts +7 -1
  5. package/dist/api/ApiProvider.d.ts +17 -4
  6. package/dist/api/DebugSocketClient.d.ts +2 -0
  7. package/dist/api/GlobalConfigAPI.d.ts +35 -0
  8. package/dist/api/IoTPointTemplateAPI.d.ts +32 -0
  9. package/dist/api/MarketplaceAPI.d.ts +39 -0
  10. package/dist/api/RuleChainAPI.d.ts +23 -4
  11. package/dist/api/RuleChainVersionsAPI.d.ts +28 -0
  12. package/dist/api/SkillsAPI.d.ts +31 -0
  13. package/dist/api/UserAPI.d.ts +39 -0
  14. package/dist/api/extended-api-shared.d.ts +25 -0
  15. package/dist/api/index.d.ts +19 -2
  16. package/dist/api/public-api.test-d.d.ts +87 -0
  17. package/dist/api/response-utils.d.ts +1 -0
  18. package/dist/api/types.d.ts +86 -14
  19. package/dist/chunks/editor-core-api-BQiYFuIO.js +1157 -0
  20. package/dist/chunks/editor-core-canvas-nodes-BE9eN51s.js +6921 -0
  21. package/dist/chunks/editor-core-code-editor-DFm5Owtv.js +660 -0
  22. package/dist/chunks/{editor-core-default-components-BjF65lar.js → editor-core-default-components-BsNP8ma1.js} +98 -98
  23. package/dist/chunks/editor-core-dialogs-D9YHvzys.js +12009 -0
  24. package/dist/chunks/{editor-core-locales-i6o28vm2.js → editor-core-locales-CsqTh7Wh.js} +1723 -11
  25. package/dist/chunks/{editor-core-node-patches-BJTT3TuX.js → editor-core-node-patches-Dbi8XYxu.js} +633 -184
  26. package/dist/chunks/{editor-core-node-views-BOaPVdmN.js → editor-core-node-views-C8FQYC3E.js} +39 -29
  27. package/dist/chunks/editor-core-property-drawers-Bqmp9B_J.js +9562 -0
  28. package/dist/chunks/editor-core-settings-DcGCJSc7.js +4161 -0
  29. package/dist/chunks/editor-core-standalone-C7pzm8ZB.js +10013 -0
  30. package/dist/chunks/{editor-core-styles-DFhXz0vB.js → editor-core-styles-CwjFPfAo.js} +967 -510
  31. package/dist/chunks/vendor-highlight-acC2fLd8.js +5868 -0
  32. package/dist/chunks/vendor-logicflow-core-runtime-DpsWXOGl.js +4 -0
  33. package/dist/chunks/vendor-logicflow-shared-C_kIdBKO.js +4 -0
  34. package/dist/core/ActionRegistry.d.ts +4 -2
  35. package/dist/core/DataAdapter.d.ts +17 -1
  36. package/dist/core/DialogProvider.d.ts +33 -0
  37. package/dist/core/EditorCore.d.ts +16 -3
  38. package/dist/core/FieldCapabilityRegistry.d.ts +4 -1
  39. package/dist/core/FieldChangeRegistry.d.ts +3 -1
  40. package/dist/core/I18nManager.d.ts +1 -1
  41. package/dist/core/IdentityProvider.d.ts +32 -0
  42. package/dist/core/OptionSourceRegistry.d.ts +4 -1
  43. package/dist/core/PropertyControlRegistry.d.ts +29 -0
  44. package/dist/core/ThemeManager.d.ts +7 -0
  45. package/dist/core/anchored-popover.d.ts +16 -0
  46. package/dist/core/assistant-dsl.d.ts +18 -0
  47. package/dist/core/business-log-config.d.ts +18 -0
  48. package/dist/core/clean-snapshot.d.ts +14 -0
  49. package/dist/core/component-localization.d.ts +17 -0
  50. package/dist/core/component-palette.d.ts +3 -0
  51. package/dist/core/connection-status.d.ts +11 -0
  52. package/dist/core/dialog-styles.d.ts +1 -0
  53. package/dist/core/editor-capabilities.d.ts +82 -1
  54. package/dist/core/editor-edge-anchors.d.ts +16 -0
  55. package/dist/core/endpoint-protocol.d.ts +15 -0
  56. package/dist/core/expression-preview.d.ts +6 -0
  57. package/dist/core/field-protocol.d.ts +19 -4
  58. package/dist/core/global-config.d.ts +47 -0
  59. package/dist/core/global-search.d.ts +31 -0
  60. package/dist/core/group-protocol.d.ts +56 -0
  61. package/dist/core/identity-provider-default.d.ts +32 -0
  62. package/dist/core/index.d.ts +31 -5
  63. package/dist/core/keymap.d.ts +10 -0
  64. package/dist/core/payload-kv.d.ts +7 -0
  65. package/dist/core/rule-chain-versions.d.ts +143 -0
  66. package/dist/core/run-analysis.d.ts +126 -0
  67. package/dist/core/runtime-field-dictionary.d.ts +3 -0
  68. package/dist/core/save-conflict.d.ts +1 -0
  69. package/dist/core/server-status.d.ts +1 -0
  70. package/dist/core/toolbar-icons.d.ts +1 -1
  71. package/dist/core/variable-completion.d.ts +13 -0
  72. package/dist/core/websocket-auth.d.ts +2 -0
  73. package/dist/defaults/analysis-locales.d.ts +241 -0
  74. package/dist/defaults/component-locale-categories.d.ts +14 -0
  75. package/dist/defaults/component-locale-data.d.ts +4 -0
  76. package/dist/defaults/component-locale-en-US.d.ts +10 -0
  77. package/dist/defaults/component-locale-summaries.d.ts +15 -0
  78. package/dist/defaults/component-locale-zh-CN.d.ts +10 -0
  79. package/dist/defaults/editor-shell-locales.d.ts +290 -0
  80. package/dist/defaults/example-chain.d.ts +2 -0
  81. package/dist/defaults/field-interaction-locales.d.ts +19 -0
  82. package/dist/defaults/global-config-locales.d.ts +166 -0
  83. package/dist/defaults/official-component-fallbacks.d.ts +2 -1
  84. package/dist/defaults/point-template-locales.d.ts +64 -0
  85. package/dist/index.cjs +2856 -2086
  86. package/dist/index.d.ts +33 -10
  87. package/dist/index.esm.js +1182 -810
  88. package/dist/index.umd.js +2850 -2080
  89. package/dist/nodes/UnknownNodeModel.d.ts +12 -1
  90. package/dist/standalone/HuanbanRulegoEditor.d.ts +145 -13
  91. package/dist/standalone/auth-fetch.d.ts +1 -0
  92. package/dist/standalone/auth-ui-defaults.d.ts +15 -0
  93. package/dist/standalone/code-editor.d.ts +7 -5
  94. package/dist/standalone/connection-status-binding.d.ts +3 -2
  95. package/dist/standalone/custom-nodes.d.ts +13 -0
  96. package/dist/standalone/drawer-locale.d.ts +12 -0
  97. package/dist/standalone/drawer-unsaved-guard.d.ts +6 -1
  98. package/dist/standalone/dynamic-field-browse.d.ts +25 -0
  99. package/dist/standalone/edge-label-quick-editor.d.ts +2 -1
  100. package/dist/standalone/editor-actions.d.ts +1 -0
  101. package/dist/standalone/editor-canvas-anchors.d.ts +19 -0
  102. package/dist/standalone/editor-canvas-shortcuts.d.ts +1 -0
  103. package/dist/standalone/editor-chain-info.d.ts +1 -0
  104. package/dist/standalone/editor-debug-data.d.ts +18 -0
  105. package/dist/standalone/editor-debug-ws.d.ts +2 -0
  106. package/dist/standalone/editor-delete.d.ts +5 -3
  107. package/dist/standalone/editor-dialog-provider.d.ts +3 -0
  108. package/dist/standalone/editor-dialogs.d.ts +25 -2
  109. package/dist/standalone/editor-global-config.d.ts +44 -0
  110. package/dist/standalone/editor-group-interactions.d.ts +1 -0
  111. package/dist/standalone/editor-host-region-styles.d.ts +1 -0
  112. package/dist/standalone/editor-host-regions.d.ts +53 -0
  113. package/dist/standalone/editor-login.d.ts +15 -0
  114. package/dist/standalone/editor-overlays.d.ts +5 -0
  115. package/dist/standalone/editor-property-drawers.d.ts +3 -1
  116. package/dist/standalone/editor-run-analysis.d.ts +81 -0
  117. package/dist/standalone/editor-run-compare.d.ts +20 -0
  118. package/dist/standalone/editor-run-waterfall.d.ts +11 -0
  119. package/dist/standalone/editor-toast.d.ts +1 -1
  120. package/dist/standalone/editor-toolbar-presentation.d.ts +12 -0
  121. package/dist/standalone/editor-toolbar.d.ts +5 -1
  122. package/dist/standalone/editor-ui-configuration.d.ts +55 -0
  123. package/dist/standalone/editor-ui-settings.d.ts +26 -0
  124. package/dist/standalone/editor-user-menu.d.ts +8 -0
  125. package/dist/standalone/editor-version-history.d.ts +82 -0
  126. package/dist/standalone/editor-workspace-shell.d.ts +47 -0
  127. package/dist/standalone/editor-workspace-styles.d.ts +1 -0
  128. package/dist/standalone/field-expression-preview.d.ts +12 -0
  129. package/dist/standalone/group-node.d.ts +19 -3
  130. package/dist/standalone/icon-utils.d.ts +7 -0
  131. package/dist/standalone/index.d.ts +17 -5
  132. package/dist/standalone/keyboard-events.d.ts +3 -0
  133. package/dist/standalone/multi-select-popover.d.ts +16 -0
  134. package/dist/standalone/node-copy.d.ts +1 -0
  135. package/dist/standalone/node-definitions.d.ts +4 -0
  136. package/dist/standalone/node-renderer-utils.d.ts +21 -0
  137. package/dist/standalone/node-theme.d.ts +1 -1
  138. package/dist/standalone/point-template-actions.d.ts +43 -0
  139. package/dist/standalone/property-field-draft.d.ts +5 -0
  140. package/dist/standalone/question-list-editor.d.ts +35 -0
  141. package/dist/standalone/shared-node-manager.d.ts +14 -0
  142. package/dist/standalone/single-select-popover.d.ts +6 -0
  143. package/dist/standalone/theme-scope.d.ts +15 -0
  144. package/dist/standalone/themes.d.ts +4 -0
  145. package/dist/standalone/variable-completion-dropdown.d.ts +18 -0
  146. package/dist/types/component.d.ts +22 -1
  147. package/dist/types/editor.d.ts +41 -0
  148. package/dist/utils/relation-utils.d.ts +19 -1
  149. package/dist/version.d.ts +2 -2
  150. package/package.json +3 -3
  151. package/vite-chunks.mjs +66 -0
  152. package/dist/chunks/editor-core-code-editor-CRki2wA_.js +0 -512
  153. package/dist/chunks/editor-core-dialogs-BMWb0WRN.js +0 -17228
  154. package/dist/chunks/editor-core-property-drawers-BPh-jj1b.js +0 -7998
  155. package/dist/chunks/editor-core-standalone-Cls7lcgT.js +0 -11302
  156. package/dist/chunks/vendor-logicflow-core-runtime-Cp6IBEjB.js +0 -217
  157. package/dist/chunks/vendor-logicflow-shared-C7YynLDn.js +0 -4
@@ -0,0 +1,4161 @@
1
+ import { r as vt, f as qr, u as De, a as Ne, G as re, b as ut, c as wn, d as Pt, e as Sn, g as X, h as xn, i as j, j as Cn, k as kn, w as An, l as En, m as Tn } from "./editor-core-canvas-nodes-BE9eN51s.js";
2
+ import { c as $n, T as Mn, a as Nn, n as Ln, b as Jt, E as Dt, i as Rn } from "./editor-core-styles-CwjFPfAo.js";
3
+ import { g as _t, c as rt, a as Pn, b as Dn } from "./editor-core-locales-CsqTh7Wh.js";
4
+ import { Compartment as On, StateEffect as In } from "@codemirror/state";
5
+ import { EditorView as dr } from "@codemirror/view";
6
+ import { c as qn } from "./editor-core-code-editor-DFm5Owtv.js";
7
+ import { S as jn, R as zn } from "./editor-core-api-BQiYFuIO.js";
8
+ const Te = {
9
+ maxImportBytes: 5 * 1024 * 1024,
10
+ maxGraphNodes: 1e3,
11
+ maxGraphEdges: 3e3,
12
+ maxComponents: 1e3,
13
+ maxFieldsPerNode: 200,
14
+ maxDebugItems: 500,
15
+ maxDebugItemChars: 2e4,
16
+ maxExampleEventLogLines: 80,
17
+ maxJsonPrettyChars: 2e5,
18
+ runHistoryRequestTimeoutMs: 15e3,
19
+ maxChatChains: 20,
20
+ maxChatMessagesPerChain: 50,
21
+ maxChatMessageChars: 2e3,
22
+ maxChatReasoningChars: 5e4,
23
+ maxChatToolArgumentChars: 2e4,
24
+ maxRecentToolCallGroups: 5,
25
+ maxObjectDepth: 8
26
+ };
27
+ class Xe extends Error {
28
+ constructor(t, r) {
29
+ super(r), this.code = t, this.name = "RuntimeLimitError";
30
+ }
31
+ }
32
+ function Ua(e, t) {
33
+ var a, o;
34
+ const r = ((a = e.nodes) == null ? void 0 : a.length) ?? 0, n = ((o = e.edges) == null ? void 0 : o.length) ?? 0;
35
+ if (r > Te.maxGraphNodes)
36
+ throw new Xe(
37
+ "GRAPH_NODES_LIMIT",
38
+ `${t} graph has ${r} nodes, max is ${Te.maxGraphNodes}`
39
+ );
40
+ if (n > Te.maxGraphEdges)
41
+ throw new Xe(
42
+ "GRAPH_EDGES_LIMIT",
43
+ `${t} graph has ${n} edges, max is ${Te.maxGraphEdges}`
44
+ );
45
+ }
46
+ function Wa(e) {
47
+ if (e.length > Te.maxComponents)
48
+ throw new Xe(
49
+ "COMPONENTS_LIMIT",
50
+ `component list has ${e.length} items, max is ${Te.maxComponents}`
51
+ );
52
+ }
53
+ function Ka(e, t, r) {
54
+ const n = Hn(e);
55
+ if (n > t)
56
+ throw new Xe("TEXT_BYTES_LIMIT", `${r} has ${n} bytes, max is ${t}`);
57
+ }
58
+ function Ya(e, t) {
59
+ const r = String(e ?? "");
60
+ return r.length <= t ? r : `${r.slice(0, t)}...[TRUNCATED ${r.length - t} CHARS]`;
61
+ }
62
+ function Qa(e, t, r) {
63
+ const n = /* @__PURE__ */ new WeakSet(), a = (o, s) => {
64
+ if (!(o === null || typeof o != "object")) {
65
+ if (s > t)
66
+ throw new Xe("OBJECT_DEPTH_LIMIT", `${r} depth exceeds ${t}`);
67
+ if (!n.has(o)) {
68
+ if (n.add(o), Array.isArray(o)) {
69
+ for (const i of o) a(i, s + 1);
70
+ return;
71
+ }
72
+ for (const i of Object.values(o)) a(i, s + 1);
73
+ }
74
+ }
75
+ };
76
+ a(e, 0);
77
+ }
78
+ function Hn(e) {
79
+ return typeof TextEncoder < "u" ? new TextEncoder().encode(e).length : e.length;
80
+ }
81
+ const Bn = $n("--rg"), dt = /* @__PURE__ */ new WeakMap();
82
+ function jr(e) {
83
+ for (let t = e; t; t = t.parentElement) {
84
+ const r = dt.get(t);
85
+ if (r) return r;
86
+ }
87
+ }
88
+ class Xa {
89
+ constructor() {
90
+ this.themes = /* @__PURE__ */ new Map(), this.currentTheme = "default", this.targetElement = null, this.scopes = /* @__PURE__ */ new Map(), this.changeCallbacks = /* @__PURE__ */ new Set(), this.systemThemeQuery = null, this.systemThemeHandler = null, Object.keys(Mn).forEach((t) => this.register(Nn(t)));
91
+ }
92
+ /**
93
+ * 注册主题
94
+ *
95
+ * @param theme - 主题定义
96
+ * @param overwrite - 是否覆盖已有同名主题 (默认: true)
97
+ */
98
+ register(t, r = !0) {
99
+ if (this.themes.has(t.name) && !r) {
100
+ console.warn(`[ThemeManager] 主题 "${t.name}" 已存在, 跳过注册`);
101
+ return;
102
+ }
103
+ this.themes.set(t.name, t);
104
+ }
105
+ /**
106
+ * 切换主题
107
+ *
108
+ * @param name - 主题名称
109
+ * @param container - CSS 变量挂载的实例容器;省略时使用已有容器。
110
+ */
111
+ setTheme(t, r) {
112
+ var s;
113
+ const n = t !== "dark" && this.themes.has(t) ? t : Ln(t), a = this.themes.get(n);
114
+ if (!a) {
115
+ console.warn(`[ThemeManager] 未找到主题 "${n}", 可用主题:`, this.getAvailableThemes());
116
+ return;
117
+ }
118
+ const o = this.targetElement;
119
+ r && (this.targetElement = r), o && o !== this.targetElement && !((s = this.scopes.get(o)) != null && s.references) && this.releaseScope(o), this.currentTheme = n, this.targetElement && this.ensureScope(this.targetElement), this.scopes.forEach((i, d) => this.applyScope(d, i, a)), this.changeCallbacks.forEach((i) => {
120
+ try {
121
+ i(n, a.isDark);
122
+ } catch (d) {
123
+ console.error("[ThemeManager] 主题变更回调出错:", d);
124
+ }
125
+ });
126
+ }
127
+ /** Bind an additional instance-owned surface without changing the primary container. */
128
+ bindElement(t) {
129
+ const r = this.ensureScope(t);
130
+ r.references += 1;
131
+ const n = this.getThemeDefinition();
132
+ n && this.applyScope(t, r, n);
133
+ let a = !1;
134
+ return () => {
135
+ a || (a = !0, r.references -= 1, !r.references && this.targetElement !== t && this.releaseScope(t));
136
+ };
137
+ }
138
+ ensureScope(t) {
139
+ let r = this.scopes.get(t);
140
+ return r || (r = {
141
+ references: 0,
142
+ original: /* @__PURE__ */ new Map(),
143
+ applied: /* @__PURE__ */ new Map(),
144
+ attributes: new Map(["data-theme", "data-rg-theme", "data-rg-dark"].map((n) => [n, t.getAttribute(n)]))
145
+ }, this.scopes.set(t, r), dt.set(t, this)), r;
146
+ }
147
+ restoreVariable(t, r, n) {
148
+ if (t.style.getPropertyValue(n) !== r.applied.get(n)) return;
149
+ const a = r.original.get(n);
150
+ a != null && a.value ? t.style.setProperty(n, a.value, a.priority) : t.style.removeProperty(n);
151
+ }
152
+ applyScope(t, r, n) {
153
+ const a = { ...Bn, ...n.variables };
154
+ for (const o of r.applied.keys())
155
+ o in a || (this.restoreVariable(t, r, o), r.applied.delete(o));
156
+ for (const [o, s] of Object.entries(a))
157
+ r.original.has(o) || r.original.set(o, {
158
+ value: t.style.getPropertyValue(o),
159
+ priority: t.style.getPropertyPriority(o)
160
+ }), t.style.setProperty(o, s), r.applied.set(o, t.style.getPropertyValue(o));
161
+ t.setAttribute("data-theme", n.name), t.setAttribute("data-rg-theme", n.name), t.setAttribute("data-rg-dark", String(n.isDark));
162
+ }
163
+ releaseScope(t) {
164
+ const r = this.scopes.get(t);
165
+ if (r) {
166
+ for (const n of r.applied.keys()) this.restoreVariable(t, r, n);
167
+ for (const [n, a] of r.attributes)
168
+ a === null ? t.removeAttribute(n) : t.setAttribute(n, a);
169
+ this.scopes.delete(t), dt.get(t) === this && dt.delete(t);
170
+ }
171
+ }
172
+ /**
173
+ * 获取当前主题名称
174
+ */
175
+ getTheme() {
176
+ return this.currentTheme;
177
+ }
178
+ /**
179
+ * 获取当前主题定义
180
+ */
181
+ getThemeDefinition() {
182
+ return this.themes.get(this.currentTheme);
183
+ }
184
+ /**
185
+ * 获取所有可用主题
186
+ */
187
+ getAvailableThemes() {
188
+ return Array.from(this.themes.values()).map((t) => ({
189
+ name: t.name,
190
+ label: t.label,
191
+ isDark: t.isDark
192
+ }));
193
+ }
194
+ /**
195
+ * 跟随系统主题。
196
+ *
197
+ * 为保证编辑器在不同系统设置下保持可读,默认两种系统状态都使用浅色主题。
198
+ *
199
+ * @param darkTheme - 深色系统模式使用的主题名 (默认: 'default')
200
+ * @param lightTheme - 浅色模式使用的主题名 (默认: 'default')
201
+ */
202
+ followSystem(t = "default", r = "default") {
203
+ if (typeof window > "u" || !window.matchMedia) {
204
+ console.warn("[ThemeManager] 当前环境不支持 matchMedia, 无法跟随系统主题");
205
+ return;
206
+ }
207
+ this.unfollowSystem(), this.systemThemeQuery = window.matchMedia("(prefers-color-scheme: dark)"), this.setTheme(this.systemThemeQuery.matches ? t : r), this.systemThemeHandler = (n) => {
208
+ this.setTheme(n.matches ? t : r);
209
+ }, this.systemThemeQuery.addEventListener("change", this.systemThemeHandler);
210
+ }
211
+ /**
212
+ * 停止跟随系统主题
213
+ */
214
+ unfollowSystem() {
215
+ this.systemThemeQuery && this.systemThemeHandler && (this.systemThemeQuery.removeEventListener("change", this.systemThemeHandler), this.systemThemeQuery = null, this.systemThemeHandler = null);
216
+ }
217
+ /**
218
+ * 监听主题变更
219
+ *
220
+ * @param callback - 变更回调 (themeName, isDark)
221
+ * @returns 取消监听函数
222
+ */
223
+ onChange(t) {
224
+ return this.changeCallbacks.add(t), () => {
225
+ this.changeCallbacks.delete(t);
226
+ };
227
+ }
228
+ /**
229
+ * 销毁主题管理器
230
+ */
231
+ destroy() {
232
+ this.unfollowSystem(), this.changeCallbacks.clear();
233
+ for (const t of this.scopes.keys()) this.releaseScope(t);
234
+ this.targetElement = null, this.themes.clear();
235
+ }
236
+ }
237
+ const Za = {
238
+ name: "light",
239
+ label: "明亮",
240
+ isDark: !1,
241
+ variables: {
242
+ // ---- 全局背景 ----
243
+ "--rg-bg-primary": "#ffffff",
244
+ "--rg-bg-secondary": "#f8f9fc",
245
+ "--rg-bg-tertiary": "#f0f2f5",
246
+ "--rg-bg-hover": "rgba(59, 130, 246, 0.06)",
247
+ "--rg-bg-active": "rgba(59, 130, 246, 0.1)",
248
+ "--rg-bg-overlay": "rgba(0, 0, 0, 0.45)",
249
+ // ---- 文字颜色 ----
250
+ "--rg-text-primary": "#1a1d23",
251
+ "--rg-text-secondary": "#5f6672",
252
+ "--rg-text-tertiary": "#9ca3af",
253
+ "--rg-text-inverse": "#ffffff",
254
+ "--rg-text-link": "#3b82f6",
255
+ "--rg-text-link-hover": "#2563eb",
256
+ // ---- 边框 ----
257
+ "--rg-border-primary": "#e5e7eb",
258
+ "--rg-border-secondary": "#d1d5db",
259
+ "--rg-border-focus": "#3b82f6",
260
+ "--rg-border-error": "#ef4444",
261
+ "--rg-border-radius": "8px",
262
+ "--rg-border-radius-sm": "4px",
263
+ "--rg-border-radius-lg": "12px",
264
+ "--rg-border-radius-xl": "16px",
265
+ // ---- 阴影 ----
266
+ "--rg-shadow-sm": "0 1px 2px rgba(0, 0, 0, 0.04)",
267
+ "--rg-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.08)",
268
+ "--rg-shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.12)",
269
+ "--rg-shadow-xl": "0 16px 48px rgba(0, 0, 0, 0.16)",
270
+ "--rg-shadow-focus": "0 0 0 3px rgba(59, 130, 246, 0.25)",
271
+ "--rg-shadow-inset": "inset 0 2px 4px rgba(0, 0, 0, 0.04)",
272
+ // ---- 画布 ----
273
+ "--rg-canvas-bg": "#f8f9fc",
274
+ "--rg-canvas-grid-color": "#e8eaee",
275
+ "--rg-canvas-grid-size": "20px",
276
+ // ---- 节点分类色 (背景/边框) ----
277
+ "--rg-node-filter-bg": "#fef9c3",
278
+ "--rg-node-filter-border": "#facc15",
279
+ "--rg-node-filter-text": "#854d0e",
280
+ "--rg-node-transform-bg": "#dbeafe",
281
+ "--rg-node-transform-border": "#60a5fa",
282
+ "--rg-node-transform-text": "#1e40af",
283
+ "--rg-node-action-bg": "#fce7f3",
284
+ "--rg-node-action-border": "#f472b6",
285
+ "--rg-node-action-text": "#9d174d",
286
+ "--rg-node-external-bg": "#ffedd5",
287
+ "--rg-node-external-border": "#fb923c",
288
+ "--rg-node-external-text": "#9a3412",
289
+ "--rg-node-flow-bg": "#ede9fe",
290
+ "--rg-node-flow-border": "#a78bfa",
291
+ "--rg-node-flow-text": "#5b21b6",
292
+ "--rg-node-start-bg": "linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%)",
293
+ "--rg-node-start-border": "#6366f1",
294
+ "--rg-node-start-text": "#ffffff",
295
+ // ---- 节点通用 ----
296
+ "--rg-node-shadow": "0 2px 8px rgba(0, 0, 0, 0.08)",
297
+ "--rg-node-shadow-hover": "0 4px 16px rgba(0, 0, 0, 0.14)",
298
+ "--rg-node-shadow-selected": "0 0 0 2px #3b82f6, 0 4px 16px rgba(59, 130, 246, 0.2)",
299
+ "--rg-node-width": "180px",
300
+ "--rg-node-min-height": "40px",
301
+ "--rg-node-font-size": "13px",
302
+ // ---- 连接线 ----
303
+ "--rg-edge-color": "#94a3b8",
304
+ "--rg-edge-color-hover": "#3b82f6",
305
+ "--rg-edge-color-selected": "#2563eb",
306
+ "--rg-edge-width": "2px",
307
+ "--rg-edge-label-bg": "#ffffff",
308
+ "--rg-edge-label-color": "#64748b",
309
+ "--rg-edge-label-font-size": "11px",
310
+ // ---- 工具栏 ----
311
+ "--rg-toolbar-bg": "#ffffff",
312
+ "--rg-toolbar-border": "#e5e7eb",
313
+ "--rg-toolbar-shadow": "0 2px 8px rgba(0, 0, 0, 0.06)",
314
+ "--rg-toolbar-btn-bg": "transparent",
315
+ "--rg-toolbar-btn-bg-hover": "rgba(59, 130, 246, 0.08)",
316
+ "--rg-toolbar-btn-bg-active": "rgba(59, 130, 246, 0.15)",
317
+ "--rg-toolbar-btn-color": "#5f6672",
318
+ "--rg-toolbar-btn-color-hover": "#3b82f6",
319
+ "--rg-toolbar-btn-radius": "6px",
320
+ // ---- 侧边栏 ----
321
+ "--rg-sidebar-bg": "#ffffff",
322
+ "--rg-sidebar-border": "#e5e7eb",
323
+ "--rg-sidebar-width": "260px",
324
+ "--rg-sidebar-item-bg-hover": "rgba(59, 130, 246, 0.06)",
325
+ "--rg-sidebar-item-bg-active": "rgba(59, 130, 246, 0.1)",
326
+ "--rg-sidebar-group-header-bg": "#f8f9fc",
327
+ // ---- 属性面板 ----
328
+ "--rg-panel-bg": "#ffffff",
329
+ "--rg-panel-border": "#e5e7eb",
330
+ "--rg-panel-width": "320px",
331
+ "--rg-panel-shadow": "-4px 0 16px rgba(0, 0, 0, 0.06)",
332
+ // ---- 输入框 ----
333
+ "--rg-input-bg": "#ffffff",
334
+ "--rg-input-border": "#d1d5db",
335
+ "--rg-input-border-focus": "#3b82f6",
336
+ "--rg-input-text": "#1a1d23",
337
+ "--rg-input-placeholder": "#9ca3af",
338
+ "--rg-input-shadow-focus": "0 0 0 3px rgba(59, 130, 246, 0.15)",
339
+ // ---- 按钮 ----
340
+ "--rg-btn-primary-bg": "linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)",
341
+ "--rg-btn-primary-bg-hover": "linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)",
342
+ "--rg-btn-primary-text": "#ffffff",
343
+ "--rg-btn-primary-shadow": "0 2px 6px rgba(59, 130, 246, 0.3)",
344
+ "--rg-btn-secondary-bg": "#f3f4f6",
345
+ "--rg-btn-secondary-bg-hover": "#e5e7eb",
346
+ "--rg-btn-secondary-text": "#374151",
347
+ "--rg-btn-danger-bg": "#ef4444",
348
+ "--rg-btn-danger-bg-hover": "#dc2626",
349
+ "--rg-btn-danger-text": "#ffffff",
350
+ // ---- 状态色 ----
351
+ "--rg-color-success": "#10b981",
352
+ "--rg-color-warning": "#f59e0b",
353
+ "--rg-color-error": "#ef4444",
354
+ "--rg-color-info": "#3b82f6",
355
+ // ---- 动画 ----
356
+ "--rg-transition-fast": "0.15s ease",
357
+ "--rg-transition-normal": "0.25s ease",
358
+ "--rg-transition-slow": "0.35s ease",
359
+ "--rg-transition-spring": "0.4s cubic-bezier(0.34, 1.56, 0.64, 1)"
360
+ }
361
+ }, eo = {
362
+ name: "dark",
363
+ label: "暗色",
364
+ isDark: !0,
365
+ variables: {
366
+ // ---- 全局背景 ----
367
+ "--rg-bg-primary": "#1a1b1e",
368
+ "--rg-bg-secondary": "#212226",
369
+ "--rg-bg-tertiary": "#2a2b30",
370
+ "--rg-bg-hover": "rgba(99, 102, 241, 0.1)",
371
+ "--rg-bg-active": "rgba(99, 102, 241, 0.18)",
372
+ "--rg-bg-overlay": "rgba(0, 0, 0, 0.6)",
373
+ // ---- 文字颜色 ----
374
+ "--rg-text-primary": "#e4e5e9",
375
+ "--rg-text-secondary": "#9ca0aa",
376
+ "--rg-text-tertiary": "#6b7080",
377
+ "--rg-text-inverse": "#1a1b1e",
378
+ "--rg-text-link": "#818cf8",
379
+ "--rg-text-link-hover": "#a5b4fc",
380
+ // ---- 边框 ----
381
+ "--rg-border-primary": "#333540",
382
+ "--rg-border-secondary": "#3f4150",
383
+ "--rg-border-focus": "#818cf8",
384
+ "--rg-border-error": "#f87171",
385
+ "--rg-border-radius": "8px",
386
+ "--rg-border-radius-sm": "4px",
387
+ "--rg-border-radius-lg": "12px",
388
+ "--rg-border-radius-xl": "16px",
389
+ // ---- 阴影 (暗色主题阴影更深) ----
390
+ "--rg-shadow-sm": "0 1px 3px rgba(0, 0, 0, 0.3)",
391
+ "--rg-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.4)",
392
+ "--rg-shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.5)",
393
+ "--rg-shadow-xl": "0 16px 48px rgba(0, 0, 0, 0.6)",
394
+ "--rg-shadow-focus": "0 0 0 3px rgba(129, 140, 248, 0.3)",
395
+ "--rg-shadow-inset": "inset 0 2px 4px rgba(0, 0, 0, 0.2)",
396
+ // ---- 画布 ----
397
+ "--rg-canvas-bg": "#1e1f23",
398
+ "--rg-canvas-grid-color": "#2a2c32",
399
+ "--rg-canvas-grid-size": "20px",
400
+ // ---- 节点分类色 (暗色适配 — 降低亮度、增加饱和度) ----
401
+ "--rg-node-filter-bg": "rgba(250, 204, 21, 0.12)",
402
+ "--rg-node-filter-border": "#ca8a04",
403
+ "--rg-node-filter-text": "#fde047",
404
+ "--rg-node-transform-bg": "rgba(96, 165, 250, 0.12)",
405
+ "--rg-node-transform-border": "#3b82f6",
406
+ "--rg-node-transform-text": "#93c5fd",
407
+ "--rg-node-action-bg": "rgba(244, 114, 182, 0.12)",
408
+ "--rg-node-action-border": "#ec4899",
409
+ "--rg-node-action-text": "#f9a8d4",
410
+ "--rg-node-external-bg": "rgba(251, 146, 60, 0.12)",
411
+ "--rg-node-external-border": "#f97316",
412
+ "--rg-node-external-text": "#fdba74",
413
+ "--rg-node-flow-bg": "rgba(167, 139, 250, 0.12)",
414
+ "--rg-node-flow-border": "#8b5cf6",
415
+ "--rg-node-flow-text": "#c4b5fd",
416
+ "--rg-node-start-bg": "linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%)",
417
+ "--rg-node-start-border": "#6366f1",
418
+ "--rg-node-start-text": "#ffffff",
419
+ // ---- 节点通用 ----
420
+ "--rg-node-shadow": "0 2px 8px rgba(0, 0, 0, 0.3)",
421
+ "--rg-node-shadow-hover": "0 4px 16px rgba(0, 0, 0, 0.4)",
422
+ "--rg-node-shadow-selected": "0 0 0 2px #818cf8, 0 4px 16px rgba(129, 140, 248, 0.25)",
423
+ "--rg-node-width": "180px",
424
+ "--rg-node-min-height": "40px",
425
+ "--rg-node-font-size": "13px",
426
+ // ---- 连接线 ----
427
+ "--rg-edge-color": "#4b5563",
428
+ "--rg-edge-color-hover": "#818cf8",
429
+ "--rg-edge-color-selected": "#a5b4fc",
430
+ "--rg-edge-width": "2px",
431
+ "--rg-edge-label-bg": "#2a2b30",
432
+ "--rg-edge-label-color": "#9ca0aa",
433
+ "--rg-edge-label-font-size": "11px",
434
+ // ---- 工具栏 ----
435
+ "--rg-toolbar-bg": "#212226",
436
+ "--rg-toolbar-border": "#333540",
437
+ "--rg-toolbar-shadow": "0 2px 8px rgba(0, 0, 0, 0.3)",
438
+ "--rg-toolbar-btn-bg": "transparent",
439
+ "--rg-toolbar-btn-bg-hover": "rgba(129, 140, 248, 0.1)",
440
+ "--rg-toolbar-btn-bg-active": "rgba(129, 140, 248, 0.2)",
441
+ "--rg-toolbar-btn-color": "#9ca0aa",
442
+ "--rg-toolbar-btn-color-hover": "#818cf8",
443
+ "--rg-toolbar-btn-radius": "6px",
444
+ // ---- 侧边栏 ----
445
+ "--rg-sidebar-bg": "#212226",
446
+ "--rg-sidebar-border": "#333540",
447
+ "--rg-sidebar-width": "260px",
448
+ "--rg-sidebar-item-bg-hover": "rgba(129, 140, 248, 0.08)",
449
+ "--rg-sidebar-item-bg-active": "rgba(129, 140, 248, 0.15)",
450
+ "--rg-sidebar-group-header-bg": "#2a2b30",
451
+ // ---- 属性面板 ----
452
+ "--rg-panel-bg": "#212226",
453
+ "--rg-panel-border": "#333540",
454
+ "--rg-panel-width": "320px",
455
+ "--rg-panel-shadow": "-4px 0 16px rgba(0, 0, 0, 0.4)",
456
+ // ---- 输入框 ----
457
+ "--rg-input-bg": "#2a2b30",
458
+ "--rg-input-border": "#3f4150",
459
+ "--rg-input-border-focus": "#818cf8",
460
+ "--rg-input-text": "#e4e5e9",
461
+ "--rg-input-placeholder": "#6b7080",
462
+ "--rg-input-shadow-focus": "0 0 0 3px rgba(129, 140, 248, 0.2)",
463
+ // ---- 按钮 ----
464
+ "--rg-btn-primary-bg": "linear-gradient(135deg, #6366f1 0%, #7c3aed 100%)",
465
+ "--rg-btn-primary-bg-hover": "linear-gradient(135deg, #4f46e5 0%, #6d28d9 100%)",
466
+ "--rg-btn-primary-text": "#ffffff",
467
+ "--rg-btn-primary-shadow": "0 2px 6px rgba(99, 102, 241, 0.3)",
468
+ "--rg-btn-secondary-bg": "#333540",
469
+ "--rg-btn-secondary-bg-hover": "#3f4150",
470
+ "--rg-btn-secondary-text": "#e4e5e9",
471
+ "--rg-btn-danger-bg": "#dc2626",
472
+ "--rg-btn-danger-bg-hover": "#b91c1c",
473
+ "--rg-btn-danger-text": "#ffffff",
474
+ // ---- 状态色 ----
475
+ "--rg-color-success": "#34d399",
476
+ "--rg-color-warning": "#fbbf24",
477
+ "--rg-color-error": "#f87171",
478
+ "--rg-color-info": "#818cf8",
479
+ // ---- 动画 ----
480
+ "--rg-transition-fast": "0.15s ease",
481
+ "--rg-transition-normal": "0.25s ease",
482
+ "--rg-transition-slow": "0.35s ease",
483
+ "--rg-transition-spring": "0.4s cubic-bezier(0.34, 1.56, 0.64, 1)"
484
+ }
485
+ }, to = {
486
+ name: "blue",
487
+ label: "科技蓝",
488
+ isDark: !0,
489
+ variables: {
490
+ // ---- 全局背景 ----
491
+ "--rg-bg-primary": "#0d1b2a",
492
+ "--rg-bg-secondary": "#132338",
493
+ "--rg-bg-tertiary": "#1a2d45",
494
+ "--rg-bg-hover": "rgba(0, 180, 216, 0.1)",
495
+ "--rg-bg-active": "rgba(0, 180, 216, 0.18)",
496
+ "--rg-bg-overlay": "rgba(0, 0, 0, 0.6)",
497
+ // ---- 文字颜色 ----
498
+ "--rg-text-primary": "#caf0f8",
499
+ "--rg-text-secondary": "#90caf9",
500
+ "--rg-text-tertiary": "#5a8aab",
501
+ "--rg-text-inverse": "#0d1b2a",
502
+ "--rg-text-link": "#00b4d8",
503
+ "--rg-text-link-hover": "#48cae4",
504
+ // ---- 边框 ----
505
+ "--rg-border-primary": "#1e3a5f",
506
+ "--rg-border-secondary": "#274c77",
507
+ "--rg-border-focus": "#00b4d8",
508
+ "--rg-border-error": "#f87171",
509
+ "--rg-border-radius": "8px",
510
+ "--rg-border-radius-sm": "4px",
511
+ "--rg-border-radius-lg": "12px",
512
+ "--rg-border-radius-xl": "16px",
513
+ // ---- 阴影 ----
514
+ "--rg-shadow-sm": "0 1px 3px rgba(0, 0, 0, 0.35)",
515
+ "--rg-shadow-md": "0 4px 12px rgba(0, 0, 0, 0.45)",
516
+ "--rg-shadow-lg": "0 8px 24px rgba(0, 0, 0, 0.55)",
517
+ "--rg-shadow-xl": "0 16px 48px rgba(0, 0, 0, 0.65)",
518
+ "--rg-shadow-focus": "0 0 0 3px rgba(0, 180, 216, 0.3)",
519
+ "--rg-shadow-inset": "inset 0 2px 4px rgba(0, 0, 0, 0.25)",
520
+ // ---- 画布 ----
521
+ "--rg-canvas-bg": "#0f2030",
522
+ "--rg-canvas-grid-color": "#162a42",
523
+ "--rg-canvas-grid-size": "20px",
524
+ // ---- 节点分类色 ----
525
+ "--rg-node-filter-bg": "rgba(250, 204, 21, 0.1)",
526
+ "--rg-node-filter-border": "#b8930f",
527
+ "--rg-node-filter-text": "#fde047",
528
+ "--rg-node-transform-bg": "rgba(0, 180, 216, 0.12)",
529
+ "--rg-node-transform-border": "#00b4d8",
530
+ "--rg-node-transform-text": "#90e0ef",
531
+ "--rg-node-action-bg": "rgba(244, 114, 182, 0.1)",
532
+ "--rg-node-action-border": "#ec4899",
533
+ "--rg-node-action-text": "#f9a8d4",
534
+ "--rg-node-external-bg": "rgba(251, 146, 60, 0.1)",
535
+ "--rg-node-external-border": "#f97316",
536
+ "--rg-node-external-text": "#fdba74",
537
+ "--rg-node-flow-bg": "rgba(167, 139, 250, 0.1)",
538
+ "--rg-node-flow-border": "#8b5cf6",
539
+ "--rg-node-flow-text": "#c4b5fd",
540
+ "--rg-node-start-bg": "linear-gradient(135deg, #0077b6 0%, #00b4d8 100%)",
541
+ "--rg-node-start-border": "#0096c7",
542
+ "--rg-node-start-text": "#ffffff",
543
+ // ---- 节点通用 ----
544
+ "--rg-node-shadow": "0 2px 8px rgba(0, 0, 0, 0.4)",
545
+ "--rg-node-shadow-hover": "0 4px 16px rgba(0, 180, 216, 0.2)",
546
+ "--rg-node-shadow-selected": "0 0 0 2px #00b4d8, 0 4px 16px rgba(0, 180, 216, 0.3)",
547
+ "--rg-node-width": "180px",
548
+ "--rg-node-min-height": "40px",
549
+ "--rg-node-font-size": "13px",
550
+ // ---- 连接线 ----
551
+ "--rg-edge-color": "#274c77",
552
+ "--rg-edge-color-hover": "#00b4d8",
553
+ "--rg-edge-color-selected": "#48cae4",
554
+ "--rg-edge-width": "2px",
555
+ "--rg-edge-label-bg": "#132338",
556
+ "--rg-edge-label-color": "#90caf9",
557
+ "--rg-edge-label-font-size": "11px",
558
+ // ---- 工具栏 ----
559
+ "--rg-toolbar-bg": "#132338",
560
+ "--rg-toolbar-border": "#1e3a5f",
561
+ "--rg-toolbar-shadow": "0 2px 8px rgba(0, 0, 0, 0.35)",
562
+ "--rg-toolbar-btn-bg": "transparent",
563
+ "--rg-toolbar-btn-bg-hover": "rgba(0, 180, 216, 0.1)",
564
+ "--rg-toolbar-btn-bg-active": "rgba(0, 180, 216, 0.2)",
565
+ "--rg-toolbar-btn-color": "#90caf9",
566
+ "--rg-toolbar-btn-color-hover": "#00b4d8",
567
+ "--rg-toolbar-btn-radius": "6px",
568
+ // ---- 侧边栏 ----
569
+ "--rg-sidebar-bg": "#132338",
570
+ "--rg-sidebar-border": "#1e3a5f",
571
+ "--rg-sidebar-width": "260px",
572
+ "--rg-sidebar-item-bg-hover": "rgba(0, 180, 216, 0.08)",
573
+ "--rg-sidebar-item-bg-active": "rgba(0, 180, 216, 0.15)",
574
+ "--rg-sidebar-group-header-bg": "#1a2d45",
575
+ // ---- 属性面板 ----
576
+ "--rg-panel-bg": "#132338",
577
+ "--rg-panel-border": "#1e3a5f",
578
+ "--rg-panel-width": "320px",
579
+ "--rg-panel-shadow": "-4px 0 16px rgba(0, 0, 0, 0.45)",
580
+ // ---- 输入框 ----
581
+ "--rg-input-bg": "#1a2d45",
582
+ "--rg-input-border": "#274c77",
583
+ "--rg-input-border-focus": "#00b4d8",
584
+ "--rg-input-text": "#caf0f8",
585
+ "--rg-input-placeholder": "#5a8aab",
586
+ "--rg-input-shadow-focus": "0 0 0 3px rgba(0, 180, 216, 0.2)",
587
+ // ---- 按钮 ----
588
+ "--rg-btn-primary-bg": "linear-gradient(135deg, #0077b6 0%, #00b4d8 100%)",
589
+ "--rg-btn-primary-bg-hover": "linear-gradient(135deg, #005f8d 0%, #0096c7 100%)",
590
+ "--rg-btn-primary-text": "#ffffff",
591
+ "--rg-btn-primary-shadow": "0 2px 6px rgba(0, 180, 216, 0.3)",
592
+ "--rg-btn-secondary-bg": "#1a2d45",
593
+ "--rg-btn-secondary-bg-hover": "#274c77",
594
+ "--rg-btn-secondary-text": "#caf0f8",
595
+ "--rg-btn-danger-bg": "#dc2626",
596
+ "--rg-btn-danger-bg-hover": "#b91c1c",
597
+ "--rg-btn-danger-text": "#ffffff",
598
+ // ---- 状态色 ----
599
+ "--rg-color-success": "#34d399",
600
+ "--rg-color-warning": "#fbbf24",
601
+ "--rg-color-error": "#f87171",
602
+ "--rg-color-info": "#00b4d8",
603
+ // ---- 动画 ----
604
+ "--rg-transition-fast": "0.15s ease",
605
+ "--rg-transition-normal": "0.25s ease",
606
+ "--rg-transition-slow": "0.35s ease",
607
+ "--rg-transition-spring": "0.4s cubic-bezier(0.34, 1.56, 0.64, 1)"
608
+ }
609
+ };
610
+ function Fn(e) {
611
+ if (e.getElementById("rg-dialog-provider-styles")) return;
612
+ const t = e.createElement("style");
613
+ t.id = "rg-dialog-provider-styles", t.textContent = `
614
+ .rg-dialog-overlay { position:fixed; inset:0; z-index:var(--hb-z-confirmation,10050); display:flex; align-items:center; justify-content:center; padding:16px; box-sizing:border-box; background:rgba(15,23,42,.28); backdrop-filter:blur(2px); font-family:var(--hb-font-family,system-ui,sans-serif); }
615
+ .rg-dialog { box-sizing:border-box; width:420px; max-width:100%; max-height:calc(100dvh - 32px); overflow:auto; background:var(--hb-bg-drawer,#fff); border:1px solid var(--hb-border-light,#e5e7eb); border-radius:8px; box-shadow:0 18px 48px rgba(15,23,42,.22); padding:18px; outline:none; }
616
+ .rg-dialog-title { color:var(--hb-text-primary,#111827); font-size:15px; font-weight:700; line-height:1.4; overflow-wrap:anywhere; }
617
+ .rg-dialog-message { color:var(--hb-text-secondary,#4b5563); font-size:13px; line-height:1.7; white-space:pre-wrap; overflow-wrap:anywhere; }
618
+ .rg-dialog-title + .rg-dialog-message { margin-top:8px; }
619
+ .rg-dialog-input { display:block; width:100%; box-sizing:border-box; margin-top:12px; padding:7px 10px; font:inherit; font-size:13px; line-height:1.5; color:var(--hb-text-primary,#333); background:var(--hb-bg-input,#fff); border:1px solid var(--hb-border-color,#dcdfe6); border-radius:6px; outline:none; }
620
+ .rg-dialog-input:focus { border-color:var(--hb-color-primary,#409eff); box-shadow:0 0 0 2px var(--hb-border-light,#e5e7eb); }
621
+ .rg-dialog-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; margin-top:18px; }
622
+ .rg-dialog-btn { min-height:32px; max-width:100%; padding:6px 13px; border-radius:6px; font:inherit; font-size:12px; cursor:pointer; border:1px solid transparent; overflow-wrap:anywhere; }
623
+ .rg-dialog-btn:focus-visible { outline:2px solid var(--hb-color-primary,#409eff); outline-offset:2px; }
624
+ .rg-dialog-btn-default { background:var(--hb-bg-drawer,#fff); color:var(--hb-text-primary,#333); border-color:var(--hb-border-color,#dcdfe6); }
625
+ .rg-dialog-btn-default:hover { background:var(--hb-bg-hover,#f5f7fa); }
626
+ .rg-dialog-btn-primary { color:var(--rg-btn-primary-text,#fff); background:var(--hb-color-primary,#409eff); border-color:var(--hb-color-primary,#409eff); }
627
+ .rg-dialog-btn-danger { color:var(--rg-btn-danger-text,#fff); background:var(--hb-color-danger,#f56c6c); border-color:var(--hb-color-danger,#f56c6c); }
628
+ .rg-dialog-btn-primary:hover,.rg-dialog-btn-danger:hover { opacity:.9; }
629
+ `, e.head.appendChild(t);
630
+ }
631
+ const cr = /* @__PURE__ */ new WeakMap();
632
+ function Gn(e) {
633
+ return typeof e == "function" ? e() : e || document.body;
634
+ }
635
+ function je(e) {
636
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
637
+ }
638
+ function Vn(e = {}) {
639
+ const t = e.t || ((o, s) => s), r = /* @__PURE__ */ new Set();
640
+ let n = !1;
641
+ function a(o, s, i, d) {
642
+ var g;
643
+ if (n || typeof document > "u") return Promise.resolve(i);
644
+ const c = Gn(e.container);
645
+ if (!(c != null && c.isConnected)) return Promise.resolve(i);
646
+ const u = c.ownerDocument;
647
+ Fn(u);
648
+ const f = cr.get(u) || [];
649
+ cr.set(u, f);
650
+ const b = u.activeElement, m = u.createElement("div");
651
+ m.className = "rg-dialog-overlay";
652
+ const y = (g = e.getThemeClass) == null ? void 0 : g.call(e);
653
+ y && m.classList.add(...y.split(/\s+/).filter(Boolean));
654
+ const w = u.createElement("div");
655
+ w.className = "rg-dialog", w.setAttribute("role", "dialog"), w.setAttribute("aria-modal", "true");
656
+ const v = "type" in s ? s.type : void 0;
657
+ v && w.classList.add(`rg-dialog-type-${v}`);
658
+ const p = s.title || "", _ = s.confirmText || t("editor.dialog.confirm", "确定"), x = "cancelText" in s && s.cancelText || t("editor.dialog.cancel", "取消");
659
+ w.setAttribute("aria-label", p || s.message);
660
+ const h = s;
661
+ w.innerHTML = `
662
+ ${p ? `<div class="rg-dialog-title">${je(p)}</div>` : ""}
663
+ <div class="rg-dialog-message">${je(s.message)}</div>
664
+ ${o === "prompt" ? `<input type="text" class="rg-dialog-input" value="${je(h.defaultValue || "")}" placeholder="${je(h.placeholder || "")}" />` : ""}
665
+ <div class="rg-dialog-actions">
666
+ ${o !== "alert" ? `<button type="button" class="rg-dialog-btn rg-dialog-btn-default" data-dialog-action="cancel">${je(x)}</button>` : ""}
667
+ <button type="button" class="rg-dialog-btn ${v === "danger" ? "rg-dialog-btn-danger" : "rg-dialog-btn-primary"}" data-dialog-action="confirm">${je(_)}</button>
668
+ </div>`, m.appendChild(w), c.appendChild(m), f.push(m);
669
+ const l = w.querySelector("input");
670
+ return new Promise((S) => {
671
+ var le, Z, W;
672
+ let C = !1, A = !1, N;
673
+ const L = () => f[f.length - 1] === m, O = (V) => {
674
+ if (C) return;
675
+ C = !0;
676
+ const ve = L();
677
+ K.disconnect(), clearTimeout(N), u.removeEventListener("keydown", G, !0), r.delete(I), f.splice(f.indexOf(m), 1), m.remove(), ve && (b != null && b.isConnected) && b.focus(), S(V);
678
+ }, I = () => O(i), z = () => {
679
+ if (!m.isConnected || !c.isConnected) {
680
+ I();
681
+ return;
682
+ }
683
+ L() && !A && O(d(l));
684
+ }, G = (V) => {
685
+ var ve, _e, he;
686
+ if (L()) {
687
+ if (!m.isConnected || !c.isConnected) {
688
+ I();
689
+ return;
690
+ }
691
+ if (["Enter", "Escape", "Tab"].includes(V.key) && (V.stopImmediatePropagation(), !(A || V.isComposing || V.keyCode === 229)))
692
+ if (V.preventDefault(), V.key === "Escape") I();
693
+ else if (V.key === "Enter")
694
+ V.repeat || (((_e = (ve = V.target) == null ? void 0 : ve.dataset) == null ? void 0 : _e.dialogAction) === "cancel" ? I() : z());
695
+ else {
696
+ const oe = Array.from(w.querySelectorAll("input,button")), we = oe.indexOf(u.activeElement);
697
+ (he = oe[(we + (V.shiftKey ? -1 : 1) + oe.length) % oe.length]) == null || he.focus();
698
+ }
699
+ }
700
+ }, K = new MutationObserver(() => {
701
+ (!m.isConnected || !c.isConnected) && I();
702
+ });
703
+ K.observe(u.documentElement, { childList: !0, subtree: !0 }), r.add(I), m.addEventListener("compositionstart", () => {
704
+ clearTimeout(N), A = !0;
705
+ }), m.addEventListener("compositionend", () => {
706
+ N = setTimeout(() => {
707
+ A = !1;
708
+ }, 0);
709
+ }), m.addEventListener("click", (V) => {
710
+ L() && V.target === m && I();
711
+ }), (le = w.querySelector('[data-dialog-action="cancel"]')) == null || le.addEventListener("click", () => {
712
+ L() && I();
713
+ }), (Z = w.querySelector('[data-dialog-action="confirm"]')) == null || Z.addEventListener("click", z), u.addEventListener("keydown", G, !0), (W = l || w.querySelector('[data-dialog-action="confirm"]')) == null || W.focus(), l == null || l.select();
714
+ });
715
+ }
716
+ return {
717
+ confirm: (o) => a("confirm", o, !1, () => !0),
718
+ prompt: (o) => a("prompt", o, null, (s) => (s == null ? void 0 : s.value) ?? ""),
719
+ alert: (o) => a("alert", o, void 0, () => {
720
+ }),
721
+ destroy() {
722
+ n = !0, Array.from(r).reverse().forEach((o) => o());
723
+ }
724
+ };
725
+ }
726
+ const zr = /* @__PURE__ */ new Set([
727
+ // Connection status polling
728
+ "connectionState",
729
+ "connectionMessage",
730
+ "connectionStale",
731
+ "connectionLabel",
732
+ "connectionTooltip",
733
+ "connectionKind",
734
+ "_connectionStatus",
735
+ // Topology diagnostics
736
+ "topologyWarnings",
737
+ "_topologyDiagnostics",
738
+ // Debug / run highlighting
739
+ "__rgLoopStamp",
740
+ "__loopDragTo",
741
+ "runCount",
742
+ "runDuration",
743
+ "debugHighlight",
744
+ "status",
745
+ "_debugState",
746
+ "_runMetrics"
747
+ ]);
748
+ function Jn(e) {
749
+ return ct(e, "root");
750
+ }
751
+ function ct(e, t) {
752
+ if (e == null || typeof e != "object") return e;
753
+ if (Array.isArray(e))
754
+ return e.map((i) => ct(i, t === "root" ? "element" : "data"));
755
+ const r = e, n = t === "root" && Array.isArray(r.nodes) && Array.isArray(r.edges) && !("ruleChain" in r), a = (t === "root" || t === "element") && typeof r.id == "string" && typeof r.type == "string" && (typeof r.x == "number" && typeof r.y == "number" || typeof r.sourceNodeId == "string" && typeof r.targetNodeId == "string"), o = Object.keys(r).filter((i) => t !== "runtime-properties" || !zr.has(i)).sort(), s = [];
756
+ for (const i of o) {
757
+ const d = r[i], c = n && (i === "nodes" || i === "edges") && Array.isArray(d) ? d.map((u) => ct(u, "element")) : ct(d, a && i === "properties" ? "runtime-properties" : "data");
758
+ s.push([i, c]);
759
+ }
760
+ return Object.fromEntries(s);
761
+ }
762
+ function Ot(e) {
763
+ return JSON.stringify(Jn(e)) ?? "undefined";
764
+ }
765
+ function ro(e, t) {
766
+ return Ot(e) === Ot(t);
767
+ }
768
+ function no() {
769
+ return new Set(zr);
770
+ }
771
+ function ao(e) {
772
+ const t = e.windowMs ?? 300;
773
+ let r = null, n = !1;
774
+ function a() {
775
+ r !== null && (clearTimeout(r), r = null);
776
+ }
777
+ function o() {
778
+ n || (a(), r = setTimeout(() => {
779
+ r = null, n || e.onReconcile();
780
+ }, t));
781
+ }
782
+ function s() {
783
+ return r !== null;
784
+ }
785
+ function i() {
786
+ n = !0, a();
787
+ }
788
+ return { suppress: o, isSuppressed: s, destroy: i };
789
+ }
790
+ const Un = /* @__PURE__ */ new Set([
791
+ "createTime",
792
+ "updateTime",
793
+ "username",
794
+ "lastModified",
795
+ "lastModifiedTime"
796
+ ]);
797
+ function ie(e) {
798
+ return !!e && typeof e == "object" && !Array.isArray(e);
799
+ }
800
+ function oo(e) {
801
+ return ie(e) && ie(e.ruleChain) && typeof e.ruleChain.id == "string" && e.ruleChain.id.length > 0 && ie(e.metadata) && Array.isArray(e.metadata.nodes) && Array.isArray(e.metadata.connections);
802
+ }
803
+ function ft(e) {
804
+ return Array.isArray(e) ? `[${e.map((t) => ft(t)).join(",")}]` : ie(e) ? `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${ft(e[t])}`).join(",")}}` : JSON.stringify(e);
805
+ }
806
+ function pe(e) {
807
+ if (Array.isArray(e)) return e.map((r) => pe(r));
808
+ if (!ie(e)) return e;
809
+ const t = {};
810
+ return Object.keys(e).sort().forEach((r) => {
811
+ const n = pe(e[r]);
812
+ n !== void 0 && (t[r] = n);
813
+ }), t;
814
+ }
815
+ function Wn(e, t = {}) {
816
+ if (!ie(e)) return;
817
+ const r = {};
818
+ return Object.keys(e).sort().forEach((n) => {
819
+ if (Un.has(n) || t.ruleChain && n === "noDefaultInput" && e[n] !== !0) return;
820
+ if (t.ruleChain && (n === "layoutX" || n === "layoutY")) {
821
+ const o = Number(e[n]);
822
+ if (Number.isFinite(o) && o === 280) return;
823
+ }
824
+ const a = pe(e[n]);
825
+ a !== void 0 && (r[n] = a);
826
+ }), Object.keys(r).length > 0 ? r : void 0;
827
+ }
828
+ function Hr(e, t = {}) {
829
+ if (!ie(e)) return pe(e);
830
+ const r = {};
831
+ Object.keys(e).sort().forEach((a) => {
832
+ if (a === "debugMode" || a === "disabled" || a === "additionalInfo" || t.endpoint && (a === "processors" || a === "routers")) return;
833
+ const o = pe(e[a]);
834
+ o !== void 0 && (r[a] = o);
835
+ }), r.debugMode = e.debugMode === !0, r.disabled = e.disabled === !0;
836
+ const n = Wn(e.additionalInfo, t);
837
+ return n !== void 0 && (r.additionalInfo = n), e.configuration == null && (r.configuration = {}), t.endpoint && (e.processors != null && (!Array.isArray(e.processors) || e.processors.length > 0) && (r.processors = pe(e.processors)), r.routers = e.routers == null ? [] : pe(e.routers)), r;
838
+ }
839
+ function ht(e, t, r) {
840
+ if (!ie(e)) return `${t}:${r}`;
841
+ const n = e.id;
842
+ if (typeof n == "string" && n.trim()) return `${t}:id:${n}`;
843
+ const a = e.fromId, o = e.toId;
844
+ return a || o ? `${t}:edge:${String(a || "")}->${String(o || "")}:${String(e.fromPort || "")}:${String(e.toPort || "")}` : `${t}:${ft(e)}`;
845
+ }
846
+ function ur(e, t, r) {
847
+ return Array.isArray(e) ? e.map((n) => Hr(n, r)).sort((n, a) => ht(n, t, 0).localeCompare(ht(a, t, 0))) : [];
848
+ }
849
+ function Kn(e) {
850
+ return Array.isArray(e) ? e.map((t) => pe(t)).sort((t, r) => ht(t, "connection", 0).localeCompare(ht(r, "connection", 0))) : [];
851
+ }
852
+ function Br(e) {
853
+ if (!ie(e)) return null;
854
+ const t = ie(e.ruleChain) ? e.ruleChain : e, r = ie(e.metadata) ? e.metadata : {}, n = Hr(t, { ruleChain: !0 });
855
+ n.root = t.root !== !1, delete n.disabled;
856
+ const a = {};
857
+ Object.keys(r).sort().forEach((f) => {
858
+ if (f === "nodes" || f === "endpoints" || f === "connections" || f === "firstNodeIndex") return;
859
+ const b = pe(r[f]);
860
+ b !== void 0 && (a[f] = b);
861
+ });
862
+ const o = ur(r.nodes, "node"), s = ur(r.endpoints, "endpoint", { endpoint: !0 }), i = Kn(r.connections);
863
+ a.nodes = o, a.endpoints = s, a.connections = i;
864
+ const d = Number(r.firstNodeIndex), c = Array.isArray(r.nodes) ? r.nodes : [], u = Number.isInteger(d) ? c[d] : void 0;
865
+ return ie(u) && typeof u.id == "string" && u.id && (a.firstNodeId = u.id), { ruleChain: n, metadata: a };
866
+ }
867
+ function fr(e) {
868
+ const t = Br(e);
869
+ return t ? ft(t) : "";
870
+ }
871
+ function so(e, t) {
872
+ const r = fr(t);
873
+ return !!r && fr(e) !== r;
874
+ }
875
+ const ke = Object.freeze({}), Yn = /* @__PURE__ */ new Set([
876
+ "none",
877
+ "connected",
878
+ "reconnecting",
879
+ "disconnected",
880
+ "error",
881
+ "unknown"
882
+ ]), It = 5e3, Qn = 15e3, Xn = 3e4, hr = 400;
883
+ function Le(e) {
884
+ return !!e && typeof e == "object" && !Array.isArray(e);
885
+ }
886
+ function Ut(e) {
887
+ if (e == null) return;
888
+ const t = String(e).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [REDACTED]").replace(/\b(authorization|token|api[_-]?key|secret|password)\s*[:=]\s*[^\s,;]+/gi, "$1=[REDACTED]").trim();
889
+ if (t)
890
+ return t.length <= hr ? t : `${t.slice(0, hr - 3)}...`;
891
+ }
892
+ function Fr(e) {
893
+ const t = String(e ?? "").trim().toLowerCase();
894
+ return Yn.has(t) ? t : "unknown";
895
+ }
896
+ function qt(e) {
897
+ if (!Le(e) || !Object.prototype.hasOwnProperty.call(e, "data")) return e;
898
+ if (e.success === !1 || e.ok === !1) return null;
899
+ const t = ["code", "status", "success", "ok", "message", "msg", "error"];
900
+ return Object.keys(e).length === 1 || t.some((r) => Object.prototype.hasOwnProperty.call(e, r)) ? e.data : e;
901
+ }
902
+ function gr(e) {
903
+ const t = qt(e);
904
+ if (!Le(t)) return ke;
905
+ const r = {};
906
+ for (const [n, a] of Object.entries(t)) {
907
+ const o = String(n).trim();
908
+ if (!o || !Le(a) || !Object.prototype.hasOwnProperty.call(a, "status")) continue;
909
+ const s = Fr(a.status), i = Ut(a.message);
910
+ r[o] = Object.freeze({
911
+ status: s,
912
+ ...i ? { message: i } : {}
913
+ });
914
+ }
915
+ return Object.freeze(r);
916
+ }
917
+ function br() {
918
+ return {
919
+ chainId: null,
920
+ nodes: ke,
921
+ shared: ke,
922
+ chainPhase: "idle",
923
+ sharedPhase: "idle",
924
+ chainUpdatedAt: null,
925
+ sharedUpdatedAt: null
926
+ };
927
+ }
928
+ class io {
929
+ constructor() {
930
+ this.store = new jn(br()), this.destroyed = !1;
931
+ }
932
+ getState() {
933
+ return this.store.getState();
934
+ }
935
+ subscribe(t) {
936
+ return this.destroyed ? () => {
937
+ } : this.store.subscribe(t);
938
+ }
939
+ update(t) {
940
+ this.destroyed || this.store.setState(t);
941
+ }
942
+ reset() {
943
+ this.destroyed || this.store.reset(br());
944
+ }
945
+ destroy() {
946
+ this.destroyed || (this.destroyed = !0, this.store.destroy());
947
+ }
948
+ }
949
+ function jt(e) {
950
+ if (!Le(e)) return null;
951
+ const t = Number(e.status);
952
+ if (Number.isFinite(t)) return t;
953
+ if (Le(e.response)) {
954
+ const r = Number(e.response.status);
955
+ if (Number.isFinite(r)) return r;
956
+ }
957
+ return null;
958
+ }
959
+ function pr(e) {
960
+ return typeof DOMException < "u" && e instanceof DOMException && e.name === "AbortError" || Le(e) && e.name === "AbortError";
961
+ }
962
+ function mr(e) {
963
+ const t = jt(e);
964
+ return t !== null ? `HTTP ${t}` : Ut(e instanceof Error ? e.message : e) || "Connection status request failed";
965
+ }
966
+ function Ge(e) {
967
+ return e === "unauthorized" || e === "unsupported";
968
+ }
969
+ function yr(e) {
970
+ const t = Object.values(e).filter((r) => r.status !== "none");
971
+ return t.length === 0 ? Xn : t.every((r) => r.status === "connected") ? Qn : It;
972
+ }
973
+ function vr(e, t) {
974
+ return Ge(e) || e === "error" || e === "stale" ? e : Object.keys(t).length > 0 ? "stale" : "idle";
975
+ }
976
+ class lo {
977
+ constructor(t, r, n = {}) {
978
+ var a, o;
979
+ this.store = t, this.provider = r, this.chainTimer = null, this.sharedTimer = null, this.chainRequest = null, this.sharedRequest = null, this.chainGeneration = 0, this.sharedGeneration = 0, this.sharedConsumers = 0, this.destroyed = !1, this.onVisibilityChange = () => {
980
+ var d;
981
+ if (this.destroyed) return;
982
+ const s = !((d = this.visibilityDocument) != null && d.hidden);
983
+ if (this.pageVisible === s) return;
984
+ const i = this.canPoll();
985
+ this.pageVisible = s, this.updateVisibility(i);
986
+ }, this.enabled = n.enabled !== !1, this.visible = n.visible !== !1, this.visibilityDocument = n.pauseWhenHidden !== !1 && typeof document < "u" ? document : null, this.pageVisible = !((a = this.visibilityDocument) != null && a.hidden), this.pollIntervalMs = typeof n.pollIntervalMs == "number" && Number.isFinite(n.pollIntervalMs) ? Math.max(250, Math.floor(n.pollIntervalMs)) : void 0, this.now = n.now || (() => Date.now()), (o = this.visibilityDocument) == null || o.addEventListener("visibilitychange", this.onVisibilityChange);
987
+ }
988
+ /** Suspend an inactive host view without clearing snapshots or auth failures. */
989
+ setVisible(t) {
990
+ if (this.destroyed || this.visible === t) return;
991
+ const r = this.canPoll();
992
+ this.visible = t, this.updateVisibility(r);
993
+ }
994
+ canPoll() {
995
+ return !this.destroyed && this.enabled && this.visible && this.pageVisible;
996
+ }
997
+ updateVisibility(t) {
998
+ if (t === this.canPoll()) return;
999
+ if (this.canPoll()) {
1000
+ this.resumePolling();
1001
+ return;
1002
+ }
1003
+ this.chainGeneration++, this.sharedGeneration++, this.stopChainRequest(), this.stopSharedRequest();
1004
+ const r = this.store.getState();
1005
+ this.store.update({
1006
+ chainPhase: vr(r.chainPhase, r.nodes),
1007
+ sharedPhase: vr(r.sharedPhase, r.shared)
1008
+ });
1009
+ }
1010
+ resumePolling() {
1011
+ if (!this.canPoll()) return;
1012
+ const t = this.store.getState();
1013
+ t.chainId && t.chainId !== "__scratch__" && !Ge(t.chainPhase) && this.pollChain(t.chainId, this.chainGeneration), this.sharedConsumers > 0 && !Ge(t.sharedPhase) && this.pollShared(this.sharedGeneration);
1014
+ }
1015
+ setEnabled(t) {
1016
+ this.destroyed || this.enabled === t || (this.enabled = t, this.stopChainRequest(), this.stopSharedRequest(), this.chainGeneration++, this.sharedGeneration++, this.store.update({
1017
+ nodes: ke,
1018
+ shared: ke,
1019
+ chainPhase: "idle",
1020
+ sharedPhase: "idle",
1021
+ chainUpdatedAt: null,
1022
+ sharedUpdatedAt: null,
1023
+ chainError: void 0,
1024
+ sharedError: void 0
1025
+ }), this.resumePolling());
1026
+ }
1027
+ setChain(t) {
1028
+ if (this.destroyed) return;
1029
+ const r = String(t || "").trim();
1030
+ this.stopChainRequest(), this.chainGeneration++, this.store.update({
1031
+ chainId: r || null,
1032
+ nodes: ke,
1033
+ chainPhase: "idle",
1034
+ chainUpdatedAt: null,
1035
+ chainError: void 0
1036
+ }), !(!this.canPoll() || !r || r === "__scratch__") && this.pollChain(r, this.chainGeneration);
1037
+ }
1038
+ /**
1039
+ * Mark a successful API interaction (data load, save, etc.) so the chain
1040
+ * phase reflects that the backend is reachable. Only promotes `idle` and
1041
+ * `error` phases; `ready`, `stale`, terminal, and polling states are left
1042
+ * unchanged to avoid overwriting richer information.
1043
+ */
1044
+ markApiSuccess() {
1045
+ if (this.destroyed) return;
1046
+ const { chainPhase: t } = this.store.getState();
1047
+ (t === "idle" || t === "error") && this.store.update({ chainPhase: "ready", chainError: void 0 });
1048
+ }
1049
+ restartCurrentChain() {
1050
+ this.setChain(this.store.getState().chainId);
1051
+ }
1052
+ restartShared() {
1053
+ this.destroyed || !this.enabled || this.sharedConsumers === 0 || (this.stopSharedRequest(), this.sharedGeneration++, this.store.update({
1054
+ shared: ke,
1055
+ sharedPhase: "idle",
1056
+ sharedUpdatedAt: null,
1057
+ sharedError: void 0
1058
+ }), this.pollShared(this.sharedGeneration));
1059
+ }
1060
+ acquireShared() {
1061
+ if (this.destroyed) return () => {
1062
+ };
1063
+ this.sharedConsumers++, this.sharedConsumers === 1 && (this.sharedGeneration++, this.store.update({ sharedPhase: "idle", sharedError: void 0 }), this.canPoll() && this.pollShared(this.sharedGeneration));
1064
+ let t = !1;
1065
+ return () => {
1066
+ t || (t = !0, this.releaseShared());
1067
+ };
1068
+ }
1069
+ releaseShared() {
1070
+ this.sharedConsumers !== 0 && (this.sharedConsumers--, !(this.sharedConsumers > 0) && (this.stopSharedRequest(), this.sharedGeneration++, this.store.update({
1071
+ shared: ke,
1072
+ sharedPhase: "idle",
1073
+ sharedUpdatedAt: null,
1074
+ sharedError: void 0
1075
+ })));
1076
+ }
1077
+ async pollChain(t, r) {
1078
+ if (!this.canPoll() || this.chainRequest || r !== this.chainGeneration) return;
1079
+ const n = new AbortController();
1080
+ this.chainRequest = n;
1081
+ let a = this.pollIntervalMs ?? It;
1082
+ this.store.getState().chainPhase !== "stale" && this.store.update({ chainPhase: "loading", chainError: void 0 });
1083
+ try {
1084
+ const o = await this.provider.getChainStatuses(t, n.signal);
1085
+ if (!this.isCurrentChain(t, r, n)) return;
1086
+ const s = gr(o);
1087
+ Le(qt(o)) && (a = this.pollIntervalMs ?? yr(s)), this.store.update({
1088
+ nodes: s,
1089
+ chainPhase: "ready",
1090
+ chainUpdatedAt: this.now(),
1091
+ chainError: void 0
1092
+ });
1093
+ } catch (o) {
1094
+ if (pr(o) || !this.isCurrentChain(t, r, n)) return;
1095
+ const s = jt(o), i = this.store.getState(), d = s === 401 || s === 403 ? "unauthorized" : s === 404 || s === 501 ? "unsupported" : Object.keys(i.nodes).length > 0 ? "stale" : "error";
1096
+ this.store.update({ chainPhase: d, chainError: mr(o) });
1097
+ } finally {
1098
+ this.chainRequest === n && (this.chainRequest = null);
1099
+ const o = this.store.getState();
1100
+ this.isCurrentChain(t, r) && !Ge(o.chainPhase) && (this.chainTimer = setTimeout(() => {
1101
+ this.chainTimer = null, this.pollChain(t, r);
1102
+ }, a));
1103
+ }
1104
+ }
1105
+ async pollShared(t) {
1106
+ if (!this.canPoll() || this.sharedConsumers === 0 || this.sharedRequest || t !== this.sharedGeneration) return;
1107
+ const r = new AbortController();
1108
+ this.sharedRequest = r;
1109
+ let n = this.pollIntervalMs ?? It;
1110
+ this.store.getState().sharedPhase !== "stale" && this.store.update({ sharedPhase: "loading", sharedError: void 0 });
1111
+ try {
1112
+ const a = await this.provider.getSharedNodeStatuses(r.signal);
1113
+ if (!this.isCurrentShared(t, r)) return;
1114
+ const o = gr(a);
1115
+ Le(qt(a)) && (n = this.pollIntervalMs ?? yr(o)), this.store.update({
1116
+ shared: o,
1117
+ sharedPhase: "ready",
1118
+ sharedUpdatedAt: this.now(),
1119
+ sharedError: void 0
1120
+ });
1121
+ } catch (a) {
1122
+ if (pr(a) || !this.isCurrentShared(t, r)) return;
1123
+ const o = jt(a), s = this.store.getState(), i = o === 401 || o === 403 ? "unauthorized" : o === 404 || o === 501 ? "unsupported" : Object.keys(s.shared).length > 0 ? "stale" : "error";
1124
+ this.store.update({ sharedPhase: i, sharedError: mr(a) });
1125
+ } finally {
1126
+ this.sharedRequest === r && (this.sharedRequest = null);
1127
+ const a = this.store.getState();
1128
+ this.isCurrentShared(t) && !Ge(a.sharedPhase) && (this.sharedTimer = setTimeout(() => {
1129
+ this.sharedTimer = null, this.pollShared(t);
1130
+ }, n));
1131
+ }
1132
+ }
1133
+ isCurrentChain(t, r, n) {
1134
+ return this.canPoll() && r === this.chainGeneration && this.store.getState().chainId === t && (!n || !n.signal.aborted);
1135
+ }
1136
+ isCurrentShared(t, r) {
1137
+ return this.canPoll() && this.sharedConsumers > 0 && t === this.sharedGeneration && (!r || !r.signal.aborted);
1138
+ }
1139
+ stopChainRequest() {
1140
+ var t;
1141
+ this.chainTimer !== null && clearTimeout(this.chainTimer), this.chainTimer = null, (t = this.chainRequest) == null || t.abort(), this.chainRequest = null;
1142
+ }
1143
+ stopSharedRequest() {
1144
+ var t;
1145
+ this.sharedTimer !== null && clearTimeout(this.sharedTimer), this.sharedTimer = null, (t = this.sharedRequest) == null || t.abort(), this.sharedRequest = null;
1146
+ }
1147
+ destroy() {
1148
+ var t;
1149
+ this.destroyed || (this.destroyed = !0, this.chainGeneration++, this.sharedGeneration++, this.sharedConsumers = 0, this.stopChainRequest(), this.stopSharedRequest(), (t = this.visibilityDocument) == null || t.removeEventListener("visibilitychange", this.onVisibilityChange));
1150
+ }
1151
+ }
1152
+ const Zn = {
1153
+ none: { label: "", kind: "neutral" },
1154
+ connected: { label: "已连接", kind: "success" },
1155
+ reconnecting: { label: "重连中", kind: "warning" },
1156
+ disconnected: { label: "已断开", kind: "neutral" },
1157
+ error: { label: "连接异常", kind: "danger" },
1158
+ unknown: { label: "未知状态", kind: "neutral" }
1159
+ };
1160
+ function ea(e, t = !1, r) {
1161
+ if (!e || e.status === "none") return null;
1162
+ const n = Fr(e.status), a = Zn[n], o = t ? (r == null ? void 0 : r("stale", "状态可能已过期")) || "状态可能已过期" : (r == null ? void 0 : r(n, a.label)) || a.label, s = Ut(e.message);
1163
+ return {
1164
+ visible: !0,
1165
+ state: n,
1166
+ label: o,
1167
+ tooltip: s ? `${o}: ${s}` : o,
1168
+ kind: t ? "neutral" : a.kind,
1169
+ stale: t
1170
+ };
1171
+ }
1172
+ function Wt(e, t) {
1173
+ var f;
1174
+ const r = t instanceof HTMLElement ? t : (t == null ? void 0 : t.rootEl) || (t == null ? void 0 : t._activeDrawerWrapper) || (t == null ? void 0 : t._activeModalWrapper), a = (t instanceof HTMLElement || (f = t == null ? void 0 : t.core) == null ? void 0 : f.theme) || jr(r);
1175
+ if (a != null && a.bindElement) return a.bindElement(e);
1176
+ const o = (r == null ? void 0 : r.closest('[data-theme], [data-rg-theme], [style*="--hb-"], [style*="--rge-"]')) || r, s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), d = e.getAttribute("data-theme"), c = () => {
1177
+ var w, v;
1178
+ const b = (o == null ? void 0 : o.getAttribute("data-theme")) || (o == null ? void 0 : o.getAttribute("data-rg-theme")) || !(t instanceof HTMLElement) && ((t == null ? void 0 : t._currentTheme) || ((w = t == null ? void 0 : t.opts) == null ? void 0 : w.theme)) || "default", m = Jt(b), y = (v = o == null ? void 0 : o.ownerDocument.defaultView) == null ? void 0 : v.getComputedStyle(o);
1179
+ for (const p of Object.keys(m)) {
1180
+ s.has(p) || s.set(p, {
1181
+ value: e.style.getPropertyValue(p),
1182
+ priority: e.style.getPropertyPriority(p)
1183
+ });
1184
+ const _ = y == null ? void 0 : y.getPropertyValue(p).trim();
1185
+ e.style.setProperty(p, _ || m[p]), i.set(p, e.style.getPropertyValue(p));
1186
+ }
1187
+ e.setAttribute("data-theme", b);
1188
+ };
1189
+ c();
1190
+ const u = o && o !== e && typeof MutationObserver < "u" ? new MutationObserver(c) : null;
1191
+ return u == null || u.observe(o, { attributes: !0, attributeFilter: ["style", "class", "data-theme", "data-rg-theme"] }), () => {
1192
+ u == null || u.disconnect();
1193
+ for (const [b, m] of i) {
1194
+ if (e.style.getPropertyValue(b) !== m) continue;
1195
+ const y = s.get(b);
1196
+ y.value ? e.style.setProperty(b, y.value, y.priority) : e.style.removeProperty(b);
1197
+ }
1198
+ d === null ? e.removeAttribute("data-theme") : e.setAttribute("data-theme", d);
1199
+ };
1200
+ }
1201
+ const ta = [
1202
+ "input[data-form]",
1203
+ "textarea[data-form]",
1204
+ "select[data-form]",
1205
+ "input[data-field]",
1206
+ "textarea[data-field]",
1207
+ "select[data-field]",
1208
+ "input[data-pair-key]",
1209
+ "input[data-pair-val]",
1210
+ "input[data-arr-val]",
1211
+ "textarea[data-arr-val]",
1212
+ "select[data-arr-val]",
1213
+ "input[data-switch-case]",
1214
+ "textarea[data-switch-case]",
1215
+ "input[data-switch-then]",
1216
+ "input[data-struct-key]",
1217
+ "textarea[data-struct-key]",
1218
+ "select[data-struct-key]",
1219
+ "input[data-struct-parent]",
1220
+ "textarea[data-struct-parent]",
1221
+ "select[data-struct-parent]",
1222
+ "input[data-struct-map-pair-key]",
1223
+ "input[data-struct-map-pair-val]",
1224
+ "textarea[data-tools-json]",
1225
+ "input[data-chain-field]",
1226
+ "textarea[data-chain-field]",
1227
+ "select[data-chain-field]",
1228
+ "input[data-schema-field]",
1229
+ "textarea[data-schema-field]",
1230
+ "select[data-schema-field]",
1231
+ "textarea[data-input-schema-json]",
1232
+ "input[data-ref-mode]",
1233
+ "input[data-ref-shared-value]",
1234
+ "input[data-provider-mode]",
1235
+ "select[data-provider-value]"
1236
+ ].join(","), Tt = /* @__PURE__ */ new WeakMap();
1237
+ function Re(e, t, r) {
1238
+ const n = e.t(t);
1239
+ return n && n !== t ? n : r;
1240
+ }
1241
+ function ra(e, t) {
1242
+ const r = e, n = [
1243
+ r.getAttribute("data-form"),
1244
+ r.getAttribute("data-field"),
1245
+ r.getAttribute("data-chain-field"),
1246
+ r.getAttribute("data-schema-field"),
1247
+ r.getAttribute("data-switch-case"),
1248
+ r.getAttribute("data-switch-then"),
1249
+ r.getAttribute("data-struct-key"),
1250
+ r.getAttribute("data-struct-parent"),
1251
+ r.getAttribute("data-struct-map-field"),
1252
+ r.getAttribute("data-tools-json"),
1253
+ r.getAttribute("data-input-schema-json") !== null ? "input-schema-json" : "",
1254
+ r.name,
1255
+ r.id
1256
+ ].filter(Boolean);
1257
+ return n.length ? n.join(":") : `${r.tagName.toLowerCase()}:${t}`;
1258
+ }
1259
+ function na(e) {
1260
+ return e instanceof HTMLInputElement ? e.type === "checkbox" || e.type === "radio" ? e.checked : e.value : e instanceof HTMLTextAreaElement ? e.value : e instanceof HTMLSelectElement ? e.multiple ? Array.from(e.selectedOptions).map((t) => t.value) : e.value : "";
1261
+ }
1262
+ function Kt(e, t = {}) {
1263
+ var s;
1264
+ (s = t.beforeCapture) == null || s.call(t);
1265
+ const r = t.selector || ta, n = typeof t.extra == "function" ? t.extra() : t.extra, a = Array.from(e.querySelectorAll(r)).filter((i) => !i.closest("[data-unsaved-ignore]")).map((i, d) => ({
1266
+ key: ra(i, d),
1267
+ tag: i.tagName.toLowerCase(),
1268
+ disabled: i.disabled === !0,
1269
+ value: na(i)
1270
+ })), o = Array.from(e.querySelectorAll("[data-point-table-json]")).map((i) => ({
1271
+ field: i.getAttribute("data-point-field"),
1272
+ value: i.getAttribute("data-point-table-json")
1273
+ }));
1274
+ return JSON.stringify({ controls: a, tables: o, extra: n ?? null });
1275
+ }
1276
+ function aa(e, t, r = {}) {
1277
+ return Kt(e, r) !== t;
1278
+ }
1279
+ function oa(e) {
1280
+ var o, s, i;
1281
+ if ((o = e.signal) != null && o.aborted) return Promise.resolve("cancel");
1282
+ if (typeof document > "u" || !document.body) {
1283
+ const d = e._dialogProvider;
1284
+ return d ? d.confirm({
1285
+ message: Re(e, "editor.panel.unsavedSaveBeforeClose", "The form has unsaved changes. Save before closing?")
1286
+ }).then((c) => c ? "save" : d.confirm({
1287
+ message: Re(e, "editor.panel.unsavedDiscardBeforeClose", "Discard unsaved changes and close?")
1288
+ }).then((u) => u ? "discard" : "cancel")) : Promise.resolve("cancel");
1289
+ }
1290
+ const t = e.guardOwner || e._activeDrawerWrapper || e;
1291
+ (s = Tt.get(t)) == null || s();
1292
+ const r = document.createElement("div");
1293
+ r.className = "huanban_unsaved_guard_modal", r.setAttribute("data-unsaved-close-modal", "true"), r.innerHTML = `
1294
+ <div class="huanban_unsaved_guard_dialog" role="dialog" aria-modal="true" aria-labelledby="huanban_unsaved_guard_title">
1295
+ <div class="huanban_unsaved_guard_title" id="huanban_unsaved_guard_title">${Fe(Re(e, "editor.panel.unsavedCloseTitle", "Unsaved changes"))}</div>
1296
+ <div class="huanban_unsaved_guard_desc">${Fe(Re(e, "editor.panel.unsavedCloseDesc", "This drawer has unsaved form changes. Save before closing, discard changes, or keep editing."))}</div>
1297
+ <div class="huanban_unsaved_guard_actions">
1298
+ <button type="button" class="btn_cancel" data-unsaved-action="cancel">${Fe(Re(e, "editor.panel.keepEditing", "Keep editing"))}</button>
1299
+ <button type="button" class="btn_danger" data-unsaved-action="discard">${Fe(Re(e, "editor.panel.discardChanges", "Discard"))}</button>
1300
+ <button type="button" class="btn_primary" data-unsaved-action="save">${Fe(Re(e, "editor.panel.saveAndClose", "Save and close"))}</button>
1301
+ </div>
1302
+ </div>
1303
+ `;
1304
+ const n = e._activeDrawerWrapper;
1305
+ (i = n == null ? void 0 : n.__huanbanOwnedOverlays) == null || i.add(r);
1306
+ const a = Wt(r, n || e.themeOwner);
1307
+ return new Promise((d) => {
1308
+ var m, y;
1309
+ let c = !1;
1310
+ const u = (w) => {
1311
+ var v, p;
1312
+ c || (c = !0, document.removeEventListener("keydown", b), (v = e.signal) == null || v.removeEventListener("abort", f), Tt.delete(t), (p = n == null ? void 0 : n.__huanbanOwnedOverlays) == null || p.delete(r), a(), r.remove(), d(w));
1313
+ }, f = () => u("cancel");
1314
+ r.__huanbanCleanup = f, Tt.set(t, f);
1315
+ const b = (w) => {
1316
+ const v = document.querySelectorAll("[data-unsaved-close-modal]");
1317
+ w.key === "Escape" && v[v.length - 1] === r && u("cancel");
1318
+ };
1319
+ r.addEventListener("click", (w) => {
1320
+ w.target === r && u("cancel");
1321
+ }), r.querySelectorAll("[data-unsaved-action]").forEach((w) => {
1322
+ w.addEventListener("click", () => {
1323
+ const v = w.getAttribute("data-unsaved-action");
1324
+ u(v === "save" || v === "discard" ? v : "cancel");
1325
+ });
1326
+ }), document.addEventListener("keydown", b), (m = e.signal) == null || m.addEventListener("abort", f, { once: !0 }), document.body.appendChild(r), (y = r.querySelector('[data-unsaved-action="cancel"]')) == null || y.focus();
1327
+ });
1328
+ }
1329
+ function Fe(e) {
1330
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1331
+ }
1332
+ const _r = /* @__PURE__ */ new WeakMap(), wr = /* @__PURE__ */ new WeakMap(), Gr = {
1333
+ confirm: async () => !1,
1334
+ prompt: async () => null,
1335
+ alert: async ({ message: e }) => {
1336
+ console.warn(e);
1337
+ }
1338
+ };
1339
+ function it(e) {
1340
+ if (!e) return Gr;
1341
+ const t = wr.get(e);
1342
+ if (t) return t;
1343
+ const r = () => e._dialogProvider || sa(e), n = {
1344
+ async confirm(a) {
1345
+ const o = Sr(e);
1346
+ try {
1347
+ return await r().confirm(a) === !0 && o();
1348
+ } catch {
1349
+ return !1;
1350
+ }
1351
+ },
1352
+ async prompt(a) {
1353
+ const o = Sr(e);
1354
+ try {
1355
+ const s = await r().prompt(a);
1356
+ return o() ? s : null;
1357
+ } catch {
1358
+ return null;
1359
+ }
1360
+ },
1361
+ async alert(a) {
1362
+ try {
1363
+ await r().alert(a);
1364
+ } catch {
1365
+ }
1366
+ }
1367
+ };
1368
+ return wr.set(e, n), n;
1369
+ }
1370
+ function sa(e) {
1371
+ if (typeof document > "u") return Gr;
1372
+ let t = _r.get(e);
1373
+ return t || (t = Vn({
1374
+ container: () => {
1375
+ var r, n;
1376
+ return e.rootEl || ((r = e._activeModalWrapper) == null ? void 0 : r.parentElement) || ((n = e._activeDrawerWrapper) == null ? void 0 : n.parentElement) || null;
1377
+ },
1378
+ t: (r, n) => {
1379
+ var o;
1380
+ const a = (o = e.t) == null ? void 0 : o.call(e, r);
1381
+ return a && a !== r ? a : n;
1382
+ }
1383
+ }), _r.set(e, t)), t;
1384
+ }
1385
+ function Sr(e) {
1386
+ const t = e == null ? void 0 : e.lf, r = e == null ? void 0 : e.rootEl, n = r == null ? void 0 : r.isConnected, a = e == null ? void 0 : e._activeDrawerWrapper, o = e == null ? void 0 : e._dialogProvider, s = () => {
1387
+ var d, c, u, f, b, m, y, w, v, p, _, x, h;
1388
+ return JSON.stringify([
1389
+ (u = (c = (d = e == null ? void 0 : e.workspace) == null ? void 0 : d.getActiveTab) == null ? void 0 : c.call(d)) == null ? void 0 : u.id,
1390
+ e == null ? void 0 : e.openChainGeneration,
1391
+ e == null ? void 0 : e.transportGeneration,
1392
+ e == null ? void 0 : e.capabilities,
1393
+ e == null ? void 0 : e.saveAuthorityGeneration,
1394
+ a ? Kt(a) : null,
1395
+ (y = (m = (b = (f = e == null ? void 0 : e.core) == null ? void 0 : f.store) == null ? void 0 : b.getState) == null ? void 0 : m.call(b)) == null ? void 0 : y.ruleChain,
1396
+ Ot(((w = t == null ? void 0 : t.getGraphRawData) == null ? void 0 : w.call(t)) || ((v = t == null ? void 0 : t.getGraphData) == null ? void 0 : v.call(t)) || {
1397
+ nodes: (_ = (p = t == null ? void 0 : t.graphModel) == null ? void 0 : p.nodes) == null ? void 0 : _.map((l) => {
1398
+ var g;
1399
+ return ((g = l.getData) == null ? void 0 : g.call(l)) || l;
1400
+ }),
1401
+ edges: (h = (x = t == null ? void 0 : t.graphModel) == null ? void 0 : x.edges) == null ? void 0 : h.map((l) => {
1402
+ var g;
1403
+ return ((g = l.getData) == null ? void 0 : g.call(l)) || l;
1404
+ })
1405
+ })
1406
+ ]);
1407
+ };
1408
+ let i;
1409
+ try {
1410
+ i = s();
1411
+ } catch {
1412
+ return () => !1;
1413
+ }
1414
+ return () => {
1415
+ var d, c;
1416
+ try {
1417
+ return !(e != null && e.destroyed) && (e == null ? void 0 : e.lf) === t && (e == null ? void 0 : e._dialogProvider) === o && (e == null ? void 0 : e._activeDrawerWrapper) === a && (!n || r.isConnected) && ((c = (d = e == null ? void 0 : e.capabilities) == null ? void 0 : d.editor) == null ? void 0 : c.readOnly) !== !0 && s() === i;
1418
+ } catch {
1419
+ return !1;
1420
+ }
1421
+ };
1422
+ }
1423
+ function Ze(e, t, r = "info") {
1424
+ if (typeof document > "u") return;
1425
+ const n = String(t || "").trim();
1426
+ if (!n) return;
1427
+ const a = document.body;
1428
+ if (!a) return;
1429
+ let o = Array.from(a.children).find((c) => c instanceof HTMLElement && c.classList.contains("huanban_rulego_editor_notification_host"));
1430
+ o || (o = document.createElement("div"), o.className = "huanban_rulego_editor_notification_host", o.setAttribute("role", "region"), o.setAttribute("aria-live", "polite"), o.setAttribute("aria-relevant", "additions text"), o.setAttribute("aria-label", "Editor notifications"), a.appendChild(o));
1431
+ const s = document.createElement("div");
1432
+ s.className = `huanban_rulego_editor_toast ${r === "error" ? "is_error" : "is_info"}`, s.setAttribute("role", r === "error" ? "alert" : "status"), s.textContent = n;
1433
+ const i = Wt(s, e);
1434
+ o.appendChild(s);
1435
+ const d = r === "error" ? 4e3 : 2e3;
1436
+ window.setTimeout(() => {
1437
+ if (!s.isConnected) {
1438
+ i();
1439
+ return;
1440
+ }
1441
+ s.classList.add("is_hiding"), window.setTimeout(() => {
1442
+ const c = s.parentElement;
1443
+ i(), s.remove(), c != null && c.classList.contains("huanban_rulego_editor_notification_host") && !c.childElementCount && c.remove();
1444
+ }, 180);
1445
+ }, d);
1446
+ }
1447
+ function gt(e, t = e == null ? void 0 : e.opts) {
1448
+ const r = (e == null ? void 0 : e.identityProvider) || (t == null ? void 0 : t.identityProvider), n = r ? r.getToken() : (t == null ? void 0 : t.includeStoredToken) !== !1 ? ia() : "";
1449
+ if (!(t != null && t.fetchHeaders))
1450
+ return n ? { Authorization: `Bearer ${n}` } : {};
1451
+ const o = { ...(typeof t.fetchHeaders == "function" ? t.fetchHeaders() : t.fetchHeaders) || {} }, s = Object.keys(o).some((i) => i.toLowerCase() === "authorization");
1452
+ return n && !s && (o.Authorization = `Bearer ${n}`), o;
1453
+ }
1454
+ function ia() {
1455
+ if (typeof localStorage > "u") return "";
1456
+ try {
1457
+ return localStorage.getItem("token") || localStorage.getItem("access_token") || "";
1458
+ } catch {
1459
+ return "";
1460
+ }
1461
+ }
1462
+ function co(e, t) {
1463
+ var a;
1464
+ const r = t.replace(/^wss:/i, "https:").replace(/^ws:/i, "http:");
1465
+ if (!Kr(r, e == null ? void 0 : e.opts, {})) return "";
1466
+ const n = new Headers(gt(e)).get("Authorization") || "";
1467
+ return ((a = /^Bearer\s+(.+)$/i.exec(n)) == null ? void 0 : a[1]) || "";
1468
+ }
1469
+ const la = [
1470
+ "authorization",
1471
+ "cookie",
1472
+ "x-api-key",
1473
+ "api-key",
1474
+ "x-auth-token",
1475
+ "x-access-token"
1476
+ ], xr = 1200, Cr = /* @__PURE__ */ new WeakMap();
1477
+ let kr = 0;
1478
+ const da = /* @__PURE__ */ new Set(["arrayBuffer", "blob", "formData", "json", "text"]);
1479
+ function bt() {
1480
+ if (typeof DOMException == "function") return new DOMException("Request timed out", "AbortError");
1481
+ const e = new Error("Request timed out");
1482
+ return e.name = "AbortError", e;
1483
+ }
1484
+ function Ke(e) {
1485
+ return (e == null ? void 0 : e.reason) || (typeof DOMException == "function" ? new DOMException("The operation was aborted", "AbortError") : Object.assign(new Error("The operation was aborted"), { name: "AbortError" }));
1486
+ }
1487
+ function Vr(e) {
1488
+ var r;
1489
+ const t = (r = e == null ? void 0 : e._getTransportGeneration) == null ? void 0 : r.call(e);
1490
+ return Number.isFinite(Number(t)) ? Number(t) : null;
1491
+ }
1492
+ function ca(e, t) {
1493
+ return {
1494
+ generation: Vr(e),
1495
+ apiBase: String((t == null ? void 0 : t.apiBase) || "").trim(),
1496
+ customFetch: t == null ? void 0 : t.customFetch,
1497
+ fetchHeaders: t == null ? void 0 : t.fetchHeaders,
1498
+ apiCacheKey: t == null ? void 0 : t.apiCacheKey,
1499
+ identityProvider: (e == null ? void 0 : e.identityProvider) || (t == null ? void 0 : t.identityProvider)
1500
+ };
1501
+ }
1502
+ function ua(e, t) {
1503
+ const r = e == null ? void 0 : e.opts, n = Vr(e);
1504
+ return t.generation !== null && n !== null ? t.generation === n : String((r == null ? void 0 : r.apiBase) || "").trim() === t.apiBase && (r == null ? void 0 : r.customFetch) === t.customFetch && (r == null ? void 0 : r.fetchHeaders) === t.fetchHeaders && (r == null ? void 0 : r.apiCacheKey) === t.apiCacheKey && ((e == null ? void 0 : e.identityProvider) || (r == null ? void 0 : r.identityProvider)) === t.identityProvider;
1505
+ }
1506
+ function Jr(e, t) {
1507
+ let r;
1508
+ try {
1509
+ r = e();
1510
+ } catch (d) {
1511
+ r = Promise.reject(d);
1512
+ }
1513
+ const { controller: n, deadline: a, upstreamSignal: o, onBodyFailure: s, onBodySettled: i } = t;
1514
+ return new Promise((d, c) => {
1515
+ let u = !1, f = null;
1516
+ const b = (w) => {
1517
+ u || (u = !0, f !== null && clearTimeout(f), o == null || o.removeEventListener("abort", y), i == null || i(), w());
1518
+ }, m = (w, v) => b(() => {
1519
+ v && (s == null || s(w)), c(w);
1520
+ }), y = () => {
1521
+ const w = Ke(o);
1522
+ n.signal.aborted || n.abort(w), m(w, !1);
1523
+ };
1524
+ if (r.then(
1525
+ (w) => b(() => d(w)),
1526
+ (w) => m(w, !(o != null && o.aborted))
1527
+ ), o != null && o.aborted) {
1528
+ y();
1529
+ return;
1530
+ }
1531
+ if (o == null || o.addEventListener("abort", y, { once: !0 }), a !== null) {
1532
+ const w = a - Date.now();
1533
+ if (w <= 0) {
1534
+ const v = bt();
1535
+ n.signal.aborted || n.abort(v), m(v, !0);
1536
+ return;
1537
+ }
1538
+ f = setTimeout(() => {
1539
+ const v = bt();
1540
+ n.signal.aborted || n.abort(v), m(v, !0);
1541
+ }, w);
1542
+ }
1543
+ });
1544
+ }
1545
+ function fa(e, t) {
1546
+ let r = null, n = !1, a = !1, o = null, s = null;
1547
+ const i = () => {
1548
+ var y, w;
1549
+ o !== null && clearTimeout(o), o = null, (y = t.upstreamSignal) == null || y.removeEventListener("abort", c), (w = t.onBodySettled) == null || w.call(t);
1550
+ }, d = (y, w) => {
1551
+ var p;
1552
+ if (a) return;
1553
+ a = !0, i(), w && ((p = t.onBodyFailure) == null || p.call(t, y));
1554
+ try {
1555
+ s == null || s.error(y);
1556
+ } catch {
1557
+ }
1558
+ (r ? r.cancel(y) : e.cancel(y)).catch(() => {
1559
+ });
1560
+ }, c = () => {
1561
+ const y = Ke(t.upstreamSignal);
1562
+ t.controller.signal.aborted || t.controller.abort(y), d(y, !1);
1563
+ }, u = () => {
1564
+ var w, v;
1565
+ if (n) return;
1566
+ if (n = !0, (w = t.upstreamSignal) != null && w.aborted) {
1567
+ c();
1568
+ return;
1569
+ }
1570
+ if ((v = t.upstreamSignal) == null || v.addEventListener("abort", c, { once: !0 }), t.deadline === null) return;
1571
+ const y = t.deadline - Date.now();
1572
+ if (y <= 0) {
1573
+ const p = bt();
1574
+ t.controller.signal.aborted || t.controller.abort(p), d(p, !0);
1575
+ return;
1576
+ }
1577
+ o = setTimeout(() => {
1578
+ const p = bt();
1579
+ t.controller.signal.aborted || t.controller.abort(p), d(p, !0);
1580
+ }, y);
1581
+ }, f = () => (r || (r = e.getReader()), r), b = new ReadableStream({
1582
+ start(y) {
1583
+ s = y;
1584
+ },
1585
+ async pull(y) {
1586
+ var w;
1587
+ if (u(), !a)
1588
+ try {
1589
+ const p = await f().read();
1590
+ if (a) return;
1591
+ p.done ? (a = !0, i(), y.close()) : y.enqueue(p.value);
1592
+ } catch (v) {
1593
+ d(v, !((w = t.upstreamSignal) != null && w.aborted));
1594
+ }
1595
+ },
1596
+ cancel(y) {
1597
+ return a || (a = !0, i()), r ? r.cancel(y) : e.cancel(y);
1598
+ }
1599
+ }, { highWaterMark: 0 }), m = /* @__PURE__ */ new Set([
1600
+ "cancel",
1601
+ "getReader",
1602
+ "pipeThrough",
1603
+ "pipeTo",
1604
+ "tee",
1605
+ "values",
1606
+ Symbol.asyncIterator
1607
+ ]);
1608
+ return new Proxy(b, {
1609
+ get(y, w) {
1610
+ const v = Reflect.get(y, w, y);
1611
+ return typeof v != "function" ? v : m.has(w) ? (...p) => (f(), v.apply(y, p)) : v.bind(y);
1612
+ }
1613
+ });
1614
+ }
1615
+ function Ur(e, t, r = {
1616
+ activeLeases: 0,
1617
+ onAllSettled: t.onBodySettled
1618
+ }) {
1619
+ r.activeLeases += 1;
1620
+ let n = !1;
1621
+ const a = () => {
1622
+ var d;
1623
+ n || (n = !0, r.activeLeases -= 1, r.activeLeases === 0 && ((d = r.onAllSettled) == null || d.call(r)));
1624
+ }, o = {
1625
+ ...t,
1626
+ onBodySettled: a
1627
+ };
1628
+ if (!e.body || e.bodyUsed)
1629
+ return a(), e;
1630
+ let s = null, i;
1631
+ return i = new Proxy(e, {
1632
+ get(d, c) {
1633
+ if (c === "body")
1634
+ return s || (s = fa(d.body, o)), s;
1635
+ if (c === "clone")
1636
+ return () => Ur(d.clone(), t, r);
1637
+ if (typeof c == "string" && da.has(c))
1638
+ return () => Jr(
1639
+ () => d[c](),
1640
+ o
1641
+ );
1642
+ const u = Reflect.get(d, c, d);
1643
+ return typeof u == "function" ? u.bind(d) : u;
1644
+ }
1645
+ }), i;
1646
+ }
1647
+ function ha(e) {
1648
+ const t = Date.now();
1649
+ if (e && typeof e == "object") {
1650
+ const r = Cr.get(e) || 0;
1651
+ return t - r < xr ? !1 : (Cr.set(e, t), !0);
1652
+ }
1653
+ return t - kr < xr ? !1 : (kr = t, !0);
1654
+ }
1655
+ async function Wr(e, t = {}, r, n = {}) {
1656
+ var p, _, x, h, l, g, S, C, A, N;
1657
+ const a = r == null ? void 0 : r.opts, o = ca(r, a), s = a == null ? void 0 : a.customFetch, i = n.includeAuthHeaders === !1 ? {} : gt(r, a), d = () => {
1658
+ var L;
1659
+ return ua(r, o) && ((r == null ? void 0 : r.identityProvider) || ((L = r == null ? void 0 : r.opts) == null ? void 0 : L.identityProvider)) === o.identityProvider && ga(i, gt(r));
1660
+ }, c = n.timeoutMs ?? (a == null ? void 0 : a.fetchTimeout) ?? 1e4, u = new AbortController(), f = t.signal;
1661
+ let b = !1;
1662
+ const m = () => {
1663
+ u.signal.aborted || (b = !0, u.abort(Ke(f)));
1664
+ };
1665
+ f && (f.aborted ? m() : f.addEventListener("abort", m, { once: !0 }));
1666
+ const y = Date.now() + c;
1667
+ let w = !1;
1668
+ const v = () => f == null ? void 0 : f.removeEventListener("abort", m);
1669
+ try {
1670
+ if (u.signal.aborted) throw Ke(u.signal);
1671
+ const L = pa(i, t.headers), O = ma(L, e, a, n), I = {
1672
+ ...t,
1673
+ headers: O,
1674
+ signal: u.signal
1675
+ }, z = await Jr(
1676
+ () => typeof s == "function" ? s(e, I) : fetch(e, I),
1677
+ { controller: u, deadline: y, upstreamSignal: f }
1678
+ );
1679
+ if (u.signal.aborted) throw Ke(u.signal);
1680
+ if (n.includeAuthHeaders !== !1 && d() && $t(e, r, a) && ((p = r.serverStatus) == null || p.recordHttpStatus(
1681
+ z.status,
1682
+ z.ok ? void 0 : `HTTP ${z.status}`
1683
+ )), (z.status === 401 || z.status === 403) && n.includeAuthHeaders !== !1 && d() && ba(e, a)) {
1684
+ const K = o.identityProvider;
1685
+ if (ha(r))
1686
+ if (K) {
1687
+ try {
1688
+ Promise.resolve(K.handleAuthError({ status: z.status, url: String(e) })).catch(() => {
1689
+ });
1690
+ } catch {
1691
+ }
1692
+ a != null && a.identityProvider || (x = (_ = r == null ? void 0 : r.opts) == null ? void 0 : _.onAuthExpired) == null || x.call(_, z);
1693
+ } else
1694
+ (l = (h = r == null ? void 0 : r.opts) == null ? void 0 : h.onAuthExpired) == null || l.call(h, z), (S = (g = r == null ? void 0 : r.opts) == null ? void 0 : g.onApiAuthRequired) == null || S.call(g, { status: z.status, url: String(e) });
1695
+ z.status === 401 && !(a != null && a.identityProvider) && ((A = (C = r == null ? void 0 : r.opts) == null ? void 0 : C.clearToken) == null || A.call(C));
1696
+ }
1697
+ const G = (K) => {
1698
+ var Z;
1699
+ if (n.includeAuthHeaders === !1 || !d() || !$t(e, r, a)) return;
1700
+ const le = K instanceof Error ? K.message : String(K || "Response body failed");
1701
+ (Z = r.serverStatus) == null || Z.recordHttpStatus(0, le);
1702
+ };
1703
+ return w = !0, Ur(z, {
1704
+ controller: u,
1705
+ deadline: n.streamResponse ? null : y,
1706
+ upstreamSignal: f,
1707
+ onBodyFailure: G,
1708
+ onBodySettled: v
1709
+ });
1710
+ } catch (L) {
1711
+ if (!b && n.includeAuthHeaders !== !1 && d() && $t(e, r, a)) {
1712
+ const O = L instanceof Error ? L.message : String(L || "Network request failed");
1713
+ (N = r.serverStatus) == null || N.recordHttpStatus(0, O);
1714
+ }
1715
+ throw L;
1716
+ } finally {
1717
+ w || v();
1718
+ }
1719
+ }
1720
+ function ga(e, t) {
1721
+ const r = new Headers(e), n = new Headers(t), a = Array.from(r.entries()).sort(([s], [i]) => s.localeCompare(i)), o = Array.from(n.entries()).sort(([s], [i]) => s.localeCompare(i));
1722
+ return JSON.stringify(a) === JSON.stringify(o);
1723
+ }
1724
+ function $t(e, t, r = t == null ? void 0 : t.opts) {
1725
+ if (!(t != null && t.serverStatus)) return !1;
1726
+ const n = String(e || "").trim();
1727
+ if (!n) return !1;
1728
+ if (Yt(n)) return !0;
1729
+ const a = String((r == null ? void 0 : r.apiBase) || "").trim();
1730
+ if (!a) return !1;
1731
+ try {
1732
+ return new URL(n, mt() || void 0).origin === new URL(a, mt() || void 0).origin;
1733
+ } catch {
1734
+ return !1;
1735
+ }
1736
+ }
1737
+ function ba(e, t) {
1738
+ if (Yt(e)) return !0;
1739
+ const r = String((t == null ? void 0 : t.apiBase) || "").trim();
1740
+ if (!r) return !1;
1741
+ const n = pt(e), a = pt(r);
1742
+ return !!(n && a && n === a);
1743
+ }
1744
+ function pa(e, t) {
1745
+ const r = new Headers(t || {});
1746
+ for (const [n, a] of Object.entries(e))
1747
+ r.has(n) || r.set(n, a);
1748
+ return r;
1749
+ }
1750
+ function ma(e, t, r, n) {
1751
+ if (Kr(t, r, n)) return e;
1752
+ const a = [
1753
+ ...la,
1754
+ ...n.sensitiveHeaderNames ?? []
1755
+ ], o = new Set(a.map((i) => i.toLowerCase())), s = new Headers(e);
1756
+ for (const i of Array.from(s.keys()))
1757
+ o.has(i.toLowerCase()) && s.delete(i);
1758
+ return s;
1759
+ }
1760
+ function Kr(e, t, r) {
1761
+ if (Yt(e)) return !0;
1762
+ const n = pt(e);
1763
+ if (!n) return !1;
1764
+ const a = /* @__PURE__ */ new Set(), o = mt();
1765
+ o && a.add(o);
1766
+ for (const i of r.allowedOrigins ?? []) a.add(i);
1767
+ for (const i of (t == null ? void 0 : t.allowedApiOrigins) ?? []) a.add(i);
1768
+ const s = pt(t == null ? void 0 : t.apiBase);
1769
+ return s && a.add(s), a.has(n);
1770
+ }
1771
+ function Yt(e) {
1772
+ const t = String(e ?? "").trim();
1773
+ return !!t && !/^[a-z][a-z0-9+.-]*:/i.test(t) && !t.startsWith("//");
1774
+ }
1775
+ function pt(e) {
1776
+ const t = String(e ?? "").trim();
1777
+ if (!t) return null;
1778
+ try {
1779
+ return new URL(t, mt() || "http://localhost").origin;
1780
+ } catch {
1781
+ return null;
1782
+ }
1783
+ }
1784
+ function mt() {
1785
+ var e;
1786
+ return typeof window < "u" && ((e = window.location) != null && e.origin) ? window.location.origin : null;
1787
+ }
1788
+ const ya = {
1789
+ maxDepth: Number.POSITIVE_INFINITY,
1790
+ maxString: Number.POSITIVE_INFINITY,
1791
+ maxArray: Number.POSITIVE_INFINITY
1792
+ };
1793
+ function fe(...e) {
1794
+ for (const t of e)
1795
+ if (t != null && t !== "") return t;
1796
+ }
1797
+ function et(e) {
1798
+ if (e == null || e === "") return null;
1799
+ const t = Number(e);
1800
+ if (Number.isFinite(t) && t > 0)
1801
+ return t < 1e12 ? t * 1e3 : t;
1802
+ const r = new Date(String(e)).getTime();
1803
+ return Number.isFinite(r) ? r : null;
1804
+ }
1805
+ function Ve(e) {
1806
+ return String(fe(e.id, e.runId, e.msgId, e.traceId, e.uuid, "") || "");
1807
+ }
1808
+ function Yr(e, t = "zh-CN") {
1809
+ const r = fe(
1810
+ e.startTs,
1811
+ e.ts,
1812
+ e.time,
1813
+ e.createdAt,
1814
+ e.createTime,
1815
+ e.startTime,
1816
+ e.timestamp
1817
+ ), n = et(r);
1818
+ return n !== null ? new Date(n).toLocaleString(t) : r === void 0 ? "-" : String(r || "-");
1819
+ }
1820
+ function uo(e) {
1821
+ var n, a, o, s, i, d, c, u, f, b;
1822
+ const t = Array.isArray(e.logs) ? e.logs.find((m) => (m == null ? void 0 : m.inMsg) || (m == null ? void 0 : m.msg)) : null, r = e.inMsg || e.msg || (t == null ? void 0 : t.inMsg) || (t == null ? void 0 : t.msg) || null;
1823
+ return String(fe(
1824
+ e.msgType,
1825
+ e.messageType,
1826
+ e.type,
1827
+ e.method,
1828
+ (n = e.metadata) == null ? void 0 : n.msgType,
1829
+ (a = e.metadata) == null ? void 0 : a.msgtype,
1830
+ r == null ? void 0 : r.type,
1831
+ (o = r == null ? void 0 : r.metadata) == null ? void 0 : o.msgType,
1832
+ (s = r == null ? void 0 : r.metadata) == null ? void 0 : s.msgtype,
1833
+ (i = t == null ? void 0 : t.inMsg) == null ? void 0 : i.type,
1834
+ (d = t == null ? void 0 : t.msg) == null ? void 0 : d.type,
1835
+ (u = (c = t == null ? void 0 : t.inMsg) == null ? void 0 : c.metadata) == null ? void 0 : u.msgType,
1836
+ (b = (f = t == null ? void 0 : t.inMsg) == null ? void 0 : f.metadata) == null ? void 0 : b.msgtype,
1837
+ "-"
1838
+ ));
1839
+ }
1840
+ function fo(e, t = {}) {
1841
+ if (e.success === !0 || e.ok === !0) return { kind: "success", label: t.success || "成功" };
1842
+ if (e.success === !1 || e.ok === !1 || e.err || e.error) return { kind: "failed", label: t.failed || "失败" };
1843
+ const r = Array.isArray(e.logs) ? e.logs : [];
1844
+ if (r.some((a) => (a == null ? void 0 : a.err) || (a == null ? void 0 : a.error))) return { kind: "failed", label: t.failed || "失败" };
1845
+ const n = String(fe(e.status, e.state, "") || "").toLowerCase();
1846
+ return ["success", "succeeded", "ok", "done", "completed", "complete"].includes(n) ? { kind: "success", label: t.success || "成功" } : ["failed", "failure", "error", "fail", "panic", "timeout"].includes(n) ? { kind: "failed", label: t.failed || "失败" } : !n && r.length > 0 ? { kind: "success", label: t.success || "成功" } : { kind: "unknown", label: n || t.unknown || "未知" };
1847
+ }
1848
+ function ho(e) {
1849
+ const t = fe(e.duration, e.cost, e.elapsed, e.elapsedMs, e.timeCost);
1850
+ if (t !== void 0) {
1851
+ if (typeof t == "number") return t >= 1e3 ? `${(t / 1e3).toFixed(2)}s` : `${t}ms`;
1852
+ const a = Number(t);
1853
+ return Number.isFinite(a) && /^\d+(\.\d+)?$/.test(String(t).trim()) ? a >= 1e3 ? `${(a / 1e3).toFixed(2)}s` : `${a}ms` : String(t);
1854
+ }
1855
+ const r = et(fe(e.startTs, e.ts, e.startTime)), n = et(fe(e.endTs, e.endTime, e.finishTime, e.completedAt));
1856
+ if (r !== null && n !== null && n >= r) {
1857
+ const a = n - r;
1858
+ return a >= 1e3 ? `${(a / 1e3).toFixed(2)}s` : `${a}ms`;
1859
+ }
1860
+ return "-";
1861
+ }
1862
+ function go(e) {
1863
+ const t = fe(e.duration, e.cost, e.elapsed, e.elapsedMs, e.timeCost);
1864
+ if (t !== void 0)
1865
+ return typeof t == "number" ? t >= 1e3 ? `${(t / 1e3).toFixed(2)}s` : `${t}ms` : String(t);
1866
+ const r = et(fe(e.startTs, e.ts, e.startTime)), n = et(fe(e.endTs, e.endTime, e.finishTime));
1867
+ if (r !== null && n !== null && n >= r) {
1868
+ const a = n - r;
1869
+ return a >= 1e3 ? `${(a / 1e3).toFixed(2)}s` : `${a}ms`;
1870
+ }
1871
+ return "-";
1872
+ }
1873
+ function Qr(e) {
1874
+ if (!e) return null;
1875
+ const t = {
1876
+ type: e.type,
1877
+ dataType: e.dataType
1878
+ };
1879
+ if (e.data !== void 0 && e.data !== null && e.data !== "")
1880
+ if (typeof e.data == "string")
1881
+ try {
1882
+ t.data = JSON.parse(e.data);
1883
+ } catch {
1884
+ t.data = e.data;
1885
+ }
1886
+ else
1887
+ t.data = e.data;
1888
+ return e.body !== void 0 && e.body !== null && e.body !== "" && (t.body = e.body), e.metadata && typeof e.metadata == "object" && Object.keys(e.metadata).length > 0 && (t.metadata = e.metadata), t;
1889
+ }
1890
+ function va(e) {
1891
+ const t = /* @__PURE__ */ new WeakSet();
1892
+ try {
1893
+ return JSON.stringify(e, (r, n) => {
1894
+ if (typeof n == "bigint") return `${n.toString()}n`;
1895
+ if (typeof n == "function") return `[Function${n.name ? ` ${n.name}` : ""}]`;
1896
+ if (n && typeof n == "object") {
1897
+ if (t.has(n)) return "[CIRCULAR]";
1898
+ t.add(n);
1899
+ }
1900
+ return n;
1901
+ }, 2);
1902
+ } catch (r) {
1903
+ return `[Unserializable: ${r instanceof Error ? r.message : String(r)}]`;
1904
+ }
1905
+ }
1906
+ function wt(e, t = !0) {
1907
+ const r = t ? vt(e, ya) : e, n = va(r);
1908
+ return n === void 0 ? "undefined" : n;
1909
+ }
1910
+ function bo(e) {
1911
+ const t = Qr(e);
1912
+ return t ? qr(vt(t), { maxChars: Te.maxDebugItemChars }) : "";
1913
+ }
1914
+ function po(e) {
1915
+ const t = Qr(e);
1916
+ return t ? wt(t) : "";
1917
+ }
1918
+ function mo(e, t = Te.maxDebugItemChars) {
1919
+ return qr(vt(e), { maxChars: t });
1920
+ }
1921
+ function yo(e) {
1922
+ return wt(e);
1923
+ }
1924
+ class ze extends Error {
1925
+ constructor(t, r) {
1926
+ super(r), this.code = t, this.name = "RuleChainVersionsError";
1927
+ }
1928
+ }
1929
+ function Q(e) {
1930
+ return e !== null && typeof e == "object" && !Array.isArray(e);
1931
+ }
1932
+ function Me(e) {
1933
+ throw new ze("invalid-response", e);
1934
+ }
1935
+ function Qt(e) {
1936
+ if (e == null || e === "" || typeof e == "boolean") return null;
1937
+ const t = Number(e);
1938
+ return Number.isFinite(t) ? t : null;
1939
+ }
1940
+ function zt(e, t) {
1941
+ const r = Qt(e);
1942
+ return r !== null && Number.isInteger(r) && r > 0 ? r : t;
1943
+ }
1944
+ function Xr(e) {
1945
+ if (!Q(e) || typeof e.id != "string" || !e.id.trim())
1946
+ return Me("A version must contain a non-empty id");
1947
+ const t = { ...e, id: e.id };
1948
+ for (const r of ["seq", "nodeCount", "dslSize"]) {
1949
+ const n = Qt(e[r]);
1950
+ n !== null ? t[r] = n : delete t[r];
1951
+ }
1952
+ return typeof e.source != "string" && delete t.source, typeof e.ts != "string" && typeof e.ts != "number" && delete t.ts, t;
1953
+ }
1954
+ function _a(e, t = 1, r = 20) {
1955
+ const n = De(e), a = Array.isArray(n) ? n : Q(n) ? n.items : void 0;
1956
+ if (!Array.isArray(a)) return Me("The version response must contain an items array");
1957
+ const o = Q(n) ? n : {}, s = Qt(o.total);
1958
+ return s !== null && (!Number.isInteger(s) || s < 0) ? Me("Invalid version total") : {
1959
+ items: a.map(Xr),
1960
+ total: s,
1961
+ page: zt(o.page, t),
1962
+ pageSize: zt(o.size ?? o.pageSize, r)
1963
+ };
1964
+ }
1965
+ function Zr(e, t) {
1966
+ let r = De(e);
1967
+ if (typeof r == "string")
1968
+ try {
1969
+ r = JSON.parse(r);
1970
+ } catch {
1971
+ return Me("The version DSL is not valid JSON");
1972
+ }
1973
+ return !Q(r) || !Q(r.ruleChain) || !Q(r.metadata) || typeof r.ruleChain.id != "string" || !r.ruleChain.id.trim() || !Array.isArray(r.metadata.nodes) || r.metadata.connections !== void 0 && !Array.isArray(r.metadata.connections) || r.metadata.endpoints !== void 0 && !Array.isArray(r.metadata.endpoints) ? Me("The response does not contain a rule-chain DSL") : t !== void 0 && r.ruleChain.id !== t ? Me("The response belongs to a different rule chain") : r;
1974
+ }
1975
+ function Mt(e, t, r) {
1976
+ const n = De(e);
1977
+ return !Q(n) || !Object.prototype.hasOwnProperty.call(n, "dsl") ? Me("The version response does not contain dsl") : n.id !== void 0 && n.id !== r ? Me("The response belongs to a different version") : { ...Xr({ ...n, id: r }), dsl: Zr(n.dsl, t) };
1978
+ }
1979
+ function ue(e) {
1980
+ return Array.isArray(e) ? `[${e.map(ue).join(",")}]` : Q(e) ? `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${ue(e[t])}`).join(",")}}` : JSON.stringify(e) ?? "undefined";
1981
+ }
1982
+ function Ar(e) {
1983
+ return typeof e == "string" ? e : JSON.stringify(e, null, 2) ?? "undefined";
1984
+ }
1985
+ function Ae(e, t, r = "") {
1986
+ const n = [], a = (s, i, d, c) => {
1987
+ n.push({
1988
+ path: d || "$",
1989
+ kind: c,
1990
+ before: s,
1991
+ after: i,
1992
+ ...c !== "added" ? { a: Ar(s) } : {},
1993
+ ...c !== "removed" ? { b: Ar(i) } : {}
1994
+ });
1995
+ }, o = (s, i, d) => {
1996
+ if (!Object.is(s, i))
1997
+ if (Array.isArray(s) && Array.isArray(i))
1998
+ for (let c = 0; c < Math.max(s.length, i.length); c += 1) {
1999
+ const u = `${d}[${c}]`;
2000
+ c >= s.length ? a(void 0, i[c], u, "added") : c >= i.length ? a(s[c], void 0, u, "removed") : o(s[c], i[c], u);
2001
+ }
2002
+ else if (Q(s) && Q(i))
2003
+ for (const c of /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(i)])) {
2004
+ const u = /^[A-Za-z_$][\w$]*$/.test(c) ? d ? `${d}.${c}` : c : `${d}[${JSON.stringify(c)}]`;
2005
+ Object.prototype.hasOwnProperty.call(s, c) ? Object.prototype.hasOwnProperty.call(i, c) ? o(s[c], i[c], u) : a(s[c], void 0, u, "removed") : a(void 0, i[c], u, "added");
2006
+ }
2007
+ else
2008
+ a(s, i, d, s === void 0 ? "added" : i === void 0 ? "removed" : "changed");
2009
+ };
2010
+ return o(e, t, r), n;
2011
+ }
2012
+ function Er(e) {
2013
+ const t = typeof e == "string" ? JSON.parse(e) : e, r = Br(t);
2014
+ if (!Q(r)) return { ruleChain: {}, metadata: {} };
2015
+ const n = (o) => {
2016
+ if (!Q(o)) return o;
2017
+ const s = Q(o.additionalInfo) ? { ...o.additionalInfo } : {};
2018
+ delete s.layoutX, delete s.layoutY;
2019
+ const i = { ...o };
2020
+ return delete i.additionalInfo, Object.keys(s).length && (i.additionalInfo = s), i;
2021
+ }, a = r.metadata;
2022
+ return a.nodes = a.nodes.map(n), a.endpoints = a.endpoints.map(n), r.ruleChain = n(r.ruleChain), r;
2023
+ }
2024
+ function wa(e, t) {
2025
+ const r = Er(e), n = Er(t), a = r.metadata, o = n.metadata, s = (p) => {
2026
+ const _ = /* @__PURE__ */ new Map();
2027
+ for (const x of ["nodes", "endpoints"])
2028
+ for (const h of Array.isArray(p[x]) ? p[x] : [])
2029
+ Q(h) && _.set(`${x}:${String(h.id)}`, h);
2030
+ return _;
2031
+ }, i = s(a), d = s(o), c = [];
2032
+ for (const p of /* @__PURE__ */ new Set([...i.keys(), ...d.keys()])) {
2033
+ const _ = i.get(p), x = d.get(p), h = x || _, l = Ae(_, x);
2034
+ if (!l.length) continue;
2035
+ const g = _ && x ? [...new Set(l.map((S) => S.path.split(/[.[]/, 1)[0]))] : [];
2036
+ c.push({
2037
+ key: p,
2038
+ id: String(h.id),
2039
+ label: String(h.name || h.id),
2040
+ type: String(h.type || ""),
2041
+ kind: _ ? x ? "changed" : "removed" : "added",
2042
+ fields: g,
2043
+ changes: l,
2044
+ configPaths: _ && x ? [
2045
+ ...Ae(_.configuration, x.configuration, "configuration"),
2046
+ ...Ae(_.routers, x.routers, "routers")
2047
+ ] : []
2048
+ });
2049
+ }
2050
+ const u = (p) => {
2051
+ const _ = /* @__PURE__ */ new Map(), x = (h) => {
2052
+ const l = String(h.fromId ?? ""), g = String(h.toId ?? ""), S = JSON.stringify([l, g, h.routerId ?? "", h.fromPort ?? "", h.toPort ?? ""]), C = _.get(S) || { from: l, to: g, values: [] };
2053
+ C.values.push(h), _.set(S, C);
2054
+ };
2055
+ for (const h of Array.isArray(p.connections) ? p.connections : []) Q(h) && x(h);
2056
+ for (const h of Array.isArray(p.endpoints) ? p.endpoints : [])
2057
+ if (!(!Q(h) || !Array.isArray(h.routers)))
2058
+ for (const l of h.routers)
2059
+ !Q(l) || !Q(l.from) || !Q(l.to) || !l.from.path || !l.to.path || x({ fromId: h.id, toId: l.to.path, routerId: l.id || l.from.path, type: "" });
2060
+ for (const h of _.values()) h.values.sort((l, g) => ue(l).localeCompare(ue(g)));
2061
+ return _;
2062
+ }, f = u(a), b = u(o), m = [];
2063
+ for (const p of /* @__PURE__ */ new Set([...f.keys(), ...b.keys()])) {
2064
+ const _ = f.get(p), x = b.get(p), h = x || _, l = Ae(_ == null ? void 0 : _.values, x == null ? void 0 : x.values);
2065
+ l.length && m.push({
2066
+ key: p,
2067
+ from: h.from,
2068
+ to: h.to,
2069
+ label: `${h.from} -> ${h.to}`,
2070
+ kind: _ ? x ? "changed" : "removed" : "added",
2071
+ changes: l
2072
+ });
2073
+ }
2074
+ const y = (p) => {
2075
+ const _ = { ...p.metadata };
2076
+ return delete _.nodes, delete _.endpoints, delete _.connections, { ...p, metadata: _ };
2077
+ }, w = Ae(y(r), y(n)), v = (p, _) => p.filter((x) => x.kind === _).length;
2078
+ return { nodes: c, edges: m, chain: w, summary: {
2079
+ nodeAdded: v(c, "added"),
2080
+ nodeRemoved: v(c, "removed"),
2081
+ nodeChanged: v(c, "changed"),
2082
+ edgeAdded: v(m, "added"),
2083
+ edgeRemoved: v(m, "removed"),
2084
+ edgeChanged: v(m, "changed"),
2085
+ identical: !c.length && !m.length && !w.length
2086
+ } };
2087
+ }
2088
+ function ce(e, t) {
2089
+ return new Promise((r, n) => {
2090
+ const a = () => n(t.reason || new DOMException("The operation was aborted", "AbortError"));
2091
+ if (t.aborted) {
2092
+ a();
2093
+ return;
2094
+ }
2095
+ t.addEventListener("abort", a, { once: !0 }), Promise.resolve().then(() => {
2096
+ if (t.aborted) throw t.reason || new DOMException("The operation was aborted", "AbortError");
2097
+ return e();
2098
+ }).then(r, n).finally(() => t.removeEventListener("abort", a));
2099
+ });
2100
+ }
2101
+ function vo(e) {
2102
+ const t = zt(e.pageSize, 20), r = (l) => ({
2103
+ chainId: l,
2104
+ phase: "idle",
2105
+ items: [],
2106
+ total: null,
2107
+ page: 0,
2108
+ pageSize: t,
2109
+ hasMore: !1,
2110
+ showDrafts: !1,
2111
+ selection: [],
2112
+ detail: null,
2113
+ comparison: null,
2114
+ error: null,
2115
+ pendingRollback: !1,
2116
+ lastRollback: null
2117
+ });
2118
+ let n = r(e.chainId || ""), a = !1, o = null, s = null;
2119
+ const i = /* @__PURE__ */ new Set(), d = (l) => {
2120
+ if (n = { ...n, ...l }, !a) for (const g of i) g(n);
2121
+ }, c = () => e.getDraftRevision ? e.getDraftRevision() : e.isDirty(), u = () => {
2122
+ const l = o;
2123
+ o = null, l == null || l.abort(), d({ phase: "idle" });
2124
+ }, f = async (l, g) => {
2125
+ if (a || o || !n.chainId) return !1;
2126
+ const S = new AbortController();
2127
+ o = S, d({ phase: l, error: null });
2128
+ try {
2129
+ return await ce(() => g(S.signal), S.signal);
2130
+ } catch (C) {
2131
+ return o === S && !S.signal.aborted && d({ error: { operation: n.phase, cause: C, committed: !!s } }), !1;
2132
+ } finally {
2133
+ o === S && (o = null, d({ phase: "idle" }));
2134
+ }
2135
+ }, b = (l) => {
2136
+ if (l.aborted || a) throw l.reason || new DOMException("The operation was aborted", "AbortError");
2137
+ }, m = async (l, g) => {
2138
+ const S = await ce(() => e.fetcher.getRuleVersions(n.chainId, l, n.pageSize, g), g);
2139
+ b(g);
2140
+ const C = _a(S, l, n.pageSize);
2141
+ if (C.page !== l) throw new ze("pagination-stalled", "The server returned a different version page");
2142
+ return C;
2143
+ }, y = (l, g) => {
2144
+ const S = new Map((g ? n.items : []).map((N) => [N.id, N])), C = S.size;
2145
+ l.items.forEach((N) => S.set(N.id, N));
2146
+ const A = [...S.values()];
2147
+ if (!l.items.length && l.total !== null && A.length < l.total || g && l.items.length > 0 && S.size === C)
2148
+ throw new ze("pagination-stalled", "The server returned no additional versions");
2149
+ return {
2150
+ items: A,
2151
+ total: l.total,
2152
+ page: l.page,
2153
+ pageSize: l.pageSize,
2154
+ hasMore: l.total !== null ? A.length < l.total : l.items.length >= l.pageSize,
2155
+ showDrafts: n.showDrafts || !g && A.length > 0 && A.every((N) => N.source === "save"),
2156
+ ...g ? {} : { selection: [], comparison: null, detail: null }
2157
+ };
2158
+ }, w = (l, g) => d(y(l, g)), v = async (l, g, S) => {
2159
+ if (typeof e.confirm != "function") throw new ze("confirmation-required", "Rollback requires explicit confirmation");
2160
+ const C = await ce(() => e.confirm({ kind: l, chainId: n.chainId, version: g, signal: S }), S);
2161
+ return b(S), C === !0;
2162
+ }, p = (l) => {
2163
+ if (!Object.is(c(), l)) throw new ze("draft-changed", "The local draft changed during rollback");
2164
+ }, _ = () => {
2165
+ if (e.canRollback && e.canRollback() !== !0)
2166
+ throw new ze("readonly", "Rollback is disabled in the current editor state");
2167
+ }, x = async (l) => {
2168
+ const g = s, S = n.chainId;
2169
+ d({ phase: "refreshing" });
2170
+ const C = await ce(() => e.fetcher.getContent(S, l), l);
2171
+ b(l);
2172
+ const A = Zr(C, S), N = await m(1, l), L = y(N, !1);
2173
+ p(g.revision), _();
2174
+ const O = { chainId: S, version: g.version, response: g.response, content: A, versions: N };
2175
+ return e.onRolledBack && await ce(() => (p(g.revision), _(), e.onRolledBack(O, l)), l), b(l), d(L), s = null, d({ pendingRollback: !1, lastRollback: O }), !0;
2176
+ }, h = {
2177
+ getState: () => n,
2178
+ subscribe(l) {
2179
+ return a ? () => {
2180
+ } : (i.add(l), l(n), () => {
2181
+ i.delete(l);
2182
+ });
2183
+ },
2184
+ async setChain(l) {
2185
+ return a ? !1 : (u(), s = null, n = r(l), d({}), l ? h.reload() : !1);
2186
+ },
2187
+ reload: () => s ? h.retryReadback() : f("loading", async (l) => (w(await m(1, l), !1), !0)),
2188
+ loadMore: () => !n.hasMore || s ? Promise.resolve(!1) : f("loading-more", async (l) => (w(await m(n.page + 1, l), !0), !0)),
2189
+ setShowDrafts(l) {
2190
+ a || d({ showDrafts: l });
2191
+ },
2192
+ select(l, g) {
2193
+ if (a || o || !n.items.some((C) => C.id === l)) return;
2194
+ const S = n.selection.filter((C) => C !== l);
2195
+ g && S.length < 2 && S.push(l), d({ selection: S, comparison: null });
2196
+ },
2197
+ inspect: (l) => f("detail", async (g) => {
2198
+ const S = await ce(() => e.fetcher.getRuleVersion(n.chainId, l, g), g);
2199
+ return b(g), d({ detail: Mt(S, n.chainId, l) }), !0;
2200
+ }),
2201
+ compareSelected: () => f("comparing", async (l) => {
2202
+ const g = n.items.filter((L) => n.selection.includes(L.id));
2203
+ if (g.length !== 2) return !1;
2204
+ const [S, C] = g, A = Mt(await ce(() => e.fetcher.getRuleVersion(n.chainId, C.id, l), l), n.chainId, C.id), N = Mt(await ce(() => e.fetcher.getRuleVersion(n.chainId, S.id, l), l), n.chainId, S.id);
2205
+ return b(l), d({ comparison: { older: C, newer: S, diff: wa(A.dsl, N.dsl) } }), !0;
2206
+ }),
2207
+ rollback: (l) => f("confirming", async (g) => {
2208
+ var N;
2209
+ if (s) return !1;
2210
+ _();
2211
+ const S = n.items.find((L) => L.id === l);
2212
+ if (!S || ((N = n.items[0]) == null ? void 0 : N.id) === l) return !1;
2213
+ const C = c();
2214
+ if (e.isDirty() && !await v("discard-dirty", S, g) || !await v("rollback", S, g)) return !1;
2215
+ p(C), _(), d({ phase: "rolling-back", lastRollback: null });
2216
+ const A = await ce(() => (p(C), _(), e.fetcher.rollbackRuleVersion(n.chainId, l, g)), g);
2217
+ if (b(g), A === !1) throw new Error("The server rejected rollback");
2218
+ return De(A), s = { version: S, response: A, revision: C }, d({ pendingRollback: !0 }), x(g);
2219
+ }),
2220
+ retryReadback: () => s ? f("confirming", async (l) => {
2221
+ _();
2222
+ const g = s;
2223
+ if (!Object.is(c(), g.revision)) {
2224
+ const S = c();
2225
+ if (!await v("discard-dirty", g.version, l)) return !1;
2226
+ p(S), g.revision = S;
2227
+ }
2228
+ return x(l);
2229
+ }) : Promise.resolve(!1),
2230
+ cancel: u,
2231
+ destroy() {
2232
+ a || (a = !0, i.clear(), u(), s = null);
2233
+ }
2234
+ };
2235
+ return h;
2236
+ }
2237
+ function yt(e) {
2238
+ return e !== null && typeof e == "object" && !Array.isArray(e);
2239
+ }
2240
+ function Ht(e) {
2241
+ if (typeof e == "number") return Number.isFinite(e) ? e : null;
2242
+ if (typeof e != "string" || !e.trim()) return null;
2243
+ const t = Number(e);
2244
+ if (Number.isFinite(t)) return t;
2245
+ const r = Date.parse(e);
2246
+ return Number.isFinite(r) ? r : null;
2247
+ }
2248
+ function Tr(e) {
2249
+ return yt(e) ? Ht(e.ts) : null;
2250
+ }
2251
+ function Bt(e) {
2252
+ const t = Ht(e.startTs) ?? Tr(e.inMsg), r = Ht(e.endTs) ?? Tr(e.outMsg), n = t !== null && r !== null && r < t;
2253
+ return {
2254
+ startTs: t,
2255
+ endTs: r,
2256
+ invalid: n,
2257
+ durationMs: t !== null && r !== null && !n ? r - t : null
2258
+ };
2259
+ }
2260
+ function Ft(e = []) {
2261
+ const t = /* @__PURE__ */ new Map();
2262
+ return e.map((r, n) => {
2263
+ const a = typeof r.nodeId == "string" ? r.nodeId : "", o = (t.get(a) || 0) + 1;
2264
+ return t.set(a, o), { key: `${a}#${o}`, nodeId: a, occurrence: o, index: n, log: r };
2265
+ });
2266
+ }
2267
+ function Je(e) {
2268
+ return e == null || e === !1 || e === "" ? "" : typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
2269
+ }
2270
+ function Gt(e = [], t = {}, r = {}) {
2271
+ const n = Ft(e).map((f) => ({ ...f, timing: Bt(f.log) })).filter((f) => f.nodeId && f.timing.startTs !== null);
2272
+ if (!n.length) return { rows: [], startTs: null, spanMs: 0, scaleMs: 0, omittedCount: e.length, slowest: null, ticks: [] };
2273
+ let a = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
2274
+ for (const { timing: f } of n)
2275
+ a = Math.min(a, f.startTs), o = Math.max(o, f.startTs, f.invalid ? f.startTs : f.endTs ?? f.startTs);
2276
+ Number.isFinite(r.observedUntil) && (o = Math.max(o, r.observedUntil));
2277
+ const s = Math.max(0, o - a), i = Number.isFinite(r.scaleMs) ? Math.max(s, r.scaleMs) : s, d = Math.max(i, 1);
2278
+ let c = 0;
2279
+ const u = n.map(({ timing: f, ...b }) => {
2280
+ const m = f.durationMs;
2281
+ m !== null && (c = Math.max(c, m));
2282
+ const y = f.invalid ? 0 : m ?? Math.max(0, o - f.startTs), w = f.startTs - a, v = Math.min(100, w / d * 100);
2283
+ return {
2284
+ ...b,
2285
+ label: t[b.nodeId] || b.nodeId,
2286
+ startTs: f.startTs,
2287
+ endTs: f.endTs,
2288
+ offsetMs: w,
2289
+ durationMs: m,
2290
+ observedMs: y,
2291
+ unfinished: f.endTs === null,
2292
+ invalidTiming: f.invalid,
2293
+ err: Je(b.log.err),
2294
+ isSlowest: !1,
2295
+ left: v,
2296
+ width: Math.max(0, Math.min(100 - v, y / d * 100))
2297
+ };
2298
+ });
2299
+ return u.forEach((f) => {
2300
+ f.isSlowest = c > 0 && f.durationMs === c;
2301
+ }), {
2302
+ rows: u,
2303
+ startTs: a,
2304
+ spanMs: s,
2305
+ scaleMs: i,
2306
+ omittedCount: e.length - u.length,
2307
+ slowest: u.find((f) => f.isSlowest) || null,
2308
+ ticks: [0, 25, 50, 75, 100].map((f) => ({ pct: f, offsetMs: i * f / 100 }))
2309
+ };
2310
+ }
2311
+ const $r = /* @__PURE__ */ new Set(["ts", "_ts", "id", "msgId"]);
2312
+ function Vt(e) {
2313
+ if (typeof e != "string") return e;
2314
+ try {
2315
+ return JSON.parse(e);
2316
+ } catch {
2317
+ return e;
2318
+ }
2319
+ }
2320
+ function me(e) {
2321
+ return yt(e) ? Object.fromEntries(Object.entries(e).filter(([t]) => !$r.has(t)).map(([t, r]) => [
2322
+ t,
2323
+ t === "data" ? Vt(r) : t === "metadata" && yt(r) ? Object.fromEntries(Object.entries(r).filter(([n]) => !$r.has(n))) : r
2324
+ ])) : e;
2325
+ }
2326
+ function Ue(e) {
2327
+ var t, r;
2328
+ return (r = (t = e.logs) == null ? void 0 : t[0]) == null ? void 0 : r.inMsg;
2329
+ }
2330
+ function Mr(e) {
2331
+ if (!e) return "";
2332
+ const t = Ue(e);
2333
+ if (t != null) {
2334
+ const r = ue(me(t));
2335
+ let n = 5381;
2336
+ for (let a = 0; a < r.length; a += 1) n = (n << 5) + n + r.charCodeAt(a) | 0;
2337
+ return `d:${(n >>> 0).toString(16)}`;
2338
+ }
2339
+ return `s:${e.msgType || ""}|${typeof e.msgData == "string" ? e.msgData : ue(e.msgData)}`;
2340
+ }
2341
+ function Sa(e, t) {
2342
+ return {
2343
+ inDiff: Ae(me(e == null ? void 0 : e.inMsg), me(t == null ? void 0 : t.inMsg)),
2344
+ outDiff: Ae(me(e == null ? void 0 : e.outMsg), me(t == null ? void 0 : t.outMsg))
2345
+ };
2346
+ }
2347
+ function xa(e, t) {
2348
+ const r = new Map(t.map((y, w) => [y.key, w])), n = e.filter((y) => r.has(y.key)), a = [], o = new Array(n.length).fill(-1);
2349
+ n.forEach((y, w) => {
2350
+ const v = r.get(y.key);
2351
+ let p = 0, _ = a.length;
2352
+ for (; p < _; ) {
2353
+ const x = p + _ >>> 1;
2354
+ r.get(n[a[x]].key) < v ? p = x + 1 : _ = x;
2355
+ }
2356
+ p && (o[w] = a[p - 1]), a[p] = w;
2357
+ });
2358
+ const s = [];
2359
+ for (let y = a[a.length - 1] ?? -1; y >= 0; y = o[y]) s.push(n[y].key);
2360
+ s.reverse();
2361
+ const i = new Set(s), d = new Set(e.map((y) => y.key)), c = [], u = /* @__PURE__ */ new Set(), f = (y) => {
2362
+ u.has(y) || (u.add(y), c.push({ key: y, moved: d.has(y) && r.has(y) && !i.has(y) }));
2363
+ };
2364
+ let b = 0, m = 0;
2365
+ for (const y of s) {
2366
+ for (; b < e.length && e[b].key !== y; ) f(e[b++].key);
2367
+ for (; m < t.length && t[m].key !== y; ) f(t[m++].key);
2368
+ f(y), b += 1, m += 1;
2369
+ }
2370
+ for (; b < e.length; ) f(e[b++].key);
2371
+ for (; m < t.length; ) f(t[m++].key);
2372
+ return c;
2373
+ }
2374
+ function Nr(e) {
2375
+ return typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0 ? e.durationMs : null;
2376
+ }
2377
+ function Ca(e, t) {
2378
+ const r = e, n = t, a = r.level !== "summary" && Array.isArray(r.logs) && r.logs.length > 0, o = n.level !== "summary" && Array.isArray(n.logs) && n.logs.length > 0, s = a && o ? "detail" : a || o ? "mixed" : "summary", i = Ue(r), d = Ue(n), c = i != null && d != null, u = typeof r.success == "boolean" ? r.success : null, f = typeof n.success == "boolean" ? n.success : null, b = (_) => String(_.msgType || (yt(Ue(_)) ? Ue(_).type : "") || ""), m = {
2379
+ level: s,
2380
+ pair: {
2381
+ same: c ? ue(me(i)) === ue(me(d)) : null,
2382
+ confidence: c ? "input" : "summary",
2383
+ keyA: Mr(r),
2384
+ keyB: Mr(n)
2385
+ },
2386
+ chain: {
2387
+ successA: u,
2388
+ successB: f,
2389
+ successDiff: u !== f,
2390
+ errA: Je(r.errorMsg),
2391
+ errB: Je(n.errorMsg),
2392
+ durationA: Nr(r),
2393
+ durationB: Nr(n),
2394
+ msgTypeA: b(r),
2395
+ msgTypeB: b(n),
2396
+ outDiff: Ae(Vt(r.msgData), Vt(n.msgData))
2397
+ },
2398
+ timeline: [],
2399
+ firstDivergence: null,
2400
+ counts: { same: 0, diverge: 0, error: 0, onlyA: 0, onlyB: 0, unknown: 0 }
2401
+ };
2402
+ if (s !== "detail") return m;
2403
+ const y = Ft(r.logs), w = Ft(n.logs), v = new Map(y.map((_) => [_.key, _])), p = new Map(w.map((_) => [_.key, _]));
2404
+ for (const { key: _, moved: x } of xa(y, w)) {
2405
+ const h = v.get(_), l = p.get(_), g = h || l, S = h == null ? void 0 : h.log, C = l == null ? void 0 : l.log, A = Je(S == null ? void 0 : S.err), N = Je(C == null ? void 0 : C.err), L = (S == null ? void 0 : S.relationType) || "", O = (C == null ? void 0 : C.relationType) || "", I = (S == null ? void 0 : S.outMsg) == null || (C == null ? void 0 : C.outMsg) == null, z = ue(me(S == null ? void 0 : S.outMsg)) === ue(me(C == null ? void 0 : C.outMsg)), G = h ? l ? A !== N ? "error" : x || L !== O ? "diverge" : !g.nodeId || I && !A && !N ? "unknown" : !A && !N && z ? "same" : "diverge" : "only-a" : "only-b";
2406
+ G !== "same" && G !== "unknown" && !m.firstDivergence && (m.firstDivergence = { key: _, nodeId: g.nodeId });
2407
+ const K = G === "only-a" ? "onlyA" : G === "only-b" ? "onlyB" : G;
2408
+ m.counts[K] += 1, m.timeline.push({
2409
+ key: _,
2410
+ nodeId: g.nodeId,
2411
+ occurrence: g.occurrence,
2412
+ status: G,
2413
+ orderChanged: x,
2414
+ downstream: m.firstDivergence !== null && m.firstDivergence.key !== _,
2415
+ aDur: S ? Bt(S).durationMs : null,
2416
+ bDur: C ? Bt(C).durationMs : null,
2417
+ aErr: A,
2418
+ bErr: N,
2419
+ aRel: L,
2420
+ bRel: O,
2421
+ a: S,
2422
+ b: C
2423
+ });
2424
+ }
2425
+ return m;
2426
+ }
2427
+ const en = `
2428
+ .hb_analysis { min-width:0; max-width:100%; color:var(--hb-text-primary); background:var(--hb-bg-modal); font:inherit; font-size:13px; line-height:1.5; letter-spacing:0; overflow-wrap:anywhere; }
2429
+ .hb_analysis *, .hb_analysis_modal * { box-sizing:border-box; }
2430
+ .hb_analysis [hidden] { display:none!important; }
2431
+ .hb_analysis h3 { font-size:14px; margin:12px 0 8px; line-height:1.5; }
2432
+ .hb_analysis_header, .hb_analysis_tools { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-bottom:8px; }
2433
+ .hb_analysis_header h3 { margin:0; flex:1; }
2434
+ .hb_analysis button, .hb_analysis select { font:inherit; color:var(--hb-text-primary); background:var(--hb-bg-input); border:1px solid var(--hb-border-color); border-radius:4px; min-height:32px; max-width:100%; }
2435
+ .hb_analysis button { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:4px 8px; cursor:pointer; overflow-wrap:anywhere; white-space:normal; }
2436
+ .hb_analysis button:hover:not(:disabled) { background:var(--hb-bg-hover); }
2437
+ .hb_analysis button:disabled { color:var(--hb-text-disabled); cursor:not-allowed; }
2438
+ .hb_analysis button:focus-visible, .hb_analysis select:focus-visible, .hb_analysis summary:focus-visible { outline:2px solid var(--hb-color-primary); outline-offset:2px; }
2439
+ .hb_analysis button svg { flex:none; width:16px; height:16px; }
2440
+ .hb_analysis .hb_analysis_icon { width:32px; height:32px; padding:6px; flex:none; }
2441
+ .hb_analysis .hb_analysis_danger { color:var(--hb-color-danger); }
2442
+ .hb_analysis label { display:flex; align-items:center; flex-wrap:wrap; gap:6px; min-width:0; }
2443
+ .hb_analysis select { padding:4px 8px; min-width:0; }
2444
+ .hb_analysis input[type=checkbox] { accent-color:var(--hb-color-primary); }
2445
+ .hb_analysis_muted { color:var(--hb-text-secondary); }
2446
+ .hb_analysis_error { color:var(--hb-color-danger); white-space:pre-wrap; }
2447
+ .hb_analysis_notice { padding:8px 0; border-bottom:1px solid var(--hb-border-light); }
2448
+ .hb_analysis_warning { color:var(--hb-color-warning); }
2449
+ .hb_analysis_success { color:var(--hb-color-success); }
2450
+ .hb_analysis_table_wrap { width:100%; overflow:auto; }
2451
+ .hb_analysis table { border-collapse:collapse; width:100%; text-align:left; table-layout:fixed; }
2452
+ .hb_analysis th, .hb_analysis td { padding:8px; border-bottom:1px solid var(--hb-border-light); text-align:left; vertical-align:top; overflow-wrap:anywhere; }
2453
+ .hb_analysis th { color:var(--hb-text-secondary); font-weight:600; background:var(--hb-bg-section); }
2454
+ .hb_analysis .hb_analysis_diff_table { min-width:480px; }
2455
+ .hb_analysis .hb_analysis_diff_table th:first-child { width:22%; }
2456
+ .hb_analysis .hb_analysis_diff_table th:nth-child(2) { width:14%; }
2457
+ .hb_analysis pre { font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace; white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; margin:4px 0; max-width:100%; }
2458
+ .hb_analysis .hb_analysis_json { max-height:360px; overflow:auto; padding:8px; background:var(--hb-bg-section); }
2459
+ .hb_analysis details { min-width:0; margin:6px 0; }
2460
+ .hb_analysis summary { cursor:pointer; color:var(--hb-text-primary); padding:4px 0; }
2461
+ .hb_analysis_summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr)); gap:12px; padding:8px 0; border-bottom:1px solid var(--hb-border-light); }
2462
+ .hb_analysis_summary section { min-width:0; }
2463
+ .hb_analysis_pair { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,380px),1fr)); gap:16px; margin-top:12px; }
2464
+ .hb_analysis_waterfall_chart { min-width:460px; }
2465
+ .hb_analysis_waterfall_axis, .hb_analysis_waterfall_row { display:grid; grid-template-columns:minmax(110px,160px) minmax(180px,1fr) 90px; gap:8px; align-items:center; }
2466
+ .hb_analysis_waterfall_axis { min-height:22px; color:var(--hb-text-secondary); font-size:11px; }
2467
+ .hb_analysis_waterfall_row { min-height:32px; padding:3px 0; }
2468
+ .hb_analysis_waterfall_axis_track, .hb_analysis_waterfall_track { position:relative; min-width:0; height:22px; }
2469
+ .hb_analysis_waterfall_track { background:var(--hb-bg-section); overflow:hidden; }
2470
+ .hb_analysis_waterfall_tick { position:absolute; transform:translateX(-50%); white-space:nowrap; }
2471
+ .hb_analysis_waterfall_tick:first-child { transform:none; }
2472
+ .hb_analysis_waterfall_tick:last-child { transform:translateX(-100%); }
2473
+ .hb_analysis_waterfall_bar { position:absolute; height:12px; top:5px; min-width:2px; max-width:100%; border-radius:2px; background:var(--hb-color-primary); }
2474
+ .hb_analysis_waterfall_bar.is_error { background:var(--hb-color-danger); }
2475
+ .hb_analysis_waterfall_bar.is_unfinished { background:transparent; border:1px dashed var(--hb-color-warning); }
2476
+ .hb_analysis_waterfall_bar.is_invalid { background:var(--hb-color-warning); }
2477
+ .hb_analysis .hb_analysis_node { border:0; background:transparent; padding:0; min-height:26px; justify-content:flex-start; text-align:left; }
2478
+ .hb_analysis_timeline { min-width:720px; }
2479
+ .hb_analysis_timeline th:first-child { width:23%; }
2480
+ .hb_analysis_timeline th:last-child { width:11%; }
2481
+ .hb_analysis_timeline tr[data-downstream=true] > td { color:var(--hb-text-secondary); }
2482
+ .hb_analysis_badge { display:inline-block; font-size:11px; padding:1px 4px; border:1px solid var(--hb-border-color); border-radius:3px; margin-left:4px; }
2483
+ .hb_analysis_modal_wrapper { color:var(--hb-text-primary); font-family:inherit; }
2484
+ .hb_analysis_modal_wrapper > .huanban_modal_overlay { position:fixed; inset:0; background:var(--hb-overlay); z-index:var(--hb-z-modal-backdrop,${Dt.modalBackdrop}); }
2485
+ .hb_analysis_modal_wrapper > .hb_analysis_modal { position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); width:1040px; max-width:calc(100vw - 24px); max-height:calc(100dvh - 24px); display:flex; flex-direction:column; background:var(--hb-bg-modal); border:1px solid var(--hb-border-color); border-radius:8px; box-shadow:var(--hb-shadow-lg); z-index:var(--hb-z-modal,${Dt.modal}); }
2486
+ .hb_analysis_modal_header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; border-bottom:1px solid var(--hb-border-light); }
2487
+ .hb_analysis_modal_header h2 { font-size:16px; line-height:1.5; margin:0; overflow-wrap:anywhere; }
2488
+ .hb_analysis_modal_body { padding:12px 16px; overflow:auto; min-height:0; }
2489
+ `;
2490
+ function ne(e, t) {
2491
+ const r = e;
2492
+ (r.__analysisLocaleBindings || (r.__analysisLocaleBindings = [])).push(t), t();
2493
+ }
2494
+ function St(e) {
2495
+ for (const t of [e, ...Array.from(e.querySelectorAll("*"))])
2496
+ for (const r of t.__analysisLocaleBindings || []) r();
2497
+ }
2498
+ function Xt(e) {
2499
+ return typeof e == "function" ? e() : e;
2500
+ }
2501
+ function T(e, t = "", r) {
2502
+ const n = document.createElement(e);
2503
+ return n.className = t, typeof r == "function" ? ne(n, () => {
2504
+ n.textContent = r();
2505
+ }) : r !== void 0 && (n.textContent = r), n;
2506
+ }
2507
+ function xt(e, t, r, n = !1) {
2508
+ const a = T("button", n ? "hb_analysis_icon" : "");
2509
+ a.type = "button", a.innerHTML = Ne(e), n || a.append(T("span", "hb_analysis_button_label", t));
2510
+ const o = () => {
2511
+ a.title = Xt(t), a.setAttribute("aria-label", a.title);
2512
+ };
2513
+ return typeof t == "function" ? ne(a, o) : o(), a.addEventListener("click", r), a;
2514
+ }
2515
+ function Zt(e, t = {}) {
2516
+ const r = T("section", "hb_analysis");
2517
+ ne(r, () => {
2518
+ r.lang = _t(t);
2519
+ }), t.theme && !jr(e) && !e.closest("[data-theme]") && Object.entries(Jt(t.theme)).forEach(([a, o]) => r.style.setProperty(a, o));
2520
+ const n = T("style");
2521
+ return n.textContent = en, r.append(n), e.append(r), r;
2522
+ }
2523
+ function Ye(e, t, r, n, a) {
2524
+ const o = T("details");
2525
+ o.append(T("summary", "", t));
2526
+ let s = !1;
2527
+ o.addEventListener("toggle", () => {
2528
+ if (!o.open || s) return;
2529
+ s = !0;
2530
+ const i = wt(r), d = T("div");
2531
+ d.setAttribute("role", "status");
2532
+ let c = null, u = "";
2533
+ const f = () => {
2534
+ d.textContent = c === "copied" ? n("common.copied") : c === "failed" ? n("common.copyFailed", { error: u }) : "";
2535
+ };
2536
+ ne(d, f);
2537
+ const b = xt("copy", () => n("common.copy"), () => {
2538
+ Promise.resolve().then(() => navigator.clipboard.writeText(i)).then(() => {
2539
+ o.isConnected && (c = "copied", f());
2540
+ }, (m) => {
2541
+ o.isConnected && (c = "failed", u = m instanceof Error ? m.message : String(m), f(), d.className = "hb_analysis_error", a == null || a(d.textContent || "", "error"));
2542
+ });
2543
+ }, !0);
2544
+ o.append(b, d, T("pre", "hb_analysis_json", i));
2545
+ }), e.append(o);
2546
+ }
2547
+ function Nt(e, t, r, n) {
2548
+ const a = T("details", "hb_analysis_diff");
2549
+ a.append(T("summary", "", () => `${Xt(t)} (${r.length})`));
2550
+ let o = !1;
2551
+ a.addEventListener("toggle", () => {
2552
+ if (!a.open || o) return;
2553
+ if (o = !0, !r.length) {
2554
+ a.append(T("p", "hb_analysis_muted", () => n("common.none")));
2555
+ return;
2556
+ }
2557
+ const s = T("table", "hb_analysis_diff_table"), i = s.createTHead().insertRow();
2558
+ for (const u of ["common.path", "common.change", "common.before", "common.after"]) i.append(T("th", "", () => n(u)));
2559
+ const d = s.createTBody();
2560
+ for (const u of r) {
2561
+ const f = d.insertRow();
2562
+ f.insertCell().textContent = u.path;
2563
+ const b = f.insertCell();
2564
+ ne(b, () => {
2565
+ b.textContent = n(`common.${u.kind}`);
2566
+ });
2567
+ for (const [m, y] of [[u.kind !== "added", u.before], [u.kind !== "removed", u.after]]) {
2568
+ const w = f.insertCell();
2569
+ if (!m) {
2570
+ w.textContent = "-";
2571
+ continue;
2572
+ }
2573
+ const v = vt({ [u.path]: y }, { maxDepth: 1 / 0, maxString: 1 / 0, maxArray: 1 / 0 });
2574
+ w.append(T("pre", "", wt(v[u.path], !1)));
2575
+ }
2576
+ }
2577
+ const c = T("div", "hb_analysis_table_wrap");
2578
+ c.append(s), a.append(c);
2579
+ }), e.append(a);
2580
+ }
2581
+ function ka(e, t, r) {
2582
+ var h, l;
2583
+ const n = e._activeModalWrapper;
2584
+ n && (e._closeModal ? e._closeModal() : ((h = n.__huanbanCleanup) == null || h.call(n), n.remove()));
2585
+ const a = rt(r), o = document.activeElement instanceof HTMLElement ? document.activeElement : null, s = T("div", "hb_analysis_modal_wrapper"), i = Wt(s, e.rootEl || { opts: { theme: r.theme || ((l = e.opts) == null ? void 0 : l.theme) } }), d = T("style");
2586
+ d.textContent = en;
2587
+ const c = T("div", "huanban_modal_overlay"), u = T("section", "huanban_modal hb_analysis_modal hb_analysis");
2588
+ u.tabIndex = -1, u.setAttribute("role", "dialog"), u.setAttribute("aria-modal", "true"), ne(u, () => {
2589
+ u.setAttribute("aria-label", Xt(t));
2590
+ });
2591
+ const f = T("header", "huanban_modal_header hb_analysis_modal_header"), b = T("div", "hb_analysis_modal_body");
2592
+ let m = !1;
2593
+ const y = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), v = () => {
2594
+ if (!m) {
2595
+ m = !0, document.removeEventListener("keydown", _);
2596
+ for (const g of y) g();
2597
+ y.clear(), w.clear(), i(), s.remove(), e._activeModalWrapper === s && (e._activeModalWrapper = null), o != null && o.isConnected && o.focus();
2598
+ }
2599
+ }, p = xt("error", () => a("common.close"), v, !0), _ = (g) => {
2600
+ var N;
2601
+ if (!s.contains(document.activeElement) || (g.key === "Escape" && (g.preventDefault(), g.stopPropagation(), v()), g.key !== "Tab")) return;
2602
+ const S = Array.from(u.querySelectorAll('button:not(:disabled),select:not(:disabled),input:not(:disabled),summary,textarea,[tabindex="0"]')).filter((L) => !L.closest("[hidden]") && !L.closest("details:not([open]) > :not(summary)")), C = S[0], A = S[S.length - 1];
2603
+ S.includes(document.activeElement) ? g.shiftKey && document.activeElement === C ? (g.preventDefault(), A == null || A.focus()) : !g.shiftKey && document.activeElement === A && (g.preventDefault(), C == null || C.focus()) : (g.preventDefault(), (N = g.shiftKey ? A : C) == null || N.focus());
2604
+ };
2605
+ f.append(T("h2", "", t), p), u.append(f, b), s.append(d, c, u), c.addEventListener("click", v), s.__huanbanCleanup = v;
2606
+ const x = () => {
2607
+ if (!m) {
2608
+ for (const g of w) g();
2609
+ s.lang = _t(r), St(s);
2610
+ }
2611
+ };
2612
+ return s.__huanbanRefreshLocale = x, e._activeModalWrapper = s, (e.rootEl || document.body).append(s), document.addEventListener("keydown", _), p.focus(), {
2613
+ element: s,
2614
+ body: b,
2615
+ close: v,
2616
+ destroy: v,
2617
+ refreshLocale: x,
2618
+ addCleanup: (g) => {
2619
+ y.add(g);
2620
+ },
2621
+ addLocaleRefresh: (g) => {
2622
+ w.add(g);
2623
+ }
2624
+ };
2625
+ }
2626
+ function ye(e) {
2627
+ return e === null ? "-" : `${Number(e.toFixed(3))} ms`;
2628
+ }
2629
+ function Lr(e) {
2630
+ const t = ye(e);
2631
+ return t.length > 10 ? `${e.toExponential(1)} ms` : t;
2632
+ }
2633
+ function tn(e, t) {
2634
+ const r = Zt(e, t), n = T("div");
2635
+ r.append(n);
2636
+ let a = !1;
2637
+ const o = (s) => {
2638
+ if (a) return;
2639
+ n.replaceChildren();
2640
+ const i = rt(s), d = Gt(s.logs, s.nodeNames, s), c = T("header", "hb_analysis_header");
2641
+ if (c.append(T("h3", "", () => i("run.waterfall")), T("span", "hb_analysis_muted", () => i("run.elapsed", { duration: ye(d.spanMs) }))), n.append(c), d.omittedCount && n.append(T("p", "hb_analysis_warning", () => i("run.omitted", { count: d.omittedCount }))), !d.rows.length) {
2642
+ n.append(T("p", "hb_analysis_muted", () => i("run.empty")));
2643
+ return;
2644
+ }
2645
+ const u = T("div", "hb_analysis_table_wrap"), f = T("div", "hb_analysis_waterfall_chart");
2646
+ f.setAttribute("role", "list"), ne(f, () => {
2647
+ f.setAttribute("aria-label", i("run.waterfall"));
2648
+ });
2649
+ const b = T("div", "hb_analysis_waterfall_axis"), m = T("div", "hb_analysis_waterfall_axis_track"), y = Math.max(...d.ticks.map((p) => Lr(p.offsetMs).length)), w = d.ticks.filter((p) => y <= 5 || p.pct % (y <= 8 ? 50 : 100) === 0);
2650
+ for (const p of w) {
2651
+ const _ = T("span", "hb_analysis_waterfall_tick", Lr(p.offsetMs));
2652
+ _.style.left = `${p.pct}%`, m.append(_);
2653
+ }
2654
+ b.append(T("span", "", () => i("run.node")), m, T("span", "", () => i("common.duration"))), f.append(b);
2655
+ const v = T("div");
2656
+ for (const p of d.rows) {
2657
+ const _ = T("div", "hb_analysis_waterfall_row");
2658
+ _.dataset.runKey = p.key, _.setAttribute("role", "listitem");
2659
+ const x = xt("data", `${p.label} (${p.occurrence})`, () => {
2660
+ var C;
2661
+ v.replaceChildren(), Ye(v, () => `${p.label}: ${i("common.fullJson")}`, p.log, i, s.notify);
2662
+ const S = v.querySelector("details");
2663
+ S && (S.open = !0), (C = s.onNodeSelect) == null || C.call(s, p.nodeId);
2664
+ });
2665
+ x.classList.add("hb_analysis_node"), ne(x, () => {
2666
+ x.title = `${p.nodeId}: ${i("run.occurrence", { count: p.occurrence })}`;
2667
+ }), p.isSlowest && x.append(T("span", "hb_analysis_badge", () => i("run.slowest")));
2668
+ const h = T("div", "hb_analysis_waterfall_track"), l = T("div", `hb_analysis_waterfall_bar${p.err ? " is_error" : ""}${p.unfinished ? " is_unfinished" : ""}${p.invalidTiming ? " is_invalid" : ""}`);
2669
+ l.style.left = `min(${p.left}%, calc(100% - 2px))`, l.style.width = `${p.width}%`, ne(h, () => {
2670
+ h.title = `${p.label}; ${i("run.offset")}: ${ye(p.offsetMs)}; ${i("common.duration")}: ${ye(p.durationMs)}` + (p.unfinished ? `; ${i("run.unfinished")}` : "") + (p.invalidTiming ? `; ${i("run.invalidTiming")}` : "") + (p.err ? `; ${p.err}` : ""), h.setAttribute("aria-label", h.title);
2671
+ }), h.append(l);
2672
+ const g = T("span", p.err ? "hb_analysis_error" : "", ye(p.durationMs));
2673
+ (p.unfinished || p.invalidTiming) && g.append(T("small", "hb_analysis_muted", () => ` ${i(p.unfinished ? "run.unfinished" : "run.invalidTiming")}`)), _.append(x, h, g), f.append(_);
2674
+ }
2675
+ u.append(f), n.append(u, v);
2676
+ };
2677
+ return o(t), { element: r, update: o, refreshLocale() {
2678
+ a || St(r);
2679
+ }, destroy() {
2680
+ a = !0, r.remove();
2681
+ } };
2682
+ }
2683
+ function rn(e, t) {
2684
+ const r = Zt(e, t), n = T("div");
2685
+ r.append(n);
2686
+ let a = [], o = !1;
2687
+ const s = (i) => {
2688
+ if (o) return;
2689
+ a.forEach((h) => h.destroy()), a = [], n.replaceChildren();
2690
+ const d = rt(i), c = Ca(i.detailA, i.detailB), u = (h) => {
2691
+ var l;
2692
+ return ((l = i.nodeNames) == null ? void 0 : l[h]) || h || d("common.unknown");
2693
+ }, f = () => c.level !== "detail" ? d("run.summary") : c.firstDivergence ? d("run.firstDivergence", { node: u(c.firstDivergence.nodeId) }) : d(c.counts.unknown ? "run.incomplete" : "run.identical");
2694
+ n.append(T("h3", "", f));
2695
+ const b = T("div", "hb_analysis_summary");
2696
+ for (const [h, l, g, S, C] of [
2697
+ [i.detailA, "run.baseline", c.chain.successA, c.chain.durationA, c.chain.errA],
2698
+ [i.detailB, "run.candidate", c.chain.successB, c.chain.durationB, c.chain.errB]
2699
+ ]) {
2700
+ const A = T("section");
2701
+ A.append(
2702
+ T("strong", "", () => d(l)),
2703
+ T("div", "hb_analysis_muted", () => `${Ve(h)} | ${Yr(h, _t(i))}`),
2704
+ T("div", "", () => `${d(g === null ? "common.unknown" : g ? "common.success" : "common.failed")} | ${ye(S)}`)
2705
+ ), C && A.append(T("pre", "hb_analysis_error", C)), Ye(A, () => d("common.fullJson"), h, d, i.notify), b.append(A);
2706
+ }
2707
+ if (n.append(b), c.pair.same !== !0 && n.append(T("p", "hb_analysis_notice hb_analysis_warning", () => d(c.pair.same === !1 ? "run.inputDifferent" : "run.inputUnknown"))), c.level !== "detail" && n.append(T("p", "hb_analysis_notice hb_analysis_muted", () => d(c.level === "mixed" ? "run.mixed" : "run.summaryOnly"))), Nt(n, () => d("run.chainOutput"), c.chain.outDiff, d), c.level !== "detail") return;
2708
+ const m = T("div", "hb_analysis_table_wrap"), y = T("table", "hb_analysis_timeline"), w = y.createTHead().insertRow();
2709
+ for (const h of ["run.node", "run.result", "run.durationA", "run.durationB", "run.delta", "common.details"]) w.append(T("th", "", () => d(h)));
2710
+ const v = y.createTBody(), p = (h, l) => {
2711
+ h.append(T("div", "", () => `${d("run.relationA")}: ${l.aRel || "-"} | ${d("run.relationB")}: ${l.bRel || "-"}`)), l.orderChanged && h.append(T("div", "hb_analysis_warning", () => d("run.orderChanged"))), l.aErr && h.append(T("pre", "hb_analysis_error", () => `${d("run.errorA")}: ${l.aErr}`)), l.bErr && h.append(T("pre", "hb_analysis_error", () => `${d("run.errorB")}: ${l.bErr}`));
2712
+ const g = Sa(l.a, l.b);
2713
+ Nt(h, () => d("run.inputDiff"), g.inDiff, d), Nt(h, () => d("run.outputDiff"), g.outDiff, d), l.a && Ye(h, () => `${d("run.baseline")}: ${d("common.fullJson")}`, l.a, d, i.notify), l.b && Ye(h, () => `${d("run.candidate")}: ${d("common.fullJson")}`, l.b, d, i.notify);
2714
+ };
2715
+ for (const h of c.timeline) {
2716
+ const l = v.insertRow();
2717
+ l.dataset.runKey = h.key, l.dataset.downstream = String(h.downstream), h.downstream && ne(l, () => {
2718
+ l.title = d("run.downstream");
2719
+ });
2720
+ const g = l.insertCell();
2721
+ ne(g, () => {
2722
+ g.textContent = `${u(h.nodeId)} (${h.occurrence})`;
2723
+ }), g.title = h.key;
2724
+ const S = l.insertCell();
2725
+ ne(S, () => {
2726
+ S.textContent = d(`run.status.${h.status}`);
2727
+ }), l.insertCell().textContent = ye(h.aDur), l.insertCell().textContent = ye(h.bDur);
2728
+ const C = h.aDur !== null && h.bDur !== null ? h.bDur - h.aDur : null;
2729
+ l.insertCell().textContent = C === null ? "-" : `${C > 0 ? "+" : ""}${ye(C)}`;
2730
+ const A = l.insertCell(), N = v.insertRow();
2731
+ N.hidden = !0;
2732
+ const L = N.insertCell();
2733
+ L.colSpan = 6;
2734
+ let O = !1;
2735
+ const I = xt("data", () => d("common.details"), () => {
2736
+ N.hidden = !N.hidden, I.setAttribute("aria-expanded", String(!N.hidden)), O || (O = !0, p(L, h));
2737
+ }, !0);
2738
+ I.setAttribute("aria-expanded", "false"), A.append(I);
2739
+ }
2740
+ m.append(y), n.append(m);
2741
+ const _ = T("div", "hb_analysis_pair"), x = Math.max(Gt(i.detailA.logs).spanMs, Gt(i.detailB.logs).spanMs);
2742
+ for (const [h, l] of [[i.detailA, "run.baseline"], [i.detailB, "run.candidate"]]) {
2743
+ const g = T("section");
2744
+ g.append(T("h3", "", () => d(l))), a.push(tn(g, { ...i, logs: h.logs || [], scaleMs: x })), _.append(g);
2745
+ }
2746
+ n.append(_);
2747
+ };
2748
+ return s(t), {
2749
+ element: r,
2750
+ update: s,
2751
+ refreshLocale() {
2752
+ o || St(r);
2753
+ },
2754
+ destroy() {
2755
+ o = !0, a.forEach((i) => i.destroy()), r.remove();
2756
+ }
2757
+ };
2758
+ }
2759
+ function Aa(e, t) {
2760
+ const r = Zt(e, t), n = rt(t), a = T("div", "hb_analysis_tools"), o = T("div", "hb_analysis_notice");
2761
+ o.setAttribute("role", "status");
2762
+ const s = T("div");
2763
+ r.append(a, o, s);
2764
+ let i = t.records, d = null, c = null, u = !1, f = () => "";
2765
+ const b = (x, h = !1) => {
2766
+ f = x, o.className = `hb_analysis_notice${h ? " hb_analysis_error" : ""}`, o.setAttribute("role", h ? "alert" : "status"), o.textContent = f();
2767
+ };
2768
+ ne(o, () => {
2769
+ o.textContent = f();
2770
+ });
2771
+ const m = ["run.selectA", "run.selectB"].map((x) => {
2772
+ const h = T("label"), l = T("select");
2773
+ return ne(l, () => {
2774
+ l.setAttribute("aria-label", n(x));
2775
+ }), h.append(T("span", "", () => n(x)), l), a.append(h), l;
2776
+ }), y = () => {
2777
+ d == null || d.abort(), d = null;
2778
+ }, w = () => {
2779
+ c == null || c.destroy(), c = null, s.replaceChildren();
2780
+ }, v = async (x, h) => {
2781
+ var S;
2782
+ if (u) return !1;
2783
+ if (y(), w(), x === h || Ve(x) && Ve(x) === Ve(h) && x.chainId === h.chainId)
2784
+ return b(() => n("run.sameRecord")), !1;
2785
+ const l = new AbortController();
2786
+ d = l, b(() => n("run.detailLoading")), r.setAttribute("aria-busy", "true");
2787
+ const g = async (C) => {
2788
+ const A = t.loadDetail ? await ce(() => t.loadDetail(C, l.signal), l.signal) : C;
2789
+ if (!A || typeof A != "object" || Array.isArray(A) || A.logs !== void 0 && !Array.isArray(A.logs) || C.id && A.id !== C.id || C.chainId && A.chainId && C.chainId !== A.chainId) throw new Error(n("run.invalidRecord"));
2790
+ return A;
2791
+ };
2792
+ try {
2793
+ const C = await g(x), A = await g(h);
2794
+ return l.signal.aborted || u || d !== l ? !1 : (c = rn(s, { ...t, detailA: C, detailB: A }), b(() => ""), !0);
2795
+ } catch (C) {
2796
+ return !l.signal.aborted && !u && d === l && (b(() => n("run.loadFailed", { error: C instanceof Error ? C.message : String(C) }), !0), (S = t.notify) == null || S.call(t, o.textContent, "error")), !1;
2797
+ } finally {
2798
+ d === l && (d = null, r.setAttribute("aria-busy", "false"));
2799
+ }
2800
+ }, p = () => {
2801
+ y(), w(), r.setAttribute("aria-busy", "false");
2802
+ const [x, h] = m.map((l) => l.value === "" ? void 0 : i[Number(l.value)]);
2803
+ x && h ? v(x, h) : b(() => n("run.noPair"));
2804
+ };
2805
+ m.forEach((x) => x.addEventListener("change", p));
2806
+ const _ = (x) => {
2807
+ if (!u) {
2808
+ y(), w(), i = x;
2809
+ for (const h of m)
2810
+ h.replaceChildren(new Option("-", "")), i.forEach((l, g) => {
2811
+ const S = new Option("", String(g));
2812
+ ne(S, () => {
2813
+ S.textContent = `${Ve(l) || g + 1} | ${Yr(l, _t(t))}`;
2814
+ }), h.append(S);
2815
+ });
2816
+ b(() => n("run.noPair")), r.setAttribute("aria-busy", "false");
2817
+ }
2818
+ };
2819
+ return _(i), {
2820
+ element: r,
2821
+ setRecords: _,
2822
+ compare: v,
2823
+ refreshLocale() {
2824
+ u || St(r);
2825
+ },
2826
+ destroy() {
2827
+ u = !0, y(), w(), r.remove();
2828
+ }
2829
+ };
2830
+ }
2831
+ function _o(e, t) {
2832
+ const r = {
2833
+ ...t,
2834
+ locale: t.locale || (() => {
2835
+ var o;
2836
+ return ((o = e.opts) == null ? void 0 : o.locale) || "en-US";
2837
+ }),
2838
+ t: t.t || ((o, s) => {
2839
+ var i;
2840
+ return ((i = e.t) == null ? void 0 : i.call(e, o, s)) || o;
2841
+ }),
2842
+ notify: t.notify || ((o, s) => Ze(e, o, s))
2843
+ }, n = rt(r), a = ka(e, () => n("record" in t ? "run.waterfall" : "run.compare"), r);
2844
+ if ("record" in t) {
2845
+ const o = tn(a.body, { ...r, logs: t.record.logs || [] });
2846
+ Ye(o.element, () => n("common.fullJson"), t.record, n, r.notify), a.addCleanup(() => o.destroy());
2847
+ } else if ("detailA" in t) {
2848
+ const o = rn(a.body, { ...r, detailA: t.detailA, detailB: t.detailB });
2849
+ a.addCleanup(() => o.destroy());
2850
+ } else {
2851
+ const o = Aa(a.body, { ...r, records: t.records, loadDetail: t.loadDetail });
2852
+ a.addCleanup(() => o.destroy());
2853
+ }
2854
+ return { element: a.element, close: a.close, destroy: a.close, refreshLocale: a.refreshLocale };
2855
+ }
2856
+ class Ea extends Error {
2857
+ constructor(t, r, n) {
2858
+ super(t), this.status = r, this.url = n, this.name = "GlobalConfigApiError";
2859
+ }
2860
+ }
2861
+ function Qe(e) {
2862
+ return e.reason || new DOMException("The operation was aborted", "AbortError");
2863
+ }
2864
+ function Ta(e, t) {
2865
+ return t.aborted ? Promise.reject(Qe(t)) : new Promise((r, n) => {
2866
+ const a = () => n(Qe(t));
2867
+ t.addEventListener("abort", a, { once: !0 }), Promise.resolve().then(() => {
2868
+ if (t.aborted) throw Qe(t);
2869
+ return e();
2870
+ }).then(r, n).finally(() => t.removeEventListener("abort", a));
2871
+ });
2872
+ }
2873
+ function $a(e, t) {
2874
+ var r;
2875
+ try {
2876
+ const n = JSON.parse(e), a = ((r = n == null ? void 0 : n.error) == null ? void 0 : r.message) || (n == null ? void 0 : n.error) || (n == null ? void 0 : n.message) || (n == null ? void 0 : n.msg);
2877
+ if (typeof a == "string" && a.trim()) return a;
2878
+ } catch {
2879
+ }
2880
+ return e.trim() || `HTTP ${t}`;
2881
+ }
2882
+ class nn {
2883
+ constructor(t) {
2884
+ this.editor = t, this.requests = /* @__PURE__ */ new Set(), this.destroyed = !1;
2885
+ }
2886
+ captureContext() {
2887
+ var c, u;
2888
+ const t = this.editor.opts, r = String(t.apiBase || "").trim().replace(/\/+$/, ""), n = t.customFetch, a = t.fetchHeaders, o = t.apiCacheKey, s = (u = (c = this.editor)._getTransportGeneration) == null ? void 0 : u.call(c), i = () => JSON.stringify(Array.from(new Headers(gt(this.editor)).entries()).sort(([f], [b]) => f.localeCompare(b))), d = i();
2889
+ return () => {
2890
+ var f, b;
2891
+ return !this.destroyed && r === String(this.editor.opts.apiBase || "").trim().replace(/\/+$/, "") && n === this.editor.opts.customFetch && a === this.editor.opts.fetchHeaders && o === this.editor.opts.apiCacheKey && s === ((b = (f = this.editor)._getTransportGeneration) == null ? void 0 : b.call(f)) && d === i();
2892
+ };
2893
+ }
2894
+ async request(t, r, n, a) {
2895
+ if (this.destroyed) throw new DOMException("The global configuration API was destroyed", "AbortError");
2896
+ if (a != null && a.aborted) throw Qe(a);
2897
+ const o = String(this.editor.opts.apiBase || "").trim().replace(/\/+$/, "");
2898
+ if (!o) throw new re("missingApiBase");
2899
+ const s = this.captureContext(), i = `${o}${t}`, d = new AbortController(), c = () => d.abort(a == null ? void 0 : a.reason);
2900
+ a == null || a.addEventListener("abort", c, { once: !0 }), this.requests.add(d);
2901
+ const u = this.editor.opts.fetchTimeout ?? 1e4, f = setTimeout(() => d.abort(new DOMException("Request timed out", "TimeoutError")), u);
2902
+ try {
2903
+ return await Ta(async () => {
2904
+ const b = await Wr(i, {
2905
+ method: r,
2906
+ headers: { "Content-Type": "application/json" },
2907
+ ...n === void 0 ? {} : { body: JSON.stringify(n) },
2908
+ signal: d.signal
2909
+ }, this.editor), m = await b.text();
2910
+ if (d.signal.aborted) throw Qe(d.signal);
2911
+ if (!s()) throw new re("contextChanged");
2912
+ if (!b.ok) throw new Ea($a(m, b.status), b.status, i);
2913
+ if (!m.trim()) {
2914
+ if (r === "GET") throw new re("invalidResponse");
2915
+ return;
2916
+ }
2917
+ try {
2918
+ return JSON.parse(m);
2919
+ } catch {
2920
+ throw new re("invalidResponse");
2921
+ }
2922
+ }, d.signal);
2923
+ } finally {
2924
+ clearTimeout(f), a == null || a.removeEventListener("abort", c), this.requests.delete(d);
2925
+ }
2926
+ }
2927
+ async getGlobalConfig(t) {
2928
+ return ut(await this.request("/config/global", "GET", void 0, t));
2929
+ }
2930
+ async getGlobalOverrides(t) {
2931
+ return ut(await this.request("/config/global/overrides", "GET", void 0, t));
2932
+ }
2933
+ async updateGlobalConfig(t, r) {
2934
+ if (!t || Array.isArray(t) || typeof t != "object" || !Object.keys(t).length)
2935
+ throw new re("keyRequired");
2936
+ for (const [a, o] of Object.entries(t)) {
2937
+ if (!a.trim()) throw new re("keyRequired");
2938
+ if (o === wn) throw new re("maskedPlaceholder");
2939
+ if (o !== null && (typeof o != "string" || o === "")) throw new re("valueRequired");
2940
+ }
2941
+ const n = await this.request("/config/global", "POST", t, r);
2942
+ return Pt(De(n));
2943
+ }
2944
+ async revertGlobalConfigKey(t, r) {
2945
+ if (!t.trim()) throw new re("keyRequired");
2946
+ const n = await this.request(`/config/global/revert/${encodeURIComponent(t)}`, "POST", void 0, r);
2947
+ return Pt(De(n));
2948
+ }
2949
+ destroy() {
2950
+ this.destroyed = !0;
2951
+ for (const t of this.requests) t.abort();
2952
+ this.requests.clear();
2953
+ }
2954
+ }
2955
+ const an = `
2956
+ .hb_config_surface{box-sizing:border-box;min-width:0;color:var(--hb-text-primary);font:inherit;letter-spacing:0}
2957
+ .hb_config_surface *{box-sizing:border-box;letter-spacing:0}
2958
+ .hb_config_surface [hidden]{display:none!important}
2959
+ .hb_config_surface button,.hb_config_surface input,.hb_config_surface textarea{font:inherit;color:inherit}
2960
+ .hb_config_surface button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;border:1px solid var(--hb-border-color);border-radius:4px;background:var(--hb-bg-panel);padding:5px 10px;cursor:pointer;white-space:normal;overflow-wrap:anywhere}
2961
+ .hb_config_surface button:hover:not(:disabled){background:var(--hb-bg-hover)}
2962
+ .hb_config_surface button:focus-visible,.hb_config_surface input:focus-visible,.hb_config_surface textarea:focus-visible{outline:2px solid var(--hb-color-primary);outline-offset:2px}
2963
+ .hb_config_surface button:disabled{cursor:not-allowed;color:var(--hb-text-disabled);opacity:.7}
2964
+ .hb_config_surface .hb_config_primary{background:var(--hb-color-primary);border-color:var(--hb-color-primary);color:var(--rg-text-inverse)}
2965
+ .hb_config_surface .hb_config_primary:hover:not(:disabled){background:var(--hb-color-primary-hover,var(--hb-color-primary));color:var(--rg-text-inverse)}
2966
+ .hb_config_surface .hb_config_icon{width:32px;height:32px;min-width:32px;padding:6px;flex:none}
2967
+ .hb_config_surface .hb_config_danger{color:var(--hb-color-danger)}
2968
+ .hb_config_surface .hb_control_icon{display:inline-flex;width:16px;height:16px;flex:none}
2969
+ .hb_config_toolbar,.hb_config_actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
2970
+ .hb_config_toolbar{margin-bottom:12px}
2971
+ .hb_config_feedback{white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.5;margin:8px 0}
2972
+ .hb_config_feedback[data-kind="error"]{color:var(--hb-color-danger)}
2973
+ .hb_config_feedback[data-kind="warning"]{color:var(--hb-color-warning)}
2974
+ .hb_config_feedback[data-kind="success"]{color:var(--hb-color-success)}
2975
+ .hb_config_table_scroll{overflow:auto;width:100%;border-top:1px solid var(--hb-border-color)}
2976
+ .hb_config_table{width:100%;border-collapse:collapse;table-layout:fixed;min-width:510px;font-size:13px}
2977
+ .hb_config_table th{text-align:left;font-weight:600;color:var(--hb-text-secondary);background:var(--hb-bg-section)}
2978
+ .hb_config_table th,.hb_config_table td{vertical-align:top;padding:10px 8px;border-bottom:1px solid var(--hb-border-light);overflow-wrap:anywhere}
2979
+ .hb_config_table th:last-child{width:120px}
2980
+ .hb_config_table td code{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px}
2981
+ .hb_config_table .hb_config_actions{gap:4px;flex-wrap:nowrap}
2982
+ .hb_config_badge{display:block;font-size:11px;color:var(--hb-color-warning);margin-top:5px}
2983
+ .hb_config_reference{display:block;font-size:11px;color:var(--hb-text-muted);margin-top:5px;overflow-wrap:anywhere}
2984
+ .hb_config_empty{padding:20px 8px;color:var(--hb-text-secondary);text-align:center}
2985
+ .hb_config_form{margin:0 0 16px;padding:12px 0;border-top:1px solid var(--hb-border-light);border-bottom:1px solid var(--hb-border-light)}
2986
+ .hb_config_form h3{font-size:14px;line-height:1.4;margin:0 0 12px;font-weight:600}
2987
+ .hb_config_fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-bottom:12px}
2988
+ .hb_config_surface label{display:flex;flex-direction:column;gap:6px;min-width:0;font-size:13px}
2989
+ .hb_config_surface input:not([type="checkbox"]),.hb_config_surface textarea{width:100%;min-width:0;border:1px solid var(--hb-border-color);border-radius:4px;background:var(--hb-bg-input);padding:8px}
2990
+ .hb_config_surface input:read-only{color:var(--hb-text-secondary)}
2991
+ .hb_config_surface textarea{resize:vertical;line-height:1.5;min-height:100px;font-family:var(--rg-font-family-mono,monospace)}
2992
+ .hb_config_sensitive{color:var(--hb-color-warning);font-size:12px;overflow-wrap:anywhere}
2993
+ .hb_config_confirm{padding:12px 0;border-top:1px solid var(--hb-border-color);border-bottom:1px solid var(--hb-border-color);margin:8px 0}
2994
+ .hb_config_confirm p{margin:0 0 12px;overflow-wrap:anywhere;font-size:13px;line-height:1.5}
2995
+ .hb_config_modal{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:16px;z-index:var(--hb-z-modal,${Dt.modal});background:var(--hb-overlay)}
2996
+ .hb_config_modal .hb_config_dialog{position:relative;inset:auto;transform:none;animation:none;display:flex;flex-direction:column;width:900px;height:auto;max-width:100%;max-height:calc(100dvh - 32px);margin:0;border:1px solid var(--hb-border-color);border-radius:8px;background:var(--hb-bg-panel);box-shadow:var(--hb-shadow-lg);overflow:hidden;color:var(--hb-text-primary);font:14px var(--rg-font-family,system-ui,sans-serif)}
2997
+ .hb_config_header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border-bottom:1px solid var(--hb-border-color)}
2998
+ .hb_config_header strong{min-width:0;overflow-wrap:anywhere;font-size:15px;font-weight:600}
2999
+ .hb_config_body{padding:16px;overflow:auto;min-height:0;min-width:0}
3000
+ .hb_config_modal .hb_business_log_dialog{width:600px}
3001
+ .hb_business_log_form{display:grid;gap:16px}
3002
+ .hb_business_log_form .hb_config_actions{justify-content:flex-end}
3003
+ .hb_business_log_field{display:grid;gap:6px;min-width:0;font-size:13px}
3004
+ .hb_business_log_editor{min-width:0;max-width:100%;border:1px solid var(--hb-border-color);border-radius:4px;overflow:hidden}
3005
+ .hb_business_log_editor:focus-within{border-color:var(--hb-color-primary);outline:1px solid var(--hb-color-primary)}
3006
+ .hb_config_surface .hb_business_log_editor .cm-editor{background:var(--hb-bg-input);color:var(--hb-text-primary);outline:none}
3007
+ .hb_config_surface .hb_business_log_editor .cm-content{caret-color:var(--hb-text-primary)}
3008
+ .hb_config_surface .hb_business_log_editor .cm-scroller{font-family:var(--rg-font-family-mono,monospace)}
3009
+ .hb_config_surface .hb_business_log_editor .cm-gutters{background:var(--hb-bg-section);color:var(--hb-text-secondary);border-right-color:var(--hb-border-color)}
3010
+ .hb_config_surface .hb_business_log_editor .cm-activeLine,.hb_config_surface .hb_business_log_editor .cm-activeLineGutter{background:var(--hb-bg-hover)}
3011
+ .hb_config_surface .hb_business_log_editor .cm-cursor{border-left-color:var(--hb-text-primary)}
3012
+ .hb_config_surface .hb_business_log_editor .cm-editor .cm-selectionBackground{background:color-mix(in srgb,var(--hb-color-primary) 22%,transparent)!important}
3013
+ .hb_config_surface .hb_business_log_editor .cm-tooltip{background:var(--hb-bg-panel);color:var(--hb-text-primary);border-color:var(--hb-border-color)}
3014
+ .hb_config_surface .hb_business_log_editor .cm-tooltip-autocomplete ul li[aria-selected="true"]{background:var(--hb-color-primary);color:var(--rg-text-inverse)}
3015
+ .hb_config_surface .hb_business_log_editor .cm-panels{background:var(--hb-bg-section);color:var(--hb-text-primary);border-color:var(--hb-border-color)}
3016
+ .hb_config_surface .hb_business_log_editor .cm-textfield{background:var(--hb-bg-input);color:var(--hb-text-primary);border-color:var(--hb-border-color)}
3017
+ .hb_config_surface .hb_business_log_editor .cm-button{background:var(--hb-bg-panel);color:var(--hb-text-primary);border-color:var(--hb-border-color)}
3018
+ .hb_config_surface .hb_config_checkbox{display:flex;flex-direction:row;align-items:center;gap:8px;line-height:1.4}
3019
+ .hb_business_log_identity{overflow-wrap:anywhere;font-size:13px;color:var(--hb-text-secondary)}
3020
+ @media(max-width:600px){.hb_config_modal{padding:8px}.hb_config_modal .hb_config_dialog{max-height:calc(100dvh - 16px)}.hb_config_body{padding:12px}.hb_config_fields{grid-template-columns:minmax(0,1fr)}}
3021
+ `;
3022
+ function R(e, t, r, n) {
3023
+ var c, u, f, b;
3024
+ const a = `${t}.${r}`, o = (c = e.t) == null ? void 0 : c.call(e, a, n), s = ((b = (f = (u = e.core) == null ? void 0 : u.i18n) == null ? void 0 : f.getLocale) == null ? void 0 : b.call(f)) || e.opts.locale || "zh-CN", i = /^en(?:-|$)/i.test(s) ? Pn : Dn;
3025
+ let d = o && o !== a ? o : i[t][r] || r;
3026
+ for (const [m, y] of Object.entries(n || {}))
3027
+ d = d.split(`{{${m}}}`).join(y).split(`{${m}}`).join(y);
3028
+ return d;
3029
+ }
3030
+ function Ee(e, t) {
3031
+ return t instanceof re ? R(e, "globalConfig", t.code) : t instanceof Error ? t.message : String(t);
3032
+ }
3033
+ function Pe(e) {
3034
+ var t, r, n;
3035
+ return ((r = (t = e.capabilities) == null ? void 0 : t.editor) == null ? void 0 : r.readOnly) === !0 || ((n = e.capabilities) == null ? void 0 : n.mode) === "readonly" || e.opts.readOnly === !0 || e.opts.disabled === !0 || e.opts.mode === "readonly";
3036
+ }
3037
+ function on(e, t) {
3038
+ var n, a, o;
3039
+ const r = (s) => {
3040
+ var d, c, u;
3041
+ const i = s || e._currentTheme || e.opts.theme || ((u = (c = (d = e.core) == null ? void 0 : d.theme) == null ? void 0 : c.getTheme) == null ? void 0 : u.call(c)) || "default";
3042
+ for (const [f, b] of Object.entries(Jt(i))) t.style.setProperty(f, b);
3043
+ };
3044
+ return r(), ((o = (a = (n = e.core) == null ? void 0 : n.theme) == null ? void 0 : a.onChange) == null ? void 0 : o.call(a, r)) || (() => {
3045
+ });
3046
+ }
3047
+ function lt(e, t, r, n = "") {
3048
+ return `<button type="button" class="hb_config_icon ${n}" data-global-action="${e}" title="${j(t)}" aria-label="${j(t)}">${Ne(r)}</button>`;
3049
+ }
3050
+ function Y(e, t, r = "info") {
3051
+ e.textContent = t, e.dataset.kind = r, e.hidden = !t, e.setAttribute("role", r === "error" || r === "warning" ? "alert" : "status");
3052
+ }
3053
+ function sn(e, t) {
3054
+ const r = document.createElement("section");
3055
+ r.className = "hb_config_confirm", r.hidden = !0, r.setAttribute("role", "alertdialog"), r.innerHTML = '<p></p><div class="hb_config_actions"><button type="button" data-config-confirm></button><button type="button" data-config-confirm-cancel></button></div>', t.appendChild(r);
3056
+ let n = null, a = null;
3057
+ const o = (s) => {
3058
+ const i = n;
3059
+ n = null, r.hidden = !0, a != null && a.isConnected && a.focus(), i == null || i(s);
3060
+ };
3061
+ return r.querySelector("[data-config-confirm]").addEventListener("click", () => o(!0)), r.querySelector("[data-config-confirm-cancel]").addEventListener("click", () => o(!1)), {
3062
+ ask(s) {
3063
+ return n ? Promise.resolve(!1) : (r.querySelector("p").textContent = s, r.setAttribute("aria-label", s), r.querySelector("[data-config-confirm]").textContent = R(e, "globalConfig", "confirm"), r.querySelector("[data-config-confirm-cancel]").textContent = R(e, "globalConfig", "cancel"), r.hidden = !1, a = document.activeElement instanceof HTMLElement ? document.activeElement : null, r.querySelector("[data-config-confirm-cancel]").focus(), new Promise((i) => {
3064
+ n = i;
3065
+ }));
3066
+ },
3067
+ isOpen: () => n !== null,
3068
+ cancel: () => o(!1)
3069
+ };
3070
+ }
3071
+ function ln(e, t, r) {
3072
+ var p, _, x, h;
3073
+ const n = e._activeModalWrapper;
3074
+ (p = n == null ? void 0 : n.__huanbanCleanup) == null || p.call(n), n == null || n.remove();
3075
+ const a = document.activeElement instanceof HTMLElement ? document.activeElement : null, o = document.createElement("div");
3076
+ o.className = "hb_config_surface hb_config_modal", o.innerHTML = `<style>${an}</style><section class="huanban_settings_dialog hb_config_dialog${t === "businessLog" ? " hb_business_log_dialog" : ""}" role="dialog" aria-modal="true"><header class="huanban_settings_header hb_config_header"><strong></strong><button type="button" class="hb_config_icon" data-config-close>&times;</button></header><main class="hb_config_body"></main></section>`;
3077
+ const s = o.querySelector("section"), i = o.querySelector("main"), d = o.querySelector("[data-config-close]"), c = [on(e, o)], u = new AbortController();
3078
+ let f = !1, b = async () => !0;
3079
+ const m = () => {
3080
+ const l = R(e, t, r);
3081
+ o.querySelector("strong").textContent = l, s.setAttribute("aria-label", l), d.title = R(e, t, "close"), d.setAttribute("aria-label", d.title);
3082
+ };
3083
+ m();
3084
+ const y = (h = (x = (_ = e.core) == null ? void 0 : _.i18n) == null ? void 0 : x.onLocaleChange) == null ? void 0 : h.call(x, m);
3085
+ y && c.push(y);
3086
+ const w = () => {
3087
+ f || (f = !0, u.abort(), c.forEach((l) => l()), o.remove(), e._activeModalWrapper === o && (e._activeModalWrapper = null), a != null && a.isConnected && a.focus());
3088
+ }, v = async () => f ? !0 : await b() ? (w(), !0) : !1;
3089
+ return o.__huanbanCleanup = w, e._activeModalWrapper = o, document.body.appendChild(o), d.addEventListener("click", () => {
3090
+ v();
3091
+ }, { signal: u.signal }), o.addEventListener("mousedown", (l) => {
3092
+ l.target === o && v();
3093
+ }, { signal: u.signal }), o.addEventListener("keydown", (l) => {
3094
+ if (!l.defaultPrevented) {
3095
+ if (l.key === "Escape")
3096
+ l.preventDefault(), l.stopPropagation(), v();
3097
+ else if (l.key === "Tab") {
3098
+ const g = Array.from(o.querySelectorAll('button,input,textarea,select,[tabindex="0"]')).filter((A) => !A.disabled && !A.closest("[hidden]")), S = g[0], C = g[g.length - 1];
3099
+ l.shiftKey && document.activeElement === S ? (l.preventDefault(), C == null || C.focus()) : !l.shiftKey && document.activeElement === C && (l.preventDefault(), S == null || S.focus());
3100
+ }
3101
+ }
3102
+ }, { signal: u.signal }), queueMicrotask(() => {
3103
+ f || d.focus();
3104
+ }), {
3105
+ element: o,
3106
+ body: i,
3107
+ close: w,
3108
+ requestClose: v,
3109
+ dispose: c,
3110
+ signal: u.signal,
3111
+ setCloseGuard: (l) => {
3112
+ b = l;
3113
+ }
3114
+ };
3115
+ }
3116
+ function Ma(e, t) {
3117
+ const r = [R(e, "globalConfig", "saved")];
3118
+ for (const [a, o] of [["reloadedChains", t.reloadedChains], ["reloadedNodes", t.reloadedNodes]])
3119
+ o.length && r.push(R(e, "globalConfig", a, { count: String(o.length), ids: o.join(", ") }));
3120
+ let n = !1;
3121
+ for (const [a, o] of [["failedChains", t.failedChains], ["failedNodes", t.failedNodes]])
3122
+ Object.keys(o).length && (n = !0, r.push(R(e, "globalConfig", a, { details: Object.entries(o).map(([s, i]) => `${s}: ${i}`).join("; ") })));
3123
+ return !n && !t.reloadedChains.length && !t.reloadedNodes.length && r.push(R(e, "globalConfig", "noReferences")), { message: r.join(`
3124
+ `), kind: n ? "warning" : "success" };
3125
+ }
3126
+ function Na(e, t, r = {}) {
3127
+ var he, oe, we;
3128
+ const n = document.createElement("section");
3129
+ n.className = "hb_config_surface hb_global_config_panel", n.innerHTML = `<style>${an}</style>
3130
+ <div class="hb_config_toolbar"><button type="button" class="hb_config_primary" data-global-add>${Ne("add")}<span data-global-label="add"></span></button>${lt("refresh", R(e, "globalConfig", "refresh"), "refresh")}</div>
3131
+ <div class="hb_config_feedback" data-global-feedback hidden></div>
3132
+ <div class="hb_config_feedback" data-global-overrides-feedback hidden></div>
3133
+ <form class="hb_config_form" data-global-form hidden>
3134
+ <h3 data-global-form-title></h3><div class="hb_config_fields">
3135
+ <label><span data-global-label="key"></span><input data-global-key autocomplete="off" spellcheck="false" required></label>
3136
+ <label><span data-global-label="value"></span><input data-global-value autocomplete="new-password" spellcheck="false"><small class="hb_config_sensitive" data-global-sensitive hidden></small></label>
3137
+ </div><div class="hb_config_actions"><button type="submit" class="hb_config_primary" data-global-save>${Ne("save")}<span data-global-label="save"></span></button><button type="button" data-global-cancel data-global-label="cancel"></button></div>
3138
+ </form>
3139
+ <div class="hb_config_table_scroll"><table class="hb_config_table"><thead><tr><th data-global-label="key"></th><th data-global-label="value"></th><th data-global-label="actions"></th></tr></thead><tbody data-global-rows></tbody></table></div>
3140
+ <div class="hb_config_empty" data-global-empty></div>`, t.appendChild(n);
3141
+ const a = new nn(e), o = r.fetcher || e.opts.globalConfigFetcher || a, s = on(e, n), i = new AbortController(), d = sn(e, n), c = n.querySelector("[data-global-form]"), u = n.querySelector("[data-global-key]"), f = n.querySelector("[data-global-value]"), b = n.querySelector("[data-global-feedback]"), m = n.querySelector("[data-global-overrides-feedback]"), y = n.querySelector("[data-global-rows]"), w = n.querySelector("[data-global-empty]");
3142
+ let v = [], p = !1, _ = !1, x = !1, h = !1, l = 0, g = null, S = null, C = null, A = null;
3143
+ const N = () => !!(A && (u.value !== A.key || f.value !== A.value)), L = (q, B) => Y(
3144
+ b,
3145
+ B ? R(e, "globalConfig", B, { error: Ee(e, q) }) : Ee(e, q),
3146
+ "error"
3147
+ ), O = () => {
3148
+ var D, U;
3149
+ if (c.hidden = !A, !A) return;
3150
+ const q = ((D = A.row) == null ? void 0 : D.masked) || Cn(u.value);
3151
+ f.type = q ? "password" : "text", f.placeholder = R(e, "globalConfig", (U = A.row) != null && U.masked ? "secretPlaceholder" : "valuePlaceholder"), f.title = `${R(e, "globalConfig", "environment")}: \${ENV_VAR} / \${ENV_VAR:-default}`, u.readOnly = !!A.row, n.querySelector("[data-global-form-title]").textContent = R(e, "globalConfig", A.row ? "editTitle" : "addTitle");
3152
+ const B = n.querySelector("[data-global-sensitive]");
3153
+ B.hidden = !q, B.textContent = R(e, "globalConfig", "sensitive");
3154
+ }, I = () => {
3155
+ n.setAttribute("aria-busy", String(_ || x)), n.querySelectorAll("[data-global-label]").forEach((D) => {
3156
+ D.textContent = R(e, "globalConfig", D.dataset.globalLabel);
3157
+ });
3158
+ const q = n.querySelector('[data-global-action="refresh"]');
3159
+ q.title = R(e, "globalConfig", "refresh"), q.setAttribute("aria-label", q.title), q.disabled = _ || x, y.innerHTML = v.map((D) => `<tr data-global-row="${j(D.key)}">
3160
+ <td><code>${X(D.key)}</code><small class="hb_config_reference">${X("${global." + D.key + "}")}</small>${D.overridden !== !1 ? `<span class="hb_config_badge" title="${j(R(e, "globalConfig", "overrideTitle"))}">${X(R(e, "globalConfig", D.overridden === null ? "unknown" : "overridden"))}</span>` : ""}</td>
3161
+ <td><code>${X(D.value)}</code></td>
3162
+ <td><div class="hb_config_actions">${lt("edit", R(e, "globalConfig", "edit"), "edit")}${D.overridden ? lt("revert", R(e, "globalConfig", "revert"), "undo") : ""}${lt("remove", R(e, "globalConfig", "remove"), "delete", "hb_config_danger")}</div></td>
3163
+ </tr>`).join("");
3164
+ const B = !p || _ || x || Pe(e);
3165
+ n.querySelectorAll("[data-global-add],[data-global-save],tbody button").forEach((D) => {
3166
+ D.disabled = B;
3167
+ }), u.disabled = B, f.disabled = B, n.querySelector("[data-global-cancel]").disabled = x, w.hidden = v.length > 0 || !p && !_, w.textContent = R(e, "globalConfig", _ ? "loading" : "empty"), O();
3168
+ }, z = () => {
3169
+ u.value = "", f.value = "", A = null, O();
3170
+ }, G = () => {
3171
+ if (h || x || _ || !p) return !1;
3172
+ if (Pe(e))
3173
+ return Y(b, R(e, "globalConfig", "readOnly"), "error"), !1;
3174
+ try {
3175
+ if (!(C != null && C())) throw new re("contextChanged");
3176
+ } catch (q) {
3177
+ return L(q), p = !1, v = [], I(), !1;
3178
+ }
3179
+ return !0;
3180
+ }, K = async (q = !1) => {
3181
+ var U;
3182
+ if (h) return;
3183
+ g == null || g.abort();
3184
+ const B = new AbortController();
3185
+ g = B;
3186
+ const D = ++l;
3187
+ _ = !0, p = !1, C = null, v = [], q || Y(b, ""), Y(m, ""), I();
3188
+ try {
3189
+ const J = ((U = o.captureContext) == null ? void 0 : U.call(o)) || a.captureContext(), [ee, te] = await Promise.allSettled([
3190
+ Promise.resolve().then(() => o.getGlobalConfig(B.signal)),
3191
+ Promise.resolve().then(() => o.getGlobalOverrides(B.signal))
3192
+ ]);
3193
+ if (h || D !== l || B.signal.aborted) return;
3194
+ if (!J()) throw new re("contextChanged");
3195
+ if (ee.status === "rejected") throw ee.reason;
3196
+ const nt = ut(ee.value);
3197
+ let He = null;
3198
+ if (te.status === "fulfilled")
3199
+ try {
3200
+ He = ut(te.value);
3201
+ } catch (Be) {
3202
+ Y(m, R(e, "globalConfig", "overridesFailed", { error: Ee(e, Be) }), "warning");
3203
+ }
3204
+ else
3205
+ Y(m, R(e, "globalConfig", "overridesFailed", { error: Ee(e, te.reason) }), "warning");
3206
+ v = kn(nt, He), p = !0, C = J;
3207
+ } catch (J) {
3208
+ !h && D === l && !B.signal.aborted && (v = [], q ? Y(b, `${b.textContent || ""}
3209
+ ${R(e, "globalConfig", "readbackFailed", { error: Ee(e, J) })}`, "warning") : L(J, "loadFailed"));
3210
+ } finally {
3211
+ !h && D === l && (_ = !1, I());
3212
+ }
3213
+ }, le = async (q, B) => {
3214
+ if (!G()) return;
3215
+ x = !0, S = new AbortController();
3216
+ const D = S;
3217
+ I();
3218
+ try {
3219
+ const U = Pt(await q(D.signal));
3220
+ if (h || D.signal.aborted) return;
3221
+ if (!(C != null && C())) throw new re("contextChanged");
3222
+ z();
3223
+ const J = Ma(e, U);
3224
+ Y(b, J.message, J.kind), await K(!0);
3225
+ } catch (U) {
3226
+ !h && !D.signal.aborted && L(U, B);
3227
+ } finally {
3228
+ h || (x = !1, I());
3229
+ }
3230
+ }, Z = async () => !N() || await d.ask(R(e, "globalConfig", "confirmDiscard")), W = async () => {
3231
+ h || x || d.isOpen() || !await Z() || h || (z(), await K());
3232
+ }, V = async (q) => {
3233
+ !G() || d.isOpen() || !await Z() || h || (u.value = (q == null ? void 0 : q.key) || "", f.value = q && !q.masked ? q.value : "", A = { row: q, key: u.value, value: f.value }, I(), (q ? f : u).focus());
3234
+ };
3235
+ n.querySelector("[data-global-add]").addEventListener("click", () => {
3236
+ V(null);
3237
+ }, { signal: i.signal }), n.querySelector("[data-global-cancel]").addEventListener("click", () => {
3238
+ x || z();
3239
+ }, { signal: i.signal }), u.addEventListener("input", O, { signal: i.signal }), c.addEventListener("submit", (q) => {
3240
+ var B, D;
3241
+ if (q.preventDefault(), !(!A || !G() || d.isOpen()))
3242
+ try {
3243
+ const U = Tn(((B = A.row) == null ? void 0 : B.key) || u.value.trim(), f.value, {
3244
+ masked: (D = A.row) == null ? void 0 : D.masked,
3245
+ existingKeys: A.row ? void 0 : v.map((J) => J.key)
3246
+ });
3247
+ if (U === null) {
3248
+ z(), Y(b, R(e, "globalConfig", "unchangedSecret"));
3249
+ return;
3250
+ }
3251
+ le((J) => o.updateGlobalConfig(U, J), "saveFailed");
3252
+ } catch (U) {
3253
+ L(U);
3254
+ }
3255
+ }, { signal: i.signal }), n.addEventListener("click", (q) => {
3256
+ var ee;
3257
+ const B = q.target.closest("[data-global-action]");
3258
+ if (!B || B.disabled || d.isOpen()) return;
3259
+ const D = B.dataset.globalAction;
3260
+ if (D === "refresh") {
3261
+ W();
3262
+ return;
3263
+ }
3264
+ const U = (ee = B.closest("[data-global-row]")) == null ? void 0 : ee.dataset.globalRow, J = v.find((te) => te.key === U);
3265
+ if (!(!J || !G())) {
3266
+ if (D === "edit") {
3267
+ V(J);
3268
+ return;
3269
+ }
3270
+ D !== "remove" && D !== "revert" || D === "revert" && J.overridden !== !0 || (async () => !await Z() || h || !await d.ask(R(e, "globalConfig", D === "remove" ? "confirmRemove" : "confirmRevert", { key: J.key })) || h || await le((te) => D === "remove" ? o.updateGlobalConfig({ [J.key]: null }, te) : o.revertGlobalConfigKey(J.key, te), D === "remove" ? "removeFailed" : "revertFailed"))();
3271
+ }
3272
+ }, { signal: i.signal });
3273
+ const ve = ((we = (oe = (he = e.core) == null ? void 0 : he.i18n) == null ? void 0 : oe.onLocaleChange) == null ? void 0 : we.call(oe, I)) || (() => {
3274
+ }), _e = K();
3275
+ return {
3276
+ element: n,
3277
+ ready: _e,
3278
+ reload: W,
3279
+ hasPendingChanges: N,
3280
+ async requestClose() {
3281
+ return x ? (Y(b, R(e, "globalConfig", "busy"), "warning"), !1) : d.isOpen() ? (d.cancel(), !1) : Z();
3282
+ },
3283
+ destroy() {
3284
+ h || (h = !0, l += 1, g == null || g.abort(), S == null || S.abort(), i.abort(), d.cancel(), ve(), s(), a.destroy(), z(), v = [], n.remove());
3285
+ }
3286
+ };
3287
+ }
3288
+ function wo(e, t = {}) {
3289
+ if (t.delegateToHost !== !1 && typeof e.opts.onSettingsClick == "function") {
3290
+ e.opts.onSettingsClick({
3291
+ initialTab: "globalConfig",
3292
+ apiBase: e.opts.apiBase,
3293
+ baseUrl: String(e.opts.apiBase || e.opts.baseUrl || "").replace(/\/+$/, "").replace(/\/api\/v1$/i, ""),
3294
+ browserConsoleLog: !!e.opts.browserConsoleLog
3295
+ });
3296
+ return;
3297
+ }
3298
+ if (typeof document > "u") return;
3299
+ const r = ln(e, "globalConfig", "title"), n = Na(e, r.body, t);
3300
+ return r.dispose.push(() => n.destroy()), r.setCloseGuard(n.requestClose), { element: r.element, close: r.close, requestClose: r.requestClose, panel: n };
3301
+ }
3302
+ function tt(e) {
3303
+ var t, r, n, a, o, s;
3304
+ return ((a = (n = (r = (t = e.core) == null ? void 0 : t.store) == null ? void 0 : r.getState) == null ? void 0 : n.call(r)) == null ? void 0 : a.ruleChain) || ((s = (o = e.lf) == null ? void 0 : o.getRuleChain) == null ? void 0 : s.call(o)) || null;
3305
+ }
3306
+ function dn(e, t) {
3307
+ var r, n, a, o, s;
3308
+ e._markDirty ? e._markDirty(t) : ((a = (n = (r = e.core) == null ? void 0 : r.store) == null ? void 0 : n.setState) == null || a.call(n, { isDirty: !0 }), (s = (o = e.opts).onChange) == null || s.call(o));
3309
+ }
3310
+ function La(e, t) {
3311
+ const r = () => {
3312
+ const n = tt(e);
3313
+ return (n == null ? void 0 : n.id) === t ? n : null;
3314
+ };
3315
+ return {
3316
+ getChainVars: () => {
3317
+ var a, o;
3318
+ const n = (o = (a = r()) == null ? void 0 : a.configuration) == null ? void 0 : o.vars;
3319
+ return n && typeof n == "object" && !Array.isArray(n) ? Object.keys(n) : [];
3320
+ },
3321
+ getGlobalVars: () => {
3322
+ var n, a, o, s, i, d, c, u, f, b, m;
3323
+ return [
3324
+ (n = e.lf) == null ? void 0 : n.globalVars,
3325
+ e.opts.globalVars,
3326
+ (i = (s = (o = (a = e.core) == null ? void 0 : a.store) == null ? void 0 : o.getState) == null ? void 0 : s.call(o)) == null ? void 0 : i.globalVars,
3327
+ e.opts.globals,
3328
+ (c = (d = e.opts.builtinComponents) == null ? void 0 : d.builtins) == null ? void 0 : c.globals,
3329
+ (f = (u = e.opts.componentsPayload) == null ? void 0 : u.builtins) == null ? void 0 : f.globals,
3330
+ (m = (b = e.opts.componentPayload) == null ? void 0 : b.builtins) == null ? void 0 : m.globals
3331
+ ].find(Array.isArray) || [];
3332
+ },
3333
+ getSchemaCompletions: () => {
3334
+ var o, s;
3335
+ let n = (s = (o = r()) == null ? void 0 : o.additionalInfo) == null ? void 0 : s.inputSchema;
3336
+ if (typeof n == "string")
3337
+ try {
3338
+ n = JSON.parse(n);
3339
+ } catch {
3340
+ return [];
3341
+ }
3342
+ const a = n == null ? void 0 : n.properties;
3343
+ return !a || typeof a != "object" || Array.isArray(a) ? [] : Object.entries(a).map(([i, d]) => ({
3344
+ label: i,
3345
+ value: i,
3346
+ type: "variable",
3347
+ detail: d && typeof d == "object" ? String(d.title || d.type || "") : ""
3348
+ }));
3349
+ }
3350
+ };
3351
+ }
3352
+ function cn(e, t, r) {
3353
+ var c, u, f;
3354
+ const n = ln(e, "businessLog", t);
3355
+ n.body.innerHTML = `<form class="hb_business_log_form">${r}<div class="hb_config_feedback" data-log-feedback hidden></div><div class="hb_config_actions"><button type="button" class="hb_config_danger" data-log-clear>${Ne("delete")}<span data-log-label="clear"></span></button><button type="button" data-log-cancel data-log-label="cancel"></button><button type="submit" class="hb_config_primary" data-log-apply>${Ne("save")}<span data-log-label="apply"></span></button></div></form>`;
3356
+ const a = n.body.querySelector("form"), o = a.querySelector("[data-log-feedback]"), s = sn(e, n.body), i = () => {
3357
+ n.body.querySelectorAll("[data-log-label]").forEach((b) => {
3358
+ b.textContent = R(e, "businessLog", b.dataset.logLabel);
3359
+ }), a.querySelectorAll("input,textarea,[data-log-clear],[data-log-apply]").forEach((b) => {
3360
+ b.disabled = Pe(e);
3361
+ });
3362
+ };
3363
+ i();
3364
+ const d = (f = (u = (c = e.core) == null ? void 0 : c.i18n) == null ? void 0 : u.onLocaleChange) == null ? void 0 : f.call(u, i);
3365
+ return d && n.dispose.push(d), n.dispose.push(s.cancel), a.querySelector("[data-log-cancel]").addEventListener("click", () => {
3366
+ n.requestClose();
3367
+ }, { signal: n.signal }), { ...n, form: a, feedback: o, confirmation: s };
3368
+ }
3369
+ function So(e, t) {
3370
+ var f, b, m, y;
3371
+ if (typeof document > "u") return;
3372
+ const r = (b = (f = e.lf) == null ? void 0 : f.getNodeModelById) == null ? void 0 : b.call(f, t);
3373
+ if (!((m = r == null ? void 0 : r.properties) != null && m.model)) {
3374
+ Ze(e, R(e, "businessLog", "missingNode"), "error");
3375
+ return;
3376
+ }
3377
+ const n = (y = tt(e)) == null ? void 0 : y.id, a = JSON.stringify(r.properties.model.logConfig), o = xn(r.properties.model), s = cn(e, "nodeTitle", `<div class="hb_business_log_identity">${X(String(r.properties.model.name || t))}<br>${X(t)}</div><div class="hb_business_log_field"><span data-log-label="before"></span><div class="hb_business_log_editor" data-log-before></div></div><div class="hb_business_log_field"><span data-log-label="after"></span><div class="hb_business_log_editor" data-log-after></div></div><div class="hb_config_reference"><span data-log-label="templates"></span>: <code>\${metadata.x} / \${msg.x} / \${data} / \${vars.x}</code><br><span data-log-label="maskedGlobal"></span></div>`), i = (w) => {
3378
+ var h, l, g;
3379
+ const v = qn({
3380
+ parent: s.form.querySelector(`[data-log-${w}]`),
3381
+ value: o[w],
3382
+ lang: "plain",
3383
+ readOnly: Pe(e),
3384
+ minHeight: 90,
3385
+ maxHeight: 240,
3386
+ completionMode: "plain",
3387
+ ...La(e, n)
3388
+ });
3389
+ s.dispose.push(() => v.destroy());
3390
+ const p = new On(), _ = () => dr.contentAttributes.of({
3391
+ "aria-label": R(e, "businessLog", w),
3392
+ "aria-multiline": "true",
3393
+ "aria-readonly": String(Pe(e)),
3394
+ tabindex: "0"
3395
+ });
3396
+ v.view.dispatch({ effects: In.appendConfig.of([dr.lineWrapping, p.of(_())]) });
3397
+ const x = (g = (l = (h = e.core) == null ? void 0 : h.i18n) == null ? void 0 : l.onLocaleChange) == null ? void 0 : g.call(l, () => {
3398
+ v.view.dispatch({ effects: p.reconfigure(_()) });
3399
+ });
3400
+ return x && s.dispose.push(x), v;
3401
+ }, d = i("before"), c = i("after");
3402
+ s.setCloseGuard(async () => s.confirmation.isOpen() ? (s.confirmation.cancel(), !1) : d.getValue() === o.before && c.getValue() === o.after || s.confirmation.ask(R(e, "businessLog", "confirmDiscard")));
3403
+ const u = (w) => {
3404
+ var _, x, h, l;
3405
+ if (Pe(e)) {
3406
+ Y(s.feedback, R(e, "businessLog", "readOnly"), "error");
3407
+ return;
3408
+ }
3409
+ const v = (x = (_ = e.lf) == null ? void 0 : _.getNodeModelById) == null ? void 0 : x.call(_, t), p = ((h = tt(e)) == null ? void 0 : h.id) !== n ? "changedChain" : !v || v !== r || !((l = v.properties) != null && l.model) ? "missingNode" : JSON.stringify(v.properties.model.logConfig) !== a ? "changedLog" : "";
3410
+ if (p) {
3411
+ Y(s.feedback, R(e, "businessLog", p), "error");
3412
+ return;
3413
+ }
3414
+ try {
3415
+ const g = En(v.properties.model, w ? "" : d.getValue(), w ? "" : c.getValue());
3416
+ if (JSON.stringify(g.logConfig) !== a) {
3417
+ const S = typeof v.setProperty == "function" ? () => v.setProperty("model", g) : typeof v.setProperties == "function" ? () => v.setProperties({ model: g }) : null;
3418
+ if (!S || S() === !1) throw new Error(R(e, "businessLog", "missingNode"));
3419
+ dn(e, "node:business-log"), Ze(e, R(e, "businessLog", "saved"));
3420
+ }
3421
+ s.close();
3422
+ } catch (g) {
3423
+ Y(s.feedback, R(e, "businessLog", "applyFailed", { error: Ee(e, g) }), "error");
3424
+ }
3425
+ };
3426
+ return s.form.addEventListener("submit", (w) => {
3427
+ w.preventDefault(), u(!1);
3428
+ }, { signal: s.signal }), s.form.querySelector("[data-log-clear]").addEventListener("click", () => {
3429
+ s.confirmation.ask(R(e, "businessLog", "confirmClear")).then((w) => {
3430
+ w && !s.signal.aborted && u(!0);
3431
+ });
3432
+ }, { signal: s.signal }), { element: s.element, close: s.close, requestClose: s.requestClose };
3433
+ }
3434
+ let Ra = 0;
3435
+ function xo(e) {
3436
+ var w, v, p, _, x;
3437
+ if (typeof document > "u") return;
3438
+ const t = tt(e);
3439
+ if (!t) {
3440
+ Ze(e, R(e, "businessLog", "missingChain"), "error");
3441
+ return;
3442
+ }
3443
+ const r = Sn(t.configuration || {}), n = JSON.stringify([(w = t.configuration) == null ? void 0 : w.logHandler, (v = t.configuration) == null ? void 0 : v.logEvents]), a = `hb-log-handler-${++Ra}`, o = cn(e, "chainTitle", `<div class="hb_business_log_identity">${X(String(t.name || t.id || ""))}</div><label><span data-log-label="handler"></span><input data-log-handler list="${a}" autocomplete="off"><datalist id="${a}"></datalist></label><label class="hb_config_checkbox" data-log-events><input type="checkbox" data-log-chain-end><span data-log-label="chainEnd"></span></label><div class="hb_config_reference" data-log-no-handler data-log-label="noHandler"></div><div class="hb_config_feedback" data-log-list-feedback></div>`), s = o.form.querySelector("[data-log-handler]"), i = o.form.querySelector("[data-log-chain-end]"), d = o.form.querySelector("[data-log-list-feedback]");
3444
+ s.value = r.handler, i.checked = r.chainEnd;
3445
+ const c = () => {
3446
+ const h = !!s.value.trim();
3447
+ h || (i.checked = !1), o.form.querySelector("[data-log-events]").hidden = !h, o.form.querySelector("[data-log-no-handler]").hidden = h, s.placeholder = R(e, "businessLog", "handlerPlaceholder");
3448
+ };
3449
+ c();
3450
+ const u = (x = (_ = (p = e.core) == null ? void 0 : p.i18n) == null ? void 0 : _.onLocaleChange) == null ? void 0 : x.call(_, c);
3451
+ u && o.dispose.push(u), s.addEventListener("input", c, { signal: o.signal });
3452
+ const f = /* @__PURE__ */ new Set();
3453
+ let b = !1;
3454
+ Y(d, R(e, "businessLog", "loading"));
3455
+ const m = new nn(e);
3456
+ o.dispose.push(() => m.destroy()), (async () => {
3457
+ var h, l;
3458
+ try {
3459
+ const g = m.captureContext();
3460
+ let S;
3461
+ if (typeof ((h = e.opts.workflowFetcher) == null ? void 0 : h.list) == "function")
3462
+ S = await e.opts.workflowFetcher.list(1, 200, "");
3463
+ else {
3464
+ const A = String(e.opts.rulesApi || e.opts.apiBase || "").trim().replace(/\/+$/, "");
3465
+ if (!A) throw new re("missingApiBase");
3466
+ const N = /\/rules$/i.test(A) ? A : `${A}/rules`, L = new URLSearchParams({ root: "true", keywords: "", page: "1", size: "200", disabled: "", category: "" }), O = await Wr(`${N}?${L}`, { signal: o.signal }, e), I = await O.text();
3467
+ if (!O.ok) {
3468
+ let z = I || `HTTP ${O.status}`;
3469
+ try {
3470
+ const G = JSON.parse(I);
3471
+ z = ((l = G.error) == null ? void 0 : l.message) || G.error || G.message || z;
3472
+ } catch {
3473
+ }
3474
+ throw new Error(String(z));
3475
+ }
3476
+ S = De(JSON.parse(I));
3477
+ }
3478
+ if (o.signal.aborted) return;
3479
+ if (!g()) throw new re("contextChanged");
3480
+ if (!S || typeof S != "object" || !Array.isArray(S.items)) throw new re("invalidResponse");
3481
+ const C = o.form.querySelector("datalist");
3482
+ for (const A of S.items) {
3483
+ const N = (A == null ? void 0 : A.ruleChain) || A;
3484
+ if (typeof (N == null ? void 0 : N.id) != "string" || !N.id || N.root === !1 || f.has(N.id)) continue;
3485
+ f.add(N.id);
3486
+ const L = document.createElement("option");
3487
+ L.value = N.id, L.label = String(N.name || N.id), C.appendChild(L);
3488
+ }
3489
+ b = !0, Y(d, "");
3490
+ } catch (g) {
3491
+ o.signal.aborted || Y(d, R(e, "businessLog", "listFailed", { error: Ee(e, g) }), "warning");
3492
+ }
3493
+ })(), o.setCloseGuard(async () => o.confirmation.isOpen() ? (o.confirmation.cancel(), !1) : s.value === r.handler && i.checked === r.chainEnd || o.confirmation.ask(R(e, "businessLog", "confirmDiscard")));
3494
+ const y = (h) => {
3495
+ var S, C, A, N;
3496
+ if (Pe(e)) {
3497
+ Y(o.feedback, R(e, "businessLog", "readOnly"), "error");
3498
+ return;
3499
+ }
3500
+ const l = tt(e), g = l ? l.id !== t.id ? "changedChain" : JSON.stringify([(S = l.configuration) == null ? void 0 : S.logHandler, (C = l.configuration) == null ? void 0 : C.logEvents]) !== n ? "changedLog" : "" : "missingChain";
3501
+ if (g) {
3502
+ Y(o.feedback, R(e, "businessLog", g), "error");
3503
+ return;
3504
+ }
3505
+ try {
3506
+ const L = An(l.configuration || {}, h ? "" : s.value, !h && i.checked);
3507
+ if (JSON.stringify([L.logHandler, L.logEvents]) !== n) {
3508
+ typeof ((N = (A = e.core) == null ? void 0 : A.store) == null ? void 0 : N.setState) == "function" ? e.core.store.setState({ ruleChain: { ...l, configuration: L } }) : l.configuration = L, dn(e, "chain:business-log");
3509
+ const O = !h && s.value.trim() && b && !f.has(s.value.trim());
3510
+ Ze(e, `${R(e, "businessLog", "saved")}${O ? `
3511
+ ` + R(e, "businessLog", "unknownHandler", { id: s.value.trim() }) : ""}`);
3512
+ }
3513
+ o.close();
3514
+ } catch (L) {
3515
+ Y(o.feedback, R(e, "businessLog", "applyFailed", { error: Ee(e, L) }), "error");
3516
+ }
3517
+ };
3518
+ return o.form.addEventListener("submit", (h) => {
3519
+ h.preventDefault(), y(!1);
3520
+ }, { signal: o.signal }), o.form.querySelector("[data-log-clear]").addEventListener("click", () => {
3521
+ o.confirmation.ask(R(e, "businessLog", "confirmClear")).then((h) => {
3522
+ h && !o.signal.aborted && y(!0);
3523
+ });
3524
+ }, { signal: o.signal }), { element: o.element, close: o.close, requestClose: o.requestClose };
3525
+ }
3526
+ const Rr = 20, Pa = 300, Pr = "[data-shared-form]";
3527
+ function $e(e) {
3528
+ return e !== null && typeof e == "object" && !Array.isArray(e);
3529
+ }
3530
+ function Da(e, t) {
3531
+ return t ? Object.entries(t).reduce((r, [n, a]) => r.split(`{{${n}}}`).join(a).split(`{${n}}`).join(a), e) : e;
3532
+ }
3533
+ function M(e, t, r, n) {
3534
+ const a = e.t(t, n);
3535
+ return a && a !== t ? a : Da(r, n);
3536
+ }
3537
+ function Oa(e) {
3538
+ if (!$e(e)) return null;
3539
+ const t = Number(e.status);
3540
+ return Number.isFinite(t) ? t : null;
3541
+ }
3542
+ function Lt(e) {
3543
+ return e instanceof Error && e.message ? e.message : String(e || "");
3544
+ }
3545
+ function un(e) {
3546
+ return Array.isArray(e) ? e.some((t) => {
3547
+ if (!$e(t)) return !1;
3548
+ const r = String(t.ref || "").toLowerCase();
3549
+ return r === "primary" || r === "shared" || un(t.fields);
3550
+ }) : !1;
3551
+ }
3552
+ function Dr(e) {
3553
+ const t = [
3554
+ ...Array.isArray(e.components) ? e.components : [],
3555
+ ...Object.values(e._nodeComponents || {})
3556
+ ], r = /* @__PURE__ */ new Set();
3557
+ return t.filter($e).filter((n) => un(n.fields)).filter((n) => {
3558
+ const a = String(n.type || "").trim();
3559
+ return !a || r.has(a) ? !1 : (r.add(a), !0);
3560
+ }).sort((n, a) => {
3561
+ const o = String(n.label || n.type || ""), s = String(a.label || a.type || "");
3562
+ return o.localeCompare(s);
3563
+ });
3564
+ }
3565
+ function fn(e) {
3566
+ if (!Array.isArray(e)) return {};
3567
+ const t = {};
3568
+ return e.forEach((r) => {
3569
+ if (!$e(r)) return;
3570
+ const n = String(r.name || "").trim(), a = String(r.ref || "").toLowerCase();
3571
+ if ((a === "primary" || a === "shared") && n) {
3572
+ r.defaultValue !== void 0 && (t[n] = r.defaultValue);
3573
+ return;
3574
+ }
3575
+ const o = fn(r.fields);
3576
+ Object.keys(o).length !== 0 && (n ? t[n] = o : Object.assign(t, o));
3577
+ }), t;
3578
+ }
3579
+ function Or(e) {
3580
+ return fn(e == null ? void 0 : e.fields);
3581
+ }
3582
+ function Rt(e, t) {
3583
+ var a;
3584
+ const r = e.trim();
3585
+ return String(((a = t.get(r)) == null ? void 0 : a.componentKind) || "").toLowerCase() === "ec" || r.toLowerCase().startsWith("endpoint") ? "endpoint" : r;
3586
+ }
3587
+ function We(e) {
3588
+ return {
3589
+ id: String(e.id ?? ""),
3590
+ name: String(e.name ?? e.label ?? ""),
3591
+ type: String(e.type ?? e.componentType ?? "")
3592
+ };
3593
+ }
3594
+ function Ir(e) {
3595
+ const t = JSON.stringify(e === void 0 ? {} : e, null, 2);
3596
+ return t === void 0 ? "{}" : t;
3597
+ }
3598
+ function Ia(e, t) {
3599
+ switch (t == null ? void 0 : t.sharedPhase) {
3600
+ case "loading":
3601
+ return M(e, "editor.componentManage.sharedNodes.statusLoading", "Loading connection status...");
3602
+ case "unsupported":
3603
+ return M(e, "editor.componentManage.sharedNodes.statusUnsupported", "Connection status is not supported by this server");
3604
+ case "unauthorized":
3605
+ return M(e, "editor.componentManage.sharedNodes.statusUnauthorized", "Sign in to view connection status");
3606
+ case "stale":
3607
+ return M(e, "editor.componentManage.sharedNodes.statusStale", "Connection status may be stale");
3608
+ case "error":
3609
+ return M(e, "editor.componentManage.sharedNodes.statusError", "Connection status could not be loaded");
3610
+ default:
3611
+ return "";
3612
+ }
3613
+ }
3614
+ function qa(e, t, r) {
3615
+ var d;
3616
+ const { id: n } = We(t), a = (r == null ? void 0 : r.sharedPhase) || "idle";
3617
+ let o = "", s = "neutral", i = "";
3618
+ if (a === "loading")
3619
+ o = M(e, "editor.componentManage.sharedNodes.statusLoadingShort", "Loading");
3620
+ else if (a === "unsupported")
3621
+ o = M(e, "editor.componentManage.sharedNodes.statusUnsupportedShort", "Unsupported");
3622
+ else if (a === "unauthorized")
3623
+ o = M(e, "editor.componentManage.sharedNodes.statusUnauthorizedShort", "Unauthorized");
3624
+ else if (a === "error")
3625
+ o = M(e, "editor.componentManage.sharedNodes.statusErrorShort", "Unavailable");
3626
+ else {
3627
+ const c = (d = r == null ? void 0 : r.shared) == null ? void 0 : d[n], u = ea(c, a === "stale", (f, b) => M(e, `editor.nodeConnection.${f}`, b));
3628
+ u ? (o = u.label, s = u.kind, i = u.tooltip) : o = a === "stale" ? M(e, "editor.componentManage.sharedNodes.statusStaleShort", "Stale") : M(e, "editor.componentManage.sharedNodes.statusUnknown", "Unknown");
3629
+ }
3630
+ return `<span class="shared_node_status is_${j(s)}" title="${j(i || o)}"><span aria-hidden="true"></span>${X(o)}</span>`;
3631
+ }
3632
+ function Co(e, t) {
3633
+ var lr;
3634
+ Rn();
3635
+ const r = String(e.opts.apiBase || "").trim().replace(/\/+$/, ""), n = r ? new zn({
3636
+ apiBase: r,
3637
+ timeout: e.opts.fetchTimeout,
3638
+ headers: e.opts.fetchHeaders,
3639
+ customFetch: e.opts.customFetch,
3640
+ onAuthRequired: e.opts.onApiAuthRequired,
3641
+ serverStatus: e.serverStatus
3642
+ }) : null;
3643
+ let a = Dr(e);
3644
+ const o = new Map(a.map((k) => [String(k.type), k]));
3645
+ let s = !1, i = !1, d = !1, c = !1, u = "list", f = [], b = 1, m = Rr, y = 0, w = !1, v = "", p = 0, _ = null, x = null;
3646
+ const h = new AbortController();
3647
+ let l = new AbortController(), g, S = null, C = null, A = e.connectionStatus, N = e.acquireSharedConnectionStatuses, L = 0, O = ((lr = e.connectionStatus) == null ? void 0 : lr.getState()) || null, I = null, z = "", G = "", K = "{}";
3648
+ const le = () => {
3649
+ var k, $, E;
3650
+ return e.readOnly === !0 || e.opts.readOnly === !0 || e.opts.disabled === !0 || e.opts.mode === "readonly" || (($ = (k = e.capabilities) == null ? void 0 : k.editor) == null ? void 0 : $.readOnly) === !0 || ((E = e.capabilities) == null ? void 0 : E.mode) === "readonly";
3651
+ }, Z = () => s && !i && !le(), W = (k, $) => `<span data-shared-label="${j(k)}" data-shared-fallback="${j($)}">${X(M(e, `editor.componentManage.sharedNodes.${k}`, $))}</span>`;
3652
+ t.innerHTML = `
3653
+ <section class="shared_node_manager" data-shared-node-manager>
3654
+ <div data-shared-list-view>
3655
+ <div class="shared_node_toolbar">
3656
+ <div class="shared_node_search">
3657
+ <input type="search" data-shared-search placeholder="${j(M(e, "editor.componentManage.sharedNodes.searchPlaceholder", "Search shared nodes..."))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.searchPlaceholder", "Search shared nodes..."))}" />
3658
+ <button type="button" class="shared_node_icon_btn" data-shared-action="search" title="${j(M(e, "editor.componentManage.sharedNodes.search", "Search"))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.search", "Search"))}">⌕</button>
3659
+ </div>
3660
+ <button type="button" class="btn_primary shared_node_create" data-shared-action="create"${a.length ? "" : " disabled"}>+ ${W("create", "New shared node")}</button>
3661
+ </div>
3662
+ <div class="shared_node_feedback" data-shared-feedback role="status" aria-live="polite"></div>
3663
+ <div class="shared_node_phase" data-shared-phase role="status"></div>
3664
+ <div class="shared_node_table_wrap">
3665
+ <table class="shared_node_table">
3666
+ <thead>
3667
+ <tr>
3668
+ <th>${W("id", "ID")}</th>
3669
+ <th>${W("name", "Name")}</th>
3670
+ <th>${W("componentType", "Component type")}</th>
3671
+ <th>${W("connectionStatus", "Connection status")}</th>
3672
+ <th>${W("actions", "Actions")}</th>
3673
+ </tr>
3674
+ </thead>
3675
+ <tbody data-shared-list></tbody>
3676
+ </table>
3677
+ </div>
3678
+ <div class="shared_node_pagination" data-shared-pagination>
3679
+ <label>
3680
+ ${W("pageSize", "Page size")}
3681
+ <select data-shared-page-size>
3682
+ <option value="10">10</option>
3683
+ <option value="20" selected>20</option>
3684
+ <option value="50">50</option>
3685
+ </select>
3686
+ </label>
3687
+ <span data-shared-page-summary></span>
3688
+ <div>
3689
+ <button type="button" class="shared_node_icon_btn" data-shared-action="previous" title="${j(M(e, "editor.componentManage.sharedNodes.previous", "Previous page"))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.previous", "Previous page"))}">‹</button>
3690
+ <button type="button" class="shared_node_icon_btn" data-shared-action="next" title="${j(M(e, "editor.componentManage.sharedNodes.next", "Next page"))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.next", "Next page"))}">›</button>
3691
+ </div>
3692
+ </div>
3693
+ </div>
3694
+ <div data-shared-form-view hidden>
3695
+ <div class="shared_node_form_header">
3696
+ <div>
3697
+ <h3 data-shared-form-title></h3>
3698
+ <p>${W("formHint", "Basic fields are structured; configuration is saved as a complete JSON object.")}</p>
3699
+ </div>
3700
+ <button type="button" class="shared_node_icon_btn" data-shared-action="back" title="${j(M(e, "editor.componentManage.sharedNodes.back", "Back to list"))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.back", "Back to list"))}">←</button>
3701
+ </div>
3702
+ <div class="shared_node_form">
3703
+ <label class="huanban_form_item">
3704
+ ${W("id", "ID")}
3705
+ <input type="text" data-shared-form data-shared-field="id" autocomplete="off" />
3706
+ </label>
3707
+ <label class="huanban_form_item">
3708
+ ${W("name", "Name")}
3709
+ <input type="text" data-shared-form data-shared-field="name" autocomplete="off" />
3710
+ </label>
3711
+ <label class="huanban_form_item">
3712
+ ${W("componentType", "Component type")}
3713
+ <select data-shared-form data-shared-field="type"></select>
3714
+ </label>
3715
+ <label class="huanban_form_item shared_node_configuration">
3716
+ ${W("configuration", "Configuration (JSON)")}
3717
+ <textarea rows="14" data-shared-form data-shared-field="configuration" spellcheck="false"></textarea>
3718
+ </label>
3719
+ <div class="shared_node_json_actions">
3720
+ <button type="button" class="btn_cancel" data-shared-action="format">${W("formatJson", "Format JSON")}</button>
3721
+ </div>
3722
+ <div class="shared_node_form_error" data-shared-form-error role="alert"></div>
3723
+ <div class="shared_node_form_actions">
3724
+ <button type="button" class="btn_cancel" data-shared-action="back">${W("cancel", "Cancel")}</button>
3725
+ <button type="button" class="btn_primary" data-shared-action="save">${W("save", "Save")}</button>
3726
+ </div>
3727
+ </div>
3728
+ </div>
3729
+ </section>
3730
+ `;
3731
+ const V = t.querySelector("[data-shared-node-manager]");
3732
+ V.setAttribute("inert", "");
3733
+ const ve = t.querySelector("[data-shared-list-view]"), _e = t.querySelector("[data-shared-form-view]"), he = t.querySelector("[data-shared-list]"), oe = t.querySelector("[data-shared-feedback]"), we = t.querySelector("[data-shared-phase]"), q = t.querySelector("[data-shared-pagination]"), B = t.querySelector("[data-shared-page-summary]"), D = t.querySelector("[data-shared-search]"), U = t.querySelector('[data-shared-field="id"]'), J = t.querySelector('[data-shared-field="name"]'), ee = t.querySelector('[data-shared-field="type"]'), te = t.querySelector('[data-shared-field="configuration"]'), nt = t.querySelector("[data-shared-form-title]"), He = t.querySelector("[data-shared-form-error]"), Be = t.querySelector('[data-shared-action="save"]'), ae = (k = "", $ = "info") => {
3734
+ oe.textContent = k, oe.dataset.kind = k ? $ : "";
3735
+ }, at = (k) => {
3736
+ _ == null || _.abort();
3737
+ const $ = new AbortController();
3738
+ return _ = $, x = k, { controller: $, generation: ++p };
3739
+ }, de = (k, $) => !i && s && !k.signal.aborted && _ === k && p === $, Oe = (k, $) => {
3740
+ de(k, $) && (_ = null, x = null);
3741
+ }, ot = () => {
3742
+ x === "list" && (d = !1), p += 1, _ == null || _.abort(), _ = null, x = null, c = !1;
3743
+ }, se = (k = "") => {
3744
+ He.textContent = k, He.hidden = !k;
3745
+ }, st = (k) => {
3746
+ u = k, ve.hidden = k !== "list", _e.hidden = k === "list";
3747
+ }, Ct = () => {
3748
+ const k = le();
3749
+ t.querySelector('[data-shared-action="create"]').disabled = k || !a.length, t.querySelectorAll('[data-shared-action="delete"], [data-shared-action="format"]').forEach(($) => {
3750
+ $.disabled = k;
3751
+ }), U.readOnly = k || u === "edit", J.readOnly = k, te.readOnly = k, ee.disabled = k || u === "edit", Be.disabled = k || x === "save";
3752
+ }, hn = () => {
3753
+ const k = Ia(e, O);
3754
+ we.textContent = k, we.hidden = !k, we.dataset.phase = (O == null ? void 0 : O.sharedPhase) || "idle";
3755
+ }, er = () => w ? b * m < y : f.length >= m, Se = () => {
3756
+ hn(), c ? he.innerHTML = `<tr><td colspan="5" class="shared_node_empty">${X(M(e, "editor.componentManage.sharedNodes.loading", "Loading shared nodes..."))}</td></tr>` : f.length === 0 ? he.innerHTML = `<tr><td colspan="5" class="shared_node_empty">${X(M(e, "editor.componentManage.sharedNodes.empty", "No shared nodes"))}</td></tr>` : he.innerHTML = f.map((P, F) => {
3757
+ const H = We(P);
3758
+ return `
3759
+ <tr>
3760
+ <td data-label="${j(M(e, "editor.componentManage.sharedNodes.id", "ID"))}"><code title="${j(H.id)}">${X(H.id || "-")}</code></td>
3761
+ <td data-label="${j(M(e, "editor.componentManage.sharedNodes.name", "Name"))}"><span title="${j(H.name)}">${X(H.name || "-")}</span></td>
3762
+ <td data-label="${j(M(e, "editor.componentManage.sharedNodes.componentType", "Component type"))}"><code title="${j(H.type)}">${X(H.type || "-")}</code></td>
3763
+ <td data-label="${j(M(e, "editor.componentManage.sharedNodes.connectionStatus", "Connection status"))}">${qa(e, P, O)}</td>
3764
+ <td data-label="${j(M(e, "editor.componentManage.sharedNodes.actions", "Actions"))}">
3765
+ <div class="shared_node_row_actions">
3766
+ <button type="button" class="shared_node_icon_btn" data-shared-action="edit" data-shared-index="${F}" title="${j(M(e, "editor.componentManage.sharedNodes.edit", "Edit"))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.edit", "Edit"))}">${Ne("edit")}</button>
3767
+ <button type="button" class="shared_node_icon_btn is_danger" data-shared-action="delete" data-shared-index="${F}" title="${j(M(e, "editor.componentManage.sharedNodes.delete", "Delete"))}" aria-label="${j(M(e, "editor.componentManage.sharedNodes.delete", "Delete"))}">${Ne("delete")}</button>
3768
+ </div>
3769
+ </td>
3770
+ </tr>
3771
+ `;
3772
+ }).join("");
3773
+ const k = w ? Math.max(1, Math.ceil(y / m)) : Math.max(1, b);
3774
+ B.textContent = M(
3775
+ e,
3776
+ "editor.componentManage.sharedNodes.pageSummary",
3777
+ "Page {{page}} of {{pages}}, {{total}} total",
3778
+ { page: String(b), pages: String(k), total: String(y) }
3779
+ );
3780
+ const $ = q.querySelector('[data-shared-action="previous"]'), E = q.querySelector('[data-shared-action="next"]');
3781
+ $.disabled = b <= 1, E.disabled = !er(), Ct();
3782
+ }, Ie = (k, $) => {
3783
+ const E = Oa($), P = Lt($);
3784
+ if (E === 401 || E === 403) {
3785
+ const be = M(e, "editor.componentManage.sharedNodes.unauthorized", "You are not authorized to manage shared nodes");
3786
+ k === "save" ? se(`${be}${P ? `: ${P}` : ""}`) : ae(`${be}${P ? `: ${P}` : ""}`, "error");
3787
+ return;
3788
+ }
3789
+ if (E === 404 || E === 501) {
3790
+ const be = M(e, "editor.componentManage.sharedNodes.unsupported", "Shared-node management is not supported by this server");
3791
+ k === "save" ? se(`${be}${P ? `: ${P}` : ""}`) : ae(`${be}${P ? `: ${P}` : ""}`, "error");
3792
+ return;
3793
+ }
3794
+ const F = {
3795
+ load: ["loadFailed", "Failed to load shared nodes"],
3796
+ detail: ["detailFailed", "Failed to load shared-node details"],
3797
+ save: ["saveFailed", "Failed to save shared node"],
3798
+ delete: ["deleteFailed", "Failed to delete shared node"]
3799
+ }, [H, xe] = F[k], Ce = M(e, `editor.componentManage.sharedNodes.${H}`, xe);
3800
+ k === "save" ? se(`${Ce}${P ? `: ${P}` : ""}`) : ae(`${Ce}${P ? `: ${P}` : ""}`, "error");
3801
+ }, ge = async () => {
3802
+ if (i || !s || x === "save" || x === "delete") return !1;
3803
+ if (!n)
3804
+ return f = [], y = 0, w = !0, Se(), ae(M(e, "editor.componentManage.sharedNodes.unsupported", "Shared-node management requires apiBase"), "error"), !1;
3805
+ const { controller: k, generation: $ } = at("list");
3806
+ c = !0, ae(M(e, "editor.componentManage.sharedNodes.loading", "Loading shared nodes...")), Se();
3807
+ try {
3808
+ const E = await n.getSharedNodes(v, b, m, void 0, k.signal);
3809
+ return de(k, $) ? (f = E.items.filter($e), b = Math.max(1, Number(E.page) || b), m = Math.max(1, Number(E.pageSize) || m), y = Math.max(0, Number(E.total) || 0), w = E.totalIsAuthoritative === !0, d = !0, c = !1, ae(), Se(), !0) : !1;
3810
+ } catch (E) {
3811
+ return de(k, $) && (c = !1, Ie("load", E), Se()), !1;
3812
+ } finally {
3813
+ Oe(k, $);
3814
+ }
3815
+ }, tr = async () => {
3816
+ if (typeof e.reloadComponents != "function") return !1;
3817
+ try {
3818
+ return await e.reloadComponents({ forceRefresh: !0 }) === !0;
3819
+ } catch {
3820
+ return !1;
3821
+ }
3822
+ }, rr = (k, $) => {
3823
+ const E = a.map((P) => {
3824
+ const F = String(P.type || ""), H = String(P.label || F);
3825
+ return `<option value="${j(F)}"${F === k ? " selected" : ""}>${X(H)} (${X(F)})</option>`;
3826
+ });
3827
+ k && !o.has(k) && E.unshift(`<option value="${j(k)}" selected>${X(k)}</option>`), $ || E.unshift(`<option value="">${X(M(e, "editor.componentManage.sharedNodes.selectComponent", "Select a component"))}</option>`), ee.innerHTML = E.join("");
3828
+ }, kt = () => {
3829
+ z = Kt(_e, { selector: Pr });
3830
+ }, nr = (k, $) => {
3831
+ const E = We($);
3832
+ I = k === "edit" ? { ...$ } : null, nt.textContent = k === "edit" ? M(e, "editor.componentManage.sharedNodes.editTitle", "Edit shared node") : M(e, "editor.componentManage.sharedNodes.createTitle", "New shared node"), U.value = E.id, J.value = E.name, rr(E.type, k === "edit"), ee.value = E.type, te.value = Ir($.configuration), U.readOnly = k === "edit", ee.disabled = k === "edit", G = E.type, K = te.value, se(), Be.disabled = !1, st(k), Ct(), kt(), (k === "create" ? U : J).focus();
3833
+ }, gn = () => {
3834
+ if (Z()) {
3835
+ if (a.length === 0) {
3836
+ ae(M(e, "editor.componentManage.sharedNodes.noEligibleComponents", "No installed component supports shared references"), "error");
3837
+ return;
3838
+ }
3839
+ bn("");
3840
+ }
3841
+ }, bn = (k) => {
3842
+ const $ = Or(o.get(k));
3843
+ nr("create", { id: "", name: "", type: k, configuration: $ });
3844
+ }, pn = async (k) => {
3845
+ if (!n || i || !s || x === "save" || x === "delete") return;
3846
+ const { id: $, type: E } = We(k);
3847
+ if (!$ || !E) {
3848
+ Ie("detail", new Error(M(e, "editor.componentManage.sharedNodes.identityMissing", "Shared-node ID and component type are required")));
3849
+ return;
3850
+ }
3851
+ const { controller: P, generation: F } = at("detail");
3852
+ ae(M(e, "editor.componentManage.sharedNodes.detailLoading", "Loading shared-node details..."));
3853
+ try {
3854
+ const H = await n.getSharedNode(
3855
+ $,
3856
+ Rt(E, o),
3857
+ P.signal
3858
+ );
3859
+ if (!de(P, F)) return;
3860
+ if (!$e(H)) throw new Error(M(e, "editor.componentManage.sharedNodes.detailInvalid", "Shared-node detail is not an object"));
3861
+ ae(), nr("edit", { ...k, ...H, id: H.id ?? $, type: H.type ?? E });
3862
+ } catch (H) {
3863
+ if (!de(P, F)) return;
3864
+ Ie("detail", H);
3865
+ } finally {
3866
+ Oe(P, F);
3867
+ }
3868
+ }, mn = () => {
3869
+ const k = U.value.trim(), $ = J.value.trim(), E = ee.value.trim();
3870
+ if (!k || !$ || !E)
3871
+ return se(M(e, "editor.componentManage.sharedNodes.required", "ID, name, and component type are required")), null;
3872
+ try {
3873
+ const P = JSON.parse(te.value || "{}");
3874
+ return $e(P) ? { id: k, name: $, type: E, configuration: P } : (se(M(e, "editor.componentManage.sharedNodes.configurationObjectRequired", "Configuration must be a JSON object")), null);
3875
+ } catch (P) {
3876
+ return se(`${M(e, "editor.componentManage.sharedNodes.invalidJson", "Configuration is not valid JSON")}: ${Lt(P)}`), null;
3877
+ }
3878
+ }, ar = async () => {
3879
+ if (!n || u === "list" || !Z() || x === "save" || x === "delete") return !1;
3880
+ const k = mn();
3881
+ if (!k) return !1;
3882
+ const $ = {
3883
+ ...I || {},
3884
+ id: k.id,
3885
+ name: k.name,
3886
+ type: k.type,
3887
+ configuration: k.configuration
3888
+ };
3889
+ Be.disabled = !0, se();
3890
+ const { controller: E, generation: P } = at("save");
3891
+ try {
3892
+ if (await n.saveSharedNode(
3893
+ k.id,
3894
+ Rt(k.type, o),
3895
+ $,
3896
+ E.signal
3897
+ ), !de(E, P)) return !1;
3898
+ kt();
3899
+ const F = await tr();
3900
+ return !de(E, P) || (st("list"), Oe(E, P), !await ge() || i || !s) ? !1 : F ? (ae(M(e, "editor.componentManage.sharedNodes.saveSuccess", "Shared node saved"), "success"), !0) : (ae(M(e, "editor.componentManage.sharedNodes.refreshFailed", "Shared node was saved, but the component catalog could not be refreshed"), "error"), !1);
3901
+ } catch (F) {
3902
+ return de(E, P) && Ie("save", F), !1;
3903
+ } finally {
3904
+ Oe(E, P), i || Ct();
3905
+ }
3906
+ }, yn = async (k) => {
3907
+ if (!n || !Z() || x === "save" || x === "delete") return;
3908
+ const { id: $, name: E, type: P } = We(k);
3909
+ if (!$ || !P) {
3910
+ Ie("delete", new Error(M(e, "editor.componentManage.sharedNodes.identityMissing", "Shared-node ID and component type are required")));
3911
+ return;
3912
+ }
3913
+ const F = M(
3914
+ e,
3915
+ "editor.componentManage.sharedNodes.confirmDelete",
3916
+ 'Delete shared node "{{name}}"? This cannot be undone.',
3917
+ { name: E || $ }
3918
+ );
3919
+ if (!(it(e) ? await it(e).confirm({ message: F, type: "danger" }) : !1) || !Z()) return;
3920
+ ae(M(e, "editor.componentManage.sharedNodes.deleting", "Deleting shared node..."));
3921
+ const { controller: xe, generation: Ce } = at("delete");
3922
+ try {
3923
+ if (await n.deleteSharedNode(
3924
+ $,
3925
+ Rt(P, o),
3926
+ xe.signal
3927
+ ), !de(xe, Ce)) return;
3928
+ const be = await tr();
3929
+ if (!de(xe, Ce) || (Oe(xe, Ce), !await ge() || i || !s)) return;
3930
+ if (!be) {
3931
+ ae(M(e, "editor.componentManage.sharedNodes.deleteRefreshFailed", "Shared node was deleted, but the component catalog could not be refreshed"), "error");
3932
+ return;
3933
+ }
3934
+ ae(M(e, "editor.componentManage.sharedNodes.deleteSuccess", "Shared node deleted"), "success");
3935
+ } catch (be) {
3936
+ if (!de(xe, Ce)) return;
3937
+ Ie("delete", be);
3938
+ } finally {
3939
+ Oe(xe, Ce);
3940
+ }
3941
+ }, At = () => !i && u !== "list" && !!z && aa(_e, z, { selector: Pr }), or = async () => {
3942
+ if (i) return !1;
3943
+ if (!At()) return !0;
3944
+ if (!s) return !1;
3945
+ const k = l.signal, $ = await oa({
3946
+ t: (E, P) => e.t(E, P),
3947
+ _activeDrawerWrapper: e._activeDrawerWrapper,
3948
+ themeOwner: V,
3949
+ guardOwner: V,
3950
+ signal: k
3951
+ });
3952
+ return i || !s || k.aborted ? !1 : $ === "discard" ? (ot(), st("list"), se(), !0) : $ === "save" ? ar() : !1;
3953
+ }, vn = async () => {
3954
+ await or() && (i || !s || (st("list"), se()));
3955
+ };
3956
+ t.addEventListener("click", (k) => {
3957
+ var F;
3958
+ if (i || !s) return;
3959
+ const $ = (F = k.target) == null ? void 0 : F.closest("[data-shared-action]");
3960
+ if (!$ || $ instanceof HTMLButtonElement && $.disabled) return;
3961
+ const E = $.dataset.sharedAction;
3962
+ if (E === "search") {
3963
+ qe(), v = D.value.trim(), b = 1, ge();
3964
+ return;
3965
+ }
3966
+ if (E === "create") {
3967
+ gn();
3968
+ return;
3969
+ }
3970
+ if (E === "previous" && b > 1) {
3971
+ b -= 1, ge();
3972
+ return;
3973
+ }
3974
+ if (E === "next" && er()) {
3975
+ b += 1, ge();
3976
+ return;
3977
+ }
3978
+ const P = Number($.dataset.sharedIndex);
3979
+ if (E === "edit" && Number.isInteger(P) && f[P]) {
3980
+ pn(f[P]);
3981
+ return;
3982
+ }
3983
+ if (E === "delete" && Number.isInteger(P) && f[P]) {
3984
+ yn(f[P]);
3985
+ return;
3986
+ }
3987
+ if (E === "back") {
3988
+ vn();
3989
+ return;
3990
+ }
3991
+ if (E === "save") {
3992
+ ar();
3993
+ return;
3994
+ }
3995
+ if (E === "format") {
3996
+ if (!Z()) return;
3997
+ try {
3998
+ const H = JSON.parse(te.value || "{}");
3999
+ if (!$e(H)) throw new Error(M(e, "editor.componentManage.sharedNodes.configurationObjectRequired", "Configuration must be a JSON object"));
4000
+ te.value = JSON.stringify(H, null, 2), se();
4001
+ } catch (H) {
4002
+ se(`${M(e, "editor.componentManage.sharedNodes.invalidJson", "Configuration is not valid JSON")}: ${Lt(H)}`);
4003
+ }
4004
+ }
4005
+ }, { signal: h.signal }), t.addEventListener("input", (k) => {
4006
+ i || !s || k.target !== D || (qe(), g = window.setTimeout(() => {
4007
+ g = void 0, v = D.value.trim(), b = 1, ge();
4008
+ }, Pa));
4009
+ }, { signal: h.signal }), t.addEventListener("keydown", (k) => {
4010
+ i || !s || k.target !== D || k.key !== "Enter" || (k.preventDefault(), qe(), v = D.value.trim(), b = 1, ge());
4011
+ }, { signal: h.signal }), t.addEventListener("change", async (k) => {
4012
+ if (i || !s) return;
4013
+ const $ = k.target;
4014
+ if ($ instanceof HTMLSelectElement && $.matches("[data-shared-page-size]")) {
4015
+ m = Math.max(1, Number($.value) || Rr), b = 1, ge();
4016
+ return;
4017
+ }
4018
+ if ($ !== ee || u !== "create" || !Z()) return;
4019
+ const E = ee.value;
4020
+ if (te.value !== K) {
4021
+ const P = M(e, "editor.componentManage.sharedNodes.confirmTypeChange", "Changing component type will replace the current configuration. Continue?");
4022
+ if (!(it(e) ? await it(e).confirm({ message: P, type: "warning" }) : !1)) {
4023
+ ee.value = G;
4024
+ return;
4025
+ }
4026
+ }
4027
+ G = E, K = Ir(Or(o.get(E))), te.value = K;
4028
+ }, { signal: h.signal });
4029
+ const Et = () => {
4030
+ L += 1, C == null || C(), C = null, S == null || S(), S = null;
4031
+ }, sr = () => {
4032
+ var $;
4033
+ A = e.connectionStatus, N = e.acquireSharedConnectionStatuses, O = (A == null ? void 0 : A.getState()) || null;
4034
+ const k = ++L;
4035
+ C = (A == null ? void 0 : A.subscribe((E) => {
4036
+ i || !s || k !== L || (O = E, Se());
4037
+ })) || null, S = (($ = e.acquireSharedConnectionStatuses) == null ? void 0 : $.call(e)) || null;
4038
+ }, _n = () => {
4039
+ if (i) return;
4040
+ const k = At(), $ = ee.value;
4041
+ a = Dr(e), o.clear(), a.forEach((E) => o.set(String(E.type), E)), u !== "list" && (rr($, u === "edit"), ee.value = $, nt.textContent = u === "edit" ? M(e, "editor.componentManage.sharedNodes.editTitle", "Edit shared node") : M(e, "editor.componentManage.sharedNodes.createTitle", "New shared node")), t.querySelectorAll("[data-shared-label]").forEach((E) => {
4042
+ E.textContent = M(e, `editor.componentManage.sharedNodes.${E.dataset.sharedLabel}`, E.dataset.sharedFallback || "");
4043
+ }), D.placeholder = M(e, "editor.componentManage.sharedNodes.searchPlaceholder", "Search shared nodes..."), D.setAttribute("aria-label", D.placeholder);
4044
+ for (const [E, P, F] of [
4045
+ ["search", "search", "Search"],
4046
+ ["previous", "previous", "Previous page"],
4047
+ ["next", "next", "Next page"],
4048
+ ["back", "back", "Back to list"]
4049
+ ])
4050
+ t.querySelectorAll(`[data-shared-action="${E}"][title]`).forEach((H) => {
4051
+ H.title = M(e, `editor.componentManage.sharedNodes.${P}`, F), H.setAttribute("aria-label", H.title);
4052
+ });
4053
+ s && (A !== e.connectionStatus || N !== e.acquireSharedConnectionStatuses) && (Et(), sr()), le() && (x === "save" || x === "delete") && ot(), Se(), u !== "list" && !k && kt();
4054
+ }, qe = () => {
4055
+ g !== void 0 && window.clearTimeout(g), g = void 0;
4056
+ }, ir = async () => {
4057
+ if (i || !s || x === "detail" || x === "save" || x === "delete") return !1;
4058
+ qe();
4059
+ const k = D.value.trim();
4060
+ return v !== k && (b = 1), v = k, ge();
4061
+ };
4062
+ return Se(), {
4063
+ activate() {
4064
+ i || s || (s = !0, V.removeAttribute("inert"), l.signal.aborted && (l = new AbortController()), sr(), Se(), d || ir());
4065
+ },
4066
+ deactivate() {
4067
+ i || (s = !1, V.setAttribute("inert", ""), g !== void 0 && (d = !1), ot(), qe(), l.abort(), Et());
4068
+ },
4069
+ destroy() {
4070
+ i || (i = !0, ot(), qe(), h.abort(), l.abort(), Et(), s = !1, V.remove());
4071
+ },
4072
+ reload: ir,
4073
+ refresh: _n,
4074
+ isDirty: At,
4075
+ requestClose: or
4076
+ };
4077
+ }
4078
+ export {
4079
+ Ot as $,
4080
+ co as A,
4081
+ oa as B,
4082
+ Kt as C,
4083
+ Xe as D,
4084
+ ro as E,
4085
+ ea as F,
4086
+ ce as G,
4087
+ gt as H,
4088
+ _a as I,
4089
+ Mt as J,
4090
+ Zr as K,
4091
+ Zt as L,
4092
+ T as M,
4093
+ xt as N,
4094
+ Vn as O,
4095
+ vo as P,
4096
+ ka as Q,
4097
+ Te as R,
4098
+ ze as S,
4099
+ Xa as T,
4100
+ ue as U,
4101
+ Ye as V,
4102
+ Nt as W,
4103
+ St as X,
4104
+ io as Y,
4105
+ lo as Z,
4106
+ ao as _,
4107
+ Wr as a,
4108
+ wo as a0,
4109
+ So as a1,
4110
+ xo as a2,
4111
+ nn as a3,
4112
+ Ea as a4,
4113
+ to as a5,
4114
+ eo as a6,
4115
+ Za as a7,
4116
+ Qa as a8,
4117
+ Ka as a9,
4118
+ Gt as aa,
4119
+ Jn as ab,
4120
+ fr as ac,
4121
+ Aa as ad,
4122
+ rn as ae,
4123
+ tn as af,
4124
+ wa as ag,
4125
+ Ae as ah,
4126
+ Ca as ai,
4127
+ Bt as aj,
4128
+ no as ak,
4129
+ Sa as al,
4130
+ gr as am,
4131
+ Br as an,
4132
+ Xr as ao,
4133
+ me as ap,
4134
+ Ft as aq,
4135
+ Mr as ar,
4136
+ Wt as b,
4137
+ Co as c,
4138
+ Wa as d,
4139
+ it as e,
4140
+ wt as f,
4141
+ Ua as g,
4142
+ Yr as h,
4143
+ uo as i,
4144
+ ho as j,
4145
+ fo as k,
4146
+ yo as l,
4147
+ Na as m,
4148
+ mo as n,
4149
+ go as o,
4150
+ po as p,
4151
+ bo as q,
4152
+ oo as r,
4153
+ Ze as s,
4154
+ Ya as t,
4155
+ so as u,
4156
+ Ve as v,
4157
+ _o as w,
4158
+ Sr as x,
4159
+ jr as y,
4160
+ aa as z
4161
+ };