import { __commonJSMin as e } from "../../_virtual/_rolldown/runtime.js";
import { require_cose_base as t } from "../cose-base/cose-base.js";
//#region ../../node_modules/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js
var n = /* @__PURE__ */ e(((e, n) => {
	(function(r, i) {
		typeof e == "object" && typeof n == "object" ? n.exports = i(t()) : typeof define == "function" && define.amd ? define(["cose-base"], i) : typeof e == "object" ? e.cytoscapeCoseBilkent = i(t()) : r.cytoscapeCoseBilkent = i(r.coseBase);
	})(e, function(e) {
		return (function(e) {
			var t = {};
			function n(r) {
				if (t[r]) return t[r].exports;
				var i = t[r] = {
					i: r,
					l: !1,
					exports: {}
				};
				return e[r].call(i.exports, i, i.exports, n), i.l = !0, i.exports;
			}
			return n.m = e, n.c = t, n.i = function(e) {
				return e;
			}, n.d = function(e, t, r) {
				n.o(e, t) || Object.defineProperty(e, t, {
					configurable: !1,
					enumerable: !0,
					get: r
				});
			}, n.n = function(e) {
				var t = e && e.__esModule ? function() {
					return e.default;
				} : function() {
					return e;
				};
				return n.d(t, "a", t), t;
			}, n.o = function(e, t) {
				return Object.prototype.hasOwnProperty.call(e, t);
			}, n.p = "", n(n.s = 1);
		})([(function(t, n) {
			t.exports = e;
		}), (function(e, t, n) {
			var r = n(0).layoutBase.LayoutConstants, i = n(0).layoutBase.FDLayoutConstants, a = n(0).CoSEConstants, o = n(0).CoSELayout, s = n(0).CoSENode, c = n(0).layoutBase.PointD, l = n(0).layoutBase.DimensionD, u = {
				ready: function() {},
				stop: function() {},
				quality: "default",
				nodeDimensionsIncludeLabels: !1,
				refresh: 30,
				fit: !0,
				padding: 10,
				randomize: !0,
				nodeRepulsion: 4500,
				idealEdgeLength: 50,
				edgeElasticity: .45,
				nestingFactor: .1,
				gravity: .25,
				numIter: 2500,
				tile: !0,
				animate: "end",
				animationDuration: 500,
				tilingPaddingVertical: 10,
				tilingPaddingHorizontal: 10,
				gravityRangeCompound: 1.5,
				gravityCompound: 1,
				gravityRange: 3.8,
				initialEnergyOnIncremental: .5
			};
			function d(e, t) {
				var n = {};
				for (var r in e) n[r] = e[r];
				for (var r in t) n[r] = t[r];
				return n;
			}
			function f(e) {
				this.options = d(u, e), p(this.options);
			}
			var p = function(e) {
				e.nodeRepulsion != null && (a.DEFAULT_REPULSION_STRENGTH = i.DEFAULT_REPULSION_STRENGTH = e.nodeRepulsion), e.idealEdgeLength != null && (a.DEFAULT_EDGE_LENGTH = i.DEFAULT_EDGE_LENGTH = e.idealEdgeLength), e.edgeElasticity != null && (a.DEFAULT_SPRING_STRENGTH = i.DEFAULT_SPRING_STRENGTH = e.edgeElasticity), e.nestingFactor != null && (a.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = e.nestingFactor), e.gravity != null && (a.DEFAULT_GRAVITY_STRENGTH = i.DEFAULT_GRAVITY_STRENGTH = e.gravity), e.numIter != null && (a.MAX_ITERATIONS = i.MAX_ITERATIONS = e.numIter), e.gravityRange != null && (a.DEFAULT_GRAVITY_RANGE_FACTOR = i.DEFAULT_GRAVITY_RANGE_FACTOR = e.gravityRange), e.gravityCompound != null && (a.DEFAULT_COMPOUND_GRAVITY_STRENGTH = i.DEFAULT_COMPOUND_GRAVITY_STRENGTH = e.gravityCompound), e.gravityRangeCompound != null && (a.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = e.gravityRangeCompound), e.initialEnergyOnIncremental != null && (a.DEFAULT_COOLING_FACTOR_INCREMENTAL = i.DEFAULT_COOLING_FACTOR_INCREMENTAL = e.initialEnergyOnIncremental), e.quality == "draft" ? r.QUALITY = 0 : e.quality == "proof" ? r.QUALITY = 2 : r.QUALITY = 1, a.NODE_DIMENSIONS_INCLUDE_LABELS = i.NODE_DIMENSIONS_INCLUDE_LABELS = r.NODE_DIMENSIONS_INCLUDE_LABELS = e.nodeDimensionsIncludeLabels, a.DEFAULT_INCREMENTAL = i.DEFAULT_INCREMENTAL = r.DEFAULT_INCREMENTAL = !e.randomize, a.ANIMATE = i.ANIMATE = r.ANIMATE = e.animate, a.TILE = e.tile, a.TILING_PADDING_VERTICAL = typeof e.tilingPaddingVertical == "function" ? e.tilingPaddingVertical.call() : e.tilingPaddingVertical, a.TILING_PADDING_HORIZONTAL = typeof e.tilingPaddingHorizontal == "function" ? e.tilingPaddingHorizontal.call() : e.tilingPaddingHorizontal;
			};
			f.prototype.run = function() {
				var e, t, n = this.options;
				this.idToLNode = {};
				var r = this.layout = new o(), i = this;
				i.stopped = !1, this.cy = this.options.cy, this.cy.trigger({
					type: "layoutstart",
					layout: this
				});
				var a = r.newGraphManager();
				this.gm = a;
				var s = this.options.eles.nodes(), c = this.options.eles.edges();
				this.root = a.addRoot(), this.processChildrenList(this.root, this.getTopMostNodes(s), r);
				for (var l = 0; l < c.length; l++) {
					var u = c[l], d = this.idToLNode[u.data("source")], f = this.idToLNode[u.data("target")];
					if (d !== f && d.getEdgesBetween(f).length == 0) {
						var p = a.add(r.newEdge(), d, f);
						p.id = u.id();
					}
				}
				var m = function(e, t) {
					typeof e == "number" && (e = t);
					var n = e.data("id"), r = i.idToLNode[n];
					return {
						x: r.getRect().getCenterX(),
						y: r.getRect().getCenterY()
					};
				}, h = function a() {
					for (var o = function() {
						n.fit && n.cy.fit(n.eles, n.padding), e || (e = !0, i.cy.one("layoutready", n.ready), i.cy.trigger({
							type: "layoutready",
							layout: i
						}));
					}, s = i.options.refresh, c, l = 0; l < s && !c; l++) c = i.stopped || i.layout.tick();
					if (c) {
						r.checkLayoutSuccess() && !r.isSubLayout && r.doPostLayout(), r.tilingPostLayout && r.tilingPostLayout(), r.isLayoutFinished = !0, i.options.eles.nodes().positions(m), o(), i.cy.one("layoutstop", i.options.stop), i.cy.trigger({
							type: "layoutstop",
							layout: i
						}), t && cancelAnimationFrame(t), e = !1;
						return;
					}
					var u = i.layout.getPositionsData();
					n.eles.nodes().positions(function(e, t) {
						if (typeof e == "number" && (e = t), !e.isParent()) {
							for (var n = e.id(), r = u[n], i = e; r == null && (r = u[i.data("parent")] || u["DummyCompound_" + i.data("parent")], u[n] = r, i = i.parent()[0], i != null););
							return r == null ? {
								x: e.position("x"),
								y: e.position("y")
							} : {
								x: r.x,
								y: r.y
							};
						}
					}), o(), t = requestAnimationFrame(a);
				};
				return r.addListener("layoutstarted", function() {
					i.options.animate === "during" && (t = requestAnimationFrame(h));
				}), r.runLayout(), this.options.animate !== "during" && (i.options.eles.nodes().not(":parent").layoutPositions(i, i.options, m), e = !1), this;
			}, f.prototype.getTopMostNodes = function(e) {
				for (var t = {}, n = 0; n < e.length; n++) t[e[n].id()] = !0;
				return e.filter(function(e, n) {
					typeof e == "number" && (e = n);
					for (var r = e.parent()[0]; r != null;) {
						if (t[r.id()]) return !1;
						r = r.parent()[0];
					}
					return !0;
				});
			}, f.prototype.processChildrenList = function(e, t, n) {
				for (var r = t.length, i = 0; i < r; i++) {
					var a = t[i], o = a.children(), u, d = a.layoutDimensions({ nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels });
					if (u = a.outerWidth() != null && a.outerHeight() != null ? e.add(new s(n.graphManager, new c(a.position("x") - d.w / 2, a.position("y") - d.h / 2), new l(parseFloat(d.w), parseFloat(d.h)))) : e.add(new s(this.graphManager)), u.id = a.data("id"), u.paddingLeft = parseInt(a.css("padding")), u.paddingTop = parseInt(a.css("padding")), u.paddingRight = parseInt(a.css("padding")), u.paddingBottom = parseInt(a.css("padding")), this.options.nodeDimensionsIncludeLabels && a.isParent()) {
						var f = a.boundingBox({
							includeLabels: !0,
							includeNodes: !1
						}).w, p = a.boundingBox({
							includeLabels: !0,
							includeNodes: !1
						}).h, m = a.css("text-halign");
						u.labelWidth = f, u.labelHeight = p, u.labelPos = m;
					}
					if (this.idToLNode[a.data("id")] = u, isNaN(u.rect.x) && (u.rect.x = 0), isNaN(u.rect.y) && (u.rect.y = 0), o != null && o.length > 0) {
						var h = n.getGraphManager().add(n.newGraph(), u);
						this.processChildrenList(h, o, n);
					}
				}
			}, f.prototype.stop = function() {
				return this.stopped = !0, this;
			};
			var m = function(e) {
				e("layout", "cose-bilkent", f);
			};
			typeof cytoscape < "u" && m(cytoscape), e.exports = m;
		})]);
	});
}));
//#endregion
export default n();
export { n as require_cytoscape_cose_bilkent };
