labella.min.js 21.9 KB
Newer Older
CED SA's avatar
CED SA committed
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.labella=e():t.labella=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";t.exports={Node:r(1),Force:r(2),Distributor:r(3),Renderer:r(10)}},function(t,e){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=function(){function t(e,n,i){r(this,t),this.idealPos=e,this.currentPos=e,this.width=n,this.data=i,this.layerIndex=0}return n(t,[{key:"distanceFrom",value:function(t){var e=this.width/2,r=t.width/2;return Math.max(this.currentPos-e,t.currentPos-r)-Math.min(this.currentPos+e,t.currentPos+r)}},{key:"moveToIdealPosition",value:function(){return this.currentPos=this.idealPos,this}},{key:"displacement",value:function(){return this.idealPos-this.currentPos}},{key:"overlapWithNode",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return this.distanceFrom(t)-e<0}},{key:"overlapWithPoint",value:function(t){var e=this.width/2;return t>=this.currentPos-e&&t<=this.currentPos+e}},{key:"positionBefore",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return t.currentLeft()-this.width/2-e}},{key:"positionAfter",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return t.currentRight()+this.width/2+e}},{key:"currentRight",value:function(){return this.currentPos+this.width/2}},{key:"currentLeft",value:function(){return this.currentPos-this.width/2}},{key:"idealRight",value:function(){return this.idealPos+this.width/2}},{key:"idealLeft",value:function(){return this.idealPos-this.width/2}},{key:"createStub",value:function(e){var r=new t(this.idealPos,e,this.data);return r.currentPos=this.currentPos,r.child=this,this.parent=r,r}},{key:"removeStub",value:function(){return this.parent&&(this.parent.child=null,this.parent=null),this}},{key:"isStub",value:function(){return!!this.child}},{key:"getPathToRoot",value:function(){for(var t=[],e=this;e;)t.push(e),e=e.parent;return t}},{key:"getPathFromRoot",value:function(){return this.getPathToRoot().reverse()}},{key:"getPathToRootLength",value:function(){for(var t=0,e=this;e;){var r=e.parent?e.parent.currentPos:e.idealPos;t+=Math.abs(e.currentPos-r),e=e.parent}return t}},{key:"getRoot",value:function(){for(var t=this,e=this;e;)t=e,e=e.parent;return t}},{key:"getLayerIndex",value:function(){return this.layerIndex}},{key:"clone",value:function(){var e=new t(this.idealPos,this.width,this.data);return e.currentPos=this.currentPos,e.layerIndex=this.layerIndex,e}}]),t}();t.exports=i},function(t,e,r){"use strict";var n=r(3),i=r(4),o=r(8),s={nodeSpacing:3,minPos:0,maxPos:null,algorithm:"overlap",removeOverlap:!0,density:.85,stubWidth:1},u=function(t){var e={},r=i.extend({},s),u=new n,a=[],c=null;return e.nodes=function(t){return arguments.length?(a=t,c=[t],e):a},e.getLayers=function(){return c},e.options=function(t){if(!arguments.length)return r;r=i.extend(r,t);var o=i.pick(r,Object.keys(n.DEFAULT_OPTIONS));return i.isDefined(r.minPos)&&i.isDefined(r.maxPos)?o.layerWidth=r.maxPos-r.minPos:o.layerWidth=null,u.options(o),e},e.options(t),e.compute=function(){var t=i.pick(r,Object.keys(o.DEFAULT_OPTIONS));return a.forEach(function(t){t.removeStub()}),c=u.distribute(a),c.map(function(e,n){e.forEach(function(t){t.layerIndex=n}),r.removeOverlap&&o(e,t)}),e},e.start=function(){console.log("[warning] force.start() is deprecated. Please use force.compute() instead.")},e};u.DEFAULT_OPTIONS=s,t.exports=u},function(t,e,r){"use strict";var n=r(4),i=r(6),o={algorithm:"overlap",layerWidth:1e3,density:.75,nodeSpacing:3,stubWidth:1},s=function(t){var e={};t=n.extend({},o,t),e.options=function(r){return arguments.length?(t=n.extend(t,r),e):t},e.computeRequiredWidth=function(e){return n.sum(e,function(e){return e.width+t.nodeSpacing})-t.nodeSpacing},e.maxWidthPerLayer=function(){return t.density*t.layerWidth},e.needToSplit=function(t){return e.estimateRequiredLayers(t)>1},e.estimateRequiredLayers=function(r){return t.layerWidth?Math.ceil(e.computeRequiredWidth(r)/e.maxWidthPerLayer()):1};var r={simple:function(r){for(var n=e.estimateRequiredLayers(r),i=[],o=0;n>o;o++)i.push([]);return r.forEach(function(e,r){var o=r%n;i[o].push(e);for(var s=e,u=o-1;u>=0;u--)s=s.createStub(t.stubWidth),i[u].push(s)}),i},roundRobin:function(t){var e=[];return e},overlap:function(r){for(var n=[],i=e.maxWidthPerLayer(),o=r.concat(),s=e.computeRequiredWidth(o);s>i;){e.countIdealOverlaps(o);var u=o.concat(),a=s;for(o=[];u.length>2&&a>i;){u.sort(function(t,e){return e.overlapCount-t.overlapCount});var c=u.shift();a-=c.width,a+=t.stubWidth,c.overlaps.forEach(function(t){t.overlapCount--}),o.push(c)}n.push(u),s=e.computeRequiredWidth(o)}o.length>0&&n.push(o);for(var h=n.length-1;h>=1;h--)for(var l=n[h],f=0;f<l.length;f++){var p=l[f];if(!p.isStub())for(var d=p,v=h-1;v>=0;v--)d=d.createStub(t.stubWidth),n[v].push(d)}return n}};return e.countIdealOverlaps=function(e){var r=new i(t.layerWidth/2);return e.forEach(function(t){r.add([t.idealLeft(),t.idealRight(),t])}),e.forEach(function(t){var e=r.search(t.idealLeft(),t.idealRight());t.overlaps=e.map(function(t){return t.data[2]}),t.overlapCount=e.length}),e},e.distribute=function(i){if(!i||0===i.length)return[];if("none"==t.algorithm||!n.isDefined(t.algorithm))return[i];if(!e.needToSplit(i))return[i];if(i=i.concat().sort(function(t,e){return t.idealPos-e.idealPos}),"function"==typeof t.algorithm)return t.algorithm(i,t);if(r.hasOwnProperty(t.algorithm))return r[t.algorithm](i);throw"Unknown algorithm: "+t.algorithm},e};s.DEFAULT_OPTIONS=o,t.exports=s},function(t,e,r){"use strict";var n={isDefined:function(t){return null!==t&&void 0!==t},last:function(t){return t.length>0?t[t.length-1]:null},pick:function(t,e){return e.reduce(function(e,r){return e[r]=t[r],e},{})},sum:function(t,e){return t.map(e).reduce(function(t,e){return t+e},0)}};n.extend=r(5),t.exports=n},function(t,e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},n=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},s=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var e=n.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&n.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!e&&!r)return!1;var o;for(o in t);return void 0===o||n.call(t,o)};t.exports=function u(){var t,e,n,i,a,c,h=arguments[0],l=1,f=arguments.length,p=!1;for("boolean"==typeof h?(p=h,h=arguments[1]||{},l=2):("object"!==("undefined"==typeof h?"undefined":r(h))&&"function"!=typeof h||null==h)&&(h={});f>l;++l)if(t=arguments[l],null!=t)for(e in t)n=h[e],i=t[e],h!==i&&(p&&i&&(s(i)||(a=o(i)))?(a?(a=!1,c=n&&o(n)?n:[]):c=n&&s(n)?n:{},h[e]=u(p,c,i)):void 0!==i&&(h[e]=i));return h}},function(t,e,r){"use strict";function n(t,e){if(e||(e={}),this.startKey=e.startKey||0,this.endKey=e.endKey||1,this.intervalHash={},this.pointTree=new c({compare:function(t,e){if(null==t)return-1;if(null==e)return 1;var r=t[0]-e[0];return r>0?1:0==r?0:-1}}),this._autoIncrement=0,!t||"number"!=typeof t)throw new Error("you must specify center index as the 2nd argument.");this.root=new u(t,this)}function i(t,e){return e.end<t.idx?(t.left||(t.left=new u(e.start+e.end>>1,this)),i.call(this,t.left,e)):t.idx<e.start?(t.right||(t.right=new u(e.start+e.end>>1,this)),i.call(this,t.right,e)):t.insert(e)}function o(t,e,r){return t?e<t.idx?(t.starts.every(function(t){var n=t.start<=e;return n&&r.push(t.result()),n}),o.call(this,t.left,e,r)):e>t.idx?(t.ends.every(function(t){var n=t.end>=e;return n&&r.push(t.result()),n}),o.call(this,t.right,e,r)):void t.starts.map(function(t){r.push(t.result())}):void 0}function s(t,e,r){if(0>=e-t)throw new Error("end must be greater than start. start: "+t+", end: "+e);var n={},i=[];o.call(this,this.root,t+e>>1,i,!0),i.forEach(function(t){n[t.id]=!0});for(var s=this.pointTree.bsearch([t,null]),u=this.pointTree;s>=0&&u[s][0]==t;)s--;var a=this.pointTree.bsearch([e,null]);if(a>=0){for(var c=u.length-1;c>=a&&u[a][0]<=e;)a++;u.slice(s+1,a).forEach(function(t){var e=t[1];n[e]=!0},this),Object.keys(n).forEach(function(n){var i=this.intervalHash[n];r.push(i.result(t,e))},this)}}function u(t){this.idx=t,this.starts=new c({compare:function(t,e){if(null==t)return-1;if(null==e)return 1;var r=t.start-e.start;return r>0?1:0==r?0:-1}}),this.ends=new c({compare:function(t,e){if(null==t)return-1;if(null==e)return 1;var r=t.end-e.end;return 0>r?1:0==r?0:-1}})}function a(t,e,r,n){if(this.id=e,this.start=t[r],this.end=t[n],this.data=t,"number"!=typeof this.start||"number"!=typeof this.end)throw new Error("start, end must be number. start: "+this.start+", end: "+this.end);if(this.start>=this.end)throw new Error("start must be smaller than end. start: "+this.start+", end: "+this.end)}var c=r(7);n.prototype.add=function(t,e){if(this.intervalHash[e])throw new Error("id "+e+" is already registered.");if(void 0==e){for(;this.intervalHash[this._autoIncrement];)this._autoIncrement++;e=this._autoIncrement}var r=new a(t,e,this.startKey,this.endKey);this.pointTree.insert([r.start,e]),this.pointTree.insert([r.end,e]),this.intervalHash[e]=r,this._autoIncrement++,i.call(this,this.root,r)},n.prototype.search=function(t,e){var r=[];if("number"!=typeof t)throw new Error(t+": invalid input");if(void 0==e)o.call(this,this.root,t,r);else{if("number"!=typeof e)throw new Error(t+","+e+": invalid input");s.call(this,t,e,r)}return r},n.prototype.remove=function(t){},u.prototype.insert=function(t){this.starts.insert(t),this.ends.insert(t)},a.prototype.result=function(t,e){var r={id:this.id,data:this.data};if("number"==typeof t&&"number"==typeof e){var n=Math.max(this.start,t),i=Math.min(this.end,e),o=i-n;r.rate1=o/(e-t),r.rate2=o/(this.end-this.start)}return r},t.exports=n},function(t,e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},n=function i(){var t=null,e={},n=arguments;["0","1"].forEach(function(i){var o=n[i];Array.isArray(o)?t=o:o&&"object"==("undefined"==typeof o?"undefined":r(o))&&(e=o)}),"function"==typeof e.filter&&(this._filter=e.filter),"function"==typeof e.compare?this._compare=e.compare:"string"==typeof e.compare&&i.compares[e.compare]&&(this._compare=i.compares[e.compare]),this._unique=!!e.unique,e.resume&&t?t.forEach(function(t,e){this.push(t)},this):t&&this.insert.apply(this,t)};n.create=function(t,e){return new n(t,e)},n.prototype=new Array,n.prototype.constructor=Array.prototype.constructor,n.prototype.insertOne=function(t){var e=this.bsearch(t);return this._unique&&null!=this.key(t,e)?!1:this._filter(t,e)?(this.splice(e+1,0,t),e+1):!1},n.prototype.insert=function(){return Array.prototype.map.call(arguments,function(t){return this.insertOne(t)},this)},n.prototype.remove=function(t){return this.splice(t,1),this},n.prototype.bsearch=function(t){if(!this.length)return-1;for(var e,r=0,n=this.length;n-r>1;){e=Math.floor((r+n)/2);var i=this[e],o=this._compare(t,i);if(0==o)return e;o>0?r=e:n=e}return 0==r&&this._compare(this[0],t)>0?-1:r},n.prototype.key=function(t,e){null==e&&(e=this.bsearch(t));var r=e;if(-1==r||this._compare(this[r],t)<0)return r+1<this.length&&0==this._compare(this[r+1],t)?r+1:null;for(;r>=1&&0==this._compare(this[r-1],t);)r--;return r},n.prototype.keys=function(t,e){var r=[];null==e&&(e=this.bsearch(t));for(var n=e;n>=0&&0==this._compare(this[n],t);)r.push(n),n--;var i=this.length;for(n=e+1;i>n&&0==this._compare(this[n],t);)r.push(n),n++;return r.length?r:null},n.prototype.unique=function(t){if(t)return this.filter(function(t,e){return 0==e||0!=this._compare(this[e-1],t)},this);var e=0;return this.map(function(t,r){return 0==r||0!=this._compare(this[r-1],t)?null:r-e++},this).forEach(function(t){null!=t&&this.remove(t)},this),this},n.prototype.toArray=function(){return this.slice()},n.prototype._filter=function(t,e){return!0},n.compares={number:function(t,e){var r=t-e;return r>0?1:0==r?0:-1},string:function(t,e){return t>e?1:t==e?0:-1}},n.prototype._compare=n.compares.string,t.exports=n},function(t,e,r){"use strict";function n(t){var e=new s.Variable(t.targetPos);return e.node=t,e}function i(t,e){if(t.length>0){e=o.extend(u,e),t.forEach(function(t,e){t.targetPos=t.parent?t.parent.currentPos:t.idealPos,t.index=e}),t.sort(function(t,e){var r=t.targetPos-e.targetPos;if(0!==r)return r;var n=t.isStub()-e.isStub();return 0!==n?n:t.index-e.index});for(var r=t.map(n),i=[],a=1;a<r.length;a++){var c,h=r[a-1],l=r[a];c=h.node.isStub()&&l.node.isStub()?(h.node.width+l.node.width)/2+e.lineSpacing:(h.node.width+l.node.width)/2+e.nodeSpacing,i.push(new s.Constraint(h,l,c))}if(o.isDefined(e.minPos)){var f=new s.Variable(e.minPos,1e10),p=r[0];i.push(new s.Constraint(f,p,p.node.width/2)),r.unshift(f)}if(o.isDefined(e.maxPos)){var d=new s.Variable(e.maxPos,1e10),v=o.last(r);i.push(new s.Constraint(v,d,v.node.width/2)),r.push(d)}new s.Solver(r,i).solve(),r.filter(function(t){return t.node}).map(function(t){return t.node.currentPos=Math.round(t.position()),t})}return t}var o=r(4),s=r(9),u={lineSpacing:2,nodeSpacing:3,minPos:0,maxPos:null};i.DEFAULT_OPTIONS=u,t.exports=i},function(t,e){"use strict";var r={},n=function(){function t(t){this.scale=t,this.AB=0,this.AD=0,this.A2=0}return t.prototype.addVariable=function(t){var e=this.scale/t.scale,r=t.offset/t.scale,n=t.weight;this.AB+=n*e*r,this.AD+=n*e*t.desiredPosition,this.A2+=n*e*e},t.prototype.getPosn=function(){return(this.AD-this.AB)/this.A2},t}();r.PositionStats=n;var i=function(){function t(t,e,r,n){void 0===n&&(n=!1),this.left=t,this.right=e,this.gap=r,this.equality=n,this.active=!1,this.unsatisfiable=!1,this.left=t,this.right=e,this.gap=r,this.equality=n}return t.prototype.slack=function(){return this.unsatisfiable?Number.MAX_VALUE:this.right.scale*this.right.position()-this.gap-this.left.scale*this.left.position()},t}();r.Constraint=i;var o=function(){function t(t,e,r){void 0===e&&(e=1),void 0===r&&(r=1),this.desiredPosition=t,this.weight=e,this.scale=r,this.offset=0}return t.prototype.dfdv=function(){return 2*this.weight*(this.position()-this.desiredPosition)},t.prototype.position=function(){return(this.block.ps.scale*this.block.posn+this.offset)/this.scale},t.prototype.visitNeighbours=function(t,e){var r=function(r,n){return r.active&&t!==n&&e(r,n)};this.cOut.forEach(function(t){return r(t,t.right)}),this.cIn.forEach(function(t){return r(t,t.left)})},t}();r.Variable=o;var s=function(){function t(t){this.vars=[],t.offset=0,this.ps=new n(t.scale),this.addVariable(t)}return t.prototype.addVariable=function(t){t.block=this,this.vars.push(t),this.ps.addVariable(t),this.posn=this.ps.getPosn()},t.prototype.updateWeightedPosition=function(){this.ps.AB=this.ps.AD=this.ps.A2=0;for(var t=0,e=this.vars.length;e>t;++t)this.ps.addVariable(this.vars[t]);this.posn=this.ps.getPosn()},t.prototype.compute_lm=function(t,e,r){var n=this,i=t.dfdv();return t.visitNeighbours(e,function(e,o){var s=n.compute_lm(o,t,r);o===e.right?(i+=s*e.left.scale,e.lm=s):(i+=s*e.right.scale,e.lm=-s),r(e)}),i/t.scale},t.prototype.populateSplitBlock=function(t,e){var r=this;t.visitNeighbours(e,function(e,n){n.offset=t.offset+(n===e.right?e.gap:-e.gap),r.addVariable(n),r.populateSplitBlock(n,t)})},t.prototype.traverse=function(t,e,r,n){var i=this;void 0===r&&(r=this.vars[0]),void 0===n&&(n=null),r.visitNeighbours(n,function(n,o){e.push(t(n)),i.traverse(t,e,o,r)})},t.prototype.findMinLM=function(){var t=null;return this.compute_lm(this.vars[0],null,function(e){!e.equality&&(null===t||e.lm<t.lm)&&(t=e)}),t},t.prototype.findMinLMBetween=function(t,e){this.compute_lm(t,null,function(){});var r=null;return this.findPath(t,null,e,function(t,e){!t.equality&&t.right===e&&(null===r||t.lm<r.lm)&&(r=t)}),r},t.prototype.findPath=function(t,e,r,n){var i=this,o=!1;return t.visitNeighbours(e,function(e,s){o||s!==r&&!i.findPath(s,t,r,n)||(o=!0,n(e,s))}),o},t.prototype.isActiveDirectedPathBetween=function(t,e){if(t===e)return!0;for(var r=t.cOut.length;r--;){var n=t.cOut[r];if(n.active&&this.isActiveDirectedPathBetween(n.right,e))return!0}return!1},t.split=function(e){return e.active=!1,[t.createSplitBlock(e.left),t.createSplitBlock(e.right)]},t.createSplitBlock=function(e){var r=new t(e);return r.populateSplitBlock(e,null),r},t.prototype.splitBetween=function(e,r){var n=this.findMinLMBetween(e,r);if(null!==n){var i=t.split(n);return{constraint:n,lb:i[0],rb:i[1]}}return null},t.prototype.mergeAcross=function(t,e,r){e.active=!0;for(var n=0,i=t.vars.length;i>n;++n){var o=t.vars[n];o.offset+=r,this.addVariable(o)}this.posn=this.ps.getPosn()},t.prototype.cost=function(){for(var t=0,e=this.vars.length;e--;){var r=this.vars[e],n=r.position()-r.desiredPosition;t+=n*n*r.weight}return t},t}();r.Block=s;var u=function(){function t(t){this.vs=t;var e=t.length;for(this.list=new Array(e);e--;){var r=new s(t[e]);this.list[e]=r,r.blockInd=e}}return t.prototype.cost=function(){for(var t=0,e=this.list.length;e--;)t+=this.list[e].cost();return t},t.prototype.insert=function(t){t.blockInd=this.list.length,this.list.push(t)},t.prototype.remove=function(t){var e=this.list.length-1,r=this.list[e];this.list.length=e,t!==r&&(this.list[t.blockInd]=r,r.blockInd=t.blockInd)},t.prototype.merge=function(t){var e=t.left.block,r=t.right.block,n=t.right.offset-t.left.offset-t.gap;e.vars.length<r.vars.length?(r.mergeAcross(e,t,n),this.remove(e)):(e.mergeAcross(r,t,-n),this.remove(r))},t.prototype.forEach=function(t){this.list.forEach(t)},t.prototype.updateBlockPositions=function(){this.list.forEach(function(t){return t.updateWeightedPosition()})},t.prototype.split=function(t){var e=this;this.updateBlockPositions(),this.list.forEach(function(r){var n=r.findMinLM();null!==n&&n.lm<a.LAGRANGIAN_TOLERANCE&&(r=n.left.block,s.split(n).forEach(function(t){return e.insert(t)}),e.remove(r),t.push(n))})},t}();r.Blocks=u;var a=function(){function t(t,e){this.vs=t,this.cs=e,this.vs=t,t.forEach(function(t){t.cIn=[],t.cOut=[]}),this.cs=e,e.forEach(function(t){t.left.cOut.push(t),t.right.cIn.push(t)}),this.inactive=e.map(function(t){return t.active=!1,t}),this.bs=null}return t.prototype.cost=function(){return this.bs.cost()},t.prototype.setStartingPositions=function(t){this.inactive=this.cs.map(function(t){return t.active=!1,t}),this.bs=new u(this.vs),this.bs.forEach(function(e,r){return e.posn=t[r]})},t.prototype.setDesiredPositions=function(t){this.vs.forEach(function(e,r){return e.desiredPosition=t[r]})},t.prototype.mostViolated=function(){for(var e=Number.MAX_VALUE,r=null,n=this.inactive,i=n.length,o=i,s=0;i>s;++s){var u=n[s];if(!u.unsatisfiable){var a=u.slack();if((u.equality||e>a)&&(e=a,r=u,o=s,u.equality))break}}return o!==i&&(e<t.ZERO_UPPERBOUND&&!r.active||r.equality)&&(n[o]=n[i-1],n.length=i-1),r},t.prototype.satisfy=function(){null==this.bs&&(this.bs=new u(this.vs)),this.bs.split(this.inactive);for(var e=null;(e=this.mostViolated())&&(e.equality||e.slack()<t.ZERO_UPPERBOUND&&!e.active);){var r=e.left.block,n=e.right.block;if(r!==n)this.bs.merge(e);else{if(r.isActiveDirectedPathBetween(e.right,e.left)){e.unsatisfiable=!0;continue}var i=r.splitBetween(e.left,e.right);if(null===i){e.unsatisfiable=!0;continue}this.bs.insert(i.lb),this.bs.insert(i.rb),this.bs.remove(r),this.inactive.push(i.constraint),e.slack()>=0?this.inactive.push(e):this.bs.merge(e)}}},t.prototype.solve=function(){this.satisfy();for(var t=Number.MAX_VALUE,e=this.bs.cost();Math.abs(t-e)>1e-4;)this.satisfy(),t=e,e=this.bs.cost();return e},t.LAGRANGIAN_TOLERANCE=-1e-4,t.ZERO_UPPERBOUND=-1e-10,t}();r.Solver=a,t.exports=r},function(t,e,r){"use strict";function n(t){this.options=c.extend({layerGap:60,nodeHeight:10,direction:"down"},t)}function i(t){return"L "+t.join(" ")}function o(t){return"M "+t.join(" ")}function s(t,e,r){return"C "+t.join(" ")+" "+e.join(" ")+" "+r.join(" ")}function u(t,e){var r=(t[1]+e[1])/2;return s([t[0],r],[e[0],r],e)}function a(t,e){var r=(t[0]+e[0])/2;return s([r,t[1]],[r,e[1]],e)}var c=r(4);n.lineTo=i,n.moveTo=o,n.curveTo=s,n.vCurveBetween=u,n.hCurveBetween=a,n.prototype.getWaypoints=function(t){var e=this.options,r=e.direction,n=t.getPathFromRoot(),i=e.nodeHeight+e.layerGap;return"left"===r?[[[0,n[0].idealPos]]].concat(n.map(function(t,r){var n=i*(r+1)*-1;return[[n+e.nodeHeight,t.currentPos],[n,t.currentPos]]})):"right"===r?[[[0,n[0].idealPos]]].concat(n.map(function(t,r){var n=i*(r+1);return[[n-e.nodeHeight,t.currentPos],[n,t.currentPos]]})):"up"===r?[[[n[0].idealPos,0]]].concat(n.map(function(t,r){var n=i*(r+1)*-1;return[[t.currentPos,n+e.nodeHeight],[t.currentPos,n]]})):[[[n[0].idealPos,0]]].concat(n.map(function(t,r){var n=i*(r+1);return[[t.currentPos,n-e.nodeHeight],[t.currentPos,n]]}))},n.prototype.layout=function(t){var e=this.options,r=e.layerGap+e.nodeHeight;switch(e.direction){case"left":t.forEach(function(t){var n=t.getLayerIndex()*r+e.layerGap;t.x=-n-e.nodeHeight,t.y=t.currentPos,t.dx=e.nodeHeight,t.dy=t.width});break;case"right":t.forEach(function(t){var n=t.getLayerIndex()*r+e.layerGap;t.x=n,t.y=t.currentPos,t.dx=e.nodeHeight,t.dy=t.width});break;case"up":t.forEach(function(t){var n=t.getLayerIndex()*r+e.layerGap;t.x=t.currentPos,t.y=-n-e.nodeHeight,t.dx=t.width,t.dy=e.nodeHeight});break;default:case"down":t.forEach(function(t){var n=t.getLayerIndex()*r+e.layerGap;t.x=t.currentPos,t.y=n,t.dx=t.width,t.dy=e.nodeHeight})}return t},n.prototype.generatePath=function(t){var e=this.options,r=e.direction,n=this.getWaypoints(t,r),s=[o(n[0][0])];return"left"===r||"right"===r?n.reduce(function(t,e,r){return s.push(a(t[t.length-1],e[0])),r<n.length-1&&s.push(i(e[1])),e}):n.reduce(function(t,e,r){return s.push(u(t[t.length-1],e[0])),r<n.length-1&&s.push(i(e[1])),e}),s.join(" ")},t.exports=n}])});