dishui 0.0.46 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/chart.js +35 -33
  2. package/dist/components/Chart/index.d.ts +1 -1
  3. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +1 -2
  4. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
  5. package/dist/components/pro/CodeEditor/themes.js +0 -25
  6. package/dist/components/pro/CodeEditor/themes.js.map +1 -1
  7. package/dist/components/pro/CodeEditor/types.d.ts +1 -1
  8. package/dist/components/pro/DataTable/pivotExtension.d.ts +6 -0
  9. package/dist/components/pro/DataTable/pivotExtension.js +31 -30
  10. package/dist/components/pro/DataTable/pivotExtension.js.map +1 -1
  11. package/dist/components/pro/Flow/Flow.js +500 -459
  12. package/dist/components/pro/Flow/Flow.js.map +1 -1
  13. package/dist/components/pro/Flow/FlowCanvas.js +526 -524
  14. package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
  15. package/dist/components/pro/Flow/canvas/GridRenderer.d.ts +3 -0
  16. package/dist/components/pro/Flow/canvas/GridRenderer.js +28 -23
  17. package/dist/components/pro/Flow/canvas/GridRenderer.js.map +1 -1
  18. package/dist/components/pro/Flow/canvas/MiniMapRenderer.js +18 -17
  19. package/dist/components/pro/Flow/canvas/MiniMapRenderer.js.map +1 -1
  20. package/dist/components/pro/Flow/canvas/PixiApp.d.ts +24 -0
  21. package/dist/components/pro/Flow/canvas/PixiApp.js +60 -15
  22. package/dist/components/pro/Flow/canvas/PixiApp.js.map +1 -1
  23. package/dist/components/pro/Flow/constants.js +7 -7
  24. package/dist/components/pro/Flow/constants.js.map +1 -1
  25. package/dist/components/pro/Flow/context/FlowAIContext.d.ts +15 -0
  26. package/dist/components/pro/Flow/context/FlowAIContext.js +32 -0
  27. package/dist/components/pro/Flow/context/FlowAIContext.js.map +1 -0
  28. package/dist/components/pro/Flow/context/FlowUIContext.d.ts +4 -1
  29. package/dist/components/pro/Flow/context/FlowUIContext.js +58 -55
  30. package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
  31. package/dist/components/pro/Flow/edges/EdgeRenderer.js +22 -21
  32. package/dist/components/pro/Flow/edges/EdgeRenderer.js.map +1 -1
  33. package/dist/components/pro/Flow/hooks/useFlowImportExport.d.ts +6 -0
  34. package/dist/components/pro/Flow/hooks/useFlowImportExport.js +146 -89
  35. package/dist/components/pro/Flow/hooks/useFlowImportExport.js.map +1 -1
  36. package/dist/components/pro/Flow/hooks/useLayoutActions.d.ts +2 -0
  37. package/dist/components/pro/Flow/hooks/useLayoutActions.js +94 -65
  38. package/dist/components/pro/Flow/hooks/useLayoutActions.js.map +1 -1
  39. package/dist/components/pro/Flow/hooks/usePdfExport.d.ts +10 -0
  40. package/dist/components/pro/Flow/hooks/usePdfExport.js +60 -0
  41. package/dist/components/pro/Flow/hooks/usePdfExport.js.map +1 -0
  42. package/dist/components/pro/Flow/hooks/usePixiApp.d.ts +6 -1
  43. package/dist/components/pro/Flow/hooks/usePixiApp.js +49 -30
  44. package/dist/components/pro/Flow/hooks/usePixiApp.js.map +1 -1
  45. package/dist/components/pro/Flow/index.d.ts +5 -2
  46. package/dist/components/pro/Flow/lines/FreehandTool.js +21 -20
  47. package/dist/components/pro/Flow/lines/FreehandTool.js.map +1 -1
  48. package/dist/components/pro/Flow/lines/GeometricLineTool.js +22 -18
  49. package/dist/components/pro/Flow/lines/GeometricLineTool.js.map +1 -1
  50. package/dist/components/pro/Flow/lines/LineRenderer.js +19 -18
  51. package/dist/components/pro/Flow/lines/LineRenderer.js.map +1 -1
  52. package/dist/components/pro/Flow/nodes/DataNodeView.d.ts +7 -0
  53. package/dist/components/pro/Flow/nodes/DataNodeView.js +217 -0
  54. package/dist/components/pro/Flow/nodes/DataNodeView.js.map +1 -0
  55. package/dist/components/pro/Flow/nodes/MediaContent.js +149 -120
  56. package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
  57. package/dist/components/pro/Flow/nodes/MediaOverlay.js +22 -17
  58. package/dist/components/pro/Flow/nodes/MediaOverlay.js.map +1 -1
  59. package/dist/components/pro/Flow/nodes/NodeRenderer.js +77 -76
  60. package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
  61. package/dist/components/pro/Flow/nodes/aiClient.d.ts +22 -0
  62. package/dist/components/pro/Flow/nodes/aiClient.js +107 -54
  63. package/dist/components/pro/Flow/nodes/aiClient.js.map +1 -1
  64. package/dist/components/pro/Flow/nodes/dataUtils.d.ts +52 -0
  65. package/dist/components/pro/Flow/nodes/dataUtils.js +270 -0
  66. package/dist/components/pro/Flow/nodes/dataUtils.js.map +1 -0
  67. package/dist/components/pro/Flow/nodes/svgIcons.js +59 -27
  68. package/dist/components/pro/Flow/nodes/svgIcons.js.map +1 -1
  69. package/dist/components/pro/Flow/panels/AIPanel.d.ts +2 -0
  70. package/dist/components/pro/Flow/panels/AIPanel.js +498 -0
  71. package/dist/components/pro/Flow/panels/AIPanel.js.map +1 -0
  72. package/dist/components/pro/Flow/panels/DataInspectorSection.d.ts +11 -0
  73. package/dist/components/pro/Flow/panels/DataInspectorSection.js +436 -0
  74. package/dist/components/pro/Flow/panels/DataInspectorSection.js.map +1 -0
  75. package/dist/components/pro/Flow/panels/ExpandableTextarea.d.ts +16 -0
  76. package/dist/components/pro/Flow/panels/ExpandableTextarea.js +65 -0
  77. package/dist/components/pro/Flow/panels/ExpandableTextarea.js.map +1 -0
  78. package/dist/components/pro/Flow/panels/FlowPanelGroup.js +51 -39
  79. package/dist/components/pro/Flow/panels/FlowPanelGroup.js.map +1 -1
  80. package/dist/components/pro/Flow/panels/FlowToolbar.d.ts +5 -1
  81. package/dist/components/pro/Flow/panels/FlowToolbar.js +310 -233
  82. package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
  83. package/dist/components/pro/Flow/panels/InspectorPanel.js +358 -363
  84. package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
  85. package/dist/components/pro/Flow/panels/OutlinePanel.js +63 -62
  86. package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
  87. package/dist/components/pro/Flow/panels/ProjectTitle.d.ts +8 -0
  88. package/dist/components/pro/Flow/panels/ProjectTitle.js +49 -0
  89. package/dist/components/pro/Flow/panels/ProjectTitle.js.map +1 -0
  90. package/dist/components/pro/Flow/panels/ShapePalette.js +128 -115
  91. package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
  92. package/dist/components/pro/Flow/panels/toolbarIcons.d.ts +13 -0
  93. package/dist/components/pro/Flow/panels/toolbarIcons.js +241 -87
  94. package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
  95. package/dist/components/pro/Flow/types.d.ts +77 -1
  96. package/dist/components/pro/Flow/types.js.map +1 -1
  97. package/dist/components/pro/Flow/utils/pdfExport.d.ts +20 -0
  98. package/dist/components/pro/Flow/utils/pdfExport.js +95 -0
  99. package/dist/components/pro/Flow/utils/pdfExport.js.map +1 -0
  100. package/dist/components/pro/Flow/utils/themeColor.d.ts +86 -0
  101. package/dist/components/pro/Flow/utils/themeColor.js +190 -0
  102. package/dist/components/pro/Flow/utils/themeColor.js.map +1 -0
  103. package/dist/contexts/AppContext.d.ts +1 -1
  104. package/dist/contexts/AppContext.js +28 -29
  105. package/dist/contexts/AppContext.js.map +1 -1
  106. package/dist/dishui.css +1 -1
  107. package/dist/favicon.svg +10 -0
  108. package/dist/flow.js +59 -51
  109. package/dist/index-nostyled.d.ts +1 -1
  110. package/dist/index.d.ts +1 -1
  111. package/dist/styles/themeStyles.js +6 -11
  112. package/dist/styles/themeStyles.js.map +1 -1
  113. package/dist/utils/themes.js +3 -23
  114. package/dist/utils/themes.js.map +1 -1
  115. package/package.json +17 -18
@@ -1 +1 @@
1
- {"version":3,"file":"MediaContent.js","names":[],"sources":["../../../../../src/components/pro/Flow/nodes/MediaContent.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport katex from 'katex';\nimport mermaid from 'mermaid';\nimport Markdown from '../../../Markdown';\nimport type { FlowNode, FlowAIConfig } from '../types';\nimport { streamAIChat, type AIChatMessage } from './aiClient';\nimport 'katex/dist/katex.min.css';\nimport { Model3DView } from './Model3DView';\n\nlet mermaidReady = false;\nfunction ensureMermaid() {\n if (mermaidReady) return;\n mermaid.initialize({ startOnLoad: false, theme: 'default', securityLevel: 'loose', fontFamily: 'inherit' });\n mermaidReady = true;\n}\n\n/** Renders a Mermaid diagram from source into an inline SVG. */\nfunction MermaidView({ content, color }: { content: string; color?: string }) {\n const [svg, setSvg] = useState('');\n const [error, setError] = useState<string | null>(null);\n const idRef = useRef(`flow-mermaid-${Math.random().toString(36).slice(2)}`);\n\n useEffect(() => {\n let cancelled = false;\n ensureMermaid();\n const src = content.trim();\n if (!src) { setSvg(''); setError(null); return; }\n mermaid\n .render(idRef.current, src)\n .then(({ svg }) => { if (!cancelled) { setSvg(svg); setError(null); } })\n .catch((e) => { if (!cancelled) setError(e?.message ?? 'Mermaid error'); });\n return () => { cancelled = true; };\n }, [content]);\n\n if (error) return <div className=\"flow-media-error\">{error}</div>;\n return <div className=\"flow-media-mermaid\" style={{ color }} dangerouslySetInnerHTML={{ __html: svg }} />;\n}\n\n/** Renders a LaTeX formula (display mode) via KaTeX. */\nfunction MathView({ content, color, fontSize }: { content: string; color?: string; fontSize?: number }) {\n const html = useMemo(() => {\n try {\n return katex.renderToString(content.trim() || '\\\\;', { displayMode: true, throwOnError: false });\n } catch (e: any) {\n return `<span class=\"flow-media-error\">${e?.message ?? 'KaTeX error'}</span>`;\n }\n }, [content]);\n return <div className=\"flow-media-math\" style={{ color, fontSize }} dangerouslySetInnerHTML={{ __html: html }} />;\n}\n\n/** Renders raw HTML in a sandboxed iframe (isolated from the host document). */\nfunction HtmlView({ content, interactive }: { content: string; interactive: boolean }) {\n return (\n <iframe\n title=\"html-media\"\n className=\"flow-media-iframe\"\n style={{ pointerEvents: interactive ? 'auto' : 'none' }}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-forms\"\n srcDoc={content}\n />\n );\n}\n\nfunction ImageView({ content }: { content: string }) {\n const src = content.trim();\n if (!src) {\n return <div className=\"flow-media-image-empty\">输入图片链接,或直接粘贴图片</div>;\n }\n return (\n <img\n className=\"flow-media-image\"\n src={src}\n alt=\"\"\n draggable={false}\n referrerPolicy=\"no-referrer\"\n />\n );\n}\n\n/** Interactive AI chat backed by an OpenAI/Anthropic-compatible endpoint. */\nfunction AIView({ node, config, interactive, color }: { node: FlowNode; config?: FlowAIConfig; interactive: boolean; color?: string }) {\n const [messages, setMessages] = useState<AIChatMessage[]>([]);\n const [input, setInput] = useState('');\n const [streaming, setStreaming] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const scrollRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight });\n }, [messages, streaming]);\n\n useEffect(() => () => abortRef.current?.abort(), []);\n\n const canSend = !!config?.gateway && !!config?.model && !streaming;\n\n const send = async () => {\n const text = input.trim();\n if (!text || !config?.gateway) return;\n setError(null);\n // Only keep non-empty assistant messages in history; an aborted/errored\n // request can leave an empty assistant placeholder behind, which the API\n // then rejects (\"assistant message must not be empty\").\n const history = messages.filter(\n (m) => !(m.role === 'assistant' && m.content.trim() === ''),\n );\n const next: AIChatMessage[] = [...history, { role: 'user', content: text }];\n setMessages(next);\n setInput('');\n setStreaming(true);\n const ac = new AbortController();\n abortRef.current = ac;\n let acc = '';\n setMessages((m) => [...m, { role: 'assistant', content: '' }]);\n try {\n for await (const delta of streamAIChat(config, next, ac.signal)) {\n acc += delta;\n setMessages((m) => {\n const copy = m.slice();\n copy[copy.length - 1] = { role: 'assistant', content: acc };\n return copy;\n });\n }\n } catch (e: any) {\n if (e?.name !== 'AbortError') setError(e?.message ?? 'Request failed');\n } finally {\n // Drop the trailing assistant placeholder if nothing streamed in.\n setMessages((m) => {\n const last = m[m.length - 1];\n if (last && last.role === 'assistant' && last.content.trim() === '') {\n return m.slice(0, -1);\n }\n return m;\n });\n setStreaming(false);\n abortRef.current = null;\n }\n };\n\n return (\n <div className=\"flow-media-ai\" style={{ color }}>\n <div className=\"flow-media-ai-header\">\n {config?.model ? `AI · ${config.model}` : (node.data.label || 'AI')}\n </div>\n <div className=\"flow-media-ai-log\" ref={scrollRef}>\n {messages.length === 0 && (\n <div className=\"flow-media-ai-empty\">\n {config?.gateway ? '开始对话…' : '请在属性面板配置 AI 接口'}\n </div>\n )}\n {messages.map((m, i) => (\n <div key={i} className={`flow-media-ai-msg flow-media-ai-msg--${m.role}`}>\n {m.role === 'assistant'\n ? <Markdown content={m.content || '…'} enableMermaid={false} enableMarkmap={false} />\n : <span>{m.content}</span>}\n </div>\n ))}\n {error && <div className=\"flow-media-error\">{error}</div>}\n </div>\n <div className=\"flow-media-ai-input\" style={{ pointerEvents: interactive ? 'auto' : 'none' }}>\n <textarea\n value={input}\n placeholder=\"输入消息,Enter 发送\"\n onChange={(e) => setInput(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); if (canSend) send(); }\n }}\n onPointerDown={(e) => e.stopPropagation()}\n />\n {streaming ? (\n <button type=\"button\" onClick={() => abortRef.current?.abort()}>停止</button>\n ) : (\n <button type=\"button\" disabled={!canSend || !input.trim()} onClick={send}>发送</button>\n )}\n </div>\n </div>\n );\n}\n\n/** Dispatches to the correct renderer for the node's media kind. */\nexport function MediaContent({ node, interactive }: { node: FlowNode; interactive: boolean }) {\n const kind = node.data.mediaKind ?? 'markdown';\n const content = node.data.mediaContent ?? '';\n const textColor = node.data.labelColor ?? node.data.color;\n\n switch (kind) {\n case 'markdown':\n return (\n <div className=\"flow-media-markdown\" style={{ color: textColor, fontSize: node.data.fontSize }}>\n <Markdown content={content} />\n </div>\n );\n case 'html':\n return <HtmlView content={content} interactive={interactive} />;\n case 'mermaid':\n return <MermaidView content={content} color={textColor} />;\n case 'math':\n return <MathView content={content} color={textColor} fontSize={node.data.fontSize} />;\n case 'image':\n return <ImageView content={content} />;\n case 'model3d':\n return (\n <Model3DView\n content={content}\n format={node.data.modelFormat ?? 'stl'}\n interactive={interactive}\n />\n );\n case 'ai':\n return <AIView node={node} config={node.data.aiConfig} interactive={interactive} color={textColor} />;\n default:\n return null;\n }\n}\n"],"mappings":";;;;;;;;AASA,IAAI,IAAe;AACnB,SAAS,IAAgB;AACvB,EAAI,MACJ,EAAQ,WAAW;AAAA,IAAE,aAAa;AAAA,IAAO,OAAO;AAAA,IAAW,eAAe;AAAA,IAAS,YAAY;AAAA,EAAU,CAAC,GAC1G,IAAe;AACjB;AAGA,SAAS,EAAY,EAAE,SAAA,GAAS,OAAA,EAAA,GAA8C;AAC5E,QAAM,CAAC,GAAK,CAAA,IAAU,EAAS,EAAE,GAC3B,CAAC,GAAO,CAAA,IAAY,EAAwB,IAAI,GAChD,IAAQ,EAAO,gBAAgB,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAA,EAAG;AAc1E,SAZA,EAAA,MAAgB;AACd,QAAI,IAAY;AAChB,IAAA,EAAc;AACd,UAAM,IAAM,EAAQ,KAAK;AACzB,QAAI,CAAC,GAAK;AAAE,MAAA,EAAO,EAAE,GAAG,EAAS,IAAI;AAAG;AAAA,IAAQ;AAChD,WAAA,EACG,OAAO,EAAM,SAAS,CAAG,EACzB,KAAA,CAAM,EAAE,KAAA,EAAA,MAAU;AAAE,MAAK,MAAa,EAAO,CAAG,GAAG,EAAS,IAAI;AAAA,IAAK,CAAC,EACtE,MAAA,CAAO,MAAM;AAAE,MAAK,KAAW,EAAS,GAAG,WAAW,eAAe;AAAA,IAAG,CAAC,GAC5E,MAAa;AAAE,MAAA,IAAY;AAAA,IAAM;AAAA,EACnC,GAAG,CAAC,CAAO,CAAC,GAER,IAAc,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAU;AAAA,cAAoB;AAAA,EAAW,CA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AAA;AAAA,QAAsB,aAAA;AAAA,MAAc,CAAA;AAAA,IAChE,KAAK;AACH,aAAO,gBAAA,EAAC,GAAD;AAAA,QAAsB,SAAA;AAAA,QAAS,OAAO;AAAA,MAAY,CAAA;AAAA,IAC3D,KAAK;AACH,aAAO,gBAAA,EAAC,GAAD;AAAA,QAAmB,SAAA;AAAA,QAAS,OAAO;AAAA,QAAW,UAAU,EAAK,KAAK;AAAA,MAAW,CAAA;AAAA,IACtF,KAAK;AACH,aAAO,gBAAA,EAAC,GAAD,EAAoB,SAAA,EAAU,CAAA;AAAA,IACvC,KAAK;AACH,aACE,gBAAA,EAAC,GAAD;AAAA,QACW,SAAA;AAAA,QACT,QAAQ,EAAK,KAAK,eAAe;AAAA,QACpB,aAAA;AAAA,MACd,CAAA;AAAA,IAEL,KAAK;AACH,aAAO,gBAAA,EAAC,GAAD;AAAA,QAAc,MAAA;AAAA,QAAM,QAAQ,EAAK,KAAK;AAAA,QAAuB,aAAA;AAAA,QAAa,OAAO;AAAA,MAAY,CAAA;AAAA,IACtG;AACE,aAAO;AAAA,EACX;AACF"}
1
+ {"version":3,"file":"MediaContent.js","names":[],"sources":["../../../../../src/components/pro/Flow/nodes/MediaContent.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport katex from 'katex';\nimport mermaid from 'mermaid';\nimport Markdown from '../../../Markdown';\nimport type { FlowNode, FlowAIConfig } from '../types';\nimport { streamAIChat, type AIChatMessage } from './aiClient';\nimport { resolveThemeColorCss, resolveThemeColor } from '../utils/themeColor';\nimport 'katex/dist/katex.min.css';\nimport { Model3DView } from './Model3DView';\n\n// Data-node view pulls in DataTable + Chart; lazy-load so it only enters the\n// bundle when a data node actually renders.\nconst DataNodeView = React.lazy(() =>\n import('./DataNodeView').then((m) => ({ default: m.DataNodeView })),\n);\n\nlet mermaidReady = false;\nfunction ensureMermaid() {\n if (mermaidReady) return;\n mermaid.initialize({ startOnLoad: false, theme: 'default', securityLevel: 'loose', fontFamily: 'inherit' });\n mermaidReady = true;\n}\n\n/** Renders a Mermaid diagram from source into an inline SVG. */\nfunction MermaidView({ content, color }: { content: string; color?: string }) {\n const [svg, setSvg] = useState('');\n const [error, setError] = useState<string | null>(null);\n const idRef = useRef(`flow-mermaid-${Math.random().toString(36).slice(2)}`);\n\n useEffect(() => {\n let cancelled = false;\n ensureMermaid();\n const src = content.trim();\n if (!src) { setSvg(''); setError(null); return; }\n mermaid\n .render(idRef.current, src)\n .then(({ svg }) => { if (!cancelled) { setSvg(svg); setError(null); } })\n .catch((e) => { if (!cancelled) setError(e?.message ?? 'Mermaid error'); });\n return () => { cancelled = true; };\n }, [content]);\n\n if (error) return <div className=\"flow-media-error\">{error}</div>;\n return <div className=\"flow-media-mermaid\" style={{ color }} dangerouslySetInnerHTML={{ __html: svg }} />;\n}\n\n/** Renders a LaTeX formula (display mode) via KaTeX. */\nfunction MathView({ content, color, fontSize }: { content: string; color?: string; fontSize?: number }) {\n const html = useMemo(() => {\n try {\n return katex.renderToString(content.trim() || '\\\\;', { displayMode: true, throwOnError: false });\n } catch (e: any) {\n return `<span class=\"flow-media-error\">${e?.message ?? 'KaTeX error'}</span>`;\n }\n }, [content]);\n return <div className=\"flow-media-math\" style={{ color, fontSize }} dangerouslySetInnerHTML={{ __html: html }} />;\n}\n\n/** Renders raw HTML in a sandboxed iframe (isolated from the host document).\n * A base stylesheet is injected so the fragment inherits the node's themed\n * text color / font size and a transparent background, keeping it readable on\n * any theme without the author having to set colors. */\nfunction HtmlView({ content, interactive, color, fontSize }: { content: string; interactive: boolean; color?: string; fontSize?: number }) {\n const srcDoc = useMemo(() => {\n const base = `<!doctype html><html><head><meta charset=\"utf-8\"><style>\n :root { color-scheme: light dark; }\n html, body { margin: 0; background: transparent; }\n body {\n color: ${color ?? '#111827'};\n font-size: ${fontSize ?? 13}px;\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.5;\n padding: 0;\n }\n a { color: inherit; }\n </style></head><body>${content}</body></html>`;\n return base;\n }, [content, color, fontSize]);\n return (\n <iframe\n title=\"html-media\"\n className=\"flow-media-iframe\"\n style={{ pointerEvents: interactive ? 'auto' : 'none' }}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-forms\"\n srcDoc={srcDoc}\n />\n );\n}\n\nfunction ImageView({ content }: { content: string }) {\n const src = content.trim();\n if (!src) {\n return <div className=\"flow-media-image-empty\">输入图片链接,或直接粘贴图片</div>;\n }\n return (\n <img\n className=\"flow-media-image\"\n src={src}\n alt=\"\"\n draggable={false}\n referrerPolicy=\"no-referrer\"\n />\n );\n}\n\n/** Interactive AI chat backed by an OpenAI/Anthropic-compatible endpoint. */\nfunction AIView({ node, config, interactive, color }: { node: FlowNode; config?: FlowAIConfig; interactive: boolean; color?: string }) {\n const [messages, setMessages] = useState<AIChatMessage[]>([]);\n const [input, setInput] = useState('');\n const [streaming, setStreaming] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n const scrollRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight });\n }, [messages, streaming]);\n\n useEffect(() => () => abortRef.current?.abort(), []);\n\n const canSend = !!config?.gateway && !!config?.model && !streaming;\n\n const send = async () => {\n const text = input.trim();\n if (!text || !config?.gateway) return;\n setError(null);\n // Only keep non-empty assistant messages in history; an aborted/errored\n // request can leave an empty assistant placeholder behind, which the API\n // then rejects (\"assistant message must not be empty\").\n const history = messages.filter(\n (m) => !(m.role === 'assistant' && m.content.trim() === ''),\n );\n const next: AIChatMessage[] = [...history, { role: 'user', content: text }];\n setMessages(next);\n setInput('');\n setStreaming(true);\n const ac = new AbortController();\n abortRef.current = ac;\n let acc = '';\n setMessages((m) => [...m, { role: 'assistant', content: '' }]);\n try {\n for await (const delta of streamAIChat(config, next, ac.signal)) {\n acc += delta;\n setMessages((m) => {\n const copy = m.slice();\n copy[copy.length - 1] = { role: 'assistant', content: acc };\n return copy;\n });\n }\n } catch (e: any) {\n if (e?.name !== 'AbortError') setError(e?.message ?? 'Request failed');\n } finally {\n // Drop the trailing assistant placeholder if nothing streamed in.\n setMessages((m) => {\n const last = m[m.length - 1];\n if (last && last.role === 'assistant' && last.content.trim() === '') {\n return m.slice(0, -1);\n }\n return m;\n });\n setStreaming(false);\n abortRef.current = null;\n }\n };\n\n return (\n <div className=\"flow-media-ai\" style={{ color }}>\n <div className=\"flow-media-ai-header\">\n {config?.model ? `AI · ${config.model}` : (node.data.label || 'AI')}\n </div>\n <div className=\"flow-media-ai-log\" ref={scrollRef}>\n {messages.length === 0 && (\n <div className=\"flow-media-ai-empty\">\n {config?.gateway ? '开始对话…' : '请在属性面板配置 AI 接口'}\n </div>\n )}\n {messages.map((m, i) => (\n <div key={i} className={`flow-media-ai-msg flow-media-ai-msg--${m.role}`}>\n {m.role === 'assistant'\n ? <Markdown content={m.content || '…'} enableMermaid={false} enableMarkmap={false} />\n : <span>{m.content}</span>}\n </div>\n ))}\n {error && <div className=\"flow-media-error\">{error}</div>}\n </div>\n <div className=\"flow-media-ai-input\" style={{ pointerEvents: interactive ? 'auto' : 'none' }}>\n <textarea\n value={input}\n placeholder=\"输入消息,Enter 发送\"\n onChange={(e) => setInput(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); if (canSend) send(); }\n }}\n onPointerDown={(e) => e.stopPropagation()}\n />\n {streaming ? (\n <button type=\"button\" onClick={() => abortRef.current?.abort()}>停止</button>\n ) : (\n <button type=\"button\" disabled={!canSend || !input.trim()} onClick={send}>发送</button>\n )}\n </div>\n </div>\n );\n}\n\n/** Dispatches to the correct renderer for the node's media kind. */\nexport function MediaContent({ node, interactive }: { node: FlowNode; interactive: boolean }) {\n const kind = node.data.mediaKind ?? 'markdown';\n const content = node.data.mediaContent ?? '';\n const textColor = resolveThemeColorCss(node.data.labelColor ?? node.data.color, '#111827');\n\n switch (kind) {\n case 'markdown':\n return (\n <div className=\"flow-media-markdown\" style={{ color: textColor, fontSize: node.data.fontSize }}>\n <Markdown content={content} />\n </div>\n );\n case 'html':\n // The iframe is an isolated document with no access to the parent's CSS\n // variables, so pass a concrete resolved color instead of a var().\n return (\n <HtmlView\n content={content}\n interactive={interactive}\n color={resolveThemeColor(node.data.labelColor ?? node.data.color, '#111827')}\n fontSize={node.data.fontSize}\n />\n );\n case 'mermaid':\n return <MermaidView content={content} color={textColor} />;\n case 'math':\n return <MathView content={content} color={textColor} fontSize={node.data.fontSize} />;\n case 'image':\n return <ImageView content={content} />;\n case 'model3d':\n return (\n <Model3DView\n content={content}\n format={node.data.modelFormat ?? 'stl'}\n interactive={interactive}\n />\n );\n case 'ai':\n return <AIView node={node} config={node.data.aiConfig} interactive={interactive} color={textColor} />;\n case 'data':\n return (\n <div className=\"flow-media-data\" style={{ pointerEvents: interactive ? 'auto' : 'none' }}>\n <DataNodeView config={node.data.dataConfig ?? { columns: [], rows: [], view: 'table' }} />\n </div>\n );\n default:\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,IAAe,EAAM,KAAA,MACzB,OAAO,mBAAA,EAAkB,KAAA,CAAM,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CACpE,GAEI,IAAe;AACnB,SAAS,IAAgB;AACvB,EAAI,MACJ,EAAQ,WAAW;AAAA,IAAE,aAAa;AAAA,IAAO,OAAO;AAAA,IAAW,eAAe;AAAA,IAAS,YAAY;AAAA,EAAU,CAAC,GAC1G,IAAe;AACjB;AAGA,SAAS,EAAY,EAAE,SAAA,GAAS,OAAA,EAAA,GAA8C;AAC5E,QAAM,CAAC,GAAK,CAAA,IAAU,EAAS,EAAE,GAC3B,CAAC,GAAO,CAAA,IAAY,EAAwB,IAAI,GAChD,IAAQ,EAAO,gBAAgB,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAA,EAAG;AAc1E,SAZA,EAAA,MAAgB;AACd,QAAI,IAAY;AAChB,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;AACH,aACE,gBAAA,EAAC,GAAD;AAAA,QACW,SAAA;AAAA,QACT,QAAQ,EAAK,KAAK,eAAe;AAAA,QACpB,aAAA;AAAA,MACd,CAAA;AAAA,IAEL,KAAK;AACH,aAAO,gBAAA,EAAC,GAAD;AAAA,QAAc,MAAA;AAAA,QAAM,QAAQ,EAAK,KAAK;AAAA,QAAuB,aAAA;AAAA,QAAa,OAAO;AAAA,MAAY,CAAA;AAAA,IACtG,KAAK;AACH,aACE,gBAAA,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAkB,OAAO,EAAE,eAAe,IAAc,SAAS,OAAO;AAAA,kBACrF,gBAAA,EAAC,GAAD,EAAc,QAAQ,EAAK,KAAK,cAAc;AAAA,UAAE,SAAS,CAAC;AAAA,UAAG,MAAM,CAAC;AAAA,UAAG,MAAM;AAAA,QAAQ,EAAI,CAAA;AAAA,MACtF,CAAA;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF"}
@@ -1,8 +1,9 @@
1
- import { useFlowContext as u } from "../context/FlowContext.js";
2
- import { useFlowUI as v } from "../context/FlowUIContext.js";
3
- import s, { Suspense as g, useMemo as w } from "react";
1
+ import { useFlowContext as w } from "../context/FlowContext.js";
2
+ import { useFlowUI as y } from "../context/FlowUIContext.js";
3
+ import { resolveThemeColorCss as s } from "../utils/themeColor.js";
4
+ import i, { Suspense as C, useMemo as x } from "react";
4
5
  import { jsx as r } from "react/jsx-runtime";
5
- var y = s.lazy(() => import("./MediaContent.js").then((t) => ({ default: t.MediaContent }))), N = class extends s.Component {
6
+ var N = i.lazy(() => import("./MediaContent.js").then((t) => ({ default: t.MediaContent }))), M = class extends i.Component {
6
7
  constructor(t) {
7
8
  super(t), this.state = { error: null };
8
9
  }
@@ -16,21 +17,21 @@ var y = s.lazy(() => import("./MediaContent.js").then((t) => ({ default: t.Media
16
17
  }) : this.props.children;
17
18
  }
18
19
  };
19
- function F() {
20
- const { currentCanvas: t, selection: a } = u(), { viewport: n, isNodeDragging: l } = v(), i = w(() => t.nodes.filter((e) => e.type === "mediaNode"), [t.nodes]);
21
- if (i.length === 0) return null;
22
- const { x: d, y: c, zoom: o } = n;
20
+ function D() {
21
+ const { currentCanvas: t, selection: n } = w(), { viewport: l, isNodeDragging: d } = y(), a = x(() => t.nodes.filter((e) => e.type === "mediaNode"), [t.nodes]);
22
+ if (a.length === 0) return null;
23
+ const { x: c, y: m, zoom: o } = l;
23
24
  return /* @__PURE__ */ r("div", {
24
25
  className: "flow-media-layer",
25
- children: i.map((e) => {
26
- const m = e.position.x * o + d, h = e.position.y * o + c, p = a.nodeIds.has(e.id) && !l;
26
+ children: a.map((e) => {
27
+ const p = e.position.x * o + c, f = e.position.y * o + m, h = n.nodeIds.has(e.id) && !d, u = e.data.fill === "transparent" ? "transparent" : s(e.data.fill, "transparent"), v = s(e.data.labelColor ?? e.data.color, "#111827");
27
28
  return /* @__PURE__ */ r("div", {
28
29
  className: "flow-media-node",
29
30
  "data-media-node": e.id,
30
31
  style: {
31
32
  position: "absolute",
32
- left: m,
33
- top: h,
33
+ left: p,
34
+ top: f,
34
35
  width: e.width,
35
36
  height: e.height,
36
37
  transform: `scale(${o})`,
@@ -39,15 +40,19 @@ function F() {
39
40
  },
40
41
  children: /* @__PURE__ */ r("div", {
41
42
  className: "flow-media-surface",
42
- onWheel: (f) => f.stopPropagation(),
43
- children: /* @__PURE__ */ r(g, {
43
+ onWheel: (g) => g.stopPropagation(),
44
+ style: {
45
+ background: u,
46
+ color: v
47
+ },
48
+ children: /* @__PURE__ */ r(C, {
44
49
  fallback: /* @__PURE__ */ r("div", {
45
50
  className: "flow-media-loading",
46
51
  children: "…"
47
52
  }),
48
- children: /* @__PURE__ */ r(N, { children: /* @__PURE__ */ r(y, {
53
+ children: /* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(N, {
49
54
  node: e,
50
- interactive: p
55
+ interactive: h
51
56
  }) })
52
57
  })
53
58
  })
@@ -56,7 +61,7 @@ function F() {
56
61
  });
57
62
  }
58
63
  export {
59
- F as MediaOverlay
64
+ D as MediaOverlay
60
65
  };
61
66
 
62
67
  //# sourceMappingURL=MediaOverlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MediaOverlay.js","names":[],"sources":["../../../../../src/components/pro/Flow/nodes/MediaOverlay.tsx"],"sourcesContent":["import React, { useMemo, Suspense } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport { useFlowUI } from '../context/FlowUIContext';\n\n// Lazy-load the media renderers so the heavy optional deps they pull in\n// (react-markdown, mermaid, katex, markmap, …) are only fetched when a media\n// node actually needs to render. This keeps the base `dishui/flow` bundle\n// lightweight and avoids loading that stack for diagrams without media nodes.\nconst MediaContent = React.lazy(() =>\n import('./MediaContent').then((m) => ({ default: m.MediaContent })),\n);\n\n/** Isolates media render/load failures so one bad node never blanks the editor. */\nclass MediaErrorBoundary extends React.Component<\n { children: React.ReactNode },\n { error: Error | null }\n> {\n constructor(props: { children: React.ReactNode }) {\n super(props);\n this.state = { error: null };\n }\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n render() {\n if (this.state.error) {\n return <div className=\"flow-media-error\">{this.state.error.message}</div>;\n }\n return this.props.children;\n }\n}\n\n/**\n * DOM overlay for media nodes. PixiJS draws the frame; this layer renders the\n * live content (markdown/html/mermaid/math/AI) on top, synced to the viewport\n * so it pans and zooms with the canvas.\n *\n * Event model: a media surface is `pointer-events: none` by default so the\n * canvas underneath can be clicked to select/drag the node's frame. The\n * surface only becomes interactive while its node is selected (so AI chat can\n * be typed into, HTML can be scrolled). This also stops an always-interactive\n * iframe/AI box from swallowing pointer gestures and leaving the drag stuck.\n */\nexport function MediaOverlay() {\n const { currentCanvas, selection } = useFlowContext();\n const { viewport, isNodeDragging } = useFlowUI();\n\n const mediaNodes = useMemo(\n () => currentCanvas.nodes.filter((n) => n.type === 'mediaNode'),\n [currentCanvas.nodes],\n );\n\n if (mediaNodes.length === 0) return null;\n\n const { x: vx, y: vy, zoom } = viewport;\n\n return (\n <div className=\"flow-media-layer\">\n {mediaNodes.map((node) => {\n // World → screen (CSS px, matching ViewportManager.worldToScreen).\n const left = node.position.x * zoom + vx;\n const top = node.position.y * zoom + vy;\n // Interactive only while selected, so the canvas stays draggable.\n // Suppress entirely during a drag: an interactive iframe would swallow\n // the pointer and the canvas would never receive pointerup (stuck drag).\n const interactive = selection.nodeIds.has(node.id) && !isNodeDragging;\n return (\n <div\n key={node.id}\n className=\"flow-media-node\"\n data-media-node={node.id}\n style={{\n position: 'absolute',\n left,\n top,\n width: node.width,\n height: node.height,\n // Scale the fixed-size content box to match zoom without\n // reflowing text on every zoom step.\n transform: `scale(${zoom})`,\n transformOrigin: 'top left',\n // Below the frame's selection outline but above the canvas.\n pointerEvents: 'none',\n }}\n >\n <div\n className=\"flow-media-surface\"\n onWheel={(e) => e.stopPropagation()}\n >\n <Suspense fallback={<div className=\"flow-media-loading\">…</div>}>\n <MediaErrorBoundary>\n <MediaContent node={node} interactive={interactive} />\n </MediaErrorBoundary>\n </Suspense>\n </div>\n </div>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;AAQA,IAAM,IAAe,EAAM,KAAA,MACzB,OAAO,mBAAA,EAAkB,KAAA,CAAM,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CACpE,GAGM,IAAN,cAAiC,EAAM,UAGrC;AAAA,EACA,YAAY,GAAsC;AAChD,UAAM,CAAK,GACX,KAAK,QAAQ,EAAE,OAAO,KAAK;AAAA,EAC7B;AAAA,EACA,OAAO,yBAAyB,GAAc;AAC5C,WAAO,EAAE,OAAA,EAAM;AAAA,EACjB;AAAA,EACA,SAAS;AACP,WAAI,KAAK,MAAM,QACN,gBAAA,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,gBAAoB,KAAK,MAAM,MAAM;AAAA,IAAa,CAAA,IAEnE,KAAK,MAAM;AAAA,EACpB;AACF;AAaA,SAAgB,IAAe;AAC7B,QAAM,EAAE,eAAA,GAAe,WAAA,EAAA,IAAc,EAAe,GAC9C,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../../../../src/components/pro/Flow/nodes/MediaOverlay.tsx"],"sourcesContent":["import React, { useMemo, Suspense } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport { useFlowUI } from '../context/FlowUIContext';\nimport { resolveThemeColorCss } from '../utils/themeColor';\n\n// Lazy-load the media renderers so the heavy optional deps they pull in\n// (react-markdown, mermaid, katex, markmap, …) are only fetched when a media\n// node actually needs to render. This keeps the base `dishui/flow` bundle\n// lightweight and avoids loading that stack for diagrams without media nodes.\nconst MediaContent = React.lazy(() =>\n import('./MediaContent').then((m) => ({ default: m.MediaContent })),\n);\n\n/** Isolates media render/load failures so one bad node never blanks the editor. */\nclass MediaErrorBoundary extends React.Component<\n { children: React.ReactNode },\n { error: Error | null }\n> {\n constructor(props: { children: React.ReactNode }) {\n super(props);\n this.state = { error: null };\n }\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n render() {\n if (this.state.error) {\n return <div className=\"flow-media-error\">{this.state.error.message}</div>;\n }\n return this.props.children;\n }\n}\n\n/**\n * DOM overlay for media nodes. PixiJS draws the frame; this layer renders the\n * live content (markdown/html/mermaid/math/AI) on top, synced to the viewport\n * so it pans and zooms with the canvas.\n *\n * Event model: a media surface is `pointer-events: none` by default so the\n * canvas underneath can be clicked to select/drag the node's frame. The\n * surface only becomes interactive while its node is selected (so AI chat can\n * be typed into, HTML can be scrolled). This also stops an always-interactive\n * iframe/AI box from swallowing pointer gestures and leaving the drag stuck.\n */\nexport function MediaOverlay() {\n const { currentCanvas, selection } = useFlowContext();\n const { viewport, isNodeDragging } = useFlowUI();\n\n const mediaNodes = useMemo(\n () => currentCanvas.nodes.filter((n) => n.type === 'mediaNode'),\n [currentCanvas.nodes],\n );\n\n if (mediaNodes.length === 0) return null;\n\n const { x: vx, y: vy, zoom } = viewport;\n\n return (\n <div className=\"flow-media-layer\">\n {mediaNodes.map((node) => {\n // World → screen (CSS px, matching ViewportManager.worldToScreen).\n const left = node.position.x * zoom + vx;\n const top = node.position.y * zoom + vy;\n // Interactive only while selected, so the canvas stays draggable.\n // Suppress entirely during a drag: an interactive iframe would swallow\n // the pointer and the canvas would never receive pointerup (stuck drag).\n const interactive = selection.nodeIds.has(node.id) && !isNodeDragging;\n // Drive the overlay's background / text from the node's own color data.\n // Theme tokens (`theme:*`) resolve to CSS variables so the media content\n // follows theme switches natively; literal colors are used as-is. This\n // keeps html / ai / data (which render opaque content) in sync with the\n // fill/color chosen in the inspector, matching the PixiJS frame drawn\n // underneath. The border is owned by the Pixi frame (also what PNG/PDF\n // export captures), so we don't redraw it here.\n const fillCss = node.data.fill === 'transparent'\n ? 'transparent'\n : resolveThemeColorCss(node.data.fill, 'transparent');\n const textColor = resolveThemeColorCss(node.data.labelColor ?? node.data.color, '#111827');\n return (\n <div\n key={node.id}\n className=\"flow-media-node\"\n data-media-node={node.id}\n style={{\n position: 'absolute',\n left,\n top,\n width: node.width,\n height: node.height,\n // Scale the fixed-size content box to match zoom without\n // reflowing text on every zoom step.\n transform: `scale(${zoom})`,\n transformOrigin: 'top left',\n // Below the frame's selection outline but above the canvas.\n pointerEvents: 'none',\n }}\n >\n <div\n className=\"flow-media-surface\"\n onWheel={(e) => e.stopPropagation()}\n style={{\n background: fillCss,\n color: textColor,\n }}\n >\n <Suspense fallback={<div className=\"flow-media-loading\">…</div>}>\n <MediaErrorBoundary>\n <MediaContent node={node} interactive={interactive} />\n </MediaErrorBoundary>\n </Suspense>\n </div>\n </div>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;AASA,IAAM,IAAe,EAAM,KAAA,MACzB,OAAO,mBAAA,EAAkB,KAAA,CAAM,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CACpE,GAGM,IAAN,cAAiC,EAAM,UAGrC;AAAA,EACA,YAAY,GAAsC;AAChD,UAAM,CAAK,GACX,KAAK,QAAQ,EAAE,OAAO,KAAK;AAAA,EAC7B;AAAA,EACA,OAAO,yBAAyB,GAAc;AAC5C,WAAO,EAAE,OAAA,EAAM;AAAA,EACjB;AA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AO;AAAA,YACL,YAAY;AAAA,YACZ,OAAO;AAAA,UACT;AAAA,oBAEA,gBAAA,EAAC,GAAD;AAAA,YAAU,UAAU,gBAAA,EAAC,OAAD;AAAA,cAAK,WAAU;AAAA,wBAAqB;AAAA,YAAM,CAAA;AAAA,sBAC5D,gBAAA,EAAC,GAAD,EAAA,UACE,gBAAA,EAAC,GAAD;AAAA,cAAoB,MAAA;AAAA,cAAmB,aAAA;AAAA,YAAc,CAAA,EACnC,CAAA;AAAA,UACZ,CAAA;AAAA,QACP,CAAA;AAAA,MACF,GA/BE,EAAK,EA+BP;AAAA,IAET,CAAC;AAAA,EACE,CAAA;AAET"}
@@ -1,10 +1,11 @@
1
- import { drawRoundRectBorder as M, shapeDrawers as k } from "./shapes.js";
2
- import { createNodeText as O, formatIconLabel as T, normalizeIconLabelPlacement as I, updateNodeText as N } from "./NodeText.js";
3
- import { createHandleGraphics as A, getHandlePositions as R, updateHandleGraphics as L } from "./NodeHandles.js";
4
- import { getFlipScale as z, getRotationRad as H } from "./nodeUtils.js";
5
- import { getIconTexture as B, subscribeIconTextureReady as G } from "./svgIconTexture.js";
6
- import { Container as _, Graphics as W, Sprite as P, Text as D } from "pixi.js";
7
- var j = class {
1
+ import { resolveThemeColor as m } from "../utils/themeColor.js";
2
+ import { drawRoundRectBorder as T, shapeDrawers as S } from "./shapes.js";
3
+ import { createNodeText as I, formatIconLabel as N, normalizeIconLabelPlacement as A, updateNodeText as L } from "./NodeText.js";
4
+ import { createHandleGraphics as z, getHandlePositions as W, updateHandleGraphics as H } from "./NodeHandles.js";
5
+ import { getFlipScale as B, getRotationRad as G } from "./nodeUtils.js";
6
+ import { getIconTexture as P, subscribeIconTextureReady as D } from "./svgIconTexture.js";
7
+ import { Container as R, Graphics as M, Sprite as F, Text as V } from "pixi.js";
8
+ var K = class {
8
9
  world;
9
10
  nodeLayer;
10
11
  nodes = /* @__PURE__ */ new Map();
@@ -14,25 +15,25 @@ var j = class {
14
15
  this._dynamicOffset = (this._dynamicOffset + s * 0.06) % 1e3;
15
16
  }
16
17
  constructor(s) {
17
- this.world = s, this.nodeLayer = new _({
18
+ this.world = s, this.nodeLayer = new R({
18
19
  label: "nodes",
19
20
  sortableChildren: !0
20
- }), this.world.addChild(this.nodeLayer), this._unsubscribeTextureReady = G(() => this._resync?.());
21
+ }), this.world.addChild(this.nodeLayer), this._unsubscribeTextureReady = D(() => this._resync?.());
21
22
  }
22
23
  _resync = null;
23
- sync(s, t, l, f, d) {
24
+ sync(s, t, l, c, d) {
24
25
  const r = /* @__PURE__ */ new Set();
25
- this._resync = () => this.sync(s, t, l, f, d);
26
- const e = f ?? (() => {
27
- const i = s.filter((h) => h.type === "animAnchor").sort((h, o) => (h.data.animIndex ?? 0) - (o.data.animIndex ?? 0)), a = /* @__PURE__ */ new Map();
28
- return i.forEach((h, o) => a.set(h.id, o + 1)), a;
26
+ this._resync = () => this.sync(s, t, l, c, d);
27
+ const i = c ?? (() => {
28
+ const e = s.filter((h) => h.type === "animAnchor").sort((h, o) => (h.data.animIndex ?? 0) - (o.data.animIndex ?? 0)), a = /* @__PURE__ */ new Map();
29
+ return e.forEach((h, o) => a.set(h.id, o + 1)), a;
29
30
  })();
30
- for (const i of s) {
31
- r.add(i.id);
32
- let a = this.nodes.get(i.id);
33
- a || (a = this._createNode(i), this.nodes.set(i.id, a)), this._updateNode(a, i, t.has(i.id), l === i.id, e.get(i.id), d);
31
+ for (const e of s) {
32
+ r.add(e.id);
33
+ let a = this.nodes.get(e.id);
34
+ a || (a = this._createNode(e), this.nodes.set(e.id, a)), this._updateNode(a, e, t.has(e.id), l === e.id, i.get(e.id), d);
34
35
  }
35
- for (const [i, a] of this.nodes) r.has(i) || (this.nodeLayer.removeChild(a.container), a.container.destroy({ children: !0 }), this.nodes.delete(i));
36
+ for (const [e, a] of this.nodes) r.has(e) || (this.nodeLayer.removeChild(a.container), a.container.destroy({ children: !0 }), this.nodes.delete(e));
36
37
  }
37
38
  getNodeContainer(s) {
38
39
  return this.nodes.get(s);
@@ -41,25 +42,25 @@ var j = class {
41
42
  return [...this.nodes.values()];
42
43
  }
43
44
  _createNode(s) {
44
- const t = new _({ label: `node-${s.id}` });
45
+ const t = new R({ label: `node-${s.id}` });
45
46
  t.eventMode = "static", t.cursor = "pointer";
46
- const l = new _({ label: "svg-transform" });
47
+ const l = new R({ label: "svg-transform" });
47
48
  t.addChild(l);
48
- const f = new W();
49
- f.label = "sub-canvas-glow", t.addChild(f);
50
- const d = new W();
49
+ const c = new M();
50
+ c.label = "sub-canvas-glow", t.addChild(c);
51
+ const d = new M();
51
52
  d.label = "shape", t.addChild(d);
52
- const r = new P();
53
+ const r = new F();
53
54
  r.label = "svg-icon", r.anchor.set(0.5, 0.5), r.visible = !1, t.addChild(r);
54
- const e = O({
55
+ const i = I({
55
56
  label: s.data.label,
56
- color: s.data.labelColor ?? s.data.color,
57
+ color: m(s.data.labelColor ?? s.data.color, "#111827"),
57
58
  fontSize: s.data.fontSize,
58
59
  width: s.width,
59
60
  height: s.height
60
61
  });
61
- t.addChild(e);
62
- const i = R(s.width, s.height), a = A(t, i, !1), h = new D({
62
+ t.addChild(i);
63
+ const e = W(s.width, s.height), a = z(t, e, !1), h = new V({
63
64
  text: "",
64
65
  style: {
65
66
  fontFamily: "system-ui, sans-serif",
@@ -73,105 +74,105 @@ var j = class {
73
74
  shape: d,
74
75
  svgTransform: l,
75
76
  icon: r,
76
- text: e,
77
+ text: i,
77
78
  animBadge: h,
78
79
  handles: a,
79
- handleDefs: i,
80
+ handleDefs: e,
80
81
  nodeId: s.id,
81
- subCanvasGlow: f
82
+ subCanvasGlow: c
82
83
  };
83
84
  }
84
- _updateNode(s, t, l, f, d, r) {
85
- const { container: e, svgTransform: i, shape: a, icon: h, text: o, animBadge: b, handles: g, subCanvasGlow: y } = s, w = t.type === "shapeSvg", u = H(t.data), m = z(t.data);
86
- e.zIndex = t.zIndex ?? 0, w ? (a.parent !== i && i.addChild(a), h.parent !== i && i.addChild(h), g.parent !== i && i.addChild(g), e.position.set(t.position.x, t.position.y), e.rotation = 0, e.scale.set(1, 1), e.pivot.set(0, 0), i.position.set(t.width / 2, t.height / 2), i.pivot.set(t.width / 2, t.height / 2), i.rotation = u, i.scale.set(m.sx, m.sy)) : (a.parent !== e && e.addChildAt(a, Math.min(2, e.children.length)), h.parent !== e && e.addChild(h), g.parent !== e && e.addChild(g), i.rotation = 0, i.scale.set(1, 1), e.position.set(t.position.x, t.position.y), e.rotation = u, e.scale.set(m.sx, m.sy), u !== 0 || m.sx < 0 || m.sy < 0 ? (e.pivot.set(t.width / 2, t.height / 2), e.position.set(t.position.x + t.width / 2, t.position.y + t.height / 2)) : e.pivot.set(0, 0));
87
- const S = t.type === "mediaNode", x = t.type === "animAnchor";
85
+ _updateNode(s, t, l, c, d, r) {
86
+ const { container: i, svgTransform: e, shape: a, icon: h, text: o, animBadge: b, handles: g, subCanvasGlow: y } = s, w = t.type === "shapeSvg", x = G(t.data), u = B(t.data);
87
+ i.zIndex = t.zIndex ?? 0, w ? (a.parent !== e && e.addChild(a), h.parent !== e && e.addChild(h), g.parent !== e && e.addChild(g), i.position.set(t.position.x, t.position.y), i.rotation = 0, i.scale.set(1, 1), i.pivot.set(0, 0), e.position.set(t.width / 2, t.height / 2), e.pivot.set(t.width / 2, t.height / 2), e.rotation = x, e.scale.set(u.sx, u.sy)) : (a.parent !== i && i.addChildAt(a, Math.min(2, i.children.length)), h.parent !== i && i.addChild(h), g.parent !== i && i.addChild(g), e.rotation = 0, e.scale.set(1, 1), i.position.set(t.position.x, t.position.y), i.rotation = x, i.scale.set(u.sx, u.sy), x !== 0 || u.sx < 0 || u.sy < 0 ? (i.pivot.set(t.width / 2, t.height / 2), i.position.set(t.position.x + t.width / 2, t.position.y + t.height / 2)) : i.pivot.set(0, 0));
88
+ const _ = t.type === "mediaNode", v = t.type === "animAnchor";
88
89
  if (a.clear(), a.alpha = 1, w) this._updateSvgNode(s, t, l);
89
- else if (S) {
90
+ else if (_) {
90
91
  h.visible = !1;
91
- const c = t.data.fill && t.data.fill !== "transparent" ? t.data.fill : "#ffffff", n = t.data.borderStyle === "none", p = l ? "#3b82f6" : t.data.stroke, C = l ? Math.max(t.data.strokeWidth, 2) : t.data.strokeWidth;
92
- k.shapeRoundRect(a, {
92
+ const f = t.data.fill && t.data.fill !== "transparent" ? m(t.data.fill, "#ffffff") : "#ffffff", n = t.data.borderStyle === "none", p = l ? "#3b82f6" : m(t.data.stroke, "#374151"), k = l ? Math.max(t.data.strokeWidth, 2) : t.data.strokeWidth;
93
+ S.shapeRoundRect(a, {
93
94
  width: t.width,
94
95
  height: t.height,
95
- fill: c,
96
+ fill: f,
96
97
  stroke: p,
97
- strokeWidth: C,
98
+ strokeWidth: k,
98
99
  borderStyle: l && n ? "solid" : t.data.borderStyle,
99
100
  dashOffset: this._dynamicOffset
100
101
  });
101
- } else if (x) {
102
+ } else if (v) {
102
103
  h.visible = !1;
103
- const c = "#8b5cf6", n = r?.presentation ?? !1, p = n ? (r?.presentationAnchorVisible ?? !1) && r?.presentationAnchorId === t.id : r?.showAnchors ?? !0;
104
- p && (a.alpha = n ? 0.48 : 0.9, k.shapeRoundRect(a, {
104
+ const f = "#8b5cf6", n = r?.presentation ?? !1, p = n ? (r?.presentationAnchorVisible ?? !1) && r?.presentationAnchorId === t.id : r?.showAnchors ?? !0;
105
+ p && (a.alpha = n ? 0.48 : 0.9, S.shapeRoundRect(a, {
105
106
  width: t.width,
106
107
  height: t.height,
107
108
  fill: "transparent",
108
- stroke: l && !n ? "#3b82f6" : c,
109
+ stroke: l && !n ? "#3b82f6" : f,
109
110
  strokeWidth: l && !n ? 2.5 : 1.5,
110
111
  borderStyle: "dashed"
111
- }), a.circle(0, 0, n ? 11 : 13).fill({ color: l && !n ? "#3b82f6" : c })), b.text = String(d ?? ""), b.alpha = n ? 0.7 : 1, b.visible = p, b.position.set(0, 0);
112
+ }), a.circle(0, 0, n ? 11 : 13).fill({ color: l && !n ? "#3b82f6" : f })), b.text = String(d ?? ""), b.alpha = n ? 0.7 : 1, b.visible = p, b.position.set(0, 0);
112
113
  } else {
113
114
  h.visible = !1;
114
- const c = k[t.type] ?? k.shapeRect, n = t.data.borderStyle === "none";
115
- c(a, {
115
+ const f = S[t.type] ?? S.shapeRect, n = t.data.borderStyle === "none";
116
+ f(a, {
116
117
  width: t.width,
117
118
  height: t.height,
118
- fill: t.data.fill,
119
- stroke: l ? "#3b82f6" : t.data.stroke,
119
+ fill: m(t.data.fill, "#ffffff"),
120
+ stroke: l ? "#3b82f6" : m(t.data.stroke, "#374151"),
120
121
  strokeWidth: l ? Math.max(t.data.strokeWidth, 2) : t.data.strokeWidth,
121
122
  borderStyle: l && n ? "solid" : t.data.borderStyle,
122
123
  dashOffset: this._dynamicOffset
123
124
  });
124
125
  }
125
- if (x || (b.visible = !1), y.clear(), t.data.childCanvasId) {
126
- const n = t.width + 8, p = t.height + 8, C = 0.5 + 0.3 * Math.sin(this._dynamicOffset * 8e-3);
126
+ if (v || (b.visible = !1), y.clear(), t.data.childCanvasId) {
127
+ const n = t.width + 8, p = t.height + 8, k = 0.5 + 0.3 * Math.sin(this._dynamicOffset * 8e-3);
127
128
  y.roundRect(-4, -4, n, p, 6), y.stroke({
128
129
  color: 9133302,
129
130
  width: 2.5,
130
- alpha: C
131
+ alpha: k
131
132
  }), y.roundRect(-6, -6, n + 4, p + 4, 8), y.stroke({
132
133
  color: 9133302,
133
134
  width: 1,
134
- alpha: C * 0.4
135
+ alpha: k * 0.4
135
136
  });
136
137
  }
137
- const v = I(t.data.labelPlacement);
138
- if (N(o, {
139
- label: S || x ? "" : w ? T(t.data.label, v) : t.data.label,
140
- color: t.data.labelColor ?? t.data.color,
138
+ const C = A(t.data.labelPlacement), O = t.data.labelColor ?? (w ? "theme:base-content" : t.data.color);
139
+ if (L(o, {
140
+ label: _ || v ? "" : w ? N(t.data.label, C) : t.data.label,
141
+ color: m(O, "#111827"),
141
142
  fontSize: t.data.fontSize,
142
143
  width: t.width,
143
144
  height: t.height
144
- }), o.visible = !S && !x, t.type === "shapeCorner") {
145
- const c = Math.min(t.width, t.height) * 0.4;
146
- o.position.set((c + t.width) / 2, (c + t.height) / 2);
145
+ }), o.visible = !_ && !v, t.type === "shapeCorner") {
146
+ const f = Math.min(t.width, t.height) * 0.4;
147
+ o.position.set((f + t.width) / 2, (f + t.height) / 2);
147
148
  } else if (w) {
148
149
  const n = o.width / 2, p = o.height / 2;
149
- v === "top" ? o.position.set(t.width / 2, -4 - p) : v === "bottom" ? o.position.set(t.width / 2, t.height + 4 + p) : v === "left" ? o.position.set(-4 - n, t.height / 2) : v === "right" ? o.position.set(t.width + 4 + n, t.height / 2) : o.position.set(t.width / 2, t.height / 2), o.position.x += t.data.labelOffsetX ?? 0, o.position.y += t.data.labelOffsetY ?? 0;
150
+ C === "top" ? o.position.set(t.width / 2, -4 - p) : C === "bottom" ? o.position.set(t.width / 2, t.height + 4 + p) : C === "left" ? o.position.set(-4 - n, t.height / 2) : C === "right" ? o.position.set(t.width + 4 + n, t.height / 2) : o.position.set(t.width / 2, t.height / 2), o.position.x += t.data.labelOffsetX ?? 0, o.position.y += t.data.labelOffsetY ?? 0;
150
151
  }
151
- if (w ? (o.rotation = 0, o.scale.set(1, 1)) : (o.rotation = -u, o.scale.set(m.sx, m.sy)), g.visible = (f || l) && !(x && r?.presentation), g.visible) {
152
- const c = R(t.width, t.height);
153
- s.handleDefs = c, L(g, c);
152
+ if (w ? (o.rotation = 0, o.scale.set(1, 1)) : (o.rotation = -x, o.scale.set(u.sx, u.sy)), g.visible = (c || l) && !(v && r?.presentation), g.visible) {
153
+ const f = W(t.width, t.height);
154
+ s.handleDefs = f, H(g, f);
154
155
  }
155
156
  }
156
157
  _updateSvgNode(s, t, l) {
157
- const { shape: f, icon: d } = s, { width: r, height: e, data: i } = t, a = i.iconBox ?? !1, h = i.borderStyle ?? (a ? "solid" : "none"), o = h === "none", b = Math.min(8, r * 0.12, e * 0.12);
158
- i.fill && i.fill !== "transparent" && (a || !o) && f.roundRect(0, 0, r, e, b).fill({ color: i.fill }), !o && i.stroke && i.stroke !== "transparent" && i.strokeWidth > 0 && M(f, {
158
+ const { shape: c, icon: d } = s, { width: r, height: i, data: e } = t, a = e.iconBox ?? !1, h = e.borderStyle ?? (a ? "solid" : "none"), o = h === "none", b = Math.min(8, r * 0.12, i * 0.12);
159
+ e.fill && e.fill !== "transparent" && (a || !o) && c.roundRect(0, 0, r, i, b).fill({ color: m(e.fill, "#ffffff") }), !o && e.stroke && e.stroke !== "transparent" && e.strokeWidth > 0 && T(c, {
159
160
  width: r,
160
- height: e,
161
+ height: i,
161
162
  fill: "transparent",
162
- stroke: i.stroke,
163
- strokeWidth: i.strokeWidth,
163
+ stroke: m(e.stroke, "#374151"),
164
+ strokeWidth: e.strokeWidth,
164
165
  borderStyle: h,
165
166
  dashOffset: this._dynamicOffset
166
- }, b), l && f.roundRect(0, 0, r, e, b).stroke({
167
+ }, b), l && c.roundRect(0, 0, r, i, b).stroke({
167
168
  color: "#3b82f6",
168
- width: Math.max(i.strokeWidth, 2)
169
+ width: Math.max(e.strokeWidth, 2)
169
170
  });
170
- const g = i.color || "#334155", y = B(i.svgId ?? "", g);
171
+ const g = m(e.color, "#334155") || "#334155", y = P(e.svgId ?? "", g);
171
172
  if (y) {
172
173
  d.texture = y, d.visible = !0;
173
- const w = a ? Math.min(r, e) * 0.18 : 2, u = Math.max(4, Math.min(r, e) - w * 2);
174
- d.width = u, d.height = u, d.position.set(r / 2, e / 2);
174
+ const w = a ? Math.min(r, i) * 0.18 : 2, x = Math.max(4, Math.min(r, i) - w * 2);
175
+ d.width = x, d.height = x, d.position.set(r / 2, i / 2);
175
176
  } else d.visible = !1;
176
177
  }
177
178
  destroy() {
@@ -181,7 +182,7 @@ var j = class {
181
182
  }
182
183
  };
183
184
  export {
184
- j as NodeRenderer
185
+ K as NodeRenderer
185
186
  };
186
187
 
187
188
  //# sourceMappingURL=NodeRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NodeRenderer.js","names":[],"sources":["../../../../../src/components/pro/Flow/nodes/NodeRenderer.ts"],"sourcesContent":["import { Container, Graphics, Text, Sprite } from 'pixi.js';\nimport type { FlowNode } from '../types';\nimport { drawRoundRectBorder, shapeDrawers, type ShapeDrawOptions } from './shapes';\nimport { createNodeText, formatIconLabel, normalizeIconLabelPlacement, updateNodeText } from './NodeText';\nimport { getHandlePositions, createHandleGraphics, updateHandleGraphics, type HandleDef } from './NodeHandles';\nimport { getRotationRad, getFlipScale } from './nodeUtils';\nimport { getIconTexture, subscribeIconTextureReady } from './svgIconTexture';\n\nexport interface NodeContainer {\n container: Container;\n shape: Graphics;\n /** Rotated/flipped visual content for SVG icon stamps. */\n svgTransform: Container;\n icon: Sprite;\n text: Text;\n /** Sequence badge shown on `animAnchor` nodes. */\n animBadge: Text;\n handles: Graphics;\n handleDefs: HandleDef[];\n nodeId: string;\n subCanvasGlow: Graphics;\n}\n\n/**\n * Manages PixiJS display objects for all nodes on the current canvas.\n * Syncs from FlowNode[] data → PixiJS scene graph.\n */\nexport class NodeRenderer {\n private world: Container;\n private nodeLayer: Container;\n private nodes = new Map<string, NodeContainer>();\n private _dynamicOffset = 0;\n private _unsubscribeTextureReady: () => void;\n\n /** Call once per frame to advance the dynamic dash animation. */\n advanceAnimation(deltaMs: number): void {\n this._dynamicOffset = (this._dynamicOffset + deltaMs * 0.06) % 1000;\n }\n\n constructor(world: Container) {\n this.world = world;\n this.nodeLayer = new Container({ label: 'nodes', sortableChildren: true });\n this.world.addChild(this.nodeLayer);\n this._unsubscribeTextureReady = subscribeIconTextureReady(() => this._resync?.());\n }\n\n private _resync: (() => void) | null = null;\n\n /**\n * Reconcile PixiJS containers with the current node data.\n * Creates new containers, updates existing, removes stale.\n */\n sync(\n flowNodes: FlowNode[],\n selectedIds: Set<string>,\n hoveredId: string | null,\n animSeqMap?: Map<string, number>,\n options?: {\n showAnchors?: boolean;\n presentation?: boolean;\n presentationAnchorId?: string;\n presentationAnchorVisible?: boolean;\n },\n ): void {\n const seen = new Set<string>();\n this._resync = () => this.sync(flowNodes, selectedIds, hoveredId, animSeqMap, options);\n\n // Animation-anchor display sequence (1-based). When a global map is\n // provided (document-wide, shared across sub-canvases) it is used directly;\n // otherwise derive a per-canvas order from stable creation index.\n const seqOf = animSeqMap ?? (() => {\n const anchors = flowNodes\n .filter((n) => n.type === 'animAnchor')\n .sort((a, b) => (a.data.animIndex ?? 0) - (b.data.animIndex ?? 0));\n const m = new Map<string, number>();\n anchors.forEach((n, i) => m.set(n.id, i + 1));\n return m;\n })();\n\n for (const node of flowNodes) {\n seen.add(node.id);\n let nc = this.nodes.get(node.id);\n if (!nc) {\n nc = this._createNode(node);\n this.nodes.set(node.id, nc);\n }\n this._updateNode(\n nc,\n node,\n selectedIds.has(node.id),\n hoveredId === node.id,\n seqOf.get(node.id),\n options,\n );\n }\n\n // Remove nodes no longer in data\n for (const [id, nc] of this.nodes) {\n if (!seen.has(id)) {\n this.nodeLayer.removeChild(nc.container);\n nc.container.destroy({ children: true });\n this.nodes.delete(id);\n }\n }\n }\n\n getNodeContainer(id: string): NodeContainer | undefined {\n return this.nodes.get(id);\n }\n\n getAllNodeContainers(): NodeContainer[] {\n return [...this.nodes.values()];\n }\n\n private _createNode(node: FlowNode): NodeContainer {\n const container = new Container({ label: `node-${node.id}` });\n container.eventMode = 'static';\n container.cursor = 'pointer';\n\n const svgTransform = new Container({ label: 'svg-transform' });\n container.addChild(svgTransform);\n\n const subCanvasGlow = new Graphics();\n subCanvasGlow.label = 'sub-canvas-glow';\n container.addChild(subCanvasGlow);\n\n const shape = new Graphics();\n shape.label = 'shape';\n container.addChild(shape);\n\n const icon = new Sprite();\n icon.label = 'svg-icon';\n icon.anchor.set(0.5, 0.5);\n icon.visible = false;\n container.addChild(icon);\n\n const text = createNodeText({\n label: node.data.label,\n color: node.data.labelColor ?? node.data.color,\n fontSize: node.data.fontSize,\n width: node.width,\n height: node.height,\n });\n container.addChild(text);\n\n const handleDefs = getHandlePositions(node.width, node.height);\n const handles = createHandleGraphics(container, handleDefs, false);\n\n // Sequence badge for animation anchors (top-left corner).\n const animBadge = new Text({\n text: '',\n style: { fontFamily: 'system-ui, sans-serif', fontSize: 13, fill: '#ffffff', fontWeight: '700' },\n });\n animBadge.label = 'anim-badge';\n animBadge.anchor.set(0.5, 0.5);\n animBadge.visible = false;\n container.addChild(animBadge);\n\n this.nodeLayer.addChild(container);\n\n return { container, shape, svgTransform, icon, text, animBadge, handles, handleDefs, nodeId: node.id, subCanvasGlow };\n }\n\n private _updateNode(\n nc: NodeContainer,\n node: FlowNode,\n selected: boolean,\n hovered: boolean,\n animSeq?: number,\n options?: {\n showAnchors?: boolean;\n presentation?: boolean;\n presentationAnchorId?: string;\n presentationAnchorVisible?: boolean;\n },\n ): void {\n const { container, svgTransform, shape, icon, text, animBadge, handles, subCanvasGlow } = nc;\n\n const isSvg = node.type === 'shapeSvg';\n const rad = getRotationRad(node.data);\n const flip = getFlipScale(node.data);\n\n container.zIndex = node.zIndex ?? 0;\n if (isSvg) {\n // Keep the label in the untransformed root. Only the icon box, icon and\n // connection handles rotate/flip around the node center.\n if (shape.parent !== svgTransform) svgTransform.addChild(shape);\n if (icon.parent !== svgTransform) svgTransform.addChild(icon);\n if (handles.parent !== svgTransform) svgTransform.addChild(handles);\n container.position.set(node.position.x, node.position.y);\n container.rotation = 0;\n container.scale.set(1, 1);\n container.pivot.set(0, 0);\n svgTransform.position.set(node.width / 2, node.height / 2);\n svgTransform.pivot.set(node.width / 2, node.height / 2);\n svgTransform.rotation = rad;\n svgTransform.scale.set(flip.sx, flip.sy);\n } else {\n if (shape.parent !== container) container.addChildAt(shape, Math.min(2, container.children.length));\n if (icon.parent !== container) container.addChild(icon);\n if (handles.parent !== container) container.addChild(handles);\n svgTransform.rotation = 0;\n svgTransform.scale.set(1, 1);\n container.position.set(node.position.x, node.position.y);\n container.rotation = rad;\n container.scale.set(flip.sx, flip.sy);\n if (rad !== 0 || flip.sx < 0 || flip.sy < 0) {\n container.pivot.set(node.width / 2, node.height / 2);\n container.position.set(node.position.x + node.width / 2, node.position.y + node.height / 2);\n } else {\n container.pivot.set(0, 0);\n }\n }\n\n const isMedia = node.type === 'mediaNode';\n const isAnchor = node.type === 'animAnchor';\n\n // Redraw shape\n shape.clear();\n shape.alpha = 1;\n if (isSvg) {\n this._updateSvgNode(nc, node, selected);\n } else if (isMedia) {\n // Media nodes render their content in a synced DOM overlay; PixiJS only\n // draws the frame (background + border) beneath the overlay.\n icon.visible = false;\n const r = 6;\n const fill = node.data.fill && node.data.fill !== 'transparent' ? node.data.fill : '#ffffff';\n const borderHidden = node.data.borderStyle === 'none';\n const strokeColor = selected ? '#3b82f6' : node.data.stroke;\n const strokeW = selected ? Math.max(node.data.strokeWidth, 2) : node.data.strokeWidth;\n shapeDrawers.shapeRoundRect(shape, {\n width: node.width,\n height: node.height,\n fill,\n stroke: strokeColor,\n strokeWidth: strokeW,\n borderStyle: selected && borderHidden ? 'solid' : node.data.borderStyle,\n dashOffset: this._dynamicOffset,\n });\n } else if (isAnchor) {\n // Animation anchors are globally visible/hidden in editing mode. During\n // presentation the current frame remains as a subtle dashed overlay.\n icon.visible = false;\n const accent = '#8b5cf6';\n const presentation = options?.presentation ?? false;\n const anchorVisible = presentation\n ? (options?.presentationAnchorVisible ?? false) && options?.presentationAnchorId === node.id\n : (options?.showAnchors ?? true);\n if (anchorVisible) {\n shape.alpha = presentation ? 0.48 : 0.9;\n shapeDrawers.shapeRoundRect(shape, {\n width: node.width,\n height: node.height,\n fill: 'transparent',\n stroke: selected && !presentation ? '#3b82f6' : accent,\n strokeWidth: selected && !presentation ? 2.5 : 1.5,\n borderStyle: 'dashed',\n });\n shape.circle(0, 0, presentation ? 11 : 13).fill({\n color: selected && !presentation ? '#3b82f6' : accent,\n });\n }\n animBadge.text = String(animSeq ?? '');\n animBadge.alpha = presentation ? 0.7 : 1;\n animBadge.visible = anchorVisible;\n animBadge.position.set(0, 0);\n } else {\n icon.visible = false;\n const drawFn = shapeDrawers[node.type] ?? shapeDrawers.shapeRect;\n const borderHidden = node.data.borderStyle === 'none';\n const opts: ShapeDrawOptions = {\n width: node.width,\n height: node.height,\n fill: node.data.fill,\n stroke: selected ? '#3b82f6' : node.data.stroke,\n strokeWidth: selected ? Math.max(node.data.strokeWidth, 2) : node.data.strokeWidth,\n borderStyle: (selected && borderHidden) ? 'solid' : node.data.borderStyle,\n dashOffset: this._dynamicOffset,\n };\n drawFn(shape, opts);\n }\n if (!isAnchor) animBadge.visible = false;\n\n // Sub-canvas glow indicator\n subCanvasGlow.clear();\n if (node.data.childCanvasId) {\n const pad = 4;\n const w = node.width + pad * 2;\n const h = node.height + pad * 2;\n const pulse = 0.5 + 0.3 * Math.sin(this._dynamicOffset * 0.008);\n subCanvasGlow.roundRect(-pad, -pad, w, h, 6);\n subCanvasGlow.stroke({ color: 0x8b5cf6, width: 2.5, alpha: pulse });\n subCanvasGlow.roundRect(-pad - 2, -pad - 2, w + 4, h + 4, 8);\n subCanvasGlow.stroke({ color: 0x8b5cf6, width: 1, alpha: pulse * 0.4 });\n }\n\n // Text: counter-rotate and counter-flip so it stays upright\n const iconLabelPlacement = normalizeIconLabelPlacement(node.data.labelPlacement);\n updateNodeText(text, {\n label: isMedia || isAnchor\n ? ''\n : isSvg\n ? formatIconLabel(node.data.label, iconLabelPlacement)\n : node.data.label,\n color: node.data.labelColor ?? node.data.color,\n fontSize: node.data.fontSize,\n width: node.width,\n height: node.height,\n });\n text.visible = !isMedia && !isAnchor;\n\n if (node.type === 'shapeCorner') {\n const half = Math.min(node.width, node.height) * 0.4;\n text.position.set((half + node.width) / 2, (half + node.height) / 2);\n } else if (isSvg) {\n const gap = 4;\n const halfTextWidth = text.width / 2;\n const halfTextHeight = text.height / 2;\n if (iconLabelPlacement === 'top') {\n text.position.set(node.width / 2, -gap - halfTextHeight);\n } else if (iconLabelPlacement === 'bottom') {\n text.position.set(node.width / 2, node.height + gap + halfTextHeight);\n } else if (iconLabelPlacement === 'left') {\n text.position.set(-gap - halfTextWidth, node.height / 2);\n } else if (iconLabelPlacement === 'right') {\n text.position.set(node.width + gap + halfTextWidth, node.height / 2);\n } else {\n text.position.set(node.width / 2, node.height / 2);\n }\n text.position.x += node.data.labelOffsetX ?? 0;\n text.position.y += node.data.labelOffsetY ?? 0;\n }\n\n if (isSvg) {\n text.rotation = 0;\n text.scale.set(1, 1);\n } else {\n text.rotation = -rad;\n text.scale.set(flip.sx, flip.sy);\n }\n\n // Handles visibility\n handles.visible = (hovered || selected) && !(isAnchor && options?.presentation);\n if (handles.visible) {\n const defs = getHandlePositions(node.width, node.height);\n nc.handleDefs = defs;\n updateHandleGraphics(handles, defs);\n }\n }\n\n /**\n * Draw an SVG-stamp node: optional bordered box + centered icon sprite.\n * The icon texture is rasterized lazily; a redraw is requested when ready.\n */\n private _updateSvgNode(nc: NodeContainer, node: FlowNode, selected: boolean): void {\n const { shape, icon } = nc;\n const { width, height, data } = node;\n\n // Render the configured icon box independently from the solid selection\n // outline. Otherwise selecting an icon makes dotted/dashed borders appear\n // solid and hides whether the chosen border style is actually applied.\n const showBox = data.iconBox ?? false;\n const borderStyle = data.borderStyle ?? (showBox ? 'solid' : 'none');\n const borderHidden = borderStyle === 'none';\n const r = Math.min(8, width * 0.12, height * 0.12);\n if (data.fill && data.fill !== 'transparent' && (showBox || !borderHidden)) {\n shape.roundRect(0, 0, width, height, r).fill({ color: data.fill });\n }\n if (!borderHidden && data.stroke && data.stroke !== 'transparent' && data.strokeWidth > 0) {\n drawRoundRectBorder(shape, {\n width,\n height,\n fill: 'transparent',\n stroke: data.stroke,\n strokeWidth: data.strokeWidth,\n borderStyle,\n dashOffset: this._dynamicOffset,\n }, r);\n }\n if (selected) {\n shape.roundRect(0, 0, width, height, r).stroke({\n color: '#3b82f6',\n width: Math.max(data.strokeWidth, 2),\n });\n }\n\n // Icon sprite: fit within the box with padding, centered. The texture is\n // rasterized lazily; because the ticker re-runs sync every frame, it will\n // be picked up automatically once cached.\n const iconColor = data.color || '#334155';\n const tex = getIconTexture(data.svgId ?? '', iconColor);\n if (tex) {\n icon.texture = tex;\n icon.visible = true;\n const pad = showBox ? Math.min(width, height) * 0.18 : 2;\n const box = Math.max(4, Math.min(width, height) - pad * 2);\n icon.width = box;\n icon.height = box;\n icon.position.set(width / 2, height / 2);\n } else {\n icon.visible = false;\n }\n }\n\n destroy(): void {\n this._unsubscribeTextureReady();\n this._resync = null;\n for (const [, nc] of this.nodes) {\n nc.container.destroy({ children: true });\n }\n this.nodes.clear();\n this.nodeLayer.destroy({ children: true });\n }\n}\n"],"mappings":";;;;;;AA2BA,IAAa,IAAb,MAA0B;AAAA,EACxB;AAAA,EACA;AAAA,EACA,QAAgB,oBAAI,IAA2B;AAAA,EAC/C,iBAAyB;AAAA,EACzB;AAAA,EAGA,iBAAiB,GAAuB;AACtC,SAAK,kBAAkB,KAAK,iBAAiB,IAAU,QAAQ;AAAA,EACjE;AAAA,EAEA,YAAY,GAAkB;AAC5B,SAAK,QAAQ,GACb,KAAK,YAAY,IAAI,EAAU;AAAA,MAAE,OAAO;AAAA,MAAS,kBAAkB;AAAA,IAAK,CAAC,GACzE,KAAK,MAAM,SAAS,KAAK,SAAS,GAClC,KAAK,2BAA2B,EAAA,MAAgC,KAAK,UAAU,CAAC;AAAA,EAClF;AAAA,EAEA,UAAuC;AAAA,EAMvC,KACE,GACA,GACA,GACA,GACA,GAMM;AACN,UAAM,IAAO,oBAAI,IAAY;AAC7B,SAAK,UAAA,MAAgB,KAAK,KAAK,GAAW,GAAa,GAAW,GAAY,CAAO;AAKrF,UAAM,IAAQ,MAAA,MAAqB;AACjC,YAAM,IAAU,EACb,OAAA,CAAQ,MAAM,EAAE,SAAS,YAAY,EACrC,KAAA,CAAM,GAAG,OAAO,EAAE,KAAK,aAAa,MAAM,EAAE,KAAK,aAAa,EAAE,GAC7D,IAAI,oBAAI,IAAoB;AAClC,aAAA,EAAQ,QAAA,CAAS,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI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nodes/NodeRenderer.ts"],"sourcesContent":["import { Container, Graphics, Text, Sprite } from 'pixi.js';\nimport type { FlowNode } from '../types';\nimport { drawRoundRectBorder, shapeDrawers, type ShapeDrawOptions } from './shapes';\nimport { createNodeText, formatIconLabel, normalizeIconLabelPlacement, updateNodeText } from './NodeText';\nimport { getHandlePositions, createHandleGraphics, updateHandleGraphics, type HandleDef } from './NodeHandles';\nimport { getRotationRad, getFlipScale } from './nodeUtils';\nimport { getIconTexture, subscribeIconTextureReady } from './svgIconTexture';\nimport { resolveThemeColor } from '../utils/themeColor';\n\nexport interface NodeContainer {\n container: Container;\n shape: Graphics;\n /** Rotated/flipped visual content for SVG icon stamps. */\n svgTransform: Container;\n icon: Sprite;\n text: Text;\n /** Sequence badge shown on `animAnchor` nodes. */\n animBadge: Text;\n handles: Graphics;\n handleDefs: HandleDef[];\n nodeId: string;\n subCanvasGlow: Graphics;\n}\n\n/**\n * Manages PixiJS display objects for all nodes on the current canvas.\n * Syncs from FlowNode[] data → PixiJS scene graph.\n */\nexport class NodeRenderer {\n private world: Container;\n private nodeLayer: Container;\n private nodes = new Map<string, NodeContainer>();\n private _dynamicOffset = 0;\n private _unsubscribeTextureReady: () => void;\n\n /** Call once per frame to advance the dynamic dash animation. */\n advanceAnimation(deltaMs: number): void {\n this._dynamicOffset = (this._dynamicOffset + deltaMs * 0.06) % 1000;\n }\n\n constructor(world: Container) {\n this.world = world;\n this.nodeLayer = new Container({ label: 'nodes', sortableChildren: true });\n this.world.addChild(this.nodeLayer);\n this._unsubscribeTextureReady = subscribeIconTextureReady(() => this._resync?.());\n }\n\n private _resync: (() => void) | null = null;\n\n /**\n * Reconcile PixiJS containers with the current node data.\n * Creates new containers, updates existing, removes stale.\n */\n sync(\n flowNodes: FlowNode[],\n selectedIds: Set<string>,\n hoveredId: string | null,\n animSeqMap?: Map<string, number>,\n options?: {\n showAnchors?: boolean;\n presentation?: boolean;\n presentationAnchorId?: string;\n presentationAnchorVisible?: boolean;\n },\n ): void {\n const seen = new Set<string>();\n this._resync = () => this.sync(flowNodes, selectedIds, hoveredId, animSeqMap, options);\n\n // Animation-anchor display sequence (1-based). When a global map is\n // provided (document-wide, shared across sub-canvases) it is used directly;\n // otherwise derive a per-canvas order from stable creation index.\n const seqOf = animSeqMap ?? (() => {\n const anchors = flowNodes\n .filter((n) => n.type === 'animAnchor')\n .sort((a, b) => (a.data.animIndex ?? 0) - (b.data.animIndex ?? 0));\n const m = new Map<string, number>();\n anchors.forEach((n, i) => m.set(n.id, i + 1));\n return m;\n })();\n\n for (const node of flowNodes) {\n seen.add(node.id);\n let nc = this.nodes.get(node.id);\n if (!nc) {\n nc = this._createNode(node);\n this.nodes.set(node.id, nc);\n }\n this._updateNode(\n nc,\n node,\n selectedIds.has(node.id),\n hoveredId === node.id,\n seqOf.get(node.id),\n options,\n );\n }\n\n // Remove nodes no longer in data\n for (const [id, nc] of this.nodes) {\n if (!seen.has(id)) {\n this.nodeLayer.removeChild(nc.container);\n nc.container.destroy({ children: true });\n this.nodes.delete(id);\n }\n }\n }\n\n getNodeContainer(id: string): NodeContainer | undefined {\n return this.nodes.get(id);\n }\n\n getAllNodeContainers(): NodeContainer[] {\n return [...this.nodes.values()];\n }\n\n private _createNode(node: FlowNode): NodeContainer {\n const container = new Container({ label: `node-${node.id}` });\n container.eventMode = 'static';\n container.cursor = 'pointer';\n\n const svgTransform = new Container({ label: 'svg-transform' });\n container.addChild(svgTransform);\n\n const subCanvasGlow = new Graphics();\n subCanvasGlow.label = 'sub-canvas-glow';\n container.addChild(subCanvasGlow);\n\n const shape = new Graphics();\n shape.label = 'shape';\n container.addChild(shape);\n\n const icon = new Sprite();\n icon.label = 'svg-icon';\n icon.anchor.set(0.5, 0.5);\n icon.visible = false;\n container.addChild(icon);\n\n const text = createNodeText({\n label: node.data.label,\n color: resolveThemeColor(node.data.labelColor ?? node.data.color, '#111827'),\n fontSize: node.data.fontSize,\n width: node.width,\n height: node.height,\n });\n container.addChild(text);\n\n const handleDefs = getHandlePositions(node.width, node.height);\n const handles = createHandleGraphics(container, handleDefs, false);\n\n // Sequence badge for animation anchors (top-left corner).\n const animBadge = new Text({\n text: '',\n style: { fontFamily: 'system-ui, sans-serif', fontSize: 13, fill: '#ffffff', fontWeight: '700' },\n });\n animBadge.label = 'anim-badge';\n animBadge.anchor.set(0.5, 0.5);\n animBadge.visible = false;\n container.addChild(animBadge);\n\n this.nodeLayer.addChild(container);\n\n return { container, shape, svgTransform, icon, text, animBadge, handles, handleDefs, nodeId: node.id, subCanvasGlow };\n }\n\n private _updateNode(\n nc: NodeContainer,\n node: FlowNode,\n selected: boolean,\n hovered: boolean,\n animSeq?: number,\n options?: {\n showAnchors?: boolean;\n presentation?: boolean;\n presentationAnchorId?: string;\n presentationAnchorVisible?: boolean;\n },\n ): void {\n const { container, svgTransform, shape, icon, text, animBadge, handles, subCanvasGlow } = nc;\n\n const isSvg = node.type === 'shapeSvg';\n const rad = getRotationRad(node.data);\n const flip = getFlipScale(node.data);\n\n container.zIndex = node.zIndex ?? 0;\n if (isSvg) {\n // Keep the label in the untransformed root. Only the icon box, icon and\n // connection handles rotate/flip around the node center.\n if (shape.parent !== svgTransform) svgTransform.addChild(shape);\n if (icon.parent !== svgTransform) svgTransform.addChild(icon);\n if (handles.parent !== svgTransform) svgTransform.addChild(handles);\n container.position.set(node.position.x, node.position.y);\n container.rotation = 0;\n container.scale.set(1, 1);\n container.pivot.set(0, 0);\n svgTransform.position.set(node.width / 2, node.height / 2);\n svgTransform.pivot.set(node.width / 2, node.height / 2);\n svgTransform.rotation = rad;\n svgTransform.scale.set(flip.sx, flip.sy);\n } else {\n if (shape.parent !== container) container.addChildAt(shape, Math.min(2, container.children.length));\n if (icon.parent !== container) container.addChild(icon);\n if (handles.parent !== container) container.addChild(handles);\n svgTransform.rotation = 0;\n svgTransform.scale.set(1, 1);\n container.position.set(node.position.x, node.position.y);\n container.rotation = rad;\n container.scale.set(flip.sx, flip.sy);\n if (rad !== 0 || flip.sx < 0 || flip.sy < 0) {\n container.pivot.set(node.width / 2, node.height / 2);\n container.position.set(node.position.x + node.width / 2, node.position.y + node.height / 2);\n } else {\n container.pivot.set(0, 0);\n }\n }\n\n const isMedia = node.type === 'mediaNode';\n const isAnchor = node.type === 'animAnchor';\n\n // Redraw shape\n shape.clear();\n shape.alpha = 1;\n if (isSvg) {\n this._updateSvgNode(nc, node, selected);\n } else if (isMedia) {\n // Media nodes render their content in a synced DOM overlay; PixiJS only\n // draws the frame (background + border) beneath the overlay.\n icon.visible = false;\n const r = 6;\n const fill = node.data.fill && node.data.fill !== 'transparent' ? resolveThemeColor(node.data.fill, '#ffffff') : '#ffffff';\n const borderHidden = node.data.borderStyle === 'none';\n const strokeColor = selected ? '#3b82f6' : resolveThemeColor(node.data.stroke, '#374151');\n const strokeW = selected ? Math.max(node.data.strokeWidth, 2) : node.data.strokeWidth;\n shapeDrawers.shapeRoundRect(shape, {\n width: node.width,\n height: node.height,\n fill,\n stroke: strokeColor,\n strokeWidth: strokeW,\n borderStyle: selected && borderHidden ? 'solid' : node.data.borderStyle,\n dashOffset: this._dynamicOffset,\n });\n } else if (isAnchor) {\n // Animation anchors are globally visible/hidden in editing mode. During\n // presentation the current frame remains as a subtle dashed overlay.\n icon.visible = false;\n const accent = '#8b5cf6';\n const presentation = options?.presentation ?? false;\n const anchorVisible = presentation\n ? (options?.presentationAnchorVisible ?? false) && options?.presentationAnchorId === node.id\n : (options?.showAnchors ?? true);\n if (anchorVisible) {\n shape.alpha = presentation ? 0.48 : 0.9;\n shapeDrawers.shapeRoundRect(shape, {\n width: node.width,\n height: node.height,\n fill: 'transparent',\n stroke: selected && !presentation ? '#3b82f6' : accent,\n strokeWidth: selected && !presentation ? 2.5 : 1.5,\n borderStyle: 'dashed',\n });\n shape.circle(0, 0, presentation ? 11 : 13).fill({\n color: selected && !presentation ? '#3b82f6' : accent,\n });\n }\n animBadge.text = String(animSeq ?? '');\n animBadge.alpha = presentation ? 0.7 : 1;\n animBadge.visible = anchorVisible;\n animBadge.position.set(0, 0);\n } else {\n icon.visible = false;\n const drawFn = shapeDrawers[node.type] ?? shapeDrawers.shapeRect;\n const borderHidden = node.data.borderStyle === 'none';\n const opts: ShapeDrawOptions = {\n width: node.width,\n height: node.height,\n fill: resolveThemeColor(node.data.fill, '#ffffff'),\n stroke: selected ? '#3b82f6' : resolveThemeColor(node.data.stroke, '#374151'),\n strokeWidth: selected ? Math.max(node.data.strokeWidth, 2) : node.data.strokeWidth,\n borderStyle: (selected && borderHidden) ? 'solid' : node.data.borderStyle,\n dashOffset: this._dynamicOffset,\n };\n drawFn(shape, opts);\n }\n if (!isAnchor) animBadge.visible = false;\n\n // Sub-canvas glow indicator\n subCanvasGlow.clear();\n if (node.data.childCanvasId) {\n const pad = 4;\n const w = node.width + pad * 2;\n const h = node.height + pad * 2;\n const pulse = 0.5 + 0.3 * Math.sin(this._dynamicOffset * 0.008);\n subCanvasGlow.roundRect(-pad, -pad, w, h, 6);\n subCanvasGlow.stroke({ color: 0x8b5cf6, width: 2.5, alpha: pulse });\n subCanvasGlow.roundRect(-pad - 2, -pad - 2, w + 4, h + 4, 8);\n subCanvasGlow.stroke({ color: 0x8b5cf6, width: 1, alpha: pulse * 0.4 });\n }\n\n // Text: counter-rotate and counter-flip so it stays upright\n const iconLabelPlacement = normalizeIconLabelPlacement(node.data.labelPlacement);\n // SVG-icon labels default to the theme font color (so they read on any\n // theme) even when the icon body uses a brand color; other node types fall\n // back to the node's own text color.\n const labelColor = node.data.labelColor\n ?? (isSvg ? 'theme:base-content' : node.data.color);\n updateNodeText(text, {\n label: isMedia || isAnchor\n ? ''\n : isSvg\n ? formatIconLabel(node.data.label, iconLabelPlacement)\n : node.data.label,\n color: resolveThemeColor(labelColor, '#111827'),\n fontSize: node.data.fontSize,\n width: node.width,\n height: node.height,\n });\n text.visible = !isMedia && !isAnchor;\n\n if (node.type === 'shapeCorner') {\n const half = Math.min(node.width, node.height) * 0.4;\n text.position.set((half + node.width) / 2, (half + node.height) / 2);\n } else if (isSvg) {\n const gap = 4;\n const halfTextWidth = text.width / 2;\n const halfTextHeight = text.height / 2;\n if (iconLabelPlacement === 'top') {\n text.position.set(node.width / 2, -gap - halfTextHeight);\n } else if (iconLabelPlacement === 'bottom') {\n text.position.set(node.width / 2, node.height + gap + halfTextHeight);\n } else if (iconLabelPlacement === 'left') {\n text.position.set(-gap - halfTextWidth, node.height / 2);\n } else if (iconLabelPlacement === 'right') {\n text.position.set(node.width + gap + halfTextWidth, node.height / 2);\n } else {\n text.position.set(node.width / 2, node.height / 2);\n }\n text.position.x += node.data.labelOffsetX ?? 0;\n text.position.y += node.data.labelOffsetY ?? 0;\n }\n\n if (isSvg) {\n text.rotation = 0;\n text.scale.set(1, 1);\n } else {\n text.rotation = -rad;\n text.scale.set(flip.sx, flip.sy);\n }\n\n // Handles visibility\n handles.visible = (hovered || selected) && !(isAnchor && options?.presentation);\n if (handles.visible) {\n const defs = getHandlePositions(node.width, node.height);\n nc.handleDefs = defs;\n updateHandleGraphics(handles, defs);\n }\n }\n\n /**\n * Draw an SVG-stamp node: optional bordered box + centered icon sprite.\n * The icon texture is rasterized lazily; a redraw is requested when ready.\n */\n private _updateSvgNode(nc: NodeContainer, node: FlowNode, selected: boolean): void {\n const { shape, icon } = nc;\n const { width, height, data } = node;\n\n // Render the configured icon box independently from the solid selection\n // outline. Otherwise selecting an icon makes dotted/dashed borders appear\n // solid and hides whether the chosen border style is actually applied.\n const showBox = data.iconBox ?? false;\n const borderStyle = data.borderStyle ?? (showBox ? 'solid' : 'none');\n const borderHidden = borderStyle === 'none';\n const r = Math.min(8, width * 0.12, height * 0.12);\n if (data.fill && data.fill !== 'transparent' && (showBox || !borderHidden)) {\n shape.roundRect(0, 0, width, height, r).fill({ color: resolveThemeColor(data.fill, '#ffffff') });\n }\n if (!borderHidden && data.stroke && data.stroke !== 'transparent' && data.strokeWidth > 0) {\n drawRoundRectBorder(shape, {\n width,\n height,\n fill: 'transparent',\n stroke: resolveThemeColor(data.stroke, '#374151'),\n strokeWidth: data.strokeWidth,\n borderStyle,\n dashOffset: this._dynamicOffset,\n }, r);\n }\n if (selected) {\n shape.roundRect(0, 0, width, height, r).stroke({\n color: '#3b82f6',\n width: Math.max(data.strokeWidth, 2),\n });\n }\n\n // Icon sprite: fit within the box with padding, centered. The texture is\n // rasterized lazily; because the ticker re-runs sync every frame, it will\n // be picked up automatically once cached.\n const iconColor = resolveThemeColor(data.color, '#334155') || '#334155';\n const tex = getIconTexture(data.svgId ?? '', iconColor);\n if (tex) {\n icon.texture = tex;\n icon.visible = true;\n const pad = showBox ? Math.min(width, height) * 0.18 : 2;\n const box = Math.max(4, Math.min(width, height) - pad * 2);\n icon.width = box;\n icon.height = box;\n icon.position.set(width / 2, height / 2);\n } else {\n icon.visible = false;\n }\n }\n\n destroy(): void {\n this._unsubscribeTextureReady();\n this._resync = null;\n for (const [, nc] of this.nodes) {\n nc.container.destroy({ children: true });\n }\n this.nodes.clear();\n this.nodeLayer.destroy({ children: true });\n }\n}\n"],"mappings":";;;;;;;AA4BA,IAAa,IAAb,MAA0B;AAAA,EACxB;AAAA,EACA;AAAA,EACA,QAAgB,oBAAI,IAA2B;AAAA,EAC/C,iBAAyB;AAAA,EACzB;AAAA,EAGA,iBAAiB,GAAuB;AACtC,SAAK,kBAAkB,KAAK,iBAAiB,IAAU,QAAQ;AAAA,EACjE;AAAA,EAEA,YAAY,GAAkB;AAC5B,SAAK,QAAQ,GACb,KAAK,YAAY,IAAI,EAAU;AAAA,MAAE,OAAO;AAAA,MAAS,kBAAkB;AAAA,IAAK,CAAC,GACzE,KAAK,MAAM,SAAS,KAAK,SAAS,GAClC,KAAK,2BAA2B,EAAA,MAAgC,KAAK,UAAU,CAAC;AAAA,EAClF;AAAA,EAEA,UAAuC;AAAA,EAMvC,KACE,GACA,GACA,GACA,GACA,GAMM;AACN,UAAM,IAAO,oBAAI,IAAY;AAC7B,SAAK,UAAA,MAAgB,KAAK,KAAK,GAAW,GAAa,GAAW,GAAY,CA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,GAAO,CAAM,IAAI,IAAM,CAAC;AACzD,MAAA,EAAK,QAAQ,GACb,EAAK,SAAS,GACd,EAAK,SAAS,IAAI,IAAQ,GAAG,IAAS,CAAC;AAAA,IACzC,MACE,CAAA,EAAK,UAAU;AAAA,EAEnB;AAAA,EAEA,UAAgB;AACd,SAAK,yBAAyB,GAC9B,KAAK,UAAU;AACf,eAAW,CAAA,EAAG,CAAA,KAAO,KAAK,MACxB,CAAA,EAAG,UAAU,QAAQ,EAAE,UAAU,GAAK,CAAC;AAEzC,SAAK,MAAM,MAAM,GACjB,KAAK,UAAU,QAAQ,EAAE,UAAU,GAAK,CAAC;AAAA,EAC3C;AACF"}
@@ -12,3 +12,25 @@ export interface AIChatMessage {
12
12
  content: string;
13
13
  }
14
14
  export declare function streamAIChat(config: FlowAIConfig, messages: AIChatMessage[], signal: AbortSignal): AsyncIterable<string>;
15
+ /**
16
+ * Non-streaming completion used by the AI flow generator. Accepts an optional
17
+ * image (data URL) for "reconstruct this diagram" requests. Returns the full
18
+ * assistant text.
19
+ */
20
+ export declare function completeAIChat(config: FlowAIConfig, userText: string, options?: {
21
+ imageDataUrl?: string;
22
+ systemPrompt?: string;
23
+ signal?: AbortSignal;
24
+ }): Promise<string>;
25
+ /**
26
+ * Streaming variant of `completeAIChat`: same multimodal request shape
27
+ * (optional image + system prompt override), but the reply is consumed as SSE
28
+ * deltas. `onDelta` fires with the accumulated text after every chunk so
29
+ * callers can render the response live. Returns the full assistant text.
30
+ */
31
+ export declare function completeAIChatStream(config: FlowAIConfig, userText: string, options?: {
32
+ imageDataUrl?: string;
33
+ systemPrompt?: string;
34
+ signal?: AbortSignal;
35
+ onDelta?: (accumulated: string) => void;
36
+ }): Promise<string>;