"use strict";Liferay.Loader.define("portal-workflow-kaleo-designer-web$dagre@0.8.2/lib/util",["module","exports","require","./lodash","./graphlib"],(function(n,e,r){window;{var o=r("./lodash"),t=r("./graphlib").Graph;function addDummyNode(n,e,r,t){var a;do{a=o.uniqueId(t)}while(n.hasNode(a));return r.dummy=e,n.setNode(a,r),a}function maxRank(n){return o.max(o.map(n.nodes(),(function(e){var r=n.node(e).rank;if(!o.isUndefined(r))return r})))}n.exports={addDummyNode:addDummyNode,simplify:function simplify(n){var e=(new t).setGraph(n.graph());return o.forEach(n.nodes(),(function(r){e.setNode(r,n.node(r))})),o.forEach(n.edges(),(function(r){var o=e.edge(r.v,r.w)||{weight:0,minlen:1},t=n.edge(r);e.setEdge(r.v,r.w,{weight:o.weight+t.weight,minlen:Math.max(o.minlen,t.minlen)})})),e},asNonCompoundGraph:function asNonCompoundGraph(n){var e=new t({multigraph:n.isMultigraph()}).setGraph(n.graph());return o.forEach(n.nodes(),(function(r){n.children(r).length||e.setNode(r,n.node(r))})),o.forEach(n.edges(),(function(r){e.setEdge(r,n.edge(r))})),e},successorWeights:function successorWeights(n){var e=o.map(n.nodes(),(function(e){var r={};return o.forEach(n.outEdges(e),(function(e){r[e.w]=(r[e.w]||0)+n.edge(e).weight})),r}));return o.zipObject(n.nodes(),e)},predecessorWeights:function predecessorWeights(n){var e=o.map(n.nodes(),(function(e){var r={};return o.forEach(n.inEdges(e),(function(e){r[e.v]=(r[e.v]||0)+n.edge(e).weight})),r}));return o.zipObject(n.nodes(),e)},intersectRect:function intersectRect(n,e){var r,o,t=n.x,a=n.y,i=e.x-t,d=e.y-a,s=n.width/2,u=n.height/2;if(!i&&!d)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(d)*s>Math.abs(i)*u?(d<0&&(u=-u),r=u*i/d,o=u):(i<0&&(s=-s),r=s,o=s*d/i),{x:t+r,y:a+o}},buildLayerMatrix:function buildLayerMatrix(n){var e=o.map(o.range(maxRank(n)+1),(function(){return[]}));return o.forEach(n.nodes(),(function(r){var t=n.node(r),a=t.rank;o.isUndefined(a)||(e[a][t.order]=r)})),e},normalizeRanks:function normalizeRanks(n){var e=o.minBy(o.map(n.nodes(),(function(e){return n.node(e).rank})));o.forEach(n.nodes(),(function(r){var t=n.node(r);o.has(t,"rank")&&(t.rank-=e)}))},removeEmptyRanks:function removeEmptyRanks(n){var e=o.minBy(o.map(n.nodes(),(function(e){return n.node(e).rank}))),r=[];o.forEach(n.nodes(),(function(o){var t=n.node(o).rank-e;r[t]||(r[t]=[]),r[t].push(o)}));var t=0,a=n.graph().nodeRankFactor;o.forEach(r,(function(e,r){o.isUndefined(e)&&r%a!=0?--t:t&&o.forEach(e,(function(e){n.node(e).rank+=t}))}))},addBorderNode:function addBorderNode(n,e,r,o){var t={width:0,height:0};return arguments.length>=4&&(t.rank=r,t.order=o),addDummyNode(n,"border",t,e)},maxRank:maxRank,partition:function partition(n,e){var r={lhs:[],rhs:[]};return o.forEach(n,(function(n){e(n)?r.lhs.push(n):r.rhs.push(n)})),r},time:function time(n,e){var r=o.now();try{return e()}finally{console.log(n+" time: "+(o.now()-r)+"ms")}},notime:function notime(n,e){return e()}}}}));
//# sourceMappingURL=util.js.map