import { u as de } from "./vendor/recharts.js";
import { h as le, p as he, r as $e } from "./chunk-5PVQY5BW.js";
import { n as l, r as w } from "./chunk-AGHRB4JF.js";
import { B as fe, C as ge, V as ue, W as ye, _ as xe, a as me, b as D, d as pe, q as be, s as B, v as we, y as J } from "./chunk-ICPOFSXX.js";
import { t as ke } from "./chunk-4BX2VUAB.js";
import { t as Ce } from "./mermaid-parser.core.js";
import { t as ve } from "./chunk-QZHKN3VN.js";
var m = {
  NORMAL: 0,
  REVERSE: 1,
  HIGHLIGHT: 2,
  MERGE: 3,
  CHERRY_PICK: 4
}, Ee = pe.gitGraph, S = /* @__PURE__ */ l(() => $e({
  ...Ee,
  ...J().gitGraph
}), "getConfig"), d = new ve(() => {
  const e = S(), r = e.mainBranchName, t = e.mainBranchOrder;
  return {
    mainBranchName: r,
    commits: /* @__PURE__ */ new Map(),
    head: null,
    branchConfig: /* @__PURE__ */ new Map([[r, {
      name: r,
      order: t
    }]]),
    branches: /* @__PURE__ */ new Map([[r, null]]),
    currBranch: r,
    direction: "LR",
    seq: 0,
    options: {}
  };
});
function j() {
  return he({ length: 7 });
}
l(j, "getID");
function re(e, r) {
  const t = /* @__PURE__ */ Object.create(null);
  return e.reduce((s, o) => {
    const c = r(o);
    return t[c] || (t[c] = !0, s.push(o)), s;
  }, []);
}
l(re, "uniqBy");
var Be = /* @__PURE__ */ l(function(e) {
  d.records.direction = e;
}, "setDirection"), Te = /* @__PURE__ */ l(function(e) {
  w.debug("options str", e), e = e?.trim(), e = e || "{}";
  try {
    d.records.options = JSON.parse(e);
  } catch (r) {
    w.error("error while parsing gitGraph options", r.message);
  }
}, "setOptions"), Le = /* @__PURE__ */ l(function() {
  return d.records.options;
}, "getOptions"), Me = /* @__PURE__ */ l(function(e) {
  let r = e.msg, t = e.id;
  const s = e.type;
  let o = e.tags;
  w.info("commit", r, t, s, o), w.debug("Entering commit:", r, t, s, o);
  const c = S();
  t = B.sanitizeText(t, c), r = B.sanitizeText(r, c), o = o?.map((n) => B.sanitizeText(n, c));
  const a = {
    id: t || d.records.seq + "-" + j(),
    message: r,
    seq: d.records.seq++,
    type: s ?? m.NORMAL,
    tags: o ?? [],
    parents: d.records.head == null ? [] : [d.records.head.id],
    branch: d.records.currBranch
  };
  d.records.head = a, w.info("main branch", c.mainBranchName), d.records.commits.has(a.id) && w.warn(`Commit ID ${a.id} already exists`), d.records.commits.set(a.id, a), d.records.branches.set(d.records.currBranch, a.id), w.debug("in pushCommit " + a.id);
}, "commit"), Re = /* @__PURE__ */ l(function(e) {
  let r = e.name;
  const t = e.order;
  if (r = B.sanitizeText(r, S()), d.records.branches.has(r)) throw new Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${r}")`);
  d.records.branches.set(r, d.records.head != null ? d.records.head.id : null), d.records.branchConfig.set(r, {
    name: r,
    order: t
  }), te(r), w.debug("in createBranch");
}, "branch"), Ie = /* @__PURE__ */ l((e) => {
  let r = e.branch, t = e.id;
  const s = e.type, o = e.tags, c = S();
  r = B.sanitizeText(r, c), t && (t = B.sanitizeText(t, c));
  const a = d.records.branches.get(d.records.currBranch), n = d.records.branches.get(r), $ = a ? d.records.commits.get(a) : void 0, f = n ? d.records.commits.get(n) : void 0;
  if ($ && f && $.branch === r) throw new Error(`Cannot merge branch '${r}' into itself.`);
  if (d.records.currBranch === r) {
    const i = /* @__PURE__ */ new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
    throw i.hash = {
      text: `merge ${r}`,
      token: `merge ${r}`,
      expected: ["branch abc"]
    }, i;
  }
  if ($ === void 0 || !$) {
    const i = /* @__PURE__ */ new Error(`Incorrect usage of "merge". Current branch (${d.records.currBranch})has no commits`);
    throw i.hash = {
      text: `merge ${r}`,
      token: `merge ${r}`,
      expected: ["commit"]
    }, i;
  }
  if (!d.records.branches.has(r)) {
    const i = /* @__PURE__ */ new Error('Incorrect usage of "merge". Branch to be merged (' + r + ") does not exist");
    throw i.hash = {
      text: `merge ${r}`,
      token: `merge ${r}`,
      expected: [`branch ${r}`]
    }, i;
  }
  if (f === void 0 || !f) {
    const i = /* @__PURE__ */ new Error('Incorrect usage of "merge". Branch to be merged (' + r + ") has no commits");
    throw i.hash = {
      text: `merge ${r}`,
      token: `merge ${r}`,
      expected: ['"commit"']
    }, i;
  }
  if ($ === f) {
    const i = /* @__PURE__ */ new Error('Incorrect usage of "merge". Both branches have same head');
    throw i.hash = {
      text: `merge ${r}`,
      token: `merge ${r}`,
      expected: ["branch abc"]
    }, i;
  }
  if (t && d.records.commits.has(t)) {
    const i = /* @__PURE__ */ new Error('Incorrect usage of "merge". Commit with id:' + t + " already exists, use different custom id");
    throw i.hash = {
      text: `merge ${r} ${t} ${s} ${o?.join(" ")}`,
      token: `merge ${r} ${t} ${s} ${o?.join(" ")}`,
      expected: [`merge ${r} ${t}_UNIQUE ${s} ${o?.join(" ")}`]
    }, i;
  }
  const g = n || "", h = {
    id: t || `${d.records.seq}-${j()}`,
    message: `merged branch ${r} into ${d.records.currBranch}`,
    seq: d.records.seq++,
    parents: d.records.head == null ? [] : [d.records.head.id, g],
    branch: d.records.currBranch,
    type: m.MERGE,
    customType: s,
    customId: !!t,
    tags: o ?? []
  };
  d.records.head = h, d.records.commits.set(h.id, h), d.records.branches.set(d.records.currBranch, h.id), w.debug(d.records.branches), w.debug("in mergeBranch");
}, "merge"), Oe = /* @__PURE__ */ l(function(e) {
  let r = e.id, t = e.targetId, s = e.tags, o = e.parent;
  w.debug("Entering cherryPick:", r, t, s);
  const c = S();
  if (r = B.sanitizeText(r, c), t = B.sanitizeText(t, c), s = s?.map(($) => B.sanitizeText($, c)), o = B.sanitizeText(o, c), !r || !d.records.commits.has(r)) {
    const $ = /* @__PURE__ */ new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');
    throw $.hash = {
      text: `cherryPick ${r} ${t}`,
      token: `cherryPick ${r} ${t}`,
      expected: ["cherry-pick abc"]
    }, $;
  }
  const a = d.records.commits.get(r);
  if (a === void 0 || !a) throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');
  if (o && !(Array.isArray(a.parents) && a.parents.includes(o))) throw /* @__PURE__ */ new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");
  const n = a.branch;
  if (a.type === m.MERGE && !o) throw /* @__PURE__ */ new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");
  if (!t || !d.records.commits.has(t)) {
    if (n === d.records.currBranch) {
      const h = /* @__PURE__ */ new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');
      throw h.hash = {
        text: `cherryPick ${r} ${t}`,
        token: `cherryPick ${r} ${t}`,
        expected: ["cherry-pick abc"]
      }, h;
    }
    const $ = d.records.branches.get(d.records.currBranch);
    if ($ === void 0 || !$) {
      const h = /* @__PURE__ */ new Error(`Incorrect usage of "cherry-pick". Current branch (${d.records.currBranch})has no commits`);
      throw h.hash = {
        text: `cherryPick ${r} ${t}`,
        token: `cherryPick ${r} ${t}`,
        expected: ["cherry-pick abc"]
      }, h;
    }
    const f = d.records.commits.get($);
    if (f === void 0 || !f) {
      const h = /* @__PURE__ */ new Error(`Incorrect usage of "cherry-pick". Current branch (${d.records.currBranch})has no commits`);
      throw h.hash = {
        text: `cherryPick ${r} ${t}`,
        token: `cherryPick ${r} ${t}`,
        expected: ["cherry-pick abc"]
      }, h;
    }
    const g = {
      id: d.records.seq + "-" + j(),
      message: `cherry-picked ${a?.message} into ${d.records.currBranch}`,
      seq: d.records.seq++,
      parents: d.records.head == null ? [] : [d.records.head.id, a.id],
      branch: d.records.currBranch,
      type: m.CHERRY_PICK,
      tags: s ? s.filter(Boolean) : [`cherry-pick:${a.id}${a.type === m.MERGE ? `|parent:${o}` : ""}`]
    };
    d.records.head = g, d.records.commits.set(g.id, g), d.records.branches.set(d.records.currBranch, g.id), w.debug(d.records.branches), w.debug("in cherryPick");
  }
}, "cherryPick"), te = /* @__PURE__ */ l(function(e) {
  if (e = B.sanitizeText(e, S()), d.records.branches.has(e)) {
    d.records.currBranch = e;
    const r = d.records.branches.get(d.records.currBranch);
    r === void 0 || !r ? d.records.head = null : d.records.head = d.records.commits.get(r) ?? null;
  } else {
    const r = /* @__PURE__ */ new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);
    throw r.hash = {
      text: `checkout ${e}`,
      token: `checkout ${e}`,
      expected: [`branch ${e}`]
    }, r;
  }
}, "checkout");
function V(e, r, t) {
  const s = e.indexOf(r);
  s === -1 ? e.push(t) : e.splice(s, 1, t);
}
l(V, "upsert");
function Q(e) {
  const r = e.reduce((o, c) => o.seq > c.seq ? o : c, e[0]);
  let t = "";
  e.forEach(function(o) {
    o === r ? t += "	*" : t += "	|";
  });
  const s = [
    t,
    r.id,
    r.seq
  ];
  for (const o in d.records.branches) d.records.branches.get(o) === r.id && s.push(o);
  if (w.debug(s.join(" ")), r.parents && r.parents.length == 2 && r.parents[0] && r.parents[1]) {
    const o = d.records.commits.get(r.parents[0]);
    V(e, r, o), r.parents[1] && e.push(d.records.commits.get(r.parents[1]));
  } else {
    if (r.parents.length == 0) return;
    if (r.parents[0]) {
      const o = d.records.commits.get(r.parents[0]);
      V(e, r, o);
    }
  }
  e = re(e, (o) => o.id), Q(e);
}
l(Q, "prettyPrintCommitHistory");
var _e = /* @__PURE__ */ l(function() {
  w.debug(d.records.commits);
  const e = ae()[0];
  Q([e]);
}, "prettyPrint"), Ge = /* @__PURE__ */ l(function() {
  d.reset(), me();
}, "clear"), He = /* @__PURE__ */ l(function() {
  return [...d.records.branchConfig.values()].map((e, r) => e.order !== null && e.order !== void 0 ? e : {
    ...e,
    order: parseFloat(`0.${r}`)
  }).sort((e, r) => (e.order ?? 0) - (r.order ?? 0)).map(({ name: e }) => ({ name: e }));
}, "getBranchesAsObjArray"), Se = /* @__PURE__ */ l(function() {
  return d.records.branches;
}, "getBranches"), Ae = /* @__PURE__ */ l(function() {
  return d.records.commits;
}, "getCommits"), ae = /* @__PURE__ */ l(function() {
  const e = [...d.records.commits.values()];
  return e.forEach(function(r) {
    w.debug(r.id);
  }), e.sort((r, t) => r.seq - t.seq), e;
}, "getCommitsArray"), ne = {
  commitType: m,
  getConfig: S,
  setDirection: Be,
  setOptions: Te,
  getOptions: Le,
  commit: Me,
  branch: Re,
  merge: Ie,
  cherryPick: Oe,
  checkout: te,
  prettyPrint: _e,
  clear: Ge,
  getBranchesAsObjArray: He,
  getBranches: Se,
  getCommits: Ae,
  getCommitsArray: ae,
  getCurrentBranch: /* @__PURE__ */ l(function() {
    return d.records.currBranch;
  }, "getCurrentBranch"),
  getDirection: /* @__PURE__ */ l(function() {
    return d.records.direction;
  }, "getDirection"),
  getHead: /* @__PURE__ */ l(function() {
    return d.records.head;
  }, "getHead"),
  setAccTitle: ue,
  getAccTitle: we,
  getAccDescription: xe,
  setAccDescription: fe,
  setDiagramTitle: ye,
  getDiagramTitle: ge
}, We = /* @__PURE__ */ l((e, r) => {
  ke(e, r), e.dir && r.setDirection(e.dir);
  for (const t of e.statements) qe(t, r);
}, "populate"), qe = /* @__PURE__ */ l((e, r) => {
  const t = {
    Commit: /* @__PURE__ */ l((s) => r.commit(Ne(s)), "Commit"),
    Branch: /* @__PURE__ */ l((s) => r.branch(De(s)), "Branch"),
    Merge: /* @__PURE__ */ l((s) => r.merge(ze(s)), "Merge"),
    Checkout: /* @__PURE__ */ l((s) => r.checkout(Fe(s)), "Checkout"),
    CherryPicking: /* @__PURE__ */ l((s) => r.cherryPick(Pe(s)), "CherryPicking")
  }[e.$type];
  t ? t(e) : w.error(`Unknown statement type: ${e.$type}`);
}, "parseStatement"), Ne = /* @__PURE__ */ l((e) => ({
  id: e.id,
  msg: e.message ?? "",
  type: e.type !== void 0 ? m[e.type] : m.NORMAL,
  tags: e.tags ?? void 0
}), "parseCommit"), De = /* @__PURE__ */ l((e) => ({
  name: e.name,
  order: e.order ?? 0
}), "parseBranch"), ze = /* @__PURE__ */ l((e) => ({
  branch: e.branch,
  id: e.id ?? "",
  type: e.type !== void 0 ? m[e.type] : void 0,
  tags: e.tags ?? void 0
}), "parseMerge"), Fe = /* @__PURE__ */ l((e) => e.branch, "parseCheckout"), Pe = /* @__PURE__ */ l((e) => ({
  id: e.id,
  targetId: "",
  tags: e.tags?.length === 0 ? void 0 : e.tags,
  parent: e.parent
}), "parseCherryPicking"), Ye = { parse: /* @__PURE__ */ l(async (e) => {
  const r = await Ce("gitGraph", e);
  w.debug(r), We(r, ne);
}, "parse") }, O = 10, _ = 40, L = 4, R = 2, G = 8, U = /* @__PURE__ */ new Set([
  "redux",
  "redux-dark",
  "redux-color",
  "redux-dark-color"
]), X = 12, Z = /* @__PURE__ */ new Set(["redux-color", "redux-dark-color"]), je = /* @__PURE__ */ new Set([
  "dark",
  "redux-dark",
  "redux-dark-color",
  "neo-dark"
]), H = /* @__PURE__ */ l((e, r, t = !1) => t && e > 0 ? (e - 1) % (r - 1) + 1 : e % r, "calcColorIndex"), v = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), P = 30, q = /* @__PURE__ */ new Map(), Y = [], I = 0, y = "LR", Ue = /* @__PURE__ */ l(() => {
  v.clear(), E.clear(), q.clear(), I = 0, Y = [], y = "LR";
}, "clear"), se = /* @__PURE__ */ l((e) => {
  const r = document.createElementNS("http://www.w3.org/2000/svg", "text");
  return (typeof e == "string" ? e.split(/\\n|\n|<br\s*\/?>/gi) : e).forEach((t) => {
    const s = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
    s.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"), s.setAttribute("dy", "1em"), s.setAttribute("x", "0"), s.setAttribute("class", "row"), s.textContent = t.trim(), r.appendChild(s);
  }), r;
}, "drawText"), oe = /* @__PURE__ */ l((e) => {
  let r, t, s;
  return y === "BT" ? (t = /* @__PURE__ */ l((o, c) => o <= c, "comparisonFunc"), s = 1 / 0) : (t = /* @__PURE__ */ l((o, c) => o >= c, "comparisonFunc"), s = 0), e.forEach((o) => {
    const c = y === "TB" || y == "BT" ? E.get(o)?.y : E.get(o)?.x;
    c !== void 0 && t(c, s) && (r = o, s = c);
  }), r;
}, "findClosestParent"), Ke = /* @__PURE__ */ l((e) => {
  let r = "", t = 1 / 0;
  return e.forEach((s) => {
    const o = E.get(s).y;
    o <= t && (r = s, t = o);
  }), r || void 0;
}, "findClosestParentBT"), Ve = /* @__PURE__ */ l((e, r, t) => {
  let s = t, o = t;
  const c = [];
  e.forEach((a) => {
    const n = r.get(a);
    if (!n) throw new Error(`Commit not found for key ${a}`);
    n.parents.length ? (s = Je(n), o = Math.max(s, o)) : c.push(n), Qe(n, s);
  }), s = o, c.forEach((a) => {
    Ze(a, s, t);
  }), e.forEach((a) => {
    const n = r.get(a);
    if (n?.parents.length) {
      const $ = Ke(n.parents);
      s = E.get($).y - _, s <= o && (o = s);
      const f = v.get(n.branch).pos, g = s - O;
      E.set(n.id, {
        x: f,
        y: g
      });
    }
  });
}, "setParallelBTPos"), Xe = /* @__PURE__ */ l((e) => {
  const r = oe(e.parents.filter((s) => s !== null));
  if (!r) throw new Error(`Closest parent not found for commit ${e.id}`);
  const t = E.get(r)?.y;
  if (t === void 0) throw new Error(`Closest parent position not found for commit ${e.id}`);
  return t;
}, "findClosestParentPos"), Je = /* @__PURE__ */ l((e) => Xe(e) + _, "calculateCommitPosition"), Qe = /* @__PURE__ */ l((e, r) => {
  const t = v.get(e.branch);
  if (!t) throw new Error(`Branch not found for commit ${e.id}`);
  const s = t.pos, o = r + O;
  return E.set(e.id, {
    x: s,
    y: o
  }), {
    x: s,
    y: o
  };
}, "setCommitPosition"), Ze = /* @__PURE__ */ l((e, r, t) => {
  const s = v.get(e.branch);
  if (!s) throw new Error(`Branch not found for commit ${e.id}`);
  const o = r + t, c = s.pos;
  E.set(e.id, {
    x: c,
    y: o
  });
}, "setRootPosition"), er = /* @__PURE__ */ l((e, r, t, s, o, c) => {
  const { theme: a } = D(), n = U.has(a ?? ""), $ = Z.has(a ?? ""), f = je.has(a ?? "");
  if (c === m.HIGHLIGHT)
    e.append("rect").attr("x", t.x - 10 + (n ? 3 : 0)).attr("y", t.y - 10 + (n ? 3 : 0)).attr("width", n ? 14 : 20).attr("height", n ? 14 : 20).attr("class", `commit ${r.id} commit-highlight${H(o, G, $)} ${s}-outer`), e.append("rect").attr("x", t.x - 6 + (n ? 2 : 0)).attr("y", t.y - 6 + (n ? 2 : 0)).attr("width", n ? 8 : 12).attr("height", n ? 8 : 12).attr("class", `commit ${r.id} commit${H(o, G, $)} ${s}-inner`);
  else if (c === m.CHERRY_PICK)
    e.append("circle").attr("cx", t.x).attr("cy", t.y).attr("r", n ? 7 : 10).attr("class", `commit ${r.id} ${s}`), e.append("circle").attr("cx", t.x - 3).attr("cy", t.y + 2).attr("r", n ? 2.5 : 2.75).attr("fill", f ? "#000000" : "#fff").attr("class", `commit ${r.id} ${s}`), e.append("circle").attr("cx", t.x + 3).attr("cy", t.y + 2).attr("r", n ? 2.5 : 2.75).attr("fill", f ? "#000000" : "#fff").attr("class", `commit ${r.id} ${s}`), e.append("line").attr("x1", t.x + 3).attr("y1", t.y + 1).attr("x2", t.x).attr("y2", t.y - 5).attr("stroke", f ? "#000000" : "#fff").attr("class", `commit ${r.id} ${s}`), e.append("line").attr("x1", t.x - 3).attr("y1", t.y + 1).attr("x2", t.x).attr("y2", t.y - 5).attr("stroke", f ? "#000000" : "#fff").attr("class", `commit ${r.id} ${s}`);
  else {
    const g = e.append("circle");
    if (g.attr("cx", t.x), g.attr("cy", t.y), g.attr("r", n ? 7 : 10), g.attr("class", `commit ${r.id} commit${H(o, G, $)}`), c === m.MERGE) {
      const h = e.append("circle");
      h.attr("cx", t.x), h.attr("cy", t.y), h.attr("r", n ? 5 : 6), h.attr("class", `commit ${s} ${r.id} commit${H(o, G, $)}`);
    }
    if (c === m.REVERSE) {
      const h = e.append("path"), i = n ? 4 : 5;
      h.attr("d", `M ${t.x - i},${t.y - i}L${t.x + i},${t.y + i}M${t.x - i},${t.y + i}L${t.x + i},${t.y - i}`).attr("class", `commit ${s} ${r.id} commit${H(o, G, $)}`);
    }
  }
}, "drawCommitBullet"), rr = /* @__PURE__ */ l((e, r, t, s, o) => {
  if (r.type !== m.CHERRY_PICK && (r.customId && r.type === m.MERGE || r.type !== m.MERGE) && o.showCommitLabel) {
    const c = e.append("g"), a = c.insert("rect").attr("class", "commit-label-bkg"), n = c.append("text").attr("x", s).attr("y", t.y + 25).attr("class", "commit-label").text(r.id), $ = n.node()?.getBBox();
    if ($ && (a.attr("x", t.posWithOffset - $.width / 2 - R).attr("y", t.y + 13.5).attr("width", $.width + 2 * R).attr("height", $.height + 2 * R), y === "TB" || y === "BT" ? (a.attr("x", t.x - ($.width + 4 * L + 5)).attr("y", t.y - 12), n.attr("x", t.x - ($.width + 4 * L)).attr("y", t.y + $.height - 12)) : n.attr("x", t.posWithOffset - $.width / 2), o.rotateCommitLabel))
      if (y === "TB" || y === "BT")
        n.attr("transform", "rotate(-45, " + t.x + ", " + t.y + ")"), a.attr("transform", "rotate(-45, " + t.x + ", " + t.y + ")");
      else {
        const f = -7.5 - ($.width + 10) / 25 * 9.5, g = 10 + $.width / 25 * 8.5;
        c.attr("transform", "translate(" + f + ", " + g + ") rotate(-45, " + s + ", " + t.y + ")");
      }
  }
}, "drawCommitLabel"), tr = /* @__PURE__ */ l((e, r, t, s) => {
  if (r.tags.length > 0) {
    let o = 0, c = 0, a = 0;
    const n = [];
    for (const $ of r.tags.reverse()) {
      const f = e.insert("polygon"), g = e.append("circle"), h = e.append("text").attr("y", t.y - 16 - o).attr("class", "tag-label").text($), i = h.node()?.getBBox();
      if (!i) throw new Error("Tag bbox not found");
      c = Math.max(c, i.width), a = Math.max(a, i.height), h.attr("x", t.posWithOffset - i.width / 2), n.push({
        tag: h,
        hole: g,
        rect: f,
        yOffset: o
      }), o += 20;
    }
    for (const { tag: $, hole: f, rect: g, yOffset: h } of n) {
      const i = a / 2, x = t.y - 19.2 - h;
      if (g.attr("class", "tag-label-bkg").attr("points", `
      ${s - c / 2 - L / 2},${x + R}  
      ${s - c / 2 - L / 2},${x - R}
      ${t.posWithOffset - c / 2 - L},${x - i - R}
      ${t.posWithOffset + c / 2 + L},${x - i - R}
      ${t.posWithOffset + c / 2 + L},${x + i + R}
      ${t.posWithOffset - c / 2 - L},${x + i + R}`), f.attr("cy", x).attr("cx", s - c / 2 + L / 2).attr("r", 1.5).attr("class", "tag-hole"), y === "TB" || y === "BT") {
        const u = s + h;
        g.attr("class", "tag-label-bkg").attr("points", `
        ${t.x},${u + 2}
        ${t.x},${u - 2}
        ${t.x + O},${u - i - 2}
        ${t.x + O + c + 4},${u - i - 2}
        ${t.x + O + c + 4},${u + i + 2}
        ${t.x + O},${u + i + 2}`).attr("transform", "translate(12,12) rotate(45, " + t.x + "," + s + ")"), f.attr("cx", t.x + L / 2).attr("cy", u).attr("transform", "translate(12,12) rotate(45, " + t.x + "," + s + ")"), $.attr("x", t.x + 5).attr("y", u + 3).attr("transform", "translate(14,14) rotate(45, " + t.x + "," + s + ")");
      }
    }
  }
}, "drawCommitTags"), ar = /* @__PURE__ */ l((e) => {
  switch (e.customType ?? e.type) {
    case m.NORMAL:
      return "commit-normal";
    case m.REVERSE:
      return "commit-reverse";
    case m.HIGHLIGHT:
      return "commit-highlight";
    case m.MERGE:
      return "commit-merge";
    case m.CHERRY_PICK:
      return "commit-cherry-pick";
    default:
      return "commit-normal";
  }
}, "getCommitClassType"), nr = /* @__PURE__ */ l((e, r, t, s) => {
  const o = {
    x: 0,
    y: 0
  };
  if (e.parents.length > 0) {
    const c = oe(e.parents);
    if (c) {
      const a = s.get(c) ?? o;
      return r === "TB" ? a.y + _ : r === "BT" ? (s.get(e.id) ?? o).y - _ : a.x + _;
    }
  } else return r === "TB" ? P : r === "BT" ? (s.get(e.id) ?? o).y - _ : 0;
  return 0;
}, "calculatePosition"), sr = /* @__PURE__ */ l((e, r, t) => {
  const s = y === "BT" && t ? r : r + O, o = v.get(e.branch)?.pos, c = y === "TB" || y === "BT" ? v.get(e.branch)?.pos : s;
  if (c === void 0 || o === void 0) throw new Error(`Position were undefined for commit ${e.id}`);
  const a = U.has(D().theme ?? "");
  return {
    x: c,
    y: y === "TB" || y === "BT" ? s : o + (a ? X / 2 + 1 : -2),
    posWithOffset: s
  };
}, "getCommitPosition"), ee = /* @__PURE__ */ l((e, r, t, s) => {
  const o = e.append("g").attr("class", "commit-bullets"), c = e.append("g").attr("class", "commit-labels");
  let a = y === "TB" || y === "BT" ? P : 0;
  const n = [...r.keys()], $ = s.parallelCommits ?? !1, f = /* @__PURE__ */ l((h, i) => {
    const x = r.get(h)?.seq, u = r.get(i)?.seq;
    return x !== void 0 && u !== void 0 ? x - u : 0;
  }, "sortKeys");
  let g = n.sort(f);
  y === "BT" && ($ && Ve(g, r, a), g = g.reverse()), g.forEach((h) => {
    const i = r.get(h);
    if (!i) throw new Error(`Commit not found for key ${h}`);
    $ && (a = nr(i, y, a, E));
    const x = sr(i, a, $);
    if (t) {
      const u = ar(i), p = i.customType ?? i.type;
      er(o, i, x, u, v.get(i.branch)?.index ?? 0, p), rr(c, i, x, a, s), tr(c, i, x, a);
    }
    y === "TB" || y === "BT" ? E.set(i.id, {
      x: x.x,
      y: x.posWithOffset
    }) : E.set(i.id, {
      x: x.posWithOffset,
      y: x.y
    }), a = y === "BT" && $ ? a + _ : a + _ + O, a > I && (I = a);
  });
}, "drawCommits"), or = /* @__PURE__ */ l((e, r, t, s, o) => {
  const c = (y === "TB" || y === "BT" ? t.x < s.x : t.y < s.y) ? r.branch : e.branch, a = /* @__PURE__ */ l(($) => $.branch === c, "isOnBranchToGetCurve"), n = /* @__PURE__ */ l(($) => $.seq > e.seq && $.seq < r.seq, "isBetweenCommits");
  return [...o.values()].some(($) => n($) && a($));
}, "shouldRerouteArrow"), N = /* @__PURE__ */ l((e, r, t = 0) => {
  const s = e + Math.abs(e - r) / 2;
  return t > 5 ? s : Y.every((o) => Math.abs(o - s) >= 10) ? (Y.push(s), s) : N(e, r - Math.abs(e - r) / 5, t + 1);
}, "findLane"), cr = /* @__PURE__ */ l((e, r, t, s) => {
  const { theme: o } = D(), c = Z.has(o ?? ""), a = E.get(r.id), n = E.get(t.id);
  if (a === void 0 || n === void 0) throw new Error(`Commit positions not found for commits ${r.id} and ${t.id}`);
  const $ = or(r, t, a, n, s);
  let f = "", g = "", h = 0, i = 0, x = v.get(t.branch)?.index;
  t.type === m.MERGE && r.id !== t.parents[0] && (x = v.get(r.branch)?.index);
  let u;
  if ($) {
    f = "A 10 10, 0, 0, 0,", g = "A 10 10, 0, 0, 1,", h = 10, i = 10;
    const p = a.y < n.y ? N(a.y, n.y) : N(n.y, a.y), b = a.x < n.x ? N(a.x, n.x) : N(n.x, a.x);
    y === "TB" ? a.x < n.x ? u = `M ${a.x} ${a.y} L ${b - h} ${a.y} ${g} ${b} ${a.y + i} L ${b} ${n.y - h} ${f} ${b + i} ${n.y} L ${n.x} ${n.y}` : (x = v.get(r.branch)?.index, u = `M ${a.x} ${a.y} L ${b + h} ${a.y} ${f} ${b} ${a.y + i} L ${b} ${n.y - h} ${g} ${b - i} ${n.y} L ${n.x} ${n.y}`) : y === "BT" ? a.x < n.x ? u = `M ${a.x} ${a.y} L ${b - h} ${a.y} ${f} ${b} ${a.y - i} L ${b} ${n.y + h} ${g} ${b + i} ${n.y} L ${n.x} ${n.y}` : (x = v.get(r.branch)?.index, u = `M ${a.x} ${a.y} L ${b + h} ${a.y} ${g} ${b} ${a.y - i} L ${b} ${n.y + h} ${f} ${b - i} ${n.y} L ${n.x} ${n.y}`) : a.y < n.y ? u = `M ${a.x} ${a.y} L ${a.x} ${p - h} ${f} ${a.x + i} ${p} L ${n.x - h} ${p} ${g} ${n.x} ${p + i} L ${n.x} ${n.y}` : (x = v.get(r.branch)?.index, u = `M ${a.x} ${a.y} L ${a.x} ${p + h} ${g} ${a.x + i} ${p} L ${n.x - h} ${p} ${f} ${n.x} ${p - i} L ${n.x} ${n.y}`);
  } else
    f = "A 20 20, 0, 0, 0,", g = "A 20 20, 0, 0, 1,", h = 20, i = 20, y === "TB" ? (a.x < n.x && (t.type === m.MERGE && r.id !== t.parents[0] ? u = `M ${a.x} ${a.y} L ${a.x} ${n.y - h} ${f} ${a.x + i} ${n.y} L ${n.x} ${n.y}` : u = `M ${a.x} ${a.y} L ${n.x - h} ${a.y} ${g} ${n.x} ${a.y + i} L ${n.x} ${n.y}`), a.x > n.x && (f = "A 20 20, 0, 0, 0,", g = "A 20 20, 0, 0, 1,", h = 20, i = 20, t.type === m.MERGE && r.id !== t.parents[0] ? u = `M ${a.x} ${a.y} L ${a.x} ${n.y - h} ${g} ${a.x - i} ${n.y} L ${n.x} ${n.y}` : u = `M ${a.x} ${a.y} L ${n.x + h} ${a.y} ${f} ${n.x} ${a.y + i} L ${n.x} ${n.y}`), a.x === n.x && (u = `M ${a.x} ${a.y} L ${n.x} ${n.y}`)) : y === "BT" ? (a.x < n.x && (t.type === m.MERGE && r.id !== t.parents[0] ? u = `M ${a.x} ${a.y} L ${a.x} ${n.y + h} ${g} ${a.x + i} ${n.y} L ${n.x} ${n.y}` : u = `M ${a.x} ${a.y} L ${n.x - h} ${a.y} ${f} ${n.x} ${a.y - i} L ${n.x} ${n.y}`), a.x > n.x && (f = "A 20 20, 0, 0, 0,", g = "A 20 20, 0, 0, 1,", h = 20, i = 20, t.type === m.MERGE && r.id !== t.parents[0] ? u = `M ${a.x} ${a.y} L ${a.x} ${n.y + h} ${f} ${a.x - i} ${n.y} L ${n.x} ${n.y}` : u = `M ${a.x} ${a.y} L ${n.x + h} ${a.y} ${g} ${n.x} ${a.y - i} L ${n.x} ${n.y}`), a.x === n.x && (u = `M ${a.x} ${a.y} L ${n.x} ${n.y}`)) : (a.y < n.y && (t.type === m.MERGE && r.id !== t.parents[0] ? u = `M ${a.x} ${a.y} L ${n.x - h} ${a.y} ${g} ${n.x} ${a.y + i} L ${n.x} ${n.y}` : u = `M ${a.x} ${a.y} L ${a.x} ${n.y - h} ${f} ${a.x + i} ${n.y} L ${n.x} ${n.y}`), a.y > n.y && (t.type === m.MERGE && r.id !== t.parents[0] ? u = `M ${a.x} ${a.y} L ${n.x - h} ${a.y} ${f} ${n.x} ${a.y - i} L ${n.x} ${n.y}` : u = `M ${a.x} ${a.y} L ${a.x} ${n.y + h} ${g} ${a.x + i} ${n.y} L ${n.x} ${n.y}`), a.y === n.y && (u = `M ${a.x} ${a.y} L ${n.x} ${n.y}`));
  if (u === void 0) throw new Error("Line definition not found");
  e.append("path").attr("d", u).attr("class", "arrow arrow" + H(x, G, c));
}, "drawArrow"), ir = /* @__PURE__ */ l((e, r) => {
  const t = e.append("g").attr("class", "commit-arrows");
  [...r.keys()].forEach((s) => {
    const o = r.get(s);
    o.parents && o.parents.length > 0 && o.parents.forEach((c) => {
      cr(t, r.get(c), o, r);
    });
  });
}, "drawArrows"), dr = /* @__PURE__ */ l((e, r, t, s) => {
  const { look: o, theme: c, themeVariables: a } = D(), { dropShadow: n, THEME_COLOR_LIMIT: $ } = a, f = U.has(c ?? ""), g = Z.has(c ?? ""), h = e.append("g");
  r.forEach((i, x) => {
    const u = H(x, f ? $ : G, g), p = v.get(i.name)?.pos;
    if (p === void 0) throw new Error(`Position not found for branch ${i.name}`);
    const b = y === "TB" || y === "BT" ? p : f ? p + X / 2 + 1 : p - 2, k = h.append("line");
    k.attr("x1", 0), k.attr("y1", b), k.attr("x2", I), k.attr("y2", b), k.attr("class", "branch branch" + u), y === "TB" ? (k.attr("y1", P), k.attr("x1", p), k.attr("y2", I), k.attr("x2", p)) : y === "BT" && (k.attr("y1", I), k.attr("x1", p), k.attr("y2", P), k.attr("x2", p)), Y.push(b);
    const K = i.name, W = se(K), T = h.insert("rect"), M = h.insert("g").attr("class", "branchLabel").insert("g").attr("class", "label branch-label" + u);
    M.node().appendChild(W);
    const C = W.getBBox(), z = f ? 0 : 4, F = f ? 16 : 0, A = f ? X : 0;
    o === "neo" && T.attr("data-look", "neo"), T.attr("class", "branchLabelBkg label" + u).attr("style", o === "neo" ? `filter:${f ? `url(#${s}-drop-shadow)` : n}` : "").attr("rx", z).attr("ry", z).attr("x", -C.width - 4 - (t.rotateCommitLabel === !0 ? 30 : 0)).attr("y", -C.height / 2 + 10).attr("width", C.width + 18 + F).attr("height", C.height + 4 + A), M.attr("transform", "translate(" + (-C.width - 14 - (t.rotateCommitLabel === !0 ? 30 : 0) + F / 2) + ", " + (b - C.height / 2 - 2) + ")"), y === "TB" ? (T.attr("x", p - C.width / 2 - 10).attr("y", 0), M.attr("transform", "translate(" + (p - C.width / 2 - 5) + ", 0)"), f && (T.attr("transform", `translate(${-F / 2 - 3}, ${-A - 10})`), M.attr("transform", "translate(" + (p - C.width / 2 - 5) + ", " + (-A * 2 + 7) + ")"))) : y === "BT" ? (T.attr("x", p - C.width / 2 - 10).attr("y", I), M.attr("transform", "translate(" + (p - C.width / 2 - 5) + ", " + I + ")"), f && (T.attr("transform", `translate(${-F / 2 - 3}, ${A + 10})`), M.attr("transform", "translate(" + (p - C.width / 2 - 5) + ", " + (I + A * 2 + 4) + ")"))) : T.attr("transform", "translate(-19, " + (b - 12 - A / 2) + ")");
  });
}, "drawBranches"), lr = /* @__PURE__ */ l(function(e, r, t, s, o) {
  return v.set(e, {
    pos: r,
    index: t
  }), r += 50 + (o ? 40 : 0) + (y === "TB" || y === "BT" ? s.width / 2 : 0), r;
}, "setBranchPosition"), hr = { draw: /* @__PURE__ */ l(function(e, r, t, s) {
  Ue(), w.debug("in gitgraph renderer", e + `
`, "id:", r, t);
  const o = s.db;
  if (!o.getConfig) {
    w.error("getConfig method is not available on db");
    return;
  }
  const c = o.getConfig(), a = c.rotateCommitLabel ?? !1;
  q = o.getCommits();
  const n = o.getBranchesAsObjArray();
  y = o.getDirection();
  const $ = de(`[id="${r}"]`), { look: f, theme: g, themeVariables: h } = D(), { useGradient: i, gradientStart: x, gradientStop: u, filterColor: p } = h;
  if (i) {
    const k = $.append("defs").append("linearGradient").attr("id", r + "-gradient").attr("gradientUnits", "objectBoundingBox").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
    k.append("stop").attr("offset", "0%").attr("stop-color", x).attr("stop-opacity", 1), k.append("stop").attr("offset", "100%").attr("stop-color", u).attr("stop-opacity", 1);
  }
  f === "neo" && U.has(g ?? "") && $.append("defs").append("filter").attr("id", r + "-drop-shadow").attr("height", "130%").attr("width", "130%").append("feDropShadow").attr("dx", "4").attr("dy", "4").attr("stdDeviation", 0).attr("flood-opacity", "0.06").attr("flood-color", p);
  let b = 0;
  n.forEach((k, K) => {
    const W = se(k.name), T = $.append("g"), M = T.insert("g").attr("class", "branchLabel"), C = M.insert("g").attr("class", "label branch-label");
    C.node()?.appendChild(W);
    const z = W.getBBox();
    b = lr(k.name, b, K, z, a), C.remove(), M.remove(), T.remove();
  }), ee($, q, !1, c), c.showBranches && dr($, n, c, r), ir($, q), ee($, q, !0, c), le.insertTitle($, "gitTitleText", c.titleTopMargin ?? 0, o.getDiagramTitle()), be(void 0, $, c.diagramPadding, c.useMaxWidth);
}, "draw") }, ce = 8, ie = /* @__PURE__ */ new Set([
  "redux",
  "redux-dark",
  "redux-color",
  "redux-dark-color"
]), $r = /* @__PURE__ */ new Set(["redux-color", "redux-dark-color"]), fr = /* @__PURE__ */ new Set(["neo", "neo-dark"]), gr = /* @__PURE__ */ new Set([
  "dark",
  "redux-dark",
  "redux-dark-color",
  "neo-dark"
]), ur = /* @__PURE__ */ new Set([
  "redux",
  "redux-dark",
  "redux-color",
  "redux-dark-color",
  "neo",
  "neo-dark"
]), yr = /* @__PURE__ */ l((e) => {
  const { svgId: r } = e;
  let t = "";
  if (e.useGradient && r) for (let s = 0; s < e.THEME_COLOR_LIMIT; s++) t += `
      .label${s}  { fill: ${e.mainBkg}; stroke: url(${r}-gradient); stroke-width: ${e.strokeWidth};}
             `;
  return t;
}, "genGitGraphGradient"), xr = /* @__PURE__ */ l((e) => {
  const { theme: r, themeVariables: t } = J(), { borderColorArray: s } = t, o = ie.has(r);
  if (fr.has(r)) {
    let c = "";
    for (let a = 0; a < e.THEME_COLOR_LIMIT; a++) if (a === 0) c += `
        .branch-label${a} { fill: ${e.nodeBorder};}
        .commit${a} { stroke: ${e.nodeBorder};   }
        .commit-highlight${a} { stroke: ${e.nodeBorder}; fill: ${e.nodeBorder}; }
        .arrow${a} { stroke: ${e.nodeBorder}; }
        .commit-bullets { fill: ${e.nodeBorder}; }
        .commit-cherry-pick${a} { stroke: ${e.nodeBorder}; }
        ${yr(e)}`;
    else {
      const n = a % ce;
      c += `
        .branch-label${a} { fill: ${e["gitBranchLabel" + n]}; }
        .commit${a} { stroke: ${e["git" + n]}; fill: ${e["git" + n]}; }
        .commit-highlight${a} { stroke: ${e["gitInv" + n]}; fill: ${e["gitInv" + n]}; }
        .arrow${a} { stroke: ${e["git" + n]}; }
        `;
    }
    return c;
  } else if ($r.has(r)) {
    let c = "";
    for (let a = 0; a < e.THEME_COLOR_LIMIT; a++) if (a === 0) c += `
        .branch-label${a} { fill: ${e.nodeBorder}; ${o ? `font-weight:${e.noteFontWeight}` : ""} }
        .commit${a} { stroke: ${e.nodeBorder}; }
        .commit-highlight${a} { stroke: ${e.nodeBorder}; fill: ${e.mainBkg}; }
        .label${a}  { fill: ${e.mainBkg}; stroke: ${e.nodeBorder}; stroke-width: ${e.strokeWidth}; ${o ? `font-weight:${e.noteFontWeight}` : ""} }
        .arrow${a} { stroke: ${e.nodeBorder}; }
        .commit-bullets { fill: ${e.nodeBorder}; }
        `;
    else {
      const n = a % s.length;
      c += `
        .branch-label${a} { fill: ${e.nodeBorder}; ${o ? `font-weight:${e.noteFontWeight}` : ""} }
        .commit${a} { stroke: ${s[n]}; fill: ${s[n]}; }
        .commit-highlight${a} { stroke: ${s[n]}; fill: ${s[n]}; }
        .label${a}  { fill: ${gr.has(r) ? e.mainBkg : s[n]}; stroke: ${s[n]};  stroke-width: ${e.strokeWidth}; }
        .arrow${a} { stroke: ${s[n]}; }
        `;
    }
    return c;
  } else {
    let c = "";
    for (let a = 0; a < e.THEME_COLOR_LIMIT; a++) c += `
        .branch-label${a} { fill: ${e.nodeBorder}; ${o ? `font-weight:${e.noteFontWeight}` : ""} }
        .commit${a} { stroke: ${e.nodeBorder};   }
        .commit-highlight${a} { stroke: ${e.nodeBorder}; fill: ${e.nodeBorder}; }
        .label${a}  { fill: ${e.mainBkg}; stroke: ${e.nodeBorder}; stroke-width: ${e.strokeWidth}; ${o ? `font-weight:${e.noteFontWeight}` : ""}}
        .arrow${a} { stroke: ${e.nodeBorder}; }
        .commit-bullets { fill: ${e.nodeBorder}; }
        .commit-cherry-pick${a} { stroke: ${e.nodeBorder}; }
        `;
    return c;
  }
}, "genColor"), mr = /* @__PURE__ */ l((e) => `${Array.from({ length: e.THEME_COLOR_LIMIT }, (r, t) => t).map((r) => {
  const t = r % ce;
  return `
        .branch-label${r} { fill: ${e["gitBranchLabel" + t]}; }
        .commit${r} { stroke: ${e["git" + t]}; fill: ${e["git" + t]}; }
        .commit-highlight${r} { stroke: ${e["gitInv" + t]}; fill: ${e["gitInv" + t]}; }
        .label${r}  { fill: ${e["git" + t]}; }
        .arrow${r} { stroke: ${e["git" + t]}; }
        `;
}).join(`
`)}`, "normalTheme"), Br = {
  parser: Ye,
  db: ne,
  renderer: hr,
  styles: /* @__PURE__ */ l((e) => {
    const { theme: r } = J(), t = ur.has(r);
    return `
  .commit-id,
  .commit-msg,
  .branch-label {
    fill: lightgrey;
    color: lightgrey;
    font-family: 'trebuchet ms', verdana, arial, sans-serif;
    font-family: var(--mermaid-font-family);
  }
  
  ${t ? xr(e) : mr(e)}

  .branch {
    stroke-width: ${e.strokeWidth};
    stroke: ${e.commitLineColor ?? e.lineColor};
    stroke-dasharray:  ${t ? "4 2" : "2"};
  }
  .commit-label { font-size: ${e.commitLabelFontSize}; fill: ${t ? e.nodeBorder : e.commitLabelColor}; ${t ? `font-weight:${e.noteFontWeight};` : ""}}
  .commit-label-bkg { font-size: ${e.commitLabelFontSize}; fill: ${t ? "transparent" : e.commitLabelBackground}; opacity: ${t ? "" : 0.5};  }
  .tag-label { font-size: ${e.tagLabelFontSize}; fill: ${e.tagLabelColor};}
  .tag-label-bkg { fill: ${t ? e.mainBkg : e.tagLabelBackground}; stroke: ${t ? e.nodeBorder : e.tagLabelBorder}; ${t ? `filter:${e.dropShadow}` : ""}  }
  .tag-hole { fill: ${e.textColor}; }

  .commit-merge {
    stroke: ${t ? e.mainBkg : e.primaryColor};
    fill: ${t ? e.mainBkg : e.primaryColor};
  }
  .commit-reverse {
    stroke: ${t ? e.mainBkg : e.primaryColor};
    fill: ${t ? e.mainBkg : e.primaryColor};
    stroke-width: ${t ? e.strokeWidth : 3};
  }
  .commit-highlight-outer {
  }
  .commit-highlight-inner {
    stroke: ${t ? e.mainBkg : e.primaryColor};
    fill: ${t ? e.mainBkg : e.primaryColor};
  }

  .arrow {
    /* Intentional: neo themes keep the bold 8px arrow (like classic themes); only redux-geometry themes use the thinner options.strokeWidth. */
    stroke-width: ${ie.has(r) ? e.strokeWidth : 8};
    stroke-linecap: round;
    fill: none
  }
  .gitTitleText {
    text-anchor: middle;
    font-size: 18px;
    fill: ${e.textColor};
  }
`;
  }, "getStyles")
};
export {
  Br as diagram
};

//# sourceMappingURL=gitGraphDiagram-UUTBAWPF.js.map