@particle-academy/fancy-echarts 2.0.3 → 3.0.2

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/README.md CHANGED
@@ -244,6 +244,41 @@ const [theme, setTheme] = useState<"light" | "dark-preset">("light");
244
244
  - **`params.event` vs `params.event.event`.** ECharts wraps the native event. Call `params.event.event.preventDefault()` to stop the browser context menu, not `params.event.preventDefault()`.
245
245
  - **Don't render React inside `tooltip.formatter`.** Returning an HTML string is fine; expecting React state or handlers to attach to that HTML is not. For interactive tooltips, use `Popover` driven by `onEvents.mouseover` / `mouseout` instead.
246
246
 
247
+ ## Diagrams
248
+
249
+ Beyond charts, fancy-echarts ships four schema-driven diagram components for data-modeling, process flows, mindmapping, and hierarchies. They share one routing/marker engine — same import surface, same theming.
250
+
251
+ ```tsx
252
+ import { DataDiagram, Flowchart, Mindmap, OrgChart } from "@particle-academy/fancy-echarts";
253
+ ```
254
+
255
+ | Component | Use case | Default routing |
256
+ |-----------|----------|-----------------|
257
+ | `<DataDiagram>` | ERD / UML class diagrams with fields, primary/foreign keys, exports | manhattan |
258
+ | `<Flowchart>` | Boxes + typed arrows, no fields | manhattan |
259
+ | `<Mindmap>` | Radial single-root tree with bezier connectors | bezier |
260
+ | `<OrgChart>` | Top-down hierarchy, tidy-tree layout, inheritance markers | manhattan |
261
+
262
+ See [docs/Diagram.md](docs/Diagram.md) for schemas, props, and layout details.
263
+
264
+ ## Inertia.js integration
265
+
266
+ If your app uses Inertia, install [`@particle-academy/fancy-inertia`](https://github.com/Particle-Academy/fancy-inertia). Three things to know:
267
+
268
+ 1. **`<FancyAppRoot withECharts>`** auto-calls `registerAll()` and `registerBuiltinThemes()` on the client only — drop it once at app entry and every page below it has charts ready.
269
+ 2. **SSR**: every fancy-echarts component (`<EChart>`, `<EChart3D>`, `<EChartGraphic>`, and the diagram presets) needs `window` to initialize. Wrap in `<FancyClientOnly>` if Inertia SSR is enabled.
270
+ 3. **Schema mode**: pass `withECharts: true` to `registerFancyComponents()` and your fancy-screens schemas can reference `EChart`, `DataDiagram`, `Flowchart`, `Mindmap`, `OrgChart` by name from server-supplied JSON.
271
+
272
+ ```tsx
273
+ import { FancyAppRoot, FancyClientOnly } from "@particle-academy/fancy-inertia";
274
+
275
+ <FancyAppRoot withECharts>
276
+ <FancyClientOnly fallback={<div className="h-80 animate-pulse rounded bg-zinc-100" />}>
277
+ <EChart option={option} />
278
+ </FancyClientOnly>
279
+ </FancyAppRoot>
280
+ ```
281
+
247
282
  ## Documentation
248
283
 
249
284
  Full component documentation is available in the [docs/](docs/) folder:
@@ -253,6 +288,7 @@ Full component documentation is available in the [docs/](docs/) folder:
253
288
  | [EChart](docs/EChart.md) | Base chart component + all 20 series sub-components |
254
289
  | [EChart3D](docs/EChart3D.md) | 3D charts (Bar, Scatter, Line, Surface, Globe) |
255
290
  | [EChartGraphic](docs/EChartGraphic.md) | Custom drawing with the graphic API |
291
+ | [Diagram](docs/Diagram.md) | Diagram engine + DataDiagram, Flowchart, Mindmap, OrgChart presets |
256
292
  | [useECharts](docs/useECharts.md) | Core hook for custom integrations |
257
293
  | [Registration](docs/registration.md) | Tree shaking and selective chart registration |
258
294
  | [Themes](docs/themes.md) | Built-in themes and custom theme creation |
@@ -0,0 +1,277 @@
1
+ // src/components/Diagram/diagram.serializers.ts
2
+ function serializeToERD(schema) {
3
+ const lines = [];
4
+ for (const entity of schema.entities) {
5
+ lines.push(`[${entity.name}]`);
6
+ if (entity.fields) {
7
+ for (const field of entity.fields) {
8
+ const parts = [` ${field.name}`];
9
+ if (field.type) parts.push(field.type);
10
+ if (field.primary) parts.push("PK");
11
+ if (field.foreign) parts.push("FK");
12
+ if (field.nullable) parts.push("?");
13
+ lines.push(parts.join(" "));
14
+ }
15
+ }
16
+ lines.push("");
17
+ }
18
+ for (const rel of schema.relations) {
19
+ const fromEntity = schema.entities.find((e) => e.id === rel.from);
20
+ const toEntity = schema.entities.find((e) => e.id === rel.to);
21
+ if (!fromEntity || !toEntity) continue;
22
+ const marker = getERDMarker(rel.type);
23
+ const parts = [fromEntity.name, marker, toEntity.name];
24
+ if (rel.label) parts.push(`: ${rel.label}`);
25
+ lines.push(parts.join(" "));
26
+ }
27
+ return lines.join("\n").trim();
28
+ }
29
+ function getERDMarker(type) {
30
+ switch (type) {
31
+ case "one-to-one":
32
+ return "1--1";
33
+ case "one-to-many":
34
+ return "1--*";
35
+ case "many-to-many":
36
+ return "*--*";
37
+ default:
38
+ return "--";
39
+ }
40
+ }
41
+ function serializeToUML(schema) {
42
+ const lines = ["@startuml"];
43
+ for (const entity of schema.entities) {
44
+ lines.push(`class ${entity.name} {`);
45
+ if (entity.fields) {
46
+ for (const field of entity.fields) {
47
+ const typeStr = field.type ?? "any";
48
+ const nullable = field.nullable ? "?" : "";
49
+ const stereotype = field.primary ? " <<PK>>" : field.foreign ? " <<FK>>" : "";
50
+ lines.push(` ${field.name} : ${typeStr}${nullable}${stereotype}`);
51
+ }
52
+ }
53
+ lines.push("}");
54
+ lines.push("");
55
+ }
56
+ for (const rel of schema.relations) {
57
+ const fromEntity = schema.entities.find((e) => e.id === rel.from);
58
+ const toEntity = schema.entities.find((e) => e.id === rel.to);
59
+ if (!fromEntity || !toEntity) continue;
60
+ const arrow = getUMLArrow(rel.type);
61
+ const label = rel.label ? ` : ${rel.label}` : "";
62
+ lines.push(`${fromEntity.name} ${arrow} ${toEntity.name}${label}`);
63
+ }
64
+ lines.push("@enduml");
65
+ return lines.join("\n");
66
+ }
67
+ function getUMLArrow(type) {
68
+ switch (type) {
69
+ case "one-to-one":
70
+ return '"1" -- "1"';
71
+ case "one-to-many":
72
+ return '"1" -- "*"';
73
+ case "many-to-many":
74
+ return '"*" -- "*"';
75
+ default:
76
+ return "--";
77
+ }
78
+ }
79
+ function serializeToDFD(schema) {
80
+ const lines = [];
81
+ for (const entity of schema.entities) {
82
+ lines.push(`entity ${entity.name}`);
83
+ }
84
+ lines.push("");
85
+ for (const rel of schema.relations) {
86
+ const fromEntity = schema.entities.find((e) => e.id === rel.from);
87
+ const toEntity = schema.entities.find((e) => e.id === rel.to);
88
+ if (!fromEntity || !toEntity) continue;
89
+ const label = rel.label ? ` "${rel.label}"` : "";
90
+ lines.push(`${fromEntity.name} -> ${toEntity.name}${label}`);
91
+ }
92
+ return lines.join("\n").trim();
93
+ }
94
+ function deserializeSchema(input, format) {
95
+ switch (format) {
96
+ case "erd":
97
+ return deserializeERD(input);
98
+ case "uml":
99
+ return deserializeUML(input);
100
+ case "dfd":
101
+ return deserializeDFD(input);
102
+ }
103
+ }
104
+ function deserializeERD(input) {
105
+ const entities = [];
106
+ const relations = [];
107
+ const lines = input.split("\n");
108
+ let currentEntity = null;
109
+ for (const rawLine of lines) {
110
+ const line = rawLine.trim();
111
+ const entityMatch = line.match(/^\[(.+)\]$/);
112
+ if (entityMatch) {
113
+ currentEntity = {
114
+ id: entityMatch[1].toLowerCase().replace(/\s+/g, "_"),
115
+ name: entityMatch[1],
116
+ fields: []
117
+ };
118
+ entities.push(currentEntity);
119
+ continue;
120
+ }
121
+ if (currentEntity && rawLine.startsWith(" ") && line.length > 0) {
122
+ const parts = line.split(/\s+/);
123
+ const field = { name: parts[0] };
124
+ if (parts.length > 1 && !["PK", "FK", "?"].includes(parts[1])) {
125
+ field.type = parts[1];
126
+ }
127
+ if (parts.includes("PK")) field.primary = true;
128
+ if (parts.includes("FK")) field.foreign = true;
129
+ if (parts.includes("?")) field.nullable = true;
130
+ currentEntity.fields.push(field);
131
+ continue;
132
+ }
133
+ const relMatch = line.match(
134
+ /^(\S+)\s+(1--1|1--\*|\*--\*)\s+(\S+)(?:\s*:\s*(.+))?$/
135
+ );
136
+ if (relMatch) {
137
+ currentEntity = null;
138
+ const fromName = relMatch[1];
139
+ const marker = relMatch[2];
140
+ const toName = relMatch[3];
141
+ const label = relMatch[4];
142
+ const fromEntity = entities.find((e) => e.name === fromName);
143
+ const toEntity = entities.find((e) => e.name === toName);
144
+ if (fromEntity && toEntity) {
145
+ relations.push({
146
+ id: `${fromEntity.id ?? fromEntity.name}_${toEntity.id ?? toEntity.name}`,
147
+ from: fromEntity.id ?? fromEntity.name,
148
+ to: toEntity.id ?? toEntity.name,
149
+ type: parseERDMarker(marker),
150
+ label
151
+ });
152
+ }
153
+ continue;
154
+ }
155
+ if (line === "") {
156
+ currentEntity = null;
157
+ }
158
+ }
159
+ return { entities, relations };
160
+ }
161
+ function parseERDMarker(marker) {
162
+ switch (marker) {
163
+ case "1--1":
164
+ return "one-to-one";
165
+ case "1--*":
166
+ return "one-to-many";
167
+ case "*--*":
168
+ return "many-to-many";
169
+ default:
170
+ return "one-to-many";
171
+ }
172
+ }
173
+ function deserializeUML(input) {
174
+ const entities = [];
175
+ const relations = [];
176
+ const lines = input.split("\n");
177
+ let currentEntity = null;
178
+ for (const rawLine of lines) {
179
+ const line = rawLine.trim();
180
+ if (line === "@startuml" || line === "@enduml" || line === "") continue;
181
+ const classMatch = line.match(/^class\s+(\S+)\s*\{$/);
182
+ if (classMatch) {
183
+ currentEntity = {
184
+ id: classMatch[1].toLowerCase().replace(/\s+/g, "_"),
185
+ name: classMatch[1],
186
+ fields: []
187
+ };
188
+ entities.push(currentEntity);
189
+ continue;
190
+ }
191
+ if (line === "}") {
192
+ currentEntity = null;
193
+ continue;
194
+ }
195
+ if (currentEntity) {
196
+ const fieldMatch = line.match(
197
+ /^(\S+)\s*:\s*(\S+?)(\?)?(?:\s*<<(PK|FK)>>)?$/
198
+ );
199
+ if (fieldMatch) {
200
+ const field = {
201
+ name: fieldMatch[1],
202
+ type: fieldMatch[2]
203
+ };
204
+ if (fieldMatch[3]) field.nullable = true;
205
+ if (fieldMatch[4] === "PK") field.primary = true;
206
+ if (fieldMatch[4] === "FK") field.foreign = true;
207
+ currentEntity.fields.push(field);
208
+ }
209
+ continue;
210
+ }
211
+ const relMatch = line.match(
212
+ /^(\S+)\s+"([1*])"\s+--\s+"([1*])"\s+(\S+)(?:\s*:\s*(.+))?$/
213
+ );
214
+ if (relMatch) {
215
+ const fromName = relMatch[1];
216
+ const fromCard = relMatch[2];
217
+ const toCard = relMatch[3];
218
+ const toName = relMatch[4];
219
+ const label = relMatch[5];
220
+ const fromEntity = entities.find((e) => e.name === fromName);
221
+ const toEntity = entities.find((e) => e.name === toName);
222
+ if (fromEntity && toEntity) {
223
+ const type = fromCard === "1" && toCard === "1" ? "one-to-one" : fromCard === "1" && toCard === "*" ? "one-to-many" : "many-to-many";
224
+ relations.push({
225
+ id: `${fromEntity.id ?? fromEntity.name}_${toEntity.id ?? toEntity.name}`,
226
+ from: fromEntity.id ?? fromEntity.name,
227
+ to: toEntity.id ?? toEntity.name,
228
+ type,
229
+ label
230
+ });
231
+ }
232
+ }
233
+ }
234
+ return { entities, relations };
235
+ }
236
+ function deserializeDFD(input) {
237
+ const entities = [];
238
+ const relations = [];
239
+ const lines = input.split("\n");
240
+ for (const rawLine of lines) {
241
+ const line = rawLine.trim();
242
+ if (line === "") continue;
243
+ const entityMatch = line.match(/^entity\s+(\S+)$/);
244
+ if (entityMatch) {
245
+ entities.push({
246
+ id: entityMatch[1].toLowerCase().replace(/\s+/g, "_"),
247
+ name: entityMatch[1],
248
+ fields: []
249
+ });
250
+ continue;
251
+ }
252
+ const flowMatch = line.match(
253
+ /^(\S+)\s+->\s+(\S+)(?:\s+"(.+)")?$/
254
+ );
255
+ if (flowMatch) {
256
+ const fromName = flowMatch[1];
257
+ const toName = flowMatch[2];
258
+ const label = flowMatch[3];
259
+ const fromEntity = entities.find((e) => e.name === fromName);
260
+ const toEntity = entities.find((e) => e.name === toName);
261
+ if (fromEntity && toEntity) {
262
+ relations.push({
263
+ id: `${fromEntity.id ?? fromEntity.name}_${toEntity.id ?? toEntity.name}`,
264
+ from: fromEntity.id ?? fromEntity.name,
265
+ to: toEntity.id ?? toEntity.name,
266
+ type: "one-to-many",
267
+ label
268
+ });
269
+ }
270
+ }
271
+ }
272
+ return { entities, relations };
273
+ }
274
+
275
+ export { deserializeSchema, serializeToDFD, serializeToERD, serializeToUML };
276
+ //# sourceMappingURL=diagram.serializers-DSYRR3LI.js.map
277
+ //# sourceMappingURL=diagram.serializers-DSYRR3LI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Diagram/diagram.serializers.ts"],"names":[],"mappings":";AAyBO,SAAS,eAAe,MAAA,EAA+B;AAC5D,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,KAAA,MAAW,MAAA,IAAU,OAAO,QAAA,EAAU;AACpC,IAAA,KAAA,CAAM,IAAA,CAAK,CAAA,CAAA,EAAI,MAAA,CAAO,IAAI,CAAA,CAAA,CAAG,CAAA;AAC7B,IAAA,IAAI,OAAO,MAAA,EAAQ;AACjB,MAAA,KAAA,MAAW,KAAA,IAAS,OAAO,MAAA,EAAQ;AACjC,QAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,EAAA,EAAK,KAAA,CAAM,IAAI,CAAA,CAAE,CAAA;AAChC,QAAA,IAAI,KAAA,CAAM,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,MAAM,IAAI,CAAA;AACrC,QAAA,IAAI,KAAA,CAAM,OAAA,EAAS,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAClC,QAAA,IAAI,KAAA,CAAM,OAAA,EAAS,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAClC,QAAA,IAAI,KAAA,CAAM,QAAA,EAAU,KAAA,CAAM,IAAA,CAAK,GAAG,CAAA;AAClC,QAAA,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,MAC5B;AAAA,IACF;AACA,IAAA,KAAA,CAAM,KAAK,EAAE,CAAA;AAAA,EACf;AAEA,EAAA,KAAA,MAAW,GAAA,IAAO,OAAO,SAAA,EAAW;AAClC,IAAA,MAAM,UAAA,GAAa,OAAO,QAAA,CAAS,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,EAAA,KAAO,GAAA,CAAI,IAAI,CAA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A,QACnB,QAAQ;AAAC,OACV,CAAA;AACD,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,YAAY,IAAA,CAAK,KAAA;AAAA,MACrB;AAAA,KACF;AACA,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,MAAM,QAAA,GAAW,UAAU,CAAC,CAAA;AAC5B,MAAA,MAAM,MAAA,GAAS,UAAU,CAAC,CAAA;AAC1B,MAAA,MAAM,KAAA,GAAQ,UAAU,CAAC,CAAA;AAEzB,MAAA,MAAM,aAAa,QAAA,CAAS,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,QAAQ,CAAA;AAC3D,MAAA,MAAM,WAAW,QAAA,CAAS,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,MAAM,CAAA;AACvD,MAAA,IAAI,cAAc,QAAA,EAAU;AAC1B,QAAA,SAAA,CAAU,IAAA,CAAK;AAAA,UACb,EAAA,EAAI,CAAA,EAAG,UAAA,CAAW,EAAA,IAAM,UAAA,CAAW,IAAI,CAAA,CAAA,EAAI,QAAA,CAAS,EAAA,IAAM,QAAA,CAAS,IAAI,CAAA,CAAA;AAAA,UACvE,IAAA,EAAM,UAAA,CAAW,EAAA,IAAM,UAAA,CAAW,IAAA;AAAA,UAClC,EAAA,EAAI,QAAA,CAAS,EAAA,IAAM,QAAA,CAAS,IAAA;AAAA,UAC5B,IAAA,EAAM,aAAA;AAAA,UACN;AAAA,SACD,CAAA;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,UAAU,SAAA,EAAU;AAC/B","file":"diagram.serializers-DSYRR3LI.js","sourcesContent":["import type {\n DiagramSchema,\n DiagramEntityData,\n DiagramRelationData,\n DiagramFieldData,\n ExportFormat,\n RelationType,\n} from \"./Diagram.types\";\n\n/**\n * Serialize a diagram schema to PlantUML-style ERD text.\n *\n * Example output:\n * ```\n * [Users]\n * id int PK\n * email varchar\n *\n * [Posts]\n * id int PK\n * user_id int FK\n *\n * Users 1--* Posts\n * ```\n */\nexport function serializeToERD(schema: DiagramSchema): string {\n const lines: string[] = [];\n\n for (const entity of schema.entities) {\n lines.push(`[${entity.name}]`);\n if (entity.fields) {\n for (const field of entity.fields) {\n const parts = [` ${field.name}`];\n if (field.type) parts.push(field.type);\n if (field.primary) parts.push(\"PK\");\n if (field.foreign) parts.push(\"FK\");\n if (field.nullable) parts.push(\"?\");\n lines.push(parts.join(\" \"));\n }\n }\n lines.push(\"\");\n }\n\n for (const rel of schema.relations) {\n const fromEntity = schema.entities.find((e) => e.id === rel.from);\n const toEntity = schema.entities.find((e) => e.id === rel.to);\n if (!fromEntity || !toEntity) continue;\n\n const marker = getERDMarker(rel.type);\n const parts = [fromEntity.name, marker, toEntity.name];\n if (rel.label) parts.push(`: ${rel.label}`);\n lines.push(parts.join(\" \"));\n }\n\n return lines.join(\"\\n\").trim();\n}\n\nfunction getERDMarker(type: RelationType): string {\n switch (type) {\n case \"one-to-one\":\n return \"1--1\";\n case \"one-to-many\":\n return \"1--*\";\n case \"many-to-many\":\n return \"*--*\";\n default:\n return \"--\";\n }\n}\n\n/**\n * Serialize a diagram schema to PlantUML class diagram text.\n */\nexport function serializeToUML(schema: DiagramSchema): string {\n const lines: string[] = [\"@startuml\"];\n\n for (const entity of schema.entities) {\n lines.push(`class ${entity.name} {`);\n if (entity.fields) {\n for (const field of entity.fields) {\n const typeStr = field.type ?? \"any\";\n const nullable = field.nullable ? \"?\" : \"\";\n const stereotype = field.primary\n ? \" <<PK>>\"\n : field.foreign\n ? \" <<FK>>\"\n : \"\";\n lines.push(` ${field.name} : ${typeStr}${nullable}${stereotype}`);\n }\n }\n lines.push(\"}\");\n lines.push(\"\");\n }\n\n for (const rel of schema.relations) {\n const fromEntity = schema.entities.find((e) => e.id === rel.from);\n const toEntity = schema.entities.find((e) => e.id === rel.to);\n if (!fromEntity || !toEntity) continue;\n\n const arrow = getUMLArrow(rel.type);\n const label = rel.label ? ` : ${rel.label}` : \"\";\n lines.push(`${fromEntity.name} ${arrow} ${toEntity.name}${label}`);\n }\n\n lines.push(\"@enduml\");\n return lines.join(\"\\n\");\n}\n\nfunction getUMLArrow(type: RelationType): string {\n switch (type) {\n case \"one-to-one\":\n return '\"1\" -- \"1\"';\n case \"one-to-many\":\n return '\"1\" -- \"*\"';\n case \"many-to-many\":\n return '\"*\" -- \"*\"';\n default:\n return \"--\";\n }\n}\n\n/**\n * Serialize a diagram schema to a simple DFD text format.\n */\nexport function serializeToDFD(schema: DiagramSchema): string {\n const lines: string[] = [];\n\n for (const entity of schema.entities) {\n lines.push(`entity ${entity.name}`);\n }\n\n lines.push(\"\");\n\n for (const rel of schema.relations) {\n const fromEntity = schema.entities.find((e) => e.id === rel.from);\n const toEntity = schema.entities.find((e) => e.id === rel.to);\n if (!fromEntity || !toEntity) continue;\n\n const label = rel.label ? ` \"${rel.label}\"` : \"\";\n lines.push(`${fromEntity.name} -> ${toEntity.name}${label}`);\n }\n\n return lines.join(\"\\n\").trim();\n}\n\n/**\n * Parse a serialized schema string back into a DiagramSchema.\n */\nexport function deserializeSchema(\n input: string,\n format: ExportFormat,\n): DiagramSchema {\n switch (format) {\n case \"erd\":\n return deserializeERD(input);\n case \"uml\":\n return deserializeUML(input);\n case \"dfd\":\n return deserializeDFD(input);\n }\n}\n\nfunction deserializeERD(input: string): DiagramSchema {\n const entities: DiagramEntityData[] = [];\n const relations: DiagramRelationData[] = [];\n const lines = input.split(\"\\n\");\n\n let currentEntity: DiagramEntityData | null = null;\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n\n // Entity header: [EntityName]\n const entityMatch = line.match(/^\\[(.+)\\]$/);\n if (entityMatch) {\n currentEntity = {\n id: entityMatch[1].toLowerCase().replace(/\\s+/g, \"_\"),\n name: entityMatch[1],\n fields: [],\n };\n entities.push(currentEntity);\n continue;\n }\n\n // Field line (indented): name type PK FK ?\n if (currentEntity && rawLine.startsWith(\" \") && line.length > 0) {\n const parts = line.split(/\\s+/);\n const field: DiagramFieldData = { name: parts[0] };\n if (parts.length > 1 && ![\"PK\", \"FK\", \"?\"].includes(parts[1])) {\n field.type = parts[1];\n }\n if (parts.includes(\"PK\")) field.primary = true;\n if (parts.includes(\"FK\")) field.foreign = true;\n if (parts.includes(\"?\")) field.nullable = true;\n currentEntity.fields!.push(field);\n continue;\n }\n\n // Relation: EntityA 1--* EntityB : label\n const relMatch = line.match(\n /^(\\S+)\\s+(1--1|1--\\*|\\*--\\*)\\s+(\\S+)(?:\\s*:\\s*(.+))?$/,\n );\n if (relMatch) {\n currentEntity = null;\n const fromName = relMatch[1];\n const marker = relMatch[2];\n const toName = relMatch[3];\n const label = relMatch[4];\n\n const fromEntity = entities.find((e) => e.name === fromName);\n const toEntity = entities.find((e) => e.name === toName);\n if (fromEntity && toEntity) {\n relations.push({\n id: `${fromEntity.id ?? fromEntity.name}_${toEntity.id ?? toEntity.name}`,\n from: fromEntity.id ?? fromEntity.name,\n to: toEntity.id ?? toEntity.name,\n type: parseERDMarker(marker),\n label,\n });\n }\n continue;\n }\n\n // Empty line resets current entity context\n if (line === \"\") {\n currentEntity = null;\n }\n }\n\n return { entities, relations };\n}\n\nfunction parseERDMarker(marker: string): RelationType {\n switch (marker) {\n case \"1--1\":\n return \"one-to-one\";\n case \"1--*\":\n return \"one-to-many\";\n case \"*--*\":\n return \"many-to-many\";\n default:\n return \"one-to-many\";\n }\n}\n\nfunction deserializeUML(input: string): DiagramSchema {\n const entities: DiagramEntityData[] = [];\n const relations: DiagramRelationData[] = [];\n const lines = input.split(\"\\n\");\n\n let currentEntity: DiagramEntityData | null = null;\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n\n if (line === \"@startuml\" || line === \"@enduml\" || line === \"\") continue;\n\n // Class header: class EntityName {\n const classMatch = line.match(/^class\\s+(\\S+)\\s*\\{$/);\n if (classMatch) {\n currentEntity = {\n id: classMatch[1].toLowerCase().replace(/\\s+/g, \"_\"),\n name: classMatch[1],\n fields: [],\n };\n entities.push(currentEntity);\n continue;\n }\n\n // Closing brace\n if (line === \"}\") {\n currentEntity = null;\n continue;\n }\n\n // Field: name : type<<stereotype>>\n if (currentEntity) {\n const fieldMatch = line.match(\n /^(\\S+)\\s*:\\s*(\\S+?)(\\?)?(?:\\s*<<(PK|FK)>>)?$/,\n );\n if (fieldMatch) {\n const field: DiagramFieldData = {\n name: fieldMatch[1],\n type: fieldMatch[2],\n };\n if (fieldMatch[3]) field.nullable = true;\n if (fieldMatch[4] === \"PK\") field.primary = true;\n if (fieldMatch[4] === \"FK\") field.foreign = true;\n currentEntity.fields!.push(field);\n }\n continue;\n }\n\n // Relation: EntityA \"1\" -- \"*\" EntityB : label\n const relMatch = line.match(\n /^(\\S+)\\s+\"([1*])\"\\s+--\\s+\"([1*])\"\\s+(\\S+)(?:\\s*:\\s*(.+))?$/,\n );\n if (relMatch) {\n const fromName = relMatch[1];\n const fromCard = relMatch[2];\n const toCard = relMatch[3];\n const toName = relMatch[4];\n const label = relMatch[5];\n\n const fromEntity = entities.find((e) => e.name === fromName);\n const toEntity = entities.find((e) => e.name === toName);\n if (fromEntity && toEntity) {\n const type: RelationType =\n fromCard === \"1\" && toCard === \"1\"\n ? \"one-to-one\"\n : fromCard === \"1\" && toCard === \"*\"\n ? \"one-to-many\"\n : \"many-to-many\";\n relations.push({\n id: `${fromEntity.id ?? fromEntity.name}_${toEntity.id ?? toEntity.name}`,\n from: fromEntity.id ?? fromEntity.name,\n to: toEntity.id ?? toEntity.name,\n type,\n label,\n });\n }\n }\n }\n\n return { entities, relations };\n}\n\nfunction deserializeDFD(input: string): DiagramSchema {\n const entities: DiagramEntityData[] = [];\n const relations: DiagramRelationData[] = [];\n const lines = input.split(\"\\n\");\n\n for (const rawLine of lines) {\n const line = rawLine.trim();\n if (line === \"\") continue;\n\n // Entity: entity EntityName\n const entityMatch = line.match(/^entity\\s+(\\S+)$/);\n if (entityMatch) {\n entities.push({\n id: entityMatch[1].toLowerCase().replace(/\\s+/g, \"_\"),\n name: entityMatch[1],\n fields: [],\n });\n continue;\n }\n\n // Flow: EntityA -> EntityB \"label\"\n const flowMatch = line.match(\n /^(\\S+)\\s+->\\s+(\\S+)(?:\\s+\"(.+)\")?$/,\n );\n if (flowMatch) {\n const fromName = flowMatch[1];\n const toName = flowMatch[2];\n const label = flowMatch[3];\n\n const fromEntity = entities.find((e) => e.name === fromName);\n const toEntity = entities.find((e) => e.name === toName);\n if (fromEntity && toEntity) {\n relations.push({\n id: `${fromEntity.id ?? fromEntity.name}_${toEntity.id ?? toEntity.name}`,\n from: fromEntity.id ?? fromEntity.name,\n to: toEntity.id ?? toEntity.name,\n type: \"one-to-many\",\n label,\n });\n }\n }\n }\n\n return { entities, relations };\n}\n"]}