var Km = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function sc(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
function Io(t, e) {
  (e == null || e > t.length) && (e = t.length);
  for (var r = 0, a = Array(e); r < e; r++) a[r] = t[r];
  return a;
}
function uc(t) {
  if (Array.isArray(t)) return t;
}
function lc(t) {
  if (Array.isArray(t)) return Io(t);
}
function hr(t, e) {
  if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
}
function fc(t, e) {
  for (var r = 0; r < e.length; r++) {
    var a = e[r];
    a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(t, of(a.key), a);
  }
}
function dr(t, e, r) {
  return e && fc(t.prototype, e), Object.defineProperty(t, "prototype", {
    writable: !1
  }), t;
}
function Tt(t, e) {
  var r = typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
  if (!r) {
    if (Array.isArray(t) || (r = Jo(t)) || e) {
      r && (t = r);
      var a = 0, n = function() {
      };
      return {
        s: n,
        n: function() {
          return a >= t.length ? {
            done: !0
          } : {
            done: !1,
            value: t[a++]
          };
        },
        e: function(u) {
          throw u;
        },
        f: n
      };
    }
    throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  var i, o = !0, s = !1;
  return {
    s: function() {
      r = r.call(t);
    },
    n: function() {
      var u = r.next();
      return o = u.done, u;
    },
    e: function(u) {
      s = !0, i = u;
    },
    f: function() {
      try {
        o || r.return == null || r.return();
      } finally {
        if (s) throw i;
      }
    }
  };
}
function nf(t, e, r) {
  return (e = of(e)) in t ? Object.defineProperty(t, e, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[e] = r, t;
}
function vc(t) {
  if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null) return Array.from(t);
}
function cc(t, e) {
  var r = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
  if (r != null) {
    var a, n, i, o, s = [], u = !0, l = !1;
    try {
      if (i = (r = r.call(t)).next, e === 0) {
        if (Object(r) !== r) return;
        u = !1;
      } else for (; !(u = (a = i.call(r)).done) && (s.push(a.value), s.length !== e); u = !0) ;
    } catch (f) {
      l = !0, n = f;
    } finally {
      try {
        if (!u && r.return != null && (o = r.return(), Object(o) !== o)) return;
      } finally {
        if (l) throw n;
      }
    }
    return s;
  }
}
function hc() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function dc() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Qe(t, e) {
  return uc(t) || cc(t, e) || Jo(t, e) || hc();
}
function En(t) {
  return lc(t) || vc(t) || Jo(t) || dc();
}
function gc(t, e) {
  if (typeof t != "object" || !t) return t;
  var r = t[Symbol.toPrimitive];
  if (r !== void 0) {
    var a = r.call(t, e);
    if (typeof a != "object") return a;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return String(t);
}
function of(t) {
  var e = gc(t, "string");
  return typeof e == "symbol" ? e : e + "";
}
function tt(t) {
  "@babel/helpers - typeof";
  return tt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, tt(t);
}
function Jo(t, e) {
  if (t) {
    if (typeof t == "string") return Io(t, e);
    var r = {}.toString.call(t).slice(8, -1);
    return r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set" ? Array.from(t) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? Io(t, e) : void 0;
  }
}
var je = typeof window > "u" ? null : window, As = je ? je.navigator : null;
je && je.document;
var pc = tt(""), sf = tt({}), yc = tt(function() {
}), mc = typeof HTMLElement > "u" ? "undefined" : tt(HTMLElement), Oa = function(e) {
  return e && e.instanceString && He(e.instanceString) ? e.instanceString() : null;
}, de = function(e) {
  return e != null && tt(e) == pc;
}, He = function(e) {
  return e != null && tt(e) === yc;
}, ze = function(e) {
  return !Ct(e) && (Array.isArray ? Array.isArray(e) : e != null && e instanceof Array);
}, Ie = function(e) {
  return e != null && tt(e) === sf && !ze(e) && e.constructor === Object;
}, bc = function(e) {
  return e != null && tt(e) === sf;
}, ne = function(e) {
  return e != null && tt(e) === tt(1) && !isNaN(e);
}, wc = function(e) {
  return ne(e) && Math.floor(e) === e;
}, xn = function(e) {
  if (mc !== "undefined")
    return e != null && e instanceof HTMLElement;
}, Ct = function(e) {
  return ka(e) || uf(e);
}, ka = function(e) {
  return Oa(e) === "collection" && e._private.single;
}, uf = function(e) {
  return Oa(e) === "collection" && !e._private.single;
}, jo = function(e) {
  return Oa(e) === "core";
}, lf = function(e) {
  return Oa(e) === "stylesheet";
}, Ec = function(e) {
  return Oa(e) === "event";
}, sr = function(e) {
  return e == null ? !0 : !!(e === "" || e.match(/^\s+$/));
}, xc = function(e) {
  return typeof HTMLElement > "u" ? !1 : e instanceof HTMLElement;
}, Tc = function(e) {
  return Ie(e) && ne(e.x1) && ne(e.x2) && ne(e.y1) && ne(e.y2);
}, Cc = function(e) {
  return bc(e) && He(e.then);
}, Dc = function() {
  return As && As.userAgent.match(/msie|trident|edge/i);
}, Kr = function(e, r) {
  r || (r = function() {
    if (arguments.length === 1)
      return arguments[0];
    if (arguments.length === 0)
      return "undefined";
    for (var i = [], o = 0; o < arguments.length; o++)
      i.push(arguments[o]);
    return i.join("$");
  });
  var a = function() {
    var i = this, o = arguments, s, u = r.apply(i, o), l = a.cache;
    return (s = l[u]) || (s = l[u] = e.apply(i, o)), s;
  };
  return a.cache = {}, a;
}, es = Kr(function(t) {
  return t.replace(/([A-Z])/g, function(e) {
    return "-" + e.toLowerCase();
  });
}), Nn = Kr(function(t) {
  return t.replace(/(-\w)/g, function(e) {
    return e[1].toUpperCase();
  });
}), ff = Kr(function(t, e) {
  return t + e[0].toUpperCase() + e.substring(1);
}, function(t, e) {
  return t + "$" + e;
}), Ls = function(e) {
  return sr(e) ? e : e.charAt(0).toUpperCase() + e.substring(1);
}, rr = function(e, r) {
  return e.slice(-1 * r.length) === r;
}, et = "(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))", Sc = "rgb[a]?\\((" + et + "[%]?)\\s*,\\s*(" + et + "[%]?)\\s*,\\s*(" + et + "[%]?)(?:\\s*,\\s*(" + et + "))?\\)", Ac = "rgb[a]?\\((?:" + et + "[%]?)\\s*,\\s*(?:" + et + "[%]?)\\s*,\\s*(?:" + et + "[%]?)(?:\\s*,\\s*(?:" + et + "))?\\)", Lc = "hsl[a]?\\((" + et + ")\\s*,\\s*(" + et + "[%])\\s*,\\s*(" + et + "[%])(?:\\s*,\\s*(" + et + "))?\\)", Rc = "hsl[a]?\\((?:" + et + ")\\s*,\\s*(?:" + et + "[%])\\s*,\\s*(?:" + et + "[%])(?:\\s*,\\s*(?:" + et + "))?\\)", Mc = "\\#[0-9a-fA-F]{3}", Pc = "\\#[0-9a-fA-F]{6}", vf = function(e, r) {
  return e < r ? -1 : e > r ? 1 : 0;
}, Ic = function(e, r) {
  return -1 * vf(e, r);
}, ye = Object.assign != null ? Object.assign.bind(Object) : function(t) {
  for (var e = arguments, r = 1; r < e.length; r++) {
    var a = e[r];
    if (a != null)
      for (var n = Object.keys(a), i = 0; i < n.length; i++) {
        var o = n[i];
        t[o] = a[o];
      }
  }
  return t;
}, Oc = function(e) {
  if (!(!(e.length === 4 || e.length === 7) || e[0] !== "#")) {
    var r = e.length === 4, a, n, i, o = 16;
    return r ? (a = parseInt(e[1] + e[1], o), n = parseInt(e[2] + e[2], o), i = parseInt(e[3] + e[3], o)) : (a = parseInt(e[1] + e[2], o), n = parseInt(e[3] + e[4], o), i = parseInt(e[5] + e[6], o)), [a, n, i];
  }
}, kc = function(e) {
  var r, a, n, i, o, s, u, l;
  function f(d, g, p) {
    return p < 0 && (p += 1), p > 1 && (p -= 1), p < 1 / 6 ? d + (g - d) * 6 * p : p < 1 / 2 ? g : p < 2 / 3 ? d + (g - d) * (2 / 3 - p) * 6 : d;
  }
  var v = new RegExp("^" + Lc + "$").exec(e);
  if (v) {
    if (a = parseInt(v[1]), a < 0 ? a = (360 - -1 * a % 360) % 360 : a > 360 && (a = a % 360), a /= 360, n = parseFloat(v[2]), n < 0 || n > 100 || (n = n / 100, i = parseFloat(v[3]), i < 0 || i > 100) || (i = i / 100, o = v[4], o !== void 0 && (o = parseFloat(o), o < 0 || o > 1)))
      return;
    if (n === 0)
      s = u = l = Math.round(i * 255);
    else {
      var c = i < 0.5 ? i * (1 + n) : i + n - i * n, h = 2 * i - c;
      s = Math.round(255 * f(h, c, a + 1 / 3)), u = Math.round(255 * f(h, c, a)), l = Math.round(255 * f(h, c, a - 1 / 3));
    }
    r = [s, u, l, o];
  }
  return r;
}, Nc = function(e) {
  var r, a = new RegExp("^" + Sc + "$").exec(e);
  if (a) {
    r = [];
    for (var n = [], i = 1; i <= 3; i++) {
      var o = a[i];
      if (o[o.length - 1] === "%" && (n[i] = !0), o = parseFloat(o), n[i] && (o = o / 100 * 255), o < 0 || o > 255)
        return;
      r.push(Math.floor(o));
    }
    var s = n[1] || n[2] || n[3], u = n[1] && n[2] && n[3];
    if (s && !u)
      return;
    var l = a[4];
    if (l !== void 0) {
      if (l = parseFloat(l), l < 0 || l > 1)
        return;
      r.push(l);
    }
  }
  return r;
}, Bc = function(e) {
  return Fc[e.toLowerCase()];
}, cf = function(e) {
  return (ze(e) ? e : null) || Bc(e) || Oc(e) || Nc(e) || kc(e);
}, Fc = {
  // special colour names
  transparent: [0, 0, 0, 0],
  // NB alpha === 0
  // regular colours
  aliceblue: [240, 248, 255],
  antiquewhite: [250, 235, 215],
  aqua: [0, 255, 255],
  aquamarine: [127, 255, 212],
  azure: [240, 255, 255],
  beige: [245, 245, 220],
  bisque: [255, 228, 196],
  black: [0, 0, 0],
  blanchedalmond: [255, 235, 205],
  blue: [0, 0, 255],
  blueviolet: [138, 43, 226],
  brown: [165, 42, 42],
  burlywood: [222, 184, 135],
  cadetblue: [95, 158, 160],
  chartreuse: [127, 255, 0],
  chocolate: [210, 105, 30],
  coral: [255, 127, 80],
  cornflowerblue: [100, 149, 237],
  cornsilk: [255, 248, 220],
  crimson: [220, 20, 60],
  cyan: [0, 255, 255],
  darkblue: [0, 0, 139],
  darkcyan: [0, 139, 139],
  darkgoldenrod: [184, 134, 11],
  darkgray: [169, 169, 169],
  darkgreen: [0, 100, 0],
  darkgrey: [169, 169, 169],
  darkkhaki: [189, 183, 107],
  darkmagenta: [139, 0, 139],
  darkolivegreen: [85, 107, 47],
  darkorange: [255, 140, 0],
  darkorchid: [153, 50, 204],
  darkred: [139, 0, 0],
  darksalmon: [233, 150, 122],
  darkseagreen: [143, 188, 143],
  darkslateblue: [72, 61, 139],
  darkslategray: [47, 79, 79],
  darkslategrey: [47, 79, 79],
  darkturquoise: [0, 206, 209],
  darkviolet: [148, 0, 211],
  deeppink: [255, 20, 147],
  deepskyblue: [0, 191, 255],
  dimgray: [105, 105, 105],
  dimgrey: [105, 105, 105],
  dodgerblue: [30, 144, 255],
  firebrick: [178, 34, 34],
  floralwhite: [255, 250, 240],
  forestgreen: [34, 139, 34],
  fuchsia: [255, 0, 255],
  gainsboro: [220, 220, 220],
  ghostwhite: [248, 248, 255],
  gold: [255, 215, 0],
  goldenrod: [218, 165, 32],
  gray: [128, 128, 128],
  grey: [128, 128, 128],
  green: [0, 128, 0],
  greenyellow: [173, 255, 47],
  honeydew: [240, 255, 240],
  hotpink: [255, 105, 180],
  indianred: [205, 92, 92],
  indigo: [75, 0, 130],
  ivory: [255, 255, 240],
  khaki: [240, 230, 140],
  lavender: [230, 230, 250],
  lavenderblush: [255, 240, 245],
  lawngreen: [124, 252, 0],
  lemonchiffon: [255, 250, 205],
  lightblue: [173, 216, 230],
  lightcoral: [240, 128, 128],
  lightcyan: [224, 255, 255],
  lightgoldenrodyellow: [250, 250, 210],
  lightgray: [211, 211, 211],
  lightgreen: [144, 238, 144],
  lightgrey: [211, 211, 211],
  lightpink: [255, 182, 193],
  lightsalmon: [255, 160, 122],
  lightseagreen: [32, 178, 170],
  lightskyblue: [135, 206, 250],
  lightslategray: [119, 136, 153],
  lightslategrey: [119, 136, 153],
  lightsteelblue: [176, 196, 222],
  lightyellow: [255, 255, 224],
  lime: [0, 255, 0],
  limegreen: [50, 205, 50],
  linen: [250, 240, 230],
  magenta: [255, 0, 255],
  maroon: [128, 0, 0],
  mediumaquamarine: [102, 205, 170],
  mediumblue: [0, 0, 205],
  mediumorchid: [186, 85, 211],
  mediumpurple: [147, 112, 219],
  mediumseagreen: [60, 179, 113],
  mediumslateblue: [123, 104, 238],
  mediumspringgreen: [0, 250, 154],
  mediumturquoise: [72, 209, 204],
  mediumvioletred: [199, 21, 133],
  midnightblue: [25, 25, 112],
  mintcream: [245, 255, 250],
  mistyrose: [255, 228, 225],
  moccasin: [255, 228, 181],
  navajowhite: [255, 222, 173],
  navy: [0, 0, 128],
  oldlace: [253, 245, 230],
  olive: [128, 128, 0],
  olivedrab: [107, 142, 35],
  orange: [255, 165, 0],
  orangered: [255, 69, 0],
  orchid: [218, 112, 214],
  palegoldenrod: [238, 232, 170],
  palegreen: [152, 251, 152],
  paleturquoise: [175, 238, 238],
  palevioletred: [219, 112, 147],
  papayawhip: [255, 239, 213],
  peachpuff: [255, 218, 185],
  peru: [205, 133, 63],
  pink: [255, 192, 203],
  plum: [221, 160, 221],
  powderblue: [176, 224, 230],
  purple: [128, 0, 128],
  red: [255, 0, 0],
  rosybrown: [188, 143, 143],
  royalblue: [65, 105, 225],
  saddlebrown: [139, 69, 19],
  salmon: [250, 128, 114],
  sandybrown: [244, 164, 96],
  seagreen: [46, 139, 87],
  seashell: [255, 245, 238],
  sienna: [160, 82, 45],
  silver: [192, 192, 192],
  skyblue: [135, 206, 235],
  slateblue: [106, 90, 205],
  slategray: [112, 128, 144],
  slategrey: [112, 128, 144],
  snow: [255, 250, 250],
  springgreen: [0, 255, 127],
  steelblue: [70, 130, 180],
  tan: [210, 180, 140],
  teal: [0, 128, 128],
  thistle: [216, 191, 216],
  tomato: [255, 99, 71],
  turquoise: [64, 224, 208],
  violet: [238, 130, 238],
  wheat: [245, 222, 179],
  white: [255, 255, 255],
  whitesmoke: [245, 245, 245],
  yellow: [255, 255, 0],
  yellowgreen: [154, 205, 50]
}, hf = function(e) {
  for (var r = e.map, a = e.keys, n = a.length, i = 0; i < n; i++) {
    var o = a[i];
    if (Ie(o))
      throw Error("Tried to set map with object key");
    i < a.length - 1 ? (r[o] == null && (r[o] = {}), r = r[o]) : r[o] = e.value;
  }
}, df = function(e) {
  for (var r = e.map, a = e.keys, n = a.length, i = 0; i < n; i++) {
    var o = a[i];
    if (Ie(o))
      throw Error("Tried to get map with object key");
    if (r = r[o], r == null)
      return r;
  }
  return r;
}, Wa = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Na(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var ti, Rs;
function Ba() {
  if (Rs) return ti;
  Rs = 1;
  function t(e) {
    var r = typeof e;
    return e != null && (r == "object" || r == "function");
  }
  return ti = t, ti;
}
var ri, Ms;
function Gc() {
  if (Ms) return ri;
  Ms = 1;
  var t = typeof Wa == "object" && Wa && Wa.Object === Object && Wa;
  return ri = t, ri;
}
var ai, Ps;
function Bn() {
  if (Ps) return ai;
  Ps = 1;
  var t = Gc(), e = typeof self == "object" && self && self.Object === Object && self, r = t || e || Function("return this")();
  return ai = r, ai;
}
var ni, Is;
function zc() {
  if (Is) return ni;
  Is = 1;
  var t = Bn(), e = function() {
    return t.Date.now();
  };
  return ni = e, ni;
}
var ii, Os;
function _c() {
  if (Os) return ii;
  Os = 1;
  var t = /\s/;
  function e(r) {
    for (var a = r.length; a-- && t.test(r.charAt(a)); )
      ;
    return a;
  }
  return ii = e, ii;
}
var oi, ks;
function Vc() {
  if (ks) return oi;
  ks = 1;
  var t = _c(), e = /^\s+/;
  function r(a) {
    return a && a.slice(0, t(a) + 1).replace(e, "");
  }
  return oi = r, oi;
}
var si, Ns;
function ts() {
  if (Ns) return si;
  Ns = 1;
  var t = Bn(), e = t.Symbol;
  return si = e, si;
}
var ui, Bs;
function Uc() {
  if (Bs) return ui;
  Bs = 1;
  var t = ts(), e = Object.prototype, r = e.hasOwnProperty, a = e.toString, n = t ? t.toStringTag : void 0;
  function i(o) {
    var s = r.call(o, n), u = o[n];
    try {
      o[n] = void 0;
      var l = !0;
    } catch {
    }
    var f = a.call(o);
    return l && (s ? o[n] = u : delete o[n]), f;
  }
  return ui = i, ui;
}
var li, Fs;
function qc() {
  if (Fs) return li;
  Fs = 1;
  var t = Object.prototype, e = t.toString;
  function r(a) {
    return e.call(a);
  }
  return li = r, li;
}
var fi, Gs;
function gf() {
  if (Gs) return fi;
  Gs = 1;
  var t = ts(), e = Uc(), r = qc(), a = "[object Null]", n = "[object Undefined]", i = t ? t.toStringTag : void 0;
  function o(s) {
    return s == null ? s === void 0 ? n : a : i && i in Object(s) ? e(s) : r(s);
  }
  return fi = o, fi;
}
var vi, zs;
function Yc() {
  if (zs) return vi;
  zs = 1;
  function t(e) {
    return e != null && typeof e == "object";
  }
  return vi = t, vi;
}
var ci, _s;
function Fa() {
  if (_s) return ci;
  _s = 1;
  var t = gf(), e = Yc(), r = "[object Symbol]";
  function a(n) {
    return typeof n == "symbol" || e(n) && t(n) == r;
  }
  return ci = a, ci;
}
var hi, Vs;
function Hc() {
  if (Vs) return hi;
  Vs = 1;
  var t = Vc(), e = Ba(), r = Fa(), a = NaN, n = /^[-+]0x[0-9a-f]+$/i, i = /^0b[01]+$/i, o = /^0o[0-7]+$/i, s = parseInt;
  function u(l) {
    if (typeof l == "number")
      return l;
    if (r(l))
      return a;
    if (e(l)) {
      var f = typeof l.valueOf == "function" ? l.valueOf() : l;
      l = e(f) ? f + "" : f;
    }
    if (typeof l != "string")
      return l === 0 ? l : +l;
    l = t(l);
    var v = i.test(l);
    return v || o.test(l) ? s(l.slice(2), v ? 2 : 8) : n.test(l) ? a : +l;
  }
  return hi = u, hi;
}
var di, Us;
function Xc() {
  if (Us) return di;
  Us = 1;
  var t = Ba(), e = zc(), r = Hc(), a = "Expected a function", n = Math.max, i = Math.min;
  function o(s, u, l) {
    var f, v, c, h, d, g, p = 0, y = !1, b = !1, m = !0;
    if (typeof s != "function")
      throw new TypeError(a);
    u = r(u) || 0, t(l) && (y = !!l.leading, b = "maxWait" in l, c = b ? n(r(l.maxWait) || 0, u) : c, m = "trailing" in l ? !!l.trailing : m);
    function E(R) {
      var P = f, I = v;
      return f = v = void 0, p = R, h = s.apply(I, P), h;
    }
    function C(R) {
      return p = R, d = setTimeout(x, u), y ? E(R) : h;
    }
    function S(R) {
      var P = R - g, I = R - p, k = u - P;
      return b ? i(k, c - I) : k;
    }
    function w(R) {
      var P = R - g, I = R - p;
      return g === void 0 || P >= u || P < 0 || b && I >= c;
    }
    function x() {
      var R = e();
      if (w(R))
        return T(R);
      d = setTimeout(x, S(R));
    }
    function T(R) {
      return d = void 0, m && f ? E(R) : (f = v = void 0, h);
    }
    function D() {
      d !== void 0 && clearTimeout(d), p = 0, f = g = v = d = void 0;
    }
    function A() {
      return d === void 0 ? h : T(e());
    }
    function L() {
      var R = e(), P = w(R);
      if (f = arguments, v = this, g = R, P) {
        if (d === void 0)
          return C(g);
        if (b)
          return clearTimeout(d), d = setTimeout(x, u), E(g);
      }
      return d === void 0 && (d = setTimeout(x, u)), h;
    }
    return L.cancel = D, L.flush = A, L;
  }
  return di = o, di;
}
var Wc = Xc(), Ga = /* @__PURE__ */ Na(Wc), gi = je ? je.performance : null, pf = gi && gi.now ? function() {
  return gi.now();
} : function() {
  return Date.now();
}, $c = (function() {
  if (je) {
    if (je.requestAnimationFrame)
      return function(t) {
        je.requestAnimationFrame(t);
      };
    if (je.mozRequestAnimationFrame)
      return function(t) {
        je.mozRequestAnimationFrame(t);
      };
    if (je.webkitRequestAnimationFrame)
      return function(t) {
        je.webkitRequestAnimationFrame(t);
      };
    if (je.msRequestAnimationFrame)
      return function(t) {
        je.msRequestAnimationFrame(t);
      };
  }
  return function(t) {
    t && setTimeout(function() {
      t(pf());
    }, 1e3 / 60);
  };
})(), Tn = function(e) {
  return $c(e);
}, $t = pf, Tr = 9261, yf = 65599, Vr = 5381, mf = function(e) {
  for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Tr, a = r, n; n = e.next(), !n.done; )
    a = a * yf + n.value | 0;
  return a;
}, Ta = function(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Tr;
  return r * yf + e | 0;
}, Ca = function(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Vr;
  return (r << 5) + r + e | 0;
}, Kc = function(e, r) {
  return e * 2097152 + r;
}, jt = function(e) {
  return e[0] * 2097152 + e[1];
}, $a = function(e, r) {
  return [Ta(e[0], r[0]), Ca(e[1], r[1])];
}, qs = function(e, r) {
  var a = {
    value: 0,
    done: !1
  }, n = 0, i = e.length, o = {
    next: function() {
      return n < i ? a.value = e[n++] : a.done = !0, a;
    }
  };
  return mf(o, r);
}, Sr = function(e, r) {
  var a = {
    value: 0,
    done: !1
  }, n = 0, i = e.length, o = {
    next: function() {
      return n < i ? a.value = e.charCodeAt(n++) : a.done = !0, a;
    }
  };
  return mf(o, r);
}, bf = function() {
  return Zc(arguments);
}, Zc = function(e) {
  for (var r, a = 0; a < e.length; a++) {
    var n = e[a];
    a === 0 ? r = Sr(n) : r = Sr(n, r);
  }
  return r;
};
function Qc(t, e, r, a, n) {
  var i = n * Math.PI / 180, o = Math.cos(i) * (t - r) - Math.sin(i) * (e - a) + r, s = Math.sin(i) * (t - r) + Math.cos(i) * (e - a) + a;
  return {
    x: o,
    y: s
  };
}
var Jc = function(e, r, a, n, i, o) {
  return {
    x: (e - a) * i + a,
    y: (r - n) * o + n
  };
};
function jc(t, e, r) {
  if (r === 0) return t;
  var a = (e.x1 + e.x2) / 2, n = (e.y1 + e.y2) / 2, i = e.w / e.h, o = 1 / i, s = Qc(t.x, t.y, a, n, r), u = Jc(s.x, s.y, a, n, i, o);
  return {
    x: u.x,
    y: u.y
  };
}
var Ys = !0, eh = console.warn != null, th = console.trace != null, rs = Number.MAX_SAFE_INTEGER || 9007199254740991, wf = function() {
  return !0;
}, Cn = function() {
  return !1;
}, Hs = function() {
  return 0;
}, as = function() {
}, qe = function(e) {
  throw new Error(e);
}, Ef = function(e) {
  if (e !== void 0)
    Ys = !!e;
  else
    return Ys;
}, Fe = function(e) {
  Ef() && (eh ? console.warn(e) : (console.log(e), th && console.trace()));
}, rh = function(e) {
  return ye({}, e);
}, Vt = function(e) {
  return e == null ? e : ze(e) ? e.slice() : Ie(e) ? rh(e) : e;
}, ah = function(e) {
  return e.slice();
}, xf = function(e, r) {
  for (
    // loop :)
    r = e = "";
    // b - result , a - numeric letiable
    e++ < 36;
    //
    r += e * 51 & 52 ? (
      //  return a random number or 4
      (e ^ 15 ? (
        // generate a random number from 0 to 15
        8 ^ Math.random() * (e ^ 20 ? 16 : 4)
      ) : 4).toString(16)
    ) : "-"
  ) ;
  return r;
}, nh = {}, Tf = function() {
  return nh;
}, ft = function(e) {
  var r = Object.keys(e);
  return function(a) {
    for (var n = {}, i = 0; i < r.length; i++) {
      var o = r[i], s = a?.[o];
      n[o] = s === void 0 ? e[o] : s;
    }
    return n;
  };
}, ur = function(e, r, a) {
  for (var n = e.length - 1; n >= 0; n--)
    e[n] === r && e.splice(n, 1);
}, ns = function(e) {
  e.splice(0, e.length);
}, ih = function(e, r) {
  for (var a = 0; a < r.length; a++) {
    var n = r[a];
    e.push(n);
  }
}, yt = function(e, r, a) {
  return a && (r = ff(a, r)), e[r];
}, _t = function(e, r, a, n) {
  a && (r = ff(a, r)), e[r] = n;
}, oh = /* @__PURE__ */ (function() {
  function t() {
    hr(this, t), this._obj = {};
  }
  return dr(t, [{
    key: "set",
    value: function(r, a) {
      return this._obj[r] = a, this;
    }
  }, {
    key: "delete",
    value: function(r) {
      return this._obj[r] = void 0, this;
    }
  }, {
    key: "clear",
    value: function() {
      this._obj = {};
    }
  }, {
    key: "has",
    value: function(r) {
      return this._obj[r] !== void 0;
    }
  }, {
    key: "get",
    value: function(r) {
      return this._obj[r];
    }
  }]);
})(), Wt = typeof Map < "u" ? Map : oh, sh = "undefined", uh = /* @__PURE__ */ (function() {
  function t(e) {
    if (hr(this, t), this._obj = /* @__PURE__ */ Object.create(null), this.size = 0, e != null) {
      var r;
      e.instanceString != null && e.instanceString() === this.instanceString() ? r = e.toArray() : r = e;
      for (var a = 0; a < r.length; a++)
        this.add(r[a]);
    }
  }
  return dr(t, [{
    key: "instanceString",
    value: function() {
      return "set";
    }
  }, {
    key: "add",
    value: function(r) {
      var a = this._obj;
      a[r] !== 1 && (a[r] = 1, this.size++);
    }
  }, {
    key: "delete",
    value: function(r) {
      var a = this._obj;
      a[r] === 1 && (a[r] = 0, this.size--);
    }
  }, {
    key: "clear",
    value: function() {
      this._obj = /* @__PURE__ */ Object.create(null);
    }
  }, {
    key: "has",
    value: function(r) {
      return this._obj[r] === 1;
    }
  }, {
    key: "toArray",
    value: function() {
      var r = this;
      return Object.keys(this._obj).filter(function(a) {
        return r.has(a);
      });
    }
  }, {
    key: "forEach",
    value: function(r, a) {
      return this.toArray().forEach(r, a);
    }
  }]);
})(), ta = (typeof Set > "u" ? "undefined" : tt(Set)) !== sh ? Set : uh, Fn = function(e, r) {
  var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0;
  if (e === void 0 || r === void 0 || !jo(e)) {
    qe("An element must have a core reference and parameters set");
    return;
  }
  var n = r.group;
  if (n == null && (r.data && r.data.source != null && r.data.target != null ? n = "edges" : n = "nodes"), n !== "nodes" && n !== "edges") {
    qe("An element must be of type `nodes` or `edges`; you specified `" + n + "`");
    return;
  }
  this.length = 1, this[0] = this;
  var i = this._private = {
    cy: e,
    single: !0,
    // indicates this is an element
    data: r.data || {},
    // data object
    position: r.position || {
      x: 0,
      y: 0
    },
    // (x, y) position pair
    autoWidth: void 0,
    // width and height of nodes calculated by the renderer when set to special 'auto' value
    autoHeight: void 0,
    autoPadding: void 0,
    compoundBoundsClean: !1,
    // whether the compound dimensions need to be recalculated the next time dimensions are read
    listeners: [],
    // array of bound listeners
    group: n,
    // string; 'nodes' or 'edges'
    style: {},
    // properties as set by the style
    rstyle: {},
    // properties for style sent from the renderer to the core
    styleCxts: [],
    // applied style contexts from the styler
    styleKeys: {},
    // per-group keys of style property values
    removed: !0,
    // whether it's inside the vis; true if removed (set true here since we call restore)
    selected: !!r.selected,
    // whether it's selected
    selectable: r.selectable === void 0 ? !0 : !!r.selectable,
    // whether it's selectable
    locked: !!r.locked,
    // whether the element is locked (cannot be moved)
    grabbed: !1,
    // whether the element is grabbed by the mouse; renderer sets this privately
    grabbable: r.grabbable === void 0 ? !0 : !!r.grabbable,
    // whether the element can be grabbed
    pannable: r.pannable === void 0 ? n === "edges" : !!r.pannable,
    // whether the element has passthrough panning enabled
    active: !1,
    // whether the element is active from user interaction
    classes: new ta(),
    // map ( className => true )
    animation: {
      // object for currently-running animations
      current: [],
      queue: []
    },
    rscratch: {},
    // object in which the renderer can store information
    scratch: r.scratch || {},
    // scratch objects
    edges: [],
    // array of connected edges
    children: [],
    // array of children
    parent: r.parent && r.parent.isNode() ? r.parent : null,
    // parent ref
    traversalCache: {},
    // cache of output of traversal functions
    backgrounding: !1,
    // whether background images are loading
    bbCache: null,
    // cache of the current bounding box
    bbCacheShift: {
      x: 0,
      y: 0
    },
    // shift applied to cached bb to be applied on next get
    bodyBounds: null,
    // bounds cache of element body, w/o overlay
    overlayBounds: null,
    // bounds cache of element body, including overlay
    labelBounds: {
      // bounds cache of labels
      all: null,
      source: null,
      target: null,
      main: null
    },
    arrowBounds: {
      // bounds cache of edge arrows
      source: null,
      target: null,
      "mid-source": null,
      "mid-target": null
    }
  };
  if (i.position.x == null && (i.position.x = 0), i.position.y == null && (i.position.y = 0), r.renderedPosition) {
    var o = r.renderedPosition, s = e.pan(), u = e.zoom();
    i.position = {
      x: (o.x - s.x) / u,
      y: (o.y - s.y) / u
    };
  }
  var l = [];
  ze(r.classes) ? l = r.classes : de(r.classes) && (l = r.classes.split(/\s+/));
  for (var f = 0, v = l.length; f < v; f++) {
    var c = l[f];
    !c || c === "" || i.classes.add(c);
  }
  this.createEmitter(), (a === void 0 || a) && this.restore();
  var h = r.style || r.css;
  h && (Fe("Setting a `style` bypass at element creation should be done only when absolutely necessary.  Try to use the stylesheet instead."), this.style(h));
}, Xs = function(e) {
  return e = {
    bfs: e.bfs || !e.dfs,
    dfs: e.dfs || !e.bfs
  }, function(a, n, i) {
    var o;
    Ie(a) && !Ct(a) && (o = a, a = o.roots || o.root, n = o.visit, i = o.directed), i = arguments.length === 2 && !He(n) ? n : i, n = He(n) ? n : function() {
    };
    for (var s = this._private.cy, u = a = de(a) ? this.filter(a) : a, l = [], f = [], v = {}, c = {}, h = {}, d = 0, g, p = this.byGroup(), y = p.nodes, b = p.edges, m = 0; m < u.length; m++) {
      var E = u[m], C = E.id();
      E.isNode() && (l.unshift(E), e.bfs && (h[C] = !0, f.push(E)), c[C] = 0);
    }
    for (var S = function() {
      var R = e.bfs ? l.shift() : l.pop(), P = R.id();
      if (e.dfs) {
        if (h[P])
          return 0;
        h[P] = !0, f.push(R);
      }
      var I = c[P], k = v[P], O = k != null ? k.source() : null, N = k != null ? k.target() : null, F = k == null ? void 0 : R.same(O) ? N[0] : O[0], G;
      if (G = n(R, k, F, d++, I), G === !0)
        return g = R, 1;
      if (G === !1)
        return 1;
      for (var B = R.connectedEdges().filter(function(j) {
        return (!i || j.source().same(R)) && b.has(j);
      }), z = 0; z < B.length; z++) {
        var Y = B[z], $ = Y.connectedNodes().filter(function(j) {
          return !j.same(R) && y.has(j);
        }), X = $.id();
        $.length !== 0 && !h[X] && ($ = $[0], l.push($), e.bfs && (h[X] = !0, f.push($)), v[X] = Y, c[X] = c[P] + 1);
      }
    }, w; l.length !== 0 && (w = S(), !(w !== 0 && w === 1)); )
      ;
    for (var x = s.collection(), T = 0; T < f.length; T++) {
      var D = f[T], A = v[D.id()];
      A != null && x.push(A), x.push(D);
    }
    return {
      path: s.collection(x),
      found: s.collection(g)
    };
  };
}, Da = {
  breadthFirstSearch: Xs({
    bfs: !0
  }),
  depthFirstSearch: Xs({
    dfs: !0
  })
};
Da.bfs = Da.breadthFirstSearch;
Da.dfs = Da.depthFirstSearch;
var sn = { exports: {} }, lh = sn.exports, Ws;
function fh() {
  return Ws || (Ws = 1, (function(t, e) {
    (function() {
      var r, a, n, i, o, s, u, l, f, v, c, h, d, g, p;
      n = Math.floor, v = Math.min, a = function(y, b) {
        return y < b ? -1 : y > b ? 1 : 0;
      }, f = function(y, b, m, E, C) {
        var S;
        if (m == null && (m = 0), C == null && (C = a), m < 0)
          throw new Error("lo must be non-negative");
        for (E == null && (E = y.length); m < E; )
          S = n((m + E) / 2), C(b, y[S]) < 0 ? E = S : m = S + 1;
        return [].splice.apply(y, [m, m - m].concat(b)), b;
      }, s = function(y, b, m) {
        return m == null && (m = a), y.push(b), g(y, 0, y.length - 1, m);
      }, o = function(y, b) {
        var m, E;
        return b == null && (b = a), m = y.pop(), y.length ? (E = y[0], y[0] = m, p(y, 0, b)) : E = m, E;
      }, l = function(y, b, m) {
        var E;
        return m == null && (m = a), E = y[0], y[0] = b, p(y, 0, m), E;
      }, u = function(y, b, m) {
        var E;
        return m == null && (m = a), y.length && m(y[0], b) < 0 && (E = [y[0], b], b = E[0], y[0] = E[1], p(y, 0, m)), b;
      }, i = function(y, b) {
        var m, E, C, S, w, x;
        for (b == null && (b = a), S = (function() {
          x = [];
          for (var T = 0, D = n(y.length / 2); 0 <= D ? T < D : T > D; 0 <= D ? T++ : T--)
            x.push(T);
          return x;
        }).apply(this).reverse(), w = [], E = 0, C = S.length; E < C; E++)
          m = S[E], w.push(p(y, m, b));
        return w;
      }, d = function(y, b, m) {
        var E;
        if (m == null && (m = a), E = y.indexOf(b), E !== -1)
          return g(y, 0, E, m), p(y, E, m);
      }, c = function(y, b, m) {
        var E, C, S, w, x;
        if (m == null && (m = a), C = y.slice(0, b), !C.length)
          return C;
        for (i(C, m), x = y.slice(b), S = 0, w = x.length; S < w; S++)
          E = x[S], u(C, E, m);
        return C.sort(m).reverse();
      }, h = function(y, b, m) {
        var E, C, S, w, x, T, D, A, L;
        if (m == null && (m = a), b * 10 <= y.length) {
          if (S = y.slice(0, b).sort(m), !S.length)
            return S;
          for (C = S[S.length - 1], D = y.slice(b), w = 0, T = D.length; w < T; w++)
            E = D[w], m(E, C) < 0 && (f(S, E, 0, null, m), S.pop(), C = S[S.length - 1]);
          return S;
        }
        for (i(y, m), L = [], x = 0, A = v(b, y.length); 0 <= A ? x < A : x > A; 0 <= A ? ++x : --x)
          L.push(o(y, m));
        return L;
      }, g = function(y, b, m, E) {
        var C, S, w;
        for (E == null && (E = a), C = y[m]; m > b; ) {
          if (w = m - 1 >> 1, S = y[w], E(C, S) < 0) {
            y[m] = S, m = w;
            continue;
          }
          break;
        }
        return y[m] = C;
      }, p = function(y, b, m) {
        var E, C, S, w, x;
        for (m == null && (m = a), C = y.length, x = b, S = y[b], E = 2 * b + 1; E < C; )
          w = E + 1, w < C && !(m(y[E], y[w]) < 0) && (E = w), y[b] = y[E], b = E, E = 2 * b + 1;
        return y[b] = S, g(y, x, b, m);
      }, r = (function() {
        y.push = s, y.pop = o, y.replace = l, y.pushpop = u, y.heapify = i, y.updateItem = d, y.nlargest = c, y.nsmallest = h;
        function y(b) {
          this.cmp = b ?? a, this.nodes = [];
        }
        return y.prototype.push = function(b) {
          return s(this.nodes, b, this.cmp);
        }, y.prototype.pop = function() {
          return o(this.nodes, this.cmp);
        }, y.prototype.peek = function() {
          return this.nodes[0];
        }, y.prototype.contains = function(b) {
          return this.nodes.indexOf(b) !== -1;
        }, y.prototype.replace = function(b) {
          return l(this.nodes, b, this.cmp);
        }, y.prototype.pushpop = function(b) {
          return u(this.nodes, b, this.cmp);
        }, y.prototype.heapify = function() {
          return i(this.nodes, this.cmp);
        }, y.prototype.updateItem = function(b) {
          return d(this.nodes, b, this.cmp);
        }, y.prototype.clear = function() {
          return this.nodes = [];
        }, y.prototype.empty = function() {
          return this.nodes.length === 0;
        }, y.prototype.size = function() {
          return this.nodes.length;
        }, y.prototype.clone = function() {
          var b;
          return b = new y(), b.nodes = this.nodes.slice(0), b;
        }, y.prototype.toArray = function() {
          return this.nodes.slice(0);
        }, y.prototype.insert = y.prototype.push, y.prototype.top = y.prototype.peek, y.prototype.front = y.prototype.peek, y.prototype.has = y.prototype.contains, y.prototype.copy = y.prototype.clone, y;
      })(), (function(y, b) {
        return t.exports = b();
      })(this, function() {
        return r;
      });
    }).call(lh);
  })(sn)), sn.exports;
}
var pi, $s;
function vh() {
  return $s || ($s = 1, pi = fh()), pi;
}
var ch = vh(), za = /* @__PURE__ */ Na(ch), hh = ft({
  root: null,
  weight: function(e) {
    return 1;
  },
  directed: !1
}), dh = {
  dijkstra: function(e) {
    if (!Ie(e)) {
      var r = arguments;
      e = {
        root: r[0],
        weight: r[1],
        directed: r[2]
      };
    }
    var a = hh(e), n = a.root, i = a.weight, o = a.directed, s = this, u = i, l = de(n) ? this.filter(n)[0] : n[0], f = {}, v = {}, c = {}, h = this.byGroup(), d = h.nodes, g = h.edges;
    g.unmergeBy(function(I) {
      return I.isLoop();
    });
    for (var p = function(k) {
      return f[k.id()];
    }, y = function(k, O) {
      f[k.id()] = O, b.updateItem(k);
    }, b = new za(function(I, k) {
      return p(I) - p(k);
    }), m = 0; m < d.length; m++) {
      var E = d[m];
      f[E.id()] = E.same(l) ? 0 : 1 / 0, b.push(E);
    }
    for (var C = function(k, O) {
      for (var N = (o ? k.edgesTo(O) : k.edgesWith(O)).intersect(g), F = 1 / 0, G, B = 0; B < N.length; B++) {
        var z = N[B], Y = u(z);
        (Y < F || !G) && (F = Y, G = z);
      }
      return {
        edge: G,
        dist: F
      };
    }; b.size() > 0; ) {
      var S = b.pop(), w = p(S), x = S.id();
      if (c[x] = w, w !== 1 / 0)
        for (var T = S.neighborhood().intersect(d), D = 0; D < T.length; D++) {
          var A = T[D], L = A.id(), R = C(S, A), P = w + R.dist;
          P < p(A) && (y(A, P), v[L] = {
            node: S,
            edge: R.edge
          });
        }
    }
    return {
      distanceTo: function(k) {
        var O = de(k) ? d.filter(k)[0] : k[0];
        return c[O.id()];
      },
      pathTo: function(k) {
        var O = de(k) ? d.filter(k)[0] : k[0], N = [], F = O, G = F.id();
        if (O.length > 0)
          for (N.unshift(O); v[G]; ) {
            var B = v[G];
            N.unshift(B.edge), N.unshift(B.node), F = B.node, G = F.id();
          }
        return s.spawn(N);
      }
    };
  }
}, gh = {
  // kruskal's algorithm (finds min spanning tree, assuming undirected graph)
  // implemented from pseudocode from wikipedia
  kruskal: function(e) {
    e = e || function(m) {
      return 1;
    };
    for (var r = this.byGroup(), a = r.nodes, n = r.edges, i = a.length, o = new Array(i), s = a, u = function(E) {
      for (var C = 0; C < o.length; C++) {
        var S = o[C];
        if (S.has(E))
          return C;
      }
    }, l = 0; l < i; l++)
      o[l] = this.spawn(a[l]);
    for (var f = n.sort(function(m, E) {
      return e(m) - e(E);
    }), v = 0; v < f.length; v++) {
      var c = f[v], h = c.source()[0], d = c.target()[0], g = u(h), p = u(d), y = o[g], b = o[p];
      g !== p && (s.merge(c), y.merge(b), o.splice(p, 1));
    }
    return s;
  }
}, ph = ft({
  root: null,
  goal: null,
  weight: function(e) {
    return 1;
  },
  heuristic: function(e) {
    return 0;
  },
  directed: !1
}), yh = {
  // Implemented from pseudocode from wikipedia
  aStar: function(e) {
    var r = this.cy(), a = ph(e), n = a.root, i = a.goal, o = a.heuristic, s = a.directed, u = a.weight;
    n = r.collection(n)[0], i = r.collection(i)[0];
    var l = n.id(), f = i.id(), v = {}, c = {}, h = {}, d = new za(function(G, B) {
      return c[G.id()] - c[B.id()];
    }), g = new ta(), p = {}, y = {}, b = function(B, z) {
      d.push(B), g.add(z);
    }, m, E, C = function() {
      m = d.pop(), E = m.id(), g.delete(E);
    }, S = function(B) {
      return g.has(B);
    };
    b(n, l), v[l] = 0, c[l] = o(n);
    for (var w = 0; d.size() > 0; ) {
      if (C(), w++, E === f) {
        for (var x = [], T = i, D = f, A = y[D]; x.unshift(T), A != null && x.unshift(A), T = p[D], T != null; )
          D = T.id(), A = y[D];
        return {
          found: !0,
          distance: v[E],
          path: this.spawn(x),
          steps: w
        };
      }
      h[E] = !0;
      for (var L = m._private.edges, R = 0; R < L.length; R++) {
        var P = L[R];
        if (this.hasElementWithId(P.id()) && !(s && P.data("source") !== E)) {
          var I = P.source(), k = P.target(), O = I.id() !== E ? I : k, N = O.id();
          if (this.hasElementWithId(N) && !h[N]) {
            var F = v[E] + u(P);
            if (!S(N)) {
              v[N] = F, c[N] = F + o(O), b(O, N), p[N] = m, y[N] = P;
              continue;
            }
            F < v[N] && (v[N] = F, c[N] = F + o(O), p[N] = m, y[N] = P);
          }
        }
      }
    }
    return {
      found: !1,
      distance: void 0,
      path: void 0,
      steps: w
    };
  }
}, mh = ft({
  weight: function(e) {
    return 1;
  },
  directed: !1
}), bh = {
  // Implemented from pseudocode from wikipedia
  floydWarshall: function(e) {
    for (var r = this.cy(), a = mh(e), n = a.weight, i = a.directed, o = n, s = this.byGroup(), u = s.nodes, l = s.edges, f = u.length, v = f * f, c = function(Y) {
      return u.indexOf(Y);
    }, h = function(Y) {
      return u[Y];
    }, d = new Array(v), g = 0; g < v; g++) {
      var p = g % f, y = (g - p) / f;
      y === p ? d[g] = 0 : d[g] = 1 / 0;
    }
    for (var b = new Array(v), m = new Array(v), E = 0; E < l.length; E++) {
      var C = l[E], S = C.source()[0], w = C.target()[0];
      if (S !== w) {
        var x = c(S), T = c(w), D = x * f + T, A = o(C);
        if (d[D] > A && (d[D] = A, b[D] = T, m[D] = C), !i) {
          var L = T * f + x;
          !i && d[L] > A && (d[L] = A, b[L] = x, m[L] = C);
        }
      }
    }
    for (var R = 0; R < f; R++)
      for (var P = 0; P < f; P++)
        for (var I = P * f + R, k = 0; k < f; k++) {
          var O = P * f + k, N = R * f + k;
          d[I] + d[N] < d[O] && (d[O] = d[I] + d[N], b[O] = b[I]);
        }
    var F = function(Y) {
      return (de(Y) ? r.filter(Y) : Y)[0];
    }, G = function(Y) {
      return c(F(Y));
    }, B = {
      distance: function(Y, $) {
        var X = G(Y), j = G($);
        return d[X * f + j];
      },
      path: function(Y, $) {
        var X = G(Y), j = G($), ee = h(X);
        if (X === j)
          return ee.collection();
        if (b[X * f + j] == null)
          return r.collection();
        var ae = r.collection(), K = X, V;
        for (ae.merge(ee); X !== j; )
          K = X, X = b[X * f + j], V = m[K * f + X], ae.merge(V), ae.merge(h(X));
        return ae;
      }
    };
    return B;
  }
  // floydWarshall
}, wh = ft({
  weight: function(e) {
    return 1;
  },
  directed: !1,
  root: null
}), Eh = {
  // Implemented from pseudocode from wikipedia
  bellmanFord: function(e) {
    var r = this, a = wh(e), n = a.weight, i = a.directed, o = a.root, s = n, u = this, l = this.cy(), f = this.byGroup(), v = f.edges, c = f.nodes, h = c.length, d = new Wt(), g = !1, p = [];
    o = l.collection(o)[0], v.unmergeBy(function(we) {
      return we.isLoop();
    });
    for (var y = v.length, b = function(me) {
      var ge = d.get(me.id());
      return ge || (ge = {}, d.set(me.id(), ge)), ge;
    }, m = function(me) {
      return (de(me) ? l.$(me) : me)[0];
    }, E = function(me) {
      return b(m(me)).dist;
    }, C = function(me) {
      for (var ge = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : o, oe = m(me), he = [], ce = oe; ; ) {
        if (ce == null)
          return r.spawn();
        var Ee = b(ce), be = Ee.edge, De = Ee.pred;
        if (he.unshift(ce[0]), ce.same(ge) && he.length > 0)
          break;
        be != null && he.unshift(be), ce = De;
      }
      return u.spawn(he);
    }, S = 0; S < h; S++) {
      var w = c[S], x = b(w);
      w.same(o) ? x.dist = 0 : x.dist = 1 / 0, x.pred = null, x.edge = null;
    }
    for (var T = !1, D = function(me, ge, oe, he, ce, Ee) {
      var be = he.dist + Ee;
      be < ce.dist && !oe.same(he.edge) && (ce.dist = be, ce.pred = me, ce.edge = oe, T = !0);
    }, A = 1; A < h; A++) {
      T = !1;
      for (var L = 0; L < y; L++) {
        var R = v[L], P = R.source(), I = R.target(), k = s(R), O = b(P), N = b(I);
        D(P, I, R, O, N, k), i || D(I, P, R, N, O, k);
      }
      if (!T)
        break;
    }
    if (T)
      for (var F = [], G = 0; G < y; G++) {
        var B = v[G], z = B.source(), Y = B.target(), $ = s(B), X = b(z).dist, j = b(Y).dist;
        if (X + $ < j || !i && j + $ < X)
          if (g || (Fe("Graph contains a negative weight cycle for Bellman-Ford"), g = !0), e.findNegativeWeightCycles !== !1) {
            var ee = [];
            X + $ < j && ee.push(z), !i && j + $ < X && ee.push(Y);
            for (var ae = ee.length, K = 0; K < ae; K++) {
              var V = ee[K], q = [V];
              q.push(b(V).edge);
              for (var H = b(V).pred; q.indexOf(H) === -1; )
                q.push(H), q.push(b(H).edge), H = b(H).pred;
              q = q.slice(q.indexOf(H));
              for (var Z = q[0].id(), re = 0, le = 2; le < q.length; le += 2)
                q[le].id() < Z && (Z = q[le].id(), re = le);
              q = q.slice(re).concat(q.slice(0, re)), q.push(q[0]);
              var Ae = q.map(function(we) {
                return we.id();
              }).join(",");
              F.indexOf(Ae) === -1 && (p.push(u.spawn(q)), F.push(Ae));
            }
          } else
            break;
      }
    return {
      distanceTo: E,
      pathTo: C,
      hasNegativeWeightCycle: g,
      negativeWeightCycles: p
    };
  }
  // bellmanFord
}, xh = Math.sqrt(2), Th = function(e, r, a) {
  a.length === 0 && qe("Karger-Stein must be run on a connected (sub)graph");
  for (var n = a[e], i = n[1], o = n[2], s = r[i], u = r[o], l = a, f = l.length - 1; f >= 0; f--) {
    var v = l[f], c = v[1], h = v[2];
    (r[c] === s && r[h] === u || r[c] === u && r[h] === s) && l.splice(f, 1);
  }
  for (var d = 0; d < l.length; d++) {
    var g = l[d];
    g[1] === u ? (l[d] = g.slice(), l[d][1] = s) : g[2] === u && (l[d] = g.slice(), l[d][2] = s);
  }
  for (var p = 0; p < r.length; p++)
    r[p] === u && (r[p] = s);
  return l;
}, yi = function(e, r, a, n) {
  for (; a > n; ) {
    var i = Math.floor(Math.random() * r.length);
    r = Th(i, e, r), a--;
  }
  return r;
}, Ch = {
  // Computes the minimum cut of an undirected graph
  // Returns the correct answer with high probability
  kargerStein: function() {
    var e = this, r = this.byGroup(), a = r.nodes, n = r.edges;
    n.unmergeBy(function(N) {
      return N.isLoop();
    });
    var i = a.length, o = n.length, s = Math.ceil(Math.pow(Math.log(i) / Math.LN2, 2)), u = Math.floor(i / xh);
    if (i < 2) {
      qe("At least 2 nodes are required for Karger-Stein algorithm");
      return;
    }
    for (var l = [], f = 0; f < o; f++) {
      var v = n[f];
      l.push([f, a.indexOf(v.source()), a.indexOf(v.target())]);
    }
    for (var c = 1 / 0, h = [], d = new Array(i), g = new Array(i), p = new Array(i), y = function(F, G) {
      for (var B = 0; B < i; B++)
        G[B] = F[B];
    }, b = 0; b <= s; b++) {
      for (var m = 0; m < i; m++)
        g[m] = m;
      var E = yi(g, l.slice(), i, u), C = E.slice();
      y(g, p);
      var S = yi(g, E, u, 2), w = yi(p, C, u, 2);
      S.length <= w.length && S.length < c ? (c = S.length, h = S, y(g, d)) : w.length <= S.length && w.length < c && (c = w.length, h = w, y(p, d));
    }
    for (var x = this.spawn(h.map(function(N) {
      return n[N[0]];
    })), T = this.spawn(), D = this.spawn(), A = d[0], L = 0; L < d.length; L++) {
      var R = d[L], P = a[L];
      R === A ? T.merge(P) : D.merge(P);
    }
    var I = function(F) {
      var G = e.spawn();
      return F.forEach(function(B) {
        G.merge(B), B.connectedEdges().forEach(function(z) {
          e.contains(z) && !x.contains(z) && G.merge(z);
        });
      }), G;
    }, k = [I(T), I(D)], O = {
      cut: x,
      components: k,
      // n.b. partitions are included to be compatible with the old api spec
      // (could be removed in a future major version)
      partition1: T,
      partition2: D
    };
    return O;
  }
}, mi, Dh = function(e) {
  return {
    x: e.x,
    y: e.y
  };
}, Gn = function(e, r, a) {
  return {
    x: e.x * r + a.x,
    y: e.y * r + a.y
  };
}, Cf = function(e, r, a) {
  return {
    x: (e.x - a.x) / r,
    y: (e.y - a.y) / r
  };
}, Ur = function(e) {
  return {
    x: e[0],
    y: e[1]
  };
}, Sh = function(e) {
  for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = 1 / 0, i = r; i < a; i++) {
    var o = e[i];
    isFinite(o) && (n = Math.min(o, n));
  }
  return n;
}, Ah = function(e) {
  for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = -1 / 0, i = r; i < a; i++) {
    var o = e[i];
    isFinite(o) && (n = Math.max(o, n));
  }
  return n;
}, Lh = function(e) {
  for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = 0, i = 0, o = r; o < a; o++) {
    var s = e[o];
    isFinite(s) && (n += s, i++);
  }
  return n / i;
}, Rh = function(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, o = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0;
  n ? e = e.slice(r, a) : (a < e.length && e.splice(a, e.length - a), r > 0 && e.splice(0, r));
  for (var s = 0, u = e.length - 1; u >= 0; u--) {
    var l = e[u];
    o ? isFinite(l) || (e[u] = -1 / 0, s++) : e.splice(u, 1);
  }
  i && e.sort(function(c, h) {
    return c - h;
  });
  var f = e.length, v = Math.floor(f / 2);
  return f % 2 !== 0 ? e[v + 1 + s] : (e[v - 1 + s] + e[v + s]) / 2;
}, Mh = function(e) {
  return Math.PI * e / 180;
}, Ka = function(e, r) {
  return Math.atan2(r, e) - Math.PI / 2;
}, is = Math.log2 || function(t) {
  return Math.log(t) / Math.log(2);
}, os = function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Ar = function(e, r) {
  return Math.sqrt(Er(e, r));
}, Er = function(e, r) {
  var a = r.x - e.x, n = r.y - e.y;
  return a * a + n * n;
}, Ph = function(e) {
  for (var r = e.length, a = 0, n = 0; n < r; n++)
    a += e[n];
  for (var i = 0; i < r; i++)
    e[i] = e[i] / a;
  return e;
}, nt = function(e, r, a, n) {
  return (1 - n) * (1 - n) * e + 2 * (1 - n) * n * r + n * n * a;
}, Hr = function(e, r, a, n) {
  return {
    x: nt(e.x, r.x, a.x, n),
    y: nt(e.y, r.y, a.y, n)
  };
}, Ih = function(e, r, a, n) {
  var i = {
    x: r.x - e.x,
    y: r.y - e.y
  }, o = Ar(e, r), s = {
    x: i.x / o,
    y: i.y / o
  };
  return a = a ?? 0, n = n ?? a * o, {
    x: e.x + s.x * n,
    y: e.y + s.y * n
  };
}, Sa = function(e, r, a) {
  return Math.max(e, Math.min(a, r));
}, mt = function(e) {
  if (e == null)
    return {
      x1: 1 / 0,
      y1: 1 / 0,
      x2: -1 / 0,
      y2: -1 / 0,
      w: 0,
      h: 0
    };
  if (e.x1 != null && e.y1 != null) {
    if (e.x2 != null && e.y2 != null && e.x2 >= e.x1 && e.y2 >= e.y1)
      return {
        x1: e.x1,
        y1: e.y1,
        x2: e.x2,
        y2: e.y2,
        w: e.x2 - e.x1,
        h: e.y2 - e.y1
      };
    if (e.w != null && e.h != null && e.w >= 0 && e.h >= 0)
      return {
        x1: e.x1,
        y1: e.y1,
        x2: e.x1 + e.w,
        y2: e.y1 + e.h,
        w: e.w,
        h: e.h
      };
  }
}, Oh = function(e) {
  return {
    x1: e.x1,
    x2: e.x2,
    w: e.w,
    y1: e.y1,
    y2: e.y2,
    h: e.h
  };
}, kh = function(e) {
  e.x1 = 1 / 0, e.y1 = 1 / 0, e.x2 = -1 / 0, e.y2 = -1 / 0, e.w = 0, e.h = 0;
}, Nh = function(e, r) {
  e.x1 = Math.min(e.x1, r.x1), e.x2 = Math.max(e.x2, r.x2), e.w = e.x2 - e.x1, e.y1 = Math.min(e.y1, r.y1), e.y2 = Math.max(e.y2, r.y2), e.h = e.y2 - e.y1;
}, Df = function(e, r, a) {
  e.x1 = Math.min(e.x1, r), e.x2 = Math.max(e.x2, r), e.w = e.x2 - e.x1, e.y1 = Math.min(e.y1, a), e.y2 = Math.max(e.y2, a), e.h = e.y2 - e.y1;
}, un = function(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
  return e.x1 -= r, e.x2 += r, e.y1 -= r, e.y2 += r, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1, e;
}, ln = function(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0], a, n, i, o;
  if (r.length === 1)
    a = n = i = o = r[0];
  else if (r.length === 2)
    a = i = r[0], o = n = r[1];
  else if (r.length === 4) {
    var s = Qe(r, 4);
    a = s[0], n = s[1], i = s[2], o = s[3];
  }
  return e.x1 -= o, e.x2 += n, e.y1 -= a, e.y2 += i, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1, e;
}, Ks = function(e, r) {
  e.x1 = r.x1, e.y1 = r.y1, e.x2 = r.x2, e.y2 = r.y2, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1;
}, ss = function(e, r) {
  return !(e.x1 > r.x2 || r.x1 > e.x2 || e.x2 < r.x1 || r.x2 < e.x1 || e.y2 < r.y1 || r.y2 < e.y1 || e.y1 > r.y2 || r.y1 > e.y2);
}, ar = function(e, r, a) {
  return e.x1 <= r && r <= e.x2 && e.y1 <= a && a <= e.y2;
}, Zs = function(e, r) {
  return ar(e, r.x, r.y);
}, Sf = function(e, r) {
  return ar(e, r.x1, r.y1) && ar(e, r.x2, r.y2);
}, Bh = (mi = Math.hypot) !== null && mi !== void 0 ? mi : function(t, e) {
  return Math.sqrt(t * t + e * e);
};
function Fh(t, e) {
  if (t.length < 3)
    throw new Error("Need at least 3 vertices");
  var r = function(x, T) {
    return {
      x: x.x + T.x,
      y: x.y + T.y
    };
  }, a = function(x, T) {
    return {
      x: x.x - T.x,
      y: x.y - T.y
    };
  }, n = function(x, T) {
    return {
      x: x.x * T,
      y: x.y * T
    };
  }, i = function(x, T) {
    return x.x * T.y - x.y * T.x;
  }, o = function(x) {
    var T = Bh(x.x, x.y);
    return T === 0 ? {
      x: 0,
      y: 0
    } : {
      x: x.x / T,
      y: x.y / T
    };
  }, s = function(x) {
    for (var T = 0, D = 0; D < x.length; D++) {
      var A = x[D], L = x[(D + 1) % x.length];
      T += A.x * L.y - L.x * A.y;
    }
    return T / 2;
  }, u = function(x, T, D, A) {
    var L = a(T, x), R = a(A, D), P = i(L, R);
    if (Math.abs(P) < 1e-9)
      return r(x, n(L, 0.5));
    var I = i(a(D, x), R) / P;
    return r(x, n(L, I));
  }, l = t.map(function(w) {
    return {
      x: w.x,
      y: w.y
    };
  });
  s(l) < 0 && l.reverse();
  for (var f = l.length, v = [], c = 0; c < f; c++) {
    var h = l[c], d = l[(c + 1) % f], g = a(d, h), p = o({
      x: g.y,
      y: -g.x
    });
    v.push(p);
  }
  for (var y = v.map(function(w, x) {
    var T = r(l[x], n(w, e)), D = r(l[(x + 1) % f], n(w, e));
    return {
      p1: T,
      p2: D
    };
  }), b = [], m = 0; m < f; m++) {
    var E = y[(m - 1 + f) % f], C = y[m], S = u(E.p1, E.p2, C.p1, C.p2);
    b.push(S);
  }
  return b;
}
function Gh(t, e, r, a, n, i) {
  var o = Wh(t, e, r, a, n), s = Fh(o, i), u = mt();
  return s.forEach(function(l) {
    return Df(u, l.x, l.y);
  }), u;
}
var Af = function(e, r, a, n, i, o, s) {
  var u = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : "auto", l = u === "auto" ? lr(i, o) : u, f = i / 2, v = o / 2;
  l = Math.min(l, f, v);
  var c = l !== f, h = l !== v, d;
  if (c) {
    var g = a - f + l - s, p = n - v - s, y = a + f - l + s, b = p;
    if (d = nr(e, r, a, n, g, p, y, b, !1), d.length > 0)
      return d;
  }
  if (h) {
    var m = a + f + s, E = n - v + l - s, C = m, S = n + v - l + s;
    if (d = nr(e, r, a, n, m, E, C, S, !1), d.length > 0)
      return d;
  }
  if (c) {
    var w = a - f + l - s, x = n + v + s, T = a + f - l + s, D = x;
    if (d = nr(e, r, a, n, w, x, T, D, !1), d.length > 0)
      return d;
  }
  if (h) {
    var A = a - f - s, L = n - v + l - s, R = A, P = n + v - l + s;
    if (d = nr(e, r, a, n, A, L, R, P, !1), d.length > 0)
      return d;
  }
  var I;
  {
    var k = a - f + l, O = n - v + l;
    if (I = ya(e, r, a, n, k, O, l + s), I.length > 0 && I[0] <= k && I[1] <= O)
      return [I[0], I[1]];
  }
  {
    var N = a + f - l, F = n - v + l;
    if (I = ya(e, r, a, n, N, F, l + s), I.length > 0 && I[0] >= N && I[1] <= F)
      return [I[0], I[1]];
  }
  {
    var G = a + f - l, B = n + v - l;
    if (I = ya(e, r, a, n, G, B, l + s), I.length > 0 && I[0] >= G && I[1] >= B)
      return [I[0], I[1]];
  }
  {
    var z = a - f + l, Y = n + v - l;
    if (I = ya(e, r, a, n, z, Y, l + s), I.length > 0 && I[0] <= z && I[1] >= Y)
      return [I[0], I[1]];
  }
  return [];
}, zh = function(e, r, a, n, i, o, s) {
  var u = s, l = Math.min(a, i), f = Math.max(a, i), v = Math.min(n, o), c = Math.max(n, o);
  return l - u <= e && e <= f + u && v - u <= r && r <= c + u;
}, _h = function(e, r, a, n, i, o, s, u, l) {
  var f = {
    x1: Math.min(a, s, i) - l,
    x2: Math.max(a, s, i) + l,
    y1: Math.min(n, u, o) - l,
    y2: Math.max(n, u, o) + l
  };
  return !(e < f.x1 || e > f.x2 || r < f.y1 || r > f.y2);
}, Vh = function(e, r, a, n) {
  a -= n;
  var i = r * r - 4 * e * a;
  if (i < 0)
    return [];
  var o = Math.sqrt(i), s = 2 * e, u = (-r + o) / s, l = (-r - o) / s;
  return [u, l];
}, Uh = function(e, r, a, n, i) {
  var o = 1e-5;
  e === 0 && (e = o), r /= e, a /= e, n /= e;
  var s, u, l, f, v, c, h, d;
  if (u = (3 * a - r * r) / 9, l = -(27 * n) + r * (9 * a - 2 * (r * r)), l /= 54, s = u * u * u + l * l, i[1] = 0, h = r / 3, s > 0) {
    v = l + Math.sqrt(s), v = v < 0 ? -Math.pow(-v, 1 / 3) : Math.pow(v, 1 / 3), c = l - Math.sqrt(s), c = c < 0 ? -Math.pow(-c, 1 / 3) : Math.pow(c, 1 / 3), i[0] = -h + v + c, h += (v + c) / 2, i[4] = i[2] = -h, h = Math.sqrt(3) * (-c + v) / 2, i[3] = h, i[5] = -h;
    return;
  }
  if (i[5] = i[3] = 0, s === 0) {
    d = l < 0 ? -Math.pow(-l, 1 / 3) : Math.pow(l, 1 / 3), i[0] = -h + 2 * d, i[4] = i[2] = -(d + h);
    return;
  }
  u = -u, f = u * u * u, f = Math.acos(l / Math.sqrt(f)), d = 2 * Math.sqrt(u), i[0] = -h + d * Math.cos(f / 3), i[2] = -h + d * Math.cos((f + 2 * Math.PI) / 3), i[4] = -h + d * Math.cos((f + 4 * Math.PI) / 3);
}, qh = function(e, r, a, n, i, o, s, u) {
  var l = 1 * a * a - 4 * a * i + 2 * a * s + 4 * i * i - 4 * i * s + s * s + n * n - 4 * n * o + 2 * n * u + 4 * o * o - 4 * o * u + u * u, f = 9 * a * i - 3 * a * a - 3 * a * s - 6 * i * i + 3 * i * s + 9 * n * o - 3 * n * n - 3 * n * u - 6 * o * o + 3 * o * u, v = 3 * a * a - 6 * a * i + a * s - a * e + 2 * i * i + 2 * i * e - s * e + 3 * n * n - 6 * n * o + n * u - n * r + 2 * o * o + 2 * o * r - u * r, c = 1 * a * i - a * a + a * e - i * e + n * o - n * n + n * r - o * r, h = [];
  Uh(l, f, v, c, h);
  for (var d = 1e-7, g = [], p = 0; p < 6; p += 2)
    Math.abs(h[p + 1]) < d && h[p] >= 0 && h[p] <= 1 && g.push(h[p]);
  g.push(1), g.push(0);
  for (var y = -1, b, m, E, C = 0; C < g.length; C++)
    b = Math.pow(1 - g[C], 2) * a + 2 * (1 - g[C]) * g[C] * i + g[C] * g[C] * s, m = Math.pow(1 - g[C], 2) * n + 2 * (1 - g[C]) * g[C] * o + g[C] * g[C] * u, E = Math.pow(b - e, 2) + Math.pow(m - r, 2), y >= 0 ? E < y && (y = E) : y = E;
  return y;
}, Yh = function(e, r, a, n, i, o) {
  var s = [e - a, r - n], u = [i - a, o - n], l = u[0] * u[0] + u[1] * u[1], f = s[0] * s[0] + s[1] * s[1], v = s[0] * u[0] + s[1] * u[1], c = v * v / l;
  return v < 0 ? f : c > l ? (e - i) * (e - i) + (r - o) * (r - o) : f - c;
}, xt = function(e, r, a) {
  for (var n, i, o, s, u, l = 0, f = 0; f < a.length / 2; f++)
    if (n = a[f * 2], i = a[f * 2 + 1], f + 1 < a.length / 2 ? (o = a[(f + 1) * 2], s = a[(f + 1) * 2 + 1]) : (o = a[(f + 1 - a.length / 2) * 2], s = a[(f + 1 - a.length / 2) * 2 + 1]), !(n == e && o == e)) if (n >= e && e >= o || n <= e && e <= o)
      u = (e - n) / (o - n) * (s - i) + i, u > r && l++;
    else
      continue;
  return l % 2 !== 0;
}, Kt = function(e, r, a, n, i, o, s, u, l) {
  var f = new Array(a.length), v;
  u[0] != null ? (v = Math.atan(u[1] / u[0]), u[0] < 0 ? v = v + Math.PI / 2 : v = -v - Math.PI / 2) : v = u;
  for (var c = Math.cos(-v), h = Math.sin(-v), d = 0; d < f.length / 2; d++)
    f[d * 2] = o / 2 * (a[d * 2] * c - a[d * 2 + 1] * h), f[d * 2 + 1] = s / 2 * (a[d * 2 + 1] * c + a[d * 2] * h), f[d * 2] += n, f[d * 2 + 1] += i;
  var g;
  if (l > 0) {
    var p = Sn(f, -l);
    g = Dn(p);
  } else
    g = f;
  return xt(e, r, g);
}, Hh = function(e, r, a, n, i, o, s, u) {
  for (var l = new Array(a.length * 2), f = 0; f < u.length; f++) {
    var v = u[f];
    l[f * 4 + 0] = v.startX, l[f * 4 + 1] = v.startY, l[f * 4 + 2] = v.stopX, l[f * 4 + 3] = v.stopY;
    var c = Math.pow(v.cx - e, 2) + Math.pow(v.cy - r, 2);
    if (c <= Math.pow(v.radius, 2))
      return !0;
  }
  return xt(e, r, l);
}, Dn = function(e) {
  for (var r = new Array(e.length / 2), a, n, i, o, s, u, l, f, v = 0; v < e.length / 4; v++) {
    a = e[v * 4], n = e[v * 4 + 1], i = e[v * 4 + 2], o = e[v * 4 + 3], v < e.length / 4 - 1 ? (s = e[(v + 1) * 4], u = e[(v + 1) * 4 + 1], l = e[(v + 1) * 4 + 2], f = e[(v + 1) * 4 + 3]) : (s = e[0], u = e[1], l = e[2], f = e[3]);
    var c = nr(a, n, i, o, s, u, l, f, !0);
    r[v * 2] = c[0], r[v * 2 + 1] = c[1];
  }
  return r;
}, Sn = function(e, r) {
  for (var a = new Array(e.length * 2), n, i, o, s, u = 0; u < e.length / 2; u++) {
    n = e[u * 2], i = e[u * 2 + 1], u < e.length / 2 - 1 ? (o = e[(u + 1) * 2], s = e[(u + 1) * 2 + 1]) : (o = e[0], s = e[1]);
    var l = s - i, f = -(o - n), v = Math.sqrt(l * l + f * f), c = l / v, h = f / v;
    a[u * 4] = n + c * r, a[u * 4 + 1] = i + h * r, a[u * 4 + 2] = o + c * r, a[u * 4 + 3] = s + h * r;
  }
  return a;
}, Xh = function(e, r, a, n, i, o) {
  var s = a - e, u = n - r;
  s /= i, u /= o;
  var l = Math.sqrt(s * s + u * u), f = l - 1;
  if (f < 0)
    return [];
  var v = f / l;
  return [(a - e) * v + e, (n - r) * v + r];
}, Dr = function(e, r, a, n, i, o, s) {
  return e -= i, r -= o, e /= a / 2 + s, r /= n / 2 + s, e * e + r * r <= 1;
}, ya = function(e, r, a, n, i, o, s) {
  var u = [a - e, n - r], l = [e - i, r - o], f = u[0] * u[0] + u[1] * u[1], v = 2 * (l[0] * u[0] + l[1] * u[1]), c = l[0] * l[0] + l[1] * l[1] - s * s, h = v * v - 4 * f * c;
  if (h < 0)
    return [];
  var d = (-v + Math.sqrt(h)) / (2 * f), g = (-v - Math.sqrt(h)) / (2 * f), p = Math.min(d, g), y = Math.max(d, g), b = [];
  if (p >= 0 && p <= 1 && b.push(p), y >= 0 && y <= 1 && b.push(y), b.length === 0)
    return [];
  var m = b[0] * u[0] + e, E = b[0] * u[1] + r;
  if (b.length > 1) {
    if (b[0] == b[1])
      return [m, E];
    var C = b[1] * u[0] + e, S = b[1] * u[1] + r;
    return [m, E, C, S];
  } else
    return [m, E];
}, bi = function(e, r, a) {
  return r <= e && e <= a || a <= e && e <= r ? e : e <= r && r <= a || a <= r && r <= e ? r : a;
}, nr = function(e, r, a, n, i, o, s, u, l) {
  var f = e - i, v = a - e, c = s - i, h = r - o, d = n - r, g = u - o, p = c * h - g * f, y = v * h - d * f, b = g * v - c * d;
  if (b !== 0) {
    var m = p / b, E = y / b, C = 1e-3, S = 0 - C, w = 1 + C;
    return S <= m && m <= w && S <= E && E <= w ? [e + m * v, r + m * d] : l ? [e + m * v, r + m * d] : [];
  } else
    return p === 0 || y === 0 ? bi(e, a, s) === s ? [s, u] : bi(e, a, i) === i ? [i, o] : bi(i, s, a) === a ? [a, n] : [] : [];
}, Wh = function(e, r, a, n, i) {
  var o = [], s = n / 2, u = i / 2, l = r, f = a;
  o.push({
    x: l + s * e[0],
    y: f + u * e[1]
  });
  for (var v = 1; v < e.length / 2; v++)
    o.push({
      x: l + s * e[v * 2],
      y: f + u * e[v * 2 + 1]
    });
  return o;
}, Aa = function(e, r, a, n, i, o, s, u) {
  var l = [], f, v = new Array(a.length), c = !0;
  o == null && (c = !1);
  var h;
  if (c) {
    for (var d = 0; d < v.length / 2; d++)
      v[d * 2] = a[d * 2] * o + n, v[d * 2 + 1] = a[d * 2 + 1] * s + i;
    if (u > 0) {
      var g = Sn(v, -u);
      h = Dn(g);
    } else
      h = v;
  } else
    h = a;
  for (var p, y, b, m, E = 0; E < h.length / 2; E++)
    p = h[E * 2], y = h[E * 2 + 1], E < h.length / 2 - 1 ? (b = h[(E + 1) * 2], m = h[(E + 1) * 2 + 1]) : (b = h[0], m = h[1]), f = nr(e, r, n, i, p, y, b, m), f.length !== 0 && l.push(f[0], f[1]);
  return l;
}, $h = function(e, r, a, n, i, o, s, u, l) {
  var f = [], v, c = new Array(a.length * 2);
  l.forEach(function(b, m) {
    m === 0 ? (c[c.length - 2] = b.startX, c[c.length - 1] = b.startY) : (c[m * 4 - 2] = b.startX, c[m * 4 - 1] = b.startY), c[m * 4] = b.stopX, c[m * 4 + 1] = b.stopY, v = ya(e, r, n, i, b.cx, b.cy, b.radius), v.length !== 0 && f.push(v[0], v[1]);
  });
  for (var h = 0; h < c.length / 4; h++)
    v = nr(e, r, n, i, c[h * 4], c[h * 4 + 1], c[h * 4 + 2], c[h * 4 + 3], !1), v.length !== 0 && f.push(v[0], v[1]);
  if (f.length > 2) {
    for (var d = [f[0], f[1]], g = Math.pow(d[0] - e, 2) + Math.pow(d[1] - r, 2), p = 1; p < f.length / 2; p++) {
      var y = Math.pow(f[p * 2] - e, 2) + Math.pow(f[p * 2 + 1] - r, 2);
      y <= g && (d[0] = f[p * 2], d[1] = f[p * 2 + 1], g = y);
    }
    return d;
  }
  return f;
}, Za = function(e, r, a) {
  var n = [e[0] - r[0], e[1] - r[1]], i = Math.sqrt(n[0] * n[0] + n[1] * n[1]), o = (i - a) / i;
  return o < 0 && (o = 1e-5), [r[0] + o * n[0], r[1] + o * n[1]];
}, pt = function(e, r) {
  var a = Oo(e, r);
  return a = Lf(a), a;
}, Lf = function(e) {
  for (var r, a, n = e.length / 2, i = 1 / 0, o = 1 / 0, s = -1 / 0, u = -1 / 0, l = 0; l < n; l++)
    r = e[2 * l], a = e[2 * l + 1], i = Math.min(i, r), s = Math.max(s, r), o = Math.min(o, a), u = Math.max(u, a);
  for (var f = 2 / (s - i), v = 2 / (u - o), c = 0; c < n; c++)
    r = e[2 * c] = e[2 * c] * f, a = e[2 * c + 1] = e[2 * c + 1] * v, i = Math.min(i, r), s = Math.max(s, r), o = Math.min(o, a), u = Math.max(u, a);
  if (o < -1)
    for (var h = 0; h < n; h++)
      a = e[2 * h + 1] = e[2 * h + 1] + (-1 - o);
  return e;
}, Oo = function(e, r) {
  var a = 1 / e * 2 * Math.PI, n = e % 2 === 0 ? Math.PI / 2 + a / 2 : Math.PI / 2;
  n += r;
  for (var i = new Array(e * 2), o, s = 0; s < e; s++)
    o = s * a + n, i[2 * s] = Math.cos(o), i[2 * s + 1] = Math.sin(-o);
  return i;
}, lr = function(e, r) {
  return Math.min(e / 4, r / 4, 8);
}, Rf = function(e, r) {
  return Math.min(e / 10, r / 10, 8);
}, us = function() {
  return 8;
}, Kh = function(e, r, a) {
  return [e - 2 * r + a, 2 * (r - e), e];
}, ko = function(e, r) {
  return {
    heightOffset: Math.min(15, 0.05 * r),
    widthOffset: Math.min(100, 0.25 * e),
    ctrlPtOffsetPct: 0.05
  };
};
function wi(t, e) {
  function r(v) {
    for (var c = [], h = 0; h < v.length; h++) {
      var d = v[h], g = v[(h + 1) % v.length], p = {
        x: g.x - d.x,
        y: g.y - d.y
      }, y = {
        x: -p.y,
        y: p.x
      }, b = Math.sqrt(y.x * y.x + y.y * y.y);
      c.push({
        x: y.x / b,
        y: y.y / b
      });
    }
    return c;
  }
  function a(v, c) {
    var h = 1 / 0, d = -1 / 0, g = Tt(v), p;
    try {
      for (g.s(); !(p = g.n()).done; ) {
        var y = p.value, b = y.x * c.x + y.y * c.y;
        h = Math.min(h, b), d = Math.max(d, b);
      }
    } catch (m) {
      g.e(m);
    } finally {
      g.f();
    }
    return {
      min: h,
      max: d
    };
  }
  function n(v, c) {
    return !(v.max < c.min || c.max < v.min);
  }
  var i = [].concat(En(r(t)), En(r(e))), o = Tt(i), s;
  try {
    for (o.s(); !(s = o.n()).done; ) {
      var u = s.value, l = a(t, u), f = a(e, u);
      if (!n(l, f))
        return !1;
    }
  } catch (v) {
    o.e(v);
  } finally {
    o.f();
  }
  return !0;
}
var Zh = ft({
  dampingFactor: 0.8,
  precision: 1e-6,
  iterations: 200,
  weight: function(e) {
    return 1;
  }
}), Qh = {
  pageRank: function(e) {
    for (var r = Zh(e), a = r.dampingFactor, n = r.precision, i = r.iterations, o = r.weight, s = this._private.cy, u = this.byGroup(), l = u.nodes, f = u.edges, v = l.length, c = v * v, h = f.length, d = new Array(c), g = new Array(v), p = (1 - a) / v, y = 0; y < v; y++) {
      for (var b = 0; b < v; b++) {
        var m = y * v + b;
        d[m] = 0;
      }
      g[y] = 0;
    }
    for (var E = 0; E < h; E++) {
      var C = f[E], S = C.data("source"), w = C.data("target");
      if (S !== w) {
        var x = l.indexOfId(S), T = l.indexOfId(w), D = o(C), A = T * v + x;
        d[A] += D, g[x] += D;
      }
    }
    for (var L = 1 / v + p, R = 0; R < v; R++)
      if (g[R] === 0)
        for (var P = 0; P < v; P++) {
          var I = P * v + R;
          d[I] = L;
        }
      else
        for (var k = 0; k < v; k++) {
          var O = k * v + R;
          d[O] = d[O] / g[R] + p;
        }
    for (var N = new Array(v), F = new Array(v), G, B = 0; B < v; B++)
      N[B] = 1;
    for (var z = 0; z < i; z++) {
      for (var Y = 0; Y < v; Y++)
        F[Y] = 0;
      for (var $ = 0; $ < v; $++)
        for (var X = 0; X < v; X++) {
          var j = $ * v + X;
          F[$] += d[j] * N[X];
        }
      Ph(F), G = N, N = F, F = G;
      for (var ee = 0, ae = 0; ae < v; ae++) {
        var K = G[ae] - N[ae];
        ee += K * K;
      }
      if (ee < n)
        break;
    }
    var V = {
      rank: function(H) {
        return H = s.collection(H)[0], N[l.indexOf(H)];
      }
    };
    return V;
  }
  // pageRank
}, Qs = ft({
  root: null,
  weight: function(e) {
    return 1;
  },
  directed: !1,
  alpha: 0
}), Xr = {
  degreeCentralityNormalized: function(e) {
    e = Qs(e);
    var r = this.cy(), a = this.nodes(), n = a.length;
    if (e.directed) {
      for (var f = {}, v = {}, c = 0, h = 0, d = 0; d < n; d++) {
        var g = a[d], p = g.id();
        e.root = g;
        var y = this.degreeCentrality(e);
        c < y.indegree && (c = y.indegree), h < y.outdegree && (h = y.outdegree), f[p] = y.indegree, v[p] = y.outdegree;
      }
      return {
        indegree: function(m) {
          return c == 0 ? 0 : (de(m) && (m = r.filter(m)), f[m.id()] / c);
        },
        outdegree: function(m) {
          return h === 0 ? 0 : (de(m) && (m = r.filter(m)), v[m.id()] / h);
        }
      };
    } else {
      for (var i = {}, o = 0, s = 0; s < n; s++) {
        var u = a[s];
        e.root = u;
        var l = this.degreeCentrality(e);
        o < l.degree && (o = l.degree), i[u.id()] = l.degree;
      }
      return {
        degree: function(m) {
          return o === 0 ? 0 : (de(m) && (m = r.filter(m)), i[m.id()] / o);
        }
      };
    }
  },
  // degreeCentralityNormalized
  // Implemented from the algorithm in Opsahl's paper
  // "Node centrality in weighted networks: Generalizing degree and shortest paths"
  // check the heading 2 "Degree"
  degreeCentrality: function(e) {
    e = Qs(e);
    var r = this.cy(), a = this, n = e, i = n.root, o = n.weight, s = n.directed, u = n.alpha;
    if (i = r.collection(i)[0], s) {
      for (var h = i.connectedEdges(), d = h.filter(function(S) {
        return S.target().same(i) && a.has(S);
      }), g = h.filter(function(S) {
        return S.source().same(i) && a.has(S);
      }), p = d.length, y = g.length, b = 0, m = 0, E = 0; E < d.length; E++)
        b += o(d[E]);
      for (var C = 0; C < g.length; C++)
        m += o(g[C]);
      return {
        indegree: Math.pow(p, 1 - u) * Math.pow(b, u),
        outdegree: Math.pow(y, 1 - u) * Math.pow(m, u)
      };
    } else {
      for (var l = i.connectedEdges().intersection(a), f = l.length, v = 0, c = 0; c < l.length; c++)
        v += o(l[c]);
      return {
        degree: Math.pow(f, 1 - u) * Math.pow(v, u)
      };
    }
  }
  // degreeCentrality
};
Xr.dc = Xr.degreeCentrality;
Xr.dcn = Xr.degreeCentralityNormalised = Xr.degreeCentralityNormalized;
var Js = ft({
  harmonic: !0,
  weight: function() {
    return 1;
  },
  directed: !1,
  root: null
}), Wr = {
  closenessCentralityNormalized: function(e) {
    for (var r = Js(e), a = r.harmonic, n = r.weight, i = r.directed, o = this.cy(), s = {}, u = 0, l = this.nodes(), f = this.floydWarshall({
      weight: n,
      directed: i
    }), v = 0; v < l.length; v++) {
      for (var c = 0, h = l[v], d = 0; d < l.length; d++)
        if (v !== d) {
          var g = f.distance(h, l[d]);
          a ? c += 1 / g : c += g;
        }
      a || (c = 1 / c), u < c && (u = c), s[h.id()] = c;
    }
    return {
      closeness: function(y) {
        return u == 0 ? 0 : (de(y) ? y = o.filter(y)[0].id() : y = y.id(), s[y] / u);
      }
    };
  },
  // Implemented from pseudocode from wikipedia
  closenessCentrality: function(e) {
    var r = Js(e), a = r.root, n = r.weight, i = r.directed, o = r.harmonic;
    a = this.filter(a)[0];
    for (var s = this.dijkstra({
      root: a,
      weight: n,
      directed: i
    }), u = 0, l = this.nodes(), f = 0; f < l.length; f++) {
      var v = l[f];
      if (!v.same(a)) {
        var c = s.distanceTo(v);
        o ? u += 1 / c : u += c;
      }
    }
    return o ? u : 1 / u;
  }
  // closenessCentrality
};
Wr.cc = Wr.closenessCentrality;
Wr.ccn = Wr.closenessCentralityNormalised = Wr.closenessCentralityNormalized;
var Jh = ft({
  weight: null,
  directed: !1
}), No = {
  // Implemented from the algorithm in the paper "On Variants of Shortest-Path Betweenness Centrality and their Generic Computation" by Ulrik Brandes
  betweennessCentrality: function(e) {
    for (var r = Jh(e), a = r.directed, n = r.weight, i = n != null, o = this.cy(), s = this.nodes(), u = {}, l = {}, f = 0, v = {
      set: function(m, E) {
        l[m] = E, E > f && (f = E);
      },
      get: function(m) {
        return l[m];
      }
    }, c = 0; c < s.length; c++) {
      var h = s[c], d = h.id();
      a ? u[d] = h.outgoers().nodes() : u[d] = h.openNeighborhood().nodes(), v.set(d, 0);
    }
    for (var g = function() {
      for (var m = s[p].id(), E = [], C = {}, S = {}, w = {}, x = new za(function($, X) {
        return w[$] - w[X];
      }), T = 0; T < s.length; T++) {
        var D = s[T].id();
        C[D] = [], S[D] = 0, w[D] = 1 / 0;
      }
      for (S[m] = 1, w[m] = 0, x.push(m); !x.empty(); ) {
        var A = x.pop();
        if (E.push(A), i)
          for (var L = 0; L < u[A].length; L++) {
            var R = u[A][L], P = o.getElementById(A), I = void 0;
            P.edgesTo(R).length > 0 ? I = P.edgesTo(R)[0] : I = R.edgesTo(P)[0];
            var k = n(I);
            R = R.id(), w[R] > w[A] + k && (w[R] = w[A] + k, x.nodes.indexOf(R) < 0 ? x.push(R) : x.updateItem(R), S[R] = 0, C[R] = []), w[R] == w[A] + k && (S[R] = S[R] + S[A], C[R].push(A));
          }
        else
          for (var O = 0; O < u[A].length; O++) {
            var N = u[A][O].id();
            w[N] == 1 / 0 && (x.push(N), w[N] = w[A] + 1), w[N] == w[A] + 1 && (S[N] = S[N] + S[A], C[N].push(A));
          }
      }
      for (var F = {}, G = 0; G < s.length; G++)
        F[s[G].id()] = 0;
      for (; E.length > 0; ) {
        for (var B = E.pop(), z = 0; z < C[B].length; z++) {
          var Y = C[B][z];
          F[Y] = F[Y] + S[Y] / S[B] * (1 + F[B]);
        }
        B != s[p].id() && v.set(B, v.get(B) + F[B]);
      }
    }, p = 0; p < s.length; p++)
      g();
    var y = {
      betweenness: function(m) {
        var E = o.collection(m).id();
        return v.get(E);
      },
      betweennessNormalized: function(m) {
        if (f == 0)
          return 0;
        var E = o.collection(m).id();
        return v.get(E) / f;
      }
    };
    return y.betweennessNormalised = y.betweennessNormalized, y;
  }
  // betweennessCentrality
};
No.bc = No.betweennessCentrality;
var jh = ft({
  expandFactor: 2,
  // affects time of computation and cluster granularity to some extent: M * M
  inflateFactor: 2,
  // affects cluster granularity (the greater the value, the more clusters): M(i,j) / E(j)
  multFactor: 1,
  // optional self loops for each node. Use a neutral value to improve cluster computations.
  maxIterations: 20,
  // maximum number of iterations of the MCL algorithm in a single run
  attributes: [
    // attributes/features used to group nodes, ie. similarity values between nodes
    function(t) {
      return 1;
    }
  ]
}), ed = function(e) {
  return jh(e);
}, td = function(e, r) {
  for (var a = 0, n = 0; n < r.length; n++)
    a += r[n](e);
  return a;
}, rd = function(e, r, a) {
  for (var n = 0; n < r; n++)
    e[n * r + n] = a;
}, Mf = function(e, r) {
  for (var a, n = 0; n < r; n++) {
    a = 0;
    for (var i = 0; i < r; i++)
      a += e[i * r + n];
    for (var o = 0; o < r; o++)
      e[o * r + n] = e[o * r + n] / a;
  }
}, ad = function(e, r, a) {
  for (var n = new Array(a * a), i = 0; i < a; i++) {
    for (var o = 0; o < a; o++)
      n[i * a + o] = 0;
    for (var s = 0; s < a; s++)
      for (var u = 0; u < a; u++)
        n[i * a + u] += e[i * a + s] * r[s * a + u];
  }
  return n;
}, nd = function(e, r, a) {
  for (var n = e.slice(0), i = 1; i < a; i++)
    e = ad(e, n, r);
  return e;
}, id = function(e, r, a) {
  for (var n = new Array(r * r), i = 0; i < r * r; i++)
    n[i] = Math.pow(e[i], a);
  return Mf(n, r), n;
}, od = function(e, r, a, n) {
  for (var i = 0; i < a; i++) {
    var o = Math.round(e[i] * Math.pow(10, n)) / Math.pow(10, n), s = Math.round(r[i] * Math.pow(10, n)) / Math.pow(10, n);
    if (o !== s)
      return !1;
  }
  return !0;
}, sd = function(e, r, a, n) {
  for (var i = [], o = 0; o < r; o++) {
    for (var s = [], u = 0; u < r; u++)
      Math.round(e[o * r + u] * 1e3) / 1e3 > 0 && s.push(a[u]);
    s.length !== 0 && i.push(n.collection(s));
  }
  return i;
}, ud = function(e, r) {
  for (var a = 0; a < e.length; a++)
    if (!r[a] || e[a].id() !== r[a].id())
      return !1;
  return !0;
}, ld = function(e) {
  for (var r = 0; r < e.length; r++)
    for (var a = 0; a < e.length; a++)
      r != a && ud(e[r], e[a]) && e.splice(a, 1);
  return e;
}, js = function(e) {
  for (var r = this.nodes(), a = this.edges(), n = this.cy(), i = ed(e), o = {}, s = 0; s < r.length; s++)
    o[r[s].id()] = s;
  for (var u = r.length, l = u * u, f = new Array(l), v, c = 0; c < l; c++)
    f[c] = 0;
  for (var h = 0; h < a.length; h++) {
    var d = a[h], g = o[d.source().id()], p = o[d.target().id()], y = td(d, i.attributes);
    f[g * u + p] += y, f[p * u + g] += y;
  }
  rd(f, u, i.multFactor), Mf(f, u);
  for (var b = !0, m = 0; b && m < i.maxIterations; )
    b = !1, v = nd(f, u, i.expandFactor), f = id(v, u, i.inflateFactor), od(f, v, l, 4) || (b = !0), m++;
  var E = sd(f, u, r, n);
  return E = ld(E), E;
}, fd = {
  markovClustering: js,
  mcl: js
}, vd = function(e) {
  return e;
}, Pf = function(e, r) {
  return Math.abs(r - e);
}, eu = function(e, r, a) {
  return e + Pf(r, a);
}, tu = function(e, r, a) {
  return e + Math.pow(a - r, 2);
}, cd = function(e) {
  return Math.sqrt(e);
}, hd = function(e, r, a) {
  return Math.max(e, Pf(r, a));
}, fa = function(e, r, a, n, i) {
  for (var o = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : vd, s = n, u, l, f = 0; f < e; f++)
    u = r(f), l = a(f), s = i(s, u, l);
  return o(s);
}, Zr = {
  euclidean: function(e, r, a) {
    return e >= 2 ? fa(e, r, a, 0, tu, cd) : fa(e, r, a, 0, eu);
  },
  squaredEuclidean: function(e, r, a) {
    return fa(e, r, a, 0, tu);
  },
  manhattan: function(e, r, a) {
    return fa(e, r, a, 0, eu);
  },
  max: function(e, r, a) {
    return fa(e, r, a, -1 / 0, hd);
  }
};
Zr["squared-euclidean"] = Zr.squaredEuclidean;
Zr.squaredeuclidean = Zr.squaredEuclidean;
function zn(t, e, r, a, n, i) {
  var o;
  return He(t) ? o = t : o = Zr[t] || Zr.euclidean, e === 0 && He(t) ? o(n, i) : o(e, r, a, n, i);
}
var dd = ft({
  k: 2,
  m: 2,
  sensitivityThreshold: 1e-4,
  distance: "euclidean",
  maxIterations: 10,
  attributes: [],
  testMode: !1,
  testCentroids: null
}), ls = function(e) {
  return dd(e);
}, An = function(e, r, a, n, i) {
  var o = i !== "kMedoids", s = o ? function(v) {
    return a[v];
  } : function(v) {
    return n[v](a);
  }, u = function(c) {
    return n[c](r);
  }, l = a, f = r;
  return zn(e, n.length, s, u, l, f);
}, Ei = function(e, r, a) {
  for (var n = a.length, i = new Array(n), o = new Array(n), s = new Array(r), u = null, l = 0; l < n; l++)
    i[l] = e.min(a[l]).value, o[l] = e.max(a[l]).value;
  for (var f = 0; f < r; f++) {
    u = [];
    for (var v = 0; v < n; v++)
      u[v] = Math.random() * (o[v] - i[v]) + i[v];
    s[f] = u;
  }
  return s;
}, If = function(e, r, a, n, i) {
  for (var o = 1 / 0, s = 0, u = 0; u < r.length; u++) {
    var l = An(a, e, r[u], n, i);
    l < o && (o = l, s = u);
  }
  return s;
}, Of = function(e, r, a) {
  for (var n = [], i = null, o = 0; o < r.length; o++)
    i = r[o], a[i.id()] === e && n.push(i);
  return n;
}, gd = function(e, r, a) {
  return Math.abs(r - e) <= a;
}, pd = function(e, r, a) {
  for (var n = 0; n < e.length; n++)
    for (var i = 0; i < e[n].length; i++) {
      var o = Math.abs(e[n][i] - r[n][i]);
      if (o > a)
        return !1;
    }
  return !0;
}, yd = function(e, r, a) {
  for (var n = 0; n < a; n++)
    if (e === r[n]) return !0;
  return !1;
}, ru = function(e, r) {
  var a = new Array(r);
  if (e.length < 50)
    for (var n = 0; n < r; n++) {
      for (var i = e[Math.floor(Math.random() * e.length)]; yd(i, a, n); )
        i = e[Math.floor(Math.random() * e.length)];
      a[n] = i;
    }
  else
    for (var o = 0; o < r; o++)
      a[o] = e[Math.floor(Math.random() * e.length)];
  return a;
}, au = function(e, r, a) {
  for (var n = 0, i = 0; i < r.length; i++)
    n += An("manhattan", r[i], e, a, "kMedoids");
  return n;
}, md = function(e) {
  var r = this.cy(), a = this.nodes(), n = null, i = ls(e), o = new Array(i.k), s = {}, u;
  i.testMode ? typeof i.testCentroids == "number" ? (i.testCentroids, u = Ei(a, i.k, i.attributes)) : tt(i.testCentroids) === "object" ? u = i.testCentroids : u = Ei(a, i.k, i.attributes) : u = Ei(a, i.k, i.attributes);
  for (var l = !0, f = 0; l && f < i.maxIterations; ) {
    for (var v = 0; v < a.length; v++)
      n = a[v], s[n.id()] = If(n, u, i.distance, i.attributes, "kMeans");
    l = !1;
    for (var c = 0; c < i.k; c++) {
      var h = Of(c, a, s);
      if (h.length !== 0) {
        for (var d = i.attributes.length, g = u[c], p = new Array(d), y = new Array(d), b = 0; b < d; b++) {
          y[b] = 0;
          for (var m = 0; m < h.length; m++)
            n = h[m], y[b] += i.attributes[b](n);
          p[b] = y[b] / h.length, gd(p[b], g[b], i.sensitivityThreshold) || (l = !0);
        }
        u[c] = p, o[c] = r.collection(h);
      }
    }
    f++;
  }
  return o;
}, bd = function(e) {
  var r = this.cy(), a = this.nodes(), n = null, i = ls(e), o = new Array(i.k), s, u = {}, l, f = new Array(i.k);
  i.testMode ? typeof i.testCentroids == "number" || (tt(i.testCentroids) === "object" ? s = i.testCentroids : s = ru(a, i.k)) : s = ru(a, i.k);
  for (var v = !0, c = 0; v && c < i.maxIterations; ) {
    for (var h = 0; h < a.length; h++)
      n = a[h], u[n.id()] = If(n, s, i.distance, i.attributes, "kMedoids");
    v = !1;
    for (var d = 0; d < s.length; d++) {
      var g = Of(d, a, u);
      if (g.length !== 0) {
        f[d] = au(s[d], g, i.attributes);
        for (var p = 0; p < g.length; p++)
          l = au(g[p], g, i.attributes), l < f[d] && (f[d] = l, s[d] = g[p], v = !0);
        o[d] = r.collection(g);
      }
    }
    c++;
  }
  return o;
}, wd = function(e, r, a, n, i) {
  for (var o, s, u = 0; u < r.length; u++)
    for (var l = 0; l < e.length; l++)
      n[u][l] = Math.pow(a[u][l], i.m);
  for (var f = 0; f < e.length; f++)
    for (var v = 0; v < i.attributes.length; v++) {
      o = 0, s = 0;
      for (var c = 0; c < r.length; c++)
        o += n[c][f] * i.attributes[v](r[c]), s += n[c][f];
      e[f][v] = o / s;
    }
}, Ed = function(e, r, a, n, i) {
  for (var o = 0; o < e.length; o++)
    r[o] = e[o].slice();
  for (var s, u, l, f = 2 / (i.m - 1), v = 0; v < a.length; v++)
    for (var c = 0; c < n.length; c++) {
      s = 0;
      for (var h = 0; h < a.length; h++)
        u = An(i.distance, n[c], a[v], i.attributes, "cmeans"), l = An(i.distance, n[c], a[h], i.attributes, "cmeans"), s += Math.pow(u / l, f);
      e[c][v] = 1 / s;
    }
}, xd = function(e, r, a, n) {
  for (var i = new Array(a.k), o = 0; o < i.length; o++)
    i[o] = [];
  for (var s, u, l = 0; l < r.length; l++) {
    s = -1 / 0, u = -1;
    for (var f = 0; f < r[0].length; f++)
      r[l][f] > s && (s = r[l][f], u = f);
    i[u].push(e[l]);
  }
  for (var v = 0; v < i.length; v++)
    i[v] = n.collection(i[v]);
  return i;
}, nu = function(e) {
  var r = this.cy(), a = this.nodes(), n = ls(e), i, o, s, u, l;
  u = new Array(a.length);
  for (var f = 0; f < a.length; f++)
    u[f] = new Array(n.k);
  s = new Array(a.length);
  for (var v = 0; v < a.length; v++)
    s[v] = new Array(n.k);
  for (var c = 0; c < a.length; c++) {
    for (var h = 0, d = 0; d < n.k; d++)
      s[c][d] = Math.random(), h += s[c][d];
    for (var g = 0; g < n.k; g++)
      s[c][g] = s[c][g] / h;
  }
  o = new Array(n.k);
  for (var p = 0; p < n.k; p++)
    o[p] = new Array(n.attributes.length);
  l = new Array(a.length);
  for (var y = 0; y < a.length; y++)
    l[y] = new Array(n.k);
  for (var b = !0, m = 0; b && m < n.maxIterations; )
    b = !1, wd(o, a, s, l, n), Ed(s, u, o, a, n), pd(s, u, n.sensitivityThreshold) || (b = !0), m++;
  return i = xd(a, s, n, r), {
    clusters: i,
    degreeOfMembership: s
  };
}, Td = {
  kMeans: md,
  kMedoids: bd,
  fuzzyCMeans: nu,
  fcm: nu
}, Cd = ft({
  distance: "euclidean",
  // distance metric to compare nodes
  linkage: "min",
  // linkage criterion : how to determine the distance between clusters of nodes
  mode: "threshold",
  // mode:'threshold' => clusters must be threshold distance apart
  threshold: 1 / 0,
  // the distance threshold
  // mode:'dendrogram' => the nodes are organised as leaves in a tree (siblings are close), merging makes clusters
  addDendrogram: !1,
  // whether to add the dendrogram to the graph for viz
  dendrogramDepth: 0,
  // depth at which dendrogram branches are merged into the returned clusters
  attributes: []
  // array of attr functions
}), Dd = {
  single: "min",
  complete: "max"
}, Sd = function(e) {
  var r = Cd(e), a = Dd[r.linkage];
  return a != null && (r.linkage = a), r;
}, iu = function(e, r, a, n, i) {
  for (var o = 0, s = 1 / 0, u, l = i.attributes, f = function(T, D) {
    return zn(i.distance, l.length, function(A) {
      return l[A](T);
    }, function(A) {
      return l[A](D);
    }, T, D);
  }, v = 0; v < e.length; v++) {
    var c = e[v].key, h = a[c][n[c]];
    h < s && (o = c, s = h);
  }
  if (i.mode === "threshold" && s >= i.threshold || i.mode === "dendrogram" && e.length === 1)
    return !1;
  var d = r[o], g = r[n[o]], p;
  i.mode === "dendrogram" ? p = {
    left: d,
    right: g,
    key: d.key
  } : p = {
    value: d.value.concat(g.value),
    key: d.key
  }, e[d.index] = p, e.splice(g.index, 1), r[d.key] = p;
  for (var y = 0; y < e.length; y++) {
    var b = e[y];
    d.key === b.key ? u = 1 / 0 : i.linkage === "min" ? (u = a[d.key][b.key], a[d.key][b.key] > a[g.key][b.key] && (u = a[g.key][b.key])) : i.linkage === "max" ? (u = a[d.key][b.key], a[d.key][b.key] < a[g.key][b.key] && (u = a[g.key][b.key])) : i.linkage === "mean" ? u = (a[d.key][b.key] * d.size + a[g.key][b.key] * g.size) / (d.size + g.size) : i.mode === "dendrogram" ? u = f(b.value, d.value) : u = f(b.value[0], d.value[0]), a[d.key][b.key] = a[b.key][d.key] = u;
  }
  for (var m = 0; m < e.length; m++) {
    var E = e[m].key;
    if (n[E] === d.key || n[E] === g.key) {
      for (var C = E, S = 0; S < e.length; S++) {
        var w = e[S].key;
        a[E][w] < a[E][C] && (C = w);
      }
      n[E] = C;
    }
    e[m].index = m;
  }
  return d.key = g.key = d.index = g.index = null, !0;
}, qr = function(e, r, a) {
  e && (e.value ? r.push(e.value) : (e.left && qr(e.left, r), e.right && qr(e.right, r)));
}, Bo = function(e, r) {
  if (!e) return "";
  if (e.left && e.right) {
    var a = Bo(e.left, r), n = Bo(e.right, r), i = r.add({
      group: "nodes",
      data: {
        id: a + "," + n
      }
    });
    return r.add({
      group: "edges",
      data: {
        source: a,
        target: i.id()
      }
    }), r.add({
      group: "edges",
      data: {
        source: n,
        target: i.id()
      }
    }), i.id();
  } else if (e.value)
    return e.value.id();
}, Fo = function(e, r, a) {
  if (!e) return [];
  var n = [], i = [], o = [];
  return r === 0 ? (e.left && qr(e.left, n), e.right && qr(e.right, i), o = n.concat(i), [a.collection(o)]) : r === 1 ? e.value ? [a.collection(e.value)] : (e.left && qr(e.left, n), e.right && qr(e.right, i), [a.collection(n), a.collection(i)]) : e.value ? [a.collection(e.value)] : (e.left && (n = Fo(e.left, r - 1, a)), e.right && (i = Fo(e.right, r - 1, a)), n.concat(i));
}, ou = function(e) {
  for (var r = this.cy(), a = this.nodes(), n = Sd(e), i = n.attributes, o = function(m, E) {
    return zn(n.distance, i.length, function(C) {
      return i[C](m);
    }, function(C) {
      return i[C](E);
    }, m, E);
  }, s = [], u = [], l = [], f = [], v = 0; v < a.length; v++) {
    var c = {
      value: n.mode === "dendrogram" ? a[v] : [a[v]],
      key: v,
      index: v
    };
    s[v] = c, f[v] = c, u[v] = [], l[v] = 0;
  }
  for (var h = 0; h < s.length; h++)
    for (var d = 0; d <= h; d++) {
      var g = void 0;
      n.mode === "dendrogram" ? g = h === d ? 1 / 0 : o(s[h].value, s[d].value) : g = h === d ? 1 / 0 : o(s[h].value[0], s[d].value[0]), u[h][d] = g, u[d][h] = g, g < u[h][l[h]] && (l[h] = d);
    }
  for (var p = iu(s, f, u, l, n); p; )
    p = iu(s, f, u, l, n);
  var y;
  return n.mode === "dendrogram" ? (y = Fo(s[0], n.dendrogramDepth, r), n.addDendrogram && Bo(s[0], r)) : (y = new Array(s.length), s.forEach(function(b, m) {
    b.key = b.index = null, y[m] = r.collection(b.value);
  })), y;
}, Ad = {
  hierarchicalClustering: ou,
  hca: ou
}, Ld = ft({
  distance: "euclidean",
  // distance metric to compare attributes between two nodes
  preference: "median",
  // suitability of a data point to serve as an exemplar
  damping: 0.8,
  // damping factor between [0.5, 1)
  maxIterations: 1e3,
  // max number of iterations to run
  minIterations: 100,
  // min number of iterations to run in order for clustering to stop
  attributes: [
    // functions to quantify the similarity between any two points
    // e.g. node => node.data('weight')
  ]
}), Rd = function(e) {
  var r = e.damping, a = e.preference;
  0.5 <= r && r < 1 || qe("Damping must range on [0.5, 1).  Got: ".concat(r));
  var n = ["median", "mean", "min", "max"];
  return n.some(function(i) {
    return i === a;
  }) || ne(a) || qe("Preference must be one of [".concat(n.map(function(i) {
    return "'".concat(i, "'");
  }).join(", "), "] or a number.  Got: ").concat(a)), Ld(e);
}, Md = function(e, r, a, n) {
  var i = function(s, u) {
    return n[u](s);
  };
  return -zn(e, n.length, function(o) {
    return i(r, o);
  }, function(o) {
    return i(a, o);
  }, r, a);
}, Pd = function(e, r) {
  var a = null;
  return r === "median" ? a = Rh(e) : r === "mean" ? a = Lh(e) : r === "min" ? a = Sh(e) : r === "max" ? a = Ah(e) : a = r, a;
}, Id = function(e, r, a) {
  for (var n = [], i = 0; i < e; i++)
    r[i * e + i] + a[i * e + i] > 0 && n.push(i);
  return n;
}, su = function(e, r, a) {
  for (var n = [], i = 0; i < e; i++) {
    for (var o = -1, s = -1 / 0, u = 0; u < a.length; u++) {
      var l = a[u];
      r[i * e + l] > s && (o = l, s = r[i * e + l]);
    }
    o > 0 && n.push(o);
  }
  for (var f = 0; f < a.length; f++)
    n[a[f]] = a[f];
  return n;
}, Od = function(e, r, a) {
  for (var n = su(e, r, a), i = 0; i < a.length; i++) {
    for (var o = [], s = 0; s < n.length; s++)
      n[s] === a[i] && o.push(s);
    for (var u = -1, l = -1 / 0, f = 0; f < o.length; f++) {
      for (var v = 0, c = 0; c < o.length; c++)
        v += r[o[c] * e + o[f]];
      v > l && (u = f, l = v);
    }
    a[i] = o[u];
  }
  return n = su(e, r, a), n;
}, uu = function(e) {
  for (var r = this.cy(), a = this.nodes(), n = Rd(e), i = {}, o = 0; o < a.length; o++)
    i[a[o].id()] = o;
  var s, u, l, f, v, c;
  s = a.length, u = s * s, l = new Array(u);
  for (var h = 0; h < u; h++)
    l[h] = -1 / 0;
  for (var d = 0; d < s; d++)
    for (var g = 0; g < s; g++)
      d !== g && (l[d * s + g] = Md(n.distance, a[d], a[g], n.attributes));
  f = Pd(l, n.preference);
  for (var p = 0; p < s; p++)
    l[p * s + p] = f;
  v = new Array(u);
  for (var y = 0; y < u; y++)
    v[y] = 0;
  c = new Array(u);
  for (var b = 0; b < u; b++)
    c[b] = 0;
  for (var m = new Array(s), E = new Array(s), C = new Array(s), S = 0; S < s; S++)
    m[S] = 0, E[S] = 0, C[S] = 0;
  for (var w = new Array(s * n.minIterations), x = 0; x < w.length; x++)
    w[x] = 0;
  var T;
  for (T = 0; T < n.maxIterations; T++) {
    for (var D = 0; D < s; D++) {
      for (var A = -1 / 0, L = -1 / 0, R = -1, P = 0, I = 0; I < s; I++)
        m[I] = v[D * s + I], P = c[D * s + I] + l[D * s + I], P >= A ? (L = A, A = P, R = I) : P > L && (L = P);
      for (var k = 0; k < s; k++)
        v[D * s + k] = (1 - n.damping) * (l[D * s + k] - A) + n.damping * m[k];
      v[D * s + R] = (1 - n.damping) * (l[D * s + R] - L) + n.damping * m[R];
    }
    for (var O = 0; O < s; O++) {
      for (var N = 0, F = 0; F < s; F++)
        m[F] = c[F * s + O], E[F] = Math.max(0, v[F * s + O]), N += E[F];
      N -= E[O], E[O] = v[O * s + O], N += E[O];
      for (var G = 0; G < s; G++)
        c[G * s + O] = (1 - n.damping) * Math.min(0, N - E[G]) + n.damping * m[G];
      c[O * s + O] = (1 - n.damping) * (N - E[O]) + n.damping * m[O];
    }
    for (var B = 0, z = 0; z < s; z++) {
      var Y = c[z * s + z] + v[z * s + z] > 0 ? 1 : 0;
      w[T % n.minIterations * s + z] = Y, B += Y;
    }
    if (B > 0 && (T >= n.minIterations - 1 || T == n.maxIterations - 1)) {
      for (var $ = 0, X = 0; X < s; X++) {
        C[X] = 0;
        for (var j = 0; j < n.minIterations; j++)
          C[X] += w[j * s + X];
        (C[X] === 0 || C[X] === n.minIterations) && $++;
      }
      if ($ === s)
        break;
    }
  }
  for (var ee = Id(s, v, c), ae = Od(s, l, ee), K = {}, V = 0; V < ee.length; V++)
    K[ee[V]] = [];
  for (var q = 0; q < a.length; q++) {
    var H = i[a[q].id()], Z = ae[H];
    Z != null && K[Z].push(a[q]);
  }
  for (var re = new Array(ee.length), le = 0; le < ee.length; le++)
    re[le] = r.collection(K[ee[le]]);
  return re;
}, kd = {
  affinityPropagation: uu,
  ap: uu
}, Nd = ft({
  root: void 0,
  directed: !1
}), Bd = {
  hierholzer: function(e) {
    if (!Ie(e)) {
      var r = arguments;
      e = {
        root: r[0],
        directed: r[1]
      };
    }
    var a = Nd(e), n = a.root, i = a.directed, o = this, s = !1, u, l, f;
    n && (f = de(n) ? this.filter(n)[0].id() : n[0].id());
    var v = {}, c = {};
    i ? o.forEach(function(b) {
      var m = b.id();
      if (b.isNode()) {
        var E = b.indegree(!0), C = b.outdegree(!0), S = E - C, w = C - E;
        S == 1 ? u ? s = !0 : u = m : w == 1 ? l ? s = !0 : l = m : (w > 1 || S > 1) && (s = !0), v[m] = [], b.outgoers().forEach(function(x) {
          x.isEdge() && v[m].push(x.id());
        });
      } else
        c[m] = [void 0, b.target().id()];
    }) : o.forEach(function(b) {
      var m = b.id();
      if (b.isNode()) {
        var E = b.degree(!0);
        E % 2 && (u ? l ? s = !0 : l = m : u = m), v[m] = [], b.connectedEdges().forEach(function(C) {
          return v[m].push(C.id());
        });
      } else
        c[m] = [b.source().id(), b.target().id()];
    });
    var h = {
      found: !1,
      trail: void 0
    };
    if (s) return h;
    if (l && u)
      if (i) {
        if (f && l != f)
          return h;
        f = l;
      } else {
        if (f && l != f && u != f)
          return h;
        f || (f = l);
      }
    else
      f || (f = o[0].id());
    var d = function(m) {
      for (var E = m, C = [m], S, w, x; v[E].length; )
        S = v[E].shift(), w = c[S][0], x = c[S][1], E != x ? (v[x] = v[x].filter(function(T) {
          return T != S;
        }), E = x) : !i && E != w && (v[w] = v[w].filter(function(T) {
          return T != S;
        }), E = w), C.unshift(S), C.unshift(E);
      return C;
    }, g = [], p = [];
    for (p = d(f); p.length != 1; )
      v[p[0]].length == 0 ? (g.unshift(o.getElementById(p.shift())), g.unshift(o.getElementById(p.shift()))) : p = d(p.shift()).concat(p);
    g.unshift(o.getElementById(p.shift()));
    for (var y in v)
      if (v[y].length)
        return h;
    return h.found = !0, h.trail = this.spawn(g, !0), h;
  }
}, Qa = function() {
  var e = this, r = {}, a = 0, n = 0, i = [], o = [], s = {}, u = function(c, h) {
    for (var d = o.length - 1, g = [], p = e.spawn(); o[d].x != c || o[d].y != h; )
      g.push(o.pop().edge), d--;
    g.push(o.pop().edge), g.forEach(function(y) {
      var b = y.connectedNodes().intersection(e);
      p.merge(y), b.forEach(function(m) {
        var E = m.id(), C = m.connectedEdges().intersection(e);
        p.merge(m), r[E].cutVertex ? p.merge(C.filter(function(S) {
          return S.isLoop();
        })) : p.merge(C);
      });
    }), i.push(p);
  }, l = function(c, h, d) {
    c === d && (n += 1), r[h] = {
      id: a,
      low: a++,
      cutVertex: !1
    };
    var g = e.getElementById(h).connectedEdges().intersection(e);
    if (g.size() === 0)
      i.push(e.spawn(e.getElementById(h)));
    else {
      var p, y, b, m;
      g.forEach(function(E) {
        p = E.source().id(), y = E.target().id(), b = p === h ? y : p, b !== d && (m = E.id(), s[m] || (s[m] = !0, o.push({
          x: h,
          y: b,
          edge: E
        })), b in r ? r[h].low = Math.min(r[h].low, r[b].id) : (l(c, b, h), r[h].low = Math.min(r[h].low, r[b].low), r[h].id <= r[b].low && (r[h].cutVertex = !0, u(h, b))));
      });
    }
  };
  e.forEach(function(v) {
    if (v.isNode()) {
      var c = v.id();
      c in r || (n = 0, l(c, c), r[c].cutVertex = n > 1);
    }
  });
  var f = Object.keys(r).filter(function(v) {
    return r[v].cutVertex;
  }).map(function(v) {
    return e.getElementById(v);
  });
  return {
    cut: e.spawn(f),
    components: i
  };
}, Fd = {
  hopcroftTarjanBiconnected: Qa,
  htbc: Qa,
  htb: Qa,
  hopcroftTarjanBiconnectedComponents: Qa
}, Ja = function() {
  var e = this, r = {}, a = 0, n = [], i = [], o = e.spawn(e), s = function(l) {
    i.push(l), r[l] = {
      index: a,
      low: a++,
      explored: !1
    };
    var f = e.getElementById(l).connectedEdges().intersection(e);
    if (f.forEach(function(g) {
      var p = g.target().id();
      p !== l && (p in r || s(p), r[p].explored || (r[l].low = Math.min(r[l].low, r[p].low)));
    }), r[l].index === r[l].low) {
      for (var v = e.spawn(); ; ) {
        var c = i.pop();
        if (v.merge(e.getElementById(c)), r[c].low = r[l].index, r[c].explored = !0, c === l)
          break;
      }
      var h = v.edgesWith(v), d = v.merge(h);
      n.push(d), o = o.difference(d);
    }
  };
  return e.forEach(function(u) {
    if (u.isNode()) {
      var l = u.id();
      l in r || s(l);
    }
  }), {
    cut: o,
    components: n
  };
}, Gd = {
  tarjanStronglyConnected: Ja,
  tsc: Ja,
  tscc: Ja,
  tarjanStronglyConnectedComponents: Ja
}, kf = {};
[Da, dh, gh, yh, bh, Eh, Ch, Qh, Xr, Wr, No, fd, Td, Ad, kd, Bd, Fd, Gd].forEach(function(t) {
  ye(kf, t);
});
/*!
Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
Licensed under The MIT License (http://opensource.org/licenses/MIT)
*/
var Nf = 0, Bf = 1, Ff = 2, Nt = function(e) {
  if (!(this instanceof Nt)) return new Nt(e);
  this.id = "Thenable/1.0.7", this.state = Nf, this.fulfillValue = void 0, this.rejectReason = void 0, this.onFulfilled = [], this.onRejected = [], this.proxy = {
    then: this.then.bind(this)
  }, typeof e == "function" && e.call(this, this.fulfill.bind(this), this.reject.bind(this));
};
Nt.prototype = {
  /*  promise resolving methods  */
  fulfill: function(e) {
    return lu(this, Bf, "fulfillValue", e);
  },
  reject: function(e) {
    return lu(this, Ff, "rejectReason", e);
  },
  /*  "The then Method" [Promises/A+ 1.1, 1.2, 2.2]  */
  then: function(e, r) {
    var a = this, n = new Nt();
    return a.onFulfilled.push(vu(e, n, "fulfill")), a.onRejected.push(vu(r, n, "reject")), Gf(a), n.proxy;
  }
};
var lu = function(e, r, a, n) {
  return e.state === Nf && (e.state = r, e[a] = n, Gf(e)), e;
}, Gf = function(e) {
  e.state === Bf ? fu(e, "onFulfilled", e.fulfillValue) : e.state === Ff && fu(e, "onRejected", e.rejectReason);
}, fu = function(e, r, a) {
  if (e[r].length !== 0) {
    var n = e[r];
    e[r] = [];
    var i = function() {
      for (var s = 0; s < n.length; s++) n[s](a);
    };
    typeof setImmediate == "function" ? setImmediate(i) : setTimeout(i, 0);
  }
}, vu = function(e, r, a) {
  return function(n) {
    if (typeof e != "function")
      r[a].call(r, n);
    else {
      var i;
      try {
        i = e(n);
      } catch (o) {
        r.reject(o);
        return;
      }
      zf(r, i);
    }
  };
}, zf = function(e, r) {
  if (e === r || e.proxy === r) {
    e.reject(new TypeError("cannot resolve promise with itself"));
    return;
  }
  var a;
  if (tt(r) === "object" && r !== null || typeof r == "function")
    try {
      a = r.then;
    } catch (i) {
      e.reject(i);
      return;
    }
  if (typeof a == "function") {
    var n = !1;
    try {
      a.call(
        r,
        /*  resolvePromise  */
        /*  [Promises/A+ 2.3.3.3.1]  */
        function(i) {
          n || (n = !0, i === r ? e.reject(new TypeError("circular thenable chain")) : zf(e, i));
        },
        /*  rejectPromise  */
        /*  [Promises/A+ 2.3.3.3.2]  */
        function(i) {
          n || (n = !0, e.reject(i));
        }
      );
    } catch (i) {
      n || e.reject(i);
    }
    return;
  }
  e.fulfill(r);
};
Nt.all = function(t) {
  return new Nt(function(e, r) {
    for (var a = new Array(t.length), n = 0, i = function(u, l) {
      a[u] = l, n++, n === t.length && e(a);
    }, o = 0; o < t.length; o++)
      (function(s) {
        var u = t[s], l = u != null && u.then != null;
        if (l)
          u.then(function(v) {
            i(s, v);
          }, function(v) {
            r(v);
          });
        else {
          var f = u;
          i(s, f);
        }
      })(o);
  });
};
Nt.resolve = function(t) {
  return new Nt(function(e, r) {
    e(t);
  });
};
Nt.reject = function(t) {
  return new Nt(function(e, r) {
    r(t);
  });
};
var ra = typeof Promise < "u" ? Promise : Nt, Go = function(e, r, a) {
  var n = jo(e), i = !n, o = this._private = ye({
    duration: 1e3
  }, r, a);
  if (o.target = e, o.style = o.style || o.css, o.started = !1, o.playing = !1, o.hooked = !1, o.applying = !1, o.progress = 0, o.completes = [], o.frames = [], o.complete && He(o.complete) && o.completes.push(o.complete), i) {
    var s = e.position();
    o.startPosition = o.startPosition || {
      x: s.x,
      y: s.y
    }, o.startStyle = o.startStyle || e.cy().style().getAnimationStartStyle(e, o.style);
  }
  if (n) {
    var u = e.pan();
    o.startPan = {
      x: u.x,
      y: u.y
    }, o.startZoom = e.zoom();
  }
  this.length = 1, this[0] = this;
}, Lr = Go.prototype;
ye(Lr, {
  instanceString: function() {
    return "animation";
  },
  hook: function() {
    var e = this._private;
    if (!e.hooked) {
      var r, a = e.target._private.animation;
      e.queue ? r = a.queue : r = a.current, r.push(this), Ct(e.target) && e.target.cy().addToAnimationPool(e.target), e.hooked = !0;
    }
    return this;
  },
  play: function() {
    var e = this._private;
    return e.progress === 1 && (e.progress = 0), e.playing = !0, e.started = !1, e.stopped = !1, this.hook(), this;
  },
  playing: function() {
    return this._private.playing;
  },
  apply: function() {
    var e = this._private;
    return e.applying = !0, e.started = !1, e.stopped = !1, this.hook(), this;
  },
  applying: function() {
    return this._private.applying;
  },
  pause: function() {
    var e = this._private;
    return e.playing = !1, e.started = !1, this;
  },
  stop: function() {
    var e = this._private;
    return e.playing = !1, e.started = !1, e.stopped = !0, this;
  },
  rewind: function() {
    return this.progress(0);
  },
  fastforward: function() {
    return this.progress(1);
  },
  time: function(e) {
    var r = this._private;
    return e === void 0 ? r.progress * r.duration : this.progress(e / r.duration);
  },
  progress: function(e) {
    var r = this._private, a = r.playing;
    return e === void 0 ? r.progress : (a && this.pause(), r.progress = e, r.started = !1, a && this.play(), this);
  },
  completed: function() {
    return this._private.progress === 1;
  },
  reverse: function() {
    var e = this._private, r = e.playing;
    r && this.pause(), e.progress = 1 - e.progress, e.started = !1;
    var a = function(l, f) {
      var v = e[l];
      v != null && (e[l] = e[f], e[f] = v);
    };
    if (a("zoom", "startZoom"), a("pan", "startPan"), a("position", "startPosition"), e.style)
      for (var n = 0; n < e.style.length; n++) {
        var i = e.style[n], o = i.name, s = e.startStyle[o];
        e.startStyle[o] = i, e.style[n] = s;
      }
    return r && this.play(), this;
  },
  promise: function(e) {
    var r = this._private, a;
    switch (e) {
      case "frame":
        a = r.frames;
        break;
      default:
      case "complete":
      case "completed":
        a = r.completes;
    }
    return new ra(function(n, i) {
      a.push(function() {
        n();
      });
    });
  }
});
Lr.complete = Lr.completed;
Lr.run = Lr.play;
Lr.running = Lr.playing;
var zd = {
  animated: function() {
    return function() {
      var r = this, a = r.length !== void 0, n = a ? r : [r], i = this._private.cy || this;
      if (!i.styleEnabled())
        return !1;
      var o = n[0];
      if (o)
        return o._private.animation.current.length > 0;
    };
  },
  // animated
  clearQueue: function() {
    return function() {
      var r = this, a = r.length !== void 0, n = a ? r : [r], i = this._private.cy || this;
      if (!i.styleEnabled())
        return this;
      for (var o = 0; o < n.length; o++) {
        var s = n[o];
        s._private.animation.queue = [];
      }
      return this;
    };
  },
  // clearQueue
  delay: function() {
    return function(r, a) {
      var n = this._private.cy || this;
      return n.styleEnabled() ? this.animate({
        delay: r,
        duration: r,
        complete: a
      }) : this;
    };
  },
  // delay
  delayAnimation: function() {
    return function(r, a) {
      var n = this._private.cy || this;
      return n.styleEnabled() ? this.animation({
        delay: r,
        duration: r,
        complete: a
      }) : this;
    };
  },
  // delay
  animation: function() {
    return function(r, a) {
      var n = this, i = n.length !== void 0, o = i ? n : [n], s = this._private.cy || this, u = !i, l = !u;
      if (!s.styleEnabled())
        return this;
      var f = s.style();
      r = ye({}, r, a);
      var v = Object.keys(r).length === 0;
      if (v)
        return new Go(o[0], r);
      switch (r.duration === void 0 && (r.duration = 400), r.duration) {
        case "slow":
          r.duration = 600;
          break;
        case "fast":
          r.duration = 200;
          break;
      }
      if (l && (r.style = f.getPropsList(r.style || r.css), r.css = void 0), l && r.renderedPosition != null) {
        var c = r.renderedPosition, h = s.pan(), d = s.zoom();
        r.position = Cf(c, d, h);
      }
      if (u && r.panBy != null) {
        var g = r.panBy, p = s.pan();
        r.pan = {
          x: p.x + g.x,
          y: p.y + g.y
        };
      }
      var y = r.center || r.centre;
      if (u && y != null) {
        var b = s.getCenterPan(y.eles, r.zoom);
        b != null && (r.pan = b);
      }
      if (u && r.fit != null) {
        var m = r.fit, E = s.getFitViewport(m.eles || m.boundingBox, m.padding);
        E != null && (r.pan = E.pan, r.zoom = E.zoom);
      }
      if (u && Ie(r.zoom)) {
        var C = s.getZoomedViewport(r.zoom);
        C != null ? (C.zoomed && (r.zoom = C.zoom), C.panned && (r.pan = C.pan)) : r.zoom = null;
      }
      return new Go(o[0], r);
    };
  },
  // animate
  animate: function() {
    return function(r, a) {
      var n = this, i = n.length !== void 0, o = i ? n : [n], s = this._private.cy || this;
      if (!s.styleEnabled())
        return this;
      a && (r = ye({}, r, a));
      for (var u = 0; u < o.length; u++) {
        var l = o[u], f = l.animated() && (r.queue === void 0 || r.queue), v = l.animation(r, f ? {
          queue: !0
        } : void 0);
        v.play();
      }
      return this;
    };
  },
  // animate
  stop: function() {
    return function(r, a) {
      var n = this, i = n.length !== void 0, o = i ? n : [n], s = this._private.cy || this;
      if (!s.styleEnabled())
        return this;
      for (var u = 0; u < o.length; u++) {
        for (var l = o[u], f = l._private, v = f.animation.current, c = 0; c < v.length; c++) {
          var h = v[c], d = h._private;
          a && (d.duration = 0);
        }
        r && (f.animation.queue = []), a || (f.animation.current = []);
      }
      return s.notify("draw"), this;
    };
  }
  // stop
}, xi, cu;
function _n() {
  if (cu) return xi;
  cu = 1;
  var t = Array.isArray;
  return xi = t, xi;
}
var Ti, hu;
function _d() {
  if (hu) return Ti;
  hu = 1;
  var t = _n(), e = Fa(), r = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, a = /^\w*$/;
  function n(i, o) {
    if (t(i))
      return !1;
    var s = typeof i;
    return s == "number" || s == "symbol" || s == "boolean" || i == null || e(i) ? !0 : a.test(i) || !r.test(i) || o != null && i in Object(o);
  }
  return Ti = n, Ti;
}
var Ci, du;
function Vd() {
  if (du) return Ci;
  du = 1;
  var t = gf(), e = Ba(), r = "[object AsyncFunction]", a = "[object Function]", n = "[object GeneratorFunction]", i = "[object Proxy]";
  function o(s) {
    if (!e(s))
      return !1;
    var u = t(s);
    return u == a || u == n || u == r || u == i;
  }
  return Ci = o, Ci;
}
var Di, gu;
function Ud() {
  if (gu) return Di;
  gu = 1;
  var t = Bn(), e = t["__core-js_shared__"];
  return Di = e, Di;
}
var Si, pu;
function qd() {
  if (pu) return Si;
  pu = 1;
  var t = Ud(), e = (function() {
    var a = /[^.]+$/.exec(t && t.keys && t.keys.IE_PROTO || "");
    return a ? "Symbol(src)_1." + a : "";
  })();
  function r(a) {
    return !!e && e in a;
  }
  return Si = r, Si;
}
var Ai, yu;
function Yd() {
  if (yu) return Ai;
  yu = 1;
  var t = Function.prototype, e = t.toString;
  function r(a) {
    if (a != null) {
      try {
        return e.call(a);
      } catch {
      }
      try {
        return a + "";
      } catch {
      }
    }
    return "";
  }
  return Ai = r, Ai;
}
var Li, mu;
function Hd() {
  if (mu) return Li;
  mu = 1;
  var t = Vd(), e = qd(), r = Ba(), a = Yd(), n = /[\\^$.*+?()[\]{}|]/g, i = /^\[object .+?Constructor\]$/, o = Function.prototype, s = Object.prototype, u = o.toString, l = s.hasOwnProperty, f = RegExp(
    "^" + u.call(l).replace(n, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
  );
  function v(c) {
    if (!r(c) || e(c))
      return !1;
    var h = t(c) ? f : i;
    return h.test(a(c));
  }
  return Li = v, Li;
}
var Ri, bu;
function Xd() {
  if (bu) return Ri;
  bu = 1;
  function t(e, r) {
    return e?.[r];
  }
  return Ri = t, Ri;
}
var Mi, wu;
function fs() {
  if (wu) return Mi;
  wu = 1;
  var t = Hd(), e = Xd();
  function r(a, n) {
    var i = e(a, n);
    return t(i) ? i : void 0;
  }
  return Mi = r, Mi;
}
var Pi, Eu;
function Vn() {
  if (Eu) return Pi;
  Eu = 1;
  var t = fs(), e = t(Object, "create");
  return Pi = e, Pi;
}
var Ii, xu;
function Wd() {
  if (xu) return Ii;
  xu = 1;
  var t = Vn();
  function e() {
    this.__data__ = t ? t(null) : {}, this.size = 0;
  }
  return Ii = e, Ii;
}
var Oi, Tu;
function $d() {
  if (Tu) return Oi;
  Tu = 1;
  function t(e) {
    var r = this.has(e) && delete this.__data__[e];
    return this.size -= r ? 1 : 0, r;
  }
  return Oi = t, Oi;
}
var ki, Cu;
function Kd() {
  if (Cu) return ki;
  Cu = 1;
  var t = Vn(), e = "__lodash_hash_undefined__", r = Object.prototype, a = r.hasOwnProperty;
  function n(i) {
    var o = this.__data__;
    if (t) {
      var s = o[i];
      return s === e ? void 0 : s;
    }
    return a.call(o, i) ? o[i] : void 0;
  }
  return ki = n, ki;
}
var Ni, Du;
function Zd() {
  if (Du) return Ni;
  Du = 1;
  var t = Vn(), e = Object.prototype, r = e.hasOwnProperty;
  function a(n) {
    var i = this.__data__;
    return t ? i[n] !== void 0 : r.call(i, n);
  }
  return Ni = a, Ni;
}
var Bi, Su;
function Qd() {
  if (Su) return Bi;
  Su = 1;
  var t = Vn(), e = "__lodash_hash_undefined__";
  function r(a, n) {
    var i = this.__data__;
    return this.size += this.has(a) ? 0 : 1, i[a] = t && n === void 0 ? e : n, this;
  }
  return Bi = r, Bi;
}
var Fi, Au;
function Jd() {
  if (Au) return Fi;
  Au = 1;
  var t = Wd(), e = $d(), r = Kd(), a = Zd(), n = Qd();
  function i(o) {
    var s = -1, u = o == null ? 0 : o.length;
    for (this.clear(); ++s < u; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = t, i.prototype.delete = e, i.prototype.get = r, i.prototype.has = a, i.prototype.set = n, Fi = i, Fi;
}
var Gi, Lu;
function jd() {
  if (Lu) return Gi;
  Lu = 1;
  function t() {
    this.__data__ = [], this.size = 0;
  }
  return Gi = t, Gi;
}
var zi, Ru;
function _f() {
  if (Ru) return zi;
  Ru = 1;
  function t(e, r) {
    return e === r || e !== e && r !== r;
  }
  return zi = t, zi;
}
var _i, Mu;
function Un() {
  if (Mu) return _i;
  Mu = 1;
  var t = _f();
  function e(r, a) {
    for (var n = r.length; n--; )
      if (t(r[n][0], a))
        return n;
    return -1;
  }
  return _i = e, _i;
}
var Vi, Pu;
function eg() {
  if (Pu) return Vi;
  Pu = 1;
  var t = Un(), e = Array.prototype, r = e.splice;
  function a(n) {
    var i = this.__data__, o = t(i, n);
    if (o < 0)
      return !1;
    var s = i.length - 1;
    return o == s ? i.pop() : r.call(i, o, 1), --this.size, !0;
  }
  return Vi = a, Vi;
}
var Ui, Iu;
function tg() {
  if (Iu) return Ui;
  Iu = 1;
  var t = Un();
  function e(r) {
    var a = this.__data__, n = t(a, r);
    return n < 0 ? void 0 : a[n][1];
  }
  return Ui = e, Ui;
}
var qi, Ou;
function rg() {
  if (Ou) return qi;
  Ou = 1;
  var t = Un();
  function e(r) {
    return t(this.__data__, r) > -1;
  }
  return qi = e, qi;
}
var Yi, ku;
function ag() {
  if (ku) return Yi;
  ku = 1;
  var t = Un();
  function e(r, a) {
    var n = this.__data__, i = t(n, r);
    return i < 0 ? (++this.size, n.push([r, a])) : n[i][1] = a, this;
  }
  return Yi = e, Yi;
}
var Hi, Nu;
function ng() {
  if (Nu) return Hi;
  Nu = 1;
  var t = jd(), e = eg(), r = tg(), a = rg(), n = ag();
  function i(o) {
    var s = -1, u = o == null ? 0 : o.length;
    for (this.clear(); ++s < u; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = t, i.prototype.delete = e, i.prototype.get = r, i.prototype.has = a, i.prototype.set = n, Hi = i, Hi;
}
var Xi, Bu;
function ig() {
  if (Bu) return Xi;
  Bu = 1;
  var t = fs(), e = Bn(), r = t(e, "Map");
  return Xi = r, Xi;
}
var Wi, Fu;
function og() {
  if (Fu) return Wi;
  Fu = 1;
  var t = Jd(), e = ng(), r = ig();
  function a() {
    this.size = 0, this.__data__ = {
      hash: new t(),
      map: new (r || e)(),
      string: new t()
    };
  }
  return Wi = a, Wi;
}
var $i, Gu;
function sg() {
  if (Gu) return $i;
  Gu = 1;
  function t(e) {
    var r = typeof e;
    return r == "string" || r == "number" || r == "symbol" || r == "boolean" ? e !== "__proto__" : e === null;
  }
  return $i = t, $i;
}
var Ki, zu;
function qn() {
  if (zu) return Ki;
  zu = 1;
  var t = sg();
  function e(r, a) {
    var n = r.__data__;
    return t(a) ? n[typeof a == "string" ? "string" : "hash"] : n.map;
  }
  return Ki = e, Ki;
}
var Zi, _u;
function ug() {
  if (_u) return Zi;
  _u = 1;
  var t = qn();
  function e(r) {
    var a = t(this, r).delete(r);
    return this.size -= a ? 1 : 0, a;
  }
  return Zi = e, Zi;
}
var Qi, Vu;
function lg() {
  if (Vu) return Qi;
  Vu = 1;
  var t = qn();
  function e(r) {
    return t(this, r).get(r);
  }
  return Qi = e, Qi;
}
var Ji, Uu;
function fg() {
  if (Uu) return Ji;
  Uu = 1;
  var t = qn();
  function e(r) {
    return t(this, r).has(r);
  }
  return Ji = e, Ji;
}
var ji, qu;
function vg() {
  if (qu) return ji;
  qu = 1;
  var t = qn();
  function e(r, a) {
    var n = t(this, r), i = n.size;
    return n.set(r, a), this.size += n.size == i ? 0 : 1, this;
  }
  return ji = e, ji;
}
var eo, Yu;
function cg() {
  if (Yu) return eo;
  Yu = 1;
  var t = og(), e = ug(), r = lg(), a = fg(), n = vg();
  function i(o) {
    var s = -1, u = o == null ? 0 : o.length;
    for (this.clear(); ++s < u; ) {
      var l = o[s];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = t, i.prototype.delete = e, i.prototype.get = r, i.prototype.has = a, i.prototype.set = n, eo = i, eo;
}
var to, Hu;
function hg() {
  if (Hu) return to;
  Hu = 1;
  var t = cg(), e = "Expected a function";
  function r(a, n) {
    if (typeof a != "function" || n != null && typeof n != "function")
      throw new TypeError(e);
    var i = function() {
      var o = arguments, s = n ? n.apply(this, o) : o[0], u = i.cache;
      if (u.has(s))
        return u.get(s);
      var l = a.apply(this, o);
      return i.cache = u.set(s, l) || u, l;
    };
    return i.cache = new (r.Cache || t)(), i;
  }
  return r.Cache = t, to = r, to;
}
var ro, Xu;
function dg() {
  if (Xu) return ro;
  Xu = 1;
  var t = hg(), e = 500;
  function r(a) {
    var n = t(a, function(o) {
      return i.size === e && i.clear(), o;
    }), i = n.cache;
    return n;
  }
  return ro = r, ro;
}
var ao, Wu;
function Vf() {
  if (Wu) return ao;
  Wu = 1;
  var t = dg(), e = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, r = /\\(\\)?/g, a = t(function(n) {
    var i = [];
    return n.charCodeAt(0) === 46 && i.push(""), n.replace(e, function(o, s, u, l) {
      i.push(u ? l.replace(r, "$1") : s || o);
    }), i;
  });
  return ao = a, ao;
}
var no, $u;
function Uf() {
  if ($u) return no;
  $u = 1;
  function t(e, r) {
    for (var a = -1, n = e == null ? 0 : e.length, i = Array(n); ++a < n; )
      i[a] = r(e[a], a, e);
    return i;
  }
  return no = t, no;
}
var io, Ku;
function gg() {
  if (Ku) return io;
  Ku = 1;
  var t = ts(), e = Uf(), r = _n(), a = Fa(), n = t ? t.prototype : void 0, i = n ? n.toString : void 0;
  function o(s) {
    if (typeof s == "string")
      return s;
    if (r(s))
      return e(s, o) + "";
    if (a(s))
      return i ? i.call(s) : "";
    var u = s + "";
    return u == "0" && 1 / s == -1 / 0 ? "-0" : u;
  }
  return io = o, io;
}
var oo, Zu;
function qf() {
  if (Zu) return oo;
  Zu = 1;
  var t = gg();
  function e(r) {
    return r == null ? "" : t(r);
  }
  return oo = e, oo;
}
var so, Qu;
function Yf() {
  if (Qu) return so;
  Qu = 1;
  var t = _n(), e = _d(), r = Vf(), a = qf();
  function n(i, o) {
    return t(i) ? i : e(i, o) ? [i] : r(a(i));
  }
  return so = n, so;
}
var uo, Ju;
function vs() {
  if (Ju) return uo;
  Ju = 1;
  var t = Fa();
  function e(r) {
    if (typeof r == "string" || t(r))
      return r;
    var a = r + "";
    return a == "0" && 1 / r == -1 / 0 ? "-0" : a;
  }
  return uo = e, uo;
}
var lo, ju;
function pg() {
  if (ju) return lo;
  ju = 1;
  var t = Yf(), e = vs();
  function r(a, n) {
    n = t(n, a);
    for (var i = 0, o = n.length; a != null && i < o; )
      a = a[e(n[i++])];
    return i && i == o ? a : void 0;
  }
  return lo = r, lo;
}
var fo, el;
function yg() {
  if (el) return fo;
  el = 1;
  var t = pg();
  function e(r, a, n) {
    var i = r == null ? void 0 : t(r, a);
    return i === void 0 ? n : i;
  }
  return fo = e, fo;
}
var mg = yg(), bg = /* @__PURE__ */ Na(mg), vo, tl;
function wg() {
  if (tl) return vo;
  tl = 1;
  var t = fs(), e = (function() {
    try {
      var r = t(Object, "defineProperty");
      return r({}, "", {}), r;
    } catch {
    }
  })();
  return vo = e, vo;
}
var co, rl;
function Eg() {
  if (rl) return co;
  rl = 1;
  var t = wg();
  function e(r, a, n) {
    a == "__proto__" && t ? t(r, a, {
      configurable: !0,
      enumerable: !0,
      value: n,
      writable: !0
    }) : r[a] = n;
  }
  return co = e, co;
}
var ho, al;
function xg() {
  if (al) return ho;
  al = 1;
  var t = Eg(), e = _f(), r = Object.prototype, a = r.hasOwnProperty;
  function n(i, o, s) {
    var u = i[o];
    (!(a.call(i, o) && e(u, s)) || s === void 0 && !(o in i)) && t(i, o, s);
  }
  return ho = n, ho;
}
var go, nl;
function Tg() {
  if (nl) return go;
  nl = 1;
  var t = 9007199254740991, e = /^(?:0|[1-9]\d*)$/;
  function r(a, n) {
    var i = typeof a;
    return n = n ?? t, !!n && (i == "number" || i != "symbol" && e.test(a)) && a > -1 && a % 1 == 0 && a < n;
  }
  return go = r, go;
}
var po, il;
function Cg() {
  if (il) return po;
  il = 1;
  var t = xg(), e = Yf(), r = Tg(), a = Ba(), n = vs();
  function i(o, s, u, l) {
    if (!a(o))
      return o;
    s = e(s, o);
    for (var f = -1, v = s.length, c = v - 1, h = o; h != null && ++f < v; ) {
      var d = n(s[f]), g = u;
      if (d === "__proto__" || d === "constructor" || d === "prototype")
        return o;
      if (f != c) {
        var p = h[d];
        g = l ? l(p, d, h) : void 0, g === void 0 && (g = a(p) ? p : r(s[f + 1]) ? [] : {});
      }
      t(h, d, g), h = h[d];
    }
    return o;
  }
  return po = i, po;
}
var yo, ol;
function Dg() {
  if (ol) return yo;
  ol = 1;
  var t = Cg();
  function e(r, a, n) {
    return r == null ? r : t(r, a, n);
  }
  return yo = e, yo;
}
var Sg = Dg(), Ag = /* @__PURE__ */ Na(Sg), mo, sl;
function Lg() {
  if (sl) return mo;
  sl = 1;
  function t(e, r) {
    var a = -1, n = e.length;
    for (r || (r = Array(n)); ++a < n; )
      r[a] = e[a];
    return r;
  }
  return mo = t, mo;
}
var bo, ul;
function Rg() {
  if (ul) return bo;
  ul = 1;
  var t = Uf(), e = Lg(), r = _n(), a = Fa(), n = Vf(), i = vs(), o = qf();
  function s(u) {
    return r(u) ? t(u, i) : a(u) ? [u] : e(n(o(u)));
  }
  return bo = s, bo;
}
var Mg = Rg(), Pg = /* @__PURE__ */ Na(Mg), Ig = {
  // access data field
  data: function(e) {
    var r = {
      field: "data",
      bindingEvent: "data",
      allowBinding: !1,
      allowSetting: !1,
      allowGetting: !1,
      settingEvent: "data",
      settingTriggersEvent: !1,
      triggerFnName: "trigger",
      immutableKeys: {},
      // key => true if immutable
      updateStyle: !1,
      beforeGet: function(n) {
      },
      beforeSet: function(n, i) {
      },
      onSet: function(n) {
      },
      canSet: function(n) {
        return !0;
      }
    };
    return e = ye({}, r, e), function(n, i) {
      var o = e, s = this, u = s.length !== void 0, l = u ? s : [s], f = u ? s[0] : s;
      if (de(n)) {
        var v = n.indexOf(".") !== -1, c = v && Pg(n);
        if (o.allowGetting && i === void 0) {
          var h;
          return f && (o.beforeGet(f), c && f._private[o.field][n] === void 0 ? h = bg(f._private[o.field], c) : h = f._private[o.field][n]), h;
        } else if (o.allowSetting && i !== void 0) {
          var d = !o.immutableKeys[n];
          if (d) {
            var g = nf({}, n, i);
            o.beforeSet(s, g);
            for (var p = 0, y = l.length; p < y; p++) {
              var b = l[p];
              o.canSet(b) && (c && f._private[o.field][n] === void 0 ? Ag(b._private[o.field], c, i) : b._private[o.field][n] = i);
            }
            o.updateStyle && s.updateStyle(), o.onSet(s), o.settingTriggersEvent && s[o.triggerFnName](o.settingEvent);
          }
        }
      } else if (o.allowSetting && Ie(n)) {
        var m = n, E, C, S = Object.keys(m);
        o.beforeSet(s, m);
        for (var w = 0; w < S.length; w++) {
          E = S[w], C = m[E];
          var x = !o.immutableKeys[E];
          if (x)
            for (var T = 0; T < l.length; T++) {
              var D = l[T];
              o.canSet(D) && (D._private[o.field][E] = C);
            }
        }
        o.updateStyle && s.updateStyle(), o.onSet(s), o.settingTriggersEvent && s[o.triggerFnName](o.settingEvent);
      } else if (o.allowBinding && He(n)) {
        var A = n;
        s.on(o.bindingEvent, A);
      } else if (o.allowGetting && n === void 0) {
        var L;
        return f && (o.beforeGet(f), L = f._private[o.field]), L;
      }
      return s;
    };
  },
  // data
  // remove data field
  removeData: function(e) {
    var r = {
      field: "data",
      event: "data",
      triggerFnName: "trigger",
      triggerEvent: !1,
      immutableKeys: {}
      // key => true if immutable
    };
    return e = ye({}, r, e), function(n) {
      var i = e, o = this, s = o.length !== void 0, u = s ? o : [o];
      if (de(n)) {
        for (var l = n.split(/\s+/), f = l.length, v = 0; v < f; v++) {
          var c = l[v];
          if (!sr(c)) {
            var h = !i.immutableKeys[c];
            if (h)
              for (var d = 0, g = u.length; d < g; d++)
                u[d]._private[i.field][c] = void 0;
          }
        }
        i.triggerEvent && o[i.triggerFnName](i.event);
      } else if (n === void 0) {
        for (var p = 0, y = u.length; p < y; p++)
          for (var b = u[p]._private[i.field], m = Object.keys(b), E = 0; E < m.length; E++) {
            var C = m[E], S = !i.immutableKeys[C];
            S && (b[C] = void 0);
          }
        i.triggerEvent && o[i.triggerFnName](i.event);
      }
      return o;
    };
  }
  // removeData
}, Og = {
  eventAliasesOn: function(e) {
    var r = e;
    r.addListener = r.listen = r.bind = r.on, r.unlisten = r.unbind = r.off = r.removeListener, r.trigger = r.emit, r.pon = r.promiseOn = function(a, n) {
      var i = this, o = Array.prototype.slice.call(arguments, 0);
      return new ra(function(s, u) {
        var l = function(h) {
          i.off.apply(i, v), s(h);
        }, f = o.concat([l]), v = f.concat([]);
        i.on.apply(i, f);
      });
    };
  }
}, Be = {};
[zd, Ig, Og].forEach(function(t) {
  ye(Be, t);
});
var kg = {
  animate: Be.animate(),
  animation: Be.animation(),
  animated: Be.animated(),
  clearQueue: Be.clearQueue(),
  delay: Be.delay(),
  delayAnimation: Be.delayAnimation(),
  stop: Be.stop()
}, fn = {
  classes: function(e) {
    var r = this;
    if (e === void 0) {
      var a = [];
      return r[0]._private.classes.forEach(function(d) {
        return a.push(d);
      }), a;
    } else ze(e) || (e = (e || "").match(/\S+/g) || []);
    for (var n = [], i = new ta(e), o = 0; o < r.length; o++) {
      for (var s = r[o], u = s._private, l = u.classes, f = !1, v = 0; v < e.length; v++) {
        var c = e[v], h = l.has(c);
        if (!h) {
          f = !0;
          break;
        }
      }
      f || (f = l.size !== e.length), f && (u.classes = i, n.push(s));
    }
    return n.length > 0 && this.spawn(n).updateStyle().emit("class"), r;
  },
  addClass: function(e) {
    return this.toggleClass(e, !0);
  },
  hasClass: function(e) {
    var r = this[0];
    return r != null && r._private.classes.has(e);
  },
  toggleClass: function(e, r) {
    ze(e) || (e = e.match(/\S+/g) || []);
    for (var a = this, n = r === void 0, i = [], o = 0, s = a.length; o < s; o++)
      for (var u = a[o], l = u._private.classes, f = !1, v = 0; v < e.length; v++) {
        var c = e[v], h = l.has(c), d = !1;
        r || n && !h ? (l.add(c), d = !0) : (!r || n && h) && (l.delete(c), d = !0), !f && d && (i.push(u), f = !0);
      }
    return i.length > 0 && this.spawn(i).updateStyle().emit("class"), a;
  },
  removeClass: function(e) {
    return this.toggleClass(e, !1);
  },
  flashClass: function(e, r) {
    var a = this;
    if (r == null)
      r = 250;
    else if (r === 0)
      return a;
    return a.addClass(e), setTimeout(function() {
      a.removeClass(e);
    }, r), a;
  }
};
fn.className = fn.classNames = fn.classes;
var Pe = {
  metaChar: "[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",
  // chars we need to escape in let names, etc
  comparatorOp: "=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",
  // binary comparison op (used in data selectors)
  boolOp: "\\?|\\!|\\^",
  // boolean (unary) operators (used in data selectors)
  string: `"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,
  // string literals (used in data selectors) -- doublequotes | singlequotes
  number: et,
  // number literal (used in data selectors) --- e.g. 0.1234, 1234, 12e123
  meta: "degree|indegree|outdegree",
  // allowed metadata fields (i.e. allowed functions to use from Collection)
  separator: "\\s*,\\s*",
  // queries are separated by commas, e.g. edge[foo = 'bar'], node.someClass
  descendant: "\\s+",
  child: "\\s+>\\s+",
  subject: "\\$",
  group: "node|edge|\\*",
  directedEdge: "\\s+->\\s+",
  undirectedEdge: "\\s+<->\\s+"
};
Pe.variable = "(?:[\\w-.]|(?:\\\\" + Pe.metaChar + "))+";
Pe.className = "(?:[\\w-]|(?:\\\\" + Pe.metaChar + "))+";
Pe.value = Pe.string + "|" + Pe.number;
Pe.id = Pe.variable;
(function() {
  var t, e, r;
  for (t = Pe.comparatorOp.split("|"), r = 0; r < t.length; r++)
    e = t[r], Pe.comparatorOp += "|@" + e;
  for (t = Pe.comparatorOp.split("|"), r = 0; r < t.length; r++)
    e = t[r], !(e.indexOf("!") >= 0) && e !== "=" && (Pe.comparatorOp += "|\\!" + e);
})();
var Ge = function() {
  return {
    checks: []
  };
}, ue = {
  /** E.g. node */
  GROUP: 0,
  /** A collection of elements */
  COLLECTION: 1,
  /** A filter(ele) function */
  FILTER: 2,
  /** E.g. [foo > 1] */
  DATA_COMPARE: 3,
  /** E.g. [foo] */
  DATA_EXIST: 4,
  /** E.g. [?foo] */
  DATA_BOOL: 5,
  /** E.g. [[degree > 2]] */
  META_COMPARE: 6,
  /** E.g. :selected */
  STATE: 7,
  /** E.g. #foo */
  ID: 8,
  /** E.g. .foo */
  CLASS: 9,
  /** E.g. #foo <-> #bar */
  UNDIRECTED_EDGE: 10,
  /** E.g. #foo -> #bar */
  DIRECTED_EDGE: 11,
  /** E.g. $#foo -> #bar */
  NODE_SOURCE: 12,
  /** E.g. #foo -> $#bar */
  NODE_TARGET: 13,
  /** E.g. $#foo <-> #bar */
  NODE_NEIGHBOR: 14,
  /** E.g. #foo > #bar */
  CHILD: 15,
  /** E.g. #foo #bar */
  DESCENDANT: 16,
  /** E.g. $#foo > #bar */
  PARENT: 17,
  /** E.g. $#foo #bar */
  ANCESTOR: 18,
  /** E.g. #foo > $bar > #baz */
  COMPOUND_SPLIT: 19,
  /** Always matches, useful placeholder for subject in `COMPOUND_SPLIT` */
  TRUE: 20
}, zo = [{
  selector: ":selected",
  matches: function(e) {
    return e.selected();
  }
}, {
  selector: ":unselected",
  matches: function(e) {
    return !e.selected();
  }
}, {
  selector: ":selectable",
  matches: function(e) {
    return e.selectable();
  }
}, {
  selector: ":unselectable",
  matches: function(e) {
    return !e.selectable();
  }
}, {
  selector: ":locked",
  matches: function(e) {
    return e.locked();
  }
}, {
  selector: ":unlocked",
  matches: function(e) {
    return !e.locked();
  }
}, {
  selector: ":visible",
  matches: function(e) {
    return e.visible();
  }
}, {
  selector: ":hidden",
  matches: function(e) {
    return !e.visible();
  }
}, {
  selector: ":transparent",
  matches: function(e) {
    return e.transparent();
  }
}, {
  selector: ":grabbed",
  matches: function(e) {
    return e.grabbed();
  }
}, {
  selector: ":free",
  matches: function(e) {
    return !e.grabbed();
  }
}, {
  selector: ":removed",
  matches: function(e) {
    return e.removed();
  }
}, {
  selector: ":inside",
  matches: function(e) {
    return !e.removed();
  }
}, {
  selector: ":grabbable",
  matches: function(e) {
    return e.grabbable();
  }
}, {
  selector: ":ungrabbable",
  matches: function(e) {
    return !e.grabbable();
  }
}, {
  selector: ":animated",
  matches: function(e) {
    return e.animated();
  }
}, {
  selector: ":unanimated",
  matches: function(e) {
    return !e.animated();
  }
}, {
  selector: ":parent",
  matches: function(e) {
    return e.isParent();
  }
}, {
  selector: ":childless",
  matches: function(e) {
    return e.isChildless();
  }
}, {
  selector: ":child",
  matches: function(e) {
    return e.isChild();
  }
}, {
  selector: ":orphan",
  matches: function(e) {
    return e.isOrphan();
  }
}, {
  selector: ":nonorphan",
  matches: function(e) {
    return e.isChild();
  }
}, {
  selector: ":compound",
  matches: function(e) {
    return e.isNode() ? e.isParent() : e.source().isParent() || e.target().isParent();
  }
}, {
  selector: ":loop",
  matches: function(e) {
    return e.isLoop();
  }
}, {
  selector: ":simple",
  matches: function(e) {
    return e.isSimple();
  }
}, {
  selector: ":active",
  matches: function(e) {
    return e.active();
  }
}, {
  selector: ":inactive",
  matches: function(e) {
    return !e.active();
  }
}, {
  selector: ":backgrounding",
  matches: function(e) {
    return e.backgrounding();
  }
}, {
  selector: ":nonbackgrounding",
  matches: function(e) {
    return !e.backgrounding();
  }
}].sort(function(t, e) {
  return Ic(t.selector, e.selector);
}), Ng = (function() {
  for (var t = {}, e, r = 0; r < zo.length; r++)
    e = zo[r], t[e.selector] = e.matches;
  return t;
})(), Bg = function(e, r) {
  return Ng[e](r);
}, Fg = "(" + zo.map(function(t) {
  return t.selector;
}).join("|") + ")", Or = function(e) {
  return e.replace(new RegExp("\\\\(" + Pe.metaChar + ")", "g"), function(r, a) {
    return a;
  });
}, er = function(e, r, a) {
  e[e.length - 1] = a;
}, _o = [{
  name: "group",
  // just used for identifying when debugging
  query: !0,
  regex: "(" + Pe.group + ")",
  populate: function(e, r, a) {
    var n = Qe(a, 1), i = n[0];
    r.checks.push({
      type: ue.GROUP,
      value: i === "*" ? i : i + "s"
    });
  }
}, {
  name: "state",
  query: !0,
  regex: Fg,
  populate: function(e, r, a) {
    var n = Qe(a, 1), i = n[0];
    r.checks.push({
      type: ue.STATE,
      value: i
    });
  }
}, {
  name: "id",
  query: !0,
  regex: "\\#(" + Pe.id + ")",
  populate: function(e, r, a) {
    var n = Qe(a, 1), i = n[0];
    r.checks.push({
      type: ue.ID,
      value: Or(i)
    });
  }
}, {
  name: "className",
  query: !0,
  regex: "\\.(" + Pe.className + ")",
  populate: function(e, r, a) {
    var n = Qe(a, 1), i = n[0];
    r.checks.push({
      type: ue.CLASS,
      value: Or(i)
    });
  }
}, {
  name: "dataExists",
  query: !0,
  regex: "\\[\\s*(" + Pe.variable + ")\\s*\\]",
  populate: function(e, r, a) {
    var n = Qe(a, 1), i = n[0];
    r.checks.push({
      type: ue.DATA_EXIST,
      field: Or(i)
    });
  }
}, {
  name: "dataCompare",
  query: !0,
  regex: "\\[\\s*(" + Pe.variable + ")\\s*(" + Pe.comparatorOp + ")\\s*(" + Pe.value + ")\\s*\\]",
  populate: function(e, r, a) {
    var n = Qe(a, 3), i = n[0], o = n[1], s = n[2], u = new RegExp("^" + Pe.string + "$").exec(s) != null;
    u ? s = s.substring(1, s.length - 1) : s = parseFloat(s), r.checks.push({
      type: ue.DATA_COMPARE,
      field: Or(i),
      operator: o,
      value: s
    });
  }
}, {
  name: "dataBool",
  query: !0,
  regex: "\\[\\s*(" + Pe.boolOp + ")\\s*(" + Pe.variable + ")\\s*\\]",
  populate: function(e, r, a) {
    var n = Qe(a, 2), i = n[0], o = n[1];
    r.checks.push({
      type: ue.DATA_BOOL,
      field: Or(o),
      operator: i
    });
  }
}, {
  name: "metaCompare",
  query: !0,
  regex: "\\[\\[\\s*(" + Pe.meta + ")\\s*(" + Pe.comparatorOp + ")\\s*(" + Pe.number + ")\\s*\\]\\]",
  populate: function(e, r, a) {
    var n = Qe(a, 3), i = n[0], o = n[1], s = n[2];
    r.checks.push({
      type: ue.META_COMPARE,
      field: Or(i),
      operator: o,
      value: parseFloat(s)
    });
  }
}, {
  name: "nextQuery",
  separator: !0,
  regex: Pe.separator,
  populate: function(e, r) {
    var a = e.currentSubject, n = e.edgeCount, i = e.compoundCount, o = e[e.length - 1];
    a != null && (o.subject = a, e.currentSubject = null), o.edgeCount = n, o.compoundCount = i, e.edgeCount = 0, e.compoundCount = 0;
    var s = e[e.length++] = Ge();
    return s;
  }
}, {
  name: "directedEdge",
  separator: !0,
  regex: Pe.directedEdge,
  populate: function(e, r) {
    if (e.currentSubject == null) {
      var a = Ge(), n = r, i = Ge();
      return a.checks.push({
        type: ue.DIRECTED_EDGE,
        source: n,
        target: i
      }), er(e, r, a), e.edgeCount++, i;
    } else {
      var o = Ge(), s = r, u = Ge();
      return o.checks.push({
        type: ue.NODE_SOURCE,
        source: s,
        target: u
      }), er(e, r, o), e.edgeCount++, u;
    }
  }
}, {
  name: "undirectedEdge",
  separator: !0,
  regex: Pe.undirectedEdge,
  populate: function(e, r) {
    if (e.currentSubject == null) {
      var a = Ge(), n = r, i = Ge();
      return a.checks.push({
        type: ue.UNDIRECTED_EDGE,
        nodes: [n, i]
      }), er(e, r, a), e.edgeCount++, i;
    } else {
      var o = Ge(), s = r, u = Ge();
      return o.checks.push({
        type: ue.NODE_NEIGHBOR,
        node: s,
        neighbor: u
      }), er(e, r, o), u;
    }
  }
}, {
  name: "child",
  separator: !0,
  regex: Pe.child,
  populate: function(e, r) {
    if (e.currentSubject == null) {
      var a = Ge(), n = Ge(), i = e[e.length - 1];
      return a.checks.push({
        type: ue.CHILD,
        parent: i,
        child: n
      }), er(e, r, a), e.compoundCount++, n;
    } else if (e.currentSubject === r) {
      var o = Ge(), s = e[e.length - 1], u = Ge(), l = Ge(), f = Ge(), v = Ge();
      return o.checks.push({
        type: ue.COMPOUND_SPLIT,
        left: s,
        right: u,
        subject: l
      }), l.checks = r.checks, r.checks = [{
        type: ue.TRUE
      }], v.checks.push({
        type: ue.TRUE
      }), u.checks.push({
        type: ue.PARENT,
        // type is swapped on right side queries
        parent: v,
        child: f
        // empty for now
      }), er(e, s, o), e.currentSubject = l, e.compoundCount++, f;
    } else {
      var c = Ge(), h = Ge(), d = [{
        type: ue.PARENT,
        parent: c,
        child: h
      }];
      return c.checks = r.checks, r.checks = d, e.compoundCount++, h;
    }
  }
}, {
  name: "descendant",
  separator: !0,
  regex: Pe.descendant,
  populate: function(e, r) {
    if (e.currentSubject == null) {
      var a = Ge(), n = Ge(), i = e[e.length - 1];
      return a.checks.push({
        type: ue.DESCENDANT,
        ancestor: i,
        descendant: n
      }), er(e, r, a), e.compoundCount++, n;
    } else if (e.currentSubject === r) {
      var o = Ge(), s = e[e.length - 1], u = Ge(), l = Ge(), f = Ge(), v = Ge();
      return o.checks.push({
        type: ue.COMPOUND_SPLIT,
        left: s,
        right: u,
        subject: l
      }), l.checks = r.checks, r.checks = [{
        type: ue.TRUE
      }], v.checks.push({
        type: ue.TRUE
      }), u.checks.push({
        type: ue.ANCESTOR,
        // type is swapped on right side queries
        ancestor: v,
        descendant: f
        // empty for now
      }), er(e, s, o), e.currentSubject = l, e.compoundCount++, f;
    } else {
      var c = Ge(), h = Ge(), d = [{
        type: ue.ANCESTOR,
        ancestor: c,
        descendant: h
      }];
      return c.checks = r.checks, r.checks = d, e.compoundCount++, h;
    }
  }
}, {
  name: "subject",
  modifier: !0,
  regex: Pe.subject,
  populate: function(e, r) {
    if (e.currentSubject != null && e.currentSubject !== r)
      return Fe("Redefinition of subject in selector `" + e.toString() + "`"), !1;
    e.currentSubject = r;
    var a = e[e.length - 1], n = a.checks[0], i = n == null ? null : n.type;
    i === ue.DIRECTED_EDGE ? n.type = ue.NODE_TARGET : i === ue.UNDIRECTED_EDGE && (n.type = ue.NODE_NEIGHBOR, n.node = n.nodes[1], n.neighbor = n.nodes[0], n.nodes = null);
  }
}];
_o.forEach(function(t) {
  return t.regexObj = new RegExp("^" + t.regex);
});
var Gg = function(e) {
  for (var r, a, n, i = 0; i < _o.length; i++) {
    var o = _o[i], s = o.name, u = e.match(o.regexObj);
    if (u != null) {
      a = u, r = o, n = s;
      var l = u[0];
      e = e.substring(l.length);
      break;
    }
  }
  return {
    expr: r,
    match: a,
    name: n,
    remaining: e
  };
}, zg = function(e) {
  var r = e.match(/^\s+/);
  if (r) {
    var a = r[0];
    e = e.substring(a.length);
  }
  return e;
}, _g = function(e) {
  var r = this, a = r.inputText = e, n = r[0] = Ge();
  for (r.length = 1, a = zg(a); ; ) {
    var i = Gg(a);
    if (i.expr == null)
      return Fe("The selector `" + e + "`is invalid"), !1;
    var o = i.match.slice(1), s = i.expr.populate(r, n, o);
    if (s === !1)
      return !1;
    if (s != null && (n = s), a = i.remaining, a.match(/^\s*$/))
      break;
  }
  var u = r[r.length - 1];
  r.currentSubject != null && (u.subject = r.currentSubject), u.edgeCount = r.edgeCount, u.compoundCount = r.compoundCount;
  for (var l = 0; l < r.length; l++) {
    var f = r[l];
    if (f.compoundCount > 0 && f.edgeCount > 0)
      return Fe("The selector `" + e + "` is invalid because it uses both a compound selector and an edge selector"), !1;
    if (f.edgeCount > 1)
      return Fe("The selector `" + e + "` is invalid because it uses multiple edge selectors"), !1;
    f.edgeCount === 1 && Fe("The selector `" + e + "` is deprecated.  Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons.  Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.");
  }
  return !0;
}, Vg = function() {
  if (this.toStringCache != null)
    return this.toStringCache;
  for (var e = function(f) {
    return f ?? "";
  }, r = function(f) {
    return de(f) ? '"' + f + '"' : e(f);
  }, a = function(f) {
    return " " + f + " ";
  }, n = function(f, v) {
    var c = f.type, h = f.value;
    switch (c) {
      case ue.GROUP: {
        var d = e(h);
        return d.substring(0, d.length - 1);
      }
      case ue.DATA_COMPARE: {
        var g = f.field, p = f.operator;
        return "[" + g + a(e(p)) + r(h) + "]";
      }
      case ue.DATA_BOOL: {
        var y = f.operator, b = f.field;
        return "[" + e(y) + b + "]";
      }
      case ue.DATA_EXIST: {
        var m = f.field;
        return "[" + m + "]";
      }
      case ue.META_COMPARE: {
        var E = f.operator, C = f.field;
        return "[[" + C + a(e(E)) + r(h) + "]]";
      }
      case ue.STATE:
        return h;
      case ue.ID:
        return "#" + h;
      case ue.CLASS:
        return "." + h;
      case ue.PARENT:
      case ue.CHILD:
        return i(f.parent, v) + a(">") + i(f.child, v);
      case ue.ANCESTOR:
      case ue.DESCENDANT:
        return i(f.ancestor, v) + " " + i(f.descendant, v);
      case ue.COMPOUND_SPLIT: {
        var S = i(f.left, v), w = i(f.subject, v), x = i(f.right, v);
        return S + (S.length > 0 ? " " : "") + w + x;
      }
      case ue.TRUE:
        return "";
    }
  }, i = function(f, v) {
    return f.checks.reduce(function(c, h, d) {
      return c + (v === f && d === 0 ? "$" : "") + n(h, v);
    }, "");
  }, o = "", s = 0; s < this.length; s++) {
    var u = this[s];
    o += i(u, u.subject), this.length > 1 && s < this.length - 1 && (o += ", ");
  }
  return this.toStringCache = o, o;
}, Ug = {
  parse: _g,
  toString: Vg
}, Hf = function(e, r, a) {
  var n, i = de(e), o = ne(e), s = de(a), u, l, f = !1, v = !1, c = !1;
  switch (r.indexOf("!") >= 0 && (r = r.replace("!", ""), v = !0), r.indexOf("@") >= 0 && (r = r.replace("@", ""), f = !0), (i || s || f) && (u = !i && !o ? "" : "" + e, l = "" + a), f && (e = u = u.toLowerCase(), a = l = l.toLowerCase()), r) {
    case "*=":
      n = u.indexOf(l) >= 0;
      break;
    case "$=":
      n = u.indexOf(l, u.length - l.length) >= 0;
      break;
    case "^=":
      n = u.indexOf(l) === 0;
      break;
    case "=":
      n = e === a;
      break;
    case ">":
      c = !0, n = e > a;
      break;
    case ">=":
      c = !0, n = e >= a;
      break;
    case "<":
      c = !0, n = e < a;
      break;
    case "<=":
      c = !0, n = e <= a;
      break;
    default:
      n = !1;
      break;
  }
  return v && (e != null || !c) && (n = !n), n;
}, qg = function(e, r) {
  switch (r) {
    case "?":
      return !!e;
    case "!":
      return !e;
    case "^":
      return e === void 0;
  }
}, Yg = function(e) {
  return e !== void 0;
}, cs = function(e, r) {
  return e.data(r);
}, Hg = function(e, r) {
  return e[r]();
}, $e = [], Ue = function(e, r) {
  return e.checks.every(function(a) {
    return $e[a.type](a, r);
  });
};
$e[ue.GROUP] = function(t, e) {
  var r = t.value;
  return r === "*" || r === e.group();
};
$e[ue.STATE] = function(t, e) {
  var r = t.value;
  return Bg(r, e);
};
$e[ue.ID] = function(t, e) {
  var r = t.value;
  return e.id() === r;
};
$e[ue.CLASS] = function(t, e) {
  var r = t.value;
  return e.hasClass(r);
};
$e[ue.META_COMPARE] = function(t, e) {
  var r = t.field, a = t.operator, n = t.value;
  return Hf(Hg(e, r), a, n);
};
$e[ue.DATA_COMPARE] = function(t, e) {
  var r = t.field, a = t.operator, n = t.value;
  return Hf(cs(e, r), a, n);
};
$e[ue.DATA_BOOL] = function(t, e) {
  var r = t.field, a = t.operator;
  return qg(cs(e, r), a);
};
$e[ue.DATA_EXIST] = function(t, e) {
  var r = t.field;
  return t.operator, Yg(cs(e, r));
};
$e[ue.UNDIRECTED_EDGE] = function(t, e) {
  var r = t.nodes[0], a = t.nodes[1], n = e.source(), i = e.target();
  return Ue(r, n) && Ue(a, i) || Ue(a, n) && Ue(r, i);
};
$e[ue.NODE_NEIGHBOR] = function(t, e) {
  return Ue(t.node, e) && e.neighborhood().some(function(r) {
    return r.isNode() && Ue(t.neighbor, r);
  });
};
$e[ue.DIRECTED_EDGE] = function(t, e) {
  return Ue(t.source, e.source()) && Ue(t.target, e.target());
};
$e[ue.NODE_SOURCE] = function(t, e) {
  return Ue(t.source, e) && e.outgoers().some(function(r) {
    return r.isNode() && Ue(t.target, r);
  });
};
$e[ue.NODE_TARGET] = function(t, e) {
  return Ue(t.target, e) && e.incomers().some(function(r) {
    return r.isNode() && Ue(t.source, r);
  });
};
$e[ue.CHILD] = function(t, e) {
  return Ue(t.child, e) && Ue(t.parent, e.parent());
};
$e[ue.PARENT] = function(t, e) {
  return Ue(t.parent, e) && e.children().some(function(r) {
    return Ue(t.child, r);
  });
};
$e[ue.DESCENDANT] = function(t, e) {
  return Ue(t.descendant, e) && e.ancestors().some(function(r) {
    return Ue(t.ancestor, r);
  });
};
$e[ue.ANCESTOR] = function(t, e) {
  return Ue(t.ancestor, e) && e.descendants().some(function(r) {
    return Ue(t.descendant, r);
  });
};
$e[ue.COMPOUND_SPLIT] = function(t, e) {
  return Ue(t.subject, e) && Ue(t.left, e) && Ue(t.right, e);
};
$e[ue.TRUE] = function() {
  return !0;
};
$e[ue.COLLECTION] = function(t, e) {
  var r = t.value;
  return r.has(e);
};
$e[ue.FILTER] = function(t, e) {
  var r = t.value;
  return r(e);
};
var Xg = function(e) {
  var r = this;
  if (r.length === 1 && r[0].checks.length === 1 && r[0].checks[0].type === ue.ID)
    return e.getElementById(r[0].checks[0].value).collection();
  var a = function(i) {
    for (var o = 0; o < r.length; o++) {
      var s = r[o];
      if (Ue(s, i))
        return !0;
    }
    return !1;
  };
  return r.text() == null && (a = function() {
    return !0;
  }), e.filter(a);
}, Wg = function(e) {
  for (var r = this, a = 0; a < r.length; a++) {
    var n = r[a];
    if (Ue(n, e))
      return !0;
  }
  return !1;
}, $g = {
  matches: Wg,
  filter: Xg
}, fr = function(e) {
  this.inputText = e, this.currentSubject = null, this.compoundCount = 0, this.edgeCount = 0, this.length = 0, e == null || de(e) && e.match(/^\s*$/) || (Ct(e) ? this.addQuery({
    checks: [{
      type: ue.COLLECTION,
      value: e.collection()
    }]
  }) : He(e) ? this.addQuery({
    checks: [{
      type: ue.FILTER,
      value: e
    }]
  }) : de(e) ? this.parse(e) || (this.invalid = !0) : qe("A selector must be created from a string; found "));
}, vr = fr.prototype;
[Ug, $g].forEach(function(t) {
  return ye(vr, t);
});
vr.text = function() {
  return this.inputText;
};
vr.size = function() {
  return this.length;
};
vr.eq = function(t) {
  return this[t];
};
vr.sameText = function(t) {
  return !this.invalid && !t.invalid && this.text() === t.text();
};
vr.addQuery = function(t) {
  this[this.length++] = t;
};
vr.selector = vr.toString;
var ir = {
  allAre: function(e) {
    var r = new fr(e);
    return this.every(function(a) {
      return r.matches(a);
    });
  },
  is: function(e) {
    var r = new fr(e);
    return this.some(function(a) {
      return r.matches(a);
    });
  },
  some: function(e, r) {
    for (var a = 0; a < this.length; a++) {
      var n = r ? e.apply(r, [this[a], a, this]) : e(this[a], a, this);
      if (n)
        return !0;
    }
    return !1;
  },
  every: function(e, r) {
    for (var a = 0; a < this.length; a++) {
      var n = r ? e.apply(r, [this[a], a, this]) : e(this[a], a, this);
      if (!n)
        return !1;
    }
    return !0;
  },
  same: function(e) {
    if (this === e)
      return !0;
    e = this.cy().collection(e);
    var r = this.length, a = e.length;
    return r !== a ? !1 : r === 1 ? this[0] === e[0] : this.every(function(n) {
      return e.hasElementWithId(n.id());
    });
  },
  anySame: function(e) {
    return e = this.cy().collection(e), this.some(function(r) {
      return e.hasElementWithId(r.id());
    });
  },
  allAreNeighbors: function(e) {
    e = this.cy().collection(e);
    var r = this.neighborhood();
    return e.every(function(a) {
      return r.hasElementWithId(a.id());
    });
  },
  contains: function(e) {
    e = this.cy().collection(e);
    var r = this;
    return e.every(function(a) {
      return r.hasElementWithId(a.id());
    });
  }
};
ir.allAreNeighbours = ir.allAreNeighbors;
ir.has = ir.contains;
ir.equal = ir.equals = ir.same;
var Lt = function(e, r) {
  return function(n, i, o, s) {
    var u = n, l = this, f;
    if (u == null ? f = "" : Ct(u) && u.length === 1 && (f = u.id()), l.length === 1 && f) {
      var v = l[0]._private, c = v.traversalCache = v.traversalCache || {}, h = c[r] = c[r] || [], d = Sr(f), g = h[d];
      return g || (h[d] = e.call(l, n, i, o, s));
    } else
      return e.call(l, n, i, o, s);
  };
}, Qr = {
  parent: function(e) {
    var r = [];
    if (this.length === 1) {
      var a = this[0]._private.parent;
      if (a)
        return a;
    }
    for (var n = 0; n < this.length; n++) {
      var i = this[n], o = i._private.parent;
      o && r.push(o);
    }
    return this.spawn(r, !0).filter(e);
  },
  parents: function(e) {
    for (var r = [], a = this.parent(); a.nonempty(); ) {
      for (var n = 0; n < a.length; n++) {
        var i = a[n];
        r.push(i);
      }
      a = a.parent();
    }
    return this.spawn(r, !0).filter(e);
  },
  commonAncestors: function(e) {
    for (var r, a = 0; a < this.length; a++) {
      var n = this[a], i = n.parents();
      r = r || i, r = r.intersect(i);
    }
    return r.filter(e);
  },
  orphans: function(e) {
    return this.stdFilter(function(r) {
      return r.isOrphan();
    }).filter(e);
  },
  nonorphans: function(e) {
    return this.stdFilter(function(r) {
      return r.isChild();
    }).filter(e);
  },
  children: Lt(function(t) {
    for (var e = [], r = 0; r < this.length; r++)
      for (var a = this[r], n = a._private.children, i = 0; i < n.length; i++)
        e.push(n[i]);
    return this.spawn(e, !0).filter(t);
  }, "children"),
  siblings: function(e) {
    return this.parent().children().not(this).filter(e);
  },
  isParent: function() {
    var e = this[0];
    if (e)
      return e.isNode() && e._private.children.length !== 0;
  },
  isChildless: function() {
    var e = this[0];
    if (e)
      return e.isNode() && e._private.children.length === 0;
  },
  isChild: function() {
    var e = this[0];
    if (e)
      return e.isNode() && e._private.parent != null;
  },
  isOrphan: function() {
    var e = this[0];
    if (e)
      return e.isNode() && e._private.parent == null;
  },
  descendants: function(e) {
    var r = [];
    function a(n) {
      for (var i = 0; i < n.length; i++) {
        var o = n[i];
        r.push(o), o.children().nonempty() && a(o.children());
      }
    }
    return a(this.children()), this.spawn(r, !0).filter(e);
  }
};
function hs(t, e, r, a) {
  for (var n = [], i = new ta(), o = t.cy(), s = o.hasCompoundNodes(), u = 0; u < t.length; u++) {
    var l = t[u];
    r ? n.push(l) : s && a(n, i, l);
  }
  for (; n.length > 0; ) {
    var f = n.shift();
    e(f), i.add(f.id()), s && a(n, i, f);
  }
  return t;
}
function Xf(t, e, r) {
  if (r.isParent())
    for (var a = r._private.children, n = 0; n < a.length; n++) {
      var i = a[n];
      e.has(i.id()) || t.push(i);
    }
}
Qr.forEachDown = function(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return hs(this, t, e, Xf);
};
function Wf(t, e, r) {
  if (r.isChild()) {
    var a = r._private.parent;
    e.has(a.id()) || t.push(a);
  }
}
Qr.forEachUp = function(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return hs(this, t, e, Wf);
};
function Kg(t, e, r) {
  Wf(t, e, r), Xf(t, e, r);
}
Qr.forEachUpAndDown = function(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return hs(this, t, e, Kg);
};
Qr.ancestors = Qr.parents;
var La, $f;
La = $f = {
  data: Be.data({
    field: "data",
    bindingEvent: "data",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "data",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    immutableKeys: {
      id: !0,
      source: !0,
      target: !0,
      parent: !0
    },
    updateStyle: !0
  }),
  removeData: Be.removeData({
    field: "data",
    event: "data",
    triggerFnName: "trigger",
    triggerEvent: !0,
    immutableKeys: {
      id: !0,
      source: !0,
      target: !0,
      parent: !0
    },
    updateStyle: !0
  }),
  scratch: Be.data({
    field: "scratch",
    bindingEvent: "scratch",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "scratch",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    updateStyle: !0
  }),
  removeScratch: Be.removeData({
    field: "scratch",
    event: "scratch",
    triggerFnName: "trigger",
    triggerEvent: !0,
    updateStyle: !0
  }),
  rscratch: Be.data({
    field: "rscratch",
    allowBinding: !1,
    allowSetting: !0,
    settingTriggersEvent: !1,
    allowGetting: !0
  }),
  removeRscratch: Be.removeData({
    field: "rscratch",
    triggerEvent: !1
  }),
  id: function() {
    var e = this[0];
    if (e)
      return e._private.data.id;
  }
};
La.attr = La.data;
La.removeAttr = La.removeData;
var Zg = $f, Yn = {};
function wo(t) {
  return function(e) {
    var r = this;
    if (e === void 0 && (e = !0), r.length !== 0)
      if (r.isNode() && !r.removed()) {
        for (var a = 0, n = r[0], i = n._private.edges, o = 0; o < i.length; o++) {
          var s = i[o];
          !e && s.isLoop() || (a += t(n, s));
        }
        return a;
      } else
        return;
  };
}
ye(Yn, {
  degree: wo(function(t, e) {
    return e.source().same(e.target()) ? 2 : 1;
  }),
  indegree: wo(function(t, e) {
    return e.target().same(t) ? 1 : 0;
  }),
  outdegree: wo(function(t, e) {
    return e.source().same(t) ? 1 : 0;
  })
});
function kr(t, e) {
  return function(r) {
    for (var a, n = this.nodes(), i = 0; i < n.length; i++) {
      var o = n[i], s = o[t](r);
      s !== void 0 && (a === void 0 || e(s, a)) && (a = s);
    }
    return a;
  };
}
ye(Yn, {
  minDegree: kr("degree", function(t, e) {
    return t < e;
  }),
  maxDegree: kr("degree", function(t, e) {
    return t > e;
  }),
  minIndegree: kr("indegree", function(t, e) {
    return t < e;
  }),
  maxIndegree: kr("indegree", function(t, e) {
    return t > e;
  }),
  minOutdegree: kr("outdegree", function(t, e) {
    return t < e;
  }),
  maxOutdegree: kr("outdegree", function(t, e) {
    return t > e;
  })
});
ye(Yn, {
  totalDegree: function(e) {
    for (var r = 0, a = this.nodes(), n = 0; n < a.length; n++)
      r += a[n].degree(e);
    return r;
  }
});
var kt, Kf, Zf = function(e, r, a) {
  for (var n = 0; n < e.length; n++) {
    var i = e[n];
    if (!i.locked()) {
      var o = i._private.position, s = {
        x: r.x != null ? r.x - o.x : 0,
        y: r.y != null ? r.y - o.y : 0
      };
      i.isParent() && !(s.x === 0 && s.y === 0) && i.children().shift(s, a), i.dirtyBoundingBoxCache();
    }
  }
}, ll = {
  field: "position",
  bindingEvent: "position",
  allowBinding: !0,
  allowSetting: !0,
  settingEvent: "position",
  settingTriggersEvent: !0,
  triggerFnName: "emitAndNotify",
  allowGetting: !0,
  validKeys: ["x", "y"],
  beforeGet: function(e) {
    e.updateCompoundBounds();
  },
  beforeSet: function(e, r) {
    Zf(e, r, !1);
  },
  onSet: function(e) {
    e.dirtyCompoundBoundsCache();
  },
  canSet: function(e) {
    return !e.locked();
  }
};
kt = Kf = {
  position: Be.data(ll),
  // position but no notification to renderer
  silentPosition: Be.data(ye({}, ll, {
    allowBinding: !1,
    allowSetting: !0,
    settingTriggersEvent: !1,
    allowGetting: !1,
    beforeSet: function(e, r) {
      Zf(e, r, !0);
    },
    onSet: function(e) {
      e.dirtyCompoundBoundsCache();
    }
  })),
  positions: function(e, r) {
    if (Ie(e))
      r ? this.silentPosition(e) : this.position(e);
    else if (He(e)) {
      var a = e, n = this.cy();
      n.startBatch();
      for (var i = 0; i < this.length; i++) {
        var o = this[i], s = void 0;
        (s = a(o, i)) && (r ? o.silentPosition(s) : o.position(s));
      }
      n.endBatch();
    }
    return this;
  },
  silentPositions: function(e) {
    return this.positions(e, !0);
  },
  shift: function(e, r, a) {
    var n;
    if (Ie(e) ? (n = {
      x: ne(e.x) ? e.x : 0,
      y: ne(e.y) ? e.y : 0
    }, a = r) : de(e) && ne(r) && (n = {
      x: 0,
      y: 0
    }, n[e] = r), n != null) {
      var i = this.cy();
      i.startBatch();
      for (var o = 0; o < this.length; o++) {
        var s = this[o];
        if (!(i.hasCompoundNodes() && s.isChild() && s.ancestors().anySame(this))) {
          var u = s.position(), l = {
            x: u.x + n.x,
            y: u.y + n.y
          };
          a ? s.silentPosition(l) : s.position(l);
        }
      }
      i.endBatch();
    }
    return this;
  },
  silentShift: function(e, r) {
    return Ie(e) ? this.shift(e, !0) : de(e) && ne(r) && this.shift(e, r, !0), this;
  },
  // get/set the rendered (i.e. on screen) positon of the element
  renderedPosition: function(e, r) {
    var a = this[0], n = this.cy(), i = n.zoom(), o = n.pan(), s = Ie(e) ? e : void 0, u = s !== void 0 || r !== void 0 && de(e);
    if (a && a.isNode())
      if (u)
        for (var l = 0; l < this.length; l++) {
          var f = this[l];
          r !== void 0 ? f.position(e, (r - o[e]) / i) : s !== void 0 && f.position(Cf(s, i, o));
        }
      else {
        var v = a.position();
        return s = Gn(v, i, o), e === void 0 ? s : s[e];
      }
    else if (!u)
      return;
    return this;
  },
  // get/set the position relative to the parent
  relativePosition: function(e, r) {
    var a = this[0], n = this.cy(), i = Ie(e) ? e : void 0, o = i !== void 0 || r !== void 0 && de(e), s = n.hasCompoundNodes();
    if (a && a.isNode())
      if (o)
        for (var u = 0; u < this.length; u++) {
          var l = this[u], f = s ? l.parent() : null, v = f && f.length > 0, c = v;
          v && (f = f[0]);
          var h = c ? f.position() : {
            x: 0,
            y: 0
          };
          r !== void 0 ? l.position(e, r + h[e]) : i !== void 0 && l.position({
            x: i.x + h.x,
            y: i.y + h.y
          });
        }
      else {
        var d = a.position(), g = s ? a.parent() : null, p = g && g.length > 0, y = p;
        p && (g = g[0]);
        var b = y ? g.position() : {
          x: 0,
          y: 0
        };
        return i = {
          x: d.x - b.x,
          y: d.y - b.y
        }, e === void 0 ? i : i[e];
      }
    else if (!o)
      return;
    return this;
  }
};
kt.modelPosition = kt.point = kt.position;
kt.modelPositions = kt.points = kt.positions;
kt.renderedPoint = kt.renderedPosition;
kt.relativePoint = kt.relativePosition;
var Qg = Kf, Jr = function(e) {
  switch (e) {
    case "left":
    case "right-inside":
      return "left";
    case "right":
    case "left-inside":
      return "right";
    default:
      return "center";
  }
}, jr = function(e) {
  switch (e) {
    case "top":
    case "bottom-inside":
      return "top";
    case "bottom":
    case "top-inside":
      return "bottom";
    default:
      return "center";
  }
}, Jg = function(e) {
  switch (e) {
    case "left":
      return "right";
    case "right":
      return "left";
    case "left-inside":
      return "left";
    case "right-inside":
      return "right";
    default:
      return "center";
  }
}, $r, gr;
$r = gr = {};
gr.renderedBoundingBox = function(t) {
  var e = this.boundingBox(t), r = this.cy(), a = r.zoom(), n = r.pan(), i = e.x1 * a + n.x, o = e.x2 * a + n.x, s = e.y1 * a + n.y, u = e.y2 * a + n.y;
  return {
    x1: i,
    x2: o,
    y1: s,
    y2: u,
    w: o - i,
    h: u - s
  };
};
gr.dirtyCompoundBoundsCache = function() {
  var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = this.cy();
  return !e.styleEnabled() || !e.hasCompoundNodes() ? this : (this.forEachUp(function(r) {
    if (r.isParent()) {
      var a = r._private;
      a.compoundBoundsClean = !1, a.bbCache = null, t || r.emitAndNotify("bounds");
    }
  }), this);
};
gr.updateCompoundBounds = function() {
  var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = this.cy();
  if (!e.styleEnabled() || !e.hasCompoundNodes())
    return this;
  if (!t && e.batching())
    return this;
  function r(o) {
    if (!o.isParent())
      return;
    var s = o._private, u = o.children(), l = o.pstyle("compound-sizing-wrt-labels").value === "include", f = {
      width: {
        val: o.pstyle("min-width").pfValue,
        left: o.pstyle("min-width-bias-left"),
        right: o.pstyle("min-width-bias-right")
      },
      height: {
        val: o.pstyle("min-height").pfValue,
        top: o.pstyle("min-height-bias-top"),
        bottom: o.pstyle("min-height-bias-bottom")
      }
    }, v = u.boundingBox({
      includeLabels: l,
      includeOverlays: !1,
      // updating the compound bounds happens outside of the regular
      // cache cycle (i.e. before fired events)
      useCache: !1
    }), c = s.position;
    (v.w === 0 || v.h === 0) && (v = {
      w: o.pstyle("width").pfValue,
      h: o.pstyle("height").pfValue
    }, v.x1 = c.x - v.w / 2, v.x2 = c.x + v.w / 2, v.y1 = c.y - v.h / 2, v.y2 = c.y + v.h / 2);
    function h(T, D, A) {
      var L = 0, R = 0, P = D + A;
      return T > 0 && P > 0 && (L = D / P * T, R = A / P * T), {
        biasDiff: L,
        biasComplementDiff: R
      };
    }
    function d(T, D, A, L) {
      if (A.units === "%")
        switch (L) {
          case "width":
            return T > 0 ? A.pfValue * T : 0;
          case "height":
            return D > 0 ? A.pfValue * D : 0;
          case "average":
            return T > 0 && D > 0 ? A.pfValue * (T + D) / 2 : 0;
          case "min":
            return T > 0 && D > 0 ? T > D ? A.pfValue * D : A.pfValue * T : 0;
          case "max":
            return T > 0 && D > 0 ? T > D ? A.pfValue * T : A.pfValue * D : 0;
          default:
            return 0;
        }
      else return A.units === "px" ? A.pfValue : 0;
    }
    var g = f.width.left.value;
    f.width.left.units === "px" && f.width.val > 0 && (g = g * 100 / f.width.val);
    var p = f.width.right.value;
    f.width.right.units === "px" && f.width.val > 0 && (p = p * 100 / f.width.val);
    var y = f.height.top.value;
    f.height.top.units === "px" && f.height.val > 0 && (y = y * 100 / f.height.val);
    var b = f.height.bottom.value;
    f.height.bottom.units === "px" && f.height.val > 0 && (b = b * 100 / f.height.val);
    var m = h(f.width.val - v.w, g, p), E = m.biasDiff, C = m.biasComplementDiff, S = h(f.height.val - v.h, y, b), w = S.biasDiff, x = S.biasComplementDiff;
    s.autoPadding = d(v.w, v.h, o.pstyle("padding"), o.pstyle("padding-relative-to").value), s.autoWidth = Math.max(v.w, f.width.val), c.x = (-E + v.x1 + v.x2 + C) / 2, s.autoHeight = Math.max(v.h, f.height.val), c.y = (-w + v.y1 + v.y2 + x) / 2;
  }
  for (var a = 0; a < this.length; a++) {
    var n = this[a], i = n._private;
    (!i.compoundBoundsClean || t) && (r(n), e.batching() || (i.compoundBoundsClean = !0));
  }
  return this;
};
var At = function(e) {
  return e === 1 / 0 || e === -1 / 0 ? 0 : e;
}, Ot = function(e, r, a, n, i) {
  n - r === 0 || i - a === 0 || r == null || a == null || n == null || i == null || (e.x1 = r < e.x1 ? r : e.x1, e.x2 = n > e.x2 ? n : e.x2, e.y1 = a < e.y1 ? a : e.y1, e.y2 = i > e.y2 ? i : e.y2, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1);
}, tr = function(e, r) {
  return r == null ? e : Ot(e, r.x1, r.y1, r.x2, r.y2);
}, va = function(e, r, a) {
  return yt(e, r, a);
}, ja = function(e, r, a) {
  if (!r.cy().headless()) {
    var n = r._private, i = n.rstyle, o = i.arrowWidth / 2, s = r.pstyle(a + "-arrow-shape").value, u, l;
    if (s !== "none") {
      a === "source" ? (u = i.srcX, l = i.srcY) : a === "target" ? (u = i.tgtX, l = i.tgtY) : (u = i.midX, l = i.midY);
      var f = n.arrowBounds = n.arrowBounds || {}, v = f[a] = f[a] || {};
      v.x1 = u - o, v.y1 = l - o, v.x2 = u + o, v.y2 = l + o, v.w = v.x2 - v.x1, v.h = v.y2 - v.y1, un(v, 1), Ot(e, v.x1, v.y1, v.x2, v.y2);
    }
  }
}, Eo = function(e, r, a) {
  if (!r.cy().headless()) {
    var n;
    a ? n = a + "-" : n = "";
    var i = r._private, o = i.rstyle, s = r.pstyle(n + "label").strValue;
    if (s) {
      var u = r.pstyle("text-halign"), l = r.pstyle("text-valign"), f = va(o, "labelWidth", a), v = va(o, "labelHeight", a), c = va(o, "labelX", a), h = va(o, "labelY", a), d = r.pstyle(n + "text-margin-x").pfValue, g = r.pstyle(n + "text-margin-y").pfValue, p = r.isEdge(), y = r.pstyle(n + "text-rotation"), b = r.pstyle("text-outline-width").pfValue, m = r.pstyle("text-border-width").pfValue, E = m / 2, C = r.pstyle("text-background-padding").pfValue, S = 2, w = v, x = f, T = x / 2, D = w / 2, A, L, R, P;
      if (p)
        A = c - T, L = c + T, R = h - D, P = h + D;
      else {
        switch (Jr(u.value)) {
          case "left":
            A = c - x, L = c;
            break;
          case "center":
            A = c - T, L = c + T;
            break;
          case "right":
            A = c, L = c + x;
            break;
        }
        switch (jr(l.value)) {
          case "top":
            R = h - w, P = h;
            break;
          case "center":
            R = h - D, P = h + D;
            break;
          case "bottom":
            R = h, P = h + w;
            break;
        }
      }
      var I = d - Math.max(b, E) - C - S, k = d + Math.max(b, E) + C + S, O = g - Math.max(b, E) - C - S, N = g + Math.max(b, E) + C + S;
      A += I, L += k, R += O, P += N;
      var F = a || "main", G = i.labelBounds, B = G[F] = G[F] || {};
      B.x1 = A, B.y1 = R, B.x2 = L, B.y2 = P, B.w = L - A, B.h = P - R, B.leftPad = I, B.rightPad = k, B.topPad = O, B.botPad = N;
      var z = p && y.strValue === "autorotate", Y = y.pfValue != null && y.pfValue !== 0;
      if (z || Y) {
        var $ = z ? va(i.rstyle, "labelAngle", a) : y.pfValue, X = Math.cos($), j = Math.sin($), ee = (A + L) / 2, ae = (R + P) / 2;
        if (!p) {
          switch (Jr(u.value)) {
            case "left":
              ee = L;
              break;
            case "right":
              ee = A;
              break;
          }
          switch (jr(l.value)) {
            case "top":
              ae = P;
              break;
            case "bottom":
              ae = R;
              break;
          }
        }
        var K = function(we, me) {
          return we = we - ee, me = me - ae, {
            x: we * X - me * j + ee,
            y: we * j + me * X + ae
          };
        }, V = K(A, R), q = K(A, P), H = K(L, R), Z = K(L, P);
        A = Math.min(V.x, q.x, H.x, Z.x), L = Math.max(V.x, q.x, H.x, Z.x), R = Math.min(V.y, q.y, H.y, Z.y), P = Math.max(V.y, q.y, H.y, Z.y);
      }
      var re = F + "Rot", le = G[re] = G[re] || {};
      le.x1 = A, le.y1 = R, le.x2 = L, le.y2 = P, le.w = L - A, le.h = P - R, Ot(e, A, R, L, P), Ot(i.labelBounds.all, A, R, L, P);
    }
    return e;
  }
}, fl = function(e, r) {
  if (!r.cy().headless()) {
    var a = r.pstyle("outline-opacity").value, n = r.pstyle("outline-width").value, i = r.pstyle("outline-offset").value, o = n + i;
    Qf(e, r, a, o, "outside", o / 2);
  }
}, Qf = function(e, r, a, n, i, o) {
  if (!(a === 0 || n <= 0 || i === "inside")) {
    var s = r.cy(), u = s.renderer(), l = u.nodeShapes[u.getNodeShape(r)];
    if (l) {
      var f = r.position(), v = f.x, c = f.y, h = r.width(), d = r.height();
      if (l.hasMiterBounds) {
        i === "center" && (n /= 2);
        var g = l.miterBounds(v, c, h, d, n);
        tr(e, g);
      } else o != null && o > 0 && ln(e, [o, o, o, o]);
    }
  }
}, jg = function(e, r) {
  if (!r.cy().headless()) {
    var a = r.pstyle("border-opacity").value, n = r.pstyle("border-width").pfValue, i = r.pstyle("border-position").value;
    Qf(e, r, a, n, i);
  }
}, ep = function(e, r) {
  var a = e._private.cy, n = a.styleEnabled(), i = a.headless(), o = mt(), s = e._private, u = e.isNode(), l = e.isEdge(), f, v, c, h, d, g, p = s.rstyle, y = u && n ? e.pstyle("bounds-expansion").pfValue : [0], b = function(Ae) {
    return Ae.pstyle("display").value !== "none";
  }, m = !n || b(e) && (!l || b(e.source()) && b(e.target()));
  if (m) {
    var E = 0, C = 0;
    n && r.includeOverlays && (E = e.pstyle("overlay-opacity").value, E !== 0 && (C = e.pstyle("overlay-padding").value));
    var S = 0, w = 0;
    n && r.includeUnderlays && (S = e.pstyle("underlay-opacity").value, S !== 0 && (w = e.pstyle("underlay-padding").value));
    var x = Math.max(C, w), T = 0, D = 0;
    if (n && (T = e.pstyle("width").pfValue, D = T / 2), u && r.includeNodes) {
      var A = e.position();
      d = A.x, g = A.y;
      var L = e.outerWidth(), R = L / 2, P = e.outerHeight(), I = P / 2;
      f = d - R, v = d + R, c = g - I, h = g + I, Ot(o, f, c, v, h), n && fl(o, e), n && r.includeOutlines && !i && fl(o, e), n && jg(o, e);
    } else if (l && r.includeEdges)
      if (n && !i) {
        var k = e.pstyle("curve-style").strValue;
        if (f = Math.min(p.srcX, p.midX, p.tgtX), v = Math.max(p.srcX, p.midX, p.tgtX), c = Math.min(p.srcY, p.midY, p.tgtY), h = Math.max(p.srcY, p.midY, p.tgtY), f -= D, v += D, c -= D, h += D, Ot(o, f, c, v, h), k === "haystack") {
          var O = p.haystackPts;
          if (O && O.length === 2) {
            if (f = O[0].x, c = O[0].y, v = O[1].x, h = O[1].y, f > v) {
              var N = f;
              f = v, v = N;
            }
            if (c > h) {
              var F = c;
              c = h, h = F;
            }
            Ot(o, f - D, c - D, v + D, h + D);
          }
        } else if (k === "bezier" || k === "unbundled-bezier" || rr(k, "segments") || rr(k, "taxi")) {
          var G;
          switch (k) {
            case "bezier":
            case "unbundled-bezier":
              G = p.bezierPts;
              break;
            case "segments":
            case "taxi":
            case "round-segments":
            case "round-taxi":
              G = p.linePts;
              break;
          }
          if (G != null)
            for (var B = 0; B < G.length; B++) {
              var z = G[B];
              f = z.x - D, v = z.x + D, c = z.y - D, h = z.y + D, Ot(o, f, c, v, h);
            }
        }
      } else {
        var Y = e.source(), $ = Y.position(), X = e.target(), j = X.position();
        if (f = $.x, v = j.x, c = $.y, h = j.y, f > v) {
          var ee = f;
          f = v, v = ee;
        }
        if (c > h) {
          var ae = c;
          c = h, h = ae;
        }
        f -= D, v += D, c -= D, h += D, Ot(o, f, c, v, h);
      }
    if (n && r.includeEdges && l && (ja(o, e, "mid-source"), ja(o, e, "mid-target"), ja(o, e, "source"), ja(o, e, "target")), n) {
      var K = e.pstyle("ghost").value === "yes";
      if (K) {
        var V = e.pstyle("ghost-offset-x").pfValue, q = e.pstyle("ghost-offset-y").pfValue;
        Ot(o, o.x1 + V, o.y1 + q, o.x2 + V, o.y2 + q);
      }
    }
    var H = s.bodyBounds = s.bodyBounds || {};
    Ks(H, o), ln(H, y), un(H, 1), n && (f = o.x1, v = o.x2, c = o.y1, h = o.y2, Ot(o, f - x, c - x, v + x, h + x));
    var Z = s.overlayBounds = s.overlayBounds || {};
    Ks(Z, o), ln(Z, y), un(Z, 1);
    var re = s.labelBounds = s.labelBounds || {};
    re.all != null ? kh(re.all) : re.all = mt(), n && r.includeLabels && (r.includeMainLabels && Eo(o, e, null), l && (r.includeSourceLabels && Eo(o, e, "source"), r.includeTargetLabels && Eo(o, e, "target")));
  }
  return o.x1 = At(o.x1), o.y1 = At(o.y1), o.x2 = At(o.x2), o.y2 = At(o.y2), o.w = At(o.x2 - o.x1), o.h = At(o.y2 - o.y1), o.w > 0 && o.h > 0 && m && (ln(o, y), un(o, 1)), o;
}, Jf = function(e) {
  var r = 0, a = function(o) {
    return (o ? 1 : 0) << r++;
  }, n = 0;
  return n += a(e.incudeNodes), n += a(e.includeEdges), n += a(e.includeLabels), n += a(e.includeMainLabels), n += a(e.includeSourceLabels), n += a(e.includeTargetLabels), n += a(e.includeOverlays), n += a(e.includeOutlines), n;
}, jf = function(e) {
  var r = function(s) {
    return Math.round(s);
  };
  if (e.isEdge()) {
    var a = e.source().position(), n = e.target().position();
    return qs([r(a.x), r(a.y), r(n.x), r(n.y)]);
  } else {
    var i = e.position();
    return qs([r(i.x), r(i.y)]);
  }
}, vl = function(e, r) {
  var a = e._private, n, i = e.isEdge(), o = r == null ? cl : Jf(r), s = o === cl;
  if (a.bbCache == null ? (n = ep(e, Ra), a.bbCache = n, a.bbCachePosKey = jf(e)) : n = a.bbCache, !s) {
    var u = e.isNode();
    n = mt(), (r.includeNodes && u || r.includeEdges && !u) && (r.includeOverlays ? tr(n, a.overlayBounds) : tr(n, a.bodyBounds)), r.includeLabels && (r.includeMainLabels && (!i || r.includeSourceLabels && r.includeTargetLabels) ? tr(n, a.labelBounds.all) : (r.includeMainLabels && tr(n, a.labelBounds.mainRot), r.includeSourceLabels && tr(n, a.labelBounds.sourceRot), r.includeTargetLabels && tr(n, a.labelBounds.targetRot))), n.w = n.x2 - n.x1, n.h = n.y2 - n.y1;
  }
  return n;
}, Ra = {
  includeNodes: !0,
  includeEdges: !0,
  includeLabels: !0,
  includeMainLabels: !0,
  includeSourceLabels: !0,
  includeTargetLabels: !0,
  includeOverlays: !0,
  includeUnderlays: !0,
  includeOutlines: !0,
  useCache: !0
}, cl = Jf(Ra), hl = ft(Ra);
gr.boundingBox = function(t) {
  var e, r = t === void 0 || t.useCache === void 0 || t.useCache === !0, a = Kr(function(f) {
    var v = f._private;
    return v.bbCache == null || v.styleDirty || v.bbCachePosKey !== jf(f);
  }, function(f) {
    return f.id();
  });
  if (r && this.length === 1 && !a(this[0]))
    t === void 0 ? t = Ra : t = hl(t), e = vl(this[0], t);
  else {
    e = mt(), t = t || Ra;
    var n = hl(t), i = this, o = i.cy(), s = o.styleEnabled();
    this.edges().forEach(a), this.nodes().forEach(a), s && this.recalculateRenderedStyle(r), this.updateCompoundBounds(!r);
    for (var u = 0; u < i.length; u++) {
      var l = i[u];
      a(l) && l.dirtyBoundingBoxCache(), tr(e, vl(l, n));
    }
  }
  return e.x1 = At(e.x1), e.y1 = At(e.y1), e.x2 = At(e.x2), e.y2 = At(e.y2), e.w = At(e.x2 - e.x1), e.h = At(e.y2 - e.y1), e;
};
gr.dirtyBoundingBoxCache = function() {
  for (var t = 0; t < this.length; t++) {
    var e = this[t]._private;
    e.bbCache = null, e.bbCachePosKey = null, e.bodyBounds = null, e.overlayBounds = null, e.labelBounds.all = null, e.labelBounds.source = null, e.labelBounds.target = null, e.labelBounds.main = null, e.labelBounds.sourceRot = null, e.labelBounds.targetRot = null, e.labelBounds.mainRot = null, e.arrowBounds.source = null, e.arrowBounds.target = null, e.arrowBounds["mid-source"] = null, e.arrowBounds["mid-target"] = null;
  }
  return this.emitAndNotify("bounds"), this;
};
gr.boundingBoxAt = function(t) {
  var e = this.nodes(), r = this.cy(), a = r.hasCompoundNodes(), n = r.collection();
  if (a && (n = e.filter(function(l) {
    return l.isParent();
  }), e = e.not(n)), Ie(t)) {
    var i = t;
    t = function() {
      return i;
    };
  }
  var o = function(f, v) {
    return f._private.bbAtOldPos = t(f, v);
  }, s = function(f) {
    return f._private.bbAtOldPos;
  };
  r.startBatch(), e.forEach(o).silentPositions(t), a && (n.dirtyCompoundBoundsCache(), n.dirtyBoundingBoxCache(), n.updateCompoundBounds(!0));
  var u = Oh(this.boundingBox({
    useCache: !1
  }));
  return e.silentPositions(s), a && (n.dirtyCompoundBoundsCache(), n.dirtyBoundingBoxCache(), n.updateCompoundBounds(!0)), r.endBatch(), u;
};
$r.boundingbox = $r.bb = $r.boundingBox;
$r.renderedBoundingbox = $r.renderedBoundingBox;
var tp = gr, ma, _a;
ma = _a = {};
var ev = function(e) {
  e.uppercaseName = Ls(e.name), e.autoName = "auto" + e.uppercaseName, e.labelName = "label" + e.uppercaseName, e.outerName = "outer" + e.uppercaseName, e.uppercaseOuterName = Ls(e.outerName), ma[e.name] = function() {
    var a = this[0], n = a._private, i = n.cy, o = i._private.styleEnabled;
    if (a)
      if (o) {
        if (a.isParent())
          return a.updateCompoundBounds(), n[e.autoName] || 0;
        var s = a.pstyle(e.name);
        switch (s.strValue) {
          case "label":
            return a.recalculateRenderedStyle(), n.rstyle[e.labelName] || 0;
          default:
            return s.pfValue;
        }
      } else
        return 1;
  }, ma["outer" + e.uppercaseName] = function() {
    var a = this[0], n = a._private, i = n.cy, o = i._private.styleEnabled;
    if (a)
      if (o) {
        var s = a[e.name](), u = a.pstyle("border-position").value, l;
        u === "center" ? l = a.pstyle("border-width").pfValue : u === "outside" ? l = 2 * a.pstyle("border-width").pfValue : l = 0;
        var f = 2 * a.padding();
        return s + l + f;
      } else
        return 1;
  }, ma["rendered" + e.uppercaseName] = function() {
    var a = this[0];
    if (a) {
      var n = a[e.name]();
      return n * this.cy().zoom();
    }
  }, ma["rendered" + e.uppercaseOuterName] = function() {
    var a = this[0];
    if (a) {
      var n = a[e.outerName]();
      return n * this.cy().zoom();
    }
  };
};
ev({
  name: "width"
});
ev({
  name: "height"
});
_a.padding = function() {
  var t = this[0], e = t._private;
  return t.isParent() ? (t.updateCompoundBounds(), e.autoPadding !== void 0 ? e.autoPadding : t.pstyle("padding").pfValue) : t.pstyle("padding").pfValue;
};
_a.paddedHeight = function() {
  var t = this[0];
  return t.height() + 2 * t.padding();
};
_a.paddedWidth = function() {
  var t = this[0];
  return t.width() + 2 * t.padding();
};
var rp = _a, ap = function(e, r) {
  if (e.isEdge() && e.takesUpSpace())
    return r(e);
}, np = function(e, r) {
  if (e.isEdge() && e.takesUpSpace()) {
    var a = e.cy();
    return Gn(r(e), a.zoom(), a.pan());
  }
}, ip = function(e, r) {
  if (e.isEdge() && e.takesUpSpace()) {
    var a = e.cy(), n = a.pan(), i = a.zoom();
    return r(e).map(function(o) {
      return Gn(o, i, n);
    });
  }
}, op = function(e) {
  return e.renderer().getControlPoints(e);
}, sp = function(e) {
  return e.renderer().getSegmentPoints(e);
}, up = function(e) {
  return e.renderer().getSourceEndpoint(e);
}, lp = function(e) {
  return e.renderer().getTargetEndpoint(e);
}, fp = function(e) {
  return e.renderer().getEdgeMidpoint(e);
}, dl = {
  controlPoints: {
    get: op,
    mult: !0
  },
  segmentPoints: {
    get: sp,
    mult: !0
  },
  sourceEndpoint: {
    get: up
  },
  targetEndpoint: {
    get: lp
  },
  midpoint: {
    get: fp
  }
}, vp = function(e) {
  return "rendered" + e[0].toUpperCase() + e.substr(1);
}, cp = Object.keys(dl).reduce(function(t, e) {
  var r = dl[e], a = vp(e);
  return t[e] = function() {
    return ap(this, r.get);
  }, r.mult ? t[a] = function() {
    return ip(this, r.get);
  } : t[a] = function() {
    return np(this, r.get);
  }, t;
}, {}), hp = ye({}, Qg, tp, rp, cp);
/*!
Event object based on jQuery events, MIT license

https://jquery.org/license/
https://tldrlegal.com/license/mit-license
https://github.com/jquery/jquery/blob/master/src/event.js
*/
var tv = function(e, r) {
  this.recycle(e, r);
};
function ca() {
  return !1;
}
function en() {
  return !0;
}
tv.prototype = {
  instanceString: function() {
    return "event";
  },
  recycle: function(e, r) {
    if (this.isImmediatePropagationStopped = this.isPropagationStopped = this.isDefaultPrevented = ca, e != null && e.preventDefault ? (this.type = e.type, this.isDefaultPrevented = e.defaultPrevented ? en : ca) : e != null && e.type ? r = e : this.type = e, r != null && (this.originalEvent = r.originalEvent, this.type = r.type != null ? r.type : this.type, this.cy = r.cy, this.target = r.target, this.position = r.position, this.renderedPosition = r.renderedPosition, this.namespace = r.namespace, this.layout = r.layout), this.cy != null && this.position != null && this.renderedPosition == null) {
      var a = this.position, n = this.cy.zoom(), i = this.cy.pan();
      this.renderedPosition = {
        x: a.x * n + i.x,
        y: a.y * n + i.y
      };
    }
    this.timeStamp = e && e.timeStamp || Date.now();
  },
  preventDefault: function() {
    this.isDefaultPrevented = en;
    var e = this.originalEvent;
    e && e.preventDefault && e.preventDefault();
  },
  stopPropagation: function() {
    this.isPropagationStopped = en;
    var e = this.originalEvent;
    e && e.stopPropagation && e.stopPropagation();
  },
  stopImmediatePropagation: function() {
    this.isImmediatePropagationStopped = en, this.stopPropagation();
  },
  isDefaultPrevented: ca,
  isPropagationStopped: ca,
  isImmediatePropagationStopped: ca
};
var rv = /^([^.]+)(\.(?:[^.]+))?$/, dp = ".*", av = {
  qualifierCompare: function(e, r) {
    return e === r;
  },
  eventMatches: function() {
    return !0;
  },
  addEventFields: function() {
  },
  callbackContext: function(e) {
    return e;
  },
  beforeEmit: function() {
  },
  afterEmit: function() {
  },
  bubble: function() {
    return !1;
  },
  parent: function() {
    return null;
  },
  context: null
}, gl = Object.keys(av), gp = {};
function Hn() {
  for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : gp, e = arguments.length > 1 ? arguments[1] : void 0, r = 0; r < gl.length; r++) {
    var a = gl[r];
    this[a] = t[a] || av[a];
  }
  this.context = e || this.context, this.listeners = [], this.emitting = 0;
}
var cr = Hn.prototype, nv = function(e, r, a, n, i, o, s) {
  He(n) && (i = n, n = null), s && (o == null ? o = s : o = ye({}, o, s));
  for (var u = ze(a) ? a : a.split(/\s+/), l = 0; l < u.length; l++) {
    var f = u[l];
    if (!sr(f)) {
      var v = f.match(rv);
      if (v) {
        var c = v[1], h = v[2] ? v[2] : null, d = r(e, f, c, h, n, i, o);
        if (d === !1)
          break;
      }
    }
  }
}, pl = function(e, r) {
  return e.addEventFields(e.context, r), new tv(r.type, r);
}, pp = function(e, r, a) {
  if (Ec(a)) {
    r(e, a);
    return;
  } else if (Ie(a)) {
    r(e, pl(e, a));
    return;
  }
  for (var n = ze(a) ? a : a.split(/\s+/), i = 0; i < n.length; i++) {
    var o = n[i];
    if (!sr(o)) {
      var s = o.match(rv);
      if (s) {
        var u = s[1], l = s[2] ? s[2] : null, f = pl(e, {
          type: u,
          namespace: l,
          target: e.context
        });
        r(e, f);
      }
    }
  }
};
cr.on = cr.addListener = function(t, e, r, a, n) {
  return nv(this, function(i, o, s, u, l, f, v) {
    He(f) && i.listeners.push({
      event: o,
      // full event string
      callback: f,
      // callback to run
      type: s,
      // the event type (e.g. 'click')
      namespace: u,
      // the event namespace (e.g. ".foo")
      qualifier: l,
      // a restriction on whether to match this emitter
      conf: v
      // additional configuration
    });
  }, t, e, r, a, n), this;
};
cr.one = function(t, e, r, a) {
  return this.on(t, e, r, a, {
    one: !0
  });
};
cr.removeListener = cr.off = function(t, e, r, a) {
  var n = this;
  this.emitting !== 0 && (this.listeners = ah(this.listeners));
  for (var i = this.listeners, o = function(l) {
    var f = i[l];
    nv(n, function(v, c, h, d, g, p) {
      if ((f.type === h || t === "*") && (!d && f.namespace !== ".*" || f.namespace === d) && (!g || v.qualifierCompare(f.qualifier, g)) && (!p || f.callback === p))
        return i.splice(l, 1), !1;
    }, t, e, r, a);
  }, s = i.length - 1; s >= 0; s--)
    o(s);
  return this;
};
cr.removeAllListeners = function() {
  return this.removeListener("*");
};
cr.emit = cr.trigger = function(t, e, r) {
  var a = this.listeners, n = a.length;
  return this.emitting++, ze(e) || (e = [e]), pp(this, function(i, o) {
    r != null && (a = [{
      event: o.event,
      type: o.type,
      namespace: o.namespace,
      callback: r
    }], n = a.length);
    for (var s = function() {
      var f = a[u];
      if (f.type === o.type && (!f.namespace || f.namespace === o.namespace || f.namespace === dp) && i.eventMatches(i.context, f, o)) {
        var v = [o];
        e != null && ih(v, e), i.beforeEmit(i.context, f, o), f.conf && f.conf.one && (i.listeners = i.listeners.filter(function(d) {
          return d !== f;
        }));
        var c = i.callbackContext(i.context, f, o), h = f.callback.apply(c, v);
        i.afterEmit(i.context, f, o), h === !1 && (o.stopPropagation(), o.preventDefault());
      }
    }, u = 0; u < n; u++)
      s();
    i.bubble(i.context) && !o.isPropagationStopped() && i.parent(i.context).emit(o, e);
  }, t), this.emitting--, this;
};
var yp = {
  qualifierCompare: function(e, r) {
    return e == null || r == null ? e == null && r == null : e.sameText(r);
  },
  eventMatches: function(e, r, a) {
    var n = r.qualifier;
    return n != null ? e !== a.target && ka(a.target) && n.matches(a.target) : !0;
  },
  addEventFields: function(e, r) {
    r.cy = e.cy(), r.target = e;
  },
  callbackContext: function(e, r, a) {
    return r.qualifier != null ? a.target : e;
  },
  beforeEmit: function(e, r) {
    r.conf && r.conf.once && r.conf.onceCollection.removeListener(r.event, r.qualifier, r.callback);
  },
  bubble: function() {
    return !0;
  },
  parent: function(e) {
    return e.isChild() ? e.parent() : e.cy();
  }
}, tn = function(e) {
  return de(e) ? new fr(e) : e;
}, iv = {
  createEmitter: function() {
    for (var e = 0; e < this.length; e++) {
      var r = this[e], a = r._private;
      a.emitter || (a.emitter = new Hn(yp, r));
    }
    return this;
  },
  emitter: function() {
    return this._private.emitter;
  },
  on: function(e, r, a) {
    for (var n = tn(r), i = 0; i < this.length; i++) {
      var o = this[i];
      o.emitter().on(e, n, a);
    }
    return this;
  },
  removeListener: function(e, r, a) {
    for (var n = tn(r), i = 0; i < this.length; i++) {
      var o = this[i];
      o.emitter().removeListener(e, n, a);
    }
    return this;
  },
  removeAllListeners: function() {
    for (var e = 0; e < this.length; e++) {
      var r = this[e];
      r.emitter().removeAllListeners();
    }
    return this;
  },
  one: function(e, r, a) {
    for (var n = tn(r), i = 0; i < this.length; i++) {
      var o = this[i];
      o.emitter().one(e, n, a);
    }
    return this;
  },
  once: function(e, r, a) {
    for (var n = tn(r), i = 0; i < this.length; i++) {
      var o = this[i];
      o.emitter().on(e, n, a, {
        once: !0,
        onceCollection: this
      });
    }
  },
  emit: function(e, r) {
    for (var a = 0; a < this.length; a++) {
      var n = this[a];
      n.emitter().emit(e, r);
    }
    return this;
  },
  emitAndNotify: function(e, r) {
    if (this.length !== 0)
      return this.cy().notify(e, this), this.emit(e, r), this;
  }
};
Be.eventAliasesOn(iv);
var ov = {
  nodes: function(e) {
    return this.filter(function(r) {
      return r.isNode();
    }).filter(e);
  },
  edges: function(e) {
    return this.filter(function(r) {
      return r.isEdge();
    }).filter(e);
  },
  // internal helper to get nodes and edges as separate collections with single iteration over elements
  byGroup: function() {
    for (var e = this.spawn(), r = this.spawn(), a = 0; a < this.length; a++) {
      var n = this[a];
      n.isNode() ? e.push(n) : r.push(n);
    }
    return {
      nodes: e,
      edges: r
    };
  },
  filter: function(e, r) {
    if (e === void 0)
      return this;
    if (de(e) || Ct(e))
      return new fr(e).filter(this);
    if (He(e)) {
      for (var a = this.spawn(), n = this, i = 0; i < n.length; i++) {
        var o = n[i], s = r ? e.apply(r, [o, i, n]) : e(o, i, n);
        s && a.push(o);
      }
      return a;
    }
    return this.spawn();
  },
  not: function(e) {
    if (e) {
      de(e) && (e = this.filter(e));
      for (var r = this.spawn(), a = 0; a < this.length; a++) {
        var n = this[a], i = e.has(n);
        i || r.push(n);
      }
      return r;
    } else
      return this;
  },
  absoluteComplement: function() {
    var e = this.cy();
    return e.mutableElements().not(this);
  },
  intersect: function(e) {
    if (de(e)) {
      var r = e;
      return this.filter(r);
    }
    for (var a = this.spawn(), n = this, i = e, o = this.length < e.length, s = o ? n : i, u = o ? i : n, l = 0; l < s.length; l++) {
      var f = s[l];
      u.has(f) && a.push(f);
    }
    return a;
  },
  xor: function(e) {
    var r = this._private.cy;
    de(e) && (e = r.$(e));
    var a = this.spawn(), n = this, i = e, o = function(u, l) {
      for (var f = 0; f < u.length; f++) {
        var v = u[f], c = v._private.data.id, h = l.hasElementWithId(c);
        h || a.push(v);
      }
    };
    return o(n, i), o(i, n), a;
  },
  diff: function(e) {
    var r = this._private.cy;
    de(e) && (e = r.$(e));
    var a = this.spawn(), n = this.spawn(), i = this.spawn(), o = this, s = e, u = function(f, v, c) {
      for (var h = 0; h < f.length; h++) {
        var d = f[h], g = d._private.data.id, p = v.hasElementWithId(g);
        p ? i.merge(d) : c.push(d);
      }
    };
    return u(o, s, a), u(s, o, n), {
      left: a,
      right: n,
      both: i
    };
  },
  add: function(e) {
    var r = this._private.cy;
    if (!e)
      return this;
    if (de(e)) {
      var a = e;
      e = r.mutableElements().filter(a);
    }
    for (var n = this.spawnSelf(), i = 0; i < e.length; i++) {
      var o = e[i], s = !this.has(o);
      s && n.push(o);
    }
    return n;
  },
  // in place merge on calling collection
  merge: function(e) {
    var r = this._private, a = r.cy;
    if (!e)
      return this;
    if (e && de(e)) {
      var n = e;
      e = a.mutableElements().filter(n);
    }
    for (var i = r.map, o = 0; o < e.length; o++) {
      var s = e[o], u = s._private.data.id, l = !i.has(u);
      if (l) {
        var f = this.length++;
        this[f] = s, i.set(u, {
          ele: s,
          index: f
        });
      }
    }
    return this;
  },
  unmergeAt: function(e) {
    var r = this[e], a = r.id(), n = this._private, i = n.map;
    this[e] = void 0, i.delete(a);
    var o = e === this.length - 1;
    if (this.length > 1 && !o) {
      var s = this.length - 1, u = this[s], l = u._private.data.id;
      this[s] = void 0, this[e] = u, i.set(l, {
        ele: u,
        index: e
      });
    }
    return this.length--, this;
  },
  // remove single ele in place in calling collection
  unmergeOne: function(e) {
    e = e[0];
    var r = this._private, a = e._private.data.id, n = r.map, i = n.get(a);
    if (!i)
      return this;
    var o = i.index;
    return this.unmergeAt(o), this;
  },
  // remove eles in place on calling collection
  unmerge: function(e) {
    var r = this._private.cy;
    if (!e)
      return this;
    if (e && de(e)) {
      var a = e;
      e = r.mutableElements().filter(a);
    }
    for (var n = 0; n < e.length; n++)
      this.unmergeOne(e[n]);
    return this;
  },
  unmergeBy: function(e) {
    for (var r = this.length - 1; r >= 0; r--) {
      var a = this[r];
      e(a) && this.unmergeAt(r);
    }
    return this;
  },
  map: function(e, r) {
    for (var a = [], n = this, i = 0; i < n.length; i++) {
      var o = n[i], s = r ? e.apply(r, [o, i, n]) : e(o, i, n);
      a.push(s);
    }
    return a;
  },
  reduce: function(e, r) {
    for (var a = r, n = this, i = 0; i < n.length; i++)
      a = e(a, n[i], i, n);
    return a;
  },
  max: function(e, r) {
    for (var a = -1 / 0, n, i = this, o = 0; o < i.length; o++) {
      var s = i[o], u = r ? e.apply(r, [s, o, i]) : e(s, o, i);
      u > a && (a = u, n = s);
    }
    return {
      value: a,
      ele: n
    };
  },
  min: function(e, r) {
    for (var a = 1 / 0, n, i = this, o = 0; o < i.length; o++) {
      var s = i[o], u = r ? e.apply(r, [s, o, i]) : e(s, o, i);
      u < a && (a = u, n = s);
    }
    return {
      value: a,
      ele: n
    };
  }
}, ke = ov;
ke.u = ke["|"] = ke["+"] = ke.union = ke.or = ke.add;
ke["\\"] = ke["!"] = ke["-"] = ke.difference = ke.relativeComplement = ke.subtract = ke.not;
ke.n = ke["&"] = ke["."] = ke.and = ke.intersection = ke.intersect;
ke["^"] = ke["(+)"] = ke["(-)"] = ke.symmetricDifference = ke.symdiff = ke.xor;
ke.fnFilter = ke.filterFn = ke.stdFilter = ke.filter;
ke.complement = ke.abscomp = ke.absoluteComplement;
var mp = {
  isNode: function() {
    return this.group() === "nodes";
  },
  isEdge: function() {
    return this.group() === "edges";
  },
  isLoop: function() {
    return this.isEdge() && this.source()[0] === this.target()[0];
  },
  isSimple: function() {
    return this.isEdge() && this.source()[0] !== this.target()[0];
  },
  group: function() {
    var e = this[0];
    if (e)
      return e._private.group;
  }
}, sv = function(e, r) {
  var a = e.cy(), n = a.hasCompoundNodes();
  function i(f) {
    var v = f.pstyle("z-compound-depth");
    return v.value === "auto" ? n ? f.zDepth() : 0 : v.value === "bottom" ? -1 : v.value === "top" ? rs : 0;
  }
  var o = i(e) - i(r);
  if (o !== 0)
    return o;
  function s(f) {
    var v = f.pstyle("z-index-compare");
    return v.value === "auto" && f.isNode() ? 1 : 0;
  }
  var u = s(e) - s(r);
  if (u !== 0)
    return u;
  var l = e.pstyle("z-index").value - r.pstyle("z-index").value;
  return l !== 0 ? l : e.poolIndex() - r.poolIndex();
}, Ln = {
  forEach: function(e, r) {
    if (He(e))
      for (var a = this.length, n = 0; n < a; n++) {
        var i = this[n], o = r ? e.apply(r, [i, n, this]) : e(i, n, this);
        if (o === !1)
          break;
      }
    return this;
  },
  toArray: function() {
    for (var e = [], r = 0; r < this.length; r++)
      e.push(this[r]);
    return e;
  },
  slice: function(e, r) {
    var a = [], n = this.length;
    r == null && (r = n), e == null && (e = 0), e < 0 && (e = n + e), r < 0 && (r = n + r);
    for (var i = e; i >= 0 && i < r && i < n; i++)
      a.push(this[i]);
    return this.spawn(a);
  },
  size: function() {
    return this.length;
  },
  eq: function(e) {
    return this[e] || this.spawn();
  },
  first: function() {
    return this[0] || this.spawn();
  },
  last: function() {
    return this[this.length - 1] || this.spawn();
  },
  empty: function() {
    return this.length === 0;
  },
  nonempty: function() {
    return !this.empty();
  },
  sort: function(e) {
    if (!He(e))
      return this;
    var r = this.toArray().sort(e);
    return this.spawn(r);
  },
  sortByZIndex: function() {
    return this.sort(sv);
  },
  zDepth: function() {
    var e = this[0];
    if (e) {
      var r = e._private, a = r.group;
      if (a === "nodes") {
        var n = r.data.parent ? e.parents().size() : 0;
        return e.isParent() ? n : rs - 1;
      } else {
        var i = r.source, o = r.target, s = i.zDepth(), u = o.zDepth();
        return Math.max(s, u, 0);
      }
    }
  }
};
Ln.each = Ln.forEach;
var bp = function() {
  var e = "undefined", r = (typeof Symbol > "u" ? "undefined" : tt(Symbol)) != e && tt(Symbol.iterator) != e;
  r && (Ln[Symbol.iterator] = function() {
    var a = this, n = {
      value: void 0,
      done: !1
    }, i = 0, o = this.length;
    return nf({
      next: function() {
        return i < o ? n.value = a[i++] : (n.value = void 0, n.done = !0), n;
      }
    }, Symbol.iterator, function() {
      return this;
    });
  });
};
bp();
var wp = ft({
  nodeDimensionsIncludeLabels: !1
}), vn = {
  // Calculates and returns node dimensions { x, y } based on options given
  layoutDimensions: function(e) {
    e = wp(e);
    var r;
    if (!this.takesUpSpace())
      r = {
        w: 0,
        h: 0
      };
    else if (e.nodeDimensionsIncludeLabels) {
      var a = this.boundingBox();
      r = {
        w: a.w,
        h: a.h
      };
    } else
      r = {
        w: this.outerWidth(),
        h: this.outerHeight()
      };
    return (r.w === 0 || r.h === 0) && (r.w = r.h = 1), r;
  },
  // using standard layout options, apply position function (w/ or w/o animation)
  layoutPositions: function(e, r, a) {
    var n = this.nodes().filter(function(C) {
      return !C.isParent();
    }), i = this.cy(), o = r.eles, s = function(S) {
      return S.id();
    }, u = Kr(a, s);
    e.emit({
      type: "layoutstart",
      layout: e
    }), e.animations = [];
    var l = function(S, w, x) {
      var T = {
        x: w.x1 + w.w / 2,
        y: w.y1 + w.h / 2
      }, D = {
        // scale from center of bounding box (not necessarily 0,0)
        x: (x.x - T.x) * S,
        y: (x.y - T.y) * S
      };
      return {
        x: T.x + D.x,
        y: T.y + D.y
      };
    }, f = r.spacingFactor && r.spacingFactor !== 1, v = function() {
      if (!f)
        return null;
      for (var S = mt(), w = 0; w < n.length; w++) {
        var x = n[w], T = u(x, w);
        Df(S, T.x, T.y);
      }
      return S;
    }, c = v(), h = Kr(function(C, S) {
      var w = u(C, S);
      if (f) {
        var x = Math.abs(r.spacingFactor);
        w = l(x, c, w);
      }
      return r.transform != null && (w = r.transform(C, w)), w;
    }, s);
    if (r.animate) {
      for (var d = 0; d < n.length; d++) {
        var g = n[d], p = h(g, d), y = r.animateFilter == null || r.animateFilter(g, d);
        if (y) {
          var b = g.animation({
            position: p,
            duration: r.animationDuration,
            easing: r.animationEasing
          });
          e.animations.push(b);
        } else
          g.position(p);
      }
      if (r.fit) {
        var m = i.animation({
          fit: {
            boundingBox: o.boundingBoxAt(h),
            padding: r.padding
          },
          duration: r.animationDuration,
          easing: r.animationEasing
        });
        e.animations.push(m);
      } else if (r.zoom !== void 0 && r.pan !== void 0) {
        var E = i.animation({
          zoom: r.zoom,
          pan: r.pan,
          duration: r.animationDuration,
          easing: r.animationEasing
        });
        e.animations.push(E);
      }
      e.animations.forEach(function(C) {
        return C.play();
      }), e.one("layoutready", r.ready), e.emit({
        type: "layoutready",
        layout: e
      }), ra.all(e.animations.map(function(C) {
        return C.promise();
      })).then(function() {
        e.one("layoutstop", r.stop), e.emit({
          type: "layoutstop",
          layout: e
        });
      });
    } else
      n.positions(h), r.fit && i.fit(r.eles, r.padding), r.zoom != null && i.zoom(r.zoom), r.pan && i.pan(r.pan), e.one("layoutready", r.ready), e.emit({
        type: "layoutready",
        layout: e
      }), e.one("layoutstop", r.stop), e.emit({
        type: "layoutstop",
        layout: e
      });
    return this;
  },
  layout: function(e) {
    var r = this.cy();
    return r.makeLayout(ye({}, e, {
      eles: this
    }));
  }
};
vn.createLayout = vn.makeLayout = vn.layout;
function uv(t, e, r) {
  var a = r._private, n = a.styleCache = a.styleCache || [], i;
  return (i = n[t]) != null || (i = n[t] = e(r)), i;
}
function Xn(t, e) {
  return t = Sr(t), function(a) {
    return uv(t, e, a);
  };
}
function Wn(t, e) {
  t = Sr(t);
  var r = function(n) {
    return e.call(n);
  };
  return function() {
    var n = this[0];
    if (n)
      return uv(t, r, n);
  };
}
var ut = {
  recalculateRenderedStyle: function(e) {
    var r = this.cy(), a = r.renderer(), n = r.styleEnabled();
    return a && n && a.recalculateRenderedStyle(this, e), this;
  },
  dirtyStyleCache: function() {
    var e = this.cy(), r = function(i) {
      return i._private.styleCache = null;
    };
    if (e.hasCompoundNodes()) {
      var a;
      a = this.spawnSelf().merge(this.descendants()).merge(this.parents()), a.merge(a.connectedEdges()), a.forEach(r);
    } else
      this.forEach(function(n) {
        r(n), n.connectedEdges().forEach(r);
      });
    return this;
  },
  // fully updates (recalculates) the style for the elements
  updateStyle: function(e) {
    var r = this._private.cy;
    if (!r.styleEnabled())
      return this;
    if (r.batching()) {
      var a = r._private.batchStyleEles;
      return a.merge(this), this;
    }
    var n = r.hasCompoundNodes(), i = this;
    e = !!(e || e === void 0), n && (i = this.spawnSelf().merge(this.descendants()).merge(this.parents()));
    var o = i;
    return e ? o.emitAndNotify("style") : o.emit("style"), i.forEach(function(s) {
      return s._private.styleDirty = !0;
    }), this;
  },
  // private: clears dirty flag and recalculates style
  cleanStyle: function() {
    var e = this.cy();
    if (e.styleEnabled())
      for (var r = 0; r < this.length; r++) {
        var a = this[r];
        a._private.styleDirty && (a._private.styleDirty = !1, e.style().apply(a));
      }
  },
  // get the internal parsed style object for the specified property
  parsedStyle: function(e) {
    var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, a = this[0], n = a.cy();
    if (n.styleEnabled() && a) {
      a._private.styleDirty && (a._private.styleDirty = !1, n.style().apply(a));
      var i = a._private.style[e];
      return i ?? (r ? n.style().getDefaultProperty(e) : null);
    }
  },
  numericStyle: function(e) {
    var r = this[0];
    if (r.cy().styleEnabled() && r) {
      var a = r.pstyle(e);
      return a.pfValue !== void 0 ? a.pfValue : a.value;
    }
  },
  numericStyleUnits: function(e) {
    var r = this[0];
    if (r.cy().styleEnabled() && r)
      return r.pstyle(e).units;
  },
  // get the specified css property as a rendered value (i.e. on-screen value)
  // or get the whole rendered style if no property specified (NB doesn't allow setting)
  renderedStyle: function(e) {
    var r = this.cy();
    if (!r.styleEnabled())
      return this;
    var a = this[0];
    if (a)
      return r.style().getRenderedStyle(a, e);
  },
  // read the calculated css style of the element or override the style (via a bypass)
  style: function(e, r) {
    var a = this.cy();
    if (!a.styleEnabled())
      return this;
    var n = !1, i = a.style();
    if (Ie(e)) {
      var o = e;
      i.applyBypass(this, o, n), this.emitAndNotify("style");
    } else if (de(e))
      if (r === void 0) {
        var s = this[0];
        return s ? i.getStylePropertyValue(s, e) : void 0;
      } else
        i.applyBypass(this, e, r, n), this.emitAndNotify("style");
    else if (e === void 0) {
      var u = this[0];
      return u ? i.getRawStyle(u) : void 0;
    }
    return this;
  },
  removeStyle: function(e) {
    var r = this.cy();
    if (!r.styleEnabled())
      return this;
    var a = !1, n = r.style(), i = this;
    if (e === void 0)
      for (var o = 0; o < i.length; o++) {
        var s = i[o];
        n.removeAllBypasses(s, a);
      }
    else {
      e = e.split(/\s+/);
      for (var u = 0; u < i.length; u++) {
        var l = i[u];
        n.removeBypasses(l, e, a);
      }
    }
    return this.emitAndNotify("style"), this;
  },
  show: function() {
    return this.css("display", "element"), this;
  },
  hide: function() {
    return this.css("display", "none"), this;
  },
  effectiveOpacity: function() {
    var e = this.cy();
    if (!e.styleEnabled())
      return 1;
    var r = e.hasCompoundNodes(), a = this[0];
    if (a) {
      var n = a._private, i = a.pstyle("opacity").value;
      if (!r)
        return i;
      var o = n.data.parent ? a.parents() : null;
      if (o)
        for (var s = 0; s < o.length; s++) {
          var u = o[s], l = u.pstyle("opacity").value;
          i = l * i;
        }
      return i;
    }
  },
  transparent: function() {
    var e = this.cy();
    if (!e.styleEnabled())
      return !1;
    var r = this[0], a = r.cy().hasCompoundNodes();
    if (r)
      return a ? r.effectiveOpacity() === 0 : r.pstyle("opacity").value === 0;
  },
  backgrounding: function() {
    var e = this.cy();
    if (!e.styleEnabled())
      return !1;
    var r = this[0];
    return !!r._private.backgrounding;
  }
};
function xo(t, e) {
  var r = t._private, a = r.data.parent ? t.parents() : null;
  if (a)
    for (var n = 0; n < a.length; n++) {
      var i = a[n];
      if (!e(i))
        return !1;
    }
  return !0;
}
function ds(t) {
  var e = t.ok, r = t.edgeOkViaNode || t.ok, a = t.parentOk || t.ok;
  return function() {
    var n = this.cy();
    if (!n.styleEnabled())
      return !0;
    var i = this[0], o = n.hasCompoundNodes();
    if (i) {
      var s = i._private;
      if (!e(i))
        return !1;
      if (i.isNode())
        return !o || xo(i, a);
      var u = s.source, l = s.target;
      return r(u) && (!o || xo(u, r)) && (u === l || r(l) && (!o || xo(l, r)));
    }
  };
}
var aa = Xn("eleTakesUpSpace", function(t) {
  return t.pstyle("display").value === "element" && t.width() !== 0 && (t.isNode() ? t.height() !== 0 : !0);
});
ut.takesUpSpace = Wn("takesUpSpace", ds({
  ok: aa
}));
var Ep = Xn("eleInteractive", function(t) {
  return t.pstyle("events").value === "yes" && t.pstyle("visibility").value === "visible" && aa(t);
}), xp = Xn("parentInteractive", function(t) {
  return t.pstyle("visibility").value === "visible" && aa(t);
});
ut.interactive = Wn("interactive", ds({
  ok: Ep,
  parentOk: xp,
  edgeOkViaNode: aa
}));
ut.noninteractive = function() {
  var t = this[0];
  if (t)
    return !t.interactive();
};
var Tp = Xn("eleVisible", function(t) {
  return t.pstyle("visibility").value === "visible" && t.pstyle("opacity").pfValue !== 0 && aa(t);
}), Cp = aa;
ut.visible = Wn("visible", ds({
  ok: Tp,
  edgeOkViaNode: Cp
}));
ut.hidden = function() {
  var t = this[0];
  if (t)
    return !t.visible();
};
ut.isBundledBezier = Wn("isBundledBezier", function() {
  return this.cy().styleEnabled() ? !this.removed() && this.pstyle("curve-style").value === "bezier" && this.takesUpSpace() : !1;
});
ut.bypass = ut.css = ut.style;
ut.renderedCss = ut.renderedStyle;
ut.removeBypass = ut.removeCss = ut.removeStyle;
ut.pstyle = ut.parsedStyle;
var or = {};
function yl(t) {
  return function() {
    var e = arguments, r = [];
    if (e.length === 2) {
      var a = e[0], n = e[1];
      this.on(t.event, a, n);
    } else if (e.length === 1 && He(e[0])) {
      var i = e[0];
      this.on(t.event, i);
    } else if (e.length === 0 || e.length === 1 && ze(e[0])) {
      for (var o = e.length === 1 ? e[0] : null, s = 0; s < this.length; s++) {
        var u = this[s], l = !t.ableField || u._private[t.ableField], f = u._private[t.field] != t.value;
        if (t.overrideAble) {
          var v = t.overrideAble(u);
          if (v !== void 0 && (l = v, !v))
            return this;
        }
        l && (u._private[t.field] = t.value, f && r.push(u));
      }
      var c = this.spawn(r);
      c.updateStyle(), c.emit(t.event), o && c.emit(o);
    }
    return this;
  };
}
function na(t) {
  or[t.field] = function() {
    var e = this[0];
    if (e) {
      if (t.overrideField) {
        var r = t.overrideField(e);
        if (r !== void 0)
          return r;
      }
      return e._private[t.field];
    }
  }, or[t.on] = yl({
    event: t.on,
    field: t.field,
    ableField: t.ableField,
    overrideAble: t.overrideAble,
    value: !0
  }), or[t.off] = yl({
    event: t.off,
    field: t.field,
    ableField: t.ableField,
    overrideAble: t.overrideAble,
    value: !1
  });
}
na({
  field: "locked",
  overrideField: function(e) {
    return e.cy().autolock() ? !0 : void 0;
  },
  on: "lock",
  off: "unlock"
});
na({
  field: "grabbable",
  overrideField: function(e) {
    return e.cy().autoungrabify() || e.pannable() ? !1 : void 0;
  },
  on: "grabify",
  off: "ungrabify"
});
na({
  field: "selected",
  ableField: "selectable",
  overrideAble: function(e) {
    return e.cy().autounselectify() ? !1 : void 0;
  },
  on: "select",
  off: "unselect"
});
na({
  field: "selectable",
  overrideField: function(e) {
    return e.cy().autounselectify() ? !1 : void 0;
  },
  on: "selectify",
  off: "unselectify"
});
or.deselect = or.unselect;
or.grabbed = function() {
  var t = this[0];
  if (t)
    return t._private.grabbed;
};
na({
  field: "active",
  on: "activate",
  off: "unactivate"
});
na({
  field: "pannable",
  on: "panify",
  off: "unpanify"
});
or.inactive = function() {
  var t = this[0];
  if (t)
    return !t._private.active;
};
var ht = {}, ml = function(e) {
  return function(a) {
    for (var n = this, i = [], o = 0; o < n.length; o++) {
      var s = n[o];
      if (s.isNode()) {
        for (var u = !1, l = s.connectedEdges(), f = 0; f < l.length; f++) {
          var v = l[f], c = v.source(), h = v.target();
          if (e.noIncomingEdges && h === s && c !== s || e.noOutgoingEdges && c === s && h !== s) {
            u = !0;
            break;
          }
        }
        u || i.push(s);
      }
    }
    return this.spawn(i, !0).filter(a);
  };
}, bl = function(e) {
  return function(r) {
    for (var a = this, n = [], i = 0; i < a.length; i++) {
      var o = a[i];
      if (o.isNode())
        for (var s = o.connectedEdges(), u = 0; u < s.length; u++) {
          var l = s[u], f = l.source(), v = l.target();
          e.outgoing && f === o ? (n.push(l), n.push(v)) : e.incoming && v === o && (n.push(l), n.push(f));
        }
    }
    return this.spawn(n, !0).filter(r);
  };
}, wl = function(e) {
  return function(r) {
    for (var a = this, n = [], i = {}; ; ) {
      var o = e.outgoing ? a.outgoers() : a.incomers();
      if (o.length === 0)
        break;
      for (var s = !1, u = 0; u < o.length; u++) {
        var l = o[u], f = l.id();
        i[f] || (i[f] = !0, n.push(l), s = !0);
      }
      if (!s)
        break;
      a = o;
    }
    return this.spawn(n, !0).filter(r);
  };
};
ht.clearTraversalCache = function() {
  for (var t = 0; t < this.length; t++)
    this[t]._private.traversalCache = null;
};
ye(ht, {
  // get the root nodes in the DAG
  roots: ml({
    noIncomingEdges: !0
  }),
  // get the leaf nodes in the DAG
  leaves: ml({
    noOutgoingEdges: !0
  }),
  // normally called children in graph theory
  // these nodes =edges=> outgoing nodes
  outgoers: Lt(bl({
    outgoing: !0
  }), "outgoers"),
  // aka DAG descendants
  successors: wl({
    outgoing: !0
  }),
  // normally called parents in graph theory
  // these nodes <=edges= incoming nodes
  incomers: Lt(bl({
    incoming: !0
  }), "incomers"),
  // aka DAG ancestors
  predecessors: wl({})
});
ye(ht, {
  neighborhood: Lt(function(t) {
    for (var e = [], r = this.nodes(), a = 0; a < r.length; a++)
      for (var n = r[a], i = n.connectedEdges(), o = 0; o < i.length; o++) {
        var s = i[o], u = s.source(), l = s.target(), f = n === u ? l : u;
        f.length > 0 && e.push(f[0]), e.push(s[0]);
      }
    return this.spawn(e, !0).filter(t);
  }, "neighborhood"),
  closedNeighborhood: function(e) {
    return this.neighborhood().add(this).filter(e);
  },
  openNeighborhood: function(e) {
    return this.neighborhood(e);
  }
});
ht.neighbourhood = ht.neighborhood;
ht.closedNeighbourhood = ht.closedNeighborhood;
ht.openNeighbourhood = ht.openNeighborhood;
ye(ht, {
  source: Lt(function(e) {
    var r = this[0], a;
    return r && (a = r._private.source || r.cy().collection()), a && e ? a.filter(e) : a;
  }, "source"),
  target: Lt(function(e) {
    var r = this[0], a;
    return r && (a = r._private.target || r.cy().collection()), a && e ? a.filter(e) : a;
  }, "target"),
  sources: El({
    attr: "source"
  }),
  targets: El({
    attr: "target"
  })
});
function El(t) {
  return function(r) {
    for (var a = [], n = 0; n < this.length; n++) {
      var i = this[n], o = i._private[t.attr];
      o && a.push(o);
    }
    return this.spawn(a, !0).filter(r);
  };
}
ye(ht, {
  edgesWith: Lt(xl(), "edgesWith"),
  edgesTo: Lt(xl({
    thisIsSrc: !0
  }), "edgesTo")
});
function xl(t) {
  return function(r) {
    var a = [], n = this._private.cy, i = t || {};
    de(r) && (r = n.$(r));
    for (var o = 0; o < r.length; o++)
      for (var s = r[o]._private.edges, u = 0; u < s.length; u++) {
        var l = s[u], f = l._private.data, v = this.hasElementWithId(f.source) && r.hasElementWithId(f.target), c = r.hasElementWithId(f.source) && this.hasElementWithId(f.target), h = v || c;
        h && ((i.thisIsSrc || i.thisIsTgt) && (i.thisIsSrc && !v || i.thisIsTgt && !c) || a.push(l));
      }
    return this.spawn(a, !0);
  };
}
ye(ht, {
  connectedEdges: Lt(function(t) {
    for (var e = [], r = this, a = 0; a < r.length; a++) {
      var n = r[a];
      if (n.isNode())
        for (var i = n._private.edges, o = 0; o < i.length; o++) {
          var s = i[o];
          e.push(s);
        }
    }
    return this.spawn(e, !0).filter(t);
  }, "connectedEdges"),
  connectedNodes: Lt(function(t) {
    for (var e = [], r = this, a = 0; a < r.length; a++) {
      var n = r[a];
      n.isEdge() && (e.push(n.source()[0]), e.push(n.target()[0]));
    }
    return this.spawn(e, !0).filter(t);
  }, "connectedNodes"),
  parallelEdges: Lt(Tl(), "parallelEdges"),
  codirectedEdges: Lt(Tl({
    codirected: !0
  }), "codirectedEdges")
});
function Tl(t) {
  var e = {
    codirected: !1
  };
  return t = ye({}, e, t), function(a) {
    for (var n = [], i = this.edges(), o = t, s = 0; s < i.length; s++)
      for (var u = i[s], l = u._private, f = l.source, v = f._private.data.id, c = l.data.target, h = f._private.edges, d = 0; d < h.length; d++) {
        var g = h[d], p = g._private.data, y = p.target, b = p.source, m = y === c && b === v, E = v === y && c === b;
        (o.codirected && m || !o.codirected && (m || E)) && n.push(g);
      }
    return this.spawn(n, !0).filter(a);
  };
}
ye(ht, {
  components: function(e) {
    var r = this, a = r.cy(), n = a.collection(), i = e == null ? r.nodes() : e.nodes(), o = [];
    e != null && i.empty() && (i = e.sources());
    var s = function(f, v) {
      n.merge(f), i.unmerge(f), v.merge(f);
    };
    if (i.empty())
      return r.spawn();
    var u = function() {
      var f = a.collection();
      o.push(f);
      var v = i[0];
      s(v, f), r.bfs({
        directed: !1,
        roots: v,
        visit: function(h) {
          return s(h, f);
        }
      }), f.forEach(function(c) {
        c.connectedEdges().forEach(function(h) {
          r.has(h) && f.has(h.source()) && f.has(h.target()) && f.merge(h);
        });
      });
    };
    do
      u();
    while (i.length > 0);
    return o;
  },
  component: function() {
    var e = this[0];
    return e.cy().mutableElements().components(e)[0];
  }
});
ht.componentsOf = ht.components;
var lt = function(e, r) {
  var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  if (e === void 0) {
    qe("A collection must have a reference to the core");
    return;
  }
  var i = new Wt(), o = !1;
  if (!r)
    r = [];
  else if (r.length > 0 && Ie(r[0]) && !ka(r[0])) {
    o = !0;
    for (var s = [], u = new ta(), l = 0, f = r.length; l < f; l++) {
      var v = r[l];
      v.data == null && (v.data = {});
      var c = v.data;
      if (c.id == null)
        c.id = xf();
      else if (e.hasElementWithId(c.id) || u.has(c.id))
        continue;
      var h = new Fn(e, v, !1);
      s.push(h), u.add(c.id);
    }
    r = s;
  }
  this.length = 0;
  for (var d = 0, g = r.length; d < g; d++) {
    var p = r[d][0];
    if (p != null) {
      var y = p._private.data.id;
      (!a || !i.has(y)) && (a && i.set(y, {
        index: this.length,
        ele: p
      }), this[this.length] = p, this.length++);
    }
  }
  this._private = {
    eles: this,
    cy: e,
    get map() {
      return this.lazyMap == null && this.rebuildMap(), this.lazyMap;
    },
    set map(b) {
      this.lazyMap = b;
    },
    rebuildMap: function() {
      for (var m = this.lazyMap = new Wt(), E = this.eles, C = 0; C < E.length; C++) {
        var S = E[C];
        m.set(S.id(), {
          index: C,
          ele: S
        });
      }
    }
  }, a && (this._private.map = i), o && !n && this.restore();
}, Ve = Fn.prototype = lt.prototype = Object.create(Array.prototype);
Ve.instanceString = function() {
  return "collection";
};
Ve.spawn = function(t, e) {
  return new lt(this.cy(), t, e);
};
Ve.spawnSelf = function() {
  return this.spawn(this);
};
Ve.cy = function() {
  return this._private.cy;
};
Ve.renderer = function() {
  return this._private.cy.renderer();
};
Ve.element = function() {
  return this[0];
};
Ve.collection = function() {
  return uf(this) ? this : new lt(this._private.cy, [this]);
};
Ve.unique = function() {
  return new lt(this._private.cy, this, !0);
};
Ve.hasElementWithId = function(t) {
  return t = "" + t, this._private.map.has(t);
};
Ve.getElementById = function(t) {
  t = "" + t;
  var e = this._private.cy, r = this._private.map.get(t);
  return r ? r.ele : new lt(e);
};
Ve.$id = Ve.getElementById;
Ve.poolIndex = function() {
  var t = this._private.cy, e = t._private.elements, r = this[0]._private.data.id;
  return e._private.map.get(r).index;
};
Ve.indexOf = function(t) {
  var e = t[0]._private.data.id;
  return this._private.map.get(e).index;
};
Ve.indexOfId = function(t) {
  return t = "" + t, this._private.map.get(t).index;
};
Ve.json = function(t) {
  var e = this.element(), r = this.cy();
  if (e == null && t)
    return this;
  if (e != null) {
    var a = e._private;
    if (Ie(t)) {
      if (r.startBatch(), t.data) {
        e.data(t.data);
        var n = a.data;
        if (e.isEdge()) {
          var i = !1, o = {}, s = t.data.source, u = t.data.target;
          s != null && s != n.source && (o.source = "" + s, i = !0), u != null && u != n.target && (o.target = "" + u, i = !0), i && (e = e.move(o));
        } else {
          var l = "parent" in t.data, f = t.data.parent;
          l && (f != null || n.parent != null) && f != n.parent && (f === void 0 && (f = null), f != null && (f = "" + f), e = e.move({
            parent: f
          }));
        }
      }
      t.position && e.position(t.position);
      var v = function(g, p, y) {
        var b = t[g];
        b != null && b !== a[g] && (b ? e[p]() : e[y]());
      };
      return v("removed", "remove", "restore"), v("selected", "select", "unselect"), v("selectable", "selectify", "unselectify"), v("locked", "lock", "unlock"), v("grabbable", "grabify", "ungrabify"), v("pannable", "panify", "unpanify"), t.classes != null && e.classes(t.classes), r.endBatch(), this;
    } else if (t === void 0) {
      var c = {
        data: Vt(a.data),
        position: Vt(a.position),
        group: a.group,
        removed: a.removed,
        selected: a.selected,
        selectable: a.selectable,
        locked: a.locked,
        grabbable: a.grabbable,
        pannable: a.pannable,
        classes: null
      };
      c.classes = "";
      var h = 0;
      return a.classes.forEach(function(d) {
        return c.classes += h++ === 0 ? d : " " + d;
      }), c;
    }
  }
};
Ve.jsons = function() {
  for (var t = [], e = 0; e < this.length; e++) {
    var r = this[e], a = r.json();
    t.push(a);
  }
  return t;
};
Ve.clone = function() {
  for (var t = this.cy(), e = [], r = 0; r < this.length; r++) {
    var a = this[r], n = a.json(), i = new Fn(t, n, !1);
    e.push(i);
  }
  return new lt(t, e);
};
Ve.copy = Ve.clone;
Ve.restore = function() {
  for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, r = this, a = r.cy(), n = a._private, i = [], o = [], s, u = 0, l = r.length; u < l; u++) {
    var f = r[u];
    e && !f.removed() || (f.isNode() ? i.push(f) : o.push(f));
  }
  s = i.concat(o);
  var v, c = function() {
    s.splice(v, 1), v--;
  };
  for (v = 0; v < s.length; v++) {
    var h = s[v], d = h._private, g = d.data;
    if (h.clearTraversalCache(), !(!e && !d.removed)) {
      if (g.id === void 0)
        g.id = xf();
      else if (ne(g.id))
        g.id = "" + g.id;
      else if (sr(g.id) || !de(g.id)) {
        qe("Can not create element with invalid string ID `" + g.id + "`"), c();
        continue;
      } else if (a.hasElementWithId(g.id)) {
        qe("Can not create second element with ID `" + g.id + "`"), c();
        continue;
      }
    }
    var p = g.id;
    if (h.isNode()) {
      var y = d.position;
      y.x == null && (y.x = 0), y.y == null && (y.y = 0);
    }
    if (h.isEdge()) {
      for (var b = h, m = ["source", "target"], E = m.length, C = !1, S = 0; S < E; S++) {
        var w = m[S], x = g[w];
        ne(x) && (x = g[w] = "" + g[w]), x == null || x === "" ? (qe("Can not create edge `" + p + "` with unspecified " + w), C = !0) : a.hasElementWithId(x) || (qe("Can not create edge `" + p + "` with nonexistent " + w + " `" + x + "`"), C = !0);
      }
      if (C) {
        c();
        continue;
      }
      var T = a.getElementById(g.source), D = a.getElementById(g.target);
      T.same(D) ? T._private.edges.push(b) : (T._private.edges.push(b), D._private.edges.push(b)), b._private.source = T, b._private.target = D;
    }
    d.map = new Wt(), d.map.set(p, {
      ele: h,
      index: 0
    }), d.removed = !1, e && a.addToPool(h);
  }
  for (var A = 0; A < i.length; A++) {
    var L = i[A], R = L._private.data;
    ne(R.parent) && (R.parent = "" + R.parent);
    var P = R.parent, I = P != null;
    if (I || L._private.parent) {
      var k = L._private.parent ? a.collection().merge(L._private.parent) : a.getElementById(P);
      if (k.empty())
        R.parent = void 0;
      else if (k[0].removed())
        Fe("Node added with missing parent, reference to parent removed"), R.parent = void 0, L._private.parent = null;
      else {
        for (var O = !1, N = k; !N.empty(); ) {
          if (L.same(N)) {
            O = !0, R.parent = void 0;
            break;
          }
          N = N.parent();
        }
        O || (k[0]._private.children.push(L), L._private.parent = k[0], n.hasCompoundNodes = !0);
      }
    }
  }
  if (s.length > 0) {
    for (var F = s.length === r.length ? r : new lt(a, s), G = 0; G < F.length; G++) {
      var B = F[G];
      B.isNode() || (B.parallelEdges().clearTraversalCache(), B.source().clearTraversalCache(), B.target().clearTraversalCache());
    }
    var z;
    n.hasCompoundNodes ? z = a.collection().merge(F).merge(F.connectedNodes()).merge(F.parent()) : z = F, z.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(t), t ? F.emitAndNotify("add") : e && F.emit("add");
  }
  return r;
};
Ve.removed = function() {
  var t = this[0];
  return t && t._private.removed;
};
Ve.inside = function() {
  var t = this[0];
  return t && !t._private.removed;
};
Ve.remove = function() {
  var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, r = this, a = [], n = {}, i = r._private.cy;
  function o(P) {
    for (var I = P._private.edges, k = 0; k < I.length; k++)
      u(I[k]);
  }
  function s(P) {
    for (var I = P._private.children, k = 0; k < I.length; k++)
      u(I[k]);
  }
  function u(P) {
    var I = n[P.id()];
    e && P.removed() || I || (n[P.id()] = !0, P.isNode() ? (a.push(P), o(P), s(P)) : a.unshift(P));
  }
  for (var l = 0, f = r.length; l < f; l++) {
    var v = r[l];
    u(v);
  }
  function c(P, I) {
    var k = P._private.edges;
    ur(k, I), P.clearTraversalCache();
  }
  function h(P) {
    P.clearTraversalCache();
  }
  var d = [];
  d.ids = {};
  function g(P, I) {
    I = I[0], P = P[0];
    var k = P._private.children, O = P.id();
    ur(k, I), I._private.parent = null, d.ids[O] || (d.ids[O] = !0, d.push(P));
  }
  r.dirtyCompoundBoundsCache(), e && i.removeFromPool(a);
  for (var p = 0; p < a.length; p++) {
    var y = a[p];
    if (y.isEdge()) {
      var b = y.source()[0], m = y.target()[0];
      c(b, y), c(m, y);
      for (var E = y.parallelEdges(), C = 0; C < E.length; C++) {
        var S = E[C];
        h(S), S.isBundledBezier() && S.dirtyBoundingBoxCache();
      }
    } else {
      var w = y.parent();
      w.length !== 0 && g(w, y);
    }
    e && (y._private.removed = !0);
  }
  var x = i._private.elements;
  i._private.hasCompoundNodes = !1;
  for (var T = 0; T < x.length; T++) {
    var D = x[T];
    if (D.isParent()) {
      i._private.hasCompoundNodes = !0;
      break;
    }
  }
  var A = new lt(this.cy(), a);
  A.size() > 0 && (t ? A.emitAndNotify("remove") : e && A.emit("remove"));
  for (var L = 0; L < d.length; L++) {
    var R = d[L];
    (!e || !R.removed()) && R.updateStyle();
  }
  return A;
};
Ve.move = function(t) {
  var e = this._private.cy, r = this, a = !1, n = !1, i = function(d) {
    return d == null ? d : "" + d;
  };
  if (t.source !== void 0 || t.target !== void 0) {
    var o = i(t.source), s = i(t.target), u = o != null && e.hasElementWithId(o), l = s != null && e.hasElementWithId(s);
    (u || l) && (e.batch(function() {
      r.remove(a, n), r.emitAndNotify("moveout");
      for (var h = 0; h < r.length; h++) {
        var d = r[h], g = d._private.data;
        d.isEdge() && (u && (g.source = o), l && (g.target = s));
      }
      r.restore(a, n);
    }), r.emitAndNotify("move"));
  } else if (t.parent !== void 0) {
    var f = i(t.parent), v = f === null || e.hasElementWithId(f);
    if (v) {
      var c = f === null ? void 0 : f;
      e.batch(function() {
        var h = r.remove(a, n);
        h.emitAndNotify("moveout");
        for (var d = 0; d < r.length; d++) {
          var g = r[d], p = g._private.data;
          g.isNode() && (p.parent = c);
        }
        h.restore(a, n);
      }), r.emitAndNotify("move");
    }
  }
  return this;
};
[kf, kg, fn, ir, Qr, Zg, Yn, hp, iv, ov, mp, Ln, vn, ut, or, ht].forEach(function(t) {
  ye(Ve, t);
});
var Dp = {
  add: function(e) {
    var r, a = this;
    if (Ct(e)) {
      var n = e;
      if (n._private.cy === a)
        r = n.restore();
      else {
        for (var i = [], o = 0; o < n.length; o++) {
          var s = n[o];
          i.push(s.json());
        }
        r = new lt(a, i);
      }
    } else if (ze(e)) {
      var u = e;
      r = new lt(a, u);
    } else if (Ie(e) && (ze(e.nodes) || ze(e.edges))) {
      for (var l = e, f = [], v = ["nodes", "edges"], c = 0, h = v.length; c < h; c++) {
        var d = v[c], g = l[d];
        if (ze(g))
          for (var p = 0, y = g.length; p < y; p++) {
            var b = ye({
              group: d
            }, g[p]);
            f.push(b);
          }
      }
      r = new lt(a, f);
    } else {
      var m = e;
      r = new Fn(a, m).collection();
    }
    return r;
  },
  remove: function(e) {
    if (!Ct(e)) {
      if (de(e)) {
        var r = e;
        e = this.$(r);
      }
    }
    return e.remove();
  }
};
/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */
function Sp(t, e, r, a) {
  var n = 4, i = 1e-3, o = 1e-7, s = 10, u = 11, l = 1 / (u - 1), f = typeof Float32Array < "u";
  if (arguments.length !== 4)
    return !1;
  for (var v = 0; v < 4; ++v)
    if (typeof arguments[v] != "number" || isNaN(arguments[v]) || !isFinite(arguments[v]))
      return !1;
  t = Math.min(t, 1), r = Math.min(r, 1), t = Math.max(t, 0), r = Math.max(r, 0);
  var c = f ? new Float32Array(u) : new Array(u);
  function h(D, A) {
    return 1 - 3 * A + 3 * D;
  }
  function d(D, A) {
    return 3 * A - 6 * D;
  }
  function g(D) {
    return 3 * D;
  }
  function p(D, A, L) {
    return ((h(A, L) * D + d(A, L)) * D + g(A)) * D;
  }
  function y(D, A, L) {
    return 3 * h(A, L) * D * D + 2 * d(A, L) * D + g(A);
  }
  function b(D, A) {
    for (var L = 0; L < n; ++L) {
      var R = y(A, t, r);
      if (R === 0)
        return A;
      var P = p(A, t, r) - D;
      A -= P / R;
    }
    return A;
  }
  function m() {
    for (var D = 0; D < u; ++D)
      c[D] = p(D * l, t, r);
  }
  function E(D, A, L) {
    var R, P, I = 0;
    do
      P = A + (L - A) / 2, R = p(P, t, r) - D, R > 0 ? L = P : A = P;
    while (Math.abs(R) > o && ++I < s);
    return P;
  }
  function C(D) {
    for (var A = 0, L = 1, R = u - 1; L !== R && c[L] <= D; ++L)
      A += l;
    --L;
    var P = (D - c[L]) / (c[L + 1] - c[L]), I = A + P * l, k = y(I, t, r);
    return k >= i ? b(D, I) : k === 0 ? I : E(D, A, A + l);
  }
  var S = !1;
  function w() {
    S = !0, (t !== e || r !== a) && m();
  }
  var x = function(A) {
    return S || w(), t === e && r === a ? A : A === 0 ? 0 : A === 1 ? 1 : p(C(A), e, a);
  };
  x.getControlPoints = function() {
    return [{
      x: t,
      y: e
    }, {
      x: r,
      y: a
    }];
  };
  var T = "generateBezier(" + [t, e, r, a] + ")";
  return x.toString = function() {
    return T;
  }, x;
}
/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */
var Ap = /* @__PURE__ */ (function() {
  function t(a) {
    return -a.tension * a.x - a.friction * a.v;
  }
  function e(a, n, i) {
    var o = {
      x: a.x + i.dx * n,
      v: a.v + i.dv * n,
      tension: a.tension,
      friction: a.friction
    };
    return {
      dx: o.v,
      dv: t(o)
    };
  }
  function r(a, n) {
    var i = {
      dx: a.v,
      dv: t(a)
    }, o = e(a, n * 0.5, i), s = e(a, n * 0.5, o), u = e(a, n, s), l = 1 / 6 * (i.dx + 2 * (o.dx + s.dx) + u.dx), f = 1 / 6 * (i.dv + 2 * (o.dv + s.dv) + u.dv);
    return a.x = a.x + l * n, a.v = a.v + f * n, a;
  }
  return function a(n, i, o) {
    var s = {
      x: -1,
      v: 0,
      tension: null,
      friction: null
    }, u = [0], l = 0, f = 1 / 1e4, v = 16 / 1e3, c, h, d;
    for (n = parseFloat(n) || 500, i = parseFloat(i) || 20, o = o || null, s.tension = n, s.friction = i, c = o !== null, c ? (l = a(n, i), h = l / o * v) : h = v; d = r(d || s, h), u.push(1 + d.x), l += 16, Math.abs(d.x) > f && Math.abs(d.v) > f; )
      ;
    return c ? function(g) {
      return u[g * (u.length - 1) | 0];
    } : l;
  };
})(), _e = function(e, r, a, n) {
  var i = Sp(e, r, a, n);
  return function(o, s, u) {
    return o + (s - o) * i(u);
  };
}, cn = {
  linear: function(e, r, a) {
    return e + (r - e) * a;
  },
  // default easings
  ease: _e(0.25, 0.1, 0.25, 1),
  "ease-in": _e(0.42, 0, 1, 1),
  "ease-out": _e(0, 0, 0.58, 1),
  "ease-in-out": _e(0.42, 0, 0.58, 1),
  // sine
  "ease-in-sine": _e(0.47, 0, 0.745, 0.715),
  "ease-out-sine": _e(0.39, 0.575, 0.565, 1),
  "ease-in-out-sine": _e(0.445, 0.05, 0.55, 0.95),
  // quad
  "ease-in-quad": _e(0.55, 0.085, 0.68, 0.53),
  "ease-out-quad": _e(0.25, 0.46, 0.45, 0.94),
  "ease-in-out-quad": _e(0.455, 0.03, 0.515, 0.955),
  // cubic
  "ease-in-cubic": _e(0.55, 0.055, 0.675, 0.19),
  "ease-out-cubic": _e(0.215, 0.61, 0.355, 1),
  "ease-in-out-cubic": _e(0.645, 0.045, 0.355, 1),
  // quart
  "ease-in-quart": _e(0.895, 0.03, 0.685, 0.22),
  "ease-out-quart": _e(0.165, 0.84, 0.44, 1),
  "ease-in-out-quart": _e(0.77, 0, 0.175, 1),
  // quint
  "ease-in-quint": _e(0.755, 0.05, 0.855, 0.06),
  "ease-out-quint": _e(0.23, 1, 0.32, 1),
  "ease-in-out-quint": _e(0.86, 0, 0.07, 1),
  // expo
  "ease-in-expo": _e(0.95, 0.05, 0.795, 0.035),
  "ease-out-expo": _e(0.19, 1, 0.22, 1),
  "ease-in-out-expo": _e(1, 0, 0, 1),
  // circ
  "ease-in-circ": _e(0.6, 0.04, 0.98, 0.335),
  "ease-out-circ": _e(0.075, 0.82, 0.165, 1),
  "ease-in-out-circ": _e(0.785, 0.135, 0.15, 0.86),
  // user param easings...
  spring: function(e, r, a) {
    if (a === 0)
      return cn.linear;
    var n = Ap(e, r, a);
    return function(i, o, s) {
      return i + (o - i) * n(s);
    };
  },
  "cubic-bezier": _e
};
function Cl(t, e, r, a, n) {
  if (a === 1 || e === r)
    return r;
  var i = n(e, r, a);
  return t == null || ((t.roundValue || t.color) && (i = Math.round(i)), t.min !== void 0 && (i = Math.max(i, t.min)), t.max !== void 0 && (i = Math.min(i, t.max))), i;
}
function Dl(t, e) {
  return t.pfValue != null || t.value != null ? t.pfValue != null && (e == null || e.type.units !== "%") ? t.pfValue : t.value : t;
}
function Nr(t, e, r, a, n) {
  var i = n != null ? n.type : null;
  r < 0 ? r = 0 : r > 1 && (r = 1);
  var o = Dl(t, n), s = Dl(e, n);
  if (ne(o) && ne(s))
    return Cl(i, o, s, r, a);
  if (ze(o) && ze(s)) {
    for (var u = [], l = 0; l < s.length; l++) {
      var f = o[l], v = s[l];
      if (f != null && v != null) {
        var c = Cl(i, f, v, r, a);
        u.push(c);
      } else
        u.push(v);
    }
    return u;
  }
}
function Lp(t, e, r, a) {
  var n = !a, i = t._private, o = e._private, s = o.easing, u = o.startTime, l = a ? t : t.cy(), f = l.style();
  if (!o.easingImpl)
    if (s == null)
      o.easingImpl = cn.linear;
    else {
      var v;
      if (de(s)) {
        var c = f.parse("transition-timing-function", s);
        v = c.value;
      } else
        v = s;
      var h, d;
      de(v) ? (h = v, d = []) : (h = v[1], d = v.slice(2).map(function(F) {
        return +F;
      })), d.length > 0 ? (h === "spring" && d.push(o.duration), o.easingImpl = cn[h].apply(null, d)) : o.easingImpl = cn[h];
    }
  var g = o.easingImpl, p;
  if (o.duration === 0 ? p = 1 : p = (r - u) / o.duration, o.applying && (p = o.progress), p < 0 ? p = 0 : p > 1 && (p = 1), o.delay == null) {
    var y = o.startPosition, b = o.position;
    if (b && n && !t.locked()) {
      var m = {};
      ha(y.x, b.x) && (m.x = Nr(y.x, b.x, p, g)), ha(y.y, b.y) && (m.y = Nr(y.y, b.y, p, g)), t.position(m);
    }
    var E = o.startPan, C = o.pan, S = i.pan, w = C != null && a;
    w && (ha(E.x, C.x) && (S.x = Nr(E.x, C.x, p, g)), ha(E.y, C.y) && (S.y = Nr(E.y, C.y, p, g)), t.emit("pan"));
    var x = o.startZoom, T = o.zoom, D = T != null && a;
    D && (ha(x, T) && (i.zoom = Sa(i.minZoom, Nr(x, T, p, g), i.maxZoom)), t.emit("zoom")), (w || D) && t.emit("viewport");
    var A = o.style;
    if (A && A.length > 0 && n) {
      for (var L = 0; L < A.length; L++) {
        var R = A[L], P = R.name, I = R, k = o.startStyle[P], O = f.properties[k.name], N = Nr(k, I, p, g, O);
        f.overrideBypass(t, P, N);
      }
      t.emit("style");
    }
  }
  return o.progress = p, p;
}
function ha(t, e) {
  return t == null || e == null ? !1 : ne(t) && ne(e) ? !0 : !!(t && e);
}
function Rp(t, e, r, a) {
  var n = e._private;
  n.started = !0, n.startTime = r - n.progress * n.duration;
}
function Sl(t, e) {
  var r = e._private.aniEles, a = [];
  function n(f, v) {
    var c = f._private, h = c.animation.current, d = c.animation.queue, g = !1;
    if (h.length === 0) {
      var p = d.shift();
      p && h.push(p);
    }
    for (var y = function(S) {
      for (var w = S.length - 1; w >= 0; w--) {
        var x = S[w];
        x();
      }
      S.splice(0, S.length);
    }, b = h.length - 1; b >= 0; b--) {
      var m = h[b], E = m._private;
      if (E.stopped) {
        h.splice(b, 1), E.hooked = !1, E.playing = !1, E.started = !1, y(E.frames);
        continue;
      }
      !E.playing && !E.applying || (E.playing && E.applying && (E.applying = !1), E.started || Rp(f, m, t), Lp(f, m, t, v), E.applying && (E.applying = !1), y(E.frames), E.step != null && E.step(t), m.completed() && (h.splice(b, 1), E.hooked = !1, E.playing = !1, E.started = !1, y(E.completes)), g = !0);
    }
    return !v && h.length === 0 && d.length === 0 && a.push(f), g;
  }
  for (var i = !1, o = 0; o < r.length; o++) {
    var s = r[o], u = n(s);
    i = i || u;
  }
  var l = n(e, !0);
  (i || l) && (r.length > 0 ? e.notify("draw", r) : e.notify("draw")), r.unmerge(a), e.emit("step");
}
var Mp = {
  // pull in animation functions
  animate: Be.animate(),
  animation: Be.animation(),
  animated: Be.animated(),
  clearQueue: Be.clearQueue(),
  delay: Be.delay(),
  delayAnimation: Be.delayAnimation(),
  stop: Be.stop(),
  addToAnimationPool: function(e) {
    var r = this;
    r.styleEnabled() && r._private.aniEles.merge(e);
  },
  stopAnimationLoop: function() {
    this._private.animationsRunning = !1;
  },
  startAnimationLoop: function() {
    var e = this;
    if (e._private.animationsRunning = !0, !e.styleEnabled())
      return;
    function r() {
      e._private.animationsRunning && Tn(function(i) {
        Sl(i, e), r();
      });
    }
    var a = e.renderer();
    a && a.beforeRender ? a.beforeRender(function(i, o) {
      Sl(o, e);
    }, a.beforeRenderPriorities.animations) : r();
  }
}, Pp = {
  qualifierCompare: function(e, r) {
    return e == null || r == null ? e == null && r == null : e.sameText(r);
  },
  eventMatches: function(e, r, a) {
    var n = r.qualifier;
    return n != null ? e !== a.target && ka(a.target) && n.matches(a.target) : !0;
  },
  addEventFields: function(e, r) {
    r.cy = e, r.target = e;
  },
  callbackContext: function(e, r, a) {
    return r.qualifier != null ? a.target : e;
  }
}, rn = function(e) {
  return de(e) ? new fr(e) : e;
}, lv = {
  createEmitter: function() {
    var e = this._private;
    return e.emitter || (e.emitter = new Hn(Pp, this)), this;
  },
  emitter: function() {
    return this._private.emitter;
  },
  on: function(e, r, a) {
    return this.emitter().on(e, rn(r), a), this;
  },
  removeListener: function(e, r, a) {
    return this.emitter().removeListener(e, rn(r), a), this;
  },
  removeAllListeners: function() {
    return this.emitter().removeAllListeners(), this;
  },
  one: function(e, r, a) {
    return this.emitter().one(e, rn(r), a), this;
  },
  once: function(e, r, a) {
    return this.emitter().one(e, rn(r), a), this;
  },
  emit: function(e, r) {
    return this.emitter().emit(e, r), this;
  },
  emitAndNotify: function(e, r) {
    return this.emit(e), this.notify(e, r), this;
  }
};
Be.eventAliasesOn(lv);
var Vo = {
  png: function(e) {
    var r = this._private.renderer;
    return e = e || {}, r.png(e);
  },
  jpg: function(e) {
    var r = this._private.renderer;
    return e = e || {}, e.bg = e.bg || "#fff", r.jpg(e);
  }
};
Vo.jpeg = Vo.jpg;
var hn = {
  layout: function(e) {
    var r = this;
    if (e == null) {
      qe("Layout options must be specified to make a layout");
      return;
    }
    if (e.name == null) {
      qe("A `name` must be specified to make a layout");
      return;
    }
    var a = e.name, n = r.extension("layout", a);
    if (n == null) {
      qe("No such layout `" + a + "` found.  Did you forget to import it and `cytoscape.use()` it?");
      return;
    }
    var i;
    de(e.eles) ? i = r.$(e.eles) : i = e.eles != null ? e.eles : r.$();
    var o = new n(ye({}, e, {
      cy: r,
      eles: i
    }));
    return o;
  }
};
hn.createLayout = hn.makeLayout = hn.layout;
var Ip = {
  notify: function(e, r) {
    var a = this._private;
    if (this.batching()) {
      a.batchNotifications = a.batchNotifications || {};
      var n = a.batchNotifications[e] = a.batchNotifications[e] || this.collection();
      r != null && n.merge(r);
      return;
    }
    if (a.notificationsEnabled) {
      var i = this.renderer();
      this.destroyed() || !i || i.notify(e, r);
    }
  },
  notifications: function(e) {
    var r = this._private;
    return e === void 0 ? r.notificationsEnabled : (r.notificationsEnabled = !!e, this);
  },
  noNotifications: function(e) {
    this.notifications(!1), e(), this.notifications(!0);
  },
  batching: function() {
    return this._private.batchCount > 0;
  },
  startBatch: function() {
    var e = this._private;
    return e.batchCount == null && (e.batchCount = 0), e.batchCount === 0 && (e.batchStyleEles = this.collection(), e.batchNotifications = {}), e.batchCount++, this;
  },
  endBatch: function() {
    var e = this._private;
    if (e.batchCount === 0)
      return this;
    if (e.batchCount--, e.batchCount === 0) {
      e.batchStyleEles.updateStyle();
      var r = this.renderer();
      Object.keys(e.batchNotifications).forEach(function(a) {
        var n = e.batchNotifications[a];
        n.empty() ? r.notify(a) : r.notify(a, n);
      });
    }
    return this;
  },
  batch: function(e) {
    return this.startBatch(), e(), this.endBatch(), this;
  },
  // for backwards compatibility
  batchData: function(e) {
    var r = this;
    return this.batch(function() {
      for (var a = Object.keys(e), n = 0; n < a.length; n++) {
        var i = a[n], o = e[i], s = r.getElementById(i);
        s.data(o);
      }
    });
  }
}, Op = ft({
  hideEdgesOnViewport: !1,
  textureOnViewport: !1,
  motionBlur: !1,
  motionBlurOpacity: 0.05,
  pixelRatio: void 0,
  desktopTapThreshold: 4,
  touchTapThreshold: 8,
  wheelSensitivity: 1,
  debug: !1,
  showFps: !1,
  // webgl options
  webgl: !1,
  webglDebug: !1,
  webglDebugShowAtlases: !1,
  // defaults good for mobile
  webglTexSize: 2048,
  webglTexRows: 36,
  webglTexRowsNodes: 18,
  webglBatchSize: 2048,
  webglTexPerBatch: 14,
  webglBgColor: [255, 255, 255]
}), Uo = {
  renderTo: function(e, r, a, n) {
    var i = this._private.renderer;
    return i.renderTo(e, r, a, n), this;
  },
  renderer: function() {
    return this._private.renderer;
  },
  forceRender: function() {
    return this.notify("draw"), this;
  },
  resize: function() {
    return this.invalidateSize(), this.emitAndNotify("resize"), this;
  },
  initRenderer: function(e) {
    var r = this, a = r.extension("renderer", e.name);
    if (a == null) {
      qe("Can not initialise: No such renderer `".concat(e.name, "` found. Did you forget to import it and `cytoscape.use()` it?"));
      return;
    }
    e.wheelSensitivity !== void 0 && Fe("You have set a custom wheel sensitivity.  This will make your app zoom unnaturally when using mainstream mice.  You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");
    var n = Op(e);
    n.cy = r, r._private.renderer = new a(n), this.notify("init");
  },
  destroyRenderer: function() {
    var e = this;
    e.notify("destroy");
    var r = e.container();
    if (r)
      for (r._cyreg = null; r.childNodes.length > 0; )
        r.removeChild(r.childNodes[0]);
    e._private.renderer = null, e.mutableElements().forEach(function(a) {
      var n = a._private;
      n.rscratch = {}, n.rstyle = {}, n.animation.current = [], n.animation.queue = [];
    });
  },
  onRender: function(e) {
    return this.on("render", e);
  },
  offRender: function(e) {
    return this.off("render", e);
  }
};
Uo.invalidateDimensions = Uo.resize;
var dn = {
  // get a collection
  // - empty collection on no args
  // - collection of elements in the graph on selector arg
  // - guarantee a returned collection when elements or collection specified
  collection: function(e, r) {
    return de(e) ? this.$(e) : Ct(e) ? e.collection() : ze(e) ? (r || (r = {}), new lt(this, e, r.unique, r.removed)) : new lt(this);
  },
  nodes: function(e) {
    var r = this.$(function(a) {
      return a.isNode();
    });
    return e ? r.filter(e) : r;
  },
  edges: function(e) {
    var r = this.$(function(a) {
      return a.isEdge();
    });
    return e ? r.filter(e) : r;
  },
  // search the graph like jQuery
  $: function(e) {
    var r = this._private.elements;
    return e ? r.filter(e) : r.spawnSelf();
  },
  mutableElements: function() {
    return this._private.elements;
  }
};
dn.elements = dn.filter = dn.$;
var ot = {}, wa = "t", kp = "f";
ot.apply = function(t) {
  for (var e = this, r = e._private, a = r.cy, n = a.collection(), i = 0; i < t.length; i++) {
    var o = t[i], s = e.getContextMeta(o);
    if (!s.empty) {
      var u = e.getContextStyle(s), l = e.applyContextStyle(s, u, o);
      o._private.appliedInitStyle ? e.updateTransitions(o, l.diffProps) : o._private.appliedInitStyle = !0;
      var f = e.updateStyleHints(o);
      f && n.push(o);
    }
  }
  return n;
};
ot.getPropertiesDiff = function(t, e) {
  var r = this, a = r._private.propDiffs = r._private.propDiffs || {}, n = t + "-" + e, i = a[n];
  if (i)
    return i;
  for (var o = [], s = {}, u = 0; u < r.length; u++) {
    var l = r[u], f = t[u] === wa, v = e[u] === wa, c = f !== v, h = l.mappedProperties.length > 0;
    if (c || v && h) {
      var d = void 0;
      c && h || c ? d = l.properties : h && (d = l.mappedProperties);
      for (var g = 0; g < d.length; g++) {
        for (var p = d[g], y = p.name, b = !1, m = u + 1; m < r.length; m++) {
          var E = r[m], C = e[m] === wa;
          if (C && (b = E.properties[p.name] != null, b))
            break;
        }
        !s[y] && !b && (s[y] = !0, o.push(y));
      }
    }
  }
  return a[n] = o, o;
};
ot.getContextMeta = function(t) {
  for (var e = this, r = "", a, n = t._private.styleCxtKey || "", i = 0; i < e.length; i++) {
    var o = e[i], s = o.selector && o.selector.matches(t);
    s ? r += wa : r += kp;
  }
  return a = e.getPropertiesDiff(n, r), t._private.styleCxtKey = r, {
    key: r,
    diffPropNames: a,
    empty: a.length === 0
  };
};
ot.getContextStyle = function(t) {
  var e = t.key, r = this, a = this._private.contextStyles = this._private.contextStyles || {};
  if (a[e])
    return a[e];
  for (var n = {
    _private: {
      key: e
    }
  }, i = 0; i < r.length; i++) {
    var o = r[i], s = e[i] === wa;
    if (s)
      for (var u = 0; u < o.properties.length; u++) {
        var l = o.properties[u];
        n[l.name] = l;
      }
  }
  return a[e] = n, n;
};
ot.applyContextStyle = function(t, e, r) {
  for (var a = this, n = t.diffPropNames, i = {}, o = a.types, s = 0; s < n.length; s++) {
    var u = n[s], l = e[u], f = r.pstyle(u);
    if (!l)
      if (f)
        f.bypass ? l = {
          name: u,
          deleteBypassed: !0
        } : l = {
          name: u,
          delete: !0
        };
      else continue;
    if (f !== l) {
      if (l.mapped === o.fn && f != null && f.mapping != null && f.mapping.value === l.value) {
        var v = f.mapping, c = v.fnValue = l.value(r);
        if (c === v.prevFnValue)
          continue;
      }
      var h = i[u] = {
        prev: f
      };
      a.applyParsedProperty(r, l), h.next = r.pstyle(u), h.next && h.next.bypass && (h.next = h.next.bypassed);
    }
  }
  return {
    diffProps: i
  };
};
ot.updateStyleHints = function(t) {
  var e = t._private, r = this, a = r.propertyGroupNames, n = r.propertyGroupKeys, i = function(H, Z, re) {
    return r.getPropertiesHash(H, Z, re);
  }, o = e.styleKey;
  if (t.removed())
    return !1;
  var s = e.group === "nodes", u = t._private.style;
  a = Object.keys(u);
  for (var l = 0; l < n.length; l++) {
    var f = n[l];
    e.styleKeys[f] = [Tr, Vr];
  }
  for (var v = function(H, Z) {
    return e.styleKeys[Z][0] = Ta(H, e.styleKeys[Z][0]);
  }, c = function(H, Z) {
    return e.styleKeys[Z][1] = Ca(H, e.styleKeys[Z][1]);
  }, h = function(H, Z) {
    v(H, Z), c(H, Z);
  }, d = function(H, Z) {
    for (var re = 0; re < H.length; re++) {
      var le = H.charCodeAt(re);
      v(le, Z), c(le, Z);
    }
  }, g = 2e9, p = function(H) {
    return -128 < H && H < 128 && Math.floor(H) !== H ? g - (H * 1024 | 0) : H;
  }, y = 0; y < a.length; y++) {
    var b = a[y], m = u[b];
    if (m != null) {
      var E = this.properties[b], C = E.type, S = E.groupKey, w = void 0;
      E.hashOverride != null ? w = E.hashOverride(t, m) : m.pfValue != null && (w = m.pfValue);
      var x = E.enums == null ? m.value : null, T = w != null, D = x != null, A = T || D, L = m.units;
      if (C.number && A && !C.multiple) {
        var R = T ? w : x;
        h(p(R), S), !T && L != null && d(L, S);
      } else
        d(m.strValue, S);
    }
  }
  for (var P = [Tr, Vr], I = 0; I < n.length; I++) {
    var k = n[I], O = e.styleKeys[k];
    P[0] = Ta(O[0], P[0]), P[1] = Ca(O[1], P[1]);
  }
  e.styleKey = Kc(P[0], P[1]);
  var N = e.styleKeys;
  e.labelDimsKey = jt(N.labelDimensions);
  var F = i(t, ["label"], N.labelDimensions);
  if (e.labelKey = jt(F), e.labelStyleKey = jt($a(N.commonLabel, F)), !s) {
    var G = i(t, ["source-label"], N.labelDimensions);
    e.sourceLabelKey = jt(G), e.sourceLabelStyleKey = jt($a(N.commonLabel, G));
    var B = i(t, ["target-label"], N.labelDimensions);
    e.targetLabelKey = jt(B), e.targetLabelStyleKey = jt($a(N.commonLabel, B));
  }
  if (s) {
    var z = e.styleKeys, Y = z.nodeBody, $ = z.nodeBorder, X = z.nodeOutline, j = z.backgroundImage, ee = z.compound, ae = z.pie, K = z.stripe, V = [Y, $, X, j, ee, ae, K].filter(function(q) {
      return q != null;
    }).reduce($a, [Tr, Vr]);
    e.nodeKey = jt(V), e.hasPie = ae != null && ae[0] !== Tr && ae[1] !== Vr, e.hasStripe = K != null && K[0] !== Tr && K[1] !== Vr;
  }
  return o !== e.styleKey;
};
ot.clearStyleHints = function(t) {
  var e = t._private;
  e.styleCxtKey = "", e.styleKeys = {}, e.styleKey = null, e.labelKey = null, e.labelStyleKey = null, e.sourceLabelKey = null, e.sourceLabelStyleKey = null, e.targetLabelKey = null, e.targetLabelStyleKey = null, e.nodeKey = null, e.hasPie = null, e.hasStripe = null;
};
ot.applyParsedProperty = function(t, e) {
  var r = this, a = e, n = t._private.style, i, o = r.types, s = r.properties[a.name].type, u = a.bypass, l = n[a.name], f = l && l.bypass, v = t._private, c = "mapping", h = function(Y) {
    return Y == null ? null : Y.pfValue != null ? Y.pfValue : Y.value;
  }, d = function() {
    var Y = h(l), $ = h(a);
    r.checkTriggers(t, a.name, Y, $);
  };
  if (e.name === "curve-style" && t.isEdge() && // loops must be bundled beziers
  (e.value !== "bezier" && t.isLoop() || // edges connected to compound nodes can not be haystacks
  e.value === "haystack" && (t.source().isParent() || t.target().isParent())) && (a = e = this.parse(e.name, "bezier", u)), a.delete)
    return n[a.name] = void 0, d(), !0;
  if (a.deleteBypassed)
    return l ? l.bypass ? (l.bypassed = void 0, d(), !0) : !1 : (d(), !0);
  if (a.deleteBypass)
    return l ? l.bypass ? (n[a.name] = l.bypassed, d(), !0) : !1 : (d(), !0);
  var g = function() {
    Fe("Do not assign mappings to elements without corresponding data (i.e. ele `" + t.id() + "` has no mapping for property `" + a.name + "` with data field `" + a.field + "`); try a `[" + a.field + "]` selector to limit scope to elements with `" + a.field + "` defined");
  };
  switch (a.mapped) {
    // flatten the property if mapped
    case o.mapData: {
      for (var p = a.field.split("."), y = v.data, b = 0; b < p.length && y; b++) {
        var m = p[b];
        y = y[m];
      }
      if (y == null)
        return g(), !1;
      var E;
      if (ne(y)) {
        var C = a.fieldMax - a.fieldMin;
        C === 0 ? E = 0 : E = (y - a.fieldMin) / C;
      } else
        return Fe("Do not use continuous mappers without specifying numeric data (i.e. `" + a.field + ": " + y + "` for `" + t.id() + "` is non-numeric)"), !1;
      if (E < 0 ? E = 0 : E > 1 && (E = 1), s.color) {
        var S = a.valueMin[0], w = a.valueMax[0], x = a.valueMin[1], T = a.valueMax[1], D = a.valueMin[2], A = a.valueMax[2], L = a.valueMin[3] == null ? 1 : a.valueMin[3], R = a.valueMax[3] == null ? 1 : a.valueMax[3], P = [Math.round(S + (w - S) * E), Math.round(x + (T - x) * E), Math.round(D + (A - D) * E), Math.round(L + (R - L) * E)];
        i = {
          // colours are simple, so just create the flat property instead of expensive string parsing
          bypass: a.bypass,
          // we're a bypass if the mapping property is a bypass
          name: a.name,
          value: P,
          strValue: "rgb(" + P[0] + ", " + P[1] + ", " + P[2] + ")"
        };
      } else if (s.number) {
        var I = a.valueMin + (a.valueMax - a.valueMin) * E;
        i = this.parse(a.name, I, a.bypass, c);
      } else
        return !1;
      if (!i)
        return g(), !1;
      i.mapping = a, a = i;
      break;
    }
    // direct mapping
    case o.data: {
      for (var k = a.field.split("."), O = v.data, N = 0; N < k.length && O; N++) {
        var F = k[N];
        O = O[F];
      }
      if (O != null && (i = this.parse(a.name, O, a.bypass, c)), !i)
        return g(), !1;
      i.mapping = a, a = i;
      break;
    }
    case o.fn: {
      var G = a.value, B = a.fnValue != null ? a.fnValue : G(t);
      if (a.prevFnValue = B, B == null)
        return Fe("Custom function mappers may not return null (i.e. `" + a.name + "` for ele `" + t.id() + "` is null)"), !1;
      if (i = this.parse(a.name, B, a.bypass, c), !i)
        return Fe("Custom function mappers may not return invalid values for the property type (i.e. `" + a.name + "` for ele `" + t.id() + "` is invalid)"), !1;
      i.mapping = Vt(a), a = i;
      break;
    }
    case void 0:
      break;
    // just set the property
    default:
      return !1;
  }
  return u ? (f ? a.bypassed = l.bypassed : a.bypassed = l, n[a.name] = a) : f ? l.bypassed = a : n[a.name] = a, d(), !0;
};
ot.cleanElements = function(t, e) {
  for (var r = 0; r < t.length; r++) {
    var a = t[r];
    if (this.clearStyleHints(a), a.dirtyCompoundBoundsCache(), a.dirtyBoundingBoxCache(), !e)
      a._private.style = {};
    else
      for (var n = a._private.style, i = Object.keys(n), o = 0; o < i.length; o++) {
        var s = i[o], u = n[s];
        u != null && (u.bypass ? u.bypassed = null : n[s] = null);
      }
  }
};
ot.update = function() {
  var t = this._private.cy, e = t.mutableElements();
  e.updateStyle();
};
ot.updateTransitions = function(t, e) {
  var r = this, a = t._private, n = t.pstyle("transition-property").value, i = t.pstyle("transition-duration").pfValue, o = t.pstyle("transition-delay").pfValue;
  if (n.length > 0 && i > 0) {
    for (var s = {}, u = !1, l = 0; l < n.length; l++) {
      var f = n[l], v = t.pstyle(f), c = e[f];
      if (c) {
        var h = c.prev, d = h, g = c.next != null ? c.next : v, p = !1, y = void 0, b = 1e-6;
        d && (ne(d.pfValue) && ne(g.pfValue) ? (p = g.pfValue - d.pfValue, y = d.pfValue + b * p) : ne(d.value) && ne(g.value) ? (p = g.value - d.value, y = d.value + b * p) : ze(d.value) && ze(g.value) && (p = d.value[0] !== g.value[0] || d.value[1] !== g.value[1] || d.value[2] !== g.value[2], y = d.strValue), p && (s[f] = g.strValue, this.applyBypass(t, f, y), u = !0));
      }
    }
    if (!u)
      return;
    a.transitioning = !0, new ra(function(m) {
      o > 0 ? t.delayAnimation(o).play().promise().then(m) : m();
    }).then(function() {
      return t.animation({
        style: s,
        duration: i,
        easing: t.pstyle("transition-timing-function").value,
        queue: !1
      }).play().promise();
    }).then(function() {
      r.removeBypasses(t, n), t.emitAndNotify("style"), a.transitioning = !1;
    });
  } else a.transitioning && (this.removeBypasses(t, n), t.emitAndNotify("style"), a.transitioning = !1);
};
ot.checkTrigger = function(t, e, r, a, n, i) {
  var o = this.properties[e], s = n(o);
  t.removed() || s != null && s(r, a, t) && i(o);
};
ot.checkZOrderTrigger = function(t, e, r, a) {
  var n = this;
  this.checkTrigger(t, e, r, a, function(i) {
    return i.triggersZOrder;
  }, function() {
    n._private.cy.notify("zorder", t);
  });
};
ot.checkBoundsTrigger = function(t, e, r, a) {
  this.checkTrigger(t, e, r, a, function(n) {
    return n.triggersBounds;
  }, function(n) {
    t.dirtyCompoundBoundsCache(), t.dirtyBoundingBoxCache();
  });
};
ot.checkConnectedEdgesBoundsTrigger = function(t, e, r, a) {
  this.checkTrigger(t, e, r, a, function(n) {
    return n.triggersBoundsOfConnectedEdges;
  }, function(n) {
    t.connectedEdges().forEach(function(i) {
      i.dirtyBoundingBoxCache();
    });
  });
};
ot.checkParallelEdgesBoundsTrigger = function(t, e, r, a) {
  this.checkTrigger(t, e, r, a, function(n) {
    return n.triggersBoundsOfParallelEdges;
  }, function(n) {
    t.parallelEdges().forEach(function(i) {
      i.dirtyBoundingBoxCache();
    });
  });
};
ot.checkTriggers = function(t, e, r, a) {
  t.dirtyStyleCache(), this.checkZOrderTrigger(t, e, r, a), this.checkBoundsTrigger(t, e, r, a), this.checkConnectedEdgesBoundsTrigger(t, e, r, a), this.checkParallelEdgesBoundsTrigger(t, e, r, a);
};
var Va = {};
Va.applyBypass = function(t, e, r, a) {
  var n = this, i = [], o = !0;
  if (e === "*" || e === "**") {
    if (r !== void 0)
      for (var s = 0; s < n.properties.length; s++) {
        var u = n.properties[s], l = u.name, f = this.parse(l, r, !0);
        f && i.push(f);
      }
  } else if (de(e)) {
    var v = this.parse(e, r, !0);
    v && i.push(v);
  } else if (Ie(e)) {
    var c = e;
    a = r;
    for (var h = Object.keys(c), d = 0; d < h.length; d++) {
      var g = h[d], p = c[g];
      if (p === void 0 && (p = c[Nn(g)]), p !== void 0) {
        var y = this.parse(g, p, !0);
        y && i.push(y);
      }
    }
  } else
    return !1;
  if (i.length === 0)
    return !1;
  for (var b = !1, m = 0; m < t.length; m++) {
    for (var E = t[m], C = {}, S = void 0, w = 0; w < i.length; w++) {
      var x = i[w];
      if (a) {
        var T = E.pstyle(x.name);
        S = C[x.name] = {
          prev: T
        };
      }
      b = this.applyParsedProperty(E, Vt(x)) || b, a && (S.next = E.pstyle(x.name));
    }
    b && this.updateStyleHints(E), a && this.updateTransitions(E, C, o);
  }
  return b;
};
Va.overrideBypass = function(t, e, r) {
  e = es(e);
  for (var a = 0; a < t.length; a++) {
    var n = t[a], i = n._private.style[e], o = this.properties[e].type, s = o.color, u = o.mutiple, l = i ? i.pfValue != null ? i.pfValue : i.value : null;
    !i || !i.bypass ? this.applyBypass(n, e, r) : (i.value = r, i.pfValue != null && (i.pfValue = r), s ? i.strValue = "rgb(" + r.join(",") + ")" : u ? i.strValue = r.join(" ") : i.strValue = "" + r, this.updateStyleHints(n)), this.checkTriggers(n, e, l, r);
  }
};
Va.removeAllBypasses = function(t, e) {
  return this.removeBypasses(t, this.propertyNames, e);
};
Va.removeBypasses = function(t, e, r) {
  for (var a = !0, n = 0; n < t.length; n++) {
    for (var i = t[n], o = {}, s = 0; s < e.length; s++) {
      var u = e[s], l = this.properties[u], f = i.pstyle(l.name);
      if (!(!f || !f.bypass)) {
        var v = "", c = this.parse(u, v, !0), h = o[l.name] = {
          prev: f
        };
        this.applyParsedProperty(i, c), h.next = i.pstyle(l.name);
      }
    }
    this.updateStyleHints(i), r && this.updateTransitions(i, o, a);
  }
};
var gs = {};
gs.getEmSizeInPixels = function() {
  var t = this.containerCss("font-size");
  return t != null ? parseFloat(t) : 1;
};
gs.containerCss = function(t) {
  var e = this._private.cy, r = e.container(), a = e.window();
  if (a && r && a.getComputedStyle)
    return a.getComputedStyle(r).getPropertyValue(t);
};
var Ut = {};
Ut.getRenderedStyle = function(t, e) {
  return e ? this.getStylePropertyValue(t, e, !0) : this.getRawStyle(t, !0);
};
Ut.getRawStyle = function(t, e) {
  var r = this;
  if (t = t[0], t) {
    for (var a = {}, n = 0; n < r.properties.length; n++) {
      var i = r.properties[n], o = r.getStylePropertyValue(t, i.name, e);
      o != null && (a[i.name] = o, a[Nn(i.name)] = o);
    }
    return a;
  }
};
Ut.getIndexedStyle = function(t, e, r, a) {
  var n = t.pstyle(e)[r][a];
  return n ?? t.cy().style().getDefaultProperty(e)[r][0];
};
Ut.getStylePropertyValue = function(t, e, r) {
  var a = this;
  if (t = t[0], t) {
    var n = a.properties[e];
    n.alias && (n = n.pointsTo);
    var i = n.type, o = t.pstyle(n.name);
    if (o) {
      var s = o.value, u = o.units, l = o.strValue;
      if (r && i.number && s != null && ne(s)) {
        var f = t.cy().zoom(), v = function(p) {
          return p * f;
        }, c = function(p, y) {
          return v(p) + y;
        }, h = ze(s), d = h ? u.every(function(g) {
          return g != null;
        }) : u != null;
        return d ? h ? s.map(function(g, p) {
          return c(g, u[p]);
        }).join(" ") : c(s, u) : h ? s.map(function(g) {
          return de(g) ? g : "" + v(g);
        }).join(" ") : "" + v(s);
      } else if (l != null)
        return l;
    }
    return null;
  }
};
Ut.getAnimationStartStyle = function(t, e) {
  for (var r = {}, a = 0; a < e.length; a++) {
    var n = e[a], i = n.name, o = t.pstyle(i);
    o !== void 0 && (Ie(o) ? o = this.parse(i, o.strValue) : o = this.parse(i, o)), o && (r[i] = o);
  }
  return r;
};
Ut.getPropsList = function(t) {
  var e = this, r = [], a = t, n = e.properties;
  if (a)
    for (var i = Object.keys(a), o = 0; o < i.length; o++) {
      var s = i[o], u = a[s], l = n[s] || n[es(s)], f = this.parse(l.name, u);
      f && r.push(f);
    }
  return r;
};
Ut.getNonDefaultPropertiesHash = function(t, e, r) {
  var a = r.slice(), n, i, o, s, u, l;
  for (u = 0; u < e.length; u++)
    if (n = e[u], i = t.pstyle(n, !1), i != null)
      if (i.pfValue != null)
        a[0] = Ta(s, a[0]), a[1] = Ca(s, a[1]);
      else
        for (o = i.strValue, l = 0; l < o.length; l++)
          s = o.charCodeAt(l), a[0] = Ta(s, a[0]), a[1] = Ca(s, a[1]);
  return a;
};
Ut.getPropertiesHash = Ut.getNonDefaultPropertiesHash;
var $n = {};
$n.appendFromJson = function(t) {
  for (var e = this, r = 0; r < t.length; r++) {
    var a = t[r], n = a.selector, i = a.style || a.css, o = Object.keys(i);
    e.selector(n);
    for (var s = 0; s < o.length; s++) {
      var u = o[s], l = i[u];
      e.css(u, l);
    }
  }
  return e;
};
$n.fromJson = function(t) {
  var e = this;
  return e.resetToDefault(), e.appendFromJson(t), e;
};
$n.json = function() {
  for (var t = [], e = this.defaultLength; e < this.length; e++) {
    for (var r = this[e], a = r.selector, n = r.properties, i = {}, o = 0; o < n.length; o++) {
      var s = n[o];
      i[s.name] = s.strValue;
    }
    t.push({
      selector: a ? a.toString() : "core",
      style: i
    });
  }
  return t;
};
var ps = {};
ps.appendFromString = function(t) {
  var e = this, r = this, a = "" + t, n, i, o;
  a = a.replace(/[/][*](\s|.)+?[*][/]/g, "");
  function s() {
    a.length > n.length ? a = a.substr(n.length) : a = "";
  }
  function u() {
    i.length > o.length ? i = i.substr(o.length) : i = "";
  }
  for (; ; ) {
    var l = a.match(/^\s*$/);
    if (l)
      break;
    var f = a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);
    if (!f) {
      Fe("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: " + a);
      break;
    }
    n = f[0];
    var v = f[1];
    if (v !== "core") {
      var c = new fr(v);
      if (c.invalid) {
        Fe("Skipping parsing of block: Invalid selector found in string stylesheet: " + v), s();
        continue;
      }
    }
    var h = f[2], d = !1;
    i = h;
    for (var g = []; ; ) {
      var p = i.match(/^\s*$/);
      if (p)
        break;
      var y = i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);
      if (!y) {
        Fe("Skipping parsing of block: Invalid formatting of style property and value definitions found in:" + h), d = !0;
        break;
      }
      o = y[0];
      var b = y[1], m = y[2], E = e.properties[b];
      if (!E) {
        Fe("Skipping property: Invalid property name in: " + o), u();
        continue;
      }
      var C = r.parse(b, m);
      if (!C) {
        Fe("Skipping property: Invalid property definition in: " + o), u();
        continue;
      }
      g.push({
        name: b,
        val: m
      }), u();
    }
    if (d) {
      s();
      break;
    }
    r.selector(v);
    for (var S = 0; S < g.length; S++) {
      var w = g[S];
      r.css(w.name, w.val);
    }
    s();
  }
  return r;
};
ps.fromString = function(t) {
  var e = this;
  return e.resetToDefault(), e.appendFromString(t), e;
};
var Ze = {};
(function() {
  var t = et, e = Ac, r = Rc, a = Mc, n = Pc, i = function(q) {
    return "^" + q + "\\s*\\(\\s*([\\w\\.]+)\\s*\\)$";
  }, o = function(q) {
    var H = t + "|\\w+|" + e + "|" + r + "|" + a + "|" + n;
    return "^" + q + "\\s*\\(([\\w\\.]+)\\s*\\,\\s*(" + t + ")\\s*\\,\\s*(" + t + ")\\s*,\\s*(" + H + ")\\s*\\,\\s*(" + H + ")\\)$";
  }, s = [`^url\\s*\\(\\s*['"]?(.+?)['"]?\\s*\\)$`, "^(none)$", "^(.+)$"];
  Ze.types = {
    time: {
      number: !0,
      min: 0,
      units: "s|ms",
      implicitUnits: "ms"
    },
    percent: {
      number: !0,
      min: 0,
      max: 100,
      units: "%",
      implicitUnits: "%"
    },
    percentages: {
      number: !0,
      min: 0,
      max: 100,
      units: "%",
      implicitUnits: "%",
      multiple: !0
    },
    zeroOneNumber: {
      number: !0,
      min: 0,
      max: 1,
      unitless: !0
    },
    zeroOneNumbers: {
      number: !0,
      min: 0,
      max: 1,
      unitless: !0,
      multiple: !0
    },
    nOneOneNumber: {
      number: !0,
      min: -1,
      max: 1,
      unitless: !0
    },
    nonNegativeInt: {
      number: !0,
      min: 0,
      integer: !0,
      unitless: !0
    },
    nonNegativeNumber: {
      number: !0,
      min: 0,
      unitless: !0
    },
    position: {
      enums: ["parent", "origin"]
    },
    nodeSize: {
      number: !0,
      min: 0,
      enums: ["label"]
    },
    number: {
      number: !0,
      unitless: !0
    },
    numbers: {
      number: !0,
      unitless: !0,
      multiple: !0
    },
    positiveNumber: {
      number: !0,
      unitless: !0,
      min: 0,
      strictMin: !0
    },
    size: {
      number: !0,
      min: 0
    },
    bidirectionalSize: {
      number: !0
    },
    // allows negative
    bidirectionalSizeMaybePercent: {
      number: !0,
      allowPercent: !0
    },
    // allows negative
    bidirectionalSizes: {
      number: !0,
      multiple: !0
    },
    // allows negative
    sizeMaybePercent: {
      number: !0,
      min: 0,
      allowPercent: !0
    },
    axisDirection: {
      enums: ["horizontal", "leftward", "rightward", "vertical", "upward", "downward", "auto"]
    },
    axisDirectionExplicit: {
      enums: ["leftward", "rightward", "upward", "downward"]
    },
    axisDirectionPrimary: {
      enums: ["horizontal", "vertical"]
    },
    paddingRelativeTo: {
      enums: ["width", "height", "average", "min", "max"]
    },
    bgWH: {
      number: !0,
      min: 0,
      allowPercent: !0,
      enums: ["auto"],
      multiple: !0
    },
    bgPos: {
      number: !0,
      allowPercent: !0,
      multiple: !0
    },
    bgRelativeTo: {
      enums: ["inner", "include-padding"],
      multiple: !0
    },
    bgRepeat: {
      enums: ["repeat", "repeat-x", "repeat-y", "no-repeat"],
      multiple: !0
    },
    bgFit: {
      enums: ["none", "contain", "cover"],
      multiple: !0
    },
    bgCrossOrigin: {
      enums: ["anonymous", "use-credentials", "null"],
      multiple: !0
    },
    bgClip: {
      enums: ["none", "node"],
      multiple: !0
    },
    bgContainment: {
      enums: ["inside", "over"],
      multiple: !0
    },
    boxSelection: {
      enums: ["contain", "overlap", "none"]
    },
    color: {
      color: !0
    },
    colors: {
      color: !0,
      multiple: !0
    },
    fill: {
      enums: ["solid", "linear-gradient", "radial-gradient"]
    },
    bool: {
      enums: ["yes", "no"]
    },
    bools: {
      enums: ["yes", "no"],
      multiple: !0
    },
    lineStyle: {
      enums: ["solid", "dotted", "dashed"]
    },
    lineCap: {
      enums: ["butt", "round", "square"]
    },
    linePosition: {
      enums: ["center", "inside", "outside"]
    },
    lineJoin: {
      enums: ["round", "bevel", "miter"]
    },
    borderStyle: {
      enums: ["solid", "dotted", "dashed", "double"]
    },
    curveStyle: {
      enums: ["bezier", "unbundled-bezier", "haystack", "segments", "straight", "straight-triangle", "taxi", "round-segments", "round-taxi"]
    },
    radiusType: {
      enums: ["arc-radius", "influence-radius"],
      multiple: !0
    },
    fontFamily: {
      regex: '^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'
    },
    fontStyle: {
      enums: ["italic", "normal", "oblique"]
    },
    fontWeight: {
      enums: ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "800", "900", 100, 200, 300, 400, 500, 600, 700, 800, 900]
    },
    textDecoration: {
      enums: ["none", "underline", "overline", "line-through"]
    },
    textTransform: {
      enums: ["none", "uppercase", "lowercase"]
    },
    textWrap: {
      enums: ["none", "wrap", "ellipsis"]
    },
    textOverflowWrap: {
      enums: ["whitespace", "anywhere"]
    },
    textBackgroundShape: {
      enums: ["rectangle", "roundrectangle", "round-rectangle", "circle"]
    },
    nodeShape: {
      enums: ["rectangle", "roundrectangle", "round-rectangle", "cutrectangle", "cut-rectangle", "bottomroundrectangle", "bottom-round-rectangle", "barrel", "ellipse", "triangle", "round-triangle", "square", "pentagon", "round-pentagon", "hexagon", "round-hexagon", "concavehexagon", "concave-hexagon", "heptagon", "round-heptagon", "octagon", "round-octagon", "tag", "round-tag", "star", "diamond", "round-diamond", "vee", "rhomboid", "right-rhomboid", "polygon"]
    },
    overlayShape: {
      enums: ["roundrectangle", "round-rectangle", "ellipse"]
    },
    cornerRadius: {
      number: !0,
      min: 0,
      units: "px|em",
      implicitUnits: "px",
      enums: ["auto"]
    },
    compoundIncludeLabels: {
      enums: ["include", "exclude"]
    },
    arrowShape: {
      enums: ["tee", "triangle", "triangle-tee", "circle-triangle", "triangle-cross", "triangle-backcurve", "vee", "square", "circle", "diamond", "chevron", "none"]
    },
    arrowFill: {
      enums: ["filled", "hollow"]
    },
    arrowWidth: {
      number: !0,
      units: "%|px|em",
      implicitUnits: "px",
      enums: ["match-line"]
    },
    display: {
      enums: ["element", "none"]
    },
    visibility: {
      enums: ["hidden", "visible"]
    },
    zCompoundDepth: {
      enums: ["bottom", "orphan", "auto", "top"]
    },
    zIndexCompare: {
      enums: ["auto", "manual"]
    },
    valign: {
      enums: ["top", "top-inside", "center", "bottom", "bottom-inside"]
    },
    halign: {
      enums: ["left", "left-inside", "center", "right", "right-inside"]
    },
    justification: {
      enums: ["left", "center", "right", "auto"]
    },
    textMetrics: {
      enums: ["font", "glyph"]
    },
    text: {
      string: !0
    },
    data: {
      mapping: !0,
      regex: i("data")
    },
    layoutData: {
      mapping: !0,
      regex: i("layoutData")
    },
    scratch: {
      mapping: !0,
      regex: i("scratch")
    },
    mapData: {
      mapping: !0,
      regex: o("mapData")
    },
    mapLayoutData: {
      mapping: !0,
      regex: o("mapLayoutData")
    },
    mapScratch: {
      mapping: !0,
      regex: o("mapScratch")
    },
    fn: {
      mapping: !0,
      fn: !0
    },
    url: {
      regexes: s,
      singleRegexMatchValue: !0
    },
    urls: {
      regexes: s,
      singleRegexMatchValue: !0,
      multiple: !0
    },
    propList: {
      propList: !0
    },
    angle: {
      number: !0,
      units: "deg|rad",
      implicitUnits: "rad"
    },
    textRotation: {
      number: !0,
      units: "deg|rad",
      implicitUnits: "rad",
      enums: ["none", "autorotate"]
    },
    polygonPointList: {
      number: !0,
      multiple: !0,
      evenMultiple: !0,
      min: -1,
      max: 1,
      unitless: !0
    },
    edgeDistances: {
      enums: ["intersection", "node-position", "endpoints"]
    },
    edgeEndpoint: {
      number: !0,
      multiple: !0,
      units: "%|px|em|deg|rad",
      implicitUnits: "px",
      enums: ["inside-to-node", "outside-to-node", "outside-to-node-or-label", "outside-to-line", "outside-to-line-or-label"],
      singleEnum: !0,
      validate: function(q, H) {
        switch (q.length) {
          case 2:
            return H[0] !== "deg" && H[0] !== "rad" && H[1] !== "deg" && H[1] !== "rad";
          case 1:
            return de(q[0]) || H[0] === "deg" || H[0] === "rad";
          default:
            return !1;
        }
      }
    },
    easing: {
      regexes: ["^(spring)\\s*\\(\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*\\)$", "^(cubic-bezier)\\s*\\(\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*\\)$"],
      enums: ["linear", "ease", "ease-in", "ease-out", "ease-in-out", "ease-in-sine", "ease-out-sine", "ease-in-out-sine", "ease-in-quad", "ease-out-quad", "ease-in-out-quad", "ease-in-cubic", "ease-out-cubic", "ease-in-out-cubic", "ease-in-quart", "ease-out-quart", "ease-in-out-quart", "ease-in-quint", "ease-out-quint", "ease-in-out-quint", "ease-in-expo", "ease-out-expo", "ease-in-out-expo", "ease-in-circ", "ease-out-circ", "ease-in-out-circ"]
    },
    gradientDirection: {
      enums: [
        "to-bottom",
        "to-top",
        "to-left",
        "to-right",
        "to-bottom-right",
        "to-bottom-left",
        "to-top-right",
        "to-top-left",
        "to-right-bottom",
        "to-left-bottom",
        "to-right-top",
        "to-left-top"
        // different order
      ]
    },
    boundsExpansion: {
      number: !0,
      multiple: !0,
      min: 0,
      validate: function(q) {
        var H = q.length;
        return H === 1 || H === 2 || H === 4;
      }
    }
  };
  var u = {
    zeroNonZero: function(q, H) {
      return (q == null || H == null) && q !== H || q == 0 && H != 0 ? !0 : q != 0 && H == 0;
    },
    any: function(q, H) {
      return q != H;
    },
    emptyNonEmpty: function(q, H) {
      var Z = sr(q), re = sr(H);
      return Z && !re || !Z && re;
    }
  }, l = Ze.types, f = [{
    name: "label",
    type: l.text,
    triggersBounds: u.any,
    triggersZOrder: u.emptyNonEmpty
  }, {
    name: "text-rotation",
    type: l.textRotation,
    triggersBounds: u.any
  }, {
    name: "text-margin-x",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "text-margin-y",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }], v = [{
    name: "source-label",
    type: l.text,
    triggersBounds: u.any
  }, {
    name: "source-text-rotation",
    type: l.textRotation,
    triggersBounds: u.any
  }, {
    name: "source-text-margin-x",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "source-text-margin-y",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "source-text-offset",
    type: l.size,
    triggersBounds: u.any
  }], c = [{
    name: "target-label",
    type: l.text,
    triggersBounds: u.any
  }, {
    name: "target-text-rotation",
    type: l.textRotation,
    triggersBounds: u.any
  }, {
    name: "target-text-margin-x",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "target-text-margin-y",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "target-text-offset",
    type: l.size,
    triggersBounds: u.any
  }], h = [{
    name: "font-family",
    type: l.fontFamily,
    triggersBounds: u.any
  }, {
    name: "font-style",
    type: l.fontStyle,
    triggersBounds: u.any
  }, {
    name: "font-weight",
    type: l.fontWeight,
    triggersBounds: u.any
  }, {
    name: "font-size",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "text-transform",
    type: l.textTransform,
    triggersBounds: u.any
  }, {
    name: "text-wrap",
    type: l.textWrap,
    triggersBounds: u.any
  }, {
    name: "text-overflow-wrap",
    type: l.textOverflowWrap,
    triggersBounds: u.any
  }, {
    name: "text-max-width",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "text-outline-width",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "line-height",
    type: l.positiveNumber,
    triggersBounds: u.any
  }], d = [{
    name: "text-valign",
    type: l.valign,
    triggersBounds: u.any
  }, {
    name: "text-halign",
    type: l.halign,
    triggersBounds: u.any
  }, {
    name: "color",
    type: l.color
  }, {
    name: "text-outline-color",
    type: l.color
  }, {
    name: "text-outline-opacity",
    type: l.zeroOneNumber
  }, {
    name: "text-background-color",
    type: l.color
  }, {
    name: "text-background-opacity",
    type: l.zeroOneNumber
  }, {
    name: "text-background-padding",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "text-border-opacity",
    type: l.zeroOneNumber
  }, {
    name: "text-border-color",
    type: l.color
  }, {
    name: "text-border-width",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "text-border-style",
    type: l.borderStyle,
    triggersBounds: u.any
  }, {
    name: "text-background-shape",
    type: l.textBackgroundShape,
    triggersBounds: u.any
  }, {
    name: "text-justification",
    type: l.justification
  }, {
    name: "text-metrics",
    type: l.textMetrics
  }, {
    name: "box-select-labels",
    type: l.bool,
    triggersBounds: u.any
  }], g = [{
    name: "events",
    type: l.bool,
    triggersZOrder: u.any
  }, {
    name: "text-events",
    type: l.bool,
    triggersZOrder: u.any
  }, {
    name: "box-selection",
    type: l.boxSelection,
    triggersZOrder: u.any
  }], p = [{
    name: "display",
    type: l.display,
    triggersZOrder: u.any,
    triggersBounds: u.any,
    triggersBoundsOfConnectedEdges: u.any,
    triggersBoundsOfParallelEdges: function(q, H, Z) {
      return q === H ? !1 : Z.pstyle("curve-style").value === "bezier";
    }
  }, {
    name: "visibility",
    type: l.visibility,
    triggersZOrder: u.any
  }, {
    name: "opacity",
    type: l.zeroOneNumber,
    triggersZOrder: u.zeroNonZero
  }, {
    name: "text-opacity",
    type: l.zeroOneNumber
  }, {
    name: "min-zoomed-font-size",
    type: l.size
  }, {
    name: "z-compound-depth",
    type: l.zCompoundDepth,
    triggersZOrder: u.any
  }, {
    name: "z-index-compare",
    type: l.zIndexCompare,
    triggersZOrder: u.any
  }, {
    name: "z-index",
    type: l.number,
    triggersZOrder: u.any
  }], y = [{
    name: "overlay-padding",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "overlay-color",
    type: l.color
  }, {
    name: "overlay-opacity",
    type: l.zeroOneNumber,
    triggersBounds: u.zeroNonZero
  }, {
    name: "overlay-shape",
    type: l.overlayShape,
    triggersBounds: u.any
  }, {
    name: "overlay-corner-radius",
    type: l.cornerRadius
  }], b = [{
    name: "underlay-padding",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "underlay-color",
    type: l.color
  }, {
    name: "underlay-opacity",
    type: l.zeroOneNumber,
    triggersBounds: u.zeroNonZero
  }, {
    name: "underlay-shape",
    type: l.overlayShape,
    triggersBounds: u.any
  }, {
    name: "underlay-corner-radius",
    type: l.cornerRadius
  }], m = [{
    name: "transition-property",
    type: l.propList
  }, {
    name: "transition-duration",
    type: l.time
  }, {
    name: "transition-delay",
    type: l.time
  }, {
    name: "transition-timing-function",
    type: l.easing
  }], E = function(q, H) {
    return H.value === "label" ? -q.poolIndex() : H.pfValue;
  }, C = [{
    name: "height",
    type: l.nodeSize,
    triggersBounds: u.any,
    hashOverride: E
  }, {
    name: "width",
    type: l.nodeSize,
    triggersBounds: u.any,
    hashOverride: E
  }, {
    name: "shape",
    type: l.nodeShape,
    triggersBounds: u.any
  }, {
    name: "shape-polygon-points",
    type: l.polygonPointList,
    triggersBounds: u.any
  }, {
    name: "corner-radius",
    type: l.cornerRadius
  }, {
    name: "background-color",
    type: l.color
  }, {
    name: "background-fill",
    type: l.fill
  }, {
    name: "background-opacity",
    type: l.zeroOneNumber
  }, {
    name: "background-blacken",
    type: l.nOneOneNumber
  }, {
    name: "background-gradient-stop-colors",
    type: l.colors
  }, {
    name: "background-gradient-stop-positions",
    type: l.percentages
  }, {
    name: "background-gradient-direction",
    type: l.gradientDirection
  }, {
    name: "padding",
    type: l.sizeMaybePercent,
    triggersBounds: u.any
  }, {
    name: "padding-relative-to",
    type: l.paddingRelativeTo,
    triggersBounds: u.any
  }, {
    name: "bounds-expansion",
    type: l.boundsExpansion,
    triggersBounds: u.any
  }], S = [{
    name: "border-color",
    type: l.color
  }, {
    name: "border-opacity",
    type: l.zeroOneNumber
  }, {
    name: "border-width",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "border-style",
    type: l.borderStyle
  }, {
    name: "border-cap",
    type: l.lineCap
  }, {
    name: "border-join",
    type: l.lineJoin
  }, {
    name: "border-dash-pattern",
    type: l.numbers
  }, {
    name: "border-dash-offset",
    type: l.number
  }, {
    name: "border-position",
    type: l.linePosition
  }], w = [{
    name: "outline-color",
    type: l.color
  }, {
    name: "outline-opacity",
    type: l.zeroOneNumber
  }, {
    name: "outline-width",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "outline-style",
    type: l.borderStyle
  }, {
    name: "outline-offset",
    type: l.size,
    triggersBounds: u.any
  }], x = [{
    name: "background-image",
    type: l.urls
  }, {
    name: "background-image-crossorigin",
    type: l.bgCrossOrigin
  }, {
    name: "background-image-opacity",
    type: l.zeroOneNumbers
  }, {
    name: "background-image-containment",
    type: l.bgContainment
  }, {
    name: "background-image-smoothing",
    type: l.bools
  }, {
    name: "background-position-x",
    type: l.bgPos
  }, {
    name: "background-position-y",
    type: l.bgPos
  }, {
    name: "background-width-relative-to",
    type: l.bgRelativeTo
  }, {
    name: "background-height-relative-to",
    type: l.bgRelativeTo
  }, {
    name: "background-repeat",
    type: l.bgRepeat
  }, {
    name: "background-fit",
    type: l.bgFit
  }, {
    name: "background-clip",
    type: l.bgClip
  }, {
    name: "background-width",
    type: l.bgWH
  }, {
    name: "background-height",
    type: l.bgWH
  }, {
    name: "background-offset-x",
    type: l.bgPos
  }, {
    name: "background-offset-y",
    type: l.bgPos
  }], T = [{
    name: "position",
    type: l.position,
    triggersBounds: u.any
  }, {
    name: "compound-sizing-wrt-labels",
    type: l.compoundIncludeLabels,
    triggersBounds: u.any
  }, {
    name: "min-width",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "min-width-bias-left",
    type: l.sizeMaybePercent,
    triggersBounds: u.any
  }, {
    name: "min-width-bias-right",
    type: l.sizeMaybePercent,
    triggersBounds: u.any
  }, {
    name: "min-height",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "min-height-bias-top",
    type: l.sizeMaybePercent,
    triggersBounds: u.any
  }, {
    name: "min-height-bias-bottom",
    type: l.sizeMaybePercent,
    triggersBounds: u.any
  }], D = [{
    name: "line-style",
    type: l.lineStyle
  }, {
    name: "line-color",
    type: l.color
  }, {
    name: "line-fill",
    type: l.fill
  }, {
    name: "line-cap",
    type: l.lineCap
  }, {
    name: "line-opacity",
    type: l.zeroOneNumber
  }, {
    name: "line-dash-pattern",
    type: l.numbers
  }, {
    name: "line-dash-offset",
    type: l.number
  }, {
    name: "line-outline-width",
    type: l.size
  }, {
    name: "line-outline-color",
    type: l.color
  }, {
    name: "line-gradient-stop-colors",
    type: l.colors
  }, {
    name: "line-gradient-stop-positions",
    type: l.percentages
  }, {
    name: "curve-style",
    type: l.curveStyle,
    triggersBounds: u.any,
    triggersBoundsOfParallelEdges: function(q, H) {
      return q === H ? !1 : q === "bezier" || // remove from bundle
      H === "bezier";
    }
  }, {
    name: "haystack-radius",
    type: l.zeroOneNumber,
    triggersBounds: u.any
  }, {
    name: "source-endpoint",
    type: l.edgeEndpoint,
    triggersBounds: u.any
  }, {
    name: "target-endpoint",
    type: l.edgeEndpoint,
    triggersBounds: u.any
  }, {
    name: "control-point-step-size",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "control-point-distances",
    type: l.bidirectionalSizes,
    triggersBounds: u.any
  }, {
    name: "control-point-weights",
    type: l.numbers,
    triggersBounds: u.any
  }, {
    name: "segment-distances",
    type: l.bidirectionalSizes,
    triggersBounds: u.any
  }, {
    name: "segment-weights",
    type: l.numbers,
    triggersBounds: u.any
  }, {
    name: "segment-radii",
    type: l.numbers,
    triggersBounds: u.any
  }, {
    name: "radius-type",
    type: l.radiusType,
    triggersBounds: u.any
  }, {
    name: "taxi-turn",
    type: l.bidirectionalSizeMaybePercent,
    triggersBounds: u.any
  }, {
    name: "taxi-turn-min-distance",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "taxi-direction",
    type: l.axisDirection,
    triggersBounds: u.any
  }, {
    name: "taxi-radius",
    type: l.number,
    triggersBounds: u.any
  }, {
    name: "edge-distances",
    type: l.edgeDistances,
    triggersBounds: u.any
  }, {
    name: "arrow-scale",
    type: l.positiveNumber,
    triggersBounds: u.any
  }, {
    name: "loop-direction",
    type: l.angle,
    triggersBounds: u.any
  }, {
    name: "loop-sweep",
    type: l.angle,
    triggersBounds: u.any
  }, {
    name: "source-distance-from-node",
    type: l.size,
    triggersBounds: u.any
  }, {
    name: "target-distance-from-node",
    type: l.size,
    triggersBounds: u.any
  }], A = [{
    name: "ghost",
    type: l.bool,
    triggersBounds: u.any
  }, {
    name: "ghost-offset-x",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "ghost-offset-y",
    type: l.bidirectionalSize,
    triggersBounds: u.any
  }, {
    name: "ghost-opacity",
    type: l.zeroOneNumber
  }], L = [{
    name: "selection-box-color",
    type: l.color
  }, {
    name: "selection-box-opacity",
    type: l.zeroOneNumber
  }, {
    name: "selection-box-border-color",
    type: l.color
  }, {
    name: "selection-box-border-width",
    type: l.size
  }, {
    name: "active-bg-color",
    type: l.color
  }, {
    name: "active-bg-opacity",
    type: l.zeroOneNumber
  }, {
    name: "active-bg-size",
    type: l.size
  }, {
    name: "outside-texture-bg-color",
    type: l.color
  }, {
    name: "outside-texture-bg-opacity",
    type: l.zeroOneNumber
  }], R = [];
  Ze.pieBackgroundN = 16, R.push({
    name: "pie-size",
    type: l.sizeMaybePercent
  }), R.push({
    name: "pie-hole",
    type: l.sizeMaybePercent
  }), R.push({
    name: "pie-start-angle",
    type: l.angle
  });
  for (var P = 1; P <= Ze.pieBackgroundN; P++)
    R.push({
      name: "pie-" + P + "-background-color",
      type: l.color
    }), R.push({
      name: "pie-" + P + "-background-size",
      type: l.percent
    }), R.push({
      name: "pie-" + P + "-background-opacity",
      type: l.zeroOneNumber
    });
  var I = [];
  Ze.stripeBackgroundN = 16, I.push({
    name: "stripe-size",
    type: l.sizeMaybePercent
  }), I.push({
    name: "stripe-direction",
    type: l.axisDirectionPrimary
  });
  for (var k = 1; k <= Ze.stripeBackgroundN; k++)
    I.push({
      name: "stripe-" + k + "-background-color",
      type: l.color
    }), I.push({
      name: "stripe-" + k + "-background-size",
      type: l.percent
    }), I.push({
      name: "stripe-" + k + "-background-opacity",
      type: l.zeroOneNumber
    });
  var O = [], N = Ze.arrowPrefixes = ["source", "mid-source", "target", "mid-target"];
  [{
    name: "arrow-shape",
    type: l.arrowShape,
    triggersBounds: u.any
  }, {
    name: "arrow-color",
    type: l.color
  }, {
    name: "arrow-fill",
    type: l.arrowFill
  }, {
    name: "arrow-width",
    type: l.arrowWidth
  }].forEach(function(V) {
    N.forEach(function(q) {
      var H = q + "-" + V.name, Z = V.type, re = V.triggersBounds;
      O.push({
        name: H,
        type: Z,
        triggersBounds: re
      });
    });
  }, {});
  var F = Ze.properties = [].concat(g, m, p, y, b, A, d, h, f, v, c, C, S, w, x, R, I, T, D, O, L), G = Ze.propertyGroups = {
    // common to all eles
    behavior: g,
    transition: m,
    visibility: p,
    overlay: y,
    underlay: b,
    ghost: A,
    // labels
    commonLabel: d,
    labelDimensions: h,
    mainLabel: f,
    sourceLabel: v,
    targetLabel: c,
    // node props
    nodeBody: C,
    nodeBorder: S,
    nodeOutline: w,
    backgroundImage: x,
    pie: R,
    stripe: I,
    compound: T,
    // edge props
    edgeLine: D,
    edgeArrow: O,
    core: L
  }, B = Ze.propertyGroupNames = {}, z = Ze.propertyGroupKeys = Object.keys(G);
  z.forEach(function(V) {
    B[V] = G[V].map(function(q) {
      return q.name;
    }), G[V].forEach(function(q) {
      return q.groupKey = V;
    });
  });
  var Y = Ze.aliases = [{
    name: "content",
    pointsTo: "label"
  }, {
    name: "control-point-distance",
    pointsTo: "control-point-distances"
  }, {
    name: "control-point-weight",
    pointsTo: "control-point-weights"
  }, {
    name: "segment-distance",
    pointsTo: "segment-distances"
  }, {
    name: "segment-weight",
    pointsTo: "segment-weights"
  }, {
    name: "segment-radius",
    pointsTo: "segment-radii"
  }, {
    name: "edge-text-rotation",
    pointsTo: "text-rotation"
  }, {
    name: "padding-left",
    pointsTo: "padding"
  }, {
    name: "padding-right",
    pointsTo: "padding"
  }, {
    name: "padding-top",
    pointsTo: "padding"
  }, {
    name: "padding-bottom",
    pointsTo: "padding"
  }];
  Ze.propertyNames = F.map(function(V) {
    return V.name;
  });
  for (var $ = 0; $ < F.length; $++) {
    var X = F[$];
    F[X.name] = X;
  }
  for (var j = 0; j < Y.length; j++) {
    var ee = Y[j], ae = F[ee.pointsTo], K = {
      name: ee.name,
      alias: !0,
      pointsTo: ae
    };
    F.push(K), F[ee.name] = K;
  }
})();
Ze.getDefaultProperty = function(t) {
  return this.getDefaultProperties()[t];
};
Ze.getDefaultProperties = function() {
  var t = this._private;
  if (t.defaultProperties != null)
    return t.defaultProperties;
  for (var e = ye({
    // core props
    "selection-box-color": "#ddd",
    "selection-box-opacity": 0.65,
    "selection-box-border-color": "#aaa",
    "selection-box-border-width": 1,
    "active-bg-color": "black",
    "active-bg-opacity": 0.15,
    "active-bg-size": 30,
    "outside-texture-bg-color": "#000",
    "outside-texture-bg-opacity": 0.125,
    // common node/edge props
    events: "yes",
    "text-events": "no",
    "text-valign": "top",
    "text-halign": "center",
    "text-justification": "auto",
    "line-height": 1,
    color: "#000",
    "box-selection": "contain",
    "text-outline-color": "#000",
    "text-outline-width": 0,
    "text-outline-opacity": 1,
    "text-opacity": 1,
    "text-decoration": "none",
    "text-transform": "none",
    "text-wrap": "none",
    "text-overflow-wrap": "whitespace",
    "text-max-width": 9999,
    "text-background-color": "#000",
    "text-background-opacity": 0,
    "text-background-shape": "rectangle",
    "text-background-padding": 0,
    "text-border-opacity": 0,
    "text-border-width": 0,
    "text-border-style": "solid",
    "text-border-color": "#000",
    "font-family": "Helvetica Neue, Helvetica, sans-serif",
    "font-style": "normal",
    "font-weight": "normal",
    "font-size": 16,
    "min-zoomed-font-size": 0,
    "text-rotation": "none",
    "source-text-rotation": "none",
    "target-text-rotation": "none",
    visibility: "visible",
    display: "element",
    opacity: 1,
    "z-compound-depth": "auto",
    "z-index-compare": "auto",
    "z-index": 0,
    label: "",
    "text-margin-x": 0,
    "text-margin-y": 0,
    "source-label": "",
    "source-text-offset": 0,
    "source-text-margin-x": 0,
    "source-text-margin-y": 0,
    "target-label": "",
    "target-text-offset": 0,
    "target-text-margin-x": 0,
    "target-text-margin-y": 0,
    "overlay-opacity": 0,
    "overlay-color": "#000",
    "overlay-padding": 10,
    "overlay-shape": "round-rectangle",
    "overlay-corner-radius": "auto",
    "underlay-opacity": 0,
    "underlay-color": "#000",
    "underlay-padding": 10,
    "underlay-shape": "round-rectangle",
    "underlay-corner-radius": "auto",
    "text-metrics": "font",
    "transition-property": "none",
    "transition-duration": 0,
    "transition-delay": 0,
    "transition-timing-function": "linear",
    "box-select-labels": "no",
    // node props
    "background-blacken": 0,
    "background-color": "#999",
    "background-fill": "solid",
    "background-opacity": 1,
    "background-image": "none",
    "background-image-crossorigin": "anonymous",
    "background-image-opacity": 1,
    "background-image-containment": "inside",
    "background-image-smoothing": "yes",
    "background-position-x": "50%",
    "background-position-y": "50%",
    "background-offset-x": 0,
    "background-offset-y": 0,
    "background-width-relative-to": "include-padding",
    "background-height-relative-to": "include-padding",
    "background-repeat": "no-repeat",
    "background-fit": "none",
    "background-clip": "node",
    "background-width": "auto",
    "background-height": "auto",
    "border-color": "#000",
    "border-opacity": 1,
    "border-width": 0,
    "border-style": "solid",
    "border-dash-pattern": [4, 2],
    "border-dash-offset": 0,
    "border-cap": "butt",
    "border-join": "miter",
    "border-position": "center",
    "outline-color": "#999",
    "outline-opacity": 1,
    "outline-width": 0,
    "outline-offset": 0,
    "outline-style": "solid",
    height: 30,
    width: 30,
    shape: "ellipse",
    "shape-polygon-points": "-1, -1,   1, -1,   1, 1,   -1, 1",
    "corner-radius": "auto",
    "bounds-expansion": 0,
    // node gradient
    "background-gradient-direction": "to-bottom",
    "background-gradient-stop-colors": "#999",
    "background-gradient-stop-positions": "0%",
    // ghost props
    ghost: "no",
    "ghost-offset-y": 0,
    "ghost-offset-x": 0,
    "ghost-opacity": 0,
    // compound props
    padding: 0,
    "padding-relative-to": "width",
    position: "origin",
    "compound-sizing-wrt-labels": "include",
    "min-width": 0,
    "min-width-bias-left": 0,
    "min-width-bias-right": 0,
    "min-height": 0,
    "min-height-bias-top": 0,
    "min-height-bias-bottom": 0
  }, {
    // node pie bg
    "pie-size": "100%",
    "pie-hole": 0,
    "pie-start-angle": "0deg"
  }, [{
    name: "pie-{{i}}-background-color",
    value: "black"
  }, {
    name: "pie-{{i}}-background-size",
    value: "0%"
  }, {
    name: "pie-{{i}}-background-opacity",
    value: 1
  }].reduce(function(u, l) {
    for (var f = 1; f <= Ze.pieBackgroundN; f++) {
      var v = l.name.replace("{{i}}", f), c = l.value;
      u[v] = c;
    }
    return u;
  }, {}), {
    // node stripes bg
    "stripe-size": "100%",
    "stripe-direction": "horizontal"
  }, [{
    name: "stripe-{{i}}-background-color",
    value: "black"
  }, {
    name: "stripe-{{i}}-background-size",
    value: "0%"
  }, {
    name: "stripe-{{i}}-background-opacity",
    value: 1
  }].reduce(function(u, l) {
    for (var f = 1; f <= Ze.stripeBackgroundN; f++) {
      var v = l.name.replace("{{i}}", f), c = l.value;
      u[v] = c;
    }
    return u;
  }, {}), {
    // edge props
    "line-style": "solid",
    "line-color": "#999",
    "line-fill": "solid",
    "line-cap": "butt",
    "line-opacity": 1,
    "line-outline-width": 0,
    "line-outline-color": "#000",
    "line-gradient-stop-colors": "#999",
    "line-gradient-stop-positions": "0%",
    "control-point-step-size": 40,
    "control-point-weights": 0.5,
    "segment-weights": 0.5,
    "segment-distances": 20,
    "segment-radii": 15,
    "radius-type": "arc-radius",
    "taxi-turn": "50%",
    "taxi-radius": 15,
    "taxi-turn-min-distance": 10,
    "taxi-direction": "auto",
    "edge-distances": "intersection",
    "curve-style": "haystack",
    "haystack-radius": 0,
    "arrow-scale": 1,
    "loop-direction": "-45deg",
    "loop-sweep": "-90deg",
    "source-distance-from-node": 0,
    "target-distance-from-node": 0,
    "source-endpoint": "outside-to-node",
    "target-endpoint": "outside-to-node",
    "line-dash-pattern": [6, 3],
    "line-dash-offset": 0
  }, [{
    name: "arrow-shape",
    value: "none"
  }, {
    name: "arrow-color",
    value: "#999"
  }, {
    name: "arrow-fill",
    value: "filled"
  }, {
    name: "arrow-width",
    value: 1
  }].reduce(function(u, l) {
    return Ze.arrowPrefixes.forEach(function(f) {
      var v = f + "-" + l.name, c = l.value;
      u[v] = c;
    }), u;
  }, {})), r = {}, a = 0; a < this.properties.length; a++) {
    var n = this.properties[a];
    if (!n.pointsTo) {
      var i = n.name, o = e[i], s = this.parse(i, o);
      r[i] = s;
    }
  }
  return t.defaultProperties = r, t.defaultProperties;
};
Ze.addDefaultStylesheet = function() {
  this.selector(":parent").css({
    shape: "rectangle",
    padding: 10,
    "background-color": "#eee",
    "border-color": "#ccc",
    "border-width": 1
  }).selector("edge").css({
    width: 3
  }).selector(":loop").css({
    "curve-style": "bezier"
  }).selector("edge:compound").css({
    "curve-style": "bezier",
    "source-endpoint": "outside-to-line",
    "target-endpoint": "outside-to-line"
  }).selector(":selected").css({
    "background-color": "#0169D9",
    "line-color": "#0169D9",
    "source-arrow-color": "#0169D9",
    "target-arrow-color": "#0169D9",
    "mid-source-arrow-color": "#0169D9",
    "mid-target-arrow-color": "#0169D9"
  }).selector(":parent:selected").css({
    "background-color": "#CCE1F9",
    "border-color": "#aec8e5"
  }).selector(":active").css({
    "overlay-color": "black",
    "overlay-padding": 10,
    "overlay-opacity": 0.25
  }), this.defaultLength = this.length;
};
var Kn = {};
Kn.parse = function(t, e, r, a) {
  var n = this;
  if (He(e))
    return n.parseImplWarn(t, e, r, a);
  var i = a === "mapping" || a === !0 || a === !1 || a == null ? "dontcare" : a, o = r ? "t" : "f", s = "" + e, u = bf(t, s, o, i), l = n.propCache = n.propCache || [], f;
  return (f = l[u]) || (f = l[u] = n.parseImplWarn(t, e, r, a)), (r || a === "mapping") && (f = Vt(f), f && (f.value = Vt(f.value))), f;
};
Kn.parseImplWarn = function(t, e, r, a) {
  var n = this.parseImpl(t, e, r, a);
  return !n && e != null && Fe("The style property `".concat(t, ": ").concat(e, "` is invalid")), n && (n.name === "width" || n.name === "height") && e === "label" && Fe("The style value of `label` is deprecated for `" + n.name + "`"), n;
};
Kn.parseImpl = function(t, e, r, a) {
  var n = this;
  t = es(t);
  var i = n.properties[t], o = e, s = n.types;
  if (!i || e === void 0)
    return null;
  i.alias && (i = i.pointsTo, t = i.name);
  var u = de(e);
  u && (e = e.trim());
  var l = i.type;
  if (!l)
    return null;
  if (r && (e === "" || e === null))
    return {
      name: t,
      value: e,
      bypass: !0,
      deleteBypass: !0
    };
  if (He(e))
    return {
      name: t,
      value: e,
      strValue: "fn",
      mapped: s.fn,
      bypass: r
    };
  var f, v;
  if (!(!u || a || e.length < 7 || e[1] !== "a")) {
    if (e.length >= 7 && e[0] === "d" && (f = new RegExp(s.data.regex).exec(e))) {
      if (r)
        return !1;
      var c = s.data;
      return {
        name: t,
        value: f,
        strValue: "" + e,
        mapped: c,
        field: f[1],
        bypass: r
      };
    } else if (e.length >= 10 && e[0] === "m" && (v = new RegExp(s.mapData.regex).exec(e))) {
      if (r || l.multiple)
        return !1;
      var h = s.mapData;
      if (!(l.color || l.number))
        return !1;
      var d = this.parse(t, v[4]);
      if (!d || d.mapped)
        return !1;
      var g = this.parse(t, v[5]);
      if (!g || g.mapped)
        return !1;
      if (d.pfValue === g.pfValue || d.strValue === g.strValue)
        return Fe("`" + t + ": " + e + "` is not a valid mapper because the output range is zero; converting to `" + t + ": " + d.strValue + "`"), this.parse(t, d.strValue);
      if (l.color) {
        var p = d.value, y = g.value, b = p[0] === y[0] && p[1] === y[1] && p[2] === y[2] && // optional alpha
        (p[3] === y[3] || (p[3] == null || p[3] === 1) && (y[3] == null || y[3] === 1));
        if (b)
          return !1;
      }
      return {
        name: t,
        value: v,
        strValue: "" + e,
        mapped: h,
        field: v[1],
        fieldMin: parseFloat(v[2]),
        // min & max are numeric
        fieldMax: parseFloat(v[3]),
        valueMin: d.value,
        valueMax: g.value,
        bypass: r
      };
    }
  }
  if (l.multiple && a !== "multiple") {
    var m;
    if (u ? m = e.split(/\s+/) : ze(e) ? m = e : m = [e], l.evenMultiple && m.length % 2 !== 0)
      return null;
    for (var E = [], C = [], S = [], w = "", x = !1, T = 0; T < m.length; T++) {
      var D = n.parse(t, m[T], r, "multiple");
      x = x || de(D.value), E.push(D.value), S.push(D.pfValue != null ? D.pfValue : D.value), C.push(D.units), w += (T > 0 ? " " : "") + D.strValue;
    }
    return l.validate && !l.validate(E, C) ? null : l.singleEnum && x ? E.length === 1 && de(E[0]) ? {
      name: t,
      value: E[0],
      strValue: E[0],
      bypass: r
    } : null : {
      name: t,
      value: E,
      pfValue: S,
      strValue: w,
      bypass: r,
      units: C
    };
  }
  var A = function() {
    for (var K = 0; K < l.enums.length; K++) {
      var V = l.enums[K];
      if (V === e)
        return {
          name: t,
          value: e,
          strValue: "" + e,
          bypass: r
        };
    }
    return null;
  };
  if (l.number) {
    var L, R = "px";
    if (l.units && (L = l.units), l.implicitUnits && (R = l.implicitUnits), !l.unitless)
      if (u) {
        var P = "px|em" + (l.allowPercent ? "|\\%" : "");
        L && (P = L);
        var I = e.match("^(" + et + ")(" + P + ")?$");
        I && (e = I[1], L = I[2] || R);
      } else (!L || l.implicitUnits) && (L = R);
    if (e = parseFloat(e), isNaN(e) && l.enums === void 0)
      return null;
    if (isNaN(e) && l.enums !== void 0)
      return e = o, A();
    if (l.integer && !wc(e) || l.min !== void 0 && (e < l.min || l.strictMin && e === l.min) || l.max !== void 0 && (e > l.max || l.strictMax && e === l.max))
      return null;
    var k = {
      name: t,
      value: e,
      strValue: "" + e + (L || ""),
      units: L,
      bypass: r
    };
    return l.unitless || L !== "px" && L !== "em" ? k.pfValue = e : k.pfValue = L === "px" || !L ? e : this.getEmSizeInPixels() * e, (L === "ms" || L === "s") && (k.pfValue = L === "ms" ? e : 1e3 * e), (L === "deg" || L === "rad") && (k.pfValue = L === "rad" ? e : Mh(e)), L === "%" && (k.pfValue = e / 100), k;
  } else if (l.propList) {
    var O = [], N = "" + e;
    if (N !== "none") {
      for (var F = N.split(/\s*,\s*|\s+/), G = 0; G < F.length; G++) {
        var B = F[G].trim();
        n.properties[B] ? O.push(B) : Fe("`" + B + "` is not a valid property name");
      }
      if (O.length === 0)
        return null;
    }
    return {
      name: t,
      value: O,
      strValue: O.length === 0 ? "none" : O.join(" "),
      bypass: r
    };
  } else if (l.color) {
    var z = cf(e);
    return z ? {
      name: t,
      value: z,
      pfValue: z,
      strValue: "rgb(" + z[0] + "," + z[1] + "," + z[2] + ")",
      // n.b. no spaces b/c of multiple support
      bypass: r
    } : null;
  } else if (l.regex || l.regexes) {
    if (l.enums) {
      var Y = A();
      if (Y)
        return Y;
    }
    for (var $ = l.regexes ? l.regexes : [l.regex], X = 0; X < $.length; X++) {
      var j = new RegExp($[X]), ee = j.exec(e);
      if (ee)
        return {
          name: t,
          value: l.singleRegexMatchValue ? ee[1] : ee,
          strValue: "" + e,
          bypass: r
        };
    }
    return null;
  } else return l.string ? {
    name: t,
    value: "" + e,
    strValue: "" + e,
    bypass: r
  } : l.enums ? A() : null;
};
var it = function(e) {
  if (!(this instanceof it))
    return new it(e);
  if (!jo(e)) {
    qe("A style must have a core reference");
    return;
  }
  this._private = {
    cy: e,
    coreStyle: {}
  }, this.length = 0, this.resetToDefault();
}, dt = it.prototype;
dt.instanceString = function() {
  return "style";
};
dt.clear = function() {
  for (var t = this._private, e = t.cy, r = e.elements(), a = 0; a < this.length; a++)
    this[a] = void 0;
  return this.length = 0, t.contextStyles = {}, t.propDiffs = {}, this.cleanElements(r, !0), r.forEach(function(n) {
    var i = n[0]._private;
    i.styleDirty = !0, i.appliedInitStyle = !1;
  }), this;
};
dt.resetToDefault = function() {
  return this.clear(), this.addDefaultStylesheet(), this;
};
dt.core = function(t) {
  return this._private.coreStyle[t] || this.getDefaultProperty(t);
};
dt.selector = function(t) {
  var e = t === "core" ? null : new fr(t), r = this.length++;
  return this[r] = {
    selector: e,
    properties: [],
    mappedProperties: [],
    index: r
  }, this;
};
dt.css = function() {
  var t = this, e = arguments;
  if (e.length === 1)
    for (var r = e[0], a = 0; a < t.properties.length; a++) {
      var n = t.properties[a], i = r[n.name];
      i === void 0 && (i = r[Nn(n.name)]), i !== void 0 && this.cssRule(n.name, i);
    }
  else e.length === 2 && this.cssRule(e[0], e[1]);
  return this;
};
dt.style = dt.css;
dt.cssRule = function(t, e) {
  var r = this.parse(t, e);
  if (r) {
    var a = this.length - 1;
    this[a].properties.push(r), this[a].properties[r.name] = r, r.name.match(/pie-(\d+)-background-size/) && r.value && (this._private.hasPie = !0), r.name.match(/stripe-(\d+)-background-size/) && r.value && (this._private.hasStripe = !0), r.mapped && this[a].mappedProperties.push(r);
    var n = !this[a].selector;
    n && (this._private.coreStyle[r.name] = r);
  }
  return this;
};
dt.append = function(t) {
  return lf(t) ? t.appendToStyle(this) : ze(t) ? this.appendFromJson(t) : de(t) && this.appendFromString(t), this;
};
it.fromJson = function(t, e) {
  var r = new it(t);
  return r.fromJson(e), r;
};
it.fromString = function(t, e) {
  return new it(t).fromString(e);
};
[ot, Va, gs, Ut, $n, ps, Ze, Kn].forEach(function(t) {
  ye(dt, t);
});
it.types = dt.types;
it.properties = dt.properties;
it.propertyGroups = dt.propertyGroups;
it.propertyGroupNames = dt.propertyGroupNames;
it.propertyGroupKeys = dt.propertyGroupKeys;
var Np = {
  style: function(e) {
    if (e) {
      var r = this.setStyle(e);
      r.update();
    }
    return this._private.style;
  },
  setStyle: function(e) {
    var r = this._private;
    return lf(e) ? r.style = e.generateStyle(this) : ze(e) ? r.style = it.fromJson(this, e) : de(e) ? r.style = it.fromString(this, e) : r.style = it(this), r.style;
  },
  // e.g. cy.data() changed => recalc ele mappers
  updateStyle: function() {
    this.mutableElements().updateStyle();
  }
}, Bp = "single", Rr = {
  autolock: function(e) {
    if (e !== void 0)
      this._private.autolock = !!e;
    else
      return this._private.autolock;
    return this;
  },
  autoungrabify: function(e) {
    if (e !== void 0)
      this._private.autoungrabify = !!e;
    else
      return this._private.autoungrabify;
    return this;
  },
  autounselectify: function(e) {
    if (e !== void 0)
      this._private.autounselectify = !!e;
    else
      return this._private.autounselectify;
    return this;
  },
  selectionType: function(e) {
    var r = this._private;
    if (r.selectionType == null && (r.selectionType = Bp), e !== void 0)
      (e === "additive" || e === "single") && (r.selectionType = e);
    else
      return r.selectionType;
    return this;
  },
  panningEnabled: function(e) {
    if (e !== void 0)
      this._private.panningEnabled = !!e;
    else
      return this._private.panningEnabled;
    return this;
  },
  userPanningEnabled: function(e) {
    if (e !== void 0)
      this._private.userPanningEnabled = !!e;
    else
      return this._private.userPanningEnabled;
    return this;
  },
  zoomingEnabled: function(e) {
    if (e !== void 0)
      this._private.zoomingEnabled = !!e;
    else
      return this._private.zoomingEnabled;
    return this;
  },
  userZoomingEnabled: function(e) {
    if (e !== void 0)
      this._private.userZoomingEnabled = !!e;
    else
      return this._private.userZoomingEnabled;
    return this;
  },
  boxSelectionEnabled: function(e) {
    if (e !== void 0)
      this._private.boxSelectionEnabled = !!e;
    else
      return this._private.boxSelectionEnabled;
    return this;
  },
  pan: function() {
    var e = arguments, r = this._private.pan, a, n, i, o, s;
    switch (e.length) {
      case 0:
        return r;
      case 1:
        if (de(e[0]))
          return a = e[0], r[a];
        if (Ie(e[0])) {
          if (!this._private.panningEnabled)
            return this;
          i = e[0], o = i.x, s = i.y, ne(o) && (r.x = o), ne(s) && (r.y = s), this.emit("pan viewport");
        }
        break;
      case 2:
        if (!this._private.panningEnabled)
          return this;
        a = e[0], n = e[1], (a === "x" || a === "y") && ne(n) && (r[a] = n), this.emit("pan viewport");
        break;
    }
    return this.notify("viewport"), this;
  },
  panBy: function(e, r) {
    var a = arguments, n = this._private.pan, i, o, s, u, l;
    if (!this._private.panningEnabled)
      return this;
    switch (a.length) {
      case 1:
        Ie(e) && (s = a[0], u = s.x, l = s.y, ne(u) && (n.x += u), ne(l) && (n.y += l), this.emit("pan viewport"));
        break;
      case 2:
        i = e, o = r, (i === "x" || i === "y") && ne(o) && (n[i] += o), this.emit("pan viewport");
        break;
    }
    return this.notify("viewport"), this;
  },
  gc: function() {
    this.notify("gc");
  },
  fit: function(e, r) {
    var a = this.getFitViewport(e, r);
    if (a) {
      var n = this._private;
      n.zoom = a.zoom, n.pan = a.pan, this.emit("pan zoom viewport"), this.notify("viewport");
    }
    return this;
  },
  getFitViewport: function(e, r) {
    if (ne(e) && r === void 0 && (r = e, e = void 0), !(!this._private.panningEnabled || !this._private.zoomingEnabled)) {
      var a;
      if (de(e)) {
        var n = e;
        e = this.$(n);
      } else if (Tc(e)) {
        var i = e;
        a = {
          x1: i.x1,
          y1: i.y1,
          x2: i.x2,
          y2: i.y2
        }, a.w = a.x2 - a.x1, a.h = a.y2 - a.y1;
      } else Ct(e) || (e = this.mutableElements());
      if (!(Ct(e) && e.empty())) {
        a = a || e.boundingBox();
        var o = this.width(), s = this.height(), u;
        if (r = ne(r) ? r : 0, !isNaN(o) && !isNaN(s) && o > 0 && s > 0 && !isNaN(a.w) && !isNaN(a.h) && a.w > 0 && a.h > 0) {
          u = Math.min((o - 2 * r) / a.w, (s - 2 * r) / a.h), u = u > this._private.maxZoom ? this._private.maxZoom : u, u = u < this._private.minZoom ? this._private.minZoom : u;
          var l = {
            // now pan to middle
            x: (o - u * (a.x1 + a.x2)) / 2,
            y: (s - u * (a.y1 + a.y2)) / 2
          };
          return {
            zoom: u,
            pan: l
          };
        }
      }
    }
  },
  zoomRange: function(e, r) {
    var a = this._private;
    if (r == null) {
      var n = e;
      e = n.min, r = n.max;
    }
    return ne(e) && ne(r) && e <= r ? (a.minZoom = e, a.maxZoom = r) : ne(e) && r === void 0 && e <= a.maxZoom ? a.minZoom = e : ne(r) && e === void 0 && r >= a.minZoom && (a.maxZoom = r), this;
  },
  minZoom: function(e) {
    return e === void 0 ? this._private.minZoom : this.zoomRange({
      min: e
    });
  },
  maxZoom: function(e) {
    return e === void 0 ? this._private.maxZoom : this.zoomRange({
      max: e
    });
  },
  getZoomedViewport: function(e) {
    var r = this._private, a = r.pan, n = r.zoom, i, o, s = !1;
    if (r.zoomingEnabled || (s = !0), ne(e) ? o = e : Ie(e) && (o = e.level, e.position != null ? i = Gn(e.position, n, a) : e.renderedPosition != null && (i = e.renderedPosition), i != null && !r.panningEnabled && (s = !0)), o = o > r.maxZoom ? r.maxZoom : o, o = o < r.minZoom ? r.minZoom : o, s || !ne(o) || o === n || i != null && (!ne(i.x) || !ne(i.y)))
      return null;
    if (i != null) {
      var u = a, l = n, f = o, v = {
        x: -f / l * (i.x - u.x) + i.x,
        y: -f / l * (i.y - u.y) + i.y
      };
      return {
        zoomed: !0,
        panned: !0,
        zoom: f,
        pan: v
      };
    } else
      return {
        zoomed: !0,
        panned: !1,
        zoom: o,
        pan: a
      };
  },
  zoom: function(e) {
    if (e === void 0)
      return this._private.zoom;
    var r = this.getZoomedViewport(e), a = this._private;
    return r == null || !r.zoomed ? this : (a.zoom = r.zoom, r.panned && (a.pan.x = r.pan.x, a.pan.y = r.pan.y), this.emit("zoom" + (r.panned ? " pan" : "") + " viewport"), this.notify("viewport"), this);
  },
  viewport: function(e) {
    var r = this._private, a = !0, n = !0, i = [], o = !1, s = !1;
    if (!e)
      return this;
    if (ne(e.zoom) || (a = !1), Ie(e.pan) || (n = !1), !a && !n)
      return this;
    if (a) {
      var u = e.zoom;
      u < r.minZoom || u > r.maxZoom || !r.zoomingEnabled ? o = !0 : (r.zoom = u, i.push("zoom"));
    }
    if (n && (!o || !e.cancelOnFailedZoom) && r.panningEnabled) {
      var l = e.pan;
      ne(l.x) && (r.pan.x = l.x, s = !1), ne(l.y) && (r.pan.y = l.y, s = !1), s || i.push("pan");
    }
    return i.length > 0 && (i.push("viewport"), this.emit(i.join(" ")), this.notify("viewport")), this;
  },
  center: function(e) {
    var r = this.getCenterPan(e);
    return r && (this._private.pan = r, this.emit("pan viewport"), this.notify("viewport")), this;
  },
  getCenterPan: function(e, r) {
    if (this._private.panningEnabled) {
      if (de(e)) {
        var a = e;
        e = this.mutableElements().filter(a);
      } else Ct(e) || (e = this.mutableElements());
      if (e.length !== 0) {
        var n = e.boundingBox(), i = this.width(), o = this.height();
        r = r === void 0 ? this._private.zoom : r;
        var s = {
          // middle
          x: (i - r * (n.x1 + n.x2)) / 2,
          y: (o - r * (n.y1 + n.y2)) / 2
        };
        return s;
      }
    }
  },
  reset: function() {
    return !this._private.panningEnabled || !this._private.zoomingEnabled ? this : (this.viewport({
      pan: {
        x: 0,
        y: 0
      },
      zoom: 1
    }), this);
  },
  invalidateSize: function() {
    this._private.sizeCache = null;
  },
  size: function() {
    var e = this._private, r = e.container, a = this;
    return e.sizeCache = e.sizeCache || (r ? (function() {
      var n = a.window().getComputedStyle(r), i = function(s) {
        return parseFloat(n.getPropertyValue(s));
      };
      return {
        width: r.clientWidth - i("padding-left") - i("padding-right"),
        height: r.clientHeight - i("padding-top") - i("padding-bottom")
      };
    })() : {
      // fallback if no container (not 0 b/c can be used for dividing etc)
      width: 1,
      height: 1
    });
  },
  width: function() {
    return this.size().width;
  },
  height: function() {
    return this.size().height;
  },
  extent: function() {
    var e = this._private.pan, r = this._private.zoom, a = this.renderedExtent(), n = {
      x1: (a.x1 - e.x) / r,
      x2: (a.x2 - e.x) / r,
      y1: (a.y1 - e.y) / r,
      y2: (a.y2 - e.y) / r
    };
    return n.w = n.x2 - n.x1, n.h = n.y2 - n.y1, n;
  },
  renderedExtent: function() {
    var e = this.width(), r = this.height();
    return {
      x1: 0,
      y1: 0,
      x2: e,
      y2: r,
      w: e,
      h: r
    };
  },
  multiClickDebounceTime: function(e) {
    if (e) this._private.multiClickDebounceTime = e;
    else return this._private.multiClickDebounceTime;
    return this;
  }
};
Rr.centre = Rr.center;
Rr.autolockNodes = Rr.autolock;
Rr.autoungrabifyNodes = Rr.autoungrabify;
var Ma = {
  data: Be.data({
    field: "data",
    bindingEvent: "data",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "data",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    updateStyle: !0
  }),
  removeData: Be.removeData({
    field: "data",
    event: "data",
    triggerFnName: "trigger",
    triggerEvent: !0,
    updateStyle: !0
  }),
  scratch: Be.data({
    field: "scratch",
    bindingEvent: "scratch",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "scratch",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    updateStyle: !0
  }),
  removeScratch: Be.removeData({
    field: "scratch",
    event: "scratch",
    triggerFnName: "trigger",
    triggerEvent: !0,
    updateStyle: !0
  })
};
Ma.attr = Ma.data;
Ma.removeAttr = Ma.removeData;
var Pa = function(e) {
  var r = this;
  e = ye({}, e);
  var a = e.container;
  a && !xn(a) && xn(a[0]) && (a = a[0]);
  var n = a ? a._cyreg : null;
  n = n || {}, n && n.cy && (n.cy.destroy(), n = {});
  var i = n.readies = n.readies || [];
  a && (a._cyreg = n), n.cy = r;
  var o = je !== void 0 && a !== void 0 && !e.headless, s = e;
  s.layout = ye({
    name: o ? "grid" : "null"
  }, s.layout), s.renderer = ye({
    name: o ? "canvas" : "null"
  }, s.renderer);
  var u = function(d, g, p) {
    return g !== void 0 ? g : p !== void 0 ? p : d;
  }, l = this._private = {
    container: a,
    // html dom ele container
    ready: !1,
    // whether ready has been triggered
    options: s,
    // cached options
    elements: new lt(this),
    // elements in the graph
    listeners: [],
    // list of listeners
    aniEles: new lt(this),
    // elements being animated
    data: s.data || {},
    // data for the core
    scratch: {},
    // scratch object for core
    layout: null,
    renderer: null,
    destroyed: !1,
    // whether destroy was called
    notificationsEnabled: !0,
    // whether notifications are sent to the renderer
    minZoom: 1e-50,
    maxZoom: 1e50,
    zoomingEnabled: u(!0, s.zoomingEnabled),
    userZoomingEnabled: u(!0, s.userZoomingEnabled),
    panningEnabled: u(!0, s.panningEnabled),
    userPanningEnabled: u(!0, s.userPanningEnabled),
    boxSelectionEnabled: u(!0, s.boxSelectionEnabled),
    autolock: u(!1, s.autolock, s.autolockNodes),
    autoungrabify: u(!1, s.autoungrabify, s.autoungrabifyNodes),
    autounselectify: u(!1, s.autounselectify),
    styleEnabled: s.styleEnabled === void 0 ? o : s.styleEnabled,
    zoom: ne(s.zoom) ? s.zoom : 1,
    pan: {
      x: Ie(s.pan) && ne(s.pan.x) ? s.pan.x : 0,
      y: Ie(s.pan) && ne(s.pan.y) ? s.pan.y : 0
    },
    animation: {
      // object for currently-running animations
      current: [],
      queue: []
    },
    hasCompoundNodes: !1,
    multiClickDebounceTime: u(250, s.multiClickDebounceTime)
  };
  this.createEmitter(), this.selectionType(s.selectionType), this.zoomRange({
    min: s.minZoom,
    max: s.maxZoom
  });
  var f = function(d, g) {
    var p = d.some(Cc);
    if (p)
      return ra.all(d).then(g);
    g(d);
  };
  l.styleEnabled && r.setStyle([]);
  var v = ye({}, s, s.renderer);
  r.initRenderer(v);
  var c = function(d, g, p) {
    r.notifications(!1);
    var y = r.mutableElements();
    y.length > 0 && y.remove(), d != null && (Ie(d) || ze(d)) && r.add(d), r.one("layoutready", function(m) {
      r.notifications(!0), r.emit(m), r.one("load", g), r.emitAndNotify("load");
    }).one("layoutstop", function() {
      r.one("done", p), r.emit("done");
    });
    var b = ye({}, r._private.options.layout);
    b.eles = r.elements(), r.layout(b).run();
  };
  f([s.style, s.elements], function(h) {
    var d = h[0], g = h[1];
    l.styleEnabled && r.style().append(d), c(g, function() {
      r.startAnimationLoop(), l.ready = !0, He(s.ready) && r.on("ready", s.ready);
      for (var p = 0; p < i.length; p++) {
        var y = i[p];
        r.on("ready", y);
      }
      n && (n.readies = []), r.emit("ready");
    }, s.done);
  });
}, Rn = Pa.prototype;
ye(Rn, {
  instanceString: function() {
    return "core";
  },
  isReady: function() {
    return this._private.ready;
  },
  destroyed: function() {
    return this._private.destroyed;
  },
  ready: function(e) {
    return this.isReady() ? this.emitter().emit("ready", [], e) : this.on("ready", e), this;
  },
  destroy: function() {
    var e = this;
    if (!e.destroyed())
      return e.stopAnimationLoop(), e.destroyRenderer(), this.emit("destroy"), e._private.destroyed = !0, e;
  },
  hasElementWithId: function(e) {
    return this._private.elements.hasElementWithId(e);
  },
  getElementById: function(e) {
    return this._private.elements.getElementById(e);
  },
  hasCompoundNodes: function() {
    return this._private.hasCompoundNodes;
  },
  headless: function() {
    return this._private.renderer.isHeadless();
  },
  styleEnabled: function() {
    return this._private.styleEnabled;
  },
  addToPool: function(e) {
    return this._private.elements.merge(e), this;
  },
  removeFromPool: function(e) {
    return this._private.elements.unmerge(e), this;
  },
  container: function() {
    return this._private.container || null;
  },
  window: function() {
    var e = this._private.container;
    if (e == null) return je;
    var r = this._private.container.ownerDocument;
    return r === void 0 || r == null ? je : r.defaultView || je;
  },
  mount: function(e) {
    if (e != null) {
      var r = this, a = r._private, n = a.options;
      return !xn(e) && xn(e[0]) && (e = e[0]), r.stopAnimationLoop(), r.destroyRenderer(), a.container = e, a.styleEnabled = !0, r.invalidateSize(), r.initRenderer(ye({}, n, n.renderer, {
        // allow custom renderer name to be re-used, otherwise use canvas
        name: n.renderer.name === "null" ? "canvas" : n.renderer.name
      })), r.startAnimationLoop(), r.style(n.style), r.emit("mount"), r;
    }
  },
  unmount: function() {
    var e = this;
    return e.stopAnimationLoop(), e.destroyRenderer(), e.initRenderer({
      name: "null"
    }), e.emit("unmount"), e;
  },
  options: function() {
    return Vt(this._private.options);
  },
  json: function(e) {
    var r = this, a = r._private, n = r.mutableElements(), i = function(E) {
      return r.getElementById(E.id());
    };
    if (Ie(e)) {
      if (r.startBatch(), e.elements) {
        var o = {}, s = function(E, C) {
          for (var S = [], w = [], x = 0; x < E.length; x++) {
            var T = E[x];
            if (!T.data.id) {
              Fe("cy.json() cannot handle elements without an ID attribute");
              continue;
            }
            var D = "" + T.data.id, A = r.getElementById(D);
            o[D] = !0, A.length !== 0 ? w.push({
              ele: A,
              json: T
            }) : (C && (T.group = C), S.push(T));
          }
          r.add(S);
          for (var L = 0; L < w.length; L++) {
            var R = w[L], P = R.ele, I = R.json;
            P.json(I);
          }
        };
        if (ze(e.elements))
          s(e.elements);
        else
          for (var u = ["nodes", "edges"], l = 0; l < u.length; l++) {
            var f = u[l], v = e.elements[f];
            ze(v) && s(v, f);
          }
        var c = r.collection();
        n.filter(function(m) {
          return !o[m.id()];
        }).forEach(function(m) {
          m.isParent() ? c.merge(m) : m.remove();
        }), c.forEach(function(m) {
          return m.children().move({
            parent: null
          });
        }), c.forEach(function(m) {
          return i(m).remove();
        });
      }
      e.style && r.style(e.style), e.zoom != null && e.zoom !== a.zoom && r.zoom(e.zoom), e.pan && (e.pan.x !== a.pan.x || e.pan.y !== a.pan.y) && r.pan(e.pan), e.data && r.data(e.data);
      for (var h = ["minZoom", "maxZoom", "zoomingEnabled", "userZoomingEnabled", "panningEnabled", "userPanningEnabled", "boxSelectionEnabled", "autolock", "autoungrabify", "autounselectify", "multiClickDebounceTime"], d = 0; d < h.length; d++) {
        var g = h[d];
        e[g] != null && r[g](e[g]);
      }
      return r.endBatch(), this;
    } else {
      var p = !!e, y = {};
      p ? y.elements = this.elements().map(function(m) {
        return m.json();
      }) : (y.elements = {}, n.forEach(function(m) {
        var E = m.group();
        y.elements[E] || (y.elements[E] = []), y.elements[E].push(m.json());
      })), this._private.styleEnabled && (y.style = r.style().json()), y.data = Vt(r.data());
      var b = a.options;
      return y.zoomingEnabled = a.zoomingEnabled, y.userZoomingEnabled = a.userZoomingEnabled, y.zoom = a.zoom, y.minZoom = a.minZoom, y.maxZoom = a.maxZoom, y.panningEnabled = a.panningEnabled, y.userPanningEnabled = a.userPanningEnabled, y.pan = Vt(a.pan), y.boxSelectionEnabled = a.boxSelectionEnabled, y.renderer = Vt(b.renderer), y.hideEdgesOnViewport = b.hideEdgesOnViewport, y.textureOnViewport = b.textureOnViewport, y.wheelSensitivity = b.wheelSensitivity, y.motionBlur = b.motionBlur, y.multiClickDebounceTime = b.multiClickDebounceTime, y;
    }
  }
});
Rn.$id = Rn.getElementById;
[Dp, Mp, lv, Vo, hn, Ip, Uo, dn, Np, Rr, Ma].forEach(function(t) {
  ye(Rn, t);
});
var Fp = {
  fit: !0,
  // whether to fit the viewport to the graph
  directed: !1,
  // whether the tree is directed downwards (or edges can point in any direction if false)
  direction: "downward",
  // determines the direction in which the tree structure is drawn.  The possible values are 'downward', 'upward', 'rightward', or 'leftward'.
  padding: 30,
  // padding on fit
  circle: !1,
  // put depths in concentric circles if true, put depths top down if false
  grid: !1,
  // whether to create an even grid into which the DAG is placed (circle:false only)
  spacingFactor: 1.75,
  // positive spacing factor, larger => more space between nodes (N.B. n/a if causes overlap)
  boundingBox: void 0,
  // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  avoidOverlap: !0,
  // prevents node overlap, may overflow boundingBox if not enough space
  nodeDimensionsIncludeLabels: !1,
  // Excludes the label when calculating node bounding boxes for the layout algorithm
  roots: void 0,
  // the roots of the trees
  depthSort: void 0,
  // a sorting function to order nodes at equal depth. e.g. function(a, b){ return a.data('weight') - b.data('weight') }
  animate: !1,
  // whether to transition the node positions
  animationDuration: 500,
  // duration of animation in ms if enabled
  animationEasing: void 0,
  // easing of animation if enabled,
  animateFilter: function(e, r) {
    return !0;
  },
  // a function that determines whether the node should be animated.  All nodes animated by default on animate enabled.  Non-animated nodes are positioned immediately when the layout starts
  ready: void 0,
  // callback on layoutready
  stop: void 0,
  // callback on layoutstop
  transform: function(e, r) {
    return r;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts
}, Gp = {
  maximal: !1,
  // whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only); setting acyclic to true sets maximal to true also
  acyclic: !1
  // whether the tree is acyclic and thus a node could be shifted (due to the maximal option) multiple times without causing an infinite loop; setting to true sets maximal to true also; if you are uncertain whether a tree is acyclic, set to false to avoid potential infinite loops
}, Br = function(e) {
  return e.scratch("breadthfirst");
}, Al = function(e, r) {
  return e.scratch("breadthfirst", r);
};
function fv(t) {
  this.options = ye({}, Fp, Gp, t);
}
fv.prototype.run = function() {
  var t = this.options, e = t.cy, r = t.eles, a = r.nodes().filter(function(ge) {
    return ge.isChildless();
  }), n = r, i = t.directed, o = t.acyclic || t.maximal || t.maximalAdjustments > 0, s = !!t.boundingBox, u = mt(s ? t.boundingBox : structuredClone(e.extent())), l;
  if (Ct(t.roots))
    l = t.roots;
  else if (ze(t.roots)) {
    for (var f = [], v = 0; v < t.roots.length; v++) {
      var c = t.roots[v], h = e.getElementById(c);
      f.push(h);
    }
    l = e.collection(f);
  } else if (de(t.roots))
    l = e.$(t.roots);
  else if (i)
    l = a.roots();
  else {
    var d = r.components();
    l = e.collection();
    for (var g = function() {
      var oe = d[p], he = oe.maxDegree(!1), ce = oe.filter(function(Ee) {
        return Ee.degree(!1) === he;
      });
      l = l.add(ce);
    }, p = 0; p < d.length; p++)
      g();
  }
  var y = [], b = {}, m = function(oe, he) {
    y[he] == null && (y[he] = []);
    var ce = y[he].length;
    y[he].push(oe), Al(oe, {
      index: ce,
      depth: he
    });
  }, E = function(oe, he) {
    var ce = Br(oe), Ee = ce.depth, be = ce.index;
    y[Ee][be] = null, oe.isChildless() && m(oe, he);
  };
  n.bfs({
    roots: l,
    directed: t.directed,
    visit: function(oe, he, ce, Ee, be) {
      var De = oe[0], Le = De.id();
      De.isChildless() && m(De, be), b[Le] = !0;
    }
  });
  for (var C = [], S = 0; S < a.length; S++) {
    var w = a[S];
    b[w.id()] || C.push(w);
  }
  var x = function(oe) {
    for (var he = y[oe], ce = 0; ce < he.length; ce++) {
      var Ee = he[ce];
      if (Ee == null) {
        he.splice(ce, 1), ce--;
        continue;
      }
      Al(Ee, {
        depth: oe,
        index: ce
      });
    }
  }, T = function(oe, he) {
    for (var ce = Br(oe), Ee = oe.incomers().filter(function(J) {
      return J.isNode() && r.has(J);
    }), be = -1, De = oe.id(), Le = 0; Le < Ee.length; Le++) {
      var Ne = Ee[Le], Oe = Br(Ne);
      be = Math.max(be, Oe.depth);
    }
    if (ce.depth <= be) {
      if (!t.acyclic && he[De])
        return null;
      var Me = be + 1;
      return E(oe, Me), he[De] = Me, !0;
    }
    return !1;
  };
  if (i && o) {
    var D = [], A = {}, L = function(oe) {
      return D.push(oe);
    }, R = function() {
      return D.shift();
    };
    for (a.forEach(function(ge) {
      return D.push(ge);
    }); D.length > 0; ) {
      var P = R(), I = T(P, A);
      if (I)
        P.outgoers().filter(function(ge) {
          return ge.isNode() && r.has(ge);
        }).forEach(L);
      else if (I === null) {
        Fe("Detected double maximal shift for node `" + P.id() + "`.  Bailing maximal adjustment due to cycle.  Use `options.maximal: true` only on DAGs.");
        break;
      }
    }
  }
  var k = 0;
  if (t.avoidOverlap)
    for (var O = 0; O < a.length; O++) {
      var N = a[O], F = N.layoutDimensions(t), G = F.w, B = F.h;
      k = Math.max(k, G, B);
    }
  var z = {}, Y = function(oe) {
    if (z[oe.id()])
      return z[oe.id()];
    for (var he = Br(oe).depth, ce = oe.neighborhood(), Ee = 0, be = 0, De = 0; De < ce.length; De++) {
      var Le = ce[De];
      if (!(Le.isEdge() || Le.isParent() || !a.has(Le))) {
        var Ne = Br(Le);
        if (Ne != null) {
          var Oe = Ne.index, Me = Ne.depth;
          if (!(Oe == null || Me == null)) {
            var J = y[Me].length;
            Me < he && (Ee += Oe / J, be++);
          }
        }
      }
    }
    return be = Math.max(1, be), Ee = Ee / be, be === 0 && (Ee = 0), z[oe.id()] = Ee, Ee;
  }, $ = function(oe, he) {
    var ce = Y(oe), Ee = Y(he), be = ce - Ee;
    return be === 0 ? vf(oe.id(), he.id()) : be;
  };
  t.depthSort !== void 0 && ($ = t.depthSort);
  for (var X = y.length, j = 0; j < X; j++)
    y[j].sort($), x(j);
  for (var ee = [], ae = 0; ae < C.length; ae++)
    ee.push(C[ae]);
  var K = function() {
    for (var oe = 0; oe < X; oe++)
      x(oe);
  };
  ee.length && (y.unshift(ee), X = y.length, K());
  for (var V = 0, q = 0; q < X; q++)
    V = Math.max(y[q].length, V);
  var H = {
    x: u.x1 + u.w / 2,
    y: u.y1 + u.h / 2
  }, Z = a.reduce(function(ge, oe) {
    return (function(he) {
      return {
        w: ge.w === -1 ? he.w : (ge.w + he.w) / 2,
        h: ge.h === -1 ? he.h : (ge.h + he.h) / 2
      };
    })(oe.boundingBox({
      includeLabels: t.nodeDimensionsIncludeLabels
    }));
  }, {
    w: -1,
    h: -1
  }), re = Math.max(
    // only one depth
    X === 1 ? 0 : (
      // inside a bounding box, no need for top & bottom padding
      s ? (u.h - t.padding * 2 - Z.h) / (X - 1) : (u.h - t.padding * 2 - Z.h) / (X + 1)
    ),
    k
  ), le = y.reduce(function(ge, oe) {
    return Math.max(ge, oe.length);
  }, 0), Ae = function(oe) {
    var he = Br(oe), ce = he.depth, Ee = he.index;
    if (t.circle) {
      var be = Math.min(u.w / 2 / X, u.h / 2 / X);
      be = Math.max(be, k);
      var De = be * ce + be - (X > 0 && y[0].length <= 3 ? be / 2 : 0), Le = 2 * Math.PI / y[ce].length * Ee;
      return ce === 0 && y[0].length === 1 && (De = 1), {
        x: H.x + De * Math.cos(Le),
        y: H.y + De * Math.sin(Le)
      };
    } else {
      var Ne = y[ce].length, Oe = Math.max(
        // only one depth
        Ne === 1 ? 0 : (
          // inside a bounding box, no need for left & right padding
          s ? (u.w - t.padding * 2 - Z.w) / ((t.grid ? le : Ne) - 1) : (u.w - t.padding * 2 - Z.w) / ((t.grid ? le : Ne) + 1)
        ),
        k
      ), Me = {
        x: H.x + (Ee + 1 - (Ne + 1) / 2) * Oe,
        y: H.y + (ce + 1 - (X + 1) / 2) * re
      };
      return Me;
    }
  }, we = {
    downward: 0,
    leftward: 90,
    upward: 180,
    rightward: -90
  };
  Object.keys(we).indexOf(t.direction) === -1 && qe("Invalid direction '".concat(t.direction, "' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(we).join(", ")));
  var me = function(oe) {
    return jc(Ae(oe), u, we[t.direction]);
  };
  return r.nodes().layoutPositions(this, t, me), this;
};
var zp = {
  fit: !0,
  // whether to fit the viewport to the graph
  padding: 30,
  // the padding on fit
  boundingBox: void 0,
  // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  avoidOverlap: !0,
  // prevents node overlap, may overflow boundingBox and radius if not enough space
  nodeDimensionsIncludeLabels: !1,
  // Excludes the label when calculating node bounding boxes for the layout algorithm
  spacingFactor: void 0,
  // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
  radius: void 0,
  // the radius of the circle
  startAngle: 3 / 2 * Math.PI,
  // where nodes start in radians
  sweep: void 0,
  // how many radians should be between the first and last node (defaults to full circle)
  clockwise: !0,
  // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false)
  sort: void 0,
  // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') }
  animate: !1,
  // whether to transition the node positions
  animationDuration: 500,
  // duration of animation in ms if enabled
  animationEasing: void 0,
  // easing of animation if enabled
  animateFilter: function(e, r) {
    return !0;
  },
  // a function that determines whether the node should be animated.  All nodes animated by default on animate enabled.  Non-animated nodes are positioned immediately when the layout starts
  ready: void 0,
  // callback on layoutready
  stop: void 0,
  // callback on layoutstop
  transform: function(e, r) {
    return r;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts 
};
function vv(t) {
  this.options = ye({}, zp, t);
}
vv.prototype.run = function() {
  var t = this.options, e = t, r = t.cy, a = e.eles, n = e.counterclockwise !== void 0 ? !e.counterclockwise : e.clockwise, i = a.nodes().not(":parent");
  e.sort && (i = i.sort(e.sort));
  for (var o = mt(e.boundingBox ? e.boundingBox : {
    x1: 0,
    y1: 0,
    w: r.width(),
    h: r.height()
  }), s = {
    x: o.x1 + o.w / 2,
    y: o.y1 + o.h / 2
  }, u = e.sweep === void 0 ? 2 * Math.PI - 2 * Math.PI / i.length : e.sweep, l = u / Math.max(1, i.length - 1), f, v = 0, c = 0; c < i.length; c++) {
    var h = i[c], d = h.layoutDimensions(e), g = d.w, p = d.h;
    v = Math.max(v, g, p);
  }
  if (ne(e.radius) ? f = e.radius : i.length <= 1 ? f = 0 : f = Math.min(o.h, o.w) / 2 - v, i.length > 1 && e.avoidOverlap) {
    v *= 1.75;
    var y = Math.cos(l) - Math.cos(0), b = Math.sin(l) - Math.sin(0), m = Math.sqrt(v * v / (y * y + b * b));
    f = Math.max(m, f);
  }
  var E = function(S, w) {
    var x = e.startAngle + w * l * (n ? 1 : -1), T = f * Math.cos(x), D = f * Math.sin(x), A = {
      x: s.x + T,
      y: s.y + D
    };
    return A;
  };
  return a.nodes().layoutPositions(this, e, E), this;
};
var _p = {
  fit: !0,
  // whether to fit the viewport to the graph
  padding: 30,
  // the padding on fit
  startAngle: 3 / 2 * Math.PI,
  // where nodes start in radians
  sweep: void 0,
  // how many radians should be between the first and last node (defaults to full circle)
  clockwise: !0,
  // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false)
  equidistant: !1,
  // whether levels have an equal radial distance betwen them, may cause bounding box overflow
  minNodeSpacing: 10,
  // min spacing between outside of nodes (used for radius adjustment)
  boundingBox: void 0,
  // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  avoidOverlap: !0,
  // prevents node overlap, may overflow boundingBox if not enough space
  nodeDimensionsIncludeLabels: !1,
  // Excludes the label when calculating node bounding boxes for the layout algorithm
  height: void 0,
  // height of layout area (overrides container height)
  width: void 0,
  // width of layout area (overrides container width)
  spacingFactor: void 0,
  // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
  concentric: function(e) {
    return e.degree();
  },
  levelWidth: function(e) {
    return e.maxDegree() / 4;
  },
  animate: !1,
  // whether to transition the node positions
  animationDuration: 500,
  // duration of animation in ms if enabled
  animationEasing: void 0,
  // easing of animation if enabled
  animateFilter: function(e, r) {
    return !0;
  },
  // a function that determines whether the node should be animated.  All nodes animated by default on animate enabled.  Non-animated nodes are positioned immediately when the layout starts
  ready: void 0,
  // callback on layoutready
  stop: void 0,
  // callback on layoutstop
  transform: function(e, r) {
    return r;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts
};
function cv(t) {
  this.options = ye({}, _p, t);
}
cv.prototype.run = function() {
  for (var t = this.options, e = t, r = e.counterclockwise !== void 0 ? !e.counterclockwise : e.clockwise, a = t.cy, n = e.eles, i = n.nodes().not(":parent"), o = mt(e.boundingBox ? e.boundingBox : {
    x1: 0,
    y1: 0,
    w: a.width(),
    h: a.height()
  }), s = {
    x: o.x1 + o.w / 2,
    y: o.y1 + o.h / 2
  }, u = [], l = 0, f = 0; f < i.length; f++) {
    var v = i[f], c = void 0;
    c = e.concentric(v), u.push({
      value: c,
      node: v
    }), v._private.scratch.concentric = c;
  }
  i.updateStyle();
  for (var h = 0; h < i.length; h++) {
    var d = i[h], g = d.layoutDimensions(e);
    l = Math.max(l, g.w, g.h);
  }
  u.sort(function(re, le) {
    return le.value - re.value;
  });
  for (var p = e.levelWidth(i), y = [[]], b = y[0], m = 0; m < u.length; m++) {
    var E = u[m];
    if (b.length > 0) {
      var C = Math.abs(b[0].value - E.value);
      C >= p && (b = [], y.push(b));
    }
    b.push(E);
  }
  var S = l + e.minNodeSpacing;
  if (!e.avoidOverlap) {
    var w = y.length > 0 && y[0].length > 1, x = Math.min(o.w, o.h) / 2 - S, T = x / (y.length + w ? 1 : 0);
    S = Math.min(S, T);
  }
  for (var D = 0, A = 0; A < y.length; A++) {
    var L = y[A], R = e.sweep === void 0 ? 2 * Math.PI - 2 * Math.PI / L.length : e.sweep, P = L.dTheta = R / Math.max(1, L.length - 1);
    if (L.length > 1 && e.avoidOverlap) {
      var I = Math.cos(P) - Math.cos(0), k = Math.sin(P) - Math.sin(0), O = Math.sqrt(S * S / (I * I + k * k));
      D = Math.max(O, D);
    }
    L.r = D, D += S;
  }
  if (e.equidistant) {
    for (var N = 0, F = 0, G = 0; G < y.length; G++) {
      var B = y[G], z = B.r - F;
      N = Math.max(N, z);
    }
    F = 0;
    for (var Y = 0; Y < y.length; Y++) {
      var $ = y[Y];
      Y === 0 && (F = $.r), $.r = F, F += N;
    }
  }
  for (var X = {}, j = 0; j < y.length; j++)
    for (var ee = y[j], ae = ee.dTheta, K = ee.r, V = 0; V < ee.length; V++) {
      var q = ee[V], H = e.startAngle + (r ? 1 : -1) * ae * V, Z = {
        x: s.x + K * Math.cos(H),
        y: s.y + K * Math.sin(H)
      };
      X[q.node.id()] = Z;
    }
  return n.nodes().layoutPositions(this, e, function(re) {
    var le = re.id();
    return X[le];
  }), this;
};
var To, Vp = {
  // Called on `layoutready`
  ready: function() {
  },
  // Called on `layoutstop`
  stop: function() {
  },
  // Whether to animate while running the layout
  // true : Animate continuously as the layout is running
  // false : Just show the end result
  // 'end' : Animate with the end result, from the initial positions to the end positions
  animate: !0,
  // Easing of the animation for animate:'end'
  animationEasing: void 0,
  // The duration of the animation for animate:'end'
  animationDuration: void 0,
  // A function that determines whether the node should be animated
  // All nodes animated by default on animate enabled
  // Non-animated nodes are positioned immediately when the layout starts
  animateFilter: function(e, r) {
    return !0;
  },
  // The layout animates only after this many milliseconds for animate:true
  // (prevents flashing on fast runs)
  animationThreshold: 250,
  // Number of iterations between consecutive screen positions update
  refresh: 20,
  // Whether to fit the network view after when done
  fit: !0,
  // Padding on fit
  padding: 30,
  // Constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  boundingBox: void 0,
  // Excludes the label when calculating node bounding boxes for the layout algorithm
  nodeDimensionsIncludeLabels: !1,
  // Randomize the initial positions of the nodes (true) or use existing positions (false)
  randomize: !1,
  // Extra spacing between components in non-compound graphs
  componentSpacing: 40,
  // Node repulsion (non overlapping) multiplier
  nodeRepulsion: function(e) {
    return 2048;
  },
  // Node repulsion (overlapping) multiplier
  nodeOverlap: 4,
  // Ideal edge (non nested) length
  idealEdgeLength: function(e) {
    return 32;
  },
  // Divisor to compute edge forces
  edgeElasticity: function(e) {
    return 32;
  },
  // Nesting factor (multiplier) to compute ideal edge length for nested edges
  nestingFactor: 1.2,
  // Gravity force (constant)
  gravity: 1,
  // Maximum number of iterations to perform
  numIter: 1e3,
  // Initial temperature (maximum node displacement)
  initialTemp: 1e3,
  // Cooling factor (how the temperature is reduced between consecutive iterations
  coolingFactor: 0.99,
  // Lower temperature threshold (below this point the layout will end)
  minTemp: 1
};
function Zn(t) {
  this.options = ye({}, Vp, t), this.options.layout = this;
  var e = this.options.eles.nodes(), r = this.options.eles.edges(), a = r.filter(function(n) {
    var i = n.source().data("id"), o = n.target().data("id"), s = e.some(function(l) {
      return l.data("id") === i;
    }), u = e.some(function(l) {
      return l.data("id") === o;
    });
    return !s || !u;
  });
  this.options.eles = this.options.eles.not(a);
}
Zn.prototype.run = function() {
  var t = this.options, e = t.cy, r = this;
  r.stopped = !1, (t.animate === !0 || t.animate === !1) && r.emit({
    type: "layoutstart",
    layout: r
  }), t.debug === !0 ? To = !0 : To = !1;
  var a = Up(e, r, t);
  To && Yp(a), t.randomize && Hp(a);
  var n = $t(), i = function() {
    Xp(a, e, t), t.fit === !0 && e.fit(t.padding);
  }, o = function(c) {
    return !(r.stopped || c >= t.numIter || (Wp(a, t), a.temperature = a.temperature * t.coolingFactor, a.temperature < t.minTemp));
  }, s = function() {
    if (t.animate === !0 || t.animate === !1)
      i(), r.one("layoutstop", t.stop), r.emit({
        type: "layoutstop",
        layout: r
      });
    else {
      var c = t.eles.nodes(), h = dv(a, t, c);
      c.layoutPositions(r, t, h);
    }
  }, u = 0, l = !0;
  if (t.animate === !0) {
    var f = function() {
      for (var c = 0; l && c < t.refresh; )
        l = o(u), u++, c++;
      if (!l)
        Rl(a, t), s();
      else {
        var h = $t();
        h - n >= t.animationThreshold && i(), Tn(f);
      }
    };
    f();
  } else {
    for (; l; )
      l = o(u), u++;
    Rl(a, t), s();
  }
  return this;
};
Zn.prototype.stop = function() {
  return this.stopped = !0, this.thread && this.thread.stop(), this.emit("layoutstop"), this;
};
Zn.prototype.destroy = function() {
  return this.thread && this.thread.stop(), this;
};
var Up = function(e, r, a) {
  for (var n = a.eles.edges(), i = a.eles.nodes(), o = mt(a.boundingBox ? a.boundingBox : {
    x1: 0,
    y1: 0,
    w: e.width(),
    h: e.height()
  }), s = {
    isCompound: e.hasCompoundNodes(),
    layoutNodes: [],
    idToIndex: {},
    nodeSize: i.size(),
    graphSet: [],
    indexToGraph: [],
    layoutEdges: [],
    edgeSize: n.size(),
    temperature: a.initialTemp,
    clientWidth: o.w,
    clientHeight: o.h,
    boundingBox: o
  }, u = a.eles.components(), l = {}, f = 0; f < u.length; f++)
    for (var v = u[f], c = 0; c < v.length; c++) {
      var h = v[c];
      l[h.id()] = f;
    }
  for (var f = 0; f < s.nodeSize; f++) {
    var d = i[f], g = d.layoutDimensions(a), p = {};
    p.isLocked = d.locked(), p.id = d.data("id"), p.parentId = d.data("parent"), p.cmptId = l[d.id()], p.children = [], p.positionX = d.position("x"), p.positionY = d.position("y"), p.offsetX = 0, p.offsetY = 0, p.height = g.w, p.width = g.h, p.maxX = p.positionX + p.width / 2, p.minX = p.positionX - p.width / 2, p.maxY = p.positionY + p.height / 2, p.minY = p.positionY - p.height / 2, p.padLeft = parseFloat(d.style("padding")), p.padRight = parseFloat(d.style("padding")), p.padTop = parseFloat(d.style("padding")), p.padBottom = parseFloat(d.style("padding")), p.nodeRepulsion = He(a.nodeRepulsion) ? a.nodeRepulsion(d) : a.nodeRepulsion, s.layoutNodes.push(p), s.idToIndex[p.id] = f;
  }
  for (var y = [], b = 0, m = -1, E = [], f = 0; f < s.nodeSize; f++) {
    var d = s.layoutNodes[f], C = d.parentId;
    C != null ? s.layoutNodes[s.idToIndex[C]].children.push(d.id) : (y[++m] = d.id, E.push(d.id));
  }
  for (s.graphSet.push(E); b <= m; ) {
    var S = y[b++], w = s.idToIndex[S], h = s.layoutNodes[w], x = h.children;
    if (x.length > 0) {
      s.graphSet.push(x);
      for (var f = 0; f < x.length; f++)
        y[++m] = x[f];
    }
  }
  for (var f = 0; f < s.graphSet.length; f++)
    for (var T = s.graphSet[f], c = 0; c < T.length; c++) {
      var D = s.idToIndex[T[c]];
      s.indexToGraph[D] = f;
    }
  for (var f = 0; f < s.edgeSize; f++) {
    var A = n[f], L = {};
    L.id = A.data("id"), L.sourceId = A.data("source"), L.targetId = A.data("target");
    var R = He(a.idealEdgeLength) ? a.idealEdgeLength(A) : a.idealEdgeLength, P = He(a.edgeElasticity) ? a.edgeElasticity(A) : a.edgeElasticity, I = s.idToIndex[L.sourceId], k = s.idToIndex[L.targetId], O = s.indexToGraph[I], N = s.indexToGraph[k];
    if (O != N) {
      for (var F = qp(L.sourceId, L.targetId, s), G = s.graphSet[F], B = 0, p = s.layoutNodes[I]; G.indexOf(p.id) === -1; )
        p = s.layoutNodes[s.idToIndex[p.parentId]], B++;
      for (p = s.layoutNodes[k]; G.indexOf(p.id) === -1; )
        p = s.layoutNodes[s.idToIndex[p.parentId]], B++;
      R *= B * a.nestingFactor;
    }
    L.idealLength = R, L.elasticity = P, s.layoutEdges.push(L);
  }
  return s;
}, qp = function(e, r, a) {
  var n = hv(e, r, 0, a);
  return 2 > n.count ? 0 : n.graph;
}, hv = function(e, r, a, n) {
  var i = n.graphSet[a];
  if (-1 < i.indexOf(e) && -1 < i.indexOf(r))
    return {
      count: 2,
      graph: a
    };
  for (var o = 0, s = 0; s < i.length; s++) {
    var u = i[s], l = n.idToIndex[u], f = n.layoutNodes[l].children;
    if (f.length !== 0) {
      var v = n.indexToGraph[n.idToIndex[f[0]]], c = hv(e, r, v, n);
      if (c.count !== 0)
        if (c.count === 1) {
          if (o++, o === 2)
            break;
        } else
          return c;
    }
  }
  return {
    count: o,
    graph: a
  };
}, Yp, Hp = function(e, r) {
  for (var a = e.clientWidth, n = e.clientHeight, i = 0; i < e.nodeSize; i++) {
    var o = e.layoutNodes[i];
    o.children.length === 0 && !o.isLocked && (o.positionX = Math.random() * a, o.positionY = Math.random() * n);
  }
}, dv = function(e, r, a) {
  var n = e.boundingBox, i = {
    x1: 1 / 0,
    x2: -1 / 0,
    y1: 1 / 0,
    y2: -1 / 0
  };
  return r.boundingBox && (a.forEach(function(o) {
    var s = e.layoutNodes[e.idToIndex[o.data("id")]];
    i.x1 = Math.min(i.x1, s.positionX), i.x2 = Math.max(i.x2, s.positionX), i.y1 = Math.min(i.y1, s.positionY), i.y2 = Math.max(i.y2, s.positionY);
  }), i.w = i.x2 - i.x1, i.h = i.y2 - i.y1), function(o, s) {
    var u = e.layoutNodes[e.idToIndex[o.data("id")]];
    if (r.boundingBox) {
      var l = i.w === 0 ? 0.5 : (u.positionX - i.x1) / i.w, f = i.h === 0 ? 0.5 : (u.positionY - i.y1) / i.h;
      return {
        x: n.x1 + l * n.w,
        y: n.y1 + f * n.h
      };
    } else
      return {
        x: u.positionX,
        y: u.positionY
      };
  };
}, Xp = function(e, r, a) {
  var n = a.layout, i = a.eles.nodes(), o = dv(e, a, i);
  i.positions(o), e.ready !== !0 && (e.ready = !0, n.one("layoutready", a.ready), n.emit({
    type: "layoutready",
    layout: this
  }));
}, Wp = function(e, r, a) {
  $p(e, r), Qp(e), Jp(e, r), jp(e), ey(e);
}, $p = function(e, r) {
  for (var a = 0; a < e.graphSet.length; a++)
    for (var n = e.graphSet[a], i = n.length, o = 0; o < i; o++)
      for (var s = e.layoutNodes[e.idToIndex[n[o]]], u = o + 1; u < i; u++) {
        var l = e.layoutNodes[e.idToIndex[n[u]]];
        Kp(s, l, e, r);
      }
}, Ll = function(e) {
  return -e + 2 * e * Math.random();
}, Kp = function(e, r, a, n) {
  var i = e.cmptId, o = r.cmptId;
  if (!(i !== o && !a.isCompound)) {
    var s = r.positionX - e.positionX, u = r.positionY - e.positionY, l = 1;
    s === 0 && u === 0 && (s = Ll(l), u = Ll(l));
    var f = Zp(e, r, s, u);
    if (f > 0)
      var v = n.nodeOverlap * f, c = Math.sqrt(s * s + u * u), h = v * s / c, d = v * u / c;
    else
      var g = Mn(e, s, u), p = Mn(r, -1 * s, -1 * u), y = p.x - g.x, b = p.y - g.y, m = y * y + b * b, c = Math.sqrt(m), v = (e.nodeRepulsion + r.nodeRepulsion) / m, h = v * y / c, d = v * b / c;
    e.isLocked || (e.offsetX -= h, e.offsetY -= d), r.isLocked || (r.offsetX += h, r.offsetY += d);
  }
}, Zp = function(e, r, a, n) {
  if (a > 0)
    var i = e.maxX - r.minX;
  else
    var i = r.maxX - e.minX;
  if (n > 0)
    var o = e.maxY - r.minY;
  else
    var o = r.maxY - e.minY;
  return i >= 0 && o >= 0 ? Math.sqrt(i * i + o * o) : 0;
}, Mn = function(e, r, a) {
  var n = e.positionX, i = e.positionY, o = e.height || 1, s = e.width || 1, u = a / r, l = o / s, f = {};
  return r === 0 && 0 < a || r === 0 && 0 > a ? (f.x = n, f.y = i + o / 2, f) : 0 < r && -1 * l <= u && u <= l ? (f.x = n + s / 2, f.y = i + s * a / 2 / r, f) : 0 > r && -1 * l <= u && u <= l ? (f.x = n - s / 2, f.y = i - s * a / 2 / r, f) : 0 < a && (u <= -1 * l || u >= l) ? (f.x = n + o * r / 2 / a, f.y = i + o / 2, f) : (0 > a && (u <= -1 * l || u >= l) && (f.x = n - o * r / 2 / a, f.y = i - o / 2), f);
}, Qp = function(e, r) {
  for (var a = 0; a < e.edgeSize; a++) {
    var n = e.layoutEdges[a], i = e.idToIndex[n.sourceId], o = e.layoutNodes[i], s = e.idToIndex[n.targetId], u = e.layoutNodes[s], l = u.positionX - o.positionX, f = u.positionY - o.positionY;
    if (!(l === 0 && f === 0)) {
      var v = Mn(o, l, f), c = Mn(u, -1 * l, -1 * f), h = c.x - v.x, d = c.y - v.y, g = Math.sqrt(h * h + d * d), p = Math.pow(n.idealLength - g, 2) / n.elasticity;
      if (g !== 0)
        var y = p * h / g, b = p * d / g;
      else
        var y = 0, b = 0;
      o.isLocked || (o.offsetX += y, o.offsetY += b), u.isLocked || (u.offsetX -= y, u.offsetY -= b);
    }
  }
}, Jp = function(e, r) {
  if (r.gravity !== 0)
    for (var a = 1, n = 0; n < e.graphSet.length; n++) {
      var i = e.graphSet[n], o = i.length;
      if (n === 0)
        var s = e.clientHeight / 2, u = e.clientWidth / 2;
      else
        var l = e.layoutNodes[e.idToIndex[i[0]]], f = e.layoutNodes[e.idToIndex[l.parentId]], s = f.positionX, u = f.positionY;
      for (var v = 0; v < o; v++) {
        var c = e.layoutNodes[e.idToIndex[i[v]]];
        if (!c.isLocked) {
          var h = s - c.positionX, d = u - c.positionY, g = Math.sqrt(h * h + d * d);
          if (g > a) {
            var p = r.gravity * h / g, y = r.gravity * d / g;
            c.offsetX += p, c.offsetY += y;
          }
        }
      }
    }
}, jp = function(e, r) {
  var a = [], n = 0, i = -1;
  for (a.push.apply(a, e.graphSet[0]), i += e.graphSet[0].length; n <= i; ) {
    var o = a[n++], s = e.idToIndex[o], u = e.layoutNodes[s], l = u.children;
    if (0 < l.length && !u.isLocked) {
      for (var f = u.offsetX, v = u.offsetY, c = 0; c < l.length; c++) {
        var h = e.layoutNodes[e.idToIndex[l[c]]];
        h.offsetX += f, h.offsetY += v, a[++i] = l[c];
      }
      u.offsetX = 0, u.offsetY = 0;
    }
  }
}, ey = function(e, r) {
  for (var a = 0; a < e.nodeSize; a++) {
    var n = e.layoutNodes[a];
    0 < n.children.length && (n.maxX = void 0, n.minX = void 0, n.maxY = void 0, n.minY = void 0);
  }
  for (var a = 0; a < e.nodeSize; a++) {
    var n = e.layoutNodes[a];
    if (!(0 < n.children.length || n.isLocked)) {
      var i = ty(n.offsetX, n.offsetY, e.temperature);
      n.positionX += i.x, n.positionY += i.y, n.offsetX = 0, n.offsetY = 0, n.minX = n.positionX - n.width, n.maxX = n.positionX + n.width, n.minY = n.positionY - n.height, n.maxY = n.positionY + n.height, gv(n, e);
    }
  }
  for (var a = 0; a < e.nodeSize; a++) {
    var n = e.layoutNodes[a];
    0 < n.children.length && !n.isLocked && (n.positionX = (n.maxX + n.minX) / 2, n.positionY = (n.maxY + n.minY) / 2, n.width = n.maxX - n.minX, n.height = n.maxY - n.minY);
  }
}, ty = function(e, r, a) {
  var n = Math.sqrt(e * e + r * r);
  if (n > a)
    var i = {
      x: a * e / n,
      y: a * r / n
    };
  else
    var i = {
      x: e,
      y: r
    };
  return i;
}, gv = function(e, r) {
  var a = e.parentId;
  if (a != null) {
    var n = r.layoutNodes[r.idToIndex[a]], i = !1;
    if ((n.maxX == null || e.maxX + n.padRight > n.maxX) && (n.maxX = e.maxX + n.padRight, i = !0), (n.minX == null || e.minX - n.padLeft < n.minX) && (n.minX = e.minX - n.padLeft, i = !0), (n.maxY == null || e.maxY + n.padBottom > n.maxY) && (n.maxY = e.maxY + n.padBottom, i = !0), (n.minY == null || e.minY - n.padTop < n.minY) && (n.minY = e.minY - n.padTop, i = !0), i)
      return gv(n, r);
  }
}, Rl = function(e, r) {
  for (var a = e.layoutNodes, n = [], i = 0; i < a.length; i++) {
    var o = a[i], s = o.cmptId, u = n[s] = n[s] || [];
    u.push(o);
  }
  for (var l = 0, i = 0; i < n.length; i++) {
    var f = n[i];
    if (f) {
      f.x1 = 1 / 0, f.x2 = -1 / 0, f.y1 = 1 / 0, f.y2 = -1 / 0;
      for (var v = 0; v < f.length; v++) {
        var c = f[v];
        f.x1 = Math.min(f.x1, c.positionX - c.width / 2), f.x2 = Math.max(f.x2, c.positionX + c.width / 2), f.y1 = Math.min(f.y1, c.positionY - c.height / 2), f.y2 = Math.max(f.y2, c.positionY + c.height / 2);
      }
      f.w = f.x2 - f.x1, f.h = f.y2 - f.y1, l += f.w * f.h;
    }
  }
  n.sort(function(b, m) {
    return m.w * m.h - b.w * b.h;
  });
  for (var h = 0, d = 0, g = 0, p = 0, y = Math.sqrt(l) * e.clientWidth / e.clientHeight, i = 0; i < n.length; i++) {
    var f = n[i];
    if (f) {
      for (var v = 0; v < f.length; v++) {
        var c = f[v];
        c.isLocked || (c.positionX += h - f.x1, c.positionY += d - f.y1);
      }
      h += f.w + r.componentSpacing, g += f.w + r.componentSpacing, p = Math.max(p, f.h), g > y && (d += p + r.componentSpacing, h = 0, g = 0, p = 0);
    }
  }
}, ry = {
  fit: !0,
  // whether to fit the viewport to the graph
  padding: 30,
  // padding used on fit
  boundingBox: void 0,
  // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  avoidOverlap: !0,
  // prevents node overlap, may overflow boundingBox if not enough space
  avoidOverlapPadding: 10,
  // extra spacing around nodes when avoidOverlap: true
  nodeDimensionsIncludeLabels: !1,
  // Excludes the label when calculating node bounding boxes for the layout algorithm
  spacingFactor: void 0,
  // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
  condense: !1,
  // uses all available space on false, uses minimal space on true
  rows: void 0,
  // force num of rows in the grid
  cols: void 0,
  // force num of columns in the grid
  position: function(e) {
  },
  // returns { row, col } for element
  sort: void 0,
  // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') }
  animate: !1,
  // whether to transition the node positions
  animationDuration: 500,
  // duration of animation in ms if enabled
  animationEasing: void 0,
  // easing of animation if enabled
  animateFilter: function(e, r) {
    return !0;
  },
  // a function that determines whether the node should be animated.  All nodes animated by default on animate enabled.  Non-animated nodes are positioned immediately when the layout starts
  ready: void 0,
  // callback on layoutready
  stop: void 0,
  // callback on layoutstop
  transform: function(e, r) {
    return r;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts 
};
function pv(t) {
  this.options = ye({}, ry, t);
}
pv.prototype.run = function() {
  var t = this.options, e = t, r = t.cy, a = e.eles, n = a.nodes().not(":parent");
  e.sort && (n = n.sort(e.sort));
  var i = mt(e.boundingBox ? e.boundingBox : {
    x1: 0,
    y1: 0,
    w: r.width(),
    h: r.height()
  });
  if (i.h === 0 || i.w === 0)
    a.nodes().layoutPositions(this, e, function(Y) {
      return {
        x: i.x1,
        y: i.y1
      };
    });
  else {
    var o = n.size(), s = Math.sqrt(o * i.h / i.w), u = Math.round(s), l = Math.round(i.w / i.h * s), f = function($) {
      if ($ == null)
        return Math.min(u, l);
      var X = Math.min(u, l);
      X == u ? u = $ : l = $;
    }, v = function($) {
      if ($ == null)
        return Math.max(u, l);
      var X = Math.max(u, l);
      X == u ? u = $ : l = $;
    }, c = e.rows, h = e.cols != null ? e.cols : e.columns;
    if (c != null && h != null)
      u = c, l = h;
    else if (c != null && h == null)
      u = c, l = Math.ceil(o / u);
    else if (c == null && h != null)
      l = h, u = Math.ceil(o / l);
    else if (l * u > o) {
      var d = f(), g = v();
      (d - 1) * g >= o ? f(d - 1) : (g - 1) * d >= o && v(g - 1);
    } else
      for (; l * u < o; ) {
        var p = f(), y = v();
        (y + 1) * p >= o ? v(y + 1) : f(p + 1);
      }
    var b = i.w / l, m = i.h / u;
    if (e.condense && (b = 0, m = 0), e.avoidOverlap)
      for (var E = 0; E < n.length; E++) {
        var C = n[E], S = C._private.position;
        (S.x == null || S.y == null) && (S.x = 0, S.y = 0);
        var w = C.layoutDimensions(e), x = e.avoidOverlapPadding, T = w.w + x, D = w.h + x;
        b = Math.max(b, T), m = Math.max(m, D);
      }
    for (var A = {}, L = function($, X) {
      return !!A["c-" + $ + "-" + X];
    }, R = function($, X) {
      A["c-" + $ + "-" + X] = !0;
    }, P = 0, I = 0, k = function() {
      I++, I >= l && (I = 0, P++);
    }, O = {}, N = 0; N < n.length; N++) {
      var F = n[N], G = e.position(F);
      if (G && (G.row !== void 0 || G.col !== void 0)) {
        var B = {
          row: G.row,
          col: G.col
        };
        if (B.col === void 0)
          for (B.col = 0; L(B.row, B.col); )
            B.col++;
        else if (B.row === void 0)
          for (B.row = 0; L(B.row, B.col); )
            B.row++;
        O[F.id()] = B, R(B.row, B.col);
      }
    }
    var z = function($, X) {
      var j, ee;
      if ($.locked() || $.isParent())
        return !1;
      var ae = O[$.id()];
      if (ae)
        j = ae.col * b + b / 2 + i.x1, ee = ae.row * m + m / 2 + i.y1;
      else {
        for (; L(P, I); )
          k();
        j = I * b + b / 2 + i.x1, ee = P * m + m / 2 + i.y1, R(P, I), k();
      }
      return {
        x: j,
        y: ee
      };
    };
    n.layoutPositions(this, e, z);
  }
  return this;
};
var ay = {
  ready: function() {
  },
  // on layoutready
  stop: function() {
  }
  // on layoutstop
};
function ys(t) {
  this.options = ye({}, ay, t);
}
ys.prototype.run = function() {
  var t = this.options, e = t.eles, r = this;
  return t.cy, r.emit("layoutstart"), e.nodes().positions(function() {
    return {
      x: 0,
      y: 0
    };
  }), r.one("layoutready", t.ready), r.emit("layoutready"), r.one("layoutstop", t.stop), r.emit("layoutstop"), this;
};
ys.prototype.stop = function() {
  return this;
};
var ny = {
  positions: void 0,
  // map of (node id) => (position obj); or function(node){ return somPos; }
  zoom: void 0,
  // the zoom level to set (prob want fit = false if set)
  pan: void 0,
  // the pan level to set (prob want fit = false if set)
  fit: !0,
  // whether to fit to viewport
  padding: 30,
  // padding on fit
  spacingFactor: void 0,
  // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
  animate: !1,
  // whether to transition the node positions
  animationDuration: 500,
  // duration of animation in ms if enabled
  animationEasing: void 0,
  // easing of animation if enabled
  animateFilter: function(e, r) {
    return !0;
  },
  // a function that determines whether the node should be animated.  All nodes animated by default on animate enabled.  Non-animated nodes are positioned immediately when the layout starts
  ready: void 0,
  // callback on layoutready
  stop: void 0,
  // callback on layoutstop
  transform: function(e, r) {
    return r;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts
};
function yv(t) {
  this.options = ye({}, ny, t);
}
yv.prototype.run = function() {
  var t = this.options, e = t.eles, r = e.nodes(), a = He(t.positions);
  function n(i) {
    if (t.positions == null)
      return Dh(i.position());
    if (a)
      return t.positions(i);
    var o = t.positions[i._private.data.id];
    return o ?? null;
  }
  return r.layoutPositions(this, t, function(i, o) {
    var s = n(i);
    return i.locked() || s == null ? !1 : s;
  }), this;
};
var iy = {
  fit: !0,
  // whether to fit to viewport
  padding: 30,
  // fit padding
  boundingBox: void 0,
  // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  animate: !1,
  // whether to transition the node positions
  animationDuration: 500,
  // duration of animation in ms if enabled
  animationEasing: void 0,
  // easing of animation if enabled
  animateFilter: function(e, r) {
    return !0;
  },
  // a function that determines whether the node should be animated.  All nodes animated by default on animate enabled.  Non-animated nodes are positioned immediately when the layout starts
  ready: void 0,
  // callback on layoutready
  stop: void 0,
  // callback on layoutstop
  transform: function(e, r) {
    return r;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts 
};
function mv(t) {
  this.options = ye({}, iy, t);
}
mv.prototype.run = function() {
  var t = this.options, e = t.cy, r = t.eles, a = mt(t.boundingBox ? t.boundingBox : {
    x1: 0,
    y1: 0,
    w: e.width(),
    h: e.height()
  }), n = function(o, s) {
    return {
      x: a.x1 + Math.round(Math.random() * a.w),
      y: a.y1 + Math.round(Math.random() * a.h)
    };
  };
  return r.nodes().layoutPositions(this, t, n), this;
};
var oy = [{
  name: "breadthfirst",
  impl: fv
}, {
  name: "circle",
  impl: vv
}, {
  name: "concentric",
  impl: cv
}, {
  name: "cose",
  impl: Zn
}, {
  name: "grid",
  impl: pv
}, {
  name: "null",
  impl: ys
}, {
  name: "preset",
  impl: yv
}, {
  name: "random",
  impl: mv
}];
function bv(t) {
  this.options = t, this.notifications = 0;
}
var Ml = function() {
}, Pl = function() {
  throw new Error("A headless instance can not render images");
};
bv.prototype = {
  recalculateRenderedStyle: Ml,
  notify: function() {
    this.notifications++;
  },
  init: Ml,
  isHeadless: function() {
    return !0;
  },
  png: Pl,
  jpg: Pl
};
var ms = {};
ms.arrowShapeWidth = 0.3;
ms.registerArrowShapes = function() {
  var t = this.arrowShapes = {}, e = this, r = function(l, f, v, c, h, d, g) {
    var p = h.x - v / 2 - g, y = h.x + v / 2 + g, b = h.y - v / 2 - g, m = h.y + v / 2 + g, E = p <= l && l <= y && b <= f && f <= m;
    return E;
  }, a = function(l, f, v, c, h) {
    var d = l * Math.cos(c) - f * Math.sin(c), g = l * Math.sin(c) + f * Math.cos(c), p = d * v, y = g * v, b = p + h.x, m = y + h.y;
    return {
      x: b,
      y: m
    };
  }, n = function(l, f, v, c) {
    for (var h = [], d = 0; d < l.length; d += 2) {
      var g = l[d], p = l[d + 1];
      h.push(a(g, p, f, v, c));
    }
    return h;
  }, i = function(l) {
    for (var f = [], v = 0; v < l.length; v++) {
      var c = l[v];
      f.push(c.x, c.y);
    }
    return f;
  }, o = function(l) {
    return l.pstyle("width").pfValue * l.pstyle("arrow-scale").pfValue * 2;
  }, s = function(l, f) {
    de(f) && (f = t[f]), t[l] = ye({
      name: l,
      points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3],
      collide: function(c, h, d, g, p, y) {
        var b = i(n(this.points, d + 2 * y, g, p)), m = xt(c, h, b);
        return m;
      },
      roughCollide: r,
      draw: function(c, h, d, g) {
        var p = n(this.points, h, d, g);
        e.arrowShapeImpl("polygon")(c, p);
      },
      spacing: function(c) {
        return 0;
      },
      gap: o
    }, f);
  };
  s("none", {
    collide: Cn,
    roughCollide: Cn,
    draw: as,
    spacing: Hs,
    gap: Hs
  }), s("triangle", {
    points: [-0.15, -0.3, 0, 0, 0.15, -0.3]
  }), s("arrow", "triangle"), s("triangle-backcurve", {
    points: t.triangle.points,
    controlPoint: [0, -0.15],
    roughCollide: r,
    draw: function(l, f, v, c, h) {
      var d = n(this.points, f, v, c), g = this.controlPoint, p = a(g[0], g[1], f, v, c);
      e.arrowShapeImpl(this.name)(l, d, p);
    },
    gap: function(l) {
      return o(l) * 0.8;
    }
  }), s("triangle-tee", {
    points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0],
    pointsTee: [-0.15, -0.4, -0.15, -0.5, 0.15, -0.5, 0.15, -0.4],
    collide: function(l, f, v, c, h, d, g) {
      var p = i(n(this.points, v + 2 * g, c, h)), y = i(n(this.pointsTee, v + 2 * g, c, h)), b = xt(l, f, p) || xt(l, f, y);
      return b;
    },
    draw: function(l, f, v, c, h) {
      var d = n(this.points, f, v, c), g = n(this.pointsTee, f, v, c);
      e.arrowShapeImpl(this.name)(l, d, g);
    }
  }), s("circle-triangle", {
    radius: 0.15,
    pointsTr: [0, -0.15, 0.15, -0.45, -0.15, -0.45, 0, -0.15],
    collide: function(l, f, v, c, h, d, g) {
      var p = h, y = Math.pow(p.x - l, 2) + Math.pow(p.y - f, 2) <= Math.pow((v + 2 * g) * this.radius, 2), b = i(n(this.points, v + 2 * g, c, h));
      return xt(l, f, b) || y;
    },
    draw: function(l, f, v, c, h) {
      var d = n(this.pointsTr, f, v, c);
      e.arrowShapeImpl(this.name)(l, d, c.x, c.y, this.radius * f);
    },
    spacing: function(l) {
      return e.getArrowWidth(l.pstyle("width").pfValue, l.pstyle("arrow-scale").value) * this.radius;
    }
  }), s("triangle-cross", {
    points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0],
    baseCrossLinePts: [
      -0.15,
      -0.4,
      // first half of the rectangle
      -0.15,
      -0.4,
      0.15,
      -0.4,
      // second half of the rectangle
      0.15,
      -0.4
    ],
    crossLinePts: function(l, f) {
      var v = this.baseCrossLinePts.slice(), c = f / l, h = 3, d = 5;
      return v[h] = v[h] - c, v[d] = v[d] - c, v;
    },
    collide: function(l, f, v, c, h, d, g) {
      var p = i(n(this.points, v + 2 * g, c, h)), y = i(n(this.crossLinePts(v, d), v + 2 * g, c, h)), b = xt(l, f, p) || xt(l, f, y);
      return b;
    },
    draw: function(l, f, v, c, h) {
      var d = n(this.points, f, v, c), g = n(this.crossLinePts(f, h), f, v, c);
      e.arrowShapeImpl(this.name)(l, d, g);
    }
  }), s("vee", {
    points: [-0.15, -0.3, 0, 0, 0.15, -0.3, 0, -0.15],
    gap: function(l) {
      return o(l) * 0.525;
    }
  }), s("circle", {
    radius: 0.15,
    collide: function(l, f, v, c, h, d, g) {
      var p = h, y = Math.pow(p.x - l, 2) + Math.pow(p.y - f, 2) <= Math.pow((v + 2 * g) * this.radius, 2);
      return y;
    },
    draw: function(l, f, v, c, h) {
      e.arrowShapeImpl(this.name)(l, c.x, c.y, this.radius * f);
    },
    spacing: function(l) {
      return e.getArrowWidth(l.pstyle("width").pfValue, l.pstyle("arrow-scale").value) * this.radius;
    }
  }), s("tee", {
    points: [-0.15, 0, -0.15, -0.1, 0.15, -0.1, 0.15, 0],
    spacing: function(l) {
      return 1;
    },
    gap: function(l) {
      return 1;
    }
  }), s("square", {
    points: [-0.15, 0, 0.15, 0, 0.15, -0.3, -0.15, -0.3]
  }), s("diamond", {
    points: [-0.15, -0.15, 0, -0.3, 0.15, -0.15, 0, 0],
    gap: function(l) {
      return l.pstyle("width").pfValue * l.pstyle("arrow-scale").value;
    }
  }), s("chevron", {
    points: [0, 0, -0.15, -0.15, -0.1, -0.2, 0, -0.1, 0.1, -0.2, 0.15, -0.15],
    gap: function(l) {
      return 0.95 * l.pstyle("width").pfValue * l.pstyle("arrow-scale").value;
    }
  });
};
var Pr = {};
Pr.projectIntoViewport = function(t, e) {
  var r = this.cy, a = this.findContainerClientCoords(), n = a[0], i = a[1], o = a[4], s = r.pan(), u = r.zoom(), l = ((t - n) / o - s.x) / u, f = ((e - i) / o - s.y) / u;
  return [l, f];
};
Pr.findContainerClientCoords = function() {
  if (this.containerBB)
    return this.containerBB;
  var t = this.container, e = t.getBoundingClientRect(), r = this.cy.window().getComputedStyle(t), a = function(y) {
    return parseFloat(r.getPropertyValue(y));
  }, n = {
    left: a("padding-left"),
    right: a("padding-right"),
    top: a("padding-top"),
    bottom: a("padding-bottom")
  }, i = {
    left: a("border-left-width"),
    right: a("border-right-width"),
    top: a("border-top-width"),
    bottom: a("border-bottom-width")
  }, o = t.clientWidth, s = t.clientHeight, u = n.left + n.right, l = n.top + n.bottom, f = i.left + i.right, v = e.width / (o + f), c = o - u, h = s - l, d = e.left + n.left + i.left, g = e.top + n.top + i.top;
  return this.containerBB = [d, g, c, h, v];
};
Pr.invalidateContainerClientCoordsCache = function() {
  this.containerBB = null;
};
Pr.findNearestElement = function(t, e, r, a) {
  return this.findNearestElements(t, e, r, a)[0];
};
Pr.findNearestElements = function(t, e, r, a) {
  var n = this, i = this, o = i.getCachedZSortedEles(), s = [], u = i.cy.zoom(), l = i.cy.hasCompoundNodes(), f = (a ? 24 : 8) / u, v = (a ? 8 : 2) / u, c = (a ? 8 : 2) / u, h = 1 / 0, d, g;
  r && (o = o.interactive);
  function p(w, x) {
    if (w.isNode()) {
      if (g)
        return;
      g = w, s.push(w);
    }
    if (w.isEdge() && (x == null || x < h))
      if (d) {
        if (d.pstyle("z-compound-depth").value === w.pstyle("z-compound-depth").value && d.pstyle("z-compound-depth").value === w.pstyle("z-compound-depth").value) {
          for (var T = 0; T < s.length; T++)
            if (s[T].isEdge()) {
              s[T] = w, d = w, h = x ?? h;
              break;
            }
        }
      } else
        s.push(w), d = w, h = x ?? h;
  }
  function y(w) {
    var x = w.outerWidth() + 2 * v, T = w.outerHeight() + 2 * v, D = x / 2, A = T / 2, L = w.position(), R = w.pstyle("corner-radius").value === "auto" ? "auto" : w.pstyle("corner-radius").pfValue, P = w._private.rscratch;
    if (L.x - D <= t && t <= L.x + D && L.y - A <= e && e <= L.y + A) {
      var I = i.nodeShapes[n.getNodeShape(w)];
      if (I.checkPoint(t, e, 0, x, T, L.x, L.y, R, P))
        return p(w, 0), !0;
    }
  }
  function b(w) {
    var x = w._private, T = x.rscratch, D = w.pstyle("width").pfValue, A = w.pstyle("arrow-scale").value, L = D / 2 + f, R = L * L, P = L * 2, N = x.source, F = x.target, I;
    if (T.edgeType === "segments" || T.edgeType === "straight" || T.edgeType === "haystack") {
      for (var k = T.allpts, O = 0; O + 3 < k.length; O += 2)
        if (zh(t, e, k[O], k[O + 1], k[O + 2], k[O + 3], P) && R > (I = Yh(t, e, k[O], k[O + 1], k[O + 2], k[O + 3])))
          return p(w, I), !0;
    } else if (T.edgeType === "bezier" || T.edgeType === "multibezier" || T.edgeType === "self" || T.edgeType === "compound") {
      for (var k = T.allpts, O = 0; O + 5 < T.allpts.length; O += 4)
        if (_h(t, e, k[O], k[O + 1], k[O + 2], k[O + 3], k[O + 4], k[O + 5], P) && R > (I = qh(t, e, k[O], k[O + 1], k[O + 2], k[O + 3], k[O + 4], k[O + 5])))
          return p(w, I), !0;
    }
    for (var N = N || x.source, F = F || x.target, G = n.getArrowWidth(D, A), B = [{
      name: "source",
      x: T.arrowStartX,
      y: T.arrowStartY,
      angle: T.srcArrowAngle
    }, {
      name: "target",
      x: T.arrowEndX,
      y: T.arrowEndY,
      angle: T.tgtArrowAngle
    }, {
      name: "mid-source",
      x: T.midX,
      y: T.midY,
      angle: T.midsrcArrowAngle
    }, {
      name: "mid-target",
      x: T.midX,
      y: T.midY,
      angle: T.midtgtArrowAngle
    }], O = 0; O < B.length; O++) {
      var z = B[O], Y = i.arrowShapes[w.pstyle(z.name + "-arrow-shape").value], $ = w.pstyle("width").pfValue;
      if (Y.roughCollide(t, e, G, z.angle, {
        x: z.x,
        y: z.y
      }, $, f) && Y.collide(t, e, G, z.angle, {
        x: z.x,
        y: z.y
      }, $, f))
        return p(w), !0;
    }
    l && s.length > 0 && (y(N), y(F));
  }
  function m(w, x, T) {
    return yt(w, x, T);
  }
  function E(w, x) {
    var T = w._private, D = c, A;
    x ? A = x + "-" : A = "", w.boundingBox();
    var L = T.labelBounds[x || "main"], R = w.pstyle(A + "label").value, P = w.pstyle("text-events").strValue === "yes";
    if (!(!P || !R)) {
      var I = m(T.rscratch, "labelX", x), k = m(T.rscratch, "labelY", x), O = m(T.rscratch, "labelAngle", x), N = w.pstyle(A + "text-margin-x").pfValue, F = w.pstyle(A + "text-margin-y").pfValue, G = L.x1 - D - N, B = L.x2 + D - N, z = L.y1 - D - F, Y = L.y2 + D - F;
      if (O) {
        var $ = Math.cos(O), X = Math.sin(O), j = function(Z, re) {
          return Z = Z - I, re = re - k, {
            x: Z * $ - re * X + I,
            y: Z * X + re * $ + k
          };
        }, ee = j(G, z), ae = j(G, Y), K = j(B, z), V = j(B, Y), q = [
          // with the margin added after the rotation is applied
          ee.x + N,
          ee.y + F,
          K.x + N,
          K.y + F,
          V.x + N,
          V.y + F,
          ae.x + N,
          ae.y + F
        ];
        if (xt(t, e, q))
          return p(w), !0;
      } else if (ar(L, t, e))
        return p(w), !0;
    }
  }
  for (var C = o.length - 1; C >= 0; C--) {
    var S = o[C];
    S.isNode() ? y(S) || E(S) : b(S) || E(S) || E(S, "source") || E(S, "target");
  }
  return s;
};
Pr.getAllInBox = function(t, e, r, a) {
  var n = this.getCachedZSortedEles().interactive, i = this.cy.zoom(), o = 2 / i, s = [], u = Math.min(t, r), l = Math.max(t, r), f = Math.min(e, a), v = Math.max(e, a);
  t = u, r = l, e = f, a = v;
  var c = mt({
    x1: t,
    y1: e,
    x2: r,
    y2: a
  }), h = [{
    x: c.x1,
    y: c.y1
  }, {
    x: c.x2,
    y: c.y1
  }, {
    x: c.x2,
    y: c.y2
  }, {
    x: c.x1,
    y: c.y2
  }], d = [[h[0], h[1]], [h[1], h[2]], [h[2], h[3]], [h[3], h[0]]];
  function g(Z, re, le) {
    return yt(Z, re, le);
  }
  function p(Z, re) {
    var le = Z._private, Ae = o, we = "";
    Z.boundingBox();
    var me = le.labelBounds.main;
    if (!me)
      return null;
    var ge = g(le.rscratch, "labelX", re), oe = g(le.rscratch, "labelY", re), he = g(le.rscratch, "labelAngle", re), ce = Z.pstyle(we + "text-margin-x").pfValue, Ee = Z.pstyle(we + "text-margin-y").pfValue, be = me.x1 - Ae - ce, De = me.x2 + Ae - ce, Le = me.y1 - Ae - Ee, Ne = me.y2 + Ae - Ee;
    if (he) {
      var Oe = Math.cos(he), Me = Math.sin(he), J = function(_, U) {
        return _ = _ - ge, U = U - oe, {
          x: _ * Oe - U * Me + ge,
          y: _ * Me + U * Oe + oe
        };
      };
      return [J(be, Le), J(De, Le), J(De, Ne), J(be, Ne)];
    } else
      return [{
        x: be,
        y: Le
      }, {
        x: De,
        y: Le
      }, {
        x: De,
        y: Ne
      }, {
        x: be,
        y: Ne
      }];
  }
  function y(Z, re, le, Ae) {
    function we(me, ge, oe) {
      return (oe.y - me.y) * (ge.x - me.x) > (ge.y - me.y) * (oe.x - me.x);
    }
    return we(Z, le, Ae) !== we(re, le, Ae) && we(Z, re, le) !== we(Z, re, Ae);
  }
  for (var b = 0; b < n.length; b++) {
    var m = n[b];
    if (m.isNode()) {
      var E = m, C = E.pstyle("text-events").strValue === "yes", S = E.pstyle("box-selection").strValue, w = E.pstyle("box-select-labels").strValue === "yes";
      if (S === "none")
        continue;
      var x = (S === "overlap" || w) && C, T = E.boundingBox({
        includeNodes: !0,
        includeEdges: !1,
        includeLabels: x
      });
      if (S === "contain") {
        var D = !1;
        if (w && C) {
          var A = p(E);
          A && wi(A, h) && (s.push(E), D = !0);
        }
        !D && Sf(c, T) && s.push(E);
      } else if (S === "overlap" && ss(c, T)) {
        var L = E.boundingBox({
          includeNodes: !0,
          includeEdges: !0,
          includeLabels: !1,
          includeMainLabels: !1,
          includeSourceLabels: !1,
          includeTargetLabels: !1
        }), R = [{
          x: L.x1,
          y: L.y1
        }, {
          x: L.x2,
          y: L.y1
        }, {
          x: L.x2,
          y: L.y2
        }, {
          x: L.x1,
          y: L.y2
        }];
        if (wi(R, h))
          s.push(E);
        else {
          var P = p(E);
          P && wi(P, h) && s.push(E);
        }
      }
    } else {
      var I = m, k = I._private, O = k.rscratch, N = I.pstyle("box-selection").strValue;
      if (N === "none")
        continue;
      if (N === "contain") {
        if (O.startX != null && O.startY != null && !ar(c, O.startX, O.startY) || O.endX != null && O.endY != null && !ar(c, O.endX, O.endY))
          continue;
        if (O.edgeType === "bezier" || O.edgeType === "multibezier" || O.edgeType === "self" || O.edgeType === "compound" || O.edgeType === "segments" || O.edgeType === "haystack") {
          for (var F = k.rstyle.bezierPts || k.rstyle.linePts || k.rstyle.haystackPts, G = !0, B = 0; B < F.length; B++)
            if (!Zs(c, F[B])) {
              G = !1;
              break;
            }
          G && s.push(I);
        } else O.edgeType === "straight" && s.push(I);
      } else if (N === "overlap") {
        var z = !1;
        if (O.startX != null && O.startY != null && O.endX != null && O.endY != null && (ar(c, O.startX, O.startY) || ar(c, O.endX, O.endY)))
          s.push(I), z = !0;
        else if (!z && O.edgeType === "haystack") {
          for (var Y = k.rstyle.haystackPts, $ = 0; $ < Y.length; $++)
            if (Zs(c, Y[$])) {
              s.push(I), z = !0;
              break;
            }
        }
        if (!z) {
          var X = k.rstyle.bezierPts || k.rstyle.linePts || k.rstyle.haystackPts;
          if ((!X || X.length < 2) && O.edgeType === "straight" && O.startX != null && O.startY != null && O.endX != null && O.endY != null && (X = [{
            x: O.startX,
            y: O.startY
          }, {
            x: O.endX,
            y: O.endY
          }]), !X || X.length < 2) continue;
          for (var j = 0; j < X.length - 1; j++) {
            for (var ee = X[j], ae = X[j + 1], K = 0; K < d.length; K++) {
              var V = Qe(d[K], 2), q = V[0], H = V[1];
              if (y(ee, ae, q, H)) {
                s.push(I), z = !0;
                break;
              }
            }
            if (z) break;
          }
        }
      }
    }
  }
  return s;
};
var Pn = {};
Pn.calculateArrowAngles = function(t) {
  var e = t._private.rscratch, r = e.edgeType === "haystack", a = e.edgeType === "bezier", n = e.edgeType === "multibezier", i = e.edgeType === "segments", o = e.edgeType === "compound", s = e.edgeType === "self", u, l, f, v, c, h, y, b;
  if (r ? (f = e.haystackPts[0], v = e.haystackPts[1], c = e.haystackPts[2], h = e.haystackPts[3]) : (f = e.arrowStartX, v = e.arrowStartY, c = e.arrowEndX, h = e.arrowEndY), y = e.midX, b = e.midY, i)
    u = f - e.segpts[0], l = v - e.segpts[1];
  else if (n || o || s || a) {
    var d = e.allpts, g = nt(d[0], d[2], d[4], 0.1), p = nt(d[1], d[3], d[5], 0.1);
    u = f - g, l = v - p;
  } else
    u = f - y, l = v - b;
  e.srcArrowAngle = Ka(u, l);
  var y = e.midX, b = e.midY;
  if (r && (y = (f + c) / 2, b = (v + h) / 2), u = c - f, l = h - v, i) {
    var d = e.allpts;
    if (d.length / 2 % 2 === 0) {
      var m = d.length / 2, E = m - 2;
      u = d[m] - d[E], l = d[m + 1] - d[E + 1];
    } else if (e.isRound)
      u = e.midVector[1], l = -e.midVector[0];
    else {
      var m = d.length / 2 - 1, E = m - 2;
      u = d[m] - d[E], l = d[m + 1] - d[E + 1];
    }
  } else if (n || o || s) {
    var d = e.allpts, C = e.ctrlpts, S, w, x, T;
    if (C.length / 2 % 2 === 0) {
      var D = d.length / 2 - 1, A = D + 2, L = A + 2;
      S = nt(d[D], d[A], d[L], 0), w = nt(d[D + 1], d[A + 1], d[L + 1], 0), x = nt(d[D], d[A], d[L], 1e-4), T = nt(d[D + 1], d[A + 1], d[L + 1], 1e-4);
    } else {
      var A = d.length / 2 - 1, D = A - 2, L = A + 2;
      S = nt(d[D], d[A], d[L], 0.4999), w = nt(d[D + 1], d[A + 1], d[L + 1], 0.4999), x = nt(d[D], d[A], d[L], 0.5), T = nt(d[D + 1], d[A + 1], d[L + 1], 0.5);
    }
    u = x - S, l = T - w;
  }
  if (e.midtgtArrowAngle = Ka(u, l), e.midDispX = u, e.midDispY = l, u *= -1, l *= -1, i) {
    var d = e.allpts;
    if (d.length / 2 % 2 !== 0) {
      if (!e.isRound) {
        var m = d.length / 2 - 1, R = m + 2;
        u = -(d[R] - d[m]), l = -(d[R + 1] - d[m + 1]);
      }
    }
  }
  if (e.midsrcArrowAngle = Ka(u, l), i)
    u = c - e.segpts[e.segpts.length - 2], l = h - e.segpts[e.segpts.length - 1];
  else if (n || o || s || a) {
    var d = e.allpts, P = d.length, g = nt(d[P - 6], d[P - 4], d[P - 2], 0.9), p = nt(d[P - 5], d[P - 3], d[P - 1], 0.9);
    u = c - g, l = h - p;
  } else
    u = c - y, l = h - b;
  e.tgtArrowAngle = Ka(u, l);
};
Pn.getArrowWidth = Pn.getArrowHeight = function(t, e) {
  var r = this.arrowWidthCache = this.arrowWidthCache || {}, a = r[t + ", " + e];
  return a || (a = Math.max(Math.pow(t * 13.37, 0.9), 29) * e, r[t + ", " + e] = a, a);
};
var qo, Yo, zt = {}, St = {}, Il, Ol, Cr, gn, Xt, br, xr, Ft, Fr, an, wv, Ev, Ho, Xo, kl, Nl = function(e, r, a) {
  a.x = r.x - e.x, a.y = r.y - e.y, a.len = Math.sqrt(a.x * a.x + a.y * a.y), a.nx = a.x / a.len, a.ny = a.y / a.len, a.ang = Math.atan2(a.ny, a.nx);
}, sy = function(e, r) {
  r.x = e.x * -1, r.y = e.y * -1, r.nx = e.nx * -1, r.ny = e.ny * -1, r.ang = e.ang > 0 ? -(Math.PI - e.ang) : Math.PI + e.ang;
}, uy = function(e, r, a, n, i) {
  if (e !== kl ? Nl(r, e, zt) : sy(St, zt), Nl(r, a, St), Il = zt.nx * St.ny - zt.ny * St.nx, Ol = zt.nx * St.nx - zt.ny * -St.ny, Xt = Math.asin(Math.max(-1, Math.min(1, Il))), Math.abs(Xt) < 1e-6) {
    qo = r.x, Yo = r.y, xr = Fr = 0;
    return;
  }
  Cr = 1, gn = !1, Ol < 0 ? Xt < 0 ? Xt = Math.PI + Xt : (Xt = Math.PI - Xt, Cr = -1, gn = !0) : Xt > 0 && (Cr = -1, gn = !0), r.radius !== void 0 ? Fr = r.radius : Fr = n, br = Xt / 2, an = Math.min(zt.len / 2, St.len / 2), i ? (Ft = Math.abs(Math.cos(br) * Fr / Math.sin(br)), Ft > an ? (Ft = an, xr = Math.abs(Ft * Math.sin(br) / Math.cos(br))) : xr = Fr) : (Ft = Math.min(an, Fr), xr = Math.abs(Ft * Math.sin(br) / Math.cos(br))), Ho = r.x + St.nx * Ft, Xo = r.y + St.ny * Ft, qo = Ho - St.ny * xr * Cr, Yo = Xo + St.nx * xr * Cr, wv = r.x + zt.nx * Ft, Ev = r.y + zt.ny * Ft, kl = r;
};
function xv(t, e) {
  e.radius === 0 ? t.lineTo(e.cx, e.cy) : t.arc(e.cx, e.cy, e.radius, e.startAngle, e.endAngle, e.counterClockwise);
}
function bs(t, e, r, a) {
  var n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0;
  return a === 0 || e.radius === 0 ? {
    cx: e.x,
    cy: e.y,
    radius: 0,
    startX: e.x,
    startY: e.y,
    stopX: e.x,
    stopY: e.y,
    startAngle: void 0,
    endAngle: void 0,
    counterClockwise: void 0
  } : (uy(t, e, r, a, n), {
    cx: qo,
    cy: Yo,
    radius: xr,
    startX: wv,
    startY: Ev,
    stopX: Ho,
    stopY: Xo,
    startAngle: zt.ang + Math.PI / 2 * Cr,
    endAngle: St.ang - Math.PI / 2 * Cr,
    counterClockwise: gn
  });
}
var Ia = 0.01, ly = Math.sqrt(2 * Ia), gt = {};
gt.findMidptPtsEtc = function(t, e) {
  var r = e.posPts, a = e.intersectionPts, n = e.vectorNormInverse, i, o = t.pstyle("source-endpoint"), s = t.pstyle("target-endpoint"), u = o.units != null && s.units != null, l = function(C, S, w, x) {
    var T = x - S, D = w - C, A = Math.sqrt(D * D + T * T);
    return {
      x: -T / A,
      y: D / A
    };
  }, f = t.pstyle("edge-distances").value;
  switch (f) {
    case "node-position":
      i = r;
      break;
    case "intersection":
      i = a;
      break;
    case "endpoints": {
      if (u) {
        var v = this.manualEndptToPx(t.source()[0], o), c = Qe(v, 2), h = c[0], d = c[1], g = this.manualEndptToPx(t.target()[0], s), p = Qe(g, 2), y = p[0], b = p[1], m = {
          x1: h,
          y1: d,
          x2: y,
          y2: b
        };
        n = l(h, d, y, b), i = m;
      } else
        Fe("Edge ".concat(t.id(), " has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint.  Falling back on edge-distances:intersection (default).")), i = a;
      break;
    }
  }
  return {
    midptPts: i,
    vectorNormInverse: n
  };
};
gt.findHaystackPoints = function(t) {
  for (var e = 0; e < t.length; e++) {
    var r = t[e], a = r._private, n = a.rscratch;
    if (!n.haystack) {
      var i = Math.random() * 2 * Math.PI;
      n.source = {
        x: Math.cos(i),
        y: Math.sin(i)
      }, i = Math.random() * 2 * Math.PI, n.target = {
        x: Math.cos(i),
        y: Math.sin(i)
      };
    }
    var o = a.source, s = a.target, u = o.position(), l = s.position(), f = o.width(), v = s.width(), c = o.height(), h = s.height(), d = r.pstyle("haystack-radius").value, g = d / 2;
    n.haystackPts = n.allpts = [n.source.x * f * g + u.x, n.source.y * c * g + u.y, n.target.x * v * g + l.x, n.target.y * h * g + l.y], n.midX = (n.allpts[0] + n.allpts[2]) / 2, n.midY = (n.allpts[1] + n.allpts[3]) / 2, n.edgeType = "haystack", n.haystack = !0, this.storeEdgeProjections(r), this.calculateArrowAngles(r), this.recalculateEdgeLabelProjections(r), this.calculateLabelAngles(r);
  }
};
gt.findSegmentsPoints = function(t, e) {
  var r = t._private.rscratch, a = t.pstyle("segment-weights"), n = t.pstyle("segment-distances"), i = t.pstyle("segment-radii"), o = t.pstyle("radius-type"), s = Math.min(a.pfValue.length, n.pfValue.length), u = i.pfValue[i.pfValue.length - 1], l = o.pfValue[o.pfValue.length - 1];
  r.edgeType = "segments", r.segpts = [], r.radii = [], r.isArcRadius = [];
  for (var f = 0; f < s; f++) {
    var v = a.pfValue[f], c = n.pfValue[f], h = 1 - v, d = v, g = this.findMidptPtsEtc(t, e), p = g.midptPts, y = g.vectorNormInverse, b = {
      x: p.x1 * h + p.x2 * d,
      y: p.y1 * h + p.y2 * d
    };
    r.segpts.push(b.x + y.x * c, b.y + y.y * c), r.radii.push(i.pfValue[f] !== void 0 ? i.pfValue[f] : u), r.isArcRadius.push((o.pfValue[f] !== void 0 ? o.pfValue[f] : l) === "arc-radius");
  }
};
gt.findLoopPoints = function(t, e, r, a) {
  var n = t._private.rscratch, i = e.dirCounts, o = e.srcPos, s = t.pstyle("control-point-distances"), u = s ? s.pfValue[0] : void 0, l = t.pstyle("loop-direction").pfValue, f = t.pstyle("loop-sweep").pfValue, v = t.pstyle("control-point-step-size").pfValue;
  n.edgeType = "self";
  var c = r, h = v;
  a && (c = 0, h = u);
  var d = l - Math.PI / 2, g = d - f / 2, p = d + f / 2, y = l + "_" + f;
  c = i[y] === void 0 ? i[y] = 0 : ++i[y], n.ctrlpts = [o.x + Math.cos(g) * 1.4 * h * (c / 3 + 1), o.y + Math.sin(g) * 1.4 * h * (c / 3 + 1), o.x + Math.cos(p) * 1.4 * h * (c / 3 + 1), o.y + Math.sin(p) * 1.4 * h * (c / 3 + 1)];
};
gt.findCompoundLoopPoints = function(t, e, r, a) {
  var n = t._private.rscratch;
  n.edgeType = "compound";
  var i = e.srcPos, o = e.tgtPos, s = e.srcW, u = e.srcH, l = e.tgtW, f = e.tgtH, v = t.pstyle("control-point-step-size").pfValue, c = t.pstyle("control-point-distances"), h = c ? c.pfValue[0] : void 0, d = r, g = v;
  a && (d = 0, g = h);
  var p = 50, y = {
    x: i.x - s / 2,
    y: i.y - u / 2
  }, b = {
    x: o.x - l / 2,
    y: o.y - f / 2
  }, m = {
    x: Math.min(y.x, b.x),
    y: Math.min(y.y, b.y)
  }, E = 0.5, C = Math.max(E, Math.log(s * Ia)), S = Math.max(E, Math.log(l * Ia));
  n.ctrlpts = [m.x, m.y - (1 + Math.pow(p, 1.12) / 100) * g * (d / 3 + 1) * C, m.x - (1 + Math.pow(p, 1.12) / 100) * g * (d / 3 + 1) * S, m.y];
};
gt.findStraightEdgePoints = function(t) {
  t._private.rscratch.edgeType = "straight";
};
gt.findBezierPoints = function(t, e, r, a, n) {
  var i = t._private.rscratch, o = t.pstyle("control-point-step-size").pfValue, s = t.pstyle("control-point-distances"), u = t.pstyle("control-point-weights"), l = s && u ? Math.min(s.value.length, u.value.length) : 1, f = s ? s.pfValue[0] : void 0, v = u.value[0], c = a;
  i.edgeType = c ? "multibezier" : "bezier", i.ctrlpts = [];
  for (var h = 0; h < l; h++) {
    var d = (0.5 - e.eles.length / 2 + r) * o * (n ? -1 : 1), g = void 0, p = os(d);
    c && (f = s ? s.pfValue[h] : o, v = u.value[h]), a ? g = f : g = f !== void 0 ? p * f : void 0;
    var y = g !== void 0 ? g : d, b = 1 - v, m = v, E = this.findMidptPtsEtc(t, e), C = E.midptPts, S = E.vectorNormInverse, w = {
      x: C.x1 * b + C.x2 * m,
      y: C.y1 * b + C.y2 * m
    };
    i.ctrlpts.push(w.x + S.x * y, w.y + S.y * y);
  }
};
gt.findTaxiPoints = function(t, e) {
  var r = t._private.rscratch;
  r.edgeType = "segments";
  var a = "vertical", n = "horizontal", i = "leftward", o = "rightward", s = "downward", u = "upward", l = "auto", f = e.posPts, v = e.srcW, c = e.srcH, h = e.tgtW, d = e.tgtH, g = t.pstyle("edge-distances").value, p = g !== "node-position", y = t.pstyle("taxi-direction").value, b = y, m = t.pstyle("taxi-turn"), E = m.units === "%", C = m.pfValue, S = C < 0, w = t.pstyle("taxi-turn-min-distance").pfValue, x = p ? (v + h) / 2 : 0, T = p ? (c + d) / 2 : 0, D = f.x2 - f.x1, A = f.y2 - f.y1, L = function(U, W) {
    return U > 0 ? Math.max(U - W, 0) : Math.min(U + W, 0);
  }, R = L(D, x), P = L(A, T), I = !1;
  b === l ? y = Math.abs(R) > Math.abs(P) ? n : a : b === u || b === s ? (y = a, I = !0) : (b === i || b === o) && (y = n, I = !0);
  var k = y === a, O = k ? P : R, N = k ? A : D, F = os(N), G = !1;
  !(I && (E || S)) && (b === s && N < 0 || b === u && N > 0 || b === i && N > 0 || b === o && N < 0) && (F *= -1, O = F * Math.abs(O), G = !0);
  var B;
  if (E) {
    var z = C < 0 ? 1 + C : C;
    B = z * O;
  } else {
    var Y = C < 0 ? O : 0;
    B = Y + C * F;
  }
  var $ = function(U) {
    return Math.abs(U) < w || Math.abs(U) >= Math.abs(O);
  }, X = $(B), j = $(Math.abs(O) - Math.abs(B)), ee = X || j;
  if (ee && !G)
    if (k) {
      var ae = Math.abs(N) <= c / 2, K = Math.abs(D) <= h / 2;
      if (ae) {
        var V = (f.x1 + f.x2) / 2, q = f.y1, H = f.y2;
        r.segpts = [V, q, V, H];
      } else if (K) {
        var Z = (f.y1 + f.y2) / 2, re = f.x1, le = f.x2;
        r.segpts = [re, Z, le, Z];
      } else
        r.segpts = [f.x1, f.y2];
    } else {
      var Ae = Math.abs(N) <= v / 2, we = Math.abs(A) <= d / 2;
      if (Ae) {
        var me = (f.y1 + f.y2) / 2, ge = f.x1, oe = f.x2;
        r.segpts = [ge, me, oe, me];
      } else if (we) {
        var he = (f.x1 + f.x2) / 2, ce = f.y1, Ee = f.y2;
        r.segpts = [he, ce, he, Ee];
      } else
        r.segpts = [f.x2, f.y1];
    }
  else if (k) {
    var be = f.y1 + B + (p ? c / 2 * F : 0), De = f.x1, Le = f.x2;
    r.segpts = [De, be, Le, be];
  } else {
    var Ne = f.x1 + B + (p ? v / 2 * F : 0), Oe = f.y1, Me = f.y2;
    r.segpts = [Ne, Oe, Ne, Me];
  }
  if (r.isRound) {
    var J = t.pstyle("taxi-radius").value, M = t.pstyle("radius-type").value[0] === "arc-radius";
    r.radii = new Array(r.segpts.length / 2).fill(J), r.isArcRadius = new Array(r.segpts.length / 2).fill(M);
  }
};
gt.tryToCorrectInvalidPoints = function(t, e) {
  var r = t._private.rscratch;
  if (r.edgeType === "bezier") {
    var a = e.srcPos, n = e.tgtPos, i = e.srcW, o = e.srcH, s = e.tgtW, u = e.tgtH, l = e.srcShape, f = e.tgtShape, v = e.srcCornerRadius, c = e.tgtCornerRadius, h = e.srcRs, d = e.tgtRs, g = !ne(r.startX) || !ne(r.startY), p = !ne(r.arrowStartX) || !ne(r.arrowStartY), y = !ne(r.endX) || !ne(r.endY), b = !ne(r.arrowEndX) || !ne(r.arrowEndY), m = 3, E = this.getArrowWidth(t.pstyle("width").pfValue, t.pstyle("arrow-scale").value) * this.arrowShapeWidth, C = m * E, S = Ar({
      x: r.ctrlpts[0],
      y: r.ctrlpts[1]
    }, {
      x: r.startX,
      y: r.startY
    }), w = S < C, x = Ar({
      x: r.ctrlpts[0],
      y: r.ctrlpts[1]
    }, {
      x: r.endX,
      y: r.endY
    }), T = x < C, D = !1;
    if (g || p || w) {
      D = !0;
      var A = {
        // delta
        x: r.ctrlpts[0] - a.x,
        y: r.ctrlpts[1] - a.y
      }, L = Math.sqrt(A.x * A.x + A.y * A.y), R = {
        // normalised delta
        x: A.x / L,
        y: A.y / L
      }, P = Math.max(i, o), I = {
        // *2 radius guarantees outside shape
        x: r.ctrlpts[0] + R.x * 2 * P,
        y: r.ctrlpts[1] + R.y * 2 * P
      }, k = l.intersectLine(a.x, a.y, i, o, I.x, I.y, 0, v, h);
      w ? (r.ctrlpts[0] = r.ctrlpts[0] + R.x * (C - S), r.ctrlpts[1] = r.ctrlpts[1] + R.y * (C - S)) : (r.ctrlpts[0] = k[0] + R.x * C, r.ctrlpts[1] = k[1] + R.y * C);
    }
    if (y || b || T) {
      D = !0;
      var O = {
        // delta
        x: r.ctrlpts[0] - n.x,
        y: r.ctrlpts[1] - n.y
      }, N = Math.sqrt(O.x * O.x + O.y * O.y), F = {
        // normalised delta
        x: O.x / N,
        y: O.y / N
      }, G = Math.max(i, o), B = {
        // *2 radius guarantees outside shape
        x: r.ctrlpts[0] + F.x * 2 * G,
        y: r.ctrlpts[1] + F.y * 2 * G
      }, z = f.intersectLine(n.x, n.y, s, u, B.x, B.y, 0, c, d);
      T ? (r.ctrlpts[0] = r.ctrlpts[0] + F.x * (C - x), r.ctrlpts[1] = r.ctrlpts[1] + F.y * (C - x)) : (r.ctrlpts[0] = z[0] + F.x * C, r.ctrlpts[1] = z[1] + F.y * C);
    }
    D && this.findEndpoints(t);
  }
};
gt.storeAllpts = function(t) {
  var e = t._private.rscratch;
  if (e.edgeType === "multibezier" || e.edgeType === "bezier" || e.edgeType === "self" || e.edgeType === "compound") {
    e.allpts = [], e.allpts.push(e.startX, e.startY);
    for (var r = 0; r + 1 < e.ctrlpts.length; r += 2)
      e.allpts.push(e.ctrlpts[r], e.ctrlpts[r + 1]), r + 3 < e.ctrlpts.length && e.allpts.push((e.ctrlpts[r] + e.ctrlpts[r + 2]) / 2, (e.ctrlpts[r + 1] + e.ctrlpts[r + 3]) / 2);
    e.allpts.push(e.endX, e.endY);
    var a, n;
    e.ctrlpts.length / 2 % 2 === 0 ? (a = e.allpts.length / 2 - 1, e.midX = e.allpts[a], e.midY = e.allpts[a + 1]) : (a = e.allpts.length / 2 - 3, n = 0.5, e.midX = nt(e.allpts[a], e.allpts[a + 2], e.allpts[a + 4], n), e.midY = nt(e.allpts[a + 1], e.allpts[a + 3], e.allpts[a + 5], n));
  } else if (e.edgeType === "straight")
    e.allpts = [e.startX, e.startY, e.endX, e.endY], e.midX = (e.startX + e.endX + e.arrowStartX + e.arrowEndX) / 4, e.midY = (e.startY + e.endY + e.arrowStartY + e.arrowEndY) / 4;
  else if (e.edgeType === "segments") {
    if (e.allpts = [], e.allpts.push(e.startX, e.startY), e.allpts.push.apply(e.allpts, e.segpts), e.allpts.push(e.endX, e.endY), e.isRound) {
      e.roundCorners = [];
      for (var i = 2; i + 3 < e.allpts.length; i += 2) {
        var o = e.radii[i / 2 - 1], s = e.isArcRadius[i / 2 - 1];
        e.roundCorners.push(bs({
          x: e.allpts[i - 2],
          y: e.allpts[i - 1]
        }, {
          x: e.allpts[i],
          y: e.allpts[i + 1],
          radius: o
        }, {
          x: e.allpts[i + 2],
          y: e.allpts[i + 3]
        }, o, s));
      }
    }
    if (e.segpts.length % 4 === 0) {
      var u = e.segpts.length / 2, l = u - 2;
      e.midX = (e.segpts[l] + e.segpts[u]) / 2, e.midY = (e.segpts[l + 1] + e.segpts[u + 1]) / 2;
    } else {
      var f = e.segpts.length / 2 - 1;
      if (!e.isRound)
        e.midX = e.segpts[f], e.midY = e.segpts[f + 1];
      else {
        var v = {
          x: e.segpts[f],
          y: e.segpts[f + 1]
        }, c = e.roundCorners[f / 2];
        if (c.radius === 0) {
          var h = {
            x: e.segpts[f + 2],
            y: e.segpts[f + 3]
          };
          e.midX = v.x, e.midY = v.y, e.midVector = [v.y - h.y, h.x - v.x];
        } else {
          var d = [v.x - c.cx, v.y - c.cy], g = c.radius / Math.sqrt(Math.pow(d[0], 2) + Math.pow(d[1], 2));
          d = d.map(function(p) {
            return p * g;
          }), e.midX = c.cx + d[0], e.midY = c.cy + d[1], e.midVector = d;
        }
      }
    }
  }
};
gt.checkForInvalidEdgeWarning = function(t) {
  var e = t[0]._private.rscratch;
  e.nodesOverlap || ne(e.startX) && ne(e.startY) && ne(e.endX) && ne(e.endY) ? e.loggedErr = !1 : e.loggedErr || (e.loggedErr = !0, Fe("Edge `" + t.id() + "` has invalid endpoints and so it is impossible to draw.  Adjust your edge style (e.g. control points) accordingly or use an alternative edge type.  This is expected behaviour when the source node and the target node overlap."));
};
gt.findEdgeControlPoints = function(t) {
  var e = this;
  if (!(!t || t.length === 0)) {
    for (var r = this, a = r.cy, n = a.hasCompoundNodes(), i = new Wt(), o = function(T, D) {
      return [].concat(En(T), [D ? 1 : 0]).join("-");
    }, s = [], u = [], l = 0; l < t.length; l++) {
      var f = t[l], v = f._private, c = f.pstyle("curve-style").value;
      if (!(f.removed() || !f.takesUpSpace())) {
        if (c === "haystack") {
          u.push(f);
          continue;
        }
        var h = c === "unbundled-bezier" || rr(c, "segments") || c === "straight" || c === "straight-triangle" || rr(c, "taxi"), d = c === "unbundled-bezier" || c === "bezier", g = v.source, p = v.target, y = g.poolIndex(), b = p.poolIndex(), m = [y, b].sort(), E = o(m, h), C = i.get(E);
        C == null && (C = {
          eles: []
        }, s.push({
          pairId: m,
          edgeIsUnbundled: h
        }), i.set(E, C)), C.eles.push(f), h && (C.hasUnbundled = !0), d && (C.hasBezier = !0);
      }
    }
    for (var S = function() {
      var T = s[w], D = T.pairId, A = T.edgeIsUnbundled, L = o(D, A), R = i.get(L), P;
      if (!R.hasUnbundled) {
        var I = R.eles[0].parallelEdges().filter(function(M) {
          return M.isBundledBezier();
        });
        ns(R.eles), I.forEach(function(M) {
          return R.eles.push(M);
        }), R.eles.sort(function(M, _) {
          return M.poolIndex() - _.poolIndex();
        });
      }
      var k = R.eles[0], O = k.source(), N = k.target();
      if (O.poolIndex() > N.poolIndex()) {
        var F = O;
        O = N, N = F;
      }
      var G = R.srcPos = O.position(), B = R.tgtPos = N.position(), z = R.srcW = O.outerWidth(), Y = R.srcH = O.outerHeight(), $ = R.tgtW = N.outerWidth(), X = R.tgtH = N.outerHeight(), j = R.srcShape = r.nodeShapes[e.getNodeShape(O)], ee = R.tgtShape = r.nodeShapes[e.getNodeShape(N)], ae = R.srcCornerRadius = O.pstyle("corner-radius").value === "auto" ? "auto" : O.pstyle("corner-radius").pfValue, K = R.tgtCornerRadius = N.pstyle("corner-radius").value === "auto" ? "auto" : N.pstyle("corner-radius").pfValue, V = R.tgtRs = N._private.rscratch, q = R.srcRs = O._private.rscratch;
      R.dirCounts = {
        north: 0,
        west: 0,
        south: 0,
        east: 0,
        northwest: 0,
        southwest: 0,
        northeast: 0,
        southeast: 0
      };
      for (var H = 0; H < R.eles.length; H++) {
        var Z = R.eles[H], re = Z[0]._private.rscratch, le = Z.pstyle("curve-style").value, Ae = le === "unbundled-bezier" || rr(le, "segments") || rr(le, "taxi"), we = !O.same(Z.source());
        if (!R.calculatedIntersection && O !== N && (R.hasBezier || R.hasUnbundled)) {
          R.calculatedIntersection = !0;
          var me = j.intersectLine(G.x, G.y, z, Y, B.x, B.y, 0, ae, q), ge = R.srcIntn = me, oe = ee.intersectLine(B.x, B.y, $, X, G.x, G.y, 0, K, V), he = R.tgtIntn = oe, ce = R.intersectionPts = {
            x1: me[0],
            x2: oe[0],
            y1: me[1],
            y2: oe[1]
          }, Ee = R.posPts = {
            x1: G.x,
            x2: B.x,
            y1: G.y,
            y2: B.y
          }, be = oe[1] - me[1], De = oe[0] - me[0], Le = Math.sqrt(De * De + be * be);
          ne(Le) && Le >= ly || (Le = Math.sqrt(Math.max(De * De, Ia) + Math.max(be * be, Ia)));
          var Ne = R.vector = {
            x: De,
            y: be
          }, Oe = R.vectorNorm = {
            x: Ne.x / Le,
            y: Ne.y / Le
          }, Me = {
            x: -Oe.y,
            y: Oe.x
          };
          R.nodesOverlap = !ne(Le) || ee.checkPoint(me[0], me[1], 0, $, X, B.x, B.y, K, V) || j.checkPoint(oe[0], oe[1], 0, z, Y, G.x, G.y, ae, q), R.vectorNormInverse = Me, P = {
            nodesOverlap: R.nodesOverlap,
            dirCounts: R.dirCounts,
            calculatedIntersection: !0,
            hasBezier: R.hasBezier,
            hasUnbundled: R.hasUnbundled,
            eles: R.eles,
            srcPos: B,
            srcRs: V,
            tgtPos: G,
            tgtRs: q,
            srcW: $,
            srcH: X,
            tgtW: z,
            tgtH: Y,
            srcIntn: he,
            tgtIntn: ge,
            srcShape: ee,
            tgtShape: j,
            posPts: {
              x1: Ee.x2,
              y1: Ee.y2,
              x2: Ee.x1,
              y2: Ee.y1
            },
            intersectionPts: {
              x1: ce.x2,
              y1: ce.y2,
              x2: ce.x1,
              y2: ce.y1
            },
            vector: {
              x: -Ne.x,
              y: -Ne.y
            },
            vectorNorm: {
              x: -Oe.x,
              y: -Oe.y
            },
            vectorNormInverse: {
              x: -Me.x,
              y: -Me.y
            }
          };
        }
        var J = we ? P : R;
        re.nodesOverlap = J.nodesOverlap, re.srcIntn = J.srcIntn, re.tgtIntn = J.tgtIntn, re.isRound = le.startsWith("round"), n && (O.isParent() || O.isChild() || N.isParent() || N.isChild()) && (O.parents().anySame(N) || N.parents().anySame(O) || O.same(N) && O.isParent()) ? e.findCompoundLoopPoints(Z, J, H, Ae) : O === N ? e.findLoopPoints(Z, J, H, Ae) : le.endsWith("segments") ? e.findSegmentsPoints(Z, J) : le.endsWith("taxi") ? e.findTaxiPoints(Z, J) : le === "straight" || !Ae && R.eles.length % 2 === 1 && H === Math.floor(R.eles.length / 2) ? e.findStraightEdgePoints(Z) : e.findBezierPoints(Z, J, H, Ae, we), e.findEndpoints(Z), e.tryToCorrectInvalidPoints(Z, J), e.checkForInvalidEdgeWarning(Z), e.storeAllpts(Z), e.storeEdgeProjections(Z), e.calculateArrowAngles(Z), e.recalculateEdgeLabelProjections(Z), e.calculateLabelAngles(Z);
      }
    }, w = 0; w < s.length; w++)
      S();
    this.findHaystackPoints(u);
  }
};
function Tv(t) {
  var e = [];
  if (t != null) {
    for (var r = 0; r < t.length; r += 2) {
      var a = t[r], n = t[r + 1];
      e.push({
        x: a,
        y: n
      });
    }
    return e;
  }
}
gt.getSegmentPoints = function(t) {
  var e = t[0]._private.rscratch;
  this.recalculateRenderedStyle(t);
  var r = e.edgeType;
  if (r === "segments")
    return Tv(e.segpts);
};
gt.getControlPoints = function(t) {
  var e = t[0]._private.rscratch;
  this.recalculateRenderedStyle(t);
  var r = e.edgeType;
  if (r === "bezier" || r === "multibezier" || r === "self" || r === "compound")
    return Tv(e.ctrlpts);
};
gt.getEdgeMidpoint = function(t) {
  var e = t[0]._private.rscratch;
  return this.recalculateRenderedStyle(t), {
    x: e.midX,
    y: e.midY
  };
};
var Ua = {};
Ua.manualEndptToPx = function(t, e) {
  var r = this, a = t.position(), n = t.outerWidth(), i = t.outerHeight(), o = t._private.rscratch;
  if (e.value.length === 2) {
    var s = [e.pfValue[0], e.pfValue[1]];
    return e.units[0] === "%" && (s[0] = s[0] * n), e.units[1] === "%" && (s[1] = s[1] * i), s[0] += a.x, s[1] += a.y, s;
  } else {
    var u = e.pfValue[0];
    u = -Math.PI / 2 + u;
    var l = 2 * Math.max(n, i), f = [a.x + Math.cos(u) * l, a.y + Math.sin(u) * l];
    return r.nodeShapes[this.getNodeShape(t)].intersectLine(a.x, a.y, n, i, f[0], f[1], 0, t.pstyle("corner-radius").value === "auto" ? "auto" : t.pstyle("corner-radius").pfValue, o);
  }
};
Ua.findEndpoints = function(t) {
  var e, r, a, n, i = this, o, s = t.source()[0], u = t.target()[0], l = s.position(), f = u.position(), v = t.pstyle("target-arrow-shape").value, c = t.pstyle("source-arrow-shape").value, h = t.pstyle("target-distance-from-node").pfValue, d = t.pstyle("source-distance-from-node").pfValue, g = s._private.rscratch, p = u._private.rscratch, y = t.pstyle("curve-style").value, b = t._private.rscratch, m = b.edgeType, E = rr(y, "taxi"), C = m === "self" || m === "compound", S = m === "bezier" || m === "multibezier" || C, w = m !== "bezier", x = m === "straight" || m === "segments", T = m === "segments", D = S || w || x, A = C || E, L = t.pstyle("source-endpoint"), R = A ? "outside-to-node" : L.value, P = s.pstyle("corner-radius").value === "auto" ? "auto" : s.pstyle("corner-radius").pfValue, I = t.pstyle("target-endpoint"), k = A ? "outside-to-node" : I.value, O = u.pstyle("corner-radius").value === "auto" ? "auto" : u.pstyle("corner-radius").pfValue;
  b.srcManEndpt = L, b.tgtManEndpt = I;
  var N, F, G, B, z = (e = (I == null || (r = I.pfValue) === null || r === void 0 ? void 0 : r.length) === 2 ? I.pfValue : null) !== null && e !== void 0 ? e : [0, 0], Y = (a = (L == null || (n = L.pfValue) === null || n === void 0 ? void 0 : n.length) === 2 ? L.pfValue : null) !== null && a !== void 0 ? a : [0, 0];
  if (S) {
    var $ = [b.ctrlpts[0], b.ctrlpts[1]], X = w ? [b.ctrlpts[b.ctrlpts.length - 2], b.ctrlpts[b.ctrlpts.length - 1]] : $;
    N = X, F = $;
  } else if (x) {
    var j = T ? b.segpts.slice(0, 2) : [f.x + z[0], f.y + z[1]], ee = T ? b.segpts.slice(b.segpts.length - 2) : [l.x + Y[0], l.y + Y[1]];
    N = ee, F = j;
  }
  if (k === "inside-to-node")
    o = [f.x, f.y];
  else if (I.units)
    o = this.manualEndptToPx(u, I);
  else if (k === "outside-to-line")
    o = b.tgtIntn;
  else if (k === "outside-to-node" || k === "outside-to-node-or-label" ? G = N : (k === "outside-to-line" || k === "outside-to-line-or-label") && (G = [l.x, l.y]), o = i.nodeShapes[this.getNodeShape(u)].intersectLine(f.x, f.y, u.outerWidth(), u.outerHeight(), G[0], G[1], 0, O, p), k === "outside-to-node-or-label" || k === "outside-to-line-or-label") {
    var ae = u._private.rscratch, K = ae.labelWidth, V = ae.labelHeight, q = ae.labelX, H = ae.labelY, Z = K / 2, re = V / 2, le = u.pstyle("text-valign").value;
    le = jr(le), le === "top" ? H -= re : le === "bottom" && (H += re);
    var Ae = u.pstyle("text-halign").value;
    Ae = Jr(Ae), Ae === "left" ? q -= Z : Ae === "right" && (q += Z);
    var we = Aa(G[0], G[1], [q - Z, H - re, q + Z, H - re, q + Z, H + re, q - Z, H + re], f.x, f.y);
    if (we.length > 0) {
      var me = l, ge = Er(me, Ur(o)), oe = Er(me, Ur(we)), he = ge;
      if (oe < ge && (o = we, he = oe), we.length > 2) {
        var ce = Er(me, {
          x: we[2],
          y: we[3]
        });
        ce < he && (o = [we[2], we[3]]);
      }
    }
  }
  var Ee = Za(o, N, i.arrowShapes[v].spacing(t) + h), be = Za(o, N, i.arrowShapes[v].gap(t) + h);
  if (b.endX = be[0], b.endY = be[1], b.arrowEndX = Ee[0], b.arrowEndY = Ee[1], R === "inside-to-node")
    o = [l.x, l.y];
  else if (L.units)
    o = this.manualEndptToPx(s, L);
  else if (R === "outside-to-line")
    o = b.srcIntn;
  else if (R === "outside-to-node" || R === "outside-to-node-or-label" ? B = F : (R === "outside-to-line" || R === "outside-to-line-or-label") && (B = [f.x, f.y]), o = i.nodeShapes[this.getNodeShape(s)].intersectLine(l.x, l.y, s.outerWidth(), s.outerHeight(), B[0], B[1], 0, P, g), R === "outside-to-node-or-label" || R === "outside-to-line-or-label") {
    var De = s._private.rscratch, Le = De.labelWidth, Ne = De.labelHeight, Oe = De.labelX, Me = De.labelY, J = Le / 2, M = Ne / 2, _ = s.pstyle("text-valign").value;
    _ = jr(_), _ === "top" ? Me -= M : _ === "bottom" && (Me += M);
    var U = s.pstyle("text-halign").value;
    U = Jr(U), U === "left" ? Oe -= J : U === "right" && (Oe += J);
    var W = Aa(B[0], B[1], [Oe - J, Me - M, Oe + J, Me - M, Oe + J, Me + M, Oe - J, Me + M], l.x, l.y);
    if (W.length > 0) {
      var Q = f, fe = Er(Q, Ur(o)), te = Er(Q, Ur(W)), ie = fe;
      if (te < fe && (o = [W[0], W[1]], ie = te), W.length > 2) {
        var se = Er(Q, {
          x: W[2],
          y: W[3]
        });
        se < ie && (o = [W[2], W[3]]);
      }
    }
  }
  var pe = Za(o, F, i.arrowShapes[c].spacing(t) + d), xe = Za(o, F, i.arrowShapes[c].gap(t) + d);
  b.startX = xe[0], b.startY = xe[1], b.arrowStartX = pe[0], b.arrowStartY = pe[1], D && (!ne(b.startX) || !ne(b.startY) || !ne(b.endX) || !ne(b.endY) ? b.badLine = !0 : b.badLine = !1);
};
Ua.getSourceEndpoint = function(t) {
  var e = t[0]._private.rscratch;
  switch (this.recalculateRenderedStyle(t), e.edgeType) {
    case "haystack":
      return {
        x: e.haystackPts[0],
        y: e.haystackPts[1]
      };
    default:
      return {
        x: e.arrowStartX,
        y: e.arrowStartY
      };
  }
};
Ua.getTargetEndpoint = function(t) {
  var e = t[0]._private.rscratch;
  switch (this.recalculateRenderedStyle(t), e.edgeType) {
    case "haystack":
      return {
        x: e.haystackPts[2],
        y: e.haystackPts[3]
      };
    default:
      return {
        x: e.arrowEndX,
        y: e.arrowEndY
      };
  }
};
var ws = {};
function fy(t, e, r) {
  for (var a = function(l, f, v, c) {
    return nt(l, f, v, c);
  }, n = e._private, i = n.rstyle.bezierPts, o = 0; o < t.bezierProjPcts.length; o++) {
    var s = t.bezierProjPcts[o];
    i.push({
      x: a(r[0], r[2], r[4], s),
      y: a(r[1], r[3], r[5], s)
    });
  }
}
ws.storeEdgeProjections = function(t) {
  var e = t._private, r = e.rscratch, a = r.edgeType;
  if (e.rstyle.bezierPts = null, e.rstyle.linePts = null, e.rstyle.haystackPts = null, a === "multibezier" || a === "bezier" || a === "self" || a === "compound") {
    e.rstyle.bezierPts = [];
    for (var n = 0; n + 5 < r.allpts.length; n += 4)
      fy(this, t, r.allpts.slice(n, n + 6));
  } else if (a === "segments")
    for (var i = e.rstyle.linePts = [], n = 0; n + 1 < r.allpts.length; n += 2)
      i.push({
        x: r.allpts[n],
        y: r.allpts[n + 1]
      });
  else if (a === "haystack") {
    var o = r.haystackPts;
    e.rstyle.haystackPts = [{
      x: o[0],
      y: o[1]
    }, {
      x: o[2],
      y: o[3]
    }];
  }
  e.rstyle.arrowWidth = this.getArrowWidth(t.pstyle("width").pfValue, t.pstyle("arrow-scale").value) * this.arrowShapeWidth;
};
ws.recalculateEdgeProjections = function(t) {
  this.findEdgeControlPoints(t);
};
var qt = {};
qt.recalculateNodeLabelProjection = function(t) {
  var e = t.pstyle("label").strValue;
  if (!sr(e)) {
    var r, a, n = t._private, i = t.width(), o = t.height(), s = t.padding(), u = t.position(), l = t.pstyle("text-halign").strValue, f = t.pstyle("text-valign").strValue, v = n.rscratch, c = n.rstyle;
    switch (l) {
      case "left":
        r = u.x - i / 2 - s;
        break;
      case "left-inside":
        r = u.x - i / 2 + s;
        break;
      case "right":
        r = u.x + i / 2 + s;
        break;
      case "right-inside":
        r = u.x + i / 2 - s;
        break;
      default:
        r = u.x;
    }
    switch (f) {
      case "top":
        a = u.y - o / 2 - s;
        break;
      case "top-inside":
        a = u.y - o / 2 + s;
        break;
      case "bottom":
        a = u.y + o / 2 + s;
        break;
      case "bottom-inside":
        a = u.y + o / 2 - s;
        break;
      default:
        a = u.y;
    }
    v.labelX = r, v.labelY = a, c.labelX = r, c.labelY = a, this.calculateLabelAngles(t), this.applyLabelDimensions(t);
  }
};
var Cv = function(e, r) {
  var a = Math.atan(r / e);
  return e === 0 && a < 0 && (a = a * -1), a;
}, Dv = function(e, r) {
  var a = r.x - e.x, n = r.y - e.y;
  return Cv(a, n);
}, vy = function(e, r, a, n) {
  var i = Sa(0, n - 1e-3, 1), o = Sa(0, n + 1e-3, 1), s = Hr(e, r, a, i), u = Hr(e, r, a, o);
  return Dv(s, u);
};
qt.recalculateEdgeLabelProjections = function(t) {
  var e, r = t._private, a = r.rscratch, n = this, i = {
    mid: t.pstyle("label").strValue,
    source: t.pstyle("source-label").strValue,
    target: t.pstyle("target-label").strValue
  };
  if (i.mid || i.source || i.target) {
    e = {
      x: a.midX,
      y: a.midY
    };
    var o = function(v, c, h) {
      _t(r.rscratch, v, c, h), _t(r.rstyle, v, c, h);
    };
    o("labelX", null, e.x), o("labelY", null, e.y);
    var s = Cv(a.midDispX, a.midDispY);
    o("labelAutoAngle", null, s);
    var u = function() {
      if (u.cache)
        return u.cache;
      for (var v = [], c = 0; c + 5 < a.allpts.length; c += 4) {
        var h = {
          x: a.allpts[c],
          y: a.allpts[c + 1]
        }, d = {
          x: a.allpts[c + 2],
          y: a.allpts[c + 3]
        }, g = {
          x: a.allpts[c + 4],
          y: a.allpts[c + 5]
        };
        v.push({
          p0: h,
          p1: d,
          p2: g,
          startDist: 0,
          length: 0,
          segments: []
        });
      }
      var p = r.rstyle.bezierPts, y = n.bezierProjPcts.length;
      function b(w, x, T, D, A) {
        var L = Ar(x, T), R = w.segments[w.segments.length - 1], P = {
          p0: x,
          p1: T,
          t0: D,
          t1: A,
          startDist: R ? R.startDist + R.length : 0,
          length: L
        };
        w.segments.push(P), w.length += L;
      }
      for (var m = 0; m < v.length; m++) {
        var E = v[m], C = v[m - 1];
        C && (E.startDist = C.startDist + C.length), b(E, E.p0, p[m * y], 0, n.bezierProjPcts[0]);
        for (var S = 0; S < y - 1; S++)
          b(E, p[m * y + S], p[m * y + S + 1], n.bezierProjPcts[S], n.bezierProjPcts[S + 1]);
        b(E, p[m * y + y - 1], E.p2, n.bezierProjPcts[y - 1], 1);
      }
      return u.cache = v;
    }, l = function(v) {
      var c, h = v === "source";
      if (i[v]) {
        var d = t.pstyle(v + "-text-offset").pfValue;
        switch (a.edgeType) {
          case "self":
          case "compound":
          case "bezier":
          case "multibezier": {
            for (var g = u(), p, y = 0, b = 0, m = 0; m < g.length; m++) {
              for (var E = g[h ? m : g.length - 1 - m], C = 0; C < E.segments.length; C++) {
                var S = E.segments[h ? C : E.segments.length - 1 - C], w = m === g.length - 1 && C === E.segments.length - 1;
                if (y = b, b += S.length, b >= d || w) {
                  p = {
                    cp: E,
                    segment: S
                  };
                  break;
                }
              }
              if (p)
                break;
            }
            var x = p.cp, T = p.segment, D = (d - y) / T.length, A = T.t1 - T.t0, L = h ? T.t0 + A * D : T.t1 - A * D;
            L = Sa(0, L, 1), e = Hr(x.p0, x.p1, x.p2, L), c = vy(x.p0, x.p1, x.p2, L);
            break;
          }
          case "straight":
          case "segments":
          case "haystack": {
            for (var R = 0, P, I, k, O, N = a.allpts.length, F = 0; F + 3 < N && (h ? (k = {
              x: a.allpts[F],
              y: a.allpts[F + 1]
            }, O = {
              x: a.allpts[F + 2],
              y: a.allpts[F + 3]
            }) : (k = {
              x: a.allpts[N - 2 - F],
              y: a.allpts[N - 1 - F]
            }, O = {
              x: a.allpts[N - 4 - F],
              y: a.allpts[N - 3 - F]
            }), P = Ar(k, O), I = R, R += P, !(R >= d)); F += 2)
              ;
            var G = d - I, B = G / P;
            B = Sa(0, B, 1), e = Ih(k, O, B), c = Dv(k, O);
            break;
          }
        }
        o("labelX", v, e.x), o("labelY", v, e.y), o("labelAutoAngle", v, c);
      }
    };
    l("source"), l("target"), this.applyLabelDimensions(t);
  }
};
qt.applyLabelDimensions = function(t) {
  this.applyPrefixedLabelDimensions(t), t.isEdge() && (this.applyPrefixedLabelDimensions(t, "source"), this.applyPrefixedLabelDimensions(t, "target"));
};
qt.applyPrefixedLabelDimensions = function(t, e) {
  var r = t._private, a = this.getLabelText(t, e), n = Sr(a, t._private.labelDimsKey);
  if (yt(r.rscratch, "prefixedLabelDimsKey", e) !== n) {
    _t(r.rscratch, "prefixedLabelDimsKey", e, n);
    var i = this.calculateLabelDimensions(t, a), o = t.pstyle("line-height").pfValue, s = t.pstyle("font-size").pfValue, u = t.pstyle("text-wrap").strValue, l = yt(r.rscratch, "labelWrapCachedLines", e) || [], f = u !== "wrap" ? 1 : Math.max(l.length, 1), v = s * o, c = i.width, h = i.height + (f - 1) * (o - 1) * s;
    _t(r.rstyle, "labelWidth", e, c), _t(r.rscratch, "labelWidth", e, c), _t(r.rstyle, "labelHeight", e, h), _t(r.rscratch, "labelHeight", e, h), _t(r.rscratch, "labelLineHeight", e, v), _t(r.rscratch, "labelActualDescent", e, i.labelActualDescent);
  }
};
qt.getLabelText = function(t, e) {
  var r = t._private, a = e ? e + "-" : "", n = t.pstyle(a + "label").strValue, i = t.pstyle("text-transform").value, o = function(Y, $) {
    return $ ? (_t(r.rscratch, Y, e, $), $) : yt(r.rscratch, Y, e);
  };
  if (!n)
    return "";
  i == "none" || (i == "uppercase" ? n = n.toUpperCase() : i == "lowercase" && (n = n.toLowerCase()));
  var s = t.pstyle("text-wrap").value;
  if (s === "wrap") {
    var u = o("labelKey");
    if (u != null && o("labelWrapKey") === u)
      return o("labelWrapCachedText");
    for (var l = "​", f = n.split(`
`), v = t.pstyle("text-max-width").pfValue, c = t.pstyle("text-overflow-wrap").value, h = c === "anywhere", d = [], g = /[\s\u200b]+|$/g, p = 0; p < f.length; p++) {
      var y = f[p], b = this.calculateLabelDimensions(t, y), m = b.width;
      if (h) {
        var E = y.split("").join(l);
        y = E;
      }
      if (m > v) {
        var C = y.matchAll(g), S = "", w = 0, x = Tt(C), T;
        try {
          for (x.s(); !(T = x.n()).done; ) {
            var D = T.value, A = D[0], L = y.substring(w, D.index);
            w = D.index + A.length;
            var R = S.length === 0 ? L : S + L + A, P = this.calculateLabelDimensions(t, R), I = P.width;
            I <= v ? S += L + A : (S && d.push(S), S = L + A);
          }
        } catch (z) {
          x.e(z);
        } finally {
          x.f();
        }
        S.match(/^[\s\u200b]+$/) || d.push(S);
      } else
        d.push(y);
    }
    o("labelWrapCachedLines", d), n = o("labelWrapCachedText", d.join(`
`)), o("labelWrapKey", u);
  } else if (s === "ellipsis") {
    var k = t.pstyle("text-max-width").pfValue, O = "", N = "…", F = !1;
    if (this.calculateLabelDimensions(t, n).width < k)
      return n;
    for (var G = 0; G < n.length; G++) {
      var B = this.calculateLabelDimensions(t, O + n[G] + N).width;
      if (B > k)
        break;
      O += n[G], G === n.length - 1 && (F = !0);
    }
    return F || (O += N), O;
  }
  return n;
};
qt.getLabelJustification = function(t) {
  var e = t.pstyle("text-justification").strValue, r = t.pstyle("text-halign").strValue;
  return e === "auto" ? t.isNode() ? Jg(r) : "center" : e;
};
qt.calculateLabelDimensions = function(t, e) {
  var r = this, a = r.cy.window(), n = a.document, i = 0, o = t.pstyle("font-style").strValue, s = t.pstyle("font-size").pfValue, u = t.pstyle("font-family").strValue, l = t.pstyle("font-weight").strValue, f = t.pstyle("text-metrics").strValue || "font", v = this.labelCalcCanvas, c = this.labelCalcCanvasContext;
  if (!v) {
    v = this.labelCalcCanvas = n.createElement("canvas"), c = this.labelCalcCanvasContext = v.getContext("2d");
    var h = v.style;
    h.position = "absolute", h.left = "-9999px", h.top = "-9999px", h.zIndex = "-1", h.visibility = "hidden", h.pointerEvents = "none";
  }
  c.font = "".concat(o, " ").concat(l, " ").concat(s, "px ").concat(u);
  for (var d = 0, g = 0, p = e.split(`
`), y = p.length, b = 0, m = 0, E = 0; E < y; E++) {
    var C = p[E], S = c.measureText(C), w = Math.ceil(S.width), x = s;
    f === "glyph" && (E === 0 && (m = S.actualBoundingBoxAscent), E === y - 1 && (b = S.actualBoundingBoxDescent)), d = Math.max(w, d), g += x;
  }
  return f === "glyph" && (g -= s - m - b), d += i, g += i, {
    width: d,
    height: g,
    labelActualAscent: m,
    labelActualDescent: b
  };
};
qt.calculateLabelAngle = function(t, e) {
  var r = t._private, a = r.rscratch, n = t.isEdge(), i = e ? e + "-" : "", o = t.pstyle(i + "text-rotation"), s = o.strValue;
  return s === "none" ? 0 : n && s === "autorotate" ? a.labelAutoAngle : s === "autorotate" ? 0 : o.pfValue;
};
qt.calculateLabelAngles = function(t) {
  var e = this, r = t.isEdge(), a = t._private, n = a.rscratch;
  n.labelAngle = e.calculateLabelAngle(t), r && (n.sourceLabelAngle = e.calculateLabelAngle(t, "source"), n.targetLabelAngle = e.calculateLabelAngle(t, "target"));
};
var Sv = {}, Bl = 28, Fl = !1;
Sv.getNodeShape = function(t) {
  var e = this, r = t.pstyle("shape").value;
  if (r === "cutrectangle" && (t.width() < Bl || t.height() < Bl))
    return Fl || (Fe("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"), Fl = !0), "rectangle";
  if (t.isParent())
    return r === "rectangle" || r === "roundrectangle" || r === "round-rectangle" || r === "cutrectangle" || r === "cut-rectangle" || r === "barrel" ? r : "rectangle";
  if (r === "polygon") {
    var a = t.pstyle("shape-polygon-points").value;
    return e.nodeShapes.makePolygon(a).name;
  }
  return r;
};
var Qn = {};
Qn.registerCalculationListeners = function() {
  var t = this.cy, e = t.collection(), r = this, a = function(o) {
    var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
    if (e.merge(o), s)
      for (var u = 0; u < o.length; u++) {
        var l = o[u], f = l._private, v = f.rstyle;
        v.clean = !1, v.cleanConnected = !1;
      }
  };
  r.binder(t).on("bounds.* dirty.*", function(o) {
    var s = o.target;
    a(s);
  }).on("style.* background.*", function(o) {
    var s = o.target;
    a(s, !1);
  });
  var n = function(o) {
    if (o) {
      var s = r.onUpdateEleCalcsFns;
      e.cleanStyle();
      for (var u = 0; u < e.length; u++) {
        var l = e[u], f = l._private.rstyle;
        l.isNode() && !f.cleanConnected && (a(l.connectedEdges()), f.cleanConnected = !0);
      }
      if (s)
        for (var v = 0; v < s.length; v++) {
          var c = s[v];
          c(o, e);
        }
      r.recalculateRenderedStyle(e), e = t.collection();
    }
  };
  r.flushRenderedStyleQueue = function() {
    n(!0);
  }, r.beforeRender(n, r.beforeRenderPriorities.eleCalcs);
};
Qn.onUpdateEleCalcs = function(t) {
  var e = this.onUpdateEleCalcsFns = this.onUpdateEleCalcsFns || [];
  e.push(t);
};
Qn.recalculateRenderedStyle = function(t, e) {
  var r = function(E) {
    return E._private.rstyle.cleanConnected;
  };
  if (t.length !== 0) {
    var a = [], n = [];
    if (!this.destroyed) {
      e === void 0 && (e = !0);
      for (var i = 0; i < t.length; i++) {
        var o = t[i], s = o._private, u = s.rstyle;
        o.isEdge() && (!r(o.source()) || !r(o.target())) && (u.clean = !1), o.isEdge() && o.isBundledBezier() && o.parallelEdges().some(function(m) {
          return !m._private.rstyle.clean && m.isBundledBezier();
        }) && (u.clean = !1), !(e && u.clean || o.removed()) && o.pstyle("display").value !== "none" && (s.group === "nodes" ? n.push(o) : a.push(o), u.clean = !0);
      }
      for (var l = 0; l < n.length; l++) {
        var f = n[l], v = f._private, c = v.rstyle, h = f.position();
        this.recalculateNodeLabelProjection(f), c.nodeX = h.x, c.nodeY = h.y, c.nodeW = f.pstyle("width").pfValue, c.nodeH = f.pstyle("height").pfValue;
      }
      this.recalculateEdgeProjections(a);
      for (var d = 0; d < a.length; d++) {
        var g = a[d], p = g._private, y = p.rstyle, b = p.rscratch;
        y.srcX = b.arrowStartX, y.srcY = b.arrowStartY, y.tgtX = b.arrowEndX, y.tgtY = b.arrowEndY, y.midX = b.midX, y.midY = b.midY, y.labelAngle = b.labelAngle, y.sourceLabelAngle = b.sourceLabelAngle, y.targetLabelAngle = b.targetLabelAngle;
      }
    }
  }
};
var Jn = {};
Jn.updateCachedGrabbedEles = function() {
  var t = this.cachedZSortedEles;
  if (t) {
    t.drag = [], t.nondrag = [];
    for (var e = [], r = 0; r < t.length; r++) {
      var a = t[r], n = a._private.rscratch;
      a.grabbed() && !a.isParent() ? e.push(a) : n.inDragLayer ? t.drag.push(a) : t.nondrag.push(a);
    }
    for (var r = 0; r < e.length; r++) {
      var a = e[r];
      t.drag.push(a);
    }
  }
};
Jn.invalidateCachedZSortedEles = function() {
  this.cachedZSortedEles = null;
};
Jn.getCachedZSortedEles = function(t) {
  if (t || !this.cachedZSortedEles) {
    var e = this.cy.mutableElements().toArray();
    e.sort(sv), e.interactive = e.filter(function(r) {
      return r.interactive();
    }), this.cachedZSortedEles = e, this.updateCachedGrabbedEles();
  } else
    e = this.cachedZSortedEles;
  return e;
};
var Av = {};
[Pr, Pn, gt, Ua, ws, qt, Sv, Qn, Jn].forEach(function(t) {
  ye(Av, t);
});
var Lv = {};
Lv.getCachedImage = function(t, e, r) {
  var a = this, n = a.imageCache = a.imageCache || {}, i = n[t];
  if (i)
    return i.image.complete || i.image.addEventListener("load", r), i.image;
  i = n[t] = n[t] || {};
  var o = i.image = new Image();
  o.addEventListener("load", r), o.addEventListener("error", function() {
    o.error = !0;
  });
  var s = "data:", u = t.substring(0, s.length).toLowerCase() === s;
  return u || (e = e === "null" ? null : e, o.crossOrigin = e), o.src = t, o;
};
var Rv = function(e, r) {
  var a = e[0];
  !a || a._private.grabbed === r || (a._private.grabbed = r, e.updateStyle(!1));
}, cy = function(e) {
  Rv(e, !0);
}, hy = function(e) {
  Rv(e, !1);
}, ia = {};
ia.registerBinding = function(t, e, r, a) {
  var n = Array.prototype.slice.apply(arguments, [1]);
  if (Array.isArray(t)) {
    for (var i = [], o = 0; o < t.length; o++) {
      var s = t[o];
      if (s !== void 0) {
        var u = this.binder(s);
        i.push(u.on.apply(u, n));
      }
    }
    return i;
  }
  var u = this.binder(t);
  return u.on.apply(u, n);
};
ia.binder = function(t) {
  var e = this, r = e.cy.window(), a = t === r || t === r.document || t === r.document.body || xc(t);
  if (e.supportsPassiveEvents == null) {
    var n = !1;
    try {
      var i = Object.defineProperty({}, "passive", {
        get: function() {
          return n = !0, !0;
        }
      });
      r.addEventListener("test", null, i);
    } catch {
    }
    e.supportsPassiveEvents = n;
  }
  var o = function(u, l, f) {
    var v = Array.prototype.slice.call(arguments);
    return a && e.supportsPassiveEvents && (v[2] = {
      capture: f ?? !1,
      passive: !1,
      once: !1
    }), e.bindings.push({
      target: t,
      args: v
    }), (t.addEventListener || t.on).apply(t, v), this;
  };
  return {
    on: o,
    addEventListener: o,
    addListener: o,
    bind: o
  };
};
ia.nodeIsDraggable = function(t) {
  return t && t.isNode() && !t.locked() && t.grabbable();
};
ia.nodeIsGrabbable = function(t) {
  return this.nodeIsDraggable(t) && t.interactive();
};
ia.load = function() {
  var t = this, e = t.cy.window(), r = function(M) {
    return M.selected();
  }, a = function(M) {
    var _ = M.getRootNode();
    if (_ && _.nodeType === 11 && _.host !== void 0)
      return _;
  }, n = function(M, _, U, W) {
    M == null && (M = t.cy);
    for (var Q = 0; Q < _.length; Q++) {
      var fe = _[Q];
      M.emit({
        originalEvent: U,
        type: fe,
        position: W
      });
    }
  }, i = function(M) {
    return M.shiftKey || M.metaKey || M.ctrlKey;
  }, o = function(M, _) {
    var U = !0;
    if (t.cy.hasCompoundNodes() && M && M.pannable())
      for (var W = 0; _ && W < _.length; W++) {
        var M = _[W];
        if (M.isNode() && M.isParent() && !M.pannable()) {
          U = !1;
          break;
        }
      }
    else
      U = !0;
    return U;
  }, s = function(M) {
    M[0]._private.rscratch.inDragLayer = !0;
  }, u = function(M) {
    M[0]._private.rscratch.inDragLayer = !1;
  }, l = function(M) {
    M[0]._private.rscratch.isGrabTarget = !0;
  }, f = function(M) {
    M[0]._private.rscratch.isGrabTarget = !1;
  }, v = function(M, _) {
    var U = _.addToList, W = U.has(M);
    !W && M.grabbable() && !M.locked() && (U.merge(M), cy(M));
  }, c = function(M, _) {
    if (M.cy().hasCompoundNodes() && !(_.inDragLayer == null && _.addToList == null)) {
      var U = M.descendants();
      _.inDragLayer && (U.forEach(s), U.connectedEdges().forEach(s)), _.addToList && v(U, _);
    }
  }, h = function(M, _) {
    _ = _ || {};
    var U = M.cy().hasCompoundNodes();
    _.inDragLayer && (M.forEach(s), M.neighborhood().stdFilter(function(W) {
      return !U || W.isEdge();
    }).forEach(s)), _.addToList && M.forEach(function(W) {
      v(W, _);
    }), c(M, _), p(M, {
      inDragLayer: _.inDragLayer
    }), t.updateCachedGrabbedEles();
  }, d = h, g = function(M) {
    M && (t.getCachedZSortedEles().forEach(function(_) {
      hy(_), u(_), f(_);
    }), t.updateCachedGrabbedEles());
  }, p = function(M, _) {
    if (!(_.inDragLayer == null && _.addToList == null) && M.cy().hasCompoundNodes()) {
      var U = M.ancestors().orphans();
      if (!U.same(M)) {
        var W = U.descendants().spawnSelf().merge(U).unmerge(M).unmerge(M.descendants()), Q = W.connectedEdges();
        _.inDragLayer && (Q.forEach(s), W.forEach(s)), _.addToList && W.forEach(function(fe) {
          v(fe, _);
        });
      }
    }
  }, y = function() {
    document.activeElement != null && document.activeElement.blur != null && document.activeElement.blur();
  }, b = typeof MutationObserver < "u", m = typeof ResizeObserver < "u";
  b ? (t.removeObserver = new MutationObserver(function(J) {
    for (var M = 0; M < J.length; M++) {
      var _ = J[M], U = _.removedNodes;
      if (U)
        for (var W = 0; W < U.length; W++) {
          var Q = U[W];
          if (Q === t.container) {
            t.destroy();
            break;
          }
        }
    }
  }), t.container.parentNode && t.removeObserver.observe(t.container.parentNode, {
    childList: !0
  })) : t.registerBinding(t.container, "DOMNodeRemoved", function(J) {
    t.destroy();
  });
  var E = Ga(function() {
    t.cy.resize();
  }, 100);
  b && (t.styleObserver = new MutationObserver(E), t.styleObserver.observe(t.container, {
    attributes: !0
  })), t.registerBinding(e, "resize", E), m && (t.resizeObserver = new ResizeObserver(E), t.resizeObserver.observe(t.container));
  var C = function(M, _) {
    for (; M != null; )
      _(M), M = M.parentNode;
  }, S = function() {
    t.invalidateContainerClientCoordsCache();
  };
  C(t.container, function(J) {
    t.registerBinding(J, "transitionend", S), t.registerBinding(J, "animationend", S), t.registerBinding(J, "scroll", S);
  }), t.registerBinding(t.container, "contextmenu", function(J) {
    J.preventDefault();
  });
  var w = function() {
    return t.selection[4] !== 0;
  }, x = function(M) {
    for (var _ = t.findContainerClientCoords(), U = _[0], W = _[1], Q = _[2], fe = _[3], te = M.touches ? M.touches : [M], ie = !1, se = 0; se < te.length; se++) {
      var pe = te[se];
      if (U <= pe.clientX && pe.clientX <= U + Q && W <= pe.clientY && pe.clientY <= W + fe) {
        ie = !0;
        break;
      }
    }
    if (!ie)
      return !1;
    for (var xe = t.container, Te = M.target, ve = Te.parentNode, Se = !1; ve; ) {
      if (ve === xe) {
        Se = !0;
        break;
      }
      ve = ve.parentNode;
    }
    return !!Se;
  };
  t.registerBinding(t.container, "mousedown", function(M) {
    if (x(M) && !(t.hoverData.which === 1 && M.which !== 1)) {
      M.preventDefault(), y(), t.hoverData.capture = !0, t.hoverData.which = M.which;
      var _ = t.cy, U = [M.clientX, M.clientY], W = t.projectIntoViewport(U[0], U[1]), Q = t.selection, fe = t.findNearestElements(W[0], W[1], !0, !1), te = fe[0], ie = t.dragData.possibleDragElements;
      t.hoverData.mdownPos = W, t.hoverData.mdownGPos = U;
      var se = function(Re) {
        return {
          originalEvent: M,
          type: Re,
          position: {
            x: W[0],
            y: W[1]
          }
        };
      }, pe = function() {
        t.hoverData.tapholdCancelled = !1, clearTimeout(t.hoverData.tapholdTimeout), t.hoverData.tapholdTimeout = setTimeout(function() {
          if (!t.hoverData.tapholdCancelled) {
            var Re = t.hoverData.down;
            Re ? Re.emit(se("taphold")) : _.emit(se("taphold"));
          }
        }, t.tapholdDuration);
      };
      if (M.which == 3) {
        t.hoverData.cxtStarted = !0;
        var xe = {
          originalEvent: M,
          type: "cxttapstart",
          position: {
            x: W[0],
            y: W[1]
          }
        };
        te ? (te.activate(), te.emit(xe), t.hoverData.down = te) : _.emit(xe), t.hoverData.downTime = (/* @__PURE__ */ new Date()).getTime(), t.hoverData.cxtDragged = !1;
      } else if (M.which == 1) {
        te && te.activate();
        {
          if (te != null && t.nodeIsGrabbable(te)) {
            var Te = function(Re) {
              Re.emit(se("grab"));
            };
            if (l(te), !te.selected())
              ie = t.dragData.possibleDragElements = _.collection(), d(te, {
                addToList: ie
              }), te.emit(se("grabon")).emit(se("grab"));
            else {
              ie = t.dragData.possibleDragElements = _.collection();
              var ve = _.$(function(Se) {
                return Se.isNode() && Se.selected() && t.nodeIsGrabbable(Se);
              });
              h(ve, {
                addToList: ie
              }), te.emit(se("grabon")), ve.forEach(Te);
            }
            t.redrawHint("eles", !0), t.redrawHint("drag", !0);
          }
          t.hoverData.down = te, t.hoverData.downs = fe, t.hoverData.downTime = (/* @__PURE__ */ new Date()).getTime();
        }
        n(te, ["mousedown", "tapstart", "vmousedown"], M, {
          x: W[0],
          y: W[1]
        }), te == null ? (Q[4] = 1, t.data.bgActivePosistion = {
          x: W[0],
          y: W[1]
        }, t.redrawHint("select", !0), t.redraw()) : te.pannable() && (Q[4] = 1), pe();
      }
      Q[0] = Q[2] = W[0], Q[1] = Q[3] = W[1];
    }
  }, !1);
  var T = a(t.container);
  t.registerBinding([e, T], "mousemove", function(M) {
    var _ = t.hoverData.capture;
    if (!(!_ && !x(M))) {
      var U = !1, W = t.cy, Q = W.zoom(), fe = [M.clientX, M.clientY], te = t.projectIntoViewport(fe[0], fe[1]), ie = t.hoverData.mdownPos, se = t.hoverData.mdownGPos, pe = t.selection, xe = null;
      !t.hoverData.draggingEles && !t.hoverData.dragging && !t.hoverData.selecting && (xe = t.findNearestElement(te[0], te[1], !0, !1));
      var Te = t.hoverData.last, ve = t.hoverData.down, Se = [te[0] - pe[2], te[1] - pe[3]], Re = t.dragData.possibleDragElements, at;
      if (se) {
        var Xe = fe[0] - se[0], Rt = Xe * Xe, We = fe[1] - se[1], Ke = We * We, Je = Rt + Ke;
        t.hoverData.isOverThresholdDrag = at = Je >= t.desktopTapThreshold2;
      }
      var st = i(M);
      at && (t.hoverData.tapholdCancelled = !0);
      var Bt = function() {
        var Dt = t.hoverData.dragDelta = t.hoverData.dragDelta || [];
        Dt.length === 0 ? (Dt.push(Se[0]), Dt.push(Se[1])) : (Dt[0] += Se[0], Dt[1] += Se[1]);
      };
      U = !0, n(xe, ["mousemove", "vmousemove", "tapdrag"], M, {
        x: te[0],
        y: te[1]
      });
      var Ye = function(Dt) {
        return {
          originalEvent: M,
          type: Dt,
          position: {
            x: te[0],
            y: te[1]
          }
        };
      }, Ht = function() {
        t.data.bgActivePosistion = void 0, t.hoverData.selecting || W.emit(Ye("boxstart")), pe[4] = 1, t.hoverData.selecting = !0, t.redrawHint("select", !0), t.redraw();
      };
      if (t.hoverData.which === 3) {
        if (at) {
          var Mt = Ye("cxtdrag");
          ve ? ve.emit(Mt) : W.emit(Mt), t.hoverData.cxtDragged = !0, (!t.hoverData.cxtOver || xe !== t.hoverData.cxtOver) && (t.hoverData.cxtOver && t.hoverData.cxtOver.emit(Ye("cxtdragout")), t.hoverData.cxtOver = xe, xe && xe.emit(Ye("cxtdragover")));
        }
      } else if (t.hoverData.dragging) {
        if (U = !0, W.panningEnabled() && W.userPanningEnabled()) {
          var Jt;
          if (t.hoverData.justStartedPan) {
            var Ha = t.hoverData.mdownPos;
            Jt = {
              x: (te[0] - Ha[0]) * Q,
              y: (te[1] - Ha[1]) * Q
            }, t.hoverData.justStartedPan = !1;
          } else
            Jt = {
              x: Se[0] * Q,
              y: Se[1] * Q
            };
          W.panBy(Jt), W.emit(Ye("dragpan")), t.hoverData.dragged = !0;
        }
        te = t.projectIntoViewport(M.clientX, M.clientY);
      } else if (pe[4] == 1 && (ve == null || ve.pannable())) {
        if (at) {
          if (!t.hoverData.dragging && W.boxSelectionEnabled() && (st || !W.panningEnabled() || !W.userPanningEnabled()))
            Ht();
          else if (!t.hoverData.selecting && W.panningEnabled() && W.userPanningEnabled()) {
            var mr = o(ve, t.hoverData.downs);
            mr && (t.hoverData.dragging = !0, t.hoverData.justStartedPan = !0, pe[4] = 0, t.data.bgActivePosistion = Ur(ie), t.redrawHint("select", !0), t.redraw());
          }
          ve && ve.pannable() && ve.active() && ve.unactivate();
        }
      } else {
        if (ve && ve.pannable() && ve.active() && ve.unactivate(), (!ve || !ve.grabbed()) && xe != Te && (Te && n(Te, ["mouseout", "tapdragout"], M, {
          x: te[0],
          y: te[1]
        }), xe && n(xe, ["mouseover", "tapdragover"], M, {
          x: te[0],
          y: te[1]
        }), t.hoverData.last = xe), ve)
          if (at) {
            if (W.boxSelectionEnabled() && st)
              ve && ve.grabbed() && (g(Re), ve.emit(Ye("freeon")), Re.emit(Ye("free")), t.dragData.didDrag && (ve.emit(Ye("dragfreeon")), Re.emit(Ye("dragfree")))), Ht();
            else if (ve && ve.grabbed() && t.nodeIsDraggable(ve)) {
              var wt = !t.dragData.didDrag;
              wt && t.redrawHint("eles", !0), t.dragData.didDrag = !0, t.hoverData.draggingEles || h(Re, {
                inDragLayer: !0
              });
              var ct = {
                x: 0,
                y: 0
              };
              if (ne(Se[0]) && ne(Se[1]) && (ct.x += Se[0], ct.y += Se[1], wt)) {
                var Et = t.hoverData.dragDelta;
                Et && ne(Et[0]) && ne(Et[1]) && (ct.x += Et[0], ct.y += Et[1]);
              }
              t.hoverData.draggingEles = !0, Re.silentShift(ct).emit(Ye("position")).emit(Ye("drag")), t.redrawHint("drag", !0), t.redraw();
            }
          } else
            Bt();
        U = !0;
      }
      if (pe[2] = te[0], pe[3] = te[1], U)
        return M.stopPropagation && M.stopPropagation(), M.preventDefault && M.preventDefault(), !1;
    }
  }, !1);
  var D, A, L;
  t.registerBinding(e, "mouseup", function(M) {
    if (!(t.hoverData.which === 1 && M.which !== 1 && t.hoverData.capture)) {
      var _ = t.hoverData.capture;
      if (_) {
        t.hoverData.capture = !1;
        var U = t.cy, W = t.projectIntoViewport(M.clientX, M.clientY), Q = t.selection, fe = t.findNearestElement(W[0], W[1], !0, !1), te = t.dragData.possibleDragElements, ie = t.hoverData.down, se = i(M);
        t.data.bgActivePosistion && (t.redrawHint("select", !0), t.redraw()), t.hoverData.tapholdCancelled = !0, t.data.bgActivePosistion = void 0, ie && ie.unactivate();
        var pe = function(Xe) {
          return {
            originalEvent: M,
            type: Xe,
            position: {
              x: W[0],
              y: W[1]
            }
          };
        };
        if (t.hoverData.which === 3) {
          var xe = pe("cxttapend");
          if (ie ? ie.emit(xe) : U.emit(xe), !t.hoverData.cxtDragged) {
            var Te = pe("cxttap");
            ie ? ie.emit(Te) : U.emit(Te);
          }
          t.hoverData.cxtDragged = !1, t.hoverData.which = null;
        } else if (t.hoverData.which === 1) {
          if (n(fe, ["mouseup", "tapend", "vmouseup"], M, {
            x: W[0],
            y: W[1]
          }), !t.dragData.didDrag && // didn't move a node around
          !t.hoverData.dragged && // didn't pan
          !t.hoverData.selecting && // not box selection
          !t.hoverData.isOverThresholdDrag && (n(ie, ["click", "tap", "vclick"], M, {
            x: W[0],
            y: W[1]
          }), A = !1, M.timeStamp - L <= U.multiClickDebounceTime() ? (D && clearTimeout(D), A = !0, L = null, n(ie, ["dblclick", "dbltap", "vdblclick"], M, {
            x: W[0],
            y: W[1]
          })) : (D = setTimeout(function() {
            A || n(ie, ["oneclick", "onetap", "voneclick"], M, {
              x: W[0],
              y: W[1]
            });
          }, U.multiClickDebounceTime()), L = M.timeStamp)), ie == null && !t.dragData.didDrag && !t.hoverData.selecting && !t.hoverData.dragged && !i(M) && (U.$(r).unselect(["tapunselect"]), te.length > 0 && t.redrawHint("eles", !0), t.dragData.possibleDragElements = te = U.collection()), fe == ie && !t.dragData.didDrag && !t.hoverData.selecting && fe != null && fe._private.selectable && (t.hoverData.dragging || (U.selectionType() === "additive" || se ? fe.selected() ? fe.unselect(["tapunselect"]) : fe.select(["tapselect"]) : se || (U.$(r).unmerge(fe).unselect(["tapunselect"]), fe.select(["tapselect"]))), t.redrawHint("eles", !0)), t.hoverData.selecting) {
            var ve = U.collection(t.getAllInBox(Q[0], Q[1], Q[2], Q[3]));
            t.redrawHint("select", !0), ve.length > 0 && t.redrawHint("eles", !0), U.emit(pe("boxend"));
            var Se = function(Xe) {
              return Xe.selectable() && !Xe.selected();
            };
            U.selectionType() === "additive" || se || U.$(r).unmerge(ve).unselect(), ve.emit(pe("box")).stdFilter(Se).select().emit(pe("boxselect")), t.redraw();
          }
          if (t.hoverData.dragging && (t.hoverData.dragging = !1, t.redrawHint("select", !0), t.redrawHint("eles", !0), t.redraw()), !Q[4]) {
            t.redrawHint("drag", !0), t.redrawHint("eles", !0);
            var Re = ie && ie.grabbed();
            g(te), Re && (ie.emit(pe("freeon")), te.emit(pe("free")), t.dragData.didDrag && (ie.emit(pe("dragfreeon")), te.emit(pe("dragfree"))));
          }
        }
        Q[4] = 0, t.hoverData.down = null, t.hoverData.cxtStarted = !1, t.hoverData.draggingEles = !1, t.hoverData.selecting = !1, t.hoverData.isOverThresholdDrag = !1, t.dragData.didDrag = !1, t.hoverData.dragged = !1, t.hoverData.dragDelta = [], t.hoverData.mdownPos = null, t.hoverData.mdownGPos = null, t.hoverData.which = null;
      }
    }
  }, !1);
  var R = [], P = 4, I, k = 1e5, O = function(M, _) {
    for (var U = 0; U < M.length; U++)
      if (M[U] % _ !== 0)
        return !1;
    return !0;
  }, N = function(M) {
    for (var _ = Math.abs(M[0]), U = 1; U < M.length; U++)
      if (Math.abs(M[U]) !== _)
        return !1;
    return !0;
  }, F = function(M) {
    var _ = !1, U = M.deltaY;
    if (U == null && (M.wheelDeltaY != null ? U = M.wheelDeltaY / 4 : M.wheelDelta != null && (U = M.wheelDelta / 4)), U !== 0) {
      if (I == null)
        if (R.length >= P) {
          var W = R;
          if (I = O(W, 5), !I) {
            var Q = Math.abs(W[0]);
            I = N(W) && Q > 5;
          }
          if (I)
            for (var fe = 0; fe < W.length; fe++)
              k = Math.min(Math.abs(W[fe]), k);
        } else
          R.push(U), _ = !0;
      else I && (k = Math.min(Math.abs(U), k));
      if (!t.scrollingPage) {
        var te = t.cy, ie = te.zoom(), se = te.pan(), pe = t.projectIntoViewport(M.clientX, M.clientY), xe = [pe[0] * ie + se.x, pe[1] * ie + se.y];
        if (t.hoverData.draggingEles || t.hoverData.dragging || t.hoverData.cxtStarted || w()) {
          M.preventDefault();
          return;
        }
        if (te.panningEnabled() && te.userPanningEnabled() && te.zoomingEnabled() && te.userZoomingEnabled()) {
          M.preventDefault(), t.data.wheelZooming = !0, clearTimeout(t.data.wheelTimeout), t.data.wheelTimeout = setTimeout(function() {
            t.data.wheelZooming = !1, t.redrawHint("eles", !0), t.redraw();
          }, 150);
          var Te;
          _ && Math.abs(U) > 5 && (U = os(U) * 5), Te = U / -250, I && (Te /= k, Te *= 3), Te = Te * t.wheelSensitivity;
          var ve = M.deltaMode === 1;
          ve && (Te *= 33);
          var Se = te.zoom() * Math.pow(10, Te);
          M.type === "gesturechange" && (Se = t.gestureStartZoom * M.scale), te.zoom({
            level: Se,
            renderedPosition: {
              x: xe[0],
              y: xe[1]
            }
          }), te.emit({
            type: M.type === "gesturechange" ? "pinchzoom" : "scrollzoom",
            originalEvent: M,
            position: {
              x: pe[0],
              y: pe[1]
            }
          });
        }
      }
    }
  };
  t.registerBinding(t.container, "wheel", F, !0), t.registerBinding(e, "scroll", function(M) {
    t.scrollingPage = !0, clearTimeout(t.scrollingPageTimeout), t.scrollingPageTimeout = setTimeout(function() {
      t.scrollingPage = !1;
    }, 250);
  }, !0), t.registerBinding(t.container, "gesturestart", function(M) {
    t.gestureStartZoom = t.cy.zoom(), t.hasTouchStarted || M.preventDefault();
  }, !0), t.registerBinding(t.container, "gesturechange", function(J) {
    t.hasTouchStarted || F(J);
  }, !0), t.registerBinding(t.container, "mouseout", function(M) {
    var _ = t.projectIntoViewport(M.clientX, M.clientY);
    t.cy.emit({
      originalEvent: M,
      type: "mouseout",
      position: {
        x: _[0],
        y: _[1]
      }
    });
  }, !1), t.registerBinding(t.container, "mouseover", function(M) {
    var _ = t.projectIntoViewport(M.clientX, M.clientY);
    t.cy.emit({
      originalEvent: M,
      type: "mouseover",
      position: {
        x: _[0],
        y: _[1]
      }
    });
  }, !1);
  var G, B, z, Y, $, X, j, ee, ae, K, V, q, H, Z = function(M, _, U, W) {
    return Math.sqrt((U - M) * (U - M) + (W - _) * (W - _));
  }, re = function(M, _, U, W) {
    return (U - M) * (U - M) + (W - _) * (W - _);
  }, le;
  t.registerBinding(t.container, "touchstart", le = function(M) {
    if (t.hasTouchStarted = !0, !!x(M)) {
      y(), t.touchData.capture = !0, t.data.bgActivePosistion = void 0;
      var _ = t.cy, U = t.touchData.now, W = t.touchData.earlier;
      if (M.touches[0]) {
        var Q = t.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
        U[0] = Q[0], U[1] = Q[1];
      }
      if (M.touches[1]) {
        var Q = t.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
        U[2] = Q[0], U[3] = Q[1];
      }
      if (M.touches[2]) {
        var Q = t.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
        U[4] = Q[0], U[5] = Q[1];
      }
      var fe = function(st) {
        return {
          originalEvent: M,
          type: st,
          position: {
            x: U[0],
            y: U[1]
          }
        };
      };
      if (M.touches[1]) {
        t.touchData.singleTouchMoved = !0, g(t.dragData.touchDragEles);
        var te = t.findContainerClientCoords();
        ae = te[0], K = te[1], V = te[2], q = te[3], G = M.touches[0].clientX - ae, B = M.touches[0].clientY - K, z = M.touches[1].clientX - ae, Y = M.touches[1].clientY - K, H = 0 <= G && G <= V && 0 <= z && z <= V && 0 <= B && B <= q && 0 <= Y && Y <= q;
        var ie = _.pan(), se = _.zoom();
        $ = Z(G, B, z, Y), X = re(G, B, z, Y), j = [(G + z) / 2, (B + Y) / 2], ee = [(j[0] - ie.x) / se, (j[1] - ie.y) / se];
        var pe = 200, xe = pe * pe;
        if (X < xe && !M.touches[2]) {
          var Te = t.findNearestElement(U[0], U[1], !0, !0), ve = t.findNearestElement(U[2], U[3], !0, !0);
          Te && Te.isNode() ? (Te.activate().emit(fe("cxttapstart")), t.touchData.start = Te) : ve && ve.isNode() ? (ve.activate().emit(fe("cxttapstart")), t.touchData.start = ve) : _.emit(fe("cxttapstart")), t.touchData.start && (t.touchData.start._private.grabbed = !1), t.touchData.cxt = !0, t.touchData.cxtDragged = !1, t.data.bgActivePosistion = void 0, t.redraw();
          return;
        }
      }
      if (M.touches[2])
        _.boxSelectionEnabled() && M.preventDefault();
      else if (!M.touches[1]) {
        if (M.touches[0]) {
          var Se = t.findNearestElements(U[0], U[1], !0, !0), Re = Se[0];
          if (Re != null && (Re.activate(), t.touchData.start = Re, t.touchData.starts = Se, t.nodeIsGrabbable(Re))) {
            var at = t.dragData.touchDragEles = _.collection(), Xe = null;
            t.redrawHint("eles", !0), t.redrawHint("drag", !0), Re.selected() ? (Xe = _.$(function(Je) {
              return Je.selected() && t.nodeIsGrabbable(Je);
            }), h(Xe, {
              addToList: at
            })) : d(Re, {
              addToList: at
            }), l(Re), Re.emit(fe("grabon")), Xe ? Xe.forEach(function(Je) {
              Je.emit(fe("grab"));
            }) : Re.emit(fe("grab"));
          }
          n(Re, ["touchstart", "tapstart", "vmousedown"], M, {
            x: U[0],
            y: U[1]
          }), Re == null && (t.data.bgActivePosistion = {
            x: Q[0],
            y: Q[1]
          }, t.redrawHint("select", !0), t.redraw()), t.touchData.singleTouchMoved = !1, t.touchData.singleTouchStartTime = +/* @__PURE__ */ new Date(), clearTimeout(t.touchData.tapholdTimeout), t.touchData.tapholdTimeout = setTimeout(function() {
            t.touchData.singleTouchMoved === !1 && !t.pinching && !t.touchData.selecting && n(t.touchData.start, ["taphold"], M, {
              x: U[0],
              y: U[1]
            });
          }, t.tapholdDuration);
        }
      }
      if (M.touches.length >= 1) {
        for (var Rt = t.touchData.startPosition = [null, null, null, null, null, null], We = 0; We < U.length; We++)
          Rt[We] = W[We] = U[We];
        var Ke = M.touches[0];
        t.touchData.startGPosition = [Ke.clientX, Ke.clientY];
      }
    }
  }, !1);
  var Ae;
  t.registerBinding(e, "touchmove", Ae = function(M) {
    var _ = t.touchData.capture;
    if (!(!_ && !x(M))) {
      var U = t.selection, W = t.cy, Q = t.touchData.now, fe = t.touchData.earlier, te = W.zoom();
      if (M.touches[0]) {
        var ie = t.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
        Q[0] = ie[0], Q[1] = ie[1];
      }
      if (M.touches[1]) {
        var ie = t.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
        Q[2] = ie[0], Q[3] = ie[1];
      }
      if (M.touches[2]) {
        var ie = t.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
        Q[4] = ie[0], Q[5] = ie[1];
      }
      var se = function(oc) {
        return {
          originalEvent: M,
          type: oc,
          position: {
            x: Q[0],
            y: Q[1]
          }
        };
      }, pe = t.touchData.startGPosition, xe;
      if (_ && M.touches[0] && pe) {
        for (var Te = [], ve = 0; ve < Q.length; ve++)
          Te[ve] = Q[ve] - fe[ve];
        var Se = M.touches[0].clientX - pe[0], Re = Se * Se, at = M.touches[0].clientY - pe[1], Xe = at * at, Rt = Re + Xe;
        xe = Rt >= t.touchTapThreshold2;
      }
      if (_ && t.touchData.cxt) {
        M.preventDefault();
        var We = M.touches[0].clientX - ae, Ke = M.touches[0].clientY - K, Je = M.touches[1].clientX - ae, st = M.touches[1].clientY - K, Bt = re(We, Ke, Je, st), Ye = Bt / X, Ht = 150, Mt = Ht * Ht, Jt = 1.5, Ha = Jt * Jt;
        if (Ye >= Ha || Bt >= Mt) {
          t.touchData.cxt = !1, t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
          var mr = se("cxttapend");
          t.touchData.start ? (t.touchData.start.unactivate().emit(mr), t.touchData.start = null) : W.emit(mr);
        }
      }
      if (_ && t.touchData.cxt) {
        var mr = se("cxtdrag");
        t.data.bgActivePosistion = void 0, t.redrawHint("select", !0), t.touchData.start ? t.touchData.start.emit(mr) : W.emit(mr), t.touchData.start && (t.touchData.start._private.grabbed = !1), t.touchData.cxtDragged = !0;
        var wt = t.findNearestElement(Q[0], Q[1], !0, !0);
        (!t.touchData.cxtOver || wt !== t.touchData.cxtOver) && (t.touchData.cxtOver && t.touchData.cxtOver.emit(se("cxtdragout")), t.touchData.cxtOver = wt, wt && wt.emit(se("cxtdragover")));
      } else if (_ && M.touches[2] && W.boxSelectionEnabled())
        M.preventDefault(), t.data.bgActivePosistion = void 0, this.lastThreeTouch = +/* @__PURE__ */ new Date(), t.touchData.selecting || W.emit(se("boxstart")), t.touchData.selecting = !0, t.touchData.didSelect = !0, U[4] = 1, !U || U.length === 0 || U[0] === void 0 ? (U[0] = (Q[0] + Q[2] + Q[4]) / 3, U[1] = (Q[1] + Q[3] + Q[5]) / 3, U[2] = (Q[0] + Q[2] + Q[4]) / 3 + 1, U[3] = (Q[1] + Q[3] + Q[5]) / 3 + 1) : (U[2] = (Q[0] + Q[2] + Q[4]) / 3, U[3] = (Q[1] + Q[3] + Q[5]) / 3), t.redrawHint("select", !0), t.redraw();
      else if (_ && M.touches[1] && !t.touchData.didSelect && W.zoomingEnabled() && W.panningEnabled() && W.userZoomingEnabled() && W.userPanningEnabled()) {
        M.preventDefault(), t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
        var ct = t.dragData.touchDragEles;
        if (ct) {
          t.redrawHint("drag", !0);
          for (var Et = 0; Et < ct.length; Et++) {
            var sa = ct[Et]._private;
            sa.grabbed = !1, sa.rscratch.inDragLayer = !1;
          }
        }
        var Dt = t.touchData.start, We = M.touches[0].clientX - ae, Ke = M.touches[0].clientY - K, Je = M.touches[1].clientX - ae, st = M.touches[1].clientY - K, Ts = Z(We, Ke, Je, st), Qv = Ts / $;
        if (H) {
          var Jv = We - G, jv = Ke - B, ec = Je - z, tc = st - Y, rc = (Jv + ec) / 2, ac = (jv + tc) / 2, ua = W.zoom(), jn = ua * Qv, Xa = W.pan(), Cs = ee[0] * ua + Xa.x, Ds = ee[1] * ua + Xa.y, nc = {
            x: -jn / ua * (Cs - Xa.x - rc) + Cs,
            y: -jn / ua * (Ds - Xa.y - ac) + Ds
          };
          if (Dt && Dt.active()) {
            var ct = t.dragData.touchDragEles;
            g(ct), t.redrawHint("drag", !0), t.redrawHint("eles", !0), Dt.unactivate().emit(se("freeon")), ct.emit(se("free")), t.dragData.didDrag && (Dt.emit(se("dragfreeon")), ct.emit(se("dragfree")));
          }
          W.viewport({
            zoom: jn,
            pan: nc,
            cancelOnFailedZoom: !0
          }), W.emit(se("pinchzoom")), $ = Ts, G = We, B = Ke, z = Je, Y = st, t.pinching = !0;
        }
        if (M.touches[0]) {
          var ie = t.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
          Q[0] = ie[0], Q[1] = ie[1];
        }
        if (M.touches[1]) {
          var ie = t.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
          Q[2] = ie[0], Q[3] = ie[1];
        }
        if (M.touches[2]) {
          var ie = t.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
          Q[4] = ie[0], Q[5] = ie[1];
        }
      } else if (M.touches[0] && !t.touchData.didSelect) {
        var Pt = t.touchData.start, ei = t.touchData.last, wt;
        if (!t.hoverData.draggingEles && !t.swipePanning && (wt = t.findNearestElement(Q[0], Q[1], !0, !0)), _ && Pt != null && M.preventDefault(), _ && Pt != null && t.nodeIsDraggable(Pt))
          if (xe) {
            var ct = t.dragData.touchDragEles, Ss = !t.dragData.didDrag;
            Ss && h(ct, {
              inDragLayer: !0
            }), t.dragData.didDrag = !0;
            var la = {
              x: 0,
              y: 0
            };
            if (ne(Te[0]) && ne(Te[1]) && (la.x += Te[0], la.y += Te[1], Ss)) {
              t.redrawHint("eles", !0);
              var It = t.touchData.dragDelta;
              It && ne(It[0]) && ne(It[1]) && (la.x += It[0], la.y += It[1]);
            }
            t.hoverData.draggingEles = !0, ct.silentShift(la).emit(se("position")).emit(se("drag")), t.redrawHint("drag", !0), t.touchData.startPosition[0] == fe[0] && t.touchData.startPosition[1] == fe[1] && t.redrawHint("eles", !0), t.redraw();
          } else {
            var It = t.touchData.dragDelta = t.touchData.dragDelta || [];
            It.length === 0 ? (It.push(Te[0]), It.push(Te[1])) : (It[0] += Te[0], It[1] += Te[1]);
          }
        if (n(Pt || wt, ["touchmove", "tapdrag", "vmousemove"], M, {
          x: Q[0],
          y: Q[1]
        }), (!Pt || !Pt.grabbed()) && wt != ei && (ei && ei.emit(se("tapdragout")), wt && wt.emit(se("tapdragover"))), t.touchData.last = wt, _)
          for (var Et = 0; Et < Q.length; Et++)
            Q[Et] && t.touchData.startPosition[Et] && xe && (t.touchData.singleTouchMoved = !0);
        if (_ && (Pt == null || Pt.pannable()) && W.panningEnabled() && W.userPanningEnabled()) {
          var ic = o(Pt, t.touchData.starts);
          ic && (M.preventDefault(), t.data.bgActivePosistion || (t.data.bgActivePosistion = Ur(t.touchData.startPosition)), t.swipePanning ? (W.panBy({
            x: Te[0] * te,
            y: Te[1] * te
          }), W.emit(se("dragpan"))) : xe && (t.swipePanning = !0, W.panBy({
            x: Se * te,
            y: at * te
          }), W.emit(se("dragpan")), Pt && (Pt.unactivate(), t.redrawHint("select", !0), t.touchData.start = null)));
          var ie = t.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
          Q[0] = ie[0], Q[1] = ie[1];
        }
      }
      for (var ve = 0; ve < Q.length; ve++)
        fe[ve] = Q[ve];
      _ && M.touches.length > 0 && !t.hoverData.draggingEles && !t.swipePanning && t.data.bgActivePosistion != null && (t.data.bgActivePosistion = void 0, t.redrawHint("select", !0), t.redraw());
    }
  }, !1);
  var we;
  t.registerBinding(e, "touchcancel", we = function(M) {
    var _ = t.touchData.start;
    t.touchData.capture = !1, _ && _.unactivate();
  });
  var me, ge, oe, he;
  if (t.registerBinding(e, "touchend", me = function(M) {
    var _ = t.touchData.start, U = t.touchData.capture;
    if (U)
      M.touches.length === 0 && (t.touchData.capture = !1), M.preventDefault();
    else
      return;
    var W = t.selection;
    t.swipePanning = !1, t.hoverData.draggingEles = !1;
    var Q = t.cy, fe = Q.zoom(), te = t.touchData.now, ie = t.touchData.earlier;
    if (M.touches[0]) {
      var se = t.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
      te[0] = se[0], te[1] = se[1];
    }
    if (M.touches[1]) {
      var se = t.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
      te[2] = se[0], te[3] = se[1];
    }
    if (M.touches[2]) {
      var se = t.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
      te[4] = se[0], te[5] = se[1];
    }
    var pe = function(Mt) {
      return {
        originalEvent: M,
        type: Mt,
        position: {
          x: te[0],
          y: te[1]
        }
      };
    };
    _ && _.unactivate();
    var xe;
    if (t.touchData.cxt) {
      if (xe = pe("cxttapend"), _ ? _.emit(xe) : Q.emit(xe), !t.touchData.cxtDragged) {
        var Te = pe("cxttap");
        _ ? _.emit(Te) : Q.emit(Te);
      }
      t.touchData.start && (t.touchData.start._private.grabbed = !1), t.touchData.cxt = !1, t.touchData.start = null, t.redraw();
      return;
    }
    if (!M.touches[2] && Q.boxSelectionEnabled() && t.touchData.selecting) {
      t.touchData.selecting = !1;
      var ve = Q.collection(t.getAllInBox(W[0], W[1], W[2], W[3]));
      W[0] = void 0, W[1] = void 0, W[2] = void 0, W[3] = void 0, W[4] = 0, t.redrawHint("select", !0), Q.emit(pe("boxend"));
      var Se = function(Mt) {
        return Mt.selectable() && !Mt.selected();
      };
      ve.emit(pe("box")).stdFilter(Se).select().emit(pe("boxselect")), ve.nonempty() && t.redrawHint("eles", !0), t.redraw();
    }
    if (_?.unactivate(), M.touches[2])
      t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
    else if (!M.touches[1]) {
      if (!M.touches[0]) {
        if (!M.touches[0]) {
          t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
          var Re = t.dragData.touchDragEles;
          if (_ != null) {
            var at = _._private.grabbed;
            g(Re), t.redrawHint("drag", !0), t.redrawHint("eles", !0), at && (_.emit(pe("freeon")), Re.emit(pe("free")), t.dragData.didDrag && (_.emit(pe("dragfreeon")), Re.emit(pe("dragfree")))), n(_, ["touchend", "tapend", "vmouseup", "tapdragout"], M, {
              x: te[0],
              y: te[1]
            }), _.unactivate(), t.touchData.start = null;
          } else {
            var Xe = t.findNearestElement(te[0], te[1], !0, !0);
            n(Xe, ["touchend", "tapend", "vmouseup", "tapdragout"], M, {
              x: te[0],
              y: te[1]
            });
          }
          var Rt = t.touchData.startPosition[0] - te[0], We = Rt * Rt, Ke = t.touchData.startPosition[1] - te[1], Je = Ke * Ke, st = We + Je, Bt = st * fe * fe;
          t.touchData.singleTouchMoved || (_ || Q.$(":selected").unselect(["tapunselect"]), n(_, ["tap", "vclick"], M, {
            x: te[0],
            y: te[1]
          }), ge = !1, M.timeStamp - he <= Q.multiClickDebounceTime() ? (oe && clearTimeout(oe), ge = !0, he = null, n(_, ["dbltap", "vdblclick"], M, {
            x: te[0],
            y: te[1]
          })) : (oe = setTimeout(function() {
            ge || n(_, ["onetap", "voneclick"], M, {
              x: te[0],
              y: te[1]
            });
          }, Q.multiClickDebounceTime()), he = M.timeStamp)), _ != null && !t.dragData.didDrag && _._private.selectable && Bt < t.touchTapThreshold2 && !t.pinching && (Q.selectionType() === "single" ? (Q.$(r).unmerge(_).unselect(["tapunselect"]), _.select(["tapselect"])) : _.selected() ? _.unselect(["tapunselect"]) : _.select(["tapselect"]), t.redrawHint("eles", !0)), t.touchData.singleTouchMoved = !0;
        }
      }
    }
    for (var Ye = 0; Ye < te.length; Ye++)
      ie[Ye] = te[Ye];
    t.dragData.didDrag = !1, M.touches.length === 0 && (t.touchData.dragDelta = [], t.touchData.startPosition = [null, null, null, null, null, null], t.touchData.startGPosition = null, t.touchData.didSelect = !1), M.touches.length < 2 && (M.touches.length === 1 && (t.touchData.startGPosition = [M.touches[0].clientX, M.touches[0].clientY]), t.pinching = !1, t.redrawHint("eles", !0), t.redraw());
  }, !1), typeof TouchEvent > "u") {
    var ce = [], Ee = function(M) {
      return {
        clientX: M.clientX,
        clientY: M.clientY,
        force: 1,
        identifier: M.pointerId,
        pageX: M.pageX,
        pageY: M.pageY,
        radiusX: M.width / 2,
        radiusY: M.height / 2,
        screenX: M.screenX,
        screenY: M.screenY,
        target: M.target
      };
    }, be = function(M) {
      return {
        event: M,
        touch: Ee(M)
      };
    }, De = function(M) {
      ce.push(be(M));
    }, Le = function(M) {
      for (var _ = 0; _ < ce.length; _++) {
        var U = ce[_];
        if (U.event.pointerId === M.pointerId) {
          ce.splice(_, 1);
          return;
        }
      }
    }, Ne = function(M) {
      var _ = ce.filter(function(U) {
        return U.event.pointerId === M.pointerId;
      })[0];
      _.event = M, _.touch = Ee(M);
    }, Oe = function(M) {
      M.touches = ce.map(function(_) {
        return _.touch;
      });
    }, Me = function(M) {
      return M.pointerType === "mouse" || M.pointerType === 4;
    };
    t.registerBinding(t.container, "pointerdown", function(J) {
      Me(J) || (J.preventDefault(), De(J), Oe(J), le(J));
    }), t.registerBinding(t.container, "pointerup", function(J) {
      Me(J) || (Le(J), Oe(J), me(J));
    }), t.registerBinding(t.container, "pointercancel", function(J) {
      Me(J) || (Le(J), Oe(J), we(J));
    }), t.registerBinding(t.container, "pointermove", function(J) {
      Me(J) || (J.preventDefault(), Ne(J), Oe(J), Ae(J));
    });
  }
};
var Zt = {};
Zt.generatePolygon = function(t, e) {
  return this.nodeShapes[t] = {
    renderer: this,
    name: t,
    points: e,
    draw: function(a, n, i, o, s, u) {
      this.renderer.nodeShapeImpl("polygon", a, n, i, o, s, this.points);
    },
    intersectLine: function(a, n, i, o, s, u, l, f) {
      return Aa(s, u, this.points, a, n, i / 2, o / 2, l);
    },
    checkPoint: function(a, n, i, o, s, u, l, f) {
      return Kt(a, n, this.points, u, l, o, s, [0, -1], i);
    },
    hasMiterBounds: t !== "rectangle",
    miterBounds: function(a, n, i, o, s, u) {
      return Gh(this.points, a, n, i, o, s);
    }
  };
};
Zt.generateEllipse = function() {
  return this.nodeShapes.ellipse = {
    renderer: this,
    name: "ellipse",
    draw: function(e, r, a, n, i, o) {
      this.renderer.nodeShapeImpl(this.name, e, r, a, n, i);
    },
    intersectLine: function(e, r, a, n, i, o, s, u) {
      return Xh(i, o, e, r, a / 2 + s, n / 2 + s);
    },
    checkPoint: function(e, r, a, n, i, o, s, u) {
      return Dr(e, r, n, i, o, s, a);
    }
  };
};
Zt.generateRoundPolygon = function(t, e) {
  return this.nodeShapes[t] = {
    renderer: this,
    name: t,
    points: e,
    getOrCreateCorners: function(a, n, i, o, s, u, l) {
      if (u[l] !== void 0 && u[l + "-cx"] === a && u[l + "-cy"] === n)
        return u[l];
      u[l] = new Array(e.length / 2), u[l + "-cx"] = a, u[l + "-cy"] = n;
      var f = i / 2, v = o / 2;
      s = s === "auto" ? Rf(i, o) : s;
      for (var c = new Array(e.length / 2), h = 0; h < e.length / 2; h++)
        c[h] = {
          x: a + f * e[h * 2],
          y: n + v * e[h * 2 + 1]
        };
      var d, g, p, y, b = c.length;
      for (g = c[b - 1], d = 0; d < b; d++)
        p = c[d % b], y = c[(d + 1) % b], u[l][d] = bs(g, p, y, s), g = p, p = y;
      return u[l];
    },
    draw: function(a, n, i, o, s, u, l) {
      this.renderer.nodeShapeImpl("round-polygon", a, n, i, o, s, this.points, this.getOrCreateCorners(n, i, o, s, u, l, "drawCorners"));
    },
    intersectLine: function(a, n, i, o, s, u, l, f, v) {
      return $h(s, u, this.points, a, n, i, o, l, this.getOrCreateCorners(a, n, i, o, f, v, "corners"));
    },
    checkPoint: function(a, n, i, o, s, u, l, f, v) {
      return Hh(a, n, this.points, u, l, o, s, this.getOrCreateCorners(u, l, o, s, f, v, "corners"));
    }
  };
};
Zt.generateRoundRectangle = function() {
  return this.nodeShapes["round-rectangle"] = this.nodeShapes.roundrectangle = {
    renderer: this,
    name: "round-rectangle",
    points: pt(4, 0),
    draw: function(e, r, a, n, i, o) {
      this.renderer.nodeShapeImpl(this.name, e, r, a, n, i, this.points, o);
    },
    intersectLine: function(e, r, a, n, i, o, s, u) {
      return Af(i, o, e, r, a, n, s, u);
    },
    checkPoint: function(e, r, a, n, i, o, s, u) {
      var l = n / 2, f = i / 2;
      u = u === "auto" ? lr(n, i) : u, u = Math.min(l, f, u);
      var v = u * 2;
      return !!(Kt(e, r, this.points, o, s, n, i - v, [0, -1], a) || Kt(e, r, this.points, o, s, n - v, i, [0, -1], a) || Dr(e, r, v, v, o - l + u, s - f + u, a) || Dr(e, r, v, v, o + l - u, s - f + u, a) || Dr(e, r, v, v, o + l - u, s + f - u, a) || Dr(e, r, v, v, o - l + u, s + f - u, a));
    }
  };
};
Zt.generateCutRectangle = function() {
  return this.nodeShapes["cut-rectangle"] = this.nodeShapes.cutrectangle = {
    renderer: this,
    name: "cut-rectangle",
    cornerLength: us(),
    points: pt(4, 0),
    draw: function(e, r, a, n, i, o) {
      this.renderer.nodeShapeImpl(this.name, e, r, a, n, i, null, o);
    },
    generateCutTrianglePts: function(e, r, a, n, i) {
      var o = i === "auto" ? this.cornerLength : i, s = r / 2, u = e / 2, l = a - u, f = a + u, v = n - s, c = n + s;
      return {
        topLeft: [l, v + o, l + o, v, l + o, v + o],
        topRight: [f - o, v, f, v + o, f - o, v + o],
        bottomRight: [f, c - o, f - o, c, f - o, c - o],
        bottomLeft: [l + o, c, l, c - o, l + o, c - o]
      };
    },
    intersectLine: function(e, r, a, n, i, o, s, u) {
      var l = this.generateCutTrianglePts(a + 2 * s, n + 2 * s, e, r, u), f = [].concat.apply([], [l.topLeft.splice(0, 4), l.topRight.splice(0, 4), l.bottomRight.splice(0, 4), l.bottomLeft.splice(0, 4)]);
      return Aa(i, o, f, e, r);
    },
    checkPoint: function(e, r, a, n, i, o, s, u) {
      var l = u === "auto" ? this.cornerLength : u;
      if (Kt(e, r, this.points, o, s, n, i - 2 * l, [0, -1], a) || Kt(e, r, this.points, o, s, n - 2 * l, i, [0, -1], a))
        return !0;
      var f = this.generateCutTrianglePts(n, i, o, s);
      return xt(e, r, f.topLeft) || xt(e, r, f.topRight) || xt(e, r, f.bottomRight) || xt(e, r, f.bottomLeft);
    }
  };
};
Zt.generateBarrel = function() {
  return this.nodeShapes.barrel = {
    renderer: this,
    name: "barrel",
    points: pt(4, 0),
    draw: function(e, r, a, n, i, o) {
      this.renderer.nodeShapeImpl(this.name, e, r, a, n, i);
    },
    intersectLine: function(e, r, a, n, i, o, s, u) {
      var l = 0.15, f = 0.5, v = 0.85, c = this.generateBarrelBezierPts(a + 2 * s, n + 2 * s, e, r), h = function(p) {
        var y = Hr({
          x: p[0],
          y: p[1]
        }, {
          x: p[2],
          y: p[3]
        }, {
          x: p[4],
          y: p[5]
        }, l), b = Hr({
          x: p[0],
          y: p[1]
        }, {
          x: p[2],
          y: p[3]
        }, {
          x: p[4],
          y: p[5]
        }, f), m = Hr({
          x: p[0],
          y: p[1]
        }, {
          x: p[2],
          y: p[3]
        }, {
          x: p[4],
          y: p[5]
        }, v);
        return [p[0], p[1], y.x, y.y, b.x, b.y, m.x, m.y, p[4], p[5]];
      }, d = [].concat(h(c.topLeft), h(c.topRight), h(c.bottomRight), h(c.bottomLeft));
      return Aa(i, o, d, e, r);
    },
    generateBarrelBezierPts: function(e, r, a, n) {
      var i = r / 2, o = e / 2, s = a - o, u = a + o, l = n - i, f = n + i, v = ko(e, r), c = v.heightOffset, h = v.widthOffset, d = v.ctrlPtOffsetPct * e, g = {
        topLeft: [s, l + c, s + d, l, s + h, l],
        topRight: [u - h, l, u - d, l, u, l + c],
        bottomRight: [u, f - c, u - d, f, u - h, f],
        bottomLeft: [s + h, f, s + d, f, s, f - c]
      };
      return g.topLeft.isTop = !0, g.topRight.isTop = !0, g.bottomLeft.isBottom = !0, g.bottomRight.isBottom = !0, g;
    },
    checkPoint: function(e, r, a, n, i, o, s, u) {
      var l = ko(n, i), f = l.heightOffset, v = l.widthOffset;
      if (Kt(e, r, this.points, o, s, n, i - 2 * f, [0, -1], a) || Kt(e, r, this.points, o, s, n - 2 * v, i, [0, -1], a))
        return !0;
      for (var c = this.generateBarrelBezierPts(n, i, o, s), h = function(x, T, D) {
        var A = D[4], L = D[2], R = D[0], P = D[5], I = D[1], k = Math.min(A, R), O = Math.max(A, R), N = Math.min(P, I), F = Math.max(P, I);
        if (k <= x && x <= O && N <= T && T <= F) {
          var G = Kh(A, L, R), B = Vh(G[0], G[1], G[2], x), z = B.filter(function(Y) {
            return 0 <= Y && Y <= 1;
          });
          if (z.length > 0)
            return z[0];
        }
        return null;
      }, d = Object.keys(c), g = 0; g < d.length; g++) {
        var p = d[g], y = c[p], b = h(e, r, y);
        if (b != null) {
          var m = y[5], E = y[3], C = y[1], S = nt(m, E, C, b);
          if (y.isTop && S <= r || y.isBottom && r <= S)
            return !0;
        }
      }
      return !1;
    }
  };
};
Zt.generateBottomRoundrectangle = function() {
  return this.nodeShapes["bottom-round-rectangle"] = this.nodeShapes.bottomroundrectangle = {
    renderer: this,
    name: "bottom-round-rectangle",
    points: pt(4, 0),
    draw: function(e, r, a, n, i, o) {
      this.renderer.nodeShapeImpl(this.name, e, r, a, n, i, this.points, o);
    },
    intersectLine: function(e, r, a, n, i, o, s, u) {
      var l = e - (a / 2 + s), f = r - (n / 2 + s), v = f, c = e + (a / 2 + s), h = nr(i, o, e, r, l, f, c, v, !1);
      return h.length > 0 ? h : Af(i, o, e, r, a, n, s, u);
    },
    checkPoint: function(e, r, a, n, i, o, s, u) {
      u = u === "auto" ? lr(n, i) : u;
      var l = 2 * u;
      if (Kt(e, r, this.points, o, s, n, i - l, [0, -1], a) || Kt(e, r, this.points, o, s, n - l, i, [0, -1], a))
        return !0;
      var f = n / 2 + 2 * a, v = i / 2 + 2 * a, c = [o - f, s - v, o - f, s, o + f, s, o + f, s - v];
      return !!(xt(e, r, c) || Dr(e, r, l, l, o + n / 2 - u, s + i / 2 - u, a) || Dr(e, r, l, l, o - n / 2 + u, s + i / 2 - u, a));
    }
  };
};
Zt.registerNodeShapes = function() {
  var t = this.nodeShapes = {}, e = this;
  this.generateEllipse(), this.generatePolygon("triangle", pt(3, 0)), this.generateRoundPolygon("round-triangle", pt(3, 0)), this.generatePolygon("rectangle", pt(4, 0)), t.square = t.rectangle, this.generateRoundRectangle(), this.generateCutRectangle(), this.generateBarrel(), this.generateBottomRoundrectangle();
  {
    var r = [0, 1, 1, 0, 0, -1, -1, 0];
    this.generatePolygon("diamond", r), this.generateRoundPolygon("round-diamond", r);
  }
  this.generatePolygon("pentagon", pt(5, 0)), this.generateRoundPolygon("round-pentagon", pt(5, 0)), this.generatePolygon("hexagon", pt(6, 0)), this.generateRoundPolygon("round-hexagon", pt(6, 0)), this.generatePolygon("heptagon", pt(7, 0)), this.generateRoundPolygon("round-heptagon", pt(7, 0)), this.generatePolygon("octagon", pt(8, 0)), this.generateRoundPolygon("round-octagon", pt(8, 0));
  var a = new Array(20);
  {
    var n = Oo(5, 0), i = Oo(5, Math.PI / 5), o = 0.5 * (3 - Math.sqrt(5));
    o *= 1.57;
    for (var s = 0; s < i.length / 2; s++)
      i[s * 2] *= o, i[s * 2 + 1] *= o;
    for (var s = 0; s < 20 / 4; s++)
      a[s * 4] = n[s * 2], a[s * 4 + 1] = n[s * 2 + 1], a[s * 4 + 2] = i[s * 2], a[s * 4 + 3] = i[s * 2 + 1];
  }
  a = Lf(a), this.generatePolygon("star", a), this.generatePolygon("vee", [-1, -1, 0, -0.333, 1, -1, 0, 1]), this.generatePolygon("rhomboid", [-1, -1, 0.333, -1, 1, 1, -0.333, 1]), this.generatePolygon("right-rhomboid", [-0.333, -1, 1, -1, 0.333, 1, -1, 1]), this.nodeShapes.concavehexagon = this.generatePolygon("concave-hexagon", [-1, -0.95, -0.75, 0, -1, 0.95, 1, 0.95, 0.75, 0, 1, -0.95]);
  {
    var u = [-1, -1, 0.25, -1, 1, 0, 0.25, 1, -1, 1];
    this.generatePolygon("tag", u), this.generateRoundPolygon("round-tag", u);
  }
  t.makePolygon = function(l) {
    var f = l.join("$"), v = "polygon-" + f, c;
    return (c = this[v]) ? c : e.generatePolygon(v, l);
  };
};
var qa = {};
qa.timeToRender = function() {
  return this.redrawTotalTime / this.redrawCount;
};
qa.redraw = function(t) {
  t = t || Tf();
  var e = this;
  e.averageRedrawTime === void 0 && (e.averageRedrawTime = 0), e.lastRedrawTime === void 0 && (e.lastRedrawTime = 0), e.lastDrawTime === void 0 && (e.lastDrawTime = 0), e.requestedFrame = !0, e.renderOptions = t;
};
qa.beforeRender = function(t, e) {
  if (!this.destroyed) {
    e == null && qe("Priority is not optional for beforeRender");
    var r = this.beforeRenderCallbacks;
    r.push({
      fn: t,
      priority: e
    }), r.sort(function(a, n) {
      return n.priority - a.priority;
    });
  }
};
var Gl = function(e, r, a) {
  for (var n = e.beforeRenderCallbacks, i = 0; i < n.length; i++)
    n[i].fn(r, a);
};
qa.startRenderLoop = function() {
  var t = this, e = t.cy;
  if (!t.renderLoopStarted) {
    t.renderLoopStarted = !0;
    var r = function(n) {
      if (!t.destroyed) {
        if (!e.batching()) if (t.requestedFrame && !t.skipFrame) {
          Gl(t, !0, n);
          var i = $t();
          t.render(t.renderOptions);
          var o = t.lastDrawTime = $t();
          t.averageRedrawTime === void 0 && (t.averageRedrawTime = o - i), t.redrawCount === void 0 && (t.redrawCount = 0), t.redrawCount++, t.redrawTotalTime === void 0 && (t.redrawTotalTime = 0);
          var s = o - i;
          t.redrawTotalTime += s, t.lastRedrawTime = s, t.averageRedrawTime = t.averageRedrawTime / 2 + s / 2, t.requestedFrame = !1;
        } else
          Gl(t, !1, n);
        t.skipFrame = !1, Tn(r);
      }
    };
    Tn(r);
  }
};
var dy = function(e) {
  this.init(e);
}, Mv = dy, oa = Mv.prototype;
oa.clientFunctions = ["redrawHint", "render", "renderTo", "matchCanvasSize", "nodeShapeImpl", "arrowShapeImpl"];
oa.init = function(t) {
  var e = this;
  e.options = t, e.cy = t.cy;
  var r = e.container = t.cy.container(), a = e.cy.window();
  if (a) {
    var n = a.document, i = n.head, o = "__________cytoscape_stylesheet", s = "__________cytoscape_container", u = n.getElementById(o) != null;
    if (r.className.indexOf(s) < 0 && (r.className = (r.className || "") + " " + s), !u) {
      var l = n.createElement("style");
      l.id = o, l.textContent = "." + s + " { position: relative; }", i.insertBefore(l, i.children[0]);
    }
    var f = a.getComputedStyle(r), v = f.getPropertyValue("position");
    v === "static" && Fe("A Cytoscape container has style position:static and so can not use UI extensions properly");
  }
  e.selection = [void 0, void 0, void 0, void 0, 0], e.bezierProjPcts = [0.05, 0.225, 0.4, 0.5, 0.6, 0.775, 0.95], e.hoverData = {
    down: null,
    last: null,
    downTime: null,
    triggerMode: null,
    dragging: !1,
    initialPan: [null, null],
    capture: !1
  }, e.dragData = {
    possibleDragElements: []
  }, e.touchData = {
    start: null,
    capture: !1,
    // These 3 fields related to tap, taphold events
    startPosition: [null, null, null, null, null, null],
    singleTouchStartTime: null,
    singleTouchMoved: !0,
    now: [null, null, null, null, null, null],
    earlier: [null, null, null, null, null, null]
  }, e.redraws = 0, e.showFps = t.showFps, e.debug = t.debug, e.webgl = t.webgl, e.hideEdgesOnViewport = t.hideEdgesOnViewport, e.textureOnViewport = t.textureOnViewport, e.wheelSensitivity = t.wheelSensitivity, e.motionBlurEnabled = t.motionBlur, e.forcedPixelRatio = ne(t.pixelRatio) ? t.pixelRatio : null, e.motionBlur = t.motionBlur, e.motionBlurOpacity = t.motionBlurOpacity, e.motionBlurTransparency = 1 - e.motionBlurOpacity, e.motionBlurPxRatio = 1, e.mbPxRBlurry = 1, e.minMbLowQualFrames = 4, e.fullQualityMb = !1, e.clearedForMotionBlur = [], e.desktopTapThreshold = t.desktopTapThreshold, e.desktopTapThreshold2 = t.desktopTapThreshold * t.desktopTapThreshold, e.touchTapThreshold = t.touchTapThreshold, e.touchTapThreshold2 = t.touchTapThreshold * t.touchTapThreshold, e.tapholdDuration = 500, e.bindings = [], e.beforeRenderCallbacks = [], e.beforeRenderPriorities = {
    // higher priority execs before lower one
    animations: 400,
    eleCalcs: 300,
    eleTxrDeq: 200,
    lyrTxrDeq: 150,
    lyrTxrSkip: 100
  }, e.registerNodeShapes(), e.registerArrowShapes(), e.registerCalculationListeners();
};
oa.notify = function(t, e) {
  var r = this, a = r.cy;
  if (!this.destroyed) {
    if (t === "init") {
      r.load();
      return;
    }
    if (t === "destroy") {
      r.destroy();
      return;
    }
    (t === "add" || t === "remove" || t === "move" && a.hasCompoundNodes() || t === "load" || t === "zorder" || t === "mount") && r.invalidateCachedZSortedEles(), t === "viewport" && r.redrawHint("select", !0), t === "gc" && r.redrawHint("gc", !0), (t === "load" || t === "resize" || t === "mount") && (r.invalidateContainerClientCoordsCache(), r.matchCanvasSize(r.container)), r.redrawHint("eles", !0), r.redrawHint("drag", !0), this.startRenderLoop(), this.redraw();
  }
};
oa.destroy = function() {
  var t = this;
  t.destroyed = !0, t.cy.stopAnimationLoop();
  for (var e = 0; e < t.bindings.length; e++) {
    var r = t.bindings[e], a = r, n = a.target;
    (n.off || n.removeEventListener).apply(n, a.args);
  }
  if (t.bindings = [], t.beforeRenderCallbacks = [], t.onUpdateEleCalcsFns = [], t.removeObserver && t.removeObserver.disconnect(), t.styleObserver && t.styleObserver.disconnect(), t.resizeObserver && t.resizeObserver.disconnect(), t.labelCalcDiv)
    try {
      document.body.removeChild(t.labelCalcDiv);
    } catch {
    }
};
oa.isHeadless = function() {
  return !1;
};
[ms, Av, Lv, ia, Zt, qa].forEach(function(t) {
  ye(oa, t);
});
var Co = 1e3 / 60, Pv = {
  setupDequeueing: function(e) {
    return function() {
      var a = this, n = this.renderer;
      if (!a.dequeueingSetup) {
        a.dequeueingSetup = !0;
        var i = Ga(function() {
          n.redrawHint("eles", !0), n.redrawHint("drag", !0), n.redraw();
        }, e.deqRedrawThreshold), o = function(l, f) {
          var v = $t(), c = n.averageRedrawTime, h = n.lastRedrawTime, d = [], g = n.cy.extent(), p = n.getPixelRatio();
          for (l || n.flushRenderedStyleQueue(); ; ) {
            var y = $t(), b = y - v, m = y - f;
            if (h < Co) {
              var E = Co - (l ? c : 0);
              if (m >= e.deqFastCost * E)
                break;
            } else if (l) {
              if (b >= e.deqCost * h || b >= e.deqAvgCost * c)
                break;
            } else if (m >= e.deqNoDrawCost * Co)
              break;
            var C = e.deq(a, p, g);
            if (C.length > 0)
              for (var S = 0; S < C.length; S++)
                d.push(C[S]);
            else
              break;
          }
          d.length > 0 && (e.onDeqd(a, d), !l && e.shouldRedraw(a, d, p, g) && i());
        }, s = e.priority || as;
        n.beforeRender(o, s(a));
      }
    };
  }
}, gy = /* @__PURE__ */ (function() {
  function t(e) {
    var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Cn;
    hr(this, t), this.idsByKey = new Wt(), this.keyForId = new Wt(), this.cachesByLvl = new Wt(), this.lvls = [], this.getKey = e, this.doesEleInvalidateKey = r;
  }
  return dr(t, [{
    key: "getIdsFor",
    value: function(r) {
      r == null && qe("Can not get id list for null key");
      var a = this.idsByKey, n = this.idsByKey.get(r);
      return n || (n = new ta(), a.set(r, n)), n;
    }
  }, {
    key: "addIdForKey",
    value: function(r, a) {
      r != null && this.getIdsFor(r).add(a);
    }
  }, {
    key: "deleteIdForKey",
    value: function(r, a) {
      r != null && this.getIdsFor(r).delete(a);
    }
  }, {
    key: "getNumberOfIdsForKey",
    value: function(r) {
      return r == null ? 0 : this.getIdsFor(r).size;
    }
  }, {
    key: "updateKeyMappingFor",
    value: function(r) {
      var a = r.id(), n = this.keyForId.get(a), i = this.getKey(r);
      this.deleteIdForKey(n, a), this.addIdForKey(i, a), this.keyForId.set(a, i);
    }
  }, {
    key: "deleteKeyMappingFor",
    value: function(r) {
      var a = r.id(), n = this.keyForId.get(a);
      this.deleteIdForKey(n, a), this.keyForId.delete(a);
    }
  }, {
    key: "keyHasChangedFor",
    value: function(r) {
      var a = r.id(), n = this.keyForId.get(a), i = this.getKey(r);
      return n !== i;
    }
  }, {
    key: "isInvalid",
    value: function(r) {
      return this.keyHasChangedFor(r) || this.doesEleInvalidateKey(r);
    }
  }, {
    key: "getCachesAt",
    value: function(r) {
      var a = this.cachesByLvl, n = this.lvls, i = a.get(r);
      return i || (i = new Wt(), a.set(r, i), n.push(r)), i;
    }
  }, {
    key: "getCache",
    value: function(r, a) {
      return this.getCachesAt(a).get(r);
    }
  }, {
    key: "get",
    value: function(r, a) {
      var n = this.getKey(r), i = this.getCache(n, a);
      return i != null && this.updateKeyMappingFor(r), i;
    }
  }, {
    key: "getForCachedKey",
    value: function(r, a) {
      var n = this.keyForId.get(r.id()), i = this.getCache(n, a);
      return i;
    }
  }, {
    key: "hasCache",
    value: function(r, a) {
      return this.getCachesAt(a).has(r);
    }
  }, {
    key: "has",
    value: function(r, a) {
      var n = this.getKey(r);
      return this.hasCache(n, a);
    }
  }, {
    key: "setCache",
    value: function(r, a, n) {
      n.key = r, this.getCachesAt(a).set(r, n);
    }
  }, {
    key: "set",
    value: function(r, a, n) {
      var i = this.getKey(r);
      this.setCache(i, a, n), this.updateKeyMappingFor(r);
    }
  }, {
    key: "deleteCache",
    value: function(r, a) {
      this.getCachesAt(a).delete(r);
    }
  }, {
    key: "delete",
    value: function(r, a) {
      var n = this.getKey(r);
      this.deleteCache(n, a);
    }
  }, {
    key: "invalidateKey",
    value: function(r) {
      var a = this;
      this.lvls.forEach(function(n) {
        return a.deleteCache(r, n);
      });
    }
    // returns true if no other eles reference the invalidated cache (n.b. other eles may need the cache with the same key)
  }, {
    key: "invalidate",
    value: function(r) {
      var a = r.id(), n = this.keyForId.get(a);
      this.deleteKeyMappingFor(r);
      var i = this.doesEleInvalidateKey(r);
      return i && this.invalidateKey(n), i || this.getNumberOfIdsForKey(n) === 0;
    }
  }]);
})(), zl = 25, nn = 50, pn = -4, Wo = 3, Iv = 7.99, py = 8, yy = 1024, my = 1024, by = 1024, wy = 0.2, Ey = 0.8, xy = 10, Ty = 0.15, Cy = 0.1, Dy = 0.9, Sy = 0.9, Ay = 100, Ly = 1, Yr = {
  dequeue: "dequeue",
  downscale: "downscale",
  highQuality: "highQuality"
}, Ry = ft({
  getKey: null,
  doesEleInvalidateKey: Cn,
  drawElement: null,
  getBoundingBox: null,
  getRotationPoint: null,
  getRotationOffset: null,
  isVisible: wf,
  allowEdgeTxrCaching: !0,
  allowParentTxrCaching: !0
}), ba = function(e, r) {
  var a = this;
  a.renderer = e, a.onDequeues = [];
  var n = Ry(r);
  ye(a, n), a.lookup = new gy(n.getKey, n.doesEleInvalidateKey), a.setupDequeueing();
}, rt = ba.prototype;
rt.reasons = Yr;
rt.getTextureQueue = function(t) {
  var e = this;
  return e.eleImgCaches = e.eleImgCaches || {}, e.eleImgCaches[t] = e.eleImgCaches[t] || [];
};
rt.getRetiredTextureQueue = function(t) {
  var e = this, r = e.eleImgCaches.retired = e.eleImgCaches.retired || {}, a = r[t] = r[t] || [];
  return a;
};
rt.getElementQueue = function() {
  var t = this, e = t.eleCacheQueue = t.eleCacheQueue || new za(function(r, a) {
    return a.reqs - r.reqs;
  });
  return e;
};
rt.getElementKeyToQueue = function() {
  var t = this, e = t.eleKeyToCacheQueue = t.eleKeyToCacheQueue || {};
  return e;
};
rt.getElement = function(t, e, r, a, n) {
  var i = this, o = this.renderer, s = o.cy.zoom(), u = this.lookup;
  if (!e || e.w === 0 || e.h === 0 || isNaN(e.w) || isNaN(e.h) || !t.visible() || t.removed() || !i.allowEdgeTxrCaching && t.isEdge() || !i.allowParentTxrCaching && t.isParent())
    return null;
  if (a == null && (a = Math.ceil(is(s * r))), a < pn)
    a = pn;
  else if (s >= Iv || a > Wo)
    return null;
  var l = Math.pow(2, a), f = e.h * l, v = e.w * l, c = o.eleTextBiggerThanMin(t, l);
  if (!this.isVisible(t, c))
    return null;
  var h = u.get(t, a);
  if (h && h.invalidated && (h.invalidated = !1, h.texture.invalidatedWidth -= h.width), h)
    return h;
  var d;
  if (f <= zl ? d = zl : f <= nn ? d = nn : d = Math.ceil(f / nn) * nn, f > by || v > my)
    return null;
  var g = i.getTextureQueue(d), p = g[g.length - 2], y = function() {
    return i.recycleTexture(d, v) || i.addTexture(d, v);
  };
  p || (p = g[g.length - 1]), p || (p = y()), p.width - p.usedWidth < v && (p = y());
  for (var b = function(k) {
    return k && k.scaledLabelShown === c;
  }, m = n && n === Yr.dequeue, E = n && n === Yr.highQuality, C = n && n === Yr.downscale, S, w = a + 1; w <= Wo; w++) {
    var x = u.get(t, w);
    if (x) {
      S = x;
      break;
    }
  }
  var T = S && S.level === a + 1 ? S : null, D = function() {
    p.context.drawImage(T.texture.canvas, T.x, 0, T.width, T.height, p.usedWidth, 0, v, f);
  };
  if (p.context.setTransform(1, 0, 0, 1, 0, 0), p.context.clearRect(p.usedWidth, 0, v, d), b(T))
    D();
  else if (b(S))
    if (E) {
      for (var A = S.level; A > a; A--)
        T = i.getElement(t, e, r, A, Yr.downscale);
      D();
    } else
      return i.queueElement(t, S.level - 1), S;
  else {
    var L;
    if (!m && !E && !C)
      for (var R = a - 1; R >= pn; R--) {
        var P = u.get(t, R);
        if (P) {
          L = P;
          break;
        }
      }
    if (b(L))
      return i.queueElement(t, a), L;
    p.context.translate(p.usedWidth, 0), p.context.scale(l, l), this.drawElement(p.context, t, e, c, !1), p.context.scale(1 / l, 1 / l), p.context.translate(-p.usedWidth, 0);
  }
  return h = {
    x: p.usedWidth,
    texture: p,
    level: a,
    scale: l,
    width: v,
    height: f,
    scaledLabelShown: c
  }, p.usedWidth += Math.ceil(v + py), p.eleCaches.push(h), u.set(t, a, h), i.checkTextureFullness(p), h;
};
rt.invalidateElements = function(t) {
  for (var e = 0; e < t.length; e++)
    this.invalidateElement(t[e]);
};
rt.invalidateElement = function(t) {
  var e = this, r = e.lookup, a = [], n = r.isInvalid(t);
  if (n) {
    for (var i = pn; i <= Wo; i++) {
      var o = r.getForCachedKey(t, i);
      o && a.push(o);
    }
    var s = r.invalidate(t);
    if (s)
      for (var u = 0; u < a.length; u++) {
        var l = a[u], f = l.texture;
        f.invalidatedWidth += l.width, l.invalidated = !0, e.checkTextureUtility(f);
      }
    e.removeFromQueue(t);
  }
};
rt.checkTextureUtility = function(t) {
  t.invalidatedWidth >= wy * t.width && this.retireTexture(t);
};
rt.checkTextureFullness = function(t) {
  var e = this, r = e.getTextureQueue(t.height);
  t.usedWidth / t.width > Ey && t.fullnessChecks >= xy ? ur(r, t) : t.fullnessChecks++;
};
rt.retireTexture = function(t) {
  var e = this, r = t.height, a = e.getTextureQueue(r), n = this.lookup;
  ur(a, t), t.retired = !0;
  for (var i = t.eleCaches, o = 0; o < i.length; o++) {
    var s = i[o];
    n.deleteCache(s.key, s.level);
  }
  ns(i);
  var u = e.getRetiredTextureQueue(r);
  u.push(t);
};
rt.addTexture = function(t, e) {
  var r = this, a = r.getTextureQueue(t), n = {};
  return a.push(n), n.eleCaches = [], n.height = t, n.width = Math.max(yy, e), n.usedWidth = 0, n.invalidatedWidth = 0, n.fullnessChecks = 0, n.canvas = r.renderer.makeOffscreenCanvas(n.width, n.height), n.context = n.canvas.getContext("2d"), n;
};
rt.recycleTexture = function(t, e) {
  for (var r = this, a = r.getTextureQueue(t), n = r.getRetiredTextureQueue(t), i = 0; i < n.length; i++) {
    var o = n[i];
    if (o.width >= e)
      return o.retired = !1, o.usedWidth = 0, o.invalidatedWidth = 0, o.fullnessChecks = 0, ns(o.eleCaches), o.context.setTransform(1, 0, 0, 1, 0, 0), o.context.clearRect(0, 0, o.width, o.height), ur(n, o), a.push(o), o;
  }
};
rt.queueElement = function(t, e) {
  var r = this, a = r.getElementQueue(), n = r.getElementKeyToQueue(), i = this.getKey(t), o = n[i];
  if (o)
    o.level = Math.max(o.level, e), o.eles.merge(t), o.reqs++, a.updateItem(o);
  else {
    var s = {
      eles: t.spawn().merge(t),
      level: e,
      reqs: 1,
      key: i
    };
    a.push(s), n[i] = s;
  }
};
rt.dequeue = function(t) {
  for (var e = this, r = e.getElementQueue(), a = e.getElementKeyToQueue(), n = [], i = e.lookup, o = 0; o < Ly && r.size() > 0; o++) {
    var s = r.pop(), u = s.key, l = s.eles[0], f = i.hasCache(l, s.level);
    if (a[u] = null, f)
      continue;
    n.push(s);
    var v = e.getBoundingBox(l);
    e.getElement(l, v, t, s.level, Yr.dequeue);
  }
  return n;
};
rt.removeFromQueue = function(t) {
  var e = this, r = e.getElementQueue(), a = e.getElementKeyToQueue(), n = this.getKey(t), i = a[n];
  i != null && (i.eles.length === 1 ? (i.reqs = rs, r.updateItem(i), r.pop(), a[n] = null) : i.eles.unmerge(t));
};
rt.onDequeue = function(t) {
  this.onDequeues.push(t);
};
rt.offDequeue = function(t) {
  ur(this.onDequeues, t);
};
rt.setupDequeueing = Pv.setupDequeueing({
  deqRedrawThreshold: Ay,
  deqCost: Ty,
  deqAvgCost: Cy,
  deqNoDrawCost: Dy,
  deqFastCost: Sy,
  deq: function(e, r, a) {
    return e.dequeue(r, a);
  },
  onDeqd: function(e, r) {
    for (var a = 0; a < e.onDequeues.length; a++) {
      var n = e.onDequeues[a];
      n(r);
    }
  },
  shouldRedraw: function(e, r, a, n) {
    for (var i = 0; i < r.length; i++)
      for (var o = r[i].eles, s = 0; s < o.length; s++) {
        var u = o[s].boundingBox();
        if (ss(u, n))
          return !0;
      }
    return !1;
  },
  priority: function(e) {
    return e.renderer.beforeRenderPriorities.eleTxrDeq;
  }
});
var My = 1, Ea = -4, In = 2, Py = 3.99, Iy = 50, Oy = 50, ky = 0.15, Ny = 0.1, By = 0.9, Fy = 0.9, Gy = 1, _l = 250, zy = 4e3 * 4e3, Vl = 32767, _y = !0, Ov = function(e) {
  var r = this, a = r.renderer = e, n = a.cy;
  r.layersByLevel = {}, r.firstGet = !0, r.lastInvalidationTime = $t() - 2 * _l, r.skipping = !1, r.eleTxrDeqs = n.collection(), r.scheduleElementRefinement = Ga(function() {
    r.refineElementTextures(r.eleTxrDeqs), r.eleTxrDeqs.unmerge(r.eleTxrDeqs);
  }, Oy), a.beforeRender(function(o, s) {
    s - r.lastInvalidationTime <= _l ? r.skipping = !0 : r.skipping = !1;
  }, a.beforeRenderPriorities.lyrTxrSkip);
  var i = function(s, u) {
    return u.reqs - s.reqs;
  };
  r.layersQueue = new za(i), r.setupDequeueing();
}, vt = Ov.prototype, Ul = 0, Vy = Math.pow(2, 53) - 1;
vt.makeLayer = function(t, e) {
  var r = Math.pow(2, e), a = Math.ceil(t.w * r), n = Math.ceil(t.h * r), i = this.renderer.makeOffscreenCanvas(a, n), o = {
    id: Ul = ++Ul % Vy,
    bb: t,
    level: e,
    width: a,
    height: n,
    canvas: i,
    context: i.getContext("2d"),
    eles: [],
    elesQueue: [],
    reqs: 0
  }, s = o.context, u = -o.bb.x1, l = -o.bb.y1;
  return s.scale(r, r), s.translate(u, l), o;
};
vt.getLayers = function(t, e, r) {
  var a = this, n = a.renderer, i = n.cy, o = i.zoom(), s = a.firstGet;
  if (a.firstGet = !1, r == null) {
    if (r = Math.ceil(is(o * e)), r < Ea)
      r = Ea;
    else if (o >= Py || r > In)
      return null;
  }
  a.validateLayersElesOrdering(r, t);
  var u = a.layersByLevel, l = Math.pow(2, r), f = u[r] = u[r] || [], v, c = a.levelIsComplete(r, t), h, d = function() {
    var D = function(I) {
      if (a.validateLayersElesOrdering(I, t), a.levelIsComplete(I, t))
        return h = u[I], !0;
    }, A = function(I) {
      if (!h)
        for (var k = r + I; Ea <= k && k <= In && !D(k); k += I)
          ;
    };
    A(1), A(-1);
    for (var L = f.length - 1; L >= 0; L--) {
      var R = f[L];
      R.invalid && ur(f, R);
    }
  };
  if (!c)
    d();
  else
    return f;
  var g = function() {
    if (!v) {
      v = mt();
      for (var D = 0; D < t.length; D++)
        Nh(v, t[D].boundingBox());
    }
    return v;
  }, p = function(D) {
    D = D || {};
    var A = D.after;
    g();
    var L = Math.ceil(v.w * l), R = Math.ceil(v.h * l);
    if (L > Vl || R > Vl)
      return null;
    var P = L * R;
    if (P > zy)
      return null;
    var I = a.makeLayer(v, r);
    if (A != null) {
      var k = f.indexOf(A) + 1;
      f.splice(k, 0, I);
    } else (D.insert === void 0 || D.insert) && f.unshift(I);
    return I;
  };
  if (a.skipping && !s)
    return null;
  for (var y = null, b = t.length / My, m = !s, E = 0; E < t.length; E++) {
    var C = t[E], S = C._private.rscratch, w = S.imgLayerCaches = S.imgLayerCaches || {}, x = w[r];
    if (x) {
      y = x;
      continue;
    }
    if ((!y || y.eles.length >= b || !Sf(y.bb, C.boundingBox())) && (y = p({
      insert: !0,
      after: y
    }), !y))
      return null;
    h || m ? a.queueLayer(y, C) : a.drawEleInLayer(y, C, r, e), y.eles.push(C), w[r] = y;
  }
  return h || (m ? null : f);
};
vt.getEleLevelForLayerLevel = function(t, e) {
  return t;
};
vt.drawEleInLayer = function(t, e, r, a) {
  var n = this, i = this.renderer, o = t.context, s = e.boundingBox();
  s.w === 0 || s.h === 0 || !e.visible() || (r = n.getEleLevelForLayerLevel(r, a), i.setImgSmoothing(o, !1), i.drawCachedElement(o, e, null, null, r, _y), i.setImgSmoothing(o, !0));
};
vt.levelIsComplete = function(t, e) {
  var r = this, a = r.layersByLevel[t];
  if (!a || a.length === 0)
    return !1;
  for (var n = 0, i = 0; i < a.length; i++) {
    var o = a[i];
    if (o.reqs > 0 || o.invalid)
      return !1;
    n += o.eles.length;
  }
  return n === e.length;
};
vt.validateLayersElesOrdering = function(t, e) {
  var r = this.layersByLevel[t];
  if (r)
    for (var a = 0; a < r.length; a++) {
      for (var n = r[a], i = -1, o = 0; o < e.length; o++)
        if (n.eles[0] === e[o]) {
          i = o;
          break;
        }
      if (i < 0) {
        this.invalidateLayer(n);
        continue;
      }
      for (var s = i, o = 0; o < n.eles.length; o++)
        if (n.eles[o] !== e[s + o]) {
          this.invalidateLayer(n);
          break;
        }
    }
};
vt.updateElementsInLayers = function(t, e) {
  for (var r = this, a = ka(t[0]), n = 0; n < t.length; n++)
    for (var i = a ? null : t[n], o = a ? t[n] : t[n].ele, s = o._private.rscratch, u = s.imgLayerCaches = s.imgLayerCaches || {}, l = Ea; l <= In; l++) {
      var f = u[l];
      f && (i && r.getEleLevelForLayerLevel(f.level) !== i.level || e(f, o, i));
    }
};
vt.haveLayers = function() {
  for (var t = this, e = !1, r = Ea; r <= In; r++) {
    var a = t.layersByLevel[r];
    if (a && a.length > 0) {
      e = !0;
      break;
    }
  }
  return e;
};
vt.invalidateElements = function(t) {
  var e = this;
  t.length !== 0 && (e.lastInvalidationTime = $t(), !(t.length === 0 || !e.haveLayers()) && e.updateElementsInLayers(t, function(a, n, i) {
    e.invalidateLayer(a);
  }));
};
vt.invalidateLayer = function(t) {
  if (this.lastInvalidationTime = $t(), !t.invalid) {
    var e = t.level, r = t.eles, a = this.layersByLevel[e];
    ur(a, t), t.elesQueue = [], t.invalid = !0, t.replacement && (t.replacement.invalid = !0);
    for (var n = 0; n < r.length; n++) {
      var i = r[n]._private.rscratch.imgLayerCaches;
      i && (i[e] = null);
    }
  }
};
vt.refineElementTextures = function(t) {
  var e = this;
  e.updateElementsInLayers(t, function(a, n, i) {
    var o = a.replacement;
    if (o || (o = a.replacement = e.makeLayer(a.bb, a.level), o.replaces = a, o.eles = a.eles), !o.reqs)
      for (var s = 0; s < o.eles.length; s++)
        e.queueLayer(o, o.eles[s]);
  });
};
vt.enqueueElementRefinement = function(t) {
  this.eleTxrDeqs.merge(t), this.scheduleElementRefinement();
};
vt.queueLayer = function(t, e) {
  var r = this, a = r.layersQueue, n = t.elesQueue, i = n.hasId = n.hasId || {};
  if (!t.replacement) {
    if (e) {
      if (i[e.id()])
        return;
      n.push(e), i[e.id()] = !0;
    }
    t.reqs ? (t.reqs++, a.updateItem(t)) : (t.reqs = 1, a.push(t));
  }
};
vt.dequeue = function(t) {
  for (var e = this, r = e.layersQueue, a = [], n = 0; n < Gy && r.size() !== 0; ) {
    var i = r.peek();
    if (i.replacement) {
      r.pop();
      continue;
    }
    if (i.replaces && i !== i.replaces.replacement) {
      r.pop();
      continue;
    }
    if (i.invalid) {
      r.pop();
      continue;
    }
    var o = i.elesQueue.shift();
    o && (e.drawEleInLayer(i, o, i.level, t), n++), a.length === 0 && a.push(!0), i.elesQueue.length === 0 && (r.pop(), i.reqs = 0, i.replaces && e.applyLayerReplacement(i), e.requestRedraw());
  }
  return a;
};
vt.applyLayerReplacement = function(t) {
  var e = this, r = e.layersByLevel[t.level], a = t.replaces, n = r.indexOf(a);
  if (!(n < 0 || a.invalid)) {
    r[n] = t;
    for (var i = 0; i < t.eles.length; i++) {
      var o = t.eles[i]._private, s = o.imgLayerCaches = o.imgLayerCaches || {};
      s && (s[t.level] = t);
    }
    e.requestRedraw();
  }
};
vt.requestRedraw = Ga(function() {
  var t = this.renderer;
  t.redrawHint("eles", !0), t.redrawHint("drag", !0), t.redraw();
}, 100);
vt.setupDequeueing = Pv.setupDequeueing({
  deqRedrawThreshold: Iy,
  deqCost: ky,
  deqAvgCost: Ny,
  deqNoDrawCost: By,
  deqFastCost: Fy,
  deq: function(e, r) {
    return e.dequeue(r);
  },
  onDeqd: as,
  shouldRedraw: wf,
  priority: function(e) {
    return e.renderer.beforeRenderPriorities.lyrTxrDeq;
  }
});
var kv = {}, ql;
function Uy(t, e) {
  for (var r = 0; r < e.length; r++) {
    var a = e[r];
    t.lineTo(a.x, a.y);
  }
}
function qy(t, e, r) {
  for (var a, n = 0; n < e.length; n++) {
    var i = e[n];
    n === 0 && (a = i), t.lineTo(i.x, i.y);
  }
  t.quadraticCurveTo(r.x, r.y, a.x, a.y);
}
function Yl(t, e, r) {
  t.beginPath && t.beginPath();
  for (var a = e, n = 0; n < a.length; n++) {
    var i = a[n];
    t.lineTo(i.x, i.y);
  }
  var o = r, s = r[0];
  t.moveTo(s.x, s.y);
  for (var n = 1; n < o.length; n++) {
    var i = o[n];
    t.lineTo(i.x, i.y);
  }
  t.closePath && t.closePath();
}
function Yy(t, e, r, a, n) {
  t.beginPath && t.beginPath(), t.arc(r, a, n, 0, Math.PI * 2, !1);
  var i = e, o = i[0];
  t.moveTo(o.x, o.y);
  for (var s = 0; s < i.length; s++) {
    var u = i[s];
    t.lineTo(u.x, u.y);
  }
  t.closePath && t.closePath();
}
function Hy(t, e, r, a) {
  t.arc(e, r, a, 0, Math.PI * 2, !1);
}
kv.arrowShapeImpl = function(t) {
  return (ql || (ql = {
    polygon: Uy,
    "triangle-backcurve": qy,
    "triangle-tee": Yl,
    "circle-triangle": Yy,
    "triangle-cross": Yl,
    circle: Hy
  }))[t];
};
var Yt = {};
Yt.drawElement = function(t, e, r, a, n, i) {
  var o = this;
  e.isNode() ? o.drawNode(t, e, r, a, n, i) : o.drawEdge(t, e, r, a, n, i);
};
Yt.drawElementOverlay = function(t, e) {
  var r = this;
  e.isNode() ? r.drawNodeOverlay(t, e) : r.drawEdgeOverlay(t, e);
};
Yt.drawElementUnderlay = function(t, e) {
  var r = this;
  e.isNode() ? r.drawNodeUnderlay(t, e) : r.drawEdgeUnderlay(t, e);
};
Yt.drawCachedElementPortion = function(t, e, r, a, n, i, o, s) {
  var u = this, l = r.getBoundingBox(e);
  if (!(l.w === 0 || l.h === 0)) {
    var f = r.getElement(e, l, a, n, i);
    if (f != null) {
      var v = s(u, e);
      if (v === 0)
        return;
      var c = o(u, e), h = l.x1, d = l.y1, g = l.w, p = l.h, y, b, m, E, C;
      if (c !== 0) {
        var S = r.getRotationPoint(e);
        m = S.x, E = S.y, t.translate(m, E), t.rotate(c), C = u.getImgSmoothing(t), C || u.setImgSmoothing(t, !0);
        var w = r.getRotationOffset(e);
        y = w.x, b = w.y;
      } else
        y = h, b = d;
      var x;
      v !== 1 && (x = t.globalAlpha, t.globalAlpha = x * v), t.drawImage(f.texture.canvas, f.x, 0, f.width, f.height, y, b, g, p), v !== 1 && (t.globalAlpha = x), c !== 0 && (t.rotate(-c), t.translate(-m, -E), C || u.setImgSmoothing(t, !1));
    } else
      r.drawElement(t, e);
  }
};
var Xy = function() {
  return 0;
}, Wy = function(e, r) {
  return e.getTextAngle(r, null);
}, $y = function(e, r) {
  return e.getTextAngle(r, "source");
}, Ky = function(e, r) {
  return e.getTextAngle(r, "target");
}, Zy = function(e, r) {
  return r.effectiveOpacity();
}, Do = function(e, r) {
  return r.pstyle("text-opacity").pfValue * r.effectiveOpacity();
};
Yt.drawCachedElement = function(t, e, r, a, n, i) {
  var o = this, s = o.data, u = s.eleTxrCache, l = s.lblTxrCache, f = s.slbTxrCache, v = s.tlbTxrCache, c = e.boundingBox(), h = i === !0 ? u.reasons.highQuality : null;
  if (!(c.w === 0 || c.h === 0 || !e.visible()) && (!a || ss(c, a))) {
    var d = e.isEdge(), g = e.element()._private.rscratch.badLine;
    o.drawElementUnderlay(t, e), o.drawCachedElementPortion(t, e, u, r, n, h, Xy, Zy), (!d || !g) && o.drawCachedElementPortion(t, e, l, r, n, h, Wy, Do), d && !g && (o.drawCachedElementPortion(t, e, f, r, n, h, $y, Do), o.drawCachedElementPortion(t, e, v, r, n, h, Ky, Do)), o.drawElementOverlay(t, e);
  }
};
Yt.drawElements = function(t, e) {
  for (var r = this, a = 0; a < e.length; a++) {
    var n = e[a];
    r.drawElement(t, n);
  }
};
Yt.drawCachedElements = function(t, e, r, a) {
  for (var n = this, i = 0; i < e.length; i++) {
    var o = e[i];
    n.drawCachedElement(t, o, r, a);
  }
};
Yt.drawCachedNodes = function(t, e, r, a) {
  for (var n = this, i = 0; i < e.length; i++) {
    var o = e[i];
    o.isNode() && n.drawCachedElement(t, o, r, a);
  }
};
Yt.drawLayeredElements = function(t, e, r, a) {
  var n = this, i = n.data.lyrTxrCache.getLayers(e, r);
  if (i)
    for (var o = 0; o < i.length; o++) {
      var s = i[o], u = s.bb;
      u.w === 0 || u.h === 0 || t.drawImage(s.canvas, u.x1, u.y1, u.w, u.h);
    }
  else
    n.drawCachedElements(t, e, r, a);
};
var Qt = {};
Qt.drawEdge = function(t, e, r) {
  var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, o = this, s = e._private.rscratch;
  if (!(i && !e.visible()) && !(s.badLine || s.allpts == null || isNaN(s.allpts[0]))) {
    var u;
    r && (u = r, t.translate(-u.x1, -u.y1));
    var l = i ? e.pstyle("opacity").value : 1, f = i ? e.pstyle("line-opacity").value : 1, v = e.pstyle("curve-style").value, c = e.pstyle("line-style").value, h = e.pstyle("width").pfValue, d = e.pstyle("line-cap").value, g = e.pstyle("line-outline-width").value, p = e.pstyle("line-outline-color").value, y = l * f, b = l * f, m = function() {
      var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : y;
      v === "straight-triangle" ? (o.eleStrokeStyle(t, e, I), o.drawEdgeTrianglePath(e, t, s.allpts)) : (t.lineWidth = h, t.lineCap = d, o.eleStrokeStyle(t, e, I), o.drawEdgePath(e, t, s.allpts, c), t.lineCap = "butt");
    }, E = function() {
      var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : y;
      if (t.lineWidth = h + g, t.lineCap = d, g > 0)
        o.colorStrokeStyle(t, p[0], p[1], p[2], I);
      else {
        t.lineCap = "butt";
        return;
      }
      v === "straight-triangle" ? o.drawEdgeTrianglePath(e, t, s.allpts) : (o.drawEdgePath(e, t, s.allpts, c), t.lineCap = "butt");
    }, C = function() {
      n && o.drawEdgeOverlay(t, e);
    }, S = function() {
      n && o.drawEdgeUnderlay(t, e);
    }, w = function() {
      var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b;
      o.drawArrowheads(t, e, I);
    }, x = function() {
      o.drawElementText(t, e, null, a);
    };
    t.lineJoin = "round";
    var T = e.pstyle("ghost").value === "yes";
    if (T) {
      var D = e.pstyle("ghost-offset-x").pfValue, A = e.pstyle("ghost-offset-y").pfValue, L = e.pstyle("ghost-opacity").value, R = y * L;
      t.translate(D, A), m(R), w(R), t.translate(-D, -A);
    } else
      E();
    S(), m(), w(), C(), x(), r && t.translate(u.x1, u.y1);
  }
};
var Nv = function(e) {
  if (!["overlay", "underlay"].includes(e))
    throw new Error("Invalid state");
  return function(r, a) {
    if (a.visible()) {
      var n = a.pstyle("".concat(e, "-opacity")).value;
      if (n !== 0) {
        var i = this, o = i.usePaths(), s = a._private.rscratch, u = a.pstyle("".concat(e, "-padding")).pfValue, l = 2 * u, f = a.pstyle("".concat(e, "-color")).value;
        r.lineWidth = l, s.edgeType === "self" && !o ? r.lineCap = "butt" : r.lineCap = "round", i.colorStrokeStyle(r, f[0], f[1], f[2], n), i.drawEdgePath(a, r, s.allpts, "solid");
      }
    }
  };
};
Qt.drawEdgeOverlay = Nv("overlay");
Qt.drawEdgeUnderlay = Nv("underlay");
Qt.drawEdgePath = function(t, e, r, a) {
  var n = t._private.rscratch, i = e, o, s = !1, u = this.usePaths(), l = t.pstyle("line-dash-pattern").pfValue, f = t.pstyle("line-dash-offset").pfValue;
  if (u) {
    var v = r.join("$"), c = n.pathCacheKey && n.pathCacheKey === v;
    c ? (o = e = n.pathCache, s = !0) : (o = e = new Path2D(), n.pathCacheKey = v, n.pathCache = o);
  }
  if (i.setLineDash)
    switch (a) {
      case "dotted":
        i.setLineDash([1, 1]);
        break;
      case "dashed":
        i.setLineDash(l), i.lineDashOffset = f;
        break;
      case "solid":
        i.setLineDash([]);
        break;
    }
  if (!s && !n.badLine)
    switch (e.beginPath && e.beginPath(), e.moveTo(r[0], r[1]), n.edgeType) {
      case "bezier":
      case "self":
      case "compound":
      case "multibezier":
        for (var h = 2; h + 3 < r.length; h += 4)
          e.quadraticCurveTo(r[h], r[h + 1], r[h + 2], r[h + 3]);
        break;
      case "straight":
      case "haystack":
        for (var d = 2; d + 1 < r.length; d += 2)
          e.lineTo(r[d], r[d + 1]);
        break;
      case "segments":
        if (n.isRound) {
          var g = Tt(n.roundCorners), p;
          try {
            for (g.s(); !(p = g.n()).done; ) {
              var y = p.value;
              xv(e, y);
            }
          } catch (m) {
            g.e(m);
          } finally {
            g.f();
          }
          e.lineTo(r[r.length - 2], r[r.length - 1]);
        } else
          for (var b = 2; b + 1 < r.length; b += 2)
            e.lineTo(r[b], r[b + 1]);
        break;
    }
  e = i, u ? e.stroke(o) : e.stroke(), e.setLineDash && e.setLineDash([]);
};
Qt.drawEdgeTrianglePath = function(t, e, r) {
  e.fillStyle = e.strokeStyle;
  for (var a = t.pstyle("width").pfValue, n = 0; n + 1 < r.length; n += 2) {
    var i = [r[n + 2] - r[n], r[n + 3] - r[n + 1]], o = Math.sqrt(i[0] * i[0] + i[1] * i[1]), s = [i[1] / o, -i[0] / o], u = [s[0] * a / 2, s[1] * a / 2];
    e.beginPath(), e.moveTo(r[n] - u[0], r[n + 1] - u[1]), e.lineTo(r[n] + u[0], r[n + 1] + u[1]), e.lineTo(r[n + 2], r[n + 3]), e.closePath(), e.fill();
  }
};
Qt.drawArrowheads = function(t, e, r) {
  var a = e._private.rscratch, n = a.edgeType === "haystack";
  n || this.drawArrowhead(t, e, "source", a.arrowStartX, a.arrowStartY, a.srcArrowAngle, r), this.drawArrowhead(t, e, "mid-target", a.midX, a.midY, a.midtgtArrowAngle, r), this.drawArrowhead(t, e, "mid-source", a.midX, a.midY, a.midsrcArrowAngle, r), n || this.drawArrowhead(t, e, "target", a.arrowEndX, a.arrowEndY, a.tgtArrowAngle, r);
};
Qt.drawArrowhead = function(t, e, r, a, n, i, o) {
  if (!(isNaN(a) || a == null || isNaN(n) || n == null || isNaN(i) || i == null)) {
    var s = this, u = e.pstyle(r + "-arrow-shape").value;
    if (u !== "none") {
      var l = e.pstyle(r + "-arrow-fill").value === "hollow" ? "both" : "filled", f = e.pstyle(r + "-arrow-fill").value, v = e.pstyle("width").pfValue, c = e.pstyle(r + "-arrow-width"), h = c.value === "match-line" ? v : c.pfValue;
      c.units === "%" && (h *= v);
      var d = e.pstyle("opacity").value;
      o === void 0 && (o = d);
      var g = t.globalCompositeOperation;
      (o !== 1 || f === "hollow") && (t.globalCompositeOperation = "destination-out", s.colorFillStyle(t, 255, 255, 255, 1), s.colorStrokeStyle(t, 255, 255, 255, 1), s.drawArrowShape(e, t, l, v, u, h, a, n, i), t.globalCompositeOperation = g);
      var p = e.pstyle(r + "-arrow-color").value;
      s.colorFillStyle(t, p[0], p[1], p[2], o), s.colorStrokeStyle(t, p[0], p[1], p[2], o), s.drawArrowShape(e, t, f, v, u, h, a, n, i);
    }
  }
};
Qt.drawArrowShape = function(t, e, r, a, n, i, o, s, u) {
  var l = this, f = this.usePaths() && n !== "triangle-cross", v = !1, c, h = e, d = {
    x: o,
    y: s
  }, g = t.pstyle("arrow-scale").value, p = this.getArrowWidth(a, g), y = l.arrowShapes[n];
  if (f) {
    var b = l.arrowPathCache = l.arrowPathCache || [], m = Sr(n), E = b[m];
    E != null ? (c = e = E, v = !0) : (c = e = new Path2D(), b[m] = c);
  }
  v || (e.beginPath && e.beginPath(), f ? y.draw(e, 1, 0, {
    x: 0,
    y: 0
  }, 1) : y.draw(e, p, u, d, a), e.closePath && e.closePath()), e = h, f && (e.translate(o, s), e.rotate(u), e.scale(p, p)), (r === "filled" || r === "both") && (f ? e.fill(c) : e.fill()), (r === "hollow" || r === "both") && (e.lineWidth = i / (f ? p : 1), e.lineJoin = "miter", f ? e.stroke(c) : e.stroke()), f && (e.scale(1 / p, 1 / p), e.rotate(-u), e.translate(-o, -s));
};
var Es = {};
Es.safeDrawImage = function(t, e, r, a, n, i, o, s, u, l) {
  if (!(n <= 0 || i <= 0 || u <= 0 || l <= 0))
    try {
      t.drawImage(e, r, a, n, i, o, s, u, l);
    } catch (f) {
      Fe(f);
    }
};
Es.drawInscribedImage = function(t, e, r, a, n) {
  var i = this, o = r.position(), s = o.x, u = o.y, l = r.cy().style(), f = l.getIndexedStyle.bind(l), v = f(r, "background-fit", "value", a), c = f(r, "background-repeat", "value", a), h = r.width(), d = r.height(), g = r.padding() * 2, p = h + (f(r, "background-width-relative-to", "value", a) === "inner" ? 0 : g), y = d + (f(r, "background-height-relative-to", "value", a) === "inner" ? 0 : g), b = r._private.rscratch, m = f(r, "background-clip", "value", a), E = m === "node", C = f(r, "background-image-opacity", "value", a) * n, S = f(r, "background-image-smoothing", "value", a), w = r.pstyle("corner-radius").value;
  w !== "auto" && (w = r.pstyle("corner-radius").pfValue);
  var x = e.width || e.cachedW, T = e.height || e.cachedH;
  (x == null || T == null) && (document.body.appendChild(e), x = e.cachedW = e.width || e.offsetWidth, T = e.cachedH = e.height || e.offsetHeight, document.body.removeChild(e));
  var D = x, A = T;
  if (f(r, "background-width", "value", a) !== "auto" && (f(r, "background-width", "units", a) === "%" ? D = f(r, "background-width", "pfValue", a) * p : D = f(r, "background-width", "pfValue", a)), f(r, "background-height", "value", a) !== "auto" && (f(r, "background-height", "units", a) === "%" ? A = f(r, "background-height", "pfValue", a) * y : A = f(r, "background-height", "pfValue", a)), !(D === 0 || A === 0)) {
    if (v === "contain") {
      var L = Math.min(p / D, y / A);
      D *= L, A *= L;
    } else if (v === "cover") {
      var L = Math.max(p / D, y / A);
      D *= L, A *= L;
    }
    var R = s - p / 2, P = f(r, "background-position-x", "units", a), I = f(r, "background-position-x", "pfValue", a);
    P === "%" ? R += (p - D) * I : R += I;
    var k = f(r, "background-offset-x", "units", a), O = f(r, "background-offset-x", "pfValue", a);
    k === "%" ? R += (p - D) * O : R += O;
    var N = u - y / 2, F = f(r, "background-position-y", "units", a), G = f(r, "background-position-y", "pfValue", a);
    F === "%" ? N += (y - A) * G : N += G;
    var B = f(r, "background-offset-y", "units", a), z = f(r, "background-offset-y", "pfValue", a);
    B === "%" ? N += (y - A) * z : N += z, b.pathCache && (R -= s, N -= u, s = 0, u = 0);
    var Y = t.globalAlpha;
    t.globalAlpha = C;
    var $ = i.getImgSmoothing(t), X = !1;
    if (S === "no" && $ ? (i.setImgSmoothing(t, !1), X = !0) : S === "yes" && !$ && (i.setImgSmoothing(t, !0), X = !0), c === "no-repeat")
      E && (t.save(), b.pathCache ? t.clip(b.pathCache) : (i.nodeShapes[i.getNodeShape(r)].draw(t, s, u, p, y, w, b), t.clip())), i.safeDrawImage(t, e, 0, 0, x, T, R, N, D, A), E && t.restore();
    else {
      var j = t.createPattern(e, c);
      t.fillStyle = j, i.nodeShapes[i.getNodeShape(r)].draw(t, s, u, p, y, w, b), t.translate(R, N), t.fill(), t.translate(-R, -N);
    }
    t.globalAlpha = Y, X && i.setImgSmoothing(t, $);
  }
};
var Ir = {};
Ir.eleTextBiggerThanMin = function(t, e) {
  if (!e) {
    var r = t.cy().zoom(), a = this.getPixelRatio(), n = Math.ceil(is(r * a));
    e = Math.pow(2, n);
  }
  var i = t.pstyle("font-size").pfValue * e, o = t.pstyle("min-zoomed-font-size").pfValue;
  return !(i < o);
};
Ir.drawElementText = function(t, e, r, a, n) {
  var i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, o = this;
  if (a == null) {
    if (i && !o.eleTextBiggerThanMin(e))
      return;
  } else if (a === !1)
    return;
  if (e.isNode()) {
    var s = e.pstyle("label");
    if (!s || !s.value)
      return;
    var u = o.getLabelJustification(e), l = e.pstyle("text-metrics").strValue === "glyph";
    t.textAlign = u, t.textBaseline = l ? "alphabetic" : "bottom";
  } else {
    var f = e.element()._private.rscratch.badLine, v = e.pstyle("label"), c = e.pstyle("source-label"), h = e.pstyle("target-label");
    if (f || (!v || !v.value) && (!c || !c.value) && (!h || !h.value))
      return;
    t.textAlign = "center", t.textBaseline = "bottom";
  }
  var d = !r, g;
  r && (g = r, t.translate(-g.x1, -g.y1)), n == null ? (o.drawText(t, e, null, d, i), e.isEdge() && (o.drawText(t, e, "source", d, i), o.drawText(t, e, "target", d, i))) : o.drawText(t, e, n, d, i), r && t.translate(g.x1, g.y1);
};
Ir.getFontCache = function(t) {
  var e;
  this.fontCaches = this.fontCaches || [];
  for (var r = 0; r < this.fontCaches.length; r++)
    if (e = this.fontCaches[r], e.context === t)
      return e;
  return e = {
    context: t
  }, this.fontCaches.push(e), e;
};
Ir.setupTextStyle = function(t, e) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0, a = e.pstyle("font-style").strValue, n = e.pstyle("font-size").pfValue + "px", i = e.pstyle("font-family").strValue, o = e.pstyle("font-weight").strValue, s = r ? e.effectiveOpacity() * e.pstyle("text-opacity").value : 1, u = e.pstyle("text-outline-opacity").value * s, l = e.pstyle("color").value, f = e.pstyle("text-outline-color").value;
  t.font = a + " " + o + " " + n + " " + i, t.lineJoin = "round", this.colorFillStyle(t, l[0], l[1], l[2], s), this.colorStrokeStyle(t, f[0], f[1], f[2], u);
};
function Qy(t, e, r, a, n) {
  var i = Math.min(a, n), o = i / 2, s = e + a / 2, u = r + n / 2;
  t.beginPath(), t.arc(s, u, o, 0, Math.PI * 2), t.closePath();
}
function Hl(t, e, r, a, n) {
  var i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 5, o = Math.min(i, a / 2, n / 2);
  t.beginPath(), t.moveTo(e + o, r), t.lineTo(e + a - o, r), t.quadraticCurveTo(e + a, r, e + a, r + o), t.lineTo(e + a, r + n - o), t.quadraticCurveTo(e + a, r + n, e + a - o, r + n), t.lineTo(e + o, r + n), t.quadraticCurveTo(e, r + n, e, r + n - o), t.lineTo(e, r + o), t.quadraticCurveTo(e, r, e + o, r), t.closePath();
}
Ir.getTextAngle = function(t, e) {
  var r, a = t._private, n = a.rscratch, i = e ? e + "-" : "", o = t.pstyle(i + "text-rotation");
  if (o.strValue === "autorotate") {
    var s = yt(n, "labelAngle", e);
    r = t.isEdge() ? s : 0;
  } else o.strValue === "none" ? r = 0 : r = o.pfValue;
  return r;
};
Ir.drawText = function(t, e, r) {
  var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = e._private, o = i.rscratch, s = n ? e.effectiveOpacity() : 1;
  if (!(n && (s === 0 || e.pstyle("text-opacity").value === 0))) {
    r === "main" && (r = null);
    var u = yt(o, "labelX", r), l = yt(o, "labelY", r), f, v, c = this.getLabelText(e, r);
    if (c != null && c !== "" && !isNaN(u) && !isNaN(l)) {
      this.setupTextStyle(t, e, n);
      var h = r ? r + "-" : "", d = yt(o, "labelWidth", r), g = yt(o, "labelHeight", r), p = yt(o, "labelActualDescent", r), y = e.pstyle(h + "text-margin-x").pfValue, b = e.pstyle(h + "text-margin-y").pfValue, m = e.isEdge(), E = e.pstyle("text-halign").value, C = e.pstyle("text-valign").value;
      m && (E = "center", C = "center"), u += y, l += b;
      var S;
      a ? S = this.getTextAngle(e, r) : S = 0, S !== 0 && (f = u, v = l, t.translate(f, v), t.rotate(S), u = 0, l = 0);
      var w = Jr(E), x = jr(C);
      switch (x) {
        case "top":
          break;
        case "center":
          l += g / 2;
          break;
        case "bottom":
          l += g;
          break;
      }
      var T = e.pstyle("text-background-opacity").value, D = e.pstyle("text-border-opacity").value, A = e.pstyle("text-border-width").pfValue, L = e.pstyle("text-background-padding").pfValue, R = e.pstyle("text-background-shape").strValue, P = R === "round-rectangle" || R === "roundrectangle", I = R === "circle", k = 2;
      if (T > 0 || A > 0 && D > 0) {
        var O = t.fillStyle, N = t.strokeStyle, F = t.lineWidth, G = e.pstyle("text-background-color").value, B = e.pstyle("text-border-color").value, z = e.pstyle("text-border-style").value, Y = T > 0, $ = A > 0 && D > 0, X = u - L;
        switch (w) {
          case "left":
            X -= d;
            break;
          case "center":
            X -= d / 2;
            break;
        }
        var j = l - g - L, ee = d + 2 * L, ae = g + 2 * L;
        if (Y && (t.fillStyle = "rgba(".concat(G[0], ",").concat(G[1], ",").concat(G[2], ",").concat(T * s, ")")), $ && (t.strokeStyle = "rgba(".concat(B[0], ",").concat(B[1], ",").concat(B[2], ",").concat(D * s, ")"), t.lineWidth = A, t.setLineDash))
          switch (z) {
            case "dotted":
              t.setLineDash([1, 1]);
              break;
            case "dashed":
              t.setLineDash([4, 2]);
              break;
            case "double":
              t.lineWidth = A / 4, t.setLineDash([]);
              break;
            case "solid":
            default:
              t.setLineDash([]);
              break;
          }
        if (P ? (t.beginPath(), Hl(t, X, j, ee, ae, k)) : I ? (t.beginPath(), Qy(t, X, j, ee, ae)) : (t.beginPath(), t.rect(X, j, ee, ae)), Y && t.fill(), $ && t.stroke(), $ && z === "double") {
          var K = A / 2;
          t.beginPath(), P ? Hl(t, X + K, j + K, ee - 2 * K, ae - 2 * K, k) : t.rect(X + K, j + K, ee - 2 * K, ae - 2 * K), t.stroke();
        }
        t.fillStyle = O, t.strokeStyle = N, t.lineWidth = F, t.setLineDash && t.setLineDash([]);
      }
      var V = 2 * e.pstyle("text-outline-width").pfValue;
      if (V > 0 && (t.lineWidth = V), l -= p, e.pstyle("text-wrap").value === "wrap") {
        var q = yt(o, "labelWrapCachedLines", r), H = yt(o, "labelLineHeight", r), Z = d / 2, re = this.getLabelJustification(e);
        switch (re === "auto" || (w === "left" ? re === "left" ? u += -d : re === "center" && (u += -Z) : w === "center" ? re === "left" ? u += -Z : re === "right" && (u += Z) : w === "right" && (re === "center" ? u += Z : re === "right" && (u += d))), x) {
          case "top":
            l -= (q.length - 1) * H;
            break;
          case "center":
          case "bottom":
            l -= (q.length - 1) * H;
            break;
        }
        for (var le = 0; le < q.length; le++)
          V > 0 && t.strokeText(q[le], u, l), t.fillText(q[le], u, l), l += H;
      } else
        V > 0 && t.strokeText(c, u, l), t.fillText(c, u, l);
      S !== 0 && (t.rotate(-S), t.translate(-f, -v));
    }
  }
};
var pr = {};
pr.drawNode = function(t, e, r) {
  var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, o = this, s, u, l = e._private, f = l.rscratch, v = e.position();
  if (!(!ne(v.x) || !ne(v.y)) && !(i && !e.visible())) {
    var c = i ? e.effectiveOpacity() : 1, h = o.usePaths(), d, g = !1, p = e.padding();
    s = e.width() + 2 * p, u = e.height() + 2 * p;
    var y;
    r && (y = r, t.translate(-y.x1, -y.y1));
    for (var b = e.pstyle("background-image"), m = b.value, E = new Array(m.length), C = new Array(m.length), S = 0, w = 0; w < m.length; w++) {
      var x = m[w], T = E[w] = x != null && x !== "none";
      if (T) {
        var D = e.cy().style().getIndexedStyle(e, "background-image-crossorigin", "value", w);
        S++, C[w] = o.getCachedImage(x, D, function() {
          l.backgroundTimestamp = Date.now(), e.emitAndNotify("background");
        });
      }
    }
    var A = e.pstyle("background-blacken").value, L = e.pstyle("border-width").pfValue, R = e.pstyle("background-opacity").value * c, P = e.pstyle("border-color").value, I = e.pstyle("border-style").value, k = e.pstyle("border-join").value, O = e.pstyle("border-cap").value, N = e.pstyle("border-position").value, F = e.pstyle("border-dash-pattern").pfValue, G = e.pstyle("border-dash-offset").pfValue, B = e.pstyle("border-opacity").value * c, z = e.pstyle("outline-width").pfValue, Y = e.pstyle("outline-color").value, $ = e.pstyle("outline-style").value, X = e.pstyle("outline-opacity").value * c, j = e.pstyle("outline-offset").value, ee = e.pstyle("corner-radius").value;
    ee !== "auto" && (ee = e.pstyle("corner-radius").pfValue);
    var ae = function() {
      var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : R;
      o.eleFillStyle(t, e, M);
    }, K = function() {
      var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : B;
      o.colorStrokeStyle(t, P[0], P[1], P[2], M);
    }, V = function() {
      var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : X;
      o.colorStrokeStyle(t, Y[0], Y[1], Y[2], M);
    }, q = function(M, _, U, W) {
      var Q = o.nodePathCache = o.nodePathCache || [], fe = bf(U === "polygon" ? U + "," + W.join(",") : U, "" + _, "" + M, "" + ee), te = Q[fe], ie, se = !1;
      return te != null ? (ie = te, se = !0, f.pathCache = ie) : (ie = new Path2D(), Q[fe] = f.pathCache = ie), {
        path: ie,
        cacheHit: se
      };
    }, H = e.pstyle("shape").strValue, Z = e.pstyle("shape-polygon-points").pfValue;
    if (h) {
      t.translate(v.x, v.y);
      var re = q(s, u, H, Z);
      d = re.path, g = re.cacheHit;
    }
    var le = function() {
      if (!g) {
        var M = v;
        h && (M = {
          x: 0,
          y: 0
        }), o.nodeShapes[o.getNodeShape(e)].draw(d || t, M.x, M.y, s, u, ee, f);
      }
      h ? t.fill(d) : t.fill();
    }, Ae = function() {
      for (var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : c, _ = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, U = l.backgrounding, W = 0, Q = 0; Q < C.length; Q++) {
        var fe = e.cy().style().getIndexedStyle(e, "background-image-containment", "value", Q);
        if (_ && fe === "over" || !_ && fe === "inside") {
          W++;
          continue;
        }
        E[Q] && C[Q].complete && !C[Q].error && (W++, o.drawInscribedImage(t, C[Q], e, Q, M));
      }
      l.backgrounding = W !== S, U !== l.backgrounding && e.updateStyle(!1);
    }, we = function() {
      var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, _ = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : c;
      o.hasPie(e) && (o.drawPie(t, e, _), M && (h || o.nodeShapes[o.getNodeShape(e)].draw(t, v.x, v.y, s, u, ee, f)));
    }, me = function() {
      var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, _ = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : c;
      o.hasStripe(e) && (t.save(), h ? t.clip(f.pathCache) : (o.nodeShapes[o.getNodeShape(e)].draw(t, v.x, v.y, s, u, ee, f), t.clip()), o.drawStripe(t, e, _), t.restore(), M && (h || o.nodeShapes[o.getNodeShape(e)].draw(t, v.x, v.y, s, u, ee, f)));
    }, ge = function() {
      var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : c, _ = (A > 0 ? A : -A) * M, U = A > 0 ? 0 : 255;
      A !== 0 && (o.colorFillStyle(t, U, U, U, _), h ? t.fill(d) : t.fill());
    }, oe = function() {
      if (L > 0) {
        if (t.lineWidth = L, t.lineCap = O, t.lineJoin = k, t.setLineDash)
          switch (I) {
            case "dotted":
              t.setLineDash([1, 1]);
              break;
            case "dashed":
              t.setLineDash(F), t.lineDashOffset = G;
              break;
            case "solid":
            case "double":
              t.setLineDash([]);
              break;
          }
        if (N !== "center") {
          if (t.save(), t.lineWidth *= 2, N === "inside")
            h ? t.clip(d) : t.clip();
          else {
            var M = new Path2D();
            M.rect(-s / 2 - L, -u / 2 - L, s + 2 * L, u + 2 * L), M.addPath(d), t.clip(M, "evenodd");
          }
          h ? t.stroke(d) : t.stroke(), t.restore();
        } else
          h ? t.stroke(d) : t.stroke();
        if (I === "double") {
          t.lineWidth = L / 3;
          var _ = t.globalCompositeOperation;
          t.globalCompositeOperation = "destination-out", h ? t.stroke(d) : t.stroke(), t.globalCompositeOperation = _;
        }
        t.setLineDash && t.setLineDash([]);
      }
    }, he = function() {
      if (z > 0) {
        if (t.lineWidth = z, t.lineCap = "butt", t.setLineDash)
          switch ($) {
            case "dotted":
              t.setLineDash([1, 1]);
              break;
            case "dashed":
              t.setLineDash([4, 2]);
              break;
            case "solid":
            case "double":
              t.setLineDash([]);
              break;
          }
        var M = v;
        h && (M = {
          x: 0,
          y: 0
        });
        var _ = o.getNodeShape(e), U = L;
        N === "inside" && (U = 0), N === "outside" && (U *= 2);
        var W = (s + U + (z + j)) / s, Q = (u + U + (z + j)) / u, fe = s * W, te = u * Q, ie = o.nodeShapes[_].points, se;
        if (h) {
          var pe = q(fe, te, _, ie);
          se = pe.path;
        }
        if (_ === "ellipse")
          o.drawEllipsePath(se || t, M.x, M.y, fe, te);
        else if (["round-diamond", "round-heptagon", "round-hexagon", "round-octagon", "round-pentagon", "round-polygon", "round-triangle", "round-tag"].includes(_)) {
          var xe = 0, Te = 0, ve = 0;
          _ === "round-diamond" ? xe = (U + j + z) * 1.4 : _ === "round-heptagon" ? (xe = (U + j + z) * 1.075, ve = -(U / 2 + j + z) / 35) : _ === "round-hexagon" ? xe = (U + j + z) * 1.12 : _ === "round-pentagon" ? (xe = (U + j + z) * 1.13, ve = -(U / 2 + j + z) / 15) : _ === "round-tag" ? (xe = (U + j + z) * 1.12, Te = (U / 2 + z + j) * 0.07) : _ === "round-triangle" && (xe = (U + j + z) * (Math.PI / 2), ve = -(U + j / 2 + z) / Math.PI), xe !== 0 && (W = (s + xe) / s, fe = s * W, ["round-hexagon", "round-tag"].includes(_) || (Q = (u + xe) / u, te = u * Q)), ee = ee === "auto" ? Rf(fe, te) : ee;
          for (var Se = fe / 2, Re = te / 2, at = ee + (U + z + j) / 2, Xe = new Array(ie.length / 2), Rt = new Array(ie.length / 2), We = 0; We < ie.length / 2; We++)
            Xe[We] = {
              x: M.x + Te + Se * ie[We * 2],
              y: M.y + ve + Re * ie[We * 2 + 1]
            };
          var Ke, Je, st, Bt, Ye = Xe.length;
          for (Je = Xe[Ye - 1], Ke = 0; Ke < Ye; Ke++)
            st = Xe[Ke % Ye], Bt = Xe[(Ke + 1) % Ye], Rt[Ke] = bs(Je, st, Bt, at), Je = st, st = Bt;
          o.drawRoundPolygonPath(se || t, M.x + Te, M.y + ve, s * W, u * Q, ie, Rt);
        } else if (["roundrectangle", "round-rectangle"].includes(_))
          ee = ee === "auto" ? lr(fe, te) : ee, o.drawRoundRectanglePath(se || t, M.x, M.y, fe, te, ee + (U + z + j) / 2);
        else if (["cutrectangle", "cut-rectangle"].includes(_))
          ee = ee === "auto" ? us() : ee, o.drawCutRectanglePath(se || t, M.x, M.y, fe, te, null, ee + (U + z + j) / 4);
        else if (["bottomroundrectangle", "bottom-round-rectangle"].includes(_))
          ee = ee === "auto" ? lr(fe, te) : ee, o.drawBottomRoundRectanglePath(se || t, M.x, M.y, fe, te, ee + (U + z + j) / 2);
        else if (_ === "barrel")
          o.drawBarrelPath(se || t, M.x, M.y, fe, te);
        else if (_.startsWith("polygon") || ["rhomboid", "right-rhomboid", "round-tag", "tag", "vee"].includes(_)) {
          var Ht = (U + z + j) / s;
          ie = Dn(Sn(ie, Ht)), o.drawPolygonPath(se || t, M.x, M.y, s, u, ie);
        } else {
          var Mt = (U + z + j) / s;
          ie = Dn(Sn(ie, -Mt)), o.drawPolygonPath(se || t, M.x, M.y, s, u, ie);
        }
        if (h ? t.stroke(se) : t.stroke(), $ === "double") {
          t.lineWidth = U / 3;
          var Jt = t.globalCompositeOperation;
          t.globalCompositeOperation = "destination-out", h ? t.stroke(se) : t.stroke(), t.globalCompositeOperation = Jt;
        }
        t.setLineDash && t.setLineDash([]);
      }
    }, ce = function() {
      n && o.drawNodeOverlay(t, e, v, s, u);
    }, Ee = function() {
      n && o.drawNodeUnderlay(t, e, v, s, u);
    }, be = function() {
      o.drawElementText(t, e, null, a);
    }, De = e.pstyle("ghost").value === "yes";
    if (De) {
      var Le = e.pstyle("ghost-offset-x").pfValue, Ne = e.pstyle("ghost-offset-y").pfValue, Oe = e.pstyle("ghost-opacity").value, Me = Oe * c;
      t.translate(Le, Ne), V(), he(), ae(Oe * R), le(), Ae(Me, !0), K(Oe * B), oe(), we(A !== 0 || L !== 0), me(A !== 0 || L !== 0), Ae(Me, !1), ge(Me), t.translate(-Le, -Ne);
    }
    h && t.translate(-v.x, -v.y), Ee(), h && t.translate(v.x, v.y), V(), he(), ae(), le(), Ae(c, !0), K(), oe(), we(A !== 0 || L !== 0), me(A !== 0 || L !== 0), Ae(c, !1), ge(), h && t.translate(-v.x, -v.y), be(), ce(), r && t.translate(y.x1, y.y1);
  }
};
var Bv = function(e) {
  if (!["overlay", "underlay"].includes(e))
    throw new Error("Invalid state");
  return function(r, a, n, i, o) {
    var s = this;
    if (a.visible()) {
      var u = a.pstyle("".concat(e, "-padding")).pfValue, l = a.pstyle("".concat(e, "-opacity")).value, f = a.pstyle("".concat(e, "-color")).value, v = a.pstyle("".concat(e, "-shape")).value, c = a.pstyle("".concat(e, "-corner-radius")).value;
      if (l > 0) {
        if (n = n || a.position(), i == null || o == null) {
          var h = a.padding();
          i = a.width() + 2 * h, o = a.height() + 2 * h;
        }
        s.colorFillStyle(r, f[0], f[1], f[2], l), s.nodeShapes[v].draw(r, n.x, n.y, i + u * 2, o + u * 2, c), r.fill();
      }
    }
  };
};
pr.drawNodeOverlay = Bv("overlay");
pr.drawNodeUnderlay = Bv("underlay");
pr.hasPie = function(t) {
  return t = t[0], t._private.hasPie;
};
pr.hasStripe = function(t) {
  return t = t[0], t._private.hasStripe;
};
pr.drawPie = function(t, e, r, a) {
  e = e[0], a = a || e.position();
  var n = e.cy().style(), i = e.pstyle("pie-size"), o = e.pstyle("pie-hole"), s = e.pstyle("pie-start-angle").pfValue, u = a.x, l = a.y, f = e.width(), v = e.height(), c = Math.min(f, v) / 2, h, d = 0, g = this.usePaths();
  if (g && (u = 0, l = 0), i.units === "%" ? c = c * i.pfValue : i.pfValue !== void 0 && (c = i.pfValue / 2), o.units === "%" ? h = c * o.pfValue : o.pfValue !== void 0 && (h = o.pfValue / 2), !(h >= c))
    for (var p = 1; p <= n.pieBackgroundN; p++) {
      var y = e.pstyle("pie-" + p + "-background-size").value, b = e.pstyle("pie-" + p + "-background-color").value, m = e.pstyle("pie-" + p + "-background-opacity").value * r, E = y / 100;
      E + d > 1 && (E = 1 - d);
      var C = 1.5 * Math.PI + 2 * Math.PI * d;
      C += s;
      var S = 2 * Math.PI * E, w = C + S;
      y === 0 || d >= 1 || d + E > 1 || (h === 0 ? (t.beginPath(), t.moveTo(u, l), t.arc(u, l, c, C, w), t.closePath()) : (t.beginPath(), t.arc(u, l, c, C, w), t.arc(u, l, h, w, C, !0), t.closePath()), this.colorFillStyle(t, b[0], b[1], b[2], m), t.fill(), d += E);
    }
};
pr.drawStripe = function(t, e, r, a) {
  e = e[0], a = a || e.position();
  var n = e.cy().style(), i = a.x, o = a.y, s = e.width(), u = e.height(), l = 0, f = this.usePaths();
  t.save();
  var v = e.pstyle("stripe-direction").value, c = e.pstyle("stripe-size");
  switch (v) {
    case "vertical":
      break;
    // default
    case "righward":
      t.rotate(-Math.PI / 2);
      break;
  }
  var h = s, d = u;
  c.units === "%" ? (h = h * c.pfValue, d = d * c.pfValue) : c.pfValue !== void 0 && (h = c.pfValue, d = c.pfValue), f && (i = 0, o = 0), o -= h / 2, i -= d / 2;
  for (var g = 1; g <= n.stripeBackgroundN; g++) {
    var p = e.pstyle("stripe-" + g + "-background-size").value, y = e.pstyle("stripe-" + g + "-background-color").value, b = e.pstyle("stripe-" + g + "-background-opacity").value * r, m = p / 100;
    m + l > 1 && (m = 1 - l), !(p === 0 || l >= 1 || l + m > 1) && (t.beginPath(), t.rect(i, o + d * l, h, d * m), t.closePath(), this.colorFillStyle(t, y[0], y[1], y[2], b), t.fill(), l += m);
  }
  t.restore();
};
var bt = {}, Jy = 100;
bt.getPixelRatio = function() {
  var t = this.data.contexts[0];
  if (this.forcedPixelRatio != null)
    return this.forcedPixelRatio;
  var e = this.cy.window(), r = t.backingStorePixelRatio || t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1;
  return (e.devicePixelRatio || 1) / r;
};
bt.paintCache = function(t) {
  for (var e = this.paintCaches = this.paintCaches || [], r = !0, a, n = 0; n < e.length; n++)
    if (a = e[n], a.context === t) {
      r = !1;
      break;
    }
  return r && (a = {
    context: t
  }, e.push(a)), a;
};
bt.createGradientStyleFor = function(t, e, r, a, n) {
  var i, o = this.usePaths(), s = r.pstyle(e + "-gradient-stop-colors").value, u = r.pstyle(e + "-gradient-stop-positions").pfValue;
  if (a === "radial-gradient")
    if (r.isEdge()) {
      var l = r.sourceEndpoint(), f = r.targetEndpoint(), v = r.midpoint(), c = Ar(l, v), h = Ar(f, v);
      i = t.createRadialGradient(v.x, v.y, 0, v.x, v.y, Math.max(c, h));
    } else {
      var d = o ? {
        x: 0,
        y: 0
      } : r.position(), g = r.paddedWidth(), p = r.paddedHeight();
      i = t.createRadialGradient(d.x, d.y, 0, d.x, d.y, Math.max(g, p));
    }
  else if (r.isEdge()) {
    var y = r.sourceEndpoint(), b = r.targetEndpoint();
    i = t.createLinearGradient(y.x, y.y, b.x, b.y);
  } else {
    var m = o ? {
      x: 0,
      y: 0
    } : r.position(), E = r.paddedWidth(), C = r.paddedHeight(), S = E / 2, w = C / 2, x = r.pstyle("background-gradient-direction").value;
    switch (x) {
      case "to-bottom":
        i = t.createLinearGradient(m.x, m.y - w, m.x, m.y + w);
        break;
      case "to-top":
        i = t.createLinearGradient(m.x, m.y + w, m.x, m.y - w);
        break;
      case "to-left":
        i = t.createLinearGradient(m.x + S, m.y, m.x - S, m.y);
        break;
      case "to-right":
        i = t.createLinearGradient(m.x - S, m.y, m.x + S, m.y);
        break;
      case "to-bottom-right":
      case "to-right-bottom":
        i = t.createLinearGradient(m.x - S, m.y - w, m.x + S, m.y + w);
        break;
      case "to-top-right":
      case "to-right-top":
        i = t.createLinearGradient(m.x - S, m.y + w, m.x + S, m.y - w);
        break;
      case "to-bottom-left":
      case "to-left-bottom":
        i = t.createLinearGradient(m.x + S, m.y - w, m.x - S, m.y + w);
        break;
      case "to-top-left":
      case "to-left-top":
        i = t.createLinearGradient(m.x + S, m.y + w, m.x - S, m.y - w);
        break;
    }
  }
  if (!i) return null;
  for (var T = u.length === s.length, D = s.length, A = 0; A < D; A++)
    i.addColorStop(T ? u[A] : A / (D - 1), "rgba(" + s[A][0] + "," + s[A][1] + "," + s[A][2] + "," + n + ")");
  return i;
};
bt.gradientFillStyle = function(t, e, r, a) {
  var n = this.createGradientStyleFor(t, "background", e, r, a);
  if (!n) return null;
  t.fillStyle = n;
};
bt.colorFillStyle = function(t, e, r, a, n) {
  t.fillStyle = "rgba(" + e + "," + r + "," + a + "," + n + ")";
};
bt.eleFillStyle = function(t, e, r) {
  var a = e.pstyle("background-fill").value;
  if (a === "linear-gradient" || a === "radial-gradient")
    this.gradientFillStyle(t, e, a, r);
  else {
    var n = e.pstyle("background-color").value;
    this.colorFillStyle(t, n[0], n[1], n[2], r);
  }
};
bt.gradientStrokeStyle = function(t, e, r, a) {
  var n = this.createGradientStyleFor(t, "line", e, r, a);
  if (!n) return null;
  t.strokeStyle = n;
};
bt.colorStrokeStyle = function(t, e, r, a, n) {
  t.strokeStyle = "rgba(" + e + "," + r + "," + a + "," + n + ")";
};
bt.eleStrokeStyle = function(t, e, r) {
  var a = e.pstyle("line-fill").value;
  if (a === "linear-gradient" || a === "radial-gradient")
    this.gradientStrokeStyle(t, e, a, r);
  else {
    var n = e.pstyle("line-color").value;
    this.colorStrokeStyle(t, n[0], n[1], n[2], r);
  }
};
bt.matchCanvasSize = function(t) {
  var e = this, r = e.data, a = e.findContainerClientCoords(), n = a[2], i = a[3], o = e.getPixelRatio(), s = e.motionBlurPxRatio;
  (t === e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE] || t === e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG]) && (o = s);
  var u = n * o, l = i * o, f;
  if (!(u === e.canvasWidth && l === e.canvasHeight)) {
    e.fontCaches = null;
    var v = r.canvasContainer;
    v.style.width = n + "px", v.style.height = i + "px";
    for (var c = 0; c < e.CANVAS_LAYERS; c++)
      f = r.canvases[c], f.width = u, f.height = l, f.style.width = n + "px", f.style.height = i + "px";
    for (var c = 0; c < e.BUFFER_COUNT; c++)
      f = r.bufferCanvases[c], f.width = u, f.height = l, f.style.width = n + "px", f.style.height = i + "px";
    e.textureMult = 1, o <= 1 && (f = r.bufferCanvases[e.TEXTURE_BUFFER], e.textureMult = 2, f.width = u * e.textureMult, f.height = l * e.textureMult), e.canvasWidth = u, e.canvasHeight = l, e.pixelRatio = o;
  }
};
bt.renderTo = function(t, e, r, a) {
  this.render({
    forcedContext: t,
    forcedZoom: e,
    forcedPan: r,
    drawAllLayers: !0,
    forcedPxRatio: a
  });
};
bt.clearCanvas = function() {
  var t = this, e = t.data;
  function r(a) {
    a.clearRect(0, 0, t.canvasWidth, t.canvasHeight);
  }
  r(e.contexts[t.NODE]), r(e.contexts[t.DRAG]);
};
bt.render = function(t) {
  var e = this;
  t = t || Tf();
  var r = e.cy, a = t.forcedContext, n = t.drawAllLayers, i = t.drawOnlyNodeLayer, o = t.forcedZoom, s = t.forcedPan, u = t.forcedPxRatio === void 0 ? this.getPixelRatio() : t.forcedPxRatio, l = e.data, f = l.canvasNeedsRedraw, v = e.textureOnViewport && !a && (e.pinching || e.hoverData.dragging || e.swipePanning || e.data.wheelZooming), c = t.motionBlur !== void 0 ? t.motionBlur : e.motionBlur, h = e.motionBlurPxRatio, d = r.hasCompoundNodes(), g = e.hoverData.draggingEles, p = !!(e.hoverData.selecting || e.touchData.selecting);
  c = c && !a && e.motionBlurEnabled && !p;
  var y = c;
  a || (e.prevPxRatio !== u && (e.invalidateContainerClientCoordsCache(), e.matchCanvasSize(e.container), e.redrawHint("eles", !0), e.redrawHint("drag", !0)), e.prevPxRatio = u), !a && e.motionBlurTimeout && clearTimeout(e.motionBlurTimeout), c && (e.mbFrames == null && (e.mbFrames = 0), e.mbFrames++, e.mbFrames < 3 && (y = !1), e.mbFrames > e.minMbLowQualFrames && (e.motionBlurPxRatio = e.mbPxRBlurry)), e.clearingMotionBlur && (e.motionBlurPxRatio = 1), e.textureDrawLastFrame && !v && (f[e.NODE] = !0, f[e.SELECT_BOX] = !0);
  var b = r.style(), m = r.zoom(), E = o !== void 0 ? o : m, C = r.pan(), S = {
    x: C.x,
    y: C.y
  }, w = {
    zoom: m,
    pan: {
      x: C.x,
      y: C.y
    }
  }, x = e.prevViewport, T = x === void 0 || w.zoom !== x.zoom || w.pan.x !== x.pan.x || w.pan.y !== x.pan.y;
  !T && !(g && !d) && (e.motionBlurPxRatio = 1), s && (S = s), E *= u, S.x *= u, S.y *= u;
  var D = e.getCachedZSortedEles();
  function A(K, V, q, H, Z) {
    var re = K.globalCompositeOperation;
    K.globalCompositeOperation = "destination-out", e.colorFillStyle(K, 255, 255, 255, e.motionBlurTransparency), K.fillRect(V, q, H, Z), K.globalCompositeOperation = re;
  }
  function L(K, V) {
    var q, H, Z, re;
    !e.clearingMotionBlur && (K === l.bufferContexts[e.MOTIONBLUR_BUFFER_NODE] || K === l.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG]) ? (q = {
      x: C.x * h,
      y: C.y * h
    }, H = m * h, Z = e.canvasWidth * h, re = e.canvasHeight * h) : (q = S, H = E, Z = e.canvasWidth, re = e.canvasHeight), K.setTransform(1, 0, 0, 1, 0, 0), V === "motionBlur" ? A(K, 0, 0, Z, re) : !a && (V === void 0 || V) && K.clearRect(0, 0, Z, re), n || (K.translate(q.x, q.y), K.scale(H, H)), s && K.translate(s.x, s.y), o && K.scale(o, o);
  }
  if (v || (e.textureDrawLastFrame = !1), v) {
    if (e.textureDrawLastFrame = !0, !e.textureCache) {
      e.textureCache = {}, e.textureCache.bb = r.mutableElements().boundingBox(), e.textureCache.texture = e.data.bufferCanvases[e.TEXTURE_BUFFER];
      var R = e.data.bufferContexts[e.TEXTURE_BUFFER];
      R.setTransform(1, 0, 0, 1, 0, 0), R.clearRect(0, 0, e.canvasWidth * e.textureMult, e.canvasHeight * e.textureMult), e.render({
        forcedContext: R,
        drawOnlyNodeLayer: !0,
        forcedPxRatio: u * e.textureMult
      });
      var w = e.textureCache.viewport = {
        zoom: r.zoom(),
        pan: r.pan(),
        width: e.canvasWidth,
        height: e.canvasHeight
      };
      w.mpan = {
        x: (0 - w.pan.x) / w.zoom,
        y: (0 - w.pan.y) / w.zoom
      };
    }
    f[e.DRAG] = !1, f[e.NODE] = !1;
    var P = l.contexts[e.NODE], I = e.textureCache.texture, w = e.textureCache.viewport;
    P.setTransform(1, 0, 0, 1, 0, 0), c ? A(P, 0, 0, w.width, w.height) : P.clearRect(0, 0, w.width, w.height);
    var k = b.core("outside-texture-bg-color").value, O = b.core("outside-texture-bg-opacity").value;
    e.colorFillStyle(P, k[0], k[1], k[2], O), P.fillRect(0, 0, w.width, w.height);
    var m = r.zoom();
    L(P, !1), P.clearRect(w.mpan.x, w.mpan.y, w.width / w.zoom / u, w.height / w.zoom / u), P.drawImage(I, w.mpan.x, w.mpan.y, w.width / w.zoom / u, w.height / w.zoom / u);
  } else e.textureOnViewport && !a && (e.textureCache = null);
  var N = r.extent(), F = e.pinching || e.hoverData.dragging || e.swipePanning || e.data.wheelZooming || e.hoverData.draggingEles || e.cy.animated(), G = e.hideEdgesOnViewport && F, B = [];
  if (B[e.NODE] = !f[e.NODE] && c && !e.clearedForMotionBlur[e.NODE] || e.clearingMotionBlur, B[e.NODE] && (e.clearedForMotionBlur[e.NODE] = !0), B[e.DRAG] = !f[e.DRAG] && c && !e.clearedForMotionBlur[e.DRAG] || e.clearingMotionBlur, B[e.DRAG] && (e.clearedForMotionBlur[e.DRAG] = !0), f[e.NODE] || n || i || B[e.NODE]) {
    var z = c && !B[e.NODE] && h !== 1, P = a || (z ? e.data.bufferContexts[e.MOTIONBLUR_BUFFER_NODE] : l.contexts[e.NODE]), Y = c && !z ? "motionBlur" : void 0;
    L(P, Y), G ? e.drawCachedNodes(P, D.nondrag, u, N) : e.drawLayeredElements(P, D.nondrag, u, N), e.debug && e.drawDebugPoints(P, D.nondrag), !n && !c && (f[e.NODE] = !1);
  }
  if (!i && (f[e.DRAG] || n || B[e.DRAG])) {
    var z = c && !B[e.DRAG] && h !== 1, P = a || (z ? e.data.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG] : l.contexts[e.DRAG]);
    L(P, c && !z ? "motionBlur" : void 0), G ? e.drawCachedNodes(P, D.drag, u, N) : e.drawCachedElements(P, D.drag, u, N), e.debug && e.drawDebugPoints(P, D.drag), !n && !c && (f[e.DRAG] = !1);
  }
  if (this.drawSelectionRectangle(t, L), c && h !== 1) {
    var $ = l.contexts[e.NODE], X = e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE], j = l.contexts[e.DRAG], ee = e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG], ae = function(V, q, H) {
      V.setTransform(1, 0, 0, 1, 0, 0), H || !y ? V.clearRect(0, 0, e.canvasWidth, e.canvasHeight) : A(V, 0, 0, e.canvasWidth, e.canvasHeight);
      var Z = h;
      V.drawImage(
        q,
        // img
        0,
        0,
        // sx, sy
        e.canvasWidth * Z,
        e.canvasHeight * Z,
        // sw, sh
        0,
        0,
        // x, y
        e.canvasWidth,
        e.canvasHeight
        // w, h
      );
    };
    (f[e.NODE] || B[e.NODE]) && (ae($, X, B[e.NODE]), f[e.NODE] = !1), (f[e.DRAG] || B[e.DRAG]) && (ae(j, ee, B[e.DRAG]), f[e.DRAG] = !1);
  }
  e.prevViewport = w, e.clearingMotionBlur && (e.clearingMotionBlur = !1, e.motionBlurCleared = !0, e.motionBlur = !0), c && (e.motionBlurTimeout = setTimeout(function() {
    e.motionBlurTimeout = null, e.clearedForMotionBlur[e.NODE] = !1, e.clearedForMotionBlur[e.DRAG] = !1, e.motionBlur = !1, e.clearingMotionBlur = !v, e.mbFrames = 0, f[e.NODE] = !0, f[e.DRAG] = !0, e.redraw();
  }, Jy)), a || r.emit("render");
};
var da;
bt.drawSelectionRectangle = function(t, e) {
  var r = this, a = r.cy, n = r.data, i = a.style(), o = t.drawOnlyNodeLayer, s = t.drawAllLayers, u = n.canvasNeedsRedraw, l = t.forcedContext;
  if (r.showFps || !o && u[r.SELECT_BOX] && !s) {
    var f = l || n.contexts[r.SELECT_BOX];
    if (e(f), r.selection[4] == 1 && (r.hoverData.selecting || r.touchData.selecting)) {
      var v = r.cy.zoom(), c = i.core("selection-box-border-width").value / v;
      f.lineWidth = c, f.fillStyle = "rgba(" + i.core("selection-box-color").value[0] + "," + i.core("selection-box-color").value[1] + "," + i.core("selection-box-color").value[2] + "," + i.core("selection-box-opacity").value + ")", f.fillRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]), c > 0 && (f.strokeStyle = "rgba(" + i.core("selection-box-border-color").value[0] + "," + i.core("selection-box-border-color").value[1] + "," + i.core("selection-box-border-color").value[2] + "," + i.core("selection-box-opacity").value + ")", f.strokeRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]));
    }
    if (n.bgActivePosistion && !r.hoverData.selecting) {
      var v = r.cy.zoom(), h = n.bgActivePosistion;
      f.fillStyle = "rgba(" + i.core("active-bg-color").value[0] + "," + i.core("active-bg-color").value[1] + "," + i.core("active-bg-color").value[2] + "," + i.core("active-bg-opacity").value + ")", f.beginPath(), f.arc(h.x, h.y, i.core("active-bg-size").pfValue / v, 0, 2 * Math.PI), f.fill();
    }
    var d = r.lastRedrawTime;
    if (r.showFps && d) {
      d = Math.round(d);
      var g = Math.round(1e3 / d), p = "1 frame = " + d + " ms = " + g + " fps";
      if (f.setTransform(1, 0, 0, 1, 0, 0), f.fillStyle = "rgba(255, 0, 0, 0.75)", f.strokeStyle = "rgba(255, 0, 0, 0.75)", f.font = "30px Arial", !da) {
        var y = f.measureText(p);
        da = y.actualBoundingBoxAscent;
      }
      f.fillText(p, 0, da);
      var b = 60;
      f.strokeRect(0, da + 10, 250, 20), f.fillRect(0, da + 10, 250 * Math.min(g / b, 1), 20);
    }
    s || (u[r.SELECT_BOX] = !1);
  }
};
function Xl(t, e, r) {
  var a = t.createShader(e);
  if (t.shaderSource(a, r), t.compileShader(a), !t.getShaderParameter(a, t.COMPILE_STATUS))
    throw new Error(t.getShaderInfoLog(a));
  return a;
}
function jy(t, e, r) {
  var a = Xl(t, t.VERTEX_SHADER, e), n = Xl(t, t.FRAGMENT_SHADER, r), i = t.createProgram();
  if (t.attachShader(i, a), t.attachShader(i, n), t.linkProgram(i), !t.getProgramParameter(i, t.LINK_STATUS))
    throw new Error("Could not initialize shaders");
  return i;
}
function em(t, e, r) {
  r === void 0 && (r = e);
  var a = t.makeOffscreenCanvas(e, r), n = a.context = a.getContext("2d");
  return a.clear = function() {
    return n.clearRect(0, 0, a.width, a.height);
  }, a.clear(), a;
}
function xs(t) {
  var e = t.pixelRatio, r = t.cy.zoom(), a = t.cy.pan();
  return {
    zoom: r * e,
    pan: {
      x: a.x * e,
      y: a.y * e
    }
  };
}
function tm(t) {
  var e = t.pixelRatio, r = t.cy.zoom();
  return r * e;
}
function rm(t, e, r, a, n) {
  var i = a * r + e.x, o = n * r + e.y;
  return o = Math.round(t.canvasHeight - o), [i, o];
}
function am(t, e) {
  return e.picking ? !0 : t.pstyle("background-fill").value !== "solid" || t.pstyle("background-image").strValue !== "none" ? !1 : t.pstyle("border-width").value === 0 || t.pstyle("border-opacity").value === 0 ? !0 : t.pstyle("border-style").value === "solid";
}
function nm(t, e) {
  if (t.length !== e.length)
    return !1;
  for (var r = 0; r < t.length; r++)
    if (t[r] !== e[r])
      return !1;
  return !0;
}
function wr(t, e, r) {
  var a = t[0] / 255, n = t[1] / 255, i = t[2] / 255, o = e, s = r || new Array(4);
  return s[0] = a * o, s[1] = n * o, s[2] = i * o, s[3] = o, s;
}
function Gr(t, e) {
  var r = e || new Array(4);
  return r[0] = (t >> 0 & 255) / 255, r[1] = (t >> 8 & 255) / 255, r[2] = (t >> 16 & 255) / 255, r[3] = (t >> 24 & 255) / 255, r;
}
function im(t) {
  return t[0] + (t[1] << 8) + (t[2] << 16) + (t[3] << 24);
}
function om(t, e) {
  var r = t.createTexture();
  return r.buffer = function(a) {
    t.bindTexture(t.TEXTURE_2D, r), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR_MIPMAP_NEAREST), t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, a), t.generateMipmap(t.TEXTURE_2D), t.bindTexture(t.TEXTURE_2D, null);
  }, r.deleteTexture = function() {
    t.deleteTexture(r);
  }, r;
}
function Fv(t, e) {
  switch (e) {
    case "float":
      return [1, t.FLOAT, 4];
    case "vec2":
      return [2, t.FLOAT, 4];
    case "vec3":
      return [3, t.FLOAT, 4];
    case "vec4":
      return [4, t.FLOAT, 4];
    case "int":
      return [1, t.INT, 4];
    case "ivec2":
      return [2, t.INT, 4];
  }
}
function Gv(t, e, r) {
  switch (e) {
    case t.FLOAT:
      return new Float32Array(r);
    case t.INT:
      return new Int32Array(r);
  }
}
function sm(t, e, r, a, n, i) {
  switch (e) {
    case t.FLOAT:
      return new Float32Array(r.buffer, i * a, n);
    case t.INT:
      return new Int32Array(r.buffer, i * a, n);
  }
}
function um(t, e, r, a) {
  var n = Fv(t, e), i = Qe(n, 2), o = i[0], s = i[1], u = Gv(t, s, a), l = t.createBuffer();
  return t.bindBuffer(t.ARRAY_BUFFER, l), t.bufferData(t.ARRAY_BUFFER, u, t.STATIC_DRAW), s === t.FLOAT ? t.vertexAttribPointer(r, o, s, !1, 0, 0) : s === t.INT && t.vertexAttribIPointer(r, o, s, 0, 0), t.enableVertexAttribArray(r), t.bindBuffer(t.ARRAY_BUFFER, null), l;
}
function Gt(t, e, r, a) {
  var n = Fv(t, r), i = Qe(n, 3), o = i[0], s = i[1], u = i[2], l = Gv(t, s, e * o), f = o * u, v = t.createBuffer();
  t.bindBuffer(t.ARRAY_BUFFER, v), t.bufferData(t.ARRAY_BUFFER, e * f, t.DYNAMIC_DRAW), t.enableVertexAttribArray(a), s === t.FLOAT ? t.vertexAttribPointer(a, o, s, !1, f, 0) : s === t.INT && t.vertexAttribIPointer(a, o, s, f, 0), t.vertexAttribDivisor(a, 1), t.bindBuffer(t.ARRAY_BUFFER, null);
  for (var c = new Array(e), h = 0; h < e; h++)
    c[h] = sm(t, s, l, f, o, h);
  return v.dataArray = l, v.stride = f, v.size = o, v.getView = function(d) {
    return c[d];
  }, v.setPoint = function(d, g, p) {
    var y = c[d];
    y[0] = g, y[1] = p;
  }, v.bufferSubData = function(d) {
    t.bindBuffer(t.ARRAY_BUFFER, v), d ? t.bufferSubData(t.ARRAY_BUFFER, 0, l, 0, d * o) : t.bufferSubData(t.ARRAY_BUFFER, 0, l);
  }, v;
}
function lm(t, e, r) {
  for (var a = 9, n = new Float32Array(e * a), i = new Array(e), o = 0; o < e; o++) {
    var s = o * a * 4;
    i[o] = new Float32Array(n.buffer, s, a);
  }
  var u = t.createBuffer();
  t.bindBuffer(t.ARRAY_BUFFER, u), t.bufferData(t.ARRAY_BUFFER, n.byteLength, t.DYNAMIC_DRAW);
  for (var l = 0; l < 3; l++) {
    var f = r + l;
    t.enableVertexAttribArray(f), t.vertexAttribPointer(f, 3, t.FLOAT, !1, 36, l * 12), t.vertexAttribDivisor(f, 1);
  }
  return t.bindBuffer(t.ARRAY_BUFFER, null), u.getMatrixView = function(v) {
    return i[v];
  }, u.setData = function(v, c) {
    i[c].set(v, 0);
  }, u.bufferSubData = function() {
    t.bindBuffer(t.ARRAY_BUFFER, u), t.bufferSubData(t.ARRAY_BUFFER, 0, n);
  }, u;
}
function fm(t) {
  var e = t.createFramebuffer();
  t.bindFramebuffer(t.FRAMEBUFFER, e);
  var r = t.createTexture();
  return t.bindTexture(t.TEXTURE_2D, r), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, r, 0), t.bindFramebuffer(t.FRAMEBUFFER, null), e.setFramebufferAttachmentSizes = function(a, n) {
    t.bindTexture(t.TEXTURE_2D, r), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, a, n, 0, t.RGBA, t.UNSIGNED_BYTE, null);
  }, e;
}
var Wl = typeof Float32Array < "u" ? Float32Array : Array;
Math.hypot || (Math.hypot = function() {
  for (var t = 0, e = arguments.length; e--; )
    t += arguments[e] * arguments[e];
  return Math.sqrt(t);
});
function So() {
  var t = new Wl(9);
  return Wl != Float32Array && (t[1] = 0, t[2] = 0, t[3] = 0, t[5] = 0, t[6] = 0, t[7] = 0), t[0] = 1, t[4] = 1, t[8] = 1, t;
}
function $l(t) {
  return t[0] = 1, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 1, t[5] = 0, t[6] = 0, t[7] = 0, t[8] = 1, t;
}
function vm(t, e, r) {
  var a = e[0], n = e[1], i = e[2], o = e[3], s = e[4], u = e[5], l = e[6], f = e[7], v = e[8], c = r[0], h = r[1], d = r[2], g = r[3], p = r[4], y = r[5], b = r[6], m = r[7], E = r[8];
  return t[0] = c * a + h * o + d * l, t[1] = c * n + h * s + d * f, t[2] = c * i + h * u + d * v, t[3] = g * a + p * o + y * l, t[4] = g * n + p * s + y * f, t[5] = g * i + p * u + y * v, t[6] = b * a + m * o + E * l, t[7] = b * n + m * s + E * f, t[8] = b * i + m * u + E * v, t;
}
function yn(t, e, r) {
  var a = e[0], n = e[1], i = e[2], o = e[3], s = e[4], u = e[5], l = e[6], f = e[7], v = e[8], c = r[0], h = r[1];
  return t[0] = a, t[1] = n, t[2] = i, t[3] = o, t[4] = s, t[5] = u, t[6] = c * a + h * o + l, t[7] = c * n + h * s + f, t[8] = c * i + h * u + v, t;
}
function Kl(t, e, r) {
  var a = e[0], n = e[1], i = e[2], o = e[3], s = e[4], u = e[5], l = e[6], f = e[7], v = e[8], c = Math.sin(r), h = Math.cos(r);
  return t[0] = h * a + c * o, t[1] = h * n + c * s, t[2] = h * i + c * u, t[3] = h * o - c * a, t[4] = h * s - c * n, t[5] = h * u - c * i, t[6] = l, t[7] = f, t[8] = v, t;
}
function $o(t, e, r) {
  var a = r[0], n = r[1];
  return t[0] = a * e[0], t[1] = a * e[1], t[2] = a * e[2], t[3] = n * e[3], t[4] = n * e[4], t[5] = n * e[5], t[6] = e[6], t[7] = e[7], t[8] = e[8], t;
}
function cm(t, e, r) {
  return t[0] = 2 / e, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = -2 / r, t[5] = 0, t[6] = -1, t[7] = 1, t[8] = 1, t;
}
var hm = /* @__PURE__ */ (function() {
  function t(e, r, a, n) {
    hr(this, t), this.debugID = Math.floor(Math.random() * 1e4), this.r = e, this.texSize = r, this.texRows = a, this.texHeight = Math.floor(r / a), this.enableWrapping = !0, this.locked = !1, this.texture = null, this.needsBuffer = !0, this.freePointer = {
      x: 0,
      row: 0
    }, this.keyToLocation = /* @__PURE__ */ new Map(), this.canvas = n(e, r, r), this.scratch = n(e, r, this.texHeight, "scratch");
  }
  return dr(t, [{
    key: "lock",
    value: function() {
      this.locked = !0;
    }
  }, {
    key: "getKeys",
    value: function() {
      return new Set(this.keyToLocation.keys());
    }
  }, {
    key: "getScale",
    value: function(r) {
      var a = r.w, n = r.h, i = this.texHeight, o = this.texSize, s = i / n, u = a * s, l = n * s;
      return u > o && (s = o / a, u = a * s, l = n * s), {
        scale: s,
        texW: u,
        texH: l
      };
    }
  }, {
    key: "draw",
    value: function(r, a, n) {
      var i = this;
      if (this.locked) throw new Error("can't draw, atlas is locked");
      var o = this.texSize, s = this.texRows, u = this.texHeight, l = this.getScale(a), f = l.scale, v = l.texW, c = l.texH, h = function(m, E) {
        if (n && E) {
          var C = E.context, S = m.x, w = m.row, x = S, T = u * w;
          C.save(), C.translate(x, T), C.scale(f, f), n(C, a), C.restore();
        }
      }, d = [null, null], g = function() {
        h(i.freePointer, i.canvas), d[0] = {
          x: i.freePointer.x,
          y: i.freePointer.row * u,
          w: v,
          h: c
        }, d[1] = {
          // create a second location with a width of 0, for convenience
          x: i.freePointer.x + v,
          y: i.freePointer.row * u,
          w: 0,
          h: c
        }, i.freePointer.x += v, i.freePointer.x == o && (i.freePointer.x = 0, i.freePointer.row++);
      }, p = function() {
        var m = i.scratch, E = i.canvas;
        m.clear(), h({
          x: 0,
          row: 0
        }, m);
        var C = o - i.freePointer.x, S = v - C, w = u;
        {
          var x = i.freePointer.x, T = i.freePointer.row * u, D = C;
          E.context.drawImage(m, 0, 0, D, w, x, T, D, w), d[0] = {
            x,
            y: T,
            w: D,
            h: c
          };
        }
        {
          var A = C, L = (i.freePointer.row + 1) * u, R = S;
          E && E.context.drawImage(m, A, 0, R, w, 0, L, R, w), d[1] = {
            x: 0,
            y: L,
            w: R,
            h: c
          };
        }
        i.freePointer.x = S, i.freePointer.row++;
      }, y = function() {
        i.freePointer.x = 0, i.freePointer.row++;
      };
      if (this.freePointer.x + v <= o)
        g();
      else {
        if (this.freePointer.row >= s - 1)
          return !1;
        this.freePointer.x === o ? (y(), g()) : this.enableWrapping ? p() : (y(), g());
      }
      return this.keyToLocation.set(r, d), this.needsBuffer = !0, d;
    }
  }, {
    key: "getOffsets",
    value: function(r) {
      return this.keyToLocation.get(r);
    }
  }, {
    key: "isEmpty",
    value: function() {
      return this.freePointer.x === 0 && this.freePointer.row === 0;
    }
  }, {
    key: "canFit",
    value: function(r) {
      if (this.locked) return !1;
      var a = this.texSize, n = this.texRows, i = this.getScale(r), o = i.texW;
      return this.freePointer.x + o > a ? this.freePointer.row < n - 1 : !0;
    }
    // called on every frame
  }, {
    key: "bufferIfNeeded",
    value: function(r) {
      this.texture || (this.texture = om(r, this.debugID)), this.needsBuffer && (this.texture.buffer(this.canvas), this.needsBuffer = !1, this.locked && (this.canvas = null, this.scratch = null));
    }
  }, {
    key: "dispose",
    value: function() {
      this.texture && (this.texture.deleteTexture(), this.texture = null), this.canvas = null, this.scratch = null, this.locked = !0;
    }
  }]);
})(), dm = /* @__PURE__ */ (function() {
  function t(e, r, a, n) {
    hr(this, t), this.r = e, this.texSize = r, this.texRows = a, this.createTextureCanvas = n, this.atlases = [], this.styleKeyToAtlas = /* @__PURE__ */ new Map(), this.markedKeys = /* @__PURE__ */ new Set();
  }
  return dr(t, [{
    key: "getKeys",
    value: function() {
      return new Set(this.styleKeyToAtlas.keys());
    }
  }, {
    key: "_createAtlas",
    value: function() {
      var r = this.r, a = this.texSize, n = this.texRows, i = this.createTextureCanvas;
      return new hm(r, a, n, i);
    }
  }, {
    key: "_getScratchCanvas",
    value: function() {
      if (!this.scratch) {
        var r = this.r, a = this.texSize, n = this.texRows, i = this.createTextureCanvas, o = Math.floor(a / n);
        this.scratch = i(r, a, o, "scratch");
      }
      return this.scratch;
    }
  }, {
    key: "draw",
    value: function(r, a, n) {
      var i = this.styleKeyToAtlas.get(r);
      return i || (i = this.atlases[this.atlases.length - 1], (!i || !i.canFit(a)) && (i && i.lock(), i = this._createAtlas(), this.atlases.push(i)), i.draw(r, a, n), this.styleKeyToAtlas.set(r, i)), i;
    }
  }, {
    key: "getAtlas",
    value: function(r) {
      return this.styleKeyToAtlas.get(r);
    }
  }, {
    key: "hasAtlas",
    value: function(r) {
      return this.styleKeyToAtlas.has(r);
    }
  }, {
    key: "markKeyForGC",
    value: function(r) {
      this.markedKeys.add(r);
    }
  }, {
    key: "gc",
    value: function() {
      var r = this, a = this.markedKeys;
      if (a.size === 0) {
        console.log("nothing to garbage collect");
        return;
      }
      var n = [], i = /* @__PURE__ */ new Map(), o = null, s = Tt(this.atlases), u;
      try {
        var l = function() {
          var v = u.value, c = v.getKeys(), h = gm(a, c);
          if (h.size === 0)
            return n.push(v), c.forEach(function(C) {
              return i.set(C, v);
            }), 1;
          o || (o = r._createAtlas(), n.push(o));
          var d = Tt(c), g;
          try {
            for (d.s(); !(g = d.n()).done; ) {
              var p = g.value;
              if (!h.has(p)) {
                var y = v.getOffsets(p), b = Qe(y, 2), m = b[0], E = b[1];
                o.canFit({
                  w: m.w + E.w,
                  h: m.h
                }) || (o.lock(), o = r._createAtlas(), n.push(o)), v.canvas && (r._copyTextureToNewAtlas(p, v, o), i.set(p, o));
              }
            }
          } catch (C) {
            d.e(C);
          } finally {
            d.f();
          }
          v.dispose();
        };
        for (s.s(); !(u = s.n()).done; )
          l();
      } catch (f) {
        s.e(f);
      } finally {
        s.f();
      }
      this.atlases = n, this.styleKeyToAtlas = i, this.markedKeys = /* @__PURE__ */ new Set();
    }
  }, {
    key: "_copyTextureToNewAtlas",
    value: function(r, a, n) {
      var i = a.getOffsets(r), o = Qe(i, 2), s = o[0], u = o[1];
      if (u.w === 0)
        n.draw(r, s, function(c) {
          c.drawImage(a.canvas, s.x, s.y, s.w, s.h, 0, 0, s.w, s.h);
        });
      else {
        var l = this._getScratchCanvas();
        l.clear(), l.context.drawImage(a.canvas, s.x, s.y, s.w, s.h, 0, 0, s.w, s.h), l.context.drawImage(a.canvas, u.x, u.y, u.w, u.h, s.w, 0, u.w, u.h);
        var f = s.w + u.w, v = s.h;
        n.draw(r, {
          w: f,
          h: v
        }, function(c) {
          c.drawImage(
            l,
            0,
            0,
            f,
            v,
            0,
            0,
            f,
            v
            // the destination context has already been translated to the correct position
          );
        });
      }
    }
  }, {
    key: "getCounts",
    value: function() {
      return {
        keyCount: this.styleKeyToAtlas.size,
        atlasCount: new Set(this.styleKeyToAtlas.values()).size
      };
    }
  }]);
})();
function gm(t, e) {
  return t.intersection ? t.intersection(e) : new Set(En(t).filter(function(r) {
    return e.has(r);
  }));
}
var pm = /* @__PURE__ */ (function() {
  function t(e, r) {
    hr(this, t), this.r = e, this.globalOptions = r, this.atlasSize = r.webglTexSize, this.maxAtlasesPerBatch = r.webglTexPerBatch, this.renderTypes = /* @__PURE__ */ new Map(), this.collections = /* @__PURE__ */ new Map(), this.typeAndIdToKey = /* @__PURE__ */ new Map();
  }
  return dr(t, [{
    key: "getAtlasSize",
    value: function() {
      return this.atlasSize;
    }
  }, {
    key: "addAtlasCollection",
    value: function(r, a) {
      var n = this.globalOptions, i = n.webglTexSize, o = n.createTextureCanvas, s = a.texRows, u = this._cacheScratchCanvas(o), l = new dm(this.r, i, s, u);
      this.collections.set(r, l);
    }
  }, {
    key: "addRenderType",
    value: function(r, a) {
      var n = a.collection;
      if (!this.collections.has(n)) throw new Error("invalid atlas collection name '".concat(n, "'"));
      var i = this.collections.get(n), o = ye({
        type: r,
        atlasCollection: i
      }, a);
      this.renderTypes.set(r, o);
    }
  }, {
    key: "getRenderTypeOpts",
    value: function(r) {
      return this.renderTypes.get(r);
    }
  }, {
    key: "getAtlasCollection",
    value: function(r) {
      return this.collections.get(r);
    }
  }, {
    key: "_cacheScratchCanvas",
    value: function(r) {
      var a = -1, n = -1, i = null;
      return function(o, s, u, l) {
        return l ? ((!i || s != a || u != n) && (a = s, n = u, i = r(o, s, u)), i) : r(o, s, u);
      };
    }
  }, {
    key: "_key",
    value: function(r, a) {
      return "".concat(r, "-").concat(a);
    }
    /** Marks textues associated with the element for garbage collection. */
  }, {
    key: "invalidate",
    value: function(r) {
      var a = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = n.forceRedraw, o = i === void 0 ? !1 : i, s = n.filterEle, u = s === void 0 ? function() {
        return !0;
      } : s, l = n.filterType, f = l === void 0 ? function() {
        return !0;
      } : l, v = !1, c = !1, h = Tt(r), d;
      try {
        for (h.s(); !(d = h.n()).done; ) {
          var g = d.value;
          if (u(g)) {
            var p = Tt(this.renderTypes.values()), y;
            try {
              var b = function() {
                var E = y.value, C = E.type;
                if (f(C)) {
                  var S = a.collections.get(E.collection), w = E.getKey(g), x = Array.isArray(w) ? w : [w];
                  if (o)
                    x.forEach(function(L) {
                      return S.markKeyForGC(L);
                    }), c = !0;
                  else {
                    var T = E.getID ? E.getID(g) : g.id(), D = a._key(C, T), A = a.typeAndIdToKey.get(D);
                    A !== void 0 && !nm(x, A) && (v = !0, a.typeAndIdToKey.delete(D), A.forEach(function(L) {
                      return S.markKeyForGC(L);
                    }));
                  }
                }
              };
              for (p.s(); !(y = p.n()).done; )
                b();
            } catch (m) {
              p.e(m);
            } finally {
              p.f();
            }
          }
        }
      } catch (m) {
        h.e(m);
      } finally {
        h.f();
      }
      return c && (this.gc(), v = !1), v;
    }
    /** Garbage collect */
  }, {
    key: "gc",
    value: function() {
      var r = Tt(this.collections.values()), a;
      try {
        for (r.s(); !(a = r.n()).done; ) {
          var n = a.value;
          n.gc();
        }
      } catch (i) {
        r.e(i);
      } finally {
        r.f();
      }
    }
  }, {
    key: "getOrCreateAtlas",
    value: function(r, a, n, i) {
      var o = this.renderTypes.get(a), s = this.collections.get(o.collection), u = !1, l = s.draw(i, n, function(c) {
        o.drawClipped ? (c.save(), c.beginPath(), c.rect(0, 0, n.w, n.h), c.clip(), o.drawElement(c, r, n, !0, !0), c.restore()) : o.drawElement(c, r, n, !0, !0), u = !0;
      });
      if (u) {
        var f = o.getID ? o.getID(r) : r.id(), v = this._key(a, f);
        this.typeAndIdToKey.has(v) ? this.typeAndIdToKey.get(v).push(i) : this.typeAndIdToKey.set(v, [i]);
      }
      return l;
    }
  }, {
    key: "getAtlasInfo",
    value: function(r, a) {
      var n = this, i = this.renderTypes.get(a), o = i.getKey(r), s = Array.isArray(o) ? o : [o];
      return s.map(function(u) {
        var l = i.getBoundingBox(r, u), f = n.getOrCreateAtlas(r, a, l, u), v = f.getOffsets(u), c = Qe(v, 2), h = c[0], d = c[1];
        return {
          atlas: f,
          tex: h,
          tex1: h,
          tex2: d,
          bb: l
        };
      });
    }
  }, {
    key: "getDebugInfo",
    value: function() {
      var r = [], a = Tt(this.collections), n;
      try {
        for (a.s(); !(n = a.n()).done; ) {
          var i = Qe(n.value, 2), o = i[0], s = i[1], u = s.getCounts(), l = u.keyCount, f = u.atlasCount;
          r.push({
            type: o,
            keyCount: l,
            atlasCount: f
          });
        }
      } catch (v) {
        a.e(v);
      } finally {
        a.f();
      }
      return r;
    }
  }]);
})(), ym = /* @__PURE__ */ (function() {
  function t(e) {
    hr(this, t), this.globalOptions = e, this.atlasSize = e.webglTexSize, this.maxAtlasesPerBatch = e.webglTexPerBatch, this.batchAtlases = [];
  }
  return dr(t, [{
    key: "getMaxAtlasesPerBatch",
    value: function() {
      return this.maxAtlasesPerBatch;
    }
  }, {
    key: "getAtlasSize",
    value: function() {
      return this.atlasSize;
    }
  }, {
    key: "getIndexArray",
    value: function() {
      return Array.from({
        length: this.maxAtlasesPerBatch
      }, function(r, a) {
        return a;
      });
    }
  }, {
    key: "startBatch",
    value: function() {
      this.batchAtlases = [];
    }
  }, {
    key: "getAtlasCount",
    value: function() {
      return this.batchAtlases.length;
    }
  }, {
    key: "getAtlases",
    value: function() {
      return this.batchAtlases;
    }
  }, {
    key: "canAddToCurrentBatch",
    value: function(r) {
      return this.batchAtlases.length === this.maxAtlasesPerBatch ? this.batchAtlases.includes(r) : !0;
    }
  }, {
    key: "getAtlasIndexForBatch",
    value: function(r) {
      var a = this.batchAtlases.indexOf(r);
      if (a < 0) {
        if (this.batchAtlases.length === this.maxAtlasesPerBatch)
          throw new Error("cannot add more atlases to batch");
        this.batchAtlases.push(r), a = this.batchAtlases.length - 1;
      }
      return a;
    }
  }]);
})(), mm = `
  float circleSD(vec2 p, float r) {
    return distance(vec2(0), p) - r; // signed distance
  }
`, bm = `
  float rectangleSD(vec2 p, vec2 b) {
    vec2 d = abs(p)-b;
    return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);
  }
`, wm = `
  float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {
    cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;
    cr.x  = (p.y > 0.0) ? cr.x  : cr.y;
    vec2 q = abs(p) - b + cr.x;
    return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;
  }
`, Em = `
  float ellipseSD(vec2 p, vec2 ab) {
    p = abs( p ); // symmetry

    // find root with Newton solver
    vec2 q = ab*(p-ab);
    float w = (q.x<q.y)? 1.570796327 : 0.0;
    for( int i=0; i<5; i++ ) {
      vec2 cs = vec2(cos(w),sin(w));
      vec2 u = ab*vec2( cs.x,cs.y);
      vec2 v = ab*vec2(-cs.y,cs.x);
      w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));
    }
    
    // compute final point and distance
    float d = length(p-ab*vec2(cos(w),sin(w)));
    
    // return signed distance
    return (dot(p/ab,p/ab)>1.0) ? d : -d;
  }
`, xa = {
  SCREEN: {
    name: "screen",
    screen: !0
  },
  PICKING: {
    name: "picking",
    picking: !0
  }
}, On = {
  // render the texture just like in RENDER_TARGET.SCREEN mode
  IGNORE: 1,
  // don't render the texture at all
  USE_BB: 2
  // render the bounding box as an opaque rectangle
}, Ao = 0, Zl = 1, Ql = 2, Lo = 3, zr = 4, on = 5, ga = 6, pa = 7, xm = /* @__PURE__ */ (function() {
  function t(e, r, a) {
    hr(this, t), this.r = e, this.gl = r, this.maxInstances = a.webglBatchSize, this.atlasSize = a.webglTexSize, this.bgColor = a.bgColor, this.debug = a.webglDebug, this.batchDebugInfo = [], a.enableWrapping = !0, a.createTextureCanvas = em, this.atlasManager = new pm(e, a), this.batchManager = new ym(a), this.simpleShapeOptions = /* @__PURE__ */ new Map(), this.program = this._createShaderProgram(xa.SCREEN), this.pickingProgram = this._createShaderProgram(xa.PICKING), this.vao = this._createVAO();
  }
  return dr(t, [{
    key: "addAtlasCollection",
    value: function(r, a) {
      this.atlasManager.addAtlasCollection(r, a);
    }
    /**
     * @typedef { Object } TextureRenderTypeOpts
     * @property { string } collection - name of atlas collection to render textures to
     * @property { function } getKey - returns the "style key" for an element, may be a single value or an array for multi-line lables
     * @property { function } drawElement - uses a canvas renderer to draw the element to the texture atlas
     * @property { boolean  } drawClipped - if true the context will be clipped to the bounding box before drawElement() is called, may affect performance
     * @property { function } getBoundingBox - returns the bounding box for an element
     * @property { function } getRotation
     * @property { function } getRotationPoint
     * @property { function } getRotationOffset
     * @property { function } isVisible - an extra check for visibility in addition to ele.visible()
     * @property { function } getTexPickingMode - returns a value from the TEX_PICKING_MODE enum
     */
    /**
     * @param { string } typeName
     * @param { TextureRenderTypeOpts } opts
     */
  }, {
    key: "addTextureAtlasRenderType",
    value: function(r, a) {
      this.atlasManager.addRenderType(r, a);
    }
    /**
     * @typedef { Object } SimpleShapeRenderTypeOpts
     * @property { function } getBoundingBox - returns the bounding box for an element
     * @property { function } isVisible - this is an extra check for visibility in addition to ele.visible()
     * @property { function } isSimple - check if element is a simple shape, or if it needs to fall back to texture rendering
     * @property { ShapeVisualProperties } shapeProps
     */
    /**
     * @typedef { Object } ShapeVisualProperties
     * @property { string } shape
     * @property { string } color
     * @property { string } opacity
     * @property { string } padding
     * @property { string } radius
     * @property { boolean } border
    */
    /**
     * @param { string } typeName
     * @param { SimpleShapeRenderTypeOpts } opts
     */
  }, {
    key: "addSimpleShapeRenderType",
    value: function(r, a) {
      this.simpleShapeOptions.set(r, a);
    }
    /**
     * Inform the atlasManager when element style keys may have changed.
     * The atlasManager can then mark unused textures for "garbage collection".
     */
  }, {
    key: "invalidate",
    value: function(r) {
      var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = a.type, i = this.atlasManager;
      return n ? i.invalidate(r, {
        filterType: function(s) {
          return s === n;
        },
        forceRedraw: !0
      }) : i.invalidate(r);
    }
    /**
     * Run texture garbage collection.
     */
  }, {
    key: "gc",
    value: function() {
      this.atlasManager.gc();
    }
  }, {
    key: "_createShaderProgram",
    value: function(r) {
      var a = this.gl, n = `#version 300 es
      precision highp float;

      uniform mat3 uPanZoomMatrix;
      uniform int  uAtlasSize;
      
      // instanced
      in vec2 aPosition; // a vertex from the unit square
      
      in mat3 aTransform; // used to transform verticies, eg into a bounding box
      in int aVertType; // the type of thing we are rendering

      // the z-index that is output when using picking mode
      in vec4 aIndex;
      
      // For textures
      in int aAtlasId; // which shader unit/atlas to use
      in vec4 aTex; // x/y/w/h of texture in atlas

      // for edges
      in vec4 aPointAPointB;
      in vec4 aPointCPointD;
      in vec2 aLineWidth; // also used for node border width

      // simple shapes
      in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]
      in vec4 aColor; // also used for edges
      in vec4 aBorderColor; // aLineWidth is used for border width

      // output values passed to the fragment shader
      out vec2 vTexCoord;
      out vec4 vColor;
      out vec2 vPosition;
      // flat values are not interpolated
      flat out int vAtlasId; 
      flat out int vVertType;
      flat out vec2 vTopRight;
      flat out vec2 vBotLeft;
      flat out vec4 vCornerRadius;
      flat out vec4 vBorderColor;
      flat out vec2 vBorderWidth;
      flat out vec4 vIndex;
      
      void main(void) {
        int vid = gl_VertexID;
        vec2 position = aPosition; // TODO make this a vec3, simplifies some code below

        if(aVertType == `.concat(Ao, `) {
          float texX = aTex.x; // texture coordinates
          float texY = aTex.y;
          float texW = aTex.z;
          float texH = aTex.w;

          if(vid == 1 || vid == 2 || vid == 4) {
            texX += texW;
          }
          if(vid == 2 || vid == 4 || vid == 5) {
            texY += texH;
          }

          float d = float(uAtlasSize);
          vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1

          gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
        }
        else if(aVertType == `).concat(zr, " || aVertType == ").concat(pa, ` 
             || aVertType == `).concat(on, " || aVertType == ").concat(ga, `) { // simple shapes

          // the bounding box is needed by the fragment shader
          vBotLeft  = (aTransform * vec3(0, 0, 1)).xy; // flat
          vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat
          vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated

          // calculations are done in the fragment shader, just pass these along
          vColor = aColor;
          vCornerRadius = aCornerRadius;
          vBorderColor = aBorderColor;
          vBorderWidth = aLineWidth;

          gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
        }
        else if(aVertType == `).concat(Zl, `) {
          vec2 source = aPointAPointB.xy;
          vec2 target = aPointAPointB.zw;

          // adjust the geometry so that the line is centered on the edge
          position.y = position.y - 0.5;

          // stretch the unit square into a long skinny rectangle
          vec2 xBasis = target - source;
          vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
          vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;

          gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
          vColor = aColor;
        } 
        else if(aVertType == `).concat(Ql, `) {
          vec2 pointA = aPointAPointB.xy;
          vec2 pointB = aPointAPointB.zw;
          vec2 pointC = aPointCPointD.xy;
          vec2 pointD = aPointCPointD.zw;

          // adjust the geometry so that the line is centered on the edge
          position.y = position.y - 0.5;

          vec2 p0, p1, p2, pos;
          if(position.x == 0.0) { // The left side of the unit square
            p0 = pointA;
            p1 = pointB;
            p2 = pointC;
            pos = position;
          } else { // The right side of the unit square, use same approach but flip the geometry upside down
            p0 = pointD;
            p1 = pointC;
            p2 = pointB;
            pos = vec2(0.0, -position.y);
          }

          vec2 p01 = p1 - p0;
          vec2 p12 = p2 - p1;
          vec2 p21 = p1 - p2;

          // Find the normal vector.
          vec2 tangent = normalize(normalize(p12) + normalize(p01));
          vec2 normal = vec2(-tangent.y, tangent.x);

          // Find the vector perpendicular to p0 -> p1.
          vec2 p01Norm = normalize(vec2(-p01.y, p01.x));

          // Determine the bend direction.
          float sigma = sign(dot(p01 + p21, normal));
          float width = aLineWidth[0];

          if(sign(pos.y) == -sigma) {
            // This is an intersecting vertex. Adjust the position so that there's no overlap.
            vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
            gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
          } else {
            // This is a non-intersecting vertex. Treat it like a mitre join.
            vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
            gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
          }

          vColor = aColor;
        } 
        else if(aVertType == `).concat(Lo, ` && vid < 3) {
          // massage the first triangle into an edge arrow
          if(vid == 0)
            position = vec2(-0.15, -0.3);
          if(vid == 1)
            position = vec2(  0.0,  0.0);
          if(vid == 2)
            position = vec2( 0.15, -0.3);

          gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
          vColor = aColor;
        }
        else {
          gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
        }

        vAtlasId = aAtlasId;
        vVertType = aVertType;
        vIndex = aIndex;
      }
    `), i = this.batchManager.getIndexArray(), o = `#version 300 es
      precision highp float;

      // declare texture unit for each texture atlas in the batch
      `.concat(i.map(function(l) {
        return "uniform sampler2D uTexture".concat(l, ";");
      }).join(`
	`), `

      uniform vec4 uBGColor;
      uniform float uZoom;

      in vec2 vTexCoord;
      in vec4 vColor;
      in vec2 vPosition; // model coordinates

      flat in int vAtlasId;
      flat in vec4 vIndex;
      flat in int vVertType;
      flat in vec2 vTopRight;
      flat in vec2 vBotLeft;
      flat in vec4 vCornerRadius;
      flat in vec4 vBorderColor;
      flat in vec2 vBorderWidth;

      out vec4 outColor;

      `).concat(mm, `
      `).concat(bm, `
      `).concat(wm, `
      `).concat(Em, `

      vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha
        return vec4( 
          top.rgb + (bot.rgb * (1.0 - top.a)),
          top.a   + (bot.a   * (1.0 - top.a)) 
        );
      }

      vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance
        // scale to the zoom level so that borders don't look blurry when zoomed in
        // note 1.5 is an aribitrary value chosen because it looks good
        return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d))); 
      }

      void main(void) {
        if(vVertType == `).concat(Ao, `) {
          // look up the texel from the texture unit
          `).concat(i.map(function(l) {
        return "if(vAtlasId == ".concat(l, ") outColor = texture(uTexture").concat(l, ", vTexCoord);");
      }).join(`
	else `), `
        } 
        else if(vVertType == `).concat(Lo, `) {
          // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';
          outColor = blend(vColor, uBGColor);
          outColor.a = 1.0; // make opaque, masks out line under arrow
        }
        else if(vVertType == `).concat(zr, ` && vBorderWidth == vec2(0.0)) { // simple rectangle with no border
          outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done
        }
        else if(vVertType == `).concat(zr, " || vVertType == ").concat(pa, ` 
          || vVertType == `).concat(on, " || vVertType == ").concat(ga, `) { // use SDF

          float outerBorder = vBorderWidth[0];
          float innerBorder = vBorderWidth[1];
          float borderPadding = outerBorder * 2.0;
          float w = vTopRight.x - vBotLeft.x - borderPadding;
          float h = vTopRight.y - vBotLeft.y - borderPadding;
          vec2 b = vec2(w/2.0, h/2.0); // half width, half height
          vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center

          float d; // signed distance
          if(vVertType == `).concat(zr, `) {
            d = rectangleSD(p, b);
          } else if(vVertType == `).concat(pa, ` && w == h) {
            d = circleSD(p, b.x); // faster than ellipse
          } else if(vVertType == `).concat(pa, `) {
            d = ellipseSD(p, b);
          } else {
            d = roundRectangleSD(p, b, vCornerRadius.wzyx);
          }

          // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling
          // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box
          if(d > 0.0) {
            if(d > outerBorder) {
              discard;
            } else {
              outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);
            }
          } else {
            if(d > innerBorder) {
              vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;
              vec4 innerBorderColor = blend(vBorderColor, vColor);
              outColor = distInterp(innerBorderColor, outerColor, d);
            } 
            else {
              vec4 outerColor;
              if(innerBorder == 0.0 && outerBorder == 0.0) {
                outerColor = vec4(0);
              } else if(innerBorder == 0.0) {
                outerColor = vBorderColor;
              } else {
                outerColor = blend(vBorderColor, vColor);
              }
              outColor = distInterp(vColor, outerColor, d - innerBorder);
            }
          }
        }
        else {
          outColor = vColor;
        }

        `).concat(r.picking ? `if(outColor.a == 0.0) discard;
             else outColor = vIndex;` : "", `
      }
    `), s = jy(a, n, o);
      s.aPosition = a.getAttribLocation(s, "aPosition"), s.aIndex = a.getAttribLocation(s, "aIndex"), s.aVertType = a.getAttribLocation(s, "aVertType"), s.aTransform = a.getAttribLocation(s, "aTransform"), s.aAtlasId = a.getAttribLocation(s, "aAtlasId"), s.aTex = a.getAttribLocation(s, "aTex"), s.aPointAPointB = a.getAttribLocation(s, "aPointAPointB"), s.aPointCPointD = a.getAttribLocation(s, "aPointCPointD"), s.aLineWidth = a.getAttribLocation(s, "aLineWidth"), s.aColor = a.getAttribLocation(s, "aColor"), s.aCornerRadius = a.getAttribLocation(s, "aCornerRadius"), s.aBorderColor = a.getAttribLocation(s, "aBorderColor"), s.uPanZoomMatrix = a.getUniformLocation(s, "uPanZoomMatrix"), s.uAtlasSize = a.getUniformLocation(s, "uAtlasSize"), s.uBGColor = a.getUniformLocation(s, "uBGColor"), s.uZoom = a.getUniformLocation(s, "uZoom"), s.uTextures = [];
      for (var u = 0; u < this.batchManager.getMaxAtlasesPerBatch(); u++)
        s.uTextures.push(a.getUniformLocation(s, "uTexture".concat(u)));
      return s;
    }
  }, {
    key: "_createVAO",
    value: function() {
      var r = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1];
      this.vertexCount = r.length / 2;
      var a = this.maxInstances, n = this.gl, i = this.program, o = n.createVertexArray();
      return n.bindVertexArray(o), um(n, "vec2", i.aPosition, r), this.transformBuffer = lm(n, a, i.aTransform), this.indexBuffer = Gt(n, a, "vec4", i.aIndex), this.vertTypeBuffer = Gt(n, a, "int", i.aVertType), this.atlasIdBuffer = Gt(n, a, "int", i.aAtlasId), this.texBuffer = Gt(n, a, "vec4", i.aTex), this.pointAPointBBuffer = Gt(n, a, "vec4", i.aPointAPointB), this.pointCPointDBuffer = Gt(n, a, "vec4", i.aPointCPointD), this.lineWidthBuffer = Gt(n, a, "vec2", i.aLineWidth), this.colorBuffer = Gt(n, a, "vec4", i.aColor), this.cornerRadiusBuffer = Gt(n, a, "vec4", i.aCornerRadius), this.borderColorBuffer = Gt(n, a, "vec4", i.aBorderColor), n.bindVertexArray(null), o;
    }
  }, {
    key: "buffers",
    get: function() {
      var r = this;
      return this._buffers || (this._buffers = Object.keys(this).filter(function(a) {
        return rr(a, "Buffer");
      }).map(function(a) {
        return r[a];
      })), this._buffers;
    }
  }, {
    key: "startFrame",
    value: function(r) {
      var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : xa.SCREEN;
      this.panZoomMatrix = r, this.renderTarget = a, this.batchDebugInfo = [], this.wrappedCount = 0, this.simpleCount = 0, this.startBatch();
    }
  }, {
    key: "startBatch",
    value: function() {
      this.instanceCount = 0, this.batchManager.startBatch();
    }
  }, {
    key: "endFrame",
    value: function() {
      this.endBatch();
    }
  }, {
    key: "_isVisible",
    value: function(r, a) {
      return r.visible() ? a && a.isVisible ? a.isVisible(r) : !0 : !1;
    }
    /**
     * Draws a texture using the texture atlas.
     */
  }, {
    key: "drawTexture",
    value: function(r, a, n) {
      var i = this.atlasManager, o = this.batchManager, s = i.getRenderTypeOpts(n);
      if (this._isVisible(r, s) && !(r.isEdge() && !this._isValidEdge(r))) {
        if (this.renderTarget.picking && s.getTexPickingMode) {
          var u = s.getTexPickingMode(r);
          if (u === On.IGNORE)
            return;
          if (u == On.USE_BB) {
            this.drawPickingRectangle(r, a, n);
            return;
          }
        }
        var l = i.getAtlasInfo(r, n), f = Tt(l), v;
        try {
          for (f.s(); !(v = f.n()).done; ) {
            var c = v.value, h = c.atlas, d = c.tex1, g = c.tex2;
            o.canAddToCurrentBatch(h) || this.endBatch();
            for (var p = o.getAtlasIndexForBatch(h), y = 0, b = [[d, !0], [g, !1]]; y < b.length; y++) {
              var m = Qe(b[y], 2), E = m[0], C = m[1];
              if (E.w != 0) {
                var S = this.instanceCount;
                this.vertTypeBuffer.getView(S)[0] = Ao;
                var w = this.indexBuffer.getView(S);
                Gr(a, w);
                var x = this.atlasIdBuffer.getView(S);
                x[0] = p;
                var T = this.texBuffer.getView(S);
                T[0] = E.x, T[1] = E.y, T[2] = E.w, T[3] = E.h;
                var D = this.transformBuffer.getMatrixView(S);
                this.setTransformMatrix(r, D, s, c, C), this.instanceCount++, C || this.wrappedCount++, this.instanceCount >= this.maxInstances && this.endBatch();
              }
            }
          }
        } catch (A) {
          f.e(A);
        } finally {
          f.f();
        }
      }
    }
    /**
     * matrix is expected to be a 9 element array
     * this function follows same pattern as CRp.drawCachedElementPortion(...)
     */
  }, {
    key: "setTransformMatrix",
    value: function(r, a, n, i) {
      var o = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, s = 0;
      if (n.shapeProps && n.shapeProps.padding && (s = r.pstyle(n.shapeProps.padding).pfValue), i) {
        var u = i.bb, l = i.tex1, f = i.tex2, v = l.w / (l.w + f.w);
        o || (v = 1 - v);
        var c = this._getAdjustedBB(u, s, o, v);
        this._applyTransformMatrix(a, c, n, r);
      } else {
        var h = n.getBoundingBox(r), d = this._getAdjustedBB(h, s, !0, 1);
        this._applyTransformMatrix(a, d, n, r);
      }
    }
  }, {
    key: "_applyTransformMatrix",
    value: function(r, a, n, i) {
      var o, s;
      $l(r);
      var u = n.getRotation ? n.getRotation(i) : 0;
      if (u !== 0) {
        var l = n.getRotationPoint(i), f = l.x, v = l.y;
        yn(r, r, [f, v]), Kl(r, r, u);
        var c = n.getRotationOffset(i);
        o = c.x + (a.xOffset || 0), s = c.y + (a.yOffset || 0);
      } else
        o = a.x1, s = a.y1;
      yn(r, r, [o, s]), $o(r, r, [a.w, a.h]);
    }
    /**
     * Adjusts a node or label BB to accomodate padding and split for wrapped textures.
     * @param bb - the original bounding box
     * @param padding - the padding to add to the bounding box
     * @param first - whether this is the first part of a wrapped texture
     * @param ratio - the ratio of the texture width of part of the text to the entire texture
     */
  }, {
    key: "_getAdjustedBB",
    value: function(r, a, n, i) {
      var o = r.x1, s = r.y1, u = r.w, l = r.h, f = r.yOffset;
      a && (o -= a, s -= a, u += 2 * a, l += 2 * a);
      var v = 0, c = u * i;
      return n && i < 1 ? u = c : !n && i < 1 && (v = u - c, o += v, u = c), {
        x1: o,
        y1: s,
        w: u,
        h: l,
        xOffset: v,
        yOffset: f
      };
    }
    /**
     * Draw a solid opaque rectangle matching the element's Bounding Box.
     * Used by the PICKING mode to make the entire BB of a label clickable.
     */
  }, {
    key: "drawPickingRectangle",
    value: function(r, a, n) {
      var i = this.atlasManager.getRenderTypeOpts(n), o = this.instanceCount;
      this.vertTypeBuffer.getView(o)[0] = zr;
      var s = this.indexBuffer.getView(o);
      Gr(a, s);
      var u = this.colorBuffer.getView(o);
      wr([0, 0, 0], 1, u);
      var l = this.transformBuffer.getMatrixView(o);
      this.setTransformMatrix(r, l, i), this.simpleCount++, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
    }
    /**
     * Draw a node using either a texture or a "simple shape".
     */
  }, {
    key: "drawNode",
    value: function(r, a, n) {
      var i = this.simpleShapeOptions.get(n);
      if (this._isVisible(r, i)) {
        var o = i.shapeProps, s = this._getVertTypeForShape(r, o.shape);
        if (s === void 0 || i.isSimple && !i.isSimple(r, this.renderTarget)) {
          this.drawTexture(r, a, n);
          return;
        }
        var u = this.instanceCount;
        if (this.vertTypeBuffer.getView(u)[0] = s, s === on || s === ga) {
          var l = i.getBoundingBox(r), f = this._getCornerRadius(r, o.radius, l), v = this.cornerRadiusBuffer.getView(u);
          v[0] = f, v[1] = f, v[2] = f, v[3] = f, s === ga && (v[0] = 0, v[2] = 0);
        }
        var c = this.indexBuffer.getView(u);
        Gr(a, c);
        var h = this.renderTarget.picking ? 1 : n === "node-body" ? r.effectiveOpacity() : 1, d = this.renderTarget.picking ? 1 : r.pstyle(o.opacity).value * h, g = r.pstyle(o.color).value, p = this.colorBuffer.getView(u);
        wr(g, d, p);
        var y = this.lineWidthBuffer.getView(u);
        if (y[0] = 0, y[1] = 0, o.border) {
          var b = r.pstyle("border-width").value;
          if (b > 0) {
            var m = r.pstyle("border-color").value, E = h * r.pstyle("border-opacity").value, C = this.borderColorBuffer.getView(u);
            wr(m, E, C);
            var S = r.pstyle("border-position").value;
            if (S === "inside")
              y[0] = 0, y[1] = -b;
            else if (S === "outside")
              y[0] = b, y[1] = 0;
            else {
              var w = b / 2;
              y[0] = w, y[1] = -w;
            }
          }
        }
        var x = this.transformBuffer.getMatrixView(u);
        this.setTransformMatrix(r, x, i), this.simpleCount++, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
      }
    }
  }, {
    key: "_getVertTypeForShape",
    value: function(r, a) {
      var n = r.pstyle(a).value;
      switch (n) {
        case "rectangle":
          return zr;
        case "ellipse":
          return pa;
        case "roundrectangle":
        case "round-rectangle":
          return on;
        case "bottom-round-rectangle":
          return ga;
        default:
          return;
      }
    }
  }, {
    key: "_getCornerRadius",
    value: function(r, a, n) {
      var i = n.w, o = n.h;
      if (r.pstyle(a).value === "auto")
        return lr(i, o);
      var s = r.pstyle(a).pfValue, u = i / 2, l = o / 2;
      return Math.min(s, l, u);
    }
    /**
     * Only supports drawing triangles at the moment.
     */
  }, {
    key: "drawEdgeArrow",
    value: function(r, a, n) {
      if (r.visible()) {
        var i = r._private.rscratch, o, s, u;
        if (n === "source" ? (o = i.arrowStartX, s = i.arrowStartY, u = i.srcArrowAngle) : (o = i.arrowEndX, s = i.arrowEndY, u = i.tgtArrowAngle), !(isNaN(o) || o == null || isNaN(s) || s == null || isNaN(u) || u == null)) {
          var l = r.pstyle(n + "-arrow-shape").value;
          if (l !== "none") {
            var f = r.pstyle(n + "-arrow-color").value, v = r.pstyle("opacity").value, c = r.pstyle("line-opacity").value, h = v * c, d = r.pstyle("width").pfValue, g = r.pstyle("arrow-scale").value, p = this.r.getArrowWidth(d, g), y = this.instanceCount, b = this.transformBuffer.getMatrixView(y);
            $l(b), yn(b, b, [o, s]), $o(b, b, [p, p]), Kl(b, b, u), this.vertTypeBuffer.getView(y)[0] = Lo;
            var m = this.indexBuffer.getView(y);
            Gr(a, m);
            var E = this.colorBuffer.getView(y);
            wr(f, h, E), this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
          }
        }
      }
    }
    /**
     * Draw straight-line or bezier curve edges.
     */
  }, {
    key: "drawEdgeLine",
    value: function(r, a) {
      if (r.visible()) {
        var n = this._getEdgePoints(r);
        if (n) {
          var i = r.pstyle("opacity").value, o = r.pstyle("line-opacity").value, s = r.pstyle("width").pfValue, u = r.pstyle("line-color").value, l = i * o;
          if (n.length / 2 + this.instanceCount > this.maxInstances && this.endBatch(), n.length == 4) {
            var f = this.instanceCount;
            this.vertTypeBuffer.getView(f)[0] = Zl;
            var v = this.indexBuffer.getView(f);
            Gr(a, v);
            var c = this.colorBuffer.getView(f);
            wr(u, l, c);
            var h = this.lineWidthBuffer.getView(f);
            h[0] = s;
            var d = this.pointAPointBBuffer.getView(f);
            d[0] = n[0], d[1] = n[1], d[2] = n[2], d[3] = n[3], this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
          } else
            for (var g = 0; g < n.length - 2; g += 2) {
              var p = this.instanceCount;
              this.vertTypeBuffer.getView(p)[0] = Ql;
              var y = this.indexBuffer.getView(p);
              Gr(a, y);
              var b = this.colorBuffer.getView(p);
              wr(u, l, b);
              var m = this.lineWidthBuffer.getView(p);
              m[0] = s;
              var E = n[g - 2], C = n[g - 1], S = n[g], w = n[g + 1], x = n[g + 2], T = n[g + 3], D = n[g + 4], A = n[g + 5];
              g == 0 && (E = 2 * S - x + 1e-3, C = 2 * w - T + 1e-3), g == n.length - 4 && (D = 2 * x - S + 1e-3, A = 2 * T - w + 1e-3);
              var L = this.pointAPointBBuffer.getView(p);
              L[0] = E, L[1] = C, L[2] = S, L[3] = w;
              var R = this.pointCPointDBuffer.getView(p);
              R[0] = x, R[1] = T, R[2] = D, R[3] = A, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
            }
        }
      }
    }
  }, {
    key: "_isValidEdge",
    value: function(r) {
      var a = r._private.rscratch;
      return !(a.badLine || a.allpts == null || isNaN(a.allpts[0]));
    }
  }, {
    key: "_getEdgePoints",
    value: function(r) {
      var a = r._private.rscratch;
      if (this._isValidEdge(r)) {
        var n = a.allpts;
        if (n.length == 4)
          return n;
        var i = this._getNumSegments(r);
        return this._getCurveSegmentPoints(n, i);
      }
    }
  }, {
    key: "_getNumSegments",
    value: function(r) {
      var a = 15;
      return Math.min(Math.max(a, 5), this.maxInstances);
    }
  }, {
    key: "_getCurveSegmentPoints",
    value: function(r, a) {
      if (r.length == 4)
        return r;
      for (var n = Array((a + 1) * 2), i = 0; i <= a; i++)
        if (i == 0)
          n[0] = r[0], n[1] = r[1];
        else if (i == a)
          n[i * 2] = r[r.length - 2], n[i * 2 + 1] = r[r.length - 1];
        else {
          var o = i / a;
          this._setCurvePoint(r, o, n, i * 2);
        }
      return n;
    }
  }, {
    key: "_setCurvePoint",
    value: function(r, a, n, i) {
      if (r.length <= 2)
        n[i] = r[0], n[i + 1] = r[1];
      else {
        for (var o = Array(r.length - 2), s = 0; s < o.length; s += 2) {
          var u = (1 - a) * r[s] + a * r[s + 2], l = (1 - a) * r[s + 1] + a * r[s + 3];
          o[s] = u, o[s + 1] = l;
        }
        return this._setCurvePoint(o, a, n, i);
      }
    }
  }, {
    key: "endBatch",
    value: function() {
      var r = this.gl, a = this.vao, n = this.vertexCount, i = this.instanceCount;
      if (i !== 0) {
        var o = this.renderTarget.picking ? this.pickingProgram : this.program;
        r.useProgram(o), r.bindVertexArray(a);
        var s = Tt(this.buffers), u;
        try {
          for (s.s(); !(u = s.n()).done; ) {
            var l = u.value;
            l.bufferSubData(i);
          }
        } catch (d) {
          s.e(d);
        } finally {
          s.f();
        }
        for (var f = this.batchManager.getAtlases(), v = 0; v < f.length; v++)
          f[v].bufferIfNeeded(r);
        for (var c = 0; c < f.length; c++)
          r.activeTexture(r.TEXTURE0 + c), r.bindTexture(r.TEXTURE_2D, f[c].texture), r.uniform1i(o.uTextures[c], c);
        r.uniform1f(o.uZoom, tm(this.r)), r.uniformMatrix3fv(o.uPanZoomMatrix, !1, this.panZoomMatrix), r.uniform1i(o.uAtlasSize, this.batchManager.getAtlasSize());
        var h = wr(this.bgColor, 1);
        r.uniform4fv(o.uBGColor, h), r.drawArraysInstanced(r.TRIANGLES, 0, n, i), r.bindVertexArray(null), r.bindTexture(r.TEXTURE_2D, null), this.debug && this.batchDebugInfo.push({
          count: i,
          // instance count
          atlasCount: f.length
        }), this.startBatch();
      }
    }
  }, {
    key: "getDebugInfo",
    value: function() {
      var r = this.atlasManager.getDebugInfo(), a = r.reduce(function(o, s) {
        return o + s.atlasCount;
      }, 0), n = this.batchDebugInfo, i = n.reduce(function(o, s) {
        return o + s.count;
      }, 0);
      return {
        atlasInfo: r,
        totalAtlases: a,
        wrappedCount: this.wrappedCount,
        simpleCount: this.simpleCount,
        batchCount: n.length,
        batchInfo: n,
        totalInstances: i
      };
    }
  }]);
})(), zv = {};
zv.initWebgl = function(t, e) {
  var r = this, a = r.data.contexts[r.WEBGL];
  t.bgColor = Tm(r), t.webglTexSize = Math.min(t.webglTexSize, a.getParameter(a.MAX_TEXTURE_SIZE)), t.webglTexRows = Math.min(t.webglTexRows, 54), t.webglTexRowsNodes = Math.min(t.webglTexRowsNodes, 54), t.webglBatchSize = Math.min(t.webglBatchSize, 16384), t.webglTexPerBatch = Math.min(t.webglTexPerBatch, a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)), r.webglDebug = t.webglDebug, r.webglDebugShowAtlases = t.webglDebugShowAtlases, r.pickingFrameBuffer = fm(a), r.pickingFrameBuffer.needsDraw = !0, r.drawing = new xm(r, a, t);
  var n = function(v) {
    return function(c) {
      return r.getTextAngle(c, v);
    };
  }, i = function(v) {
    return function(c) {
      var h = c.pstyle(v);
      return h && h.value;
    };
  }, o = function(v) {
    return function(c) {
      return c.pstyle("".concat(v, "-opacity")).value > 0;
    };
  }, s = function(v) {
    var c = v.pstyle("text-events").strValue === "yes";
    return c ? On.USE_BB : On.IGNORE;
  }, u = function(v) {
    var c = v.position(), h = c.x, d = c.y, g = v.outerWidth(), p = v.outerHeight();
    return {
      w: g,
      h: p,
      x1: h - g / 2,
      y1: d - p / 2
    };
  };
  r.drawing.addAtlasCollection("node", {
    texRows: t.webglTexRowsNodes
  }), r.drawing.addAtlasCollection("label", {
    texRows: t.webglTexRows
  }), r.drawing.addTextureAtlasRenderType("node-body", {
    collection: "node",
    getKey: e.getStyleKey,
    getBoundingBox: e.getElementBox,
    drawElement: e.drawElement
  }), r.drawing.addSimpleShapeRenderType("node-body", {
    getBoundingBox: u,
    isSimple: am,
    shapeProps: {
      shape: "shape",
      color: "background-color",
      opacity: "background-opacity",
      radius: "corner-radius",
      border: !0
    }
  }), r.drawing.addSimpleShapeRenderType("node-overlay", {
    getBoundingBox: u,
    isVisible: o("overlay"),
    shapeProps: {
      shape: "overlay-shape",
      color: "overlay-color",
      opacity: "overlay-opacity",
      padding: "overlay-padding",
      radius: "overlay-corner-radius"
    }
  }), r.drawing.addSimpleShapeRenderType("node-underlay", {
    getBoundingBox: u,
    isVisible: o("underlay"),
    shapeProps: {
      shape: "underlay-shape",
      color: "underlay-color",
      opacity: "underlay-opacity",
      padding: "underlay-padding",
      radius: "underlay-corner-radius"
    }
  }), r.drawing.addTextureAtlasRenderType("label", {
    // node label or edge mid label
    collection: "label",
    getTexPickingMode: s,
    getKey: Ro(e.getLabelKey, null),
    getBoundingBox: Mo(e.getLabelBox, null),
    drawClipped: !0,
    drawElement: e.drawLabel,
    getRotation: n(null),
    getRotationPoint: e.getLabelRotationPoint,
    getRotationOffset: e.getLabelRotationOffset,
    isVisible: i("label")
  }), r.drawing.addTextureAtlasRenderType("edge-source-label", {
    collection: "label",
    getTexPickingMode: s,
    getKey: Ro(e.getSourceLabelKey, "source"),
    getBoundingBox: Mo(e.getSourceLabelBox, "source"),
    drawClipped: !0,
    drawElement: e.drawSourceLabel,
    getRotation: n("source"),
    getRotationPoint: e.getSourceLabelRotationPoint,
    getRotationOffset: e.getSourceLabelRotationOffset,
    isVisible: i("source-label")
  }), r.drawing.addTextureAtlasRenderType("edge-target-label", {
    collection: "label",
    getTexPickingMode: s,
    getKey: Ro(e.getTargetLabelKey, "target"),
    getBoundingBox: Mo(e.getTargetLabelBox, "target"),
    drawClipped: !0,
    drawElement: e.drawTargetLabel,
    getRotation: n("target"),
    getRotationPoint: e.getTargetLabelRotationPoint,
    getRotationOffset: e.getTargetLabelRotationOffset,
    isVisible: i("target-label")
  });
  var l = Ga(function() {
    console.log("garbage collect flag set"), r.data.gc = !0;
  }, 1e4);
  r.onUpdateEleCalcs(function(f, v) {
    var c = !1;
    v && v.length > 0 && (c |= r.drawing.invalidate(v)), c && l();
  }), Cm(r);
};
function Tm(t) {
  var e = t.cy.container(), r = e && e.style && e.style.backgroundColor || "white";
  return cf(r);
}
function _v(t, e) {
  var r = t._private.rscratch;
  return yt(r, "labelWrapCachedLines", e) || [];
}
var Ro = function(e, r) {
  return function(a) {
    var n = e(a), i = _v(a, r);
    return i.length > 1 ? i.map(function(o, s) {
      return "".concat(n, "_").concat(s);
    }) : n;
  };
}, Mo = function(e, r) {
  return function(a, n) {
    var i = e(a);
    if (typeof n == "string") {
      var o = n.indexOf("_");
      if (o > 0) {
        var s = Number(n.substring(o + 1)), u = _v(a, r), l = i.h / u.length, f = l * s, v = i.y1 + f;
        return {
          x1: i.x1,
          w: i.w,
          y1: v,
          h: l,
          yOffset: f
        };
      }
    }
    return i;
  };
};
function Cm(t) {
  {
    var e = t.render;
    t.render = function(i) {
      i = i || {};
      var o = t.cy;
      t.webgl && (o.zoom() > Iv ? (Dm(t), e.call(t, i)) : (Sm(t), Uv(t, i, xa.SCREEN)));
    };
  }
  {
    var r = t.matchCanvasSize;
    t.matchCanvasSize = function(i) {
      r.call(t, i), t.pickingFrameBuffer.setFramebufferAttachmentSizes(t.canvasWidth, t.canvasHeight), t.pickingFrameBuffer.needsDraw = !0;
    };
  }
  t.findNearestElements = function(i, o, s, u) {
    return Im(t, i, o);
  };
  {
    var a = t.invalidateCachedZSortedEles;
    t.invalidateCachedZSortedEles = function() {
      a.call(t), t.pickingFrameBuffer.needsDraw = !0;
    };
  }
  {
    var n = t.notify;
    t.notify = function(i, o) {
      n.call(t, i, o), i === "viewport" || i === "bounds" ? t.pickingFrameBuffer.needsDraw = !0 : i === "background" && t.drawing.invalidate(o, {
        type: "node-body"
      });
    };
  }
}
function Dm(t) {
  var e = t.data.contexts[t.WEBGL];
  e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT);
}
function Sm(t) {
  var e = function(a) {
    a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, t.canvasWidth, t.canvasHeight), a.restore();
  };
  e(t.data.contexts[t.NODE]), e(t.data.contexts[t.DRAG]);
}
function Am(t) {
  var e = t.canvasWidth, r = t.canvasHeight, a = xs(t), n = a.pan, i = a.zoom, o = So();
  yn(o, o, [n.x, n.y]), $o(o, o, [i, i]);
  var s = So();
  cm(s, e, r);
  var u = So();
  return vm(u, s, o), u;
}
function Vv(t, e) {
  var r = t.canvasWidth, a = t.canvasHeight, n = xs(t), i = n.pan, o = n.zoom;
  e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, r, a), e.translate(i.x, i.y), e.scale(o, o);
}
function Lm(t, e) {
  t.drawSelectionRectangle(e, function(r) {
    return Vv(t, r);
  });
}
function Rm(t) {
  var e = t.data.contexts[t.NODE];
  e.save(), Vv(t, e), e.strokeStyle = "rgba(0, 0, 0, 0.3)", e.beginPath(), e.moveTo(-1e3, 0), e.lineTo(1e3, 0), e.stroke(), e.beginPath(), e.moveTo(0, -1e3), e.lineTo(0, 1e3), e.stroke(), e.restore();
}
function Mm(t) {
  var e = function(n, i, o) {
    for (var s = n.atlasManager.getAtlasCollection(i), u = t.data.contexts[t.NODE], l = s.atlases, f = 0; f < l.length; f++) {
      var v = l[f], c = v.canvas;
      if (c) {
        var h = c.width, d = c.height, g = h * f, p = c.height * o, y = 0.4;
        u.save(), u.scale(y, y), u.drawImage(c, g, p), u.strokeStyle = "black", u.rect(g, p, h, d), u.stroke(), u.restore();
      }
    }
  }, r = 0;
  e(t.drawing, "node", r++), e(t.drawing, "label", r++);
}
function Pm(t, e, r, a, n) {
  var i, o, s, u, l = xs(t), f = l.pan, v = l.zoom;
  {
    var c = rm(t, f, v, e, r), h = Qe(c, 2), d = h[0], g = h[1], p = 6;
    i = d - p / 2, o = g - p / 2, s = p, u = p;
  }
  if (s === 0 || u === 0)
    return [];
  var y = t.data.contexts[t.WEBGL];
  y.bindFramebuffer(y.FRAMEBUFFER, t.pickingFrameBuffer), t.pickingFrameBuffer.needsDraw && (y.viewport(0, 0, y.canvas.width, y.canvas.height), Uv(t, null, xa.PICKING), t.pickingFrameBuffer.needsDraw = !1);
  var b = s * u, m = new Uint8Array(b * 4);
  y.readPixels(i, o, s, u, y.RGBA, y.UNSIGNED_BYTE, m), y.bindFramebuffer(y.FRAMEBUFFER, null);
  for (var E = /* @__PURE__ */ new Set(), C = 0; C < b; C++) {
    var S = m.slice(C * 4, C * 4 + 4), w = im(S) - 1;
    w >= 0 && E.add(w);
  }
  return E;
}
function Im(t, e, r) {
  var a = Pm(t, e, r), n = t.getCachedZSortedEles(), i, o, s = Tt(a), u;
  try {
    for (s.s(); !(u = s.n()).done; ) {
      var l = u.value, f = n[l];
      if (!i && f.isNode() && (i = f), !o && f.isEdge() && (o = f), i && o)
        break;
    }
  } catch (v) {
    s.e(v);
  } finally {
    s.f();
  }
  return [i, o].filter(Boolean);
}
function Po(t, e, r) {
  var a = t.drawing;
  e += 1, r.isNode() ? (a.drawNode(r, e, "node-underlay"), a.drawNode(r, e, "node-body"), a.drawTexture(r, e, "label"), a.drawNode(r, e, "node-overlay")) : (a.drawEdgeLine(r, e), a.drawEdgeArrow(r, e, "source"), a.drawEdgeArrow(r, e, "target"), a.drawTexture(r, e, "label"), a.drawTexture(r, e, "edge-source-label"), a.drawTexture(r, e, "edge-target-label"));
}
function Uv(t, e, r) {
  var a;
  t.webglDebug && (a = performance.now());
  var n = t.drawing, i = 0;
  if (r.screen && t.data.canvasNeedsRedraw[t.SELECT_BOX] && Lm(t, e), t.data.canvasNeedsRedraw[t.NODE] || r.picking) {
    var o = t.data.contexts[t.WEBGL];
    r.screen ? (o.clearColor(0, 0, 0, 0), o.enable(o.BLEND), o.blendFunc(o.ONE, o.ONE_MINUS_SRC_ALPHA)) : o.disable(o.BLEND), o.clear(o.COLOR_BUFFER_BIT | o.DEPTH_BUFFER_BIT), o.viewport(0, 0, o.canvas.width, o.canvas.height);
    var s = Am(t), u = t.getCachedZSortedEles();
    if (i = u.length, n.startFrame(s, r), r.screen) {
      for (var l = 0; l < u.nondrag.length; l++)
        Po(t, l, u.nondrag[l]);
      for (var f = 0; f < u.drag.length; f++)
        Po(t, f, u.drag[f]);
    } else if (r.picking)
      for (var v = 0; v < u.length; v++)
        Po(t, v, u[v]);
    n.endFrame(), r.screen && t.webglDebugShowAtlases && (Rm(t), Mm(t)), t.data.canvasNeedsRedraw[t.NODE] = !1, t.data.canvasNeedsRedraw[t.DRAG] = !1;
  }
  if (t.webglDebug) {
    var c = performance.now(), h = !1, d = Math.ceil(c - a), g = n.getDebugInfo(), p = ["".concat(i, " elements"), "".concat(g.totalInstances, " instances"), "".concat(g.batchCount, " batches"), "".concat(g.totalAtlases, " atlases"), "".concat(g.wrappedCount, " wrapped textures"), "".concat(g.simpleCount, " simple shapes")].join(", ");
    if (h)
      console.log("WebGL (".concat(r.name, ") - time ").concat(d, "ms, ").concat(p));
    else {
      console.log("WebGL (".concat(r.name, ") - frame time ").concat(d, "ms")), console.log("Totals:"), console.log("  ".concat(p)), console.log("Texture Atlases Used:");
      var y = g.atlasInfo, b = Tt(y), m;
      try {
        for (b.s(); !(m = b.n()).done; ) {
          var E = m.value;
          console.log("  ".concat(E.type, ": ").concat(E.keyCount, " keys, ").concat(E.atlasCount, " atlases"));
        }
      } catch (C) {
        b.e(C);
      } finally {
        b.f();
      }
      console.log("");
    }
  }
  t.data.gc && (console.log("Garbage Collect!"), t.data.gc = !1, n.gc());
}
var yr = {};
yr.drawPolygonPath = function(t, e, r, a, n, i) {
  var o = a / 2, s = n / 2;
  t.beginPath && t.beginPath(), t.moveTo(e + o * i[0], r + s * i[1]);
  for (var u = 1; u < i.length / 2; u++)
    t.lineTo(e + o * i[u * 2], r + s * i[u * 2 + 1]);
  t.closePath();
};
yr.drawRoundPolygonPath = function(t, e, r, a, n, i, o) {
  o.forEach(function(s) {
    return xv(t, s);
  }), t.closePath();
};
yr.drawRoundRectanglePath = function(t, e, r, a, n, i) {
  var o = a / 2, s = n / 2, u = i === "auto" ? lr(a, n) : Math.min(i, s, o);
  t.beginPath && t.beginPath(), t.moveTo(e, r - s), t.arcTo(e + o, r - s, e + o, r, u), t.arcTo(e + o, r + s, e, r + s, u), t.arcTo(e - o, r + s, e - o, r, u), t.arcTo(e - o, r - s, e, r - s, u), t.lineTo(e, r - s), t.closePath();
};
yr.drawBottomRoundRectanglePath = function(t, e, r, a, n, i) {
  var o = a / 2, s = n / 2, u = i === "auto" ? lr(a, n) : i;
  t.beginPath && t.beginPath(), t.moveTo(e, r - s), t.lineTo(e + o, r - s), t.lineTo(e + o, r), t.arcTo(e + o, r + s, e, r + s, u), t.arcTo(e - o, r + s, e - o, r, u), t.lineTo(e - o, r - s), t.lineTo(e, r - s), t.closePath();
};
yr.drawCutRectanglePath = function(t, e, r, a, n, i, o) {
  var s = a / 2, u = n / 2, l = o === "auto" ? us() : o;
  t.beginPath && t.beginPath(), t.moveTo(e - s + l, r - u), t.lineTo(e + s - l, r - u), t.lineTo(e + s, r - u + l), t.lineTo(e + s, r + u - l), t.lineTo(e + s - l, r + u), t.lineTo(e - s + l, r + u), t.lineTo(e - s, r + u - l), t.lineTo(e - s, r - u + l), t.closePath();
};
yr.drawBarrelPath = function(t, e, r, a, n) {
  var i = a / 2, o = n / 2, s = e - i, u = e + i, l = r - o, f = r + o, v = ko(a, n), c = v.widthOffset, h = v.heightOffset, d = v.ctrlPtOffsetPct * c;
  t.beginPath && t.beginPath(), t.moveTo(s, l + h), t.lineTo(s, f - h), t.quadraticCurveTo(s + d, f, s + c, f), t.lineTo(u - c, f), t.quadraticCurveTo(u - d, f, u, f - h), t.lineTo(u, l + h), t.quadraticCurveTo(u - d, l, u - c, l), t.lineTo(s + c, l), t.quadraticCurveTo(s + d, l, s, l + h), t.closePath();
};
var Jl = Math.sin(0), jl = Math.cos(0), Ko = {}, Zo = {}, qv = Math.PI / 40;
for (var _r = 0 * Math.PI; _r < 2 * Math.PI; _r += qv)
  Ko[_r] = Math.sin(_r), Zo[_r] = Math.cos(_r);
yr.drawEllipsePath = function(t, e, r, a, n) {
  if (t.beginPath && t.beginPath(), t.ellipse)
    t.ellipse(e, r, a / 2, n / 2, 0, 0, 2 * Math.PI);
  else
    for (var i, o, s = a / 2, u = n / 2, l = 0 * Math.PI; l < 2 * Math.PI; l += qv)
      i = e - s * Ko[l] * Jl + s * Zo[l] * jl, o = r + u * Zo[l] * Jl + u * Ko[l] * jl, l === 0 ? t.moveTo(i, o) : t.lineTo(i, o);
  t.closePath();
};
var Ya = {};
Ya.createBuffer = function(t, e) {
  var r = document.createElement("canvas");
  return r.width = t, r.height = e, [r, r.getContext("2d")];
};
Ya.bufferCanvasImage = function(t) {
  var e = this.cy, r = e.mutableElements(), a = r.boundingBox(), n = this.findContainerClientCoords(), i = t.full ? Math.ceil(a.w) : n[2], o = t.full ? Math.ceil(a.h) : n[3], s = ne(t.maxWidth) || ne(t.maxHeight), u = this.getPixelRatio(), l = 1;
  if (t.scale !== void 0)
    i *= t.scale, o *= t.scale, l = t.scale;
  else if (s) {
    var f = 1 / 0, v = 1 / 0;
    ne(t.maxWidth) && (f = l * t.maxWidth / i), ne(t.maxHeight) && (v = l * t.maxHeight / o), l = Math.min(f, v), i *= l, o *= l;
  }
  s || (i *= u, o *= u, l *= u);
  var c = document.createElement("canvas");
  c.width = i, c.height = o, c.style.width = i + "px", c.style.height = o + "px";
  var h = c.getContext("2d");
  if (i > 0 && o > 0) {
    h.clearRect(0, 0, i, o), h.globalCompositeOperation = "source-over";
    var d = this.getCachedZSortedEles();
    if (t.full)
      h.translate(-a.x1 * l, -a.y1 * l), h.scale(l, l), this.drawElements(h, d), h.scale(1 / l, 1 / l), h.translate(a.x1 * l, a.y1 * l);
    else {
      var g = e.pan(), p = {
        x: g.x * l,
        y: g.y * l
      };
      l *= e.zoom(), h.translate(p.x, p.y), h.scale(l, l), this.drawElements(h, d), h.scale(1 / l, 1 / l), h.translate(-p.x, -p.y);
    }
    t.bg && (h.globalCompositeOperation = "destination-over", h.fillStyle = t.bg, h.rect(0, 0, i, o), h.fill());
  }
  return c;
};
function Om(t, e) {
  for (var r = atob(t), a = new ArrayBuffer(r.length), n = new Uint8Array(a), i = 0; i < r.length; i++)
    n[i] = r.charCodeAt(i);
  return new Blob([a], {
    type: e
  });
}
function ef(t) {
  var e = t.indexOf(",");
  return t.substr(e + 1);
}
function Yv(t, e, r) {
  var a = function() {
    return e.toDataURL(r, t.quality);
  };
  switch (t.output) {
    case "blob-promise":
      return new ra(function(n, i) {
        try {
          e.toBlob(function(o) {
            o != null ? n(o) : i(new Error("`canvas.toBlob()` sent a null value in its callback"));
          }, r, t.quality);
        } catch (o) {
          i(o);
        }
      });
    case "blob":
      return Om(ef(a()), r);
    case "base64":
      return ef(a());
    case "base64uri":
    default:
      return a();
  }
}
Ya.png = function(t) {
  return Yv(t, this.bufferCanvasImage(t), "image/png");
};
Ya.jpg = function(t) {
  return Yv(t, this.bufferCanvasImage(t), "image/jpeg");
};
var Hv = {};
Hv.nodeShapeImpl = function(t, e, r, a, n, i, o, s) {
  switch (t) {
    case "ellipse":
      return this.drawEllipsePath(e, r, a, n, i);
    case "polygon":
      return this.drawPolygonPath(e, r, a, n, i, o);
    case "round-polygon":
      return this.drawRoundPolygonPath(e, r, a, n, i, o, s);
    case "roundrectangle":
    case "round-rectangle":
      return this.drawRoundRectanglePath(e, r, a, n, i, s);
    case "cutrectangle":
    case "cut-rectangle":
      return this.drawCutRectanglePath(e, r, a, n, i, o, s);
    case "bottomroundrectangle":
    case "bottom-round-rectangle":
      return this.drawBottomRoundRectanglePath(e, r, a, n, i, s);
    case "barrel":
      return this.drawBarrelPath(e, r, a, n, i);
  }
};
var km = Xv, Ce = Xv.prototype;
Ce.CANVAS_LAYERS = 3;
Ce.SELECT_BOX = 0;
Ce.DRAG = 1;
Ce.NODE = 2;
Ce.WEBGL = 3;
Ce.CANVAS_TYPES = ["2d", "2d", "2d", "webgl2"];
Ce.BUFFER_COUNT = 3;
Ce.TEXTURE_BUFFER = 0;
Ce.MOTIONBLUR_BUFFER_NODE = 1;
Ce.MOTIONBLUR_BUFFER_DRAG = 2;
function Xv(t) {
  var e = this, r = e.cy.window(), a = r.document;
  t.webgl && (Ce.CANVAS_LAYERS = e.CANVAS_LAYERS = 4, console.log("webgl rendering enabled")), e.data = {
    canvases: new Array(Ce.CANVAS_LAYERS),
    contexts: new Array(Ce.CANVAS_LAYERS),
    canvasNeedsRedraw: new Array(Ce.CANVAS_LAYERS),
    bufferCanvases: new Array(Ce.BUFFER_COUNT),
    bufferContexts: new Array(Ce.CANVAS_LAYERS)
  };
  var n = "-webkit-tap-highlight-color", i = "rgba(0,0,0,0)";
  e.data.canvasContainer = a.createElement("div");
  var o = e.data.canvasContainer.style;
  e.data.canvasContainer.style[n] = i, o.position = "relative", o.zIndex = "0", o.overflow = "hidden";
  var s = t.cy.container();
  s.appendChild(e.data.canvasContainer), s.style[n] = i;
  var u = {
    "-webkit-user-select": "none",
    "-moz-user-select": "-moz-none",
    "user-select": "none",
    "-webkit-tap-highlight-color": "rgba(0,0,0,0)",
    "outline-style": "none"
  };
  Dc() && (u["-ms-touch-action"] = "none", u["touch-action"] = "none");
  for (var l = 0; l < Ce.CANVAS_LAYERS; l++) {
    var f = e.data.canvases[l] = a.createElement("canvas"), v = Ce.CANVAS_TYPES[l];
    e.data.contexts[l] = f.getContext(v), e.data.contexts[l] || qe("Could not create canvas of type " + v), Object.keys(u).forEach(function(K) {
      f.style[K] = u[K];
    }), f.style.position = "absolute", f.setAttribute("data-id", "layer" + l), f.style.zIndex = String(Ce.CANVAS_LAYERS - l), e.data.canvasContainer.appendChild(f), e.data.canvasNeedsRedraw[l] = !1;
  }
  e.data.topCanvas = e.data.canvases[0], e.data.canvases[Ce.NODE].setAttribute("data-id", "layer" + Ce.NODE + "-node"), e.data.canvases[Ce.SELECT_BOX].setAttribute("data-id", "layer" + Ce.SELECT_BOX + "-selectbox"), e.data.canvases[Ce.DRAG].setAttribute("data-id", "layer" + Ce.DRAG + "-drag"), e.data.canvases[Ce.WEBGL] && e.data.canvases[Ce.WEBGL].setAttribute("data-id", "layer" + Ce.WEBGL + "-webgl");
  for (var l = 0; l < Ce.BUFFER_COUNT; l++)
    e.data.bufferCanvases[l] = a.createElement("canvas"), e.data.bufferContexts[l] = e.data.bufferCanvases[l].getContext("2d"), e.data.bufferCanvases[l].style.position = "absolute", e.data.bufferCanvases[l].setAttribute("data-id", "buffer" + l), e.data.bufferCanvases[l].style.zIndex = String(-l - 1), e.data.bufferCanvases[l].style.visibility = "hidden";
  e.pathsEnabled = !0;
  var c = mt(), h = function(V) {
    return {
      x: (V.x1 + V.x2) / 2,
      y: (V.y1 + V.y2) / 2
    };
  }, d = function(V) {
    return {
      x: -V.w / 2,
      y: -V.h / 2
    };
  }, g = function(V) {
    var q = V[0]._private, H = q.oldBackgroundTimestamp === q.backgroundTimestamp;
    return !H;
  }, p = function(V) {
    return V[0]._private.nodeKey;
  }, y = function(V) {
    return V[0]._private.labelStyleKey;
  }, b = function(V) {
    return V[0]._private.sourceLabelStyleKey;
  }, m = function(V) {
    return V[0]._private.targetLabelStyleKey;
  }, E = function(V, q, H, Z, re) {
    return e.drawElement(V, q, H, !1, !1, re);
  }, C = function(V, q, H, Z, re) {
    return e.drawElementText(V, q, H, Z, "main", re);
  }, S = function(V, q, H, Z, re) {
    return e.drawElementText(V, q, H, Z, "source", re);
  }, w = function(V, q, H, Z, re) {
    return e.drawElementText(V, q, H, Z, "target", re);
  }, x = function(V) {
    return V.boundingBox(), V[0]._private.bodyBounds;
  }, T = function(V) {
    return V.boundingBox(), V[0]._private.labelBounds.main || c;
  }, D = function(V) {
    return V.boundingBox(), V[0]._private.labelBounds.source || c;
  }, A = function(V) {
    return V.boundingBox(), V[0]._private.labelBounds.target || c;
  }, L = function(V, q) {
    return q;
  }, R = function(V) {
    return h(x(V));
  }, P = function(V, q, H) {
    var Z = V ? V + "-" : "";
    return {
      x: q.x + H.pstyle(Z + "text-margin-x").pfValue,
      y: q.y + H.pstyle(Z + "text-margin-y").pfValue
    };
  }, I = function(V, q, H) {
    var Z = V[0]._private.rscratch;
    return {
      x: Z[q],
      y: Z[H]
    };
  }, k = function(V) {
    return P("", I(V, "labelX", "labelY"), V);
  }, O = function(V) {
    return P("source", I(V, "sourceLabelX", "sourceLabelY"), V);
  }, N = function(V) {
    return P("target", I(V, "targetLabelX", "targetLabelY"), V);
  }, F = function(V) {
    return d(x(V));
  }, G = function(V) {
    return d(D(V));
  }, B = function(V) {
    return d(A(V));
  }, z = function(V) {
    var q = T(V), H = d(T(V));
    if (V.isNode()) {
      switch (Jr(V.pstyle("text-halign").value)) {
        case "left":
          H.x = -q.w - (q.leftPad || 0);
          break;
        case "right":
          H.x = -(q.rightPad || 0);
          break;
      }
      switch (jr(V.pstyle("text-valign").value)) {
        case "top":
          H.y = -q.h - (q.topPad || 0);
          break;
        case "bottom":
          H.y = -(q.botPad || 0);
          break;
      }
    }
    return H;
  }, Y = e.data.eleTxrCache = new ba(e, {
    getKey: p,
    doesEleInvalidateKey: g,
    drawElement: E,
    getBoundingBox: x,
    getRotationPoint: R,
    getRotationOffset: F,
    allowEdgeTxrCaching: !1,
    allowParentTxrCaching: !1
  }), $ = e.data.lblTxrCache = new ba(e, {
    getKey: y,
    drawElement: C,
    getBoundingBox: T,
    getRotationPoint: k,
    getRotationOffset: z,
    isVisible: L
  }), X = e.data.slbTxrCache = new ba(e, {
    getKey: b,
    drawElement: S,
    getBoundingBox: D,
    getRotationPoint: O,
    getRotationOffset: G,
    isVisible: L
  }), j = e.data.tlbTxrCache = new ba(e, {
    getKey: m,
    drawElement: w,
    getBoundingBox: A,
    getRotationPoint: N,
    getRotationOffset: B,
    isVisible: L
  }), ee = e.data.lyrTxrCache = new Ov(e);
  e.onUpdateEleCalcs(function(V, q) {
    Y.invalidateElements(q), $.invalidateElements(q), X.invalidateElements(q), j.invalidateElements(q), ee.invalidateElements(q);
    for (var H = 0; H < q.length; H++) {
      var Z = q[H]._private;
      Z.oldBackgroundTimestamp = Z.backgroundTimestamp;
    }
  });
  var ae = function(V) {
    for (var q = 0; q < V.length; q++)
      ee.enqueueElementRefinement(V[q].ele);
  };
  Y.onDequeue(ae), $.onDequeue(ae), X.onDequeue(ae), j.onDequeue(ae), t.webgl && e.initWebgl(t, {
    getStyleKey: p,
    getLabelKey: y,
    getSourceLabelKey: b,
    getTargetLabelKey: m,
    drawElement: E,
    drawLabel: C,
    drawSourceLabel: S,
    drawTargetLabel: w,
    getElementBox: x,
    getLabelBox: T,
    getSourceLabelBox: D,
    getTargetLabelBox: A,
    getElementRotationPoint: R,
    getElementRotationOffset: F,
    getLabelRotationPoint: k,
    getSourceLabelRotationPoint: O,
    getTargetLabelRotationPoint: N,
    getLabelRotationOffset: z,
    getSourceLabelRotationOffset: G,
    getTargetLabelRotationOffset: B
  });
}
Ce.redrawHint = function(t, e) {
  var r = this;
  switch (t) {
    case "eles":
      r.data.canvasNeedsRedraw[Ce.NODE] = e;
      break;
    case "drag":
      r.data.canvasNeedsRedraw[Ce.DRAG] = e;
      break;
    case "select":
      r.data.canvasNeedsRedraw[Ce.SELECT_BOX] = e;
      break;
    case "gc":
      r.data.gc = !0;
      break;
  }
};
var Nm = typeof Path2D < "u";
Ce.path2dEnabled = function(t) {
  if (t === void 0)
    return this.pathsEnabled;
  this.pathsEnabled = !!t;
};
Ce.usePaths = function() {
  return Nm && this.pathsEnabled;
};
Ce.setImgSmoothing = function(t, e) {
  t.imageSmoothingEnabled != null ? t.imageSmoothingEnabled = e : (t.webkitImageSmoothingEnabled = e, t.mozImageSmoothingEnabled = e, t.msImageSmoothingEnabled = e);
};
Ce.getImgSmoothing = function(t) {
  return t.imageSmoothingEnabled != null ? t.imageSmoothingEnabled : t.webkitImageSmoothingEnabled || t.mozImageSmoothingEnabled || t.msImageSmoothingEnabled;
};
Ce.makeOffscreenCanvas = function(t, e) {
  var r;
  if ((typeof OffscreenCanvas > "u" ? "undefined" : tt(OffscreenCanvas)) !== "undefined")
    r = new OffscreenCanvas(t, e);
  else {
    var a = this.cy.window(), n = a.document;
    r = n.createElement("canvas"), r.width = t, r.height = e;
  }
  return r;
};
[kv, Yt, Qt, Es, Ir, pr, bt, zv, yr, Ya, Hv].forEach(function(t) {
  ye(Ce, t);
});
var Bm = [{
  name: "null",
  impl: bv
}, {
  name: "base",
  impl: Mv
}, {
  name: "canvas",
  impl: km
}], Fm = [{
  type: "layout",
  extensions: oy
}, {
  type: "renderer",
  extensions: Bm
}], Wv = {}, $v = {};
function Kv(t, e, r) {
  var a = r, n = function(x) {
    Fe("Can not register `" + e + "` for `" + t + "` since `" + x + "` already exists in the prototype and can not be overridden");
  };
  if (t === "core") {
    if (Pa.prototype[e])
      return n(e);
    Pa.prototype[e] = r;
  } else if (t === "collection") {
    if (lt.prototype[e])
      return n(e);
    lt.prototype[e] = r;
  } else if (t === "layout") {
    for (var i = function(x) {
      this.options = x, r.call(this, x), Ie(this._private) || (this._private = {}), this._private.cy = x.cy, this._private.listeners = [], this.createEmitter();
    }, o = i.prototype = Object.create(r.prototype), s = [], u = 0; u < s.length; u++) {
      var l = s[u];
      o[l] = o[l] || function() {
        return this;
      };
    }
    o.start && !o.run ? o.run = function() {
      return this.start(), this;
    } : !o.start && o.run && (o.start = function() {
      return this.run(), this;
    });
    var f = r.prototype.stop;
    o.stop = function() {
      var w = this.options;
      if (w && w.animate) {
        var x = this.animations;
        if (x)
          for (var T = 0; T < x.length; T++)
            x[T].stop();
      }
      return f ? f.call(this) : this.emit("layoutstop"), this;
    }, o.destroy || (o.destroy = function() {
      return this;
    }), o.cy = function() {
      return this._private.cy;
    };
    var v = function(x) {
      return x._private.cy;
    }, c = {
      addEventFields: function(x, T) {
        T.layout = x, T.cy = v(x), T.target = x;
      },
      bubble: function() {
        return !0;
      },
      parent: function(x) {
        return v(x);
      }
    };
    ye(o, {
      createEmitter: function() {
        return this._private.emitter = new Hn(c, this), this;
      },
      emitter: function() {
        return this._private.emitter;
      },
      on: function(x, T) {
        return this.emitter().on(x, T), this;
      },
      one: function(x, T) {
        return this.emitter().one(x, T), this;
      },
      once: function(x, T) {
        return this.emitter().one(x, T), this;
      },
      removeListener: function(x, T) {
        return this.emitter().removeListener(x, T), this;
      },
      removeAllListeners: function() {
        return this.emitter().removeAllListeners(), this;
      },
      emit: function(x, T) {
        return this.emitter().emit(x, T), this;
      }
    }), Be.eventAliasesOn(o), a = i;
  } else if (t === "renderer" && e !== "null" && e !== "base") {
    var h = Zv("renderer", "base"), d = h.prototype, g = r, p = r.prototype, y = function() {
      h.apply(this, arguments), g.apply(this, arguments);
    }, b = y.prototype;
    for (var m in d) {
      var E = d[m], C = p[m] != null;
      if (C)
        return n(m);
      b[m] = E;
    }
    for (var S in p)
      b[S] = p[S];
    d.clientFunctions.forEach(function(w) {
      b[w] = b[w] || function() {
        qe("Renderer does not implement `renderer." + w + "()` on its prototype");
      };
    }), a = y;
  } else if (t === "__proto__" || t === "constructor" || t === "prototype")
    return qe(t + " is an illegal type to be registered, possibly lead to prototype pollutions");
  return hf({
    map: Wv,
    keys: [t, e],
    value: a
  });
}
function Zv(t, e) {
  return df({
    map: Wv,
    keys: [t, e]
  });
}
function Gm(t, e, r, a, n) {
  return hf({
    map: $v,
    keys: [t, e, r, a],
    value: n
  });
}
function zm(t, e, r, a) {
  return df({
    map: $v,
    keys: [t, e, r, a]
  });
}
var Qo = function() {
  if (arguments.length === 2)
    return Zv.apply(null, arguments);
  if (arguments.length === 3)
    return Kv.apply(null, arguments);
  if (arguments.length === 4)
    return zm.apply(null, arguments);
  if (arguments.length === 5)
    return Gm.apply(null, arguments);
  qe("Invalid extension access syntax");
};
Pa.prototype.extension = Qo;
Fm.forEach(function(t) {
  t.extensions.forEach(function(e) {
    Kv(t.type, e.name, e.impl);
  });
});
var kn = function() {
  if (!(this instanceof kn))
    return new kn();
  this.length = 0;
}, Mr = kn.prototype;
Mr.instanceString = function() {
  return "stylesheet";
};
Mr.selector = function(t) {
  var e = this.length++;
  return this[e] = {
    selector: t,
    properties: []
  }, this;
};
Mr.css = function(t, e) {
  var r = this.length - 1;
  if (de(t))
    this[r].properties.push({
      name: t,
      value: e
    });
  else if (Ie(t))
    for (var a = t, n = Object.keys(a), i = 0; i < n.length; i++) {
      var o = n[i], s = a[o];
      if (s != null) {
        var u = it.properties[o] || it.properties[Nn(o)];
        if (u != null) {
          var l = u.name, f = s;
          this[r].properties.push({
            name: l,
            value: f
          });
        }
      }
    }
  return this;
};
Mr.style = Mr.css;
Mr.generateStyle = function(t) {
  var e = new it(t);
  return this.appendToStyle(e);
};
Mr.appendToStyle = function(t) {
  for (var e = 0; e < this.length; e++) {
    var r = this[e], a = r.selector, n = r.properties;
    t.selector(a);
    for (var i = 0; i < n.length; i++) {
      var o = n[i];
      t.css(o.name, o.value);
    }
  }
  return t;
};
var _m = "3.34.0", ea = function(e) {
  if (e === void 0 && (e = {}), Ie(e))
    return new Pa(e);
  if (de(e))
    return Qo.apply(Qo, arguments);
};
ea.use = function(t) {
  var e = Array.prototype.slice.call(arguments, 1);
  return e.unshift(ea), t.apply(null, e), this;
};
ea.warnings = function(t) {
  return Ef(t);
};
ea.version = _m;
ea.stylesheet = ea.Stylesheet = kn;
var mn = { exports: {} }, bn = { exports: {} }, wn = { exports: {} }, Vm = wn.exports, tf;
function Um() {
  return tf || (tf = 1, (function(t, e) {
    (function(a, n) {
      t.exports = n();
    })(Vm, function() {
      return (
        /******/
        (function(r) {
          var a = {};
          function n(i) {
            if (a[i])
              return a[i].exports;
            var o = a[i] = {
              /******/
              i,
              /******/
              l: !1,
              /******/
              exports: {}
              /******/
            };
            return r[i].call(o.exports, o, o.exports, n), o.l = !0, o.exports;
          }
          return n.m = r, n.c = a, n.i = function(i) {
            return i;
          }, n.d = function(i, o, s) {
            n.o(i, o) || Object.defineProperty(i, o, {
              /******/
              configurable: !1,
              /******/
              enumerable: !0,
              /******/
              get: s
              /******/
            });
          }, n.n = function(i) {
            var o = i && i.__esModule ? (
              /******/
              function() {
                return i.default;
              }
            ) : (
              /******/
              function() {
                return i;
              }
            );
            return n.d(o, "a", o), o;
          }, n.o = function(i, o) {
            return Object.prototype.hasOwnProperty.call(i, o);
          }, n.p = "", n(n.s = 26);
        })([
          /* 0 */
          /***/
          (function(r, a, n) {
            function i() {
            }
            i.QUALITY = 1, i.DEFAULT_CREATE_BENDS_AS_NEEDED = !1, i.DEFAULT_INCREMENTAL = !1, i.DEFAULT_ANIMATION_ON_LAYOUT = !0, i.DEFAULT_ANIMATION_DURING_LAYOUT = !1, i.DEFAULT_ANIMATION_PERIOD = 50, i.DEFAULT_UNIFORM_LEAF_NODE_SIZES = !1, i.DEFAULT_GRAPH_MARGIN = 15, i.NODE_DIMENSIONS_INCLUDE_LABELS = !1, i.SIMPLE_NODE_SIZE = 40, i.SIMPLE_NODE_HALF_SIZE = i.SIMPLE_NODE_SIZE / 2, i.EMPTY_COMPOUND_NODE_SIZE = 40, i.MIN_EDGE_LENGTH = 1, i.WORLD_BOUNDARY = 1e6, i.INITIAL_WORLD_BOUNDARY = i.WORLD_BOUNDARY / 1e3, i.WORLD_CENTER_X = 1200, i.WORLD_CENTER_Y = 900, r.exports = i;
          }),
          /* 1 */
          /***/
          (function(r, a, n) {
            var i = n(2), o = n(8), s = n(9);
            function u(f, v, c) {
              i.call(this, c), this.isOverlapingSourceAndTarget = !1, this.vGraphObject = c, this.bendpoints = [], this.source = f, this.target = v;
            }
            u.prototype = Object.create(i.prototype);
            for (var l in i)
              u[l] = i[l];
            u.prototype.getSource = function() {
              return this.source;
            }, u.prototype.getTarget = function() {
              return this.target;
            }, u.prototype.isInterGraph = function() {
              return this.isInterGraph;
            }, u.prototype.getLength = function() {
              return this.length;
            }, u.prototype.isOverlapingSourceAndTarget = function() {
              return this.isOverlapingSourceAndTarget;
            }, u.prototype.getBendpoints = function() {
              return this.bendpoints;
            }, u.prototype.getLca = function() {
              return this.lca;
            }, u.prototype.getSourceInLca = function() {
              return this.sourceInLca;
            }, u.prototype.getTargetInLca = function() {
              return this.targetInLca;
            }, u.prototype.getOtherEnd = function(f) {
              if (this.source === f)
                return this.target;
              if (this.target === f)
                return this.source;
              throw "Node is not incident with this edge";
            }, u.prototype.getOtherEndInGraph = function(f, v) {
              for (var c = this.getOtherEnd(f), h = v.getGraphManager().getRoot(); ; ) {
                if (c.getOwner() == v)
                  return c;
                if (c.getOwner() == h)
                  break;
                c = c.getOwner().getParent();
              }
              return null;
            }, u.prototype.updateLength = function() {
              var f = new Array(4);
              this.isOverlapingSourceAndTarget = o.getIntersection(this.target.getRect(), this.source.getRect(), f), this.isOverlapingSourceAndTarget || (this.lengthX = f[0] - f[2], this.lengthY = f[1] - f[3], Math.abs(this.lengthX) < 1 && (this.lengthX = s.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = s.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY));
            }, u.prototype.updateLengthSimple = function() {
              this.lengthX = this.target.getCenterX() - this.source.getCenterX(), this.lengthY = this.target.getCenterY() - this.source.getCenterY(), Math.abs(this.lengthX) < 1 && (this.lengthX = s.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = s.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
            }, r.exports = u;
          }),
          /* 2 */
          /***/
          (function(r, a, n) {
            function i(o) {
              this.vGraphObject = o;
            }
            r.exports = i;
          }),
          /* 3 */
          /***/
          (function(r, a, n) {
            var i = n(2), o = n(10), s = n(13), u = n(0), l = n(16), f = n(4);
            function v(h, d, g, p) {
              g == null && p == null && (p = d), i.call(this, p), h.graphManager != null && (h = h.graphManager), this.estimatedSize = o.MIN_VALUE, this.inclusionTreeDepth = o.MAX_VALUE, this.vGraphObject = p, this.edges = [], this.graphManager = h, g != null && d != null ? this.rect = new s(d.x, d.y, g.width, g.height) : this.rect = new s();
            }
            v.prototype = Object.create(i.prototype);
            for (var c in i)
              v[c] = i[c];
            v.prototype.getEdges = function() {
              return this.edges;
            }, v.prototype.getChild = function() {
              return this.child;
            }, v.prototype.getOwner = function() {
              return this.owner;
            }, v.prototype.getWidth = function() {
              return this.rect.width;
            }, v.prototype.setWidth = function(h) {
              this.rect.width = h;
            }, v.prototype.getHeight = function() {
              return this.rect.height;
            }, v.prototype.setHeight = function(h) {
              this.rect.height = h;
            }, v.prototype.getCenterX = function() {
              return this.rect.x + this.rect.width / 2;
            }, v.prototype.getCenterY = function() {
              return this.rect.y + this.rect.height / 2;
            }, v.prototype.getCenter = function() {
              return new f(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
            }, v.prototype.getLocation = function() {
              return new f(this.rect.x, this.rect.y);
            }, v.prototype.getRect = function() {
              return this.rect;
            }, v.prototype.getDiagonal = function() {
              return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
            }, v.prototype.getHalfTheDiagonal = function() {
              return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
            }, v.prototype.setRect = function(h, d) {
              this.rect.x = h.x, this.rect.y = h.y, this.rect.width = d.width, this.rect.height = d.height;
            }, v.prototype.setCenter = function(h, d) {
              this.rect.x = h - this.rect.width / 2, this.rect.y = d - this.rect.height / 2;
            }, v.prototype.setLocation = function(h, d) {
              this.rect.x = h, this.rect.y = d;
            }, v.prototype.moveBy = function(h, d) {
              this.rect.x += h, this.rect.y += d;
            }, v.prototype.getEdgeListToNode = function(h) {
              var d = [], g = this;
              return g.edges.forEach(function(p) {
                if (p.target == h) {
                  if (p.source != g) throw "Incorrect edge source!";
                  d.push(p);
                }
              }), d;
            }, v.prototype.getEdgesBetween = function(h) {
              var d = [], g = this;
              return g.edges.forEach(function(p) {
                if (!(p.source == g || p.target == g)) throw "Incorrect edge source and/or target";
                (p.target == h || p.source == h) && d.push(p);
              }), d;
            }, v.prototype.getNeighborsList = function() {
              var h = /* @__PURE__ */ new Set(), d = this;
              return d.edges.forEach(function(g) {
                if (g.source == d)
                  h.add(g.target);
                else {
                  if (g.target != d)
                    throw "Incorrect incidency!";
                  h.add(g.source);
                }
              }), h;
            }, v.prototype.withChildren = function() {
              var h = /* @__PURE__ */ new Set(), d, g;
              if (h.add(this), this.child != null)
                for (var p = this.child.getNodes(), y = 0; y < p.length; y++)
                  d = p[y], g = d.withChildren(), g.forEach(function(b) {
                    h.add(b);
                  });
              return h;
            }, v.prototype.getNoOfChildren = function() {
              var h = 0, d;
              if (this.child == null)
                h = 1;
              else
                for (var g = this.child.getNodes(), p = 0; p < g.length; p++)
                  d = g[p], h += d.getNoOfChildren();
              return h == 0 && (h = 1), h;
            }, v.prototype.getEstimatedSize = function() {
              if (this.estimatedSize == o.MIN_VALUE)
                throw "assert failed";
              return this.estimatedSize;
            }, v.prototype.calcEstimatedSize = function() {
              return this.child == null ? this.estimatedSize = (this.rect.width + this.rect.height) / 2 : (this.estimatedSize = this.child.calcEstimatedSize(), this.rect.width = this.estimatedSize, this.rect.height = this.estimatedSize, this.estimatedSize);
            }, v.prototype.scatter = function() {
              var h, d, g = -u.INITIAL_WORLD_BOUNDARY, p = u.INITIAL_WORLD_BOUNDARY;
              h = u.WORLD_CENTER_X + l.nextDouble() * (p - g) + g;
              var y = -u.INITIAL_WORLD_BOUNDARY, b = u.INITIAL_WORLD_BOUNDARY;
              d = u.WORLD_CENTER_Y + l.nextDouble() * (b - y) + y, this.rect.x = h, this.rect.y = d;
            }, v.prototype.updateBounds = function() {
              if (this.getChild() == null)
                throw "assert failed";
              if (this.getChild().getNodes().length != 0) {
                var h = this.getChild();
                if (h.updateBounds(!0), this.rect.x = h.getLeft(), this.rect.y = h.getTop(), this.setWidth(h.getRight() - h.getLeft()), this.setHeight(h.getBottom() - h.getTop()), u.NODE_DIMENSIONS_INCLUDE_LABELS) {
                  var d = h.getRight() - h.getLeft(), g = h.getBottom() - h.getTop();
                  this.labelWidth > d && (this.rect.x -= (this.labelWidth - d) / 2, this.setWidth(this.labelWidth)), this.labelHeight > g && (this.labelPos == "center" ? this.rect.y -= (this.labelHeight - g) / 2 : this.labelPos == "top" && (this.rect.y -= this.labelHeight - g), this.setHeight(this.labelHeight));
                }
              }
            }, v.prototype.getInclusionTreeDepth = function() {
              if (this.inclusionTreeDepth == o.MAX_VALUE)
                throw "assert failed";
              return this.inclusionTreeDepth;
            }, v.prototype.transform = function(h) {
              var d = this.rect.x;
              d > u.WORLD_BOUNDARY ? d = u.WORLD_BOUNDARY : d < -u.WORLD_BOUNDARY && (d = -u.WORLD_BOUNDARY);
              var g = this.rect.y;
              g > u.WORLD_BOUNDARY ? g = u.WORLD_BOUNDARY : g < -u.WORLD_BOUNDARY && (g = -u.WORLD_BOUNDARY);
              var p = new f(d, g), y = h.inverseTransformPoint(p);
              this.setLocation(y.x, y.y);
            }, v.prototype.getLeft = function() {
              return this.rect.x;
            }, v.prototype.getRight = function() {
              return this.rect.x + this.rect.width;
            }, v.prototype.getTop = function() {
              return this.rect.y;
            }, v.prototype.getBottom = function() {
              return this.rect.y + this.rect.height;
            }, v.prototype.getParent = function() {
              return this.owner == null ? null : this.owner.getParent();
            }, r.exports = v;
          }),
          /* 4 */
          /***/
          (function(r, a, n) {
            function i(o, s) {
              o == null && s == null ? (this.x = 0, this.y = 0) : (this.x = o, this.y = s);
            }
            i.prototype.getX = function() {
              return this.x;
            }, i.prototype.getY = function() {
              return this.y;
            }, i.prototype.setX = function(o) {
              this.x = o;
            }, i.prototype.setY = function(o) {
              this.y = o;
            }, i.prototype.getDifference = function(o) {
              return new DimensionD(this.x - o.x, this.y - o.y);
            }, i.prototype.getCopy = function() {
              return new i(this.x, this.y);
            }, i.prototype.translate = function(o) {
              return this.x += o.width, this.y += o.height, this;
            }, r.exports = i;
          }),
          /* 5 */
          /***/
          (function(r, a, n) {
            var i = n(2), o = n(10), s = n(0), u = n(6), l = n(3), f = n(1), v = n(13), c = n(12), h = n(11);
            function d(p, y, b) {
              i.call(this, b), this.estimatedSize = o.MIN_VALUE, this.margin = s.DEFAULT_GRAPH_MARGIN, this.edges = [], this.nodes = [], this.isConnected = !1, this.parent = p, y != null && y instanceof u ? this.graphManager = y : y != null && y instanceof Layout && (this.graphManager = y.graphManager);
            }
            d.prototype = Object.create(i.prototype);
            for (var g in i)
              d[g] = i[g];
            d.prototype.getNodes = function() {
              return this.nodes;
            }, d.prototype.getEdges = function() {
              return this.edges;
            }, d.prototype.getGraphManager = function() {
              return this.graphManager;
            }, d.prototype.getParent = function() {
              return this.parent;
            }, d.prototype.getLeft = function() {
              return this.left;
            }, d.prototype.getRight = function() {
              return this.right;
            }, d.prototype.getTop = function() {
              return this.top;
            }, d.prototype.getBottom = function() {
              return this.bottom;
            }, d.prototype.isConnected = function() {
              return this.isConnected;
            }, d.prototype.add = function(p, y, b) {
              if (y == null && b == null) {
                var m = p;
                if (this.graphManager == null)
                  throw "Graph has no graph mgr!";
                if (this.getNodes().indexOf(m) > -1)
                  throw "Node already in graph!";
                return m.owner = this, this.getNodes().push(m), m;
              } else {
                var E = p;
                if (!(this.getNodes().indexOf(y) > -1 && this.getNodes().indexOf(b) > -1))
                  throw "Source or target not in graph!";
                if (!(y.owner == b.owner && y.owner == this))
                  throw "Both owners must be this graph!";
                return y.owner != b.owner ? null : (E.source = y, E.target = b, E.isInterGraph = !1, this.getEdges().push(E), y.edges.push(E), b != y && b.edges.push(E), E);
              }
            }, d.prototype.remove = function(p) {
              var y = p;
              if (p instanceof l) {
                if (y == null)
                  throw "Node is null!";
                if (!(y.owner != null && y.owner == this))
                  throw "Owner graph is invalid!";
                if (this.graphManager == null)
                  throw "Owner graph manager is invalid!";
                for (var b = y.edges.slice(), m, E = b.length, C = 0; C < E; C++)
                  m = b[C], m.isInterGraph ? this.graphManager.remove(m) : m.source.owner.remove(m);
                var S = this.nodes.indexOf(y);
                if (S == -1)
                  throw "Node not in owner node list!";
                this.nodes.splice(S, 1);
              } else if (p instanceof f) {
                var m = p;
                if (m == null)
                  throw "Edge is null!";
                if (!(m.source != null && m.target != null))
                  throw "Source and/or target is null!";
                if (!(m.source.owner != null && m.target.owner != null && m.source.owner == this && m.target.owner == this))
                  throw "Source and/or target owner is invalid!";
                var w = m.source.edges.indexOf(m), x = m.target.edges.indexOf(m);
                if (!(w > -1 && x > -1))
                  throw "Source and/or target doesn't know this edge!";
                m.source.edges.splice(w, 1), m.target != m.source && m.target.edges.splice(x, 1);
                var S = m.source.owner.getEdges().indexOf(m);
                if (S == -1)
                  throw "Not in owner's edge list!";
                m.source.owner.getEdges().splice(S, 1);
              }
            }, d.prototype.updateLeftTop = function() {
              for (var p = o.MAX_VALUE, y = o.MAX_VALUE, b, m, E, C = this.getNodes(), S = C.length, w = 0; w < S; w++) {
                var x = C[w];
                b = x.getTop(), m = x.getLeft(), p > b && (p = b), y > m && (y = m);
              }
              return p == o.MAX_VALUE ? null : (C[0].getParent().paddingLeft != null ? E = C[0].getParent().paddingLeft : E = this.margin, this.left = y - E, this.top = p - E, new c(this.left, this.top));
            }, d.prototype.updateBounds = function(p) {
              for (var y = o.MAX_VALUE, b = -o.MAX_VALUE, m = o.MAX_VALUE, E = -o.MAX_VALUE, C, S, w, x, T, D = this.nodes, A = D.length, L = 0; L < A; L++) {
                var R = D[L];
                p && R.child != null && R.updateBounds(), C = R.getLeft(), S = R.getRight(), w = R.getTop(), x = R.getBottom(), y > C && (y = C), b < S && (b = S), m > w && (m = w), E < x && (E = x);
              }
              var P = new v(y, m, b - y, E - m);
              y == o.MAX_VALUE && (this.left = this.parent.getLeft(), this.right = this.parent.getRight(), this.top = this.parent.getTop(), this.bottom = this.parent.getBottom()), D[0].getParent().paddingLeft != null ? T = D[0].getParent().paddingLeft : T = this.margin, this.left = P.x - T, this.right = P.x + P.width + T, this.top = P.y - T, this.bottom = P.y + P.height + T;
            }, d.calculateBounds = function(p) {
              for (var y = o.MAX_VALUE, b = -o.MAX_VALUE, m = o.MAX_VALUE, E = -o.MAX_VALUE, C, S, w, x, T = p.length, D = 0; D < T; D++) {
                var A = p[D];
                C = A.getLeft(), S = A.getRight(), w = A.getTop(), x = A.getBottom(), y > C && (y = C), b < S && (b = S), m > w && (m = w), E < x && (E = x);
              }
              var L = new v(y, m, b - y, E - m);
              return L;
            }, d.prototype.getInclusionTreeDepth = function() {
              return this == this.graphManager.getRoot() ? 1 : this.parent.getInclusionTreeDepth();
            }, d.prototype.getEstimatedSize = function() {
              if (this.estimatedSize == o.MIN_VALUE)
                throw "assert failed";
              return this.estimatedSize;
            }, d.prototype.calcEstimatedSize = function() {
              for (var p = 0, y = this.nodes, b = y.length, m = 0; m < b; m++) {
                var E = y[m];
                p += E.calcEstimatedSize();
              }
              return p == 0 ? this.estimatedSize = s.EMPTY_COMPOUND_NODE_SIZE : this.estimatedSize = p / Math.sqrt(this.nodes.length), this.estimatedSize;
            }, d.prototype.updateConnected = function() {
              var p = this;
              if (this.nodes.length == 0) {
                this.isConnected = !0;
                return;
              }
              var y = new h(), b = /* @__PURE__ */ new Set(), m = this.nodes[0], E, C, S = m.withChildren();
              for (S.forEach(function(L) {
                y.push(L), b.add(L);
              }); y.length !== 0; ) {
                m = y.shift(), E = m.getEdges();
                for (var w = E.length, x = 0; x < w; x++) {
                  var T = E[x];
                  if (C = T.getOtherEndInGraph(m, this), C != null && !b.has(C)) {
                    var D = C.withChildren();
                    D.forEach(function(L) {
                      y.push(L), b.add(L);
                    });
                  }
                }
              }
              if (this.isConnected = !1, b.size >= this.nodes.length) {
                var A = 0;
                b.forEach(function(L) {
                  L.owner == p && A++;
                }), A == this.nodes.length && (this.isConnected = !0);
              }
            }, r.exports = d;
          }),
          /* 6 */
          /***/
          (function(r, a, n) {
            var i, o = n(1);
            function s(u) {
              i = n(5), this.layout = u, this.graphs = [], this.edges = [];
            }
            s.prototype.addRoot = function() {
              var u = this.layout.newGraph(), l = this.layout.newNode(null), f = this.add(u, l);
              return this.setRootGraph(f), this.rootGraph;
            }, s.prototype.add = function(u, l, f, v, c) {
              if (f == null && v == null && c == null) {
                if (u == null)
                  throw "Graph is null!";
                if (l == null)
                  throw "Parent node is null!";
                if (this.graphs.indexOf(u) > -1)
                  throw "Graph already in this graph mgr!";
                if (this.graphs.push(u), u.parent != null)
                  throw "Already has a parent!";
                if (l.child != null)
                  throw "Already has a child!";
                return u.parent = l, l.child = u, u;
              } else {
                c = f, v = l, f = u;
                var h = v.getOwner(), d = c.getOwner();
                if (!(h != null && h.getGraphManager() == this))
                  throw "Source not in this graph mgr!";
                if (!(d != null && d.getGraphManager() == this))
                  throw "Target not in this graph mgr!";
                if (h == d)
                  return f.isInterGraph = !1, h.add(f, v, c);
                if (f.isInterGraph = !0, f.source = v, f.target = c, this.edges.indexOf(f) > -1)
                  throw "Edge already in inter-graph edge list!";
                if (this.edges.push(f), !(f.source != null && f.target != null))
                  throw "Edge source and/or target is null!";
                if (!(f.source.edges.indexOf(f) == -1 && f.target.edges.indexOf(f) == -1))
                  throw "Edge already in source and/or target incidency list!";
                return f.source.edges.push(f), f.target.edges.push(f), f;
              }
            }, s.prototype.remove = function(u) {
              if (u instanceof i) {
                var l = u;
                if (l.getGraphManager() != this)
                  throw "Graph not in this graph mgr";
                if (!(l == this.rootGraph || l.parent != null && l.parent.graphManager == this))
                  throw "Invalid parent node!";
                var f = [];
                f = f.concat(l.getEdges());
                for (var v, c = f.length, h = 0; h < c; h++)
                  v = f[h], l.remove(v);
                var d = [];
                d = d.concat(l.getNodes());
                var g;
                c = d.length;
                for (var h = 0; h < c; h++)
                  g = d[h], l.remove(g);
                l == this.rootGraph && this.setRootGraph(null);
                var p = this.graphs.indexOf(l);
                this.graphs.splice(p, 1), l.parent = null;
              } else if (u instanceof o) {
                if (v = u, v == null)
                  throw "Edge is null!";
                if (!v.isInterGraph)
                  throw "Not an inter-graph edge!";
                if (!(v.source != null && v.target != null))
                  throw "Source and/or target is null!";
                if (!(v.source.edges.indexOf(v) != -1 && v.target.edges.indexOf(v) != -1))
                  throw "Source and/or target doesn't know this edge!";
                var p = v.source.edges.indexOf(v);
                if (v.source.edges.splice(p, 1), p = v.target.edges.indexOf(v), v.target.edges.splice(p, 1), !(v.source.owner != null && v.source.owner.getGraphManager() != null))
                  throw "Edge owner graph or owner graph manager is null!";
                if (v.source.owner.getGraphManager().edges.indexOf(v) == -1)
                  throw "Not in owner graph manager's edge list!";
                var p = v.source.owner.getGraphManager().edges.indexOf(v);
                v.source.owner.getGraphManager().edges.splice(p, 1);
              }
            }, s.prototype.updateBounds = function() {
              this.rootGraph.updateBounds(!0);
            }, s.prototype.getGraphs = function() {
              return this.graphs;
            }, s.prototype.getAllNodes = function() {
              if (this.allNodes == null) {
                for (var u = [], l = this.getGraphs(), f = l.length, v = 0; v < f; v++)
                  u = u.concat(l[v].getNodes());
                this.allNodes = u;
              }
              return this.allNodes;
            }, s.prototype.resetAllNodes = function() {
              this.allNodes = null;
            }, s.prototype.resetAllEdges = function() {
              this.allEdges = null;
            }, s.prototype.resetAllNodesToApplyGravitation = function() {
              this.allNodesToApplyGravitation = null;
            }, s.prototype.getAllEdges = function() {
              if (this.allEdges == null) {
                var u = [], l = this.getGraphs();
                l.length;
                for (var f = 0; f < l.length; f++)
                  u = u.concat(l[f].getEdges());
                u = u.concat(this.edges), this.allEdges = u;
              }
              return this.allEdges;
            }, s.prototype.getAllNodesToApplyGravitation = function() {
              return this.allNodesToApplyGravitation;
            }, s.prototype.setAllNodesToApplyGravitation = function(u) {
              if (this.allNodesToApplyGravitation != null)
                throw "assert failed";
              this.allNodesToApplyGravitation = u;
            }, s.prototype.getRoot = function() {
              return this.rootGraph;
            }, s.prototype.setRootGraph = function(u) {
              if (u.getGraphManager() != this)
                throw "Root not in this graph mgr!";
              this.rootGraph = u, u.parent == null && (u.parent = this.layout.newNode("Root node"));
            }, s.prototype.getLayout = function() {
              return this.layout;
            }, s.prototype.isOneAncestorOfOther = function(u, l) {
              if (!(u != null && l != null))
                throw "assert failed";
              if (u == l)
                return !0;
              var f = u.getOwner(), v;
              do {
                if (v = f.getParent(), v == null)
                  break;
                if (v == l)
                  return !0;
                if (f = v.getOwner(), f == null)
                  break;
              } while (!0);
              f = l.getOwner();
              do {
                if (v = f.getParent(), v == null)
                  break;
                if (v == u)
                  return !0;
                if (f = v.getOwner(), f == null)
                  break;
              } while (!0);
              return !1;
            }, s.prototype.calcLowestCommonAncestors = function() {
              for (var u, l, f, v, c, h = this.getAllEdges(), d = h.length, g = 0; g < d; g++) {
                if (u = h[g], l = u.source, f = u.target, u.lca = null, u.sourceInLca = l, u.targetInLca = f, l == f) {
                  u.lca = l.getOwner();
                  continue;
                }
                for (v = l.getOwner(); u.lca == null; ) {
                  for (u.targetInLca = f, c = f.getOwner(); u.lca == null; ) {
                    if (c == v) {
                      u.lca = c;
                      break;
                    }
                    if (c == this.rootGraph)
                      break;
                    if (u.lca != null)
                      throw "assert failed";
                    u.targetInLca = c.getParent(), c = u.targetInLca.getOwner();
                  }
                  if (v == this.rootGraph)
                    break;
                  u.lca == null && (u.sourceInLca = v.getParent(), v = u.sourceInLca.getOwner());
                }
                if (u.lca == null)
                  throw "assert failed";
              }
            }, s.prototype.calcLowestCommonAncestor = function(u, l) {
              if (u == l)
                return u.getOwner();
              var f = u.getOwner();
              do {
                if (f == null)
                  break;
                var v = l.getOwner();
                do {
                  if (v == null)
                    break;
                  if (v == f)
                    return v;
                  v = v.getParent().getOwner();
                } while (!0);
                f = f.getParent().getOwner();
              } while (!0);
              return f;
            }, s.prototype.calcInclusionTreeDepths = function(u, l) {
              u == null && l == null && (u = this.rootGraph, l = 1);
              for (var f, v = u.getNodes(), c = v.length, h = 0; h < c; h++)
                f = v[h], f.inclusionTreeDepth = l, f.child != null && this.calcInclusionTreeDepths(f.child, l + 1);
            }, s.prototype.includesInvalidEdge = function() {
              for (var u, l = this.edges.length, f = 0; f < l; f++)
                if (u = this.edges[f], this.isOneAncestorOfOther(u.source, u.target))
                  return !0;
              return !1;
            }, r.exports = s;
          }),
          /* 7 */
          /***/
          (function(r, a, n) {
            var i = n(0);
            function o() {
            }
            for (var s in i)
              o[s] = i[s];
            o.MAX_ITERATIONS = 2500, o.DEFAULT_EDGE_LENGTH = 50, o.DEFAULT_SPRING_STRENGTH = 0.45, o.DEFAULT_REPULSION_STRENGTH = 4500, o.DEFAULT_GRAVITY_STRENGTH = 0.4, o.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1, o.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8, o.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5, o.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = !0, o.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = !0, o.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3, o.COOLING_ADAPTATION_FACTOR = 0.33, o.ADAPTATION_LOWER_NODE_LIMIT = 1e3, o.ADAPTATION_UPPER_NODE_LIMIT = 5e3, o.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100, o.MAX_NODE_DISPLACEMENT = o.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3, o.MIN_REPULSION_DIST = o.DEFAULT_EDGE_LENGTH / 10, o.CONVERGENCE_CHECK_PERIOD = 100, o.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1, o.MIN_EDGE_LENGTH = 1, o.GRID_CALCULATION_CHECK_PERIOD = 10, r.exports = o;
          }),
          /* 8 */
          /***/
          (function(r, a, n) {
            var i = n(12);
            function o() {
            }
            o.calcSeparationAmount = function(s, u, l, f) {
              if (!s.intersects(u))
                throw "assert failed";
              var v = new Array(2);
              this.decideDirectionsForOverlappingNodes(s, u, v), l[0] = Math.min(s.getRight(), u.getRight()) - Math.max(s.x, u.x), l[1] = Math.min(s.getBottom(), u.getBottom()) - Math.max(s.y, u.y), s.getX() <= u.getX() && s.getRight() >= u.getRight() ? l[0] += Math.min(u.getX() - s.getX(), s.getRight() - u.getRight()) : u.getX() <= s.getX() && u.getRight() >= s.getRight() && (l[0] += Math.min(s.getX() - u.getX(), u.getRight() - s.getRight())), s.getY() <= u.getY() && s.getBottom() >= u.getBottom() ? l[1] += Math.min(u.getY() - s.getY(), s.getBottom() - u.getBottom()) : u.getY() <= s.getY() && u.getBottom() >= s.getBottom() && (l[1] += Math.min(s.getY() - u.getY(), u.getBottom() - s.getBottom()));
              var c = Math.abs((u.getCenterY() - s.getCenterY()) / (u.getCenterX() - s.getCenterX()));
              u.getCenterY() === s.getCenterY() && u.getCenterX() === s.getCenterX() && (c = 1);
              var h = c * l[0], d = l[1] / c;
              l[0] < d ? d = l[0] : h = l[1], l[0] = -1 * v[0] * (d / 2 + f), l[1] = -1 * v[1] * (h / 2 + f);
            }, o.decideDirectionsForOverlappingNodes = function(s, u, l) {
              s.getCenterX() < u.getCenterX() ? l[0] = -1 : l[0] = 1, s.getCenterY() < u.getCenterY() ? l[1] = -1 : l[1] = 1;
            }, o.getIntersection2 = function(s, u, l) {
              var f = s.getCenterX(), v = s.getCenterY(), c = u.getCenterX(), h = u.getCenterY();
              if (s.intersects(u))
                return l[0] = f, l[1] = v, l[2] = c, l[3] = h, !0;
              var d = s.getX(), g = s.getY(), p = s.getRight(), y = s.getX(), b = s.getBottom(), m = s.getRight(), E = s.getWidthHalf(), C = s.getHeightHalf(), S = u.getX(), w = u.getY(), x = u.getRight(), T = u.getX(), D = u.getBottom(), A = u.getRight(), L = u.getWidthHalf(), R = u.getHeightHalf(), P = !1, I = !1;
              if (f === c) {
                if (v > h)
                  return l[0] = f, l[1] = g, l[2] = c, l[3] = D, !1;
                if (v < h)
                  return l[0] = f, l[1] = b, l[2] = c, l[3] = w, !1;
              } else if (v === h) {
                if (f > c)
                  return l[0] = d, l[1] = v, l[2] = x, l[3] = h, !1;
                if (f < c)
                  return l[0] = p, l[1] = v, l[2] = S, l[3] = h, !1;
              } else {
                var k = s.height / s.width, O = u.height / u.width, N = (h - v) / (c - f), F = void 0, G = void 0, B = void 0, z = void 0, Y = void 0, $ = void 0;
                if (-k === N ? f > c ? (l[0] = y, l[1] = b, P = !0) : (l[0] = p, l[1] = g, P = !0) : k === N && (f > c ? (l[0] = d, l[1] = g, P = !0) : (l[0] = m, l[1] = b, P = !0)), -O === N ? c > f ? (l[2] = T, l[3] = D, I = !0) : (l[2] = x, l[3] = w, I = !0) : O === N && (c > f ? (l[2] = S, l[3] = w, I = !0) : (l[2] = A, l[3] = D, I = !0)), P && I)
                  return !1;
                if (f > c ? v > h ? (F = this.getCardinalDirection(k, N, 4), G = this.getCardinalDirection(O, N, 2)) : (F = this.getCardinalDirection(-k, N, 3), G = this.getCardinalDirection(-O, N, 1)) : v > h ? (F = this.getCardinalDirection(-k, N, 1), G = this.getCardinalDirection(-O, N, 3)) : (F = this.getCardinalDirection(k, N, 2), G = this.getCardinalDirection(O, N, 4)), !P)
                  switch (F) {
                    case 1:
                      z = g, B = f + -C / N, l[0] = B, l[1] = z;
                      break;
                    case 2:
                      B = m, z = v + E * N, l[0] = B, l[1] = z;
                      break;
                    case 3:
                      z = b, B = f + C / N, l[0] = B, l[1] = z;
                      break;
                    case 4:
                      B = y, z = v + -E * N, l[0] = B, l[1] = z;
                      break;
                  }
                if (!I)
                  switch (G) {
                    case 1:
                      $ = w, Y = c + -R / N, l[2] = Y, l[3] = $;
                      break;
                    case 2:
                      Y = A, $ = h + L * N, l[2] = Y, l[3] = $;
                      break;
                    case 3:
                      $ = D, Y = c + R / N, l[2] = Y, l[3] = $;
                      break;
                    case 4:
                      Y = T, $ = h + -L * N, l[2] = Y, l[3] = $;
                      break;
                  }
              }
              return !1;
            }, o.getCardinalDirection = function(s, u, l) {
              return s > u ? l : 1 + l % 4;
            }, o.getIntersection = function(s, u, l, f) {
              if (f == null)
                return this.getIntersection2(s, u, l);
              var v = s.x, c = s.y, h = u.x, d = u.y, g = l.x, p = l.y, y = f.x, b = f.y, m = void 0, E = void 0, C = void 0, S = void 0, w = void 0, x = void 0, T = void 0, D = void 0, A = void 0;
              return C = d - c, w = v - h, T = h * c - v * d, S = b - p, x = g - y, D = y * p - g * b, A = C * x - S * w, A === 0 ? null : (m = (w * D - x * T) / A, E = (S * T - C * D) / A, new i(m, E));
            }, o.angleOfVector = function(s, u, l, f) {
              var v = void 0;
              return s !== l ? (v = Math.atan((f - u) / (l - s)), l < s ? v += Math.PI : f < u && (v += this.TWO_PI)) : f < u ? v = this.ONE_AND_HALF_PI : v = this.HALF_PI, v;
            }, o.doIntersect = function(s, u, l, f) {
              var v = s.x, c = s.y, h = u.x, d = u.y, g = l.x, p = l.y, y = f.x, b = f.y, m = (h - v) * (b - p) - (y - g) * (d - c);
              if (m === 0)
                return !1;
              var E = ((b - p) * (y - v) + (g - y) * (b - c)) / m, C = ((c - d) * (y - v) + (h - v) * (b - c)) / m;
              return 0 < E && E < 1 && 0 < C && C < 1;
            }, o.HALF_PI = 0.5 * Math.PI, o.ONE_AND_HALF_PI = 1.5 * Math.PI, o.TWO_PI = 2 * Math.PI, o.THREE_PI = 3 * Math.PI, r.exports = o;
          }),
          /* 9 */
          /***/
          (function(r, a, n) {
            function i() {
            }
            i.sign = function(o) {
              return o > 0 ? 1 : o < 0 ? -1 : 0;
            }, i.floor = function(o) {
              return o < 0 ? Math.ceil(o) : Math.floor(o);
            }, i.ceil = function(o) {
              return o < 0 ? Math.floor(o) : Math.ceil(o);
            }, r.exports = i;
          }),
          /* 10 */
          /***/
          (function(r, a, n) {
            function i() {
            }
            i.MAX_VALUE = 2147483647, i.MIN_VALUE = -2147483648, r.exports = i;
          }),
          /* 11 */
          /***/
          (function(r, a, n) {
            var i = /* @__PURE__ */ (function() {
              function v(c, h) {
                for (var d = 0; d < h.length; d++) {
                  var g = h[d];
                  g.enumerable = g.enumerable || !1, g.configurable = !0, "value" in g && (g.writable = !0), Object.defineProperty(c, g.key, g);
                }
              }
              return function(c, h, d) {
                return h && v(c.prototype, h), d && v(c, d), c;
              };
            })();
            function o(v, c) {
              if (!(v instanceof c))
                throw new TypeError("Cannot call a class as a function");
            }
            var s = function(c) {
              return { value: c, next: null, prev: null };
            }, u = function(c, h, d, g) {
              return c !== null ? c.next = h : g.head = h, d !== null ? d.prev = h : g.tail = h, h.prev = c, h.next = d, g.length++, h;
            }, l = function(c, h) {
              var d = c.prev, g = c.next;
              return d !== null ? d.next = g : h.head = g, g !== null ? g.prev = d : h.tail = d, c.prev = c.next = null, h.length--, c;
            }, f = (function() {
              function v(c) {
                var h = this;
                o(this, v), this.length = 0, this.head = null, this.tail = null, c?.forEach(function(d) {
                  return h.push(d);
                });
              }
              return i(v, [{
                key: "size",
                value: function() {
                  return this.length;
                }
              }, {
                key: "insertBefore",
                value: function(h, d) {
                  return u(d.prev, s(h), d, this);
                }
              }, {
                key: "insertAfter",
                value: function(h, d) {
                  return u(d, s(h), d.next, this);
                }
              }, {
                key: "insertNodeBefore",
                value: function(h, d) {
                  return u(d.prev, h, d, this);
                }
              }, {
                key: "insertNodeAfter",
                value: function(h, d) {
                  return u(d, h, d.next, this);
                }
              }, {
                key: "push",
                value: function(h) {
                  return u(this.tail, s(h), null, this);
                }
              }, {
                key: "unshift",
                value: function(h) {
                  return u(null, s(h), this.head, this);
                }
              }, {
                key: "remove",
                value: function(h) {
                  return l(h, this);
                }
              }, {
                key: "pop",
                value: function() {
                  return l(this.tail, this).value;
                }
              }, {
                key: "popNode",
                value: function() {
                  return l(this.tail, this);
                }
              }, {
                key: "shift",
                value: function() {
                  return l(this.head, this).value;
                }
              }, {
                key: "shiftNode",
                value: function() {
                  return l(this.head, this);
                }
              }, {
                key: "get_object_at",
                value: function(h) {
                  if (h <= this.length()) {
                    for (var d = 1, g = this.head; d < h; )
                      g = g.next, d++;
                    return g.value;
                  }
                }
              }, {
                key: "set_object_at",
                value: function(h, d) {
                  if (h <= this.length()) {
                    for (var g = 1, p = this.head; g < h; )
                      p = p.next, g++;
                    p.value = d;
                  }
                }
              }]), v;
            })();
            r.exports = f;
          }),
          /* 12 */
          /***/
          (function(r, a, n) {
            function i(o, s, u) {
              this.x = null, this.y = null, o == null && s == null && u == null ? (this.x = 0, this.y = 0) : typeof o == "number" && typeof s == "number" && u == null ? (this.x = o, this.y = s) : o.constructor.name == "Point" && s == null && u == null && (u = o, this.x = u.x, this.y = u.y);
            }
            i.prototype.getX = function() {
              return this.x;
            }, i.prototype.getY = function() {
              return this.y;
            }, i.prototype.getLocation = function() {
              return new i(this.x, this.y);
            }, i.prototype.setLocation = function(o, s, u) {
              o.constructor.name == "Point" && s == null && u == null ? (u = o, this.setLocation(u.x, u.y)) : typeof o == "number" && typeof s == "number" && u == null && (parseInt(o) == o && parseInt(s) == s ? this.move(o, s) : (this.x = Math.floor(o + 0.5), this.y = Math.floor(s + 0.5)));
            }, i.prototype.move = function(o, s) {
              this.x = o, this.y = s;
            }, i.prototype.translate = function(o, s) {
              this.x += o, this.y += s;
            }, i.prototype.equals = function(o) {
              if (o.constructor.name == "Point") {
                var s = o;
                return this.x == s.x && this.y == s.y;
              }
              return this == o;
            }, i.prototype.toString = function() {
              return new i().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
            }, r.exports = i;
          }),
          /* 13 */
          /***/
          (function(r, a, n) {
            function i(o, s, u, l) {
              this.x = 0, this.y = 0, this.width = 0, this.height = 0, o != null && s != null && u != null && l != null && (this.x = o, this.y = s, this.width = u, this.height = l);
            }
            i.prototype.getX = function() {
              return this.x;
            }, i.prototype.setX = function(o) {
              this.x = o;
            }, i.prototype.getY = function() {
              return this.y;
            }, i.prototype.setY = function(o) {
              this.y = o;
            }, i.prototype.getWidth = function() {
              return this.width;
            }, i.prototype.setWidth = function(o) {
              this.width = o;
            }, i.prototype.getHeight = function() {
              return this.height;
            }, i.prototype.setHeight = function(o) {
              this.height = o;
            }, i.prototype.getRight = function() {
              return this.x + this.width;
            }, i.prototype.getBottom = function() {
              return this.y + this.height;
            }, i.prototype.intersects = function(o) {
              return !(this.getRight() < o.x || this.getBottom() < o.y || o.getRight() < this.x || o.getBottom() < this.y);
            }, i.prototype.getCenterX = function() {
              return this.x + this.width / 2;
            }, i.prototype.getMinX = function() {
              return this.getX();
            }, i.prototype.getMaxX = function() {
              return this.getX() + this.width;
            }, i.prototype.getCenterY = function() {
              return this.y + this.height / 2;
            }, i.prototype.getMinY = function() {
              return this.getY();
            }, i.prototype.getMaxY = function() {
              return this.getY() + this.height;
            }, i.prototype.getWidthHalf = function() {
              return this.width / 2;
            }, i.prototype.getHeightHalf = function() {
              return this.height / 2;
            }, r.exports = i;
          }),
          /* 14 */
          /***/
          (function(r, a, n) {
            var i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(s) {
              return typeof s;
            } : function(s) {
              return s && typeof Symbol == "function" && s.constructor === Symbol && s !== Symbol.prototype ? "symbol" : typeof s;
            };
            function o() {
            }
            o.lastID = 0, o.createID = function(s) {
              return o.isPrimitive(s) ? s : (s.uniqueID != null || (s.uniqueID = o.getString(), o.lastID++), s.uniqueID);
            }, o.getString = function(s) {
              return s == null && (s = o.lastID), "Object#" + s;
            }, o.isPrimitive = function(s) {
              var u = typeof s > "u" ? "undefined" : i(s);
              return s == null || u != "object" && u != "function";
            }, r.exports = o;
          }),
          /* 15 */
          /***/
          (function(r, a, n) {
            function i(g) {
              if (Array.isArray(g)) {
                for (var p = 0, y = Array(g.length); p < g.length; p++)
                  y[p] = g[p];
                return y;
              } else
                return Array.from(g);
            }
            var o = n(0), s = n(6), u = n(3), l = n(1), f = n(5), v = n(4), c = n(17), h = n(27);
            function d(g) {
              h.call(this), this.layoutQuality = o.QUALITY, this.createBendsAsNeeded = o.DEFAULT_CREATE_BENDS_AS_NEEDED, this.incremental = o.DEFAULT_INCREMENTAL, this.animationOnLayout = o.DEFAULT_ANIMATION_ON_LAYOUT, this.animationDuringLayout = o.DEFAULT_ANIMATION_DURING_LAYOUT, this.animationPeriod = o.DEFAULT_ANIMATION_PERIOD, this.uniformLeafNodeSizes = o.DEFAULT_UNIFORM_LEAF_NODE_SIZES, this.edgeToDummyNodes = /* @__PURE__ */ new Map(), this.graphManager = new s(this), this.isLayoutFinished = !1, this.isSubLayout = !1, this.isRemoteUse = !1, g != null && (this.isRemoteUse = g);
            }
            d.RANDOM_SEED = 1, d.prototype = Object.create(h.prototype), d.prototype.getGraphManager = function() {
              return this.graphManager;
            }, d.prototype.getAllNodes = function() {
              return this.graphManager.getAllNodes();
            }, d.prototype.getAllEdges = function() {
              return this.graphManager.getAllEdges();
            }, d.prototype.getAllNodesToApplyGravitation = function() {
              return this.graphManager.getAllNodesToApplyGravitation();
            }, d.prototype.newGraphManager = function() {
              var g = new s(this);
              return this.graphManager = g, g;
            }, d.prototype.newGraph = function(g) {
              return new f(null, this.graphManager, g);
            }, d.prototype.newNode = function(g) {
              return new u(this.graphManager, g);
            }, d.prototype.newEdge = function(g) {
              return new l(null, null, g);
            }, d.prototype.checkLayoutSuccess = function() {
              return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge();
            }, d.prototype.runLayout = function() {
              this.isLayoutFinished = !1, this.tilingPreLayout && this.tilingPreLayout(), this.initParameters();
              var g;
              return this.checkLayoutSuccess() ? g = !1 : g = this.layout(), o.ANIMATE === "during" ? !1 : (g && (this.isSubLayout || this.doPostLayout()), this.tilingPostLayout && this.tilingPostLayout(), this.isLayoutFinished = !0, g);
            }, d.prototype.doPostLayout = function() {
              this.incremental || this.transform(), this.update();
            }, d.prototype.update2 = function() {
              if (this.createBendsAsNeeded && (this.createBendpointsFromDummyNodes(), this.graphManager.resetAllEdges()), !this.isRemoteUse) {
                for (var g = this.graphManager.getAllEdges(), p = 0; p < g.length; p++)
                  g[p];
                for (var y = this.graphManager.getRoot().getNodes(), p = 0; p < y.length; p++)
                  y[p];
                this.update(this.graphManager.getRoot());
              }
            }, d.prototype.update = function(g) {
              if (g == null)
                this.update2();
              else if (g instanceof u) {
                var p = g;
                if (p.getChild() != null)
                  for (var y = p.getChild().getNodes(), b = 0; b < y.length; b++)
                    update(y[b]);
                if (p.vGraphObject != null) {
                  var m = p.vGraphObject;
                  m.update(p);
                }
              } else if (g instanceof l) {
                var E = g;
                if (E.vGraphObject != null) {
                  var C = E.vGraphObject;
                  C.update(E);
                }
              } else if (g instanceof f) {
                var S = g;
                if (S.vGraphObject != null) {
                  var w = S.vGraphObject;
                  w.update(S);
                }
              }
            }, d.prototype.initParameters = function() {
              this.isSubLayout || (this.layoutQuality = o.QUALITY, this.animationDuringLayout = o.DEFAULT_ANIMATION_DURING_LAYOUT, this.animationPeriod = o.DEFAULT_ANIMATION_PERIOD, this.animationOnLayout = o.DEFAULT_ANIMATION_ON_LAYOUT, this.incremental = o.DEFAULT_INCREMENTAL, this.createBendsAsNeeded = o.DEFAULT_CREATE_BENDS_AS_NEEDED, this.uniformLeafNodeSizes = o.DEFAULT_UNIFORM_LEAF_NODE_SIZES), this.animationDuringLayout && (this.animationOnLayout = !1);
            }, d.prototype.transform = function(g) {
              if (g == null)
                this.transform(new v(0, 0));
              else {
                var p = new c(), y = this.graphManager.getRoot().updateLeftTop();
                if (y != null) {
                  p.setWorldOrgX(g.x), p.setWorldOrgY(g.y), p.setDeviceOrgX(y.x), p.setDeviceOrgY(y.y);
                  for (var b = this.getAllNodes(), m, E = 0; E < b.length; E++)
                    m = b[E], m.transform(p);
                }
              }
            }, d.prototype.positionNodesRandomly = function(g) {
              if (g == null)
                this.positionNodesRandomly(this.getGraphManager().getRoot()), this.getGraphManager().getRoot().updateBounds(!0);
              else
                for (var p, y, b = g.getNodes(), m = 0; m < b.length; m++)
                  p = b[m], y = p.getChild(), y == null || y.getNodes().length == 0 ? p.scatter() : (this.positionNodesRandomly(y), p.updateBounds());
            }, d.prototype.getFlatForest = function() {
              for (var g = [], p = !0, y = this.graphManager.getRoot().getNodes(), b = !0, m = 0; m < y.length; m++)
                y[m].getChild() != null && (b = !1);
              if (!b)
                return g;
              var E = /* @__PURE__ */ new Set(), C = [], S = /* @__PURE__ */ new Map(), w = [];
              for (w = w.concat(y); w.length > 0 && p; ) {
                for (C.push(w[0]); C.length > 0 && p; ) {
                  var x = C[0];
                  C.splice(0, 1), E.add(x);
                  for (var T = x.getEdges(), m = 0; m < T.length; m++) {
                    var D = T[m].getOtherEnd(x);
                    if (S.get(x) != D)
                      if (!E.has(D))
                        C.push(D), S.set(D, x);
                      else {
                        p = !1;
                        break;
                      }
                  }
                }
                if (!p)
                  g = [];
                else {
                  var A = [].concat(i(E));
                  g.push(A);
                  for (var m = 0; m < A.length; m++) {
                    var L = A[m], R = w.indexOf(L);
                    R > -1 && w.splice(R, 1);
                  }
                  E = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Map();
                }
              }
              return g;
            }, d.prototype.createDummyNodesForBendpoints = function(g) {
              for (var p = [], y = g.source, b = this.graphManager.calcLowestCommonAncestor(g.source, g.target), m = 0; m < g.bendpoints.length; m++) {
                var E = this.newNode(null);
                E.setRect(new Point(0, 0), new Dimension(1, 1)), b.add(E);
                var C = this.newEdge(null);
                this.graphManager.add(C, y, E), p.add(E), y = E;
              }
              var C = this.newEdge(null);
              return this.graphManager.add(C, y, g.target), this.edgeToDummyNodes.set(g, p), g.isInterGraph() ? this.graphManager.remove(g) : b.remove(g), p;
            }, d.prototype.createBendpointsFromDummyNodes = function() {
              var g = [];
              g = g.concat(this.graphManager.getAllEdges()), g = [].concat(i(this.edgeToDummyNodes.keys())).concat(g);
              for (var p = 0; p < g.length; p++) {
                var y = g[p];
                if (y.bendpoints.length > 0) {
                  for (var b = this.edgeToDummyNodes.get(y), m = 0; m < b.length; m++) {
                    var E = b[m], C = new v(E.getCenterX(), E.getCenterY()), S = y.bendpoints.get(m);
                    S.x = C.x, S.y = C.y, E.getOwner().remove(E);
                  }
                  this.graphManager.add(y, y.source, y.target);
                }
              }
            }, d.transform = function(g, p, y, b) {
              if (y != null && b != null) {
                var m = p;
                if (g <= 50) {
                  var E = p / y;
                  m -= (p - E) / 50 * (50 - g);
                } else {
                  var C = p * b;
                  m += (C - p) / 50 * (g - 50);
                }
                return m;
              } else {
                var S, w;
                return g <= 50 ? (S = 9 * p / 500, w = p / 10) : (S = 9 * p / 50, w = -8 * p), S * g + w;
              }
            }, d.findCenterOfTree = function(g) {
              var p = [];
              p = p.concat(g);
              var y = [], b = /* @__PURE__ */ new Map(), m = !1, E = null;
              (p.length == 1 || p.length == 2) && (m = !0, E = p[0]);
              for (var C = 0; C < p.length; C++) {
                var S = p[C], w = S.getNeighborsList().size;
                b.set(S, S.getNeighborsList().size), w == 1 && y.push(S);
              }
              var x = [];
              for (x = x.concat(y); !m; ) {
                var T = [];
                T = T.concat(x), x = [];
                for (var C = 0; C < p.length; C++) {
                  var S = p[C], D = p.indexOf(S);
                  D >= 0 && p.splice(D, 1);
                  var A = S.getNeighborsList();
                  A.forEach(function(P) {
                    if (y.indexOf(P) < 0) {
                      var I = b.get(P), k = I - 1;
                      k == 1 && x.push(P), b.set(P, k);
                    }
                  });
                }
                y = y.concat(x), (p.length == 1 || p.length == 2) && (m = !0, E = p[0]);
              }
              return E;
            }, d.prototype.setGraphManager = function(g) {
              this.graphManager = g;
            }, r.exports = d;
          }),
          /* 16 */
          /***/
          (function(r, a, n) {
            function i() {
            }
            i.seed = 1, i.x = 0, i.nextDouble = function() {
              return i.x = Math.sin(i.seed++) * 1e4, i.x - Math.floor(i.x);
            }, r.exports = i;
          }),
          /* 17 */
          /***/
          (function(r, a, n) {
            var i = n(4);
            function o(s, u) {
              this.lworldOrgX = 0, this.lworldOrgY = 0, this.ldeviceOrgX = 0, this.ldeviceOrgY = 0, this.lworldExtX = 1, this.lworldExtY = 1, this.ldeviceExtX = 1, this.ldeviceExtY = 1;
            }
            o.prototype.getWorldOrgX = function() {
              return this.lworldOrgX;
            }, o.prototype.setWorldOrgX = function(s) {
              this.lworldOrgX = s;
            }, o.prototype.getWorldOrgY = function() {
              return this.lworldOrgY;
            }, o.prototype.setWorldOrgY = function(s) {
              this.lworldOrgY = s;
            }, o.prototype.getWorldExtX = function() {
              return this.lworldExtX;
            }, o.prototype.setWorldExtX = function(s) {
              this.lworldExtX = s;
            }, o.prototype.getWorldExtY = function() {
              return this.lworldExtY;
            }, o.prototype.setWorldExtY = function(s) {
              this.lworldExtY = s;
            }, o.prototype.getDeviceOrgX = function() {
              return this.ldeviceOrgX;
            }, o.prototype.setDeviceOrgX = function(s) {
              this.ldeviceOrgX = s;
            }, o.prototype.getDeviceOrgY = function() {
              return this.ldeviceOrgY;
            }, o.prototype.setDeviceOrgY = function(s) {
              this.ldeviceOrgY = s;
            }, o.prototype.getDeviceExtX = function() {
              return this.ldeviceExtX;
            }, o.prototype.setDeviceExtX = function(s) {
              this.ldeviceExtX = s;
            }, o.prototype.getDeviceExtY = function() {
              return this.ldeviceExtY;
            }, o.prototype.setDeviceExtY = function(s) {
              this.ldeviceExtY = s;
            }, o.prototype.transformX = function(s) {
              var u = 0, l = this.lworldExtX;
              return l != 0 && (u = this.ldeviceOrgX + (s - this.lworldOrgX) * this.ldeviceExtX / l), u;
            }, o.prototype.transformY = function(s) {
              var u = 0, l = this.lworldExtY;
              return l != 0 && (u = this.ldeviceOrgY + (s - this.lworldOrgY) * this.ldeviceExtY / l), u;
            }, o.prototype.inverseTransformX = function(s) {
              var u = 0, l = this.ldeviceExtX;
              return l != 0 && (u = this.lworldOrgX + (s - this.ldeviceOrgX) * this.lworldExtX / l), u;
            }, o.prototype.inverseTransformY = function(s) {
              var u = 0, l = this.ldeviceExtY;
              return l != 0 && (u = this.lworldOrgY + (s - this.ldeviceOrgY) * this.lworldExtY / l), u;
            }, o.prototype.inverseTransformPoint = function(s) {
              var u = new i(this.inverseTransformX(s.x), this.inverseTransformY(s.y));
              return u;
            }, r.exports = o;
          }),
          /* 18 */
          /***/
          (function(r, a, n) {
            function i(h) {
              if (Array.isArray(h)) {
                for (var d = 0, g = Array(h.length); d < h.length; d++)
                  g[d] = h[d];
                return g;
              } else
                return Array.from(h);
            }
            var o = n(15), s = n(7), u = n(0), l = n(8), f = n(9);
            function v() {
              o.call(this), this.useSmartIdealEdgeLengthCalculation = s.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.idealEdgeLength = s.DEFAULT_EDGE_LENGTH, this.springConstant = s.DEFAULT_SPRING_STRENGTH, this.repulsionConstant = s.DEFAULT_REPULSION_STRENGTH, this.gravityConstant = s.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = s.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = s.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = s.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.displacementThresholdPerNode = 3 * s.DEFAULT_EDGE_LENGTH / 100, this.coolingFactor = s.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.initialCoolingFactor = s.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.totalDisplacement = 0, this.oldTotalDisplacement = 0, this.maxIterations = s.MAX_ITERATIONS;
            }
            v.prototype = Object.create(o.prototype);
            for (var c in o)
              v[c] = o[c];
            v.prototype.initParameters = function() {
              o.prototype.initParameters.call(this, arguments), this.totalIterations = 0, this.notAnimatedIterations = 0, this.useFRGridVariant = s.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION, this.grid = [];
            }, v.prototype.calcIdealEdgeLengths = function() {
              for (var h, d, g, p, y, b, m = this.getGraphManager().getAllEdges(), E = 0; E < m.length; E++)
                h = m[E], h.idealLength = this.idealEdgeLength, h.isInterGraph && (g = h.getSource(), p = h.getTarget(), y = h.getSourceInLca().getEstimatedSize(), b = h.getTargetInLca().getEstimatedSize(), this.useSmartIdealEdgeLengthCalculation && (h.idealLength += y + b - 2 * u.SIMPLE_NODE_SIZE), d = h.getLca().getInclusionTreeDepth(), h.idealLength += s.DEFAULT_EDGE_LENGTH * s.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (g.getInclusionTreeDepth() + p.getInclusionTreeDepth() - 2 * d));
            }, v.prototype.initSpringEmbedder = function() {
              var h = this.getAllNodes().length;
              this.incremental ? (h > s.ADAPTATION_LOWER_NODE_LIMIT && (this.coolingFactor = Math.max(this.coolingFactor * s.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (h - s.ADAPTATION_LOWER_NODE_LIMIT) / (s.ADAPTATION_UPPER_NODE_LIMIT - s.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - s.COOLING_ADAPTATION_FACTOR))), this.maxNodeDisplacement = s.MAX_NODE_DISPLACEMENT_INCREMENTAL) : (h > s.ADAPTATION_LOWER_NODE_LIMIT ? this.coolingFactor = Math.max(s.COOLING_ADAPTATION_FACTOR, 1 - (h - s.ADAPTATION_LOWER_NODE_LIMIT) / (s.ADAPTATION_UPPER_NODE_LIMIT - s.ADAPTATION_LOWER_NODE_LIMIT) * (1 - s.COOLING_ADAPTATION_FACTOR)) : this.coolingFactor = 1, this.initialCoolingFactor = this.coolingFactor, this.maxNodeDisplacement = s.MAX_NODE_DISPLACEMENT), this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations), this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length, this.repulsionRange = this.calcRepulsionRange();
            }, v.prototype.calcSpringForces = function() {
              for (var h = this.getAllEdges(), d, g = 0; g < h.length; g++)
                d = h[g], this.calcSpringForce(d, d.idealLength);
            }, v.prototype.calcRepulsionForces = function() {
              var h = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, g, p, y, b, m = this.getAllNodes(), E;
              if (this.useFRGridVariant)
                for (this.totalIterations % s.GRID_CALCULATION_CHECK_PERIOD == 1 && h && this.updateGrid(), E = /* @__PURE__ */ new Set(), g = 0; g < m.length; g++)
                  y = m[g], this.calculateRepulsionForceOfANode(y, E, h, d), E.add(y);
              else
                for (g = 0; g < m.length; g++)
                  for (y = m[g], p = g + 1; p < m.length; p++)
                    b = m[p], y.getOwner() == b.getOwner() && this.calcRepulsionForce(y, b);
            }, v.prototype.calcGravitationalForces = function() {
              for (var h, d = this.getAllNodesToApplyGravitation(), g = 0; g < d.length; g++)
                h = d[g], this.calcGravitationalForce(h);
            }, v.prototype.moveNodes = function() {
              for (var h = this.getAllNodes(), d, g = 0; g < h.length; g++)
                d = h[g], d.move();
            }, v.prototype.calcSpringForce = function(h, d) {
              var g = h.getSource(), p = h.getTarget(), y, b, m, E;
              if (this.uniformLeafNodeSizes && g.getChild() == null && p.getChild() == null)
                h.updateLengthSimple();
              else if (h.updateLength(), h.isOverlapingSourceAndTarget)
                return;
              y = h.getLength(), y != 0 && (b = this.springConstant * (y - d), m = b * (h.lengthX / y), E = b * (h.lengthY / y), g.springForceX += m, g.springForceY += E, p.springForceX -= m, p.springForceY -= E);
            }, v.prototype.calcRepulsionForce = function(h, d) {
              var g = h.getRect(), p = d.getRect(), y = new Array(2), b = new Array(4), m, E, C, S, w, x, T;
              if (g.intersects(p)) {
                l.calcSeparationAmount(g, p, y, s.DEFAULT_EDGE_LENGTH / 2), x = 2 * y[0], T = 2 * y[1];
                var D = h.noOfChildren * d.noOfChildren / (h.noOfChildren + d.noOfChildren);
                h.repulsionForceX -= D * x, h.repulsionForceY -= D * T, d.repulsionForceX += D * x, d.repulsionForceY += D * T;
              } else
                this.uniformLeafNodeSizes && h.getChild() == null && d.getChild() == null ? (m = p.getCenterX() - g.getCenterX(), E = p.getCenterY() - g.getCenterY()) : (l.getIntersection(g, p, b), m = b[2] - b[0], E = b[3] - b[1]), Math.abs(m) < s.MIN_REPULSION_DIST && (m = f.sign(m) * s.MIN_REPULSION_DIST), Math.abs(E) < s.MIN_REPULSION_DIST && (E = f.sign(E) * s.MIN_REPULSION_DIST), C = m * m + E * E, S = Math.sqrt(C), w = this.repulsionConstant * h.noOfChildren * d.noOfChildren / C, x = w * m / S, T = w * E / S, h.repulsionForceX -= x, h.repulsionForceY -= T, d.repulsionForceX += x, d.repulsionForceY += T;
            }, v.prototype.calcGravitationalForce = function(h) {
              var d, g, p, y, b, m, E, C;
              d = h.getOwner(), g = (d.getRight() + d.getLeft()) / 2, p = (d.getTop() + d.getBottom()) / 2, y = h.getCenterX() - g, b = h.getCenterY() - p, m = Math.abs(y) + h.getWidth() / 2, E = Math.abs(b) + h.getHeight() / 2, h.getOwner() == this.graphManager.getRoot() ? (C = d.getEstimatedSize() * this.gravityRangeFactor, (m > C || E > C) && (h.gravitationForceX = -this.gravityConstant * y, h.gravitationForceY = -this.gravityConstant * b)) : (C = d.getEstimatedSize() * this.compoundGravityRangeFactor, (m > C || E > C) && (h.gravitationForceX = -this.gravityConstant * y * this.compoundGravityConstant, h.gravitationForceY = -this.gravityConstant * b * this.compoundGravityConstant));
            }, v.prototype.isConverged = function() {
              var h, d = !1;
              return this.totalIterations > this.maxIterations / 3 && (d = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2), h = this.totalDisplacement < this.totalDisplacementThreshold, this.oldTotalDisplacement = this.totalDisplacement, h || d;
            }, v.prototype.animate = function() {
              this.animationDuringLayout && !this.isSubLayout && (this.notAnimatedIterations == this.animationPeriod ? (this.update(), this.notAnimatedIterations = 0) : this.notAnimatedIterations++);
            }, v.prototype.calcNoOfChildrenForAllNodes = function() {
              for (var h, d = this.graphManager.getAllNodes(), g = 0; g < d.length; g++)
                h = d[g], h.noOfChildren = h.getNoOfChildren();
            }, v.prototype.calcGrid = function(h) {
              var d = 0, g = 0;
              d = parseInt(Math.ceil((h.getRight() - h.getLeft()) / this.repulsionRange)), g = parseInt(Math.ceil((h.getBottom() - h.getTop()) / this.repulsionRange));
              for (var p = new Array(d), y = 0; y < d; y++)
                p[y] = new Array(g);
              for (var y = 0; y < d; y++)
                for (var b = 0; b < g; b++)
                  p[y][b] = new Array();
              return p;
            }, v.prototype.addNodeToGrid = function(h, d, g) {
              var p = 0, y = 0, b = 0, m = 0;
              p = parseInt(Math.floor((h.getRect().x - d) / this.repulsionRange)), y = parseInt(Math.floor((h.getRect().width + h.getRect().x - d) / this.repulsionRange)), b = parseInt(Math.floor((h.getRect().y - g) / this.repulsionRange)), m = parseInt(Math.floor((h.getRect().height + h.getRect().y - g) / this.repulsionRange));
              for (var E = p; E <= y; E++)
                for (var C = b; C <= m; C++)
                  this.grid[E][C].push(h), h.setGridCoordinates(p, y, b, m);
            }, v.prototype.updateGrid = function() {
              var h, d, g = this.getAllNodes();
              for (this.grid = this.calcGrid(this.graphManager.getRoot()), h = 0; h < g.length; h++)
                d = g[h], this.addNodeToGrid(d, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
            }, v.prototype.calculateRepulsionForceOfANode = function(h, d, g, p) {
              if (this.totalIterations % s.GRID_CALCULATION_CHECK_PERIOD == 1 && g || p) {
                var y = /* @__PURE__ */ new Set();
                h.surrounding = new Array();
                for (var b, m = this.grid, E = h.startX - 1; E < h.finishX + 2; E++)
                  for (var C = h.startY - 1; C < h.finishY + 2; C++)
                    if (!(E < 0 || C < 0 || E >= m.length || C >= m[0].length)) {
                      for (var S = 0; S < m[E][C].length; S++)
                        if (b = m[E][C][S], !(h.getOwner() != b.getOwner() || h == b) && !d.has(b) && !y.has(b)) {
                          var w = Math.abs(h.getCenterX() - b.getCenterX()) - (h.getWidth() / 2 + b.getWidth() / 2), x = Math.abs(h.getCenterY() - b.getCenterY()) - (h.getHeight() / 2 + b.getHeight() / 2);
                          w <= this.repulsionRange && x <= this.repulsionRange && y.add(b);
                        }
                    }
                h.surrounding = [].concat(i(y));
              }
              for (E = 0; E < h.surrounding.length; E++)
                this.calcRepulsionForce(h, h.surrounding[E]);
            }, v.prototype.calcRepulsionRange = function() {
              return 0;
            }, r.exports = v;
          }),
          /* 19 */
          /***/
          (function(r, a, n) {
            var i = n(1), o = n(7);
            function s(l, f, v) {
              i.call(this, l, f, v), this.idealLength = o.DEFAULT_EDGE_LENGTH;
            }
            s.prototype = Object.create(i.prototype);
            for (var u in i)
              s[u] = i[u];
            r.exports = s;
          }),
          /* 20 */
          /***/
          (function(r, a, n) {
            var i = n(3);
            function o(u, l, f, v) {
              i.call(this, u, l, f, v), this.springForceX = 0, this.springForceY = 0, this.repulsionForceX = 0, this.repulsionForceY = 0, this.gravitationForceX = 0, this.gravitationForceY = 0, this.displacementX = 0, this.displacementY = 0, this.startX = 0, this.finishX = 0, this.startY = 0, this.finishY = 0, this.surrounding = [];
            }
            o.prototype = Object.create(i.prototype);
            for (var s in i)
              o[s] = i[s];
            o.prototype.setGridCoordinates = function(u, l, f, v) {
              this.startX = u, this.finishX = l, this.startY = f, this.finishY = v;
            }, r.exports = o;
          }),
          /* 21 */
          /***/
          (function(r, a, n) {
            function i(o, s) {
              this.width = 0, this.height = 0, o !== null && s !== null && (this.height = s, this.width = o);
            }
            i.prototype.getWidth = function() {
              return this.width;
            }, i.prototype.setWidth = function(o) {
              this.width = o;
            }, i.prototype.getHeight = function() {
              return this.height;
            }, i.prototype.setHeight = function(o) {
              this.height = o;
            }, r.exports = i;
          }),
          /* 22 */
          /***/
          (function(r, a, n) {
            var i = n(14);
            function o() {
              this.map = {}, this.keys = [];
            }
            o.prototype.put = function(s, u) {
              var l = i.createID(s);
              this.contains(l) || (this.map[l] = u, this.keys.push(s));
            }, o.prototype.contains = function(s) {
              return i.createID(s), this.map[s] != null;
            }, o.prototype.get = function(s) {
              var u = i.createID(s);
              return this.map[u];
            }, o.prototype.keySet = function() {
              return this.keys;
            }, r.exports = o;
          }),
          /* 23 */
          /***/
          (function(r, a, n) {
            var i = n(14);
            function o() {
              this.set = {};
            }
            o.prototype.add = function(s) {
              var u = i.createID(s);
              this.contains(u) || (this.set[u] = s);
            }, o.prototype.remove = function(s) {
              delete this.set[i.createID(s)];
            }, o.prototype.clear = function() {
              this.set = {};
            }, o.prototype.contains = function(s) {
              return this.set[i.createID(s)] == s;
            }, o.prototype.isEmpty = function() {
              return this.size() === 0;
            }, o.prototype.size = function() {
              return Object.keys(this.set).length;
            }, o.prototype.addAllTo = function(s) {
              for (var u = Object.keys(this.set), l = u.length, f = 0; f < l; f++)
                s.push(this.set[u[f]]);
            }, o.prototype.size = function() {
              return Object.keys(this.set).length;
            }, o.prototype.addAll = function(s) {
              for (var u = s.length, l = 0; l < u; l++) {
                var f = s[l];
                this.add(f);
              }
            }, r.exports = o;
          }),
          /* 24 */
          /***/
          (function(r, a, n) {
            var i = /* @__PURE__ */ (function() {
              function l(f, v) {
                for (var c = 0; c < v.length; c++) {
                  var h = v[c];
                  h.enumerable = h.enumerable || !1, h.configurable = !0, "value" in h && (h.writable = !0), Object.defineProperty(f, h.key, h);
                }
              }
              return function(f, v, c) {
                return v && l(f.prototype, v), c && l(f, c), f;
              };
            })();
            function o(l, f) {
              if (!(l instanceof f))
                throw new TypeError("Cannot call a class as a function");
            }
            var s = n(11), u = (function() {
              function l(f, v) {
                o(this, l), (v !== null || v !== void 0) && (this.compareFunction = this._defaultCompareFunction);
                var c = void 0;
                f instanceof s ? c = f.size() : c = f.length, this._quicksort(f, 0, c - 1);
              }
              return i(l, [{
                key: "_quicksort",
                value: function(v, c, h) {
                  if (c < h) {
                    var d = this._partition(v, c, h);
                    this._quicksort(v, c, d), this._quicksort(v, d + 1, h);
                  }
                }
              }, {
                key: "_partition",
                value: function(v, c, h) {
                  for (var d = this._get(v, c), g = c, p = h; ; ) {
                    for (; this.compareFunction(d, this._get(v, p)); )
                      p--;
                    for (; this.compareFunction(this._get(v, g), d); )
                      g++;
                    if (g < p)
                      this._swap(v, g, p), g++, p--;
                    else return p;
                  }
                }
              }, {
                key: "_get",
                value: function(v, c) {
                  return v instanceof s ? v.get_object_at(c) : v[c];
                }
              }, {
                key: "_set",
                value: function(v, c, h) {
                  v instanceof s ? v.set_object_at(c, h) : v[c] = h;
                }
              }, {
                key: "_swap",
                value: function(v, c, h) {
                  var d = this._get(v, c);
                  this._set(v, c, this._get(v, h)), this._set(v, h, d);
                }
              }, {
                key: "_defaultCompareFunction",
                value: function(v, c) {
                  return c > v;
                }
              }]), l;
            })();
            r.exports = u;
          }),
          /* 25 */
          /***/
          (function(r, a, n) {
            var i = /* @__PURE__ */ (function() {
              function u(l, f) {
                for (var v = 0; v < f.length; v++) {
                  var c = f[v];
                  c.enumerable = c.enumerable || !1, c.configurable = !0, "value" in c && (c.writable = !0), Object.defineProperty(l, c.key, c);
                }
              }
              return function(l, f, v) {
                return f && u(l.prototype, f), v && u(l, v), l;
              };
            })();
            function o(u, l) {
              if (!(u instanceof l))
                throw new TypeError("Cannot call a class as a function");
            }
            var s = (function() {
              function u(l, f) {
                var v = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1, c = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : -1, h = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
                o(this, u), this.sequence1 = l, this.sequence2 = f, this.match_score = v, this.mismatch_penalty = c, this.gap_penalty = h, this.iMax = l.length + 1, this.jMax = f.length + 1, this.grid = new Array(this.iMax);
                for (var d = 0; d < this.iMax; d++) {
                  this.grid[d] = new Array(this.jMax);
                  for (var g = 0; g < this.jMax; g++)
                    this.grid[d][g] = 0;
                }
                this.tracebackGrid = new Array(this.iMax);
                for (var p = 0; p < this.iMax; p++) {
                  this.tracebackGrid[p] = new Array(this.jMax);
                  for (var y = 0; y < this.jMax; y++)
                    this.tracebackGrid[p][y] = [null, null, null];
                }
                this.alignments = [], this.score = -1, this.computeGrids();
              }
              return i(u, [{
                key: "getScore",
                value: function() {
                  return this.score;
                }
              }, {
                key: "getAlignments",
                value: function() {
                  return this.alignments;
                }
                // Main dynamic programming procedure
              }, {
                key: "computeGrids",
                value: function() {
                  for (var f = 1; f < this.jMax; f++)
                    this.grid[0][f] = this.grid[0][f - 1] + this.gap_penalty, this.tracebackGrid[0][f] = [!1, !1, !0];
                  for (var v = 1; v < this.iMax; v++)
                    this.grid[v][0] = this.grid[v - 1][0] + this.gap_penalty, this.tracebackGrid[v][0] = [!1, !0, !1];
                  for (var c = 1; c < this.iMax; c++)
                    for (var h = 1; h < this.jMax; h++) {
                      var d = void 0;
                      this.sequence1[c - 1] === this.sequence2[h - 1] ? d = this.grid[c - 1][h - 1] + this.match_score : d = this.grid[c - 1][h - 1] + this.mismatch_penalty;
                      var g = this.grid[c - 1][h] + this.gap_penalty, p = this.grid[c][h - 1] + this.gap_penalty, y = [d, g, p], b = this.arrayAllMaxIndexes(y);
                      this.grid[c][h] = y[b[0]], this.tracebackGrid[c][h] = [b.includes(0), b.includes(1), b.includes(2)];
                    }
                  this.score = this.grid[this.iMax - 1][this.jMax - 1];
                }
                // Gets all possible valid sequence combinations
              }, {
                key: "alignmentTraceback",
                value: function() {
                  var f = [];
                  for (f.push({
                    pos: [this.sequence1.length, this.sequence2.length],
                    seq1: "",
                    seq2: ""
                  }); f[0]; ) {
                    var v = f[0], c = this.tracebackGrid[v.pos[0]][v.pos[1]];
                    c[0] && f.push({
                      pos: [v.pos[0] - 1, v.pos[1] - 1],
                      seq1: this.sequence1[v.pos[0] - 1] + v.seq1,
                      seq2: this.sequence2[v.pos[1] - 1] + v.seq2
                    }), c[1] && f.push({
                      pos: [v.pos[0] - 1, v.pos[1]],
                      seq1: this.sequence1[v.pos[0] - 1] + v.seq1,
                      seq2: "-" + v.seq2
                    }), c[2] && f.push({
                      pos: [v.pos[0], v.pos[1] - 1],
                      seq1: "-" + v.seq1,
                      seq2: this.sequence2[v.pos[1] - 1] + v.seq2
                    }), v.pos[0] === 0 && v.pos[1] === 0 && this.alignments.push({
                      sequence1: v.seq1,
                      sequence2: v.seq2
                    }), f.shift();
                  }
                  return this.alignments;
                }
                // Helper Functions
              }, {
                key: "getAllIndexes",
                value: function(f, v) {
                  for (var c = [], h = -1; (h = f.indexOf(v, h + 1)) !== -1; )
                    c.push(h);
                  return c;
                }
              }, {
                key: "arrayAllMaxIndexes",
                value: function(f) {
                  return this.getAllIndexes(f, Math.max.apply(null, f));
                }
              }]), u;
            })();
            r.exports = s;
          }),
          /* 26 */
          /***/
          (function(r, a, n) {
            var i = function() {
            };
            i.FDLayout = n(18), i.FDLayoutConstants = n(7), i.FDLayoutEdge = n(19), i.FDLayoutNode = n(20), i.DimensionD = n(21), i.HashMap = n(22), i.HashSet = n(23), i.IGeometry = n(8), i.IMath = n(9), i.Integer = n(10), i.Point = n(12), i.PointD = n(4), i.RandomSeed = n(16), i.RectangleD = n(13), i.Transform = n(17), i.UniqueIDGeneretor = n(14), i.Quicksort = n(24), i.LinkedList = n(11), i.LGraphObject = n(2), i.LGraph = n(5), i.LEdge = n(1), i.LGraphManager = n(6), i.LNode = n(3), i.Layout = n(15), i.LayoutConstants = n(0), i.NeedlemanWunsch = n(25), r.exports = i;
          }),
          /* 27 */
          /***/
          (function(r, a, n) {
            function i() {
              this.listeners = [];
            }
            var o = i.prototype;
            o.addListener = function(s, u) {
              this.listeners.push({
                event: s,
                callback: u
              });
            }, o.removeListener = function(s, u) {
              for (var l = this.listeners.length; l >= 0; l--) {
                var f = this.listeners[l];
                f.event === s && f.callback === u && this.listeners.splice(l, 1);
              }
            }, o.emit = function(s, u) {
              for (var l = 0; l < this.listeners.length; l++) {
                var f = this.listeners[l];
                s === f.event && f.callback(u);
              }
            }, r.exports = i;
          })
          /******/
        ])
      );
    });
  })(wn)), wn.exports;
}
var qm = bn.exports, rf;
function Ym() {
  return rf || (rf = 1, (function(t, e) {
    (function(a, n) {
      t.exports = n(Um());
    })(qm, function(r) {
      return (
        /******/
        (function(a) {
          var n = {};
          function i(o) {
            if (n[o])
              return n[o].exports;
            var s = n[o] = {
              /******/
              i: o,
              /******/
              l: !1,
              /******/
              exports: {}
              /******/
            };
            return a[o].call(s.exports, s, s.exports, i), s.l = !0, s.exports;
          }
          return i.m = a, i.c = n, i.i = function(o) {
            return o;
          }, i.d = function(o, s, u) {
            i.o(o, s) || Object.defineProperty(o, s, {
              /******/
              configurable: !1,
              /******/
              enumerable: !0,
              /******/
              get: u
              /******/
            });
          }, i.n = function(o) {
            var s = o && o.__esModule ? (
              /******/
              function() {
                return o.default;
              }
            ) : (
              /******/
              function() {
                return o;
              }
            );
            return i.d(s, "a", s), s;
          }, i.o = function(o, s) {
            return Object.prototype.hasOwnProperty.call(o, s);
          }, i.p = "", i(i.s = 7);
        })([
          /* 0 */
          /***/
          (function(a, n) {
            a.exports = r;
          }),
          /* 1 */
          /***/
          (function(a, n, i) {
            var o = i(0).FDLayoutConstants;
            function s() {
            }
            for (var u in o)
              s[u] = o[u];
            s.DEFAULT_USE_MULTI_LEVEL_SCALING = !1, s.DEFAULT_RADIAL_SEPARATION = o.DEFAULT_EDGE_LENGTH, s.DEFAULT_COMPONENT_SEPERATION = 60, s.TILE = !0, s.TILING_PADDING_VERTICAL = 10, s.TILING_PADDING_HORIZONTAL = 10, s.TREE_REDUCTION_ON_INCREMENTAL = !1, a.exports = s;
          }),
          /* 2 */
          /***/
          (function(a, n, i) {
            var o = i(0).FDLayoutEdge;
            function s(l, f, v) {
              o.call(this, l, f, v);
            }
            s.prototype = Object.create(o.prototype);
            for (var u in o)
              s[u] = o[u];
            a.exports = s;
          }),
          /* 3 */
          /***/
          (function(a, n, i) {
            var o = i(0).LGraph;
            function s(l, f, v) {
              o.call(this, l, f, v);
            }
            s.prototype = Object.create(o.prototype);
            for (var u in o)
              s[u] = o[u];
            a.exports = s;
          }),
          /* 4 */
          /***/
          (function(a, n, i) {
            var o = i(0).LGraphManager;
            function s(l) {
              o.call(this, l);
            }
            s.prototype = Object.create(o.prototype);
            for (var u in o)
              s[u] = o[u];
            a.exports = s;
          }),
          /* 5 */
          /***/
          (function(a, n, i) {
            var o = i(0).FDLayoutNode, s = i(0).IMath;
            function u(f, v, c, h) {
              o.call(this, f, v, c, h);
            }
            u.prototype = Object.create(o.prototype);
            for (var l in o)
              u[l] = o[l];
            u.prototype.move = function() {
              var f = this.graphManager.getLayout();
              this.displacementX = f.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren, this.displacementY = f.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren, Math.abs(this.displacementX) > f.coolingFactor * f.maxNodeDisplacement && (this.displacementX = f.coolingFactor * f.maxNodeDisplacement * s.sign(this.displacementX)), Math.abs(this.displacementY) > f.coolingFactor * f.maxNodeDisplacement && (this.displacementY = f.coolingFactor * f.maxNodeDisplacement * s.sign(this.displacementY)), this.child == null ? this.moveBy(this.displacementX, this.displacementY) : this.child.getNodes().length == 0 ? this.moveBy(this.displacementX, this.displacementY) : this.propogateDisplacementToChildren(this.displacementX, this.displacementY), f.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY), this.springForceX = 0, this.springForceY = 0, this.repulsionForceX = 0, this.repulsionForceY = 0, this.gravitationForceX = 0, this.gravitationForceY = 0, this.displacementX = 0, this.displacementY = 0;
            }, u.prototype.propogateDisplacementToChildren = function(f, v) {
              for (var c = this.getChild().getNodes(), h, d = 0; d < c.length; d++)
                h = c[d], h.getChild() == null ? (h.moveBy(f, v), h.displacementX += f, h.displacementY += v) : h.propogateDisplacementToChildren(f, v);
            }, u.prototype.setPred1 = function(f) {
              this.pred1 = f;
            }, u.prototype.getPred1 = function() {
              return pred1;
            }, u.prototype.getPred2 = function() {
              return pred2;
            }, u.prototype.setNext = function(f) {
              this.next = f;
            }, u.prototype.getNext = function() {
              return next;
            }, u.prototype.setProcessed = function(f) {
              this.processed = f;
            }, u.prototype.isProcessed = function() {
              return processed;
            }, a.exports = u;
          }),
          /* 6 */
          /***/
          (function(a, n, i) {
            var o = i(0).FDLayout, s = i(4), u = i(3), l = i(5), f = i(2), v = i(1), c = i(0).FDLayoutConstants, h = i(0).LayoutConstants, d = i(0).Point, g = i(0).PointD, p = i(0).Layout, y = i(0).Integer, b = i(0).IGeometry, m = i(0).LGraph, E = i(0).Transform;
            function C() {
              o.call(this), this.toBeTiled = {};
            }
            C.prototype = Object.create(o.prototype);
            for (var S in o)
              C[S] = o[S];
            C.prototype.newGraphManager = function() {
              var w = new s(this);
              return this.graphManager = w, w;
            }, C.prototype.newGraph = function(w) {
              return new u(null, this.graphManager, w);
            }, C.prototype.newNode = function(w) {
              return new l(this.graphManager, w);
            }, C.prototype.newEdge = function(w) {
              return new f(null, null, w);
            }, C.prototype.initParameters = function() {
              o.prototype.initParameters.call(this, arguments), this.isSubLayout || (v.DEFAULT_EDGE_LENGTH < 10 ? this.idealEdgeLength = 10 : this.idealEdgeLength = v.DEFAULT_EDGE_LENGTH, this.useSmartIdealEdgeLengthCalculation = v.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.springConstant = c.DEFAULT_SPRING_STRENGTH, this.repulsionConstant = c.DEFAULT_REPULSION_STRENGTH, this.gravityConstant = c.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = c.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = c.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = c.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.prunedNodesAll = [], this.growTreeIterations = 0, this.afterGrowthIterations = 0, this.isTreeGrowing = !1, this.isGrowthFinished = !1, this.coolingCycle = 0, this.maxCoolingCycle = this.maxIterations / c.CONVERGENCE_CHECK_PERIOD, this.finalTemperature = c.CONVERGENCE_CHECK_PERIOD / this.maxIterations, this.coolingAdjuster = 1);
            }, C.prototype.layout = function() {
              var w = h.DEFAULT_CREATE_BENDS_AS_NEEDED;
              return w && (this.createBendpoints(), this.graphManager.resetAllEdges()), this.level = 0, this.classicLayout();
            }, C.prototype.classicLayout = function() {
              if (this.nodesWithGravity = this.calculateNodesToApplyGravitationTo(), this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity), this.calcNoOfChildrenForAllNodes(), this.graphManager.calcLowestCommonAncestors(), this.graphManager.calcInclusionTreeDepths(), this.graphManager.getRoot().calcEstimatedSize(), this.calcIdealEdgeLengths(), this.incremental) {
                if (v.TREE_REDUCTION_ON_INCREMENTAL) {
                  this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
                  var x = new Set(this.getAllNodes()), T = this.nodesWithGravity.filter(function(L) {
                    return x.has(L);
                  });
                  this.graphManager.setAllNodesToApplyGravitation(T);
                }
              } else {
                var w = this.getFlatForest();
                if (w.length > 0)
                  this.positionNodesRadially(w);
                else {
                  this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
                  var x = new Set(this.getAllNodes()), T = this.nodesWithGravity.filter(function(D) {
                    return x.has(D);
                  });
                  this.graphManager.setAllNodesToApplyGravitation(T), this.positionNodesRandomly();
                }
              }
              return this.initSpringEmbedder(), this.runSpringEmbedder(), !0;
            }, C.prototype.tick = function() {
              if (this.totalIterations++, this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished)
                if (this.prunedNodesAll.length > 0)
                  this.isTreeGrowing = !0;
                else
                  return !0;
              if (this.totalIterations % c.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) {
                if (this.isConverged())
                  if (this.prunedNodesAll.length > 0)
                    this.isTreeGrowing = !0;
                  else
                    return !0;
                this.coolingCycle++, this.layoutQuality == 0 ? this.coolingAdjuster = this.coolingCycle : this.layoutQuality == 1 && (this.coolingAdjuster = this.coolingCycle / 3), this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature), this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor));
              }
              if (this.isTreeGrowing) {
                if (this.growTreeIterations % 10 == 0)
                  if (this.prunedNodesAll.length > 0) {
                    this.graphManager.updateBounds(), this.updateGrid(), this.growTree(this.prunedNodesAll), this.graphManager.resetAllNodesToApplyGravitation();
                    var w = new Set(this.getAllNodes()), x = this.nodesWithGravity.filter(function(A) {
                      return w.has(A);
                    });
                    this.graphManager.setAllNodesToApplyGravitation(x), this.graphManager.updateBounds(), this.updateGrid(), this.coolingFactor = c.DEFAULT_COOLING_FACTOR_INCREMENTAL;
                  } else
                    this.isTreeGrowing = !1, this.isGrowthFinished = !0;
                this.growTreeIterations++;
              }
              if (this.isGrowthFinished) {
                if (this.isConverged())
                  return !0;
                this.afterGrowthIterations % 10 == 0 && (this.graphManager.updateBounds(), this.updateGrid()), this.coolingFactor = c.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100), this.afterGrowthIterations++;
              }
              var T = !this.isTreeGrowing && !this.isGrowthFinished, D = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished;
              return this.totalDisplacement = 0, this.graphManager.updateBounds(), this.calcSpringForces(), this.calcRepulsionForces(T, D), this.calcGravitationalForces(), this.moveNodes(), this.animate(), !1;
            }, C.prototype.getPositionsData = function() {
              for (var w = this.graphManager.getAllNodes(), x = {}, T = 0; T < w.length; T++) {
                var D = w[T].rect, A = w[T].id;
                x[A] = {
                  id: A,
                  x: D.getCenterX(),
                  y: D.getCenterY(),
                  w: D.width,
                  h: D.height
                };
              }
              return x;
            }, C.prototype.runSpringEmbedder = function() {
              this.initialAnimationPeriod = 25, this.animationPeriod = this.initialAnimationPeriod;
              var w = !1;
              if (c.ANIMATE === "during")
                this.emit("layoutstarted");
              else {
                for (; !w; )
                  w = this.tick();
                this.graphManager.updateBounds();
              }
            }, C.prototype.calculateNodesToApplyGravitationTo = function() {
              var w = [], x, T = this.graphManager.getGraphs(), D = T.length, A;
              for (A = 0; A < D; A++)
                x = T[A], x.updateConnected(), x.isConnected || (w = w.concat(x.getNodes()));
              return w;
            }, C.prototype.createBendpoints = function() {
              var w = [];
              w = w.concat(this.graphManager.getAllEdges());
              var x = /* @__PURE__ */ new Set(), T;
              for (T = 0; T < w.length; T++) {
                var D = w[T];
                if (!x.has(D)) {
                  var A = D.getSource(), L = D.getTarget();
                  if (A == L)
                    D.getBendpoints().push(new g()), D.getBendpoints().push(new g()), this.createDummyNodesForBendpoints(D), x.add(D);
                  else {
                    var R = [];
                    if (R = R.concat(A.getEdgeListToNode(L)), R = R.concat(L.getEdgeListToNode(A)), !x.has(R[0])) {
                      if (R.length > 1) {
                        var P;
                        for (P = 0; P < R.length; P++) {
                          var I = R[P];
                          I.getBendpoints().push(new g()), this.createDummyNodesForBendpoints(I);
                        }
                      }
                      R.forEach(function(k) {
                        x.add(k);
                      });
                    }
                  }
                }
                if (x.size == w.length)
                  break;
              }
            }, C.prototype.positionNodesRadially = function(w) {
              for (var x = new d(0, 0), T = Math.ceil(Math.sqrt(w.length)), D = 0, A = 0, L = 0, R = new g(0, 0), P = 0; P < w.length; P++) {
                P % T == 0 && (L = 0, A = D, P != 0 && (A += v.DEFAULT_COMPONENT_SEPERATION), D = 0);
                var I = w[P], k = p.findCenterOfTree(I);
                x.x = L, x.y = A, R = C.radialLayout(I, k, x), R.y > D && (D = Math.floor(R.y)), L = Math.floor(R.x + v.DEFAULT_COMPONENT_SEPERATION);
              }
              this.transform(new g(h.WORLD_CENTER_X - R.x / 2, h.WORLD_CENTER_Y - R.y / 2));
            }, C.radialLayout = function(w, x, T) {
              var D = Math.max(this.maxDiagonalInTree(w), v.DEFAULT_RADIAL_SEPARATION);
              C.branchRadialLayout(x, null, 0, 359, 0, D);
              var A = m.calculateBounds(w), L = new E();
              L.setDeviceOrgX(A.getMinX()), L.setDeviceOrgY(A.getMinY()), L.setWorldOrgX(T.x), L.setWorldOrgY(T.y);
              for (var R = 0; R < w.length; R++) {
                var P = w[R];
                P.transform(L);
              }
              var I = new g(A.getMaxX(), A.getMaxY());
              return L.inverseTransformPoint(I);
            }, C.branchRadialLayout = function(w, x, T, D, A, L) {
              var R = (D - T + 1) / 2;
              R < 0 && (R += 180);
              var P = (R + T) % 360, I = P * b.TWO_PI / 360, k = A * Math.cos(I), O = A * Math.sin(I);
              w.setCenter(k, O);
              var N = [];
              N = N.concat(w.getEdges());
              var F = N.length;
              x != null && F--;
              for (var G = 0, B = N.length, z, Y = w.getEdgesBetween(x); Y.length > 1; ) {
                var $ = Y[0];
                Y.splice(0, 1);
                var X = N.indexOf($);
                X >= 0 && N.splice(X, 1), B--, F--;
              }
              x != null ? z = (N.indexOf(Y[0]) + 1) % B : z = 0;
              for (var j = Math.abs(D - T) / F, ee = z; G != F; ee = ++ee % B) {
                var ae = N[ee].getOtherEnd(w);
                if (ae != x) {
                  var K = (T + G * j) % 360, V = (K + j) % 360;
                  C.branchRadialLayout(ae, w, K, V, A + L, L), G++;
                }
              }
            }, C.maxDiagonalInTree = function(w) {
              for (var x = y.MIN_VALUE, T = 0; T < w.length; T++) {
                var D = w[T], A = D.getDiagonal();
                A > x && (x = A);
              }
              return x;
            }, C.prototype.calcRepulsionRange = function() {
              return 2 * (this.level + 1) * this.idealEdgeLength;
            }, C.prototype.groupZeroDegreeMembers = function() {
              var w = this, x = {};
              this.memberGroups = {}, this.idToDummyNode = {};
              for (var T = [], D = this.graphManager.getAllNodes(), A = 0; A < D.length; A++) {
                var L = D[A], R = L.getParent();
                this.getNodeDegreeWithChildren(L) === 0 && (R.id == null || !this.getToBeTiled(R)) && T.push(L);
              }
              for (var A = 0; A < T.length; A++) {
                var L = T[A], P = L.getParent().id;
                typeof x[P] > "u" && (x[P] = []), x[P] = x[P].concat(L);
              }
              Object.keys(x).forEach(function(I) {
                if (x[I].length > 1) {
                  var k = "DummyCompound_" + I;
                  w.memberGroups[k] = x[I];
                  var O = x[I][0].getParent(), N = new l(w.graphManager);
                  N.id = k, N.paddingLeft = O.paddingLeft || 0, N.paddingRight = O.paddingRight || 0, N.paddingBottom = O.paddingBottom || 0, N.paddingTop = O.paddingTop || 0, w.idToDummyNode[k] = N;
                  var F = w.getGraphManager().add(w.newGraph(), N), G = O.getChild();
                  G.add(N);
                  for (var B = 0; B < x[I].length; B++) {
                    var z = x[I][B];
                    G.remove(z), F.add(z);
                  }
                }
              });
            }, C.prototype.clearCompounds = function() {
              var w = {}, x = {};
              this.performDFSOnCompounds();
              for (var T = 0; T < this.compoundOrder.length; T++)
                x[this.compoundOrder[T].id] = this.compoundOrder[T], w[this.compoundOrder[T].id] = [].concat(this.compoundOrder[T].getChild().getNodes()), this.graphManager.remove(this.compoundOrder[T].getChild()), this.compoundOrder[T].child = null;
              this.graphManager.resetAllNodes(), this.tileCompoundMembers(w, x);
            }, C.prototype.clearZeroDegreeMembers = function() {
              var w = this, x = this.tiledZeroDegreePack = [];
              Object.keys(this.memberGroups).forEach(function(T) {
                var D = w.idToDummyNode[T];
                x[T] = w.tileNodes(w.memberGroups[T], D.paddingLeft + D.paddingRight), D.rect.width = x[T].width, D.rect.height = x[T].height;
              });
            }, C.prototype.repopulateCompounds = function() {
              for (var w = this.compoundOrder.length - 1; w >= 0; w--) {
                var x = this.compoundOrder[w], T = x.id, D = x.paddingLeft, A = x.paddingTop;
                this.adjustLocations(this.tiledMemberPack[T], x.rect.x, x.rect.y, D, A);
              }
            }, C.prototype.repopulateZeroDegreeMembers = function() {
              var w = this, x = this.tiledZeroDegreePack;
              Object.keys(x).forEach(function(T) {
                var D = w.idToDummyNode[T], A = D.paddingLeft, L = D.paddingTop;
                w.adjustLocations(x[T], D.rect.x, D.rect.y, A, L);
              });
            }, C.prototype.getToBeTiled = function(w) {
              var x = w.id;
              if (this.toBeTiled[x] != null)
                return this.toBeTiled[x];
              var T = w.getChild();
              if (T == null)
                return this.toBeTiled[x] = !1, !1;
              for (var D = T.getNodes(), A = 0; A < D.length; A++) {
                var L = D[A];
                if (this.getNodeDegree(L) > 0)
                  return this.toBeTiled[x] = !1, !1;
                if (L.getChild() == null) {
                  this.toBeTiled[L.id] = !1;
                  continue;
                }
                if (!this.getToBeTiled(L))
                  return this.toBeTiled[x] = !1, !1;
              }
              return this.toBeTiled[x] = !0, !0;
            }, C.prototype.getNodeDegree = function(w) {
              w.id;
              for (var x = w.getEdges(), T = 0, D = 0; D < x.length; D++) {
                var A = x[D];
                A.getSource().id !== A.getTarget().id && (T = T + 1);
              }
              return T;
            }, C.prototype.getNodeDegreeWithChildren = function(w) {
              var x = this.getNodeDegree(w);
              if (w.getChild() == null)
                return x;
              for (var T = w.getChild().getNodes(), D = 0; D < T.length; D++) {
                var A = T[D];
                x += this.getNodeDegreeWithChildren(A);
              }
              return x;
            }, C.prototype.performDFSOnCompounds = function() {
              this.compoundOrder = [], this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
            }, C.prototype.fillCompexOrderByDFS = function(w) {
              for (var x = 0; x < w.length; x++) {
                var T = w[x];
                T.getChild() != null && this.fillCompexOrderByDFS(T.getChild().getNodes()), this.getToBeTiled(T) && this.compoundOrder.push(T);
              }
            }, C.prototype.adjustLocations = function(w, x, T, D, A) {
              x += D, T += A;
              for (var L = x, R = 0; R < w.rows.length; R++) {
                var P = w.rows[R];
                x = L;
                for (var I = 0, k = 0; k < P.length; k++) {
                  var O = P[k];
                  O.rect.x = x, O.rect.y = T, x += O.rect.width + w.horizontalPadding, O.rect.height > I && (I = O.rect.height);
                }
                T += I + w.verticalPadding;
              }
            }, C.prototype.tileCompoundMembers = function(w, x) {
              var T = this;
              this.tiledMemberPack = [], Object.keys(w).forEach(function(D) {
                var A = x[D];
                T.tiledMemberPack[D] = T.tileNodes(w[D], A.paddingLeft + A.paddingRight), A.rect.width = T.tiledMemberPack[D].width, A.rect.height = T.tiledMemberPack[D].height;
              });
            }, C.prototype.tileNodes = function(w, x) {
              var T = v.TILING_PADDING_VERTICAL, D = v.TILING_PADDING_HORIZONTAL, A = {
                rows: [],
                rowWidth: [],
                rowHeight: [],
                width: 0,
                height: x,
                // assume minHeight equals to minWidth
                verticalPadding: T,
                horizontalPadding: D
              };
              w.sort(function(P, I) {
                return P.rect.width * P.rect.height > I.rect.width * I.rect.height ? -1 : P.rect.width * P.rect.height < I.rect.width * I.rect.height ? 1 : 0;
              });
              for (var L = 0; L < w.length; L++) {
                var R = w[L];
                A.rows.length == 0 ? this.insertNodeToRow(A, R, 0, x) : this.canAddHorizontal(A, R.rect.width, R.rect.height) ? this.insertNodeToRow(A, R, this.getShortestRowIndex(A), x) : this.insertNodeToRow(A, R, A.rows.length, x), this.shiftToLastRow(A);
              }
              return A;
            }, C.prototype.insertNodeToRow = function(w, x, T, D) {
              var A = D;
              if (T == w.rows.length) {
                var L = [];
                w.rows.push(L), w.rowWidth.push(A), w.rowHeight.push(0);
              }
              var R = w.rowWidth[T] + x.rect.width;
              w.rows[T].length > 0 && (R += w.horizontalPadding), w.rowWidth[T] = R, w.width < R && (w.width = R);
              var P = x.rect.height;
              T > 0 && (P += w.verticalPadding);
              var I = 0;
              P > w.rowHeight[T] && (I = w.rowHeight[T], w.rowHeight[T] = P, I = w.rowHeight[T] - I), w.height += I, w.rows[T].push(x);
            }, C.prototype.getShortestRowIndex = function(w) {
              for (var x = -1, T = Number.MAX_VALUE, D = 0; D < w.rows.length; D++)
                w.rowWidth[D] < T && (x = D, T = w.rowWidth[D]);
              return x;
            }, C.prototype.getLongestRowIndex = function(w) {
              for (var x = -1, T = Number.MIN_VALUE, D = 0; D < w.rows.length; D++)
                w.rowWidth[D] > T && (x = D, T = w.rowWidth[D]);
              return x;
            }, C.prototype.canAddHorizontal = function(w, x, T) {
              var D = this.getShortestRowIndex(w);
              if (D < 0)
                return !0;
              var A = w.rowWidth[D];
              if (A + w.horizontalPadding + x <= w.width) return !0;
              var L = 0;
              w.rowHeight[D] < T && D > 0 && (L = T + w.verticalPadding - w.rowHeight[D]);
              var R;
              w.width - A >= x + w.horizontalPadding ? R = (w.height + L) / (A + x + w.horizontalPadding) : R = (w.height + L) / w.width, L = T + w.verticalPadding;
              var P;
              return w.width < x ? P = (w.height + L) / x : P = (w.height + L) / w.width, P < 1 && (P = 1 / P), R < 1 && (R = 1 / R), R < P;
            }, C.prototype.shiftToLastRow = function(w) {
              var x = this.getLongestRowIndex(w), T = w.rowWidth.length - 1, D = w.rows[x], A = D[D.length - 1], L = A.width + w.horizontalPadding;
              if (w.width - w.rowWidth[T] > L && x != T) {
                D.splice(-1, 1), w.rows[T].push(A), w.rowWidth[x] = w.rowWidth[x] - L, w.rowWidth[T] = w.rowWidth[T] + L, w.width = w.rowWidth[instance.getLongestRowIndex(w)];
                for (var R = Number.MIN_VALUE, P = 0; P < D.length; P++)
                  D[P].height > R && (R = D[P].height);
                x > 0 && (R += w.verticalPadding);
                var I = w.rowHeight[x] + w.rowHeight[T];
                w.rowHeight[x] = R, w.rowHeight[T] < A.height + w.verticalPadding && (w.rowHeight[T] = A.height + w.verticalPadding);
                var k = w.rowHeight[x] + w.rowHeight[T];
                w.height += k - I, this.shiftToLastRow(w);
              }
            }, C.prototype.tilingPreLayout = function() {
              v.TILE && (this.groupZeroDegreeMembers(), this.clearCompounds(), this.clearZeroDegreeMembers());
            }, C.prototype.tilingPostLayout = function() {
              v.TILE && (this.repopulateZeroDegreeMembers(), this.repopulateCompounds());
            }, C.prototype.reduceTrees = function() {
              for (var w = [], x = !0, T; x; ) {
                var D = this.graphManager.getAllNodes(), A = [];
                x = !1;
                for (var L = 0; L < D.length; L++)
                  T = D[L], T.getEdges().length == 1 && !T.getEdges()[0].isInterGraph && T.getChild() == null && (A.push([T, T.getEdges()[0], T.getOwner()]), x = !0);
                if (x == !0) {
                  for (var R = [], P = 0; P < A.length; P++)
                    A[P][0].getEdges().length == 1 && (R.push(A[P]), A[P][0].getOwner().remove(A[P][0]));
                  w.push(R), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
                }
              }
              this.prunedNodesAll = w;
            }, C.prototype.growTree = function(w) {
              for (var x = w.length, T = w[x - 1], D, A = 0; A < T.length; A++)
                D = T[A], this.findPlaceforPrunedNode(D), D[2].add(D[0]), D[2].add(D[1], D[1].source, D[1].target);
              w.splice(w.length - 1, 1), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
            }, C.prototype.findPlaceforPrunedNode = function(w) {
              var x, T, D = w[0];
              D == w[1].source ? T = w[1].target : T = w[1].source;
              var A = T.startX, L = T.finishX, R = T.startY, P = T.finishY, I = 0, k = 0, O = 0, N = 0, F = [I, O, k, N];
              if (R > 0)
                for (var G = A; G <= L; G++)
                  F[0] += this.grid[G][R - 1].length + this.grid[G][R].length - 1;
              if (L < this.grid.length - 1)
                for (var G = R; G <= P; G++)
                  F[1] += this.grid[L + 1][G].length + this.grid[L][G].length - 1;
              if (P < this.grid[0].length - 1)
                for (var G = A; G <= L; G++)
                  F[2] += this.grid[G][P + 1].length + this.grid[G][P].length - 1;
              if (A > 0)
                for (var G = R; G <= P; G++)
                  F[3] += this.grid[A - 1][G].length + this.grid[A][G].length - 1;
              for (var B = y.MAX_VALUE, z, Y, $ = 0; $ < F.length; $++)
                F[$] < B ? (B = F[$], z = 1, Y = $) : F[$] == B && z++;
              if (z == 3 && B == 0)
                F[0] == 0 && F[1] == 0 && F[2] == 0 ? x = 1 : F[0] == 0 && F[1] == 0 && F[3] == 0 ? x = 0 : F[0] == 0 && F[2] == 0 && F[3] == 0 ? x = 3 : F[1] == 0 && F[2] == 0 && F[3] == 0 && (x = 2);
              else if (z == 2 && B == 0) {
                var X = Math.floor(Math.random() * 2);
                F[0] == 0 && F[1] == 0 ? X == 0 ? x = 0 : x = 1 : F[0] == 0 && F[2] == 0 ? X == 0 ? x = 0 : x = 2 : F[0] == 0 && F[3] == 0 ? X == 0 ? x = 0 : x = 3 : F[1] == 0 && F[2] == 0 ? X == 0 ? x = 1 : x = 2 : F[1] == 0 && F[3] == 0 ? X == 0 ? x = 1 : x = 3 : X == 0 ? x = 2 : x = 3;
              } else if (z == 4 && B == 0) {
                var X = Math.floor(Math.random() * 4);
                x = X;
              } else
                x = Y;
              x == 0 ? D.setCenter(T.getCenterX(), T.getCenterY() - T.getHeight() / 2 - c.DEFAULT_EDGE_LENGTH - D.getHeight() / 2) : x == 1 ? D.setCenter(T.getCenterX() + T.getWidth() / 2 + c.DEFAULT_EDGE_LENGTH + D.getWidth() / 2, T.getCenterY()) : x == 2 ? D.setCenter(T.getCenterX(), T.getCenterY() + T.getHeight() / 2 + c.DEFAULT_EDGE_LENGTH + D.getHeight() / 2) : D.setCenter(T.getCenterX() - T.getWidth() / 2 - c.DEFAULT_EDGE_LENGTH - D.getWidth() / 2, T.getCenterY());
            }, a.exports = C;
          }),
          /* 7 */
          /***/
          (function(a, n, i) {
            var o = {};
            o.layoutBase = i(0), o.CoSEConstants = i(1), o.CoSEEdge = i(2), o.CoSEGraph = i(3), o.CoSEGraphManager = i(4), o.CoSELayout = i(6), o.CoSENode = i(5), a.exports = o;
          })
          /******/
        ])
      );
    });
  })(bn)), bn.exports;
}
var Hm = mn.exports, af;
function Xm() {
  return af || (af = 1, (function(t, e) {
    (function(a, n) {
      t.exports = n(Ym());
    })(Hm, function(r) {
      return (
        /******/
        (function(a) {
          var n = {};
          function i(o) {
            if (n[o])
              return n[o].exports;
            var s = n[o] = {
              /******/
              i: o,
              /******/
              l: !1,
              /******/
              exports: {}
              /******/
            };
            return a[o].call(s.exports, s, s.exports, i), s.l = !0, s.exports;
          }
          return i.m = a, i.c = n, i.i = function(o) {
            return o;
          }, i.d = function(o, s, u) {
            i.o(o, s) || Object.defineProperty(o, s, {
              /******/
              configurable: !1,
              /******/
              enumerable: !0,
              /******/
              get: u
              /******/
            });
          }, i.n = function(o) {
            var s = o && o.__esModule ? (
              /******/
              function() {
                return o.default;
              }
            ) : (
              /******/
              function() {
                return o;
              }
            );
            return i.d(s, "a", s), s;
          }, i.o = function(o, s) {
            return Object.prototype.hasOwnProperty.call(o, s);
          }, i.p = "", i(i.s = 1);
        })([
          /* 0 */
          /***/
          (function(a, n) {
            a.exports = r;
          }),
          /* 1 */
          /***/
          (function(a, n, i) {
            var o = i(0).layoutBase.LayoutConstants, s = i(0).layoutBase.FDLayoutConstants, u = i(0).CoSEConstants, l = i(0).CoSELayout, f = i(0).CoSENode, v = i(0).layoutBase.PointD, c = i(0).layoutBase.DimensionD, h = {
              // Called on `layoutready`
              ready: function() {
              },
              // Called on `layoutstop`
              stop: function() {
              },
              // 'draft', 'default' or 'proof" 
              // - 'draft' fast cooling rate 
              // - 'default' moderate cooling rate 
              // - "proof" slow cooling rate
              quality: "default",
              // include labels in node dimensions
              nodeDimensionsIncludeLabels: !1,
              // number of ticks per frame; higher is faster but more jerky
              refresh: 30,
              // Whether to fit the network view after when done
              fit: !0,
              // Padding on fit
              padding: 10,
              // Whether to enable incremental mode
              randomize: !0,
              // Node repulsion (non overlapping) multiplier
              nodeRepulsion: 4500,
              // Ideal edge (non nested) length
              idealEdgeLength: 50,
              // Divisor to compute edge forces
              edgeElasticity: 0.45,
              // Nesting factor (multiplier) to compute ideal edge length for nested edges
              nestingFactor: 0.1,
              // Gravity force (constant)
              gravity: 0.25,
              // Maximum number of iterations to perform
              numIter: 2500,
              // For enabling tiling
              tile: !0,
              // Type of layout animation. The option set is {'during', 'end', false}
              animate: "end",
              // Duration for animate:end
              animationDuration: 500,
              // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function)
              tilingPaddingVertical: 10,
              // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function)
              tilingPaddingHorizontal: 10,
              // Gravity range (constant) for compounds
              gravityRangeCompound: 1.5,
              // Gravity force (constant) for compounds
              gravityCompound: 1,
              // Gravity range (constant)
              gravityRange: 3.8,
              // Initial cooling factor for incremental layout
              initialEnergyOnIncremental: 0.5
            };
            function d(b, m) {
              var E = {};
              for (var C in b)
                E[C] = b[C];
              for (var C in m)
                E[C] = m[C];
              return E;
            }
            function g(b) {
              this.options = d(h, b), p(this.options);
            }
            var p = function(m) {
              m.nodeRepulsion != null && (u.DEFAULT_REPULSION_STRENGTH = s.DEFAULT_REPULSION_STRENGTH = m.nodeRepulsion), m.idealEdgeLength != null && (u.DEFAULT_EDGE_LENGTH = s.DEFAULT_EDGE_LENGTH = m.idealEdgeLength), m.edgeElasticity != null && (u.DEFAULT_SPRING_STRENGTH = s.DEFAULT_SPRING_STRENGTH = m.edgeElasticity), m.nestingFactor != null && (u.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = s.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = m.nestingFactor), m.gravity != null && (u.DEFAULT_GRAVITY_STRENGTH = s.DEFAULT_GRAVITY_STRENGTH = m.gravity), m.numIter != null && (u.MAX_ITERATIONS = s.MAX_ITERATIONS = m.numIter), m.gravityRange != null && (u.DEFAULT_GRAVITY_RANGE_FACTOR = s.DEFAULT_GRAVITY_RANGE_FACTOR = m.gravityRange), m.gravityCompound != null && (u.DEFAULT_COMPOUND_GRAVITY_STRENGTH = s.DEFAULT_COMPOUND_GRAVITY_STRENGTH = m.gravityCompound), m.gravityRangeCompound != null && (u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = s.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = m.gravityRangeCompound), m.initialEnergyOnIncremental != null && (u.DEFAULT_COOLING_FACTOR_INCREMENTAL = s.DEFAULT_COOLING_FACTOR_INCREMENTAL = m.initialEnergyOnIncremental), m.quality == "draft" ? o.QUALITY = 0 : m.quality == "proof" ? o.QUALITY = 2 : o.QUALITY = 1, u.NODE_DIMENSIONS_INCLUDE_LABELS = s.NODE_DIMENSIONS_INCLUDE_LABELS = o.NODE_DIMENSIONS_INCLUDE_LABELS = m.nodeDimensionsIncludeLabels, u.DEFAULT_INCREMENTAL = s.DEFAULT_INCREMENTAL = o.DEFAULT_INCREMENTAL = !m.randomize, u.ANIMATE = s.ANIMATE = o.ANIMATE = m.animate, u.TILE = m.tile, u.TILING_PADDING_VERTICAL = typeof m.tilingPaddingVertical == "function" ? m.tilingPaddingVertical.call() : m.tilingPaddingVertical, u.TILING_PADDING_HORIZONTAL = typeof m.tilingPaddingHorizontal == "function" ? m.tilingPaddingHorizontal.call() : m.tilingPaddingHorizontal;
            };
            g.prototype.run = function() {
              var b, m, E = this.options;
              this.idToLNode = {};
              var C = this.layout = new l(), S = this;
              S.stopped = !1, this.cy = this.options.cy, this.cy.trigger({ type: "layoutstart", layout: this });
              var w = C.newGraphManager();
              this.gm = w;
              var x = this.options.eles.nodes(), T = this.options.eles.edges();
              this.root = w.addRoot(), this.processChildrenList(this.root, this.getTopMostNodes(x), C);
              for (var D = 0; D < T.length; D++) {
                var A = T[D], L = this.idToLNode[A.data("source")], R = this.idToLNode[A.data("target")];
                if (L !== R && L.getEdgesBetween(R).length == 0) {
                  var P = w.add(C.newEdge(), L, R);
                  P.id = A.id();
                }
              }
              var I = function(N, F) {
                typeof N == "number" && (N = F);
                var G = N.data("id"), B = S.idToLNode[G];
                return {
                  x: B.getRect().getCenterX(),
                  y: B.getRect().getCenterY()
                };
              }, k = function O() {
                for (var N = function() {
                  E.fit && E.cy.fit(E.eles, E.padding), b || (b = !0, S.cy.one("layoutready", E.ready), S.cy.trigger({ type: "layoutready", layout: S }));
                }, F = S.options.refresh, G, B = 0; B < F && !G; B++)
                  G = S.stopped || S.layout.tick();
                if (G) {
                  C.checkLayoutSuccess() && !C.isSubLayout && C.doPostLayout(), C.tilingPostLayout && C.tilingPostLayout(), C.isLayoutFinished = !0, S.options.eles.nodes().positions(I), N(), S.cy.one("layoutstop", S.options.stop), S.cy.trigger({ type: "layoutstop", layout: S }), m && cancelAnimationFrame(m), b = !1;
                  return;
                }
                var z = S.layout.getPositionsData();
                E.eles.nodes().positions(function(Y, $) {
                  if (typeof Y == "number" && (Y = $), !Y.isParent()) {
                    for (var X = Y.id(), j = z[X], ee = Y; j == null && (j = z[ee.data("parent")] || z["DummyCompound_" + ee.data("parent")], z[X] = j, ee = ee.parent()[0], ee != null); )
                      ;
                    return j != null ? {
                      x: j.x,
                      y: j.y
                    } : {
                      x: Y.position("x"),
                      y: Y.position("y")
                    };
                  }
                }), N(), m = requestAnimationFrame(O);
              };
              return C.addListener("layoutstarted", function() {
                S.options.animate === "during" && (m = requestAnimationFrame(k));
              }), C.runLayout(), this.options.animate !== "during" && (S.options.eles.nodes().not(":parent").layoutPositions(S, S.options, I), b = !1), this;
            }, g.prototype.getTopMostNodes = function(b) {
              for (var m = {}, E = 0; E < b.length; E++)
                m[b[E].id()] = !0;
              var C = b.filter(function(S, w) {
                typeof S == "number" && (S = w);
                for (var x = S.parent()[0]; x != null; ) {
                  if (m[x.id()])
                    return !1;
                  x = x.parent()[0];
                }
                return !0;
              });
              return C;
            }, g.prototype.processChildrenList = function(b, m, E) {
              for (var C = m.length, S = 0; S < C; S++) {
                var w = m[S], x = w.children(), T, D = w.layoutDimensions({
                  nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels
                });
                if (w.outerWidth() != null && w.outerHeight() != null ? T = b.add(new f(E.graphManager, new v(w.position("x") - D.w / 2, w.position("y") - D.h / 2), new c(parseFloat(D.w), parseFloat(D.h)))) : T = b.add(new f(this.graphManager)), T.id = w.data("id"), T.paddingLeft = parseInt(w.css("padding")), T.paddingTop = parseInt(w.css("padding")), T.paddingRight = parseInt(w.css("padding")), T.paddingBottom = parseInt(w.css("padding")), this.options.nodeDimensionsIncludeLabels && w.isParent()) {
                  var A = w.boundingBox({ includeLabels: !0, includeNodes: !1 }).w, L = w.boundingBox({ includeLabels: !0, includeNodes: !1 }).h, R = w.css("text-halign");
                  T.labelWidth = A, T.labelHeight = L, T.labelPos = R;
                }
                if (this.idToLNode[w.data("id")] = T, isNaN(T.rect.x) && (T.rect.x = 0), isNaN(T.rect.y) && (T.rect.y = 0), x != null && x.length > 0) {
                  var P;
                  P = E.getGraphManager().add(E.newGraph(), T), this.processChildrenList(P, x, E);
                }
              }
            }, g.prototype.stop = function() {
              return this.stopped = !0, this;
            };
            var y = function(m) {
              m("layout", "cose-bilkent", g);
            };
            typeof cytoscape < "u" && y(cytoscape), a.exports = y;
          })
          /******/
        ])
      );
    });
  })(mn)), mn.exports;
}
var Wm = Xm();
const Zm = /* @__PURE__ */ sc(Wm);
export {
  ea as a,
  Zm as b,
  Km as c,
  sc as g
};
