@fieldwangai/agentflow 0.1.154 → 0.1.156

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.
@@ -150,7 +150,7 @@ export function layoutWorkspaceFlowDir(flowDir, { all = false, workspaceRoot = "
150
150
  }
151
151
 
152
152
  /** 没有节点丢失时的空损耗清单,让返回值形状始终一致。 */
153
- const NO_LOSS = { remapped: [], dropped: [], droppedEdges: [], warnings: [] };
153
+ const NO_LOSS = { remapped: [], dropped: [], droppedEdges: [], renamedIds: [], warnings: [] };
154
154
 
155
155
  /**
156
156
  * 把一个流程目录就地迁移成代码形态。两个来源:
@@ -207,6 +207,7 @@ function migrateLegacyYamlDir(dir, { force = false, marketplaceRoot = "" } = {})
207
207
  remapped: converted.remapped,
208
208
  dropped: converted.dropped,
209
209
  droppedEdges: converted.droppedEdges,
210
+ renamedIds: converted.renamedIds,
210
211
  warnings: converted.warnings,
211
212
  };
212
213
  // `control_end` 和指向它的边标了 benign——丢了等于没丢,不该拦住迁移。
@@ -67,6 +67,34 @@ function slotsOf(instance, definitionId, kind) {
67
67
 
68
68
  const isNodeSlot = (slot) => String(slot?.type || "") === "node";
69
69
 
70
+ // DSL 里的节点 id 同时也是顶层 `const` 变量名。旧 YAML 允许 `foo-bar`、数字开头,
71
+ // 甚至 JS 关键字;直接交给 codegen 会生成无法解析的 workspace.flow.js,整张图只能退回
72
+ // graph.json。迁移时稳定地改成合法且唯一的绑定名,并把改名清单返回给调用方。
73
+ const JS_RESERVED_WORDS = new Set([
74
+ "arguments", "await", "break", "case", "catch", "class", "const", "continue", "debugger", "default",
75
+ "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function",
76
+ "if", "implements", "import", "in", "instanceof", "interface", "let", "new", "null", "package", "eval",
77
+ "private", "protected", "public", "return", "static", "super", "switch", "this", "throw", "true",
78
+ "try", "typeof", "var", "void", "while", "with", "yield",
79
+ ]);
80
+
81
+ function legacyNodeIdMap(ids) {
82
+ const used = new Set();
83
+ const mapping = new Map();
84
+ for (const raw of ids) {
85
+ let base = String(raw || "").replace(/[^A-Za-z0-9_$]/g, "_");
86
+ if (!/^[A-Za-z_$]/.test(base)) base = `node_${base}`;
87
+ if (!base) base = "node";
88
+ if (JS_RESERVED_WORDS.has(base)) base = `${base}_node`;
89
+ let next = base;
90
+ let suffix = 2;
91
+ while (used.has(next)) next = `${base}_${suffix++}`;
92
+ used.add(next);
93
+ mapping.set(raw, next);
94
+ }
95
+ return mapping;
96
+ }
97
+
70
98
  /**
71
99
  * 把老实例的槽位搬到新定义的槽位表上:先对名字,对不上的按位置兜底。
72
100
  *
@@ -121,6 +149,7 @@ function rebuildSlots(oldSlots, newDefSlots) {
121
149
  * remapped: Array<{ id: string, from: string, to: string, caveat?: string }>,
122
150
  * dropped: Array<{ id: string, definitionId: string, reason: string }>,
123
151
  * droppedEdges: Array<{ source: string, target: string, reason: string }>,
152
+ * renamedIds: Array<{ from: string, to: string }>,
124
153
  * warnings: string[],
125
154
  * }}
126
155
  */
@@ -129,10 +158,14 @@ export function legacyYamlToDesignGraph(yamlText) {
129
158
  if (!parsed || typeof parsed !== "object") throw new Error("flow.yaml 解析不出对象");
130
159
  const srcInstances = parsed.instances && typeof parsed.instances === "object" ? parsed.instances : {};
131
160
  const srcEdges = Array.isArray(parsed.edges) ? parsed.edges : [];
161
+ const idMap = legacyNodeIdMap(Object.keys(srcInstances));
132
162
 
133
163
  const remapped = [];
134
164
  const dropped = [];
135
165
  const droppedEdges = [];
166
+ const renamedIds = [...idMap]
167
+ .filter(([from, to]) => from !== to)
168
+ .map(([from, to]) => ({ from, to }));
136
169
  const warnings = [];
137
170
 
138
171
  /** id -> { input, output, renameIn, renameOut },用来重接边。 */
@@ -141,7 +174,8 @@ export function legacyYamlToDesignGraph(yamlText) {
141
174
  const benignDrops = new Set();
142
175
  const instances = {};
143
176
 
144
- for (const [id, raw] of Object.entries(srcInstances)) {
177
+ for (const [legacyId, raw] of Object.entries(srcInstances)) {
178
+ const id = idMap.get(legacyId);
145
179
  const instance = raw && typeof raw === "object" ? raw : {};
146
180
  const from = String(instance.definitionId || "");
147
181
  const oldIn = slotsOf(instance, from, "input");
@@ -154,17 +188,17 @@ export function legacyYamlToDesignGraph(yamlText) {
154
188
  // 终点节点本来就没有对应物需要表达。所以标 benign——报出来,但不算有损。
155
189
  if (hasRemap && to === null) {
156
190
  dropped.push({
157
- id,
191
+ id: legacyId,
158
192
  definitionId: from,
159
193
  benign: true,
160
194
  reason: "Workspace 没有终点节点,跑到没有后继就结束",
161
195
  });
162
- benignDrops.add(id);
196
+ benignDrops.add(legacyId);
163
197
  continue;
164
198
  }
165
199
  if (!hasRemap && definitionOf(from).runtime === "none") {
166
200
  dropped.push({
167
- id,
201
+ id: legacyId,
168
202
  definitionId: from,
169
203
  benign: false,
170
204
  reason: DEFINITIONS[from]
@@ -180,13 +214,14 @@ export function legacyYamlToDesignGraph(yamlText) {
180
214
  const rebuiltOut = rebuildSlots(oldOut, def.output || []);
181
215
  const next = { ...instance, definitionId: to, input: rebuiltIn.slots, output: rebuiltOut.slots };
182
216
  instances[id] = next;
183
- kept.set(id, {
217
+ kept.set(legacyId, {
218
+ id,
184
219
  input: next.input,
185
220
  output: next.output,
186
221
  renameIn: rebuiltIn.renames,
187
222
  renameOut: rebuiltOut.renames,
188
223
  });
189
- const entry = { id, from, to };
224
+ const entry = { id: legacyId, from, to };
190
225
  const droppedFields = [];
191
226
  for (const field of REMAP_DROPPED_FIELDS[to] || []) {
192
227
  const text = String(next[field] ?? "").trim();
@@ -204,7 +239,7 @@ export function legacyYamlToDesignGraph(yamlText) {
204
239
  // 拿定义去覆盖会把作者加的输入抹掉。
205
240
  const next = { ...instance, input: [...oldIn], output: [...oldOut] };
206
241
  instances[id] = next;
207
- kept.set(id, { input: next.input, output: next.output, renameIn: new Map(), renameOut: new Map() });
242
+ kept.set(legacyId, { id, input: next.input, output: next.output, renameIn: new Map(), renameOut: new Map() });
208
243
  }
209
244
  }
210
245
 
@@ -241,28 +276,28 @@ export function legacyYamlToDesignGraph(yamlText) {
241
276
  }
242
277
  // Workspace 禁止 fan-in:同一个输入槽只能有一条入边。老图里靠 control_anyOne
243
278
  // 汇合的分支,删掉汇合点之后会撞在同一个槽上。
244
- const key = `${target} input-${tgtIdx}`;
279
+ const key = `${to.id} input-${tgtIdx}`;
245
280
  if (takenTargets.has(key)) {
246
281
  droppedEdges.push({ source, target, benign: false, reason: `${target}.${tgtFinal} 已经有入边了,Workspace 不允许 fan-in` });
247
282
  continue;
248
283
  }
249
284
  takenTargets.add(key);
250
- edges.push({ source, target, sourceHandle: `output-${srcIdx}`, targetHandle: `input-${tgtIdx}` });
285
+ edges.push({ source: from.id, target: to.id, sourceHandle: `output-${srcIdx}`, targetHandle: `input-${tgtIdx}` });
251
286
  }
252
287
 
253
288
  // ── ui ────────────────────────────────────────────────────────────────────
254
289
  const srcUi = parsed.ui && typeof parsed.ui === "object" ? parsed.ui : {};
255
290
  const nodePositions = {};
256
291
  for (const [id, pos] of Object.entries(srcUi.nodePositions || {})) {
257
- if (kept.has(id)) nodePositions[id] = pos;
292
+ if (kept.has(id)) nodePositions[kept.get(id).id] = pos;
258
293
  }
259
294
  const ui = { nodePositions, nodeSizes: {} };
260
295
  if (typeof srcUi.description === "string" && srcUi.description.trim()) ui.description = srcUi.description;
261
296
 
262
297
  if (!Object.keys(instances).length) warnings.push("迁移之后一个节点都不剩");
263
- else if (![...kept.keys()].some((id) => instances[id].definitionId === "workspace_run")) {
298
+ else if (![...kept.values()].some(({ id }) => instances[id].definitionId === "workspace_run")) {
264
299
  warnings.push("图里没有运行节点(老流程缺 control_start);补一个 workspace_run 才能跑");
265
300
  }
266
301
 
267
- return { graph: { version: 1, instances, edges, ui }, remapped, dropped, droppedEdges, warnings };
302
+ return { graph: { version: 1, instances, edges, ui }, remapped, dropped, droppedEdges, renamedIds, warnings };
268
303
  }
@@ -29,6 +29,7 @@ import { t } from "./i18n.mjs";
29
29
  import {
30
30
  PACKAGE_ROOT,
31
31
  ARCHIVED_PIPELINES_DIR_NAME,
32
+ PIPELINES_DIR,
32
33
  getAgentflowDataRoot,
33
34
  getAgentflowSkillsRoot,
34
35
  getAgentflowUserConfigAbs,
@@ -1686,9 +1687,12 @@ function isValidFlowSourceWrite(s) {
1686
1687
  return s === "user" || s === "workspace";
1687
1688
  }
1688
1689
 
1689
- function cleanupExpiredWorkspacePreviews() {
1690
+ function cleanupExpiredWorkspacePreviews(workspaceRoot = "") {
1690
1691
  const roots = new Set(listAgentflowUserIds().map((id) => getUserPipelinesRoot(id)));
1691
1692
  roots.add(getUserPipelinesRoot(""));
1693
+ if (workspaceRoot) {
1694
+ roots.add(path.join(path.resolve(workspaceRoot), PIPELINES_DIR, ARCHIVED_PIPELINES_DIR_NAME));
1695
+ }
1692
1696
  let removed = 0;
1693
1697
  for (const pipelinesRoot of roots) {
1694
1698
  for (const item of listExpiredWorkspacePreviews(pipelinesRoot)) {
@@ -4290,7 +4294,7 @@ finishedAt: "${new Date().toISOString()}"
4290
4294
 
4291
4295
  const workspacePreviewCleanupTimer = setInterval(() => {
4292
4296
  try {
4293
- const removed = cleanupExpiredWorkspacePreviews();
4297
+ const removed = cleanupExpiredWorkspacePreviews(root);
4294
4298
  if (removed > 0) log.debug(`[workspace-preview] removed ${removed} expired preview project(s)`);
4295
4299
  } catch (e) {
4296
4300
  log.debug(`[workspace-preview] cleanup poll failed: ${(e && e.message) || String(e)}`);
@@ -4301,7 +4305,7 @@ finishedAt: "${new Date().toISOString()}"
4301
4305
  } catch (_) {}
4302
4306
  server.on("close", () => clearInterval(workspacePreviewCleanupTimer));
4303
4307
  try {
4304
- cleanupExpiredWorkspacePreviews();
4308
+ cleanupExpiredWorkspacePreviews(root);
4305
4309
  } catch (_) {}
4306
4310
 
4307
4311
  return new Promise((resolve, reject) => {
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import crypto from "crypto";
4
- import { getUserPipelinesRoot } from "./paths.mjs";
4
+ import { ARCHIVED_PIPELINES_DIR_NAME, PIPELINES_DIR, getUserPipelinesRoot } from "./paths.mjs";
5
5
 
6
6
  export const WORKSPACE_PREVIEW_METADATA_FILENAME = ".agentflow-workspace-preview.json";
7
7
  export const DEFAULT_WORKSPACE_PREVIEW_TTL_MS = 2 * 60 * 60 * 1000;
@@ -42,6 +42,17 @@ export function workspacePreviewFlowDir(flowId, userId = "") {
42
42
  return path.join(getUserPipelinesRoot(userId), safeId);
43
43
  }
44
44
 
45
+ /**
46
+ * CLI 生成的预览要由另一个 Web 登录用户打开,所以不能放在创建者的 personal 目录。
47
+ * 放到 Workspace 的 archived 区域同时得到两条性质:随机链接跨账号可读,所有现有写入/
48
+ * 运行路由又都会按 archived 拒绝操作。
49
+ */
50
+ export function workspaceSharedPreviewFlowDir(workspaceRoot, flowId) {
51
+ const safeId = safePreviewId(flowId);
52
+ if (!safeId) return "";
53
+ return path.join(path.resolve(workspaceRoot), PIPELINES_DIR, ARCHIVED_PIPELINES_DIR_NAME, safeId);
54
+ }
55
+
45
56
  export function createWorkspacePreviewId() {
46
57
  return `preview_${crypto.randomBytes(10).toString("hex")}`;
47
58
  }
@@ -71,4 +82,3 @@ export function listExpiredWorkspacePreviews(userPipelinesRoot, now = Date.now()
71
82
  }
72
83
  return expired;
73
84
  }
74
-
@@ -34,7 +34,7 @@ import { readMergedEnvObject, runtimeEnvForUser } from "./user-env.mjs";
34
34
  import { acceptWorkspaceCollaborationInvite, addWorkspaceCollaborationMember, ensureWorkspaceCollaboration, getWorkspaceCollaborationForProject, listWorkspaceCollaborationsForUser, removeWorkspaceCollaborationMember, removeWorkspaceCollaborationTeamShare, setWorkspaceCollaborationTeamShare, workspaceCollaborationAccess } from "./workspace-collaboration.mjs";
35
35
  import { WorkspaceFlowParseError } from "./workspace-flow-store.mjs";
36
36
  import { mergeWorkspaceGraphs, workspaceDesignRevision, workspaceRuntimeRevision } from "./workspace-graph-merge.mjs";
37
- import { DEFAULT_WORKSPACE_PREVIEW_TTL_MS, createWorkspacePreviewId, normalizeWorkspacePreviewTtlMs, readWorkspacePreviewMetadata, workspacePreviewFlowDir, writeWorkspacePreviewMetadata } from "./workspace-preview.mjs";
37
+ import { DEFAULT_WORKSPACE_PREVIEW_TTL_MS, createWorkspacePreviewId, normalizeWorkspacePreviewTtlMs, readWorkspacePreviewMetadata, workspaceSharedPreviewFlowDir, writeWorkspacePreviewMetadata } from "./workspace-preview.mjs";
38
38
  import { appendWorkspaceRunLogEvent, createWorkspaceRunLogSession, finishWorkspaceRunLogSession, listWorkspaceRunLogs, readWorkspaceRunLogEvents } from "./workspace-run-logs.mjs";
39
39
  import { activeWorkspaceRuns, appendWorkspaceRunFinished, appendWorkspaceRunStarted, hydrateWorkspaceGraphForRuntime, isReadonlyBuiltinFlowSource, isTransientAgentNetworkError, isValidFlowSourceRead, isWorkspaceRunAbortError, listWorkspaceScheduleStatusesForFlow, mergeWorkspacePersistentNodeRefs, mergeWorkspaceRunGraph, normalizeWorkspaceEntry, readWorkspaceConversations, readWorkspaceFiles, readWorkspaceGraph, resolveWorkspaceFilePath, resolveWorkspaceScopeRoot, runWorkspaceGraph, sleepMs, syncWorkspaceSchedulesForGraph, workspaceActiveRunsForScope, workspaceCollaborationEventKey, workspaceCollaborationSequences, workspaceCollaborationSubscribers, workspaceCollaborationSummaryWithUsers, workspaceDesignPath, workspaceDownloadContentDisposition, workspaceFindActiveRunConflict, workspaceGraphAsSource, workspaceOptimizeRunImplementations, workspaceRepoUrlWithCredential, workspaceRunControl, workspaceRunEntryKey, workspaceRunKey, workspaceRunPlan, workspaceRunPlanNodeIds, workspaceRunTouchedNodeIds, workspaceRuntimeNodeLabel, workspaceScopedUserContext, workspaceSearchGuardrailsBlock, workspaceUnwrapOutputEnvelopeForDisplay, workspacesPath, writeWorkspaceConversations, writeWorkspaceGraph } from "./workspace-server.mjs";
40
40
  import { getWorkspaceTree } from "./workspace-tree.mjs";
@@ -1328,7 +1328,7 @@ async function workspaceRoutes(req, res, ctx) {
1328
1328
  }
1329
1329
  const rawRequestedId = String(payload.previewId || "").trim();
1330
1330
  const flowId = rawRequestedId || createWorkspacePreviewId();
1331
- const flowDir = workspacePreviewFlowDir(flowId, authUser.userId);
1331
+ const flowDir = workspaceSharedPreviewFlowDir(root, flowId);
1332
1332
  if (!flowDir) {
1333
1333
  json(res, 400, { error: "Invalid previewId" });
1334
1334
  return;
@@ -1367,8 +1367,8 @@ async function workspaceRoutes(req, res, ctx) {
1367
1367
  return;
1368
1368
  }
1369
1369
  const baseUrl = `${url.protocol}//${url.host}`;
1370
- const workspaceUrl = `${baseUrl}/workspace?flowId=${encodeURIComponent(flowId)}&flowSource=user`;
1371
- json(res, 200, { ok: true, flowId, flowSource: "user", preview: true, expiresAt: metadata.expiresAt, url: workspaceUrl });
1370
+ const workspaceUrl = `${baseUrl}/workspace?flowId=${encodeURIComponent(flowId)}&flowSource=workspace&archived=1`;
1371
+ json(res, 200, { ok: true, flowId, flowSource: "workspace", archived: true, preview: true, expiresAt: metadata.expiresAt, url: workspaceUrl });
1372
1372
  return;
1373
1373
  }
1374
1374
 
@@ -1,4 +1,4 @@
1
- var Lo=Object.defineProperty;var Vo=(t,e,s)=>e in t?Lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var m=(t,e,s)=>Vo(t,typeof e!="symbol"?e+"":e,s);import{R as J,r as M,j as p,g as Uo,a as qo,b as Ho,M as zo}from"./index-BZ5KqLur.js";function Gt(){return Gt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},Gt.apply(null,arguments)}let je=null;function Go(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const s=je;je=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{je=s}}function Se(){if(!je)throw new Error("No resource fiber available");return je}function Ve(){return je}const ls=Symbol("tap.Context.defaultValue"),Ko=t=>t;let ge=new Map;const Ie=new Set,Jr=()=>new Map(ge),Ks=(t,e)=>{const s=ge;ge=t;try{return e()}finally{ge=s}},Xr=(t,e)=>{t[ls]=e},Zr=t=>typeof t=="object"&&t!==null&&ls in t,en=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),us=t=>Zr(t)||en(t),tn=t=>{if(!Zr(t)){if(en(t)){Xr(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},sn=(t,e,s)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");tn(t);const r=t,n=Se(),i=V(void 0),o=i.current===void 0||!Object.is(i.current.value,e);N(()=>{i.current={value:e}},[e]);const a=ge.get(r),c=a!==void 0||ge.has(r);ge.set(r,{value:e,source:n});try{return Wo(r,o,s)}finally{c?ge.set(r,a):ge.delete(r)}},Wo=(t,e,s)=>{const r=Ie.has(t);e?Ie.add(t):Ie.delete(t);try{return s()}finally{r?Ie.add(t):Ie.delete(t)}},Qo=t=>{tn(t);const e=t,s=Yo(e,t),r=Se();return(r.wipContextDeps??(r.wipContextDeps=new Map)).set(e,s.source),s.value},Yo=(t,e)=>ge.get(t)??{value:Ko(e)[ls],source:null},Jo=(t,e,s,r)=>{if(!r)return s;let n=s;for(const[i,o]of r)o===e||o===t||(n??(n=new Map)).set(i,o);return n},rn=(t,e=t.wipContextDeps)=>{const s=Ve();!s||!e||(s.wipContextDeps=Jo(s,t,s.wipContextDeps,e))},nn=()=>Ie.size>0,ds=t=>{if(!t.contextDeps||!nn())return!1;for(const e of Ie.keys())if(t.contextDeps.has(e))return!0;return!1},hs=(t,e)=>{if(t.length!==0){if(t.length===1)throw t[0];for(const s of t)console.error(s);throw new AggregateError(t,e)}},ye={HookState:0,EffectEvent:1,PassiveEffectCleanup:2,PassiveEffectSetup:3},Xo=[ye.HookState,ye.EffectEvent,ye.PassiveEffectCleanup,ye.PassiveEffectSetup];function Zo(t){const e=[];for(const s of Xo){const r=t[s];if(r!==void 0)for(let n=0;n<r.length;n++)try{r[n]()}catch(i){e.push(i)}}hs(e,"Errors during commit")}function ea(t){var s;const e=[];for(const r of t.cells)if((r==null?void 0:r.type)==="effect"&&(r.deps=null,r.cleanup))try{(s=r.cleanup)==null||s.call(r)}catch(n){e.push(n)}finally{r.cleanup=void 0}hs(e,"Errors during cleanup")}const on=t=>({version:0,committedVersion:0,context:Jr(),dispatchUpdate:t,changelog:[],rollbackCallbacks:[]}),gt=t=>{t.committedVersion=t.version,t.changelog.length=0,t.rollbackCallbacks.length=0},We=(t,e)=>{const s=t.version>e;if(t.version=e,s){for(let r=0;r<t.rollbackCallbacks.length;r++)t.rollbackCallbacks[r]();if(t.rollbackCallbacks.length=0,e<=t.committedVersion)t.committedVersion=e,t.changelog.length=0;else{for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop();for(let r=0;r<t.changelog.length;r++)an(t.changelog[r]);gt(t)}}},an=t=>{var e;ln(t.fiber,t.cell),t.queued||(t.queued=!0,((e=t.cell).queue??(e.queue=[])).push(t))},Xe=(t,e,s)=>{const r=t.wipCommitCallbacks;(r[e]??(r[e]=[])).push(s)},cn=(t,e)=>{t.rollbackCallbacks.push(e)},ln=(t,e)=>{var s;e.isDirty||(e.isDirty=!0,(s=t.markDirty)==null||s.call(t),cn(t.root,()=>{if(e.queue!==null){for(const r of e.queue)r.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},fs=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},ps=()=>{throw new Error("Hook order changed between renders")},ta=(t,e,s)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let r=!1,n=!0;t.root.dispatchUpdate(()=>(r||(r=!0,s&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.eagerState=s(e.cell.workInProgress,e.action),e.hasEagerState=!0,n=!Object.is(e.cell.current,e.eagerState))),n),()=>(r=!0,n=!0,an(e),t.root.changelog.push(e),!0))},sa=(t,e,s,r,n)=>{const i=r?r(s):s,o={type:"reducer",workInProgress:i,current:i,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:a=>{const c=Ve();if(c!==null){if(c!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??(t.renderPendingCells=new Set)).add(o),(o.renderQueue??(o.renderQueue=[])).push(a)}else ta(t,{fiber:t,cell:o,action:a,hasEagerState:!1,eagerState:void 0,queued:!1},n?e:void 0)}};return o};function un(t,e,s,r){var l;const n=Se(),i=n.currentIndex++,o=n.cells[i],a=(()=>{if(o!==void 0)return o.type==="reducer"?o:ps();!n.isFirstRender&&i>=n.cells.length&&fs();const u=sa(n,t,e,s,r);return n.cells[i]=u,u})(),c=a.queue;if(c!==null){const u=t===a.reducer;for(let h=0;h<c.length;h++){const d=c[h];(!d.hasEagerState||!u)&&(d.eagerState=t(a.workInProgress,d.action),d.hasEagerState=!0),d.queued=!1,a.workInProgress=d.eagerState}a.queue=null}if(a.reducer=t,a.renderQueue!==null){let u=a.workInProgress;for(const h of a.renderQueue)u=t(u,h);a.renderQueue=null,(l=n.renderPendingCells)==null||l.delete(a),Object.is(u,a.workInProgress)||(ln(n,a),a.workInProgress=u)}return a.isDirty&&Xe(n,ye.HookState,()=>{a.current=a.workInProgress,a.isDirty=!1}),[a.workInProgress,a.dispatch]}function dn(t,e,s){return un(t,e,s,!1)}const ra=(t,e)=>typeof e=="function"?e(t):e,na=t=>t===void 0?void 0:typeof t=="function"?t():t;function gs(t){return un(ra,t,na,!0)}const Et=(t,e)=>{for(let s=0;s<t.length&&s<e.length;s++)if(!Object.is(t[s],e[s]))return!1;return!0},Ws=(t,e)=>{Xe(t,ye.HookState,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.isDirty=!1})},Rt=(t,e)=>{const s=Se(),r=s.currentIndex++;let n=s.cells[r];if(n===void 0){!s.isFirstRender&&r>=s.cells.length&&fs();const a=t();return n={type:"memo",current:a,currentDeps:e,wip:a,wipDeps:e,isDirty:!1},s.cells[r]=n,a}n.type!=="memo"&&ps();const i=n;if(Et(i.wipDeps,e))return i.isDirty&&Ws(s,i),i.wip;const o=t();return i.wip=o,i.wipDeps=e,i.isDirty||(i.isDirty=!0,cn(s.root,()=>{i.wip=i.current,i.wipDeps=i.currentDeps,i.isDirty=!1})),Ws(s,i),o};function At(t){return Rt(()=>({current:t}),[])}const ms=(t,e)=>Rt(()=>t,e),ia=()=>({type:"effect",cleanup:void 0,deps:null});function Be(t,e){const s=Se(),r=s.currentIndex++,n=s.cells[r],i=n===void 0?ia():n.type==="effect"?n:ps();if(n===void 0&&(!s.isFirstRender&&r>=s.cells.length&&fs(),s.cells[r]=i),!(e&&i.deps&&Et(i.deps,e))){if(i.deps!==null&&!!e!=!!i.deps)throw new Error("useEffect called with and without dependencies across re-renders");Xe(s,ye.PassiveEffectCleanup,()=>{var o;try{(o=i.cleanup)==null||o.call(i)}finally{i.cleanup=void 0}}),Xe(s,ye.PassiveEffectSetup,()=>{try{const o=t();if(o!==void 0&&typeof o!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof o}`);i.cleanup=o}finally{i.deps=e}})}}function bs(t){const e=Se(),s=At(t);return s.current!==t&&Xe(e,ye.EffectEvent,()=>{s.current=t}),ms((...r)=>s.current(...r),[])}const mt=t=>{if(!us(t))throw new Error("A tap resource's `use()` only accepts a tap context.");return Qo(t)},hn=(t,e,s=e)=>{const r=At(!0),n=r.current?s():e();r.current=!1;const[,i]=gs(0),o=bs(()=>{try{if(Object.is(n,e()))return}catch{return}i(a=>a+1)});return Be(()=>(o(),t(o)),[t]),n},fn=(t,e)=>{},oa=J;function aa(t){const e=M.useRef(t);return M.useInsertionEffect(()=>{e.current=t}),M.useCallback((...s)=>e.current(...s),[])}const ca=oa.useEffectEvent??aa,ie=()=>Ve()!==null,oe=J,G=t=>ie()?gs(t):oe.useState(t),la=(t,e,s)=>ie()?dn(t,e,s):oe.useReducer(t,e,s),V=t=>ie()?At(t):oe.useRef(t),Y=(t,e)=>ie()?Rt(t,e):oe.useMemo(t,e),Qe=(t,e)=>ie()?ms(t,e):oe.useCallback(t,e),N=(t,e)=>ie()?Be(t,e):oe.useEffect(t,e),bt=(t,e)=>ie()?Be(t,e):oe.useLayoutEffect(t,e),le=t=>ie()?bs(t):ca(t),Ue=(t,e,s)=>ie()?hn(t,e,s):oe.useSyncExternalStore(t,e,s),ua=(t,e)=>ie()?fn():oe.useDebugValue(t,e),ae=t=>{const e=oe.createContext(t);return Xr(e,t),e},pn=t=>ie()&&us(t)?mt(t):oe.use(t),he=t=>ie()&&us(t)?mt(t):oe.useContext(t),gn=Symbol.for("react.memo_cache_sentinel"),mn=t=>new Array(t).fill(gn),da=(t,e)=>{const s=t.memoCache;let r=s.workInProgress;if(r===null){const o=s.current;r=o===null?[]:o.map(a=>a.slice()),s.workInProgress=r}const n=s.index++;let i=r[n];return i===void 0&&(i=mn(e),r[n]=i),i},bn=t=>da(Se(),t),ha=J,fa=t=>M.useMemo(()=>{const e=mn(t);return e[gn]=!0,e},[]);var Yr;const pa=((Yr=ha.__COMPILER_RUNTIME)==null?void 0:Yr.c)??fa,ga=()=>Ve()!==null,_=t=>ga()?bn(t):pa(t);function q(t){return(...e)=>({hook:t,args:e})}function ne(t,e,s){return typeof e=="function"?(...r)=>ne(t,e(...r)):s?{...e,key:t,deps:s}:{...e,key:t}}const ma=50;let me={schedulers:new Set([]),isScheduled:!1},_e=null;var ba=class{constructor(t){m(this,"_isDirty",!1);m(this,"_task");this._task=t}get isDirty(){return this._isDirty}markDirty(){if(_e&&(_e.get(this)??0)>=ma)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.");this._isDirty=!0,me.schedulers.add(this),_a()}runTask(){_e==null||_e.set(this,(_e.get(this)??0)+1),this._isDirty=!1,this._task()}};const _a=()=>{me.isScheduled||(me.isScheduled=!0,ya())},Kt=()=>{const t=_e;_e=new Map;try{const e=[];for(const s of me.schedulers)if(me.schedulers.delete(s),!!s.isDirty)try{s.runTask()}catch(r){e.push(r)}hs(e,"Errors occurred during flushSync")}finally{_e=t,me.schedulers.clear(),me.isScheduled=!1}},ya=(()=>{if(typeof MessageChannel<"u"){let t=null,e;return()=>{var s;if(!t){const r=new MessageChannel;r.port1.onmessage=()=>{var n;(n=t==null?void 0:t.unref)==null||n.call(t),Kt()},t=r.port1,e=r.port2}(s=t.ref)==null||s.call(t),e.postMessage(null)}}return()=>setTimeout(Kt,0)})(),Qs=t=>{const e=me;me={schedulers:new Set([]),isScheduled:!0};try{const s=t();return Kt(),s}finally{me=e}},va={useState:gs,useReducer:dn,useRef:At,useMemo:Rt,useCallback:ms,useEffect:Be,useLayoutEffect:Be,useInsertionEffect:Be,useEffectEvent:bs,useContext:mt,use:mt,useSyncExternalStore:hn,useDebugValue:fn,useMemoCache:bn},Ys=J,Te=Ys.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??Ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nt=Te==null?null:"H"in Te?{get current(){return Te.H},set current(t){Te.H=t}}:"ReactCurrentDispatcher"in Te?{get current(){return Te.ReactCurrentDispatcher.current},set current(t){Te.ReactCurrentDispatcher.current=t}}:null;function Sa(t){if(!nt)return t();const e=nt.current;nt.current=va;try{return t()}finally{nt.current=e}}function _n(t,e,s=void 0,r){return{hook:t,root:e,markDirty:s,devStrictMode:r,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Oe(t){if(!t.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");t.isMounted=!1,ea(t)}function Ee(t,e){var n;if(t.memoCache.workInProgress=null,t.renderPendingCells!==null){for(const i of t.renderPendingCells)i.renderQueue=null;t.renderPendingCells.clear()}let s=0,r;do{if(++s>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,Go(t,()=>{r=Sa(()=>t.hook(...e))})}while((((n=t.renderPendingCells)==null?void 0:n.size)??0)>0);return rn(t),r}function Ze(t){const e=t.wipCommitCallbacks??t.commitCallbacks??[];t.wipCommitCallbacks=null,t.commitCallbacks=e,t.isMounted=!0,t.contextDeps=t.wipContextDeps,gt(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null),t.isNeverMounted=!1,Zo(e)}const xa=()=>{const t=Se();return t.devStrictMode?t.isFirstRender?"child":"root":null},wa=()=>null,Ta=()=>wa,yn=()=>Ve()?xa:Ta(),Ca=t=>t(),Ia=t=>{const[e]=G(()=>new ba(()=>f())),[s]=G(()=>[]),r=yn(),[n]=G(()=>{const g=on((b,v)=>{if(!e.isDirty){if(!b())return;v()}We(g,g.committedVersion+g.changelog.length),s.push(v),e.markDirty()});return _n(Ca,g,void 0,r())}),i=Jr(),o=n.root.version-n.root.committedVersion,a=Ks(i,()=>Ee(n,[t])),c=V(!1),l=V([t]),u=V(a),[h]=G(()=>new Set),d=g=>{e.isDirty||u.current===g||(u.current=g,h.forEach(b=>b()))},f=le(()=>{We(n.root,n.root.committedVersion),s.forEach(b=>{b()}),We(n.root,n.root.committedVersion+n.root.changelog.length);const g=Ks(n.root.context,()=>Ee(n,l.current));if(e.isDirty)throw new Error("Scheduler is dirty, this should never happen");gt(n.root),s.length=0,c.current&&Ze(n),d(g)});return N(()=>(c.current=!0,()=>{c.current=!1,Oe(n)}),[n]),N(()=>{l.current=[t],gt(n.root),s.splice(0,o),n.root.context=i,Ze(n),d(a)}),Y(()=>({getValue:()=>u.current,subscribe:g=>(h.add(g),()=>h.delete(g))}),[h])},Ea=()=>{const t=V(0),e=t.current,s=Se();return{version:e,markDirty:Y(()=>()=>{var r;t.current++,(r=s==null?void 0:s.markDirty)==null||r.call(s)},[s]),root:s.root}},Ra=()=>{const[t]=G(()=>on((n,i)=>{let o=!1;r(a=>(o=!n(),o?a:a+1)),o||s(i)})),[e,s]=la((n,i)=>(We(t,n),n+(i()?1:0)),0),[,r]=G(0);return We(t,e),{root:t,version:e,markDirty:void 0}},_s=()=>{const t=yn(),{root:e,version:s,markDirty:r}=Ve()?Ea():Ra();return{version:s,createFiber:Qe((n,i,o)=>_n(n,e,o?()=>{o(),r==null||r()}:r,t()),[])}},vn=(t,e,s)=>{const r=V(null),n=r.current??(r.current={wipDeps:null,wip:null,currentDeps:null,current:null});return n.wipDeps=n.currentDeps,n.wip=n.current,N(()=>{n.currentDeps=n.wipDeps,n.current=n.wip}),!s&&n.currentDeps&&Et(n.currentDeps,e)?n.current:(n.wipDeps=e,n.wip=t(),n.wip)};function se(t){const{version:e,createFiber:s}=_s(),r=Y(()=>s(t.hook,t.key),[t.hook,t.key,s]),n=vn(()=>({value:Ee(r,t.args)}),[r,e,t.args],ds(r));return N(()=>()=>Oe(r),[r]),N(()=>{Ze(r)},[r,n]),n.value}const Js=(t,e)=>{const s=t.get(e);s&&(s.isDirty=!0)},Aa=(t,e)=>!t.isDirty&&!ds(t.fiber)&&e!==void 0&&t.committedDeps!==void 0&&Et(t.committedDeps,e),Ma=t=>{if(!nn())return!1;for(const{fiber:e}of t.values())if(ds(e))return!0;return!1};function Mt(t){const[e]=G(()=>new Map),{version:s,createFiber:r}=_s(),n=Ma(e),i=vn(()=>{const o=new Set,a=[];let c=0;for(let l=0;l<t.length;l++){const u=t[l],h=u.key;if(h===void 0)throw new Error(`useResources did not provide a key for array at index ${l}`);if(o.has(h))throw new Error(`Duplicate key ${h} in useResources`);o.add(h);let d=e.get(h);if(d)if(d.fiber.hook!==u.hook){const f=r(u.hook,u.key,()=>Js(e,h)),g=Ee(f,u.args);d.next={value:g,deps:u.deps,remount:f}}else if(Aa(d,u.deps))d.fiber.contextDeps&&rn(d.fiber,d.fiber.contextDeps),d.next="skip";else{const f=Ee(d.fiber,u.args);d.next={value:f,deps:u.deps}}else{const f=r(u.hook,u.key,()=>Js(e,h));d={fiber:f,next:{value:Ee(f,u.args),deps:u.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},c++,e.set(h,d)}a.push(typeof d.next=="object"?d.next.value:d.committedValue)}if(e.size>a.length-c)for(const l of e.keys())o.has(l)||(e.get(l).next="delete");return a},[t,e,r,s],n);return N(()=>()=>{for(const o of e.keys()){const a=e.get(o).fiber;Oe(a)}},[e]),N(()=>{for(const[o,a]of e.entries()){const c=a.next;c==="delete"?(a.fiber.isMounted&&Oe(a.fiber),e.delete(o)):c==="skip"||(c.remount&&(Oe(a.fiber),a.fiber=c.remount),Ze(a.fiber),a.committedDeps=c.deps,a.committedValue=c.value,a.isDirty=!1)}},[i,e]),i}const Pa=t=>t(),ka=t=>{const{createFiber:e}=_s(),s=Y(()=>e(Pa,void 0),[e]),r=Ee(s,[t]);N(()=>()=>{Oe(s)},[s]);let n=!1;const i=()=>{n&&s.isMounted||(n=!0,Ze(s))};return N(i),{value:r,effects:i}},$a=()=>{const t=_(4),[e,s]=G(ja);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=(c,l)=>(s(u=>({...u,renderers:{...u.renderers,[c]:[...u.renderers[c]??[],l]}})),()=>{s(u=>{var h;return{...u,renderers:{...u.renderers,[c]:((h=u.renderers[c])==null?void 0:h.filter(d=>d!==l))??[]}}})}),t[0]=r):r=t[0];const n=r;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=c=>(s(l=>({...l,fallbacks:[...l.fallbacks,c]})),()=>{s(l=>({...l,fallbacks:l.fallbacks.filter(u=>u!==c)}))}),t[1]=i):i=t[1];const o=i;let a;return t[2]!==e?(a={getState:()=>e,setDataUI:n,setFallbackDataUI:o},t[2]=e,t[3]=a):a=t[3],a},Da=q($a);function ja(){return{renderers:{},fallbacks:[]}}const Ba=t=>{const e=Array.from(t).map(r=>r.getModelContext()).sort((r,n)=>(n.priority??0)-(r.priority??0)),s={};return e.reduce((r,n)=>{var o;const i=n.priority??0;if(n.system&&(r.system?r.system+=`
1
+ var Lo=Object.defineProperty;var Vo=(t,e,s)=>e in t?Lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var m=(t,e,s)=>Vo(t,typeof e!="symbol"?e+"":e,s);import{R as J,r as M,j as p,g as Uo,a as qo,b as Ho,M as zo}from"./index-BJzMYRK3.js";function Gt(){return Gt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},Gt.apply(null,arguments)}let je=null;function Go(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const s=je;je=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{je=s}}function Se(){if(!je)throw new Error("No resource fiber available");return je}function Ve(){return je}const ls=Symbol("tap.Context.defaultValue"),Ko=t=>t;let ge=new Map;const Ie=new Set,Jr=()=>new Map(ge),Ks=(t,e)=>{const s=ge;ge=t;try{return e()}finally{ge=s}},Xr=(t,e)=>{t[ls]=e},Zr=t=>typeof t=="object"&&t!==null&&ls in t,en=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),us=t=>Zr(t)||en(t),tn=t=>{if(!Zr(t)){if(en(t)){Xr(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},sn=(t,e,s)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");tn(t);const r=t,n=Se(),i=V(void 0),o=i.current===void 0||!Object.is(i.current.value,e);N(()=>{i.current={value:e}},[e]);const a=ge.get(r),c=a!==void 0||ge.has(r);ge.set(r,{value:e,source:n});try{return Wo(r,o,s)}finally{c?ge.set(r,a):ge.delete(r)}},Wo=(t,e,s)=>{const r=Ie.has(t);e?Ie.add(t):Ie.delete(t);try{return s()}finally{r?Ie.add(t):Ie.delete(t)}},Qo=t=>{tn(t);const e=t,s=Yo(e,t),r=Se();return(r.wipContextDeps??(r.wipContextDeps=new Map)).set(e,s.source),s.value},Yo=(t,e)=>ge.get(t)??{value:Ko(e)[ls],source:null},Jo=(t,e,s,r)=>{if(!r)return s;let n=s;for(const[i,o]of r)o===e||o===t||(n??(n=new Map)).set(i,o);return n},rn=(t,e=t.wipContextDeps)=>{const s=Ve();!s||!e||(s.wipContextDeps=Jo(s,t,s.wipContextDeps,e))},nn=()=>Ie.size>0,ds=t=>{if(!t.contextDeps||!nn())return!1;for(const e of Ie.keys())if(t.contextDeps.has(e))return!0;return!1},hs=(t,e)=>{if(t.length!==0){if(t.length===1)throw t[0];for(const s of t)console.error(s);throw new AggregateError(t,e)}},ye={HookState:0,EffectEvent:1,PassiveEffectCleanup:2,PassiveEffectSetup:3},Xo=[ye.HookState,ye.EffectEvent,ye.PassiveEffectCleanup,ye.PassiveEffectSetup];function Zo(t){const e=[];for(const s of Xo){const r=t[s];if(r!==void 0)for(let n=0;n<r.length;n++)try{r[n]()}catch(i){e.push(i)}}hs(e,"Errors during commit")}function ea(t){var s;const e=[];for(const r of t.cells)if((r==null?void 0:r.type)==="effect"&&(r.deps=null,r.cleanup))try{(s=r.cleanup)==null||s.call(r)}catch(n){e.push(n)}finally{r.cleanup=void 0}hs(e,"Errors during cleanup")}const on=t=>({version:0,committedVersion:0,context:Jr(),dispatchUpdate:t,changelog:[],rollbackCallbacks:[]}),gt=t=>{t.committedVersion=t.version,t.changelog.length=0,t.rollbackCallbacks.length=0},We=(t,e)=>{const s=t.version>e;if(t.version=e,s){for(let r=0;r<t.rollbackCallbacks.length;r++)t.rollbackCallbacks[r]();if(t.rollbackCallbacks.length=0,e<=t.committedVersion)t.committedVersion=e,t.changelog.length=0;else{for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop();for(let r=0;r<t.changelog.length;r++)an(t.changelog[r]);gt(t)}}},an=t=>{var e;ln(t.fiber,t.cell),t.queued||(t.queued=!0,((e=t.cell).queue??(e.queue=[])).push(t))},Xe=(t,e,s)=>{const r=t.wipCommitCallbacks;(r[e]??(r[e]=[])).push(s)},cn=(t,e)=>{t.rollbackCallbacks.push(e)},ln=(t,e)=>{var s;e.isDirty||(e.isDirty=!0,(s=t.markDirty)==null||s.call(t),cn(t.root,()=>{if(e.queue!==null){for(const r of e.queue)r.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},fs=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},ps=()=>{throw new Error("Hook order changed between renders")},ta=(t,e,s)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let r=!1,n=!0;t.root.dispatchUpdate(()=>(r||(r=!0,s&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.eagerState=s(e.cell.workInProgress,e.action),e.hasEagerState=!0,n=!Object.is(e.cell.current,e.eagerState))),n),()=>(r=!0,n=!0,an(e),t.root.changelog.push(e),!0))},sa=(t,e,s,r,n)=>{const i=r?r(s):s,o={type:"reducer",workInProgress:i,current:i,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:a=>{const c=Ve();if(c!==null){if(c!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??(t.renderPendingCells=new Set)).add(o),(o.renderQueue??(o.renderQueue=[])).push(a)}else ta(t,{fiber:t,cell:o,action:a,hasEagerState:!1,eagerState:void 0,queued:!1},n?e:void 0)}};return o};function un(t,e,s,r){var l;const n=Se(),i=n.currentIndex++,o=n.cells[i],a=(()=>{if(o!==void 0)return o.type==="reducer"?o:ps();!n.isFirstRender&&i>=n.cells.length&&fs();const u=sa(n,t,e,s,r);return n.cells[i]=u,u})(),c=a.queue;if(c!==null){const u=t===a.reducer;for(let h=0;h<c.length;h++){const d=c[h];(!d.hasEagerState||!u)&&(d.eagerState=t(a.workInProgress,d.action),d.hasEagerState=!0),d.queued=!1,a.workInProgress=d.eagerState}a.queue=null}if(a.reducer=t,a.renderQueue!==null){let u=a.workInProgress;for(const h of a.renderQueue)u=t(u,h);a.renderQueue=null,(l=n.renderPendingCells)==null||l.delete(a),Object.is(u,a.workInProgress)||(ln(n,a),a.workInProgress=u)}return a.isDirty&&Xe(n,ye.HookState,()=>{a.current=a.workInProgress,a.isDirty=!1}),[a.workInProgress,a.dispatch]}function dn(t,e,s){return un(t,e,s,!1)}const ra=(t,e)=>typeof e=="function"?e(t):e,na=t=>t===void 0?void 0:typeof t=="function"?t():t;function gs(t){return un(ra,t,na,!0)}const Et=(t,e)=>{for(let s=0;s<t.length&&s<e.length;s++)if(!Object.is(t[s],e[s]))return!1;return!0},Ws=(t,e)=>{Xe(t,ye.HookState,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.isDirty=!1})},Rt=(t,e)=>{const s=Se(),r=s.currentIndex++;let n=s.cells[r];if(n===void 0){!s.isFirstRender&&r>=s.cells.length&&fs();const a=t();return n={type:"memo",current:a,currentDeps:e,wip:a,wipDeps:e,isDirty:!1},s.cells[r]=n,a}n.type!=="memo"&&ps();const i=n;if(Et(i.wipDeps,e))return i.isDirty&&Ws(s,i),i.wip;const o=t();return i.wip=o,i.wipDeps=e,i.isDirty||(i.isDirty=!0,cn(s.root,()=>{i.wip=i.current,i.wipDeps=i.currentDeps,i.isDirty=!1})),Ws(s,i),o};function At(t){return Rt(()=>({current:t}),[])}const ms=(t,e)=>Rt(()=>t,e),ia=()=>({type:"effect",cleanup:void 0,deps:null});function Be(t,e){const s=Se(),r=s.currentIndex++,n=s.cells[r],i=n===void 0?ia():n.type==="effect"?n:ps();if(n===void 0&&(!s.isFirstRender&&r>=s.cells.length&&fs(),s.cells[r]=i),!(e&&i.deps&&Et(i.deps,e))){if(i.deps!==null&&!!e!=!!i.deps)throw new Error("useEffect called with and without dependencies across re-renders");Xe(s,ye.PassiveEffectCleanup,()=>{var o;try{(o=i.cleanup)==null||o.call(i)}finally{i.cleanup=void 0}}),Xe(s,ye.PassiveEffectSetup,()=>{try{const o=t();if(o!==void 0&&typeof o!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof o}`);i.cleanup=o}finally{i.deps=e}})}}function bs(t){const e=Se(),s=At(t);return s.current!==t&&Xe(e,ye.EffectEvent,()=>{s.current=t}),ms((...r)=>s.current(...r),[])}const mt=t=>{if(!us(t))throw new Error("A tap resource's `use()` only accepts a tap context.");return Qo(t)},hn=(t,e,s=e)=>{const r=At(!0),n=r.current?s():e();r.current=!1;const[,i]=gs(0),o=bs(()=>{try{if(Object.is(n,e()))return}catch{return}i(a=>a+1)});return Be(()=>(o(),t(o)),[t]),n},fn=(t,e)=>{},oa=J;function aa(t){const e=M.useRef(t);return M.useInsertionEffect(()=>{e.current=t}),M.useCallback((...s)=>e.current(...s),[])}const ca=oa.useEffectEvent??aa,ie=()=>Ve()!==null,oe=J,G=t=>ie()?gs(t):oe.useState(t),la=(t,e,s)=>ie()?dn(t,e,s):oe.useReducer(t,e,s),V=t=>ie()?At(t):oe.useRef(t),Y=(t,e)=>ie()?Rt(t,e):oe.useMemo(t,e),Qe=(t,e)=>ie()?ms(t,e):oe.useCallback(t,e),N=(t,e)=>ie()?Be(t,e):oe.useEffect(t,e),bt=(t,e)=>ie()?Be(t,e):oe.useLayoutEffect(t,e),le=t=>ie()?bs(t):ca(t),Ue=(t,e,s)=>ie()?hn(t,e,s):oe.useSyncExternalStore(t,e,s),ua=(t,e)=>ie()?fn():oe.useDebugValue(t,e),ae=t=>{const e=oe.createContext(t);return Xr(e,t),e},pn=t=>ie()&&us(t)?mt(t):oe.use(t),he=t=>ie()&&us(t)?mt(t):oe.useContext(t),gn=Symbol.for("react.memo_cache_sentinel"),mn=t=>new Array(t).fill(gn),da=(t,e)=>{const s=t.memoCache;let r=s.workInProgress;if(r===null){const o=s.current;r=o===null?[]:o.map(a=>a.slice()),s.workInProgress=r}const n=s.index++;let i=r[n];return i===void 0&&(i=mn(e),r[n]=i),i},bn=t=>da(Se(),t),ha=J,fa=t=>M.useMemo(()=>{const e=mn(t);return e[gn]=!0,e},[]);var Yr;const pa=((Yr=ha.__COMPILER_RUNTIME)==null?void 0:Yr.c)??fa,ga=()=>Ve()!==null,_=t=>ga()?bn(t):pa(t);function q(t){return(...e)=>({hook:t,args:e})}function ne(t,e,s){return typeof e=="function"?(...r)=>ne(t,e(...r)):s?{...e,key:t,deps:s}:{...e,key:t}}const ma=50;let me={schedulers:new Set([]),isScheduled:!1},_e=null;var ba=class{constructor(t){m(this,"_isDirty",!1);m(this,"_task");this._task=t}get isDirty(){return this._isDirty}markDirty(){if(_e&&(_e.get(this)??0)>=ma)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.");this._isDirty=!0,me.schedulers.add(this),_a()}runTask(){_e==null||_e.set(this,(_e.get(this)??0)+1),this._isDirty=!1,this._task()}};const _a=()=>{me.isScheduled||(me.isScheduled=!0,ya())},Kt=()=>{const t=_e;_e=new Map;try{const e=[];for(const s of me.schedulers)if(me.schedulers.delete(s),!!s.isDirty)try{s.runTask()}catch(r){e.push(r)}hs(e,"Errors occurred during flushSync")}finally{_e=t,me.schedulers.clear(),me.isScheduled=!1}},ya=(()=>{if(typeof MessageChannel<"u"){let t=null,e;return()=>{var s;if(!t){const r=new MessageChannel;r.port1.onmessage=()=>{var n;(n=t==null?void 0:t.unref)==null||n.call(t),Kt()},t=r.port1,e=r.port2}(s=t.ref)==null||s.call(t),e.postMessage(null)}}return()=>setTimeout(Kt,0)})(),Qs=t=>{const e=me;me={schedulers:new Set([]),isScheduled:!0};try{const s=t();return Kt(),s}finally{me=e}},va={useState:gs,useReducer:dn,useRef:At,useMemo:Rt,useCallback:ms,useEffect:Be,useLayoutEffect:Be,useInsertionEffect:Be,useEffectEvent:bs,useContext:mt,use:mt,useSyncExternalStore:hn,useDebugValue:fn,useMemoCache:bn},Ys=J,Te=Ys.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??Ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nt=Te==null?null:"H"in Te?{get current(){return Te.H},set current(t){Te.H=t}}:"ReactCurrentDispatcher"in Te?{get current(){return Te.ReactCurrentDispatcher.current},set current(t){Te.ReactCurrentDispatcher.current=t}}:null;function Sa(t){if(!nt)return t();const e=nt.current;nt.current=va;try{return t()}finally{nt.current=e}}function _n(t,e,s=void 0,r){return{hook:t,root:e,markDirty:s,devStrictMode:r,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Oe(t){if(!t.isMounted)throw new Error("Tried to unmount a fiber that is already unmounted");t.isMounted=!1,ea(t)}function Ee(t,e){var n;if(t.memoCache.workInProgress=null,t.renderPendingCells!==null){for(const i of t.renderPendingCells)i.renderQueue=null;t.renderPendingCells.clear()}let s=0,r;do{if(++s>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,Go(t,()=>{r=Sa(()=>t.hook(...e))})}while((((n=t.renderPendingCells)==null?void 0:n.size)??0)>0);return rn(t),r}function Ze(t){const e=t.wipCommitCallbacks??t.commitCallbacks??[];t.wipCommitCallbacks=null,t.commitCallbacks=e,t.isMounted=!0,t.contextDeps=t.wipContextDeps,gt(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null),t.isNeverMounted=!1,Zo(e)}const xa=()=>{const t=Se();return t.devStrictMode?t.isFirstRender?"child":"root":null},wa=()=>null,Ta=()=>wa,yn=()=>Ve()?xa:Ta(),Ca=t=>t(),Ia=t=>{const[e]=G(()=>new ba(()=>f())),[s]=G(()=>[]),r=yn(),[n]=G(()=>{const g=on((b,v)=>{if(!e.isDirty){if(!b())return;v()}We(g,g.committedVersion+g.changelog.length),s.push(v),e.markDirty()});return _n(Ca,g,void 0,r())}),i=Jr(),o=n.root.version-n.root.committedVersion,a=Ks(i,()=>Ee(n,[t])),c=V(!1),l=V([t]),u=V(a),[h]=G(()=>new Set),d=g=>{e.isDirty||u.current===g||(u.current=g,h.forEach(b=>b()))},f=le(()=>{We(n.root,n.root.committedVersion),s.forEach(b=>{b()}),We(n.root,n.root.committedVersion+n.root.changelog.length);const g=Ks(n.root.context,()=>Ee(n,l.current));if(e.isDirty)throw new Error("Scheduler is dirty, this should never happen");gt(n.root),s.length=0,c.current&&Ze(n),d(g)});return N(()=>(c.current=!0,()=>{c.current=!1,Oe(n)}),[n]),N(()=>{l.current=[t],gt(n.root),s.splice(0,o),n.root.context=i,Ze(n),d(a)}),Y(()=>({getValue:()=>u.current,subscribe:g=>(h.add(g),()=>h.delete(g))}),[h])},Ea=()=>{const t=V(0),e=t.current,s=Se();return{version:e,markDirty:Y(()=>()=>{var r;t.current++,(r=s==null?void 0:s.markDirty)==null||r.call(s)},[s]),root:s.root}},Ra=()=>{const[t]=G(()=>on((n,i)=>{let o=!1;r(a=>(o=!n(),o?a:a+1)),o||s(i)})),[e,s]=la((n,i)=>(We(t,n),n+(i()?1:0)),0),[,r]=G(0);return We(t,e),{root:t,version:e,markDirty:void 0}},_s=()=>{const t=yn(),{root:e,version:s,markDirty:r}=Ve()?Ea():Ra();return{version:s,createFiber:Qe((n,i,o)=>_n(n,e,o?()=>{o(),r==null||r()}:r,t()),[])}},vn=(t,e,s)=>{const r=V(null),n=r.current??(r.current={wipDeps:null,wip:null,currentDeps:null,current:null});return n.wipDeps=n.currentDeps,n.wip=n.current,N(()=>{n.currentDeps=n.wipDeps,n.current=n.wip}),!s&&n.currentDeps&&Et(n.currentDeps,e)?n.current:(n.wipDeps=e,n.wip=t(),n.wip)};function se(t){const{version:e,createFiber:s}=_s(),r=Y(()=>s(t.hook,t.key),[t.hook,t.key,s]),n=vn(()=>({value:Ee(r,t.args)}),[r,e,t.args],ds(r));return N(()=>()=>Oe(r),[r]),N(()=>{Ze(r)},[r,n]),n.value}const Js=(t,e)=>{const s=t.get(e);s&&(s.isDirty=!0)},Aa=(t,e)=>!t.isDirty&&!ds(t.fiber)&&e!==void 0&&t.committedDeps!==void 0&&Et(t.committedDeps,e),Ma=t=>{if(!nn())return!1;for(const{fiber:e}of t.values())if(ds(e))return!0;return!1};function Mt(t){const[e]=G(()=>new Map),{version:s,createFiber:r}=_s(),n=Ma(e),i=vn(()=>{const o=new Set,a=[];let c=0;for(let l=0;l<t.length;l++){const u=t[l],h=u.key;if(h===void 0)throw new Error(`useResources did not provide a key for array at index ${l}`);if(o.has(h))throw new Error(`Duplicate key ${h} in useResources`);o.add(h);let d=e.get(h);if(d)if(d.fiber.hook!==u.hook){const f=r(u.hook,u.key,()=>Js(e,h)),g=Ee(f,u.args);d.next={value:g,deps:u.deps,remount:f}}else if(Aa(d,u.deps))d.fiber.contextDeps&&rn(d.fiber,d.fiber.contextDeps),d.next="skip";else{const f=Ee(d.fiber,u.args);d.next={value:f,deps:u.deps}}else{const f=r(u.hook,u.key,()=>Js(e,h));d={fiber:f,next:{value:Ee(f,u.args),deps:u.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},c++,e.set(h,d)}a.push(typeof d.next=="object"?d.next.value:d.committedValue)}if(e.size>a.length-c)for(const l of e.keys())o.has(l)||(e.get(l).next="delete");return a},[t,e,r,s],n);return N(()=>()=>{for(const o of e.keys()){const a=e.get(o).fiber;Oe(a)}},[e]),N(()=>{for(const[o,a]of e.entries()){const c=a.next;c==="delete"?(a.fiber.isMounted&&Oe(a.fiber),e.delete(o)):c==="skip"||(c.remount&&(Oe(a.fiber),a.fiber=c.remount),Ze(a.fiber),a.committedDeps=c.deps,a.committedValue=c.value,a.isDirty=!1)}},[i,e]),i}const Pa=t=>t(),ka=t=>{const{createFiber:e}=_s(),s=Y(()=>e(Pa,void 0),[e]),r=Ee(s,[t]);N(()=>()=>{Oe(s)},[s]);let n=!1;const i=()=>{n&&s.isMounted||(n=!0,Ze(s))};return N(i),{value:r,effects:i}},$a=()=>{const t=_(4),[e,s]=G(ja);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=(c,l)=>(s(u=>({...u,renderers:{...u.renderers,[c]:[...u.renderers[c]??[],l]}})),()=>{s(u=>{var h;return{...u,renderers:{...u.renderers,[c]:((h=u.renderers[c])==null?void 0:h.filter(d=>d!==l))??[]}}})}),t[0]=r):r=t[0];const n=r;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=c=>(s(l=>({...l,fallbacks:[...l.fallbacks,c]})),()=>{s(l=>({...l,fallbacks:l.fallbacks.filter(u=>u!==c)}))}),t[1]=i):i=t[1];const o=i;let a;return t[2]!==e?(a={getState:()=>e,setDataUI:n,setFallbackDataUI:o},t[2]=e,t[3]=a):a=t[3],a},Da=q($a);function ja(){return{renderers:{},fallbacks:[]}}const Ba=t=>{const e=Array.from(t).map(r=>r.getModelContext()).sort((r,n)=>(n.priority??0)-(r.priority??0)),s={};return e.reduce((r,n)=>{var o;const i=n.priority??0;if(n.system&&(r.system?r.system+=`
2
2
 
3
3
  ${n.system}`:r.system=n.system),n.tools)for(const[a,c]of Object.entries(n.tools)){const l=(o=r.tools)==null?void 0:o[a];if(l&&l!==c){const u=s[a];if(u===i)throw new Error(`You tried to define a tool with the name ${a}, but it already exists.`);const h=u>i?l:c,d=u>i?c:l;r.tools[a]={...d,...h},s[a]=Math.max(u,i);continue}r.tools||(r.tools={}),r.tools[a]=c,s[a]??(s[a]=i)}return n.config&&(r.config={...r.config,...n.config}),n.callSettings&&(r.callSettings={...r.callSettings,...n.callSettings}),n.unstable_composerMetadata&&(r.unstable_composerMetadata={...r.unstable_composerMetadata,...n.unstable_composerMetadata}),r},{})};var Sn=class{constructor(){m(this,"_providers",new Set);m(this,"_subscribers",new Set)}getModelContext(){return Ba(this._providers)}registerModelContextProvider(t){var s;this._providers.add(t);const e=(s=t.subscribe)==null?void 0:s.call(t,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(t),e==null||e(),this.notifySubscribers()}}notifySubscribers(){for(const t of this._subscribers)t()}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}};const Wt=[],Oa={modelName:void 0,toolNames:Wt},Na=(t,e)=>t===e||t.length===e.length&&t.every((s,r)=>s===e[r]),it=(t,e)=>{var o;const s=t.getModelContext(),r=(o=s.config)==null?void 0:o.modelName,n=s.tools?Object.keys(s.tools).sort():Wt,i=n.length?n:Wt;return r===e.modelName&&Na(i,e.toolNames)?e:{modelName:r,toolNames:i}},Fa=()=>{const t=_(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Sn,t[0]=e):e=t[0];const s=e;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>it(s,Oa),t[1]=r):r=t[1];const[n,i]=G(r);let o,a;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(i(f=>it(s,f)),s.subscribe(()=>{i(f=>it(s,f))})),a=[s],t[2]=o,t[3]=a):(o=t[2],a=t[3]),N(o,a);let c;t[4]!==n?(c=()=>it(s,n),t[4]=n,t[5]=c):c=t[5];let l,u,h;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s.getModelContext(),u=f=>s.subscribe(f),h=f=>s.registerModelContextProvider(f),t[6]=l,t[7]=u,t[8]=h):(l=t[6],u=t[7],h=t[8]);let d;return t[9]!==c?(d={getState:c,getModelContext:l,subscribe:u,register:h},t[9]=c,t[10]=d):d=t[10],d},xn=q(Fa),La=t=>t.display!==void 0?t.display==="standalone":t.type==="human",Va=(t,e)=>{var r,n;if(!(((r=e.status)==null?void 0:r.type)==="running"||((n=e.status)==null?void 0:n.type)==="requires-action")){const i=t.complete;return typeof i!="function"?i??null:i({args:e.args,result:e.result})}const s=t.running;return typeof s!="function"?s??null:s({args:e.args})},Ua=t=>function(s){return Va(t,s)},Qt=Symbol("assistant-ui.store.clientIndex"),qa=t=>t[Qt],wn=ae([]),ys=()=>pn(wn),Ha=(t,e)=>{const s=_(3),r=ys();let n;return s[0]!==t||s[1]!==r?(n=[...r,t],s[0]=t,s[1]=r,s[2]=n):n=s[2],sn(wn,n,e)},za=new Set(["$$typeof","nodeType","then"]),Pt=(t,e)=>{if(t===Symbol.toStringTag)return e;if(typeof t!="symbol"){if(t==="toJSON")return()=>e;if(!za.has(t))return!1}};var vs=class{getOwnPropertyDescriptor(t,e){const s=this.get(t,e);if(s!==void 0)return{value:s,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}};const _t=Symbol("assistant-ui.store.getValue"),Ga=t=>{var s;const e=t[_t];if(!e)throw new Error("Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.");return(s=e.getState)==null?void 0:s.call(e)},Xs=new Map;function Ka(t){let e=Xs.get(t);return e||(e=function(...s){if(!this||typeof this!="object")throw new Error(`Method "${String(t)}" called without proper context. This may indicate the function was called incorrectly.`);const r=this[_t];if(!r)throw new Error(`Method "${String(t)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const n=r[t];if(!n)throw new Error(`Method "${String(t)}" is not implemented.`);if(typeof n!="function")throw new Error(`"${String(t)}" is not a function.`);return n(...s)},Xs.set(t,e)),e}var Wa=class extends vs{constructor(e,s){super();m(this,"boundFns");m(this,"cachedReceiver");m(this,"outputRef");m(this,"index");this.outputRef=e,this.index=s}get(e,s,r){if(s===_t)return this.outputRef.current;if(s===Qt)return this.index;const n=Pt(s,"ClientProxy");if(n!==!1)return n;const i=this.outputRef.current[s];if(typeof i=="function"){this.cachedReceiver!==r&&(this.boundFns=new Map,this.cachedReceiver=r);let o=this.boundFns.get(s);return o||(o=Ka(s).bind(r),this.boundFns.set(s,o)),o}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,s){return s===_t||s===Qt?!0:s in this.outputRef.current}};const tt=t=>{var i;const e=V(null),s=ys().length,r=Y(()=>new Proxy({},new Wa(e,s)),[s]),n=Ha(r,function(){return se(t)});return e.current||(e.current=n),N(()=>{e.current=n}),{methods:r,state:(i=n.getState)==null?void 0:i.call(n),key:t.key}},Qa=q(tt),Ye=Symbol("assistant-ui.store.proxiedAssistantState"),Bt=t=>t==="on"||t==="subscribe"||typeof t=="symbol",Tn=t=>{class e extends vs{get(r,n){const i=Pt(n,"AssistantState");if(i!==!1)return i;const o=n;if(!Bt(o))return Ga(t[o]())}ownKeys(){return Object.keys(t).filter(r=>!Bt(r))}has(r,n){return!Bt(n)&&n in t}}return new Proxy({},new e)},Ya=t=>t[Ye],Zs=()=>()=>{},Cn=t=>{const e=()=>{throw new Error(t)};return e.source=null,e.query=null,e};var Ja=class extends vs{get(t,e){if(e==="subscribe"||e==="on")return Zs;if(e===Ye)return Xa;const s=Pt(e,"DefaultAssistantClient");return s!==!1?s:Cn("You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.")}ownKeys(){return["subscribe","on",Ye]}has(t,e){return e==="subscribe"||e==="on"||e===Ye}};const kt=new Proxy({},new Ja),Xa=Tn(kt),Za=()=>new Proxy({},{get(t,e){const s=Pt(e,"AssistantClient");return s!==!1?s:Cn(`The current scope does not have a "${String(e)}" property.`)}}),In=ae(kt),En=Symbol("assistant-ui.store.useEffects"),ec=()=>{},tc=t=>t[En]??ec,sc=()=>{"use no memo";const t=Rn();return N(tc(t)),null},Rn=()=>he(In),ue=({value:t,children:e})=>{"use no memo";return p.jsxs(In.Provider,{value:t,children:[p.jsx(sc,{}),e]})},Yt=t=>{throw new Error("Derived elements are config-only and must not be mounted")},re=q(Yt),Jt=Symbol("assistant-ui.transform-scopes");function An(t,e){const s=t;if(s[Jt])throw new Error("transformScopes is already attached to this resource");s[Jt]=e}function rc(t){return t[Jt]}const Mn=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},Pn=ae(null),nc=(t,e)=>sn(Pn,t,e),kn=()=>{const t=pn(Pn);if(!t)throw new Error("AssistantTapContext is not available");return t},$n=()=>kn().clientRef,Ss=()=>{const t=_(3),{emit:e}=kn(),s=ys();let r;return t[0]!==s||t[1]!==e?(r=(n,i)=>{e(n,i,s)},t[0]=s,t[1]=e,t[2]=r):r=t[2],le(r)};function ic(t,e){const s={...t},r=new Set;let n=!0;for(;n;){n=!1;for(const a of Object.values(s)){if(a.hook===Yt||r.has(a.hook))continue;r.add(a.hook);const c=rc(a.hook);if(c){c(s,e),n=!0;break}}}const i={},o={};for(const[a,c]of Object.entries(s))c.hook===Yt?o[a]=c:i[a]=c;return{rootClients:i,derivedClients:o}}const er=t=>Y(()=>t,[...Object.entries(t).flat()]),oc=(t,e)=>{const s=_(6);let r;s[0]!==e||s[1]!==t?(r=ic(t,e),s[0]=e,s[1]=t,s[2]=r):r=s[2];const{rootClients:n,derivedClients:i}=r,o=er(n),a=er(i);let c;return s[3]!==o||s[4]!==a?(c={rootClients:o,derivedClients:a},s[3]=o,s[4]=a,s[5]=c):c=s[5],c},ac=()=>{const t=_(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,t[0]=e):e=t[0];const s=e;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[1]=r):r=t[1];const n=r;let i;if(t[2]===Symbol.for("react.memo_cache_sentinel")){const o=new Set;i={on(a,c){const l=c;if(a==="*")return n.add(l),()=>n.delete(l);let u=s.get(a);return u||(u=new Set,s.set(a,u)),u.add(l),()=>{u.delete(l),u.size===0&&s.delete(a)}},emit(a,c,l){const u=s.get(a);!u&&n.size===0||queueMicrotask(()=>{const h=[];if(u)for(const d of u)try{d(c,l)}catch(f){const g=f;h.push(g)}if(n.size>0){const d={event:a,payload:c};for(const f of n)try{f(d,l)}catch(g){const b=g;h.push(b)}}if(h.length>0){if(h.length===1)throw h[0];for(const d of h)console.error(d);throw new AggregateError(h,"Errors occurred during event emission")}})},subscribe(a){return o.add(a),()=>o.delete(a)},notifySubscribers(){for(const a of o)try{a()}catch(c){console.error("NotificationManager: subscriber callback error",c)}}},t[2]=i}else i=t[2];return i},cc=q(ac),Dn=t=>Y(()=>t,t),lc=({element:t,emit:e,clientRef:s})=>{const{methods:r,state:n}=nc({clientRef:s,emit:e},function(){return tt(t)});return Y(()=>({state:n,methods:r}),[r,n])},uc=({element:t,notifications:e,clientRef:s,name:r})=>{const n=Ia(function(){return lc({element:t,emit:e.emit,clientRef:s})});return N(()=>n.subscribe(e.notifySubscribers),[n,e]),Y(()=>{const i=()=>n.getValue().methods;return Object.defineProperties(i,{source:{value:"root",writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),i},[n,r])},dc=q(uc),hc=()=>{const t=_(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s={clients:e,subscribe:void 0,on:void 0},t[1]=s):s=t[1],s},fc=q(hc),pc=t=>{const e=_(14),{clients:s,clientRef:r}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=cc(),e[0]=n):n=e[0];const i=se(n);let o;e[1]!==r.parent||e[2]!==i.notifySubscribers?(o=()=>r.parent.subscribe(i.notifySubscribers),e[1]=r.parent,e[2]=i.notifySubscribers,e[3]=o):o=e[3];let a;e[4]!==r||e[5]!==i?(a=[r,i],e[4]=r,e[5]=i,e[6]=a):a=e[6],N(o,a);let c;e[7]!==r||e[8]!==s||e[9]!==i?(c=Object.keys(s).map(h=>ne(h,dc({element:s[h],notifications:i,clientRef:r,name:h}))),e[7]=r,e[8]=s,e[9]=i,e[10]=c):c=e[10];const l=Dn(Mt(c));let u;return e[11]!==i||e[12]!==l?(u={notifications:i,results:l},e[11]=i,e[12]=l,e[13]=u):u=e[13],u},gc=t=>{const{clientRef:e}=t,{notifications:s,results:r}=pc(t);return Y(()=>({clients:r,subscribe:s.subscribe,on:function(n,i){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:o,event:a}=Mn(n);if(o!=="*"&&this[o].source===null)throw new Error(`Scope "${o}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);const c=s.on(a,(u,h)=>{if(o==="*"){i(u);return}const d=this[o]();d===h[qa(d)]&&i(u)});if(o!=="*"&&e.parent[o].source===null)return c;const l=e.parent.on(n,i);return()=>{c(),l()}}}),[r,s,e])},mc=q(gc),bc=({element:t,clientRef:e,name:s})=>{const r=V(t.args[0]);return r.current=t.args[0],Y(()=>{const n=()=>r.current.get(e.current);return Object.defineProperties(n,{source:{value:r.current.source},query:{value:r.current.query},name:{value:s,configurable:!0}}),n},[e,s])},_c=q(bc),yc=(t,e)=>{let s;try{const r={};for(const n of Object.keys(e.query).sort())r[n]=e.query[n];s=JSON.stringify(r)}catch{s=String(e.query)}return`${t}::${e.source}::${s}`},vc=t=>{const e=_(3),{clients:s,clientRef:r}=t;let n;return e[0]!==r||e[1]!==s?(n=Object.keys(s).map(i=>{const o=i,a=s[o];return ne(yc(o,a.args[0]),_c({element:a,clientRef:r,name:o}))}),e[0]=r,e[1]=s,e[2]=n):n=e[2],Dn(Mt(n))},Sc=t=>{const e=_(3),{rootClients:s,clientRef:r}=t;let n;return e[0]!==r||e[1]!==s?(n=Object.keys(s).length>0?mc({clients:s,clientRef:r}):fc(),e[0]=r,e[1]=s,e[2]=n):n=e[2],se(n)},xc=({parent:t,clients:e})=>{const{rootClients:s,derivedClients:r}=oc(e,t),n=V({parent:t,current:null}).current;N(()=>{n.current=a});const i=Sc({rootClients:s,clientRef:n}),o=vc({clients:r,clientRef:n}),a=Y(()=>{const c=t===kt?Za():t,l=Object.create(c);Object.assign(l,{subscribe:i.subscribe??t.subscribe,on:i.on??t.on,[Ye]:Tn(l)});for(const u of i.clients)l[u.name]=u;for(const u of o)l[u.name]=u;return l},[t,i,o]);return n.current===null&&(n.current=a),a},wc=t=>{const{value:e,effects:s}=ka(function(){return xc(t)});return e[En]=s,e};function F(t,{parent:e}={parent:Rn()}){if(t)return wc({parent:e??kt,clients:t});if(e===null)throw new Error("received null parent, this usage is not allowed");return e}const P=t=>{const e=_(6),s=F();let r;e[0]!==s?(r=Ya(s),e[0]=s,e[1]=r):r=e[1];const n=r;let i,o;e[2]!==n||e[3]!==t?(i=()=>t(n),o=()=>t(n),e[2]=n,e[3]=t,e[4]=i,e[5]=o):(i=e[4],o=e[5]);const a=Ue(s.subscribe,i,o);if(a===n)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return ua(a),a},Tc=t=>{const e=F(),s=V(!1),r=s.current?null:t(e);return P(()=>s.current?t(e):r),()=>(s.current=!0,t(e))},Cc=Object.freeze({});function qe(t){const e=_(3),{getItemState:s,children:r}=t,n=Tc(s);let i;return e[0]!==r||e[1]!==n?(i=r(n),e[0]=r,e[1]=n,e[2]=i):i=e[2],Ic(i)}const Ic=t=>{const e=typeof t=="object"&&t!=null&&"type"in t?t:null,s=e==null?void 0:e.type,r=e==null?void 0:e.key;return Y(()=>e,[s,r,typeof(e==null?void 0:e.props)=="object"&&e.props!=null&&Object.entries(e.props).length===0?Cc:e==null?void 0:e.props])??t},Ec=J.createContext(!0);function tr(){throw new Error("A function wrapped in useEffectEvent can't be called during rendering.")}const Rc="use"in J?()=>{try{return J.use(Ec)}catch{return!1}}:()=>!1;function Ac(t){const e=J.useRef(tr);return J.useInsertionEffect(()=>{e.current=t},[t]),(...s)=>{Rc()&&tr();const r=e.current;return r(...s)}}const yt=(t,e)=>{const s=_(11),r=F(),n=Ac(e);let i;s[0]!==t?(i=Mn(t),s[0]=t,s[1]=i):i=s[1];const{scope:o,event:a}=i;let c;s[2]!==r||s[3]!==n||s[4]!==a||s[5]!==o?(c=()=>r.on({scope:o,event:a},n),s[2]=r,s[3]=n,s[4]=a,s[5]=o,s[6]=c):c=s[6];let l;s[7]!==r||s[8]!==a||s[9]!==o?(l=[r,o,a],s[7]=r,s[8]=a,s[9]=o,s[10]=l):l=s[10],N(c,l)},Mc=t=>{if(t.key===void 0)throw new Error("useClientLookup: Element has no key");return t.key};function Re(t){const e=_(15);let s;e[0]!==t?(s=t.map($c),e[0]=t,e[1]=s):s=e[1];const r=Mt(s);let n;e[2]!==r?(n=Object.keys(r),e[2]=r,e[3]=n):n=e[3];const i=n;let o;e[4]!==r?(o=r.reduce(kc,{}),e[4]=r,e[5]=o):o=e[5];const a=o;let c;e[6]!==r?(c=r.map(Pc),e[6]=r,e[7]=c):c=e[7];const l=c;let u;e[8]!==a||e[9]!==i||e[10]!==r?(u=d=>{if("index"in d){if(d.index<0||i.length===0)throw new Error(`useClientLookup: Index ${d.index} out of bounds (length: ${i.length})`);const g=Math.min(d.index,i.length-1);return g!==d.index&&console.warn(`useClientLookup: Clamped stale index ${d.index} to ${g} (length: ${i.length})`),r[g].methods}const f=a[d.key];if(f===void 0)throw new Error(`useClientLookup: Key "${d.key}" not found`);return r[f].methods},e[8]=a,e[9]=i,e[10]=r,e[11]=u):u=e[11];let h;return e[12]!==l||e[13]!==u?(h={state:l,get:u},e[12]=l,e[13]=u,e[14]=h):h=e[14],h}function Pc(t){return t.state}function kc(t,e,s){return t[e.key]=s,t}function $c(t){return ne(Mc(t),Qa(t),t.deps)}const jn=t=>{const e=_(15),{toolkit:s,mcpApp:r}=t;let n;e[0]!==r?(n=r?[ne("mcpApp",r)]:[],e[0]=r,e[1]=n):n=e[1];const i=Mt(n)[0],[o,a]=G(jc);let c;e[2]!==o?(c=Object.fromEntries(Object.entries(o).map(Oc)),e[2]=o,e[3]=c):c=e[3];let l;e[4]!==i||e[5]!==c||e[6]!==o?(l={toolUIs:o,mcpApp:i,tools:c},e[4]=i,e[5]=c,e[6]=o,e[7]=l):l=e[7];const u=l,h=$n();let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(x,S,T)=>{const y={render:S,standalone:(T==null?void 0:T.standalone)??!1};return a(w=>({...w,[x]:[...w[x]??[],y]})),()=>{a(w=>{var $;const C=(($=w[x])==null?void 0:$.filter(D=>D!==y))??[];if(C.length>0)return{...w,[x]:C};const I={...w};return delete I[x],I})}},e[8]=d):d=e[8];const f=d;let g,b;e[9]!==h||e[10]!==s?(g=()=>{if(!s)return;const x=[];for(const[T,y]of Object.entries(s)){const w="render"in y?y.render:void 0,C="renderText"in y?y.renderText:void 0,I=w??(C?Ua(C):void 0);I&&x.push(f(T,I,{standalone:La(y)}))}const S=Object.entries(s).reduce(Nc,{});return x.push(h.current.modelContext().register({getModelContext:()=>({tools:S})})),()=>{x.forEach(Fc)}},b=[s,f,h],e[9]=h,e[10]=s,e[11]=g,e[12]=b):(g=e[11],b=e[12]),N(g,b);let v;return e[13]!==u?(v={getState:()=>u,setToolUI:f},e[13]=u,e[14]=v):v=e[14],v},Dc=q(jn);An(jn,(t,e)=>{!t.modelContext&&e.modelContext.source===null&&(t.modelContext=xn())});function jc(){return{}}function Bc(t){return t.render}function Oc(t){const[e,s]=t;return[e,s.map(Bc)]}function Nc(t,e){const[s,r]=e;if(r.type==="mcp")return t;const{display:n,render:i,renderText:o,...a}=r;return t[s]=a,t}function Fc(t){return t()}const Pe=t=>Ue(t.subscribe,t.getState),Lc=t=>{const e=_(8),{runtime:s}=t,r=Pe(s);let n;e[0]!==r?(n=()=>r,e[0]=r,e[1]=n):n=e[1];let i;e[2]!==s?(i=()=>s,e[2]=s,e[3]=i):i=e[3];let o;return e[4]!==s.remove||e[5]!==n||e[6]!==i?(o={getState:n,remove:s.remove,__internal_getRuntime:i},e[4]=s.remove,e[5]=n,e[6]=i,e[7]=o):o=e[7],o},Bn=q(Lc),Vc=t=>{const e=_(5),{runtime:s,index:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getAttachmentByIndex(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=Bn({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},Uc=q(Vc),qc=({item:t,onSteer:e,onRemove:s})=>({getState:()=>t,steer:e,remove:s}),Hc=q(qc),zc=t=>{const e=_(55),{threadIdRef:s,messageIdRef:r,runtime:n}=t,i=Pe(n),o=Ss();let a,c;e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==s?(a=()=>{const I=[];for(const $ of["send","attachmentAdd"]){const D=n.unstable_on($,()=>{o(`composer.${$}`,{threadId:s.current,...r&&{messageId:r.current}})});I.push(D)}return I.push(n.unstable_on("attachmentAddError",$=>{o("composer.attachmentAddError",{threadId:s.current,...r&&{messageId:r.current},...$.attachmentId&&{attachmentId:$.attachmentId},reason:$.reason,message:$.message})})),()=>{for(const $ of I)$()}},c=[n,o,s,r],e[0]=o,e[1]=r,e[2]=n,e[3]=s,e[4]=a,e[5]=c):(a=e[4],c=e[5]),N(a,c);let l;if(e[6]!==n||e[7]!==i.attachments){let I;e[9]!==n?(I=($,D)=>ne($.id,Uc({runtime:n,index:D}),[n,D]),e[9]=n,e[10]=I):I=e[10],l=i.attachments.map(I),e[6]=n,e[7]=i.attachments,e[8]=l}else l=e[8];const u=Re(l),h=i.queue;let d;if(e[11]!==h||e[12]!==n){let I;e[14]!==n?(I=$=>ne($.id,Hc({item:$,onSteer:()=>n.steerQueueItem($.id),onRemove:()=>n.removeQueueItem($.id)})),e[14]=n,e[15]=I):I=e[15],d=h.map(I),e[11]=h,e[12]=n,e[13]=d}else d=e[13];const f=Re(d),g=i.type??"thread";let b;e[16]!==u.state||e[17]!==h||e[18]!==i.attachmentAccept||e[19]!==i.canCancel||e[20]!==i.canSend||e[21]!==i.dictation||e[22]!==i.isEditing||e[23]!==i.isEmpty||e[24]!==i.quote||e[25]!==i.role||e[26]!==i.runConfig||e[27]!==i.text||e[28]!==g?(b={text:i.text,role:i.role,attachments:u.state,runConfig:i.runConfig,isEditing:i.isEditing,canCancel:i.canCancel,canSend:i.canSend,attachmentAccept:i.attachmentAccept,isEmpty:i.isEmpty,type:g,dictation:i.dictation,quote:i.quote,queue:h},e[16]=u.state,e[17]=h,e[18]=i.attachmentAccept,e[19]=i.canCancel,e[20]=i.canSend,e[21]=i.dictation,e[22]=i.isEditing,e[23]=i.isEmpty,e[24]=i.quote,e[25]=i.role,e[26]=i.runConfig,e[27]=i.text,e[28]=g,e[29]=b):b=e[29];const v=b;let x;e[30]!==v?(x=()=>v,e[30]=v,e[31]=x):x=e[31];const S=n.beginEdit??Gc;let T;e[32]!==u?(T=I=>"id"in I?u.get({key:I.id}):u.get(I),e[32]=u,e[33]=T):T=e[33];let y;e[34]!==f?(y=I=>f.get(I),e[34]=f,e[35]=y):y=e[35];let w;e[36]!==n?(w=()=>n,e[36]=n,e[37]=w):w=e[37];let C;return e[38]!==n.addAttachment||e[39]!==n.cancel||e[40]!==n.clearAttachments||e[41]!==n.reset||e[42]!==n.send||e[43]!==n.setQuote||e[44]!==n.setRole||e[45]!==n.setRunConfig||e[46]!==n.setText||e[47]!==n.startDictation||e[48]!==n.stopDictation||e[49]!==y||e[50]!==w||e[51]!==x||e[52]!==S||e[53]!==T?(C={getState:x,setText:n.setText,setRole:n.setRole,setRunConfig:n.setRunConfig,addAttachment:n.addAttachment,reset:n.reset,clearAttachments:n.clearAttachments,send:n.send,cancel:n.cancel,beginEdit:S,startDictation:n.startDictation,stopDictation:n.stopDictation,setQuote:n.setQuote,attachment:T,queueItem:y,__internal_getRuntime:w},e[38]=n.addAttachment,e[39]=n.cancel,e[40]=n.clearAttachments,e[41]=n.reset,e[42]=n.send,e[43]=n.setQuote,e[44]=n.setRole,e[45]=n.setRunConfig,e[46]=n.setText,e[47]=n.startDictation,e[48]=n.stopDictation,e[49]=y,e[50]=w,e[51]=x,e[52]=S,e[53]=T,e[54]=C):C=e[54],C},On=q(zc);function Gc(){throw new Error("beginEdit is not supported in this runtime")}const Nn=t=>({get current(){return t()}}),Kc=t=>{const e=_(13),{runtime:s}=t,r=Pe(s);let n;e[0]!==r?(n=()=>r,e[0]=r,e[1]=n):n=e[1];let i,o,a,c;e[2]!==s?(i=u=>s.addToolResult(u),o=u=>s.resumeToolCall(u),a=u=>s.respondToToolApproval(u),c=()=>s,e[2]=s,e[3]=i,e[4]=o,e[5]=a,e[6]=c):(i=e[3],o=e[4],a=e[5],c=e[6]);let l;return e[7]!==n||e[8]!==i||e[9]!==o||e[10]!==a||e[11]!==c?(l={getState:n,addToolResult:i,resumeToolCall:o,respondToToolApproval:a,__internal_getRuntime:c},e[7]=n,e[8]=i,e[9]=o,e[10]=a,e[11]=c,e[12]=l):l=e[12],l},Wc=q(Kc),Qc=t=>{const e=_(5),{runtime:s,index:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getAttachmentByIndex(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=Bn({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},Yc=q(Qc),Jc=t=>{const e=_(5),{runtime:s,index:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getMessagePartByIndex(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=Wc({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},Xc=q(Jc),Zc=t=>{const e=_(55),{runtime:s,threadIdRef:r}=t,n=Pe(s),[i,o]=G(!1),[a,c]=G(!1);let l;e[0]!==s?(l=Nn(()=>s.getState().id),e[0]=s,e[1]=l):l=e[1];const u=l;let h;e[2]!==u||e[3]!==s.composer||e[4]!==r?(h=On({runtime:s.composer,threadIdRef:r,messageIdRef:u}),e[2]=u,e[3]=s.composer,e[4]=r,e[5]=h):h=e[5];const d=tt(h);let f;if(e[6]!==s||e[7]!==n.content){let j;e[9]!==s?(j=(U,z)=>ne("toolCallId"in U&&U.toolCallId!=null?`toolCallId-${U.toolCallId}`:`index-${z}`,Xc({runtime:s,index:z}),[s,z]),e[9]=s,e[10]=j):j=e[10],f=n.content.map(j),e[6]=s,e[7]=n.content,e[8]=f}else f=e[8];const g=Re(f);let b;e[11]!==n.attachments?(b=n.attachments??[],e[11]=n.attachments,e[12]=b):b=e[12];let v;if(e[13]!==s||e[14]!==b){let j;e[16]!==s?(j=(U,z)=>ne(U.id,Yc({runtime:s,index:z}),[s,z]),e[16]=s,e[17]=j):j=e[17],v=b.map(j),e[13]=s,e[14]=b,e[15]=v}else v=e[15];const x=Re(v),S=n;let T;e[18]!==d.state||e[19]!==i||e[20]!==a||e[21]!==g.state||e[22]!==S?(T={...S,parts:g.state,composer:d.state,isCopied:i,isHovering:a},e[18]=d.state,e[19]=i,e[20]=a,e[21]=g.state,e[22]=S,e[23]=T):T=e[23];const y=T;let w;e[24]!==y?(w=()=>y,e[24]=y,e[25]=w):w=e[25];let C;e[26]!==d.methods?(C=()=>d.methods,e[26]=d.methods,e[27]=C):C=e[27];let I,$,D,R,E,k,A;e[28]!==s?(I=()=>s.delete(),$=j=>s.reload(j),D=()=>s.speak(),R=()=>s.stopSpeaking(),E=j=>s.submitFeedback(j),k=j=>s.switchToBranch(j),A=()=>s.unstable_getCopyText(),e[28]=s,e[29]=I,e[30]=$,e[31]=D,e[32]=R,e[33]=E,e[34]=k,e[35]=A):(I=e[29],$=e[30],D=e[31],R=e[32],E=e[33],k=e[34],A=e[35]);let B;e[36]!==g?(B=j=>"index"in j?g.get({index:j.index}):g.get({key:`toolCallId-${j.toolCallId}`}),e[36]=g,e[37]=B):B=e[37];let O;e[38]!==x?(O=j=>"id"in j?x.get({key:j.id}):x.get(j),e[38]=x,e[39]=O):O=e[39];let L;e[40]!==s?(L=()=>s,e[40]=s,e[41]=L):L=e[41];let H;return e[42]!==I||e[43]!==$||e[44]!==D||e[45]!==R||e[46]!==E||e[47]!==k||e[48]!==A||e[49]!==B||e[50]!==O||e[51]!==L||e[52]!==w||e[53]!==C?(H={getState:w,composer:C,delete:I,reload:$,speak:D,stopSpeaking:R,submitFeedback:E,switchToBranch:k,getCopyText:A,part:B,attachment:O,setIsCopied:o,setIsHovering:c,__internal_getRuntime:L},e[42]=I,e[43]=$,e[44]=D,e[45]=R,e[46]=E,e[47]=k,e[48]=A,e[49]=B,e[50]=O,e[51]=L,e[52]=w,e[53]=C,e[54]=H):H=e[54],H},el=q(Zc),tl=t=>{const e=_(6),{runtime:s,id:r,threadIdRef:n}=t;let i;e[0]!==r||e[1]!==s?(i=s.getMessageById(r),e[0]=r,e[1]=s,e[2]=i):i=e[2];const o=i;let a;return e[3]!==o||e[4]!==n?(a=el({runtime:o,threadIdRef:n}),e[3]=o,e[4]=n,e[5]=a):a=e[5],se(a)},sl=q(tl),rl=t=>{const e=_(58),{runtime:s}=t,r=Pe(s),n=Ss();let i,o;e[0]!==n||e[1]!==s?(i=()=>{const w=[];for(const C of["runStart","runEnd","initialize","modelContextUpdate"]){const I=s.unstable_on(C,()=>{var D;const $=((D=s.getState())==null?void 0:D.threadId)||"unknown";n(`thread.${C}`,{threadId:$})});w.push(I)}return()=>{for(const C of w)C()}},o=[s,n],e[0]=n,e[1]=s,e[2]=i,e[3]=o):(i=e[2],o=e[3]),N(i,o);let a;e[4]!==s?(a=Nn(()=>s.getState().threadId),e[4]=s,e[5]=a):a=e[5];const c=a;let l;e[6]!==s.composer||e[7]!==c?(l=On({runtime:s.composer,threadIdRef:c}),e[6]=s.composer,e[7]=c,e[8]=l):l=e[8];const u=tt(l);let h;if(e[9]!==s||e[10]!==r.messages||e[11]!==c){let w;e[13]!==s||e[14]!==c?(w=C=>ne(C.id,sl({runtime:s,id:C.id,threadIdRef:c}),[s,C.id,c]),e[13]=s,e[14]=c,e[15]=w):w=e[15],h=r.messages.map(w),e[9]=s,e[10]=r.messages,e[11]=c,e[12]=h}else h=e[12];const d=Re(h),f=d.state.length===0&&!r.isLoading;let g;e[16]!==u.state||e[17]!==d.state||e[18]!==r.capabilities||e[19]!==r.extras||e[20]!==r.isDisabled||e[21]!==r.isLoading||e[22]!==r.isRunning||e[23]!==r.speech||e[24]!==r.state||e[25]!==r.suggestions||e[26]!==r.voice||e[27]!==f?(g={isEmpty:f,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:u.state,messages:d.state},e[16]=u.state,e[17]=d.state,e[18]=r.capabilities,e[19]=r.extras,e[20]=r.isDisabled,e[21]=r.isLoading,e[22]=r.isRunning,e[23]=r.speech,e[24]=r.state,e[25]=r.suggestions,e[26]=r.voice,e[27]=f,e[28]=g):g=e[28];const b=g;let v;e[29]!==b?(v=()=>b,e[29]=b,e[30]=v):v=e[30];let x;e[31]!==u.methods?(x=()=>u.methods,e[31]=u.methods,e[32]=x):x=e[32];let S;e[33]!==d?(S=w=>"id"in w?d.get({key:w.id}):d.get(w),e[33]=d,e[34]=S):S=e[34];let T;e[35]!==s?(T=()=>s,e[35]=s,e[36]=T):T=e[36];let y;return e[37]!==s.append||e[38]!==s.cancelRun||e[39]!==s.connectVoice||e[40]!==s.deleteMessage||e[41]!==s.disconnectVoice||e[42]!==s.export||e[43]!==s.getModelContext||e[44]!==s.getVoiceVolume||e[45]!==s.import||e[46]!==s.muteVoice||e[47]!==s.reset||e[48]!==s.resumeRun||e[49]!==s.startRun||e[50]!==s.stopSpeaking||e[51]!==s.subscribeVoiceVolume||e[52]!==s.unmuteVoice||e[53]!==S||e[54]!==T||e[55]!==v||e[56]!==x?(y={getState:v,composer:x,append:s.append,deleteMessage:s.deleteMessage,startRun:s.startRun,resumeRun:s.resumeRun,cancelRun:s.cancelRun,getModelContext:s.getModelContext,export:s.export,import:s.import,reset:s.reset,stopSpeaking:s.stopSpeaking,connectVoice:s.connectVoice,disconnectVoice:s.disconnectVoice,getVoiceVolume:s.getVoiceVolume,subscribeVoiceVolume:s.subscribeVoiceVolume,muteVoice:s.muteVoice,unmuteVoice:s.unmuteVoice,message:S,__internal_getRuntime:T},e[37]=s.append,e[38]=s.cancelRun,e[39]=s.connectVoice,e[40]=s.deleteMessage,e[41]=s.disconnectVoice,e[42]=s.export,e[43]=s.getModelContext,e[44]=s.getVoiceVolume,e[45]=s.import,e[46]=s.muteVoice,e[47]=s.reset,e[48]=s.resumeRun,e[49]=s.startRun,e[50]=s.stopSpeaking,e[51]=s.subscribeVoiceVolume,e[52]=s.unmuteVoice,e[53]=S,e[54]=T,e[55]=v,e[56]=x,e[57]=y):y=e[57],y},nl=q(rl),il=t=>{const e=_(20),{runtime:s}=t,r=Pe(s),n=Ss();let i,o;e[0]!==n||e[1]!==s?(i=()=>{const u=[];for(const h of["switchedTo","switchedAway"]){const d=s.unstable_on(h,()=>{n(`threadListItem.${h}`,{threadId:s.getState().id})});u.push(d)}return()=>{for(const h of u)h()}},o=[s,n],e[0]=n,e[1]=s,e[2]=i,e[3]=o):(i=e[2],o=e[3]),N(i,o);let a;e[4]!==r?(a=()=>r,e[4]=r,e[5]=a):a=e[5];let c;e[6]!==s?(c=()=>s,e[6]=s,e[7]=c):c=e[7];let l;return e[8]!==s.archive||e[9]!==s.delete||e[10]!==s.detach||e[11]!==s.generateTitle||e[12]!==s.initialize||e[13]!==s.rename||e[14]!==s.switchTo||e[15]!==s.unarchive||e[16]!==s.updateCustom||e[17]!==a||e[18]!==c?(l={getState:a,switchTo:s.switchTo,rename:s.rename,updateCustom:s.updateCustom,archive:s.archive,unarchive:s.unarchive,delete:s.delete,generateTitle:s.generateTitle,initialize:s.initialize,detach:s.detach,__internal_getRuntime:c},e[8]=s.archive,e[9]=s.delete,e[10]=s.detach,e[11]=s.generateTitle,e[12]=s.initialize,e[13]=s.rename,e[14]=s.switchTo,e[15]=s.unarchive,e[16]=s.updateCustom,e[17]=a,e[18]=c,e[19]=l):l=e[19],l},ol=q(il),al=t=>{const e=_(5),{runtime:s,id:r}=t;let n;e[0]!==r||e[1]!==s?(n=s.getItemById(r),e[0]=r,e[1]=s,e[2]=n):n=e[2];const i=n;let o;return e[3]!==i?(o=ol({runtime:i}),e[3]=i,e[4]=o):o=e[4],se(o)},cl=q(al),ll=t=>{const e=_(40),{runtime:s,__internal_assistantRuntime:r}=t,n=Pe(s);let i;e[0]!==s.main?(i=nl({runtime:s.main}),e[0]=s.main,e[1]=i):i=e[1];const o=tt(i);let a;e[2]!==s||e[3]!==n.threadItems?(a=Object.keys(n.threadItems).map(C=>ne(C,cl({runtime:s,id:C}),[s,C])),e[2]=s,e[3]=n.threadItems,e[4]=a):a=e[4];const c=Re(a),l=n.newThreadId??null;let u;e[5]!==o.state||e[6]!==n.archivedThreadIds||e[7]!==n.hasMore||e[8]!==n.isLoading||e[9]!==n.isLoadingMore||e[10]!==n.mainThreadId||e[11]!==n.threadIds||e[12]!==l||e[13]!==c.state?(u={mainThreadId:n.mainThreadId,newThreadId:l,isLoading:n.isLoading,isLoadingMore:n.isLoadingMore,hasMore:n.hasMore,threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadItems:c.state,main:o.state},e[5]=o.state,e[6]=n.archivedThreadIds,e[7]=n.hasMore,e[8]=n.isLoading,e[9]=n.isLoadingMore,e[10]=n.mainThreadId,e[11]=n.threadIds,e[12]=l,e[13]=c.state,e[14]=u):u=e[14];const h=u;let d;e[15]!==h?(d=()=>h,e[15]=h,e[16]=d):d=e[16];let f;e[17]!==o.methods?(f=()=>o.methods,e[17]=o.methods,e[18]=f):f=e[18];let g;e[19]!==h||e[20]!==c?(g=C=>{if(C==="main")return c.get({key:h.mainThreadId});if("id"in C)return c.get({key:C.id});const{index:I,archived:$}=C,D=$!==void 0&&$?h.archivedThreadIds[I]:h.threadIds[I];return c.get({key:D})},e[19]=h,e[20]=c,e[21]=g):g=e[21];let b,v,x,S,T;e[22]!==s?(S=async(C,I)=>{await s.switchToThread(C,I)},T=async()=>{await s.switchToNewThread()},b=()=>s.getLoadThreadsPromise(),v=()=>s.reload(),x=()=>s.loadMore(),e[22]=s,e[23]=b,e[24]=v,e[25]=x,e[26]=S,e[27]=T):(b=e[23],v=e[24],x=e[25],S=e[26],T=e[27]);let y;e[28]!==r?(y=()=>r,e[28]=r,e[29]=y):y=e[29];let w;return e[30]!==b||e[31]!==v||e[32]!==x||e[33]!==y||e[34]!==d||e[35]!==f||e[36]!==g||e[37]!==S||e[38]!==T?(w={getState:d,thread:f,item:g,switchToThread:S,switchToNewThread:T,getLoadThreadsPromise:b,reload:v,loadMore:x,__internal_getAssistantRuntime:y},e[30]=b,e[31]=v,e[32]=x,e[33]=y,e[34]=d,e[35]=f,e[36]=g,e[37]=S,e[38]=T,e[39]=w):w=e[39],w},ul=q(ll),dl=t=>({getState:()=>t}),hl=q(dl),fl=t=>{const e=_(11);let s;e[0]!==t?(s=()=>({suggestions:(t??[]).map(gl)}),e[0]=t,e[1]=s):s=e[1];const[r]=G(s);let n;e[2]!==r.suggestions?(n=r.suggestions.map(ml),e[2]=r.suggestions,e[3]=n):n=e[3];const i=Re(n);let o;e[4]!==r?(o=()=>r,e[4]=r,e[5]=o):o=e[5];let a;e[6]!==i?(a=l=>{const{index:u}=l;return i.get({index:u})},e[6]=i,e[7]=a):a=e[7];let c;return e[8]!==o||e[9]!==a?(c={getState:o,suggestion:a},e[8]=o,e[9]=a,e[10]=c):c=e[10],c},pl=q(fl);function gl(t){return typeof t=="string"?{title:t,label:"",prompt:t}:{title:t.title,label:t.label,prompt:t.prompt}}function ml(t,e){return ne(e,hl(t),[t])}const bl=(t,e)=>{t.thread??(t.thread=re({source:"threads",query:{type:"main"},get:s=>s.threads().thread("main")})),t.threadListItem??(t.threadListItem=re({source:"threads",query:{type:"main"},get:s=>s.threads().item("main")})),t.composer??(t.composer=re({source:"thread",query:{},get:s=>s.threads().thread("main").composer()})),!t.modelContext&&e.modelContext.source===null&&(t.modelContext=xn()),!t.suggestions&&e.suggestions.source===null&&(t.suggestions=pl())},Fn=t=>{const e=_(6),s=$n();let r,n;e[0]!==s||e[1]!==t?(r=()=>t.registerModelContextProvider(s.current.modelContext()),n=[t,s],e[0]=s,e[1]=t,e[2]=r,e[3]=n):(r=e[2],n=e[3]),N(r,n);let i;return e[4]!==t?(i=ul({runtime:t.threads,__internal_assistantRuntime:t}),e[4]=t,e[5]=i):i=e[5],se(i)},_l=q(Fn);An(Fn,(t,e)=>{bl(t,e),!t.tools&&e.tools.source===null&&(t.tools=Dc({})),!t.dataRenderers&&e.dataRenderers.source===null&&(t.dataRenderers=Da())});const yl=t=>{var e;return(e=t._core)==null?void 0:e.RenderComponent},vl=M.memo(({runtime:t,aui:e=null,children:s})=>{"use no memo";const r=F({threads:_l(t)},{parent:e}),n=yl(t),i=p.jsxs(ue,{value:r,children:[n&&p.jsx(n,{}),s]});return e?p.jsx(ue,{value:e,children:i}):i}),sr=t=>{let e;const s=new Set,r=(l,u)=>{const h=typeof l=="function"?l(e):l;if(!Object.is(h,e)){const d=e;e=u??(typeof h!="object"||h===null)?h:Object.assign({},e,h),s.forEach(f=>f(e,d))}},n=()=>e,a={setState:r,getState:n,getInitialState:()=>c,subscribe:l=>(s.add(l),()=>s.delete(l))},c=e=t(r,n,a);return a},Sl=t=>t?sr(t):sr,xl=t=>t;function wl(t,e=xl){const s=J.useSyncExternalStore(t.subscribe,J.useCallback(()=>e(t.getState()),[t,e]),J.useCallback(()=>e(t.getInitialState()),[t,e]));return J.useDebugValue(s),s}const rr=t=>{const e=Sl(t),s=r=>wl(e,r);return Object.assign(s,e),s},Tl=t=>t?rr(t):rr;function Z(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function vt(t,e=0){return e>100?!1:t===null||typeof t=="string"||typeof t=="boolean"?!0:typeof t=="number"?!Number.isNaN(t)&&Number.isFinite(t):Array.isArray(t)?t.every(s=>vt(s,e+1)):Z(t)?Object.entries(t).every(([s,r])=>typeof s=="string"&&vt(r,e+1)):!1}const Cl=100,Xt=(t,e,s)=>{if(t===e)return!0;if(s>Cl||t==null||e==null)return!1;if(Array.isArray(t))return!Array.isArray(e)||t.length!==e.length?!1:t.every((i,o)=>Xt(i,e[o],s+1));if(Array.isArray(e)||!Z(t)||!Z(e))return!1;const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(i=>Object.hasOwn(e,i)&&Xt(t[i],e[i],s+1))},xs=(t,e)=>!vt(t)||!vt(e)?!1:Xt(t,e,0);function Il(t){const e=t.metadata;if(!e||typeof e!="object")return;const s=e.custom;if(!s||typeof s!="object")return;const r=s.interactables;return Array.isArray(r)?r:void 0}function El(t){return`update_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}const nr=t=>{if(!Z(t))return;const e=t.id;return typeof e=="string"||typeof e=="number"?e:void 0};function Rl(t,e,s){let r=Array.isArray(e.set)?[...e.set]:[...t];if(e.clear===!0&&(r=[]),Array.isArray(e.remove)&&e.remove.length>0){const i=new Set(e.remove);r=r.filter(o=>{const a=nr(o);return a!==void 0?!i.has(a):!i.has(o)})}const n=e.update;if(Array.isArray(n)&&n.length>0&&(r=r.map(i=>{const o=nr(i);if(o===void 0||!Z(i))return i;const a=n.find(c=>Z(c)&&c.id===o);return a?{...i,...a}:i})),Array.isArray(e.add)&&e.add.length>0){const i=s?e.add.map(o=>{if(!Z(o)||o.id!==void 0)return o;const a=s();return a===void 0?o:{...o,id:a}}):e.add;r=[...r,...i]}return r}function Ot(t,e,s){if(!Z(t)||!Z(e))return e;const r=Z(s==null?void 0:s.arrayBaseline)?s.arrayBaseline:t,n={...t};for(const[i,o]of Object.entries(e)){const a=r[i];Array.isArray(a)&&Z(o)?n[i]=Rl(a,o,s!=null&&s.idFactory&&(s.idKeyedFields===void 0||s.idKeyedFields.has(i))?()=>{var c;return(c=s.idFactory)==null?void 0:c.call(s,i)}:void 0):n[i]=o}return n}function Al(t,e){if(!Z(t)||!Z(e))return;for(const n of Object.keys(t))if(!(n in e))return;const s={};for(const[n,i]of Object.entries(e))(!(n in t)||!xs(t[n],i))&&(s[n]=i);const r=Object.keys(s).length;if(!(r===0||r===Object.keys(e).length))return s}const Ml=t=>{if(!t||typeof t!="object")return;const e=t;return e.type==="tool-call"?e:void 0},Pl=(t,e)=>{if(!t.args||typeof t.args!="object")return!1;const s=Z(t.result)?t.result:void 0;if((s==null?void 0:s.success)===!1)return!1;if(typeof(s==null?void 0:s.id)=="string")return s.id===e;const r=t.args.id;return r===e||r===void 0},kl=t=>{const e=Z(t)?t.addedItemIds:void 0;if(!Z(e))return;const s=new Map;for(const[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;const i=n.filter(o=>typeof o=="string");i.length>0&&s.set(r,i)}if(s.size!==0)return r=>{var n;return(n=s.get(r))==null?void 0:n.shift()}},ir=new WeakMap;function $l(t,e,s){var l;let r=ir.get(t);r||(r=new Map,ir.set(t,r));let n=r.get(s);n||(n=new Map,r.set(s,n));const i=n.get(e);if(i)return i;const o=El(s),a=[],c=()=>a[a.length-1];for(const u of t){if(u.role==="user"){const h=(l=Il(u))==null?void 0:l.find(d=>d.id===e);if(!h)continue;if(h.partial){const d=c();d&&a.push({state:Ot(d.state,h.state),origin:"user-edit"})}else a.push({state:h.state,origin:"user-edit"});continue}if(u.role==="assistant")for(const h of u.content??[]){const d=Ml(h);if(d){if(d.toolCallId===e&&d.toolName===s)d.args&&typeof d.args=="object"&&a.push({state:d.args,origin:"create",toolCallId:e});else if(d.toolName===o&&Pl(d,e)){const f=c();if(f){const{id:g,...b}=d.args,v=kl(d.result);a.push({state:v?Ot(f.state,b,{idFactory:v}):Ot(f.state,b),origin:"update",toolCallId:d.toolCallId})}}}}}return n.set(e,a),a}function Dl(t,e,s){const r=$l(t,e,s),n=r[r.length-1];return n?{state:n.state}:void 0}function Ln(t,e){if(!t)return;const{interactables:s,...r}=t,n={...r};if(Array.isArray(s)){const i=[];for(const o of s){const a=Dl(e,o.id,o.name);if(!a){i.push({id:o.id,name:o.name,state:o.state});continue}if(xs(o.state,a.state))continue;const c=Al(a.state,o.state);i.push(c?{id:o.id,name:o.name,state:c,partial:!0}:{id:o.id,name:o.name,state:o.state})}i.length&&(n.interactables=i)}return Object.keys(n).length?n:void 0}const ws=()=>{let t,e;const s=new Promise((r,n)=>{t=r,e=n});if(!t||!e)throw new Error("Failed to create promise");return{promise:s,resolve:t,reject:e}},jl=()=>{const t=[];let e=!1,s,r;const n=i=>{i.promise||(i.promise=i.reader.read().then(({done:o,value:a})=>{i.promise=void 0,o?(t.splice(t.indexOf(i),1),e&&t.length===0&&s.close()):s.enqueue(a),r==null||r.resolve(),r=void 0}).catch(o=>{console.error(o),t.forEach(a=>{a.reader.cancel()}),t.length=0,s.error(o),r==null||r.reject(o),r=void 0}))};return{readable:new ReadableStream({start(i){s=i},pull(){return r=ws(),t.forEach(i=>{n(i)}),r.promise},cancel(){t.forEach(i=>{i.reader.cancel()}),t.length=0}}),isSealed(){return e},seal(){e=!0,t.length===0&&s.close()},addStream(i){if(e)throw new Error("Cannot add streams after the run callback has settled.");const o={reader:i.getReader()};t.push(o),n(o)},enqueue(i){this.addStream(new ReadableStream({start(o){o.enqueue(i),o.close()}}))}}};var or=class{constructor(t){m(this,"_controller");m(this,"_isClosed",!1);this._controller=t}append(t){return this._controller.enqueue({type:"text-delta",path:[],textDelta:t}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const Vn=t=>new ReadableStream({start(e){var s;return(s=t.start)==null?void 0:s.call(t,new or(e))},pull(e){var s;return(s=t.pull)==null?void 0:s.call(t,new or(e))},cancel(e){var s;return(s=t.cancel)==null?void 0:s.call(t,e)}}),ar=()=>{let t;return[Vn({start(e){t=e}}),t]};var cr=class{constructor(t){m(this,"_controller");m(this,"_isClosed",!1);m(this,"_mergeTask");m(this,"_argsTextController");this._controller=t;const e=Vn({start:r=>{this._argsTextController=r}});let s=!1;this._mergeTask=e.pipeTo(new WritableStream({write:r=>{switch(r.type){case"text-delta":s=!0,this._controller.enqueue(r);break;case"part-finish":s||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${r.type}`)}}}))}get argsText(){return this._argsTextController}async setResponse(t){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:"result",path:[],...t.artifact!==void 0?{artifact:t.artifact}:{},result:t.result,isError:t.isError??!1,...t.modelContent!==void 0?{modelContent:t.modelContent}:{},...t.messages!==void 0?{messages:t.messages}:{}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}};const Bl=t=>new ReadableStream({start(e){var s;return(s=t.start)==null?void 0:s.call(t,new cr(e))},pull(e){var s;return(s=t.pull)==null?void 0:s.call(t,new cr(e))},cancel(e){var s;return(s=t.cancel)==null?void 0:s.call(t,e)}}),Ol=()=>{let t;return[Bl({start(e){t=e}}),t]};var Un=class{constructor(){m(this,"value",-1)}up(){return++this.value}},Nl=class extends TransformStream{constructor(t){super({transform(e,s){s.enqueue({...e,path:[t,...e.path]})}})}};(class extends TransformStream{constructor(t){super({transform(e,s){const{path:[r,...n]}=e;if(t!==r)throw new Error(`Path mismatch: expected ${t}, got ${r}`);s.enqueue({...e,path:n})}})}});var Fl=class extends TransformStream{constructor(t){const e=new Un,s=new Map;super({transform(r,n){r.type==="part-start"&&r.path.length===0&&s.set(e.up(),t.up());const[i,...o]=r.path;if(i===void 0){n.enqueue(r);return}const a=s.get(i);if(a===void 0)throw new Error("Path not found");n.enqueue({...r,path:[a,...o]})}})}},Ll=class extends TransformStream{constructor(t){super();const e=t(super.readable);Object.defineProperty(this,"readable",{value:e,writable:!1})}},qn=class extends TransformStream{constructor(){const t=[];super({transform(e,s){if(e.type==="part-start"){if(e.path.length!==0){s.error(new Error("Nested parts are not supported"));return}t.push(e.part),s.enqueue(e);return}if(e.type==="text-delta"||e.type==="result"||e.type==="part-finish"||e.type==="tool-call-args-text-finish"){if(e.path.length!==1){s.error(new Error(`${e.type} chunks must have a path of length 1`));return}const r=e.path[0];if(r<0||r>=t.length){s.error(new Error(`Invalid path index: ${r}`));return}const n=t[r];s.enqueue({...e,meta:n});return}s.enqueue(e)}})}};let Vl=(t,e=21)=>(s=e)=>{let r="",n=s|0;for(;n-- >0;)r+=t[Math.random()*t.length|0];return r};const Ul=Vl("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);var ql=class Hn{constructor(e){m(this,"_state");m(this,"_parentId");this._state=e||{merger:jl(),contentCounter:new Un}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,s){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:e,path:[]}),this._state.merger.addStream(s.pipeThrough(new Nl(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new Fl(this._state.contentCounter)))}appendText(e){var s;(((s=this._state.append)==null?void 0:s.kind)!=="text"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"text",parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e){var s;(((s=this._state.append)==null?void 0:s.kind)!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){const[e,s]=ar();return this._addPart(this._withParentIdOption({type:"text"}),e),s}addReasoningPart(){const[e,s]=ar();return this._addPart(this._withParentIdOption({type:"reasoning"}),e),s}addToolCallPart(e){const s=typeof e=="string"?{toolName:e}:e,r=s.toolName,n=s.toolCallId??Ul(),[i,o]=Ol();return this._addPart({type:"tool-call",toolName:r,toolCallId:n,...this._parentId&&{parentId:this._parentId}},i),s.argsText!==void 0&&(o.argsText.append(s.argsText),o.argsText.close()),s.args!==void 0&&(o.argsText.append(JSON.stringify(s.args)),o.argsText.close()),s.response!==void 0&&o.setResponse(s.response),o}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:"part-finish",path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type==="part-start"&&e.path.length===0&&this._state.contentCounter.up()}withParentId(e){const s=new Hn(this._state);return s._parentId=e,s}close(){var e,s,r,n;(s=(e=this._state.append)==null?void 0:e.controller)==null||s.close(),this._state.merger.seal(),(n=(r=this._state).closeSubscriber)==null||n.call(r)}};function Hl(t){const e=new ql;return(async()=>{try{await t(e)}catch(r){throw e.__internal_isClosed||e.enqueue({type:"error",path:[],error:String(r)}),r}finally{e.__internal_isClosed||e.close()}})(),e.__internal_getReadable()}function zl(){const{resolve:t,promise:e}=ws();let s;return[Hl(r=>(s=r,s.__internal_subscribeToClose(t),e)),s]}function Gl(t){const e=["ROOT"];let s=-1,r=null;const n=[];let i;function o(){i!==void 0&&(n.push(JSON.parse(`"${i}"`)),i=void 0)}function a(h,d,f){switch(h){case'"':s=d,e.pop(),e.push(f),e.push("INSIDE_STRING"),o();break;case"f":case"t":case"n":s=d,r=d,e.pop(),e.push(f),e.push("INSIDE_LITERAL");break;case"-":e.pop(),e.push(f),e.push("INSIDE_NUMBER"),o();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s=d,e.pop(),e.push(f),e.push("INSIDE_NUMBER"),o();break;case"{":s=d,e.pop(),e.push(f),e.push("INSIDE_OBJECT_START"),o();break;case"[":s=d,e.pop(),e.push(f),e.push("INSIDE_ARRAY_START"),o();break}}function c(h,d){switch(h){case",":e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":s=d,e.pop(),i=n.pop();break}}function l(h,d){switch(h){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":s=d,e.pop(),i=n.pop();break}}for(let h=0;h<t.length;h++){const d=t[h];switch(e[e.length-1]){case"ROOT":a(d,h,"FINISH");break;case"INSIDE_OBJECT_START":switch(d){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),i="";break;case"}":s=h,e.pop(),i=n.pop();break}break;case"INSIDE_OBJECT_AFTER_COMMA":switch(d){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),i="";break}break;case"INSIDE_OBJECT_KEY":switch(d){case'"':e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":e.push("INSIDE_STRING_ESCAPE"),i+=d;break;default:i+=d;break}break;case"INSIDE_OBJECT_AFTER_KEY":switch(d){case":":e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}break;case"INSIDE_OBJECT_BEFORE_VALUE":a(d,h,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":c(d,h);break;case"INSIDE_STRING":switch(d){case'"':e.pop(),s=h,i=n.pop();break;case"\\":e.push("INSIDE_STRING_ESCAPE");break;default:s=h}break;case"INSIDE_ARRAY_START":switch(d){case"]":s=h,e.pop(),i=n.pop();break;default:s=h,i="0",a(d,h,"INSIDE_ARRAY_AFTER_VALUE");break}break;case"INSIDE_ARRAY_AFTER_VALUE":switch(d){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),i=(Number(i)+1).toString();break;case"]":s=h,e.pop(),i=n.pop();break;default:s=h;break}break;case"INSIDE_ARRAY_AFTER_COMMA":a(d,h,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":e.pop(),e[e.length-1]==="INSIDE_STRING"?s=h:e[e.length-1]==="INSIDE_OBJECT_KEY"&&(i+=d);break;case"INSIDE_NUMBER":switch(d){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s=h;break;case"e":case"E":case"-":case".":break;case",":e.pop(),i=n.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(d,h),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(d,h);break;case"}":e.pop(),i=n.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(d,h);break;case"]":e.pop(),i=n.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(d,h);break;default:e.pop(),i=n.pop();break}break;case"INSIDE_LITERAL":{const f=t.substring(r,h+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?c(d,h):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&l(d,h)):s=h;break}}}let u=t.slice(0,s+1);for(let h=e.length-1;h>=0;h--)switch(e[h]){case"INSIDE_STRING":u+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":u+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":u+="]";break;case"INSIDE_LITERAL":{const d=t.substring(r,t.length);"true".startsWith(d)?u+="true".slice(d.length):"false".startsWith(d)?u+="false".slice(d.length):"null".startsWith(d)&&(u+="null".slice(d.length))}}return[u,n]}var He={exports:{}};const Kl=typeof Buffer<"u",lr=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,ur=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function zn(t,e,s){s==null&&e!==null&&typeof e=="object"&&(s=e,e=void 0),Kl&&Buffer.isBuffer(t)&&(t=t.toString()),t&&t.charCodeAt(0)===65279&&(t=t.slice(1));const r=JSON.parse(t,e);if(r===null||typeof r!="object")return r;const n=s&&s.protoAction||"error",i=s&&s.constructorAction||"error";if(n==="ignore"&&i==="ignore")return r;if(n!=="ignore"&&i!=="ignore"){if(lr.test(t)===!1&&ur.test(t)===!1)return r}else if(n!=="ignore"&&i==="ignore"){if(lr.test(t)===!1)return r}else if(ur.test(t)===!1)return r;return Gn(r,{protoAction:n,constructorAction:i,safe:s&&s.safe})}function Gn(t,{protoAction:e="error",constructorAction:s="error",safe:r}={}){let n=[t];for(;n.length;){const i=n;n=[];for(const o of i){if(e!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(r===!0)return null;if(e==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.__proto__}if(s!=="ignore"&&Object.prototype.hasOwnProperty.call(o,"constructor")&&o.constructor!==null&&typeof o.constructor=="object"&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype")){if(r===!0)return null;if(s==="error")throw new SyntaxError("Object contains forbidden prototype property");delete o.constructor}for(const a in o){const c=o[a];c&&typeof c=="object"&&n.push(c)}}}return t}function Ts(t,e,s){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return zn(t,e,s)}finally{Error.stackTraceLimit=r}}function Wl(t,e){const{stackTraceLimit:s}=Error;Error.stackTraceLimit=0;try{return zn(t,e,{safe:!0})}catch{return}finally{Error.stackTraceLimit=s}}He.exports=Ts;He.exports.default=Ts;He.exports.parse=Ts;He.exports.safeParse=Wl;He.exports.scan=Gn;var Ql=He.exports;const Zt=Uo(Ql),ht=Symbol("aui.parse-partial-json-object.meta"),Yl=t=>t==null?void 0:t[ht],es=t=>{if(t.length===0)return{[ht]:{state:"partial",partialPath:[]}};try{const e=Zt.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[ht]={state:"complete",partialPath:[]},e}catch{try{const[e,s]=Gl(t),r=Zt.parse(e);if(typeof r!="object"||r===null)throw new Error("argsText is expected to be an object");return r[ht]={state:"partial",partialPath:s},r}catch{return}}},Kn=(t,e,s)=>{if(typeof t!="object"||t===null)return e.state;if(e.state==="complete")return"complete";if(s.length===0)return e.state;const[r,...n]=s;if(!Object.hasOwn(t,r))return"partial";const[i,...o]=e.partialPath;if(r!==i)return"complete";const a=t[r];return Kn(a,{state:"partial",partialPath:o},n)},Fe=(t,e)=>{const s=Yl(t);if(!s)throw new Error("unable to determine object state");return Kn(t,s,e.map(String))};async function*Jl(){const t=this.getReader();try{for(;;){const{done:e,value:s}=await t.read();if(e)break;yield s}}finally{t.releaseLock()}}function Nt(t){var e;return t[e=Symbol.asyncIterator]??(t[e]=Jl),t}const dr=Symbol.for("aui.tool-response");var ve=class ts{constructor(e){m(this,"artifact");m(this,"result");m(this,"isError");m(this,"modelContent");m(this,"messages");e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}get[dr](){return!0}static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&dr in e}static toResponse(e){return e instanceof ts?e:new ts({result:e===void 0?"<no result>":e})}};function Xl(t,e,s){try{const r=t();if(typeof r=="object"&&r!==null&&"then"in r)return r.then(e,s);e(r)}catch(r){s(r)}}function Le(t,e){let s=t;for(const r of e){if(s==null)return;s=s[r]}return s}var Zl=class{constructor(t,e,s){m(this,"resolve");m(this,"reject");m(this,"disposed",!1);m(this,"fieldPath");this.resolve=t,this.reject=e,this.fieldPath=s}update(t){if(!this.disposed)try{if(Fe(t,this.fieldPath)==="complete"){const e=Le(t,this.fieldPath);e!==void 0&&(this.resolve(e),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(t){if(!this.disposed)try{const e=Le(t,this.fieldPath);this.resolve(e)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},eu=class{constructor(t,e){m(this,"controller");m(this,"disposed",!1);m(this,"fieldPath");this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=Le(t,this.fieldPath);e!==void 0&&this.controller.enqueue(e),Fe(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},tu=class{constructor(t,e){m(this,"controller");m(this,"disposed",!1);m(this,"fieldPath");m(this,"lastValue");this.controller=t,this.fieldPath=e}update(t){var e;if(!this.disposed)try{const s=Le(t,this.fieldPath);if(s!==void 0&&typeof s=="string"){const r=s.substring(((e=this.lastValue)==null?void 0:e.length)||0);this.lastValue=s,this.controller.enqueue(r)}Fe(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(s){this.controller.error(s),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},su=class{constructor(t,e){m(this,"controller");m(this,"disposed",!1);m(this,"fieldPath");m(this,"processedIndexes",new Set);this.controller=t,this.fieldPath=e}update(t){if(!this.disposed)try{const e=Le(t,this.fieldPath);if(!Array.isArray(e))return;for(let s=0;s<e.length;s++)this.processedIndexes.has(s)||Fe(t,[...this.fieldPath,s])==="complete"&&(this.controller.enqueue(e[s]),this.processedIndexes.add(s));Fe(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},ru=class{constructor(t){m(this,"argTextDeltas");m(this,"handles",new Set);m(this,"args",es(""));m(this,"finished",!1);this.argTextDeltas=t,this.processStream()}async processStream(){try{let t="";const e=this.argTextDeltas.getReader();for(;;){const{value:s,done:r}=await e.read();if(r)break;t+=s;const n=es(t);if(n!==void 0){this.args=n;for(const i of this.handles)i.update(n)}}}catch(t){console.error("Error processing argument stream:",t)}finally{this.finished=!0;for(const t of this.handles)t.end(this.args);this.handles.clear()}}get(...t){return new Promise((e,s)=>{const r=new Zl(e,s,t);if(this.args&&Fe(this.args,t)==="complete"){const n=Le(this.args,t);if(n!==void 0){e(n);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...t){const e=t;let s;return Nt(new ReadableStream({start:r=>{s=new eu(r,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}streamText(...t){const e=t;let s;return Nt(new ReadableStream({start:r=>{s=new tu(r,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}forEach(...t){const e=t;let s;return Nt(new ReadableStream({start:r=>{s=new su(r,e),this.finished||this.handles.add(s),s.update(this.args),this.finished&&s.end()},cancel:()=>{s&&(s.dispose(),this.handles.delete(s))}}))}},nu=class{constructor(t){m(this,"promise");this.promise=t}get(){return this.promise}},iu=class{constructor(){m(this,"args");m(this,"response");m(this,"writable");m(this,"resolve");m(this,"argsText","");m(this,"result",{get:async()=>(await this.response.get()).result});const t=new TransformStream;this.writable=t.writable,this.args=new ru(t.readable);const{promise:e,resolve:s}=ws();this.resolve=s,this.response=new nu(e)}async appendArgsTextDelta(t){const e=this.writable.getWriter();try{await e.write(t)}catch(s){console.warn(s)}finally{e.releaseLock()}this.argsText+=t}async finishArgsText(){const t=this.writable.getWriter();try{await t.close()}catch(e){console.warn(e)}finally{t.releaseLock()}}setResponse(t){this.resolve(t)}},ou=class extends Ll{constructor(t){const e=new Map,s=new Map;super(r=>{const n=new TransformStream({async transform(i,o){switch((i.type!=="part-finish"||i.meta.type!=="tool-call")&&o.enqueue(i),i.type){case"part-start":if(i.part.type==="tool-call"){const a=new iu;s.set(i.part.toolCallId,a),t.streamCall({reader:a,toolCallId:i.part.toolCallId,toolName:i.part.toolName})}break;case"text-delta":if(i.meta.type==="tool-call"){const a=i.meta.toolCallId,c=s.get(a);if(!c)throw new Error("No controller found for tool call");await c.appendArgsTextDelta(i.textDelta)}break;case"result":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,c=s.get(a);if(!c)throw new Error("No controller found for tool call");c.setResponse(new ve({result:i.result,artifact:i.artifact,isError:i.isError,modelContent:i.modelContent}));break}case"tool-call-args-text-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a,toolName:c}=i.meta,l=s.get(a);if(!l)throw new Error("No controller found for tool call");await l.finishArgsText();let u=!1;const h=Xl(()=>{var g;let d;try{d=Zt.parse(l.argsText)}catch(b){throw new Error(`Function parameter parsing failed. ${JSON.stringify(b.message)}`)}const f=t.execute({toolCallId:a,toolName:c,args:d});return f!==void 0&&(u=!0,(g=t.onExecutionStart)==null||g.call(t,a,c)),f},d=>{var g;if(u&&((g=t.onExecutionEnd)==null||g.call(t,a,c)),d===void 0)return;const f=new ve({artifact:d.artifact,result:d.result,isError:d.isError,messages:d.messages,modelContent:d.modelContent});l.setResponse(f),o.enqueue({type:"result",path:i.path,...f})},d=>{var g;u&&((g=t.onExecutionEnd)==null||g.call(t,a,c));const f=new ve({result:String(d),isError:!0});l.setResponse(f),o.enqueue({type:"result",path:i.path,...f})});h&&e.set(a,h);break}case"part-finish":{if(i.meta.type!=="tool-call")break;const{toolCallId:a}=i.meta,c=e.get(a);c?c.then(()=>{e.delete(a),s.delete(a),o.enqueue(i)}):o.enqueue(i)}}},async flush(){await Promise.all(e.values())}});return r.pipeThrough(new qn).pipeThrough(n)})}};const au=t=>typeof t=="object"&&t!==null&&"~standard"in t&&t["~standard"].version===1;function cu(t,e,s,r){const n=t==null?void 0:t[s.toolName];return n!=null&&n.execute?(async o=>{if(e.aborted)return new ve({result:"Tool execution was cancelled.",isError:!0});let a=o;if(au(n.parameters)){let u=n.parameters["~standard"].validate(s.args);u instanceof Promise&&(u=await u),u.issues&&(a=n.experimental_onSchemaValidationError??(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(u.issues)}`)}))}const c=new Promise(u=>{const h=()=>{queueMicrotask(()=>{queueMicrotask(()=>{u(new ve({result:"Tool execution was cancelled.",isError:!0}))})})};e.aborted?h():e.addEventListener("abort",h,{once:!0})}),l=(async()=>{const u=await a(s.args,{toolCallId:s.toolCallId,abortSignal:e,human:d=>r(s.toolCallId,d)}),h=ve.toResponse(u);if(n.toModelOutput&&!h.isError&&h.modelContent===void 0)try{const d=await n.toModelOutput({toolCallId:s.toolCallId,input:s.args,output:h.result});return new ve({result:h.result,artifact:h.artifact,isError:h.isError,messages:h.messages,modelContent:d})}catch(d){console.warn(`[assistant-stream] tool "${s.toolName}" toModelOutput threw; falling back to default projection.`,d)}return h})();return Promise.race([l,c])})(n.execute):void 0}function lu(t,e,s,r,n){var i,o;(o=(i=t==null?void 0:t[r.toolName])==null?void 0:i.streamCall)==null||o.call(i,s,{toolCallId:r.toolCallId,abortSignal:e,human:a=>n(r.toolCallId,a)})}function uu(t,e,s,r){const n=typeof t=="function"?t:()=>t,i=typeof e=="function"?e:()=>e;return new ou({execute:o=>cu(n(),i(),o,s),streamCall:({reader:o,...a})=>lu(n(),i(),o,a,s),onExecutionStart:r==null?void 0:r.onExecutionStart,onExecutionEnd:r==null?void 0:r.onExecutionEnd})}let du=(t,e=21)=>(s=e)=>{let r="",n=s|0;for(;n-- >0;)r+=t[Math.random()*t.length|0];return r};const Ae=du("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),Wn=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"message",query:{type:"index",index:s},get:c=>c.message().attachment({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={attachment:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},Qn=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"composer",query:{type:"index",index:s},get:c=>c.composer().attachment({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={attachment:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},Yn=t=>{const e=_(10),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"thread",query:{type:"index",index:s},get:l=>l.thread().message({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==s?(i=re({source:"message",query:{},get:l=>l.thread().message({index:s}).composer()}),e[2]=s,e[3]=i):i=e[3];let o;e[4]!==n||e[5]!==i?(o={message:n,composer:i},e[4]=n,e[5]=i,e[6]=o):o=e[6];const a=F(o);let c;return e[7]!==a||e[8]!==r?(c=p.jsx(ue,{value:a,children:r}),e[7]=a,e[8]=r,e[9]=c):c=e[9],c},Cs=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"message",query:{type:"index",index:s},get:c=>c.message().part({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={part:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},hu=t=>{const e=_(7),{text:s,isRunning:r}=t;let n;e[0]!==r?(n=r?{type:"running"}:{type:"complete"},e[0]=r,e[1]=n):n=e[1];let i;e[2]!==n||e[3]!==s?(i={type:"text",text:s,status:n},e[2]=n,e[3]=s,e[4]=i):i=e[4];const o=i;let a;return e[5]!==o?(a={getState:()=>o,addToolResult:pu,resumeToolCall:gu,respondToToolApproval:mu},e[5]=o,e[6]=a):a=e[6],a},fu=q(hu),Is=t=>{const e=_(8),{text:s,isRunning:r,children:n}=t,i=r===void 0?!1:r;let o;e[0]!==i||e[1]!==s?(o=fu({text:s,isRunning:i}),e[0]=i,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==o?(a={part:o},e[3]=o,e[4]=a):a=e[4];const c=F(a);let l;return e[5]!==c||e[6]!==n?(l=p.jsx(ue,{value:c,children:n}),e[5]=c,e[6]=n,e[7]=l):l=e[7],l};function pu(){throw new Error("Not supported")}function gu(){throw new Error("Not supported")}function mu(){throw new Error("Not supported")}const bu=Object.freeze({type:"complete"}),_u=t=>{var h;const e=_(9),{parts:s,getMessagePart:r}=t,[n,i]=G(!0),o=((h=s[s.length-1])==null?void 0:h.status)??bu;let a;e[0]!==n||e[1]!==s||e[2]!==o?(a={parts:s,collapsed:n,status:o},e[0]=n,e[1]=s,e[2]=o,e[3]=a):a=e[3];const c=a;let l;e[4]!==c?(l=()=>c,e[4]=c,e[5]=l):l=e[5];let u;return e[6]!==r||e[7]!==l?(u={getState:l,setCollapsed:i,part:r},e[6]=r,e[7]=l,e[8]=u):u=e[8],u},yu=q(_u),vu=t=>{const e=_(5),{startIndex:s,endIndex:r,children:n}=t,i=P(Su).slice(s,r+1),o=F(),a=yu({parts:i,getMessagePart:h=>{const{index:d}=h;if(d<0||d>=i.length)throw new Error(`ChainOfThought part index ${d} is out of bounds (0..${i.length-1})`);return o.message().part({index:s+d})}});let c;e[0]!==a?(c={chainOfThought:a},e[0]=a,e[1]=c):c=e[1];const l=F(c);let u;return e[2]!==l||e[3]!==n?(u=p.jsx(ue,{value:l,children:n}),e[2]=l,e[3]=n,e[4]=u):u=e[4],u};function Su(t){return t.message.parts}const Jn=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"suggestions",query:{index:s},get:c=>c.suggestions().suggestion({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={suggestion:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},xu=t=>{const e=_(7),{index:s,children:r}=t;let n;e[0]!==s?(n=re({source:"composer",query:{index:s},get:c=>c.composer().queueItem({index:s})}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==n?(i={queueItem:n},e[2]=n,e[3]=i):i=e[3];const o=F(i);let a;return e[4]!==o||e[5]!==r?(a=p.jsx(ue,{value:o,children:r}),e[4]=o,e[5]=r,e[6]=a):a=e[6],a},Me=Symbol("innerMessage"),Ft=Symbol("innerMessages"),wu=[],Tu=(t,e)=>{Me in t||(t[Me]=e)},Cu=t=>{const e="messages"in t?t.messages:t,s=e[Ft]||e[Me];return s?Array.isArray(s)?s:(e[Ft]=[s],e[Ft]):wu},de=Symbol("skip-update");function Iu(t,e){if(t===void 0&&e===void 0)return!0;if(t===void 0||e===void 0)return!1;for(const s of Object.keys(t)){const r=t[s],n=e[s];if(!Object.is(r,n))return!1}return!0}var Eu=class{constructor(){m(this,"_subscribers",new Set)}subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}waitForUpdate(){return new Promise(t=>{const e=this.subscribe(()=>{e(),t()})})}_notifySubscribers(){const t=[];for(const e of this._subscribers)try{e()}catch(s){t.push(s)}if(t.length>0){if(t.length===1)throw t[0];for(const e of t)console.error(e);throw new AggregateError(t)}}},$t=class{constructor(){m(this,"_subscriptions",new Set);m(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(t){for(const e of this._subscriptions)e(t)}_updateConnection(){var t;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(t=this._connection)==null||t.call(this),this._connection=void 0}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},ce=class extends $t{constructor(e){super();m(this,"binding");m(this,"_previousState");m(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=e;const s=e.getState();if(s===de)throw new Error("Entry not available in the store");this._previousState=s}get path(){return this.binding.path}_syncState(){const e=this.binding.getState();return e===de||Iu(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){const e=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(e)}},Es=class extends $t{constructor(e){super();m(this,"binding");m(this,"_previousStateDirty",!0);m(this,"_previousState");m(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const e=this.binding.getState();e!==de&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=e}get path(){return this.binding.path}_connect(){const e=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(e)}},St=class extends $t{constructor(e){super();m(this,"binding");this.binding=e}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){const e=()=>{this.notifySubscribers()};let s=this.binding.getState(),r=s==null?void 0:s.subscribe(e);const n=()=>{const o=this.binding.getState();o!==s&&(s=o,r==null||r(),r=o==null?void 0:o.subscribe(e),e())},i=this.outerSubscribe(n);return()=>{i==null||i(),r==null||r()}}},Xn=class extends $t{constructor(e){super();m(this,"config");this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){const e=o=>{this.notifySubscribers(o)};let s=this.config.binding.getState(),r=s==null?void 0:s.unstable_on(this.config.event,e);const n=()=>{const o=this.config.binding.getState();o!==s&&(s=o,r==null||r(),r=o==null?void 0:o.unstable_on(this.config.event,e))},i=this.outerSubscribe(n);return()=>{i==null||i(),r==null||r()}}},Zn=class{constructor(t){m(this,"_core");this._core=t,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(t){return this._core.subscribe(t)}},ei=class extends Zn{constructor(e,s){super(e);m(this,"_composerApi");this._composerApi=s}remove(){const e=this._composerApi.getState();if(!e)throw new Error("Composer is not available");return e.removeAttachment(this.getState().id)}},Ru=class extends ei{get source(){return"thread-composer"}},Au=class extends ei{get source(){return"edit-composer"}},Mu=class extends Zn{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const xt=Object.freeze([]),ti=Object.freeze({}),Pu=t=>Object.freeze({type:"thread",isEditing:(t==null?void 0:t.isEditing)??!1,canCancel:(t==null?void 0:t.canCancel)??!1,canSend:(t==null?void 0:t.canSend)??!1,isEmpty:(t==null?void 0:t.isEmpty)??!0,attachments:(t==null?void 0:t.attachments)??xt,text:(t==null?void 0:t.text)??"",role:(t==null?void 0:t.role)??"user",runConfig:(t==null?void 0:t.runConfig)??ti,attachmentAccept:(t==null?void 0:t.attachmentAccept)??"",dictation:t==null?void 0:t.dictation,quote:t==null?void 0:t.quote,queue:(t==null?void 0:t.queue)??xt,value:(t==null?void 0:t.text)??""}),ku=t=>Object.freeze({type:"edit",isEditing:(t==null?void 0:t.isEditing)??!1,canCancel:(t==null?void 0:t.canCancel)??!1,canSend:(t==null?void 0:t.canSend)??!1,isEmpty:(t==null?void 0:t.isEmpty)??!0,text:(t==null?void 0:t.text)??"",role:(t==null?void 0:t.role)??"user",attachments:(t==null?void 0:t.attachments)??xt,runConfig:(t==null?void 0:t.runConfig)??ti,attachmentAccept:(t==null?void 0:t.attachmentAccept)??"",dictation:t==null?void 0:t.dictation,quote:t==null?void 0:t.quote,queue:(t==null?void 0:t.queue)??xt,parentId:(t==null?void 0:t.parentId)??null,sourceId:(t==null?void 0:t.sourceId)??null,value:(t==null?void 0:t.text)??""});var si=class{constructor(t){m(this,"_core");m(this,"_eventSubscriptionSubjects",new Map);this._core=t}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setText(t)}setRunConfig(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRunConfig(t)}addAttachment(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.addAttachment(t)}reset(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.reset()}clearAttachments(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.clearAttachments()}send(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.send(t)}cancel(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.cancel()}steerQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.steerQueueItem(t)}removeQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.removeQueueItem(t)}setRole(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRole(t)}startDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.startDictation()}stopDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.stopDictation()}setQuote(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setQuote(t)}subscribe(t){return this._core.subscribe(t)}unstable_on(t,e){let s=this._eventSubscriptionSubjects.get(t);return s||(s=new Xn({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,s)),s.subscribe(e)}},$u=class extends si{constructor(e){const s=new Es({path:e.path,getState:()=>Pu(e.getState()),subscribe:r=>e.subscribe(r)});super({path:e.path,getState:()=>e.getState(),subscribe:r=>s.subscribe(r)});m(this,"_getState");this._getState=s.getState.bind(s),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(e){return new Ru(new ce({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{const s=this.getState().attachments[e];return s?{...s,source:"thread-composer"}:de},subscribe:s=>this._core.subscribe(s)}),this._core)}},Du=class extends si{constructor(e,s){const r=new Es({path:e.path,getState:()=>ku(e.getState()),subscribe:n=>e.subscribe(n)});super({path:e.path,getState:()=>e.getState(),subscribe:n=>r.subscribe(n)});m(this,"_beginEdit");m(this,"_getState");this._beginEdit=s,this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new Au(new ce({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{const s=this.getState().attachments[e];return s?{...s,source:"edit-composer"}:de},subscribe:s=>this._core.subscribe(s)}),this._core)}};const et=t=>t.content.filter(e=>e.type==="text").map(e=>e.text).join(`
4
4
 
@@ -207,7 +207,7 @@ ${n("project:fileTruncated")}`:""]})]}):s.jsx("p",{children:n("project:noNodeFil
207
207
  </body>
208
208
  </html>`}const GL=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),MY=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function LY(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const i=n.slice(r+2);return i.includes("}")?null:{atIndex:r,query:i}}function $Y(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function cA(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function YL(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const i=r.slice(6).trim();return i!==""&&t.has(i)}if(r.startsWith("output.")){const i=r.slice(7).trim();return i!==""&&n.has(i)}if(GL.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const i=`${r}.md`;if(t.has(i)||n.has(i))return!0}return!1}function JL(e){return{inputNames:cA(e==null?void 0:e.inputs),outputNames:cA(e==null?void 0:e.outputs)}}function OY(e,t,n){const r=JL(t),i=$Y(e),o=[];for(const a of i)if(!YL(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function DY(e,t){const n=JL(t),r=/\$\{([^}]*)\}/g,i=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&i.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=YL(a[1],n);i.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&i.push({kind:"plain",text:e.slice(o)}),i}function FY(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function zY(e){return e.map(t=>{const n=FY(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function WY(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const i=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!i)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${i}`,label:i,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const i=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!i)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${i}`,label:i,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of MY)GL.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function BY(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function HY(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),i=document.createElement("div");i.setAttribute("aria-hidden","true"),i.style.visibility="hidden",i.style.position="fixed",i.style.top="0",i.style.left="-99999px",i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word",i.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;i.style.width=`${o}px`,i.style.font=r.font,i.style.lineHeight=r.lineHeight,i.style.padding=r.padding,i.style.border=r.border,i.style.boxSizing=r.boxSizing,i.style.letterSpacing=r.letterSpacing,i.style.textIndent=r.textIndent,i.style.tabSize=r.tabSize||"8",i.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",i.appendChild(a),document.body.appendChild(i);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(i),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function jh({value:e,onChange:t,disabled:n,placeholder:r,rows:i=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:p}=Ur(),f=h.useId(),d=h.useRef(null),m=h.useRef(null),[y,v]=h.useState(0),[b,g]=h.useState(0),[k,x]=h.useState(null),C=h.useMemo(()=>Io(c),[c]),N=h.useMemo(()=>OY(e,a,p),[e,a,p]),_=N.length>0,I=h.useMemo(()=>DY(e,a),[e,a]),L=h.useMemo(()=>zY(I),[I]),K=h.useMemo(()=>n?null:LY(e,y),[e,y,n]),E=h.useMemo(()=>{if(!K)return[];const P=WY(a,p);return BY(P,K.query)},[K,a,p]);h.useEffect(()=>{g(P=>{const $=Math.max(0,E.length-1);return Math.min(Math.max(0,P),$)})},[E.length]);const W=h.useCallback(()=>{const P=d.current;if(!P||!K||E.length===0){x(null);return}const $=HY(P,y);if(!$){x(null);return}const O=4,q=44,T=13.5*16,te=Math.min(E.length*q+8,T);let U=$.bottom+O;U+te>window.innerHeight-8&&(U=Math.max(8,$.top-te-O));const M=288;let Z=$.left;Z=Math.max(8,Math.min(Z,window.innerWidth-M-8)),x({top:U,left:Z})},[K,E.length,y]);h.useLayoutEffect(()=>{if(!K||E.length===0){x(null);return}const P=requestAnimationFrame(()=>W());return()=>cancelAnimationFrame(P)},[K,E.length,y,e,W]),h.useEffect(()=>{if(!K||E.length===0)return;const P=()=>W();return window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[K,E.length,W]);const z=h.useCallback(P=>{if(!K)return;const{atIndex:$}=K,O=e.slice(0,$)+"${"+P+"}"+e.slice(y);t(O);const q=$+P.length+3;queueMicrotask(()=>{const T=d.current;T&&(T.focus(),T.setSelectionRange(q,q)),v(q)})},[K,e,y,t]),B=h.useCallback(()=>{const P=d.current,$=m.current;!P||!$||($.scrollTop=P.scrollTop,$.scrollLeft=P.scrollLeft,K&&E.length>0&&queueMicrotask(()=>W()))},[K,E.length,W]),D=h.useCallback(P=>{if(!n&&K&&E.length>0&&(P.key==="ArrowDown"||P.key==="ArrowUp"||P.key==="Enter")){if(P.key==="ArrowDown")P.preventDefault(),g($=>($+1)%E.length);else if(P.key==="ArrowUp")P.preventDefault(),g($=>($-1+E.length)%E.length);else if(P.key==="Enter"&&!P.shiftKey){P.preventDefault();const $=E[b];$&&z($.insert)}}},[n,K,E,b,z]),H=h.useCallback(async P=>{if(n||typeof u!="function")return!1;const $=await VL({files:P,body:e,images:C});return $?(t($.body),u($.images),queueMicrotask(()=>{const O=d.current;if(!O)return;O.focus();const q=$.body.length;O.setSelectionRange(q,q),v(q)}),!0):!1},[n,C,t,u,e]);return s.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[C.length>0?s.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:C.map((P,$)=>s.jsxs("span",{className:"af-body-image-chip",title:P.name,children:[s.jsx("img",{src:P.dataUrl,alt:""}),s.jsxs("span",{children:["[",P.label||`image ${$+1}`,"]"]})]},P.id||$))}):null,s.jsxs("div",{className:"af-body-prompt-stack",children:[s.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:L+`
209
209
  `}}),s.jsx("textarea",{ref:d,className:"af-body-prompt-textarea "+o,rows:i,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":_,"aria-describedby":_?f:void 0,onChange:P=>{t(P.target.value),v(P.target.selectionStart??P.target.value.length)},onSelect:P=>{const $=P.target;$ instanceof HTMLTextAreaElement&&v($.selectionStart??0)},onClick:P=>{const $=P.target;$ instanceof HTMLTextAreaElement&&v($.selectionStart??0)},onKeyUp:P=>{const $=P.target;$ instanceof HTMLTextAreaElement&&v($.selectionStart??$.value.length)},onKeyDown:D,onPaste:P=>{const $=KL(P);$.length!==0&&(P.preventDefault(),H($).catch(()=>{}))},onDragOver:P=>{Qd(P).length>0&&P.preventDefault()},onDrop:P=>{const $=Qd(P);$.length!==0&&(P.preventDefault(),H($).catch(()=>{}))},onScroll:B})]}),K&&E.length>0&&k?ar.createPortal(s.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:E.map((P,$)=>s.jsx("li",{role:"option","aria-selected":$===b,children:s.jsxs("button",{type:"button",className:"af-composer-mention-item"+($===b?" af-composer-mention-item--active":""),onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>g($),onClick:()=>z(P.insert),children:[s.jsx("span",{className:"af-composer-mention-id",children:`\${${P.insert}}`}),P.subtitle?s.jsx("span",{className:"af-composer-mention-sub",children:P.subtitle}):null]})},`${P.section}-${P.insert}`))}),document.body):null,_?s.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:N.map(P=>P.message).join(" · ")}):null]})}const KY=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function md(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function uA({kind:e,label:t,slots:n,onSlotsChange:r,disabled:i,requiredReadonly:o=!0}){const{t:a}=Ur(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((d,m)=>m!==f)),u=(f,d,m)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[d]:m};return d==="required"&&m===!0&&(g.showOnNode=!0),g});r(y)},p=e==="input"?"input":"output";return s.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[s.jsxs("div",{className:"af-node-props-io-head",children:[s.jsx("span",{className:"af-node-props-label",children:t}),s.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:i,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),s.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?s.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?s.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[s.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[s.jsx("span",{children:a("flow:nodeProps.handle")}),s.jsx("span",{children:a("flow:nodeProps.type")}),s.jsx("span",{children:a("flow:nodeProps.name")}),s.jsx("span",{children:a("flow:nodeProps.defaultValue")}),s.jsx("span",{children:a("flow:nodeProps.description")}),s.jsx("span",{children:a("flow:nodeProps.required")}),s.jsx("span",{children:a("flow:nodeProps.showOnNode")}),s.jsx("span",{})]}),n.map((f,d)=>s.jsxs("div",{className:"af-node-props-io-row",children:[s.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${d}`,children:[p,"-",d]}),s.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:m=>u(d,"type",m.target.value),disabled:i,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:d}),children:["node","text","file","bool"].map(m=>s.jsx("option",{value:m,children:m},m))}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:m=>u(d,"name",m.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:d})}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:m=>u(d,"default",m.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:d})}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:m=>u(d,"description",m.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:d})}),s.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:s.jsx("input",{type:"checkbox",checked:!!f.required,onChange:m=>{o||u(d,"required",m.target.checked)},disabled:i||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:d})})}),s.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:s.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:m=>u(d,"showOnNode",m.target.checked),disabled:i,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:d})})}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(d),disabled:i,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:d}),title:a("flow:nodeProps.deletePin"),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${d}`))]}):null]})}function VY({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:i,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:p,ioSlots:f}){const{t:d}=Ur(),[m,y]=h.useState(!1),[v,b]=h.useState(!1),[g,k]=h.useState({status:"idle",message:""}),x=h.useCallback(B=>{t(D=>D&&{...D,...B})},[t]),{cursorList:C,opencodeList:N,claudeCodeList:_,codexList:I,currentNotInLists:L}=h.useMemo(()=>{const B=Array.isArray(i==null?void 0:i.cursor)?i.cursor:[],D=Array.isArray(i==null?void 0:i.opencode)?i.opencode:[],H=Array.isArray(i==null?void 0:i.claudeCode)?i.claudeCode:[],P=Array.isArray(i==null?void 0:i.codex)?i.codex:[],$=new Set([...B,...D,...H,...P].map(md)),O=((e==null?void 0:e.model)??"").trim(),q=O.startsWith("cursor:")?O.slice(7):O.startsWith("opencode:")?O.slice(9):O.startsWith("codex:")?O.slice(6):O.startsWith("claude-code:")?O.slice(12):O,T=O&&!$.has(q)?O:"";return{cursorList:B,opencodeList:D,claudeCodeList:H,codexList:P,currentNotInLists:T}},[i,e==null?void 0:e.model]);if(!e)return null;const K=String(e.script??""),E=n==="tool_nodejs"||K.trim()!=="",W=typeof c=="function"&&!o&&(e==null?void 0:e.newId),z=async()=>{if(W){k({status:"running",message:d("flow:nodeProps.publishRunning")});try{const B=await c(e,n);k({status:"success",message:B!=null&&B.definitionId?d("flow:nodeProps.publishSuccessWithId",{id:B.definitionId}):d("flow:nodeProps.publishSuccess")})}catch(B){k({status:"error",message:String((B==null?void 0:B.message)||B)})}}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:d("flow:nodeProps.title")}),s.jsxs("div",{className:"af-node-props-head-actions",children:[s.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:z,disabled:!W||g.status==="running",title:d("flow:nodeProps.publishToMarketplaceHint"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?d("flow:nodeProps.publishing"):d("flow:nodeProps.publishToMarketplace")]}),s.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:d("common:common.close")})]})]}),s.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?s.jsx("p",{className:"af-err af-node-props-err",children:p}):null,g.message?s.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.nodeType")}),s.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:nodeProps.instanceId"),s.jsx("span",{className:"af-node-props-hint",children:d("flow:node.displayNameHint")})]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:B=>x({newId:B.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":d("flow:nodeProps.instanceId")})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.displayName"),"(LABEL)"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:B=>x({label:B.target.value}),disabled:o,spellCheck:!1})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.role"),"(ROLE)"]}),s.jsx("select",{className:"af-node-props-select",value:If.includes(e.role)?e.role:d("flow:roles.normal"),onChange:B=>x({role:B.target.value}),disabled:o,children:If.map(B=>s.jsx("option",{value:B,children:B},B))})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.model"),"(MODEL)"]}),s.jsx("span",{className:"af-node-props-sublabel",children:d("flow:node.modelHint")}),s.jsxs("select",{className:"af-node-props-select",value:(()=>{const B=(e.model||"").trim();return B?L||B:""})(),onChange:B=>x({model:B.target.value}),disabled:o,"aria-label":d("flow:nodeProps.modelAriaLabel"),children:[s.jsx("option",{value:"",children:d("flow:node.defaultModel")}),L?s.jsxs("option",{value:L,children:[L,d("flow:nodeProps.yamlValueNotInList")]}):null,C.length>0?s.jsx("optgroup",{label:"Cursor",children:C.map(B=>s.jsx("option",{value:md(B),children:B},`c-${B}`))}):null,N.length>0?s.jsx("optgroup",{label:"OpenCode",children:N.map(B=>s.jsx("option",{value:`opencode:${md(B)}`,children:B},`o-${B}`))}):null,I.length>0?s.jsx("optgroup",{label:"Codex",children:I.map(B=>s.jsx("option",{value:`codex:${md(B)}`,children:B},`codex-${B}`))}):null,_.length>0?s.jsx("optgroup",{label:"Claude Code",children:_.map(B=>s.jsx("option",{value:`claude-code:${md(B)}`,children:B},`cc-${B}`))}):null]})]}),s.jsx(uA,{kind:"input",label:d("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:B=>x({inputs:B}),disabled:o,requiredReadonly:!u}),s.jsx(uA,{kind:"output",label:d("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:B=>x({outputs:B}),disabled:o,requiredReadonly:!u}),E?s.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[s.jsxs("div",{className:"af-node-props-prompt-head",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.directCommand"),"(script)",s.jsx("span",{className:"af-node-props-hint",children:d("flow:node.scriptHint")})]}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":d("flow:nodeProps.expandEditScript"),title:d("flow:nodeProps.expand"),disabled:o,children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),s.jsx(jh,{value:K,onChange:B=>x({script:B}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:f,variant:"drawer"})]}):null,s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),s.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:B=>x({scriptRef:B.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),s.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:B=>x({implementationRef:B.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),s.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:B=>x({implementationMode:B.target.value}),disabled:o,children:[s.jsx("option",{value:"",children:"auto"}),s.jsx("option",{value:"script",children:"script"}),s.jsx("option",{value:"steps",children:"steps"}),s.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),s.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[s.jsxs("div",{className:"af-node-props-prompt-head",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.userPrompt")}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":d("flow:nodeProps.expandEdit"),title:d("flow:nodeProps.expand"),disabled:o,children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),s.jsx(jh,{value:e.body,onChange:B=>x({body:B}),images:e.images,onImagesChange:B=>x({images:B}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.systemDescription")}),s.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||d("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?s.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editScript"),onMouseDown:B=>{B.target===B.currentTarget&&b(!1)},children:s.jsxs("div",{className:"af-node-props-expand-panel",children:[s.jsxs("div",{className:"af-node-props-expand-head",children:[s.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.directCommand")}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":d("flow:nodeProps.collapse"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx(jh,{value:K,onChange:B=>x({script:B}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,m?s.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editUserPrompt"),onMouseDown:B=>{B.target===B.currentTarget&&y(!1)},children:s.jsxs("div",{className:"af-node-props-expand-panel",children:[s.jsxs("div",{className:"af-node-props-expand-head",children:[s.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.body")}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":d("flow:nodeProps.collapse"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx(jh,{value:e.body,onChange:B=>x({body:B}),images:e.images,onImagesChange:B=>x({images:B}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function qY({open:e,onClose:t,flowId:n,flowSource:r,onArchived:i}){const{t:o}=Ur(),a=h.useId(),l=h.useRef(null),[c,u]=h.useState(""),[p,f]=h.useState(!1),[d,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;u(""),m(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||p)){f(!0),m("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){m(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}i()}catch(k){m(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:s.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),s.jsxs("label",{className:"af-new-pipeline-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),s.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),d?s.jsx("p",{className:"af-err af-new-pipeline-err",children:d}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:o("project:archiveModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||p,children:o(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function UY({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:i=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Ur(),u=h.useId(),p=h.useRef(null),[f,d]=h.useState(""),[m,y]=h.useState(!1),[v,b]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),b(""),y(!1);const C=requestAnimationFrame(()=>{var N;return(N=p.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(C)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(C){if(C.preventDefault(),!k||m)return;y(!0),b("");let N=null;try{const _=new AbortController;N=setTimeout(()=>_.abort(),15e3);const I=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:i,workspaceId:o}),signal:_.signal}),L=await I.json().catch(()=>({}));if(!I.ok){b(typeof L.error=="string"?L.error:c("project:deleteModal.deleteFailed"));return}try{for(let K=localStorage.length-1;K>=0;K--){const E=localStorage.key(K);E&&(E.startsWith(`af:composer-sessions:${n}:${r}`)||E.startsWith(`af:composer-active-session:${n}:${r}`)||E.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(E)}}catch{}await l()}catch(_){if((_==null?void 0:_.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((_==null?void 0:_.message)||_))}finally{N&&clearTimeout(N),y(!1)}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&t()},children:s.jsxs("div",{ref:p,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:x,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:s.jsxs("label",{className:"af-new-pipeline-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),s.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:C=>d(C.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?s.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:m,children:c("project:deleteModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||m,children:m?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const dA=80,GY=220;function YY(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:i,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function JY(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Sh(e,t,n){const r={nodes:Array.isArray(e)?e.map(YY):[],edges:Array.isArray(t)?t.map(JY):[],extra:n&&typeof n=="object"?n:{}},i=JSON.stringify(r);return{value:JSON.parse(i),signature:i}}function Ex(e,t){const n=[...e,t];return n.length>dA?n.slice(n.length-dA):n}function XY({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:i}){const[o,a]=h.useState(0),l=h.useRef([]),c=h.useRef([]),u=h.useRef(null),p=h.useRef(null),f=h.useRef(null),d=h.useRef(null),m=h.useRef(!1),y=h.useCallback(()=>a(N=>N+1),[]),v=h.useCallback(()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},[]),b=h.useCallback(()=>{v();const N=p.current,_=f.current;return p.current=null,f.current=null,!N||!_||N.signature===_.signature?(_&&(u.current=_),!1):(l.current=Ex(l.current,N),c.current=[],u.current=_,y(),!0)},[y,v]),g=h.useCallback((N=[],_=[],I={})=>{v(),l.current=[],c.current=[],p.current=null,f.current=null,u.current=Sh(N,_,I),m.current=!1,y()},[y,v]),k=h.useCallback(N=>{m.current=!0,u.current=N,p.current=null,f.current=null,v(),i==null||i(N.value),y()},[y,v,i]),x=h.useCallback(()=>{b();const N=u.current||Sh(e,t,n),_=l.current.pop();return _?(c.current=Ex(c.current,N),k(_),!0):(y(),!1)},[y,t,n,b,e,k]),C=h.useCallback(()=>{b();const N=u.current||Sh(e,t,n),_=c.current.pop();return _?(l.current=Ex(l.current,N),k(_),!0):(y(),!1)},[y,t,n,b,e,k]);return h.useEffect(()=>()=>v(),[v]),h.useEffect(()=>{if(!r)return;const N=Sh(e,t,n);if(!u.current){u.current=N;return}if(m.current){m.current=!1,u.current=N;return}N.signature!==u.current.signature&&(p.current||(p.current=u.current),f.current=N,v(),d.current=window.setTimeout(()=>{b()},GY))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:C,version:o}}function No(e){return String(e??"").trim()}function fA(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(No(e).toLowerCase())}function QY(e){return e===!1?!0:["false","no","not_required","waived"].includes(No(e).toLowerCase())}function ZY(e,t=""){return No((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||t)}function XL(e){return No((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function QL(e){return XL(e)==="all"}function eJ(e,t=[]){const n=No((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||(e==null?void 0:e.parent));if(n)return n;const r=XL(e),i=ZY(e);if(!i||!["android","ios"].includes(r))return"";const o=`-${r}`;if(!i.endsWith(o))return"";const a=i.slice(0,-o.length);return new Set(t.map(l=>No(l))).has(a)?a:""}function ng(e){const t=No(e==null?void 0:e.label).toLowerCase(),n=No((e==null?void 0:e.href)||(e==null?void 0:e.url)).toLowerCase();return/\/merge_requests\/\d+/.test(n)||/\bmr\b|merge request|合并请求|实现 mr|修复 mr|提测 mr|集成 mr/i.test(t)?"mr":/\/issues\/\d+/.test(n)||/gitlab issue/i.test(t)?"issue":"other"}function tJ(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[ng(n)]-t[ng(r)])}function nJ(e){const t=No((e==null?void 0:e.noMrReason)||(e==null?void 0:e.no_mr_reason)||(e==null?void 0:e.mrWaiverReason)||(e==null?void 0:e.mr_waiver_reason)||(e==null?void 0:e.implementationNotRequiredReason)||(e==null?void 0:e.implementation_not_required_reason));return/user confirmed self-test completion without implementation mr evidence/i.test(t)?"自测确认,无需实现 MR":t}function rJ(e,t=[]){if(QL(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(ng);if(n.includes("mr"))return{kind:"linked",label:"MR 已关联",detail:""};const r=(e==null?void 0:e.mrRequired)??(e==null?void 0:e.mr_required)??(e==null?void 0:e.requiresMr)??(e==null?void 0:e.requires_mr);return fA(e==null?void 0:e.implementationNotRequired)||fA(e==null?void 0:e.implementation_not_required)||QY(r)?{kind:"not-required",label:nJ(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function Tk(e=[]){return e.reduce((t,n)=>t+1+Tk(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function Ir(e){return String(e||"").trim()}function sa(e){return Ir(e).toLowerCase()}function rg(e){return typeof e=="string"?sa(e):!e||typeof e!="object"||Array.isArray(e)?"":sa(e.kind||e.type||e.persistence||e.durability)}function ZL(e,t="http://localhost"){const n=Ir(e);if(!n)return"";try{const r=new URL(n,t);return r.origin==="null"?`${r.protocol}//${r.host}${r.pathname}`:`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function e2(e={}){const t=Ir(e.href||e.url);if(!t)return!1;const n=sa(e.kind||e.type),r=sa(e.durability),i=sa(e.persistence),o=sa(e.truth||e.stateTruth||e.state_truth),a=sa(e.authority),l=rg(e.source)||rg(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(Ir).join(" "),u=[e.label,e.title,n,i,a,l,t].map(Ir).join(" ");if(r==="temporary"||i==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const d=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),m=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||i==="ai-doc"&&d,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return m&&(r==="durable"||m||y)}function t2(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(Ir).join(" ");return/技术方案|tech(?:nical)?[-_ ]?design/i.test(t)?"tech-design":/方案文档|方案已确认|plan(?:[-_ ]?doc)?/i.test(t)?"plan":/代码审查|code[-_ ]?review/i.test(t)?"code-review":/设计文档|design[-_ ]?doc/i.test(t)?"design":"document"}function sJ(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=Ir(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(Ir(t)?Ir(t):t2(e)==="tech-design"&&Ir(n)?Ir(n):Ir(e.title||e.label))}function iJ(e={},t="http://localhost"){const n=Ir(e.issueKey||e.issue_key||e.issue),r=t2(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const i=Ir(e.documentPath||e.document_path||e.path);return i?`path:${i.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${ZL(e.href||e.url,t)}`}function pA(e={}){const t=Ir(e.href||e.url),n=sa(e.kind||e.type),r=rg(e.source)||rg(e.sourceArtifact||e.source_artifact),i=Ir(e.label);let o=0;return e.confirmed===!0&&(o+=100),r==="ai-doc"&&(o+=80),n==="ai-doc"&&(o+=70),/^https?:\/\//i.test(t)&&(o+=30),/\/api\/prd-workflow\/review\//.test(t)&&(o+=20),/预览|review/i.test(i)||(o+=10),o}function oJ(e,t){const n=pA(t)>pA(e)?t:e,r=n===t?e:t;return{...r,...n,title:hA(e.title)>=hA(t.title)?e.title:t.title,issueKey:e.issueKey||t.issueKey,platform:e.platform||t.platform,documentPath:n.documentPath||r.documentPath,source:n.source||r.source}}function hA(e){const t=Ir(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function Ix(e,t){const n=new Map,r=[];for(const i of e){const o=t(i);if(!o){r.push(i);continue}const a=n.get(o);if(a===void 0){n.set(o,r.length),r.push(i);continue}r[a]=oJ(r[a],i)}return r}function aJ(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>e2(o)),r=Ix(n,o=>ZL(o.href||o.url,t)),i=Ix(r,o=>Ir(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return Ix(i,o=>iJ(o,t))}function Yt(e){return String(e||"").trim()}function _o(e){return typeof e=="string"?Yt(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Yt(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function sg(e){return Yt((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function n2(e){return Yt((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function r2(e){const t=Yt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function lJ(e){const t=Yt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return n.hash="",n.searchParams.sort(),n.href}catch{return t.split("#")[0]}}function cJ(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Yt(e.issueKey||e.issue_key||e.issue),n=Yt(e.action||e.actionId||e.action_id),r=Yt(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),i=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Yt(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(i)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function uJ(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Yt(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Yt(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=Yt(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",i=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||i===!1)}function Tf(e){const t=sg(e);if(/^prd-review:/i.test(t)||Yt((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(n2(e)))return!0;const n=Yt((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),i=Yt(e==null?void 0:e.durability).toLowerCase(),o=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||i==="temporary"||i==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function Rk(e){return/^(?:markdown\s+review|review|markdown\s*预览|文档预览|预览)$/i.test(Yt(e))}function dc(e){const t=Yt(e==null?void 0:e.label),n=Yt(e==null?void 0:e.title);return t&&!Rk(t)?t:n&&!Rk(n)?n:t||n}function mA(e){const t=dc(e);if(t&&!Rk(t))return 100;const n=[t,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,_o(e==null?void 0:e.source)].map(Yt).join(" ");return/Markdown Review/i.test(n)?20:/预览|review/i.test(n)?10:0}function gA(e){const t=[],n=sg(e);if(n&&t.push(`key:${n}`),Tf(e)){const i=r2(n2(e));i&&t.push(`review:${i}`)}const r=lJ((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${Yt(e==null?void 0:e.label)}
210
- ${r}`),t}function dJ(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const i=dc(r),o=i&&i!==Yt(r==null?void 0:r.label)?{...r,label:i}:r,a=gA(o),l=a.map(y=>n.get(y)).find(y=>y!=null);if(l==null){a.forEach(y=>n.set(y,t.length)),t.push(o);continue}const c=t[l],u=mA(o)>=mA(c)?dc(o)||dc(c):dc(c)||dc(o),p=!!sg(c),f=!!sg(o),d=p&&!f?c:o,m=d===c?o:c;t[l]={...m,...d,...u?{label:u}:{}},gA(t[l]).forEach(y=>n.set(y,l))}return t}function s2(e){const t=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Yt(e==null?void 0:e.durability).toLowerCase(),r=Yt(e==null?void 0:e.persistence).toLowerCase(),i=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Yt).join(" ");return t==="temporary-review"||n==="temporary"||i==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function fJ(e){if(!Tf(e)||s2(e))return!1;const t=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Yt(e==null?void 0:e.durability).toLowerCase(),r=Yt(e==null?void 0:e.persistence).toLowerCase(),i=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Yt).join(" ");return t==="review"||n==="durable"||i==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function pJ(e){if(Tf(e))return!1;const t=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Yt(e==null?void 0:e.persistence).toLowerCase(),r=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),i=[e==null?void 0:e.label,t].map(Yt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(i)}function hJ(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Yt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function mJ(e=[],t={}){const n=dJ(Array.isArray(e)?e:[]);if(!hJ(t))return n;const r=n.filter(Tf);if(r.length===0)return n;const i=r.filter(fJ),a=i.length>0||n.some(pJ)?i.at(-1):r.filter(s2).at(-1);return n.filter(l=>!Tf(l)||l===a)}function Di(e,t){const n=[],r=new Map,i=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Yt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=r2(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const p=Yt(a.path);return p&&l.push(`path:${p}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=i(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(p=>r.set(p,u));return}n[c]=a,i(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function fs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ig(e){return Array.isArray(e)?e.map(ig):fs(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,ig(e[t])])):e}function yo(e,t){return JSON.stringify(ig(e))===JSON.stringify(ig(t))}function i2(e){return fs(e==null?void 0:e.instances)?e.instances:{}}function Rf(e){return fs(e==null?void 0:e.ui)?e.ui:{}}function Nh(e,t){if(!fs(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function gJ(e,t){if(!fs(e)||!fs(t)||!fs(e.instances)||!fs(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!fs(e.ui)||!fs(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Nh(e,["version","instances","edges","ui"]),r=Nh(t,["version","instances","edges","ui"]);if(!yo(n,r))return!1;const i=["nodePositions","nodeSizes","groups","displayPage","viewport"];return yo(Nh(e.ui,i),Nh(t.ui,i))}function o2(e){const t=Array.isArray(Rf(e).groups)?Rf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function yA(e){const t=new Set(Object.keys(i2(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of o2(e).keys())t.add(n);return t}function wA(e,t){const n=i2(e),r=Rf(e),i=o2(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:fs(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:fs(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:i.get(t)||null}}function xA(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),i=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(i)})}function yJ(e,t){if(!gJ(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...yA(e),...yA(t)]),r=Array.from(n).filter(i=>!yo(wA(e,i),wA(t,i)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!yo(xA(e),xA(t)),displayPageChanged:!yo(Rf(e).displayPage||null,Rf(t).displayPage||null)}}function wJ(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),i=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!i.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function bA(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function kA(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function xJ(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[bA(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const i=n.get(bA(r));return i?yo(kA(i),kA(r))?i:{...r,selected:i.selected===!0}:r})}function bJ(e,t,n){const r=fs(e)?e:{},i=fs(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(i).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}const kJ=160,Zo=72,a2=120,l2=360,_h=28;function vA(e,t){return Number.isFinite(Number(e))?Number(e):t}function ia(e,t){var i,o,a,l;const n=(o=(i=e==null?void 0:e.ui)==null?void 0:i.nodeSizes)==null?void 0:o[t];if(n&&Number.isFinite(n.width)&&Number.isFinite(n.height))return{width:Math.max(80,n.width),height:Math.max(60,n.height)};const r=String(((l=(a=e==null?void 0:e.instances)==null?void 0:a[t])==null?void 0:l.definitionId)||"");return r==="workspace_run"||r==="workspace_scheduled_run"?{width:256,height:156}:r.startsWith("provide_")?{width:220,height:110}:r.startsWith("display_")?{width:496,height:160}:{width:260,height:150}}function jA(e){const t=/-(\d+)$/.exec(String(e||""));return t?Number(t[1]):0}function vJ(e,t){var a,l;const n=(a=e==null?void 0:e.instances)==null?void 0:a[t.source],r=(l=e==null?void 0:e.instances)==null?void 0:l[t.target],i=Array.isArray(n==null?void 0:n.output)?n.output[jA(t.sourceHandle)]:null,o=Array.isArray(r==null?void 0:r.input)?r.input[jA(t.targetHandle)]:null;return(i==null?void 0:i.type)==="node"||(o==null?void 0:o.type)==="node"}function c2(e){const t=[],n=new Set,r=i=>{const o=String(i||"");!o||n.has(o)||(n.add(o),t.push(o))};for(const i of Object.keys((e==null?void 0:e.instances)||{}))r(i);for(const i of(e==null?void 0:e.edges)||[])r(i==null?void 0:i.source),r(i==null?void 0:i.target);return t}function jJ(e,t,n){const r=new Set(t),i=new Map(t.map(f=>[f,new Set])),o=new Map(t.map(f=>[f,0]));for(const f of(e==null?void 0:e.edges)||[]){const d=String((f==null?void 0:f.source)||""),m=String((f==null?void 0:f.target)||"");!r.has(d)||!r.has(m)||d===m||i.get(d).has(m)||(i.get(d).add(m),o.set(m,o.get(m)+1))}const a=(f,d)=>n.get(f)-n.get(d),l=t.filter(f=>o.get(f)===0).sort(a),c=new Map(t.map(f=>[f,0])),u=new Set;for(;l.length;){const f=l.shift();u.add(f);for(const d of[...i.get(f)].sort(a))c.set(d,Math.max(c.get(d),c.get(f)+1)),o.set(d,o.get(d)-1),o.get(d)===0&&(l.push(d),l.sort(a))}let p=Math.max(0,...c.values());for(const f of t)u.has(f)||(p+=1,c.set(f,p));return c}function Ch(e,t,n,r){let i=t;for(const o of e)r[o]={...r[o],y:i},i+=ia(n,o).height+Zo;return i}function SJ(e){var p,f;const t=c2(e),n=new Map(t.map((d,m)=>[d,m])),r=jJ(e,t,n),i=new Set;for(const d of(e==null?void 0:e.edges)||[])vJ(e,d)&&(i.add(String(d.source)),i.add(String(d.target)));for(const d of t){const m=String(((f=(p=e==null?void 0:e.instances)==null?void 0:p[d])==null?void 0:f.definitionId)||"");(m==="workspace_run"||m==="workspace_scheduled_run")&&i.add(d)}const o=new Map;for(const d of t){const m=r.get(d)||0;o.has(m)||o.set(m,[]),o.get(m).push(d)}const a=[...o.keys()].sort((d,m)=>d-m),l={};let c=l2;for(const d of o.values()){const m=d.filter(b=>i.has(b)),y=d.filter(b=>{var g,k;return!i.has(b)&&!String(((k=(g=e==null?void 0:e.instances)==null?void 0:g[b])==null?void 0:k.definitionId)||"").startsWith("display_")}),v=y.reduce((b,g)=>b+ia(e,g).height,0)+Math.max(0,y.length-1)*Zo;if(m.length)c=Math.max(c,v+Zo+80);else{const b=d.reduce((g,k)=>g+ia(e,k).height,0)+Math.max(0,d.length-1)*Zo;c=Math.max(c,b/2+80)}}let u=a2;for(const d of a){const m=o.get(d).sort((k,x)=>n.get(k)-n.get(x)),y=m.filter(k=>i.has(k)),v=m.filter(k=>{var x,C;return!i.has(k)&&!String(((C=(x=e==null?void 0:e.instances)==null?void 0:x[k])==null?void 0:C.definitionId)||"").startsWith("display_")}),b=m.filter(k=>!i.has(k)&&!v.includes(k));for(const k of m)l[k]={x:u,y:c};if(y.length){const k=c,x=Ch(y,k,e,l),C=v.reduce((N,_)=>N+ia(e,_).height,0)+Math.max(0,v.length-1)*Zo;Ch(v,k-Zo-C,e,l),Ch(b,x,e,l)}else{const k=[...v,...b],x=k.reduce((C,N)=>C+ia(e,N).height,0)+Math.max(0,k.length-1)*Zo;Ch(k,c-x/2,e,l)}const g=Math.max(...m.map(k=>ia(e,k).width),0);u+=g+kJ}return l}function SA(e){return e&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function NJ(e,t){return e.x<t.x+t.width+_h&&e.x+e.width+_h>t.x&&e.y<t.y+t.height+_h&&e.y+e.height+_h>t.y}function _J(e,{preserveExisting:t=!0}={}){var a,l,c;const n=SJ(e||{}),r=(a=e==null?void 0:e.ui)!=null&&a.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},i=t?{...r}:{},o=[];if(t)for(const[u,p]of Object.entries(r)){if(!SA(p))continue;const f=ia(e,u);o.push({id:u,x:p.x,y:p.y,...f})}for(const u of c2(e||{})){if(t&&SA(r[u]))continue;const p=ia(e,u),f={x:vA((l=n[u])==null?void 0:l.x,a2),y:vA((c=n[u])==null?void 0:c.y,l2)};let d={id:u,...f,...p};for(;o.some(m=>NJ(d,m));)f.y+=p.height+Zo,d={id:u,...f,...p};i[u]=f,o.push(d)}return i}function CJ({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:i=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==i||l!==a)?"local-edits":""}function AJ({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function u2(e=[]){let t=!1,n=!1,r=!1;for(const i of Array.isArray(e)?e:[]){if((i==null?void 0:i.type)==="position"&&i.position){r=!0,i.dragging===!0&&(t=!0),i.dragging===!1&&(n=!0);continue}if((i==null?void 0:i.type)==="dimensions"&&i.dimensions){r=!0,i.resizing===!0&&(t=!0),i.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(i==null?void 0:i.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function EJ({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function IJ(e=[]){const t=u2(e);return t.mutated&&!t.active}function PJ(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function TJ(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function RJ(e=[]){const t=[],n=[];let r=!1;for(const i of Array.isArray(e)?e:[]){if(PJ(i)){t.push(i);continue}n.push(i),TJ(i)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function lm(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const i=String((r==null?void 0:r.id)||"").trim();if(!(i&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${i}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function MJ(e=[]){return lm(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function NA(e){const t=Number((e==null?void 0:e.width)||0),n=Number((e==null?void 0:e.height)||0);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:t,height:n}}function d2({resizing:e=!1,liveSize:t=null,persistedSize:n=null}={}){const r=NA(n);return e&&NA(t)||r}function LJ({phase:e="loading",detail:t="",nodeInteracting:n=!1}={}){if(n)return{phase:"interacting",label:"交互保护中",detail:"远端更新暂缓,松手后同步"};const r={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[e]||"同步状态";return{phase:e,label:r,detail:t}}function _A(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function $J({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function OJ({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:i=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&i}const DJ=h.lazy(()=>qT(()=>import("./WorkflowAssistantThread-CKClwj96.js"),[])),FJ="af:workspace-graph:v2",CA="agentflow.workspace.sidebarCollapsed",fc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],zJ=new Set(["png","jpg","jpeg","gif","webp","svg"]),f2=320,p2=180,h2=960,og=96,m2=900,Mk=520,Lk=320,Ah=52,kl=240,vl=160,$k="display-ref:",Mf="0 9 * * *",WJ="Asia/Shanghai",BJ="0.1.154";function HJ(){const e=new URLSearchParams(window.location.search),t=String(e.get("returnTo")||"").trim();return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1",returnTo:t==="/workflows"||t.startsWith("/workflows?")?t:"",workflowDemo:e.get("workflowDemo")==="1"}}function Hr(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),e.returnTo&&t.set("returnTo",e.returnTo),e.workflowDemo&&t.set("workflowDemo","1"),t}function Jo(e={}){return[e.workspaceId||"",e.flowSource||"user",e.flowId||""].join(" ")}function KJ(e){const t=String(e||"").trim();if(!t)return null;try{const n=JSON.parse(window.sessionStorage.getItem(`agentflow.workflow.demo:${t}`)||"null");return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Oj(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
210
+ ${r}`),t}function dJ(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const i=dc(r),o=i&&i!==Yt(r==null?void 0:r.label)?{...r,label:i}:r,a=gA(o),l=a.map(y=>n.get(y)).find(y=>y!=null);if(l==null){a.forEach(y=>n.set(y,t.length)),t.push(o);continue}const c=t[l],u=mA(o)>=mA(c)?dc(o)||dc(c):dc(c)||dc(o),p=!!sg(c),f=!!sg(o),d=p&&!f?c:o,m=d===c?o:c;t[l]={...m,...d,...u?{label:u}:{}},gA(t[l]).forEach(y=>n.set(y,l))}return t}function s2(e){const t=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Yt(e==null?void 0:e.durability).toLowerCase(),r=Yt(e==null?void 0:e.persistence).toLowerCase(),i=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Yt).join(" ");return t==="temporary-review"||n==="temporary"||i==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function fJ(e){if(!Tf(e)||s2(e))return!1;const t=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Yt(e==null?void 0:e.durability).toLowerCase(),r=Yt(e==null?void 0:e.persistence).toLowerCase(),i=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Yt).join(" ");return t==="review"||n==="durable"||i==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function pJ(e){if(Tf(e))return!1;const t=Yt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Yt(e==null?void 0:e.persistence).toLowerCase(),r=_o(e==null?void 0:e.source)||_o((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),i=[e==null?void 0:e.label,t].map(Yt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(i)}function hJ(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Yt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function mJ(e=[],t={}){const n=dJ(Array.isArray(e)?e:[]);if(!hJ(t))return n;const r=n.filter(Tf);if(r.length===0)return n;const i=r.filter(fJ),a=i.length>0||n.some(pJ)?i.at(-1):r.filter(s2).at(-1);return n.filter(l=>!Tf(l)||l===a)}function Di(e,t){const n=[],r=new Map,i=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Yt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=r2(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const p=Yt(a.path);return p&&l.push(`path:${p}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=i(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(p=>r.set(p,u));return}n[c]=a,i(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function fs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ig(e){return Array.isArray(e)?e.map(ig):fs(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,ig(e[t])])):e}function yo(e,t){return JSON.stringify(ig(e))===JSON.stringify(ig(t))}function i2(e){return fs(e==null?void 0:e.instances)?e.instances:{}}function Rf(e){return fs(e==null?void 0:e.ui)?e.ui:{}}function Nh(e,t){if(!fs(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function gJ(e,t){if(!fs(e)||!fs(t)||!fs(e.instances)||!fs(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!fs(e.ui)||!fs(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Nh(e,["version","instances","edges","ui"]),r=Nh(t,["version","instances","edges","ui"]);if(!yo(n,r))return!1;const i=["nodePositions","nodeSizes","groups","displayPage","viewport"];return yo(Nh(e.ui,i),Nh(t.ui,i))}function o2(e){const t=Array.isArray(Rf(e).groups)?Rf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function yA(e){const t=new Set(Object.keys(i2(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of o2(e).keys())t.add(n);return t}function wA(e,t){const n=i2(e),r=Rf(e),i=o2(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:fs(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:fs(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:i.get(t)||null}}function xA(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),i=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(i)})}function yJ(e,t){if(!gJ(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...yA(e),...yA(t)]),r=Array.from(n).filter(i=>!yo(wA(e,i),wA(t,i)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!yo(xA(e),xA(t)),displayPageChanged:!yo(Rf(e).displayPage||null,Rf(t).displayPage||null)}}function wJ(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),i=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!i.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function bA(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function kA(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function xJ(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[bA(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const i=n.get(bA(r));return i?yo(kA(i),kA(r))?i:{...r,selected:i.selected===!0}:r})}function bJ(e,t,n){const r=fs(e)?e:{},i=fs(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(i).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}const kJ=160,Zo=72,a2=120,l2=360,_h=28;function vA(e,t){return Number.isFinite(Number(e))?Number(e):t}function ia(e,t){var i,o,a,l;const n=(o=(i=e==null?void 0:e.ui)==null?void 0:i.nodeSizes)==null?void 0:o[t];if(n&&Number.isFinite(n.width)&&Number.isFinite(n.height))return{width:Math.max(80,n.width),height:Math.max(60,n.height)};const r=String(((l=(a=e==null?void 0:e.instances)==null?void 0:a[t])==null?void 0:l.definitionId)||"");return r==="workspace_run"||r==="workspace_scheduled_run"?{width:256,height:156}:r.startsWith("provide_")?{width:220,height:110}:r.startsWith("display_")?{width:496,height:160}:{width:260,height:150}}function jA(e){const t=/-(\d+)$/.exec(String(e||""));return t?Number(t[1]):0}function vJ(e,t){var a,l;const n=(a=e==null?void 0:e.instances)==null?void 0:a[t.source],r=(l=e==null?void 0:e.instances)==null?void 0:l[t.target],i=Array.isArray(n==null?void 0:n.output)?n.output[jA(t.sourceHandle)]:null,o=Array.isArray(r==null?void 0:r.input)?r.input[jA(t.targetHandle)]:null;return(i==null?void 0:i.type)==="node"||(o==null?void 0:o.type)==="node"}function c2(e){const t=[],n=new Set,r=i=>{const o=String(i||"");!o||n.has(o)||(n.add(o),t.push(o))};for(const i of Object.keys((e==null?void 0:e.instances)||{}))r(i);for(const i of(e==null?void 0:e.edges)||[])r(i==null?void 0:i.source),r(i==null?void 0:i.target);return t}function jJ(e,t,n){const r=new Set(t),i=new Map(t.map(f=>[f,new Set])),o=new Map(t.map(f=>[f,0]));for(const f of(e==null?void 0:e.edges)||[]){const d=String((f==null?void 0:f.source)||""),m=String((f==null?void 0:f.target)||"");!r.has(d)||!r.has(m)||d===m||i.get(d).has(m)||(i.get(d).add(m),o.set(m,o.get(m)+1))}const a=(f,d)=>n.get(f)-n.get(d),l=t.filter(f=>o.get(f)===0).sort(a),c=new Map(t.map(f=>[f,0])),u=new Set;for(;l.length;){const f=l.shift();u.add(f);for(const d of[...i.get(f)].sort(a))c.set(d,Math.max(c.get(d),c.get(f)+1)),o.set(d,o.get(d)-1),o.get(d)===0&&(l.push(d),l.sort(a))}let p=Math.max(0,...c.values());for(const f of t)u.has(f)||(p+=1,c.set(f,p));return c}function Ch(e,t,n,r){let i=t;for(const o of e)r[o]={...r[o],y:i},i+=ia(n,o).height+Zo;return i}function SJ(e){var p,f;const t=c2(e),n=new Map(t.map((d,m)=>[d,m])),r=jJ(e,t,n),i=new Set;for(const d of(e==null?void 0:e.edges)||[])vJ(e,d)&&(i.add(String(d.source)),i.add(String(d.target)));for(const d of t){const m=String(((f=(p=e==null?void 0:e.instances)==null?void 0:p[d])==null?void 0:f.definitionId)||"");(m==="workspace_run"||m==="workspace_scheduled_run")&&i.add(d)}const o=new Map;for(const d of t){const m=r.get(d)||0;o.has(m)||o.set(m,[]),o.get(m).push(d)}const a=[...o.keys()].sort((d,m)=>d-m),l={};let c=l2;for(const d of o.values()){const m=d.filter(b=>i.has(b)),y=d.filter(b=>{var g,k;return!i.has(b)&&!String(((k=(g=e==null?void 0:e.instances)==null?void 0:g[b])==null?void 0:k.definitionId)||"").startsWith("display_")}),v=y.reduce((b,g)=>b+ia(e,g).height,0)+Math.max(0,y.length-1)*Zo;if(m.length)c=Math.max(c,v+Zo+80);else{const b=d.reduce((g,k)=>g+ia(e,k).height,0)+Math.max(0,d.length-1)*Zo;c=Math.max(c,b/2+80)}}let u=a2;for(const d of a){const m=o.get(d).sort((k,x)=>n.get(k)-n.get(x)),y=m.filter(k=>i.has(k)),v=m.filter(k=>{var x,C;return!i.has(k)&&!String(((C=(x=e==null?void 0:e.instances)==null?void 0:x[k])==null?void 0:C.definitionId)||"").startsWith("display_")}),b=m.filter(k=>!i.has(k)&&!v.includes(k));for(const k of m)l[k]={x:u,y:c};if(y.length){const k=c,x=Ch(y,k,e,l),C=v.reduce((N,_)=>N+ia(e,_).height,0)+Math.max(0,v.length-1)*Zo;Ch(v,k-Zo-C,e,l),Ch(b,x,e,l)}else{const k=[...v,...b],x=k.reduce((C,N)=>C+ia(e,N).height,0)+Math.max(0,k.length-1)*Zo;Ch(k,c-x/2,e,l)}const g=Math.max(...m.map(k=>ia(e,k).width),0);u+=g+kJ}return l}function SA(e){return e&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function NJ(e,t){return e.x<t.x+t.width+_h&&e.x+e.width+_h>t.x&&e.y<t.y+t.height+_h&&e.y+e.height+_h>t.y}function _J(e,{preserveExisting:t=!0}={}){var a,l,c;const n=SJ(e||{}),r=(a=e==null?void 0:e.ui)!=null&&a.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},i=t?{...r}:{},o=[];if(t)for(const[u,p]of Object.entries(r)){if(!SA(p))continue;const f=ia(e,u);o.push({id:u,x:p.x,y:p.y,...f})}for(const u of c2(e||{})){if(t&&SA(r[u]))continue;const p=ia(e,u),f={x:vA((l=n[u])==null?void 0:l.x,a2),y:vA((c=n[u])==null?void 0:c.y,l2)};let d={id:u,...f,...p};for(;o.some(m=>NJ(d,m));)f.y+=p.height+Zo,d={id:u,...f,...p};i[u]=f,o.push(d)}return i}function CJ({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:i=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==i||l!==a)?"local-edits":""}function AJ({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function u2(e=[]){let t=!1,n=!1,r=!1;for(const i of Array.isArray(e)?e:[]){if((i==null?void 0:i.type)==="position"&&i.position){r=!0,i.dragging===!0&&(t=!0),i.dragging===!1&&(n=!0);continue}if((i==null?void 0:i.type)==="dimensions"&&i.dimensions){r=!0,i.resizing===!0&&(t=!0),i.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(i==null?void 0:i.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function EJ({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function IJ(e=[]){const t=u2(e);return t.mutated&&!t.active}function PJ(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function TJ(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function RJ(e=[]){const t=[],n=[];let r=!1;for(const i of Array.isArray(e)?e:[]){if(PJ(i)){t.push(i);continue}n.push(i),TJ(i)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function lm(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const i=String((r==null?void 0:r.id)||"").trim();if(!(i&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${i}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function MJ(e=[]){return lm(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function NA(e){const t=Number((e==null?void 0:e.width)||0),n=Number((e==null?void 0:e.height)||0);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:t,height:n}}function d2({resizing:e=!1,liveSize:t=null,persistedSize:n=null}={}){const r=NA(n);return e&&NA(t)||r}function LJ({phase:e="loading",detail:t="",nodeInteracting:n=!1}={}){if(n)return{phase:"interacting",label:"交互保护中",detail:"远端更新暂缓,松手后同步"};const r={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[e]||"同步状态";return{phase:e,label:r,detail:t}}function _A(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function $J({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function OJ({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:i=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&i}const DJ=h.lazy(()=>qT(()=>import("./WorkflowAssistantThread-ClNxY2Wu.js"),[])),FJ="af:workspace-graph:v2",CA="agentflow.workspace.sidebarCollapsed",fc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],zJ=new Set(["png","jpg","jpeg","gif","webp","svg"]),f2=320,p2=180,h2=960,og=96,m2=900,Mk=520,Lk=320,Ah=52,kl=240,vl=160,$k="display-ref:",Mf="0 9 * * *",WJ="Asia/Shanghai",BJ="0.1.156";function HJ(){const e=new URLSearchParams(window.location.search),t=String(e.get("returnTo")||"").trim();return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1",returnTo:t==="/workflows"||t.startsWith("/workflows?")?t:"",workflowDemo:e.get("workflowDemo")==="1"}}function Hr(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),e.returnTo&&t.set("returnTo",e.returnTo),e.workflowDemo&&t.set("workflowDemo","1"),t}function Jo(e={}){return[e.workspaceId||"",e.flowSource||"user",e.flowId||""].join(" ")}function KJ(e){const t=String(e||"").trim();if(!t)return null;try{const n=JSON.parse(window.sessionStorage.getItem(`agentflow.workflow.demo:${t}`)||"null");return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Oj(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
211
211
  ...[truncated ${n.length-t} chars]`:n:""}function VJ(e){const t=Oj(e==null?void 0:e.text,4e3);return t?{role:(e==null?void 0:e.role)==="user"?"user":"assistant",...e!=null&&e.kind?{kind:String(e.kind)}:{},text:t,...e!=null&&e.error?{error:!0}:{},at:Number.isFinite(Number(e==null?void 0:e.at))?Number(e.at):Date.now()}:null}function Dj(e,t=80){return(Array.isArray(e)?e:[]).map(VJ).filter(Boolean).slice(-t)}function qJ(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,i]of Object.entries(t).slice(-80)){const o=String(r||"").trim();if(!o||!i||typeof i!="object")continue;const a=Dj(i.messages,40),l=Oj(i.draft||"",2e3);!a.length&&!l||(n[o]={sessionId:String(i.sessionId||`nodechat_${o}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function UJ(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Dj(t==null?void 0:t.messages,80);if(!r.length)return null;const i=String((t==null?void 0:t.status)||"done");return{id:n,label:Oj((t==null?void 0:t.label)||n,120),status:i==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function AA(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=t.composer&&typeof t.composer=="object"&&!Array.isArray(t.composer)?t.composer:{};return{composer:{activeSessionId:String(n.activeSessionId||"workspace").trim()||"workspace",messages:Dj(n.messages,100),runSessions:UJ(n.runSessions)},nodeChats:qJ(t.nodeChats)}}function ag(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return zJ.has(n)}function Lf(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const i=Hr(t||{});return i.set("path",r),n.download&&i.set("download","1"),`/api/workspace/file/raw?${i.toString()}`}function GJ(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function YJ(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${CA}:${t}`:CA}function JJ(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function EA(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function XJ(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function QJ(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!XJ(e)}function ZJ(e){const t=String(e||"").trim();if(!t||eX(t))return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),i=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return i==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function eX(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function tX(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function Px(e,t,n,r="Workspace Run"){var c;const i=String(n||"").trim(),o=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===i):null,a=t&&typeof t=="object"?t[i]:null;return String(((c=o==null?void 0:o.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||i||r}function Tx(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,i=String(t||"").trim();return!i||r===i?r:`${r} (${i})`}function Qa(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function IA(e){const t=String(e||"").trim().toLowerCase();return{unselected:"未选择需求",unavailable:"未连接",json_unsupported:"待升级",command_failed:"读取失败",uninitialized:"未初始化",preflight_blocked:"环境阻塞",tech_design_missing:"缺技术方案",tech_design_draft_review:"方案待确认",tech_design_confirmed:"方案已确认",baseline_missing:"缺基线",plan_missing:"缺计划",plan_draft_review:"计划待确认",issue_binding_missing:"待绑定 Issue",ready_for_implementation:"待实现",implementation_ready:"待实现",implementing:"实现中",implementation_in_progress:"实现中",implementation_review:"实现待审",self_test_ready:"待自测",bugfix:"修 Bug",fix_ready:"待修复",fix_in_progress:"修复中",testing:"已提测",done:"完成",blocked:"阻塞",conflict:"冲突",requirement_changed:"需求变更"}[t]||t||"未知"}function nX(e){const t=String(e||"").trim().toLowerCase();return!t||["unselected","unavailable","json_unsupported","command_failed","uninitialized","preflight_blocked"].includes(t)?-1:/done|complete|closed|finished/.test(t)?3:/bug|fix|testing|test|self_test|submit_test/.test(t)?2:/implement|development|ready_for_implementation|issue_binding|gitlab|mr/.test(t)?1:0}function rX(e){const t=nX(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let i="pending";return t>r?i="done":t===r&&(i=r===3?"done":"current"),{label:n,status:i}})}function sX(e,t=""){var o,a,l,c;const n=e!=null&&e.globalState&&typeof e.globalState=="object"?e.globalState:{},r=(o=e==null?void 0:e.overall)!=null&&o.requirement&&typeof e.overall.requirement=="object"?e.overall.requirement:{};return String(n.title||r.title||r.name||((a=e==null?void 0:e.prd)==null?void 0:a.title)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.title)||"").trim()||(t?`TAPD ${t}`:"选择 TAPD 需求后读取状态")}function $f(e){const t=String(e||"").trim();if(!t)return"";if(t.startsWith("/")&&!t.startsWith("//")||t.startsWith("#"))return t;if(!/^https?:\/\//i.test(t))return"";try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const i=window.location.hostname;n.hostname=i&&i!=="0.0.0.0"&&i!=="::"?i:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function Hc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return $f(t);const n=String((e==null?void 0:e.path)||"").trim();return n&&/^https?:\/\//i.test(n)?$f(n):""}function La(e){const t=String(e||"").trim().toLowerCase();return["done","success","completed","passed"].includes(t)?"done":["current","running","active","next"].includes(t)?"current":["observed","observation"].includes(t)?"observed":["superseded","stale","replaced"].includes(t)?"superseded":["blocked","failed","error","conflict"].includes(t)?"blocked":"pending"}function Na(e){if(!e||typeof e!="object")return"";const t=String(e.truth||e.stateTruth||e.state_truth||"").trim().toLowerCase();return t||(String(e.idempotencyKey||e.idempotency_key||"").trim().startsWith("snapshot-action:")||String(e.source||"")==="prd-flow-client"&&String(e.type||"")==="workflow-action"?"observation":String(e.type||"")==="review-link"?"runtime_event":"")}function Fj(e){return La(e==null?void 0:e.status)==="done"&&Na(e)!=="observation"}function wo(e,t){return!e||typeof e!="object"?`Action ${t+1}`:String(e.title||e.label||e.name||e.actionLabel||e.action_label||e.id||e.action||`Action ${t+1}`)}function cm(e){return!e||typeof e!="object"?"":String(e.detail||e.content||e.description||e.summary||e.message||e.reason||"")}function zj(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function iX(e,t="当前任务"){const r=[e==null?void 0:e.issueLabel,e==null?void 0:e.issue_label,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.name].map(i=>String(i||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function oX(e,t){const n=wo(e,t),r=String((e==null?void 0:e.title)||(e==null?void 0:e.label)||(e==null?void 0:e.name)||(e==null?void 0:e.actionLabel)||(e==null?void 0:e.action_label)||"").trim();if(r)return r;const i=La(e==null?void 0:e.status),o=Fj(e),l=`${jl(e)} ${zj(e)}`,c=iX(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(l)){if(o)return`${c} 方案已确认`;if(i==="observed"||i==="superseded"||Na(e)==="observation")return`${c} 方案状态已观察`;if(i==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(l)){if(o)return`已为 ${c} 创建/绑定 GitLab Issue`;if(i==="observed"||i==="superseded"||Na(e)==="observation")return`${c} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(l)?`正在实现 ${c}`:/implementation_ready/.test(l)?`可以开始实现 ${c}`:n}function aX(e){if(!e||typeof e!="object")return"";const t=cm(e);if(t)return t;const n=La(e.status),r=Na(e),i=Fj(e),a=`${jl(e)} ${zj(e)}`,l=Wj(e),c=l.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),u=l.some(f=>/gitlab issue/i.test(String(f.label||""))),p=l.some(f=>/gitlab epic/i.test(String(f.label||"")));return/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)?i?c?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":r==="observation"||n==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":n==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":n==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。":/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)?i?u&&p?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":u?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":r==="observation"||n==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":n==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。":/implementation_in_progress|impl_in_progress/.test(a)?"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。":/implementation_ready/.test(a)?"方案文档和 GitLab Issue 已就绪,等待开始实现。":""}function lg(e){return!e||typeof e!="object"?"":String(e.stageEnteredAt||e.stage_entered_at||e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const g2="Asia/Shanghai",lX=new Intl.DateTimeFormat("zh-CN",{timeZone:g2,year:"numeric",month:"2-digit",day:"2-digit"}),cX=new Intl.DateTimeFormat("zh-CN",{timeZone:g2,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function y2(e){const t=lg(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function uX(e){const t=y2(e);return t?lX.format(t).replace(/\//g,"-"):"无时间"}function dX(e){const t=y2(e);return t?cX.format(t):""}function fX(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const i=uX(n);let o=t[t.length-1];(!o||o.day!==i)&&(o={day:i,items:[]},t.push(o)),o.items.push({item:n,index:r})}),t}function w2(e){const t=La(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function oa(e){const t=String(e||"").trim(),n=t.toLowerCase();return n==="android"?"Android":n==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(n)?"双端":t}function pX(e){const t=La(e==null?void 0:e.status);return Na(e)==="observation"&&t==="done"?"已观察":w2(t)}function x2(e){if(!e||typeof e!="object")return[];const t=[],n=(o,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${o}:${c}`,type:o,label:String(a||c),value:c})},r=La(e.status),i=Na(e)==="observation"&&r==="done"?"observed":r;return n("status",w2(i),i),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",oa(e.platform),e.platform),t}function hX(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{x2(n).forEach(r=>{const i=t.get(r.key);t.set(r.key,{...r,count:((i==null?void 0:i.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const i={status:0,issue:1,platform:2,source:3,actor:4};return(i[n.type]??9)-(i[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function mX(e,t){const n=String(t||"all");return!n||n==="all"?!0:x2(e).some(r=>r.key===n)}function gX(e){if(!e||typeof e!="object")return[];const t=[],n=(r,i)=>{const o=String(i||"").trim();o&&t.push({label:r,value:o})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",oa(e.platform)),t}function Wj(e){const t=[],n=(o,a,l={})=>{const c=$f(a);c&&t.push({...l,label:String(o||c).trim()||c,href:c})},r=(o,a="链接",l=0)=>{if(l>3||o==null)return;if(typeof o=="string"){(/^(https?:\/\/|file:\/\/)/i.test(o)||o.startsWith("/"))&&n(a,o);return}if(Array.isArray(o)){o.forEach((u,p)=>r(u,`${a} ${p+1}`,l+1));return}if(typeof o!="object")return;const c=o.label||o.title||o.name||o.kind||o.type||a;n(c,o.url||o.href||o.path||o.file||o.filePath||o.file_path,o);for(const u of["links","urls","artifacts","outputs","output","results","result","files"])o[u]!=null&&r(o[u],u,l+1)},i=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const o of i)typeof o=="string"?n("链接",o):n((o==null?void 0:o.label)||(o==null?void 0:o.title)||(o==null?void 0:o.kind)||"链接",(o==null?void 0:o.url)||(o==null?void 0:o.href),o);for(const o of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((o==null?void 0:o.label)||(o==null?void 0:o.title)||(o==null?void 0:o.kind)||"Artifact",Hc(o),o);return n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件"),mJ(t,e)}function yX(e,t=[]){var l,c,u,p,f;const n=[],r=new Map,i=String(((c=(l=e==null?void 0:e.overall)==null?void 0:l.requirement)==null?void 0:c.title)||((p=(u=e==null?void 0:e.overall)==null?void 0:u.requirement)==null?void 0:p.name)||"").trim();for(const d of Ok(e)){const m=Hi(d),y=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();m&&y&&r.set(m,y)}const o=(d,m={})=>{if(!d||typeof d!="object")return;const y=(b,g={})=>{if(!b||typeof b!="object")return;const k=String(m.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),x=b.source||b.sourceArtifact||b.source_artifact||d.sourceArtifact||d.source_artifact||d.source||m.source||null,C=sJ({...b,title:b.title||m.documentTitle||(d==null?void 0:d.title)||"",documentTitle:b.documentTitle||b.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(k)||"",requirementTitle:i}),N={label:String(b.label||"ai-doc").trim()||"ai-doc",href:String(b.href||b.url||"").trim(),kind:String(b.kind||b.type||d.kind||d.type||"").trim(),title:C,issueKey:k,platform:m.platform||oa(d.platform),durability:b.durability||d.durability||m.durability||"",persistence:b.persistence||d.persistence||m.persistence||"",truth:b.truth||b.stateTruth||b.state_truth||Na(d)||m.truth||"",authority:b.authority||d.authority||m.authority||"",confirmed:b.confirmed??d.confirmed??m.confirmed,source:x,documentPath:b.documentPath||b.document_path||b.path||g.documentPath||(x==null?void 0:x.path)||(x==null?void 0:x.documentPath)||(x==null?void 0:x.document_path)||""};N.href&&n.push(N)};for(const b of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Hc(b)},{documentPath:b.path});for(const b of Array.isArray(d==null?void 0:d.links)?d.links:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Hc(b)},{documentPath:b.path});const v=Hc(d);v&&y({...d,label:d.label||d.title||d.kind||"ai-doc",href:v},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:oa(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const m of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(m,{issueKey:String((m==null?void 0:m.issueKey)||(m==null?void 0:m.issue_key)||(m==null?void 0:m.issue)||"").trim(),platform:oa(m==null?void 0:m.platform),documentTitle:String((m==null?void 0:m.documentTitle)||(m==null?void 0:m.document_title)||(m==null?void 0:m.title)||"").trim()});for(const d of Ok(e))o(d,{issueKey:Hi(d),platform:oa(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});const a=(f=e==null?void 0:e.extensions)!=null&&f["prd-flow"]&&typeof e.extensions["prd-flow"]=="object"?e.extensions["prd-flow"]:{};for(const d of[...Array.isArray(e==null?void 0:e.aiDocs)?e.aiDocs:[],...Array.isArray(e==null?void 0:e.ai_docs)?e.ai_docs:[],...Array.isArray(a.aiDocs)?a.aiDocs:[],...Array.isArray(a.ai_docs)?a.ai_docs:[]])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||"").trim(),platform:oa(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.label)||"").trim()});return aJ(n,window.location.origin)}function wX(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function Hi(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function xX(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||Hi(e,t)||`Issue ${t+1}`).trim()}function bX(e){return String((e==null?void 0:e.epicKey)||(e==null?void 0:e.epic_key)||(e==null?void 0:e.epic)||(e==null?void 0:e.epicTitle)||(e==null?void 0:e.epic_title)||(e==null?void 0:e.parentEpic)||(e==null?void 0:e.parent_epic)||"未归类").trim()}function kX(e){return String((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parent)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||"").trim()}function vX(e){const t=Wj(e),n=(i,o)=>{if(Array.isArray(i)){for(const a of i)if(a)if(typeof a=="string")t.push({label:o,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||o,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(i=>{const o=String(i.href||"").trim();if(!o)return!1;const a=`${i.label}
212
212
  ${o}`;return r.has(a)?!1:(r.add(a),!0)})}function jX(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,i=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=i(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const p of u)p&&typeof p=="object"&&c.issues.push({...p,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)i(bX(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((p,f)=>Hi(p,f));return a.forEach((p,f)=>{const d=Hi(p,f);l.set(d,{issue:p,children:[]})}),a.forEach((p,f)=>{const d=Hi(p,f),m=kX(p)||eJ(p,u),y=l.get(d);m&&l.has(m)?l.get(m).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function cg(e){return String((e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.action)||(e==null?void 0:e.id)||"").trim()}function PA(e){var t;return String(((t=e==null?void 0:e.actionModel)==null?void 0:t.key)||(e==null?void 0:e.key)||(e==null?void 0:e.actionKey)||(e==null?void 0:e.action_key)||(e==null?void 0:e.action)||(e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.stageKey)||(e==null?void 0:e.stage_key)||"").trim()}function SX(e){const t=String(e||"pending");return t==="passed"?"check":t==="failed"?"close":t==="blocked"?"block":t==="skipped"?"skip_next":"radio_button_unchecked"}function jl(e){return cJ(e)}function ug(e){const t=lg(e)||String((e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)||""),n=Date.parse(t);return Number.isFinite(n)?n:NaN}function Ok(e){var i,o,a,l,c,u,p,f,d,m,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(i=e==null?void 0:e.raw)==null?void 0:i.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:f.epics,(m=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:m.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function NX(e,t){const n=String(t||"").trim();return n&&Ok(e).find((r,i)=>Hi(r,i)===n)||null}function _X(e){var t,n,r,i,o,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((i=e==null?void 0:e.raw)==null?void 0:i.gitlab_epic)||((a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function CX(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=NX(e,n),i=String(t.platform||(r==null?void 0:r.platform)||"").trim(),o=i&&!t.platform?{...t,platform:i}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||o.gitlabIssue||o.gitlab_issue||"").trim(),l=_X(e);if(!a&&!l)return o;const c=jl(o),u=`${c} ${zj(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({key:`gitlab-issue:${n}:${(i||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const d=La(o.status),m=a&&d==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...m?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:Di(o.artifacts,f)}}function TA(e,t){const n=ug(t),r=ug(e),i=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,o=(i==null?void 0:i.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:wo(i,0)||wo(t,0)||wo(e,0),detail:cm(i)||cm(t)||cm(e),status:o,links:Di(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Di(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Di(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Di(e==null?void 0:e.results,t==null?void 0:t.results),events:Di(e==null?void 0:e.events,t==null?void 0:t.events),createdAt:(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(t==null?void 0:t.createdAt)||(t==null?void 0:t.created_at),startedAt:(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(t==null?void 0:t.startedAt)||(t==null?void 0:t.started_at),updatedAt:(i==null?void 0:i.updatedAt)||(i==null?void 0:i.updated_at)||(t==null?void 0:t.updatedAt)||(t==null?void 0:t.updated_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)}}function AX(e,t){const n=[],r=new Map,i=new Map,o=new Map,a=f=>{var d,m;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||uJ(f)||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((d=f.conflict)==null?void 0:d.previousArtifact)||((m=f.conflict)==null?void 0:m.incomingArtifact)||"")))},l=(f,d)=>({...f,links:Di(f==null?void 0:f.links,d==null?void 0:d.links),artifacts:Di(f==null?void 0:f.artifacts,d==null?void 0:d.artifacts),outputs:Di(f==null?void 0:f.outputs,d==null?void 0:d.outputs),results:Di(f==null?void 0:f.results,d==null?void 0:d.results)}),c=(f,d)=>{if(!f)return;const m=r.get(f);if(m!=null){n[m]=l(n[m],d);return}o.set(f,l(o.get(f)||{},d))},u=(f,d)=>f&&o.has(f)?l(d,o.get(f)):d,p=f=>{if(Array.isArray(f))for(const d of f){const m=jl(d);if(a(d)){c(m,d);continue}const y=String(d.id||d.eventId||d.event_id||d.actionId||d.action_id||"").trim(),v=m||y,b=v?r.get(v)??i.get(y):null;v&&b!=null?(n[b]=u(m,TA(n[b],d)),m&&r.set(m,b),y&&i.set(y,b)):(v&&r.set(v,n.length),y&&i.set(y,n.length),n.push(u(m,d)))}};if(p(e==null?void 0:e.actions),p(e==null?void 0:e.workflowActions),p(e==null?void 0:e.workflow_actions),p(e==null?void 0:e.timeline),p(e==null?void 0:e.history),p(e==null?void 0:e.events),p(e==null?void 0:e.runtimeEvents),p(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=cg(t),d=jl(t),m=d?r.get(d):f?i.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};m!=null&&(n[m]=TA(n[m],y))}return n.map((f,d)=>({item:f,index:d,ts:ug(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,d)=>d.ts-f.ts||f.index-d.index).map(f=>CX(e,f.item))}function EX(e){const t=Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[],n=Array.isArray(e==null?void 0:e.snapshotAudit)?e.snapshotAudit:Array.isArray(e==null?void 0:e.snapshot_audit)?e.snapshot_audit:[];return[...t,...n].filter(i=>i&&typeof i=="object").map((i,o)=>({item:i,index:o,ts:ug(i)})).sort((i,o)=>{const a=Number.isFinite(i.ts),l=Number.isFinite(o.ts);return a&&l?o.ts-i.ts||o.index-i.index:a?-1:l?1:o.index-i.index}).slice(0,8).map(i=>i.item)}function IX(e,t){const n=String(t||"all");if(n==="all")return!0;const r=[e==null?void 0:e.status,e==null?void 0:e.type,e==null?void 0:e.kind,e==null?void 0:e.title,e==null?void 0:e.detail,e==null?void 0:e.error,JSON.stringify((e==null?void 0:e.links)||[]),JSON.stringify((e==null?void 0:e.artifacts)||[])].join(" ").toLowerCase();return n==="errors"?/error|failed|conflict|blocked|stale|revision|冲突|失败/.test(r):n==="review"?/review|temporary-review|临时/.test(r):n==="external"?/mr|merge request|gitlab|jenkins|package|build|tapd/.test(r):!0}function PX(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,i=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(i)?`(+${Qa(r)} / 总 ${Qa(i)})`:"";return`${t+1}. ${n}${o}`}function b2(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function pc(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function TX(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function RX(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function MX(e,t){var i;const n=String(((i=t==null?void 0:t.args)==null?void 0:i.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function LX(e){var o,a,l;const t=b2(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),i=pc(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=RX(t),u=TX(t),p=pc(t.startedAtMs,c==null?void 0:c.startedAtMs),f=pc(t.completedAtMs,c==null?void 0:c.completedAtMs),d=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},m=Number.isFinite(p)&&Number.isFinite(f)?Math.max(0,f-p):pc(d.executionTime,d.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||d.command||"").trim(),v=y?y.split(`
213
213
  `).find(Boolean)||y:"";return{kind:"tool",label:MX(u,c),durationMs:Number.isFinite(m)?m:null,at:i,detail:v?v.slice(0,90):""}}if(n==="result"){const c=pc(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:i,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:i,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:i,detail:""}:null}function RA(e,t,n,r){const i=(Array.isArray(e)?e:[]).map(b=>typeof b=="string"?{text:b}:b).filter(b=>b&&String(b.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(b=>(b==null?void 0:b.kind)==="total"&&Number.isFinite(Number(b.durationMs))),l=[...i].reverse().find(b=>Number.isFinite(Number(b.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=pc(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),p=i.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),f=o.filter(b=>(b==null?void 0:b.kind)==="tool"),d=f.reduce((b,g)=>b+(Number(g.durationMs)||0),0),m=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...i.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${Qa(u)}`),p>0&&v.push(`- 模型相关间隔:约 ${Qa(p)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${Qa(d)}(${f.length} 次完成事件)`),m>0&&v.push(`- 网络/会话恢复事件:${m} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${Qa(b.durationMs)}${k}`)})),i.length>0&&(v.push(""),v.push("最近 Activity"),i.slice(-10).forEach((b,g)=>{v.push(PX(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${Qa(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
@@ -867,4 +867,4 @@ node skills/agentflow-cli/scripts/agentflow-cli.mjs run \\
867
867
  transform: scale(1);
868
868
  }
869
869
  }
870
- `)),document.head.appendChild(b);const g=setTimeout(()=>{Vr.domElement(d.current)&&c&&d.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[m,a,c]);const y=co(o.open);let v;if(t){const b=t;v=Nt.createElement(b,{continuous:n,index:r,isLastStep:i,size:u,step:p})}else v=Nt.createElement("span",{style:f.beacon},Nt.createElement("span",{style:f.beaconOuter}),Nt.createElement("span",{style:f.beaconInner}));return Nt.createElement("button",{ref:d,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function jfe({styles:e,...t}){const{color:n,height:r,width:i,...o}=e;return Nt.createElement("button",{style:o,type:"button",...t},Nt.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof i=="number"?`${i}px`:i,xmlns:"http://www.w3.org/2000/svg"},Nt.createElement("g",null,Nt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Sfe(e){const{backProps:t,closeProps:n,index:r,isLastStep:i,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:p,styles:f,title:d}=l,m={};u.includes("primary")&&(m.primary=Nt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!i&&(m.skip=Nt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(m.back=Nt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),m.close=u.includes("close")&&Nt.createElement(jfe,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":co(p),"aria-describedby":"joyride-tooltip-content"};return Nt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},Nt.createElement("div",{style:f.tooltipContainer},d&&Nt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},d),Nt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},p)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&Nt.createElement("div",{style:f.tooltipFooter},Nt.createElement("div",{style:f.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function Nfe(e){const{continuous:t,controls:n,index:r,isLastStep:i,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Ri.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Ri.BUTTON_CLOSE):n.close(Ri.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Ri.BUTTON_PRIMARY);return}n.next(Ri.BUTTON_PRIMARY)},p=g=>{g.preventDefault(),n.skip(Ri.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:C,nextWithProgress:N,skip:_}=a.locale,I=co(g),L=co(k),K=co(x),E=co(C),W=co(_);let z=k,B=L;if(t){if(z=C,B=E,a.showProgress&&!i){const D=co(N,{step:r+1,steps:o});z=tv(N,r+1,o),B=D}i&&(z=x,B=K)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":L,children:k,"data-action":"close",onClick:c,role:"button",title:L},primaryProps:{"aria-label":B,children:z,"data-action":"primary",onClick:u,role:"button",title:B},skipProps:{"aria-label":W,children:_,"data-action":"skip",onClick:p,role:"button",title:W},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:m,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=Nt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v})}else b=Nt.createElement(Sfe,{...f(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v});return b}function _fe(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Cfe(e,t,n){var r,i;return e?[Pde()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Ide({crossAxis:!1,fallbackPlacements:_fe(n),padding:20,...(i=t.floatingOptions)==null?void 0:i.flipOptions})]}function Afe(e){var q,T,te,U,M;const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:p,size:f,step:d,target:m,updateState:y}=e,v=h.useRef(null),b=h.useRef({}),g=h.useRef({}),k=d.placement==="center",x=d.placement==="auto",C=h.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=h.useMemo(()=>eO(m)?bu(m):void 0,[m]),_=h.useMemo(()=>ku(m),[m]),I=h.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),L=k||x?"bottom":d.placement,K=k?"fixed":((q=d.floatingOptions)==null?void 0:q.strategy)??(d.isFixed||_?"fixed":"absolute"),E=h.useMemo(()=>{var Z,fe,Q,le;return k?[{name:"center",fn:({rects:ae})=>({x:(window.innerWidth-ae.floating.width)/2,y:(window.innerHeight-ae.floating.height)/2})}]:[rI(({placement:ae})=>{var Ie;let ce="right";ae.startsWith("top")?ce="top":ae.startsWith("bottom")?ce="bottom":ae.startsWith("left")&&(ce="left");const ge=d.spotlightTarget?0:d.spotlightPadding[ce];return d.offset+ge+((Ie=d.floatingOptions)!=null&&Ie.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(Z=d.floatingOptions)==null?void 0:Z.hideArrow]),...Cfe(x,d,L),Ede({padding:10,...I,...(fe=d.floatingOptions)==null?void 0:fe.shiftOptions}),...(Q=d.floatingOptions)!=null&&Q.hideArrow?[]:[Tde({element:v,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((le=d.floatingOptions)==null?void 0:le.middleware)??[]]},[k,d,x,L,I]),W=nI({...k?{elements:{reference:C}}:{},placement:L,strategy:K,middleware:E}),z=nI({strategy:K,placement:d.beaconPlacement??(x||k?"bottom":d.placement),middleware:h.useMemo(()=>{var Z,fe;return[rI(((fe=(Z=d.floatingOptions)==null?void 0:Z.beaconOptions)==null?void 0:fe.offset)??-18)]},[(te=(T=d.floatingOptions)==null?void 0:T.beaconOptions)==null?void 0:te.offset]),whileElementsMounted:ZE});g.current=W.middlewareData,b.current=z.middlewareData,h.useEffect(()=>{var Q;const{floating:Z,reference:fe}=W.elements;if(!(!fe||!Z||i!==wt.TOOLTIP))return ZE(fe,Z,W.update,(Q=d.floatingOptions)==null?void 0:Q.autoUpdate)},[i,W.update,(U=d.floatingOptions)==null?void 0:U.autoUpdate,d.target,W.elements]),h.useEffect(()=>{!k&&m&&W.refs.setReference(m),m&&z.refs.setReference(m)},[z.refs,k,m,W.refs]),h.useEffect(()=>{W.isPositioned&&c("tooltip",{placement:W.placement,x:W.x??0,y:W.y??0,middlewareData:g.current})},[c,W.isPositioned,W.placement,W.x,W.y]),h.useEffect(()=>{z.isPositioned&&c("beacon",{placement:z.placement,x:z.x??0,y:z.y??0,middlewareData:b.current})},[c,z.isPositioned,z.placement,z.x,z.y]);const B=d.zIndex+100,D=h.useCallback(Z=>{Z.type==="mouseenter"&&d.beaconTrigger!=="hover"||y({lifecycle:wt.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,y]),H=h.useCallback(Z=>{Z&&(W.refs.setFloating(Z),u(Z))},[W.refs,u]),{arrow:P,floater:$}=d.styles;let O=null;if(i===wt.TOOLTIP||i===wt.TOOLTIP_BEFORE){const Z=iI({...$,...W.floatingStyles,zIndex:B,opacity:a&&W.isPositioned?1:0,...!a&&{transition:"none"}});O=Nt.createElement("div",{ref:H,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:Z},Nt.createElement(Nfe,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:d}),!k&&!((M=d.floatingOptions)!=null&&M.hideArrow)&&Nt.createElement(kfe,{arrowComponent:d.arrowComponent,arrowRef:v,base:d.arrowBase,placement:W.placement,position:W.middlewareData.arrow,size:d.arrowSize,styles:P}))}else(i===wt.BEACON||i===wt.BEACON_BEFORE)&&(O=Nt.createElement("div",{ref:z.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:iI({...z.floatingStyles,zIndex:B})},Nt.createElement(vfe,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:d.locale,nonce:o,onInteract:D,shouldFocus:p,size:f,step:d,styles:d.styles})));return Nt.createElement(sO,{element:l},O)}function Efe(e){const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:p,updateState:f}=e,[d,m]=h.useState(null);wfe(p.disableFocusTrap?null:d,"[data-action=primary]");const y=Us(p.target),v=i===wt.TOOLTIP;return!nO(p)||!Vr.domElement(y)?null:Nt.createElement(Afe,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:u,step:p,target:y,updateState:f})}function Ife({controls:e,mergedProps:t,state:n,step:r,store:i}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,p=cfe(c),{index:f,lifecycle:d,status:m}=n,y=m===qt.RUNNING,[v,b]=h.useState(!1),g=h.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),h.useEffect(()=>{if(!y)return;const N=_=>{!r||d!==wt.TOOLTIP||_.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Ri.KEYBOARD):e.close(Ri.KEYBOARD))};return document.body.addEventListener("keydown",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,y,d,r]);const x=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Ri.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Ri.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const C=n.action===en.START&&!r.skipBeacon&&r.placement!=="center";return Nt.createElement(Nt.Fragment,null,d!==wt.INIT&&Nt.createElement(Efe,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:i.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:i.current.updateState}),Nt.createElement(sO,{element:p},Nt.createElement(Nt.Fragment,null,v&&Nt.createElement(dfe,{nonce:l,step:r}),!C&&Nt.createElement(gfe,{...r,continuous:o,lifecycle:d,onClickOverlay:x,portalElement:c?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Pfe(e){const{controls:t,failures:n,mergedProps:r,state:i,step:o,store:a}=lfe(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>Sg(i,"positioned"),[i]),step:o,Tour:rS()?Nt.createElement(Ife,{controls:t,mergedProps:r,state:i,step:o,store:a}):null}}function Tfe(e){const{Tour:t}=Pfe(e);return t}function Rfe(e){return rS()?Nt.createElement(Tfe,e):null}function Mfe(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function Lfe(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function $fe(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const zh="af:onboarding";function Ofe({page:e,hasNodes:t=!1}){const{t:n}=Ur(),[r,i]=h.useState(!1),[o,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?Mfe(n):t?Lfe(n):$fe(n),[e,t,n]);return h.useEffect(()=>{const u=localStorage.getItem(zh),p=u?JSON.parse(u):{};if(p.completed||p[e]){i(!1),a([]);return}localStorage.setItem(zh,JSON.stringify({...p,[e]:!0})),a(c),i(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const u=p=>{var y;const f=p.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const m=(y=f.textContent)==null?void 0:y.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const v=localStorage.getItem(zh)||"{}",b=JSON.parse(v);m===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(zh,JSON.stringify(b)),a([]),i(!1),e==="projects"&&(m===n("onboarding:done")||m===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:s.jsx(Rfe,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const Dfe="agentflow:recent-runs:v1",Ffe="agentflow:recent-runs:poller",zfe=3e3,Wfe=8e3,Bfe=2e3,dI=5e3,Hfe=16e3,fI=[1e4,3e4,6e4];function Kfe(e){return fI[Math.min(Math.max(e-1,0),fI.length-1)]}function Vfe(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function qfe(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function Ufe(){const{navigate:e,path:t}=rs(),[n,r]=h.useState([]),[i,o]=h.useState(!1),[a,l]=h.useState(1),[c,u]=h.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),p=h.useRef(()=>{});h.useEffect(()=>{let C=!1,N=!1,_=!1,I=null,L=0,K=0,E=0,W=0,z=null,B=0,D=0;const H=Vfe(),P=new Map,$=typeof BroadcastChannel=="function"?new BroadcastChannel(Dfe):null,O=Ae=>{try{$==null||$.postMessage({...Ae,tabId:H,sentAt:Date.now()})}catch{}},q=()=>{const Ae=Date.now()-Hfe;for(const[Te,Ue]of P)Ue<Ae&&P.delete(Te);l(1+P.size)},T=(Ae="presence")=>{O({type:Ae,visible:!document.hidden})},te=Ae=>{if(!C&&(Array.isArray(Ae.runs)&&r(Ae.runs),Ae.syncHealth&&typeof Ae.syncHealth=="object")){const Te=Ae.syncHealth;B=Number(Te.failureCount)||0,D=Number(Te.lastSuccessAt)||0,u(Te)}},U=Ae=>{te(Ae),O({type:"state",...Ae})},M=()=>{L&&(window.clearTimeout(L),L=0)},Z=Ae=>{M(),!(C||!N||document.hidden)&&(L=window.setTimeout(()=>{L=0,fe()},Math.max(0,Ae)))},fe=async()=>{if(C||!N||document.hidden||z)return;const Ae=new AbortController;z=Ae;let Te=!1;const Ue=window.setTimeout(()=>{Te=!0,Ae.abort()},Wfe);try{const Xe=await fetch("/api/pipeline-recent-runs",{signal:Ae.signal});if(!Xe.ok)throw new Error(`HTTP ${Xe.status}`);const ot=await Xe.json();if(C||!N||document.hidden)return;B=0,D=Date.now();const at=Array.isArray(ot.runs)?ot.runs:[];U({runs:at.filter(Mt=>Mt&&Mt.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:D,message:""}}),Z(zfe)}catch(Xe){const ot=Ae.signal.aborted&&!Te;if(C||!N||document.hidden||ot)return;B+=1,U({syncHealth:{status:"delayed",failureCount:B,lastSuccessAt:D,message:Te?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((Xe==null?void 0:Xe.message)||Xe)}`}}),Z(Kfe(B))}finally{window.clearTimeout(Ue),z===Ae&&(z=null)}},Q=()=>{M(),z&&(z.abort(),z=null)},le=()=>{if(Q(),I){const Ae=I;I=null,Ae()}N=!1},ae=(Ae=Bfe)=>{K&&window.clearTimeout(K),!(C||document.hidden||N||_)&&(K=window.setTimeout(()=>{K=0,ge()},Ae))},ce=()=>{C||document.hidden||N||(N=!0,Z(0))},ge=async()=>{var Ae;if(!(C||document.hidden||N||_)){if(!((Ae=navigator.locks)!=null&&Ae.request)){ce();return}_=!0;try{await navigator.locks.request(Ffe,{mode:"exclusive",ifAvailable:!0},async Te=>{if(_=!1,!Te||C||document.hidden){ae();return}N=!0,Z(0),await new Promise(Ue=>{I=Ue}),I=null,N=!1})}catch{_=!1}finally{ae()}}},Ie=()=>{if(!C){if(N){B=0,Z(0);return}O({type:"retry"}),ae(0)}};p.current=Ie,$&&($.onmessage=Ae=>{const Te=Ae.data;if(!(!Te||Te.tabId===H)){if(Te.type==="hello"||Te.type==="presence"){P.set(Te.tabId,Date.now()),q(),Te.type==="hello"&&T();return}if(Te.type==="bye"){P.delete(Te.tabId),q(),ae(0);return}if(Te.type==="state"){P.set(Te.tabId,Date.now()),q(),te(Te);return}Te.type==="retry"&&N&&(B=0,Z(0))}});const de=()=>{T(),document.hidden?le():ae(0)},oe=()=>{T("bye"),le()},je=()=>{T("hello"),ae(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",oe),window.addEventListener("pageshow",je),T("hello"),E=window.setInterval(T,dI),W=window.setInterval(q,dI),ae(0),()=>{C=!0,p.current=()=>{},T("bye"),le(),K&&window.clearTimeout(K),E&&window.clearInterval(E),W&&window.clearInterval(W),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",oe),window.removeEventListener("pageshow",je),$==null||$.close()}},[]);const f=C=>{const N=new URLSearchParams({flowId:C.flowId,flowSource:C.flowSource||"workspace"});e(`/flow?${N.toString()}`),o(!1)},d=t==="/flow"?new URLSearchParams(window.location.search):null,m=(d==null?void 0:d.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(C=>!C)};return s.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[i&&s.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&s.jsxs("div",{className:"af-run-indicator__sync",children:[s.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),s.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&s.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",qfe(c.lastSuccessAt)]}),y&&s.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:C=>{C.stopPropagation(),p.current()},children:"立即重试"})]}),n.map(C=>s.jsxs("button",{type:"button",className:"af-run-indicator__item"+(C.flowId===m?" af-run-indicator__item--current":""),onClick:()=>f(C),title:`${C.flowId} · ${C.runId}`,children:[s.jsx("span",{className:"af-run-indicator__dot"}),s.jsx("span",{className:"af-run-indicator__flow",children:C.flowId}),s.jsx("span",{className:"af-run-indicator__run",children:C.runId.slice(0,12)})]},`${C.flowId}:${C.runId}`))]}),s.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[s.jsx("span",{className:"af-run-indicator__pulse"}),s.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const Qx="0.1.154",Gfe=6e4,Yfe=30*6e4;function cu(e){return String(e||"").trim().replace(/^v/i,"")}function Jfe(e,t){const n=cu(e),r=cu(t);return!!(n&&r&&n!==r)}function Xfe(e,t){return`agentflow.app-version.snooze:${cu(e)}:${cu(t)}`}function Qfe(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Zfe(){const[e,t]=h.useState(null);if(h.useEffect(()=>{let r=!1,i=!1;const o=async()=>{if(!(i||document.visibilityState==="hidden")){i=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const p=cu(u.version);if(!Jfe(Qx,p)){t(null);return}const f=Xfe(Qx,p);if(Qfe(f)>Date.now())return;t({clientVersion:cu(Qx),serverVersion:p,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{i=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),Gfe);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+Yfe))}catch{}t(null)};return s.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),s.jsxs("div",{className:"af-app-version-notice__copy",children:[s.jsx("strong",{children:"AgentFlow 已更新"}),s.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),s.jsxs("div",{className:"af-app-version-notice__actions",children:[s.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),s.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function iO(e){return e==="/likee-context"||e==="/likee_context"}function epe(e){if(e!=="/workspace"&&e!=="/workflow-checklist")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()||e==="/workflow-checklist"&&t.get("demo")==="1"}function tpe(){return s.jsx("div",{className:"af-app-loading",role:"status","aria-live":"polite","aria-label":"AgentFlow 正在启动",children:s.jsxs("div",{className:"af-app-loading__content",children:[s.jsx("div",{className:"af-app-loading__mark",children:s.jsx("img",{src:Wg,alt:""})}),s.jsx("h1",{children:"AgentFlow"}),s.jsx("p",{children:"Orchestration Engine"}),s.jsx("div",{className:"af-app-loading__track","aria-hidden":!0,children:s.jsx("span",{})}),s.jsx("small",{children:"正在连接工作空间…"})]})})}function npe(){const{navigate:e}=rs();return h.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",i=t.get("flowSource")||"";r&&n.set("flowId",r),i&&n.set("flowSource",i),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class rpe extends h.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,i,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((i=this.state.error)==null?void 0:i.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return s.jsx("div",{className:"af-auth-screen",children:s.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"error"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow UI Error"}),s.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),s.jsx("pre",{children:t}),n?s.jsx("pre",{children:n}):null]})})}}function spe({authUser:e}){const{path:t}=rs();return t==="/projects"||t==="/"?s.jsx(rc,{authUser:e}):t==="/nodes"?s.jsx(rc,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?s.jsx(rc,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?s.jsx(rc,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?s.jsx(rc,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?s.jsx(hle,{authUser:e}):t==="/workflows"?s.jsx(Ale,{authUser:e}):t==="/workflow-report"?s.jsx(bce,{}):t==="/workflow-checklist"?s.jsx(A$,{}):t==="/mcps"?s.jsx(tle,{}):t==="/schedules"?s.jsx(ile,{}):t==="/node-studio"?s.jsx(lle,{}):t==="/flow"?s.jsx(npe,{}):t==="/workspace"?s.jsx(X2,{}):t.startsWith("/display")?s.jsx(e$,{}):t==="/settings"?s.jsx(Fae,{authUser:e}):t==="/admin/usage"?s.jsx(Uae,{authUser:e}):t==="/admin/teams"?s.jsx(Gae,{authUser:e}):t==="/feedback"?s.jsx(Jae,{authUser:e}):iO(t)?s.jsx(E$,{}):s.jsx(rc,{})}function ipe({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,i]=h.useState(""),[o,a]=h.useState(""),[l,c]=h.useState(!1),[u,p]=h.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),p(y.error?String(y.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),p(String(m.message||m))}};h.useEffect(()=>{f()},[]);const d=async m=>{m.preventDefault(),c(!0),p("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");i(""),a(""),window.location.replace(window.location.href);return}catch(y){p(String(y.message||y))}finally{c(!1)}};return t.loading?s.jsx(tpe,{}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):s.jsx("div",{className:"af-auth-screen",children:s.jsxs("form",{className:"af-auth-panel",onSubmit:d,autoComplete:"on",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow"}),s.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"用户名"}),s.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:m=>i(m.target.value),autoComplete:"username",autoFocus:!0})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"密码"}),s.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?s.jsx("p",{className:"af-auth-error",children:u}):null,s.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function ope({authUser:e,onLogout:t}){const{path:n}=rs(),r=n==="/workflow-report",i=n==="/flow"||n==="/workspace"||n==="/workflow-checklist",o=i||r;return s.jsxs("div",{className:"af-app",children:[n!=="/settings"&&!r?s.jsx(Ofe,{page:i?"flow":"projects"}):null,o?null:s.jsx(qz,{authUser:e,onLogout:t}),s.jsx("div",{className:o?"af-main af-main--pipeline":"af-main",children:s.jsx(spe,{authUser:e})}),s.jsx(Ufe,{})]})}function ape(){return s.jsx(rpe,{children:s.jsxs(Cz,{children:[s.jsx(lpe,{}),s.jsx(Zfe,{})]})})}function lpe(){const{path:e}=rs();return e.startsWith("/display")?s.jsx(e$,{}):iO(e)?s.jsx(E$,{}):epe(e)?e==="/workflow-checklist"?s.jsx(A$,{}):s.jsx(X2,{}):s.jsx(ipe,{children:({user:t,onLogout:n})=>s.jsx(ope,{authUser:t,onLogout:n})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const pI=document.querySelector('link[rel="icon"]');pI&&(pI.href=Wg);Zx.createRoot(document.getElementById("root")).render(s.jsx(Nt.StrictMode,{children:s.jsx(ape,{})}));export{Ef as M,Nt as R,gpe as a,ar as b,Ia as g,s as j,h as r};
870
+ `)),document.head.appendChild(b);const g=setTimeout(()=>{Vr.domElement(d.current)&&c&&d.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[m,a,c]);const y=co(o.open);let v;if(t){const b=t;v=Nt.createElement(b,{continuous:n,index:r,isLastStep:i,size:u,step:p})}else v=Nt.createElement("span",{style:f.beacon},Nt.createElement("span",{style:f.beaconOuter}),Nt.createElement("span",{style:f.beaconInner}));return Nt.createElement("button",{ref:d,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function jfe({styles:e,...t}){const{color:n,height:r,width:i,...o}=e;return Nt.createElement("button",{style:o,type:"button",...t},Nt.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof i=="number"?`${i}px`:i,xmlns:"http://www.w3.org/2000/svg"},Nt.createElement("g",null,Nt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Sfe(e){const{backProps:t,closeProps:n,index:r,isLastStep:i,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:p,styles:f,title:d}=l,m={};u.includes("primary")&&(m.primary=Nt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!i&&(m.skip=Nt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(m.back=Nt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),m.close=u.includes("close")&&Nt.createElement(jfe,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":co(p),"aria-describedby":"joyride-tooltip-content"};return Nt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},Nt.createElement("div",{style:f.tooltipContainer},d&&Nt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},d),Nt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},p)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&Nt.createElement("div",{style:f.tooltipFooter},Nt.createElement("div",{style:f.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function Nfe(e){const{continuous:t,controls:n,index:r,isLastStep:i,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Ri.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Ri.BUTTON_CLOSE):n.close(Ri.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Ri.BUTTON_PRIMARY);return}n.next(Ri.BUTTON_PRIMARY)},p=g=>{g.preventDefault(),n.skip(Ri.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:C,nextWithProgress:N,skip:_}=a.locale,I=co(g),L=co(k),K=co(x),E=co(C),W=co(_);let z=k,B=L;if(t){if(z=C,B=E,a.showProgress&&!i){const D=co(N,{step:r+1,steps:o});z=tv(N,r+1,o),B=D}i&&(z=x,B=K)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":L,children:k,"data-action":"close",onClick:c,role:"button",title:L},primaryProps:{"aria-label":B,children:z,"data-action":"primary",onClick:u,role:"button",title:B},skipProps:{"aria-label":W,children:_,"data-action":"skip",onClick:p,role:"button",title:W},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:m,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=Nt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v})}else b=Nt.createElement(Sfe,{...f(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v});return b}function _fe(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Cfe(e,t,n){var r,i;return e?[Pde()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Ide({crossAxis:!1,fallbackPlacements:_fe(n),padding:20,...(i=t.floatingOptions)==null?void 0:i.flipOptions})]}function Afe(e){var q,T,te,U,M;const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:p,size:f,step:d,target:m,updateState:y}=e,v=h.useRef(null),b=h.useRef({}),g=h.useRef({}),k=d.placement==="center",x=d.placement==="auto",C=h.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=h.useMemo(()=>eO(m)?bu(m):void 0,[m]),_=h.useMemo(()=>ku(m),[m]),I=h.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),L=k||x?"bottom":d.placement,K=k?"fixed":((q=d.floatingOptions)==null?void 0:q.strategy)??(d.isFixed||_?"fixed":"absolute"),E=h.useMemo(()=>{var Z,fe,Q,le;return k?[{name:"center",fn:({rects:ae})=>({x:(window.innerWidth-ae.floating.width)/2,y:(window.innerHeight-ae.floating.height)/2})}]:[rI(({placement:ae})=>{var Ie;let ce="right";ae.startsWith("top")?ce="top":ae.startsWith("bottom")?ce="bottom":ae.startsWith("left")&&(ce="left");const ge=d.spotlightTarget?0:d.spotlightPadding[ce];return d.offset+ge+((Ie=d.floatingOptions)!=null&&Ie.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(Z=d.floatingOptions)==null?void 0:Z.hideArrow]),...Cfe(x,d,L),Ede({padding:10,...I,...(fe=d.floatingOptions)==null?void 0:fe.shiftOptions}),...(Q=d.floatingOptions)!=null&&Q.hideArrow?[]:[Tde({element:v,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((le=d.floatingOptions)==null?void 0:le.middleware)??[]]},[k,d,x,L,I]),W=nI({...k?{elements:{reference:C}}:{},placement:L,strategy:K,middleware:E}),z=nI({strategy:K,placement:d.beaconPlacement??(x||k?"bottom":d.placement),middleware:h.useMemo(()=>{var Z,fe;return[rI(((fe=(Z=d.floatingOptions)==null?void 0:Z.beaconOptions)==null?void 0:fe.offset)??-18)]},[(te=(T=d.floatingOptions)==null?void 0:T.beaconOptions)==null?void 0:te.offset]),whileElementsMounted:ZE});g.current=W.middlewareData,b.current=z.middlewareData,h.useEffect(()=>{var Q;const{floating:Z,reference:fe}=W.elements;if(!(!fe||!Z||i!==wt.TOOLTIP))return ZE(fe,Z,W.update,(Q=d.floatingOptions)==null?void 0:Q.autoUpdate)},[i,W.update,(U=d.floatingOptions)==null?void 0:U.autoUpdate,d.target,W.elements]),h.useEffect(()=>{!k&&m&&W.refs.setReference(m),m&&z.refs.setReference(m)},[z.refs,k,m,W.refs]),h.useEffect(()=>{W.isPositioned&&c("tooltip",{placement:W.placement,x:W.x??0,y:W.y??0,middlewareData:g.current})},[c,W.isPositioned,W.placement,W.x,W.y]),h.useEffect(()=>{z.isPositioned&&c("beacon",{placement:z.placement,x:z.x??0,y:z.y??0,middlewareData:b.current})},[c,z.isPositioned,z.placement,z.x,z.y]);const B=d.zIndex+100,D=h.useCallback(Z=>{Z.type==="mouseenter"&&d.beaconTrigger!=="hover"||y({lifecycle:wt.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,y]),H=h.useCallback(Z=>{Z&&(W.refs.setFloating(Z),u(Z))},[W.refs,u]),{arrow:P,floater:$}=d.styles;let O=null;if(i===wt.TOOLTIP||i===wt.TOOLTIP_BEFORE){const Z=iI({...$,...W.floatingStyles,zIndex:B,opacity:a&&W.isPositioned?1:0,...!a&&{transition:"none"}});O=Nt.createElement("div",{ref:H,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:Z},Nt.createElement(Nfe,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:d}),!k&&!((M=d.floatingOptions)!=null&&M.hideArrow)&&Nt.createElement(kfe,{arrowComponent:d.arrowComponent,arrowRef:v,base:d.arrowBase,placement:W.placement,position:W.middlewareData.arrow,size:d.arrowSize,styles:P}))}else(i===wt.BEACON||i===wt.BEACON_BEFORE)&&(O=Nt.createElement("div",{ref:z.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:iI({...z.floatingStyles,zIndex:B})},Nt.createElement(vfe,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:d.locale,nonce:o,onInteract:D,shouldFocus:p,size:f,step:d,styles:d.styles})));return Nt.createElement(sO,{element:l},O)}function Efe(e){const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:p,updateState:f}=e,[d,m]=h.useState(null);wfe(p.disableFocusTrap?null:d,"[data-action=primary]");const y=Us(p.target),v=i===wt.TOOLTIP;return!nO(p)||!Vr.domElement(y)?null:Nt.createElement(Afe,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:u,step:p,target:y,updateState:f})}function Ife({controls:e,mergedProps:t,state:n,step:r,store:i}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,p=cfe(c),{index:f,lifecycle:d,status:m}=n,y=m===qt.RUNNING,[v,b]=h.useState(!1),g=h.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),h.useEffect(()=>{if(!y)return;const N=_=>{!r||d!==wt.TOOLTIP||_.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Ri.KEYBOARD):e.close(Ri.KEYBOARD))};return document.body.addEventListener("keydown",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,y,d,r]);const x=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Ri.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Ri.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const C=n.action===en.START&&!r.skipBeacon&&r.placement!=="center";return Nt.createElement(Nt.Fragment,null,d!==wt.INIT&&Nt.createElement(Efe,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:i.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:i.current.updateState}),Nt.createElement(sO,{element:p},Nt.createElement(Nt.Fragment,null,v&&Nt.createElement(dfe,{nonce:l,step:r}),!C&&Nt.createElement(gfe,{...r,continuous:o,lifecycle:d,onClickOverlay:x,portalElement:c?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Pfe(e){const{controls:t,failures:n,mergedProps:r,state:i,step:o,store:a}=lfe(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>Sg(i,"positioned"),[i]),step:o,Tour:rS()?Nt.createElement(Ife,{controls:t,mergedProps:r,state:i,step:o,store:a}):null}}function Tfe(e){const{Tour:t}=Pfe(e);return t}function Rfe(e){return rS()?Nt.createElement(Tfe,e):null}function Mfe(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function Lfe(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function $fe(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const zh="af:onboarding";function Ofe({page:e,hasNodes:t=!1}){const{t:n}=Ur(),[r,i]=h.useState(!1),[o,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?Mfe(n):t?Lfe(n):$fe(n),[e,t,n]);return h.useEffect(()=>{const u=localStorage.getItem(zh),p=u?JSON.parse(u):{};if(p.completed||p[e]){i(!1),a([]);return}localStorage.setItem(zh,JSON.stringify({...p,[e]:!0})),a(c),i(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const u=p=>{var y;const f=p.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const m=(y=f.textContent)==null?void 0:y.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const v=localStorage.getItem(zh)||"{}",b=JSON.parse(v);m===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(zh,JSON.stringify(b)),a([]),i(!1),e==="projects"&&(m===n("onboarding:done")||m===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:s.jsx(Rfe,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const Dfe="agentflow:recent-runs:v1",Ffe="agentflow:recent-runs:poller",zfe=3e3,Wfe=8e3,Bfe=2e3,dI=5e3,Hfe=16e3,fI=[1e4,3e4,6e4];function Kfe(e){return fI[Math.min(Math.max(e-1,0),fI.length-1)]}function Vfe(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function qfe(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function Ufe(){const{navigate:e,path:t}=rs(),[n,r]=h.useState([]),[i,o]=h.useState(!1),[a,l]=h.useState(1),[c,u]=h.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),p=h.useRef(()=>{});h.useEffect(()=>{let C=!1,N=!1,_=!1,I=null,L=0,K=0,E=0,W=0,z=null,B=0,D=0;const H=Vfe(),P=new Map,$=typeof BroadcastChannel=="function"?new BroadcastChannel(Dfe):null,O=Ae=>{try{$==null||$.postMessage({...Ae,tabId:H,sentAt:Date.now()})}catch{}},q=()=>{const Ae=Date.now()-Hfe;for(const[Te,Ue]of P)Ue<Ae&&P.delete(Te);l(1+P.size)},T=(Ae="presence")=>{O({type:Ae,visible:!document.hidden})},te=Ae=>{if(!C&&(Array.isArray(Ae.runs)&&r(Ae.runs),Ae.syncHealth&&typeof Ae.syncHealth=="object")){const Te=Ae.syncHealth;B=Number(Te.failureCount)||0,D=Number(Te.lastSuccessAt)||0,u(Te)}},U=Ae=>{te(Ae),O({type:"state",...Ae})},M=()=>{L&&(window.clearTimeout(L),L=0)},Z=Ae=>{M(),!(C||!N||document.hidden)&&(L=window.setTimeout(()=>{L=0,fe()},Math.max(0,Ae)))},fe=async()=>{if(C||!N||document.hidden||z)return;const Ae=new AbortController;z=Ae;let Te=!1;const Ue=window.setTimeout(()=>{Te=!0,Ae.abort()},Wfe);try{const Xe=await fetch("/api/pipeline-recent-runs",{signal:Ae.signal});if(!Xe.ok)throw new Error(`HTTP ${Xe.status}`);const ot=await Xe.json();if(C||!N||document.hidden)return;B=0,D=Date.now();const at=Array.isArray(ot.runs)?ot.runs:[];U({runs:at.filter(Mt=>Mt&&Mt.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:D,message:""}}),Z(zfe)}catch(Xe){const ot=Ae.signal.aborted&&!Te;if(C||!N||document.hidden||ot)return;B+=1,U({syncHealth:{status:"delayed",failureCount:B,lastSuccessAt:D,message:Te?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((Xe==null?void 0:Xe.message)||Xe)}`}}),Z(Kfe(B))}finally{window.clearTimeout(Ue),z===Ae&&(z=null)}},Q=()=>{M(),z&&(z.abort(),z=null)},le=()=>{if(Q(),I){const Ae=I;I=null,Ae()}N=!1},ae=(Ae=Bfe)=>{K&&window.clearTimeout(K),!(C||document.hidden||N||_)&&(K=window.setTimeout(()=>{K=0,ge()},Ae))},ce=()=>{C||document.hidden||N||(N=!0,Z(0))},ge=async()=>{var Ae;if(!(C||document.hidden||N||_)){if(!((Ae=navigator.locks)!=null&&Ae.request)){ce();return}_=!0;try{await navigator.locks.request(Ffe,{mode:"exclusive",ifAvailable:!0},async Te=>{if(_=!1,!Te||C||document.hidden){ae();return}N=!0,Z(0),await new Promise(Ue=>{I=Ue}),I=null,N=!1})}catch{_=!1}finally{ae()}}},Ie=()=>{if(!C){if(N){B=0,Z(0);return}O({type:"retry"}),ae(0)}};p.current=Ie,$&&($.onmessage=Ae=>{const Te=Ae.data;if(!(!Te||Te.tabId===H)){if(Te.type==="hello"||Te.type==="presence"){P.set(Te.tabId,Date.now()),q(),Te.type==="hello"&&T();return}if(Te.type==="bye"){P.delete(Te.tabId),q(),ae(0);return}if(Te.type==="state"){P.set(Te.tabId,Date.now()),q(),te(Te);return}Te.type==="retry"&&N&&(B=0,Z(0))}});const de=()=>{T(),document.hidden?le():ae(0)},oe=()=>{T("bye"),le()},je=()=>{T("hello"),ae(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",oe),window.addEventListener("pageshow",je),T("hello"),E=window.setInterval(T,dI),W=window.setInterval(q,dI),ae(0),()=>{C=!0,p.current=()=>{},T("bye"),le(),K&&window.clearTimeout(K),E&&window.clearInterval(E),W&&window.clearInterval(W),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",oe),window.removeEventListener("pageshow",je),$==null||$.close()}},[]);const f=C=>{const N=new URLSearchParams({flowId:C.flowId,flowSource:C.flowSource||"workspace"});e(`/flow?${N.toString()}`),o(!1)},d=t==="/flow"?new URLSearchParams(window.location.search):null,m=(d==null?void 0:d.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(C=>!C)};return s.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[i&&s.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&s.jsxs("div",{className:"af-run-indicator__sync",children:[s.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),s.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&s.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",qfe(c.lastSuccessAt)]}),y&&s.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:C=>{C.stopPropagation(),p.current()},children:"立即重试"})]}),n.map(C=>s.jsxs("button",{type:"button",className:"af-run-indicator__item"+(C.flowId===m?" af-run-indicator__item--current":""),onClick:()=>f(C),title:`${C.flowId} · ${C.runId}`,children:[s.jsx("span",{className:"af-run-indicator__dot"}),s.jsx("span",{className:"af-run-indicator__flow",children:C.flowId}),s.jsx("span",{className:"af-run-indicator__run",children:C.runId.slice(0,12)})]},`${C.flowId}:${C.runId}`))]}),s.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[s.jsx("span",{className:"af-run-indicator__pulse"}),s.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const Qx="0.1.156",Gfe=6e4,Yfe=30*6e4;function cu(e){return String(e||"").trim().replace(/^v/i,"")}function Jfe(e,t){const n=cu(e),r=cu(t);return!!(n&&r&&n!==r)}function Xfe(e,t){return`agentflow.app-version.snooze:${cu(e)}:${cu(t)}`}function Qfe(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Zfe(){const[e,t]=h.useState(null);if(h.useEffect(()=>{let r=!1,i=!1;const o=async()=>{if(!(i||document.visibilityState==="hidden")){i=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const p=cu(u.version);if(!Jfe(Qx,p)){t(null);return}const f=Xfe(Qx,p);if(Qfe(f)>Date.now())return;t({clientVersion:cu(Qx),serverVersion:p,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{i=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),Gfe);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+Yfe))}catch{}t(null)};return s.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),s.jsxs("div",{className:"af-app-version-notice__copy",children:[s.jsx("strong",{children:"AgentFlow 已更新"}),s.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),s.jsxs("div",{className:"af-app-version-notice__actions",children:[s.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),s.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function iO(e){return e==="/likee-context"||e==="/likee_context"}function epe(e){if(e!=="/workspace"&&e!=="/workflow-checklist")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()||e==="/workflow-checklist"&&t.get("demo")==="1"}function tpe(){return s.jsx("div",{className:"af-app-loading",role:"status","aria-live":"polite","aria-label":"AgentFlow 正在启动",children:s.jsxs("div",{className:"af-app-loading__content",children:[s.jsx("div",{className:"af-app-loading__mark",children:s.jsx("img",{src:Wg,alt:""})}),s.jsx("h1",{children:"AgentFlow"}),s.jsx("p",{children:"Orchestration Engine"}),s.jsx("div",{className:"af-app-loading__track","aria-hidden":!0,children:s.jsx("span",{})}),s.jsx("small",{children:"正在连接工作空间…"})]})})}function npe(){const{navigate:e}=rs();return h.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",i=t.get("flowSource")||"";r&&n.set("flowId",r),i&&n.set("flowSource",i),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class rpe extends h.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,i,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((i=this.state.error)==null?void 0:i.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return s.jsx("div",{className:"af-auth-screen",children:s.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"error"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow UI Error"}),s.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),s.jsx("pre",{children:t}),n?s.jsx("pre",{children:n}):null]})})}}function spe({authUser:e}){const{path:t}=rs();return t==="/projects"||t==="/"?s.jsx(rc,{authUser:e}):t==="/nodes"?s.jsx(rc,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?s.jsx(rc,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?s.jsx(rc,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?s.jsx(rc,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?s.jsx(hle,{authUser:e}):t==="/workflows"?s.jsx(Ale,{authUser:e}):t==="/workflow-report"?s.jsx(bce,{}):t==="/workflow-checklist"?s.jsx(A$,{}):t==="/mcps"?s.jsx(tle,{}):t==="/schedules"?s.jsx(ile,{}):t==="/node-studio"?s.jsx(lle,{}):t==="/flow"?s.jsx(npe,{}):t==="/workspace"?s.jsx(X2,{}):t.startsWith("/display")?s.jsx(e$,{}):t==="/settings"?s.jsx(Fae,{authUser:e}):t==="/admin/usage"?s.jsx(Uae,{authUser:e}):t==="/admin/teams"?s.jsx(Gae,{authUser:e}):t==="/feedback"?s.jsx(Jae,{authUser:e}):iO(t)?s.jsx(E$,{}):s.jsx(rc,{})}function ipe({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,i]=h.useState(""),[o,a]=h.useState(""),[l,c]=h.useState(!1),[u,p]=h.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),p(y.error?String(y.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),p(String(m.message||m))}};h.useEffect(()=>{f()},[]);const d=async m=>{m.preventDefault(),c(!0),p("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");i(""),a(""),window.location.replace(window.location.href);return}catch(y){p(String(y.message||y))}finally{c(!1)}};return t.loading?s.jsx(tpe,{}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):s.jsx("div",{className:"af-auth-screen",children:s.jsxs("form",{className:"af-auth-panel",onSubmit:d,autoComplete:"on",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow"}),s.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"用户名"}),s.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:m=>i(m.target.value),autoComplete:"username",autoFocus:!0})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"密码"}),s.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?s.jsx("p",{className:"af-auth-error",children:u}):null,s.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function ope({authUser:e,onLogout:t}){const{path:n}=rs(),r=n==="/workflow-report",i=n==="/flow"||n==="/workspace"||n==="/workflow-checklist",o=i||r;return s.jsxs("div",{className:"af-app",children:[n!=="/settings"&&!r?s.jsx(Ofe,{page:i?"flow":"projects"}):null,o?null:s.jsx(qz,{authUser:e,onLogout:t}),s.jsx("div",{className:o?"af-main af-main--pipeline":"af-main",children:s.jsx(spe,{authUser:e})}),s.jsx(Ufe,{})]})}function ape(){return s.jsx(rpe,{children:s.jsxs(Cz,{children:[s.jsx(lpe,{}),s.jsx(Zfe,{})]})})}function lpe(){const{path:e}=rs();return e.startsWith("/display")?s.jsx(e$,{}):iO(e)?s.jsx(E$,{}):epe(e)?e==="/workflow-checklist"?s.jsx(A$,{}):s.jsx(X2,{}):s.jsx(ipe,{children:({user:t,onLogout:n})=>s.jsx(ope,{authUser:t,onLogout:n})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const pI=document.querySelector('link[rel="icon"]');pI&&(pI.href=Wg);Zx.createRoot(document.getElementById("root")).render(s.jsx(Nt.StrictMode,{children:s.jsx(ape,{})}));export{Ef as M,Nt as R,gpe as a,ar as b,Ia as g,s as j,h as r};
@@ -30,7 +30,7 @@
30
30
  @keyframes af-app-loading-slide { from { transform: translateX(-115%); } to { transform: translateX(250%); } }
31
31
  @media (prefers-reduced-motion: reduce) { .af-app-loading__track span { width: 100%; animation: none; } }
32
32
  </style>
33
- <script type="module" crossorigin src="/assets/index-BZ5KqLur.js"></script>
33
+ <script type="module" crossorigin src="/assets/index-BJzMYRK3.js"></script>
34
34
  <link rel="stylesheet" crossorigin href="/assets/index-CEXmmwM2.css">
35
35
  </head>
36
36
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldwangai/agentflow",
3
- "version": "0.1.154",
3
+ "version": "0.1.156",
4
4
  "description": "Orchestration system for long-running complex agent tasks using Cursor, OpenCode, Claude Code, or Codex as execution backends",
5
5
  "type": "module",
6
6
  "main": "bin/agentflow.mjs",
@@ -54,6 +54,7 @@
54
54
  "dev:web": "cd builtin/web-ui && npm run dev",
55
55
  "dev:website": "cd website && npm run dev",
56
56
  "preview:website": "cd website && npm run preview",
57
+ "version": "npm --prefix builtin/web-ui run build && git add builtin/web-ui/dist",
57
58
  "prepack": "npm run build:web-ui"
58
59
  },
59
60
  "dependencies": {