{
const { group, setAttributes } = SVG;
const root = svg`${src}`;
const attrs = {
fill: "none",
stroke: "#000",
"stroke-linecap": "round",
"stroke-linejoin": "round"
};
setAttributes(root, { ...attrs, width, height: 400 });
yield root;
const params = { kerning: -1.7, scale: [0.3, 0.4], weight: 1.8 };
const textNodes = root.getElementsByTagName("text");
for (const node of textNodes) {
const text = node.textContent;
const { x, y } = node.getBBox();
const gr = group([x, y + 8], str2polylines(text, params));
node.replaceWith(gr);
}
const switchNodes = root.getElementsByTagName("switch");
for (const node of switchNodes) {
const parent = node.parentNode;
const rect = parent.previousSibling;
if (rect?.tagName == "rect") {
const text = node.textContent;
const { x, y, width: w, height: h } = rect.getBBox();
const { x: xt, y: yt, width: wt, height: ht } = bounds(text, params);
const offset = [x + w / 2 - xt - wt / 2, y + h / 2 - yt - ht / 2 + 1.5];
const gr = group(offset, str2polylines(text, params));
node.replaceWith(gr);
} else node.remove();
}
return zoomAndPanSvg(root);
}