import { positionEdgeLabel, markers_default, insertEdgeLabel, insertEdge } from "./dist-chunks-mermaid.core-chunk-QXUST7PY.js";
import { labelHelper, insertNode, insertCluster } from "./dist-chunks-mermaid.core-chunk-JZLCHNYA.js";
import { interpolateToCurve } from "./dist-chunks-mermaid.core-chunk-S3R3BYOJ.js";
import { getConfig, common_default } from "./dist-chunks-mermaid.core-chunk-ABZYJK2D.js";
import { __name, log } from "./dist-chunks-mermaid.core-chunk-AGHRB4JF.js";
var internalHelpers = {
  common: common_default,
  getConfig,
  insertCluster,
  insertEdge,
  insertEdgeLabel,
  insertMarkers: markers_default,
  insertNode,
  interpolateToCurve,
  labelHelper,
  log,
  positionEdgeLabel
};
var layoutAlgorithms = {};
var registerLayoutLoaders = /* @__PURE__ */ __name((loaders) => {
  for (const loader of loaders) {
    layoutAlgorithms[loader.name] = loader;
  }
}, "registerLayoutLoaders");
var registerDefaultLayoutLoaders = /* @__PURE__ */ __name(() => {
  registerLayoutLoaders([
    {
      name: "dagre",
      loader: /* @__PURE__ */ __name(async () => await import("./dist-chunks-mermaid.core-dagre-6UL2VRFP.js"), "loader")
    },
    ...[
      {
        name: "cose-bilkent",
        loader: /* @__PURE__ */ __name(async () => await import("./dist-chunks-mermaid.core-cose-bilkent-S5V4N54A.js"), "loader")
      }
    ]
  ]);
}, "registerDefaultLayoutLoaders");
registerDefaultLayoutLoaders();
var render = /* @__PURE__ */ __name(async (data4Layout, svg) => {
  if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {
    throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);
  }
  const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];
  const layoutRenderer = await layoutDefinition.loader();
  return layoutRenderer.render(data4Layout, svg, internalHelpers, {
    algorithm: layoutDefinition.algorithm
  });
}, "render");
var getRegisteredLayoutAlgorithm = /* @__PURE__ */ __name((algorithm = "", { fallback = "dagre" } = {}) => {
  if (algorithm in layoutAlgorithms) {
    return algorithm;
  }
  if (fallback in layoutAlgorithms) {
    log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);
    return fallback;
  }
  throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);
}, "getRegisteredLayoutAlgorithm");
export {
  getRegisteredLayoutAlgorithm,
  registerLayoutLoaders,
  render
};
//# sourceMappingURL=dist-chunks-mermaid.core-chunk-N4CR4FBY.js.map
