import { AbstractMermaidTokenBuilder as c, __name as a, AbstractMermaidValueConverter as p, MermaidGeneratedSharedModule as f, TreemapGeneratedModule as T } from "./chunk-FPAJGGOC.js";
import { EmptyFileSystem as u } from "../../../../../../../langium@3.3.1/node_modules/langium/lib/workspace/file-system-provider.js";
import { inject as d } from "../../../../../../../langium@3.3.1/node_modules/langium/lib/dependency-injection.js";
import { createDefaultSharedCoreModule as v, createDefaultCoreModule as g } from "../../../../../../../langium@3.3.1/node_modules/langium/lib/default-module.js";
var i, h = (i = class extends c {
  constructor() {
    super(["treemap"]);
  }
}, a(i, "TreemapTokenBuilder"), i), C = /classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/, n, V = (n = class extends p {
  runCustomConverter(r, e, o) {
    if (r.name === "NUMBER2")
      return parseFloat(e.replace(/,/g, ""));
    if (r.name === "SEPARATOR")
      return e.substring(1, e.length - 1);
    if (r.name === "STRING2")
      return e.substring(1, e.length - 1);
    if (r.name === "INDENTATION")
      return e.length;
    if (r.name === "ClassDef") {
      if (typeof e != "string")
        return e;
      const t = C.exec(e);
      if (t)
        return {
          $type: "ClassDefStatement",
          className: t[1],
          styleText: t[2] || void 0
        };
    }
  }
}, a(n, "TreemapValueConverter"), n);
function m(l) {
  const r = l.validation.TreemapValidator, e = l.validation.ValidationRegistry;
  if (e) {
    const o = {
      Treemap: r.checkSingleRoot.bind(r)
      // Remove unused validation for TreemapRow
    };
    e.register(o, r);
  }
}
a(m, "registerValidationChecks");
var s, M = (s = class {
  /**
   * Validates that a treemap has only one root node.
   * A root node is defined as a node that has no indentation.
   */
  checkSingleRoot(r, e) {
    let o;
    for (const t of r.TreemapRows)
      t.item && (o === void 0 && // Check if this is a root node (no indentation)
      t.indent === void 0 ? o = 0 : t.indent === void 0 ? e("error", "Multiple root nodes are not allowed in a treemap.", {
        node: t,
        property: "item"
      }) : o !== void 0 && o >= parseInt(t.indent, 10) && e("error", "Multiple root nodes are not allowed in a treemap.", {
        node: t,
        property: "item"
      }));
  }
}, a(s, "TreemapValidator"), s), S = {
  parser: {
    TokenBuilder: /* @__PURE__ */ a(() => new h(), "TokenBuilder"),
    ValueConverter: /* @__PURE__ */ a(() => new V(), "ValueConverter")
  },
  validation: {
    TreemapValidator: /* @__PURE__ */ a(() => new M(), "TreemapValidator")
  }
};
function k(l = u) {
  const r = d(
    v(l),
    f
  ), e = d(
    g({ shared: r }),
    T,
    S
  );
  return r.ServiceRegistry.register(e), m(e), { shared: r, Treemap: e };
}
a(k, "createTreemapServices");
export {
  S as TreemapModule,
  k as createTreemapServices
};
