import { l as log } from "./config-b4fa35bb.js"; const d3Attrs = function(d3Elem, attrs) { for (let attr of attrs) { d3Elem.attr(attr[0], attr[1]); } }; const calculateSvgSizeAttrs = function(height, width, useMaxWidth) { let attrs = /* @__PURE__ */ new Map(); if (useMaxWidth) { attrs.set("width", "100%"); attrs.set("style", `max-width: ${width}px;`); } else { attrs.set("height", height); attrs.set("width", width); } return attrs; }; const configureSvgSize = function(svgElem, height, width, useMaxWidth) { const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth); d3Attrs(svgElem, attrs); }; const setupGraphViewbox = function(graph, svgElem, padding, useMaxWidth) { const svgBounds = svgElem.node().getBBox(); const sWidth = svgBounds.width; const sHeight = svgBounds.height; log.info(`SVG bounds: ${sWidth}x${sHeight}`, svgBounds); let width = 0; let height = 0; log.info(`Graph bounds: ${width}x${height}`, graph); width = sWidth + padding * 2; height = sHeight + padding * 2; log.info(`Calculated bounds: ${width}x${height}`); configureSvgSize(svgElem, height, width, useMaxWidth); const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${svgBounds.width + 2 * padding} ${svgBounds.height + 2 * padding}`; svgElem.attr("viewBox", vBox); }; export { configureSvgSize as c, setupGraphViewbox as s }; //# sourceMappingURL=setupGraphViewbox-16a0ba81.js.map