UNPKG

smart-chat-asp

Version:

smartChat component

21,944 lines 793 kB
import { az as js, aA as uv, a1 as Or, X as eo, aC as lv, ac as fv, aE as bn, Y as wn, a0 as cv, bo as vv, bp as hv, bq as dv, aG as gv } from "./lib-abebf4b0.mjs";
import { a as pv } from "./createText-2e5e7dd3-9711772c.mjs";
import "vue";
function Os(r, e) {
  (e == null || e > r.length) && (e = r.length);
  for (var t = 0, a = Array(e); t < e; t++)
    a[t] = r[t];
  return a;
}
function yv(r) {
  if (Array.isArray(r))
    return r;
}
function mv(r) {
  if (Array.isArray(r))
    return Os(r);
}
function hr(r, e) {
  if (!(r instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function bv(r, e) {
  for (var t = 0; t < e.length; t++) {
    var a = e[t];
    a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(r, of(a.key), a);
  }
}
function dr(r, e, t) {
  return e && bv(r.prototype, e), Object.defineProperty(r, "prototype", {
    writable: !1
  }), r;
}
function Dt(r, e) {
  var t = typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
  if (!t) {
    if (Array.isArray(r) || (t = to(r)) || e) {
      t && (r = t);
      var a = 0, n = function() {
      };
      return {
        s: n,
        n: function() {
          return a >= r.length ? {
            done: !0
          } : {
            done: !1,
            value: r[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, s = !0, o = !1;
  return {
    s: function() {
      t = t.call(r);
    },
    n: function() {
      var u = t.next();
      return s = u.done, u;
    },
    e: function(u) {
      o = !0, i = u;
    },
    f: function() {
      try {
        s || t.return == null || t.return();
      } finally {
        if (o)
          throw i;
      }
    }
  };
}
function sf(r, e, t) {
  return (e = of(e)) in r ? Object.defineProperty(r, e, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : r[e] = t, r;
}
function wv(r) {
  if (typeof Symbol < "u" && r[Symbol.iterator] != null || r["@@iterator"] != null)
    return Array.from(r);
}
function Ev(r, e) {
  var t = r == null ? null : typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
  if (t != null) {
    var a, n, i, s, o = [], u = !0, l = !1;
    try {
      if (i = (t = t.call(r)).next, e === 0) {
        if (Object(t) !== t)
          return;
        u = !1;
      } else
        for (; !(u = (a = i.call(t)).done) && (o.push(a.value), o.length !== e); u = !0)
          ;
    } catch (f) {
      l = !0, n = f;
    } finally {
      try {
        if (!u && t.return != null && (s = t.return(), Object(s) !== s))
          return;
      } finally {
        if (l)
          throw n;
      }
    }
    return o;
  }
}
function xv() {
  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 Tv() {
  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 je(r, e) {
  return yv(r) || Ev(r, e) || to(r, e) || xv();
}
function En(r) {
  return mv(r) || wv(r) || to(r) || Tv();
}
function Cv(r, e) {
  if (typeof r != "object" || !r)
    return r;
  var t = r[Symbol.toPrimitive];
  if (t !== void 0) {
    var a = t.call(r, e);
    if (typeof a != "object")
      return a;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return String(r);
}
function of(r) {
  var e = Cv(r, "string");
  return typeof e == "symbol" ? e : e + "";
}
function rt(r) {
  "@babel/helpers - typeof";
  return rt = 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;
  }, rt(r);
}
function to(r, e) {
  if (r) {
    if (typeof r == "string")
      return Os(r, e);
    var t = {}.toString.call(r).slice(8, -1);
    return t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set" ? Array.from(r) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? Os(r, e) : void 0;
  }
}
var Je = typeof window > "u" ? null : window, Oo = Je ? Je.navigator : null;
Je && Je.document;
var Dv = rt(""), uf = rt({}), Sv = rt(function() {
}), Av = typeof HTMLElement > "u" ? "undefined" : rt(HTMLElement), Pa = function(e) {
  return e && e.instanceString && He(e.instanceString) ? e.instanceString() : null;
}, ce = function(e) {
  return e != null && rt(e) == Dv;
}, He = function(e) {
  return e != null && rt(e) === Sv;
}, _e = function(e) {
  return !At(e) && (Array.isArray ? Array.isArray(e) : e != null && e instanceof Array);
}, Re = function(e) {
  return e != null && rt(e) === uf && !_e(e) && e.constructor === Object;
}, Lv = function(e) {
  return e != null && rt(e) === uf;
}, ae = function(e) {
  return e != null && rt(e) === rt(1) && !isNaN(e);
}, Rv = function(e) {
  return ae(e) && Math.floor(e) === e;
}, xn = function(e) {
  if (Av !== "undefined")
    return e != null && e instanceof HTMLElement;
}, At = function(e) {
  return Na(e) || lf(e);
}, Na = function(e) {
  return Pa(e) === "collection" && e._private.single;
}, lf = function(e) {
  return Pa(e) === "collection" && !e._private.single;
}, ro = function(e) {
  return Pa(e) === "core";
}, ff = function(e) {
  return Pa(e) === "stylesheet";
}, Iv = function(e) {
  return Pa(e) === "event";
}, sr = function(e) {
  return e == null ? !0 : !!(e === "" || e.match(/^\s+$/));
}, Mv = function(e) {
  return typeof HTMLElement > "u" ? !1 : e instanceof HTMLElement;
}, Ov = function(e) {
  return Re(e) && ae(e.x1) && ae(e.x2) && ae(e.y1) && ae(e.y2);
}, Pv = function(e) {
  return Lv(e) && He(e.then);
}, Nv = function() {
  return Oo && Oo.userAgent.match(/msie|trident|edge/i);
}, Jr = function(e, t) {
  t || (t = function() {
    if (arguments.length === 1)
      return arguments[0];
    if (arguments.length === 0)
      return "undefined";
    for (var i = [], s = 0; s < arguments.length; s++)
      i.push(arguments[s]);
    return i.join("$");
  });
  var a = function() {
    var i = this, s = arguments, o, u = t.apply(i, s), l = a.cache;
    return (o = l[u]) || (o = l[u] = e.apply(i, s)), o;
  };
  return a.cache = {}, a;
}, ao = Jr(function(r) {
  return r.replace(/([A-Z])/g, function(e) {
    return "-" + e.toLowerCase();
  });
}), kn = Jr(function(r) {
  return r.replace(/(-\w)/g, function(e) {
    return e[1].toUpperCase();
  });
}), cf = Jr(function(r, e) {
  return r + e[0].toUpperCase() + e.substring(1);
}, function(r, e) {
  return r + "$" + e;
}), Po = function(e) {
  return sr(e) ? e : e.charAt(0).toUpperCase() + e.substring(1);
}, tt = "(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))", kv = "rgb[a]?\\((" + tt + "[%]?)\\s*,\\s*(" + tt + "[%]?)\\s*,\\s*(" + tt + "[%]?)(?:\\s*,\\s*(" + tt + "))?\\)", Bv = "rgb[a]?\\((?:" + tt + "[%]?)\\s*,\\s*(?:" + tt + "[%]?)\\s*,\\s*(?:" + tt + "[%]?)(?:\\s*,\\s*(?:" + tt + "))?\\)", Fv = "hsl[a]?\\((" + tt + ")\\s*,\\s*(" + tt + "[%])\\s*,\\s*(" + tt + "[%])(?:\\s*,\\s*(" + tt + "))?\\)", _v = "hsl[a]?\\((?:" + tt + ")\\s*,\\s*(?:" + tt + "[%])\\s*,\\s*(?:" + tt + "[%])(?:\\s*,\\s*(?:" + tt + "))?\\)", Gv = "\\#[0-9a-fA-F]{3}", zv = "\\#[0-9a-fA-F]{6}", vf = function(e, t) {
  return e < t ? -1 : e > t ? 1 : 0;
}, Vv = function(e, t) {
  return -1 * vf(e, t);
}, de = Object.assign != null ? Object.assign.bind(Object) : function(r) {
  for (var e = arguments, t = 1; t < e.length; t++) {
    var a = e[t];
    if (a != null)
      for (var n = Object.keys(a), i = 0; i < n.length; i++) {
        var s = n[i];
        r[s] = a[s];
      }
  }
  return r;
}, Uv = function(e) {
  if (!(!(e.length === 4 || e.length === 7) || e[0] !== "#")) {
    var t = e.length === 4, a, n, i, s = 16;
    return t ? (a = parseInt(e[1] + e[1], s), n = parseInt(e[2] + e[2], s), i = parseInt(e[3] + e[3], s)) : (a = parseInt(e[1] + e[2], s), n = parseInt(e[3] + e[4], s), i = parseInt(e[5] + e[6], s)), [a, n, i];
  }
}, qv = function(e) {
  var t, a, n, i, s, o, u, l;
  function f(d, p, g) {
    return g < 0 && (g += 1), g > 1 && (g -= 1), g < 1 / 6 ? d + (p - d) * 6 * g : g < 1 / 2 ? p : g < 2 / 3 ? d + (p - d) * (2 / 3 - g) * 6 : d;
  }
  var c = new RegExp("^" + Fv + "$").exec(e);
  if (c) {
    if (a = parseInt(c[1]), a < 0 ? a = (360 - -1 * a % 360) % 360 : a > 360 && (a = a % 360), a /= 360, n = parseFloat(c[2]), n < 0 || n > 100 || (n = n / 100, i = parseFloat(c[3]), i < 0 || i > 100) || (i = i / 100, s = c[4], s !== void 0 && (s = parseFloat(s), s < 0 || s > 1)))
      return;
    if (n === 0)
      o = u = l = Math.round(i * 255);
    else {
      var v = i < 0.5 ? i * (1 + n) : i + n - i * n, h = 2 * i - v;
      o = Math.round(255 * f(h, v, a + 1 / 3)), u = Math.round(255 * f(h, v, a)), l = Math.round(255 * f(h, v, a - 1 / 3));
    }
    t = [o, u, l, s];
  }
  return t;
}, Hv = function(e) {
  var t, a = new RegExp("^" + kv + "$").exec(e);
  if (a) {
    t = [];
    for (var n = [], i = 1; i <= 3; i++) {
      var s = a[i];
      if (s[s.length - 1] === "%" && (n[i] = !0), s = parseFloat(s), n[i] && (s = s / 100 * 255), s < 0 || s > 255)
        return;
      t.push(Math.floor(s));
    }
    var o = n[1] || n[2] || n[3], u = n[1] && n[2] && n[3];
    if (o && !u)
      return;
    var l = a[4];
    if (l !== void 0) {
      if (l = parseFloat(l), l < 0 || l > 1)
        return;
      t.push(l);
    }
  }
  return t;
}, Yv = function(e) {
  return Xv[e.toLowerCase()];
}, hf = function(e) {
  return (_e(e) ? e : null) || Yv(e) || Uv(e) || Hv(e) || qv(e);
}, Xv = {
  // 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]
}, df = function(e) {
  for (var t = e.map, a = e.keys, n = a.length, i = 0; i < n; i++) {
    var s = a[i];
    if (Re(s))
      throw Error("Tried to set map with object key");
    i < a.length - 1 ? (t[s] == null && (t[s] = {}), t = t[s]) : t[s] = e.value;
  }
}, gf = function(e) {
  for (var t = e.map, a = e.keys, n = a.length, i = 0; i < n; i++) {
    var s = a[i];
    if (Re(s))
      throw Error("Tried to get map with object key");
    if (t = t[s], t == null)
      return t;
  }
  return t;
}, Wa = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function ka(r) {
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
var ti, No;
function Ba() {
  if (No)
    return ti;
  No = 1;
  function r(e) {
    var t = typeof e;
    return e != null && (t == "object" || t == "function");
  }
  return ti = r, ti;
}
var ri, ko;
function $v() {
  if (ko)
    return ri;
  ko = 1;
  var r = typeof Wa == "object" && Wa && Wa.Object === Object && Wa;
  return ri = r, ri;
}
var ai, Bo;
function Bn() {
  if (Bo)
    return ai;
  Bo = 1;
  var r = $v(), e = typeof self == "object" && self && self.Object === Object && self, t = r || e || Function("return this")();
  return ai = t, ai;
}
var ni, Fo;
function Wv() {
  if (Fo)
    return ni;
  Fo = 1;
  var r = Bn(), e = function() {
    return r.Date.now();
  };
  return ni = e, ni;
}
var ii, _o;
function Kv() {
  if (_o)
    return ii;
  _o = 1;
  var r = /\s/;
  function e(t) {
    for (var a = t.length; a-- && r.test(t.charAt(a)); )
      ;
    return a;
  }
  return ii = e, ii;
}
var si, Go;
function Zv() {
  if (Go)
    return si;
  Go = 1;
  var r = Kv(), e = /^\s+/;
  function t(a) {
    return a && a.slice(0, r(a) + 1).replace(e, "");
  }
  return si = t, si;
}
var oi, zo;
function no() {
  if (zo)
    return oi;
  zo = 1;
  var r = Bn(), e = r.Symbol;
  return oi = e, oi;
}
var ui, Vo;
function Qv() {
  if (Vo)
    return ui;
  Vo = 1;
  var r = no(), e = Object.prototype, t = e.hasOwnProperty, a = e.toString, n = r ? r.toStringTag : void 0;
  function i(s) {
    var o = t.call(s, n), u = s[n];
    try {
      s[n] = void 0;
      var l = !0;
    } catch {
    }
    var f = a.call(s);
    return l && (o ? s[n] = u : delete s[n]), f;
  }
  return ui = i, ui;
}
var li, Uo;
function Jv() {
  if (Uo)
    return li;
  Uo = 1;
  var r = Object.prototype, e = r.toString;
  function t(a) {
    return e.call(a);
  }
  return li = t, li;
}
var fi, qo;
function pf() {
  if (qo)
    return fi;
  qo = 1;
  var r = no(), e = Qv(), t = Jv(), a = "[object Null]", n = "[object Undefined]", i = r ? r.toStringTag : void 0;
  function s(o) {
    return o == null ? o === void 0 ? n : a : i && i in Object(o) ? e(o) : t(o);
  }
  return fi = s, fi;
}
var ci, Ho;
function jv() {
  if (Ho)
    return ci;
  Ho = 1;
  function r(e) {
    return e != null && typeof e == "object";
  }
  return ci = r, ci;
}
var vi, Yo;
function Fa() {
  if (Yo)
    return vi;
  Yo = 1;
  var r = pf(), e = jv(), t = "[object Symbol]";
  function a(n) {
    return typeof n == "symbol" || e(n) && r(n) == t;
  }
  return vi = a, vi;
}
var hi, Xo;
function eh() {
  if (Xo)
    return hi;
  Xo = 1;
  var r = Zv(), e = Ba(), t = Fa(), a = 0 / 0, n = /^[-+]0x[0-9a-f]+$/i, i = /^0b[01]+$/i, s = /^0o[0-7]+$/i, o = parseInt;
  function u(l) {
    if (typeof l == "number")
      return l;
    if (t(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 = r(l);
    var c = i.test(l);
    return c || s.test(l) ? o(l.slice(2), c ? 2 : 8) : n.test(l) ? a : +l;
  }
  return hi = u, hi;
}
var di, $o;
function th() {
  if ($o)
    return di;
  $o = 1;
  var r = Ba(), e = Wv(), t = eh(), a = "Expected a function", n = Math.max, i = Math.min;
  function s(o, u, l) {
    var f, c, v, h, d, p, g = 0, y = !1, b = !1, m = !0;
    if (typeof o != "function")
      throw new TypeError(a);
    u = t(u) || 0, r(l) && (y = !!l.leading, b = "maxWait" in l, v = b ? n(t(l.maxWait) || 0, u) : v, m = "trailing" in l ? !!l.trailing : m);
    function E(R) {
      var I = f, O = c;
      return f = c = void 0, g = R, h = o.apply(O, I), h;
    }
    function x(R) {
      return g = R, d = setTimeout(T, u), y ? E(R) : h;
    }
    function S(R) {
      var I = R - p, O = R - g, N = u - I;
      return b ? i(N, v - O) : N;
    }
    function w(R) {
      var I = R - p, O = R - g;
      return p === void 0 || I >= u || I < 0 || b && O >= v;
    }
    function T() {
      var R = e();
      if (w(R))
        return C(R);
      d = setTimeout(T, S(R));
    }
    function C(R) {
      return d = void 0, m && f ? E(R) : (f = c = void 0, h);
    }
    function D() {
      d !== void 0 && clearTimeout(d), g = 0, f = p = c = d = void 0;
    }
    function A() {
      return d === void 0 ? h : C(e());
    }
    function L() {
      var R = e(), I = w(R);
      if (f = arguments, c = this, p = R, I) {
        if (d === void 0)
          return x(p);
        if (b)
          return clearTimeout(d), d = setTimeout(T, u), E(p);
      }
      return d === void 0 && (d = setTimeout(T, u)), h;
    }
    return L.cancel = D, L.flush = A, L;
  }
  return di = s, di;
}
var rh = th(), _a = /* @__PURE__ */ ka(rh), gi = Je ? Je.performance : null, yf = gi && gi.now ? function() {
  return gi.now();
} : function() {
  return Date.now();
}, ah = function() {
  if (Je) {
    if (Je.requestAnimationFrame)
      return function(r) {
        Je.requestAnimationFrame(r);
      };
    if (Je.mozRequestAnimationFrame)
      return function(r) {
        Je.mozRequestAnimationFrame(r);
      };
    if (Je.webkitRequestAnimationFrame)
      return function(r) {
        Je.webkitRequestAnimationFrame(r);
      };
    if (Je.msRequestAnimationFrame)
      return function(r) {
        Je.msRequestAnimationFrame(r);
      };
  }
  return function(r) {
    r && setTimeout(function() {
      r(yf());
    }, 1e3 / 60);
  };
}(), Tn = function(e) {
  return ah(e);
}, Zt = yf, Cr = 9261, mf = 65599, Hr = 5381, bf = function(e) {
  for (var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Cr, a = t, n; n = e.next(), !n.done; )
    a = a * mf + n.value | 0;
  return a;
}, Ta = function(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Cr;
  return t * mf + e | 0;
}, Ca = function(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Hr;
  return (t << 5) + t + e | 0;
}, nh = function(e, t) {
  return e * 2097152 + t;
}, tr = function(e) {
  return e[0] * 2097152 + e[1];
}, Ka = function(e, t) {
  return [Ta(e[0], t[0]), Ca(e[1], t[1])];
}, Wo = function(e, t) {
  var a = {
    value: 0,
    done: !1
  }, n = 0, i = e.length, s = {
    next: function() {
      return n < i ? a.value = e[n++] : a.done = !0, a;
    }
  };
  return bf(s, t);
}, Ar = function(e, t) {
  var a = {
    value: 0,
    done: !1
  }, n = 0, i = e.length, s = {
    next: function() {
      return n < i ? a.value = e.charCodeAt(n++) : a.done = !0, a;
    }
  };
  return bf(s, t);
}, wf = function() {
  return ih(arguments);
}, ih = function(e) {
  for (var t, a = 0; a < e.length; a++) {
    var n = e[a];
    a === 0 ? t = Ar(n) : t = Ar(n, t);
  }
  return t;
}, Ko = !0, sh = console.warn != null, oh = console.trace != null, io = Number.MAX_SAFE_INTEGER || 9007199254740991, Ef = function() {
  return !0;
}, Cn = function() {
  return !1;
}, Zo = function() {
  return 0;
}, so = function() {
}, qe = function(e) {
  throw new Error(e);
}, xf = function(e) {
  if (e !== void 0)
    Ko = !!e;
  else
    return Ko;
}, Pe = function(e) {
  xf() && (sh ? console.warn(e) : (console.log(e), oh && console.trace()));
}, uh = function(e) {
  return de({}, e);
}, Ut = function(e) {
  return e == null ? e : _e(e) ? e.slice() : Re(e) ? uh(e) : e;
}, lh = function(e) {
  return e.slice();
}, Tf = function(e, t) {
  for (
    // loop :)
    t = e = "";
    // b - result , a - numeric letiable
    e++ < 36;
    //
    t += 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 t;
}, fh = {}, Cf = function() {
  return fh;
}, vt = function(e) {
  var t = Object.keys(e);
  return function(a) {
    for (var n = {}, i = 0; i < t.length; i++) {
      var s = t[i], o = a == null ? void 0 : a[s];
      n[s] = o === void 0 ? e[s] : o;
    }
    return n;
  };
}, or = function(e, t, a) {
  for (var n = e.length - 1; n >= 0; n--)
    e[n] === t && e.splice(n, 1);
}, oo = function(e) {
  e.splice(0, e.length);
}, ch = function(e, t) {
  for (var a = 0; a < t.length; a++) {
    var n = t[a];
    e.push(n);
  }
}, Tt = function(e, t, a) {
  return a && (t = cf(a, t)), e[t];
}, Wt = function(e, t, a, n) {
  a && (t = cf(a, t)), e[t] = n;
}, vh = /* @__PURE__ */ function() {
  function r() {
    hr(this, r), this._obj = {};
  }
  return dr(r, [{
    key: "set",
    value: function(t, a) {
      return this._obj[t] = a, this;
    }
  }, {
    key: "delete",
    value: function(t) {
      return this._obj[t] = void 0, this;
    }
  }, {
    key: "clear",
    value: function() {
      this._obj = {};
    }
  }, {
    key: "has",
    value: function(t) {
      return this._obj[t] !== void 0;
    }
  }, {
    key: "get",
    value: function(t) {
      return this._obj[t];
    }
  }]);
}(), Kt = typeof Map < "u" ? Map : vh, hh = "undefined", dh = /* @__PURE__ */ function() {
  function r(e) {
    if (hr(this, r), this._obj = /* @__PURE__ */ Object.create(null), this.size = 0, e != null) {
      var t;
      e.instanceString != null && e.instanceString() === this.instanceString() ? t = e.toArray() : t = e;
      for (var a = 0; a < t.length; a++)
        this.add(t[a]);
    }
  }
  return dr(r, [{
    key: "instanceString",
    value: function() {
      return "set";
    }
  }, {
    key: "add",
    value: function(t) {
      var a = this._obj;
      a[t] !== 1 && (a[t] = 1, this.size++);
    }
  }, {
    key: "delete",
    value: function(t) {
      var a = this._obj;
      a[t] === 1 && (a[t] = 0, this.size--);
    }
  }, {
    key: "clear",
    value: function() {
      this._obj = /* @__PURE__ */ Object.create(null);
    }
  }, {
    key: "has",
    value: function(t) {
      return this._obj[t] === 1;
    }
  }, {
    key: "toArray",
    value: function() {
      var t = this;
      return Object.keys(this._obj).filter(function(a) {
        return t.has(a);
      });
    }
  }, {
    key: "forEach",
    value: function(t, a) {
      return this.toArray().forEach(t, a);
    }
  }]);
}(), ra = (typeof Set > "u" ? "undefined" : rt(Set)) !== hh ? Set : dh, Fn = function(e, t) {
  var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0;
  if (e === void 0 || t === void 0 || !ro(e)) {
    qe("An element must have a core reference and parameters set");
    return;
  }
  var n = t.group;
  if (n == null && (t.data && t.data.source != null && t.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: t.data || {},
    // data object
    position: t.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: !!t.selected,
    // whether it's selected
    selectable: t.selectable === void 0 ? !0 : !!t.selectable,
    // whether it's selectable
    locked: !!t.locked,
    // whether the element is locked (cannot be moved)
    grabbed: !1,
    // whether the element is grabbed by the mouse; renderer sets this privately
    grabbable: t.grabbable === void 0 ? !0 : !!t.grabbable,
    // whether the element can be grabbed
    pannable: t.pannable === void 0 ? n === "edges" : !!t.pannable,
    // whether the element has passthrough panning enabled
    active: !1,
    // whether the element is active from user interaction
    classes: new ra(),
    // map ( className => true )
    animation: {
      // object for currently-running animations
      current: [],
      queue: []
    },
    rscratch: {},
    // object in which the renderer can store information
    scratch: t.scratch || {},
    // scratch objects
    edges: [],
    // array of connected edges
    children: [],
    // array of children
    parent: t.parent && t.parent.isNode() ? t.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), t.renderedPosition) {
    var s = t.renderedPosition, o = e.pan(), u = e.zoom();
    i.position = {
      x: (s.x - o.x) / u,
      y: (s.y - o.y) / u
    };
  }
  var l = [];
  _e(t.classes) ? l = t.classes : ce(t.classes) && (l = t.classes.split(/\s+/));
  for (var f = 0, c = l.length; f < c; f++) {
    var v = l[f];
    !v || v === "" || i.classes.add(v);
  }
  this.createEmitter(), (a === void 0 || a) && this.restore();
  var h = t.style || t.css;
  h && (Pe("Setting a `style` bypass at element creation should be done only when absolutely necessary.  Try to use the stylesheet instead."), this.style(h));
}, Qo = function(e) {
  return e = {
    bfs: e.bfs || !e.dfs,
    dfs: e.dfs || !e.bfs
  }, function(a, n, i) {
    var s;
    Re(a) && !At(a) && (s = a, a = s.roots || s.root, n = s.visit, i = s.directed), i = arguments.length === 2 && !He(n) ? n : i, n = He(n) ? n : function() {
    };
    for (var o = this._private.cy, u = a = ce(a) ? this.filter(a) : a, l = [], f = [], c = {}, v = {}, h = {}, d = 0, p, g = this.byGroup(), y = g.nodes, b = g.edges, m = 0; m < u.length; m++) {
      var E = u[m], x = E.id();
      E.isNode() && (l.unshift(E), e.bfs && (h[x] = !0, f.push(E)), v[x] = 0);
    }
    for (var S = function() {
      var R = e.bfs ? l.shift() : l.pop(), I = R.id();
      if (e.dfs) {
        if (h[I])
          return 0;
        h[I] = !0, f.push(R);
      }
      var O = v[I], N = c[I], k = N != null ? N.source() : null, P = N != null ? N.target() : null, B = N == null ? void 0 : R.same(k) ? P[0] : k[0], _;
      if (_ = n(R, N, B, d++, O), _ === !0)
        return p = R, 1;
      if (_ === !1)
        return 1;
      for (var F = R.connectedEdges().filter(function(X) {
        return (!i || X.source().same(R)) && b.has(X);
      }), G = 0; G < F.length; G++) {
        var U = F[G], H = U.connectedNodes().filter(function(X) {
          return !X.same(R) && y.has(X);
        }), $ = H.id();
        H.length !== 0 && !h[$] && (H = H[0], l.push(H), e.bfs && (h[$] = !0, f.push(H)), c[$] = U, v[$] = v[I] + 1);
      }
    }, w; l.length !== 0 && (w = S(), !(w !== 0 && w === 1)); )
      ;
    for (var T = o.collection(), C = 0; C < f.length; C++) {
      var D = f[C], A = c[D.id()];
      A != null && T.push(A), T.push(D);
    }
    return {
      path: o.collection(T),
      found: o.collection(p)
    };
  };
}, Da = {
  breadthFirstSearch: Qo({
    bfs: !0
  }),
  depthFirstSearch: Qo({
    dfs: !0
  })
};
Da.bfs = Da.breadthFirstSearch;
Da.dfs = Da.depthFirstSearch;
var un = { exports: {} }, gh = un.exports, Jo;
function ph() {
  return Jo || (Jo = 1, function(r, e) {
    (function() {
      var t, a, n, i, s, o, u, l, f, c, v, h, d, p, g;
      n = Math.floor, c = Math.min, a = function(y, b) {
        return y < b ? -1 : y > b ? 1 : 0;
      }, f = function(y, b, m, E, x) {
        var S;
        if (m == null && (m = 0), x == null && (x = a), m < 0)
          throw new Error("lo must be non-negative");
        for (E == null && (E = y.length); m < E; )
          S = n((m + E) / 2), x(b, y[S]) < 0 ? E = S : m = S + 1;
        return [].splice.apply(y, [m, m - m].concat(b)), b;
      }, o = function(y, b, m) {
        return m == null && (m = a), y.push(b), p(y, 0, y.length - 1, m);
      }, s = function(y, b) {
        var m, E;
        return b == null && (b = a), m = y.pop(), y.length ? (E = y[0], y[0] = m, g(y, 0, b)) : E = m, E;
      }, l = function(y, b, m) {
        var E;
        return m == null && (m = a), E = y[0], y[0] = b, g(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], g(y, 0, m)), b;
      }, i = function(y, b) {
        var m, E, x, S, w, T;
        for (b == null && (b = a), S = (function() {
          T = [];
          for (var C = 0, D = n(y.length / 2); 0 <= D ? C < D : C > D; 0 <= D ? C++ : C--)
            T.push(C);
          return T;
        }).apply(this).reverse(), w = [], E = 0, x = S.length; E < x; E++)
          m = S[E], w.push(g(y, m, b));
        return w;
      }, d = function(y, b, m) {
        var E;
        if (m == null && (m = a), E = y.indexOf(b), E !== -1)
          return p(y, 0, E, m), g(y, E, m);
      }, v = function(y, b, m) {
        var E, x, S, w, T;
        if (m == null && (m = a), x = y.slice(0, b), !x.length)
          return x;
        for (i(x, m), T = y.slice(b), S = 0, w = T.length; S < w; S++)
          E = T[S], u(x, E, m);
        return x.sort(m).reverse();
      }, h = function(y, b, m) {
        var E, x, S, w, T, C, 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 (x = S[S.length - 1], D = y.slice(b), w = 0, C = D.length; w < C; w++)
            E = D[w], m(E, x) < 0 && (f(S, E, 0, null, m), S.pop(), x = S[S.length - 1]);
          return S;
        }
        for (i(y, m), L = [], T = 0, A = c(b, y.length); 0 <= A ? T < A : T > A; 0 <= A ? ++T : --T)
          L.push(s(y, m));
        return L;
      }, p = function(y, b, m, E) {
        var x, S, w;
        for (E == null && (E = a), x = y[m]; m > b; ) {
          if (w = m - 1 >> 1, S = y[w], E(x, S) < 0) {
            y[m] = S, m = w;
            continue;
          }
          break;
        }
        return y[m] = x;
      }, g = function(y, b, m) {
        var E, x, S, w, T;
        for (m == null && (m = a), x = y.length, T = b, S = y[b], E = 2 * b + 1; E < x; )
          w = E + 1, w < x && !(m(y[E], y[w]) < 0) && (E = w), y[b] = y[E], b = E, E = 2 * b + 1;
        return y[b] = S, p(y, T, b, m);
      }, t = function() {
        y.push = o, y.pop = s, y.replace = l, y.pushpop = u, y.heapify = i, y.updateItem = d, y.nlargest = v, y.nsmallest = h;
        function y(b) {
          this.cmp = b ?? a, this.nodes = [];
        }
        return y.prototype.push = function(b) {
          return o(this.nodes, b, this.cmp);
        }, y.prototype.pop = function() {
          return s(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 r.exports = b();
      }(this, function() {
        return t;
      });
    }).call(gh);
  }(un)), un.exports;
}
var pi, jo;
function yh() {
  return jo || (jo = 1, pi = ph()), pi;
}
var mh = yh(), Ga = /* @__PURE__ */ ka(mh), bh = vt({
  root: null,
  weight: function(e) {
    return 1;
  },
  directed: !1
}), wh = {
  dijkstra: function(e) {
    if (!Re(e)) {
      var t = arguments;
      e = {
        root: t[0],
        weight: t[1],
        directed: t[2]
      };
    }
    var a = bh(e), n = a.root, i = a.weight, s = a.directed, o = this, u = i, l = ce(n) ? this.filter(n)[0] : n[0], f = {}, c = {}, v = {}, h = this.byGroup(), d = h.nodes, p = h.edges;
    p.unmergeBy(function(O) {
      return O.isLoop();
    });
    for (var g = function(N) {
      return f[N.id()];
    }, y = function(N, k) {
      f[N.id()] = k, b.updateItem(N);
    }, b = new Ga(function(O, N) {
      return g(O) - g(N);
    }), m = 0; m < d.length; m++) {
      var E = d[m];
      f[E.id()] = E.same(l) ? 0 : 1 / 0, b.push(E);
    }
    for (var x = function(N, k) {
      for (var P = (s ? N.edgesTo(k) : N.edgesWith(k)).intersect(p), B = 1 / 0, _, F = 0; F < P.length; F++) {
        var G = P[F], U = u(G);
        (U < B || !_) && (B = U, _ = G);
      }
      return {
        edge: _,
        dist: B
      };
    }; b.size() > 0; ) {
      var S = b.pop(), w = g(S), T = S.id();
      if (v[T] = w, w !== 1 / 0)
        for (var C = S.neighborhood().intersect(d), D = 0; D < C.length; D++) {
          var A = C[D], L = A.id(), R = x(S, A), I = w + R.dist;
          I < g(A) && (y(A, I), c[L] = {
            node: S,
            edge: R.edge
          });
        }
    }
    return {
      distanceTo: function(N) {
        var k = ce(N) ? d.filter(N)[0] : N[0];
        return v[k.id()];
      },
      pathTo: function(N) {
        var k = ce(N) ? d.filter(N)[0] : N[0], P = [], B = k, _ = B.id();
        if (k.length > 0)
          for (P.unshift(k); c[_]; ) {
            var F = c[_];
            P.unshift(F.edge), P.unshift(F.node), B = F.node, _ = B.id();
          }
        return o.spawn(P);
      }
    };
  }
}, Eh = {
  // 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 t = this.byGroup(), a = t.nodes, n = t.edges, i = a.length, s = new Array(i), o = a, u = function(E) {
      for (var x = 0; x < s.length; x++) {
        var S = s[x];
        if (S.has(E))
          return x;
      }
    }, l = 0; l < i; l++)
      s[l] = this.spawn(a[l]);
    for (var f = n.sort(function(m, E) {
      return e(m) - e(E);
    }), c = 0; c < f.length; c++) {
      var v = f[c], h = v.source()[0], d = v.target()[0], p = u(h), g = u(d), y = s[p], b = s[g];
      p !== g && (o.merge(v), y.merge(b), s.splice(g, 1));
    }
    return o;
  }
}, xh = vt({
  root: null,
  goal: null,
  weight: function(e) {
    return 1;
  },
  heuristic: function(e) {
    return 0;
  },
  directed: !1
}), Th = {
  // Implemented from pseudocode from wikipedia
  aStar: function(e) {
    var t = this.cy(), a = xh(e), n = a.root, i = a.goal, s = a.heuristic, o = a.directed, u = a.weight;
    n = t.collection(n)[0], i = t.collection(i)[0];
    var l = n.id(), f = i.id(), c = {}, v = {}, h = {}, d = new Ga(function(_, F) {
      return v[_.id()] - v[F.id()];
    }), p = new ra(), g = {}, y = {}, b = function(F, G) {
      d.push(F), p.add(G);
    }, m, E, x = function() {
      m = d.pop(), E = m.id(), p.delete(E);
    }, S = function(F) {
      return p.has(F);
    };
    b(n, l), c[l] = 0, v[l] = s(n);
    for (var w = 0; d.size() > 0; ) {
      if (x(), w++, E === f) {
        for (var T = [], C = i, D = f, A = y[D]; T.unshift(C), A != null && T.unshift(A), C = g[D], C != null; )
          D = C.id(), A = y[D];
        return {
          found: !0,
          distance: c[E],
          path: this.spawn(T),
          steps: w
        };
      }
      h[E] = !0;
      for (var L = m._private.edges, R = 0; R < L.length; R++) {
        var I = L[R];
        if (this.hasElementWithId(I.id()) && !(o && I.data("source") !== E)) {
          var O = I.source(), N = I.target(), k = O.id() !== E ? O : N, P = k.id();
          if (this.hasElementWithId(P) && !h[P]) {
            var B = c[E] + u(I);
            if (!S(P)) {
              c[P] = B, v[P] = B + s(k), b(k, P), g[P] = m, y[P] = I;
              continue;
            }
            B < c[P] && (c[P] = B, v[P] = B + s(k), g[P] = m, y[P] = I);
          }
        }
      }
    }
    return {
      found: !1,
      distance: void 0,
      path: void 0,
      steps: w
    };
  }
}, Ch = vt({
  weight: function(e) {
    return 1;
  },
  directed: !1
}), Dh = {
  // Implemented from pseudocode from wikipedia
  floydWarshall: function(e) {
    for (var t = this.cy(), a = Ch(e), n = a.weight, i = a.directed, s = n, o = this.byGroup(), u = o.nodes, l = o.edges, f = u.length, c = f * f, v = function(U) {
      return u.indexOf(U);
    }, h = function(U) {
      return u[U];
    }, d = new Array(c), p = 0; p < c; p++) {
      var g = p % f, y = (p - g) / f;
      y === g ? d[p] = 0 : d[p] = 1 / 0;
    }
    for (var b = new Array(c), m = new Array(c), E = 0; E < l.length; E++) {
      var x = l[E], S = x.source()[0], w = x.target()[0];
      if (S !== w) {
        var T = v(S), C = v(w), D = T * f + C, A = s(x);
        if (d[D] > A && (d[D] = A, b[D] = C, m[D] = x), !i) {
          var L = C * f + T;
          !i && d[L] > A && (d[L] = A, b[L] = T, m[L] = x);
        }
      }
    }
    for (var R = 0; R < f; R++)
      for (var I = 0; I < f; I++)
        for (var O = I * f + R, N = 0; N < f; N++) {
          var k = I * f + N, P = R * f + N;
          d[O] + d[P] < d[k] && (d[k] = d[O] + d[P], b[k] = b[O]);
        }
    var B = function(U) {
      return (ce(U) ? t.filter(U) : U)[0];
    }, _ = function(U) {
      return v(B(U));
    }, F = {
      distance: function(U, H) {
        var $ = _(U), X = _(H);
        return d[$ * f + X];
      },
      path: function(U, H) {
        var $ = _(U), X = _(H), Q = h($);
        if ($ === X)
          return Q.collection();
        if (b[$ * f + X] == null)
          return t.collection();
        var re = t.collection(), J = $, z;
        for (re.merge(Q); $ !== X; )
          J = $, $ = b[$ * f + X], z = m[J * f + $], re.merge(z), re.merge(h($));
        return re;
      }
    };
    return F;
  }
  // floydWarshall
}, Sh = vt({
  weight: function(e) {
    return 1;
  },
  directed: !1,
  root: null
}), Ah = {
  // Implemented from pseudocode from wikipedia
  bellmanFord: function(e) {
    var t = this, a = Sh(e), n = a.weight, i = a.directed, s = a.root, o = n, u = this, l = this.cy(), f = this.byGroup(), c = f.edges, v = f.nodes, h = v.length, d = new Kt(), p = !1, g = [];
    s = l.collection(s)[0], c.unmergeBy(function(Ne) {
      return Ne.isLoop();
    });
    for (var y = c.length, b = function(se) {
      var oe = d.get(se.id());
      return oe || (oe = {}, d.set(se.id(), oe)), oe;
    }, m = function(se) {
      return (ce(se) ? l.$(se) : se)[0];
    }, E = function(se) {
      return b(m(se)).dist;
    }, x = function(se) {
      for (var oe = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : s, ve = m(se), ge = [], he = ve; ; ) {
        if (he == null)
          return t.spawn();
        var ye = b(he), we = ye.edge, Se = ye.pred;
        if (ge.unshift(he[0]), he.same(oe) && ge.length > 0)
          break;
        we != null && ge.unshift(we), he = Se;
      }
      return u.spawn(ge);
    }, S = 0; S < h; S++) {
      var w = v[S], T = b(w);
      w.same(s) ? T.dist = 0 : T.dist = 1 / 0, T.pred = null, T.edge = null;
    }
    for (var C = !1, D = function(se, oe, ve, ge, he, ye) {
      var we = ge.dist + ye;
      we < he.dist && !ve.same(ge.edge) && (he.dist = we, he.pred = se, he.edge = ve, C = !0);
    }, A = 1; A < h; A++) {
      C = !1;
      for (var L = 0; L < y; L++) {
        var R = c[L], I = R.source(), O = R.target(), N = o(R), k = b(I), P = b(O);
        D(I, O, R, k, P, N), i || D(O, I, R, P, k, N);
      }
      if (!C)
        break;
    }
    if (C)
      for (var B = [], _ = 0; _ < y; _++) {
        var F = c[_], G = F.source(), U = F.target(), H = o(F), $ = b(G).dist, X = b(U).dist;
        if ($ + H < X || !i && X + H < $)
          if (p || (Pe("Graph contains a negative weight cycle for Bellman-Ford"), p = !0), e.findNegativeWeightCycles !== !1) {
            var Q = [];
            $ + H < X && Q.push(G), !i && X + H < $ && Q.push(U);
            for (var re = Q.length, J = 0; J < re; J++) {
              var z = Q[J], V = [z];
              V.push(b(z).edge);
              for (var Y = b(z).pred; V.indexOf(Y) === -1; )
                V.push(Y), V.push(b(Y).edge), Y = b(Y).pred;
              V = V.slice(V.indexOf(Y));
              for (var ee = V[0].id(), ne = 0, be = 2; be < V.length; be += 2)
                V[be].id() < ee && (ee = V[be].id(), ne = be);
              V = V.slice(ne).concat(V.slice(0, ne)), V.push(V[0]);
              var Ve = V.map(function(Ne) {
                return Ne.id();
              }).join(",");
              B.indexOf(Ve) === -1 && (g.push(u.spawn(V)), B.push(Ve));
            }
          } else
            break;
      }
    return {
      distanceTo: E,
      pathTo: x,
      hasNegativeWeightCycle: p,
      negativeWeightCycles: g
    };
  }
  // bellmanFord
}, Lh = Math.sqrt(2), Rh = function(e, t, a) {
  a.length === 0 && qe("Karger-Stein must be run on a connected (sub)graph");
  for (var n = a[e], i = n[1], s = n[2], o = t[i], u = t[s], l = a, f = l.length - 1; f >= 0; f--) {
    var c = l[f], v = c[1], h = c[2];
    (t[v] === o && t[h] === u || t[v] === u && t[h] === o) && l.splice(f, 1);
  }
  for (var d = 0; d < l.length; d++) {
    var p = l[d];
    p[1] === u ? (l[d] = p.slice(), l[d][1] = o) : p[2] === u && (l[d] = p.slice(), l[d][2] = o);
  }
  for (var g = 0; g < t.length; g++)
    t[g] === u && (t[g] = o);
  return l;
}, yi = function(e, t, a, n) {
  for (; a > n; ) {
    var i = Math.floor(Math.random() * t.length);
    t = Rh(i, e, t), a--;
  }
  return t;
}, Ih = {
  // Computes the minimum cut of an undirected graph
  // Returns the correct answer with high probability
  kargerStein: function() {
    var e = this, t = this.byGroup(), a = t.nodes, n = t.edges;
    n.unmergeBy(function(P) {
      return P.isLoop();
    });
    var i = a.length, s = n.length, o = Math.ceil(Math.pow(Math.log(i) / Math.LN2, 2)), u = Math.floor(i / Lh);
    if (i < 2) {
      qe("At least 2 nodes are required for Karger-Stein algorithm");
      return;
    }
    for (var l = [], f = 0; f < s; f++) {
      var c = n[f];
      l.push([f, a.indexOf(c.source()), a.indexOf(c.target())]);
    }
    for (var v = 1 / 0, h = [], d = new Array(i), p = new Array(i), g = new Array(i), y = function(B, _) {
      for (var F = 0; F < i; F++)
        _[F] = B[F];
    }, b = 0; b <= o; b++) {
      for (var m = 0; m < i; m++)
        p[m] = m;
      var E = yi(p, l.slice(), i, u), x = E.slice();
      y(p, g);
      var S = yi(p, E, u, 2), w = yi(g, x, u, 2);
      S.length <= w.length && S.length < v ? (v = S.length, h = S, y(p, d)) : w.length <= S.length && w.length < v && (v = w.length, h = w, y(g, d));
    }
    for (var T = this.spawn(h.map(function(P) {
      return n[P[0]];
    })), C = this.spawn(), D = this.spawn(), A = d[0], L = 0; L < d.length; L++) {
      var R = d[L], I = a[L];
      R === A ? C.merge(I) : D.merge(I);
    }
    var O = function(B) {
      var _ = e.spawn();
      return B.forEach(function(F) {
        _.merge(F), F.connectedEdges().forEach(function(G) {
          e.contains(G) && !T.contains(G) && _.merge(G);
        });
      }), _;
    }, N = [O(C), O(D)], k = {
      cut: T,
      components: N,
      // n.b. partitions are included to be compatible with the old api spec
      // (could be removed in a future major version)
      partition1: C,
      partition2: D
    };
    return k;
  }
}, Mh = function(e) {
  return {
    x: e.x,
    y: e.y
  };
}, _n = function(e, t, a) {
  return {
    x: e.x * t + a.x,
    y: e.y * t + a.y
  };
}, Df = function(e, t, a) {
  return {
    x: (e.x - a.x) / t,
    y: (e.y - a.y) / t
  };
}, Yr = function(e) {
  return {
    x: e[0],
    y: e[1]
  };
}, Oh = function(e) {
  for (var t = 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 = t; i < a; i++) {
    var s = e[i];
    isFinite(s) && (n = Math.min(s, n));
  }
  return n;
}, Ph = function(e) {
  for (var t = 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 = t; i < a; i++) {
    var s = e[i];
    isFinite(s) && (n = Math.max(s, n));
  }
  return n;
}, Nh = function(e) {
  for (var t = 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, s = t; s < a; s++) {
    var o = e[s];
    isFinite(o) && (n += o, i++);
  }
  return n / i;
}, kh = function(e) {
  var t = 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, s = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0;
  n ? e = e.slice(t, a) : (a < e.length && e.splice(a, e.length - a), t > 0 && e.splice(0, t));
  for (var o = 0, u = e.length - 1; u >= 0; u--) {
    var l = e[u];
    s ? isFinite(l) || (e[u] = -1 / 0, o++) : e.splice(u, 1);
  }
  i && e.sort(function(v, h) {
    return v - h;
  });
  var f = e.length, c = Math.floor(f / 2);
  return f % 2 !== 0 ? e[c + 1 + o] : (e[c - 1 + o] + e[c + o]) / 2;
}, Bh = function(e) {
  return Math.PI * e / 180;
}, Za = function(e, t) {
  return Math.atan2(t, e) - Math.PI / 2;
}, uo = Math.log2 || function(r) {
  return Math.log(r) / Math.log(2);
}, lo = function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Lr = function(e, t) {
  return Math.sqrt(Er(e, t));
}, Er = function(e, t) {
  var a = t.x - e.x, n = t.y - e.y;
  return a * a + n * n;
}, Fh = function(e) {
  for (var t = e.length, a = 0, n = 0; n < t; n++)
    a += e[n];
  for (var i = 0; i < t; i++)
    e[i] = e[i] / a;
  return e;
}, it = function(e, t, a, n) {
  return (1 - n) * (1 - n) * e + 2 * (1 - n) * n * t + n * n * a;
}, Wr = function(e, t, a, n) {
  return {
    x: it(e.x, t.x, a.x, n),
    y: it(e.y, t.y, a.y, n)
  };
}, _h = function(e, t, a, n) {
  var i = {
    x: t.x - e.x,
    y: t.y - e.y
  }, s = Lr(e, t), o = {
    x: i.x / s,
    y: i.y / s
  };
  return a = a ?? 0, n = n ?? a * s, {
    x: e.x + o.x * n,
    y: e.y + o.y * n
  };
}, Sa = function(e, t, a) {
  return Math.max(e, Math.min(a, t));
}, St = 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
      };
  }
}, Gh = function(e) {
  return {
    x1: e.x1,
    x2: e.x2,
    w: e.w,
    y1: e.y1,
    y2: e.y2,
    h: e.h
  };
}, zh = function(e) {
  e.x1 = 1 / 0, e.y1 = 1 / 0, e.x2 = -1 / 0, e.y2 = -1 / 0, e.w = 0, e.h = 0;
}, Vh = function(e, t, a) {
  return {
    x1: e.x1 + t,
    x2: e.x2 + t,
    y1: e.y1 + a,
    y2: e.y2 + a,
    w: e.w,
    h: e.h
  };
}, Sf = function(e, t) {
  e.x1 = Math.min(e.x1, t.x1), e.x2 = Math.max(e.x2, t.x2), e.w = e.x2 - e.x1, e.y1 = Math.min(e.y1, t.y1), e.y2 = Math.max(e.y2, t.y2), e.h = e.y2 - e.y1;
}, Uh = function(e, t, a) {
  e.x1 = Math.min(e.x1, t), e.x2 = Math.max(e.x2, t), 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;
}, ln = function(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
  return e.x1 -= t, e.x2 += t, e.y1 -= t, e.y2 += t, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1, e;
}, fn = function(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0], a, n, i, s;
  if (t.length === 1)
    a = n = i = s = t[0];
  else if (t.length === 2)
    a = i = t[0], s = n = t[1];
  else if (t.length === 4) {
    var o = je(t, 4);
    a = o[0], n = o[1], i = o[2], s = o[3];
  }
  return e.x1 -= s, e.x2 += n, e.y1 -= a, e.y2 += i, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1, e;
}, eu = function(e, t) {
  e.x1 = t.x1, e.y1 = t.y1, e.x2 = t.x2, e.y2 = t.y2, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1;
}, fo = function(e, t) {
  return !(e.x1 > t.x2 || t.x1 > e.x2 || e.x2 < t.x1 || t.x2 < e.x1 || e.y2 < t.y1 || t.y2 < e.y1 || e.y1 > t.y2 || t.y1 > e.y2);
}, jr = function(e, t, a) {
  return e.x1 <= t && t <= e.x2 && e.y1 <= a && a <= e.y2;
}, qh = function(e, t) {
  return jr(e, t.x, t.y);
}, Hh = function(e, t) {
  return jr(e, t.x1, t.y1) && jr(e, t.x2, t.y2);
}, Af = function(e, t, a, n, i, s, o) {
  var u = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : "auto", l = u === "auto" ? ur(i, s) : u, f = i / 2, c = s / 2;
  l = Math.min(l, f, c);
  var v = l !== f, h = l !== c, d;
  if (v) {
    var p = a - f + l - o, g = n - c - o, y = a + f - l + o, b = g;
    if (d = ar(e, t, a, n, p, g, y, b, !1), d.length > 0)
      return d;
  }
  if (h) {
    var m = a + f + o, E = n - c + l - o, x = m, S = n + c - l + o;
    if (d = ar(e, t, a, n, m, E, x, S, !1), d.length > 0)
      return d;
  }
  if (v) {
    var w = a - f + l - o, T = n + c + o, C = a + f - l + o, D = T;
    if (d = ar(e, t, a, n, w, T, C, D, !1), d.length > 0)
      return d;
  }
  if (h) {
    var A = a - f - o, L = n - c + l - o, R = A, I = n + c - l + o;
    if (d = ar(e, t, a, n, A, L, R, I, !1), d.length > 0)
      return d;
  }
  var O;
  {
    var N = a - f + l, k = n - c + l;
    if (O = ya(e, t, a, n, N, k, l + o), O.length > 0 && O[0] <= N && O[1] <= k)
      return [O[0], O[1]];
  }
  {
    var P = a + f - l, B = n - c + l;
    if (O = ya(e, t, a, n, P, B, l + o), O.length > 0 && O[0] >= P && O[1] <= B)
      return [O[0], O[1]];
  }
  {
    var _ = a + f - l, F = n + c - l;
    if (O = ya(e, t, a, n, _, F, l + o), O.length > 0 && O[0] >= _ && O[1] >= F)
      return [O[0], O[1]];
  }
  {
    var G = a - f + l, U = n + c - l;
    if (O = ya(e, t, a, n, G, U, l + o), O.length > 0 && O[0] <= G && O[1] >= U)
      return [O[0], O[1]];
  }
  return [];
}, Yh = function(e, t, a, n, i, s, o) {
  var u = o, l = Math.min(a, i), f = Math.max(a, i), c = Math.min(n, s), v = Math.max(n, s);
  return l - u <= e && e <= f + u && c - u <= t && t <= v + u;
}, Xh = function(e, t, a, n, i, s, o, u, l) {
  var f = {
    x1: Math.min(a, o, i) - l,
    x2: Math.max(a, o, i) + l,
    y1: Math.min(n, u, s) - l,
    y2: Math.max(n, u, s) + l
  };
  return !(e < f.x1 || e > f.x2 || t < f.y1 || t > f.y2);
}, $h = function(e, t, a, n) {
  a -= n;
  var i = t * t - 4 * e * a;
  if (i < 0)
    return [];
  var s = Math.sqrt(i), o = 2 * e, u = (-t + s) / o, l = (-t - s) / o;
  return [u, l];
}, Wh = function(e, t, a, n, i) {
  var s = 1e-5;
  e === 0 && (e = s), t /= e, a /= e, n /= e;
  var o, u, l, f, c, v, h, d;
  if (u = (3 * a - t * t) / 9, l = -(27 * n) + t * (9 * a - 2 * (t * t)), l /= 54, o = u * u * u + l * l, i[1] = 0, h = t / 3, o > 0) {
    c = l + Math.sqrt(o), c = c < 0 ? -Math.pow(-c, 1 / 3) : Math.pow(c, 1 / 3), v = l - Math.sqrt(o), v = v < 0 ? -Math.pow(-v, 1 / 3) : Math.pow(v, 1 / 3), i[0] = -h + c + v, h += (c + v) / 2, i[4] = i[2] = -h, h = Math.sqrt(3) * (-v + c) / 2, i[3] = h, i[5] = -h;
    return;
  }
  if (i[5] = i[3] = 0, o === 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);
}, Kh = function(e, t, a, n, i, s, o, u) {
  var l = 1 * a * a - 4 * a * i + 2 * a * o + 4 * i * i - 4 * i * o + o * o + n * n - 4 * n * s + 2 * n * u + 4 * s * s - 4 * s * u + u * u, f = 1 * 9 * a * i - 3 * a * a - 3 * a * o - 6 * i * i + 3 * i * o + 9 * n * s - 3 * n * n - 3 * n * u - 6 * s * s + 3 * s * u, c = 1 * 3 * a * a - 6 * a * i + a * o - a * e + 2 * i * i + 2 * i * e - o * e + 3 * n * n - 6 * n * s + n * u - n * t + 2 * s * s + 2 * s * t - u * t, v = 1 * a * i - a * a + a * e - i * e + n * s - n * n + n * t - s * t, h = [];
  Wh(l, f, c, v, h);
  for (var d = 1e-7, p = [], g = 0; g < 6; g += 2)
    Math.abs(h[g + 1]) < d && h[g] >= 0 && h[g] <= 1 && p.push(h[g]);
  p.push(1), p.push(0);
  for (var y = -1, b, m, E, x = 0; x < p.length; x++)
    b = Math.pow(1 - p[x], 2) * a + 2 * (1 - p[x]) * p[x] * i + p[x] * p[x] * o, m = Math.pow(1 - p[x], 2) * n + 2 * (1 - p[x]) * p[x] * s + p[x] * p[x] * u, E = Math.pow(b - e, 2) + Math.pow(m - t, 2), y >= 0 ? E < y && (y = E) : y = E;
  return y;
}, Zh = function(e, t, a, n, i, s) {
  var o = [e - a, t - n], u = [i - a, s - n], l = u[0] * u[0] + u[1] * u[1], f = o[0] * o[0] + o[1] * o[1], c = o[0] * u[0] + o[1] * u[1], v = c * c / l;
  return c < 0 ? f : v > l ? (e - i) * (e - i) + (t - s) * (t - s) : f - v;
}, Ct = function(e, t, a) {
  for (var n, i, s, o, 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 ? (s = a[(f + 1) * 2], o = a[(f + 1) * 2 + 1]) : (s = a[(f + 1 - a.length / 2) * 2], o = a[(f + 1 - a.length / 2) * 2 + 1]), !(n == e && s == e))
      if (n >= e && e >= s || n <= e && e <= s)
        u = (e - n) / (s - n) * (o - i) + i, u > t && l++;
      else
        continue;
  return l % 2 !== 0;
}, Qt = function(e, t, a, n, i, s, o, u, l) {
  var f = new Array(a.length), c;
  u[0] != null ? (c = Math.atan(u[1] / u[0]), u[0] < 0 ? c = c + Math.PI / 2 : c = -c - Math.PI / 2) : c = u;
  for (var v = Math.cos(-c), h = Math.sin(-c), d = 0; d < f.length / 2; d++)
    f[d * 2] = s / 2 * (a[d * 2] * v - a[d * 2 + 1] * h), f[d * 2 + 1] = o / 2 * (a[d * 2 + 1] * v + a[d * 2] * h), f[d * 2] += n, f[d * 2 + 1] += i;
  var p;
  if (l > 0) {
    var g = Sn(f, -l);
    p = Dn(g);
  } else
    p = f;
  return Ct(e, t, p);
}, Qh = function(e, t, a, n, i, s, o, u) {
  for (var l = new Array(a.length * 2), f = 0; f < u.length; f++) {
    var c = u[f];
    l[f * 4 + 0] = c.startX, l[f * 4 + 1] = c.startY, l[f * 4 + 2] = c.stopX, l[f * 4 + 3] = c.stopY;
    var v = Math.pow(c.cx - e, 2) + Math.pow(c.cy - t, 2);
    if (v <= Math.pow(c.radius, 2))
      return !0;
  }
  return Ct(e, t, l);
}, Dn = function(e) {
  for (var t = new Array(e.length / 2), a, n, i, s, o, u, l, f, c = 0; c < e.length / 4; c++) {
    a = e[c * 4], n = e[c * 4 + 1], i = e[c * 4 + 2], s = e[c * 4 + 3], c < e.length / 4 - 1 ? (o = e[(c + 1) * 4], u = e[(c + 1) * 4 + 1], l = e[(c + 1) * 4 + 2], f = e[(c + 1) * 4 + 3]) : (o = e[0], u = e[1], l = e[2], f = e[3]);
    var v = ar(a, n, i, s, o, u, l, f, !0);
    t[c * 2] = v[0], t[c * 2 + 1] = v[1];
  }
  return t;
}, Sn = function(e, t) {
  for (var a = new Array(e.length * 2), n, i, s, o, u = 0; u < e.length / 2; u++) {
    n = e[u * 2], i = e[u * 2 + 1], u < e.length / 2 - 1 ? (s = e[(u + 1) * 2], o = e[(u + 1) * 2 + 1]) : (s = e[0], o = e[1]);
    var l = o - i, f = -(s - n), c = Math.sqrt(l * l + f * f), v = l / c, h = f / c;
    a[u * 4] = n + v * t, a[u * 4 + 1] = i + h * t, a[u * 4 + 2] = s + v * t, a[u * 4 + 3] = o + h * t;
  }
  return a;
}, Jh = function(e, t, a, n, i, s) {
  var o = a - e, u = n - t;
  o /= i, u /= s;
  var l = Math.sqrt(o * o + u * u), f = l - 1;
  if (f < 0)
    return [];
  var c = f / l;
  return [(a - e) * c + e, (n - t) * c + t];
}, Sr = function(e, t, a, n, i, s, o) {
  return e -= i, t -= s, e /= a / 2 + o, t /= n / 2 + o, e * e + t * t <= 1;
}, ya = function(e, t, a, n, i, s, o) {
  var u = [a - e, n - t], l = [e - i, t - s], f = u[0] * u[0] + u[1] * u[1], c = 2 * (l[0] * u[0] + l[1] * u[1]), v = l[0] * l[0] + l[1] * l[1] - o * o, h = c * c - 4 * f * v;
  if (h < 0)
    return [];
  var d = (-c + Math.sqrt(h)) / (2 * f), p = (-c - Math.sqrt(h)) / (2 * f), g = Math.min(d, p), y = Math.max(d, p), b = [];
  if (g >= 0 && g <= 1 && b.push(g), y >= 0 && y <= 1 && b.push(y), b.length === 0)
    return [];
  var m = b[0] * u[0] + e, E = b[0] * u[1] + t;
  if (b.length > 1) {
    if (b[0] == b[1])
      return [m, E];
    var x = b[1] * u[0] + e, S = b[1] * u[1] + t;
    return [m, E, x, S];
  } else
    return [m, E];
}, mi = function(e, t, a) {
  return t <= e && e <= a || a <= e && e <= t ? e : e <= t && t <= a || a <= t && t <= e ? t : a;
}, ar = function(e, t, a, n, i, s, o, u, l) {
  var f = e - i, c = a - e, v = o - i, h = t - s, d = n - t, p = u - s, g = v * h - p * f, y = c * h - d * f, b = p * c - v * d;
  if (b !== 0) {
    var m = g / b, E = y / b, x = 1e-3, S = 0 - x, w = 1 + x;
    return S <= m && m <= w && S <= E && E <= w ? [e + m * c, t + m * d] : l ? [e + m * c, t + m * d] : [];
  } else
    return g === 0 || y === 0 ? mi(e, a, o) === o ? [o, u] : mi(e, a, i) === i ? [i, s] : mi(i, o, a) === a ? [a, n] : [] : [];
}, Aa = function(e, t, a, n, i, s, o, u) {
  var l = [], f, c = new Array(a.length), v = !0;
  s == null && (v = !1);
  var h;
  if (v) {
    for (var d = 0; d < c.length / 2; d++)
      c[d * 2] = a[d * 2] * s + n, c[d * 2 + 1] = a[d * 2 + 1] * o + i;
    if (u > 0) {
      var p = Sn(c, -u);
      h = Dn(p);
    } else
      h = c;
  } else
    h = a;
  for (var g, y, b, m, E = 0; E < h.length / 2; E++)
    g = 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 = ar(e, t, n, i, g, y, b, m), f.length !== 0 && l.push(f[0], f[1]);
  return l;
}, jh = function(e, t, a, n, i, s, o, u, l) {
  var f = [], c, v = new Array(a.length * 2);
  l.forEach(function(b, m) {
    m === 0 ? (v[v.length - 2] = b.startX, v[v.length - 1] = b.startY) : (v[m * 4 - 2] = b.startX, v[m * 4 - 1] = b.startY), v[m * 4] = b.stopX, v[m * 4 + 1] = b.stopY, c = ya(e, t, n, i, b.cx, b.cy, b.radius), c.length !== 0 && f.push(c[0], c[1]);
  });
  for (var h = 0; h < v.length / 4; h++)
    c = ar(e, t, n, i, v[h * 4], v[h * 4 + 1], v[h * 4 + 2], v[h * 4 + 3], !1), c.length !== 0 && f.push(c[0], c[1]);
  if (f.length > 2) {
    for (var d = [f[0], f[1]], p = Math.pow(d[0] - e, 2) + Math.pow(d[1] - t, 2), g = 1; g < f.length / 2; g++) {
      var y = Math.pow(f[g * 2] - e, 2) + Math.pow(f[g * 2 + 1] - t, 2);
      y <= p && (d[0] = f[g * 2], d[1] = f[g * 2 + 1], p = y);
    }
    return d;
  }
  return f;
}, Qa = function(e, t, a) {
  var n = [e[0] - t[0], e[1] - t[1]], i = Math.sqrt(n[0] * n[0] + n[1] * n[1]), s = (i - a) / i;
  return s < 0 && (s = 1e-5), [t[0] + s * n[0], t[1] + s * n[1]];
}, mt = function(e, t) {
  var a = Ps(e, t);
  return a = Lf(a), a;
}, Lf = function(e) {
  for (var t, a, n = e.length / 2, i = 1 / 0, s = 1 / 0, o = -1 / 0, u = -1 / 0, l = 0; l < n; l++)
    t = e[2 * l], a = e[2 * l + 1], i = Math.min(i, t), o = Math.max(o, t), s = Math.min(s, a), u = Math.max(u, a);
  for (var f = 2 / (o - i), c = 2 / (u - s), v = 0; v < n; v++)
    t = e[2 * v] = e[2 * v] * f, a = e[2 * v + 1] = e[2 * v + 1] * c, i = Math.min(i, t), o = Math.max(o, t), s = Math.min(s, a), u = Math.max(u, a);
  if (s < -1)
    for (var h = 0; h < n; h++)
      a = e[2 * h + 1] = e[2 * h + 1] + (-1 - s);
  return e;
}, Ps = function(e, t) {
  var a = 1 / e * 2 * Math.PI, n = e % 2 === 0 ? Math.PI / 2 + a / 2 : Math.PI / 2;
  n += t;
  for (var i = new Array(e * 2), s, o = 0; o < e; o++)
    s = o * a + n, i[2 * o] = Math.cos(s), i[2 * o + 1] = Math.sin(-s);
  return i;
}, ur = function(e, t) {
  return Math.min(e / 4, t / 4, 8);
}, Rf = function(e, t) {
  return Math.min(e / 10, t / 10, 8);
}, co = function() {
  return 8;
}, ed = function(e, t, a) {
  return [e - 2 * t + a, 2 * (t - e), e];
}, Ns = function(e, t) {
  return {
    heightOffset: Math.min(15, 0.05 * t),
    widthOffset: Math.min(100, 0.25 * e),
    ctrlPtOffsetPct: 0.05
  };
};
function td(r, e) {
  function t(c) {
    for (var v = [], h = 0; h < c.length; h++) {
      var d = c[h], p = c[(h + 1) % c.length], g = {
        x: p.x - d.x,
        y: p.y - d.y
      }, y = {
        x: -g.y,
        y: g.x
      }, b = Math.sqrt(y.x * y.x + y.y * y.y);
      v.push({
        x: y.x / b,
        y: y.y / b
      });
    }
    return v;
  }
  function a(c, v) {
    var h = 1 / 0, d = -1 / 0, p = Dt(c), g;
    try {
      for (p.s(); !(g = p.n()).done; ) {
        var y = g.value, b = y.x * v.x + y.y * v.y;
        h = Math.min(h, b), d = Math.max(d, b);
      }
    } catch (m) {
      p.e(m);
    } finally {
      p.f();
    }
    return {
      min: h,
      max: d
    };
  }
  function n(c, v) {
    return !(c.max < v.min || v.max < c.min);
  }
  var i = [].concat(En(t(r)), En(t(e))), s = Dt(i), o;
  try {
    for (s.s(); !(o = s.n()).done; ) {
      var u = o.value, l = a(r, u), f = a(e, u);
      if (!n(l, f))
        return !1;
    }
  } catch (c) {
    s.e(c);
  } finally {
    s.f();
  }
  return !0;
}
var rd = vt({
  dampingFactor: 0.8,
  precision: 1e-6,
  iterations: 200,
  weight: function(e) {
    return 1;
  }
}), ad = {
  pageRank: function(e) {
    for (var t = rd(e), a = t.dampingFactor, n = t.precision, i = t.iterations, s = t.weight, o = this._private.cy, u = this.byGroup(), l = u.nodes, f = u.edges, c = l.length, v = c * c, h = f.length, d = new Array(v), p = new Array(c), g = (1 - a) / c, y = 0; y < c; y++) {
      for (var b = 0; b < c; b++) {
        var m = y * c + b;
        d[m] = 0;
      }
      p[y] = 0;
    }
    for (var E = 0; E < h; E++) {
      var x = f[E], S = x.data("source"), w = x.data("target");
      if (S !== w) {
        var T = l.indexOfId(S), C = l.indexOfId(w), D = s(x), A = C * c + T;
        d[A] += D, p[T] += D;
      }
    }
    for (var L = 1 / c + g, R = 0; R < c; R++)
      if (p[R] === 0)
        for (var I = 0; I < c; I++) {
          var O = I * c + R;
          d[O] = L;
        }
      else
        for (var N = 0; N < c; N++) {
          var k = N * c + R;
          d[k] = d[k] / p[R] + g;
        }
    for (var P = new Array(c), B = new Array(c), _, F = 0; F < c; F++)
      P[F] = 1;
    for (var G = 0; G < i; G++) {
      for (var U = 0; U < c; U++)
        B[U] = 0;
      for (var H = 0; H < c; H++)
        for (var $ = 0; $ < c; $++) {
          var X = H * c + $;
          B[H] += d[X] * P[$];
        }
      Fh(B), _ = P, P = B, B = _;
      for (var Q = 0, re = 0; re < c; re++) {
        var J = _[re] - P[re];
        Q += J * J;
      }
      if (Q < n)
        break;
    }
    var z = {
      rank: function(Y) {
        return Y = o.collection(Y)[0], P[l.indexOf(Y)];
      }
    };
    return z;
  }
  // pageRank
}, tu = vt({
  root: null,
  weight: function(e) {
    return 1;
  },
  directed: !1,
  alpha: 0
}), Kr = {
  degreeCentralityNormalized: function(e) {
    e = tu(e);
    var t = this.cy(), a = this.nodes(), n = a.length;
    if (e.directed) {
      for (var f = {}, c = {}, v = 0, h = 0, d = 0; d < n; d++) {
        var p = a[d], g = p.id();
        e.root = p;
        var y = this.degreeCentrality(e);
        v < y.indegree && (v = y.indegree), h < y.outdegree && (h = y.outdegree), f[g] = y.indegree, c[g] = y.outdegree;
      }
      return {
        indegree: function(m) {
          return v == 0 ? 0 : (ce(m) && (m = t.filter(m)), f[m.id()] / v);
        },
        outdegree: function(m) {
          return h === 0 ? 0 : (ce(m) && (m = t.filter(m)), c[m.id()] / h);
        }
      };
    } else {
      for (var i = {}, s = 0, o = 0; o < n; o++) {
        var u = a[o];
        e.root = u;
        var l = this.degreeCentrality(e);
        s < l.degree && (s = l.degree), i[u.id()] = l.degree;
      }
      return {
        degree: function(m) {
          return s === 0 ? 0 : (ce(m) && (m = t.filter(m)), i[m.id()] / s);
        }
      };
    }
  },
  // 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 = tu(e);
    var t = this.cy(), a = this, n = e, i = n.root, s = n.weight, o = n.directed, u = n.alpha;
    if (i = t.collection(i)[0], o) {
      for (var h = i.connectedEdges(), d = h.filter(function(S) {
        return S.target().same(i) && a.has(S);
      }), p = h.filter(function(S) {
        return S.source().same(i) && a.has(S);
      }), g = d.length, y = p.length, b = 0, m = 0, E = 0; E < d.length; E++)
        b += s(d[E]);
      for (var x = 0; x < p.length; x++)
        m += s(p[x]);
      return {
        indegree: Math.pow(g, 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, c = 0, v = 0; v < l.length; v++)
        c += s(l[v]);
      return {
        degree: Math.pow(f, 1 - u) * Math.pow(c, u)
      };
    }
  }
  // degreeCentrality
};
Kr.dc = Kr.degreeCentrality;
Kr.dcn = Kr.degreeCentralityNormalised = Kr.degreeCentralityNormalized;
var ru = vt({
  harmonic: !0,
  weight: function() {
    return 1;
  },
  directed: !1,
  root: null
}), Zr = {
  closenessCentralityNormalized: function(e) {
    for (var t = ru(e), a = t.harmonic, n = t.weight, i = t.directed, s = this.cy(), o = {}, u = 0, l = this.nodes(), f = this.floydWarshall({
      weight: n,
      directed: i
    }), c = 0; c < l.length; c++) {
      for (var v = 0, h = l[c], d = 0; d < l.length; d++)
        if (c !== d) {
          var p = f.distance(h, l[d]);
          a ? v += 1 / p : v += p;
        }
      a || (v = 1 / v), u < v && (u = v), o[h.id()] = v;
    }
    return {
      closeness: function(y) {
        return u == 0 ? 0 : (ce(y) ? y = s.filter(y)[0].id() : y = y.id(), o[y] / u);
      }
    };
  },
  // Implemented from pseudocode from wikipedia
  closenessCentrality: function(e) {
    var t = ru(e), a = t.root, n = t.weight, i = t.directed, s = t.harmonic;
    a = this.filter(a)[0];
    for (var o = this.dijkstra({
      root: a,
      weight: n,
      directed: i
    }), u = 0, l = this.nodes(), f = 0; f < l.length; f++) {
      var c = l[f];
      if (!c.same(a)) {
        var v = o.distanceTo(c);
        s ? u += 1 / v : u += v;
      }
    }
    return s ? u : 1 / u;
  }
  // closenessCentrality
};
Zr.cc = Zr.closenessCentrality;
Zr.ccn = Zr.closenessCentralityNormalised = Zr.closenessCentralityNormalized;
var nd = vt({
  weight: null,
  directed: !1
}), ks = {
  // 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 t = nd(e), a = t.directed, n = t.weight, i = n != null, s = this.cy(), o = this.nodes(), u = {}, l = {}, f = 0, c = {
      set: function(m, E) {
        l[m] = E, E > f && (f = E);
      },
      get: function(m) {
        return l[m];
      }
    }, v = 0; v < o.length; v++) {
      var h = o[v], d = h.id();
      a ? u[d] = h.outgoers().nodes() : u[d] = h.openNeighborhood().nodes(), c.set(d, 0);
    }
    for (var p = function() {
      for (var m = o[g].id(), E = [], x = {}, S = {}, w = {}, T = new Ga(function(H, $) {
        return w[H] - w[$];
      }), C = 0; C < o.length; C++) {
        var D = o[C].id();
        x[D] = [], S[D] = 0, w[D] = 1 / 0;
      }
      for (S[m] = 1, w[m] = 0, T.push(m); !T.empty(); ) {
        var A = T.pop();
        if (E.push(A), i)
          for (var L = 0; L < u[A].length; L++) {
            var R = u[A][L], I = s.getElementById(A), O = void 0;
            I.edgesTo(R).length > 0 ? O = I.edgesTo(R)[0] : O = R.edgesTo(I)[0];
            var N = n(O);
            R = R.id(), w[R] > w[A] + N && (w[R] = w[A] + N, T.nodes.indexOf(R) < 0 ? T.push(R) : T.updateItem(R), S[R] = 0, x[R] = []), w[R] == w[A] + N && (S[R] = S[R] + S[A], x[R].push(A));
          }
        else
          for (var k = 0; k < u[A].length; k++) {
            var P = u[A][k].id();
            w[P] == 1 / 0 && (T.push(P), w[P] = w[A] + 1), w[P] == w[A] + 1 && (S[P] = S[P] + S[A], x[P].push(A));
          }
      }
      for (var B = {}, _ = 0; _ < o.length; _++)
        B[o[_].id()] = 0;
      for (; E.length > 0; ) {
        for (var F = E.pop(), G = 0; G < x[F].length; G++) {
          var U = x[F][G];
          B[U] = B[U] + S[U] / S[F] * (1 + B[F]);
        }
        F != o[g].id() && c.set(F, c.get(F) + B[F]);
      }
    }, g = 0; g < o.length; g++)
      p();
    var y = {
      betweenness: function(m) {
        var E = s.collection(m).id();
        return c.get(E);
      },
      betweennessNormalized: function(m) {
        if (f == 0)
          return 0;
        var E = s.collection(m).id();
        return c.get(E) / f;
      }
    };
    return y.betweennessNormalised = y.betweennessNormalized, y;
  }
  // betweennessCentrality
};
ks.bc = ks.betweennessCentrality;
var id = vt({
  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(r) {
      return 1;
    }
  ]
}), sd = function(e) {
  return id(e);
}, od = function(e, t) {
  for (var a = 0, n = 0; n < t.length; n++)
    a += t[n](e);
  return a;
}, ud = function(e, t, a) {
  for (var n = 0; n < t; n++)
    e[n * t + n] = a;
}, If = function(e, t) {
  for (var a, n = 0; n < t; n++) {
    a = 0;
    for (var i = 0; i < t; i++)
      a += e[i * t + n];
    for (var s = 0; s < t; s++)
      e[s * t + n] = e[s * t + n] / a;
  }
}, ld = function(e, t, a) {
  for (var n = new Array(a * a), i = 0; i < a; i++) {
    for (var s = 0; s < a; s++)
      n[i * a + s] = 0;
    for (var o = 0; o < a; o++)
      for (var u = 0; u < a; u++)
        n[i * a + u] += e[i * a + o] * t[o * a + u];
  }
  return n;
}, fd = function(e, t, a) {
  for (var n = e.slice(0), i = 1; i < a; i++)
    e = ld(e, n, t);
  return e;
}, cd = function(e, t, a) {
  for (var n = new Array(t * t), i = 0; i < t * t; i++)
    n[i] = Math.pow(e[i], a);
  return If(n, t), n;
}, vd = function(e, t, a, n) {
  for (var i = 0; i < a; i++) {
    var s = Math.round(e[i] * Math.pow(10, n)) / Math.pow(10, n), o = Math.round(t[i] * Math.pow(10, n)) / Math.pow(10, n);
    if (s !== o)
      return !1;
  }
  return !0;
}, hd = function(e, t, a, n) {
  for (var i = [], s = 0; s < t; s++) {
    for (var o = [], u = 0; u < t; u++)
      Math.round(e[s * t + u] * 1e3) / 1e3 > 0 && o.push(a[u]);
    o.length !== 0 && i.push(n.collection(o));
  }
  return i;
}, dd = function(e, t) {
  for (var a = 0; a < e.length; a++)
    if (!t[a] || e[a].id() !== t[a].id())
      return !1;
  return !0;
}, gd = function(e) {
  for (var t = 0; t < e.length; t++)
    for (var a = 0; a < e.length; a++)
      t != a && dd(e[t], e[a]) && e.splice(a, 1);
  return e;
}, au = function(e) {
  for (var t = this.nodes(), a = this.edges(), n = this.cy(), i = sd(e), s = {}, o = 0; o < t.length; o++)
    s[t[o].id()] = o;
  for (var u = t.length, l = u * u, f = new Array(l), c, v = 0; v < l; v++)
    f[v] = 0;
  for (var h = 0; h < a.length; h++) {
    var d = a[h], p = s[d.source().id()], g = s[d.target().id()], y = od(d, i.attributes);
    f[p * u + g] += y, f[g * u + p] += y;
  }
  ud(f, u, i.multFactor), If(f, u);
  for (var b = !0, m = 0; b && m < i.maxIterations; )
    b = !1, c = fd(f, u, i.expandFactor), f = cd(c, u, i.inflateFactor), vd(f, c, l, 4) || (b = !0), m++;
  var E = hd(f, u, t, n);
  return E = gd(E), E;
}, pd = {
  markovClustering: au,
  mcl: au
}, yd = function(e) {
  return e;
}, Mf = function(e, t) {
  return Math.abs(t - e);
}, nu = function(e, t, a) {
  return e + Mf(t, a);
}, iu = function(e, t, a) {
  return e + Math.pow(a - t, 2);
}, md = function(e) {
  return Math.sqrt(e);
}, bd = function(e, t, a) {
  return Math.max(e, Mf(t, a));
}, fa = function(e, t, a, n, i) {
  for (var s = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : yd, o = n, u, l, f = 0; f < e; f++)
    u = t(f), l = a(f), o = i(o, u, l);
  return s(o);
}, ea = {
  euclidean: function(e, t, a) {
    return e >= 2 ? fa(e, t, a, 0, iu, md) : fa(e, t, a, 0, nu);
  },
  squaredEuclidean: function(e, t, a) {
    return fa(e, t, a, 0, iu);
  },
  manhattan: function(e, t, a) {
    return fa(e, t, a, 0, nu);
  },
  max: function(e, t, a) {
    return fa(e, t, a, -1 / 0, bd);
  }
};
ea["squared-euclidean"] = ea.squaredEuclidean;
ea.squaredeuclidean = ea.squaredEuclidean;
function Gn(r, e, t, a, n, i) {
  var s;
  return He(r) ? s = r : s = ea[r] || ea.euclidean, e === 0 && He(r) ? s(n, i) : s(e, t, a, n, i);
}
var wd = vt({
  k: 2,
  m: 2,
  sensitivityThreshold: 1e-4,
  distance: "euclidean",
  maxIterations: 10,
  attributes: [],
  testMode: !1,
  testCentroids: null
}), vo = function(e) {
  return wd(e);
}, An = function(e, t, a, n, i) {
  var s = i !== "kMedoids", o = s ? function(c) {
    return a[c];
  } : function(c) {
    return n[c](a);
  }, u = function(v) {
    return n[v](t);
  }, l = a, f = t;
  return Gn(e, n.length, o, u, l, f);
}, bi = function(e, t, a) {
  for (var n = a.length, i = new Array(n), s = new Array(n), o = new Array(t), u = null, l = 0; l < n; l++)
    i[l] = e.min(a[l]).value, s[l] = e.max(a[l]).value;
  for (var f = 0; f < t; f++) {
    u = [];
    for (var c = 0; c < n; c++)
      u[c] = Math.random() * (s[c] - i[c]) + i[c];
    o[f] = u;
  }
  return o;
}, Of = function(e, t, a, n, i) {
  for (var s = 1 / 0, o = 0, u = 0; u < t.length; u++) {
    var l = An(a, e, t[u], n, i);
    l < s && (s = l, o = u);
  }
  return o;
}, Pf = function(e, t, a) {
  for (var n = [], i = null, s = 0; s < t.length; s++)
    i = t[s], a[i.id()] === e && n.push(i);
  return n;
}, Ed = function(e, t, a) {
  return Math.abs(t - e) <= a;
}, xd = function(e, t, a) {
  for (var n = 0; n < e.length; n++)
    for (var i = 0; i < e[n].length; i++) {
      var s = Math.abs(e[n][i] - t[n][i]);
      if (s > a)
        return !1;
    }
  return !0;
}, Td = function(e, t, a) {
  for (var n = 0; n < a; n++)
    if (e === t[n])
      return !0;
  return !1;
}, su = function(e, t) {
  var a = new Array(t);
  if (e.length < 50)
    for (var n = 0; n < t; n++) {
      for (var i = e[Math.floor(Math.random() * e.length)]; Td(i, a, n); )
        i = e[Math.floor(Math.random() * e.length)];
      a[n] = i;
    }
  else
    for (var s = 0; s < t; s++)
      a[s] = e[Math.floor(Math.random() * e.length)];
  return a;
}, ou = function(e, t, a) {
  for (var n = 0, i = 0; i < t.length; i++)
    n += An("manhattan", t[i], e, a, "kMedoids");
  return n;
}, Cd = function(e) {
  var t = this.cy(), a = this.nodes(), n = null, i = vo(e), s = new Array(i.k), o = {}, u;
  i.testMode ? typeof i.testCentroids == "number" ? (i.testCentroids, u = bi(a, i.k, i.attributes)) : rt(i.testCentroids) === "object" ? u = i.testCentroids : u = bi(a, i.k, i.attributes) : u = bi(a, i.k, i.attributes);
  for (var l = !0, f = 0; l && f < i.maxIterations; ) {
    for (var c = 0; c < a.length; c++)
      n = a[c], o[n.id()] = Of(n, u, i.distance, i.attributes, "kMeans");
    l = !1;
    for (var v = 0; v < i.k; v++) {
      var h = Pf(v, a, o);
      if (h.length !== 0) {
        for (var d = i.attributes.length, p = u[v], g = 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);
          g[b] = y[b] / h.length, Ed(g[b], p[b], i.sensitivityThreshold) || (l = !0);
        }
        u[v] = g, s[v] = t.collection(h);
      }
    }
    f++;
  }
  return s;
}, Dd = function(e) {
  var t = this.cy(), a = this.nodes(), n = null, i = vo(e), s = new Array(i.k), o, u = {}, l, f = new Array(i.k);
  i.testMode ? typeof i.testCentroids == "number" || (rt(i.testCentroids) === "object" ? o = i.testCentroids : o = su(a, i.k)) : o = su(a, i.k);
  for (var c = !0, v = 0; c && v < i.maxIterations; ) {
    for (var h = 0; h < a.length; h++)
      n = a[h], u[n.id()] = Of(n, o, i.distance, i.attributes, "kMedoids");
    c = !1;
    for (var d = 0; d < o.length; d++) {
      var p = Pf(d, a, u);
      if (p.length !== 0) {
        f[d] = ou(o[d], p, i.attributes);
        for (var g = 0; g < p.length; g++)
          l = ou(p[g], p, i.attributes), l < f[d] && (f[d] = l, o[d] = p[g], c = !0);
        s[d] = t.collection(p);
      }
    }
    v++;
  }
  return s;
}, Sd = function(e, t, a, n, i) {
  for (var s, o, u = 0; u < t.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 c = 0; c < i.attributes.length; c++) {
      s = 0, o = 0;
      for (var v = 0; v < t.length; v++)
        s += n[v][f] * i.attributes[c](t[v]), o += n[v][f];
      e[f][c] = s / o;
    }
}, Ad = function(e, t, a, n, i) {
  for (var s = 0; s < e.length; s++)
    t[s] = e[s].slice();
  for (var o, u, l, f = 2 / (i.m - 1), c = 0; c < a.length; c++)
    for (var v = 0; v < n.length; v++) {
      o = 0;
      for (var h = 0; h < a.length; h++)
        u = An(i.distance, n[v], a[c], i.attributes, "cmeans"), l = An(i.distance, n[v], a[h], i.attributes, "cmeans"), o += Math.pow(u / l, f);
      e[v][c] = 1 / o;
    }
}, Ld = function(e, t, a, n) {
  for (var i = new Array(a.k), s = 0; s < i.length; s++)
    i[s] = [];
  for (var o, u, l = 0; l < t.length; l++) {
    o = -1 / 0, u = -1;
    for (var f = 0; f < t[0].length; f++)
      t[l][f] > o && (o = t[l][f], u = f);
    i[u].push(e[l]);
  }
  for (var c = 0; c < i.length; c++)
    i[c] = n.collection(i[c]);
  return i;
}, uu = function(e) {
  var t = this.cy(), a = this.nodes(), n = vo(e), i, s, o, u, l;
  u = new Array(a.length);
  for (var f = 0; f < a.length; f++)
    u[f] = new Array(n.k);
  o = new Array(a.length);
  for (var c = 0; c < a.length; c++)
    o[c] = new Array(n.k);
  for (var v = 0; v < a.length; v++) {
    for (var h = 0, d = 0; d < n.k; d++)
      o[v][d] = Math.random(), h += o[v][d];
    for (var p = 0; p < n.k; p++)
      o[v][p] = o[v][p] / h;
  }
  s = new Array(n.k);
  for (var g = 0; g < n.k; g++)
    s[g] = 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, Sd(s, a, o, l, n), Ad(o, u, s, a, n), xd(o, u, n.sensitivityThreshold) || (b = !0), m++;
  return i = Ld(a, o, n, t), {
    clusters: i,
    degreeOfMembership: o
  };
}, Rd = {
  kMeans: Cd,
  kMedoids: Dd,
  fuzzyCMeans: uu,
  fcm: uu
}, Id = vt({
  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
}), Md = {
  single: "min",
  complete: "max"
}, Od = function(e) {
  var t = Id(e), a = Md[t.linkage];
  return a != null && (t.linkage = a), t;
}, lu = function(e, t, a, n, i) {
  for (var s = 0, o = 1 / 0, u, l = i.attributes, f = function(C, D) {
    return Gn(i.distance, l.length, function(A) {
      return l[A](C);
    }, function(A) {
      return l[A](D);
    }, C, D);
  }, c = 0; c < e.length; c++) {
    var v = e[c].key, h = a[v][n[v]];
    h < o && (s = v, o = h);
  }
  if (i.mode === "threshold" && o >= i.threshold || i.mode === "dendrogram" && e.length === 1)
    return !1;
  var d = t[s], p = t[n[s]], g;
  i.mode === "dendrogram" ? g = {
    left: d,
    right: p,
    key: d.key
  } : g = {
    value: d.value.concat(p.value),
    key: d.key
  }, e[d.index] = g, e.splice(p.index, 1), t[d.key] = g;
  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[p.key][b.key] && (u = a[p.key][b.key])) : i.linkage === "max" ? (u = a[d.key][b.key], a[d.key][b.key] < a[p.key][b.key] && (u = a[p.key][b.key])) : i.linkage === "mean" ? u = (a[d.key][b.key] * d.size + a[p.key][b.key] * p.size) / (d.size + p.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] === p.key) {
      for (var x = E, S = 0; S < e.length; S++) {
        var w = e[S].key;
        a[E][w] < a[E][x] && (x = w);
      }
      n[E] = x;
    }
    e[m].index = m;
  }
  return d.key = p.key = d.index = p.index = null, !0;
}, Xr = function(e, t, a) {
  e && (e.value ? t.push(e.value) : (e.left && Xr(e.left, t), e.right && Xr(e.right, t)));
}, Bs = function(e, t) {
  if (!e)
    return "";
  if (e.left && e.right) {
    var a = Bs(e.left, t), n = Bs(e.right, t), i = t.add({
      group: "nodes",
      data: {
        id: a + "," + n
      }
    });
    return t.add({
      group: "edges",
      data: {
        source: a,
        target: i.id()
      }
    }), t.add({
      group: "edges",
      data: {
        source: n,
        target: i.id()
      }
    }), i.id();
  } else if (e.value)
    return e.value.id();
}, Fs = function(e, t, a) {
  if (!e)
    return [];
  var n = [], i = [], s = [];
  return t === 0 ? (e.left && Xr(e.left, n), e.right && Xr(e.right, i), s = n.concat(i), [a.collection(s)]) : t === 1 ? e.value ? [a.collection(e.value)] : (e.left && Xr(e.left, n), e.right && Xr(e.right, i), [a.collection(n), a.collection(i)]) : e.value ? [a.collection(e.value)] : (e.left && (n = Fs(e.left, t - 1, a)), e.right && (i = Fs(e.right, t - 1, a)), n.concat(i));
}, fu = function(e) {
  for (var t = this.cy(), a = this.nodes(), n = Od(e), i = n.attributes, s = function(m, E) {
    return Gn(n.distance, i.length, function(x) {
      return i[x](m);
    }, function(x) {
      return i[x](E);
    }, m, E);
  }, o = [], u = [], l = [], f = [], c = 0; c < a.length; c++) {
    var v = {
      value: n.mode === "dendrogram" ? a[c] : [a[c]],
      key: c,
      index: c
    };
    o[c] = v, f[c] = v, u[c] = [], l[c] = 0;
  }
  for (var h = 0; h < o.length; h++)
    for (var d = 0; d <= h; d++) {
      var p = void 0;
      n.mode === "dendrogram" ? p = h === d ? 1 / 0 : s(o[h].value, o[d].value) : p = h === d ? 1 / 0 : s(o[h].value[0], o[d].value[0]), u[h][d] = p, u[d][h] = p, p < u[h][l[h]] && (l[h] = d);
    }
  for (var g = lu(o, f, u, l, n); g; )
    g = lu(o, f, u, l, n);
  var y;
  return n.mode === "dendrogram" ? (y = Fs(o[0], n.dendrogramDepth, t), n.addDendrogram && Bs(o[0], t)) : (y = new Array(o.length), o.forEach(function(b, m) {
    b.key = b.index = null, y[m] = t.collection(b.value);
  })), y;
}, Pd = {
  hierarchicalClustering: fu,
  hca: fu
}, Nd = vt({
  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')
  ]
}), kd = function(e) {
  var t = e.damping, a = e.preference;
  0.5 <= t && t < 1 || qe("Damping must range on [0.5, 1).  Got: ".concat(t));
  var n = ["median", "mean", "min", "max"];
  return n.some(function(i) {
    return i === a;
  }) || ae(a) || qe("Preference must be one of [".concat(n.map(function(i) {
    return "'".concat(i, "'");
  }).join(", "), "] or a number.  Got: ").concat(a)), Nd(e);
}, Bd = function(e, t, a, n) {
  var i = function(o, u) {
    return n[u](o);
  };
  return -Gn(e, n.length, function(s) {
    return i(t, s);
  }, function(s) {
    return i(a, s);
  }, t, a);
}, Fd = function(e, t) {
  var a = null;
  return t === "median" ? a = kh(e) : t === "mean" ? a = Nh(e) : t === "min" ? a = Oh(e) : t === "max" ? a = Ph(e) : a = t, a;
}, _d = function(e, t, a) {
  for (var n = [], i = 0; i < e; i++)
    t[i * e + i] + a[i * e + i] > 0 && n.push(i);
  return n;
}, cu = function(e, t, a) {
  for (var n = [], i = 0; i < e; i++) {
    for (var s = -1, o = -1 / 0, u = 0; u < a.length; u++) {
      var l = a[u];
      t[i * e + l] > o && (s = l, o = t[i * e + l]);
    }
    s > 0 && n.push(s);
  }
  for (var f = 0; f < a.length; f++)
    n[a[f]] = a[f];
  return n;
}, Gd = function(e, t, a) {
  for (var n = cu(e, t, a), i = 0; i < a.length; i++) {
    for (var s = [], o = 0; o < n.length; o++)
      n[o] === a[i] && s.push(o);
    for (var u = -1, l = -1 / 0, f = 0; f < s.length; f++) {
      for (var c = 0, v = 0; v < s.length; v++)
        c += t[s[v] * e + s[f]];
      c > l && (u = f, l = c);
    }
    a[i] = s[u];
  }
  return n = cu(e, t, a), n;
}, vu = function(e) {
  for (var t = this.cy(), a = this.nodes(), n = kd(e), i = {}, s = 0; s < a.length; s++)
    i[a[s].id()] = s;
  var o, u, l, f, c, v;
  o = a.length, u = o * o, l = new Array(u);
  for (var h = 0; h < u; h++)
    l[h] = -1 / 0;
  for (var d = 0; d < o; d++)
    for (var p = 0; p < o; p++)
      d !== p && (l[d * o + p] = Bd(n.distance, a[d], a[p], n.attributes));
  f = Fd(l, n.preference);
  for (var g = 0; g < o; g++)
    l[g * o + g] = f;
  c = new Array(u);
  for (var y = 0; y < u; y++)
    c[y] = 0;
  v = new Array(u);
  for (var b = 0; b < u; b++)
    v[b] = 0;
  for (var m = new Array(o), E = new Array(o), x = new Array(o), S = 0; S < o; S++)
    m[S] = 0, E[S] = 0, x[S] = 0;
  for (var w = new Array(o * n.minIterations), T = 0; T < w.length; T++)
    w[T] = 0;
  var C;
  for (C = 0; C < n.maxIterations; C++) {
    for (var D = 0; D < o; D++) {
      for (var A = -1 / 0, L = -1 / 0, R = -1, I = 0, O = 0; O < o; O++)
        m[O] = c[D * o + O], I = v[D * o + O] + l[D * o + O], I >= A ? (L = A, A = I, R = O) : I > L && (L = I);
      for (var N = 0; N < o; N++)
        c[D * o + N] = (1 - n.damping) * (l[D * o + N] - A) + n.damping * m[N];
      c[D * o + R] = (1 - n.damping) * (l[D * o + R] - L) + n.damping * m[R];
    }
    for (var k = 0; k < o; k++) {
      for (var P = 0, B = 0; B < o; B++)
        m[B] = v[B * o + k], E[B] = Math.max(0, c[B * o + k]), P += E[B];
      P -= E[k], E[k] = c[k * o + k], P += E[k];
      for (var _ = 0; _ < o; _++)
        v[_ * o + k] = (1 - n.damping) * Math.min(0, P - E[_]) + n.damping * m[_];
      v[k * o + k] = (1 - n.damping) * (P - E[k]) + n.damping * m[k];
    }
    for (var F = 0, G = 0; G < o; G++) {
      var U = v[G * o + G] + c[G * o + G] > 0 ? 1 : 0;
      w[C % n.minIterations * o + G] = U, F += U;
    }
    if (F > 0 && (C >= n.minIterations - 1 || C == n.maxIterations - 1)) {
      for (var H = 0, $ = 0; $ < o; $++) {
        x[$] = 0;
        for (var X = 0; X < n.minIterations; X++)
          x[$] += w[X * o + $];
        (x[$] === 0 || x[$] === n.minIterations) && H++;
      }
      if (H === o)
        break;
    }
  }
  for (var Q = _d(o, c, v), re = Gd(o, l, Q), J = {}, z = 0; z < Q.length; z++)
    J[Q[z]] = [];
  for (var V = 0; V < a.length; V++) {
    var Y = i[a[V].id()], ee = re[Y];
    ee != null && J[ee].push(a[V]);
  }
  for (var ne = new Array(Q.length), be = 0; be < Q.length; be++)
    ne[be] = t.collection(J[Q[be]]);
  return ne;
}, zd = {
  affinityPropagation: vu,
  ap: vu
}, Vd = vt({
  root: void 0,
  directed: !1
}), Ud = {
  hierholzer: function(e) {
    if (!Re(e)) {
      var t = arguments;
      e = {
        root: t[0],
        directed: t[1]
      };
    }
    var a = Vd(e), n = a.root, i = a.directed, s = this, o = !1, u, l, f;
    n && (f = ce(n) ? this.filter(n)[0].id() : n[0].id());
    var c = {}, v = {};
    i ? s.forEach(function(b) {
      var m = b.id();
      if (b.isNode()) {
        var E = b.indegree(!0), x = b.outdegree(!0), S = E - x, w = x - E;
        S == 1 ? u ? o = !0 : u = m : w == 1 ? l ? o = !0 : l = m : (w > 1 || S > 1) && (o = !0), c[m] = [], b.outgoers().forEach(function(T) {
          T.isEdge() && c[m].push(T.id());
        });
      } else
        v[m] = [void 0, b.target().id()];
    }) : s.forEach(function(b) {
      var m = b.id();
      if (b.isNode()) {
        var E = b.degree(!0);
        E % 2 && (u ? l ? o = !0 : l = m : u = m), c[m] = [], b.connectedEdges().forEach(function(x) {
          return c[m].push(x.id());
        });
      } else
        v[m] = [b.source().id(), b.target().id()];
    });
    var h = {
      found: !1,
      trail: void 0
    };
    if (o)
      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 = s[0].id());
    var d = function(m) {
      for (var E = m, x = [m], S, w, T; c[E].length; )
        S = c[E].shift(), w = v[S][0], T = v[S][1], E != T ? (c[T] = c[T].filter(function(C) {
          return C != S;
        }), E = T) : !i && E != w && (c[w] = c[w].filter(function(C) {
          return C != S;
        }), E = w), x.unshift(S), x.unshift(E);
      return x;
    }, p = [], g = [];
    for (g = d(f); g.length != 1; )
      c[g[0]].length == 0 ? (p.unshift(s.getElementById(g.shift())), p.unshift(s.getElementById(g.shift()))) : g = d(g.shift()).concat(g);
    p.unshift(s.getElementById(g.shift()));
    for (var y in c)
      if (c[y].length)
        return h;
    return h.found = !0, h.trail = this.spawn(p, !0), h;
  }
}, Ja = function() {
  var e = this, t = {}, a = 0, n = 0, i = [], s = [], o = {}, u = function(v, h) {
    for (var d = s.length - 1, p = [], g = e.spawn(); s[d].x != v || s[d].y != h; )
      p.push(s.pop().edge), d--;
    p.push(s.pop().edge), p.forEach(function(y) {
      var b = y.connectedNodes().intersection(e);
      g.merge(y), b.forEach(function(m) {
        var E = m.id(), x = m.connectedEdges().intersection(e);
        g.merge(m), t[E].cutVertex ? g.merge(x.filter(function(S) {
          return S.isLoop();
        })) : g.merge(x);
      });
    }), i.push(g);
  }, l = function(v, h, d) {
    v === d && (n += 1), t[h] = {
      id: a,
      low: a++,
      cutVertex: !1
    };
    var p = e.getElementById(h).connectedEdges().intersection(e);
    if (p.size() === 0)
      i.push(e.spawn(e.getElementById(h)));
    else {
      var g, y, b, m;
      p.forEach(function(E) {
        g = E.source().id(), y = E.target().id(), b = g === h ? y : g, b !== d && (m = E.id(), o[m] || (o[m] = !0, s.push({
          x: h,
          y: b,
          edge: E
        })), b in t ? t[h].low = Math.min(t[h].low, t[b].id) : (l(v, b, h), t[h].low = Math.min(t[h].low, t[b].low), t[h].id <= t[b].low && (t[h].cutVertex = !0, u(h, b))));
      });
    }
  };
  e.forEach(function(c) {
    if (c.isNode()) {
      var v = c.id();
      v in t || (n = 0, l(v, v), t[v].cutVertex = n > 1);
    }
  });
  var f = Object.keys(t).filter(function(c) {
    return t[c].cutVertex;
  }).map(function(c) {
    return e.getElementById(c);
  });
  return {
    cut: e.spawn(f),
    components: i
  };
}, qd = {
  hopcroftTarjanBiconnected: Ja,
  htbc: Ja,
  htb: Ja,
  hopcroftTarjanBiconnectedComponents: Ja
}, ja = function() {
  var e = this, t = {}, a = 0, n = [], i = [], s = e.spawn(e), o = function(l) {
    i.push(l), t[l] = {
      index: a,
      low: a++,
      explored: !1
    };
    var f = e.getElementById(l).connectedEdges().intersection(e);
    if (f.forEach(function(p) {
      var g = p.target().id();
      g !== l && (g in t || o(g), t[g].explored || (t[l].low = Math.min(t[l].low, t[g].low)));
    }), t[l].index === t[l].low) {
      for (var c = e.spawn(); ; ) {
        var v = i.pop();
        if (c.merge(e.getElementById(v)), t[v].low = t[l].index, t[v].explored = !0, v === l)
          break;
      }
      var h = c.edgesWith(c), d = c.merge(h);
      n.push(d), s = s.difference(d);
    }
  };
  return e.forEach(function(u) {
    if (u.isNode()) {
      var l = u.id();
      l in t || o(l);
    }
  }), {
    cut: s,
    components: n
  };
}, Hd = {
  tarjanStronglyConnected: ja,
  tsc: ja,
  tscc: ja,
  tarjanStronglyConnectedComponents: ja
}, Nf = {};
[Da, wh, Eh, Th, Dh, Ah, Ih, ad, Kr, Zr, ks, pd, Rd, Pd, zd, Ud, qd, Hd].forEach(function(r) {
  de(Nf, r);
});
/*!
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 kf = 0, Bf = 1, Ff = 2, Bt = function(e) {
  if (!(this instanceof Bt))
    return new Bt(e);
  this.id = "Thenable/1.0.7", this.state = kf, 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));
};
Bt.prototype = {
  /*  promise resolving methods  */
  fulfill: function(e) {
    return hu(this, Bf, "fulfillValue", e);
  },
  reject: function(e) {
    return hu(this, Ff, "rejectReason", e);
  },
  /*  "The then Method" [Promises/A+ 1.1, 1.2, 2.2]  */
  then: function(e, t) {
    var a = this, n = new Bt();
    return a.onFulfilled.push(gu(e, n, "fulfill")), a.onRejected.push(gu(t, n, "reject")), _f(a), n.proxy;
  }
};
var hu = function(e, t, a, n) {
  return e.state === kf && (e.state = t, e[a] = n, _f(e)), e;
}, _f = function(e) {
  e.state === Bf ? du(e, "onFulfilled", e.fulfillValue) : e.state === Ff && du(e, "onRejected", e.rejectReason);
}, du = function(e, t, a) {
  if (e[t].length !== 0) {
    var n = e[t];
    e[t] = [];
    var i = function() {
      for (var o = 0; o < n.length; o++)
        n[o](a);
    };
    typeof setImmediate == "function" ? setImmediate(i) : setTimeout(i, 0);
  }
}, gu = function(e, t, a) {
  return function(n) {
    if (typeof e != "function")
      t[a].call(t, n);
    else {
      var i;
      try {
        i = e(n);
      } catch (s) {
        t.reject(s);
        return;
      }
      Gf(t, i);
    }
  };
}, Gf = function(e, t) {
  if (e === t || e.proxy === t) {
    e.reject(new TypeError("cannot resolve promise with itself"));
    return;
  }
  var a;
  if (rt(t) === "object" && t !== null || typeof t == "function")
    try {
      a = t.then;
    } catch (i) {
      e.reject(i);
      return;
    }
  if (typeof a == "function") {
    var n = !1;
    try {
      a.call(
        t,
        /*  resolvePromise  */
        /*  [Promises/A+ 2.3.3.3.1]  */
        function(i) {
          n || (n = !0, i === t ? e.reject(new TypeError("circular thenable chain")) : Gf(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(t);
};
Bt.all = function(r) {
  return new Bt(function(e, t) {
    for (var a = new Array(r.length), n = 0, i = function(u, l) {
      a[u] = l, n++, n === r.length && e(a);
    }, s = 0; s < r.length; s++)
      (function(o) {
        var u = r[o], l = u != null && u.then != null;
        if (l)
          u.then(function(c) {
            i(o, c);
          }, function(c) {
            t(c);
          });
        else {
          var f = u;
          i(o, f);
        }
      })(s);
  });
};
Bt.resolve = function(r) {
  return new Bt(function(e, t) {
    e(r);
  });
};
Bt.reject = function(r) {
  return new Bt(function(e, t) {
    t(r);
  });
};
var aa = typeof Promise < "u" ? Promise : Bt, _s = function(e, t, a) {
  var n = ro(e), i = !n, s = this._private = de({
    duration: 1e3
  }, t, a);
  if (s.target = e, s.style = s.style || s.css, s.started = !1, s.playing = !1, s.hooked = !1, s.applying = !1, s.progress = 0, s.completes = [], s.frames = [], s.complete && He(s.complete) && s.completes.push(s.complete), i) {
    var o = e.position();
    s.startPosition = s.startPosition || {
      x: o.x,
      y: o.y
    }, s.startStyle = s.startStyle || e.cy().style().getAnimationStartStyle(e, s.style);
  }
  if (n) {
    var u = e.pan();
    s.startPan = {
      x: u.x,
      y: u.y
    }, s.startZoom = e.zoom();
  }
  this.length = 1, this[0] = this;
}, Rr = _s.prototype;
de(Rr, {
  instanceString: function() {
    return "animation";
  },
  hook: function() {
    var e = this._private;
    if (!e.hooked) {
      var t, a = e.target._private.animation;
      e.queue ? t = a.queue : t = a.current, t.push(this), At(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 t = this._private;
    return e === void 0 ? t.progress * t.duration : this.progress(e / t.duration);
  },
  progress: function(e) {
    var t = this._private, a = t.playing;
    return e === void 0 ? t.progress : (a && this.pause(), t.progress = e, t.started = !1, a && this.play(), this);
  },
  completed: function() {
    return this._private.progress === 1;
  },
  reverse: function() {
    var e = this._private, t = e.playing;
    t && this.pause(), e.progress = 1 - e.progress, e.started = !1;
    var a = function(l, f) {
      var c = e[l];
      c != null && (e[l] = e[f], e[f] = c);
    };
    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], s = i.name, o = e.startStyle[s];
        e.startStyle[s] = i, e.style[n] = o;
      }
    return t && this.play(), this;
  },
  promise: function(e) {
    var t = this._private, a;
    switch (e) {
      case "frame":
        a = t.frames;
        break;
      default:
      case "complete":
      case "completed":
        a = t.completes;
    }
    return new aa(function(n, i) {
      a.push(function() {
        n();
      });
    });
  }
});
Rr.complete = Rr.completed;
Rr.run = Rr.play;
Rr.running = Rr.playing;
var Yd = {
  animated: function() {
    return function() {
      var t = this, a = t.length !== void 0, n = a ? t : [t], i = this._private.cy || this;
      if (!i.styleEnabled())
        return !1;
      var s = n[0];
      if (s)
        return s._private.animation.current.length > 0;
    };
  },
  // animated
  clearQueue: function() {
    return function() {
      var t = this, a = t.length !== void 0, n = a ? t : [t], i = this._private.cy || this;
      if (!i.styleEnabled())
        return this;
      for (var s = 0; s < n.length; s++) {
        var o = n[s];
        o._private.animation.queue = [];
      }
      return this;
    };
  },
  // clearQueue
  delay: function() {
    return function(t, a) {
      var n = this._private.cy || this;
      return n.styleEnabled() ? this.animate({
        delay: t,
        duration: t,
        complete: a
      }) : this;
    };
  },
  // delay
  delayAnimation: function() {
    return function(t, a) {
      var n = this._private.cy || this;
      return n.styleEnabled() ? this.animation({
        delay: t,
        duration: t,
        complete: a
      }) : this;
    };
  },
  // delay
  animation: function() {
    return function(t, a) {
      var n = this, i = n.length !== void 0, s = i ? n : [n], o = this._private.cy || this, u = !i, l = !u;
      if (!o.styleEnabled())
        return this;
      var f = o.style();
      t = de({}, t, a);
      var c = Object.keys(t).length === 0;
      if (c)
        return new _s(s[0], t);
      switch (t.duration === void 0 && (t.duration = 400), t.duration) {
        case "slow":
          t.duration = 600;
          break;
        case "fast":
          t.duration = 200;
          break;
      }
      if (l && (t.style = f.getPropsList(t.style || t.css), t.css = void 0), l && t.renderedPosition != null) {
        var v = t.renderedPosition, h = o.pan(), d = o.zoom();
        t.position = Df(v, d, h);
      }
      if (u && t.panBy != null) {
        var p = t.panBy, g = o.pan();
        t.pan = {
          x: g.x + p.x,
          y: g.y + p.y
        };
      }
      var y = t.center || t.centre;
      if (u && y != null) {
        var b = o.getCenterPan(y.eles, t.zoom);
        b != null && (t.pan = b);
      }
      if (u && t.fit != null) {
        var m = t.fit, E = o.getFitViewport(m.eles || m.boundingBox, m.padding);
        E != null && (t.pan = E.pan, t.zoom = E.zoom);
      }
      if (u && Re(t.zoom)) {
        var x = o.getZoomedViewport(t.zoom);
        x != null ? (x.zoomed && (t.zoom = x.zoom), x.panned && (t.pan = x.pan)) : t.zoom = null;
      }
      return new _s(s[0], t);
    };
  },
  // animate
  animate: function() {
    return function(t, a) {
      var n = this, i = n.length !== void 0, s = i ? n : [n], o = this._private.cy || this;
      if (!o.styleEnabled())
        return this;
      a && (t = de({}, t, a));
      for (var u = 0; u < s.length; u++) {
        var l = s[u], f = l.animated() && (t.queue === void 0 || t.queue), c = l.animation(t, f ? {
          queue: !0
        } : void 0);
        c.play();
      }
      return this;
    };
  },
  // animate
  stop: function() {
    return function(t, a) {
      var n = this, i = n.length !== void 0, s = i ? n : [n], o = this._private.cy || this;
      if (!o.styleEnabled())
        return this;
      for (var u = 0; u < s.length; u++) {
        for (var l = s[u], f = l._private, c = f.animation.current, v = 0; v < c.length; v++) {
          var h = c[v], d = h._private;
          a && (d.duration = 0);
        }
        t && (f.animation.queue = []), a || (f.animation.current = []);
      }
      return o.notify("draw"), this;
    };
  }
  // stop
}, wi, pu;
function zn() {
  if (pu)
    return wi;
  pu = 1;
  var r = Array.isArray;
  return wi = r, wi;
}
var Ei, yu;
function Xd() {
  if (yu)
    return Ei;
  yu = 1;
  var r = zn(), e = Fa(), t = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, a = /^\w*$/;
  function n(i, s) {
    if (r(i))
      return !1;
    var o = typeof i;
    return o == "number" || o == "symbol" || o == "boolean" || i == null || e(i) ? !0 : a.test(i) || !t.test(i) || s != null && i in Object(s);
  }
  return Ei = n, Ei;
}
var xi, mu;
function $d() {
  if (mu)
    return xi;
  mu = 1;
  var r = pf(), e = Ba(), t = "[object AsyncFunction]", a = "[object Function]", n = "[object GeneratorFunction]", i = "[object Proxy]";
  function s(o) {
    if (!e(o))
      return !1;
    var u = r(o);
    return u == a || u == n || u == t || u == i;
  }
  return xi = s, xi;
}
var Ti, bu;
function Wd() {
  if (bu)
    return Ti;
  bu = 1;
  var r = Bn(), e = r["__core-js_shared__"];
  return Ti = e, Ti;
}
var Ci, wu;
function Kd() {
  if (wu)
    return Ci;
  wu = 1;
  var r = Wd(), e = function() {
    var a = /[^.]+$/.exec(r && r.keys && r.keys.IE_PROTO || "");
    return a ? "Symbol(src)_1." + a : "";
  }();
  function t(a) {
    return !!e && e in a;
  }
  return Ci = t, Ci;
}
var Di, Eu;
function Zd() {
  if (Eu)
    return Di;
  Eu = 1;
  var r = Function.prototype, e = r.toString;
  function t(a) {
    if (a != null) {
      try {
        return e.call(a);
      } catch {
      }
      try {
        return a + "";
      } catch {
      }
    }
    return "";
  }
  return Di = t, Di;
}
var Si, xu;
function Qd() {
  if (xu)
    return Si;
  xu = 1;
  var r = $d(), e = Kd(), t = Ba(), a = Zd(), n = /[\\^$.*+?()[\]{}|]/g, i = /^\[object .+?Constructor\]$/, s = Function.prototype, o = Object.prototype, u = s.toString, l = o.hasOwnProperty, f = RegExp(
    "^" + u.call(l).replace(n, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
  );
  function c(v) {
    if (!t(v) || e(v))
      return !1;
    var h = r(v) ? f : i;
    return h.test(a(v));
  }
  return Si = c, Si;
}
var Ai, Tu;
function Jd() {
  if (Tu)
    return Ai;
  Tu = 1;
  function r(e, t) {
    return e == null ? void 0 : e[t];
  }
  return Ai = r, Ai;
}
var Li, Cu;
function ho() {
  if (Cu)
    return Li;
  Cu = 1;
  var r = Qd(), e = Jd();
  function t(a, n) {
    var i = e(a, n);
    return r(i) ? i : void 0;
  }
  return Li = t, Li;
}
var Ri, Du;
function Vn() {
  if (Du)
    return Ri;
  Du = 1;
  var r = ho(), e = r(Object, "create");
  return Ri = e, Ri;
}
var Ii, Su;
function jd() {
  if (Su)
    return Ii;
  Su = 1;
  var r = Vn();
  function e() {
    this.__data__ = r ? r(null) : {}, this.size = 0;
  }
  return Ii = e, Ii;
}
var Mi, Au;
function eg() {
  if (Au)
    return Mi;
  Au = 1;
  function r(e) {
    var t = this.has(e) && delete this.__data__[e];
    return this.size -= t ? 1 : 0, t;
  }
  return Mi = r, Mi;
}
var Oi, Lu;
function tg() {
  if (Lu)
    return Oi;
  Lu = 1;
  var r = Vn(), e = "__lodash_hash_undefined__", t = Object.prototype, a = t.hasOwnProperty;
  function n(i) {
    var s = this.__data__;
    if (r) {
      var o = s[i];
      return o === e ? void 0 : o;
    }
    return a.call(s, i) ? s[i] : void 0;
  }
  return Oi = n, Oi;
}
var Pi, Ru;
function rg() {
  if (Ru)
    return Pi;
  Ru = 1;
  var r = Vn(), e = Object.prototype, t = e.hasOwnProperty;
  function a(n) {
    var i = this.__data__;
    return r ? i[n] !== void 0 : t.call(i, n);
  }
  return Pi = a, Pi;
}
var Ni, Iu;
function ag() {
  if (Iu)
    return Ni;
  Iu = 1;
  var r = Vn(), e = "__lodash_hash_undefined__";
  function t(a, n) {
    var i = this.__data__;
    return this.size += this.has(a) ? 0 : 1, i[a] = r && n === void 0 ? e : n, this;
  }
  return Ni = t, Ni;
}
var ki, Mu;
function ng() {
  if (Mu)
    return ki;
  Mu = 1;
  var r = jd(), e = eg(), t = tg(), a = rg(), n = ag();
  function i(s) {
    var o = -1, u = s == null ? 0 : s.length;
    for (this.clear(); ++o < u; ) {
      var l = s[o];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = r, i.prototype.delete = e, i.prototype.get = t, i.prototype.has = a, i.prototype.set = n, ki = i, ki;
}
var Bi, Ou;
function ig() {
  if (Ou)
    return Bi;
  Ou = 1;
  function r() {
    this.__data__ = [], this.size = 0;
  }
  return Bi = r, Bi;
}
var Fi, Pu;
function zf() {
  if (Pu)
    return Fi;
  Pu = 1;
  function r(e, t) {
    return e === t || e !== e && t !== t;
  }
  return Fi = r, Fi;
}
var _i, Nu;
function Un() {
  if (Nu)
    return _i;
  Nu = 1;
  var r = zf();
  function e(t, a) {
    for (var n = t.length; n--; )
      if (r(t[n][0], a))
        return n;
    return -1;
  }
  return _i = e, _i;
}
var Gi, ku;
function sg() {
  if (ku)
    return Gi;
  ku = 1;
  var r = Un(), e = Array.prototype, t = e.splice;
  function a(n) {
    var i = this.__data__, s = r(i, n);
    if (s < 0)
      return !1;
    var o = i.length - 1;
    return s == o ? i.pop() : t.call(i, s, 1), --this.size, !0;
  }
  return Gi = a, Gi;
}
var zi, Bu;
function og() {
  if (Bu)
    return zi;
  Bu = 1;
  var r = Un();
  function e(t) {
    var a = this.__data__, n = r(a, t);
    return n < 0 ? void 0 : a[n][1];
  }
  return zi = e, zi;
}
var Vi, Fu;
function ug() {
  if (Fu)
    return Vi;
  Fu = 1;
  var r = Un();
  function e(t) {
    return r(this.__data__, t) > -1;
  }
  return Vi = e, Vi;
}
var Ui, _u;
function lg() {
  if (_u)
    return Ui;
  _u = 1;
  var r = Un();
  function e(t, a) {
    var n = this.__data__, i = r(n, t);
    return i < 0 ? (++this.size, n.push([t, a])) : n[i][1] = a, this;
  }
  return Ui = e, Ui;
}
var qi, Gu;
function fg() {
  if (Gu)
    return qi;
  Gu = 1;
  var r = ig(), e = sg(), t = og(), a = ug(), n = lg();
  function i(s) {
    var o = -1, u = s == null ? 0 : s.length;
    for (this.clear(); ++o < u; ) {
      var l = s[o];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = r, i.prototype.delete = e, i.prototype.get = t, i.prototype.has = a, i.prototype.set = n, qi = i, qi;
}
var Hi, zu;
function cg() {
  if (zu)
    return Hi;
  zu = 1;
  var r = ho(), e = Bn(), t = r(e, "Map");
  return Hi = t, Hi;
}
var Yi, Vu;
function vg() {
  if (Vu)
    return Yi;
  Vu = 1;
  var r = ng(), e = fg(), t = cg();
  function a() {
    this.size = 0, this.__data__ = {
      hash: new r(),
      map: new (t || e)(),
      string: new r()
    };
  }
  return Yi = a, Yi;
}
var Xi, Uu;
function hg() {
  if (Uu)
    return Xi;
  Uu = 1;
  function r(e) {
    var t = typeof e;
    return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
  }
  return Xi = r, Xi;
}
var $i, qu;
function qn() {
  if (qu)
    return $i;
  qu = 1;
  var r = hg();
  function e(t, a) {
    var n = t.__data__;
    return r(a) ? n[typeof a == "string" ? "string" : "hash"] : n.map;
  }
  return $i = e, $i;
}
var Wi, Hu;
function dg() {
  if (Hu)
    return Wi;
  Hu = 1;
  var r = qn();
  function e(t) {
    var a = r(this, t).delete(t);
    return this.size -= a ? 1 : 0, a;
  }
  return Wi = e, Wi;
}
var Ki, Yu;
function gg() {
  if (Yu)
    return Ki;
  Yu = 1;
  var r = qn();
  function e(t) {
    return r(this, t).get(t);
  }
  return Ki = e, Ki;
}
var Zi, Xu;
function pg() {
  if (Xu)
    return Zi;
  Xu = 1;
  var r = qn();
  function e(t) {
    return r(this, t).has(t);
  }
  return Zi = e, Zi;
}
var Qi, $u;
function yg() {
  if ($u)
    return Qi;
  $u = 1;
  var r = qn();
  function e(t, a) {
    var n = r(this, t), i = n.size;
    return n.set(t, a), this.size += n.size == i ? 0 : 1, this;
  }
  return Qi = e, Qi;
}
var Ji, Wu;
function mg() {
  if (Wu)
    return Ji;
  Wu = 1;
  var r = vg(), e = dg(), t = gg(), a = pg(), n = yg();
  function i(s) {
    var o = -1, u = s == null ? 0 : s.length;
    for (this.clear(); ++o < u; ) {
      var l = s[o];
      this.set(l[0], l[1]);
    }
  }
  return i.prototype.clear = r, i.prototype.delete = e, i.prototype.get = t, i.prototype.has = a, i.prototype.set = n, Ji = i, Ji;
}
var ji, Ku;
function bg() {
  if (Ku)
    return ji;
  Ku = 1;
  var r = mg(), e = "Expected a function";
  function t(a, n) {
    if (typeof a != "function" || n != null && typeof n != "function")
      throw new TypeError(e);
    var i = function() {
      var s = arguments, o = n ? n.apply(this, s) : s[0], u = i.cache;
      if (u.has(o))
        return u.get(o);
      var l = a.apply(this, s);
      return i.cache = u.set(o, l) || u, l;
    };
    return i.cache = new (t.Cache || r)(), i;
  }
  return t.Cache = r, ji = t, ji;
}
var es, Zu;
function wg() {
  if (Zu)
    return es;
  Zu = 1;
  var r = bg(), e = 500;
  function t(a) {
    var n = r(a, function(s) {
      return i.size === e && i.clear(), s;
    }), i = n.cache;
    return n;
  }
  return es = t, es;
}
var ts, Qu;
function Vf() {
  if (Qu)
    return ts;
  Qu = 1;
  var r = wg(), e = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, t = /\\(\\)?/g, a = r(function(n) {
    var i = [];
    return n.charCodeAt(0) === 46 && i.push(""), n.replace(e, function(s, o, u, l) {
      i.push(u ? l.replace(t, "$1") : o || s);
    }), i;
  });
  return ts = a, ts;
}
var rs, Ju;
function Uf() {
  if (Ju)
    return rs;
  Ju = 1;
  function r(e, t) {
    for (var a = -1, n = e == null ? 0 : e.length, i = Array(n); ++a < n; )
      i[a] = t(e[a], a, e);
    return i;
  }
  return rs = r, rs;
}
var as, ju;
function Eg() {
  if (ju)
    return as;
  ju = 1;
  var r = no(), e = Uf(), t = zn(), a = Fa(), n = r ? r.prototype : void 0, i = n ? n.toString : void 0;
  function s(o) {
    if (typeof o == "string")
      return o;
    if (t(o))
      return e(o, s) + "";
    if (a(o))
      return i ? i.call(o) : "";
    var u = o + "";
    return u == "0" && 1 / o == -1 / 0 ? "-0" : u;
  }
  return as = s, as;
}
var ns, el;
function qf() {
  if (el)
    return ns;
  el = 1;
  var r = Eg();
  function e(t) {
    return t == null ? "" : r(t);
  }
  return ns = e, ns;
}
var is, tl;
function Hf() {
  if (tl)
    return is;
  tl = 1;
  var r = zn(), e = Xd(), t = Vf(), a = qf();
  function n(i, s) {
    return r(i) ? i : e(i, s) ? [i] : t(a(i));
  }
  return is = n, is;
}
var ss, rl;
function go() {
  if (rl)
    return ss;
  rl = 1;
  var r = Fa();
  function e(t) {
    if (typeof t == "string" || r(t))
      return t;
    var a = t + "";
    return a == "0" && 1 / t == -1 / 0 ? "-0" : a;
  }
  return ss = e, ss;
}
var os, al;
function xg() {
  if (al)
    return os;
  al = 1;
  var r = Hf(), e = go();
  function t(a, n) {
    n = r(n, a);
    for (var i = 0, s = n.length; a != null && i < s; )
      a = a[e(n[i++])];
    return i && i == s ? a : void 0;
  }
  return os = t, os;
}
var us, nl;
function Tg() {
  if (nl)
    return us;
  nl = 1;
  var r = xg();
  function e(t, a, n) {
    var i = t == null ? void 0 : r(t, a);
    return i === void 0 ? n : i;
  }
  return us = e, us;
}
var Cg = Tg(), Dg = /* @__PURE__ */ ka(Cg), ls, il;
function Sg() {
  if (il)
    return ls;
  il = 1;
  var r = ho(), e = function() {
    try {
      var t = r(Object, "defineProperty");
      return t({}, "", {}), t;
    } catch {
    }
  }();
  return ls = e, ls;
}
var fs, sl;
function Ag() {
  if (sl)
    return fs;
  sl = 1;
  var r = Sg();
  function e(t, a, n) {
    a == "__proto__" && r ? r(t, a, {
      configurable: !0,
      enumerable: !0,
      value: n,
      writable: !0
    }) : t[a] = n;
  }
  return fs = e, fs;
}
var cs, ol;
function Lg() {
  if (ol)
    return cs;
  ol = 1;
  var r = Ag(), e = zf(), t = Object.prototype, a = t.hasOwnProperty;
  function n(i, s, o) {
    var u = i[s];
    (!(a.call(i, s) && e(u, o)) || o === void 0 && !(s in i)) && r(i, s, o);
  }
  return cs = n, cs;
}
var vs, ul;
function Rg() {
  if (ul)
    return vs;
  ul = 1;
  var r = 9007199254740991, e = /^(?:0|[1-9]\d*)$/;
  function t(a, n) {
    var i = typeof a;
    return n = n ?? r, !!n && (i == "number" || i != "symbol" && e.test(a)) && a > -1 && a % 1 == 0 && a < n;
  }
  return vs = t, vs;
}
var hs, ll;
function Ig() {
  if (ll)
    return hs;
  ll = 1;
  var r = Lg(), e = Hf(), t = Rg(), a = Ba(), n = go();
  function i(s, o, u, l) {
    if (!a(s))
      return s;
    o = e(o, s);
    for (var f = -1, c = o.length, v = c - 1, h = s; h != null && ++f < c; ) {
      var d = n(o[f]), p = u;
      if (d === "__proto__" || d === "constructor" || d === "prototype")
        return s;
      if (f != v) {
        var g = h[d];
        p = l ? l(g, d, h) : void 0, p === void 0 && (p = a(g) ? g : t(o[f + 1]) ? [] : {});
      }
      r(h, d, p), h = h[d];
    }
    return s;
  }
  return hs = i, hs;
}
var ds, fl;
function Mg() {
  if (fl)
    return ds;
  fl = 1;
  var r = Ig();
  function e(t, a, n) {
    return t == null ? t : r(t, a, n);
  }
  return ds = e, ds;
}
var Og = Mg(), Pg = /* @__PURE__ */ ka(Og), gs, cl;
function Ng() {
  if (cl)
    return gs;
  cl = 1;
  function r(e, t) {
    var a = -1, n = e.length;
    for (t || (t = Array(n)); ++a < n; )
      t[a] = e[a];
    return t;
  }
  return gs = r, gs;
}
var ps, vl;
function kg() {
  if (vl)
    return ps;
  vl = 1;
  var r = Uf(), e = Ng(), t = zn(), a = Fa(), n = Vf(), i = go(), s = qf();
  function o(u) {
    return t(u) ? r(u, i) : a(u) ? [u] : e(n(s(u)));
  }
  return ps = o, ps;
}
var Bg = kg(), Fg = /* @__PURE__ */ ka(Bg), _g = {
  // access data field
  data: function(e) {
    var t = {
      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 = de({}, t, e), function(n, i) {
      var s = e, o = this, u = o.length !== void 0, l = u ? o : [o], f = u ? o[0] : o;
      if (ce(n)) {
        var c = n.indexOf(".") !== -1, v = c && Fg(n);
        if (s.allowGetting && i === void 0) {
          var h;
          return f && (s.beforeGet(f), v && f._private[s.field][n] === void 0 ? h = Dg(f._private[s.field], v) : h = f._private[s.field][n]), h;
        } else if (s.allowSetting && i !== void 0) {
          var d = !s.immutableKeys[n];
          if (d) {
            var p = sf({}, n, i);
            s.beforeSet(o, p);
            for (var g = 0, y = l.length; g < y; g++) {
              var b = l[g];
              s.canSet(b) && (v && f._private[s.field][n] === void 0 ? Pg(b._private[s.field], v, i) : b._private[s.field][n] = i);
            }
            s.updateStyle && o.updateStyle(), s.onSet(o), s.settingTriggersEvent && o[s.triggerFnName](s.settingEvent);
          }
        }
      } else if (s.allowSetting && Re(n)) {
        var m = n, E, x, S = Object.keys(m);
        s.beforeSet(o, m);
        for (var w = 0; w < S.length; w++) {
          E = S[w], x = m[E];
          var T = !s.immutableKeys[E];
          if (T)
            for (var C = 0; C < l.length; C++) {
              var D = l[C];
              s.canSet(D) && (D._private[s.field][E] = x);
            }
        }
        s.updateStyle && o.updateStyle(), s.onSet(o), s.settingTriggersEvent && o[s.triggerFnName](s.settingEvent);
      } else if (s.allowBinding && He(n)) {
        var A = n;
        o.on(s.bindingEvent, A);
      } else if (s.allowGetting && n === void 0) {
        var L;
        return f && (s.beforeGet(f), L = f._private[s.field]), L;
      }
      return o;
    };
  },
  // data
  // remove data field
  removeData: function(e) {
    var t = {
      field: "data",
      event: "data",
      triggerFnName: "trigger",
      triggerEvent: !1,
      immutableKeys: {}
      // key => true if immutable
    };
    return e = de({}, t, e), function(n) {
      var i = e, s = this, o = s.length !== void 0, u = o ? s : [s];
      if (ce(n)) {
        for (var l = n.split(/\s+/), f = l.length, c = 0; c < f; c++) {
          var v = l[c];
          if (!sr(v)) {
            var h = !i.immutableKeys[v];
            if (h)
              for (var d = 0, p = u.length; d < p; d++)
                u[d]._private[i.field][v] = void 0;
          }
        }
        i.triggerEvent && s[i.triggerFnName](i.event);
      } else if (n === void 0) {
        for (var g = 0, y = u.length; g < y; g++)
          for (var b = u[g]._private[i.field], m = Object.keys(b), E = 0; E < m.length; E++) {
            var x = m[E], S = !i.immutableKeys[x];
            S && (b[x] = void 0);
          }
        i.triggerEvent && s[i.triggerFnName](i.event);
      }
      return s;
    };
  }
  // removeData
}, Gg = {
  eventAliasesOn: function(e) {
    var t = e;
    t.addListener = t.listen = t.bind = t.on, t.unlisten = t.unbind = t.off = t.removeListener, t.trigger = t.emit, t.pon = t.promiseOn = function(a, n) {
      var i = this, s = Array.prototype.slice.call(arguments, 0);
      return new aa(function(o, u) {
        var l = function(h) {
          i.off.apply(i, c), o(h);
        }, f = s.concat([l]), c = f.concat([]);
        i.on.apply(i, f);
      });
    };
  }
}, Oe = {};
[Yd, _g, Gg].forEach(function(r) {
  de(Oe, r);
});
var zg = {
  animate: Oe.animate(),
  animation: Oe.animation(),
  animated: Oe.animated(),
  clearQueue: Oe.clearQueue(),
  delay: Oe.delay(),
  delayAnimation: Oe.delayAnimation(),
  stop: Oe.stop()
}, cn = {
  classes: function(e) {
    var t = this;
    if (e === void 0) {
      var a = [];
      return t[0]._private.classes.forEach(function(d) {
        return a.push(d);
      }), a;
    } else
      _e(e) || (e = (e || "").match(/\S+/g) || []);
    for (var n = [], i = new ra(e), s = 0; s < t.length; s++) {
      for (var o = t[s], u = o._private, l = u.classes, f = !1, c = 0; c < e.length; c++) {
        var v = e[c], h = l.has(v);
        if (!h) {
          f = !0;
          break;
        }
      }
      f || (f = l.size !== e.length), f && (u.classes = i, n.push(o));
    }
    return n.length > 0 && this.spawn(n).updateStyle().emit("class"), t;
  },
  addClass: function(e) {
    return this.toggleClass(e, !0);
  },
  hasClass: function(e) {
    var t = this[0];
    return t != null && t._private.classes.has(e);
  },
  toggleClass: function(e, t) {
    _e(e) || (e = e.match(/\S+/g) || []);
    for (var a = this, n = t === void 0, i = [], s = 0, o = a.length; s < o; s++)
      for (var u = a[s], l = u._private.classes, f = !1, c = 0; c < e.length; c++) {
        var v = e[c], h = l.has(v), d = !1;
        t || n && !h ? (l.add(v), d = !0) : (!t || n && h) && (l.delete(v), 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, t) {
    var a = this;
    if (t == null)
      t = 250;
    else if (t === 0)
      return a;
    return a.addClass(e), setTimeout(function() {
      a.removeClass(e);
    }, t), a;
  }
};
cn.className = cn.classNames = cn.classes;
var Le = {
  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: tt,
  // 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+"
};
Le.variable = "(?:[\\w-.]|(?:\\\\" + Le.metaChar + "))+";
Le.className = "(?:[\\w-]|(?:\\\\" + Le.metaChar + "))+";
Le.value = Le.string + "|" + Le.number;
Le.id = Le.variable;
(function() {
  var r, e, t;
  for (r = Le.comparatorOp.split("|"), t = 0; t < r.length; t++)
    e = r[t], Le.comparatorOp += "|@" + e;
  for (r = Le.comparatorOp.split("|"), t = 0; t < r.length; t++)
    e = r[t], !(e.indexOf("!") >= 0) && e !== "=" && (Le.comparatorOp += "|\\!" + e);
})();
var Be = function() {
  return {
    checks: []
  };
}, ie = {
  /** 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
}, Gs = [{
  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(r, e) {
  return Vv(r.selector, e.selector);
}), Vg = function() {
  for (var r = {}, e, t = 0; t < Gs.length; t++)
    e = Gs[t], r[e.selector] = e.matches;
  return r;
}(), Ug = function(e, t) {
  return Vg[e](t);
}, qg = "(" + Gs.map(function(r) {
  return r.selector;
}).join("|") + ")", Br = function(e) {
  return e.replace(new RegExp("\\\\(" + Le.metaChar + ")", "g"), function(t, a) {
    return a;
  });
}, rr = function(e, t, a) {
  e[e.length - 1] = a;
}, zs = [{
  name: "group",
  // just used for identifying when debugging
  query: !0,
  regex: "(" + Le.group + ")",
  populate: function(e, t, a) {
    var n = je(a, 1), i = n[0];
    t.checks.push({
      type: ie.GROUP,
      value: i === "*" ? i : i + "s"
    });
  }
}, {
  name: "state",
  query: !0,
  regex: qg,
  populate: function(e, t, a) {
    var n = je(a, 1), i = n[0];
    t.checks.push({
      type: ie.STATE,
      value: i
    });
  }
}, {
  name: "id",
  query: !0,
  regex: "\\#(" + Le.id + ")",
  populate: function(e, t, a) {
    var n = je(a, 1), i = n[0];
    t.checks.push({
      type: ie.ID,
      value: Br(i)
    });
  }
}, {
  name: "className",
  query: !0,
  regex: "\\.(" + Le.className + ")",
  populate: function(e, t, a) {
    var n = je(a, 1), i = n[0];
    t.checks.push({
      type: ie.CLASS,
      value: Br(i)
    });
  }
}, {
  name: "dataExists",
  query: !0,
  regex: "\\[\\s*(" + Le.variable + ")\\s*\\]",
  populate: function(e, t, a) {
    var n = je(a, 1), i = n[0];
    t.checks.push({
      type: ie.DATA_EXIST,
      field: Br(i)
    });
  }
}, {
  name: "dataCompare",
  query: !0,
  regex: "\\[\\s*(" + Le.variable + ")\\s*(" + Le.comparatorOp + ")\\s*(" + Le.value + ")\\s*\\]",
  populate: function(e, t, a) {
    var n = je(a, 3), i = n[0], s = n[1], o = n[2], u = new RegExp("^" + Le.string + "$").exec(o) != null;
    u ? o = o.substring(1, o.length - 1) : o = parseFloat(o), t.checks.push({
      type: ie.DATA_COMPARE,
      field: Br(i),
      operator: s,
      value: o
    });
  }
}, {
  name: "dataBool",
  query: !0,
  regex: "\\[\\s*(" + Le.boolOp + ")\\s*(" + Le.variable + ")\\s*\\]",
  populate: function(e, t, a) {
    var n = je(a, 2), i = n[0], s = n[1];
    t.checks.push({
      type: ie.DATA_BOOL,
      field: Br(s),
      operator: i
    });
  }
}, {
  name: "metaCompare",
  query: !0,
  regex: "\\[\\[\\s*(" + Le.meta + ")\\s*(" + Le.comparatorOp + ")\\s*(" + Le.number + ")\\s*\\]\\]",
  populate: function(e, t, a) {
    var n = je(a, 3), i = n[0], s = n[1], o = n[2];
    t.checks.push({
      type: ie.META_COMPARE,
      field: Br(i),
      operator: s,
      value: parseFloat(o)
    });
  }
}, {
  name: "nextQuery",
  separator: !0,
  regex: Le.separator,
  populate: function(e, t) {
    var a = e.currentSubject, n = e.edgeCount, i = e.compoundCount, s = e[e.length - 1];
    a != null && (s.subject = a, e.currentSubject = null), s.edgeCount = n, s.compoundCount = i, e.edgeCount = 0, e.compoundCount = 0;
    var o = e[e.length++] = Be();
    return o;
  }
}, {
  name: "directedEdge",
  separator: !0,
  regex: Le.directedEdge,
  populate: function(e, t) {
    if (e.currentSubject == null) {
      var a = Be(), n = t, i = Be();
      return a.checks.push({
        type: ie.DIRECTED_EDGE,
        source: n,
        target: i
      }), rr(e, t, a), e.edgeCount++, i;
    } else {
      var s = Be(), o = t, u = Be();
      return s.checks.push({
        type: ie.NODE_SOURCE,
        source: o,
        target: u
      }), rr(e, t, s), e.edgeCount++, u;
    }
  }
}, {
  name: "undirectedEdge",
  separator: !0,
  regex: Le.undirectedEdge,
  populate: function(e, t) {
    if (e.currentSubject == null) {
      var a = Be(), n = t, i = Be();
      return a.checks.push({
        type: ie.UNDIRECTED_EDGE,
        nodes: [n, i]
      }), rr(e, t, a), e.edgeCount++, i;
    } else {
      var s = Be(), o = t, u = Be();
      return s.checks.push({
        type: ie.NODE_NEIGHBOR,
        node: o,
        neighbor: u
      }), rr(e, t, s), u;
    }
  }
}, {
  name: "child",
  separator: !0,
  regex: Le.child,
  populate: function(e, t) {
    if (e.currentSubject == null) {
      var a = Be(), n = Be(), i = e[e.length - 1];
      return a.checks.push({
        type: ie.CHILD,
        parent: i,
        child: n
      }), rr(e, t, a), e.compoundCount++, n;
    } else if (e.currentSubject === t) {
      var s = Be(), o = e[e.length - 1], u = Be(), l = Be(), f = Be(), c = Be();
      return s.checks.push({
        type: ie.COMPOUND_SPLIT,
        left: o,
        right: u,
        subject: l
      }), l.checks = t.checks, t.checks = [{
        type: ie.TRUE
      }], c.checks.push({
        type: ie.TRUE
      }), u.checks.push({
        type: ie.PARENT,
        // type is swapped on right side queries
        parent: c,
        child: f
        // empty for now
      }), rr(e, o, s), e.currentSubject = l, e.compoundCount++, f;
    } else {
      var v = Be(), h = Be(), d = [{
        type: ie.PARENT,
        parent: v,
        child: h
      }];
      return v.checks = t.checks, t.checks = d, e.compoundCount++, h;
    }
  }
}, {
  name: "descendant",
  separator: !0,
  regex: Le.descendant,
  populate: function(e, t) {
    if (e.currentSubject == null) {
      var a = Be(), n = Be(), i = e[e.length - 1];
      return a.checks.push({
        type: ie.DESCENDANT,
        ancestor: i,
        descendant: n
      }), rr(e, t, a), e.compoundCount++, n;
    } else if (e.currentSubject === t) {
      var s = Be(), o = e[e.length - 1], u = Be(), l = Be(), f = Be(), c = Be();
      return s.checks.push({
        type: ie.COMPOUND_SPLIT,
        left: o,
        right: u,
        subject: l
      }), l.checks = t.checks, t.checks = [{
        type: ie.TRUE
      }], c.checks.push({
        type: ie.TRUE
      }), u.checks.push({
        type: ie.ANCESTOR,
        // type is swapped on right side queries
        ancestor: c,
        descendant: f
        // empty for now
      }), rr(e, o, s), e.currentSubject = l, e.compoundCount++, f;
    } else {
      var v = Be(), h = Be(), d = [{
        type: ie.ANCESTOR,
        ancestor: v,
        descendant: h
      }];
      return v.checks = t.checks, t.checks = d, e.compoundCount++, h;
    }
  }
}, {
  name: "subject",
  modifier: !0,
  regex: Le.subject,
  populate: function(e, t) {
    if (e.currentSubject != null && e.currentSubject !== t)
      return Pe("Redefinition of subject in selector `" + e.toString() + "`"), !1;
    e.currentSubject = t;
    var a = e[e.length - 1], n = a.checks[0], i = n == null ? null : n.type;
    i === ie.DIRECTED_EDGE ? n.type = ie.NODE_TARGET : i === ie.UNDIRECTED_EDGE && (n.type = ie.NODE_NEIGHBOR, n.node = n.nodes[1], n.neighbor = n.nodes[0], n.nodes = null);
  }
}];
zs.forEach(function(r) {
  return r.regexObj = new RegExp("^" + r.regex);
});
var Hg = function(e) {
  for (var t, a, n, i = 0; i < zs.length; i++) {
    var s = zs[i], o = s.name, u = e.match(s.regexObj);
    if (u != null) {
      a = u, t = s, n = o;
      var l = u[0];
      e = e.substring(l.length);
      break;
    }
  }
  return {
    expr: t,
    match: a,
    name: n,
    remaining: e
  };
}, Yg = function(e) {
  var t = e.match(/^\s+/);
  if (t) {
    var a = t[0];
    e = e.substring(a.length);
  }
  return e;
}, Xg = function(e) {
  var t = this, a = t.inputText = e, n = t[0] = Be();
  for (t.length = 1, a = Yg(a); ; ) {
    var i = Hg(a);
    if (i.expr == null)
      return Pe("The selector `" + e + "`is invalid"), !1;
    var s = i.match.slice(1), o = i.expr.populate(t, n, s);
    if (o === !1)
      return !1;
    if (o != null && (n = o), a = i.remaining, a.match(/^\s*$/))
      break;
  }
  var u = t[t.length - 1];
  t.currentSubject != null && (u.subject = t.currentSubject), u.edgeCount = t.edgeCount, u.compoundCount = t.compoundCount;
  for (var l = 0; l < t.length; l++) {
    var f = t[l];
    if (f.compoundCount > 0 && f.edgeCount > 0)
      return Pe("The selector `" + e + "` is invalid because it uses both a compound selector and an edge selector"), !1;
    if (f.edgeCount > 1)
      return Pe("The selector `" + e + "` is invalid because it uses multiple edge selectors"), !1;
    f.edgeCount === 1 && Pe("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;
}, $g = function() {
  if (this.toStringCache != null)
    return this.toStringCache;
  for (var e = function(f) {
    return f ?? "";
  }, t = function(f) {
    return ce(f) ? '"' + f + '"' : e(f);
  }, a = function(f) {
    return " " + f + " ";
  }, n = function(f, c) {
    var v = f.type, h = f.value;
    switch (v) {
      case ie.GROUP: {
        var d = e(h);
        return d.substring(0, d.length - 1);
      }
      case ie.DATA_COMPARE: {
        var p = f.field, g = f.operator;
        return "[" + p + a(e(g)) + t(h) + "]";
      }
      case ie.DATA_BOOL: {
        var y = f.operator, b = f.field;
        return "[" + e(y) + b + "]";
      }
      case ie.DATA_EXIST: {
        var m = f.field;
        return "[" + m + "]";
      }
      case ie.META_COMPARE: {
        var E = f.operator, x = f.field;
        return "[[" + x + a(e(E)) + t(h) + "]]";
      }
      case ie.STATE:
        return h;
      case ie.ID:
        return "#" + h;
      case ie.CLASS:
        return "." + h;
      case ie.PARENT:
      case ie.CHILD:
        return i(f.parent, c) + a(">") + i(f.child, c);
      case ie.ANCESTOR:
      case ie.DESCENDANT:
        return i(f.ancestor, c) + " " + i(f.descendant, c);
      case ie.COMPOUND_SPLIT: {
        var S = i(f.left, c), w = i(f.subject, c), T = i(f.right, c);
        return S + (S.length > 0 ? " " : "") + w + T;
      }
      case ie.TRUE:
        return "";
    }
  }, i = function(f, c) {
    return f.checks.reduce(function(v, h, d) {
      return v + (c === f && d === 0 ? "$" : "") + n(h, c);
    }, "");
  }, s = "", o = 0; o < this.length; o++) {
    var u = this[o];
    s += i(u, u.subject), this.length > 1 && o < this.length - 1 && (s += ", ");
  }
  return this.toStringCache = s, s;
}, Wg = {
  parse: Xg,
  toString: $g
}, Yf = function(e, t, a) {
  var n, i = ce(e), s = ae(e), o = ce(a), u, l, f = !1, c = !1, v = !1;
  switch (t.indexOf("!") >= 0 && (t = t.replace("!", ""), c = !0), t.indexOf("@") >= 0 && (t = t.replace("@", ""), f = !0), (i || o || f) && (u = !i && !s ? "" : "" + e, l = "" + a), f && (e = u = u.toLowerCase(), a = l = l.toLowerCase()), t) {
    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 ">":
      v = !0, n = e > a;
      break;
    case ">=":
      v = !0, n = e >= a;
      break;
    case "<":
      v = !0, n = e < a;
      break;
    case "<=":
      v = !0, n = e <= a;
      break;
    default:
      n = !1;
      break;
  }
  return c && (e != null || !v) && (n = !n), n;
}, Kg = function(e, t) {
  switch (t) {
    case "?":
      return !!e;
    case "!":
      return !e;
    case "^":
      return e === void 0;
  }
}, Zg = function(e) {
  return e !== void 0;
}, po = function(e, t) {
  return e.data(t);
}, Qg = function(e, t) {
  return e[t]();
}, Xe = [], Ue = function(e, t) {
  return e.checks.every(function(a) {
    return Xe[a.type](a, t);
  });
};
Xe[ie.GROUP] = function(r, e) {
  var t = r.value;
  return t === "*" || t === e.group();
};
Xe[ie.STATE] = function(r, e) {
  var t = r.value;
  return Ug(t, e);
};
Xe[ie.ID] = function(r, e) {
  var t = r.value;
  return e.id() === t;
};
Xe[ie.CLASS] = function(r, e) {
  var t = r.value;
  return e.hasClass(t);
};
Xe[ie.META_COMPARE] = function(r, e) {
  var t = r.field, a = r.operator, n = r.value;
  return Yf(Qg(e, t), a, n);
};
Xe[ie.DATA_COMPARE] = function(r, e) {
  var t = r.field, a = r.operator, n = r.value;
  return Yf(po(e, t), a, n);
};
Xe[ie.DATA_BOOL] = function(r, e) {
  var t = r.field, a = r.operator;
  return Kg(po(e, t), a);
};
Xe[ie.DATA_EXIST] = function(r, e) {
  var t = r.field;
  return r.operator, Zg(po(e, t));
};
Xe[ie.UNDIRECTED_EDGE] = function(r, e) {
  var t = r.nodes[0], a = r.nodes[1], n = e.source(), i = e.target();
  return Ue(t, n) && Ue(a, i) || Ue(a, n) && Ue(t, i);
};
Xe[ie.NODE_NEIGHBOR] = function(r, e) {
  return Ue(r.node, e) && e.neighborhood().some(function(t) {
    return t.isNode() && Ue(r.neighbor, t);
  });
};
Xe[ie.DIRECTED_EDGE] = function(r, e) {
  return Ue(r.source, e.source()) && Ue(r.target, e.target());
};
Xe[ie.NODE_SOURCE] = function(r, e) {
  return Ue(r.source, e) && e.outgoers().some(function(t) {
    return t.isNode() && Ue(r.target, t);
  });
};
Xe[ie.NODE_TARGET] = function(r, e) {
  return Ue(r.target, e) && e.incomers().some(function(t) {
    return t.isNode() && Ue(r.source, t);
  });
};
Xe[ie.CHILD] = function(r, e) {
  return Ue(r.child, e) && Ue(r.parent, e.parent());
};
Xe[ie.PARENT] = function(r, e) {
  return Ue(r.parent, e) && e.children().some(function(t) {
    return Ue(r.child, t);
  });
};
Xe[ie.DESCENDANT] = function(r, e) {
  return Ue(r.descendant, e) && e.ancestors().some(function(t) {
    return Ue(r.ancestor, t);
  });
};
Xe[ie.ANCESTOR] = function(r, e) {
  return Ue(r.ancestor, e) && e.descendants().some(function(t) {
    return Ue(r.descendant, t);
  });
};
Xe[ie.COMPOUND_SPLIT] = function(r, e) {
  return Ue(r.subject, e) && Ue(r.left, e) && Ue(r.right, e);
};
Xe[ie.TRUE] = function() {
  return !0;
};
Xe[ie.COLLECTION] = function(r, e) {
  var t = r.value;
  return t.has(e);
};
Xe[ie.FILTER] = function(r, e) {
  var t = r.value;
  return t(e);
};
var Jg = function(e) {
  var t = this;
  if (t.length === 1 && t[0].checks.length === 1 && t[0].checks[0].type === ie.ID)
    return e.getElementById(t[0].checks[0].value).collection();
  var a = function(i) {
    for (var s = 0; s < t.length; s++) {
      var o = t[s];
      if (Ue(o, i))
        return !0;
    }
    return !1;
  };
  return t.text() == null && (a = function() {
    return !0;
  }), e.filter(a);
}, jg = function(e) {
  for (var t = this, a = 0; a < t.length; a++) {
    var n = t[a];
    if (Ue(n, e))
      return !0;
  }
  return !1;
}, ep = {
  matches: jg,
  filter: Jg
}, lr = function(e) {
  this.inputText = e, this.currentSubject = null, this.compoundCount = 0, this.edgeCount = 0, this.length = 0, e == null || ce(e) && e.match(/^\s*$/) || (At(e) ? this.addQuery({
    checks: [{
      type: ie.COLLECTION,
      value: e.collection()
    }]
  }) : He(e) ? this.addQuery({
    checks: [{
      type: ie.FILTER,
      value: e
    }]
  }) : ce(e) ? this.parse(e) || (this.invalid = !0) : qe("A selector must be created from a string; found "));
}, fr = lr.prototype;
[Wg, ep].forEach(function(r) {
  return de(fr, r);
});
fr.text = function() {
  return this.inputText;
};
fr.size = function() {
  return this.length;
};
fr.eq = function(r) {
  return this[r];
};
fr.sameText = function(r) {
  return !this.invalid && !r.invalid && this.text() === r.text();
};
fr.addQuery = function(r) {
  this[this.length++] = r;
};
fr.selector = fr.toString;
var nr = {
  allAre: function(e) {
    var t = new lr(e);
    return this.every(function(a) {
      return t.matches(a);
    });
  },
  is: function(e) {
    var t = new lr(e);
    return this.some(function(a) {
      return t.matches(a);
    });
  },
  some: function(e, t) {
    for (var a = 0; a < this.length; a++) {
      var n = t ? e.apply(t, [this[a], a, this]) : e(this[a], a, this);
      if (n)
        return !0;
    }
    return !1;
  },
  every: function(e, t) {
    for (var a = 0; a < this.length; a++) {
      var n = t ? e.apply(t, [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 t = this.length, a = e.length;
    return t !== a ? !1 : t === 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(t) {
      return e.hasElementWithId(t.id());
    });
  },
  allAreNeighbors: function(e) {
    e = this.cy().collection(e);
    var t = this.neighborhood();
    return e.every(function(a) {
      return t.hasElementWithId(a.id());
    });
  },
  contains: function(e) {
    e = this.cy().collection(e);
    var t = this;
    return e.every(function(a) {
      return t.hasElementWithId(a.id());
    });
  }
};
nr.allAreNeighbours = nr.allAreNeighbors;
nr.has = nr.contains;
nr.equal = nr.equals = nr.same;
var It = function(e, t) {
  return function(n, i, s, o) {
    var u = n, l = this, f;
    if (u == null ? f = "" : At(u) && u.length === 1 && (f = u.id()), l.length === 1 && f) {
      var c = l[0]._private, v = c.traversalCache = c.traversalCache || {}, h = v[t] = v[t] || [], d = Ar(f), p = h[d];
      return p || (h[d] = e.call(l, n, i, s, o));
    } else
      return e.call(l, n, i, s, o);
  };
}, ta = {
  parent: function(e) {
    var t = [];
    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], s = i._private.parent;
      s && t.push(s);
    }
    return this.spawn(t, !0).filter(e);
  },
  parents: function(e) {
    for (var t = [], a = this.parent(); a.nonempty(); ) {
      for (var n = 0; n < a.length; n++) {
        var i = a[n];
        t.push(i);
      }
      a = a.parent();
    }
    return this.spawn(t, !0).filter(e);
  },
  commonAncestors: function(e) {
    for (var t, a = 0; a < this.length; a++) {
      var n = this[a], i = n.parents();
      t = t || i, t = t.intersect(i);
    }
    return t.filter(e);
  },
  orphans: function(e) {
    return this.stdFilter(function(t) {
      return t.isOrphan();
    }).filter(e);
  },
  nonorphans: function(e) {
    return this.stdFilter(function(t) {
      return t.isChild();
    }).filter(e);
  },
  children: It(function(r) {
    for (var e = [], t = 0; t < this.length; t++)
      for (var a = this[t], n = a._private.children, i = 0; i < n.length; i++)
        e.push(n[i]);
    return this.spawn(e, !0).filter(r);
  }, "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 t = [];
    function a(n) {
      for (var i = 0; i < n.length; i++) {
        var s = n[i];
        t.push(s), s.children().nonempty() && a(s.children());
      }
    }
    return a(this.children()), this.spawn(t, !0).filter(e);
  }
};
function yo(r, e, t, a) {
  for (var n = [], i = new ra(), s = r.cy(), o = s.hasCompoundNodes(), u = 0; u < r.length; u++) {
    var l = r[u];
    t ? n.push(l) : o && a(n, i, l);
  }
  for (; n.length > 0; ) {
    var f = n.shift();
    e(f), i.add(f.id()), o && a(n, i, f);
  }
  return r;
}
function Xf(r, e, t) {
  if (t.isParent())
    for (var a = t._private.children, n = 0; n < a.length; n++) {
      var i = a[n];
      e.has(i.id()) || r.push(i);
    }
}
ta.forEachDown = function(r) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return yo(this, r, e, Xf);
};
function $f(r, e, t) {
  if (t.isChild()) {
    var a = t._private.parent;
    e.has(a.id()) || r.push(a);
  }
}
ta.forEachUp = function(r) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return yo(this, r, e, $f);
};
function tp(r, e, t) {
  $f(r, e, t), Xf(r, e, t);
}
ta.forEachUpAndDown = function(r) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
  return yo(this, r, e, tp);
};
ta.ancestors = ta.parents;
var La, Wf;
La = Wf = {
  data: Oe.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: Oe.removeData({
    field: "data",
    event: "data",
    triggerFnName: "trigger",
    triggerEvent: !0,
    immutableKeys: {
      id: !0,
      source: !0,
      target: !0,
      parent: !0
    },
    updateStyle: !0
  }),
  scratch: Oe.data({
    field: "scratch",
    bindingEvent: "scratch",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "scratch",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    updateStyle: !0
  }),
  removeScratch: Oe.removeData({
    field: "scratch",
    event: "scratch",
    triggerFnName: "trigger",
    triggerEvent: !0,
    updateStyle: !0
  }),
  rscratch: Oe.data({
    field: "rscratch",
    allowBinding: !1,
    allowSetting: !0,
    settingTriggersEvent: !1,
    allowGetting: !0
  }),
  removeRscratch: Oe.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 rp = Wf, Hn = {};
function ys(r) {
  return function(e) {
    var t = this;
    if (e === void 0 && (e = !0), t.length !== 0)
      if (t.isNode() && !t.removed()) {
        for (var a = 0, n = t[0], i = n._private.edges, s = 0; s < i.length; s++) {
          var o = i[s];
          !e && o.isLoop() || (a += r(n, o));
        }
        return a;
      } else
        return;
  };
}
de(Hn, {
  degree: ys(function(r, e) {
    return e.source().same(e.target()) ? 2 : 1;
  }),
  indegree: ys(function(r, e) {
    return e.target().same(r) ? 1 : 0;
  }),
  outdegree: ys(function(r, e) {
    return e.source().same(r) ? 1 : 0;
  })
});
function Fr(r, e) {
  return function(t) {
    for (var a, n = this.nodes(), i = 0; i < n.length; i++) {
      var s = n[i], o = s[r](t);
      o !== void 0 && (a === void 0 || e(o, a)) && (a = o);
    }
    return a;
  };
}
de(Hn, {
  minDegree: Fr("degree", function(r, e) {
    return r < e;
  }),
  maxDegree: Fr("degree", function(r, e) {
    return r > e;
  }),
  minIndegree: Fr("indegree", function(r, e) {
    return r < e;
  }),
  maxIndegree: Fr("indegree", function(r, e) {
    return r > e;
  }),
  minOutdegree: Fr("outdegree", function(r, e) {
    return r < e;
  }),
  maxOutdegree: Fr("outdegree", function(r, e) {
    return r > e;
  })
});
de(Hn, {
  totalDegree: function(e) {
    for (var t = 0, a = this.nodes(), n = 0; n < a.length; n++)
      t += a[n].degree(e);
    return t;
  }
});
var Nt, Kf, Zf = function(e, t, a) {
  for (var n = 0; n < e.length; n++) {
    var i = e[n];
    if (!i.locked()) {
      var s = i._private.position, o = {
        x: t.x != null ? t.x - s.x : 0,
        y: t.y != null ? t.y - s.y : 0
      };
      i.isParent() && !(o.x === 0 && o.y === 0) && i.children().shift(o, a), i.dirtyBoundingBoxCache();
    }
  }
}, hl = {
  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, t) {
    Zf(e, t, !1);
  },
  onSet: function(e) {
    e.dirtyCompoundBoundsCache();
  },
  canSet: function(e) {
    return !e.locked();
  }
};
Nt = Kf = {
  position: Oe.data(hl),
  // position but no notification to renderer
  silentPosition: Oe.data(de({}, hl, {
    allowBinding: !1,
    allowSetting: !0,
    settingTriggersEvent: !1,
    allowGetting: !1,
    beforeSet: function(e, t) {
      Zf(e, t, !0);
    },
    onSet: function(e) {
      e.dirtyCompoundBoundsCache();
    }
  })),
  positions: function(e, t) {
    if (Re(e))
      t ? 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 s = this[i], o = void 0;
        (o = a(s, i)) && (t ? s.silentPosition(o) : s.position(o));
      }
      n.endBatch();
    }
    return this;
  },
  silentPositions: function(e) {
    return this.positions(e, !0);
  },
  shift: function(e, t, a) {
    var n;
    if (Re(e) ? (n = {
      x: ae(e.x) ? e.x : 0,
      y: ae(e.y) ? e.y : 0
    }, a = t) : ce(e) && ae(t) && (n = {
      x: 0,
      y: 0
    }, n[e] = t), n != null) {
      var i = this.cy();
      i.startBatch();
      for (var s = 0; s < this.length; s++) {
        var o = this[s];
        if (!(i.hasCompoundNodes() && o.isChild() && o.ancestors().anySame(this))) {
          var u = o.position(), l = {
            x: u.x + n.x,
            y: u.y + n.y
          };
          a ? o.silentPosition(l) : o.position(l);
        }
      }
      i.endBatch();
    }
    return this;
  },
  silentShift: function(e, t) {
    return Re(e) ? this.shift(e, !0) : ce(e) && ae(t) && this.shift(e, t, !0), this;
  },
  // get/set the rendered (i.e. on screen) positon of the element
  renderedPosition: function(e, t) {
    var a = this[0], n = this.cy(), i = n.zoom(), s = n.pan(), o = Re(e) ? e : void 0, u = o !== void 0 || t !== void 0 && ce(e);
    if (a && a.isNode())
      if (u)
        for (var l = 0; l < this.length; l++) {
          var f = this[l];
          t !== void 0 ? f.position(e, (t - s[e]) / i) : o !== void 0 && f.position(Df(o, i, s));
        }
      else {
        var c = a.position();
        return o = _n(c, i, s), e === void 0 ? o : o[e];
      }
    else if (!u)
      return;
    return this;
  },
  // get/set the position relative to the parent
  relativePosition: function(e, t) {
    var a = this[0], n = this.cy(), i = Re(e) ? e : void 0, s = i !== void 0 || t !== void 0 && ce(e), o = n.hasCompoundNodes();
    if (a && a.isNode())
      if (s)
        for (var u = 0; u < this.length; u++) {
          var l = this[u], f = o ? l.parent() : null, c = f && f.length > 0, v = c;
          c && (f = f[0]);
          var h = v ? f.position() : {
            x: 0,
            y: 0
          };
          t !== void 0 ? l.position(e, t + h[e]) : i !== void 0 && l.position({
            x: i.x + h.x,
            y: i.y + h.y
          });
        }
      else {
        var d = a.position(), p = o ? a.parent() : null, g = p && p.length > 0, y = g;
        g && (p = p[0]);
        var b = y ? p.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 (!s)
      return;
    return this;
  }
};
Nt.modelPosition = Nt.point = Nt.position;
Nt.modelPositions = Nt.points = Nt.positions;
Nt.renderedPoint = Nt.renderedPosition;
Nt.relativePoint = Nt.relativePosition;
var ap = Kf, Qr, gr;
Qr = gr = {};
gr.renderedBoundingBox = function(r) {
  var e = this.boundingBox(r), t = this.cy(), a = t.zoom(), n = t.pan(), i = e.x1 * a + n.x, s = e.x2 * a + n.x, o = e.y1 * a + n.y, u = e.y2 * a + n.y;
  return {
    x1: i,
    x2: s,
    y1: o,
    y2: u,
    w: s - i,
    h: u - o
  };
};
gr.dirtyCompoundBoundsCache = function() {
  var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = this.cy();
  return !e.styleEnabled() || !e.hasCompoundNodes() ? this : (this.forEachUp(function(t) {
    if (t.isParent()) {
      var a = t._private;
      a.compoundBoundsClean = !1, a.bbCache = null, r || t.emitAndNotify("bounds");
    }
  }), this);
};
gr.updateCompoundBounds = function() {
  var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = this.cy();
  if (!e.styleEnabled() || !e.hasCompoundNodes())
    return this;
  if (!r && e.batching())
    return this;
  function t(s) {
    if (!s.isParent())
      return;
    var o = s._private, u = s.children(), l = s.pstyle("compound-sizing-wrt-labels").value === "include", f = {
      width: {
        val: s.pstyle("min-width").pfValue,
        left: s.pstyle("min-width-bias-left"),
        right: s.pstyle("min-width-bias-right")
      },
      height: {
        val: s.pstyle("min-height").pfValue,
        top: s.pstyle("min-height-bias-top"),
        bottom: s.pstyle("min-height-bias-bottom")
      }
    }, c = u.boundingBox({
      includeLabels: l,
      includeOverlays: !1,
      // updating the compound bounds happens outside of the regular
      // cache cycle (i.e. before fired events)
      useCache: !1
    }), v = o.position;
    (c.w === 0 || c.h === 0) && (c = {
      w: s.pstyle("width").pfValue,
      h: s.pstyle("height").pfValue
    }, c.x1 = v.x - c.w / 2, c.x2 = v.x + c.w / 2, c.y1 = v.y - c.h / 2, c.y2 = v.y + c.h / 2);
    function h(C, D, A) {
      var L = 0, R = 0, I = D + A;
      return C > 0 && I > 0 && (L = D / I * C, R = A / I * C), {
        biasDiff: L,
        biasComplementDiff: R
      };
    }
    function d(C, D, A, L) {
      if (A.units === "%")
        switch (L) {
          case "width":
            return C > 0 ? A.pfValue * C : 0;
          case "height":
            return D > 0 ? A.pfValue * D : 0;
          case "average":
            return C > 0 && D > 0 ? A.pfValue * (C + D) / 2 : 0;
          case "min":
            return C > 0 && D > 0 ? C > D ? A.pfValue * D : A.pfValue * C : 0;
          case "max":
            return C > 0 && D > 0 ? C > D ? A.pfValue * C : A.pfValue * D : 0;
          default:
            return 0;
        }
      else
        return A.units === "px" ? A.pfValue : 0;
    }
    var p = f.width.left.value;
    f.width.left.units === "px" && f.width.val > 0 && (p = p * 100 / f.width.val);
    var g = f.width.right.value;
    f.width.right.units === "px" && f.width.val > 0 && (g = g * 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 - c.w, p, g), E = m.biasDiff, x = m.biasComplementDiff, S = h(f.height.val - c.h, y, b), w = S.biasDiff, T = S.biasComplementDiff;
    o.autoPadding = d(c.w, c.h, s.pstyle("padding"), s.pstyle("padding-relative-to").value), o.autoWidth = Math.max(c.w, f.width.val), v.x = (-E + c.x1 + c.x2 + x) / 2, o.autoHeight = Math.max(c.h, f.height.val), v.y = (-w + c.y1 + c.y2 + T) / 2;
  }
  for (var a = 0; a < this.length; a++) {
    var n = this[a], i = n._private;
    (!i.compoundBoundsClean || r) && (t(n), e.batching() || (i.compoundBoundsClean = !0));
  }
  return this;
};
var Rt = function(e) {
  return e === 1 / 0 || e === -1 / 0 ? 0 : e;
}, Pt = function(e, t, a, n, i) {
  n - t === 0 || i - a === 0 || t == null || a == null || n == null || i == null || (e.x1 = t < e.x1 ? t : 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);
}, xr = function(e, t) {
  return t == null ? e : Pt(e, t.x1, t.y1, t.x2, t.y2);
}, ca = function(e, t, a) {
  return Tt(e, t, a);
}, en = function(e, t, a) {
  if (!t.cy().headless()) {
    var n = t._private, i = n.rstyle, s = i.arrowWidth / 2, o = t.pstyle(a + "-arrow-shape").value, u, l;
    if (o !== "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 || {}, c = f[a] = f[a] || {};
      c.x1 = u - s, c.y1 = l - s, c.x2 = u + s, c.y2 = l + s, c.w = c.x2 - c.x1, c.h = c.y2 - c.y1, ln(c, 1), Pt(e, c.x1, c.y1, c.x2, c.y2);
    }
  }
}, ms = function(e, t, a) {
  if (!t.cy().headless()) {
    var n;
    a ? n = a + "-" : n = "";
    var i = t._private, s = i.rstyle, o = t.pstyle(n + "label").strValue;
    if (o) {
      var u = t.pstyle("text-halign"), l = t.pstyle("text-valign"), f = ca(s, "labelWidth", a), c = ca(s, "labelHeight", a), v = ca(s, "labelX", a), h = ca(s, "labelY", a), d = t.pstyle(n + "text-margin-x").pfValue, p = t.pstyle(n + "text-margin-y").pfValue, g = t.isEdge(), y = t.pstyle(n + "text-rotation"), b = t.pstyle("text-outline-width").pfValue, m = t.pstyle("text-border-width").pfValue, E = m / 2, x = t.pstyle("text-background-padding").pfValue, S = 2, w = c, T = f, C = T / 2, D = w / 2, A, L, R, I;
      if (g)
        A = v - C, L = v + C, R = h - D, I = h + D;
      else {
        switch (u.value) {
          case "left":
            A = v - T, L = v;
            break;
          case "center":
            A = v - C, L = v + C;
            break;
          case "right":
            A = v, L = v + T;
            break;
        }
        switch (l.value) {
          case "top":
            R = h - w, I = h;
            break;
          case "center":
            R = h - D, I = h + D;
            break;
          case "bottom":
            R = h, I = h + w;
            break;
        }
      }
      var O = d - Math.max(b, E) - x - S, N = d + Math.max(b, E) + x + S, k = p - Math.max(b, E) - x - S, P = p + Math.max(b, E) + x + S;
      A += O, L += N, R += k, I += P;
      var B = a || "main", _ = i.labelBounds, F = _[B] = _[B] || {};
      F.x1 = A, F.y1 = R, F.x2 = L, F.y2 = I, F.w = L - A, F.h = I - R, F.leftPad = O, F.rightPad = N, F.topPad = k, F.botPad = P;
      var G = g && y.strValue === "autorotate", U = y.pfValue != null && y.pfValue !== 0;
      if (G || U) {
        var H = G ? ca(i.rstyle, "labelAngle", a) : y.pfValue, $ = Math.cos(H), X = Math.sin(H), Q = (A + L) / 2, re = (R + I) / 2;
        if (!g) {
          switch (u.value) {
            case "left":
              Q = L;
              break;
            case "right":
              Q = A;
              break;
          }
          switch (l.value) {
            case "top":
              re = I;
              break;
            case "bottom":
              re = R;
              break;
          }
        }
        var J = function(Ne, se) {
          return Ne = Ne - Q, se = se - re, {
            x: Ne * $ - se * X + Q,
            y: Ne * X + se * $ + re
          };
        }, z = J(A, R), V = J(A, I), Y = J(L, R), ee = J(L, I);
        A = Math.min(z.x, V.x, Y.x, ee.x), L = Math.max(z.x, V.x, Y.x, ee.x), R = Math.min(z.y, V.y, Y.y, ee.y), I = Math.max(z.y, V.y, Y.y, ee.y);
      }
      var ne = B + "Rot", be = _[ne] = _[ne] || {};
      be.x1 = A, be.y1 = R, be.x2 = L, be.y2 = I, be.w = L - A, be.h = I - R, Pt(e, A, R, L, I), Pt(i.labelBounds.all, A, R, L, I);
    }
    return e;
  }
}, np = function(e, t) {
  if (!t.cy().headless()) {
    var a = t.pstyle("outline-opacity").value, n = t.pstyle("outline-width").value;
    if (a > 0 && n > 0) {
      var i = t.pstyle("outline-offset").value, s = t.pstyle("shape").value, o = n + i, u = (e.w + o * 2) / e.w, l = (e.h + o * 2) / e.h, f = 0, c = 0;
      ["diamond", "pentagon", "round-triangle"].includes(s) ? (u = (e.w + o * 2.4) / e.w, c = -o / 3.6) : ["concave-hexagon", "rhomboid", "right-rhomboid"].includes(s) ? u = (e.w + o * 2.4) / e.w : s === "star" ? (u = (e.w + o * 2.8) / e.w, l = (e.h + o * 2.6) / e.h, c = -o / 3.8) : s === "triangle" ? (u = (e.w + o * 2.8) / e.w, l = (e.h + o * 2.4) / e.h, c = -o / 1.4) : s === "vee" && (u = (e.w + o * 4.4) / e.w, l = (e.h + o * 3.8) / e.h, c = -o * 0.5);
      var v = e.h * l - e.h, h = e.w * u - e.w;
      if (fn(e, [Math.ceil(v / 2), Math.ceil(h / 2)]), f != 0 || c !== 0) {
        var d = Vh(e, f, c);
        Sf(e, d);
      }
    }
  }
}, ip = function(e, t) {
  var a = e._private.cy, n = a.styleEnabled(), i = a.headless(), s = St(), o = e._private, u = e.isNode(), l = e.isEdge(), f, c, v, h, d, p, g = o.rstyle, y = u && n ? e.pstyle("bounds-expansion").pfValue : [0], b = function(Ve) {
    return Ve.pstyle("display").value !== "none";
  }, m = !n || b(e) && (!l || b(e.source()) && b(e.target()));
  if (m) {
    var E = 0, x = 0;
    n && t.includeOverlays && (E = e.pstyle("overlay-opacity").value, E !== 0 && (x = e.pstyle("overlay-padding").value));
    var S = 0, w = 0;
    n && t.includeUnderlays && (S = e.pstyle("underlay-opacity").value, S !== 0 && (w = e.pstyle("underlay-padding").value));
    var T = Math.max(x, w), C = 0, D = 0;
    if (n && (C = e.pstyle("width").pfValue, D = C / 2), u && t.includeNodes) {
      var A = e.position();
      d = A.x, p = A.y;
      var L = e.outerWidth(), R = L / 2, I = e.outerHeight(), O = I / 2;
      f = d - R, c = d + R, v = p - O, h = p + O, Pt(s, f, v, c, h), n && t.includeOutlines && np(s, e);
    } else if (l && t.includeEdges)
      if (n && !i) {
        var N = e.pstyle("curve-style").strValue;
        if (f = Math.min(g.srcX, g.midX, g.tgtX), c = Math.max(g.srcX, g.midX, g.tgtX), v = Math.min(g.srcY, g.midY, g.tgtY), h = Math.max(g.srcY, g.midY, g.tgtY), f -= D, c += D, v -= D, h += D, Pt(s, f, v, c, h), N === "haystack") {
          var k = g.haystackPts;
          if (k && k.length === 2) {
            if (f = k[0].x, v = k[0].y, c = k[1].x, h = k[1].y, f > c) {
              var P = f;
              f = c, c = P;
            }
            if (v > h) {
              var B = v;
              v = h, h = B;
            }
            Pt(s, f - D, v - D, c + D, h + D);
          }
        } else if (N === "bezier" || N === "unbundled-bezier" || N.endsWith("segments") || N.endsWith("taxi")) {
          var _;
          switch (N) {
            case "bezier":
            case "unbundled-bezier":
              _ = g.bezierPts;
              break;
            case "segments":
            case "taxi":
            case "round-segments":
            case "round-taxi":
              _ = g.linePts;
              break;
          }
          if (_ != null)
            for (var F = 0; F < _.length; F++) {
              var G = _[F];
              f = G.x - D, c = G.x + D, v = G.y - D, h = G.y + D, Pt(s, f, v, c, h);
            }
        }
      } else {
        var U = e.source(), H = U.position(), $ = e.target(), X = $.position();
        if (f = H.x, c = X.x, v = H.y, h = X.y, f > c) {
          var Q = f;
          f = c, c = Q;
        }
        if (v > h) {
          var re = v;
          v = h, h = re;
        }
        f -= D, c += D, v -= D, h += D, Pt(s, f, v, c, h);
      }
    if (n && t.includeEdges && l && (en(s, e, "mid-source"), en(s, e, "mid-target"), en(s, e, "source"), en(s, e, "target")), n) {
      var J = e.pstyle("ghost").value === "yes";
      if (J) {
        var z = e.pstyle("ghost-offset-x").pfValue, V = e.pstyle("ghost-offset-y").pfValue;
        Pt(s, s.x1 + z, s.y1 + V, s.x2 + z, s.y2 + V);
      }
    }
    var Y = o.bodyBounds = o.bodyBounds || {};
    eu(Y, s), fn(Y, y), ln(Y, 1), n && (f = s.x1, c = s.x2, v = s.y1, h = s.y2, Pt(s, f - T, v - T, c + T, h + T));
    var ee = o.overlayBounds = o.overlayBounds || {};
    eu(ee, s), fn(ee, y), ln(ee, 1);
    var ne = o.labelBounds = o.labelBounds || {};
    ne.all != null ? zh(ne.all) : ne.all = St(), n && t.includeLabels && (t.includeMainLabels && ms(s, e, null), l && (t.includeSourceLabels && ms(s, e, "source"), t.includeTargetLabels && ms(s, e, "target")));
  }
  return s.x1 = Rt(s.x1), s.y1 = Rt(s.y1), s.x2 = Rt(s.x2), s.y2 = Rt(s.y2), s.w = Rt(s.x2 - s.x1), s.h = Rt(s.y2 - s.y1), s.w > 0 && s.h > 0 && m && (fn(s, y), ln(s, 1)), s;
}, Qf = function(e) {
  var t = 0, a = function(s) {
    return (s ? 1 : 0) << t++;
  }, 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 t = function(o) {
    return Math.round(o);
  };
  if (e.isEdge()) {
    var a = e.source().position(), n = e.target().position();
    return Wo([t(a.x), t(a.y), t(n.x), t(n.y)]);
  } else {
    var i = e.position();
    return Wo([t(i.x), t(i.y)]);
  }
}, dl = function(e, t) {
  var a = e._private, n, i = e.isEdge(), s = t == null ? gl : Qf(t), o = s === gl;
  if (a.bbCache == null ? (n = ip(e, Ra), a.bbCache = n, a.bbCachePosKey = Jf(e)) : n = a.bbCache, !o) {
    var u = e.isNode();
    n = St(), (t.includeNodes && u || t.includeEdges && !u) && (t.includeOverlays ? xr(n, a.overlayBounds) : xr(n, a.bodyBounds)), t.includeLabels && (t.includeMainLabels && (!i || t.includeSourceLabels && t.includeTargetLabels) ? xr(n, a.labelBounds.all) : (t.includeMainLabels && xr(n, a.labelBounds.mainRot), t.includeSourceLabels && xr(n, a.labelBounds.sourceRot), t.includeTargetLabels && xr(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
}, gl = Qf(Ra), pl = vt(Ra);
gr.boundingBox = function(r) {
  var e, t = r === void 0 || r.useCache === void 0 || r.useCache === !0, a = Jr(function(f) {
    var c = f._private;
    return c.bbCache == null || c.styleDirty || c.bbCachePosKey !== Jf(f);
  }, function(f) {
    return f.id();
  });
  if (t && this.length === 1 && !a(this[0]))
    r === void 0 ? r = Ra : r = pl(r), e = dl(this[0], r);
  else {
    e = St(), r = r || Ra;
    var n = pl(r), i = this, s = i.cy(), o = s.styleEnabled();
    this.edges().forEach(a), this.nodes().forEach(a), o && this.recalculateRenderedStyle(t), this.updateCompoundBounds(!t);
    for (var u = 0; u < i.length; u++) {
      var l = i[u];
      a(l) && l.dirtyBoundingBoxCache(), xr(e, dl(l, n));
    }
  }
  return e.x1 = Rt(e.x1), e.y1 = Rt(e.y1), e.x2 = Rt(e.x2), e.y2 = Rt(e.y2), e.w = Rt(e.x2 - e.x1), e.h = Rt(e.y2 - e.y1), e;
};
gr.dirtyBoundingBoxCache = function() {
  for (var r = 0; r < this.length; r++) {
    var e = this[r]._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(r) {
  var e = this.nodes(), t = this.cy(), a = t.hasCompoundNodes(), n = t.collection();
  if (a && (n = e.filter(function(l) {
    return l.isParent();
  }), e = e.not(n)), Re(r)) {
    var i = r;
    r = function() {
      return i;
    };
  }
  var s = function(f, c) {
    return f._private.bbAtOldPos = r(f, c);
  }, o = function(f) {
    return f._private.bbAtOldPos;
  };
  t.startBatch(), e.forEach(s).silentPositions(r), a && (n.dirtyCompoundBoundsCache(), n.dirtyBoundingBoxCache(), n.updateCompoundBounds(!0));
  var u = Gh(this.boundingBox({
    useCache: !1
  }));
  return e.silentPositions(o), a && (n.dirtyCompoundBoundsCache(), n.dirtyBoundingBoxCache(), n.updateCompoundBounds(!0)), t.endBatch(), u;
};
Qr.boundingbox = Qr.bb = Qr.boundingBox;
Qr.renderedBoundingbox = Qr.renderedBoundingBox;
var sp = gr, ma, za;
ma = za = {};
var jf = function(e) {
  e.uppercaseName = Po(e.name), e.autoName = "auto" + e.uppercaseName, e.labelName = "label" + e.uppercaseName, e.outerName = "outer" + e.uppercaseName, e.uppercaseOuterName = Po(e.outerName), ma[e.name] = function() {
    var a = this[0], n = a._private, i = n.cy, s = i._private.styleEnabled;
    if (a)
      if (s) {
        if (a.isParent())
          return a.updateCompoundBounds(), n[e.autoName] || 0;
        var o = a.pstyle(e.name);
        switch (o.strValue) {
          case "label":
            return a.recalculateRenderedStyle(), n.rstyle[e.labelName] || 0;
          default:
            return o.pfValue;
        }
      } else
        return 1;
  }, ma["outer" + e.uppercaseName] = function() {
    var a = this[0], n = a._private, i = n.cy, s = i._private.styleEnabled;
    if (a)
      if (s) {
        var o = 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 o + 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();
    }
  };
};
jf({
  name: "width"
});
jf({
  name: "height"
});
za.padding = function() {
  var r = this[0], e = r._private;
  return r.isParent() ? (r.updateCompoundBounds(), e.autoPadding !== void 0 ? e.autoPadding : r.pstyle("padding").pfValue) : r.pstyle("padding").pfValue;
};
za.paddedHeight = function() {
  var r = this[0];
  return r.height() + 2 * r.padding();
};
za.paddedWidth = function() {
  var r = this[0];
  return r.width() + 2 * r.padding();
};
var op = za, up = function(e, t) {
  if (e.isEdge() && e.takesUpSpace())
    return t(e);
}, lp = function(e, t) {
  if (e.isEdge() && e.takesUpSpace()) {
    var a = e.cy();
    return _n(t(e), a.zoom(), a.pan());
  }
}, fp = function(e, t) {
  if (e.isEdge() && e.takesUpSpace()) {
    var a = e.cy(), n = a.pan(), i = a.zoom();
    return t(e).map(function(s) {
      return _n(s, i, n);
    });
  }
}, cp = function(e) {
  return e.renderer().getControlPoints(e);
}, vp = function(e) {
  return e.renderer().getSegmentPoints(e);
}, hp = function(e) {
  return e.renderer().getSourceEndpoint(e);
}, dp = function(e) {
  return e.renderer().getTargetEndpoint(e);
}, gp = function(e) {
  return e.renderer().getEdgeMidpoint(e);
}, yl = {
  controlPoints: {
    get: cp,
    mult: !0
  },
  segmentPoints: {
    get: vp,
    mult: !0
  },
  sourceEndpoint: {
    get: hp
  },
  targetEndpoint: {
    get: dp
  },
  midpoint: {
    get: gp
  }
}, pp = function(e) {
  return "rendered" + e[0].toUpperCase() + e.substr(1);
}, yp = Object.keys(yl).reduce(function(r, e) {
  var t = yl[e], a = pp(e);
  return r[e] = function() {
    return up(this, t.get);
  }, t.mult ? r[a] = function() {
    return fp(this, t.get);
  } : r[a] = function() {
    return lp(this, t.get);
  }, r;
}, {}), mp = de({}, ap, sp, op, yp);
/*!
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 ec = function(e, t) {
  this.recycle(e, t);
};
function va() {
  return !1;
}
function tn() {
  return !0;
}
ec.prototype = {
  instanceString: function() {
    return "event";
  },
  recycle: function(e, t) {
    if (this.isImmediatePropagationStopped = this.isPropagationStopped = this.isDefaultPrevented = va, e != null && e.preventDefault ? (this.type = e.type, this.isDefaultPrevented = e.defaultPrevented ? tn : va) : e != null && e.type ? t = e : this.type = e, t != null && (this.originalEvent = t.originalEvent, this.type = t.type != null ? t.type : this.type, this.cy = t.cy, this.target = t.target, this.position = t.position, this.renderedPosition = t.renderedPosition, this.namespace = t.namespace, this.layout = t.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 = tn;
    var e = this.originalEvent;
    e && e.preventDefault && e.preventDefault();
  },
  stopPropagation: function() {
    this.isPropagationStopped = tn;
    var e = this.originalEvent;
    e && e.stopPropagation && e.stopPropagation();
  },
  stopImmediatePropagation: function() {
    this.isImmediatePropagationStopped = tn, this.stopPropagation();
  },
  isDefaultPrevented: va,
  isPropagationStopped: va,
  isImmediatePropagationStopped: va
};
var tc = /^([^.]+)(\.(?:[^.]+))?$/, bp = ".*", rc = {
  qualifierCompare: function(e, t) {
    return e === t;
  },
  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
}, ml = Object.keys(rc), wp = {};
function Yn() {
  for (var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : wp, e = arguments.length > 1 ? arguments[1] : void 0, t = 0; t < ml.length; t++) {
    var a = ml[t];
    this[a] = r[a] || rc[a];
  }
  this.context = e || this.context, this.listeners = [], this.emitting = 0;
}
var cr = Yn.prototype, ac = function(e, t, a, n, i, s, o) {
  He(n) && (i = n, n = null), o && (s == null ? s = o : s = de({}, s, o));
  for (var u = _e(a) ? a : a.split(/\s+/), l = 0; l < u.length; l++) {
    var f = u[l];
    if (!sr(f)) {
      var c = f.match(tc);
      if (c) {
        var v = c[1], h = c[2] ? c[2] : null, d = t(e, f, v, h, n, i, s);
        if (d === !1)
          break;
      }
    }
  }
}, bl = function(e, t) {
  return e.addEventFields(e.context, t), new ec(t.type, t);
}, Ep = function(e, t, a) {
  if (Iv(a)) {
    t(e, a);
    return;
  } else if (Re(a)) {
    t(e, bl(e, a));
    return;
  }
  for (var n = _e(a) ? a : a.split(/\s+/), i = 0; i < n.length; i++) {
    var s = n[i];
    if (!sr(s)) {
      var o = s.match(tc);
      if (o) {
        var u = o[1], l = o[2] ? o[2] : null, f = bl(e, {
          type: u,
          namespace: l,
          target: e.context
        });
        t(e, f);
      }
    }
  }
};
cr.on = cr.addListener = function(r, e, t, a, n) {
  return ac(this, function(i, s, o, u, l, f, c) {
    He(f) && i.listeners.push({
      event: s,
      // full event string
      callback: f,
      // callback to run
      type: o,
      // 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: c
      // additional configuration
    });
  }, r, e, t, a, n), this;
};
cr.one = function(r, e, t, a) {
  return this.on(r, e, t, a, {
    one: !0
  });
};
cr.removeListener = cr.off = function(r, e, t, a) {
  var n = this;
  this.emitting !== 0 && (this.listeners = lh(this.listeners));
  for (var i = this.listeners, s = function(l) {
    var f = i[l];
    ac(n, function(c, v, h, d, p, g) {
      if ((f.type === h || r === "*") && (!d && f.namespace !== ".*" || f.namespace === d) && (!p || c.qualifierCompare(f.qualifier, p)) && (!g || f.callback === g))
        return i.splice(l, 1), !1;
    }, r, e, t, a);
  }, o = i.length - 1; o >= 0; o--)
    s(o);
  return this;
};
cr.removeAllListeners = function() {
  return this.removeListener("*");
};
cr.emit = cr.trigger = function(r, e, t) {
  var a = this.listeners, n = a.length;
  return this.emitting++, _e(e) || (e = [e]), Ep(this, function(i, s) {
    t != null && (a = [{
      event: s.event,
      type: s.type,
      namespace: s.namespace,
      callback: t
    }], n = a.length);
    for (var o = function() {
      var f = a[u];
      if (f.type === s.type && (!f.namespace || f.namespace === s.namespace || f.namespace === bp) && i.eventMatches(i.context, f, s)) {
        var c = [s];
        e != null && ch(c, e), i.beforeEmit(i.context, f, s), f.conf && f.conf.one && (i.listeners = i.listeners.filter(function(d) {
          return d !== f;
        }));
        var v = i.callbackContext(i.context, f, s), h = f.callback.apply(v, c);
        i.afterEmit(i.context, f, s), h === !1 && (s.stopPropagation(), s.preventDefault());
      }
    }, u = 0; u < n; u++)
      o();
    i.bubble(i.context) && !s.isPropagationStopped() && i.parent(i.context).emit(s, e);
  }, r), this.emitting--, this;
};
var xp = {
  qualifierCompare: function(e, t) {
    return e == null || t == null ? e == null && t == null : e.sameText(t);
  },
  eventMatches: function(e, t, a) {
    var n = t.qualifier;
    return n != null ? e !== a.target && Na(a.target) && n.matches(a.target) : !0;
  },
  addEventFields: function(e, t) {
    t.cy = e.cy(), t.target = e;
  },
  callbackContext: function(e, t, a) {
    return t.qualifier != null ? a.target : e;
  },
  beforeEmit: function(e, t) {
    t.conf && t.conf.once && t.conf.onceCollection.removeListener(t.event, t.qualifier, t.callback);
  },
  bubble: function() {
    return !0;
  },
  parent: function(e) {
    return e.isChild() ? e.parent() : e.cy();
  }
}, rn = function(e) {
  return ce(e) ? new lr(e) : e;
}, nc = {
  createEmitter: function() {
    for (var e = 0; e < this.length; e++) {
      var t = this[e], a = t._private;
      a.emitter || (a.emitter = new Yn(xp, t));
    }
    return this;
  },
  emitter: function() {
    return this._private.emitter;
  },
  on: function(e, t, a) {
    for (var n = rn(t), i = 0; i < this.length; i++) {
      var s = this[i];
      s.emitter().on(e, n, a);
    }
    return this;
  },
  removeListener: function(e, t, a) {
    for (var n = rn(t), i = 0; i < this.length; i++) {
      var s = this[i];
      s.emitter().removeListener(e, n, a);
    }
    return this;
  },
  removeAllListeners: function() {
    for (var e = 0; e < this.length; e++) {
      var t = this[e];
      t.emitter().removeAllListeners();
    }
    return this;
  },
  one: function(e, t, a) {
    for (var n = rn(t), i = 0; i < this.length; i++) {
      var s = this[i];
      s.emitter().one(e, n, a);
    }
    return this;
  },
  once: function(e, t, a) {
    for (var n = rn(t), i = 0; i < this.length; i++) {
      var s = this[i];
      s.emitter().on(e, n, a, {
        once: !0,
        onceCollection: this
      });
    }
  },
  emit: function(e, t) {
    for (var a = 0; a < this.length; a++) {
      var n = this[a];
      n.emitter().emit(e, t);
    }
    return this;
  },
  emitAndNotify: function(e, t) {
    if (this.length !== 0)
      return this.cy().notify(e, this), this.emit(e, t), this;
  }
};
Oe.eventAliasesOn(nc);
var ic = {
  nodes: function(e) {
    return this.filter(function(t) {
      return t.isNode();
    }).filter(e);
  },
  edges: function(e) {
    return this.filter(function(t) {
      return t.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(), t = this.spawn(), a = 0; a < this.length; a++) {
      var n = this[a];
      n.isNode() ? e.push(n) : t.push(n);
    }
    return {
      nodes: e,
      edges: t
    };
  },
  filter: function(e, t) {
    if (e === void 0)
      return this;
    if (ce(e) || At(e))
      return new lr(e).filter(this);
    if (He(e)) {
      for (var a = this.spawn(), n = this, i = 0; i < n.length; i++) {
        var s = n[i], o = t ? e.apply(t, [s, i, n]) : e(s, i, n);
        o && a.push(s);
      }
      return a;
    }
    return this.spawn();
  },
  not: function(e) {
    if (e) {
      ce(e) && (e = this.filter(e));
      for (var t = this.spawn(), a = 0; a < this.length; a++) {
        var n = this[a], i = e.has(n);
        i || t.push(n);
      }
      return t;
    } else
      return this;
  },
  absoluteComplement: function() {
    var e = this.cy();
    return e.mutableElements().not(this);
  },
  intersect: function(e) {
    if (ce(e)) {
      var t = e;
      return this.filter(t);
    }
    for (var a = this.spawn(), n = this, i = e, s = this.length < e.length, o = s ? n : i, u = s ? i : n, l = 0; l < o.length; l++) {
      var f = o[l];
      u.has(f) && a.push(f);
    }
    return a;
  },
  xor: function(e) {
    var t = this._private.cy;
    ce(e) && (e = t.$(e));
    var a = this.spawn(), n = this, i = e, s = function(u, l) {
      for (var f = 0; f < u.length; f++) {
        var c = u[f], v = c._private.data.id, h = l.hasElementWithId(v);
        h || a.push(c);
      }
    };
    return s(n, i), s(i, n), a;
  },
  diff: function(e) {
    var t = this._private.cy;
    ce(e) && (e = t.$(e));
    var a = this.spawn(), n = this.spawn(), i = this.spawn(), s = this, o = e, u = function(f, c, v) {
      for (var h = 0; h < f.length; h++) {
        var d = f[h], p = d._private.data.id, g = c.hasElementWithId(p);
        g ? i.merge(d) : v.push(d);
      }
    };
    return u(s, o, a), u(o, s, n), {
      left: a,
      right: n,
      both: i
    };
  },
  add: function(e) {
    var t = this._private.cy;
    if (!e)
      return this;
    if (ce(e)) {
      var a = e;
      e = t.mutableElements().filter(a);
    }
    for (var n = this.spawnSelf(), i = 0; i < e.length; i++) {
      var s = e[i], o = !this.has(s);
      o && n.push(s);
    }
    return n;
  },
  // in place merge on calling collection
  merge: function(e) {
    var t = this._private, a = t.cy;
    if (!e)
      return this;
    if (e && ce(e)) {
      var n = e;
      e = a.mutableElements().filter(n);
    }
    for (var i = t.map, s = 0; s < e.length; s++) {
      var o = e[s], u = o._private.data.id, l = !i.has(u);
      if (l) {
        var f = this.length++;
        this[f] = o, i.set(u, {
          ele: o,
          index: f
        });
      }
    }
    return this;
  },
  unmergeAt: function(e) {
    var t = this[e], a = t.id(), n = this._private, i = n.map;
    this[e] = void 0, i.delete(a);
    var s = e === this.length - 1;
    if (this.length > 1 && !s) {
      var o = this.length - 1, u = this[o], l = u._private.data.id;
      this[o] = 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 t = this._private, a = e._private.data.id, n = t.map, i = n.get(a);
    if (!i)
      return this;
    var s = i.index;
    return this.unmergeAt(s), this;
  },
  // remove eles in place on calling collection
  unmerge: function(e) {
    var t = this._private.cy;
    if (!e)
      return this;
    if (e && ce(e)) {
      var a = e;
      e = t.mutableElements().filter(a);
    }
    for (var n = 0; n < e.length; n++)
      this.unmergeOne(e[n]);
    return this;
  },
  unmergeBy: function(e) {
    for (var t = this.length - 1; t >= 0; t--) {
      var a = this[t];
      e(a) && this.unmergeAt(t);
    }
    return this;
  },
  map: function(e, t) {
    for (var a = [], n = this, i = 0; i < n.length; i++) {
      var s = n[i], o = t ? e.apply(t, [s, i, n]) : e(s, i, n);
      a.push(o);
    }
    return a;
  },
  reduce: function(e, t) {
    for (var a = t, n = this, i = 0; i < n.length; i++)
      a = e(a, n[i], i, n);
    return a;
  },
  max: function(e, t) {
    for (var a = -1 / 0, n, i = this, s = 0; s < i.length; s++) {
      var o = i[s], u = t ? e.apply(t, [o, s, i]) : e(o, s, i);
      u > a && (a = u, n = o);
    }
    return {
      value: a,
      ele: n
    };
  },
  min: function(e, t) {
    for (var a = 1 / 0, n, i = this, s = 0; s < i.length; s++) {
      var o = i[s], u = t ? e.apply(t, [o, s, i]) : e(o, s, i);
      u < a && (a = u, n = o);
    }
    return {
      value: a,
      ele: n
    };
  }
}, Me = ic;
Me.u = Me["|"] = Me["+"] = Me.union = Me.or = Me.add;
Me["\\"] = Me["!"] = Me["-"] = Me.difference = Me.relativeComplement = Me.subtract = Me.not;
Me.n = Me["&"] = Me["."] = Me.and = Me.intersection = Me.intersect;
Me["^"] = Me["(+)"] = Me["(-)"] = Me.symmetricDifference = Me.symdiff = Me.xor;
Me.fnFilter = Me.filterFn = Me.stdFilter = Me.filter;
Me.complement = Me.abscomp = Me.absoluteComplement;
var Tp = {
  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;
  }
}, sc = function(e, t) {
  var a = e.cy(), n = a.hasCompoundNodes();
  function i(f) {
    var c = f.pstyle("z-compound-depth");
    return c.value === "auto" ? n ? f.zDepth() : 0 : c.value === "bottom" ? -1 : c.value === "top" ? io : 0;
  }
  var s = i(e) - i(t);
  if (s !== 0)
    return s;
  function o(f) {
    var c = f.pstyle("z-index-compare");
    return c.value === "auto" && f.isNode() ? 1 : 0;
  }
  var u = o(e) - o(t);
  if (u !== 0)
    return u;
  var l = e.pstyle("z-index").value - t.pstyle("z-index").value;
  return l !== 0 ? l : e.poolIndex() - t.poolIndex();
}, Ln = {
  forEach: function(e, t) {
    if (He(e))
      for (var a = this.length, n = 0; n < a; n++) {
        var i = this[n], s = t ? e.apply(t, [i, n, this]) : e(i, n, this);
        if (s === !1)
          break;
      }
    return this;
  },
  toArray: function() {
    for (var e = [], t = 0; t < this.length; t++)
      e.push(this[t]);
    return e;
  },
  slice: function(e, t) {
    var a = [], n = this.length;
    t == null && (t = n), e == null && (e = 0), e < 0 && (e = n + e), t < 0 && (t = n + t);
    for (var i = e; i >= 0 && i < t && 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 t = this.toArray().sort(e);
    return this.spawn(t);
  },
  sortByZIndex: function() {
    return this.sort(sc);
  },
  zDepth: function() {
    var e = this[0];
    if (e) {
      var t = e._private, a = t.group;
      if (a === "nodes") {
        var n = t.data.parent ? e.parents().size() : 0;
        return e.isParent() ? n : io - 1;
      } else {
        var i = t.source, s = t.target, o = i.zDepth(), u = s.zDepth();
        return Math.max(o, u, 0);
      }
    }
  }
};
Ln.each = Ln.forEach;
var Cp = function() {
  var e = "undefined", t = (typeof Symbol > "u" ? "undefined" : rt(Symbol)) != e && rt(Symbol.iterator) != e;
  t && (Ln[Symbol.iterator] = function() {
    var a = this, n = {
      value: void 0,
      done: !1
    }, i = 0, s = this.length;
    return sf({
      next: function() {
        return i < s ? n.value = a[i++] : (n.value = void 0, n.done = !0), n;
      }
    }, Symbol.iterator, function() {
      return this;
    });
  });
};
Cp();
var Dp = vt({
  nodeDimensionsIncludeLabels: !1
}), vn = {
  // Calculates and returns node dimensions { x, y } based on options given
  layoutDimensions: function(e) {
    e = Dp(e);
    var t;
    if (!this.takesUpSpace())
      t = {
        w: 0,
        h: 0
      };
    else if (e.nodeDimensionsIncludeLabels) {
      var a = this.boundingBox();
      t = {
        w: a.w,
        h: a.h
      };
    } else
      t = {
        w: this.outerWidth(),
        h: this.outerHeight()
      };
    return (t.w === 0 || t.h === 0) && (t.w = t.h = 1), t;
  },
  // using standard layout options, apply position function (w/ or w/o animation)
  layoutPositions: function(e, t, a) {
    var n = this.nodes().filter(function(x) {
      return !x.isParent();
    }), i = this.cy(), s = t.eles, o = function(S) {
      return S.id();
    }, u = Jr(a, o);
    e.emit({
      type: "layoutstart",
      layout: e
    }), e.animations = [];
    var l = function(S, w, T) {
      var C = {
        x: w.x1 + w.w / 2,
        y: w.y1 + w.h / 2
      }, D = {
        // scale from center of bounding box (not necessarily 0,0)
        x: (T.x - C.x) * S,
        y: (T.y - C.y) * S
      };
      return {
        x: C.x + D.x,
        y: C.y + D.y
      };
    }, f = t.spacingFactor && t.spacingFactor !== 1, c = function() {
      if (!f)
        return null;
      for (var S = St(), w = 0; w < n.length; w++) {
        var T = n[w], C = u(T, w);
        Uh(S, C.x, C.y);
      }
      return S;
    }, v = c(), h = Jr(function(x, S) {
      var w = u(x, S);
      if (f) {
        var T = Math.abs(t.spacingFactor);
        w = l(T, v, w);
      }
      return t.transform != null && (w = t.transform(x, w)), w;
    }, o);
    if (t.animate) {
      for (var d = 0; d < n.length; d++) {
        var p = n[d], g = h(p, d), y = t.animateFilter == null || t.animateFilter(p, d);
        if (y) {
          var b = p.animation({
            position: g,
            duration: t.animationDuration,
            easing: t.animationEasing
          });
          e.animations.push(b);
        } else
          p.position(g);
      }
      if (t.fit) {
        var m = i.animation({
          fit: {
            boundingBox: s.boundingBoxAt(h),
            padding: t.padding
          },
          duration: t.animationDuration,
          easing: t.animationEasing
        });
        e.animations.push(m);
      } else if (t.zoom !== void 0 && t.pan !== void 0) {
        var E = i.animation({
          zoom: t.zoom,
          pan: t.pan,
          duration: t.animationDuration,
          easing: t.animationEasing
        });
        e.animations.push(E);
      }
      e.animations.forEach(function(x) {
        return x.play();
      }), e.one("layoutready", t.ready), e.emit({
        type: "layoutready",
        layout: e
      }), aa.all(e.animations.map(function(x) {
        return x.promise();
      })).then(function() {
        e.one("layoutstop", t.stop), e.emit({
          type: "layoutstop",
          layout: e
        });
      });
    } else
      n.positions(h), t.fit && i.fit(t.eles, t.padding), t.zoom != null && i.zoom(t.zoom), t.pan && i.pan(t.pan), e.one("layoutready", t.ready), e.emit({
        type: "layoutready",
        layout: e
      }), e.one("layoutstop", t.stop), e.emit({
        type: "layoutstop",
        layout: e
      });
    return this;
  },
  layout: function(e) {
    var t = this.cy();
    return t.makeLayout(de({}, e, {
      eles: this
    }));
  }
};
vn.createLayout = vn.makeLayout = vn.layout;
function oc(r, e, t) {
  var a = t._private, n = a.styleCache = a.styleCache || [], i;
  return (i = n[r]) != null || (i = n[r] = e(t)), i;
}
function Xn(r, e) {
  return r = Ar(r), function(a) {
    return oc(r, e, a);
  };
}
function $n(r, e) {
  r = Ar(r);
  var t = function(n) {
    return e.call(n);
  };
  return function() {
    var n = this[0];
    if (n)
      return oc(r, t, n);
  };
}
var ft = {
  recalculateRenderedStyle: function(e) {
    var t = this.cy(), a = t.renderer(), n = t.styleEnabled();
    return a && n && a.recalculateRenderedStyle(this, e), this;
  },
  dirtyStyleCache: function() {
    var e = this.cy(), t = 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(t);
    } else
      this.forEach(function(n) {
        t(n), n.connectedEdges().forEach(t);
      });
    return this;
  },
  // fully updates (recalculates) the style for the elements
  updateStyle: function(e) {
    var t = this._private.cy;
    if (!t.styleEnabled())
      return this;
    if (t.batching()) {
      var a = t._private.batchStyleEles;
      return a.merge(this), this;
    }
    var n = t.hasCompoundNodes(), i = this;
    e = !!(e || e === void 0), n && (i = this.spawnSelf().merge(this.descendants()).merge(this.parents()));
    var s = i;
    return e ? s.emitAndNotify("style") : s.emit("style"), i.forEach(function(o) {
      return o._private.styleDirty = !0;
    }), this;
  },
  // private: clears dirty flag and recalculates style
  cleanStyle: function() {
    var e = this.cy();
    if (e.styleEnabled())
      for (var t = 0; t < this.length; t++) {
        var a = this[t];
        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 t = 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 ?? (t ? n.style().getDefaultProperty(e) : null);
    }
  },
  numericStyle: function(e) {
    var t = this[0];
    if (t.cy().styleEnabled() && t) {
      var a = t.pstyle(e);
      return a.pfValue !== void 0 ? a.pfValue : a.value;
    }
  },
  numericStyleUnits: function(e) {
    var t = this[0];
    if (t.cy().styleEnabled() && t)
      return t.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 t = this.cy();
    if (!t.styleEnabled())
      return this;
    var a = this[0];
    if (a)
      return t.style().getRenderedStyle(a, e);
  },
  // read the calculated css style of the element or override the style (via a bypass)
  style: function(e, t) {
    var a = this.cy();
    if (!a.styleEnabled())
      return this;
    var n = !1, i = a.style();
    if (Re(e)) {
      var s = e;
      i.applyBypass(this, s, n), this.emitAndNotify("style");
    } else if (ce(e))
      if (t === void 0) {
        var o = this[0];
        return o ? i.getStylePropertyValue(o, e) : void 0;
      } else
        i.applyBypass(this, e, t, 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 t = this.cy();
    if (!t.styleEnabled())
      return this;
    var a = !1, n = t.style(), i = this;
    if (e === void 0)
      for (var s = 0; s < i.length; s++) {
        var o = i[s];
        n.removeAllBypasses(o, 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 t = e.hasCompoundNodes(), a = this[0];
    if (a) {
      var n = a._private, i = a.pstyle("opacity").value;
      if (!t)
        return i;
      var s = n.data.parent ? a.parents() : null;
      if (s)
        for (var o = 0; o < s.length; o++) {
          var u = s[o], l = u.pstyle("opacity").value;
          i = l * i;
        }
      return i;
    }
  },
  transparent: function() {
    var e = this.cy();
    if (!e.styleEnabled())
      return !1;
    var t = this[0], a = t.cy().hasCompoundNodes();
    if (t)
      return a ? t.effectiveOpacity() === 0 : t.pstyle("opacity").value === 0;
  },
  backgrounding: function() {
    var e = this.cy();
    if (!e.styleEnabled())
      return !1;
    var t = this[0];
    return !!t._private.backgrounding;
  }
};
function bs(r, e) {
  var t = r._private, a = t.data.parent ? r.parents() : null;
  if (a)
    for (var n = 0; n < a.length; n++) {
      var i = a[n];
      if (!e(i))
        return !1;
    }
  return !0;
}
function mo(r) {
  var e = r.ok, t = r.edgeOkViaNode || r.ok, a = r.parentOk || r.ok;
  return function() {
    var n = this.cy();
    if (!n.styleEnabled())
      return !0;
    var i = this[0], s = n.hasCompoundNodes();
    if (i) {
      var o = i._private;
      if (!e(i))
        return !1;
      if (i.isNode())
        return !s || bs(i, a);
      var u = o.source, l = o.target;
      return t(u) && (!s || bs(u, t)) && (u === l || t(l) && (!s || bs(l, t)));
    }
  };
}
var na = Xn("eleTakesUpSpace", function(r) {
  return r.pstyle("display").value === "element" && r.width() !== 0 && (r.isNode() ? r.height() !== 0 : !0);
});
ft.takesUpSpace = $n("takesUpSpace", mo({
  ok: na
}));
var Sp = Xn("eleInteractive", function(r) {
  return r.pstyle("events").value === "yes" && r.pstyle("visibility").value === "visible" && na(r);
}), Ap = Xn("parentInteractive", function(r) {
  return r.pstyle("visibility").value === "visible" && na(r);
});
ft.interactive = $n("interactive", mo({
  ok: Sp,
  parentOk: Ap,
  edgeOkViaNode: na
}));
ft.noninteractive = function() {
  var r = this[0];
  if (r)
    return !r.interactive();
};
var Lp = Xn("eleVisible", function(r) {
  return r.pstyle("visibility").value === "visible" && r.pstyle("opacity").pfValue !== 0 && na(r);
}), Rp = na;
ft.visible = $n("visible", mo({
  ok: Lp,
  edgeOkViaNode: Rp
}));
ft.hidden = function() {
  var r = this[0];
  if (r)
    return !r.visible();
};
ft.isBundledBezier = $n("isBundledBezier", function() {
  return this.cy().styleEnabled() ? !this.removed() && this.pstyle("curve-style").value === "bezier" && this.takesUpSpace() : !1;
});
ft.bypass = ft.css = ft.style;
ft.renderedCss = ft.renderedStyle;
ft.removeBypass = ft.removeCss = ft.removeStyle;
ft.pstyle = ft.parsedStyle;
var ir = {};
function wl(r) {
  return function() {
    var e = arguments, t = [];
    if (e.length === 2) {
      var a = e[0], n = e[1];
      this.on(r.event, a, n);
    } else if (e.length === 1 && He(e[0])) {
      var i = e[0];
      this.on(r.event, i);
    } else if (e.length === 0 || e.length === 1 && _e(e[0])) {
      for (var s = e.length === 1 ? e[0] : null, o = 0; o < this.length; o++) {
        var u = this[o], l = !r.ableField || u._private[r.ableField], f = u._private[r.field] != r.value;
        if (r.overrideAble) {
          var c = r.overrideAble(u);
          if (c !== void 0 && (l = c, !c))
            return this;
        }
        l && (u._private[r.field] = r.value, f && t.push(u));
      }
      var v = this.spawn(t);
      v.updateStyle(), v.emit(r.event), s && v.emit(s);
    }
    return this;
  };
}
function ia(r) {
  ir[r.field] = function() {
    var e = this[0];
    if (e) {
      if (r.overrideField) {
        var t = r.overrideField(e);
        if (t !== void 0)
          return t;
      }
      return e._private[r.field];
    }
  }, ir[r.on] = wl({
    event: r.on,
    field: r.field,
    ableField: r.ableField,
    overrideAble: r.overrideAble,
    value: !0
  }), ir[r.off] = wl({
    event: r.off,
    field: r.field,
    ableField: r.ableField,
    overrideAble: r.overrideAble,
    value: !1
  });
}
ia({
  field: "locked",
  overrideField: function(e) {
    return e.cy().autolock() ? !0 : void 0;
  },
  on: "lock",
  off: "unlock"
});
ia({
  field: "grabbable",
  overrideField: function(e) {
    return e.cy().autoungrabify() || e.pannable() ? !1 : void 0;
  },
  on: "grabify",
  off: "ungrabify"
});
ia({
  field: "selected",
  ableField: "selectable",
  overrideAble: function(e) {
    return e.cy().autounselectify() ? !1 : void 0;
  },
  on: "select",
  off: "unselect"
});
ia({
  field: "selectable",
  overrideField: function(e) {
    return e.cy().autounselectify() ? !1 : void 0;
  },
  on: "selectify",
  off: "unselectify"
});
ir.deselect = ir.unselect;
ir.grabbed = function() {
  var r = this[0];
  if (r)
    return r._private.grabbed;
};
ia({
  field: "active",
  on: "activate",
  off: "unactivate"
});
ia({
  field: "pannable",
  on: "panify",
  off: "unpanify"
});
ir.inactive = function() {
  var r = this[0];
  if (r)
    return !r._private.active;
};
var gt = {}, El = function(e) {
  return function(a) {
    for (var n = this, i = [], s = 0; s < n.length; s++) {
      var o = n[s];
      if (o.isNode()) {
        for (var u = !1, l = o.connectedEdges(), f = 0; f < l.length; f++) {
          var c = l[f], v = c.source(), h = c.target();
          if (e.noIncomingEdges && h === o && v !== o || e.noOutgoingEdges && v === o && h !== o) {
            u = !0;
            break;
          }
        }
        u || i.push(o);
      }
    }
    return this.spawn(i, !0).filter(a);
  };
}, xl = function(e) {
  return function(t) {
    for (var a = this, n = [], i = 0; i < a.length; i++) {
      var s = a[i];
      if (s.isNode())
        for (var o = s.connectedEdges(), u = 0; u < o.length; u++) {
          var l = o[u], f = l.source(), c = l.target();
          e.outgoing && f === s ? (n.push(l), n.push(c)) : e.incoming && c === s && (n.push(l), n.push(f));
        }
    }
    return this.spawn(n, !0).filter(t);
  };
}, Tl = function(e) {
  return function(t) {
    for (var a = this, n = [], i = {}; ; ) {
      var s = e.outgoing ? a.outgoers() : a.incomers();
      if (s.length === 0)
        break;
      for (var o = !1, u = 0; u < s.length; u++) {
        var l = s[u], f = l.id();
        i[f] || (i[f] = !0, n.push(l), o = !0);
      }
      if (!o)
        break;
      a = s;
    }
    return this.spawn(n, !0).filter(t);
  };
};
gt.clearTraversalCache = function() {
  for (var r = 0; r < this.length; r++)
    this[r]._private.traversalCache = null;
};
de(gt, {
  // get the root nodes in the DAG
  roots: El({
    noIncomingEdges: !0
  }),
  // get the leaf nodes in the DAG
  leaves: El({
    noOutgoingEdges: !0
  }),
  // normally called children in graph theory
  // these nodes =edges=> outgoing nodes
  outgoers: It(xl({
    outgoing: !0
  }), "outgoers"),
  // aka DAG descendants
  successors: Tl({
    outgoing: !0
  }),
  // normally called parents in graph theory
  // these nodes <=edges= incoming nodes
  incomers: It(xl({
    incoming: !0
  }), "incomers"),
  // aka DAG ancestors
  predecessors: Tl({})
});
de(gt, {
  neighborhood: It(function(r) {
    for (var e = [], t = this.nodes(), a = 0; a < t.length; a++)
      for (var n = t[a], i = n.connectedEdges(), s = 0; s < i.length; s++) {
        var o = i[s], u = o.source(), l = o.target(), f = n === u ? l : u;
        f.length > 0 && e.push(f[0]), e.push(o[0]);
      }
    return this.spawn(e, !0).filter(r);
  }, "neighborhood"),
  closedNeighborhood: function(e) {
    return this.neighborhood().add(this).filter(e);
  },
  openNeighborhood: function(e) {
    return this.neighborhood(e);
  }
});
gt.neighbourhood = gt.neighborhood;
gt.closedNeighbourhood = gt.closedNeighborhood;
gt.openNeighbourhood = gt.openNeighborhood;
de(gt, {
  source: It(function(e) {
    var t = this[0], a;
    return t && (a = t._private.source || t.cy().collection()), a && e ? a.filter(e) : a;
  }, "source"),
  target: It(function(e) {
    var t = this[0], a;
    return t && (a = t._private.target || t.cy().collection()), a && e ? a.filter(e) : a;
  }, "target"),
  sources: Cl({
    attr: "source"
  }),
  targets: Cl({
    attr: "target"
  })
});
function Cl(r) {
  return function(t) {
    for (var a = [], n = 0; n < this.length; n++) {
      var i = this[n], s = i._private[r.attr];
      s && a.push(s);
    }
    return this.spawn(a, !0).filter(t);
  };
}
de(gt, {
  edgesWith: It(Dl(), "edgesWith"),
  edgesTo: It(Dl({
    thisIsSrc: !0
  }), "edgesTo")
});
function Dl(r) {
  return function(t) {
    var a = [], n = this._private.cy, i = r || {};
    ce(t) && (t = n.$(t));
    for (var s = 0; s < t.length; s++)
      for (var o = t[s]._private.edges, u = 0; u < o.length; u++) {
        var l = o[u], f = l._private.data, c = this.hasElementWithId(f.source) && t.hasElementWithId(f.target), v = t.hasElementWithId(f.source) && this.hasElementWithId(f.target), h = c || v;
        h && ((i.thisIsSrc || i.thisIsTgt) && (i.thisIsSrc && !c || i.thisIsTgt && !v) || a.push(l));
      }
    return this.spawn(a, !0);
  };
}
de(gt, {
  connectedEdges: It(function(r) {
    for (var e = [], t = this, a = 0; a < t.length; a++) {
      var n = t[a];
      if (n.isNode())
        for (var i = n._private.edges, s = 0; s < i.length; s++) {
          var o = i[s];
          e.push(o);
        }
    }
    return this.spawn(e, !0).filter(r);
  }, "connectedEdges"),
  connectedNodes: It(function(r) {
    for (var e = [], t = this, a = 0; a < t.length; a++) {
      var n = t[a];
      n.isEdge() && (e.push(n.source()[0]), e.push(n.target()[0]));
    }
    return this.spawn(e, !0).filter(r);
  }, "connectedNodes"),
  parallelEdges: It(Sl(), "parallelEdges"),
  codirectedEdges: It(Sl({
    codirected: !0
  }), "codirectedEdges")
});
function Sl(r) {
  var e = {
    codirected: !1
  };
  return r = de({}, e, r), function(a) {
    for (var n = [], i = this.edges(), s = r, o = 0; o < i.length; o++)
      for (var u = i[o], l = u._private, f = l.source, c = f._private.data.id, v = l.data.target, h = f._private.edges, d = 0; d < h.length; d++) {
        var p = h[d], g = p._private.data, y = g.target, b = g.source, m = y === v && b === c, E = c === y && v === b;
        (s.codirected && m || !s.codirected && (m || E)) && n.push(p);
      }
    return this.spawn(n, !0).filter(a);
  };
}
de(gt, {
  components: function(e) {
    var t = this, a = t.cy(), n = a.collection(), i = e == null ? t.nodes() : e.nodes(), s = [];
    e != null && i.empty() && (i = e.sources());
    var o = function(f, c) {
      n.merge(f), i.unmerge(f), c.merge(f);
    };
    if (i.empty())
      return t.spawn();
    var u = function() {
      var f = a.collection();
      s.push(f);
      var c = i[0];
      o(c, f), t.bfs({
        directed: !1,
        roots: c,
        visit: function(h) {
          return o(h, f);
        }
      }), f.forEach(function(v) {
        v.connectedEdges().forEach(function(h) {
          t.has(h) && f.has(h.source()) && f.has(h.target()) && f.merge(h);
        });
      });
    };
    do
      u();
    while (i.length > 0);
    return s;
  },
  component: function() {
    var e = this[0];
    return e.cy().mutableElements().components(e)[0];
  }
});
gt.componentsOf = gt.components;
var ct = function(e, t) {
  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 Kt(), s = !1;
  if (!t)
    t = [];
  else if (t.length > 0 && Re(t[0]) && !Na(t[0])) {
    s = !0;
    for (var o = [], u = new ra(), l = 0, f = t.length; l < f; l++) {
      var c = t[l];
      c.data == null && (c.data = {});
      var v = c.data;
      if (v.id == null)
        v.id = Tf();
      else if (e.hasElementWithId(v.id) || u.has(v.id))
        continue;
      var h = new Fn(e, c, !1);
      o.push(h), u.add(v.id);
    }
    t = o;
  }
  this.length = 0;
  for (var d = 0, p = t.length; d < p; d++) {
    var g = t[d][0];
    if (g != null) {
      var y = g._private.data.id;
      (!a || !i.has(y)) && (a && i.set(y, {
        index: this.length,
        ele: g
      }), this[this.length] = g, 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 Kt(), E = this.eles, x = 0; x < E.length; x++) {
        var S = E[x];
        m.set(S.id(), {
          index: x,
          ele: S
        });
      }
    }
  }, a && (this._private.map = i), s && !n && this.restore();
}, ze = Fn.prototype = ct.prototype = Object.create(Array.prototype);
ze.instanceString = function() {
  return "collection";
};
ze.spawn = function(r, e) {
  return new ct(this.cy(), r, e);
};
ze.spawnSelf = function() {
  return this.spawn(this);
};
ze.cy = function() {
  return this._private.cy;
};
ze.renderer = function() {
  return this._private.cy.renderer();
};
ze.element = function() {
  return this[0];
};
ze.collection = function() {
  return lf(this) ? this : new ct(this._private.cy, [this]);
};
ze.unique = function() {
  return new ct(this._private.cy, this, !0);
};
ze.hasElementWithId = function(r) {
  return r = "" + r, this._private.map.has(r);
};
ze.getElementById = function(r) {
  r = "" + r;
  var e = this._private.cy, t = this._private.map.get(r);
  return t ? t.ele : new ct(e);
};
ze.$id = ze.getElementById;
ze.poolIndex = function() {
  var r = this._private.cy, e = r._private.elements, t = this[0]._private.data.id;
  return e._private.map.get(t).index;
};
ze.indexOf = function(r) {
  var e = r[0]._private.data.id;
  return this._private.map.get(e).index;
};
ze.indexOfId = function(r) {
  return r = "" + r, this._private.map.get(r).index;
};
ze.json = function(r) {
  var e = this.element(), t = this.cy();
  if (e == null && r)
    return this;
  if (e != null) {
    var a = e._private;
    if (Re(r)) {
      if (t.startBatch(), r.data) {
        e.data(r.data);
        var n = a.data;
        if (e.isEdge()) {
          var i = !1, s = {}, o = r.data.source, u = r.data.target;
          o != null && o != n.source && (s.source = "" + o, i = !0), u != null && u != n.target && (s.target = "" + u, i = !0), i && (e = e.move(s));
        } else {
          var l = "parent" in r.data, f = r.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
          }));
        }
      }
      r.position && e.position(r.position);
      var c = function(p, g, y) {
        var b = r[p];
        b != null && b !== a[p] && (b ? e[g]() : e[y]());
      };
      return c("removed", "remove", "restore"), c("selected", "select", "unselect"), c("selectable", "selectify", "unselectify"), c("locked", "lock", "unlock"), c("grabbable", "grabify", "ungrabify"), c("pannable", "panify", "unpanify"), r.classes != null && e.classes(r.classes), t.endBatch(), this;
    } else if (r === void 0) {
      var v = {
        data: Ut(a.data),
        position: Ut(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
      };
      v.classes = "";
      var h = 0;
      return a.classes.forEach(function(d) {
        return v.classes += h++ === 0 ? d : " " + d;
      }), v;
    }
  }
};
ze.jsons = function() {
  for (var r = [], e = 0; e < this.length; e++) {
    var t = this[e], a = t.json();
    r.push(a);
  }
  return r;
};
ze.clone = function() {
  for (var r = this.cy(), e = [], t = 0; t < this.length; t++) {
    var a = this[t], n = a.json(), i = new Fn(r, n, !1);
    e.push(i);
  }
  return new ct(r, e);
};
ze.copy = ze.clone;
ze.restore = function() {
  for (var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, t = this, a = t.cy(), n = a._private, i = [], s = [], o, u = 0, l = t.length; u < l; u++) {
    var f = t[u];
    e && !f.removed() || (f.isNode() ? i.push(f) : s.push(f));
  }
  o = i.concat(s);
  var c, v = function() {
    o.splice(c, 1), c--;
  };
  for (c = 0; c < o.length; c++) {
    var h = o[c], d = h._private, p = d.data;
    if (h.clearTraversalCache(), !(!e && !d.removed)) {
      if (p.id === void 0)
        p.id = Tf();
      else if (ae(p.id))
        p.id = "" + p.id;
      else if (sr(p.id) || !ce(p.id)) {
        qe("Can not create element with invalid string ID `" + p.id + "`"), v();
        continue;
      } else if (a.hasElementWithId(p.id)) {
        qe("Can not create second element with ID `" + p.id + "`"), v();
        continue;
      }
    }
    var g = p.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, x = !1, S = 0; S < E; S++) {
        var w = m[S], T = p[w];
        ae(T) && (T = p[w] = "" + p[w]), T == null || T === "" ? (qe("Can not create edge `" + g + "` with unspecified " + w), x = !0) : a.hasElementWithId(T) || (qe("Can not create edge `" + g + "` with nonexistant " + w + " `" + T + "`"), x = !0);
      }
      if (x) {
        v();
        continue;
      }
      var C = a.getElementById(p.source), D = a.getElementById(p.target);
      C.same(D) ? C._private.edges.push(b) : (C._private.edges.push(b), D._private.edges.push(b)), b._private.source = C, b._private.target = D;
    }
    d.map = new Kt(), d.map.set(g, {
      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;
    ae(R.parent) && (R.parent = "" + R.parent);
    var I = R.parent, O = I != null;
    if (O || L._private.parent) {
      var N = L._private.parent ? a.collection().merge(L._private.parent) : a.getElementById(I);
      if (N.empty())
        R.parent = void 0;
      else if (N[0].removed())
        Pe("Node added with missing parent, reference to parent removed"), R.parent = void 0, L._private.parent = null;
      else {
        for (var k = !1, P = N; !P.empty(); ) {
          if (L.same(P)) {
            k = !0, R.parent = void 0;
            break;
          }
          P = P.parent();
        }
        k || (N[0]._private.children.push(L), L._private.parent = N[0], n.hasCompoundNodes = !0);
      }
    }
  }
  if (o.length > 0) {
    for (var B = o.length === t.length ? t : new ct(a, o), _ = 0; _ < B.length; _++) {
      var F = B[_];
      F.isNode() || (F.parallelEdges().clearTraversalCache(), F.source().clearTraversalCache(), F.target().clearTraversalCache());
    }
    var G;
    n.hasCompoundNodes ? G = a.collection().merge(B).merge(B.connectedNodes()).merge(B.parent()) : G = B, G.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(r), r ? B.emitAndNotify("add") : e && B.emit("add");
  }
  return t;
};
ze.removed = function() {
  var r = this[0];
  return r && r._private.removed;
};
ze.inside = function() {
  var r = this[0];
  return r && !r._private.removed;
};
ze.remove = function() {
  var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, t = this, a = [], n = {}, i = t._private.cy;
  function s(I) {
    for (var O = I._private.edges, N = 0; N < O.length; N++)
      u(O[N]);
  }
  function o(I) {
    for (var O = I._private.children, N = 0; N < O.length; N++)
      u(O[N]);
  }
  function u(I) {
    var O = n[I.id()];
    e && I.removed() || O || (n[I.id()] = !0, I.isNode() ? (a.push(I), s(I), o(I)) : a.unshift(I));
  }
  for (var l = 0, f = t.length; l < f; l++) {
    var c = t[l];
    u(c);
  }
  function v(I, O) {
    var N = I._private.edges;
    or(N, O), I.clearTraversalCache();
  }
  function h(I) {
    I.clearTraversalCache();
  }
  var d = [];
  d.ids = {};
  function p(I, O) {
    O = O[0], I = I[0];
    var N = I._private.children, k = I.id();
    or(N, O), O._private.parent = null, d.ids[k] || (d.ids[k] = !0, d.push(I));
  }
  t.dirtyCompoundBoundsCache(), e && i.removeFromPool(a);
  for (var g = 0; g < a.length; g++) {
    var y = a[g];
    if (y.isEdge()) {
      var b = y.source()[0], m = y.target()[0];
      v(b, y), v(m, y);
      for (var E = y.parallelEdges(), x = 0; x < E.length; x++) {
        var S = E[x];
        h(S), S.isBundledBezier() && S.dirtyBoundingBoxCache();
      }
    } else {
      var w = y.parent();
      w.length !== 0 && p(w, y);
    }
    e && (y._private.removed = !0);
  }
  var T = i._private.elements;
  i._private.hasCompoundNodes = !1;
  for (var C = 0; C < T.length; C++) {
    var D = T[C];
    if (D.isParent()) {
      i._private.hasCompoundNodes = !0;
      break;
    }
  }
  var A = new ct(this.cy(), a);
  A.size() > 0 && (r ? 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;
};
ze.move = function(r) {
  var e = this._private.cy, t = this, a = !1, n = !1, i = function(d) {
    return d == null ? d : "" + d;
  };
  if (r.source !== void 0 || r.target !== void 0) {
    var s = i(r.source), o = i(r.target), u = s != null && e.hasElementWithId(s), l = o != null && e.hasElementWithId(o);
    (u || l) && (e.batch(function() {
      t.remove(a, n), t.emitAndNotify("moveout");
      for (var h = 0; h < t.length; h++) {
        var d = t[h], p = d._private.data;
        d.isEdge() && (u && (p.source = s), l && (p.target = o));
      }
      t.restore(a, n);
    }), t.emitAndNotify("move"));
  } else if (r.parent !== void 0) {
    var f = i(r.parent), c = f === null || e.hasElementWithId(f);
    if (c) {
      var v = f === null ? void 0 : f;
      e.batch(function() {
        var h = t.remove(a, n);
        h.emitAndNotify("moveout");
        for (var d = 0; d < t.length; d++) {
          var p = t[d], g = p._private.data;
          p.isNode() && (g.parent = v);
        }
        h.restore(a, n);
      }), t.emitAndNotify("move");
    }
  }
  return this;
};
[Nf, zg, cn, nr, ta, rp, Hn, mp, nc, ic, Tp, Ln, vn, ft, ir, gt].forEach(function(r) {
  de(ze, r);
});
var Ip = {
  add: function(e) {
    var t, a = this;
    if (At(e)) {
      var n = e;
      if (n._private.cy === a)
        t = n.restore();
      else {
        for (var i = [], s = 0; s < n.length; s++) {
          var o = n[s];
          i.push(o.json());
        }
        t = new ct(a, i);
      }
    } else if (_e(e)) {
      var u = e;
      t = new ct(a, u);
    } else if (Re(e) && (_e(e.nodes) || _e(e.edges))) {
      for (var l = e, f = [], c = ["nodes", "edges"], v = 0, h = c.length; v < h; v++) {
        var d = c[v], p = l[d];
        if (_e(p))
          for (var g = 0, y = p.length; g < y; g++) {
            var b = de({
              group: d
            }, p[g]);
            f.push(b);
          }
      }
      t = new ct(a, f);
    } else {
      var m = e;
      t = new Fn(a, m).collection();
    }
    return t;
  },
  remove: function(e) {
    if (!At(e)) {
      if (ce(e)) {
        var t = e;
        e = this.$(t);
      }
    }
    return e.remove();
  }
};
/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */
function Mp(r, e, t, a) {
  var n = 4, i = 1e-3, s = 1e-7, o = 10, u = 11, l = 1 / (u - 1), f = typeof Float32Array < "u";
  if (arguments.length !== 4)
    return !1;
  for (var c = 0; c < 4; ++c)
    if (typeof arguments[c] != "number" || isNaN(arguments[c]) || !isFinite(arguments[c]))
      return !1;
  r = Math.min(r, 1), t = Math.min(t, 1), r = Math.max(r, 0), t = Math.max(t, 0);
  var v = 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 p(D) {
    return 3 * D;
  }
  function g(D, A, L) {
    return ((h(A, L) * D + d(A, L)) * D + p(A)) * D;
  }
  function y(D, A, L) {
    return 3 * h(A, L) * D * D + 2 * d(A, L) * D + p(A);
  }
  function b(D, A) {
    for (var L = 0; L < n; ++L) {
      var R = y(A, r, t);
      if (R === 0)
        return A;
      var I = g(A, r, t) - D;
      A -= I / R;
    }
    return A;
  }
  function m() {
    for (var D = 0; D < u; ++D)
      v[D] = g(D * l, r, t);
  }
  function E(D, A, L) {
    var R, I, O = 0;
    do
      I = A + (L - A) / 2, R = g(I, r, t) - D, R > 0 ? L = I : A = I;
    while (Math.abs(R) > s && ++O < o);
    return I;
  }
  function x(D) {
    for (var A = 0, L = 1, R = u - 1; L !== R && v[L] <= D; ++L)
      A += l;
    --L;
    var I = (D - v[L]) / (v[L + 1] - v[L]), O = A + I * l, N = y(O, r, t);
    return N >= i ? b(D, O) : N === 0 ? O : E(D, A, A + l);
  }
  var S = !1;
  function w() {
    S = !0, (r !== e || t !== a) && m();
  }
  var T = function(A) {
    return S || w(), r === e && t === a ? A : A === 0 ? 0 : A === 1 ? 1 : g(x(A), e, a);
  };
  T.getControlPoints = function() {
    return [{
      x: r,
      y: e
    }, {
      x: t,
      y: a
    }];
  };
  var C = "generateBezier(" + [r, e, t, a] + ")";
  return T.toString = function() {
    return C;
  }, T;
}
/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */
var Op = function() {
  function r(a) {
    return -a.tension * a.x - a.friction * a.v;
  }
  function e(a, n, i) {
    var s = {
      x: a.x + i.dx * n,
      v: a.v + i.dv * n,
      tension: a.tension,
      friction: a.friction
    };
    return {
      dx: s.v,
      dv: r(s)
    };
  }
  function t(a, n) {
    var i = {
      dx: a.v,
      dv: r(a)
    }, s = e(a, n * 0.5, i), o = e(a, n * 0.5, s), u = e(a, n, o), l = 1 / 6 * (i.dx + 2 * (s.dx + o.dx) + u.dx), f = 1 / 6 * (i.dv + 2 * (s.dv + o.dv) + u.dv);
    return a.x = a.x + l * n, a.v = a.v + f * n, a;
  }
  return function a(n, i, s) {
    var o = {
      x: -1,
      v: 0,
      tension: null,
      friction: null
    }, u = [0], l = 0, f = 1 / 1e4, c = 16 / 1e3, v, h, d;
    for (n = parseFloat(n) || 500, i = parseFloat(i) || 20, s = s || null, o.tension = n, o.friction = i, v = s !== null, v ? (l = a(n, i), h = l / s * c) : h = c; d = t(d || o, h), u.push(1 + d.x), l += 16, Math.abs(d.x) > f && Math.abs(d.v) > f; )
      ;
    return v ? function(p) {
      return u[p * (u.length - 1) | 0];
    } : l;
  };
}(), Ge = function(e, t, a, n) {
  var i = Mp(e, t, a, n);
  return function(s, o, u) {
    return s + (o - s) * i(u);
  };
}, hn = {
  linear: function(e, t, a) {
    return e + (t - e) * a;
  },
  // default easings
  ease: Ge(0.25, 0.1, 0.25, 1),
  "ease-in": Ge(0.42, 0, 1, 1),
  "ease-out": Ge(0, 0, 0.58, 1),
  "ease-in-out": Ge(0.42, 0, 0.58, 1),
  // sine
  "ease-in-sine": Ge(0.47, 0, 0.745, 0.715),
  "ease-out-sine": Ge(0.39, 0.575, 0.565, 1),
  "ease-in-out-sine": Ge(0.445, 0.05, 0.55, 0.95),
  // quad
  "ease-in-quad": Ge(0.55, 0.085, 0.68, 0.53),
  "ease-out-quad": Ge(0.25, 0.46, 0.45, 0.94),
  "ease-in-out-quad": Ge(0.455, 0.03, 0.515, 0.955),
  // cubic
  "ease-in-cubic": Ge(0.55, 0.055, 0.675, 0.19),
  "ease-out-cubic": Ge(0.215, 0.61, 0.355, 1),
  "ease-in-out-cubic": Ge(0.645, 0.045, 0.355, 1),
  // quart
  "ease-in-quart": Ge(0.895, 0.03, 0.685, 0.22),
  "ease-out-quart": Ge(0.165, 0.84, 0.44, 1),
  "ease-in-out-quart": Ge(0.77, 0, 0.175, 1),
  // quint
  "ease-in-quint": Ge(0.755, 0.05, 0.855, 0.06),
  "ease-out-quint": Ge(0.23, 1, 0.32, 1),
  "ease-in-out-quint": Ge(0.86, 0, 0.07, 1),
  // expo
  "ease-in-expo": Ge(0.95, 0.05, 0.795, 0.035),
  "ease-out-expo": Ge(0.19, 1, 0.22, 1),
  "ease-in-out-expo": Ge(1, 0, 0, 1),
  // circ
  "ease-in-circ": Ge(0.6, 0.04, 0.98, 0.335),
  "ease-out-circ": Ge(0.075, 0.82, 0.165, 1),
  "ease-in-out-circ": Ge(0.785, 0.135, 0.15, 0.86),
  // user param easings...
  spring: function(e, t, a) {
    if (a === 0)
      return hn.linear;
    var n = Op(e, t, a);
    return function(i, s, o) {
      return i + (s - i) * n(o);
    };
  },
  "cubic-bezier": Ge
};
function Al(r, e, t, a, n) {
  if (a === 1 || e === t)
    return t;
  var i = n(e, t, a);
  return r == null || ((r.roundValue || r.color) && (i = Math.round(i)), r.min !== void 0 && (i = Math.max(i, r.min)), r.max !== void 0 && (i = Math.min(i, r.max))), i;
}
function Ll(r, e) {
  return r.pfValue != null || r.value != null ? r.pfValue != null && (e == null || e.type.units !== "%") ? r.pfValue : r.value : r;
}
function _r(r, e, t, a, n) {
  var i = n != null ? n.type : null;
  t < 0 ? t = 0 : t > 1 && (t = 1);
  var s = Ll(r, n), o = Ll(e, n);
  if (ae(s) && ae(o))
    return Al(i, s, o, t, a);
  if (_e(s) && _e(o)) {
    for (var u = [], l = 0; l < o.length; l++) {
      var f = s[l], c = o[l];
      if (f != null && c != null) {
        var v = Al(i, f, c, t, a);
        u.push(v);
      } else
        u.push(c);
    }
    return u;
  }
}
function Pp(r, e, t, a) {
  var n = !a, i = r._private, s = e._private, o = s.easing, u = s.startTime, l = a ? r : r.cy(), f = l.style();
  if (!s.easingImpl)
    if (o == null)
      s.easingImpl = hn.linear;
    else {
      var c;
      if (ce(o)) {
        var v = f.parse("transition-timing-function", o);
        c = v.value;
      } else
        c = o;
      var h, d;
      ce(c) ? (h = c, d = []) : (h = c[1], d = c.slice(2).map(function(B) {
        return +B;
      })), d.length > 0 ? (h === "spring" && d.push(s.duration), s.easingImpl = hn[h].apply(null, d)) : s.easingImpl = hn[h];
    }
  var p = s.easingImpl, g;
  if (s.duration === 0 ? g = 1 : g = (t - u) / s.duration, s.applying && (g = s.progress), g < 0 ? g = 0 : g > 1 && (g = 1), s.delay == null) {
    var y = s.startPosition, b = s.position;
    if (b && n && !r.locked()) {
      var m = {};
      ha(y.x, b.x) && (m.x = _r(y.x, b.x, g, p)), ha(y.y, b.y) && (m.y = _r(y.y, b.y, g, p)), r.position(m);
    }
    var E = s.startPan, x = s.pan, S = i.pan, w = x != null && a;
    w && (ha(E.x, x.x) && (S.x = _r(E.x, x.x, g, p)), ha(E.y, x.y) && (S.y = _r(E.y, x.y, g, p)), r.emit("pan"));
    var T = s.startZoom, C = s.zoom, D = C != null && a;
    D && (ha(T, C) && (i.zoom = Sa(i.minZoom, _r(T, C, g, p), i.maxZoom)), r.emit("zoom")), (w || D) && r.emit("viewport");
    var A = s.style;
    if (A && A.length > 0 && n) {
      for (var L = 0; L < A.length; L++) {
        var R = A[L], I = R.name, O = R, N = s.startStyle[I], k = f.properties[N.name], P = _r(N, O, g, p, k);
        f.overrideBypass(r, I, P);
      }
      r.emit("style");
    }
  }
  return s.progress = g, g;
}
function ha(r, e) {
  return r == null || e == null ? !1 : ae(r) && ae(e) ? !0 : !!(r && e);
}
function Np(r, e, t, a) {
  var n = e._private;
  n.started = !0, n.startTime = t - n.progress * n.duration;
}
function Rl(r, e) {
  var t = e._private.aniEles, a = [];
  function n(f, c) {
    var v = f._private, h = v.animation.current, d = v.animation.queue, p = !1;
    if (h.length === 0) {
      var g = d.shift();
      g && h.push(g);
    }
    for (var y = function(S) {
      for (var w = S.length - 1; w >= 0; w--) {
        var T = S[w];
        T();
      }
      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 || Np(f, m, r), Pp(f, m, r, c), E.applying && (E.applying = !1), y(E.frames), E.step != null && E.step(r), m.completed() && (h.splice(b, 1), E.hooked = !1, E.playing = !1, E.started = !1, y(E.completes)), p = !0);
    }
    return !c && h.length === 0 && d.length === 0 && a.push(f), p;
  }
  for (var i = !1, s = 0; s < t.length; s++) {
    var o = t[s], u = n(o);
    i = i || u;
  }
  var l = n(e, !0);
  (i || l) && (t.length > 0 ? e.notify("draw", t) : e.notify("draw")), t.unmerge(a), e.emit("step");
}
var kp = {
  // pull in animation functions
  animate: Oe.animate(),
  animation: Oe.animation(),
  animated: Oe.animated(),
  clearQueue: Oe.clearQueue(),
  delay: Oe.delay(),
  delayAnimation: Oe.delayAnimation(),
  stop: Oe.stop(),
  addToAnimationPool: function(e) {
    var t = this;
    t.styleEnabled() && t._private.aniEles.merge(e);
  },
  stopAnimationLoop: function() {
    this._private.animationsRunning = !1;
  },
  startAnimationLoop: function() {
    var e = this;
    if (e._private.animationsRunning = !0, !e.styleEnabled())
      return;
    function t() {
      e._private.animationsRunning && Tn(function(i) {
        Rl(i, e), t();
      });
    }
    var a = e.renderer();
    a && a.beforeRender ? a.beforeRender(function(i, s) {
      Rl(s, e);
    }, a.beforeRenderPriorities.animations) : t();
  }
}, Bp = {
  qualifierCompare: function(e, t) {
    return e == null || t == null ? e == null && t == null : e.sameText(t);
  },
  eventMatches: function(e, t, a) {
    var n = t.qualifier;
    return n != null ? e !== a.target && Na(a.target) && n.matches(a.target) : !0;
  },
  addEventFields: function(e, t) {
    t.cy = e, t.target = e;
  },
  callbackContext: function(e, t, a) {
    return t.qualifier != null ? a.target : e;
  }
}, an = function(e) {
  return ce(e) ? new lr(e) : e;
}, uc = {
  createEmitter: function() {
    var e = this._private;
    return e.emitter || (e.emitter = new Yn(Bp, this)), this;
  },
  emitter: function() {
    return this._private.emitter;
  },
  on: function(e, t, a) {
    return this.emitter().on(e, an(t), a), this;
  },
  removeListener: function(e, t, a) {
    return this.emitter().removeListener(e, an(t), a), this;
  },
  removeAllListeners: function() {
    return this.emitter().removeAllListeners(), this;
  },
  one: function(e, t, a) {
    return this.emitter().one(e, an(t), a), this;
  },
  once: function(e, t, a) {
    return this.emitter().one(e, an(t), a), this;
  },
  emit: function(e, t) {
    return this.emitter().emit(e, t), this;
  },
  emitAndNotify: function(e, t) {
    return this.emit(e), this.notify(e, t), this;
  }
};
Oe.eventAliasesOn(uc);
var Vs = {
  png: function(e) {
    var t = this._private.renderer;
    return e = e || {}, t.png(e);
  },
  jpg: function(e) {
    var t = this._private.renderer;
    return e = e || {}, e.bg = e.bg || "#fff", t.jpg(e);
  }
};
Vs.jpeg = Vs.jpg;
var dn = {
  layout: function(e) {
    var t = 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 = t.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;
    ce(e.eles) ? i = t.$(e.eles) : i = e.eles != null ? e.eles : t.$();
    var s = new n(de({}, e, {
      cy: t,
      eles: i
    }));
    return s;
  }
};
dn.createLayout = dn.makeLayout = dn.layout;
var Fp = {
  notify: function(e, t) {
    var a = this._private;
    if (this.batching()) {
      a.batchNotifications = a.batchNotifications || {};
      var n = a.batchNotifications[e] = a.batchNotifications[e] || this.collection();
      t != null && n.merge(t);
      return;
    }
    if (a.notificationsEnabled) {
      var i = this.renderer();
      this.destroyed() || !i || i.notify(e, t);
    }
  },
  notifications: function(e) {
    var t = this._private;
    return e === void 0 ? t.notificationsEnabled : (t.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 t = this.renderer();
      Object.keys(e.batchNotifications).forEach(function(a) {
        var n = e.batchNotifications[a];
        n.empty() ? t.notify(a) : t.notify(a, n);
      });
    }
    return this;
  },
  batch: function(e) {
    return this.startBatch(), e(), this.endBatch(), this;
  },
  // for backwards compatibility
  batchData: function(e) {
    var t = this;
    return this.batch(function() {
      for (var a = Object.keys(e), n = 0; n < a.length; n++) {
        var i = a[n], s = e[i], o = t.getElementById(i);
        o.data(s);
      }
    });
  }
}, _p = vt({
  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]
}), Us = {
  renderTo: function(e, t, a, n) {
    var i = this._private.renderer;
    return i.renderTo(e, t, 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 t = this, a = t.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 && Pe("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 = _p(e);
    n.cy = t, t._private.renderer = new a(n), this.notify("init");
  },
  destroyRenderer: function() {
    var e = this;
    e.notify("destroy");
    var t = e.container();
    if (t)
      for (t._cyreg = null; t.childNodes.length > 0; )
        t.removeChild(t.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);
  }
};
Us.invalidateDimensions = Us.resize;
var gn = {
  // 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, t) {
    return ce(e) ? this.$(e) : At(e) ? e.collection() : _e(e) ? (t || (t = {}), new ct(this, e, t.unique, t.removed)) : new ct(this);
  },
  nodes: function(e) {
    var t = this.$(function(a) {
      return a.isNode();
    });
    return e ? t.filter(e) : t;
  },
  edges: function(e) {
    var t = this.$(function(a) {
      return a.isEdge();
    });
    return e ? t.filter(e) : t;
  },
  // search the graph like jQuery
  $: function(e) {
    var t = this._private.elements;
    return e ? t.filter(e) : t.spawnSelf();
  },
  mutableElements: function() {
    return this._private.elements;
  }
};
gn.elements = gn.filter = gn.$;
var ot = {}, wa = "t", Gp = "f";
ot.apply = function(r) {
  for (var e = this, t = e._private, a = t.cy, n = a.collection(), i = 0; i < r.length; i++) {
    var s = r[i], o = e.getContextMeta(s);
    if (!o.empty) {
      var u = e.getContextStyle(o), l = e.applyContextStyle(o, u, s);
      s._private.appliedInitStyle ? e.updateTransitions(s, l.diffProps) : s._private.appliedInitStyle = !0;
      var f = e.updateStyleHints(s);
      f && n.push(s);
    }
  }
  return n;
};
ot.getPropertiesDiff = function(r, e) {
  var t = this, a = t._private.propDiffs = t._private.propDiffs || {}, n = r + "-" + e, i = a[n];
  if (i)
    return i;
  for (var s = [], o = {}, u = 0; u < t.length; u++) {
    var l = t[u], f = r[u] === wa, c = e[u] === wa, v = f !== c, h = l.mappedProperties.length > 0;
    if (v || c && h) {
      var d = void 0;
      v && h || v ? d = l.properties : h && (d = l.mappedProperties);
      for (var p = 0; p < d.length; p++) {
        for (var g = d[p], y = g.name, b = !1, m = u + 1; m < t.length; m++) {
          var E = t[m], x = e[m] === wa;
          if (x && (b = E.properties[g.name] != null, b))
            break;
        }
        !o[y] && !b && (o[y] = !0, s.push(y));
      }
    }
  }
  return a[n] = s, s;
};
ot.getContextMeta = function(r) {
  for (var e = this, t = "", a, n = r._private.styleCxtKey || "", i = 0; i < e.length; i++) {
    var s = e[i], o = s.selector && s.selector.matches(r);
    o ? t += wa : t += Gp;
  }
  return a = e.getPropertiesDiff(n, t), r._private.styleCxtKey = t, {
    key: t,
    diffPropNames: a,
    empty: a.length === 0
  };
};
ot.getContextStyle = function(r) {
  var e = r.key, t = this, a = this._private.contextStyles = this._private.contextStyles || {};
  if (a[e])
    return a[e];
  for (var n = {
    _private: {
      key: e
    }
  }, i = 0; i < t.length; i++) {
    var s = t[i], o = e[i] === wa;
    if (o)
      for (var u = 0; u < s.properties.length; u++) {
        var l = s.properties[u];
        n[l.name] = l;
      }
  }
  return a[e] = n, n;
};
ot.applyContextStyle = function(r, e, t) {
  for (var a = this, n = r.diffPropNames, i = {}, s = a.types, o = 0; o < n.length; o++) {
    var u = n[o], l = e[u], f = t.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 === s.fn && f != null && f.mapping != null && f.mapping.value === l.value) {
        var c = f.mapping, v = c.fnValue = l.value(t);
        if (v === c.prevFnValue)
          continue;
      }
      var h = i[u] = {
        prev: f
      };
      a.applyParsedProperty(t, l), h.next = t.pstyle(u), h.next && h.next.bypass && (h.next = h.next.bypassed);
    }
  }
  return {
    diffProps: i
  };
};
ot.updateStyleHints = function(r) {
  var e = r._private, t = this, a = t.propertyGroupNames, n = t.propertyGroupKeys, i = function(Y, ee, ne) {
    return t.getPropertiesHash(Y, ee, ne);
  }, s = e.styleKey;
  if (r.removed())
    return !1;
  var o = e.group === "nodes", u = r._private.style;
  a = Object.keys(u);
  for (var l = 0; l < n.length; l++) {
    var f = n[l];
    e.styleKeys[f] = [Cr, Hr];
  }
  for (var c = function(Y, ee) {
    return e.styleKeys[ee][0] = Ta(Y, e.styleKeys[ee][0]);
  }, v = function(Y, ee) {
    return e.styleKeys[ee][1] = Ca(Y, e.styleKeys[ee][1]);
  }, h = function(Y, ee) {
    c(Y, ee), v(Y, ee);
  }, d = function(Y, ee) {
    for (var ne = 0; ne < Y.length; ne++) {
      var be = Y.charCodeAt(ne);
      c(be, ee), v(be, ee);
    }
  }, p = 2e9, g = function(Y) {
    return -128 < Y && Y < 128 && Math.floor(Y) !== Y ? p - (Y * 1024 | 0) : Y;
  }, y = 0; y < a.length; y++) {
    var b = a[y], m = u[b];
    if (m != null) {
      var E = this.properties[b], x = E.type, S = E.groupKey, w = void 0;
      E.hashOverride != null ? w = E.hashOverride(r, m) : m.pfValue != null && (w = m.pfValue);
      var T = E.enums == null ? m.value : null, C = w != null, D = T != null, A = C || D, L = m.units;
      if (x.number && A && !x.multiple) {
        var R = C ? w : T;
        h(g(R), S), !C && L != null && d(L, S);
      } else
        d(m.strValue, S);
    }
  }
  for (var I = [Cr, Hr], O = 0; O < n.length; O++) {
    var N = n[O], k = e.styleKeys[N];
    I[0] = Ta(k[0], I[0]), I[1] = Ca(k[1], I[1]);
  }
  e.styleKey = nh(I[0], I[1]);
  var P = e.styleKeys;
  e.labelDimsKey = tr(P.labelDimensions);
  var B = i(r, ["label"], P.labelDimensions);
  if (e.labelKey = tr(B), e.labelStyleKey = tr(Ka(P.commonLabel, B)), !o) {
    var _ = i(r, ["source-label"], P.labelDimensions);
    e.sourceLabelKey = tr(_), e.sourceLabelStyleKey = tr(Ka(P.commonLabel, _));
    var F = i(r, ["target-label"], P.labelDimensions);
    e.targetLabelKey = tr(F), e.targetLabelStyleKey = tr(Ka(P.commonLabel, F));
  }
  if (o) {
    var G = e.styleKeys, U = G.nodeBody, H = G.nodeBorder, $ = G.nodeOutline, X = G.backgroundImage, Q = G.compound, re = G.pie, J = G.stripe, z = [U, H, $, X, Q, re, J].filter(function(V) {
      return V != null;
    }).reduce(Ka, [Cr, Hr]);
    e.nodeKey = tr(z), e.hasPie = re != null && re[0] !== Cr && re[1] !== Hr, e.hasStripe = J != null && J[0] !== Cr && J[1] !== Hr;
  }
  return s !== e.styleKey;
};
ot.clearStyleHints = function(r) {
  var e = r._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(r, e) {
  var t = this, a = e, n = r._private.style, i, s = t.types, o = t.properties[a.name].type, u = a.bypass, l = n[a.name], f = l && l.bypass, c = r._private, v = "mapping", h = function(U) {
    return U == null ? null : U.pfValue != null ? U.pfValue : U.value;
  }, d = function() {
    var U = h(l), H = h(a);
    t.checkTriggers(r, a.name, U, H);
  };
  if (e.name === "curve-style" && r.isEdge() && // loops must be bundled beziers
  (e.value !== "bezier" && r.isLoop() || // edges connected to compound nodes can not be haystacks
  e.value === "haystack" && (r.source().isParent() || r.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 p = function() {
    Pe("Do not assign mappings to elements without corresponding data (i.e. ele `" + r.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) {
    case s.mapData: {
      for (var g = a.field.split("."), y = c.data, b = 0; b < g.length && y; b++) {
        var m = g[b];
        y = y[m];
      }
      if (y == null)
        return p(), !1;
      var E;
      if (ae(y)) {
        var x = a.fieldMax - a.fieldMin;
        x === 0 ? E = 0 : E = (y - a.fieldMin) / x;
      } else
        return Pe("Do not use continuous mappers without specifying numeric data (i.e. `" + a.field + ": " + y + "` for `" + r.id() + "` is non-numeric)"), !1;
      if (E < 0 ? E = 0 : E > 1 && (E = 1), o.color) {
        var S = a.valueMin[0], w = a.valueMax[0], T = a.valueMin[1], C = 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], I = [Math.round(S + (w - S) * E), Math.round(T + (C - T) * 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: I,
          strValue: "rgb(" + I[0] + ", " + I[1] + ", " + I[2] + ")"
        };
      } else if (o.number) {
        var O = a.valueMin + (a.valueMax - a.valueMin) * E;
        i = this.parse(a.name, O, a.bypass, v);
      } else
        return !1;
      if (!i)
        return p(), !1;
      i.mapping = a, a = i;
      break;
    }
    case s.data: {
      for (var N = a.field.split("."), k = c.data, P = 0; P < N.length && k; P++) {
        var B = N[P];
        k = k[B];
      }
      if (k != null && (i = this.parse(a.name, k, a.bypass, v)), !i)
        return p(), !1;
      i.mapping = a, a = i;
      break;
    }
    case s.fn: {
      var _ = a.value, F = a.fnValue != null ? a.fnValue : _(r);
      if (a.prevFnValue = F, F == null)
        return Pe("Custom function mappers may not return null (i.e. `" + a.name + "` for ele `" + r.id() + "` is null)"), !1;
      if (i = this.parse(a.name, F, a.bypass, v), !i)
        return Pe("Custom function mappers may not return invalid values for the property type (i.e. `" + a.name + "` for ele `" + r.id() + "` is invalid)"), !1;
      i.mapping = Ut(a), a = i;
      break;
    }
    case void 0:
      break;
    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(r, e) {
  for (var t = 0; t < r.length; t++) {
    var a = r[t];
    if (this.clearStyleHints(a), a.dirtyCompoundBoundsCache(), a.dirtyBoundingBoxCache(), !e)
      a._private.style = {};
    else
      for (var n = a._private.style, i = Object.keys(n), s = 0; s < i.length; s++) {
        var o = i[s], u = n[o];
        u != null && (u.bypass ? u.bypassed = null : n[o] = null);
      }
  }
};
ot.update = function() {
  var r = this._private.cy, e = r.mutableElements();
  e.updateStyle();
};
ot.updateTransitions = function(r, e) {
  var t = this, a = r._private, n = r.pstyle("transition-property").value, i = r.pstyle("transition-duration").pfValue, s = r.pstyle("transition-delay").pfValue;
  if (n.length > 0 && i > 0) {
    for (var o = {}, u = !1, l = 0; l < n.length; l++) {
      var f = n[l], c = r.pstyle(f), v = e[f];
      if (v) {
        var h = v.prev, d = h, p = v.next != null ? v.next : c, g = !1, y = void 0, b = 1e-6;
        d && (ae(d.pfValue) && ae(p.pfValue) ? (g = p.pfValue - d.pfValue, y = d.pfValue + b * g) : ae(d.value) && ae(p.value) ? (g = p.value - d.value, y = d.value + b * g) : _e(d.value) && _e(p.value) && (g = d.value[0] !== p.value[0] || d.value[1] !== p.value[1] || d.value[2] !== p.value[2], y = d.strValue), g && (o[f] = p.strValue, this.applyBypass(r, f, y), u = !0));
      }
    }
    if (!u)
      return;
    a.transitioning = !0, new aa(function(m) {
      s > 0 ? r.delayAnimation(s).play().promise().then(m) : m();
    }).then(function() {
      return r.animation({
        style: o,
        duration: i,
        easing: r.pstyle("transition-timing-function").value,
        queue: !1
      }).play().promise();
    }).then(function() {
      t.removeBypasses(r, n), r.emitAndNotify("style"), a.transitioning = !1;
    });
  } else
    a.transitioning && (this.removeBypasses(r, n), r.emitAndNotify("style"), a.transitioning = !1);
};
ot.checkTrigger = function(r, e, t, a, n, i) {
  var s = this.properties[e], o = n(s);
  r.removed() || o != null && o(t, a, r) && i(s);
};
ot.checkZOrderTrigger = function(r, e, t, a) {
  var n = this;
  this.checkTrigger(r, e, t, a, function(i) {
    return i.triggersZOrder;
  }, function() {
    n._private.cy.notify("zorder", r);
  });
};
ot.checkBoundsTrigger = function(r, e, t, a) {
  this.checkTrigger(r, e, t, a, function(n) {
    return n.triggersBounds;
  }, function(n) {
    r.dirtyCompoundBoundsCache(), r.dirtyBoundingBoxCache();
  });
};
ot.checkConnectedEdgesBoundsTrigger = function(r, e, t, a) {
  this.checkTrigger(r, e, t, a, function(n) {
    return n.triggersBoundsOfConnectedEdges;
  }, function(n) {
    r.connectedEdges().forEach(function(i) {
      i.dirtyBoundingBoxCache();
    });
  });
};
ot.checkParallelEdgesBoundsTrigger = function(r, e, t, a) {
  this.checkTrigger(r, e, t, a, function(n) {
    return n.triggersBoundsOfParallelEdges;
  }, function(n) {
    r.parallelEdges().forEach(function(i) {
      i.dirtyBoundingBoxCache();
    });
  });
};
ot.checkTriggers = function(r, e, t, a) {
  r.dirtyStyleCache(), this.checkZOrderTrigger(r, e, t, a), this.checkBoundsTrigger(r, e, t, a), this.checkConnectedEdgesBoundsTrigger(r, e, t, a), this.checkParallelEdgesBoundsTrigger(r, e, t, a);
};
var Va = {};
Va.applyBypass = function(r, e, t, a) {
  var n = this, i = [], s = !0;
  if (e === "*" || e === "**") {
    if (t !== void 0)
      for (var o = 0; o < n.properties.length; o++) {
        var u = n.properties[o], l = u.name, f = this.parse(l, t, !0);
        f && i.push(f);
      }
  } else if (ce(e)) {
    var c = this.parse(e, t, !0);
    c && i.push(c);
  } else if (Re(e)) {
    var v = e;
    a = t;
    for (var h = Object.keys(v), d = 0; d < h.length; d++) {
      var p = h[d], g = v[p];
      if (g === void 0 && (g = v[kn(p)]), g !== void 0) {
        var y = this.parse(p, g, !0);
        y && i.push(y);
      }
    }
  } else
    return !1;
  if (i.length === 0)
    return !1;
  for (var b = !1, m = 0; m < r.length; m++) {
    for (var E = r[m], x = {}, S = void 0, w = 0; w < i.length; w++) {
      var T = i[w];
      if (a) {
        var C = E.pstyle(T.name);
        S = x[T.name] = {
          prev: C
        };
      }
      b = this.applyParsedProperty(E, Ut(T)) || b, a && (S.next = E.pstyle(T.name));
    }
    b && this.updateStyleHints(E), a && this.updateTransitions(E, x, s);
  }
  return b;
};
Va.overrideBypass = function(r, e, t) {
  e = ao(e);
  for (var a = 0; a < r.length; a++) {
    var n = r[a], i = n._private.style[e], s = this.properties[e].type, o = s.color, u = s.mutiple, l = i ? i.pfValue != null ? i.pfValue : i.value : null;
    !i || !i.bypass ? this.applyBypass(n, e, t) : (i.value = t, i.pfValue != null && (i.pfValue = t), o ? i.strValue = "rgb(" + t.join(",") + ")" : u ? i.strValue = t.join(" ") : i.strValue = "" + t, this.updateStyleHints(n)), this.checkTriggers(n, e, l, t);
  }
};
Va.removeAllBypasses = function(r, e) {
  return this.removeBypasses(r, this.propertyNames, e);
};
Va.removeBypasses = function(r, e, t) {
  for (var a = !0, n = 0; n < r.length; n++) {
    for (var i = r[n], s = {}, o = 0; o < e.length; o++) {
      var u = e[o], l = this.properties[u], f = i.pstyle(l.name);
      if (!(!f || !f.bypass)) {
        var c = "", v = this.parse(u, c, !0), h = s[l.name] = {
          prev: f
        };
        this.applyParsedProperty(i, v), h.next = i.pstyle(l.name);
      }
    }
    this.updateStyleHints(i), t && this.updateTransitions(i, s, a);
  }
};
var bo = {};
bo.getEmSizeInPixels = function() {
  var r = this.containerCss("font-size");
  return r != null ? parseFloat(r) : 1;
};
bo.containerCss = function(r) {
  var e = this._private.cy, t = e.container(), a = e.window();
  if (a && t && a.getComputedStyle)
    return a.getComputedStyle(t).getPropertyValue(r);
};
var qt = {};
qt.getRenderedStyle = function(r, e) {
  return e ? this.getStylePropertyValue(r, e, !0) : this.getRawStyle(r, !0);
};
qt.getRawStyle = function(r, e) {
  var t = this;
  if (r = r[0], r) {
    for (var a = {}, n = 0; n < t.properties.length; n++) {
      var i = t.properties[n], s = t.getStylePropertyValue(r, i.name, e);
      s != null && (a[i.name] = s, a[kn(i.name)] = s);
    }
    return a;
  }
};
qt.getIndexedStyle = function(r, e, t, a) {
  var n = r.pstyle(e)[t][a];
  return n ?? r.cy().style().getDefaultProperty(e)[t][0];
};
qt.getStylePropertyValue = function(r, e, t) {
  var a = this;
  if (r = r[0], r) {
    var n = a.properties[e];
    n.alias && (n = n.pointsTo);
    var i = n.type, s = r.pstyle(n.name);
    if (s) {
      var o = s.value, u = s.units, l = s.strValue;
      if (t && i.number && o != null && ae(o)) {
        var f = r.cy().zoom(), c = function(g) {
          return g * f;
        }, v = function(g, y) {
          return c(g) + y;
        }, h = _e(o), d = h ? u.every(function(p) {
          return p != null;
        }) : u != null;
        return d ? h ? o.map(function(p, g) {
          return v(p, u[g]);
        }).join(" ") : v(o, u) : h ? o.map(function(p) {
          return ce(p) ? p : "" + c(p);
        }).join(" ") : "" + c(o);
      } else if (l != null)
        return l;
    }
    return null;
  }
};
qt.getAnimationStartStyle = function(r, e) {
  for (var t = {}, a = 0; a < e.length; a++) {
    var n = e[a], i = n.name, s = r.pstyle(i);
    s !== void 0 && (Re(s) ? s = this.parse(i, s.strValue) : s = this.parse(i, s)), s && (t[i] = s);
  }
  return t;
};
qt.getPropsList = function(r) {
  var e = this, t = [], a = r, n = e.properties;
  if (a)
    for (var i = Object.keys(a), s = 0; s < i.length; s++) {
      var o = i[s], u = a[o], l = n[o] || n[ao(o)], f = this.parse(l.name, u);
      f && t.push(f);
    }
  return t;
};
qt.getNonDefaultPropertiesHash = function(r, e, t) {
  var a = t.slice(), n, i, s, o, u, l;
  for (u = 0; u < e.length; u++)
    if (n = e[u], i = r.pstyle(n, !1), i != null)
      if (i.pfValue != null)
        a[0] = Ta(o, a[0]), a[1] = Ca(o, a[1]);
      else
        for (s = i.strValue, l = 0; l < s.length; l++)
          o = s.charCodeAt(l), a[0] = Ta(o, a[0]), a[1] = Ca(o, a[1]);
  return a;
};
qt.getPropertiesHash = qt.getNonDefaultPropertiesHash;
var Wn = {};
Wn.appendFromJson = function(r) {
  for (var e = this, t = 0; t < r.length; t++) {
    var a = r[t], n = a.selector, i = a.style || a.css, s = Object.keys(i);
    e.selector(n);
    for (var o = 0; o < s.length; o++) {
      var u = s[o], l = i[u];
      e.css(u, l);
    }
  }
  return e;
};
Wn.fromJson = function(r) {
  var e = this;
  return e.resetToDefault(), e.appendFromJson(r), e;
};
Wn.json = function() {
  for (var r = [], e = this.defaultLength; e < this.length; e++) {
    for (var t = this[e], a = t.selector, n = t.properties, i = {}, s = 0; s < n.length; s++) {
      var o = n[s];
      i[o.name] = o.strValue;
    }
    r.push({
      selector: a ? a.toString() : "core",
      style: i
    });
  }
  return r;
};
var wo = {};
wo.appendFromString = function(r) {
  var e = this, t = this, a = "" + r, n, i, s;
  a = a.replace(/[/][*](\s|.)+?[*][/]/g, "");
  function o() {
    a.length > n.length ? a = a.substr(n.length) : a = "";
  }
  function u() {
    i.length > s.length ? i = i.substr(s.length) : i = "";
  }
  for (; ; ) {
    var l = a.match(/^\s*$/);
    if (l)
      break;
    var f = a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);
    if (!f) {
      Pe("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: " + a);
      break;
    }
    n = f[0];
    var c = f[1];
    if (c !== "core") {
      var v = new lr(c);
      if (v.invalid) {
        Pe("Skipping parsing of block: Invalid selector found in string stylesheet: " + c), o();
        continue;
      }
    }
    var h = f[2], d = !1;
    i = h;
    for (var p = []; ; ) {
      var g = i.match(/^\s*$/);
      if (g)
        break;
      var y = i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);
      if (!y) {
        Pe("Skipping parsing of block: Invalid formatting of style property and value definitions found in:" + h), d = !0;
        break;
      }
      s = y[0];
      var b = y[1], m = y[2], E = e.properties[b];
      if (!E) {
        Pe("Skipping property: Invalid property name in: " + s), u();
        continue;
      }
      var x = t.parse(b, m);
      if (!x) {
        Pe("Skipping property: Invalid property definition in: " + s), u();
        continue;
      }
      p.push({
        name: b,
        val: m
      }), u();
    }
    if (d) {
      o();
      break;
    }
    t.selector(c);
    for (var S = 0; S < p.length; S++) {
      var w = p[S];
      t.css(w.name, w.val);
    }
    o();
  }
  return t;
};
wo.fromString = function(r) {
  var e = this;
  return e.resetToDefault(), e.appendFromString(r), e;
};
var Ze = {};
(function() {
  var r = tt, e = Bv, t = _v, a = Gv, n = zv, i = function(V) {
    return "^" + V + "\\s*\\(\\s*([\\w\\.]+)\\s*\\)$";
  }, s = function(V) {
    var Y = r + "|\\w+|" + e + "|" + t + "|" + a + "|" + n;
    return "^" + V + "\\s*\\(([\\w\\.]+)\\s*\\,\\s*(" + r + ")\\s*\\,\\s*(" + r + ")\\s*,\\s*(" + Y + ")\\s*\\,\\s*(" + Y + ")\\)$";
  }, o = [`^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
    },
    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"]
    },
    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", "center", "bottom"]
    },
    halign: {
      enums: ["left", "center", "right"]
    },
    justification: {
      enums: ["left", "center", "right", "auto"]
    },
    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: s("mapData")
    },
    mapLayoutData: {
      mapping: !0,
      regex: s("mapLayoutData")
    },
    mapScratch: {
      mapping: !0,
      regex: s("mapScratch")
    },
    fn: {
      mapping: !0,
      fn: !0
    },
    url: {
      regexes: o,
      singleRegexMatchValue: !0
    },
    urls: {
      regexes: o,
      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(V, Y) {
        switch (V.length) {
          case 2:
            return Y[0] !== "deg" && Y[0] !== "rad" && Y[1] !== "deg" && Y[1] !== "rad";
          case 1:
            return ce(V[0]) || Y[0] === "deg" || Y[0] === "rad";
          default:
            return !1;
        }
      }
    },
    easing: {
      regexes: ["^(spring)\\s*\\(\\s*(" + r + ")\\s*,\\s*(" + r + ")\\s*\\)$", "^(cubic-bezier)\\s*\\(\\s*(" + r + ")\\s*,\\s*(" + r + ")\\s*,\\s*(" + r + ")\\s*,\\s*(" + r + ")\\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(V) {
        var Y = V.length;
        return Y === 1 || Y === 2 || Y === 4;
      }
    }
  };
  var u = {
    zeroNonZero: function(V, Y) {
      return (V == null || Y == null) && V !== Y || V == 0 && Y != 0 ? !0 : V != 0 && Y == 0;
    },
    any: function(V, Y) {
      return V != Y;
    },
    emptyNonEmpty: function(V, Y) {
      var ee = sr(V), ne = sr(Y);
      return ee && !ne || !ee && ne;
    }
  }, 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
  }], c = [{
    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
  }], v = [{
    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: "box-select-labels",
    type: l.bool,
    triggersBounds: u.any
  }], p = [{
    name: "events",
    type: l.bool,
    triggersZOrder: u.any
  }, {
    name: "text-events",
    type: l.bool,
    triggersZOrder: u.any
  }], g = [{
    name: "display",
    type: l.display,
    triggersZOrder: u.any,
    triggersBounds: u.any,
    triggersBoundsOfConnectedEdges: u.any,
    triggersBoundsOfParallelEdges: function(V, Y, ee) {
      return V === Y ? !1 : ee.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(V, Y) {
    return Y.value === "label" ? -V.poolIndex() : Y.pfValue;
  }, x = [{
    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
  }], T = [{
    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
  }], C = [{
    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(V, Y) {
      return V === Y ? !1 : V === "bezier" || // remove from bundle
      Y === "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 I = 1; I <= Ze.pieBackgroundN; I++)
    R.push({
      name: "pie-" + I + "-background-color",
      type: l.color
    }), R.push({
      name: "pie-" + I + "-background-size",
      type: l.percent
    }), R.push({
      name: "pie-" + I + "-background-opacity",
      type: l.zeroOneNumber
    });
  var O = [];
  Ze.stripeBackgroundN = 16, O.push({
    name: "stripe-size",
    type: l.sizeMaybePercent
  }), O.push({
    name: "stripe-direction",
    type: l.axisDirectionPrimary
  });
  for (var N = 1; N <= Ze.stripeBackgroundN; N++)
    O.push({
      name: "stripe-" + N + "-background-color",
      type: l.color
    }), O.push({
      name: "stripe-" + N + "-background-size",
      type: l.percent
    }), O.push({
      name: "stripe-" + N + "-background-opacity",
      type: l.zeroOneNumber
    });
  var k = [], P = 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(z) {
    P.forEach(function(V) {
      var Y = V + "-" + z.name, ee = z.type, ne = z.triggersBounds;
      k.push({
        name: Y,
        type: ee,
        triggersBounds: ne
      });
    });
  }, {});
  var B = Ze.properties = [].concat(p, m, g, y, b, A, d, h, f, c, v, x, S, w, T, R, O, C, D, k, L), _ = Ze.propertyGroups = {
    // common to all eles
    behavior: p,
    transition: m,
    visibility: g,
    overlay: y,
    underlay: b,
    ghost: A,
    // labels
    commonLabel: d,
    labelDimensions: h,
    mainLabel: f,
    sourceLabel: c,
    targetLabel: v,
    // node props
    nodeBody: x,
    nodeBorder: S,
    nodeOutline: w,
    backgroundImage: T,
    pie: R,
    stripe: O,
    compound: C,
    // edge props
    edgeLine: D,
    edgeArrow: k,
    core: L
  }, F = Ze.propertyGroupNames = {}, G = Ze.propertyGroupKeys = Object.keys(_);
  G.forEach(function(z) {
    F[z] = _[z].map(function(V) {
      return V.name;
    }), _[z].forEach(function(V) {
      return V.groupKey = z;
    });
  });
  var U = 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 = B.map(function(z) {
    return z.name;
  });
  for (var H = 0; H < B.length; H++) {
    var $ = B[H];
    B[$.name] = $;
  }
  for (var X = 0; X < U.length; X++) {
    var Q = U[X], re = B[Q.pointsTo], J = {
      name: Q.name,
      alias: !0,
      pointsTo: re
    };
    B.push(J), B[Q.name] = J;
  }
})();
Ze.getDefaultProperty = function(r) {
  return this.getDefaultProperties()[r];
};
Ze.getDefaultProperties = function() {
  var r = this._private;
  if (r.defaultProperties != null)
    return r.defaultProperties;
  for (var e = de({
    // 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",
    "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",
    "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 c = l.name.replace("{{i}}", f), v = l.value;
      u[c] = v;
    }
    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 c = l.name.replace("{{i}}", f), v = l.value;
      u[c] = v;
    }
    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 c = f + "-" + l.name, v = l.value;
      u[c] = v;
    }), u;
  }, {})), t = {}, a = 0; a < this.properties.length; a++) {
    var n = this.properties[a];
    if (!n.pointsTo) {
      var i = n.name, s = e[i], o = this.parse(i, s);
      t[i] = o;
    }
  }
  return r.defaultProperties = t, r.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(r, e, t, a) {
  var n = this;
  if (He(e))
    return n.parseImplWarn(r, e, t, a);
  var i = a === "mapping" || a === !0 || a === !1 || a == null ? "dontcare" : a, s = t ? "t" : "f", o = "" + e, u = wf(r, o, s, i), l = n.propCache = n.propCache || [], f;
  return (f = l[u]) || (f = l[u] = n.parseImplWarn(r, e, t, a)), (t || a === "mapping") && (f = Ut(f), f && (f.value = Ut(f.value))), f;
};
Kn.parseImplWarn = function(r, e, t, a) {
  var n = this.parseImpl(r, e, t, a);
  return !n && e != null && Pe("The style property `".concat(r, ": ").concat(e, "` is invalid")), n && (n.name === "width" || n.name === "height") && e === "label" && Pe("The style value of `label` is deprecated for `" + n.name + "`"), n;
};
Kn.parseImpl = function(r, e, t, a) {
  var n = this;
  r = ao(r);
  var i = n.properties[r], s = e, o = n.types;
  if (!i || e === void 0)
    return null;
  i.alias && (i = i.pointsTo, r = i.name);
  var u = ce(e);
  u && (e = e.trim());
  var l = i.type;
  if (!l)
    return null;
  if (t && (e === "" || e === null))
    return {
      name: r,
      value: e,
      bypass: !0,
      deleteBypass: !0
    };
  if (He(e))
    return {
      name: r,
      value: e,
      strValue: "fn",
      mapped: o.fn,
      bypass: t
    };
  var f, c;
  if (!(!u || a || e.length < 7 || e[1] !== "a")) {
    if (e.length >= 7 && e[0] === "d" && (f = new RegExp(o.data.regex).exec(e))) {
      if (t)
        return !1;
      var v = o.data;
      return {
        name: r,
        value: f,
        strValue: "" + e,
        mapped: v,
        field: f[1],
        bypass: t
      };
    } else if (e.length >= 10 && e[0] === "m" && (c = new RegExp(o.mapData.regex).exec(e))) {
      if (t || l.multiple)
        return !1;
      var h = o.mapData;
      if (!(l.color || l.number))
        return !1;
      var d = this.parse(r, c[4]);
      if (!d || d.mapped)
        return !1;
      var p = this.parse(r, c[5]);
      if (!p || p.mapped)
        return !1;
      if (d.pfValue === p.pfValue || d.strValue === p.strValue)
        return Pe("`" + r + ": " + e + "` is not a valid mapper because the output range is zero; converting to `" + r + ": " + d.strValue + "`"), this.parse(r, d.strValue);
      if (l.color) {
        var g = d.value, y = p.value, b = g[0] === y[0] && g[1] === y[1] && g[2] === y[2] && // optional alpha
        (g[3] === y[3] || (g[3] == null || g[3] === 1) && (y[3] == null || y[3] === 1));
        if (b)
          return !1;
      }
      return {
        name: r,
        value: c,
        strValue: "" + e,
        mapped: h,
        field: c[1],
        fieldMin: parseFloat(c[2]),
        // min & max are numeric
        fieldMax: parseFloat(c[3]),
        valueMin: d.value,
        valueMax: p.value,
        bypass: t
      };
    }
  }
  if (l.multiple && a !== "multiple") {
    var m;
    if (u ? m = e.split(/\s+/) : _e(e) ? m = e : m = [e], l.evenMultiple && m.length % 2 !== 0)
      return null;
    for (var E = [], x = [], S = [], w = "", T = !1, C = 0; C < m.length; C++) {
      var D = n.parse(r, m[C], t, "multiple");
      T = T || ce(D.value), E.push(D.value), S.push(D.pfValue != null ? D.pfValue : D.value), x.push(D.units), w += (C > 0 ? " " : "") + D.strValue;
    }
    return l.validate && !l.validate(E, x) ? null : l.singleEnum && T ? E.length === 1 && ce(E[0]) ? {
      name: r,
      value: E[0],
      strValue: E[0],
      bypass: t
    } : null : {
      name: r,
      value: E,
      pfValue: S,
      strValue: w,
      bypass: t,
      units: x
    };
  }
  var A = function() {
    for (var J = 0; J < l.enums.length; J++) {
      var z = l.enums[J];
      if (z === e)
        return {
          name: r,
          value: e,
          strValue: "" + e,
          bypass: t
        };
    }
    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 I = "px|em" + (l.allowPercent ? "|\\%" : "");
        L && (I = L);
        var O = e.match("^(" + tt + ")(" + I + ")?$");
        O && (e = O[1], L = O[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 = s, A();
    if (l.integer && !Rv(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 N = {
      name: r,
      value: e,
      strValue: "" + e + (L || ""),
      units: L,
      bypass: t
    };
    return l.unitless || L !== "px" && L !== "em" ? N.pfValue = e : N.pfValue = L === "px" || !L ? e : this.getEmSizeInPixels() * e, (L === "ms" || L === "s") && (N.pfValue = L === "ms" ? e : 1e3 * e), (L === "deg" || L === "rad") && (N.pfValue = L === "rad" ? e : Bh(e)), L === "%" && (N.pfValue = e / 100), N;
  } else if (l.propList) {
    var k = [], P = "" + e;
    if (P !== "none") {
      for (var B = P.split(/\s*,\s*|\s+/), _ = 0; _ < B.length; _++) {
        var F = B[_].trim();
        n.properties[F] ? k.push(F) : Pe("`" + F + "` is not a valid property name");
      }
      if (k.length === 0)
        return null;
    }
    return {
      name: r,
      value: k,
      strValue: k.length === 0 ? "none" : k.join(" "),
      bypass: t
    };
  } else if (l.color) {
    var G = hf(e);
    return G ? {
      name: r,
      value: G,
      pfValue: G,
      strValue: "rgb(" + G[0] + "," + G[1] + "," + G[2] + ")",
      // n.b. no spaces b/c of multiple support
      bypass: t
    } : null;
  } else if (l.regex || l.regexes) {
    if (l.enums) {
      var U = A();
      if (U)
        return U;
    }
    for (var H = l.regexes ? l.regexes : [l.regex], $ = 0; $ < H.length; $++) {
      var X = new RegExp(H[$]), Q = X.exec(e);
      if (Q)
        return {
          name: r,
          value: l.singleRegexMatchValue ? Q[1] : Q,
          strValue: "" + e,
          bypass: t
        };
    }
    return null;
  } else
    return l.string ? {
      name: r,
      value: "" + e,
      strValue: "" + e,
      bypass: t
    } : l.enums ? A() : null;
};
var st = function(e) {
  if (!(this instanceof st))
    return new st(e);
  if (!ro(e)) {
    qe("A style must have a core reference");
    return;
  }
  this._private = {
    cy: e,
    coreStyle: {}
  }, this.length = 0, this.resetToDefault();
}, pt = st.prototype;
pt.instanceString = function() {
  return "style";
};
pt.clear = function() {
  for (var r = this._private, e = r.cy, t = e.elements(), a = 0; a < this.length; a++)
    this[a] = void 0;
  return this.length = 0, r.contextStyles = {}, r.propDiffs = {}, this.cleanElements(t, !0), t.forEach(function(n) {
    var i = n[0]._private;
    i.styleDirty = !0, i.appliedInitStyle = !1;
  }), this;
};
pt.resetToDefault = function() {
  return this.clear(), this.addDefaultStylesheet(), this;
};
pt.core = function(r) {
  return this._private.coreStyle[r] || this.getDefaultProperty(r);
};
pt.selector = function(r) {
  var e = r === "core" ? null : new lr(r), t = this.length++;
  return this[t] = {
    selector: e,
    properties: [],
    mappedProperties: [],
    index: t
  }, this;
};
pt.css = function() {
  var r = this, e = arguments;
  if (e.length === 1)
    for (var t = e[0], a = 0; a < r.properties.length; a++) {
      var n = r.properties[a], i = t[n.name];
      i === void 0 && (i = t[kn(n.name)]), i !== void 0 && this.cssRule(n.name, i);
    }
  else
    e.length === 2 && this.cssRule(e[0], e[1]);
  return this;
};
pt.style = pt.css;
pt.cssRule = function(r, e) {
  var t = this.parse(r, e);
  if (t) {
    var a = this.length - 1;
    this[a].properties.push(t), this[a].properties[t.name] = t, t.name.match(/pie-(\d+)-background-size/) && t.value && (this._private.hasPie = !0), t.name.match(/stripe-(\d+)-background-size/) && t.value && (this._private.hasStripe = !0), t.mapped && this[a].mappedProperties.push(t);
    var n = !this[a].selector;
    n && (this._private.coreStyle[t.name] = t);
  }
  return this;
};
pt.append = function(r) {
  return ff(r) ? r.appendToStyle(this) : _e(r) ? this.appendFromJson(r) : ce(r) && this.appendFromString(r), this;
};
st.fromJson = function(r, e) {
  var t = new st(r);
  return t.fromJson(e), t;
};
st.fromString = function(r, e) {
  return new st(r).fromString(e);
};
[ot, Va, bo, qt, Wn, wo, Ze, Kn].forEach(function(r) {
  de(pt, r);
});
st.types = pt.types;
st.properties = pt.properties;
st.propertyGroups = pt.propertyGroups;
st.propertyGroupNames = pt.propertyGroupNames;
st.propertyGroupKeys = pt.propertyGroupKeys;
var zp = {
  style: function(e) {
    if (e) {
      var t = this.setStyle(e);
      t.update();
    }
    return this._private.style;
  },
  setStyle: function(e) {
    var t = this._private;
    return ff(e) ? t.style = e.generateStyle(this) : _e(e) ? t.style = st.fromJson(this, e) : ce(e) ? t.style = st.fromString(this, e) : t.style = st(this), t.style;
  },
  // e.g. cy.data() changed => recalc ele mappers
  updateStyle: function() {
    this.mutableElements().updateStyle();
  }
}, Vp = "single", Ir = {
  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 t = this._private;
    if (t.selectionType == null && (t.selectionType = Vp), e !== void 0)
      (e === "additive" || e === "single") && (t.selectionType = e);
    else
      return t.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, t = this._private.pan, a, n, i, s, o;
    switch (e.length) {
      case 0:
        return t;
      case 1:
        if (ce(e[0]))
          return a = e[0], t[a];
        if (Re(e[0])) {
          if (!this._private.panningEnabled)
            return this;
          i = e[0], s = i.x, o = i.y, ae(s) && (t.x = s), ae(o) && (t.y = o), this.emit("pan viewport");
        }
        break;
      case 2:
        if (!this._private.panningEnabled)
          return this;
        a = e[0], n = e[1], (a === "x" || a === "y") && ae(n) && (t[a] = n), this.emit("pan viewport");
        break;
    }
    return this.notify("viewport"), this;
  },
  panBy: function(e, t) {
    var a = arguments, n = this._private.pan, i, s, o, u, l;
    if (!this._private.panningEnabled)
      return this;
    switch (a.length) {
      case 1:
        Re(e) && (o = a[0], u = o.x, l = o.y, ae(u) && (n.x += u), ae(l) && (n.y += l), this.emit("pan viewport"));
        break;
      case 2:
        i = e, s = t, (i === "x" || i === "y") && ae(s) && (n[i] += s), this.emit("pan viewport");
        break;
    }
    return this.notify("viewport"), this;
  },
  gc: function() {
    this.notify("gc");
  },
  fit: function(e, t) {
    var a = this.getFitViewport(e, t);
    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, t) {
    if (ae(e) && t === void 0 && (t = e, e = void 0), !(!this._private.panningEnabled || !this._private.zoomingEnabled)) {
      var a;
      if (ce(e)) {
        var n = e;
        e = this.$(n);
      } else if (Ov(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
        At(e) || (e = this.mutableElements());
      if (!(At(e) && e.empty())) {
        a = a || e.boundingBox();
        var s = this.width(), o = this.height(), u;
        if (t = ae(t) ? t : 0, !isNaN(s) && !isNaN(o) && s > 0 && o > 0 && !isNaN(a.w) && !isNaN(a.h) && a.w > 0 && a.h > 0) {
          u = Math.min((s - 2 * t) / a.w, (o - 2 * t) / 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: (s - u * (a.x1 + a.x2)) / 2,
            y: (o - u * (a.y1 + a.y2)) / 2
          };
          return {
            zoom: u,
            pan: l
          };
        }
      }
    }
  },
  zoomRange: function(e, t) {
    var a = this._private;
    if (t == null) {
      var n = e;
      e = n.min, t = n.max;
    }
    return ae(e) && ae(t) && e <= t ? (a.minZoom = e, a.maxZoom = t) : ae(e) && t === void 0 && e <= a.maxZoom ? a.minZoom = e : ae(t) && e === void 0 && t >= a.minZoom && (a.maxZoom = t), 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 t = this._private, a = t.pan, n = t.zoom, i, s, o = !1;
    if (t.zoomingEnabled || (o = !0), ae(e) ? s = e : Re(e) && (s = e.level, e.position != null ? i = _n(e.position, n, a) : e.renderedPosition != null && (i = e.renderedPosition), i != null && !t.panningEnabled && (o = !0)), s = s > t.maxZoom ? t.maxZoom : s, s = s < t.minZoom ? t.minZoom : s, o || !ae(s) || s === n || i != null && (!ae(i.x) || !ae(i.y)))
      return null;
    if (i != null) {
      var u = a, l = n, f = s, c = {
        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: c
      };
    } else
      return {
        zoomed: !0,
        panned: !1,
        zoom: s,
        pan: a
      };
  },
  zoom: function(e) {
    if (e === void 0)
      return this._private.zoom;
    var t = this.getZoomedViewport(e), a = this._private;
    return t == null || !t.zoomed ? this : (a.zoom = t.zoom, t.panned && (a.pan.x = t.pan.x, a.pan.y = t.pan.y), this.emit("zoom" + (t.panned ? " pan" : "") + " viewport"), this.notify("viewport"), this);
  },
  viewport: function(e) {
    var t = this._private, a = !0, n = !0, i = [], s = !1, o = !1;
    if (!e)
      return this;
    if (ae(e.zoom) || (a = !1), Re(e.pan) || (n = !1), !a && !n)
      return this;
    if (a) {
      var u = e.zoom;
      u < t.minZoom || u > t.maxZoom || !t.zoomingEnabled ? s = !0 : (t.zoom = u, i.push("zoom"));
    }
    if (n && (!s || !e.cancelOnFailedZoom) && t.panningEnabled) {
      var l = e.pan;
      ae(l.x) && (t.pan.x = l.x, o = !1), ae(l.y) && (t.pan.y = l.y, o = !1), o || i.push("pan");
    }
    return i.length > 0 && (i.push("viewport"), this.emit(i.join(" ")), this.notify("viewport")), this;
  },
  center: function(e) {
    var t = this.getCenterPan(e);
    return t && (this._private.pan = t, this.emit("pan viewport"), this.notify("viewport")), this;
  },
  getCenterPan: function(e, t) {
    if (this._private.panningEnabled) {
      if (ce(e)) {
        var a = e;
        e = this.mutableElements().filter(a);
      } else
        At(e) || (e = this.mutableElements());
      if (e.length !== 0) {
        var n = e.boundingBox(), i = this.width(), s = this.height();
        t = t === void 0 ? this._private.zoom : t;
        var o = {
          // middle
          x: (i - t * (n.x1 + n.x2)) / 2,
          y: (s - t * (n.y1 + n.y2)) / 2
        };
        return o;
      }
    }
  },
  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, t = e.container, a = this;
    return e.sizeCache = e.sizeCache || (t ? function() {
      var n = a.window().getComputedStyle(t), i = function(o) {
        return parseFloat(n.getPropertyValue(o));
      };
      return {
        width: t.clientWidth - i("padding-left") - i("padding-right"),
        height: t.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, t = this._private.zoom, a = this.renderedExtent(), n = {
      x1: (a.x1 - e.x) / t,
      x2: (a.x2 - e.x) / t,
      y1: (a.y1 - e.y) / t,
      y2: (a.y2 - e.y) / t
    };
    return n.w = n.x2 - n.x1, n.h = n.y2 - n.y1, n;
  },
  renderedExtent: function() {
    var e = this.width(), t = this.height();
    return {
      x1: 0,
      y1: 0,
      x2: e,
      y2: t,
      w: e,
      h: t
    };
  },
  multiClickDebounceTime: function(e) {
    if (e)
      this._private.multiClickDebounceTime = e;
    else
      return this._private.multiClickDebounceTime;
    return this;
  }
};
Ir.centre = Ir.center;
Ir.autolockNodes = Ir.autolock;
Ir.autoungrabifyNodes = Ir.autoungrabify;
var Ia = {
  data: Oe.data({
    field: "data",
    bindingEvent: "data",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "data",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    updateStyle: !0
  }),
  removeData: Oe.removeData({
    field: "data",
    event: "data",
    triggerFnName: "trigger",
    triggerEvent: !0,
    updateStyle: !0
  }),
  scratch: Oe.data({
    field: "scratch",
    bindingEvent: "scratch",
    allowBinding: !0,
    allowSetting: !0,
    settingEvent: "scratch",
    settingTriggersEvent: !0,
    triggerFnName: "trigger",
    allowGetting: !0,
    updateStyle: !0
  }),
  removeScratch: Oe.removeData({
    field: "scratch",
    event: "scratch",
    triggerFnName: "trigger",
    triggerEvent: !0,
    updateStyle: !0
  })
};
Ia.attr = Ia.data;
Ia.removeAttr = Ia.removeData;
var Ma = function(e) {
  var t = this;
  e = de({}, 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 = t;
  var s = Je !== void 0 && a !== void 0 && !e.headless, o = e;
  o.layout = de({
    name: s ? "grid" : "null"
  }, o.layout), o.renderer = de({
    name: s ? "canvas" : "null"
  }, o.renderer);
  var u = function(d, p, g) {
    return p !== void 0 ? p : g !== void 0 ? g : d;
  }, l = this._private = {
    container: a,
    // html dom ele container
    ready: !1,
    // whether ready has been triggered
    options: o,
    // cached options
    elements: new ct(this),
    // elements in the graph
    listeners: [],
    // list of listeners
    aniEles: new ct(this),
    // elements being animated
    data: o.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, o.zoomingEnabled),
    userZoomingEnabled: u(!0, o.userZoomingEnabled),
    panningEnabled: u(!0, o.panningEnabled),
    userPanningEnabled: u(!0, o.userPanningEnabled),
    boxSelectionEnabled: u(!0, o.boxSelectionEnabled),
    autolock: u(!1, o.autolock, o.autolockNodes),
    autoungrabify: u(!1, o.autoungrabify, o.autoungrabifyNodes),
    autounselectify: u(!1, o.autounselectify),
    styleEnabled: o.styleEnabled === void 0 ? s : o.styleEnabled,
    zoom: ae(o.zoom) ? o.zoom : 1,
    pan: {
      x: Re(o.pan) && ae(o.pan.x) ? o.pan.x : 0,
      y: Re(o.pan) && ae(o.pan.y) ? o.pan.y : 0
    },
    animation: {
      // object for currently-running animations
      current: [],
      queue: []
    },
    hasCompoundNodes: !1,
    multiClickDebounceTime: u(250, o.multiClickDebounceTime)
  };
  this.createEmitter(), this.selectionType(o.selectionType), this.zoomRange({
    min: o.minZoom,
    max: o.maxZoom
  });
  var f = function(d, p) {
    var g = d.some(Pv);
    if (g)
      return aa.all(d).then(p);
    p(d);
  };
  l.styleEnabled && t.setStyle([]);
  var c = de({}, o, o.renderer);
  t.initRenderer(c);
  var v = function(d, p, g) {
    t.notifications(!1);
    var y = t.mutableElements();
    y.length > 0 && y.remove(), d != null && (Re(d) || _e(d)) && t.add(d), t.one("layoutready", function(m) {
      t.notifications(!0), t.emit(m), t.one("load", p), t.emitAndNotify("load");
    }).one("layoutstop", function() {
      t.one("done", g), t.emit("done");
    });
    var b = de({}, t._private.options.layout);
    b.eles = t.elements(), t.layout(b).run();
  };
  f([o.style, o.elements], function(h) {
    var d = h[0], p = h[1];
    l.styleEnabled && t.style().append(d), v(p, function() {
      t.startAnimationLoop(), l.ready = !0, He(o.ready) && t.on("ready", o.ready);
      for (var g = 0; g < i.length; g++) {
        var y = i[g];
        t.on("ready", y);
      }
      n && (n.readies = []), t.emit("ready");
    }, o.done);
  });
}, Rn = Ma.prototype;
de(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 t = this._private.container.ownerDocument;
    return t === void 0 || t == null ? Je : t.defaultView || Je;
  },
  mount: function(e) {
    if (e != null) {
      var t = this, a = t._private, n = a.options;
      return !xn(e) && xn(e[0]) && (e = e[0]), t.stopAnimationLoop(), t.destroyRenderer(), a.container = e, a.styleEnabled = !0, t.invalidateSize(), t.initRenderer(de({}, n, n.renderer, {
        // allow custom renderer name to be re-used, otherwise use canvas
        name: n.renderer.name === "null" ? "canvas" : n.renderer.name
      })), t.startAnimationLoop(), t.style(n.style), t.emit("mount"), t;
    }
  },
  unmount: function() {
    var e = this;
    return e.stopAnimationLoop(), e.destroyRenderer(), e.initRenderer({
      name: "null"
    }), e.emit("unmount"), e;
  },
  options: function() {
    return Ut(this._private.options);
  },
  json: function(e) {
    var t = this, a = t._private, n = t.mutableElements(), i = function(E) {
      return t.getElementById(E.id());
    };
    if (Re(e)) {
      if (t.startBatch(), e.elements) {
        var s = {}, o = function(E, x) {
          for (var S = [], w = [], T = 0; T < E.length; T++) {
            var C = E[T];
            if (!C.data.id) {
              Pe("cy.json() cannot handle elements without an ID attribute");
              continue;
            }
            var D = "" + C.data.id, A = t.getElementById(D);
            s[D] = !0, A.length !== 0 ? w.push({
              ele: A,
              json: C
            }) : (x && (C.group = x), S.push(C));
          }
          t.add(S);
          for (var L = 0; L < w.length; L++) {
            var R = w[L], I = R.ele, O = R.json;
            I.json(O);
          }
        };
        if (_e(e.elements))
          o(e.elements);
        else
          for (var u = ["nodes", "edges"], l = 0; l < u.length; l++) {
            var f = u[l], c = e.elements[f];
            _e(c) && o(c, f);
          }
        var v = t.collection();
        n.filter(function(m) {
          return !s[m.id()];
        }).forEach(function(m) {
          m.isParent() ? v.merge(m) : m.remove();
        }), v.forEach(function(m) {
          return m.children().move({
            parent: null
          });
        }), v.forEach(function(m) {
          return i(m).remove();
        });
      }
      e.style && t.style(e.style), e.zoom != null && e.zoom !== a.zoom && t.zoom(e.zoom), e.pan && (e.pan.x !== a.pan.x || e.pan.y !== a.pan.y) && t.pan(e.pan), e.data && t.data(e.data);
      for (var h = ["minZoom", "maxZoom", "zoomingEnabled", "userZoomingEnabled", "panningEnabled", "userPanningEnabled", "boxSelectionEnabled", "autolock", "autoungrabify", "autounselectify", "multiClickDebounceTime"], d = 0; d < h.length; d++) {
        var p = h[d];
        e[p] != null && t[p](e[p]);
      }
      return t.endBatch(), this;
    } else {
      var g = !!e, y = {};
      g ? 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 = t.style().json()), y.data = Ut(t.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 = Ut(a.pan), y.boxSelectionEnabled = a.boxSelectionEnabled, y.renderer = Ut(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;
[Ip, kp, uc, Vs, dn, Fp, Us, gn, zp, Ir, Ia].forEach(function(r) {
  de(Rn, r);
});
var Up = {
  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)
  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, t) {
    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, t) {
    return t;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts
}, qp = {
  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
}, Gr = function(e) {
  return e.scratch("breadthfirst");
}, Il = function(e, t) {
  return e.scratch("breadthfirst", t);
};
function lc(r) {
  this.options = de({}, Up, qp, r);
}
lc.prototype.run = function() {
  var r = this.options, e = r.cy, t = r.eles, a = t.nodes().filter(function(se) {
    return se.isChildless();
  }), n = t, i = r.directed, s = r.acyclic || r.maximal || r.maximalAdjustments > 0, o = !!r.boundingBox, u = e.extent(), l = St(o ? r.boundingBox : {
    x1: u.x1,
    y1: u.y1,
    w: u.w,
    h: u.h
  }), f;
  if (At(r.roots))
    f = r.roots;
  else if (_e(r.roots)) {
    for (var c = [], v = 0; v < r.roots.length; v++) {
      var h = r.roots[v], d = e.getElementById(h);
      c.push(d);
    }
    f = e.collection(c);
  } else if (ce(r.roots))
    f = e.$(r.roots);
  else if (i)
    f = a.roots();
  else {
    var p = t.components();
    f = e.collection();
    for (var g = function() {
      var oe = p[y], ve = oe.maxDegree(!1), ge = oe.filter(function(he) {
        return he.degree(!1) === ve;
      });
      f = f.add(ge);
    }, y = 0; y < p.length; y++)
      g();
  }
  var b = [], m = {}, E = function(oe, ve) {
    b[ve] == null && (b[ve] = []);
    var ge = b[ve].length;
    b[ve].push(oe), Il(oe, {
      index: ge,
      depth: ve
    });
  }, x = function(oe, ve) {
    var ge = Gr(oe), he = ge.depth, ye = ge.index;
    b[he][ye] = null, oe.isChildless() && E(oe, ve);
  };
  n.bfs({
    roots: f,
    directed: r.directed,
    visit: function(oe, ve, ge, he, ye) {
      var we = oe[0], Se = we.id();
      we.isChildless() && E(we, ye), m[Se] = !0;
    }
  });
  for (var S = [], w = 0; w < a.length; w++) {
    var T = a[w];
    m[T.id()] || S.push(T);
  }
  var C = function(oe) {
    for (var ve = b[oe], ge = 0; ge < ve.length; ge++) {
      var he = ve[ge];
      if (he == null) {
        ve.splice(ge, 1), ge--;
        continue;
      }
      Il(he, {
        depth: oe,
        index: ge
      });
    }
  }, D = function(oe, ve) {
    for (var ge = Gr(oe), he = oe.incomers().filter(function(We) {
      return We.isNode() && t.has(We);
    }), ye = -1, we = oe.id(), Se = 0; Se < he.length; Se++) {
      var Fe = he[Se], Ye = Gr(Fe);
      ye = Math.max(ye, Ye.depth);
    }
    if (ge.depth <= ye) {
      if (!r.acyclic && ve[we])
        return null;
      var Ie = ye + 1;
      return x(oe, Ie), ve[we] = Ie, !0;
    }
    return !1;
  };
  if (i && s) {
    var A = [], L = {}, R = function(oe) {
      return A.push(oe);
    }, I = function() {
      return A.shift();
    };
    for (a.forEach(function(se) {
      return A.push(se);
    }); A.length > 0; ) {
      var O = I(), N = D(O, L);
      if (N)
        O.outgoers().filter(function(se) {
          return se.isNode() && t.has(se);
        }).forEach(R);
      else if (N === null) {
        Pe("Detected double maximal shift for node `" + O.id() + "`.  Bailing maximal adjustment due to cycle.  Use `options.maximal: true` only on DAGs.");
        break;
      }
    }
  }
  var k = 0;
  if (r.avoidOverlap)
    for (var P = 0; P < a.length; P++) {
      var B = a[P], _ = B.layoutDimensions(r), F = _.w, G = _.h;
      k = Math.max(k, F, G);
    }
  var U = {}, H = function(oe) {
    if (U[oe.id()])
      return U[oe.id()];
    for (var ve = Gr(oe).depth, ge = oe.neighborhood(), he = 0, ye = 0, we = 0; we < ge.length; we++) {
      var Se = ge[we];
      if (!(Se.isEdge() || Se.isParent() || !a.has(Se))) {
        var Fe = Gr(Se);
        if (Fe != null) {
          var Ye = Fe.index, Ie = Fe.depth;
          if (!(Ye == null || Ie == null)) {
            var We = b[Ie].length;
            Ie < ve && (he += Ye / We, ye++);
          }
        }
      }
    }
    return ye = Math.max(1, ye), he = he / ye, ye === 0 && (he = 0), U[oe.id()] = he, he;
  }, $ = function(oe, ve) {
    var ge = H(oe), he = H(ve), ye = ge - he;
    return ye === 0 ? vf(oe.id(), ve.id()) : ye;
  };
  r.depthSort !== void 0 && ($ = r.depthSort);
  for (var X = b.length, Q = 0; Q < X; Q++)
    b[Q].sort($), C(Q);
  for (var re = [], J = 0; J < S.length; J++)
    re.push(S[J]);
  var z = function() {
    for (var oe = 0; oe < X; oe++)
      C(oe);
  };
  re.length && (b.unshift(re), X = b.length, z());
  for (var V = 0, Y = 0; Y < X; Y++)
    V = Math.max(b[Y].length, V);
  var ee = {
    x: l.x1 + l.w / 2,
    y: l.y1 + l.h / 2
  }, ne = a.reduce(function(se, oe) {
    return function(ve) {
      return {
        w: se.w === -1 ? ve.w : (se.w + ve.w) / 2,
        h: se.h === -1 ? ve.h : (se.h + ve.h) / 2
      };
    }(oe.boundingBox({
      includeLabels: r.nodeDimensionsIncludeLabels
    }));
  }, {
    w: -1,
    h: -1
  }), be = Math.max(
    // only one depth
    X === 1 ? 0 : (
      // inside a bounding box, no need for top & bottom padding
      o ? (l.h - r.padding * 2 - ne.h) / (X - 1) : (l.h - r.padding * 2 - ne.h) / (X + 1)
    ),
    k
  ), Ve = b.reduce(function(se, oe) {
    return Math.max(se, oe.length);
  }, 0), Ne = function(oe) {
    var ve = Gr(oe), ge = ve.depth, he = ve.index;
    if (r.circle) {
      var ye = Math.min(l.w / 2 / X, l.h / 2 / X);
      ye = Math.max(ye, k);
      var we = ye * ge + ye - (X > 0 && b[0].length <= 3 ? ye / 2 : 0), Se = 2 * Math.PI / b[ge].length * he;
      return ge === 0 && b[0].length === 1 && (we = 1), {
        x: ee.x + we * Math.cos(Se),
        y: ee.y + we * Math.sin(Se)
      };
    } else {
      var Fe = b[ge].length, Ye = Math.max(
        // only one depth
        Fe === 1 ? 0 : (
          // inside a bounding box, no need for left & right padding
          o ? (l.w - r.padding * 2 - ne.w) / ((r.grid ? Ve : Fe) - 1) : (l.w - r.padding * 2 - ne.w) / ((r.grid ? Ve : Fe) + 1)
        ),
        k
      ), Ie = {
        x: ee.x + (he + 1 - (Fe + 1) / 2) * Ye,
        y: ee.y + (ge + 1 - (X + 1) / 2) * be
      };
      return Ie;
    }
  };
  return t.nodes().layoutPositions(this, r, Ne), this;
};
var Hp = {
  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, t) {
    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, t) {
    return t;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts 
};
function fc(r) {
  this.options = de({}, Hp, r);
}
fc.prototype.run = function() {
  var r = this.options, e = r, t = r.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 s = St(e.boundingBox ? e.boundingBox : {
    x1: 0,
    y1: 0,
    w: t.width(),
    h: t.height()
  }), o = {
    x: s.x1 + s.w / 2,
    y: s.y1 + s.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, c = 0, v = 0; v < i.length; v++) {
    var h = i[v], d = h.layoutDimensions(e), p = d.w, g = d.h;
    c = Math.max(c, p, g);
  }
  if (ae(e.radius) ? f = e.radius : i.length <= 1 ? f = 0 : f = Math.min(s.h, s.w) / 2 - c, i.length > 1 && e.avoidOverlap) {
    c *= 1.75;
    var y = Math.cos(l) - Math.cos(0), b = Math.sin(l) - Math.sin(0), m = Math.sqrt(c * c / (y * y + b * b));
    f = Math.max(m, f);
  }
  var E = function(S, w) {
    var T = e.startAngle + w * l * (n ? 1 : -1), C = f * Math.cos(T), D = f * Math.sin(T), A = {
      x: o.x + C,
      y: o.y + D
    };
    return A;
  };
  return a.nodes().layoutPositions(this, e, E), this;
};
var Yp = {
  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, t) {
    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, t) {
    return t;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts
};
function cc(r) {
  this.options = de({}, Yp, r);
}
cc.prototype.run = function() {
  for (var r = this.options, e = r, t = e.counterclockwise !== void 0 ? !e.counterclockwise : e.clockwise, a = r.cy, n = e.eles, i = n.nodes().not(":parent"), s = St(e.boundingBox ? e.boundingBox : {
    x1: 0,
    y1: 0,
    w: a.width(),
    h: a.height()
  }), o = {
    x: s.x1 + s.w / 2,
    y: s.y1 + s.h / 2
  }, u = [], l = 0, f = 0; f < i.length; f++) {
    var c = i[f], v = void 0;
    v = e.concentric(c), u.push({
      value: v,
      node: c
    }), c._private.scratch.concentric = v;
  }
  i.updateStyle();
  for (var h = 0; h < i.length; h++) {
    var d = i[h], p = d.layoutDimensions(e);
    l = Math.max(l, p.w, p.h);
  }
  u.sort(function(ne, be) {
    return be.value - ne.value;
  });
  for (var g = e.levelWidth(i), y = [[]], b = y[0], m = 0; m < u.length; m++) {
    var E = u[m];
    if (b.length > 0) {
      var x = Math.abs(b[0].value - E.value);
      x >= g && (b = [], y.push(b));
    }
    b.push(E);
  }
  var S = l + e.minNodeSpacing;
  if (!e.avoidOverlap) {
    var w = y.length > 0 && y[0].length > 1, T = Math.min(s.w, s.h) / 2 - S, C = T / (y.length + w ? 1 : 0);
    S = Math.min(S, C);
  }
  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, I = L.dTheta = R / Math.max(1, L.length - 1);
    if (L.length > 1 && e.avoidOverlap) {
      var O = Math.cos(I) - Math.cos(0), N = Math.sin(I) - Math.sin(0), k = Math.sqrt(S * S / (O * O + N * N));
      D = Math.max(k, D);
    }
    L.r = D, D += S;
  }
  if (e.equidistant) {
    for (var P = 0, B = 0, _ = 0; _ < y.length; _++) {
      var F = y[_], G = F.r - B;
      P = Math.max(P, G);
    }
    B = 0;
    for (var U = 0; U < y.length; U++) {
      var H = y[U];
      U === 0 && (B = H.r), H.r = B, B += P;
    }
  }
  for (var $ = {}, X = 0; X < y.length; X++)
    for (var Q = y[X], re = Q.dTheta, J = Q.r, z = 0; z < Q.length; z++) {
      var V = Q[z], Y = e.startAngle + (t ? 1 : -1) * re * z, ee = {
        x: o.x + J * Math.cos(Y),
        y: o.y + J * Math.sin(Y)
      };
      $[V.node.id()] = ee;
    }
  return n.nodes().layoutPositions(this, e, function(ne) {
    var be = ne.id();
    return $[be];
  }), this;
};
var ws, Xp = {
  // 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, t) {
    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(r) {
  this.options = de({}, Xp, r), this.options.layout = this;
  var e = this.options.eles.nodes(), t = this.options.eles.edges(), a = t.filter(function(n) {
    var i = n.source().data("id"), s = n.target().data("id"), o = e.some(function(l) {
      return l.data("id") === i;
    }), u = e.some(function(l) {
      return l.data("id") === s;
    });
    return !o || !u;
  });
  this.options.eles = this.options.eles.not(a);
}
Zn.prototype.run = function() {
  var r = this.options, e = r.cy, t = this;
  t.stopped = !1, (r.animate === !0 || r.animate === !1) && t.emit({
    type: "layoutstart",
    layout: t
  }), r.debug === !0 ? ws = !0 : ws = !1;
  var a = $p(e, t, r);
  ws && Kp(a), r.randomize && Zp(a);
  var n = Zt(), i = function() {
    Qp(a, e, r), r.fit === !0 && e.fit(r.padding);
  }, s = function(v) {
    return !(t.stopped || v >= r.numIter || (Jp(a, r), a.temperature = a.temperature * r.coolingFactor, a.temperature < r.minTemp));
  }, o = function() {
    if (r.animate === !0 || r.animate === !1)
      i(), t.one("layoutstop", r.stop), t.emit({
        type: "layoutstop",
        layout: t
      });
    else {
      var v = r.eles.nodes(), h = hc(a, r, v);
      v.layoutPositions(t, r, h);
    }
  }, u = 0, l = !0;
  if (r.animate === !0) {
    var f = function() {
      for (var v = 0; l && v < r.refresh; )
        l = s(u), u++, v++;
      if (!l)
        Ol(a, r), o();
      else {
        var h = Zt();
        h - n >= r.animationThreshold && i(), Tn(f);
      }
    };
    f();
  } else {
    for (; l; )
      l = s(u), u++;
    Ol(a, r), o();
  }
  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 $p = function(e, t, a) {
  for (var n = a.eles.edges(), i = a.eles.nodes(), s = St(a.boundingBox ? a.boundingBox : {
    x1: 0,
    y1: 0,
    w: e.width(),
    h: e.height()
  }), o = {
    isCompound: e.hasCompoundNodes(),
    layoutNodes: [],
    idToIndex: {},
    nodeSize: i.size(),
    graphSet: [],
    indexToGraph: [],
    layoutEdges: [],
    edgeSize: n.size(),
    temperature: a.initialTemp,
    clientWidth: s.w,
    clientHeight: s.h,
    boundingBox: s
  }, u = a.eles.components(), l = {}, f = 0; f < u.length; f++)
    for (var c = u[f], v = 0; v < c.length; v++) {
      var h = c[v];
      l[h.id()] = f;
    }
  for (var f = 0; f < o.nodeSize; f++) {
    var d = i[f], p = d.layoutDimensions(a), g = {};
    g.isLocked = d.locked(), g.id = d.data("id"), g.parentId = d.data("parent"), g.cmptId = l[d.id()], g.children = [], g.positionX = d.position("x"), g.positionY = d.position("y"), g.offsetX = 0, g.offsetY = 0, g.height = p.w, g.width = p.h, g.maxX = g.positionX + g.width / 2, g.minX = g.positionX - g.width / 2, g.maxY = g.positionY + g.height / 2, g.minY = g.positionY - g.height / 2, g.padLeft = parseFloat(d.style("padding")), g.padRight = parseFloat(d.style("padding")), g.padTop = parseFloat(d.style("padding")), g.padBottom = parseFloat(d.style("padding")), g.nodeRepulsion = He(a.nodeRepulsion) ? a.nodeRepulsion(d) : a.nodeRepulsion, o.layoutNodes.push(g), o.idToIndex[g.id] = f;
  }
  for (var y = [], b = 0, m = -1, E = [], f = 0; f < o.nodeSize; f++) {
    var d = o.layoutNodes[f], x = d.parentId;
    x != null ? o.layoutNodes[o.idToIndex[x]].children.push(d.id) : (y[++m] = d.id, E.push(d.id));
  }
  for (o.graphSet.push(E); b <= m; ) {
    var S = y[b++], w = o.idToIndex[S], h = o.layoutNodes[w], T = h.children;
    if (T.length > 0) {
      o.graphSet.push(T);
      for (var f = 0; f < T.length; f++)
        y[++m] = T[f];
    }
  }
  for (var f = 0; f < o.graphSet.length; f++)
    for (var C = o.graphSet[f], v = 0; v < C.length; v++) {
      var D = o.idToIndex[C[v]];
      o.indexToGraph[D] = f;
    }
  for (var f = 0; f < o.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, I = He(a.edgeElasticity) ? a.edgeElasticity(A) : a.edgeElasticity, O = o.idToIndex[L.sourceId], N = o.idToIndex[L.targetId], k = o.indexToGraph[O], P = o.indexToGraph[N];
    if (k != P) {
      for (var B = Wp(L.sourceId, L.targetId, o), _ = o.graphSet[B], F = 0, g = o.layoutNodes[O]; _.indexOf(g.id) === -1; )
        g = o.layoutNodes[o.idToIndex[g.parentId]], F++;
      for (g = o.layoutNodes[N]; _.indexOf(g.id) === -1; )
        g = o.layoutNodes[o.idToIndex[g.parentId]], F++;
      R *= F * a.nestingFactor;
    }
    L.idealLength = R, L.elasticity = I, o.layoutEdges.push(L);
  }
  return o;
}, Wp = function(e, t, a) {
  var n = vc(e, t, 0, a);
  return 2 > n.count ? 0 : n.graph;
}, vc = function(e, t, a, n) {
  var i = n.graphSet[a];
  if (-1 < i.indexOf(e) && -1 < i.indexOf(t))
    return {
      count: 2,
      graph: a
    };
  for (var s = 0, o = 0; o < i.length; o++) {
    var u = i[o], l = n.idToIndex[u], f = n.layoutNodes[l].children;
    if (f.length !== 0) {
      var c = n.indexToGraph[n.idToIndex[f[0]]], v = vc(e, t, c, n);
      if (v.count !== 0)
        if (v.count === 1) {
          if (s++, s === 2)
            break;
        } else
          return v;
    }
  }
  return {
    count: s,
    graph: a
  };
}, Kp, Zp = function(e, t) {
  for (var a = e.clientWidth, n = e.clientHeight, i = 0; i < e.nodeSize; i++) {
    var s = e.layoutNodes[i];
    s.children.length === 0 && !s.isLocked && (s.positionX = Math.random() * a, s.positionY = Math.random() * n);
  }
}, hc = function(e, t, a) {
  var n = e.boundingBox, i = {
    x1: 1 / 0,
    x2: -1 / 0,
    y1: 1 / 0,
    y2: -1 / 0
  };
  return t.boundingBox && (a.forEach(function(s) {
    var o = e.layoutNodes[e.idToIndex[s.data("id")]];
    i.x1 = Math.min(i.x1, o.positionX), i.x2 = Math.max(i.x2, o.positionX), i.y1 = Math.min(i.y1, o.positionY), i.y2 = Math.max(i.y2, o.positionY);
  }), i.w = i.x2 - i.x1, i.h = i.y2 - i.y1), function(s, o) {
    var u = e.layoutNodes[e.idToIndex[s.data("id")]];
    if (t.boundingBox) {
      var l = (u.positionX - i.x1) / i.w, f = (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
      };
  };
}, Qp = function(e, t, a) {
  var n = a.layout, i = a.eles.nodes(), s = hc(e, a, i);
  i.positions(s), e.ready !== !0 && (e.ready = !0, n.one("layoutready", a.ready), n.emit({
    type: "layoutready",
    layout: this
  }));
}, Jp = function(e, t, a) {
  jp(e, t), ry(e), ay(e, t), ny(e), iy(e);
}, jp = function(e, t) {
  for (var a = 0; a < e.graphSet.length; a++)
    for (var n = e.graphSet[a], i = n.length, s = 0; s < i; s++)
      for (var o = e.layoutNodes[e.idToIndex[n[s]]], u = s + 1; u < i; u++) {
        var l = e.layoutNodes[e.idToIndex[n[u]]];
        ey(o, l, e, t);
      }
}, Ml = function(e) {
  return -1 + 2 * e * Math.random();
}, ey = function(e, t, a, n) {
  var i = e.cmptId, s = t.cmptId;
  if (!(i !== s && !a.isCompound)) {
    var o = t.positionX - e.positionX, u = t.positionY - e.positionY, l = 1;
    o === 0 && u === 0 && (o = Ml(l), u = Ml(l));
    var f = ty(e, t, o, u);
    if (f > 0)
      var c = n.nodeOverlap * f, v = Math.sqrt(o * o + u * u), h = c * o / v, d = c * u / v;
    else
      var p = In(e, o, u), g = In(t, -1 * o, -1 * u), y = g.x - p.x, b = g.y - p.y, m = y * y + b * b, v = Math.sqrt(m), c = (e.nodeRepulsion + t.nodeRepulsion) / m, h = c * y / v, d = c * b / v;
    e.isLocked || (e.offsetX -= h, e.offsetY -= d), t.isLocked || (t.offsetX += h, t.offsetY += d);
  }
}, ty = function(e, t, a, n) {
  if (a > 0)
    var i = e.maxX - t.minX;
  else
    var i = t.maxX - e.minX;
  if (n > 0)
    var s = e.maxY - t.minY;
  else
    var s = t.maxY - e.minY;
  return i >= 0 && s >= 0 ? Math.sqrt(i * i + s * s) : 0;
}, In = function(e, t, a) {
  var n = e.positionX, i = e.positionY, s = e.height || 1, o = e.width || 1, u = a / t, l = s / o, f = {};
  return t === 0 && 0 < a || t === 0 && 0 > a ? (f.x = n, f.y = i + s / 2, f) : 0 < t && -1 * l <= u && u <= l ? (f.x = n + o / 2, f.y = i + o * a / 2 / t, f) : 0 > t && -1 * l <= u && u <= l ? (f.x = n - o / 2, f.y = i - o * a / 2 / t, f) : 0 < a && (u <= -1 * l || u >= l) ? (f.x = n + s * t / 2 / a, f.y = i + s / 2, f) : (0 > a && (u <= -1 * l || u >= l) && (f.x = n - s * t / 2 / a, f.y = i - s / 2), f);
}, ry = function(e, t) {
  for (var a = 0; a < e.edgeSize; a++) {
    var n = e.layoutEdges[a], i = e.idToIndex[n.sourceId], s = e.layoutNodes[i], o = e.idToIndex[n.targetId], u = e.layoutNodes[o], l = u.positionX - s.positionX, f = u.positionY - s.positionY;
    if (!(l === 0 && f === 0)) {
      var c = In(s, l, f), v = In(u, -1 * l, -1 * f), h = v.x - c.x, d = v.y - c.y, p = Math.sqrt(h * h + d * d), g = Math.pow(n.idealLength - p, 2) / n.elasticity;
      if (p !== 0)
        var y = g * h / p, b = g * d / p;
      else
        var y = 0, b = 0;
      s.isLocked || (s.offsetX += y, s.offsetY += b), u.isLocked || (u.offsetX -= y, u.offsetY -= b);
    }
  }
}, ay = function(e, t) {
  if (t.gravity !== 0)
    for (var a = 1, n = 0; n < e.graphSet.length; n++) {
      var i = e.graphSet[n], s = i.length;
      if (n === 0)
        var o = e.clientHeight / 2, u = e.clientWidth / 2;
      else
        var l = e.layoutNodes[e.idToIndex[i[0]]], f = e.layoutNodes[e.idToIndex[l.parentId]], o = f.positionX, u = f.positionY;
      for (var c = 0; c < s; c++) {
        var v = e.layoutNodes[e.idToIndex[i[c]]];
        if (!v.isLocked) {
          var h = o - v.positionX, d = u - v.positionY, p = Math.sqrt(h * h + d * d);
          if (p > a) {
            var g = t.gravity * h / p, y = t.gravity * d / p;
            v.offsetX += g, v.offsetY += y;
          }
        }
      }
    }
}, ny = function(e, t) {
  var a = [], n = 0, i = -1;
  for (a.push.apply(a, e.graphSet[0]), i += e.graphSet[0].length; n <= i; ) {
    var s = a[n++], o = e.idToIndex[s], u = e.layoutNodes[o], l = u.children;
    if (0 < l.length && !u.isLocked) {
      for (var f = u.offsetX, c = u.offsetY, v = 0; v < l.length; v++) {
        var h = e.layoutNodes[e.idToIndex[l[v]]];
        h.offsetX += f, h.offsetY += c, a[++i] = l[v];
      }
      u.offsetX = 0, u.offsetY = 0;
    }
  }
}, iy = function(e, t) {
  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 = sy(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, dc(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);
  }
}, sy = function(e, t, a) {
  var n = Math.sqrt(e * e + t * t);
  if (n > a)
    var i = {
      x: a * e / n,
      y: a * t / n
    };
  else
    var i = {
      x: e,
      y: t
    };
  return i;
}, dc = function(e, t) {
  var a = e.parentId;
  if (a != null) {
    var n = t.layoutNodes[t.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 dc(n, t);
  }
}, Ol = function(e, t) {
  for (var a = e.layoutNodes, n = [], i = 0; i < a.length; i++) {
    var s = a[i], o = s.cmptId, u = n[o] = n[o] || [];
    u.push(s);
  }
  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 c = 0; c < f.length; c++) {
        var v = f[c];
        f.x1 = Math.min(f.x1, v.positionX - v.width / 2), f.x2 = Math.max(f.x2, v.positionX + v.width / 2), f.y1 = Math.min(f.y1, v.positionY - v.height / 2), f.y2 = Math.max(f.y2, v.positionY + v.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, p = 0, g = 0, y = Math.sqrt(l) * e.clientWidth / e.clientHeight, i = 0; i < n.length; i++) {
    var f = n[i];
    if (f) {
      for (var c = 0; c < f.length; c++) {
        var v = f[c];
        v.isLocked || (v.positionX += h - f.x1, v.positionY += d - f.y1);
      }
      h += f.w + t.componentSpacing, p += f.w + t.componentSpacing, g = Math.max(g, f.h), p > y && (d += g + t.componentSpacing, h = 0, p = 0, g = 0);
    }
  }
}, oy = {
  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, t) {
    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, t) {
    return t;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts 
};
function gc(r) {
  this.options = de({}, oy, r);
}
gc.prototype.run = function() {
  var r = this.options, e = r, t = r.cy, a = e.eles, n = a.nodes().not(":parent");
  e.sort && (n = n.sort(e.sort));
  var i = St(e.boundingBox ? e.boundingBox : {
    x1: 0,
    y1: 0,
    w: t.width(),
    h: t.height()
  });
  if (i.h === 0 || i.w === 0)
    a.nodes().layoutPositions(this, e, function(U) {
      return {
        x: i.x1,
        y: i.y1
      };
    });
  else {
    var s = n.size(), o = Math.sqrt(s * i.h / i.w), u = Math.round(o), l = Math.round(i.w / i.h * o), f = function(H) {
      if (H == null)
        return Math.min(u, l);
      var $ = Math.min(u, l);
      $ == u ? u = H : l = H;
    }, c = function(H) {
      if (H == null)
        return Math.max(u, l);
      var $ = Math.max(u, l);
      $ == u ? u = H : l = H;
    }, v = e.rows, h = e.cols != null ? e.cols : e.columns;
    if (v != null && h != null)
      u = v, l = h;
    else if (v != null && h == null)
      u = v, l = Math.ceil(s / u);
    else if (v == null && h != null)
      l = h, u = Math.ceil(s / l);
    else if (l * u > s) {
      var d = f(), p = c();
      (d - 1) * p >= s ? f(d - 1) : (p - 1) * d >= s && c(p - 1);
    } else
      for (; l * u < s; ) {
        var g = f(), y = c();
        (y + 1) * g >= s ? c(y + 1) : f(g + 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 x = n[E], S = x._private.position;
        (S.x == null || S.y == null) && (S.x = 0, S.y = 0);
        var w = x.layoutDimensions(e), T = e.avoidOverlapPadding, C = w.w + T, D = w.h + T;
        b = Math.max(b, C), m = Math.max(m, D);
      }
    for (var A = {}, L = function(H, $) {
      return !!A["c-" + H + "-" + $];
    }, R = function(H, $) {
      A["c-" + H + "-" + $] = !0;
    }, I = 0, O = 0, N = function() {
      O++, O >= l && (O = 0, I++);
    }, k = {}, P = 0; P < n.length; P++) {
      var B = n[P], _ = e.position(B);
      if (_ && (_.row !== void 0 || _.col !== void 0)) {
        var F = {
          row: _.row,
          col: _.col
        };
        if (F.col === void 0)
          for (F.col = 0; L(F.row, F.col); )
            F.col++;
        else if (F.row === void 0)
          for (F.row = 0; L(F.row, F.col); )
            F.row++;
        k[B.id()] = F, R(F.row, F.col);
      }
    }
    var G = function(H, $) {
      var X, Q;
      if (H.locked() || H.isParent())
        return !1;
      var re = k[H.id()];
      if (re)
        X = re.col * b + b / 2 + i.x1, Q = re.row * m + m / 2 + i.y1;
      else {
        for (; L(I, O); )
          N();
        X = O * b + b / 2 + i.x1, Q = I * m + m / 2 + i.y1, R(I, O), N();
      }
      return {
        x: X,
        y: Q
      };
    };
    n.layoutPositions(this, e, G);
  }
  return this;
};
var uy = {
  ready: function() {
  },
  // on layoutready
  stop: function() {
  }
  // on layoutstop
};
function Eo(r) {
  this.options = de({}, uy, r);
}
Eo.prototype.run = function() {
  var r = this.options, e = r.eles, t = this;
  return r.cy, t.emit("layoutstart"), e.nodes().positions(function() {
    return {
      x: 0,
      y: 0
    };
  }), t.one("layoutready", r.ready), t.emit("layoutready"), t.one("layoutstop", r.stop), t.emit("layoutstop"), this;
};
Eo.prototype.stop = function() {
  return this;
};
var ly = {
  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, t) {
    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, t) {
    return t;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts
};
function pc(r) {
  this.options = de({}, ly, r);
}
pc.prototype.run = function() {
  var r = this.options, e = r.eles, t = e.nodes(), a = He(r.positions);
  function n(i) {
    if (r.positions == null)
      return Mh(i.position());
    if (a)
      return r.positions(i);
    var s = r.positions[i._private.data.id];
    return s ?? null;
  }
  return t.layoutPositions(this, r, function(i, s) {
    var o = n(i);
    return i.locked() || o == null ? !1 : o;
  }), this;
};
var fy = {
  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, t) {
    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, t) {
    return t;
  }
  // transform a given node position. Useful for changing flow direction in discrete layouts 
};
function yc(r) {
  this.options = de({}, fy, r);
}
yc.prototype.run = function() {
  var r = this.options, e = r.cy, t = r.eles, a = St(r.boundingBox ? r.boundingBox : {
    x1: 0,
    y1: 0,
    w: e.width(),
    h: e.height()
  }), n = function(s, o) {
    return {
      x: a.x1 + Math.round(Math.random() * a.w),
      y: a.y1 + Math.round(Math.random() * a.h)
    };
  };
  return t.nodes().layoutPositions(this, r, n), this;
};
var cy = [{
  name: "breadthfirst",
  impl: lc
}, {
  name: "circle",
  impl: fc
}, {
  name: "concentric",
  impl: cc
}, {
  name: "cose",
  impl: Zn
}, {
  name: "grid",
  impl: gc
}, {
  name: "null",
  impl: Eo
}, {
  name: "preset",
  impl: pc
}, {
  name: "random",
  impl: yc
}];
function mc(r) {
  this.options = r, this.notifications = 0;
}
var Pl = function() {
}, Nl = function() {
  throw new Error("A headless instance can not render images");
};
mc.prototype = {
  recalculateRenderedStyle: Pl,
  notify: function() {
    this.notifications++;
  },
  init: Pl,
  isHeadless: function() {
    return !0;
  },
  png: Nl,
  jpg: Nl
};
var xo = {};
xo.arrowShapeWidth = 0.3;
xo.registerArrowShapes = function() {
  var r = this.arrowShapes = {}, e = this, t = function(l, f, c, v, h, d, p) {
    var g = h.x - c / 2 - p, y = h.x + c / 2 + p, b = h.y - c / 2 - p, m = h.y + c / 2 + p, E = g <= l && l <= y && b <= f && f <= m;
    return E;
  }, a = function(l, f, c, v, h) {
    var d = l * Math.cos(v) - f * Math.sin(v), p = l * Math.sin(v) + f * Math.cos(v), g = d * c, y = p * c, b = g + h.x, m = y + h.y;
    return {
      x: b,
      y: m
    };
  }, n = function(l, f, c, v) {
    for (var h = [], d = 0; d < l.length; d += 2) {
      var p = l[d], g = l[d + 1];
      h.push(a(p, g, f, c, v));
    }
    return h;
  }, i = function(l) {
    for (var f = [], c = 0; c < l.length; c++) {
      var v = l[c];
      f.push(v.x, v.y);
    }
    return f;
  }, s = function(l) {
    return l.pstyle("width").pfValue * l.pstyle("arrow-scale").pfValue * 2;
  }, o = function(l, f) {
    ce(f) && (f = r[f]), r[l] = de({
      name: l,
      points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3],
      collide: function(v, h, d, p, g, y) {
        var b = i(n(this.points, d + 2 * y, p, g)), m = Ct(v, h, b);
        return m;
      },
      roughCollide: t,
      draw: function(v, h, d, p) {
        var g = n(this.points, h, d, p);
        e.arrowShapeImpl("polygon")(v, g);
      },
      spacing: function(v) {
        return 0;
      },
      gap: s
    }, f);
  };
  o("none", {
    collide: Cn,
    roughCollide: Cn,
    draw: so,
    spacing: Zo,
    gap: Zo
  }), o("triangle", {
    points: [-0.15, -0.3, 0, 0, 0.15, -0.3]
  }), o("arrow", "triangle"), o("triangle-backcurve", {
    points: r.triangle.points,
    controlPoint: [0, -0.15],
    roughCollide: t,
    draw: function(l, f, c, v, h) {
      var d = n(this.points, f, c, v), p = this.controlPoint, g = a(p[0], p[1], f, c, v);
      e.arrowShapeImpl(this.name)(l, d, g);
    },
    gap: function(l) {
      return s(l) * 0.8;
    }
  }), o("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, c, v, h, d, p) {
      var g = i(n(this.points, c + 2 * p, v, h)), y = i(n(this.pointsTee, c + 2 * p, v, h)), b = Ct(l, f, g) || Ct(l, f, y);
      return b;
    },
    draw: function(l, f, c, v, h) {
      var d = n(this.points, f, c, v), p = n(this.pointsTee, f, c, v);
      e.arrowShapeImpl(this.name)(l, d, p);
    }
  }), o("circle-triangle", {
    radius: 0.15,
    pointsTr: [0, -0.15, 0.15, -0.45, -0.15, -0.45, 0, -0.15],
    collide: function(l, f, c, v, h, d, p) {
      var g = h, y = Math.pow(g.x - l, 2) + Math.pow(g.y - f, 2) <= Math.pow((c + 2 * p) * this.radius, 2), b = i(n(this.points, c + 2 * p, v, h));
      return Ct(l, f, b) || y;
    },
    draw: function(l, f, c, v, h) {
      var d = n(this.pointsTr, f, c, v);
      e.arrowShapeImpl(this.name)(l, d, v.x, v.y, this.radius * f);
    },
    spacing: function(l) {
      return e.getArrowWidth(l.pstyle("width").pfValue, l.pstyle("arrow-scale").value) * this.radius;
    }
  }), o("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 c = this.baseCrossLinePts.slice(), v = f / l, h = 3, d = 5;
      return c[h] = c[h] - v, c[d] = c[d] - v, c;
    },
    collide: function(l, f, c, v, h, d, p) {
      var g = i(n(this.points, c + 2 * p, v, h)), y = i(n(this.crossLinePts(c, d), c + 2 * p, v, h)), b = Ct(l, f, g) || Ct(l, f, y);
      return b;
    },
    draw: function(l, f, c, v, h) {
      var d = n(this.points, f, c, v), p = n(this.crossLinePts(f, h), f, c, v);
      e.arrowShapeImpl(this.name)(l, d, p);
    }
  }), o("vee", {
    points: [-0.15, -0.3, 0, 0, 0.15, -0.3, 0, -0.15],
    gap: function(l) {
      return s(l) * 0.525;
    }
  }), o("circle", {
    radius: 0.15,
    collide: function(l, f, c, v, h, d, p) {
      var g = h, y = Math.pow(g.x - l, 2) + Math.pow(g.y - f, 2) <= Math.pow((c + 2 * p) * this.radius, 2);
      return y;
    },
    draw: function(l, f, c, v, h) {
      e.arrowShapeImpl(this.name)(l, v.x, v.y, this.radius * f);
    },
    spacing: function(l) {
      return e.getArrowWidth(l.pstyle("width").pfValue, l.pstyle("arrow-scale").value) * this.radius;
    }
  }), o("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;
    }
  }), o("square", {
    points: [-0.15, 0, 0.15, 0, 0.15, -0.3, -0.15, -0.3]
  }), o("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;
    }
  }), o("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(r, e) {
  var t = this.cy, a = this.findContainerClientCoords(), n = a[0], i = a[1], s = a[4], o = t.pan(), u = t.zoom(), l = ((r - n) / s - o.x) / u, f = ((e - i) / s - o.y) / u;
  return [l, f];
};
Pr.findContainerClientCoords = function() {
  if (this.containerBB)
    return this.containerBB;
  var r = this.container, e = r.getBoundingClientRect(), t = this.cy.window().getComputedStyle(r), a = function(y) {
    return parseFloat(t.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")
  }, s = r.clientWidth, o = r.clientHeight, u = n.left + n.right, l = n.top + n.bottom, f = i.left + i.right, c = e.width / (s + f), v = s - u, h = o - l, d = e.left + n.left + i.left, p = e.top + n.top + i.top;
  return this.containerBB = [d, p, v, h, c];
};
Pr.invalidateContainerClientCoordsCache = function() {
  this.containerBB = null;
};
Pr.findNearestElement = function(r, e, t, a) {
  return this.findNearestElements(r, e, t, a)[0];
};
Pr.findNearestElements = function(r, e, t, a) {
  var n = this, i = this, s = i.getCachedZSortedEles(), o = [], u = i.cy.zoom(), l = i.cy.hasCompoundNodes(), f = (a ? 24 : 8) / u, c = (a ? 8 : 2) / u, v = (a ? 8 : 2) / u, h = 1 / 0, d, p;
  t && (s = s.interactive);
  function g(w, T) {
    if (w.isNode()) {
      if (p)
        return;
      p = w, o.push(w);
    }
    if (w.isEdge() && (T == null || T < 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 C = 0; C < o.length; C++)
            if (o[C].isEdge()) {
              o[C] = w, d = w, h = T ?? h;
              break;
            }
        }
      } else
        o.push(w), d = w, h = T ?? h;
  }
  function y(w) {
    var T = w.outerWidth() + 2 * c, C = w.outerHeight() + 2 * c, D = T / 2, A = C / 2, L = w.position(), R = w.pstyle("corner-radius").value === "auto" ? "auto" : w.pstyle("corner-radius").pfValue, I = w._private.rscratch;
    if (L.x - D <= r && r <= L.x + D && L.y - A <= e && e <= L.y + A) {
      var O = i.nodeShapes[n.getNodeShape(w)];
      if (O.checkPoint(r, e, 0, T, C, L.x, L.y, R, I))
        return g(w, 0), !0;
    }
  }
  function b(w) {
    var T = w._private, C = T.rscratch, D = w.pstyle("width").pfValue, A = w.pstyle("arrow-scale").value, L = D / 2 + f, R = L * L, I = L * 2, P = T.source, B = T.target, O;
    if (C.edgeType === "segments" || C.edgeType === "straight" || C.edgeType === "haystack") {
      for (var N = C.allpts, k = 0; k + 3 < N.length; k += 2)
        if (Yh(r, e, N[k], N[k + 1], N[k + 2], N[k + 3], I) && R > (O = Zh(r, e, N[k], N[k + 1], N[k + 2], N[k + 3])))
          return g(w, O), !0;
    } else if (C.edgeType === "bezier" || C.edgeType === "multibezier" || C.edgeType === "self" || C.edgeType === "compound") {
      for (var N = C.allpts, k = 0; k + 5 < C.allpts.length; k += 4)
        if (Xh(r, e, N[k], N[k + 1], N[k + 2], N[k + 3], N[k + 4], N[k + 5], I) && R > (O = Kh(r, e, N[k], N[k + 1], N[k + 2], N[k + 3], N[k + 4], N[k + 5])))
          return g(w, O), !0;
    }
    for (var P = P || T.source, B = B || T.target, _ = n.getArrowWidth(D, A), F = [{
      name: "source",
      x: C.arrowStartX,
      y: C.arrowStartY,
      angle: C.srcArrowAngle
    }, {
      name: "target",
      x: C.arrowEndX,
      y: C.arrowEndY,
      angle: C.tgtArrowAngle
    }, {
      name: "mid-source",
      x: C.midX,
      y: C.midY,
      angle: C.midsrcArrowAngle
    }, {
      name: "mid-target",
      x: C.midX,
      y: C.midY,
      angle: C.midtgtArrowAngle
    }], k = 0; k < F.length; k++) {
      var G = F[k], U = i.arrowShapes[w.pstyle(G.name + "-arrow-shape").value], H = w.pstyle("width").pfValue;
      if (U.roughCollide(r, e, _, G.angle, {
        x: G.x,
        y: G.y
      }, H, f) && U.collide(r, e, _, G.angle, {
        x: G.x,
        y: G.y
      }, H, f))
        return g(w), !0;
    }
    l && o.length > 0 && (y(P), y(B));
  }
  function m(w, T, C) {
    return Tt(w, T, C);
  }
  function E(w, T) {
    var C = w._private, D = v, A;
    T ? A = T + "-" : A = "", w.boundingBox();
    var L = C.labelBounds[T || "main"], R = w.pstyle(A + "label").value, I = w.pstyle("text-events").strValue === "yes";
    if (!(!I || !R)) {
      var O = m(C.rscratch, "labelX", T), N = m(C.rscratch, "labelY", T), k = m(C.rscratch, "labelAngle", T), P = w.pstyle(A + "text-margin-x").pfValue, B = w.pstyle(A + "text-margin-y").pfValue, _ = L.x1 - D - P, F = L.x2 + D - P, G = L.y1 - D - B, U = L.y2 + D - B;
      if (k) {
        var H = Math.cos(k), $ = Math.sin(k), X = function(ee, ne) {
          return ee = ee - O, ne = ne - N, {
            x: ee * H - ne * $ + O,
            y: ee * $ + ne * H + N
          };
        }, Q = X(_, G), re = X(_, U), J = X(F, G), z = X(F, U), V = [
          // with the margin added after the rotation is applied
          Q.x + P,
          Q.y + B,
          J.x + P,
          J.y + B,
          z.x + P,
          z.y + B,
          re.x + P,
          re.y + B
        ];
        if (Ct(r, e, V))
          return g(w), !0;
      } else if (jr(L, r, e))
        return g(w), !0;
    }
  }
  for (var x = s.length - 1; x >= 0; x--) {
    var S = s[x];
    S.isNode() ? y(S) || E(S) : b(S) || E(S) || E(S, "source") || E(S, "target");
  }
  return o;
};
Pr.getAllInBox = function(r, e, t, a) {
  var n = this.getCachedZSortedEles().interactive, i = this.cy.zoom(), s = 2 / i, o = [], u = Math.min(r, t), l = Math.max(r, t), f = Math.min(e, a), c = Math.max(e, a);
  r = u, t = l, e = f, a = c;
  var v = St({
    x1: r,
    y1: e,
    x2: t,
    y2: a
  });
  function h(R, I, O) {
    return Tt(R, I, O);
  }
  function d(R, I) {
    var O = R._private, N = s, k = "";
    R.boundingBox();
    var P = O.labelBounds.main, B = h(O.rscratch, "labelX", I), _ = h(O.rscratch, "labelY", I), F = h(O.rscratch, "labelAngle", I), G = R.pstyle(k + "text-margin-x").pfValue, U = R.pstyle(k + "text-margin-y").pfValue, H = P.x1 - N - G, $ = P.x2 + N - G, X = P.y1 - N - U, Q = P.y2 + N - U;
    if (F) {
      var re = Math.cos(F), J = Math.sin(F), z = function(Y, ee) {
        return Y = Y - B, ee = ee - _, {
          x: Y * re - ee * J + B,
          y: Y * J + ee * re + _
        };
      };
      return [z(H, X), z($, X), z($, Q), z(H, Q)];
    } else
      return [{
        x: H,
        y: X
      }, {
        x: $,
        y: X
      }, {
        x: $,
        y: Q
      }, {
        x: H,
        y: Q
      }];
  }
  for (var p = 0; p < n.length; p++) {
    var g = n[p];
    if (g.isNode()) {
      var y = g, b = y.pstyle("text-events").strValue === "yes", m = y.pstyle("box-select-labels").strValue === "yes", E = y.boundingBox({
        includeNodes: !0,
        includeEdges: !1,
        includeLabels: m && b
      });
      if (fo(v, E)) {
        var x = d(y), S = [{
          x: v.x1,
          y: v.y1
        }, {
          x: v.x2,
          y: v.y1
        }, {
          x: v.x2,
          y: v.y2
        }, {
          x: v.x1,
          y: v.y2
        }];
        td(x, S) && o.push(y);
      }
    } else {
      var w = g, T = w._private, C = T.rscratch;
      if (C.startX != null && C.startY != null && !jr(v, C.startX, C.startY) || C.endX != null && C.endY != null && !jr(v, C.endX, C.endY))
        continue;
      if (C.edgeType === "bezier" || C.edgeType === "multibezier" || C.edgeType === "self" || C.edgeType === "compound" || C.edgeType === "segments" || C.edgeType === "haystack") {
        for (var D = T.rstyle.bezierPts || T.rstyle.linePts || T.rstyle.haystackPts, A = !0, L = 0; L < D.length; L++)
          if (!qh(v, D[L])) {
            A = !1;
            break;
          }
        A && o.push(w);
      } else
        (C.edgeType === "haystack" || C.edgeType === "straight") && o.push(w);
    }
  }
  return o;
};
var Mn = {};
Mn.calculateArrowAngles = function(r) {
  var e = r._private.rscratch, t = e.edgeType === "haystack", a = e.edgeType === "bezier", n = e.edgeType === "multibezier", i = e.edgeType === "segments", s = e.edgeType === "compound", o = e.edgeType === "self", u, l, f, c, v, h, y, b;
  if (t ? (f = e.haystackPts[0], c = e.haystackPts[1], v = e.haystackPts[2], h = e.haystackPts[3]) : (f = e.arrowStartX, c = e.arrowStartY, v = e.arrowEndX, h = e.arrowEndY), y = e.midX, b = e.midY, i)
    u = f - e.segpts[0], l = c - e.segpts[1];
  else if (n || s || o || a) {
    var d = e.allpts, p = it(d[0], d[2], d[4], 0.1), g = it(d[1], d[3], d[5], 0.1);
    u = f - p, l = c - g;
  } else
    u = f - y, l = c - b;
  e.srcArrowAngle = Za(u, l);
  var y = e.midX, b = e.midY;
  if (t && (y = (f + v) / 2, b = (c + h) / 2), u = v - f, l = h - c, 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 || s || o) {
    var d = e.allpts, x = e.ctrlpts, S, w, T, C;
    if (x.length / 2 % 2 === 0) {
      var D = d.length / 2 - 1, A = D + 2, L = A + 2;
      S = it(d[D], d[A], d[L], 0), w = it(d[D + 1], d[A + 1], d[L + 1], 0), T = it(d[D], d[A], d[L], 1e-4), C = it(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 = it(d[D], d[A], d[L], 0.4999), w = it(d[D + 1], d[A + 1], d[L + 1], 0.4999), T = it(d[D], d[A], d[L], 0.5), C = it(d[D + 1], d[A + 1], d[L + 1], 0.5);
    }
    u = T - S, l = C - w;
  }
  if (e.midtgtArrowAngle = Za(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 = Za(u, l), i)
    u = v - e.segpts[e.segpts.length - 2], l = h - e.segpts[e.segpts.length - 1];
  else if (n || s || o || a) {
    var d = e.allpts, I = d.length, p = it(d[I - 6], d[I - 4], d[I - 2], 0.9), g = it(d[I - 5], d[I - 3], d[I - 1], 0.9);
    u = v - p, l = h - g;
  } else
    u = v - y, l = h - b;
  e.tgtArrowAngle = Za(u, l);
};
Mn.getArrowWidth = Mn.getArrowHeight = function(r, e) {
  var t = this.arrowWidthCache = this.arrowWidthCache || {}, a = t[r + ", " + e];
  return a || (a = Math.max(Math.pow(r * 13.37, 0.9), 29) * e, t[r + ", " + e] = a, a);
};
var qs, Hs, Vt = {}, Lt = {}, kl, Bl, Dr, pn, $t, br, Tr, Gt, zr, nn, bc, wc, Ys, Xs, Fl, _l = function(e, t, a) {
  a.x = t.x - e.x, a.y = t.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);
}, vy = function(e, t) {
  t.x = e.x * -1, t.y = e.y * -1, t.nx = e.nx * -1, t.ny = e.ny * -1, t.ang = e.ang > 0 ? -(Math.PI - e.ang) : Math.PI + e.ang;
}, hy = function(e, t, a, n, i) {
  if (e !== Fl ? _l(t, e, Vt) : vy(Lt, Vt), _l(t, a, Lt), kl = Vt.nx * Lt.ny - Vt.ny * Lt.nx, Bl = Vt.nx * Lt.nx - Vt.ny * -Lt.ny, $t = Math.asin(Math.max(-1, Math.min(1, kl))), Math.abs($t) < 1e-6) {
    qs = t.x, Hs = t.y, Tr = zr = 0;
    return;
  }
  Dr = 1, pn = !1, Bl < 0 ? $t < 0 ? $t = Math.PI + $t : ($t = Math.PI - $t, Dr = -1, pn = !0) : $t > 0 && (Dr = -1, pn = !0), t.radius !== void 0 ? zr = t.radius : zr = n, br = $t / 2, nn = Math.min(Vt.len / 2, Lt.len / 2), i ? (Gt = Math.abs(Math.cos(br) * zr / Math.sin(br)), Gt > nn ? (Gt = nn, Tr = Math.abs(Gt * Math.sin(br) / Math.cos(br))) : Tr = zr) : (Gt = Math.min(nn, zr), Tr = Math.abs(Gt * Math.sin(br) / Math.cos(br))), Ys = t.x + Lt.nx * Gt, Xs = t.y + Lt.ny * Gt, qs = Ys - Lt.ny * Tr * Dr, Hs = Xs + Lt.nx * Tr * Dr, bc = t.x + Vt.nx * Gt, wc = t.y + Vt.ny * Gt, Fl = t;
};
function Ec(r, e) {
  e.radius === 0 ? r.lineTo(e.cx, e.cy) : r.arc(e.cx, e.cy, e.radius, e.startAngle, e.endAngle, e.counterClockwise);
}
function To(r, e, t, 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
  } : (hy(r, e, t, a, n), {
    cx: qs,
    cy: Hs,
    radius: Tr,
    startX: bc,
    startY: wc,
    stopX: Ys,
    stopY: Xs,
    startAngle: Vt.ang + Math.PI / 2 * Dr,
    endAngle: Lt.ang - Math.PI / 2 * Dr,
    counterClockwise: pn
  });
}
var Oa = 0.01, dy = Math.sqrt(2 * Oa), yt = {};
yt.findMidptPtsEtc = function(r, e) {
  var t = e.posPts, a = e.intersectionPts, n = e.vectorNormInverse, i, s = r.pstyle("source-endpoint"), o = r.pstyle("target-endpoint"), u = s.units != null && o.units != null, l = function(x, S, w, T) {
    var C = T - S, D = w - x, A = Math.sqrt(D * D + C * C);
    return {
      x: -C / A,
      y: D / A
    };
  }, f = r.pstyle("edge-distances").value;
  switch (f) {
    case "node-position":
      i = t;
      break;
    case "intersection":
      i = a;
      break;
    case "endpoints": {
      if (u) {
        var c = this.manualEndptToPx(r.source()[0], s), v = je(c, 2), h = v[0], d = v[1], p = this.manualEndptToPx(r.target()[0], o), g = je(p, 2), y = g[0], b = g[1], m = {
          x1: h,
          y1: d,
          x2: y,
          y2: b
        };
        n = l(h, d, y, b), i = m;
      } else
        Pe("Edge ".concat(r.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
  };
};
yt.findHaystackPoints = function(r) {
  for (var e = 0; e < r.length; e++) {
    var t = r[e], a = t._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 s = a.source, o = a.target, u = s.position(), l = o.position(), f = s.width(), c = o.width(), v = s.height(), h = o.height(), d = t.pstyle("haystack-radius").value, p = d / 2;
    n.haystackPts = n.allpts = [n.source.x * f * p + u.x, n.source.y * v * p + u.y, n.target.x * c * p + l.x, n.target.y * h * p + 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(t), this.calculateArrowAngles(t), this.recalculateEdgeLabelProjections(t), this.calculateLabelAngles(t);
  }
};
yt.findSegmentsPoints = function(r, e) {
  var t = r._private.rscratch, a = r.pstyle("segment-weights"), n = r.pstyle("segment-distances"), i = r.pstyle("segment-radii"), s = r.pstyle("radius-type"), o = Math.min(a.pfValue.length, n.pfValue.length), u = i.pfValue[i.pfValue.length - 1], l = s.pfValue[s.pfValue.length - 1];
  t.edgeType = "segments", t.segpts = [], t.radii = [], t.isArcRadius = [];
  for (var f = 0; f < o; f++) {
    var c = a.pfValue[f], v = n.pfValue[f], h = 1 - c, d = c, p = this.findMidptPtsEtc(r, e), g = p.midptPts, y = p.vectorNormInverse, b = {
      x: g.x1 * h + g.x2 * d,
      y: g.y1 * h + g.y2 * d
    };
    t.segpts.push(b.x + y.x * v, b.y + y.y * v), t.radii.push(i.pfValue[f] !== void 0 ? i.pfValue[f] : u), t.isArcRadius.push((s.pfValue[f] !== void 0 ? s.pfValue[f] : l) === "arc-radius");
  }
};
yt.findLoopPoints = function(r, e, t, a) {
  var n = r._private.rscratch, i = e.dirCounts, s = e.srcPos, o = r.pstyle("control-point-distances"), u = o ? o.pfValue[0] : void 0, l = r.pstyle("loop-direction").pfValue, f = r.pstyle("loop-sweep").pfValue, c = r.pstyle("control-point-step-size").pfValue;
  n.edgeType = "self";
  var v = t, h = c;
  a && (v = 0, h = u);
  var d = l - Math.PI / 2, p = d - f / 2, g = d + f / 2, y = l + "_" + f;
  v = i[y] === void 0 ? i[y] = 0 : ++i[y], n.ctrlpts = [s.x + Math.cos(p) * 1.4 * h * (v / 3 + 1), s.y + Math.sin(p) * 1.4 * h * (v / 3 + 1), s.x + Math.cos(g) * 1.4 * h * (v / 3 + 1), s.y + Math.sin(g) * 1.4 * h * (v / 3 + 1)];
};
yt.findCompoundLoopPoints = function(r, e, t, a) {
  var n = r._private.rscratch;
  n.edgeType = "compound";
  var i = e.srcPos, s = e.tgtPos, o = e.srcW, u = e.srcH, l = e.tgtW, f = e.tgtH, c = r.pstyle("control-point-step-size").pfValue, v = r.pstyle("control-point-distances"), h = v ? v.pfValue[0] : void 0, d = t, p = c;
  a && (d = 0, p = h);
  var g = 50, y = {
    x: i.x - o / 2,
    y: i.y - u / 2
  }, b = {
    x: s.x - l / 2,
    y: s.y - f / 2
  }, m = {
    x: Math.min(y.x, b.x),
    y: Math.min(y.y, b.y)
  }, E = 0.5, x = Math.max(E, Math.log(o * Oa)), S = Math.max(E, Math.log(l * Oa));
  n.ctrlpts = [m.x, m.y - (1 + Math.pow(g, 1.12) / 100) * p * (d / 3 + 1) * x, m.x - (1 + Math.pow(g, 1.12) / 100) * p * (d / 3 + 1) * S, m.y];
};
yt.findStraightEdgePoints = function(r) {
  r._private.rscratch.edgeType = "straight";
};
yt.findBezierPoints = function(r, e, t, a, n) {
  var i = r._private.rscratch, s = r.pstyle("control-point-step-size").pfValue, o = r.pstyle("control-point-distances"), u = r.pstyle("control-point-weights"), l = o && u ? Math.min(o.value.length, u.value.length) : 1, f = o ? o.pfValue[0] : void 0, c = u.value[0], v = a;
  i.edgeType = v ? "multibezier" : "bezier", i.ctrlpts = [];
  for (var h = 0; h < l; h++) {
    var d = (0.5 - e.eles.length / 2 + t) * s * (n ? -1 : 1), p = void 0, g = lo(d);
    v && (f = o ? o.pfValue[h] : s, c = u.value[h]), a ? p = f : p = f !== void 0 ? g * f : void 0;
    var y = p !== void 0 ? p : d, b = 1 - c, m = c, E = this.findMidptPtsEtc(r, e), x = E.midptPts, S = E.vectorNormInverse, w = {
      x: x.x1 * b + x.x2 * m,
      y: x.y1 * b + x.y2 * m
    };
    i.ctrlpts.push(w.x + S.x * y, w.y + S.y * y);
  }
};
yt.findTaxiPoints = function(r, e) {
  var t = r._private.rscratch;
  t.edgeType = "segments";
  var a = "vertical", n = "horizontal", i = "leftward", s = "rightward", o = "downward", u = "upward", l = "auto", f = e.posPts, c = e.srcW, v = e.srcH, h = e.tgtW, d = e.tgtH, p = r.pstyle("edge-distances").value, g = p !== "node-position", y = r.pstyle("taxi-direction").value, b = y, m = r.pstyle("taxi-turn"), E = m.units === "%", x = m.pfValue, S = x < 0, w = r.pstyle("taxi-turn-min-distance").pfValue, T = g ? (c + h) / 2 : 0, C = g ? (v + d) / 2 : 0, D = f.x2 - f.x1, A = f.y2 - f.y1, L = function(M, q) {
    return M > 0 ? Math.max(M - q, 0) : Math.min(M + q, 0);
  }, R = L(D, T), I = L(A, C), O = !1;
  b === l ? y = Math.abs(R) > Math.abs(I) ? n : a : b === u || b === o ? (y = a, O = !0) : (b === i || b === s) && (y = n, O = !0);
  var N = y === a, k = N ? I : R, P = N ? A : D, B = lo(P), _ = !1;
  !(O && (E || S)) && (b === o && P < 0 || b === u && P > 0 || b === i && P > 0 || b === s && P < 0) && (B *= -1, k = B * Math.abs(k), _ = !0);
  var F;
  if (E) {
    var G = x < 0 ? 1 + x : x;
    F = G * k;
  } else {
    var U = x < 0 ? k : 0;
    F = U + x * B;
  }
  var H = function(M) {
    return Math.abs(M) < w || Math.abs(M) >= Math.abs(k);
  }, $ = H(F), X = H(Math.abs(k) - Math.abs(F)), Q = $ || X;
  if (Q && !_)
    if (N) {
      var re = Math.abs(P) <= v / 2, J = Math.abs(D) <= h / 2;
      if (re) {
        var z = (f.x1 + f.x2) / 2, V = f.y1, Y = f.y2;
        t.segpts = [z, V, z, Y];
      } else if (J) {
        var ee = (f.y1 + f.y2) / 2, ne = f.x1, be = f.x2;
        t.segpts = [ne, ee, be, ee];
      } else
        t.segpts = [f.x1, f.y2];
    } else {
      var Ve = Math.abs(P) <= c / 2, Ne = Math.abs(A) <= d / 2;
      if (Ve) {
        var se = (f.y1 + f.y2) / 2, oe = f.x1, ve = f.x2;
        t.segpts = [oe, se, ve, se];
      } else if (Ne) {
        var ge = (f.x1 + f.x2) / 2, he = f.y1, ye = f.y2;
        t.segpts = [ge, he, ge, ye];
      } else
        t.segpts = [f.x2, f.y1];
    }
  else if (N) {
    var we = f.y1 + F + (g ? v / 2 * B : 0), Se = f.x1, Fe = f.x2;
    t.segpts = [Se, we, Fe, we];
  } else {
    var Ye = f.x1 + F + (g ? c / 2 * B : 0), Ie = f.y1, We = f.y2;
    t.segpts = [Ye, Ie, Ye, We];
  }
  if (t.isRound) {
    var Ae = r.pstyle("taxi-radius").value, le = r.pstyle("radius-type").value[0] === "arc-radius";
    t.radii = new Array(t.segpts.length / 2).fill(Ae), t.isArcRadius = new Array(t.segpts.length / 2).fill(le);
  }
};
yt.tryToCorrectInvalidPoints = function(r, e) {
  var t = r._private.rscratch;
  if (t.edgeType === "bezier") {
    var a = e.srcPos, n = e.tgtPos, i = e.srcW, s = e.srcH, o = e.tgtW, u = e.tgtH, l = e.srcShape, f = e.tgtShape, c = e.srcCornerRadius, v = e.tgtCornerRadius, h = e.srcRs, d = e.tgtRs, p = !ae(t.startX) || !ae(t.startY), g = !ae(t.arrowStartX) || !ae(t.arrowStartY), y = !ae(t.endX) || !ae(t.endY), b = !ae(t.arrowEndX) || !ae(t.arrowEndY), m = 3, E = this.getArrowWidth(r.pstyle("width").pfValue, r.pstyle("arrow-scale").value) * this.arrowShapeWidth, x = m * E, S = Lr({
      x: t.ctrlpts[0],
      y: t.ctrlpts[1]
    }, {
      x: t.startX,
      y: t.startY
    }), w = S < x, T = Lr({
      x: t.ctrlpts[0],
      y: t.ctrlpts[1]
    }, {
      x: t.endX,
      y: t.endY
    }), C = T < x, D = !1;
    if (p || g || w) {
      D = !0;
      var A = {
        // delta
        x: t.ctrlpts[0] - a.x,
        y: t.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
      }, I = Math.max(i, s), O = {
        // *2 radius guarantees outside shape
        x: t.ctrlpts[0] + R.x * 2 * I,
        y: t.ctrlpts[1] + R.y * 2 * I
      }, N = l.intersectLine(a.x, a.y, i, s, O.x, O.y, 0, c, h);
      w ? (t.ctrlpts[0] = t.ctrlpts[0] + R.x * (x - S), t.ctrlpts[1] = t.ctrlpts[1] + R.y * (x - S)) : (t.ctrlpts[0] = N[0] + R.x * x, t.ctrlpts[1] = N[1] + R.y * x);
    }
    if (y || b || C) {
      D = !0;
      var k = {
        // delta
        x: t.ctrlpts[0] - n.x,
        y: t.ctrlpts[1] - n.y
      }, P = Math.sqrt(k.x * k.x + k.y * k.y), B = {
        // normalised delta
        x: k.x / P,
        y: k.y / P
      }, _ = Math.max(i, s), F = {
        // *2 radius guarantees outside shape
        x: t.ctrlpts[0] + B.x * 2 * _,
        y: t.ctrlpts[1] + B.y * 2 * _
      }, G = f.intersectLine(n.x, n.y, o, u, F.x, F.y, 0, v, d);
      C ? (t.ctrlpts[0] = t.ctrlpts[0] + B.x * (x - T), t.ctrlpts[1] = t.ctrlpts[1] + B.y * (x - T)) : (t.ctrlpts[0] = G[0] + B.x * x, t.ctrlpts[1] = G[1] + B.y * x);
    }
    D && this.findEndpoints(r);
  }
};
yt.storeAllpts = function(r) {
  var e = r._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 t = 0; t + 1 < e.ctrlpts.length; t += 2)
      e.allpts.push(e.ctrlpts[t], e.ctrlpts[t + 1]), t + 3 < e.ctrlpts.length && e.allpts.push((e.ctrlpts[t] + e.ctrlpts[t + 2]) / 2, (e.ctrlpts[t + 1] + e.ctrlpts[t + 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 = it(e.allpts[a], e.allpts[a + 2], e.allpts[a + 4], n), e.midY = it(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 s = e.radii[i / 2 - 1], o = e.isArcRadius[i / 2 - 1];
        e.roundCorners.push(To({
          x: e.allpts[i - 2],
          y: e.allpts[i - 1]
        }, {
          x: e.allpts[i],
          y: e.allpts[i + 1],
          radius: s
        }, {
          x: e.allpts[i + 2],
          y: e.allpts[i + 3]
        }, s, o));
      }
    }
    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 c = {
          x: e.segpts[f],
          y: e.segpts[f + 1]
        }, v = e.roundCorners[f / 2];
        if (v.radius === 0) {
          var h = {
            x: e.segpts[f + 2],
            y: e.segpts[f + 3]
          };
          e.midX = c.x, e.midY = c.y, e.midVector = [c.y - h.y, h.x - c.x];
        } else {
          var d = [c.x - v.cx, c.y - v.cy], p = v.radius / Math.sqrt(Math.pow(d[0], 2) + Math.pow(d[1], 2));
          d = d.map(function(g) {
            return g * p;
          }), e.midX = v.cx + d[0], e.midY = v.cy + d[1], e.midVector = d;
        }
      }
    }
  }
};
yt.checkForInvalidEdgeWarning = function(r) {
  var e = r[0]._private.rscratch;
  e.nodesOverlap || ae(e.startX) && ae(e.startY) && ae(e.endX) && ae(e.endY) ? e.loggedErr = !1 : e.loggedErr || (e.loggedErr = !0, Pe("Edge `" + r.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."));
};
yt.findEdgeControlPoints = function(r) {
  var e = this;
  if (!(!r || r.length === 0)) {
    for (var t = this, a = t.cy, n = a.hasCompoundNodes(), i = new Kt(), s = function(C, D) {
      return [].concat(En(C), [D ? 1 : 0]).join("-");
    }, o = [], u = [], l = 0; l < r.length; l++) {
      var f = r[l], c = f._private, v = f.pstyle("curve-style").value;
      if (!(f.removed() || !f.takesUpSpace())) {
        if (v === "haystack") {
          u.push(f);
          continue;
        }
        var h = v === "unbundled-bezier" || v.endsWith("segments") || v === "straight" || v === "straight-triangle" || v.endsWith("taxi"), d = v === "unbundled-bezier" || v === "bezier", p = c.source, g = c.target, y = p.poolIndex(), b = g.poolIndex(), m = [y, b].sort(), E = s(m, h), x = i.get(E);
        x == null && (x = {
          eles: []
        }, o.push({
          pairId: m,
          edgeIsUnbundled: h
        }), i.set(E, x)), x.eles.push(f), h && (x.hasUnbundled = !0), d && (x.hasBezier = !0);
      }
    }
    for (var S = function() {
      var C = o[w], D = C.pairId, A = C.edgeIsUnbundled, L = s(D, A), R = i.get(L), I;
      if (!R.hasUnbundled) {
        var O = R.eles[0].parallelEdges().filter(function(le) {
          return le.isBundledBezier();
        });
        oo(R.eles), O.forEach(function(le) {
          return R.eles.push(le);
        }), R.eles.sort(function(le, j) {
          return le.poolIndex() - j.poolIndex();
        });
      }
      var N = R.eles[0], k = N.source(), P = N.target();
      if (k.poolIndex() > P.poolIndex()) {
        var B = k;
        k = P, P = B;
      }
      var _ = R.srcPos = k.position(), F = R.tgtPos = P.position(), G = R.srcW = k.outerWidth(), U = R.srcH = k.outerHeight(), H = R.tgtW = P.outerWidth(), $ = R.tgtH = P.outerHeight(), X = R.srcShape = t.nodeShapes[e.getNodeShape(k)], Q = R.tgtShape = t.nodeShapes[e.getNodeShape(P)], re = R.srcCornerRadius = k.pstyle("corner-radius").value === "auto" ? "auto" : k.pstyle("corner-radius").pfValue, J = R.tgtCornerRadius = P.pstyle("corner-radius").value === "auto" ? "auto" : P.pstyle("corner-radius").pfValue, z = R.tgtRs = P._private.rscratch, V = R.srcRs = k._private.rscratch;
      R.dirCounts = {
        north: 0,
        west: 0,
        south: 0,
        east: 0,
        northwest: 0,
        southwest: 0,
        northeast: 0,
        southeast: 0
      };
      for (var Y = 0; Y < R.eles.length; Y++) {
        var ee = R.eles[Y], ne = ee[0]._private.rscratch, be = ee.pstyle("curve-style").value, Ve = be === "unbundled-bezier" || be.endsWith("segments") || be.endsWith("taxi"), Ne = !k.same(ee.source());
        if (!R.calculatedIntersection && k !== P && (R.hasBezier || R.hasUnbundled)) {
          R.calculatedIntersection = !0;
          var se = X.intersectLine(_.x, _.y, G, U, F.x, F.y, 0, re, V), oe = R.srcIntn = se, ve = Q.intersectLine(F.x, F.y, H, $, _.x, _.y, 0, J, z), ge = R.tgtIntn = ve, he = R.intersectionPts = {
            x1: se[0],
            x2: ve[0],
            y1: se[1],
            y2: ve[1]
          }, ye = R.posPts = {
            x1: _.x,
            x2: F.x,
            y1: _.y,
            y2: F.y
          }, we = ve[1] - se[1], Se = ve[0] - se[0], Fe = Math.sqrt(Se * Se + we * we);
          ae(Fe) && Fe >= dy || (Fe = Math.sqrt(Math.max(Se * Se, Oa) + Math.max(we * we, Oa)));
          var Ye = R.vector = {
            x: Se,
            y: we
          }, Ie = R.vectorNorm = {
            x: Ye.x / Fe,
            y: Ye.y / Fe
          }, We = {
            x: -Ie.y,
            y: Ie.x
          };
          R.nodesOverlap = !ae(Fe) || Q.checkPoint(se[0], se[1], 0, H, $, F.x, F.y, J, z) || X.checkPoint(ve[0], ve[1], 0, G, U, _.x, _.y, re, V), R.vectorNormInverse = We, I = {
            nodesOverlap: R.nodesOverlap,
            dirCounts: R.dirCounts,
            calculatedIntersection: !0,
            hasBezier: R.hasBezier,
            hasUnbundled: R.hasUnbundled,
            eles: R.eles,
            srcPos: F,
            srcRs: z,
            tgtPos: _,
            tgtRs: V,
            srcW: H,
            srcH: $,
            tgtW: G,
            tgtH: U,
            srcIntn: ge,
            tgtIntn: oe,
            srcShape: Q,
            tgtShape: X,
            posPts: {
              x1: ye.x2,
              y1: ye.y2,
              x2: ye.x1,
              y2: ye.y1
            },
            intersectionPts: {
              x1: he.x2,
              y1: he.y2,
              x2: he.x1,
              y2: he.y1
            },
            vector: {
              x: -Ye.x,
              y: -Ye.y
            },
            vectorNorm: {
              x: -Ie.x,
              y: -Ie.y
            },
            vectorNormInverse: {
              x: -We.x,
              y: -We.y
            }
          };
        }
        var Ae = Ne ? I : R;
        ne.nodesOverlap = Ae.nodesOverlap, ne.srcIntn = Ae.srcIntn, ne.tgtIntn = Ae.tgtIntn, ne.isRound = be.startsWith("round"), n && (k.isParent() || k.isChild() || P.isParent() || P.isChild()) && (k.parents().anySame(P) || P.parents().anySame(k) || k.same(P) && k.isParent()) ? e.findCompoundLoopPoints(ee, Ae, Y, Ve) : k === P ? e.findLoopPoints(ee, Ae, Y, Ve) : be.endsWith("segments") ? e.findSegmentsPoints(ee, Ae) : be.endsWith("taxi") ? e.findTaxiPoints(ee, Ae) : be === "straight" || !Ve && R.eles.length % 2 === 1 && Y === Math.floor(R.eles.length / 2) ? e.findStraightEdgePoints(ee) : e.findBezierPoints(ee, Ae, Y, Ve, Ne), e.findEndpoints(ee), e.tryToCorrectInvalidPoints(ee, Ae), e.checkForInvalidEdgeWarning(ee), e.storeAllpts(ee), e.storeEdgeProjections(ee), e.calculateArrowAngles(ee), e.recalculateEdgeLabelProjections(ee), e.calculateLabelAngles(ee);
      }
    }, w = 0; w < o.length; w++)
      S();
    this.findHaystackPoints(u);
  }
};
function xc(r) {
  var e = [];
  if (r != null) {
    for (var t = 0; t < r.length; t += 2) {
      var a = r[t], n = r[t + 1];
      e.push({
        x: a,
        y: n
      });
    }
    return e;
  }
}
yt.getSegmentPoints = function(r) {
  var e = r[0]._private.rscratch;
  this.recalculateRenderedStyle(r);
  var t = e.edgeType;
  if (t === "segments")
    return xc(e.segpts);
};
yt.getControlPoints = function(r) {
  var e = r[0]._private.rscratch;
  this.recalculateRenderedStyle(r);
  var t = e.edgeType;
  if (t === "bezier" || t === "multibezier" || t === "self" || t === "compound")
    return xc(e.ctrlpts);
};
yt.getEdgeMidpoint = function(r) {
  var e = r[0]._private.rscratch;
  return this.recalculateRenderedStyle(r), {
    x: e.midX,
    y: e.midY
  };
};
var Ua = {};
Ua.manualEndptToPx = function(r, e) {
  var t = this, a = r.position(), n = r.outerWidth(), i = r.outerHeight(), s = r._private.rscratch;
  if (e.value.length === 2) {
    var o = [e.pfValue[0], e.pfValue[1]];
    return e.units[0] === "%" && (o[0] = o[0] * n), e.units[1] === "%" && (o[1] = o[1] * i), o[0] += a.x, o[1] += a.y, o;
  } 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 t.nodeShapes[this.getNodeShape(r)].intersectLine(a.x, a.y, n, i, f[0], f[1], 0, r.pstyle("corner-radius").value === "auto" ? "auto" : r.pstyle("corner-radius").pfValue, s);
  }
};
Ua.findEndpoints = function(r) {
  var e = this, t, a = r.source()[0], n = r.target()[0], i = a.position(), s = n.position(), o = r.pstyle("target-arrow-shape").value, u = r.pstyle("source-arrow-shape").value, l = r.pstyle("target-distance-from-node").pfValue, f = r.pstyle("source-distance-from-node").pfValue, c = a._private.rscratch, v = n._private.rscratch, h = r.pstyle("curve-style").value, d = r._private.rscratch, p = d.edgeType, g = h === "taxi", y = p === "self" || p === "compound", b = p === "bezier" || p === "multibezier" || y, m = p !== "bezier", E = p === "straight" || p === "segments", x = p === "segments", S = b || m || E, w = y || g, T = r.pstyle("source-endpoint"), C = w ? "outside-to-node" : T.value, D = a.pstyle("corner-radius").value === "auto" ? "auto" : a.pstyle("corner-radius").pfValue, A = r.pstyle("target-endpoint"), L = w ? "outside-to-node" : A.value, R = n.pstyle("corner-radius").value === "auto" ? "auto" : n.pstyle("corner-radius").pfValue;
  d.srcManEndpt = T, d.tgtManEndpt = A;
  var I, O, N, k;
  if (b) {
    var P = [d.ctrlpts[0], d.ctrlpts[1]], B = m ? [d.ctrlpts[d.ctrlpts.length - 2], d.ctrlpts[d.ctrlpts.length - 1]] : P;
    I = B, O = P;
  } else if (E) {
    var _ = x ? d.segpts.slice(0, 2) : [s.x, s.y], F = x ? d.segpts.slice(d.segpts.length - 2) : [i.x, i.y];
    I = F, O = _;
  }
  if (L === "inside-to-node")
    t = [s.x, s.y];
  else if (A.units)
    t = this.manualEndptToPx(n, A);
  else if (L === "outside-to-line")
    t = d.tgtIntn;
  else if (L === "outside-to-node" || L === "outside-to-node-or-label" ? N = I : (L === "outside-to-line" || L === "outside-to-line-or-label") && (N = [i.x, i.y]), t = e.nodeShapes[this.getNodeShape(n)].intersectLine(s.x, s.y, n.outerWidth(), n.outerHeight(), N[0], N[1], 0, R, v), L === "outside-to-node-or-label" || L === "outside-to-line-or-label") {
    var G = n._private.rscratch, U = G.labelWidth, H = G.labelHeight, $ = G.labelX, X = G.labelY, Q = U / 2, re = H / 2, J = n.pstyle("text-valign").value;
    J === "top" ? X -= re : J === "bottom" && (X += re);
    var z = n.pstyle("text-halign").value;
    z === "left" ? $ -= Q : z === "right" && ($ += Q);
    var V = Aa(N[0], N[1], [$ - Q, X - re, $ + Q, X - re, $ + Q, X + re, $ - Q, X + re], s.x, s.y);
    if (V.length > 0) {
      var Y = i, ee = Er(Y, Yr(t)), ne = Er(Y, Yr(V)), be = ee;
      if (ne < ee && (t = V, be = ne), V.length > 2) {
        var Ve = Er(Y, {
          x: V[2],
          y: V[3]
        });
        Ve < be && (t = [V[2], V[3]]);
      }
    }
  }
  var Ne = Qa(t, I, e.arrowShapes[o].spacing(r) + l), se = Qa(t, I, e.arrowShapes[o].gap(r) + l);
  if (d.endX = se[0], d.endY = se[1], d.arrowEndX = Ne[0], d.arrowEndY = Ne[1], C === "inside-to-node")
    t = [i.x, i.y];
  else if (T.units)
    t = this.manualEndptToPx(a, T);
  else if (C === "outside-to-line")
    t = d.srcIntn;
  else if (C === "outside-to-node" || C === "outside-to-node-or-label" ? k = O : (C === "outside-to-line" || C === "outside-to-line-or-label") && (k = [s.x, s.y]), t = e.nodeShapes[this.getNodeShape(a)].intersectLine(i.x, i.y, a.outerWidth(), a.outerHeight(), k[0], k[1], 0, D, c), C === "outside-to-node-or-label" || C === "outside-to-line-or-label") {
    var oe = a._private.rscratch, ve = oe.labelWidth, ge = oe.labelHeight, he = oe.labelX, ye = oe.labelY, we = ve / 2, Se = ge / 2, Fe = a.pstyle("text-valign").value;
    Fe === "top" ? ye -= Se : Fe === "bottom" && (ye += Se);
    var Ye = a.pstyle("text-halign").value;
    Ye === "left" ? he -= we : Ye === "right" && (he += we);
    var Ie = Aa(k[0], k[1], [he - we, ye - Se, he + we, ye - Se, he + we, ye + Se, he - we, ye + Se], i.x, i.y);
    if (Ie.length > 0) {
      var We = s, Ae = Er(We, Yr(t)), le = Er(We, Yr(Ie)), j = Ae;
      if (le < Ae && (t = [Ie[0], Ie[1]], j = le), Ie.length > 2) {
        var M = Er(We, {
          x: Ie[2],
          y: Ie[3]
        });
        M < j && (t = [Ie[2], Ie[3]]);
      }
    }
  }
  var q = Qa(t, O, e.arrowShapes[u].spacing(r) + f), W = Qa(t, O, e.arrowShapes[u].gap(r) + f);
  d.startX = W[0], d.startY = W[1], d.arrowStartX = q[0], d.arrowStartY = q[1], S && (!ae(d.startX) || !ae(d.startY) || !ae(d.endX) || !ae(d.endY) ? d.badLine = !0 : d.badLine = !1);
};
Ua.getSourceEndpoint = function(r) {
  var e = r[0]._private.rscratch;
  switch (this.recalculateRenderedStyle(r), e.edgeType) {
    case "haystack":
      return {
        x: e.haystackPts[0],
        y: e.haystackPts[1]
      };
    default:
      return {
        x: e.arrowStartX,
        y: e.arrowStartY
      };
  }
};
Ua.getTargetEndpoint = function(r) {
  var e = r[0]._private.rscratch;
  switch (this.recalculateRenderedStyle(r), e.edgeType) {
    case "haystack":
      return {
        x: e.haystackPts[2],
        y: e.haystackPts[3]
      };
    default:
      return {
        x: e.arrowEndX,
        y: e.arrowEndY
      };
  }
};
var Co = {};
function gy(r, e, t) {
  for (var a = function(l, f, c, v) {
    return it(l, f, c, v);
  }, n = e._private, i = n.rstyle.bezierPts, s = 0; s < r.bezierProjPcts.length; s++) {
    var o = r.bezierProjPcts[s];
    i.push({
      x: a(t[0], t[2], t[4], o),
      y: a(t[1], t[3], t[5], o)
    });
  }
}
Co.storeEdgeProjections = function(r) {
  var e = r._private, t = e.rscratch, a = t.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 < t.allpts.length; n += 4)
      gy(this, r, t.allpts.slice(n, n + 6));
  } else if (a === "segments")
    for (var i = e.rstyle.linePts = [], n = 0; n + 1 < t.allpts.length; n += 2)
      i.push({
        x: t.allpts[n],
        y: t.allpts[n + 1]
      });
  else if (a === "haystack") {
    var s = t.haystackPts;
    e.rstyle.haystackPts = [{
      x: s[0],
      y: s[1]
    }, {
      x: s[2],
      y: s[3]
    }];
  }
  e.rstyle.arrowWidth = this.getArrowWidth(r.pstyle("width").pfValue, r.pstyle("arrow-scale").value) * this.arrowShapeWidth;
};
Co.recalculateEdgeProjections = function(r) {
  this.findEdgeControlPoints(r);
};
var Ht = {};
Ht.recalculateNodeLabelProjection = function(r) {
  var e = r.pstyle("label").strValue;
  if (!sr(e)) {
    var t, a, n = r._private, i = r.width(), s = r.height(), o = r.padding(), u = r.position(), l = r.pstyle("text-halign").strValue, f = r.pstyle("text-valign").strValue, c = n.rscratch, v = n.rstyle;
    switch (l) {
      case "left":
        t = u.x - i / 2 - o;
        break;
      case "right":
        t = u.x + i / 2 + o;
        break;
      default:
        t = u.x;
    }
    switch (f) {
      case "top":
        a = u.y - s / 2 - o;
        break;
      case "bottom":
        a = u.y + s / 2 + o;
        break;
      default:
        a = u.y;
    }
    c.labelX = t, c.labelY = a, v.labelX = t, v.labelY = a, this.calculateLabelAngles(r), this.applyLabelDimensions(r);
  }
};
var Tc = function(e, t) {
  var a = Math.atan(t / e);
  return e === 0 && a < 0 && (a = a * -1), a;
}, Cc = function(e, t) {
  var a = t.x - e.x, n = t.y - e.y;
  return Tc(a, n);
}, py = function(e, t, a, n) {
  var i = Sa(0, n - 1e-3, 1), s = Sa(0, n + 1e-3, 1), o = Wr(e, t, a, i), u = Wr(e, t, a, s);
  return Cc(o, u);
};
Ht.recalculateEdgeLabelProjections = function(r) {
  var e, t = r._private, a = t.rscratch, n = this, i = {
    mid: r.pstyle("label").strValue,
    source: r.pstyle("source-label").strValue,
    target: r.pstyle("target-label").strValue
  };
  if (i.mid || i.source || i.target) {
    e = {
      x: a.midX,
      y: a.midY
    };
    var s = function(c, v, h) {
      Wt(t.rscratch, c, v, h), Wt(t.rstyle, c, v, h);
    };
    s("labelX", null, e.x), s("labelY", null, e.y);
    var o = Tc(a.midDispX, a.midDispY);
    s("labelAutoAngle", null, o);
    var u = function() {
      if (u.cache)
        return u.cache;
      for (var c = [], v = 0; v + 5 < a.allpts.length; v += 4) {
        var h = {
          x: a.allpts[v],
          y: a.allpts[v + 1]
        }, d = {
          x: a.allpts[v + 2],
          y: a.allpts[v + 3]
        }, p = {
          x: a.allpts[v + 4],
          y: a.allpts[v + 5]
        };
        c.push({
          p0: h,
          p1: d,
          p2: p,
          startDist: 0,
          length: 0,
          segments: []
        });
      }
      var g = t.rstyle.bezierPts, y = n.bezierProjPcts.length;
      function b(w, T, C, D, A) {
        var L = Lr(T, C), R = w.segments[w.segments.length - 1], I = {
          p0: T,
          p1: C,
          t0: D,
          t1: A,
          startDist: R ? R.startDist + R.length : 0,
          length: L
        };
        w.segments.push(I), w.length += L;
      }
      for (var m = 0; m < c.length; m++) {
        var E = c[m], x = c[m - 1];
        x && (E.startDist = x.startDist + x.length), b(E, E.p0, g[m * y], 0, n.bezierProjPcts[0]);
        for (var S = 0; S < y - 1; S++)
          b(E, g[m * y + S], g[m * y + S + 1], n.bezierProjPcts[S], n.bezierProjPcts[S + 1]);
        b(E, g[m * y + y - 1], E.p2, n.bezierProjPcts[y - 1], 1);
      }
      return u.cache = c;
    }, l = function(c) {
      var v, h = c === "source";
      if (i[c]) {
        var d = r.pstyle(c + "-text-offset").pfValue;
        switch (a.edgeType) {
          case "self":
          case "compound":
          case "bezier":
          case "multibezier": {
            for (var p = u(), g, y = 0, b = 0, m = 0; m < p.length; m++) {
              for (var E = p[h ? m : p.length - 1 - m], x = 0; x < E.segments.length; x++) {
                var S = E.segments[h ? x : E.segments.length - 1 - x], w = m === p.length - 1 && x === E.segments.length - 1;
                if (y = b, b += S.length, b >= d || w) {
                  g = {
                    cp: E,
                    segment: S
                  };
                  break;
                }
              }
              if (g)
                break;
            }
            var T = g.cp, C = g.segment, D = (d - y) / C.length, A = C.t1 - C.t0, L = h ? C.t0 + A * D : C.t1 - A * D;
            L = Sa(0, L, 1), e = Wr(T.p0, T.p1, T.p2, L), v = py(T.p0, T.p1, T.p2, L);
            break;
          }
          case "straight":
          case "segments":
          case "haystack": {
            for (var R = 0, I, O, N, k, P = a.allpts.length, B = 0; B + 3 < P && (h ? (N = {
              x: a.allpts[B],
              y: a.allpts[B + 1]
            }, k = {
              x: a.allpts[B + 2],
              y: a.allpts[B + 3]
            }) : (N = {
              x: a.allpts[P - 2 - B],
              y: a.allpts[P - 1 - B]
            }, k = {
              x: a.allpts[P - 4 - B],
              y: a.allpts[P - 3 - B]
            }), I = Lr(N, k), O = R, R += I, !(R >= d)); B += 2)
              ;
            var _ = d - O, F = _ / I;
            F = Sa(0, F, 1), e = _h(N, k, F), v = Cc(N, k);
            break;
          }
        }
        s("labelX", c, e.x), s("labelY", c, e.y), s("labelAutoAngle", c, v);
      }
    };
    l("source"), l("target"), this.applyLabelDimensions(r);
  }
};
Ht.applyLabelDimensions = function(r) {
  this.applyPrefixedLabelDimensions(r), r.isEdge() && (this.applyPrefixedLabelDimensions(r, "source"), this.applyPrefixedLabelDimensions(r, "target"));
};
Ht.applyPrefixedLabelDimensions = function(r, e) {
  var t = r._private, a = this.getLabelText(r, e), n = Ar(a, r._private.labelDimsKey);
  if (Tt(t.rscratch, "prefixedLabelDimsKey", e) !== n) {
    Wt(t.rscratch, "prefixedLabelDimsKey", e, n);
    var i = this.calculateLabelDimensions(r, a), s = r.pstyle("line-height").pfValue, o = r.pstyle("text-wrap").strValue, u = Tt(t.rscratch, "labelWrapCachedLines", e) || [], l = o !== "wrap" ? 1 : Math.max(u.length, 1), f = i.height / l, c = f * s, v = i.width, h = i.height + (l - 1) * (s - 1) * f;
    Wt(t.rstyle, "labelWidth", e, v), Wt(t.rscratch, "labelWidth", e, v), Wt(t.rstyle, "labelHeight", e, h), Wt(t.rscratch, "labelHeight", e, h), Wt(t.rscratch, "labelLineHeight", e, c);
  }
};
Ht.getLabelText = function(r, e) {
  var t = r._private, a = e ? e + "-" : "", n = r.pstyle(a + "label").strValue, i = r.pstyle("text-transform").value, s = function(U, H) {
    return H ? (Wt(t.rscratch, U, e, H), H) : Tt(t.rscratch, U, e);
  };
  if (!n)
    return "";
  i == "none" || (i == "uppercase" ? n = n.toUpperCase() : i == "lowercase" && (n = n.toLowerCase()));
  var o = r.pstyle("text-wrap").value;
  if (o === "wrap") {
    var u = s("labelKey");
    if (u != null && s("labelWrapKey") === u)
      return s("labelWrapCachedText");
    for (var l = "​", f = n.split(`
`), c = r.pstyle("text-max-width").pfValue, v = r.pstyle("text-overflow-wrap").value, h = v === "anywhere", d = [], p = /[\s\u200b]+|$/g, g = 0; g < f.length; g++) {
      var y = f[g], b = this.calculateLabelDimensions(r, y), m = b.width;
      if (h) {
        var E = y.split("").join(l);
        y = E;
      }
      if (m > c) {
        var x = y.matchAll(p), S = "", w = 0, T = Dt(x), C;
        try {
          for (T.s(); !(C = T.n()).done; ) {
            var D = C.value, A = D[0], L = y.substring(w, D.index);
            w = D.index + A.length;
            var R = S.length === 0 ? L : S + L + A, I = this.calculateLabelDimensions(r, R), O = I.width;
            O <= c ? S += L + A : (S && d.push(S), S = L + A);
          }
        } catch (G) {
          T.e(G);
        } finally {
          T.f();
        }
        S.match(/^[\s\u200b]+$/) || d.push(S);
      } else
        d.push(y);
    }
    s("labelWrapCachedLines", d), n = s("labelWrapCachedText", d.join(`
`)), s("labelWrapKey", u);
  } else if (o === "ellipsis") {
    var N = r.pstyle("text-max-width").pfValue, k = "", P = "…", B = !1;
    if (this.calculateLabelDimensions(r, n).width < N)
      return n;
    for (var _ = 0; _ < n.length; _++) {
      var F = this.calculateLabelDimensions(r, k + n[_] + P).width;
      if (F > N)
        break;
      k += n[_], _ === n.length - 1 && (B = !0);
    }
    return B || (k += P), k;
  }
  return n;
};
Ht.getLabelJustification = function(r) {
  var e = r.pstyle("text-justification").strValue, t = r.pstyle("text-halign").strValue;
  if (e === "auto")
    if (r.isNode())
      switch (t) {
        case "left":
          return "right";
        case "right":
          return "left";
        default:
          return "center";
      }
    else
      return "center";
  else
    return e;
};
Ht.calculateLabelDimensions = function(r, e) {
  var t = this, a = t.cy.window(), n = a.document, i = 0, s = r.pstyle("font-style").strValue, o = r.pstyle("font-size").pfValue, u = r.pstyle("font-family").strValue, l = r.pstyle("font-weight").strValue, f = this.labelCalcCanvas, c = this.labelCalcCanvasContext;
  if (!f) {
    f = this.labelCalcCanvas = n.createElement("canvas"), c = this.labelCalcCanvasContext = f.getContext("2d");
    var v = f.style;
    v.position = "absolute", v.left = "-9999px", v.top = "-9999px", v.zIndex = "-1", v.visibility = "hidden", v.pointerEvents = "none";
  }
  c.font = "".concat(s, " ").concat(l, " ").concat(o, "px ").concat(u);
  for (var h = 0, d = 0, p = e.split(`
`), g = 0; g < p.length; g++) {
    var y = p[g], b = c.measureText(y), m = Math.ceil(b.width), E = o;
    h = Math.max(m, h), d += E;
  }
  return h += i, d += i, {
    width: h,
    height: d
  };
};
Ht.calculateLabelAngle = function(r, e) {
  var t = r._private, a = t.rscratch, n = r.isEdge(), i = e ? e + "-" : "", s = r.pstyle(i + "text-rotation"), o = s.strValue;
  return o === "none" ? 0 : n && o === "autorotate" ? a.labelAutoAngle : o === "autorotate" ? 0 : s.pfValue;
};
Ht.calculateLabelAngles = function(r) {
  var e = this, t = r.isEdge(), a = r._private, n = a.rscratch;
  n.labelAngle = e.calculateLabelAngle(r), t && (n.sourceLabelAngle = e.calculateLabelAngle(r, "source"), n.targetLabelAngle = e.calculateLabelAngle(r, "target"));
};
var Dc = {}, Gl = 28, zl = !1;
Dc.getNodeShape = function(r) {
  var e = this, t = r.pstyle("shape").value;
  if (t === "cutrectangle" && (r.width() < Gl || r.height() < Gl))
    return zl || (Pe("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"), zl = !0), "rectangle";
  if (r.isParent())
    return t === "rectangle" || t === "roundrectangle" || t === "round-rectangle" || t === "cutrectangle" || t === "cut-rectangle" || t === "barrel" ? t : "rectangle";
  if (t === "polygon") {
    var a = r.pstyle("shape-polygon-points").value;
    return e.nodeShapes.makePolygon(a).name;
  }
  return t;
};
var Qn = {};
Qn.registerCalculationListeners = function() {
  var r = this.cy, e = r.collection(), t = this, a = function(s) {
    var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
    if (e.merge(s), o)
      for (var u = 0; u < s.length; u++) {
        var l = s[u], f = l._private, c = f.rstyle;
        c.clean = !1, c.cleanConnected = !1;
      }
  };
  t.binder(r).on("bounds.* dirty.*", function(s) {
    var o = s.target;
    a(o);
  }).on("style.* background.*", function(s) {
    var o = s.target;
    a(o, !1);
  });
  var n = function(s) {
    if (s) {
      var o = t.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 (o)
        for (var c = 0; c < o.length; c++) {
          var v = o[c];
          v(s, e);
        }
      t.recalculateRenderedStyle(e), e = r.collection();
    }
  };
  t.flushRenderedStyleQueue = function() {
    n(!0);
  }, t.beforeRender(n, t.beforeRenderPriorities.eleCalcs);
};
Qn.onUpdateEleCalcs = function(r) {
  var e = this.onUpdateEleCalcsFns = this.onUpdateEleCalcsFns || [];
  e.push(r);
};
Qn.recalculateRenderedStyle = function(r, e) {
  var t = function(E) {
    return E._private.rstyle.cleanConnected;
  };
  if (r.length !== 0) {
    var a = [], n = [];
    if (!this.destroyed) {
      e === void 0 && (e = !0);
      for (var i = 0; i < r.length; i++) {
        var s = r[i], o = s._private, u = o.rstyle;
        s.isEdge() && (!t(s.source()) || !t(s.target())) && (u.clean = !1), s.isEdge() && s.isBundledBezier() && s.parallelEdges().some(function(m) {
          return !m._private.rstyle.clean && m.isBundledBezier();
        }) && (u.clean = !1), !(e && u.clean || s.removed()) && s.pstyle("display").value !== "none" && (o.group === "nodes" ? n.push(s) : a.push(s), u.clean = !0);
      }
      for (var l = 0; l < n.length; l++) {
        var f = n[l], c = f._private, v = c.rstyle, h = f.position();
        this.recalculateNodeLabelProjection(f), v.nodeX = h.x, v.nodeY = h.y, v.nodeW = f.pstyle("width").pfValue, v.nodeH = f.pstyle("height").pfValue;
      }
      this.recalculateEdgeProjections(a);
      for (var d = 0; d < a.length; d++) {
        var p = a[d], g = p._private, y = g.rstyle, b = g.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 r = this.cachedZSortedEles;
  if (r) {
    r.drag = [], r.nondrag = [];
    for (var e = [], t = 0; t < r.length; t++) {
      var a = r[t], n = a._private.rscratch;
      a.grabbed() && !a.isParent() ? e.push(a) : n.inDragLayer ? r.drag.push(a) : r.nondrag.push(a);
    }
    for (var t = 0; t < e.length; t++) {
      var a = e[t];
      r.drag.push(a);
    }
  }
};
Jn.invalidateCachedZSortedEles = function() {
  this.cachedZSortedEles = null;
};
Jn.getCachedZSortedEles = function(r) {
  if (r || !this.cachedZSortedEles) {
    var e = this.cy.mutableElements().toArray();
    e.sort(sc), e.interactive = e.filter(function(t) {
      return t.interactive();
    }), this.cachedZSortedEles = e, this.updateCachedGrabbedEles();
  } else
    e = this.cachedZSortedEles;
  return e;
};
var Sc = {};
[Pr, Mn, yt, Ua, Co, Ht, Dc, Qn, Jn].forEach(function(r) {
  de(Sc, r);
});
var Ac = {};
Ac.getCachedImage = function(r, e, t) {
  var a = this, n = a.imageCache = a.imageCache || {}, i = n[r];
  if (i)
    return i.image.complete || i.image.addEventListener("load", t), i.image;
  i = n[r] = n[r] || {};
  var s = i.image = new Image();
  s.addEventListener("load", t), s.addEventListener("error", function() {
    s.error = !0;
  });
  var o = "data:", u = r.substring(0, o.length).toLowerCase() === o;
  return u || (e = e === "null" ? null : e, s.crossOrigin = e), s.src = r, s;
};
var sa = {};
sa.registerBinding = function(r, e, t, a) {
  var n = Array.prototype.slice.apply(arguments, [1]);
  if (Array.isArray(r)) {
    for (var i = [], s = 0; s < r.length; s++) {
      var o = r[s];
      if (o !== void 0) {
        var u = this.binder(o);
        i.push(u.on.apply(u, n));
      }
    }
    return i;
  }
  var u = this.binder(r);
  return u.on.apply(u, n);
};
sa.binder = function(r) {
  var e = this, t = e.cy.window(), a = r === t || r === t.document || r === t.document.body || Mv(r);
  if (e.supportsPassiveEvents == null) {
    var n = !1;
    try {
      var i = Object.defineProperty({}, "passive", {
        get: function() {
          return n = !0, !0;
        }
      });
      t.addEventListener("test", null, i);
    } catch {
    }
    e.supportsPassiveEvents = n;
  }
  var s = function(u, l, f) {
    var c = Array.prototype.slice.call(arguments);
    return a && e.supportsPassiveEvents && (c[2] = {
      capture: f ?? !1,
      passive: !1,
      once: !1
    }), e.bindings.push({
      target: r,
      args: c
    }), (r.addEventListener || r.on).apply(r, c), this;
  };
  return {
    on: s,
    addEventListener: s,
    addListener: s,
    bind: s
  };
};
sa.nodeIsDraggable = function(r) {
  return r && r.isNode() && !r.locked() && r.grabbable();
};
sa.nodeIsGrabbable = function(r) {
  return this.nodeIsDraggable(r) && r.interactive();
};
sa.load = function() {
  var r = this, e = r.cy.window(), t = function(M) {
    return M.selected();
  }, a = function(M) {
    var q = M.getRootNode();
    if (q && q.nodeType === 11 && q.host !== void 0)
      return q;
  }, n = function(M, q, W, K) {
    M == null && (M = r.cy);
    for (var Z = 0; Z < q.length; Z++) {
      var ue = q[Z];
      M.emit({
        originalEvent: W,
        type: ue,
        position: K
      });
    }
  }, i = function(M) {
    return M.shiftKey || M.metaKey || M.ctrlKey;
  }, s = function(M, q) {
    var W = !0;
    if (r.cy.hasCompoundNodes() && M && M.pannable())
      for (var K = 0; q && K < q.length; K++) {
        var M = q[K];
        if (M.isNode() && M.isParent() && !M.pannable()) {
          W = !1;
          break;
        }
      }
    else
      W = !0;
    return W;
  }, o = function(M) {
    M[0]._private.grabbed = !0;
  }, u = function(M) {
    M[0]._private.grabbed = !1;
  }, l = function(M) {
    M[0]._private.rscratch.inDragLayer = !0;
  }, f = function(M) {
    M[0]._private.rscratch.inDragLayer = !1;
  }, c = function(M) {
    M[0]._private.rscratch.isGrabTarget = !0;
  }, v = function(M) {
    M[0]._private.rscratch.isGrabTarget = !1;
  }, h = function(M, q) {
    var W = q.addToList, K = W.has(M);
    !K && M.grabbable() && !M.locked() && (W.merge(M), o(M));
  }, d = function(M, q) {
    if (M.cy().hasCompoundNodes() && !(q.inDragLayer == null && q.addToList == null)) {
      var W = M.descendants();
      q.inDragLayer && (W.forEach(l), W.connectedEdges().forEach(l)), q.addToList && h(W, q);
    }
  }, p = function(M, q) {
    q = q || {};
    var W = M.cy().hasCompoundNodes();
    q.inDragLayer && (M.forEach(l), M.neighborhood().stdFilter(function(K) {
      return !W || K.isEdge();
    }).forEach(l)), q.addToList && M.forEach(function(K) {
      h(K, q);
    }), d(M, q), b(M, {
      inDragLayer: q.inDragLayer
    }), r.updateCachedGrabbedEles();
  }, g = p, y = function(M) {
    M && (r.getCachedZSortedEles().forEach(function(q) {
      u(q), f(q), v(q);
    }), r.updateCachedGrabbedEles());
  }, b = function(M, q) {
    if (!(q.inDragLayer == null && q.addToList == null) && M.cy().hasCompoundNodes()) {
      var W = M.ancestors().orphans();
      if (!W.same(M)) {
        var K = W.descendants().spawnSelf().merge(W).unmerge(M).unmerge(M.descendants()), Z = K.connectedEdges();
        q.inDragLayer && (Z.forEach(l), K.forEach(l)), q.addToList && K.forEach(function(ue) {
          h(ue, q);
        });
      }
    }
  }, m = function() {
    document.activeElement != null && document.activeElement.blur != null && document.activeElement.blur();
  }, E = typeof MutationObserver < "u", x = typeof ResizeObserver < "u";
  E ? (r.removeObserver = new MutationObserver(function(j) {
    for (var M = 0; M < j.length; M++) {
      var q = j[M], W = q.removedNodes;
      if (W)
        for (var K = 0; K < W.length; K++) {
          var Z = W[K];
          if (Z === r.container) {
            r.destroy();
            break;
          }
        }
    }
  }), r.container.parentNode && r.removeObserver.observe(r.container.parentNode, {
    childList: !0
  })) : r.registerBinding(r.container, "DOMNodeRemoved", function(j) {
    r.destroy();
  });
  var S = _a(function() {
    r.cy.resize();
  }, 100);
  E && (r.styleObserver = new MutationObserver(S), r.styleObserver.observe(r.container, {
    attributes: !0
  })), r.registerBinding(e, "resize", S), x && (r.resizeObserver = new ResizeObserver(S), r.resizeObserver.observe(r.container));
  var w = function(M, q) {
    for (; M != null; )
      q(M), M = M.parentNode;
  }, T = function() {
    r.invalidateContainerClientCoordsCache();
  };
  w(r.container, function(j) {
    r.registerBinding(j, "transitionend", T), r.registerBinding(j, "animationend", T), r.registerBinding(j, "scroll", T);
  }), r.registerBinding(r.container, "contextmenu", function(j) {
    j.preventDefault();
  });
  var C = function() {
    return r.selection[4] !== 0;
  }, D = function(M) {
    for (var q = r.findContainerClientCoords(), W = q[0], K = q[1], Z = q[2], ue = q[3], te = M.touches ? M.touches : [M], fe = !1, xe = 0; xe < te.length; xe++) {
      var De = te[xe];
      if (W <= De.clientX && De.clientX <= W + Z && K <= De.clientY && De.clientY <= K + ue) {
        fe = !0;
        break;
      }
    }
    if (!fe)
      return !1;
    for (var pe = r.container, Te = M.target, me = Te.parentNode, Ee = !1; me; ) {
      if (me === pe) {
        Ee = !0;
        break;
      }
      me = me.parentNode;
    }
    return !!Ee;
  };
  r.registerBinding(r.container, "mousedown", function(M) {
    if (D(M) && !(r.hoverData.which === 1 && M.which !== 1)) {
      M.preventDefault(), m(), r.hoverData.capture = !0, r.hoverData.which = M.which;
      var q = r.cy, W = [M.clientX, M.clientY], K = r.projectIntoViewport(W[0], W[1]), Z = r.selection, ue = r.findNearestElements(K[0], K[1], !0, !1), te = ue[0], fe = r.dragData.possibleDragElements;
      r.hoverData.mdownPos = K, r.hoverData.mdownGPos = W;
      var xe = function() {
        r.hoverData.tapholdCancelled = !1, clearTimeout(r.hoverData.tapholdTimeout), r.hoverData.tapholdTimeout = setTimeout(function() {
          if (!r.hoverData.tapholdCancelled) {
            var ke = r.hoverData.down;
            ke ? ke.emit({
              originalEvent: M,
              type: "taphold",
              position: {
                x: K[0],
                y: K[1]
              }
            }) : q.emit({
              originalEvent: M,
              type: "taphold",
              position: {
                x: K[0],
                y: K[1]
              }
            });
          }
        }, r.tapholdDuration);
      };
      if (M.which == 3) {
        r.hoverData.cxtStarted = !0;
        var De = {
          originalEvent: M,
          type: "cxttapstart",
          position: {
            x: K[0],
            y: K[1]
          }
        };
        te ? (te.activate(), te.emit(De), r.hoverData.down = te) : q.emit(De), r.hoverData.downTime = (/* @__PURE__ */ new Date()).getTime(), r.hoverData.cxtDragged = !1;
      } else if (M.which == 1) {
        te && te.activate();
        {
          if (te != null && r.nodeIsGrabbable(te)) {
            var pe = function(ke) {
              return {
                originalEvent: M,
                type: ke,
                position: {
                  x: K[0],
                  y: K[1]
                }
              };
            }, Te = function(ke) {
              ke.emit(pe("grab"));
            };
            if (c(te), !te.selected())
              fe = r.dragData.possibleDragElements = q.collection(), g(te, {
                addToList: fe
              }), te.emit(pe("grabon")).emit(pe("grab"));
            else {
              fe = r.dragData.possibleDragElements = q.collection();
              var me = q.$(function(Ee) {
                return Ee.isNode() && Ee.selected() && r.nodeIsGrabbable(Ee);
              });
              p(me, {
                addToList: fe
              }), te.emit(pe("grabon")), me.forEach(Te);
            }
            r.redrawHint("eles", !0), r.redrawHint("drag", !0);
          }
          r.hoverData.down = te, r.hoverData.downs = ue, r.hoverData.downTime = (/* @__PURE__ */ new Date()).getTime();
        }
        n(te, ["mousedown", "tapstart", "vmousedown"], M, {
          x: K[0],
          y: K[1]
        }), te == null ? (Z[4] = 1, r.data.bgActivePosistion = {
          x: K[0],
          y: K[1]
        }, r.redrawHint("select", !0), r.redraw()) : te.pannable() && (Z[4] = 1), xe();
      }
      Z[0] = Z[2] = K[0], Z[1] = Z[3] = K[1];
    }
  }, !1);
  var A = a(r.container);
  r.registerBinding([e, A], "mousemove", function(M) {
    var q = r.hoverData.capture;
    if (!(!q && !D(M))) {
      var W = !1, K = r.cy, Z = K.zoom(), ue = [M.clientX, M.clientY], te = r.projectIntoViewport(ue[0], ue[1]), fe = r.hoverData.mdownPos, xe = r.hoverData.mdownGPos, De = r.selection, pe = null;
      !r.hoverData.draggingEles && !r.hoverData.dragging && !r.hoverData.selecting && (pe = r.findNearestElement(te[0], te[1], !0, !1));
      var Te = r.hoverData.last, me = r.hoverData.down, Ee = [te[0] - De[2], te[1] - De[3]], ke = r.dragData.possibleDragElements, Ke;
      if (xe) {
        var ut = ue[0] - xe[0], nt = ut * ut, $e = ue[1] - xe[1], lt = $e * $e, Qe = nt + lt;
        r.hoverData.isOverThresholdDrag = Ke = Qe >= r.desktopTapThreshold2;
      }
      var wt = i(M);
      Ke && (r.hoverData.tapholdCancelled = !0);
      var Ft = function() {
        var _t = r.hoverData.dragDelta = r.hoverData.dragDelta || [];
        _t.length === 0 ? (_t.push(Ee[0]), _t.push(Ee[1])) : (_t[0] += Ee[0], _t[1] += Ee[1]);
      };
      W = !0, n(pe, ["mousemove", "vmousemove", "tapdrag"], M, {
        x: te[0],
        y: te[1]
      });
      var er = function() {
        r.data.bgActivePosistion = void 0, r.hoverData.selecting || K.emit({
          originalEvent: M,
          type: "boxstart",
          position: {
            x: te[0],
            y: te[1]
          }
        }), De[4] = 1, r.hoverData.selecting = !0, r.redrawHint("select", !0), r.redraw();
      };
      if (r.hoverData.which === 3) {
        if (Ke) {
          var Xt = {
            originalEvent: M,
            type: "cxtdrag",
            position: {
              x: te[0],
              y: te[1]
            }
          };
          me ? me.emit(Xt) : K.emit(Xt), r.hoverData.cxtDragged = !0, (!r.hoverData.cxtOver || pe !== r.hoverData.cxtOver) && (r.hoverData.cxtOver && r.hoverData.cxtOver.emit({
            originalEvent: M,
            type: "cxtdragout",
            position: {
              x: te[0],
              y: te[1]
            }
          }), r.hoverData.cxtOver = pe, pe && pe.emit({
            originalEvent: M,
            type: "cxtdragover",
            position: {
              x: te[0],
              y: te[1]
            }
          }));
        }
      } else if (r.hoverData.dragging) {
        if (W = !0, K.panningEnabled() && K.userPanningEnabled()) {
          var kr;
          if (r.hoverData.justStartedPan) {
            var Ya = r.hoverData.mdownPos;
            kr = {
              x: (te[0] - Ya[0]) * Z,
              y: (te[1] - Ya[1]) * Z
            }, r.hoverData.justStartedPan = !1;
          } else
            kr = {
              x: Ee[0] * Z,
              y: Ee[1] * Z
            };
          K.panBy(kr), K.emit("dragpan"), r.hoverData.dragged = !0;
        }
        te = r.projectIntoViewport(M.clientX, M.clientY);
      } else if (De[4] == 1 && (me == null || me.pannable())) {
        if (Ke) {
          if (!r.hoverData.dragging && K.boxSelectionEnabled() && (wt || !K.panningEnabled() || !K.userPanningEnabled()))
            er();
          else if (!r.hoverData.selecting && K.panningEnabled() && K.userPanningEnabled()) {
            var mr = s(me, r.hoverData.downs);
            mr && (r.hoverData.dragging = !0, r.hoverData.justStartedPan = !0, De[4] = 0, r.data.bgActivePosistion = Yr(fe), r.redrawHint("select", !0), r.redraw());
          }
          me && me.pannable() && me.active() && me.unactivate();
        }
      } else {
        if (me && me.pannable() && me.active() && me.unactivate(), (!me || !me.grabbed()) && pe != Te && (Te && n(Te, ["mouseout", "tapdragout"], M, {
          x: te[0],
          y: te[1]
        }), pe && n(pe, ["mouseover", "tapdragover"], M, {
          x: te[0],
          y: te[1]
        }), r.hoverData.last = pe), me)
          if (Ke) {
            if (K.boxSelectionEnabled() && wt)
              me && me.grabbed() && (y(ke), me.emit("freeon"), ke.emit("free"), r.dragData.didDrag && (me.emit("dragfreeon"), ke.emit("dragfree"))), er();
            else if (me && me.grabbed() && r.nodeIsDraggable(me)) {
              var Et = !r.dragData.didDrag;
              Et && r.redrawHint("eles", !0), r.dragData.didDrag = !0, r.hoverData.draggingEles || p(ke, {
                inDragLayer: !0
              });
              var dt = {
                x: 0,
                y: 0
              };
              if (ae(Ee[0]) && ae(Ee[1]) && (dt.x += Ee[0], dt.y += Ee[1], Et)) {
                var xt = r.hoverData.dragDelta;
                xt && ae(xt[0]) && ae(xt[1]) && (dt.x += xt[0], dt.y += xt[1]);
              }
              r.hoverData.draggingEles = !0, ke.silentShift(dt).emit("position drag"), r.redrawHint("drag", !0), r.redraw();
            }
          } else
            Ft();
        W = !0;
      }
      if (De[2] = te[0], De[3] = te[1], W)
        return M.stopPropagation && M.stopPropagation(), M.preventDefault && M.preventDefault(), !1;
    }
  }, !1);
  var L, R, I;
  r.registerBinding(e, "mouseup", function(M) {
    if (!(r.hoverData.which === 1 && M.which !== 1 && r.hoverData.capture)) {
      var q = r.hoverData.capture;
      if (q) {
        r.hoverData.capture = !1;
        var W = r.cy, K = r.projectIntoViewport(M.clientX, M.clientY), Z = r.selection, ue = r.findNearestElement(K[0], K[1], !0, !1), te = r.dragData.possibleDragElements, fe = r.hoverData.down, xe = i(M);
        if (r.data.bgActivePosistion && (r.redrawHint("select", !0), r.redraw()), r.hoverData.tapholdCancelled = !0, r.data.bgActivePosistion = void 0, fe && fe.unactivate(), r.hoverData.which === 3) {
          var De = {
            originalEvent: M,
            type: "cxttapend",
            position: {
              x: K[0],
              y: K[1]
            }
          };
          if (fe ? fe.emit(De) : W.emit(De), !r.hoverData.cxtDragged) {
            var pe = {
              originalEvent: M,
              type: "cxttap",
              position: {
                x: K[0],
                y: K[1]
              }
            };
            fe ? fe.emit(pe) : W.emit(pe);
          }
          r.hoverData.cxtDragged = !1, r.hoverData.which = null;
        } else if (r.hoverData.which === 1) {
          if (n(ue, ["mouseup", "tapend", "vmouseup"], M, {
            x: K[0],
            y: K[1]
          }), !r.dragData.didDrag && // didn't move a node around
          !r.hoverData.dragged && // didn't pan
          !r.hoverData.selecting && // not box selection
          !r.hoverData.isOverThresholdDrag && (n(fe, ["click", "tap", "vclick"], M, {
            x: K[0],
            y: K[1]
          }), R = !1, M.timeStamp - I <= W.multiClickDebounceTime() ? (L && clearTimeout(L), R = !0, I = null, n(fe, ["dblclick", "dbltap", "vdblclick"], M, {
            x: K[0],
            y: K[1]
          })) : (L = setTimeout(function() {
            R || n(fe, ["oneclick", "onetap", "voneclick"], M, {
              x: K[0],
              y: K[1]
            });
          }, W.multiClickDebounceTime()), I = M.timeStamp)), fe == null && !r.dragData.didDrag && !r.hoverData.selecting && !r.hoverData.dragged && !i(M) && (W.$(t).unselect(["tapunselect"]), te.length > 0 && r.redrawHint("eles", !0), r.dragData.possibleDragElements = te = W.collection()), ue == fe && !r.dragData.didDrag && !r.hoverData.selecting && ue != null && ue._private.selectable && (r.hoverData.dragging || (W.selectionType() === "additive" || xe ? ue.selected() ? ue.unselect(["tapunselect"]) : ue.select(["tapselect"]) : xe || (W.$(t).unmerge(ue).unselect(["tapunselect"]), ue.select(["tapselect"]))), r.redrawHint("eles", !0)), r.hoverData.selecting) {
            var Te = W.collection(r.getAllInBox(Z[0], Z[1], Z[2], Z[3]));
            r.redrawHint("select", !0), Te.length > 0 && r.redrawHint("eles", !0), W.emit({
              type: "boxend",
              originalEvent: M,
              position: {
                x: K[0],
                y: K[1]
              }
            });
            var me = function(Ke) {
              return Ke.selectable() && !Ke.selected();
            };
            W.selectionType() === "additive" || xe || W.$(t).unmerge(Te).unselect(), Te.emit("box").stdFilter(me).select().emit("boxselect"), r.redraw();
          }
          if (r.hoverData.dragging && (r.hoverData.dragging = !1, r.redrawHint("select", !0), r.redrawHint("eles", !0), r.redraw()), !Z[4]) {
            r.redrawHint("drag", !0), r.redrawHint("eles", !0);
            var Ee = fe && fe.grabbed();
            y(te), Ee && (fe.emit("freeon"), te.emit("free"), r.dragData.didDrag && (fe.emit("dragfreeon"), te.emit("dragfree")));
          }
        }
        Z[4] = 0, r.hoverData.down = null, r.hoverData.cxtStarted = !1, r.hoverData.draggingEles = !1, r.hoverData.selecting = !1, r.hoverData.isOverThresholdDrag = !1, r.dragData.didDrag = !1, r.hoverData.dragged = !1, r.hoverData.dragDelta = [], r.hoverData.mdownPos = null, r.hoverData.mdownGPos = null, r.hoverData.which = null;
      }
    }
  }, !1);
  var O = [], N = 4, k, P = 1e5, B = function(M, q) {
    for (var W = 0; W < M.length; W++)
      if (M[W] % q !== 0)
        return !1;
    return !0;
  }, _ = function(M) {
    for (var q = Math.abs(M[0]), W = 1; W < M.length; W++)
      if (Math.abs(M[W]) !== q)
        return !1;
    return !0;
  }, F = function(M) {
    var q = !1, W = M.deltaY;
    if (W == null && (M.wheelDeltaY != null ? W = M.wheelDeltaY / 4 : M.wheelDelta != null && (W = M.wheelDelta / 4)), k == null)
      if (O.length >= N) {
        var K = O;
        if (k = B(K, 5), !k) {
          var Z = Math.abs(K[0]);
          k = _(K) && Z > 5;
        }
        if (k)
          for (var ue = 0; ue < K.length; ue++)
            P = Math.min(Math.abs(K[ue]), P);
      } else
        O.push(W), q = !0;
    else
      k && (P = Math.min(Math.abs(W), P));
    if (!r.scrollingPage) {
      var te = r.cy, fe = te.zoom(), xe = te.pan(), De = r.projectIntoViewport(M.clientX, M.clientY), pe = [De[0] * fe + xe.x, De[1] * fe + xe.y];
      if (r.hoverData.draggingEles || r.hoverData.dragging || r.hoverData.cxtStarted || C()) {
        M.preventDefault();
        return;
      }
      if (te.panningEnabled() && te.userPanningEnabled() && te.zoomingEnabled() && te.userZoomingEnabled()) {
        M.preventDefault(), r.data.wheelZooming = !0, clearTimeout(r.data.wheelTimeout), r.data.wheelTimeout = setTimeout(function() {
          r.data.wheelZooming = !1, r.redrawHint("eles", !0), r.redraw();
        }, 150);
        var Te;
        q && Math.abs(W) > 5 && (W = lo(W) * 5), Te = W / -250, k && (Te /= P, Te *= 3), Te = Te * r.wheelSensitivity;
        var me = M.deltaMode === 1;
        me && (Te *= 33);
        var Ee = te.zoom() * Math.pow(10, Te);
        M.type === "gesturechange" && (Ee = r.gestureStartZoom * M.scale), te.zoom({
          level: Ee,
          renderedPosition: {
            x: pe[0],
            y: pe[1]
          }
        }), te.emit(M.type === "gesturechange" ? "pinchzoom" : "scrollzoom");
      }
    }
  };
  r.registerBinding(r.container, "wheel", F, !0), r.registerBinding(e, "scroll", function(M) {
    r.scrollingPage = !0, clearTimeout(r.scrollingPageTimeout), r.scrollingPageTimeout = setTimeout(function() {
      r.scrollingPage = !1;
    }, 250);
  }, !0), r.registerBinding(r.container, "gesturestart", function(M) {
    r.gestureStartZoom = r.cy.zoom(), r.hasTouchStarted || M.preventDefault();
  }, !0), r.registerBinding(r.container, "gesturechange", function(j) {
    r.hasTouchStarted || F(j);
  }, !0), r.registerBinding(r.container, "mouseout", function(M) {
    var q = r.projectIntoViewport(M.clientX, M.clientY);
    r.cy.emit({
      originalEvent: M,
      type: "mouseout",
      position: {
        x: q[0],
        y: q[1]
      }
    });
  }, !1), r.registerBinding(r.container, "mouseover", function(M) {
    var q = r.projectIntoViewport(M.clientX, M.clientY);
    r.cy.emit({
      originalEvent: M,
      type: "mouseover",
      position: {
        x: q[0],
        y: q[1]
      }
    });
  }, !1);
  var G, U, H, $, X, Q, re, J, z, V, Y, ee, ne, be = function(M, q, W, K) {
    return Math.sqrt((W - M) * (W - M) + (K - q) * (K - q));
  }, Ve = function(M, q, W, K) {
    return (W - M) * (W - M) + (K - q) * (K - q);
  }, Ne;
  r.registerBinding(r.container, "touchstart", Ne = function(M) {
    if (r.hasTouchStarted = !0, !!D(M)) {
      m(), r.touchData.capture = !0, r.data.bgActivePosistion = void 0;
      var q = r.cy, W = r.touchData.now, K = r.touchData.earlier;
      if (M.touches[0]) {
        var Z = r.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
        W[0] = Z[0], W[1] = Z[1];
      }
      if (M.touches[1]) {
        var Z = r.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
        W[2] = Z[0], W[3] = Z[1];
      }
      if (M.touches[2]) {
        var Z = r.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
        W[4] = Z[0], W[5] = Z[1];
      }
      if (M.touches[1]) {
        r.touchData.singleTouchMoved = !0, y(r.dragData.touchDragEles);
        var ue = r.findContainerClientCoords();
        z = ue[0], V = ue[1], Y = ue[2], ee = ue[3], G = M.touches[0].clientX - z, U = M.touches[0].clientY - V, H = M.touches[1].clientX - z, $ = M.touches[1].clientY - V, ne = 0 <= G && G <= Y && 0 <= H && H <= Y && 0 <= U && U <= ee && 0 <= $ && $ <= ee;
        var te = q.pan(), fe = q.zoom();
        X = be(G, U, H, $), Q = Ve(G, U, H, $), re = [(G + H) / 2, (U + $) / 2], J = [(re[0] - te.x) / fe, (re[1] - te.y) / fe];
        var xe = 200, De = xe * xe;
        if (Q < De && !M.touches[2]) {
          var pe = r.findNearestElement(W[0], W[1], !0, !0), Te = r.findNearestElement(W[2], W[3], !0, !0);
          pe && pe.isNode() ? (pe.activate().emit({
            originalEvent: M,
            type: "cxttapstart",
            position: {
              x: W[0],
              y: W[1]
            }
          }), r.touchData.start = pe) : Te && Te.isNode() ? (Te.activate().emit({
            originalEvent: M,
            type: "cxttapstart",
            position: {
              x: W[0],
              y: W[1]
            }
          }), r.touchData.start = Te) : q.emit({
            originalEvent: M,
            type: "cxttapstart",
            position: {
              x: W[0],
              y: W[1]
            }
          }), r.touchData.start && (r.touchData.start._private.grabbed = !1), r.touchData.cxt = !0, r.touchData.cxtDragged = !1, r.data.bgActivePosistion = void 0, r.redraw();
          return;
        }
      }
      if (M.touches[2])
        q.boxSelectionEnabled() && M.preventDefault();
      else if (!M.touches[1]) {
        if (M.touches[0]) {
          var me = r.findNearestElements(W[0], W[1], !0, !0), Ee = me[0];
          if (Ee != null && (Ee.activate(), r.touchData.start = Ee, r.touchData.starts = me, r.nodeIsGrabbable(Ee))) {
            var ke = r.dragData.touchDragEles = q.collection(), Ke = null;
            r.redrawHint("eles", !0), r.redrawHint("drag", !0), Ee.selected() ? (Ke = q.$(function(Qe) {
              return Qe.selected() && r.nodeIsGrabbable(Qe);
            }), p(Ke, {
              addToList: ke
            })) : g(Ee, {
              addToList: ke
            }), c(Ee);
            var ut = function(wt) {
              return {
                originalEvent: M,
                type: wt,
                position: {
                  x: W[0],
                  y: W[1]
                }
              };
            };
            Ee.emit(ut("grabon")), Ke ? Ke.forEach(function(Qe) {
              Qe.emit(ut("grab"));
            }) : Ee.emit(ut("grab"));
          }
          n(Ee, ["touchstart", "tapstart", "vmousedown"], M, {
            x: W[0],
            y: W[1]
          }), Ee == null && (r.data.bgActivePosistion = {
            x: Z[0],
            y: Z[1]
          }, r.redrawHint("select", !0), r.redraw()), r.touchData.singleTouchMoved = !1, r.touchData.singleTouchStartTime = +/* @__PURE__ */ new Date(), clearTimeout(r.touchData.tapholdTimeout), r.touchData.tapholdTimeout = setTimeout(function() {
            r.touchData.singleTouchMoved === !1 && !r.pinching && !r.touchData.selecting && n(r.touchData.start, ["taphold"], M, {
              x: W[0],
              y: W[1]
            });
          }, r.tapholdDuration);
        }
      }
      if (M.touches.length >= 1) {
        for (var nt = r.touchData.startPosition = [null, null, null, null, null, null], $e = 0; $e < W.length; $e++)
          nt[$e] = K[$e] = W[$e];
        var lt = M.touches[0];
        r.touchData.startGPosition = [lt.clientX, lt.clientY];
      }
    }
  }, !1);
  var se;
  r.registerBinding(e, "touchmove", se = function(M) {
    var q = r.touchData.capture;
    if (!(!q && !D(M))) {
      var W = r.selection, K = r.cy, Z = r.touchData.now, ue = r.touchData.earlier, te = K.zoom();
      if (M.touches[0]) {
        var fe = r.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
        Z[0] = fe[0], Z[1] = fe[1];
      }
      if (M.touches[1]) {
        var fe = r.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
        Z[2] = fe[0], Z[3] = fe[1];
      }
      if (M.touches[2]) {
        var fe = r.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
        Z[4] = fe[0], Z[5] = fe[1];
      }
      var xe = r.touchData.startGPosition, De;
      if (q && M.touches[0] && xe) {
        for (var pe = [], Te = 0; Te < Z.length; Te++)
          pe[Te] = Z[Te] - ue[Te];
        var me = M.touches[0].clientX - xe[0], Ee = me * me, ke = M.touches[0].clientY - xe[1], Ke = ke * ke, ut = Ee + Ke;
        De = ut >= r.touchTapThreshold2;
      }
      if (q && r.touchData.cxt) {
        M.preventDefault();
        var nt = M.touches[0].clientX - z, $e = M.touches[0].clientY - V, lt = M.touches[1].clientX - z, Qe = M.touches[1].clientY - V, wt = Ve(nt, $e, lt, Qe), Ft = wt / Q, er = 150, Xt = er * er, kr = 1.5, Ya = kr * kr;
        if (Ft >= Ya || wt >= Xt) {
          r.touchData.cxt = !1, r.data.bgActivePosistion = void 0, r.redrawHint("select", !0);
          var mr = {
            originalEvent: M,
            type: "cxttapend",
            position: {
              x: Z[0],
              y: Z[1]
            }
          };
          r.touchData.start ? (r.touchData.start.unactivate().emit(mr), r.touchData.start = null) : K.emit(mr);
        }
      }
      if (q && r.touchData.cxt) {
        var mr = {
          originalEvent: M,
          type: "cxtdrag",
          position: {
            x: Z[0],
            y: Z[1]
          }
        };
        r.data.bgActivePosistion = void 0, r.redrawHint("select", !0), r.touchData.start ? r.touchData.start.emit(mr) : K.emit(mr), r.touchData.start && (r.touchData.start._private.grabbed = !1), r.touchData.cxtDragged = !0;
        var Et = r.findNearestElement(Z[0], Z[1], !0, !0);
        (!r.touchData.cxtOver || Et !== r.touchData.cxtOver) && (r.touchData.cxtOver && r.touchData.cxtOver.emit({
          originalEvent: M,
          type: "cxtdragout",
          position: {
            x: Z[0],
            y: Z[1]
          }
        }), r.touchData.cxtOver = Et, Et && Et.emit({
          originalEvent: M,
          type: "cxtdragover",
          position: {
            x: Z[0],
            y: Z[1]
          }
        }));
      } else if (q && M.touches[2] && K.boxSelectionEnabled())
        M.preventDefault(), r.data.bgActivePosistion = void 0, this.lastThreeTouch = +/* @__PURE__ */ new Date(), r.touchData.selecting || K.emit({
          originalEvent: M,
          type: "boxstart",
          position: {
            x: Z[0],
            y: Z[1]
          }
        }), r.touchData.selecting = !0, r.touchData.didSelect = !0, W[4] = 1, !W || W.length === 0 || W[0] === void 0 ? (W[0] = (Z[0] + Z[2] + Z[4]) / 3, W[1] = (Z[1] + Z[3] + Z[5]) / 3, W[2] = (Z[0] + Z[2] + Z[4]) / 3 + 1, W[3] = (Z[1] + Z[3] + Z[5]) / 3 + 1) : (W[2] = (Z[0] + Z[2] + Z[4]) / 3, W[3] = (Z[1] + Z[3] + Z[5]) / 3), r.redrawHint("select", !0), r.redraw();
      else if (q && M.touches[1] && !r.touchData.didSelect && K.zoomingEnabled() && K.panningEnabled() && K.userZoomingEnabled() && K.userPanningEnabled()) {
        M.preventDefault(), r.data.bgActivePosistion = void 0, r.redrawHint("select", !0);
        var dt = r.dragData.touchDragEles;
        if (dt) {
          r.redrawHint("drag", !0);
          for (var xt = 0; xt < dt.length; xt++) {
            var Xa = dt[xt]._private;
            Xa.grabbed = !1, Xa.rscratch.inDragLayer = !1;
          }
        }
        var _t = r.touchData.start, nt = M.touches[0].clientX - z, $e = M.touches[0].clientY - V, lt = M.touches[1].clientX - z, Qe = M.touches[1].clientY - V, Lo = be(nt, $e, lt, Qe), jc = Lo / X;
        if (ne) {
          var ev = nt - G, tv = $e - U, rv = lt - H, av = Qe - $, nv = (ev + rv) / 2, iv = (tv + av) / 2, ua = K.zoom(), jn = ua * jc, $a = K.pan(), Ro = J[0] * ua + $a.x, Io = J[1] * ua + $a.y, sv = {
            x: -jn / ua * (Ro - $a.x - nv) + Ro,
            y: -jn / ua * (Io - $a.y - iv) + Io
          };
          if (_t && _t.active()) {
            var dt = r.dragData.touchDragEles;
            y(dt), r.redrawHint("drag", !0), r.redrawHint("eles", !0), _t.unactivate().emit("freeon"), dt.emit("free"), r.dragData.didDrag && (_t.emit("dragfreeon"), dt.emit("dragfree"));
          }
          K.viewport({
            zoom: jn,
            pan: sv,
            cancelOnFailedZoom: !0
          }), K.emit("pinchzoom"), X = Lo, G = nt, U = $e, H = lt, $ = Qe, r.pinching = !0;
        }
        if (M.touches[0]) {
          var fe = r.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
          Z[0] = fe[0], Z[1] = fe[1];
        }
        if (M.touches[1]) {
          var fe = r.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
          Z[2] = fe[0], Z[3] = fe[1];
        }
        if (M.touches[2]) {
          var fe = r.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
          Z[4] = fe[0], Z[5] = fe[1];
        }
      } else if (M.touches[0] && !r.touchData.didSelect) {
        var Mt = r.touchData.start, ei = r.touchData.last, Et;
        if (!r.hoverData.draggingEles && !r.swipePanning && (Et = r.findNearestElement(Z[0], Z[1], !0, !0)), q && Mt != null && M.preventDefault(), q && Mt != null && r.nodeIsDraggable(Mt))
          if (De) {
            var dt = r.dragData.touchDragEles, Mo = !r.dragData.didDrag;
            Mo && p(dt, {
              inDragLayer: !0
            }), r.dragData.didDrag = !0;
            var la = {
              x: 0,
              y: 0
            };
            if (ae(pe[0]) && ae(pe[1]) && (la.x += pe[0], la.y += pe[1], Mo)) {
              r.redrawHint("eles", !0);
              var Ot = r.touchData.dragDelta;
              Ot && ae(Ot[0]) && ae(Ot[1]) && (la.x += Ot[0], la.y += Ot[1]);
            }
            r.hoverData.draggingEles = !0, dt.silentShift(la).emit("position drag"), r.redrawHint("drag", !0), r.touchData.startPosition[0] == ue[0] && r.touchData.startPosition[1] == ue[1] && r.redrawHint("eles", !0), r.redraw();
          } else {
            var Ot = r.touchData.dragDelta = r.touchData.dragDelta || [];
            Ot.length === 0 ? (Ot.push(pe[0]), Ot.push(pe[1])) : (Ot[0] += pe[0], Ot[1] += pe[1]);
          }
        if (n(Mt || Et, ["touchmove", "tapdrag", "vmousemove"], M, {
          x: Z[0],
          y: Z[1]
        }), (!Mt || !Mt.grabbed()) && Et != ei && (ei && ei.emit({
          originalEvent: M,
          type: "tapdragout",
          position: {
            x: Z[0],
            y: Z[1]
          }
        }), Et && Et.emit({
          originalEvent: M,
          type: "tapdragover",
          position: {
            x: Z[0],
            y: Z[1]
          }
        })), r.touchData.last = Et, q)
          for (var xt = 0; xt < Z.length; xt++)
            Z[xt] && r.touchData.startPosition[xt] && De && (r.touchData.singleTouchMoved = !0);
        if (q && (Mt == null || Mt.pannable()) && K.panningEnabled() && K.userPanningEnabled()) {
          var ov = s(Mt, r.touchData.starts);
          ov && (M.preventDefault(), r.data.bgActivePosistion || (r.data.bgActivePosistion = Yr(r.touchData.startPosition)), r.swipePanning ? (K.panBy({
            x: pe[0] * te,
            y: pe[1] * te
          }), K.emit("dragpan")) : De && (r.swipePanning = !0, K.panBy({
            x: me * te,
            y: ke * te
          }), K.emit("dragpan"), Mt && (Mt.unactivate(), r.redrawHint("select", !0), r.touchData.start = null)));
          var fe = r.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
          Z[0] = fe[0], Z[1] = fe[1];
        }
      }
      for (var Te = 0; Te < Z.length; Te++)
        ue[Te] = Z[Te];
      q && M.touches.length > 0 && !r.hoverData.draggingEles && !r.swipePanning && r.data.bgActivePosistion != null && (r.data.bgActivePosistion = void 0, r.redrawHint("select", !0), r.redraw());
    }
  }, !1);
  var oe;
  r.registerBinding(e, "touchcancel", oe = function(M) {
    var q = r.touchData.start;
    r.touchData.capture = !1, q && q.unactivate();
  });
  var ve, ge, he, ye;
  if (r.registerBinding(e, "touchend", ve = function(M) {
    var q = r.touchData.start, W = r.touchData.capture;
    if (W)
      M.touches.length === 0 && (r.touchData.capture = !1), M.preventDefault();
    else
      return;
    var K = r.selection;
    r.swipePanning = !1, r.hoverData.draggingEles = !1;
    var Z = r.cy, ue = Z.zoom(), te = r.touchData.now, fe = r.touchData.earlier;
    if (M.touches[0]) {
      var xe = r.projectIntoViewport(M.touches[0].clientX, M.touches[0].clientY);
      te[0] = xe[0], te[1] = xe[1];
    }
    if (M.touches[1]) {
      var xe = r.projectIntoViewport(M.touches[1].clientX, M.touches[1].clientY);
      te[2] = xe[0], te[3] = xe[1];
    }
    if (M.touches[2]) {
      var xe = r.projectIntoViewport(M.touches[2].clientX, M.touches[2].clientY);
      te[4] = xe[0], te[5] = xe[1];
    }
    q && q.unactivate();
    var De;
    if (r.touchData.cxt) {
      if (De = {
        originalEvent: M,
        type: "cxttapend",
        position: {
          x: te[0],
          y: te[1]
        }
      }, q ? q.emit(De) : Z.emit(De), !r.touchData.cxtDragged) {
        var pe = {
          originalEvent: M,
          type: "cxttap",
          position: {
            x: te[0],
            y: te[1]
          }
        };
        q ? q.emit(pe) : Z.emit(pe);
      }
      r.touchData.start && (r.touchData.start._private.grabbed = !1), r.touchData.cxt = !1, r.touchData.start = null, r.redraw();
      return;
    }
    if (!M.touches[2] && Z.boxSelectionEnabled() && r.touchData.selecting) {
      r.touchData.selecting = !1;
      var Te = Z.collection(r.getAllInBox(K[0], K[1], K[2], K[3]));
      K[0] = void 0, K[1] = void 0, K[2] = void 0, K[3] = void 0, K[4] = 0, r.redrawHint("select", !0), Z.emit({
        type: "boxend",
        originalEvent: M,
        position: {
          x: te[0],
          y: te[1]
        }
      });
      var me = function(Xt) {
        return Xt.selectable() && !Xt.selected();
      };
      Te.emit("box").stdFilter(me).select().emit("boxselect"), Te.nonempty() && r.redrawHint("eles", !0), r.redraw();
    }
    if (q != null && q.unactivate(), M.touches[2])
      r.data.bgActivePosistion = void 0, r.redrawHint("select", !0);
    else if (!M.touches[1]) {
      if (!M.touches[0]) {
        if (!M.touches[0]) {
          r.data.bgActivePosistion = void 0, r.redrawHint("select", !0);
          var Ee = r.dragData.touchDragEles;
          if (q != null) {
            var ke = q._private.grabbed;
            y(Ee), r.redrawHint("drag", !0), r.redrawHint("eles", !0), ke && (q.emit("freeon"), Ee.emit("free"), r.dragData.didDrag && (q.emit("dragfreeon"), Ee.emit("dragfree"))), n(q, ["touchend", "tapend", "vmouseup", "tapdragout"], M, {
              x: te[0],
              y: te[1]
            }), q.unactivate(), r.touchData.start = null;
          } else {
            var Ke = r.findNearestElement(te[0], te[1], !0, !0);
            n(Ke, ["touchend", "tapend", "vmouseup", "tapdragout"], M, {
              x: te[0],
              y: te[1]
            });
          }
          var ut = r.touchData.startPosition[0] - te[0], nt = ut * ut, $e = r.touchData.startPosition[1] - te[1], lt = $e * $e, Qe = nt + lt, wt = Qe * ue * ue;
          r.touchData.singleTouchMoved || (q || Z.$(":selected").unselect(["tapunselect"]), n(q, ["tap", "vclick"], M, {
            x: te[0],
            y: te[1]
          }), ge = !1, M.timeStamp - ye <= Z.multiClickDebounceTime() ? (he && clearTimeout(he), ge = !0, ye = null, n(q, ["dbltap", "vdblclick"], M, {
            x: te[0],
            y: te[1]
          })) : (he = setTimeout(function() {
            ge || n(q, ["onetap", "voneclick"], M, {
              x: te[0],
              y: te[1]
            });
          }, Z.multiClickDebounceTime()), ye = M.timeStamp)), q != null && !r.dragData.didDrag && q._private.selectable && wt < r.touchTapThreshold2 && !r.pinching && (Z.selectionType() === "single" ? (Z.$(t).unmerge(q).unselect(["tapunselect"]), q.select(["tapselect"])) : q.selected() ? q.unselect(["tapunselect"]) : q.select(["tapselect"]), r.redrawHint("eles", !0)), r.touchData.singleTouchMoved = !0;
        }
      }
    }
    for (var Ft = 0; Ft < te.length; Ft++)
      fe[Ft] = te[Ft];
    r.dragData.didDrag = !1, M.touches.length === 0 && (r.touchData.dragDelta = [], r.touchData.startPosition = [null, null, null, null, null, null], r.touchData.startGPosition = null, r.touchData.didSelect = !1), M.touches.length < 2 && (M.touches.length === 1 && (r.touchData.startGPosition = [M.touches[0].clientX, M.touches[0].clientY]), r.pinching = !1, r.redrawHint("eles", !0), r.redraw());
  }, !1), typeof TouchEvent > "u") {
    var we = [], Se = 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
      };
    }, Fe = function(M) {
      return {
        event: M,
        touch: Se(M)
      };
    }, Ye = function(M) {
      we.push(Fe(M));
    }, Ie = function(M) {
      for (var q = 0; q < we.length; q++) {
        var W = we[q];
        if (W.event.pointerId === M.pointerId) {
          we.splice(q, 1);
          return;
        }
      }
    }, We = function(M) {
      var q = we.filter(function(W) {
        return W.event.pointerId === M.pointerId;
      })[0];
      q.event = M, q.touch = Se(M);
    }, Ae = function(M) {
      M.touches = we.map(function(q) {
        return q.touch;
      });
    }, le = function(M) {
      return M.pointerType === "mouse" || M.pointerType === 4;
    };
    r.registerBinding(r.container, "pointerdown", function(j) {
      le(j) || (j.preventDefault(), Ye(j), Ae(j), Ne(j));
    }), r.registerBinding(r.container, "pointerup", function(j) {
      le(j) || (Ie(j), Ae(j), ve(j));
    }), r.registerBinding(r.container, "pointercancel", function(j) {
      le(j) || (Ie(j), Ae(j), oe(j));
    }), r.registerBinding(r.container, "pointermove", function(j) {
      le(j) || (j.preventDefault(), We(j), Ae(j), se(j));
    });
  }
};
var Jt = {};
Jt.generatePolygon = function(r, e) {
  return this.nodeShapes[r] = {
    renderer: this,
    name: r,
    points: e,
    draw: function(a, n, i, s, o, u) {
      this.renderer.nodeShapeImpl("polygon", a, n, i, s, o, this.points);
    },
    intersectLine: function(a, n, i, s, o, u, l, f) {
      return Aa(o, u, this.points, a, n, i / 2, s / 2, l);
    },
    checkPoint: function(a, n, i, s, o, u, l, f) {
      return Qt(a, n, this.points, u, l, s, o, [0, -1], i);
    }
  };
};
Jt.generateEllipse = function() {
  return this.nodeShapes.ellipse = {
    renderer: this,
    name: "ellipse",
    draw: function(e, t, a, n, i, s) {
      this.renderer.nodeShapeImpl(this.name, e, t, a, n, i);
    },
    intersectLine: function(e, t, a, n, i, s, o, u) {
      return Jh(i, s, e, t, a / 2 + o, n / 2 + o);
    },
    checkPoint: function(e, t, a, n, i, s, o, u) {
      return Sr(e, t, n, i, s, o, a);
    }
  };
};
Jt.generateRoundPolygon = function(r, e) {
  return this.nodeShapes[r] = {
    renderer: this,
    name: r,
    points: e,
    getOrCreateCorners: function(a, n, i, s, o, 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, c = s / 2;
      o = o === "auto" ? Rf(i, s) : o;
      for (var v = new Array(e.length / 2), h = 0; h < e.length / 2; h++)
        v[h] = {
          x: a + f * e[h * 2],
          y: n + c * e[h * 2 + 1]
        };
      var d, p, g, y, b = v.length;
      for (p = v[b - 1], d = 0; d < b; d++)
        g = v[d % b], y = v[(d + 1) % b], u[l][d] = To(p, g, y, o), p = g, g = y;
      return u[l];
    },
    draw: function(a, n, i, s, o, u, l) {
      this.renderer.nodeShapeImpl("round-polygon", a, n, i, s, o, this.points, this.getOrCreateCorners(n, i, s, o, u, l, "drawCorners"));
    },
    intersectLine: function(a, n, i, s, o, u, l, f, c) {
      return jh(o, u, this.points, a, n, i, s, l, this.getOrCreateCorners(a, n, i, s, f, c, "corners"));
    },
    checkPoint: function(a, n, i, s, o, u, l, f, c) {
      return Qh(a, n, this.points, u, l, s, o, this.getOrCreateCorners(u, l, s, o, f, c, "corners"));
    }
  };
};
Jt.generateRoundRectangle = function() {
  return this.nodeShapes["round-rectangle"] = this.nodeShapes.roundrectangle = {
    renderer: this,
    name: "round-rectangle",
    points: mt(4, 0),
    draw: function(e, t, a, n, i, s) {
      this.renderer.nodeShapeImpl(this.name, e, t, a, n, i, this.points, s);
    },
    intersectLine: function(e, t, a, n, i, s, o, u) {
      return Af(i, s, e, t, a, n, o, u);
    },
    checkPoint: function(e, t, a, n, i, s, o, u) {
      var l = n / 2, f = i / 2;
      u = u === "auto" ? ur(n, i) : u, u = Math.min(l, f, u);
      var c = u * 2;
      return !!(Qt(e, t, this.points, s, o, n, i - c, [0, -1], a) || Qt(e, t, this.points, s, o, n - c, i, [0, -1], a) || Sr(e, t, c, c, s - l + u, o - f + u, a) || Sr(e, t, c, c, s + l - u, o - f + u, a) || Sr(e, t, c, c, s + l - u, o + f - u, a) || Sr(e, t, c, c, s - l + u, o + f - u, a));
    }
  };
};
Jt.generateCutRectangle = function() {
  return this.nodeShapes["cut-rectangle"] = this.nodeShapes.cutrectangle = {
    renderer: this,
    name: "cut-rectangle",
    cornerLength: co(),
    points: mt(4, 0),
    draw: function(e, t, a, n, i, s) {
      this.renderer.nodeShapeImpl(this.name, e, t, a, n, i, null, s);
    },
    generateCutTrianglePts: function(e, t, a, n, i) {
      var s = i === "auto" ? this.cornerLength : i, o = t / 2, u = e / 2, l = a - u, f = a + u, c = n - o, v = n + o;
      return {
        topLeft: [l, c + s, l + s, c, l + s, c + s],
        topRight: [f - s, c, f, c + s, f - s, c + s],
        bottomRight: [f, v - s, f - s, v, f - s, v - s],
        bottomLeft: [l + s, v, l, v - s, l + s, v - s]
      };
    },
    intersectLine: function(e, t, a, n, i, s, o, u) {
      var l = this.generateCutTrianglePts(a + 2 * o, n + 2 * o, e, t, 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, s, f, e, t);
    },
    checkPoint: function(e, t, a, n, i, s, o, u) {
      var l = u === "auto" ? this.cornerLength : u;
      if (Qt(e, t, this.points, s, o, n, i - 2 * l, [0, -1], a) || Qt(e, t, this.points, s, o, n - 2 * l, i, [0, -1], a))
        return !0;
      var f = this.generateCutTrianglePts(n, i, s, o);
      return Ct(e, t, f.topLeft) || Ct(e, t, f.topRight) || Ct(e, t, f.bottomRight) || Ct(e, t, f.bottomLeft);
    }
  };
};
Jt.generateBarrel = function() {
  return this.nodeShapes.barrel = {
    renderer: this,
    name: "barrel",
    points: mt(4, 0),
    draw: function(e, t, a, n, i, s) {
      this.renderer.nodeShapeImpl(this.name, e, t, a, n, i);
    },
    intersectLine: function(e, t, a, n, i, s, o, u) {
      var l = 0.15, f = 0.5, c = 0.85, v = this.generateBarrelBezierPts(a + 2 * o, n + 2 * o, e, t), h = function(g) {
        var y = Wr({
          x: g[0],
          y: g[1]
        }, {
          x: g[2],
          y: g[3]
        }, {
          x: g[4],
          y: g[5]
        }, l), b = Wr({
          x: g[0],
          y: g[1]
        }, {
          x: g[2],
          y: g[3]
        }, {
          x: g[4],
          y: g[5]
        }, f), m = Wr({
          x: g[0],
          y: g[1]
        }, {
          x: g[2],
          y: g[3]
        }, {
          x: g[4],
          y: g[5]
        }, c);
        return [g[0], g[1], y.x, y.y, b.x, b.y, m.x, m.y, g[4], g[5]];
      }, d = [].concat(h(v.topLeft), h(v.topRight), h(v.bottomRight), h(v.bottomLeft));
      return Aa(i, s, d, e, t);
    },
    generateBarrelBezierPts: function(e, t, a, n) {
      var i = t / 2, s = e / 2, o = a - s, u = a + s, l = n - i, f = n + i, c = Ns(e, t), v = c.heightOffset, h = c.widthOffset, d = c.ctrlPtOffsetPct * e, p = {
        topLeft: [o, l + v, o + d, l, o + h, l],
        topRight: [u - h, l, u - d, l, u, l + v],
        bottomRight: [u, f - v, u - d, f, u - h, f],
        bottomLeft: [o + h, f, o + d, f, o, f - v]
      };
      return p.topLeft.isTop = !0, p.topRight.isTop = !0, p.bottomLeft.isBottom = !0, p.bottomRight.isBottom = !0, p;
    },
    checkPoint: function(e, t, a, n, i, s, o, u) {
      var l = Ns(n, i), f = l.heightOffset, c = l.widthOffset;
      if (Qt(e, t, this.points, s, o, n, i - 2 * f, [0, -1], a) || Qt(e, t, this.points, s, o, n - 2 * c, i, [0, -1], a))
        return !0;
      for (var v = this.generateBarrelBezierPts(n, i, s, o), h = function(T, C, D) {
        var A = D[4], L = D[2], R = D[0], I = D[5], O = D[1], N = Math.min(A, R), k = Math.max(A, R), P = Math.min(I, O), B = Math.max(I, O);
        if (N <= T && T <= k && P <= C && C <= B) {
          var _ = ed(A, L, R), F = $h(_[0], _[1], _[2], T), G = F.filter(function(U) {
            return 0 <= U && U <= 1;
          });
          if (G.length > 0)
            return G[0];
        }
        return null;
      }, d = Object.keys(v), p = 0; p < d.length; p++) {
        var g = d[p], y = v[g], b = h(e, t, y);
        if (b != null) {
          var m = y[5], E = y[3], x = y[1], S = it(m, E, x, b);
          if (y.isTop && S <= t || y.isBottom && t <= S)
            return !0;
        }
      }
      return !1;
    }
  };
};
Jt.generateBottomRoundrectangle = function() {
  return this.nodeShapes["bottom-round-rectangle"] = this.nodeShapes.bottomroundrectangle = {
    renderer: this,
    name: "bottom-round-rectangle",
    points: mt(4, 0),
    draw: function(e, t, a, n, i, s) {
      this.renderer.nodeShapeImpl(this.name, e, t, a, n, i, this.points, s);
    },
    intersectLine: function(e, t, a, n, i, s, o, u) {
      var l = e - (a / 2 + o), f = t - (n / 2 + o), c = f, v = e + (a / 2 + o), h = ar(i, s, e, t, l, f, v, c, !1);
      return h.length > 0 ? h : Af(i, s, e, t, a, n, o, u);
    },
    checkPoint: function(e, t, a, n, i, s, o, u) {
      u = u === "auto" ? ur(n, i) : u;
      var l = 2 * u;
      if (Qt(e, t, this.points, s, o, n, i - l, [0, -1], a) || Qt(e, t, this.points, s, o, n - l, i, [0, -1], a))
        return !0;
      var f = n / 2 + 2 * a, c = i / 2 + 2 * a, v = [s - f, o - c, s - f, o, s + f, o, s + f, o - c];
      return !!(Ct(e, t, v) || Sr(e, t, l, l, s + n / 2 - u, o + i / 2 - u, a) || Sr(e, t, l, l, s - n / 2 + u, o + i / 2 - u, a));
    }
  };
};
Jt.registerNodeShapes = function() {
  var r = this.nodeShapes = {}, e = this;
  this.generateEllipse(), this.generatePolygon("triangle", mt(3, 0)), this.generateRoundPolygon("round-triangle", mt(3, 0)), this.generatePolygon("rectangle", mt(4, 0)), r.square = r.rectangle, this.generateRoundRectangle(), this.generateCutRectangle(), this.generateBarrel(), this.generateBottomRoundrectangle();
  {
    var t = [0, 1, 1, 0, 0, -1, -1, 0];
    this.generatePolygon("diamond", t), this.generateRoundPolygon("round-diamond", t);
  }
  this.generatePolygon("pentagon", mt(5, 0)), this.generateRoundPolygon("round-pentagon", mt(5, 0)), this.generatePolygon("hexagon", mt(6, 0)), this.generateRoundPolygon("round-hexagon", mt(6, 0)), this.generatePolygon("heptagon", mt(7, 0)), this.generateRoundPolygon("round-heptagon", mt(7, 0)), this.generatePolygon("octagon", mt(8, 0)), this.generateRoundPolygon("round-octagon", mt(8, 0));
  var a = new Array(20);
  {
    var n = Ps(5, 0), i = Ps(5, Math.PI / 5), s = 0.5 * (3 - Math.sqrt(5));
    s *= 1.57;
    for (var o = 0; o < i.length / 2; o++)
      i[o * 2] *= s, i[o * 2 + 1] *= s;
    for (var o = 0; o < 20 / 4; o++)
      a[o * 4] = n[o * 2], a[o * 4 + 1] = n[o * 2 + 1], a[o * 4 + 2] = i[o * 2], a[o * 4 + 3] = i[o * 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);
  }
  r.makePolygon = function(l) {
    var f = l.join("$"), c = "polygon-" + f, v;
    return (v = this[c]) ? v : e.generatePolygon(c, l);
  };
};
var qa = {};
qa.timeToRender = function() {
  return this.redrawTotalTime / this.redrawCount;
};
qa.redraw = function(r) {
  r = r || Cf();
  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 = r;
};
qa.beforeRender = function(r, e) {
  if (!this.destroyed) {
    e == null && qe("Priority is not optional for beforeRender");
    var t = this.beforeRenderCallbacks;
    t.push({
      fn: r,
      priority: e
    }), t.sort(function(a, n) {
      return n.priority - a.priority;
    });
  }
};
var Vl = function(e, t, a) {
  for (var n = e.beforeRenderCallbacks, i = 0; i < n.length; i++)
    n[i].fn(t, a);
};
qa.startRenderLoop = function() {
  var r = this, e = r.cy;
  if (!r.renderLoopStarted) {
    r.renderLoopStarted = !0;
    var t = function(n) {
      if (!r.destroyed) {
        if (!e.batching())
          if (r.requestedFrame && !r.skipFrame) {
            Vl(r, !0, n);
            var i = Zt();
            r.render(r.renderOptions);
            var s = r.lastDrawTime = Zt();
            r.averageRedrawTime === void 0 && (r.averageRedrawTime = s - i), r.redrawCount === void 0 && (r.redrawCount = 0), r.redrawCount++, r.redrawTotalTime === void 0 && (r.redrawTotalTime = 0);
            var o = s - i;
            r.redrawTotalTime += o, r.lastRedrawTime = o, r.averageRedrawTime = r.averageRedrawTime / 2 + o / 2, r.requestedFrame = !1;
          } else
            Vl(r, !1, n);
        r.skipFrame = !1, Tn(t);
      }
    };
    Tn(t);
  }
};
var yy = function(e) {
  this.init(e);
}, Lc = yy, oa = Lc.prototype;
oa.clientFunctions = ["redrawHint", "render", "renderTo", "matchCanvasSize", "nodeShapeImpl", "arrowShapeImpl"];
oa.init = function(r) {
  var e = this;
  e.options = r, e.cy = r.cy;
  var t = e.container = r.cy.container(), a = e.cy.window();
  if (a) {
    var n = a.document, i = n.head, s = "__________cytoscape_stylesheet", o = "__________cytoscape_container", u = n.getElementById(s) != null;
    if (t.className.indexOf(o) < 0 && (t.className = (t.className || "") + " " + o), !u) {
      var l = n.createElement("style");
      l.id = s, l.textContent = "." + o + " { position: relative; }", i.insertBefore(l, i.children[0]);
    }
    var f = a.getComputedStyle(t), c = f.getPropertyValue("position");
    c === "static" && Pe("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 = r.showFps, e.debug = r.debug, e.webgl = r.webgl, e.hideEdgesOnViewport = r.hideEdgesOnViewport, e.textureOnViewport = r.textureOnViewport, e.wheelSensitivity = r.wheelSensitivity, e.motionBlurEnabled = r.motionBlur, e.forcedPixelRatio = ae(r.pixelRatio) ? r.pixelRatio : null, e.motionBlur = r.motionBlur, e.motionBlurOpacity = r.motionBlurOpacity, e.motionBlurTransparency = 1 - e.motionBlurOpacity, e.motionBlurPxRatio = 1, e.mbPxRBlurry = 1, e.minMbLowQualFrames = 4, e.fullQualityMb = !1, e.clearedForMotionBlur = [], e.desktopTapThreshold = r.desktopTapThreshold, e.desktopTapThreshold2 = r.desktopTapThreshold * r.desktopTapThreshold, e.touchTapThreshold = r.touchTapThreshold, e.touchTapThreshold2 = r.touchTapThreshold * r.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(r, e) {
  var t = this, a = t.cy;
  if (!this.destroyed) {
    if (r === "init") {
      t.load();
      return;
    }
    if (r === "destroy") {
      t.destroy();
      return;
    }
    (r === "add" || r === "remove" || r === "move" && a.hasCompoundNodes() || r === "load" || r === "zorder" || r === "mount") && t.invalidateCachedZSortedEles(), r === "viewport" && t.redrawHint("select", !0), r === "gc" && t.redrawHint("gc", !0), (r === "load" || r === "resize" || r === "mount") && (t.invalidateContainerClientCoordsCache(), t.matchCanvasSize(t.container)), t.redrawHint("eles", !0), t.redrawHint("drag", !0), this.startRenderLoop(), this.redraw();
  }
};
oa.destroy = function() {
  var r = this;
  r.destroyed = !0, r.cy.stopAnimationLoop();
  for (var e = 0; e < r.bindings.length; e++) {
    var t = r.bindings[e], a = t, n = a.target;
    (n.off || n.removeEventListener).apply(n, a.args);
  }
  if (r.bindings = [], r.beforeRenderCallbacks = [], r.onUpdateEleCalcsFns = [], r.removeObserver && r.removeObserver.disconnect(), r.styleObserver && r.styleObserver.disconnect(), r.resizeObserver && r.resizeObserver.disconnect(), r.labelCalcDiv)
    try {
      document.body.removeChild(r.labelCalcDiv);
    } catch {
    }
};
oa.isHeadless = function() {
  return !1;
};
[xo, Sc, Ac, sa, Jt, qa].forEach(function(r) {
  de(oa, r);
});
var Es = 1e3 / 60, Rc = {
  setupDequeueing: function(e) {
    return function() {
      var a = this, n = this.renderer;
      if (!a.dequeueingSetup) {
        a.dequeueingSetup = !0;
        var i = _a(function() {
          n.redrawHint("eles", !0), n.redrawHint("drag", !0), n.redraw();
        }, e.deqRedrawThreshold), s = function(l, f) {
          var c = Zt(), v = n.averageRedrawTime, h = n.lastRedrawTime, d = [], p = n.cy.extent(), g = n.getPixelRatio();
          for (l || n.flushRenderedStyleQueue(); ; ) {
            var y = Zt(), b = y - c, m = y - f;
            if (h < Es) {
              var E = Es - (l ? v : 0);
              if (m >= e.deqFastCost * E)
                break;
            } else if (l) {
              if (b >= e.deqCost * h || b >= e.deqAvgCost * v)
                break;
            } else if (m >= e.deqNoDrawCost * Es)
              break;
            var x = e.deq(a, g, p);
            if (x.length > 0)
              for (var S = 0; S < x.length; S++)
                d.push(x[S]);
            else
              break;
          }
          d.length > 0 && (e.onDeqd(a, d), !l && e.shouldRedraw(a, d, g, p) && i());
        }, o = e.priority || so;
        n.beforeRender(s, o(a));
      }
    };
  }
}, my = /* @__PURE__ */ function() {
  function r(e) {
    var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Cn;
    hr(this, r), this.idsByKey = new Kt(), this.keyForId = new Kt(), this.cachesByLvl = new Kt(), this.lvls = [], this.getKey = e, this.doesEleInvalidateKey = t;
  }
  return dr(r, [{
    key: "getIdsFor",
    value: function(t) {
      t == null && qe("Can not get id list for null key");
      var a = this.idsByKey, n = this.idsByKey.get(t);
      return n || (n = new ra(), a.set(t, n)), n;
    }
  }, {
    key: "addIdForKey",
    value: function(t, a) {
      t != null && this.getIdsFor(t).add(a);
    }
  }, {
    key: "deleteIdForKey",
    value: function(t, a) {
      t != null && this.getIdsFor(t).delete(a);
    }
  }, {
    key: "getNumberOfIdsForKey",
    value: function(t) {
      return t == null ? 0 : this.getIdsFor(t).size;
    }
  }, {
    key: "updateKeyMappingFor",
    value: function(t) {
      var a = t.id(), n = this.keyForId.get(a), i = this.getKey(t);
      this.deleteIdForKey(n, a), this.addIdForKey(i, a), this.keyForId.set(a, i);
    }
  }, {
    key: "deleteKeyMappingFor",
    value: function(t) {
      var a = t.id(), n = this.keyForId.get(a);
      this.deleteIdForKey(n, a), this.keyForId.delete(a);
    }
  }, {
    key: "keyHasChangedFor",
    value: function(t) {
      var a = t.id(), n = this.keyForId.get(a), i = this.getKey(t);
      return n !== i;
    }
  }, {
    key: "isInvalid",
    value: function(t) {
      return this.keyHasChangedFor(t) || this.doesEleInvalidateKey(t);
    }
  }, {
    key: "getCachesAt",
    value: function(t) {
      var a = this.cachesByLvl, n = this.lvls, i = a.get(t);
      return i || (i = new Kt(), a.set(t, i), n.push(t)), i;
    }
  }, {
    key: "getCache",
    value: function(t, a) {
      return this.getCachesAt(a).get(t);
    }
  }, {
    key: "get",
    value: function(t, a) {
      var n = this.getKey(t), i = this.getCache(n, a);
      return i != null && this.updateKeyMappingFor(t), i;
    }
  }, {
    key: "getForCachedKey",
    value: function(t, a) {
      var n = this.keyForId.get(t.id()), i = this.getCache(n, a);
      return i;
    }
  }, {
    key: "hasCache",
    value: function(t, a) {
      return this.getCachesAt(a).has(t);
    }
  }, {
    key: "has",
    value: function(t, a) {
      var n = this.getKey(t);
      return this.hasCache(n, a);
    }
  }, {
    key: "setCache",
    value: function(t, a, n) {
      n.key = t, this.getCachesAt(a).set(t, n);
    }
  }, {
    key: "set",
    value: function(t, a, n) {
      var i = this.getKey(t);
      this.setCache(i, a, n), this.updateKeyMappingFor(t);
    }
  }, {
    key: "deleteCache",
    value: function(t, a) {
      this.getCachesAt(a).delete(t);
    }
  }, {
    key: "delete",
    value: function(t, a) {
      var n = this.getKey(t);
      this.deleteCache(n, a);
    }
  }, {
    key: "invalidateKey",
    value: function(t) {
      var a = this;
      this.lvls.forEach(function(n) {
        return a.deleteCache(t, 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(t) {
      var a = t.id(), n = this.keyForId.get(a);
      this.deleteKeyMappingFor(t);
      var i = this.doesEleInvalidateKey(t);
      return i && this.invalidateKey(n), i || this.getNumberOfIdsForKey(n) === 0;
    }
  }]);
}(), Ul = 25, sn = 50, yn = -4, $s = 3, Ic = 7.99, by = 8, wy = 1024, Ey = 1024, xy = 1024, Ty = 0.2, Cy = 0.8, Dy = 10, Sy = 0.15, Ay = 0.1, Ly = 0.9, Ry = 0.9, Iy = 100, My = 1, $r = {
  dequeue: "dequeue",
  downscale: "downscale",
  highQuality: "highQuality"
}, Oy = vt({
  getKey: null,
  doesEleInvalidateKey: Cn,
  drawElement: null,
  getBoundingBox: null,
  getRotationPoint: null,
  getRotationOffset: null,
  isVisible: Ef,
  allowEdgeTxrCaching: !0,
  allowParentTxrCaching: !0
}), ba = function(e, t) {
  var a = this;
  a.renderer = e, a.onDequeues = [];
  var n = Oy(t);
  de(a, n), a.lookup = new my(n.getKey, n.doesEleInvalidateKey), a.setupDequeueing();
}, at = ba.prototype;
at.reasons = $r;
at.getTextureQueue = function(r) {
  var e = this;
  return e.eleImgCaches = e.eleImgCaches || {}, e.eleImgCaches[r] = e.eleImgCaches[r] || [];
};
at.getRetiredTextureQueue = function(r) {
  var e = this, t = e.eleImgCaches.retired = e.eleImgCaches.retired || {}, a = t[r] = t[r] || [];
  return a;
};
at.getElementQueue = function() {
  var r = this, e = r.eleCacheQueue = r.eleCacheQueue || new Ga(function(t, a) {
    return a.reqs - t.reqs;
  });
  return e;
};
at.getElementKeyToQueue = function() {
  var r = this, e = r.eleKeyToCacheQueue = r.eleKeyToCacheQueue || {};
  return e;
};
at.getElement = function(r, e, t, a, n) {
  var i = this, s = this.renderer, o = s.cy.zoom(), u = this.lookup;
  if (!e || e.w === 0 || e.h === 0 || isNaN(e.w) || isNaN(e.h) || !r.visible() || r.removed() || !i.allowEdgeTxrCaching && r.isEdge() || !i.allowParentTxrCaching && r.isParent())
    return null;
  if (a == null && (a = Math.ceil(uo(o * t))), a < yn)
    a = yn;
  else if (o >= Ic || a > $s)
    return null;
  var l = Math.pow(2, a), f = e.h * l, c = e.w * l, v = s.eleTextBiggerThanMin(r, l);
  if (!this.isVisible(r, v))
    return null;
  var h = u.get(r, a);
  if (h && h.invalidated && (h.invalidated = !1, h.texture.invalidatedWidth -= h.width), h)
    return h;
  var d;
  if (f <= Ul ? d = Ul : f <= sn ? d = sn : d = Math.ceil(f / sn) * sn, f > xy || c > Ey)
    return null;
  var p = i.getTextureQueue(d), g = p[p.length - 2], y = function() {
    return i.recycleTexture(d, c) || i.addTexture(d, c);
  };
  g || (g = p[p.length - 1]), g || (g = y()), g.width - g.usedWidth < c && (g = y());
  for (var b = function(N) {
    return N && N.scaledLabelShown === v;
  }, m = n && n === $r.dequeue, E = n && n === $r.highQuality, x = n && n === $r.downscale, S, w = a + 1; w <= $s; w++) {
    var T = u.get(r, w);
    if (T) {
      S = T;
      break;
    }
  }
  var C = S && S.level === a + 1 ? S : null, D = function() {
    g.context.drawImage(C.texture.canvas, C.x, 0, C.width, C.height, g.usedWidth, 0, c, f);
  };
  if (g.context.setTransform(1, 0, 0, 1, 0, 0), g.context.clearRect(g.usedWidth, 0, c, d), b(C))
    D();
  else if (b(S))
    if (E) {
      for (var A = S.level; A > a; A--)
        C = i.getElement(r, e, t, A, $r.downscale);
      D();
    } else
      return i.queueElement(r, S.level - 1), S;
  else {
    var L;
    if (!m && !E && !x)
      for (var R = a - 1; R >= yn; R--) {
        var I = u.get(r, R);
        if (I) {
          L = I;
          break;
        }
      }
    if (b(L))
      return i.queueElement(r, a), L;
    g.context.translate(g.usedWidth, 0), g.context.scale(l, l), this.drawElement(g.context, r, e, v, !1), g.context.scale(1 / l, 1 / l), g.context.translate(-g.usedWidth, 0);
  }
  return h = {
    x: g.usedWidth,
    texture: g,
    level: a,
    scale: l,
    width: c,
    height: f,
    scaledLabelShown: v
  }, g.usedWidth += Math.ceil(c + by), g.eleCaches.push(h), u.set(r, a, h), i.checkTextureFullness(g), h;
};
at.invalidateElements = function(r) {
  for (var e = 0; e < r.length; e++)
    this.invalidateElement(r[e]);
};
at.invalidateElement = function(r) {
  var e = this, t = e.lookup, a = [], n = t.isInvalid(r);
  if (n) {
    for (var i = yn; i <= $s; i++) {
      var s = t.getForCachedKey(r, i);
      s && a.push(s);
    }
    var o = t.invalidate(r);
    if (o)
      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(r);
  }
};
at.checkTextureUtility = function(r) {
  r.invalidatedWidth >= Ty * r.width && this.retireTexture(r);
};
at.checkTextureFullness = function(r) {
  var e = this, t = e.getTextureQueue(r.height);
  r.usedWidth / r.width > Cy && r.fullnessChecks >= Dy ? or(t, r) : r.fullnessChecks++;
};
at.retireTexture = function(r) {
  var e = this, t = r.height, a = e.getTextureQueue(t), n = this.lookup;
  or(a, r), r.retired = !0;
  for (var i = r.eleCaches, s = 0; s < i.length; s++) {
    var o = i[s];
    n.deleteCache(o.key, o.level);
  }
  oo(i);
  var u = e.getRetiredTextureQueue(t);
  u.push(r);
};
at.addTexture = function(r, e) {
  var t = this, a = t.getTextureQueue(r), n = {};
  return a.push(n), n.eleCaches = [], n.height = r, n.width = Math.max(wy, e), n.usedWidth = 0, n.invalidatedWidth = 0, n.fullnessChecks = 0, n.canvas = t.renderer.makeOffscreenCanvas(n.width, n.height), n.context = n.canvas.getContext("2d"), n;
};
at.recycleTexture = function(r, e) {
  for (var t = this, a = t.getTextureQueue(r), n = t.getRetiredTextureQueue(r), i = 0; i < n.length; i++) {
    var s = n[i];
    if (s.width >= e)
      return s.retired = !1, s.usedWidth = 0, s.invalidatedWidth = 0, s.fullnessChecks = 0, oo(s.eleCaches), s.context.setTransform(1, 0, 0, 1, 0, 0), s.context.clearRect(0, 0, s.width, s.height), or(n, s), a.push(s), s;
  }
};
at.queueElement = function(r, e) {
  var t = this, a = t.getElementQueue(), n = t.getElementKeyToQueue(), i = this.getKey(r), s = n[i];
  if (s)
    s.level = Math.max(s.level, e), s.eles.merge(r), s.reqs++, a.updateItem(s);
  else {
    var o = {
      eles: r.spawn().merge(r),
      level: e,
      reqs: 1,
      key: i
    };
    a.push(o), n[i] = o;
  }
};
at.dequeue = function(r) {
  for (var e = this, t = e.getElementQueue(), a = e.getElementKeyToQueue(), n = [], i = e.lookup, s = 0; s < My && t.size() > 0; s++) {
    var o = t.pop(), u = o.key, l = o.eles[0], f = i.hasCache(l, o.level);
    if (a[u] = null, f)
      continue;
    n.push(o);
    var c = e.getBoundingBox(l);
    e.getElement(l, c, r, o.level, $r.dequeue);
  }
  return n;
};
at.removeFromQueue = function(r) {
  var e = this, t = e.getElementQueue(), a = e.getElementKeyToQueue(), n = this.getKey(r), i = a[n];
  i != null && (i.eles.length === 1 ? (i.reqs = io, t.updateItem(i), t.pop(), a[n] = null) : i.eles.unmerge(r));
};
at.onDequeue = function(r) {
  this.onDequeues.push(r);
};
at.offDequeue = function(r) {
  or(this.onDequeues, r);
};
at.setupDequeueing = Rc.setupDequeueing({
  deqRedrawThreshold: Iy,
  deqCost: Sy,
  deqAvgCost: Ay,
  deqNoDrawCost: Ly,
  deqFastCost: Ry,
  deq: function(e, t, a) {
    return e.dequeue(t, a);
  },
  onDeqd: function(e, t) {
    for (var a = 0; a < e.onDequeues.length; a++) {
      var n = e.onDequeues[a];
      n(t);
    }
  },
  shouldRedraw: function(e, t, a, n) {
    for (var i = 0; i < t.length; i++)
      for (var s = t[i].eles, o = 0; o < s.length; o++) {
        var u = s[o].boundingBox();
        if (fo(u, n))
          return !0;
      }
    return !1;
  },
  priority: function(e) {
    return e.renderer.beforeRenderPriorities.eleTxrDeq;
  }
});
var Py = 1, Ea = -4, On = 2, Ny = 3.99, ky = 50, By = 50, Fy = 0.15, _y = 0.1, Gy = 0.9, zy = 0.9, Vy = 1, ql = 250, Uy = 4e3 * 4e3, Hl = 32767, qy = !0, Mc = function(e) {
  var t = this, a = t.renderer = e, n = a.cy;
  t.layersByLevel = {}, t.firstGet = !0, t.lastInvalidationTime = Zt() - 2 * ql, t.skipping = !1, t.eleTxrDeqs = n.collection(), t.scheduleElementRefinement = _a(function() {
    t.refineElementTextures(t.eleTxrDeqs), t.eleTxrDeqs.unmerge(t.eleTxrDeqs);
  }, By), a.beforeRender(function(s, o) {
    o - t.lastInvalidationTime <= ql ? t.skipping = !0 : t.skipping = !1;
  }, a.beforeRenderPriorities.lyrTxrSkip);
  var i = function(o, u) {
    return u.reqs - o.reqs;
  };
  t.layersQueue = new Ga(i), t.setupDequeueing();
}, ht = Mc.prototype, Yl = 0, Hy = Math.pow(2, 53) - 1;
ht.makeLayer = function(r, e) {
  var t = Math.pow(2, e), a = Math.ceil(r.w * t), n = Math.ceil(r.h * t), i = this.renderer.makeOffscreenCanvas(a, n), s = {
    id: Yl = ++Yl % Hy,
    bb: r,
    level: e,
    width: a,
    height: n,
    canvas: i,
    context: i.getContext("2d"),
    eles: [],
    elesQueue: [],
    reqs: 0
  }, o = s.context, u = -s.bb.x1, l = -s.bb.y1;
  return o.scale(t, t), o.translate(u, l), s;
};
ht.getLayers = function(r, e, t) {
  var a = this, n = a.renderer, i = n.cy, s = i.zoom(), o = a.firstGet;
  if (a.firstGet = !1, t == null) {
    if (t = Math.ceil(uo(s * e)), t < Ea)
      t = Ea;
    else if (s >= Ny || t > On)
      return null;
  }
  a.validateLayersElesOrdering(t, r);
  var u = a.layersByLevel, l = Math.pow(2, t), f = u[t] = u[t] || [], c, v = a.levelIsComplete(t, r), h, d = function() {
    var D = function(O) {
      if (a.validateLayersElesOrdering(O, r), a.levelIsComplete(O, r))
        return h = u[O], !0;
    }, A = function(O) {
      if (!h)
        for (var N = t + O; Ea <= N && N <= On && !D(N); N += O)
          ;
    };
    A(1), A(-1);
    for (var L = f.length - 1; L >= 0; L--) {
      var R = f[L];
      R.invalid && or(f, R);
    }
  };
  if (!v)
    d();
  else
    return f;
  var p = function() {
    if (!c) {
      c = St();
      for (var D = 0; D < r.length; D++)
        Sf(c, r[D].boundingBox());
    }
    return c;
  }, g = function(D) {
    D = D || {};
    var A = D.after;
    p();
    var L = Math.ceil(c.w * l), R = Math.ceil(c.h * l);
    if (L > Hl || R > Hl)
      return null;
    var I = L * R;
    if (I > Uy)
      return null;
    var O = a.makeLayer(c, t);
    if (A != null) {
      var N = f.indexOf(A) + 1;
      f.splice(N, 0, O);
    } else
      (D.insert === void 0 || D.insert) && f.unshift(O);
    return O;
  };
  if (a.skipping && !o)
    return null;
  for (var y = null, b = r.length / Py, m = !o, E = 0; E < r.length; E++) {
    var x = r[E], S = x._private.rscratch, w = S.imgLayerCaches = S.imgLayerCaches || {}, T = w[t];
    if (T) {
      y = T;
      continue;
    }
    if ((!y || y.eles.length >= b || !Hh(y.bb, x.boundingBox())) && (y = g({
      insert: !0,
      after: y
    }), !y))
      return null;
    h || m ? a.queueLayer(y, x) : a.drawEleInLayer(y, x, t, e), y.eles.push(x), w[t] = y;
  }
  return h || (m ? null : f);
};
ht.getEleLevelForLayerLevel = function(r, e) {
  return r;
};
ht.drawEleInLayer = function(r, e, t, a) {
  var n = this, i = this.renderer, s = r.context, o = e.boundingBox();
  o.w === 0 || o.h === 0 || !e.visible() || (t = n.getEleLevelForLayerLevel(t, a), i.setImgSmoothing(s, !1), i.drawCachedElement(s, e, null, null, t, qy), i.setImgSmoothing(s, !0));
};
ht.levelIsComplete = function(r, e) {
  var t = this, a = t.layersByLevel[r];
  if (!a || a.length === 0)
    return !1;
  for (var n = 0, i = 0; i < a.length; i++) {
    var s = a[i];
    if (s.reqs > 0 || s.invalid)
      return !1;
    n += s.eles.length;
  }
  return n === e.length;
};
ht.validateLayersElesOrdering = function(r, e) {
  var t = this.layersByLevel[r];
  if (t)
    for (var a = 0; a < t.length; a++) {
      for (var n = t[a], i = -1, s = 0; s < e.length; s++)
        if (n.eles[0] === e[s]) {
          i = s;
          break;
        }
      if (i < 0) {
        this.invalidateLayer(n);
        continue;
      }
      for (var o = i, s = 0; s < n.eles.length; s++)
        if (n.eles[s] !== e[o + s]) {
          this.invalidateLayer(n);
          break;
        }
    }
};
ht.updateElementsInLayers = function(r, e) {
  for (var t = this, a = Na(r[0]), n = 0; n < r.length; n++)
    for (var i = a ? null : r[n], s = a ? r[n] : r[n].ele, o = s._private.rscratch, u = o.imgLayerCaches = o.imgLayerCaches || {}, l = Ea; l <= On; l++) {
      var f = u[l];
      f && (i && t.getEleLevelForLayerLevel(f.level) !== i.level || e(f, s, i));
    }
};
ht.haveLayers = function() {
  for (var r = this, e = !1, t = Ea; t <= On; t++) {
    var a = r.layersByLevel[t];
    if (a && a.length > 0) {
      e = !0;
      break;
    }
  }
  return e;
};
ht.invalidateElements = function(r) {
  var e = this;
  r.length !== 0 && (e.lastInvalidationTime = Zt(), !(r.length === 0 || !e.haveLayers()) && e.updateElementsInLayers(r, function(a, n, i) {
    e.invalidateLayer(a);
  }));
};
ht.invalidateLayer = function(r) {
  if (this.lastInvalidationTime = Zt(), !r.invalid) {
    var e = r.level, t = r.eles, a = this.layersByLevel[e];
    or(a, r), r.elesQueue = [], r.invalid = !0, r.replacement && (r.replacement.invalid = !0);
    for (var n = 0; n < t.length; n++) {
      var i = t[n]._private.rscratch.imgLayerCaches;
      i && (i[e] = null);
    }
  }
};
ht.refineElementTextures = function(r) {
  var e = this;
  e.updateElementsInLayers(r, function(a, n, i) {
    var s = a.replacement;
    if (s || (s = a.replacement = e.makeLayer(a.bb, a.level), s.replaces = a, s.eles = a.eles), !s.reqs)
      for (var o = 0; o < s.eles.length; o++)
        e.queueLayer(s, s.eles[o]);
  });
};
ht.enqueueElementRefinement = function(r) {
  this.eleTxrDeqs.merge(r), this.scheduleElementRefinement();
};
ht.queueLayer = function(r, e) {
  var t = this, a = t.layersQueue, n = r.elesQueue, i = n.hasId = n.hasId || {};
  if (!r.replacement) {
    if (e) {
      if (i[e.id()])
        return;
      n.push(e), i[e.id()] = !0;
    }
    r.reqs ? (r.reqs++, a.updateItem(r)) : (r.reqs = 1, a.push(r));
  }
};
ht.dequeue = function(r) {
  for (var e = this, t = e.layersQueue, a = [], n = 0; n < Vy && t.size() !== 0; ) {
    var i = t.peek();
    if (i.replacement) {
      t.pop();
      continue;
    }
    if (i.replaces && i !== i.replaces.replacement) {
      t.pop();
      continue;
    }
    if (i.invalid) {
      t.pop();
      continue;
    }
    var s = i.elesQueue.shift();
    s && (e.drawEleInLayer(i, s, i.level, r), n++), a.length === 0 && a.push(!0), i.elesQueue.length === 0 && (t.pop(), i.reqs = 0, i.replaces && e.applyLayerReplacement(i), e.requestRedraw());
  }
  return a;
};
ht.applyLayerReplacement = function(r) {
  var e = this, t = e.layersByLevel[r.level], a = r.replaces, n = t.indexOf(a);
  if (!(n < 0 || a.invalid)) {
    t[n] = r;
    for (var i = 0; i < r.eles.length; i++) {
      var s = r.eles[i]._private, o = s.imgLayerCaches = s.imgLayerCaches || {};
      o && (o[r.level] = r);
    }
    e.requestRedraw();
  }
};
ht.requestRedraw = _a(function() {
  var r = this.renderer;
  r.redrawHint("eles", !0), r.redrawHint("drag", !0), r.redraw();
}, 100);
ht.setupDequeueing = Rc.setupDequeueing({
  deqRedrawThreshold: ky,
  deqCost: Fy,
  deqAvgCost: _y,
  deqNoDrawCost: Gy,
  deqFastCost: zy,
  deq: function(e, t) {
    return e.dequeue(t);
  },
  onDeqd: so,
  shouldRedraw: Ef,
  priority: function(e) {
    return e.renderer.beforeRenderPriorities.lyrTxrDeq;
  }
});
var Oc = {}, Xl;
function Yy(r, e) {
  for (var t = 0; t < e.length; t++) {
    var a = e[t];
    r.lineTo(a.x, a.y);
  }
}
function Xy(r, e, t) {
  for (var a, n = 0; n < e.length; n++) {
    var i = e[n];
    n === 0 && (a = i), r.lineTo(i.x, i.y);
  }
  r.quadraticCurveTo(t.x, t.y, a.x, a.y);
}
function $l(r, e, t) {
  r.beginPath && r.beginPath();
  for (var a = e, n = 0; n < a.length; n++) {
    var i = a[n];
    r.lineTo(i.x, i.y);
  }
  var s = t, o = t[0];
  r.moveTo(o.x, o.y);
  for (var n = 1; n < s.length; n++) {
    var i = s[n];
    r.lineTo(i.x, i.y);
  }
  r.closePath && r.closePath();
}
function $y(r, e, t, a, n) {
  r.beginPath && r.beginPath(), r.arc(t, a, n, 0, Math.PI * 2, !1);
  var i = e, s = i[0];
  r.moveTo(s.x, s.y);
  for (var o = 0; o < i.length; o++) {
    var u = i[o];
    r.lineTo(u.x, u.y);
  }
  r.closePath && r.closePath();
}
function Wy(r, e, t, a) {
  r.arc(e, t, a, 0, Math.PI * 2, !1);
}
Oc.arrowShapeImpl = function(r) {
  return (Xl || (Xl = {
    polygon: Yy,
    "triangle-backcurve": Xy,
    "triangle-tee": $l,
    "circle-triangle": $y,
    "triangle-cross": $l,
    circle: Wy
  }))[r];
};
var Yt = {};
Yt.drawElement = function(r, e, t, a, n, i) {
  var s = this;
  e.isNode() ? s.drawNode(r, e, t, a, n, i) : s.drawEdge(r, e, t, a, n, i);
};
Yt.drawElementOverlay = function(r, e) {
  var t = this;
  e.isNode() ? t.drawNodeOverlay(r, e) : t.drawEdgeOverlay(r, e);
};
Yt.drawElementUnderlay = function(r, e) {
  var t = this;
  e.isNode() ? t.drawNodeUnderlay(r, e) : t.drawEdgeUnderlay(r, e);
};
Yt.drawCachedElementPortion = function(r, e, t, a, n, i, s, o) {
  var u = this, l = t.getBoundingBox(e);
  if (!(l.w === 0 || l.h === 0)) {
    var f = t.getElement(e, l, a, n, i);
    if (f != null) {
      var c = o(u, e);
      if (c === 0)
        return;
      var v = s(u, e), h = l.x1, d = l.y1, p = l.w, g = l.h, y, b, m, E, x;
      if (v !== 0) {
        var S = t.getRotationPoint(e);
        m = S.x, E = S.y, r.translate(m, E), r.rotate(v), x = u.getImgSmoothing(r), x || u.setImgSmoothing(r, !0);
        var w = t.getRotationOffset(e);
        y = w.x, b = w.y;
      } else
        y = h, b = d;
      var T;
      c !== 1 && (T = r.globalAlpha, r.globalAlpha = T * c), r.drawImage(f.texture.canvas, f.x, 0, f.width, f.height, y, b, p, g), c !== 1 && (r.globalAlpha = T), v !== 0 && (r.rotate(-v), r.translate(-m, -E), x || u.setImgSmoothing(r, !1));
    } else
      t.drawElement(r, e);
  }
};
var Ky = function() {
  return 0;
}, Zy = function(e, t) {
  return e.getTextAngle(t, null);
}, Qy = function(e, t) {
  return e.getTextAngle(t, "source");
}, Jy = function(e, t) {
  return e.getTextAngle(t, "target");
}, jy = function(e, t) {
  return t.effectiveOpacity();
}, xs = function(e, t) {
  return t.pstyle("text-opacity").pfValue * t.effectiveOpacity();
};
Yt.drawCachedElement = function(r, e, t, a, n, i) {
  var s = this, o = s.data, u = o.eleTxrCache, l = o.lblTxrCache, f = o.slbTxrCache, c = o.tlbTxrCache, v = e.boundingBox(), h = i === !0 ? u.reasons.highQuality : null;
  if (!(v.w === 0 || v.h === 0 || !e.visible()) && (!a || fo(v, a))) {
    var d = e.isEdge(), p = e.element()._private.rscratch.badLine;
    s.drawElementUnderlay(r, e), s.drawCachedElementPortion(r, e, u, t, n, h, Ky, jy), (!d || !p) && s.drawCachedElementPortion(r, e, l, t, n, h, Zy, xs), d && !p && (s.drawCachedElementPortion(r, e, f, t, n, h, Qy, xs), s.drawCachedElementPortion(r, e, c, t, n, h, Jy, xs)), s.drawElementOverlay(r, e);
  }
};
Yt.drawElements = function(r, e) {
  for (var t = this, a = 0; a < e.length; a++) {
    var n = e[a];
    t.drawElement(r, n);
  }
};
Yt.drawCachedElements = function(r, e, t, a) {
  for (var n = this, i = 0; i < e.length; i++) {
    var s = e[i];
    n.drawCachedElement(r, s, t, a);
  }
};
Yt.drawCachedNodes = function(r, e, t, a) {
  for (var n = this, i = 0; i < e.length; i++) {
    var s = e[i];
    s.isNode() && n.drawCachedElement(r, s, t, a);
  }
};
Yt.drawLayeredElements = function(r, e, t, a) {
  var n = this, i = n.data.lyrTxrCache.getLayers(e, t);
  if (i)
    for (var s = 0; s < i.length; s++) {
      var o = i[s], u = o.bb;
      u.w === 0 || u.h === 0 || r.drawImage(o.canvas, u.x1, u.y1, u.w, u.h);
    }
  else
    n.drawCachedElements(r, e, t, a);
};
var jt = {};
jt.drawEdge = function(r, e, t) {
  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, s = this, o = e._private.rscratch;
  if (!(i && !e.visible()) && !(o.badLine || o.allpts == null || isNaN(o.allpts[0]))) {
    var u;
    t && (u = t, r.translate(-u.x1, -u.y1));
    var l = i ? e.pstyle("opacity").value : 1, f = i ? e.pstyle("line-opacity").value : 1, c = e.pstyle("curve-style").value, v = e.pstyle("line-style").value, h = e.pstyle("width").pfValue, d = e.pstyle("line-cap").value, p = e.pstyle("line-outline-width").value, g = e.pstyle("line-outline-color").value, y = l * f, b = l * f, m = function() {
      var O = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : y;
      c === "straight-triangle" ? (s.eleStrokeStyle(r, e, O), s.drawEdgeTrianglePath(e, r, o.allpts)) : (r.lineWidth = h, r.lineCap = d, s.eleStrokeStyle(r, e, O), s.drawEdgePath(e, r, o.allpts, v), r.lineCap = "butt");
    }, E = function() {
      var O = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : y;
      if (r.lineWidth = h + p, r.lineCap = d, p > 0)
        s.colorStrokeStyle(r, g[0], g[1], g[2], O);
      else {
        r.lineCap = "butt";
        return;
      }
      c === "straight-triangle" ? s.drawEdgeTrianglePath(e, r, o.allpts) : (s.drawEdgePath(e, r, o.allpts, v), r.lineCap = "butt");
    }, x = function() {
      n && s.drawEdgeOverlay(r, e);
    }, S = function() {
      n && s.drawEdgeUnderlay(r, e);
    }, w = function() {
      var O = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b;
      s.drawArrowheads(r, e, O);
    }, T = function() {
      s.drawElementText(r, e, null, a);
    };
    r.lineJoin = "round";
    var C = e.pstyle("ghost").value === "yes";
    if (C) {
      var D = e.pstyle("ghost-offset-x").pfValue, A = e.pstyle("ghost-offset-y").pfValue, L = e.pstyle("ghost-opacity").value, R = y * L;
      r.translate(D, A), m(R), w(R), r.translate(-D, -A);
    } else
      E();
    S(), m(), w(), x(), T(), t && r.translate(u.x1, u.y1);
  }
};
var Pc = function(e) {
  if (!["overlay", "underlay"].includes(e))
    throw new Error("Invalid state");
  return function(t, a) {
    if (a.visible()) {
      var n = a.pstyle("".concat(e, "-opacity")).value;
      if (n !== 0) {
        var i = this, s = i.usePaths(), o = a._private.rscratch, u = a.pstyle("".concat(e, "-padding")).pfValue, l = 2 * u, f = a.pstyle("".concat(e, "-color")).value;
        t.lineWidth = l, o.edgeType === "self" && !s ? t.lineCap = "butt" : t.lineCap = "round", i.colorStrokeStyle(t, f[0], f[1], f[2], n), i.drawEdgePath(a, t, o.allpts, "solid");
      }
    }
  };
};
jt.drawEdgeOverlay = Pc("overlay");
jt.drawEdgeUnderlay = Pc("underlay");
jt.drawEdgePath = function(r, e, t, a) {
  var n = r._private.rscratch, i = e, s, o = !1, u = this.usePaths(), l = r.pstyle("line-dash-pattern").pfValue, f = r.pstyle("line-dash-offset").pfValue;
  if (u) {
    var c = t.join("$"), v = n.pathCacheKey && n.pathCacheKey === c;
    v ? (s = e = n.pathCache, o = !0) : (s = e = new Path2D(), n.pathCacheKey = c, n.pathCache = s);
  }
  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 (!o && !n.badLine)
    switch (e.beginPath && e.beginPath(), e.moveTo(t[0], t[1]), n.edgeType) {
      case "bezier":
      case "self":
      case "compound":
      case "multibezier":
        for (var h = 2; h + 3 < t.length; h += 4)
          e.quadraticCurveTo(t[h], t[h + 1], t[h + 2], t[h + 3]);
        break;
      case "straight":
      case "haystack":
        for (var d = 2; d + 1 < t.length; d += 2)
          e.lineTo(t[d], t[d + 1]);
        break;
      case "segments":
        if (n.isRound) {
          var p = Dt(n.roundCorners), g;
          try {
            for (p.s(); !(g = p.n()).done; ) {
              var y = g.value;
              Ec(e, y);
            }
          } catch (m) {
            p.e(m);
          } finally {
            p.f();
          }
          e.lineTo(t[t.length - 2], t[t.length - 1]);
        } else
          for (var b = 2; b + 1 < t.length; b += 2)
            e.lineTo(t[b], t[b + 1]);
        break;
    }
  e = i, u ? e.stroke(s) : e.stroke(), e.setLineDash && e.setLineDash([]);
};
jt.drawEdgeTrianglePath = function(r, e, t) {
  e.fillStyle = e.strokeStyle;
  for (var a = r.pstyle("width").pfValue, n = 0; n + 1 < t.length; n += 2) {
    var i = [t[n + 2] - t[n], t[n + 3] - t[n + 1]], s = Math.sqrt(i[0] * i[0] + i[1] * i[1]), o = [i[1] / s, -i[0] / s], u = [o[0] * a / 2, o[1] * a / 2];
    e.beginPath(), e.moveTo(t[n] - u[0], t[n + 1] - u[1]), e.lineTo(t[n] + u[0], t[n + 1] + u[1]), e.lineTo(t[n + 2], t[n + 3]), e.closePath(), e.fill();
  }
};
jt.drawArrowheads = function(r, e, t) {
  var a = e._private.rscratch, n = a.edgeType === "haystack";
  n || this.drawArrowhead(r, e, "source", a.arrowStartX, a.arrowStartY, a.srcArrowAngle, t), this.drawArrowhead(r, e, "mid-target", a.midX, a.midY, a.midtgtArrowAngle, t), this.drawArrowhead(r, e, "mid-source", a.midX, a.midY, a.midsrcArrowAngle, t), n || this.drawArrowhead(r, e, "target", a.arrowEndX, a.arrowEndY, a.tgtArrowAngle, t);
};
jt.drawArrowhead = function(r, e, t, a, n, i, s) {
  if (!(isNaN(a) || a == null || isNaN(n) || n == null || isNaN(i) || i == null)) {
    var o = this, u = e.pstyle(t + "-arrow-shape").value;
    if (u !== "none") {
      var l = e.pstyle(t + "-arrow-fill").value === "hollow" ? "both" : "filled", f = e.pstyle(t + "-arrow-fill").value, c = e.pstyle("width").pfValue, v = e.pstyle(t + "-arrow-width"), h = v.value === "match-line" ? c : v.pfValue;
      v.units === "%" && (h *= c);
      var d = e.pstyle("opacity").value;
      s === void 0 && (s = d);
      var p = r.globalCompositeOperation;
      (s !== 1 || f === "hollow") && (r.globalCompositeOperation = "destination-out", o.colorFillStyle(r, 255, 255, 255, 1), o.colorStrokeStyle(r, 255, 255, 255, 1), o.drawArrowShape(e, r, l, c, u, h, a, n, i), r.globalCompositeOperation = p);
      var g = e.pstyle(t + "-arrow-color").value;
      o.colorFillStyle(r, g[0], g[1], g[2], s), o.colorStrokeStyle(r, g[0], g[1], g[2], s), o.drawArrowShape(e, r, f, c, u, h, a, n, i);
    }
  }
};
jt.drawArrowShape = function(r, e, t, a, n, i, s, o, u) {
  var l = this, f = this.usePaths() && n !== "triangle-cross", c = !1, v, h = e, d = {
    x: s,
    y: o
  }, p = r.pstyle("arrow-scale").value, g = this.getArrowWidth(a, p), y = l.arrowShapes[n];
  if (f) {
    var b = l.arrowPathCache = l.arrowPathCache || [], m = Ar(n), E = b[m];
    E != null ? (v = e = E, c = !0) : (v = e = new Path2D(), b[m] = v);
  }
  c || (e.beginPath && e.beginPath(), f ? y.draw(e, 1, 0, {
    x: 0,
    y: 0
  }, 1) : y.draw(e, g, u, d, a), e.closePath && e.closePath()), e = h, f && (e.translate(s, o), e.rotate(u), e.scale(g, g)), (t === "filled" || t === "both") && (f ? e.fill(v) : e.fill()), (t === "hollow" || t === "both") && (e.lineWidth = i / (f ? g : 1), e.lineJoin = "miter", f ? e.stroke(v) : e.stroke()), f && (e.scale(1 / g, 1 / g), e.rotate(-u), e.translate(-s, -o));
};
var Do = {};
Do.safeDrawImage = function(r, e, t, a, n, i, s, o, u, l) {
  if (!(n <= 0 || i <= 0 || u <= 0 || l <= 0))
    try {
      r.drawImage(e, t, a, n, i, s, o, u, l);
    } catch (f) {
      Pe(f);
    }
};
Do.drawInscribedImage = function(r, e, t, a, n) {
  var i = this, s = t.position(), o = s.x, u = s.y, l = t.cy().style(), f = l.getIndexedStyle.bind(l), c = f(t, "background-fit", "value", a), v = f(t, "background-repeat", "value", a), h = t.width(), d = t.height(), p = t.padding() * 2, g = h + (f(t, "background-width-relative-to", "value", a) === "inner" ? 0 : p), y = d + (f(t, "background-height-relative-to", "value", a) === "inner" ? 0 : p), b = t._private.rscratch, m = f(t, "background-clip", "value", a), E = m === "node", x = f(t, "background-image-opacity", "value", a) * n, S = f(t, "background-image-smoothing", "value", a), w = t.pstyle("corner-radius").value;
  w !== "auto" && (w = t.pstyle("corner-radius").pfValue);
  var T = e.width || e.cachedW, C = e.height || e.cachedH;
  (T == null || C == null) && (document.body.appendChild(e), T = e.cachedW = e.width || e.offsetWidth, C = e.cachedH = e.height || e.offsetHeight, document.body.removeChild(e));
  var D = T, A = C;
  if (f(t, "background-width", "value", a) !== "auto" && (f(t, "background-width", "units", a) === "%" ? D = f(t, "background-width", "pfValue", a) * g : D = f(t, "background-width", "pfValue", a)), f(t, "background-height", "value", a) !== "auto" && (f(t, "background-height", "units", a) === "%" ? A = f(t, "background-height", "pfValue", a) * y : A = f(t, "background-height", "pfValue", a)), !(D === 0 || A === 0)) {
    if (c === "contain") {
      var L = Math.min(g / D, y / A);
      D *= L, A *= L;
    } else if (c === "cover") {
      var L = Math.max(g / D, y / A);
      D *= L, A *= L;
    }
    var R = o - g / 2, I = f(t, "background-position-x", "units", a), O = f(t, "background-position-x", "pfValue", a);
    I === "%" ? R += (g - D) * O : R += O;
    var N = f(t, "background-offset-x", "units", a), k = f(t, "background-offset-x", "pfValue", a);
    N === "%" ? R += (g - D) * k : R += k;
    var P = u - y / 2, B = f(t, "background-position-y", "units", a), _ = f(t, "background-position-y", "pfValue", a);
    B === "%" ? P += (y - A) * _ : P += _;
    var F = f(t, "background-offset-y", "units", a), G = f(t, "background-offset-y", "pfValue", a);
    F === "%" ? P += (y - A) * G : P += G, b.pathCache && (R -= o, P -= u, o = 0, u = 0);
    var U = r.globalAlpha;
    r.globalAlpha = x;
    var H = i.getImgSmoothing(r), $ = !1;
    if (S === "no" && H ? (i.setImgSmoothing(r, !1), $ = !0) : S === "yes" && !H && (i.setImgSmoothing(r, !0), $ = !0), v === "no-repeat")
      E && (r.save(), b.pathCache ? r.clip(b.pathCache) : (i.nodeShapes[i.getNodeShape(t)].draw(r, o, u, g, y, w, b), r.clip())), i.safeDrawImage(r, e, 0, 0, T, C, R, P, D, A), E && r.restore();
    else {
      var X = r.createPattern(e, v);
      r.fillStyle = X, i.nodeShapes[i.getNodeShape(t)].draw(r, o, u, g, y, w, b), r.translate(R, P), r.fill(), r.translate(-R, -P);
    }
    r.globalAlpha = U, $ && i.setImgSmoothing(r, H);
  }
};
var Nr = {};
Nr.eleTextBiggerThanMin = function(r, e) {
  if (!e) {
    var t = r.cy().zoom(), a = this.getPixelRatio(), n = Math.ceil(uo(t * a));
    e = Math.pow(2, n);
  }
  var i = r.pstyle("font-size").pfValue * e, s = r.pstyle("min-zoomed-font-size").pfValue;
  return !(i < s);
};
Nr.drawElementText = function(r, e, t, a, n) {
  var i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, s = this;
  if (a == null) {
    if (i && !s.eleTextBiggerThanMin(e))
      return;
  } else if (a === !1)
    return;
  if (e.isNode()) {
    var o = e.pstyle("label");
    if (!o || !o.value)
      return;
    var u = s.getLabelJustification(e);
    r.textAlign = u, r.textBaseline = "bottom";
  } else {
    var l = e.element()._private.rscratch.badLine, f = e.pstyle("label"), c = e.pstyle("source-label"), v = e.pstyle("target-label");
    if (l || (!f || !f.value) && (!c || !c.value) && (!v || !v.value))
      return;
    r.textAlign = "center", r.textBaseline = "bottom";
  }
  var h = !t, d;
  t && (d = t, r.translate(-d.x1, -d.y1)), n == null ? (s.drawText(r, e, null, h, i), e.isEdge() && (s.drawText(r, e, "source", h, i), s.drawText(r, e, "target", h, i))) : s.drawText(r, e, n, h, i), t && r.translate(d.x1, d.y1);
};
Nr.getFontCache = function(r) {
  var e;
  this.fontCaches = this.fontCaches || [];
  for (var t = 0; t < this.fontCaches.length; t++)
    if (e = this.fontCaches[t], e.context === r)
      return e;
  return e = {
    context: r
  }, this.fontCaches.push(e), e;
};
Nr.setupTextStyle = function(r, e) {
  var t = 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, s = e.pstyle("font-weight").strValue, o = t ? e.effectiveOpacity() * e.pstyle("text-opacity").value : 1, u = e.pstyle("text-outline-opacity").value * o, l = e.pstyle("color").value, f = e.pstyle("text-outline-color").value;
  r.font = a + " " + s + " " + n + " " + i, r.lineJoin = "round", this.colorFillStyle(r, l[0], l[1], l[2], o), this.colorStrokeStyle(r, f[0], f[1], f[2], u);
};
function Ts(r, e, t, a, n) {
  var i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 5, s = arguments.length > 6 ? arguments[6] : void 0;
  r.beginPath(), r.moveTo(e + i, t), r.lineTo(e + a - i, t), r.quadraticCurveTo(e + a, t, e + a, t + i), r.lineTo(e + a, t + n - i), r.quadraticCurveTo(e + a, t + n, e + a - i, t + n), r.lineTo(e + i, t + n), r.quadraticCurveTo(e, t + n, e, t + n - i), r.lineTo(e, t + i), r.quadraticCurveTo(e, t, e + i, t), r.closePath(), s ? r.stroke() : r.fill();
}
Nr.getTextAngle = function(r, e) {
  var t, a = r._private, n = a.rscratch, i = e ? e + "-" : "", s = r.pstyle(i + "text-rotation");
  if (s.strValue === "autorotate") {
    var o = Tt(n, "labelAngle", e);
    t = r.isEdge() ? o : 0;
  } else
    s.strValue === "none" ? t = 0 : t = s.pfValue;
  return t;
};
Nr.drawText = function(r, e, t) {
  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, s = i.rscratch, o = n ? e.effectiveOpacity() : 1;
  if (!(n && (o === 0 || e.pstyle("text-opacity").value === 0))) {
    t === "main" && (t = null);
    var u = Tt(s, "labelX", t), l = Tt(s, "labelY", t), f, c, v = this.getLabelText(e, t);
    if (v != null && v !== "" && !isNaN(u) && !isNaN(l)) {
      this.setupTextStyle(r, e, n);
      var h = t ? t + "-" : "", d = Tt(s, "labelWidth", t), p = Tt(s, "labelHeight", t), g = e.pstyle(h + "text-margin-x").pfValue, y = e.pstyle(h + "text-margin-y").pfValue, b = e.isEdge(), m = e.pstyle("text-halign").value, E = e.pstyle("text-valign").value;
      b && (m = "center", E = "center"), u += g, l += y;
      var x;
      switch (a ? x = this.getTextAngle(e, t) : x = 0, x !== 0 && (f = u, c = l, r.translate(f, c), r.rotate(x), u = 0, l = 0), E) {
        case "top":
          break;
        case "center":
          l += p / 2;
          break;
        case "bottom":
          l += p;
          break;
      }
      var S = e.pstyle("text-background-opacity").value, w = e.pstyle("text-border-opacity").value, T = e.pstyle("text-border-width").pfValue, C = e.pstyle("text-background-padding").pfValue, D = e.pstyle("text-background-shape").strValue, A = D.indexOf("round") === 0, L = 2;
      if (S > 0 || T > 0 && w > 0) {
        var R = u - C;
        switch (m) {
          case "left":
            R -= d;
            break;
          case "center":
            R -= d / 2;
            break;
        }
        var I = l - p - C, O = d + 2 * C, N = p + 2 * C;
        if (S > 0) {
          var k = r.fillStyle, P = e.pstyle("text-background-color").value;
          r.fillStyle = "rgba(" + P[0] + "," + P[1] + "," + P[2] + "," + S * o + ")", A ? Ts(r, R, I, O, N, L) : r.fillRect(R, I, O, N), r.fillStyle = k;
        }
        if (T > 0 && w > 0) {
          var B = r.strokeStyle, _ = r.lineWidth, F = e.pstyle("text-border-color").value, G = e.pstyle("text-border-style").value;
          if (r.strokeStyle = "rgba(" + F[0] + "," + F[1] + "," + F[2] + "," + w * o + ")", r.lineWidth = T, r.setLineDash)
            switch (G) {
              case "dotted":
                r.setLineDash([1, 1]);
                break;
              case "dashed":
                r.setLineDash([4, 2]);
                break;
              case "double":
                r.lineWidth = T / 4, r.setLineDash([]);
                break;
              case "solid":
                r.setLineDash([]);
                break;
            }
          if (A ? Ts(r, R, I, O, N, L, "stroke") : r.strokeRect(R, I, O, N), G === "double") {
            var U = T / 2;
            A ? Ts(r, R + U, I + U, O - U * 2, N - U * 2, L, "stroke") : r.strokeRect(R + U, I + U, O - U * 2, N - U * 2);
          }
          r.setLineDash && r.setLineDash([]), r.lineWidth = _, r.strokeStyle = B;
        }
      }
      var H = 2 * e.pstyle("text-outline-width").pfValue;
      if (H > 0 && (r.lineWidth = H), e.pstyle("text-wrap").value === "wrap") {
        var $ = Tt(s, "labelWrapCachedLines", t), X = Tt(s, "labelLineHeight", t), Q = d / 2, re = this.getLabelJustification(e);
        switch (re === "auto" || (m === "left" ? re === "left" ? u += -d : re === "center" && (u += -Q) : m === "center" ? re === "left" ? u += -Q : re === "right" && (u += Q) : m === "right" && (re === "center" ? u += Q : re === "right" && (u += d))), E) {
          case "top":
            l -= ($.length - 1) * X;
            break;
          case "center":
          case "bottom":
            l -= ($.length - 1) * X;
            break;
        }
        for (var J = 0; J < $.length; J++)
          H > 0 && r.strokeText($[J], u, l), r.fillText($[J], u, l), l += X;
      } else
        H > 0 && r.strokeText(v, u, l), r.fillText(v, u, l);
      x !== 0 && (r.rotate(-x), r.translate(-f, -c));
    }
  }
};
var pr = {};
pr.drawNode = function(r, e, t) {
  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, s = this, o, u, l = e._private, f = l.rscratch, c = e.position();
  if (!(!ae(c.x) || !ae(c.y)) && !(i && !e.visible())) {
    var v = i ? e.effectiveOpacity() : 1, h = s.usePaths(), d, p = !1, g = e.padding();
    o = e.width() + 2 * g, u = e.height() + 2 * g;
    var y;
    t && (y = t, r.translate(-y.x1, -y.y1));
    for (var b = e.pstyle("background-image"), m = b.value, E = new Array(m.length), x = new Array(m.length), S = 0, w = 0; w < m.length; w++) {
      var T = m[w], C = E[w] = T != null && T !== "none";
      if (C) {
        var D = e.cy().style().getIndexedStyle(e, "background-image-crossorigin", "value", w);
        S++, x[w] = s.getCachedImage(T, 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 * v, I = e.pstyle("border-color").value, O = e.pstyle("border-style").value, N = e.pstyle("border-join").value, k = e.pstyle("border-cap").value, P = e.pstyle("border-position").value, B = e.pstyle("border-dash-pattern").pfValue, _ = e.pstyle("border-dash-offset").pfValue, F = e.pstyle("border-opacity").value * v, G = e.pstyle("outline-width").pfValue, U = e.pstyle("outline-color").value, H = e.pstyle("outline-style").value, $ = e.pstyle("outline-opacity").value * v, X = e.pstyle("outline-offset").value, Q = e.pstyle("corner-radius").value;
    Q !== "auto" && (Q = e.pstyle("corner-radius").pfValue);
    var re = function() {
      var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : R;
      s.eleFillStyle(r, e, le);
    }, J = function() {
      var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : F;
      s.colorStrokeStyle(r, I[0], I[1], I[2], le);
    }, z = function() {
      var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : $;
      s.colorStrokeStyle(r, U[0], U[1], U[2], le);
    }, V = function(le, j, M, q) {
      var W = s.nodePathCache = s.nodePathCache || [], K = wf(M === "polygon" ? M + "," + q.join(",") : M, "" + j, "" + le, "" + Q), Z = W[K], ue, te = !1;
      return Z != null ? (ue = Z, te = !0, f.pathCache = ue) : (ue = new Path2D(), W[K] = f.pathCache = ue), {
        path: ue,
        cacheHit: te
      };
    }, Y = e.pstyle("shape").strValue, ee = e.pstyle("shape-polygon-points").pfValue;
    if (h) {
      r.translate(c.x, c.y);
      var ne = V(o, u, Y, ee);
      d = ne.path, p = ne.cacheHit;
    }
    var be = function() {
      if (!p) {
        var le = c;
        h && (le = {
          x: 0,
          y: 0
        }), s.nodeShapes[s.getNodeShape(e)].draw(d || r, le.x, le.y, o, u, Q, f);
      }
      h ? r.fill(d) : r.fill();
    }, Ve = function() {
      for (var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : v, j = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, M = l.backgrounding, q = 0, W = 0; W < x.length; W++) {
        var K = e.cy().style().getIndexedStyle(e, "background-image-containment", "value", W);
        if (j && K === "over" || !j && K === "inside") {
          q++;
          continue;
        }
        E[W] && x[W].complete && !x[W].error && (q++, s.drawInscribedImage(r, x[W], e, W, le));
      }
      l.backgrounding = q !== S, M !== l.backgrounding && e.updateStyle(!1);
    }, Ne = function() {
      var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, j = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : v;
      s.hasPie(e) && (s.drawPie(r, e, j), le && (h || s.nodeShapes[s.getNodeShape(e)].draw(r, c.x, c.y, o, u, Q, f)));
    }, se = function() {
      var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, j = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : v;
      s.hasStripe(e) && (r.save(), h ? r.clip(f.pathCache) : (s.nodeShapes[s.getNodeShape(e)].draw(r, c.x, c.y, o, u, Q, f), r.clip()), s.drawStripe(r, e, j), r.restore(), le && (h || s.nodeShapes[s.getNodeShape(e)].draw(r, c.x, c.y, o, u, Q, f)));
    }, oe = function() {
      var le = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : v, j = (A > 0 ? A : -A) * le, M = A > 0 ? 0 : 255;
      A !== 0 && (s.colorFillStyle(r, M, M, M, j), h ? r.fill(d) : r.fill());
    }, ve = function() {
      if (L > 0) {
        if (r.lineWidth = L, r.lineCap = k, r.lineJoin = N, r.setLineDash)
          switch (O) {
            case "dotted":
              r.setLineDash([1, 1]);
              break;
            case "dashed":
              r.setLineDash(B), r.lineDashOffset = _;
              break;
            case "solid":
            case "double":
              r.setLineDash([]);
              break;
          }
        if (P !== "center") {
          if (r.save(), r.lineWidth *= 2, P === "inside")
            h ? r.clip(d) : r.clip();
          else {
            var le = new Path2D();
            le.rect(-o / 2 - L, -u / 2 - L, o + 2 * L, u + 2 * L), le.addPath(d), r.clip(le, "evenodd");
          }
          h ? r.stroke(d) : r.stroke(), r.restore();
        } else
          h ? r.stroke(d) : r.stroke();
        if (O === "double") {
          r.lineWidth = L / 3;
          var j = r.globalCompositeOperation;
          r.globalCompositeOperation = "destination-out", h ? r.stroke(d) : r.stroke(), r.globalCompositeOperation = j;
        }
        r.setLineDash && r.setLineDash([]);
      }
    }, ge = function() {
      if (G > 0) {
        if (r.lineWidth = G, r.lineCap = "butt", r.setLineDash)
          switch (H) {
            case "dotted":
              r.setLineDash([1, 1]);
              break;
            case "dashed":
              r.setLineDash([4, 2]);
              break;
            case "solid":
            case "double":
              r.setLineDash([]);
              break;
          }
        var le = c;
        h && (le = {
          x: 0,
          y: 0
        });
        var j = s.getNodeShape(e), M = L;
        P === "inside" && (M = 0), P === "outside" && (M *= 2);
        var q = (o + M + (G + X)) / o, W = (u + M + (G + X)) / u, K = o * q, Z = u * W, ue = s.nodeShapes[j].points, te;
        if (h) {
          var fe = V(K, Z, j, ue);
          te = fe.path;
        }
        if (j === "ellipse")
          s.drawEllipsePath(te || r, le.x, le.y, K, Z);
        else if (["round-diamond", "round-heptagon", "round-hexagon", "round-octagon", "round-pentagon", "round-polygon", "round-triangle", "round-tag"].includes(j)) {
          var xe = 0, De = 0, pe = 0;
          j === "round-diamond" ? xe = (M + X + G) * 1.4 : j === "round-heptagon" ? (xe = (M + X + G) * 1.075, pe = -(M / 2 + X + G) / 35) : j === "round-hexagon" ? xe = (M + X + G) * 1.12 : j === "round-pentagon" ? (xe = (M + X + G) * 1.13, pe = -(M / 2 + X + G) / 15) : j === "round-tag" ? (xe = (M + X + G) * 1.12, De = (M / 2 + G + X) * 0.07) : j === "round-triangle" && (xe = (M + X + G) * (Math.PI / 2), pe = -(M + X / 2 + G) / Math.PI), xe !== 0 && (q = (o + xe) / o, K = o * q, ["round-hexagon", "round-tag"].includes(j) || (W = (u + xe) / u, Z = u * W)), Q = Q === "auto" ? Rf(K, Z) : Q;
          for (var Te = K / 2, me = Z / 2, Ee = Q + (M + G + X) / 2, ke = new Array(ue.length / 2), Ke = new Array(ue.length / 2), ut = 0; ut < ue.length / 2; ut++)
            ke[ut] = {
              x: le.x + De + Te * ue[ut * 2],
              y: le.y + pe + me * ue[ut * 2 + 1]
            };
          var nt, $e, lt, Qe, wt = ke.length;
          for ($e = ke[wt - 1], nt = 0; nt < wt; nt++)
            lt = ke[nt % wt], Qe = ke[(nt + 1) % wt], Ke[nt] = To($e, lt, Qe, Ee), $e = lt, lt = Qe;
          s.drawRoundPolygonPath(te || r, le.x + De, le.y + pe, o * q, u * W, ue, Ke);
        } else if (["roundrectangle", "round-rectangle"].includes(j))
          Q = Q === "auto" ? ur(K, Z) : Q, s.drawRoundRectanglePath(te || r, le.x, le.y, K, Z, Q + (M + G + X) / 2);
        else if (["cutrectangle", "cut-rectangle"].includes(j))
          Q = Q === "auto" ? co() : Q, s.drawCutRectanglePath(te || r, le.x, le.y, K, Z, null, Q + (M + G + X) / 4);
        else if (["bottomroundrectangle", "bottom-round-rectangle"].includes(j))
          Q = Q === "auto" ? ur(K, Z) : Q, s.drawBottomRoundRectanglePath(te || r, le.x, le.y, K, Z, Q + (M + G + X) / 2);
        else if (j === "barrel")
          s.drawBarrelPath(te || r, le.x, le.y, K, Z);
        else if (j.startsWith("polygon") || ["rhomboid", "right-rhomboid", "round-tag", "tag", "vee"].includes(j)) {
          var Ft = (M + G + X) / o;
          ue = Dn(Sn(ue, Ft)), s.drawPolygonPath(te || r, le.x, le.y, o, u, ue);
        } else {
          var er = (M + G + X) / o;
          ue = Dn(Sn(ue, -er)), s.drawPolygonPath(te || r, le.x, le.y, o, u, ue);
        }
        if (h ? r.stroke(te) : r.stroke(), H === "double") {
          r.lineWidth = M / 3;
          var Xt = r.globalCompositeOperation;
          r.globalCompositeOperation = "destination-out", h ? r.stroke(te) : r.stroke(), r.globalCompositeOperation = Xt;
        }
        r.setLineDash && r.setLineDash([]);
      }
    }, he = function() {
      n && s.drawNodeOverlay(r, e, c, o, u);
    }, ye = function() {
      n && s.drawNodeUnderlay(r, e, c, o, u);
    }, we = function() {
      s.drawElementText(r, e, null, a);
    }, Se = e.pstyle("ghost").value === "yes";
    if (Se) {
      var Fe = e.pstyle("ghost-offset-x").pfValue, Ye = e.pstyle("ghost-offset-y").pfValue, Ie = e.pstyle("ghost-opacity").value, We = Ie * v;
      r.translate(Fe, Ye), z(), ge(), re(Ie * R), be(), Ve(We, !0), J(Ie * F), ve(), Ne(A !== 0 || L !== 0), se(A !== 0 || L !== 0), Ve(We, !1), oe(We), r.translate(-Fe, -Ye);
    }
    h && r.translate(-c.x, -c.y), ye(), h && r.translate(c.x, c.y), z(), ge(), re(), be(), Ve(v, !0), J(), ve(), Ne(A !== 0 || L !== 0), se(A !== 0 || L !== 0), Ve(v, !1), oe(), h && r.translate(-c.x, -c.y), we(), he(), t && r.translate(y.x1, y.y1);
  }
};
var Nc = function(e) {
  if (!["overlay", "underlay"].includes(e))
    throw new Error("Invalid state");
  return function(t, a, n, i, s) {
    var o = 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, c = a.pstyle("".concat(e, "-shape")).value, v = a.pstyle("".concat(e, "-corner-radius")).value;
      if (l > 0) {
        if (n = n || a.position(), i == null || s == null) {
          var h = a.padding();
          i = a.width() + 2 * h, s = a.height() + 2 * h;
        }
        o.colorFillStyle(t, f[0], f[1], f[2], l), o.nodeShapes[c].draw(t, n.x, n.y, i + u * 2, s + u * 2, v), t.fill();
      }
    }
  };
};
pr.drawNodeOverlay = Nc("overlay");
pr.drawNodeUnderlay = Nc("underlay");
pr.hasPie = function(r) {
  return r = r[0], r._private.hasPie;
};
pr.hasStripe = function(r) {
  return r = r[0], r._private.hasStripe;
};
pr.drawPie = function(r, e, t, a) {
  e = e[0], a = a || e.position();
  var n = e.cy().style(), i = e.pstyle("pie-size"), s = e.pstyle("pie-hole"), o = e.pstyle("pie-start-angle").pfValue, u = a.x, l = a.y, f = e.width(), c = e.height(), v = Math.min(f, c) / 2, h, d = 0, p = this.usePaths();
  if (p && (u = 0, l = 0), i.units === "%" ? v = v * i.pfValue : i.pfValue !== void 0 && (v = i.pfValue / 2), s.units === "%" ? h = v * s.pfValue : s.pfValue !== void 0 && (h = s.pfValue / 2), !(h >= v))
    for (var g = 1; g <= n.pieBackgroundN; g++) {
      var y = e.pstyle("pie-" + g + "-background-size").value, b = e.pstyle("pie-" + g + "-background-color").value, m = e.pstyle("pie-" + g + "-background-opacity").value * t, E = y / 100;
      E + d > 1 && (E = 1 - d);
      var x = 1.5 * Math.PI + 2 * Math.PI * d;
      x += o;
      var S = 2 * Math.PI * E, w = x + S;
      y === 0 || d >= 1 || d + E > 1 || (h === 0 ? (r.beginPath(), r.moveTo(u, l), r.arc(u, l, v, x, w), r.closePath()) : (r.beginPath(), r.arc(u, l, v, x, w), r.arc(u, l, h, w, x, !0), r.closePath()), this.colorFillStyle(r, b[0], b[1], b[2], m), r.fill(), d += E);
    }
};
pr.drawStripe = function(r, e, t, a) {
  e = e[0], a = a || e.position();
  var n = e.cy().style(), i = a.x, s = a.y, o = e.width(), u = e.height(), l = 0, f = this.usePaths();
  r.save();
  var c = e.pstyle("stripe-direction").value, v = e.pstyle("stripe-size");
  switch (c) {
    case "vertical":
      break;
    case "righward":
      r.rotate(-Math.PI / 2);
      break;
  }
  var h = o, d = u;
  v.units === "%" ? (h = h * v.pfValue, d = d * v.pfValue) : v.pfValue !== void 0 && (h = v.pfValue, d = v.pfValue), f && (i = 0, s = 0), s -= h / 2, i -= d / 2;
  for (var p = 1; p <= n.stripeBackgroundN; p++) {
    var g = e.pstyle("stripe-" + p + "-background-size").value, y = e.pstyle("stripe-" + p + "-background-color").value, b = e.pstyle("stripe-" + p + "-background-opacity").value * t, m = g / 100;
    m + l > 1 && (m = 1 - l), !(g === 0 || l >= 1 || l + m > 1) && (r.beginPath(), r.rect(i, s + d * l, h, d * m), r.closePath(), this.colorFillStyle(r, y[0], y[1], y[2], b), r.fill(), l += m);
  }
  r.restore();
};
var bt = {}, em = 100;
bt.getPixelRatio = function() {
  var r = this.data.contexts[0];
  if (this.forcedPixelRatio != null)
    return this.forcedPixelRatio;
  var e = this.cy.window(), t = r.backingStorePixelRatio || r.webkitBackingStorePixelRatio || r.mozBackingStorePixelRatio || r.msBackingStorePixelRatio || r.oBackingStorePixelRatio || r.backingStorePixelRatio || 1;
  return (e.devicePixelRatio || 1) / t;
};
bt.paintCache = function(r) {
  for (var e = this.paintCaches = this.paintCaches || [], t = !0, a, n = 0; n < e.length; n++)
    if (a = e[n], a.context === r) {
      t = !1;
      break;
    }
  return t && (a = {
    context: r
  }, e.push(a)), a;
};
bt.createGradientStyleFor = function(r, e, t, a, n) {
  var i, s = this.usePaths(), o = t.pstyle(e + "-gradient-stop-colors").value, u = t.pstyle(e + "-gradient-stop-positions").pfValue;
  if (a === "radial-gradient")
    if (t.isEdge()) {
      var l = t.sourceEndpoint(), f = t.targetEndpoint(), c = t.midpoint(), v = Lr(l, c), h = Lr(f, c);
      i = r.createRadialGradient(c.x, c.y, 0, c.x, c.y, Math.max(v, h));
    } else {
      var d = s ? {
        x: 0,
        y: 0
      } : t.position(), p = t.paddedWidth(), g = t.paddedHeight();
      i = r.createRadialGradient(d.x, d.y, 0, d.x, d.y, Math.max(p, g));
    }
  else if (t.isEdge()) {
    var y = t.sourceEndpoint(), b = t.targetEndpoint();
    i = r.createLinearGradient(y.x, y.y, b.x, b.y);
  } else {
    var m = s ? {
      x: 0,
      y: 0
    } : t.position(), E = t.paddedWidth(), x = t.paddedHeight(), S = E / 2, w = x / 2, T = t.pstyle("background-gradient-direction").value;
    switch (T) {
      case "to-bottom":
        i = r.createLinearGradient(m.x, m.y - w, m.x, m.y + w);
        break;
      case "to-top":
        i = r.createLinearGradient(m.x, m.y + w, m.x, m.y - w);
        break;
      case "to-left":
        i = r.createLinearGradient(m.x + S, m.y, m.x - S, m.y);
        break;
      case "to-right":
        i = r.createLinearGradient(m.x - S, m.y, m.x + S, m.y);
        break;
      case "to-bottom-right":
      case "to-right-bottom":
        i = r.createLinearGradient(m.x - S, m.y - w, m.x + S, m.y + w);
        break;
      case "to-top-right":
      case "to-right-top":
        i = r.createLinearGradient(m.x - S, m.y + w, m.x + S, m.y - w);
        break;
      case "to-bottom-left":
      case "to-left-bottom":
        i = r.createLinearGradient(m.x + S, m.y - w, m.x - S, m.y + w);
        break;
      case "to-top-left":
      case "to-left-top":
        i = r.createLinearGradient(m.x + S, m.y + w, m.x - S, m.y - w);
        break;
    }
  }
  if (!i)
    return null;
  for (var C = u.length === o.length, D = o.length, A = 0; A < D; A++)
    i.addColorStop(C ? u[A] : A / (D - 1), "rgba(" + o[A][0] + "," + o[A][1] + "," + o[A][2] + "," + n + ")");
  return i;
};
bt.gradientFillStyle = function(r, e, t, a) {
  var n = this.createGradientStyleFor(r, "background", e, t, a);
  if (!n)
    return null;
  r.fillStyle = n;
};
bt.colorFillStyle = function(r, e, t, a, n) {
  r.fillStyle = "rgba(" + e + "," + t + "," + a + "," + n + ")";
};
bt.eleFillStyle = function(r, e, t) {
  var a = e.pstyle("background-fill").value;
  if (a === "linear-gradient" || a === "radial-gradient")
    this.gradientFillStyle(r, e, a, t);
  else {
    var n = e.pstyle("background-color").value;
    this.colorFillStyle(r, n[0], n[1], n[2], t);
  }
};
bt.gradientStrokeStyle = function(r, e, t, a) {
  var n = this.createGradientStyleFor(r, "line", e, t, a);
  if (!n)
    return null;
  r.strokeStyle = n;
};
bt.colorStrokeStyle = function(r, e, t, a, n) {
  r.strokeStyle = "rgba(" + e + "," + t + "," + a + "," + n + ")";
};
bt.eleStrokeStyle = function(r, e, t) {
  var a = e.pstyle("line-fill").value;
  if (a === "linear-gradient" || a === "radial-gradient")
    this.gradientStrokeStyle(r, e, a, t);
  else {
    var n = e.pstyle("line-color").value;
    this.colorStrokeStyle(r, n[0], n[1], n[2], t);
  }
};
bt.matchCanvasSize = function(r) {
  var e = this, t = e.data, a = e.findContainerClientCoords(), n = a[2], i = a[3], s = e.getPixelRatio(), o = e.motionBlurPxRatio;
  (r === e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE] || r === e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG]) && (s = o);
  var u = n * s, l = i * s, f;
  if (!(u === e.canvasWidth && l === e.canvasHeight)) {
    e.fontCaches = null;
    var c = t.canvasContainer;
    c.style.width = n + "px", c.style.height = i + "px";
    for (var v = 0; v < e.CANVAS_LAYERS; v++)
      f = t.canvases[v], f.width = u, f.height = l, f.style.width = n + "px", f.style.height = i + "px";
    for (var v = 0; v < e.BUFFER_COUNT; v++)
      f = t.bufferCanvases[v], f.width = u, f.height = l, f.style.width = n + "px", f.style.height = i + "px";
    e.textureMult = 1, s <= 1 && (f = t.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 = s;
  }
};
bt.renderTo = function(r, e, t, a) {
  this.render({
    forcedContext: r,
    forcedZoom: e,
    forcedPan: t,
    drawAllLayers: !0,
    forcedPxRatio: a
  });
};
bt.clearCanvas = function() {
  var r = this, e = r.data;
  function t(a) {
    a.clearRect(0, 0, r.canvasWidth, r.canvasHeight);
  }
  t(e.contexts[r.NODE]), t(e.contexts[r.DRAG]);
};
bt.render = function(r) {
  var e = this;
  r = r || Cf();
  var t = e.cy, a = r.forcedContext, n = r.drawAllLayers, i = r.drawOnlyNodeLayer, s = r.forcedZoom, o = r.forcedPan, u = r.forcedPxRatio === void 0 ? this.getPixelRatio() : r.forcedPxRatio, l = e.data, f = l.canvasNeedsRedraw, c = e.textureOnViewport && !a && (e.pinching || e.hoverData.dragging || e.swipePanning || e.data.wheelZooming), v = r.motionBlur !== void 0 ? r.motionBlur : e.motionBlur, h = e.motionBlurPxRatio, d = t.hasCompoundNodes(), p = e.hoverData.draggingEles, g = !!(e.hoverData.selecting || e.touchData.selecting);
  v = v && !a && e.motionBlurEnabled && !g;
  var y = v;
  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), v && (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 && !c && (f[e.NODE] = !0, f[e.SELECT_BOX] = !0);
  var b = t.style(), m = t.zoom(), E = s !== void 0 ? s : m, x = t.pan(), S = {
    x: x.x,
    y: x.y
  }, w = {
    zoom: m,
    pan: {
      x: x.x,
      y: x.y
    }
  }, T = e.prevViewport, C = T === void 0 || w.zoom !== T.zoom || w.pan.x !== T.pan.x || w.pan.y !== T.pan.y;
  !C && !(p && !d) && (e.motionBlurPxRatio = 1), o && (S = o), E *= u, S.x *= u, S.y *= u;
  var D = e.getCachedZSortedEles();
  function A(J, z, V, Y, ee) {
    var ne = J.globalCompositeOperation;
    J.globalCompositeOperation = "destination-out", e.colorFillStyle(J, 255, 255, 255, e.motionBlurTransparency), J.fillRect(z, V, Y, ee), J.globalCompositeOperation = ne;
  }
  function L(J, z) {
    var V, Y, ee, ne;
    !e.clearingMotionBlur && (J === l.bufferContexts[e.MOTIONBLUR_BUFFER_NODE] || J === l.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG]) ? (V = {
      x: x.x * h,
      y: x.y * h
    }, Y = m * h, ee = e.canvasWidth * h, ne = e.canvasHeight * h) : (V = S, Y = E, ee = e.canvasWidth, ne = e.canvasHeight), J.setTransform(1, 0, 0, 1, 0, 0), z === "motionBlur" ? A(J, 0, 0, ee, ne) : !a && (z === void 0 || z) && J.clearRect(0, 0, ee, ne), n || (J.translate(V.x, V.y), J.scale(Y, Y)), o && J.translate(o.x, o.y), s && J.scale(s, s);
  }
  if (c || (e.textureDrawLastFrame = !1), c) {
    if (e.textureDrawLastFrame = !0, !e.textureCache) {
      e.textureCache = {}, e.textureCache.bb = t.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: t.zoom(),
        pan: t.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 I = l.contexts[e.NODE], O = e.textureCache.texture, w = e.textureCache.viewport;
    I.setTransform(1, 0, 0, 1, 0, 0), v ? A(I, 0, 0, w.width, w.height) : I.clearRect(0, 0, w.width, w.height);
    var N = b.core("outside-texture-bg-color").value, k = b.core("outside-texture-bg-opacity").value;
    e.colorFillStyle(I, N[0], N[1], N[2], k), I.fillRect(0, 0, w.width, w.height);
    var m = t.zoom();
    L(I, !1), I.clearRect(w.mpan.x, w.mpan.y, w.width / w.zoom / u, w.height / w.zoom / u), I.drawImage(O, w.mpan.x, w.mpan.y, w.width / w.zoom / u, w.height / w.zoom / u);
  } else
    e.textureOnViewport && !a && (e.textureCache = null);
  var P = t.extent(), B = e.pinching || e.hoverData.dragging || e.swipePanning || e.data.wheelZooming || e.hoverData.draggingEles || e.cy.animated(), _ = e.hideEdgesOnViewport && B, F = [];
  if (F[e.NODE] = !f[e.NODE] && v && !e.clearedForMotionBlur[e.NODE] || e.clearingMotionBlur, F[e.NODE] && (e.clearedForMotionBlur[e.NODE] = !0), F[e.DRAG] = !f[e.DRAG] && v && !e.clearedForMotionBlur[e.DRAG] || e.clearingMotionBlur, F[e.DRAG] && (e.clearedForMotionBlur[e.DRAG] = !0), f[e.NODE] || n || i || F[e.NODE]) {
    var G = v && !F[e.NODE] && h !== 1, I = a || (G ? e.data.bufferContexts[e.MOTIONBLUR_BUFFER_NODE] : l.contexts[e.NODE]), U = v && !G ? "motionBlur" : void 0;
    L(I, U), _ ? e.drawCachedNodes(I, D.nondrag, u, P) : e.drawLayeredElements(I, D.nondrag, u, P), e.debug && e.drawDebugPoints(I, D.nondrag), !n && !v && (f[e.NODE] = !1);
  }
  if (!i && (f[e.DRAG] || n || F[e.DRAG])) {
    var G = v && !F[e.DRAG] && h !== 1, I = a || (G ? e.data.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG] : l.contexts[e.DRAG]);
    L(I, v && !G ? "motionBlur" : void 0), _ ? e.drawCachedNodes(I, D.drag, u, P) : e.drawCachedElements(I, D.drag, u, P), e.debug && e.drawDebugPoints(I, D.drag), !n && !v && (f[e.DRAG] = !1);
  }
  if (this.drawSelectionRectangle(r, L), v && h !== 1) {
    var H = l.contexts[e.NODE], $ = e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE], X = l.contexts[e.DRAG], Q = e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG], re = function(z, V, Y) {
      z.setTransform(1, 0, 0, 1, 0, 0), Y || !y ? z.clearRect(0, 0, e.canvasWidth, e.canvasHeight) : A(z, 0, 0, e.canvasWidth, e.canvasHeight);
      var ee = h;
      z.drawImage(
        V,
        // img
        0,
        0,
        // sx, sy
        e.canvasWidth * ee,
        e.canvasHeight * ee,
        // sw, sh
        0,
        0,
        // x, y
        e.canvasWidth,
        e.canvasHeight
        // w, h
      );
    };
    (f[e.NODE] || F[e.NODE]) && (re(H, $, F[e.NODE]), f[e.NODE] = !1), (f[e.DRAG] || F[e.DRAG]) && (re(X, Q, F[e.DRAG]), f[e.DRAG] = !1);
  }
  e.prevViewport = w, e.clearingMotionBlur && (e.clearingMotionBlur = !1, e.motionBlurCleared = !0, e.motionBlur = !0), v && (e.motionBlurTimeout = setTimeout(function() {
    e.motionBlurTimeout = null, e.clearedForMotionBlur[e.NODE] = !1, e.clearedForMotionBlur[e.DRAG] = !1, e.motionBlur = !1, e.clearingMotionBlur = !c, e.mbFrames = 0, f[e.NODE] = !0, f[e.DRAG] = !0, e.redraw();
  }, em)), a || t.emit("render");
};
var da;
bt.drawSelectionRectangle = function(r, e) {
  var t = this, a = t.cy, n = t.data, i = a.style(), s = r.drawOnlyNodeLayer, o = r.drawAllLayers, u = n.canvasNeedsRedraw, l = r.forcedContext;
  if (t.showFps || !s && u[t.SELECT_BOX] && !o) {
    var f = l || n.contexts[t.SELECT_BOX];
    if (e(f), t.selection[4] == 1 && (t.hoverData.selecting || t.touchData.selecting)) {
      var c = t.cy.zoom(), v = i.core("selection-box-border-width").value / c;
      f.lineWidth = v, 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(t.selection[0], t.selection[1], t.selection[2] - t.selection[0], t.selection[3] - t.selection[1]), v > 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(t.selection[0], t.selection[1], t.selection[2] - t.selection[0], t.selection[3] - t.selection[1]));
    }
    if (n.bgActivePosistion && !t.hoverData.selecting) {
      var c = t.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 / c, 0, 2 * Math.PI), f.fill();
    }
    var d = t.lastRedrawTime;
    if (t.showFps && d) {
      d = Math.round(d);
      var p = Math.round(1e3 / d), g = "1 frame = " + d + " ms = " + p + " 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(g);
        da = y.actualBoundingBoxAscent;
      }
      f.fillText(g, 0, da);
      var b = 60;
      f.strokeRect(0, da + 10, 250, 20), f.fillRect(0, da + 10, 250 * Math.min(p / b, 1), 20);
    }
    o || (u[t.SELECT_BOX] = !1);
  }
};
function Wl(r, e, t) {
  var a = r.createShader(e);
  if (r.shaderSource(a, t), r.compileShader(a), !r.getShaderParameter(a, r.COMPILE_STATUS))
    throw new Error(r.getShaderInfoLog(a));
  return a;
}
function tm(r, e, t) {
  var a = Wl(r, r.VERTEX_SHADER, e), n = Wl(r, r.FRAGMENT_SHADER, t), i = r.createProgram();
  if (r.attachShader(i, a), r.attachShader(i, n), r.linkProgram(i), !r.getProgramParameter(i, r.LINK_STATUS))
    throw new Error("Could not initialize shaders");
  return i;
}
function rm(r, e, t) {
  t === void 0 && (t = e);
  var a = r.makeOffscreenCanvas(e, t), n = a.context = a.getContext("2d");
  return a.clear = function() {
    return n.clearRect(0, 0, a.width, a.height);
  }, a.clear(), a;
}
function So(r) {
  var e = r.pixelRatio, t = r.cy.zoom(), a = r.cy.pan();
  return {
    zoom: t * e,
    pan: {
      x: a.x * e,
      y: a.y * e
    }
  };
}
function am(r) {
  var e = r.pixelRatio, t = r.cy.zoom();
  return t * e;
}
function nm(r, e, t, a, n) {
  var i = a * t + e.x, s = n * t + e.y;
  return s = Math.round(r.canvasHeight - s), [i, s];
}
function im(r) {
  return r.pstyle("background-fill").value !== "solid" || r.pstyle("background-image").strValue !== "none" ? !1 : r.pstyle("border-width").value === 0 || r.pstyle("border-opacity").value === 0 ? !0 : r.pstyle("border-style").value === "solid";
}
function sm(r, e) {
  if (r.length !== e.length)
    return !1;
  for (var t = 0; t < r.length; t++)
    if (r[t] !== e[t])
      return !1;
  return !0;
}
function wr(r, e, t) {
  var a = r[0] / 255, n = r[1] / 255, i = r[2] / 255, s = e, o = t || new Array(4);
  return o[0] = a * s, o[1] = n * s, o[2] = i * s, o[3] = s, o;
}
function Vr(r, e) {
  var t = e || new Array(4);
  return t[0] = (r >> 0 & 255) / 255, t[1] = (r >> 8 & 255) / 255, t[2] = (r >> 16 & 255) / 255, t[3] = (r >> 24 & 255) / 255, t;
}
function om(r) {
  return r[0] + (r[1] << 8) + (r[2] << 16) + (r[3] << 24);
}
function um(r, e) {
  var t = r.createTexture();
  return t.buffer = function(a) {
    r.bindTexture(r.TEXTURE_2D, t), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MAG_FILTER, r.LINEAR), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR_MIPMAP_NEAREST), r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, a), r.generateMipmap(r.TEXTURE_2D), r.bindTexture(r.TEXTURE_2D, null);
  }, t.deleteTexture = function() {
    r.deleteTexture(t);
  }, t;
}
function kc(r, e) {
  switch (e) {
    case "float":
      return [1, r.FLOAT, 4];
    case "vec2":
      return [2, r.FLOAT, 4];
    case "vec3":
      return [3, r.FLOAT, 4];
    case "vec4":
      return [4, r.FLOAT, 4];
    case "int":
      return [1, r.INT, 4];
    case "ivec2":
      return [2, r.INT, 4];
  }
}
function Bc(r, e, t) {
  switch (e) {
    case r.FLOAT:
      return new Float32Array(t);
    case r.INT:
      return new Int32Array(t);
  }
}
function lm(r, e, t, a, n, i) {
  switch (e) {
    case r.FLOAT:
      return new Float32Array(t.buffer, i * a, n);
    case r.INT:
      return new Int32Array(t.buffer, i * a, n);
  }
}
function fm(r, e, t, a) {
  var n = kc(r, e), i = je(n, 2), s = i[0], o = i[1], u = Bc(r, o, a), l = r.createBuffer();
  return r.bindBuffer(r.ARRAY_BUFFER, l), r.bufferData(r.ARRAY_BUFFER, u, r.STATIC_DRAW), o === r.FLOAT ? r.vertexAttribPointer(t, s, o, !1, 0, 0) : o === r.INT && r.vertexAttribIPointer(t, s, o, 0, 0), r.enableVertexAttribArray(t), r.bindBuffer(r.ARRAY_BUFFER, null), l;
}
function zt(r, e, t, a) {
  var n = kc(r, t), i = je(n, 3), s = i[0], o = i[1], u = i[2], l = Bc(r, o, e * s), f = s * u, c = r.createBuffer();
  r.bindBuffer(r.ARRAY_BUFFER, c), r.bufferData(r.ARRAY_BUFFER, e * f, r.DYNAMIC_DRAW), r.enableVertexAttribArray(a), o === r.FLOAT ? r.vertexAttribPointer(a, s, o, !1, f, 0) : o === r.INT && r.vertexAttribIPointer(a, s, o, f, 0), r.vertexAttribDivisor(a, 1), r.bindBuffer(r.ARRAY_BUFFER, null);
  for (var v = new Array(e), h = 0; h < e; h++)
    v[h] = lm(r, o, l, f, s, h);
  return c.dataArray = l, c.stride = f, c.size = s, c.getView = function(d) {
    return v[d];
  }, c.setPoint = function(d, p, g) {
    var y = v[d];
    y[0] = p, y[1] = g;
  }, c.bufferSubData = function(d) {
    r.bindBuffer(r.ARRAY_BUFFER, c), d ? r.bufferSubData(r.ARRAY_BUFFER, 0, l, 0, d * s) : r.bufferSubData(r.ARRAY_BUFFER, 0, l);
  }, c;
}
function cm(r, e, t) {
  for (var a = 9, n = new Float32Array(e * a), i = new Array(e), s = 0; s < e; s++) {
    var o = s * a * 4;
    i[s] = new Float32Array(n.buffer, o, a);
  }
  var u = r.createBuffer();
  r.bindBuffer(r.ARRAY_BUFFER, u), r.bufferData(r.ARRAY_BUFFER, n.byteLength, r.DYNAMIC_DRAW);
  for (var l = 0; l < 3; l++) {
    var f = t + l;
    r.enableVertexAttribArray(f), r.vertexAttribPointer(f, 3, r.FLOAT, !1, 3 * 12, l * 12), r.vertexAttribDivisor(f, 1);
  }
  return r.bindBuffer(r.ARRAY_BUFFER, null), u.getMatrixView = function(c) {
    return i[c];
  }, u.setData = function(c, v) {
    i[v].set(c, 0);
  }, u.bufferSubData = function() {
    r.bindBuffer(r.ARRAY_BUFFER, u), r.bufferSubData(r.ARRAY_BUFFER, 0, n);
  }, u;
}
function vm(r) {
  var e = r.createFramebuffer();
  r.bindFramebuffer(r.FRAMEBUFFER, e);
  var t = r.createTexture();
  return r.bindTexture(r.TEXTURE_2D, t), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, t, 0), r.bindFramebuffer(r.FRAMEBUFFER, null), e.setFramebufferAttachmentSizes = function(a, n) {
    r.bindTexture(r.TEXTURE_2D, t), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, a, n, 0, r.RGBA, r.UNSIGNED_BYTE, null);
  }, e;
}
var Kl = typeof Float32Array < "u" ? Float32Array : Array;
Math.hypot || (Math.hypot = function() {
  for (var r = 0, e = arguments.length; e--; )
    r += arguments[e] * arguments[e];
  return Math.sqrt(r);
});
function Cs() {
  var r = new Kl(9);
  return Kl != Float32Array && (r[1] = 0, r[2] = 0, r[3] = 0, r[5] = 0, r[6] = 0, r[7] = 0), r[0] = 1, r[4] = 1, r[8] = 1, r;
}
function Zl(r) {
  return r[0] = 1, r[1] = 0, r[2] = 0, r[3] = 0, r[4] = 1, r[5] = 0, r[6] = 0, r[7] = 0, r[8] = 1, r;
}
function hm(r, e, t) {
  var a = e[0], n = e[1], i = e[2], s = e[3], o = e[4], u = e[5], l = e[6], f = e[7], c = e[8], v = t[0], h = t[1], d = t[2], p = t[3], g = t[4], y = t[5], b = t[6], m = t[7], E = t[8];
  return r[0] = v * a + h * s + d * l, r[1] = v * n + h * o + d * f, r[2] = v * i + h * u + d * c, r[3] = p * a + g * s + y * l, r[4] = p * n + g * o + y * f, r[5] = p * i + g * u + y * c, r[6] = b * a + m * s + E * l, r[7] = b * n + m * o + E * f, r[8] = b * i + m * u + E * c, r;
}
function mn(r, e, t) {
  var a = e[0], n = e[1], i = e[2], s = e[3], o = e[4], u = e[5], l = e[6], f = e[7], c = e[8], v = t[0], h = t[1];
  return r[0] = a, r[1] = n, r[2] = i, r[3] = s, r[4] = o, r[5] = u, r[6] = v * a + h * s + l, r[7] = v * n + h * o + f, r[8] = v * i + h * u + c, r;
}
function Ql(r, e, t) {
  var a = e[0], n = e[1], i = e[2], s = e[3], o = e[4], u = e[5], l = e[6], f = e[7], c = e[8], v = Math.sin(t), h = Math.cos(t);
  return r[0] = h * a + v * s, r[1] = h * n + v * o, r[2] = h * i + v * u, r[3] = h * s - v * a, r[4] = h * o - v * n, r[5] = h * u - v * i, r[6] = l, r[7] = f, r[8] = c, r;
}
function Ws(r, e, t) {
  var a = t[0], n = t[1];
  return r[0] = a * e[0], r[1] = a * e[1], r[2] = a * e[2], r[3] = n * e[3], r[4] = n * e[4], r[5] = n * e[5], r[6] = e[6], r[7] = e[7], r[8] = e[8], r;
}
function dm(r, e, t) {
  return r[0] = 2 / e, r[1] = 0, r[2] = 0, r[3] = 0, r[4] = -2 / t, r[5] = 0, r[6] = -1, r[7] = 1, r[8] = 1, r;
}
var gm = /* @__PURE__ */ function() {
  function r(e, t, a, n) {
    hr(this, r), this.debugID = Math.floor(Math.random() * 1e4), this.r = e, this.texSize = t, this.texRows = a, this.texHeight = Math.floor(t / 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, t, t), this.scratch = n(e, t, this.texHeight, "scratch");
  }
  return dr(r, [{
    key: "lock",
    value: function() {
      this.locked = !0;
    }
  }, {
    key: "getKeys",
    value: function() {
      return new Set(this.keyToLocation.keys());
    }
  }, {
    key: "getScale",
    value: function(t) {
      var a = t.w, n = t.h, i = this.texHeight, s = this.texSize, o = i / n, u = a * o, l = n * o;
      return u > s && (o = s / a, u = a * o, l = n * o), {
        scale: o,
        texW: u,
        texH: l
      };
    }
  }, {
    key: "draw",
    value: function(t, a, n) {
      var i = this;
      if (this.locked)
        throw new Error("can't draw, atlas is locked");
      var s = this.texSize, o = this.texRows, u = this.texHeight, l = this.getScale(a), f = l.scale, c = l.texW, v = l.texH, h = function(m, E) {
        if (n && E) {
          var x = E.context, S = m.x, w = m.row, T = S, C = u * w;
          x.save(), x.translate(T, C), x.scale(f, f), n(x, a), x.restore();
        }
      }, d = [null, null], p = function() {
        h(i.freePointer, i.canvas), d[0] = {
          x: i.freePointer.x,
          y: i.freePointer.row * u,
          w: c,
          h: v
        }, d[1] = {
          // create a second location with a width of 0, for convenience
          x: i.freePointer.x + c,
          y: i.freePointer.row * u,
          w: 0,
          h: v
        }, i.freePointer.x += c, i.freePointer.x == s && (i.freePointer.x = 0, i.freePointer.row++);
      }, g = function() {
        var m = i.scratch, E = i.canvas;
        m.clear(), h({
          x: 0,
          row: 0
        }, m);
        var x = s - i.freePointer.x, S = c - x, w = u;
        {
          var T = i.freePointer.x, C = i.freePointer.row * u, D = x;
          E.context.drawImage(m, 0, 0, D, w, T, C, D, w), d[0] = {
            x: T,
            y: C,
            w: D,
            h: v
          };
        }
        {
          var A = x, 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: v
          };
        }
        i.freePointer.x = S, i.freePointer.row++;
      }, y = function() {
        i.freePointer.x = 0, i.freePointer.row++;
      };
      if (this.freePointer.x + c <= s)
        p();
      else {
        if (this.freePointer.row >= o - 1)
          return !1;
        this.freePointer.x === s ? (y(), p()) : this.enableWrapping ? g() : (y(), p());
      }
      return this.keyToLocation.set(t, d), this.needsBuffer = !0, d;
    }
  }, {
    key: "getOffsets",
    value: function(t) {
      return this.keyToLocation.get(t);
    }
  }, {
    key: "isEmpty",
    value: function() {
      return this.freePointer.x === 0 && this.freePointer.row === 0;
    }
  }, {
    key: "canFit",
    value: function(t) {
      if (this.locked)
        return !1;
      var a = this.texSize, n = this.texRows, i = this.getScale(t), s = i.texW;
      return this.freePointer.x + s > a ? this.freePointer.row < n - 1 : !0;
    }
    // called on every frame
  }, {
    key: "bufferIfNeeded",
    value: function(t) {
      this.texture || (this.texture = um(t, 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;
    }
  }]);
}(), pm = /* @__PURE__ */ function() {
  function r(e, t, a, n) {
    hr(this, r), this.r = e, this.texSize = t, this.texRows = a, this.createTextureCanvas = n, this.atlases = [], this.styleKeyToAtlas = /* @__PURE__ */ new Map(), this.markedKeys = /* @__PURE__ */ new Set();
  }
  return dr(r, [{
    key: "getKeys",
    value: function() {
      return new Set(this.styleKeyToAtlas.keys());
    }
  }, {
    key: "_createAtlas",
    value: function() {
      var t = this.r, a = this.texSize, n = this.texRows, i = this.createTextureCanvas;
      return new gm(t, a, n, i);
    }
  }, {
    key: "_getScratchCanvas",
    value: function() {
      if (!this.scratch) {
        var t = this.r, a = this.texSize, n = this.texRows, i = this.createTextureCanvas, s = Math.floor(a / n);
        this.scratch = i(t, a, s, "scratch");
      }
      return this.scratch;
    }
  }, {
    key: "draw",
    value: function(t, a, n) {
      var i = this.styleKeyToAtlas.get(t);
      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(t, a, n), this.styleKeyToAtlas.set(t, i)), i;
    }
  }, {
    key: "getAtlas",
    value: function(t) {
      return this.styleKeyToAtlas.get(t);
    }
  }, {
    key: "hasAtlas",
    value: function(t) {
      return this.styleKeyToAtlas.has(t);
    }
  }, {
    key: "markKeyForGC",
    value: function(t) {
      this.markedKeys.add(t);
    }
  }, {
    key: "gc",
    value: function() {
      var t = this, a = this.markedKeys;
      if (a.size === 0) {
        console.log("nothing to garbage collect");
        return;
      }
      var n = [], i = /* @__PURE__ */ new Map(), s = null, o = Dt(this.atlases), u;
      try {
        var l = function() {
          var c = u.value, v = c.getKeys(), h = ym(a, v);
          if (h.size === 0)
            return n.push(c), v.forEach(function(x) {
              return i.set(x, c);
            }), 1;
          s || (s = t._createAtlas(), n.push(s));
          var d = Dt(v), p;
          try {
            for (d.s(); !(p = d.n()).done; ) {
              var g = p.value;
              if (!h.has(g)) {
                var y = c.getOffsets(g), b = je(y, 2), m = b[0], E = b[1];
                s.canFit({
                  w: m.w + E.w,
                  h: m.h
                }) || (s.lock(), s = t._createAtlas(), n.push(s)), c.canvas && (t._copyTextureToNewAtlas(g, c, s), i.set(g, s));
              }
            }
          } catch (x) {
            d.e(x);
          } finally {
            d.f();
          }
          c.dispose();
        };
        for (o.s(); !(u = o.n()).done; )
          l();
      } catch (f) {
        o.e(f);
      } finally {
        o.f();
      }
      this.atlases = n, this.styleKeyToAtlas = i, this.markedKeys = /* @__PURE__ */ new Set();
    }
  }, {
    key: "_copyTextureToNewAtlas",
    value: function(t, a, n) {
      var i = a.getOffsets(t), s = je(i, 2), o = s[0], u = s[1];
      if (u.w === 0)
        n.draw(t, o, function(v) {
          v.drawImage(a.canvas, o.x, o.y, o.w, o.h, 0, 0, o.w, o.h);
        });
      else {
        var l = this._getScratchCanvas();
        l.clear(), l.context.drawImage(a.canvas, o.x, o.y, o.w, o.h, 0, 0, o.w, o.h), l.context.drawImage(a.canvas, u.x, u.y, u.w, u.h, o.w, 0, u.w, u.h);
        var f = o.w + u.w, c = o.h;
        n.draw(t, {
          w: f,
          h: c
        }, function(v) {
          v.drawImage(
            l,
            0,
            0,
            f,
            c,
            0,
            0,
            f,
            c
            // 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 ym(r, e) {
  return r.intersection ? r.intersection(e) : new Set(En(r).filter(function(t) {
    return e.has(t);
  }));
}
var mm = /* @__PURE__ */ function() {
  function r(e, t) {
    hr(this, r), this.r = e, this.globalOptions = t, this.atlasSize = t.webglTexSize, this.maxAtlasesPerBatch = t.webglTexPerBatch, this.renderTypes = /* @__PURE__ */ new Map(), this.collections = /* @__PURE__ */ new Map(), this.typeAndIdToKey = /* @__PURE__ */ new Map();
  }
  return dr(r, [{
    key: "getAtlasSize",
    value: function() {
      return this.atlasSize;
    }
  }, {
    key: "addAtlasCollection",
    value: function(t, a) {
      var n = this.globalOptions, i = n.webglTexSize, s = n.createTextureCanvas, o = a.texRows, u = this._cacheScratchCanvas(s), l = new pm(this.r, i, o, u);
      this.collections.set(t, l);
    }
  }, {
    key: "addRenderType",
    value: function(t, 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), s = de({
        type: t,
        atlasCollection: i
      }, a);
      this.renderTypes.set(t, s);
    }
  }, {
    key: "getRenderTypeOpts",
    value: function(t) {
      return this.renderTypes.get(t);
    }
  }, {
    key: "getAtlasCollection",
    value: function(t) {
      return this.collections.get(t);
    }
  }, {
    key: "_cacheScratchCanvas",
    value: function(t) {
      var a = -1, n = -1, i = null;
      return function(s, o, u, l) {
        return l ? ((!i || o != a || u != n) && (a = o, n = u, i = t(s, o, u)), i) : t(s, o, u);
      };
    }
  }, {
    key: "_key",
    value: function(t, a) {
      return "".concat(t, "-").concat(a);
    }
    /** Marks textues associated with the element for garbage collection. */
  }, {
    key: "invalidate",
    value: function(t) {
      var a = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = n.forceRedraw, s = i === void 0 ? !1 : i, o = n.filterEle, u = o === void 0 ? function() {
        return !0;
      } : o, l = n.filterType, f = l === void 0 ? function() {
        return !0;
      } : l, c = !1, v = !1, h = Dt(t), d;
      try {
        for (h.s(); !(d = h.n()).done; ) {
          var p = d.value;
          if (u(p)) {
            var g = Dt(this.renderTypes.values()), y;
            try {
              var b = function() {
                var E = y.value, x = E.type;
                if (f(x)) {
                  var S = a.collections.get(E.collection), w = E.getKey(p), T = Array.isArray(w) ? w : [w];
                  if (s)
                    T.forEach(function(L) {
                      return S.markKeyForGC(L);
                    }), v = !0;
                  else {
                    var C = E.getID ? E.getID(p) : p.id(), D = a._key(x, C), A = a.typeAndIdToKey.get(D);
                    A !== void 0 && !sm(T, A) && (c = !0, a.typeAndIdToKey.delete(D), A.forEach(function(L) {
                      return S.markKeyForGC(L);
                    }));
                  }
                }
              };
              for (g.s(); !(y = g.n()).done; )
                b();
            } catch (m) {
              g.e(m);
            } finally {
              g.f();
            }
          }
        }
      } catch (m) {
        h.e(m);
      } finally {
        h.f();
      }
      return v && (this.gc(), c = !1), c;
    }
    /** Garbage collect */
  }, {
    key: "gc",
    value: function() {
      var t = Dt(this.collections.values()), a;
      try {
        for (t.s(); !(a = t.n()).done; ) {
          var n = a.value;
          n.gc();
        }
      } catch (i) {
        t.e(i);
      } finally {
        t.f();
      }
    }
  }, {
    key: "getOrCreateAtlas",
    value: function(t, a, n, i) {
      var s = this.renderTypes.get(a), o = this.collections.get(s.collection), u = !1, l = o.draw(i, n, function(v) {
        s.drawClipped ? (v.save(), v.beginPath(), v.rect(0, 0, n.w, n.h), v.clip(), s.drawElement(v, t, n, !0, !0), v.restore()) : s.drawElement(v, t, n, !0, !0), u = !0;
      });
      if (u) {
        var f = s.getID ? s.getID(t) : t.id(), c = this._key(a, f);
        this.typeAndIdToKey.has(c) ? this.typeAndIdToKey.get(c).push(i) : this.typeAndIdToKey.set(c, [i]);
      }
      return l;
    }
  }, {
    key: "getAtlasInfo",
    value: function(t, a) {
      var n = this, i = this.renderTypes.get(a), s = i.getKey(t), o = Array.isArray(s) ? s : [s];
      return o.map(function(u) {
        var l = i.getBoundingBox(t, u), f = n.getOrCreateAtlas(t, a, l, u), c = f.getOffsets(u), v = je(c, 2), h = v[0], d = v[1];
        return {
          atlas: f,
          tex: h,
          tex1: h,
          tex2: d,
          bb: l
        };
      });
    }
  }, {
    key: "getDebugInfo",
    value: function() {
      var t = [], a = Dt(this.collections), n;
      try {
        for (a.s(); !(n = a.n()).done; ) {
          var i = je(n.value, 2), s = i[0], o = i[1], u = o.getCounts(), l = u.keyCount, f = u.atlasCount;
          t.push({
            type: s,
            keyCount: l,
            atlasCount: f
          });
        }
      } catch (c) {
        a.e(c);
      } finally {
        a.f();
      }
      return t;
    }
  }]);
}(), bm = /* @__PURE__ */ function() {
  function r(e) {
    hr(this, r), this.globalOptions = e, this.atlasSize = e.webglTexSize, this.maxAtlasesPerBatch = e.webglTexPerBatch, this.batchAtlases = [];
  }
  return dr(r, [{
    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(t, 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(t) {
      return this.batchAtlases.length === this.maxAtlasesPerBatch ? this.batchAtlases.includes(t) : !0;
    }
  }, {
    key: "getAtlasIndexForBatch",
    value: function(t) {
      var a = this.batchAtlases.indexOf(t);
      if (a < 0) {
        if (this.batchAtlases.length === this.maxAtlasesPerBatch)
          throw new Error("cannot add more atlases to batch");
        this.batchAtlases.push(t), a = this.batchAtlases.length - 1;
      }
      return a;
    }
  }]);
}(), wm = `
  float circleSD(vec2 p, float r) {
    return distance(vec2(0), p) - r; // signed distance
  }
`, Em = `
  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);
  }
`, xm = `
  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;
  }
`, Tm = `
  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
  }
}, Pn = {
  // 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
}, Ds = 0, Jl = 1, jl = 2, Ss = 3, Ur = 4, on = 5, ga = 6, pa = 7, Cm = /* @__PURE__ */ function() {
  function r(e, t, a) {
    hr(this, r), this.r = e, this.gl = t, this.maxInstances = a.webglBatchSize, this.atlasSize = a.webglTexSize, this.bgColor = a.bgColor, this.debug = a.webglDebug, this.batchDebugInfo = [], a.enableWrapping = !0, a.createTextureCanvas = rm, this.atlasManager = new mm(e, a), this.batchManager = new bm(a), this.simpleShapeOptions = /* @__PURE__ */ new Map(), this.program = this._createShaderProgram(xa.SCREEN), this.pickingProgram = this._createShaderProgram(xa.PICKING), this.vao = this._createVAO();
  }
  return dr(r, [{
    key: "addAtlasCollection",
    value: function(t, a) {
      this.atlasManager.addAtlasCollection(t, 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(t, a) {
      this.atlasManager.addRenderType(t, 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(t, a) {
      this.simpleShapeOptions.set(t, 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(t) {
      var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = a.type, i = this.atlasManager;
      return n ? i.invalidate(t, {
        filterType: function(o) {
          return o === n;
        },
        forceRedraw: !0
      }) : i.invalidate(t);
    }
    /**
     * Run texture garbage collection.
     */
  }, {
    key: "gc",
    value: function() {
      this.atlasManager.gc();
    }
  }, {
    key: "_createShaderProgram",
    value: function(t) {
      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(Ds, `) {
          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(Ur, " || 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(Jl, `) {
          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(jl, `) {
          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(Ss, ` && 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(), s = `#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(wm, `
      `).concat(Em, `
      `).concat(xm, `
      `).concat(Tm, `

      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(Ds, `) {
          // 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(Ss, `) {
          // 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(Ur, ` && 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(Ur, " || 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(Ur, `) {
            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(t.picking ? `if(outColor.a == 0.0) discard;
             else outColor = vIndex;` : "", `
      }
    `), o = tm(a, n, s);
      o.aPosition = a.getAttribLocation(o, "aPosition"), o.aIndex = a.getAttribLocation(o, "aIndex"), o.aVertType = a.getAttribLocation(o, "aVertType"), o.aTransform = a.getAttribLocation(o, "aTransform"), o.aAtlasId = a.getAttribLocation(o, "aAtlasId"), o.aTex = a.getAttribLocation(o, "aTex"), o.aPointAPointB = a.getAttribLocation(o, "aPointAPointB"), o.aPointCPointD = a.getAttribLocation(o, "aPointCPointD"), o.aLineWidth = a.getAttribLocation(o, "aLineWidth"), o.aColor = a.getAttribLocation(o, "aColor"), o.aCornerRadius = a.getAttribLocation(o, "aCornerRadius"), o.aBorderColor = a.getAttribLocation(o, "aBorderColor"), o.uPanZoomMatrix = a.getUniformLocation(o, "uPanZoomMatrix"), o.uAtlasSize = a.getUniformLocation(o, "uAtlasSize"), o.uBGColor = a.getUniformLocation(o, "uBGColor"), o.uZoom = a.getUniformLocation(o, "uZoom"), o.uTextures = [];
      for (var u = 0; u < this.batchManager.getMaxAtlasesPerBatch(); u++)
        o.uTextures.push(a.getUniformLocation(o, "uTexture".concat(u)));
      return o;
    }
  }, {
    key: "_createVAO",
    value: function() {
      var t = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1];
      this.vertexCount = t.length / 2;
      var a = this.maxInstances, n = this.gl, i = this.program, s = n.createVertexArray();
      return n.bindVertexArray(s), fm(n, "vec2", i.aPosition, t), this.transformBuffer = cm(n, a, i.aTransform), this.indexBuffer = zt(n, a, "vec4", i.aIndex), this.vertTypeBuffer = zt(n, a, "int", i.aVertType), this.atlasIdBuffer = zt(n, a, "int", i.aAtlasId), this.texBuffer = zt(n, a, "vec4", i.aTex), this.pointAPointBBuffer = zt(n, a, "vec4", i.aPointAPointB), this.pointCPointDBuffer = zt(n, a, "vec4", i.aPointCPointD), this.lineWidthBuffer = zt(n, a, "vec2", i.aLineWidth), this.colorBuffer = zt(n, a, "vec4", i.aColor), this.cornerRadiusBuffer = zt(n, a, "vec4", i.aCornerRadius), this.borderColorBuffer = zt(n, a, "vec4", i.aBorderColor), n.bindVertexArray(null), s;
    }
  }, {
    key: "buffers",
    get: function() {
      var t = this;
      return this._buffers || (this._buffers = Object.keys(this).filter(function(a) {
        return a.endsWith("Buffer");
      }).map(function(a) {
        return t[a];
      })), this._buffers;
    }
  }, {
    key: "startFrame",
    value: function(t) {
      var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : xa.SCREEN;
      this.panZoomMatrix = t, 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(t, a) {
      return t.visible() ? a && a.isVisible ? a.isVisible(t) : !0 : !1;
    }
    /**
     * Draws a texture using the texture atlas.
     */
  }, {
    key: "drawTexture",
    value: function(t, a, n) {
      var i = this.atlasManager, s = this.batchManager, o = i.getRenderTypeOpts(n);
      if (this._isVisible(t, o)) {
        if (this.renderTarget.picking && o.getTexPickingMode) {
          var u = o.getTexPickingMode(t);
          if (u === Pn.IGNORE)
            return;
          if (u == Pn.USE_BB) {
            this.drawPickingRectangle(t, a, n);
            return;
          }
        }
        var l = i.getAtlasInfo(t, n), f = Dt(l), c;
        try {
          for (f.s(); !(c = f.n()).done; ) {
            var v = c.value, h = v.atlas, d = v.tex1, p = v.tex2;
            s.canAddToCurrentBatch(h) || this.endBatch();
            for (var g = s.getAtlasIndexForBatch(h), y = 0, b = [[d, !0], [p, !1]]; y < b.length; y++) {
              var m = je(b[y], 2), E = m[0], x = m[1];
              if (E.w != 0) {
                var S = this.instanceCount;
                this.vertTypeBuffer.getView(S)[0] = Ds;
                var w = this.indexBuffer.getView(S);
                Vr(a, w);
                var T = this.atlasIdBuffer.getView(S);
                T[0] = g;
                var C = this.texBuffer.getView(S);
                C[0] = E.x, C[1] = E.y, C[2] = E.w, C[3] = E.h;
                var D = this.transformBuffer.getMatrixView(S);
                this.setTransformMatrix(t, D, o, v, x), this.instanceCount++, x || 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(t, a, n, i) {
      var s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, o = 0;
      if (n.shapeProps && n.shapeProps.padding && (o = t.pstyle(n.shapeProps.padding).pfValue), i) {
        var u = i.bb, l = i.tex1, f = i.tex2, c = l.w / (l.w + f.w);
        s || (c = 1 - c);
        var v = this._getAdjustedBB(u, o, s, c);
        this._applyTransformMatrix(a, v, n, t);
      } else {
        var h = n.getBoundingBox(t), d = this._getAdjustedBB(h, o, !0, 1);
        this._applyTransformMatrix(a, d, n, t);
      }
    }
  }, {
    key: "_applyTransformMatrix",
    value: function(t, a, n, i) {
      var s, o;
      Zl(t);
      var u = n.getRotation ? n.getRotation(i) : 0;
      if (u !== 0) {
        var l = n.getRotationPoint(i), f = l.x, c = l.y;
        mn(t, t, [f, c]), Ql(t, t, u);
        var v = n.getRotationOffset(i);
        s = v.x + (a.xOffset || 0), o = v.y + (a.yOffset || 0);
      } else
        s = a.x1, o = a.y1;
      mn(t, t, [s, o]), Ws(t, t, [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(t, a, n, i) {
      var s = t.x1, o = t.y1, u = t.w, l = t.h, f = t.yOffset;
      a && (s -= a, o -= a, u += 2 * a, l += 2 * a);
      var c = 0, v = u * i;
      return n && i < 1 ? u = v : !n && i < 1 && (c = u - v, s += c, u = v), {
        x1: s,
        y1: o,
        w: u,
        h: l,
        xOffset: c,
        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(t, a, n) {
      var i = this.atlasManager.getRenderTypeOpts(n), s = this.instanceCount;
      this.vertTypeBuffer.getView(s)[0] = Ur;
      var o = this.indexBuffer.getView(s);
      Vr(a, o);
      var u = this.colorBuffer.getView(s);
      wr([0, 0, 0], 1, u);
      var l = this.transformBuffer.getMatrixView(s);
      this.setTransformMatrix(t, 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(t, a, n) {
      var i = this.simpleShapeOptions.get(n);
      if (this._isVisible(t, i)) {
        var s = i.shapeProps, o = this._getVertTypeForShape(t, s.shape);
        if (o === void 0 || i.isSimple && !i.isSimple(t)) {
          this.drawTexture(t, a, n);
          return;
        }
        var u = this.instanceCount;
        if (this.vertTypeBuffer.getView(u)[0] = o, o === on || o === ga) {
          var l = i.getBoundingBox(t), f = this._getCornerRadius(t, s.radius, l), c = this.cornerRadiusBuffer.getView(u);
          c[0] = f, c[1] = f, c[2] = f, c[3] = f, o === ga && (c[0] = 0, c[2] = 0);
        }
        var v = this.indexBuffer.getView(u);
        Vr(a, v);
        var h = t.pstyle(s.color).value, d = t.pstyle(s.opacity).value, p = this.colorBuffer.getView(u);
        wr(h, d, p);
        var g = this.lineWidthBuffer.getView(u);
        if (g[0] = 0, g[1] = 0, s.border) {
          var y = t.pstyle("border-width").value;
          if (y > 0) {
            var b = t.pstyle("border-color").value, m = t.pstyle("border-opacity").value, E = this.borderColorBuffer.getView(u);
            wr(b, m, E);
            var x = t.pstyle("border-position").value;
            if (x === "inside")
              g[0] = 0, g[1] = -y;
            else if (x === "outside")
              g[0] = y, g[1] = 0;
            else {
              var S = y / 2;
              g[0] = S, g[1] = -S;
            }
          }
        }
        var w = this.transformBuffer.getMatrixView(u);
        this.setTransformMatrix(t, w, i), this.simpleCount++, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
      }
    }
  }, {
    key: "_getVertTypeForShape",
    value: function(t, a) {
      var n = t.pstyle(a).value;
      switch (n) {
        case "rectangle":
          return Ur;
        case "ellipse":
          return pa;
        case "roundrectangle":
        case "round-rectangle":
          return on;
        case "bottom-round-rectangle":
          return ga;
        default:
          return;
      }
    }
  }, {
    key: "_getCornerRadius",
    value: function(t, a, n) {
      var i = n.w, s = n.h;
      if (t.pstyle(a).value === "auto")
        return ur(i, s);
      var o = t.pstyle(a).pfValue, u = i / 2, l = s / 2;
      return Math.min(o, l, u);
    }
    /**
     * Only supports drawing triangles at the moment.
     */
  }, {
    key: "drawEdgeArrow",
    value: function(t, a, n) {
      if (t.visible()) {
        var i = t._private.rscratch, s, o, u;
        if (n === "source" ? (s = i.arrowStartX, o = i.arrowStartY, u = i.srcArrowAngle) : (s = i.arrowEndX, o = i.arrowEndY, u = i.tgtArrowAngle), !(isNaN(s) || s == null || isNaN(o) || o == null || isNaN(u) || u == null)) {
          var l = t.pstyle(n + "-arrow-shape").value;
          if (l !== "none") {
            var f = t.pstyle(n + "-arrow-color").value, c = t.pstyle("opacity").value, v = t.pstyle("line-opacity").value, h = c * v, d = t.pstyle("width").pfValue, p = t.pstyle("arrow-scale").value, g = this.r.getArrowWidth(d, p), y = this.instanceCount, b = this.transformBuffer.getMatrixView(y);
            Zl(b), mn(b, b, [s, o]), Ws(b, b, [g, g]), Ql(b, b, u), this.vertTypeBuffer.getView(y)[0] = Ss;
            var m = this.indexBuffer.getView(y);
            Vr(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(t, a) {
      if (t.visible()) {
        var n = this._getEdgePoints(t);
        if (n) {
          var i = t.pstyle("opacity").value, s = t.pstyle("line-opacity").value, o = t.pstyle("width").pfValue, u = t.pstyle("line-color").value, l = i * s;
          if (n.length / 2 + this.instanceCount > this.maxInstances && this.endBatch(), n.length == 4) {
            var f = this.instanceCount;
            this.vertTypeBuffer.getView(f)[0] = Jl;
            var c = this.indexBuffer.getView(f);
            Vr(a, c);
            var v = this.colorBuffer.getView(f);
            wr(u, l, v);
            var h = this.lineWidthBuffer.getView(f);
            h[0] = o;
            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 p = 0; p < n.length - 2; p += 2) {
              var g = this.instanceCount;
              this.vertTypeBuffer.getView(g)[0] = jl;
              var y = this.indexBuffer.getView(g);
              Vr(a, y);
              var b = this.colorBuffer.getView(g);
              wr(u, l, b);
              var m = this.lineWidthBuffer.getView(g);
              m[0] = o;
              var E = n[p - 2], x = n[p - 1], S = n[p], w = n[p + 1], T = n[p + 2], C = n[p + 3], D = n[p + 4], A = n[p + 5];
              p == 0 && (E = 2 * S - T + 1e-3, x = 2 * w - C + 1e-3), p == n.length - 4 && (D = 2 * T - S + 1e-3, A = 2 * C - w + 1e-3);
              var L = this.pointAPointBBuffer.getView(g);
              L[0] = E, L[1] = x, L[2] = S, L[3] = w;
              var R = this.pointCPointDBuffer.getView(g);
              R[0] = T, R[1] = C, R[2] = D, R[3] = A, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
            }
        }
      }
    }
  }, {
    key: "_getEdgePoints",
    value: function(t) {
      var a = t._private.rscratch;
      if (!(a.badLine || a.allpts == null || isNaN(a.allpts[0]))) {
        var n = a.allpts;
        if (n.length == 4)
          return n;
        var i = this._getNumSegments(t);
        return this._getCurveSegmentPoints(n, i);
      }
    }
  }, {
    key: "_getNumSegments",
    value: function(t) {
      var a = 15;
      return Math.min(Math.max(a, 5), this.maxInstances);
    }
  }, {
    key: "_getCurveSegmentPoints",
    value: function(t, a) {
      if (t.length == 4)
        return t;
      for (var n = Array((a + 1) * 2), i = 0; i <= a; i++)
        if (i == 0)
          n[0] = t[0], n[1] = t[1];
        else if (i == a)
          n[i * 2] = t[t.length - 2], n[i * 2 + 1] = t[t.length - 1];
        else {
          var s = i / a;
          this._setCurvePoint(t, s, n, i * 2);
        }
      return n;
    }
  }, {
    key: "_setCurvePoint",
    value: function(t, a, n, i) {
      if (t.length <= 2)
        n[i] = t[0], n[i + 1] = t[1];
      else {
        for (var s = Array(t.length - 2), o = 0; o < s.length; o += 2) {
          var u = (1 - a) * t[o] + a * t[o + 2], l = (1 - a) * t[o + 1] + a * t[o + 3];
          s[o] = u, s[o + 1] = l;
        }
        return this._setCurvePoint(s, a, n, i);
      }
    }
  }, {
    key: "endBatch",
    value: function() {
      var t = this.gl, a = this.vao, n = this.vertexCount, i = this.instanceCount;
      if (i !== 0) {
        var s = this.renderTarget.picking ? this.pickingProgram : this.program;
        t.useProgram(s), t.bindVertexArray(a);
        var o = Dt(this.buffers), u;
        try {
          for (o.s(); !(u = o.n()).done; ) {
            var l = u.value;
            l.bufferSubData(i);
          }
        } catch (d) {
          o.e(d);
        } finally {
          o.f();
        }
        for (var f = this.batchManager.getAtlases(), c = 0; c < f.length; c++)
          f[c].bufferIfNeeded(t);
        for (var v = 0; v < f.length; v++)
          t.activeTexture(t.TEXTURE0 + v), t.bindTexture(t.TEXTURE_2D, f[v].texture), t.uniform1i(s.uTextures[v], v);
        t.uniform1f(s.uZoom, am(this.r)), t.uniformMatrix3fv(s.uPanZoomMatrix, !1, this.panZoomMatrix), t.uniform1i(s.uAtlasSize, this.batchManager.getAtlasSize());
        var h = wr(this.bgColor, 1);
        t.uniform4fv(s.uBGColor, h), t.drawArraysInstanced(t.TRIANGLES, 0, n, i), t.bindVertexArray(null), t.bindTexture(t.TEXTURE_2D, null), this.debug && this.batchDebugInfo.push({
          count: i,
          // instance count
          atlasCount: f.length
        }), this.startBatch();
      }
    }
  }, {
    key: "getDebugInfo",
    value: function() {
      var t = this.atlasManager.getDebugInfo(), a = t.reduce(function(s, o) {
        return s + o.atlasCount;
      }, 0), n = this.batchDebugInfo, i = n.reduce(function(s, o) {
        return s + o.count;
      }, 0);
      return {
        atlasInfo: t,
        totalAtlases: a,
        wrappedCount: this.wrappedCount,
        simpleCount: this.simpleCount,
        batchCount: n.length,
        batchInfo: n,
        totalInstances: i
      };
    }
  }]);
}(), Fc = {};
Fc.initWebgl = function(r, e) {
  var t = this, a = t.data.contexts[t.WEBGL];
  r.bgColor = Dm(t), r.webglTexSize = Math.min(r.webglTexSize, a.getParameter(a.MAX_TEXTURE_SIZE)), r.webglTexRows = Math.min(r.webglTexRows, 54), r.webglTexRowsNodes = Math.min(r.webglTexRowsNodes, 54), r.webglBatchSize = Math.min(r.webglBatchSize, 16384), r.webglTexPerBatch = Math.min(r.webglTexPerBatch, a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)), t.webglDebug = r.webglDebug, t.webglDebugShowAtlases = r.webglDebugShowAtlases, t.pickingFrameBuffer = vm(a), t.pickingFrameBuffer.needsDraw = !0, t.drawing = new Cm(t, a, r);
  var n = function(c) {
    return function(v) {
      return t.getTextAngle(v, c);
    };
  }, i = function(c) {
    return function(v) {
      var h = v.pstyle(c);
      return h && h.value;
    };
  }, s = function(c) {
    return function(v) {
      return v.pstyle("".concat(c, "-opacity")).value > 0;
    };
  }, o = function(c) {
    var v = c.pstyle("text-events").strValue === "yes";
    return v ? Pn.USE_BB : Pn.IGNORE;
  }, u = function(c) {
    var v = c.position(), h = v.x, d = v.y, p = c.outerWidth(), g = c.outerHeight();
    return {
      w: p,
      h: g,
      x1: h - p / 2,
      y1: d - g / 2
    };
  };
  t.drawing.addAtlasCollection("node", {
    texRows: r.webglTexRowsNodes
  }), t.drawing.addAtlasCollection("label", {
    texRows: r.webglTexRows
  }), t.drawing.addTextureAtlasRenderType("node-body", {
    collection: "node",
    getKey: e.getStyleKey,
    getBoundingBox: e.getElementBox,
    drawElement: e.drawElement
  }), t.drawing.addSimpleShapeRenderType("node-body", {
    getBoundingBox: u,
    isSimple: im,
    shapeProps: {
      shape: "shape",
      color: "background-color",
      opacity: "background-opacity",
      radius: "corner-radius",
      border: !0
    }
  }), t.drawing.addSimpleShapeRenderType("node-overlay", {
    getBoundingBox: u,
    isVisible: s("overlay"),
    shapeProps: {
      shape: "overlay-shape",
      color: "overlay-color",
      opacity: "overlay-opacity",
      padding: "overlay-padding",
      radius: "overlay-corner-radius"
    }
  }), t.drawing.addSimpleShapeRenderType("node-underlay", {
    getBoundingBox: u,
    isVisible: s("underlay"),
    shapeProps: {
      shape: "underlay-shape",
      color: "underlay-color",
      opacity: "underlay-opacity",
      padding: "underlay-padding",
      radius: "underlay-corner-radius"
    }
  }), t.drawing.addTextureAtlasRenderType("label", {
    // node label or edge mid label
    collection: "label",
    getTexPickingMode: o,
    getKey: As(e.getLabelKey, null),
    getBoundingBox: Ls(e.getLabelBox, null),
    drawClipped: !0,
    drawElement: e.drawLabel,
    getRotation: n(null),
    getRotationPoint: e.getLabelRotationPoint,
    getRotationOffset: e.getLabelRotationOffset,
    isVisible: i("label")
  }), t.drawing.addTextureAtlasRenderType("edge-source-label", {
    collection: "label",
    getTexPickingMode: o,
    getKey: As(e.getSourceLabelKey, "source"),
    getBoundingBox: Ls(e.getSourceLabelBox, "source"),
    drawClipped: !0,
    drawElement: e.drawSourceLabel,
    getRotation: n("source"),
    getRotationPoint: e.getSourceLabelRotationPoint,
    getRotationOffset: e.getSourceLabelRotationOffset,
    isVisible: i("source-label")
  }), t.drawing.addTextureAtlasRenderType("edge-target-label", {
    collection: "label",
    getTexPickingMode: o,
    getKey: As(e.getTargetLabelKey, "target"),
    getBoundingBox: Ls(e.getTargetLabelBox, "target"),
    drawClipped: !0,
    drawElement: e.drawTargetLabel,
    getRotation: n("target"),
    getRotationPoint: e.getTargetLabelRotationPoint,
    getRotationOffset: e.getTargetLabelRotationOffset,
    isVisible: i("target-label")
  });
  var l = _a(function() {
    console.log("garbage collect flag set"), t.data.gc = !0;
  }, 1e4);
  t.onUpdateEleCalcs(function(f, c) {
    var v = !1;
    c && c.length > 0 && (v |= t.drawing.invalidate(c)), v && l();
  }), Sm(t);
};
function Dm(r) {
  var e = r.cy.container(), t = e && e.style && e.style.backgroundColor || "white";
  return hf(t);
}
function _c(r, e) {
  var t = r._private.rscratch;
  return Tt(t, "labelWrapCachedLines", e) || [];
}
var As = function(e, t) {
  return function(a) {
    var n = e(a), i = _c(a, t);
    return i.length > 1 ? i.map(function(s, o) {
      return "".concat(n, "_").concat(o);
    }) : n;
  };
}, Ls = function(e, t) {
  return function(a, n) {
    var i = e(a);
    if (typeof n == "string") {
      var s = n.indexOf("_");
      if (s > 0) {
        var o = Number(n.substring(s + 1)), u = _c(a, t), l = i.h / u.length, f = l * o, c = i.y1 + f;
        return {
          x1: i.x1,
          w: i.w,
          y1: c,
          h: l,
          yOffset: f
        };
      }
    }
    return i;
  };
};
function Sm(r) {
  {
    var e = r.render;
    r.render = function(i) {
      i = i || {};
      var s = r.cy;
      r.webgl && (s.zoom() > Ic ? (Am(r), e.call(r, i)) : (Lm(r), zc(r, i, xa.SCREEN)));
    };
  }
  {
    var t = r.matchCanvasSize;
    r.matchCanvasSize = function(i) {
      t.call(r, i), r.pickingFrameBuffer.setFramebufferAttachmentSizes(r.canvasWidth, r.canvasHeight), r.pickingFrameBuffer.needsDraw = !0;
    };
  }
  r.findNearestElements = function(i, s, o, u) {
    return Nm(r, i, s);
  };
  {
    var a = r.invalidateCachedZSortedEles;
    r.invalidateCachedZSortedEles = function() {
      a.call(r), r.pickingFrameBuffer.needsDraw = !0;
    };
  }
  {
    var n = r.notify;
    r.notify = function(i, s) {
      n.call(r, i, s), i === "viewport" || i === "bounds" ? r.pickingFrameBuffer.needsDraw = !0 : i === "background" && r.drawing.invalidate(s, {
        type: "node-body"
      });
    };
  }
}
function Am(r) {
  var e = r.data.contexts[r.WEBGL];
  e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT);
}
function Lm(r) {
  var e = function(a) {
    a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, r.canvasWidth, r.canvasHeight), a.restore();
  };
  e(r.data.contexts[r.NODE]), e(r.data.contexts[r.DRAG]);
}
function Rm(r) {
  var e = r.canvasWidth, t = r.canvasHeight, a = So(r), n = a.pan, i = a.zoom, s = Cs();
  mn(s, s, [n.x, n.y]), Ws(s, s, [i, i]);
  var o = Cs();
  dm(o, e, t);
  var u = Cs();
  return hm(u, o, s), u;
}
function Gc(r, e) {
  var t = r.canvasWidth, a = r.canvasHeight, n = So(r), i = n.pan, s = n.zoom;
  e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, t, a), e.translate(i.x, i.y), e.scale(s, s);
}
function Im(r, e) {
  r.drawSelectionRectangle(e, function(t) {
    return Gc(r, t);
  });
}
function Mm(r) {
  var e = r.data.contexts[r.NODE];
  e.save(), Gc(r, 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 Om(r) {
  var e = function(n, i, s) {
    for (var o = n.atlasManager.getAtlasCollection(i), u = r.data.contexts[r.NODE], l = o.atlases, f = 0; f < l.length; f++) {
      var c = l[f], v = c.canvas;
      if (v) {
        var h = v.width, d = v.height, p = h * f, g = v.height * s, y = 0.4;
        u.save(), u.scale(y, y), u.drawImage(v, p, g), u.strokeStyle = "black", u.rect(p, g, h, d), u.stroke(), u.restore();
      }
    }
  }, t = 0;
  e(r.drawing, "node", t++), e(r.drawing, "label", t++);
}
function Pm(r, e, t, a, n) {
  var i, s, o, u, l = So(r), f = l.pan, c = l.zoom;
  {
    var v = nm(r, f, c, e, t), h = je(v, 2), d = h[0], p = h[1], g = 6;
    i = d - g / 2, s = p - g / 2, o = g, u = g;
  }
  if (o === 0 || u === 0)
    return [];
  var y = r.data.contexts[r.WEBGL];
  y.bindFramebuffer(y.FRAMEBUFFER, r.pickingFrameBuffer), r.pickingFrameBuffer.needsDraw && (y.viewport(0, 0, y.canvas.width, y.canvas.height), zc(r, null, xa.PICKING), r.pickingFrameBuffer.needsDraw = !1);
  var b = o * u, m = new Uint8Array(b * 4);
  y.readPixels(i, s, o, u, y.RGBA, y.UNSIGNED_BYTE, m), y.bindFramebuffer(y.FRAMEBUFFER, null);
  for (var E = /* @__PURE__ */ new Set(), x = 0; x < b; x++) {
    var S = m.slice(x * 4, x * 4 + 4), w = om(S) - 1;
    w >= 0 && E.add(w);
  }
  return E;
}
function Nm(r, e, t) {
  var a = Pm(r, e, t), n = r.getCachedZSortedEles(), i, s, o = Dt(a), u;
  try {
    for (o.s(); !(u = o.n()).done; ) {
      var l = u.value, f = n[l];
      if (!i && f.isNode() && (i = f), !s && f.isEdge() && (s = f), i && s)
        break;
    }
  } catch (c) {
    o.e(c);
  } finally {
    o.f();
  }
  return [i, s].filter(Boolean);
}
function Rs(r, e, t) {
  var a = r.drawing;
  e += 1, t.isNode() ? (a.drawNode(t, e, "node-underlay"), a.drawNode(t, e, "node-body"), a.drawTexture(t, e, "label"), a.drawNode(t, e, "node-overlay")) : (a.drawEdgeLine(t, e), a.drawEdgeArrow(t, e, "source"), a.drawEdgeArrow(t, e, "target"), a.drawTexture(t, e, "label"), a.drawTexture(t, e, "edge-source-label"), a.drawTexture(t, e, "edge-target-label"));
}
function zc(r, e, t) {
  var a;
  r.webglDebug && (a = performance.now());
  var n = r.drawing, i = 0;
  if (t.screen && r.data.canvasNeedsRedraw[r.SELECT_BOX] && Im(r, e), r.data.canvasNeedsRedraw[r.NODE] || t.picking) {
    var s = r.data.contexts[r.WEBGL];
    t.screen ? (s.clearColor(0, 0, 0, 0), s.enable(s.BLEND), s.blendFunc(s.ONE, s.ONE_MINUS_SRC_ALPHA)) : s.disable(s.BLEND), s.clear(s.COLOR_BUFFER_BIT | s.DEPTH_BUFFER_BIT), s.viewport(0, 0, s.canvas.width, s.canvas.height);
    var o = Rm(r), u = r.getCachedZSortedEles();
    if (i = u.length, n.startFrame(o, t), t.screen) {
      for (var l = 0; l < u.nondrag.length; l++)
        Rs(r, l, u.nondrag[l]);
      for (var f = 0; f < u.drag.length; f++)
        Rs(r, f, u.drag[f]);
    } else if (t.picking)
      for (var c = 0; c < u.length; c++)
        Rs(r, c, u[c]);
    n.endFrame(), t.screen && r.webglDebugShowAtlases && (Mm(r), Om(r)), r.data.canvasNeedsRedraw[r.NODE] = !1, r.data.canvasNeedsRedraw[r.DRAG] = !1;
  }
  if (r.webglDebug) {
    var v = performance.now(), h = !1, d = Math.ceil(v - a), p = n.getDebugInfo(), g = ["".concat(i, " elements"), "".concat(p.totalInstances, " instances"), "".concat(p.batchCount, " batches"), "".concat(p.totalAtlases, " atlases"), "".concat(p.wrappedCount, " wrapped textures"), "".concat(p.simpleCount, " simple shapes")].join(", ");
    if (h)
      console.log("WebGL (".concat(t.name, ") - time ").concat(d, "ms, ").concat(g));
    else {
      console.log("WebGL (".concat(t.name, ") - frame time ").concat(d, "ms")), console.log("Totals:"), console.log("  ".concat(g)), console.log("Texture Atlases Used:");
      var y = p.atlasInfo, b = Dt(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 (x) {
        b.e(x);
      } finally {
        b.f();
      }
      console.log("");
    }
  }
  r.data.gc && (console.log("Garbage Collect!"), r.data.gc = !1, n.gc());
}
var yr = {};
yr.drawPolygonPath = function(r, e, t, a, n, i) {
  var s = a / 2, o = n / 2;
  r.beginPath && r.beginPath(), r.moveTo(e + s * i[0], t + o * i[1]);
  for (var u = 1; u < i.length / 2; u++)
    r.lineTo(e + s * i[u * 2], t + o * i[u * 2 + 1]);
  r.closePath();
};
yr.drawRoundPolygonPath = function(r, e, t, a, n, i, s) {
  s.forEach(function(o) {
    return Ec(r, o);
  }), r.closePath();
};
yr.drawRoundRectanglePath = function(r, e, t, a, n, i) {
  var s = a / 2, o = n / 2, u = i === "auto" ? ur(a, n) : Math.min(i, o, s);
  r.beginPath && r.beginPath(), r.moveTo(e, t - o), r.arcTo(e + s, t - o, e + s, t, u), r.arcTo(e + s, t + o, e, t + o, u), r.arcTo(e - s, t + o, e - s, t, u), r.arcTo(e - s, t - o, e, t - o, u), r.lineTo(e, t - o), r.closePath();
};
yr.drawBottomRoundRectanglePath = function(r, e, t, a, n, i) {
  var s = a / 2, o = n / 2, u = i === "auto" ? ur(a, n) : i;
  r.beginPath && r.beginPath(), r.moveTo(e, t - o), r.lineTo(e + s, t - o), r.lineTo(e + s, t), r.arcTo(e + s, t + o, e, t + o, u), r.arcTo(e - s, t + o, e - s, t, u), r.lineTo(e - s, t - o), r.lineTo(e, t - o), r.closePath();
};
yr.drawCutRectanglePath = function(r, e, t, a, n, i, s) {
  var o = a / 2, u = n / 2, l = s === "auto" ? co() : s;
  r.beginPath && r.beginPath(), r.moveTo(e - o + l, t - u), r.lineTo(e + o - l, t - u), r.lineTo(e + o, t - u + l), r.lineTo(e + o, t + u - l), r.lineTo(e + o - l, t + u), r.lineTo(e - o + l, t + u), r.lineTo(e - o, t + u - l), r.lineTo(e - o, t - u + l), r.closePath();
};
yr.drawBarrelPath = function(r, e, t, a, n) {
  var i = a / 2, s = n / 2, o = e - i, u = e + i, l = t - s, f = t + s, c = Ns(a, n), v = c.widthOffset, h = c.heightOffset, d = c.ctrlPtOffsetPct * v;
  r.beginPath && r.beginPath(), r.moveTo(o, l + h), r.lineTo(o, f - h), r.quadraticCurveTo(o + d, f, o + v, f), r.lineTo(u - v, f), r.quadraticCurveTo(u - d, f, u, f - h), r.lineTo(u, l + h), r.quadraticCurveTo(u - d, l, u - v, l), r.lineTo(o + v, l), r.quadraticCurveTo(o + d, l, o, l + h), r.closePath();
};
var ef = Math.sin(0), tf = Math.cos(0), Ks = {}, Zs = {}, Vc = Math.PI / 40;
for (var qr = 0 * Math.PI; qr < 2 * Math.PI; qr += Vc)
  Ks[qr] = Math.sin(qr), Zs[qr] = Math.cos(qr);
yr.drawEllipsePath = function(r, e, t, a, n) {
  if (r.beginPath && r.beginPath(), r.ellipse)
    r.ellipse(e, t, a / 2, n / 2, 0, 0, 2 * Math.PI);
  else
    for (var i, s, o = a / 2, u = n / 2, l = 0 * Math.PI; l < 2 * Math.PI; l += Vc)
      i = e - o * Ks[l] * ef + o * Zs[l] * tf, s = t + u * Zs[l] * ef + u * Ks[l] * tf, l === 0 ? r.moveTo(i, s) : r.lineTo(i, s);
  r.closePath();
};
var Ha = {};
Ha.createBuffer = function(r, e) {
  var t = document.createElement("canvas");
  return t.width = r, t.height = e, [t, t.getContext("2d")];
};
Ha.bufferCanvasImage = function(r) {
  var e = this.cy, t = e.mutableElements(), a = t.boundingBox(), n = this.findContainerClientCoords(), i = r.full ? Math.ceil(a.w) : n[2], s = r.full ? Math.ceil(a.h) : n[3], o = ae(r.maxWidth) || ae(r.maxHeight), u = this.getPixelRatio(), l = 1;
  if (r.scale !== void 0)
    i *= r.scale, s *= r.scale, l = r.scale;
  else if (o) {
    var f = 1 / 0, c = 1 / 0;
    ae(r.maxWidth) && (f = l * r.maxWidth / i), ae(r.maxHeight) && (c = l * r.maxHeight / s), l = Math.min(f, c), i *= l, s *= l;
  }
  o || (i *= u, s *= u, l *= u);
  var v = document.createElement("canvas");
  v.width = i, v.height = s, v.style.width = i + "px", v.style.height = s + "px";
  var h = v.getContext("2d");
  if (i > 0 && s > 0) {
    h.clearRect(0, 0, i, s), h.globalCompositeOperation = "source-over";
    var d = this.getCachedZSortedEles();
    if (r.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 p = e.pan(), g = {
        x: p.x * l,
        y: p.y * l
      };
      l *= e.zoom(), h.translate(g.x, g.y), h.scale(l, l), this.drawElements(h, d), h.scale(1 / l, 1 / l), h.translate(-g.x, -g.y);
    }
    r.bg && (h.globalCompositeOperation = "destination-over", h.fillStyle = r.bg, h.rect(0, 0, i, s), h.fill());
  }
  return v;
};
function km(r, e) {
  for (var t = atob(r), a = new ArrayBuffer(t.length), n = new Uint8Array(a), i = 0; i < t.length; i++)
    n[i] = t.charCodeAt(i);
  return new Blob([a], {
    type: e
  });
}
function rf(r) {
  var e = r.indexOf(",");
  return r.substr(e + 1);
}
function Uc(r, e, t) {
  var a = function() {
    return e.toDataURL(t, r.quality);
  };
  switch (r.output) {
    case "blob-promise":
      return new aa(function(n, i) {
        try {
          e.toBlob(function(s) {
            s != null ? n(s) : i(new Error("`canvas.toBlob()` sent a null value in its callback"));
          }, t, r.quality);
        } catch (s) {
          i(s);
        }
      });
    case "blob":
      return km(rf(a()), t);
    case "base64":
      return rf(a());
    case "base64uri":
    default:
      return a();
  }
}
Ha.png = function(r) {
  return Uc(r, this.bufferCanvasImage(r), "image/png");
};
Ha.jpg = function(r) {
  return Uc(r, this.bufferCanvasImage(r), "image/jpeg");
};
var qc = {};
qc.nodeShapeImpl = function(r, e, t, a, n, i, s, o) {
  switch (r) {
    case "ellipse":
      return this.drawEllipsePath(e, t, a, n, i);
    case "polygon":
      return this.drawPolygonPath(e, t, a, n, i, s);
    case "round-polygon":
      return this.drawRoundPolygonPath(e, t, a, n, i, s, o);
    case "roundrectangle":
    case "round-rectangle":
      return this.drawRoundRectanglePath(e, t, a, n, i, o);
    case "cutrectangle":
    case "cut-rectangle":
      return this.drawCutRectanglePath(e, t, a, n, i, s, o);
    case "bottomroundrectangle":
    case "bottom-round-rectangle":
      return this.drawBottomRoundRectanglePath(e, t, a, n, i, o);
    case "barrel":
      return this.drawBarrelPath(e, t, a, n, i);
  }
};
var Bm = Hc, Ce = Hc.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 Hc(r) {
  var e = this, t = e.cy.window(), a = t.document;
  r.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 s = e.data.canvasContainer.style;
  e.data.canvasContainer.style[n] = i, s.position = "relative", s.zIndex = "0", s.overflow = "hidden";
  var o = r.cy.container();
  o.appendChild(e.data.canvasContainer), o.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"
  };
  Nv() && (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"), c = Ce.CANVAS_TYPES[l];
    e.data.contexts[l] = f.getContext(c), e.data.contexts[l] || qe("Could not create canvas of type " + c), Object.keys(u).forEach(function(J) {
      f.style[J] = u[J];
    }), 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 v = St(), h = function(z) {
    return {
      x: (z.x1 + z.x2) / 2,
      y: (z.y1 + z.y2) / 2
    };
  }, d = function(z) {
    return {
      x: -z.w / 2,
      y: -z.h / 2
    };
  }, p = function(z) {
    var V = z[0]._private, Y = V.oldBackgroundTimestamp === V.backgroundTimestamp;
    return !Y;
  }, g = function(z) {
    return z[0]._private.nodeKey;
  }, y = function(z) {
    return z[0]._private.labelStyleKey;
  }, b = function(z) {
    return z[0]._private.sourceLabelStyleKey;
  }, m = function(z) {
    return z[0]._private.targetLabelStyleKey;
  }, E = function(z, V, Y, ee, ne) {
    return e.drawElement(z, V, Y, !1, !1, ne);
  }, x = function(z, V, Y, ee, ne) {
    return e.drawElementText(z, V, Y, ee, "main", ne);
  }, S = function(z, V, Y, ee, ne) {
    return e.drawElementText(z, V, Y, ee, "source", ne);
  }, w = function(z, V, Y, ee, ne) {
    return e.drawElementText(z, V, Y, ee, "target", ne);
  }, T = function(z) {
    return z.boundingBox(), z[0]._private.bodyBounds;
  }, C = function(z) {
    return z.boundingBox(), z[0]._private.labelBounds.main || v;
  }, D = function(z) {
    return z.boundingBox(), z[0]._private.labelBounds.source || v;
  }, A = function(z) {
    return z.boundingBox(), z[0]._private.labelBounds.target || v;
  }, L = function(z, V) {
    return V;
  }, R = function(z) {
    return h(T(z));
  }, I = function(z, V, Y) {
    var ee = z ? z + "-" : "";
    return {
      x: V.x + Y.pstyle(ee + "text-margin-x").pfValue,
      y: V.y + Y.pstyle(ee + "text-margin-y").pfValue
    };
  }, O = function(z, V, Y) {
    var ee = z[0]._private.rscratch;
    return {
      x: ee[V],
      y: ee[Y]
    };
  }, N = function(z) {
    return I("", O(z, "labelX", "labelY"), z);
  }, k = function(z) {
    return I("source", O(z, "sourceLabelX", "sourceLabelY"), z);
  }, P = function(z) {
    return I("target", O(z, "targetLabelX", "targetLabelY"), z);
  }, B = function(z) {
    return d(T(z));
  }, _ = function(z) {
    return d(D(z));
  }, F = function(z) {
    return d(A(z));
  }, G = function(z) {
    var V = C(z), Y = d(C(z));
    if (z.isNode()) {
      switch (z.pstyle("text-halign").value) {
        case "left":
          Y.x = -V.w - (V.leftPad || 0);
          break;
        case "right":
          Y.x = -(V.rightPad || 0);
          break;
      }
      switch (z.pstyle("text-valign").value) {
        case "top":
          Y.y = -V.h - (V.topPad || 0);
          break;
        case "bottom":
          Y.y = -(V.botPad || 0);
          break;
      }
    }
    return Y;
  }, U = e.data.eleTxrCache = new ba(e, {
    getKey: g,
    doesEleInvalidateKey: p,
    drawElement: E,
    getBoundingBox: T,
    getRotationPoint: R,
    getRotationOffset: B,
    allowEdgeTxrCaching: !1,
    allowParentTxrCaching: !1
  }), H = e.data.lblTxrCache = new ba(e, {
    getKey: y,
    drawElement: x,
    getBoundingBox: C,
    getRotationPoint: N,
    getRotationOffset: G,
    isVisible: L
  }), $ = e.data.slbTxrCache = new ba(e, {
    getKey: b,
    drawElement: S,
    getBoundingBox: D,
    getRotationPoint: k,
    getRotationOffset: _,
    isVisible: L
  }), X = e.data.tlbTxrCache = new ba(e, {
    getKey: m,
    drawElement: w,
    getBoundingBox: A,
    getRotationPoint: P,
    getRotationOffset: F,
    isVisible: L
  }), Q = e.data.lyrTxrCache = new Mc(e);
  e.onUpdateEleCalcs(function(z, V) {
    U.invalidateElements(V), H.invalidateElements(V), $.invalidateElements(V), X.invalidateElements(V), Q.invalidateElements(V);
    for (var Y = 0; Y < V.length; Y++) {
      var ee = V[Y]._private;
      ee.oldBackgroundTimestamp = ee.backgroundTimestamp;
    }
  });
  var re = function(z) {
    for (var V = 0; V < z.length; V++)
      Q.enqueueElementRefinement(z[V].ele);
  };
  U.onDequeue(re), H.onDequeue(re), $.onDequeue(re), X.onDequeue(re), r.webgl && e.initWebgl(r, {
    getStyleKey: g,
    getLabelKey: y,
    getSourceLabelKey: b,
    getTargetLabelKey: m,
    drawElement: E,
    drawLabel: x,
    drawSourceLabel: S,
    drawTargetLabel: w,
    getElementBox: T,
    getLabelBox: C,
    getSourceLabelBox: D,
    getTargetLabelBox: A,
    getElementRotationPoint: R,
    getElementRotationOffset: B,
    getLabelRotationPoint: N,
    getSourceLabelRotationPoint: k,
    getTargetLabelRotationPoint: P,
    getLabelRotationOffset: G,
    getSourceLabelRotationOffset: _,
    getTargetLabelRotationOffset: F
  });
}
Ce.redrawHint = function(r, e) {
  var t = this;
  switch (r) {
    case "eles":
      t.data.canvasNeedsRedraw[Ce.NODE] = e;
      break;
    case "drag":
      t.data.canvasNeedsRedraw[Ce.DRAG] = e;
      break;
    case "select":
      t.data.canvasNeedsRedraw[Ce.SELECT_BOX] = e;
      break;
    case "gc":
      t.data.gc = !0;
      break;
  }
};
var Fm = typeof Path2D < "u";
Ce.path2dEnabled = function(r) {
  if (r === void 0)
    return this.pathsEnabled;
  this.pathsEnabled = !!r;
};
Ce.usePaths = function() {
  return Fm && this.pathsEnabled;
};
Ce.setImgSmoothing = function(r, e) {
  r.imageSmoothingEnabled != null ? r.imageSmoothingEnabled = e : (r.webkitImageSmoothingEnabled = e, r.mozImageSmoothingEnabled = e, r.msImageSmoothingEnabled = e);
};
Ce.getImgSmoothing = function(r) {
  return r.imageSmoothingEnabled != null ? r.imageSmoothingEnabled : r.webkitImageSmoothingEnabled || r.mozImageSmoothingEnabled || r.msImageSmoothingEnabled;
};
Ce.makeOffscreenCanvas = function(r, e) {
  var t;
  if ((typeof OffscreenCanvas > "u" ? "undefined" : rt(OffscreenCanvas)) !== "undefined")
    t = new OffscreenCanvas(r, e);
  else {
    var a = this.cy.window(), n = a.document;
    t = n.createElement("canvas"), t.width = r, t.height = e;
  }
  return t;
};
[Oc, Yt, jt, Do, Nr, pr, bt, Fc, yr, Ha, qc].forEach(function(r) {
  de(Ce, r);
});
var _m = [{
  name: "null",
  impl: mc
}, {
  name: "base",
  impl: Lc
}, {
  name: "canvas",
  impl: Bm
}], Gm = [{
  type: "layout",
  extensions: cy
}, {
  type: "renderer",
  extensions: _m
}], Yc = {}, Xc = {};
function $c(r, e, t) {
  var a = t, n = function(T) {
    Pe("Can not register `" + e + "` for `" + r + "` since `" + T + "` already exists in the prototype and can not be overridden");
  };
  if (r === "core") {
    if (Ma.prototype[e])
      return n(e);
    Ma.prototype[e] = t;
  } else if (r === "collection") {
    if (ct.prototype[e])
      return n(e);
    ct.prototype[e] = t;
  } else if (r === "layout") {
    for (var i = function(T) {
      this.options = T, t.call(this, T), Re(this._private) || (this._private = {}), this._private.cy = T.cy, this._private.listeners = [], this.createEmitter();
    }, s = i.prototype = Object.create(t.prototype), o = [], u = 0; u < o.length; u++) {
      var l = o[u];
      s[l] = s[l] || function() {
        return this;
      };
    }
    s.start && !s.run ? s.run = function() {
      return this.start(), this;
    } : !s.start && s.run && (s.start = function() {
      return this.run(), this;
    });
    var f = t.prototype.stop;
    s.stop = function() {
      var w = this.options;
      if (w && w.animate) {
        var T = this.animations;
        if (T)
          for (var C = 0; C < T.length; C++)
            T[C].stop();
      }
      return f ? f.call(this) : this.emit("layoutstop"), this;
    }, s.destroy || (s.destroy = function() {
      return this;
    }), s.cy = function() {
      return this._private.cy;
    };
    var c = function(T) {
      return T._private.cy;
    }, v = {
      addEventFields: function(T, C) {
        C.layout = T, C.cy = c(T), C.target = T;
      },
      bubble: function() {
        return !0;
      },
      parent: function(T) {
        return c(T);
      }
    };
    de(s, {
      createEmitter: function() {
        return this._private.emitter = new Yn(v, this), this;
      },
      emitter: function() {
        return this._private.emitter;
      },
      on: function(T, C) {
        return this.emitter().on(T, C), this;
      },
      one: function(T, C) {
        return this.emitter().one(T, C), this;
      },
      once: function(T, C) {
        return this.emitter().one(T, C), this;
      },
      removeListener: function(T, C) {
        return this.emitter().removeListener(T, C), this;
      },
      removeAllListeners: function() {
        return this.emitter().removeAllListeners(), this;
      },
      emit: function(T, C) {
        return this.emitter().emit(T, C), this;
      }
    }), Oe.eventAliasesOn(s), a = i;
  } else if (r === "renderer" && e !== "null" && e !== "base") {
    var h = Wc("renderer", "base"), d = h.prototype, p = t, g = t.prototype, y = function() {
      h.apply(this, arguments), p.apply(this, arguments);
    }, b = y.prototype;
    for (var m in d) {
      var E = d[m], x = g[m] != null;
      if (x)
        return n(m);
      b[m] = E;
    }
    for (var S in g)
      b[S] = g[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 (r === "__proto__" || r === "constructor" || r === "prototype")
    return qe(r + " is an illegal type to be registered, possibly lead to prototype pollutions");
  return df({
    map: Yc,
    keys: [r, e],
    value: a
  });
}
function Wc(r, e) {
  return gf({
    map: Yc,
    keys: [r, e]
  });
}
function zm(r, e, t, a, n) {
  return df({
    map: Xc,
    keys: [r, e, t, a],
    value: n
  });
}
function Vm(r, e, t, a) {
  return gf({
    map: Xc,
    keys: [r, e, t, a]
  });
}
var Qs = function() {
  if (arguments.length === 2)
    return Wc.apply(null, arguments);
  if (arguments.length === 3)
    return $c.apply(null, arguments);
  if (arguments.length === 4)
    return Vm.apply(null, arguments);
  if (arguments.length === 5)
    return zm.apply(null, arguments);
  qe("Invalid extension access syntax");
};
Ma.prototype.extension = Qs;
Gm.forEach(function(r) {
  r.extensions.forEach(function(e) {
    $c(r.type, e.name, e.impl);
  });
});
var Nn = function() {
  if (!(this instanceof Nn))
    return new Nn();
  this.length = 0;
}, Mr = Nn.prototype;
Mr.instanceString = function() {
  return "stylesheet";
};
Mr.selector = function(r) {
  var e = this.length++;
  return this[e] = {
    selector: r,
    properties: []
  }, this;
};
Mr.css = function(r, e) {
  var t = this.length - 1;
  if (ce(r))
    this[t].properties.push({
      name: r,
      value: e
    });
  else if (Re(r))
    for (var a = r, n = Object.keys(a), i = 0; i < n.length; i++) {
      var s = n[i], o = a[s];
      if (o != null) {
        var u = st.properties[s] || st.properties[kn(s)];
        if (u != null) {
          var l = u.name, f = o;
          this[t].properties.push({
            name: l,
            value: f
          });
        }
      }
    }
  return this;
};
Mr.style = Mr.css;
Mr.generateStyle = function(r) {
  var e = new st(r);
  return this.appendToStyle(e);
};
Mr.appendToStyle = function(r) {
  for (var e = 0; e < this.length; e++) {
    var t = this[e], a = t.selector, n = t.properties;
    r.selector(a);
    for (var i = 0; i < n.length; i++) {
      var s = n[i];
      r.css(s.name, s.value);
    }
  }
  return r;
};
var Um = "3.32.0", vr = function(e) {
  if (e === void 0 && (e = {}), Re(e))
    return new Ma(e);
  if (ce(e))
    return Qs.apply(Qs, arguments);
};
vr.use = function(r) {
  var e = Array.prototype.slice.call(arguments, 1);
  return e.unshift(vr), r.apply(null, e), this;
};
vr.warnings = function(r) {
  return xf(r);
};
vr.version = Um;
vr.stylesheet = vr.Stylesheet = Nn;
var Kc = { exports: {} }, Is = { exports: {} }, Ms = { exports: {} }, af;
function qm() {
  return af || (af = 1, function(r, e) {
    (function(a, n) {
      r.exports = n();
    })(js, function() {
      return (
        /******/
        function(t) {
          var a = {};
          function n(i) {
            if (a[i])
              return a[i].exports;
            var s = a[i] = {
              /******/
              i,
              /******/
              l: !1,
              /******/
              exports: {}
              /******/
            };
            return t[i].call(s.exports, s, s.exports, n), s.l = !0, s.exports;
          }
          return n.m = t, n.c = a, n.i = function(i) {
            return i;
          }, n.d = function(i, s, o) {
            n.o(i, s) || Object.defineProperty(i, s, {
              /******/
              configurable: !1,
              /******/
              enumerable: !0,
              /******/
              get: o
              /******/
            });
          }, n.n = function(i) {
            var s = i && i.__esModule ? (
              /******/
              function() {
                return i.default;
              }
            ) : (
              /******/
              function() {
                return i;
              }
            );
            return n.d(s, "a", s), s;
          }, n.o = function(i, s) {
            return Object.prototype.hasOwnProperty.call(i, s);
          }, n.p = "", n(n.s = 26);
        }([
          /* 0 */
          /***/
          function(t, 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, t.exports = i;
          },
          /* 1 */
          /***/
          function(t, a, n) {
            var i = n(2), s = n(8), o = n(9);
            function u(f, c, v) {
              i.call(this, v), this.isOverlapingSourceAndTarget = !1, this.vGraphObject = v, this.bendpoints = [], this.source = f, this.target = c;
            }
            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, c) {
              for (var v = this.getOtherEnd(f), h = c.getGraphManager().getRoot(); ; ) {
                if (v.getOwner() == c)
                  return v;
                if (v.getOwner() == h)
                  break;
                v = v.getOwner().getParent();
              }
              return null;
            }, u.prototype.updateLength = function() {
              var f = new Array(4);
              this.isOverlapingSourceAndTarget = s.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 = o.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = o.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 = o.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = o.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
            }, t.exports = u;
          },
          /* 2 */
          /***/
          function(t, a, n) {
            function i(s) {
              this.vGraphObject = s;
            }
            t.exports = i;
          },
          /* 3 */
          /***/
          function(t, a, n) {
            var i = n(2), s = n(10), o = n(13), u = n(0), l = n(16), f = n(4);
            function c(h, d, p, g) {
              p == null && g == null && (g = d), i.call(this, g), h.graphManager != null && (h = h.graphManager), this.estimatedSize = s.MIN_VALUE, this.inclusionTreeDepth = s.MAX_VALUE, this.vGraphObject = g, this.edges = [], this.graphManager = h, p != null && d != null ? this.rect = new o(d.x, d.y, p.width, p.height) : this.rect = new o();
            }
            c.prototype = Object.create(i.prototype);
            for (var v in i)
              c[v] = i[v];
            c.prototype.getEdges = function() {
              return this.edges;
            }, c.prototype.getChild = function() {
              return this.child;
            }, c.prototype.getOwner = function() {
              return this.owner;
            }, c.prototype.getWidth = function() {
              return this.rect.width;
            }, c.prototype.setWidth = function(h) {
              this.rect.width = h;
            }, c.prototype.getHeight = function() {
              return this.rect.height;
            }, c.prototype.setHeight = function(h) {
              this.rect.height = h;
            }, c.prototype.getCenterX = function() {
              return this.rect.x + this.rect.width / 2;
            }, c.prototype.getCenterY = function() {
              return this.rect.y + this.rect.height / 2;
            }, c.prototype.getCenter = function() {
              return new f(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
            }, c.prototype.getLocation = function() {
              return new f(this.rect.x, this.rect.y);
            }, c.prototype.getRect = function() {
              return this.rect;
            }, c.prototype.getDiagonal = function() {
              return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
            }, c.prototype.getHalfTheDiagonal = function() {
              return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
            }, c.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;
            }, c.prototype.setCenter = function(h, d) {
              this.rect.x = h - this.rect.width / 2, this.rect.y = d - this.rect.height / 2;
            }, c.prototype.setLocation = function(h, d) {
              this.rect.x = h, this.rect.y = d;
            }, c.prototype.moveBy = function(h, d) {
              this.rect.x += h, this.rect.y += d;
            }, c.prototype.getEdgeListToNode = function(h) {
              var d = [], p = this;
              return p.edges.forEach(function(g) {
                if (g.target == h) {
                  if (g.source != p)
                    throw "Incorrect edge source!";
                  d.push(g);
                }
              }), d;
            }, c.prototype.getEdgesBetween = function(h) {
              var d = [], p = this;
              return p.edges.forEach(function(g) {
                if (!(g.source == p || g.target == p))
                  throw "Incorrect edge source and/or target";
                (g.target == h || g.source == h) && d.push(g);
              }), d;
            }, c.prototype.getNeighborsList = function() {
              var h = /* @__PURE__ */ new Set(), d = this;
              return d.edges.forEach(function(p) {
                if (p.source == d)
                  h.add(p.target);
                else {
                  if (p.target != d)
                    throw "Incorrect incidency!";
                  h.add(p.source);
                }
              }), h;
            }, c.prototype.withChildren = function() {
              var h = /* @__PURE__ */ new Set(), d, p;
              if (h.add(this), this.child != null)
                for (var g = this.child.getNodes(), y = 0; y < g.length; y++)
                  d = g[y], p = d.withChildren(), p.forEach(function(b) {
                    h.add(b);
                  });
              return h;
            }, c.prototype.getNoOfChildren = function() {
              var h = 0, d;
              if (this.child == null)
                h = 1;
              else
                for (var p = this.child.getNodes(), g = 0; g < p.length; g++)
                  d = p[g], h += d.getNoOfChildren();
              return h == 0 && (h = 1), h;
            }, c.prototype.getEstimatedSize = function() {
              if (this.estimatedSize == s.MIN_VALUE)
                throw "assert failed";
              return this.estimatedSize;
            }, c.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);
            }, c.prototype.scatter = function() {
              var h, d, p = -u.INITIAL_WORLD_BOUNDARY, g = u.INITIAL_WORLD_BOUNDARY;
              h = u.WORLD_CENTER_X + l.nextDouble() * (g - p) + p;
              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;
            }, c.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(), p = h.getBottom() - h.getTop();
                  this.labelWidth > d && (this.rect.x -= (this.labelWidth - d) / 2, this.setWidth(this.labelWidth)), this.labelHeight > p && (this.labelPos == "center" ? this.rect.y -= (this.labelHeight - p) / 2 : this.labelPos == "top" && (this.rect.y -= this.labelHeight - p), this.setHeight(this.labelHeight));
                }
              }
            }, c.prototype.getInclusionTreeDepth = function() {
              if (this.inclusionTreeDepth == s.MAX_VALUE)
                throw "assert failed";
              return this.inclusionTreeDepth;
            }, c.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 p = this.rect.y;
              p > u.WORLD_BOUNDARY ? p = u.WORLD_BOUNDARY : p < -u.WORLD_BOUNDARY && (p = -u.WORLD_BOUNDARY);
              var g = new f(d, p), y = h.inverseTransformPoint(g);
              this.setLocation(y.x, y.y);
            }, c.prototype.getLeft = function() {
              return this.rect.x;
            }, c.prototype.getRight = function() {
              return this.rect.x + this.rect.width;
            }, c.prototype.getTop = function() {
              return this.rect.y;
            }, c.prototype.getBottom = function() {
              return this.rect.y + this.rect.height;
            }, c.prototype.getParent = function() {
              return this.owner == null ? null : this.owner.getParent();
            }, t.exports = c;
          },
          /* 4 */
          /***/
          function(t, a, n) {
            function i(s, o) {
              s == null && o == null ? (this.x = 0, this.y = 0) : (this.x = s, this.y = o);
            }
            i.prototype.getX = function() {
              return this.x;
            }, i.prototype.getY = function() {
              return this.y;
            }, i.prototype.setX = function(s) {
              this.x = s;
            }, i.prototype.setY = function(s) {
              this.y = s;
            }, i.prototype.getDifference = function(s) {
              return new DimensionD(this.x - s.x, this.y - s.y);
            }, i.prototype.getCopy = function() {
              return new i(this.x, this.y);
            }, i.prototype.translate = function(s) {
              return this.x += s.width, this.y += s.height, this;
            }, t.exports = i;
          },
          /* 5 */
          /***/
          function(t, a, n) {
            var i = n(2), s = n(10), o = n(0), u = n(6), l = n(3), f = n(1), c = n(13), v = n(12), h = n(11);
            function d(g, y, b) {
              i.call(this, b), this.estimatedSize = s.MIN_VALUE, this.margin = o.DEFAULT_GRAPH_MARGIN, this.edges = [], this.nodes = [], this.isConnected = !1, this.parent = g, 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 p in i)
              d[p] = i[p];
            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(g, y, b) {
              if (y == null && b == null) {
                var m = g;
                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 = g;
                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(g) {
              var y = g;
              if (g 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, x = 0; x < E; x++)
                  m = b[x], 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 (g instanceof f) {
                var m = g;
                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), T = m.target.edges.indexOf(m);
                if (!(w > -1 && T > -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(T, 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 g = s.MAX_VALUE, y = s.MAX_VALUE, b, m, E, x = this.getNodes(), S = x.length, w = 0; w < S; w++) {
                var T = x[w];
                b = T.getTop(), m = T.getLeft(), g > b && (g = b), y > m && (y = m);
              }
              return g == s.MAX_VALUE ? null : (x[0].getParent().paddingLeft != null ? E = x[0].getParent().paddingLeft : E = this.margin, this.left = y - E, this.top = g - E, new v(this.left, this.top));
            }, d.prototype.updateBounds = function(g) {
              for (var y = s.MAX_VALUE, b = -s.MAX_VALUE, m = s.MAX_VALUE, E = -s.MAX_VALUE, x, S, w, T, C, D = this.nodes, A = D.length, L = 0; L < A; L++) {
                var R = D[L];
                g && R.child != null && R.updateBounds(), x = R.getLeft(), S = R.getRight(), w = R.getTop(), T = R.getBottom(), y > x && (y = x), b < S && (b = S), m > w && (m = w), E < T && (E = T);
              }
              var I = new c(y, m, b - y, E - m);
              y == s.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 ? C = D[0].getParent().paddingLeft : C = this.margin, this.left = I.x - C, this.right = I.x + I.width + C, this.top = I.y - C, this.bottom = I.y + I.height + C;
            }, d.calculateBounds = function(g) {
              for (var y = s.MAX_VALUE, b = -s.MAX_VALUE, m = s.MAX_VALUE, E = -s.MAX_VALUE, x, S, w, T, C = g.length, D = 0; D < C; D++) {
                var A = g[D];
                x = A.getLeft(), S = A.getRight(), w = A.getTop(), T = A.getBottom(), y > x && (y = x), b < S && (b = S), m > w && (m = w), E < T && (E = T);
              }
              var L = new c(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 == s.MIN_VALUE)
                throw "assert failed";
              return this.estimatedSize;
            }, d.prototype.calcEstimatedSize = function() {
              for (var g = 0, y = this.nodes, b = y.length, m = 0; m < b; m++) {
                var E = y[m];
                g += E.calcEstimatedSize();
              }
              return g == 0 ? this.estimatedSize = o.EMPTY_COMPOUND_NODE_SIZE : this.estimatedSize = g / Math.sqrt(this.nodes.length), this.estimatedSize;
            }, d.prototype.updateConnected = function() {
              var g = this;
              if (this.nodes.length == 0) {
                this.isConnected = !0;
                return;
              }
              var y = new h(), b = /* @__PURE__ */ new Set(), m = this.nodes[0], E, x, 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, T = 0; T < w; T++) {
                  var C = E[T];
                  if (x = C.getOtherEndInGraph(m, this), x != null && !b.has(x)) {
                    var D = x.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 == g && A++;
                }), A == this.nodes.length && (this.isConnected = !0);
              }
            }, t.exports = d;
          },
          /* 6 */
          /***/
          function(t, a, n) {
            var i, s = n(1);
            function o(u) {
              i = n(5), this.layout = u, this.graphs = [], this.edges = [];
            }
            o.prototype.addRoot = function() {
              var u = this.layout.newGraph(), l = this.layout.newNode(null), f = this.add(u, l);
              return this.setRootGraph(f), this.rootGraph;
            }, o.prototype.add = function(u, l, f, c, v) {
              if (f == null && c == null && v == 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 {
                v = f, c = l, f = u;
                var h = c.getOwner(), d = v.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, c, v);
                if (f.isInterGraph = !0, f.source = c, f.target = v, 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;
              }
            }, o.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 c, v = f.length, h = 0; h < v; h++)
                  c = f[h], l.remove(c);
                var d = [];
                d = d.concat(l.getNodes());
                var p;
                v = d.length;
                for (var h = 0; h < v; h++)
                  p = d[h], l.remove(p);
                l == this.rootGraph && this.setRootGraph(null);
                var g = this.graphs.indexOf(l);
                this.graphs.splice(g, 1), l.parent = null;
              } else if (u instanceof s) {
                if (c = u, c == null)
                  throw "Edge is null!";
                if (!c.isInterGraph)
                  throw "Not an inter-graph edge!";
                if (!(c.source != null && c.target != null))
                  throw "Source and/or target is null!";
                if (!(c.source.edges.indexOf(c) != -1 && c.target.edges.indexOf(c) != -1))
                  throw "Source and/or target doesn't know this edge!";
                var g = c.source.edges.indexOf(c);
                if (c.source.edges.splice(g, 1), g = c.target.edges.indexOf(c), c.target.edges.splice(g, 1), !(c.source.owner != null && c.source.owner.getGraphManager() != null))
                  throw "Edge owner graph or owner graph manager is null!";
                if (c.source.owner.getGraphManager().edges.indexOf(c) == -1)
                  throw "Not in owner graph manager's edge list!";
                var g = c.source.owner.getGraphManager().edges.indexOf(c);
                c.source.owner.getGraphManager().edges.splice(g, 1);
              }
            }, o.prototype.updateBounds = function() {
              this.rootGraph.updateBounds(!0);
            }, o.prototype.getGraphs = function() {
              return this.graphs;
            }, o.prototype.getAllNodes = function() {
              if (this.allNodes == null) {
                for (var u = [], l = this.getGraphs(), f = l.length, c = 0; c < f; c++)
                  u = u.concat(l[c].getNodes());
                this.allNodes = u;
              }
              return this.allNodes;
            }, o.prototype.resetAllNodes = function() {
              this.allNodes = null;
            }, o.prototype.resetAllEdges = function() {
              this.allEdges = null;
            }, o.prototype.resetAllNodesToApplyGravitation = function() {
              this.allNodesToApplyGravitation = null;
            }, o.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;
            }, o.prototype.getAllNodesToApplyGravitation = function() {
              return this.allNodesToApplyGravitation;
            }, o.prototype.setAllNodesToApplyGravitation = function(u) {
              if (this.allNodesToApplyGravitation != null)
                throw "assert failed";
              this.allNodesToApplyGravitation = u;
            }, o.prototype.getRoot = function() {
              return this.rootGraph;
            }, o.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"));
            }, o.prototype.getLayout = function() {
              return this.layout;
            }, o.prototype.isOneAncestorOfOther = function(u, l) {
              if (!(u != null && l != null))
                throw "assert failed";
              if (u == l)
                return !0;
              var f = u.getOwner(), c;
              do {
                if (c = f.getParent(), c == null)
                  break;
                if (c == l)
                  return !0;
                if (f = c.getOwner(), f == null)
                  break;
              } while (!0);
              f = l.getOwner();
              do {
                if (c = f.getParent(), c == null)
                  break;
                if (c == u)
                  return !0;
                if (f = c.getOwner(), f == null)
                  break;
              } while (!0);
              return !1;
            }, o.prototype.calcLowestCommonAncestors = function() {
              for (var u, l, f, c, v, h = this.getAllEdges(), d = h.length, p = 0; p < d; p++) {
                if (u = h[p], l = u.source, f = u.target, u.lca = null, u.sourceInLca = l, u.targetInLca = f, l == f) {
                  u.lca = l.getOwner();
                  continue;
                }
                for (c = l.getOwner(); u.lca == null; ) {
                  for (u.targetInLca = f, v = f.getOwner(); u.lca == null; ) {
                    if (v == c) {
                      u.lca = v;
                      break;
                    }
                    if (v == this.rootGraph)
                      break;
                    if (u.lca != null)
                      throw "assert failed";
                    u.targetInLca = v.getParent(), v = u.targetInLca.getOwner();
                  }
                  if (c == this.rootGraph)
                    break;
                  u.lca == null && (u.sourceInLca = c.getParent(), c = u.sourceInLca.getOwner());
                }
                if (u.lca == null)
                  throw "assert failed";
              }
            }, o.prototype.calcLowestCommonAncestor = function(u, l) {
              if (u == l)
                return u.getOwner();
              var f = u.getOwner();
              do {
                if (f == null)
                  break;
                var c = l.getOwner();
                do {
                  if (c == null)
                    break;
                  if (c == f)
                    return c;
                  c = c.getParent().getOwner();
                } while (!0);
                f = f.getParent().getOwner();
              } while (!0);
              return f;
            }, o.prototype.calcInclusionTreeDepths = function(u, l) {
              u == null && l == null && (u = this.rootGraph, l = 1);
              for (var f, c = u.getNodes(), v = c.length, h = 0; h < v; h++)
                f = c[h], f.inclusionTreeDepth = l, f.child != null && this.calcInclusionTreeDepths(f.child, l + 1);
            }, o.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;
            }, t.exports = o;
          },
          /* 7 */
          /***/
          function(t, a, n) {
            var i = n(0);
            function s() {
            }
            for (var o in i)
              s[o] = i[o];
            s.MAX_ITERATIONS = 2500, s.DEFAULT_EDGE_LENGTH = 50, s.DEFAULT_SPRING_STRENGTH = 0.45, s.DEFAULT_REPULSION_STRENGTH = 4500, s.DEFAULT_GRAVITY_STRENGTH = 0.4, s.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1, s.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8, s.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5, s.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = !0, s.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = !0, s.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3, s.COOLING_ADAPTATION_FACTOR = 0.33, s.ADAPTATION_LOWER_NODE_LIMIT = 1e3, s.ADAPTATION_UPPER_NODE_LIMIT = 5e3, s.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100, s.MAX_NODE_DISPLACEMENT = s.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3, s.MIN_REPULSION_DIST = s.DEFAULT_EDGE_LENGTH / 10, s.CONVERGENCE_CHECK_PERIOD = 100, s.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1, s.MIN_EDGE_LENGTH = 1, s.GRID_CALCULATION_CHECK_PERIOD = 10, t.exports = s;
          },
          /* 8 */
          /***/
          function(t, a, n) {
            var i = n(12);
            function s() {
            }
            s.calcSeparationAmount = function(o, u, l, f) {
              if (!o.intersects(u))
                throw "assert failed";
              var c = new Array(2);
              this.decideDirectionsForOverlappingNodes(o, u, c), l[0] = Math.min(o.getRight(), u.getRight()) - Math.max(o.x, u.x), l[1] = Math.min(o.getBottom(), u.getBottom()) - Math.max(o.y, u.y), o.getX() <= u.getX() && o.getRight() >= u.getRight() ? l[0] += Math.min(u.getX() - o.getX(), o.getRight() - u.getRight()) : u.getX() <= o.getX() && u.getRight() >= o.getRight() && (l[0] += Math.min(o.getX() - u.getX(), u.getRight() - o.getRight())), o.getY() <= u.getY() && o.getBottom() >= u.getBottom() ? l[1] += Math.min(u.getY() - o.getY(), o.getBottom() - u.getBottom()) : u.getY() <= o.getY() && u.getBottom() >= o.getBottom() && (l[1] += Math.min(o.getY() - u.getY(), u.getBottom() - o.getBottom()));
              var v = Math.abs((u.getCenterY() - o.getCenterY()) / (u.getCenterX() - o.getCenterX()));
              u.getCenterY() === o.getCenterY() && u.getCenterX() === o.getCenterX() && (v = 1);
              var h = v * l[0], d = l[1] / v;
              l[0] < d ? d = l[0] : h = l[1], l[0] = -1 * c[0] * (d / 2 + f), l[1] = -1 * c[1] * (h / 2 + f);
            }, s.decideDirectionsForOverlappingNodes = function(o, u, l) {
              o.getCenterX() < u.getCenterX() ? l[0] = -1 : l[0] = 1, o.getCenterY() < u.getCenterY() ? l[1] = -1 : l[1] = 1;
            }, s.getIntersection2 = function(o, u, l) {
              var f = o.getCenterX(), c = o.getCenterY(), v = u.getCenterX(), h = u.getCenterY();
              if (o.intersects(u))
                return l[0] = f, l[1] = c, l[2] = v, l[3] = h, !0;
              var d = o.getX(), p = o.getY(), g = o.getRight(), y = o.getX(), b = o.getBottom(), m = o.getRight(), E = o.getWidthHalf(), x = o.getHeightHalf(), S = u.getX(), w = u.getY(), T = u.getRight(), C = u.getX(), D = u.getBottom(), A = u.getRight(), L = u.getWidthHalf(), R = u.getHeightHalf(), I = !1, O = !1;
              if (f === v) {
                if (c > h)
                  return l[0] = f, l[1] = p, l[2] = v, l[3] = D, !1;
                if (c < h)
                  return l[0] = f, l[1] = b, l[2] = v, l[3] = w, !1;
              } else if (c === h) {
                if (f > v)
                  return l[0] = d, l[1] = c, l[2] = T, l[3] = h, !1;
                if (f < v)
                  return l[0] = g, l[1] = c, l[2] = S, l[3] = h, !1;
              } else {
                var N = o.height / o.width, k = u.height / u.width, P = (h - c) / (v - f), B = void 0, _ = void 0, F = void 0, G = void 0, U = void 0, H = void 0;
                if (-N === P ? f > v ? (l[0] = y, l[1] = b, I = !0) : (l[0] = g, l[1] = p, I = !0) : N === P && (f > v ? (l[0] = d, l[1] = p, I = !0) : (l[0] = m, l[1] = b, I = !0)), -k === P ? v > f ? (l[2] = C, l[3] = D, O = !0) : (l[2] = T, l[3] = w, O = !0) : k === P && (v > f ? (l[2] = S, l[3] = w, O = !0) : (l[2] = A, l[3] = D, O = !0)), I && O)
                  return !1;
                if (f > v ? c > h ? (B = this.getCardinalDirection(N, P, 4), _ = this.getCardinalDirection(k, P, 2)) : (B = this.getCardinalDirection(-N, P, 3), _ = this.getCardinalDirection(-k, P, 1)) : c > h ? (B = this.getCardinalDirection(-N, P, 1), _ = this.getCardinalDirection(-k, P, 3)) : (B = this.getCardinalDirection(N, P, 2), _ = this.getCardinalDirection(k, P, 4)), !I)
                  switch (B) {
                    case 1:
                      G = p, F = f + -x / P, l[0] = F, l[1] = G;
                      break;
                    case 2:
                      F = m, G = c + E * P, l[0] = F, l[1] = G;
                      break;
                    case 3:
                      G = b, F = f + x / P, l[0] = F, l[1] = G;
                      break;
                    case 4:
                      F = y, G = c + -E * P, l[0] = F, l[1] = G;
                      break;
                  }
                if (!O)
                  switch (_) {
                    case 1:
                      H = w, U = v + -R / P, l[2] = U, l[3] = H;
                      break;
                    case 2:
                      U = A, H = h + L * P, l[2] = U, l[3] = H;
                      break;
                    case 3:
                      H = D, U = v + R / P, l[2] = U, l[3] = H;
                      break;
                    case 4:
                      U = C, H = h + -L * P, l[2] = U, l[3] = H;
                      break;
                  }
              }
              return !1;
            }, s.getCardinalDirection = function(o, u, l) {
              return o > u ? l : 1 + l % 4;
            }, s.getIntersection = function(o, u, l, f) {
              if (f == null)
                return this.getIntersection2(o, u, l);
              var c = o.x, v = o.y, h = u.x, d = u.y, p = l.x, g = l.y, y = f.x, b = f.y, m = void 0, E = void 0, x = void 0, S = void 0, w = void 0, T = void 0, C = void 0, D = void 0, A = void 0;
              return x = d - v, w = c - h, C = h * v - c * d, S = b - g, T = p - y, D = y * g - p * b, A = x * T - S * w, A === 0 ? null : (m = (w * D - T * C) / A, E = (S * C - x * D) / A, new i(m, E));
            }, s.angleOfVector = function(o, u, l, f) {
              var c = void 0;
              return o !== l ? (c = Math.atan((f - u) / (l - o)), l < o ? c += Math.PI : f < u && (c += this.TWO_PI)) : f < u ? c = this.ONE_AND_HALF_PI : c = this.HALF_PI, c;
            }, s.doIntersect = function(o, u, l, f) {
              var c = o.x, v = o.y, h = u.x, d = u.y, p = l.x, g = l.y, y = f.x, b = f.y, m = (h - c) * (b - g) - (y - p) * (d - v);
              if (m === 0)
                return !1;
              var E = ((b - g) * (y - c) + (p - y) * (b - v)) / m, x = ((v - d) * (y - c) + (h - c) * (b - v)) / m;
              return 0 < E && E < 1 && 0 < x && x < 1;
            }, s.HALF_PI = 0.5 * Math.PI, s.ONE_AND_HALF_PI = 1.5 * Math.PI, s.TWO_PI = 2 * Math.PI, s.THREE_PI = 3 * Math.PI, t.exports = s;
          },
          /* 9 */
          /***/
          function(t, a, n) {
            function i() {
            }
            i.sign = function(s) {
              return s > 0 ? 1 : s < 0 ? -1 : 0;
            }, i.floor = function(s) {
              return s < 0 ? Math.ceil(s) : Math.floor(s);
            }, i.ceil = function(s) {
              return s < 0 ? Math.floor(s) : Math.ceil(s);
            }, t.exports = i;
          },
          /* 10 */
          /***/
          function(t, a, n) {
            function i() {
            }
            i.MAX_VALUE = 2147483647, i.MIN_VALUE = -2147483648, t.exports = i;
          },
          /* 11 */
          /***/
          function(t, a, n) {
            var i = function() {
              function c(v, h) {
                for (var d = 0; d < h.length; d++) {
                  var p = h[d];
                  p.enumerable = p.enumerable || !1, p.configurable = !0, "value" in p && (p.writable = !0), Object.defineProperty(v, p.key, p);
                }
              }
              return function(v, h, d) {
                return h && c(v.prototype, h), d && c(v, d), v;
              };
            }();
            function s(c, v) {
              if (!(c instanceof v))
                throw new TypeError("Cannot call a class as a function");
            }
            var o = function(v) {
              return { value: v, next: null, prev: null };
            }, u = function(v, h, d, p) {
              return v !== null ? v.next = h : p.head = h, d !== null ? d.prev = h : p.tail = h, h.prev = v, h.next = d, p.length++, h;
            }, l = function(v, h) {
              var d = v.prev, p = v.next;
              return d !== null ? d.next = p : h.head = p, p !== null ? p.prev = d : h.tail = d, v.prev = v.next = null, h.length--, v;
            }, f = function() {
              function c(v) {
                var h = this;
                s(this, c), this.length = 0, this.head = null, this.tail = null, v != null && v.forEach(function(d) {
                  return h.push(d);
                });
              }
              return i(c, [{
                key: "size",
                value: function() {
                  return this.length;
                }
              }, {
                key: "insertBefore",
                value: function(h, d) {
                  return u(d.prev, o(h), d, this);
                }
              }, {
                key: "insertAfter",
                value: function(h, d) {
                  return u(d, o(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, o(h), null, this);
                }
              }, {
                key: "unshift",
                value: function(h) {
                  return u(null, o(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, p = this.head; d < h; )
                      p = p.next, d++;
                    return p.value;
                  }
                }
              }, {
                key: "set_object_at",
                value: function(h, d) {
                  if (h <= this.length()) {
                    for (var p = 1, g = this.head; p < h; )
                      g = g.next, p++;
                    g.value = d;
                  }
                }
              }]), c;
            }();
            t.exports = f;
          },
          /* 12 */
          /***/
          function(t, a, n) {
            function i(s, o, u) {
              this.x = null, this.y = null, s == null && o == null && u == null ? (this.x = 0, this.y = 0) : typeof s == "number" && typeof o == "number" && u == null ? (this.x = s, this.y = o) : s.constructor.name == "Point" && o == null && u == null && (u = s, 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(s, o, u) {
              s.constructor.name == "Point" && o == null && u == null ? (u = s, this.setLocation(u.x, u.y)) : typeof s == "number" && typeof o == "number" && u == null && (parseInt(s) == s && parseInt(o) == o ? this.move(s, o) : (this.x = Math.floor(s + 0.5), this.y = Math.floor(o + 0.5)));
            }, i.prototype.move = function(s, o) {
              this.x = s, this.y = o;
            }, i.prototype.translate = function(s, o) {
              this.x += s, this.y += o;
            }, i.prototype.equals = function(s) {
              if (s.constructor.name == "Point") {
                var o = s;
                return this.x == o.x && this.y == o.y;
              }
              return this == s;
            }, i.prototype.toString = function() {
              return new i().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
            }, t.exports = i;
          },
          /* 13 */
          /***/
          function(t, a, n) {
            function i(s, o, u, l) {
              this.x = 0, this.y = 0, this.width = 0, this.height = 0, s != null && o != null && u != null && l != null && (this.x = s, this.y = o, this.width = u, this.height = l);
            }
            i.prototype.getX = function() {
              return this.x;
            }, i.prototype.setX = function(s) {
              this.x = s;
            }, i.prototype.getY = function() {
              return this.y;
            }, i.prototype.setY = function(s) {
              this.y = s;
            }, i.prototype.getWidth = function() {
              return this.width;
            }, i.prototype.setWidth = function(s) {
              this.width = s;
            }, i.prototype.getHeight = function() {
              return this.height;
            }, i.prototype.setHeight = function(s) {
              this.height = s;
            }, i.prototype.getRight = function() {
              return this.x + this.width;
            }, i.prototype.getBottom = function() {
              return this.y + this.height;
            }, i.prototype.intersects = function(s) {
              return !(this.getRight() < s.x || this.getBottom() < s.y || s.getRight() < this.x || s.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;
            }, t.exports = i;
          },
          /* 14 */
          /***/
          function(t, a, n) {
            var i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
              return typeof o;
            } : function(o) {
              return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
            };
            function s() {
            }
            s.lastID = 0, s.createID = function(o) {
              return s.isPrimitive(o) ? o : (o.uniqueID != null || (o.uniqueID = s.getString(), s.lastID++), o.uniqueID);
            }, s.getString = function(o) {
              return o == null && (o = s.lastID), "Object#" + o;
            }, s.isPrimitive = function(o) {
              var u = typeof o > "u" ? "undefined" : i(o);
              return o == null || u != "object" && u != "function";
            }, t.exports = s;
          },
          /* 15 */
          /***/
          function(t, a, n) {
            function i(p) {
              if (Array.isArray(p)) {
                for (var g = 0, y = Array(p.length); g < p.length; g++)
                  y[g] = p[g];
                return y;
              } else
                return Array.from(p);
            }
            var s = n(0), o = n(6), u = n(3), l = n(1), f = n(5), c = n(4), v = n(17), h = n(27);
            function d(p) {
              h.call(this), this.layoutQuality = s.QUALITY, this.createBendsAsNeeded = s.DEFAULT_CREATE_BENDS_AS_NEEDED, this.incremental = s.DEFAULT_INCREMENTAL, this.animationOnLayout = s.DEFAULT_ANIMATION_ON_LAYOUT, this.animationDuringLayout = s.DEFAULT_ANIMATION_DURING_LAYOUT, this.animationPeriod = s.DEFAULT_ANIMATION_PERIOD, this.uniformLeafNodeSizes = s.DEFAULT_UNIFORM_LEAF_NODE_SIZES, this.edgeToDummyNodes = /* @__PURE__ */ new Map(), this.graphManager = new o(this), this.isLayoutFinished = !1, this.isSubLayout = !1, this.isRemoteUse = !1, p != null && (this.isRemoteUse = p);
            }
            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 p = new o(this);
              return this.graphManager = p, p;
            }, d.prototype.newGraph = function(p) {
              return new f(null, this.graphManager, p);
            }, d.prototype.newNode = function(p) {
              return new u(this.graphManager, p);
            }, d.prototype.newEdge = function(p) {
              return new l(null, null, p);
            }, 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 p;
              return this.checkLayoutSuccess() ? p = !1 : p = this.layout(), s.ANIMATE === "during" ? !1 : (p && (this.isSubLayout || this.doPostLayout()), this.tilingPostLayout && this.tilingPostLayout(), this.isLayoutFinished = !0, p);
            }, 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 p = this.graphManager.getAllEdges(), g = 0; g < p.length; g++)
                  p[g];
                for (var y = this.graphManager.getRoot().getNodes(), g = 0; g < y.length; g++)
                  y[g];
                this.update(this.graphManager.getRoot());
              }
            }, d.prototype.update = function(p) {
              if (p == null)
                this.update2();
              else if (p instanceof u) {
                var g = p;
                if (g.getChild() != null)
                  for (var y = g.getChild().getNodes(), b = 0; b < y.length; b++)
                    update(y[b]);
                if (g.vGraphObject != null) {
                  var m = g.vGraphObject;
                  m.update(g);
                }
              } else if (p instanceof l) {
                var E = p;
                if (E.vGraphObject != null) {
                  var x = E.vGraphObject;
                  x.update(E);
                }
              } else if (p instanceof f) {
                var S = p;
                if (S.vGraphObject != null) {
                  var w = S.vGraphObject;
                  w.update(S);
                }
              }
            }, d.prototype.initParameters = function() {
              this.isSubLayout || (this.layoutQuality = s.QUALITY, this.animationDuringLayout = s.DEFAULT_ANIMATION_DURING_LAYOUT, this.animationPeriod = s.DEFAULT_ANIMATION_PERIOD, this.animationOnLayout = s.DEFAULT_ANIMATION_ON_LAYOUT, this.incremental = s.DEFAULT_INCREMENTAL, this.createBendsAsNeeded = s.DEFAULT_CREATE_BENDS_AS_NEEDED, this.uniformLeafNodeSizes = s.DEFAULT_UNIFORM_LEAF_NODE_SIZES), this.animationDuringLayout && (this.animationOnLayout = !1);
            }, d.prototype.transform = function(p) {
              if (p == null)
                this.transform(new c(0, 0));
              else {
                var g = new v(), y = this.graphManager.getRoot().updateLeftTop();
                if (y != null) {
                  g.setWorldOrgX(p.x), g.setWorldOrgY(p.y), g.setDeviceOrgX(y.x), g.setDeviceOrgY(y.y);
                  for (var b = this.getAllNodes(), m, E = 0; E < b.length; E++)
                    m = b[E], m.transform(g);
                }
              }
            }, d.prototype.positionNodesRandomly = function(p) {
              if (p == null)
                this.positionNodesRandomly(this.getGraphManager().getRoot()), this.getGraphManager().getRoot().updateBounds(!0);
              else
                for (var g, y, b = p.getNodes(), m = 0; m < b.length; m++)
                  g = b[m], y = g.getChild(), y == null || y.getNodes().length == 0 ? g.scatter() : (this.positionNodesRandomly(y), g.updateBounds());
            }, d.prototype.getFlatForest = function() {
              for (var p = [], g = !0, y = this.graphManager.getRoot().getNodes(), b = !0, m = 0; m < y.length; m++)
                y[m].getChild() != null && (b = !1);
              if (!b)
                return p;
              var E = /* @__PURE__ */ new Set(), x = [], S = /* @__PURE__ */ new Map(), w = [];
              for (w = w.concat(y); w.length > 0 && g; ) {
                for (x.push(w[0]); x.length > 0 && g; ) {
                  var T = x[0];
                  x.splice(0, 1), E.add(T);
                  for (var C = T.getEdges(), m = 0; m < C.length; m++) {
                    var D = C[m].getOtherEnd(T);
                    if (S.get(T) != D)
                      if (!E.has(D))
                        x.push(D), S.set(D, T);
                      else {
                        g = !1;
                        break;
                      }
                  }
                }
                if (!g)
                  p = [];
                else {
                  var A = [].concat(i(E));
                  p.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 p;
            }, d.prototype.createDummyNodesForBendpoints = function(p) {
              for (var g = [], y = p.source, b = this.graphManager.calcLowestCommonAncestor(p.source, p.target), m = 0; m < p.bendpoints.length; m++) {
                var E = this.newNode(null);
                E.setRect(new Point(0, 0), new Dimension(1, 1)), b.add(E);
                var x = this.newEdge(null);
                this.graphManager.add(x, y, E), g.add(E), y = E;
              }
              var x = this.newEdge(null);
              return this.graphManager.add(x, y, p.target), this.edgeToDummyNodes.set(p, g), p.isInterGraph() ? this.graphManager.remove(p) : b.remove(p), g;
            }, d.prototype.createBendpointsFromDummyNodes = function() {
              var p = [];
              p = p.concat(this.graphManager.getAllEdges()), p = [].concat(i(this.edgeToDummyNodes.keys())).concat(p);
              for (var g = 0; g < p.length; g++) {
                var y = p[g];
                if (y.bendpoints.length > 0) {
                  for (var b = this.edgeToDummyNodes.get(y), m = 0; m < b.length; m++) {
                    var E = b[m], x = new c(E.getCenterX(), E.getCenterY()), S = y.bendpoints.get(m);
                    S.x = x.x, S.y = x.y, E.getOwner().remove(E);
                  }
                  this.graphManager.add(y, y.source, y.target);
                }
              }
            }, d.transform = function(p, g, y, b) {
              if (y != null && b != null) {
                var m = g;
                if (p <= 50) {
                  var E = g / y;
                  m -= (g - E) / 50 * (50 - p);
                } else {
                  var x = g * b;
                  m += (x - g) / 50 * (p - 50);
                }
                return m;
              } else {
                var S, w;
                return p <= 50 ? (S = 9 * g / 500, w = g / 10) : (S = 9 * g / 50, w = -8 * g), S * p + w;
              }
            }, d.findCenterOfTree = function(p) {
              var g = [];
              g = g.concat(p);
              var y = [], b = /* @__PURE__ */ new Map(), m = !1, E = null;
              (g.length == 1 || g.length == 2) && (m = !0, E = g[0]);
              for (var x = 0; x < g.length; x++) {
                var S = g[x], w = S.getNeighborsList().size;
                b.set(S, S.getNeighborsList().size), w == 1 && y.push(S);
              }
              var T = [];
              for (T = T.concat(y); !m; ) {
                var C = [];
                C = C.concat(T), T = [];
                for (var x = 0; x < g.length; x++) {
                  var S = g[x], D = g.indexOf(S);
                  D >= 0 && g.splice(D, 1);
                  var A = S.getNeighborsList();
                  A.forEach(function(I) {
                    if (y.indexOf(I) < 0) {
                      var O = b.get(I), N = O - 1;
                      N == 1 && T.push(I), b.set(I, N);
                    }
                  });
                }
                y = y.concat(T), (g.length == 1 || g.length == 2) && (m = !0, E = g[0]);
              }
              return E;
            }, d.prototype.setGraphManager = function(p) {
              this.graphManager = p;
            }, t.exports = d;
          },
          /* 16 */
          /***/
          function(t, 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);
            }, t.exports = i;
          },
          /* 17 */
          /***/
          function(t, a, n) {
            var i = n(4);
            function s(o, 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;
            }
            s.prototype.getWorldOrgX = function() {
              return this.lworldOrgX;
            }, s.prototype.setWorldOrgX = function(o) {
              this.lworldOrgX = o;
            }, s.prototype.getWorldOrgY = function() {
              return this.lworldOrgY;
            }, s.prototype.setWorldOrgY = function(o) {
              this.lworldOrgY = o;
            }, s.prototype.getWorldExtX = function() {
              return this.lworldExtX;
            }, s.prototype.setWorldExtX = function(o) {
              this.lworldExtX = o;
            }, s.prototype.getWorldExtY = function() {
              return this.lworldExtY;
            }, s.prototype.setWorldExtY = function(o) {
              this.lworldExtY = o;
            }, s.prototype.getDeviceOrgX = function() {
              return this.ldeviceOrgX;
            }, s.prototype.setDeviceOrgX = function(o) {
              this.ldeviceOrgX = o;
            }, s.prototype.getDeviceOrgY = function() {
              return this.ldeviceOrgY;
            }, s.prototype.setDeviceOrgY = function(o) {
              this.ldeviceOrgY = o;
            }, s.prototype.getDeviceExtX = function() {
              return this.ldeviceExtX;
            }, s.prototype.setDeviceExtX = function(o) {
              this.ldeviceExtX = o;
            }, s.prototype.getDeviceExtY = function() {
              return this.ldeviceExtY;
            }, s.prototype.setDeviceExtY = function(o) {
              this.ldeviceExtY = o;
            }, s.prototype.transformX = function(o) {
              var u = 0, l = this.lworldExtX;
              return l != 0 && (u = this.ldeviceOrgX + (o - this.lworldOrgX) * this.ldeviceExtX / l), u;
            }, s.prototype.transformY = function(o) {
              var u = 0, l = this.lworldExtY;
              return l != 0 && (u = this.ldeviceOrgY + (o - this.lworldOrgY) * this.ldeviceExtY / l), u;
            }, s.prototype.inverseTransformX = function(o) {
              var u = 0, l = this.ldeviceExtX;
              return l != 0 && (u = this.lworldOrgX + (o - this.ldeviceOrgX) * this.lworldExtX / l), u;
            }, s.prototype.inverseTransformY = function(o) {
              var u = 0, l = this.ldeviceExtY;
              return l != 0 && (u = this.lworldOrgY + (o - this.ldeviceOrgY) * this.lworldExtY / l), u;
            }, s.prototype.inverseTransformPoint = function(o) {
              var u = new i(this.inverseTransformX(o.x), this.inverseTransformY(o.y));
              return u;
            }, t.exports = s;
          },
          /* 18 */
          /***/
          function(t, a, n) {
            function i(h) {
              if (Array.isArray(h)) {
                for (var d = 0, p = Array(h.length); d < h.length; d++)
                  p[d] = h[d];
                return p;
              } else
                return Array.from(h);
            }
            var s = n(15), o = n(7), u = n(0), l = n(8), f = n(9);
            function c() {
              s.call(this), this.useSmartIdealEdgeLengthCalculation = o.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.idealEdgeLength = o.DEFAULT_EDGE_LENGTH, this.springConstant = o.DEFAULT_SPRING_STRENGTH, this.repulsionConstant = o.DEFAULT_REPULSION_STRENGTH, this.gravityConstant = o.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = o.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = o.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = o.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.displacementThresholdPerNode = 3 * o.DEFAULT_EDGE_LENGTH / 100, this.coolingFactor = o.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.initialCoolingFactor = o.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.totalDisplacement = 0, this.oldTotalDisplacement = 0, this.maxIterations = o.MAX_ITERATIONS;
            }
            c.prototype = Object.create(s.prototype);
            for (var v in s)
              c[v] = s[v];
            c.prototype.initParameters = function() {
              s.prototype.initParameters.call(this, arguments), this.totalIterations = 0, this.notAnimatedIterations = 0, this.useFRGridVariant = o.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION, this.grid = [];
            }, c.prototype.calcIdealEdgeLengths = function() {
              for (var h, d, p, g, y, b, m = this.getGraphManager().getAllEdges(), E = 0; E < m.length; E++)
                h = m[E], h.idealLength = this.idealEdgeLength, h.isInterGraph && (p = h.getSource(), g = 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 += o.DEFAULT_EDGE_LENGTH * o.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (p.getInclusionTreeDepth() + g.getInclusionTreeDepth() - 2 * d));
            }, c.prototype.initSpringEmbedder = function() {
              var h = this.getAllNodes().length;
              this.incremental ? (h > o.ADAPTATION_LOWER_NODE_LIMIT && (this.coolingFactor = Math.max(this.coolingFactor * o.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (h - o.ADAPTATION_LOWER_NODE_LIMIT) / (o.ADAPTATION_UPPER_NODE_LIMIT - o.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - o.COOLING_ADAPTATION_FACTOR))), this.maxNodeDisplacement = o.MAX_NODE_DISPLACEMENT_INCREMENTAL) : (h > o.ADAPTATION_LOWER_NODE_LIMIT ? this.coolingFactor = Math.max(o.COOLING_ADAPTATION_FACTOR, 1 - (h - o.ADAPTATION_LOWER_NODE_LIMIT) / (o.ADAPTATION_UPPER_NODE_LIMIT - o.ADAPTATION_LOWER_NODE_LIMIT) * (1 - o.COOLING_ADAPTATION_FACTOR)) : this.coolingFactor = 1, this.initialCoolingFactor = this.coolingFactor, this.maxNodeDisplacement = o.MAX_NODE_DISPLACEMENT), this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations), this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length, this.repulsionRange = this.calcRepulsionRange();
            }, c.prototype.calcSpringForces = function() {
              for (var h = this.getAllEdges(), d, p = 0; p < h.length; p++)
                d = h[p], this.calcSpringForce(d, d.idealLength);
            }, c.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, p, g, y, b, m = this.getAllNodes(), E;
              if (this.useFRGridVariant)
                for (this.totalIterations % o.GRID_CALCULATION_CHECK_PERIOD == 1 && h && this.updateGrid(), E = /* @__PURE__ */ new Set(), p = 0; p < m.length; p++)
                  y = m[p], this.calculateRepulsionForceOfANode(y, E, h, d), E.add(y);
              else
                for (p = 0; p < m.length; p++)
                  for (y = m[p], g = p + 1; g < m.length; g++)
                    b = m[g], y.getOwner() == b.getOwner() && this.calcRepulsionForce(y, b);
            }, c.prototype.calcGravitationalForces = function() {
              for (var h, d = this.getAllNodesToApplyGravitation(), p = 0; p < d.length; p++)
                h = d[p], this.calcGravitationalForce(h);
            }, c.prototype.moveNodes = function() {
              for (var h = this.getAllNodes(), d, p = 0; p < h.length; p++)
                d = h[p], d.move();
            }, c.prototype.calcSpringForce = function(h, d) {
              var p = h.getSource(), g = h.getTarget(), y, b, m, E;
              if (this.uniformLeafNodeSizes && p.getChild() == null && g.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), p.springForceX += m, p.springForceY += E, g.springForceX -= m, g.springForceY -= E);
            }, c.prototype.calcRepulsionForce = function(h, d) {
              var p = h.getRect(), g = d.getRect(), y = new Array(2), b = new Array(4), m, E, x, S, w, T, C;
              if (p.intersects(g)) {
                l.calcSeparationAmount(p, g, y, o.DEFAULT_EDGE_LENGTH / 2), T = 2 * y[0], C = 2 * y[1];
                var D = h.noOfChildren * d.noOfChildren / (h.noOfChildren + d.noOfChildren);
                h.repulsionForceX -= D * T, h.repulsionForceY -= D * C, d.repulsionForceX += D * T, d.repulsionForceY += D * C;
              } else
                this.uniformLeafNodeSizes && h.getChild() == null && d.getChild() == null ? (m = g.getCenterX() - p.getCenterX(), E = g.getCenterY() - p.getCenterY()) : (l.getIntersection(p, g, b), m = b[2] - b[0], E = b[3] - b[1]), Math.abs(m) < o.MIN_REPULSION_DIST && (m = f.sign(m) * o.MIN_REPULSION_DIST), Math.abs(E) < o.MIN_REPULSION_DIST && (E = f.sign(E) * o.MIN_REPULSION_DIST), x = m * m + E * E, S = Math.sqrt(x), w = this.repulsionConstant * h.noOfChildren * d.noOfChildren / x, T = w * m / S, C = w * E / S, h.repulsionForceX -= T, h.repulsionForceY -= C, d.repulsionForceX += T, d.repulsionForceY += C;
            }, c.prototype.calcGravitationalForce = function(h) {
              var d, p, g, y, b, m, E, x;
              d = h.getOwner(), p = (d.getRight() + d.getLeft()) / 2, g = (d.getTop() + d.getBottom()) / 2, y = h.getCenterX() - p, b = h.getCenterY() - g, m = Math.abs(y) + h.getWidth() / 2, E = Math.abs(b) + h.getHeight() / 2, h.getOwner() == this.graphManager.getRoot() ? (x = d.getEstimatedSize() * this.gravityRangeFactor, (m > x || E > x) && (h.gravitationForceX = -this.gravityConstant * y, h.gravitationForceY = -this.gravityConstant * b)) : (x = d.getEstimatedSize() * this.compoundGravityRangeFactor, (m > x || E > x) && (h.gravitationForceX = -this.gravityConstant * y * this.compoundGravityConstant, h.gravitationForceY = -this.gravityConstant * b * this.compoundGravityConstant));
            }, c.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;
            }, c.prototype.animate = function() {
              this.animationDuringLayout && !this.isSubLayout && (this.notAnimatedIterations == this.animationPeriod ? (this.update(), this.notAnimatedIterations = 0) : this.notAnimatedIterations++);
            }, c.prototype.calcNoOfChildrenForAllNodes = function() {
              for (var h, d = this.graphManager.getAllNodes(), p = 0; p < d.length; p++)
                h = d[p], h.noOfChildren = h.getNoOfChildren();
            }, c.prototype.calcGrid = function(h) {
              var d = 0, p = 0;
              d = parseInt(Math.ceil((h.getRight() - h.getLeft()) / this.repulsionRange)), p = parseInt(Math.ceil((h.getBottom() - h.getTop()) / this.repulsionRange));
              for (var g = new Array(d), y = 0; y < d; y++)
                g[y] = new Array(p);
              for (var y = 0; y < d; y++)
                for (var b = 0; b < p; b++)
                  g[y][b] = new Array();
              return g;
            }, c.prototype.addNodeToGrid = function(h, d, p) {
              var g = 0, y = 0, b = 0, m = 0;
              g = 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 - p) / this.repulsionRange)), m = parseInt(Math.floor((h.getRect().height + h.getRect().y - p) / this.repulsionRange));
              for (var E = g; E <= y; E++)
                for (var x = b; x <= m; x++)
                  this.grid[E][x].push(h), h.setGridCoordinates(g, y, b, m);
            }, c.prototype.updateGrid = function() {
              var h, d, p = this.getAllNodes();
              for (this.grid = this.calcGrid(this.graphManager.getRoot()), h = 0; h < p.length; h++)
                d = p[h], this.addNodeToGrid(d, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
            }, c.prototype.calculateRepulsionForceOfANode = function(h, d, p, g) {
              if (this.totalIterations % o.GRID_CALCULATION_CHECK_PERIOD == 1 && p || g) {
                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 x = h.startY - 1; x < h.finishY + 2; x++)
                    if (!(E < 0 || x < 0 || E >= m.length || x >= m[0].length)) {
                      for (var S = 0; S < m[E][x].length; S++)
                        if (b = m[E][x][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), T = Math.abs(h.getCenterY() - b.getCenterY()) - (h.getHeight() / 2 + b.getHeight() / 2);
                          w <= this.repulsionRange && T <= this.repulsionRange && y.add(b);
                        }
                    }
                h.surrounding = [].concat(i(y));
              }
              for (E = 0; E < h.surrounding.length; E++)
                this.calcRepulsionForce(h, h.surrounding[E]);
            }, c.prototype.calcRepulsionRange = function() {
              return 0;
            }, t.exports = c;
          },
          /* 19 */
          /***/
          function(t, a, n) {
            var i = n(1), s = n(7);
            function o(l, f, c) {
              i.call(this, l, f, c), this.idealLength = s.DEFAULT_EDGE_LENGTH;
            }
            o.prototype = Object.create(i.prototype);
            for (var u in i)
              o[u] = i[u];
            t.exports = o;
          },
          /* 20 */
          /***/
          function(t, a, n) {
            var i = n(3);
            function s(u, l, f, c) {
              i.call(this, u, l, f, c), 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 = [];
            }
            s.prototype = Object.create(i.prototype);
            for (var o in i)
              s[o] = i[o];
            s.prototype.setGridCoordinates = function(u, l, f, c) {
              this.startX = u, this.finishX = l, this.startY = f, this.finishY = c;
            }, t.exports = s;
          },
          /* 21 */
          /***/
          function(t, a, n) {
            function i(s, o) {
              this.width = 0, this.height = 0, s !== null && o !== null && (this.height = o, this.width = s);
            }
            i.prototype.getWidth = function() {
              return this.width;
            }, i.prototype.setWidth = function(s) {
              this.width = s;
            }, i.prototype.getHeight = function() {
              return this.height;
            }, i.prototype.setHeight = function(s) {
              this.height = s;
            }, t.exports = i;
          },
          /* 22 */
          /***/
          function(t, a, n) {
            var i = n(14);
            function s() {
              this.map = {}, this.keys = [];
            }
            s.prototype.put = function(o, u) {
              var l = i.createID(o);
              this.contains(l) || (this.map[l] = u, this.keys.push(o));
            }, s.prototype.contains = function(o) {
              return i.createID(o), this.map[o] != null;
            }, s.prototype.get = function(o) {
              var u = i.createID(o);
              return this.map[u];
            }, s.prototype.keySet = function() {
              return this.keys;
            }, t.exports = s;
          },
          /* 23 */
          /***/
          function(t, a, n) {
            var i = n(14);
            function s() {
              this.set = {};
            }
            s.prototype.add = function(o) {
              var u = i.createID(o);
              this.contains(u) || (this.set[u] = o);
            }, s.prototype.remove = function(o) {
              delete this.set[i.createID(o)];
            }, s.prototype.clear = function() {
              this.set = {};
            }, s.prototype.contains = function(o) {
              return this.set[i.createID(o)] == o;
            }, s.prototype.isEmpty = function() {
              return this.size() === 0;
            }, s.prototype.size = function() {
              return Object.keys(this.set).length;
            }, s.prototype.addAllTo = function(o) {
              for (var u = Object.keys(this.set), l = u.length, f = 0; f < l; f++)
                o.push(this.set[u[f]]);
            }, s.prototype.size = function() {
              return Object.keys(this.set).length;
            }, s.prototype.addAll = function(o) {
              for (var u = o.length, l = 0; l < u; l++) {
                var f = o[l];
                this.add(f);
              }
            }, t.exports = s;
          },
          /* 24 */
          /***/
          function(t, a, n) {
            var i = function() {
              function l(f, c) {
                for (var v = 0; v < c.length; v++) {
                  var h = c[v];
                  h.enumerable = h.enumerable || !1, h.configurable = !0, "value" in h && (h.writable = !0), Object.defineProperty(f, h.key, h);
                }
              }
              return function(f, c, v) {
                return c && l(f.prototype, c), v && l(f, v), f;
              };
            }();
            function s(l, f) {
              if (!(l instanceof f))
                throw new TypeError("Cannot call a class as a function");
            }
            var o = n(11), u = function() {
              function l(f, c) {
                s(this, l), (c !== null || c !== void 0) && (this.compareFunction = this._defaultCompareFunction);
                var v = void 0;
                f instanceof o ? v = f.size() : v = f.length, this._quicksort(f, 0, v - 1);
              }
              return i(l, [{
                key: "_quicksort",
                value: function(c, v, h) {
                  if (v < h) {
                    var d = this._partition(c, v, h);
                    this._quicksort(c, v, d), this._quicksort(c, d + 1, h);
                  }
                }
              }, {
                key: "_partition",
                value: function(c, v, h) {
                  for (var d = this._get(c, v), p = v, g = h; ; ) {
                    for (; this.compareFunction(d, this._get(c, g)); )
                      g--;
                    for (; this.compareFunction(this._get(c, p), d); )
                      p++;
                    if (p < g)
                      this._swap(c, p, g), p++, g--;
                    else
                      return g;
                  }
                }
              }, {
                key: "_get",
                value: function(c, v) {
                  return c instanceof o ? c.get_object_at(v) : c[v];
                }
              }, {
                key: "_set",
                value: function(c, v, h) {
                  c instanceof o ? c.set_object_at(v, h) : c[v] = h;
                }
              }, {
                key: "_swap",
                value: function(c, v, h) {
                  var d = this._get(c, v);
                  this._set(c, v, this._get(c, h)), this._set(c, h, d);
                }
              }, {
                key: "_defaultCompareFunction",
                value: function(c, v) {
                  return v > c;
                }
              }]), l;
            }();
            t.exports = u;
          },
          /* 25 */
          /***/
          function(t, a, n) {
            var i = function() {
              function u(l, f) {
                for (var c = 0; c < f.length; c++) {
                  var v = f[c];
                  v.enumerable = v.enumerable || !1, v.configurable = !0, "value" in v && (v.writable = !0), Object.defineProperty(l, v.key, v);
                }
              }
              return function(l, f, c) {
                return f && u(l.prototype, f), c && u(l, c), l;
              };
            }();
            function s(u, l) {
              if (!(u instanceof l))
                throw new TypeError("Cannot call a class as a function");
            }
            var o = function() {
              function u(l, f) {
                var c = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1, v = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : -1, h = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
                s(this, u), this.sequence1 = l, this.sequence2 = f, this.match_score = c, this.mismatch_penalty = v, 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 p = 0; p < this.jMax; p++)
                    this.grid[d][p] = 0;
                }
                this.tracebackGrid = new Array(this.iMax);
                for (var g = 0; g < this.iMax; g++) {
                  this.tracebackGrid[g] = new Array(this.jMax);
                  for (var y = 0; y < this.jMax; y++)
                    this.tracebackGrid[g][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 c = 1; c < this.iMax; c++)
                    this.grid[c][0] = this.grid[c - 1][0] + this.gap_penalty, this.tracebackGrid[c][0] = [!1, !0, !1];
                  for (var v = 1; v < this.iMax; v++)
                    for (var h = 1; h < this.jMax; h++) {
                      var d = void 0;
                      this.sequence1[v - 1] === this.sequence2[h - 1] ? d = this.grid[v - 1][h - 1] + this.match_score : d = this.grid[v - 1][h - 1] + this.mismatch_penalty;
                      var p = this.grid[v - 1][h] + this.gap_penalty, g = this.grid[v][h - 1] + this.gap_penalty, y = [d, p, g], b = this.arrayAllMaxIndexes(y);
                      this.grid[v][h] = y[b[0]], this.tracebackGrid[v][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 c = f[0], v = this.tracebackGrid[c.pos[0]][c.pos[1]];
                    v[0] && f.push({
                      pos: [c.pos[0] - 1, c.pos[1] - 1],
                      seq1: this.sequence1[c.pos[0] - 1] + c.seq1,
                      seq2: this.sequence2[c.pos[1] - 1] + c.seq2
                    }), v[1] && f.push({
                      pos: [c.pos[0] - 1, c.pos[1]],
                      seq1: this.sequence1[c.pos[0] - 1] + c.seq1,
                      seq2: "-" + c.seq2
                    }), v[2] && f.push({
                      pos: [c.pos[0], c.pos[1] - 1],
                      seq1: "-" + c.seq1,
                      seq2: this.sequence2[c.pos[1] - 1] + c.seq2
                    }), c.pos[0] === 0 && c.pos[1] === 0 && this.alignments.push({
                      sequence1: c.seq1,
                      sequence2: c.seq2
                    }), f.shift();
                  }
                  return this.alignments;
                }
                // Helper Functions
              }, {
                key: "getAllIndexes",
                value: function(f, c) {
                  for (var v = [], h = -1; (h = f.indexOf(c, h + 1)) !== -1; )
                    v.push(h);
                  return v;
                }
              }, {
                key: "arrayAllMaxIndexes",
                value: function(f) {
                  return this.getAllIndexes(f, Math.max.apply(null, f));
                }
              }]), u;
            }();
            t.exports = o;
          },
          /* 26 */
          /***/
          function(t, 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), t.exports = i;
          },
          /* 27 */
          /***/
          function(t, a, n) {
            function i() {
              this.listeners = [];
            }
            var s = i.prototype;
            s.addListener = function(o, u) {
              this.listeners.push({
                event: o,
                callback: u
              });
            }, s.removeListener = function(o, u) {
              for (var l = this.listeners.length; l >= 0; l--) {
                var f = this.listeners[l];
                f.event === o && f.callback === u && this.listeners.splice(l, 1);
              }
            }, s.emit = function(o, u) {
              for (var l = 0; l < this.listeners.length; l++) {
                var f = this.listeners[l];
                o === f.event && f.callback(u);
              }
            }, t.exports = i;
          }
          /******/
        ])
      );
    });
  }(Ms)), Ms.exports;
}
var nf;
function Hm() {
  return nf || (nf = 1, function(r, e) {
    (function(a, n) {
      r.exports = n(qm());
    })(js, function(t) {
      return (
        /******/
        function(a) {
          var n = {};
          function i(s) {
            if (n[s])
              return n[s].exports;
            var o = n[s] = {
              /******/
              i: s,
              /******/
              l: !1,
              /******/
              exports: {}
              /******/
            };
            return a[s].call(o.exports, o, o.exports, i), o.l = !0, o.exports;
          }
          return i.m = a, i.c = n, i.i = function(s) {
            return s;
          }, i.d = function(s, o, u) {
            i.o(s, o) || Object.defineProperty(s, o, {
              /******/
              configurable: !1,
              /******/
              enumerable: !0,
              /******/
              get: u
              /******/
            });
          }, i.n = function(s) {
            var o = s && s.__esModule ? (
              /******/
              function() {
                return s.default;
              }
            ) : (
              /******/
              function() {
                return s;
              }
            );
            return i.d(o, "a", o), o;
          }, i.o = function(s, o) {
            return Object.prototype.hasOwnProperty.call(s, o);
          }, i.p = "", i(i.s = 7);
        }([
          /* 0 */
          /***/
          function(a, n) {
            a.exports = t;
          },
          /* 1 */
          /***/
          function(a, n, i) {
            var s = i(0).FDLayoutConstants;
            function o() {
            }
            for (var u in s)
              o[u] = s[u];
            o.DEFAULT_USE_MULTI_LEVEL_SCALING = !1, o.DEFAULT_RADIAL_SEPARATION = s.DEFAULT_EDGE_LENGTH, o.DEFAULT_COMPONENT_SEPERATION = 60, o.TILE = !0, o.TILING_PADDING_VERTICAL = 10, o.TILING_PADDING_HORIZONTAL = 10, o.TREE_REDUCTION_ON_INCREMENTAL = !1, a.exports = o;
          },
          /* 2 */
          /***/
          function(a, n, i) {
            var s = i(0).FDLayoutEdge;
            function o(l, f, c) {
              s.call(this, l, f, c);
            }
            o.prototype = Object.create(s.prototype);
            for (var u in s)
              o[u] = s[u];
            a.exports = o;
          },
          /* 3 */
          /***/
          function(a, n, i) {
            var s = i(0).LGraph;
            function o(l, f, c) {
              s.call(this, l, f, c);
            }
            o.prototype = Object.create(s.prototype);
            for (var u in s)
              o[u] = s[u];
            a.exports = o;
          },
          /* 4 */
          /***/
          function(a, n, i) {
            var s = i(0).LGraphManager;
            function o(l) {
              s.call(this, l);
            }
            o.prototype = Object.create(s.prototype);
            for (var u in s)
              o[u] = s[u];
            a.exports = o;
          },
          /* 5 */
          /***/
          function(a, n, i) {
            var s = i(0).FDLayoutNode, o = i(0).IMath;
            function u(f, c, v, h) {
              s.call(this, f, c, v, h);
            }
            u.prototype = Object.create(s.prototype);
            for (var l in s)
              u[l] = s[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 * o.sign(this.displacementX)), Math.abs(this.displacementY) > f.coolingFactor * f.maxNodeDisplacement && (this.displacementY = f.coolingFactor * f.maxNodeDisplacement * o.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, c) {
              for (var v = this.getChild().getNodes(), h, d = 0; d < v.length; d++)
                h = v[d], h.getChild() == null ? (h.moveBy(f, c), h.displacementX += f, h.displacementY += c) : h.propogateDisplacementToChildren(f, c);
            }, 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 s = i(0).FDLayout, o = i(4), u = i(3), l = i(5), f = i(2), c = i(1), v = i(0).FDLayoutConstants, h = i(0).LayoutConstants, d = i(0).Point, p = i(0).PointD, g = i(0).Layout, y = i(0).Integer, b = i(0).IGeometry, m = i(0).LGraph, E = i(0).Transform;
            function x() {
              s.call(this), this.toBeTiled = {};
            }
            x.prototype = Object.create(s.prototype);
            for (var S in s)
              x[S] = s[S];
            x.prototype.newGraphManager = function() {
              var w = new o(this);
              return this.graphManager = w, w;
            }, x.prototype.newGraph = function(w) {
              return new u(null, this.graphManager, w);
            }, x.prototype.newNode = function(w) {
              return new l(this.graphManager, w);
            }, x.prototype.newEdge = function(w) {
              return new f(null, null, w);
            }, x.prototype.initParameters = function() {
              s.prototype.initParameters.call(this, arguments), this.isSubLayout || (c.DEFAULT_EDGE_LENGTH < 10 ? this.idealEdgeLength = 10 : this.idealEdgeLength = c.DEFAULT_EDGE_LENGTH, this.useSmartIdealEdgeLengthCalculation = c.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.springConstant = v.DEFAULT_SPRING_STRENGTH, this.repulsionConstant = v.DEFAULT_REPULSION_STRENGTH, this.gravityConstant = v.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = v.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = v.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = v.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 / v.CONVERGENCE_CHECK_PERIOD, this.finalTemperature = v.CONVERGENCE_CHECK_PERIOD / this.maxIterations, this.coolingAdjuster = 1);
            }, x.prototype.layout = function() {
              var w = h.DEFAULT_CREATE_BENDS_AS_NEEDED;
              return w && (this.createBendpoints(), this.graphManager.resetAllEdges()), this.level = 0, this.classicLayout();
            }, x.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 (c.TREE_REDUCTION_ON_INCREMENTAL) {
                  this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
                  var T = new Set(this.getAllNodes()), C = this.nodesWithGravity.filter(function(L) {
                    return T.has(L);
                  });
                  this.graphManager.setAllNodesToApplyGravitation(C);
                }
              } else {
                var w = this.getFlatForest();
                if (w.length > 0)
                  this.positionNodesRadially(w);
                else {
                  this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
                  var T = new Set(this.getAllNodes()), C = this.nodesWithGravity.filter(function(D) {
                    return T.has(D);
                  });
                  this.graphManager.setAllNodesToApplyGravitation(C), this.positionNodesRandomly();
                }
              }
              return this.initSpringEmbedder(), this.runSpringEmbedder(), !0;
            }, x.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 % v.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()), T = this.nodesWithGravity.filter(function(A) {
                      return w.has(A);
                    });
                    this.graphManager.setAllNodesToApplyGravitation(T), this.graphManager.updateBounds(), this.updateGrid(), this.coolingFactor = v.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 = v.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100), this.afterGrowthIterations++;
              }
              var C = !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(C, D), this.calcGravitationalForces(), this.moveNodes(), this.animate(), !1;
            }, x.prototype.getPositionsData = function() {
              for (var w = this.graphManager.getAllNodes(), T = {}, C = 0; C < w.length; C++) {
                var D = w[C].rect, A = w[C].id;
                T[A] = {
                  id: A,
                  x: D.getCenterX(),
                  y: D.getCenterY(),
                  w: D.width,
                  h: D.height
                };
              }
              return T;
            }, x.prototype.runSpringEmbedder = function() {
              this.initialAnimationPeriod = 25, this.animationPeriod = this.initialAnimationPeriod;
              var w = !1;
              if (v.ANIMATE === "during")
                this.emit("layoutstarted");
              else {
                for (; !w; )
                  w = this.tick();
                this.graphManager.updateBounds();
              }
            }, x.prototype.calculateNodesToApplyGravitationTo = function() {
              var w = [], T, C = this.graphManager.getGraphs(), D = C.length, A;
              for (A = 0; A < D; A++)
                T = C[A], T.updateConnected(), T.isConnected || (w = w.concat(T.getNodes()));
              return w;
            }, x.prototype.createBendpoints = function() {
              var w = [];
              w = w.concat(this.graphManager.getAllEdges());
              var T = /* @__PURE__ */ new Set(), C;
              for (C = 0; C < w.length; C++) {
                var D = w[C];
                if (!T.has(D)) {
                  var A = D.getSource(), L = D.getTarget();
                  if (A == L)
                    D.getBendpoints().push(new p()), D.getBendpoints().push(new p()), this.createDummyNodesForBendpoints(D), T.add(D);
                  else {
                    var R = [];
                    if (R = R.concat(A.getEdgeListToNode(L)), R = R.concat(L.getEdgeListToNode(A)), !T.has(R[0])) {
                      if (R.length > 1) {
                        var I;
                        for (I = 0; I < R.length; I++) {
                          var O = R[I];
                          O.getBendpoints().push(new p()), this.createDummyNodesForBendpoints(O);
                        }
                      }
                      R.forEach(function(N) {
                        T.add(N);
                      });
                    }
                  }
                }
                if (T.size == w.length)
                  break;
              }
            }, x.prototype.positionNodesRadially = function(w) {
              for (var T = new d(0, 0), C = Math.ceil(Math.sqrt(w.length)), D = 0, A = 0, L = 0, R = new p(0, 0), I = 0; I < w.length; I++) {
                I % C == 0 && (L = 0, A = D, I != 0 && (A += c.DEFAULT_COMPONENT_SEPERATION), D = 0);
                var O = w[I], N = g.findCenterOfTree(O);
                T.x = L, T.y = A, R = x.radialLayout(O, N, T), R.y > D && (D = Math.floor(R.y)), L = Math.floor(R.x + c.DEFAULT_COMPONENT_SEPERATION);
              }
              this.transform(new p(h.WORLD_CENTER_X - R.x / 2, h.WORLD_CENTER_Y - R.y / 2));
            }, x.radialLayout = function(w, T, C) {
              var D = Math.max(this.maxDiagonalInTree(w), c.DEFAULT_RADIAL_SEPARATION);
              x.branchRadialLayout(T, null, 0, 359, 0, D);
              var A = m.calculateBounds(w), L = new E();
              L.setDeviceOrgX(A.getMinX()), L.setDeviceOrgY(A.getMinY()), L.setWorldOrgX(C.x), L.setWorldOrgY(C.y);
              for (var R = 0; R < w.length; R++) {
                var I = w[R];
                I.transform(L);
              }
              var O = new p(A.getMaxX(), A.getMaxY());
              return L.inverseTransformPoint(O);
            }, x.branchRadialLayout = function(w, T, C, D, A, L) {
              var R = (D - C + 1) / 2;
              R < 0 && (R += 180);
              var I = (R + C) % 360, O = I * b.TWO_PI / 360, N = A * Math.cos(O), k = A * Math.sin(O);
              w.setCenter(N, k);
              var P = [];
              P = P.concat(w.getEdges());
              var B = P.length;
              T != null && B--;
              for (var _ = 0, F = P.length, G, U = w.getEdgesBetween(T); U.length > 1; ) {
                var H = U[0];
                U.splice(0, 1);
                var $ = P.indexOf(H);
                $ >= 0 && P.splice($, 1), F--, B--;
              }
              T != null ? G = (P.indexOf(U[0]) + 1) % F : G = 0;
              for (var X = Math.abs(D - C) / B, Q = G; _ != B; Q = ++Q % F) {
                var re = P[Q].getOtherEnd(w);
                if (re != T) {
                  var J = (C + _ * X) % 360, z = (J + X) % 360;
                  x.branchRadialLayout(re, w, J, z, A + L, L), _++;
                }
              }
            }, x.maxDiagonalInTree = function(w) {
              for (var T = y.MIN_VALUE, C = 0; C < w.length; C++) {
                var D = w[C], A = D.getDiagonal();
                A > T && (T = A);
              }
              return T;
            }, x.prototype.calcRepulsionRange = function() {
              return 2 * (this.level + 1) * this.idealEdgeLength;
            }, x.prototype.groupZeroDegreeMembers = function() {
              var w = this, T = {};
              this.memberGroups = {}, this.idToDummyNode = {};
              for (var C = [], 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)) && C.push(L);
              }
              for (var A = 0; A < C.length; A++) {
                var L = C[A], I = L.getParent().id;
                typeof T[I] > "u" && (T[I] = []), T[I] = T[I].concat(L);
              }
              Object.keys(T).forEach(function(O) {
                if (T[O].length > 1) {
                  var N = "DummyCompound_" + O;
                  w.memberGroups[N] = T[O];
                  var k = T[O][0].getParent(), P = new l(w.graphManager);
                  P.id = N, P.paddingLeft = k.paddingLeft || 0, P.paddingRight = k.paddingRight || 0, P.paddingBottom = k.paddingBottom || 0, P.paddingTop = k.paddingTop || 0, w.idToDummyNode[N] = P;
                  var B = w.getGraphManager().add(w.newGraph(), P), _ = k.getChild();
                  _.add(P);
                  for (var F = 0; F < T[O].length; F++) {
                    var G = T[O][F];
                    _.remove(G), B.add(G);
                  }
                }
              });
            }, x.prototype.clearCompounds = function() {
              var w = {}, T = {};
              this.performDFSOnCompounds();
              for (var C = 0; C < this.compoundOrder.length; C++)
                T[this.compoundOrder[C].id] = this.compoundOrder[C], w[this.compoundOrder[C].id] = [].concat(this.compoundOrder[C].getChild().getNodes()), this.graphManager.remove(this.compoundOrder[C].getChild()), this.compoundOrder[C].child = null;
              this.graphManager.resetAllNodes(), this.tileCompoundMembers(w, T);
            }, x.prototype.clearZeroDegreeMembers = function() {
              var w = this, T = this.tiledZeroDegreePack = [];
              Object.keys(this.memberGroups).forEach(function(C) {
                var D = w.idToDummyNode[C];
                T[C] = w.tileNodes(w.memberGroups[C], D.paddingLeft + D.paddingRight), D.rect.width = T[C].width, D.rect.height = T[C].height;
              });
            }, x.prototype.repopulateCompounds = function() {
              for (var w = this.compoundOrder.length - 1; w >= 0; w--) {
                var T = this.compoundOrder[w], C = T.id, D = T.paddingLeft, A = T.paddingTop;
                this.adjustLocations(this.tiledMemberPack[C], T.rect.x, T.rect.y, D, A);
              }
            }, x.prototype.repopulateZeroDegreeMembers = function() {
              var w = this, T = this.tiledZeroDegreePack;
              Object.keys(T).forEach(function(C) {
                var D = w.idToDummyNode[C], A = D.paddingLeft, L = D.paddingTop;
                w.adjustLocations(T[C], D.rect.x, D.rect.y, A, L);
              });
            }, x.prototype.getToBeTiled = function(w) {
              var T = w.id;
              if (this.toBeTiled[T] != null)
                return this.toBeTiled[T];
              var C = w.getChild();
              if (C == null)
                return this.toBeTiled[T] = !1, !1;
              for (var D = C.getNodes(), A = 0; A < D.length; A++) {
                var L = D[A];
                if (this.getNodeDegree(L) > 0)
                  return this.toBeTiled[T] = !1, !1;
                if (L.getChild() == null) {
                  this.toBeTiled[L.id] = !1;
                  continue;
                }
                if (!this.getToBeTiled(L))
                  return this.toBeTiled[T] = !1, !1;
              }
              return this.toBeTiled[T] = !0, !0;
            }, x.prototype.getNodeDegree = function(w) {
              w.id;
              for (var T = w.getEdges(), C = 0, D = 0; D < T.length; D++) {
                var A = T[D];
                A.getSource().id !== A.getTarget().id && (C = C + 1);
              }
              return C;
            }, x.prototype.getNodeDegreeWithChildren = function(w) {
              var T = this.getNodeDegree(w);
              if (w.getChild() == null)
                return T;
              for (var C = w.getChild().getNodes(), D = 0; D < C.length; D++) {
                var A = C[D];
                T += this.getNodeDegreeWithChildren(A);
              }
              return T;
            }, x.prototype.performDFSOnCompounds = function() {
              this.compoundOrder = [], this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
            }, x.prototype.fillCompexOrderByDFS = function(w) {
              for (var T = 0; T < w.length; T++) {
                var C = w[T];
                C.getChild() != null && this.fillCompexOrderByDFS(C.getChild().getNodes()), this.getToBeTiled(C) && this.compoundOrder.push(C);
              }
            }, x.prototype.adjustLocations = function(w, T, C, D, A) {
              T += D, C += A;
              for (var L = T, R = 0; R < w.rows.length; R++) {
                var I = w.rows[R];
                T = L;
                for (var O = 0, N = 0; N < I.length; N++) {
                  var k = I[N];
                  k.rect.x = T, k.rect.y = C, T += k.rect.width + w.horizontalPadding, k.rect.height > O && (O = k.rect.height);
                }
                C += O + w.verticalPadding;
              }
            }, x.prototype.tileCompoundMembers = function(w, T) {
              var C = this;
              this.tiledMemberPack = [], Object.keys(w).forEach(function(D) {
                var A = T[D];
                C.tiledMemberPack[D] = C.tileNodes(w[D], A.paddingLeft + A.paddingRight), A.rect.width = C.tiledMemberPack[D].width, A.rect.height = C.tiledMemberPack[D].height;
              });
            }, x.prototype.tileNodes = function(w, T) {
              var C = c.TILING_PADDING_VERTICAL, D = c.TILING_PADDING_HORIZONTAL, A = {
                rows: [],
                rowWidth: [],
                rowHeight: [],
                width: 0,
                height: T,
                // assume minHeight equals to minWidth
                verticalPadding: C,
                horizontalPadding: D
              };
              w.sort(function(I, O) {
                return I.rect.width * I.rect.height > O.rect.width * O.rect.height ? -1 : I.rect.width * I.rect.height < O.rect.width * O.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, T) : this.canAddHorizontal(A, R.rect.width, R.rect.height) ? this.insertNodeToRow(A, R, this.getShortestRowIndex(A), T) : this.insertNodeToRow(A, R, A.rows.length, T), this.shiftToLastRow(A);
              }
              return A;
            }, x.prototype.insertNodeToRow = function(w, T, C, D) {
              var A = D;
              if (C == w.rows.length) {
                var L = [];
                w.rows.push(L), w.rowWidth.push(A), w.rowHeight.push(0);
              }
              var R = w.rowWidth[C] + T.rect.width;
              w.rows[C].length > 0 && (R += w.horizontalPadding), w.rowWidth[C] = R, w.width < R && (w.width = R);
              var I = T.rect.height;
              C > 0 && (I += w.verticalPadding);
              var O = 0;
              I > w.rowHeight[C] && (O = w.rowHeight[C], w.rowHeight[C] = I, O = w.rowHeight[C] - O), w.height += O, w.rows[C].push(T);
            }, x.prototype.getShortestRowIndex = function(w) {
              for (var T = -1, C = Number.MAX_VALUE, D = 0; D < w.rows.length; D++)
                w.rowWidth[D] < C && (T = D, C = w.rowWidth[D]);
              return T;
            }, x.prototype.getLongestRowIndex = function(w) {
              for (var T = -1, C = Number.MIN_VALUE, D = 0; D < w.rows.length; D++)
                w.rowWidth[D] > C && (T = D, C = w.rowWidth[D]);
              return T;
            }, x.prototype.canAddHorizontal = function(w, T, C) {
              var D = this.getShortestRowIndex(w);
              if (D < 0)
                return !0;
              var A = w.rowWidth[D];
              if (A + w.horizontalPadding + T <= w.width)
                return !0;
              var L = 0;
              w.rowHeight[D] < C && D > 0 && (L = C + w.verticalPadding - w.rowHeight[D]);
              var R;
              w.width - A >= T + w.horizontalPadding ? R = (w.height + L) / (A + T + w.horizontalPadding) : R = (w.height + L) / w.width, L = C + w.verticalPadding;
              var I;
              return w.width < T ? I = (w.height + L) / T : I = (w.height + L) / w.width, I < 1 && (I = 1 / I), R < 1 && (R = 1 / R), R < I;
            }, x.prototype.shiftToLastRow = function(w) {
              var T = this.getLongestRowIndex(w), C = w.rowWidth.length - 1, D = w.rows[T], A = D[D.length - 1], L = A.width + w.horizontalPadding;
              if (w.width - w.rowWidth[C] > L && T != C) {
                D.splice(-1, 1), w.rows[C].push(A), w.rowWidth[T] = w.rowWidth[T] - L, w.rowWidth[C] = w.rowWidth[C] + L, w.width = w.rowWidth[instance.getLongestRowIndex(w)];
                for (var R = Number.MIN_VALUE, I = 0; I < D.length; I++)
                  D[I].height > R && (R = D[I].height);
                T > 0 && (R += w.verticalPadding);
                var O = w.rowHeight[T] + w.rowHeight[C];
                w.rowHeight[T] = R, w.rowHeight[C] < A.height + w.verticalPadding && (w.rowHeight[C] = A.height + w.verticalPadding);
                var N = w.rowHeight[T] + w.rowHeight[C];
                w.height += N - O, this.shiftToLastRow(w);
              }
            }, x.prototype.tilingPreLayout = function() {
              c.TILE && (this.groupZeroDegreeMembers(), this.clearCompounds(), this.clearZeroDegreeMembers());
            }, x.prototype.tilingPostLayout = function() {
              c.TILE && (this.repopulateZeroDegreeMembers(), this.repopulateCompounds());
            }, x.prototype.reduceTrees = function() {
              for (var w = [], T = !0, C; T; ) {
                var D = this.graphManager.getAllNodes(), A = [];
                T = !1;
                for (var L = 0; L < D.length; L++)
                  C = D[L], C.getEdges().length == 1 && !C.getEdges()[0].isInterGraph && C.getChild() == null && (A.push([C, C.getEdges()[0], C.getOwner()]), T = !0);
                if (T == !0) {
                  for (var R = [], I = 0; I < A.length; I++)
                    A[I][0].getEdges().length == 1 && (R.push(A[I]), A[I][0].getOwner().remove(A[I][0]));
                  w.push(R), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
                }
              }
              this.prunedNodesAll = w;
            }, x.prototype.growTree = function(w) {
              for (var T = w.length, C = w[T - 1], D, A = 0; A < C.length; A++)
                D = C[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();
            }, x.prototype.findPlaceforPrunedNode = function(w) {
              var T, C, D = w[0];
              D == w[1].source ? C = w[1].target : C = w[1].source;
              var A = C.startX, L = C.finishX, R = C.startY, I = C.finishY, O = 0, N = 0, k = 0, P = 0, B = [O, k, N, P];
              if (R > 0)
                for (var _ = A; _ <= L; _++)
                  B[0] += this.grid[_][R - 1].length + this.grid[_][R].length - 1;
              if (L < this.grid.length - 1)
                for (var _ = R; _ <= I; _++)
                  B[1] += this.grid[L + 1][_].length + this.grid[L][_].length - 1;
              if (I < this.grid[0].length - 1)
                for (var _ = A; _ <= L; _++)
                  B[2] += this.grid[_][I + 1].length + this.grid[_][I].length - 1;
              if (A > 0)
                for (var _ = R; _ <= I; _++)
                  B[3] += this.grid[A - 1][_].length + this.grid[A][_].length - 1;
              for (var F = y.MAX_VALUE, G, U, H = 0; H < B.length; H++)
                B[H] < F ? (F = B[H], G = 1, U = H) : B[H] == F && G++;
              if (G == 3 && F == 0)
                B[0] == 0 && B[1] == 0 && B[2] == 0 ? T = 1 : B[0] == 0 && B[1] == 0 && B[3] == 0 ? T = 0 : B[0] == 0 && B[2] == 0 && B[3] == 0 ? T = 3 : B[1] == 0 && B[2] == 0 && B[3] == 0 && (T = 2);
              else if (G == 2 && F == 0) {
                var $ = Math.floor(Math.random() * 2);
                B[0] == 0 && B[1] == 0 ? $ == 0 ? T = 0 : T = 1 : B[0] == 0 && B[2] == 0 ? $ == 0 ? T = 0 : T = 2 : B[0] == 0 && B[3] == 0 ? $ == 0 ? T = 0 : T = 3 : B[1] == 0 && B[2] == 0 ? $ == 0 ? T = 1 : T = 2 : B[1] == 0 && B[3] == 0 ? $ == 0 ? T = 1 : T = 3 : $ == 0 ? T = 2 : T = 3;
              } else if (G == 4 && F == 0) {
                var $ = Math.floor(Math.random() * 4);
                T = $;
              } else
                T = U;
              T == 0 ? D.setCenter(C.getCenterX(), C.getCenterY() - C.getHeight() / 2 - v.DEFAULT_EDGE_LENGTH - D.getHeight() / 2) : T == 1 ? D.setCenter(C.getCenterX() + C.getWidth() / 2 + v.DEFAULT_EDGE_LENGTH + D.getWidth() / 2, C.getCenterY()) : T == 2 ? D.setCenter(C.getCenterX(), C.getCenterY() + C.getHeight() / 2 + v.DEFAULT_EDGE_LENGTH + D.getHeight() / 2) : D.setCenter(C.getCenterX() - C.getWidth() / 2 - v.DEFAULT_EDGE_LENGTH - D.getWidth() / 2, C.getCenterY());
            }, a.exports = x;
          },
          /* 7 */
          /***/
          function(a, n, i) {
            var s = {};
            s.layoutBase = i(0), s.CoSEConstants = i(1), s.CoSEEdge = i(2), s.CoSEGraph = i(3), s.CoSEGraphManager = i(4), s.CoSELayout = i(6), s.CoSENode = i(5), a.exports = s;
          }
          /******/
        ])
      );
    });
  }(Is)), Is.exports;
}
(function(r, e) {
  (function(a, n) {
    r.exports = n(Hm());
  })(js, function(t) {
    return (
      /******/
      function(a) {
        var n = {};
        function i(s) {
          if (n[s])
            return n[s].exports;
          var o = n[s] = {
            /******/
            i: s,
            /******/
            l: !1,
            /******/
            exports: {}
            /******/
          };
          return a[s].call(o.exports, o, o.exports, i), o.l = !0, o.exports;
        }
        return i.m = a, i.c = n, i.i = function(s) {
          return s;
        }, i.d = function(s, o, u) {
          i.o(s, o) || Object.defineProperty(s, o, {
            /******/
            configurable: !1,
            /******/
            enumerable: !0,
            /******/
            get: u
            /******/
          });
        }, i.n = function(s) {
          var o = s && s.__esModule ? (
            /******/
            function() {
              return s.default;
            }
          ) : (
            /******/
            function() {
              return s;
            }
          );
          return i.d(o, "a", o), o;
        }, i.o = function(s, o) {
          return Object.prototype.hasOwnProperty.call(s, o);
        }, i.p = "", i(i.s = 1);
      }([
        /* 0 */
        /***/
        function(a, n) {
          a.exports = t;
        },
        /* 1 */
        /***/
        function(a, n, i) {
          var s = i(0).layoutBase.LayoutConstants, o = i(0).layoutBase.FDLayoutConstants, u = i(0).CoSEConstants, l = i(0).CoSELayout, f = i(0).CoSENode, c = i(0).layoutBase.PointD, v = 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 x in b)
              E[x] = b[x];
            for (var x in m)
              E[x] = m[x];
            return E;
          }
          function p(b) {
            this.options = d(h, b), g(this.options);
          }
          var g = function(m) {
            m.nodeRepulsion != null && (u.DEFAULT_REPULSION_STRENGTH = o.DEFAULT_REPULSION_STRENGTH = m.nodeRepulsion), m.idealEdgeLength != null && (u.DEFAULT_EDGE_LENGTH = o.DEFAULT_EDGE_LENGTH = m.idealEdgeLength), m.edgeElasticity != null && (u.DEFAULT_SPRING_STRENGTH = o.DEFAULT_SPRING_STRENGTH = m.edgeElasticity), m.nestingFactor != null && (u.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = o.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = m.nestingFactor), m.gravity != null && (u.DEFAULT_GRAVITY_STRENGTH = o.DEFAULT_GRAVITY_STRENGTH = m.gravity), m.numIter != null && (u.MAX_ITERATIONS = o.MAX_ITERATIONS = m.numIter), m.gravityRange != null && (u.DEFAULT_GRAVITY_RANGE_FACTOR = o.DEFAULT_GRAVITY_RANGE_FACTOR = m.gravityRange), m.gravityCompound != null && (u.DEFAULT_COMPOUND_GRAVITY_STRENGTH = o.DEFAULT_COMPOUND_GRAVITY_STRENGTH = m.gravityCompound), m.gravityRangeCompound != null && (u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = o.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = m.gravityRangeCompound), m.initialEnergyOnIncremental != null && (u.DEFAULT_COOLING_FACTOR_INCREMENTAL = o.DEFAULT_COOLING_FACTOR_INCREMENTAL = m.initialEnergyOnIncremental), m.quality == "draft" ? s.QUALITY = 0 : m.quality == "proof" ? s.QUALITY = 2 : s.QUALITY = 1, u.NODE_DIMENSIONS_INCLUDE_LABELS = o.NODE_DIMENSIONS_INCLUDE_LABELS = s.NODE_DIMENSIONS_INCLUDE_LABELS = m.nodeDimensionsIncludeLabels, u.DEFAULT_INCREMENTAL = o.DEFAULT_INCREMENTAL = s.DEFAULT_INCREMENTAL = !m.randomize, u.ANIMATE = o.ANIMATE = s.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;
          };
          p.prototype.run = function() {
            var b, m, E = this.options;
            this.idToLNode = {};
            var x = this.layout = new l(), S = this;
            S.stopped = !1, this.cy = this.options.cy, this.cy.trigger({ type: "layoutstart", layout: this });
            var w = x.newGraphManager();
            this.gm = w;
            var T = this.options.eles.nodes(), C = this.options.eles.edges();
            this.root = w.addRoot(), this.processChildrenList(this.root, this.getTopMostNodes(T), x);
            for (var D = 0; D < C.length; D++) {
              var A = C[D], L = this.idToLNode[A.data("source")], R = this.idToLNode[A.data("target")];
              if (L !== R && L.getEdgesBetween(R).length == 0) {
                var I = w.add(x.newEdge(), L, R);
                I.id = A.id();
              }
            }
            var O = function(P, B) {
              typeof P == "number" && (P = B);
              var _ = P.data("id"), F = S.idToLNode[_];
              return {
                x: F.getRect().getCenterX(),
                y: F.getRect().getCenterY()
              };
            }, N = function k() {
              for (var P = 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 }));
              }, B = S.options.refresh, _, F = 0; F < B && !_; F++)
                _ = S.stopped || S.layout.tick();
              if (_) {
                x.checkLayoutSuccess() && !x.isSubLayout && x.doPostLayout(), x.tilingPostLayout && x.tilingPostLayout(), x.isLayoutFinished = !0, S.options.eles.nodes().positions(O), P(), S.cy.one("layoutstop", S.options.stop), S.cy.trigger({ type: "layoutstop", layout: S }), m && cancelAnimationFrame(m), b = !1;
                return;
              }
              var G = S.layout.getPositionsData();
              E.eles.nodes().positions(function(U, H) {
                if (typeof U == "number" && (U = H), !U.isParent()) {
                  for (var $ = U.id(), X = G[$], Q = U; X == null && (X = G[Q.data("parent")] || G["DummyCompound_" + Q.data("parent")], G[$] = X, Q = Q.parent()[0], Q != null); )
                    ;
                  return X != null ? {
                    x: X.x,
                    y: X.y
                  } : {
                    x: U.position("x"),
                    y: U.position("y")
                  };
                }
              }), P(), m = requestAnimationFrame(k);
            };
            return x.addListener("layoutstarted", function() {
              S.options.animate === "during" && (m = requestAnimationFrame(N));
            }), x.runLayout(), this.options.animate !== "during" && (S.options.eles.nodes().not(":parent").layoutPositions(S, S.options, O), b = !1), this;
          }, p.prototype.getTopMostNodes = function(b) {
            for (var m = {}, E = 0; E < b.length; E++)
              m[b[E].id()] = !0;
            var x = b.filter(function(S, w) {
              typeof S == "number" && (S = w);
              for (var T = S.parent()[0]; T != null; ) {
                if (m[T.id()])
                  return !1;
                T = T.parent()[0];
              }
              return !0;
            });
            return x;
          }, p.prototype.processChildrenList = function(b, m, E) {
            for (var x = m.length, S = 0; S < x; S++) {
              var w = m[S], T = w.children(), C, D = w.layoutDimensions({
                nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels
              });
              if (w.outerWidth() != null && w.outerHeight() != null ? C = b.add(new f(E.graphManager, new c(w.position("x") - D.w / 2, w.position("y") - D.h / 2), new v(parseFloat(D.w), parseFloat(D.h)))) : C = b.add(new f(this.graphManager)), C.id = w.data("id"), C.paddingLeft = parseInt(w.css("padding")), C.paddingTop = parseInt(w.css("padding")), C.paddingRight = parseInt(w.css("padding")), C.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");
                C.labelWidth = A, C.labelHeight = L, C.labelPos = R;
              }
              if (this.idToLNode[w.data("id")] = C, isNaN(C.rect.x) && (C.rect.x = 0), isNaN(C.rect.y) && (C.rect.y = 0), T != null && T.length > 0) {
                var I;
                I = E.getGraphManager().add(E.newGraph(), C), this.processChildrenList(I, T, E);
              }
            }
          }, p.prototype.stop = function() {
            return this.stopped = !0, this;
          };
          var y = function(m) {
            m("layout", "cose-bilkent", p);
          };
          typeof cytoscape < "u" && y(cytoscape), a.exports = y;
        }
        /******/
      ])
    );
  });
})(Kc);
var Ym = Kc.exports;
const Xm = /* @__PURE__ */ uv(Ym);
var Js = function() {
  var r = function(E, x, S, w) {
    for (S = S || {}, w = E.length; w--; S[E[w]] = x)
      ;
    return S;
  }, e = [1, 4], t = [1, 13], a = [1, 12], n = [1, 15], i = [1, 16], s = [1, 20], o = [1, 19], u = [6, 7, 8], l = [1, 26], f = [1, 24], c = [1, 25], v = [6, 7, 11], h = [1, 6, 13, 15, 16, 19, 22], d = [1, 33], p = [1, 34], g = [1, 6, 7, 11, 13, 15, 16, 19, 22], y = {
    trace: function() {
    },
    yy: {},
    symbols_: { error: 2, start: 3, mindMap: 4, spaceLines: 5, SPACELINE: 6, NL: 7, MINDMAP: 8, document: 9, stop: 10, EOF: 11, statement: 12, SPACELIST: 13, node: 14, ICON: 15, CLASS: 16, nodeWithId: 17, nodeWithoutId: 18, NODE_DSTART: 19, NODE_DESCR: 20, NODE_DEND: 21, NODE_ID: 22, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" },
    productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]],
    performAction: function(x, S, w, T, C, D, A) {
      var L = D.length - 1;
      switch (C) {
        case 6:
        case 7:
          return T;
        case 8:
          T.getLogger().trace("Stop NL ");
          break;
        case 9:
          T.getLogger().trace("Stop EOF ");
          break;
        case 11:
          T.getLogger().trace("Stop NL2 ");
          break;
        case 12:
          T.getLogger().trace("Stop EOF2 ");
          break;
        case 15:
          T.getLogger().info("Node: ", D[L].id), T.addNode(D[L - 1].length, D[L].id, D[L].descr, D[L].type);
          break;
        case 16:
          T.getLogger().trace("Icon: ", D[L]), T.decorateNode({ icon: D[L] });
          break;
        case 17:
        case 21:
          T.decorateNode({ class: D[L] });
          break;
        case 18:
          T.getLogger().trace("SPACELIST");
          break;
        case 19:
          T.getLogger().trace("Node: ", D[L].id), T.addNode(0, D[L].id, D[L].descr, D[L].type);
          break;
        case 20:
          T.decorateNode({ icon: D[L] });
          break;
        case 25:
          T.getLogger().trace("node found ..", D[L - 2]), this.$ = { id: D[L - 1], descr: D[L - 1], type: T.getType(D[L - 2], D[L]) };
          break;
        case 26:
          this.$ = { id: D[L], descr: D[L], type: T.nodeType.DEFAULT };
          break;
        case 27:
          T.getLogger().trace("node found ..", D[L - 3]), this.$ = { id: D[L - 3], descr: D[L - 1], type: T.getType(D[L - 2], D[L]) };
          break;
      }
    },
    table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: e }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: e }, { 6: t, 7: [1, 10], 9: 9, 12: 11, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, r(u, [2, 3]), { 1: [2, 2] }, r(u, [2, 4]), r(u, [2, 5]), { 1: [2, 6], 6: t, 12: 21, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, { 6: t, 9: 22, 12: 11, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, { 6: l, 7: f, 10: 23, 11: c }, r(v, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: s, 22: o }), r(v, [2, 18]), r(v, [2, 19]), r(v, [2, 20]), r(v, [2, 21]), r(v, [2, 23]), r(v, [2, 24]), r(v, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: l, 7: f, 10: 32, 11: c }, { 1: [2, 7], 6: t, 12: 21, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, r(h, [2, 14], { 7: d, 11: p }), r(g, [2, 8]), r(g, [2, 9]), r(g, [2, 10]), r(v, [2, 15]), r(v, [2, 16]), r(v, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, r(h, [2, 13], { 7: d, 11: p }), r(g, [2, 11]), r(g, [2, 12]), { 21: [1, 37] }, r(v, [2, 25]), r(v, [2, 27])],
    defaultActions: { 2: [2, 1], 6: [2, 2] },
    parseError: function(x, S) {
      if (S.recoverable)
        this.trace(x);
      else {
        var w = new Error(x);
        throw w.hash = S, w;
      }
    },
    parse: function(x) {
      var S = this, w = [0], T = [], C = [null], D = [], A = this.table, L = "", R = 0, I = 0, O = 2, N = 1, k = D.slice.call(arguments, 1), P = Object.create(this.lexer), B = { yy: {} };
      for (var _ in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, _) && (B.yy[_] = this.yy[_]);
      P.setInput(x, B.yy), B.yy.lexer = P, B.yy.parser = this, typeof P.yylloc > "u" && (P.yylloc = {});
      var F = P.yylloc;
      D.push(F);
      var G = P.options && P.options.ranges;
      typeof B.yy.parseError == "function" ? this.parseError = B.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function U() {
        var ne;
        return ne = T.pop() || P.lex() || N, typeof ne != "number" && (ne instanceof Array && (T = ne, ne = T.pop()), ne = S.symbols_[ne] || ne), ne;
      }
      for (var H, $, X, Q, re = {}, J, z, V, Y; ; ) {
        if ($ = w[w.length - 1], this.defaultActions[$] ? X = this.defaultActions[$] : ((H === null || typeof H > "u") && (H = U()), X = A[$] && A[$][H]), typeof X > "u" || !X.length || !X[0]) {
          var ee = "";
          Y = [];
          for (J in A[$])
            this.terminals_[J] && J > O && Y.push("'" + this.terminals_[J] + "'");
          P.showPosition ? ee = "Parse error on line " + (R + 1) + `:
` + P.showPosition() + `
Expecting ` + Y.join(", ") + ", got '" + (this.terminals_[H] || H) + "'" : ee = "Parse error on line " + (R + 1) + ": Unexpected " + (H == N ? "end of input" : "'" + (this.terminals_[H] || H) + "'"), this.parseError(ee, {
            text: P.match,
            token: this.terminals_[H] || H,
            line: P.yylineno,
            loc: F,
            expected: Y
          });
        }
        if (X[0] instanceof Array && X.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + $ + ", token: " + H);
        switch (X[0]) {
          case 1:
            w.push(H), C.push(P.yytext), D.push(P.yylloc), w.push(X[1]), H = null, I = P.yyleng, L = P.yytext, R = P.yylineno, F = P.yylloc;
            break;
          case 2:
            if (z = this.productions_[X[1]][1], re.$ = C[C.length - z], re._$ = {
              first_line: D[D.length - (z || 1)].first_line,
              last_line: D[D.length - 1].last_line,
              first_column: D[D.length - (z || 1)].first_column,
              last_column: D[D.length - 1].last_column
            }, G && (re._$.range = [
              D[D.length - (z || 1)].range[0],
              D[D.length - 1].range[1]
            ]), Q = this.performAction.apply(re, [
              L,
              I,
              R,
              B.yy,
              X[1],
              C,
              D
            ].concat(k)), typeof Q < "u")
              return Q;
            z && (w = w.slice(0, -1 * z * 2), C = C.slice(0, -1 * z), D = D.slice(0, -1 * z)), w.push(this.productions_[X[1]][0]), C.push(re.$), D.push(re._$), V = A[w[w.length - 2]][w[w.length - 1]], w.push(V);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }
  }, b = function() {
    var E = {
      EOF: 1,
      parseError: function(S, w) {
        if (this.yy.parser)
          this.yy.parser.parseError(S, w);
        else
          throw new Error(S);
      },
      // resets the lexer, sets new input
      setInput: function(x, S) {
        return this.yy = S || this.yy || {}, this._input = x, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
          first_line: 1,
          first_column: 0,
          last_line: 1,
          last_column: 0
        }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
      },
      // consumes and returns one char from the input
      input: function() {
        var x = this._input[0];
        this.yytext += x, this.yyleng++, this.offset++, this.match += x, this.matched += x;
        var S = x.match(/(?:\r\n?|\n).*/g);
        return S ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), x;
      },
      // unshifts one char (or a string) into the input
      unput: function(x) {
        var S = x.length, w = x.split(/(?:\r\n?|\n)/g);
        this._input = x + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - S), this.offset -= S;
        var T = this.match.split(/(?:\r\n?|\n)/g);
        this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), w.length - 1 && (this.yylineno -= w.length - 1);
        var C = this.yylloc.range;
        return this.yylloc = {
          first_line: this.yylloc.first_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.first_column,
          last_column: w ? (w.length === T.length ? this.yylloc.first_column : 0) + T[T.length - w.length].length - w[0].length : this.yylloc.first_column - S
        }, this.options.ranges && (this.yylloc.range = [C[0], C[0] + this.yyleng - S]), this.yyleng = this.yytext.length, this;
      },
      // When called from action, caches matched text and appends it on next action
      more: function() {
        return this._more = !0, this;
      },
      // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
      reject: function() {
        if (this.options.backtrack_lexer)
          this._backtrack = !0;
        else
          return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
            text: "",
            token: null,
            line: this.yylineno
          });
        return this;
      },
      // retain first n characters of the match
      less: function(x) {
        this.unput(this.match.slice(x));
      },
      // displays already matched input, i.e. for error messages
      pastInput: function() {
        var x = this.matched.substr(0, this.matched.length - this.match.length);
        return (x.length > 20 ? "..." : "") + x.substr(-20).replace(/\n/g, "");
      },
      // displays upcoming input, i.e. for error messages
      upcomingInput: function() {
        var x = this.match;
        return x.length < 20 && (x += this._input.substr(0, 20 - x.length)), (x.substr(0, 20) + (x.length > 20 ? "..." : "")).replace(/\n/g, "");
      },
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: function() {
        var x = this.pastInput(), S = new Array(x.length + 1).join("-");
        return x + this.upcomingInput() + `
` + S + "^";
      },
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: function(x, S) {
        var w, T, C;
        if (this.options.backtrack_lexer && (C = {
          yylineno: this.yylineno,
          yylloc: {
            first_line: this.yylloc.first_line,
            last_line: this.last_line,
            first_column: this.yylloc.first_column,
            last_column: this.yylloc.last_column
          },
          yytext: this.yytext,
          match: this.match,
          matches: this.matches,
          matched: this.matched,
          yyleng: this.yyleng,
          offset: this.offset,
          _more: this._more,
          _input: this._input,
          yy: this.yy,
          conditionStack: this.conditionStack.slice(0),
          done: this.done
        }, this.options.ranges && (C.yylloc.range = this.yylloc.range.slice(0))), T = x[0].match(/(?:\r\n?|\n).*/g), T && (this.yylineno += T.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: T ? T[T.length - 1].length - T[T.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + x[0].length
        }, this.yytext += x[0], this.match += x[0], this.matches = x, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(x[0].length), this.matched += x[0], w = this.performAction.call(this, this.yy, this, S, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), w)
          return w;
        if (this._backtrack) {
          for (var D in C)
            this[D] = C[D];
          return !1;
        }
        return !1;
      },
      // return next match in input
      next: function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var x, S, w, T;
        this._more || (this.yytext = "", this.match = "");
        for (var C = this._currentRules(), D = 0; D < C.length; D++)
          if (w = this._input.match(this.rules[C[D]]), w && (!S || w[0].length > S[0].length)) {
            if (S = w, T = D, this.options.backtrack_lexer) {
              if (x = this.test_match(w, C[D]), x !== !1)
                return x;
              if (this._backtrack) {
                S = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return S ? (x = this.test_match(S, C[T]), x !== !1 ? x : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      },
      // return next match that has a token
      lex: function() {
        var S = this.next();
        return S || this.lex();
      },
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: function(S) {
        this.conditionStack.push(S);
      },
      // pop the previously active lexer condition state off the condition stack
      popState: function() {
        var S = this.conditionStack.length - 1;
        return S > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      },
      // produce the lexer rule set which is active for the currently active lexer condition state
      _currentRules: function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      },
      // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
      topState: function(S) {
        return S = this.conditionStack.length - 1 - Math.abs(S || 0), S >= 0 ? this.conditionStack[S] : "INITIAL";
      },
      // alias for begin(condition)
      pushState: function(S) {
        this.begin(S);
      },
      // return the number of states currently on the stack
      stateStackSize: function() {
        return this.conditionStack.length;
      },
      options: { "case-insensitive": !0 },
      performAction: function(S, w, T, C) {
        switch (T) {
          case 0:
            return S.getLogger().trace("Found comment", w.yytext), 6;
          case 1:
            return 8;
          case 2:
            this.begin("CLASS");
            break;
          case 3:
            return this.popState(), 16;
          case 4:
            this.popState();
            break;
          case 5:
            S.getLogger().trace("Begin icon"), this.begin("ICON");
            break;
          case 6:
            return S.getLogger().trace("SPACELINE"), 6;
          case 7:
            return 7;
          case 8:
            return 15;
          case 9:
            S.getLogger().trace("end icon"), this.popState();
            break;
          case 10:
            return S.getLogger().trace("Exploding node"), this.begin("NODE"), 19;
          case 11:
            return S.getLogger().trace("Cloud"), this.begin("NODE"), 19;
          case 12:
            return S.getLogger().trace("Explosion Bang"), this.begin("NODE"), 19;
          case 13:
            return S.getLogger().trace("Cloud Bang"), this.begin("NODE"), 19;
          case 14:
            return this.begin("NODE"), 19;
          case 15:
            return this.begin("NODE"), 19;
          case 16:
            return this.begin("NODE"), 19;
          case 17:
            return this.begin("NODE"), 19;
          case 18:
            return 13;
          case 19:
            return 22;
          case 20:
            return 11;
          case 21:
            this.begin("NSTR2");
            break;
          case 22:
            return "NODE_DESCR";
          case 23:
            this.popState();
            break;
          case 24:
            S.getLogger().trace("Starting NSTR"), this.begin("NSTR");
            break;
          case 25:
            return S.getLogger().trace("description:", w.yytext), "NODE_DESCR";
          case 26:
            this.popState();
            break;
          case 27:
            return this.popState(), S.getLogger().trace("node end ))"), "NODE_DEND";
          case 28:
            return this.popState(), S.getLogger().trace("node end )"), "NODE_DEND";
          case 29:
            return this.popState(), S.getLogger().trace("node end ...", w.yytext), "NODE_DEND";
          case 30:
            return this.popState(), S.getLogger().trace("node end (("), "NODE_DEND";
          case 31:
            return this.popState(), S.getLogger().trace("node end (-"), "NODE_DEND";
          case 32:
            return this.popState(), S.getLogger().trace("node end (-"), "NODE_DEND";
          case 33:
            return this.popState(), S.getLogger().trace("node end (("), "NODE_DEND";
          case 34:
            return this.popState(), S.getLogger().trace("node end (("), "NODE_DEND";
          case 35:
            return S.getLogger().trace("Long description:", w.yytext), 20;
          case 36:
            return S.getLogger().trace("Long description:", w.yytext), 20;
        }
      },
      rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i],
      conditions: { CLASS: { rules: [3, 4], inclusive: !1 }, ICON: { rules: [8, 9], inclusive: !1 }, NSTR2: { rules: [22, 23], inclusive: !1 }, NSTR: { rules: [25, 26], inclusive: !1 }, NODE: { rules: [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], inclusive: !0 } }
    };
    return E;
  }();
  y.lexer = b;
  function m() {
    this.yy = {};
  }
  return m.prototype = y, y.Parser = m, new m();
}();
Js.parser = Js;
const $m = Js;
let kt = [], Zc = 0, Ao = {};
const Wm = () => {
  kt = [], Zc = 0, Ao = {};
}, Km = function(r) {
  for (let e = kt.length - 1; e >= 0; e--)
    if (kt[e].level < r)
      return kt[e];
  return null;
}, Zm = () => kt.length > 0 ? kt[0] : null, Qm = (r, e, t, a) => {
  var n, i;
  Or.info("addNode", r, e, t, a);
  const s = eo();
  let o = ((n = s.mindmap) == null ? void 0 : n.padding) ?? bn.mindmap.padding;
  switch (a) {
    case et.ROUNDED_RECT:
    case et.RECT:
    case et.HEXAGON:
      o *= 2;
  }
  const u = {
    id: Zc++,
    nodeId: wn(e, s),
    level: r,
    descr: wn(t, s),
    type: a,
    children: [],
    width: ((i = s.mindmap) == null ? void 0 : i.maxNodeWidth) ?? bn.mindmap.maxNodeWidth,
    padding: o
  }, l = Km(r);
  if (l)
    l.children.push(u), kt.push(u);
  else if (kt.length === 0)
    kt.push(u);
  else
    throw new Error(
      'There can be only one root. No parent could be found for ("' + u.descr + '")'
    );
}, et = {
  DEFAULT: 0,
  NO_BORDER: 0,
  ROUNDED_RECT: 1,
  RECT: 2,
  CIRCLE: 3,
  CLOUD: 4,
  BANG: 5,
  HEXAGON: 6
}, Jm = (r, e) => {
  switch (Or.debug("In get type", r, e), r) {
    case "[":
      return et.RECT;
    case "(":
      return e === ")" ? et.ROUNDED_RECT : et.CLOUD;
    case "((":
      return et.CIRCLE;
    case ")":
      return et.CLOUD;
    case "))":
      return et.BANG;
    case "{{":
      return et.HEXAGON;
    default:
      return et.DEFAULT;
  }
}, jm = (r, e) => {
  Ao[r] = e;
}, e0 = (r) => {
  if (!r)
    return;
  const e = eo(), t = kt[kt.length - 1];
  r.icon && (t.icon = wn(r.icon, e)), r.class && (t.class = wn(r.class, e));
}, t0 = (r) => {
  switch (r) {
    case et.DEFAULT:
      return "no-border";
    case et.RECT:
      return "rect";
    case et.ROUNDED_RECT:
      return "rounded-rect";
    case et.CIRCLE:
      return "circle";
    case et.CLOUD:
      return "cloud";
    case et.BANG:
      return "bang";
    case et.HEXAGON:
      return "hexgon";
    default:
      return "no-border";
  }
}, r0 = () => Or, a0 = (r) => Ao[r], n0 = {
  clear: Wm,
  addNode: Qm,
  getMindmap: Zm,
  nodeType: et,
  getType: Jm,
  setElementForId: jm,
  decorateNode: e0,
  type2Str: t0,
  getLogger: r0,
  getElementById: a0
}, i0 = n0, s0 = 12, o0 = function(r, e, t, a) {
  e.append("path").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + r.type2Str(t.type)).attr(
    "d",
    `M0 ${t.height - 5} v${-t.height + 2 * 5} q0,-5 5,-5 h${t.width - 2 * 5} q5,0 5,5 v${t.height - 5} H0 Z`
  ), e.append("line").attr("class", "node-line-" + a).attr("x1", 0).attr("y1", t.height).attr("x2", t.width).attr("y2", t.height);
}, u0 = function(r, e, t) {
  e.append("rect").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + r.type2Str(t.type)).attr("height", t.height).attr("width", t.width);
}, l0 = function(r, e, t) {
  const a = t.width, n = t.height, i = 0.15 * a, s = 0.25 * a, o = 0.35 * a, u = 0.2 * a;
  e.append("path").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + r.type2Str(t.type)).attr(
    "d",
    `M0 0 a${i},${i} 0 0,1 ${a * 0.25},${-1 * a * 0.1}
      a${o},${o} 1 0,1 ${a * 0.4},${-1 * a * 0.1}
      a${s},${s} 1 0,1 ${a * 0.35},${1 * a * 0.2}

      a${i},${i} 1 0,1 ${a * 0.15},${1 * n * 0.35}
      a${u},${u} 1 0,1 ${-1 * a * 0.15},${1 * n * 0.65}

      a${s},${i} 1 0,1 ${-1 * a * 0.25},${a * 0.15}
      a${o},${o} 1 0,1 ${-1 * a * 0.5},0
      a${i},${i} 1 0,1 ${-1 * a * 0.25},${-1 * a * 0.15}

      a${i},${i} 1 0,1 ${-1 * a * 0.1},${-1 * n * 0.35}
      a${u},${u} 1 0,1 ${a * 0.1},${-1 * n * 0.65}

    H0 V0 Z`
  );
}, f0 = function(r, e, t) {
  const a = t.width, n = t.height, i = 0.15 * a;
  e.append("path").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + r.type2Str(t.type)).attr(
    "d",
    `M0 0 a${i},${i} 1 0,0 ${a * 0.25},${-1 * n * 0.1}
      a${i},${i} 1 0,0 ${a * 0.25},0
      a${i},${i} 1 0,0 ${a * 0.25},0
      a${i},${i} 1 0,0 ${a * 0.25},${1 * n * 0.1}

      a${i},${i} 1 0,0 ${a * 0.15},${1 * n * 0.33}
      a${i * 0.8},${i * 0.8} 1 0,0 0,${1 * n * 0.34}
      a${i},${i} 1 0,0 ${-1 * a * 0.15},${1 * n * 0.33}

      a${i},${i} 1 0,0 ${-1 * a * 0.25},${n * 0.15}
      a${i},${i} 1 0,0 ${-1 * a * 0.25},0
      a${i},${i} 1 0,0 ${-1 * a * 0.25},0
      a${i},${i} 1 0,0 ${-1 * a * 0.25},${-1 * n * 0.15}

      a${i},${i} 1 0,0 ${-1 * a * 0.1},${-1 * n * 0.33}
      a${i * 0.8},${i * 0.8} 1 0,0 0,${-1 * n * 0.34}
      a${i},${i} 1 0,0 ${a * 0.1},${-1 * n * 0.33}

    H0 V0 Z`
  );
}, c0 = function(r, e, t) {
  e.append("circle").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + r.type2Str(t.type)).attr("r", t.width / 2);
};
function v0(r, e, t, a, n) {
  return r.insert("polygon", ":first-child").attr(
    "points",
    a.map(function(i) {
      return i.x + "," + i.y;
    }).join(" ")
  ).attr("transform", "translate(" + (n.width - e) / 2 + ", " + t + ")");
}
const h0 = function(r, e, t) {
  const a = t.height, i = a / 4, s = t.width - t.padding + 2 * i, o = [
    { x: i, y: 0 },
    { x: s - i, y: 0 },
    { x: s, y: -a / 2 },
    { x: s - i, y: -a },
    { x: i, y: -a },
    { x: 0, y: -a / 2 }
  ];
  v0(e, s, a, o, t);
}, d0 = function(r, e, t) {
  e.append("rect").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + r.type2Str(t.type)).attr("height", t.height).attr("rx", t.padding).attr("ry", t.padding).attr("width", t.width);
}, g0 = function(r, e, t, a, n) {
  const i = n.htmlLabels, s = a % (s0 - 1), o = e.append("g");
  t.section = s;
  let u = "section-" + s;
  s < 0 && (u += " section-root"), o.attr("class", (t.class ? t.class + " " : "") + "mindmap-node " + u);
  const l = o.append("g"), f = o.append("g"), c = t.descr.replace(/(<br\/*>)/g, `
`);
  pv(f, c, {
    useHtmlLabels: i,
    width: t.width,
    classes: "mindmap-node-label"
  }), i || f.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle");
  const v = f.node().getBBox(), [h] = gv(n.fontSize);
  if (t.height = v.height + h * 1.1 * 0.5 + t.padding, t.width = v.width + 2 * t.padding, t.icon)
    if (t.type === r.nodeType.CIRCLE)
      t.height += 50, t.width += 50, o.append("foreignObject").attr("height", "50px").attr("width", t.width).attr("style", "text-align: center;").append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + s + " " + t.icon), f.attr(
        "transform",
        "translate(" + t.width / 2 + ", " + (t.height / 2 - 1.5 * t.padding) + ")"
      );
    else {
      t.width += 50;
      const d = t.height;
      t.height = Math.max(d, 60);
      const p = Math.abs(t.height - d);
      o.append("foreignObject").attr("width", "60px").attr("height", t.height).attr("style", "text-align: center;margin-top:" + p / 2 + "px;").append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + s + " " + t.icon), f.attr(
        "transform",
        "translate(" + (25 + t.width / 2) + ", " + (p / 2 + t.padding / 2) + ")"
      );
    }
  else if (i) {
    const d = (t.width - v.width) / 2, p = (t.height - v.height) / 2;
    f.attr("transform", "translate(" + d + ", " + p + ")");
  } else {
    const d = t.width / 2, p = t.padding / 2;
    f.attr("transform", "translate(" + d + ", " + p + ")");
  }
  switch (t.type) {
    case r.nodeType.DEFAULT:
      o0(r, l, t, s);
      break;
    case r.nodeType.ROUNDED_RECT:
      d0(r, l, t);
      break;
    case r.nodeType.RECT:
      u0(r, l, t);
      break;
    case r.nodeType.CIRCLE:
      l.attr("transform", "translate(" + t.width / 2 + ", " + +t.height / 2 + ")"), c0(r, l, t);
      break;
    case r.nodeType.CLOUD:
      l0(r, l, t);
      break;
    case r.nodeType.BANG:
      f0(r, l, t);
      break;
    case r.nodeType.HEXAGON:
      h0(r, l, t);
      break;
  }
  return r.setElementForId(t.id, o), t.height;
}, p0 = function(r, e) {
  const t = r.getElementById(e.id), a = e.x || 0, n = e.y || 0;
  t.attr("transform", "translate(" + a + "," + n + ")");
};
vr.use(Xm);
function Qc(r, e, t, a, n) {
  g0(r, e, t, a, n), t.children && t.children.forEach((i, s) => {
    Qc(r, e, i, a < 0 ? s : a, n);
  });
}
function y0(r, e) {
  e.edges().map((t, a) => {
    const n = t.data();
    if (t[0]._private.bodyBounds) {
      const i = t[0]._private.rscratch;
      Or.trace("Edge: ", a, n), r.insert("path").attr(
        "d",
        `M ${i.startX},${i.startY} L ${i.midX},${i.midY} L${i.endX},${i.endY} `
      ).attr("class", "edge section-edge-" + n.section + " edge-depth-" + n.depth);
    }
  });
}
function Jc(r, e, t, a) {
  e.add({
    group: "nodes",
    data: {
      id: r.id.toString(),
      labelText: r.descr,
      height: r.height,
      width: r.width,
      level: a,
      nodeId: r.id,
      padding: r.padding,
      type: r.type
    },
    position: {
      x: r.x,
      y: r.y
    }
  }), r.children && r.children.forEach((n) => {
    Jc(n, e, t, a + 1), e.add({
      group: "edges",
      data: {
        id: `${r.id}_${n.id}`,
        source: r.id,
        target: n.id,
        depth: a,
        section: n.section
      }
    });
  });
}
function m0(r, e) {
  return new Promise((t) => {
    const a = cv("body").append("div").attr("id", "cy").attr("style", "display:none"), n = vr({
      container: document.getElementById("cy"),
      // container to render in
      style: [
        {
          selector: "edge",
          style: {
            "curve-style": "bezier"
          }
        }
      ]
    });
    a.remove(), Jc(r, n, e, 0), n.nodes().forEach(function(i) {
      i.layoutDimensions = () => {
        const s = i.data();
        return { w: s.width, h: s.height };
      };
    }), n.layout({
      name: "cose-bilkent",
      // @ts-ignore Types for cose-bilkent are not correct?
      quality: "proof",
      styleEnabled: !1,
      animate: !1
    }).run(), n.ready((i) => {
      Or.info("Ready", i), t(n);
    });
  });
}
function b0(r, e) {
  e.nodes().map((t, a) => {
    const n = t.data();
    n.x = t.position().x, n.y = t.position().y, p0(r, n);
    const i = r.getElementById(n.nodeId);
    Or.info("Id:", a, "Position: (", t.position().x, ", ", t.position().y, ")", n), i.attr(
      "transform",
      `translate(${t.position().x - n.width / 2}, ${t.position().y - n.height / 2})`
    ), i.attr("attr", `apa-${a})`);
  });
}
const w0 = async (r, e, t, a) => {
  var n, i;
  Or.debug(`Rendering mindmap diagram
` + r);
  const s = a.db, o = s.getMindmap();
  if (!o)
    return;
  const u = eo();
  u.htmlLabels = !1;
  const l = lv(e), f = l.append("g");
  f.attr("class", "mindmap-edges");
  const c = l.append("g");
  c.attr("class", "mindmap-nodes"), Qc(s, c, o, -1, u);
  const v = await m0(o, u);
  y0(f, v), b0(s, v), fv(
    void 0,
    l,
    ((n = u.mindmap) == null ? void 0 : n.padding) ?? bn.mindmap.padding,
    ((i = u.mindmap) == null ? void 0 : i.useMaxWidth) ?? bn.mindmap.useMaxWidth
  );
}, E0 = {
  draw: w0
}, x0 = (r) => {
  let e = "";
  for (let t = 0; t < r.THEME_COLOR_LIMIT; t++)
    r["lineColor" + t] = r["lineColor" + t] || r["cScaleInv" + t], vv(r["lineColor" + t]) ? r["lineColor" + t] = hv(r["lineColor" + t], 20) : r["lineColor" + t] = dv(r["lineColor" + t], 20);
  for (let t = 0; t < r.THEME_COLOR_LIMIT; t++) {
    const a = "" + (17 - 3 * t);
    e += `
    .section-${t - 1} rect, .section-${t - 1} path, .section-${t - 1} circle, .section-${t - 1} polygon, .section-${t - 1} path  {
      fill: ${r["cScale" + t]};
    }
    .section-${t - 1} text {
     fill: ${r["cScaleLabel" + t]};
    }
    .node-icon-${t - 1} {
      font-size: 40px;
      color: ${r["cScaleLabel" + t]};
    }
    .section-edge-${t - 1}{
      stroke: ${r["cScale" + t]};
    }
    .edge-depth-${t - 1}{
      stroke-width: ${a};
    }
    .section-${t - 1} line {
      stroke: ${r["cScaleInv" + t]} ;
      stroke-width: 3;
    }

    .disabled, .disabled circle, .disabled text {
      fill: lightgray;
    }
    .disabled text {
      fill: #efefef;
    }
    `;
  }
  return e;
}, T0 = (r) => `
  .edge {
    stroke-width: 3;
  }
  ${x0(r)}
  .section-root rect, .section-root path, .section-root circle, .section-root polygon  {
    fill: ${r.git0};
  }
  .section-root text {
    fill: ${r.gitBranchLabel0};
  }
  .icon-container {
    height:100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edge {
    fill: none;
  }
  .mindmap-node-label {
    dy: 1em;
    alignment-baseline: middle;
    text-anchor: middle;
    dominant-baseline: middle;
    text-align: center;
  }
`, C0 = T0, L0 = {
  db: i0,
  renderer: E0,
  parser: $m,
  styles: C0
};
export {
  L0 as diagram
};