/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // main.ts var main_exports = {}; __export(main_exports, { default: () => ScGraphView }); module.exports = __toCommonJS(main_exports); var import_obsidian = require("obsidian"); // node_modules/d3-array/src/ascending.js function ascending(a2, b) { return a2 == null || b == null ? NaN : a2 < b ? -1 : a2 > b ? 1 : a2 >= b ? 0 : NaN; } // node_modules/d3-array/src/descending.js function descending(a2, b) { return a2 == null || b == null ? NaN : b < a2 ? -1 : b > a2 ? 1 : b >= a2 ? 0 : NaN; } // node_modules/d3-array/src/bisector.js function bisector(f) { let compare1, compare2, delta; if (f.length !== 2) { compare1 = ascending; compare2 = (d, x3) => ascending(f(d), x3); delta = (d, x3) => f(d) - x3; } else { compare1 = f === ascending || f === descending ? f : zero; compare2 = f; delta = f; } function left(a2, x3, lo = 0, hi = a2.length) { if (lo < hi) { if (compare1(x3, x3) !== 0) return hi; do { const mid = lo + hi >>> 1; if (compare2(a2[mid], x3) < 0) lo = mid + 1; else hi = mid; } while (lo < hi); } return lo; } function right(a2, x3, lo = 0, hi = a2.length) { if (lo < hi) { if (compare1(x3, x3) !== 0) return hi; do { const mid = lo + hi >>> 1; if (compare2(a2[mid], x3) <= 0) lo = mid + 1; else hi = mid; } while (lo < hi); } return lo; } function center(a2, x3, lo = 0, hi = a2.length) { const i = left(a2, x3, lo, hi - 1); return i > lo && delta(a2[i - 1], x3) > -delta(a2[i], x3) ? i - 1 : i; } return { left, center, right }; } function zero() { return 0; } // node_modules/d3-array/src/number.js function number(x3) { return x3 === null ? NaN : +x3; } // node_modules/d3-array/src/bisect.js var ascendingBisect = bisector(ascending); var bisectRight = ascendingBisect.right; var bisectLeft = ascendingBisect.left; var bisectCenter = bisector(number).center; var bisect_default = bisectRight; // node_modules/d3-array/src/ticks.js var e10 = Math.sqrt(50); var e5 = Math.sqrt(10); var e2 = Math.sqrt(2); function tickSpec(start2, stop, count) { const step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; let i1, i2, inc; if (power < 0) { inc = Math.pow(10, -power) / factor; i1 = Math.round(start2 * inc); i2 = Math.round(stop * inc); if (i1 / inc < start2) ++i1; if (i2 / inc > stop) --i2; inc = -inc; } else { inc = Math.pow(10, power) * factor; i1 = Math.round(start2 / inc); i2 = Math.round(stop / inc); if (i1 * inc < start2) ++i1; if (i2 * inc > stop) --i2; } if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start2, stop, count * 2); return [i1, i2, inc]; } function ticks(start2, stop, count) { stop = +stop, start2 = +start2, count = +count; if (!(count > 0)) return []; if (start2 === stop) return [start2]; const reverse = stop < start2, [i1, i2, inc] = reverse ? tickSpec(stop, start2, count) : tickSpec(start2, stop, count); if (!(i2 >= i1)) return []; const n = i2 - i1 + 1, ticks2 = new Array(n); if (reverse) { if (inc < 0) for (let i = 0; i < n; ++i) ticks2[i] = (i2 - i) / -inc; else for (let i = 0; i < n; ++i) ticks2[i] = (i2 - i) * inc; } else { if (inc < 0) for (let i = 0; i < n; ++i) ticks2[i] = (i1 + i) / -inc; else for (let i = 0; i < n; ++i) ticks2[i] = (i1 + i) * inc; } return ticks2; } function tickIncrement(start2, stop, count) { stop = +stop, start2 = +start2, count = +count; return tickSpec(start2, stop, count)[2]; } function tickStep(start2, stop, count) { stop = +stop, start2 = +start2, count = +count; const reverse = stop < start2, inc = reverse ? tickIncrement(stop, start2, count) : tickIncrement(start2, stop, count); return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); } // node_modules/d3-dispatch/src/dispatch.js var noop = { value: () => { } }; function dispatch() { for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) { if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t); _[t] = []; } return new Dispatch(_); } function Dispatch(_) { this._ = _; } function parseTypenames(typenames, types) { return typenames.trim().split(/^|\s+/).map(function(t) { var name = "", i = t.indexOf("."); if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t); return { type: t, name }; }); } Dispatch.prototype = dispatch.prototype = { constructor: Dispatch, on: function(typename, callback) { var _ = this._, T = parseTypenames(typename + "", _), t, i = -1, n = T.length; if (arguments.length < 2) { while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t; return; } if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); while (++i < n) { if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback); else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null); } return this; }, copy: function() { var copy2 = {}, _ = this._; for (var t in _) copy2[t] = _[t].slice(); return new Dispatch(copy2); }, call: function(type2, that) { if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2]; if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2); for (t = this._[type2], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); }, apply: function(type2, that, args) { if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2); for (var t = this._[type2], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); } }; function get(type2, name) { for (var i = 0, n = type2.length, c2; i < n; ++i) { if ((c2 = type2[i]).name === name) { return c2.value; } } } function set(type2, name, callback) { for (var i = 0, n = type2.length; i < n; ++i) { if (type2[i].name === name) { type2[i] = noop, type2 = type2.slice(0, i).concat(type2.slice(i + 1)); break; } } if (callback != null) type2.push({ name, value: callback }); return type2; } var dispatch_default = dispatch; // node_modules/d3-selection/src/namespaces.js var xhtml = "http://www.w3.org/1999/xhtml"; var namespaces_default = { svg: "http://www.w3.org/2000/svg", xhtml, xlink: "http://www.w3.org/1999/xlink", xml: "http://www.w3.org/XML/1998/namespace", xmlns: "http://www.w3.org/2000/xmlns/" }; // node_modules/d3-selection/src/namespace.js function namespace_default(name) { var prefix = name += "", i = prefix.indexOf(":"); if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); return namespaces_default.hasOwnProperty(prefix) ? { space: namespaces_default[prefix], local: name } : name; } // node_modules/d3-selection/src/creator.js function creatorInherit(name) { return function() { var document2 = this.ownerDocument, uri = this.namespaceURI; return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name); }; } function creatorFixed(fullname) { return function() { return this.ownerDocument.createElementNS(fullname.space, fullname.local); }; } function creator_default(name) { var fullname = namespace_default(name); return (fullname.local ? creatorFixed : creatorInherit)(fullname); } // node_modules/d3-selection/src/selector.js function none() { } function selector_default(selector) { return selector == null ? none : function() { return this.querySelector(selector); }; } // node_modules/d3-selection/src/selection/select.js function select_default(select) { if (typeof select !== "function") select = selector_default(select); for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { if ("__data__" in node) subnode.__data__ = node.__data__; subgroup[i] = subnode; } } } return new Selection(subgroups, this._parents); } // node_modules/d3-selection/src/array.js function array(x3) { return x3 == null ? [] : Array.isArray(x3) ? x3 : Array.from(x3); } // node_modules/d3-selection/src/selectorAll.js function empty() { return []; } function selectorAll_default(selector) { return selector == null ? empty : function() { return this.querySelectorAll(selector); }; } // node_modules/d3-selection/src/selection/selectAll.js function arrayAll(select) { return function() { return array(select.apply(this, arguments)); }; } function selectAll_default(select) { if (typeof select === "function") select = arrayAll(select); else select = selectorAll_default(select); for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { if (node = group[i]) { subgroups.push(select.call(node, node.__data__, i, group)); parents.push(node); } } } return new Selection(subgroups, parents); } // node_modules/d3-selection/src/matcher.js function matcher_default(selector) { return function() { return this.matches(selector); }; } function childMatcher(selector) { return function(node) { return node.matches(selector); }; } // node_modules/d3-selection/src/selection/selectChild.js var find = Array.prototype.find; function childFind(match) { return function() { return find.call(this.children, match); }; } function childFirst() { return this.firstElementChild; } function selectChild_default(match) { return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match))); } // node_modules/d3-selection/src/selection/selectChildren.js var filter = Array.prototype.filter; function children() { return Array.from(this.children); } function childrenFilter(match) { return function() { return filter.call(this.children, match); }; } function selectChildren_default(match) { return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match))); } // node_modules/d3-selection/src/selection/filter.js function filter_default(match) { if (typeof match !== "function") match = matcher_default(match); for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { if ((node = group[i]) && match.call(node, node.__data__, i, group)) { subgroup.push(node); } } } return new Selection(subgroups, this._parents); } // node_modules/d3-selection/src/selection/sparse.js function sparse_default(update) { return new Array(update.length); } // node_modules/d3-selection/src/selection/enter.js function enter_default() { return new Selection(this._enter || this._groups.map(sparse_default), this._parents); } function EnterNode(parent, datum2) { this.ownerDocument = parent.ownerDocument; this.namespaceURI = parent.namespaceURI; this._next = null; this._parent = parent; this.__data__ = datum2; } EnterNode.prototype = { constructor: EnterNode, appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, querySelector: function(selector) { return this._parent.querySelector(selector); }, querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } }; // node_modules/d3-selection/src/constant.js function constant_default(x3) { return function() { return x3; }; } // node_modules/d3-selection/src/selection/data.js function bindIndex(parent, group, enter, update, exit, data) { var i = 0, node, groupLength = group.length, dataLength = data.length; for (; i < dataLength; ++i) { if (node = group[i]) { node.__data__ = data[i]; update[i] = node; } else { enter[i] = new EnterNode(parent, data[i]); } } for (; i < groupLength; ++i) { if (node = group[i]) { exit[i] = node; } } } function bindKey(parent, group, enter, update, exit, data, key) { var i, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue; for (i = 0; i < groupLength; ++i) { if (node = group[i]) { keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + ""; if (nodeByKeyValue.has(keyValue)) { exit[i] = node; } else { nodeByKeyValue.set(keyValue, node); } } } for (i = 0; i < dataLength; ++i) { keyValue = key.call(parent, data[i], i, data) + ""; if (node = nodeByKeyValue.get(keyValue)) { update[i] = node; node.__data__ = data[i]; nodeByKeyValue.delete(keyValue); } else { enter[i] = new EnterNode(parent, data[i]); } } for (i = 0; i < groupLength; ++i) { if ((node = group[i]) && nodeByKeyValue.get(keyValues[i]) === node) { exit[i] = node; } } } function datum(node) { return node.__data__; } function data_default(value, key) { if (!arguments.length) return Array.from(this, datum); var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups; if (typeof value !== "function") value = constant_default(value); for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j = 0; j < m2; ++j) { var parent = parents[j], group = groups[j], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), dataLength = data.length, enterGroup = enter[j] = new Array(dataLength), updateGroup = update[j] = new Array(dataLength), exitGroup = exit[j] = new Array(groupLength); bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { if (previous = enterGroup[i0]) { if (i0 >= i1) i1 = i0 + 1; while (!(next = updateGroup[i1]) && ++i1 < dataLength) ; previous._next = next || null; } } } update = new Selection(update, parents); update._enter = enter; update._exit = exit; return update; } function arraylike(data) { return typeof data === "object" && "length" in data ? data : Array.from(data); } // node_modules/d3-selection/src/selection/exit.js function exit_default() { return new Selection(this._exit || this._groups.map(sparse_default), this._parents); } // node_modules/d3-selection/src/selection/join.js function join_default(onenter, onupdate, onexit) { var enter = this.enter(), update = this, exit = this.exit(); if (typeof onenter === "function") { enter = onenter(enter); if (enter) enter = enter.selection(); } else { enter = enter.append(onenter + ""); } if (onupdate != null) { update = onupdate(update); if (update) update = update.selection(); } if (onexit == null) exit.remove(); else onexit(exit); return enter && update ? enter.merge(update).order() : update; } // node_modules/d3-selection/src/selection/merge.js function merge_default(context) { var selection2 = context.selection ? context.selection() : context; for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m2; ++j) { for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { if (node = group0[i] || group1[i]) { merge[i] = node; } } } for (; j < m0; ++j) { merges[j] = groups0[j]; } return new Selection(merges, this._parents); } // node_modules/d3-selection/src/selection/order.js function order_default() { for (var groups = this._groups, j = -1, m2 = groups.length; ++j < m2; ) { for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { if (node = group[i]) { if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); next = node; } } } return this; } // node_modules/d3-selection/src/selection/sort.js function sort_default(compare) { if (!compare) compare = ascending2; function compareNode(a2, b) { return a2 && b ? compare(a2.__data__, b.__data__) : !a2 - !b; } for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { if (node = group[i]) { sortgroup[i] = node; } } sortgroup.sort(compareNode); } return new Selection(sortgroups, this._parents).order(); } function ascending2(a2, b) { return a2 < b ? -1 : a2 > b ? 1 : a2 >= b ? 0 : NaN; } // node_modules/d3-selection/src/selection/call.js function call_default() { var callback = arguments[0]; arguments[0] = this; callback.apply(null, arguments); return this; } // node_modules/d3-selection/src/selection/nodes.js function nodes_default() { return Array.from(this); } // node_modules/d3-selection/src/selection/node.js function node_default() { for (var groups = this._groups, j = 0, m2 = groups.length; j < m2; ++j) { for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { var node = group[i]; if (node) return node; } } return null; } // node_modules/d3-selection/src/selection/size.js function size_default() { let size = 0; for (const node of this) ++size; return size; } // node_modules/d3-selection/src/selection/empty.js function empty_default() { return !this.node(); } // node_modules/d3-selection/src/selection/each.js function each_default(callback) { for (var groups = this._groups, j = 0, m2 = groups.length; j < m2; ++j) { for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { if (node = group[i]) callback.call(node, node.__data__, i, group); } } return this; } // node_modules/d3-selection/src/selection/attr.js function attrRemove(name) { return function() { this.removeAttribute(name); }; } function attrRemoveNS(fullname) { return function() { this.removeAttributeNS(fullname.space, fullname.local); }; } function attrConstant(name, value) { return function() { this.setAttribute(name, value); }; } function attrConstantNS(fullname, value) { return function() { this.setAttributeNS(fullname.space, fullname.local, value); }; } function attrFunction(name, value) { return function() { var v = value.apply(this, arguments); if (v == null) this.removeAttribute(name); else this.setAttribute(name, v); }; } function attrFunctionNS(fullname, value) { return function() { var v = value.apply(this, arguments); if (v == null) this.removeAttributeNS(fullname.space, fullname.local); else this.setAttributeNS(fullname.space, fullname.local, v); }; } function attr_default(name, value) { var fullname = namespace_default(name); if (arguments.length < 2) { var node = this.node(); return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname); } return this.each((value == null ? fullname.local ? attrRemoveNS : attrRemove : typeof value === "function" ? fullname.local ? attrFunctionNS : attrFunction : fullname.local ? attrConstantNS : attrConstant)(fullname, value)); } // node_modules/d3-selection/src/window.js function window_default(node) { return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView; } // node_modules/d3-selection/src/selection/style.js function styleRemove(name) { return function() { this.style.removeProperty(name); }; } function styleConstant(name, value, priority) { return function() { this.style.setProperty(name, value, priority); }; } function styleFunction(name, value, priority) { return function() { var v = value.apply(this, arguments); if (v == null) this.style.removeProperty(name); else this.style.setProperty(name, v, priority); }; } function style_default(name, value, priority) { return arguments.length > 1 ? this.each((value == null ? styleRemove : typeof value === "function" ? styleFunction : styleConstant)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name); } function styleValue(node, name) { return node.style.getPropertyValue(name) || window_default(node).getComputedStyle(node, null).getPropertyValue(name); } // node_modules/d3-selection/src/selection/property.js function propertyRemove(name) { return function() { delete this[name]; }; } function propertyConstant(name, value) { return function() { this[name] = value; }; } function propertyFunction(name, value) { return function() { var v = value.apply(this, arguments); if (v == null) delete this[name]; else this[name] = v; }; } function property_default(name, value) { return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name]; } // node_modules/d3-selection/src/selection/classed.js function classArray(string) { return string.trim().split(/^|\s+/); } function classList(node) { return node.classList || new ClassList(node); } function ClassList(node) { this._node = node; this._names = classArray(node.getAttribute("class") || ""); } ClassList.prototype = { add: function(name) { var i = this._names.indexOf(name); if (i < 0) { this._names.push(name); this._node.setAttribute("class", this._names.join(" ")); } }, remove: function(name) { var i = this._names.indexOf(name); if (i >= 0) { this._names.splice(i, 1); this._node.setAttribute("class", this._names.join(" ")); } }, contains: function(name) { return this._names.indexOf(name) >= 0; } }; function classedAdd(node, names) { var list = classList(node), i = -1, n = names.length; while (++i < n) list.add(names[i]); } function classedRemove(node, names) { var list = classList(node), i = -1, n = names.length; while (++i < n) list.remove(names[i]); } function classedTrue(names) { return function() { classedAdd(this, names); }; } function classedFalse(names) { return function() { classedRemove(this, names); }; } function classedFunction(names, value) { return function() { (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); }; } function classed_default(name, value) { var names = classArray(name + ""); if (arguments.length < 2) { var list = classList(this.node()), i = -1, n = names.length; while (++i < n) if (!list.contains(names[i])) return false; return true; } return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value)); } // node_modules/d3-selection/src/selection/text.js function textRemove() { this.textContent = ""; } function textConstant(value) { return function() { this.textContent = value; }; } function textFunction(value) { return function() { var v = value.apply(this, arguments); this.textContent = v == null ? "" : v; }; } function text_default(value) { return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction : textConstant)(value)) : this.node().textContent; } // node_modules/d3-selection/src/selection/html.js function htmlRemove() { this.innerHTML = ""; } function htmlConstant(value) { return function() { this.innerHTML = value; }; } function htmlFunction(value) { return function() { var v = value.apply(this, arguments); this.innerHTML = v == null ? "" : v; }; } function html_default(value) { return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML; } // node_modules/d3-selection/src/selection/raise.js function raise() { if (this.nextSibling) this.parentNode.appendChild(this); } function raise_default() { return this.each(raise); } // node_modules/d3-selection/src/selection/lower.js function lower() { if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); } function lower_default() { return this.each(lower); } // node_modules/d3-selection/src/selection/append.js function append_default(name) { var create2 = typeof name === "function" ? name : creator_default(name); return this.select(function() { return this.appendChild(create2.apply(this, arguments)); }); } // node_modules/d3-selection/src/selection/insert.js function constantNull() { return null; } function insert_default(name, before) { var create2 = typeof name === "function" ? name : creator_default(name), select = before == null ? constantNull : typeof before === "function" ? before : selector_default(before); return this.select(function() { return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null); }); } // node_modules/d3-selection/src/selection/remove.js function remove() { var parent = this.parentNode; if (parent) parent.removeChild(this); } function remove_default() { return this.each(remove); } // node_modules/d3-selection/src/selection/clone.js function selection_cloneShallow() { var clone = this.cloneNode(false), parent = this.parentNode; return parent ? parent.insertBefore(clone, this.nextSibling) : clone; } function selection_cloneDeep() { var clone = this.cloneNode(true), parent = this.parentNode; return parent ? parent.insertBefore(clone, this.nextSibling) : clone; } function clone_default(deep) { return this.select(deep ? selection_cloneDeep : selection_cloneShallow); } // node_modules/d3-selection/src/selection/datum.js function datum_default(value) { return arguments.length ? this.property("__data__", value) : this.node().__data__; } // node_modules/d3-selection/src/selection/on.js function contextListener(listener) { return function(event) { listener.call(this, event, this.__data__); }; } function parseTypenames2(typenames) { return typenames.trim().split(/^|\s+/).map(function(t) { var name = "", i = t.indexOf("."); if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); return { type: t, name }; }); } function onRemove(typename) { return function() { var on = this.__on; if (!on) return; for (var j = 0, i = -1, m2 = on.length, o; j < m2; ++j) { if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { this.removeEventListener(o.type, o.listener, o.options); } else { on[++i] = o; } } if (++i) on.length = i; else delete this.__on; }; } function onAdd(typename, value, options) { return function() { var on = this.__on, o, listener = contextListener(value); if (on) for (var j = 0, m2 = on.length; j < m2; ++j) { if ((o = on[j]).type === typename.type && o.name === typename.name) { this.removeEventListener(o.type, o.listener, o.options); this.addEventListener(o.type, o.listener = listener, o.options = options); o.value = value; return; } } this.addEventListener(typename.type, listener, options); o = { type: typename.type, name: typename.name, value, listener, options }; if (!on) this.__on = [o]; else on.push(o); }; } function on_default(typename, value, options) { var typenames = parseTypenames2(typename + ""), i, n = typenames.length, t; if (arguments.length < 2) { var on = this.node().__on; if (on) for (var j = 0, m2 = on.length, o; j < m2; ++j) { for (i = 0, o = on[j]; i < n; ++i) { if ((t = typenames[i]).type === o.type && t.name === o.name) { return o.value; } } } return; } on = value ? onAdd : onRemove; for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options)); return this; } // node_modules/d3-selection/src/selection/dispatch.js function dispatchEvent(node, type2, params) { var window2 = window_default(node), event = window2.CustomEvent; if (typeof event === "function") { event = new event(type2, params); } else { event = window2.document.createEvent("Event"); if (params) event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail; else event.initEvent(type2, false, false); } node.dispatchEvent(event); } function dispatchConstant(type2, params) { return function() { return dispatchEvent(this, type2, params); }; } function dispatchFunction(type2, params) { return function() { return dispatchEvent(this, type2, params.apply(this, arguments)); }; } function dispatch_default2(type2, params) { return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params)); } // node_modules/d3-selection/src/selection/iterator.js function* iterator_default() { for (var groups = this._groups, j = 0, m2 = groups.length; j < m2; ++j) { for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { if (node = group[i]) yield node; } } } // node_modules/d3-selection/src/selection/index.js var root = [null]; function Selection(groups, parents) { this._groups = groups; this._parents = parents; } function selection() { return new Selection([[document.documentElement]], root); } function selection_selection() { return this; } Selection.prototype = selection.prototype = { constructor: Selection, select: select_default, selectAll: selectAll_default, selectChild: selectChild_default, selectChildren: selectChildren_default, filter: filter_default, data: data_default, enter: enter_default, exit: exit_default, join: join_default, merge: merge_default, selection: selection_selection, order: order_default, sort: sort_default, call: call_default, nodes: nodes_default, node: node_default, size: size_default, empty: empty_default, each: each_default, attr: attr_default, style: style_default, property: property_default, classed: classed_default, text: text_default, html: html_default, raise: raise_default, lower: lower_default, append: append_default, insert: insert_default, remove: remove_default, clone: clone_default, datum: datum_default, on: on_default, dispatch: dispatch_default2, [Symbol.iterator]: iterator_default }; var selection_default = selection; // node_modules/d3-selection/src/select.js function select_default2(selector) { return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root); } // node_modules/d3-selection/src/sourceEvent.js function sourceEvent_default(event) { let sourceEvent; while (sourceEvent = event.sourceEvent) event = sourceEvent; return event; } // node_modules/d3-selection/src/pointer.js function pointer_default(event, node) { event = sourceEvent_default(event); if (node === void 0) node = event.currentTarget; if (node) { var svg = node.ownerSVGElement || node; if (svg.createSVGPoint) { var point = svg.createSVGPoint(); point.x = event.clientX, point.y = event.clientY; point = point.matrixTransform(node.getScreenCTM().inverse()); return [point.x, point.y]; } if (node.getBoundingClientRect) { var rect = node.getBoundingClientRect(); return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop]; } } return [event.pageX, event.pageY]; } // node_modules/d3-drag/src/noevent.js var nonpassive = { passive: false }; var nonpassivecapture = { capture: true, passive: false }; function nopropagation(event) { event.stopImmediatePropagation(); } function noevent_default(event) { event.preventDefault(); event.stopImmediatePropagation(); } // node_modules/d3-drag/src/nodrag.js function nodrag_default(view) { var root2 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", noevent_default, nonpassivecapture); if ("onselectstart" in root2) { selection2.on("selectstart.drag", noevent_default, nonpassivecapture); } else { root2.__noselect = root2.style.MozUserSelect; root2.style.MozUserSelect = "none"; } } function yesdrag(view, noclick) { var root2 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", null); if (noclick) { selection2.on("click.drag", noevent_default, nonpassivecapture); setTimeout(function() { selection2.on("click.drag", null); }, 0); } if ("onselectstart" in root2) { selection2.on("selectstart.drag", null); } else { root2.style.MozUserSelect = root2.__noselect; delete root2.__noselect; } } // node_modules/d3-drag/src/constant.js var constant_default2 = (x3) => () => x3; // node_modules/d3-drag/src/event.js function DragEvent(type2, { sourceEvent, subject, target, identifier, active, x: x3, y: y3, dx, dy, dispatch: dispatch2 }) { Object.defineProperties(this, { type: { value: type2, enumerable: true, configurable: true }, sourceEvent: { value: sourceEvent, enumerable: true, configurable: true }, subject: { value: subject, enumerable: true, configurable: true }, target: { value: target, enumerable: true, configurable: true }, identifier: { value: identifier, enumerable: true, configurable: true }, active: { value: active, enumerable: true, configurable: true }, x: { value: x3, enumerable: true, configurable: true }, y: { value: y3, enumerable: true, configurable: true }, dx: { value: dx, enumerable: true, configurable: true }, dy: { value: dy, enumerable: true, configurable: true }, _: { value: dispatch2 } }); } DragEvent.prototype.on = function() { var value = this._.on.apply(this._, arguments); return value === this._ ? this : value; }; // node_modules/d3-drag/src/drag.js function defaultFilter(event) { return !event.ctrlKey && !event.button; } function defaultContainer() { return this.parentNode; } function defaultSubject(event, d) { return d == null ? { x: event.x, y: event.y } : d; } function defaultTouchable() { return navigator.maxTouchPoints || "ontouchstart" in this; } function drag_default() { var filter2 = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch_default("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0; function drag(selection2) { selection2.on("mousedown.drag", mousedowned).filter(touchable).on("touchstart.drag", touchstarted).on("touchmove.drag", touchmoved, nonpassive).on("touchend.drag touchcancel.drag", touchended).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); } function mousedowned(event, d) { if (touchending || !filter2.call(this, event, d)) return; var gesture = beforestart(this, container.call(this, event, d), event, d, "mouse"); if (!gesture) return; select_default2(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture); nodrag_default(event.view); nopropagation(event); mousemoving = false; mousedownx = event.clientX; mousedowny = event.clientY; gesture("start", event); } function mousemoved(event) { noevent_default(event); if (!mousemoving) { var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny; mousemoving = dx * dx + dy * dy > clickDistance2; } gestures.mouse("drag", event); } function mouseupped(event) { select_default2(event.view).on("mousemove.drag mouseup.drag", null); yesdrag(event.view, mousemoving); noevent_default(event); gestures.mouse("end", event); } function touchstarted(event, d) { if (!filter2.call(this, event, d)) return; var touches = event.changedTouches, c2 = container.call(this, event, d), n = touches.length, i, gesture; for (i = 0; i < n; ++i) { if (gesture = beforestart(this, c2, event, d, touches[i].identifier, touches[i])) { nopropagation(event); gesture("start", event, touches[i]); } } } function touchmoved(event) { var touches = event.changedTouches, n = touches.length, i, gesture; for (i = 0; i < n; ++i) { if (gesture = gestures[touches[i].identifier]) { noevent_default(event); gesture("drag", event, touches[i]); } } } function touchended(event) { var touches = event.changedTouches, n = touches.length, i, gesture; if (touchending) clearTimeout(touchending); touchending = setTimeout(function() { touchending = null; }, 500); for (i = 0; i < n; ++i) { if (gesture = gestures[touches[i].identifier]) { nopropagation(event); gesture("end", event, touches[i]); } } } function beforestart(that, container2, event, d, identifier, touch) { var dispatch2 = listeners.copy(), p = pointer_default(touch || event, container2), dx, dy, s; if ((s = subject.call(that, new DragEvent("beforestart", { sourceEvent: event, target: drag, identifier, active, x: p[0], y: p[1], dx: 0, dy: 0, dispatch: dispatch2 }), d)) == null) return; dx = s.x - p[0] || 0; dy = s.y - p[1] || 0; return function gesture(type2, event2, touch2) { var p0 = p, n; switch (type2) { case "start": gestures[identifier] = gesture, n = active++; break; case "end": delete gestures[identifier], --active; case "drag": p = pointer_default(touch2 || event2, container2), n = active; break; } dispatch2.call( type2, that, new DragEvent(type2, { sourceEvent: event2, subject: s, target: drag, identifier, active: n, x: p[0] + dx, y: p[1] + dy, dx: p[0] - p0[0], dy: p[1] - p0[1], dispatch: dispatch2 }), d ); }; } drag.filter = function(_) { return arguments.length ? (filter2 = typeof _ === "function" ? _ : constant_default2(!!_), drag) : filter2; }; drag.container = function(_) { return arguments.length ? (container = typeof _ === "function" ? _ : constant_default2(_), drag) : container; }; drag.subject = function(_) { return arguments.length ? (subject = typeof _ === "function" ? _ : constant_default2(_), drag) : subject; }; drag.touchable = function(_) { return arguments.length ? (touchable = typeof _ === "function" ? _ : constant_default2(!!_), drag) : touchable; }; drag.on = function() { var value = listeners.on.apply(listeners, arguments); return value === listeners ? drag : value; }; drag.clickDistance = function(_) { return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2); }; return drag; } // node_modules/d3-color/src/define.js function define_default(constructor, factory, prototype) { constructor.prototype = factory.prototype = prototype; prototype.constructor = constructor; } function extend(parent, definition) { var prototype = Object.create(parent.prototype); for (var key in definition) prototype[key] = definition[key]; return prototype; } // node_modules/d3-color/src/color.js function Color() { } var darker = 0.7; var brighter = 1 / darker; var reI = "\\s*([+-]?\\d+)\\s*"; var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*"; var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*"; var reHex = /^#([0-9a-f]{3,8})$/; var reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`); var reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`); var reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`); var reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`); var reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`); var reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); var named = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 }; define_default(Color, color, { copy(channels) { return Object.assign(new this.constructor(), this, channels); }, displayable() { return this.rgb().displayable(); }, hex: color_formatHex, // Deprecated! Use color.formatHex. formatHex: color_formatHex, formatHex8: color_formatHex8, formatHsl: color_formatHsl, formatRgb: color_formatRgb, toString: color_formatRgb }); function color_formatHex() { return this.rgb().formatHex(); } function color_formatHex8() { return this.rgb().formatHex8(); } function color_formatHsl() { return hslConvert(this).formatHsl(); } function color_formatRgb() { return this.rgb().formatRgb(); } function color(format2) { var m2, l; format2 = (format2 + "").trim().toLowerCase(); return (m2 = reHex.exec(format2)) ? (l = m2[1].length, m2 = parseInt(m2[1], 16), l === 6 ? rgbn(m2) : l === 3 ? new Rgb(m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, (m2 & 15) << 4 | m2 & 15, 1) : l === 8 ? rgba(m2 >> 24 & 255, m2 >> 16 & 255, m2 >> 8 & 255, (m2 & 255) / 255) : l === 4 ? rgba(m2 >> 12 & 15 | m2 >> 8 & 240, m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, ((m2 & 15) << 4 | m2 & 15) / 255) : null) : (m2 = reRgbInteger.exec(format2)) ? new Rgb(m2[1], m2[2], m2[3], 1) : (m2 = reRgbPercent.exec(format2)) ? new Rgb(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, 1) : (m2 = reRgbaInteger.exec(format2)) ? rgba(m2[1], m2[2], m2[3], m2[4]) : (m2 = reRgbaPercent.exec(format2)) ? rgba(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, m2[4]) : (m2 = reHslPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, 1) : (m2 = reHslaPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, m2[4]) : named.hasOwnProperty(format2) ? rgbn(named[format2]) : format2 === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; } function rgbn(n) { return new Rgb(n >> 16 & 255, n >> 8 & 255, n & 255, 1); } function rgba(r, g, b, a2) { if (a2 <= 0) r = g = b = NaN; return new Rgb(r, g, b, a2); } function rgbConvert(o) { if (!(o instanceof Color)) o = color(o); if (!o) return new Rgb(); o = o.rgb(); return new Rgb(o.r, o.g, o.b, o.opacity); } function rgb(r, g, b, opacity) { return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); } function Rgb(r, g, b, opacity) { this.r = +r; this.g = +g; this.b = +b; this.opacity = +opacity; } define_default(Rgb, rgb, extend(Color, { brighter(k) { k = k == null ? brighter : Math.pow(brighter, k); return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); }, darker(k) { k = k == null ? darker : Math.pow(darker, k); return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); }, rgb() { return this; }, clamp() { return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); }, displayable() { return -0.5 <= this.r && this.r < 255.5 && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1); }, hex: rgb_formatHex, // Deprecated! Use color.formatHex. formatHex: rgb_formatHex, formatHex8: rgb_formatHex8, formatRgb: rgb_formatRgb, toString: rgb_formatRgb })); function rgb_formatHex() { return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; } function rgb_formatHex8() { return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; } function rgb_formatRgb() { const a2 = clampa(this.opacity); return `${a2 === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a2 === 1 ? ")" : `, ${a2})`}`; } function clampa(opacity) { return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); } function clampi(value) { return Math.max(0, Math.min(255, Math.round(value) || 0)); } function hex(value) { value = clampi(value); return (value < 16 ? "0" : "") + value.toString(16); } function hsla(h, s, l, a2) { if (a2 <= 0) h = s = l = NaN; else if (l <= 0 || l >= 1) h = s = NaN; else if (s <= 0) h = NaN; return new Hsl(h, s, l, a2); } function hslConvert(o) { if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); if (!(o instanceof Color)) o = color(o); if (!o) return new Hsl(); if (o instanceof Hsl) return o; o = o.rgb(); var r = o.r / 255, g = o.g / 255, b = o.b / 255, min2 = Math.min(r, g, b), max2 = Math.max(r, g, b), h = NaN, s = max2 - min2, l = (max2 + min2) / 2; if (s) { if (r === max2) h = (g - b) / s + (g < b) * 6; else if (g === max2) h = (b - r) / s + 2; else h = (r - g) / s + 4; s /= l < 0.5 ? max2 + min2 : 2 - max2 - min2; h *= 60; } else { s = l > 0 && l < 1 ? 0 : h; } return new Hsl(h, s, l, o.opacity); } function hsl(h, s, l, opacity) { return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); } function Hsl(h, s, l, opacity) { this.h = +h; this.s = +s; this.l = +l; this.opacity = +opacity; } define_default(Hsl, hsl, extend(Color, { brighter(k) { k = k == null ? brighter : Math.pow(brighter, k); return new Hsl(this.h, this.s, this.l * k, this.opacity); }, darker(k) { k = k == null ? darker : Math.pow(darker, k); return new Hsl(this.h, this.s, this.l * k, this.opacity); }, rgb() { var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2; return new Rgb( hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity ); }, clamp() { return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1); }, formatHsl() { const a2 = clampa(this.opacity); return `${a2 === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a2 === 1 ? ")" : `, ${a2})`}`; } })); function clamph(value) { value = (value || 0) % 360; return value < 0 ? value + 360 : value; } function clampt(value) { return Math.max(0, Math.min(1, value || 0)); } function hsl2rgb(h, m1, m2) { return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; } // node_modules/d3-interpolate/src/basis.js function basis(t1, v0, v1, v2, v3) { var t2 = t1 * t1, t3 = t2 * t1; return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6; } function basis_default(values) { var n = values.length - 1; return function(t) { var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), v1 = values[i], v2 = values[i + 1], v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1; return basis((t - i / n) * n, v0, v1, v2, v3); }; } // node_modules/d3-interpolate/src/basisClosed.js function basisClosed_default(values) { var n = values.length; return function(t) { var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), v0 = values[(i + n - 1) % n], v1 = values[i % n], v2 = values[(i + 1) % n], v3 = values[(i + 2) % n]; return basis((t - i / n) * n, v0, v1, v2, v3); }; } // node_modules/d3-interpolate/src/constant.js var constant_default3 = (x3) => () => x3; // node_modules/d3-interpolate/src/color.js function linear(a2, d) { return function(t) { return a2 + t * d; }; } function exponential(a2, b, y3) { return a2 = Math.pow(a2, y3), b = Math.pow(b, y3) - a2, y3 = 1 / y3, function(t) { return Math.pow(a2 + t * b, y3); }; } function gamma(y3) { return (y3 = +y3) === 1 ? nogamma : function(a2, b) { return b - a2 ? exponential(a2, b, y3) : constant_default3(isNaN(a2) ? b : a2); }; } function nogamma(a2, b) { var d = b - a2; return d ? linear(a2, d) : constant_default3(isNaN(a2) ? b : a2); } // node_modules/d3-interpolate/src/rgb.js var rgb_default = function rgbGamma(y3) { var color2 = gamma(y3); function rgb2(start2, end) { var r = color2((start2 = rgb(start2)).r, (end = rgb(end)).r), g = color2(start2.g, end.g), b = color2(start2.b, end.b), opacity = nogamma(start2.opacity, end.opacity); return function(t) { start2.r = r(t); start2.g = g(t); start2.b = b(t); start2.opacity = opacity(t); return start2 + ""; }; } rgb2.gamma = rgbGamma; return rgb2; }(1); function rgbSpline(spline) { return function(colors) { var n = colors.length, r = new Array(n), g = new Array(n), b = new Array(n), i, color2; for (i = 0; i < n; ++i) { color2 = rgb(colors[i]); r[i] = color2.r || 0; g[i] = color2.g || 0; b[i] = color2.b || 0; } r = spline(r); g = spline(g); b = spline(b); color2.opacity = 1; return function(t) { color2.r = r(t); color2.g = g(t); color2.b = b(t); return color2 + ""; }; }; } var rgbBasis = rgbSpline(basis_default); var rgbBasisClosed = rgbSpline(basisClosed_default); // node_modules/d3-interpolate/src/numberArray.js function numberArray_default(a2, b) { if (!b) b = []; var n = a2 ? Math.min(b.length, a2.length) : 0, c2 = b.slice(), i; return function(t) { for (i = 0; i < n; ++i) c2[i] = a2[i] * (1 - t) + b[i] * t; return c2; }; } function isNumberArray(x3) { return ArrayBuffer.isView(x3) && !(x3 instanceof DataView); } // node_modules/d3-interpolate/src/array.js function genericArray(a2, b) { var nb = b ? b.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x3 = new Array(na), c2 = new Array(nb), i; for (i = 0; i < na; ++i) x3[i] = value_default(a2[i], b[i]); for (; i < nb; ++i) c2[i] = b[i]; return function(t) { for (i = 0; i < na; ++i) c2[i] = x3[i](t); return c2; }; } // node_modules/d3-interpolate/src/date.js function date_default(a2, b) { var d = new Date(); return a2 = +a2, b = +b, function(t) { return d.setTime(a2 * (1 - t) + b * t), d; }; } // node_modules/d3-interpolate/src/number.js function number_default(a2, b) { return a2 = +a2, b = +b, function(t) { return a2 * (1 - t) + b * t; }; } // node_modules/d3-interpolate/src/object.js function object_default(a2, b) { var i = {}, c2 = {}, k; if (a2 === null || typeof a2 !== "object") a2 = {}; if (b === null || typeof b !== "object") b = {}; for (k in b) { if (k in a2) { i[k] = value_default(a2[k], b[k]); } else { c2[k] = b[k]; } } return function(t) { for (k in i) c2[k] = i[k](t); return c2; }; } // node_modules/d3-interpolate/src/string.js var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; var reB = new RegExp(reA.source, "g"); function zero2(b) { return function() { return b; }; } function one(b) { return function(t) { return b(t) + ""; }; } function string_default(a2, b) { var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; a2 = a2 + "", b = b + ""; while ((am = reA.exec(a2)) && (bm = reB.exec(b))) { if ((bs = bm.index) > bi) { bs = b.slice(bi, bs); if (s[i]) s[i] += bs; else s[++i] = bs; } if ((am = am[0]) === (bm = bm[0])) { if (s[i]) s[i] += bm; else s[++i] = bm; } else { s[++i] = null; q.push({ i, x: number_default(am, bm) }); } bi = reB.lastIndex; } if (bi < b.length) { bs = b.slice(bi); if (s[i]) s[i] += bs; else s[++i] = bs; } return s.length < 2 ? q[0] ? one(q[0].x) : zero2(b) : (b = q.length, function(t) { for (var i2 = 0, o; i2 < b; ++i2) s[(o = q[i2]).i] = o.x(t); return s.join(""); }); } // node_modules/d3-interpolate/src/value.js function value_default(a2, b) { var t = typeof b, c2; return b == null || t === "boolean" ? constant_default3(b) : (t === "number" ? number_default : t === "string" ? (c2 = color(b)) ? (b = c2, rgb_default) : string_default : b instanceof color ? rgb_default : b instanceof Date ? date_default : isNumberArray(b) ? numberArray_default : Array.isArray(b) ? genericArray : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object_default : number_default)(a2, b); } // node_modules/d3-interpolate/src/round.js function round_default(a2, b) { return a2 = +a2, b = +b, function(t) { return Math.round(a2 * (1 - t) + b * t); }; } // node_modules/d3-interpolate/src/transform/decompose.js var degrees = 180 / Math.PI; var identity = { translateX: 0, translateY: 0, rotate: 0, skewX: 0, scaleX: 1, scaleY: 1 }; function decompose_default(a2, b, c2, d, e, f) { var scaleX, scaleY, skewX; if (scaleX = Math.sqrt(a2 * a2 + b * b)) a2 /= scaleX, b /= scaleX; if (skewX = a2 * c2 + b * d) c2 -= a2 * skewX, d -= b * skewX; if (scaleY = Math.sqrt(c2 * c2 + d * d)) c2 /= scaleY, d /= scaleY, skewX /= scaleY; if (a2 * d < b * c2) a2 = -a2, b = -b, skewX = -skewX, scaleX = -scaleX; return { translateX: e, translateY: f, rotate: Math.atan2(b, a2) * degrees, skewX: Math.atan(skewX) * degrees, scaleX, scaleY }; } // node_modules/d3-interpolate/src/transform/parse.js var svgNode; function parseCss(value) { const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); return m2.isIdentity ? identity : decompose_default(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f); } function parseSvg(value) { if (value == null) return identity; if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); svgNode.setAttribute("transform", value); if (!(value = svgNode.transform.baseVal.consolidate())) return identity; value = value.matrix; return decompose_default(value.a, value.b, value.c, value.d, value.e, value.f); } // node_modules/d3-interpolate/src/transform/index.js function interpolateTransform(parse, pxComma, pxParen, degParen) { function pop(s) { return s.length ? s.pop() + " " : ""; } function translate(xa, ya, xb, yb, s, q) { if (xa !== xb || ya !== yb) { var i = s.push("translate(", null, pxComma, null, pxParen); q.push({ i: i - 4, x: number_default(xa, xb) }, { i: i - 2, x: number_default(ya, yb) }); } else if (xb || yb) { s.push("translate(" + xb + pxComma + yb + pxParen); } } function rotate(a2, b, s, q) { if (a2 !== b) { if (a2 - b > 180) b += 360; else if (b - a2 > 180) a2 += 360; q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: number_default(a2, b) }); } else if (b) { s.push(pop(s) + "rotate(" + b + degParen); } } function skewX(a2, b, s, q) { if (a2 !== b) { q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: number_default(a2, b) }); } else if (b) { s.push(pop(s) + "skewX(" + b + degParen); } } function scale(xa, ya, xb, yb, s, q) { if (xa !== xb || ya !== yb) { var i = s.push(pop(s) + "scale(", null, ",", null, ")"); q.push({ i: i - 4, x: number_default(xa, xb) }, { i: i - 2, x: number_default(ya, yb) }); } else if (xb !== 1 || yb !== 1) { s.push(pop(s) + "scale(" + xb + "," + yb + ")"); } } return function(a2, b) { var s = [], q = []; a2 = parse(a2), b = parse(b); translate(a2.translateX, a2.translateY, b.translateX, b.translateY, s, q); rotate(a2.rotate, b.rotate, s, q); skewX(a2.skewX, b.skewX, s, q); scale(a2.scaleX, a2.scaleY, b.scaleX, b.scaleY, s, q); a2 = b = null; return function(t) { var i = -1, n = q.length, o; while (++i < n) s[(o = q[i]).i] = o.x(t); return s.join(""); }; }; } var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); // node_modules/d3-interpolate/src/zoom.js var epsilon2 = 1e-12; function cosh(x3) { return ((x3 = Math.exp(x3)) + 1 / x3) / 2; } function sinh(x3) { return ((x3 = Math.exp(x3)) - 1 / x3) / 2; } function tanh(x3) { return ((x3 = Math.exp(2 * x3)) - 1) / (x3 + 1); } var zoom_default = function zoomRho(rho, rho2, rho4) { function zoom(p0, p1) { var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; if (d2 < epsilon2) { S = Math.log(w1 / w0) / rho; i = function(t) { return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S) ]; }; } else { var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); S = (r1 - r0) / rho; i = function(t) { var s = t * S, coshr0 = cosh(r0), u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0)); return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0) ]; }; } i.duration = S * 1e3 * rho / Math.SQRT2; return i; } zoom.rho = function(_) { var _1 = Math.max(1e-3, +_), _2 = _1 * _1, _4 = _2 * _2; return zoomRho(_1, _2, _4); }; return zoom; }(Math.SQRT2, 2, 4); // node_modules/d3-timer/src/timer.js var frame = 0; var timeout = 0; var interval = 0; var pokeDelay = 1e3; var taskHead; var taskTail; var clockLast = 0; var clockNow = 0; var clockSkew = 0; var clock = typeof performance === "object" && performance.now ? performance : Date; var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); }; function now() { return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); } function clearNow() { clockNow = 0; } function Timer() { this._call = this._time = this._next = null; } Timer.prototype = timer.prototype = { constructor: Timer, restart: function(callback, delay, time) { if (typeof callback !== "function") throw new TypeError("callback is not a function"); time = (time == null ? now() : +time) + (delay == null ? 0 : +delay); if (!this._next && taskTail !== this) { if (taskTail) taskTail._next = this; else taskHead = this; taskTail = this; } this._call = callback; this._time = time; sleep(); }, stop: function() { if (this._call) { this._call = null; this._time = Infinity; sleep(); } } }; function timer(callback, delay, time) { var t = new Timer(); t.restart(callback, delay, time); return t; } function timerFlush() { now(); ++frame; var t = taskHead, e; while (t) { if ((e = clockNow - t._time) >= 0) t._call.call(void 0, e); t = t._next; } --frame; } function wake() { clockNow = (clockLast = clock.now()) + clockSkew; frame = timeout = 0; try { timerFlush(); } finally { frame = 0; nap(); clockNow = 0; } } function poke() { var now2 = clock.now(), delay = now2 - clockLast; if (delay > pokeDelay) clockSkew -= delay, clockLast = now2; } function nap() { var t0, t1 = taskHead, t2, time = Infinity; while (t1) { if (t1._call) { if (time > t1._time) time = t1._time; t0 = t1, t1 = t1._next; } else { t2 = t1._next, t1._next = null; t1 = t0 ? t0._next = t2 : taskHead = t2; } } taskTail = t0; sleep(time); } function sleep(time) { if (frame) return; if (timeout) timeout = clearTimeout(timeout); var delay = time - clockNow; if (delay > 24) { if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew); if (interval) interval = clearInterval(interval); } else { if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay); frame = 1, setFrame(wake); } } // node_modules/d3-timer/src/timeout.js function timeout_default(callback, delay, time) { var t = new Timer(); delay = delay == null ? 0 : +delay; t.restart((elapsed) => { t.stop(); callback(elapsed + delay); }, delay, time); return t; } // node_modules/d3-transition/src/transition/schedule.js var emptyOn = dispatch_default("start", "end", "cancel", "interrupt"); var emptyTween = []; var CREATED = 0; var SCHEDULED = 1; var STARTING = 2; var STARTED = 3; var RUNNING = 4; var ENDING = 5; var ENDED = 6; function schedule_default(node, name, id2, index2, group, timing) { var schedules = node.__transition; if (!schedules) node.__transition = {}; else if (id2 in schedules) return; create(node, id2, { name, index: index2, // For context during callback. group, // For context during callback. on: emptyOn, tween: emptyTween, time: timing.time, delay: timing.delay, duration: timing.duration, ease: timing.ease, timer: null, state: CREATED }); } function init(node, id2) { var schedule = get2(node, id2); if (schedule.state > CREATED) throw new Error("too late; already scheduled"); return schedule; } function set2(node, id2) { var schedule = get2(node, id2); if (schedule.state > STARTED) throw new Error("too late; already running"); return schedule; } function get2(node, id2) { var schedule = node.__transition; if (!schedule || !(schedule = schedule[id2])) throw new Error("transition not found"); return schedule; } function create(node, id2, self) { var schedules = node.__transition, tween; schedules[id2] = self; self.timer = timer(schedule, 0, self.time); function schedule(elapsed) { self.state = SCHEDULED; self.timer.restart(start2, self.delay, self.time); if (self.delay <= elapsed) start2(elapsed - self.delay); } function start2(elapsed) { var i, j, n, o; if (self.state !== SCHEDULED) return stop(); for (i in schedules) { o = schedules[i]; if (o.name !== self.name) continue; if (o.state === STARTED) return timeout_default(start2); if (o.state === RUNNING) { o.state = ENDED; o.timer.stop(); o.on.call("interrupt", node, node.__data__, o.index, o.group); delete schedules[i]; } else if (+i < id2) { o.state = ENDED; o.timer.stop(); o.on.call("cancel", node, node.__data__, o.index, o.group); delete schedules[i]; } } timeout_default(function() { if (self.state === STARTED) { self.state = RUNNING; self.timer.restart(tick, self.delay, self.time); tick(elapsed); } }); self.state = STARTING; self.on.call("start", node, node.__data__, self.index, self.group); if (self.state !== STARTING) return; self.state = STARTED; tween = new Array(n = self.tween.length); for (i = 0, j = -1; i < n; ++i) { if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) { tween[++j] = o; } } tween.length = j + 1; } function tick(elapsed) { var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1), i = -1, n = tween.length; while (++i < n) { tween[i].call(node, t); } if (self.state === ENDING) { self.on.call("end", node, node.__data__, self.index, self.group); stop(); } } function stop() { self.state = ENDED; self.timer.stop(); delete schedules[id2]; for (var i in schedules) return; delete node.__transition; } } // node_modules/d3-transition/src/interrupt.js function interrupt_default(node, name) { var schedules = node.__transition, schedule, active, empty2 = true, i; if (!schedules) return; name = name == null ? null : name + ""; for (i in schedules) { if ((schedule = schedules[i]).name !== name) { empty2 = false; continue; } active = schedule.state > STARTING && schedule.state < ENDING; schedule.state = ENDED; schedule.timer.stop(); schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group); delete schedules[i]; } if (empty2) delete node.__transition; } // node_modules/d3-transition/src/selection/interrupt.js function interrupt_default2(name) { return this.each(function() { interrupt_default(this, name); }); } // node_modules/d3-transition/src/transition/tween.js function tweenRemove(id2, name) { var tween0, tween1; return function() { var schedule = set2(this, id2), tween = schedule.tween; if (tween !== tween0) { tween1 = tween0 = tween; for (var i = 0, n = tween1.length; i < n; ++i) { if (tween1[i].name === name) { tween1 = tween1.slice(); tween1.splice(i, 1); break; } } } schedule.tween = tween1; }; } function tweenFunction(id2, name, value) { var tween0, tween1; if (typeof value !== "function") throw new Error(); return function() { var schedule = set2(this, id2), tween = schedule.tween; if (tween !== tween0) { tween1 = (tween0 = tween).slice(); for (var t = { name, value }, i = 0, n = tween1.length; i < n; ++i) { if (tween1[i].name === name) { tween1[i] = t; break; } } if (i === n) tween1.push(t); } schedule.tween = tween1; }; } function tween_default(name, value) { var id2 = this._id; name += ""; if (arguments.length < 2) { var tween = get2(this.node(), id2).tween; for (var i = 0, n = tween.length, t; i < n; ++i) { if ((t = tween[i]).name === name) { return t.value; } } return null; } return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value)); } function tweenValue(transition2, name, value) { var id2 = transition2._id; transition2.each(function() { var schedule = set2(this, id2); (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments); }); return function(node) { return get2(node, id2).value[name]; }; } // node_modules/d3-transition/src/transition/interpolate.js function interpolate_default(a2, b) { var c2; return (typeof b === "number" ? number_default : b instanceof color ? rgb_default : (c2 = color(b)) ? (b = c2, rgb_default) : string_default)(a2, b); } // node_modules/d3-transition/src/transition/attr.js function attrRemove2(name) { return function() { this.removeAttribute(name); }; } function attrRemoveNS2(fullname) { return function() { this.removeAttributeNS(fullname.space, fullname.local); }; } function attrConstant2(name, interpolate, value1) { var string00, string1 = value1 + "", interpolate0; return function() { var string0 = this.getAttribute(name); return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1); }; } function attrConstantNS2(fullname, interpolate, value1) { var string00, string1 = value1 + "", interpolate0; return function() { var string0 = this.getAttributeNS(fullname.space, fullname.local); return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1); }; } function attrFunction2(name, interpolate, value) { var string00, string10, interpolate0; return function() { var string0, value1 = value(this), string1; if (value1 == null) return void this.removeAttribute(name); string0 = this.getAttribute(name); string1 = value1 + ""; return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); }; } function attrFunctionNS2(fullname, interpolate, value) { var string00, string10, interpolate0; return function() { var string0, value1 = value(this), string1; if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local); string0 = this.getAttributeNS(fullname.space, fullname.local); string1 = value1 + ""; return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); }; } function attr_default2(name, value) { var fullname = namespace_default(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate_default; return this.attrTween(name, typeof value === "function" ? (fullname.local ? attrFunctionNS2 : attrFunction2)(fullname, i, tweenValue(this, "attr." + name, value)) : value == null ? (fullname.local ? attrRemoveNS2 : attrRemove2)(fullname) : (fullname.local ? attrConstantNS2 : attrConstant2)(fullname, i, value)); } // node_modules/d3-transition/src/transition/attrTween.js function attrInterpolate(name, i) { return function(t) { this.setAttribute(name, i.call(this, t)); }; } function attrInterpolateNS(fullname, i) { return function(t) { this.setAttributeNS(fullname.space, fullname.local, i.call(this, t)); }; } function attrTweenNS(fullname, value) { var t0, i0; function tween() { var i = value.apply(this, arguments); if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i); return t0; } tween._value = value; return tween; } function attrTween(name, value) { var t0, i0; function tween() { var i = value.apply(this, arguments); if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i); return t0; } tween._value = value; return tween; } function attrTween_default(name, value) { var key = "attr." + name; if (arguments.length < 2) return (key = this.tween(key)) && key._value; if (value == null) return this.tween(key, null); if (typeof value !== "function") throw new Error(); var fullname = namespace_default(name); return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value)); } // node_modules/d3-transition/src/transition/delay.js function delayFunction(id2, value) { return function() { init(this, id2).delay = +value.apply(this, arguments); }; } function delayConstant(id2, value) { return value = +value, function() { init(this, id2).delay = value; }; } function delay_default(value) { var id2 = this._id; return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get2(this.node(), id2).delay; } // node_modules/d3-transition/src/transition/duration.js function durationFunction(id2, value) { return function() { set2(this, id2).duration = +value.apply(this, arguments); }; } function durationConstant(id2, value) { return value = +value, function() { set2(this, id2).duration = value; }; } function duration_default(value) { var id2 = this._id; return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get2(this.node(), id2).duration; } // node_modules/d3-transition/src/transition/ease.js function easeConstant(id2, value) { if (typeof value !== "function") throw new Error(); return function() { set2(this, id2).ease = value; }; } function ease_default(value) { var id2 = this._id; return arguments.length ? this.each(easeConstant(id2, value)) : get2(this.node(), id2).ease; } // node_modules/d3-transition/src/transition/easeVarying.js function easeVarying(id2, value) { return function() { var v = value.apply(this, arguments); if (typeof v !== "function") throw new Error(); set2(this, id2).ease = v; }; } function easeVarying_default(value) { if (typeof value !== "function") throw new Error(); return this.each(easeVarying(this._id, value)); } // node_modules/d3-transition/src/transition/filter.js function filter_default2(match) { if (typeof match !== "function") match = matcher_default(match); for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { if ((node = group[i]) && match.call(node, node.__data__, i, group)) { subgroup.push(node); } } } return new Transition(subgroups, this._parents, this._name, this._id); } // node_modules/d3-transition/src/transition/merge.js function merge_default2(transition2) { if (transition2._id !== this._id) throw new Error(); for (var groups0 = this._groups, groups1 = transition2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m2; ++j) { for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { if (node = group0[i] || group1[i]) { merge[i] = node; } } } for (; j < m0; ++j) { merges[j] = groups0[j]; } return new Transition(merges, this._parents, this._name, this._id); } // node_modules/d3-transition/src/transition/on.js function start(name) { return (name + "").trim().split(/^|\s+/).every(function(t) { var i = t.indexOf("."); if (i >= 0) t = t.slice(0, i); return !t || t === "start"; }); } function onFunction(id2, name, listener) { var on0, on1, sit = start(name) ? init : set2; return function() { var schedule = sit(this, id2), on = schedule.on; if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener); schedule.on = on1; }; } function on_default2(name, listener) { var id2 = this._id; return arguments.length < 2 ? get2(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener)); } // node_modules/d3-transition/src/transition/remove.js function removeFunction(id2) { return function() { var parent = this.parentNode; for (var i in this.__transition) if (+i !== id2) return; if (parent) parent.removeChild(this); }; } function remove_default2() { return this.on("end.remove", removeFunction(this._id)); } // node_modules/d3-transition/src/transition/select.js function select_default3(select) { var name = this._name, id2 = this._id; if (typeof select !== "function") select = selector_default(select); for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { if ("__data__" in node) subnode.__data__ = node.__data__; subgroup[i] = subnode; schedule_default(subgroup[i], name, id2, i, subgroup, get2(node, id2)); } } } return new Transition(subgroups, this._parents, name, id2); } // node_modules/d3-transition/src/transition/selectAll.js function selectAll_default2(select) { var name = this._name, id2 = this._id; if (typeof select !== "function") select = selectorAll_default(select); for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { if (node = group[i]) { for (var children2 = select.call(node, node.__data__, i, group), child, inherit2 = get2(node, id2), k = 0, l = children2.length; k < l; ++k) { if (child = children2[k]) { schedule_default(child, name, id2, k, children2, inherit2); } } subgroups.push(children2); parents.push(node); } } } return new Transition(subgroups, parents, name, id2); } // node_modules/d3-transition/src/transition/selection.js var Selection2 = selection_default.prototype.constructor; function selection_default2() { return new Selection2(this._groups, this._parents); } // node_modules/d3-transition/src/transition/style.js function styleNull(name, interpolate) { var string00, string10, interpolate0; return function() { var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name)); return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate(string00 = string0, string10 = string1); }; } function styleRemove2(name) { return function() { this.style.removeProperty(name); }; } function styleConstant2(name, interpolate, value1) { var string00, string1 = value1 + "", interpolate0; return function() { var string0 = styleValue(this, name); return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1); }; } function styleFunction2(name, interpolate, value) { var string00, string10, interpolate0; return function() { var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + ""; if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name)); return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); }; } function styleMaybeRemove(id2, name) { var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2; return function() { var schedule = set2(this, id2), on = schedule.on, listener = schedule.value[key] == null ? remove2 || (remove2 = styleRemove2(name)) : void 0; if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener); schedule.on = on1; }; } function style_default2(name, value, priority) { var i = (name += "") === "transform" ? interpolateTransformCss : interpolate_default; return value == null ? this.styleTween(name, styleNull(name, i)).on("end.style." + name, styleRemove2(name)) : typeof value === "function" ? this.styleTween(name, styleFunction2(name, i, tweenValue(this, "style." + name, value))).each(styleMaybeRemove(this._id, name)) : this.styleTween(name, styleConstant2(name, i, value), priority).on("end.style." + name, null); } // node_modules/d3-transition/src/transition/styleTween.js function styleInterpolate(name, i, priority) { return function(t) { this.style.setProperty(name, i.call(this, t), priority); }; } function styleTween(name, value, priority) { var t, i0; function tween() { var i = value.apply(this, arguments); if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority); return t; } tween._value = value; return tween; } function styleTween_default(name, value, priority) { var key = "style." + (name += ""); if (arguments.length < 2) return (key = this.tween(key)) && key._value; if (value == null) return this.tween(key, null); if (typeof value !== "function") throw new Error(); return this.tween(key, styleTween(name, value, priority == null ? "" : priority)); } // node_modules/d3-transition/src/transition/text.js function textConstant2(value) { return function() { this.textContent = value; }; } function textFunction2(value) { return function() { var value1 = value(this); this.textContent = value1 == null ? "" : value1; }; } function text_default2(value) { return this.tween("text", typeof value === "function" ? textFunction2(tweenValue(this, "text", value)) : textConstant2(value == null ? "" : value + "")); } // node_modules/d3-transition/src/transition/textTween.js function textInterpolate(i) { return function(t) { this.textContent = i.call(this, t); }; } function textTween(value) { var t0, i0; function tween() { var i = value.apply(this, arguments); if (i !== i0) t0 = (i0 = i) && textInterpolate(i); return t0; } tween._value = value; return tween; } function textTween_default(value) { var key = "text"; if (arguments.length < 1) return (key = this.tween(key)) && key._value; if (value == null) return this.tween(key, null); if (typeof value !== "function") throw new Error(); return this.tween(key, textTween(value)); } // node_modules/d3-transition/src/transition/transition.js function transition_default() { var name = this._name, id0 = this._id, id1 = newId(); for (var groups = this._groups, m2 = groups.length, j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { if (node = group[i]) { var inherit2 = get2(node, id0); schedule_default(node, name, id1, i, group, { time: inherit2.time + inherit2.delay + inherit2.duration, delay: 0, duration: inherit2.duration, ease: inherit2.ease }); } } } return new Transition(groups, this._parents, name, id1); } // node_modules/d3-transition/src/transition/end.js function end_default() { var on0, on1, that = this, id2 = that._id, size = that.size(); return new Promise(function(resolve, reject) { var cancel = { value: reject }, end = { value: function() { if (--size === 0) resolve(); } }; that.each(function() { var schedule = set2(this, id2), on = schedule.on; if (on !== on0) { on1 = (on0 = on).copy(); on1._.cancel.push(cancel); on1._.interrupt.push(cancel); on1._.end.push(end); } schedule.on = on1; }); if (size === 0) resolve(); }); } // node_modules/d3-transition/src/transition/index.js var id = 0; function Transition(groups, parents, name, id2) { this._groups = groups; this._parents = parents; this._name = name; this._id = id2; } function transition(name) { return selection_default().transition(name); } function newId() { return ++id; } var selection_prototype = selection_default.prototype; Transition.prototype = transition.prototype = { constructor: Transition, select: select_default3, selectAll: selectAll_default2, selectChild: selection_prototype.selectChild, selectChildren: selection_prototype.selectChildren, filter: filter_default2, merge: merge_default2, selection: selection_default2, transition: transition_default, call: selection_prototype.call, nodes: selection_prototype.nodes, node: selection_prototype.node, size: selection_prototype.size, empty: selection_prototype.empty, each: selection_prototype.each, on: on_default2, attr: attr_default2, attrTween: attrTween_default, style: style_default2, styleTween: styleTween_default, text: text_default2, textTween: textTween_default, remove: remove_default2, tween: tween_default, delay: delay_default, duration: duration_default, ease: ease_default, easeVarying: easeVarying_default, end: end_default, [Symbol.iterator]: selection_prototype[Symbol.iterator] }; // node_modules/d3-ease/src/cubic.js function cubicInOut(t) { return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; } // node_modules/d3-transition/src/selection/transition.js var defaultTiming = { time: null, // Set on use. delay: 0, duration: 250, ease: cubicInOut }; function inherit(node, id2) { var timing; while (!(timing = node.__transition) || !(timing = timing[id2])) { if (!(node = node.parentNode)) { throw new Error(`transition ${id2} not found`); } } return timing; } function transition_default2(name) { var id2, timing; if (name instanceof Transition) { id2 = name._id, name = name._name; } else { id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + ""; } for (var groups = this._groups, m2 = groups.length, j = 0; j < m2; ++j) { for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { if (node = group[i]) { schedule_default(node, name, id2, i, group, timing || inherit(node, id2)); } } } return new Transition(groups, this._parents, name, id2); } // node_modules/d3-transition/src/selection/index.js selection_default.prototype.interrupt = interrupt_default2; selection_default.prototype.transition = transition_default2; // node_modules/d3-brush/src/brush.js var { abs, max, min } = Math; function number1(e) { return [+e[0], +e[1]]; } function number2(e) { return [number1(e[0]), number1(e[1])]; } var X = { name: "x", handles: ["w", "e"].map(type), input: function(x3, e) { return x3 == null ? null : [[+x3[0], e[0][1]], [+x3[1], e[1][1]]]; }, output: function(xy) { return xy && [xy[0][0], xy[1][0]]; } }; var Y = { name: "y", handles: ["n", "s"].map(type), input: function(y3, e) { return y3 == null ? null : [[e[0][0], +y3[0]], [e[1][0], +y3[1]]]; }, output: function(xy) { return xy && [xy[0][1], xy[1][1]]; } }; var XY = { name: "xy", handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type), input: function(xy) { return xy == null ? null : number2(xy); }, output: function(xy) { return xy; } }; function type(t) { return { type: t }; } // node_modules/d3-force/src/center.js function center_default(x3, y3) { var nodes, strength = 1; if (x3 == null) x3 = 0; if (y3 == null) y3 = 0; function force() { var i, n = nodes.length, node, sx = 0, sy = 0; for (i = 0; i < n; ++i) { node = nodes[i], sx += node.x, sy += node.y; } for (sx = (sx / n - x3) * strength, sy = (sy / n - y3) * strength, i = 0; i < n; ++i) { node = nodes[i], node.x -= sx, node.y -= sy; } } force.initialize = function(_) { nodes = _; }; force.x = function(_) { return arguments.length ? (x3 = +_, force) : x3; }; force.y = function(_) { return arguments.length ? (y3 = +_, force) : y3; }; force.strength = function(_) { return arguments.length ? (strength = +_, force) : strength; }; return force; } // node_modules/d3-quadtree/src/add.js function add_default(d) { const x3 = +this._x.call(null, d), y3 = +this._y.call(null, d); return add(this.cover(x3, y3), x3, y3, d); } function add(tree, x3, y3, d) { if (isNaN(x3) || isNaN(y3)) return tree; var parent, node = tree._root, leaf = { data: d }, x0 = tree._x0, y0 = tree._y0, x1 = tree._x1, y1 = tree._y1, xm, ym, xp, yp, right, bottom, i, j; if (!node) return tree._root = leaf, tree; while (node.length) { if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm; if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym; if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree; } xp = +tree._x.call(null, node.data); yp = +tree._y.call(null, node.data); if (x3 === xp && y3 === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree; do { parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4); if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm; if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym; } while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm)); return parent[j] = node, parent[i] = leaf, tree; } function addAll(data) { var d, i, n = data.length, x3, y3, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity; for (i = 0; i < n; ++i) { if (isNaN(x3 = +this._x.call(null, d = data[i])) || isNaN(y3 = +this._y.call(null, d))) continue; xz[i] = x3; yz[i] = y3; if (x3 < x0) x0 = x3; if (x3 > x1) x1 = x3; if (y3 < y0) y0 = y3; if (y3 > y1) y1 = y3; } if (x0 > x1 || y0 > y1) return this; this.cover(x0, y0).cover(x1, y1); for (i = 0; i < n; ++i) { add(this, xz[i], yz[i], data[i]); } return this; } // node_modules/d3-quadtree/src/cover.js function cover_default(x3, y3) { if (isNaN(x3 = +x3) || isNaN(y3 = +y3)) return this; var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1; if (isNaN(x0)) { x1 = (x0 = Math.floor(x3)) + 1; y1 = (y0 = Math.floor(y3)) + 1; } else { var z = x1 - x0 || 1, node = this._root, parent, i; while (x0 > x3 || x3 >= x1 || y0 > y3 || y3 >= y1) { i = (y3 < y0) << 1 | x3 < x0; parent = new Array(4), parent[i] = node, node = parent, z *= 2; switch (i) { case 0: x1 = x0 + z, y1 = y0 + z; break; case 1: x0 = x1 - z, y1 = y0 + z; break; case 2: x1 = x0 + z, y0 = y1 - z; break; case 3: x0 = x1 - z, y0 = y1 - z; break; } } if (this._root && this._root.length) this._root = node; } this._x0 = x0; this._y0 = y0; this._x1 = x1; this._y1 = y1; return this; } // node_modules/d3-quadtree/src/data.js function data_default2() { var data = []; this.visit(function(node) { if (!node.length) do data.push(node.data); while (node = node.next); }); return data; } // node_modules/d3-quadtree/src/extent.js function extent_default(_) { return arguments.length ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]]; } // node_modules/d3-quadtree/src/quad.js function quad_default(node, x0, y0, x1, y1) { this.node = node; this.x0 = x0; this.y0 = y0; this.x1 = x1; this.y1 = y1; } // node_modules/d3-quadtree/src/find.js function find_default(x3, y3, radius) { var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22, x32 = this._x1, y32 = this._y1, quads = [], node = this._root, q, i; if (node) quads.push(new quad_default(node, x0, y0, x32, y32)); if (radius == null) radius = Infinity; else { x0 = x3 - radius, y0 = y3 - radius; x32 = x3 + radius, y32 = y3 + radius; radius *= radius; } while (q = quads.pop()) { if (!(node = q.node) || (x1 = q.x0) > x32 || (y1 = q.y0) > y32 || (x22 = q.x1) < x0 || (y22 = q.y1) < y0) continue; if (node.length) { var xm = (x1 + x22) / 2, ym = (y1 + y22) / 2; quads.push( new quad_default(node[3], xm, ym, x22, y22), new quad_default(node[2], x1, ym, xm, y22), new quad_default(node[1], xm, y1, x22, ym), new quad_default(node[0], x1, y1, xm, ym) ); if (i = (y3 >= ym) << 1 | x3 >= xm) { q = quads[quads.length - 1]; quads[quads.length - 1] = quads[quads.length - 1 - i]; quads[quads.length - 1 - i] = q; } } else { var dx = x3 - +this._x.call(null, node.data), dy = y3 - +this._y.call(null, node.data), d2 = dx * dx + dy * dy; if (d2 < radius) { var d = Math.sqrt(radius = d2); x0 = x3 - d, y0 = y3 - d; x32 = x3 + d, y32 = y3 + d; data = node.data; } } } return data; } // node_modules/d3-quadtree/src/remove.js function remove_default3(d) { if (isNaN(x3 = +this._x.call(null, d)) || isNaN(y3 = +this._y.call(null, d))) return this; var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1, x3, y3, xm, ym, right, bottom, i, j; if (!node) return this; if (node.length) while (true) { if (right = x3 >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm; if (bottom = y3 >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym; if (!(parent = node, node = node[i = bottom << 1 | right])) return this; if (!node.length) break; if (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3]) retainer = parent, j = i; } while (node.data !== d) if (!(previous = node, node = node.next)) return this; if (next = node.next) delete node.next; if (previous) return next ? previous.next = next : delete previous.next, this; if (!parent) return this._root = next, this; next ? parent[i] = next : delete parent[i]; if ((node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length) { if (retainer) retainer[j] = node; else this._root = node; } return this; } function removeAll(data) { for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]); return this; } // node_modules/d3-quadtree/src/root.js function root_default() { return this._root; } // node_modules/d3-quadtree/src/size.js function size_default2() { var size = 0; this.visit(function(node) { if (!node.length) do ++size; while (node = node.next); }); return size; } // node_modules/d3-quadtree/src/visit.js function visit_default(callback) { var quads = [], q, node = this._root, child, x0, y0, x1, y1; if (node) quads.push(new quad_default(node, this._x0, this._y0, this._x1, this._y1)); while (q = quads.pop()) { if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) { var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2; if (child = node[3]) quads.push(new quad_default(child, xm, ym, x1, y1)); if (child = node[2]) quads.push(new quad_default(child, x0, ym, xm, y1)); if (child = node[1]) quads.push(new quad_default(child, xm, y0, x1, ym)); if (child = node[0]) quads.push(new quad_default(child, x0, y0, xm, ym)); } } return this; } // node_modules/d3-quadtree/src/visitAfter.js function visitAfter_default(callback) { var quads = [], next = [], q; if (this._root) quads.push(new quad_default(this._root, this._x0, this._y0, this._x1, this._y1)); while (q = quads.pop()) { var node = q.node; if (node.length) { var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2; if (child = node[0]) quads.push(new quad_default(child, x0, y0, xm, ym)); if (child = node[1]) quads.push(new quad_default(child, xm, y0, x1, ym)); if (child = node[2]) quads.push(new quad_default(child, x0, ym, xm, y1)); if (child = node[3]) quads.push(new quad_default(child, xm, ym, x1, y1)); } next.push(q); } while (q = next.pop()) { callback(q.node, q.x0, q.y0, q.x1, q.y1); } return this; } // node_modules/d3-quadtree/src/x.js function defaultX(d) { return d[0]; } function x_default(_) { return arguments.length ? (this._x = _, this) : this._x; } // node_modules/d3-quadtree/src/y.js function defaultY(d) { return d[1]; } function y_default(_) { return arguments.length ? (this._y = _, this) : this._y; } // node_modules/d3-quadtree/src/quadtree.js function quadtree(nodes, x3, y3) { var tree = new Quadtree(x3 == null ? defaultX : x3, y3 == null ? defaultY : y3, NaN, NaN, NaN, NaN); return nodes == null ? tree : tree.addAll(nodes); } function Quadtree(x3, y3, x0, y0, x1, y1) { this._x = x3; this._y = y3; this._x0 = x0; this._y0 = y0; this._x1 = x1; this._y1 = y1; this._root = void 0; } function leaf_copy(leaf) { var copy2 = { data: leaf.data }, next = copy2; while (leaf = leaf.next) next = next.next = { data: leaf.data }; return copy2; } var treeProto = quadtree.prototype = Quadtree.prototype; treeProto.copy = function() { var copy2 = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), node = this._root, nodes, child; if (!node) return copy2; if (!node.length) return copy2._root = leaf_copy(node), copy2; nodes = [{ source: node, target: copy2._root = new Array(4) }]; while (node = nodes.pop()) { for (var i = 0; i < 4; ++i) { if (child = node.source[i]) { if (child.length) nodes.push({ source: child, target: node.target[i] = new Array(4) }); else node.target[i] = leaf_copy(child); } } } return copy2; }; treeProto.add = add_default; treeProto.addAll = addAll; treeProto.cover = cover_default; treeProto.data = data_default2; treeProto.extent = extent_default; treeProto.find = find_default; treeProto.remove = remove_default3; treeProto.removeAll = removeAll; treeProto.root = root_default; treeProto.size = size_default2; treeProto.visit = visit_default; treeProto.visitAfter = visitAfter_default; treeProto.x = x_default; treeProto.y = y_default; // node_modules/d3-force/src/constant.js function constant_default5(x3) { return function() { return x3; }; } // node_modules/d3-force/src/jiggle.js function jiggle_default(random) { return (random() - 0.5) * 1e-6; } // node_modules/d3-force/src/collide.js function x(d) { return d.x + d.vx; } function y(d) { return d.y + d.vy; } function collide_default(radius) { var nodes, radii, random, strength = 1, iterations = 1; if (typeof radius !== "function") radius = constant_default5(radius == null ? 1 : +radius); function force() { var i, n = nodes.length, tree, node, xi, yi, ri, ri2; for (var k = 0; k < iterations; ++k) { tree = quadtree(nodes, x, y).visitAfter(prepare); for (i = 0; i < n; ++i) { node = nodes[i]; ri = radii[node.index], ri2 = ri * ri; xi = node.x + node.vx; yi = node.y + node.vy; tree.visit(apply); } } function apply(quad, x0, y0, x1, y1) { var data = quad.data, rj = quad.r, r = ri + rj; if (data) { if (data.index > node.index) { var x3 = xi - data.x - data.vx, y3 = yi - data.y - data.vy, l = x3 * x3 + y3 * y3; if (l < r * r) { if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3; if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3; l = (r - (l = Math.sqrt(l))) / l * strength; node.vx += (x3 *= l) * (r = (rj *= rj) / (ri2 + rj)); node.vy += (y3 *= l) * r; data.vx -= x3 * (r = 1 - r); data.vy -= y3 * r; } } return; } return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r; } } function prepare(quad) { if (quad.data) return quad.r = radii[quad.data.index]; for (var i = quad.r = 0; i < 4; ++i) { if (quad[i] && quad[i].r > quad.r) { quad.r = quad[i].r; } } } function initialize() { if (!nodes) return; var i, n = nodes.length, node; radii = new Array(n); for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes); } force.initialize = function(_nodes, _random) { nodes = _nodes; random = _random; initialize(); }; force.iterations = function(_) { return arguments.length ? (iterations = +_, force) : iterations; }; force.strength = function(_) { return arguments.length ? (strength = +_, force) : strength; }; force.radius = function(_) { return arguments.length ? (radius = typeof _ === "function" ? _ : constant_default5(+_), initialize(), force) : radius; }; return force; } // node_modules/d3-force/src/link.js function index(d) { return d.index; } function find2(nodeById, nodeId) { var node = nodeById.get(nodeId); if (!node) throw new Error("node not found: " + nodeId); return node; } function link_default(links) { var id2 = index, strength = defaultStrength, strengths, distance = constant_default5(30), distances, nodes, count, bias, random, iterations = 1; if (links == null) links = []; function defaultStrength(link) { return 1 / Math.min(count[link.source.index], count[link.target.index]); } function force(alpha) { for (var k = 0, n = links.length; k < iterations; ++k) { for (var i = 0, link, source, target, x3, y3, l, b; i < n; ++i) { link = links[i], source = link.source, target = link.target; x3 = target.x + target.vx - source.x - source.vx || jiggle_default(random); y3 = target.y + target.vy - source.y - source.vy || jiggle_default(random); l = Math.sqrt(x3 * x3 + y3 * y3); l = (l - distances[i]) / l * alpha * strengths[i]; x3 *= l, y3 *= l; target.vx -= x3 * (b = bias[i]); target.vy -= y3 * b; source.vx += x3 * (b = 1 - b); source.vy += y3 * b; } } } function initialize() { if (!nodes) return; var i, n = nodes.length, m2 = links.length, nodeById = new Map(nodes.map((d, i2) => [id2(d, i2, nodes), d])), link; for (i = 0, count = new Array(n); i < m2; ++i) { link = links[i], link.index = i; if (typeof link.source !== "object") link.source = find2(nodeById, link.source); if (typeof link.target !== "object") link.target = find2(nodeById, link.target); count[link.source.index] = (count[link.source.index] || 0) + 1; count[link.target.index] = (count[link.target.index] || 0) + 1; } for (i = 0, bias = new Array(m2); i < m2; ++i) { link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]); } strengths = new Array(m2), initializeStrength(); distances = new Array(m2), initializeDistance(); } function initializeStrength() { if (!nodes) return; for (var i = 0, n = links.length; i < n; ++i) { strengths[i] = +strength(links[i], i, links); } } function initializeDistance() { if (!nodes) return; for (var i = 0, n = links.length; i < n; ++i) { distances[i] = +distance(links[i], i, links); } } force.initialize = function(_nodes, _random) { nodes = _nodes; random = _random; initialize(); }; force.links = function(_) { return arguments.length ? (links = _, initialize(), force) : links; }; force.id = function(_) { return arguments.length ? (id2 = _, force) : id2; }; force.iterations = function(_) { return arguments.length ? (iterations = +_, force) : iterations; }; force.strength = function(_) { return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default5(+_), initializeStrength(), force) : strength; }; force.distance = function(_) { return arguments.length ? (distance = typeof _ === "function" ? _ : constant_default5(+_), initializeDistance(), force) : distance; }; return force; } // node_modules/d3-force/src/lcg.js var a = 1664525; var c = 1013904223; var m = 4294967296; function lcg_default() { let s = 1; return () => (s = (a * s + c) % m) / m; } // node_modules/d3-force/src/simulation.js function x2(d) { return d.x; } function y2(d) { return d.y; } var initialRadius = 10; var initialAngle = Math.PI * (3 - Math.sqrt(5)); function simulation_default(nodes) { var simulation, alpha = 1, alphaMin = 1e-3, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = /* @__PURE__ */ new Map(), stepper = timer(step), event = dispatch_default("tick", "end"), random = lcg_default(); if (nodes == null) nodes = []; function step() { tick(); event.call("tick", simulation); if (alpha < alphaMin) { stepper.stop(); event.call("end", simulation); } } function tick(iterations) { var i, n = nodes.length, node; if (iterations === void 0) iterations = 1; for (var k = 0; k < iterations; ++k) { alpha += (alphaTarget - alpha) * alphaDecay; forces.forEach(function(force) { force(alpha); }); for (i = 0; i < n; ++i) { node = nodes[i]; if (node.fx == null) node.x += node.vx *= velocityDecay; else node.x = node.fx, node.vx = 0; if (node.fy == null) node.y += node.vy *= velocityDecay; else node.y = node.fy, node.vy = 0; } } return simulation; } function initializeNodes() { for (var i = 0, n = nodes.length, node; i < n; ++i) { node = nodes[i], node.index = i; if (node.fx != null) node.x = node.fx; if (node.fy != null) node.y = node.fy; if (isNaN(node.x) || isNaN(node.y)) { var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle; node.x = radius * Math.cos(angle); node.y = radius * Math.sin(angle); } if (isNaN(node.vx) || isNaN(node.vy)) { node.vx = node.vy = 0; } } } function initializeForce(force) { if (force.initialize) force.initialize(nodes, random); return force; } initializeNodes(); return simulation = { tick, restart: function() { return stepper.restart(step), simulation; }, stop: function() { return stepper.stop(), simulation; }, nodes: function(_) { return arguments.length ? (nodes = _, initializeNodes(), forces.forEach(initializeForce), simulation) : nodes; }, alpha: function(_) { return arguments.length ? (alpha = +_, simulation) : alpha; }, alphaMin: function(_) { return arguments.length ? (alphaMin = +_, simulation) : alphaMin; }, alphaDecay: function(_) { return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay; }, alphaTarget: function(_) { return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget; }, velocityDecay: function(_) { return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay; }, randomSource: function(_) { return arguments.length ? (random = _, forces.forEach(initializeForce), simulation) : random; }, force: function(name, _) { return arguments.length > 1 ? (_ == null ? forces.delete(name) : forces.set(name, initializeForce(_)), simulation) : forces.get(name); }, find: function(x3, y3, radius) { var i = 0, n = nodes.length, dx, dy, d2, node, closest; if (radius == null) radius = Infinity; else radius *= radius; for (i = 0; i < n; ++i) { node = nodes[i]; dx = x3 - node.x; dy = y3 - node.y; d2 = dx * dx + dy * dy; if (d2 < radius) closest = node, radius = d2; } return closest; }, on: function(name, _) { return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name); } }; } // node_modules/d3-force/src/manyBody.js function manyBody_default() { var nodes, node, random, alpha, strength = constant_default5(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81; function force(_) { var i, n = nodes.length, tree = quadtree(nodes, x2, y2).visitAfter(accumulate); for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply); } function initialize() { if (!nodes) return; var i, n = nodes.length, node2; strengths = new Array(n); for (i = 0; i < n; ++i) node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes); } function accumulate(quad) { var strength2 = 0, q, c2, weight = 0, x3, y3, i; if (quad.length) { for (x3 = y3 = i = 0; i < 4; ++i) { if ((q = quad[i]) && (c2 = Math.abs(q.value))) { strength2 += q.value, weight += c2, x3 += c2 * q.x, y3 += c2 * q.y; } } quad.x = x3 / weight; quad.y = y3 / weight; } else { q = quad; q.x = q.data.x; q.y = q.data.y; do strength2 += strengths[q.data.index]; while (q = q.next); } quad.value = strength2; } function apply(quad, x1, _, x22) { if (!quad.value) return true; var x3 = quad.x - node.x, y3 = quad.y - node.y, w = x22 - x1, l = x3 * x3 + y3 * y3; if (w * w / theta2 < l) { if (l < distanceMax2) { if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3; if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3; if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l); node.vx += x3 * quad.value * alpha / l; node.vy += y3 * quad.value * alpha / l; } return true; } else if (quad.length || l >= distanceMax2) return; if (quad.data !== node || quad.next) { if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3; if (y3 === 0) y3 = jiggle_default(random), l += y3 * y3; if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l); } do if (quad.data !== node) { w = strengths[quad.data.index] * alpha / l; node.vx += x3 * w; node.vy += y3 * w; } while (quad = quad.next); } force.initialize = function(_nodes, _random) { nodes = _nodes; random = _random; initialize(); }; force.strength = function(_) { return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default5(+_), initialize(), force) : strength; }; force.distanceMin = function(_) { return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2); }; force.distanceMax = function(_) { return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2); }; force.theta = function(_) { return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2); }; return force; } // node_modules/d3-format/src/formatDecimal.js function formatDecimal_default(x3) { return Math.abs(x3 = Math.round(x3)) >= 1e21 ? x3.toLocaleString("en").replace(/,/g, "") : x3.toString(10); } function formatDecimalParts(x3, p) { if ((i = (x3 = p ? x3.toExponential(p - 1) : x3.toExponential()).indexOf("e")) < 0) return null; var i, coefficient = x3.slice(0, i); return [ coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, +x3.slice(i + 1) ]; } // node_modules/d3-format/src/exponent.js function exponent_default(x3) { return x3 = formatDecimalParts(Math.abs(x3)), x3 ? x3[1] : NaN; } // node_modules/d3-format/src/formatGroup.js function formatGroup_default(grouping, thousands) { return function(value, width) { var i = value.length, t = [], j = 0, g = grouping[0], length = 0; while (i > 0 && g > 0) { if (length + g + 1 > width) g = Math.max(1, width - length); t.push(value.substring(i -= g, i + g)); if ((length += g + 1) > width) break; g = grouping[j = (j + 1) % grouping.length]; } return t.reverse().join(thousands); }; } // node_modules/d3-format/src/formatNumerals.js function formatNumerals_default(numerals) { return function(value) { return value.replace(/[0-9]/g, function(i) { return numerals[+i]; }); }; } // node_modules/d3-format/src/formatSpecifier.js var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; function formatSpecifier(specifier) { if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); var match; return new FormatSpecifier({ fill: match[1], align: match[2], sign: match[3], symbol: match[4], zero: match[5], width: match[6], comma: match[7], precision: match[8] && match[8].slice(1), trim: match[9], type: match[10] }); } formatSpecifier.prototype = FormatSpecifier.prototype; function FormatSpecifier(specifier) { this.fill = specifier.fill === void 0 ? " " : specifier.fill + ""; this.align = specifier.align === void 0 ? ">" : specifier.align + ""; this.sign = specifier.sign === void 0 ? "-" : specifier.sign + ""; this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + ""; this.zero = !!specifier.zero; this.width = specifier.width === void 0 ? void 0 : +specifier.width; this.comma = !!specifier.comma; this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision; this.trim = !!specifier.trim; this.type = specifier.type === void 0 ? "" : specifier.type + ""; } FormatSpecifier.prototype.toString = function() { return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type; }; // node_modules/d3-format/src/formatTrim.js function formatTrim_default(s) { out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { switch (s[i]) { case ".": i0 = i1 = i; break; case "0": if (i0 === 0) i0 = i; i1 = i; break; default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break; } } return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; } // node_modules/d3-format/src/formatPrefixAuto.js var prefixExponent; function formatPrefixAuto_default(x3, p) { var d = formatDecimalParts(x3, p); if (!d) return x3 + ""; var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length; return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x3, Math.max(0, p + i - 1))[0]; } // node_modules/d3-format/src/formatRounded.js function formatRounded_default(x3, p) { var d = formatDecimalParts(x3, p); if (!d) return x3 + ""; var coefficient = d[0], exponent = d[1]; return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0"); } // node_modules/d3-format/src/formatTypes.js var formatTypes_default = { "%": (x3, p) => (x3 * 100).toFixed(p), "b": (x3) => Math.round(x3).toString(2), "c": (x3) => x3 + "", "d": formatDecimal_default, "e": (x3, p) => x3.toExponential(p), "f": (x3, p) => x3.toFixed(p), "g": (x3, p) => x3.toPrecision(p), "o": (x3) => Math.round(x3).toString(8), "p": (x3, p) => formatRounded_default(x3 * 100, p), "r": formatRounded_default, "s": formatPrefixAuto_default, "X": (x3) => Math.round(x3).toString(16).toUpperCase(), "x": (x3) => Math.round(x3).toString(16) }; // node_modules/d3-format/src/identity.js function identity_default(x3) { return x3; } // node_modules/d3-format/src/locale.js var map = Array.prototype.map; var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; function locale_default(locale2) { var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default : formatGroup_default(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity_default : formatNumerals_default(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "\u2212" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + ""; function newFormat(specifier) { specifier = formatSpecifier(specifier); var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type2 = specifier.type; if (type2 === "n") comma = true, type2 = "g"; else if (!formatTypes_default[type2]) precision === void 0 && (precision = 12), trim = true, type2 = "g"; if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "="; var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : ""; var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2); precision = precision === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); function format2(value) { var valuePrefix = prefix, valueSuffix = suffix, i, n, c2; if (type2 === "c") { valueSuffix = formatType(value) + valueSuffix; value = ""; } else { value = +value; var valueNegative = value < 0 || 1 / value < 0; value = isNaN(value) ? nan : formatType(Math.abs(value), precision); if (trim) value = formatTrim_default(value); if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); if (maybeSuffix) { i = -1, n = value.length; while (++i < n) { if (c2 = value.charCodeAt(i), 48 > c2 || c2 > 57) { valueSuffix = (c2 === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; value = value.slice(0, i); break; } } } } if (comma && !zero3) value = group(value, Infinity); var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : ""; if (comma && zero3) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; switch (align) { case "<": value = valuePrefix + value + valueSuffix + padding; break; case "=": value = valuePrefix + padding + value + valueSuffix; break; case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; default: value = padding + valuePrefix + value + valueSuffix; break; } return numerals(value); } format2.toString = function() { return specifier + ""; }; return format2; } function formatPrefix2(specifier, value) { var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3, k = Math.pow(10, -e), prefix = prefixes[8 + e / 3]; return function(value2) { return f(k * value2) + prefix; }; } return { format: newFormat, formatPrefix: formatPrefix2 }; } // node_modules/d3-format/src/defaultLocale.js var locale; var format; var formatPrefix; defaultLocale({ thousands: ",", grouping: [3], currency: ["$", ""] }); function defaultLocale(definition) { locale = locale_default(definition); format = locale.format; formatPrefix = locale.formatPrefix; return locale; } // node_modules/d3-format/src/precisionFixed.js function precisionFixed_default(step) { return Math.max(0, -exponent_default(Math.abs(step))); } // node_modules/d3-format/src/precisionPrefix.js function precisionPrefix_default(step, value) { return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step))); } // node_modules/d3-format/src/precisionRound.js function precisionRound_default(step, max2) { step = Math.abs(step), max2 = Math.abs(max2) - step; return Math.max(0, exponent_default(max2) - exponent_default(step)) + 1; } // node_modules/d3-scale/src/init.js function initRange(domain, range) { switch (arguments.length) { case 0: break; case 1: this.range(domain); break; default: this.range(range).domain(domain); break; } return this; } // node_modules/d3-scale/src/constant.js function constants(x3) { return function() { return x3; }; } // node_modules/d3-scale/src/number.js function number3(x3) { return +x3; } // node_modules/d3-scale/src/continuous.js var unit = [0, 1]; function identity2(x3) { return x3; } function normalize(a2, b) { return (b -= a2 = +a2) ? function(x3) { return (x3 - a2) / b; } : constants(isNaN(b) ? NaN : 0.5); } function clamper(a2, b) { var t; if (a2 > b) t = a2, a2 = b, b = t; return function(x3) { return Math.max(a2, Math.min(b, x3)); }; } function bimap(domain, range, interpolate) { var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); else d0 = normalize(d0, d1), r0 = interpolate(r0, r1); return function(x3) { return r0(d0(x3)); }; } function polymap(domain, range, interpolate) { var j = Math.min(domain.length, range.length) - 1, d = new Array(j), r = new Array(j), i = -1; if (domain[j] < domain[0]) { domain = domain.slice().reverse(); range = range.slice().reverse(); } while (++i < j) { d[i] = normalize(domain[i], domain[i + 1]); r[i] = interpolate(range[i], range[i + 1]); } return function(x3) { var i2 = bisect_default(domain, x3, 1, j) - 1; return r[i2](d[i2](x3)); }; } function copy(source, target) { return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown()); } function transformer() { var domain = unit, range = unit, interpolate = value_default, transform2, untransform, unknown, clamp = identity2, piecewise, output, input; function rescale() { var n = Math.min(domain.length, range.length); if (clamp !== identity2) clamp = clamper(domain[0], domain[n - 1]); piecewise = n > 2 ? polymap : bimap; output = input = null; return scale; } function scale(x3) { return x3 == null || isNaN(x3 = +x3) ? unknown : (output || (output = piecewise(domain.map(transform2), range, interpolate)))(transform2(clamp(x3))); } scale.invert = function(y3) { return clamp(untransform((input || (input = piecewise(range, domain.map(transform2), number_default)))(y3))); }; scale.domain = function(_) { return arguments.length ? (domain = Array.from(_, number3), rescale()) : domain.slice(); }; scale.range = function(_) { return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); }; scale.rangeRound = function(_) { return range = Array.from(_), interpolate = round_default, rescale(); }; scale.clamp = function(_) { return arguments.length ? (clamp = _ ? true : identity2, rescale()) : clamp !== identity2; }; scale.interpolate = function(_) { return arguments.length ? (interpolate = _, rescale()) : interpolate; }; scale.unknown = function(_) { return arguments.length ? (unknown = _, scale) : unknown; }; return function(t, u) { transform2 = t, untransform = u; return rescale(); }; } function continuous() { return transformer()(identity2, identity2); } // node_modules/d3-scale/src/tickFormat.js function tickFormat(start2, stop, count, specifier) { var step = tickStep(start2, stop, count), precision; specifier = formatSpecifier(specifier == null ? ",f" : specifier); switch (specifier.type) { case "s": { var value = Math.max(Math.abs(start2), Math.abs(stop)); if (specifier.precision == null && !isNaN(precision = precisionPrefix_default(step, value))) specifier.precision = precision; return formatPrefix(specifier, value); } case "": case "e": case "g": case "p": case "r": { if (specifier.precision == null && !isNaN(precision = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); break; } case "f": case "%": { if (specifier.precision == null && !isNaN(precision = precisionFixed_default(step))) specifier.precision = precision - (specifier.type === "%") * 2; break; } } return format(specifier); } // node_modules/d3-scale/src/linear.js function linearish(scale) { var domain = scale.domain; scale.ticks = function(count) { var d = domain(); return ticks(d[0], d[d.length - 1], count == null ? 10 : count); }; scale.tickFormat = function(count, specifier) { var d = domain(); return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier); }; scale.nice = function(count) { if (count == null) count = 10; var d = domain(); var i0 = 0; var i1 = d.length - 1; var start2 = d[i0]; var stop = d[i1]; var prestep; var step; var maxIter = 10; if (stop < start2) { step = start2, start2 = stop, stop = step; step = i0, i0 = i1, i1 = step; } while (maxIter-- > 0) { step = tickIncrement(start2, stop, count); if (step === prestep) { d[i0] = start2; d[i1] = stop; return domain(d); } else if (step > 0) { start2 = Math.floor(start2 / step) * step; stop = Math.ceil(stop / step) * step; } else if (step < 0) { start2 = Math.ceil(start2 * step) / step; stop = Math.floor(stop * step) / step; } else { break; } prestep = step; } return scale; }; return scale; } function linear2() { var scale = continuous(); scale.copy = function() { return copy(scale, linear2()); }; initRange.apply(scale, arguments); return linearish(scale); } // node_modules/d3-zoom/src/constant.js var constant_default6 = (x3) => () => x3; // node_modules/d3-zoom/src/event.js function ZoomEvent(type2, { sourceEvent, target, transform: transform2, dispatch: dispatch2 }) { Object.defineProperties(this, { type: { value: type2, enumerable: true, configurable: true }, sourceEvent: { value: sourceEvent, enumerable: true, configurable: true }, target: { value: target, enumerable: true, configurable: true }, transform: { value: transform2, enumerable: true, configurable: true }, _: { value: dispatch2 } }); } // node_modules/d3-zoom/src/transform.js function Transform(k, x3, y3) { this.k = k; this.x = x3; this.y = y3; } Transform.prototype = { constructor: Transform, scale: function(k) { return k === 1 ? this : new Transform(this.k * k, this.x, this.y); }, translate: function(x3, y3) { return x3 === 0 & y3 === 0 ? this : new Transform(this.k, this.x + this.k * x3, this.y + this.k * y3); }, apply: function(point) { return [point[0] * this.k + this.x, point[1] * this.k + this.y]; }, applyX: function(x3) { return x3 * this.k + this.x; }, applyY: function(y3) { return y3 * this.k + this.y; }, invert: function(location) { return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k]; }, invertX: function(x3) { return (x3 - this.x) / this.k; }, invertY: function(y3) { return (y3 - this.y) / this.k; }, rescaleX: function(x3) { return x3.copy().domain(x3.range().map(this.invertX, this).map(x3.invert, x3)); }, rescaleY: function(y3) { return y3.copy().domain(y3.range().map(this.invertY, this).map(y3.invert, y3)); }, toString: function() { return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; } }; var identity3 = new Transform(1, 0, 0); transform.prototype = Transform.prototype; function transform(node) { while (!node.__zoom) if (!(node = node.parentNode)) return identity3; return node.__zoom; } // node_modules/d3-zoom/src/noevent.js function nopropagation3(event) { event.stopImmediatePropagation(); } function noevent_default3(event) { event.preventDefault(); event.stopImmediatePropagation(); } // node_modules/d3-zoom/src/zoom.js function defaultFilter2(event) { return (!event.ctrlKey || event.type === "wheel") && !event.button; } function defaultExtent() { var e = this; if (e instanceof SVGElement) { e = e.ownerSVGElement || e; if (e.hasAttribute("viewBox")) { e = e.viewBox.baseVal; return [[e.x, e.y], [e.x + e.width, e.y + e.height]]; } return [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]]; } return [[0, 0], [e.clientWidth, e.clientHeight]]; } function defaultTransform() { return this.__zoom || identity3; } function defaultWheelDelta(event) { return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1); } function defaultTouchable2() { return navigator.maxTouchPoints || "ontouchstart" in this; } function defaultConstrain(transform2, extent, translateExtent) { var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1]; return transform2.translate( dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1), dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1) ); } function zoom_default2() { var filter2 = defaultFilter2, extent = defaultExtent, constrain = defaultConstrain, wheelDelta = defaultWheelDelta, touchable = defaultTouchable2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], duration = 250, interpolate = zoom_default, listeners = dispatch_default("start", "zoom", "end"), touchstarting, touchfirst, touchending, touchDelay = 500, wheelDelay = 150, clickDistance2 = 0, tapDistance = 10; function zoom(selection2) { selection2.property("__zoom", defaultTransform).on("wheel.zoom", wheeled, { passive: false }).on("mousedown.zoom", mousedowned).on("dblclick.zoom", dblclicked).filter(touchable).on("touchstart.zoom", touchstarted).on("touchmove.zoom", touchmoved).on("touchend.zoom touchcancel.zoom", touchended).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); } zoom.transform = function(collection, transform2, point, event) { var selection2 = collection.selection ? collection.selection() : collection; selection2.property("__zoom", defaultTransform); if (collection !== selection2) { schedule(collection, transform2, point, event); } else { selection2.interrupt().each(function() { gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(); }); } }; zoom.scaleBy = function(selection2, k, p, event) { zoom.scaleTo(selection2, function() { var k0 = this.__zoom.k, k1 = typeof k === "function" ? k.apply(this, arguments) : k; return k0 * k1; }, p, event); }; zoom.scaleTo = function(selection2, k, p, event) { zoom.transform(selection2, function() { var e = extent.apply(this, arguments), t0 = this.__zoom, p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p, p1 = t0.invert(p0), k1 = typeof k === "function" ? k.apply(this, arguments) : k; return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent); }, p, event); }; zoom.translateBy = function(selection2, x3, y3, event) { zoom.transform(selection2, function() { return constrain(this.__zoom.translate( typeof x3 === "function" ? x3.apply(this, arguments) : x3, typeof y3 === "function" ? y3.apply(this, arguments) : y3 ), extent.apply(this, arguments), translateExtent); }, null, event); }; zoom.translateTo = function(selection2, x3, y3, p, event) { zoom.transform(selection2, function() { var e = extent.apply(this, arguments), t = this.__zoom, p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p; return constrain(identity3.translate(p0[0], p0[1]).scale(t.k).translate( typeof x3 === "function" ? -x3.apply(this, arguments) : -x3, typeof y3 === "function" ? -y3.apply(this, arguments) : -y3 ), e, translateExtent); }, p, event); }; function scale(transform2, k) { k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k)); return k === transform2.k ? transform2 : new Transform(k, transform2.x, transform2.y); } function translate(transform2, p0, p1) { var x3 = p0[0] - p1[0] * transform2.k, y3 = p0[1] - p1[1] * transform2.k; return x3 === transform2.x && y3 === transform2.y ? transform2 : new Transform(transform2.k, x3, y3); } function centroid(extent2) { return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2]; } function schedule(transition2, transform2, point, event) { transition2.on("start.zoom", function() { gesture(this, arguments).event(event).start(); }).on("interrupt.zoom end.zoom", function() { gesture(this, arguments).event(event).end(); }).tween("zoom", function() { var that = this, args = arguments, g = gesture(that, args).event(event), e = extent.apply(that, args), p = point == null ? centroid(e) : typeof point === "function" ? point.apply(that, args) : point, w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]), a2 = that.__zoom, b = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i = interpolate(a2.invert(p).concat(w / a2.k), b.invert(p).concat(w / b.k)); return function(t) { if (t === 1) t = b; else { var l = i(t), k = w / l[2]; t = new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k); } g.zoom(null, t); }; }); } function gesture(that, args, clean) { return !clean && that.__zooming || new Gesture(that, args); } function Gesture(that, args) { this.that = that; this.args = args; this.active = 0; this.sourceEvent = null; this.extent = extent.apply(that, args); this.taps = 0; } Gesture.prototype = { event: function(event) { if (event) this.sourceEvent = event; return this; }, start: function() { if (++this.active === 1) { this.that.__zooming = this; this.emit("start"); } return this; }, zoom: function(key, transform2) { if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]); if (this.touch0 && key !== "touch") this.touch0[1] = transform2.invert(this.touch0[0]); if (this.touch1 && key !== "touch") this.touch1[1] = transform2.invert(this.touch1[0]); this.that.__zoom = transform2; this.emit("zoom"); return this; }, end: function() { if (--this.active === 0) { delete this.that.__zooming; this.emit("end"); } return this; }, emit: function(type2) { var d = select_default2(this.that).datum(); listeners.call( type2, this.that, new ZoomEvent(type2, { sourceEvent: this.sourceEvent, target: zoom, type: type2, transform: this.that.__zoom, dispatch: listeners }), d ); } }; function wheeled(event, ...args) { if (!filter2.apply(this, arguments)) return; var g = gesture(this, args).event(event), t = this.__zoom, k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p = pointer_default(event); if (g.wheel) { if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) { g.mouse[1] = t.invert(g.mouse[0] = p); } clearTimeout(g.wheel); } else if (t.k === k) return; else { g.mouse = [p, t.invert(p)]; interrupt_default(this); g.start(); } noevent_default3(event); g.wheel = setTimeout(wheelidled, wheelDelay); g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent, translateExtent)); function wheelidled() { g.wheel = null; g.end(); } } function mousedowned(event, ...args) { if (touchending || !filter2.apply(this, arguments)) return; var currentTarget = event.currentTarget, g = gesture(this, args, true).event(event), v = select_default2(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true), p = pointer_default(event, currentTarget), x0 = event.clientX, y0 = event.clientY; nodrag_default(event.view); nopropagation3(event); g.mouse = [p, this.__zoom.invert(p)]; interrupt_default(this); g.start(); function mousemoved(event2) { noevent_default3(event2); if (!g.moved) { var dx = event2.clientX - x0, dy = event2.clientY - y0; g.moved = dx * dx + dy * dy > clickDistance2; } g.event(event2).zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = pointer_default(event2, currentTarget), g.mouse[1]), g.extent, translateExtent)); } function mouseupped(event2) { v.on("mousemove.zoom mouseup.zoom", null); yesdrag(event2.view, g.moved); noevent_default3(event2); g.event(event2).end(); } } function dblclicked(event, ...args) { if (!filter2.apply(this, arguments)) return; var t0 = this.__zoom, p0 = pointer_default(event.changedTouches ? event.changedTouches[0] : event, this), p1 = t0.invert(p0), k1 = t0.k * (event.shiftKey ? 0.5 : 2), t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(this, args), translateExtent); noevent_default3(event); if (duration > 0) select_default2(this).transition().duration(duration).call(schedule, t1, p0, event); else select_default2(this).call(zoom.transform, t1, p0, event); } function touchstarted(event, ...args) { if (!filter2.apply(this, arguments)) return; var touches = event.touches, n = touches.length, g = gesture(this, args, event.changedTouches.length === n).event(event), started, i, t, p; nopropagation3(event); for (i = 0; i < n; ++i) { t = touches[i], p = pointer_default(t, this); p = [p, this.__zoom.invert(p), t.identifier]; if (!g.touch0) g.touch0 = p, started = true, g.taps = 1 + !!touchstarting; else if (!g.touch1 && g.touch0[2] !== p[2]) g.touch1 = p, g.taps = 0; } if (touchstarting) touchstarting = clearTimeout(touchstarting); if (started) { if (g.taps < 2) touchfirst = p[0], touchstarting = setTimeout(function() { touchstarting = null; }, touchDelay); interrupt_default(this); g.start(); } } function touchmoved(event, ...args) { if (!this.__zooming) return; var g = gesture(this, args).event(event), touches = event.changedTouches, n = touches.length, i, t, p, l; noevent_default3(event); for (i = 0; i < n; ++i) { t = touches[i], p = pointer_default(t, this); if (g.touch0 && g.touch0[2] === t.identifier) g.touch0[0] = p; else if (g.touch1 && g.touch1[2] === t.identifier) g.touch1[0] = p; } t = g.that.__zoom; if (g.touch1) { var p0 = g.touch0[0], l0 = g.touch0[1], p1 = g.touch1[0], l1 = g.touch1[1], dp = (dp = p1[0] - p0[0]) * dp + (dp = p1[1] - p0[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl; t = scale(t, Math.sqrt(dp / dl)); p = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2]; l = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2]; } else if (g.touch0) p = g.touch0[0], l = g.touch0[1]; else return; g.zoom("touch", constrain(translate(t, p, l), g.extent, translateExtent)); } function touchended(event, ...args) { if (!this.__zooming) return; var g = gesture(this, args).event(event), touches = event.changedTouches, n = touches.length, i, t; nopropagation3(event); if (touchending) clearTimeout(touchending); touchending = setTimeout(function() { touchending = null; }, touchDelay); for (i = 0; i < n; ++i) { t = touches[i]; if (g.touch0 && g.touch0[2] === t.identifier) delete g.touch0; else if (g.touch1 && g.touch1[2] === t.identifier) delete g.touch1; } if (g.touch1 && !g.touch0) g.touch0 = g.touch1, delete g.touch1; if (g.touch0) g.touch0[1] = this.__zoom.invert(g.touch0[0]); else { g.end(); if (g.taps === 2) { t = pointer_default(t, this); if (Math.hypot(touchfirst[0] - t[0], touchfirst[1] - t[1]) < tapDistance) { var p = select_default2(this).on("dblclick.zoom"); if (p) p.apply(this, arguments); } } } } zoom.wheelDelta = function(_) { return arguments.length ? (wheelDelta = typeof _ === "function" ? _ : constant_default6(+_), zoom) : wheelDelta; }; zoom.filter = function(_) { return arguments.length ? (filter2 = typeof _ === "function" ? _ : constant_default6(!!_), zoom) : filter2; }; zoom.touchable = function(_) { return arguments.length ? (touchable = typeof _ === "function" ? _ : constant_default6(!!_), zoom) : touchable; }; zoom.extent = function(_) { return arguments.length ? (extent = typeof _ === "function" ? _ : constant_default6([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), zoom) : extent; }; zoom.scaleExtent = function(_) { return arguments.length ? (scaleExtent[0] = +_[0], scaleExtent[1] = +_[1], zoom) : [scaleExtent[0], scaleExtent[1]]; }; zoom.translateExtent = function(_) { return arguments.length ? (translateExtent[0][0] = +_[0][0], translateExtent[1][0] = +_[1][0], translateExtent[0][1] = +_[0][1], translateExtent[1][1] = +_[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]]; }; zoom.constrain = function(_) { return arguments.length ? (constrain = _, zoom) : constrain; }; zoom.duration = function(_) { return arguments.length ? (duration = +_, zoom) : duration; }; zoom.interpolate = function(_) { return arguments.length ? (interpolate = _, zoom) : interpolate; }; zoom.on = function() { var value = listeners.on.apply(listeners, arguments); return value === listeners ? zoom : value; }; zoom.clickDistance = function(_) { return arguments.length ? (clickDistance2 = (_ = +_) * _, zoom) : Math.sqrt(clickDistance2); }; zoom.tapDistance = function(_) { return arguments.length ? (tapDistance = +_, zoom) : tapDistance; }; return zoom; } // main.ts var DEFAULT_NETWORK_SETTINGS = { relevanceScoreThreshold: 0.5, nodeSize: 4, linkThickness: 0.3, repelForce: 400, linkForce: 0.4, linkDistance: 70, centerForce: 0.1, textFadeThreshold: 1.1, minLinkThickness: 0.3, maxLinkThickness: 0.6, maxLabelCharacters: 18, linkLabelSize: 7, nodeLabelSize: 6, connectionType: "block", noteFillColor: "#7c8594", blockFillColor: "#926ec9" }; var ScGraphItemView = class extends import_obsidian.ItemView { constructor(leaf, plugin) { super(leaf); this.connectionType = "block"; this.relevanceScoreThreshold = 0.5; this.nodeSize = 4; this.linkThickness = 0.3; this.repelForce = 400; this.linkForce = 0.4; this.linkDistance = 70; this.centerForce = 0.3; this.textFadeThreshold = 1.1; this.minScore = 1; this.maxScore = 0; this.minNodeSize = 3; this.maxNodeSize = 6; this.minLinkThickness = 0.3; this.maxLinkThickness = 0.6; this.isCtrlPressed = false; this.isAltPressed = false; this.isDragging = false; this.isChangingConnectionType = true; this.maxLabelCharacters = 18; this.linkLabelSize = 7; this.nodeLabelSize = 6; this.blockFillColor = "#926ec9"; this.noteFillColor = "#7c8594"; this.startX = 0; this.startY = 0; this.nodes = []; this.links = []; this.connections = []; this.centerHighlighted = false; this.dragging = false; this.highlightedNodeId = "-1"; this.currentNoteChanging = false; this.isFiltering = false; this.settingsMade = false; this.currentNoteKey = ""; this.isHovering = false; this.plugin = plugin; this.relevanceScoreThreshold = this.plugin.settings.relevanceScoreThreshold; this.nodeSize = this.plugin.settings.nodeSize; this.linkThickness = this.plugin.settings.linkThickness; this.repelForce = this.plugin.settings.repelForce; this.linkForce = this.plugin.settings.linkForce; this.linkDistance = this.plugin.settings.linkDistance; this.centerForce = this.plugin.settings.centerForce; this.textFadeThreshold = this.plugin.settings.textFadeThreshold; this.minLinkThickness = this.plugin.settings.minLinkThickness; this.maxLinkThickness = this.plugin.settings.maxLinkThickness; this.maxLabelCharacters = this.plugin.settings.maxLabelCharacters; this.linkLabelSize = this.plugin.settings.linkLabelSize; this.nodeLabelSize = this.plugin.settings.nodeLabelSize; this.connectionType = this.plugin.settings.connectionType; this.noteFillColor = this.plugin.settings.noteFillColor; this.blockFillColor = this.plugin.settings.blockFillColor; } getViewType() { return "smart-connections-visualizer"; } getDisplayText() { return "Smart connections visualizer"; } getIcon() { return "git-fork"; } updateNodeAppearance() { this.nodeSelection.transition().duration(500).attr("fill", (d) => d.fill).attr("stroke", (d) => d.selected ? "blanchedalmond" : d.highlighted ? "#d46ebe" : "transparent").attr("stroke-width", (d) => d.selected ? 1.5 : d.highlighted ? 0.3 : 0).attr("opacity", (d) => this.getNodeOpacity(d)); } // getNodeFill(d: any) { // if (d.id === this.centralNode.id) return '#7c8594'; // if (d.highlighted && !d.selected) return '#d46ebe'; // return d.group === 'note' ? '#7c8594' : '#926ec9'; // } getNodeOpacity(d) { if (d.id === this.centralNode.id) return 1; if (d.selected) return 1; if (d.highlighted) return 0.8; return this.isHovering ? 0.1 : 1; } toggleNodeSelection(nodeId) { const node = this.nodeSelection.data().find((d) => d.id === nodeId); if (node) { node.selected = !node.selected; if (!node.selected) { node.highlighted = false; } this.updateNodeAppearance(); } } clearSelections() { this.nodeSelection.each((d) => { d.selected = false; d.highlighted = false; }); this.updateNodeAppearance(); } highlightNode(node) { if (node.id === this.centralNode.id) { this.centerHighlighted = true; } this.highlightedNodeId = node.id; this.nodeSelection.each((d) => { if (d.id !== this.centralNode.id) { d.highlighted = d.id === node.id || this.validatedLinks.some((link) => link.source.id === node.id && link.target.id === d.id || link.target.id === node.id && link.source.id === d.id); } }); this.updateNodeAppearance(); this.updateLinkAppearance(node); this.updateLabelAppearance(node); this.updateLinkLabelAppearance(node); } updateHighlight(d, node) { if (d.id !== this.centralNode.id) { d.highlighted = d.id === node.id || this.validatedLinks.some((link) => link.source.id === node.id && link.target.id === d.id || link.target.id === node.id && link.source.id === d.id); } } updateLinkAppearance(node) { this.linkSelection.transition().duration(500).attr("opacity", (d) => d.source.id === node.id || d.target.id === node.id ? 1 : 0.1); } updateLabelAppearance(node) { this.labelSelection.transition().duration(500).attr("opacity", (d) => this.getLabelOpacity(d, node)).text((d) => d.id === this.highlightedNodeId ? this.formatLabel(d.name, false) : this.formatLabel(d.name, true)); } getLabelOpacity(d, node) { if (!node) { return 1; } return d.id === node.id || this.validatedLinks.some((link) => link.source.id === node.id && link.target.id === d.id) || d.id == this.centralNode.id ? 1 : 0.1; } updateLinkLabelAppearance(node) { this.linkLabelSelection.transition().duration(500).attr("opacity", (d) => { return d.source.id === node.id || d.target.id === node.id ? 1 : 0; }); } unhighlightNode(node) { this.highlightedNodeId = "-1"; this.nodeSelection.each((d) => { if (d.id !== this.centralNode.id) d.highlighted = false; }); this.updateNodeAppearance(); this.resetLinkAppearance(); this.resetLabelAppearance(); this.resetLinkLabelAppearance(); this.updateLabelAppearance(null); } resetLinkAppearance() { this.linkSelection.transition().duration(500).attr("opacity", 1); } resetLabelAppearance() { this.labelSelection.transition().duration(500).attr("opacity", 1).text((d) => this.formatLabel(d.name, true)); } resetLinkLabelAppearance() { this.linkLabelSelection.transition().duration(500).attr("opacity", 0); } formatLabel(path, truncate = true) { let label = this.extractLabel(path); return truncate ? this.truncateLabel(label) : label; } extractLabel(path) { let label = path; if (path && path.includes("#")) { const parts = path.split("#"); let lastPart = parts[parts.length - 1]; if (lastPart === "" || /^\{\d+\}$/.test(lastPart)) { lastPart = parts[parts.length - 2] + "#" + lastPart; } if (lastPart.includes("/")) { lastPart = lastPart.split("/").pop() || lastPart; } label = lastPart; } else if (path) { label = path.split("/").pop() || label; } else { return ""; } label = label.replace(/[\[\]]/g, "").replace(/\.[^/#]+#(?=\{\d+\}$)/, "").replace(/\.[^/.]+$/, ""); return label; } truncateLabel(label) { return label.length > this.maxLabelCharacters ? label.slice(0, this.maxLabelCharacters) + "..." : label; } //@ts-ignore get env() { return window.smart_env; } get smartNotes() { var _a, _b; return (_b = (_a = window.smart_env) == null ? void 0 : _a.smart_sources) == null ? void 0 : _b.items; } async onOpen() { this.contentEl.createEl("h2", { text: "Smart Visualizer" }); this.contentEl.createEl("p", { text: "Waiting for Smart Connections to load..." }); console.log(this.app); setTimeout(() => { this.render(); }, 500); } async render() { var _a; while (!((_a = this.env) == null ? void 0 : _a.collections_loaded)) { await new Promise((resolve) => setTimeout(resolve, 2e3)); } this.contentEl.empty(); this.initializeVariables(); if (Object.keys(this.smartNotes).length === 0) { return; } this.setupSettingsMenu(); this.setupSVG(); this.addEventListeners(); this.watchForNoteChanges(); const currentNodeChange = this.app.workspace.getActiveFile(); if (currentNodeChange && !this.currentNoteChanging) { this.currentNoteKey = currentNodeChange.path; this.currentNoteChanging = true; this.render(); return; } this.updateVisualization(); } async waitForSmartNotes() { var _a; const maxRetries = 10; const delay = 2e3; for (let attempt = 0; attempt < maxRetries; attempt++) { console.log(this.env); if ((_a = this.env) == null ? void 0 : _a.collections_loaded) { return; } await new Promise((resolve) => setTimeout(resolve, delay)); } console.error("Smart notes did not load in time"); this.contentEl.createEl("p", { text: "Failed to load Smart Connections." }); } initializeVariables() { this.minScore = 1; this.maxScore = 0; } setupSVG() { const width = this.contentEl.clientWidth; const height = this.contentEl.clientHeight; const svg = select_default2(this.contentEl).append("svg").attr("width", "100%").attr("height", "98%").attr("viewBox", `0 0 ${width} ${height}`).attr("preserveAspectRatio", "xMidYMid meet").call(zoom_default2().scaleExtent([0.1, 10]).on("zoom", (event) => { svgGroup.attr("transform", event.transform); this.updateLabelOpacity(event.transform.k); })); const svgGroup = svg.append("g"); svgGroup.append("g").attr("class", "smart-connections-visualizer-links"); svgGroup.append("g").attr("class", "smart-connections-visualizer-node-labels"); svgGroup.append("g").attr("class", "smart-connections-visualizer-link-labels"); svgGroup.append("g").attr("class", "smart-connections-visualizer-nodes"); this.svgGroup = svgGroup; this.svg = svg; } getSVGDimensions() { const width = this.contentEl.clientWidth || this.contentEl.getBoundingClientRect().width; const height = this.contentEl.clientHeight || this.contentEl.getBoundingClientRect().height; return { width, height }; } createSVG(width, height) { return select_default2(this.contentEl).append("svg").attr("width", "100%").attr("height", "98%").attr("viewBox", `0 0 ${width} ${height}`).attr("preserveAspectRatio", "xMidYMid meet").style("background", "#2d3039").call(zoom_default2().scaleExtent([0.1, 10]).on("zoom", this.onZoom.bind(this))); } createSVGGroup(svg) { return svg.append("g"); } onZoom(event) { select_default2("g").attr("transform", event.transform); this.updateLabelOpacity(event.transform.k); } initializeSimulation(width, height) { this.simulation = simulation_default().force("center", center_default(width / 2, height / 2).strength(this.centerForce)).force("charge", manyBody_default().strength(-this.repelForce)).force("link", link_default().id((d) => d.id).distance((d) => this.linkDistanceScale(d.score)).strength(this.linkForce)).force("collide", collide_default().radius(this.nodeSize + 3).strength(0.7)).on("tick", this.simulationTickHandler.bind(this)); this.simulation.force("labels", this.avoidLabelCollisions.bind(this)); } renderLegend() { if (this.validatedLinks.length === 0) { return; } const types = ["block", "note"]; const counts = types.map((type2) => this.nodes.filter((node) => node.group === type2 && node.id !== this.centralNode.id).length); let colors = { "block": DEFAULT_NETWORK_SETTINGS.blockFillColor, "note": DEFAULT_NETWORK_SETTINGS.noteFillColor }; for (let node of this.nodes) { if (colors[node.group]) { colors[node.group] = node.fill; } } const tableContainer = this.contentEl.createEl("div", { cls: "smart-connections-visualizer-legend-container" }); const header = tableContainer.createEl("div", { cls: "smart-connections-visualizer-legend-header" }); ["Connection Type", "Count", "Color"].forEach((headerTitle) => { switch (headerTitle) { case "Connection Type": header.createEl("div", { text: headerTitle, cls: "smart-connections-visualizer-variable-col" }); break; case "Count": header.createEl("div", { text: headerTitle, cls: "smart-connections-visualizer-count-col" }); break; case "Color": header.createEl("div", { text: headerTitle, cls: "smart-connections-visualizer-color-col" }); break; default: header.createEl("div", { text: headerTitle, cls: "smart-connections-visualizer-variable-col" }); break; } }); types.forEach((type2, index2) => { if (counts[index2] > 0) { const row = tableContainer.createEl("div", { cls: "smart-connections-visualizer-legend-row" }); row.createEl("div", { text: this.capitalizeFirstLetter(type2), cls: "smart-connections-visualizer-variable-col" }); row.createEl("div", { text: `${counts[index2]}`, cls: "smart-connections-visualizer-count-col" }); const colorCell = row.createEl("div", { cls: "smart-connections-visualizer-color-col" }); const colorPicker = colorCell.createEl("input", { type: "color", value: colors[type2], cls: "smart-connections-visualizer-legend-color-picker" }); colorPicker.addEventListener("change", (e) => this.updateNodeColors(type2, e.target.value)); } }); } capitalizeFirstLetter(str) { if (!str) return str; console.log("string: ", str); return str.charAt(0).toUpperCase() + str.slice(1); } updateNodeColors(type2, color2) { if (type2 === "note" && color2 !== this.noteFillColor) { this.noteFillColor = color2; this.plugin.settings.noteFillColor = color2; this.plugin.saveSettings(); } if (type2 === "block" && color2 !== this.blockFillColor) { this.blockFillColor = color2; this.plugin.settings.noteFillColor = color2; this.plugin.saveSettings(); } this.nodes.forEach((node) => { if (node.group === type2) { node.fill = color2; } }); this.updateNodeFill(); } updateNodeFill() { this.nodeSelection.attr("fill", (d) => d.fill); } // Ensure node labels dont collide with any elements avoidLabelCollisions() { const padding = 5; return (alpha) => { const quadtree2 = quadtree().x((d) => d.x).y((d) => d.y).addAll(this.labelSelection.data()); this.labelSelection.each((d) => { const radius = d.radius + padding; const nx1 = d.x - radius, nx2 = d.x + radius, ny1 = d.y - radius, ny2 = d.y + radius; quadtree2.visit((quad, x1, y1, x22, y22) => { if ("data" in quad && quad.data && quad.data !== d) { let x3 = d.x - quad.data.x, y3 = d.y - quad.data.y, l = Math.sqrt(x3 * x3 + y3 * y3), r = radius + quad.data.radius; if (l < r) { l = (l - r) / l * alpha; d.x -= x3 *= l; d.y -= y3 *= l; quad.data.x += x3; quad.data.y += y3; } } return x1 > nx2 || x22 < nx1 || y1 > ny2 || y22 < ny1; }); }); }; } addEventListeners() { this.setupSVGEventListeners(); this.setupKeyboardEventListeners(); } setupSVGEventListeners() { select_default2("svg").on("mousedown", this.onMouseDown.bind(this)).on("mousemove", this.onMouseMove.bind(this)).on("mouseup", this.onMouseUp.bind(this)).on("click", this.onSVGClick.bind(this)); } // TODO: Add back in when ready for multiselect onMouseDown(event) { } onMouseMove(event) { } onMouseUp() { } onSVGClick(event) { if (!event.defaultPrevented && !event.ctrlKey) this.clearSelections(); } setupKeyboardEventListeners() { document.addEventListener("keydown", this.onKeyDown.bind(this)); document.addEventListener("keyup", this.onKeyUp.bind(this)); } // TODO:: Add back when ready for multiselect onKeyDown(event) { } onKeyUp(event) { } setupSettingsMenu() { const existingIcon = this.contentEl.querySelector(".smart-connections-visualizer-settings-icon"); if (existingIcon) { existingIcon.remove(); } const existingDropdownMenu = this.contentEl.querySelector(".sc-visualizer-dropdown-menu"); if (existingDropdownMenu) { existingDropdownMenu.remove(); } this.createSettingsIcon(); this.createDropdownMenu(); this.setupAccordionHeaders(); this.setupSettingsEventListeners(); } createDropdownMenu() { const dropdownMenu = this.contentEl.createEl("div", { cls: "sc-visualizer-dropdown-menu" }); this.buildDropdownMenuContent(dropdownMenu); } buildDropdownMenuContent(dropdownMenu) { const menuHeader = dropdownMenu.createEl("div", { cls: "smart-connections-visualizer-menu-header" }); const refreshIcon = this.createRefreshIcon(); refreshIcon.classList.add("smart-connections-visualizer-icon"); refreshIcon.setAttribute("id", "smart-connections-visualizer-refresh-icon"); menuHeader.appendChild(refreshIcon); const xIcon = this.createNewXIcon(); xIcon.classList.add("smart-connections-visualizer-icon"); xIcon.setAttribute("id", "smart-connections-visualizer-close-icon"); menuHeader.appendChild(xIcon); this.addAccordionItem(dropdownMenu, "Filters", this.getFiltersContent.bind(this)); this.addAccordionItem(dropdownMenu, "Display", this.getDisplayContent.bind(this)); this.addAccordionItem(dropdownMenu, "Forces", this.getForcesContent.bind(this)); } addAccordionItem(parent, title, buildContent) { const accordionItem = parent.createEl("div", { cls: "smart-connections-visualizer-accordion-item" }); const header = accordionItem.createEl("div", { cls: "smart-connections-visualizer-accordion-header" }); const arrowIcon = header.createEl("span", { cls: "smart-connections-visualizer-arrow-icon" }); arrowIcon.appendChild(this.createRightArrow()); header.createEl("span", { text: title }); const accordionContent = accordionItem.createEl("div", { cls: "smart-connections-visualizer-accordion-content" }); buildContent(accordionContent); } getFiltersContent(parent) { const sliderContainer1 = parent.createEl("div", { cls: "smart-connections-visualizer-slider-container" }); sliderContainer1.createEl("label", { text: `Min relevance: ${(this.relevanceScoreThreshold * 100).toFixed(0)}%`, attr: { id: "smart-connections-visualizer-scoreThresholdLabel", for: "smart-connections-visualizer-scoreThreshold" } }); const relevanceSlider = sliderContainer1.createEl("input", { attr: { type: "range", id: "smart-connections-visualizer-scoreThreshold", class: "smart-connections-visualizer-slider", name: "scoreThreshold", min: "0", max: "0.99", step: "0.01" } }); relevanceSlider.value = this.relevanceScoreThreshold.toString(); parent.createEl("label", { text: "Connection type:", cls: "smart-connections-visualizer-settings-item-content-label" }); const radioContainer = parent.createEl("div", { cls: "smart-connections-visualizer-radio-container" }); const radioBlockLabel = radioContainer.createEl("label"); const blockRadio = radioBlockLabel.createEl("input", { attr: { type: "radio", name: "connectionType", value: "block" } }); blockRadio.checked = this.connectionType === "block"; radioBlockLabel.appendText(" Block"); const radioNoteLabel = radioContainer.createEl("label"); const noteRadio = radioNoteLabel.createEl("input", { attr: { type: "radio", name: "connectionType", value: "note" } }); noteRadio.checked = this.connectionType === "note"; radioNoteLabel.appendText(" Note"); const radioBothLabel = radioContainer.createEl("label"); const bothRadio = radioBothLabel.createEl("input", { attr: { type: "radio", name: "connectionType", value: "both" } }); bothRadio.checked = this.connectionType === "both"; radioBothLabel.appendText(" Both"); } getDisplayContent(parent) { const displaySettings = [ { id: "smart-connections-visualizer-nodeSize", label: "Node size", value: this.nodeSize, min: 1, max: 15, step: 0.01 }, { id: "smart-connections-visualizer-maxLabelCharacters", label: "Max label characters", value: this.maxLabelCharacters, min: 1, max: 50, step: 1 }, { id: "smart-connections-visualizer-linkLabelSize", label: "Link label size", value: this.linkLabelSize, min: 1, max: 15, step: 0.01 }, { id: "smart-connections-visualizer-nodeLabelSize", label: "Node label size", value: this.nodeLabelSize, min: 1, max: 26, step: 1 }, { id: "smart-connections-visualizer-minLinkThickness", label: "Min link thickness", value: this.minLinkThickness, min: 0.1, max: 10, step: 0.01 }, { id: "smart-connections-visualizer-maxLinkThickness", label: "Max link thickness", value: this.maxLinkThickness, min: 0.1, max: 10, step: 0.01 }, { id: "smart-connections-visualizer-fadeThreshold", label: "Text fade threshold", value: this.textFadeThreshold, min: 0.1, max: 10, step: 0.01 } ]; displaySettings.forEach((setting) => { const sliderContainer = parent.createEl("div", { cls: "smart-connections-visualizer-slider-container" }); sliderContainer.createEl("label", { text: `${setting.label}: ${setting.value}`, attr: { id: `${setting.id}Label`, for: setting.id } }); sliderContainer.createEl("input", { attr: { type: "range", id: setting.id, class: "smart-connections-visualizer-slider", name: setting.id, min: `${setting.min}`, max: `${setting.max}`, value: `${setting.value}`, step: `${setting.step}` } }); }); } getForcesContent(parent) { const forcesSettings = [ { id: "smart-connections-visualizer-repelForce", label: "Repel force", value: this.repelForce, min: 0, max: 1500, step: 1 }, { id: "smart-connections-visualizer-linkForce", label: "Link force", value: this.linkForce, min: 0, max: 1, step: 0.01 }, { id: "smart-connections-visualizer-linkDistance", label: "Link distance", value: this.linkDistance, min: 10, max: 200, step: 1 } ]; forcesSettings.forEach((setting) => { const sliderContainer = parent.createEl("div", { cls: "smart-connections-visualizer-slider-container" }); sliderContainer.createEl("label", { text: `${setting.label}: ${setting.value}`, attr: { id: `${setting.id}Label`, for: setting.id } }); sliderContainer.createEl("input", { attr: { type: "range", id: setting.id, class: "smart-connections-visualizer-slider", name: setting.id, min: `${setting.min}`, max: `${setting.max}`, value: `${setting.value}`, step: `${setting.step}` } }); }); } toggleDropdownMenu() { const dropdownMenu = document.querySelector(".sc-visualizer-dropdown-menu"); if (dropdownMenu) { dropdownMenu.classList.toggle("visible"); } else { console.error("Dropdown menu element not found"); } } setupAccordionHeaders() { const accordionHeaders = document.querySelectorAll(".smart-connections-visualizer-accordion-header"); accordionHeaders.forEach((header) => header.addEventListener("click", this.toggleAccordionContent.bind(this))); } toggleAccordionContent(event) { const content = event.currentTarget.nextElementSibling; const arrowIcon = event.currentTarget.querySelector(".smart-connections-visualizer-arrow-icon"); if (content && arrowIcon) { content.classList.toggle("show"); arrowIcon.innerHTML = ""; arrowIcon.appendChild(content.classList.contains("show") ? this.createDropdownArrow() : this.createRightArrow()); } } createDropdownArrow() { const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.setAttribute("class", "smart-connections-visualizer-dropdown-indicator"); svg.setAttribute("viewBox", "0 0 16 16"); svg.setAttribute("fill", "currentColor"); const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); path.setAttribute("fill-rule", "evenodd"); path.setAttribute("d", "M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"); svg.appendChild(path); return svg; } createRightArrow() { const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.setAttribute("class", "smart-connections-visualizer-dropdown-indicator"); svg.setAttribute("viewBox", "0 0 16 16"); svg.setAttribute("fill", "currentColor"); const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); path.setAttribute("fill-rule", "evenodd"); path.setAttribute("d", "M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"); svg.appendChild(path); return svg; } createSettingsIcon() { const settingsIcon = this.contentEl.createEl("div", { cls: ["smart-connections-visualizer-settings-icon"], attr: { "aria-label": "Open graph settings" } }); const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.setAttribute("width", "24"); svg.setAttribute("height", "24"); svg.setAttribute("viewBox", "0 0 24 24"); svg.setAttribute("fill", "none"); svg.setAttribute("stroke", "currentColor"); svg.setAttribute("stroke-width", "2"); svg.setAttribute("stroke-linecap", "round"); svg.setAttribute("stroke-linejoin", "round"); svg.setAttribute("class", "smart-connections-visualizer-svg-icon smart-connections-visualizer-lucide-settings"); const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); path.setAttribute("d", "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"); svg.appendChild(path); const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle"); circle.setAttribute("cx", "12"); circle.setAttribute("cy", "12"); circle.setAttribute("r", "3"); svg.appendChild(circle); settingsIcon.appendChild(svg); settingsIcon.addEventListener("click", this.toggleDropdownMenu); } createRefreshIcon() { const refreshIcon = this.contentEl.createEl("div", { cls: "smart-connections-visualizer-refresh-icon" }); const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.setAttribute("width", "24"); svg.setAttribute("height", "24"); svg.setAttribute("viewBox", "0 0 24 24"); svg.setAttribute("fill", "none"); svg.setAttribute("stroke", "currentColor"); svg.setAttribute("stroke-width", "2"); svg.setAttribute("stroke-linecap", "round"); svg.setAttribute("stroke-linejoin", "round"); svg.setAttribute("class", "smart-connections-visualizer-svg-icon smart-connections-visualizer-lucide-rotate-ccw"); const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path1.setAttribute("d", "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"); svg.appendChild(path1); const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path2.setAttribute("d", "M3 3v5h5"); svg.appendChild(path2); refreshIcon.appendChild(svg); return refreshIcon; } createNewXIcon() { const xIcon = this.contentEl.createEl("div", { cls: "smart-connections-visualizer-x-icon" }); const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.setAttribute("width", "24"); svg.setAttribute("height", "24"); svg.setAttribute("viewBox", "0 0 24 24"); svg.setAttribute("fill", "none"); svg.setAttribute("stroke", "currentColor"); svg.setAttribute("stroke-width", "2"); svg.setAttribute("stroke-linecap", "round"); svg.setAttribute("stroke-linejoin", "round"); svg.setAttribute("class", "smart-connections-visualizer-svg-icon smart-connections-visualizer-lucide-x"); const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path1.setAttribute("d", "M18 6 6 18"); svg.appendChild(path1); const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path2.setAttribute("d", "m6 6 12 12"); svg.appendChild(path2); xIcon.appendChild(svg); return xIcon; } setupSettingsEventListeners() { this.setupScoreThresholdSlider(); this.setupNodeSizeSlider(); this.setupLineThicknessSlider(); this.setupCenterForceSlider(); this.setupRepelForceSlider(); this.setupLinkForceSlider(); this.setupLinkDistanceSlider(); this.setupFadeThresholdSlider(); this.setupMinLinkThicknessSlider(); this.setupMaxLinkThicknessSlider(); this.setupConnectionTypeRadios(); this.setupMaxLabelCharactersSlider(); this.setupLinkLabelSizeSlider(); this.setupNodeLabelSizeSlider(); this.setupCloseIcon(); this.setupRefreshIcon(); } setupScoreThresholdSlider() { const scoreThresholdSlider = document.getElementById("smart-connections-visualizer-scoreThreshold"); if (scoreThresholdSlider) { scoreThresholdSlider.addEventListener("input", (event) => this.updateScoreThreshold(event)); const debouncedUpdate = (0, import_obsidian.debounce)((event) => { this.updateVisualization(parseFloat(event.target.value)); }, 500, true); scoreThresholdSlider.addEventListener("input", debouncedUpdate); } } updateScoreThreshold(event) { const newScoreThreshold = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-scoreThresholdLabel"); this.plugin.settings.relevanceScoreThreshold = newScoreThreshold; this.plugin.saveSettings(); if (label) label.textContent = `Min relevance: ${(newScoreThreshold * 100).toFixed(0)}%`; } setupNodeSizeSlider() { const nodeSizeSlider = document.getElementById("smart-connections-visualizer-nodeSize"); if (nodeSizeSlider) { nodeSizeSlider.addEventListener("input", (event) => this.updateNodeSize(event)); } } updateNodeSize(event) { const newNodeSize = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-nodeSizeLabel"); if (label) label.textContent = `Node size: ${newNodeSize}`; this.plugin.settings.nodeSize = newNodeSize; this.plugin.saveSettings(); this.nodeSize = newNodeSize; this.updateNodeSizes(); } setupLineThicknessSlider() { const lineThicknessSlider = document.getElementById("smart-connections-visualizer-lineThickness"); if (lineThicknessSlider) { lineThicknessSlider.addEventListener("input", (event) => this.updateLineThickness(event)); } } updateLineThickness(event) { const newLineThickness = parseFloat(event.target.value); const label = document.getElementById("lineThicknessLabel"); if (label) label.textContent = `Line thickness: ${newLineThickness}`; this.plugin.settings.linkThickness = newLineThickness; this.plugin.saveSettings(); this.linkThickness = newLineThickness; this.updateLinkThickness(); } setupCenterForceSlider() { const centerForceSlider = document.getElementById("smart-connections-visualizer-centerForce"); if (centerForceSlider) { centerForceSlider.addEventListener("input", (event) => this.updateCenterForce(event)); } } updateCenterForce(event) { const newCenterForce = parseFloat(event.target.value); const label = document.getElementById("centerForceLabel"); if (label) label.textContent = `Center force: ${newCenterForce}`; this.plugin.settings.centerForce = newCenterForce; this.plugin.saveSettings(); this.centerForce = newCenterForce; this.updateSimulationForces(); } setupRepelForceSlider() { const repelForceSlider = document.getElementById("smart-connections-visualizer-repelForce"); if (repelForceSlider) { repelForceSlider.addEventListener("input", (event) => this.updateRepelForce(event)); } } updateRepelForce(event) { const newRepelForce = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-repelForceLabel"); if (label) label.textContent = `Repel force: ${newRepelForce}`; this.repelForce = newRepelForce; this.plugin.settings.repelForce = newRepelForce; this.plugin.saveSettings(); this.updateSimulationForces(); } setupLinkForceSlider() { const linkForceSlider = document.getElementById("smart-connections-visualizer-linkForce"); if (linkForceSlider) { linkForceSlider.addEventListener("input", (event) => this.updateLinkForce(event)); } } updateLinkForce(event) { const newLinkForce = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-linkForceLabel"); if (label) label.textContent = `Link force: ${newLinkForce}`; this.linkForce = newLinkForce; this.plugin.settings.linkForce = newLinkForce; this.plugin.saveSettings(); this.updateSimulationForces(); } setupLinkDistanceSlider() { const linkDistanceSlider = document.getElementById("smart-connections-visualizer-linkDistance"); if (linkDistanceSlider) { linkDistanceSlider.addEventListener("input", (event) => this.updateLinkDistance(event)); } } updateLinkDistance(event) { const newLinkDistance = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-linkDistanceLabel"); if (label) label.textContent = `Link distance: ${newLinkDistance}`; this.linkDistance = newLinkDistance; this.plugin.settings.linkDistance = newLinkDistance; this.plugin.saveSettings(); this.updateSimulationForces(); } setupFadeThresholdSlider() { const fadeThresholdSlider = document.getElementById("smart-connections-visualizer-fadeThreshold"); if (fadeThresholdSlider) { fadeThresholdSlider.addEventListener("input", (event) => { this.updateFadeThreshold(event); this.updateLabelOpacity(transform(select_default2("svg").node()).k); }); } } updateFadeThreshold(event) { const newFadeThreshold = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-fadeThresholdLabel"); if (label) label.textContent = `Text fade threshold: ${newFadeThreshold}`; this.textFadeThreshold = newFadeThreshold; this.plugin.settings.textFadeThreshold = newFadeThreshold; this.plugin.saveSettings(); } setupMinLinkThicknessSlider() { const minLinkThicknessSlider = document.getElementById("smart-connections-visualizer-minLinkThickness"); if (minLinkThicknessSlider) { minLinkThicknessSlider.addEventListener("input", (event) => this.updateMinLinkThickness(event)); } } updateMinLinkThickness(event) { const newMinLinkThickness = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-minLinkThicknessLabel"); if (label) label.textContent = `Min link thickness: ${newMinLinkThickness}`; this.minLinkThickness = newMinLinkThickness; this.plugin.settings.minLinkThickness = newMinLinkThickness; this.plugin.saveSettings(); this.updateLinkThickness(); } setupMaxLinkThicknessSlider() { const maxLinkThicknessSlider = document.getElementById("smart-connections-visualizer-maxLinkThickness"); if (maxLinkThicknessSlider) { maxLinkThicknessSlider.addEventListener("input", (event) => this.updateMaxLinkThickness(event)); } } updateMaxLinkThickness(event) { const newMaxLinkThickness = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-maxLinkThicknessLabel"); if (label) label.textContent = `Max link thickness: ${newMaxLinkThickness}`; this.maxLinkThickness = newMaxLinkThickness; this.plugin.settings.maxLinkThickness = newMaxLinkThickness; this.plugin.saveSettings(); this.updateLinkThickness(); } setupConnectionTypeRadios() { const connectionTypeRadios = document.querySelectorAll('input[name="connectionType"]'); connectionTypeRadios.forEach((radio) => radio.addEventListener("change", (event) => this.updateConnectionType(event))); } updateConnectionType(event) { this.connectionType = event.target.value; this.isChangingConnectionType = true; this.plugin.settings.connectionType = this.connectionType; this.plugin.saveSettings(); this.updateVisualization(); } setupMaxLabelCharactersSlider() { const maxLabelCharactersSlider = document.getElementById("smart-connections-visualizer-maxLabelCharacters"); if (maxLabelCharactersSlider) { maxLabelCharactersSlider.addEventListener("input", (event) => this.updateMaxLabelCharacters(event)); } } updateMaxLabelCharacters(event) { const newMaxLabelCharacters = parseInt(event.target.value, 10); const label = document.getElementById("smart-connections-visualizer-maxLabelCharactersLabel"); if (label) label.textContent = `Max Label Characters: ${newMaxLabelCharacters}`; this.maxLabelCharacters = newMaxLabelCharacters; this.updateNodeLabels(); } setupLinkLabelSizeSlider() { const linkLabelSizeSlider = document.getElementById("smart-connections-visualizer-linkLabelSize"); if (linkLabelSizeSlider) { linkLabelSizeSlider.addEventListener("input", (event) => this.updateLinkLabelSize(event)); } } updateLinkLabelSize(event) { const newLinkLabelSize = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-linkLabelSizeLabel"); if (label) label.textContent = `Link Label Size: ${newLinkLabelSize}`; this.linkLabelSize = newLinkLabelSize; this.updateLinkLabelSizes(); } setupNodeLabelSizeSlider() { const nodeLabelSizeSlider = document.getElementById("smart-connections-visualizer-nodeLabelSize"); if (nodeLabelSizeSlider) { nodeLabelSizeSlider.addEventListener("input", (event) => this.updateNodeLabelSize(event)); } } updateNodeLabelSize(event) { console.log("flounddd"); const newNodeLabelSize = parseFloat(event.target.value); const label = document.getElementById("smart-connections-visualizer-nodeLabelSizeLabel"); if (label) label.textContent = `Node Label Size: ${newNodeLabelSize}`; this.nodeLabelSize = newNodeLabelSize; this.updateNodeLabelSizes(); } // Updated setupCloseIcon method setupCloseIcon() { const closeIcon = document.getElementById("smart-connections-visualizer-close-icon"); if (closeIcon) closeIcon.addEventListener("click", () => this.toggleDropdownMenu()); } closeDropdownMenu() { const dropdownMenu = document.querySelector(".sc-visualizer-dropdown-menu"); if (dropdownMenu) dropdownMenu.classList.remove("open"); } setupRefreshIcon() { const refreshIcon = document.getElementById("smart-connections-visualizer-refresh-icon"); if (refreshIcon) refreshIcon.addEventListener("click", () => this.resetToDefault()); } resetToDefault() { this.relevanceScoreThreshold = DEFAULT_NETWORK_SETTINGS.relevanceScoreThreshold; this.nodeSize = DEFAULT_NETWORK_SETTINGS.nodeSize; this.linkThickness = DEFAULT_NETWORK_SETTINGS.lineThickness; this.repelForce = DEFAULT_NETWORK_SETTINGS.repelForce; this.linkForce = DEFAULT_NETWORK_SETTINGS.linkForce; this.linkDistance = DEFAULT_NETWORK_SETTINGS.linkDistance; this.centerForce = DEFAULT_NETWORK_SETTINGS.centerForce; this.textFadeThreshold = DEFAULT_NETWORK_SETTINGS.textFadeThreshold; this.minLinkThickness = DEFAULT_NETWORK_SETTINGS.minLinkThickness; this.maxLinkThickness = DEFAULT_NETWORK_SETTINGS.maxLinkThickness; this.maxLabelCharacters = DEFAULT_NETWORK_SETTINGS.maxLabelCharacters; this.linkLabelSize = DEFAULT_NETWORK_SETTINGS.linkLabelSize; this.nodeLabelSize = DEFAULT_NETWORK_SETTINGS.nodeLabelSize; this.connectionType = DEFAULT_NETWORK_SETTINGS.connectionType; this.noteFillColor = DEFAULT_NETWORK_SETTINGS.noteFillColor; this.blockFillColor = DEFAULT_NETWORK_SETTINGS.blockFillColor; this.plugin.settings.relevanceScoreThreshold = DEFAULT_NETWORK_SETTINGS.relevanceScoreThreshold; this.plugin.settings.nodeSize = DEFAULT_NETWORK_SETTINGS.nodeSize; this.plugin.settings.linkThickness = DEFAULT_NETWORK_SETTINGS.lineThickness; this.plugin.settings.repelForce = DEFAULT_NETWORK_SETTINGS.repelForce; this.plugin.settings.linkForce = DEFAULT_NETWORK_SETTINGS.linkForce; this.plugin.settings.linkDistance = DEFAULT_NETWORK_SETTINGS.linkDistance; this.plugin.settings.centerForce = DEFAULT_NETWORK_SETTINGS.centerForce; this.plugin.settings.textFadeThreshold = DEFAULT_NETWORK_SETTINGS.textFadeThreshold; this.plugin.settings.minLinkThickness = DEFAULT_NETWORK_SETTINGS.minLinkThickness; this.plugin.settings.maxLinkThickness = DEFAULT_NETWORK_SETTINGS.maxLinkThickness; this.plugin.settings.maxLabelCharacters = DEFAULT_NETWORK_SETTINGS.maxLabelCharacters; this.plugin.settings.linkLabelSize = DEFAULT_NETWORK_SETTINGS.linkLabelSize; this.plugin.settings.nodeLabelSize = DEFAULT_NETWORK_SETTINGS.nodeLabelSize; this.plugin.settings.connectionType = DEFAULT_NETWORK_SETTINGS.connectionType; this.plugin.settings.noteFillColor = DEFAULT_NETWORK_SETTINGS.noteFillColor; this.plugin.settings.blockFillColor = DEFAULT_NETWORK_SETTINGS.blockFillColor; this.plugin.saveSettings(); this.updateLabelsToDefaults(); this.updateSliders(); this.updateNodeSizes(); this.updateLinkThickness(); this.updateSimulationForces(); this.updateVisualization(this.relevanceScoreThreshold); } updateLabelsToDefaults() { const labels = { "smart-connections-visualizer-scoreThresholdLabel": `Min relevance: ${(this.relevanceScoreThreshold * 100).toFixed(0)}%`, "smart-connections-visualizer-nodeSizeLabel": `Node size: ${this.nodeSize}`, "smart-connections-visualizer-maxLabelCharactersLabel": `Max label characters: ${this.maxLabelCharacters}`, "smart-connections-visualizer-linkLabelSizeLabel": `Link label size: ${this.linkLabelSize}`, "smart-connections-visualizer-smart-connections-visualizer-nodeLabelSizeLabel": `Node label size: ${this.nodeLabelSize}`, "smart-connections-visualizer-minLinkThicknessLabel": `Min link thickness: ${this.minLinkThickness}`, "smart-connections-visualizer-maxLinkThicknessLabel": `Max link thickness: ${this.maxLinkThickness}`, "smart-connections-visualizer-fadeThresholdLabel": `Text fade threshold: ${this.textFadeThreshold}`, "smart-connections-visualizer-repelForceLabel": `Repel force: ${this.repelForce}`, "smart-connections-visualizer-linkForceLabel": `Link force: ${this.linkForce}`, "smart-connections-visualizer-linkDistanceLabel": `Link distance: ${this.linkDistance}` }; for (const [id2, text] of Object.entries(labels)) { const label = document.getElementById(id2); if (label) { label.textContent = text; } } } updateSliders() { const scoreThresholdSlider = document.getElementById("smart-connections-visualizer-scoreThreshold"); const nodeSizeSlider = document.getElementById("smart-connections-visualizer-nodeSize"); const repelForceSlider = document.getElementById("smart-connections-visualizer-repelForce"); const linkForceSlider = document.getElementById("smart-connections-visualizer-linkForce"); const linkDistanceSlider = document.getElementById("smart-connections-visualizer-linkDistance"); const fadeThresholdSlider = document.getElementById("smart-connections-visualizer-fadeThreshold"); const minLinkThicknessSlider = document.getElementById("smart-connections-visualizer-minLinkThickness"); const maxLinkThicknessSlider = document.getElementById("smart-connections-visualizer-maxLinkThickness"); const maxLabelCharactersSlider = document.getElementById("smart-connections-visualizer-maxLabelCharacters"); const linkLabelSizeSlider = document.getElementById("smart-connections-visualizer-linkLabelSize"); const nodeLabelSizeSlider = document.getElementById("smart-connections-visualizer-nodeLabelSize"); scoreThresholdSlider.value = `${this.relevanceScoreThreshold}`; nodeSizeSlider.value = `${this.nodeSize}`; repelForceSlider.value = `${this.repelForce}`; linkForceSlider.value = `${this.linkForce}`; linkDistanceSlider.value = `${this.linkDistance}`; fadeThresholdSlider.value = `${this.textFadeThreshold}`; minLinkThicknessSlider.value = `${this.minLinkThickness}`; maxLinkThicknessSlider.value = `${this.maxLinkThickness}`; maxLabelCharactersSlider.value = `${this.maxLabelCharacters}`; linkLabelSizeSlider.value = `${this.linkLabelSize}`; nodeLabelSizeSlider.value = `${this.nodeLabelSize}`; } watchForNoteChanges() { this.app.workspace.on("file-open", (file) => { if (file && this.currentNoteKey !== file.path && !this.isHovering && this.containerEl.children[1].checkVisibility()) { this.currentNoteKey = file.path; this.currentNoteChanging = true; this.render(); } }); } async updateVisualization(newScoreThreshold) { if (this.updatingVisualization && !this.isChangingConnectionType) { this.updatingVisualization = false; this.currentNoteChanging = false; return; } this.isChangingConnectionType = false; if (newScoreThreshold !== void 0) { this.relevanceScoreThreshold = newScoreThreshold; } await this.updateConnections(); const filteredConnections = this.connections.filter((connection) => connection.score >= this.relevanceScoreThreshold); const visibleNodes = /* @__PURE__ */ new Set(); filteredConnections.forEach((connection) => { visibleNodes.add(connection.source); visibleNodes.add(connection.target); }); visibleNodes.add(this.centralNote.key); const nodesData = Array.from(visibleNodes).map((id2) => { const node = this.nodes.find((node2) => node2.id === id2); return node ? node : null; }).filter(Boolean); if (!nodesData.some((node) => node.id === this.centralNote.key)) { const centralNode = this.nodes.find((node) => node.id === this.centralNote.key); if (centralNode) { nodesData.push(centralNode); } } nodesData.forEach((node, index2) => { if (!node.x || !node.y) { console.warn(`Node with invalid position: ${node.id}`); node.x = Math.random() * 1e3; node.y = Math.random() * 1e3; } }); this.validatedLinks = filteredConnections.filter((link) => { const sourceNode = nodesData.find((node) => node.id === link.source); const targetNode = nodesData.find((node) => node.id === link.target); if (!sourceNode || !targetNode) { console.warn(`Link source or target node not found: ${link.source}, ${link.target}`); } return sourceNode && targetNode; }); if (nodesData.length === 0 || this.validatedLinks.length === 0) { this.updatingVisualization = false; console.warn("No nodes or links to display after filtering. Aborting update."); new import_obsidian.Notice("No nodes or links to display after filtering. Adjust filter settings"); this.nodeSelection = this.svgGroup.select("g.smart-connections-visualizer-nodes").selectAll("circle").data([]).exit().remove(); this.linkSelection = this.svgGroup.select("g.smart-connections-visualizer-links").selectAll("line").data([]).exit().remove(); this.linkLabelSelection = this.svgGroup.select("g.smart-connections-visualizer-link-labels").selectAll("text").data([]).exit().remove(); this.labelSelection = this.svgGroup.select("g.smart-connections-visualizer-node-labels").selectAll("text").data([]).exit().remove(); return; } this.updateNodeAndLinkSelection(nodesData); if (!this.simulation || this.currentNoteChanging || this.isFiltering) { const { width, height } = this.getSVGDimensions(); this.initializeSimulation(width, height); this.currentNoteChanging = false; this.isFiltering = false; } this.simulation.nodes(nodesData).on("tick", this.simulationTickHandler.bind(this)); this.simulation.force("link").links(this.validatedLinks).distance((d) => this.linkDistanceScale(d.score)); this.simulation.alpha(1).restart(); setTimeout(() => { this.simulation.alphaTarget(0); }, 1e3); this.updatingVisualization = false; } simulationTickHandler() { this.nodeSelection.attr("cx", (d) => d.x).attr("cy", (d) => d.y).style("cursor", "pointer"); this.linkSelection.attr("x1", (d) => d.source.x || 0).attr("y1", (d) => d.source.y || 0).style("cursor", "pointer").attr("x2", (d) => d.target.x || 0).attr("y2", (d) => d.target.y || 0); this.linkLabelSelection.attr("x", (d) => (d.source.x + d.target.x) / 2).attr("y", (d) => (d.source.y + d.target.y) / 2); this.labelSelection.attr("x", (d) => d.x).attr("y", (d) => d.y); } async updateConnections() { this.nodes = []; this.links = []; this.connections = []; this.minScore = 1; this.maxScore = 0; if (!this.currentNoteKey) return; this.centralNote = this.smartNotes[this.currentNoteKey]; console.log("central note: ", this.centralNote); const connections = await this.centralNote.find_connections(); const noteConnections = connections.filter( (connection) => connection.score >= this.relevanceScoreThreshold ); this.addCentralNode(); this.addFilteredConnections(noteConnections); const isValid = this.validateGraphData(this.nodes, this.links); if (!isValid) console.error("Graph data validation failed."); } addCentralNode() { if (this.centralNote.key && this.centralNote.key.trim() !== "" && !this.nodes.some((node) => node.id === this.centralNote.key)) { const svg = this.svg.node(); const { width, height } = svg.getBoundingClientRect(); this.nodes.push({ id: this.centralNote.key, name: this.centralNote.key, group: "note", x: width / 2, y: height / 2, fx: null, fy: null, fill: this.noteFillColor, selected: false, highlighted: false }); this.centralNode = this.nodes[this.nodes.length - 1]; } else { console.error(`Central node not found or already exists: ${this.centralNote.key}`); } } addFilteredConnections(noteConnections) { const filteredConnections = noteConnections.filter((connection) => { var _a; if (this.connectionType === "both") { return true; } else { const isBlock = ((_a = connection.item) == null ? void 0 : _a.collection_key) === "smart_blocks"; return this.connectionType === "block" === isBlock; } }); filteredConnections.forEach((connection, index2) => { if (connection && connection.item && connection.item.key) { const connectionId = connection.item.key; this.addConnectionNode(connectionId, connection); this.addConnectionLink(connectionId, connection); } else { console.warn(`Skipping invalid connection at index ${index2}:`, connection); } }); } addConnectionNode(connectionId, connection) { var _a; if (!this.nodes.some((node) => node.id === connectionId)) { const isBlock = ((_a = connection.item) == null ? void 0 : _a.collection_key) === "smart_blocks"; this.nodes.push({ id: connectionId, name: connectionId, group: isBlock ? "block" : "note", x: Math.random() * 1e3, y: Math.random() * 1e3, fx: null, fy: null, fill: isBlock ? this.blockFillColor : this.noteFillColor, selected: false, highlighted: false }); } else { console.log("Node already exists for connection ID:", connectionId); } } addConnectionLink(connectionId, connection) { const sourceNode = this.nodes.find((node) => node.id === this.centralNote.key); const targetNode = this.nodes.find((node) => node.id === connectionId); if (!sourceNode) { console.error(`Source node not found: ${this.centralNote.key}`); return; } if (!targetNode) { console.error(`Target node not found: ${connectionId}`); return; } this.links.push({ source: this.centralNote.key, target: connectionId, value: connection.score || 0 }); this.connections.push({ source: this.centralNote.key, target: connectionId, score: connection.score || 0 }); this.updateScoreRange(connection.score); } updateScoreRange(score) { if (score > this.maxScore) this.maxScore = score; if (score < this.minScore) this.minScore = score; } validateGraphData(nodes, links) { const nodeIds = new Set(nodes.map((node) => node.id)); let isValid = true; links.forEach((link, index2) => { if (!nodeIds.has(link.source)) { console.error(`Link at index ${index2} has an invalid source: ${link.source}`); isValid = false; } if (!nodeIds.has(link.target)) { console.error(`Link at index ${index2} has an invalid target: ${link.target}`); isValid = false; } }); nodes.forEach((node, index2) => { if (!node.hasOwnProperty("id") || !node.hasOwnProperty("name") || !node.hasOwnProperty("group")) { console.error(`Node at index ${index2} is missing required properties: ${JSON.stringify(node)}`); isValid = false; } }); return isValid; } updateNodeAndLinkSelection(nodesData) { const svgGroup = this.svgGroup; this.linkSelection = svgGroup.select("g.smart-connections-visualizer-links").selectAll("line").data(this.validatedLinks, (d) => `${d.source}-${d.target}`).join( (enter) => this.enterLink(enter), (update) => this.updateLink(update), (exit) => exit.remove() ); this.linkLabelSelection = svgGroup.select("g.smart-connections-visualizer-link-labels").selectAll("text").data(this.validatedLinks, (d) => `${d.source.id}-${d.target.id}`).join( (enter) => this.enterLinkLabel(enter), (update) => this.updateLinkLabel(update), (exit) => exit.remove() ); this.labelSelection = svgGroup.select("g.smart-connections-visualizer-node-labels").selectAll("text").data(nodesData, (d) => d.id).join( (enter) => this.enterLabel(enter), (update) => this.updateLabel(update), (exit) => exit.remove() ).attr("x", (d) => d.x).attr("y", (d) => d.y); this.nodeSelection = svgGroup.select("g.smart-connections-visualizer-nodes").selectAll("circle").data(nodesData, (d) => { return d.id; }).join( (enter) => this.enterNode(enter), (update) => this.updateNode(update), (exit) => exit.remove() ); } enterNode(enter) { const that = this; return enter.append("circle").attr("class", "smart-connections-visualizer-node").attr("r", (d) => d.id === this.centralNode.id ? this.nodeSize + 2 : this.nodeSize).attr("fill", (d) => d.fill).attr("stroke", (d) => d.selected ? "blanchedalmond" : "transparent").attr("stroke-width", (d) => d.selected ? 1.5 : 0.3).attr("opacity", 1).attr("cursor", "pointer").call(drag_default().on("start", this.onDragStart.bind(this)).on("drag", this.onDrag.bind(this)).on("end", this.onDragEnd.bind(this))).on("click", this.onNodeClick.bind(this)).on("mouseover", this.onNodeMouseOver.bind(this)).on("mouseout", this.onNodeMouseOut.bind(this)); } updateNode(update) { return update.attr("r", (d) => d.id === this.centralNode.id ? this.nodeSize + 2 : this.nodeSize).attr("fill", (d) => d.selected ? "#f3ee5d" : d.fill).attr("stroke", (d) => d.selected ? "blanchedalmond" : "transparent").attr("stroke-width", (d) => d.selected ? 1.5 : 0.3); } onDragStart(event, d) { if (!event.active) this.simulation.alphaTarget(0.3).restart(); this.dragging = true; d.fx = d.x; d.fy = d.y; } onDrag(event, d) { if (this.isHovering) this.isHovering = false; d.fx = event.x; d.fy = event.y; } onDragEnd(event, d) { if (!event.active) this.simulation.alphaTarget(0); d.fx = null; d.fy = null; this.dragging = false; } onNodeClick(event, d) { if (d.id === this.centralNode.id) return; this.env.plugin.open_note(d.id, event); } onNodeMouseOver(event, d) { if (this.dragging) return; if (d.id === this.centralNode.id) return; this.isHovering = true; this.highlightNode(d); this.updateLinkLabelAppearance(d); this.app.workspace.trigger("hover-link", { event, source: "D3", hoverParent: event.currentTarget.parentElement, targetEl: event.currentTarget, linktext: d.id }); } onNodeMouseOut(event, d) { if (this.dragging) return; this.isHovering = false; this.centerHighlighted = false; this.unhighlightNode(d); this.updateLinkLabelAppearance({ id: null }); } updateLinkLabelPositions() { this.linkLabelSelection.attr("x", (d) => (d.source.x + d.target.x) / 2).attr("y", (d) => (d.source.y + d.target.y) / 2); } updateLinkSelection(svgGroup) { return svgGroup.select("g.links").selectAll("line").data(this.validatedLinks, (d) => `${d.source}-${d.target}`).style("cursor", "pointer").join( (enter) => this.enterLink(enter), (update) => this.updateLink(update), (exit) => exit.remove() ); } enterLink(enter) { return enter.append("line").attr("class", "smart-connections-visualizer-link").attr("stroke", "#4c7787").attr("stroke-width", (d) => this.getLinkStrokeWidth(d)).attr("stroke-opacity", 1).attr("opacity", 1); } updateLink(update) { return update.attr("stroke", "#4c7787").attr("stroke-width", (d) => this.getLinkStrokeWidth(d)); } getLinkStrokeWidth(d) { return linear2().domain([this.minScore, this.maxScore]).range([this.minLinkThickness, this.maxLinkThickness])(d.score); } updateLinkLabelSelection(svgGroup) { return svgGroup.append("g").attr("class", "smart-connections-visualizer-link-labels").selectAll("text").data(this.validatedLinks, (d) => `${d.source.id}-${d.target.id}`).join( (enter) => this.enterLinkLabel(enter), (update) => this.updateLinkLabel(update), (exit) => exit.remove() ); } enterLinkLabel(enter) { return enter.append("text").attr("class", "smart-connections-visualizer-link-label").attr("font-size", this.linkLabelSize).attr("fill", "#bbb").attr("opacity", 0).attr("x", (d) => d.x).attr("y", (d) => d.y).text((d) => (d.score * 100).toFixed(1) + "%"); } updateLinkLabel(update) { return update.text((d) => (d.score * 100).toFixed(1)).attr("x", (d) => d.x).attr("y", (d) => d.y); } enterLabel(enter) { return enter.append("text").attr("class", "smart-connections-visualizer-label").attr("dx", 0).attr("font-size", this.nodeLabelSize).attr("dy", 12).attr("text-anchor", "middle").attr("fill", "#bbb").attr("data-id", (d) => d.id).attr("opacity", 1).attr("x", (d) => d.x).attr("y", (d) => d.y).text((d) => this.formatLabel(d.name)); } updateLabel(update) { return update.attr("dx", 0).attr("data-id", (d) => d.id).attr("text-anchor", "middle").text((d) => d.id === this.highlightedNodeId ? this.formatLabel(d.name, false) : this.formatLabel(d.name, true)).attr("fill", "#bbb").attr("font-size", this.nodeLabelSize).attr("x", (d) => d.x).attr("y", (d) => d.y).attr("opacity", 1); } updateNodeSizes() { this.nodeSelection.attr("r", (d) => d.id === this.centralNode.id ? this.nodeSize + 3 : this.nodeSize); } updateLinkThickness() { const linkStrokeScale = linear2().domain([this.minScore, this.maxScore]).range([this.minLinkThickness, this.maxLinkThickness]); this.linkSelection.attr("stroke-width", (d) => linkStrokeScale(d.score)); } updateSimulationForces() { if (!this.simulation) { console.error("Simulation not initialized"); return; } this.simulation.force("charge", manyBody_default().strength(-this.repelForce)).force("link", link_default(this.validatedLinks).id((d) => d.id).distance((d) => this.linkDistanceScale(d.score)).strength(this.linkForce)); this.simulation.alphaTarget(0.3).restart(); setTimeout(() => { this.simulation.alphaTarget(0); }, 1e3); } normalizeScore(score) { if (this.minScore === this.maxScore) { return 0.5; } return (score - this.minScore) / (this.maxScore - this.minScore); } linkDistanceScale(score) { return linear2().domain([0, 1]).range([this.linkDistance * 2, this.linkDistance / 2])(this.normalizeScore(score)); } updateLabelOpacity(zoomLevel) { const maxOpacity = 1; const minOpacity = 0; const minZoom = 0.1; const maxZoom = this.textFadeThreshold; let newOpacity = (zoomLevel - minZoom) / (maxZoom - minZoom); if (zoomLevel <= minZoom) newOpacity = minOpacity; if (zoomLevel >= maxZoom) newOpacity = maxOpacity; newOpacity = Math.max(minOpacity, Math.min(maxOpacity, newOpacity)); if (this.labelSelection) { this.labelSelection.transition().duration(300).attr("opacity", newOpacity); } } updateNodeLabels() { this.labelSelection.attr("font-size", this.nodeLabelSize).text((d) => this.formatLabel(d.name, true)); } updateLinkLabelSizes() { if (this.linkLabelSelection) { this.linkLabelSelection.attr("font-size", this.linkLabelSize); } } updateNodeLabelSizes() { this.labelSelection.attr("font-size", this.nodeLabelSize); } updateNodeLabelOpacity(zoomLevel) { const maxOpacity = 1; const minOpacity = 0; const minZoom = 0.1; const maxZoom = this.textFadeThreshold; let newOpacity = (zoomLevel - minZoom) / (maxZoom - minZoom); if (zoomLevel <= minZoom) newOpacity = minOpacity; if (zoomLevel >= maxZoom) newOpacity = maxOpacity; newOpacity = Math.max(minOpacity, Math.min(maxOpacity, newOpacity)); this.labelSelection.transition().duration(300).attr("opacity", newOpacity); } startBoxSelection(event) { if (!this.isCtrlPressed) return; this.isDragging = true; const [x3, y3] = pointer_default(event); this.selectionBox = select_default2("svg").append("rect").attr("class", "smart-connections-visualizer-selection-box").attr("x", x3).attr("y", y3).attr("width", 0).attr("height", 0).attr("stroke", "#00f").attr("stroke-width", 1).attr("fill", "rgba(0, 0, 255, 0.3)"); this.startX = x3; this.startY = y3; } updateBoxSelection(event) { if (!this.isDragging) return; const [x3, y3] = pointer_default(event); const newWidth = x3 - this.startX; const newHeight = y3 - this.startY; this.selectionBox.attr("width", Math.abs(newWidth)).attr("height", Math.abs(newHeight)).attr("x", Math.min(x3, this.startX)).attr("y", Math.min(y3, this.startY)); this.updateNodeSelectionInBox(newWidth, newHeight); this.updateNodeAppearance(); } updateNodeSelectionInBox(newWidth, newHeight) { const endX = this.startX + newWidth; const endY = this.startY + newHeight; const transformedStartX = Math.min(this.startX, endX); const transformedStartY = Math.min(this.startY, endY); const transformedEndX = Math.max(this.startX, endX); const transformedEndY = Math.max(this.startY, endY); const transform2 = transform(select_default2("svg").node()); const zoomedStartX = (transformedStartX - transform2.x) / transform2.k; const zoomedStartY = (transformedStartY - transform2.y) / transform2.k; const zoomedEndX = (transformedEndX - transform2.x) / transform2.k; const zoomedEndY = (transformedEndY - transform2.y) / transform2.k; this.nodeSelection.each((d) => { const nodeX = d.x; const nodeY = d.y; d.selected = nodeX >= zoomedStartX && nodeX <= zoomedEndX && nodeY >= zoomedStartY && nodeY <= zoomedEndY; }); } endBoxSelection() { if (!this.isDragging) return; this.isDragging = false; this.selectionBox.remove(); } // TODO:: Add back in when ready for toolti // showTooltip(event: any, d: any) { // const tooltip = d3.select('.tooltip'); // tooltip.text(d.name) // .style('visibility', 'visible'); // const [x, y] = d3.pointer(event); // tooltip.style('top', `${y + 10}px`) // .style('left', `${x + 10}px`); // } // hideTooltip() { // const tooltip = d3.select('.tooltip'); // tooltip.style('visibility', 'hidden'); // } }; var ScGraphView = class extends import_obsidian.Plugin { async onload() { try { await this.loadSettings(); this.registerView("smart-connections-visualizer", (leaf) => new ScGraphItemView(leaf, this)); this.registerHoverLinkSource("smart-connections-visualizer", { display: "Smart connections visualizer hover link source", defaultMod: true }); this.addCommand({ id: "open-smart-connections-visualizer", name: "Open Smart Connections Visualizer", callback: async () => { await this.openSmartConnectionsVisualizer(); } }); this.addRibbonIcon("git-fork", "Open smart connections visualizer", async (evt) => { await this.openSmartConnectionsVisualizer(); }); console.log("Smart Connections Visualizer plugin loaded successfully"); } catch (error) { console.error("Error loading Smart Connections Visualizer plugin:", error); new import_obsidian.Notice("Failed to load Smart Connections Visualizer plugin. Check console for details."); } } async openSmartConnectionsVisualizer() { try { console.log("opening smart connections visualizer"); const existingLeaf = this.app.workspace.getLeavesOfType("smart-connections-visualizer")[0]; console.log("existingLeaf: ", existingLeaf); if (existingLeaf) { console.log("1 opening smart connections visualizer"); this.app.workspace.setActiveLeaf(existingLeaf); console.log("1.5 opening smart connections visualizer"); } else { console.log("2 opening smart connections visualizer"); let leaf = this.app.workspace.getRightLeaf(false); if (!leaf) { leaf = this.app.workspace.getLeaf(true); } console.log("3 opening smart connections visualizer"); await leaf.setViewState({ type: "smart-connections-visualizer", active: true }); console.log("4 opening smart connections visualizer"); } } catch (error) { console.error("Error opening Smart Connections Visualizer:", error); new import_obsidian.Notice("Failed to open Smart Connections Visualizer. Check console for details."); } } async loadSettings() { this.settings = Object.assign({}, DEFAULT_NETWORK_SETTINGS, await this.loadData()); } async saveSettings() { await this.saveData(this.settings); } onunload() { } }; /* nosourcemap */