"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const chunkQXUST7PY = require("./dist-chunks-mermaid.core-chunk-QXUST7PY.cjs");
const chunkJZLCHNYA = require("./dist-chunks-mermaid.core-chunk-JZLCHNYA.cjs");
const chunkS3R3BYOJ = require("./dist-chunks-mermaid.core-chunk-S3R3BYOJ.cjs");
const chunkABZYJK2D = require("./dist-chunks-mermaid.core-chunk-ABZYJK2D.cjs");
const chunkAGHRB4JF = require("./dist-chunks-mermaid.core-chunk-AGHRB4JF.cjs");
var internalHelpers = {
  common: chunkABZYJK2D.common_default,
  getConfig: chunkABZYJK2D.getConfig,
  insertCluster: chunkJZLCHNYA.insertCluster,
  insertEdge: chunkQXUST7PY.insertEdge,
  insertEdgeLabel: chunkQXUST7PY.insertEdgeLabel,
  insertMarkers: chunkQXUST7PY.markers_default,
  insertNode: chunkJZLCHNYA.insertNode,
  interpolateToCurve: chunkS3R3BYOJ.interpolateToCurve,
  labelHelper: chunkJZLCHNYA.labelHelper,
  log: chunkAGHRB4JF.log,
  positionEdgeLabel: chunkQXUST7PY.positionEdgeLabel
};
var layoutAlgorithms = {};
var registerLayoutLoaders = /* @__PURE__ */ chunkAGHRB4JF.__name((loaders) => {
  for (const loader of loaders) {
    layoutAlgorithms[loader.name] = loader;
  }
}, "registerLayoutLoaders");
var registerDefaultLayoutLoaders = /* @__PURE__ */ chunkAGHRB4JF.__name(() => {
  registerLayoutLoaders([
    {
      name: "dagre",
      loader: /* @__PURE__ */ chunkAGHRB4JF.__name(async () => await Promise.resolve().then(() => require("./dist-chunks-mermaid.core-dagre-6UL2VRFP.cjs")), "loader")
    },
    ...[
      {
        name: "cose-bilkent",
        loader: /* @__PURE__ */ chunkAGHRB4JF.__name(async () => await Promise.resolve().then(() => require("./dist-chunks-mermaid.core-cose-bilkent-S5V4N54A.cjs")), "loader")
      }
    ]
  ]);
}, "registerDefaultLayoutLoaders");
registerDefaultLayoutLoaders();
var render = /* @__PURE__ */ chunkAGHRB4JF.__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__ */ chunkAGHRB4JF.__name((algorithm = "", { fallback = "dagre" } = {}) => {
  if (algorithm in layoutAlgorithms) {
    return algorithm;
  }
  if (fallback in layoutAlgorithms) {
    chunkAGHRB4JF.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");
exports.getRegisteredLayoutAlgorithm = getRegisteredLayoutAlgorithm;
exports.registerLayoutLoaders = registerLayoutLoaders;
exports.render = render;
//# sourceMappingURL=dist-chunks-mermaid.core-chunk-N4CR4FBY.cjs.map
