@graphty/graph-io 0.3.45 → 0.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{approximations-DJMHdDvv.js → approximations-wWjCRzKj.js} +2 -2
- package/dist/chunks/{approximations-DJMHdDvv.js.map → approximations-wWjCRzKj.js.map} +1 -1
- package/dist/chunks/{block-CPCHkX42.js → block-DiGq58c3.js} +9 -3
- package/dist/chunks/block-DiGq58c3.js.map +1 -0
- package/dist/chunks/{emit-DZy6JgdA.js → emit-CwU8cUmG.js} +2 -2
- package/dist/chunks/{emit-DZy6JgdA.js.map → emit-CwU8cUmG.js.map} +1 -1
- package/dist/chunks/{exporter-DFqJhBnj.js → exporter-CJgfhF-l.js} +4 -4
- package/dist/chunks/{exporter-DFqJhBnj.js.map → exporter-CJgfhF-l.js.map} +1 -1
- package/dist/chunks/{exporter-C-9cgZKa.js → exporter-CrDWIyiq.js} +4 -4
- package/dist/chunks/{exporter-C-9cgZKa.js.map → exporter-CrDWIyiq.js.map} +1 -1
- package/dist/chunks/{exporter-DteVeJki.js → exporter-DndFlGSa.js} +3 -3
- package/dist/chunks/{exporter-DteVeJki.js.map → exporter-DndFlGSa.js.map} +1 -1
- package/dist/chunks/{generic-BGO71QBv.js → generic-Dq1ntt9q.js} +3 -3
- package/dist/chunks/{generic-BGO71QBv.js.map → generic-Dq1ntt9q.js.map} +1 -1
- package/dist/chunks/{importer-B-9Rc1zO.js → importer-BSvfrX_h.js} +4 -4
- package/dist/chunks/{importer-B-9Rc1zO.js.map → importer-BSvfrX_h.js.map} +1 -1
- package/dist/chunks/{importer-BVVR740x.js → importer-CMmeMWlC.js} +3 -3
- package/dist/chunks/{importer-BVVR740x.js.map → importer-CMmeMWlC.js.map} +1 -1
- package/dist/chunks/{importer-C7pvJe1L.js → importer-COTK9Tsl.js} +5 -5
- package/dist/chunks/{importer-C7pvJe1L.js.map → importer-COTK9Tsl.js.map} +1 -1
- package/dist/chunks/{importer-ClwoVx3O.js → importer-DiZRmOQG.js} +4 -4
- package/dist/chunks/{importer-ClwoVx3O.js.map → importer-DiZRmOQG.js.map} +1 -1
- package/dist/chunks/{importer-EHQk1jbM.js → importer-e6LGpqHB.js} +5 -5
- package/dist/chunks/importer-e6LGpqHB.js.map +1 -0
- package/dist/chunks/{importer-C0AjA3Ax.js → importer-iFYPEKaJ.js} +4 -4
- package/dist/chunks/{importer-C0AjA3Ax.js.map → importer-iFYPEKaJ.js.map} +1 -1
- package/dist/chunks/{importer-D0sC_6bO.js → importer-yh_aBCU6.js} +2 -2
- package/dist/chunks/{importer-D0sC_6bO.js.map → importer-yh_aBCU6.js.map} +1 -1
- package/dist/chunks/{lexicon-WMsNddyU.js → lexicon-CT69Kd87.js} +2 -2
- package/dist/chunks/{lexicon-WMsNddyU.js.map → lexicon-CT69Kd87.js.map} +1 -1
- package/dist/chunks/{styles-zNTmz5R7.js → styles-BQnsga7p.js} +3 -3
- package/dist/chunks/{styles-zNTmz5R7.js.map → styles-BQnsga7p.js.map} +1 -1
- package/dist/chunks/{styles-DvoFBKCK.js → styles-D3fRphrO.js} +3 -3
- package/dist/chunks/{styles-DvoFBKCK.js.map → styles-D3fRphrO.js.map} +1 -1
- package/dist/chunks/{styles-yed-Cz9rLBCP.js → styles-yed-BF5x3_Y5.js} +3 -3
- package/dist/chunks/{styles-yed-Cz9rLBCP.js.map → styles-yed-BF5x3_Y5.js.map} +1 -1
- package/dist/chunks/{writer-gQ8kx99H.js → writer-DMKvthQE.js} +2 -2
- package/dist/chunks/{writer-gQ8kx99H.js.map → writer-DMKvthQE.js.map} +1 -1
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +2 -2
- package/dist/gexf.js +2 -2
- package/dist/gml.js +6 -6
- package/dist/graph-io.js +23 -23
- package/dist/graphml.js +2 -2
- package/dist/json.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/formats/pajek/styles.d.ts +1 -1
- package/dist/src/formats/pajek/styles.d.ts.map +1 -1
- package/dist/src/formats/pajek/styles.js +4 -3
- package/dist/src/formats/pajek/styles.js.map +1 -1
- package/dist/src/styles/canon/color-tables.d.ts +2 -1
- package/dist/src/styles/canon/color-tables.d.ts.map +1 -1
- package/dist/src/styles/canon/color-tables.js +7 -2
- package/dist/src/styles/canon/color-tables.js.map +1 -1
- package/dist/src/styles/defaults.d.ts.map +1 -1
- package/dist/src/styles/defaults.js +7 -0
- package/dist/src/styles/defaults.js.map +1 -1
- package/dist/styles.js +6 -6
- package/dist/xgmml.js +3 -3
- package/package.json +2 -2
- package/src/formats/pajek/styles.ts +4 -3
- package/src/styles/canon/color-tables.ts +7 -2
- package/src/styles/defaults.ts +8 -0
- package/dist/chunks/block-CPCHkX42.js.map +0 -1
- package/dist/chunks/importer-EHQk1jbM.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles-yed-Cz9rLBCP.js","sources":["../../src/styles/canon/bends.ts","../../src/formats/graphml/styles-yed.ts"],"sourcesContent":["/**\n * The neutral `bends` value of an edge: the points its route passes through between its two nodes, each relative to\n * the straight line from the source node's center to the target node's center. `along` is how far along that line\n * the point lies (0 at the source center, 1 at the target center) and `across` how far to its left, y up, both as\n * fractions of the line's length. Written `along,across` per point, in order from the source, separated by spaces:\n * `\"0,-0.5 1,-0.5\"` is a route that leaves the source, runs parallel to the line half its length to the right, and\n * comes back to the target. Relative, so a drawing that moves or scales the nodes keeps the route's shape and its\n * right angles.\n */\n\n/** A point in the file's own coordinates. */\nexport type BendPoint = readonly [x: number, y: number];\n\n/**\n * Rounds a fraction to 4 decimals, so a value spells the same whatever float noise the file's numbers carry.\n * @param v - the fraction\n * @returns its spelling\n */\nconst fraction = (v: number): string => String(Math.round(v * 1e4) / 1e4);\n\n/**\n * The `bends` value of an edge whose route passes through `points`.\n * @param source - the source node's center\n * @param target - the target node's center\n * @param points - the bend points, from the source end\n * @param yDown - true when the file's y axis points down (the value is always y up)\n * @returns the value, or null with no bends, no line between distinct centers, or a coordinate that is not finite\n * @category Styles\n */\nexport function canonBends(\n source: BendPoint,\n target: BendPoint,\n points: readonly BendPoint[],\n yDown: boolean,\n): string | null {\n const flip = yDown ? -1 : 1;\n const dx = target[0] - source[0];\n const dy = (target[1] - source[1]) * flip;\n const length2 = dx * dx + dy * dy;\n if (points.length === 0 || length2 <= 0 || !Number.isFinite(length2)) {\n return null;\n }\n const out: string[] = [];\n for (const [px, py] of points) {\n const rx = px - source[0];\n const ry = (py - source[1]) * flip;\n const along = (rx * dx + ry * dy) / length2;\n const across = (dx * ry - dy * rx) / length2;\n if (!Number.isFinite(along) || !Number.isFinite(across)) {\n return null;\n }\n out.push(`${fraction(along)},${fraction(across)}`);\n }\n return out.join(\" \");\n}\n\n/**\n * The bend points a `bends` value places between two node centers: the inverse of {@link canonBends}.\n * @param source - the source node's center\n * @param target - the target node's center\n * @param value - the `bends` value\n * @param yDown - true when the points are wanted in a y-down file's coordinates\n * @returns the points, or null when the value is not `along,across` pairs or a coordinate is not finite\n * @category Styles\n */\nexport function bendsToPoints(source: BendPoint, target: BendPoint, value: string, yDown: boolean): BendPoint[] | null {\n const flip = yDown ? -1 : 1;\n const dx = target[0] - source[0];\n const dy = (target[1] - source[1]) * flip;\n const out: BendPoint[] = [];\n for (const pair of value.trim().split(/\\s+/)) {\n const [a, c, extra] = pair.split(\",\").map(Number);\n if (extra !== undefined || !Number.isFinite(a) || !Number.isFinite(c)) {\n return null;\n }\n const x = source[0] + a * dx - c * dy;\n const y = source[1] + (a * dy + c * dx) * flip;\n if (!Number.isFinite(x) || !Number.isFinite(y)) {\n return null;\n }\n out.push([x, y]);\n }\n return out.length === 0 ? null : out;\n}\n","/**\n * yEd styles (yFiles for Java 2.x GraphML): reading every realizer a yEd graphics tree holds (`y:ShapeNode`,\n * `y:GenericNode`, `y:GroupNode`, `y:SVGNode`, `y:PolyLineEdge`, `y:BezierEdge`, ...) into the neutral style\n * vocabulary, and writing a graph's styles back as `y:ShapeNode` and `y:PolyLineEdge` graphics. The trees are the\n * json columns the GraphML importer keeps (tree.ts), never the typed `yfiles.*` columns read from them.\n *\n * The tree helpers here are shared with the yFiles 3 reader.\n */\n\nimport type { GraphSnapshot } from \"@graphty/graph-format\";\n\nimport { toFilePositions, toNeutral } from \"../../positions/convert.js\";\nimport type { PositionColumnExtra } from \"../../positions/types.js\";\nimport { type BendPoint, bendsToPoints, canonBends } from \"../../styles/canon/bends.js\";\nimport { canonColor, colorOpacity } from \"../../styles/canon/color.js\";\nimport { canonEnum } from \"../../styles/canon/enums.js\";\nimport { canonNumber } from \"../../styles/canon/number.js\";\nimport { type CanonSite, MAX_STYLE_VALUE_LENGTH, noteAt } from \"../../styles/canon/site.js\";\nimport { canonText } from \"../../styles/canon/text.js\";\nimport { STYLE_ISSUE } from \"../../styles/codes.js\";\nimport { StyleApproximations } from \"../../styles/io/approximations.js\";\nimport type { ExporterStyleInput } from \"../../styles/io/writer.js\";\nimport type { StyleNotes } from \"../../styles/notes.js\";\nimport { plainCell } from \"../../styles/plan/resolve.js\";\nimport type { StyleTarget, StyleValue, StyleWorkBudget, StyleWriteCapabilities } from \"../../styles/types.js\";\nimport type { LossNote } from \"../../types.js\";\n\n// ============================================================ the kept trees\n\n/** A tree object as tree.ts builds it: `@_<name>` attributes, `#text`, and child elements by name. */\ntype Tree = Record<string, unknown>;\n\n/**\n * Whether a value is a tree object.\n * @param value - the value\n * @returns true for a non-array object\n */\nexport function isTree(value: unknown): value is Tree {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The local part of an element name: `y:ShapeNode` is `ShapeNode`, whatever the prefix.\n * @param name - the name as written\n * @returns the local name\n */\nexport function localOf(name: string): string {\n const colon = name.indexOf(\":\");\n return colon < 0 ? name : name.slice(colon + 1);\n}\n\n/**\n * The child elements of a tree node with a local name, in file order.\n * @param node - the tree node\n * @param local - the local name\n * @returns the children\n */\nexport function treeChildren(node: unknown, local: string): unknown[] {\n const out: unknown[] = [];\n if (!isTree(node)) {\n return out;\n }\n for (const key of Object.keys(node)) {\n if (key.startsWith(\"@_\") || key === \"#text\" || localOf(key) !== local) {\n continue;\n }\n const value = node[key];\n if (Array.isArray(value)) {\n for (const item of value) {\n out.push(item);\n }\n } else {\n out.push(value);\n }\n }\n return out;\n}\n\n/**\n * The first child element of a tree node with a local name.\n * @param node - the tree node\n * @param local - the local name\n * @returns the child, or undefined\n */\nexport function treeChild(node: unknown, local: string): unknown {\n if (!isTree(node)) {\n return undefined;\n }\n for (const key of Object.keys(node)) {\n if (!key.startsWith(\"@_\") && key !== \"#text\" && localOf(key) === local) {\n const value = node[key];\n return Array.isArray(value) ? value[0] : value;\n }\n }\n return undefined;\n}\n\n/**\n * An attribute of a tree node.\n * @param node - the tree node\n * @param name - the attribute name as written\n * @returns its text, or undefined\n */\nexport function treeAttr(node: unknown, name: string): string | undefined {\n if (!isTree(node) || !Object.hasOwn(node, `@_${name}`)) {\n return undefined;\n }\n const value = node[`@_${name}`];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * The text of an element: the element itself when it has neither attributes nor children, else its `#text`.\n * @param node - the tree node\n * @returns the text, or null\n */\nexport function treeText(node: unknown): string | null {\n if (typeof node === \"string\") {\n return node;\n }\n if (isTree(node) && Object.hasOwn(node, \"#text\")) {\n const text = node[\"#text\"];\n return typeof text === \"string\" ? text : null;\n }\n return null;\n}\n\n/**\n * The json columns of a table holding yFiles trees.\n * @param table - the node, edge or graph table\n * @returns their names\n */\nfunction treeColumns(table: GraphSnapshot[\"nodes\"]): string[] {\n const out: string[] = [];\n for (const col of table) {\n if (col.dtype === \"json\" && col.meta.origin?.namespace === \"yfiles\") {\n out.push(col.meta.name);\n }\n }\n return out;\n}\n\n/**\n * Every column of a table the GraphML importer made from yFiles keys: the trees and the typed `yfiles.*` columns\n * read from them. They hold the styles themselves, so the planner never explains a style with them.\n * @param table - the node or edge table\n * @returns their names\n */\nexport function yfilesColumns(table: GraphSnapshot[\"nodes\"]): string[] {\n const out: string[] = [];\n for (const col of table) {\n if (col.meta.origin?.namespace === \"yfiles\") {\n out.push(col.meta.name);\n }\n }\n return out;\n}\n\n// ============================================================ reading\n\n/** One element's canonical value of a property; null leaves it unset. */\nexport type PutValue = (property: string, value: StyleValue | null) => void;\n\n/** Where a value of an element was read, by property. */\nexport type SiteOf = (property: string) => CanonSite;\n\n/** The yEd node realizers, by local name. */\nconst NODE_REALIZERS: ReadonlySet<string> = new Set([\n \"ShapeNode\",\n \"GenericNode\",\n \"GroupNode\",\n \"GenericGroupNode\",\n \"SVGNode\",\n \"ImageNode\",\n \"TableNode\",\n \"UMLClassNode\",\n \"UMLNoteNode\",\n \"ProxyAutoBoundsNode\",\n]);\n\n/** The yEd edge realizers, by local name. */\nconst EDGE_REALIZERS: ReadonlySet<string> = new Set([\n \"PolyLineEdge\",\n \"ArcEdge\",\n \"BezierEdge\",\n \"QuadCurveEdge\",\n \"SplineEdge\",\n \"GenericEdge\",\n]);\n\n/** A realizer: its local name and its element. */\ninterface Realizer {\n readonly type: string;\n readonly r: unknown;\n}\n\n/**\n * The realizer a graphics tree holds; a `y:ProxyAutoBoundsNode` (a folder or group) gives its active realizer.\n * @param tree - the `<data>` content\n * @param names - the realizer names of the target\n * @returns the realizer, or null\n */\nfunction realizerOf(tree: unknown, names: ReadonlySet<string>): Realizer | null {\n if (!isTree(tree)) {\n return null;\n }\n for (const key of Object.keys(tree)) {\n const type = localOf(key);\n if (key.startsWith(\"@_\") || !names.has(type)) {\n continue;\n }\n const value = tree[key];\n const r = Array.isArray(value) ? value[0] : value;\n return type === \"ProxyAutoBoundsNode\" ? activeRealizer(r) : { type, r };\n }\n return null;\n}\n\n/**\n * The active realizer of a `y:ProxyAutoBoundsNode`, else its first.\n * @param proxy - the proxy element\n * @returns the realizer, or null when it has none\n */\nfunction activeRealizer(proxy: unknown): Realizer | null {\n const realizers = treeChild(proxy, \"Realizers\");\n const all: Realizer[] = [];\n if (isTree(realizers)) {\n for (const k of Object.keys(realizers).filter((key) => !key.startsWith(\"@_\") && key !== \"#text\")) {\n for (const item of treeChildren(realizers, localOf(k))) {\n all.push({ type: localOf(k), r: item });\n }\n }\n }\n const active = Number(treeAttr(realizers, \"active\") ?? \"0\");\n return all[Number.isInteger(active) && active >= 0 && active < all.length ? active : 0] ?? null;\n}\n\n/**\n * yEd's flowchart palette (`com.yworks.flowchart.<name>`), by name, to the shape each draws. Matched whole, before\n * the words below: \"data\" is a parallelogram, but \"storedData\" and \"directData\" are not.\n */\nconst FLOWCHART_SHAPES: ReadonlyMap<string, string> = new Map([\n [\"process\", \"rectangle\"],\n [\"decision\", \"diamond\"],\n [\"terminator\", \"round-rectangle\"],\n [\"start1\", \"ellipse\"],\n [\"start2\", \"ellipse\"],\n [\"data\", \"parallelogram\"],\n [\"preparation\", \"hexagon\"],\n]);\n\nconst FLOWCHART_PREFIX = \"com.yworks.flowchart.\";\n\n/**\n * The shape a yEd flowchart configuration draws: a GraphML GenericNode's `configuration`, or a yEd GML node's\n * `customconfiguration`.\n * @param configuration - the configuration\n * @returns the neutral shape, or null for a configuration that is not one of the flowchart shapes known here\n */\nexport function flowchartShape(configuration: string): string | null {\n return configuration.startsWith(FLOWCHART_PREFIX)\n ? (FLOWCHART_SHAPES.get(configuration.slice(FLOWCHART_PREFIX.length)) ?? null)\n : null;\n}\n\n/** GenericNode configurations, by a word they contain, to the shape they draw; the first match wins. */\nconst GENERIC_SHAPES: readonly (readonly [string, string])[] = [\n [\"ellipse\", \"ellipse\"],\n [\"circle\", \"ellipse\"],\n [\"oval\", \"ellipse\"],\n [\"diamond\", \"diamond\"],\n [\"decision\", \"diamond\"],\n [\"hexagon\", \"hexagon\"],\n [\"octagon\", \"octagon\"],\n [\"triangle\", \"triangle\"],\n [\"rect\", \"rectangle\"],\n [\"process\", \"rectangle\"],\n [\"box\", \"rectangle\"],\n];\n\n/** yEd's label positions (`modelPosition` of the internal, sides and eight-position models). */\nconst YED_POSITIONS: ReadonlyMap<string, string> = new Map([\n [\"c\", \"center\"],\n [\"t\", \"top\"],\n [\"b\", \"bottom\"],\n [\"l\", \"left\"],\n [\"r\", \"right\"],\n [\"tl\", \"top-left\"],\n [\"tr\", \"top-right\"],\n [\"bl\", \"bottom-left\"],\n [\"br\", \"bottom-right\"],\n [\"n\", \"top\"],\n [\"s\", \"bottom\"],\n [\"e\", \"right\"],\n [\"w\", \"left\"],\n [\"nw\", \"top-left\"],\n [\"ne\", \"top-right\"],\n [\"sw\", \"bottom-left\"],\n [\"se\", \"bottom-right\"],\n]);\n\n/** yEd's font styles, as label weight and italic. */\nexport const FONT_STYLES: ReadonlyMap<string, readonly [string, boolean]> = new Map([\n [\"plain\", [\"normal\", false]],\n [\"bold\", [\"bold\", false]],\n [\"italic\", [\"normal\", true]],\n [\"bolditalic\", [\"bold\", true]],\n]);\n\n/**\n * Reads a color into a property and its alpha into the property's opacity (or notes the alpha dropped).\n * @param raw - the attribute\n * @param property - the color property\n * @param opacity - its opacity property, or null when it has none\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readColor(raw: unknown, property: string, opacity: string | null, put: PutValue, at: SiteOf): void {\n const c = canonColor(raw, \"yed\", at(property));\n if (c === null) {\n return;\n }\n put(property, c.color);\n const alpha = colorOpacity(c, null, at(property), opacity !== null);\n if (opacity !== null) {\n put(opacity, alpha);\n }\n}\n\n/**\n * Reads an element's label: the first visible label with text (yEd icon nodes put an empty, `hasText=\"false\"`\n * label first); further visible labels are noted for the element.\n * @param labels - the label elements, in file order\n * @param node - whether they are node labels (which have a position)\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readLabels(labels: readonly unknown[], node: boolean, put: PutValue, at: SiteOf): void {\n let label: unknown = undefined;\n let text = \"\";\n let extra = 0;\n for (const l of labels) {\n const t = treeText(l)?.trim() ?? \"\";\n if (t.length === 0 || treeAttr(l, \"visible\") === \"false\" || treeAttr(l, \"hasText\") === \"false\") {\n continue;\n }\n if (label === undefined) {\n label = l;\n text = t;\n } else {\n extra++;\n }\n }\n if (label === undefined) {\n return;\n }\n if (extra > 0) {\n noteAt(at(\"label\"), STYLE_ISSUE.EXTRA_LABELS, `${String(extra + 1)} labels`);\n }\n put(\"label\", canonText(text, at(\"label\")));\n readLabelLook(label, node, put, at);\n}\n\n/**\n * Reads a label's look: its color, font and, for a node label, its position.\n * @param label - the label element\n * @param node - whether it is a node label\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readLabelLook(label: unknown, node: boolean, put: PutValue, at: SiteOf): void {\n readColor(treeAttr(label, \"textColor\"), \"labelColor\", null, put, at);\n put(\"labelSize\", canonNumber(treeAttr(label, \"fontSize\"), at(\"labelSize\")));\n put(\"labelFont\", canonText(treeAttr(label, \"fontFamily\"), at(\"labelFont\")));\n const style = treeAttr(label, \"fontStyle\");\n if (style !== undefined) {\n const known = FONT_STYLES.get(style.trim().toLowerCase());\n if (known === undefined) {\n noteAt(at(\"labelWeight\"), STYLE_ISSUE.UNKNOWN_VALUE, style.slice(0, MAX_STYLE_VALUE_LENGTH));\n } else {\n put(\"labelWeight\", known[0]);\n put(\"labelItalic\", known[1]);\n }\n }\n const position = node ? treeAttr(label, \"modelPosition\") : undefined;\n if (position !== undefined) {\n const known = YED_POSITIONS.get(position.trim().toLowerCase());\n if (known === undefined) {\n noteAt(at(\"labelPosition\"), STYLE_ISSUE.UNKNOWN_VALUE, position.slice(0, MAX_STYLE_VALUE_LENGTH));\n }\n put(\"labelPosition\", known ?? null);\n }\n}\n\n/**\n * The shape of a node realizer: its `y:Shape` where it has one, a GenericNode's configuration, or the realizer\n * type itself for one that draws an image (SVG, image, table, UML).\n * @param real - the realizer\n * @param at - the sites\n * @returns the shape, or null\n */\nfunction realizerShape(real: Realizer, at: SiteOf): string | null {\n const shape = treeChild(real.r, \"Shape\");\n if (shape !== undefined) {\n return canonEnum(\"shape\", treeAttr(shape, \"type\"), \"yed\", at(\"shape\"));\n }\n if (real.type === \"ShapeNode\" || real.type === \"GroupNode\" || real.type === \"GenericGroupNode\") {\n return null;\n }\n if (real.type === \"GenericNode\") {\n const conf = treeAttr(real.r, \"configuration\") ?? \"\";\n const flowchart = flowchartShape(conf);\n if (flowchart !== null) {\n return flowchart;\n }\n const lower = conf.slice(0, MAX_STYLE_VALUE_LENGTH).toLowerCase();\n for (const [word, value] of GENERIC_SHAPES) {\n if (lower.includes(word)) {\n return value;\n }\n }\n if (lower.length === 0) {\n return null;\n }\n noteAt(at(\"shape\"), STYLE_ISSUE.UNKNOWN_VALUE, lower);\n return `other:${lower}`;\n }\n noteAt(at(\"shape\"), STYLE_ISSUE.UNKNOWN_VALUE, real.type);\n return `other:${real.type}`;\n}\n\n/**\n * Reads one node realizer.\n * @param real - the realizer\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readNode(real: Realizer, put: PutValue, at: SiteOf): void {\n const { r } = real;\n const fill = treeChild(r, \"Fill\");\n if (fill !== undefined) {\n if (treeAttr(fill, \"hasColor\") === \"false\" || treeAttr(fill, \"transparent\") === \"true\") {\n noteAt(at(\"fill\"), STYLE_ISSUE.NO_FILL, \"transparent\");\n put(\"fillOpacity\", 0);\n } else {\n readColor(treeAttr(fill, \"color\"), \"fill\", \"fillOpacity\", put, at);\n const second = treeAttr(fill, \"color2\");\n if (second !== undefined) {\n noteAt(at(\"fill\"), STYLE_ISSUE.GRADIENT, second);\n }\n }\n }\n const border = treeChild(r, \"BorderStyle\");\n if (border !== undefined) {\n if (treeAttr(border, \"hasColor\") === \"false\") {\n put(\"borderWidth\", 0);\n } else {\n readColor(treeAttr(border, \"color\"), \"borderColor\", null, put, at);\n put(\"borderWidth\", canonNumber(treeAttr(border, \"width\"), at(\"borderWidth\")));\n }\n put(\"borderStyle\", canonEnum(\"borderStyle\", treeAttr(border, \"type\"), \"yed\", at(\"borderStyle\")));\n }\n const geometry = treeChild(r, \"Geometry\");\n put(\"width\", canonNumber(treeAttr(geometry, \"width\"), at(\"width\")));\n put(\"height\", canonNumber(treeAttr(geometry, \"height\"), at(\"height\")));\n put(\"shape\", realizerShape(real, at));\n readLabels(treeChildren(r, \"NodeLabel\"), true, put, at);\n}\n\n/**\n * Reads one edge realizer.\n * @param real - the realizer\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readEdge(real: Realizer, put: PutValue, at: SiteOf): void {\n const { r } = real;\n const line = treeChild(r, \"LineStyle\");\n if (line !== undefined) {\n readColor(treeAttr(line, \"color\"), \"color\", \"opacity\", put, at);\n put(\"width\", canonNumber(treeAttr(line, \"width\"), at(\"width\")));\n put(\"lineStyle\", canonEnum(\"lineStyle\", treeAttr(line, \"type\"), \"yed\", at(\"lineStyle\")));\n }\n const arrows = treeChild(r, \"Arrows\");\n if (arrows !== undefined) {\n put(\"sourceArrow\", canonEnum(\"arrow\", treeAttr(arrows, \"source\"), \"yed\", at(\"sourceArrow\")));\n put(\"targetArrow\", canonEnum(\"arrow\", treeAttr(arrows, \"target\"), \"yed\", at(\"targetArrow\")));\n }\n put(\"curved\", edgeCurved(real));\n readLabels(treeChildren(r, \"EdgeLabel\"), false, put, at);\n}\n\n/**\n * Whether yEd draws an edge curved: an arc always; a Bezier, quad curve, spline or generic edge only through its\n * control points (with none it is a straight line); a polyline only when it smooths bends it has.\n * @param real - the edge realizer\n * @returns true when curved, null when a polyline does not say whether it smooths\n */\nfunction edgeCurved(real: Realizer): boolean | null {\n if (real.type === \"ArcEdge\") {\n return true;\n }\n const bent = treeChildren(treeChild(real.r, \"Path\"), \"Point\").length > 0;\n if (real.type !== \"PolyLineEdge\") {\n return bent;\n }\n const smoothed = treeAttr(treeChild(real.r, \"BendStyle\"), \"smoothed\");\n return smoothed === undefined ? null : smoothed === \"true\" && bent;\n}\n\n/**\n * An edge's bends: the points of its `y:Path`, relative to the centers of its two nodes. yEd draws a polyline through\n * them; a curve type (Bezier, quad curve, spline) passes near them as its control points.\n * @param real - the edge realizer\n * @param centers - each node's center, x and y\n * @param source - the source node's index\n * @param target - the target node's index\n * @returns the `bends` value, or null without bends\n */\nfunction edgeBends(real: Realizer, centers: Float64Array, source: number, target: number): string | null {\n const points = treeChildren(treeChild(real.r, \"Path\"), \"Point\").map((p): BendPoint => [\n Number(treeAttr(p, \"x\")),\n Number(treeAttr(p, \"y\")),\n ]);\n const at = (k: number): BendPoint => [centers[2 * k], centers[2 * k + 1]];\n return canonBends(at(source), at(target), points, true);\n}\n\n/** Canonical values per property, by element index. */\nexport type ValueColumns = Record<string, (StyleValue | null)[]>;\n\n/**\n * A collector of canonical values for one target.\n * @param n - the element count\n * @returns the values and a setter for element i\n */\nexport function valueColumns(n: number): {\n readonly values: ValueColumns;\n put(i: number, property: string, value: StyleValue | null): void;\n} {\n const values: ValueColumns = Object.create(null) as ValueColumns;\n return {\n values,\n put(i, property, value) {\n if (value !== null) {\n values[property] ??= new Array<StyleValue | null>(n).fill(null);\n values[property][i] = value;\n }\n },\n };\n}\n\n/** What the yEd reader read. */\nexport interface YedRead {\n /** Node values. */\n readonly node: ValueColumns;\n /** Edge values. */\n readonly edge: ValueColumns;\n}\n\n/**\n * The yEd styles of a graph: each element's realizer read into canonical values.\n * @param snapshot - the graph\n * @param notes - where problems are noted\n * @param budget - the work budget\n * @returns the values, or null when no element has a yEd realizer\n */\nexport function readYedStyles(snapshot: GraphSnapshot, notes: StyleNotes, budget: StyleWorkBudget): YedRead | null {\n let found = false;\n // each node's center, read with the node, for its edges' bends; NaN for a node without yEd graphics\n const centers = new Float64Array(2 * snapshot.nodeCount).fill(Number.NaN);\n const read = (target: StyleTarget): ValueColumns => {\n const table = target === \"node\" ? snapshot.nodes : snapshot.edges;\n const n = target === \"node\" ? snapshot.nodeCount : snapshot.edgeCount;\n const names = target === \"node\" ? NODE_REALIZERS : EDGE_REALIZERS;\n const columns = treeColumns(table);\n const out = valueColumns(n);\n if (columns.length === 0) {\n return out.values;\n }\n for (let i = 0; i < n; i++) {\n budget.spend(target, columns.length);\n let real: Realizer | null = null;\n for (let c = 0; c < columns.length && real === null; c++) {\n real = realizerOf(plainCell(table.value(columns[c], i)), names);\n }\n if (real === null) {\n continue;\n }\n found = true;\n const at: SiteOf = (property) => ({ notes, target, property, element: i, budget });\n const put: PutValue = (property, value) => {\n out.put(i, property, value);\n };\n if (target === \"node\") {\n readNode(real, put, at);\n const geometry = treeChild(real.r, \"Geometry\");\n centers[2 * i] = Number(treeAttr(geometry, \"x\")) + Number(treeAttr(geometry, \"width\")) / 2;\n centers[2 * i + 1] = Number(treeAttr(geometry, \"y\")) + Number(treeAttr(geometry, \"height\")) / 2;\n } else {\n readEdge(real, put, at);\n put(\"bends\", edgeBends(real, centers, snapshot.edgeSource(i), snapshot.edgeTarget(i)));\n }\n }\n return out.values;\n };\n const node = read(\"node\");\n const edge = read(\"edge\");\n return found ? { node, edge } : null;\n}\n\n// ============================================================ writing\n\n/**\n * What the GraphML writer holds natively: yEd `y:ShapeNode` and `y:PolyLineEdge` graphics. The `graphty.styles`\n * block is a graph `<data>` under its own key, and the per-element values its rules read are keys of their own.\n * @category Built-in formats\n */\nexport const GRAPHML_STYLE_CAPABILITIES: StyleWriteCapabilities = Object.freeze({\n node: Object.freeze([\n \"fill\",\n \"fillOpacity\",\n \"borderColor\",\n \"borderWidth\",\n \"borderStyle\",\n \"shape\",\n \"width\",\n \"height\",\n \"label\",\n \"labelColor\",\n \"labelSize\",\n \"labelFont\",\n \"labelWeight\",\n \"labelItalic\",\n \"labelPosition\",\n ] as const),\n edge: Object.freeze([\n \"color\",\n \"opacity\",\n \"width\",\n \"lineStyle\",\n \"sourceArrow\",\n \"targetArrow\",\n \"curved\",\n \"bends\",\n \"label\",\n \"labelColor\",\n \"labelSize\",\n \"labelFont\",\n \"labelWeight\",\n \"labelItalic\",\n ] as const),\n block: \"attributes\",\n});\n\n/** A written value and whether it is the exact value. */\ninterface Written {\n readonly value: string;\n readonly exact: boolean;\n}\n\n/** yEd's ShapeNode types, by the neutral shape each draws exactly. */\nexport const YED_SHAPES: ReadonlyMap<string, string> = new Map([\n [\"ellipse\", \"ellipse\"],\n [\"rectangle\", \"rectangle\"],\n [\"round-rectangle\", \"roundrectangle\"],\n [\"triangle\", \"triangle\"],\n [\"diamond\", \"diamond\"],\n [\"hexagon\", \"hexagon\"],\n [\"octagon\", \"octagon\"],\n [\"parallelogram\", \"parallelogram\"],\n [\"trapezoid\", \"trapezoid\"],\n [\"star\", \"star5\"],\n]);\n\n/** yEd's line types, by the neutral line style each draws exactly. */\nexport const YED_LINES: ReadonlyMap<string, string> = new Map([\n [\"solid\", \"line\"],\n [\"dashed\", \"dashed\"],\n [\"dotted\", \"dotted\"],\n [\"dash-dot\", \"dashed_dotted\"],\n]);\n\n/** yEd's arrows, by the neutral arrow each draws exactly. */\nexport const YED_ARROWS: ReadonlyMap<string, string> = new Map([\n [\"none\", \"none\"],\n [\"triangle\", \"standard\"],\n [\"triangle-open\", \"white_delta\"],\n [\"vee\", \"concave\"],\n [\"tee\", \"t_shape\"],\n [\"diamond\", \"diamond\"],\n [\"diamond-open\", \"white_diamond\"],\n [\"circle\", \"circle\"],\n [\"circle-open\", \"white_circle\"],\n [\"square\", \"skewed_dash\"],\n [\"crow\", \"crows_foot_many\"],\n]);\n\n/** yEd's label positions in the internal model, by neutral position. */\nconst YED_MODEL_POSITIONS: ReadonlyMap<string, string> = new Map([\n [\"center\", \"c\"],\n [\"top\", \"t\"],\n [\"bottom\", \"b\"],\n [\"left\", \"l\"],\n [\"right\", \"r\"],\n [\"top-left\", \"tl\"],\n [\"top-right\", \"tr\"],\n [\"bottom-left\", \"bl\"],\n [\"bottom-right\", \"br\"],\n]);\n\n/**\n * A value of a table, or the nearest value the table has.\n * @param table - neutral value to yEd value\n * @param value - the neutral value\n * @param nearest - the yEd value written when the table has none\n * @returns the written value\n */\nexport function yedValue(table: ReadonlyMap<string, string>, value: string, nearest: string): Written {\n const exact = table.get(value);\n if (exact !== undefined) {\n return { value: exact, exact: true };\n }\n // a value the reader kept as other:<raw> goes back as written\n return value.startsWith(\"other:\") ? { value: value.slice(6), exact: true } : { value: nearest, exact: false };\n}\n\n/**\n * A color with an alpha from an opacity, as yEd writes it: `#RRGGBB`, or `#RRGGBBAA` with the alpha last.\n * @param color - the canonical color\n * @param opacity - the opacity, or null\n * @returns the text\n */\nexport function yedColor(color: string, opacity: StyleValue | null): string {\n const hex = color.toUpperCase();\n if (typeof opacity !== \"number\" || opacity >= 1) {\n return hex;\n }\n return (\n hex +\n Math.round(Math.max(0, opacity) * 255)\n .toString(16)\n .toUpperCase()\n .padStart(2, \"0\")\n );\n}\n\n/** Records a value written as the nearest one yEd has. */\ntype Approximate = (property: string, value: StyleValue) => void;\n\n/**\n * A value in yEd's spelling, recorded as approximated when yEd has no exact one.\n * @param table - yEd's spellings\n * @param value - the neutral value\n * @param nearest - the spelling written when there is no exact one\n * @param property - the property, for the approximation note\n * @param approximate - records approximations\n * @returns the spelling\n */\nexport function yedSpelled(\n table: ReadonlyMap<string, string>,\n value: string,\n nearest: string,\n property: string,\n approximate: Approximate,\n): string {\n const w = yedValue(table, value, nearest);\n if (!w.exact) {\n approximate(property, value);\n }\n return w.value;\n}\n\n/** One element's value of a property. */\ntype GetValue = (property: string) => StyleValue | null;\n\n/**\n * The label attributes and text of one element.\n * @param get - the element's values\n * @param node - whether it is a node label (which has a position)\n * @param approximate - records approximations\n * @returns the label element, or null when the element has no label text\n */\nfunction labelTree(get: GetValue, node: boolean, approximate: Approximate): Tree | null {\n const text = get(\"label\");\n if (typeof text !== \"string\" || text.trim().length === 0) {\n return null;\n }\n const label: Tree = {};\n const font = get(\"labelFont\");\n if (typeof font === \"string\") {\n label[\"@_fontFamily\"] = font;\n }\n const size = get(\"labelSize\");\n if (typeof size === \"number\") {\n label[\"@_fontSize\"] = String(size);\n }\n const weight = get(\"labelWeight\");\n const italic = get(\"labelItalic\");\n if (weight !== null || italic !== null) {\n const style = (weight === \"bold\" ? \"bold\" : \"\") + (italic === true ? \"italic\" : \"\");\n label[\"@_fontStyle\"] = style.length === 0 ? \"plain\" : style;\n }\n const color = get(\"labelColor\");\n if (typeof color === \"string\") {\n label[\"@_textColor\"] = color.toUpperCase();\n }\n const position = node ? get(\"labelPosition\") : null;\n if (typeof position === \"string\") {\n const written = YED_MODEL_POSITIONS.get(position);\n if (written === undefined) {\n approximate(\"labelPosition\", position);\n }\n label[\"@_modelName\"] = \"internal\";\n label[\"@_modelPosition\"] = written ?? \"c\";\n }\n label[\"#text\"] = text;\n return label;\n}\n\n/**\n * A node's `y:ShapeNode` from its values.\n * @param get - the node's values\n * @param at - the node's position from the graphics it had, or null\n * @param approximate - records approximations\n * @returns the graphics tree\n */\nfunction shapeNodeTree(get: GetValue, at: readonly [string, string] | null, approximate: Approximate): Tree {\n const node: Tree = {};\n node[\"y:Geometry\"] = geometryTree(get, at);\n const fill = get(\"fill\");\n const fillOpacity = get(\"fillOpacity\");\n if (typeof fill === \"string\") {\n node[\"y:Fill\"] = { \"@_color\": yedColor(fill, fillOpacity), \"@_transparent\": \"false\" };\n } else if (fillOpacity === 0) {\n node[\"y:Fill\"] = { \"@_hasColor\": \"false\", \"@_transparent\": \"false\" };\n }\n const border = lineTree(get, [\"borderColor\", \"borderWidth\", \"borderStyle\"], approximate);\n if (border !== null) {\n node[\"y:BorderStyle\"] = border;\n }\n const label = labelTree(get, true, approximate);\n if (label !== null) {\n node[\"y:NodeLabel\"] = label;\n }\n const shape = get(\"shape\");\n if (typeof shape === \"string\") {\n node[\"y:Shape\"] = {\n \"@_type\": yedSpelled(YED_SHAPES, shape, shape === \"vee\" ? \"triangle\" : \"rectangle\", \"shape\", approximate),\n };\n }\n return { \"y:ShapeNode\": node };\n}\n\n/**\n * A node's `y:Geometry`: its size, and its position from the graphics it had.\n * @param get - the node's values\n * @param at - the node's position, or null\n * @returns the geometry\n */\nfunction geometryTree(get: GetValue, at: readonly [string, string] | null): Tree {\n const geometry: Tree = {};\n const height = get(\"height\");\n const width = get(\"width\");\n if (typeof height === \"number\") {\n geometry[\"@_height\"] = String(height);\n }\n if (typeof width === \"number\") {\n geometry[\"@_width\"] = String(width);\n }\n if (at !== null) {\n geometry[\"@_x\"] = at[0];\n geometry[\"@_y\"] = at[1];\n }\n return geometry;\n}\n\n/**\n * A `y:BorderStyle` or `y:LineStyle`: a color, a width and a line type. A node's border color is written opaque; an\n * edge's color carries its opacity.\n * @param get - the element's values\n * @param properties - the color, width and style properties\n * @param approximate - records approximations\n * @param opacity - the opacity of the color, for an edge's line\n * @returns the element, or null when none of the three is set\n */\nfunction lineTree(\n get: GetValue,\n properties: readonly [string, string, string],\n approximate: Approximate,\n opacity?: StyleValue | null,\n): Tree | null {\n const [colorKey, widthKey, styleKey] = properties;\n const color = get(colorKey);\n const width = get(widthKey);\n const style = get(styleKey);\n if (color === null && width === null && style === null) {\n return null;\n }\n const line: Tree = {};\n if (typeof color === \"string\") {\n line[\"@_color\"] = opacity === undefined ? color.toUpperCase() : yedColor(color, opacity);\n }\n if (typeof style === \"string\") {\n const nearest = styleKey === \"lineStyle\" && style === \"long-dash\" ? \"dashed\" : \"line\";\n line[\"@_type\"] = yedSpelled(YED_LINES, style, nearest, styleKey, approximate);\n }\n if (typeof width === \"number\") {\n line[\"@_width\"] = String(width);\n }\n return line;\n}\n\n/**\n * An edge's `y:PolyLineEdge` from its values.\n * @param get - the edge's values\n * @param path - the `y:Path` of the graphics it had, or undefined\n * @param approximate - records approximations\n * @returns the graphics tree\n */\nfunction polyLineEdgeTree(get: GetValue, path: unknown, approximate: Approximate): Tree {\n const edge: Tree = {};\n if (path !== undefined) {\n edge[\"y:Path\"] = path;\n }\n const line = lineTree(get, [\"color\", \"width\", \"lineStyle\"], approximate, get(\"opacity\"));\n if (line !== null) {\n edge[\"y:LineStyle\"] = line;\n }\n const source = get(\"sourceArrow\");\n const target = get(\"targetArrow\");\n if (source !== null || target !== null) {\n const arrow = (property: string, value: StyleValue | null): string =>\n typeof value === \"string\" ? yedSpelled(YED_ARROWS, value, \"standard\", property, approximate) : \"none\";\n edge[\"y:Arrows\"] = { \"@_source\": arrow(\"sourceArrow\", source), \"@_target\": arrow(\"targetArrow\", target) };\n }\n const label = labelTree(get, false, approximate);\n if (label !== null) {\n edge[\"y:EdgeLabel\"] = label;\n }\n const curved = get(\"curved\");\n if (typeof curved === \"boolean\") {\n edge[\"y:BendStyle\"] = { \"@_smoothed\": String(curved) };\n }\n return { \"y:PolyLineEdge\": edge };\n}\n\n/**\n * Each element's values of the properties the writer writes, as a getter per element.\n * @param picture - each element's value of a property\n * @param target - nodes or edges\n * @returns the getter\n */\nfunction getter(\n picture: (target: StyleTarget, property: string) => readonly (StyleValue | null)[],\n target: StyleTarget,\n): (i: number) => GetValue {\n const columns = new Map<string, readonly (StyleValue | null)[]>();\n for (const p of GRAPHML_STYLE_CAPABILITIES[target]) {\n columns.set(p, picture(target, p));\n }\n return (i) => (property) => columns.get(property)?.[i] ?? null;\n}\n\n/**\n * For a file graphty wrote: where a value read from the yEd graphics is what the writer writes for the block's own\n * value (a pentagon written as a hexagon, an opacity rounded to yEd's 255 steps), the block's exact value is the\n * truth, so a re-import gives back the same rules; a value another program changed since stays the truth.\n * @param read - the values the reader read, changed in place\n * @param picture - each element's value of a property under the block's rules\n * @param counts - the node and edge counts\n * @param counts.node - the node count\n * @param counts.edge - the edge count\n * @param notes - a scratch note list for reading back what the writer writes\n */\nexport function exactFromBlock(\n read: YedRead,\n picture: (target: StyleTarget, property: string) => readonly (StyleValue | null)[],\n counts: { readonly node: number; readonly edge: number },\n notes: StyleNotes,\n): void {\n for (const target of [\"node\", \"edge\"] as const) {\n const values = read[target];\n const get = getter(picture, target);\n for (let i = 0; i < counts[target]; i++) {\n const want = get(i);\n const back = writtenAndReadBack(target, want, notes);\n if (back === null) {\n continue;\n }\n for (const property of GRAPHML_STYLE_CAPABILITIES[target]) {\n const native = values[property]?.[i] ?? null;\n const w = want(property);\n if (native !== w && native === (back.get(property) ?? null)) {\n values[property] ??= new Array<StyleValue | null>(counts[target]).fill(null);\n values[property][i] = w;\n }\n }\n }\n }\n}\n\n/**\n * An element's values written as the writer writes them and read back as the reader reads them.\n * @param target - nodes or edges\n * @param want - its values\n * @param notes - a scratch for the notes the round trip makes\n * @returns the values read back, by property, or null when the written graphics hold no realizer\n */\nfunction writtenAndReadBack(target: StyleTarget, want: GetValue, notes: StyleNotes): Map<string, StyleValue> | null {\n const ignore: Approximate = () => undefined;\n const tree = target === \"node\" ? shapeNodeTree(want, null, ignore) : polyLineEdgeTree(want, undefined, ignore);\n const real = realizerOf(tree, target === \"node\" ? NODE_REALIZERS : EDGE_REALIZERS);\n if (real === null) {\n return null;\n }\n const back = new Map<string, StyleValue>();\n const at: SiteOf = (property) => ({ notes, target, property });\n const put: PutValue = (property, value) => {\n if (value !== null) {\n back.set(property, value);\n }\n };\n if (target === \"node\") {\n readNode(real, put, at);\n } else {\n readEdge(real, put, at);\n }\n return back;\n}\n\n/** A GraphML export with styles worked out. */\ninterface GraphmlStyledExport {\n /** The graph to write: the yFiles drawing columns replaced by yEd graphics written from the styles. */\n readonly snapshot: GraphSnapshot;\n /** W_STYLE_APPROXIMATED for every value written as the nearest one yEd has. */\n readonly notes: readonly LossNote[];\n}\n\n/** The yFiles key type of the written node and edge graphics. */\nconst GRAPHICS_TYPES: Readonly<Record<StyleTarget, string>> = { node: \"nodegraphics\", edge: \"edgegraphics\" };\n\n/**\n * A node's position from the graphics it had: a yEd realizer's `y:Geometry` x and y, or a yFiles 3 `y:RectD`'s.\n * @param table - the node table\n * @param columns - its tree columns\n * @param i - the node\n * @returns the x and y as written, or null\n */\nfunction keptPosition(table: GraphSnapshot[\"nodes\"], columns: readonly string[], i: number): [string, string] | null {\n for (const name of columns) {\n const tree = plainCell(table.value(name, i));\n const real = realizerOf(tree, NODE_REALIZERS);\n const geometry = real === null ? treeChild(tree, \"RectD\") : treeChild(real.r, \"Geometry\");\n const x = treeAttr(geometry, real === null ? \"X\" : \"x\");\n const y = treeAttr(geometry, real === null ? \"Y\" : \"y\");\n if (x !== undefined && y !== undefined) {\n return [x, y];\n }\n }\n return null;\n}\n\n/**\n * A node's `y:Geometry` x and y from the graph's position column, for a node with no yEd graphics of its own: the\n * column's coordinate read in its declared spelling (center, y up when it declares none), written as yEd places a\n * box, by its top-left corner with y growing downward.\n * @param snapshot - the graph\n * @param i - the node\n * @param get - the node's values (its drawn width and height)\n * @returns the x and y to write, or null when the node has no finite position\n */\nfunction columnPosition(snapshot: GraphSnapshot, i: number, get: GetValue): [string, string] | null {\n const column = snapshot.nodes.byRole(\"position\");\n if (column === null || column.meta.components < 2 || !column.isSet(i)) {\n return null;\n }\n const v = column.value(i) as ArrayLike<number>;\n const width = get(\"width\");\n const height = get(\"height\");\n const size: [number, number] = [typeof width === \"number\" ? width : 0, typeof height === \"number\" ? height : 0];\n const p: [number, number, number] = [v[0], v[1], 0];\n toNeutral(p, column.meta.extra ?? {}, size, false);\n const [x, y] = toFilePositions(Float64Array.from(p), YED_SPELLING, {\n width: Float64Array.of(size[0]),\n height: Float64Array.of(size[1]),\n });\n return Number.isFinite(x) && Number.isFinite(y) ? [String(x), String(y)] : null;\n}\n\n/** How yEd spells a node's place: its box's top-left corner, y growing downward. */\nconst YED_SPELLING: PositionColumnExtra = { yAxis: \"down\", anchor: \"top-left\" };\n\n/**\n * An edge's `y:Path` (its bends) from the yEd graphics it had.\n * @param table - the edge table\n * @param columns - its tree columns\n * @param e - the edge\n * @returns the path, or undefined\n */\nfunction keptPath(table: GraphSnapshot[\"edges\"], columns: readonly string[], e: number): unknown {\n for (const name of columns) {\n const real = realizerOf(plainCell(table.value(name, e)), EDGE_REALIZERS);\n const path = real === null ? undefined : treeChild(real.r, \"Path\");\n if (path !== undefined) {\n return path;\n }\n }\n return undefined;\n}\n\n/**\n * An edge's `y:Path` with its points placed from its `bends` value between the written node centers, so the bends\n * read back as written; the ports of the path it had are kept. Without a value, or without both centers, the path it\n * had.\n * @param kept - the path from the graphics the edge had, or undefined\n * @param bends - the edge's `bends` value\n * @param ends - the written centers of its source and target\n * @returns the path, or undefined\n */\nfunction pathWithBends(kept: unknown, bends: StyleValue | null, ends: readonly [BendPoint, BendPoint]): unknown {\n const points = typeof bends === \"string\" ? bendsToPoints(ends[0], ends[1], bends, true) : null;\n if (points === null) {\n return kept;\n }\n const path: Tree = {};\n for (const port of [\"sx\", \"sy\", \"tx\", \"ty\"]) {\n path[`@_${port}`] = treeAttr(kept, port) ?? \"0.0\";\n }\n path[\"y:Point\"] = points.map(([x, y]) => ({ \"@_x\": String(x), \"@_y\": String(y) }));\n return path;\n}\n\n/**\n * A column name not yet taken in a table.\n * @param table - the table\n * @param base - the preferred name\n * @returns the name\n */\nfunction freeName(table: GraphSnapshot[\"nodes\"], base: string): string {\n let name = base;\n let k = 2;\n while (table.has(name)) {\n name = `${base}#${String(k)}`;\n k++;\n }\n return name;\n}\n\n/**\n * Works out a GraphML export with styles: every node and edge column made from yFiles keys (the graphics trees,\n * the typed `yfiles.*` columns and yFiles 3's drawing state) is replaced by yEd graphics written from what graphty\n * draws, keeping each node's position and each edge's bends from the graphics it had; graph data from yFiles 3\n * keys goes too, since its `y:` elements are not yEd's.\n * @param snapshot - the graph handed to the exporter\n * @param input - the styles, or undefined when none are written\n * @returns the styled export, or null without styles\n */\nexport function graphmlStyledExport(\n snapshot: GraphSnapshot,\n input: ExporterStyleInput | undefined,\n): GraphmlStyledExport | null {\n if (input === undefined) {\n return null;\n }\n const approximated = new StyleApproximations();\n const approximateFor =\n (target: StyleTarget): Approximate =>\n (property, value) => {\n approximated.add(target, property, value);\n };\n const picture = (target: StyleTarget, property: string): readonly (StyleValue | null)[] =>\n input.picture(target, property as never);\n const nodeColumns = treeColumns(snapshot.nodes);\n const edgeColumns = treeColumns(snapshot.edges);\n const getNode = getter(picture, \"node\");\n const getEdge = getter(picture, \"edge\");\n const nodeTrees: (Tree | null)[] = [];\n for (let i = 0; i < snapshot.nodeCount; i++) {\n const get = getNode(i);\n const at = keptPosition(snapshot.nodes, nodeColumns, i) ?? columnPosition(snapshot, i, get);\n nodeTrees.push(shapeNodeTree(get, at, approximateFor(\"node\")));\n }\n const centers = nodeTrees.map((tree): BendPoint => {\n const geometry = treeChild(treeChild(tree, \"ShapeNode\"), \"Geometry\");\n const at = (k: string): number => Number(treeAttr(geometry, k) ?? Number.NaN);\n return [at(\"x\") + at(\"width\") / 2, at(\"y\") + at(\"height\") / 2];\n });\n const edgeTrees: (Tree | null)[] = [];\n for (let e = 0; e < snapshot.edgeCount; e++) {\n const get = getEdge(e);\n const ends: readonly [BendPoint, BendPoint] = [\n centers[snapshot.edgeSource(e)],\n centers[snapshot.edgeTarget(e)],\n ];\n const path = pathWithBends(keptPath(snapshot.edges, edgeColumns, e), get(\"bends\"), ends);\n edgeTrees.push(polyLineEdgeTree(get, path, approximateFor(\"edge\")));\n }\n const out = snapshot.withColumns();\n for (const [table, trees, target] of [\n [out.nodes, nodeTrees, \"node\"],\n [out.edges, edgeTrees, \"edge\"],\n ] as const) {\n for (const name of yfilesColumns(table)) {\n table.remove(name);\n }\n const name = freeName(table, GRAPHICS_TYPES[target]);\n table.set(name, trees, {\n dtype: \"json\",\n nullable: true,\n origin: { format: \"graphml\", id: null, title: null, type: GRAPHICS_TYPES[target], namespace: \"yfiles\" },\n });\n }\n const yfiles3 = [...out.graph].filter(\n (col) => col.meta.origin?.namespace === \"yfiles\" && (col.meta.origin.type ?? \"\").includes(\"://\"),\n );\n for (const col of yfiles3) {\n out.graph.remove(col.meta.name);\n }\n return { snapshot: out, notes: approximated.notes(\"yEd\") };\n}\n"],"names":["name"],"mappings":";;;AAkBA,MAAM,WAAW,CAAC,MAAsB,OAAO,KAAK,MAAM,IAAI,GAAG,IAAI,GAAG;AAWjE,SAAS,WACZ,QACA,QACA,QACA,OACa;AACb,QAAM,OAAe;AACrB,QAAM,KAAK,OAAO,CAAC,IAAI,OAAO,CAAC;AAC/B,QAAM,MAAM,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK;AACrC,QAAM,UAAU,KAAK,KAAK,KAAK;AAC/B,MAAI,OAAO,WAAW,KAAK,WAAW,KAAK,CAAC,OAAO,SAAS,OAAO,GAAG;AAClE,WAAO;A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AI,KAAK,OAAO,QAAQ,IAAI,SAAS,KAAK;AAAA,EAAA;AAEnG,aAAW,OAAO,SAAS;AACvB,QAAI,MAAM,OAAO,IAAI,KAAK,IAAI;AAAA,EAClC;AACA,SAAO,EAAE,UAAU,KAAK,OAAO,aAAa,MAAM,KAAK,EAAA;AAC3D;"}
|
|
1
|
+
{"version":3,"file":"styles-yed-BF5x3_Y5.js","sources":["../../src/styles/canon/bends.ts","../../src/formats/graphml/styles-yed.ts"],"sourcesContent":["/**\n * The neutral `bends` value of an edge: the points its route passes through between its two nodes, each relative to\n * the straight line from the source node's center to the target node's center. `along` is how far along that line\n * the point lies (0 at the source center, 1 at the target center) and `across` how far to its left, y up, both as\n * fractions of the line's length. Written `along,across` per point, in order from the source, separated by spaces:\n * `\"0,-0.5 1,-0.5\"` is a route that leaves the source, runs parallel to the line half its length to the right, and\n * comes back to the target. Relative, so a drawing that moves or scales the nodes keeps the route's shape and its\n * right angles.\n */\n\n/** A point in the file's own coordinates. */\nexport type BendPoint = readonly [x: number, y: number];\n\n/**\n * Rounds a fraction to 4 decimals, so a value spells the same whatever float noise the file's numbers carry.\n * @param v - the fraction\n * @returns its spelling\n */\nconst fraction = (v: number): string => String(Math.round(v * 1e4) / 1e4);\n\n/**\n * The `bends` value of an edge whose route passes through `points`.\n * @param source - the source node's center\n * @param target - the target node's center\n * @param points - the bend points, from the source end\n * @param yDown - true when the file's y axis points down (the value is always y up)\n * @returns the value, or null with no bends, no line between distinct centers, or a coordinate that is not finite\n * @category Styles\n */\nexport function canonBends(\n source: BendPoint,\n target: BendPoint,\n points: readonly BendPoint[],\n yDown: boolean,\n): string | null {\n const flip = yDown ? -1 : 1;\n const dx = target[0] - source[0];\n const dy = (target[1] - source[1]) * flip;\n const length2 = dx * dx + dy * dy;\n if (points.length === 0 || length2 <= 0 || !Number.isFinite(length2)) {\n return null;\n }\n const out: string[] = [];\n for (const [px, py] of points) {\n const rx = px - source[0];\n const ry = (py - source[1]) * flip;\n const along = (rx * dx + ry * dy) / length2;\n const across = (dx * ry - dy * rx) / length2;\n if (!Number.isFinite(along) || !Number.isFinite(across)) {\n return null;\n }\n out.push(`${fraction(along)},${fraction(across)}`);\n }\n return out.join(\" \");\n}\n\n/**\n * The bend points a `bends` value places between two node centers: the inverse of {@link canonBends}.\n * @param source - the source node's center\n * @param target - the target node's center\n * @param value - the `bends` value\n * @param yDown - true when the points are wanted in a y-down file's coordinates\n * @returns the points, or null when the value is not `along,across` pairs or a coordinate is not finite\n * @category Styles\n */\nexport function bendsToPoints(source: BendPoint, target: BendPoint, value: string, yDown: boolean): BendPoint[] | null {\n const flip = yDown ? -1 : 1;\n const dx = target[0] - source[0];\n const dy = (target[1] - source[1]) * flip;\n const out: BendPoint[] = [];\n for (const pair of value.trim().split(/\\s+/)) {\n const [a, c, extra] = pair.split(\",\").map(Number);\n if (extra !== undefined || !Number.isFinite(a) || !Number.isFinite(c)) {\n return null;\n }\n const x = source[0] + a * dx - c * dy;\n const y = source[1] + (a * dy + c * dx) * flip;\n if (!Number.isFinite(x) || !Number.isFinite(y)) {\n return null;\n }\n out.push([x, y]);\n }\n return out.length === 0 ? null : out;\n}\n","/**\n * yEd styles (yFiles for Java 2.x GraphML): reading every realizer a yEd graphics tree holds (`y:ShapeNode`,\n * `y:GenericNode`, `y:GroupNode`, `y:SVGNode`, `y:PolyLineEdge`, `y:BezierEdge`, ...) into the neutral style\n * vocabulary, and writing a graph's styles back as `y:ShapeNode` and `y:PolyLineEdge` graphics. The trees are the\n * json columns the GraphML importer keeps (tree.ts), never the typed `yfiles.*` columns read from them.\n *\n * The tree helpers here are shared with the yFiles 3 reader.\n */\n\nimport type { GraphSnapshot } from \"@graphty/graph-format\";\n\nimport { toFilePositions, toNeutral } from \"../../positions/convert.js\";\nimport type { PositionColumnExtra } from \"../../positions/types.js\";\nimport { type BendPoint, bendsToPoints, canonBends } from \"../../styles/canon/bends.js\";\nimport { canonColor, colorOpacity } from \"../../styles/canon/color.js\";\nimport { canonEnum } from \"../../styles/canon/enums.js\";\nimport { canonNumber } from \"../../styles/canon/number.js\";\nimport { type CanonSite, MAX_STYLE_VALUE_LENGTH, noteAt } from \"../../styles/canon/site.js\";\nimport { canonText } from \"../../styles/canon/text.js\";\nimport { STYLE_ISSUE } from \"../../styles/codes.js\";\nimport { StyleApproximations } from \"../../styles/io/approximations.js\";\nimport type { ExporterStyleInput } from \"../../styles/io/writer.js\";\nimport type { StyleNotes } from \"../../styles/notes.js\";\nimport { plainCell } from \"../../styles/plan/resolve.js\";\nimport type { StyleTarget, StyleValue, StyleWorkBudget, StyleWriteCapabilities } from \"../../styles/types.js\";\nimport type { LossNote } from \"../../types.js\";\n\n// ============================================================ the kept trees\n\n/** A tree object as tree.ts builds it: `@_<name>` attributes, `#text`, and child elements by name. */\ntype Tree = Record<string, unknown>;\n\n/**\n * Whether a value is a tree object.\n * @param value - the value\n * @returns true for a non-array object\n */\nexport function isTree(value: unknown): value is Tree {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The local part of an element name: `y:ShapeNode` is `ShapeNode`, whatever the prefix.\n * @param name - the name as written\n * @returns the local name\n */\nexport function localOf(name: string): string {\n const colon = name.indexOf(\":\");\n return colon < 0 ? name : name.slice(colon + 1);\n}\n\n/**\n * The child elements of a tree node with a local name, in file order.\n * @param node - the tree node\n * @param local - the local name\n * @returns the children\n */\nexport function treeChildren(node: unknown, local: string): unknown[] {\n const out: unknown[] = [];\n if (!isTree(node)) {\n return out;\n }\n for (const key of Object.keys(node)) {\n if (key.startsWith(\"@_\") || key === \"#text\" || localOf(key) !== local) {\n continue;\n }\n const value = node[key];\n if (Array.isArray(value)) {\n for (const item of value) {\n out.push(item);\n }\n } else {\n out.push(value);\n }\n }\n return out;\n}\n\n/**\n * The first child element of a tree node with a local name.\n * @param node - the tree node\n * @param local - the local name\n * @returns the child, or undefined\n */\nexport function treeChild(node: unknown, local: string): unknown {\n if (!isTree(node)) {\n return undefined;\n }\n for (const key of Object.keys(node)) {\n if (!key.startsWith(\"@_\") && key !== \"#text\" && localOf(key) === local) {\n const value = node[key];\n return Array.isArray(value) ? value[0] : value;\n }\n }\n return undefined;\n}\n\n/**\n * An attribute of a tree node.\n * @param node - the tree node\n * @param name - the attribute name as written\n * @returns its text, or undefined\n */\nexport function treeAttr(node: unknown, name: string): string | undefined {\n if (!isTree(node) || !Object.hasOwn(node, `@_${name}`)) {\n return undefined;\n }\n const value = node[`@_${name}`];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * The text of an element: the element itself when it has neither attributes nor children, else its `#text`.\n * @param node - the tree node\n * @returns the text, or null\n */\nexport function treeText(node: unknown): string | null {\n if (typeof node === \"string\") {\n return node;\n }\n if (isTree(node) && Object.hasOwn(node, \"#text\")) {\n const text = node[\"#text\"];\n return typeof text === \"string\" ? text : null;\n }\n return null;\n}\n\n/**\n * The json columns of a table holding yFiles trees.\n * @param table - the node, edge or graph table\n * @returns their names\n */\nfunction treeColumns(table: GraphSnapshot[\"nodes\"]): string[] {\n const out: string[] = [];\n for (const col of table) {\n if (col.dtype === \"json\" && col.meta.origin?.namespace === \"yfiles\") {\n out.push(col.meta.name);\n }\n }\n return out;\n}\n\n/**\n * Every column of a table the GraphML importer made from yFiles keys: the trees and the typed `yfiles.*` columns\n * read from them. They hold the styles themselves, so the planner never explains a style with them.\n * @param table - the node or edge table\n * @returns their names\n */\nexport function yfilesColumns(table: GraphSnapshot[\"nodes\"]): string[] {\n const out: string[] = [];\n for (const col of table) {\n if (col.meta.origin?.namespace === \"yfiles\") {\n out.push(col.meta.name);\n }\n }\n return out;\n}\n\n// ============================================================ reading\n\n/** One element's canonical value of a property; null leaves it unset. */\nexport type PutValue = (property: string, value: StyleValue | null) => void;\n\n/** Where a value of an element was read, by property. */\nexport type SiteOf = (property: string) => CanonSite;\n\n/** The yEd node realizers, by local name. */\nconst NODE_REALIZERS: ReadonlySet<string> = new Set([\n \"ShapeNode\",\n \"GenericNode\",\n \"GroupNode\",\n \"GenericGroupNode\",\n \"SVGNode\",\n \"ImageNode\",\n \"TableNode\",\n \"UMLClassNode\",\n \"UMLNoteNode\",\n \"ProxyAutoBoundsNode\",\n]);\n\n/** The yEd edge realizers, by local name. */\nconst EDGE_REALIZERS: ReadonlySet<string> = new Set([\n \"PolyLineEdge\",\n \"ArcEdge\",\n \"BezierEdge\",\n \"QuadCurveEdge\",\n \"SplineEdge\",\n \"GenericEdge\",\n]);\n\n/** A realizer: its local name and its element. */\ninterface Realizer {\n readonly type: string;\n readonly r: unknown;\n}\n\n/**\n * The realizer a graphics tree holds; a `y:ProxyAutoBoundsNode` (a folder or group) gives its active realizer.\n * @param tree - the `<data>` content\n * @param names - the realizer names of the target\n * @returns the realizer, or null\n */\nfunction realizerOf(tree: unknown, names: ReadonlySet<string>): Realizer | null {\n if (!isTree(tree)) {\n return null;\n }\n for (const key of Object.keys(tree)) {\n const type = localOf(key);\n if (key.startsWith(\"@_\") || !names.has(type)) {\n continue;\n }\n const value = tree[key];\n const r = Array.isArray(value) ? value[0] : value;\n return type === \"ProxyAutoBoundsNode\" ? activeRealizer(r) : { type, r };\n }\n return null;\n}\n\n/**\n * The active realizer of a `y:ProxyAutoBoundsNode`, else its first.\n * @param proxy - the proxy element\n * @returns the realizer, or null when it has none\n */\nfunction activeRealizer(proxy: unknown): Realizer | null {\n const realizers = treeChild(proxy, \"Realizers\");\n const all: Realizer[] = [];\n if (isTree(realizers)) {\n for (const k of Object.keys(realizers).filter((key) => !key.startsWith(\"@_\") && key !== \"#text\")) {\n for (const item of treeChildren(realizers, localOf(k))) {\n all.push({ type: localOf(k), r: item });\n }\n }\n }\n const active = Number(treeAttr(realizers, \"active\") ?? \"0\");\n return all[Number.isInteger(active) && active >= 0 && active < all.length ? active : 0] ?? null;\n}\n\n/**\n * yEd's flowchart palette (`com.yworks.flowchart.<name>`), by name, to the shape each draws. Matched whole, before\n * the words below: \"data\" is a parallelogram, but \"storedData\" and \"directData\" are not.\n */\nconst FLOWCHART_SHAPES: ReadonlyMap<string, string> = new Map([\n [\"process\", \"rectangle\"],\n [\"decision\", \"diamond\"],\n [\"terminator\", \"round-rectangle\"],\n [\"start1\", \"ellipse\"],\n [\"start2\", \"ellipse\"],\n [\"data\", \"parallelogram\"],\n [\"preparation\", \"hexagon\"],\n]);\n\nconst FLOWCHART_PREFIX = \"com.yworks.flowchart.\";\n\n/**\n * The shape a yEd flowchart configuration draws: a GraphML GenericNode's `configuration`, or a yEd GML node's\n * `customconfiguration`.\n * @param configuration - the configuration\n * @returns the neutral shape, or null for a configuration that is not one of the flowchart shapes known here\n */\nexport function flowchartShape(configuration: string): string | null {\n return configuration.startsWith(FLOWCHART_PREFIX)\n ? (FLOWCHART_SHAPES.get(configuration.slice(FLOWCHART_PREFIX.length)) ?? null)\n : null;\n}\n\n/** GenericNode configurations, by a word they contain, to the shape they draw; the first match wins. */\nconst GENERIC_SHAPES: readonly (readonly [string, string])[] = [\n [\"ellipse\", \"ellipse\"],\n [\"circle\", \"ellipse\"],\n [\"oval\", \"ellipse\"],\n [\"diamond\", \"diamond\"],\n [\"decision\", \"diamond\"],\n [\"hexagon\", \"hexagon\"],\n [\"octagon\", \"octagon\"],\n [\"triangle\", \"triangle\"],\n [\"rect\", \"rectangle\"],\n [\"process\", \"rectangle\"],\n [\"box\", \"rectangle\"],\n];\n\n/** yEd's label positions (`modelPosition` of the internal, sides and eight-position models). */\nconst YED_POSITIONS: ReadonlyMap<string, string> = new Map([\n [\"c\", \"center\"],\n [\"t\", \"top\"],\n [\"b\", \"bottom\"],\n [\"l\", \"left\"],\n [\"r\", \"right\"],\n [\"tl\", \"top-left\"],\n [\"tr\", \"top-right\"],\n [\"bl\", \"bottom-left\"],\n [\"br\", \"bottom-right\"],\n [\"n\", \"top\"],\n [\"s\", \"bottom\"],\n [\"e\", \"right\"],\n [\"w\", \"left\"],\n [\"nw\", \"top-left\"],\n [\"ne\", \"top-right\"],\n [\"sw\", \"bottom-left\"],\n [\"se\", \"bottom-right\"],\n]);\n\n/** yEd's font styles, as label weight and italic. */\nexport const FONT_STYLES: ReadonlyMap<string, readonly [string, boolean]> = new Map([\n [\"plain\", [\"normal\", false]],\n [\"bold\", [\"bold\", false]],\n [\"italic\", [\"normal\", true]],\n [\"bolditalic\", [\"bold\", true]],\n]);\n\n/**\n * Reads a color into a property and its alpha into the property's opacity (or notes the alpha dropped).\n * @param raw - the attribute\n * @param property - the color property\n * @param opacity - its opacity property, or null when it has none\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readColor(raw: unknown, property: string, opacity: string | null, put: PutValue, at: SiteOf): void {\n const c = canonColor(raw, \"yed\", at(property));\n if (c === null) {\n return;\n }\n put(property, c.color);\n const alpha = colorOpacity(c, null, at(property), opacity !== null);\n if (opacity !== null) {\n put(opacity, alpha);\n }\n}\n\n/**\n * Reads an element's label: the first visible label with text (yEd icon nodes put an empty, `hasText=\"false\"`\n * label first); further visible labels are noted for the element.\n * @param labels - the label elements, in file order\n * @param node - whether they are node labels (which have a position)\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readLabels(labels: readonly unknown[], node: boolean, put: PutValue, at: SiteOf): void {\n let label: unknown = undefined;\n let text = \"\";\n let extra = 0;\n for (const l of labels) {\n const t = treeText(l)?.trim() ?? \"\";\n if (t.length === 0 || treeAttr(l, \"visible\") === \"false\" || treeAttr(l, \"hasText\") === \"false\") {\n continue;\n }\n if (label === undefined) {\n label = l;\n text = t;\n } else {\n extra++;\n }\n }\n if (label === undefined) {\n return;\n }\n if (extra > 0) {\n noteAt(at(\"label\"), STYLE_ISSUE.EXTRA_LABELS, `${String(extra + 1)} labels`);\n }\n put(\"label\", canonText(text, at(\"label\")));\n readLabelLook(label, node, put, at);\n}\n\n/**\n * Reads a label's look: its color, font and, for a node label, its position.\n * @param label - the label element\n * @param node - whether it is a node label\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readLabelLook(label: unknown, node: boolean, put: PutValue, at: SiteOf): void {\n readColor(treeAttr(label, \"textColor\"), \"labelColor\", null, put, at);\n put(\"labelSize\", canonNumber(treeAttr(label, \"fontSize\"), at(\"labelSize\")));\n put(\"labelFont\", canonText(treeAttr(label, \"fontFamily\"), at(\"labelFont\")));\n const style = treeAttr(label, \"fontStyle\");\n if (style !== undefined) {\n const known = FONT_STYLES.get(style.trim().toLowerCase());\n if (known === undefined) {\n noteAt(at(\"labelWeight\"), STYLE_ISSUE.UNKNOWN_VALUE, style.slice(0, MAX_STYLE_VALUE_LENGTH));\n } else {\n put(\"labelWeight\", known[0]);\n put(\"labelItalic\", known[1]);\n }\n }\n const position = node ? treeAttr(label, \"modelPosition\") : undefined;\n if (position !== undefined) {\n const known = YED_POSITIONS.get(position.trim().toLowerCase());\n if (known === undefined) {\n noteAt(at(\"labelPosition\"), STYLE_ISSUE.UNKNOWN_VALUE, position.slice(0, MAX_STYLE_VALUE_LENGTH));\n }\n put(\"labelPosition\", known ?? null);\n }\n}\n\n/**\n * The shape of a node realizer: its `y:Shape` where it has one, a GenericNode's configuration, or the realizer\n * type itself for one that draws an image (SVG, image, table, UML).\n * @param real - the realizer\n * @param at - the sites\n * @returns the shape, or null\n */\nfunction realizerShape(real: Realizer, at: SiteOf): string | null {\n const shape = treeChild(real.r, \"Shape\");\n if (shape !== undefined) {\n return canonEnum(\"shape\", treeAttr(shape, \"type\"), \"yed\", at(\"shape\"));\n }\n if (real.type === \"ShapeNode\" || real.type === \"GroupNode\" || real.type === \"GenericGroupNode\") {\n return null;\n }\n if (real.type === \"GenericNode\") {\n const conf = treeAttr(real.r, \"configuration\") ?? \"\";\n const flowchart = flowchartShape(conf);\n if (flowchart !== null) {\n return flowchart;\n }\n const lower = conf.slice(0, MAX_STYLE_VALUE_LENGTH).toLowerCase();\n for (const [word, value] of GENERIC_SHAPES) {\n if (lower.includes(word)) {\n return value;\n }\n }\n if (lower.length === 0) {\n return null;\n }\n noteAt(at(\"shape\"), STYLE_ISSUE.UNKNOWN_VALUE, lower);\n return `other:${lower}`;\n }\n noteAt(at(\"shape\"), STYLE_ISSUE.UNKNOWN_VALUE, real.type);\n return `other:${real.type}`;\n}\n\n/**\n * Reads one node realizer.\n * @param real - the realizer\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readNode(real: Realizer, put: PutValue, at: SiteOf): void {\n const { r } = real;\n const fill = treeChild(r, \"Fill\");\n if (fill !== undefined) {\n if (treeAttr(fill, \"hasColor\") === \"false\" || treeAttr(fill, \"transparent\") === \"true\") {\n noteAt(at(\"fill\"), STYLE_ISSUE.NO_FILL, \"transparent\");\n put(\"fillOpacity\", 0);\n } else {\n readColor(treeAttr(fill, \"color\"), \"fill\", \"fillOpacity\", put, at);\n const second = treeAttr(fill, \"color2\");\n if (second !== undefined) {\n noteAt(at(\"fill\"), STYLE_ISSUE.GRADIENT, second);\n }\n }\n }\n const border = treeChild(r, \"BorderStyle\");\n if (border !== undefined) {\n if (treeAttr(border, \"hasColor\") === \"false\") {\n put(\"borderWidth\", 0);\n } else {\n readColor(treeAttr(border, \"color\"), \"borderColor\", null, put, at);\n put(\"borderWidth\", canonNumber(treeAttr(border, \"width\"), at(\"borderWidth\")));\n }\n put(\"borderStyle\", canonEnum(\"borderStyle\", treeAttr(border, \"type\"), \"yed\", at(\"borderStyle\")));\n }\n const geometry = treeChild(r, \"Geometry\");\n put(\"width\", canonNumber(treeAttr(geometry, \"width\"), at(\"width\")));\n put(\"height\", canonNumber(treeAttr(geometry, \"height\"), at(\"height\")));\n put(\"shape\", realizerShape(real, at));\n readLabels(treeChildren(r, \"NodeLabel\"), true, put, at);\n}\n\n/**\n * Reads one edge realizer.\n * @param real - the realizer\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readEdge(real: Realizer, put: PutValue, at: SiteOf): void {\n const { r } = real;\n const line = treeChild(r, \"LineStyle\");\n if (line !== undefined) {\n readColor(treeAttr(line, \"color\"), \"color\", \"opacity\", put, at);\n put(\"width\", canonNumber(treeAttr(line, \"width\"), at(\"width\")));\n put(\"lineStyle\", canonEnum(\"lineStyle\", treeAttr(line, \"type\"), \"yed\", at(\"lineStyle\")));\n }\n const arrows = treeChild(r, \"Arrows\");\n if (arrows !== undefined) {\n put(\"sourceArrow\", canonEnum(\"arrow\", treeAttr(arrows, \"source\"), \"yed\", at(\"sourceArrow\")));\n put(\"targetArrow\", canonEnum(\"arrow\", treeAttr(arrows, \"target\"), \"yed\", at(\"targetArrow\")));\n }\n put(\"curved\", edgeCurved(real));\n readLabels(treeChildren(r, \"EdgeLabel\"), false, put, at);\n}\n\n/**\n * Whether yEd draws an edge curved: an arc always; a Bezier, quad curve, spline or generic edge only through its\n * control points (with none it is a straight line); a polyline only when it smooths bends it has.\n * @param real - the edge realizer\n * @returns true when curved, null when a polyline does not say whether it smooths\n */\nfunction edgeCurved(real: Realizer): boolean | null {\n if (real.type === \"ArcEdge\") {\n return true;\n }\n const bent = treeChildren(treeChild(real.r, \"Path\"), \"Point\").length > 0;\n if (real.type !== \"PolyLineEdge\") {\n return bent;\n }\n const smoothed = treeAttr(treeChild(real.r, \"BendStyle\"), \"smoothed\");\n return smoothed === undefined ? null : smoothed === \"true\" && bent;\n}\n\n/**\n * An edge's bends: the points of its `y:Path`, relative to the centers of its two nodes. yEd draws a polyline through\n * them; a curve type (Bezier, quad curve, spline) passes near them as its control points.\n * @param real - the edge realizer\n * @param centers - each node's center, x and y\n * @param source - the source node's index\n * @param target - the target node's index\n * @returns the `bends` value, or null without bends\n */\nfunction edgeBends(real: Realizer, centers: Float64Array, source: number, target: number): string | null {\n const points = treeChildren(treeChild(real.r, \"Path\"), \"Point\").map((p): BendPoint => [\n Number(treeAttr(p, \"x\")),\n Number(treeAttr(p, \"y\")),\n ]);\n const at = (k: number): BendPoint => [centers[2 * k], centers[2 * k + 1]];\n return canonBends(at(source), at(target), points, true);\n}\n\n/** Canonical values per property, by element index. */\nexport type ValueColumns = Record<string, (StyleValue | null)[]>;\n\n/**\n * A collector of canonical values for one target.\n * @param n - the element count\n * @returns the values and a setter for element i\n */\nexport function valueColumns(n: number): {\n readonly values: ValueColumns;\n put(i: number, property: string, value: StyleValue | null): void;\n} {\n const values: ValueColumns = Object.create(null) as ValueColumns;\n return {\n values,\n put(i, property, value) {\n if (value !== null) {\n values[property] ??= new Array<StyleValue | null>(n).fill(null);\n values[property][i] = value;\n }\n },\n };\n}\n\n/** What the yEd reader read. */\nexport interface YedRead {\n /** Node values. */\n readonly node: ValueColumns;\n /** Edge values. */\n readonly edge: ValueColumns;\n}\n\n/**\n * The yEd styles of a graph: each element's realizer read into canonical values.\n * @param snapshot - the graph\n * @param notes - where problems are noted\n * @param budget - the work budget\n * @returns the values, or null when no element has a yEd realizer\n */\nexport function readYedStyles(snapshot: GraphSnapshot, notes: StyleNotes, budget: StyleWorkBudget): YedRead | null {\n let found = false;\n // each node's center, read with the node, for its edges' bends; NaN for a node without yEd graphics\n const centers = new Float64Array(2 * snapshot.nodeCount).fill(Number.NaN);\n const read = (target: StyleTarget): ValueColumns => {\n const table = target === \"node\" ? snapshot.nodes : snapshot.edges;\n const n = target === \"node\" ? snapshot.nodeCount : snapshot.edgeCount;\n const names = target === \"node\" ? NODE_REALIZERS : EDGE_REALIZERS;\n const columns = treeColumns(table);\n const out = valueColumns(n);\n if (columns.length === 0) {\n return out.values;\n }\n for (let i = 0; i < n; i++) {\n budget.spend(target, columns.length);\n let real: Realizer | null = null;\n for (let c = 0; c < columns.length && real === null; c++) {\n real = realizerOf(plainCell(table.value(columns[c], i)), names);\n }\n if (real === null) {\n continue;\n }\n found = true;\n const at: SiteOf = (property) => ({ notes, target, property, element: i, budget });\n const put: PutValue = (property, value) => {\n out.put(i, property, value);\n };\n if (target === \"node\") {\n readNode(real, put, at);\n const geometry = treeChild(real.r, \"Geometry\");\n centers[2 * i] = Number(treeAttr(geometry, \"x\")) + Number(treeAttr(geometry, \"width\")) / 2;\n centers[2 * i + 1] = Number(treeAttr(geometry, \"y\")) + Number(treeAttr(geometry, \"height\")) / 2;\n } else {\n readEdge(real, put, at);\n put(\"bends\", edgeBends(real, centers, snapshot.edgeSource(i), snapshot.edgeTarget(i)));\n }\n }\n return out.values;\n };\n const node = read(\"node\");\n const edge = read(\"edge\");\n return found ? { node, edge } : null;\n}\n\n// ============================================================ writing\n\n/**\n * What the GraphML writer holds natively: yEd `y:ShapeNode` and `y:PolyLineEdge` graphics. The `graphty.styles`\n * block is a graph `<data>` under its own key, and the per-element values its rules read are keys of their own.\n * @category Built-in formats\n */\nexport const GRAPHML_STYLE_CAPABILITIES: StyleWriteCapabilities = Object.freeze({\n node: Object.freeze([\n \"fill\",\n \"fillOpacity\",\n \"borderColor\",\n \"borderWidth\",\n \"borderStyle\",\n \"shape\",\n \"width\",\n \"height\",\n \"label\",\n \"labelColor\",\n \"labelSize\",\n \"labelFont\",\n \"labelWeight\",\n \"labelItalic\",\n \"labelPosition\",\n ] as const),\n edge: Object.freeze([\n \"color\",\n \"opacity\",\n \"width\",\n \"lineStyle\",\n \"sourceArrow\",\n \"targetArrow\",\n \"curved\",\n \"bends\",\n \"label\",\n \"labelColor\",\n \"labelSize\",\n \"labelFont\",\n \"labelWeight\",\n \"labelItalic\",\n ] as const),\n block: \"attributes\",\n});\n\n/** A written value and whether it is the exact value. */\ninterface Written {\n readonly value: string;\n readonly exact: boolean;\n}\n\n/** yEd's ShapeNode types, by the neutral shape each draws exactly. */\nexport const YED_SHAPES: ReadonlyMap<string, string> = new Map([\n [\"ellipse\", \"ellipse\"],\n [\"rectangle\", \"rectangle\"],\n [\"round-rectangle\", \"roundrectangle\"],\n [\"triangle\", \"triangle\"],\n [\"diamond\", \"diamond\"],\n [\"hexagon\", \"hexagon\"],\n [\"octagon\", \"octagon\"],\n [\"parallelogram\", \"parallelogram\"],\n [\"trapezoid\", \"trapezoid\"],\n [\"star\", \"star5\"],\n]);\n\n/** yEd's line types, by the neutral line style each draws exactly. */\nexport const YED_LINES: ReadonlyMap<string, string> = new Map([\n [\"solid\", \"line\"],\n [\"dashed\", \"dashed\"],\n [\"dotted\", \"dotted\"],\n [\"dash-dot\", \"dashed_dotted\"],\n]);\n\n/** yEd's arrows, by the neutral arrow each draws exactly. */\nexport const YED_ARROWS: ReadonlyMap<string, string> = new Map([\n [\"none\", \"none\"],\n [\"triangle\", \"standard\"],\n [\"triangle-open\", \"white_delta\"],\n [\"vee\", \"concave\"],\n [\"tee\", \"t_shape\"],\n [\"diamond\", \"diamond\"],\n [\"diamond-open\", \"white_diamond\"],\n [\"circle\", \"circle\"],\n [\"circle-open\", \"white_circle\"],\n [\"square\", \"skewed_dash\"],\n [\"crow\", \"crows_foot_many\"],\n]);\n\n/** yEd's label positions in the internal model, by neutral position. */\nconst YED_MODEL_POSITIONS: ReadonlyMap<string, string> = new Map([\n [\"center\", \"c\"],\n [\"top\", \"t\"],\n [\"bottom\", \"b\"],\n [\"left\", \"l\"],\n [\"right\", \"r\"],\n [\"top-left\", \"tl\"],\n [\"top-right\", \"tr\"],\n [\"bottom-left\", \"bl\"],\n [\"bottom-right\", \"br\"],\n]);\n\n/**\n * A value of a table, or the nearest value the table has.\n * @param table - neutral value to yEd value\n * @param value - the neutral value\n * @param nearest - the yEd value written when the table has none\n * @returns the written value\n */\nexport function yedValue(table: ReadonlyMap<string, string>, value: string, nearest: string): Written {\n const exact = table.get(value);\n if (exact !== undefined) {\n return { value: exact, exact: true };\n }\n // a value the reader kept as other:<raw> goes back as written\n return value.startsWith(\"other:\") ? { value: value.slice(6), exact: true } : { value: nearest, exact: false };\n}\n\n/**\n * A color with an alpha from an opacity, as yEd writes it: `#RRGGBB`, or `#RRGGBBAA` with the alpha last.\n * @param color - the canonical color\n * @param opacity - the opacity, or null\n * @returns the text\n */\nexport function yedColor(color: string, opacity: StyleValue | null): string {\n const hex = color.toUpperCase();\n if (typeof opacity !== \"number\" || opacity >= 1) {\n return hex;\n }\n return (\n hex +\n Math.round(Math.max(0, opacity) * 255)\n .toString(16)\n .toUpperCase()\n .padStart(2, \"0\")\n );\n}\n\n/** Records a value written as the nearest one yEd has. */\ntype Approximate = (property: string, value: StyleValue) => void;\n\n/**\n * A value in yEd's spelling, recorded as approximated when yEd has no exact one.\n * @param table - yEd's spellings\n * @param value - the neutral value\n * @param nearest - the spelling written when there is no exact one\n * @param property - the property, for the approximation note\n * @param approximate - records approximations\n * @returns the spelling\n */\nexport function yedSpelled(\n table: ReadonlyMap<string, string>,\n value: string,\n nearest: string,\n property: string,\n approximate: Approximate,\n): string {\n const w = yedValue(table, value, nearest);\n if (!w.exact) {\n approximate(property, value);\n }\n return w.value;\n}\n\n/** One element's value of a property. */\ntype GetValue = (property: string) => StyleValue | null;\n\n/**\n * The label attributes and text of one element.\n * @param get - the element's values\n * @param node - whether it is a node label (which has a position)\n * @param approximate - records approximations\n * @returns the label element, or null when the element has no label text\n */\nfunction labelTree(get: GetValue, node: boolean, approximate: Approximate): Tree | null {\n const text = get(\"label\");\n if (typeof text !== \"string\" || text.trim().length === 0) {\n return null;\n }\n const label: Tree = {};\n const font = get(\"labelFont\");\n if (typeof font === \"string\") {\n label[\"@_fontFamily\"] = font;\n }\n const size = get(\"labelSize\");\n if (typeof size === \"number\") {\n label[\"@_fontSize\"] = String(size);\n }\n const weight = get(\"labelWeight\");\n const italic = get(\"labelItalic\");\n if (weight !== null || italic !== null) {\n const style = (weight === \"bold\" ? \"bold\" : \"\") + (italic === true ? \"italic\" : \"\");\n label[\"@_fontStyle\"] = style.length === 0 ? \"plain\" : style;\n }\n const color = get(\"labelColor\");\n if (typeof color === \"string\") {\n label[\"@_textColor\"] = color.toUpperCase();\n }\n const position = node ? get(\"labelPosition\") : null;\n if (typeof position === \"string\") {\n const written = YED_MODEL_POSITIONS.get(position);\n if (written === undefined) {\n approximate(\"labelPosition\", position);\n }\n label[\"@_modelName\"] = \"internal\";\n label[\"@_modelPosition\"] = written ?? \"c\";\n }\n label[\"#text\"] = text;\n return label;\n}\n\n/**\n * A node's `y:ShapeNode` from its values.\n * @param get - the node's values\n * @param at - the node's position from the graphics it had, or null\n * @param approximate - records approximations\n * @returns the graphics tree\n */\nfunction shapeNodeTree(get: GetValue, at: readonly [string, string] | null, approximate: Approximate): Tree {\n const node: Tree = {};\n node[\"y:Geometry\"] = geometryTree(get, at);\n const fill = get(\"fill\");\n const fillOpacity = get(\"fillOpacity\");\n if (typeof fill === \"string\") {\n node[\"y:Fill\"] = { \"@_color\": yedColor(fill, fillOpacity), \"@_transparent\": \"false\" };\n } else if (fillOpacity === 0) {\n node[\"y:Fill\"] = { \"@_hasColor\": \"false\", \"@_transparent\": \"false\" };\n }\n const border = lineTree(get, [\"borderColor\", \"borderWidth\", \"borderStyle\"], approximate);\n if (border !== null) {\n node[\"y:BorderStyle\"] = border;\n }\n const label = labelTree(get, true, approximate);\n if (label !== null) {\n node[\"y:NodeLabel\"] = label;\n }\n const shape = get(\"shape\");\n if (typeof shape === \"string\") {\n node[\"y:Shape\"] = {\n \"@_type\": yedSpelled(YED_SHAPES, shape, shape === \"vee\" ? \"triangle\" : \"rectangle\", \"shape\", approximate),\n };\n }\n return { \"y:ShapeNode\": node };\n}\n\n/**\n * A node's `y:Geometry`: its size, and its position from the graphics it had.\n * @param get - the node's values\n * @param at - the node's position, or null\n * @returns the geometry\n */\nfunction geometryTree(get: GetValue, at: readonly [string, string] | null): Tree {\n const geometry: Tree = {};\n const height = get(\"height\");\n const width = get(\"width\");\n if (typeof height === \"number\") {\n geometry[\"@_height\"] = String(height);\n }\n if (typeof width === \"number\") {\n geometry[\"@_width\"] = String(width);\n }\n if (at !== null) {\n geometry[\"@_x\"] = at[0];\n geometry[\"@_y\"] = at[1];\n }\n return geometry;\n}\n\n/**\n * A `y:BorderStyle` or `y:LineStyle`: a color, a width and a line type. A node's border color is written opaque; an\n * edge's color carries its opacity.\n * @param get - the element's values\n * @param properties - the color, width and style properties\n * @param approximate - records approximations\n * @param opacity - the opacity of the color, for an edge's line\n * @returns the element, or null when none of the three is set\n */\nfunction lineTree(\n get: GetValue,\n properties: readonly [string, string, string],\n approximate: Approximate,\n opacity?: StyleValue | null,\n): Tree | null {\n const [colorKey, widthKey, styleKey] = properties;\n const color = get(colorKey);\n const width = get(widthKey);\n const style = get(styleKey);\n if (color === null && width === null && style === null) {\n return null;\n }\n const line: Tree = {};\n if (typeof color === \"string\") {\n line[\"@_color\"] = opacity === undefined ? color.toUpperCase() : yedColor(color, opacity);\n }\n if (typeof style === \"string\") {\n const nearest = styleKey === \"lineStyle\" && style === \"long-dash\" ? \"dashed\" : \"line\";\n line[\"@_type\"] = yedSpelled(YED_LINES, style, nearest, styleKey, approximate);\n }\n if (typeof width === \"number\") {\n line[\"@_width\"] = String(width);\n }\n return line;\n}\n\n/**\n * An edge's `y:PolyLineEdge` from its values.\n * @param get - the edge's values\n * @param path - the `y:Path` of the graphics it had, or undefined\n * @param approximate - records approximations\n * @returns the graphics tree\n */\nfunction polyLineEdgeTree(get: GetValue, path: unknown, approximate: Approximate): Tree {\n const edge: Tree = {};\n if (path !== undefined) {\n edge[\"y:Path\"] = path;\n }\n const line = lineTree(get, [\"color\", \"width\", \"lineStyle\"], approximate, get(\"opacity\"));\n if (line !== null) {\n edge[\"y:LineStyle\"] = line;\n }\n const source = get(\"sourceArrow\");\n const target = get(\"targetArrow\");\n if (source !== null || target !== null) {\n const arrow = (property: string, value: StyleValue | null): string =>\n typeof value === \"string\" ? yedSpelled(YED_ARROWS, value, \"standard\", property, approximate) : \"none\";\n edge[\"y:Arrows\"] = { \"@_source\": arrow(\"sourceArrow\", source), \"@_target\": arrow(\"targetArrow\", target) };\n }\n const label = labelTree(get, false, approximate);\n if (label !== null) {\n edge[\"y:EdgeLabel\"] = label;\n }\n const curved = get(\"curved\");\n if (typeof curved === \"boolean\") {\n edge[\"y:BendStyle\"] = { \"@_smoothed\": String(curved) };\n }\n return { \"y:PolyLineEdge\": edge };\n}\n\n/**\n * Each element's values of the properties the writer writes, as a getter per element.\n * @param picture - each element's value of a property\n * @param target - nodes or edges\n * @returns the getter\n */\nfunction getter(\n picture: (target: StyleTarget, property: string) => readonly (StyleValue | null)[],\n target: StyleTarget,\n): (i: number) => GetValue {\n const columns = new Map<string, readonly (StyleValue | null)[]>();\n for (const p of GRAPHML_STYLE_CAPABILITIES[target]) {\n columns.set(p, picture(target, p));\n }\n return (i) => (property) => columns.get(property)?.[i] ?? null;\n}\n\n/**\n * For a file graphty wrote: where a value read from the yEd graphics is what the writer writes for the block's own\n * value (a pentagon written as a hexagon, an opacity rounded to yEd's 255 steps), the block's exact value is the\n * truth, so a re-import gives back the same rules; a value another program changed since stays the truth.\n * @param read - the values the reader read, changed in place\n * @param picture - each element's value of a property under the block's rules\n * @param counts - the node and edge counts\n * @param counts.node - the node count\n * @param counts.edge - the edge count\n * @param notes - a scratch note list for reading back what the writer writes\n */\nexport function exactFromBlock(\n read: YedRead,\n picture: (target: StyleTarget, property: string) => readonly (StyleValue | null)[],\n counts: { readonly node: number; readonly edge: number },\n notes: StyleNotes,\n): void {\n for (const target of [\"node\", \"edge\"] as const) {\n const values = read[target];\n const get = getter(picture, target);\n for (let i = 0; i < counts[target]; i++) {\n const want = get(i);\n const back = writtenAndReadBack(target, want, notes);\n if (back === null) {\n continue;\n }\n for (const property of GRAPHML_STYLE_CAPABILITIES[target]) {\n const native = values[property]?.[i] ?? null;\n const w = want(property);\n if (native !== w && native === (back.get(property) ?? null)) {\n values[property] ??= new Array<StyleValue | null>(counts[target]).fill(null);\n values[property][i] = w;\n }\n }\n }\n }\n}\n\n/**\n * An element's values written as the writer writes them and read back as the reader reads them.\n * @param target - nodes or edges\n * @param want - its values\n * @param notes - a scratch for the notes the round trip makes\n * @returns the values read back, by property, or null when the written graphics hold no realizer\n */\nfunction writtenAndReadBack(target: StyleTarget, want: GetValue, notes: StyleNotes): Map<string, StyleValue> | null {\n const ignore: Approximate = () => undefined;\n const tree = target === \"node\" ? shapeNodeTree(want, null, ignore) : polyLineEdgeTree(want, undefined, ignore);\n const real = realizerOf(tree, target === \"node\" ? NODE_REALIZERS : EDGE_REALIZERS);\n if (real === null) {\n return null;\n }\n const back = new Map<string, StyleValue>();\n const at: SiteOf = (property) => ({ notes, target, property });\n const put: PutValue = (property, value) => {\n if (value !== null) {\n back.set(property, value);\n }\n };\n if (target === \"node\") {\n readNode(real, put, at);\n } else {\n readEdge(real, put, at);\n }\n return back;\n}\n\n/** A GraphML export with styles worked out. */\ninterface GraphmlStyledExport {\n /** The graph to write: the yFiles drawing columns replaced by yEd graphics written from the styles. */\n readonly snapshot: GraphSnapshot;\n /** W_STYLE_APPROXIMATED for every value written as the nearest one yEd has. */\n readonly notes: readonly LossNote[];\n}\n\n/** The yFiles key type of the written node and edge graphics. */\nconst GRAPHICS_TYPES: Readonly<Record<StyleTarget, string>> = { node: \"nodegraphics\", edge: \"edgegraphics\" };\n\n/**\n * A node's position from the graphics it had: a yEd realizer's `y:Geometry` x and y, or a yFiles 3 `y:RectD`'s.\n * @param table - the node table\n * @param columns - its tree columns\n * @param i - the node\n * @returns the x and y as written, or null\n */\nfunction keptPosition(table: GraphSnapshot[\"nodes\"], columns: readonly string[], i: number): [string, string] | null {\n for (const name of columns) {\n const tree = plainCell(table.value(name, i));\n const real = realizerOf(tree, NODE_REALIZERS);\n const geometry = real === null ? treeChild(tree, \"RectD\") : treeChild(real.r, \"Geometry\");\n const x = treeAttr(geometry, real === null ? \"X\" : \"x\");\n const y = treeAttr(geometry, real === null ? \"Y\" : \"y\");\n if (x !== undefined && y !== undefined) {\n return [x, y];\n }\n }\n return null;\n}\n\n/**\n * A node's `y:Geometry` x and y from the graph's position column, for a node with no yEd graphics of its own: the\n * column's coordinate read in its declared spelling (center, y up when it declares none), written as yEd places a\n * box, by its top-left corner with y growing downward.\n * @param snapshot - the graph\n * @param i - the node\n * @param get - the node's values (its drawn width and height)\n * @returns the x and y to write, or null when the node has no finite position\n */\nfunction columnPosition(snapshot: GraphSnapshot, i: number, get: GetValue): [string, string] | null {\n const column = snapshot.nodes.byRole(\"position\");\n if (column === null || column.meta.components < 2 || !column.isSet(i)) {\n return null;\n }\n const v = column.value(i) as ArrayLike<number>;\n const width = get(\"width\");\n const height = get(\"height\");\n const size: [number, number] = [typeof width === \"number\" ? width : 0, typeof height === \"number\" ? height : 0];\n const p: [number, number, number] = [v[0], v[1], 0];\n toNeutral(p, column.meta.extra ?? {}, size, false);\n const [x, y] = toFilePositions(Float64Array.from(p), YED_SPELLING, {\n width: Float64Array.of(size[0]),\n height: Float64Array.of(size[1]),\n });\n return Number.isFinite(x) && Number.isFinite(y) ? [String(x), String(y)] : null;\n}\n\n/** How yEd spells a node's place: its box's top-left corner, y growing downward. */\nconst YED_SPELLING: PositionColumnExtra = { yAxis: \"down\", anchor: \"top-left\" };\n\n/**\n * An edge's `y:Path` (its bends) from the yEd graphics it had.\n * @param table - the edge table\n * @param columns - its tree columns\n * @param e - the edge\n * @returns the path, or undefined\n */\nfunction keptPath(table: GraphSnapshot[\"edges\"], columns: readonly string[], e: number): unknown {\n for (const name of columns) {\n const real = realizerOf(plainCell(table.value(name, e)), EDGE_REALIZERS);\n const path = real === null ? undefined : treeChild(real.r, \"Path\");\n if (path !== undefined) {\n return path;\n }\n }\n return undefined;\n}\n\n/**\n * An edge's `y:Path` with its points placed from its `bends` value between the written node centers, so the bends\n * read back as written; the ports of the path it had are kept. Without a value, or without both centers, the path it\n * had.\n * @param kept - the path from the graphics the edge had, or undefined\n * @param bends - the edge's `bends` value\n * @param ends - the written centers of its source and target\n * @returns the path, or undefined\n */\nfunction pathWithBends(kept: unknown, bends: StyleValue | null, ends: readonly [BendPoint, BendPoint]): unknown {\n const points = typeof bends === \"string\" ? bendsToPoints(ends[0], ends[1], bends, true) : null;\n if (points === null) {\n return kept;\n }\n const path: Tree = {};\n for (const port of [\"sx\", \"sy\", \"tx\", \"ty\"]) {\n path[`@_${port}`] = treeAttr(kept, port) ?? \"0.0\";\n }\n path[\"y:Point\"] = points.map(([x, y]) => ({ \"@_x\": String(x), \"@_y\": String(y) }));\n return path;\n}\n\n/**\n * A column name not yet taken in a table.\n * @param table - the table\n * @param base - the preferred name\n * @returns the name\n */\nfunction freeName(table: GraphSnapshot[\"nodes\"], base: string): string {\n let name = base;\n let k = 2;\n while (table.has(name)) {\n name = `${base}#${String(k)}`;\n k++;\n }\n return name;\n}\n\n/**\n * Works out a GraphML export with styles: every node and edge column made from yFiles keys (the graphics trees,\n * the typed `yfiles.*` columns and yFiles 3's drawing state) is replaced by yEd graphics written from what graphty\n * draws, keeping each node's position and each edge's bends from the graphics it had; graph data from yFiles 3\n * keys goes too, since its `y:` elements are not yEd's.\n * @param snapshot - the graph handed to the exporter\n * @param input - the styles, or undefined when none are written\n * @returns the styled export, or null without styles\n */\nexport function graphmlStyledExport(\n snapshot: GraphSnapshot,\n input: ExporterStyleInput | undefined,\n): GraphmlStyledExport | null {\n if (input === undefined) {\n return null;\n }\n const approximated = new StyleApproximations();\n const approximateFor =\n (target: StyleTarget): Approximate =>\n (property, value) => {\n approximated.add(target, property, value);\n };\n const picture = (target: StyleTarget, property: string): readonly (StyleValue | null)[] =>\n input.picture(target, property as never);\n const nodeColumns = treeColumns(snapshot.nodes);\n const edgeColumns = treeColumns(snapshot.edges);\n const getNode = getter(picture, \"node\");\n const getEdge = getter(picture, \"edge\");\n const nodeTrees: (Tree | null)[] = [];\n for (let i = 0; i < snapshot.nodeCount; i++) {\n const get = getNode(i);\n const at = keptPosition(snapshot.nodes, nodeColumns, i) ?? columnPosition(snapshot, i, get);\n nodeTrees.push(shapeNodeTree(get, at, approximateFor(\"node\")));\n }\n const centers = nodeTrees.map((tree): BendPoint => {\n const geometry = treeChild(treeChild(tree, \"ShapeNode\"), \"Geometry\");\n const at = (k: string): number => Number(treeAttr(geometry, k) ?? Number.NaN);\n return [at(\"x\") + at(\"width\") / 2, at(\"y\") + at(\"height\") / 2];\n });\n const edgeTrees: (Tree | null)[] = [];\n for (let e = 0; e < snapshot.edgeCount; e++) {\n const get = getEdge(e);\n const ends: readonly [BendPoint, BendPoint] = [\n centers[snapshot.edgeSource(e)],\n centers[snapshot.edgeTarget(e)],\n ];\n const path = pathWithBends(keptPath(snapshot.edges, edgeColumns, e), get(\"bends\"), ends);\n edgeTrees.push(polyLineEdgeTree(get, path, approximateFor(\"edge\")));\n }\n const out = snapshot.withColumns();\n for (const [table, trees, target] of [\n [out.nodes, nodeTrees, \"node\"],\n [out.edges, edgeTrees, \"edge\"],\n ] as const) {\n for (const name of yfilesColumns(table)) {\n table.remove(name);\n }\n const name = freeName(table, GRAPHICS_TYPES[target]);\n table.set(name, trees, {\n dtype: \"json\",\n nullable: true,\n origin: { format: \"graphml\", id: null, title: null, type: GRAPHICS_TYPES[target], namespace: \"yfiles\" },\n });\n }\n const yfiles3 = [...out.graph].filter(\n (col) => col.meta.origin?.namespace === \"yfiles\" && (col.meta.origin.type ?? \"\").includes(\"://\"),\n );\n for (const col of yfiles3) {\n out.graph.remove(col.meta.name);\n }\n return { snapshot: out, notes: approximated.notes(\"yEd\") };\n}\n"],"names":["name"],"mappings":";;;AAkBA,MAAM,WAAW,CAAC,MAAsB,OAAO,KAAK,MAAM,IAAI,GAAG,IAAI,GAAG;AAWjE,SAAS,WACZ,QACA,QACA,QACA,OACa;AACb,QAAM,OAAe;AACrB,QAAM,KAAK,OAAO,CAAC,IAAI,OAAO,CAAC;AAC/B,QAAM,MAAM,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK;AACrC,QAAM,UAAU,KAAK,KAAK,KAAK;AAC/B,MAAI,OAAO,WAAW,KAAK,WAAW,KAAK,CAAC,OAAO,SAAS,OAAO,GAAG;AAClE,WAAO;AAAA,EACX;AACA,QAAM,MAAgB,CAAA;AACtB,aAAW,CAAC,IAAI,EAAE,KAAK,QAAQ;AAC3B,UAAM,KAAK,KAAK,OAAO,CAAC;AACxB,UAAM,MAAM,KAAK,OAAO,CAAC,KAAK;AAC9B,UAAM,SAAS,KAAK,KAAK,KAAK,MAAM;AACpC,UAAM,UAAU,KAAK,KAAK,KAAK,MAAM;AACrC,QAAI,CAAC,OAAO,SAAS,KAAK,KAAK,CAAC,OAAO,SAAS,MAAM,GAAG;AACrD,aAAO;AAAA,IACX;AACA,QAAI,KAAK,GAAG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AACrB,UAAM,OAAwC;AAAA,MAC1C,QAAQ,SAAS,WAAW,CAAC,CAAC;AAAA,MAC9B,QAAQ,SAAS,WAAW,CAAC,CAAC;AAAA,IAAA;AAElC,UAAM,OAAO,cAAc,SAAS,SAAS,OAAO,aAAa,CAAC,GAAG,IAAI,OAAO,GAAG,IAAI;AACvF,cAAU,KAAK,iBAAiB,KAAK,MAAM,eAAe,MAAM,CAAC,CAAC;AAAA,EACtE;AACA,QAAM,MAAM,SAAS,YAAA;AACrB,aAAW,CAAC,OAAO,OAAO,MAAM,KAAK;AAAA,IACjC,CAAC,IAAI,OAAO,WAAW,MAAM;AAAA,IAC7B,CAAC,IAAI,OAAO,WAAW,MAAM;AAAA,EAAA,GACrB;AACR,eAAWA,SAAQ,cAAc,KAAK,GAAG;AACrC,YAAM,OAAOA,KAAI;AAAA,IACrB;AACA,UAAM,OAAO,SAAS,OAAO,eAAe,MAAM,CAAC;AACnD,UAAM,IAAI,MAAM,OAAO;AAAA,MACnB,OAAO;AAAA,MACP,UAAU;AAAA,MACV,QAAQ,EAAE,QAAQ,WAAW,IAAI,MAAM,OAAO,MAAM,MAAM,eAAe,MAAM,GAAG,WAAW,SAAA;AAAA,IAAS,CACzG;AAAA,EACL;AACA,QAAM,UAAU,CAAC,GAAG,IAAI,KAAK,EAAE;AAAA,IAC3B,CAAC,QAAQ,IAAI,KAAK,QAAQ,cAAc,aAAa,IAAI,KAAK,OAAO,QAAQ,IAAI,SAAS,KAAK;AAAA,EAAA;AAEnG,aAAW,OAAO,SAAS;AACvB,QAAI,MAAM,OAAO,IAAI,KAAK,IAAI;AAAA,EAClC;AACA,SAAO,EAAE,UAAU,KAAK,OAAO,aAAa,MAAM,KAAK,EAAA;AAC3D;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { p as plural, a as agree } from "./format-BpQBx8MZ.js";
|
|
2
|
-
import { s as styleFingerprint, a as STYLE_ISSUE, b as styleTag, w as writeStyleBlock, c as styleBlockLosses, r as resolveStyles, S as STYLE_BLOCK_NAME, d as canonicalFor, e as degreeValues, f as dataCell, p as plainCell } from "./block-
|
|
2
|
+
import { s as styleFingerprint, a as STYLE_ISSUE, b as styleTag, w as writeStyleBlock, c as styleBlockLosses, r as resolveStyles, S as STYLE_BLOCK_NAME, d as canonicalFor, e as degreeValues, f as dataCell, p as plainCell } from "./block-DiGq58c3.js";
|
|
3
3
|
const STYLE_ROLES = /* @__PURE__ */ new Set(["color", "size", "shape", "thickness", "hidden"]);
|
|
4
4
|
const TARGETS = ["node", "edge"];
|
|
5
5
|
function prepareStyleExport(snapshot, exporter, given, plain) {
|
|
@@ -445,4 +445,4 @@ export {
|
|
|
445
445
|
prepareStyleExport as p,
|
|
446
446
|
sharedInExportCall as s
|
|
447
447
|
};
|
|
448
|
-
//# sourceMappingURL=writer-
|
|
448
|
+
//# sourceMappingURL=writer-DMKvthQE.js.map
|