@dilipod/ui 0.4.34 → 0.4.35
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.
- package/dist/components/file-preview.d.ts +1 -0
- package/dist/components/file-preview.d.ts.map +1 -1
- package/dist/components/flowchart-diagram.d.ts.map +1 -1
- package/dist/index.js +356 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +357 -163
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/file-preview.tsx +29 -15
- package/src/components/flowchart-diagram.tsx +446 -216
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { clsx } from 'clsx';
|
|
|
10
10
|
import { twMerge } from 'tailwind-merge';
|
|
11
11
|
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
12
12
|
import * as react_star from '@phosphor-icons/react';
|
|
13
|
-
import { X, CaretDown, Circle, CaretLeft, DotsThree, CaretRight, Check, House, Info, WarningCircle, Play, Download, Folder, ArrowSquareOut,
|
|
13
|
+
import { X, CaretDown, Circle, CaretLeft, DotsThree, CaretRight, Check, House, Info, WarningCircle, CircleNotch, Play, Download, Folder, ArrowSquareOut, File, FileVideo, Lightning, CheckCircle, CaretUp, Plus, PaperPlaneTilt, Eye, TreeStructure, Code, PencilSimple, WebhooksLogo, Copy, CloudArrowUp, CloudArrowDown, ArrowsClockwise, DownloadSimple, ClockCounterClockwise, ArrowsLeftRight, Minus, Pencil, Robot, MagnifyingGlass, FilmStrip, FileText, ImageSquare, TextT, Target, Crosshair, ListNumbers, Wrench, Clock, TrendUp, CurrencyEur, Sparkle, Plugs, ShieldCheck, FileImage, FilePdf, FileDoc, Question, Warning, Trash, Globe, GitBranch, Package, Timer, VideoCamera, Lightbulb } from '@phosphor-icons/react';
|
|
14
14
|
import 'react-dom';
|
|
15
15
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
16
16
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
@@ -3957,7 +3957,8 @@ function FilePreview({
|
|
|
3957
3957
|
const FileIcon = getFileIcon(file.type);
|
|
3958
3958
|
const typeLabel = getTypeLabel(file.type);
|
|
3959
3959
|
const sizeLabel = formatSize(file.size);
|
|
3960
|
-
const
|
|
3960
|
+
const isProcessing = file.processing === true;
|
|
3961
|
+
const isPreviewable = !isProcessing && canPreview(file);
|
|
3961
3962
|
const previewType = getPreviewType(file);
|
|
3962
3963
|
return /* @__PURE__ */ jsxs(
|
|
3963
3964
|
"div",
|
|
@@ -3967,20 +3968,20 @@ function FilePreview({
|
|
|
3967
3968
|
children: [
|
|
3968
3969
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
3969
3970
|
/* @__PURE__ */ jsxs("div", { className: "relative shrink-0", children: [
|
|
3970
|
-
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 rounded-sm bg-white border border-gray-200 flex items-center justify-center", children: /* @__PURE__ */ jsx(FileIcon, { className: "w-5 h-5 text-[var(--cyan)]", weight: "fill" }) }),
|
|
3971
|
-
previewType === "video" && /* @__PURE__ */ jsx(Play, { className: "absolute -bottom-0.5 -right-0.5 w-3.5 h-3.5 text-[var(--cyan)] bg-white rounded-full", weight: "fill" })
|
|
3971
|
+
/* @__PURE__ */ jsx("div", { className: "w-10 h-10 rounded-sm bg-white border border-gray-200 flex items-center justify-center", children: isProcessing ? /* @__PURE__ */ jsx(CircleNotch, { className: "w-5 h-5 text-[var(--cyan)] animate-spin" }) : /* @__PURE__ */ jsx(FileIcon, { className: "w-5 h-5 text-[var(--cyan)]", weight: "fill" }) }),
|
|
3972
|
+
!isProcessing && previewType === "video" && /* @__PURE__ */ jsx(Play, { className: "absolute -bottom-0.5 -right-0.5 w-3.5 h-3.5 text-[var(--cyan)] bg-white rounded-full", weight: "fill" })
|
|
3972
3973
|
] }),
|
|
3973
3974
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
3974
3975
|
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-[var(--black)] truncate", children: file.filename }),
|
|
3975
|
-
/* @__PURE__ */
|
|
3976
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: isProcessing ? /* @__PURE__ */ jsx("span", { className: "text-amber-600", children: "Processing video \u2014 this takes about a minute" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3976
3977
|
typeLabel,
|
|
3977
3978
|
" \xB7 ",
|
|
3978
3979
|
sizeLabel,
|
|
3979
3980
|
isPreviewable && /* @__PURE__ */ jsx("span", { className: "text-[var(--cyan)] ml-1", children: "\xB7 Click to preview" })
|
|
3980
|
-
] })
|
|
3981
|
+
] }) })
|
|
3981
3982
|
] })
|
|
3982
3983
|
] }),
|
|
3983
|
-
/* @__PURE__ */ jsx(
|
|
3984
|
+
!isProcessing && /* @__PURE__ */ jsx(
|
|
3984
3985
|
"button",
|
|
3985
3986
|
{
|
|
3986
3987
|
onClick: (e) => handleDownload(e, file),
|
|
@@ -6253,190 +6254,383 @@ function WorkflowViewer({
|
|
|
6253
6254
|
] })
|
|
6254
6255
|
] });
|
|
6255
6256
|
}
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6257
|
+
var NODE_WIDTH = 180;
|
|
6258
|
+
var NODE_HEIGHT = 44;
|
|
6259
|
+
var DIAMOND_SIZE = 72;
|
|
6260
|
+
var X_GAP = 50;
|
|
6261
|
+
var Y_GAP = 64;
|
|
6262
|
+
var PADDING = 40;
|
|
6263
|
+
var FONT_SIZE = 11;
|
|
6264
|
+
var CHAR_WIDTH = 6.2;
|
|
6265
|
+
var LINE_HEIGHT = 14;
|
|
6266
|
+
function stripQuotes(s) {
|
|
6267
|
+
const t = s.trim();
|
|
6268
|
+
if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'")) {
|
|
6269
|
+
return t.slice(1, -1);
|
|
6270
|
+
}
|
|
6271
|
+
return t;
|
|
6272
|
+
}
|
|
6273
|
+
function parseNodeRef(raw) {
|
|
6274
|
+
const s = raw.trim();
|
|
6275
|
+
const decision = s.match(/^([A-Za-z0-9_]+)\{(.+)\}$/);
|
|
6276
|
+
if (decision) return { id: decision[1], label: stripQuotes(decision[2]), type: "decision" };
|
|
6277
|
+
const stadium = s.match(/^([A-Za-z0-9_]+)\(\[(.+)\]\)$/);
|
|
6278
|
+
if (stadium) return { id: stadium[1], label: stripQuotes(stadium[2]), type: "terminal" };
|
|
6279
|
+
const circle = s.match(/^([A-Za-z0-9_]+)\(\((.+)\)\)$/);
|
|
6280
|
+
if (circle) return { id: circle[1], label: stripQuotes(circle[2]), type: "terminal" };
|
|
6281
|
+
const rounded = s.match(/^([A-Za-z0-9_]+)\(([^[(].+?)\)$/);
|
|
6282
|
+
if (rounded) return { id: rounded[1], label: stripQuotes(rounded[2]), type: "action" };
|
|
6283
|
+
const rect = s.match(/^([A-Za-z0-9_]+)\[([^(].+?)\]$/);
|
|
6284
|
+
if (rect) {
|
|
6285
|
+
const label = stripQuotes(rect[2]);
|
|
6286
|
+
const isTerminal = /^(start|end|begin|finish|done|stop)$/i.test(label);
|
|
6287
|
+
return { id: rect[1], label, type: isTerminal ? "terminal" : "action" };
|
|
6288
|
+
}
|
|
6289
|
+
const bareId = s.match(/^([A-Za-z0-9_]+)$/);
|
|
6290
|
+
if (bareId) return { id: bareId[1] };
|
|
6291
|
+
return { id: s };
|
|
6292
|
+
}
|
|
6293
|
+
function registerNode(map, ref) {
|
|
6294
|
+
if (!ref.id) return;
|
|
6295
|
+
const existing = map.get(ref.id);
|
|
6296
|
+
if (existing) {
|
|
6297
|
+
if (ref.label && existing.label === existing.id) {
|
|
6298
|
+
existing.label = ref.label;
|
|
6268
6299
|
}
|
|
6269
|
-
|
|
6300
|
+
if (ref.type && ref.type !== "action" && existing.type === "action") {
|
|
6301
|
+
existing.type = ref.type;
|
|
6302
|
+
}
|
|
6303
|
+
return;
|
|
6270
6304
|
}
|
|
6305
|
+
map.set(ref.id, {
|
|
6306
|
+
id: ref.id,
|
|
6307
|
+
label: ref.label || ref.id,
|
|
6308
|
+
type: ref.type || "action"
|
|
6309
|
+
});
|
|
6310
|
+
}
|
|
6311
|
+
function parseMermaidFlowchart(mermaid) {
|
|
6312
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
6313
|
+
const edges = [];
|
|
6314
|
+
const lines = mermaid.split(/\\n|\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith("%%"));
|
|
6271
6315
|
for (const line of lines) {
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6316
|
+
if (/^(flowchart|graph|subgraph|end|style|classDef|class|click|linkStyle)\b/i.test(line)) continue;
|
|
6317
|
+
const edgeMatch = line.match(
|
|
6318
|
+
/^(.+?)\s*(?:-->|==>|-\.->|---)\s*(?:\|([^|]*)\|)?\s*(.+)$/
|
|
6319
|
+
);
|
|
6320
|
+
if (edgeMatch) {
|
|
6321
|
+
const leftNode = parseNodeRef(edgeMatch[1].trim());
|
|
6322
|
+
const edgeLabel = edgeMatch[2]?.trim() || void 0;
|
|
6323
|
+
const rightNode = parseNodeRef(edgeMatch[3].trim());
|
|
6324
|
+
registerNode(nodeMap, leftNode);
|
|
6325
|
+
registerNode(nodeMap, rightNode);
|
|
6326
|
+
edges.push({ from: leftNode.id, to: rightNode.id, label: edgeLabel });
|
|
6327
|
+
continue;
|
|
6281
6328
|
}
|
|
6282
|
-
|
|
6283
|
-
|
|
6329
|
+
const nodeDef = parseNodeRef(line);
|
|
6330
|
+
if (nodeDef.label) {
|
|
6331
|
+
registerNode(nodeMap, nodeDef);
|
|
6284
6332
|
}
|
|
6285
|
-
|
|
6286
|
-
|
|
6333
|
+
}
|
|
6334
|
+
return { nodes: Array.from(nodeMap.values()), edges };
|
|
6335
|
+
}
|
|
6336
|
+
function computeLayout(nodes, edges) {
|
|
6337
|
+
if (nodes.length === 0) return { layoutNodes: [], svgWidth: 0, svgHeight: 0 };
|
|
6338
|
+
const forward = /* @__PURE__ */ new Map();
|
|
6339
|
+
const backward = /* @__PURE__ */ new Map();
|
|
6340
|
+
for (const e of edges) {
|
|
6341
|
+
if (!forward.has(e.from)) forward.set(e.from, []);
|
|
6342
|
+
forward.get(e.from).push(e.to);
|
|
6343
|
+
if (!backward.has(e.to)) backward.set(e.to, []);
|
|
6344
|
+
backward.get(e.to).push(e.from);
|
|
6345
|
+
}
|
|
6346
|
+
const roots = nodes.filter((n) => !backward.has(n.id) || backward.get(n.id).length === 0);
|
|
6347
|
+
if (roots.length === 0) roots.push(nodes[0]);
|
|
6348
|
+
const layers = /* @__PURE__ */ new Map();
|
|
6349
|
+
const queue = [];
|
|
6350
|
+
for (const r of roots) {
|
|
6351
|
+
layers.set(r.id, 0);
|
|
6352
|
+
queue.push(r.id);
|
|
6353
|
+
}
|
|
6354
|
+
const visited = /* @__PURE__ */ new Set();
|
|
6355
|
+
while (queue.length > 0) {
|
|
6356
|
+
const id = queue.shift();
|
|
6357
|
+
if (visited.has(id)) continue;
|
|
6358
|
+
visited.add(id);
|
|
6359
|
+
const myLayer = layers.get(id) || 0;
|
|
6360
|
+
for (const child of forward.get(id) || []) {
|
|
6361
|
+
const childLayer = layers.get(child);
|
|
6362
|
+
if (childLayer === void 0 || myLayer + 1 > childLayer) {
|
|
6363
|
+
layers.set(child, myLayer + 1);
|
|
6364
|
+
}
|
|
6365
|
+
if (!visited.has(child)) queue.push(child);
|
|
6287
6366
|
}
|
|
6288
|
-
|
|
6289
|
-
|
|
6367
|
+
}
|
|
6368
|
+
const maxLayer = Math.max(0, ...Array.from(layers.values()));
|
|
6369
|
+
for (const n of nodes) {
|
|
6370
|
+
if (!layers.has(n.id)) layers.set(n.id, maxLayer + 1);
|
|
6371
|
+
}
|
|
6372
|
+
const nodesByLayer = /* @__PURE__ */ new Map();
|
|
6373
|
+
for (const n of nodes) {
|
|
6374
|
+
const layer = layers.get(n.id);
|
|
6375
|
+
if (!nodesByLayer.has(layer)) nodesByLayer.set(layer, []);
|
|
6376
|
+
nodesByLayer.get(layer).push(n);
|
|
6377
|
+
}
|
|
6378
|
+
const sortedLayers = Array.from(nodesByLayer.keys()).sort((a, b) => a - b);
|
|
6379
|
+
const posInLayer = /* @__PURE__ */ new Map();
|
|
6380
|
+
for (let li = 0; li < sortedLayers.length; li++) {
|
|
6381
|
+
const layer = sortedLayers[li];
|
|
6382
|
+
const nodesInLayer = nodesByLayer.get(layer);
|
|
6383
|
+
if (li > 0) {
|
|
6384
|
+
nodesInLayer.sort((a, b) => {
|
|
6385
|
+
const parentsA = backward.get(a.id) || [];
|
|
6386
|
+
const parentsB = backward.get(b.id) || [];
|
|
6387
|
+
const avgA = parentsA.length > 0 ? parentsA.reduce((s, p) => s + (posInLayer.get(p) ?? 0), 0) / parentsA.length : 0;
|
|
6388
|
+
const avgB = parentsB.length > 0 ? parentsB.reduce((s, p) => s + (posInLayer.get(p) ?? 0), 0) / parentsB.length : 0;
|
|
6389
|
+
return avgA - avgB;
|
|
6390
|
+
});
|
|
6290
6391
|
}
|
|
6291
|
-
|
|
6392
|
+
nodesInLayer.forEach((n, i) => posInLayer.set(n.id, i));
|
|
6393
|
+
}
|
|
6394
|
+
const layoutNodes = [];
|
|
6395
|
+
for (const layer of sortedLayers) {
|
|
6396
|
+
const nodesInLayer = nodesByLayer.get(layer);
|
|
6397
|
+
const widths = nodesInLayer.map((n) => nodeWidth(n));
|
|
6398
|
+
const heights = nodesInLayer.map((n) => nodeHeight(n));
|
|
6399
|
+
const totalWidth = widths.reduce((s, w) => s + w, 0) + (nodesInLayer.length - 1) * X_GAP;
|
|
6400
|
+
let startX = -totalWidth / 2;
|
|
6401
|
+
nodesInLayer.forEach((n, i) => {
|
|
6402
|
+
layoutNodes.push({
|
|
6403
|
+
id: n.id,
|
|
6404
|
+
x: startX + widths[i] / 2,
|
|
6405
|
+
y: layer * (NODE_HEIGHT + Y_GAP),
|
|
6406
|
+
width: widths[i],
|
|
6407
|
+
height: heights[i],
|
|
6408
|
+
layer,
|
|
6409
|
+
node: n
|
|
6410
|
+
});
|
|
6411
|
+
startX += widths[i] + X_GAP;
|
|
6412
|
+
});
|
|
6292
6413
|
}
|
|
6293
|
-
|
|
6414
|
+
const minX = Math.min(...layoutNodes.map((n) => n.x - n.width / 2));
|
|
6415
|
+
const minY = Math.min(...layoutNodes.map((n) => n.y - n.height / 2));
|
|
6416
|
+
const offsetX = PADDING - minX;
|
|
6417
|
+
const offsetY = PADDING - minY;
|
|
6418
|
+
for (const n of layoutNodes) {
|
|
6419
|
+
n.x += offsetX;
|
|
6420
|
+
n.y += offsetY;
|
|
6421
|
+
}
|
|
6422
|
+
const svgWidth = Math.max(...layoutNodes.map((n) => n.x + n.width / 2)) + PADDING;
|
|
6423
|
+
const svgHeight = Math.max(...layoutNodes.map((n) => n.y + n.height / 2)) + PADDING;
|
|
6424
|
+
return { layoutNodes, svgWidth, svgHeight };
|
|
6425
|
+
}
|
|
6426
|
+
function nodeWidth(n) {
|
|
6427
|
+
if (n.type === "decision") return Math.max(DIAMOND_SIZE * 1.4, 100);
|
|
6428
|
+
const textWidth = n.label.length * CHAR_WIDTH + 32;
|
|
6429
|
+
return Math.max(100, Math.min(NODE_WIDTH, textWidth));
|
|
6294
6430
|
}
|
|
6295
|
-
function
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6431
|
+
function nodeHeight(n) {
|
|
6432
|
+
if (n.type === "decision") return DIAMOND_SIZE;
|
|
6433
|
+
const w = nodeWidth(n);
|
|
6434
|
+
const lines = wrapText(n.label, w - 24);
|
|
6435
|
+
return Math.max(NODE_HEIGHT, lines.length * LINE_HEIGHT + 16);
|
|
6436
|
+
}
|
|
6437
|
+
function wrapText(text, maxPixelWidth) {
|
|
6438
|
+
const charsPerLine = Math.max(8, Math.floor(maxPixelWidth / CHAR_WIDTH));
|
|
6439
|
+
if (text.length <= charsPerLine) return [text];
|
|
6440
|
+
const words = text.split(" ");
|
|
6441
|
+
const lines = [];
|
|
6442
|
+
let cur = "";
|
|
6443
|
+
for (const word of words) {
|
|
6444
|
+
const test = cur ? `${cur} ${word}` : word;
|
|
6445
|
+
if (test.length > charsPerLine && cur) {
|
|
6446
|
+
lines.push(cur);
|
|
6447
|
+
cur = word;
|
|
6448
|
+
} else {
|
|
6449
|
+
cur = test;
|
|
6308
6450
|
}
|
|
6309
6451
|
}
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6452
|
+
if (cur) lines.push(cur);
|
|
6453
|
+
if (lines.length > 3) {
|
|
6454
|
+
lines.length = 3;
|
|
6455
|
+
lines[2] = lines[2].slice(0, -1) + "\u2026";
|
|
6456
|
+
}
|
|
6457
|
+
return lines;
|
|
6458
|
+
}
|
|
6459
|
+
function computeEdgePath(from, to) {
|
|
6460
|
+
let startX = from.x;
|
|
6461
|
+
let startY = from.y + from.height / 2;
|
|
6462
|
+
if (from.node.type === "decision") {
|
|
6463
|
+
const dx = to.x - from.x;
|
|
6464
|
+
const halfDiamond = DIAMOND_SIZE / 2;
|
|
6465
|
+
if (Math.abs(dx) > halfDiamond) {
|
|
6466
|
+
startX = from.x + (dx > 0 ? halfDiamond : -halfDiamond);
|
|
6467
|
+
startY = from.y;
|
|
6319
6468
|
}
|
|
6320
|
-
const outs = outgoing.get(id) || [];
|
|
6321
|
-
for (const e of outs) q.push(e.to);
|
|
6322
6469
|
}
|
|
6323
|
-
|
|
6470
|
+
const endX = to.x;
|
|
6471
|
+
const endY = to.y - to.height / 2;
|
|
6472
|
+
const midY = (startY + endY) / 2;
|
|
6473
|
+
return `M ${startX} ${startY} C ${startX} ${midY}, ${endX} ${midY}, ${endX} ${endY}`;
|
|
6324
6474
|
}
|
|
6325
|
-
function
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
if (visited.has(nextId)) break;
|
|
6339
|
-
items.push({ type: "arrow", label: outs[0].label });
|
|
6340
|
-
currentId = nextId;
|
|
6341
|
-
} else {
|
|
6342
|
-
currentId = null;
|
|
6343
|
-
}
|
|
6344
|
-
} else {
|
|
6345
|
-
visited.add(currentId);
|
|
6346
|
-
items.push({ type: "node", nodeId: currentId });
|
|
6347
|
-
const branchStarts = outs.map((e) => e.to);
|
|
6348
|
-
const mergeId = findMergePoint(branchStarts, outgoing);
|
|
6349
|
-
const branches = [];
|
|
6350
|
-
for (const edge of outs) {
|
|
6351
|
-
if (visited.has(edge.to) && edge.to !== mergeId) {
|
|
6352
|
-
branches.push({ label: edge.label, items: [] });
|
|
6353
|
-
continue;
|
|
6354
|
-
}
|
|
6355
|
-
const branchItems = buildLayout(edge.to, outgoing, incoming, nodeMap, visited);
|
|
6356
|
-
branches.push({ label: edge.label, items: branchItems });
|
|
6357
|
-
}
|
|
6358
|
-
items.push({ type: "branch", decision: currentId, branches, mergeId });
|
|
6359
|
-
if (mergeId && !visited.has(mergeId)) {
|
|
6360
|
-
items.push({ type: "arrow" });
|
|
6361
|
-
currentId = mergeId;
|
|
6362
|
-
} else {
|
|
6363
|
-
currentId = null;
|
|
6475
|
+
function SvgDefs() {
|
|
6476
|
+
return /* @__PURE__ */ jsxs("defs", { children: [
|
|
6477
|
+
/* @__PURE__ */ jsx(
|
|
6478
|
+
"marker",
|
|
6479
|
+
{
|
|
6480
|
+
id: "fc-arrowhead",
|
|
6481
|
+
viewBox: "0 0 10 7",
|
|
6482
|
+
refX: "10",
|
|
6483
|
+
refY: "3.5",
|
|
6484
|
+
markerWidth: "8",
|
|
6485
|
+
markerHeight: "6",
|
|
6486
|
+
orient: "auto-start-reverse",
|
|
6487
|
+
children: /* @__PURE__ */ jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "#D1D5DB" })
|
|
6364
6488
|
}
|
|
6489
|
+
),
|
|
6490
|
+
/* @__PURE__ */ jsx("filter", { id: "fc-shadow", x: "-4%", y: "-4%", width: "108%", height: "116%", children: /* @__PURE__ */ jsx("feDropShadow", { dx: "0", dy: "1", stdDeviation: "1.5", floodOpacity: "0.07" }) })
|
|
6491
|
+
] });
|
|
6492
|
+
}
|
|
6493
|
+
function TextBlock({ lines, x, y, fill, fontSize }) {
|
|
6494
|
+
const startY = y - (lines.length - 1) * LINE_HEIGHT / 2;
|
|
6495
|
+
return /* @__PURE__ */ jsx(
|
|
6496
|
+
"text",
|
|
6497
|
+
{
|
|
6498
|
+
x,
|
|
6499
|
+
textAnchor: "middle",
|
|
6500
|
+
fill,
|
|
6501
|
+
style: { fontSize: `${fontSize}px`, fontFamily: "var(--font-outfit, system-ui, sans-serif)", fontWeight: 500 },
|
|
6502
|
+
children: lines.map((line, i) => /* @__PURE__ */ jsx("tspan", { x, y: startY + i * LINE_HEIGHT, children: line }, i))
|
|
6365
6503
|
}
|
|
6366
|
-
|
|
6367
|
-
return items;
|
|
6504
|
+
);
|
|
6368
6505
|
}
|
|
6369
|
-
function
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
/* @__PURE__ */ jsx(
|
|
6373
|
-
|
|
6506
|
+
function ActionNodeSvg({ n }) {
|
|
6507
|
+
const lines = wrapText(n.node.label, n.width - 24);
|
|
6508
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6509
|
+
/* @__PURE__ */ jsx(
|
|
6510
|
+
"rect",
|
|
6511
|
+
{
|
|
6512
|
+
x: n.x - n.width / 2,
|
|
6513
|
+
y: n.y - n.height / 2,
|
|
6514
|
+
width: n.width,
|
|
6515
|
+
height: n.height,
|
|
6516
|
+
rx: 3,
|
|
6517
|
+
fill: "white",
|
|
6518
|
+
stroke: "#E5E7EB",
|
|
6519
|
+
strokeWidth: 1,
|
|
6520
|
+
filter: "url(#fc-shadow)"
|
|
6521
|
+
}
|
|
6522
|
+
),
|
|
6523
|
+
/* @__PURE__ */ jsx(TextBlock, { lines, x: n.x, y: n.y, fill: "#0A0A0A", fontSize: FONT_SIZE })
|
|
6374
6524
|
] });
|
|
6375
6525
|
}
|
|
6376
|
-
function
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6526
|
+
function DecisionNodeSvg({ n }) {
|
|
6527
|
+
const half = DIAMOND_SIZE / 2;
|
|
6528
|
+
const points = `${n.x},${n.y - half} ${n.x + half},${n.y} ${n.x},${n.y + half} ${n.x - half},${n.y}`;
|
|
6529
|
+
const lines = wrapText(n.node.label, DIAMOND_SIZE - 16);
|
|
6530
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6531
|
+
/* @__PURE__ */ jsx(
|
|
6532
|
+
"polygon",
|
|
6380
6533
|
{
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
node.label
|
|
6386
|
-
]
|
|
6534
|
+
points,
|
|
6535
|
+
fill: "#FFFBEB",
|
|
6536
|
+
stroke: "#FCD34D",
|
|
6537
|
+
strokeWidth: 2
|
|
6387
6538
|
}
|
|
6388
|
-
)
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
return /* @__PURE__ */ jsx("div", { className: "bg-gray-100 border border-gray-200 rounded-full px-5 py-1.5 text-xs font-medium text-gray-500 text-center my-1", children: node.label });
|
|
6392
|
-
}
|
|
6393
|
-
return /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200 rounded-sm px-4 py-2 text-xs font-medium text-[var(--black)] text-center shadow-sm my-1 max-w-[220px]", children: node.label });
|
|
6539
|
+
),
|
|
6540
|
+
/* @__PURE__ */ jsx(TextBlock, { lines, x: n.x, y: n.y, fill: "#92400E", fontSize: 10 })
|
|
6541
|
+
] });
|
|
6394
6542
|
}
|
|
6395
|
-
function
|
|
6396
|
-
return /* @__PURE__ */
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6543
|
+
function TerminalNodeSvg({ n }) {
|
|
6544
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6545
|
+
/* @__PURE__ */ jsx(
|
|
6546
|
+
"rect",
|
|
6547
|
+
{
|
|
6548
|
+
x: n.x - n.width / 2,
|
|
6549
|
+
y: n.y - n.height / 2,
|
|
6550
|
+
width: n.width,
|
|
6551
|
+
height: n.height,
|
|
6552
|
+
rx: n.height / 2,
|
|
6553
|
+
fill: "#F3F4F6",
|
|
6554
|
+
stroke: "#E5E7EB",
|
|
6555
|
+
strokeWidth: 1
|
|
6556
|
+
}
|
|
6557
|
+
),
|
|
6558
|
+
/* @__PURE__ */ jsx(TextBlock, { lines: [n.node.label], x: n.x, y: n.y, fill: "#6B7280", fontSize: FONT_SIZE })
|
|
6559
|
+
] });
|
|
6560
|
+
}
|
|
6561
|
+
function EdgeSvg({ from, to, label }) {
|
|
6562
|
+
const path = computeEdgePath(from, to);
|
|
6563
|
+
const midX = (from.x + to.x) / 2;
|
|
6564
|
+
const midY = (from.y + from.height / 2 + to.y - to.height / 2) / 2;
|
|
6565
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6566
|
+
/* @__PURE__ */ jsx(
|
|
6567
|
+
"path",
|
|
6568
|
+
{
|
|
6569
|
+
d: path,
|
|
6570
|
+
fill: "none",
|
|
6571
|
+
stroke: "#D1D5DB",
|
|
6572
|
+
strokeWidth: 1.5,
|
|
6573
|
+
markerEnd: "url(#fc-arrowhead)"
|
|
6574
|
+
}
|
|
6575
|
+
),
|
|
6576
|
+
label && /* @__PURE__ */ jsxs("g", { children: [
|
|
6577
|
+
/* @__PURE__ */ jsx(
|
|
6578
|
+
"rect",
|
|
6579
|
+
{
|
|
6580
|
+
x: midX - label.length * CHAR_WIDTH / 2 - 6,
|
|
6581
|
+
y: midY - 9,
|
|
6582
|
+
width: label.length * CHAR_WIDTH + 12,
|
|
6583
|
+
height: 18,
|
|
6584
|
+
rx: 9,
|
|
6585
|
+
fill: "#F5F3FF"
|
|
6586
|
+
}
|
|
6587
|
+
),
|
|
6588
|
+
/* @__PURE__ */ jsx(
|
|
6589
|
+
"text",
|
|
6590
|
+
{
|
|
6591
|
+
x: midX,
|
|
6592
|
+
y: midY + 1,
|
|
6593
|
+
textAnchor: "middle",
|
|
6594
|
+
dominantBaseline: "central",
|
|
6595
|
+
fill: "#7C3AED",
|
|
6596
|
+
style: { fontSize: "10px", fontFamily: "var(--font-outfit, system-ui, sans-serif)", fontWeight: 500 },
|
|
6597
|
+
children: label
|
|
6598
|
+
}
|
|
6599
|
+
)
|
|
6600
|
+
] })
|
|
6601
|
+
] });
|
|
6420
6602
|
}
|
|
6421
6603
|
function FlowchartDiagram({ mermaid, className }) {
|
|
6422
6604
|
const { nodes, edges } = parseMermaidFlowchart(mermaid);
|
|
6423
6605
|
if (nodes.length === 0) {
|
|
6424
6606
|
return /* @__PURE__ */ jsx("pre", { className: "text-xs bg-white border border-gray-100 rounded-sm p-3 overflow-x-auto whitespace-pre-wrap", children: mermaid });
|
|
6425
6607
|
}
|
|
6426
|
-
const
|
|
6427
|
-
const
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6608
|
+
const { layoutNodes, svgWidth, svgHeight } = computeLayout(nodes, edges);
|
|
6609
|
+
const nodeById = new Map(layoutNodes.map((n) => [n.id, n]));
|
|
6610
|
+
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs(
|
|
6611
|
+
"svg",
|
|
6612
|
+
{
|
|
6613
|
+
width: svgWidth,
|
|
6614
|
+
height: svgHeight,
|
|
6615
|
+
viewBox: `0 0 ${svgWidth} ${svgHeight}`,
|
|
6616
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6617
|
+
className: "block",
|
|
6618
|
+
children: [
|
|
6619
|
+
/* @__PURE__ */ jsx(SvgDefs, {}),
|
|
6620
|
+
edges.map((e, i) => {
|
|
6621
|
+
const fromNode = nodeById.get(e.from);
|
|
6622
|
+
const toNode = nodeById.get(e.to);
|
|
6623
|
+
if (!fromNode || !toNode) return null;
|
|
6624
|
+
return /* @__PURE__ */ jsx(EdgeSvg, { from: fromNode, to: toNode, label: e.label }, `e-${i}`);
|
|
6625
|
+
}),
|
|
6626
|
+
layoutNodes.map((n) => {
|
|
6627
|
+
if (n.node.type === "decision") return /* @__PURE__ */ jsx(DecisionNodeSvg, { n }, n.id);
|
|
6628
|
+
if (n.node.type === "terminal") return /* @__PURE__ */ jsx(TerminalNodeSvg, { n }, n.id);
|
|
6629
|
+
return /* @__PURE__ */ jsx(ActionNodeSvg, { n }, n.id);
|
|
6630
|
+
})
|
|
6631
|
+
]
|
|
6632
|
+
}
|
|
6633
|
+
) }) });
|
|
6440
6634
|
}
|
|
6441
6635
|
var frequencyLabels = {
|
|
6442
6636
|
multiple_daily: "occurrence",
|