').addClass('item ' + subject.obj_id)
- .attr({id: subject.obj_id})
- .append(
- item.media = $('
')
- .attr({src: image})
- .addClass('media')
- .on('mouseover', function(event){
- // load_infowin(event, subject.obj_id, this);
- })
- )
- .append(
- item.data = $('
').addClass('data')
- )
- );
- }
- SALSAH.ApiGet('properties', subject.obj_id, {noresedit: true}, function(data) {
- window.status = 'GET...';
- $.each(params.important_props, function(i, prop) {
- var metadata = '';
- if(data.properties[prop] !== undefined) {
- metadata = data.properties[prop].values[0].textval;
- if(data.properties[prop].guielement === 'hlist' || data.properties[prop].guielement === 'geoname') {
- metadata = metadata.split(/ (.+)?/)[1];
- }
- }
- if (i === '1') {
- item.data.append($('
').html(metadata));
- }
- else if (i === '2') {
- item.data.append($('
').append($('').html(metadata)));
- }
- else {
- item.data.append($('').html(metadata));
- }
- });
- });
- // page for only one resource
- if (RESVIEW.winclass == '.workwin_content') {
- item.media.on('click', function(event) {
- SALSAH.zoom_resource(subject.obj_id, {searchtype: searchtype, params: params});
- });
- item.media.on('contextmenu', function(e) {
- SALSAH.zoom_resource(subject.obj_id, {searchtype: searchtype, params: params});
- return false; // no context menu
- });
- }
- else {
- item.media.on('click', function(event) {
- RESVIEW.new_resource_editor(subject.obj_id, '');
- });
- }
-
- } else {
- alert(new Error().lineNumber + ' ' + data.errormsg);
- }
-
- });
-
- });
- break;
-
- default:
- var info_icon = SITE_URL + '/app/icons/16x16/info.png';
- table = $('
').addClass('admin searchres');
- var tableheader;
- table.append(tableheader = $('')
- .append($('').text(s_('_info')))
- .append($(' | ').text(s_('_type')))
- //.append($(' | ').text(strings._property))
- .append($(' | ').text(s_('_value')))
- );
- var max_n_vals = 0;
- var tr;
- var value;
- data.subjects.forEach(function(arrele) {
- var valcell;
- tr = $(' |
').addClass('result_row').data('resid', arrele.obj_id);
- tr.append($('')
- .append($('').attr({src: info_icon}).addClass('result_info').on('mouseover', function(event) {
- load_infowin(event, arrele.obj_id, this);
- }))
- );
- tr.append($(' | ')
- .append($('').attr({src: arrele.iconsrc? arrele.iconsrc : defaultresicon, title: arrele.icontitle}))
- .append(arrele.iconlabel)
- .dragndrop('makeDraggable', 'RESID', {resid: arrele.obj_id})
- );
- var idx;
- if (arrele.value.length > max_n_vals) max_n_vals = arrele.value.length;
- for (idx in arrele.value) {
- tr.append(valcell = $(' | ')
- .append($('').append(arrele.valuelabel[idx] + ' : '))
- );
-
- switch (parseInt(arrele.valuetype_id[idx])) {
- case VALTYPE_TEXT: {
- var valstr;
- if ((params.searchstring !== undefined) && (params.searchstring.length > 0)) {
- var p = arrele.value[idx].indexOf(params.searchstring);
- if (p != -1) {
- var s = p - 25;
- if (s < 0) s = 0;
- var e = p + 35;
- if (e >= arrele.value[idx].length) e = arrele.value[idx].length;
- valstr = '…' + arrele.value[idx].substring(s, e) + '…';
- valstr = valstr.replace(params.searchstring, '' + params.searchstring + '');
- }
- else {
- if (arrele.value[idx]) {
- if (arrele.value[idx].length > 32) {
- valstr = arrele.value[idx].substr(0, 23) + '…';
- }
- else {
- valstr = arrele.value[idx];
- }
- }
- else {
- valstr = '???';
- }
- }
- }
- else {
- if (arrele.value[idx]) {
- if (arrele.value[idx].length > 32) {
- valstr = arrele.value[idx].substr(0, 23) + '…';
- }
- else {
- valstr = arrele.value[idx];
- }
- }
- else {
- valstr = '???';
- }
- }
- valcell.append(valstr)
- break;
- }
- case VALTYPE_TIME: {
- valcell.append($('').timeobj(arrele.value[idx]))
- break;
- }
- case VALTYPE_DATE: {
- valcell.append($('').dateobj(arrele.value[idx]))
- break;
- }
- case VALTYPE_COLOR: {
- valcell.append($('').css({'background-color': arrele.value[idx]}).text(arrele.value[idx]))
- break;
- }
- case VALTYPE_RICHTEXT: {
- if ((params.searchstring !== undefined) && (params.searchstring.length > 0)) {
- var p = arrele.value[idx].utf8str.indexOf(params.searchstring);
- var s = p - 25;
- if (s < 0) s = 0;
- var e = p + 35;
- if (e >= arrele.value[idx].utf8str.length) e = arrele.value[idx].utf8str.length;
- valstr = '…' + arrele.value[idx].utf8str.substring(s, e) + '…';
- valstr = valstr.replace(params.searchstring, '' + params.searchstring + '');
- }
- else {
- if (arrele.value[idx].utf8str.length > 32) {
- valstr = arrele.value[idx].utf8str.substr(0, 32) + '…';
- }
- else {
- valstr = arrele.value[idx].utf8str;
- }
-
- }
- valcell.append(valstr);
- break;
- }
- case VALTYPE_RESPTR: {
- if (arrele.value[idx].resinfo.value_of === undefined) {
- valcell.append(arrele.value[idx].firstprop.label + ' : ' + arrele.value[idx].firstprop.values[0].val + ' (')
- .append($('').attr({src: arrele.value[idx].resinfo.restype_iconsrc, title: arrele.icontitle}).on('click', function(event) {
- event.stopImmediatePropagation();
- if (RESVIEW.winclass == '.workwin_content') {
- SALSAH.show_detail(arrele.value[idx].resid, {searchtype: searchtype, params: params});
- }
- else {
- RESVIEW.new_resource_editor(arrele.value[idx].resid, '');
- }
- }))
- .append(arrele.value[idx].resinfo.restype_label + ')')
- }
- else {
- valcell.append(arrele.value[idx].resinfo.restype_name + '>>' + arrele.value[idx].firstprop.values[0].val + ' (')
- .append($('').attr({src: arrele.value[idx].resinfo.restype_iconsrc, title: arrele.icontitle}))
- .append(arrele.value[idx].resinfo.restype_label + ')');
- }
- break;
- }
- case VALTYPE_ICONCLASS: {
- valcell.append(arrele.value[idx]);
- break;
- }
- default: {
- valcell.append(arrele.value[idx]);
- }
- } // switch
-
- } // foreach
- if (RESVIEW.winclass == '.workwin_content') {
- tr.on('click', function(event) {
- //console.log("calling SALSAH.show_detail")
- SALSAH.show_detail(arrele.obj_id, {searchtype: searchtype, params: params});
- });
- }
- else {
- tr.on('click', function(event) {
- //console.log("1. calling RESVIEW.new_resource_editor")
- RESVIEW.new_resource_editor(arrele.obj_id, '');
- });
- }
- table.append(tr);
- });
- for (var i = 1; i < max_n_vals; i++) {
- tableheader.append($('').text(' '));
- }
- }
- if (params.display_type == 'matrix') {
-
- }
- else {
-
- }
- ele.append(table);
-
- if (pele2 !== undefined) {
- ele.append(pele2);
- }
-
-
-};
diff --git a/salsah1/public/js/03_showval.js b/salsah1/public/js/03_showval.js
deleted file mode 100644
index 421e9cd69b..0000000000
--- a/salsah1/public/js/03_showval.js
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright © 2015-2021 the contributors (see Contributors.md).
- *
- * This file is part of Knora.
- *
- * Knora is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Knora is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with Knora. If not, see .
- */
-
-SALSAH.showval = function(value_container, prop, value_index, options)
-{
-
- // console.log("in showval: valtype is " + prop.valuetype_id);
- switch (prop.valuetype_id) {
- // this value type is mot used anymore: every text is a richtext now
- /*case VALTYPE_TEXT: {
- var reg = new RegExp('(http://[^<>\\s]+[\\w\\d])', 'g'); // replace URL's with anchor tags
- //value_container.append(prop.values[value_index].replace(reg, '$1'));
- value_container.append(prop.values[value_index]);
- break;
- }*/
- case 'LABEL': {
- value_container.append(prop.values[value_index]);
- break;
- }
- case VALTYPE_INTEGER: {
- value_container.append(prop.values[value_index]);
- break;
- }
- case VALTYPE_FLOAT: {
- value_container.append(prop.values[value_index]);
- break;
- }
- case VALTYPE_TIME: {
- value_container.append(prop.values[value_index]);
- break;
- }
- case VALTYPE_BOOLEAN: {
- var checkbox = $('', {
- type: "checkbox"
- });
-
- checkbox.attr('disabled', true);
-
- if (prop.values[value_index]) {
- checkbox.attr('checked', true);
- }
-
- value_container.append(checkbox);
- break;
- }
- case VALTYPE_URI: {
- value_container.append(prop.values[value_index]);
- break;
- }
- case VALTYPE_DATE: {
- value_container.dateobj('init', prop.values[value_index]);
- break;
- }
- case VALTYPE_PERIOD: {
- value_container.append('VALTYPE_PERIOD: NOT YET IMPLEMENTED!');
- break;
- }
- case VALTYPE_RICHTEXT: {
-
- var textobj = {};
-
- // check if it is a simple text without standoff ('utf8str')
- // or a text with standoff markup ('xml')
- if (prop.values[value_index]['utf8str'] !== undefined) {
- // simple text
- textobj.utf8str = prop.values[value_index]['utf8str'];
- } else if (prop.values[value_index]['xml'] !== undefined){
- // xml
- textobj.xml = prop.values[value_index]['xml'];
- } else {
- alert("no text value given for text property (showval.js)")
- }
-
-
- var tmp_ele = $('');
- value_container.append(tmp_ele.htmleditor(textobj));
-
- //
- // add handlers to SALSAH Links here
- //
- value_container.find('a.salsah-link').off('mouseover').on('mouseover', function(event) {
-
- var resid = $(this).attr('href');
- load_infowin(event, resid, this);
-
- }).off('click').on('click', function(event) {
- event.preventDefault();
-
- var resid = $(this).attr('href');
-
- RESVIEW.new_resource_editor(resid, 'Linked Resource');
-
- });
-
- // all links will be opened in a new window
- value_container.find('a').attr({target: '_blank'});
-
- // value is represented by a RESOURCE which relates to the resource (via 'salsah:value_of') the 'normal' properties refer to
- break;
- }
- case VALTYPE_RESPTR: {
- switch (prop.guielement) {
- case 'pulldown':
- case 'searchbox':
- default: { // which is 'pulldown' and 'searchbox'
- var span = $(' ', {'class': 'propedit'}).css('cursor', 'pointer').mouseover(function(event) {
- load_infowin(event, prop.values[value_index], this, 'local');
- }).dragndrop('makeDropable', function(event, dropdata) {
- span.data('drop_resid', dropdata.resid);
- span.next().click();
- }).click(function(event) {
- if (options.simple_view) {
- options.simple_view_action(prop.values[value_index]);
- }
- else {
- // check if this is a part of a compound object pointing to the same via its 'salsah:part_of' prop
- if (prop == 'salsah:part_of' && propinfo['salsah:seqnum'].values !== undefined) {
- // open compund object viewer at the correspondent position
- RESVIEW.new_resource_editor(prop.values[value_index], prop.value_firstprops[value_index], {}, {sequence_number: propinfo['salsah:seqnum'].values[0]});
- } else {
- // standard procedure
- RESVIEW.new_resource_editor(prop.values[value_index], prop.value_firstprops[value_index]);
- }
- }
- }).appendTo(value_container);
- $('', {src: prop.value_iconsrcs[value_index]}).css({borderStyle: 'none'}).appendTo(span);
- $(span).append(' ' + prop.value_firstprops[value_index] + ' (' + prop.value_restype[value_index] + ')');
- }
- }
- break;
- }
- case VALTYPE_HLIST: {
- var hlist_id;
- var attrs = prop.attributes.split(';');
- $.each(attrs, function() {
- var attr = this.split('=');
- if (attr[0] == 'hlist') {
- hlist_id = attr[1].slice(1,-1);
- }
- });
- switch (prop.guielement) {
- case 'hlist': {
- value_container.hlist('init', {hlist_id: hlist_id, value: prop.values[value_index]});
- break;
- }
- case 'radio': {
- value_container.selradio('init', {selection_id: hlist_id, value: prop.values[value_index]});
- break;
- }
- case 'pulldown': {
- value_container.selection('init', {selection_id: hlist_id, value: prop.values[value_index]});
- break;
- }
- }
- break;
- }
- case VALTYPE_INTERVAL: {
- //value_container.append(prop.values[value_index]);
- value_container.timeobj('init', prop.values[value_index]);
- break;
- }
- case VALTYPE_GEOMETRY: {
- var geometry_object = JSON.parse(prop.values[value_index]);
- value_container.css({cursor: 'default'}).append(geometry_object.type);
- if (options.canvas !== undefined) {
- value_container.bind('mouseenter.highlight', function(event) {
- var geo = options.canvas.regions('searchObject', 'val_id', prop.value_ids[value_index]);
- options.canvas.regions('highlightObject', geo.index);
- }).bind('mousemove.highlight', function(event) {
- var geo = options.canvas.regions('searchObject', 'val_id', prop.value_ids[value_index]);
- options.canvas.regions('highlightObject', geo.index);
- }).bind('mouseout.highlight', function(event){
- options.canvas.regions('unhighlightObjects');
- });
- }
- else {
- value_container.append(' (' + strings._open_assoc_res +')');
- }
- break;
- }
- case VALTYPE_COLOR: {
- value_container.colorpicker('init', {color: prop.values[value_index]});
- break;
- }
- case VALTYPE_ICONCLASS: {
- value_container.append(prop.values[value_index]);
- break;
- }
- case VALTYPE_GEONAME: {
- value_container.geonames('init', {value: prop.values[value_index]});
- break;
- }
- default: {
- value_container.append('INTERNAL ERROR: UNKNOWN VALUE TYPE! ' + prop.valuetype_id);
- }
- } // switch(parseInt(prop.valuetype_id))
-
-};
diff --git a/salsah1/public/js/cola.js b/salsah1/public/js/cola.js
deleted file mode 100644
index 1801b81d6b..0000000000
--- a/salsah1/public/js/cola.js
+++ /dev/null
@@ -1,4324 +0,0 @@
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.cola = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o i) {
- var d = D[i][j];
- if (d > 0 && d < this.minD) {
- this.minD = d;
- }
- }
- }
- if (this.minD === Number.MAX_VALUE)
- this.minD = 1;
- i = this.k;
- while (i--) {
- this.g[i] = new Array(n);
- this.H[i] = new Array(n);
- j = n;
- while (j--) {
- this.H[i][j] = new Array(n);
- }
- this.Hd[i] = new Array(n);
- this.a[i] = new Array(n);
- this.b[i] = new Array(n);
- this.c[i] = new Array(n);
- this.d[i] = new Array(n);
- this.e[i] = new Array(n);
- this.ia[i] = new Array(n);
- this.ib[i] = new Array(n);
- this.xtmp[i] = new Array(n);
- }
- }
- Descent.createSquareMatrix = function (n, f) {
- var M = new Array(n);
- for (var i = 0; i < n; ++i) {
- M[i] = new Array(n);
- for (var j = 0; j < n; ++j) {
- M[i][j] = f(i, j);
- }
- }
- return M;
- };
- Descent.prototype.offsetDir = function () {
- var _this = this;
- var u = new Array(this.k);
- var l = 0;
- for (var i = 0; i < this.k; ++i) {
- var x = u[i] = this.random.getNextBetween(0.01, 1) - 0.5;
- l += x * x;
- }
- l = Math.sqrt(l);
- return u.map(function (x) { return x *= _this.minD / l; });
- };
- Descent.prototype.computeDerivatives = function (x) {
- var _this = this;
- var n = this.n;
- if (n < 1)
- return;
- var i;
- var d = new Array(this.k);
- var d2 = new Array(this.k);
- var Huu = new Array(this.k);
- var maxH = 0;
- for (var u = 0; u < n; ++u) {
- for (i = 0; i < this.k; ++i)
- Huu[i] = this.g[i][u] = 0;
- for (var v = 0; v < n; ++v) {
- if (u === v)
- continue;
- var maxDisplaces = n;
- while (maxDisplaces--) {
- var sd2 = 0;
- for (i = 0; i < this.k; ++i) {
- var dx = d[i] = x[i][u] - x[i][v];
- sd2 += d2[i] = dx * dx;
- }
- if (sd2 > 1e-9)
- break;
- var rd = this.offsetDir();
- for (i = 0; i < this.k; ++i)
- x[i][v] += rd[i];
- }
- var l = Math.sqrt(sd2);
- var D = this.D[u][v];
- var weight = this.G != null ? this.G[u][v] : 1;
- if (weight > 1 && l > D || !isFinite(D)) {
- for (i = 0; i < this.k; ++i)
- this.H[i][u][v] = 0;
- continue;
- }
- if (weight > 1) {
- weight = 1;
- }
- var D2 = D * D;
- var gs = 2 * weight * (l - D) / (D2 * l);
- var l3 = l * l * l;
- var hs = 2 * -weight / (D2 * l3);
- if (!isFinite(gs))
- console.log(gs);
- for (i = 0; i < this.k; ++i) {
- this.g[i][u] += d[i] * gs;
- Huu[i] -= this.H[i][u][v] = hs * (l3 + D * (d2[i] - sd2) + l * sd2);
- }
- }
- for (i = 0; i < this.k; ++i)
- maxH = Math.max(maxH, this.H[i][u][u] = Huu[i]);
- }
- var r = this.snapGridSize / 2;
- var g = this.snapGridSize;
- var w = this.snapStrength;
- var k = w / (r * r);
- var numNodes = this.numGridSnapNodes;
- for (var u = 0; u < numNodes; ++u) {
- for (i = 0; i < this.k; ++i) {
- var xiu = this.x[i][u];
- var m = xiu / g;
- var f = m % 1;
- var q = m - f;
- var a = Math.abs(f);
- var dx = (a <= 0.5) ? xiu - q * g :
- (xiu > 0) ? xiu - (q + 1) * g : xiu - (q - 1) * g;
- if (-r < dx && dx <= r) {
- if (this.scaleSnapByMaxH) {
- this.g[i][u] += maxH * k * dx;
- this.H[i][u][u] += maxH * k;
- }
- else {
- this.g[i][u] += k * dx;
- this.H[i][u][u] += k;
- }
- }
- }
- }
- if (!this.locks.isEmpty()) {
- this.locks.apply(function (u, p) {
- for (i = 0; i < _this.k; ++i) {
- _this.H[i][u][u] += maxH;
- _this.g[i][u] -= maxH * (p[i] - x[i][u]);
- }
- });
- }
- };
- Descent.dotProd = function (a, b) {
- var x = 0, i = a.length;
- while (i--)
- x += a[i] * b[i];
- return x;
- };
- Descent.rightMultiply = function (m, v, r) {
- var i = m.length;
- while (i--)
- r[i] = Descent.dotProd(m[i], v);
- };
- Descent.prototype.computeStepSize = function (d) {
- var numerator = 0, denominator = 0;
- for (var i = 0; i < this.k; ++i) {
- numerator += Descent.dotProd(this.g[i], d[i]);
- Descent.rightMultiply(this.H[i], d[i], this.Hd[i]);
- denominator += Descent.dotProd(d[i], this.Hd[i]);
- }
- if (denominator === 0 || !isFinite(denominator))
- return 0;
- return 1 * numerator / denominator;
- };
- Descent.prototype.reduceStress = function () {
- this.computeDerivatives(this.x);
- var alpha = this.computeStepSize(this.g);
- for (var i = 0; i < this.k; ++i) {
- this.takeDescentStep(this.x[i], this.g[i], alpha);
- }
- return this.computeStress();
- };
- Descent.copy = function (a, b) {
- var m = a.length, n = b[0].length;
- for (var i = 0; i < m; ++i) {
- for (var j = 0; j < n; ++j) {
- b[i][j] = a[i][j];
- }
- }
- };
- Descent.prototype.stepAndProject = function (x0, r, d, stepSize) {
- Descent.copy(x0, r);
- this.takeDescentStep(r[0], d[0], stepSize);
- if (this.project)
- this.project[0](x0[0], x0[1], r[0]);
- this.takeDescentStep(r[1], d[1], stepSize);
- if (this.project)
- this.project[1](r[0], x0[1], r[1]);
- for (var i = 2; i < this.k; i++)
- this.takeDescentStep(r[i], d[i], stepSize);
- };
- Descent.mApply = function (m, n, f) {
- var i = m;
- while (i-- > 0) {
- var j = n;
- while (j-- > 0)
- f(i, j);
- }
- };
- Descent.prototype.matrixApply = function (f) {
- Descent.mApply(this.k, this.n, f);
- };
- Descent.prototype.computeNextPosition = function (x0, r) {
- var _this = this;
- this.computeDerivatives(x0);
- var alpha = this.computeStepSize(this.g);
- this.stepAndProject(x0, r, this.g, alpha);
- if (this.project) {
- this.matrixApply(function (i, j) { return _this.e[i][j] = x0[i][j] - r[i][j]; });
- var beta = this.computeStepSize(this.e);
- beta = Math.max(0.2, Math.min(beta, 1));
- this.stepAndProject(x0, r, this.e, beta);
- }
- };
- Descent.prototype.run = function (iterations) {
- var stress = Number.MAX_VALUE, converged = false;
- while (!converged && iterations-- > 0) {
- var s = this.rungeKutta();
- converged = Math.abs(stress / s - 1) < this.threshold;
- stress = s;
- }
- return stress;
- };
- Descent.prototype.rungeKutta = function () {
- var _this = this;
- this.computeNextPosition(this.x, this.a);
- Descent.mid(this.x, this.a, this.ia);
- this.computeNextPosition(this.ia, this.b);
- Descent.mid(this.x, this.b, this.ib);
- this.computeNextPosition(this.ib, this.c);
- this.computeNextPosition(this.c, this.d);
- var disp = 0;
- this.matrixApply(function (i, j) {
- var x = (_this.a[i][j] + 2.0 * _this.b[i][j] + 2.0 * _this.c[i][j] + _this.d[i][j]) / 6.0, d = _this.x[i][j] - x;
- disp += d * d;
- _this.x[i][j] = x;
- });
- return disp;
- };
- Descent.mid = function (a, b, m) {
- Descent.mApply(a.length, a[0].length, function (i, j) {
- return m[i][j] = a[i][j] + (b[i][j] - a[i][j]) / 2.0;
- });
- };
- Descent.prototype.takeDescentStep = function (x, d, stepSize) {
- for (var i = 0; i < this.n; ++i) {
- x[i] = x[i] - stepSize * d[i];
- }
- };
- Descent.prototype.computeStress = function () {
- var stress = 0;
- for (var u = 0, nMinus1 = this.n - 1; u < nMinus1; ++u) {
- for (var v = u + 1, n = this.n; v < n; ++v) {
- var l = 0;
- for (var i = 0; i < this.k; ++i) {
- var dx = this.x[i][u] - this.x[i][v];
- l += dx * dx;
- }
- l = Math.sqrt(l);
- var d = this.D[u][v];
- if (!isFinite(d))
- continue;
- var rl = d - l;
- var d2 = d * d;
- stress += rl * rl / d2;
- }
- }
- return stress;
- };
- return Descent;
-}());
-Descent.zeroDistance = 1e-10;
-exports.Descent = Descent;
-var PseudoRandom = (function () {
- function PseudoRandom(seed) {
- if (seed === void 0) { seed = 1; }
- this.seed = seed;
- this.a = 214013;
- this.c = 2531011;
- this.m = 2147483648;
- this.range = 32767;
- }
- PseudoRandom.prototype.getNext = function () {
- this.seed = (this.seed * this.a + this.c) % this.m;
- return (this.seed >> 16) / this.range;
- };
- PseudoRandom.prototype.getNextBetween = function (min, max) {
- return min + this.getNext() * (max - min);
- };
- return PseudoRandom;
-}());
-exports.PseudoRandom = PseudoRandom;
-
-},{}],7:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-};
-var rectangle_1 = require("./rectangle");
-var Point = (function () {
- function Point() {
- }
- return Point;
-}());
-exports.Point = Point;
-var LineSegment = (function () {
- function LineSegment(x1, y1, x2, y2) {
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
- }
- return LineSegment;
-}());
-exports.LineSegment = LineSegment;
-var PolyPoint = (function (_super) {
- __extends(PolyPoint, _super);
- function PolyPoint() {
- return _super.apply(this, arguments) || this;
- }
- return PolyPoint;
-}(Point));
-exports.PolyPoint = PolyPoint;
-function isLeft(P0, P1, P2) {
- return (P1.x - P0.x) * (P2.y - P0.y) - (P2.x - P0.x) * (P1.y - P0.y);
-}
-exports.isLeft = isLeft;
-function above(p, vi, vj) {
- return isLeft(p, vi, vj) > 0;
-}
-function below(p, vi, vj) {
- return isLeft(p, vi, vj) < 0;
-}
-function ConvexHull(S) {
- var P = S.slice(0).sort(function (a, b) { return a.x !== b.x ? b.x - a.x : b.y - a.y; });
- var n = S.length, i;
- var minmin = 0;
- var xmin = P[0].x;
- for (i = 1; i < n; ++i) {
- if (P[i].x !== xmin)
- break;
- }
- var minmax = i - 1;
- var H = [];
- H.push(P[minmin]);
- if (minmax === n - 1) {
- if (P[minmax].y !== P[minmin].y)
- H.push(P[minmax]);
- }
- else {
- var maxmin, maxmax = n - 1;
- var xmax = P[n - 1].x;
- for (i = n - 2; i >= 0; i--)
- if (P[i].x !== xmax)
- break;
- maxmin = i + 1;
- i = minmax;
- while (++i <= maxmin) {
- if (isLeft(P[minmin], P[maxmin], P[i]) >= 0 && i < maxmin)
- continue;
- while (H.length > 1) {
- if (isLeft(H[H.length - 2], H[H.length - 1], P[i]) > 0)
- break;
- else
- H.length -= 1;
- }
- if (i != minmin)
- H.push(P[i]);
- }
- if (maxmax != maxmin)
- H.push(P[maxmax]);
- var bot = H.length;
- i = maxmin;
- while (--i >= minmax) {
- if (isLeft(P[maxmax], P[minmax], P[i]) >= 0 && i > minmax)
- continue;
- while (H.length > bot) {
- if (isLeft(H[H.length - 2], H[H.length - 1], P[i]) > 0)
- break;
- else
- H.length -= 1;
- }
- if (i != minmin)
- H.push(P[i]);
- }
- }
- return H;
-}
-exports.ConvexHull = ConvexHull;
-function clockwiseRadialSweep(p, P, f) {
- P.slice(0).sort(function (a, b) { return Math.atan2(a.y - p.y, a.x - p.x) - Math.atan2(b.y - p.y, b.x - p.x); }).forEach(f);
-}
-exports.clockwiseRadialSweep = clockwiseRadialSweep;
-function nextPolyPoint(p, ps) {
- if (p.polyIndex === ps.length - 1)
- return ps[0];
- return ps[p.polyIndex + 1];
-}
-function prevPolyPoint(p, ps) {
- if (p.polyIndex === 0)
- return ps[ps.length - 1];
- return ps[p.polyIndex - 1];
-}
-function tangent_PointPolyC(P, V) {
- return { rtan: Rtangent_PointPolyC(P, V), ltan: Ltangent_PointPolyC(P, V) };
-}
-function Rtangent_PointPolyC(P, V) {
- var n = V.length - 1;
- var a, b, c;
- var upA, dnC;
- if (below(P, V[1], V[0]) && !above(P, V[n - 1], V[0]))
- return 0;
- for (a = 0, b = n;;) {
- if (b - a === 1)
- if (above(P, V[a], V[b]))
- return a;
- else
- return b;
- c = Math.floor((a + b) / 2);
- dnC = below(P, V[c + 1], V[c]);
- if (dnC && !above(P, V[c - 1], V[c]))
- return c;
- upA = above(P, V[a + 1], V[a]);
- if (upA) {
- if (dnC)
- b = c;
- else {
- if (above(P, V[a], V[c]))
- b = c;
- else
- a = c;
- }
- }
- else {
- if (!dnC)
- a = c;
- else {
- if (below(P, V[a], V[c]))
- b = c;
- else
- a = c;
- }
- }
- }
-}
-function Ltangent_PointPolyC(P, V) {
- var n = V.length - 1;
- var a, b, c;
- var dnA, dnC;
- if (above(P, V[n - 1], V[0]) && !below(P, V[1], V[0]))
- return 0;
- for (a = 0, b = n;;) {
- if (b - a === 1)
- if (below(P, V[a], V[b]))
- return a;
- else
- return b;
- c = Math.floor((a + b) / 2);
- dnC = below(P, V[c + 1], V[c]);
- if (above(P, V[c - 1], V[c]) && !dnC)
- return c;
- dnA = below(P, V[a + 1], V[a]);
- if (dnA) {
- if (!dnC)
- b = c;
- else {
- if (below(P, V[a], V[c]))
- b = c;
- else
- a = c;
- }
- }
- else {
- if (dnC)
- a = c;
- else {
- if (above(P, V[a], V[c]))
- b = c;
- else
- a = c;
- }
- }
- }
-}
-function tangent_PolyPolyC(V, W, t1, t2, cmp1, cmp2) {
- var ix1, ix2;
- ix1 = t1(W[0], V);
- ix2 = t2(V[ix1], W);
- var done = false;
- while (!done) {
- done = true;
- while (true) {
- if (ix1 === V.length - 1)
- ix1 = 0;
- if (cmp1(W[ix2], V[ix1], V[ix1 + 1]))
- break;
- ++ix1;
- }
- while (true) {
- if (ix2 === 0)
- ix2 = W.length - 1;
- if (cmp2(V[ix1], W[ix2], W[ix2 - 1]))
- break;
- --ix2;
- done = false;
- }
- }
- return { t1: ix1, t2: ix2 };
-}
-exports.tangent_PolyPolyC = tangent_PolyPolyC;
-function LRtangent_PolyPolyC(V, W) {
- var rl = RLtangent_PolyPolyC(W, V);
- return { t1: rl.t2, t2: rl.t1 };
-}
-exports.LRtangent_PolyPolyC = LRtangent_PolyPolyC;
-function RLtangent_PolyPolyC(V, W) {
- return tangent_PolyPolyC(V, W, Rtangent_PointPolyC, Ltangent_PointPolyC, above, below);
-}
-exports.RLtangent_PolyPolyC = RLtangent_PolyPolyC;
-function LLtangent_PolyPolyC(V, W) {
- return tangent_PolyPolyC(V, W, Ltangent_PointPolyC, Ltangent_PointPolyC, below, below);
-}
-exports.LLtangent_PolyPolyC = LLtangent_PolyPolyC;
-function RRtangent_PolyPolyC(V, W) {
- return tangent_PolyPolyC(V, W, Rtangent_PointPolyC, Rtangent_PointPolyC, above, above);
-}
-exports.RRtangent_PolyPolyC = RRtangent_PolyPolyC;
-var BiTangent = (function () {
- function BiTangent(t1, t2) {
- this.t1 = t1;
- this.t2 = t2;
- }
- return BiTangent;
-}());
-exports.BiTangent = BiTangent;
-var BiTangents = (function () {
- function BiTangents() {
- }
- return BiTangents;
-}());
-exports.BiTangents = BiTangents;
-var TVGPoint = (function (_super) {
- __extends(TVGPoint, _super);
- function TVGPoint() {
- return _super.apply(this, arguments) || this;
- }
- return TVGPoint;
-}(Point));
-exports.TVGPoint = TVGPoint;
-var VisibilityVertex = (function () {
- function VisibilityVertex(id, polyid, polyvertid, p) {
- this.id = id;
- this.polyid = polyid;
- this.polyvertid = polyvertid;
- this.p = p;
- p.vv = this;
- }
- return VisibilityVertex;
-}());
-exports.VisibilityVertex = VisibilityVertex;
-var VisibilityEdge = (function () {
- function VisibilityEdge(source, target) {
- this.source = source;
- this.target = target;
- }
- VisibilityEdge.prototype.length = function () {
- var dx = this.source.p.x - this.target.p.x;
- var dy = this.source.p.y - this.target.p.y;
- return Math.sqrt(dx * dx + dy * dy);
- };
- return VisibilityEdge;
-}());
-exports.VisibilityEdge = VisibilityEdge;
-var TangentVisibilityGraph = (function () {
- function TangentVisibilityGraph(P, g0) {
- this.P = P;
- this.V = [];
- this.E = [];
- if (!g0) {
- var n = P.length;
- for (var i = 0; i < n; i++) {
- var p = P[i];
- for (var j = 0; j < p.length; ++j) {
- var pj = p[j], vv = new VisibilityVertex(this.V.length, i, j, pj);
- this.V.push(vv);
- if (j > 0)
- this.E.push(new VisibilityEdge(p[j - 1].vv, vv));
- }
- }
- for (var i = 0; i < n - 1; i++) {
- var Pi = P[i];
- for (var j = i + 1; j < n; j++) {
- var Pj = P[j], t = tangents(Pi, Pj);
- for (var q in t) {
- var c = t[q], source = Pi[c.t1], target = Pj[c.t2];
- this.addEdgeIfVisible(source, target, i, j);
- }
- }
- }
- }
- else {
- this.V = g0.V.slice(0);
- this.E = g0.E.slice(0);
- }
- }
- TangentVisibilityGraph.prototype.addEdgeIfVisible = function (u, v, i1, i2) {
- if (!this.intersectsPolys(new LineSegment(u.x, u.y, v.x, v.y), i1, i2)) {
- this.E.push(new VisibilityEdge(u.vv, v.vv));
- }
- };
- TangentVisibilityGraph.prototype.addPoint = function (p, i1) {
- var n = this.P.length;
- this.V.push(new VisibilityVertex(this.V.length, n, 0, p));
- for (var i = 0; i < n; ++i) {
- if (i === i1)
- continue;
- var poly = this.P[i], t = tangent_PointPolyC(p, poly);
- this.addEdgeIfVisible(p, poly[t.ltan], i1, i);
- this.addEdgeIfVisible(p, poly[t.rtan], i1, i);
- }
- return p.vv;
- };
- TangentVisibilityGraph.prototype.intersectsPolys = function (l, i1, i2) {
- for (var i = 0, n = this.P.length; i < n; ++i) {
- if (i != i1 && i != i2 && intersects(l, this.P[i]).length > 0) {
- return true;
- }
- }
- return false;
- };
- return TangentVisibilityGraph;
-}());
-exports.TangentVisibilityGraph = TangentVisibilityGraph;
-function intersects(l, P) {
- var ints = [];
- for (var i = 1, n = P.length; i < n; ++i) {
- var int = rectangle_1.Rectangle.lineIntersection(l.x1, l.y1, l.x2, l.y2, P[i - 1].x, P[i - 1].y, P[i].x, P[i].y);
- if (int)
- ints.push(int);
- }
- return ints;
-}
-function tangents(V, W) {
- var m = V.length - 1, n = W.length - 1;
- var bt = new BiTangents();
- for (var i = 0; i < m; ++i) {
- for (var j = 0; j < n; ++j) {
- var v1 = V[i == 0 ? m - 1 : i - 1];
- var v2 = V[i];
- var v3 = V[i + 1];
- var w1 = W[j == 0 ? n - 1 : j - 1];
- var w2 = W[j];
- var w3 = W[j + 1];
- var v1v2w2 = isLeft(v1, v2, w2);
- var v2w1w2 = isLeft(v2, w1, w2);
- var v2w2w3 = isLeft(v2, w2, w3);
- var w1w2v2 = isLeft(w1, w2, v2);
- var w2v1v2 = isLeft(w2, v1, v2);
- var w2v2v3 = isLeft(w2, v2, v3);
- if (v1v2w2 >= 0 && v2w1w2 >= 0 && v2w2w3 < 0
- && w1w2v2 >= 0 && w2v1v2 >= 0 && w2v2v3 < 0) {
- bt.ll = new BiTangent(i, j);
- }
- else if (v1v2w2 <= 0 && v2w1w2 <= 0 && v2w2w3 > 0
- && w1w2v2 <= 0 && w2v1v2 <= 0 && w2v2v3 > 0) {
- bt.rr = new BiTangent(i, j);
- }
- else if (v1v2w2 <= 0 && v2w1w2 > 0 && v2w2w3 <= 0
- && w1w2v2 >= 0 && w2v1v2 < 0 && w2v2v3 >= 0) {
- bt.rl = new BiTangent(i, j);
- }
- else if (v1v2w2 >= 0 && v2w1w2 < 0 && v2w2w3 >= 0
- && w1w2v2 <= 0 && w2v1v2 > 0 && w2v2v3 <= 0) {
- bt.lr = new BiTangent(i, j);
- }
- }
- }
- return bt;
-}
-exports.tangents = tangents;
-function isPointInsidePoly(p, poly) {
- for (var i = 1, n = poly.length; i < n; ++i)
- if (below(poly[i - 1], poly[i], p))
- return false;
- return true;
-}
-function isAnyPInQ(p, q) {
- return !p.every(function (v) { return !isPointInsidePoly(v, q); });
-}
-function polysOverlap(p, q) {
- if (isAnyPInQ(p, q))
- return true;
- if (isAnyPInQ(q, p))
- return true;
- for (var i = 1, n = p.length; i < n; ++i) {
- var v = p[i], u = p[i - 1];
- if (intersects(new LineSegment(u.x, u.y, v.x, v.y), q).length > 0)
- return true;
- }
- return false;
-}
-exports.polysOverlap = polysOverlap;
-
-},{"./rectangle":16}],8:[function(require,module,exports){
-"use strict";
-var rectangle_1 = require("./rectangle");
-var vpsc_1 = require("./vpsc");
-var shortestpaths_1 = require("./shortestpaths");
-var NodeWrapper = (function () {
- function NodeWrapper(id, rect, children) {
- this.id = id;
- this.rect = rect;
- this.children = children;
- this.leaf = typeof children === 'undefined' || children.length === 0;
- }
- return NodeWrapper;
-}());
-exports.NodeWrapper = NodeWrapper;
-var Vert = (function () {
- function Vert(id, x, y, node, line) {
- if (node === void 0) { node = null; }
- if (line === void 0) { line = null; }
- this.id = id;
- this.x = x;
- this.y = y;
- this.node = node;
- this.line = line;
- }
- return Vert;
-}());
-exports.Vert = Vert;
-var LongestCommonSubsequence = (function () {
- function LongestCommonSubsequence(s, t) {
- this.s = s;
- this.t = t;
- var mf = LongestCommonSubsequence.findMatch(s, t);
- var tr = t.slice(0).reverse();
- var mr = LongestCommonSubsequence.findMatch(s, tr);
- if (mf.length >= mr.length) {
- this.length = mf.length;
- this.si = mf.si;
- this.ti = mf.ti;
- this.reversed = false;
- }
- else {
- this.length = mr.length;
- this.si = mr.si;
- this.ti = t.length - mr.ti - mr.length;
- this.reversed = true;
- }
- }
- LongestCommonSubsequence.findMatch = function (s, t) {
- var m = s.length;
- var n = t.length;
- var match = { length: 0, si: -1, ti: -1 };
- var l = new Array(m);
- for (var i = 0; i < m; i++) {
- l[i] = new Array(n);
- for (var j = 0; j < n; j++)
- if (s[i] === t[j]) {
- var v = l[i][j] = (i === 0 || j === 0) ? 1 : l[i - 1][j - 1] + 1;
- if (v > match.length) {
- match.length = v;
- match.si = i - v + 1;
- match.ti = j - v + 1;
- }
- ;
- }
- else
- l[i][j] = 0;
- }
- return match;
- };
- LongestCommonSubsequence.prototype.getSequence = function () {
- return this.length >= 0 ? this.s.slice(this.si, this.si + this.length) : [];
- };
- return LongestCommonSubsequence;
-}());
-exports.LongestCommonSubsequence = LongestCommonSubsequence;
-var GridRouter = (function () {
- function GridRouter(originalnodes, accessor, groupPadding) {
- if (groupPadding === void 0) { groupPadding = 12; }
- var _this = this;
- this.originalnodes = originalnodes;
- this.groupPadding = groupPadding;
- this.leaves = null;
- this.nodes = originalnodes.map(function (v, i) { return new NodeWrapper(i, accessor.getBounds(v), accessor.getChildren(v)); });
- this.leaves = this.nodes.filter(function (v) { return v.leaf; });
- this.groups = this.nodes.filter(function (g) { return !g.leaf; });
- this.cols = this.getGridLines('x');
- this.rows = this.getGridLines('y');
- this.groups.forEach(function (v) {
- return v.children.forEach(function (c) { return _this.nodes[c].parent = v; });
- });
- this.root = { children: [] };
- this.nodes.forEach(function (v) {
- if (typeof v.parent === 'undefined') {
- v.parent = _this.root;
- _this.root.children.push(v.id);
- }
- v.ports = [];
- });
- this.backToFront = this.nodes.slice(0);
- this.backToFront.sort(function (x, y) { return _this.getDepth(x) - _this.getDepth(y); });
- var frontToBackGroups = this.backToFront.slice(0).reverse().filter(function (g) { return !g.leaf; });
- frontToBackGroups.forEach(function (v) {
- var r = rectangle_1.Rectangle.empty();
- v.children.forEach(function (c) { return r = r.union(_this.nodes[c].rect); });
- v.rect = r.inflate(_this.groupPadding);
- });
- var colMids = this.midPoints(this.cols.map(function (r) { return r.pos; }));
- var rowMids = this.midPoints(this.rows.map(function (r) { return r.pos; }));
- var rowx = colMids[0], rowX = colMids[colMids.length - 1];
- var coly = rowMids[0], colY = rowMids[rowMids.length - 1];
- var hlines = this.rows.map(function (r) { return ({ x1: rowx, x2: rowX, y1: r.pos, y2: r.pos }); })
- .concat(rowMids.map(function (m) { return ({ x1: rowx, x2: rowX, y1: m, y2: m }); }));
- var vlines = this.cols.map(function (c) { return ({ x1: c.pos, x2: c.pos, y1: coly, y2: colY }); })
- .concat(colMids.map(function (m) { return ({ x1: m, x2: m, y1: coly, y2: colY }); }));
- var lines = hlines.concat(vlines);
- lines.forEach(function (l) { return l.verts = []; });
- this.verts = [];
- this.edges = [];
- hlines.forEach(function (h) {
- return vlines.forEach(function (v) {
- var p = new Vert(_this.verts.length, v.x1, h.y1);
- h.verts.push(p);
- v.verts.push(p);
- _this.verts.push(p);
- var i = _this.backToFront.length;
- while (i-- > 0) {
- var node = _this.backToFront[i], r = node.rect;
- var dx = Math.abs(p.x - r.cx()), dy = Math.abs(p.y - r.cy());
- if (dx < r.width() / 2 && dy < r.height() / 2) {
- p.node = node;
- break;
- }
- }
- });
- });
- lines.forEach(function (l, li) {
- _this.nodes.forEach(function (v, i) {
- v.rect.lineIntersections(l.x1, l.y1, l.x2, l.y2).forEach(function (intersect, j) {
- var p = new Vert(_this.verts.length, intersect.x, intersect.y, v, l);
- _this.verts.push(p);
- l.verts.push(p);
- v.ports.push(p);
- });
- });
- var isHoriz = Math.abs(l.y1 - l.y2) < 0.1;
- var delta = function (a, b) { return isHoriz ? b.x - a.x : b.y - a.y; };
- l.verts.sort(delta);
- for (var i = 1; i < l.verts.length; i++) {
- var u = l.verts[i - 1], v = l.verts[i];
- if (u.node && u.node === v.node && u.node.leaf)
- continue;
- _this.edges.push({ source: u.id, target: v.id, length: Math.abs(delta(u, v)) });
- }
- });
- }
- GridRouter.prototype.avg = function (a) { return a.reduce(function (x, y) { return x + y; }) / a.length; };
- GridRouter.prototype.getGridLines = function (axis) {
- var columns = [];
- var ls = this.leaves.slice(0, this.leaves.length);
- while (ls.length > 0) {
- var overlapping = ls.filter(function (v) { return v.rect['overlap' + axis.toUpperCase()](ls[0].rect); });
- var col = {
- nodes: overlapping,
- pos: this.avg(overlapping.map(function (v) { return v.rect['c' + axis](); }))
- };
- columns.push(col);
- col.nodes.forEach(function (v) { return ls.splice(ls.indexOf(v), 1); });
- }
- columns.sort(function (a, b) { return a.pos - b.pos; });
- return columns;
- };
- GridRouter.prototype.getDepth = function (v) {
- var depth = 0;
- while (v.parent !== this.root) {
- depth++;
- v = v.parent;
- }
- return depth;
- };
- GridRouter.prototype.midPoints = function (a) {
- var gap = a[1] - a[0];
- var mids = [a[0] - gap / 2];
- for (var i = 1; i < a.length; i++) {
- mids.push((a[i] + a[i - 1]) / 2);
- }
- mids.push(a[a.length - 1] + gap / 2);
- return mids;
- };
- GridRouter.prototype.findLineage = function (v) {
- var lineage = [v];
- do {
- v = v.parent;
- lineage.push(v);
- } while (v !== this.root);
- return lineage.reverse();
- };
- GridRouter.prototype.findAncestorPathBetween = function (a, b) {
- var aa = this.findLineage(a), ba = this.findLineage(b), i = 0;
- while (aa[i] === ba[i])
- i++;
- return { commonAncestor: aa[i - 1], lineages: aa.slice(i).concat(ba.slice(i)) };
- };
- GridRouter.prototype.siblingObstacles = function (a, b) {
- var _this = this;
- var path = this.findAncestorPathBetween(a, b);
- var lineageLookup = {};
- path.lineages.forEach(function (v) { return lineageLookup[v.id] = {}; });
- var obstacles = path.commonAncestor.children.filter(function (v) { return !(v in lineageLookup); });
- path.lineages
- .filter(function (v) { return v.parent !== path.commonAncestor; })
- .forEach(function (v) { return obstacles = obstacles.concat(v.parent.children.filter(function (c) { return c !== v.id; })); });
- return obstacles.map(function (v) { return _this.nodes[v]; });
- };
- GridRouter.getSegmentSets = function (routes, x, y) {
- var vsegments = [];
- for (var ei = 0; ei < routes.length; ei++) {
- var route = routes[ei];
- for (var si = 0; si < route.length; si++) {
- var s = route[si];
- s.edgeid = ei;
- s.i = si;
- var sdx = s[1][x] - s[0][x];
- if (Math.abs(sdx) < 0.1) {
- vsegments.push(s);
- }
- }
- }
- vsegments.sort(function (a, b) { return a[0][x] - b[0][x]; });
- var vsegmentsets = [];
- var segmentset = null;
- for (var i = 0; i < vsegments.length; i++) {
- var s = vsegments[i];
- if (!segmentset || Math.abs(s[0][x] - segmentset.pos) > 0.1) {
- segmentset = { pos: s[0][x], segments: [] };
- vsegmentsets.push(segmentset);
- }
- segmentset.segments.push(s);
- }
- return vsegmentsets;
- };
- GridRouter.nudgeSegs = function (x, y, routes, segments, leftOf, gap) {
- var n = segments.length;
- if (n <= 1)
- return;
- var vs = segments.map(function (s) { return new vpsc_1.Variable(s[0][x]); });
- var cs = [];
- for (var i = 0; i < n; i++) {
- for (var j = 0; j < n; j++) {
- if (i === j)
- continue;
- var s1 = segments[i], s2 = segments[j], e1 = s1.edgeid, e2 = s2.edgeid, lind = -1, rind = -1;
- if (x == 'x') {
- if (leftOf(e1, e2)) {
- if (s1[0][y] < s1[1][y]) {
- lind = j, rind = i;
- }
- else {
- lind = i, rind = j;
- }
- }
- }
- else {
- if (leftOf(e1, e2)) {
- if (s1[0][y] < s1[1][y]) {
- lind = i, rind = j;
- }
- else {
- lind = j, rind = i;
- }
- }
- }
- if (lind >= 0) {
- cs.push(new vpsc_1.Constraint(vs[lind], vs[rind], gap));
- }
- }
- }
- var solver = new vpsc_1.Solver(vs, cs);
- solver.solve();
- vs.forEach(function (v, i) {
- var s = segments[i];
- var pos = v.position();
- s[0][x] = s[1][x] = pos;
- var route = routes[s.edgeid];
- if (s.i > 0)
- route[s.i - 1][1][x] = pos;
- if (s.i < route.length - 1)
- route[s.i + 1][0][x] = pos;
- });
- };
- GridRouter.nudgeSegments = function (routes, x, y, leftOf, gap) {
- var vsegmentsets = GridRouter.getSegmentSets(routes, x, y);
- for (var i = 0; i < vsegmentsets.length; i++) {
- var ss = vsegmentsets[i];
- var events = [];
- for (var j = 0; j < ss.segments.length; j++) {
- var s = ss.segments[j];
- events.push({ type: 0, s: s, pos: Math.min(s[0][y], s[1][y]) });
- events.push({ type: 1, s: s, pos: Math.max(s[0][y], s[1][y]) });
- }
- events.sort(function (a, b) { return a.pos - b.pos + a.type - b.type; });
- var open = [];
- var openCount = 0;
- events.forEach(function (e) {
- if (e.type === 0) {
- open.push(e.s);
- openCount++;
- }
- else {
- openCount--;
- }
- if (openCount == 0) {
- GridRouter.nudgeSegs(x, y, routes, open, leftOf, gap);
- open = [];
- }
- });
- }
- };
- GridRouter.prototype.routeEdges = function (edges, nudgeGap, source, target) {
- var _this = this;
- var routePaths = edges.map(function (e) { return _this.route(source(e), target(e)); });
- var order = GridRouter.orderEdges(routePaths);
- var routes = routePaths.map(function (e) { return GridRouter.makeSegments(e); });
- GridRouter.nudgeSegments(routes, 'x', 'y', order, nudgeGap);
- GridRouter.nudgeSegments(routes, 'y', 'x', order, nudgeGap);
- GridRouter.unreverseEdges(routes, routePaths);
- return routes;
- };
- GridRouter.unreverseEdges = function (routes, routePaths) {
- routes.forEach(function (segments, i) {
- var path = routePaths[i];
- if (path.reversed) {
- segments.reverse();
- segments.forEach(function (segment) {
- segment.reverse();
- });
- }
- });
- };
- GridRouter.angleBetween2Lines = function (line1, line2) {
- var angle1 = Math.atan2(line1[0].y - line1[1].y, line1[0].x - line1[1].x);
- var angle2 = Math.atan2(line2[0].y - line2[1].y, line2[0].x - line2[1].x);
- var diff = angle1 - angle2;
- if (diff > Math.PI || diff < -Math.PI) {
- diff = angle2 - angle1;
- }
- return diff;
- };
- GridRouter.isLeft = function (a, b, c) {
- return ((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)) <= 0;
- };
- GridRouter.getOrder = function (pairs) {
- var outgoing = {};
- for (var i = 0; i < pairs.length; i++) {
- var p = pairs[i];
- if (typeof outgoing[p.l] === 'undefined')
- outgoing[p.l] = {};
- outgoing[p.l][p.r] = true;
- }
- return function (l, r) { return typeof outgoing[l] !== 'undefined' && outgoing[l][r]; };
- };
- GridRouter.orderEdges = function (edges) {
- var edgeOrder = [];
- for (var i = 0; i < edges.length - 1; i++) {
- for (var j = i + 1; j < edges.length; j++) {
- var e = edges[i], f = edges[j], lcs = new LongestCommonSubsequence(e, f);
- var u, vi, vj;
- if (lcs.length === 0)
- continue;
- if (lcs.reversed) {
- f.reverse();
- f.reversed = true;
- lcs = new LongestCommonSubsequence(e, f);
- }
- if ((lcs.si <= 0 || lcs.ti <= 0) &&
- (lcs.si + lcs.length >= e.length || lcs.ti + lcs.length >= f.length)) {
- edgeOrder.push({ l: i, r: j });
- continue;
- }
- if (lcs.si + lcs.length >= e.length || lcs.ti + lcs.length >= f.length) {
- u = e[lcs.si + 1];
- vj = e[lcs.si - 1];
- vi = f[lcs.ti - 1];
- }
- else {
- u = e[lcs.si + lcs.length - 2];
- vi = e[lcs.si + lcs.length];
- vj = f[lcs.ti + lcs.length];
- }
- if (GridRouter.isLeft(u, vi, vj)) {
- edgeOrder.push({ l: j, r: i });
- }
- else {
- edgeOrder.push({ l: i, r: j });
- }
- }
- }
- return GridRouter.getOrder(edgeOrder);
- };
- GridRouter.makeSegments = function (path) {
- function copyPoint(p) {
- return { x: p.x, y: p.y };
- }
- var isStraight = function (a, b, c) { return Math.abs((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)) < 0.001; };
- var segments = [];
- var a = copyPoint(path[0]);
- for (var i = 1; i < path.length; i++) {
- var b = copyPoint(path[i]), c = i < path.length - 1 ? path[i + 1] : null;
- if (!c || !isStraight(a, b, c)) {
- segments.push([a, b]);
- a = b;
- }
- }
- return segments;
- };
- GridRouter.prototype.route = function (s, t) {
- var _this = this;
- var source = this.nodes[s], target = this.nodes[t];
- this.obstacles = this.siblingObstacles(source, target);
- var obstacleLookup = {};
- this.obstacles.forEach(function (o) { return obstacleLookup[o.id] = o; });
- this.passableEdges = this.edges.filter(function (e) {
- var u = _this.verts[e.source], v = _this.verts[e.target];
- return !(u.node && u.node.id in obstacleLookup
- || v.node && v.node.id in obstacleLookup);
- });
- for (var i = 1; i < source.ports.length; i++) {
- var u = source.ports[0].id;
- var v = source.ports[i].id;
- this.passableEdges.push({
- source: u,
- target: v,
- length: 0
- });
- }
- for (var i = 1; i < target.ports.length; i++) {
- var u = target.ports[0].id;
- var v = target.ports[i].id;
- this.passableEdges.push({
- source: u,
- target: v,
- length: 0
- });
- }
- var getSource = function (e) { return e.source; }, getTarget = function (e) { return e.target; }, getLength = function (e) { return e.length; };
- var shortestPathCalculator = new shortestpaths_1.Calculator(this.verts.length, this.passableEdges, getSource, getTarget, getLength);
- var bendPenalty = function (u, v, w) {
- var a = _this.verts[u], b = _this.verts[v], c = _this.verts[w];
- var dx = Math.abs(c.x - a.x), dy = Math.abs(c.y - a.y);
- if (a.node === source && a.node === b.node || b.node === target && b.node === c.node)
- return 0;
- return dx > 1 && dy > 1 ? 1000 : 0;
- };
- var shortestPath = shortestPathCalculator.PathFromNodeToNodeWithPrevCost(source.ports[0].id, target.ports[0].id, bendPenalty);
- var pathPoints = shortestPath.reverse().map(function (vi) { return _this.verts[vi]; });
- pathPoints.push(this.nodes[target.id].ports[0]);
- return pathPoints.filter(function (v, i) {
- return !(i < pathPoints.length - 1 && pathPoints[i + 1].node === source && v.node === source
- || i > 0 && v.node === target && pathPoints[i - 1].node === target);
- });
- };
- GridRouter.getRoutePath = function (route, cornerradius, arrowwidth, arrowheight) {
- var result = {
- routepath: 'M ' + route[0][0].x + ' ' + route[0][0].y + ' ',
- arrowpath: ''
- };
- if (route.length > 1) {
- for (var i = 0; i < route.length; i++) {
- var li = route[i];
- var x = li[1].x, y = li[1].y;
- var dx = x - li[0].x;
- var dy = y - li[0].y;
- if (i < route.length - 1) {
- if (Math.abs(dx) > 0) {
- x -= dx / Math.abs(dx) * cornerradius;
- }
- else {
- y -= dy / Math.abs(dy) * cornerradius;
- }
- result.routepath += 'L ' + x + ' ' + y + ' ';
- var l = route[i + 1];
- var x0 = l[0].x, y0 = l[0].y;
- var x1 = l[1].x;
- var y1 = l[1].y;
- dx = x1 - x0;
- dy = y1 - y0;
- var angle = GridRouter.angleBetween2Lines(li, l) < 0 ? 1 : 0;
- var x2, y2;
- if (Math.abs(dx) > 0) {
- x2 = x0 + dx / Math.abs(dx) * cornerradius;
- y2 = y0;
- }
- else {
- x2 = x0;
- y2 = y0 + dy / Math.abs(dy) * cornerradius;
- }
- var cx = Math.abs(x2 - x);
- var cy = Math.abs(y2 - y);
- result.routepath += 'A ' + cx + ' ' + cy + ' 0 0 ' + angle + ' ' + x2 + ' ' + y2 + ' ';
- }
- else {
- var arrowtip = [x, y];
- var arrowcorner1, arrowcorner2;
- if (Math.abs(dx) > 0) {
- x -= dx / Math.abs(dx) * arrowheight;
- arrowcorner1 = [x, y + arrowwidth];
- arrowcorner2 = [x, y - arrowwidth];
- }
- else {
- y -= dy / Math.abs(dy) * arrowheight;
- arrowcorner1 = [x + arrowwidth, y];
- arrowcorner2 = [x - arrowwidth, y];
- }
- result.routepath += 'L ' + x + ' ' + y + ' ';
- if (arrowheight > 0) {
- result.arrowpath = 'M ' + arrowtip[0] + ' ' + arrowtip[1] + ' L ' + arrowcorner1[0] + ' ' + arrowcorner1[1]
- + ' L ' + arrowcorner2[0] + ' ' + arrowcorner2[1];
- }
- }
- }
- }
- else {
- var li = route[0];
- var x = li[1].x, y = li[1].y;
- var dx = x - li[0].x;
- var dy = y - li[0].y;
- var arrowtip = [x, y];
- var arrowcorner1, arrowcorner2;
- if (Math.abs(dx) > 0) {
- x -= dx / Math.abs(dx) * arrowheight;
- arrowcorner1 = [x, y + arrowwidth];
- arrowcorner2 = [x, y - arrowwidth];
- }
- else {
- y -= dy / Math.abs(dy) * arrowheight;
- arrowcorner1 = [x + arrowwidth, y];
- arrowcorner2 = [x - arrowwidth, y];
- }
- result.routepath += 'L ' + x + ' ' + y + ' ';
- if (arrowheight > 0) {
- result.arrowpath = 'M ' + arrowtip[0] + ' ' + arrowtip[1] + ' L ' + arrowcorner1[0] + ' ' + arrowcorner1[1]
- + ' L ' + arrowcorner2[0] + ' ' + arrowcorner2[1];
- }
- }
- return result;
- };
- return GridRouter;
-}());
-exports.GridRouter = GridRouter;
-
-},{"./rectangle":16,"./shortestpaths":17,"./vpsc":18}],9:[function(require,module,exports){
-"use strict";
-var packingOptions = {
- PADDING: 10,
- GOLDEN_SECTION: (1 + Math.sqrt(5)) / 2,
- FLOAT_EPSILON: 0.0001,
- MAX_INERATIONS: 100
-};
-function applyPacking(graphs, w, h, node_size, desired_ratio) {
- if (desired_ratio === void 0) { desired_ratio = 1; }
- var init_x = 0, init_y = 0, svg_width = w, svg_height = h, desired_ratio = typeof desired_ratio !== 'undefined' ? desired_ratio : 1, node_size = typeof node_size !== 'undefined' ? node_size : 0, real_width = 0, real_height = 0, min_width = 0, global_bottom = 0, line = [];
- if (graphs.length == 0)
- return;
- calculate_bb(graphs);
- apply(graphs, desired_ratio);
- put_nodes_to_right_positions(graphs);
- function calculate_bb(graphs) {
- graphs.forEach(function (g) {
- calculate_single_bb(g);
- });
- function calculate_single_bb(graph) {
- var min_x = Number.MAX_VALUE, min_y = Number.MAX_VALUE, max_x = 0, max_y = 0;
- graph.array.forEach(function (v) {
- var w = typeof v.width !== 'undefined' ? v.width : node_size;
- var h = typeof v.height !== 'undefined' ? v.height : node_size;
- w /= 2;
- h /= 2;
- max_x = Math.max(v.x + w, max_x);
- min_x = Math.min(v.x - w, min_x);
- max_y = Math.max(v.y + h, max_y);
- min_y = Math.min(v.y - h, min_y);
- });
- graph.width = max_x - min_x;
- graph.height = max_y - min_y;
- }
- }
- function put_nodes_to_right_positions(graphs) {
- graphs.forEach(function (g) {
- var center = { x: 0, y: 0 };
- g.array.forEach(function (node) {
- center.x += node.x;
- center.y += node.y;
- });
- center.x /= g.array.length;
- center.y /= g.array.length;
- var corner = { x: center.x - g.width / 2, y: center.y - g.height / 2 };
- var offset = { x: g.x - corner.x + svg_width / 2 - real_width / 2, y: g.y - corner.y + svg_height / 2 - real_height / 2 };
- g.array.forEach(function (node) {
- node.x += offset.x;
- node.y += offset.y;
- });
- });
- }
- function apply(data, desired_ratio) {
- var curr_best_f = Number.POSITIVE_INFINITY;
- var curr_best = 0;
- data.sort(function (a, b) { return b.height - a.height; });
- min_width = data.reduce(function (a, b) {
- return a.width < b.width ? a.width : b.width;
- });
- var left = x1 = min_width;
- var right = x2 = get_entire_width(data);
- var iterationCounter = 0;
- var f_x1 = Number.MAX_VALUE;
- var f_x2 = Number.MAX_VALUE;
- var flag = -1;
- var dx = Number.MAX_VALUE;
- var df = Number.MAX_VALUE;
- while ((dx > min_width) || df > packingOptions.FLOAT_EPSILON) {
- if (flag != 1) {
- var x1 = right - (right - left) / packingOptions.GOLDEN_SECTION;
- var f_x1 = step(data, x1);
- }
- if (flag != 0) {
- var x2 = left + (right - left) / packingOptions.GOLDEN_SECTION;
- var f_x2 = step(data, x2);
- }
- dx = Math.abs(x1 - x2);
- df = Math.abs(f_x1 - f_x2);
- if (f_x1 < curr_best_f) {
- curr_best_f = f_x1;
- curr_best = x1;
- }
- if (f_x2 < curr_best_f) {
- curr_best_f = f_x2;
- curr_best = x2;
- }
- if (f_x1 > f_x2) {
- left = x1;
- x1 = x2;
- f_x1 = f_x2;
- flag = 1;
- }
- else {
- right = x2;
- x2 = x1;
- f_x2 = f_x1;
- flag = 0;
- }
- if (iterationCounter++ > 100) {
- break;
- }
- }
- step(data, curr_best);
- }
- function step(data, max_width) {
- line = [];
- real_width = 0;
- real_height = 0;
- global_bottom = init_y;
- for (var i = 0; i < data.length; i++) {
- var o = data[i];
- put_rect(o, max_width);
- }
- return Math.abs(get_real_ratio() - desired_ratio);
- }
- function put_rect(rect, max_width) {
- var parent = undefined;
- for (var i = 0; i < line.length; i++) {
- if ((line[i].space_left >= rect.height) && (line[i].x + line[i].width + rect.width + packingOptions.PADDING - max_width) <= packingOptions.FLOAT_EPSILON) {
- parent = line[i];
- break;
- }
- }
- line.push(rect);
- if (parent !== undefined) {
- rect.x = parent.x + parent.width + packingOptions.PADDING;
- rect.y = parent.bottom;
- rect.space_left = rect.height;
- rect.bottom = rect.y;
- parent.space_left -= rect.height + packingOptions.PADDING;
- parent.bottom += rect.height + packingOptions.PADDING;
- }
- else {
- rect.y = global_bottom;
- global_bottom += rect.height + packingOptions.PADDING;
- rect.x = init_x;
- rect.bottom = rect.y;
- rect.space_left = rect.height;
- }
- if (rect.y + rect.height - real_height > -packingOptions.FLOAT_EPSILON)
- real_height = rect.y + rect.height - init_y;
- if (rect.x + rect.width - real_width > -packingOptions.FLOAT_EPSILON)
- real_width = rect.x + rect.width - init_x;
- }
- ;
- function get_entire_width(data) {
- var width = 0;
- data.forEach(function (d) { return width += d.width + packingOptions.PADDING; });
- return width;
- }
- function get_real_ratio() {
- return (real_width / real_height);
- }
-}
-exports.applyPacking = applyPacking;
-function separateGraphs(nodes, links) {
- var marks = {};
- var ways = {};
- var graphs = [];
- var clusters = 0;
- for (var i = 0; i < links.length; i++) {
- var link = links[i];
- var n1 = link.source;
- var n2 = link.target;
- if (ways[n1.index])
- ways[n1.index].push(n2);
- else
- ways[n1.index] = [n2];
- if (ways[n2.index])
- ways[n2.index].push(n1);
- else
- ways[n2.index] = [n1];
- }
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- if (marks[node.index])
- continue;
- explore_node(node, true);
- }
- function explore_node(n, is_new) {
- if (marks[n.index] !== undefined)
- return;
- if (is_new) {
- clusters++;
- graphs.push({ array: [] });
- }
- marks[n.index] = clusters;
- graphs[clusters - 1].array.push(n);
- var adjacent = ways[n.index];
- if (!adjacent)
- return;
- for (var j = 0; j < adjacent.length; j++) {
- explore_node(adjacent[j], false);
- }
- }
- return graphs;
-}
-exports.separateGraphs = separateGraphs;
-
-},{}],10:[function(require,module,exports){
-"use strict";
-var powergraph = require("./powergraph");
-var linklengths_1 = require("./linklengths");
-var descent_1 = require("./descent");
-var rectangle_1 = require("./rectangle");
-var shortestpaths_1 = require("./shortestpaths");
-var geom_1 = require("./geom");
-var handledisconnected_1 = require("./handledisconnected");
-var EventType;
-(function (EventType) {
- EventType[EventType["start"] = 0] = "start";
- EventType[EventType["tick"] = 1] = "tick";
- EventType[EventType["end"] = 2] = "end";
-})(EventType = exports.EventType || (exports.EventType = {}));
-;
-function isGroup(g) {
- return typeof g.leaves !== 'undefined' || typeof g.groups !== 'undefined';
-}
-var Layout = (function () {
- function Layout() {
- var _this = this;
- this._canvasSize = [1, 1];
- this._linkDistance = 20;
- this._defaultNodeSize = 10;
- this._linkLengthCalculator = null;
- this._linkType = null;
- this._avoidOverlaps = false;
- this._handleDisconnected = true;
- this._running = false;
- this._nodes = [];
- this._groups = [];
- this._rootGroup = null;
- this._links = [];
- this._constraints = [];
- this._distanceMatrix = null;
- this._descent = null;
- this._directedLinkConstraints = null;
- this._threshold = 0.01;
- this._visibilityGraph = null;
- this._groupCompactness = 1e-6;
- this.event = null;
- this.linkAccessor = {
- getSourceIndex: Layout.getSourceIndex,
- getTargetIndex: Layout.getTargetIndex,
- setLength: Layout.setLinkLength,
- getType: function (l) { return typeof _this._linkType === "function" ? _this._linkType(l) : 0; }
- };
- }
- Layout.prototype.on = function (e, listener) {
- if (!this.event)
- this.event = {};
- if (typeof e === 'string') {
- this.event[EventType[e]] = listener;
- }
- else {
- this.event[e] = listener;
- }
- return this;
- };
- Layout.prototype.trigger = function (e) {
- if (this.event && typeof this.event[e.type] !== 'undefined') {
- this.event[e.type](e);
- }
- };
- Layout.prototype.kick = function () {
- while (!this.tick())
- ;
- };
- Layout.prototype.tick = function () {
- if (this._alpha < this._threshold) {
- this._running = false;
- this.trigger({ type: EventType.end, alpha: this._alpha = 0, stress: this._lastStress });
- return true;
- }
- var n = this._nodes.length, m = this._links.length;
- var o, i;
- this._descent.locks.clear();
- for (i = 0; i < n; ++i) {
- o = this._nodes[i];
- if (o.fixed) {
- if (typeof o.px === 'undefined' || typeof o.py === 'undefined') {
- o.px = o.x;
- o.py = o.y;
- }
- var p = [o.px, o.py];
- this._descent.locks.add(i, p);
- }
- }
- var s1 = this._descent.rungeKutta();
- if (s1 === 0) {
- this._alpha = 0;
- }
- else if (typeof this._lastStress !== 'undefined') {
- this._alpha = s1;
- }
- this._lastStress = s1;
- this.updateNodePositions();
- this.trigger({ type: EventType.tick, alpha: this._alpha, stress: this._lastStress });
- return false;
- };
- Layout.prototype.updateNodePositions = function () {
- var x = this._descent.x[0], y = this._descent.x[1];
- var o, i = this._nodes.length;
- while (i--) {
- o = this._nodes[i];
- o.x = x[i];
- o.y = y[i];
- }
- };
- Layout.prototype.nodes = function (v) {
- if (!v) {
- if (this._nodes.length === 0 && this._links.length > 0) {
- var n = 0;
- this._links.forEach(function (l) {
- n = Math.max(n, l.source, l.target);
- });
- this._nodes = new Array(++n);
- for (var i = 0; i < n; ++i) {
- this._nodes[i] = {};
- }
- }
- return this._nodes;
- }
- this._nodes = v;
- return this;
- };
- Layout.prototype.groups = function (x) {
- var _this = this;
- if (!x)
- return this._groups;
- this._groups = x;
- this._rootGroup = {};
- this._groups.forEach(function (g) {
- if (typeof g.padding === "undefined")
- g.padding = 1;
- if (typeof g.leaves !== "undefined") {
- g.leaves.forEach(function (v, i) {
- if (typeof v === 'number')
- (g.leaves[i] = _this._nodes[v]).parent = g;
- });
- }
- if (typeof g.groups !== "undefined") {
- g.groups.forEach(function (gi, i) {
- if (typeof gi === 'number')
- (g.groups[i] = _this._groups[gi]).parent = g;
- });
- }
- });
- this._rootGroup.leaves = this._nodes.filter(function (v) { return typeof v.parent === 'undefined'; });
- this._rootGroup.groups = this._groups.filter(function (g) { return typeof g.parent === 'undefined'; });
- return this;
- };
- Layout.prototype.powerGraphGroups = function (f) {
- var g = powergraph.getGroups(this._nodes, this._links, this.linkAccessor, this._rootGroup);
- this.groups(g.groups);
- f(g);
- return this;
- };
- Layout.prototype.avoidOverlaps = function (v) {
- if (!arguments.length)
- return this._avoidOverlaps;
- this._avoidOverlaps = v;
- return this;
- };
- Layout.prototype.handleDisconnected = function (v) {
- if (!arguments.length)
- return this._handleDisconnected;
- this._handleDisconnected = v;
- return this;
- };
- Layout.prototype.flowLayout = function (axis, minSeparation) {
- if (!arguments.length)
- axis = 'y';
- this._directedLinkConstraints = {
- axis: axis,
- getMinSeparation: typeof minSeparation === 'number' ? function () { return minSeparation; } : minSeparation
- };
- return this;
- };
- Layout.prototype.links = function (x) {
- if (!arguments.length)
- return this._links;
- this._links = x;
- return this;
- };
- Layout.prototype.constraints = function (c) {
- if (!arguments.length)
- return this._constraints;
- this._constraints = c;
- return this;
- };
- Layout.prototype.distanceMatrix = function (d) {
- if (!arguments.length)
- return this._distanceMatrix;
- this._distanceMatrix = d;
- return this;
- };
- Layout.prototype.size = function (x) {
- if (!x)
- return this._canvasSize;
- this._canvasSize = x;
- return this;
- };
- Layout.prototype.defaultNodeSize = function (x) {
- if (!x)
- return this._defaultNodeSize;
- this._defaultNodeSize = x;
- return this;
- };
- Layout.prototype.groupCompactness = function (x) {
- if (!x)
- return this._groupCompactness;
- this._groupCompactness = x;
- return this;
- };
- Layout.prototype.linkDistance = function (x) {
- if (!x) {
- return this._linkDistance;
- }
- this._linkDistance = typeof x === "function" ? x : +x;
- this._linkLengthCalculator = null;
- return this;
- };
- Layout.prototype.linkType = function (f) {
- this._linkType = f;
- return this;
- };
- Layout.prototype.convergenceThreshold = function (x) {
- if (!x)
- return this._threshold;
- this._threshold = typeof x === "function" ? x : +x;
- return this;
- };
- Layout.prototype.alpha = function (x) {
- if (!arguments.length)
- return this._alpha;
- else {
- x = +x;
- if (this._alpha) {
- if (x > 0)
- this._alpha = x;
- else
- this._alpha = 0;
- }
- else if (x > 0) {
- if (!this._running) {
- this._running = true;
- this.trigger({ type: EventType.start, alpha: this._alpha = x });
- this.kick();
- }
- }
- return this;
- }
- };
- Layout.prototype.getLinkLength = function (link) {
- return typeof this._linkDistance === "function" ? +(this._linkDistance(link)) : this._linkDistance;
- };
- Layout.setLinkLength = function (link, length) {
- link.length = length;
- };
- Layout.prototype.getLinkType = function (link) {
- return typeof this._linkType === "function" ? this._linkType(link) : 0;
- };
- Layout.prototype.symmetricDiffLinkLengths = function (idealLength, w) {
- var _this = this;
- if (w === void 0) { w = 1; }
- this.linkDistance(function (l) { return idealLength * l.length; });
- this._linkLengthCalculator = function () { return linklengths_1.symmetricDiffLinkLengths(_this._links, _this.linkAccessor, w); };
- return this;
- };
- Layout.prototype.jaccardLinkLengths = function (idealLength, w) {
- var _this = this;
- if (w === void 0) { w = 1; }
- this.linkDistance(function (l) { return idealLength * l.length; });
- this._linkLengthCalculator = function () { return linklengths_1.jaccardLinkLengths(_this._links, _this.linkAccessor, w); };
- return this;
- };
- Layout.prototype.start = function (initialUnconstrainedIterations, initialUserConstraintIterations, initialAllConstraintsIterations, gridSnapIterations, keepRunning) {
- var _this = this;
- if (initialUnconstrainedIterations === void 0) { initialUnconstrainedIterations = 0; }
- if (initialUserConstraintIterations === void 0) { initialUserConstraintIterations = 0; }
- if (initialAllConstraintsIterations === void 0) { initialAllConstraintsIterations = 0; }
- if (gridSnapIterations === void 0) { gridSnapIterations = 0; }
- if (keepRunning === void 0) { keepRunning = true; }
- var i, j, n = this.nodes().length, N = n + 2 * this._groups.length, m = this._links.length, w = this._canvasSize[0], h = this._canvasSize[1];
- var x = new Array(N), y = new Array(N);
- var G = null;
- var ao = this._avoidOverlaps;
- this._nodes.forEach(function (v, i) {
- v.index = i;
- if (typeof v.x === 'undefined') {
- v.x = w / 2, v.y = h / 2;
- }
- x[i] = v.x, y[i] = v.y;
- });
- if (this._linkLengthCalculator)
- this._linkLengthCalculator();
- var distances;
- if (this._distanceMatrix) {
- distances = this._distanceMatrix;
- }
- else {
- distances = (new shortestpaths_1.Calculator(N, this._links, Layout.getSourceIndex, Layout.getTargetIndex, function (l) { return _this.getLinkLength(l); })).DistanceMatrix();
- G = descent_1.Descent.createSquareMatrix(N, function () { return 2; });
- this._links.forEach(function (l) {
- if (typeof l.source == "number")
- l.source = _this._nodes[l.source];
- if (typeof l.target == "number")
- l.target = _this._nodes[l.target];
- });
- this._links.forEach(function (e) {
- var u = Layout.getSourceIndex(e), v = Layout.getTargetIndex(e);
- G[u][v] = G[v][u] = e.weight || 1;
- });
- }
- var D = descent_1.Descent.createSquareMatrix(N, function (i, j) {
- return distances[i][j];
- });
- if (this._rootGroup && typeof this._rootGroup.groups !== 'undefined') {
- var i = n;
- var addAttraction = function (i, j, strength, idealDistance) {
- G[i][j] = G[j][i] = strength;
- D[i][j] = D[j][i] = idealDistance;
- };
- this._groups.forEach(function (g) {
- addAttraction(i, i + 1, _this._groupCompactness, 0.1);
- x[i] = 0, y[i++] = 0;
- x[i] = 0, y[i++] = 0;
- });
- }
- else
- this._rootGroup = { leaves: this._nodes, groups: [] };
- var curConstraints = this._constraints || [];
- if (this._directedLinkConstraints) {
- this.linkAccessor.getMinSeparation = this._directedLinkConstraints.getMinSeparation;
- curConstraints = curConstraints.concat(linklengths_1.generateDirectedEdgeConstraints(n, this._links, this._directedLinkConstraints.axis, (this.linkAccessor)));
- }
- this.avoidOverlaps(false);
- this._descent = new descent_1.Descent([x, y], D);
- this._descent.locks.clear();
- for (var i = 0; i < n; ++i) {
- var o = this._nodes[i];
- if (o.fixed) {
- o.px = o.x;
- o.py = o.y;
- var p = [o.x, o.y];
- this._descent.locks.add(i, p);
- }
- }
- this._descent.threshold = this._threshold;
- this.initialLayout(initialUnconstrainedIterations, x, y);
- if (curConstraints.length > 0)
- this._descent.project = new rectangle_1.Projection(this._nodes, this._groups, this._rootGroup, curConstraints).projectFunctions();
- this._descent.run(initialUserConstraintIterations);
- this.separateOverlappingComponents(w, h);
- this.avoidOverlaps(ao);
- if (ao) {
- this._nodes.forEach(function (v, i) { v.x = x[i], v.y = y[i]; });
- this._descent.project = new rectangle_1.Projection(this._nodes, this._groups, this._rootGroup, curConstraints, true).projectFunctions();
- this._nodes.forEach(function (v, i) { x[i] = v.x, y[i] = v.y; });
- }
- this._descent.G = G;
- this._descent.run(initialAllConstraintsIterations);
- if (gridSnapIterations) {
- this._descent.snapStrength = 1000;
- this._descent.snapGridSize = this._nodes[0].width;
- this._descent.numGridSnapNodes = n;
- this._descent.scaleSnapByMaxH = n != N;
- var G0 = descent_1.Descent.createSquareMatrix(N, function (i, j) {
- if (i >= n || j >= n)
- return G[i][j];
- return 0;
- });
- this._descent.G = G0;
- this._descent.run(gridSnapIterations);
- }
- this.updateNodePositions();
- this.separateOverlappingComponents(w, h);
- return keepRunning ? this.resume() : this;
- };
- Layout.prototype.initialLayout = function (iterations, x, y) {
- if (this._groups.length > 0 && iterations > 0) {
- var n = this._nodes.length;
- var edges = this._links.map(function (e) { return ({ source: e.source.index, target: e.target.index }); });
- var vs = this._nodes.map(function (v) { return ({ index: v.index }); });
- this._groups.forEach(function (g, i) {
- vs.push({ index: g.index = n + i });
- });
- this._groups.forEach(function (g, i) {
- if (typeof g.leaves !== 'undefined')
- g.leaves.forEach(function (v) { return edges.push({ source: g.index, target: v.index }); });
- if (typeof g.groups !== 'undefined')
- g.groups.forEach(function (gg) { return edges.push({ source: g.index, target: gg.index }); });
- });
- new Layout()
- .size(this.size())
- .nodes(vs)
- .links(edges)
- .avoidOverlaps(false)
- .linkDistance(this.linkDistance())
- .symmetricDiffLinkLengths(5)
- .convergenceThreshold(1e-4)
- .start(iterations, 0, 0, 0, false);
- this._nodes.forEach(function (v) {
- x[v.index] = vs[v.index].x;
- y[v.index] = vs[v.index].y;
- });
- }
- else {
- this._descent.run(iterations);
- }
- };
- Layout.prototype.separateOverlappingComponents = function (width, height) {
- var _this = this;
- if (!this._distanceMatrix && this._handleDisconnected) {
- var x_1 = this._descent.x[0], y_1 = this._descent.x[1];
- this._nodes.forEach(function (v, i) { v.x = x_1[i], v.y = y_1[i]; });
- var graphs = handledisconnected_1.separateGraphs(this._nodes, this._links);
- handledisconnected_1.applyPacking(graphs, width, height, this._defaultNodeSize);
- this._nodes.forEach(function (v, i) {
- _this._descent.x[0][i] = v.x, _this._descent.x[1][i] = v.y;
- if (v.bounds) {
- v.bounds.setXCentre(v.x);
- v.bounds.setYCentre(v.y);
- }
- });
- }
- };
- Layout.prototype.resume = function () {
- return this.alpha(0.1);
- };
- Layout.prototype.stop = function () {
- return this.alpha(0);
- };
- Layout.prototype.prepareEdgeRouting = function (nodeMargin) {
- if (nodeMargin === void 0) { nodeMargin = 0; }
- this._visibilityGraph = new geom_1.TangentVisibilityGraph(this._nodes.map(function (v) {
- return v.bounds.inflate(-nodeMargin).vertices();
- }));
- };
- Layout.prototype.routeEdge = function (edge, draw) {
- var lineData = [];
- var vg2 = new geom_1.TangentVisibilityGraph(this._visibilityGraph.P, { V: this._visibilityGraph.V, E: this._visibilityGraph.E }), port1 = { x: edge.source.x, y: edge.source.y }, port2 = { x: edge.target.x, y: edge.target.y }, start = vg2.addPoint(port1, edge.source.index), end = vg2.addPoint(port2, edge.target.index);
- vg2.addEdgeIfVisible(port1, port2, edge.source.index, edge.target.index);
- if (typeof draw !== 'undefined') {
- draw(vg2);
- }
- var sourceInd = function (e) { return e.source.id; }, targetInd = function (e) { return e.target.id; }, length = function (e) { return e.length(); }, spCalc = new shortestpaths_1.Calculator(vg2.V.length, vg2.E, sourceInd, targetInd, length), shortestPath = spCalc.PathFromNodeToNode(start.id, end.id);
- if (shortestPath.length === 1 || shortestPath.length === vg2.V.length) {
- var route = rectangle_1.makeEdgeBetween(edge.source.innerBounds, edge.target.innerBounds, 5);
- lineData = [route.sourceIntersection, route.arrowStart];
- }
- else {
- var n = shortestPath.length - 2, p = vg2.V[shortestPath[n]].p, q = vg2.V[shortestPath[0]].p, lineData = [edge.source.innerBounds.rayIntersection(p.x, p.y)];
- for (var i = n; i >= 0; --i)
- lineData.push(vg2.V[shortestPath[i]].p);
- lineData.push(rectangle_1.makeEdgeTo(q, edge.target.innerBounds, 5));
- }
- return lineData;
- };
- Layout.getSourceIndex = function (e) {
- return typeof e.source === 'number' ? e.source : e.source.index;
- };
- Layout.getTargetIndex = function (e) {
- return typeof e.target === 'number' ? e.target : e.target.index;
- };
- Layout.linkId = function (e) {
- return Layout.getSourceIndex(e) + "-" + Layout.getTargetIndex(e);
- };
- Layout.dragStart = function (d) {
- if (isGroup(d)) {
- Layout.storeOffset(d, Layout.dragOrigin(d));
- }
- else {
- Layout.stopNode(d);
- d.fixed |= 2;
- }
- };
- Layout.stopNode = function (v) {
- v.px = v.x;
- v.py = v.y;
- };
- Layout.storeOffset = function (d, origin) {
- if (typeof d.leaves !== 'undefined') {
- d.leaves.forEach(function (v) {
- v.fixed |= 2;
- Layout.stopNode(v);
- v._dragGroupOffsetX = v.x - origin.x;
- v._dragGroupOffsetY = v.y - origin.y;
- });
- }
- if (typeof d.groups !== 'undefined') {
- d.groups.forEach(function (g) { return Layout.storeOffset(g, origin); });
- }
- };
- Layout.dragOrigin = function (d) {
- if (isGroup(d)) {
- return {
- x: d.bounds.cx(),
- y: d.bounds.cy()
- };
- }
- else {
- return d;
- }
- };
- Layout.drag = function (d, position) {
- if (isGroup(d)) {
- if (typeof d.leaves !== 'undefined') {
- d.leaves.forEach(function (v) {
- d.bounds.setXCentre(position.x);
- d.bounds.setYCentre(position.y);
- v.px = v._dragGroupOffsetX + position.x;
- v.py = v._dragGroupOffsetY + position.y;
- });
- }
- if (typeof d.groups !== 'undefined') {
- d.groups.forEach(function (g) { return Layout.drag(g, position); });
- }
- }
- else {
- d.px = position.x;
- d.py = position.y;
- }
- };
- Layout.dragEnd = function (d) {
- if (isGroup(d)) {
- if (typeof d.leaves !== 'undefined') {
- d.leaves.forEach(function (v) {
- Layout.dragEnd(v);
- delete v._dragGroupOffsetX;
- delete v._dragGroupOffsetY;
- });
- }
- if (typeof d.groups !== 'undefined') {
- d.groups.forEach(Layout.dragEnd);
- }
- }
- else {
- d.fixed &= ~6;
- }
- };
- Layout.mouseOver = function (d) {
- d.fixed |= 4;
- d.px = d.x, d.py = d.y;
- };
- Layout.mouseOut = function (d) {
- d.fixed &= ~4;
- };
- return Layout;
-}());
-exports.Layout = Layout;
-
-},{"./descent":6,"./geom":7,"./handledisconnected":9,"./linklengths":12,"./powergraph":13,"./rectangle":16,"./shortestpaths":17}],11:[function(require,module,exports){
-"use strict";
-var shortestpaths_1 = require("./shortestpaths");
-var descent_1 = require("./descent");
-var rectangle_1 = require("./rectangle");
-var linklengths_1 = require("./linklengths");
-var Link3D = (function () {
- function Link3D(source, target) {
- this.source = source;
- this.target = target;
- }
- Link3D.prototype.actualLength = function (x) {
- var _this = this;
- return Math.sqrt(x.reduce(function (c, v) {
- var dx = v[_this.target] - v[_this.source];
- return c + dx * dx;
- }, 0));
- };
- return Link3D;
-}());
-exports.Link3D = Link3D;
-var Node3D = (function () {
- function Node3D(x, y, z) {
- if (x === void 0) { x = 0; }
- if (y === void 0) { y = 0; }
- if (z === void 0) { z = 0; }
- this.x = x;
- this.y = y;
- this.z = z;
- }
- return Node3D;
-}());
-exports.Node3D = Node3D;
-var Layout3D = (function () {
- function Layout3D(nodes, links, idealLinkLength) {
- if (idealLinkLength === void 0) { idealLinkLength = 1; }
- var _this = this;
- this.nodes = nodes;
- this.links = links;
- this.idealLinkLength = idealLinkLength;
- this.constraints = null;
- this.useJaccardLinkLengths = true;
- this.result = new Array(Layout3D.k);
- for (var i = 0; i < Layout3D.k; ++i) {
- this.result[i] = new Array(nodes.length);
- }
- nodes.forEach(function (v, i) {
- for (var _i = 0, _a = Layout3D.dims; _i < _a.length; _i++) {
- var dim = _a[_i];
- if (typeof v[dim] == 'undefined')
- v[dim] = Math.random();
- }
- _this.result[0][i] = v.x;
- _this.result[1][i] = v.y;
- _this.result[2][i] = v.z;
- });
- }
- ;
- Layout3D.prototype.linkLength = function (l) {
- return l.actualLength(this.result);
- };
- Layout3D.prototype.start = function (iterations) {
- var _this = this;
- if (iterations === void 0) { iterations = 100; }
- var n = this.nodes.length;
- var linkAccessor = new LinkAccessor();
- if (this.useJaccardLinkLengths)
- linklengths_1.jaccardLinkLengths(this.links, linkAccessor, 1.5);
- this.links.forEach(function (e) { return e.length *= _this.idealLinkLength; });
- var distanceMatrix = (new shortestpaths_1.Calculator(n, this.links, function (e) { return e.source; }, function (e) { return e.target; }, function (e) { return e.length; })).DistanceMatrix();
- var D = descent_1.Descent.createSquareMatrix(n, function (i, j) { return distanceMatrix[i][j]; });
- var G = descent_1.Descent.createSquareMatrix(n, function () { return 2; });
- this.links.forEach(function (_a) {
- var source = _a.source, target = _a.target;
- return G[source][target] = G[target][source] = 1;
- });
- this.descent = new descent_1.Descent(this.result, D);
- this.descent.threshold = 1e-3;
- this.descent.G = G;
- if (this.constraints)
- this.descent.project = new rectangle_1.Projection(this.nodes, null, null, this.constraints).projectFunctions();
- for (var i = 0; i < this.nodes.length; i++) {
- var v = this.nodes[i];
- if (v.fixed) {
- this.descent.locks.add(i, [v.x, v.y, v.z]);
- }
- }
- this.descent.run(iterations);
- return this;
- };
- Layout3D.prototype.tick = function () {
- this.descent.locks.clear();
- for (var i = 0; i < this.nodes.length; i++) {
- var v = this.nodes[i];
- if (v.fixed) {
- this.descent.locks.add(i, [v.x, v.y, v.z]);
- }
- }
- return this.descent.rungeKutta();
- };
- return Layout3D;
-}());
-Layout3D.dims = ['x', 'y', 'z'];
-Layout3D.k = Layout3D.dims.length;
-exports.Layout3D = Layout3D;
-var LinkAccessor = (function () {
- function LinkAccessor() {
- }
- LinkAccessor.prototype.getSourceIndex = function (e) { return e.source; };
- LinkAccessor.prototype.getTargetIndex = function (e) { return e.target; };
- LinkAccessor.prototype.getLength = function (e) { return e.length; };
- LinkAccessor.prototype.setLength = function (e, l) { e.length = l; };
- return LinkAccessor;
-}());
-
-},{"./descent":6,"./linklengths":12,"./rectangle":16,"./shortestpaths":17}],12:[function(require,module,exports){
-"use strict";
-function unionCount(a, b) {
- var u = {};
- for (var i in a)
- u[i] = {};
- for (var i in b)
- u[i] = {};
- return Object.keys(u).length;
-}
-function intersectionCount(a, b) {
- var n = 0;
- for (var i in a)
- if (typeof b[i] !== 'undefined')
- ++n;
- return n;
-}
-function getNeighbours(links, la) {
- var neighbours = {};
- var addNeighbours = function (u, v) {
- if (typeof neighbours[u] === 'undefined')
- neighbours[u] = {};
- neighbours[u][v] = {};
- };
- links.forEach(function (e) {
- var u = la.getSourceIndex(e), v = la.getTargetIndex(e);
- addNeighbours(u, v);
- addNeighbours(v, u);
- });
- return neighbours;
-}
-function computeLinkLengths(links, w, f, la) {
- var neighbours = getNeighbours(links, la);
- links.forEach(function (l) {
- var a = neighbours[la.getSourceIndex(l)];
- var b = neighbours[la.getTargetIndex(l)];
- la.setLength(l, 1 + w * f(a, b));
- });
-}
-function symmetricDiffLinkLengths(links, la, w) {
- if (w === void 0) { w = 1; }
- computeLinkLengths(links, w, function (a, b) { return Math.sqrt(unionCount(a, b) - intersectionCount(a, b)); }, la);
-}
-exports.symmetricDiffLinkLengths = symmetricDiffLinkLengths;
-function jaccardLinkLengths(links, la, w) {
- if (w === void 0) { w = 1; }
- computeLinkLengths(links, w, function (a, b) {
- return Math.min(Object.keys(a).length, Object.keys(b).length) < 1.1 ? 0 : intersectionCount(a, b) / unionCount(a, b);
- }, la);
-}
-exports.jaccardLinkLengths = jaccardLinkLengths;
-function generateDirectedEdgeConstraints(n, links, axis, la) {
- var components = stronglyConnectedComponents(n, links, la);
- var nodes = {};
- components.forEach(function (c, i) {
- return c.forEach(function (v) { return nodes[v] = i; });
- });
- var constraints = [];
- links.forEach(function (l) {
- var ui = la.getSourceIndex(l), vi = la.getTargetIndex(l), u = nodes[ui], v = nodes[vi];
- if (u !== v) {
- constraints.push({
- axis: axis,
- left: ui,
- right: vi,
- gap: la.getMinSeparation(l)
- });
- }
- });
- return constraints;
-}
-exports.generateDirectedEdgeConstraints = generateDirectedEdgeConstraints;
-function stronglyConnectedComponents(numVertices, edges, la) {
- var nodes = [];
- var index = 0;
- var stack = [];
- var components = [];
- function strongConnect(v) {
- v.index = v.lowlink = index++;
- stack.push(v);
- v.onStack = true;
- for (var _i = 0, _a = v.out; _i < _a.length; _i++) {
- var w = _a[_i];
- if (typeof w.index === 'undefined') {
- strongConnect(w);
- v.lowlink = Math.min(v.lowlink, w.lowlink);
- }
- else if (w.onStack) {
- v.lowlink = Math.min(v.lowlink, w.index);
- }
- }
- if (v.lowlink === v.index) {
- var component = [];
- while (stack.length) {
- w = stack.pop();
- w.onStack = false;
- component.push(w);
- if (w === v)
- break;
- }
- components.push(component.map(function (v) { return v.id; }));
- }
- }
- for (var i = 0; i < numVertices; i++) {
- nodes.push({ id: i, out: [] });
- }
- for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
- var e = edges_1[_i];
- var v_1 = nodes[la.getSourceIndex(e)], w = nodes[la.getTargetIndex(e)];
- v_1.out.push(w);
- }
- for (var _a = 0, nodes_1 = nodes; _a < nodes_1.length; _a++) {
- var v = nodes_1[_a];
- if (typeof v.index === 'undefined')
- strongConnect(v);
- }
- return components;
-}
-exports.stronglyConnectedComponents = stronglyConnectedComponents;
-
-},{}],13:[function(require,module,exports){
-"use strict";
-var PowerEdge = (function () {
- function PowerEdge(source, target, type) {
- this.source = source;
- this.target = target;
- this.type = type;
- }
- return PowerEdge;
-}());
-exports.PowerEdge = PowerEdge;
-var Configuration = (function () {
- function Configuration(n, edges, linkAccessor, rootGroup) {
- var _this = this;
- this.linkAccessor = linkAccessor;
- this.modules = new Array(n);
- this.roots = [];
- if (rootGroup) {
- this.initModulesFromGroup(rootGroup);
- }
- else {
- this.roots.push(new ModuleSet());
- for (var i = 0; i < n; ++i)
- this.roots[0].add(this.modules[i] = new Module(i));
- }
- this.R = edges.length;
- edges.forEach(function (e) {
- var s = _this.modules[linkAccessor.getSourceIndex(e)], t = _this.modules[linkAccessor.getTargetIndex(e)], type = linkAccessor.getType(e);
- s.outgoing.add(type, t);
- t.incoming.add(type, s);
- });
- }
- Configuration.prototype.initModulesFromGroup = function (group) {
- var moduleSet = new ModuleSet();
- this.roots.push(moduleSet);
- for (var i = 0; i < group.leaves.length; ++i) {
- var node = group.leaves[i];
- var module = new Module(node.id);
- this.modules[node.id] = module;
- moduleSet.add(module);
- }
- if (group.groups) {
- for (var j = 0; j < group.groups.length; ++j) {
- var child = group.groups[j];
- var definition = {};
- for (var prop in child)
- if (prop !== "leaves" && prop !== "groups" && child.hasOwnProperty(prop))
- definition[prop] = child[prop];
- moduleSet.add(new Module(-1 - j, new LinkSets(), new LinkSets(), this.initModulesFromGroup(child), definition));
- }
- }
- return moduleSet;
- };
- Configuration.prototype.merge = function (a, b, k) {
- if (k === void 0) { k = 0; }
- var inInt = a.incoming.intersection(b.incoming), outInt = a.outgoing.intersection(b.outgoing);
- var children = new ModuleSet();
- children.add(a);
- children.add(b);
- var m = new Module(this.modules.length, outInt, inInt, children);
- this.modules.push(m);
- var update = function (s, i, o) {
- s.forAll(function (ms, linktype) {
- ms.forAll(function (n) {
- var nls = n[i];
- nls.add(linktype, m);
- nls.remove(linktype, a);
- nls.remove(linktype, b);
- a[o].remove(linktype, n);
- b[o].remove(linktype, n);
- });
- });
- };
- update(outInt, "incoming", "outgoing");
- update(inInt, "outgoing", "incoming");
- this.R -= inInt.count() + outInt.count();
- this.roots[k].remove(a);
- this.roots[k].remove(b);
- this.roots[k].add(m);
- return m;
- };
- Configuration.prototype.rootMerges = function (k) {
- if (k === void 0) { k = 0; }
- var rs = this.roots[k].modules();
- var n = rs.length;
- var merges = new Array(n * (n - 1));
- var ctr = 0;
- for (var i = 0, i_ = n - 1; i < i_; ++i) {
- for (var j = i + 1; j < n; ++j) {
- var a = rs[i], b = rs[j];
- merges[ctr] = { id: ctr, nEdges: this.nEdges(a, b), a: a, b: b };
- ctr++;
- }
- }
- return merges;
- };
- Configuration.prototype.greedyMerge = function () {
- for (var i = 0; i < this.roots.length; ++i) {
- if (this.roots[i].modules().length < 2)
- continue;
- var ms = this.rootMerges(i).sort(function (a, b) { return a.nEdges == b.nEdges ? a.id - b.id : a.nEdges - b.nEdges; });
- var m = ms[0];
- if (m.nEdges >= this.R)
- continue;
- this.merge(m.a, m.b, i);
- return true;
- }
- };
- Configuration.prototype.nEdges = function (a, b) {
- var inInt = a.incoming.intersection(b.incoming), outInt = a.outgoing.intersection(b.outgoing);
- return this.R - inInt.count() - outInt.count();
- };
- Configuration.prototype.getGroupHierarchy = function (retargetedEdges) {
- var _this = this;
- var groups = [];
- var root = {};
- toGroups(this.roots[0], root, groups);
- var es = this.allEdges();
- es.forEach(function (e) {
- var a = _this.modules[e.source];
- var b = _this.modules[e.target];
- retargetedEdges.push(new PowerEdge(typeof a.gid === "undefined" ? e.source : groups[a.gid], typeof b.gid === "undefined" ? e.target : groups[b.gid], e.type));
- });
- return groups;
- };
- Configuration.prototype.allEdges = function () {
- var es = [];
- Configuration.getEdges(this.roots[0], es);
- return es;
- };
- Configuration.getEdges = function (modules, es) {
- modules.forAll(function (m) {
- m.getEdges(es);
- Configuration.getEdges(m.children, es);
- });
- };
- return Configuration;
-}());
-exports.Configuration = Configuration;
-function toGroups(modules, group, groups) {
- modules.forAll(function (m) {
- if (m.isLeaf()) {
- if (!group.leaves)
- group.leaves = [];
- group.leaves.push(m.id);
- }
- else {
- var g = group;
- m.gid = groups.length;
- if (!m.isIsland() || m.isPredefined()) {
- g = { id: m.gid };
- if (m.isPredefined())
- for (var prop in m.definition)
- g[prop] = m.definition[prop];
- if (!group.groups)
- group.groups = [];
- group.groups.push(m.gid);
- groups.push(g);
- }
- toGroups(m.children, g, groups);
- }
- });
-}
-var Module = (function () {
- function Module(id, outgoing, incoming, children, definition) {
- if (outgoing === void 0) { outgoing = new LinkSets(); }
- if (incoming === void 0) { incoming = new LinkSets(); }
- if (children === void 0) { children = new ModuleSet(); }
- this.id = id;
- this.outgoing = outgoing;
- this.incoming = incoming;
- this.children = children;
- this.definition = definition;
- }
- Module.prototype.getEdges = function (es) {
- var _this = this;
- this.outgoing.forAll(function (ms, edgetype) {
- ms.forAll(function (target) {
- es.push(new PowerEdge(_this.id, target.id, edgetype));
- });
- });
- };
- Module.prototype.isLeaf = function () {
- return this.children.count() === 0;
- };
- Module.prototype.isIsland = function () {
- return this.outgoing.count() === 0 && this.incoming.count() === 0;
- };
- Module.prototype.isPredefined = function () {
- return typeof this.definition !== "undefined";
- };
- return Module;
-}());
-exports.Module = Module;
-function intersection(m, n) {
- var i = {};
- for (var v in m)
- if (v in n)
- i[v] = m[v];
- return i;
-}
-var ModuleSet = (function () {
- function ModuleSet() {
- this.table = {};
- }
- ModuleSet.prototype.count = function () {
- return Object.keys(this.table).length;
- };
- ModuleSet.prototype.intersection = function (other) {
- var result = new ModuleSet();
- result.table = intersection(this.table, other.table);
- return result;
- };
- ModuleSet.prototype.intersectionCount = function (other) {
- return this.intersection(other).count();
- };
- ModuleSet.prototype.contains = function (id) {
- return id in this.table;
- };
- ModuleSet.prototype.add = function (m) {
- this.table[m.id] = m;
- };
- ModuleSet.prototype.remove = function (m) {
- delete this.table[m.id];
- };
- ModuleSet.prototype.forAll = function (f) {
- for (var mid in this.table) {
- f(this.table[mid]);
- }
- };
- ModuleSet.prototype.modules = function () {
- var vs = [];
- this.forAll(function (m) {
- if (!m.isPredefined())
- vs.push(m);
- });
- return vs;
- };
- return ModuleSet;
-}());
-exports.ModuleSet = ModuleSet;
-var LinkSets = (function () {
- function LinkSets() {
- this.sets = {};
- this.n = 0;
- }
- LinkSets.prototype.count = function () {
- return this.n;
- };
- LinkSets.prototype.contains = function (id) {
- var result = false;
- this.forAllModules(function (m) {
- if (!result && m.id == id) {
- result = true;
- }
- });
- return result;
- };
- LinkSets.prototype.add = function (linktype, m) {
- var s = linktype in this.sets ? this.sets[linktype] : this.sets[linktype] = new ModuleSet();
- s.add(m);
- ++this.n;
- };
- LinkSets.prototype.remove = function (linktype, m) {
- var ms = this.sets[linktype];
- ms.remove(m);
- if (ms.count() === 0) {
- delete this.sets[linktype];
- }
- --this.n;
- };
- LinkSets.prototype.forAll = function (f) {
- for (var linktype in this.sets) {
- f(this.sets[linktype], Number(linktype));
- }
- };
- LinkSets.prototype.forAllModules = function (f) {
- this.forAll(function (ms, lt) { return ms.forAll(f); });
- };
- LinkSets.prototype.intersection = function (other) {
- var result = new LinkSets();
- this.forAll(function (ms, lt) {
- if (lt in other.sets) {
- var i = ms.intersection(other.sets[lt]), n = i.count();
- if (n > 0) {
- result.sets[lt] = i;
- result.n += n;
- }
- }
- });
- return result;
- };
- return LinkSets;
-}());
-exports.LinkSets = LinkSets;
-function intersectionCount(m, n) {
- return Object.keys(intersection(m, n)).length;
-}
-function getGroups(nodes, links, la, rootGroup) {
- var n = nodes.length, c = new Configuration(n, links, la, rootGroup);
- while (c.greedyMerge())
- ;
- var powerEdges = [];
- var g = c.getGroupHierarchy(powerEdges);
- powerEdges.forEach(function (e) {
- var f = function (end) {
- var g = e[end];
- if (typeof g == "number")
- e[end] = nodes[g];
- };
- f("source");
- f("target");
- });
- return { groups: g, powerEdges: powerEdges };
-}
-exports.getGroups = getGroups;
-
-},{}],14:[function(require,module,exports){
-"use strict";
-var PairingHeap = (function () {
- function PairingHeap(elem) {
- this.elem = elem;
- this.subheaps = [];
- }
- PairingHeap.prototype.toString = function (selector) {
- var str = "", needComma = false;
- for (var i = 0; i < this.subheaps.length; ++i) {
- var subheap = this.subheaps[i];
- if (!subheap.elem) {
- needComma = false;
- continue;
- }
- if (needComma) {
- str = str + ",";
- }
- str = str + subheap.toString(selector);
- needComma = true;
- }
- if (str !== "") {
- str = "(" + str + ")";
- }
- return (this.elem ? selector(this.elem) : "") + str;
- };
- PairingHeap.prototype.forEach = function (f) {
- if (!this.empty()) {
- f(this.elem, this);
- this.subheaps.forEach(function (s) { return s.forEach(f); });
- }
- };
- PairingHeap.prototype.count = function () {
- return this.empty() ? 0 : 1 + this.subheaps.reduce(function (n, h) {
- return n + h.count();
- }, 0);
- };
- PairingHeap.prototype.min = function () {
- return this.elem;
- };
- PairingHeap.prototype.empty = function () {
- return this.elem == null;
- };
- PairingHeap.prototype.contains = function (h) {
- if (this === h)
- return true;
- for (var i = 0; i < this.subheaps.length; i++) {
- if (this.subheaps[i].contains(h))
- return true;
- }
- return false;
- };
- PairingHeap.prototype.isHeap = function (lessThan) {
- var _this = this;
- return this.subheaps.every(function (h) { return lessThan(_this.elem, h.elem) && h.isHeap(lessThan); });
- };
- PairingHeap.prototype.insert = function (obj, lessThan) {
- return this.merge(new PairingHeap(obj), lessThan);
- };
- PairingHeap.prototype.merge = function (heap2, lessThan) {
- if (this.empty())
- return heap2;
- else if (heap2.empty())
- return this;
- else if (lessThan(this.elem, heap2.elem)) {
- this.subheaps.push(heap2);
- return this;
- }
- else {
- heap2.subheaps.push(this);
- return heap2;
- }
- };
- PairingHeap.prototype.removeMin = function (lessThan) {
- if (this.empty())
- return null;
- else
- return this.mergePairs(lessThan);
- };
- PairingHeap.prototype.mergePairs = function (lessThan) {
- if (this.subheaps.length == 0)
- return new PairingHeap(null);
- else if (this.subheaps.length == 1) {
- return this.subheaps[0];
- }
- else {
- var firstPair = this.subheaps.pop().merge(this.subheaps.pop(), lessThan);
- var remaining = this.mergePairs(lessThan);
- return firstPair.merge(remaining, lessThan);
- }
- };
- PairingHeap.prototype.decreaseKey = function (subheap, newValue, setHeapNode, lessThan) {
- var newHeap = subheap.removeMin(lessThan);
- subheap.elem = newHeap.elem;
- subheap.subheaps = newHeap.subheaps;
- if (setHeapNode !== null && newHeap.elem !== null) {
- setHeapNode(subheap.elem, subheap);
- }
- var pairingNode = new PairingHeap(newValue);
- if (setHeapNode !== null) {
- setHeapNode(newValue, pairingNode);
- }
- return this.merge(pairingNode, lessThan);
- };
- return PairingHeap;
-}());
-exports.PairingHeap = PairingHeap;
-var PriorityQueue = (function () {
- function PriorityQueue(lessThan) {
- this.lessThan = lessThan;
- }
- PriorityQueue.prototype.top = function () {
- if (this.empty()) {
- return null;
- }
- return this.root.elem;
- };
- PriorityQueue.prototype.push = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var pairingNode;
- for (var i = 0, arg; arg = args[i]; ++i) {
- pairingNode = new PairingHeap(arg);
- this.root = this.empty() ?
- pairingNode : this.root.merge(pairingNode, this.lessThan);
- }
- return pairingNode;
- };
- PriorityQueue.prototype.empty = function () {
- return !this.root || !this.root.elem;
- };
- PriorityQueue.prototype.isHeap = function () {
- return this.root.isHeap(this.lessThan);
- };
- PriorityQueue.prototype.forEach = function (f) {
- this.root.forEach(f);
- };
- PriorityQueue.prototype.pop = function () {
- if (this.empty()) {
- return null;
- }
- var obj = this.root.min();
- this.root = this.root.removeMin(this.lessThan);
- return obj;
- };
- PriorityQueue.prototype.reduceKey = function (heapNode, newKey, setHeapNode) {
- if (setHeapNode === void 0) { setHeapNode = null; }
- this.root = this.root.decreaseKey(heapNode, newKey, setHeapNode, this.lessThan);
- };
- PriorityQueue.prototype.toString = function (selector) {
- return this.root.toString(selector);
- };
- PriorityQueue.prototype.count = function () {
- return this.root.count();
- };
- return PriorityQueue;
-}());
-exports.PriorityQueue = PriorityQueue;
-
-},{}],15:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-};
-var TreeBase = (function () {
- function TreeBase() {
- this.findIter = function (data) {
- var res = this._root;
- var iter = this.iterator();
- while (res !== null) {
- var c = this._comparator(data, res.data);
- if (c === 0) {
- iter._cursor = res;
- return iter;
- }
- else {
- iter._ancestors.push(res);
- res = res.get_child(c > 0);
- }
- }
- return null;
- };
- }
- TreeBase.prototype.clear = function () {
- this._root = null;
- this.size = 0;
- };
- ;
- TreeBase.prototype.find = function (data) {
- var res = this._root;
- while (res !== null) {
- var c = this._comparator(data, res.data);
- if (c === 0) {
- return res.data;
- }
- else {
- res = res.get_child(c > 0);
- }
- }
- return null;
- };
- ;
- TreeBase.prototype.lowerBound = function (data) {
- return this._bound(data, this._comparator);
- };
- ;
- TreeBase.prototype.upperBound = function (data) {
- var cmp = this._comparator;
- function reverse_cmp(a, b) {
- return cmp(b, a);
- }
- return this._bound(data, reverse_cmp);
- };
- ;
- TreeBase.prototype.min = function () {
- var res = this._root;
- if (res === null) {
- return null;
- }
- while (res.left !== null) {
- res = res.left;
- }
- return res.data;
- };
- ;
- TreeBase.prototype.max = function () {
- var res = this._root;
- if (res === null) {
- return null;
- }
- while (res.right !== null) {
- res = res.right;
- }
- return res.data;
- };
- ;
- TreeBase.prototype.iterator = function () {
- return new Iterator(this);
- };
- ;
- TreeBase.prototype.each = function (cb) {
- var it = this.iterator(), data;
- while ((data = it.next()) !== null) {
- cb(data);
- }
- };
- ;
- TreeBase.prototype.reach = function (cb) {
- var it = this.iterator(), data;
- while ((data = it.prev()) !== null) {
- cb(data);
- }
- };
- ;
- TreeBase.prototype._bound = function (data, cmp) {
- var cur = this._root;
- var iter = this.iterator();
- while (cur !== null) {
- var c = this._comparator(data, cur.data);
- if (c === 0) {
- iter._cursor = cur;
- return iter;
- }
- iter._ancestors.push(cur);
- cur = cur.get_child(c > 0);
- }
- for (var i = iter._ancestors.length - 1; i >= 0; --i) {
- cur = iter._ancestors[i];
- if (cmp(data, cur.data) > 0) {
- iter._cursor = cur;
- iter._ancestors.length = i;
- return iter;
- }
- }
- iter._ancestors.length = 0;
- return iter;
- };
- ;
- return TreeBase;
-}());
-exports.TreeBase = TreeBase;
-var Iterator = (function () {
- function Iterator(tree) {
- this._tree = tree;
- this._ancestors = [];
- this._cursor = null;
- }
- Iterator.prototype.data = function () {
- return this._cursor !== null ? this._cursor.data : null;
- };
- ;
- Iterator.prototype.next = function () {
- if (this._cursor === null) {
- var root = this._tree._root;
- if (root !== null) {
- this._minNode(root);
- }
- }
- else {
- if (this._cursor.right === null) {
- var save;
- do {
- save = this._cursor;
- if (this._ancestors.length) {
- this._cursor = this._ancestors.pop();
- }
- else {
- this._cursor = null;
- break;
- }
- } while (this._cursor.right === save);
- }
- else {
- this._ancestors.push(this._cursor);
- this._minNode(this._cursor.right);
- }
- }
- return this._cursor !== null ? this._cursor.data : null;
- };
- ;
- Iterator.prototype.prev = function () {
- if (this._cursor === null) {
- var root = this._tree._root;
- if (root !== null) {
- this._maxNode(root);
- }
- }
- else {
- if (this._cursor.left === null) {
- var save;
- do {
- save = this._cursor;
- if (this._ancestors.length) {
- this._cursor = this._ancestors.pop();
- }
- else {
- this._cursor = null;
- break;
- }
- } while (this._cursor.left === save);
- }
- else {
- this._ancestors.push(this._cursor);
- this._maxNode(this._cursor.left);
- }
- }
- return this._cursor !== null ? this._cursor.data : null;
- };
- ;
- Iterator.prototype._minNode = function (start) {
- while (start.left !== null) {
- this._ancestors.push(start);
- start = start.left;
- }
- this._cursor = start;
- };
- ;
- Iterator.prototype._maxNode = function (start) {
- while (start.right !== null) {
- this._ancestors.push(start);
- start = start.right;
- }
- this._cursor = start;
- };
- ;
- return Iterator;
-}());
-exports.Iterator = Iterator;
-var Node = (function () {
- function Node(data) {
- this.data = data;
- this.left = null;
- this.right = null;
- this.red = true;
- }
- Node.prototype.get_child = function (dir) {
- return dir ? this.right : this.left;
- };
- ;
- Node.prototype.set_child = function (dir, val) {
- if (dir) {
- this.right = val;
- }
- else {
- this.left = val;
- }
- };
- ;
- return Node;
-}());
-var RBTree = (function (_super) {
- __extends(RBTree, _super);
- function RBTree(comparator) {
- var _this = _super.call(this) || this;
- _this._root = null;
- _this._comparator = comparator;
- _this.size = 0;
- return _this;
- }
- RBTree.prototype.insert = function (data) {
- var ret = false;
- if (this._root === null) {
- this._root = new Node(data);
- ret = true;
- this.size++;
- }
- else {
- var head = new Node(undefined);
- var dir = false;
- var last = false;
- var gp = null;
- var ggp = head;
- var p = null;
- var node = this._root;
- ggp.right = this._root;
- while (true) {
- if (node === null) {
- node = new Node(data);
- p.set_child(dir, node);
- ret = true;
- this.size++;
- }
- else if (RBTree.is_red(node.left) && RBTree.is_red(node.right)) {
- node.red = true;
- node.left.red = false;
- node.right.red = false;
- }
- if (RBTree.is_red(node) && RBTree.is_red(p)) {
- var dir2 = ggp.right === gp;
- if (node === p.get_child(last)) {
- ggp.set_child(dir2, RBTree.single_rotate(gp, !last));
- }
- else {
- ggp.set_child(dir2, RBTree.double_rotate(gp, !last));
- }
- }
- var cmp = this._comparator(node.data, data);
- if (cmp === 0) {
- break;
- }
- last = dir;
- dir = cmp < 0;
- if (gp !== null) {
- ggp = gp;
- }
- gp = p;
- p = node;
- node = node.get_child(dir);
- }
- this._root = head.right;
- }
- this._root.red = false;
- return ret;
- };
- ;
- RBTree.prototype.remove = function (data) {
- if (this._root === null) {
- return false;
- }
- var head = new Node(undefined);
- var node = head;
- node.right = this._root;
- var p = null;
- var gp = null;
- var found = null;
- var dir = true;
- while (node.get_child(dir) !== null) {
- var last = dir;
- gp = p;
- p = node;
- node = node.get_child(dir);
- var cmp = this._comparator(data, node.data);
- dir = cmp > 0;
- if (cmp === 0) {
- found = node;
- }
- if (!RBTree.is_red(node) && !RBTree.is_red(node.get_child(dir))) {
- if (RBTree.is_red(node.get_child(!dir))) {
- var sr = RBTree.single_rotate(node, dir);
- p.set_child(last, sr);
- p = sr;
- }
- else if (!RBTree.is_red(node.get_child(!dir))) {
- var sibling = p.get_child(!last);
- if (sibling !== null) {
- if (!RBTree.is_red(sibling.get_child(!last)) && !RBTree.is_red(sibling.get_child(last))) {
- p.red = false;
- sibling.red = true;
- node.red = true;
- }
- else {
- var dir2 = gp.right === p;
- if (RBTree.is_red(sibling.get_child(last))) {
- gp.set_child(dir2, RBTree.double_rotate(p, last));
- }
- else if (RBTree.is_red(sibling.get_child(!last))) {
- gp.set_child(dir2, RBTree.single_rotate(p, last));
- }
- var gpc = gp.get_child(dir2);
- gpc.red = true;
- node.red = true;
- gpc.left.red = false;
- gpc.right.red = false;
- }
- }
- }
- }
- }
- if (found !== null) {
- found.data = node.data;
- p.set_child(p.right === node, node.get_child(node.left === null));
- this.size--;
- }
- this._root = head.right;
- if (this._root !== null) {
- this._root.red = false;
- }
- return found !== null;
- };
- ;
- RBTree.is_red = function (node) {
- return node !== null && node.red;
- };
- RBTree.single_rotate = function (root, dir) {
- var save = root.get_child(!dir);
- root.set_child(!dir, save.get_child(dir));
- save.set_child(dir, root);
- root.red = true;
- save.red = false;
- return save;
- };
- RBTree.double_rotate = function (root, dir) {
- root.set_child(!dir, RBTree.single_rotate(root.get_child(!dir), !dir));
- return RBTree.single_rotate(root, dir);
- };
- return RBTree;
-}(TreeBase));
-exports.RBTree = RBTree;
-
-},{}],16:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-};
-var vpsc_1 = require("./vpsc");
-var rbtree_1 = require("./rbtree");
-function computeGroupBounds(g) {
- g.bounds = typeof g.leaves !== "undefined" ?
- g.leaves.reduce(function (r, c) { return c.bounds.union(r); }, Rectangle.empty()) :
- Rectangle.empty();
- if (typeof g.groups !== "undefined")
- g.bounds = g.groups.reduce(function (r, c) { return computeGroupBounds(c).union(r); }, g.bounds);
- g.bounds = g.bounds.inflate(g.padding);
- return g.bounds;
-}
-exports.computeGroupBounds = computeGroupBounds;
-var Rectangle = (function () {
- function Rectangle(x, X, y, Y) {
- this.x = x;
- this.X = X;
- this.y = y;
- this.Y = Y;
- }
- Rectangle.empty = function () { return new Rectangle(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); };
- Rectangle.prototype.cx = function () { return (this.x + this.X) / 2; };
- Rectangle.prototype.cy = function () { return (this.y + this.Y) / 2; };
- Rectangle.prototype.overlapX = function (r) {
- var ux = this.cx(), vx = r.cx();
- if (ux <= vx && r.x < this.X)
- return this.X - r.x;
- if (vx <= ux && this.x < r.X)
- return r.X - this.x;
- return 0;
- };
- Rectangle.prototype.overlapY = function (r) {
- var uy = this.cy(), vy = r.cy();
- if (uy <= vy && r.y < this.Y)
- return this.Y - r.y;
- if (vy <= uy && this.y < r.Y)
- return r.Y - this.y;
- return 0;
- };
- Rectangle.prototype.setXCentre = function (cx) {
- var dx = cx - this.cx();
- this.x += dx;
- this.X += dx;
- };
- Rectangle.prototype.setYCentre = function (cy) {
- var dy = cy - this.cy();
- this.y += dy;
- this.Y += dy;
- };
- Rectangle.prototype.width = function () {
- return this.X - this.x;
- };
- Rectangle.prototype.height = function () {
- return this.Y - this.y;
- };
- Rectangle.prototype.union = function (r) {
- return new Rectangle(Math.min(this.x, r.x), Math.max(this.X, r.X), Math.min(this.y, r.y), Math.max(this.Y, r.Y));
- };
- Rectangle.prototype.lineIntersections = function (x1, y1, x2, y2) {
- var sides = [[this.x, this.y, this.X, this.y],
- [this.X, this.y, this.X, this.Y],
- [this.X, this.Y, this.x, this.Y],
- [this.x, this.Y, this.x, this.y]];
- var intersections = [];
- for (var i = 0; i < 4; ++i) {
- var r = Rectangle.lineIntersection(x1, y1, x2, y2, sides[i][0], sides[i][1], sides[i][2], sides[i][3]);
- if (r !== null)
- intersections.push({ x: r.x, y: r.y });
- }
- return intersections;
- };
- Rectangle.prototype.rayIntersection = function (x2, y2) {
- var ints = this.lineIntersections(this.cx(), this.cy(), x2, y2);
- return ints.length > 0 ? ints[0] : null;
- };
- Rectangle.prototype.vertices = function () {
- return [
- { x: this.x, y: this.y },
- { x: this.X, y: this.y },
- { x: this.X, y: this.Y },
- { x: this.x, y: this.Y },
- { x: this.x, y: this.y }
- ];
- };
- Rectangle.lineIntersection = function (x1, y1, x2, y2, x3, y3, x4, y4) {
- var dx12 = x2 - x1, dx34 = x4 - x3, dy12 = y2 - y1, dy34 = y4 - y3, denominator = dy34 * dx12 - dx34 * dy12;
- if (denominator == 0)
- return null;
- var dx31 = x1 - x3, dy31 = y1 - y3, numa = dx34 * dy31 - dy34 * dx31, a = numa / denominator, numb = dx12 * dy31 - dy12 * dx31, b = numb / denominator;
- if (a >= 0 && a <= 1 && b >= 0 && b <= 1) {
- return {
- x: x1 + a * dx12,
- y: y1 + a * dy12
- };
- }
- return null;
- };
- Rectangle.prototype.inflate = function (pad) {
- return new Rectangle(this.x - pad, this.X + pad, this.y - pad, this.Y + pad);
- };
- return Rectangle;
-}());
-exports.Rectangle = Rectangle;
-function makeEdgeBetween(source, target, ah) {
- var si = source.rayIntersection(target.cx(), target.cy()) || { x: source.cx(), y: source.cy() }, ti = target.rayIntersection(source.cx(), source.cy()) || { x: target.cx(), y: target.cy() }, dx = ti.x - si.x, dy = ti.y - si.y, l = Math.sqrt(dx * dx + dy * dy), al = l - ah;
- return {
- sourceIntersection: si,
- targetIntersection: ti,
- arrowStart: { x: si.x + al * dx / l, y: si.y + al * dy / l }
- };
-}
-exports.makeEdgeBetween = makeEdgeBetween;
-function makeEdgeTo(s, target, ah) {
- var ti = target.rayIntersection(s.x, s.y);
- if (!ti)
- ti = { x: target.cx(), y: target.cy() };
- var dx = ti.x - s.x, dy = ti.y - s.y, l = Math.sqrt(dx * dx + dy * dy);
- return { x: ti.x - ah * dx / l, y: ti.y - ah * dy / l };
-}
-exports.makeEdgeTo = makeEdgeTo;
-var Node = (function () {
- function Node(v, r, pos) {
- this.v = v;
- this.r = r;
- this.pos = pos;
- this.prev = makeRBTree();
- this.next = makeRBTree();
- }
- return Node;
-}());
-var Event = (function () {
- function Event(isOpen, v, pos) {
- this.isOpen = isOpen;
- this.v = v;
- this.pos = pos;
- }
- return Event;
-}());
-function compareEvents(a, b) {
- if (a.pos > b.pos) {
- return 1;
- }
- if (a.pos < b.pos) {
- return -1;
- }
- if (a.isOpen) {
- return -1;
- }
- if (b.isOpen) {
- return 1;
- }
- return 0;
-}
-function makeRBTree() {
- return new rbtree_1.RBTree(function (a, b) { return a.pos - b.pos; });
-}
-var xRect = {
- getCentre: function (r) { return r.cx(); },
- getOpen: function (r) { return r.y; },
- getClose: function (r) { return r.Y; },
- getSize: function (r) { return r.width(); },
- makeRect: function (open, close, center, size) { return new Rectangle(center - size / 2, center + size / 2, open, close); },
- findNeighbours: findXNeighbours
-};
-var yRect = {
- getCentre: function (r) { return r.cy(); },
- getOpen: function (r) { return r.x; },
- getClose: function (r) { return r.X; },
- getSize: function (r) { return r.height(); },
- makeRect: function (open, close, center, size) { return new Rectangle(open, close, center - size / 2, center + size / 2); },
- findNeighbours: findYNeighbours
-};
-function generateGroupConstraints(root, f, minSep, isContained) {
- if (isContained === void 0) { isContained = false; }
- var padding = root.padding, gn = typeof root.groups !== 'undefined' ? root.groups.length : 0, ln = typeof root.leaves !== 'undefined' ? root.leaves.length : 0, childConstraints = !gn ? []
- : root.groups.reduce(function (ccs, g) { return ccs.concat(generateGroupConstraints(g, f, minSep, true)); }, []), n = (isContained ? 2 : 0) + ln + gn, vs = new Array(n), rs = new Array(n), i = 0, add = function (r, v) { rs[i] = r; vs[i++] = v; };
- if (isContained) {
- var b = root.bounds, c = f.getCentre(b), s = f.getSize(b) / 2, open = f.getOpen(b), close = f.getClose(b), min = c - s + padding / 2, max = c + s - padding / 2;
- root.minVar.desiredPosition = min;
- add(f.makeRect(open, close, min, padding), root.minVar);
- root.maxVar.desiredPosition = max;
- add(f.makeRect(open, close, max, padding), root.maxVar);
- }
- if (ln)
- root.leaves.forEach(function (l) { return add(l.bounds, l.variable); });
- if (gn)
- root.groups.forEach(function (g) {
- var b = g.bounds;
- add(f.makeRect(f.getOpen(b), f.getClose(b), f.getCentre(b), f.getSize(b)), g.minVar);
- });
- var cs = generateConstraints(rs, vs, f, minSep);
- if (gn) {
- vs.forEach(function (v) { v.cOut = [], v.cIn = []; });
- cs.forEach(function (c) { c.left.cOut.push(c), c.right.cIn.push(c); });
- root.groups.forEach(function (g) {
- var gapAdjustment = (g.padding - f.getSize(g.bounds)) / 2;
- g.minVar.cIn.forEach(function (c) { return c.gap += gapAdjustment; });
- g.minVar.cOut.forEach(function (c) { c.left = g.maxVar; c.gap += gapAdjustment; });
- });
- }
- return childConstraints.concat(cs);
-}
-function generateConstraints(rs, vars, rect, minSep) {
- var i, n = rs.length;
- var N = 2 * n;
- console.assert(vars.length >= n);
- var events = new Array(N);
- for (i = 0; i < n; ++i) {
- var r = rs[i];
- var v = new Node(vars[i], r, rect.getCentre(r));
- events[i] = new Event(true, v, rect.getOpen(r));
- events[i + n] = new Event(false, v, rect.getClose(r));
- }
- events.sort(compareEvents);
- var cs = new Array();
- var scanline = makeRBTree();
- for (i = 0; i < N; ++i) {
- var e = events[i];
- var v = e.v;
- if (e.isOpen) {
- scanline.insert(v);
- rect.findNeighbours(v, scanline);
- }
- else {
- scanline.remove(v);
- var makeConstraint = function (l, r) {
- var sep = (rect.getSize(l.r) + rect.getSize(r.r)) / 2 + minSep;
- cs.push(new vpsc_1.Constraint(l.v, r.v, sep));
- };
- var visitNeighbours = function (forward, reverse, mkcon) {
- var u, it = v[forward].iterator();
- while ((u = it[forward]()) !== null) {
- mkcon(u, v);
- u[reverse].remove(v);
- }
- };
- visitNeighbours("prev", "next", function (u, v) { return makeConstraint(u, v); });
- visitNeighbours("next", "prev", function (u, v) { return makeConstraint(v, u); });
- }
- }
- console.assert(scanline.size === 0);
- return cs;
-}
-function findXNeighbours(v, scanline) {
- var f = function (forward, reverse) {
- var it = scanline.findIter(v);
- var u;
- while ((u = it[forward]()) !== null) {
- var uovervX = u.r.overlapX(v.r);
- if (uovervX <= 0 || uovervX <= u.r.overlapY(v.r)) {
- v[forward].insert(u);
- u[reverse].insert(v);
- }
- if (uovervX <= 0) {
- break;
- }
- }
- };
- f("next", "prev");
- f("prev", "next");
-}
-function findYNeighbours(v, scanline) {
- var f = function (forward, reverse) {
- var u = scanline.findIter(v)[forward]();
- if (u !== null && u.r.overlapX(v.r) > 0) {
- v[forward].insert(u);
- u[reverse].insert(v);
- }
- };
- f("next", "prev");
- f("prev", "next");
-}
-function generateXConstraints(rs, vars) {
- return generateConstraints(rs, vars, xRect, 1e-6);
-}
-exports.generateXConstraints = generateXConstraints;
-function generateYConstraints(rs, vars) {
- return generateConstraints(rs, vars, yRect, 1e-6);
-}
-exports.generateYConstraints = generateYConstraints;
-function generateXGroupConstraints(root) {
- return generateGroupConstraints(root, xRect, 1e-6);
-}
-exports.generateXGroupConstraints = generateXGroupConstraints;
-function generateYGroupConstraints(root) {
- return generateGroupConstraints(root, yRect, 1e-6);
-}
-exports.generateYGroupConstraints = generateYGroupConstraints;
-function removeOverlaps(rs) {
- var vs = rs.map(function (r) { return new vpsc_1.Variable(r.cx()); });
- var cs = generateXConstraints(rs, vs);
- var solver = new vpsc_1.Solver(vs, cs);
- solver.solve();
- vs.forEach(function (v, i) { return rs[i].setXCentre(v.position()); });
- vs = rs.map(function (r) { return new vpsc_1.Variable(r.cy()); });
- cs = generateYConstraints(rs, vs);
- solver = new vpsc_1.Solver(vs, cs);
- solver.solve();
- vs.forEach(function (v, i) { return rs[i].setYCentre(v.position()); });
-}
-exports.removeOverlaps = removeOverlaps;
-var IndexedVariable = (function (_super) {
- __extends(IndexedVariable, _super);
- function IndexedVariable(index, w) {
- var _this = _super.call(this, 0, w) || this;
- _this.index = index;
- return _this;
- }
- return IndexedVariable;
-}(vpsc_1.Variable));
-exports.IndexedVariable = IndexedVariable;
-var Projection = (function () {
- function Projection(nodes, groups, rootGroup, constraints, avoidOverlaps) {
- if (rootGroup === void 0) { rootGroup = null; }
- if (constraints === void 0) { constraints = null; }
- if (avoidOverlaps === void 0) { avoidOverlaps = false; }
- var _this = this;
- this.nodes = nodes;
- this.groups = groups;
- this.rootGroup = rootGroup;
- this.avoidOverlaps = avoidOverlaps;
- this.variables = nodes.map(function (v, i) {
- return v.variable = new IndexedVariable(i, 1);
- });
- if (constraints)
- this.createConstraints(constraints);
- if (avoidOverlaps && rootGroup && typeof rootGroup.groups !== 'undefined') {
- nodes.forEach(function (v) {
- if (!v.width || !v.height) {
- v.bounds = new Rectangle(v.x, v.x, v.y, v.y);
- return;
- }
- var w2 = v.width / 2, h2 = v.height / 2;
- v.bounds = new Rectangle(v.x - w2, v.x + w2, v.y - h2, v.y + h2);
- });
- computeGroupBounds(rootGroup);
- var i = nodes.length;
- groups.forEach(function (g) {
- _this.variables[i] = g.minVar = new IndexedVariable(i++, typeof g.stiffness !== "undefined" ? g.stiffness : 0.01);
- _this.variables[i] = g.maxVar = new IndexedVariable(i++, typeof g.stiffness !== "undefined" ? g.stiffness : 0.01);
- });
- }
- }
- Projection.prototype.createSeparation = function (c) {
- return new vpsc_1.Constraint(this.nodes[c.left].variable, this.nodes[c.right].variable, c.gap, typeof c.equality !== "undefined" ? c.equality : false);
- };
- Projection.prototype.makeFeasible = function (c) {
- var _this = this;
- if (!this.avoidOverlaps)
- return;
- var axis = 'x', dim = 'width';
- if (c.axis === 'x')
- axis = 'y', dim = 'height';
- var vs = c.offsets.map(function (o) { return _this.nodes[o.node]; }).sort(function (a, b) { return a[axis] - b[axis]; });
- var p = null;
- vs.forEach(function (v) {
- if (p)
- v[axis] = p[axis] + p[dim] + 1;
- p = v;
- });
- };
- Projection.prototype.createAlignment = function (c) {
- var _this = this;
- var u = this.nodes[c.offsets[0].node].variable;
- this.makeFeasible(c);
- var cs = c.axis === 'x' ? this.xConstraints : this.yConstraints;
- c.offsets.slice(1).forEach(function (o) {
- var v = _this.nodes[o.node].variable;
- cs.push(new vpsc_1.Constraint(u, v, o.offset, true));
- });
- };
- Projection.prototype.createConstraints = function (constraints) {
- var _this = this;
- var isSep = function (c) { return typeof c.type === 'undefined' || c.type === 'separation'; };
- this.xConstraints = constraints
- .filter(function (c) { return c.axis === "x" && isSep(c); })
- .map(function (c) { return _this.createSeparation(c); });
- this.yConstraints = constraints
- .filter(function (c) { return c.axis === "y" && isSep(c); })
- .map(function (c) { return _this.createSeparation(c); });
- constraints
- .filter(function (c) { return c.type === 'alignment'; })
- .forEach(function (c) { return _this.createAlignment(c); });
- };
- Projection.prototype.setupVariablesAndBounds = function (x0, y0, desired, getDesired) {
- this.nodes.forEach(function (v, i) {
- if (v.fixed) {
- v.variable.weight = v.fixedWeight ? v.fixedWeight : 1000;
- desired[i] = getDesired(v);
- }
- else {
- v.variable.weight = 1;
- }
- var w = (v.width || 0) / 2, h = (v.height || 0) / 2;
- var ix = x0[i], iy = y0[i];
- v.bounds = new Rectangle(ix - w, ix + w, iy - h, iy + h);
- });
- };
- Projection.prototype.xProject = function (x0, y0, x) {
- if (!this.rootGroup && !(this.avoidOverlaps || this.xConstraints))
- return;
- this.project(x0, y0, x0, x, function (v) { return v.px; }, this.xConstraints, generateXGroupConstraints, function (v) { return v.bounds.setXCentre(x[v.variable.index] = v.variable.position()); }, function (g) {
- var xmin = x[g.minVar.index] = g.minVar.position();
- var xmax = x[g.maxVar.index] = g.maxVar.position();
- var p2 = g.padding / 2;
- g.bounds.x = xmin - p2;
- g.bounds.X = xmax + p2;
- });
- };
- Projection.prototype.yProject = function (x0, y0, y) {
- if (!this.rootGroup && !this.yConstraints)
- return;
- this.project(x0, y0, y0, y, function (v) { return v.py; }, this.yConstraints, generateYGroupConstraints, function (v) { return v.bounds.setYCentre(y[v.variable.index] = v.variable.position()); }, function (g) {
- var ymin = y[g.minVar.index] = g.minVar.position();
- var ymax = y[g.maxVar.index] = g.maxVar.position();
- var p2 = g.padding / 2;
- g.bounds.y = ymin - p2;
- ;
- g.bounds.Y = ymax + p2;
- });
- };
- Projection.prototype.projectFunctions = function () {
- var _this = this;
- return [
- function (x0, y0, x) { return _this.xProject(x0, y0, x); },
- function (x0, y0, y) { return _this.yProject(x0, y0, y); }
- ];
- };
- Projection.prototype.project = function (x0, y0, start, desired, getDesired, cs, generateConstraints, updateNodeBounds, updateGroupBounds) {
- this.setupVariablesAndBounds(x0, y0, desired, getDesired);
- if (this.rootGroup && this.avoidOverlaps) {
- computeGroupBounds(this.rootGroup);
- cs = cs.concat(generateConstraints(this.rootGroup));
- }
- this.solve(this.variables, cs, start, desired);
- this.nodes.forEach(updateNodeBounds);
- if (this.rootGroup && this.avoidOverlaps) {
- this.groups.forEach(updateGroupBounds);
- computeGroupBounds(this.rootGroup);
- }
- };
- Projection.prototype.solve = function (vs, cs, starting, desired) {
- var solver = new vpsc_1.Solver(vs, cs);
- solver.setStartingPositions(starting);
- solver.setDesiredPositions(desired);
- solver.solve();
- };
- return Projection;
-}());
-exports.Projection = Projection;
-
-},{"./rbtree":15,"./vpsc":18}],17:[function(require,module,exports){
-"use strict";
-var pqueue_1 = require("./pqueue");
-var Neighbour = (function () {
- function Neighbour(id, distance) {
- this.id = id;
- this.distance = distance;
- }
- return Neighbour;
-}());
-var Node = (function () {
- function Node(id) {
- this.id = id;
- this.neighbours = [];
- }
- return Node;
-}());
-var QueueEntry = (function () {
- function QueueEntry(node, prev, d) {
- this.node = node;
- this.prev = prev;
- this.d = d;
- }
- return QueueEntry;
-}());
-var Calculator = (function () {
- function Calculator(n, es, getSourceIndex, getTargetIndex, getLength) {
- this.n = n;
- this.es = es;
- this.neighbours = new Array(this.n);
- var i = this.n;
- while (i--)
- this.neighbours[i] = new Node(i);
- i = this.es.length;
- while (i--) {
- var e = this.es[i];
- var u = getSourceIndex(e), v = getTargetIndex(e);
- var d = getLength(e);
- this.neighbours[u].neighbours.push(new Neighbour(v, d));
- this.neighbours[v].neighbours.push(new Neighbour(u, d));
- }
- }
- Calculator.prototype.DistanceMatrix = function () {
- var D = new Array(this.n);
- for (var i = 0; i < this.n; ++i) {
- D[i] = this.dijkstraNeighbours(i);
- }
- return D;
- };
- Calculator.prototype.DistancesFromNode = function (start) {
- return this.dijkstraNeighbours(start);
- };
- Calculator.prototype.PathFromNodeToNode = function (start, end) {
- return this.dijkstraNeighbours(start, end);
- };
- Calculator.prototype.PathFromNodeToNodeWithPrevCost = function (start, end, prevCost) {
- var q = new pqueue_1.PriorityQueue(function (a, b) { return a.d <= b.d; }), u = this.neighbours[start], qu = new QueueEntry(u, null, 0), visitedFrom = {};
- q.push(qu);
- while (!q.empty()) {
- qu = q.pop();
- u = qu.node;
- if (u.id === end) {
- break;
- }
- var i = u.neighbours.length;
- while (i--) {
- var neighbour = u.neighbours[i], v = this.neighbours[neighbour.id];
- if (qu.prev && v.id === qu.prev.node.id)
- continue;
- var viduid = v.id + ',' + u.id;
- if (viduid in visitedFrom && visitedFrom[viduid] <= qu.d)
- continue;
- var cc = qu.prev ? prevCost(qu.prev.node.id, u.id, v.id) : 0, t = qu.d + neighbour.distance + cc;
- visitedFrom[viduid] = t;
- q.push(new QueueEntry(v, qu, t));
- }
- }
- var path = [];
- while (qu.prev) {
- qu = qu.prev;
- path.push(qu.node.id);
- }
- return path;
- };
- Calculator.prototype.dijkstraNeighbours = function (start, dest) {
- if (dest === void 0) { dest = -1; }
- var q = new pqueue_1.PriorityQueue(function (a, b) { return a.d <= b.d; }), i = this.neighbours.length, d = new Array(i);
- while (i--) {
- var node = this.neighbours[i];
- node.d = i === start ? 0 : Number.POSITIVE_INFINITY;
- node.q = q.push(node);
- }
- while (!q.empty()) {
- var u = q.pop();
- d[u.id] = u.d;
- if (u.id === dest) {
- var path = [];
- var v = u;
- while (typeof v.prev !== 'undefined') {
- path.push(v.prev.id);
- v = v.prev;
- }
- return path;
- }
- i = u.neighbours.length;
- while (i--) {
- var neighbour = u.neighbours[i];
- var v = this.neighbours[neighbour.id];
- var t = u.d + neighbour.distance;
- if (u.d !== Number.MAX_VALUE && v.d > t) {
- v.d = t;
- v.prev = u;
- q.reduceKey(v.q, v, function (e, q) { return e.q = q; });
- }
- }
- }
- return d;
- };
- return Calculator;
-}());
-exports.Calculator = Calculator;
-
-},{"./pqueue":14}],18:[function(require,module,exports){
-"use strict";
-var PositionStats = (function () {
- function PositionStats(scale) {
- this.scale = scale;
- this.AB = 0;
- this.AD = 0;
- this.A2 = 0;
- }
- PositionStats.prototype.addVariable = function (v) {
- var ai = this.scale / v.scale;
- var bi = v.offset / v.scale;
- var wi = v.weight;
- this.AB += wi * ai * bi;
- this.AD += wi * ai * v.desiredPosition;
- this.A2 += wi * ai * ai;
- };
- PositionStats.prototype.getPosn = function () {
- return (this.AD - this.AB) / this.A2;
- };
- return PositionStats;
-}());
-exports.PositionStats = PositionStats;
-var Constraint = (function () {
- function Constraint(left, right, gap, equality) {
- if (equality === void 0) { equality = false; }
- this.left = left;
- this.right = right;
- this.gap = gap;
- this.equality = equality;
- this.active = false;
- this.unsatisfiable = false;
- this.left = left;
- this.right = right;
- this.gap = gap;
- this.equality = equality;
- }
- Constraint.prototype.slack = function () {
- return this.unsatisfiable ? Number.MAX_VALUE
- : this.right.scale * this.right.position() - this.gap
- - this.left.scale * this.left.position();
- };
- return Constraint;
-}());
-exports.Constraint = Constraint;
-var Variable = (function () {
- function Variable(desiredPosition, weight, scale) {
- if (weight === void 0) { weight = 1; }
- if (scale === void 0) { scale = 1; }
- this.desiredPosition = desiredPosition;
- this.weight = weight;
- this.scale = scale;
- this.offset = 0;
- }
- Variable.prototype.dfdv = function () {
- return 2.0 * this.weight * (this.position() - this.desiredPosition);
- };
- Variable.prototype.position = function () {
- return (this.block.ps.scale * this.block.posn + this.offset) / this.scale;
- };
- Variable.prototype.visitNeighbours = function (prev, f) {
- var ff = function (c, next) { return c.active && prev !== next && f(c, next); };
- this.cOut.forEach(function (c) { return ff(c, c.right); });
- this.cIn.forEach(function (c) { return ff(c, c.left); });
- };
- return Variable;
-}());
-exports.Variable = Variable;
-var Block = (function () {
- function Block(v) {
- this.vars = [];
- v.offset = 0;
- this.ps = new PositionStats(v.scale);
- this.addVariable(v);
- }
- Block.prototype.addVariable = function (v) {
- v.block = this;
- this.vars.push(v);
- this.ps.addVariable(v);
- this.posn = this.ps.getPosn();
- };
- Block.prototype.updateWeightedPosition = function () {
- this.ps.AB = this.ps.AD = this.ps.A2 = 0;
- for (var i = 0, n = this.vars.length; i < n; ++i)
- this.ps.addVariable(this.vars[i]);
- this.posn = this.ps.getPosn();
- };
- Block.prototype.compute_lm = function (v, u, postAction) {
- var _this = this;
- var dfdv = v.dfdv();
- v.visitNeighbours(u, function (c, next) {
- var _dfdv = _this.compute_lm(next, v, postAction);
- if (next === c.right) {
- dfdv += _dfdv * c.left.scale;
- c.lm = _dfdv;
- }
- else {
- dfdv += _dfdv * c.right.scale;
- c.lm = -_dfdv;
- }
- postAction(c);
- });
- return dfdv / v.scale;
- };
- Block.prototype.populateSplitBlock = function (v, prev) {
- var _this = this;
- v.visitNeighbours(prev, function (c, next) {
- next.offset = v.offset + (next === c.right ? c.gap : -c.gap);
- _this.addVariable(next);
- _this.populateSplitBlock(next, v);
- });
- };
- Block.prototype.traverse = function (visit, acc, v, prev) {
- var _this = this;
- if (v === void 0) { v = this.vars[0]; }
- if (prev === void 0) { prev = null; }
- v.visitNeighbours(prev, function (c, next) {
- acc.push(visit(c));
- _this.traverse(visit, acc, next, v);
- });
- };
- Block.prototype.findMinLM = function () {
- var m = null;
- this.compute_lm(this.vars[0], null, function (c) {
- if (!c.equality && (m === null || c.lm < m.lm))
- m = c;
- });
- return m;
- };
- Block.prototype.findMinLMBetween = function (lv, rv) {
- this.compute_lm(lv, null, function () { });
- var m = null;
- this.findPath(lv, null, rv, function (c, next) {
- if (!c.equality && c.right === next && (m === null || c.lm < m.lm))
- m = c;
- });
- return m;
- };
- Block.prototype.findPath = function (v, prev, to, visit) {
- var _this = this;
- var endFound = false;
- v.visitNeighbours(prev, function (c, next) {
- if (!endFound && (next === to || _this.findPath(next, v, to, visit))) {
- endFound = true;
- visit(c, next);
- }
- });
- return endFound;
- };
- Block.prototype.isActiveDirectedPathBetween = function (u, v) {
- if (u === v)
- return true;
- var i = u.cOut.length;
- while (i--) {
- var c = u.cOut[i];
- if (c.active && this.isActiveDirectedPathBetween(c.right, v))
- return true;
- }
- return false;
- };
- Block.split = function (c) {
- c.active = false;
- return [Block.createSplitBlock(c.left), Block.createSplitBlock(c.right)];
- };
- Block.createSplitBlock = function (startVar) {
- var b = new Block(startVar);
- b.populateSplitBlock(startVar, null);
- return b;
- };
- Block.prototype.splitBetween = function (vl, vr) {
- var c = this.findMinLMBetween(vl, vr);
- if (c !== null) {
- var bs = Block.split(c);
- return { constraint: c, lb: bs[0], rb: bs[1] };
- }
- return null;
- };
- Block.prototype.mergeAcross = function (b, c, dist) {
- c.active = true;
- for (var i = 0, n = b.vars.length; i < n; ++i) {
- var v = b.vars[i];
- v.offset += dist;
- this.addVariable(v);
- }
- this.posn = this.ps.getPosn();
- };
- Block.prototype.cost = function () {
- var sum = 0, i = this.vars.length;
- while (i--) {
- var v = this.vars[i], d = v.position() - v.desiredPosition;
- sum += d * d * v.weight;
- }
- return sum;
- };
- return Block;
-}());
-exports.Block = Block;
-var Blocks = (function () {
- function Blocks(vs) {
- this.vs = vs;
- var n = vs.length;
- this.list = new Array(n);
- while (n--) {
- var b = new Block(vs[n]);
- this.list[n] = b;
- b.blockInd = n;
- }
- }
- Blocks.prototype.cost = function () {
- var sum = 0, i = this.list.length;
- while (i--)
- sum += this.list[i].cost();
- return sum;
- };
- Blocks.prototype.insert = function (b) {
- b.blockInd = this.list.length;
- this.list.push(b);
- };
- Blocks.prototype.remove = function (b) {
- var last = this.list.length - 1;
- var swapBlock = this.list[last];
- this.list.length = last;
- if (b !== swapBlock) {
- this.list[b.blockInd] = swapBlock;
- swapBlock.blockInd = b.blockInd;
- }
- };
- Blocks.prototype.merge = function (c) {
- var l = c.left.block, r = c.right.block;
- var dist = c.right.offset - c.left.offset - c.gap;
- if (l.vars.length < r.vars.length) {
- r.mergeAcross(l, c, dist);
- this.remove(l);
- }
- else {
- l.mergeAcross(r, c, -dist);
- this.remove(r);
- }
- };
- Blocks.prototype.forEach = function (f) {
- this.list.forEach(f);
- };
- Blocks.prototype.updateBlockPositions = function () {
- this.list.forEach(function (b) { return b.updateWeightedPosition(); });
- };
- Blocks.prototype.split = function (inactive) {
- var _this = this;
- this.updateBlockPositions();
- this.list.forEach(function (b) {
- var v = b.findMinLM();
- if (v !== null && v.lm < Solver.LAGRANGIAN_TOLERANCE) {
- b = v.left.block;
- Block.split(v).forEach(function (nb) { return _this.insert(nb); });
- _this.remove(b);
- inactive.push(v);
- }
- });
- };
- return Blocks;
-}());
-exports.Blocks = Blocks;
-var Solver = (function () {
- function Solver(vs, cs) {
- this.vs = vs;
- this.cs = cs;
- this.vs = vs;
- vs.forEach(function (v) {
- v.cIn = [], v.cOut = [];
- });
- this.cs = cs;
- cs.forEach(function (c) {
- c.left.cOut.push(c);
- c.right.cIn.push(c);
- });
- this.inactive = cs.map(function (c) { c.active = false; return c; });
- this.bs = null;
- }
- Solver.prototype.cost = function () {
- return this.bs.cost();
- };
- Solver.prototype.setStartingPositions = function (ps) {
- this.inactive = this.cs.map(function (c) { c.active = false; return c; });
- this.bs = new Blocks(this.vs);
- this.bs.forEach(function (b, i) { return b.posn = ps[i]; });
- };
- Solver.prototype.setDesiredPositions = function (ps) {
- this.vs.forEach(function (v, i) { return v.desiredPosition = ps[i]; });
- };
- Solver.prototype.mostViolated = function () {
- var minSlack = Number.MAX_VALUE, v = null, l = this.inactive, n = l.length, deletePoint = n;
- for (var i = 0; i < n; ++i) {
- var c = l[i];
- if (c.unsatisfiable)
- continue;
- var slack = c.slack();
- if (c.equality || slack < minSlack) {
- minSlack = slack;
- v = c;
- deletePoint = i;
- if (c.equality)
- break;
- }
- }
- if (deletePoint !== n &&
- (minSlack < Solver.ZERO_UPPERBOUND && !v.active || v.equality)) {
- l[deletePoint] = l[n - 1];
- l.length = n - 1;
- }
- return v;
- };
- Solver.prototype.satisfy = function () {
- if (this.bs == null) {
- this.bs = new Blocks(this.vs);
- }
- this.bs.split(this.inactive);
- var v = null;
- while ((v = this.mostViolated()) && (v.equality || v.slack() < Solver.ZERO_UPPERBOUND && !v.active)) {
- var lb = v.left.block, rb = v.right.block;
- if (lb !== rb) {
- this.bs.merge(v);
- }
- else {
- if (lb.isActiveDirectedPathBetween(v.right, v.left)) {
- v.unsatisfiable = true;
- continue;
- }
- var split = lb.splitBetween(v.left, v.right);
- if (split !== null) {
- this.bs.insert(split.lb);
- this.bs.insert(split.rb);
- this.bs.remove(lb);
- this.inactive.push(split.constraint);
- }
- else {
- v.unsatisfiable = true;
- continue;
- }
- if (v.slack() >= 0) {
- this.inactive.push(v);
- }
- else {
- this.bs.merge(v);
- }
- }
- }
- };
- Solver.prototype.solve = function () {
- this.satisfy();
- var lastcost = Number.MAX_VALUE, cost = this.bs.cost();
- while (Math.abs(lastcost - cost) > 0.0001) {
- this.satisfy();
- lastcost = cost;
- cost = this.bs.cost();
- }
- return cost;
- };
- return Solver;
-}());
-Solver.LAGRANGIAN_TOLERANCE = -1e-4;
-Solver.ZERO_UPPERBOUND = -1e-10;
-exports.Solver = Solver;
-function removeOverlapInOneDimension(spans, lowerBound, upperBound) {
- var vs = spans.map(function (s) { return new Variable(s.desiredCenter); });
- var cs = [];
- var n = spans.length;
- for (var i = 0; i < n - 1; i++) {
- var left = spans[i], right = spans[i + 1];
- cs.push(new Constraint(vs[i], vs[i + 1], (left.size + right.size) / 2));
- }
- var leftMost = vs[0], rightMost = vs[n - 1], leftMostSize = spans[0].size / 2, rightMostSize = spans[n - 1].size / 2;
- var vLower = null, vUpper = null;
- if (lowerBound) {
- vLower = new Variable(lowerBound, leftMost.weight * 1000);
- vs.push(vLower);
- cs.push(new Constraint(vLower, leftMost, leftMostSize));
- }
- if (upperBound) {
- vUpper = new Variable(upperBound, rightMost.weight * 1000);
- vs.push(vUpper);
- cs.push(new Constraint(rightMost, vUpper, rightMostSize));
- }
- var solver = new Solver(vs, cs);
- solver.solve();
- return {
- newCenters: vs.slice(0, spans.length).map(function (v) { return v.position(); }),
- lowerBound: vLower ? vLower.position() : leftMost.position() - leftMostSize,
- upperBound: vUpper ? vUpper.position() : rightMost.position() + rightMostSize
- };
-}
-exports.removeOverlapInOneDimension = removeOverlapInOneDimension;
-
-},{}]},{},[1])(1)
-});
\ No newline at end of file
diff --git a/salsah1/public/js/cytoscape-cola.js b/salsah1/public/js/cytoscape-cola.js
deleted file mode 100644
index 2f70e367b1..0000000000
--- a/salsah1/public/js/cytoscape-cola.js
+++ /dev/null
@@ -1,546 +0,0 @@
-/*!
-Copyright (c) The Cytoscape Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the “Software”), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-;(function(){ 'use strict';
-
- // registers the extension on a cytoscape lib ref
- var register = function( cytoscape, cola ){
- if( !cytoscape || !cola ){ return; } // can't register if cytoscape unspecified
-
- var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame;
- var isString = function(o){ return typeof o === typeof ''; };
- var isNumber = function(o){ return typeof o === typeof 0; };
- var isObject = function(o){ return o != null && typeof o === typeof {}; };
-
- // default layout options
- var defaults = {
- animate: true, // whether to show the layout as it's running
- refresh: 1, // number of ticks per frame; higher is faster but more jerky
- maxSimulationTime: 4000, // max length in ms to run the layout
- ungrabifyWhileSimulating: false, // so you can't drag nodes during layout
- fit: true, // on every layout reposition of nodes, fit the viewport
- padding: 30, // padding around the simulation
- boundingBox: undefined, // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
-
- // layout event callbacks
- ready: function(){}, // on layoutready
- stop: function(){}, // on layoutstop
-
- // positioning options
- randomize: false, // use random node positions at beginning of layout
- avoidOverlap: true, // if true, prevents overlap of node bounding boxes
- handleDisconnected: true, // if true, avoids disconnected components from overlapping
- nodeSpacing: function( node ){ return 10; }, // extra spacing around nodes
- flow: undefined, // use DAG/tree flow layout if specified, e.g. { axis: 'y', minSeparation: 30 }
- alignment: undefined, // relative alignment constraints on nodes, e.g. function( node ){ return { x: 0, y: 1 } }
-
- // different methods of specifying edge length
- // each can be a constant numerical value or a function like `function( edge ){ return 2; }`
- edgeLength: undefined, // sets edge length directly in simulation
- edgeSymDiffLength: undefined, // symmetric diff edge length in simulation
- edgeJaccardLength: undefined, // jaccard edge length in simulation
-
- // iterations of cola algorithm; uses default values on undefined
- unconstrIter: undefined, // unconstrained initial layout iterations
- userConstIter: undefined, // initial layout iterations with user-specified constraints
- allConstIter: undefined, // initial layout iterations with all constraints including non-overlap
-
- // infinite layout options
- infinite: false // overrides all other options for a forces-all-the-time mode
- };
-
- // constructor
- // options : object containing layout options
- function ColaLayout( options ){
- var opts = this.options = {};
- for( var i in defaults ){ opts[i] = defaults[i]; }
- for( var i in options ){ opts[i] = options[i]; }
- }
-
- // runs the layout
- ColaLayout.prototype.run = function(){
- var layout = this;
- var options = this.options;
-
- layout.manuallyStopped = false;
-
- var cy = options.cy; // cy is automatically populated for us in the constructor
- var eles = options.eles;
- var nodes = eles.nodes();
- var edges = eles.edges();
- var ready = false;
-
- var bb = options.boundingBox || { x1: 0, y1: 0, w: cy.width(), h: cy.height() };
- if( bb.x2 === undefined ){ bb.x2 = bb.x1 + bb.w; }
- if( bb.w === undefined ){ bb.w = bb.x2 - bb.x1; }
- if( bb.y2 === undefined ){ bb.y2 = bb.y1 + bb.h; }
- if( bb.h === undefined ){ bb.h = bb.y2 - bb.y1; }
-
- var typeoffn = typeof function(){};
- var getOptVal = function( val, ele ){
- if( typeof val === typeoffn ){
- var fn = val;
- return fn.apply( ele, [ ele ] );
- } else {
- return val;
- }
- };
-
- var updateNodePositions = function(){
- for( var i = 0; i < nodes.length; i++ ){
- var node = nodes[i];
- var scratch = node.scratch('cola');
-
- // update node dims
- if( !scratch.updatedDims ){
- var padding = getOptVal( options.nodeSpacing, node );
-
- scratch.width = node.outerWidth() + 2*padding;
- scratch.height = node.outerHeight() + 2*padding;
- }
- }
-
- nodes.positions(function(i, node){
- var scratch = node.scratch().cola;
- var retPos;
-
- if( !node.grabbed() && !node.isParent() ){
- retPos = {
- x: bb.x1 + scratch.x,
- y: bb.y1 + scratch.y
- };
-
- if( !isNumber(retPos.x) || !isNumber(retPos.y) ){
- retPos = undefined;
- }
- }
-
- return retPos;
- });
-
- nodes.updateCompoundBounds(); // because the way this layout sets positions is buggy for some reason; ref #878
-
- if( !ready ){
- onReady();
- ready = true;
- }
-
- if( options.fit ){
- cy.fit( options.padding );
- }
- };
-
- var onDone = function(){
- if( options.ungrabifyWhileSimulating ){
- grabbableNodes.grabify();
- }
-
- cy.off('destroy', destroyHandler);
-
- nodes.off('grab free position', grabHandler);
- nodes.off('lock unlock', lockHandler);
-
- // trigger layoutstop when the layout stops (e.g. finishes)
- layout.one('layoutstop', options.stop);
- layout.trigger({ type: 'layoutstop', layout: layout });
- };
-
- var onReady = function(){
- // trigger layoutready when each node has had its position set at least once
- layout.one('layoutready', options.ready);
- layout.trigger({ type: 'layoutready', layout: layout });
- };
-
- var ticksPerFrame = options.refresh;
- var tickSkip = 1; // frames until a tick; used to slow down sim for debugging
-
- if( options.refresh < 0 ){
- tickSkip = Math.abs( options.refresh );
- ticksPerFrame = 1;
- } else {
- ticksPerFrame = Math.max( 1, ticksPerFrame ); // at least 1
- }
-
- var adaptor = layout.adaptor = cola.adaptor({
- trigger: function( e ){ // on sim event
- var TICK = cola.EventType ? cola.EventType.tick : null;
- var END = cola.EventType ? cola.EventType.end : null;
-
- switch( e.type ){
- case 'tick':
- case TICK:
- if( options.animate ){
- updateNodePositions();
- }
- break;
-
- case 'end':
- case END:
- updateNodePositions();
- if( !options.infinite ){ onDone(); }
- break;
- }
- },
-
- kick: function(){ // kick off the simulation
- //var skip = 0;
-
- var inftick = function(){
- if( layout.manuallyStopped ){
- onDone();
-
- return true;
- }
-
- var ret = adaptor.tick();
-
- if( ret && options.infinite ){ // resume layout if done
- adaptor.resume(); // resume => new kick
- }
-
- return ret; // allow regular finish b/c of new kick
- };
-
- var multitick = function(){ // multiple ticks in a row
- var ret;
-
- // skip ticks to slow down layout for debugging
- // var thisSkip = skip;
- // skip = (skip + 1) % tickSkip;
- // if( thisSkip !== 0 ){
- // return false;
- // }
-
- for( var i = 0; i < ticksPerFrame && !ret; i++ ){
- ret = ret || inftick(); // pick up true ret vals => sim done
- }
-
- return ret;
- };
-
- if( options.animate ){
- var frame = function(){
- if( multitick() ){ return; }
-
- raf( frame );
- };
-
- raf( frame );
- } else {
- while( !inftick() ){}
- }
- },
-
- on: function( type, listener ){}, // dummy; not needed
-
- drag: function(){} // not needed for our case
- });
- layout.adaptor = adaptor;
-
- // if set no grabbing during layout
- var grabbableNodes = nodes.filter(':grabbable');
- if( options.ungrabifyWhileSimulating ){
- grabbableNodes.ungrabify();
- }
-
- var destroyHandler;
- cy.one('destroy', destroyHandler = function(e){
- layout.stop();
- });
-
- // handle node dragging
- var grabHandler;
- nodes.on('grab free position', grabHandler = function(e){
- var node = this;
- var scrCola = node.scratch().cola;
- var pos = node.position();
-
- switch( e.type ){
- case 'grab':
- adaptor.dragstart( scrCola );
- adaptor.resume();
- break;
- case 'free':
- adaptor.dragend( scrCola );
- break;
- case 'position':
- // only update when different (i.e. manual .position() call or drag) so we don't loop needlessly
- if( scrCola.x !== pos.x - bb.x1 || scrCola.y !== pos.y - bb.y1 ){
- scrCola.px = pos.x - bb.x1;
- scrCola.py = pos.y - bb.y1;
- adaptor.resume();
- }
- break;
- }
-
- });
-
- var lockHandler;
- nodes.on('lock unlock', lockHandler = function(e){
- var node = this;
- var scrCola = node.scratch().cola;
-
- scrCola.fixed = node.locked();
-
- if( node.locked() ){
- adaptor.dragstart( scrCola );
- } else {
- adaptor.dragend( scrCola );
- }
- });
-
- var nonparentNodes = nodes.stdFilter(function( node ){
- return !node.isParent();
- });
-
- // add nodes to cola
- adaptor.nodes( nonparentNodes.map(function( node, i ){
- var padding = getOptVal( options.nodeSpacing, node );
- var pos = node.position();
- var nbb = node.boundingBox();
-
- var struct = node.scratch().cola = {
- x: options.randomize || pos.x === undefined ? Math.round( Math.random() * bb.w ) : pos.x,
- y: options.randomize || pos.y === undefined ? Math.round( Math.random() * bb.h ) : pos.y,
- width: nbb.w + 2*padding,
- height: nbb.h + 2*padding,
- index: i,
- fixed: node.locked()
- };
-
- return struct;
- }) );
-
- if( options.alignment ){ // then set alignment constraints
-
- var offsetsX = [];
- var offsetsY = [];
-
- nonparentNodes.forEach(function( node ){
- var align = getOptVal( options.alignment, node );
- var scrCola = node.scratch().cola;
- var index = scrCola.index;
-
- if( !align ){ return; }
-
- if( align.x != null ){
- offsetsX.push({
- node: index,
- offset: align.x
- });
- }
-
- if( align.y != null ){
- offsetsY.push({
- node: index,
- offset: align.y
- });
- }
- });
-
- // add alignment constraints on nodes
- var constraints = [];
-
- if( offsetsX.length > 0 ){
- constraints.push({
- type: 'alignment',
- axis: 'x',
- offsets: offsetsX
- });
- }
-
- if( offsetsY.length > 0 ){
- constraints.push({
- type: 'alignment',
- axis: 'y',
- offsets: offsetsY
- });
- }
-
- adaptor.constraints( constraints );
-
- }
-
- // add compound nodes to cola
- adaptor.groups( nodes.stdFilter(function( node ){
- return node.isParent();
- }).map(function( node, i ){ // add basic group incl leaf nodes
- var optPadding = getOptVal( options.nodeSpacing, node );
- var getPadding = function(d){
- return parseFloat( node.style('padding-'+d) );
- };
-
- var pleft = getPadding('left') + optPadding;
- var pright = getPadding('right') + optPadding;
- var ptop = getPadding('top') + optPadding;
- var pbottom = getPadding('bottom') + optPadding;
-
- node.scratch().cola = {
- index: i,
-
- padding: Math.max( pleft, pright, ptop, pbottom ),
-
- // leaves should only contain direct descendants (children),
- // not the leaves of nested compound nodes or any nodes that are compounds themselves
- leaves: node.children().stdFilter(function( child ){
- return !child.isParent();
- }).map(function( child ){
- return child[0].scratch().cola.index;
- }),
-
- fixed: node.locked()
- };
-
- return node;
- }).map(function( node ){ // add subgroups
- node.scratch().cola.groups = node.children().stdFilter(function( child ){
- return child.isParent();
- }).map(function( child ){
- return child.scratch().cola.index;
- });
-
- return node.scratch().cola;
- }) );
-
- // get the edge length setting mechanism
- var length;
- var lengthFnName;
- if( options.edgeLength != null ){
- length = options.edgeLength;
- lengthFnName = 'linkDistance';
- } else if( options.edgeSymDiffLength != null ){
- length = options.edgeSymDiffLength;
- lengthFnName = 'symmetricDiffLinkLengths';
- } else if( options.edgeJaccardLength != null ){
- length = options.edgeJaccardLength;
- lengthFnName = 'jaccardLinkLengths';
- } else {
- length = 100;
- lengthFnName = 'linkDistance';
- }
-
- var lengthGetter = function( link ){
- return link.calcLength;
- };
-
- // add the edges to cola
- adaptor.links( edges.stdFilter(function( edge ){
- return !edge.source().isParent() && !edge.target().isParent();
- }).map(function( edge, i ){
- var c = edge.scratch().cola = {
- source: edge.source()[0].scratch().cola.index,
- target: edge.target()[0].scratch().cola.index
- };
-
- if( length != null ){
- c.calcLength = getOptVal( length, edge );
- }
-
- return c;
- }) );
-
- adaptor.size([ bb.w, bb.h ]);
-
- if( length != null ){
- adaptor[ lengthFnName ]( lengthGetter );
- }
-
- // set the flow of cola
- if( options.flow ){
- var flow;
- var defAxis = 'y';
- var defMinSep = 50;
-
- if( isString(options.flow) ){
- flow = {
- axis: options.flow,
- minSeparation: defMinSep
- };
- } else if( isNumber(options.flow) ){
- flow = {
- axis: defAxis,
- minSeparation: options.flow
- };
- } else if( isObject(options.flow) ){
- flow = options.flow;
-
- flow.axis = flow.axis || defAxis;
- flow.minSeparation = flow.minSeparation != null ? flow.minSeparation : defMinSep;
- } else { // e.g. options.flow: true
- flow = {
- axis: defAxis,
- minSeparation: defMinSep
- };
- }
-
- adaptor.flowLayout( flow.axis , flow.minSeparation );
- }
-
- layout.trigger({ type: 'layoutstart', layout: layout });
-
- adaptor
- .avoidOverlaps( options.avoidOverlap )
- .handleDisconnected( options.handleDisconnected )
- .start( options.unconstrIter, options.userConstIter, options.allConstIter)
- ;
-
- if( !options.infinite ){
- setTimeout(function(){
- if( !layout.manuallyStopped ){
- adaptor.stop();
- }
- }, options.maxSimulationTime);
- }
-
- return this; // chaining
- };
-
- // called on continuous layouts to stop them before they finish
- ColaLayout.prototype.stop = function(){
- if( this.adaptor ){
- this.manuallyStopped = true;
- this.adaptor.stop();
- }
-
- return this; // chaining
- };
-
-
- cytoscape('layout', 'cola', ColaLayout);
-
- };
-
- if( typeof module !== 'undefined' && module.exports ){ // expose as a commonjs module
- module.exports = register;
- }
-
- if( typeof define !== 'undefined' && define.amd ){ // expose as an amd/requirejs module
- define('cytoscape-cola', function(){
- return register;
- });
- }
-
- if( typeof cytoscape !== 'undefined' && typeof cola !== 'undefined' ){ // expose to global cytoscape (i.e. window.cytoscape)
- register( cytoscape, cola );
- }
-
-})();
diff --git a/salsah1/public/js/cytoscape.min.js b/salsah1/public/js/cytoscape.min.js
deleted file mode 100644
index fe0d5a2d9d..0000000000
--- a/salsah1/public/js/cytoscape.min.js
+++ /dev/null
@@ -1,63 +0,0 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.cytoscape=e()}}(function(){var define,module,exports;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oa&&(n=a,r=i)}return r}},a=this._private.cy;if(null!=e&&null!=e.root){var o=n.string(e.root)?this.filter(e.root)[0]:e.root[0];if(null!=e.goal){var s=n.string(e.goal)?this.filter(e.goal)[0]:e.goal[0];if(null!=e.heuristic&&n.fn(e.heuristic))var l=e.heuristic;else var l=function(){return 0};if(null!=e.weight&&n.fn(e.weight))var u=e.weight;else var u=function(e){return 1};if(null!=e.directed)var c=e.directed;else var c=!1;var d=[],h=[o.id()],p={},f={},v={},g={};v[o.id()]=0,g[o.id()]=l(o);for(var y=this.edges().stdFilter(function(e){return!e.isLoop()}),m=this.nodes(),b=0;h.length>0;){var x=i(h,g),w=a.getElementById(h[x]);if(b++,w.id()==s.id()){var E=r(o.id(),s.id(),p,[]);return E.reverse(),{found:!0,distance:v[w.id()],path:t.spawn(E),steps:b}}d.push(w.id()),h.splice(x,1);var _=w.connectedEdges();c&&(_=_.stdFilter(function(e){return e.data("source")===w.id()})),_=_.intersect(y);for(var P=0;P<_.length;P++){var S=_[P],k=S.connectedNodes().stdFilter(function(e){return e.id()!==w.id()}).intersect(m);if(-1==d.indexOf(k.id())){var T=v[w.id()]+u.apply(S,[S]);-1!=h.indexOf(k.id())?Th;h++)d[u[h].id()]=h;for(var p=[],f=[],v=[],h=0;c>h;h++)u[h].id()===o.id()?p[h]=0:p[h]=1/0,f[h]=void 0;for(var g=!1,h=1;c>h;h++){g=!1;for(var y=0;yh;h++)E.push(u[h].id());var _={distanceTo:function(e){if(n.string(e))var t=s.filter(e)[0].id();else var t=e.id();return p[d[t]]},pathTo:function(e){var r=function(e,t,r,n,i,a){for(;;){if(i.push(s.getElementById(n[r])),i.push(a[r]),t===r)return i;var o=e[r];if("undefined"==typeof o)return;r=o}};if(n.string(e))var i=s.filter(e)[0].id();else var i=e.id();var a=[],l=r(f,d[o.id()],d[i],E,a,v);return null!=l&&l.reverse(),t.spawn(l)},hasNegativeWeightCycle:!1};return _}}};t.exports=a},{"../../is":83,"../../util":100}],5:[function(e,t,r){"use strict";var n=e("../../is"),i=e("../../heap"),a={betweennessCentrality:function(e){e=e||{};var t,r;n.fn(e.weight)?(r=e.weight,t=!0):t=!1;for(var a,o=null!=e.directed?e.directed:!1,s=this._private.cy,l=this.nodes(),u={},c={},d={set:function(e,t){c[e]=t,t>a&&(a=t)},get:function(e){return c[e]}},h=0;h0?S.edgesTo(P)[0]:P.edgesTo(S)[0];var k=r.apply(_,[_]);P=P.id(),x[P]>x[p]+k&&(x[P]=x[p]+k,w.nodes.indexOf(P)<0?w.push(P):w.updateItem(P),b[P]=0,m[P]=[]),x[P]==x[p]+k&&(b[P]=b[P]+b[p],m[P].push(p))}else for(var E=0;E0;)for(var P=y.pop(),E=0;Ea&&(a=u),i[o[l].id()]=u}return{closeness:function(e){if(n.string(e))var e=t.filter(e)[0].id();else var e=e.id();return i[e]/a}}},closenessCentrality:function(e){if(e=e||{},null!=e.root){if(n.string(e.root))var t=this.filter(e.root)[0];else var t=e.root[0];if(null!=e.weight&&n.fn(e.weight))var r=e.weight;else var r=function(){return 1};if(null!=e.directed&&n.bool(e.directed))var i=e.directed;else var i=!1;var a=e.harmonic;void 0===a&&(a=!0);for(var o=this.dijkstra({root:t,weight:r,directed:i}),s=0,l=this.nodes(),u=0;ud;d++){var h=a[d],p=this.degreeCentrality(i.extend({},e,{root:h}));ud;d++){var h=a[d],p=this.degreeCentrality(i.extend({},e,{root:h}));vu||!i)&&(o=u,i=l)}return{edge:i,dist:o}};v.size()>0;){var b=v.pop(),x=p(b),w=b.id();if(c[w]=x,x===Math.Infinite)break;for(var E=b.neighborhood().intersect(h),g=0;g0)for(r.unshift(t);u[i.id()];){var a=u[i.id()];r.unshift(a.edge),r.unshift(a.node),i=a.node}return o.collection(r)}}}};t.exports=a},{"../../heap":81,"../../is":83}],10:[function(e,t,r){"use strict";var n=e("../../is"),i={floydWarshall:function(e){e=e||{};var t=this.cy();if(null!=e.weight&&n.fn(e.weight))var r=e.weight;else var r=function(e){return 1};if(null!=e.directed)var i=e.directed;else var i=!1;for(var a=this.edges().stdFilter(function(e){return!e.isLoop()}),o=this.nodes(),s=o.length,l={},u=0;s>u;u++)l[o[u].id()]=u;for(var c=[],u=0;s>u;u++){for(var d=new Array(s),h=0;s>h;h++)u==h?d[h]=0:d[h]=1/0;c.push(d)}var p=[],f=[],v=function(e){for(var t=0;s>t;t++){for(var r=new Array(s),n=0;s>n;n++)r[n]=void 0;e.push(r)}};v(p),v(f);for(var u=0;um&&(c[g][y]=m,p[g][y]=y,f[g][y]=a[u])}if(!i)for(var u=0;um&&(c[g][y]=m,p[g][y]=y,f[g][y]=a[u])}for(var b=0;s>b;b++)for(var u=0;s>u;u++)for(var h=0;s>h;h++)c[u][b]+c[b][h]u;u++)x.push(o[u].id());var w={distance:function(e,r){if(n.string(e))var i=t.filter(e)[0].id();else var i=e.id();if(n.string(r))var a=t.filter(r)[0].id();else var a=r.id();return c[l[i]][l[a]]},path:function(e,r){var i=function(e,r,n,i,a){if(e===r)return t.getElementById(i[e]);if(void 0!==n[e][r]){for(var o=[t.getElementById(i[e])],s=e;e!==r;){s=e,e=n[e][r];var l=a[s][e];o.push(l),o.push(t.getElementById(i[e]))}return o}};if(n.string(e))var a=t.filter(e)[0].id();else var a=e.id();if(n.string(r))var o=t.filter(r)[0].id();else var o=r.id();var s=i(l[a],l[o],p,x,f);return t.collection(s)}};return w}};t.exports=i},{"../../is":83}],11:[function(e,t,r){"use strict";var n=e("../../util"),i={};[e("./bfs-dfs"),e("./dijkstra"),e("./kruskal"),e("./a-star"),e("./floyd-warshall"),e("./bellman-ford"),e("./kerger-stein"),e("./page-rank"),e("./degree-centrality"),e("./closeness-centrality"),e("./betweenness-centrality")].forEach(function(e){n.extend(i,e)}),t.exports=i},{"../../util":100,"./a-star":3,"./bellman-ford":4,"./betweenness-centrality":5,"./bfs-dfs":6,"./closeness-centrality":7,"./degree-centrality":8,"./dijkstra":9,"./floyd-warshall":10,"./kerger-stein":12,"./kruskal":13,"./page-rank":14}],12:[function(e,t,r){"use strict";var n=e("../../util"),i={kargerStein:function(e){var t=this;e=e||{};var r=function(e,t,r){for(var n=r[e],i=n[1],a=n[2],o=t[i],s=t[a],l=r.filter(function(e){return t[e[1]]===o&&t[e[2]]===s?!1:t[e[1]]!==s||t[e[2]]!==o}),u=0;u=n)return t;var o=Math.floor(Math.random()*t.length),s=r(o,e,t);return i(e,s,n-1,a)},a=this._private.cy,o=this.edges().stdFilter(function(e){return!e.isLoop()}),s=this.nodes(),l=s.length,u=o.length,c=Math.ceil(Math.pow(Math.log(l)/Math.LN2,2)),d=Math.floor(l/Math.sqrt(2));if(2>l)return void n.error("At least 2 nodes are required for Karger-Stein algorithm");for(var h={},p=0;l>p;p++)h[s[p].id()]=p;for(var f=[],p=0;u>p;p++){var v=o[p];f.push([p,h[v.source().id()],h[v.target().id()]])}for(var g,y=1/0,m=[],p=0;l>p;p++)m.push(p);for(var b=0;c>=b;b++){var x=m.slice(0),w=i(x,f,l,d),E=x.slice(0),_=i(x,w,d,2),P=i(E,w,d,2);_.length<=P.length&&_.lengthn;n++)r+=e[n];for(var n=0;t>n;n++)e[n]=e[n]/r};if(null!=e&&null!=e.dampingFactor)var r=e.dampingFactor;else var r=.8;if(null!=e&&null!=e.precision)var i=e.precision;else var i=1e-6;if(null!=e&&null!=e.iterations)var a=e.iterations;else var a=200;if(null!=e&&null!=e.weight&&n.fn(e.weight))var o=e.weight;else var o=function(e){return 1};for(var s=this._private.cy,l=this.edges().stdFilter(function(e){return!e.isLoop()}),u=this.nodes(),c=u.length,d=l.length,h={},p=0;c>p;p++)h[u[p].id()]=p;for(var f=[],v=[],g=(1-r)/c,p=0;c>p;p++){for(var y=[],m=0;c>m;m++)y.push(0);f.push(y),v.push(0)}for(var p=0;d>p;p++){var b=l[p],x=h[b.source().id()],w=h[b.target().id()],E=o.apply(b,[b]);f[w][x]+=E,v[x]+=E}for(var _=1/c+g,m=0;c>m;m++)if(0===v[m])for(var p=0;c>p;p++)f[p][m]=_;else for(var p=0;c>p;p++)f[p][m]=f[p][m]/v[m]+g;for(var P,S=[],k=[],p=0;c>p;p++)S.push(1),k.push(0);for(var T=0;a>T;T++){for(var D=k.slice(0),p=0;c>p;p++)for(var m=0;c>m;m++)D[p]+=f[p][m]*S[m];t(D),P=S,S=D;for(var C=0,p=0;c>p;p++)C+=Math.pow(P[p]-S[p],2);if(i>C)break}var M={rank:function(e){if(n.string(e))var t=s.filter(e)[0].id();else var t=e.id();return S[h[t]]}};return M}};t.exports=i},{"../../is":83}],15:[function(e,t,r){"use strict";var n=e("../define"),i={animate:n.animate(),animation:n.animation(),animated:n.animated(),clearQueue:n.clearQueue(),delay:n.delay(),delayAnimation:n.delayAnimation(),stop:n.stop()};t.exports=i},{"../define":44}],16:[function(e,t,r){"use strict";var n=e("../util"),i={classes:function(e){e=e.match(/\S+/g)||[];for(var t=this,r=[],i={},a=0;a0&&this.spawn(r).updateStyle().trigger("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return!(null==t||!t._private.classes[e])},toggleClass:function(e,t){for(var r=e.match(/\S+/g)||[],n=this,i=[],a=0,o=n.length;o>a;a++)for(var s=n[a],l=!1,u=0;u0&&this.spawn(i).updateStyle().trigger("class"),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var r=this;if(null==t)t=250;else if(0===t)return r;return r.addClass(e),setTimeout(function(){r.removeClass(e)},t),r}};t.exports=i},{"../util":100}],17:[function(e,t,r){"use strict";var n={allAre:function(e){return this.filter(e).length===this.length},is:function(e){return this.filter(e).length>0},some:function(e,t){for(var r=0;r0},allAreNeighbors:function(e){return e=this.cy().collection(e),this.neighborhood().intersect(e).length===e.length}};n.allAreNeighbours=n.allAreNeighbors,t.exports=n},{}],18:[function(e,t,r){"use strict";var n={parent:function(e){for(var t=[],r=this._private.cy,n=0;n0&&t.push(a)}return this.spawn(t,{unique:!0}).filter(e)},parents:function(e){for(var t=[],r=this.parent();r.nonempty();){for(var n=0;ne}),maxDegree:i("degree",function(e,t){return e>t}),minIndegree:i("indegree",function(e,t){return t>e}),maxIndegree:i("indegree",function(e,t){return e>t}),minOutdegree:i("outdegree",function(e,t){return t>e}),maxOutdegree:i("outdegree",function(e,t){return e>t})}),a.extend(o,{totalDegree:function(e){for(var t=0,r=this.nodes(),n=0;n0?this.add(s):this;t?l.trigger("position"):l.rtrigger("position")}return this},silentPositions:function(e){return this.positions(e,!0)},renderedPosition:function(e,t){var r=this[0],n=this.cy(),i=n.zoom(),a=n.pan(),s=o.plainObject(e)?e:void 0,l=void 0!==s||void 0!==t&&o.string(e);if(r&&r.isNode()){if(!l){var u=r._private.position;return s={x:u.x*i+a.x,y:u.y*i+a.y},void 0===e?s:s[e]}for(var c=0;c0,d=c;c&&(u=u[0]);var h=d?u._private.position:{x:0,y:0};return i={x:l.x-h.x,y:l.y-h.y},void 0===e?i:i[e]}for(var p=0;p0,d=c;c&&(u=u[0]);var h=d?u._private.position:{x:0,y:0};void 0!==t?r._private.position[e]=t+h[e]:void 0!==i&&(r._private.position={x:i.x+h.x,y:i.y+h.y})}this.rtrigger("position")}else if(!a)return;return this},renderedBoundingBox:function(e){var t=this.boundingBox(e),r=this.cy(),n=r.zoom(),i=r.pan(),a=t.x1*n+i.x,o=t.x2*n+i.x,s=t.y1*n+i.y,l=t.y2*n+i.y;return{x1:a,x2:o,y1:s,y2:l,w:o-a,h:l-s}},updateCompoundBounds:function(){function e(e){if(e.isParent()){var t=e._private,n=e.children(),i="include"===e.pstyle("compound-sizing-wrt-labels").value,a=n.boundingBox({includeLabels:i,includeShadows:!1,includeOverlays:!1,useCache:!1}),o={top:e.pstyle("padding-top").pfValue,bottom:e.pstyle("padding-bottom").pfValue,left:e.pstyle("padding-left").pfValue,right:e.pstyle("padding-right").pfValue},s=t.position;t.autoWidth=a.w,s.x=(a.x1+a.x2-o.left+o.right)/2,t.autoHeight=a.h,s.y=(a.y1+a.y2-o.top+o.bottom)/2,r.push(e)}}var t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes())return t.collection();for(var r=[],n=this;n.nonempty();){for(var i=0;ie.x2?n:e.x2,e.y1=re.y2?i:e.y2)},d=function(e,t){return c(e,t.x1,t.y1,t.x2,t.y2)},h=function(e,t,r){return s.getPrefixedProperty(e,t,r)},p=function(e,t,r,n){var i,a,o=t._private,s=o.rstyle,l=s.arrowWidth/2,u=t.pstyle(r+"-arrow-shape").value;"none"!==u&&("source"===r?(i=s.srcX,a=s.srcY):"target"===r?(i=s.tgtX,a=s.tgtY):(i=s.midX,a=s.midY),c(e,i-l,a-l,i+l,a+l))},f=function(e,t,r,n){var i;i=r?r+"-":"";var a=t._private,o=a.rstyle,s=t.pstyle(i+"label").strValue;if(s){var l,u,d,p,f=t.pstyle("text-halign"),v=t.pstyle("text-valign"),g=h(o,"labelWidth",r),y=h(o,"labelHeight",r),m=h(o,"labelX",r),b=h(o,"labelY",r),x=t.pstyle(i+"text-margin-x").pfValue,w=t.pstyle(i+"text-margin-y").pfValue,E=t.isEdge(),_=t.pstyle(i+"text-rotation"),P=t.pstyle("text-shadow-blur").pfValue/2,S=t.pstyle("text-shadow-offset-x").pfValue,k=t.pstyle("text-shadow-offset-y").pfValue,T=t.pstyle("text-shadow-opacity").value,D=t.pstyle("text-outline-width").pfValue,C=t.pstyle("text-border-width").pfValue,M=C/2,N=y,B=g,z=B/2,I=N/2;if(E)l=m-z,u=m+z,d=b-I,p=b+I;else{switch(f.value){case"left":l=m-B,u=m;break;case"center":l=m-z,u=m+z;break;case"right":l=m,u=m+B}switch(v.value){case"top":d=b-N,p=b;break;case"center":d=b-I,p=b+I;break;case"bottom":d=b,p=b+N}}var L=E&&"autorotate"===_.strValue,O=null!=_.pfValue&&0!==_.pfValue;if(L||O){var A=L?h(a.rstyle,"labelAngle",r):_.pfValue,R=Math.cos(A),q=Math.sin(A),V=function(e,t){return e-=m,t-=b,{x:e*R-t*q+m,y:e*q+t*R+b}},F=V(l,d),j=V(l,p),X=V(u,d),Y=V(u,p);l=Math.min(F.x,j.x,X.x,Y.x),u=Math.max(F.x,j.x,X.x,Y.x),d=Math.min(F.y,j.y,X.y,Y.y),p=Math.max(F.y,j.y,X.y,Y.y)}l+=x-Math.max(D,M),u+=x+Math.max(D,M),d+=w-Math.max(D,M),p+=w+Math.max(D,M),c(e,l,d,u,p),n.includeShadows&&T>0&&(l+=-P+S,u+=+P+S,d+=-P+k,p+=+P+k,c(e,l,d,u,p))}return e},v=function(e,t){var r,n,i,a,o,s,d=e._private.cy,h=d._private,v=h.styleEnabled,g={x1:1/0,y1:1/0,x2:-(1/0),y2:-(1/0)},y=e._private,m=v?e.pstyle("display").value:"element",b=e.isNode(),x=e.isEdge(),w="none"!==m;if(w){var E=0,_=0;v&&t.includeOverlays&&(E=e.pstyle("overlay-opacity").value,0!==E&&(_=e.pstyle("overlay-padding").value));var P=0,S=0;if(v&&(P=e.pstyle("width").pfValue,S=P/2),b&&t.includeNodes){var k=y.position;o=k.x,s=k.y;var P=e.outerWidth(),T=P/2,D=e.outerHeight(),C=D/2;r=o-T-_,n=o+T+_,i=s-C-_,a=s+C+_,c(g,r,i,n,a)}else if(x&&t.includeEdges){var M=y.rstyle||{};if(v&&(r=Math.min(M.srcX,M.midX,M.tgtX),n=Math.max(M.srcX,M.midX,M.tgtX),i=Math.min(M.srcY,M.midY,M.tgtY),a=Math.max(M.srcY,M.midY,M.tgtY),r-=S,n+=S,i-=S,a+=S,c(g,r,i,n,a)),v&&"haystack"===e.pstyle("curve-style").strValue){var N=M.haystackPts;if(r=N[0].x,i=N[0].y,n=N[1].x,a=N[1].y,r>n){var B=r;r=n,n=B}if(i>a){var B=i;i=a,a=B}c(g,r-S,i-S,n+S,a+S)}else{for(var z=M.bezierPts||M.linePts||[],I=0;In){var B=r;r=n,n=B}if(i>a){var B=i;i=a,a=B}r-=S,n+=S,i-=S,a+=S,c(g,r,i,n,a)}}}if(v){if(r=g.x1,n=g.x2,i=g.y1,a=g.y2,t.includeShadows&&e.pstyle("shadow-opacity").value>0){var j=e.pstyle("shadow-blur").pfValue/2,X=e.pstyle("shadow-offset-x").pfValue,Y=e.pstyle("shadow-offset-y").pfValue;c(g,r-j+X,i-j+Y,n+j+X,a+j+Y)}c(g,r-_,i-_,n+_,a+_)}v&&t.includeEdges&&x&&(p(g,e,"mid-source",t),p(g,e,"mid-target",t),p(g,e,"source",t),p(g,e,"target",t)),v&&t.includeLabels&&(f(g,e,null,t),x&&(f(g,e,"source",t),f(g,e,"target",t)))}return g.x1=u(g.x1),g.y1=u(g.y1),g.x2=u(g.x2),g.y2=u(g.y2),g.w=u(g.x2-g.x1),g.h=u(g.y2-g.y1),g.w>0&&g.h>0&&w&&l.expandBoundingBox(g,1),g},g=function(e){return e?"t":"f"},y=function(e){var t="";return t+=g(e.incudeNodes),t+=g(e.includeEdges),t+=g(e.includeLabels),t+=g(e.includeShadows),t+=g(e.includeOverlays)},m=function(e,t){var r,n=e._private,i=e.cy().headless(),a=t===b?x:y(t);return t.useCache&&!i&&n.bbCache&&n.bbCache[a]?r=n.bbCache[a]:(r=v(e,t),i||(n.bbCache=n.bbCache||{},n.bbCache[a]=r)),r},b={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeShadows:!0,includeOverlays:!0,useCache:!0},x=y(b);i.recalculateRenderedStyle=function(e){var t=this.cy(),r=t.renderer(),n=t.styleEnabled();return r&&n&&r.recalculateRenderedStyle(this,e),this},i.boundingBox=function(e){if(1===this.length&&this[0]._private.bbCache&&(void 0===e||void 0===e.useCache||e.useCache===!0))return void 0===e&&(e=b),m(this[0],e);var t={x1:1/0,y1:1/0,x2:-(1/0),y2:-(1/0)};e=e||s.staticEmptyObject();var r={includeNodes:s["default"](e.includeNodes,b.includeNodes),includeEdges:s["default"](e.includeEdges,b.includeEdges),includeLabels:s["default"](e.includeLabels,b.includeLabels),includeShadows:s["default"](e.includeShadows,b.includeShadows),
-includeOverlays:s["default"](e.includeOverlays,b.includeOverlays),useCache:s["default"](e.useCache,b.useCache)},n=this,i=n.cy(),a=i.styleEnabled();a&&this.recalculateRenderedStyle(r.useCache);for(var o=0;od;d++){var p=c[d];p&&""!==p&&(a._private.classes[p]=!0)}(t.style||t.css)&&e.style().applyBypass(this,t.style||t.css),(void 0===r||r)&&this.restore()};t.exports=a},{"../is":83,"../util":100}],23:[function(e,t,r){"use strict";var n=e("../define"),i={on:n.on(),one:n.on({unbindSelfOnTrigger:!0}),once:n.on({unbindAllBindersOnTrigger:!0}),off:n.off(),trigger:n.trigger(),rtrigger:function(e,t){return 0!==this.length?(this.cy().notify({type:e,eles:this}),this.trigger(e,t),this):void 0}};n.eventAliasesOn(i),t.exports=i},{"../define":44}],24:[function(e,t,r){"use strict";var n=e("../is"),i=e("../selector"),a={nodes:function(e){return this.filter(function(e,t){return t.isNode()}).filter(e)},edges:function(e){return this.filter(function(e,t){return t.isEdge()}).filter(e)},filter:function(e){if(void 0===e)return this;if(n.string(e)||n.elementOrCollection(e))return i(e).filter(this);if(n.fn(e)){for(var t=[],r=0;r1&&!i){var a=this.length-1,o=this[a],s=o._private.data.id;this[a]=void 0,this[n]=o,t.indexes[s]=n}return this.length--,this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&n.string(e)){var r=e;e=t.mutableElements().filter(r)}for(var i=0;in&&(n=s,r=o)}return{value:n,ele:r}},min:function(e,t){for(var r,n=1/0,i=this,a=0;as&&(n=s,r=o)}return{value:n,ele:r}}},o=a;o.u=o["|"]=o["+"]=o.union=o.or=o.add,o["\\"]=o["!"]=o["-"]=o.difference=o.relativeComplement=o.subtract=o.not,o.n=o["&"]=o["."]=o.and=o.intersection=o.intersect,o["^"]=o["(+)"]=o["(-)"]=o.symmetricDifference=o.symdiff=o.xor,o.fnFilter=o.filterFn=o.stdFilter,o.complement=o.abscomp=o.absoluteComplement,t.exports=a},{"../is":83,"../selector":87}],25:[function(e,t,r){"use strict";var n={isNode:function(){return"nodes"===this.group()},isEdge:function(){return"edges"===this.group()},isLoop:function(){return this.isEdge()&&this.source().id()===this.target().id()},isSimple:function(){return this.isEdge()&&this.source().id()!==this.target().id()},group:function(){var e=this[0];return e?e._private.group:void 0}};t.exports=n},{}],26:[function(e,t,r){"use strict";var n=e("../util"),i=e("../is"),a=e("./element"),o={generate:function(e,t,r){for(var i=null!=r?r:n.uuid();e.hasElementWithId(i);)i=n.uuid();return i}},s=function(e,t,r){if(void 0===e||!i.core(e))return void n.error("A collection must have a reference to the core");var s={},l={},u=!1;if(t){if(t.length>0&&i.plainObject(t[0])&&!i.element(t[0])){u=!0;for(var c=[],d={},h=0,p=t.length;p>h;h++){var f=t[h];null==f.data&&(f.data={});var v=f.data;if(null==v.id)v.id=o.generate(e,f);else if(e.hasElementWithId(v.id)||d[v.id])continue;var g=new a(e,f,!1);c.push(g),d[v.id]=!0}t=c}}else t=[];this.length=0;for(var h=0,p=t.length;p>h;h++){var y=t[h];if(y){var m=y._private.data.id;(!r||r.unique&&!s[m])&&(s[m]=y,l[m]=this.length,this[this.length]=y,this.length++)}}this._private={cy:e,ids:s,indexes:l},u&&this.restore()},l=a.prototype=s.prototype;l.instanceString=function(){return"collection"},l.spawn=function(e,t,r){return i.core(e)||(r=t,t=e,e=this.cy()),new s(e,t,r)},l.spawnSelf=function(){return this.spawn(this)},l.cy=function(){return this._private.cy},l.element=function(){return this[0]},l.collection=function(){return i.collection(this)?this:new s(this._private.cy,[this])},l.unique=function(){return new s(this._private.cy,this,{unique:!0})},l.hasElementWithId=function(e){return!!this._private.ids[e]},l.getElementById=function(e){var t=this._private.cy,r=this._private.ids[e];return r?r:new s(t)},l.poolIndex=function(){var e=this._private.cy,t=e._private.elements,r=this._private.data.id;return t._private.indexes[r]},l.json=function(e){var t=this.element(),r=this.cy();if(null==t&&e)return this;if(null!=t){var a=t._private;if(i.plainObject(e)){r.startBatch(),e.data&&t.data(e.data),e.position&&t.position(e.position);var o=function(r,n,i){var o=e[r];null!=o&&o!==a[r]&&(o?t[n]():t[i]())};return o("removed","remove","restore"),o("selected","select","unselect"),o("selectable","selectify","unselectify"),o("locked","lock","unlock"),o("grabbable","grabify","ungrabify"),null!=e.classes&&t.classes(e.classes),r.endBatch(),this}if(void 0===e){var s={data:n.copy(a.data),position:n.copy(a.position),group:a.group,removed:a.removed,selected:a.selected,selectable:a.selectable,locked:a.locked,grabbable:a.grabbable,classes:null};return s.classes=Object.keys(a.classes).filter(function(e){return a.classes[e]}).join(" "),s}}},l.jsons=function(){for(var e=[],t=0;td;d++){var p=t[d];p.removed()&&(p.isNode()?u.push(p):c.push(p))}l=u.concat(c);var d,f=function(){l.splice(d,1),d--};for(d=0;dP;P++){var S=w[P],k=g[S];i.number(k)&&(k=g[S]=""+g[S]),null==k||""===k?(n.error("Can not create edge `"+y+"` with unspecified "+S),_=!0):r.hasElementWithId(k)||(n.error("Can not create edge `"+y+"` with nonexistant "+S+" `"+k+"`"),_=!0)}if(_){f();continue}var T=r.getElementById(g.source),D=r.getElementById(g.target);T._private.edges.push(x),D._private.edges.push(x),x._private.source=T,x._private.target=D}v.ids={},v.ids[y]=p,v.indexes={},v.indexes[y]=p,v.removed=!1,r.addToPool(p)}for(var d=0;d0){for(var I=new s(r,l),d=0;df;f++){var g=u[f];i(g)}var y=[];y.ids={},p.removeFromPool(d);for(var f=0;f0&&(e&&this.cy().notify({type:"remove",eles:E}),E.trigger("remove"));for(var f=0;fe&&(e=n+e),0>t&&(t=n+t);for(var i=e;i>=0&&t>i&&n>i;i++)r.push(this[i]);return this.spawn(r)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return 0===this.length},nonempty:function(){return!this.empty()},sort:function(e){if(!n.fn(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(i)},zDepth:function(){var e=this[0];if(e){var t=e._private,r=t.group;if("nodes"===r){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:Number.MAX_VALUE}var i=t.source,a=t.target,o=i.zDepth(),s=a.zDepth();return Math.max(o,s,0)}}};t.exports=a},{"../is":83,"./zsort":32}],28:[function(e,t,r){"use strict";var n=e("../is"),i=e("../util"),a=e("../promise"),o={layoutPositions:function(e,t,r){var i=this.nodes(),o=this.cy();if(e.trigger({type:"layoutstart",layout:e}),e.animations=[],t.animate){for(var s=0;s0?this.add(i):this;return e?a.rtrigger("style"):a.trigger("style"),this},updateMappers:function(e){var t=this._private.cy,r=t.style();if(e=!(!e&&void 0!==e),!t.styleEnabled())return this;r.updateMappers(this);var n=this.updateCompoundBounds(),i=n.length>0?this.add(n):this;return e?i.rtrigger("style"):i.trigger("style"),this},parsedStyle:function(e){var t=this[0];if(t.cy().styleEnabled())return t?t._private.style[e]||t.cy().style().getDefaultProperty(e):void 0},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var r=this[0];if(r){var n=r.cy().style().getRenderedStyle(r);return void 0===e?n:n[e]}},style:function(e,t){var r=this.cy();if(!r.styleEnabled())return this;var i=!1,a=r.style();if(n.plainObject(e)){var o=e;a.applyBypass(this,o,i);var s=this.updateCompoundBounds(),l=s.length>0?this.add(s):this;l.rtrigger("style")}else if(n.string(e)){if(void 0===t){var u=this[0];return u?a.getStylePropertyValue(u,e):void 0}a.applyBypass(this,e,t,i);var s=this.updateCompoundBounds(),l=s.length>0?this.add(s):this;l.rtrigger("style")}else if(void 0===e){var u=this[0];return u?a.getRawStyle(u):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var r=!1,n=t.style(),i=this;if(void 0===e)for(var a=0;a0?this.add(s):this;return l.rtrigger("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},visible:function(){var e=this.cy();if(!e.styleEnabled())return!0;var t=this[0],r=e.hasCompoundNodes();if(t){if("visible"!==t.pstyle("visibility").value||"element"!==t.pstyle("display").value||0===t.pstyle("width").pfValue)return!1;if("nodes"===t._private.group){if(0===t.pstyle("height").pfValue)return!1;if(!r)return!0;var n=t._private.data.parent?t.parents():null;if(n)for(var i=0;i0&&t.push(c[0]),t.push(s[0])}return this.spawn(t,{unique:!0}).filter(e)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),l.neighbourhood=l.neighborhood,l.closedNeighbourhood=l.closedNeighborhood,l.openNeighbourhood=l.openNeighborhood,o.extend(l,{source:u(function(e){var t,r=this[0];return r&&(t=r._private.source||r.cy().collection()),t&&e?t.filter(e):t},"source"),target:u(function(e){var t,r=this[0];return r&&(t=r._private.target||r.cy().collection()),t&&e?t.filter(e):t},"target"),sources:n({attr:"source"}),targets:n({attr:"target"})}),o.extend(l,{edgesWith:u(i(),"edgesWith",!0),edgesTo:u(i({thisIsSrc:!0}),"edgesTo",!0)}),o.extend(l,{connectedEdges:u(function(e){for(var t=[],r=this,n=0;n0);return i.map(function(e){var t=e.connectedEdges().stdFilter(function(t){return e.anySame(t.source())&&e.anySame(t.target())});return e.union(t)})}}),t.exports=l},{"../is":83,"../util":100}],32:[function(e,t,r){"use strict";var n=function(e,t){var r=e.cy(),n=e.pstyle("z-index").value-t.pstyle("z-index").value,i=0,a=0,o=r.hasCompoundNodes(),s=e.isNode(),l=!s,u=t.isNode(),c=!u;o&&(i=e.zDepth(),a=t.zDepth());var d=i-a,h=0===d;return h?s&&c?1:l&&u?-1:0===n?e.poolIndex()-t.poolIndex():n:d};t.exports=n},{}],33:[function(e,t,r){"use strict";var n=e("../is"),i=e("../util"),a=e("../collection"),o=e("../collection/element"),s={add:function(e){var t,r=this;if(n.elementOrCollection(e)){var s=e;if(s._private.cy===r)t=s.restore();else{for(var l=[],u=0;uu;u++){var f=h[u],v=d[f];if(n.array(v))for(var g=0,y=v.length;y>g;g++){var m=i.extend({group:f},v[g]);l.push(m)}}t=new a(r,l)}else{var m=e;t=new o(r,m).collection()}return t},remove:function(e){if(n.elementOrCollection(e));else if(n.string(e)){var t=e;e=this.$(t)}return e.remove()},load:function(e,t,r){var a=this;a.notifications(!1);var o=a.mutableElements();o.length>0&&o.remove(),null!=e&&(n.plainObject(e)||n.array(e))&&a.add(e),a.one("layoutready",function(e){a.notifications(!0),a.trigger(e),a.notify({type:"load",eles:a.mutableElements()}),a.one("load",t),a.trigger("load")}).one("layoutstop",function(){a.one("done",r),a.trigger("done")});var s=i.extend({},a._private.options.layout);return s.eles=a.elements(),a.layout(s),this}};t.exports=s},{"../collection":26,"../collection/element":22,"../is":83,"../util":100}],34:[function(e,t,r){"use strict";var n=e("../define"),i=e("../util"),a=e("../is"),o={animate:n.animate(),animation:n.animation(),animated:n.animated(),clearQueue:n.clearQueue(),delay:n.delay(),delayAnimation:n.delayAnimation(),stop:n.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){function e(){c._private.animationsRunning&&i.requestAnimationFrame(function(r){t(r),e()})}function t(e){function t(t,i){var s=t._private,l=s.animation.current,u=s.animation.queue,c=!1;if(0===l.length){var d=u.shift();d&&l.push(d)}for(var h=function(e){for(var t=e.length-1;t>=0;t--){var r=e[t];r()}e.splice(0,e.length)},p=l.length-1;p>=0;p--){var f=l[p],v=f._private;v.stopped?(l.splice(p,1),v.hooked=!1,v.playing=!1,v.started=!1,h(v.frames)):(v.playing||v.applying)&&(v.playing&&v.applying&&(v.applying=!1),v.started||r(t,f,e),n(t,f,e,i),a.fn(v.step)&&v.step.call(t,e),v.applying&&(v.applying=!1),h(v.frames),f.completed()&&(l.splice(p,1),v.hooked=!1,v.playing=!1,v.started=!1,h(v.completes)),c=!0)}return i||0!==l.length||0!==u.length||o.push(t),c}for(var i=c._private.aniEles,o=[],s=!1,l=0;l0){var p=i.updateCompoundBounds().spawnSelf().merge(i);c.notify({type:"draw",eles:p})}else c.notify({type:"draw"});i.unmerge(o),c.trigger("step")}function r(e,t,r){var n=a.core(e),i=!n,o=e,s=c._private.style,l=t._private;if(i){var u=o._private.position;l.startPosition=l.startPosition||{x:u.x,y:u.y},l.startStyle=l.startStyle||s.getAnimationStartStyle(o,l.style)}if(n){var d=c._private.pan;l.startPan=l.startPan||{x:d.x,y:d.y},l.startZoom=null!=l.startZoom?l.startZoom:c._private.zoom}l.started=!0,l.startTime=r-l.progress*l.duration}function n(e,t,r,n){var i=c._private.style,s=!n,l=e._private,d=t._private,h=d.easing,f=d.startTime;if(!d.easingImpl)if(null==h)d.easingImpl=p.linear;else{var v;if(a.string(h)){var g=i.parse("transition-timing-function",h);v=g.value}else v=h;var y,m;a.string(v)?(y=v,m=[]):(y=v[1],m=v.slice(2).map(function(e){return+e})),m.length>0?("spring"===y&&m.push(d.duration),d.easingImpl=p[y].apply(null,m)):d.easingImpl=p[y]}var b,x=d.easingImpl;if(b=0===d.duration?1:(r-f)/d.duration,d.applying&&(b=d.progress),0>b?b=0:b>1&&(b=1),null==d.delay){var w=d.startPosition,E=d.position,_=l.position;E&&s&&(o(w.x,E.x)&&(_.x=u(w.x,E.x,b,x)),o(w.y,E.y)&&(_.y=u(w.y,E.y,b,x)),e.trigger("position"));var P=d.startPan,S=d.pan,k=l.pan,T=null!=S&&n;T&&(o(P.x,S.x)&&(k.x=u(P.x,S.x,b,x)),o(P.y,S.y)&&(k.y=u(P.y,S.y,b,x)),e.trigger("pan"));var D=d.startZoom,C=d.zoom,M=null!=C&&n;M&&(o(D,C)&&(l.zoom=u(D,C,b,x)),e.trigger("zoom")),(T||M)&&e.trigger("viewport");var N=d.style;if(N&&N.length>0&&s){for(var B=0;Br?r=0:r>1&&(r=1);var i,o;if(i=null!=e.pfValue||null!=e.value?null!=e.pfValue?e.pfValue:e.value:e,o=null!=t.pfValue||null!=t.value?null!=t.pfValue?t.pfValue:t.value:t,a.number(i)&&a.number(o))return n(i,o,r);if(a.array(i)&&a.array(o)){for(var s=[],l=0;ld&&Math.abs(s.v)>d))break;return a?function(e){return u[e*(u.length-1)|0]}:c}}(),p={linear:function(e,t,r){return e+(t-e)*r},ease:l(.25,.1,.25,1),"ease-in":l(.42,0,1,1),"ease-out":l(0,0,.58,1),"ease-in-out":l(.42,0,.58,1),"ease-in-sine":l(.47,0,.745,.715),"ease-out-sine":l(.39,.575,.565,1),"ease-in-out-sine":l(.445,.05,.55,.95),"ease-in-quad":l(.55,.085,.68,.53),"ease-out-quad":l(.25,.46,.45,.94),"ease-in-out-quad":l(.455,.03,.515,.955),"ease-in-cubic":l(.55,.055,.675,.19),"ease-out-cubic":l(.215,.61,.355,1),"ease-in-out-cubic":l(.645,.045,.355,1),"ease-in-quart":l(.895,.03,.685,.22),"ease-out-quart":l(.165,.84,.44,1),"ease-in-out-quart":l(.77,0,.175,1),"ease-in-quint":l(.755,.05,.855,.06),"ease-out-quint":l(.23,1,.32,1),"ease-in-out-quint":l(.86,0,.07,1),"ease-in-expo":l(.95,.05,.795,.035),"ease-out-expo":l(.19,1,.22,1),"ease-in-out-expo":l(1,0,0,1),"ease-in-circ":l(.6,.04,.98,.335),"ease-out-circ":l(.075,.82,.165,1),"ease-in-out-circ":l(.785,.135,.15,.86),spring:function(e,t,r){if(0===r)return p.linear;var n=h(e,t,r);return function(e,t,r){return e+(t-e)*n(r)}},"cubic-bezier":function(e,t,r,n){return l(e,t,r,n)}}}}};t.exports=o},{"../define":44,"../is":83,"../util":100}],35:[function(e,t,r){"use strict";var n=e("../define"),i={on:n.on(),one:n.on({unbindSelfOnTrigger:!0}),once:n.on({unbindAllBindersOnTrigger:!0}),off:n.off(),trigger:n.trigger()};n.eventAliasesOn(i),t.exports=i},{"../define":44}],36:[function(e,t,r){"use strict";var n={png:function(e){var t=this._private.renderer;return e=e||{},t.png(e)},jpg:function(e){var t=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",t.jpg(e)}};n.jpeg=n.jpg,t.exports=n},{}],37:[function(e,t,r){"use strict";var n=e("../window"),i=e("../util"),a=e("../collection"),o=e("../is"),s=e("../promise"),l=e("../define"),u=function(e){var t=this;e=i.extend({},e);var r=e.container;r&&!o.htmlElement(r)&&o.htmlElement(r[0])&&(r=r[0]);var l=r?r._cyreg:null;l=l||{},l&&l.cy&&(l.cy.destroy(),l={});var u=l.readies=l.readies||[];r&&(r._cyreg=l),l.cy=t;var c=void 0!==n&&void 0!==r&&!e.headless,d=e;d.layout=i.extend({name:c?"grid":"null"},d.layout),d.renderer=i.extend({name:c?"canvas":"null"},d.renderer);var h=function(e,t,r){return void 0!==t?t:void 0!==r?r:e},p=this._private={container:r,ready:!1,initrender:!1,options:d,elements:new a(this),listeners:[],aniEles:new a(this),scratch:{},layout:null,renderer:null,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:h(!0,d.zoomingEnabled),userZoomingEnabled:h(!0,d.userZoomingEnabled),panningEnabled:h(!0,d.panningEnabled),userPanningEnabled:h(!0,d.userPanningEnabled),boxSelectionEnabled:h(!0,d.boxSelectionEnabled),autolock:h(!1,d.autolock,d.autolockNodes),autoungrabify:h(!1,d.autoungrabify,d.autoungrabifyNodes),autounselectify:h(!1,d.autounselectify),styleEnabled:void 0===d.styleEnabled?c:d.styleEnabled,zoom:o.number(d.zoom)?d.zoom:1,pan:{x:o.plainObject(d.pan)&&o.number(d.pan.x)?d.pan.x:0,y:o.plainObject(d.pan)&&o.number(d.pan.y)?d.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1},f=d.selectionType;void 0===f||"additive"!==f&&"single"!==f?p.selectionType="single":p.selectionType=f,o.number(d.minZoom)&&o.number(d.maxZoom)&&d.minZoom0?d.wheelSensitivity:1,motionBlur:void 0===d.motionBlur?!1:d.motionBlur,motionBlurOpacity:void 0===d.motionBlurOpacity?.05:d.motionBlurOpacity,pixelRatio:o.number(d.pixelRatio)&&d.pixelRatio>0?d.pixelRatio:void 0,desktopTapThreshold:void 0===d.desktopTapThreshold?4:d.desktopTapThreshold,touchTapThreshold:void 0===d.touchTapThreshold?8:d.touchTapThreshold},d.renderer)),v([d.style,d.elements],function(e){var r=e[0],n=e[1];p.styleEnabled&&t.setStyle(r),d.initrender&&(t.on("initrender",d.initrender),t.on("initrender",function(){p.initrender=!0})),t.load(n,function(){t.startAnimationLoop(),p.ready=!0,o.fn(d.ready)&&t.on("ready",d.ready);for(var e=0;e0;)t.removeChild(t.childNodes[0]);e._private.renderer=null},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};i.invalidateDimensions=i.resize,t.exports=i},{"../util":100}],41:[function(e,t,r){"use strict";var n=e("../is"),i=e("../collection"),a={collection:function(e,t){return n.string(e)?this.$(e):n.elementOrCollection(e)?e.collection():n.array(e)?new i(this,e,t):new i(this)},nodes:function(e){var t=this.$(function(){return this.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(){return this.isEdge()});return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};a.elements=a.filter=a.$,t.exports=a},{"../collection":26,"../is":83}],42:[function(e,t,r){"use strict";var n=e("../is"),i=e("../style"),a={style:function(e){if(e){var t=this.setStyle(e);t.update()}return this._private.style},setStyle:function(e){var t=this._private;return n.stylesheet(e)?t.style=e.generateStyle(this):n.array(e)?t.style=i.fromJson(this,e):n.string(e)?t.style=i.fromString(this,e):t.style=i(this),t.style}};t.exports=a},{"../is":83,"../style":92}],43:[function(e,t,r){"use strict";var n=e("../is"),i={autolock:function(e){return void 0===e?this._private.autolock:(this._private.autolock=!!e,this)},autoungrabify:function(e){return void 0===e?this._private.autoungrabify:(this._private.autoungrabify=!!e,this)},autounselectify:function(e){return void 0===e?this._private.autounselectify:(this._private.autounselectify=!!e,this)},panningEnabled:function(e){return void 0===e?this._private.panningEnabled:(this._private.panningEnabled=!!e,this)},userPanningEnabled:function(e){return void 0===e?this._private.userPanningEnabled:(this._private.userPanningEnabled=!!e,this)},zoomingEnabled:function(e){return void 0===e?this._private.zoomingEnabled:(this._private.zoomingEnabled=!!e,this)},userZoomingEnabled:function(e){return void 0===e?this._private.userZoomingEnabled:(this._private.userZoomingEnabled=!!e,this)},boxSelectionEnabled:function(e){return void 0===e?this._private.boxSelectionEnabled:(this._private.boxSelectionEnabled=!!e,this)},pan:function(){var e,t,r,i,a,o=arguments,s=this._private.pan;switch(o.length){case 0:return s;case 1:if(n.string(o[0]))return e=o[0],s[e];if(n.plainObject(o[0])){if(!this._private.panningEnabled)return this;r=o[0],i=r.x,a=r.y,n.number(i)&&(s.x=i),n.number(a)&&(s.y=a),this.trigger("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;e=o[0],t=o[1],"x"!==e&&"y"!==e||!n.number(t)||(s[e]=t),this.trigger("pan viewport")}return this.notify({type:"viewport"}),this},panBy:function(e){var t,r,i,a,o,s=arguments,l=this._private.pan;if(!this._private.panningEnabled)return this;switch(s.length){case 1:n.plainObject(s[0])&&(i=s[0],a=i.x,o=i.y,n.number(a)&&(l.x+=a),n.number(o)&&(l.y+=o),this.trigger("pan viewport"));break;case 2:t=s[0],r=s[1],"x"!==t&&"y"!==t||!n.number(r)||(l[t]+=r),this.trigger("pan viewport")}return this.notify({type:"viewport"}),this},fit:function(e,t){var r=this.getFitViewport(e,t);if(r){var n=this._private;n.zoom=r.zoom,n.pan=r.pan,this.trigger("pan zoom viewport"),this.notify({type:"viewport"})}return this},getFitViewport:function(e,t){if(n.number(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var r;if(n.string(e)){var i=e;e=this.$(i)}else if(n.boundingBox(e)){var a=e;r={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2},r.w=r.x2-r.x1,r.h=r.y2-r.y1}else n.elementOrCollection(e)||(e=this.mutableElements());r=r||e.boundingBox();var o,s=this.width(),l=this.height();if(t=n.number(t)?t:0,!isNaN(s)&&!isNaN(l)&&s>0&&l>0&&!isNaN(r.w)&&!isNaN(r.h)&&r.w>0&&r.h>0){o=Math.min((s-2*t)/r.w,(l-2*t)/r.h),o=o>this._private.maxZoom?this._private.maxZoom:o,o=othis._private.maxZoom?this._private.maxZoom:r,r=rt.maxZoom||!t.zoomingEnabled?o=!0:(t.zoom=l,a.push("zoom"))}if(i&&(!o||!e.cancelOnFailedZoom)&&t.panningEnabled){var u=e.pan;n.number(u.x)&&(t.pan.x=u.x,s=!1),n.number(u.y)&&(t.pan.y=u.y,s=!1),s||a.push("pan")}return a.length>0&&(a.push("viewport"),this.trigger(a.join(" ")),this.notify({type:"viewport"})),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.trigger("pan viewport"),this.notify({type:"viewport"})),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(n.string(e)){var r=e;e=this.mutableElements().filter(r)}else n.elementOrCollection(e)||(e=this.mutableElements());var i=e.boundingBox(),a=this.width(),o=this.height();t=void 0===t?this._private.zoom:t;var s={x:(a-t*(i.x1+i.x2))/2,y:(o-t*(i.y1+i.y2))/2};return s}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,t=e.container;return e.sizeCache=e.sizeCache||(t?{width:t.clientWidth,height:t.clientHeight}:{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,r=this.renderedExtent(),n={x1:(r.x1-e.x)/t,x2:(r.x2-e.x)/t,y1:(r.y1-e.y)/t,y2:(r.y2-e.y)/t};return n.w=n.x2-n.x1,n.h=n.y2-n.y1,n},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}}};i.centre=i.center,i.autolockNodes=i.autolock,i.autoungrabifyNodes=i.autoungrabify,t.exports=i},{"../is":83}],44:[function(e,t,r){"use strict";var n=e("./util"),i=e("./is"),a=e("./selector"),o=e("./promise"),s=e("./event"),l=e("./animation"),u={data:function(e){var t={field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,onSet:function(e){},canSet:function(e){return!0}};return e=n.extend({},t,e),function(t,r){var n=e,a=this,o=void 0!==a.length,s=o?a:[a],l=o?a[0]:a;if(i.string(t)){if(n.allowGetting&&void 0===r){var u;return l&&(u=l._private[n.field][t]),u}if(n.allowSetting&&void 0!==r){var c=!n.immutableKeys[t];if(c){for(var d=0,h=s.length;h>d;d++)n.canSet(s[d])&&(s[d]._private[n.field][t]=r);n.updateStyle&&a.updateStyle(),n.onSet(a),n.settingTriggersEvent&&a[n.triggerFnName](n.settingEvent)}}}else if(n.allowSetting&&i.plainObject(t)){for(var p,f,v=t,g=Object.keys(v),d=0;du;u++){var c=s[u];if(!i.emptyString(c)){var d=!r.immutableKeys[c];if(d)for(var h=0,p=o.length;p>h;h++)o[h]._private[r.field][c]=void 0}}r.triggerEvent&&n[r.triggerFnName](r.event)}else if(void 0===t){for(var h=0,p=o.length;p>h;h++)for(var f=o[h]._private[r.field],s=Object.keys(f),u=0;u0:void 0}},clearQueue:function(e){var t={};return e=n.extend({},t,e),function(){var e=this,t=void 0!==e.length,r=t?e:[e],n=this._private.cy||this;if(!n.styleEnabled())return this;for(var i=0;i0;){var g=n.collection();i.bfs({roots:v[0],visit:function(e,t,r,n,i){g=g.add(r)},directed:!1}),v=v.not(g),f.push(g)}e=n.collection();for(var d=0;dD;){for(var C=k.shift(),M=C.neighborhood().nodes(),N=!1,d=0;dd;d++)for(var B=x[d],R=B.length,q=0;R>q;q++){var p=B[q],V=p._private.scratch.breadthfirst,F=I(p);F&&(V.intEle=F,A.push(p))}for(var d=0;dx.length-1;)x.push([]);x[X].push(p),V.depth=X,V.index=x[X].length-1}z()}var Y=0;if(r.avoidOverlap){for(var d=0;du||0===t)&&(n+=l/c,i++)}return i=Math.max(1,i),n/=i,0===i&&(n=void 0),Z[e.id()]=n,n},Q=function(e,t){var r=G(e),n=G(t);return r-n},K=0;3>K;K++){for(var d=0;d0&&x[0].length<=3?c/2:0),h=2*Math.PI/x[i].length*a;return 0===i&&1===x[0].length&&(d=1),{x:ee.x+d*Math.cos(h),y:ee.y+d*Math.sin(h)}}return{x:ee.x+(a+1-(o+1)/2)*s,y:(i+1)*l}}var p={x:ee.x+(a+1-(o+1)/2)*s,y:(i+1)*l};return t?p:p},re={},d=x.length-1;d>=0;d--)for(var B=x[d],q=0;q1&&t.avoidOverlap){p*=1.75;var b=Math.cos(h)-Math.cos(0),x=Math.sin(h)-Math.sin(0),w=Math.sqrt(p*p/(b*b+x*x));l=Math.max(w,l)}var E=function(e,r){var n=t.startAngle+e*h*(i?1:-1),a=l*Math.cos(n),o=l*Math.sin(n),s={x:c.x+a,y:c.y+o};return s};return s.layoutPositions(this,t,E),this},t.exports=n},{"../../is":83,"../../math":85,"../../util":100}],50:[function(e,t,r){"use strict";function n(e){this.options=i.extend({},o,e)}var i=e("../../util"),a=e("../../math"),o={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,height:void 0,width:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,ready:void 0,stop:void 0};n.prototype.run=function(){for(var e=this.options,t=e,r=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,n=e.cy,i=t.eles,o=i.nodes().not(":parent"),s=a.makeBoundingBox(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l={x:s.x1+s.w/2,y:s.y1+s.h/2},u=[],c=t.startAngle,d=0,h=0;h0){var x=Math.abs(m[0].value-b.value);x>=g&&(m=[],y.push(m))}m.push(b)}var w=d+t.minNodeSpacing;if(!t.avoidOverlap){var E=y.length>0&&y[0].length>1,_=Math.min(s.w,s.h)/2-w,P=_/(y.length+E?1:0);w=Math.min(w,P)}for(var S=0,h=0;h1&&t.avoidOverlap){var C=Math.cos(D)-Math.cos(0),M=Math.sin(D)-Math.sin(0),N=Math.sqrt(w*w/(C*C+M*M));S=Math.max(N,S)}k.r=S,S+=w}if(t.equidistant){for(var B=0,S=0,h=0;ha;a++)for(var o=e.layoutNodes[e.idToIndex[n[a]]],l=a+1;i>l;l++){var u=e.layoutNodes[e.idToIndex[n[l]]];s(o,u,e,t)}},s=function(e,t,r,n){var i=e.cmptId,a=t.cmptId;if(i===a||r.isCompound){var o=t.positionX-e.positionX,s=t.positionY-e.positionY;if(0!==o||0!==s){var c=l(e,t,o,s);if(c>0)var d=n.nodeOverlap*c,h=Math.sqrt(o*o+s*s),p=d*o/h,f=d*s/h;else var v=u(e,o,s),g=u(t,-1*o,-1*s),y=g.x-v.x,m=g.y-v.y,b=y*y+m*m,h=Math.sqrt(b),d=(e.nodeRepulsion+t.nodeRepulsion)/b,p=d*y/h,f=d*m/h;e.isLocked||(e.offsetX-=p,e.offsetY-=f),t.isLocked||(t.offsetX+=p,t.offsetY+=f)}}},l=function(e,t,r,n){if(r>0)var i=e.maxX-t.minX;else var i=t.maxX-e.minX;if(n>0)var a=e.maxY-t.minY;else var a=t.maxY-e.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},u=function(e,t,r){var n=e.positionX,i=e.positionY,a=e.height||1,o=e.width||1,s=r/t,l=a/o,u={};do{if(0===t&&r>0){u.x=n,u.y=i+a/2;break}if(0===t&&0>r){u.x=n,u.y=i+a/2;break}if(t>0&&s>=-1*l&&l>=s){u.x=n+o/2,u.y=i+o*r/2/t;break}if(0>t&&s>=-1*l&&l>=s){u.x=n-o/2,u.y=i-o*r/2/t;break}if(r>0&&(-1*l>=s||s>=l)){u.x=n+a*t/2/r,u.y=i+a/2;break}if(0>r&&(-1*l>=s||s>=l)){u.x=n-a*t/2/r,u.y=i-a/2;break}}while(!1);return u},c=function(e,t){for(var r=0;rc;c++){var d=e.layoutNodes[e.idToIndex[i[c]]];if(!d.isLocked){var h=o-d.positionX,p=s-d.positionY,f=Math.sqrt(h*h+p*p);if(f>r){var v=t.gravity*h/f,g=t.gravity*p/f;d.offsetX+=v,d.offsetY+=g}}}}},h=function(e,t){var r=[],n=0,i=-1;for(r.push.apply(r,e.graphSet[0]),i+=e.graphSet[0].length;i>=n;){var a=r[n++],o=e.idToIndex[a],s=e.layoutNodes[o],l=s.children;if(0r)var i={x:r*e/n,y:r*t/n};else var i={x:e,y:t};return i},v=function(e,t){var r=e.parentId;if(null!=r){var n=t.layoutNodes[t.idToIndex[r]],i=!1;return(null==n.maxX||e.maxX+n.padRight>n.maxX)&&(n.maxX=e.maxX+n.padRight,i=!0),(null==n.minX||e.minX-n.padLeftn.maxY)&&(n.maxY=e.maxY+n.padBottom,i=!0),(null==n.minY||e.minY-n.padTopy&&(f+=g+t.componentSpacing,p=0,v=0,g=0)}}},y=function(e){return i?!1:(a(r,n,e),r.temperature=r.temperature*n.coolingFactor,!(r.temperature=b;){var _=m[b++],P=a.idToIndex[_],f=a.layoutNodes[P],S=f.children;if(S.length>0){a.graphSet.push(S);for(var c=0;cn.count?0:n.graph},h=function(e,t,r,n){var i=n.graphSet[r];if(-1s){var v=d(),g=h();(v-1)*g>=s?d(v-1):(g-1)*v>=s&&h(g-1)}else for(;s>c*u;){var v=d(),g=h();(g+1)*v>=s?h(g+1):d(v+1)}var y=o.w/c,m=o.h/u;if(t.condense&&(y=0,m=0),t.avoidOverlap)for(var b=0;b=c&&(M=0,C++)},B={},b=0;b=o&&s>=e&&t>=l&&u>=t;return c},o=function(e,t,r,n,i){var a=e*Math.cos(n)-t*Math.sin(n),o=e*Math.sin(n)+t*Math.cos(n),s=a*r,l=o*r,u=s+i.x,c=l+i.y;return{x:u,y:c}},s=function(e,t,r,n){for(var i=[],a=0;at))if(d){if(d.pstyle("z-index").value===e.pstyle("z-index").value)for(var r=0;r(l=i.sqdistToFiniteLine(e,t,_[P],_[P+1],_[P+2],_[P+3]))&&a(n,l);else if("bezier"===c.edgeType||"multibezier"===c.edgeType||"self"===c.edgeType||"compound"===c.edgeType)for(var _=c.allpts,P=0;P+5(l=i.sqdistToQuadraticBezier(e,t,_[P],_[P+1],_[P+2],_[P+3],_[P+4],_[P+5]))&&a(n,l);if(w&&E())for(var y=y||o.source,x=x||o.target,S=n.pstyle("width").pfValue,k=p.getArrowWidth(S),T=[{name:"source",x:c.arrowStartX,y:c.arrowStartY,angle:c.srcArrowAngle},{name:"target",x:c.arrowEndX,y:c.arrowEndY,angle:c.tgtArrowAngle},{name:"mid-source",x:c.midX,y:c.midY,angle:c.midsrcArrowAngle},{name:"mid-target",x:c.midX,y:c.midY,angle:c.midtgtArrowAngle}],P=0;P0&&(s(y),s(x))}}function u(e,t,r){return o.getPrefixedProperty(e,t,r)}function c(r,n){var o,s=r._private,l=w;if(o=n?n+"-":"","no"!==r.pstyle("text-events").strValue){var c=r.pstyle(o+"text-rotation");if("autorotate"===c.strValue||c.pfValue){var d=s.rstyle,h=r.pstyle("text-border-width").pfValue,p=u(d,"labelWidth",n)+h/2+2*l,f=u(d,"labelHeight",n)+h/2+2*l,v=u(d,"labelX",n),g=u(d,"labelY",n),y=u(s.rscratch,"labelAngle",n),m=Math.cos(y),b=Math.sin(y),x=function(e,t){return e-=v,t-=g,{x:e*m-t*b+v,y:e*b+t*m+g}},E=v-p/2,_=v+p/2,P=g-f/2,S=g+f/2,k=x(E,P),T=x(E,S),D=x(_,P),C=x(_,S),M=[k.x,k.y,D.x,D.y,C.x,C.y,T.x,T.y];i.pointInsidePolygonPoints(e,t,M)&&a(r)}else{var N=r.boundingBox({includeLabels:!0,includeNodes:!1,includeEdges:!1});N.x1-=l,N.y1-=l,N.x2+=l,N.y2+=l,N.w=N.x2-N.x1,N.h=N.y2-N.y1,i.inBoundingBox(N,e,t)&&a(r)}}}for(var d,h,p=this,f=this,v=f.getCachedZSortedEles(),g=[],y=f.cy.zoom(),m=f.cy.hasCompoundNodes(),b=(n?24:8)/y,x=(n?8:2)/y,w=(n?8:2)/y,E=1/0,_=v.length-1;_>=0;_--){var P=v[_];P.isNode()?(s(P),c(P)):(l(P),c(P),c(P,"source"),c(P,"target"))}return g},l.getAllInBox=function(e,t,r,n){var a=this.getCachedZSortedEles(),o=a.nodes,s=a.edges,l=[],u=Math.min(e,r),c=Math.max(e,r),d=Math.min(t,n),h=Math.max(t,n);e=u,r=c,t=d,n=h;for(var p=i.makeBoundingBox({x1:e,y1:t,x2:r,y2:n}),f=0;fv;v++)e(p,d[o*h+v],d[o*h+v+1],a.bezierProjPcts[v],a.bezierProjPcts[v+1]);e(p,d[o*h+h-1],p.p2,a.bezierProjPcts[h-1],1)}return u.cache=t},c=function(r){var a,o="source"===r;if(s[r]){var c=e.pstyle(r+"-text-offset").pfValue,d=function(e,t){var r=t.x-e.x,n=t.y-e.y;return Math.atan(n/r)},h=function(e,t,r,n){var a=i.bound(0,n-.001,1),o=i.bound(0,n+.001,1),s=i.qbezierPtAt(e,t,r,a),l=i.qbezierPtAt(e,t,r,o);return d(s,l)};switch(n.edgeType){case"self":case"compound":case"bezier":case"multibezier":for(var p,f=u(),v=0,g=0,y=0;y=c||w){p={cp:m,segment:x};break}}if(p)break}var m=p.cp,x=p.segment,E=(c-v)/x.length,_=x.t1-x.t0,P=o?x.t0+_*E:x.t1-_*E;P=i.bound(0,P,1),t=i.qbezierPtAt(m.p0,m.p1,m.p2,P),a=h(m.p0,m.p1,m.p2,P,t);break;case"straight":case"segments":case"haystack":for(var S,k,T,D,C=0,M=n.allpts.length,y=0;M>y+3&&(o?(T={x:n.allpts[y],y:n.allpts[y+1]},D={x:n.allpts[y+2],y:n.allpts[y+3]}):(T={x:n.allpts[M-2-y],y:n.allpts[M-1-y]},D={x:n.allpts[M-4-y],y:n.allpts[M-3-y]}),S=i.dist(T,D),k=C,C+=S,!(C>=c));y+=2);var N=c-k,P=N/S;P=i.bound(0,P,1),t=i.lineAt(T,D,P),a=d(T,D)}l("labelX",r,t.x),l("labelY",r,t.y),l("labelAutoAngle",r,a)}};c("source"),c("target"),this.applyLabelDimensions(e)}},l.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},l.applyPrefixedLabelDimensions=function(e,t){var r=e._private,n=this.getLabelText(e,t),i=this.calculateLabelDimensions(e,n);o.setPrefixedProperty(r.rstyle,"labelWidth",t,i.width),o.setPrefixedProperty(r.rscratch,"labelWidth",t,i.width),o.setPrefixedProperty(r.rstyle,"labelHeight",t,i.height),o.setPrefixedProperty(r.rscratch,"labelHeight",t,i.height)},l.getLabelText=function(e,t){var r=e._private,n=t?t+"-":"",i=e.pstyle(n+"label").strValue,a=e.pstyle("text-transform").value,s=function(e,n){return n?(o.setPrefixedProperty(r.rscratch,e,t,n),n):o.getPrefixedProperty(r.rscratch,e,t)};if("none"==a||("uppercase"==a?i=i.toUpperCase():"lowercase"==a&&(i=i.toLowerCase())),"wrap"===e.pstyle("text-wrap").value){var l=s("labelKey");if(l&&s("labelWrapKey")===l)return s("labelWrapCachedText");for(var u=i.split("\n"),c=e.pstyle("text-max-width").pfValue,d=[],h=0;hc){for(var g=p.split(/\s+/),y="",m=0;m=E?y+=b+" ":(d.push(y),y=b+" ")}y.match(/^\s+$/)||d.push(y)}else d.push(p)}s("labelWrapCachedLines",d),i=s("labelWrapCachedText",d.join("\n")),s("labelWrapKey",l)}return i},l.calculateLabelDimensions=function(e,t,r){var n=this,i=e._private.labelStyleKey+"$@$"+t;r&&(i+="$@$"+r);var a=n.labelDimCache||(n.labelDimCache={});if(a[i])return a[i];var o=1,s=e.pstyle("font-style").strValue,l=o*e.pstyle("font-size").pfValue+"px",u=e.pstyle("font-family").strValue,c=e.pstyle("font-weight").strValue,d=this.labelCalcDiv;d||(d=this.labelCalcDiv=document.createElement("div"),document.body.appendChild(d));var h=d.style;return h.fontFamily=u,h.fontStyle=s,h.fontSize=l,h.fontWeight=c,h.position="absolute",h.left="-9999px",h.top="-9999px",h.zIndex="-1",h.visibility="hidden",h.pointerEvents="none",h.padding="0",h.lineHeight="1","wrap"===e.pstyle("text-wrap").value?h.whiteSpace="pre":h.whiteSpace="normal",d.textContent=t,a[i]={width:Math.ceil(d.clientWidth/o),height:Math.ceil(d.clientHeight/o)},a[i]},l.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)},l.findEdgeControlPoints=function(e){if(e&&0!==e.length){for(var t,r=this,n=r.cy,o=n.hasCompoundNodes(),s={},l=[],u=[],c=0;cy?y+"$-$"+g:g+"$-$"+y,v&&(t="unbundled$-$"+p.id),null==s[t]&&(s[t]=[],l.push(t)),s[t].push(d),v&&(s[t].hasUnbundled=!0)}else u.push(d)}for(var m,b,x,w,E,_,P,S,k,T,D,C,M,N,B=0;Bb.id()){var I=m;m=b,b=I}if(x=m._private,w=b._private,E=x.position,_=w.position,P=m.outerWidth(),S=m.outerHeight(),k=b.outerWidth(),T=b.outerHeight(),D=r.nodeShapes[this.getNodeShape(m)],C=r.nodeShapes[this.getNodeShape(b)],N=!1,z.length>1&&m!==b||z.hasUnbundled){var L=D.intersectLine(E.x,E.y,P,S,_.x,_.y,0),O=C.intersectLine(_.x,_.y,k,T,E.x,E.y,0),A={x1:L[0],x2:O[0],y1:L[1],y2:O[1]},R={x1:E.x,x2:_.x,y1:E.y,y2:_.y},q=O[1]-L[1],V=O[0]-L[0],F=Math.sqrt(V*V+q*q),j={x:V,y:q},X={x:j.x/F,y:j.y/F};M={x:-X.y,y:X.x},C.checkPoint(L[0],L[1],0,k,T,_.x,_.y)&&D.checkPoint(O[0],O[1],0,P,S,E.x,E.y)&&(M={},N=!0)}for(var d,Y,W,c=0;cze;ze++){var Ie=Me[ze],Le=Ne[ze],Oe=1-Ie,Ae=Ie,Re="node-position"===xe?R:A,qe={x:Re.x1*Oe+Re.x2*Ae,y:Re.y1*Oe+Re.y2*Ae};W.segpts.push(qe.x+M.x*Le,qe.y+M.y*Le)}}else if(z.length%2!==1||c!==Math.floor(z.length/2)||v){var Ve=v;W.edgeType=Ve?"multibezier":"bezier",W.ctrlpts=[];for(var Fe=0;K>Fe;Fe++){var je,Xe=(.5-z.length/2+c)*J,Ye=i.signum(Xe);Ve&&(ee=G?G.pfValue[Fe]:J,te=Q.value[Fe]),je=v?ee:void 0!==ee?Ye*ee:void 0;var We=void 0!==je?je:Xe,Oe=1-te,Ae=te,Re="node-position"===xe?R:A,qe={x:Re.x1*Oe+Re.x2*Ae,y:Re.y1*Oe+Re.y2*Ae};W.ctrlpts.push(qe.x+M.x*We,qe.y+M.y*We)}}else W.edgeType="straight";this.findEndpoints(d);var $e=!a.number(W.startX)||!a.number(W.startY),He=!a.number(W.arrowStartX)||!a.number(W.arrowStartY),Ue=!a.number(W.endX)||!a.number(W.endY),Ze=!a.number(W.arrowEndX)||!a.number(W.arrowEndY),Ge=3,Qe=this.getArrowWidth(d.pstyle("width").pfValue)*this.arrowShapeWidth,Ke=Ge*Qe;if("bezier"===W.edgeType){var Je=i.dist({x:W.ctrlpts[0],y:W.ctrlpts[1]},{x:W.startX,y:W.startY}),et=Ke>Je,tt=i.dist({x:W.ctrlpts[0],y:W.ctrlpts[1]},{x:W.endX,y:W.endY}),rt=Ke>tt,nt=!1;if($e||He||et){nt=!0;var it={x:W.ctrlpts[0]-E.x,y:W.ctrlpts[1]-E.y},at=Math.sqrt(it.x*it.x+it.y*it.y),ot={x:it.x/at,y:it.y/at},st=Math.max(P,S),lt={x:W.ctrlpts[0]+2*ot.x*st,y:W.ctrlpts[1]+2*ot.y*st},ut=D.intersectLine(E.x,E.y,P,S,lt.x,lt.y,0);et?(W.ctrlpts[0]=W.ctrlpts[0]+ot.x*(Ke-Je),W.ctrlpts[1]=W.ctrlpts[1]+ot.y*(Ke-Je)):(W.ctrlpts[0]=ut[0]+ot.x*Ke,W.ctrlpts[1]=ut[1]+ot.y*Ke)}if(Ue||Ze||rt){nt=!0;var it={x:W.ctrlpts[0]-_.x,y:W.ctrlpts[1]-_.y},at=Math.sqrt(it.x*it.x+it.y*it.y),ot={x:it.x/at,y:it.y/at},st=Math.max(P,S),lt={x:W.ctrlpts[0]+2*ot.x*st,y:W.ctrlpts[1]+2*ot.y*st},ct=C.intersectLine(_.x,_.y,k,T,lt.x,lt.y,0);rt?(W.ctrlpts[0]=W.ctrlpts[0]+ot.x*(Ke-tt),W.ctrlpts[1]=W.ctrlpts[1]+ot.y*(Ke-tt)):(W.ctrlpts[0]=ct[0]+ot.x*Ke,W.ctrlpts[1]=ct[1]+ot.y*Ke)}nt&&this.findEndpoints(d)}if("multibezier"===W.edgeType||"bezier"===W.edgeType||"self"===W.edgeType||"compound"===W.edgeType){W.allpts=[],W.allpts.push(W.startX,W.startY);for(var Fe=0;Fe+1c[0]&&i.clientXc[1]&&i.clientY=e.desktopTapThreshold2}var I=r(i);P&&(e.hoverData.tapholdCancelled=!0);var L=function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];0===t.length?(t.push(T[0]),t.push(T[1])):(t[0]+=T[0],t[1]+=T[1])};if(l=!0,t(_,["mousemove","vmousemove","tapdrag"],i,{cyPosition:{x:b[0],y:b[1]}}),3===e.hoverData.which){if(P){var O=new o(i,{type:"cxtdrag",cyPosition:{x:b[0],y:b[1]}});k?k.trigger(O):v.trigger(O),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&_===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.trigger(new o(i,{type:"cxtdragout",cyPosition:{x:b[0],y:b[1]}})),e.hoverData.cxtOver=_,_&&_.trigger(new o(i,{type:"cxtdragover",cyPosition:{x:b[0],y:b[1]}})))}}else if(e.hoverData.dragging){if(l=!0,v.panningEnabled()&&v.userPanningEnabled()){var A;if(e.hoverData.justStartedPan){var R=e.hoverData.mdownPos;A={x:(b[0]-R[0])*g,y:(b[1]-R[1])*g},e.hoverData.justStartedPan=!1}else A={x:T[0]*g,y:T[1]*g};v.panBy(A),e.hoverData.dragged=!0}b=e.projectIntoViewport(i.clientX,i.clientY)}else if(1!=E[4]||null!=k&&!k.isEdge()){if(k&&k.isEdge()&&k.active()&&k.unactivate(),k&&k.grabbed()||_==S||(S&&t(S,["mouseout","tapdragout"],i,{cyPosition:{x:b[0],y:b[1]}}),_&&t(_,["mouseover","tapdragover"],i,{cyPosition:{x:b[0],y:b[1]}}),e.hoverData.last=_),k&&e.nodeIsDraggable(k))if(P){var q=!e.dragData.didDrag;q&&e.redrawHint("eles",!0),e.dragData.didDrag=!0;var V=[];e.hoverData.draggingEles||y(v.collection(D),{inDragLayer:!0});for(var F=0;F0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=c=[]),t(u,["mouseup","tapend","vmouseup"],n,{cyPosition:{x:s[0],y:s[1]}}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||t(d,["click","tap","vclick"],n,{cyPosition:{x:s[0],y:s[1]}}),u!=d||e.dragData.didDrag||e.hoverData.selecting||null!=u&&u._private.selectable&&(e.hoverData.dragging||("additive"===a.selectionType()||h?u.selected()?u.unselect():u.select():h||(a.$(":selected").unmerge(u).unselect(),u.select())),e.redrawHint("eles",!0)),e.hoverData.selecting){var v=a.collection(e.getAllInBox(l[0],l[1],l[2],l[3]));e.redrawHint("select",!0),v.length>0&&e.redrawHint("eles",!0),a.trigger("boxend");var g=function(e){return e.selectable()&&!e.selected()};"additive"===a.selectionType()?v.trigger("box").stdFilter(g).select().trigger("boxselect"):(h||a.$(":selected").unmerge(v).unselect(),v.trigger("box").stdFilter(g).select().trigger("boxselect")),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint("select",!0),e.redrawHint("eles",!0),e.redraw()),!l[4]){e.redrawHint("drag",!0),e.redrawHint("eles",!0);var y=d&&d.grabbed();b(c),y&&d.trigger("free")}}l[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null}},!1);var k=function(t){if(!e.scrollingPage){var r=e.cy,n=e.projectIntoViewport(t.clientX,t.clientY),i=[n[0]*r.zoom()+r.pan().x,n[1]*r.zoom()+r.pan().y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||S())return void t.preventDefault();if(r.panningEnabled()&&r.userPanningEnabled()&&r.zoomingEnabled()&&r.userZoomingEnabled()){t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout(function(){e.data.wheelZooming=!1,e.redrawHint("eles",!0),e.redraw()},150);var a=t.deltaY/-250||t.wheelDeltaY/1e3||t.wheelDelta/1e3;a*=e.wheelSensitivity;var o=1===t.deltaMode;o&&(a*=33),r.zoom({level:r.zoom()*Math.pow(10,a),renderedPosition:{x:i[0],y:i[1]}})}}};e.registerBinding(e.container,"wheel",k,!0),e.registerBinding(window,"scroll",function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout(function(){e.scrollingPage=!1},250)},!0),e.registerBinding(e.container,"mouseout",function(t){var r=e.projectIntoViewport(t.clientX,t.clientY);e.cy.trigger(new o(t,{type:"mouseout",cyPosition:{x:r[0],y:r[1]}}))},!1),e.registerBinding(e.container,"mouseover",function(t){var r=e.projectIntoViewport(t.clientX,t.clientY);e.cy.trigger(new o(t,{type:"mouseover",cyPosition:{x:r[0],y:r[1]}}))},!1);var T,D,C,M,N,B,z,I,L,O,A,R,q,V,F=function(e,t,r,n){return Math.sqrt((r-e)*(r-e)+(n-t)*(n-t))},j=function(e,t,r,n){return(r-e)*(r-e)+(n-t)*(n-t)};e.registerBinding(e.container,"touchstart",V=function(r){e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,i=e.touchData.now,a=e.touchData.earlier;if(r.touches[0]){var s=e.projectIntoViewport(r.touches[0].clientX,r.touches[0].clientY);i[0]=s[0],i[1]=s[1]}if(r.touches[1]){var s=e.projectIntoViewport(r.touches[1].clientX,r.touches[1].clientY);i[2]=s[0],i[3]=s[1]}if(r.touches[2]){var s=e.projectIntoViewport(r.touches[2].clientX,r.touches[2].clientY);i[4]=s[0],i[5]=s[1]}if(r.touches[1]){b(e.dragData.touchDragEles);var l=e.findContainerClientCoords();L=l[0],O=l[1],A=l[2],R=l[3],T=r.touches[0].clientX-L,D=r.touches[0].clientY-O,C=r.touches[1].clientX-L,M=r.touches[1].clientY-O,q=T>=0&&A>=T&&C>=0&&A>=C&&D>=0&&R>=D&&M>=0&&R>=M;var u=n.pan(),c=n.zoom();N=F(T,D,C,M),B=j(T,D,C,M),z=[(T+C)/2,(D+M)/2],I=[(z[0]-u.x)/c,(z[1]-u.y)/c];var d=200,h=d*d;if(h>B&&!r.touches[2]){var f=e.findNearestElement(i[0],i[1],!0,!0),v=e.findNearestElement(i[2],i[3],!0,!0);return f&&f.isNode()?(f.activate().trigger(new o(r,{type:"cxttapstart",cyPosition:{x:i[0],y:i[1]}})),e.touchData.start=f):v&&v.isNode()?(v.activate().trigger(new o(r,{type:"cxttapstart",cyPosition:{x:i[0],y:i[1]}})),e.touchData.start=v):(n.trigger(new o(r,{type:"cxttapstart",cyPosition:{x:i[0],y:i[1]}})),e.touchData.start=null),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!0,e.touchData.cxtDragged=!1,e.data.bgActivePosistion=void 0,void e.redraw()}}if(r.touches[2]);else if(r.touches[1]);else if(r.touches[0]){var g=e.findNearestElements(i[0],i[1],!0,!0),x=g[0];if(null!=x&&(x.activate(),e.touchData.start=x,e.touchData.starts=g,e.nodeIsGrabbable(x))){var w=e.dragData.touchDragEles=[];if(e.redrawHint("eles",!0),e.redrawHint("drag",!0),x.selected()){var E=n.$(function(){return this.selected()&&e.nodeIsGrabbable(this)});y(E,{addToList:w})}else m(x,{addToList:w});p(x),x.trigger(new o(r,{type:"grab",cyPosition:{x:i[0],y:i[1]}}))}t(x,["touchstart","tapstart","vmousedown"],r,{cyPosition:{x:i[0],y:i[1]}}),null==x&&(e.data.bgActivePosistion={x:s[0],y:s[1]},e.redrawHint("select",!0),e.redraw()),e.touchData.startPosition=[];for(var _=0;_=e.touchTapThreshold2}if(l&&e.touchData.cxt){r.preventDefault();var S=r.touches[0].clientX-L,k=r.touches[0].clientY-O,z=r.touches[1].clientX-L,A=r.touches[1].clientY-O,R=j(S,k,z,A),V=R/B,X=150,Y=X*X,W=1.5,$=W*W;if(V>=$||R>=Y){e.touchData.cxt=!1,e.touchData.start&&(e.touchData.start.unactivate(),e.touchData.start=null),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var H=new o(r,{type:"cxttapend",cyPosition:{x:c[0],y:c[1]}});e.touchData.start?e.touchData.start.trigger(H):u.trigger(H)}}if(l&&e.touchData.cxt){var H=new o(r,{type:"cxtdrag",cyPosition:{x:c[0],y:c[1]}});e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.touchData.start?e.touchData.start.trigger(H):u.trigger(H),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var U=e.findNearestElement(c[0],c[1],!0,!0);e.touchData.cxtOver&&U===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.trigger(new o(r,{type:"cxtdragout",cyPosition:{x:c[0],y:c[1]}})),e.touchData.cxtOver=U,U&&U.trigger(new o(r,{type:"cxtdragover",cyPosition:{x:c[0],y:c[1]}})))}else if(l&&r.touches[2]&&u.boxSelectionEnabled())r.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||u.trigger("boxstart"),e.touchData.selecting=!0,e.redrawHint("select",!0),i&&0!==i.length&&void 0!==i[0]?(i[2]=(c[0]+c[2]+c[4])/3,i[3]=(c[1]+c[3]+c[5])/3):(i[0]=(c[0]+c[2]+c[4])/3,i[1]=(c[1]+c[3]+c[5])/3,i[2]=(c[0]+c[2]+c[4])/3+1,i[3]=(c[1]+c[3]+c[5])/3+1),i[4]=1,e.touchData.selecting=!0,e.redraw();else if(l&&r.touches[1]&&u.zoomingEnabled()&&u.panningEnabled()&&u.userZoomingEnabled()&&u.userPanningEnabled()){r.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var Z=e.dragData.touchDragEles;if(Z){e.redrawHint("drag",!0);for(var G=0;G=e*e+t*t}}},i.generateRoundRectangle=function(){return this.nodeShapes.roundrectangle={renderer:this,name:"roundrectangle",points:n.generateUnitNgonPointsFitToSquare(4,0),draw:function(e,t,r,n,i){this.renderer.nodeShapeImpl(this.name,e,t,r,n,i)},intersectLine:function(e,t,r,i,a,o,s){return n.roundRectangleIntersectLine(a,o,e,t,r,i,s)},checkPoint:function(e,t,r,i,a,o,s){var l=n.getRoundRectangleRadius(i,a);if(n.pointInsidePolygon(e,t,this.points,o,s,i,a-2*l,[0,-1],r))return!0;if(n.pointInsidePolygon(e,t,this.points,o,s,i-2*l,a,[0,-1],r))return!0;var u=function(e,t,r,n,i,a,o){return e-=r,t-=n,e/=i/2+o,t/=a/2+o,1>=e*e+t*t};return u(e,t,o-i/2+l,s-a/2+l,2*l,2*l,r)?!0:u(e,t,o+i/2-l,s-a/2+l,2*l,2*l,r)?!0:u(e,t,o+i/2-l,s+a/2-l,2*l,2*l,r)?!0:!!u(e,t,o-i/2+l,s+a/2-l,2*l,2*l,r)}}},i.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",n.generateUnitNgonPointsFitToSquare(3,0)),this.generatePolygon("rectangle",n.generateUnitNgonPointsFitToSquare(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generatePolygon("diamond",[0,1,1,0,0,-1,-1,0]),this.generatePolygon("pentagon",n.generateUnitNgonPointsFitToSquare(5,0)),this.generatePolygon("hexagon",n.generateUnitNgonPointsFitToSquare(6,0)),this.generatePolygon("heptagon",n.generateUnitNgonPointsFitToSquare(7,0)),this.generatePolygon("octagon",n.generateUnitNgonPointsFitToSquare(8,0));var r=new Array(20),i=n.generateUnitNgonPoints(5,0),a=n.generateUnitNgonPoints(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;ss;s++)r[4*s]=i[2*s],r[4*s+1]=i[2*s+1],r[4*s+2]=a[2*s],r[4*s+3]=a[2*s+1];r=n.fitPolygonToSquare(r),this.generatePolygon("star",r),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),e.makePolygon=function(e){var r,n=e.join("$"),i="polygon-"+n;return(r=this[i])?r:t.generatePolygon(i,e)}},t.exports=i},{"../../../math":85}],63:[function(e,t,r){"use strict";var n=e("../../../util"),i={};i.timeToRender=function(){return this.redrawTotalTime/this.redrawCount},i.redraw=function(e){e=e||n.staticEmptyObject();var t=this;void 0===t.averageRedrawTime&&(t.averageRedrawTime=0),void 0===t.lastRedrawTime&&(t.lastRedrawTime=0),void 0===t.lastDrawTime&&(t.lastDrawTime=0),t.requestedFrame=!0,t.renderOptions=e},i.beforeRender=function(e,t){if(!this.destroyed){t=t||0;var r=this.beforeRenderCallbacks;r.push({fn:e,priority:t}),r.sort(function(e,t){return t.priority-e.priority})}};var a=function(e,t,r){for(var n=e.beforeRenderCallbacks,i=0;io)},o.drawElementText=function(e,t,r){var n=this;if(void 0===r){if(!n.eleTextBiggerThanMin(t))return}else if(!r)return;if(t.isNode()){var i=t.pstyle("label");if(!i||!i.value)return;var a=t.pstyle("text-halign").strValue;t.pstyle("text-valign").strValue;switch(a){case"left":e.textAlign="right";break;case"right":e.textAlign="left";break;default:e.textAlign="center"}e.textBaseline="bottom"}else{var i=t.pstyle("label"),o=t.pstyle("source-label"),s=t.pstyle("target-label");if(!(i&&i.value||o&&o.value||s&&s.value))return;e.textAlign="center",e.textBaseline="bottom"}n.drawText(e,t),t.isEdge()&&(n.drawText(e,t,"source"),n.drawText(e,t,"target"))},o.drawNodeText=o.drawEdgeText=o.drawElementText,o.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var r=0;r0||N>0&&M>0){var B=l;switch(b){case"left":B-=h;break;case"center":B-=h/2;break;case"right":}var z=u-p;if(C>0){var I=e.fillStyle,L=t.pstyle("text-background-color").value;e.fillStyle="rgba("+L[0]+","+L[1]+","+L[2]+","+C*s+")";var O=t.pstyle("text-background-shape").strValue;"roundrectangle"==O?n(e,B,z,h,p,2):e.fillRect(B,z,h,p),e.fillStyle=I}if(N>0&&M>0){var A=e.strokeStyle,R=e.lineWidth,q=t.pstyle("text-border-color").value,V=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+q[0]+","+q[1]+","+q[2]+","+M*s+")",e.lineWidth=N,e.setLineDash)switch(V){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=N/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(e.strokeRect(B,z,h,p),"double"===V){var F=N/2;e.strokeRect(B+F,z+F,h-2*F,p-2*F)}e.setLineDash&&e.setLineDash([]),e.lineWidth=R,
-e.strokeStyle=A}}var j=2*t.pstyle("text-outline-width").pfValue;if(j>0&&(e.lineWidth=j),"wrap"===t.pstyle("text-wrap").value){var X=o.labelWrapCachedLines,Y=p/X.length;switch(x){case"top":u-=(X.length-1)*Y;break;case"center":case"bottom":u-=(X.length-1)*Y}for(var W=0;W0&&e.strokeText(X[W],l,u),e.fillText(X[W],l,u),u+=Y}else j>0&&e.strokeText(c,l,u),e.fillText(c,l,u);0!==w&&(e.rotate(-w),e.translate(-_,-P)),this.shadowStyle(e,"transparent",0)}}},t.exports=o},{"../../../math":85,"../../../util":100}],69:[function(e,t,r){"use strict";var n=e("../../../is"),i={};i.drawNode=function(e,t,r,i){var a,o,s=this,l=t._private.rscratch,u=t._private,c=c||u.position;if(n.number(c.x)&&n.number(c.y)&&t.visible()){var d,h=t.effectiveOpacity(),p=this.usePaths(),f=!1;a=t.width()+t.pstyle("padding-left").pfValue+t.pstyle("padding-right").pfValue,o=t.height()+t.pstyle("padding-top").pfValue+t.pstyle("padding-bottom").pfValue,e.lineWidth=t.pstyle("border-width").pfValue;var v;r&&(v=r,e.translate(-v.x1,-v.y1));var g,y=t.pstyle("background-image"),m=y.value[2]||y.value[1];if(void 0!==m){g=this.getCachedImage(m,function(){t.trigger("background"),s.redrawHint("eles",!0),s.redrawHint("drag",!0),s.drawingImage=!0,s.redraw()});var b=u.backgrounding;u.backgrounding=!g.complete,b!==u.backgrounding&&t.updateStyle(!1)}var x=t.pstyle("background-color").value,w=t.pstyle("border-color").value,E=t.pstyle("border-style").value;this.fillStyle(e,x[0],x[1],x[2],t.pstyle("background-opacity").value*h),this.strokeStyle(e,w[0],w[1],w[2],t.pstyle("border-opacity").value*h);var _=t.pstyle("shadow-blur").pfValue,P=t.pstyle("shadow-opacity").value,S=t.pstyle("shadow-color").value,k=t.pstyle("shadow-offset-x").pfValue,T=t.pstyle("shadow-offset-y").pfValue;if(this.shadowStyle(e,S,P,_,k,T),e.lineJoin="miter",e.setLineDash)switch(E){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var D=t.pstyle("shape").strValue,C=t.pstyle("shape-polygon-points").pfValue;if(p){var M=D+"$"+a+"$"+o+("polygon"===D?"$"+C.join("$"):"");e.translate(c.x,c.y),l.pathCacheKey===M?(d=l.pathCache,f=!0):(d=new Path2D,l.pathCacheKey=M,l.pathCache=d)}if(!f){var N=c;p&&(N={x:0,y:0}),s.nodeShapes[this.getNodeShape(t)].draw(d||e,N.x,N.y,a,o)}p?e.fill(d):e.fill(),this.shadowStyle(e,"transparent",0),void 0!==m&&g.complete&&this.drawInscribedImage(e,g,t);var B=t.pstyle("background-blacken").value,z=t.pstyle("border-width").pfValue;if(this.hasPie(t)&&(this.drawPie(e,t,h),0===B&&0===z||p||s.nodeShapes[this.getNodeShape(t)].draw(e,c.x,c.y,a,o)),B>0?(this.fillStyle(e,0,0,0,B),p?e.fill(d):e.fill()):0>B&&(this.fillStyle(e,255,255,255,-B),p?e.fill(d):e.fill()),z>0&&(p?e.stroke(d):e.stroke(),"double"===E)){e.lineWidth=t.pstyle("border-width").pfValue/3;var I=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",p?e.stroke(d):e.stroke(),e.globalCompositeOperation=I}p&&e.translate(-c.x,-c.y),e.setLineDash&&e.setLineDash([]),s.drawElementText(e,t,i);var L=t.pstyle("overlay-padding").pfValue,O=t.pstyle("overlay-opacity").value,A=t.pstyle("overlay-color").value;O>0&&(this.fillStyle(e,A[0],A[1],A[2],O),s.nodeShapes.roundrectangle.draw(e,t._private.position.x,t._private.position.y,a+2*L,o+2*L),e.fill()),r&&e.translate(v.x1,v.y1)}},i.hasPie=function(e){return e=e[0],e._private.hasPie},i.drawPie=function(e,t,r,n){t=t[0];var i=t._private,a=t.cy().style(),o=t.pstyle("pie-size"),s=t.width(),l=t.height(),n=n||i.position,u=n.x,c=n.y,d=Math.min(s,l)/2,h=0,p=this.usePaths();p&&(u=0,c=0),"%"===o.units?d=d*o.value/100:void 0!==o.pfValue&&(d=o.pfValue/2);for(var f=1;f<=a.pieBackgroundN;f++){var v=t.pstyle("pie-"+f+"-background-size").value,g=t.pstyle("pie-"+f+"-background-color").value,y=t.pstyle("pie-"+f+"-background-opacity").value*r,m=v/100;m+h>1&&(m=1-h);var b=1.5*Math.PI+2*Math.PI*h,x=2*Math.PI*m,w=b+x;0===v||h>=1||h+m>1||(e.beginPath(),e.moveTo(u,c),e.arc(u,c,d,b,w),e.closePath(),this.fillStyle(e,g[0],g[1],g[2],y),e.fill(),h+=m)}},t.exports=i},{"../../../is":83}],70:[function(e,t,r){"use strict";var n={},i=e("../../../util"),a=100;n.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t},n.paintCache=function(e){for(var t,r=this.paintCaches=this.paintCaches||[],n=!0,i=0;i0?(e.shadowBlur=n*o,e.shadowColor="rgba("+t[0]+","+t[1]+","+t[2]+","+r+")",e.shadowOffsetX=i*o,e.shadowOffsetY=a*o):(e.shadowBlur=0,e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0)},n.matchCanvasSize=function(e){var t=this,r=t.data,n=e.clientWidth,i=e.clientHeight,a=t.getPixelRatio(),o=t.motionBlurPxRatio;e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE]&&e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG]||(a=o);var s,l=n*a,u=i*a;if(l!==t.canvasWidth||u!==t.canvasHeight){t.fontCaches=null;var c=r.canvasContainer;c.style.width=n+"px",c.style.height=i+"px";for(var d=0;d=a&&(s=r.bufferCanvases[t.TEXTURE_BUFFER],t.textureMult=2,s.width=l*t.textureMult,s.height=u*t.textureMult),t.canvasWidth=l,t.canvasHeight=u}},n.renderTo=function(e,t,r,n){this.render({forcedContext:e,forcedZoom:t,forcedPan:r,drawAllLayers:!0,forcedPxRatio:n})},n.render=function(e){function t(e,t,r,n,i){var a=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",c.fillStyle(e,255,255,255,c.motionBlurTransparency),e.fillRect(t,r,n,i),e.globalCompositeOperation=a}function r(e,r){var i,a,s,d;c.clearingMotionBlur||e!==p.bufferContexts[c.MOTIONBLUR_BUFFER_NODE]&&e!==p.bufferContexts[c.MOTIONBLUR_BUFFER_DRAG]?(i=k,a=P,s=c.canvasWidth,d=c.canvasHeight):(i={x:S.x*y,y:S.y*y},a=_*y,s=c.canvasWidth*y,d=c.canvasHeight*y),e.setTransform(1,0,0,1,0,0),"motionBlur"===r?t(e,0,0,s,d):n||void 0!==r&&!r||e.clearRect(0,0,s,d),o||(e.translate(i.x,i.y),e.scale(a,a)),u&&e.translate(u.x,u.y),l&&e.scale(l,l)}e=e||i.staticEmptyObject();var n=e.forcedContext,o=e.drawAllLayers,s=e.drawOnlyNodeLayer,l=e.forcedZoom,u=e.forcedPan,c=this,d=void 0===e.forcedPxRatio?this.getPixelRatio():e.forcedPxRatio,h=c.cy,p=c.data,f=p.canvasNeedsRedraw,v=c.textureOnViewport&&!n&&(c.pinching||c.hoverData.dragging||c.swipePanning||c.data.wheelZooming),g=void 0!==e.motionBlur?e.motionBlur:c.motionBlur,y=c.motionBlurPxRatio,m=h.hasCompoundNodes(),b=c.hoverData.draggingEles,x=!(!c.hoverData.selecting&&!c.touchData.selecting);g=g&&!n&&c.motionBlurEnabled&&!x;var w=g;n||(c.prevPxRatio!==d&&(c.invalidateContainerClientCoordsCache(),c.matchCanvasSize(c.container),c.redrawHint("eles",!0),c.redrawHint("drag",!0)),c.prevPxRatio=d),!n&&c.motionBlurTimeout&&clearTimeout(c.motionBlurTimeout),g&&(null==c.mbFrames&&(c.mbFrames=0),c.drawingImage||c.mbFrames++,c.mbFrames<3&&(w=!1),c.mbFrames>c.minMbLowQualFrames&&(c.motionBlurPxRatio=c.mbPxRBlurry)),c.clearingMotionBlur&&(c.motionBlurPxRatio=1),c.textureDrawLastFrame&&!v&&(f[c.NODE]=!0,f[c.SELECT_BOX]=!0);var E=h.style()._private.coreStyle,_=h.zoom(),P=void 0!==l?l:_,S=h.pan(),k={x:S.x,y:S.y},T={zoom:_,pan:{x:S.x,y:S.y}},D=c.prevViewport,C=void 0===D||T.zoom!==D.zoom||T.pan.x!==D.pan.x||T.pan.y!==D.pan.y;C||b&&!m||(c.motionBlurPxRatio=1),u&&(k=u),P*=d,k.x*=d,k.y*=d;var M=c.getCachedZSortedEles();if(v||(c.textureDrawLastFrame=!1),v){c.textureDrawLastFrame=!0;var N;if(!c.textureCache){c.textureCache={},N=c.textureCache.bb=h.mutableElements().boundingBox(),c.textureCache.texture=c.data.bufferCanvases[c.TEXTURE_BUFFER];var B=c.data.bufferContexts[c.TEXTURE_BUFFER];B.setTransform(1,0,0,1,0,0),B.clearRect(0,0,c.canvasWidth*c.textureMult,c.canvasHeight*c.textureMult),c.render({forcedContext:B,drawOnlyNodeLayer:!0,forcedPxRatio:d*c.textureMult});var T=c.textureCache.viewport={zoom:h.zoom(),pan:h.pan(),width:c.canvasWidth,height:c.canvasHeight};T.mpan={x:(0-T.pan.x)/T.zoom,y:(0-T.pan.y)/T.zoom}}f[c.DRAG]=!1,f[c.NODE]=!1;var z=p.contexts[c.NODE],I=c.textureCache.texture,T=c.textureCache.viewport;N=c.textureCache.bb,z.setTransform(1,0,0,1,0,0),g?t(z,0,0,T.width,T.height):z.clearRect(0,0,T.width,T.height);var L=E["outside-texture-bg-color"].value,O=E["outside-texture-bg-opacity"].value;c.fillStyle(z,L[0],L[1],L[2],O),z.fillRect(0,0,T.width,T.height);var _=h.zoom();r(z,!1),z.clearRect(T.mpan.x,T.mpan.y,T.width/T.zoom/d,T.height/T.zoom/d),z.drawImage(I,T.mpan.x,T.mpan.y,T.width/T.zoom/d,T.height/T.zoom/d)}else c.textureOnViewport&&!n&&(c.textureCache=null);var A=h.extent(),R=c.pinching||c.hoverData.dragging||c.swipePanning||c.data.wheelZooming||c.hoverData.draggingEles,q=c.hideEdgesOnViewport&&R,V=[];if(V[c.NODE]=!f[c.NODE]&&g&&!c.clearedForMotionBlur[c.NODE]||c.clearingMotionBlur,V[c.NODE]&&(c.clearedForMotionBlur[c.NODE]=!0),V[c.DRAG]=!f[c.DRAG]&&g&&!c.clearedForMotionBlur[c.DRAG]||c.clearingMotionBlur,V[c.DRAG]&&(c.clearedForMotionBlur[c.DRAG]=!0),f[c.NODE]||o||s||V[c.NODE]){var F=g&&!V[c.NODE]&&1!==y,z=n||(F?c.data.bufferContexts[c.MOTIONBLUR_BUFFER_NODE]:p.contexts[c.NODE]),j=g&&!F?"motionBlur":void 0;r(z,j),q?c.drawCachedNodes(z,M.nondrag,d,A):c.drawLayeredElements(z,M.nondrag,d,A),o||g||(f[c.NODE]=!1)}if(!s&&(f[c.DRAG]||o||V[c.DRAG])){var F=g&&!V[c.DRAG]&&1!==y,z=n||(F?c.data.bufferContexts[c.MOTIONBLUR_BUFFER_DRAG]:p.contexts[c.DRAG]);r(z,g&&!F?"motionBlur":void 0),q?c.drawCachedNodes(z,M.drag,d,A):c.drawCachedElements(z,M.drag,d,A),o||g||(f[c.DRAG]=!1)}if(c.showFps||!s&&f[c.SELECT_BOX]&&!o){var z=n||p.contexts[c.SELECT_BOX];if(r(z),1==c.selection[4]&&(c.hoverData.selecting||c.touchData.selecting)){var _=c.cy.zoom(),X=E["selection-box-border-width"].value/_;z.lineWidth=X,z.fillStyle="rgba("+E["selection-box-color"].value[0]+","+E["selection-box-color"].value[1]+","+E["selection-box-color"].value[2]+","+E["selection-box-opacity"].value+")",z.fillRect(c.selection[0],c.selection[1],c.selection[2]-c.selection[0],c.selection[3]-c.selection[1]),X>0&&(z.strokeStyle="rgba("+E["selection-box-border-color"].value[0]+","+E["selection-box-border-color"].value[1]+","+E["selection-box-border-color"].value[2]+","+E["selection-box-opacity"].value+")",z.strokeRect(c.selection[0],c.selection[1],c.selection[2]-c.selection[0],c.selection[3]-c.selection[1]))}if(p.bgActivePosistion&&!c.hoverData.selecting){var _=c.cy.zoom(),Y=p.bgActivePosistion;z.fillStyle="rgba("+E["active-bg-color"].value[0]+","+E["active-bg-color"].value[1]+","+E["active-bg-color"].value[2]+","+E["active-bg-opacity"].value+")",z.beginPath(),z.arc(Y.x,Y.y,E["active-bg-size"].pfValue/_,0,2*Math.PI),z.fill()}var W=c.lastRedrawTime;if(c.showFps&&W){W=Math.round(W);var $=Math.round(1e3/W);z.setTransform(1,0,0,1,0,0),z.fillStyle="rgba(255, 0, 0, 0.75)",z.strokeStyle="rgba(255, 0, 0, 0.75)",z.lineWidth=1,z.fillText("1 frame = "+W+" ms = "+$+" fps",0,20);var H=60;z.strokeRect(0,30,250,20),z.fillRect(0,30,250*Math.min($/H,1),20)}o||(f[c.SELECT_BOX]=!1)}if(g&&1!==y){var U=p.contexts[c.NODE],Z=c.data.bufferCanvases[c.MOTIONBLUR_BUFFER_NODE],G=p.contexts[c.DRAG],Q=c.data.bufferCanvases[c.MOTIONBLUR_BUFFER_DRAG],K=function(e,r,n){e.setTransform(1,0,0,1,0,0),n||!w?e.clearRect(0,0,c.canvasWidth,c.canvasHeight):t(e,0,0,c.canvasWidth,c.canvasHeight);var i=y;e.drawImage(r,0,0,c.canvasWidth*i,c.canvasHeight*i,0,0,c.canvasWidth,c.canvasHeight)};(f[c.NODE]||V[c.NODE])&&(K(U,Z,V[c.NODE]),f[c.NODE]=!1),(f[c.DRAG]||V[c.DRAG])&&(K(G,Q,V[c.DRAG]),f[c.DRAG]=!1)}c.prevViewport=T,c.clearingMotionBlur&&(c.clearingMotionBlur=!1,c.motionBlurCleared=!0,c.motionBlur=!0),g&&(c.motionBlurTimeout=setTimeout(function(){c.motionBlurTimeout=null,c.clearedForMotionBlur[c.NODE]=!1,c.clearedForMotionBlur[c.DRAG]=!1,c.motionBlur=!1,c.clearingMotionBlur=!v,c.mbFrames=0,f[c.NODE]=!0,f[c.DRAG]=!0,c.redraw()},a)),c.drawingImage=!1,n||c.initrender||(c.initrender=!0,h.trigger("initrender")),n||h.trigger("render")},t.exports=n},{"../../../util":100}],71:[function(e,t,r){"use strict";var n=e("../../../math"),i={};i.drawPolygonPath=function(e,t,r,n,i,a){var o=n/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],r+s*a[1]);for(var l=1;li)i=u;else if(y>=d||i>c)return null;var m=Math.pow(2,i),w=t.h*m,E=t.w*m,_=g.imgCaches=g.imgCaches||{},P=_[i];if(P)return P;var S;if(S=s>=w?s:l>=w?l:Math.ceil(w/l)*l,w>v||E>f||!b&&e.isEdge()||!x&&e.isParent())return null;var k=o.getTextureQueue(S),D=k[k.length-2],C=function(){return o.recycleTexture(S,E)||o.addTexture(S,E)};D||(D=k[k.length-1]),D||(D=C()),D.width-D.usedWidth=O;O++){var A=_[O];if(A){M=A;break}}var R=M&&M.level===i+1?M:null,q=function(){D.context.drawImage(R.texture.canvas,R.x,0,R.width,R.height,D.usedWidth,0,E,w)};if(B(R))q();else if(B(M)){if(!I)return o.queueElement(e,t,M.level-1),M;for(var O=M.level;O>i;O--)R=o.getElement(e,t,r,O,T.downscale);q()}else{var V;if(!z&&!I&&!L)for(var O=i-1;O>=u;O--){var A=_[O];if(A){V=A;break}}if(B(V))return o.queueElement(e,t,i),V;D.context.translate(D.usedWidth,0),D.context.scale(m,m),p.drawElement(D.context,e,t,N),D.context.scale(1/m,1/m),D.context.translate(-D.usedWidth,0)}return P=_[i]={ele:e,x:D.usedWidth,texture:D,level:i,scale:m,width:E,height:w,scaledLabelShown:N},D.usedWidth+=Math.ceil(E+h),D.eleCaches.push(P),o.checkTextureFullness(D),P},C.invalidateElement=function(e){var t=this,r=e._private.rscratch.imgCaches;if(r)for(var n=u;c>=n;n++){var a=r[n];if(a){var o=a.texture;o.invalidatedWidth+=a.width,r[n]=null,i.removeFromArray(o.eleCaches,a),t.checkTextureUtility(o)}}},C.checkTextureUtility=function(e){e.invalidatedWidth>=g*e.width&&this.retireTexture(e)},C.checkTextureFullness=function(e){var t=this,r=t.getTextureQueue(e.height);e.usedWidth/e.width>y&&e.fullnessChecks>=m?i.removeFromArray(r,e):e.fullnessChecks++},C.retireTexture=function(e){var t=this,r=e.height,n=t.getTextureQueue(r);i.removeFromArray(n,e),e.retired=!0;for(var a=e.eleCaches,o=0;o=t)return s.retired=!1,s.usedWidth=0,s.invalidatedWidth=0,s.fullnessChecks=0,i.clearArray(s.eleCaches),s.context.clearRect(0,0,s.width,s.height),i.removeFromArray(a,s),n.push(s),s}},C.queueElement=function(e,t,r){var i=this,a=i.getElementQueue(),o=i.getElementIdToQueue(),s=e.id(),l=o[s];if(l)l.level=Math.max(l.level,r),l.reqs++,a.updateItem(l);else{var u={ele:e,bb:t,position:n.copyPosition(e.position()),level:r,reqs:1};e.isEdge()&&(u.positions={source:n.copyPosition(e.source().position()),target:n.copyPosition(e.target().position())}),a.push(u),o[s]=u}},C.dequeue=function(e,t){for(var r=this,i=r.getElementQueue(),a=r.getElementIdToQueue(),o=[],s=0;k>s&&i.size()>0;s++){var l=i.pop();a[l.ele.id()]=null,o.push(l);var u,c=l.ele;u=(!c.isEdge()||n.arePositionsSame(c.source().position(),l.positions.source)&&n.arePositionsSame(c.target().position(),l.positions.target))&&n.arePositionsSame(c.position(),l.position)?l.bb:c.boundingBox(),r.getElement(l.ele,u,e,l.level,T.dequeue)}return o},C.onDequeue=function(e){this.onDequeues.push(e)},C.offDequeue=function(e){i.removeFromArray(this.onDequeues,e)},C.setupDequeueing=o.setupDequeueing({deqRedrawThreshold:S,deqCost:w,deqAvgCost:E,deqNoDrawCost:_,deqFastCost:P,deq:function(e,t,r){return e.dequeue(t,r)},onDeqd:function(e,t){for(var r=0;r0&&o>0){p.clearRect(0,0,a,o),e.bg&&(p.fillStyle=e.bg,p.rect(0,0,a,o),p.fill()),p.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)p.translate(-i.x1*u,-i.y1*u),p.scale(u,u),this.drawElements(p,f);else{var v=t.pan(),g={x:v.x*u,y:v.y*u};u*=t.zoom(),p.translate(g.x,g.y),p.scale(u,u),this.drawElements(p,f)}}return h},i.png=function(e){return this.bufferCanvasImage(e).toDataURL("image/png")},i.jpg=function(e){return this.bufferCanvasImage(e).toDataURL("image/jpeg")},t.exports=i},{"../../../is":83}],74:[function(e,t,r){"use strict";function n(e){var t=this;t.data={canvases:new Array(u.CANVAS_LAYERS),contexts:new Array(u.CANVAS_LAYERS),canvasNeedsRedraw:new Array(u.CANVAS_LAYERS),bufferCanvases:new Array(u.BUFFER_COUNT),bufferContexts:new Array(u.CANVAS_LAYERS)},t.data.canvasContainer=document.createElement("div");var r=t.data.canvasContainer.style;t.data.canvasContainer.setAttribute("style","-webkit-tap-highlight-color: rgba(0,0,0,0);"),r.position="relative",r.zIndex="0",r.overflow="hidden";var n=e.cy.container();n.appendChild(t.data.canvasContainer),n.setAttribute("style",(n.getAttribute("style")||"")+"-webkit-tap-highlight-color: rgba(0,0,0,0);");for(var i=0;i0&&t.data.lyrTxrCache.invalidateElements(r)})}var i=e("../../../util"),a=e("../../../is"),o=e("./ele-texture-cache"),s=e("./layered-texture-cache"),l=n,u=n.prototype;u.CANVAS_LAYERS=3,u.SELECT_BOX=0,u.DRAG=1,u.NODE=2,u.BUFFER_COUNT=3,u.TEXTURE_BUFFER=0,u.MOTIONBLUR_BUFFER_NODE=1,u.MOTIONBLUR_BUFFER_DRAG=2,u.redrawHint=function(e,t){var r=this;switch(e){case"eles":r.data.canvasNeedsRedraw[u.NODE]=t;break;case"drag":r.data.canvasNeedsRedraw[u.DRAG]=t;break;case"select":r.data.canvasNeedsRedraw[u.SELECT_BOX]=t}};var c="undefined"!=typeof Path2D;u.path2dEnabled=function(e){return void 0===e?this.pathsEnabled:void(this.pathsEnabled=!!e)},u.usePaths=function(){return c&&this.pathsEnabled},[e("./arrow-shapes"),e("./drawing-elements"),e("./drawing-edges"),e("./drawing-images"),e("./drawing-label-text"),e("./drawing-nodes"),e("./drawing-redraw"),e("./drawing-shapes"),e("./export-image"),e("./node-shapes")].forEach(function(e){i.extend(u,e)}),t.exports=l},{"../../../is":83,"../../../util":100,"./arrow-shapes":64,"./drawing-edges":65,"./drawing-elements":66,"./drawing-images":67,"./drawing-label-text":68,"./drawing-nodes":69,"./drawing-redraw":70,"./drawing-shapes":71,"./ele-texture-cache":72,"./export-image":73,"./layered-texture-cache":75,"./node-shapes":76}],75:[function(e,t,r){"use strict";function n(e,t){null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled=t:(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t)}var i=e("../../../util"),a=e("../../../math"),o=e("../../../heap"),s=e("../../../is"),l=e("./texture-cache-defs"),u=1,c=-4,d=2,h=3.99,p=50,f=50,v=!0,g=.15,y=.1,m=.9,b=.9,x=1,w=250,E=16e6,_=!0,P=!0,S=!0,k=function(e,t){var r=this,n=r.renderer=e;r.layersByLevel={},r.firstGet=!0,r.lastInvalidationTime=i.performanceNow()-2*w,r.skipping=!1,n.beforeRender(function(e,t){t-r.lastInvalidationTime<=w?r.skipping=!0:r.skipping=!1});var a=function(e,t){return t.reqs-e.reqs};r.layersQueue=new o(a),r.eleTxrCache=t,r.setupEleCacheInvalidation(),r.setupDequeueing()},T=k.prototype,D=0,C=Math.pow(2,53)-1;T.makeLayer=function(e,t){var r=Math.pow(2,t),n=Math.ceil(e.w*r),i=Math.ceil(e.h*r),a=document.createElement("canvas");a.width=n,a.height=i;var o={id:D=++D%C,bb:e,level:t,width:n,height:i,canvas:a,context:a.getContext("2d"),eles:[],elesQueue:[],reqs:0},s=o.context,l=-o.bb.x1,u=-o.bb.y1;return s.scale(r,r),s.translate(l,u),o},T.getLayers=function(e,t,r){var n=this,o=n.renderer,s=o.cy,l=s.zoom(),p=n.firstGet;if(n.firstGet=!1,null==r)if(r=Math.ceil(a.log2(l*t)),c>r)r=c;else if(l>=h||r>d)return null;n.validateLayersElesOrdering(r,e);var f,v,g=n.layersByLevel,y=Math.pow(2,r),m=g[r]=g[r]||[],b=n.levelIsComplete(r,e),x=function(){var t=function(t){return n.validateLayersElesOrdering(t,e),n.levelIsComplete(t,e)?(v=g[t],!0):void 0},a=function(e){if(!v)for(var n=r+e;n>=c&&d>=n&&!t(n);n+=e);};a(1),a(-1);for(var o=m.length-1;o>=0;o--){var s=m[o];s.invalid&&i.removeFromArray(m,s)}};if(b)return m;x();var w=function(){if(!f){f=a.makeBoundingBox();for(var t=0;tE)return null;var a=n.makeLayer(f,r);if(null!=t){var o=m.indexOf(t)+1;m.splice(o,0,a)}else(void 0===e.insert||e.insert)&&m.unshift(a);return a};if(n.skipping&&!p)return null;for(var S=null,k=e.length/u,T=_&&!p,D=0;D=k||u>1&&!a.boundingBoxInBoundingBox(S.bb,C.boundingBox()))&&(S=P({insert:!0,after:S}),!S))return null;v||T?n.queueLayer(S,C):n.drawEleInLayer(S,C,r,t),S.eles.push(C),N[r]=S}}return v?v:T?null:m},T.getEleLevelForLayerLevel=function(e,t){return e},T.drawEleInLayer=function(e,t,r,i){var a=this,o=this.renderer,s=e.context,l=t.boundingBox();if(0!==l.w&&0!==l.h){var u=a.eleTxrCache,c=P?u.reasons.highQuality:void 0;r=a.getEleLevelForLayerLevel(r,i);var d=S?u.getElement(t,l,null,r,c):null;d?(v&&n(s,!1),s.drawImage(d.texture.canvas,d.x,0,d.width,d.height,l.x1,l.y1,l.w,l.h),v&&n(s,!0)):o.drawElement(s,t)}},T.levelIsComplete=function(e,t){var r=this,n=r.layersByLevel[e];if(!n||0===n.length)return!1;for(var i=0,a=0;a0)return!1;if(o.invalid)return!1;i+=o.eles.length}return i===t.length},T.validateLayersElesOrdering=function(e,t){var r=this.layersByLevel[e];if(r)for(var n=0;na)this.invalidateLayer(i);else for(var s=a,o=0;o=h;h++){var p=u[h];p&&(a&&r.getEleLevelForLayerLevel(p.level)!==a.level||t(p,o,a))}},T.haveLayers=function(){for(var e=this,t=!1,r=c;d>=r;r++){var n=e.layersByLevel[r];if(n&&n.length>0){t=!0;break}}return t},T.invalidateElements=function(e){var t=this;t.lastInvalidationTime=i.performanceNow(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,r,n){t.invalidateLayer(e)})},T.invalidateLayer=function(e){if(this.lastInvalidationTime=i.performanceNow(),!e.invalid){var t=e.level,r=e.eles,n=this.layersByLevel[t];i.removeFromArray(n,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var a=0;ai&&0!==r.size();){var a=r.peek();if(a.replacement)r.pop();else if(a.replaces&&a!==a.replaces.replacement)r.pop();else if(a.invalid)r.pop();else{var o=a.elesQueue.shift();o&&(t.drawEleInLayer(a,o,a.level,e),i++),0===n.length&&n.push(!0),0===a.elesQueue.length&&(r.pop(),a.reqs=0,a.replaces&&t.applyLayerReplacement(a),t.requestRedraw())}}return n},T.applyLayerReplacement=function(e){var t=this,r=t.layersByLevel[e.level],n=e.replaces,i=r.indexOf(n);if(!(0>i||n.invalid)){r[i]=e;for(var a=0;ac){var y=i-(o?u:0);if(g>=e.deqFastCost*y)break}else if(o){if(v>=e.deqCost*c||v>=e.deqAvgCost*u)break}else if(g>=e.deqNoDrawCost*i)break;var m=e.deq(t,p,h);if(!(m.length>0))break;for(var b=0;b0&&(e.onDeqd(t,d),!o&&e.shouldRedraw(t,d,p,h)&&a())},s=e.priority||n.noop;r.beforeRender(o,s(t))}}}}},{"../../../util":100}],78:[function(e,t,r){"use strict";t.exports=[{name:"null",impl:e("./null")},{name:"base",impl:e("./base")},{name:"canvas",impl:e("./canvas")}]},{"./base":60,"./canvas":74,"./null":79}],79:[function(e,t,r){"use strict";function n(e){this.options=e,this.notifications=0}var i=function(){};n.prototype={recalculateRenderedStyle:i,notify:function(){this.notifications++},init:i},t.exports=n},{}],80:[function(e,t,r){/*! Weaver licensed under MIT (https://tldrlegal.com/license/mit-license), copyright Max Franz */
-"use strict";var n=e("./is"),i=e("./util"),a=e("./thread"),o=e("./promise"),s=e("./define"),l=function(t){if(!(this instanceof l))return new l(t);this._private={pass:[]};var r=4;if(n.number(t),"undefined"!=typeof navigator&&null!=navigator.hardwareConcurrency)t=navigator.hardwareConcurrency;else try{t=e("os").cpus().length}catch(i){t=r}for(var o=0;t>o;o++)this[o]=new a;this.length=t},u=l.prototype;i.extend(u,{instanceString:function(){return"fabric"},require:function(e,t){for(var r=0;re?-1:e>t?1:0},t.require(e,"_$_$_cmp"),t.spread(function(e){var t=e.sort(_$_$_cmp);resolve(t)}).then(function(t){for(var i=function(n,i,a){i=Math.min(i,r),a=Math.min(a,r);for(var o=n,s=i,l=[],u=o;a>u;u++){var c=t[n],d=t[i];s>n&&(i>=a||e(c,d)<=0)?(l.push(c),n++):(l.push(d),i++)}for(var u=0;ua;a*=2)for(var o=0;r>o;o+=2*a)i(o,o+a,o+2*a);return t})}});var c=function(e){return e=e||{},function(t,r){var n=this._private.pass.shift();return this.random().pass(n)[e.threadFn](t,r)}};i.extend(u,{randomMap:c({threadFn:"map"}),reduce:c({threadFn:"reduce"}),reduceRight:c({threadFn:"reduceRight"})});var d=u;d.promise=d.run,d.terminate=d.halt=d.stop,d.include=d.require,i.extend(u,{on:s.on(),one:s.on({unbindSelfOnTrigger:!0}),off:s.off(),trigger:s.trigger()}),s.eventAliasesOn(u),t.exports=l},{"./define":44,"./is":83,"./promise":86,"./thread":98,"./util":100,os:void 0}],81:[function(e,t,r){/*!
-Ported by Xueqiao Xu ;
-
-PSF LICENSE AGREEMENT FOR PYTHON 2.7.2
-
-1. This LICENSE AGREEMENT is between the Python Software Foundation (“PSF”), and the Individual or Organization (“Licensee”) accessing and otherwise using Python 2.7.2 software in source or binary form and its associated documentation.
-2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python 2.7.2 alone or in any derivative version, provided, however, that PSF’s License Agreement and PSF’s notice of copyright, i.e., “Copyright © 2001-2012 Python Software Foundation; All Rights Reserved” are retained in Python 2.7.2 alone or in any derivative version prepared by Licensee.
-3. In the event Licensee prepares a derivative work that is based on or incorporates Python 2.7.2 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python 2.7.2.
-4. PSF is making Python 2.7.2 available to Licensee on an “AS IS” basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.7.2 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
-5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 2.7.2 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.7.2, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
-6. This License Agreement will automatically terminate upon a material breach of its terms and conditions.
-7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party.
-8. By copying, installing or otherwise using Python 2.7.2, Licensee agrees to be bound by the terms and conditions of this License Agreement.
-*/
-"use strict";var n,i,a,o,s,l,u,c,d,h,p,f,v,g,y;a=Math.floor,h=Math.min,i=function(e,t){return t>e?-1:e>t?1:0},d=function(e,t,r,n,o){var s;if(null==r&&(r=0),null==o&&(o=i),0>r)throw new Error("lo must be non-negative");for(null==n&&(n=e.length);n>r;)s=a((r+n)/2),o(t,e[s])<0?n=s:r=s+1;return[].splice.apply(e,[r,r-r].concat(t)),t},l=function(e,t,r){return null==r&&(r=i),e.push(t),g(e,0,e.length-1,r)},s=function(e,t){var r,n;return null==t&&(t=i),r=e.pop(),e.length?(n=e[0],e[0]=r,y(e,0,t)):n=r,n},c=function(e,t,r){var n;return null==r&&(r=i),n=e[0],e[0]=t,y(e,0,r),n},u=function(e,t,r){var n;return null==r&&(r=i),e.length&&r(e[0],t)<0&&(n=[e[0],t],t=n[0],e[0]=n[1],y(e,0,r)),t},o=function(e,t){var r,n,o,s,l,u;for(null==t&&(t=i),s=function(){u=[];for(var t=0,r=a(e.length/2);r>=0?r>t:t>r;r>=0?t++:t--)u.push(t);return u}.apply(this).reverse(),l=[],n=0,o=s.length;o>n;n++)r=s[n],l.push(y(e,r,t));return l},v=function(e,t,r){var n;return null==r&&(r=i),n=e.indexOf(t),-1!==n?(g(e,0,n,r),y(e,n,r)):void 0},p=function(e,t,r){var n,a,s,l,c;if(null==r&&(r=i),a=e.slice(0,t),!a.length)return a;for(o(a,r),c=e.slice(t),s=0,l=c.length;l>s;s++)n=c[s],u(a,n,r);return a.sort(r).reverse()},f=function(e,t,r){var n,a,l,u,c,p,f,v,g,y;if(null==r&&(r=i),10*t<=e.length){if(u=e.slice(0,t).sort(r),!u.length)return u;for(l=u[u.length-1],v=e.slice(t),c=0,f=v.length;f>c;c++)n=v[c],r(n,l)<0&&(d(u,n,0,null,r),u.pop(),l=u[u.length-1]);return u}for(o(e,r),y=[],a=p=0,g=h(t,e.length);g>=0?g>p:p>g;a=g>=0?++p:--p)y.push(s(e,r));return y},g=function(e,t,r,n){var a,o,s;for(null==n&&(n=i),a=e[r];r>t&&(s=r-1>>1,o=e[s],n(a,o)<0);)e[r]=o,r=s;return e[r]=a},y=function(e,t,r){var n,a,o,s,l;for(null==r&&(r=i),a=e.length,l=t,o=e[t],n=2*t+1;a>n;)s=n+1,a>s&&!(r(e[n],e[s])<0)&&(n=s),e[t]=e[n],t=n,n=2*t+1;return e[t]=o,g(e,l,t,r)},n=function(){function e(e){this.cmp=null!=e?e:i,this.nodes=[]}return e.push=l,e.pop=s,e.replace=c,e.pushpop=u,e.heapify=o,e.updateItem=v,e.nlargest=p,e.nsmallest=f,e.prototype.push=function(e){return l(this.nodes,e,this.cmp)},e.prototype.pop=function(){return s(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return c(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return u(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return o(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return v(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return t=new e,t.nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),t.exports=n},{}],82:[function(e,t,r){"use strict";e("./-preamble");var n=e("./window"),i=e("./is"),a=e("./core"),o=e("./extension"),s=e("./jquery-plugin"),l=e("./stylesheet"),u=e("./thread"),c=e("./fabric"),d=function(e){return void 0===e&&(e={}),i.plainObject(e)?new a(e):i.string(e)?o.apply(o,arguments):void 0};d.version=e("./version.json"),n&&n.jQuery&&s(n.jQuery,d),d.registerJquery=function(e){s(e,d)},d.stylesheet=d.Stylesheet=l,d.thread=d.Thread=u,d.fabric=d.Fabric=c,t.exports=d},{"./-preamble":1,"./core":37,"./extension":46,"./fabric":80,"./is":83,"./jquery-plugin":84,"./stylesheet":97,"./thread":98,"./version.json":106,"./window":107}],83:[function(e,t,r){"use strict";var n=e("./window"),i=n?n.navigator:null,a=n?n.document:null,o="string",s=typeof{},l="function",u=typeof HTMLElement,c=function(e){return e&&e.instanceString&&d.fn(e.instanceString)?e.instanceString():null},d={defined:function(e){return null!=e},string:function(e){return null!=e&&typeof e==o},fn:function(e){return null!=e&&typeof e===l},array:function(e){return Array.isArray?Array.isArray(e):null!=e&&e instanceof Array},plainObject:function(e){return null!=e&&typeof e===s&&!d.array(e)&&e.constructor===Object},object:function(e){return null!=e&&typeof e===s},number:function(e){return null!=e&&"number"==typeof e&&!isNaN(e)},integer:function(e){return d.number(e)&&Math.floor(e)===e},bool:function(e){return null!=e&&typeof e==typeof!0},htmlElement:function(e){return"undefined"===u?void 0:null!=e&&e instanceof HTMLElement},elementOrCollection:function(e){return d.element(e)||d.collection(e)},element:function(e){return"collection"===c(e)&&e._private.single},collection:function(e){return"collection"===c(e)&&!e._private.single},core:function(e){return"core"===c(e)},style:function(e){return"style"===c(e)},stylesheet:function(e){return"stylesheet"===c(e)},event:function(e){return"event"===c(e)},thread:function(e){return"thread"===c(e)},fabric:function(e){return"fabric"===c(e)},emptyString:function(e){return void 0===e||null===e?!0:!(""!==e&&!e.match(/^\s+$/))},nonemptyString:function(e){return!(!e||!d.string(e)||""===e||e.match(/^\s+$/))},domElement:function(e){return"undefined"==typeof HTMLElement?!1:e instanceof HTMLElement},boundingBox:function(e){return d.plainObject(e)&&d.number(e.x1)&&d.number(e.x2)&&d.number(e.y1)&&d.number(e.y2)},promise:function(e){return d.object(e)&&d.fn(e.then)},touch:function(){return n&&("ontouchstart"in n||n.DocumentTouch&&a instanceof DocumentTouch)},gecko:function(){return n&&("undefined"!=typeof InstallTrigger||"MozAppearance"in a.documentElement.style)},webkit:function(){return n&&("undefined"!=typeof webkitURL||"WebkitAppearance"in a.documentElement.style)},chromium:function(){return n&&"undefined"!=typeof chrome},khtml:function(){return i&&i.vendor.match(/kde/i)},khtmlEtc:function(){return d.khtml()||d.webkit()||d.chromium()},ms:function(){return i&&i.userAgent.match(/msie|trident|edge/i)},windows:function(){return i&&i.appVersion.match(/Win/i)},mac:function(){return i&&i.appVersion.match(/Mac/i)},linux:function(){return i&&i.appVersion.match(/Linux/i)},unix:function(){return i&&i.appVersion.match(/X11/i)}};t.exports=d},{"./window":107}],84:[function(e,t,r){"use strict";var n=e("./is"),i=function(e){var t=e[0]._cyreg=e[0]._cyreg||{};return t},a=function(e,t){e&&(e.fn.cytoscape||(e.fn.cytoscape=function(r){var a=e(this);if("get"===r)return i(a).cy;if(n.fn(r)){var o=r,s=i(a).cy;if(s&&s.isReady())s.trigger("ready",[],o);else{var l=i(a),u=l.readies=l.readies||[];u.push(o)}}else if(n.plainObject(r))return a.each(function(){var n=e.extend({},r,{container:e(this)[0]});t(n)})},e.cytoscape=t,null==e.fn.cy&&null==e.cy&&(e.fn.cy=e.fn.cytoscape,e.cy=e.cytoscape)))};t.exports=a},{"./is":83}],85:[function(e,t,r){"use strict";var n={};n.arePositionsSame=function(e,t){return e.x===t.x&&e.y===t.y},n.copyPosition=function(e){return{x:e.x,y:e.y}},n.array2point=function(e){return{x:e[0],y:e[1]}},n.deg2rad=function(e){return Math.PI*e/180},n.log2=Math.log2||function(e){return Math.log(e)/Math.log(2)},n.signum=function(e){return e>0?1:0>e?-1:0},n.dist=function(e,t){return Math.sqrt(n.sqdist(e,t))},n.sqdist=function(e,t){var r=t.x-e.x,n=t.y-e.y;return r*r+n*n},n.qbezierAt=function(e,t,r,n){return(1-n)*(1-n)*e+2*(1-n)*n*t+n*n*r},n.qbezierPtAt=function(e,t,r,i){return{x:n.qbezierAt(e.x,t.x,r.x,i),y:n.qbezierAt(e.y,t.y,r.y,i)}},n.lineAt=function(e,t,r,i){var a={x:t.x-e.x,y:t.y-e.y},o=n.dist(e,t),s={x:a.x/o,y:a.y/o};r=null==r?0:r;var i=null!=i?i:r*o;return{x:e.x+s.x*i,y:e.y+s.y*i}},n.lineAtDist=function(e,t,r){return n.lineAt(e,t,void 0,r)},n.triangleAngle=function(e,t,r){var i=n.dist(t,r),a=n.dist(e,r),o=n.dist(e,t);return Math.acos((i*i+a*a-o*o)/(2*i*a))},n.bound=function(e,t,r){return Math.max(e,Math.min(r,t))},n.makeBoundingBox=function(e){if(null==e)return{x1:1/0,y1:1/0,x2:-(1/0),y2:-(1/0),w:0,h:0};if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},n.updateBoundingBox=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},n.expandBoundingBox=function(e,t){return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},n.boundingBoxesIntersect=function(e,t){return e.x1>t.x2?!1:t.x1>e.x2?!1:e.x2t.y2?!1:!(t.y1>e.y2)},n.inBoundingBox=function(e,t,r){return e.x1<=t&&t<=e.x2&&e.y1<=r&&r<=e.y2},n.pointInBoundingBox=function(e,t){return this.inBoundingBox(e,t.x,t.y)},n.boundingBoxInBoundingBox=function(e,t){return n.inBoundingBox(e,t.x1,t.y1)&&n.inBoundingBox(e,t.x2,t.y2)},n.roundRectangleIntersectLine=function(e,t,r,n,i,a,o){var s,l=this.getRoundRectangleRadius(i,a),u=i/2,c=a/2,d=r-u+l-o,h=n-c-o,p=r+u-l+o,f=h;if(s=this.finiteLinesIntersect(e,t,r,n,d,h,p,f,!1),s.length>0)return s;var v=r+u+o,g=n-c+l-o,y=v,m=n+c-l+o;if(s=this.finiteLinesIntersect(e,t,r,n,v,g,y,m,!1),s.length>0)return s;var b=r-u+l-o,x=n+c+o,w=r+u-l+o,E=x;if(s=this.finiteLinesIntersect(e,t,r,n,b,x,w,E,!1),s.length>0)return s;var _=r-u-o,P=n-c+l-o,S=_,k=n+c-l+o;if(s=this.finiteLinesIntersect(e,t,r,n,_,P,S,k,!1),s.length>0)return s;var T,D=r-u+l,C=n-c+l;if(T=this.intersectLineCircle(e,t,r,n,D,C,l+o),T.length>0&&T[0]<=D&&T[1]<=C)return[T[0],T[1]];var M=r+u-l,N=n-c+l;if(T=this.intersectLineCircle(e,t,r,n,M,N,l+o),T.length>0&&T[0]>=M&&T[1]<=N)return[T[0],T[1]];var B=r+u-l,z=n+c-l;if(T=this.intersectLineCircle(e,t,r,n,B,z,l+o),T.length>0&&T[0]>=B&&T[1]>=z)return[T[0],T[1]];var I=r-u+l,L=n+c-l;return T=this.intersectLineCircle(e,t,r,n,I,L,l+o),T.length>0&&T[0]<=I&&T[1]>=L?[T[0],T[1]]:[]},n.inLineVicinity=function(e,t,r,n,i,a,o){var s=o,l=Math.min(r,i),u=Math.max(r,i),c=Math.min(n,a),d=Math.max(n,a);return e>=l-s&&u+s>=e&&t>=c-s&&d+s>=t},n.inBezierVicinity=function(e,t,r,n,i,a,o,s,l){var u={x1:Math.min(r,o,i)-l,x2:Math.max(r,o,i)+l,y1:Math.min(n,s,a)-l,y2:Math.max(n,s,a)+l};return!(eu.x2||tu.y2)},n.solveCubic=function(e,t,r,n,i){t/=e,r/=e,n/=e;var a,o,s,l,u,c,d,h;return o=(3*r-t*t)/9,s=-(27*n)+t*(9*r-2*(t*t)),s/=54,a=o*o*o+s*s,i[1]=0,d=t/3,a>0?(u=s+Math.sqrt(a),u=0>u?-Math.pow(-u,1/3):Math.pow(u,1/3),c=s-Math.sqrt(a),c=0>c?-Math.pow(-c,1/3):Math.pow(c,1/3),i[0]=-d+u+c,d+=(u+c)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-c+u)/2,i[3]=d,void(i[5]=-d)):(i[5]=i[3]=0,0===a?(h=0>s?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=-d+2*h,void(i[4]=i[2]=-(h+d))):(o=-o,l=o*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),i[0]=-d+h*Math.cos(l/3),i[2]=-d+h*Math.cos((l+2*Math.PI)/3),void(i[4]=-d+h*Math.cos((l+4*Math.PI)/3))))},n.sqdistToQuadraticBezier=function(e,t,r,n,i,a,o,s){var l=1*r*r-4*r*i+2*r*o+4*i*i-4*i*o+o*o+n*n-4*n*a+2*n*s+4*a*a-4*a*s+s*s,u=9*r*i-3*r*r-3*r*o-6*i*i+3*i*o+9*n*a-3*n*n-3*n*s-6*a*a+3*a*s,c=3*r*r-6*r*i+r*o-r*e+2*i*i+2*i*e-o*e+3*n*n-6*n*a+n*s-n*t+2*a*a+2*a*t-s*t,d=1*r*i-r*r+r*e-i*e+n*a-n*n+n*t-a*t,h=[];this.solveCubic(l,u,c,d,h);for(var p=1e-7,f=[],v=0;6>v;v+=2)Math.abs(h[v+1])=0&&h[v]<=1&&f.push(h[v]);f.push(1),f.push(0);for(var g,y,m,b,x=-1,w=0;w=0?x>b&&(x=b,g=f[w]):(x=b,g=f[w]);return x},n.sqdistToFiniteLine=function(e,t,r,n,i,a){var o=[e-r,t-n],s=[i-r,a-n],l=s[0]*s[0]+s[1]*s[1],u=o[0]*o[0]+o[1]*o[1],c=o[0]*s[0]+o[1]*s[1],d=c*c/l;return 0>c?u:d>l?(e-i)*(e-i)+(t-a)*(t-a):u-d},n.pointInsidePolygonPoints=function(e,t,r){for(var n,i,a,o,s,l=0,u=0,c=0;c=e&&e>=a||e>=n&&a>=e))continue;s=(e-n)/(a-n)*(o-i)+i,s>t&&l++,t>s&&u++}return l%2!==0},n.pointInsidePolygon=function(e,t,r,i,a,o,s,l,u){var c,d=new Array(r.length);null!=l[0]?(c=Math.atan(l[1]/l[0]),l[0]<0?c+=Math.PI/2:c=-c-Math.PI/2):c=l;for(var h=Math.cos(-c),p=Math.sin(-c),f=0;f0){var g=this.expandPolygon(d,-u);v=this.joinLines(g)}else v=d;return n.pointInsidePolygonPoints(e,t,v)},n.joinLines=function(e){for(var t,r,n,i,a,o,s,l,u=new Array(e.length/2),c=0;cu)return[];var c=u/l;return[(r-e)*c+e,(n-t)*c+t]},n.intersectLineCircle=function(e,t,r,n,i,a,o){var s=[r-e,n-t],l=[i,a],u=[e-i,t-a],c=s[0]*s[0]+s[1]*s[1],d=2*(u[0]*s[0]+u[1]*s[1]),l=u[0]*u[0]+u[1]*u[1]-o*o,h=d*d-4*c*l;if(0>h)return[];var p=(-d+Math.sqrt(h))/(2*c),f=(-d-Math.sqrt(h))/(2*c),v=Math.min(p,f),g=Math.max(p,f),y=[];if(v>=0&&1>=v&&y.push(v),g>=0&&1>=g&&y.push(g),0===y.length)return[];var m=y[0]*s[0]+e,b=y[0]*s[1]+t;if(y.length>1){if(y[0]==y[1])return[m,b];var x=y[1]*s[0]+e,w=y[1]*s[1]+t;return[m,b,x,w]}return[m,b]},n.findCircleNearPoint=function(e,t,r,n,i){var a=n-e,o=i-t,s=Math.sqrt(a*a+o*o),l=a/s,u=o/s;return[e+l*r,t+u*r]},n.findMaxSqDistanceToOrigin=function(e){for(var t,r=1e-6,n=0;nr&&(r=t);return r},n.midOfThree=function(e,t,r){return e>=t&&r>=e||e>=r&&t>=e?e:t>=e&&r>=t||t>=r&&e>=t?t:r},n.finiteLinesIntersect=function(e,t,r,n,i,a,o,s,l){var u=e-i,c=r-e,d=o-i,h=t-a,p=n-t,f=s-a,v=d*h-f*u,g=c*h-p*u,y=f*c-d*p;if(0!==y){var m=v/y,b=g/y,x=.001,w=0-x,E=1+x;return m>=w&&E>=m&&b>=w&&E>=b?[e+m*c,t+m*p]:l?[e+m*c,t+m*p]:[]}return 0===v||0===g?this.midOfThree(e,r,o)===o?[o,s]:this.midOfThree(e,r,i)===i?[i,a]:this.midOfThree(i,o,r)===r?[r,n]:[]:[]},n.polygonIntersectLine=function(e,t,r,i,a,o,s,l){for(var u,c=[],d=new Array(r.length),h=0;h0){var f=n.expandPolygon(d,-l);p=n.joinLines(f)}else p=d;for(var v,g,y,m,h=0;ha&&(a=1e-5),[t[0]+a*n[0],t[1]+a*n[1]]},n.generateUnitNgonPointsFitToSquare=function(e,t){var r=n.generateUnitNgonPoints(e,t);return r=n.fitPolygonToSquare(r)},n.fitPolygonToSquare=function(e){for(var t,r,n=e.length/2,i=1/0,a=1/0,o=-(1/0),s=-(1/0),l=0;n>l;l++)t=e[2*l],r=e[2*l+1],i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,r),s=Math.max(s,r);for(var u=2/(o-i),c=2/(s-a),l=0;n>l;l++)t=e[2*l]=e[2*l]*u,r=e[2*l+1]=e[2*l+1]*c,i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,r),s=Math.max(s,r);if(-1>a)for(var l=0;n>l;l++)r=e[2*l+1]=e[2*l+1]+(-1-a);return e},n.generateUnitNgonPoints=function(e,t){var r=1/e*2*Math.PI,n=e%2===0?Math.PI/2+r/2:Math.PI/2;n+=t;for(var i,a,o,s=new Array(2*e),l=0;e>l;l++)i=l*r+n,a=s[2*l]=Math.cos(i),o=s[2*l+1]=Math.sin(-i);return s},n.getRoundRectangleRadius=function(e,t){return Math.min(e/4,t/4,8)},t.exports=n},{}],86:[function(e,t,r){/*!
-Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
-Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
-Licensed under The MIT License (http://opensource.org/licenses/MIT)
-*/
-"use strict";var n=0,i=1,a=2,o=function(e){return this instanceof o?(this.id="Thenable/1.0.7",this.state=n,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},void("function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this)))):new o(e)};o.prototype={fulfill:function(e){return s(this,i,"fulfillValue",e)},reject:function(e){return s(this,a,"rejectReason",e)},then:function(e,t){var r=this,n=new o;return r.onFulfilled.push(c(e,n,"fulfill")),r.onRejected.push(c(t,n,"reject")),l(r),n.proxy}};var s=function(e,t,r,i){return e.state===n&&(e.state=t,e[r]=i,l(e)),e},l=function(e){e.state===i?u(e,"onFulfilled",e.fulfillValue):e.state===a&&u(e,"onRejected",e.rejectReason)},u=function(e,t,r){if(0!==e[t].length){var n=e[t];e[t]=[];var i=function(){for(var e=0;e\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:'"(?:\\\\"|[^"])+"|'+"'(?:\\\\'|[^'])+'",number:i.regex.number,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$"};l.variable="(?:[\\w-]|(?:\\\\"+l.metaChar+"))+",l.value=l.string+"|"+l.number,l.className=l.variable,l.id=l.variable;for(var u=function(e){return e.replace(new RegExp("\\\\("+l.metaChar+")","g"),function(e,t,r,n){return t})},c=l.comparatorOp.split("|"),d=0;d=0||"="!==h&&(l.comparatorOp+="|\\!"+h)}var p=[{name:"group",query:!0,regex:"(node|edge|\\*)",populate:function(e){this.group="*"===e?e:e+"s"}},{name:"state",query:!0,regex:"(:selected|:unselected|:locked|:unlocked|:visible|:hidden|:transparent|:grabbed|:free|:removed|:inside|:grabbable|:ungrabbable|:animated|:unanimated|:selectable|:unselectable|:orphan|:nonorphan|:parent|:child|:loop|:simple|:active|:inactive|:touch|:backgrounding|:nonbackgrounding)",populate:function(e){this.colonSelectors.push(e)}},{name:"id",query:!0,regex:"\\#("+l.id+")",populate:function(e){this.ids.push(u(e))}},{name:"className",query:!0,regex:"\\.("+l.className+")",populate:function(e){this.classes.push(u(e))}},{name:"dataExists",query:!0,regex:"\\[\\s*("+l.variable+")\\s*\\]",populate:function(e){this.data.push({field:u(e)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+l.variable+")\\s*("+l.comparatorOp+")\\s*("+l.value+")\\s*\\]",populate:function(e,t,r){var n=null!=new RegExp("^"+l.string+"$").exec(r);r=n?r.substring(1,r.length-1):parseFloat(r),this.data.push({field:u(e),operator:t,value:r})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+l.boolOp+")\\s*("+l.variable+")\\s*\\]",populate:function(e,t){this.data.push({field:u(t),operator:e})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+l.meta+")\\s*("+l.comparatorOp+")\\s*("+l.number+")\\s*\\]\\]",populate:function(e,t,r){this.meta.push({field:u(e),operator:t,value:parseFloat(r)})}},{name:"nextQuery",separator:!0,regex:l.separator,populate:function(){t[++d]=r(),s=null}},{name:"child",separator:!0,regex:l.child,populate:function(){var e=r();e.parent=this,e.subject=s,t[d]=e}},{name:"descendant",separator:!0,regex:l.descendant,populate:function(){var e=r();e.ancestor=this,e.subject=s,t[d]=e}},{name:"subject",modifier:!0,regex:l.subject,populate:function(){return null!=s&&this.subject!=this?(i.error("Redefinition of subject in selector `"+e+"`"),!1):(s=this,void(this.subject=this))}}];t._private.selectorText=e;var f=e,d=0,v=function(e){for(var t,r,i,a=0;a=0&&(d=d.toLowerCase(),h=h.toLowerCase(),s=s.replace("@",""),p=!0);var f=!1;s.indexOf("!")>=0&&(s=s.replace("!",""),f=!0),p&&(l=h.toLowerCase(),c=d.toLowerCase());var v=!1;switch(s){case"*=":a=d.indexOf(h)>=0;break;case"$=":a=d.indexOf(h,d.length-h.length)>=0;break;case"^=":a=0===d.indexOf(h);break;case"=":a=c===l;break;case">":v=!0,a=c>l;break;case">=":v=!0,a=c>=l;break;case"<":v=!0,a=l>c;break;case"<=":v=!0,a=l>=c;break;default:a=!1}!f||null==c&&v||(a=!a)}else if(null!=s)switch(s){case"?":a=t.fieldTruthy(u);break;case"!":a=!t.fieldTruthy(u);break;case"^":a=t.fieldUndefined(u)}else a=!t.fieldUndefined(u);if(!a){r=!1;break}}return r},v=f({name:"data",fieldValue:function(e){return r.data[e]},fieldUndefined:function(e){return void 0===r.data[e]},fieldTruthy:function(e){return!!r.data[e]}});if(!v)return!1;var g=f({name:"meta",fieldValue:function(e){return t[e]()},fieldUndefined:function(e){return null==t[e]()},fieldTruthy:function(e){return!!t[e]()}});if(!g)return!1;if(null!=e.collection){var y=e.collection.hasElementWithId(t.id());if(!y)return!1}if(null!=e.filter&&0===t.collection().filter(e.filter).size())return!1;var m=function(e,t){if(null!=e){var r=!1;if(!i.hasCompoundNodes())return!1;t=t();for(var n=0;n "+n),null!=e.ancestor&&(n=a(e.ancestor)+" "+n),null!=e.child&&(n+=" > "+a(e.child)),null!=e.descendant&&(n+=" "+a(e.descendant)),n},o=0;o1&&o0;if(h||p){var f;h&&p?f=u.properties:h?f=u.properties:p&&(f=u.mappedProperties);for(var v=0;v0){n=!0;break}}t.hasPie=n;var o=e.pstyle("text-transform").strValue,s=e.pstyle("label").strValue,l=e.pstyle("source-label").strValue,u=e.pstyle("target-label").strValue,c=e.pstyle("font-style").strValue,a=e.pstyle("font-size").pfValue+"px",d=e.pstyle("font-family").strValue,h=e.pstyle("font-weight").strValue,p=e.pstyle("text-valign").strValue,f=e.pstyle("text-valign").strValue,v=e.pstyle("text-outline-width").pfValue,g=e.pstyle("text-wrap").strValue,y=e.pstyle("text-max-width").pfValue,m=c+"$"+a+"$"+d+"$"+h+"$"+o+"$"+p+"$"+f+"$"+v+"$"+g+"$"+y;t.labelStyleKey=m,t.sourceLabelKey=m+"$"+l,t.targetLabelKey=m+"$"+u,t.labelKey=m+"$"+s,t.fontKey=c+"$"+h+"$"+a+"$"+d,t.styleKey=Date.now()}},a.applyParsedProperty=function(e,t){var r,a,o=this,s=t,l=e._private.style,u=o.types,c=o.properties[s.name].type,d=s.bypass,h=l[s.name],p=h&&h.bypass,f=e._private;if("curve-style"===t.name&&"haystack"===t.value&&e.isEdge()&&(e.isLoop()||e.source().isParent()||e.target().isParent())&&(s=t=this.parse(t.name,"bezier",d)),s["delete"])return l[s.name]=void 0,!0;if(s.deleteBypassed)return h?h.bypass?(h.bypassed=void 0,!0):!1:!0;if(s.deleteBypass)return h?h.bypass?(l[s.name]=h.bypassed,!0):!1:!0;var v=function(){n.error("Do not assign mappings to elements without corresponding data (e.g. ele `"+e.id()+"` for property `"+s.name+"` with data field `"+s.field+"`); try a `["+s.field+"]` selector to limit scope to elements with `"+s.field+"` defined")};switch(s.mapped){case u.mapData:case u.mapLayoutData:case u.mapScratch:var r,g=s.mapped===u.mapLayoutData,y=s.mapped===u.mapScratch,m=s.field.split(".");r=y||g?f.scratch:f.data;for(var b=0;bw?w=0:w>1&&(w=1),c.color){var E=s.valueMin[0],_=s.valueMax[0],P=s.valueMin[1],S=s.valueMax[1],k=s.valueMin[2],T=s.valueMax[2],D=null==s.valueMin[3]?1:s.valueMin[3],C=null==s.valueMax[3]?1:s.valueMax[3],M=[Math.round(E+(_-E)*w),Math.round(P+(S-P)*w),Math.round(k+(T-k)*w),Math.round(D+(C-D)*w)];a={bypass:s.bypass,name:s.name,value:M,strValue:"rgb("+M[0]+", "+M[1]+", "+M[2]+")"}}else{if(!c.number)return!1;var N=s.valueMin+(s.valueMax-s.valueMin)*w;a=this.parse(s.name,N,s.bypass,!0)}a||(a=this.parse(s.name,h.strValue,s.bypass,!0)),a||v(),a.mapping=s,s=a;break;case u.data:case u.layoutData:case u.scratch:var r,g=s.mapped===u.layoutData,y=s.mapped===u.scratch,m=s.field.split(".");if(r=y||g?f.scratch:f.data)for(var b=0;b0&&s>0){for(var u={},c=!1,d=0;d0&&e.delay(l),e.animate({css:u},{duration:s,easing:e.pstyle("transition-timing-function").value,queue:!1,complete:function(){r||n.removeBypasses(e,o),a.transitioning=!1}})}else a.transitioning&&(e.stop(),this.removeBypasses(e,o),a.transitioning=!1)},t.exports=a},{"../is":83,"../util":100}],89:[function(e,t,r){"use strict";var n=e("../is"),i=e("../util"),a={};a.applyBypass=function(e,t,r,a){var o=this,s=[],l=!0;if("*"===t||"**"===t){if(void 0!==r)for(var u=0;uh.max)return null;var B={name:e,value:t,strValue:""+t+(D?D:""),units:D,bypass:r};return h.unitless||"px"!==D&&"em"!==D?B.pfValue=t:B.pfValue="px"!==D&&D?this.getEmSizeInPixels()*t:t,"ms"!==D&&"s"!==D||(B.pfValue="ms"===D?t:1e3*t),"deg"!==D&&"rad"!==D||(B.pfValue="rad"===D?t:a.deg2rad(t)),B}if(h.propList){var z=[],I=""+t;if("none"===I);else{for(var L=I.split(","),O=0;O node").css({shape:"rectangle","padding-top":10,"padding-right":10,"padding-left":10,"padding-bottom":10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3,"curve-style":"haystack"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector("node:parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}).selector("core").css({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125}),this.defaultLength=this.length},t.exports=i},{"../util":100}],96:[function(e,t,r){"use strict";var n=e("../util"),i=e("../selector"),a={};a.applyFromString=function(e){function t(){c=c.length>a.length?c.substr(a.length):""}function r(){o=o.length>s.length?o.substr(s.length):""}var a,o,s,l=this,u=this,c=""+e;for(c=c.replace(/[\/][*](\s|.)+?[*][\/]/g,"");;){var d=c.match(/^\s*$/);if(d)break;var h=c.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!h){n.error("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+c);break}a=h[0];var p=h[1];if("core"!==p){var f=new i(p);if(f._private.invalid){n.error("Skipping parsing of block: Invalid selector found in string stylesheet: "+p),t();continue}}var v=h[2],g=!1;o=v;for(var y=[];;){var d=o.match(/^\s*$/);if(d)break;var m=o.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!m){n.error("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+v),g=!0;break}s=m[0];var b=m[1],x=m[2],w=l.properties[b];if(w){var E=u.parse(b,x);E?(y.push({name:b,val:x}),r()):(n.error("Skipping property: Invalid property definition in: "+s),r())}else n.error("Skipping property: Invalid property name in: "+s),r()}if(g){t();break}u.selector(p);for(var _=0;_1?", "+JSON.stringify(r):"")+" );"," "," resolve = origResolve;"," resolve( res.length > 0 ? res : ret );","}"].join("\n"))}};util.extend(thdfn,{reduce:defineFnal({name:"reduce"}),reduceRight:defineFnal({name:"reduceRight"}),map:defineFnal({name:"map"})});var fn=thdfn;fn.promise=fn.run,fn.terminate=fn.halt=fn.stop,fn.include=fn.require,util.extend(thdfn,{on:define.on(),one:define.on({unbindSelfOnTrigger:!0}),off:define.off(),trigger:define.trigger()}),define.eventAliasesOn(thdfn),module.exports=Thread},{"./define":44,"./event":45,"./is":83,"./promise":86,"./util":100,"./window":107,child_process:void 0,path:void 0}],99:[function(e,t,r){"use strict";var n=e("../is");t.exports={hex2tuple:function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,r,n,i=4===e.length,a=16;return i?(t=parseInt(e[1]+e[1],a),r=parseInt(e[2]+e[2],a),n=parseInt(e[3]+e[3],a)):(t=parseInt(e[1]+e[2],a),r=parseInt(e[3]+e[4],a),n=parseInt(e[5]+e[6],a)),[t,r,n]}},hsl2tuple:function(e){function t(e,t,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?e+6*(t-e)*r:.5>r?t:2/3>r?e+(t-e)*(2/3-r)*6:e}var r,n,i,a,o,s,l,u,c=new RegExp("^"+this.regex.hsla+"$").exec(e);if(c){if(n=parseInt(c[1]),0>n?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,i=parseFloat(c[2]),0>i||i>100)return;if(i/=100,a=parseFloat(c[3]),0>a||a>100)return;if(a/=100,o=c[4],void 0!==o&&(o=parseFloat(o),0>o||o>1))return;if(0===i)s=l=u=Math.round(255*a);else{var d=.5>a?a*(1+i):a+i-a*i,h=2*a-d;s=Math.round(255*t(h,d,n+1/3)),l=Math.round(255*t(h,d,n)),u=Math.round(255*t(h,d,n-1/3))}r=[s,l,u,o]}return r},rgb2tuple:function(e){var t,r=new RegExp("^"+this.regex.rgba+"$").exec(e);if(r){t=[];for(var n=[],i=1;3>=i;i++){var a=r[i];if("%"===a[a.length-1]&&(n[i]=!0),a=parseFloat(a),n[i]&&(a=a/100*255),0>a||a>255)return;t.push(Math.floor(a))}var o=n[1]||n[2]||n[3],s=n[1]&&n[2]&&n[3];if(o&&!s)return;var l=r[4];if(void 0!==l){if(l=parseFloat(l),0>l||l>1)return;t.push(l)}}return t},colorname2tuple:function(e){return this.colors[e.toLowerCase()]},color2tuple:function(e){return(n.array(e)?e:null)||this.colorname2tuple(e)||this.hex2tuple(e)||this.rgb2tuple(e)||this.hsl2tuple(e)},colors:{transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}},{"../is":83}],100:[function(e,t,r){"use strict";var n=e("../is"),i=e("../math"),a={trueify:function(){return!0},falsify:function(){return!1},zeroify:function(){return 0},noop:function(){},error:function(e){console.error?(console.error.apply(console,arguments),console.trace&&console.trace()):(console.log.apply(console,arguments),console.trace&&console.trace())},clone:function(e){return this.extend({},e)},copy:function(e){return null==e?e:n.array(e)?e.slice():n.plainObject(e)?this.clone(e):e},uuid:function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t}};a.makeBoundingBox=i.makeBoundingBox.bind(i),a._staticEmptyObject={},a.staticEmptyObject=function(){return a._staticEmptyObject},a.extend=null!=Object.assign?Object.assign:function(e){for(var t=arguments,r=1;r=0&&(e[n]!==t||(e.splice(n,1),r));n--);},a.clearArray=function(e){e.splice(0,e.length)},a.getPrefixedProperty=function(e,t,r){return r&&(t=this.prependCamel(r,t)),e[t]},a.setPrefixedProperty=function(e,t,r,n){r&&(t=this.prependCamel(r,t)),e[t]=n},[e("./colors"),e("./maps"),{memoize:e("./memoize")},e("./regex"),e("./strings"),e("./timing")].forEach(function(e){a.extend(a,e)}),t.exports=a},{"../is":83,"../math":85,"./colors":99,"./maps":101,"./memoize":102,"./regex":103,"./strings":104,"./timing":105}],101:[function(e,t,r){"use strict";var n=e("../is");t.exports={mapEmpty:function(e){var t=!0;return null!=e?0===Object.keys(e).length:t},pushMap:function(e){var t=this.getMap(e);null==t?this.setMap(this.extend({},e,{value:[e.value]})):t.push(e.value)},setMap:function(e){for(var t,r=e.map,i=e.keys,a=i.length,o=0;a>o;o++){var t=i[o];n.plainObject(t)&&this.error("Tried to set map with object key"),oa;a++){var o=r[a];if(n.plainObject(o)&&this.error("Tried to get map with object key"),t=t[o],null==t)return t}return t},deleteMap:function(e){for(var t=e.map,r=e.keys,i=r.length,a=e.keepChildren,o=0;i>o;o++){var s=r[o];n.plainObject(s)&&this.error("Tried to delete map with object key");var l=o===e.keys.length-1;if(l)if(a)for(var u=Object.keys(t),c=0;c=r){a&&clearTimeout(a);var i=c;a=u=c=void 0,i&&(h=d.now(),o=e.apply(l,n),u||a||(n=l=null))}else u=setTimeout(g,r)},y=function(){u&&clearTimeout(u),a=u=c=void 0,(f||p!==t)&&(h=d.now(),o=e.apply(l,n),u||a||(n=l=null))};return function(){if(n=arguments,s=d.now(),l=this,c=f&&(u||!v),p===!1)var r=v&&!u;else{a||v||(h=s);var i=p-(s-h),m=0>=i;m?(a&&(a=clearTimeout(a)),h=s,o=e.apply(l,n)):a||(a=setTimeout(y,i))}return m&&u?u=clearTimeout(u):u||t===p||(u=setTimeout(g,t)),r&&(m=!0,o=e.apply(l,n)),!m||u||a||(n=l=null),o}}},t.exports=o},{"../is":83,"../window":107}],106:[function(e,t,r){t.exports="2.7.10"},{}],107:[function(e,t,r){t.exports="undefined"==typeof window?null:window},{}]},{},[82])(82)});
\ No newline at end of file
diff --git a/salsah1/public/js/datehelpers.js b/salsah1/public/js/datehelpers.js
deleted file mode 100644
index 1878fa0edc..0000000000
--- a/salsah1/public/js/datehelpers.js
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * Copyright © 2015-2021 the contributors (see Contributors.md).
- *
- * This file is part of Knora.
- *
- * Knora is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Knora is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with Knora. If not, see .
- */
-
-(function( S ) {
-
- 'use strict';
-
- S.calendars = {
- GREGORIAN: {name: 'Gregorian', n_months: 12},
- JULIAN: {name: 'Julian', n_months: 12},
- JEWISH: {name: 'Jewish', n_months: 13},
- FRENCH: {name: 'Revol.', n_months: 13}
- };
-
- S.calendarnames = [];
- S.calendarnames.push('ZERO');
- for (var i in S.calendars) {
- S.calendarnames.push(i);
- }
-
- //
- // adapted from "http://www.fourmilab.ch/documents/calendar/"
- //
- // Please note the these functions originally asume that the gregorian calender
- // has a year 0. In PHP however, the gregorian year 0 does not exist!
- //
-
- var J0000 = 1721424.5; // Julian date of Gregorian epoch: 0000-01-01
- var J1970 = 2440587.5; // Julian date at Unix epoch: 1970-01-01
- var JMJD = 2400000.5; // Epoch of Modified Julian Date system
- var J1900 = 2415020.5; // Epoch (day 1) of Excel 1900 date system (PC)
- var J1904 = 2416480.5; // Epoch (day 0) of Excel 1904 date system (Mac)
-
- var GREGORIAN_EPOCH = 1721425.5;
- var JULIAN_EPOCH = 1721423.5;
- var HEBREW_EPOCH = 347995.5;
- var FRENCH_REVOLUTIONARY_EPOCH = 2375839.5;
-
- var NormLeap = new Array("Normal year", "Leap year");
-
- function mod(a, b) {
- return a - (b * Math.floor(a / b));
- }
-
- function jwday(j) {
- j = Number(j);
- return mod(Math.floor((j + 1.5)), 7);
- }
-
- function leap_gregorian(year) {
- year = parseInt(year);
- return ((year % 4) == 0) && (!(((year % 100) == 0) && ((year % 400) != 0)));
- }
-
- // GREGORIAN_TO_JD -- Determine Julian day number from Gregorian calendar date
-
-
- S.gregorian_to_jd = function(year, month, day) {
- // console.log("gregorian_to_jd got year " + year + ", month " + month + ", day " + day);
-
- year = parseInt(year);
- month = parseInt(month);
- day = parseInt(day);
- //if (year < 0) year++; // correction for PHP
- var jd = (GREGORIAN_EPOCH - 1) +
- (365 * (year - 1)) +
- Math.floor((year - 1) / 4) +
- (-Math.floor((year - 1) / 100)) +
- Math.floor((year - 1) / 400) +
- Math.floor((((367 * month) - 362) / 12) +
- ((month <= 2) ? 0 : (leap_gregorian(year) ? -1 : -2)) + day);
-
- // console.log("gregorian_to_jd calculated JDN " + jd);
- return jd;
- };
-
- // JD_TO_GREGORIAN -- Calculate Gregorian calendar date from Julian day
-
- S.jd_to_gregorian = function(jd) {
- var wjd, depoch, quadricent, dqc, cent, dcent, quad, dquad,
- yindex, dyindex, year, yearday, leapadj;
-
-
- //var jsd = parseInt(jd);
-
- // if a Julian Day has a fraction of 0.5 or higher, it refers to midnight (0h) or later
- // if it is has a fraction below 0.5, it refers to a time before midnight which is the day before
- // 2457498.5 -> 2016-04-20 0h
- // 2457498.4 -> 2016-04-19
- wjd = Math.floor(jd - 0.5) + 0.5;
- depoch = wjd - GREGORIAN_EPOCH;
- quadricent = Math.floor(depoch / 146097);
- dqc = mod(depoch, 146097);
- cent = Math.floor(dqc / 36524);
- dcent = mod(dqc, 36524);
- quad = Math.floor(dcent / 1461);
- dquad = mod(dcent, 1461);
- yindex = Math.floor(dquad / 365);
- year = (quadricent * 400) + (cent * 100) + (quad * 4) + yindex;
- if (!((cent == 4) || (yindex == 4))) {
- year++;
- }
- yearday = wjd - S.gregorian_to_jd(year, 1, 1);
- leapadj = ((wjd < S.gregorian_to_jd(year, 3, 1)) ? 0 : (leap_gregorian(year) ? 1 : 2));
- var month = Math.floor((((yearday + leapadj) * 12) + 373) / 367);
-
- // console.log("jd_to_gregorian calculated month " + month);
-
- var day = (wjd - S.gregorian_to_jd(year, month, 1)) + 1;
-
- // if (year <= 0) year--; // correction for PHPvar JULIAN_EPOCH = 1721423.5;
-
- return new Array(Math.round(year), Math.round(month), Math.round(day));
- };
-
-
- function leap_julian(year) {
- year = parseInt(year);
- return mod(year, 4) == ((year > 0) ? 0 : 3);
- }
-
- S.julian_to_jd = function(year, month, day) {
- year = parseInt(year);
- month = parseInt(month);
- day = parseInt(day);
-
- /* Adjust negative common era years to the zero-based notation we use. */
-
- if (year < 1) {
- year++;
- }
-
- /* Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61 */
-
- if (month <= 2) {
- year--;
- month += 12;
- }
-
- return ((Math.floor((365.25 * (year + 4716))) +
- Math.floor((30.6001 * (month + 1))) +
- day) - 1524.5);
- }
-
- // JD_TO_JULIAN -- Calculate Julian calendar date from Julian day
-
- S.jd_to_julian = function(td) {
- var z, a, alpha, b, c, d, e, year, month, day;
- td = parseInt(td);
-
- td += 0.5;
- z = Math.floor(td);
-
- a = z;
- b = a + 1524;
- c = Math.floor((b - 122.1) / 365.25);
- d = Math.floor(365.25 * c);
- e = Math.floor((b - d) / 30.6001);
-
- month = Math.floor((e < 14) ? (e - 1) : (e - 13));
- year = Math.floor((month > 2) ? (c - 4716) : (c - 4715));
- day = b - d - Math.floor(30.6001 * e);
-
- /* If year is less than 1, subtract one to convert from
- a zero based date system to the common era system in
- which the year -1 (1 B.C.E) is followed by year 1 (1 C.E.). */
-
- if (year < 1) {
- year--;
- }
-
- return new Array(Math.round(year), Math.round(month), Math.round(day));
- };
-
- function hebrew_leap(year) {
- year = parseInt(year);
- return mod(((year * 7) + 1), 19) < 7;
- }
-
- // How many months are there in a Hebrew year (12 = normal, 13 = leap)
-
- function hebrew_year_months(year) {
- year = parseInt(year);
- return hebrew_leap(year) ? 13 : 12;
- }
-
- // Test for delay of start of new year and to avoid
- // Sunday, Wednesday, and Friday as start of the new year.
-
- function hebrew_delay_1(year) {
- var months, days, parts;
- year = parseInt(year);
-
- months = Math.floor(((235 * year) - 234) / 19);
- parts = 12084 + (13753 * months);
- days = (months * 29) + Math.floor(parts / 25920);
-
- if (mod((3 * (days + 1)), 7) < 3) {
- days++;
- }
-
- return days;
- }
-
- // Check for delay in start of new year due to length of adjacent years
-
- function hebrew_delay_2(year) {
- var last, present, next;
- year = parseInt(year);
-
- last = hebrew_delay_1(year - 1);
- present = hebrew_delay_1(year);
- next = hebrew_delay_1(year + 1);
-
- return ((next - present) == 356) ? 2 :
- (((present - last) == 382) ? 1 : 0);
- }
-
- // How many days are in a Hebrew year ?
-
- function hebrew_year_days(year) {
- year = parseInt(year);
- return S.hebrew_to_jd(year + 1, 7, 1) - S.hebrew_to_jd(year, 7, 1);
- }
-
- // How many days are in a given month of a given year
-
- function hebrew_month_days(year, month) {
- year = parseInt(year);
- month = parseInt(month);
- // First of all, dispose of fixed-length 29 day months
-
- if (month == 2 || month == 4 || month == 6 ||
- month == 10 || month == 13) {
- return 29;
- }
-
- // If it's not a leap year, Adar has 29 days
-
- if (month == 12 && !hebrew_leap(year)) {
- return 29;
- }
-
- // If it's Heshvan, days depend on length of year
-
- if (month == 8 && !(mod(hebrew_year_days(year), 10) == 5)) {
- return 29;
- }
-
- // Similarly, Kislev varies with the length of year
-
- if (month == 9 && (mod(hebrew_year_days(year), 10) == 3)) {
- return 29;
- }
-
- // Nope, it's a 30 day month
-
- return 30;
- }
-
- // Finally, wrap it all up into...
-
- S.hebrew_to_jd = function(year, month, day) {
-
- year = parseInt(year);
- month = parseInt(month);
- day = parseInt(day);
-
- var jd, mon, months;
-
- months = hebrew_year_months(year);
- jd = HEBREW_EPOCH + hebrew_delay_1(year) +
- hebrew_delay_2(year) + day + 1;
-
- if (month < 7) {
- for (mon = 7; mon <= months; mon++) {
- jd += hebrew_month_days(year, mon);
- }
- for (mon = 1; mon < month; mon++) {
- jd += hebrew_month_days(year, mon);
- }
- } else {
- for (mon = 7; mon < month; mon++) {
- jd += hebrew_month_days(year, mon);
- }
- }
-
- return jd;
- }
-
- /* JD_TO_HEBREW -- Convert Julian date to Hebrew date
- This works by making multiple calls to
- the inverse function, and is this very
- slow. */
-
- S.jd_to_hebrew = function(jd) {
- var year, month, day, i, count, first;
- jd = parseInt(jd);
-
- jd = Math.floor(jd) + 0.5;
- count = Math.floor(((jd - HEBREW_EPOCH) * 98496.0) / 35975351.0);
- year = count - 1;
- for (i = count; jd >= S.hebrew_to_jd(i, 7, 1); i++) {
- year++;
- }
- first = (jd < S.hebrew_to_jd(year, 1, 1)) ? 7 : 1;
- month = first;
- for (i = first; jd > S.hebrew_to_jd(year, i, hebrew_month_days(year, i)); i++) {
- month++;
- }
- day = (jd - S.hebrew_to_jd(year, month, 1)); // + 1;
- return new Array(Math.round(year), Math.round(month), Math.round(day));
- }
-
- function annee_da_la_revolution(jd) {
- jd = parseInt(jd);
- var guess = S.jd_to_gregorian(jd)[0] - 2,
- lasteq, nexteq, adr;
-
- lasteq = paris_equinoxe_jd(guess);
- while (lasteq > jd) {
- guess--;
- lasteq = paris_equinoxe_jd(guess);
- }
- nexteq = lasteq - 1;
- while (!((lasteq <= jd) && (jd < nexteq))) {
- lasteq = nexteq;
- guess++;
- nexteq = paris_equinoxe_jd(guess);
- }
- adr = Math.round((lasteq - FRENCH_REVOLUTIONARY_EPOCH) / TropicalYear) + 1;
-
- return new Array(adr, lasteq);
- }
-
- /* JD_TO_FRENCH_REVOLUTIONARY -- Calculate date in the French Revolutionary
- calendar from Julian day. The five or six
- "sansculottides" are considered a thirteenth
- month in the results of this function. */
-
- S.jd_to_french_revolutionary = function(jd) {
- var an, mois, decade, jour,
- adr, equinoxe;
- jd = parseInt(jd);
- jd = Math.floor(jd) + 0.5;
- adr = annee_da_la_revolution(jd);
- an = adr[0];
- equinoxe = adr[1];
- mois = Math.floor((jd - equinoxe) / 30) + 1;
- jour = (jd - equinoxe) % 30;
- decade = Math.floor(jour / 10) + 1;
- jour = (jour % 10) + 1;
-
- return new Array(an, mois, decade, jour);
- };
-
- /* FRENCH_REVOLUTIONARY_TO_JD -- Obtain Julian day from a given French
- Revolutionary calendar date. */
-
- S.french_revolutionary_to_jd = function(an, mois, decade, jour) {
- var adr, equinoxe, guess, jd;
- an = parseInt(an);
- mois = parseInt(mois);
- decade = parseInt(decade);
- jour = parseInt(jour);
-
- guess = FRENCH_REVOLUTIONARY_EPOCH + (TropicalYear * ((an - 1) - 1));
- adr = new Array(an - 1, 0);
-
- while (adr[0] < an) {
- adr = annee_da_la_revolution(guess);
- guess = adr[1] + (TropicalYear + 2);
- }
- equinoxe = adr[1];
-
- jd = equinoxe + (30 * (mois - 1)) + (10 * (decade - 1)) + (jour - 1);
- return jd;
- }
-
- S.daycnt = function(cal, year, month) {
- year = parseInt(year);
- month = parseInt(month);
-
- var dc1, dc2, days;
- switch (cal) {
- case 'GREGORIAN':
- case 'gregorian': {
- dc1 = Math.round(S.gregorian_to_jd(year, month, 1));
- if ((month + 1) > S.calendars[cal].n_months) {
- month = 1;
- year++;
- dc2 = Math.round(S.gregorian_to_jd(year, month, 1));
- }
- else {
- dc2 = Math.round(S.gregorian_to_jd(year, month + 1, 1));
- }
- days = dc2 - dc1;
- break;
- }
- case 'JULIAN':
- case 'julian': {
- dc1 = Math.round(S.julian_to_jd(year, month, 1));
- if ((month + 1) > S.calendars[cal].n_months) {
- month = 1;
- year++;
- dc2 = Math.round(S.julian_to_jd(year, month, 1));
- }
- else {
- dc2 = Math.round(S.julian_to_jd(year, month + 1, 1));
- }
- days = dc2 - dc1;
- break;
- }
- case 'JEWISH':
- case 'jewish': {
- dc1 = Math.round(S.hebrew_to_jd(year, month, 1));
- if ((month + 1) > S.calendars[cal].n_months) {
- month = 1;
- year++;
- dc2 = Math.round(S.hebrew_to_jd(year, month, 1));
- }
- else {
- dc2 = Math.round(S.hebrew_to_jd(year, month + 1, 1));
- }
- days = dc2 - dc1;
- break;
- }
- case 'FRENCH':
- case 'french': {
- break;
- }
- }
- return {
- days: days,
- weekday_first: jwday(dc1)
- }
- };
-
- S.jdc_to_date = function (jdc, cal) {
- jdc = parseInt(jdc);
- var dateobj = {};
- var tmparr;
- switch (cal) {
- case 'GREGORIAN':
- case 'gregorian': {
- tmparr = S.jd_to_gregorian(jdc);
- break;
- }
- case 'JULIAN':
- case 'julian': {
- tmparr = S.jd_to_julian(jdc);
- break;
- }
- case 'JEWISH':
- case 'jewish': {
- tmparr = S.jd_to_hebrew(jdc);
- break;
- }
- case 'FRENCH':
- case 'french': {
- tmparr = S.jd_to_french_revolutionary(jdc);
- break;
- }
- }
- dateobj.year = tmparr[0];
- dateobj.month = tmparr[1];
- dateobj.day = tmparr[2];
- dateobj.weekday = jwday(jdc);
-
- return dateobj;
- }
-
- S.date_to_jdc = function(day, month, year, cal, periodpart) {
- var jdc = 0;
-
- var i_day = parseInt(day);
- var i_month = parseInt(month);
- var i_year = parseInt(year);
-
- if (periodpart == 'END') {
- if (i_month == 0) i_month = S.calendars[cal].n_months;
- if (i_day == 0) {
- var tmp = SALSAH.daycnt(cal, i_year, i_month);
- i_day = tmp.days;
- }
- }
- else {
- if (month == 0) i_month = 1;
- if (day == 0) i_day = 1;
- }
-
- switch (cal) {
- case 'GREGORIAN':
- case 'gregorian': {
- jdc = Math.round(S.gregorian_to_jd(i_year, i_month, i_day));
- break;
- }
- case 'JULIAN':
- case 'julian': {
- jdc = Math.round(S.julian_to_jd(i_year, i_month, i_day));
- break;
- }
- case 'JEWISH':
- case 'jewish': {
- jdc = Math.round(S.hebrew_to_jd(i_year, i_month, i_day));
- break;
- }
- case 'FRENCH':
- case 'french': {
- jdc = -1;
- break;
- }
- default: {
- jdc = -2;
- }
- }
- return jdc;
- }
-
-
-}) ( SALSAH );
\ No newline at end of file
diff --git a/salsah1/public/js/empty_config.js b/salsah1/public/js/empty_config.js
deleted file mode 100644
index b0d62d7a77..0000000000
--- a/salsah1/public/js/empty_config.js
+++ /dev/null
@@ -1,11 +0,0 @@
- /**----------------------------------------------------
- * NOTE:
- * "empty" config for not stepping in our way
- * with the configuration work done in js/jquery.htmleditor.js
- * it is different from the default `config.js` so the it is not overwritten
- * by a ckeditor upgrade.
- */
-
-
-CKEDITOR.editorConfig = function( config ) {
-};
diff --git a/salsah1/public/js/imagebase.js b/salsah1/public/js/imagebase.js
deleted file mode 100755
index d8ebefd59b..0000000000
--- a/salsah1/public/js/imagebase.js
+++ /dev/null
@@ -1,4432 +0,0 @@
-
-/*
- * Copyright © 2015-2021 the contributors (see Contributors.md).
- *
- * This file is part of Knora.
- *
- * Knora is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Knora is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with Knora. If not, see .
- */
-
-$(function() {
-
- var defaultresicon = "app/icons/16x16/help.png"
-
- //var metadataAreaDomCreate = function(topele, winid, tabid, regnum, resource)
- var metadataAreaDomCreate = function(topele, resource, options)
- {
- //console.log(resource);
- settings = {
- winid: undefined,
- tabid: undefined,
- regnum: undefined,
- view: 'normal' // my be 'detail'
- }
- $.extend(settings, options);
-
- var propedit;
- var petablle;
- var datafield;
-
- if (settings.view == 'normal')
- {
- //debugger;
- propedit = $('').addClass('propedit');
-
- // get the ark id
- arkdiv = $(' ');
- propedit.append(arkdiv);
- SALSAH.ApiGet('resourcesv2', resource.resdata.res_id, {resinfo: true, reqtype: 'context'}, function(datav2) {
- if (datav2['knora-api:versionArkUrl'] && datav2['knora-api:versionArkUrl']['@value']) {
- arkdiv.append(
- $(' ')
- .addClass('propedit label')
- .append('Persistent ID (')
- .append(
- $('').attr({href: 'https://en.wikipedia.org/wiki/Archival_Resource_Key'}).append('ARK'))
- .append('): ')
- .append($('').attr({src: SITE_URL + '/app/icons/16x16/attachment.png', title: 'Copy to clipboard'}).on('click', function() {
- $(this).next('.clipit').select();
- document.execCommand('copy');
- })
- .dragndrop('makeDraggable', 'HANDLE_ID', {handle_id: datav2['knora-api:versionArkUrl']['@value']}))
- .append($('')
- .attr({type:'text', readOnly: true, size: '64'})
- .addClass('clipit').val(datav2['knora-api:versionArkUrl']['@value'])));
- }
- });
-
- propedit.append(
- $('')
- .attr({src: resource.resinfo.restype_iconsrc ? resource.resinfo.restype_iconsrc : defaultresicon, title: 'DRAG TO DESTINATION'})
- .addClass('propedit resicon')
- .dragndrop('makeDraggable', 'RESID', {resid: resource.resdata.res_id})
- );
- propedit.append($('').attr({title: 'resource_id=' + resource.resdata.res_id + ' person_id=' + resource.resinfo.person_id + ' lastmod=' + resource.resinfo.lastmod}).addClass('propedit label').text(resource.resinfo.restype_label + ':'));
-
- propedit.append(' ');
-
- //
- // setting the actions in dependence of the rights
- //
- if (resource.resdata.rights >= Rights.RESOURCE_ACCESS_ANNOTATE)
- {
- propedit.append($('').attr({src: SITE_URL + '/app/icons/16x16/comment.png', title: 'ANNOTATE'}));
- }
-
- if (resource.resdata.rights >= Rights.RESOURCE_ACCESS_DELETE)
- {
- propedit.append($('').attr({src: SITE_URL + '/app/icons/16x16/trash.png', title: 'DELETE'}).addClass('propedit delres').data('res_id', resource.resdata.res_id));
- }
-
- if (resource.resdata.rights >= Rights.RESOURCE_ACCESS_RIGHTS)
- {
- propedit.append($('').attr({src: SITE_URL + '/app/icons/16x16/lock.png', title: 'RIGHTS'}));
- }
-
- if (settings.tabid === undefined) {
- datafield = 'datafield';
- }
- else {
- datafield = 'datafield_' + settings.tabid;
- }
-
- propedit.append($(' ').addClass('propedit'));
-
- //*******************************
- if (settings.regnum !== undefined) {
- propedit.append($('')
- .append($(' ').addClass('propedit label').text('LABEL: '))
- .append($('').addClass('propedit ' + datafield + ' regnum_' + settings.regnum).data('propname', '__label__')));
- }
- else {
- propedit.append($(' ')
- .append($(' ').addClass('propedit label').text('LABEL: '))
- .append($('').addClass('propedit ' + datafield + ' winid_' + settings.winid).data('propname', '__label__')));
- }
- //***************
-
- // we want the properties to be sorted, so we will transfer the
- // Objects {key: value, key: value, ...} or more precisely { propname: propdata, propname: propdata, ... }
- // into an Array [ {'key': key, 'value': value}, ... ] or more precisely [ {'name': propname, 'value': propdata}, ...]
- var sortedprops = Object.keys(resource.props).map(function(propname) {return { 'name' : propname, 'value' : resource.props[propname]};});
-
- // why did we do this Objects to Array juggling? because on arrays we can call `Array.sort()`
- sortedprops.sort(function(prop1, prop2){
- return prop1.value.guiorder - prop2.value.guiorder;
- });
-
- if ((resource.resdata.rights >= Rights.RESOURCE_ACCESS_VIEW_RESTRICTED) && (resource.resinfo.locations))
- {
- propedit.append($(' ')
- .append($(' ').addClass('propedit label').text('LOCATION: '))
- .append($('').addClass('propedit ' + datafield + ' winid_' + settings.winid).data('propname', '__location__')));
- }
- if (settings.regnum !== undefined)
- {
- for (var i = 0; i < sortedprops.length; i++)
- {
- var propname = sortedprops[i].name;
- if (propname == 'http://www.knora.org/ontology/knora-base#isRegionOf') continue;
- if (propname == '__location__') continue;
- if (propname == '__label__') continue;
- propedit
- .append($(' ').addClass('propedit label').text(sortedprops[i].value.label + ' :'))
- .append($('').addClass('propedit ' + datafield + ' regnum_' + settings.regnum).data('propname', propname))
- .append($(' ').css({height: '10px'}).text(' '));
- }
- }
- else {
- var propname;
- var propdata;
- var annotations = {};
- propedit.append(
- $(' ').addClass('propedit sectionheader metadata winid_' + settings.winid)
- .append($(' ').attr({src: SITE_URL + '/app/icons/collapse.png'}))
- .append(' Descriptive Metadata')
- );
- var metadata_section = $(' ').addClass('propedit section metadata winid_' + settings.winid);
- for (var i = 0; i < sortedprops.length; i++)
- {
- propname = sortedprops[i].name;
- propdata = sortedprops[i].value;
- if (propdata.is_annotation == 1) { // keep annotations for annotations section below
- annotations[propname] = propdata;
- continue;
- }
- if (propname == '__location__') continue;
- if (propname == '__label__') continue;
- metadata_section
- .append($(' ').addClass('propedit label').append(propdata.label + ' :'))
- .append($('').addClass('propedit ' + datafield + ' winid_' + settings.winid).data('propname', propname))
- .append($(' ').css({height: '10px'}).append(' '));
- }
- propedit.append(metadata_section);
-
- //
- // now we do the annotations
- //
- propedit.append(
- $(' ').addClass('propedit sectionheader annotations winid_' + settings.winid)
- .append($(' ').attr({src: SITE_URL + '/app/icons/collapse.png'}))
- .append(' Annotations')
- );
- var annotations_section = $(' ').addClass('propedit section annotations winid_' + settings.winid);
- for (propname in annotations) {
- propdata = annotations[propname];
- if (propname == '__location__') continue;
- if (propname == '__label__') continue;
- annotations_section
- .append($(' ').addClass('propedit label').append(propdata.label + ' :'))
- .append($('').addClass('propedit ' + datafield + ' winid_' + settings.winid).data('propname', propname))
- .append($(' ').css({height: '10px'}).append(' '));
- }
- propedit.append(annotations_section);
- }
-
- //
- // outgoing links
- //
- propedit.append(
- $(' ').addClass('propedit sectionheader outgoing winid_' + settings.winid)
- .append($(' ').attr({src: SITE_URL + '/app/icons/collapse.png'}))
- .append(' References to other objects')
- );
- var outgoing_section = $(' ').addClass('propedit section outgoing winid_' + settings.winid);
- propedit.append(outgoing_section);
-
- //
- // incoming links
- //
- propedit.append(
- $(' ').addClass('propedit sectionheader incoming winid_' + settings.winid)
- .append($(' ').attr({src: SITE_URL + '/app/icons/collapse.png'}))
- .append(' Other objects referencing this object')
- );
- var incoming_section = $(' ').addClass('propedit section incoming winid_' + settings.winid);
- var ext_res;
- for (var i in resource.incoming)
- {
- ext_res = resource.incoming[i];
- incoming_section.append(
- $(' ').attr('id', 'row_' + settings.winid + '_' + ext_res.ext_res_id.id).data({ext_res: ext_res}).on('click', function() {
- var ext_res = $(this).data('ext_res');
- RESVIEW.new_resource_editor(ext_res.ext_res_id.id, ext_res.value);
- }).on('mouseover', function(event){
- var ext_res = $(this).data('ext_res');
- load_infowin(event, ext_res.ext_res_id.id /*+ '_-_local'*/, $(this));
- }).append(
- $(' ').attr({
- src: ext_res.resinfo.restype_iconsrc,
- title: ext_res.resinfo.restype_label
- }).addClass('propedit').data({ext_res: ext_res}).on('mouseover', function(event){
- var ext_res = $(this).data('ext_res');
- load_infowin(event, ext_res.ext_res_id.id/* + '_-_local'*/, $(this));
- })
- ).append(ext_res.value)
- );
- }
- propedit.append(incoming_section);
- topele.append(propedit);
- }
- else {
- petable = $(' ').addClass('propedit');
- datafield = 'datafield';
- for (var propname in resource.props)
- {
- if (propname == 'http://www.knora.org/ontology/knora-base#isRegionOf') continue;
- if (propname == '__location__') continue;
- if (propname == '__label__') continue;
- petable
- .append(
- $('')
- .append(
- $('').addClass('propedit label').text(resource.props[propname].label)
- )
- .append(
- $(' | ').text(':')
- )
- .append(
- $(' | ').addClass('propedit datafield valuefield').data('propname', propname)
- )
- )
- }
- topele.append(petable);
- }
-
-
- }
- /*=======================================================================*/
-
- SALSAH.metadataAreaDomCreate = metadataAreaDomCreate;
-
- var sectionsetup = function(element, winid) {
- $(element).find('.sectionheader.winid_' + winid).each(
- function(index){
- var section = $(this).next('.section');
- if (section.css('display') == 'none') {
- $(this).css('cursor', 's-resize');
- }
- else {
- $(this).css('cursor', 'n-resize');
- }
- }
- );
- $(element).find('.sectionheader.winid_' + winid).click(
- function(event) {
- var section = $(this).next('.section');
- if (section.css('display') == 'none') {
- $(this).css('cursor', 'n-resize');
- $(this).find('img').attr('src', SITE_URL + '/app/icons/collapse.png');
- }
- else {
- $(this).css('cursor', 's-resize');
- $(this).find('img').attr('src', SITE_URL + '/app/icons/expand.png');
- }
- $(this).next('.section').slideToggle();
- }
- );
- };
- /*=======================================================================*/
-
- var regionsetup = function(element, winid) {
- var open_area_id;
- $(element).find('.regionheader.winid_' + winid).each(
- function(index) {
- var reg_id = $(this).data('reg_id');
- var section = $(this).next('.section');
- if (typeof open_area_id === 'undefined') {
- section.slideDown();
- $(this).find('img:first').attr('src', SITE_URL + '/app/icons/collapse.png');
- open_area_id = reg_id;
- }
- else {
- $(this).next('.section').css('display', 'none'); // this region info is collapsed ("slideUp")
- $(this).find('img:first').attr('src', SITE_URL + '/app/icons/expand.png');
- }
- }
- );
- $(element).find('.regionheader.winid_' + winid).click(
- function(event) {
-
- var section = $(this).next('.section');
-
- if (section.css('display') == 'none') {
-
- var curRegion = $(".regionheader.winid_"+ winid + "[data-reg_id='" + open_area_id + "']");
-
- curRegion.next('.section').slideUp();
- curRegion.find('img:first').attr('src', SITE_URL + '/app/icons/expand.png');
- section.slideDown();
- $(this).find('img:first').attr('src', SITE_URL + '/app/icons/collapse.png');
- open_area_id = $(this).data('reg_id');
- }
- }
- );
-
- return {
- openSection: function(index) {
-
- var curEle = $(".regionheader.winid_"+ winid + "[data-reg_id='" + index + "']");
- var section = curEle.next('.section');
-
- if (open_area_id != index) {
-
- var openRegion = $(".regionheader.winid_"+ winid + "[data-reg_id='" + open_area_id + "']");
-
- openRegion.next('.section').slideUp();
- openRegion.find('img:first').attr('src', SITE_URL + '/app/icons/expand.png');
- section.slideDown();
-
- curEle.find('img:first').attr('src', SITE_URL + '/app/icons/collapse.png');
- open_area_id = index;
- }
- }
- };
- };
- /*=======================================================================*/
-
-
-
- var regionsTabOnEnterCB = function(data_hook) {
- var figures = $.parseJSON(data_hook['FIGURES'].figures);
- for (var reg in figures) { // loop over all regions
- data_hook['FIGURES'].canvas.regions('drawObject', figures[reg]);
- }
- //
- // now we have to setup the region area and start the detect mode!
- //
- data_hook['FIGURES'].viewer.regionSection(data_hook['FIGURES'].regsec);
- data_hook['FIGURES'].canvas.regions(
- 'setMode',
- 'detect',
- {
- clicked_cb: function(index) {
- var objs = data_hook['FIGURES'].canvas.regions('returnObjects');
- data_hook['FIGURES'].regsec.openSection(objs[index].res_id);
- }
- }
- );
- };
- /*=======================================================================*/
-
- var regionsTabOnLeaveCB = function(data_hook) {
- if (data_hook['FIGURES'] === undefined) return;
- var objs = data_hook['FIGURES'].canvas.regions('returnObjects');
- data_hook['FIGURES'].figures = JSON.stringify(objs);
- data_hook['FIGURES'].canvas.regions('reinit');
- };
-
- /*=======================================================================*/
-
- var setDim = function (dim, ele, value) {
- if (typeof value === 'number') {
- if (ele[dim]() == 0) { // dim is either 'height' or 'width' => ele.width() or ele.height()
- ele[dim](value);
- return value;
- }
- else {
- return ele[dim]();
- }
- }
- else if (typeof value === 'string') {
- var tmp = value.split(':');
- if (ele[dim]() == 0) {
- ele[dim](tmp[0]);
- return tmp[0];
- }
- else {
- if ((tmp.length > 1) && (tmp[1] == 'override')) {
- ele[dim](tmp[0]);
- return (tmp[0]);
- }
- else {
- return ele[dim]();
- }
- }
- }
- return false;
- };
- /*=======================================================================*/
-
-
- /**
- * Adds a special property called __label__ to the properties of a resource, to enable viewing and editing
- * of the resource's rdfs:label.
- */
- var resource_label = function(data) {
- var rights;
-
- if (data.resdata !== undefined) {
-
- switch (data.resdata.rights) {
- case Rights.RESOURCE_ACCESS_NONE: {
- rights = Rights.VALUE_ACCESS_NONE;
- break;
- }
- case Rights.RESOURCE_ACCESS_VIEW_RESTRICTED:
- case Rights.RESOURCE_ACCESS_VIEW: {
- rights = Rights.VALUE_ACCESS_VIEW;
- break;
- }
- case Rights.RESOURCE_ACCESS_ANNOTATE:
- case Rights.RESOURCE_ACCESS_EXTEND:
- case Rights.RESOURCE_ACCESS_OVERRIDE: {
- rights = Rights.VALUE_ACCESS_ANNOTATE;
- break;
- }
- case Rights.RESOURCE_ACCESS_MODIFY:
- case Rights.RESOURCE_ACCESS_DELETE:
- case Rights.RESOURCE_ACCESS_RIGHTS: {
- rights = Rights.VALUE_ACCESS_MODIFY;
- break;
- }
- default: {
- rights = Rights.VALUE_ACCESS_NONE;
- }
- }
- data.props.__label__ = {
- attributes: "size=64",
- comments: [],
- guielement: "text",
- guiorder: 0,
- is_annotation: 0,
- label: "Label",
- occurrence: "1",
- pid: "http://www.w3.org/2000/01/rdf-schema#label",
- regular_property: 1,
- value_firstprops: [null],
- value_iconsrcs: [null],
- value_ids: [null],
- value_restype: [null],
- value_rights: [rights],
- values: [data.resinfo.firstproperty],
- valuetype_id: 'LABEL'
- };
- }
- };
-
- /**
- * This function fills the Metadata area with the image specific information including regions
- *
- * @param {Object} viewer The viewer object
- * @param {Number} winid The window ID
- * @param {Number} res_id The resource ID
- * @param {Object} data The result of an AJAX call to "/ajax/get_resource_context.php"
- * @param {Object} metadata_area_tabs The where the metadata tabs are located within
- * @param {Number} tabid Number of the tab (1 or 2)
- * @param {Boolean} regtab_active if defined, make the regiontabe active
- */
- var imageMetadataArea = function(viewer, winid, res_id, resinfo, tabid, regtab_active) {
- var canvas = viewer.topCanvas();
- //$.post(SITE_URL +'/app/helper/rdfresedit.php', {winid: winid, resid: res_id, tabid: tabid}, // TO DO, BUT ALREADY IN API DIR
- SALSAH.ApiGet('resources', res_id, function(data2) {
- if (data2.status == ApiErrors.OK) {
-
- resource_label(data2);
- var metadata_area_tabs = viewer.metadataArea();
- var icon = $(' ', {src: data2.resdata.iconsrc});//.dragndrop('makeDraggable', 'RESID', {resid: res_id});
- var label = $(' ').append(icon).append(data2.resdata.restype_label);
-
- metadata_area_tabs.tabs('remove', 'regions'); // remove region tabe (if there is alreay one - we don't want it now)
-
-
- //
- // create the tab and add the content to it
- //
- metadata_area_tabs.tabs('setTab', 'image_data', label, function(content_ele) {
- metadataAreaDomCreate(content_ele, data2, {winid: winid, tabid: tabid});
- });
-
- $('.datafield_' + tabid + '.winid_' + winid).propedit(data2.resdata, data2.props, data2.resinfo.project_id);
- var tabele = metadata_area_tabs.tabs('contentElement', 'image_data');
- tabele.addClass('propedit_frame');
- sectionsetup(tabele, winid);
-
- tabele.find('.delres').click(
- function(event) {
- if (confirm(strings._delentry)) {
- SALSAH.ApiDelete('resources/' + encodeURIComponent($(event.target).data('res_id')), function(data) {
- if (data.status == ApiErrors.OK) {
- viewer.destroy();
- }
- else {
- alert(data.errormsg);
- }
- });
- }
- }
- );
-
- //
- // here we add the region tab and fill it... (if the are regions....)
- //
- RESVIEW.setupRegionTab(resinfo, viewer, regtab_active);
- RESVIEW.transcriptionTab(viewer, res_id, resinfo.transcriptions, true);
-
- }
- else {
- alert(new Error().lineNumber + ' ' + data2.errormsg);
- }
- });
- };
- /*=======================================================================*/
-
-
- /**
- * This function fills the Metadata area with the movie specific information including regions
- *
- * @param {Object} viewer The viewer object
- * @param {Number} winid The window ID
- * @param {Number} res_id The resource ID
- * @param {Object} data The result of an AJAX call to "/ajax/get_resource_context.php"
- * @param {Object} metadata_area_tabs The where the metadata tabs are located within
- * @param {Number} tabid Number of the tab (1 or 2)
- */
- var movieMetadataArea = function(viewer, winid, res_id, resinfo, tabid) {
- SALSAH.ApiGet('resources', res_id, function(data2) {
- if (data2.status == ApiErrors.OK) {
- resource_label(data2);
- var metadata_area_tabs = viewer.metadataArea();
- var icon = $(' ', {src: data2.resdata.iconsrc}); //.dragndrop('makeDraggable', 'RESID', {resid: res_id});
- var label1 = $(' ').append(icon).append(data2.resdata.restype_label);
-
- //
- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // here we have to change the sequence tab! equivalent to the region tab
- //
- var label2 = $(' ').append('SEQUENZ');
-
- metadata_area_tabs.tabs('setTab', 'movie_data', label1, function(topele) {
- metadataAreaDomCreate(topele, data2, {winid: winid, tabid: tabid});
- });
-
-/*
- * !+!+!+!+!+!+!+!+!!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!
- * GET A LIST OF SEQUENCES
- * Movie Sequence, Show Tab if some sequences exists !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- * 2013-11-08 @ akilchenmann: todo todo todo
- *
- metadata_area_tabs.tabs('setTab', 'sequence_data', label2, ' content in the activated area');
- var seq = {};
- seq.ele = metadata_area_tabs.tabs('contentElement', 'sequence_data');
-*/
- /* sequence-ele.append(........) */
-
- $('.datafield_' + tabid + '.winid_' + winid).propedit(data2.resdata, data2.props, data2.resinfo.project_id);
-
- var tabele = metadata_area_tabs.tabs('contentElement', 'movie_data');
- tabele.addClass('propedit_frame');
- sectionsetup(tabele, winid);
-
- tabele.find('.delres').click(
- function(event) {
- if (confirm(strings._delentry)) {
- SALSAH.ApiDelete('resources/' + encodeURIComponent($(event.target).data('res_id')), function(data) {
- if (data.status == ApiErrors.OK) {
- viewer.destroy();
- }
- else {
- alert(data.errormsg);
- }
- });
- }
- }
- );
-
- //
- // here we add the sequence tab and fill it... (if there are sequences....)
- // for movies and audio files; equivalent to the region tab in images
- //
- //RESVIEW.setupSequenceTab(resinfo, viewer);
- }
- else {
- alert(new Error().lineNumber + ' ' + data2.errormsg)
- }
- });
- };
- /*=======================================================================*/
-
-
- /**
- * starts drawing of a new figure
- *
- * @param canvas The convas object which is used as overlay
- * @param image_zoom The image zoom object which controls the zooming
- * @param region_action
- * @param figure_add_cb Callback function(figure, index) which saves the figure
- */
- RESVIEW.figure_drawing = function(viewer, figure_add_cb) {
- //
- // Now we add the 3 icons for selecting a rectangle, polygon or circle to draw
- //
- var canvas = viewer.topCanvas();
- var image_zoom = viewer.imageZoom();
- var region_drawings = $(' ');
- viewer.getTaskbar().elestack('add', 'region_drawings', region_drawings);
-
- var active_figure = null;
- var draw_rect_icon;
- var draw_polygon_icon;
- var draw_circle_icon;
-
- draw_rect_icon = $(' ', {src: SITE_URL + '/app/icons/DrawRectangleTool24.gif'}).css('cursor', 'pointer').click(
- function(event) {
- var $this = $(this);
- if (active_figure !== null) { // another figure icon has already been clicked and is active ��� but we want to draw another figure! => reset!!
- switch (active_figure) {
- case 'rect': {
- draw_rect_icon.attr('src', SITE_URL + '/app/icons/DrawRectangleTool24.gif');
- canvas.regions('setMode', 'detect', {
- clicked_cb: function(index) {
- canvas.regions('setMode', 'edit', {index: index});
- }
- });
- active_figure = null;
- return;
- }
- case 'polygon': {
- draw_polygon_icon.attr('src', SITE_URL + '/app/icons/DrawPolygonTool24.gif');
- break;
- }
- case 'circle': {
- draw_circle_icon.attr('src', SITE_URL + '/app/icons/DrawEllipseTool24.gif');
- break;
- }
- }
- }
- active_figure = 'rect';
- $this.attr('src', SITE_URL + '/app/icons/DrawRectangleTool24-active.gif');
- image_zoom.disable();
- var params = {
- type: 'rectangle',
- draw_cb: function(figure, index) {
- image_zoom.enable();
- figure_add_cb(figure, index);
- canvas.regions(
- 'setMode',
- 'detect', {
- clicked_cb: function(index) {
- canvas.regions('setMode', 'edit', {index: index});
- }
- });
- $this.attr('src', SITE_URL + '/app/icons/DrawRectangleTool24.gif');
- active_figure = null;
- }
- };
- canvas.regions('setMode', 'draw', params);
- }
- ).appendTo(region_drawings);
-
- draw_polygon_icon = $(' ', {src: SITE_URL + '/app/icons/DrawPolygonTool24.gif'}).css('cursor', 'pointer').click(
- function(event){
- var $this = $(this);
- if (active_figure !== null) {
- switch (active_figure) {
- case 'rect': {
- draw_rect_icon.attr('src', SITE_URL + '/app/icons/DrawRectangleTool24.gif');
- break;
- }
- case 'polygon': {
- draw_polygon_icon.attr('src', SITE_URL + '/app/icons/DrawPolygonTool24.gif');
- canvas.regions(
- 'setMode',
- 'detect', {
- clicked_cb: function(index) {
- canvas.regions('setMode', 'edit', {index: index});
- }
- });
- active_figure = null;
- return;
- }
- case 'circle': {
- draw_circle_icon.attr('src', SITE_URL + '/app/icons/DrawEllipseTool24.gif');
- break;
- }
- }
- $this.attr('src', SITE_URL + '/app/icons/DrawPolygonTool24.gif');
- }
- active_figure = 'polygon';
- $this.attr('src', SITE_URL + '/app/icons/DrawPolygonTool24-active.gif');
- image_zoom.disable();
- var params = {
- type: 'polygon',
- draw_cb: function(figure, index){
- image_zoom.enable();
- figure_add_cb(figure, index);
- canvas.regions(
- 'setMode',
- 'detect', {
- clicked_cb: function(index) {
- canvas.regions('setMode', 'edit', {index: index});
- }
- });
- $this.attr('src', SITE_URL + '/app/icons/DrawPolygonTool24.gif');
- active_figure = null;
- }
- };
- canvas.regions('setMode', 'draw', params);
- }
- ).appendTo(region_drawings);
-
- draw_circle_icon = $(' ', {src: SITE_URL + '/app/icons/DrawEllipseTool24.gif'}).css('cursor', 'pointer').click(
- function(event){
- var $this = $(this);
- if (active_figure !== null) {
- switch (active_figure) {
- case 'rect': {
- draw_rect_icon.attr('src', SITE_URL + '/app/icons/DrawRectangleTool24.gif');
- break;
- }
- case 'polygon': {
- draw_polygon_icon.attr('src', SITE_URL + '/app/icons/DrawPolygonTool24.gif');
- break;
- }
- case 'circle': {
- draw_circle_icon.attr('src', SITE_URL + '/app/icons/DrawEllipseTool24.gif');
- canvas.regions(
- 'setMode', 'detect', {
- clicked_cb: function(index) {
- canvas.regions('setMode', 'edit', {index: index});
- }
- });
- active_figure = null;
- return;
- }
- }
- }
- active_figure = 'circle';
- $this.attr('src', SITE_URL + '/app/icons/DrawEllipseTool24-active.gif');
- image_zoom.disable();
- var params = {
- type: 'circle',
- draw_cb: function(figure, index){
- image_zoom.enable();
- figure_add_cb(figure, index);
- canvas.regions(
- 'setMode',
- 'detect',
- {
- clicked_cb: function(index) {
- canvas.regions('setMode', 'edit', {index: index});
- }
- }
- );
- $this.attr('src', SITE_URL + '/app/icons/DrawEllipseTool24.gif');
- active_figure = null;
- }
- };
- canvas.regions('setMode', 'draw', params);
- }
- ).appendTo(region_drawings);
- };
- /*=======================================================================*/
-
- RESVIEW.initQuality = function(viewer, viewer_settings, pic, thumbnail) {
- var taskbar_main = viewer.getTaskbar().elestack('get', 'main');
- taskbar_main.find('.qualityActions').remove();
- var quality_actions = $(' ').addClass('qualityActions').css({'vertical-align': 'top'});
-
-
-
- taskbar_main.append(quality_actions);
-
-
- var quality_selection = $(' | | |