import { u as ot } from "./vendor/recharts.js";
import { r as Wt } from "./chunk-5PVQY5BW.js";
import { n as w } from "./chunk-AGHRB4JF.js";
import { $ as Kt, B as Yt, C as Ht, Q as Xt, V as Zt, W as Qt, _ as Jt, a as $t, c as te, d as ee, et as ne, tt as se, v as ie, y as _t } from "./chunk-ICPOFSXX.js";
import { t as re } from "./chunk-426QAEUC.js";
import { t as oe } from "./rough.esm.js";
var Mt = (t, n) => ne(t, "a", -n), Tt = 1e-10;
function st(t, n) {
  const s = le(t), e = s.filter((c) => ae(c, t));
  let i = 0, r = 0;
  const a = [];
  if (e.length > 1) {
    const c = zt(e);
    for (let l = 0; l < e.length; ++l) {
      const u = e[l];
      u.angle = Math.atan2(u.x - c.x, u.y - c.y);
    }
    e.sort((l, u) => u.angle - l.angle);
    let f = e[e.length - 1];
    for (let l = 0; l < e.length; ++l) {
      const u = e[l];
      r += (f.x + u.x) * (u.y - f.y);
      const y = {
        x: (u.x + f.x) / 2,
        y: (u.y + f.y) / 2
      };
      let h = null;
      for (let b = 0; b < u.parentIndex.length; ++b) if (f.parentIndex.includes(u.parentIndex[b])) {
        const d = t[u.parentIndex[b]], S = Math.atan2(u.x - d.x, u.y - d.y), T = Math.atan2(f.x - d.x, f.y - d.y);
        let m = T - S;
        m < 0 && (m += 2 * Math.PI);
        const x = T - m / 2;
        let v = q(y, {
          x: d.x + d.radius * Math.sin(x),
          y: d.y + d.radius * Math.cos(x)
        });
        v > d.radius * 2 && (v = d.radius * 2), (h == null || h.width > v) && (h = {
          circle: d,
          width: v,
          p1: u,
          p2: f,
          large: v > d.radius,
          sweep: !0
        });
      }
      h != null && (a.push(h), i += ct(h.circle.radius, h.width), f = u);
    }
  } else {
    let c = t[0];
    for (let l = 1; l < t.length; ++l) t[l].radius < c.radius && (c = t[l]);
    let f = !1;
    for (let l = 0; l < t.length; ++l) if (q(t[l], c) > Math.abs(c.radius - t[l].radius)) {
      f = !0;
      break;
    }
    f ? i = r = 0 : (i = c.radius * c.radius * Math.PI, a.push({
      circle: c,
      p1: {
        x: c.x,
        y: c.y + c.radius
      },
      p2: {
        x: c.x - Tt,
        y: c.y + c.radius
      },
      width: c.radius * 2,
      large: !0,
      sweep: !0
    }));
  }
  return r /= 2, n && (n.area = i + r, n.arcArea = i, n.polygonArea = r, n.arcs = a, n.innerPoints = e, n.intersectionPoints = s), i + r;
}
function ae(t, n) {
  return n.every((s) => q(t, s) < s.radius + Tt);
}
function le(t) {
  const n = [];
  for (let s = 0; s < t.length; ++s) for (let e = s + 1; e < t.length; ++e) {
    const i = Et(t[s], t[e]);
    for (const r of i)
      r.parentIndex = [s, e], n.push(r);
  }
  return n;
}
function ct(t, n) {
  return t * t * Math.acos(1 - n / t) - (t - n) * Math.sqrt(n * (2 * t - n));
}
function q(t, n) {
  return Math.sqrt((t.x - n.x) * (t.x - n.x) + (t.y - n.y) * (t.y - n.y));
}
function xt(t, n, s) {
  if (s >= t + n) return 0;
  if (s <= Math.abs(t - n)) return Math.PI * Math.min(t, n) * Math.min(t, n);
  const e = t - (s * s - n * n + t * t) / (2 * s), i = n - (s * s - t * t + n * n) / (2 * s);
  return ct(t, e) + ct(n, i);
}
function Et(t, n) {
  const s = q(t, n), e = t.radius, i = n.radius;
  if (s >= e + i || s <= Math.abs(e - i)) return [];
  const r = (e * e - i * i + s * s) / (2 * s), a = Math.sqrt(e * e - r * r), c = t.x + r * (n.x - t.x) / s, f = t.y + r * (n.y - t.y) / s, l = -(n.y - t.y) * (a / s), u = -(n.x - t.x) * (a / s);
  return [{
    x: c + l,
    y: f - u
  }, {
    x: c - l,
    y: f + u
  }];
}
function zt(t) {
  const n = {
    x: 0,
    y: 0
  };
  for (const s of t)
    n.x += s.x, n.y += s.y;
  return n.x /= t.length, n.y /= t.length, n;
}
function ce(t, n, s, e) {
  e = e || {};
  const i = e.maxIterations || 100, r = e.tolerance || 1e-10, a = t(n), c = t(s);
  let f = s - n;
  if (a * c > 0) throw "Initial bisect points must have opposite signs";
  if (a === 0) return n;
  if (c === 0) return s;
  for (let l = 0; l < i; ++l) {
    f /= 2;
    const u = n + f, y = t(u);
    if (y * a >= 0 && (n = u), Math.abs(f) < r || y === 0) return u;
  }
  return n + f;
}
function ut(t) {
  const n = new Array(t);
  for (let s = 0; s < t; ++s) n[s] = 0;
  return n;
}
function St(t, n) {
  return ut(t).map(() => ut(n));
}
function $(t, n) {
  let s = 0;
  for (let e = 0; e < t.length; ++e) s += t[e] * n[e];
  return s;
}
function ft(t) {
  return Math.sqrt($(t, t));
}
function ht(t, n, s) {
  for (let e = 0; e < n.length; ++e) t[e] = n[e] * s;
}
function H(t, n, s, e, i) {
  for (let r = 0; r < t.length; ++r) t[r] = n * s[r] + e * i[r];
}
function At(t, n, s) {
  s = s || {};
  const e = s.maxIterations || n.length * 200, i = s.nonZeroDelta || 1.05, r = s.zeroDelta || 1e-3, a = s.minErrorDelta || 1e-6, c = s.minErrorDelta || 1e-5, f = s.rho !== void 0 ? s.rho : 1, l = s.chi !== void 0 ? s.chi : 2, u = s.psi !== void 0 ? s.psi : -0.5, y = s.sigma !== void 0 ? s.sigma : 0.5;
  let h;
  const b = n.length, d = new Array(b + 1);
  d[0] = n, d[0].fx = t(n), d[0].id = 0;
  for (let g = 0; g < b; ++g) {
    const p = n.slice();
    p[g] = p[g] ? p[g] * i : r, d[g + 1] = p, d[g + 1].fx = t(p), d[g + 1].id = g + 1;
  }
  function S(g) {
    for (let p = 0; p < g.length; p++) d[b][p] = g[p];
    d[b].fx = g.fx;
  }
  const T = (g, p) => g.fx - p.fx, m = n.slice(), x = n.slice(), v = n.slice(), k = n.slice();
  for (let g = 0; g < e; ++g) {
    if (d.sort(T), s.history) {
      const o = d.map((_) => {
        const I = _.slice();
        return I.fx = _.fx, I.id = _.id, I;
      });
      o.sort((_, I) => _.id - I.id), s.history.push({
        x: d[0].slice(),
        fx: d[0].fx,
        simplex: o
      });
    }
    h = 0;
    for (let o = 0; o < b; ++o) h = Math.max(h, Math.abs(d[0][o] - d[1][o]));
    if (Math.abs(d[0].fx - d[b].fx) < a && h < c) break;
    for (let o = 0; o < b; ++o) {
      m[o] = 0;
      for (let _ = 0; _ < b; ++_) m[o] += d[_][o];
      m[o] /= b;
    }
    const p = d[b];
    if (H(x, 1 + f, m, -f, p), x.fx = t(x), x.fx < d[0].fx)
      H(k, 1 + l, m, -l, p), k.fx = t(k), k.fx < x.fx ? S(k) : S(x);
    else if (x.fx >= d[b - 1].fx) {
      let o = !1;
      if (x.fx > p.fx ? (H(v, 1 + u, m, -u, p), v.fx = t(v), v.fx < p.fx ? S(v) : o = !0) : (H(v, 1 - u * f, m, u * f, p), v.fx = t(v), v.fx < x.fx ? S(v) : o = !0), o) {
        if (y >= 1) break;
        for (let _ = 1; _ < d.length; ++_)
          H(d[_], 1 - y, d[0], y, d[_]), d[_].fx = t(d[_]);
      }
    } else S(x);
  }
  return d.sort(T), {
    fx: d[0].fx,
    x: d[0]
  };
}
function ue(t, n, s, e, i, r, a) {
  const c = s.fx, f = $(s.fxprime, n);
  let l = c, u = c, y = f, h = 0;
  i = i || 1, r = r || 1e-6, a = a || 0.1;
  function b(d, S, T) {
    for (let m = 0; m < 16; ++m)
      if (i = (d + S) / 2, H(e.x, 1, s.x, i, n), l = e.fx = t(e.x, e.fxprime), y = $(e.fxprime, n), l > c + r * i * f || l >= T) S = i;
      else {
        if (Math.abs(y) <= -a * f) return i;
        y * (S - d) >= 0 && (S = d), d = i, T = l;
      }
    return 0;
  }
  for (let d = 0; d < 10; ++d) {
    if (H(e.x, 1, s.x, i, n), l = e.fx = t(e.x, e.fxprime), y = $(e.fxprime, n), l > c + r * i * f || d && l >= u) return b(h, i, u);
    if (Math.abs(y) <= -a * f) return i;
    if (y >= 0) return b(i, h, l);
    u = l, h = i, i *= 2;
  }
  return i;
}
function fe(t, n, s) {
  let e = {
    x: n.slice(),
    fx: 0,
    fxprime: n.slice()
  }, i = {
    x: n.slice(),
    fx: 0,
    fxprime: n.slice()
  };
  const r = n.slice();
  let a, c, f = 1, l;
  s = s || {}, l = s.maxIterations || n.length * 20, e.fx = t(e.x, e.fxprime), a = e.fxprime.slice(), ht(a, e.fxprime, -1);
  for (let u = 0; u < l; ++u) {
    if (f = ue(t, a, e, i, f), s.history && s.history.push({
      x: e.x.slice(),
      fx: e.fx,
      fxprime: e.fxprime.slice(),
      alpha: f
    }), !f) ht(a, e.fxprime, -1);
    else {
      H(r, 1, i.fxprime, -1, e.fxprime);
      const y = $(e.fxprime, e.fxprime), h = Math.max(0, $(r, i.fxprime) / y);
      H(a, h, a, -1, i.fxprime), c = e, e = i, i = c;
    }
    if (ft(e.fxprime) <= 1e-5) break;
  }
  return s.history && s.history.push({
    x: e.x.slice(),
    fx: e.fx,
    fxprime: e.fxprime.slice(),
    alpha: f
  }), e;
}
function Ct(t, n = {}) {
  n.maxIterations = n.maxIterations || 500;
  const s = n.initialLayout || ye, e = n.lossFunction || tt, i = he(t, n), r = s(i, n), a = Object.keys(r), c = [];
  for (const l of a)
    c.push(r[l].x), c.push(r[l].y);
  const f = At((l) => {
    const u = {};
    for (let y = 0; y < a.length; ++y) {
      const h = a[y];
      u[h] = {
        x: l[2 * y],
        y: l[2 * y + 1],
        radius: r[h].radius
      };
    }
    return e(u, i);
  }, c, n).x;
  for (let l = 0; l < a.length; ++l) {
    const u = a[l];
    r[u].x = f[2 * l], r[u].y = f[2 * l + 1];
  }
  return r;
}
var Dt = 1e-10;
function dt(t, n, s) {
  return Math.min(t, n) * Math.min(t, n) * Math.PI <= s + Dt ? Math.abs(t - n) : ce((e) => xt(t, n, e) - s, 0, t + n);
}
function he(t, n = {}) {
  const s = n.distinct, e = t.map((c) => Object.assign({}, c));
  function i(c) {
    return c.join(";");
  }
  if (s) {
    const c = /* @__PURE__ */ new Map();
    for (const f of e) for (let l = 0; l < f.sets.length; l++) {
      const u = String(f.sets[l]);
      c.set(u, f.size + (c.get(u) || 0));
      for (let y = l + 1; y < f.sets.length; y++) {
        const h = String(f.sets[y]), b = `${u};${h}`, d = `${h};${u}`;
        c.set(b, f.size + (c.get(b) || 0)), c.set(d, f.size + (c.get(d) || 0));
      }
    }
    for (const f of e) f.sets.length < 3 && (f.size = c.get(i(f.sets)));
  }
  const r = [], a = /* @__PURE__ */ new Set();
  for (const c of e) if (c.sets.length === 1) r.push(c.sets[0]);
  else if (c.sets.length === 2) {
    const f = c.sets[0], l = c.sets[1];
    a.add(i(c.sets)), a.add(i([l, f]));
  }
  r.sort((c, f) => c === f ? 0 : c < f ? -1 : 1);
  for (let c = 0; c < r.length; ++c) {
    const f = r[c];
    for (let l = c + 1; l < r.length; ++l) {
      const u = r[l];
      a.has(i([f, u])) || e.push({
        sets: [f, u],
        size: 0
      });
    }
  }
  return e;
}
function de(t, n, s) {
  const e = St(n.length, n.length), i = St(n.length, n.length);
  return t.filter((r) => r.sets.length === 2).forEach((r) => {
    const a = s[r.sets[0]], c = s[r.sets[1]], f = dt(Math.sqrt(n[a].size / Math.PI), Math.sqrt(n[c].size / Math.PI), r.size);
    e[a][c] = e[c][a] = f;
    let l = 0;
    r.size + 1e-10 >= Math.min(n[a].size, n[c].size) ? l = 1 : r.size <= 1e-10 && (l = -1), i[a][c] = i[c][a] = l;
  }), {
    distances: e,
    constraints: i
  };
}
function ge(t, n, s, e) {
  for (let r = 0; r < n.length; ++r) n[r] = 0;
  let i = 0;
  for (let r = 0; r < s.length; ++r) {
    const a = t[2 * r], c = t[2 * r + 1];
    for (let f = r + 1; f < s.length; ++f) {
      const l = t[2 * f], u = t[2 * f + 1], y = s[r][f], h = e[r][f], b = (l - a) * (l - a) + (u - c) * (u - c), d = Math.sqrt(b), S = b - y * y;
      h > 0 && d <= y || h < 0 && d >= y || (i += 2 * S * S, n[2 * r] += 4 * S * (a - l), n[2 * r + 1] += 4 * S * (c - u), n[2 * f] += 4 * S * (l - a), n[2 * f + 1] += 4 * S * (u - c));
    }
  }
  return i;
}
function ye(t, n = {}) {
  let s = pe(t, n);
  const e = n.lossFunction || tt;
  if (t.length >= 8) {
    const i = xe(t, n), r = e(i, t), a = e(s, t);
    r + 1e-8 < a && (s = i);
  }
  return s;
}
function xe(t, n = {}) {
  const s = n.restarts || 10, e = [], i = {};
  for (const h of t) h.sets.length === 1 && (i[h.sets[0]] = e.length, e.push(h));
  let { distances: r, constraints: a } = de(t, e, i);
  const c = ft(r.map(ft)) / r.length;
  r = r.map((h) => h.map((b) => b / c));
  const f = (h, b) => ge(h, b, r, a);
  let l = null;
  for (let h = 0; h < s; ++h) {
    const b = fe(f, ut(r.length * 2).map(Math.random), n);
    (!l || b.fx < l.fx) && (l = b);
  }
  const u = l.x, y = {};
  for (let h = 0; h < e.length; ++h) {
    const b = e[h];
    y[b.sets[0]] = {
      x: u[2 * h] * c,
      y: u[2 * h + 1] * c,
      radius: Math.sqrt(b.size / Math.PI)
    };
  }
  if (n.history) for (const h of n.history) ht(h.x, c);
  return y;
}
function pe(t, n) {
  const s = n && n.lossFunction ? n.lossFunction : tt, e = {}, i = {};
  for (const y of t) if (y.sets.length === 1) {
    const h = y.sets[0];
    e[h] = {
      x: 1e10,
      y: 1e10,
      rowid: e.length,
      size: y.size,
      radius: Math.sqrt(y.size / Math.PI)
    }, i[h] = [];
  }
  t = t.filter((y) => y.sets.length === 2);
  for (const y of t) {
    let h = y.weight != null ? y.weight : 1;
    const b = y.sets[0], d = y.sets[1];
    y.size + Dt >= Math.min(e[b].size, e[d].size) && (h = 0), i[b].push({
      set: d,
      size: y.size,
      weight: h
    }), i[d].push({
      set: b,
      size: y.size,
      weight: h
    });
  }
  const r = [];
  Object.keys(i).forEach((y) => {
    let h = 0;
    for (let b = 0; b < i[y].length; ++b) h += i[y][b].size * i[y][b].weight;
    r.push({
      set: y,
      size: h
    });
  });
  function a(y, h) {
    return h.size - y.size;
  }
  r.sort(a);
  const c = {};
  function f(y) {
    return y.set in c;
  }
  function l(y, h) {
    e[h].x = y.x, e[h].y = y.y, c[h] = !0;
  }
  l({
    x: 0,
    y: 0
  }, r[0].set);
  for (let y = 1; y < r.length; ++y) {
    const h = r[y].set, b = i[h].filter(f), d = e[h];
    if (b.sort(a), b.length === 0) throw "ERROR: missing pairwise overlap information";
    const S = [];
    for (var u = 0; u < b.length; ++u) {
      const x = e[b[u].set], v = dt(d.radius, x.radius, b[u].size);
      S.push({
        x: x.x + v,
        y: x.y
      }), S.push({
        x: x.x - v,
        y: x.y
      }), S.push({
        y: x.y + v,
        x: x.x
      }), S.push({
        y: x.y - v,
        x: x.x
      });
      for (let k = u + 1; k < b.length; ++k) {
        const g = e[b[k].set], p = dt(d.radius, g.radius, b[k].size), o = Et({
          x: x.x,
          y: x.y,
          radius: v
        }, {
          x: g.x,
          y: g.y,
          radius: p
        });
        S.push(...o);
      }
    }
    let T = 1e50, m = S[0];
    for (const x of S) {
      e[h].x = x.x, e[h].y = x.y;
      const v = s(e, t);
      v < T && (T = v, m = x);
    }
    l(m, h);
  }
  return e;
}
function tt(t, n) {
  let s = 0;
  for (const e of n) {
    if (e.sets.length === 1) continue;
    let i;
    if (e.sets.length === 2) {
      const a = t[e.sets[0]], c = t[e.sets[1]];
      i = xt(a.radius, c.radius, q(a, c));
    } else i = st(e.sets.map((a) => t[a]));
    const r = e.weight != null ? e.weight : 1;
    s += r * (i - e.size) * (i - e.size);
  }
  return s;
}
function Rt(t, n) {
  let s = 0;
  for (const e of n) {
    if (e.sets.length === 1) continue;
    let i;
    if (e.sets.length === 2) {
      const c = t[e.sets[0]], f = t[e.sets[1]];
      i = xt(c.radius, f.radius, q(c, f));
    } else i = st(e.sets.map((c) => t[c]));
    const r = e.weight != null ? e.weight : 1, a = Math.log((i + 1) / (e.size + 1));
    s += r * a * a;
  }
  return s;
}
function me(t, n, s) {
  if (s == null ? t.sort((i, r) => r.radius - i.radius) : t.sort(s), t.length > 0) {
    const i = t[0].x, r = t[0].y;
    for (const a of t)
      a.x -= i, a.y -= r;
  }
  if (t.length === 2 && q(t[0], t[1]) < Math.abs(t[1].radius - t[0].radius) && (t[1].x = t[0].x + t[0].radius - t[1].radius - 1e-10, t[1].y = t[0].y), t.length > 1) {
    const i = Math.atan2(t[1].x, t[1].y) - n, r = Math.cos(i), a = Math.sin(i);
    for (const c of t) {
      const f = c.x, l = c.y;
      c.x = r * f - a * l, c.y = a * f + r * l;
    }
  }
  if (t.length > 2) {
    let i = Math.atan2(t[2].x, t[2].y) - n;
    for (; i < 0; ) i += 2 * Math.PI;
    for (; i > 2 * Math.PI; ) i -= 2 * Math.PI;
    if (i > Math.PI) {
      const r = t[1].y / (1e-10 + t[1].x);
      for (const a of t) {
        var e = (a.x + r * a.y) / (1 + r * r);
        a.x = 2 * e - a.x, a.y = 2 * e * r - a.y;
      }
    }
  }
}
function be(t) {
  t.forEach((i) => {
    i.parent = i;
  });
  function n(i) {
    return i.parent !== i && (i.parent = n(i.parent)), i.parent;
  }
  function s(i, r) {
    const a = n(i);
    a.parent = n(r);
  }
  for (let i = 0; i < t.length; ++i) for (let r = i + 1; r < t.length; ++r) {
    const a = t[i].radius + t[r].radius;
    q(t[i], t[r]) + 1e-10 < a && s(t[r], t[i]);
  }
  const e = /* @__PURE__ */ new Map();
  for (let i = 0; i < t.length; ++i) {
    const r = n(t[i]).parent.setid;
    e.has(r) || e.set(r, []), e.get(r).push(t[i]);
  }
  return t.forEach((i) => {
    delete i.parent;
  }), Array.from(e.values());
}
function gt(t) {
  const n = (s) => ({
    max: t.reduce((e, i) => Math.max(e, i[s] + i.radius), Number.NEGATIVE_INFINITY),
    min: t.reduce((e, i) => Math.min(e, i[s] - i.radius), Number.POSITIVE_INFINITY)
  });
  return {
    xRange: n("x"),
    yRange: n("y")
  };
}
function Nt(t, n, s) {
  n == null && (n = Math.PI / 2);
  let e = jt(t).map((l) => Object.assign({}, l));
  const i = be(e);
  for (const l of i) {
    me(l, n, s);
    const u = gt(l);
    l.size = (u.xRange.max - u.xRange.min) * (u.yRange.max - u.yRange.min), l.bounds = u;
  }
  i.sort((l, u) => u.size - l.size), e = i[0];
  let r = e.bounds;
  const a = (r.xRange.max - r.xRange.min) / 50;
  function c(l, u, y) {
    if (!l) return;
    const h = l.bounds;
    let b, d;
    if (u) b = r.xRange.max - h.xRange.min + a;
    else {
      b = r.xRange.max - h.xRange.max;
      const S = (h.xRange.max - h.xRange.min) / 2 - (r.xRange.max - r.xRange.min) / 2;
      S < 0 && (b += S);
    }
    if (y) d = r.yRange.max - h.yRange.min + a;
    else {
      d = r.yRange.max - h.yRange.max;
      const S = (h.yRange.max - h.yRange.min) / 2 - (r.yRange.max - r.yRange.min) / 2;
      S < 0 && (d += S);
    }
    for (const S of l)
      S.x += b, S.y += d, e.push(S);
  }
  let f = 1;
  for (; f < i.length; )
    c(i[f], !0, !1), c(i[f + 1], !1, !0), c(i[f + 2], !0, !0), f += 3, r = gt(e);
  return Ft(e);
}
function Ot(t, n, s, e, i) {
  const r = jt(t);
  n -= 2 * e, s -= 2 * e;
  const { xRange: a, yRange: c } = gt(r);
  if (a.max === a.min || c.max === c.min)
    return console.log("not scaling solution: zero size detected"), t;
  let f, l;
  if (i) {
    const b = Math.sqrt(i / Math.PI) * 2;
    f = n / b, l = s / b;
  } else
    f = n / (a.max - a.min), l = s / (c.max - c.min);
  const u = Math.min(l, f), y = (n - (a.max - a.min) * u) / 2, h = (s - (c.max - c.min) * u) / 2;
  return Ft(r.map((b) => ({
    radius: u * b.radius,
    x: e + y + (b.x - a.min) * u,
    y: e + h + (b.y - c.min) * u,
    setid: b.setid
  })));
}
function Ft(t) {
  const n = {};
  for (const s of t) n[s.setid] = s;
  return n;
}
function jt(t) {
  return Object.keys(t).map((n) => Object.assign(t[n], { setid: n }));
}
function ve(t = {}) {
  let n = !1, s = 600, e = 350, i = 15, r = 1e3, a = Math.PI / 2, c = !0, f = null, l = !0, u = !0, y = null, h = null, b = !1, d = null, S = t && t.symmetricalTextCentre ? t.symmetricalTextCentre : !1, T = {}, m = t && t.colourScheme ? t.colourScheme : t && t.colorScheme ? t.colorScheme : [
    "#1f77b4",
    "#ff7f0e",
    "#2ca02c",
    "#d62728",
    "#9467bd",
    "#8c564b",
    "#e377c2",
    "#7f7f7f",
    "#bcbd22",
    "#17becf"
  ], x = 0, v = function(o) {
    if (o in T) return T[o];
    var _ = T[o] = m[x];
    return x += 1, x >= m.length && (x = 0), _;
  }, k = Ct, g = tt;
  function p(o) {
    let _ = o.datum();
    const I = /* @__PURE__ */ new Set();
    _.forEach((M) => {
      M.size == 0 && M.sets.length == 1 && I.add(M.sets[0]);
    }), _ = _.filter((M) => !M.sets.some((O) => I.has(O)));
    let z = {}, F = {};
    if (_.length > 0) {
      let M = k(_, {
        lossFunction: g,
        distinct: b
      });
      c && (M = Nt(M, a, h)), z = Ot(M, s, e, i, f), F = Lt(z, _, S);
    }
    const L = {};
    _.forEach((M) => {
      M.label && (L[M.sets] = M.label);
    });
    function D(M) {
      if (M.sets in L) return L[M.sets];
      if (M.sets.length == 1) return "" + M.sets[0];
    }
    o.selectAll("svg").data([z]).enter().append("svg");
    const A = o.select("svg");
    n ? A.attr("viewBox", `0 0 ${s} ${e}`) : A.attr("width", s).attr("height", e);
    const j = {};
    let E = !1;
    A.selectAll(".venn-area path").each(function(M) {
      const O = this.getAttribute("d");
      M.sets.length == 1 && O && !b && (E = !0, j[M.sets[0]] = Me(O));
    });
    function R(M) {
      return (O) => wt(M.sets.map((J) => {
        let P = j[J], X = z[J];
        return P || (P = {
          x: s / 2,
          y: e / 2,
          radius: 1
        }), X || (X = {
          x: s / 2,
          y: e / 2,
          radius: 1
        }), {
          x: P.x * (1 - O) + X.x * O,
          y: P.y * (1 - O) + X.y * O,
          radius: P.radius * (1 - O) + X.radius * O
        };
      }), d);
    }
    const N = A.selectAll(".venn-area").data(_, (M) => M.sets), V = N.enter().append("g").attr("class", (M) => `venn-area venn-${M.sets.length == 1 ? "circle" : "intersection"}${M.colour || M.color ? " venn-coloured" : ""}`).attr("data-venn-sets", (M) => M.sets.join("_")), Y = V.append("path"), W = V.append("text").attr("class", "label").text((M) => D(M)).attr("text-anchor", "middle").attr("dy", ".35em").attr("x", s / 2).attr("y", e / 2);
    u && (Y.style("fill-opacity", "0").filter((M) => M.sets.length == 1).style("fill", (M) => M.colour ? M.colour : M.color ? M.color : v(M.sets)).style("fill-opacity", ".25"), W.style("fill", (M) => M.colour || M.color ? "#FFF" : t.textFill ? t.textFill : M.sets.length == 1 ? v(M.sets) : "#444"));
    function Q(M) {
      return typeof M.transition == "function" ? M.transition("venn").duration(r) : M;
    }
    let C = o;
    E && typeof C.transition == "function" ? (C = Q(o), C.selectAll("path").attrTween("d", R)) : C.selectAll("path").attr("d", (M) => wt(M.sets.map((O) => z[O])), d);
    const U = C.selectAll("text").filter((M) => M.sets in F).text((M) => D(M)).attr("x", (M) => Math.floor(F[M.sets].x)).attr("y", (M) => Math.floor(F[M.sets].y));
    l && (E ? "on" in U ? U.on("end", at(z, D)) : U.each("end", at(z, D)) : U.each(at(z, D)));
    const G = Q(N.exit()).remove();
    typeof N.transition == "function" && G.selectAll("path").attrTween("d", R);
    const B = G.selectAll("text").attr("x", s / 2).attr("y", e / 2);
    return y !== null && (W.style("font-size", "0px"), U.style("font-size", y), B.style("font-size", "0px")), {
      circles: z,
      textCentres: F,
      nodes: N,
      enter: V,
      update: C,
      exit: G
    };
  }
  return p.wrap = function(o) {
    return arguments.length ? (l = o, p) : l;
  }, p.useViewBox = function() {
    return n = !0, p;
  }, p.width = function(o) {
    return arguments.length ? (s = o, p) : s;
  }, p.height = function(o) {
    return arguments.length ? (e = o, p) : e;
  }, p.padding = function(o) {
    return arguments.length ? (i = o, p) : i;
  }, p.distinct = function(o) {
    return arguments.length ? (b = o, p) : b;
  }, p.colours = function(o) {
    return arguments.length ? (v = o, p) : v;
  }, p.colors = function(o) {
    return arguments.length ? (v = o, p) : v;
  }, p.fontSize = function(o) {
    return arguments.length ? (y = o, p) : y;
  }, p.round = function(o) {
    return arguments.length ? (d = o, p) : d;
  }, p.duration = function(o) {
    return arguments.length ? (r = o, p) : r;
  }, p.layoutFunction = function(o) {
    return arguments.length ? (k = o, p) : k;
  }, p.normalize = function(o) {
    return arguments.length ? (c = o, p) : c;
  }, p.scaleToFit = function(o) {
    return arguments.length ? (f = o, p) : f;
  }, p.styled = function(o) {
    return arguments.length ? (u = o, p) : u;
  }, p.orientation = function(o) {
    return arguments.length ? (a = o, p) : a;
  }, p.orientationOrder = function(o) {
    return arguments.length ? (h = o, p) : h;
  }, p.lossFunction = function(o) {
    return arguments.length ? (g = o === "default" ? tt : o === "logRatio" ? Rt : o, p) : g;
  }, p;
}
function at(t, n) {
  return function(s) {
    const e = this, i = t[s.sets[0]].radius || 50, r = n(s) || "", a = r.split(/\s+/).reverse(), c = (r.length + a.length) / 3;
    let f = a.pop(), l = [f], u = 0;
    const y = 1.1;
    e.textContent = null;
    const h = [];
    function b(x) {
      const v = e.ownerDocument.createElementNS(e.namespaceURI, "tspan");
      return v.textContent = x, h.push(v), e.append(v), v;
    }
    let d = b(f);
    for (; f = a.pop(), !!f; ) {
      l.push(f);
      const x = l.join(" ");
      d.textContent = x, x.length > c && d.getComputedTextLength() > i && (l.pop(), d.textContent = l.join(" "), l = [f], d = b(f), u++);
    }
    const S = 0.35 - u * y / 2, T = e.getAttribute("x"), m = e.getAttribute("y");
    h.forEach((x, v) => {
      x.setAttribute("x", T), x.setAttribute("y", m), x.setAttribute("dy", `${S + v * y}em`);
    });
  };
}
function lt(t, n, s) {
  let e = n[0].radius - q(n[0], t);
  for (let i = 1; i < n.length; ++i) {
    const r = n[i].radius - q(n[i], t);
    r <= e && (e = r);
  }
  for (let i = 0; i < s.length; ++i) {
    const r = q(s[i], t) - s[i].radius;
    r <= e && (e = r);
  }
  return e;
}
function Pt(t, n, s) {
  const e = [];
  for (const u of t)
    e.push({
      x: u.x,
      y: u.y
    }), e.push({
      x: u.x + u.radius / 2,
      y: u.y
    }), e.push({
      x: u.x - u.radius / 2,
      y: u.y
    }), e.push({
      x: u.x,
      y: u.y + u.radius / 2
    }), e.push({
      x: u.x,
      y: u.y - u.radius / 2
    });
  let i = e[0], r = lt(e[0], t, n);
  for (let u = 1; u < e.length; ++u) {
    const y = lt(e[u], t, n);
    y >= r && (i = e[u], r = y);
  }
  const a = At((u) => -1 * lt({
    x: u[0],
    y: u[1]
  }, t, n), [i.x, i.y], {
    maxIterations: 500,
    minErrorDelta: 1e-10
  }).x, c = {
    x: s ? 0 : a[0],
    y: a[1]
  };
  let f = !0;
  for (const u of t) if (q(c, u) > u.radius) {
    f = !1;
    break;
  }
  for (const u of n) if (q(c, u) < u.radius) {
    f = !1;
    break;
  }
  if (f) return c;
  if (t.length == 1) return {
    x: t[0].x,
    y: t[0].y
  };
  const l = {};
  return st(t, l), l.arcs.length === 0 ? {
    x: 0,
    y: -1e3,
    disjoint: !0
  } : l.arcs.length == 1 ? {
    x: l.arcs[0].circle.x,
    y: l.arcs[0].circle.y
  } : n.length ? Pt(t, []) : zt(l.arcs.map((u) => u.p1));
}
function ke(t) {
  const n = {}, s = Object.keys(t);
  for (const e of s) n[e] = [];
  for (let e = 0; e < s.length; e++) {
    const i = s[e], r = t[i];
    for (let a = e + 1; a < s.length; ++a) {
      const c = s[a], f = t[c], l = q(r, f);
      l + f.radius <= r.radius + 1e-10 ? n[c].push(i) : l + r.radius <= f.radius + 1e-10 && n[i].push(c);
    }
  }
  return n;
}
function Lt(t, n, s) {
  const e = {}, i = ke(t);
  for (let r = 0; r < n.length; ++r) {
    const a = n[r].sets, c = {}, f = {};
    for (let h = 0; h < a.length; ++h) {
      c[a[h]] = !0;
      const b = i[a[h]];
      for (let d = 0; d < b.length; ++d) f[b[d]] = !0;
    }
    const l = [], u = [];
    for (let h in t) h in c ? l.push(t[h]) : h in f || u.push(t[h]);
    const y = Pt(l, u, s);
    e[a] = y, y.disjoint && n[r].size > 0 && console.log("WARNING: area " + a + " not represented on screen");
  }
  return e;
}
function Ie(t, n, s) {
  const e = [];
  return e.push(`
M`, t, n), e.push(`
m`, -s, 0), e.push(`
a`, s, s, 0, 1, 0, s * 2, 0), e.push(`
a`, s, s, 0, 1, 0, -s * 2, 0), e.join(" ");
}
function Me(t) {
  const n = t.split(" ");
  return {
    x: Number.parseFloat(n[1]),
    y: Number.parseFloat(n[2]),
    radius: -Number.parseFloat(n[4])
  };
}
function Vt(t) {
  if (t.length === 0) return [];
  const n = {};
  return st(t, n), n.arcs;
}
function Bt(t, n) {
  if (t.length === 0) return "M 0 0";
  const s = Math.pow(10, n || 0), e = n != null ? (r) => Math.round(r * s) / s : (r) => r;
  if (t.length == 1) {
    const r = t[0].circle;
    return Ie(e(r.x), e(r.y), e(r.radius));
  }
  const i = [
    `
M`,
    e(t[0].p2.x),
    e(t[0].p2.y)
  ];
  for (const r of t) {
    const a = e(r.circle.radius);
    i.push(`
A`, a, a, 0, r.large ? 1 : 0, r.sweep ? 1 : 0, e(r.p1.x), e(r.p1.y));
  }
  return i.join(" ");
}
function wt(t, n) {
  return Bt(Vt(t), n);
}
function Se(t, n = {}) {
  const { lossFunction: s, layoutFunction: e = Ct, normalize: i = !0, orientation: r = Math.PI / 2, orientationOrder: a, width: c = 600, height: f = 350, padding: l = 15, scaleToFit: u = !1, symmetricalTextCentre: y = !1, distinct: h, round: b = 2 } = n;
  let d = e(t, {
    lossFunction: s === "default" || !s ? tt : s === "logRatio" ? Rt : s,
    distinct: h
  });
  i && (d = Nt(d, r, a));
  const S = Ot(d, c, f, l, u), T = Lt(S, t, y), m = new Map(Object.keys(S).map((k) => [k, {
    set: k,
    x: S[k].x,
    y: S[k].y,
    radius: S[k].radius
  }])), x = t.map((k) => {
    const g = k.sets.map((o) => m.get(o)), p = Vt(g);
    return {
      circles: g,
      arcs: p,
      path: Bt(p, b),
      area: k,
      has: new Set(k.sets)
    };
  });
  function v(k) {
    let g = "";
    for (const p of x) p.has.size > k.length && k.every((o) => p.has.has(o)) && (g += " " + p.path);
    return g;
  }
  return x.map(({ circles: k, arcs: g, path: p, area: o }) => ({
    data: o,
    text: T[o.sets],
    circles: k,
    arcs: g,
    path: p,
    distinctPath: p + v(o.sets)
  }));
}
var yt = (function() {
  var t = /* @__PURE__ */ w(function(m, x, v, k) {
    for (v = v || {}, k = m.length; k--; v[m[k]] = x) ;
    return v;
  }, "o"), n = [5, 8], s = [
    7,
    8,
    11,
    12,
    17,
    19,
    22,
    24
  ], e = [1, 17], i = [1, 18], r = [
    7,
    8,
    11,
    12,
    14,
    15,
    16,
    17,
    19,
    20,
    21,
    22,
    24,
    27
  ], a = [1, 31], c = [1, 39], f = [
    7,
    8,
    11,
    12,
    17,
    19,
    22,
    24,
    27
  ], l = [1, 57], u = [1, 56], y = [1, 58], h = [1, 59], b = [1, 60], d = [
    7,
    8,
    11,
    12,
    16,
    17,
    19,
    20,
    22,
    24,
    27,
    31,
    32,
    33
  ], S = {
    trace: /* @__PURE__ */ w(function() {
    }, "trace"),
    yy: {},
    symbols_: {
      error: 2,
      start: 3,
      optNewlines: 4,
      VENN: 5,
      document: 6,
      EOF: 7,
      NEWLINE: 8,
      line: 9,
      statement: 10,
      TITLE: 11,
      SET: 12,
      identifier: 13,
      BRACKET_LABEL: 14,
      COLON: 15,
      NUMERIC: 16,
      UNION: 17,
      identifierList: 18,
      TEXT: 19,
      IDENTIFIER: 20,
      STRING: 21,
      INDENT_TEXT: 22,
      indentedTextTail: 23,
      STYLE: 24,
      stylesOpt: 25,
      styleField: 26,
      COMMA: 27,
      styleValue: 28,
      valueTokens: 29,
      valueToken: 30,
      HEXCOLOR: 31,
      RGBCOLOR: 32,
      RGBACOLOR: 33,
      $accept: 0,
      $end: 1
    },
    terminals_: {
      2: "error",
      5: "VENN",
      7: "EOF",
      8: "NEWLINE",
      11: "TITLE",
      12: "SET",
      14: "BRACKET_LABEL",
      15: "COLON",
      16: "NUMERIC",
      17: "UNION",
      19: "TEXT",
      20: "IDENTIFIER",
      21: "STRING",
      22: "INDENT_TEXT",
      24: "STYLE",
      27: "COMMA",
      31: "HEXCOLOR",
      32: "RGBCOLOR",
      33: "RGBACOLOR"
    },
    productions_: [
      0,
      [3, 4],
      [4, 0],
      [4, 2],
      [6, 0],
      [6, 2],
      [9, 1],
      [9, 1],
      [10, 1],
      [10, 2],
      [10, 3],
      [10, 4],
      [10, 5],
      [10, 2],
      [10, 3],
      [10, 4],
      [10, 5],
      [10, 3],
      [10, 3],
      [10, 3],
      [10, 4],
      [10, 4],
      [10, 2],
      [10, 3],
      [23, 1],
      [23, 1],
      [23, 1],
      [23, 2],
      [23, 2],
      [25, 1],
      [25, 3],
      [26, 3],
      [28, 1],
      [28, 1],
      [29, 1],
      [29, 2],
      [30, 1],
      [30, 1],
      [30, 1],
      [30, 1],
      [30, 1],
      [18, 1],
      [18, 3],
      [13, 1],
      [13, 1]
    ],
    performAction: /* @__PURE__ */ w(function(x, v, k, g, p, o, _) {
      var I = o.length - 1;
      switch (p) {
        case 1:
          return o[I - 1];
        case 2:
        case 3:
        case 4:
          this.$ = [];
          break;
        case 5:
          o[I - 1].push(o[I]), this.$ = o[I - 1];
          break;
        case 6:
          this.$ = [];
          break;
        case 7:
        case 22:
        case 32:
        case 36:
        case 37:
        case 38:
        case 39:
        case 40:
          this.$ = o[I];
          break;
        case 8:
          g.setDiagramTitle(o[I].substr(6)), this.$ = o[I].substr(6);
          break;
        case 9:
          g.addSubsetData([o[I]], void 0, void 0), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 10:
          g.addSubsetData([o[I - 1]], o[I], void 0), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 11:
          g.addSubsetData([o[I - 2]], void 0, parseFloat(o[I])), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 12:
          g.addSubsetData([o[I - 3]], o[I - 2], parseFloat(o[I])), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 13:
          if (o[I].length < 2) throw new Error("union requires multiple identifiers");
          g.validateUnionIdentifiers && g.validateUnionIdentifiers(o[I]), g.addSubsetData(o[I], void 0, void 0), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 14:
          if (o[I - 1].length < 2) throw new Error("union requires multiple identifiers");
          g.validateUnionIdentifiers && g.validateUnionIdentifiers(o[I - 1]), g.addSubsetData(o[I - 1], o[I], void 0), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 15:
          if (o[I - 2].length < 2) throw new Error("union requires multiple identifiers");
          g.validateUnionIdentifiers && g.validateUnionIdentifiers(o[I - 2]), g.addSubsetData(o[I - 2], void 0, parseFloat(o[I])), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 16:
          if (o[I - 3].length < 2) throw new Error("union requires multiple identifiers");
          g.validateUnionIdentifiers && g.validateUnionIdentifiers(o[I - 3]), g.addSubsetData(o[I - 3], o[I - 2], parseFloat(o[I])), g.setIndentMode && g.setIndentMode(!0);
          break;
        case 17:
        case 18:
        case 19:
          g.addTextData(o[I - 1], o[I], void 0);
          break;
        case 20:
        case 21:
          g.addTextData(o[I - 2], o[I - 1], o[I]);
          break;
        case 23:
          g.addStyleData(o[I - 1], o[I]);
          break;
        case 24:
        case 25:
        case 26:
          var z = g.getCurrentSets();
          if (!z) throw new Error("text requires set");
          g.addTextData(z, o[I], void 0);
          break;
        case 27:
        case 28:
          var z = g.getCurrentSets();
          if (!z) throw new Error("text requires set");
          g.addTextData(z, o[I - 1], o[I]);
          break;
        case 29:
        case 41:
          this.$ = [o[I]];
          break;
        case 30:
        case 42:
          this.$ = [...o[I - 2], o[I]];
          break;
        case 31:
          this.$ = [o[I - 2], o[I]];
          break;
        case 33:
          this.$ = o[I].join(" ");
          break;
        case 34:
          this.$ = [o[I]];
          break;
        case 35:
          o[I - 1].push(o[I]), this.$ = o[I - 1];
          break;
        case 43:
        case 44:
          this.$ = o[I];
          break;
      }
    }, "anonymous"),
    table: [
      t(n, [2, 2], {
        3: 1,
        4: 2
      }),
      { 1: [3] },
      {
        5: [1, 3],
        8: [1, 4]
      },
      t(s, [2, 4], { 6: 5 }),
      t(n, [2, 3]),
      {
        7: [1, 6],
        8: [1, 8],
        9: 7,
        10: 9,
        11: [1, 10],
        12: [1, 11],
        17: [1, 12],
        19: [1, 13],
        22: [1, 14],
        24: [1, 15]
      },
      { 1: [2, 1] },
      t(s, [2, 5]),
      t(s, [2, 6]),
      t(s, [2, 7]),
      t(s, [2, 8]),
      {
        13: 16,
        20: e,
        21: i
      },
      {
        13: 20,
        18: 19,
        20: e,
        21: i
      },
      {
        13: 20,
        18: 21,
        20: e,
        21: i
      },
      {
        16: [1, 25],
        20: [1, 23],
        21: [1, 24],
        23: 22
      },
      {
        13: 20,
        18: 26,
        20: e,
        21: i
      },
      t(s, [2, 9], {
        14: [1, 27],
        15: [1, 28]
      }),
      t(r, [2, 43]),
      t(r, [2, 44]),
      t(s, [2, 13], {
        14: [1, 29],
        15: [1, 30],
        27: a
      }),
      t(r, [2, 41]),
      {
        16: [1, 34],
        20: [1, 32],
        21: [1, 33],
        27: a
      },
      t(s, [2, 22]),
      t(s, [2, 24], { 14: [1, 35] }),
      t(s, [2, 25], { 14: [1, 36] }),
      t(s, [2, 26]),
      {
        20: c,
        25: 37,
        26: 38,
        27: a
      },
      t(s, [2, 10], { 15: [1, 40] }),
      { 16: [1, 41] },
      t(s, [2, 14], { 15: [1, 42] }),
      { 16: [1, 43] },
      {
        13: 44,
        20: e,
        21: i
      },
      t(s, [2, 17], { 14: [1, 45] }),
      t(s, [2, 18], { 14: [1, 46] }),
      t(s, [2, 19]),
      t(s, [2, 27]),
      t(s, [2, 28]),
      t(s, [2, 23], { 27: [1, 47] }),
      t(f, [2, 29]),
      { 15: [1, 48] },
      { 16: [1, 49] },
      t(s, [2, 11]),
      { 16: [1, 50] },
      t(s, [2, 15]),
      t(r, [2, 42]),
      t(s, [2, 20]),
      t(s, [2, 21]),
      {
        20: c,
        26: 51
      },
      {
        16: l,
        20: u,
        21: [1, 53],
        28: 52,
        29: 54,
        30: 55,
        31: y,
        32: h,
        33: b
      },
      t(s, [2, 12]),
      t(s, [2, 16]),
      t(f, [2, 30]),
      t(f, [2, 31]),
      t(f, [2, 32]),
      t(f, [2, 33], {
        30: 61,
        16: l,
        20: u,
        31: y,
        32: h,
        33: b
      }),
      t(d, [2, 34]),
      t(d, [2, 36]),
      t(d, [2, 37]),
      t(d, [2, 38]),
      t(d, [2, 39]),
      t(d, [2, 40]),
      t(d, [2, 35])
    ],
    defaultActions: { 6: [2, 1] },
    parseError: /* @__PURE__ */ w(function(x, v) {
      if (v.recoverable) this.trace(x);
      else {
        var k = new Error(x);
        throw k.hash = v, k;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ w(function(x) {
      var v = this, k = [0], g = [], p = [null], o = [], _ = this.table, I = "", z = 0, F = 0, L = 0, D = 2, A = 1, j = o.slice.call(arguments, 1), E = Object.create(this.lexer), R = { yy: {} };
      for (var N in this.yy) Object.prototype.hasOwnProperty.call(this.yy, N) && (R.yy[N] = this.yy[N]);
      E.setInput(x, R.yy), R.yy.lexer = E, R.yy.parser = this, typeof E.yylloc > "u" && (E.yylloc = {});
      var V = E.yylloc;
      o.push(V);
      var Y = E.options && E.options.ranges;
      typeof R.yy.parseError == "function" ? this.parseError = R.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function W(K) {
        k.length = k.length - 2 * K, p.length = p.length - K, o.length = o.length - K;
      }
      w(W, "popStack");
      function Q() {
        var K = g.pop() || E.lex() || A;
        return typeof K != "number" && (K instanceof Array && (g = K, K = g.pop()), K = v.symbols_[K] || K), K;
      }
      w(Q, "lex");
      for (var C, U, G, B, M, O = {}, J, P, X, nt; ; ) {
        if (G = k[k.length - 1], this.defaultActions[G] ? B = this.defaultActions[G] : ((C === null || typeof C > "u") && (C = Q()), B = _[G] && _[G][C]), typeof B > "u" || !B.length || !B[0]) {
          var rt = "";
          nt = [];
          for (J in _[G]) this.terminals_[J] && J > D && nt.push("'" + this.terminals_[J] + "'");
          E.showPosition ? rt = "Parse error on line " + (z + 1) + `:
` + E.showPosition() + `
Expecting ` + nt.join(", ") + ", got '" + (this.terminals_[C] || C) + "'" : rt = "Parse error on line " + (z + 1) + ": Unexpected " + (C == A ? "end of input" : "'" + (this.terminals_[C] || C) + "'"), this.parseError(rt, {
            text: E.match,
            token: this.terminals_[C] || C,
            line: E.yylineno,
            loc: V,
            expected: nt
          });
        }
        if (B[0] instanceof Array && B.length > 1) throw new Error("Parse Error: multiple actions possible at state: " + G + ", token: " + C);
        switch (B[0]) {
          case 1:
            k.push(C), p.push(E.yytext), o.push(E.yylloc), k.push(B[1]), C = null, U ? (C = U, U = null) : (F = E.yyleng, I = E.yytext, z = E.yylineno, V = E.yylloc, L > 0 && L--);
            break;
          case 2:
            if (P = this.productions_[B[1]][1], O.$ = p[p.length - P], O._$ = {
              first_line: o[o.length - (P || 1)].first_line,
              last_line: o[o.length - 1].last_line,
              first_column: o[o.length - (P || 1)].first_column,
              last_column: o[o.length - 1].last_column
            }, Y && (O._$.range = [o[o.length - (P || 1)].range[0], o[o.length - 1].range[1]]), M = this.performAction.apply(O, [
              I,
              F,
              z,
              R.yy,
              B[1],
              p,
              o
            ].concat(j)), typeof M < "u") return M;
            P && (k = k.slice(0, -1 * P * 2), p = p.slice(0, -1 * P), o = o.slice(0, -1 * P)), k.push(this.productions_[B[1]][0]), p.push(O.$), o.push(O._$), X = _[k[k.length - 2]][k[k.length - 1]], k.push(X);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  };
  S.lexer = /* @__PURE__ */ (function() {
    return {
      EOF: 1,
      parseError: /* @__PURE__ */ w(function(x, v) {
        if (this.yy.parser) this.yy.parser.parseError(x, v);
        else throw new Error(x);
      }, "parseError"),
      setInput: /* @__PURE__ */ w(function(m, x) {
        return this.yy = x || this.yy || {}, this._input = m, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
          first_line: 1,
          first_column: 0,
          last_line: 1,
          last_column: 0
        }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
      }, "setInput"),
      input: /* @__PURE__ */ w(function() {
        var m = this._input[0];
        return this.yytext += m, this.yyleng++, this.offset++, this.match += m, this.matched += m, m.match(/(?:\r\n?|\n).*/g) ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), m;
      }, "input"),
      unput: /* @__PURE__ */ w(function(m) {
        var x = m.length, v = m.split(/(?:\r\n?|\n)/g);
        this._input = m + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - x), this.offset -= x;
        var k = this.match.split(/(?:\r\n?|\n)/g);
        this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), v.length - 1 && (this.yylineno -= v.length - 1);
        var g = this.yylloc.range;
        return this.yylloc = {
          first_line: this.yylloc.first_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.first_column,
          last_column: v ? (v.length === k.length ? this.yylloc.first_column : 0) + k[k.length - v.length].length - v[0].length : this.yylloc.first_column - x
        }, this.options.ranges && (this.yylloc.range = [g[0], g[0] + this.yyleng - x]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      more: /* @__PURE__ */ w(function() {
        return this._more = !0, this;
      }, "more"),
      reject: /* @__PURE__ */ w(function() {
        if (this.options.backtrack_lexer) this._backtrack = !0;
        else return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
        return this;
      }, "reject"),
      less: /* @__PURE__ */ w(function(m) {
        this.unput(this.match.slice(m));
      }, "less"),
      pastInput: /* @__PURE__ */ w(function() {
        var m = this.matched.substr(0, this.matched.length - this.match.length);
        return (m.length > 20 ? "..." : "") + m.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      upcomingInput: /* @__PURE__ */ w(function() {
        var m = this.match;
        return m.length < 20 && (m += this._input.substr(0, 20 - m.length)), (m.substr(0, 20) + (m.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      showPosition: /* @__PURE__ */ w(function() {
        var m = this.pastInput(), x = new Array(m.length + 1).join("-");
        return m + this.upcomingInput() + `
` + x + "^";
      }, "showPosition"),
      test_match: /* @__PURE__ */ w(function(m, x) {
        var v, k, g;
        if (this.options.backtrack_lexer && (g = {
          yylineno: this.yylineno,
          yylloc: {
            first_line: this.yylloc.first_line,
            last_line: this.last_line,
            first_column: this.yylloc.first_column,
            last_column: this.yylloc.last_column
          },
          yytext: this.yytext,
          match: this.match,
          matches: this.matches,
          matched: this.matched,
          yyleng: this.yyleng,
          offset: this.offset,
          _more: this._more,
          _input: this._input,
          yy: this.yy,
          conditionStack: this.conditionStack.slice(0),
          done: this.done
        }, this.options.ranges && (g.yylloc.range = this.yylloc.range.slice(0))), k = m[0].match(/(?:\r\n?|\n).*/g), k && (this.yylineno += k.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: k ? k[k.length - 1].length - k[k.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + m[0].length
        }, this.yytext += m[0], this.match += m[0], this.matches = m, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(m[0].length), this.matched += m[0], v = this.performAction.call(this, this.yy, this, x, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), v) return v;
        if (this._backtrack) {
          for (var p in g) this[p] = g[p];
          return !1;
        }
        return !1;
      }, "test_match"),
      next: /* @__PURE__ */ w(function() {
        if (this.done) return this.EOF;
        this._input || (this.done = !0);
        var m, x, v, k;
        this._more || (this.yytext = "", this.match = "");
        for (var g = this._currentRules(), p = 0; p < g.length; p++)
          if (v = this._input.match(this.rules[g[p]]), v && (!x || v[0].length > x[0].length)) {
            if (x = v, k = p, this.options.backtrack_lexer) {
              if (m = this.test_match(v, g[p]), m !== !1) return m;
              if (this._backtrack) {
                x = !1;
                continue;
              } else return !1;
            } else if (!this.options.flex) break;
          }
        return x ? (m = this.test_match(x, g[k]), m !== !1 ? m : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      lex: /* @__PURE__ */ w(function() {
        var x = this.next();
        return x || this.lex();
      }, "lex"),
      begin: /* @__PURE__ */ w(function(x) {
        this.conditionStack.push(x);
      }, "begin"),
      popState: /* @__PURE__ */ w(function() {
        return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      _currentRules: /* @__PURE__ */ w(function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      }, "_currentRules"),
      topState: /* @__PURE__ */ w(function(x) {
        return x = this.conditionStack.length - 1 - Math.abs(x || 0), x >= 0 ? this.conditionStack[x] : "INITIAL";
      }, "topState"),
      pushState: /* @__PURE__ */ w(function(x) {
        this.begin(x);
      }, "pushState"),
      stateStackSize: /* @__PURE__ */ w(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ w(function(x, v, k, g) {
        switch (k) {
          case 0:
            break;
          case 1:
            break;
          case 2:
            break;
          case 3:
            if (x.getIndentMode && x.getIndentMode())
              return x.consumeIndentText = !0, this.begin("INITIAL"), 22;
            break;
          case 4:
            break;
          case 5:
            x.setIndentMode && x.setIndentMode(!1), this.begin("INITIAL"), this.unput(v.yytext);
            break;
          case 6:
            return this.begin("bol"), 8;
          case 7:
            break;
          case 8:
            break;
          case 9:
            return 7;
          case 10:
            return 11;
          case 11:
            return 5;
          case 12:
            return 12;
          case 13:
            return 17;
          case 14:
            if (x.consumeIndentText) x.consumeIndentText = !1;
            else return 19;
            break;
          case 15:
            return 24;
          case 16:
            return v.yytext = v.yytext.slice(2, -2), 14;
          case 17:
            return v.yytext = v.yytext.slice(1, -1).trim(), 14;
          case 18:
            return 16;
          case 19:
            return 31;
          case 20:
            return 33;
          case 21:
            return 32;
          case 22:
            return 20;
          case 23:
            return 21;
          case 24:
            return 27;
          case 25:
            return 15;
        }
      }, "anonymous"),
      rules: [
        /^(?:%%(?!\{)[^\n]*)/i,
        /^(?:[^\}]%%[^\n]*)/i,
        /^(?:[ \t]+(?=[\n\r]))/i,
        /^(?:[ \t]+(?=text\b))/i,
        /^(?:[ \t]+)/i,
        /^(?:[^ \t\n\r])/i,
        /^(?:[\n\r]+)/i,
        /^(?:%%[^\n]*)/i,
        /^(?:[ \t]+)/i,
        /^(?:$)/i,
        /^(?:title\s[^#\n;]+)/i,
        /^(?:venn-beta\b)/i,
        /^(?:set\b)/i,
        /^(?:union\b)/i,
        /^(?:text\b)/i,
        /^(?:style\b)/i,
        /^(?:\["[^\"]*"\])/i,
        /^(?:\[[^\]\"]+\])/i,
        /^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,
        /^(?:#[0-9a-fA-F]{3,8})/i,
        /^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,
        /^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,
        /^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,
        /^(?:"[^\"]*")/i,
        /^(?:,)/i,
        /^(?::)/i
      ],
      conditions: {
        bol: {
          rules: [
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25
          ],
          inclusive: !0
        },
        INITIAL: {
          rules: [
            0,
            1,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25
          ],
          inclusive: !0
        }
      }
    };
  })();
  function T() {
    this.yy = {};
  }
  return w(T, "Parser"), T.prototype = S, S.Parser = T, new T();
})();
yt.parser = yt;
var we = yt, pt = [], mt = [], bt = [], vt = /* @__PURE__ */ new Set(), kt, It = !1, _e = /* @__PURE__ */ w((t, n, s) => {
  const e = it(t).sort(), i = s ?? 10 / Math.pow(t.length, 2);
  kt = e, e.length === 1 && vt.add(e[0]), pt.push({
    sets: e,
    size: i,
    label: n ? et(n) : void 0
  });
}, "addSubsetData"), Te = /* @__PURE__ */ w(() => pt, "getSubsetData"), et = /* @__PURE__ */ w((t) => {
  const n = t.trim();
  return n.length >= 2 && n.startsWith('"') && n.endsWith('"') ? n.slice(1, -1) : n;
}, "normalizeText"), Ee = /* @__PURE__ */ w((t) => t && et(t), "normalizeStyleValue"), ze = /* @__PURE__ */ w((t, n, s) => {
  const e = et(n);
  mt.push({
    sets: it(t).sort(),
    id: e,
    label: s ? et(s) : void 0
  });
}, "addTextData"), Ae = /* @__PURE__ */ w((t, n) => {
  const s = it(t).sort(), e = {};
  for (const [i, r] of n) e[i] = Ee(r) ?? r;
  bt.push({
    targets: s,
    styles: e
  });
}, "addStyleData"), Ce = /* @__PURE__ */ w(() => bt, "getStyleData"), it = /* @__PURE__ */ w((t) => t.map((n) => et(n)), "normalizeIdentifierList"), De = /* @__PURE__ */ w((t) => {
  const n = it(t).filter((s) => !vt.has(s));
  if (n.length > 0) throw new Error(`unknown set identifier: ${n.join(", ")}`);
}, "validateUnionIdentifiers"), Re = /* @__PURE__ */ w(() => mt, "getTextData"), Ne = /* @__PURE__ */ w(() => kt, "getCurrentSets"), Oe = /* @__PURE__ */ w(() => It, "getIndentMode"), Fe = /* @__PURE__ */ w((t) => {
  It = t;
}, "setIndentMode"), je = ee.venn;
function qt() {
  return Wt(je, _t().venn);
}
w(qt, "getConfig");
var Pe = {
  getConfig: qt,
  clear: /* @__PURE__ */ w(() => {
    $t(), pt.length = 0, mt.length = 0, bt.length = 0, vt.clear(), kt = void 0, It = !1;
  }, "customClear"),
  setAccTitle: Zt,
  getAccTitle: ie,
  setDiagramTitle: Qt,
  getDiagramTitle: Ht,
  getAccDescription: Jt,
  setAccDescription: Yt,
  addSubsetData: _e,
  getSubsetData: Te,
  addTextData: ze,
  addStyleData: Ae,
  validateUnionIdentifiers: De,
  getTextData: Re,
  getStyleData: Ce,
  getCurrentSets: Ne,
  getIndentMode: Oe,
  setIndentMode: Fe
}, Le = /* @__PURE__ */ w((t) => `
  .venn-title {
    font-size: 32px;
    fill: ${t.vennTitleTextColor};
    font-family: ${t.fontFamily};
  }

  .venn-circle text {
    font-size: 48px;
    font-family: ${t.fontFamily};
  }

  .venn-intersection text {
    font-size: 48px;
    fill: ${t.vennSetTextColor};
    font-family: ${t.fontFamily};
  }

  .venn-text-node {
    font-family: ${t.fontFamily};
    color: ${t.vennSetTextColor};
  }
`, "getStyles");
function Ut(t) {
  const n = /* @__PURE__ */ new Map();
  for (const s of t) {
    const e = s.targets.join("|"), i = n.get(e);
    i ? Object.assign(i, s.styles) : n.set(e, { ...s.styles });
  }
  return n;
}
w(Ut, "buildStyleByKey");
var Ve = /* @__PURE__ */ w((t, n, s, e) => {
  const i = e.db, r = i.getConfig?.(), { themeVariables: a, look: c, handDrawnSeed: f } = _t(), l = c === "handDrawn", u = [
    a.venn1,
    a.venn2,
    a.venn3,
    a.venn4,
    a.venn5,
    a.venn6,
    a.venn7,
    a.venn8
  ].filter(Boolean), y = i.getDiagramTitle?.(), h = i.getSubsetData(), b = i.getTextData(), d = Ut(i.getStyleData()), S = r?.width ?? 800, T = r?.height ?? 450, m = S / 1600, x = y ? 48 * m : 0, v = a.primaryTextColor ?? a.textColor, k = re(n);
  k.attr("viewBox", `0 0 ${S} ${T}`), y && k.append("text").text(y).attr("class", "venn-title").attr("font-size", `${32 * m}px`).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("x", "50%").attr("y", 32 * m).style("fill", a.vennTitleTextColor || a.titleColor);
  const g = ot(document.createElement("div")), p = ve().width(S).height(T - x);
  g.datum(h).call(p);
  const o = l ? oe.svg(g.select("svg").node()) : void 0, _ = Se(h, {
    width: S,
    height: T - x,
    padding: r?.padding ?? 15
  }), I = /* @__PURE__ */ new Map();
  for (const D of _) {
    const A = Z([...D.data.sets].sort());
    I.set(A, D);
  }
  b.length > 0 && Gt(r, I, g, b, m, d);
  const z = se(a.background || "#f4f4f4");
  g.selectAll(".venn-circle").each(function(D, A) {
    const j = ot(this), E = Z([...D.sets].sort()), R = d.get(E), N = R?.fill || u[A % u.length] || a.primaryColor;
    j.classed(`venn-set-${A % 8}`, !0);
    const V = R?.["fill-opacity"] ?? 0.1, Y = R?.stroke || N, W = R?.["stroke-width"] || `${5 * m}`;
    if (l && o) {
      const C = I.get(E);
      if (C && C.circles.length > 0) {
        const U = C.circles[0], G = o.circle(U.x, U.y, U.radius * 2, {
          roughness: 0.7,
          seed: f,
          fill: Mt(N, 0.7),
          fillStyle: "hachure",
          fillWeight: 2,
          hachureGap: 8,
          hachureAngle: -41 + A * 60,
          stroke: Y,
          strokeWidth: parseFloat(String(W))
        });
        j.select("path").remove(), j.node()?.insertBefore(G, j.select("text").node());
      }
    } else j.select("path").style("fill", N).style("fill-opacity", V).style("stroke", Y).style("stroke-width", W).style("stroke-opacity", 0.95);
    const Q = R?.color || (z ? Kt(N, 30) : Xt(N, 30));
    j.select("text").style("font-size", `${48 * m}px`).style("fill", Q);
  }), l && o ? g.selectAll(".venn-intersection").each(function(D) {
    const A = ot(this), j = Z([...D.sets].sort()), E = d.get(j), R = E?.fill;
    if (R) {
      const N = A.select("path"), V = N.attr("d");
      if (V) {
        const Y = o.path(V, {
          roughness: 0.7,
          seed: f,
          fill: Mt(R, 0.3),
          fillStyle: "cross-hatch",
          fillWeight: 2,
          hachureGap: 6,
          hachureAngle: 60,
          stroke: "none"
        }), W = N.node();
        W?.parentNode?.insertBefore(Y, W), N.remove();
      }
    } else A.select("path").style("fill-opacity", 0);
    A.select("text").style("font-size", `${48 * m}px`).style("fill", E?.color ?? a.vennSetTextColor ?? v);
  }) : (g.selectAll(".venn-intersection text").style("font-size", `${48 * m}px`).style("fill", (D) => {
    const A = Z([...D.sets].sort());
    return d.get(A)?.color ?? a.vennSetTextColor ?? v;
  }), g.selectAll(".venn-intersection path").style("fill-opacity", (D) => {
    const A = Z([...D.sets].sort());
    return d.get(A)?.fill ? 1 : 0;
  }).style("fill", (D) => {
    const A = Z([...D.sets].sort());
    return d.get(A)?.fill ?? "transparent";
  }));
  const F = k.append("g").attr("transform", `translate(0, ${x})`), L = g.select("svg").node();
  if (L && "childNodes" in L) for (const D of [...L.childNodes]) F.node()?.appendChild(D);
  te(k, T, S, r?.useMaxWidth ?? !0);
}, "draw");
function Z(t) {
  return t.join("|");
}
w(Z, "stableSetsKey");
function Gt(t, n, s, e, i, r) {
  const a = t?.useDebugLayout ?? !1, c = s.select("svg").append("g").attr("class", "venn-text-nodes"), f = /* @__PURE__ */ new Map();
  for (const l of e) {
    const u = Z(l.sets), y = f.get(u);
    y ? y.push(l) : f.set(u, [l]);
  }
  for (const [l, u] of f.entries()) {
    const y = n.get(l);
    if (!y?.text) continue;
    const h = y.text.x, b = y.text.y, d = Math.min(...y.circles.map((F) => F.radius)), S = Math.min(...y.circles.map((F) => F.radius - Math.hypot(h - F.x, b - F.y)));
    let T = Number.isFinite(S) ? Math.max(0, S) : 0;
    T === 0 && Number.isFinite(d) && (T = d * 0.6);
    const m = c.append("g").attr("class", "venn-text-area").attr("font-size", `${40 * i}px`);
    a && m.append("circle").attr("class", "venn-text-debug-circle").attr("cx", h).attr("cy", b).attr("r", T).attr("fill", "none").attr("stroke", "purple").attr("stroke-width", 1.5 * i).attr("stroke-dasharray", `${6 * i} ${4 * i}`);
    const x = Math.max(80 * i, T * 2 * 0.95), v = Math.max(60 * i, T * 2 * 0.95), k = (y.data.label && y.data.label.length > 0 ? Math.min(32 * i, T * 0.25) : 0) + (u.length <= 2 ? 30 * i : 0), g = h - x / 2, p = b - v / 2 + k, o = Math.max(1, Math.ceil(Math.sqrt(u.length))), _ = Math.max(1, Math.ceil(u.length / o)), I = x / o, z = v / _;
    for (const [F, L] of u.entries()) {
      const D = F % o, A = Math.floor(F / o), j = g + I * (D + 0.5), E = p + z * (A + 0.5);
      a && m.append("rect").attr("class", "venn-text-debug-cell").attr("x", g + I * D).attr("y", p + z * A).attr("width", I).attr("height", z).attr("fill", "none").attr("stroke", "teal").attr("stroke-width", 1 * i).attr("stroke-dasharray", `${4 * i} ${3 * i}`);
      const R = I * 0.9, N = z * 0.9, V = m.append("foreignObject").attr("class", "venn-text-node-fo").attr("width", R).attr("height", N).attr("x", j - R / 2).attr("y", E - N / 2).attr("overflow", "visible"), Y = r.get(L.id)?.color, W = V.append("xhtml:span").attr("class", "venn-text-node").style("display", "flex").style("width", "100%").style("height", "100%").style("white-space", "normal").style("align-items", "center").style("justify-content", "center").style("text-align", "center").style("overflow-wrap", "normal").style("word-break", "normal").text(L.label ?? L.id);
      Y && W.style("color", Y);
    }
  }
}
w(Gt, "renderTextNodes");
var Ye = {
  parser: we,
  db: Pe,
  renderer: { draw: Ve },
  styles: Le
};
export {
  Ye as diagram
};

//# sourceMappingURL=vennDiagram-DHZGUBPP.js.map