@graphty/graph-io 0.3.48 → 0.3.50
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-C2riR4NT.js → approximations-BRXsll0T.js} +2 -2
- package/dist/chunks/{approximations-C2riR4NT.js.map → approximations-BRXsll0T.js.map} +1 -1
- package/dist/chunks/bends-BGXjv_U4.js +129 -0
- package/dist/chunks/bends-BGXjv_U4.js.map +1 -0
- package/dist/chunks/{block-Cu22ewuS.js → block-yl0f_qLO.js} +931 -164
- package/dist/chunks/block-yl0f_qLO.js.map +1 -0
- package/dist/chunks/choose-CczZJaX_.js +717 -0
- package/dist/chunks/choose-CczZJaX_.js.map +1 -0
- package/dist/chunks/{codes-CV_Bhcyi.js → codes-BE2xir2k.js} +6 -2
- package/dist/chunks/codes-BE2xir2k.js.map +1 -0
- package/dist/chunks/{constants-D0LqcsLJ.js → constants-CKkYLPtt.js} +2 -2
- package/dist/chunks/{constants-D0LqcsLJ.js.map → constants-CKkYLPtt.js.map} +1 -1
- package/dist/chunks/{context-cgmmOxZ2.js → context-DizmppHy.js} +5 -4
- package/dist/chunks/{context-cgmmOxZ2.js.map → context-DizmppHy.js.map} +1 -1
- package/dist/chunks/{convert-BcQ8_jMo.js → convert-Ct2zelbQ.js} +7 -2
- package/dist/chunks/convert-Ct2zelbQ.js.map +1 -0
- package/dist/chunks/{credentials-BiQsnMTb.js → credentials-CmvJXYeH.js} +67 -16
- package/dist/chunks/credentials-CmvJXYeH.js.map +1 -0
- package/dist/chunks/{cx-export-BEeF6ymo.js → cx-export-Bt6NoqTQ.js} +3 -3
- package/dist/chunks/{cx-export-BEeF6ymo.js.map → cx-export-Bt6NoqTQ.js.map} +1 -1
- package/dist/chunks/descriptor-B28U25x4.js +60 -0
- package/dist/chunks/descriptor-B28U25x4.js.map +1 -0
- package/dist/chunks/{descriptor-BJ-W0Jd-.js → descriptor-Dhez_Cew.js} +11 -2
- package/dist/chunks/descriptor-Dhez_Cew.js.map +1 -0
- package/dist/chunks/{emit-CD8xnY8s.js → emit-7Jkpg0yd.js} +1788 -133
- package/dist/chunks/emit-7Jkpg0yd.js.map +1 -0
- package/dist/chunks/{escape-DH2Egt-l.js → escape-CuCIzNMB.js} +8 -8
- package/dist/chunks/{escape-DH2Egt-l.js.map → escape-CuCIzNMB.js.map} +1 -1
- package/dist/chunks/{export-CZ7VRm4I.js → export-Cha4dRFz.js} +45 -387
- package/dist/chunks/export-Cha4dRFz.js.map +1 -0
- package/dist/chunks/{exporter-ChjL5fmP.js → exporter-1Ajud15J.js} +9 -8
- package/dist/chunks/{exporter-ChjL5fmP.js.map → exporter-1Ajud15J.js.map} +1 -1
- package/dist/chunks/{exporter-BIdaoIgh.js → exporter-B6yvL3wy.js} +7 -7
- package/dist/chunks/{exporter-BIdaoIgh.js.map → exporter-B6yvL3wy.js.map} +1 -1
- package/dist/chunks/{exporter-Dcw7Ldtq.js → exporter-BP6otMO6.js} +6 -6
- package/dist/chunks/{exporter-Dcw7Ldtq.js.map → exporter-BP6otMO6.js.map} +1 -1
- package/dist/chunks/{exporter-DtVU80Fa.js → exporter-CA5q8ROP.js} +9 -8
- package/dist/chunks/{exporter-DtVU80Fa.js.map → exporter-CA5q8ROP.js.map} +1 -1
- package/dist/chunks/{exporter-bxxjOrDZ.js → exporter-CQQZFJ2v.js} +1284 -156
- package/dist/chunks/exporter-CQQZFJ2v.js.map +1 -0
- package/dist/chunks/format-BXiAb-1h.js +408 -0
- package/dist/chunks/format-BXiAb-1h.js.map +1 -0
- package/dist/chunks/{generic-CP6YD34u.js → generic-Dc21MAdg.js} +387 -31
- package/dist/chunks/generic-Dc21MAdg.js.map +1 -0
- package/dist/chunks/{importer-B87_fmVx.js → importer-C6NVpCXp.js} +327 -84
- package/dist/chunks/importer-C6NVpCXp.js.map +1 -0
- package/dist/chunks/{importer-DPZDN40-.js → importer-CKFe4q54.js} +25 -17
- package/dist/chunks/importer-CKFe4q54.js.map +1 -0
- package/dist/chunks/{importer-Bji2MeWr.js → importer-CKbUbsJA.js} +13 -10
- package/dist/chunks/{importer-Bji2MeWr.js.map → importer-CKbUbsJA.js.map} +1 -1
- package/dist/chunks/{importer-CB_zV5_L.js → importer-ClCsdgTJ.js} +208 -1104
- package/dist/chunks/importer-ClCsdgTJ.js.map +1 -0
- package/dist/chunks/{importer-e3huMZbm.js → importer-CyVZTrf0.js} +14 -10
- package/dist/chunks/importer-CyVZTrf0.js.map +1 -0
- package/dist/chunks/{importer-CVT-JyDE.js → importer-DgG4v1Ms.js} +1537 -355
- package/dist/chunks/importer-DgG4v1Ms.js.map +1 -0
- package/dist/chunks/{importer-Cyy6UseH.js → importer-asFUrIsj.js} +66 -13
- package/dist/chunks/importer-asFUrIsj.js.map +1 -0
- package/dist/chunks/{input-Ccg9I22A.js → input-CAxt_aV-.js} +4 -4
- package/dist/chunks/{input-Ccg9I22A.js.map → input-CAxt_aV-.js.map} +1 -1
- package/dist/chunks/{json-elements-By172SVq.js → json-elements-Cq76WjnZ.js} +4 -4
- package/dist/chunks/{json-elements-By172SVq.js.map → json-elements-Cq76WjnZ.js.map} +1 -1
- package/dist/chunks/{lexicon-u2SI5xcx.js → lexicon-IVRq2Uoo.js} +282 -74
- package/dist/chunks/lexicon-IVRq2Uoo.js.map +1 -0
- package/dist/chunks/{ontology-export-BwgMyuF0.js → ontology-export-OMo91mb0.js} +4 -4
- package/dist/chunks/{ontology-export-BwgMyuF0.js.map → ontology-export-OMo91mb0.js.map} +1 -1
- package/dist/chunks/{records-Cgvxz-Vx.js → records-NJiYvekn.js} +2 -2
- package/dist/chunks/{records-Cgvxz-Vx.js.map → records-NJiYvekn.js.map} +1 -1
- package/dist/chunks/{report-CgdsL9Hb.js → report-CwMfYa9J.js} +23 -23
- package/dist/chunks/{report-CgdsL9Hb.js.map → report-CwMfYa9J.js.map} +1 -1
- package/dist/chunks/round-trip-Cy3_SHRZ.js +79 -0
- package/dist/chunks/round-trip-Cy3_SHRZ.js.map +1 -0
- package/dist/chunks/{sigv4-LkAzsLAu.js → sigv4-BXwVbza3.js} +5 -5
- package/dist/chunks/sigv4-BXwVbza3.js.map +1 -0
- package/dist/chunks/{styles-CaABMoO1.js → styles-CAVmBLgp.js} +1237 -138
- package/dist/chunks/styles-CAVmBLgp.js.map +1 -0
- package/dist/chunks/styles-CPczw1Jz.js +1928 -0
- package/dist/chunks/styles-CPczw1Jz.js.map +1 -0
- package/dist/chunks/styles-boK6Ln54.js +2847 -0
- package/dist/chunks/styles-boK6Ln54.js.map +1 -0
- package/dist/chunks/{styles-yed-Cs1nmrjn.js → styles-yed-XeFBQ6VS.js} +506 -175
- package/dist/chunks/styles-yed-XeFBQ6VS.js.map +1 -0
- package/dist/chunks/{text-BuKQVMz2.js → text-ystE2bYi.js} +2 -2
- package/dist/chunks/{text-BuKQVMz2.js.map → text-ystE2bYi.js.map} +1 -1
- package/dist/csv.js +7 -7
- package/dist/cx.js +2 -2
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +8 -4
- package/dist/dot.js.map +1 -1
- package/dist/gexf.js +42 -12
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +848 -194
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +230 -193
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +3 -3
- package/dist/json.js +3 -2
- package/dist/neo4j.js +6 -6
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/positions.js +45 -3
- package/dist/positions.js.map +1 -1
- package/dist/sources-cypher.js +141 -23
- package/dist/sources-cypher.js.map +1 -1
- package/dist/sources-ndex.js +2 -2
- package/dist/sources-rest.js +32 -6
- package/dist/sources-rest.js.map +1 -1
- package/dist/sources-sparql.d.ts +1 -0
- package/dist/sources-sparql.js +439 -0
- package/dist/sources-sparql.js.map +1 -0
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +5 -1
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx/styles.d.ts +24 -1
- package/dist/src/formats/cx/styles.d.ts.map +1 -1
- package/dist/src/formats/cx/styles.js +117 -11
- package/dist/src/formats/cx/styles.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +1 -0
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cx2/styles.d.ts.map +1 -1
- package/dist/src/formats/cx2/styles.js +3 -1
- package/dist/src/formats/cx2/styles.js.map +1 -1
- package/dist/src/formats/cys/importer.d.ts.map +1 -1
- package/dist/src/formats/cys/importer.js +1 -0
- package/dist/src/formats/cys/importer.js.map +1 -1
- package/dist/src/formats/cys/styles.d.ts +2 -0
- package/dist/src/formats/cys/styles.d.ts.map +1 -1
- package/dist/src/formats/cys/styles.js +15 -7
- package/dist/src/formats/cys/styles.js.map +1 -1
- package/dist/src/formats/dot/drawing.d.ts +98 -0
- package/dist/src/formats/dot/drawing.d.ts.map +1 -0
- package/dist/src/formats/dot/drawing.js +734 -0
- package/dist/src/formats/dot/drawing.js.map +1 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +34 -2
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts +6 -1
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +170 -33
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/index.d.ts +3 -1
- package/dist/src/formats/dot/index.d.ts.map +1 -1
- package/dist/src/formats/dot/index.js +2 -1
- package/dist/src/formats/dot/index.js.map +1 -1
- package/dist/src/formats/dot/label-places.d.ts +41 -0
- package/dist/src/formats/dot/label-places.d.ts.map +1 -0
- package/dist/src/formats/dot/label-places.js +185 -0
- package/dist/src/formats/dot/label-places.js.map +1 -0
- package/dist/src/formats/dot/names.d.ts +13 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -1
- package/dist/src/formats/dot/names.js +13 -0
- package/dist/src/formats/dot/names.js.map +1 -1
- package/dist/src/formats/dot/record.d.ts +50 -0
- package/dist/src/formats/dot/record.d.ts.map +1 -0
- package/dist/src/formats/dot/record.js +275 -0
- package/dist/src/formats/dot/record.js.map +1 -0
- package/dist/src/formats/dot/styles.d.ts +72 -2
- package/dist/src/formats/dot/styles.d.ts.map +1 -1
- package/dist/src/formats/dot/styles.js +1500 -119
- package/dist/src/formats/dot/styles.js.map +1 -1
- package/dist/src/formats/gexf/dialog-metrics.d.ts +15 -0
- package/dist/src/formats/gexf/dialog-metrics.d.ts.map +1 -0
- package/dist/src/formats/gexf/dialog-metrics.js +59 -0
- package/dist/src/formats/gexf/dialog-metrics.js.map +1 -0
- package/dist/src/formats/gexf/importer.d.ts +7 -0
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +41 -5
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/preview.d.ts +77 -0
- package/dist/src/formats/gexf/preview.d.ts.map +1 -0
- package/dist/src/formats/gexf/preview.js +191 -0
- package/dist/src/formats/gexf/preview.js.map +1 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -1
- package/dist/src/formats/gexf/schema.js +2 -1
- package/dist/src/formats/gexf/schema.js.map +1 -1
- package/dist/src/formats/gexf/styles.d.ts +58 -31
- package/dist/src/formats/gexf/styles.d.ts.map +1 -1
- package/dist/src/formats/gexf/styles.js +848 -225
- package/dist/src/formats/gexf/styles.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +5 -2
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +258 -71
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +1 -1
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +1 -1
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/gml/positions.d.ts +7 -0
- package/dist/src/formats/gml/positions.d.ts.map +1 -1
- package/dist/src/formats/gml/positions.js +29 -7
- package/dist/src/formats/gml/positions.js.map +1 -1
- package/dist/src/formats/gml/styles.d.ts.map +1 -1
- package/dist/src/formats/gml/styles.js +754 -102
- package/dist/src/formats/gml/styles.js.map +1 -1
- package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-plain.js +6 -10
- package/dist/src/formats/graphml/styles-plain.js.map +1 -1
- package/dist/src/formats/graphml/styles-yed.d.ts +21 -15
- package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-yed.js +695 -164
- package/dist/src/formats/graphml/styles-yed.js.map +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.d.ts +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.js +431 -64
- package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts +3 -3
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
- package/dist/src/formats/graphml/yfiles.js +16 -6
- package/dist/src/formats/graphml/yfiles.js.map +1 -1
- package/dist/src/formats/json/dialect.d.ts +3 -2
- package/dist/src/formats/json/dialect.d.ts.map +1 -1
- package/dist/src/formats/json/dialect.js +39 -5
- package/dist/src/formats/json/dialect.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +13 -2
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +42 -6
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/index.d.ts +1 -1
- package/dist/src/formats/json/index.d.ts.map +1 -1
- package/dist/src/formats/json/index.js +1 -1
- package/dist/src/formats/json/index.js.map +1 -1
- package/dist/src/formats/json/positions.d.ts +5 -2
- package/dist/src/formats/json/positions.d.ts.map +1 -1
- package/dist/src/formats/json/positions.js +20 -4
- package/dist/src/formats/json/positions.js.map +1 -1
- package/dist/src/formats/json/styles.d.ts +12 -1
- package/dist/src/formats/json/styles.d.ts.map +1 -1
- package/dist/src/formats/json/styles.js +1843 -136
- package/dist/src/formats/json/styles.js.map +1 -1
- package/dist/src/formats/pajek/draw.d.ts +104 -0
- package/dist/src/formats/pajek/draw.d.ts.map +1 -0
- package/dist/src/formats/pajek/draw.js +382 -0
- package/dist/src/formats/pajek/draw.js.map +1 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +70 -51
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts +9 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +233 -102
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/index.d.ts +1 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -1
- package/dist/src/formats/pajek/index.js.map +1 -1
- package/dist/src/formats/pajek/styles.d.ts +15 -7
- package/dist/src/formats/pajek/styles.d.ts.map +1 -1
- package/dist/src/formats/pajek/styles.js +1395 -114
- package/dist/src/formats/pajek/styles.js.map +1 -1
- package/dist/src/formats/pajek/syntax.d.ts +10 -1
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
- package/dist/src/formats/pajek/syntax.js +26 -2
- package/dist/src/formats/pajek/syntax.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts +1 -0
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +65 -5
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/styles.d.ts +23 -3
- package/dist/src/formats/xgmml/styles.d.ts.map +1 -1
- package/dist/src/formats/xgmml/styles.js +277 -60
- package/dist/src/formats/xgmml/styles.js.map +1 -1
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/positions/convert.d.ts.map +1 -1
- package/dist/src/positions/convert.js +11 -1
- package/dist/src/positions/convert.js.map +1 -1
- package/dist/src/positions/extract.d.ts.map +1 -1
- package/dist/src/positions/extract.js +53 -1
- package/dist/src/positions/extract.js.map +1 -1
- package/dist/src/positions/index.d.ts +1 -1
- package/dist/src/positions/index.d.ts.map +1 -1
- package/dist/src/positions/types.d.ts +59 -0
- package/dist/src/positions/types.d.ts.map +1 -1
- package/dist/src/sources/builtins.d.ts +1 -1
- package/dist/src/sources/builtins.d.ts.map +1 -1
- package/dist/src/sources/builtins.js +8 -2
- package/dist/src/sources/builtins.js.map +1 -1
- package/dist/src/sources/context.d.ts.map +1 -1
- package/dist/src/sources/context.js +1 -0
- package/dist/src/sources/context.js.map +1 -1
- package/dist/src/sources/credentials.d.ts +50 -1
- package/dist/src/sources/credentials.d.ts.map +1 -1
- package/dist/src/sources/credentials.js +69 -0
- package/dist/src/sources/credentials.js.map +1 -1
- package/dist/src/sources/cypher/descriptor.d.ts.map +1 -1
- package/dist/src/sources/cypher/descriptor.js +5 -0
- package/dist/src/sources/cypher/descriptor.js.map +1 -1
- package/dist/src/sources/cypher/index.d.ts.map +1 -1
- package/dist/src/sources/cypher/index.js +125 -18
- package/dist/src/sources/cypher/index.js.map +1 -1
- package/dist/src/sources/cypher/params.d.ts +1 -1
- package/dist/src/sources/cypher/params.d.ts.map +1 -1
- package/dist/src/sources/cypher/query-builder.d.ts +17 -0
- package/dist/src/sources/cypher/query-builder.d.ts.map +1 -1
- package/dist/src/sources/cypher/query-builder.js +31 -0
- package/dist/src/sources/cypher/query-builder.js.map +1 -1
- package/dist/src/sources/ids.d.ts +5 -0
- package/dist/src/sources/ids.d.ts.map +1 -1
- package/dist/src/sources/ids.js +5 -0
- package/dist/src/sources/ids.js.map +1 -1
- package/dist/src/sources/params.d.ts +3 -0
- package/dist/src/sources/params.d.ts.map +1 -1
- package/dist/src/sources/rest/descriptor.d.ts.map +1 -1
- package/dist/src/sources/rest/descriptor.js +9 -0
- package/dist/src/sources/rest/descriptor.js.map +1 -1
- package/dist/src/sources/rest/openalex.d.ts +4 -2
- package/dist/src/sources/rest/openalex.d.ts.map +1 -1
- package/dist/src/sources/rest/openalex.js +4 -2
- package/dist/src/sources/rest/openalex.js.map +1 -1
- package/dist/src/sources/rest/source.d.ts.map +1 -1
- package/dist/src/sources/rest/source.js +38 -0
- package/dist/src/sources/rest/source.js.map +1 -1
- package/dist/src/sources/run.d.ts +2 -0
- package/dist/src/sources/run.d.ts.map +1 -1
- package/dist/src/sources/run.js +30 -3
- package/dist/src/sources/run.js.map +1 -1
- package/dist/src/sources/sigv4.d.ts +5 -3
- package/dist/src/sources/sigv4.d.ts.map +1 -1
- package/dist/src/sources/sigv4.js +6 -4
- package/dist/src/sources/sigv4.js.map +1 -1
- package/dist/src/sources/sparql/descriptor.d.ts +10 -0
- package/dist/src/sources/sparql/descriptor.d.ts.map +1 -0
- package/dist/src/sources/sparql/descriptor.js +64 -0
- package/dist/src/sources/sparql/descriptor.js.map +1 -0
- package/dist/src/sources/sparql/index.d.ts +28 -0
- package/dist/src/sources/sparql/index.d.ts.map +1 -0
- package/dist/src/sources/sparql/index.js +327 -0
- package/dist/src/sources/sparql/index.js.map +1 -0
- package/dist/src/sources/sparql/ntriples.d.ts +69 -0
- package/dist/src/sources/sparql/ntriples.d.ts.map +1 -0
- package/dist/src/sources/sparql/ntriples.js +180 -0
- package/dist/src/sources/sparql/ntriples.js.map +1 -0
- package/dist/src/sources/sparql/params.d.ts +27 -0
- package/dist/src/sources/sparql/params.d.ts.map +1 -0
- package/dist/src/sources/sparql/params.js +5 -0
- package/dist/src/sources/sparql/params.js.map +1 -0
- package/dist/src/sources/sparql/query.d.ts +73 -0
- package/dist/src/sources/sparql/query.d.ts.map +1 -0
- package/dist/src/sources/sparql/query.js +164 -0
- package/dist/src/sources/sparql/query.js.map +1 -0
- package/dist/src/sources/types.d.ts +60 -0
- package/dist/src/sources/types.d.ts.map +1 -1
- package/dist/src/styles/annotations.d.ts +61 -5
- package/dist/src/styles/annotations.d.ts.map +1 -1
- package/dist/src/styles/annotations.js +130 -22
- package/dist/src/styles/annotations.js.map +1 -1
- package/dist/src/styles/canon/bends.d.ts +46 -0
- package/dist/src/styles/canon/bends.d.ts.map +1 -1
- package/dist/src/styles/canon/bends.js +123 -0
- package/dist/src/styles/canon/bends.js.map +1 -1
- package/dist/src/styles/canon/color-tables.d.ts +6 -1
- package/dist/src/styles/canon/color-tables.d.ts.map +1 -1
- package/dist/src/styles/canon/color-tables.js +10 -4
- package/dist/src/styles/canon/color-tables.js.map +1 -1
- package/dist/src/styles/canon/color.d.ts +3 -1
- package/dist/src/styles/canon/color.d.ts.map +1 -1
- package/dist/src/styles/canon/color.js +103 -3
- package/dist/src/styles/canon/color.js.map +1 -1
- package/dist/src/styles/canon/enums.d.ts +2 -2
- package/dist/src/styles/canon/enums.d.ts.map +1 -1
- package/dist/src/styles/canon/enums.js +89 -7
- package/dist/src/styles/canon/enums.js.map +1 -1
- package/dist/src/styles/canon/graphviz.d.ts +12 -3
- package/dist/src/styles/canon/graphviz.d.ts.map +1 -1
- package/dist/src/styles/canon/graphviz.js +57 -9
- package/dist/src/styles/canon/graphviz.js.map +1 -1
- package/dist/src/styles/canon/number.d.ts +8 -0
- package/dist/src/styles/canon/number.d.ts.map +1 -1
- package/dist/src/styles/canon/number.js +18 -0
- package/dist/src/styles/canon/number.js.map +1 -1
- package/dist/src/styles/canon/text.d.ts +29 -2
- package/dist/src/styles/canon/text.d.ts.map +1 -1
- package/dist/src/styles/canon/text.js +156 -16
- package/dist/src/styles/canon/text.js.map +1 -1
- package/dist/src/styles/codes.d.ts +2 -0
- package/dist/src/styles/codes.d.ts.map +1 -1
- package/dist/src/styles/codes.js +2 -0
- package/dist/src/styles/codes.js.map +1 -1
- package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
- package/dist/src/styles/cyjs/cascade.js +1139 -79
- package/dist/src/styles/cyjs/cascade.js.map +1 -1
- package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
- package/dist/src/styles/cyjs/defaults-table.js +4 -0
- package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
- package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
- package/dist/src/styles/cyjs/emit.js +232 -10
- package/dist/src/styles/cyjs/emit.js.map +1 -1
- package/dist/src/styles/cyjs/face.d.ts +20 -0
- package/dist/src/styles/cyjs/face.d.ts.map +1 -0
- package/dist/src/styles/cyjs/face.js +332 -0
- package/dist/src/styles/cyjs/face.js.map +1 -0
- package/dist/src/styles/cyjs/mappers.d.ts +44 -1
- package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
- package/dist/src/styles/cyjs/mappers.js +475 -26
- package/dist/src/styles/cyjs/mappers.js.map +1 -1
- package/dist/src/styles/cyjs/routes.d.ts +53 -0
- package/dist/src/styles/cyjs/routes.d.ts.map +1 -0
- package/dist/src/styles/cyjs/routes.js +360 -0
- package/dist/src/styles/cyjs/routes.js.map +1 -0
- package/dist/src/styles/cytoscape/charts.d.ts +23 -0
- package/dist/src/styles/cytoscape/charts.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/charts.js +560 -0
- package/dist/src/styles/cytoscape/charts.js.map +1 -0
- package/dist/src/styles/cytoscape/emit.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/emit.js +156 -48
- package/dist/src/styles/cytoscape/emit.js.map +1 -1
- package/dist/src/styles/cytoscape/lexicon.d.ts +91 -3
- package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/lexicon.js +387 -77
- package/dist/src/styles/cytoscape/lexicon.js.map +1 -1
- package/dist/src/styles/cytoscape/mappings.d.ts +30 -0
- package/dist/src/styles/cytoscape/mappings.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/mappings.js +92 -0
- package/dist/src/styles/cytoscape/mappings.js.map +1 -1
- package/dist/src/styles/cytoscape/resolve.d.ts +42 -2
- package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/resolve.js +623 -17
- package/dist/src/styles/cytoscape/resolve.js.map +1 -1
- package/dist/src/styles/defaults.d.ts +46 -26
- package/dist/src/styles/defaults.d.ts.map +1 -1
- package/dist/src/styles/defaults.js +308 -71
- package/dist/src/styles/defaults.js.map +1 -1
- package/dist/src/styles/index.d.ts +4 -3
- package/dist/src/styles/index.d.ts.map +1 -1
- package/dist/src/styles/index.js +3 -2
- package/dist/src/styles/index.js.map +1 -1
- package/dist/src/styles/internal.d.ts +1 -0
- package/dist/src/styles/internal.d.ts.map +1 -1
- package/dist/src/styles/internal.js +1 -0
- package/dist/src/styles/internal.js.map +1 -1
- package/dist/src/styles/io/generic.d.ts.map +1 -1
- package/dist/src/styles/io/generic.js +56 -16
- package/dist/src/styles/io/generic.js.map +1 -1
- package/dist/src/styles/io/round-trip.d.ts +56 -0
- package/dist/src/styles/io/round-trip.d.ts.map +1 -0
- package/dist/src/styles/io/round-trip.js +138 -0
- package/dist/src/styles/io/round-trip.js.map +1 -0
- package/dist/src/styles/io/writer.d.ts.map +1 -1
- package/dist/src/styles/io/writer.js +6 -1
- package/dist/src/styles/io/writer.js.map +1 -1
- package/dist/src/styles/notes.d.ts.map +1 -1
- package/dist/src/styles/notes.js +1 -0
- package/dist/src/styles/notes.js.map +1 -1
- package/dist/src/styles/plan/features.d.ts +1 -1
- package/dist/src/styles/plan/features.d.ts.map +1 -1
- package/dist/src/styles/plan/features.js +22 -2
- package/dist/src/styles/plan/features.js.map +1 -1
- package/dist/src/styles/plan/index.d.ts +1 -1
- package/dist/src/styles/plan/index.d.ts.map +1 -1
- package/dist/src/styles/plan/index.js +1 -1
- package/dist/src/styles/plan/index.js.map +1 -1
- package/dist/src/styles/plan/plan.d.ts.map +1 -1
- package/dist/src/styles/plan/plan.js +61 -4
- package/dist/src/styles/plan/plan.js.map +1 -1
- package/dist/src/styles/plan/resolve.d.ts +11 -0
- package/dist/src/styles/plan/resolve.d.ts.map +1 -1
- package/dist/src/styles/plan/resolve.js +40 -4
- package/dist/src/styles/plan/resolve.js.map +1 -1
- package/dist/src/styles/slots.d.ts +14 -0
- package/dist/src/styles/slots.d.ts.map +1 -0
- package/dist/src/styles/slots.js +20 -0
- package/dist/src/styles/slots.js.map +1 -0
- package/dist/src/styles/types.d.ts +687 -6
- package/dist/src/styles/types.d.ts.map +1 -1
- package/dist/src/styles/vocabulary.d.ts +3 -2
- package/dist/src/styles/vocabulary.d.ts.map +1 -1
- package/dist/src/styles/vocabulary.js +224 -0
- package/dist/src/styles/vocabulary.js.map +1 -1
- package/dist/styles.js +30 -239
- package/dist/styles.js.map +1 -1
- package/dist/xgmml.js +3 -3
- package/package.json +27 -7
- package/src/formats/cx/importer.ts +6 -1
- package/src/formats/cx/styles.ts +143 -9
- package/src/formats/cx2/importer.ts +1 -0
- package/src/formats/cx2/styles.ts +3 -1
- package/src/formats/cys/importer.ts +1 -0
- package/src/formats/cys/styles.ts +27 -5
- package/src/formats/dot/drawing.ts +799 -0
- package/src/formats/dot/exporter.ts +37 -1
- package/src/formats/dot/importer.ts +192 -36
- package/src/formats/dot/index.ts +3 -1
- package/src/formats/dot/label-places.ts +241 -0
- package/src/formats/dot/names.ts +15 -0
- package/src/formats/dot/record.ts +336 -0
- package/src/formats/dot/styles.ts +1702 -149
- package/src/formats/gexf/dialog-metrics.ts +61 -0
- package/src/formats/gexf/importer.ts +50 -5
- package/src/formats/gexf/preview.ts +217 -0
- package/src/formats/gexf/schema.ts +2 -1
- package/src/formats/gexf/styles.ts +1099 -245
- package/src/formats/gml/importer.ts +291 -76
- package/src/formats/gml/index.ts +1 -1
- package/src/formats/gml/positions.ts +29 -7
- package/src/formats/gml/styles.ts +852 -110
- package/src/formats/graphml/styles-plain.ts +6 -15
- package/src/formats/graphml/styles-yed.ts +765 -176
- package/src/formats/graphml/styles-yfiles3.ts +487 -63
- package/src/formats/graphml/yfiles.ts +19 -6
- package/src/formats/json/dialect.ts +41 -5
- package/src/formats/json/importer.ts +59 -7
- package/src/formats/json/index.ts +1 -0
- package/src/formats/json/positions.ts +22 -5
- package/src/formats/json/styles.ts +2123 -171
- package/src/formats/pajek/draw.ts +469 -0
- package/src/formats/pajek/exporter.ts +81 -49
- package/src/formats/pajek/importer.ts +278 -103
- package/src/formats/pajek/index.ts +1 -0
- package/src/formats/pajek/styles.ts +1506 -133
- package/src/formats/pajek/syntax.ts +27 -2
- package/src/formats/xgmml/emit.ts +73 -5
- package/src/formats/xgmml/styles.ts +330 -71
- package/src/index.ts +12 -1
- package/src/positions/convert.ts +12 -1
- package/src/positions/extract.ts +55 -1
- package/src/positions/index.ts +1 -0
- package/src/positions/types.ts +60 -0
- package/src/sources/builtins.ts +8 -1
- package/src/sources/context.ts +1 -0
- package/src/sources/credentials.ts +90 -1
- package/src/sources/cypher/descriptor.ts +7 -1
- package/src/sources/cypher/index.ts +149 -18
- package/src/sources/cypher/params.ts +1 -1
- package/src/sources/cypher/query-builder.ts +33 -0
- package/src/sources/ids.ts +6 -0
- package/src/sources/params.ts +3 -0
- package/src/sources/rest/descriptor.ts +9 -0
- package/src/sources/rest/openalex.ts +4 -2
- package/src/sources/rest/source.ts +41 -0
- package/src/sources/run.ts +35 -3
- package/src/sources/sigv4.ts +6 -4
- package/src/sources/sparql/descriptor.ts +67 -0
- package/src/sources/sparql/index.ts +371 -0
- package/src/sources/sparql/ntriples.ts +219 -0
- package/src/sources/sparql/params.ts +28 -0
- package/src/sources/sparql/query.ts +216 -0
- package/src/sources/types.ts +68 -0
- package/src/styles/annotations.ts +201 -27
- package/src/styles/canon/bends.ts +137 -0
- package/src/styles/canon/color-tables.ts +10 -4
- package/src/styles/canon/color.ts +105 -3
- package/src/styles/canon/enums.ts +107 -8
- package/src/styles/canon/graphviz.ts +71 -10
- package/src/styles/canon/number.ts +19 -0
- package/src/styles/canon/text.ts +187 -16
- package/src/styles/codes.ts +2 -0
- package/src/styles/cyjs/cascade.ts +1303 -84
- package/src/styles/cyjs/defaults-table.ts +4 -0
- package/src/styles/cyjs/emit.ts +268 -14
- package/src/styles/cyjs/face.ts +372 -0
- package/src/styles/cyjs/mappers.ts +506 -27
- package/src/styles/cyjs/routes.ts +432 -0
- package/src/styles/cytoscape/charts.ts +684 -0
- package/src/styles/cytoscape/emit.ts +170 -48
- package/src/styles/cytoscape/lexicon.ts +431 -78
- package/src/styles/cytoscape/mappings.ts +108 -0
- package/src/styles/cytoscape/resolve.ts +741 -17
- package/src/styles/defaults.ts +417 -108
- package/src/styles/index.ts +5 -0
- package/src/styles/internal.ts +1 -0
- package/src/styles/io/generic.ts +79 -23
- package/src/styles/io/round-trip.ts +202 -0
- package/src/styles/io/writer.ts +6 -1
- package/src/styles/notes.ts +1 -0
- package/src/styles/plan/features.ts +23 -2
- package/src/styles/plan/index.ts +1 -1
- package/src/styles/plan/plan.ts +69 -5
- package/src/styles/plan/resolve.ts +47 -4
- package/src/styles/slots.ts +25 -0
- package/src/styles/types.ts +698 -5
- package/src/styles/vocabulary.ts +232 -2
- package/dist/chunks/block-Cu22ewuS.js.map +0 -1
- package/dist/chunks/choose-Cdx6Enl2.js +0 -57
- package/dist/chunks/choose-Cdx6Enl2.js.map +0 -1
- package/dist/chunks/codes-CV_Bhcyi.js.map +0 -1
- package/dist/chunks/convert-BcQ8_jMo.js.map +0 -1
- package/dist/chunks/credentials-BiQsnMTb.js.map +0 -1
- package/dist/chunks/descriptor-BJ-W0Jd-.js.map +0 -1
- package/dist/chunks/emit-CD8xnY8s.js.map +0 -1
- package/dist/chunks/export-CZ7VRm4I.js.map +0 -1
- package/dist/chunks/exporter-bxxjOrDZ.js.map +0 -1
- package/dist/chunks/format-BMS-1Nxb.js +0 -64
- package/dist/chunks/format-BMS-1Nxb.js.map +0 -1
- package/dist/chunks/generic-CP6YD34u.js.map +0 -1
- package/dist/chunks/importer-B87_fmVx.js.map +0 -1
- package/dist/chunks/importer-CB_zV5_L.js.map +0 -1
- package/dist/chunks/importer-CVT-JyDE.js.map +0 -1
- package/dist/chunks/importer-Cyy6UseH.js.map +0 -1
- package/dist/chunks/importer-DPZDN40-.js.map +0 -1
- package/dist/chunks/importer-e3huMZbm.js.map +0 -1
- package/dist/chunks/lexicon-u2SI5xcx.js.map +0 -1
- package/dist/chunks/sigv4-LkAzsLAu.js.map +0 -1
- package/dist/chunks/styles-CaABMoO1.js.map +0 -1
- package/dist/chunks/styles-P_gmFAOi.js +0 -770
- package/dist/chunks/styles-P_gmFAOi.js.map +0 -1
- package/dist/chunks/styles-yed-Cs1nmrjn.js.map +0 -1
- package/dist/chunks/writer-DvHTl36J.js +0 -449
- package/dist/chunks/writer-DvHTl36J.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer-C6NVpCXp.js","sources":["../../src/formats/graphml/tree.ts","../../src/formats/graphml/yfiles.ts","../../src/formats/graphml/exporter.ts","../../src/formats/graphml/styles-yfiles3.ts","../../src/formats/graphml/styles-plain.ts","../../src/formats/graphml/importer.ts"],"sourcesContent":["/**\n * Nested XML inside a GraphML `<data>` element (yFiles / yEd `y:ShapeNode`, `y:PolyLineEdge`,\n * ...) as a JSON tree, the value of a `json` column with `origin.namespace: \"yfiles\"` (design\n * section 8.5: structure preserved, not byte-exact). The shape follows the fast-xml-parser\n * convention graphty-element's parser already navigates: an element is an object whose\n * `@_<name>` keys are its attributes, whose `#text` key is its non-whitespace character data\n * when it also has attributes or children, and whose other keys are its child elements (an\n * array when a name repeats); an element with neither attributes nor children is its text\n * (an empty string for an empty element).\n *\n * The builder consumes the tokenizer events of one subtree; the writer produces the XML text of\n * a tree again, so a yFiles column re-exports as the same nested markup.\n */\n\nimport { GraphFormatError } from \"@graphty/graph-format\";\n\nimport { escapeXmlAttribute, escapeXmlText } from \"../../common/escape.js\";\nimport { isWhitespace, isXmlName } from \"../../common/xml.js\";\n\n/** The prefix of an attribute key in a tree object. */\nconst ATTRIBUTE_PREFIX = \"@_\";\n\n/** The key of an element's character data when it also has attributes or children. */\nconst TEXT_KEY = \"#text\";\n\n/** A tree object: attributes, text and child elements by name. */\ntype XmlTreeObject = Record<string, unknown>;\n\n/** A frame of the builder: one open element. */\ninterface Frame {\n readonly name: string;\n readonly node: XmlTreeObject;\n hasAttrs: boolean;\n hasChildren: boolean;\n text: string;\n}\n\n/**\n * Builds the tree of one subtree from start / end / text events. The outermost frame is the\n * `<data>` element itself; `finish()` returns its content: the object of its children, or its\n * text when it has none.\n * @category Plugin helpers\n */\nexport class XmlTreeBuilder {\n private readonly frames: Frame[] = [];\n\n private readonly root: Frame;\n\n /** Create a builder whose implicit root is the containing element. */\n constructor() {\n this.root = { name: \"\", node: {}, hasAttrs: false, hasChildren: false, text: \"\" };\n }\n\n /**\n * Whether the builder is inside a child element (as opposed to at the root level).\n * @returns true while at least one child element is open\n */\n get open(): boolean {\n return this.frames.length > 0;\n }\n\n /**\n * An element starts.\n * @param name - the element name as written\n * @param attrs - its attributes\n */\n start(name: string, attrs: ReadonlyMap<string, string>): void {\n const node: XmlTreeObject = {};\n let hasAttrs = false;\n for (const [key, value] of attrs) {\n node[ATTRIBUTE_PREFIX + key] = value;\n hasAttrs = true;\n }\n this.frames.push({ name, node, hasAttrs, hasChildren: false, text: \"\" });\n }\n\n /**\n * Character data inside the current element.\n * @param text - the text\n */\n text(text: string): void {\n const frame = this.frames.at(-1) ?? this.root;\n frame.text += text;\n }\n\n /** The current element ends; its value is attached to its parent. */\n end(): void {\n const frame = this.frames.pop();\n if (frame === undefined) {\n throw new GraphFormatError(\"E_COLUMN_TYPE\", \"XmlTreeBuilder.end() without a matching start()\", {\n reason: \"tree builder underflow\",\n });\n }\n const parent = this.frames.at(-1) ?? this.root;\n attachChild(parent, frame.name, valueOf(frame));\n }\n\n /**\n * The content of the containing element: its text when it has no child elements, otherwise\n * the object of its children (with `#text` for non-whitespace mixed content).\n * @returns the value to store in the json column\n */\n finish(): unknown {\n if (this.frames.length > 0) {\n throw new GraphFormatError(\"E_COLUMN_TYPE\", \"XmlTreeBuilder.finish() with open elements\", {\n reason: \"tree builder open\",\n });\n }\n const { root } = this;\n if (!root.hasChildren) {\n return root.text;\n }\n if (!isWhitespace(root.text)) {\n root.node[TEXT_KEY] = root.text;\n }\n return root.node;\n }\n}\n\n/**\n * The value of a finished element: its text when it has neither attributes nor children,\n * else its node with `#text` set to non-whitespace text.\n * @param frame - the finished frame\n * @returns the value\n */\nfunction valueOf(frame: Frame): unknown {\n if (!frame.hasAttrs && !frame.hasChildren) {\n return frame.text;\n }\n if (!isWhitespace(frame.text)) {\n frame.node[TEXT_KEY] = frame.text;\n }\n return frame.node;\n}\n\n/**\n * Attach a child value under a name, turning a repeated name into an array.\n * @param parent - the parent frame\n * @param name - the child element name\n * @param value - the child value\n */\nfunction attachChild(parent: Frame, name: string, value: unknown): void {\n parent.hasChildren = true;\n // own keys only: an element named `__proto__` is a child like any other, never the object's prototype\n const existing = Object.hasOwn(parent.node, name) ? parent.node[name] : undefined;\n if (existing === undefined) {\n Object.defineProperty(parent.node, name, { value, writable: true, enumerable: true, configurable: true });\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n parent.node[name] = [existing, value];\n }\n}\n\n/**\n * Whether a value is a tree the writer can serialize: a string, number, boolean or null (text),\n * an array of such trees, or an object whose keys are `#text`, `@_<Name>` or `<Name>` with tree\n * values.\n * @param value - the value\n * @returns true when writeXmlTree() accepts it\n * @category Plugin helpers\n */\nexport function isXmlTree(value: unknown): boolean {\n return treeProblem(value) === null;\n}\n\n/**\n * Why a value is not a serializable tree.\n * @param value - the value\n * @returns a message, or null when the value is a tree\n * @category Plugin helpers\n */\nexport function treeProblem(value: unknown): string | null {\n if (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return null;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n if (Array.isArray(item)) {\n return \"nested arrays cannot be written as elements\";\n }\n const problem = treeProblem(item);\n if (problem !== null) {\n return problem;\n }\n }\n return null;\n }\n if (typeof value !== \"object\") {\n return `a ${typeof value} cannot be written as XML`;\n }\n for (const [key, child] of Object.entries(value)) {\n if (key === TEXT_KEY) {\n if (child !== null && typeof child === \"object\") {\n return \"#text must be a scalar\";\n }\n continue;\n }\n if (key.startsWith(ATTRIBUTE_PREFIX)) {\n const name = key.slice(ATTRIBUTE_PREFIX.length);\n if (!isXmlName(name)) {\n return `\"${name}\" is not an XML attribute name`;\n }\n if (child !== null && typeof child === \"object\") {\n return `attribute ${name} must be a scalar`;\n }\n continue;\n }\n if (!isXmlName(key)) {\n return `\"${key}\" is not an XML element name`;\n }\n const problem = treeProblem(child);\n if (problem !== null) {\n return problem;\n }\n }\n return null;\n}\n\n/**\n * Write the content of a tree as XML text: the children (and mixed text) of the containing\n * element. Leaf elements are written inline so their text stays exact; elements with children\n * are broken over lines and indented.\n * @param value - the tree (the content of a `<data>` element)\n * @param indent - the indentation of the containing element's children\n * @param out - receives the text parts\n * @category Plugin helpers\n */\nexport function writeXmlTree(value: unknown, indent: string, out: string[]): void {\n const problem = treeProblem(value);\n if (problem !== null) {\n throw new GraphFormatError(\"E_COLUMN_TYPE\", `a yfiles value cannot be written as XML: ${problem}`, {\n reason: \"xml tree\",\n });\n }\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n out.push(escapeXmlText(scalarText(value)));\n return;\n }\n const object = value as XmlTreeObject;\n let text: string | null = null;\n for (const [key, child] of Object.entries(object)) {\n if (key === TEXT_KEY) {\n text = scalarText(child);\n } else if (!key.startsWith(ATTRIBUTE_PREFIX)) {\n writeElements(key, child, indent, out);\n }\n }\n if (text !== null) {\n out.push(escapeXmlText(text));\n }\n}\n\n/**\n * Write one element (or, for an array, one element per item). An element holding text beside child elements (a yEd\n * label: its text, then its label model) is written without any whitespace of its own inside it, so the text reads\n * back exactly as it was.\n * @param name - the element name\n * @param value - the element value\n * @param indent - the indentation of this element, or null to write it with no line break or indentation\n * @param out - receives the text parts\n */\nfunction writeElements(name: string, value: unknown, indent: string | null, out: string[]): void {\n if (Array.isArray(value)) {\n for (const item of value) {\n writeElements(name, item, indent, out);\n }\n return;\n }\n const brk = indent === null ? \"\" : `\\n${indent}`;\n if (value === null || typeof value !== \"object\") {\n const text = scalarText(value);\n out.push(text.length === 0 ? `${brk}<${name}/>` : `${brk}<${name}>${escapeXmlText(text)}</${name}>`);\n return;\n }\n writeObjectElement(name, value as XmlTreeObject, indent, out);\n}\n\n/**\n * Write one element whose value is a tree object: its attributes, its text and its children.\n * @param name - the element name\n * @param object - the element value\n * @param indent - the indentation of this element, or null to write it with no line break or indentation\n * @param out - receives the text parts\n */\nfunction writeObjectElement(name: string, object: XmlTreeObject, indent: string | null, out: string[]): void {\n const brk = indent === null ? \"\" : `\\n${indent}`;\n const { attrs, text, hasChildren } = elementParts(object);\n if (!hasChildren) {\n out.push(\n text === null || text.length === 0\n ? `${brk}<${name}${attrs}/>`\n : `${brk}<${name}${attrs}>${escapeXmlText(text)}</${name}>`,\n );\n return;\n }\n // mixed content: the text first and the children with no whitespace, so none is added to the text\n const inner = indent === null || text !== null ? null : `${indent} `;\n out.push(`${brk}<${name}${attrs}>`);\n if (text !== null) {\n out.push(escapeXmlText(text));\n }\n for (const [key, child] of Object.entries(object)) {\n if (key !== TEXT_KEY && !key.startsWith(ATTRIBUTE_PREFIX)) {\n writeElements(key, child, inner, out);\n }\n }\n out.push(inner === null ? `</${name}>` : `${brk}</${name}>`);\n}\n\n/**\n * What a tree object holds besides its children: its attributes as text and its text.\n * @param object - the object\n * @returns the attribute text, the text (null for none) and whether it has child elements\n */\nfunction elementParts(object: XmlTreeObject): { attrs: string; text: string | null; hasChildren: boolean } {\n let attrs = \"\";\n let text: string | null = null;\n let hasChildren = false;\n for (const [key, child] of Object.entries(object)) {\n if (key === TEXT_KEY) {\n text = scalarText(child);\n } else if (key.startsWith(ATTRIBUTE_PREFIX)) {\n attrs += ` ${key.slice(ATTRIBUTE_PREFIX.length)}=\"${escapeXmlAttribute(scalarText(child))}\"`;\n } else {\n hasChildren = true;\n }\n }\n return { attrs, text, hasChildren };\n}\n\n/**\n * The text of a scalar tree value.\n * @param value - a string, number, boolean or null\n * @returns the text; an empty string for null\n */\nfunction scalarText(value: unknown): string {\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n case \"boolean\":\n case \"bigint\":\n return String(value);\n default:\n return \"\";\n }\n}\n","/**\n * yFiles / yEd graphics read out of the JSON tree of a `yfiles.type` key (tree.ts) into typed\n * columns, beside the tree itself: a `y:ShapeNode` gives the node's position, size, fill and\n * border colors, label and shape, and a `y:PolyLineEdge` gives the edge's line color and width,\n * its arrows and the direction they draw. The values are the ones graphty-element's own GraphML\n * parser produced, so a consumer rebuilds its records by dropping the `yfiles.` prefix: colors\n * are `#RRGGBB` in upper case (a `#RGB` is expanded, any other text is kept as written), numbers\n * are parsed with parseFloat, the position is `[x, y, 0]` and the shape is the yFiles shape type\n * as written. One difference: a label whose text is a number (`<y:NodeLabel>0</y:NodeLabel>`) is\n * kept as that text, where the element's parser turned it into a number and stored `\"\"`, nothing\n * or the number.\n *\n * The columns are views of the tree: the exporter writes the tree and never these columns, and\n * re-importing the tree gives them back. A value edited after import (a layout writing the\n * position) or a tree column removed is therefore not written, and the exporter reports it as a\n * loss (staleGraphicsRows()).\n *\n * Deprecated and frozen, not fixed: these columns, the rule that a target arrow makes an edge\n * directed and the label role of `yfiles.label` stay exactly as they are until the next major\n * version removes them. The yEd and yFiles 3 style readers read the kept graphics tree instead.\n */\n\nimport { type Column, type ColumnDecl, type GraphSnapshot, type JsonColumn } from \"@graphty/graph-format\";\n\nimport { localName } from \"../../common/xml.js\";\nimport type { ImporterPositions } from \"../../positions/types.js\";\n\n/** The name prefix of every column mapped from yFiles graphics. */\nconst YFILES_COLUMN_PREFIX = \"yfiles.\";\n\ntype Tree = Record<string, unknown>;\n\n/** The mapped node columns, by the field name graphty-element's records use. */\nconst NODE_FIELDS: Readonly<Record<string, Omit<ColumnDecl, \"name\">>> = {\n // yEd writes the top-left corner of the node's box, y growing downward, in pixels\n position: {\n dtype: \"f64\",\n components: 3,\n role: \"position\",\n mutable: true,\n extra: {\n units: \"px\",\n yAxis: \"down\",\n anchor: \"top-left\",\n width: `${YFILES_COLUMN_PREFIX}width`,\n height: `${YFILES_COLUMN_PREFIX}height`,\n },\n },\n width: { dtype: \"f64\" },\n height: { dtype: \"f64\" },\n color: { dtype: \"string\" },\n borderColor: { dtype: \"string\" },\n borderWidth: { dtype: \"f64\" },\n label: { dtype: \"string\", role: \"label\" },\n shape: { dtype: \"string\" },\n};\n\n/** The mapped edge columns, by field name. */\nconst EDGE_FIELDS: Readonly<Record<string, Omit<ColumnDecl, \"name\">>> = {\n color: { dtype: \"string\" },\n width: { dtype: \"f64\" },\n directed: { dtype: \"bool\" },\n targetArrow: { dtype: \"string\" },\n sourceArrow: { dtype: \"string\" },\n};\n\n/**\n * The declaration of a mapped column.\n * @param domain - node or edge\n * @param field - the field name (a key of the values graphicsValues() returns)\n * @param keyId - the id of the GraphML key whose tree it is read from\n * @returns the declaration\n * @category Plugin helpers\n */\nexport function graphicsDecl(domain: \"node\" | \"edge\", field: string, keyId: string): ColumnDecl {\n const fields = domain === \"node\" ? NODE_FIELDS : EDGE_FIELDS;\n return {\n ...fields[field],\n name: YFILES_COLUMN_PREFIX + field,\n nullable: true,\n origin: {\n format: \"graphml\",\n id: keyId,\n title: null,\n type: domain === \"node\" ? \"ShapeNode\" : \"PolyLineEdge\",\n namespace: \"yfiles\",\n },\n };\n}\n\n/**\n * The tool behind a GraphML file's positions, for `extractPositions()`: yEd when they come from\n * yFiles graphics. The column's `meta.extra` already says how they are spelled.\n * @param snapshot - the graph the GraphML importer read\n * @returns the tool, or null to read the position column as declared\n */\nexport function yfilesPositions(snapshot: GraphSnapshot): ImporterPositions | null {\n return snapshot.nodes.byRole(\"position\")?.meta.origin?.namespace === \"yfiles\" ? { tool: \"yed\" } : null;\n}\n\n/**\n * Whether a column is one graphicsDecl() declared (a view of a yFiles tree, never exported).\n * @param meta - the column's name, dtype and origin\n * @param meta.name - the column name\n * @param meta.dtype - the column dtype\n * @param meta.origin - the column origin\n * @returns true for a mapped graphics column\n * @category Plugin helpers\n */\nexport function isGraphicsColumn(meta: {\n readonly name: string;\n readonly dtype: string;\n readonly origin: { readonly namespace: string | null } | null;\n}): boolean {\n return meta.dtype !== \"json\" && meta.origin?.namespace === \"yfiles\" && meta.name.startsWith(YFILES_COLUMN_PREFIX);\n}\n\n/**\n * The rows of a mapped graphics column whose value is not one its yFiles tree columns (in the\n * same table) give: every set row when no tree column gives a value for the row. A file may\n * declare several yFiles keys for one domain, and the mapped column holds the values of all of\n * them, so a row is current when any tree's value matches. These are the values an export loses,\n * since only the trees are written.\n * @param column - the mapped column (isGraphicsColumn())\n * @param table - the table it is in\n * @param domain - node or edge\n * @returns the number of rows that differ from the trees\n * @category Plugin helpers\n */\nexport function staleGraphicsRows(column: Column, table: Iterable<Column>, domain: \"node\" | \"edge\"): number {\n const field = column.meta.name.slice(YFILES_COLUMN_PREFIX.length);\n const trees: JsonColumn[] = [];\n for (const c of table) {\n if (c.dtype === \"json\" && c.meta.origin?.namespace === \"yfiles\") {\n trees.push(c);\n }\n }\n let stale = 0;\n for (let r = 0; r < column.length; r++) {\n const wants = wantedGraphics(trees, domain, field, r);\n const value = column.value(r);\n const have = column.meta.components > 1 && value !== undefined ? Array.from(value as ArrayLike<number>) : value;\n if (!wants.has(JSON.stringify(have))) {\n stale++;\n }\n }\n return stale;\n}\n\n/**\n * The serialized values the trees want for one row of a mapped column.\n * @param trees - the yFiles tree columns of the table\n * @param domain - node or edge\n * @param field - the mapped field name\n * @param r - the row\n * @returns the wanted values as JSON text; just `undefined`'s when no tree wants one\n */\nfunction wantedGraphics(trees: JsonColumn[], domain: \"node\" | \"edge\", field: string, r: number): Set<string> {\n const wants = new Set<string>();\n for (const tree of trees) {\n const want = graphicsValues(domain, tree.values[r]).find(([f]) => f === field);\n if (want !== undefined) {\n wants.add(JSON.stringify(want[1]));\n }\n }\n if (wants.size === 0) {\n wants.add(JSON.stringify(undefined));\n }\n return wants;\n}\n\n/**\n * The mapped values of one `<data>` tree of a yFiles key: a ShapeNode's for a node, a\n * PolyLineEdge's for an edge. A GenericNode, ImageNode, SVGNode, UMLClassNode, UMLNoteNode, TableNode\n * or ProxyAutoBoundsNode (a group, read through the realizer `Realizers@active` names), and yFiles 3's\n * NodeGeometry `RectD`, give their geometry only: position, width and height. Nothing for any other graphics (BezierEdge, ...).\n * @param domain - node or edge\n * @param tree - the `<data>` content as tree.ts builds it\n * @param unmapped - receives the fields whose text is present but not a number (not mapped)\n * @returns field name -> value, in declaration order\n * @category Plugin helpers\n */\nexport function graphicsValues(domain: \"node\" | \"edge\", tree: unknown, unmapped: string[] = []): [string, unknown][] {\n const out: [string, unknown][] = [];\n if (domain === \"node\") {\n const shape = child(tree, \"ShapeNode\");\n const rect = child(tree, \"RectD\");\n if (rect !== undefined) {\n // yFiles 3's NodeGeometry: the same top-left corner and size as yEd's Geometry, capitalized\n geometryValues(\n {\n \"@_x\": attr(rect, \"X\"),\n \"@_y\": attr(rect, \"Y\"),\n \"@_width\": attr(rect, \"Width\"),\n \"@_height\": attr(rect, \"Height\"),\n },\n out,\n unmapped,\n );\n } else if (shape === undefined) {\n geometryValues(child(geometryNode(tree), \"Geometry\"), out, unmapped);\n } else {\n shapeNodeValues(shape, out, unmapped);\n }\n } else {\n const edge = child(tree, \"PolyLineEdge\");\n if (edge !== undefined) {\n polyLineEdgeValues(edge, out, unmapped);\n }\n }\n return out;\n}\n\n/**\n * Read a ShapeNode.\n * @param shape - the ShapeNode element\n * @param out - receives the values\n * @param unmapped - receives the fields whose text is not a number\n */\nfunction shapeNodeValues(shape: unknown, out: [string, unknown][], unmapped: string[]): void {\n geometryValues(child(shape, \"Geometry\"), out, unmapped);\n push(out, \"color\", color(attr(child(shape, \"Fill\"), \"color\")));\n const border = child(shape, \"BorderStyle\");\n push(out, \"borderColor\", color(attr(border, \"color\")));\n push(out, \"borderWidth\", checked(attr(border, \"width\"), \"borderWidth\", unmapped));\n const label = child(shape, \"NodeLabel\");\n // an element with no text and no attributes is \"\" (no label); one with attributes but no text is a blank label\n if (typeof label === \"string\" ? label.length > 0 : label !== undefined) {\n // trimmed, as the element's parser (trimValues) reads it: pretty-printed yEd puts whitespace before the label's children\n out.push([\"label\", (typeof label === \"string\" ? label : (text(label) ?? \"\")).trim()]);\n }\n push(out, \"shape\", nonEmpty(attr(child(shape, \"Shape\"), \"type\")));\n}\n\n/**\n * Read a Geometry: the position of the box's top-left corner, its width and height.\n * @param geometry - the Geometry element, or undefined\n * @param out - receives the values\n * @param unmapped - receives the fields whose text is not a number\n */\nfunction geometryValues(geometry: unknown, out: [string, unknown][], unmapped: string[]): void {\n // yFiles requires x, y, width and height on Geometry; a position needs both coordinates\n const x = checked(attr(geometry, \"x\"), \"x\", unmapped);\n const y = checked(attr(geometry, \"y\"), \"y\", unmapped);\n if (x !== undefined && y !== undefined) {\n out.push([\"position\", [x, y, 0]]);\n }\n push(out, \"width\", checked(attr(geometry, \"width\"), \"width\", unmapped));\n push(out, \"height\", checked(attr(geometry, \"height\"), \"height\", unmapped));\n}\n\n/** The node graphics besides ShapeNode whose Geometry is read. */\nconst GEOMETRY_NODES = [\"GenericNode\", \"ImageNode\", \"SVGNode\", \"UMLClassNode\", \"UMLNoteNode\", \"TableNode\"] as const;\n\n/**\n * The element holding a non-ShapeNode node's Geometry: one of GEOMETRY_NODES, or\n * the active realizer of a ProxyAutoBoundsNode (`Realizers@active`, default 0).\n * @param tree - the `<data>` content\n * @returns the element, or undefined\n */\nfunction geometryNode(tree: unknown): unknown {\n for (const local of GEOMETRY_NODES) {\n const node = child(tree, local);\n if (node !== undefined) {\n return node;\n }\n }\n const realizers = child(child(tree, \"ProxyAutoBoundsNode\"), \"Realizers\");\n const active = Number.parseInt(attr(realizers, \"active\") ?? \"0\", 10);\n return elements(realizers)[Number.isNaN(active) ? 0 : active];\n}\n\n/**\n * Every child element of a tree node, in document order per name.\n * @param node - the tree node\n * @returns the children\n */\nfunction elements(node: unknown): unknown[] {\n if (typeof node !== \"object\" || node === null) {\n return [];\n }\n return Object.entries(node as Tree)\n .filter(([key]) => !key.startsWith(\"@_\") && key !== \"#text\")\n .flatMap(([, value]) => (Array.isArray(value) ? (value as unknown[]) : [value]));\n}\n\n/**\n * Read a PolyLineEdge.\n * @param edge - the PolyLineEdge element\n * @param out - receives the values\n * @param unmapped - receives the fields whose text is not a number\n */\nfunction polyLineEdgeValues(edge: unknown, out: [string, unknown][], unmapped: string[]): void {\n const line = child(edge, \"LineStyle\");\n push(out, \"color\", color(attr(line, \"color\")));\n push(out, \"width\", checked(attr(line, \"width\"), \"width\", unmapped));\n const arrows = child(edge, \"Arrows\");\n if (arrows !== undefined && typeof arrows === \"object\") {\n const target = attr(arrows, \"target\");\n const source = attr(arrows, \"source\");\n // yEd draws direction with the target arrow; the file's edgedefault still decides topology\n out.push([\"directed\", target !== undefined && target !== \"none\"]);\n push(out, \"targetArrow\", target === \"none\" ? undefined : nonEmpty(target));\n push(out, \"sourceArrow\", source === \"none\" ? undefined : nonEmpty(source));\n }\n}\n\n/**\n * Append a value when it is defined.\n * @param out - the values\n * @param field - the field name\n * @param value - the value\n */\nfunction push(out: [string, unknown][], field: string, value: unknown): void {\n if (value !== undefined) {\n out.push([field, value]);\n }\n}\n\n/**\n * The first child element of a tree node by local name, whatever its namespace prefix.\n * @param node - the tree node\n * @param local - the local name\n * @returns the child, or undefined\n */\nfunction child(node: unknown, local: string): unknown {\n if (typeof node !== \"object\" || node === null) {\n return undefined;\n }\n for (const [key, value] of Object.entries(node as Tree)) {\n if (!key.startsWith(\"@_\") && key !== \"#text\" && localName(key) === local) {\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\n * @returns the text, or undefined\n */\nfunction attr(node: unknown, name: string): string | undefined {\n if (typeof node !== \"object\" || node === null) {\n return undefined;\n }\n const value = (node as Tree)[`@_${name}`];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * The character data of an element that also has attributes or children.\n * @param node - the tree node\n * @returns the text, or undefined\n */\nfunction text(node: unknown): string | undefined {\n const value = typeof node === \"object\" && node !== null ? (node as Tree)[\"#text\"] : undefined;\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * A non-empty text.\n * @param value - the text\n * @returns the text, or undefined when absent or empty\n */\nfunction nonEmpty(value: string | undefined): string | undefined {\n return value === undefined || value.length === 0 ? undefined : value;\n}\n\n/**\n * A number attribute, parsed as graphty-element's parser parsed it.\n * @param value - the text\n * @returns the number, or undefined when absent, empty or not a number\n */\nfunction number(value: string | undefined): number | undefined {\n if (value === undefined || value.length === 0) {\n return undefined;\n }\n const n = Number.parseFloat(value);\n return Number.isNaN(n) ? undefined : n;\n}\n\n/**\n * A number attribute, recording a present text that is not a number.\n * @param value - the text\n * @param field - the field it maps to\n * @param unmapped - receives the field when the text is not a number\n * @returns the number, or undefined\n */\nfunction checked(value: string | undefined, field: string, unmapped: string[]): number | undefined {\n const n = number(value);\n if (n === undefined && value !== undefined && value.length > 0) {\n unmapped.push(field);\n }\n return n;\n}\n\n/**\n * A color attribute: `#RRGGBB` upper-cased, `#RGB` expanded, anything else as written.\n * @param value - the text\n * @returns the color, or undefined when absent or empty\n */\nfunction color(value: string | undefined): string | undefined {\n if (value === undefined || value.length === 0) {\n return undefined;\n }\n if (/^#[0-9A-Fa-f]{6}$/.test(value)) {\n return value.toUpperCase();\n }\n if (/^#[0-9A-Fa-f]{3}$/.test(value)) {\n const [, r, g, b] = value;\n return `#${r}${r}${g}${g}${b}${b}`.toUpperCase();\n }\n return value;\n}\n","/**\n * The GraphML exporter (design section 8.5; research note 07 section 9): `<key>` declarations\n * regenerated from ColumnMeta.origin when the column came from GraphML (key id, attr.name,\n * attr.type, yfiles.type) and derived from the dtype otherwise; node ids sanitised to NMTOKEN\n * (`sanitizeIds: \"error\"` refuses, `\"mangle\"` rewrites and keeps the original in a\n * `graphty:originalId` data attribute the importer restores); mixed direction written with\n * `edgedefault` plus per-edge `directed` attributes, folding expanded pairs back through the\n * `pair` / `directed` role columns; explicit weights only (the role-weight column's validity);\n * containment (`parent` role) as nested graphs; yFiles json columns as nested XML again.\n *\n * check() lists every loss before anything is written: the generic capability gaps of\n * checkCapabilities() (dict / u32 / u8 dtypes, lists, components, options, positions, visual and\n * temporal roles, extension tables) plus the GraphML-specific ones (mutual edges written as\n * undirected, json columns without a yfiles origin written as JSON text, multi-parent columns,\n * containment order, ids that change type under the canonical rule, edge ids that read back as\n * strings, roles GraphML cannot express, yfiles values that are not serializable trees).\n */\n\nimport { type Column, GraphFormatError, type GraphSnapshot, INVALID_INDEX } from \"@graphty/graph-format\";\n\nimport { childrenCsr } from \"../../children.js\";\nimport { type PairFolding, pairFolding } from \"../../common/direction.js\";\nimport { escapeXmlAttribute, escapeXmlText } from \"../../common/escape.js\";\nimport {\n capabilities,\n checkCapabilities,\n isNmtoken,\n LOSS,\n mangleNmtoken,\n type SanitizedIds,\n sanitizeIds,\n} from \"../../common/export.js\";\nimport { formatF32, formatF64, formatInteger } from \"../../common/format.js\";\nimport { isCanonicalIntegerText } from \"../../common/ids.js\";\nimport { type ResolvedExportOptions, resolveExportOptions } from \"../../common/options.js\";\nimport { agree, plural } from \"../../common/plural.js\";\nimport { type ExplicitWeights, explicitWeights } from \"../../common/weights.js\";\nimport { encodeChunks, joinText } from \"../../common/writer.js\";\nimport { xmlIllegalTextNotes } from \"../../common/xml.js\";\nimport type { ExporterStyleOptions } from \"../../styles/io/writer.js\";\nimport { type CommonExportOptions, type ExportCapabilities, type GraphExporter, type LossNote } from \"../../types.js\";\nimport {\n EDGE_ID_COLUMN,\n FORMAT,\n GRAPHML_LOSS,\n GRAPHML_NAMESPACE,\n type GraphmlMeta,\n LABEL_COLUMN,\n META_KEY,\n ORIGINAL_ID_ATTRIBUTE,\n PARENT_COLUMN,\n RESERVED_EDGE_NAMES,\n RESERVED_NODE_NAMES,\n SCHEMA_LOCATION,\n SOURCE_PORT_COLUMN,\n TARGET_PORT_COLUMN,\n XSI_NAMESPACE,\n YFILES_NAMESPACE,\n} from \"./constants.js\";\nimport { GRAPHML_STYLE_CAPABILITIES, graphmlStyledExport } from \"./styles-yed.js\";\nimport { treeProblem, writeXmlTree } from \"./tree.js\";\nimport { isGraphicsColumn, staleGraphicsRows } from \"./yfiles.js\";\n\n/** What the writer takes: the format's options, the common ones and the styles. */\ntype GraphmlWriteOptions = GraphmlExportOptions & CommonExportOptions & ExporterStyleOptions;\n\n/**\n * The format-specific options of the GraphML exporter.\n * @category Built-in formats\n */\nexport interface GraphmlExportOptions extends CommonExportOptions {\n /**\n * Indent nested elements; false writes one element per line without indentation.\n * @defaultValue true\n */\n pretty?: boolean | undefined;\n /**\n * The `edgedefault` of the graph element. The default is the one a GraphML import read, so a\n * file with both directions reads back with the same edges marked, else the graph's direction\n * (for a graph with both, the direction most edges have).\n * @defaultValue as read\n */\n edgedefault?: \"directed\" | \"undirected\" | undefined;\n}\n\n/** What GraphML keeps as declared (research note 07 section 9). */\nconst CAPABILITIES: ExportCapabilities = capabilities({\n mixedDirection: true,\n multiEdges: true,\n selfLoops: true,\n edgeIds: \"optional\",\n idCharset: \"nmtoken\",\n dtypes: [\"bool\", \"i32\", \"f32\", \"f64\", \"string\"],\n components: false,\n lists: false,\n json: false,\n defaults: true,\n options: false,\n hierarchy: true,\n temporal: \"none\",\n graphAttributes: true,\n positions: false,\n viz: false,\n});\n\n/** Roles handled structurally (never written as a key) or reported by checkCapabilities() and not written. */\nconst STRUCTURAL_ROLES: ReadonlySet<string> = new Set([\n \"directed\",\n \"pair\",\n \"mutual\",\n \"weight\",\n \"timeText\",\n \"originalId\",\n]);\nconst DROPPED_ROLES: ReadonlySet<string> = new Set([\n \"position\",\n \"color\",\n \"size\",\n \"shape\",\n \"thickness\",\n \"start\",\n \"end\",\n \"timestamp\",\n \"timestamps\",\n \"spells\",\n \"open\",\n \"spellsOpen\",\n]);\n\n/**\n * The roles GraphML has a slot for (checkCapabilities() reports every other role as lost): the\n * label key, the edge `id`, `sourceport` and `targetport` attributes and nested graphs.\n */\nconst SLOT_ROLES: ReadonlySet<string> = new Set([\"label\", \"id\", \"sourcePort\", \"targetPort\", \"parent\"]);\n\n/** The slot roles written structurally per domain (never as a key); a label is a key titled `label`. */\nconst SLOT_ROLES_BY_DOMAIN: Readonly<Record<Domain, ReadonlySet<string>>> = {\n graph: new Set(),\n node: new Set([\"parent\"]),\n edge: new Set([\"id\", \"sourcePort\", \"targetPort\"]),\n};\n\n/** The names the importer gives the slot columns (design section 5.6), for the name-change notes. */\nconst ROLE_NAMES: Readonly<Record<string, string>> = Object.freeze({\n label: LABEL_COLUMN,\n id: EDGE_ID_COLUMN,\n sourcePort: SOURCE_PORT_COLUMN,\n targetPort: TARGET_PORT_COLUMN,\n parent: PARENT_COLUMN,\n});\n\n/** The attr.name of the weight key when the weight did not come from GraphML (the importer's weightFrom default). */\nconst DEFAULT_WEIGHT_NAME = \"weight\";\n\n/** A note-recording callback. */\ntype NoteFn = (code: string, message: string, column?: string | null, count?: number | null) => void;\n\n/** The GraphML attr.type values and the dtype each maps to, for restoring origin.type. */\nconst TYPE_DTYPES: Readonly<Record<string, string>> = {\n boolean: \"bool\",\n int: \"i32\",\n long: \"f64\",\n float: \"f32\",\n double: \"f64\",\n string: \"string\",\n};\n\nconst I32_MAX = 2147483647;\n\n/** The yfiles.type written for a yfiles json column whose origin records none. */\nconst DEFAULT_YFILES_TYPES: Readonly<Record<Domain, string>> = {\n node: \"nodegraphics\",\n edge: \"edgegraphics\",\n graph: \"resources\",\n};\n\n/** The element domains. */\ntype Domain = \"graph\" | \"node\" | \"edge\";\n\n/** One column written as a key. */\ninterface ColumnPlan {\n readonly column: Column;\n readonly domain: Domain;\n /** The key id. */\n keyId: string;\n /** The attr.type, or null for a yfiles key. */\n readonly attrType: string | null;\n /** The attr.name, or null for a yfiles key. */\n readonly attrName: string | null;\n /** The yfiles.type, or null. */\n readonly yfilesType: string | null;\n /** Whether values are written as nested XML trees. */\n readonly yfiles: boolean;\n}\n\n/** One `<key>` element (a for=\"all\" key merges up to three column plans). */\ninterface KeyPlan {\n readonly id: string;\n readonly domains: readonly Domain[];\n readonly attrName: string | null;\n readonly attrType: string | null;\n readonly yfilesType: string | null;\n /** The column whose default and desc are written; null for the weight key. */\n readonly column: Column | null;\n}\n\n/** Containment as the exporter writes it. */\ninterface Hierarchy {\n /** The parent column, or null. */\n readonly parent: Column | null;\n /** Nodes written at the top level, in order (roots, then the roots forced out of cycles). */\n readonly roots: Uint32Array;\n /** CSR of children by parent: childStart[u]..childStart[u+1] over childList. */\n readonly childStart: Uint32Array;\n readonly childList: Uint32Array;\n /** Whether the written order differs from index order. */\n readonly reordered: boolean;\n /** Nodes whose parent chain never reaches a root. */\n readonly unreachable: number;\n}\n\n/** Everything check() and export() agree on. */\ninterface Plan {\n readonly options: ResolvedExportOptions;\n readonly pretty: boolean;\n readonly notes: LossNote[];\n readonly keys: KeyPlan[];\n readonly graphColumns: ColumnPlan[];\n readonly nodeColumns: ColumnPlan[];\n readonly edgeColumns: ColumnPlan[];\n /** The weight key id, attr.type and the explicit weights, or null for an unweighted snapshot. */\n readonly weight: { readonly keyId: string; readonly attrType: string; readonly weights: ExplicitWeights } | null;\n /** The key id of the originalId attribute, when mangled ids are written. */\n readonly originalIdKey: string | null;\n readonly edgedefault: \"directed\" | \"undirected\";\n /** The pair folding: mirrors skipped, source directions. */\n readonly folding: PairFolding;\n readonly edgeIdColumn: Column | null;\n readonly sourcePortColumn: Column | null;\n readonly targetPortColumn: Column | null;\n readonly hierarchy: Hierarchy;\n readonly meta: GraphmlMeta | null;\n readonly needsOriginalIdKey: boolean;\n /** Styles are written: the `y` prefix is yEd's namespace, whatever the file the graph came from bound it to. */\n readonly yedGraphics?: boolean;\n}\n\n/** The resolved format-specific options. */\ninterface FormatOptions {\n /** Whether to indent. */\n readonly pretty: boolean;\n /** The edgedefault override, or null. */\n readonly edgedefault: \"directed\" | \"undirected\" | null;\n}\n\n/**\n * Resolve the format-specific options.\n * @param options - the caller's options\n * @returns the pretty flag and the edgedefault override\n */\nfunction resolveFormatOptions(options: GraphmlExportOptions | undefined): FormatOptions {\n const pretty = options?.pretty ?? true;\n if (typeof pretty !== \"boolean\") {\n throw new GraphFormatError(\"E_UNSUPPORTED\", \"option pretty must be a boolean\", {\n option: \"pretty\",\n found: typeof pretty,\n });\n }\n const edgedefault = options?.edgedefault ?? null;\n if (edgedefault !== null && edgedefault !== \"directed\" && edgedefault !== \"undirected\") {\n throw new GraphFormatError(\n \"E_UNSUPPORTED\",\n `option edgedefault: ${JSON.stringify(edgedefault)} is not \"directed\" or \"undirected\"`,\n { option: \"edgedefault\", found: edgedefault },\n );\n }\n return { pretty, edgedefault };\n}\n\n/**\n * The importer's `meta.extra.graphml`, when the snapshot has one of the expected shape.\n * @param snapshot - the snapshot\n * @returns the meta, or null\n */\nfunction graphmlMetaOf(snapshot: GraphSnapshot): GraphmlMeta | null {\n const value = snapshot.meta.extra[META_KEY];\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n const record = value as Record<string, unknown>;\n const graphId = typeof record.graphId === \"string\" ? record.graphId : null;\n const edgedefault =\n record.edgedefault === \"directed\" || record.edgedefault === \"undirected\" ? record.edgedefault : null;\n const namespaces: Record<string, string> = {};\n if (typeof record.namespaces === \"object\" && record.namespaces !== null) {\n for (const [prefix, uri] of Object.entries(record.namespaces as Record<string, unknown>)) {\n if (typeof uri === \"string\") {\n namespaces[prefix] = uri;\n }\n }\n }\n return { graphId, edgedefault, namespaces };\n}\n\n/**\n * Build the plan: classify every column, assign key ids, decide the edgedefault and the\n * containment order, and collect every loss note.\n * @param snapshot - the snapshot\n * @param options - the resolved common options\n * @param format - the resolved format options\n * @param keyOrdered - write each element's data in the order of the keys (styled exports)\n * @returns the plan\n */\nfunction planExport(\n snapshot: GraphSnapshot,\n options: ResolvedExportOptions,\n format: FormatOptions,\n keyOrdered = false,\n): Plan {\n // the generic json note is replaced by planTable()'s (yfiles trees are kept, other json is\n // text); columns mapped from a yfiles tree are never written: planTable() notes the ones\n // that no longer match their tree, the rest lose nothing\n const graphics = new Set(\n [...snapshot.nodes, ...snapshot.edges].filter((c) => isGraphicsColumn(c.meta)).map((c) => c.meta.name),\n );\n const notes = checkCapabilities(snapshot, CAPABILITIES, options, {\n roles: SLOT_ROLES,\n roleNames: ROLE_NAMES,\n }).filter((n) => n.code !== LOSS.JSON && (n.column === null || !graphics.has(n.column)));\n const note: NoteFn = (code, message, column = null, count = null): void => {\n notes.push(Object.freeze({ code, message, column, count }));\n };\n notes.push(...xmlIllegalTextNotes(snapshot));\n const meta = graphmlMetaOf(snapshot);\n const keyIds = new KeyIds();\n\n const graphColumns = planTable(snapshot.graph, \"graph\", notes, note);\n const nodeColumns = planTable(snapshot.nodes, \"node\", notes, note);\n const edgeColumns = planTable(snapshot.edges, \"edge\", notes, note);\n const keys = planKeys([...graphColumns, ...nodeColumns, ...edgeColumns], keyIds);\n if (keyOrdered) {\n // an element's data in the order of its keys, as a re-import orders its columns, so that exporting what a\n // styled export reads back gives the same bytes. ponytail: styled exports only, so an export without\n // styles keeps its bytes; extend it to every export when that change is wanted on its own.\n const keyOrder = new Map(keys.map((k, i) => [k.id, i]));\n const byKey = (a: ColumnPlan, b: ColumnPlan): number =>\n (keyOrder.get(a.keyId) ?? 0) - (keyOrder.get(b.keyId) ?? 0);\n nodeColumns.sort(byKey);\n edgeColumns.sort(byKey);\n }\n reservedNameNotes(nodeColumns, RESERVED_NODE_NAMES, note);\n reservedNameNotes(edgeColumns, RESERVED_EDGE_NAMES, note);\n const weight = planWeight(snapshot, edgeColumns, keyIds, keys, note);\n\n // ids\n const idTypeChanges = countIdTypeChanges(snapshot);\n if (idTypeChanges > 0) {\n note(\n GRAPHML_LOSS.ID_TEXT_TYPE,\n `${idTypeChanges} node id${plural(idTypeChanges)} ${agree(idTypeChanges, \"changes\", \"change\")} type when read back under ids: \"canonical\" (string ids that are integer text, non-integer numbers)`,\n null,\n idTypeChanges,\n );\n }\n const edgeIdColumn = snapshot.edges.byRole(\"id\");\n if (edgeIdColumn !== null) {\n planEdgeIds(snapshot, edgeIdColumn, options, note);\n }\n const unrepresentable = countUnrepresentableNodeIds(snapshot);\n const needsOriginalIdKey = unrepresentable > 0 && options.sanitizeIds === \"mangle\";\n const originalIdKey = needsOriginalIdKey ? keyIds.next(null) : null;\n\n // direction: an undirected pair folds to one undirected edge, a mutual pair too (the mark is lost)\n const folding = pairFolding(snapshot, { foldMutual: true });\n if (folding.mutualCount > 0) {\n note(\n GRAPHML_LOSS.MUTUAL_AS_UNDIRECTED,\n `${folding.mutualCount} mutual pair${plural(folding.mutualCount)} ${agree(folding.mutualCount, \"is\", \"are\")} written as undirected edges; the mutual mark is lost`,\n null,\n folding.mutualCount,\n );\n }\n const edgedefault = planEdgedefault(snapshot, folding, format, meta);\n\n // containment\n const hierarchy = planHierarchy(snapshot);\n if (hierarchy.reordered) {\n note(\n GRAPHML_LOSS.HIERARCHY_REORDERED,\n \"nodes are written in containment order (children nested under their parent); node indices change after a round trip\",\n hierarchy.parent?.meta.name ?? null,\n );\n }\n if (hierarchy.unreachable > 0) {\n note(\n GRAPHML_LOSS.PARENT_CYCLE,\n `${hierarchy.unreachable} node${plural(hierarchy.unreachable)} whose parent chain never reaches a root ${agree(hierarchy.unreachable, \"is\", \"are\")} written at the top level`,\n hierarchy.parent?.meta.name ?? null,\n hierarchy.unreachable,\n );\n }\n\n return {\n options,\n pretty: format.pretty,\n notes,\n keys,\n graphColumns,\n nodeColumns,\n edgeColumns,\n weight,\n originalIdKey,\n edgedefault,\n folding,\n edgeIdColumn,\n sourcePortColumn: snapshot.edges.byRole(\"sourcePort\"),\n targetPortColumn: snapshot.edges.byRole(\"targetPort\"),\n hierarchy,\n meta,\n needsOriginalIdKey,\n };\n}\n\n/**\n * A plain column titled like one of the importer's XML-derived columns (`id`, `sourceport`,\n * `targetport` on edges, `parent` on nodes) reads back renamed `<name>#<key id>` (design section\n * 5.6); the note says so.\n * @param plans - the column plans of one domain, key ids assigned\n * @param reserved - the reserved names of that domain\n * @param note - the note recorder\n */\nfunction reservedNameNotes(plans: readonly ColumnPlan[], reserved: ReadonlySet<string>, note: NoteFn): void {\n for (const plan of plans) {\n const { column, attrName, keyId } = plan;\n if (attrName === null || !reserved.has(attrName)) {\n continue;\n }\n note(\n LOSS.COLUMN_NAME_CHANGED,\n `${plan.domain} column \"${column.meta.name}\" is titled like the importer's ${attrName} column and reads back as \"${attrName}#${keyId}\"`,\n column.meta.name,\n column.length - column.nullCount,\n );\n }\n}\n\n/** The key ids handed out so far: a preferred NMTOKEN when free, else the next free `d<n>`. */\nclass KeyIds {\n private readonly used = new Set<string>();\n private counter = 0;\n\n /**\n * Take a key id.\n * @param preferred - the id to keep when it is an NMTOKEN not handed out yet, or null\n * @returns the id\n */\n next(preferred: string | null): string {\n if (preferred !== null && isNmtoken(preferred) && !this.used.has(preferred)) {\n this.used.add(preferred);\n return preferred;\n }\n for (;;) {\n const candidate = `d${this.counter}`;\n this.counter++;\n if (!this.used.has(candidate)) {\n this.used.add(candidate);\n return candidate;\n }\n }\n }\n}\n\n/**\n * The `<key>` elements: columns sharing a GraphML origin.id across domains become one for=\"all\"\n * key when their name, type and default agree; every other column is its own key.\n * @param all - the column plans of the three domains, in writing order\n * @param keyIds - the key id allocator\n * @returns the keys, in declaration order\n */\nfunction planKeys(all: readonly ColumnPlan[], keyIds: KeyIds): KeyPlan[] {\n const keys: KeyPlan[] = [];\n const byOrigin = new Map<string, ColumnPlan[]>();\n for (const plan of all) {\n const { origin } = plan.column.meta;\n if (origin !== null && origin.format === FORMAT && origin.id !== null) {\n const group = byOrigin.get(origin.id) ?? [];\n group.push(plan);\n byOrigin.set(origin.id, group);\n }\n }\n const planned = new Set<ColumnPlan>();\n for (const plan of all) {\n if (planned.has(plan)) {\n continue;\n }\n const { origin } = plan.column.meta;\n const group =\n origin !== null && origin.format === FORMAT && origin.id !== null\n ? (byOrigin.get(origin.id) ?? [plan])\n : [plan];\n const shared = group.length > 1 && group.every((other) => other === plan || sameKey(plan, other));\n const members = shared ? group : [plan];\n const id = keyIds.next(origin !== null && origin.format === FORMAT ? origin.id : null);\n for (const member of members) {\n member.keyId = id;\n planned.add(member);\n }\n const domains = members.map((member) => member.domain);\n // a yfiles key carries attr.name only when the column name is not the key id (yEd writes none)\n const yfilesName = plan.column.meta.origin?.title ?? plan.column.meta.name;\n let { attrName } = plan;\n if (plan.yfiles) {\n attrName = yfilesName === id ? null : yfilesName;\n }\n keys.push({\n id,\n domains: domains.length > 1 ? [\"graph\", \"node\", \"edge\"] : domains,\n attrName,\n attrType: plan.attrType,\n yfilesType: plan.yfilesType,\n column: plan.column,\n });\n }\n return keys;\n}\n\n/**\n * The weight key of a weighted snapshot (its attr.name and attr.type restored from\n * meta.weightOrigin when the weight came from GraphML), and the note for an edge column the\n * importer would read as THE weight: every edge key titled like the weight key (`weight` by\n * default) is a weight key on import, so such a column reads back as the weight, not as a column.\n * @param snapshot - the snapshot\n * @param edgeColumns - the edge column plans\n * @param keyIds - the key id allocator\n * @param keys - receives the weight key\n * @param note - the note recorder\n * @returns the weight plan, or null for an unweighted snapshot\n */\nfunction planWeight(\n snapshot: GraphSnapshot,\n edgeColumns: readonly ColumnPlan[],\n keyIds: KeyIds,\n keys: KeyPlan[],\n note: NoteFn,\n): Plan[\"weight\"] {\n const weights = explicitWeights(snapshot);\n const origin = snapshot.meta.weightOrigin;\n const fromGraphml = weights.weighted && origin !== null && origin.format === FORMAT;\n const attrName = fromGraphml && origin.title !== null ? origin.title : DEFAULT_WEIGHT_NAME;\n for (const plan of edgeColumns) {\n if (plan.attrName === attrName) {\n note(\n LOSS.WEIGHT_KEY_CLASH,\n `edge column \"${plan.column.meta.name}\" is written as a key titled \"${attrName}\", which the importer reads as the edge weight (weightFrom); it reads back as the weight, not as a column`,\n plan.column.meta.name,\n plan.column.length - plan.column.nullCount,\n );\n }\n }\n if (!weights.weighted) {\n return null;\n }\n let attrType = \"double\";\n if (fromGraphml && origin.type !== null) {\n const declared = origin.type.trim().toLowerCase();\n if (declared === \"float\" || declared === \"double\" || declared === \"long\" || declared === \"int\") {\n attrType = declared;\n }\n }\n if ((attrType === \"int\" || attrType === \"long\") && !weightsIntegral(snapshot, weights)) {\n // a declared integer weight only survives when every explicit weight is integral\n attrType = \"double\";\n }\n const id = keyIds.next(fromGraphml ? origin.id : null);\n keys.push({ id, domains: [\"edge\"], attrName, attrType, yfilesType: null, column: null });\n return { keyId: id, attrType, weights };\n}\n\n/**\n * The notes about the edge id column: a numeric column reads back as string; ids outside the\n * NMTOKEN charset are refused or mangled per sanitizeIds.\n * @param snapshot - the snapshot\n * @param column - the edge id column\n * @param options - the resolved options\n * @param note - the note recorder\n */\nfunction planEdgeIds(snapshot: GraphSnapshot, column: Column, options: ResolvedExportOptions, note: NoteFn): void {\n if (column.dtype !== \"string\" && column.dtype !== \"dict\") {\n note(\n GRAPHML_LOSS.EDGE_ID_TEXT,\n `edge id column \"${column.meta.name}\" is ${column.dtype}; GraphML edge ids read back as strings`,\n column.meta.name,\n snapshot.edgeCount - column.nullCount,\n );\n }\n const bad = countBadEdgeIds(column);\n if (bad === 0) {\n return;\n }\n if (options.sanitizeIds === \"mangle\") {\n note(\n LOSS.ID_MANGLED,\n `${bad} edge id${plural(bad)} outside the nmtoken charset ${agree(bad, \"is\", \"are\")} rewritten`,\n column.meta.name,\n bad,\n );\n } else {\n note(\n LOSS.ID_CHARSET,\n `${bad} edge id${plural(bad)} outside the nmtoken charset; the save fails unless sanitizeIds is \"mangle\"`,\n column.meta.name,\n bad,\n );\n }\n}\n\n/**\n * The top-level edgedefault: the override, else undirected for an undirected snapshot, else\n * directed when no written edge is undirected, else the one the importer recorded, else the\n * majority direction.\n * @param snapshot - the snapshot\n * @param folding - the pair folding\n * @param format - the resolved format options\n * @param meta - the importer's meta, or null\n * @returns the edgedefault\n */\nfunction planEdgedefault(\n snapshot: GraphSnapshot,\n folding: PairFolding,\n format: FormatOptions,\n meta: GraphmlMeta | null,\n): \"directed\" | \"undirected\" {\n if (format.edgedefault !== null) {\n return format.edgedefault;\n }\n if (!snapshot.directed) {\n return \"undirected\";\n }\n let directedCount = 0;\n let undirectedCount = 0;\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (folding.folded(e)) {\n continue;\n }\n if (isDirectedEdge(folding, e)) {\n directedCount++;\n } else {\n undirectedCount++;\n }\n }\n if (undirectedCount === 0) {\n return \"directed\";\n }\n const recorded = meta === null ? null : meta.edgedefault;\n if (recorded !== null) {\n return recorded;\n }\n return undirectedCount > directedCount ? \"undirected\" : \"directed\";\n}\n\n/**\n * Whether two column plans can share one for=\"all\" key.\n * @param a - one plan\n * @param b - another\n * @returns true when name, type and default agree\n */\nfunction sameKey(a: ColumnPlan, b: ColumnPlan): boolean {\n return (\n a.attrName === b.attrName &&\n a.attrType === b.attrType &&\n a.yfilesType === b.yfilesType &&\n a.domain !== b.domain &&\n JSON.stringify(a.column.meta.default ?? null) === JSON.stringify(b.column.meta.default ?? null)\n );\n}\n\n/**\n * Classify the columns of one table: which are written as keys and what each loses. A label\n * column is written into the label slot (a key titled `label`, which the importer reads back\n * with the role) unless the table holds another column of that name, in which case it keeps\n * its own title and the role is lost.\n * @param table - the table\n * @param domain - its domain\n * @param notes - the notes so far (the generic name-change note of a label column that cannot take the slot is withdrawn)\n * @param note - the note recorder\n * @returns the plans of the written columns, in declaration order\n */\nfunction planTable(table: Iterable<Column>, domain: Domain, notes: LossNote[], note: NoteFn): ColumnPlan[] {\n const plans: ColumnPlan[] = [];\n const columns = [...table];\n const names = new Set(columns.map((column) => column.meta.name));\n for (const column of columns) {\n const { meta } = column;\n const { role, name } = meta;\n if (isGraphicsColumn(meta)) {\n const stale = domain === \"graph\" ? 0 : staleGraphicsRows(column, columns, domain);\n if (stale > 0) {\n note(\n GRAPHML_LOSS.YFILES_GRAPHICS_STALE,\n `${stale} value${plural(stale)} of ${domain} column \"${name}\" differ from the yFiles tree it was read from; only the tree is written, so they are lost`,\n name,\n stale,\n );\n }\n continue;\n }\n if (role === \"parents\") {\n note(\n GRAPHML_LOSS.PARENTS_DROPPED,\n `${domain} column \"${name}\" (parents) cannot be written: nested graphs hold one parent per node`,\n name,\n column.length - column.nullCount,\n );\n continue;\n }\n if (\n role !== null &&\n (STRUCTURAL_ROLES.has(role) || DROPPED_ROLES.has(role) || SLOT_ROLES_BY_DOMAIN[domain].has(role))\n ) {\n continue;\n }\n if (role !== null && role !== \"label\" && SLOT_ROLES.has(role)) {\n // the slot belongs to another domain (an edge id on a node, a port on a graph)\n withdrawNameChange(notes, name);\n note(\n LOSS.ROLE,\n `${domain} column \"${name}\" (${role}) is written as a plain attribute; GraphML has no ${role} slot for a ${domain} and the role is lost`,\n name,\n column.length - column.nullCount,\n );\n }\n const yfiles = meta.dtype === \"json\" && meta.origin?.namespace === \"yfiles\";\n if (meta.dtype === \"json\" && !yfiles) {\n note(\n LOSS.JSON,\n `${domain} column \"${name}\" holds nested values; written as JSON text, which reads back as string`,\n name,\n column.length - column.nullCount,\n );\n }\n if (yfiles) {\n const bad = countBadTrees(column);\n if (bad > 0) {\n note(\n GRAPHML_LOSS.YFILES_TREE,\n `${bad} value${plural(bad)} of yfiles column \"${name}\" ${agree(bad, \"is\", \"are\")} not XML trees; the save fails with E_COLUMN_TYPE`,\n name,\n bad,\n );\n }\n }\n const { origin } = meta;\n const fromGraphml = origin !== null && origin.format === FORMAT;\n let attrName: string | null = null;\n if (!yfiles) {\n attrName = fromGraphml && origin.title !== null ? origin.title : name;\n if (role === \"label\" && domain !== \"graph\" && attrName !== LABEL_COLUMN) {\n attrName = labelSlot(column, domain, names, notes, note);\n } else if (role === null && domain !== \"graph\" && attrName === LABEL_COLUMN) {\n note(\n LOSS.ROLE_ASSUMED,\n `${domain} column \"${name}\" has no role but is titled \"${LABEL_COLUMN}\", which the importer reads back with the label role`,\n name,\n column.length - column.nullCount,\n );\n }\n }\n plans.push({\n column,\n domain,\n keyId: \"\",\n attrType: yfiles ? null : attrTypeFor(column),\n attrName,\n yfilesType: yfiles ? (origin?.type ?? DEFAULT_YFILES_TYPES[domain]) : null,\n yfiles,\n });\n }\n return plans;\n}\n\n/**\n * The title a label column not named `label` is written under: the label slot when the table has\n * no other column of that name (checkCapabilities() has noted the name change), else its own\n * name with the role lost (the name-change note is withdrawn and a role note recorded).\n * @param column - the label column\n * @param domain - its domain\n * @param names - the column names of the table\n * @param notes - the notes so far\n * @param note - the note recorder\n * @returns the attr.name\n */\nfunction labelSlot(\n column: Column,\n domain: Domain,\n names: ReadonlySet<string>,\n notes: LossNote[],\n note: NoteFn,\n): string {\n const { name } = column.meta;\n if (!names.has(LABEL_COLUMN)) {\n return LABEL_COLUMN;\n }\n withdrawNameChange(notes, name);\n note(\n LOSS.ROLE,\n `${domain} column \"${name}\" (label) is written as a plain attribute: the label slot (a key titled \"${LABEL_COLUMN}\") is taken by column \"${LABEL_COLUMN}\" and the role is lost`,\n name,\n column.length - column.nullCount,\n );\n return name;\n}\n\n/**\n * Withdraw the name-change note checkCapabilities() recorded for a role column that does not\n * take the slot after all.\n * @param notes - the notes so far\n * @param name - the column name\n */\nfunction withdrawNameChange(notes: LossNote[], name: string): void {\n const at = notes.findIndex((n) => n.code === LOSS.COLUMN_NAME_CHANGED && n.column === name);\n if (at >= 0) {\n notes.splice(at, 1);\n }\n}\n\n/**\n * The attr.type a column is declared with: the GraphML origin.type when it still describes the\n * column, else the type of the dtype (u32 / u8 as int or long, dict as string, list / json /\n * multi-component as string holding JSON text).\n * @param column - the column\n * @returns the attr.type text\n */\nfunction attrTypeFor(column: Column): string {\n const { meta } = column;\n const { origin } = meta;\n const declared = origin !== null && origin.format === FORMAT && origin.type !== null ? origin.type : null;\n if (meta.components > 1) {\n return \"string\";\n }\n switch (meta.dtype) {\n case \"bool\":\n return \"boolean\";\n case \"i32\":\n return \"int\";\n case \"f32\":\n return \"float\";\n case \"f64\": {\n if (declared !== null && declared.trim().toLowerCase() === \"long\" && columnIntegral(column)) {\n return \"long\";\n }\n return \"double\";\n }\n case \"u8\":\n return \"int\";\n case \"u32\":\n return columnMax(column) <= I32_MAX ? \"int\" : \"long\";\n case \"string\":\n if (declared !== null && declared.trim().toLowerCase() === \"long\" && columnIntegerText(column)) {\n // a long column read with long: \"string\" keeps its declared type, for other readers\n return \"long\";\n }\n if (declared !== null && TYPE_DTYPES[declared.trim().toLowerCase()] === undefined) {\n // an unknown declared type kept as text (W_UNKNOWN_ATTR_TYPE on import) is restored as declared\n return declared;\n }\n return \"string\";\n case \"dict\":\n case \"list\":\n case \"json\":\n return \"string\";\n default: {\n const { dtype } = meta;\n throw new GraphFormatError(\"E_UNSUPPORTED\", `unknown dtype ${String(dtype)}`, { dtype });\n }\n }\n}\n\n/**\n * Whether every set value of a string column is integer text, as a long column read with\n * `long: \"string\"` holds.\n * @param column - a string column\n * @returns true when all set values are integer text\n */\nfunction columnIntegerText(column: Column): boolean {\n for (let r = 0; r < column.length; r++) {\n if (column.isSet(r) && !/^[+-]?\\d+$/.test(String(column.value(r)))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Whether every set value of a numeric column is an integer.\n * @param column - an f64 column\n * @returns true when all set values are integral\n */\nfunction columnIntegral(column: Column): boolean {\n if (column.dtype !== \"f64\") {\n return false;\n }\n const { data } = column;\n for (let r = 0; r < column.length; r++) {\n if (column.isSet(r) && !Number.isInteger(data[r])) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The largest set value of a u32 column.\n * @param column - a u32 column\n * @returns the maximum, 0 for an empty column\n */\nfunction columnMax(column: Column): number {\n if (column.dtype !== \"u32\") {\n return 0;\n }\n let max = 0;\n const { data } = column;\n for (let r = 0; r < column.length; r++) {\n if (column.isSet(r) && data[r] > max) {\n max = data[r];\n }\n }\n return max;\n}\n\n/**\n * Whether every explicit weight is integral (so a declared int / long weight key survives).\n * @param snapshot - the snapshot\n * @param weights - the explicit weights\n * @returns true when all explicit weights are integers\n */\nfunction weightsIntegral(snapshot: GraphSnapshot, weights: ExplicitWeights): boolean {\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (weights.isExplicit(e) && !Number.isInteger(weights.value(e))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * How many values of a yfiles column are not serializable trees.\n * @param column - a json column\n * @returns the count\n */\nfunction countBadTrees(column: Column): number {\n if (column.dtype !== \"json\") {\n return 0;\n }\n let bad = 0;\n for (let r = 0; r < column.length; r++) {\n if (column.isSet(r) && treeProblem(column.values[r]) !== null) {\n bad++;\n }\n }\n return bad;\n}\n\n/**\n * Node ids that read back as another type under the canonical rule: string ids that are\n * canonical integer text, and numbers that are not safe integers.\n * @param snapshot - the snapshot\n * @returns the count\n */\nfunction countIdTypeChanges(snapshot: GraphSnapshot): number {\n const { ids } = snapshot;\n if (ids.kind === \"identity\" || ids.kind === \"dense\") {\n return 0;\n }\n let count = 0;\n for (let i = 0; i < ids.size; i++) {\n const id = ids.idOf(i);\n if (typeof id === \"string\" ? isNmtoken(id) && isCanonicalIntegerText(id) : !Number.isSafeInteger(id)) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Node ids the nmtoken charset cannot hold.\n * @param snapshot - the snapshot\n * @returns the count\n */\nfunction countUnrepresentableNodeIds(snapshot: GraphSnapshot): number {\n const { ids } = snapshot;\n if (ids.kind === \"identity\" || ids.kind === \"dense\") {\n return 0;\n }\n let count = 0;\n for (let i = 0; i < ids.size; i++) {\n if (!isNmtoken(String(ids.idOf(i)))) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Edge ids that are not NMTOKENs.\n * @param column - the edge id column\n * @returns the count\n */\nfunction countBadEdgeIds(column: Column): number {\n let bad = 0;\n for (let e = 0; e < column.length; e++) {\n if (column.isSet(e) && !isNmtoken(edgeIdText(column, e))) {\n bad++;\n }\n }\n return bad;\n}\n\n/**\n * The text of an edge id cell.\n * @param column - the edge id column\n * @param e - the edge\n * @returns the id as text\n */\nfunction edgeIdText(column: Column, e: number): string {\n const value = column.value(e);\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\") {\n return Number.isInteger(value) ? formatInteger(value) : formatF64(value);\n }\n return String(value);\n}\n\n/**\n * Whether a logical edge is written as directed: never in an undirected snapshot; never for a\n * half of an expanded pair (an undirected or a mutual source edge, whose halves the resolver\n * flags directed); otherwise per the directed role column, with directed as the default.\n * @param folding - the pair folding\n * @param e - the edge\n * @returns false for a paired edge or an edge flagged undirected\n */\nfunction isDirectedEdge(folding: PairFolding, e: number): boolean {\n return folding.mateOf(e) === INVALID_INDEX && folding.sourceDirected(e);\n}\n\n/**\n * The containment order: the children CSR over the parent column (src/children.ts), roots in\n * index order, unreachable nodes (cycles) forced to the top level.\n * @param snapshot - the snapshot\n * @returns the hierarchy\n */\nfunction planHierarchy(snapshot: GraphSnapshot): Hierarchy {\n const parent = snapshot.nodes.byRole(\"parent\");\n const csr = childrenCsr(snapshot, { column: parent !== null && parent.dtype === \"u32\" ? parent : null });\n const walk = csr.depthFirst();\n // the top-level nodes in written order: the roots, then the cycle members forced out\n const roots = walk.order.filter((u) => walk.depth[u] === 0);\n return {\n parent: csr.column,\n roots,\n childStart: csr.rowPtr,\n childList: csr.children,\n reordered: walk.reordered,\n unreachable: csr.unreachable,\n };\n}\n\n// ============================================================ writing\n\n/**\n * The text of one set cell for a `<data>` element or a `<default>`.\n * @param column - the column\n * @param row - the row\n * @param attrType - the declared attr.type\n * @returns the text\n */\nfunction cellText(column: Column, row: number, attrType: string | null): string {\n if (column.meta.components > 1) {\n const value = column.value(row);\n return JSON.stringify(Array.from(value as ArrayLike<number>));\n }\n switch (column.dtype) {\n case \"bool\":\n return column.value(row) === true ? \"true\" : \"false\";\n case \"i32\":\n case \"u32\":\n case \"u8\":\n return String(column.data[row]);\n case \"f32\":\n return formatF32(column.data[row]);\n case \"f64\": {\n const value = column.data[row];\n return (attrType === \"long\" || attrType === \"int\") && Number.isInteger(value)\n ? formatInteger(value)\n : formatF64(value);\n }\n case \"string\":\n return column.valueAt(row);\n case \"dict\":\n return column.dictionary[column.codes[row]];\n case \"list\":\n return JSON.stringify(Array.from(column.sliceOf(row)));\n case \"json\":\n return JSON.stringify(column.values[row]) ?? \"\";\n default: {\n const dtype: never = column;\n throw new GraphFormatError(\"E_UNSUPPORTED\", `unknown dtype ${String(dtype)}`, {});\n }\n }\n}\n\n/**\n * The text of a declared default.\n * @param column - the column\n * @param attrType - the declared attr.type\n * @returns the text, or null when the column has no default\n */\nfunction defaultText(column: Column, attrType: string | null): string | null {\n const value = column.meta.default;\n if (value === undefined) {\n return null;\n }\n switch (typeof value) {\n case \"boolean\":\n return value ? \"true\" : \"false\";\n case \"number\":\n if (column.dtype === \"f32\") {\n return formatF32(value);\n }\n return (attrType === \"long\" || attrType === \"int\") && Number.isInteger(value)\n ? formatInteger(value)\n : formatF64(value);\n case \"string\":\n return value;\n default:\n return JSON.stringify(value) ?? \"\";\n }\n}\n\n/**\n * Write one `<data>` element.\n * @param plan - the column plan\n * @param row - the row\n * @param indent - the indentation\n * @param out - receives the parts\n */\nfunction writeData(plan: ColumnPlan, row: number, indent: string, out: string[]): void {\n const { column } = plan;\n if (!column.isSet(row)) {\n return;\n }\n if (plan.yfiles && column.dtype === \"json\") {\n writeTreeData(plan.keyId, column.values[row], indent, out);\n return;\n }\n out.push(`\\n${indent}<data key=\"${plan.keyId}\">${escapeXmlText(cellText(column, row, plan.attrType))}</data>`);\n}\n\n/**\n * Write a `<data>` holding a yfiles tree.\n * @param keyId - the key id\n * @param value - the tree\n * @param indent - the indentation\n * @param out - receives the parts\n */\nfunction writeTreeData(keyId: string, value: unknown, indent: string, out: string[]): void {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n const parts: string[] = [];\n writeXmlTree(value, indent, parts);\n out.push(`\\n${indent}<data key=\"${keyId}\">${parts.join(\"\")}</data>`);\n return;\n }\n out.push(`\\n${indent}<data key=\"${keyId}\">`);\n writeXmlTree(value, `${indent} `, out);\n out.push(`\\n${indent}</data>`);\n}\n\n/**\n * Append the `<default>` element of a key.\n * @param key - the key\n * @param column - the key's column\n * @param inner - the indentation of the element\n * @param parts - where to append\n */\nfunction pushDefault(key: KeyPlan, column: Column, inner: string, parts: string[]): void {\n if (key.yfilesType === null) {\n parts.push(`\\n${inner}<default>${escapeXmlText(defaultText(column, key.attrType) ?? \"\")}</default>`);\n return;\n }\n const value = column.meta.default;\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n parts.push(`\\n${inner}<default>`);\n writeXmlTree(value, `${inner} `, parts);\n parts.push(`\\n${inner}</default>`);\n } else {\n const tree: string[] = [];\n writeXmlTree(value, inner, tree);\n parts.push(`\\n${inner}<default>${tree.join(\"\")}</default>`);\n }\n}\n\n/**\n * The `<key>` element of a plan.\n * @param key - the key plan\n * @param indent - the indentation\n * @returns the element text\n */\nfunction keyElement(key: KeyPlan, indent: string): string {\n const domain = key.domains.length === 3 ? \"all\" : key.domains[0];\n let text = `${indent}<key id=\"${escapeXmlAttribute(key.id)}\" for=\"${domain}\"`;\n if (key.attrName !== null) {\n text += ` attr.name=\"${escapeXmlAttribute(key.attrName)}\"`;\n }\n if (key.attrType !== null) {\n text += ` attr.type=\"${escapeXmlAttribute(key.attrType)}\"`;\n }\n if (key.yfilesType !== null) {\n // a yFiles 3 key is identified by its attr.uri, which the importer keeps as the column's type\n const uri = key.yfilesType.includes(\"://\");\n text += ` ${uri ? \"y:attr.uri\" : \"yfiles.type\"}=\"${escapeXmlAttribute(key.yfilesType)}\"`;\n }\n const { column } = key;\n const desc = column?.meta.extra.desc;\n const hasDefault = column?.meta.default !== undefined;\n if (column === null || (typeof desc !== \"string\" && !hasDefault)) {\n return `${text}/>\\n`;\n }\n const parts: string[] = [`${text}>`];\n const inner = `${indent} `;\n if (typeof desc === \"string\") {\n parts.push(`\\n${inner}<desc>${escapeXmlText(desc)}</desc>`);\n }\n if (hasDefault) {\n pushDefault(key, column, inner, parts);\n }\n parts.push(`\\n${indent}</key>\\n`);\n return parts.join(\"\");\n}\n\n/**\n * Sanitised edge ids: NMTOKENs as they are; the rest refused or mangled per sanitizeIds.\n * @param column - the edge id column, or null\n * @param mode - the resolved sanitizeIds option\n * @param edgeCount - the edge count\n * @returns the id text per edge (null for edges without one)\n */\nfunction sanitizeEdgeIds(column: Column | null, mode: \"error\" | \"mangle\", edgeCount: number): (string | null)[] {\n const out: (string | null)[] = new Array<string | null>(edgeCount).fill(null);\n if (column === null) {\n return out;\n }\n const used = new Set<string>();\n const bad: number[] = [];\n for (let e = 0; e < edgeCount; e++) {\n if (!column.isSet(e)) {\n continue;\n }\n const text = edgeIdText(column, e);\n if (isNmtoken(text)) {\n out[e] = text;\n used.add(text);\n } else {\n bad.push(e);\n }\n }\n if (bad.length > 0 && mode === \"error\") {\n throw new GraphFormatError(\n \"E_INVALID_ID\",\n `${bad.length} edge id${plural(bad.length)} ${agree(bad.length, \"is\", \"are\")} not XML name tokens (first: ${JSON.stringify(edgeIdText(column, bad[0]))} at edge ${bad[0]}); pass sanitizeIds: \"mangle\" to rewrite them`,\n { reason: \"charset\", charset: \"nmtoken\", count: bad.length, edge: bad[0] },\n );\n }\n for (const e of bad) {\n const base = mangleNmtoken(edgeIdText(column, e));\n let candidate = base;\n for (let k = 2; used.has(candidate); k++) {\n candidate = `${base}_${k}`;\n }\n used.add(candidate);\n out[e] = candidate;\n }\n return out;\n}\n\n/**\n * The document as text parts.\n * @param snapshot - the snapshot\n * @param plan - the plan\n * @yields one element (or a group of small ones) at a time\n * @returns nothing\n */\nfunction* writeGraphml(snapshot: GraphSnapshot, plan: Plan): Generator<string, void, undefined> {\n const ids: SanitizedIds = sanitizeIds(snapshot, \"nmtoken\", plan.options.sanitizeIds);\n const edgeIds = sanitizeEdgeIds(plan.edgeIdColumn, plan.options.sanitizeIds, snapshot.edgeCount);\n const i1 = plan.pretty ? \" \" : \"\";\n const i2 = plan.pretty ? \" \" : \"\";\n const i3 = plan.pretty ? \" \" : \"\";\n const step = plan.pretty ? \" \" : \"\";\n\n yield '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n yield rootElement(plan);\n\n for (const key of plan.keys) {\n yield keyElement(key, i1);\n }\n if (plan.originalIdKey !== null) {\n yield `${i1}<key id=\"${plan.originalIdKey}\" for=\"node\" attr.name=\"${ORIGINAL_ID_ATTRIBUTE}\" attr.type=\"string\"/>\\n`;\n }\n\n const graphId = plan.meta?.graphId ?? \"G\";\n yield `${i1}<graph id=\"${escapeXmlAttribute(graphId)}\" edgedefault=\"${plan.edgedefault}\">`;\n const { description } = snapshot.meta;\n if (description !== null) {\n yield `\\n${i2}<desc>${escapeXmlText(description)}</desc>`;\n }\n const graphParts: string[] = [];\n for (const column of plan.graphColumns) {\n writeData(column, 0, i2, graphParts);\n }\n if (graphParts.length > 0) {\n yield graphParts.join(\"\");\n }\n\n // nodes in containment order, children nested under their parent\n const { hierarchy } = plan;\n const nested = hierarchy.childList.length > 0;\n const walk: SubtreeWalk = {\n stackNode: [],\n stackCursor: [],\n written: nested ? new Uint8Array(snapshot.nodeCount) : null,\n };\n for (const rootNode of hierarchy.roots) {\n yield* writeNodeSubtree(rootNode, plan, ids, i2, step, walk);\n }\n\n // edges: primaries only, in index order\n const list = snapshot.edgeList();\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (!plan.folding.folded(e)) {\n const start = edgeStartTag(snapshot, plan, e, String(ids.idAt(list.src[e])), String(ids.idAt(list.dst[e])));\n yield edgeElement(plan, e, edgeIds[e], start, [i2, i3]);\n }\n }\n\n yield `\\n${i1}</graph>\\n</graphml>\\n`;\n}\n\n/**\n * The opening `<graphml>` tag with its namespaces: the kept ones, yFiles' where graphics or yFiles columns are written,\n * and XML Schema's for the schema location.\n * @param plan - the plan\n * @returns the tag\n */\nfunction rootElement(plan: Plan): string {\n const namespaces: Record<string, string> = { ...plan.meta?.namespaces };\n const yfilesColumns =\n plan.nodeColumns.some((c) => c.yfiles) ||\n plan.edgeColumns.some((c) => c.yfiles) ||\n plan.graphColumns.some((c) => c.yfiles);\n if (\n plan.yedGraphics === true ||\n (yfilesColumns &&\n !Object.values(namespaces).includes(YFILES_NAMESPACE) &&\n // a yFiles 3 file binds `y` to its own namespace, which its kept trees are written in\n namespaces.y === undefined)\n ) {\n namespaces.y = YFILES_NAMESPACE;\n }\n if (!Object.values(namespaces).includes(XSI_NAMESPACE)) {\n namespaces.xsi = XSI_NAMESPACE;\n }\n let root = `<graphml xmlns=\"${GRAPHML_NAMESPACE}\"`;\n for (const [prefix, uri] of Object.entries(namespaces)) {\n root += ` xmlns:${prefix}=\"${escapeXmlAttribute(uri)}\"`;\n }\n const xsiPrefix = Object.entries(namespaces).find(([, uri]) => uri === XSI_NAMESPACE)?.[0] ?? \"xsi\";\n return `${root} ${xsiPrefix}:schemaLocation=\"${SCHEMA_LOCATION}\">\\n`;\n}\n\n/**\n * An edge's attributes after `<edge`: its source and target, a `directed` that differs from the default, its ports.\n * @param snapshot - the snapshot\n * @param plan - the plan\n * @param e - the edge\n * @param source - the source's written id\n * @param target - the target's written id\n * @returns the attribute text\n */\nfunction edgeStartTag(snapshot: GraphSnapshot, plan: Plan, e: number, source: string, target: string): string {\n let text = ` source=\"${escapeXmlAttribute(source)}\" target=\"${escapeXmlAttribute(target)}\"`;\n const directed = snapshot.directed && isDirectedEdge(plan.folding, e);\n if (directed !== (plan.edgedefault === \"directed\")) {\n text += ` directed=\"${directed ? \"true\" : \"false\"}\"`;\n }\n const sourcePort = portText(plan.sourcePortColumn, e);\n if (sourcePort !== null) {\n text += ` sourceport=\"${escapeXmlAttribute(sourcePort)}\"`;\n }\n const targetPort = portText(plan.targetPortColumn, e);\n if (targetPort !== null) {\n text += ` targetport=\"${escapeXmlAttribute(targetPort)}\"`;\n }\n return text;\n}\n\n/**\n * One `<edge>` element with its weight and data.\n * @param plan - the plan\n * @param e - the edge\n * @param id - its written id, or null\n * @param start - its attributes after the id\n * @param indents - the edge's indentation and its data's\n * @returns the element text\n */\nfunction edgeElement(\n plan: Plan,\n e: number,\n id: string | null,\n start: string,\n indents: readonly [string, string],\n): string {\n const [i2, i3] = indents;\n const parts: string[] = [`\\n${i2}<edge`];\n if (id !== null) {\n parts.push(` id=\"${escapeXmlAttribute(id)}\"`);\n }\n parts.push(start);\n const open = parts.length;\n if (plan.weight !== null) {\n const { keyId, attrType } = plan.weight;\n const weight = plan.weight.weights.text(e, attrType === \"int\" || attrType === \"long\");\n if (weight !== null) {\n parts.push(`\\n${i3}<data key=\"${keyId}\">${escapeXmlText(weight)}</data>`);\n }\n }\n for (const column of plan.edgeColumns) {\n writeData(column, e, i3, parts);\n }\n if (parts.length === open) {\n parts.push(\"/>\");\n } else {\n parts.splice(open, 0, \">\");\n parts.push(`\\n${i2}</edge>`);\n }\n return parts.join(\"\");\n}\n\n/**\n * The text of a port reference cell.\n * @param column - the sourcePort / targetPort column, or null\n * @param e - the edge\n * @returns the port name, or null when unset\n */\nfunction portText(column: Column | null, e: number): string | null {\n if (!column?.isSet(e)) {\n return null;\n }\n const value = column.value(e);\n return typeof value === \"string\" ? value : String(value);\n}\n\n/** The state a subtree walk reuses from one top-level node to the next. */\ninterface SubtreeWalk {\n /** A reusable stack of open nodes. */\n readonly stackNode: number[];\n /** A reusable stack of child cursors. */\n readonly stackCursor: number[];\n /** Nodes already written (null when nothing is nested). */\n readonly written: Uint8Array | null;\n}\n\n/**\n * Write a top-level node and, nested, every node contained in it (iteratively, so a deep chain\n * cannot overflow the call stack).\n * @param root - the top-level node\n * @param plan - the plan\n * @param ids - the sanitised ids\n * @param indent - the indentation of top-level nodes\n * @param step - one indentation step\n * @param walk - the reusable walk state\n * @yields the node elements\n * @returns nothing\n */\nfunction* writeNodeSubtree(\n root: number,\n plan: Plan,\n ids: SanitizedIds,\n indent: string,\n step: string,\n walk: SubtreeWalk,\n): Generator<string, void, undefined> {\n const { stackNode, stackCursor, written } = walk;\n const { hierarchy } = plan;\n const hasChildren = (u: number): boolean => hierarchy.childStart[u + 1] > hierarchy.childStart[u];\n const openNode = (u: number, depth: number): string => {\n const pad = indent + step.repeat(depth * 2);\n const parts: string[] = [`\\n${pad}<node id=\"${escapeXmlAttribute(String(ids.idAt(u)))}\"`];\n const open = parts.length;\n if (plan.originalIdKey !== null && ids.isChanged(u)) {\n parts.push(\n `\\n${pad}${step}<data key=\"${plan.originalIdKey}\">${escapeXmlText(String(ids.originalAt(u)))}</data>`,\n );\n }\n for (const column of plan.nodeColumns) {\n writeData(column, u, pad + step, parts);\n }\n if (hasChildren(u)) {\n parts.splice(open, 0, \">\");\n const graphId = `${String(ids.idAt(u))}:`;\n parts.push(`\\n${pad}${step}<graph id=\"${escapeXmlAttribute(graphId)}\" edgedefault=\"${plan.edgedefault}\">`);\n return parts.join(\"\");\n }\n if (parts.length === open) {\n parts.push(\"/>\");\n } else {\n parts.splice(open, 0, \">\");\n parts.push(`\\n${pad}</node>`);\n }\n return parts.join(\"\");\n };\n const closeNode = (depth: number): string => {\n const pad = indent + step.repeat(depth * 2);\n return `\\n${pad}${step}</graph>\\n${pad}</node>`;\n };\n if (written !== null) {\n written[root] = 1;\n }\n yield openNode(root, 0);\n if (!hasChildren(root)) {\n return;\n }\n stackNode.push(root);\n stackCursor.push(hierarchy.childStart[root]);\n while (stackNode.length > 0) {\n const top = stackNode.length - 1;\n const u = stackNode[top];\n const cursor = stackCursor[top];\n if (cursor >= hierarchy.childStart[u + 1]) {\n stackNode.pop();\n stackCursor.pop();\n yield closeNode(top);\n continue;\n }\n stackCursor[top] = cursor + 1;\n const v = hierarchy.childList[cursor];\n if (written !== null && written[v] === 1) {\n continue;\n }\n if (written !== null) {\n written[v] = 1;\n }\n yield openNode(v, top + 1);\n if (hasChildren(v)) {\n stackNode.push(v);\n stackCursor.push(hierarchy.childStart[v]);\n }\n }\n}\n\n/**\n * The GraphML exporter.\n * @category Built-in formats\n */\nexport const graphmlExporter: GraphExporter<GraphmlExportOptions> = Object.freeze({\n format: FORMAT,\n options: Object.freeze([\"edgedefault\", \"pretty\"]),\n capabilities: CAPABILITIES,\n styles: Object.freeze({ capabilities: GRAPHML_STYLE_CAPABILITIES }),\n /**\n * Pre-flight: every loss the export would incur.\n * @param snapshot - the snapshot\n * @param options - format-specific and common options\n * @returns the notes\n */\n check(snapshot: GraphSnapshot, options?: GraphmlWriteOptions): readonly LossNote[] {\n const { plan, styled } = prepare(snapshot, options);\n return Object.freeze([...plan.notes, ...(styled?.notes ?? [])]);\n },\n /**\n * Write the document as UTF-8 chunks.\n * @param snapshot - the snapshot\n * @param options - format-specific and common options\n * @returns the chunks\n */\n export(snapshot: GraphSnapshot, options?: GraphmlWriteOptions): AsyncIterable<Uint8Array> {\n const { plan, written } = prepare(snapshot, options);\n return encodeChunks(writeGraphml(written, plan));\n },\n /**\n * Write the document as one string.\n * @param snapshot - the snapshot\n * @param options - format-specific and common options\n * @returns the document\n */\n exportToString(snapshot: GraphSnapshot, options?: GraphmlWriteOptions): Promise<string> {\n const { plan, written } = prepare(snapshot, options);\n return joinText(writeGraphml(written, plan));\n },\n});\n\n/**\n * The plan of an export, with styles: the graph to write with yEd graphics in place of its yFiles columns.\n * @param snapshot - the snapshot\n * @param options - format-specific and common options\n * @returns the plan, the graph to write and the styled export (null without styles)\n */\nfunction prepare(\n snapshot: GraphSnapshot,\n options: GraphmlWriteOptions | undefined,\n): { plan: Plan; written: GraphSnapshot; styled: ReturnType<typeof graphmlStyledExport> } {\n const styled = graphmlStyledExport(snapshot, options?.styles);\n const written = styled?.snapshot ?? snapshot;\n const plan = planExport(written, resolveExportOptions(options), resolveFormatOptions(options), styled !== null);\n if (styled === null) {\n return { plan, written, styled };\n }\n // the yEd graphics carry each node's position in its y:Geometry, so the position column is not lost\n const position = written.nodes.byRole(\"position\")?.meta.name;\n const notes = plan.notes.filter((n) => n.code !== LOSS.POSITIONS || n.column !== position);\n return { plan: { ...plan, notes, yedGraphics: true }, written, styled };\n}\n","/**\n * yFiles 3 styles (yFiles for HTML, yEd Live): the per-element style objects of the `NodeStyle`, `EdgeStyle`,\n * `NodeLabels`, `EdgeLabels`, `NodeGeometry` and `EdgeGeometry` keys, inline or by reference to the graph's `SharedData`, read into\n * the neutral style vocabulary. References are resolved by value with a depth limit; a reference that is circular\n * or deeper than the limit is one `W_STYLE_REFERENCE_CYCLE` note, never a hang.\n */\n\nimport type { GraphSnapshot } from \"@graphty/graph-format\";\n\nimport { type BendPoint, canonBends, canonNodeOffsets } 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 { 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 type { StyleNotes } from \"../../styles/notes.js\";\nimport { plainCell } from \"../../styles/plan/resolve.js\";\nimport type { StyleDialect, StyleTarget, StyleWorkBudget } from \"../../styles/types.js\";\nimport {\n configurationOutline,\n isTree,\n localOf,\n type PutValue,\n type SiteOf,\n treeAttr,\n treeChild,\n treeChildren,\n treeText,\n valueColumns,\n type YedOutline,\n type YedRead,\n} from \"./styles-yed.js\";\n\n/** How deep a chain of shared references is followed. */\nconst MAX_REFERENCE_DEPTH = 16;\n\n/** A style object: its element's local name and the element. */\ninterface StyleObject {\n readonly tag: string;\n readonly e: unknown;\n}\n\n/** `{x:Null}`: a property explicitly set to nothing. */\nconst NULL = Symbol(\"x:Null\");\n\n/** A property value resolved through references. */\ntype Resolved = StyleObject | string | typeof NULL | null;\n\n/** A paint: a color in a dialect, `{x:Null}`, or nothing. */\ntype Paint = { readonly raw: string; readonly dialect: StyleDialect } | typeof NULL | null;\n\n/** A `{y:GraphMLReference key}` markup extension, whatever the prefix. */\nconst REFERENCE = /^\\{\\s*[\\w.-]*:?GraphMLReference\\s+([^\\s}]+)\\s*\\}$/;\n\n/** A `{x:Null}` markup extension. */\nconst NULL_MARKUP = /^\\{\\s*[\\w.-]*:?Null\\s*\\}$/;\n\n/** The yFiles key types the reader reads, by the last segment of their `attr.uri`. */\ntype KeyKind = \"NodeStyle\" | \"EdgeStyle\" | \"NodeLabels\" | \"EdgeLabels\" | \"NodeGeometry\" | \"EdgeGeometry\" | \"SharedData\";\nconst KINDS: ReadonlySet<string> = new Set([\n \"NodeStyle\",\n \"EdgeStyle\",\n \"NodeLabels\",\n \"EdgeLabels\",\n \"NodeGeometry\",\n \"EdgeGeometry\",\n]);\n\n/**\n * The kind of a yFiles 3 column, from the `attr.uri` the importer keeps as its origin type.\n * @param type - the origin type\n * @returns the kind, or null\n */\nfunction keyKind(type: string | null | undefined): KeyKind | null {\n if (typeof type !== \"string\" || !type.includes(\"://\")) {\n return null;\n }\n const last = type.slice(type.lastIndexOf(\"/\") + 1);\n return KINDS.has(last) || last === \"SharedData\" ? (last as KeyKind) : null;\n}\n\n/**\n * The columns of a table by kind.\n * @param table - the table\n * @returns kind to column name\n */\nfunction columnsByKind(table: GraphSnapshot[\"nodes\"]): Map<KeyKind, string> {\n const out = new Map<KeyKind, string>();\n for (const col of table) {\n const kind =\n col.dtype === \"json\" && col.meta.origin?.namespace === \"yfiles\" ? keyKind(col.meta.origin.type) : null;\n if (kind !== null && !out.has(kind)) {\n out.set(kind, col.meta.name);\n }\n }\n return out;\n}\n\n/** Resolves references against the graph's shared data, counting the ones it gives up on. */\nclass References {\n private readonly shared = new Map<string, StyleObject>();\n\n /** The references given up on: circular or deeper than the limit. */\n cycles = 0;\n\n /**\n * Collects the shared objects of the graph's `SharedData` value.\n * @param data - the `<data>` content of the SharedData key\n */\n constructor(data: unknown) {\n for (const sd of treeChildren(data, \"SharedData\")) {\n if (isTree(sd)) {\n this.collect(sd);\n }\n }\n }\n\n /**\n * Collects the shared objects of one SharedData element: the first of each key wins.\n * @param sd - the element\n */\n private collect(sd: Record<string, unknown>): void {\n for (const key of Object.keys(sd).filter((k) => !k.startsWith(\"@_\") && k !== \"#text\")) {\n for (const e of treeChildren(sd, localOf(key))) {\n const name = sharedKey(e);\n if (name !== null && !this.shared.has(name)) {\n this.shared.set(name, { tag: localOf(key), e });\n }\n }\n }\n }\n\n /**\n * Whether a walk has gone too deep; counts it once when it has.\n * @param depth - the walk's depth\n * @returns true past the limit\n */\n tooDeep(depth: number): boolean {\n if (depth > MAX_REFERENCE_DEPTH) {\n this.cycles++;\n return true;\n }\n return false;\n }\n\n /**\n * A style object, following a `<y:GraphMLReference ResourceKey>` element to what it names.\n * @param tag - the element's local name\n * @param e - the element\n * @returns the object, or null when the reference names nothing\n */\n object(tag: string, e: unknown): StyleObject | null {\n if (tag === \"GraphMLReference\") {\n return this.shared.get(treeAttr(e, \"ResourceKey\") ?? \"\") ?? null;\n }\n return { tag, e };\n }\n\n /**\n * The first child element of a property element, as a style object.\n * @param d - the property element (or a `<data>` content)\n * @returns the object, or null\n */\n first(d: unknown): StyleObject | null {\n if (!isTree(d)) {\n return null;\n }\n for (const key of Object.keys(d)) {\n if (!key.startsWith(\"@_\") && key !== \"#text\") {\n return this.object(localOf(key), treeChildren(d, localOf(key))[0]);\n }\n }\n return null;\n }\n\n /**\n * A property value resolved through references: a style object, text, `{x:Null}` or nothing.\n * @param v - an attribute's text or a property element\n * @param depth - the walk's depth\n * @returns the resolved value\n */\n deref(v: unknown, depth = 0): Resolved {\n if (v === undefined || v === null || this.tooDeep(depth)) {\n return null;\n }\n if (typeof v === \"object\") {\n return this.first(v);\n }\n if (typeof v !== \"string\") {\n return null;\n }\n const t = v.trim();\n if (t.length > MAX_STYLE_VALUE_LENGTH) {\n return t;\n }\n if (NULL_MARKUP.test(t)) {\n return NULL;\n }\n const m = REFERENCE.exec(t);\n if (m !== null) {\n return this.shared.get(m[1]) ?? null;\n }\n return t;\n }\n}\n\n/**\n * The `x:Key` of a shared object.\n * @param e - the element\n * @returns the key, or null\n */\nfunction sharedKey(e: unknown): string | null {\n if (!isTree(e)) {\n return null;\n }\n for (const key of Object.keys(e)) {\n if (key.startsWith(\"@_\") && localOf(key.slice(2)) === \"Key\") {\n const value = e[key];\n return typeof value === \"string\" ? value : null;\n }\n }\n return null;\n}\n\n/**\n * A property of a style object: its attribute, or its `<Tag.property>` child element.\n * @param st - the style object\n * @param name - the property name\n * @returns the attribute text, the property element, or undefined\n */\nfunction prop(st: StyleObject, name: string): unknown {\n const attr = treeAttr(st.e, name);\n if (attr !== undefined) {\n return attr;\n }\n return treeChild(st.e, `${st.tag}.${name}`);\n}\n\n/**\n * A paint: a color constant or `#AARRGGBB` in the yFiles 3 dialect, a CSS color, the first stop of a gradient\n * (with a note), or `{x:Null}`.\n * @param refs - the references\n * @param v - the property value\n * @param gradient - called when the paint is a gradient\n * @param depth - the walk's depth\n * @returns the paint\n */\nfunction paintOf(refs: References, v: unknown, gradient: (() => void) | null, depth = 0): Paint {\n if (refs.tooDeep(depth)) {\n return null;\n }\n const x = refs.deref(v, depth);\n if (x === null || x === NULL) {\n return x;\n }\n if (typeof x === \"string\") {\n return { raw: x, dialect: \"yfiles3\" };\n }\n const { tag } = x;\n if (tag === \"SolidColorFill\") {\n return paintOf(refs, prop(x, \"color\"), gradient, depth + 1);\n }\n if (tag === \"Color\") {\n return paintOf(refs, treeAttr(x.e, \"value\"), gradient, depth + 1);\n }\n if (tag === \"CssFill\") {\n const css = treeAttr(x.e, \"cssString\");\n return css === undefined ? null : { raw: css, dialect: \"css\" };\n }\n if (tag.endsWith(\"Gradient\")) {\n gradient?.();\n const stop =\n treeChildren(x.e, \"GradientStop\")[0] ??\n treeChildren(treeChild(x.e, `${tag}.GradientStops`), \"GradientStop\")[0];\n return stop === undefined ? null : paintOf(refs, treeAttr(stop, \"color\"), null, depth + 1);\n }\n if (tag === \"Stroke\") {\n return paintOf(refs, prop(x, \"fill\"), gradient, depth + 1);\n }\n return null;\n}\n\n/** A stroke's color, width and line style. */\ninterface Stroke {\n readonly color: Paint;\n readonly width: unknown;\n readonly line: string;\n}\n\n/** yFiles 3's dash style names. */\nconst DASHES: ReadonlyMap<string, string> = new Map([\n [\"solid\", \"solid\"],\n [\"dash\", \"dashed\"],\n [\"dot\", \"dotted\"],\n [\"dashdot\", \"dash-dot\"],\n [\"dashdotdot\", \"dash-dot\"],\n]);\n\n/**\n * A stroke: a `Stroke` object, a color written as a stroke, or `{x:Null}`.\n * @param refs - the references\n * @param v - the property value\n * @returns the stroke, `{x:Null}`, or null\n */\nfunction strokeOf(refs: References, v: unknown): Stroke | typeof NULL | null {\n const x = refs.deref(v);\n if (x === null || x === NULL) {\n return x;\n }\n if (typeof x === \"string\" || x.tag !== \"Stroke\") {\n return { color: paintOf(refs, v, null), width: 1, line: \"solid\" };\n }\n let line = \"solid\";\n const d = refs.deref(prop(x, \"dashStyle\"), 1);\n if (typeof d === \"string\") {\n const lower = d.slice(0, MAX_STYLE_VALUE_LENGTH).toLowerCase().replaceAll(\"_\", \"\");\n line = DASHES.get(lower) ?? `other:${lower}`;\n } else if (d !== null && d !== NULL) {\n // a DashStyle object: two numbers dash or dot, four dash-dot\n const dashes = (treeAttr(d.e, \"dashes\") ?? \"\")\n .slice(0, MAX_STYLE_VALUE_LENGTH)\n .trim()\n .split(/[\\s,]+/)\n .map(Number)\n .filter(Number.isFinite);\n if (dashes.length === 2) {\n line = dashes[0] <= 1 ? \"dotted\" : \"dashed\";\n } else if (dashes.length === 4) {\n line = \"dash-dot\";\n } else if (dashes.length > 0) {\n line = `other:dashes ${dashes.slice(0, 8).join(\" \")}`;\n }\n }\n const w = prop(x, \"thickness\");\n return { color: paintOf(refs, prop(x, \"fill\"), null), width: typeof w === \"string\" ? w : 1, line };\n}\n\n/**\n * Writes a paint into a color property, its alpha into the property's opacity where it has one.\n * @param pt - the paint\n * @param property - the color property\n * @param opacity - its opacity property, or null\n * @param put - receives the values\n * @param at - the sites\n */\nfunction putPaint(pt: Paint, property: string, opacity: string | null, put: PutValue, at: SiteOf): void {\n if (pt === null || pt === NULL) {\n return;\n }\n const c = canonColor(pt.raw, pt.dialect, 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/** yFiles' black, the documented default color of the 2.6 Bevel, ShinyPlate and Panel styles. */\nconst BLACK = \"#FF000000\";\n\n/** The demos' FlowchartNodeStyle defaults (yfiles-for-html-demos v2.6, FlowchartStyle.ts): fill rgb(183, 201, 227). */\nconst FLOWCHART_FILL = \"#FFB7C9E3\";\n\n/**\n * yFiles for HTML 2.6 ShapeNodeShape names the neutral shapes do not spell, as the shape yFiles documents them as:\n * SHEARED_RECTANGLE sheared to the right and SHEARED_RECTANGLE2 to the left, TRAPEZ smaller at the bottom and TRAPEZ2\n * at the top, TRIANGLE2 pointing to the bottom, FAT_ARROW an arrow pointing to the right and FAT_ARROW2 to the left\n * (ShapeNodeShape API docs). A mirrored or turned shape is the polygon of its corners (`x,y` fractions of the half\n * sizes, y up). STAR5_UP is a star; PILL, a stadium, is a rectangle with half-circle ends.\n */\nconst SHAPES_26: ReadonlyMap<string, YedOutline> = new Map<string, YedOutline>([\n [\"sheared-rectangle\", { shape: \"parallelogram\" }],\n [\"sheared-rectangle2\", { shape: \"polygon\", points: \"-0.5,-1 1,-1 0.5,1 -1,1\" }],\n [\"trapez\", { shape: \"polygon\", points: \"-0.5,-1 0.5,-1 1,1 -1,1\" }],\n [\"trapez2\", { shape: \"trapezoid\" }],\n [\"star5-up\", { shape: \"star\" }],\n [\"triangle2\", { shape: \"polygon\", points: \"-1,1 0,-1 1,1\" }],\n [\"fat-arrow\", { shape: \"polygon\", points: \"-1,-1 0.6,-1 1,0 0.6,1 -1,1 -0.6,0\" }],\n [\"fat-arrow2\", { shape: \"polygon\", points: \"-0.6,-1 1,-1 0.6,0 1,1 -0.6,1 -1,0\" }],\n [\"pill\", { shape: \"round-rectangle\" }],\n]);\n\n/** ShapeNodeStyle's ROUND_RECTANGLE corner size (ShapeNodeShape API docs: \"The corner size is 10\"). */\nconst ROUND_RECTANGLE_CORNER = 10;\n\n/** A node's size from its NodeGeometry, where it has one. */\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * A rounded box's corner: a radius of 0 is a plain box.\n * @param radius - the style's `radius` attribute\n * @param fallback - the style's documented default radius\n * @param put - receives the values\n * @param at - the sites\n */\nfunction putRounded(radius: string | undefined, fallback: number, put: PutValue, at: SiteOf): void {\n const r = radius === undefined ? fallback : canonNumber(radius, at(\"cornerRadius\"));\n if (r === 0) {\n put(\"shape\", \"rectangle\");\n return;\n }\n put(\"shape\", \"round-rectangle\");\n put(\"cornerRadius\", r);\n}\n\n/**\n * Reads the yFiles for HTML 2.6 node styles yEd Live wrote before yFiles 3, and the demos' FlowchartNodeStyle:\n * BevelNodeStyle and PanelNodeStyle (a `color` fill, no outline), ShinyPlateNodeStyle (an outline only where `stroke`\n * is set) and FlowchartNodeStyle (its `type`'s outline, drawn as yEd's flowchart palette draws the same type).\n * @param refs - the references\n * @param style - the style\n * @param put - receives the values\n * @param at - the sites\n * @returns true when the style is one of these\n */\nfunction readStyle26(refs: References, style: StyleObject, put: PutValue, at: SiteOf): boolean {\n const fill = (v: unknown): void => {\n const gradient = (): void => {\n noteAt(at(\"fill\"), STYLE_ISSUE.GRADIENT, style.tag);\n };\n putPaint(paintOf(refs, v, gradient), \"fill\", \"fillOpacity\", put, at);\n };\n switch (style.tag) {\n case \"BevelNodeStyle\":\n fill(prop(style, \"color\") ?? BLACK);\n put(\"borderWidth\", 0);\n putRounded(treeAttr(style.e, \"radius\"), 10, put, at);\n return true;\n case \"PanelNodeStyle\":\n fill(prop(style, \"color\") ?? BLACK);\n put(\"borderWidth\", 0);\n put(\"shape\", \"rectangle\");\n return true;\n case \"ShinyPlateNodeStyle\": {\n fill(prop(style, \"fill\") ?? BLACK);\n const stroke = prop(style, \"stroke\");\n if (stroke === undefined) {\n put(\"borderWidth\", 0);\n } else {\n putStroke(strokeOf(refs, stroke), put, at);\n }\n putRounded(treeAttr(style.e, \"radius\"), 5, put, at);\n return true;\n }\n case \"FlowchartNodeStyle\": {\n fill(prop(style, \"fill\") ?? FLOWCHART_FILL);\n const type = treeAttr(style.e, \"type\") ?? \"\";\n // an annotation's box has no outline (its bracket is not drawn); a style without a type draws the same\n // box, outlined\n if (type === \"annotation\") {\n put(\"borderWidth\", 0);\n } else {\n putStroke(strokeOf(refs, prop(style, \"stroke\") ?? BLACK), put, at);\n }\n const outline = type === \"\" || type === \"annotation\" ? null : configurationOutline(`flowchart.${type}`);\n if (outline === null && type !== \"\" && type !== \"annotation\") {\n noteAt(at(\"shape\"), STYLE_ISSUE.UNKNOWN_VALUE, type.slice(0, MAX_STYLE_VALUE_LENGTH));\n }\n put(\"shape\", outline?.shape ?? \"rectangle\");\n if (outline?.points !== undefined) {\n put(\"shapePoints\", outline.points);\n }\n return true;\n }\n default:\n return false;\n }\n}\n\n/**\n * Writes a stroke's color, width and line style, or no outline for `{x:Null}`.\n * @param stroke - the stroke\n * @param put - receives the values\n * @param at - the sites\n */\nfunction putStroke(stroke: Stroke | typeof NULL | null, put: PutValue, at: SiteOf): void {\n if (stroke === NULL) {\n put(\"borderWidth\", 0);\n } else if (stroke !== null) {\n putPaint(stroke.color, \"borderColor\", \"borderOpacity\", put, at);\n put(\"borderWidth\", canonNumber(stroke.width, at(\"borderWidth\")));\n put(\"borderStyle\", canonEnum(\"borderStyle\", stroke.line, \"yfiles3\", at(\"borderStyle\")));\n }\n}\n\n/**\n * Reads a node style.\n * @param refs - the references\n * @param data - the `<data>` content of the NodeStyle key\n * @param put - receives the values\n * @param at - the sites\n * @param size - the node's size, for a PILL's half-circle ends\n */\nfunction readNodeStyle(refs: References, data: unknown, put: PutValue, at: SiteOf, size: Size | null): void {\n const st = unwrapped(refs, refs.first(data));\n if (st === null || typeof st !== \"object\") {\n if (data !== null && data !== undefined && data !== \"\") {\n noteAt(at(\"fill\"), STYLE_ISSUE.UNRESOLVED, \"NodeStyle\");\n }\n return;\n }\n const style = st;\n if (readStyle26(refs, style, put, at)) {\n return;\n }\n putPaint(\n paintOf(refs, prop(style, \"fill\"), () => {\n noteAt(at(\"fill\"), STYLE_ISSUE.GRADIENT, style.tag);\n }),\n \"fill\",\n \"fillOpacity\",\n put,\n at,\n );\n putStroke(strokeOf(refs, prop(style, \"stroke\")), put, at);\n put(\"shape\", nodeShapeOf(style, at));\n const points = SHAPES_26.get(shapeKey(treeAttr(style.e, \"shape\")) ?? \"\")?.points;\n if (points !== undefined) {\n put(\"shapePoints\", points);\n }\n const cornerSize = style.tag === \"RectangleNodeStyle\" ? treeAttr(style.e, \"cornerSize\") : undefined;\n if (cornerSize !== undefined) {\n put(\"cornerRadius\", canonNumber(cornerSize, at(\"cornerRadius\")));\n }\n const shape = style.tag === \"ShapeNodeStyle\" ? shapeKey(treeAttr(style.e, \"shape\")) : null;\n if (shape === \"round-rectangle\") {\n put(\"cornerRadius\", ROUND_RECTANGLE_CORNER);\n } else if (shape === \"pill\" && size !== null) {\n put(\"cornerRadius\", Math.min(size.width, size.height) / 2);\n }\n}\n\n/**\n * A ShapeNodeStyle `shape` as a lookup key: lowercase, underscores as hyphens.\n * @param shape - the attribute\n * @returns the key, or null\n */\nfunction shapeKey(shape: string | undefined): string | null {\n return shape === undefined\n ? null\n : shape.slice(0, MAX_STYLE_VALUE_LENGTH).trim().toLowerCase().replaceAll(\"_\", \"-\");\n}\n\n/**\n * The style a collapsible group's decorators wrap; a decorator that wraps itself is a cycle.\n * @param refs - the references\n * @param first - the node's style\n * @returns the style that draws the node, or null for a cycle\n */\nfunction unwrapped(refs: References, first: Resolved): Resolved {\n let st = first;\n const seen = new Set<unknown>();\n while (st !== null && typeof st === \"object\" && st.tag === \"CollapsibleNodeStyleDecorator\") {\n if (seen.has(st.e) || refs.tooDeep(seen.size)) {\n refs.cycles++;\n return null;\n }\n seen.add(st.e);\n st = refs.deref(prop(st, \"wrappedStyle\"));\n }\n return st;\n}\n\n/**\n * A node style's shape: its `shape`, else what its kind draws.\n * @param style - the style\n * @param at - the sites\n * @returns the shape, or null when it does not parse\n */\nfunction nodeShapeOf(style: StyleObject, at: SiteOf): string | null {\n const shape = treeAttr(style.e, \"shape\");\n if (shape !== undefined) {\n return SHAPES_26.get(shapeKey(shape) ?? \"\")?.shape ?? canonEnum(\"shape\", shape, \"yfiles3\", at(\"shape\"));\n }\n if (style.tag === \"RectangleNodeStyle\") {\n return treeAttr(style.e, \"cornerSize\") === undefined ? \"rectangle\" : \"round-rectangle\";\n }\n if (style.tag === \"ShapeNodeStyle\") {\n return \"rectangle\";\n }\n noteAt(at(\"shape\"), STYLE_ISSUE.UNKNOWN_VALUE, style.tag);\n return `other:${style.tag}`;\n}\n\n/**\n * Reads an edge style.\n * @param refs - the references\n * @param data - the `<data>` content of the EdgeStyle key\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readEdgeStyle(refs: References, data: unknown, put: PutValue, at: SiteOf): void {\n const st = refs.first(data);\n if (st === null) {\n return;\n }\n const stroke = strokeOf(refs, prop(st, \"stroke\"));\n if (stroke === NULL) {\n noteAt(at(\"color\"), STYLE_ISSUE.NO_STROKE, \"{x:Null}\");\n } else if (stroke !== null) {\n putPaint(stroke.color, \"color\", \"opacity\", put, at);\n put(\"width\", canonNumber(stroke.width, at(\"width\")));\n put(\"lineStyle\", canonEnum(\"lineStyle\", stroke.line, \"yfiles3\", at(\"lineStyle\")));\n }\n for (const end of [\"source\", \"target\"] as const) {\n readEdgeArrow(refs, refs.deref(prop(st, `${end}Arrow`)), end, put, at);\n }\n}\n\n/**\n * Reads one end's arrow of an edge style: its type, and for an arrow element its color, drawn hollow in its\n * stroke's color when its fill is `{x:Null}`.\n * @param refs - the references\n * @param a - the dereferenced `sourceArrow` or `targetArrow` value\n * @param end - which end\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readEdgeArrow(\n refs: References,\n a: ReturnType<References[\"deref\"]>,\n end: \"source\" | \"target\",\n put: PutValue,\n at: SiteOf,\n): void {\n const property = `${end}Arrow`;\n let type: string | null = null;\n let hollow = false;\n if (a !== null && a !== NULL && typeof a === \"object\") {\n type = treeAttr(a.e, \"type\") ?? \"DEFAULT\";\n const fill = paintOf(refs, prop(a, \"fill\"), null);\n // a `{x:Null}` fill draws the arrow's outline alone, in its stroke's color\n const open = fill === NULL ? strokeOf(refs, prop(a, \"stroke\")) : null;\n hollow = open !== null && open !== NULL;\n putPaint(open !== null && open !== NULL ? open.color : fill, `${end}ArrowColor`, null, put, at);\n } else if (typeof a === \"string\") {\n type = a;\n }\n if (type !== null) {\n const arrow = canonEnum(\"arrow\", RENAMED_ARROWS.get(type.toUpperCase()) ?? type, \"yfiles3\", at(property));\n put(property, hollow ? (HOLLOW_ARROWS.get(arrow ?? \"\") ?? arrow) : arrow);\n }\n}\n\n/**\n * yFiles 3.0 renamed 2.6's DEFAULT arrow to STEALTH and CIRCLE to ELLIPSE\n * (https://docs.yfiles.com/yfiles-html/api/ArrowType/); each is read as its 2.6 name is. STEALTH is \"an arrow that is\n * notched on the side opposite its tip\": a vee.\n */\nconst RENAMED_ARROWS: ReadonlyMap<string, string> = new Map([\n [\"DEFAULT\", \"vee\"],\n [\"STEALTH\", \"vee\"],\n [\"ELLIPSE\", \"circle\"],\n]);\n\n/** The filled arrows whose `{x:Null}` fill draws them as their open outline (a stealth's as the open triangle's). */\nconst HOLLOW_ARROWS: ReadonlyMap<string, string> = new Map([\n [\"triangle\", \"triangle-open\"],\n [\"vee\", \"triangle-open\"],\n [\"diamond\", \"diamond-open\"],\n [\"circle\", \"circle-open\"],\n]);\n\n/**\n * Reads an edge's route from its EdgeGeometry: the `y:Bend` locations, relative to its two nodes' centers (a\n * self-loop's to its node's size), and, for a PolylineEdgeStyle with a `smoothingLength` above 0, its rounded bends.\n * @param refs - the references\n * @param geometry - the `<data>` content of the EdgeGeometry key\n * @param style - the `<data>` content of the EdgeStyle key\n * @param ends - the source and target nodes' boxes (center x, y, width, height)\n * @param put - receives the values\n */\nfunction readEdgeGeometry(\n refs: References,\n geometry: unknown,\n style: unknown,\n ends: readonly [Float64Array, Float64Array, boolean],\n put: PutValue,\n): void {\n const points = treeChildren(treeChild(geometry, \"List\"), \"Bend\").map((b): BendPoint => {\n const [x, y] = (treeAttr(b, \"Location\") ?? \"\").split(\",\").map(Number);\n return [x, y];\n });\n const [s, t, loop] = ends;\n const bends = loop\n ? canonNodeOffsets([s[0], s[1]], [s[2], s[3]], points, true)\n : canonBends([s[0], s[1]], [t[0], t[1]], points, true);\n put(\"bends\", bends);\n const st = refs.first(style);\n const smoothing = st === null ? undefined : treeAttr(st.e, \"smoothingLength\");\n if (bends !== null && st?.tag === \"PolylineEdgeStyle\" && Number(smoothing) > 0) {\n put(\"curved\", true);\n }\n}\n\n/** yFiles' label positions (2.6 compass names and yFiles 3 side names, lowercase without `_`) as neutral sides. */\nconst SIDES: ReadonlyMap<string, string> = new Map([\n [\"north\", \"top\"],\n [\"south\", \"bottom\"],\n [\"east\", \"right\"],\n [\"west\", \"left\"],\n [\"northeast\", \"top-right\"],\n [\"northwest\", \"top-left\"],\n [\"southeast\", \"bottom-right\"],\n [\"southwest\", \"bottom-left\"],\n [\"top\", \"top\"],\n [\"bottom\", \"bottom\"],\n [\"right\", \"right\"],\n [\"left\", \"left\"],\n [\"topright\", \"top-right\"],\n [\"topleft\", \"top-left\"],\n [\"bottomright\", \"bottom-right\"],\n [\"bottomleft\", \"bottom-left\"],\n]);\n\n/**\n * The node label models by their parameter's local name: whether the label lies outside the node (exterior,\n * sandwich) or inside it (interior, stretch).\n */\nconst NODE_LABEL_MODELS: ReadonlyMap<string, \"outside\" | \"inside\"> = new Map([\n [\"ExteriorLabelModelParameter\", \"outside\"],\n [\"ExteriorNodeLabelModelParameter\", \"outside\"],\n [\"SandwichParameter\", \"outside\"],\n [\"SandwichLabelModelParameter\", \"outside\"],\n [\"InteriorLabelModelParameter\", \"inside\"],\n [\"InteriorNodeLabelModelParameter\", \"inside\"],\n [\"InteriorStretchLabelModelParameter\", \"inside\"],\n [\"StretchNodeLabelModelParameter\", \"inside\"],\n]);\n\n/** A `{x:Static y:SomeLabelModel.Position}` markup extension: the model's local name and the member. */\nconst STATIC_PARAMETER = /^\\{\\s*[\\w.-]*:?Static\\s+(?:[\\w.-]+:)?(\\w+)\\.(\\w+)\\s*\\}$/;\n\n/**\n * A label's layout parameter, as a parameter element's local name and the element: the `Label.LayoutParameter`\n * child, a `LayoutParameter` attribute naming a shared one, or a model's constant (`{x:Static\n * y:InteriorStretchLabelModel.North}`), read as that model's parameter with that `Position`.\n * @param refs - the references\n * @param label - the `y:Label` element\n * @returns the parameter, or null\n */\nfunction layoutParameter(refs: References, label: unknown): StyleObject | null {\n const attr = treeAttr(label, \"LayoutParameter\");\n if (attr !== undefined) {\n const m = STATIC_PARAMETER.exec(attr.slice(0, MAX_STYLE_VALUE_LENGTH).trim());\n if (m !== null) {\n return { tag: `${m[1]}Parameter`, e: { \"@_Position\": m[2] } };\n }\n }\n const p = refs.deref(attr ?? treeChild(label, \"Label.LayoutParameter\"));\n return p === null || p === NULL || typeof p !== \"object\" ? null : p;\n}\n\n/**\n * Where yFiles draws a node label, from its layout parameter's model and `Position`: outside the node for the\n * exterior and sandwich models, inside it (`inside-*`) for the interior and stretch models, and the center for a\n * centered position or any other model (the free and ratio-anchored models' offsets have no neutral property).\n * @param refs - the references\n * @param label - the `y:Label` element\n * @returns the position\n */\nfunction labelPositionOf(refs: References, label: unknown): string {\n const parameter = layoutParameter(refs, label);\n const model = parameter === null ? undefined : NODE_LABEL_MODELS.get(parameter.tag);\n if (parameter === null || model === undefined) {\n return \"center\";\n }\n const raw = treeAttr(parameter.e, \"Position\") ?? \"\";\n const side = SIDES.get(raw.slice(0, MAX_STYLE_VALUE_LENGTH).toLowerCase().replaceAll(\"_\", \"\"));\n if (side === undefined) {\n return \"center\";\n }\n return model === \"inside\" ? `inside-${side}` : side;\n}\n\n/** yFiles' edge label sides (`SideOfEdge`, and the nine-position model's middle row), as neutral positions. */\nconst EDGE_SIDES: ReadonlyMap<string, string> = new Map([\n [\"aboveedge\", \"top\"],\n [\"belowedge\", \"bottom\"],\n [\"onedge\", \"center\"],\n [\"centerabove\", \"top\"],\n [\"centerbelow\", \"bottom\"],\n [\"centercentered\", \"center\"],\n]);\n\n/** The edge label models that place a label above, on or below the line, and the attribute that says which. */\nconst EDGE_SIDE_ATTRIBUTES: ReadonlyMap<string, string> = new Map([\n [\"NinePositionsEdgeLabelModelParameter\", \"Position\"],\n [\"EdgePathLabelModelParameter\", \"SideOfEdge\"],\n]);\n\n/**\n * Where yFiles draws an edge label at the middle of its edge, above, on or below the line: the path model's\n * `SideOfEdge` at a ratio of 0.5, and the nine-position model's center row. Other places (the ends, a\n * segment's middle, left or right of the edge's direction, a free offset) give none.\n * @param refs - the references\n * @param label - the `y:Label` element\n * @returns the position, or null\n */\nfunction edgeLabelPositionOf(refs: References, label: unknown): string | null {\n const parameter = layoutParameter(refs, label);\n if (parameter === null) {\n return null;\n }\n const ratio = treeAttr(parameter.e, \"Ratio\");\n if (ratio !== undefined && Number(ratio) !== 0.5) {\n return null;\n }\n const attribute = EDGE_SIDE_ATTRIBUTES.get(parameter.tag);\n const raw = attribute === undefined ? undefined : treeAttr(parameter.e, attribute);\n return raw === undefined ? null : (EDGE_SIDES.get(raw.slice(0, MAX_STYLE_VALUE_LENGTH).toLowerCase()) ?? null);\n}\n\n/**\n * Reads an element's labels: the first one with text; further ones are noted for the element.\n * @param refs - the references\n * @param data - the `<data>` content of the NodeLabels or EdgeLabels key\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readLabels(refs: References, data: unknown, put: PutValue, at: SiteOf): void {\n let label: unknown = undefined;\n let text = \"\";\n let extra = 0;\n for (const l of treeChildren(treeChild(data, \"List\"), \"Label\")) {\n const raw = treeAttr(l, \"Text\") ?? treeText(treeChild(l, \"Label.Text\")) ?? \"\";\n if (raw.trim().length === 0) {\n continue;\n }\n if (label === undefined) {\n label = l;\n text = raw;\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 put(\n \"labelPosition\",\n at(\"label\").target === \"node\" ? labelPositionOf(refs, label) : edgeLabelPositionOf(refs, label),\n );\n const ls = refs.deref(treeAttr(label, \"Style\") ?? treeChild(label, \"Label.Style\"));\n if (ls === null || ls === NULL || typeof ls !== \"object\" || !ls.tag.endsWith(\"LabelStyle\")) {\n return;\n }\n putPaint(paintOf(refs, prop(ls, \"textFill\"), null), \"labelColor\", null, put, at);\n readLabelFont(refs.deref(prop(ls, \"font\")), put, at);\n}\n\n/**\n * Reads a label style's `Font`: its size, family and weight.\n * @param f - the dereferenced `font` property\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readLabelFont(f: ReturnType<References[\"deref\"]>, put: PutValue, at: SiteOf): void {\n if (f === null || f === NULL || typeof f !== \"object\" || f.tag !== \"Font\") {\n return;\n }\n put(\"labelSize\", canonNumber(treeAttr(f.e, \"fontSize\"), at(\"labelSize\")));\n const family = treeAttr(f.e, \"fontFamily\");\n if (family !== undefined) {\n put(\"labelFont\", canonText(family.replaceAll(/(^['\"])|(['\"]$)/g, \"\"), at(\"labelFont\")));\n }\n const weight = treeAttr(f.e, \"fontWeight\");\n if (weight !== undefined) {\n put(\"labelWeight\", canonEnum(\"weight\", weight, \"yfiles3\", at(\"labelWeight\")));\n }\n}\n\n/** The style, labels and geometry key kinds of nodes and of edges. */\nconst YFILES3_KINDS: Readonly<Record<StyleTarget, readonly KeyKind[]>> = {\n node: [\"NodeStyle\", \"NodeLabels\", \"NodeGeometry\"],\n edge: [\"EdgeStyle\", \"EdgeLabels\", \"EdgeGeometry\"],\n};\n\n/** What reading one table's yFiles 3 styles shares. */\ninterface Yfiles3Context {\n readonly snapshot: GraphSnapshot;\n readonly notes: StyleNotes;\n readonly budget: StyleWorkBudget;\n readonly refs: References;\n /** each node's center x and y, width and height from its NodeGeometry, for its edges' bends; NaN without one */\n readonly boxes: Float64Array;\n}\n\n/**\n * Reads the yFiles 3 styles of every node or every edge.\n * @param ctx - the shared state\n * @param target - nodes or edges\n * @param kinds - the table's columns by key kind\n * @returns the values\n */\nfunction readYfiles3Target(\n ctx: Yfiles3Context,\n target: StyleTarget,\n kinds: Map<KeyKind, string>,\n): ReturnType<typeof valueColumns>[\"values\"] {\n const { snapshot, notes, budget, refs, boxes } = ctx;\n const isNode = target === \"node\";\n const table = isNode ? snapshot.nodes : snapshot.edges;\n const n = isNode ? snapshot.nodeCount : snapshot.edgeCount;\n const out = valueColumns(n);\n const [style, labels, geometry] = YFILES3_KINDS[target].map((kind) => kinds.get(kind));\n const cell = (name: string | undefined, i: number): unknown =>\n name === undefined ? undefined : plainCell(table.value(name, i));\n for (let i = 0; i < n; i++) {\n budget.spend(target, 1);\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 let size: Size | null = null;\n if (geometry !== undefined && !isNode) {\n const box = (k: number): Float64Array => boxes.subarray(4 * k, 4 * k + 4);\n const [s, t] = [snapshot.edgeSource(i), snapshot.edgeTarget(i)];\n readEdgeGeometry(refs, cell(geometry, i), cell(style, i), [box(s), box(t), s === t], put);\n } else if (geometry !== undefined) {\n size = readNodeGeometry(cell(geometry, i), i, boxes, put, at);\n }\n if (style !== undefined && isNode) {\n readNodeStyle(refs, cell(style, i), put, at, size);\n } else if (style !== undefined) {\n readEdgeStyle(refs, cell(style, i), put, at);\n }\n if (labels !== undefined) {\n readLabels(refs, cell(labels, i), put, at);\n }\n }\n return out.values;\n}\n\n/**\n * Reads a node's NodeGeometry: its width and height, and its box for its edges' bends.\n * @param geometry - the `<data>` content of the NodeGeometry key\n * @param i - the node's index\n * @param boxes - receives the node's center x and y, width and height\n * @param put - receives the values\n * @param at - the sites\n * @returns the node's size, or null when its width or height is not a number\n */\nfunction readNodeGeometry(geometry: unknown, i: number, boxes: Float64Array, put: PutValue, at: SiteOf): Size | null {\n const rect = treeChild(geometry, \"RectD\");\n const width = canonNumber(treeAttr(rect, \"Width\"), at(\"width\"));\n const height = canonNumber(treeAttr(rect, \"Height\"), at(\"height\"));\n put(\"width\", width);\n put(\"height\", height);\n if (width === null || height === null) {\n return null;\n }\n const [x, y] = [Number(treeAttr(rect, \"X\")), Number(treeAttr(rect, \"Y\"))];\n boxes.set([x + width / 2, y + height / 2, width, height], 4 * i);\n return { width, height };\n}\n\n/**\n * The yFiles 3 styles of a graph.\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 the graph has none of yFiles 3's style keys\n */\nexport function readYfiles3Styles(snapshot: GraphSnapshot, notes: StyleNotes, budget: StyleWorkBudget): YedRead | null {\n const nodeKinds = columnsByKind(snapshot.nodes);\n const edgeKinds = columnsByKind(snapshot.edges);\n const styled = [...nodeKinds.keys(), ...edgeKinds.keys()].some((k) => k !== \"SharedData\");\n if (!styled) {\n return null;\n }\n const graphKinds = columnsByKind(snapshot.graph);\n const sharedName = graphKinds.get(\"SharedData\");\n const refs = new References(sharedName === undefined ? null : plainCell(snapshot.graph.value(sharedName, 0)));\n const boxes = new Float64Array(4 * snapshot.nodeCount).fill(Number.NaN);\n const read = (target: StyleTarget, kinds: Map<KeyKind, string>): ReturnType<typeof valueColumns>[\"values\"] =>\n readYfiles3Target({ snapshot, notes, budget, refs, boxes }, target, kinds);\n const node = read(\"node\", nodeKinds);\n const edge = read(\"edge\", edgeKinds);\n if (refs.cycles > 0) {\n notes.add(STYLE_ISSUE.REFERENCE_CYCLE, null, null, {\n sample: `references deeper than ${String(MAX_REFERENCE_DEPTH)} or circular (${String(refs.cycles)})`,\n });\n }\n return { node, edge };\n}\n","/**\n * GraphML styles: which program wrote the file, and its styles read the way that program draws them. yEd and\n * yFiles 3 keep their graphics in nested XML (styles-yed.ts, styles-yfiles3.ts); Gephi writes plain `r`, `g`, `b`\n * and `size` keys; Cytoscape's GraphML export writes no visual properties at all and is recognized by its `SUID`\n * and `shared name` keys. A GraphML file from any other writer has no styles: a key named like a style (`color`)\n * stays data, and no program's defaults are added.\n */\n\nimport type { GraphSnapshot } from \"@graphty/graph-format\";\n\nimport { canonColor } from \"../../styles/canon/color.js\";\nimport { canonNumber } from \"../../styles/canon/number.js\";\nimport { canonText } from \"../../styles/canon/text.js\";\nimport { STYLE_BLOCK_NAME } from \"../../styles/io/block.js\";\nimport { StyleNotes } from \"../../styles/notes.js\";\nimport { plainCell } from \"../../styles/plan/resolve.js\";\nimport type { ImporterStyles, StyleReadContext, StyleTarget, StyleValue } from \"../../styles/types.js\";\nimport { gephiRules } from \"../gexf/styles.js\";\nimport {\n exactFromBlock,\n readYedStyles,\n type ValueColumns,\n valueColumns,\n type YedRead,\n yfilesColumns,\n} from \"./styles-yed.js\";\nimport { readYfiles3Styles } from \"./styles-yfiles3.js\";\n\n/** Gephi's color and size keys. */\nconst GEPHI_COLUMNS: readonly string[] = [\"r\", \"g\", \"b\", \"size\"];\n\n/**\n * Whether a table has Gephi's `r`, `g` and `b` columns.\n * @param table - the node or edge table\n * @returns true when all three are there\n */\nfunction hasRgb(table: GraphSnapshot[\"nodes\"]): boolean {\n return table.has(\"r\") && table.has(\"g\") && table.has(\"b\");\n}\n\n/**\n * Gephi's styles: `r`, `g`, `b` as the fill of a node and the color of an edge, `size` as a node's width and\n * height, and `label` as the label.\n * @param snapshot - the graph\n * @param notes - where problems are noted\n * @param context - the work budget\n * @returns the values\n */\nfunction readGephi(\n snapshot: GraphSnapshot,\n notes: StyleNotes,\n context: StyleReadContext,\n): { node: ValueColumns; edge: ValueColumns } {\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 out = valueColumns(n);\n const has = { rgb: hasRgb(table), size: target === \"node\" && table.has(\"size\"), label: table.has(\"label\") };\n for (let i = 0; i < n; i++) {\n context.budget.spend(target, 1);\n const at = (property: string): Parameters<typeof canonNumber>[1] => ({\n notes,\n target,\n property,\n element: i,\n budget: context.budget,\n });\n readGephiRow(\n table,\n target,\n i,\n has,\n (property, value) => {\n out.put(i, property, value);\n },\n at,\n );\n }\n return out.values;\n };\n return { node: read(\"node\"), edge: read(\"edge\") };\n}\n\n/**\n * Reads one Gephi element.\n * @param table - the node or edge table\n * @param target - nodes or edges\n * @param i - the element\n * @param has - which of Gephi's columns the table has\n * @param has.rgb - the `r`, `g` and `b` columns\n * @param has.size - a node `size` column\n * @param has.label - a `label` column\n * @param put - receives the values\n * @param at - the sites\n */\nfunction readGephiRow(\n table: GraphSnapshot[\"nodes\"],\n target: StyleTarget,\n i: number,\n has: { readonly rgb: boolean; readonly size: boolean; readonly label: boolean },\n put: (property: string, value: StyleValue | null) => void,\n at: (property: string) => Parameters<typeof canonNumber>[1],\n): void {\n if (has.rgb) {\n const [r, g, b] = [\"r\", \"g\", \"b\"].map((c) => plainCell(table.value(c, i)));\n if (r !== null && g !== null && b !== null) {\n const property = target === \"node\" ? \"fill\" : \"color\";\n put(property, canonColor({ r, g, b }, \"gephi\", at(property))?.color ?? null);\n }\n }\n if (has.size) {\n const v = canonNumber(plainCell(table.value(\"size\", i)), at(\"width\"));\n put(\"width\", v);\n put(\"height\", v);\n }\n if (has.label) {\n put(\"label\", canonText(plainCell(table.value(\"label\", i)), at(\"label\")));\n }\n}\n\n/**\n * For a file graphty wrote: the yEd values that are only what the writer writes for the `graphty.styles` block's own\n * values read as the block's values (see exactFromBlock()). A block that does not parse or describes another graph\n * changes nothing; graph-io then ignores it with a note.\n * @param snapshot - the graph\n * @param yed - the values read from the yEd graphics, changed in place\n */\nfunction exactFromGraphtyBlock(snapshot: GraphSnapshot, yed: YedRead): void {\n const text = snapshot.graph.has(STYLE_BLOCK_NAME) ? plainCell(snapshot.graph.value(STYLE_BLOCK_NAME, 0)) : null;\n if (typeof text !== \"string\") {\n return;\n }\n exactFromBlock(snapshot, text, yed);\n}\n\n/**\n * The styles of a GraphML file, read the way the program that wrote it draws them, with that program's defaults\n * beneath: yEd's and yFiles 3's nested graphics, Gephi's `r`, `g`, `b` and `size` keys, or, for Cytoscape's export,\n * Cytoscape's default style with each node labeled by its `name`. A file from any other writer has none.\n * @param snapshot - the graph the import built\n * @param context - the work budget\n * @returns the styles, or null when no writer with styles is recognized\n */\nexport function graphmlStyles(snapshot: GraphSnapshot, context: StyleReadContext): ImporterStyles | null {\n const notes = new StyleNotes();\n const readFrom = { node: yfilesColumns(snapshot.nodes), edge: yfilesColumns(snapshot.edges) };\n const yfiles3 = readYfiles3Styles(snapshot, notes, context.budget);\n if (yfiles3 !== null) {\n return {\n canonical: true,\n dialect: \"yfiles3\",\n tool: \"yfiles3\",\n units: \"px\",\n node: { values: yfiles3.node },\n edge: { values: yfiles3.edge },\n notes: notes.list(),\n readFrom,\n };\n }\n const yed = readYedStyles(snapshot, notes, context.budget);\n if (yed !== null) {\n exactFromGraphtyBlock(snapshot, yed);\n return {\n canonical: true,\n dialect: \"yed\",\n tool: \"yed\",\n units: \"px\",\n node: { values: yed.node },\n edge: { values: yed.edge },\n notes: notes.list(),\n opacityInColor: true,\n readFrom,\n };\n }\n if (hasRgb(snapshot.nodes)) {\n const gephi = readGephi(snapshot, notes, context);\n // Gephi draws every edge in its end nodes' mixed color (EdgeColor MIXED), whatever its own\n delete gephi.edge.color;\n const rules = gephiRules(snapshot, { fill: gephi.node.fill, width: gephi.node.width }, {}, context.budget);\n const used = (table: GraphSnapshot[\"nodes\"]): string[] => GEPHI_COLUMNS.filter((c) => table.has(c));\n return {\n canonical: true,\n dialect: \"gephi\",\n tool: \"gephi\",\n units: \"relative\",\n node: { values: gephi.node, ...rules.node },\n edge: { values: gephi.edge, ...rules.edge },\n notes: notes.list(),\n readFrom: { node: used(snapshot.nodes), edge: used(snapshot.edges) },\n };\n }\n if (snapshot.nodes.has(\"SUID\") && snapshot.nodes.has(\"shared name\")) {\n // Cytoscape writes no visual properties into GraphML; its default style labels each node with its name\n const label = valueColumns(snapshot.nodeCount);\n if (snapshot.nodes.has(\"name\")) {\n for (let i = 0; i < snapshot.nodeCount; i++) {\n label.put(\n i,\n \"label\",\n canonText(plainCell(snapshot.nodes.value(\"name\", i)), {\n notes,\n target: \"node\",\n property: \"label\",\n element: i,\n budget: context.budget,\n }),\n );\n }\n }\n return {\n canonical: true,\n dialect: \"cytoscape\",\n tool: \"cytoscape\",\n units: \"px\",\n node: { values: label.values },\n edge: { values: {} },\n notes: notes.list(),\n };\n }\n return null;\n}\n","/**\n * The GraphML importer (design sections 8.4 and 5.1; research note 07 section 2.3): a single-pass\n * SAX-style reader over the streaming XML tokenizer that pushes scalars into the sink as elements\n * close. `<key>` declarations become typed columns up front (boolean / int / long / float / double\n * / string, with `<default>`, for the node, edge and graph domains; `for=\"all\"` declares in all\n * three with the same origin.id); `edgedefault` and per-edge `directed` go through the common\n * DirectionResolver; a nested `<graph>` inside a node becomes the `parent` column (containment,\n * never topology); `<port>` declarations and `<locator>` elements are reported and dropped while\n * `sourceport` / `targetport` edge attributes are kept as role columns; hyperedges follow the\n * `hyperedges` option (refuse, skip with a report entry, star, clique); yFiles `yfiles.type` keys\n * become `json` columns holding the nested XML as a tree (origin.namespace \"yfiles\"), reported as\n * a loss note because the structure, not the bytes, is preserved; a `y:ShapeNode` or\n * `y:PolyLineEdge` in such a tree is also read into typed `yfiles.*` columns (yfiles.ts).\n *\n * Ids are coerced with the common rule (`ids: \"canonical\"` by default, design section 4.1); the\n * edge attribute whose `attr.name` is `weightFrom` (\"weight\" by default) is THE weight and is\n * passed to `addEdge` rather than stored as a column, with its declaration kept in\n * `meta.weightOrigin`; a node key named `graphty:originalId` restores ids the exporter mangled.\n */\n\nimport {\n type ColumnDecl,\n type ColumnHandle,\n GraphFormatError,\n type GraphSink,\n INVALID_INDEX,\n MAX_COUNT,\n type NodeId,\n} from \"@graphty/graph-format\";\n\nimport {\n declareAttribute,\n type DeclaredAttribute,\n declareResolved,\n losesPrecision,\n parseDeclaredValue,\n PRECISION_CODE,\n takenIn,\n uniqueColumnName,\n} from \"../../common/attributes.js\";\nimport { type DeclaredTypeSpec, overflowsToInfinity } from \"../../common/declared-types.js\";\nimport { DirectionResolver, type EdgeKind } from \"../../common/direction.js\";\nimport { IdCoercer } from \"../../common/ids.js\";\nimport { textChunks, throwIfAborted } from \"../../common/input.js\";\nimport { type ListSyntax } from \"../../common/lists.js\";\nimport {\n type ImportFormatDefaults,\n reportSinkOptions,\n reportUnusedOptions,\n type ResolvedImportOptions,\n resolveImportOptions,\n} from \"../../common/options.js\";\nimport { agree, plural } from \"../../common/plural.js\";\nimport { ImportReportBuilder } from \"../../common/report.js\";\nimport { isWeightField, parseWeightText } from \"../../common/weights.js\";\nimport {\n isWhitespace,\n localName,\n sniffXmlText,\n tokenizeXml,\n xmlDeclaredEncoding,\n XmlEmptyInputError,\n type XmlHandler,\n XmlNestingError,\n XmlSyntaxError,\n} from \"../../common/xml.js\";\nimport { type CommonImportOptions, type GraphImporter, type ImportInput, type ImportReport } from \"../../types.js\";\nimport {\n EDGE_ID_COLUMN,\n EXTENSIONS,\n FORMAT,\n GRAPHML_ISSUE,\n GRAPHML_LOSS,\n GRAPHML_NAMESPACE,\n type GraphmlMeta,\n HYPEREDGE_HUB_COLUMN,\n LABEL_COLUMN,\n META_KEY,\n MIME_TYPES,\n ORIGINAL_ID_ATTRIBUTE,\n ORIGINAL_ID_COLUMN,\n PARENT_COLUMN,\n RESERVED_EDGE_NAMES,\n RESERVED_NODE_NAMES,\n SOURCE_PORT_COLUMN,\n TARGET_PORT_COLUMN,\n XSI_NAMESPACE,\n} from \"./constants.js\";\nimport { graphmlStyles } from \"./styles-plain.js\";\nimport { writeXmlTree, XmlTreeBuilder } from \"./tree.js\";\nimport { graphicsDecl, graphicsValues, yfilesPositions } from \"./yfiles.js\";\n\n/**\n * Whether an XML attribute is not data and passes silently: a namespace declaration, an `xml:` or\n * `xsi:` attribute, or a namespace URI where one is allowed.\n * @param kind - the element name\n * @param name - the attribute's name\n * @returns true when it is never reported\n */\nfunction isPassedAttribute(kind: string, name: string): boolean {\n return name === \"xmlns\" || /^(xmlns|xml|xsi):/.test(name) || isAttributeUri(kind, name);\n}\n\n/**\n * The warning for an attribute the importer does not read.\n * @param kind - the element name\n * @param name - the attribute's name\n * @param hint - whether it is a `parse.*` hint\n * @returns the message\n */\nfunction unreadAttributeMessage(kind: string, name: string, hint: boolean): string {\n if (hint) {\n return `the <${kind}> parse hint ${name} is ignored`;\n }\n if (SCHEMA_ATTRIBUTES.has(name)) {\n return `the <${kind}> attribute ${name} is not kept`;\n }\n return `the <${kind}> attribute ${name} is not a GraphML attribute; it is not kept`;\n}\n\n/** The XML attributes the importer reads on each element; any other is reported (once per element and name). */\nconst GRAPH_ATTRIBUTES: ReadonlySet<string> = new Set([\"id\", \"edgedefault\", \"parse.nodes\", \"parse.edges\"]);\nconst NODE_ATTRIBUTES: ReadonlySet<string> = new Set([\"id\"]);\nconst KEY_ATTRIBUTES: ReadonlySet<string> = new Set([\n \"id\",\n \"for\",\n \"attr.name\",\n \"attr.type\",\n \"name\",\n \"type\",\n \"yfiles.type\",\n]);\nconst DATA_ATTRIBUTES: ReadonlySet<string> = new Set([\"key\"]);\nconst HYPEREDGE_ATTRIBUTES: ReadonlySet<string> = new Set([\"id\"]);\nconst ENDPOINT_ATTRIBUTES: ReadonlySet<string> = new Set([\"node\", \"type\"]);\nconst PORT_ATTRIBUTES: ReadonlySet<string> = new Set([\"name\"]);\nconst NO_ATTRIBUTES: ReadonlySet<string> = new Set();\n\n/**\n * Whether a `<key>` attribute is yFiles 3's `attr.uri` (in whatever prefix the file binds to yWorks' namespace).\n * @param kind - the element name\n * @param name - the attribute name as written\n * @returns true for `<prefix>:attr.uri` on a key\n */\nfunction isAttributeUri(kind: string, name: string): boolean {\n return kind === \"key\" && name.endsWith(\":attr.uri\");\n}\n\n/**\n * The `<prefix>:attr.uri` of a key, or null.\n * @param attrs - the key's attributes\n * @returns the URI\n */\nfunction attributeUri(attrs: ReadonlyMap<string, string>): string | null {\n for (const [name, value] of attrs) {\n if (isAttributeUri(\"key\", name) && value.length > 0) {\n return value;\n }\n }\n return null;\n}\n\n/** Attributes the GraphML schema defines that the importer does not keep: reported as not kept, not as foreign. */\nconst SCHEMA_ATTRIBUTES: ReadonlySet<string> = new Set([\"id\", \"port\", \"parse.order\", \"parse.nodeids\", \"parse.edgeids\"]);\n\n/** Distinct unknown attribute names reported one by one per element kind; the rest are counted in one issue. */\nconst MAX_UNKNOWN_ATTRIBUTE_NAMES = 16;\nconst EDGE_ATTRIBUTES: ReadonlySet<string> = new Set([\n \"id\",\n \"source\",\n \"target\",\n \"directed\",\n \"sourceport\",\n \"targetport\",\n]);\n\n/**\n * The format-specific options of the GraphML importer.\n * @category Built-in formats\n */\nexport interface GraphmlImportOptions extends CommonImportOptions {\n /**\n * How yEd graphics (keys with a `yfiles.type`) are read. \"json\" keeps each one as a JSON\n * attribute named after the key (for example, `d0`) that holds its XML as a tree, which the GraphML\n * exporter writes back, and also reads the shapes it knows into plain columns beside it:\n * `yfiles.position`, `yfiles.width`, `yfiles.height`, `yfiles.color`, `yfiles.borderColor`,\n * `yfiles.borderWidth`, `yfiles.label` and `yfiles.shape` for nodes, and the line color, width\n * and arrows for edges. The report's `lossy` list then holds W_GRAPHML_YFILES_JSON, because the\n * XML comes back with the same structure but not byte for byte. \"skip\" leaves the graphics out,\n * with a W_GRAPHML_YFILES_SKIPPED warning per key. The `yfiles.*` columns are deprecated and\n * kept as they are, not fixed: read a file's styles with `styles: true` instead. In the next\n * major version they leave the import result, together with the rule that a target arrow makes\n * an edge directed and the label role of `yfiles.label`.\n * @defaultValue \"json\"\n */\n yfiles?: \"json\" | \"skip\" | undefined;\n}\n\n/** The per-format defaults of design section 8.4: text-cell ids, undirected when edgedefault is missing, weight key. */\nconst FORMAT_DEFAULTS: ImportFormatDefaults = { ids: \"canonical\", defaultDirected: false, weightFrom: \"weight\" };\n\n/** Bytes inspected by sniff(). */\nconst SNIFF_BYTES = 4096;\n\nconst YFILES_MODES: ReadonlySet<string> = new Set([\"json\", \"skip\"]);\n\n/** Elements between two checks of the cancellation signal. */\nconst ABORT_CHECK_INTERVAL = 64;\n\n/** The common options the GraphML importer reads (the rest is reported by reportUnusedOptions). */\nconst USED_OPTIONS: ReadonlySet<keyof CommonImportOptions> = new Set<keyof CommonImportOptions>([\n \"ids\",\n \"addMissingNodes\",\n \"duplicateEdges\",\n \"selfLoops\",\n \"onMixedDirection\",\n \"defaultDirected\",\n \"weightFrom\",\n \"weightDtype\",\n \"long\",\n \"restoreMangledIds\",\n \"hyperedges\",\n \"errorLimit\",\n \"signal\",\n \"onProgress\",\n]);\n\n/** Where the reader is, by the innermost open element. */\nconst enum Ctx {\n Graphml,\n Desc,\n Key,\n Default,\n Graph,\n Node,\n Edge,\n Hyperedge,\n Data,\n Capture,\n Skip,\n /** A `<port>` (ports nest; their names are collected for the edge port check). */\n Port,\n /** Inside a `<graph>` held by an `<edge>`: dropped, its nodes and edges counted as skipped. */\n Dropped,\n}\n\n/** The element domains a key can be declared for. */\ntype Domain = \"graph\" | \"node\" | \"edge\";\n\n/** A declared column of one domain. */\ninterface ColumnTarget {\n /** The column name in its table. */\n readonly name: string;\n /** The handle (node / edge domains); INVALID_INDEX for the graph domain. */\n readonly handle: ColumnHandle;\n /** The declaration (graph domain, re-sent with every setGraphValue). */\n readonly decl: ColumnDecl;\n /** How text values are parsed; null for a json (yfiles) column. */\n readonly spec: DeclaredTypeSpec | null;\n /** The list syntax (unused by GraphML, which has no list type). */\n readonly listSyntax: ListSyntax;\n}\n\n/** One `<key>` after `</key>`. */\ninterface KeyEntry {\n readonly id: string;\n readonly name: string;\n readonly node: ColumnTarget | null;\n readonly edge: ColumnTarget | null;\n readonly graph: ColumnTarget | null;\n /** The edge domain of this key is THE weight. */\n readonly weight: boolean;\n /** The node domain of this key restores mangled ids. */\n readonly originalId: boolean;\n /** Whether the key holds yFiles nested XML. */\n readonly yfiles: boolean;\n /** Whether data of this key is silently ignored (yfiles: \"skip\"; already reported). */\n readonly skipped: boolean;\n /** The domains the key was declared for, for the mismatch warning. */\n readonly domains: readonly Domain[];\n}\n\n/** A `<key>` while its `<default>` and `<desc>` are being read. */\ninterface PendingKey {\n readonly id: string | null;\n readonly attrName: string | null;\n readonly attrType: string | null;\n readonly yfilesType: string | null;\n readonly domains: readonly Domain[];\n readonly line: number;\n desc: string;\n defaultText: string | null;\n defaultTree: unknown;\n}\n\n/** A `<node>` while open (nodes nest through nested graphs, so these stack). */\ninterface NodeState {\n /** The coerced id, or null when the element is unusable. */\n id: NodeId | null;\n /** The id attribute as written, for the mangled -> original map. */\n idText: string | null;\n /** The node index once added; INVALID_INDEX before. */\n index: number;\n /** The index of the containing node, or INVALID_INDEX at the top level. */\n readonly parent: number;\n /** Data values waiting for the node to be added: handle, value, handle, value... */\n readonly pending: unknown[];\n /** A `graphty:originalId` value, restored as the id. */\n restoredId: string | null;\n failed: boolean;\n readonly line: number;\n /** The keys of the `<data>` read so far, for the duplicate check; null before the first. */\n keys: Set<string> | null;\n}\n\n/** The `<edge>` being read. */\ninterface EdgeState {\n source: NodeId | null;\n target: NodeId | null;\n id: string | null;\n kind: EdgeKind;\n sourcePort: string | null;\n targetPort: string | null;\n weight: number | undefined;\n readonly pending: unknown[];\n failed: boolean;\n line: number;\n /** The keys of the `<data>` read so far, for the duplicate check; null before the first. */\n keys: Set<string> | null;\n /** The weight key whose value was read, or null. */\n weightKey: string | null;\n /** The endpoint ids as written, for the nested-graph-id check. */\n readonly sourceText: string | null;\n readonly targetText: string | null;\n}\n\n/** One `<endpoint>` of a hyperedge. */\ninterface Endpoint {\n readonly node: NodeId;\n readonly type: \"in\" | \"out\" | \"undir\";\n}\n\n/** The `<hyperedge>` being read. */\ninterface HyperedgeState {\n id: string | null;\n readonly endpoints: Endpoint[];\n failed: boolean;\n line: number;\n}\n\n/** The `<data>` or `<default>` being read. */\ninterface ContentState {\n key: KeyEntry | null;\n pendingKey: PendingKey | null;\n domain: Domain;\n text: string;\n tree: XmlTreeBuilder | null;\n line: number;\n}\n\n/** Where an issue was found. */\ninterface Where {\n /** The line. */\n readonly line: number;\n /** The element, or null. */\n readonly element: string | null;\n}\n\n/** One open `<graph>`. */\ninterface GraphState {\n readonly directed: boolean;\n readonly parent: number;\n /** The `parse.nodes` / `parse.edges` hints of a top-level graph, checked at its end; null when absent. */\n readonly hints: { readonly nodes: number | null; readonly edges: number | null } | null;\n /** The `<node>` / `<edge>` elements read directly in this graph. */\n nodes: number;\n edges: number;\n readonly line: number;\n}\n\n/**\n * A growable bit set over node indices, marking the indices declared by a `<node>` element so a\n * second declaration is reported and a node created by an edge reference is not.\n */\nclass IndexFlags {\n private words = new Uint32Array(64);\n\n /**\n * Whether an index is marked.\n * @param index - the node index\n * @returns true when set\n */\n has(index: number): boolean {\n const w = index >>> 5;\n return w < this.words.length && ((this.words[w] >>> (index & 31)) & 1) === 1;\n }\n\n /**\n * Mark an index.\n * @param index - the node index\n */\n add(index: number): void {\n const w = index >>> 5;\n if (w >= this.words.length) {\n let size = this.words.length * 2;\n while (size <= w) {\n size *= 2;\n }\n const grown = new Uint32Array(size);\n grown.set(this.words);\n this.words = grown;\n }\n this.words[w] |= 1 << (index & 31);\n }\n}\n\n/**\n * The event handler that turns the tokenizer's events into sink calls.\n */\nclass GraphmlReader implements XmlHandler {\n private readonly sink: GraphSink;\n\n private readonly report: ImportReportBuilder;\n\n private readonly options: ResolvedImportOptions;\n\n private readonly yfilesMode: \"json\" | \"skip\";\n\n private readonly coercer: IdCoercer;\n\n private readonly direction: DirectionResolver;\n\n private readonly ctx: Ctx[] = [];\n\n /** Keys by id; one id may be declared once per domain (igraph writes `name` for graph and node). */\n private readonly keys = new Map<string, KeyEntry[]>();\n\n private readonly graphs: GraphState[] = [];\n\n private readonly nodes: NodeState[] = [];\n\n private readonly declared = new IndexFlags();\n\n private readonly edgeIds = new Set<string>();\n /** The keys `<data>` referenced before any `<key>` declared them (E_GRAPHML_UNKNOWN_KEY). */\n private readonly unknownKeyIds = new Set<string>();\n /** The ids of the edges waiting in {@link deferred}. */\n private readonly deferredEdgeIds = new Set<string>();\n\n private elementsSinceCheck = 0;\n\n /** Mangled id text -> the original id restored from `graphty:originalId`, for edge endpoints. */\n private readonly restored = new Map<string, NodeId>();\n\n private readonly graphColumnNames = new Set<string>();\n\n private pendingKey: PendingKey | null = null;\n\n private edge: EdgeState | null = null;\n\n private hyperedge: HyperedgeState | null = null;\n\n private readonly content: ContentState = {\n key: null,\n pendingKey: null,\n domain: \"node\",\n text: \"\",\n tree: null,\n line: 0,\n };\n\n private descTarget: \"graph\" | \"key\" | null = null;\n\n private descText = \"\";\n\n private descLine = 0;\n\n /** The keys of the graph-level `<data>` read so far, for the duplicate check. */\n private readonly graphKeys: { keys: Set<string> | null } = { keys: null };\n\n private description: string | null = null;\n\n private graphSeen = false;\n\n private graphId: string | null = null;\n\n private edgedefault: \"directed\" | \"undirected\" | null = null;\n\n private namespaces: Record<string, string> = {};\n\n private weightOrigin: { id: string; title: string | null; type: string | null } | null = null;\n\n private yfilesLossNoted = false;\n\n /** The mapped yFiles graphics columns declared so far, by domain and field. */\n private readonly graphicsColumns = new Map<string, ColumnHandle>();\n\n private hyperedgeCount = 0;\n\n private edgeIdHandle: ColumnHandle = INVALID_INDEX as ColumnHandle;\n\n private sourcePortHandle: ColumnHandle = INVALID_INDEX as ColumnHandle;\n\n private targetPortHandle: ColumnHandle = INVALID_INDEX as ColumnHandle;\n\n private parentHandle: ColumnHandle = INVALID_INDEX as ColumnHandle;\n\n private hubHandle: ColumnHandle = INVALID_INDEX as ColumnHandle;\n\n /** The hub nodes of star-expanded hyperedges, so a later `<node>` of the same id is reported as a clash. */\n private readonly hubs = new IndexFlags();\n\n /** Edges and hyperedges whose endpoints were not declared yet under addMissingNodes: false, added at the end. */\n private readonly deferred: (EdgeState | HyperedgeState)[] = [];\n\n /** The ids of the `<graph>` elements read so far, for the endpoint-names-a-graph check. */\n private readonly graphIds = new Set<string>();\n\n /** How many top-level `<graph>` elements were opened. */\n private topGraphs = 0;\n\n /** The namespace of the `<graphml>` root (children in it are GraphML even when it is not GraphML's). */\n private rootNs: string | null = GRAPHML_NAMESPACE;\n\n /** Whether a graph-level `<desc>` was kept, so a second one is reported. */\n private graphDescSeen = false;\n\n /** Unknown attribute names reported per element kind, and how many more were not listed. */\n private readonly unknownNames = new Map<string, Set<string>>();\n\n private readonly unknownOverflow = new Map<string, number>();\n\n /** The port names each node declares, and the ports edges reference, checked at the end. */\n private readonly ports = new Map<NodeId, Set<string>>();\n\n private readonly portRefs: [NodeId, string][] = [];\n\n /**\n * Create a reader for one import call.\n * @param sink - the sink\n * @param report - the report\n * @param options - the resolved common options\n * @param yfilesMode - the resolved yfiles option\n */\n constructor(\n sink: GraphSink,\n report: ImportReportBuilder,\n options: ResolvedImportOptions,\n yfilesMode: \"json\" | \"skip\",\n ) {\n this.sink = sink;\n this.report = report;\n this.options = options;\n this.yfilesMode = yfilesMode;\n this.coercer = new IdCoercer(options.ids);\n this.direction = new DirectionResolver(sink, report, options.onMixedDirection);\n }\n\n // ------------------------------------------------------------------ tokenizer events\n\n /**\n * An element starts.\n * @param name - the element name\n * @param attrs - its attributes\n * @param line - the line\n * @param ns - the element's namespace (null: an undeclared prefix)\n */\n start(name: string, attrs: ReadonlyMap<string, string>, line: number, ns: string | null = \"\"): void {\n const parent = this.ctx.at(-1) ?? null;\n switch (parent) {\n case Ctx.Capture:\n case Ctx.Data:\n case Ctx.Default:\n this.captureStart(name, attrs);\n return;\n case Ctx.Skip:\n case Ctx.Desc:\n this.ctx.push(Ctx.Skip);\n return;\n case Ctx.Dropped:\n this.dropStart(localName(name));\n return;\n default:\n break;\n }\n const local = localName(name);\n if (parent !== null && ns !== GRAPHML_NAMESPACE && ns !== \"\" && ns !== this.rootNs) {\n // a vendor element whose local name happens to be node, edge or data is not GraphML\n this.unknownElement(name, line);\n return;\n }\n switch (parent) {\n case null:\n if (local !== \"graphml\") {\n this.report.fail(GRAPHML_ISSUE.NOT_GRAPHML, `the root element is <${name}>, not <graphml>`, {\n line,\n });\n }\n if (ns !== GRAPHML_NAMESPACE && ns !== \"\") {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.NAMESPACE,\n ns === null\n ? `the root <${name}> uses an undeclared prefix; read as GraphML`\n : `the root <${name}> is in the namespace ${JSON.stringify(ns)}, not ${GRAPHML_NAMESPACE}; read as GraphML`,\n { line, element: ns },\n );\n }\n this.rootNs = ns;\n this.reportUnreadAttributes(\"graphml\", attrs, NO_ATTRIBUTES, line);\n this.readRoot(attrs);\n this.ctx.push(Ctx.Graphml);\n return;\n case Ctx.Graphml:\n this.startInGraphml(name, local, attrs, line);\n return;\n case Ctx.Key:\n this.startInKey(name, local, attrs, line);\n return;\n case Ctx.Graph:\n this.startInGraph(name, local, attrs, line);\n return;\n case Ctx.Node:\n this.startInNode(name, local, attrs, line);\n return;\n case Ctx.Edge:\n this.startInEdge(name, local, attrs, line);\n return;\n case Ctx.Hyperedge:\n this.startInHyperedge(name, local, attrs, line);\n return;\n case Ctx.Port:\n this.startInPort(name, local, attrs, line);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * An element ends.\n * @param name - the element name\n * @param _line - the line (unused: issues of an element cite its start line)\n */\n end(name: string, _line: number): void {\n const ctx = this.ctx.pop();\n switch (ctx) {\n case Ctx.Capture:\n this.captureEnd();\n return;\n case Ctx.Skip:\n case Ctx.Graphml:\n case Ctx.Port:\n case Ctx.Dropped:\n case undefined:\n return;\n case Ctx.Desc:\n this.finishDesc();\n return;\n case Ctx.Key:\n this.finishKey();\n return;\n case Ctx.Default:\n this.finishDefault();\n return;\n case Ctx.Data:\n this.finishData();\n return;\n case Ctx.Node:\n this.finishNode();\n return;\n case Ctx.Edge:\n this.finishEdge();\n return;\n case Ctx.Hyperedge:\n this.finishHyperedge();\n return;\n case Ctx.Graph:\n this.finishGraph();\n return;\n default: {\n const value: never = ctx;\n throw new GraphFormatError(\"E_UNSUPPORTED\", `unknown reader state ${String(value)}`, { name });\n }\n }\n }\n\n /**\n * Character data.\n * @param text - the text\n * @param line - the line\n */\n text(text: string, line: number): void {\n const ctx = this.ctx.at(-1) ?? null;\n switch (ctx) {\n case Ctx.Capture:\n this.content.tree?.text(text);\n return;\n case Ctx.Data:\n case Ctx.Default:\n if (this.content.tree === null) {\n this.content.text += text;\n } else {\n this.content.tree.text(text);\n }\n return;\n case Ctx.Desc:\n this.descText += text;\n return;\n case Ctx.Skip:\n case Ctx.Dropped:\n return;\n default:\n if (!isWhitespace(text)) {\n this.report.warnOnce(\n \"validation-error\",\n GRAPHML_ISSUE.STRAY_TEXT,\n \"text where GraphML allows only elements was ignored\",\n { line },\n );\n }\n }\n }\n\n /**\n * After the last event: the document must have held a graph; the metadata is written.\n */\n finish(): void {\n if (!this.graphSeen) {\n this.report.fail(GRAPHML_ISSUE.NO_GRAPH, \"the document has no <graph> element\");\n }\n // GraphML allows an edge before the nodes it joins: what waited for them is added now\n for (const edge of this.deferred) {\n if (\"endpoints\" in edge) {\n this.expandHyperedge(edge);\n } else {\n this.addEdge(edge);\n }\n }\n this.deferred.length = 0;\n this.checkPorts();\n for (const [kind, more] of this.unknownOverflow) {\n this.report.warning(\n \"unsupported\",\n GRAPHML_ISSUE.UNKNOWN_XML_ATTRIBUTE,\n `${more} more distinct attribute names on <${kind}> are not GraphML attributes and are not kept (not listed one by one)`,\n { element: kind },\n );\n }\n const meta: GraphmlMeta = { graphId: this.graphId, edgedefault: this.edgedefault, namespaces: this.namespaces };\n this.sink.setMeta({\n sourceFormat: FORMAT,\n description: this.description ?? undefined,\n weightOrigin:\n this.weightOrigin === null\n ? undefined\n : {\n format: FORMAT,\n id: this.weightOrigin.id,\n title: this.weightOrigin.title,\n type: this.weightOrigin.type,\n namespace: null,\n },\n extra: { [META_KEY]: meta },\n });\n }\n\n // ------------------------------------------------------------------ structure\n\n /**\n * Record the root element's namespace declarations.\n * @param attrs - the root attributes\n */\n private readRoot(attrs: ReadonlyMap<string, string>): void {\n for (const [key, value] of attrs) {\n if (key.startsWith(\"xmlns:\") && value !== GRAPHML_NAMESPACE && value !== XSI_NAMESPACE) {\n this.namespaces[key.slice(6)] = value;\n }\n }\n }\n\n /**\n * A child of `<graphml>`.\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInGraphml(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n switch (local) {\n case \"desc\":\n this.beginDesc(\"graph\", line);\n return;\n case \"key\":\n this.beginKey(attrs, line);\n return;\n case \"graph\":\n this.beginGraph(attrs, line, INVALID_INDEX);\n return;\n case \"data\":\n this.beginData(attrs, line, \"graph\");\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * A child of `<key>`.\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInKey(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n switch (local) {\n case \"desc\":\n this.beginDesc(\"key\", line);\n return;\n case \"default\":\n this.reportUnreadAttributes(\"default\", attrs, NO_ATTRIBUTES, line);\n if (\n this.pendingKey !== null &&\n (this.pendingKey.defaultText !== null || this.pendingKey.defaultTree !== undefined)\n ) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.DUPLICATE_ATTRIBUTE,\n `key \"${this.pendingKey.id ?? \"\"}\" has a second <default>; the later one is kept`,\n { line, element: this.pendingKey.id },\n );\n }\n this.content.key = null;\n this.content.pendingKey = this.pendingKey;\n this.content.text = \"\";\n this.content.tree = null;\n this.content.line = line;\n this.ctx.push(Ctx.Default);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * A child of `<graph>`.\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInGraph(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n const first = this.graphs.length === 1 && this.topGraphs === 1;\n switch (local) {\n case \"desc\":\n if (first) {\n this.beginDesc(\"graph\", line);\n } else {\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.DESC_DROPPED,\n `the <desc> of a ${this.graphs.length === 1 ? \"second top-level\" : \"nested\"} <graph> is not kept`,\n { line },\n `${GRAPHML_ISSUE.DESC_DROPPED}:graph`,\n );\n this.ctx.push(Ctx.Skip);\n }\n return;\n case \"data\":\n if (first) {\n this.beginData(attrs, line, \"graph\");\n } else {\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.NESTED_GRAPH_DATA,\n this.graphs.length === 1\n ? \"data of a second top-level <graph> cannot be kept; the graphs are merged and only the first one's attributes are kept\"\n : \"data of a nested <graph> cannot be kept; only the top-level graph has attributes\",\n { line },\n );\n this.ctx.push(Ctx.Skip);\n }\n return;\n case \"node\":\n this.beginNode(attrs, line);\n return;\n case \"edge\":\n this.beginEdge(attrs, line);\n return;\n case \"hyperedge\":\n this.beginHyperedge(attrs, line);\n return;\n case \"locator\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.LOCATOR_DROPPED,\n \"<locator> references are not followed\",\n { line },\n );\n this.ctx.push(Ctx.Skip);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * A child of `<node>`.\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInNode(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n switch (local) {\n case \"desc\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.DESC_DROPPED,\n \"node and edge <desc> texts are not kept\",\n {\n line,\n },\n );\n this.ctx.push(Ctx.Skip);\n return;\n case \"data\":\n this.beginData(attrs, line, \"node\");\n return;\n case \"port\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.PORT_DECLARATION,\n \"<port> declarations are not kept; sourceport / targetport edge attributes are\",\n { line },\n );\n this.beginPort(attrs, line);\n return;\n case \"graph\": {\n const node = this.nodes[this.nodes.length - 1];\n this.materializeNode(node);\n if (node.index === INVALID_INDEX) {\n this.report.error(\n \"missing-value\",\n GRAPHML_ISSUE.UNKNOWN_PARENT,\n \"the nodes of this nested <graph> lose their parent: the node holding it was skipped; they are read as top-level nodes\",\n { line },\n );\n }\n this.beginGraph(attrs, line, node.index);\n return;\n }\n case \"locator\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.LOCATOR_DROPPED,\n \"<locator> references are not followed\",\n { line },\n );\n this.ctx.push(Ctx.Skip);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * A child of `<edge>`.\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInEdge(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n switch (local) {\n case \"desc\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.DESC_DROPPED,\n \"node and edge <desc> texts are not kept\",\n {\n line,\n },\n );\n this.ctx.push(Ctx.Skip);\n return;\n case \"data\":\n this.beginData(attrs, line, \"edge\");\n return;\n case \"graph\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.EDGE_GRAPH_DROPPED,\n \"a <graph> inside an <edge> is not supported; it is dropped with the nodes and edges it holds (counted as skipped)\",\n { line, element: attrs.get(\"id\") ?? null },\n );\n this.ctx.push(Ctx.Dropped);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * An element inside a dropped `<graph>` (one held by an edge): counted as skipped.\n * @param local - its local name\n */\n private dropStart(local: string): void {\n if (local === \"node\") {\n this.report.counts.skippedNodes++;\n } else if (local === \"edge\" || local === \"hyperedge\") {\n this.report.counts.skippedEdges++;\n }\n this.ctx.push(local === \"data\" || local === \"desc\" ? Ctx.Skip : Ctx.Dropped);\n }\n\n /**\n * Open a `<port>`: its name is kept for the edge port check, its content is skipped.\n * @param attrs - its attributes\n * @param line - the line\n */\n private beginPort(attrs: ReadonlyMap<string, string>, line: number): void {\n this.reportUnreadAttributes(\"port\", attrs, PORT_ATTRIBUTES, line);\n const node = this.nodes[this.nodes.length - 1];\n const name = attrs.get(\"name\");\n if (node.id !== null && name !== undefined) {\n const id = node.restoredId ?? node.id;\n let names = this.ports.get(id);\n if (names === undefined) {\n names = new Set();\n this.ports.set(id, names);\n }\n names.add(name);\n }\n this.ctx.push(Ctx.Port);\n }\n\n /**\n * A child of `<port>`: a nested port declares a name too; data and desc are skipped.\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInPort(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n switch (local) {\n case \"port\":\n this.beginPort(attrs, line);\n return;\n case \"data\":\n case \"desc\":\n this.ctx.push(Ctx.Skip);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * Report the `sourceport` / `targetport` values that name a port their node never declares\n * (once, with the count), now that every node has been read.\n */\n private checkPorts(): void {\n let dangling = 0;\n let first: string | null = null;\n for (const [node, port] of this.portRefs) {\n if (this.ports.get(node)?.has(port) !== true) {\n dangling++;\n first ??= `${String(node)}:${port}`;\n }\n }\n if (dangling > 0) {\n this.report.warning(\n \"missing-value\",\n GRAPHML_ISSUE.DANGLING_REFERENCE,\n `${dangling} edge port reference${plural(dangling)} ${agree(dangling, \"names\", \"name\")} a port their node does not declare (first: ${first ?? \"\"}); the values are kept`,\n { element: first },\n );\n }\n }\n\n /**\n * A child of `<hyperedge>` (under the star / clique policies).\n * @param name - the element name\n * @param local - its local name\n * @param attrs - its attributes\n * @param line - the line\n */\n private startInHyperedge(name: string, local: string, attrs: ReadonlyMap<string, string>, line: number): void {\n switch (local) {\n case \"endpoint\":\n this.reportUnreadAttributes(\"endpoint\", attrs, ENDPOINT_ATTRIBUTES, line);\n this.readEndpoint(attrs, line);\n this.ctx.push(Ctx.Skip);\n return;\n case \"data\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.HYPEREDGE_DATA_DROPPED,\n \"hyperedge data are not kept by the star / clique expansions\",\n { line },\n );\n this.ctx.push(Ctx.Skip);\n return;\n case \"desc\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.DESC_DROPPED,\n \"the <desc> of a hyperedge is not kept by the star / clique expansions\",\n { line },\n `${GRAPHML_ISSUE.DESC_DROPPED}:hyperedge`,\n );\n this.ctx.push(Ctx.Skip);\n return;\n default:\n this.unknownElement(name, line);\n }\n }\n\n /**\n * Report an element the schema does not define at this place and skip its subtree.\n * @param name - the element name\n * @param line - the line\n */\n private unknownElement(name: string, line: number): void {\n this.report.warnOnce(\"unsupported\", GRAPHML_ISSUE.UNKNOWN_ELEMENT, unknownElementMessage(name), {\n line,\n element: name,\n });\n this.ctx.push(Ctx.Skip);\n }\n\n /**\n * Open a `<desc>`.\n * @param target - what the text describes\n * @param line - the line\n */\n private beginDesc(target: \"graph\" | \"key\", line: number): void {\n this.descTarget = target;\n this.descText = \"\";\n this.descLine = line;\n this.ctx.push(Ctx.Desc);\n }\n\n /** Close a `<desc>`. */\n private finishDesc(): void {\n const text = this.descText.trim();\n if (this.descTarget === \"key\" && this.pendingKey !== null) {\n this.pendingKey.desc = text;\n } else if (this.descTarget === \"graph\" && text.length > 0) {\n if (this.graphDescSeen) {\n // a <graphml> and a <graph> description: the graph has one description field\n this.report.warning(\n \"unsupported\",\n GRAPHML_ISSUE.DESC_DROPPED,\n \"a second graph-level <desc> replaces the first; the earlier text is not kept\",\n { line: this.descLine },\n );\n }\n this.graphDescSeen = true;\n this.description = text;\n }\n this.descTarget = null;\n this.descText = \"\";\n }\n\n // ------------------------------------------------------------------ graphs\n\n /**\n * Report, once per element kind and attribute name, an XML attribute the importer does not read:\n * a GraphML `parse.*` hint as ignored, anything else as not kept. Namespace declarations and\n * `xml:` / `xsi:` attributes are not data and pass silently. Beyond MAX_UNKNOWN_ATTRIBUTE_NAMES\n * distinct names per element kind the rest are counted and reported once at the end, so a file\n * with thousands of vendor attributes does not grow the report without bound.\n * @param kind - the element name\n * @param attrs - the element's attributes\n * @param known - the attributes the importer reads on that element\n * @param line - the line\n */\n private reportUnreadAttributes(\n kind: string,\n attrs: ReadonlyMap<string, string>,\n known: ReadonlySet<string>,\n line: number,\n ): void {\n for (const name of attrs.keys()) {\n if (!known.has(name) && !isPassedAttribute(kind, name)) {\n this.reportUnreadAttribute(kind, name, line);\n }\n }\n }\n\n /**\n * Report one attribute reportUnreadAttributes() found, unless its name was reported for this\n * element kind already or the kind is past MAX_UNKNOWN_ATTRIBUTE_NAMES names (then it is counted).\n * @param kind - the element name\n * @param name - the attribute's name\n * @param line - the line\n */\n private reportUnreadAttribute(kind: string, name: string, line: number): void {\n const hint = name.startsWith(\"parse.\");\n let names = this.unknownNames.get(kind);\n if (names === undefined) {\n names = new Set();\n this.unknownNames.set(kind, names);\n }\n if (names.has(name)) {\n return;\n }\n if (names.size >= MAX_UNKNOWN_ATTRIBUTE_NAMES && !hint) {\n this.unknownOverflow.set(kind, (this.unknownOverflow.get(kind) ?? 0) + 1);\n }\n names.add(name);\n if (names.size > MAX_UNKNOWN_ATTRIBUTE_NAMES && !hint) {\n return;\n }\n const code = hint ? GRAPHML_ISSUE.PARSE_HINT_IGNORED : GRAPHML_ISSUE.UNKNOWN_XML_ATTRIBUTE;\n this.report.warning(\"unsupported\", code, unreadAttributeMessage(kind, name, hint), { line, element: name });\n }\n\n /**\n * Open a `<graph>`: the top-level one sets the sink's direction (rule 1 of design section\n * 8.4); a nested one records its container as the parent of its nodes.\n * @param attrs - the graph attributes\n * @param line - the line\n * @param parent - the containing node's index, or INVALID_INDEX\n */\n private beginGraph(attrs: ReadonlyMap<string, string>, line: number, parent: number): void {\n this.reportUnreadAttributes(\"graph\", attrs, GRAPH_ATTRIBUTES, line);\n const top = this.graphs.length === 0;\n if (top) {\n this.topGraphs++;\n }\n const graphId = attrs.get(\"id\");\n if (graphId !== undefined && graphId.length > 0) {\n this.graphIds.add(graphId);\n }\n const edgedefault = attrs.get(\"edgedefault\");\n let directed: boolean;\n if (edgedefault === \"directed\" || edgedefault === \"undirected\") {\n directed = edgedefault === \"directed\";\n } else if (edgedefault === undefined) {\n directed = top ? this.options.defaultDirected : this.graphs[this.graphs.length - 1].directed;\n // once per kind: a file of thousands of nested graphs without edgedefault is one finding\n const direction = directed ? \"directed\" : \"undirected\";\n this.report.warnOnce(\n \"validation-error\",\n GRAPHML_ISSUE.EDGEDEFAULT_MISSING,\n top\n ? `<graph> has no edgedefault; read as ${direction}`\n : `a nested <graph> has no edgedefault; it takes its container's (${direction})`,\n { line },\n `${GRAPHML_ISSUE.EDGEDEFAULT_MISSING}:${top ? \"top\" : \"nested\"}`,\n );\n } else {\n directed = top ? this.options.defaultDirected : this.graphs[this.graphs.length - 1].directed;\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.INVALID_EDGEDEFAULT,\n `edgedefault \"${edgedefault}\" is neither directed nor undirected; read as ${directed ? \"directed\" : \"undirected\"}`,\n { line },\n );\n }\n let hints: GraphState[\"hints\"] = null;\n if (top && this.graphSeen) {\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.MULTIPLE_GRAPHS,\n \"the document holds more than one top-level <graph>; their nodes and edges are merged into one graph\",\n { line, element: attrs.get(\"id\") ?? null },\n );\n for (const name of [\"parse.nodes\", \"parse.edges\"]) {\n if (attrs.has(name)) {\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.PARSE_HINT_IGNORED,\n `the ${name} hint of a second top-level <graph> is ignored`,\n { line, element: name },\n `${GRAPHML_ISSUE.PARSE_HINT_IGNORED}:second:${name}`,\n );\n }\n }\n } else if (top) {\n this.graphSeen = true;\n this.graphId = attrs.get(\"id\") ?? null;\n this.edgedefault = directed ? \"directed\" : \"undirected\";\n this.direction.setHeader(directed, { line });\n const nodes = this.hint(attrs.get(\"parse.nodes\"), \"parse.nodes\", line);\n const edges = this.hint(attrs.get(\"parse.edges\"), \"parse.edges\", line);\n hints = nodes === null && edges === null ? null : { nodes, edges };\n if (nodes !== null || edges !== null) {\n try {\n this.sink.reserve(nodes ?? undefined, edges ?? undefined);\n } catch (err) {\n if (!(err instanceof GraphFormatError)) {\n throw err;\n }\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.COUNT_HINT,\n `count hint refused: ${err.message}`,\n {\n line,\n },\n );\n }\n }\n }\n this.graphs.push({ directed, parent, hints, nodes: 0, edges: 0, line });\n this.ctx.push(Ctx.Graph);\n }\n\n /** Close a `<graph>`: a top-level graph's count hints are checked against what it held. */\n private finishGraph(): void {\n const graph = this.graphs.pop();\n if (graph?.hints === null || graph === undefined) {\n return;\n }\n for (const [name, hint, found] of [\n [\"parse.nodes\", graph.hints.nodes, graph.nodes],\n [\"parse.edges\", graph.hints.edges, graph.edges],\n ] as const) {\n if (hint !== null && hint !== found) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.COUNT_MISMATCH,\n `<graph ${name}=\"${hint}\"> but the graph holds ${found} ${name === \"parse.nodes\" ? \"<node>\" : \"<edge>\"} elements`,\n { line: graph.line, element: name },\n );\n }\n }\n }\n\n /**\n * A `parse.nodes` / `parse.edges` hint the sink can reserve; anything else is reported and ignored.\n * @param text - the attribute text, or undefined\n * @param name - the attribute name\n * @param line - the line\n * @returns the count, or null\n */\n private hint(text: string | undefined, name: string, line: number): number | null {\n if (text === undefined) {\n return null;\n }\n const n = hint(text);\n if (n === null || n > MAX_COUNT) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.COUNT_HINT,\n `<graph ${name}=\"${text}\"> is not a count the sink can reserve; ignored`,\n { line, element: name },\n );\n return null;\n }\n return n;\n }\n\n // ------------------------------------------------------------------ keys\n\n /**\n * Open a `<key>`; the column is declared at `</key>` once its default is known.\n * @param attrs - the key attributes\n * @param line - the line\n */\n private beginKey(attrs: ReadonlyMap<string, string>, line: number): void {\n // attr.list (a list extension of some writers) and yEd's yfiles.foldertype are reported here\n this.reportUnreadAttributes(\"key\", attrs, KEY_ATTRIBUTES, line);\n const id = attrs.get(\"id\") ?? null;\n if (id !== null && this.unknownKeyIds.delete(id)) {\n this.report.warning(\n \"missing-value\",\n GRAPHML_ISSUE.KEY_DECLARED_LATE,\n `key \"${id}\" is declared after data that uses it; those values were dropped (declare <key> before <graph>)`,\n { line, element: id },\n );\n }\n const forText = attrs.get(\"for\") ?? \"all\";\n let domains: readonly Domain[];\n switch (forText) {\n case \"all\":\n domains = [\"graph\", \"node\", \"edge\"];\n break;\n case \"graphml\":\n // data on the <graphml> root (yEd's resources, yFiles 3's shared data) is read as graph data\n domains = [\"graph\"];\n break;\n case \"graph\":\n case \"node\":\n case \"edge\":\n domains = [forText];\n break;\n case \"hyperedge\":\n case \"port\":\n case \"endpoint\":\n this.report.warning(\n \"unsupported\",\n GRAPHML_ISSUE.KEY_DOMAIN_UNSUPPORTED,\n `key \"${id ?? \"\"}\" is declared for ${forText} elements, which are not kept`,\n { line, element: id },\n );\n domains = [];\n break;\n default:\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.KEY_FOR_INVALID,\n `key \"${id ?? \"\"}\" has an unknown for=\"${forText}\"`,\n { line, element: id },\n );\n domains = [];\n }\n // `name` / `type` without the `attr.` prefix are written by some tools; the spec's spelling wins\n const attrType = attrs.get(\"attr.type\") ?? attrs.get(\"type\") ?? null;\n this.pendingKey = {\n id,\n attrName: attrs.get(\"attr.name\") ?? attrs.get(\"name\") ?? null,\n attrType,\n // yFiles 3 declares its untyped keys with `y:attr.uri` instead of `yfiles.type`: their data is nested XML\n yfilesType: attrs.get(\"yfiles.type\") ?? (attrType === null ? attributeUri(attrs) : null),\n domains,\n line,\n desc: \"\",\n defaultText: null,\n defaultTree: undefined,\n };\n this.ctx.push(Ctx.Key);\n }\n\n /** Close a `<key>`: declare its columns. */\n private finishKey(): void {\n const key = this.pendingKey;\n this.pendingKey = null;\n if (key === null) {\n return;\n }\n const where = { line: key.line, element: key.id };\n if (key.id === null || key.id.length === 0) {\n this.report.error(\"validation-error\", GRAPHML_ISSUE.KEY_MISSING_ID, \"<key> without an id\", where);\n return;\n }\n const declared = this.keys.get(key.id) ?? [];\n if (declared.some((entry) => entry.domains.some((domain) => key.domains.includes(domain)))) {\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.DUPLICATE_KEY,\n `key \"${key.id}\" is declared twice for the same kind of element`,\n where,\n );\n return;\n }\n const yfiles = key.yfilesType !== null;\n const name = key.attrName !== null && key.attrName.length > 0 ? key.attrName : key.id;\n const skipped = yfiles && this.yfilesMode === \"skip\";\n if (skipped) {\n this.report.warning(\n \"unsupported\",\n GRAPHML_ISSUE.YFILES_SKIPPED,\n `yFiles key \"${key.id}\" (${key.yfilesType ?? \"\"}) skipped per the yfiles option`,\n where,\n );\n }\n let weight = false;\n let originalId = false;\n let node: ColumnTarget | null = null;\n let edge: ColumnTarget | null = null;\n let graph: ColumnTarget | null = null;\n for (const domain of key.domains) {\n if (skipped) {\n continue;\n }\n if (domain === \"edge\" && !yfiles && isWeightField(name, this.options.weightFrom)) {\n // networkx writes one weight key per value type (long and double): every key of\n // that name is the weight; two of them on one edge are reported in finishData\n weight = true;\n this.weightOrigin ??= { id: key.id, title: key.attrName, type: key.attrType };\n continue;\n }\n if (domain === \"node\" && !yfiles && name === ORIGINAL_ID_ATTRIBUTE) {\n if (this.options.restoreMangledIds) {\n originalId = true;\n continue;\n }\n node = this.declareOriginalIdColumn(key);\n continue;\n }\n try {\n const target = yfiles ? this.declareYfiles(key, name, domain) : this.declareTyped(key, name, domain);\n if (domain === \"node\") {\n node = target;\n } else if (domain === \"edge\") {\n edge = target;\n } else {\n graph = target;\n }\n } catch (err) {\n this.report.recordError(err, where);\n }\n }\n this.keys.set(key.id, [\n ...declared,\n {\n id: key.id,\n name,\n node,\n edge,\n graph,\n weight,\n originalId,\n yfiles,\n skipped,\n domains: key.domains,\n },\n ]);\n }\n\n /**\n * Declare the column of a typed (or untyped, then string) key in one domain.\n * @param key - the key\n * @param name - the resolved attribute name\n * @param domain - the domain\n * @returns the column target\n */\n private declareTyped(key: PendingKey, name: string, domain: Domain): ColumnTarget {\n const id = key.id ?? \"\";\n const declared: DeclaredAttribute = declareAttribute({\n format: FORMAT,\n id,\n title: key.attrName !== null && key.attrName.length > 0 ? key.attrName : null,\n type: key.attrType,\n defaultText: key.defaultTree === undefined ? key.defaultText : null,\n listSyntax: \"comma\",\n role: domain !== \"graph\" && name === LABEL_COLUMN ? \"label\" : null,\n long: this.options.long,\n taken: this.takenIn(domain),\n });\n for (const issue of declared.issues) {\n this.report.warning(issue.category, issue.code, issue.message, { line: key.line, element: id });\n }\n if (key.defaultTree !== undefined) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.DATA_NESTED,\n `the <default> of key \"${id}\" holds elements; a ${key.attrType ?? \"string\"} default must be text`,\n { line: key.line, element: id },\n );\n }\n const { decl } = declared;\n if (key.desc.length > 0) {\n decl.extra = { desc: key.desc };\n }\n return this.declareTarget(domain, decl, declared.spec, declared.listSyntax);\n }\n\n /**\n * Declare the json column of a yFiles key in one domain.\n * @param key - the key\n * @param name - the resolved attribute name\n * @param domain - the domain\n * @returns the column target\n */\n private declareYfiles(key: PendingKey, name: string, domain: Domain): ColumnTarget {\n const id = key.id ?? \"\";\n const columnName = uniqueColumnName(name, id, this.takenIn(domain));\n const decl: ColumnDecl = {\n name: columnName,\n dtype: \"json\",\n nullable: true,\n origin: {\n format: FORMAT,\n id,\n title: key.attrName !== null && key.attrName !== columnName ? key.attrName : null,\n type: key.yfilesType,\n namespace: \"yfiles\",\n },\n };\n if (key.defaultTree !== undefined) {\n decl.default = key.defaultTree;\n } else if (key.defaultText !== null) {\n decl.default = key.defaultText;\n }\n if (key.desc.length > 0) {\n decl.extra = { desc: key.desc };\n }\n return this.declareTarget(domain, decl, null, \"comma\");\n }\n\n /**\n * Declare the `graphty.originalId` column that keeps the exporter's original ids when\n * restoreMangledIds is off.\n * @param key - the key\n * @returns the column target\n */\n private declareOriginalIdColumn(key: PendingKey): ColumnTarget {\n const decl: ColumnDecl = {\n name: uniqueColumnName(ORIGINAL_ID_COLUMN, key.id, this.takenIn(\"node\")),\n dtype: \"string\",\n nullable: true,\n role: \"originalId\",\n origin: { format: FORMAT, id: key.id, title: key.attrName, type: key.attrType, namespace: null },\n };\n return this.declareTarget(\"node\", decl, null, \"comma\");\n }\n\n /**\n * Push a declaration into the sink for one domain through the shared design section 5.6 rule:\n * a role another column already holds is dropped (reported), a name the sink holds with\n * another shape is renamed `<name>#<id>` (reported).\n * @param domain - the domain\n * @param decl - the declaration\n * @param spec - the value spec, or null for json\n * @param listSyntax - the list syntax\n * @returns the target\n */\n private declareTarget(\n domain: Domain,\n decl: ColumnDecl,\n spec: DeclaredTypeSpec | null,\n listSyntax: ListSyntax,\n ): ColumnTarget {\n if (domain === \"graph\") {\n this.sink.setGraphValue(decl.name, undefined, decl);\n this.graphColumnNames.add(decl.name);\n return { name: decl.name, handle: INVALID_INDEX as ColumnHandle, decl, spec, listSyntax };\n }\n const resolved = declareResolved(this.sink, domain, decl, this.report, { element: decl.name });\n return { name: resolved.decl.name, handle: resolved.handle, decl: resolved.decl, spec, listSyntax };\n }\n\n /**\n * The `taken` predicate of a domain: the reserved XML-derived names plus the sink's columns.\n * @param domain - the domain\n * @returns the predicate\n */\n private takenIn(domain: Domain): (name: string) => boolean {\n if (domain === \"graph\") {\n return (name: string): boolean => this.graphColumnNames.has(name);\n }\n const reserved = domain === \"node\" ? RESERVED_NODE_NAMES : RESERVED_EDGE_NAMES;\n const inSink = takenIn(this.sink, domain);\n return (name: string): boolean => reserved.has(name) || inSink(name);\n }\n\n // ------------------------------------------------------------------ data and defaults\n\n /**\n * Open a `<data>`.\n * @param attrs - its attributes\n * @param line - the line\n * @param domain - the domain of the element holding it\n */\n private beginData(attrs: ReadonlyMap<string, string>, line: number, domain: Domain): void {\n this.reportUnreadAttributes(\"data\", attrs, DATA_ATTRIBUTES, line);\n const keyId = attrs.get(\"key\");\n const { content } = this;\n if (keyId !== undefined) {\n this.checkDuplicateData(keyId, domain, line);\n }\n content.key = null;\n content.pendingKey = null;\n content.domain = domain;\n content.text = \"\";\n content.tree = null;\n content.line = line;\n if (keyId === undefined) {\n this.report.error(\"validation-error\", GRAPHML_ISSUE.DATA_MISSING_KEY, \"<data> without a key attribute\", {\n line,\n });\n } else {\n const entries = this.keys.get(keyId);\n const key = entries?.find((entry) => entry.domains.includes(domain)) ?? entries?.[0];\n if (key === undefined) {\n this.unknownKeyIds.add(keyId);\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.UNKNOWN_KEY,\n `<data> references undeclared key \"${keyId}\"`,\n { line, element: keyId },\n );\n } else if (!key.skipped && !key.domains.includes(domain)) {\n this.report.warnOnce(\n \"validation-error\",\n GRAPHML_ISSUE.KEY_DOMAIN,\n `key \"${keyId}\" is declared for ${key.domains.join(\" / \")} elements but used on a ${domain}; ignored`,\n { line, element: keyId },\n );\n } else {\n content.key = key;\n }\n }\n this.ctx.push(Ctx.Data);\n }\n\n /**\n * Report a second `<data>` of one key on one element; the later value is kept (it overwrites).\n * @param keyId - the key\n * @param domain - the domain of the element holding it\n * @param line - the line\n */\n private checkDuplicateData(keyId: string, domain: Domain, line: number): void {\n let holder: { keys: Set<string> | null } | null = null;\n if (domain === \"node\") {\n holder = this.nodes.at(-1) ?? null;\n } else if (domain === \"edge\") {\n holder = this.edge;\n } else {\n holder = this.graphKeys;\n }\n if (holder === null) {\n return;\n }\n holder.keys ??= new Set();\n if (holder.keys.has(keyId)) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.DUPLICATE_ATTRIBUTE,\n `a second <data key=\"${keyId}\"> on one ${domain}; the later value is kept`,\n { line, element: keyId },\n );\n }\n holder.keys.add(keyId);\n }\n\n /**\n * A child element inside `<data>` / `<default>`: the content becomes a tree.\n * @param name - the element name\n * @param attrs - its attributes\n */\n private captureStart(name: string, attrs: ReadonlyMap<string, string>): void {\n const { content } = this;\n if (content.tree === null) {\n content.tree = new XmlTreeBuilder();\n if (content.text.length > 0) {\n content.tree.text(content.text);\n content.text = \"\";\n }\n }\n content.tree.start(name, attrs);\n this.ctx.push(Ctx.Capture);\n }\n\n /** A captured element ends. */\n private captureEnd(): void {\n this.content.tree?.end();\n }\n\n /** Close a `<default>`: keep its text or tree for the key. */\n private finishDefault(): void {\n const { content } = this;\n const key = content.pendingKey;\n if (key === null) {\n return;\n }\n if (content.tree !== null) {\n key.defaultTree = content.tree.finish();\n } else {\n key.defaultText = content.text;\n }\n content.tree = null;\n content.text = \"\";\n content.pendingKey = null;\n }\n\n /** Close a `<data>`: parse the value and route it to its element. */\n private finishData(): void {\n const { content } = this;\n const { key } = content;\n const value: unknown = content.tree === null ? content.text : content.tree.finish();\n content.tree = null;\n content.text = \"\";\n content.key = null;\n if (key === null || key.skipped) {\n return;\n }\n const where = { line: content.line, element: key.id };\n switch (content.domain) {\n case \"node\": {\n const node = this.nodes[this.nodes.length - 1];\n if (key.originalId) {\n if (typeof value !== \"string\" || node.index !== INVALID_INDEX) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.ORIGINAL_ID_IGNORED,\n typeof value === \"string\"\n ? `the ${ORIGINAL_ID_ATTRIBUTE} value comes after the node's nested <graph>, which added the node under its written id; it is not restored`\n : `the ${ORIGINAL_ID_ATTRIBUTE} value holds elements, not text; it is not restored`,\n where,\n );\n return;\n }\n node.restoredId = value;\n return;\n }\n if (key.yfiles) {\n for (const [handle, mapped] of this.graphics(\"node\", key, value, where)) {\n this.setNodeData(node, handle, mapped);\n }\n }\n if (key.node === null) {\n return;\n }\n const parsed = this.parseValue(key.node, value, where);\n if (parsed !== undefined) {\n this.setNodeData(node, key.node.handle, parsed);\n }\n return;\n }\n case \"edge\": {\n const { edge } = this;\n if (edge === null) {\n return;\n }\n if (key.weight) {\n if (typeof value !== \"string\") {\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.DATA_NESTED,\n \"a weight value must be text\",\n where,\n );\n return;\n }\n if (edge.weightKey !== null && edge.weightKey !== key.id) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.DUPLICATE_ATTRIBUTE,\n `the edge has values of two weight keys (\"${edge.weightKey}\" and \"${key.id}\"); the later one is kept`,\n where,\n );\n }\n edge.weightKey = key.id;\n try {\n edge.weight = parseWeightText(value, this.report);\n this.checkOverflow(value, edge.weight, key.name, where);\n } catch (err) {\n this.skipEdge(edge);\n this.report.recordError(err, where);\n }\n return;\n }\n if (key.yfiles) {\n for (const [handle, mapped] of this.graphics(\"edge\", key, value, where)) {\n edge.pending.push(handle, mapped);\n }\n }\n if (key.edge === null) {\n return;\n }\n const parsed = this.parseValue(key.edge, value, where);\n if (parsed !== undefined) {\n edge.pending.push(key.edge.handle, parsed);\n }\n return;\n }\n case \"graph\": {\n if (key.graph === null) {\n return;\n }\n const parsed = this.parseValue(key.graph, value, where);\n if (parsed !== undefined) {\n try {\n this.sink.setGraphValue(key.graph.name, parsed, key.graph.decl);\n } catch (err) {\n this.report.recordError(err, where);\n }\n }\n return;\n }\n default: {\n const { domain } = content;\n throw new GraphFormatError(\"E_UNSUPPORTED\", `unknown data domain ${String(domain)}`, {});\n }\n }\n }\n\n /**\n * Write a node value now, or keep it until the node is added.\n * @param node - the node state\n * @param handle - the column\n * @param value - the value\n */\n private setNodeData(node: NodeState, handle: ColumnHandle, value: unknown): void {\n if (node.index === INVALID_INDEX) {\n node.pending.push(handle, value);\n } else if (!node.failed) {\n this.sink.setNodeValue(handle, node.index, value);\n }\n }\n\n /**\n * The typed values mapped from a yFiles graphics tree (yfiles.ts), each with its column,\n * declared on first use.\n * @param domain - node or edge\n * @param key - the yFiles key\n * @param tree - the `<data>` content\n * @param where - the location for issues\n * @returns column handle and value pairs\n */\n private graphics(domain: \"node\" | \"edge\", key: KeyEntry, tree: unknown, where: Where): [ColumnHandle, unknown][] {\n const out: [ColumnHandle, unknown][] = [];\n const unmapped: string[] = [];\n const values = graphicsValues(domain, tree, unmapped);\n for (const field of unmapped) {\n this.report.warnOnce(\n \"validation-error\",\n GRAPHML_ISSUE.YFILES_VALUE,\n `a yFiles ${domain} ${field} that is not a number is not mapped to its yfiles column (the graphics tree is kept)`,\n where,\n `${GRAPHML_ISSUE.YFILES_VALUE}:${domain}:${field}`,\n );\n }\n for (const [field, value] of values) {\n const id = `${domain}:${field}`;\n let handle = this.graphicsColumns.get(id);\n if (handle === undefined) {\n try {\n ({ handle } = declareResolved(\n this.sink,\n domain,\n graphicsDecl(domain, field, key.id),\n this.report,\n where,\n ));\n } catch (err) {\n this.report.recordError(err, where);\n continue;\n }\n this.graphicsColumns.set(id, handle);\n }\n out.push([handle, value]);\n }\n return out;\n }\n\n /**\n * Parse the content of a `<data>` by its column's declaration.\n * @param target - the column\n * @param value - the text, or the tree of a nested subtree\n * @param where - the location for issues\n * @returns the value to write, or undefined when there is none (blank, or an error was recorded)\n */\n private parseValue(target: ColumnTarget, value: unknown, where: Where): unknown {\n if (target.spec === null) {\n if (!this.yfilesLossNoted) {\n this.yfilesLossNoted = true;\n this.report.loss(\n GRAPHML_LOSS.YFILES_JSON,\n \"yFiles nested XML is kept as a JSON tree: structure preserved, not byte-exact\",\n target.name,\n );\n }\n return value;\n }\n if (typeof value !== \"string\" && target.spec.declared === \"\") {\n // an untyped key states no type the elements contradict: keep them as their XML text\n this.report.warnOnce(\n \"validation-error\",\n GRAPHML_ISSUE.DATA_STRUCTURED,\n `<data> of the untyped attribute \"${target.name}\" holds elements; they are kept as XML text`,\n { line: where.line, element: target.name },\n `${GRAPHML_ISSUE.DATA_STRUCTURED}:${target.name}`,\n );\n const parts: string[] = [];\n writeXmlTree(value, \"\", parts);\n return parts.join(\"\").trim();\n }\n if (typeof value !== \"string\") {\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.DATA_NESTED,\n `<data> of the ${target.spec.declared} attribute \"${target.name}\" holds elements, not text`,\n where,\n );\n return undefined;\n }\n const { spec } = target;\n if (spec.kind !== \"string\" && isWhitespace(value)) {\n return undefined;\n }\n try {\n const parsed = parseDeclaredValue(value, spec, target.listSyntax);\n if (spec.precision && losesPrecision(spec, value)) {\n this.report.warnOnce(\n \"precision\",\n PRECISION_CODE,\n `long values of \"${target.name}\" beyond 2^53 are stored as the nearest double`,\n { line: where.line, element: target.name },\n );\n }\n this.checkOverflow(value, parsed, target.name, where);\n return parsed;\n } catch (err) {\n this.report.recordError(err, where);\n return undefined;\n }\n }\n\n /**\n * Report (once per column) a finite number text too large for a double, stored as Infinity.\n * @param text - the value text\n * @param value - the parsed value\n * @param column - the column name\n * @param where - the location\n */\n private checkOverflow(text: string, value: unknown, column: string, where: Where): void {\n if (typeof value === \"number\" && overflowsToInfinity(text)) {\n this.report.warnOnce(\n \"precision\",\n PRECISION_CODE,\n `values of \"${column}\" beyond the double range (${text.trim()}) are stored as Infinity`,\n { line: where.line, element: column },\n `${PRECISION_CODE}:overflow:${column}`,\n );\n }\n }\n\n // ------------------------------------------------------------------ nodes\n\n /**\n * Open a `<node>`; it is added to the sink when its data is complete (or a nested graph\n * starts), so a `graphty:originalId` value can replace its id.\n * @param attrs - the node attributes\n * @param line - the line\n */\n private beginNode(attrs: ReadonlyMap<string, string>, line: number): void {\n this.reportUnreadAttributes(\"node\", attrs, NODE_ATTRIBUTES, line);\n const graph = this.graphs[this.graphs.length - 1];\n graph.nodes++;\n const state: NodeState = {\n id: null,\n idText: null,\n index: INVALID_INDEX,\n parent: graph.parent,\n pending: [],\n restoredId: null,\n failed: false,\n line,\n keys: null,\n };\n const idText = attrs.get(\"id\");\n if (idText === undefined || idText.length === 0) {\n this.skipNode(state);\n this.report.error(\"missing-value\", GRAPHML_ISSUE.MISSING_ID, \"<node> without an id\", { line });\n } else {\n try {\n state.id = this.coercer.text(idText);\n state.idText = idText;\n this.reportMerge(idText, line);\n } catch (err) {\n this.skipNode(state);\n this.report.recordError(err, { line, element: idText });\n }\n }\n this.nodes.push(state);\n this.ctx.push(Ctx.Node);\n }\n\n /**\n * Add a node to the sink and flush its pending values.\n * @param node - the node state\n */\n private materializeNode(node: NodeState): void {\n if (node.index !== INVALID_INDEX || node.failed) {\n return;\n }\n const id: NodeId | null = node.restoredId ?? node.id;\n if (id === null) {\n node.failed = true;\n return;\n }\n if (node.restoredId !== null && node.idText !== null) {\n this.restored.set(node.idText, node.restoredId);\n }\n try {\n const existing = this.sink.indexOf(id);\n const index = this.sink.addNode(id);\n if (existing !== INVALID_INDEX && this.hubs.has(index)) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.HUB_ID_CLASH,\n `node \"${String(id)}\" has the id of the hub a star-expanded hyperedge created earlier; the node is merged into the hub`,\n { line: node.line, element: String(id) },\n );\n } else if (existing !== INVALID_INDEX && this.declared.has(index)) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.DUPLICATE_NODE,\n `node \"${String(id)}\" is declared twice; the declarations are merged`,\n { line: node.line, element: String(id) },\n );\n } else {\n this.report.counts.nodes++;\n }\n this.declared.add(index);\n node.index = index;\n this.checkAbort();\n if (node.parent !== INVALID_INDEX) {\n this.sink.setNodeValue(this.parentColumn(), index, node.parent);\n }\n const { pending } = node;\n for (let i = 0; i < pending.length; i += 2) {\n this.sink.setNodeValue(pending[i] as ColumnHandle, index, pending[i + 1]);\n }\n pending.length = 0;\n } catch (err) {\n this.skipNode(node);\n this.report.recordError(err, { line: node.line, element: String(id) });\n }\n }\n\n /**\n * Mark a node element skipped (once) before its error is recorded, so the report's counts\n * include it even when that error is the one that exceeds the limit.\n * @param node - the node state\n */\n private skipNode(node: NodeState): void {\n if (!node.failed) {\n node.failed = true;\n this.report.counts.skippedNodes++;\n }\n }\n\n /** Close a `<node>`. */\n private finishNode(): void {\n const node = this.nodes.pop();\n if (node !== undefined) {\n this.materializeNode(node);\n }\n }\n\n /**\n * The `parent` column, declared on first use.\n * @returns the handle\n */\n private parentColumn(): ColumnHandle {\n if (this.parentHandle === INVALID_INDEX) {\n this.parentHandle = this.sink.declareNodeColumn({\n name: PARENT_COLUMN,\n dtype: \"u32\",\n role: \"parent\",\n refersTo: \"node\",\n nullable: true,\n origin: { format: FORMAT, id: null, title: null, type: \"graph\", namespace: null },\n });\n }\n return this.parentHandle;\n }\n\n // ------------------------------------------------------------------ edges\n\n /**\n * Open an `<edge>`; it is pushed at `</edge>` once its weight and data are known.\n * @param attrs - the edge attributes\n * @param line - the line\n */\n private beginEdge(attrs: ReadonlyMap<string, string>, line: number): void {\n this.reportUnreadAttributes(\"edge\", attrs, EDGE_ATTRIBUTES, line);\n const graph = this.graphs[this.graphs.length - 1];\n graph.edges++;\n const idText = attrs.get(\"id\");\n const sourceText = attrs.get(\"source\");\n const targetText = attrs.get(\"target\");\n const edge: EdgeState = {\n source: null,\n target: null,\n // an exporter that writes id=\"\" for an edge without one: the same as no id\n id: idText === undefined || idText.length === 0 ? null : idText,\n kind: graph.directed ? \"directed\" : \"undirected\",\n sourcePort: attrs.get(\"sourceport\") ?? null,\n targetPort: attrs.get(\"targetport\") ?? null,\n weight: undefined,\n pending: [],\n failed: false,\n line,\n keys: null,\n weightKey: null,\n sourceText: sourceText ?? null,\n targetText: targetText ?? null,\n };\n const where = { line, element: edge.id };\n if (sourceText === undefined || sourceText.length === 0) {\n this.skipEdge(edge);\n this.report.error(\"missing-value\", GRAPHML_ISSUE.MISSING_ENDPOINT, \"<edge> without a source\", where);\n }\n if (targetText === undefined || targetText.length === 0) {\n this.skipEdge(edge);\n this.report.error(\"missing-value\", GRAPHML_ISSUE.MISSING_ENDPOINT, \"<edge> without a target\", where);\n }\n if (!edge.failed && sourceText !== undefined && targetText !== undefined) {\n try {\n edge.source = this.endpointId(sourceText, line);\n edge.target = this.endpointId(targetText, line);\n } catch (err) {\n this.skipEdge(edge);\n this.report.recordError(err, where);\n }\n }\n const directedText = attrs.get(\"directed\");\n if (directedText !== undefined) {\n // the schema types directed as xs:boolean: true, false, 1 or 0\n if (directedText === \"true\" || directedText === \"1\") {\n edge.kind = \"directed\";\n } else if (directedText === \"false\" || directedText === \"0\") {\n edge.kind = \"undirected\";\n } else {\n this.skipEdge(edge);\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.INVALID_DIRECTED,\n `directed=\"${directedText}\" is neither true nor false (nor 1 or 0)`,\n where,\n );\n }\n }\n this.edge = edge;\n this.ctx.push(Ctx.Edge);\n }\n\n /**\n * Close an `<edge>`: push it through the direction resolver and write its values.\n */\n private finishEdge(): void {\n const { edge } = this;\n this.edge = null;\n if (edge === null) {\n return;\n }\n if (edge.failed || edge.source === null || edge.target === null) {\n this.skipEdge(edge);\n return;\n }\n if (\n (!this.options.addMissingNodes &&\n (this.sink.indexOf(edge.source) === INVALID_INDEX ||\n this.sink.indexOf(edge.target) === INVALID_INDEX)) ||\n (edge.id !== null && this.deferredEdgeIds.has(edge.id))\n ) {\n // GraphML allows nodes and edges in any order: wait for the end of the document. An\n // edge reusing a waiting edge's id waits behind it, so the first one keeps the id.\n if (edge.id !== null) {\n this.deferredEdgeIds.add(edge.id);\n }\n this.deferred.push(edge);\n return;\n }\n this.addEdge(edge);\n }\n\n /**\n * Push an edge through the direction resolver and write its values.\n * @param edge - the edge, its endpoints known\n */\n private addEdge(edge: EdgeState): void {\n if (edge.source === null || edge.target === null) {\n return;\n }\n const element = edge.id ?? `${String(edge.source)} -> ${String(edge.target)}`;\n const where = { line: edge.line, element };\n try {\n if (!this.options.addMissingNodes) {\n this.requireNode(edge.source);\n this.requireNode(edge.target);\n }\n this.checkGraphEndpoint(edge.source, edge.sourceText, where);\n this.checkGraphEndpoint(edge.target, edge.targetText, where);\n if (edge.id !== null && this.edgeIds.has(edge.id)) {\n throw new GraphFormatError(\"E_DUPLICATE_EDGE_ID\", `edge id \"${edge.id}\" is used twice`, {\n id: edge.id,\n });\n }\n const before = this.sink.edgeCount;\n this.countEndpoints(edge.source, edge.target);\n const e = this.direction.addEdge(edge.source, edge.target, edge.kind, edge.weight, where);\n this.report.counts.edges += this.sink.edgeCount - before;\n this.checkAbort();\n if (edge.id !== null) {\n this.edgeIds.add(edge.id);\n this.sink.setEdgeValue(this.edgeIdColumn(), e, edge.id);\n }\n if (edge.sourcePort !== null) {\n this.sink.setEdgeValue(this.portColumn(\"source\"), e, edge.sourcePort);\n this.portRefs.push([edge.source, edge.sourcePort]);\n }\n if (edge.targetPort !== null) {\n this.sink.setEdgeValue(this.portColumn(\"target\"), e, edge.targetPort);\n this.portRefs.push([edge.target, edge.targetPort]);\n }\n const { pending } = edge;\n for (let i = 0; i < pending.length; i += 2) {\n this.sink.setEdgeValue(pending[i] as ColumnHandle, e, pending[i + 1]);\n }\n } catch (err) {\n this.skipEdge(edge);\n this.report.recordError(err, where);\n }\n }\n\n /**\n * Mark an edge (or hyperedge) element skipped once, before its error is recorded.\n * @param edge - the edge state\n */\n private skipEdge(edge: EdgeState | HyperedgeState): void {\n if (!edge.failed) {\n edge.failed = true;\n this.report.counts.skippedEdges++;\n }\n }\n\n /**\n * Report an endpoint that names a nested `<graph>` rather than a node (a node of that id is\n * then created under addMissingNodes).\n * @param id - the endpoint id\n * @param text - the endpoint as written, or null\n * @param where - the edge's location\n */\n private checkGraphEndpoint(id: NodeId, text: string | null, where: Where): void {\n if (text !== null && this.graphIds.has(text) && this.sink.indexOf(id) === INVALID_INDEX) {\n this.report.warning(\n \"validation-error\",\n GRAPHML_ISSUE.GRAPH_ENDPOINT,\n `edge endpoint \"${text}\" names a <graph>, not a node; a node \"${text}\" is created`,\n where,\n );\n }\n }\n\n /**\n * E_UNKNOWN_NODE when an endpoint was never declared (addMissingNodes false enforced by the\n * importer, whatever the sink allows).\n * @param id - the endpoint id\n */\n private requireNode(id: NodeId): void {\n if (this.sink.indexOf(id) === INVALID_INDEX) {\n throw new GraphFormatError(\"E_UNKNOWN_NODE\", `edge endpoint \"${String(id)}\" is not a declared node`, {\n id,\n });\n }\n }\n\n /**\n * The edge `id` column (role id, unique), declared on first use.\n * @returns the handle\n */\n private edgeIdColumn(): ColumnHandle {\n if (this.edgeIdHandle === INVALID_INDEX) {\n this.edgeIdHandle = this.sink.declareEdgeColumn({\n name: EDGE_ID_COLUMN,\n dtype: \"string\",\n role: \"id\",\n unique: true,\n nullable: true,\n origin: { format: FORMAT, id: null, title: null, type: \"id\", namespace: null },\n });\n }\n return this.edgeIdHandle;\n }\n\n /**\n * The sourceport / targetport column, declared on first use.\n * @param side - which end\n * @returns the handle\n */\n private portColumn(side: \"source\" | \"target\"): ColumnHandle {\n if (side === \"source\") {\n if (this.sourcePortHandle === INVALID_INDEX) {\n this.sourcePortHandle = this.sink.declareEdgeColumn({\n name: SOURCE_PORT_COLUMN,\n dtype: \"string\",\n role: \"sourcePort\",\n nullable: true,\n origin: { format: FORMAT, id: null, title: null, type: \"sourceport\", namespace: null },\n });\n }\n return this.sourcePortHandle;\n }\n if (this.targetPortHandle === INVALID_INDEX) {\n this.targetPortHandle = this.sink.declareEdgeColumn({\n name: TARGET_PORT_COLUMN,\n dtype: \"string\",\n role: \"targetPort\",\n nullable: true,\n origin: { format: FORMAT, id: null, title: null, type: \"targetport\", namespace: null },\n });\n }\n return this.targetPortHandle;\n }\n\n // ------------------------------------------------------------------ hyperedges\n\n /**\n * Open a `<hyperedge>` per the hyperedges option.\n * @param attrs - its attributes\n * @param line - the line\n */\n private beginHyperedge(attrs: ReadonlyMap<string, string>, line: number): void {\n this.reportUnreadAttributes(\"hyperedge\", attrs, HYPEREDGE_ATTRIBUTES, line);\n const id = attrs.get(\"id\") ?? null;\n const where = { line, element: id };\n switch (this.options.hyperedges) {\n case \"error\":\n this.report.error(\n \"unsupported\",\n GRAPHML_ISSUE.HYPEREDGE,\n 'hyperedge refused (hyperedges: \"error\")',\n where,\n );\n throw this.report.abort(\"hyperedge refused\", { code: GRAPHML_ISSUE.HYPEREDGE });\n case \"skip\":\n this.report.warnOnce(\n \"unsupported\",\n GRAPHML_ISSUE.HYPEREDGE_SKIPPED,\n 'hyperedges are skipped (hyperedges: \"skip\"); use \"star\" or \"clique\" to expand them',\n where,\n );\n this.report.counts.skippedEdges++;\n this.ctx.push(Ctx.Skip);\n return;\n case \"star\":\n case \"clique\":\n this.hyperedge = { id, endpoints: [], failed: false, line };\n this.ctx.push(Ctx.Hyperedge);\n return;\n default: {\n const policy: never = this.options.hyperedges;\n throw new GraphFormatError(\"E_UNSUPPORTED\", `unknown hyperedges policy ${String(policy)}`, {\n option: \"hyperedges\",\n });\n }\n }\n }\n\n /**\n * An `<endpoint>` of the open hyperedge.\n * @param attrs - its attributes\n * @param line - the line\n */\n private readEndpoint(attrs: ReadonlyMap<string, string>, line: number): void {\n const { hyperedge } = this;\n if (hyperedge === null) {\n return;\n }\n const where = { line, element: hyperedge.id };\n const nodeText = attrs.get(\"node\");\n const typeText = attrs.get(\"type\") ?? \"undir\";\n if (nodeText === undefined || nodeText.length === 0) {\n this.skipEdge(hyperedge);\n this.report.error(\"missing-value\", GRAPHML_ISSUE.HYPEREDGE_ENDPOINT, \"<endpoint> without a node\", where);\n return;\n }\n if (typeText !== \"in\" && typeText !== \"out\" && typeText !== \"undir\") {\n this.skipEdge(hyperedge);\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.HYPEREDGE_ENDPOINT,\n `endpoint type \"${typeText}\" is not in, out or undir`,\n where,\n );\n return;\n }\n try {\n const node = this.endpointId(nodeText, line);\n hyperedge.endpoints.push({ node, type: typeText });\n } catch (err) {\n this.skipEdge(hyperedge);\n this.report.recordError(err, where);\n }\n }\n\n /** Close a `<hyperedge>`: expand it to a star or a clique. */\n private finishHyperedge(): void {\n const { hyperedge } = this;\n this.hyperedge = null;\n if (hyperedge === null) {\n return;\n }\n if (hyperedge.failed) {\n return;\n }\n if (hyperedge.endpoints.length === 0) {\n this.skipEdge(hyperedge);\n this.report.error(\n \"missing-value\",\n GRAPHML_ISSUE.HYPEREDGE_ENDPOINT,\n \"<hyperedge> without endpoints yields no edge\",\n { line: hyperedge.line, element: hyperedge.id },\n );\n return;\n }\n if (\n !this.options.addMissingNodes &&\n hyperedge.endpoints.some((endpoint) => this.sink.indexOf(endpoint.node) === INVALID_INDEX)\n ) {\n this.deferred.push(hyperedge);\n return;\n }\n this.expandHyperedge(hyperedge);\n }\n\n /**\n * Expand a hyperedge to a star or a clique; under addMissingNodes false every endpoint must be\n * a declared node.\n * @param hyperedge - the hyperedge, its endpoints read\n */\n private expandHyperedge(hyperedge: HyperedgeState): void {\n const where = { line: hyperedge.line, element: hyperedge.id };\n try {\n for (const endpoint of hyperedge.endpoints) {\n if (!this.options.addMissingNodes) {\n this.requireNode(endpoint.node);\n }\n }\n for (const node of new Set(hyperedge.endpoints.map((endpoint) => endpoint.node))) {\n this.countEndpoints(node, node);\n }\n if (this.options.hyperedges === \"star\") {\n this.expandStar(hyperedge, where);\n } else if (this.expandClique(hyperedge, where) === 0) {\n this.skipEdge(hyperedge);\n this.report.error(\n \"validation-error\",\n GRAPHML_ISSUE.HYPEREDGE_ENDPOINT,\n \"no two endpoints of this hyperedge can be joined (all in, all out, or only one); it yields no edge\",\n where,\n );\n }\n } catch (err) {\n this.skipEdge(hyperedge);\n this.report.recordError(err, where);\n }\n }\n\n /**\n * Star expansion: a synthetic hub node (marked in the `graphty.hyperedge` column) joined to\n * every endpoint; `in` endpoints point at the hub, `out` endpoints are pointed at by it,\n * `undir` endpoints are undirected.\n * @param hyperedge - the hyperedge\n * @param where - the location for issues\n */\n private expandStar(hyperedge: HyperedgeState, where: Where): void {\n this.hyperedgeCount++;\n const baseId = hyperedge.id ?? `hyperedge${this.hyperedgeCount}`;\n let hubId = baseId;\n for (let n = 2; this.sink.indexOf(hubId) !== INVALID_INDEX; n++) {\n hubId = `${baseId}#${n}`;\n }\n const hub = this.sink.addNode(hubId);\n this.declared.add(hub);\n this.hubs.add(hub);\n this.report.counts.nodes++;\n if (this.hubHandle === INVALID_INDEX) {\n this.hubHandle = this.sink.declareNodeColumn({\n name: HYPEREDGE_HUB_COLUMN,\n dtype: \"bool\",\n nullable: true,\n origin: { format: FORMAT, id: null, title: null, type: \"hyperedge\", namespace: null },\n });\n }\n this.sink.setNodeValue(this.hubHandle, hub, true);\n for (const endpoint of hyperedge.endpoints) {\n const before = this.sink.edgeCount;\n switch (endpoint.type) {\n case \"in\":\n this.direction.addEdge(endpoint.node, hubId, \"directed\", undefined, where);\n break;\n case \"out\":\n this.direction.addEdge(hubId, endpoint.node, \"directed\", undefined, where);\n break;\n case \"undir\":\n this.direction.addEdge(endpoint.node, hubId, \"undirected\", undefined, where);\n break;\n default: {\n const { type } = endpoint;\n throw new GraphFormatError(\"E_UNSUPPORTED\", `unknown endpoint type ${String(type)}`, {});\n }\n }\n this.report.counts.edges += this.sink.edgeCount - before;\n }\n }\n\n /**\n * Clique expansion: every `in` endpoint points at every `out` endpoint; `undir` endpoints are\n * joined undirected to every other endpoint; two endpoints of the same direction are not joined.\n * @param hyperedge - the hyperedge\n * @param where - the location for issues\n * @returns the number of edge elements added\n */\n private expandClique(hyperedge: HyperedgeState, where: Where): number {\n const { endpoints } = hyperedge;\n let added = 0;\n for (let i = 0; i < endpoints.length; i++) {\n for (let j = i + 1; j < endpoints.length; j++) {\n const a = endpoints[i];\n const b = endpoints[j];\n const before = this.sink.edgeCount;\n if (a.type === \"undir\" || b.type === \"undir\") {\n this.direction.addEdge(a.node, b.node, \"undirected\", undefined, where);\n } else if (a.type === \"in\" && b.type === \"out\") {\n this.direction.addEdge(a.node, b.node, \"directed\", undefined, where);\n } else if (a.type === \"out\" && b.type === \"in\") {\n this.direction.addEdge(b.node, a.node, \"directed\", undefined, where);\n } else {\n continue;\n }\n added++;\n this.report.counts.edges += this.sink.edgeCount - before;\n }\n }\n return added;\n }\n\n // ------------------------------------------------------------------ options and ids\n\n /**\n * Count the endpoints of an edge the file never declared as nodes of the sink (created under\n * addMissingNodes), so the report describes what the sink holds (design section 8.6).\n * @param source - the source id\n * @param target - the target id\n */\n private countEndpoints(source: NodeId, target: NodeId): void {\n if (!this.options.addMissingNodes) {\n return;\n }\n let created = 0;\n if (this.sink.indexOf(source) === INVALID_INDEX) {\n created++;\n }\n if (source !== target && this.sink.indexOf(target) === INVALID_INDEX) {\n created++;\n }\n this.report.counts.nodes += created;\n }\n\n /** Check the cancellation signal every ABORT_CHECK_INTERVAL elements. */\n private checkAbort(): void {\n if (++this.elementsSinceCheck >= ABORT_CHECK_INTERVAL) {\n this.elementsSinceCheck = 0;\n throwIfAborted(this.options.signal);\n }\n }\n\n /**\n * The id an edge endpoint refers to: the original id when the text is a mangled id restored\n * from `graphty:originalId` (the exporter writes endpoints with the mangled id), else the\n * coerced text.\n * @param text - the source / target / endpoint node text\n * @param line - the line\n * @returns the node id\n */\n private endpointId(text: string, line: number): NodeId {\n const restored = this.restored.get(text);\n if (restored !== undefined) {\n return restored;\n }\n const id = this.coercer.text(text);\n this.reportMerge(text, line);\n return id;\n }\n\n /**\n * Report a merge the coercer detected under ids: \"number\".\n * @param text - the id text just coerced\n * @param line - the line\n */\n private reportMerge(text: string, line: number): void {\n const merge = this.coercer.lastMerge;\n if (merge !== null) {\n this.report.warning(\n \"coercion\",\n GRAPHML_ISSUE.ID_MERGED,\n `id \"${merge.text}\" merged with \"${merge.previousText}\" as ${merge.id} under ids: \"number\"`,\n { line, element: text },\n );\n }\n }\n}\n\n/**\n * A `parse.nodes` / `parse.edges` hint as a count.\n * @param text - the attribute text\n * @returns the count, or null when absent or not a non-negative integer\n */\nfunction hint(text: string | undefined): number | null {\n if (text === undefined || !/^\\d+$/.test(text)) {\n return null;\n }\n const n = Number(text);\n return Number.isSafeInteger(n) ? n : null;\n}\n\n/**\n * Resolve the format-specific options.\n * @param options - the caller's options\n * @returns the yfiles mode\n */\nfunction resolveYfiles(options: GraphmlImportOptions | undefined): \"json\" | \"skip\" {\n const value = options?.yfiles;\n if (value === undefined) {\n return \"json\";\n }\n if (typeof value !== \"string\" || !YFILES_MODES.has(value)) {\n throw new GraphFormatError(\"E_UNSUPPORTED\", `option yfiles: ${JSON.stringify(value)} is not \"json\" or \"skip\"`, {\n option: \"yfiles\",\n found: value,\n });\n }\n return value;\n}\n\n/**\n * Confidence that a head of bytes is GraphML.\n * @param head - the first bytes\n * @returns 1 for a `<graphml` root in the GraphML namespace, 0.9 for a `<graphml` root, 0.05 for other XML, 0 otherwise\n * or when the head does not start with markup\n */\nfunction sniffGraphml(head: Uint8Array): number {\n const text = sniffXmlText(head.subarray(0, SNIFF_BYTES));\n // Only a document that starts as markup: a JSON or CSV value may mention a `<graphml>` tag.\n if (!/^\\uFEFF?\\s*</.test(text)) {\n return 0;\n }\n // the root may carry a namespace prefix (<g:graphml xmlns:g=\"...\">)\n const root = text.search(/<([\\w.-]+:)?graphml[\\s>/]/);\n if (root >= 0) {\n return text.includes(GRAPHML_NAMESPACE, root) ? 1 : 0.9;\n }\n return /^\\s*<(\\?xml|!--|!DOCTYPE)/.test(text) ? 0.05 : 0;\n}\n\n/**\n * Import GraphML into a sink.\n * @param input - the document\n * @param sink - the sink\n * @param options - format-specific and common options\n * @returns the report; ImportError when the document cannot be read or the error limit is exceeded\n */\nasync function importGraphml(\n input: ImportInput,\n sink: GraphSink,\n options?: GraphmlImportOptions & CommonImportOptions,\n): Promise<ImportReport> {\n const common = resolveImportOptions(options, FORMAT_DEFAULTS);\n const yfilesMode = resolveYfiles(options);\n const report = new ImportReportBuilder(FORMAT, common.errorLimit);\n reportSinkOptions(sink, options, report, true);\n reportUnusedOptions(options, report, USED_OPTIONS);\n const reader = new GraphmlReader(sink, report, common, yfilesMode);\n try {\n await tokenizeXml(\n textChunks(input, report, { ...common, declaredEncoding: xmlDeclaredEncoding, xml: true }),\n reader,\n );\n } catch (err) {\n if (err instanceof XmlEmptyInputError) {\n report.fail(GRAPHML_ISSUE.EMPTY_INPUT, \"the input is empty (no markup at all)\", { line: err.line });\n }\n if (err instanceof XmlSyntaxError) {\n report.fail(\n err instanceof XmlNestingError ? GRAPHML_ISSUE.XML_NESTING : GRAPHML_ISSUE.XML_SYNTAX,\n err.message,\n { line: err.line },\n );\n }\n throw err;\n }\n reader.finish();\n throwIfAborted(common.signal);\n return report.finish();\n}\n\n/**\n * The GraphML importer.\n * @category Built-in formats\n */\nexport const graphmlImporter: GraphImporter<GraphmlImportOptions> = Object.freeze({\n format: FORMAT,\n options: Object.freeze([\"yfiles\"]),\n extensions: EXTENSIONS,\n mimeTypes: MIME_TYPES,\n sniff: sniffGraphml,\n styles: graphmlStyles,\n positions: yfilesPositions,\n import: importGraphml,\n});\n\n/** The elements GraphML defines, for telling a misplaced one from a foreign one. */\nconst GRAPHML_ELEMENTS = new Set([\n \"graphml\",\n \"key\",\n \"default\",\n \"graph\",\n \"node\",\n \"edge\",\n \"hyperedge\",\n \"endpoint\",\n \"port\",\n \"data\",\n \"desc\",\n \"locator\",\n]);\n\n/**\n * The message of an element skipped where it stands.\n * @param name - the element name\n * @returns a message that says where a GraphML element belongs, or that a foreign one is not GraphML\n */\nfunction unknownElementMessage(name: string): string {\n if (name === \"key\") {\n return \"element <key> is only allowed as a child of <graphml>, before the first <graph>; it was skipped\";\n }\n return GRAPHML_ELEMENTS.has(name)\n ? `element <${name}> is not allowed at this place in a GraphML file and was skipped`\n : `element <${name}> is not GraphML and was skipped`;\n}\n"],"names":["text","child","yfilesColumns","attr","hint"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,mBAAmB;AAGzB,MAAM,WAAW;AAoBV,MAAM,eAAe;AAAA;AAAA,EAMxB,cAAc;AALd,SAAiB,SAAkB,CAAA;AAM/B,SAAK,OAAO,EAAE,MAAM,IAAI,MAAM,CAAA,GAAI,UAAU,OAAO,aAAa,OAAO,MAAM,GAAA;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,OAAgB;AAChB,WAAO,KAAK,OAAO,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAc,OAA0C;AAC1D,UAAM,OAAsB,CAAA;AAC5B,QAAI,WAAW;AACf,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO;AAC9B,WAAK,mBAAmB,GAAG,IAAI;AAC/B,iBAAW;AAAA,IACf;AACA,SAAK,OAAO,KAAK,EAAE,MAAM,MAAM,UAAU,aAAa,OAAO,MAAM,GAAA,CAAI;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAKA,OAAoB;A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