You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by xi...@apache.org on 2017/05/02 17:09:33 UTC

[1/4] samza git commit: SAMZA-1204: Visualize StreamGraph and ExecutionPlan

Repository: samza
Updated Branches:
  refs/heads/master ad1f16175 -> b71b253d2


http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-shell/src/main/visualizer/js/planToDagre.js
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/visualizer/js/planToDagre.js b/samza-shell/src/main/visualizer/js/planToDagre.js
new file mode 100644
index 0000000..8ba198e
--- /dev/null
+++ b/samza-shell/src/main/visualizer/js/planToDagre.js
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function planToDagre(data) {
+  // Create the input graph
+  var g = new dagreD3.graphlib.Graph()
+      .setGraph({
+        rankdir: "LR"
+      })
+      .setDefaultEdgeLabel(function() { return {}; });
+
+  var allStreams = [data.sourceStreams, data.sinkStreams, data.intermediateStreams];
+  var streamClasses = ["source", "sink", "intermediate"];
+  for (var i = 0; i < allStreams.length; i++) {
+    var streams = allStreams[i];
+    for (var streamId in streams) {
+      var stream = streams[streamId];
+      var labelVal = "<div><h3 class=\"topbar\">" + stream.streamSpec.id + "</h3><ul class=\"detailBox\" >"
+      labelVal += "<li>SystemName: " + stream.streamSpec.systemName + "</li>"
+      labelVal += "<li>PhysicalName: " + stream.streamSpec.physicalName + "</li>"
+      labelVal += "<li>PartitionCount: " + stream.streamSpec.partitionCount + "</li>"
+      labelVal += "</ul></div>"
+      g.setNode(streamId,  { label: labelVal, labelType: "html", shape: "ellipse", class: streamClasses[i] });
+    }
+  }
+
+  var jobs = data.jobs;
+  for (var i = 0; i < jobs.length; i++) {
+    var canonicalOpIds = jobs[i].operatorGraph.canonicalOpIds;
+    var operators = jobs[i].operatorGraph.operators;
+    for (var opId in operators) {
+      var operator = operators[opId];
+      var labelVal = "<div><h3 class=\"topbar\">" + operator.opCode + "</h3><ul class=\"detailBox\">";
+      var opId = operator.opId;
+      if (!(opId in canonicalOpIds)) {
+        canonicalOpIds[opId] = opId.toString();
+      }
+      labelVal +=  "<li>ID: " + opId + "</li>";
+      labelVal +=  "<li>@" + operator.sourceLocation + "</li>";
+
+      var keys = ["opId", "opCode", "sourceLocation", "outputStreamId", "nextOperatorIds"];
+      for (var key in operator) {
+        if (keys.indexOf(key) === -1) {
+          labelVal += "<li>" + key + ": " + operator[key] + "</li>";
+        }
+      }
+
+      labelVal += "</ul></div>";
+      g.setNode(canonicalOpIds[opId],  { label: labelVal, labelType: "html", rx: 5, ry: 5 });
+    }
+  }
+
+  for (var i = 0; i < jobs.length; i++) {
+    var inputs = jobs[i].operatorGraph.inputStreams;
+    for (var k = 0; k < inputs.length; k++) {
+      var input = inputs[k];
+      for (var m = 0; m < input.nextOperatorIds.length; m++) {
+        g.setEdge(input.streamId, canonicalOpIds[input.nextOperatorIds[m]]);
+      }
+    }
+
+    var operators = jobs[i].operatorGraph.operators;
+    for (var opId in operators) {
+      var operator = operators[opId];
+      for (var j = 0; j < operator.nextOperatorIds.length; j++) {
+        g.setEdge(canonicalOpIds[opId], canonicalOpIds[operator.nextOperatorIds[j]]);
+      }
+      if (typeof(operator.outputStreamId) !== 'undefined') {
+        g.setEdge(canonicalOpIds[opId], operator.outputStreamId);
+      }
+    }
+  }
+
+  return g;
+}

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-shell/src/main/visualizer/plan.html
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/visualizer/plan.html b/samza-shell/src/main/visualizer/plan.html
new file mode 100644
index 0000000..9fe2e26
--- /dev/null
+++ b/samza-shell/src/main/visualizer/plan.html
@@ -0,0 +1,118 @@
+<!doctype html>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<meta charset="utf-8">
+<title>SAMZA Visualizer</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+
+<script src="js/d3.v3.min.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/dagre-d3.min.js"></script>
+<script type="text/javascript" src="js/planToDagre.js"></script>
+<script type="text/javascript" src="plan.json"></script>
+<script type="text/javascript" src="../plan/plan.json"></script>
+
+<h1>SAMZA Visualizer</h1>
+
+<style id="css">
+  body {
+    font: 300 14px 'Helvetica Neue', Helvetica;
+  }
+
+  svg {
+    margin-top: 30px;
+  }
+
+  .node rect {
+    stroke: #999;
+    fill: #E8E8EE;
+    stroke-width: 1.5px;
+  }
+
+  .node ellipse {
+    stroke: #999;
+    fill: #fff;
+    stroke-width: 1.5px;
+  }
+
+  .edgePath path {
+    stroke: #333;
+    stroke-width: 1.5px;
+  }
+
+  g.source > ellipse {
+    fill: #BDEDFF;
+  }
+
+  g.sink > ellipse {
+    fill: #BDEDFF;
+  }
+
+  g.intermediate > ellipse {
+    fill: #C3FDB8;
+  }
+
+  .topbar {
+    text-align: center;
+    border-bottom: solid;
+    border-bottom-color: #cdcfd2;
+    border-bottom-width: 1px;
+  }
+
+  .detailBox{
+    margin-top: -10px;
+  }
+</style>
+
+<section>
+  <p id="summary"/>
+</section>
+
+<svg id="svg-canvas" width=1200 height=1000><g/></svg>
+
+<script id="js">
+  var data = JSON.parse(plan);
+  var g = planToDagre(data);
+
+  var summary = "A visualization of application <b>" + data.applicationName + "-" + data.applicationId + "</b>";
+  summary += ", which consists of " + data.jobs.length + " job(s), ";
+  summary += Object.keys(data.sourceStreams).length + " input stream(s), and ";
+  summary += Object.keys(data.sinkStreams).length + " output stream(s).";
+  document.getElementById("summary").innerHTML = summary;
+
+  // Set up an SVG group so that we can translate the final graph.
+  var svg = d3.select("svg"),
+      inner = svg.select("g");
+
+  // Set up zoom support
+  var zoom = d3.behavior.zoom().on("zoom", function() {
+      inner.attr("transform", "translate(" + d3.event.translate + ")" +
+                                  "scale(" + d3.event.scale + ")");
+    });
+  svg.call(zoom);
+
+  // Create the renderer
+  var render = new dagreD3.render();
+
+  // Run the renderer. This is what draws the final graph.
+  render(inner, g);
+
+  var initialScale = 0.65;
+  zoom.scale(initialScale).event(svg);
+  svg.attr('height', g.graph().height * initialScale + 100);
+</script>


[2/4] samza git commit: SAMZA-1204: Visualize StreamGraph and ExecutionPlan

Posted by xi...@apache.org.
http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-shell/src/main/visualizer/js/dagre-d3.min.js
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/visualizer/js/dagre-d3.min.js b/samza-shell/src/main/visualizer/js/dagre-d3.min.js
new file mode 100644
index 0000000..b4821d8
--- /dev/null
+++ b/samza-shell/src/main/visualizer/js/dagre-d3.min.js
@@ -0,0 +1,28 @@
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.dagreD3=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(o)return o(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=e[a]={exports:{}};t[a][0].call(f.exports,function(n){var e=t[a][1][n];return i(e?e:n)},f,f.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,n,e){/**
+ * @license
+ * Copyright (c) 2012-2013 Chris Pettitt
+ *
+ * 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.
+ */
+n.exports={graphlib:t("./lib/graphlib"),dagre:t("./lib/dagre"),intersect:t("./lib/intersect"),render:t("./lib/render"),util:t("./lib/util"),version:t("./lib/version")}},{"./lib/dagre":8,"./lib/graphlib":9,"./lib/intersect":10,"./lib/render":25,"./lib/util":27,"./lib/version":28}],2:[function(t,n,e){function r(t,n,e,r){var i=t.append("marker").attr("id",n).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),o=i.append("path").attr("d","M 0 0 L 10 5 L 0 10 z").style("stroke-width",1).style("stroke-dasharray","1,0");a.applyStyle(o,e[r+"Style"]),e[r+"Class"]&&o.attr("class",e[r+"Class"])}function i(t,n,e,r){var i=t.append("marker").attr("id",n).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),o=i.append("path").attr("d","M 0 0 L 10 5 L 0 10 L 4 5 z").style("stroke-width",1)
 .style("stroke-dasharray","1,0");a.applyStyle(o,e[r+"Style"]),e[r+"Class"]&&o.attr("class",e[r+"Class"])}function o(t,n,e,r){var i=t.append("marker").attr("id",n).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),o=i.append("path").attr("d","M 0 5 L 10 5").style("stroke-width",1).style("stroke-dasharray","1,0");a.applyStyle(o,e[r+"Style"]),e[r+"Class"]&&o.attr("class",e[r+"Class"])}var a=t("./util");n.exports={"default":r,normal:r,vee:i,undirected:o}},{"./util":27}],3:[function(t,n,e){function r(t,n){var e=n.nodes().filter(function(t){return i.isSubgraph(n,t)}),r=t.selectAll("g.cluster").data(e,function(t){return t});return r.selectAll("*").remove(),r.enter().append("g").attr("class","cluster").attr("id",function(t){var e=n.node(t);return e.id}).style("opacity",0),i.applyTransition(r,n).style("opacity",1),r.each(function(t){var e=n.node(t),r=d3.select(this);d3.select(this).ap
 pend("rect");var i=r.append("g").attr("class","label");o(i,e,e.clusterLabelPos)}),r.selectAll("rect").each(function(t){var e=n.node(t),r=d3.select(this);i.applyStyle(r,e.style)}),i.applyTransition(r.exit(),n).style("opacity",0).remove(),r}var i=t("./util"),o=t("./label/add-label");n.exports=r},{"./label/add-label":18,"./util":27}],4:[function(t,n,e){"use strict";function r(t,n){var e=t.selectAll("g.edgeLabel").data(n.edges(),function(t){return a.edgeToId(t)}).classed("update",!0);return e.selectAll("*").remove(),e.enter().append("g").classed("edgeLabel",!0).style("opacity",0),e.each(function(t){var e=n.edge(t),r=o(u.select(this),n.edge(t),0,0).classed("label",!0),a=r.node().getBBox();e.labelId&&r.attr("id",e.labelId),i.has(e,"width")||(e.width=a.width),i.has(e,"height")||(e.height=a.height)}),a.applyTransition(e.exit(),n).style("opacity",0).remove(),e}var i=t("./lodash"),o=t("./label/add-label"),a=t("./util"),u=t("./d3");n.exports=r},{"./d3":7,"./label/add-label":18,"./lodash":21,".
 /util":27}],5:[function(t,n,e){"use strict";function r(t,n,e){var r=t.selectAll("g.edgePath").data(n.edges(),function(t){return h.edgeToId(t)}).classed("update",!0);return c(r,n),s(r,n),h.applyTransition(r,n).style("opacity",1),r.each(function(t){var e=d.select(this),r=n.edge(t);r.elem=this,r.id&&e.attr("id",r.id),h.applyClass(e,r["class"],(e.classed("update")?"update ":"")+"edgePath")}),r.selectAll("path.path").each(function(t){var e=n.edge(t);e.arrowheadId=f.uniqueId("arrowhead");var r=d.select(this).attr("marker-end",function(){return"url("+i(location.href,e.arrowheadId)+")"}).style("fill","none");h.applyTransition(r,n).attr("d",function(t){return o(n,t)}),h.applyStyle(r,e.style)}),r.selectAll("defs *").remove(),r.selectAll("defs").each(function(t){var r=n.edge(t),i=e[r.arrowhead];i(d.select(this),r.arrowheadId,r,"arrowhead")}),r}function i(t,n){var e=t.split("#")[0];return e+"#"+n}function o(t,n){var e=t.edge(n),r=t.node(n.v),i=t.node(n.w),o=e.points.slice(1,e.points.length-1);r
 eturn o.unshift(l(r,o[0])),o.push(l(i,o[o.length-1])),a(e,o)}function a(t,n){var e=d.svg.line().x(function(t){return t.x}).y(function(t){return t.y});return f.has(t,"lineInterpolate")&&e.interpolate(t.lineInterpolate),f.has(t,"lineTension")&&e.tension(Number(t.lineTension)),e(n)}function u(t){var n=t.getBBox(),e=t.ownerSVGElement.getScreenCTM().inverse().multiply(t.getScreenCTM()).translate(n.width/2,n.height/2);return{x:e.e,y:e.f}}function c(t,n){var e=t.enter().append("g").attr("class","edgePath").style("opacity",0);e.append("path").attr("class","path").attr("d",function(t){var e=n.edge(t),r=n.node(t.v).elem,i=f.range(e.points.length).map(function(){return u(r)});return a(e,i)}),e.append("defs")}function s(t,n){var e=t.exit();h.applyTransition(e,n).style("opacity",0).remove(),h.applyTransition(e.select("path.path"),n).attr("d",function(t){var e=n.node(t.v);if(e){var r=f.range(this.getTotalLength()).map(function(){return e});return a({},r)}return d.select(this).attr("d")})}var f=t(
 "./lodash"),l=t("./intersect/intersect-node"),h=t("./util"),d=t("./d3");n.exports=r},{"./d3":7,"./intersect/intersect-node":14,"./lodash":21,"./util":27}],6:[function(t,n,e){"use strict";function r(t,n,e){var r=n.nodes().filter(function(t){return!a.isSubgraph(n,t)}),c=t.selectAll("g.node").data(r,function(t){return t}).classed("update",!0);return c.selectAll("*").remove(),c.enter().append("g").attr("class","node").style("opacity",0),c.each(function(t){var r=n.node(t),c=u.select(this),s=c.append("g").attr("class","label"),f=o(s,r),l=e[r.shape],h=i.pick(f.node().getBBox(),"width","height");r.elem=this,r.id&&c.attr("id",r.id),r.labelId&&s.attr("id",r.labelId),a.applyClass(c,r["class"],(c.classed("update")?"update ":"")+"node"),i.has(r,"width")&&(h.width=r.width),i.has(r,"height")&&(h.height=r.height),h.width+=r.paddingLeft+r.paddingRight,h.height+=r.paddingTop+r.paddingBottom,s.attr("transform","translate("+(r.paddingLeft-r.paddingRight)/2+","+(r.paddingTop-r.paddingBottom)/2+")");var 
 d=l(u.select(this),h,r);a.applyStyle(d,r.style);var p=d.node().getBBox();r.width=p.width,r.height=p.height}),a.applyTransition(c.exit(),n).style("opacity",0).remove(),c}var i=t("./lodash"),o=t("./label/add-label"),a=t("./util"),u=t("./d3");n.exports=r},{"./d3":7,"./label/add-label":18,"./lodash":21,"./util":27}],7:[function(t,n,e){n.exports=window.d3},{}],8:[function(t,n,e){var r;if(t)try{r=t("dagre")}catch(i){}r||(r=window.dagre),n.exports=r},{dagre:29}],9:[function(t,n,e){var r;if(t)try{r=t("graphlib")}catch(i){}r||(r=window.graphlib),n.exports=r},{graphlib:59}],10:[function(t,n,e){n.exports={node:t("./intersect-node"),circle:t("./intersect-circle"),ellipse:t("./intersect-ellipse"),polygon:t("./intersect-polygon"),rect:t("./intersect-rect")}},{"./intersect-circle":11,"./intersect-ellipse":12,"./intersect-node":14,"./intersect-polygon":15,"./intersect-rect":16}],11:[function(t,n,e){function r(t,n,e){return i(t,n,n,e)}var i=t("./intersect-ellipse");n.exports=r},{"./intersect-ellipse
 ":12}],12:[function(t,n,e){function r(t,n,e,r){var i=t.x,o=t.y,a=i-r.x,u=o-r.y,c=Math.sqrt(n*n*u*u+e*e*a*a),s=Math.abs(n*e*a/c);r.x<i&&(s=-s);var f=Math.abs(n*e*u/c);return r.y<o&&(f=-f),{x:i+s,y:o+f}}n.exports=r},{}],13:[function(t,n,e){function r(t,n,e,r){var o,a,u,c,s,f,l,h,d,p,g,v,y,_,m;return o=n.y-t.y,u=t.x-n.x,s=n.x*t.y-t.x*n.y,d=o*e.x+u*e.y+s,p=o*r.x+u*r.y+s,0!==d&&0!==p&&i(d,p)||(a=r.y-e.y,c=e.x-r.x,f=r.x*e.y-e.x*r.y,l=a*t.x+c*t.y+f,h=a*n.x+c*n.y+f,0!==l&&0!==h&&i(l,h)||(g=o*c-a*u,0===g))?void 0:(v=Math.abs(g/2),y=u*f-c*s,_=0>y?(y-v)/g:(y+v)/g,y=a*s-o*f,m=0>y?(y-v)/g:(y+v)/g,{x:_,y:m})}function i(t,n){return t*n>0}n.exports=r},{}],14:[function(t,n,e){function r(t,n){return t.intersect(n)}n.exports=r},{}],15:[function(t,n,e){function r(t,n,e){var r=t.x,o=t.y,a=[],u=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;n.forEach(function(t){u=Math.min(u,t.x),c=Math.min(c,t.y)});for(var s=r-t.width/2-u,f=o-t.height/2-c,l=0;l<n.length;l++){var h=n[l],d=n[l<n.length-1?l+1:0],p=i(t
 ,e,{x:s+h.x,y:f+h.y},{x:s+d.x,y:f+d.y});p&&a.push(p)}return a.length?(a.length>1&&a.sort(function(t,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i),a=n.x-e.x,u=n.y-e.y,c=Math.sqrt(a*a+u*u);return c>o?-1:o===c?0:1}),a[0]):(console.log("NO INTERSECTION FOUND, RETURN NODE CENTER",t),t)}var i=t("./intersect-line");n.exports=r},{"./intersect-line":13}],16:[function(t,n,e){function r(t,n){var e,r,i=t.x,o=t.y,a=n.x-i,u=n.y-o,c=t.width/2,s=t.height/2;return Math.abs(u)*c>Math.abs(a)*s?(0>u&&(s=-s),e=0===u?0:s*a/u,r=s):(0>a&&(c=-c),e=c,r=0===a?0:c*u/a),{x:i+e,y:o+r}}n.exports=r},{}],17:[function(t,n,e){function r(t,n){var e=t.append("foreignObject").attr("width","100000"),r=e.append("xhtml:div");r.attr("xmlns","http://www.w3.org/1999/xhtml");var o=n.label;switch(typeof o){case"function":r.insert(o);break;case"object":r.insert(function(){return o});break;default:r.html(o)}i.applyStyle(r,n.labelStyle),r.style("display","inline-block"),r.style("white-space","nowrap");var a=r[0][0].getBoundingCl
 ientRect();return e.attr("width",a.width).attr("height",a.height),e}var i=t("../util");n.exports=r},{"../util":27}],18:[function(t,n,e){function r(t,n,e){var r=n.label,u=t.append("g");"svg"===n.labelType?a(u,n):"string"!=typeof r||"html"===n.labelType?o(u,n):i(u,n);var c,s=u.node().getBBox();switch(e){case"top":c=-n.height/2;break;case"bottom":c=n.height/2-s.height;break;default:c=-s.height/2}return u.attr("transform","translate("+-s.width/2+","+c+")"),u}var i=t("./add-text-label"),o=t("./add-html-label"),a=t("./add-svg-label");n.exports=r},{"./add-html-label":17,"./add-svg-label":19,"./add-text-label":20}],19:[function(t,n,e){function r(t,n){var e=t;return e.node().appendChild(n.label),i.applyStyle(e,n.labelStyle),e}var i=t("../util");n.exports=r},{"../util":27}],20:[function(t,n,e){function r(t,n){for(var e=t.append("text"),r=i(n.label).split("\n"),a=0;a<r.length;a++)e.append("tspan").attr("xml:space","preserve").attr("dy","1em").attr("x","1").text(r[a]);return o.applyStyle(e,n.la
 belStyle),e}function i(t){for(var n,e="",r=!1,i=0;i<t.length;++i)if(n=t[i],r){switch(n){case"n":e+="\n";break;default:e+=n}r=!1}else"\\"===n?r=!0:e+=n;return e}var o=t("../util");n.exports=r},{"../util":27}],21:[function(t,n,e){var r;if(t)try{r=t("lodash")}catch(i){}r||(r=window._),n.exports=r},{lodash:79}],22:[function(t,n,e){"use strict";function r(t,n){function e(t){var e=n.node(t);return"translate("+e.x+","+e.y+")"}var r=t.filter(function(){return!o.select(this).classed("update")});r.attr("transform",e),i.applyTransition(t,n).style("opacity",1).attr("transform",e),i.applyTransition(r.selectAll("rect"),n).attr("width",function(t){return n.node(t).width}).attr("height",function(t){return n.node(t).height}).attr("x",function(t){var e=n.node(t);return-e.width/2}).attr("y",function(t){var e=n.node(t);return-e.height/2})}var i=t("./util"),o=t("./d3");n.exports=r},{"./d3":7,"./util":27}],23:[function(t,n,e){"use strict";function r(t,n){function e(t){var e=n.edge(t);return a.has(e,"x")?
 "translate("+e.x+","+e.y+")":""}var r=t.filter(function(){return!o.select(this).classed("update")});r.attr("transform",e),i.applyTransition(t,n).style("opacity",1).attr("transform",e)}var i=t("./util"),o=t("./d3"),a=t("./lodash");n.exports=r},{"./d3":7,"./lodash":21,"./util":27}],24:[function(t,n,e){"use strict";function r(t,n){function e(t){var e=n.node(t);return"translate("+e.x+","+e.y+")"}var r=t.filter(function(){return!o.select(this).classed("update")});r.attr("transform",e),i.applyTransition(t,n).style("opacity",1).attr("transform",e)}var i=t("./util"),o=t("./d3");n.exports=r},{"./d3":7,"./util":27}],25:[function(t,n,e){function r(){var n=t("./create-nodes"),e=t("./create-clusters"),r=t("./create-edge-labels"),u=t("./create-edge-paths"),s=t("./position-nodes"),f=t("./position-edge-labels"),l=t("./position-clusters"),h=t("./shapes"),d=t("./arrows"),p=function(t,p){i(p);var g=a(t,"output"),v=a(g,"clusters"),y=a(g,"edgePaths"),_=r(a(g,"edgeLabels"),p),m=n(a(g,"nodes"),p,h);c(p),s
 (m,p),f(_,p),u(y,p,d);var w=e(v,p);l(w,p),o(p)};return p.createNodes=function(t){return arguments.length?(n=t,p):n},p.createClusters=function(t){return arguments.length?(e=t,p):e},p.createEdgeLabels=function(t){return arguments.length?(r=t,p):r},p.createEdgePaths=function(t){return arguments.length?(u=t,p):u},p.shapes=function(t){return arguments.length?(h=t,p):h},p.arrows=function(t){return arguments.length?(d=t,p):d},p}function i(t){t.nodes().forEach(function(n){var e=t.node(n);u.has(e,"label")||t.children(n).length||(e.label=n),u.has(e,"paddingX")&&u.defaults(e,{paddingLeft:e.paddingX,paddingRight:e.paddingX}),u.has(e,"paddingY")&&u.defaults(e,{paddingTop:e.paddingY,paddingBottom:e.paddingY}),u.has(e,"padding")&&u.defaults(e,{paddingLeft:e.padding,paddingRight:e.padding,paddingTop:e.padding,paddingBottom:e.padding}),u.defaults(e,s),u.each(["paddingLeft","paddingRight","paddingTop","paddingBottom"],function(t){e[t]=Number(e[t])}),u.has(e,"width")&&(e._prevWidth=e.width),u.has(e,"h
 eight")&&(e._prevHeight=e.height)}),t.edges().forEach(function(n){var e=t.edge(n);u.has(e,"label")||(e.label=""),u.defaults(e,f)})}function o(t){u.each(t.nodes(),function(n){var e=t.node(n);u.has(e,"_prevWidth")?e.width=e._prevWidth:delete e.width,u.has(e,"_prevHeight")?e.height=e._prevHeight:delete e.height,delete e._prevWidth,delete e._prevHeight})}function a(t,n){var e=t.select("g."+n);return e.empty()&&(e=t.append("g").attr("class",n)),e}var u=t("./lodash"),c=t("./dagre").layout;n.exports=r;var s={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},f={arrowhead:"normal",lineInterpolate:"linear"}},{"./arrows":2,"./create-clusters":3,"./create-edge-labels":4,"./create-edge-paths":5,"./create-nodes":6,"./dagre":8,"./lodash":21,"./position-clusters":22,"./position-edge-labels":23,"./position-nodes":24,"./shapes":26}],26:[function(t,n,e){"use strict";function r(t,n,e){var r=t.insert("rect",":first-child").attr("rx",e.rx).attr("ry",e.ry).attr("x",-n.w
 idth/2).attr("y",-n.height/2).attr("width",n.width).attr("height",n.height);return e.intersect=function(t){return u(e,t)},r}function i(t,n,e){var r=n.width/2,i=n.height/2,o=t.insert("ellipse",":first-child").attr("x",-n.width/2).attr("y",-n.height/2).attr("rx",r).attr("ry",i);return e.intersect=function(t){return c(e,r,i,t)},o}function o(t,n,e){var r=Math.max(n.width,n.height)/2,i=t.insert("circle",":first-child").attr("x",-n.width/2).attr("y",-n.height/2).attr("r",r);return e.intersect=function(t){return s(e,r,t)},i}function a(t,n,e){var r=n.width*Math.SQRT2/2,i=n.height*Math.SQRT2/2,o=[{x:0,y:-i},{x:-r,y:0},{x:0,y:i},{x:r,y:0}],a=t.insert("polygon",":first-child").attr("points",o.map(function(t){return t.x+","+t.y}).join(" "));return e.intersect=function(t){return f(e,o,t)},a}var u=t("./intersect/intersect-rect"),c=t("./intersect/intersect-ellipse"),s=t("./intersect/intersect-circle"),f=t("./intersect/intersect-polygon");n.exports={rect:r,ellipse:i,circle:o,diamond:a}},{"./interse
 ct/intersect-circle":11,"./intersect/intersect-ellipse":12,"./intersect/intersect-polygon":15,"./intersect/intersect-rect":16}],27:[function(t,n,e){function r(t,n){return!!t.children(n).length}function i(t){return o(t.v)+":"+o(t.w)+":"+o(t.name)}function o(t){return t?String(t).replace(f,"\\:"):""}function a(t,n){n&&t.attr("style",n)}function u(t,n,e){n&&t.attr("class",n).attr("class",e+" "+t.attr("class"))}function c(t,n){var e=n.graph();if(s.isPlainObject(e)){var r=e.transition;if(s.isFunction(r))return r(t)}return t}var s=t("./lodash");n.exports={isSubgraph:r,edgeToId:i,applyStyle:a,applyClass:u,applyTransition:c};var f=/:/g},{"./lodash":21}],28:[function(t,n,e){n.exports="0.4.17"},{}],29:[function(t,n,e){n.exports={graphlib:t("./lib/graphlib"),layout:t("./lib/layout"),debug:t("./lib/debug"),util:{time:t("./lib/util").time,notime:t("./lib/util").notime},version:t("./lib/version")}},{"./lib/debug":34,"./lib/graphlib":35,"./lib/layout":37,"./lib/util":57,"./lib/version":58}],30:[fu
 nction(t,n,e){"use strict";function r(t){function n(t){return function(n){return t.edge(n).weight}}var e="greedy"===t.graph().acyclicer?u(t,n(t)):i(t);a.each(e,function(n){var e=t.edge(n);t.removeEdge(n),e.forwardName=n.name,e.reversed=!0,t.setEdge(n.w,n.v,e,a.uniqueId("rev"))})}function i(t){function n(o){a.has(i,o)||(i[o]=!0,r[o]=!0,a.each(t.outEdges(o),function(t){a.has(r,t.w)?e.push(t):n(t.w)}),delete r[o])}var e=[],r={},i={};return a.each(t.nodes(),n),e}function o(t){a.each(t.edges(),function(n){var e=t.edge(n);if(e.reversed){t.removeEdge(n);var r=e.forwardName;delete e.reversed,delete e.forwardName,t.setEdge(n.w,n.v,e,r)}})}var a=t("./lodash"),u=t("./greedy-fas");n.exports={run:r,undo:o}},{"./greedy-fas":36,"./lodash":38}],31:[function(t,n,e){function r(t){function n(e){var r=t.children(e),a=t.node(e);if(r.length&&o.each(r,n),o.has(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(var u=a.minRank,c=a.maxRank+1;c>u;++u)i(t,"borderLeft","_bl",e,a,u),i(t,"borderRight","_br",e,a,
 u)}}o.each(t.children(),n)}function i(t,n,e,r,i,o){var u={width:0,height:0,rank:o,borderType:n},c=i[n][o-1],s=a.addDummyNode(t,"border",u,e);i[n][o]=s,t.setParent(s,r),c&&t.setEdge(c,s,{weight:1})}var o=t("./lodash"),a=t("./util");n.exports=r},{"./lodash":38,"./util":57}],32:[function(t,n,e){"use strict";function r(t){var n=t.graph().rankdir.toLowerCase();("lr"===n||"rl"===n)&&o(t)}function i(t){var n=t.graph().rankdir.toLowerCase();("bt"===n||"rl"===n)&&u(t),("lr"===n||"rl"===n)&&(s(t),o(t))}function o(t){l.each(t.nodes(),function(n){a(t.node(n))}),l.each(t.edges(),function(n){a(t.edge(n))})}function a(t){var n=t.width;t.width=t.height,t.height=n}function u(t){l.each(t.nodes(),function(n){c(t.node(n))}),l.each(t.edges(),function(n){var e=t.edge(n);l.each(e.points,c),l.has(e,"y")&&c(e)})}function c(t){t.y=-t.y}function s(t){l.each(t.nodes(),function(n){f(t.node(n))}),l.each(t.edges(),function(n){var e=t.edge(n);l.each(e.points,f),l.has(e,"x")&&f(e)})}function f(t){var n=t.x;t.x=t.y,
 t.y=n}var l=t("./lodash");n.exports={adjust:r,undo:i}},{"./lodash":38}],33:[function(t,n,e){function r(){var t={};t._next=t._prev=t,this._sentinel=t}function i(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function o(t,n){return"_next"!==t&&"_prev"!==t?n:void 0}n.exports=r,r.prototype.dequeue=function(){var t=this._sentinel,n=t._prev;return n!==t?(i(n),n):void 0},r.prototype.enqueue=function(t){var n=this._sentinel;t._prev&&t._next&&i(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n},r.prototype.toString=function(){for(var t=[],n=this._sentinel,e=n._prev;e!==n;)t.push(JSON.stringify(e,o)),e=e._prev;return"["+t.join(", ")+"]"}},{}],34:[function(t,n,e){function r(t){var n=o.buildLayerMatrix(t),e=new a({compound:!0,multigraph:!0}).setGraph({});return i.each(t.nodes(),function(n){e.setNode(n,{label:n}),e.setParent(n,"layer"+t.node(n).rank)}),i.each(t.edges(),function(t){e.setEdge(t.v,t.w,{},t.name)}),i.each(n,function(t,n){var r="layer"+n;e.setNode(r
 ,{rank:"same"}),i.reduce(t,function(t,n){return e.setEdge(t,n,{style:"invis"}),n})}),e}var i=t("./lodash"),o=t("./util"),a=t("./graphlib").Graph;n.exports={debugOrdering:r}},{"./graphlib":35,"./lodash":38,"./util":57}],35:[function(t,n,e){arguments[4][9][0].apply(e,arguments)},{dup:9,graphlib:59}],36:[function(t,n,e){function r(t,n){if(t.nodeCount()<=1)return[];var e=a(t,n||l),r=i(e.graph,e.buckets,e.zeroIdx);return c.flatten(c.map(r,function(n){return t.outEdges(n.v,n.w)}),!0)}function i(t,n,e){for(var r,i=[],a=n[n.length-1],u=n[0];t.nodeCount();){for(;r=u.dequeue();)o(t,n,e,r);for(;r=a.dequeue();)o(t,n,e,r);if(t.nodeCount())for(var c=n.length-2;c>0;--c)if(r=n[c].dequeue()){i=i.concat(o(t,n,e,r,!0));break}}return i}function o(t,n,e,r,i){var o=i?[]:void 0;return c.each(t.inEdges(r.v),function(r){var a=t.edge(r),c=t.node(r.v);i&&o.push({v:r.v,w:r.w}),c.out-=a,u(n,e,c)}),c.each(t.outEdges(r.v),function(r){var i=t.edge(r),o=r.w,a=t.node(o);a["in"]-=i,u(n,e,a)}),t.removeNode(r.v),o}func
 tion a(t,n){var e=new s,r=0,i=0;c.each(t.nodes(),function(t){e.setNode(t,{v:t,"in":0,out:0})}),c.each(t.edges(),function(t){var o=e.edge(t.v,t.w)||0,a=n(t),u=o+a;e.setEdge(t.v,t.w,u),i=Math.max(i,e.node(t.v).out+=a),r=Math.max(r,e.node(t.w)["in"]+=a)});var o=c.range(i+r+3).map(function(){return new f}),a=r+1;return c.each(e.nodes(),function(t){u(o,a,e.node(t))}),{graph:e,buckets:o,zeroIdx:a}}function u(t,n,e){e.out?e["in"]?t[e.out-e["in"]+n].enqueue(e):t[t.length-1].enqueue(e):t[0].enqueue(e)}var c=t("./lodash"),s=t("./graphlib").Graph,f=t("./data/list");n.exports=r;var l=c.constant(1)},{"./data/list":33,"./graphlib":35,"./lodash":38}],37:[function(t,n,e){"use strict";function r(t,n){var e=n&&n.debugTiming?O.time:O.notime;e("layout",function(){var n=e("  buildLayoutGraph",function(){return a(t)});e("  runLayout",function(){i(n,e)}),e("  updateInputGraph",function(){o(t,n)})})}function i(t,n){n("    makeSpaceForEdgeLabels",function(){u(t)}),n("    removeSelfEdges",function(){v(t)}),n
 ("    acyclic",function(){x.run(t)}),n("    nestingGraph.run",function(){j.run(t)}),n("    rank",function(){E(O.asNonCompoundGraph(t))}),n("    injectEdgeLabelProxies",function(){c(t)}),n("    removeEmptyRanks",function(){C(t)}),n("    nestingGraph.cleanup",function(){j.cleanup(t)}),n("    normalizeRanks",function(){I(t)}),n("    assignRankMinMax",function(){s(t)}),n("    removeEdgeLabelProxies",function(){f(t)}),n("    normalize.run",function(){k.run(t)}),n("    parentDummyChains",function(){N(t)}),n("    addBorderSegments",function(){R(t)}),n("    order",function(){L(t)}),n("    insertSelfEdges",function(){y(t)}),n("    adjustCoordinateSystem",function(){T.adjust(t)}),n("    position",function(){A(t)}),n("    positionSelfEdges",function(){_(t)}),n("    removeBorderNodes",function(){g(t)}),n("    normalize.undo",function(){k.undo(t)}),n("    fixupEdgeLabelCoords",function(){d(t)}),n("    undoCoordinateSystem",function(){T.undo(t)}),n("    translateGraph",function(){l(t)}),n("    as
 signNodeIntersects",function(){h(t)}),n("    reversePoints",function(){p(t)}),n("    acyclic.undo",function(){x.undo(t)})}function o(t,n){b.each(t.nodes(),function(e){var r=t.node(e),i=n.node(e);r&&(r.x=i.x,r.y=i.y,n.children(e).length&&(r.width=i.width,r.height=i.height))}),b.each(t.edges(),function(e){var r=t.edge(e),i=n.edge(e);r.points=i.points,b.has(i,"x")&&(r.x=i.x,r.y=i.y)}),t.graph().width=n.graph().width,t.graph().height=n.graph().height}function a(t){var n=new S({multigraph:!0,compound:!0}),e=w(t.graph());return n.setGraph(b.merge({},B,m(e,M),b.pick(e,U))),b.each(t.nodes(),function(e){var r=w(t.node(e));n.setNode(e,b.defaults(m(r,P),F)),n.setParent(e,t.parent(e))}),b.each(t.edges(),function(e){var r=w(t.edge(e));n.setEdge(e,b.merge({},W,m(r,D),b.pick(r,z)))}),n}function u(t){var n=t.graph();n.ranksep/=2,b.each(t.edges(),function(e){var r=t.edge(e);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===n.rankdir||"BT"===n.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)
 })}function c(t){b.each(t.edges(),function(n){var e=t.edge(n);if(e.width&&e.height){var r=t.node(n.v),i=t.node(n.w),o={rank:(i.rank-r.rank)/2+r.rank,e:n};O.addDummyNode(t,"edge-proxy",o,"_ep")}})}function s(t){var n=0;b.each(t.nodes(),function(e){var r=t.node(e);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,n=b.max(n,r.maxRank))}),t.graph().maxRank=n}function f(t){b.each(t.nodes(),function(n){var e=t.node(n);"edge-proxy"===e.dummy&&(t.edge(e.e).labelRank=e.rank,t.removeNode(n))})}function l(t){function n(t){var n=t.x,a=t.y,u=t.width,c=t.height;e=Math.min(e,n-u/2),r=Math.max(r,n+u/2),i=Math.min(i,a-c/2),o=Math.max(o,a+c/2)}var e=Number.POSITIVE_INFINITY,r=0,i=Number.POSITIVE_INFINITY,o=0,a=t.graph(),u=a.marginx||0,c=a.marginy||0;b.each(t.nodes(),function(e){n(t.node(e))}),b.each(t.edges(),function(e){var r=t.edge(e);b.has(r,"x")&&n(r)}),e-=u,i-=c,b.each(t.nodes(),function(n){var r=t.node(n);r.x-=e,r.y-=i}),b.each(t.edges(),function(n){var r=t.
 edge(n);b.each(r.points,function(t){t.x-=e,t.y-=i}),b.has(r,"x")&&(r.x-=e),b.has(r,"y")&&(r.y-=i)}),a.width=r-e+u,a.height=o-i+c}function h(t){b.each(t.edges(),function(n){var e,r,i=t.edge(n),o=t.node(n.v),a=t.node(n.w);i.points?(e=i.points[0],r=i.points[i.points.length-1]):(i.points=[],e=a,r=o),i.points.unshift(O.intersectRect(o,e)),i.points.push(O.intersectRect(a,r))})}function d(t){b.each(t.edges(),function(n){var e=t.edge(n);if(b.has(e,"x"))switch(("l"===e.labelpos||"r"===e.labelpos)&&(e.width-=e.labeloffset),e.labelpos){case"l":e.x-=e.width/2+e.labeloffset;break;case"r":e.x+=e.width/2+e.labeloffset}})}function p(t){b.each(t.edges(),function(n){var e=t.edge(n);e.reversed&&e.points.reverse()})}function g(t){b.each(t.nodes(),function(n){if(t.children(n).length){var e=t.node(n),r=t.node(e.borderTop),i=t.node(e.borderBottom),o=t.node(b.last(e.borderLeft)),a=t.node(b.last(e.borderRight));e.width=Math.abs(a.x-o.x),e.height=Math.abs(i.y-r.y),e.x=o.x+e.width/2,e.y=r.y+e.height/2}}),b.ea
 ch(t.nodes(),function(n){"border"===t.node(n).dummy&&t.removeNode(n)})}function v(t){b.each(t.edges(),function(n){if(n.v===n.w){var e=t.node(n.v);e.selfEdges||(e.selfEdges=[]),e.selfEdges.push({e:n,label:t.edge(n)}),t.removeEdge(n)}})}function y(t){var n=O.buildLayerMatrix(t);b.each(n,function(n){var e=0;b.each(n,function(n,r){var i=t.node(n);i.order=r+e,b.each(i.selfEdges,function(n){O.addDummyNode(t,"selfedge",{width:n.label.width,height:n.label.height,rank:i.rank,order:r+ ++e,e:n.e,label:n.label},"_se")}),delete i.selfEdges})})}function _(t){b.each(t.nodes(),function(n){var e=t.node(n);if("selfedge"===e.dummy){var r=t.node(e.e.v),i=r.x+r.width/2,o=r.y,a=e.x-i,u=r.height/2;t.setEdge(e.e,e.label),t.removeNode(n),e.label.points=[{x:i+2*a/3,y:o-u},{x:i+5*a/6,y:o-u},{x:i+a,y:o},{x:i+5*a/6,y:o+u},{x:i+2*a/3,y:o+u}],e.label.x=e.x,e.label.y=e.y}})}function m(t,n){return b.mapValues(b.pick(t,n),Number)}function w(t){var n={};return b.each(t,function(t,e){n[e.toLowerCase()]=t}),n}var b=t("
 ./lodash"),x=t("./acyclic"),k=t("./normalize"),E=t("./rank"),I=t("./util").normalizeRanks,N=t("./parent-dummy-chains"),C=t("./util").removeEmptyRanks,j=t("./nesting-graph"),R=t("./add-border-segments"),T=t("./coordinate-system"),L=t("./order"),A=t("./position"),O=t("./util"),S=t("./graphlib").Graph;n.exports=r;var M=["nodesep","edgesep","ranksep","marginx","marginy"],B={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},U=["acyclicer","ranker","rankdir","align"],P=["width","height"],F={width:0,height:0},D=["minlen","weight","width","height","labeloffset"],W={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"]},{"./acyclic":30,"./add-border-segments":31,"./coordinate-system":32,"./graphlib":35,"./lodash":38,"./nesting-graph":39,"./normalize":40,"./order":45,"./parent-dummy-chains":50,"./position":52,"./rank":54,"./util":57}],38:[function(t,n,e){arguments[4][21][0].apply(e,arguments)},{dup:21,lodash:79}],39:[function(t,n,e){function r(t){var n=s.addDummyNode(t,"
 root",{},"_root"),e=o(t),r=c.max(e)-1,u=2*r+1;t.graph().nestingRoot=n,c.each(t.edges(),function(n){t.edge(n).minlen*=u});var f=a(t)+1;c.each(t.children(),function(o){i(t,n,u,f,r,e,o)}),t.graph().nodeRankFactor=u}function i(t,n,e,r,o,a,u){var f=t.children(u);if(!f.length)return void(u!==n&&t.setEdge(n,u,{weight:0,minlen:e}));var l=s.addBorderNode(t,"_bt"),h=s.addBorderNode(t,"_bb"),d=t.node(u);t.setParent(l,u),d.borderTop=l,t.setParent(h,u),d.borderBottom=h,c.each(f,function(c){i(t,n,e,r,o,a,c);var s=t.node(c),f=s.borderTop?s.borderTop:c,d=s.borderBottom?s.borderBottom:c,p=s.borderTop?r:2*r,g=f!==d?1:o-a[u]+1;t.setEdge(l,f,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(d,h,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(u)||t.setEdge(n,l,{weight:0,minlen:o+a[u]})}function o(t){function n(r,i){var o=t.children(r);o&&o.length&&c.each(o,function(t){n(t,i+1)}),e[r]=i}var e={};return c.each(t.children(),function(t){n(t,1)}),e}function a(t){return c.reduce(t.edges(),function(n,e){return n+t.
 edge(e).weight},0)}function u(t){var n=t.graph();t.removeNode(n.nestingRoot),delete n.nestingRoot,c.each(t.edges(),function(n){var e=t.edge(n);e.nestingEdge&&t.removeEdge(n)})}var c=t("./lodash"),s=t("./util");n.exports={run:r,cleanup:u}},{"./lodash":38,"./util":57}],40:[function(t,n,e){"use strict";function r(t){t.graph().dummyChains=[],a.each(t.edges(),function(n){i(t,n)})}function i(t,n){var e=n.v,r=t.node(e).rank,i=n.w,o=t.node(i).rank,a=n.name,c=t.edge(n),s=c.labelRank;if(o!==r+1){t.removeEdge(n);var f,l,h;for(h=0,++r;o>r;++h,++r)c.points=[],l={width:0,height:0,edgeLabel:c,edgeObj:n,rank:r},f=u.addDummyNode(t,"edge",l,"_d"),r===s&&(l.width=c.width,l.height=c.height,l.dummy="edge-label",l.labelpos=c.labelpos),t.setEdge(e,f,{weight:c.weight},a),0===h&&t.graph().dummyChains.push(f),e=f;t.setEdge(e,i,{weight:c.weight},a)}}function o(t){a.each(t.graph().dummyChains,function(n){var e,r=t.node(n),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)e=t.successors(n)[0],t.removeNode(n),i.
 points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),n=e,r=t.node(n)})}var a=t("./lodash"),u=t("./util");n.exports={run:r,undo:o}},{"./lodash":38,"./util":57}],41:[function(t,n,e){function r(t,n,e){var r,o={};i.each(e,function(e){for(var i,a,u=t.parent(e);u;){if(i=t.parent(u),i?(a=o[i],o[i]=u):(a=r,r=u),a&&a!==u)return void n.setEdge(a,u);u=i}})}var i=t("../lodash");n.exports=r},{"../lodash":38}],42:[function(t,n,e){function r(t,n){return i.map(n,function(n){var e=t.inEdges(n);if(e.length){var r=i.reduce(e,function(n,e){var r=t.edge(e),i=t.node(e.v);return{sum:n.sum+r.weight*i.order,weight:n.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:r.sum/r.weight,weight:r.weight}}return{v:n}})}var i=t("../lodash");n.exports=r},{"../lodash":38}],43:[function(t,n,e){function r(t,n,e){var r=i(t),u=new a({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(n){return t.node(n)});return o.each(t.nodes(),function(i){var a=t.node(i
 ),c=t.parent(i);(a.rank===n||a.minRank<=n&&n<=a.maxRank)&&(u.setNode(i),u.setParent(i,c||r),o.each(t[e](i),function(n){var e=n.v===i?n.w:n.v,r=u.edge(e,i),a=o.isUndefined(r)?0:r.weight;u.setEdge(e,i,{weight:t.edge(n).weight+a})}),o.has(a,"minRank")&&u.setNode(i,{borderLeft:a.borderLeft[n],borderRight:a.borderRight[n]}))}),u}function i(t){for(var n;t.hasNode(n=o.uniqueId("_root")););return n}var o=t("../lodash"),a=t("../graphlib").Graph;n.exports=r},{"../graphlib":35,"../lodash":38}],44:[function(t,n,e){"use strict";function r(t,n){for(var e=0,r=1;r<n.length;++r)e+=i(t,n[r-1],n[r]);return e}function i(t,n,e){for(var r=o.zipObject(e,o.map(e,function(t,n){return n})),i=o.flatten(o.map(n,function(n){return o.chain(t.outEdges(n)).map(function(n){return{pos:r[n.w],weight:t.edge(n).weight}}).sortBy("pos").value()}),!0),a=1;a<e.length;)a<<=1;var u=2*a-1;a-=1;var c=o.map(new Array(u),function(){return 0}),s=0;return o.each(i.forEach(function(t){var n=t.pos+a;c[n]+=t.weight;for(var e=0;n>0;)n
 %2&&(e+=c[n+1]),n=n-1>>1,c[n]+=t.weight;s+=t.weight*e})),s}var o=t("../lodash");n.exports=r},{"../lodash":38}],45:[function(t,n,e){"use strict";function r(t){var n=p.maxRank(t),e=i(t,u.range(1,n+1),"inEdges"),r=i(t,u.range(n-1,-1,-1),"outEdges"),f=c(t);a(t,f);for(var l,h=Number.POSITIVE_INFINITY,d=0,g=0;4>g;++d,++g){o(d%2?e:r,d%4>=2),f=p.buildLayerMatrix(t);var v=s(t,f);h>v&&(g=0,l=u.cloneDeep(f),h=v)}a(t,l)}function i(t,n,e){return u.map(n,function(n){return l(t,n,e)})}function o(t,n){var e=new d;u.each(t,function(t){var r=t.graph().root,i=f(t,r,e,n);u.each(i.vs,function(n,e){t.node(n).order=e}),h(t,e,i.vs)})}function a(t,n){u.each(n,function(n){u.each(n,function(n,e){t.node(n).order=e})})}var u=t("../lodash"),c=t("./init-order"),s=t("./cross-count"),f=t("./sort-subgraph"),l=t("./build-layer-graph"),h=t("./add-subgraph-constraints"),d=t("../graphlib").Graph,p=t("../util");n.exports=r},{"../graphlib":35,"../lodash":38,"../util":57,"./add-subgraph-constraints":41,"./build-layer-graph
 ":43,"./cross-count":44,"./init-order":46,"./sort-subgraph":48}],46:[function(t,n,e){"use strict";
+
+function r(t){function n(r){if(!i.has(e,r)){e[r]=!0;var o=t.node(r);a[o.rank].push(r),i.each(t.successors(r),n)}}var e={},r=i.filter(t.nodes(),function(n){return!t.children(n).length}),o=i.max(i.map(r,function(n){return t.node(n).rank})),a=i.map(i.range(o+1),function(){return[]}),u=i.sortBy(r,function(n){return t.node(n).rank});return i.each(u,n),a}var i=t("../lodash");n.exports=r},{"../lodash":38}],47:[function(t,n,e){"use strict";function r(t,n){var e={};a.each(t,function(t,n){var r=e[t.v]={indegree:0,"in":[],out:[],vs:[t.v],i:n};a.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)}),a.each(n.edges(),function(t){var n=e[t.v],r=e[t.w];a.isUndefined(n)||a.isUndefined(r)||(r.indegree++,n.out.push(e[t.w]))});var r=a.filter(e,function(t){return!t.indegree});return i(r)}function i(t){function n(t){return function(n){n.merged||(a.isUndefined(n.barycenter)||a.isUndefined(t.barycenter)||n.barycenter>=t.barycenter)&&o(t,n)}}function e(n){return function(e){e["in"].push
 (n),0===--e.indegree&&t.push(e)}}for(var r=[];t.length;){var i=t.pop();r.push(i),a.each(i["in"].reverse(),n(i)),a.each(i.out,e(i))}return a.chain(r).filter(function(t){return!t.merged}).map(function(t){return a.pick(t,["vs","i","barycenter","weight"])}).value()}function o(t,n){var e=0,r=0;t.weight&&(e+=t.barycenter*t.weight,r+=t.weight),n.weight&&(e+=n.barycenter*n.weight,r+=n.weight),t.vs=n.vs.concat(t.vs),t.barycenter=e/r,t.weight=r,t.i=Math.min(n.i,t.i),n.merged=!0}var a=t("../lodash");n.exports=r},{"../lodash":38}],48:[function(t,n,e){function r(t,n,e,f){var l=t.children(n),h=t.node(n),d=h?h.borderLeft:void 0,p=h?h.borderRight:void 0,g={};d&&(l=a.filter(l,function(t){return t!==d&&t!==p}));var v=u(t,l);a.each(v,function(n){if(t.children(n.v).length){var i=r(t,n.v,e,f);g[n.v]=i,a.has(i,"barycenter")&&o(n,i)}});var y=c(v,e);i(y,g);var _=s(y,f);if(d&&(_.vs=a.flatten([d,_.vs,p],!0),t.predecessors(d).length)){var m=t.node(t.predecessors(d)[0]),w=t.node(t.predecessors(p)[0]);a.has(_,"
 barycenter")||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+m.order+w.order)/(_.weight+2),_.weight+=2}return _}function i(t,n){a.each(t,function(t){t.vs=a.flatten(t.vs.map(function(t){return n[t]?n[t].vs:t}),!0)})}function o(t,n){a.isUndefined(t.barycenter)?(t.barycenter=n.barycenter,t.weight=n.weight):(t.barycenter=(t.barycenter*t.weight+n.barycenter*n.weight)/(t.weight+n.weight),t.weight+=n.weight)}var a=t("../lodash"),u=t("./barycenter"),c=t("./resolve-conflicts"),s=t("./sort");n.exports=r},{"../lodash":38,"./barycenter":42,"./resolve-conflicts":47,"./sort":49}],49:[function(t,n,e){function r(t,n){var e=u.partition(t,function(t){return a.has(t,"barycenter")}),r=e.lhs,c=a.sortBy(e.rhs,function(t){return-t.i}),s=[],f=0,l=0,h=0;r.sort(o(!!n)),h=i(s,c,h),a.each(r,function(t){h+=t.vs.length,s.push(t.vs),f+=t.barycenter*t.weight,l+=t.weight,h=i(s,c,h)});var d={vs:a.flatten(s,!0)};return l&&(d.barycenter=f/l,d.weight=l),d}function i(t,n,e){for(var r;n.length&&(r=a.last
 (n)).i<=e;)n.pop(),t.push(r.vs),e++;return e}function o(t){return function(n,e){return n.barycenter<e.barycenter?-1:n.barycenter>e.barycenter?1:t?e.i-n.i:n.i-e.i}}var a=t("../lodash"),u=t("../util");n.exports=r},{"../lodash":38,"../util":57}],50:[function(t,n,e){function r(t){var n=o(t);a.each(t.graph().dummyChains,function(e){for(var r=t.node(e),o=r.edgeObj,a=i(t,n,o.v,o.w),u=a.path,c=a.lca,s=0,f=u[s],l=!0;e!==o.w;){if(r=t.node(e),l){for(;(f=u[s])!==c&&t.node(f).maxRank<r.rank;)s++;f===c&&(l=!1)}if(!l){for(;s<u.length-1&&t.node(f=u[s+1]).minRank<=r.rank;)s++;f=u[s]}t.setParent(e,f),e=t.successors(e)[0]}})}function i(t,n,e,r){var i,o,a=[],u=[],c=Math.min(n[e].low,n[r].low),s=Math.max(n[e].lim,n[r].lim);i=e;do i=t.parent(i),a.push(i);while(i&&(n[i].low>c||s>n[i].lim));for(o=i,i=r;(i=t.parent(i))!==o;)u.push(i);return{path:a.concat(u.reverse()),lca:o}}function o(t){function n(i){var o=r;a.each(t.children(i),n),e[i]={low:o,lim:r++}}var e={},r=0;return a.each(t.children(),n),e}var a=t("
 ./lodash");n.exports=r},{"./lodash":38}],51:[function(t,n,e){"use strict";function r(t,n){function e(n,e){var i=0,u=0,c=n.length,s=y.last(e);return y.each(e,function(n,f){var l=o(t,n),h=l?t.node(l).order:c;(l||n===s)&&(y.each(e.slice(u,f+1),function(n){y.each(t.predecessors(n),function(e){var o=t.node(e),u=o.order;!(i>u||u>h)||o.dummy&&t.node(n).dummy||a(r,e,n)})}),u=f+1,i=h)}),e}var r={};return y.reduce(n,e),r}function i(t,n){function e(n,e,r,o,u){var c;y.each(y.range(e,r),function(e){c=n[e],t.node(c).dummy&&y.each(t.predecessors(c),function(n){var e=t.node(n);e.dummy&&(e.order<o||e.order>u)&&a(i,n,c)})})}function r(n,r){var i,o=-1,a=0;return y.each(r,function(u,c){if("border"===t.node(u).dummy){var s=t.predecessors(u);s.length&&(i=t.node(s[0]).order,e(r,a,c,o,i),a=c,o=i)}e(r,a,r.length,i,n.length)}),r}var i={};return y.reduce(n,r),i}function o(t,n){return t.node(n).dummy?y.find(t.predecessors(n),function(n){return t.node(n).dummy}):void 0}function a(t,n,e){if(n>e){var r=n;n=e,e=r}
 var i=t[n];i||(t[n]=i={}),i[e]=!0}function u(t,n,e){if(n>e){var r=n;n=e,e=r}return y.has(t[n],e)}function c(t,n,e,r){var i={},o={},a={};return y.each(n,function(t){y.each(t,function(t,n){i[t]=t,o[t]=t,a[t]=n})}),y.each(n,function(t){var n=-1;y.each(t,function(t){var c=r(t);if(c.length){c=y.sortBy(c,function(t){return a[t]});for(var s=(c.length-1)/2,f=Math.floor(s),l=Math.ceil(s);l>=f;++f){var h=c[f];o[t]===t&&n<a[h]&&!u(e,t,h)&&(o[h]=t,o[t]=i[t]=i[h],n=a[h])}}})}),{root:i,align:o}}function s(t,n,e,r,i){function o(t){y.has(s,t)||(s[t]=!0,u[t]=y.reduce(c.inEdges(t),function(t,n){return o(n.v),Math.max(t,u[n.v]+c.edge(n))},0))}function a(n){if(2!==s[n]){s[n]++;var e=t.node(n),r=y.reduce(c.outEdges(n),function(t,n){return a(n.w),Math.min(t,u[n.w]-c.edge(n))},Number.POSITIVE_INFINITY);r!==Number.POSITIVE_INFINITY&&e.borderType!==l&&(u[n]=Math.max(u[n],r))}}var u={},c=f(t,n,e,i),s={};y.each(c.nodes(),o);var l=i?"borderLeft":"borderRight";return y.each(c.nodes(),a),y.each(r,function(t){u[t
 ]=u[e[t]]}),u}function f(t,n,e,r){var i=new _,o=t.graph(),a=g(o.nodesep,o.edgesep,r);return y.each(n,function(n){var r;y.each(n,function(n){var o=e[n];if(i.setNode(o),r){var u=e[r],c=i.edge(u,o);i.setEdge(u,o,Math.max(a(t,n,r),c||0))}r=n})}),i}function l(t,n){return y.min(n,function(n){var e=y.min(n,function(n,e){return n-v(t,e)/2}),r=y.max(n,function(n,e){return n+v(t,e)/2});return r-e})}function h(t,n){var e=y.min(n),r=y.max(n);y.each(["u","d"],function(i){y.each(["l","r"],function(o){var a,u=i+o,c=t[u];c!==n&&(a="l"===o?e-y.min(c):r-y.max(c),a&&(t[u]=y.mapValues(c,function(t){return t+a})))})})}function d(t,n){return y.mapValues(t.ul,function(e,r){if(n)return t[n.toLowerCase()][r];var i=y.sortBy(y.pluck(t,r));return(i[1]+i[2])/2})}function p(t){var n,e=m.buildLayerMatrix(t),o=y.merge(r(t,e),i(t,e)),a={};y.each(["u","d"],function(r){n="u"===r?e:y.values(e).reverse(),y.each(["l","r"],function(e){"r"===e&&(n=y.map(n,function(t){return y.values(t).reverse()}));var i=y.bind("u"===r?t.
 predecessors:t.successors,t),u=c(t,n,o,i),f=s(t,n,u.root,u.align,"r"===e);"r"===e&&(f=y.mapValues(f,function(t){return-t})),a[r+e]=f})});var u=l(t,a);return h(a,u),d(a,t.graph().align)}function g(t,n,e){return function(r,i,o){var a,u=r.node(i),c=r.node(o),s=0;if(s+=u.width/2,y.has(u,"labelpos"))switch(u.labelpos.toLowerCase()){case"l":a=-u.width/2;break;case"r":a=u.width/2}if(a&&(s+=e?a:-a),a=0,s+=(u.dummy?n:t)/2,s+=(c.dummy?n:t)/2,s+=c.width/2,y.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":a=c.width/2;break;case"r":a=-c.width/2}return a&&(s+=e?a:-a),a=0,s}}function v(t,n){return t.node(n).width}var y=t("../lodash"),_=t("../graphlib").Graph,m=t("../util");n.exports={positionX:p,findType1Conflicts:r,findType2Conflicts:i,addConflict:a,hasConflict:u,verticalAlignment:c,horizontalCompaction:s,alignCoordinates:h,findSmallestWidthAlignment:l,balance:d}},{"../graphlib":35,"../lodash":38,"../util":57}],52:[function(t,n,e){"use strict";function r(t){t=a.asNonCompoundGraph(t),i(
 t),o.each(u(t),function(n,e){t.node(e).x=n})}function i(t){var n=a.buildLayerMatrix(t),e=t.graph().ranksep,r=0;o.each(n,function(n){var i=o.max(o.map(n,function(n){return t.node(n).height}));o.each(n,function(n){t.node(n).y=r+i/2}),r+=i+e})}var o=t("../lodash"),a=t("../util"),u=t("./bk").positionX;n.exports=r},{"../lodash":38,"../util":57,"./bk":51}],53:[function(t,n,e){"use strict";function r(t){var n=new c({directed:!1}),e=t.nodes()[0],r=t.nodeCount();n.setNode(e,{});for(var u,f;i(n,t)<r;)u=o(n,t),f=n.hasNode(u.v)?s(t,u):-s(t,u),a(n,t,f);return n}function i(t,n){function e(r){u.each(n.nodeEdges(r),function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||s(n,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),e(a))})}return u.each(t.nodes(),e),t.nodeCount()}function o(t,n){return u.min(n.edges(),function(e){return t.hasNode(e.v)!==t.hasNode(e.w)?s(n,e):void 0})}function a(t,n,e){u.each(t.nodes(),function(t){n.node(t).rank+=e})}var u=t("../lodash"),c=t("../graphlib").Graph,s=t("./util").slack;n.exports
 =r},{"../graphlib":35,"../lodash":38,"./util":56}],54:[function(t,n,e){"use strict";function r(t){switch(t.graph().ranker){case"network-simplex":o(t);break;case"tight-tree":i(t);break;case"longest-path":f(t);break;default:o(t)}}function i(t){u(t),c(t)}function o(t){s(t)}var a=t("./util"),u=a.longestPath,c=t("./feasible-tree"),s=t("./network-simplex");n.exports=r;var f=u},{"./feasible-tree":53,"./network-simplex":55,"./util":56}],55:[function(t,n,e){"use strict";function r(t){t=b(t),_(t);var n=v(t);u(n),i(n,t);for(var e,r;e=s(n);)r=f(n,t,e),l(n,t,e,r)}function i(t,n){var e=w(t,t.nodes());e=e.slice(0,e.length-1),g.each(e,function(e){o(t,n,e)})}function o(t,n,e){var r=t.node(e),i=r.parent;t.edge(e,i).cutvalue=a(t,n,e)}function a(t,n,e){var r=t.node(e),i=r.parent,o=!0,a=n.edge(e,i),u=0;return a||(o=!1,a=n.edge(i,e)),u=a.weight,g.each(n.nodeEdges(e),function(r){var a=r.v===e,c=a?r.w:r.v;if(c!==i){var s=a===o,f=n.edge(r).weight;if(u+=s?f:-f,d(t,e,c)){var l=t.edge(e,c).cutvalue;u+=s?-l:l}}
 }),u}function u(t,n){arguments.length<2&&(n=t.nodes()[0]),c(t,{},1,n)}function c(t,n,e,r,i){var o=e,a=t.node(r);return n[r]=!0,g.each(t.neighbors(r),function(i){g.has(n,i)||(e=c(t,n,e,i,r))}),a.low=o,a.lim=e++,i?a.parent=i:delete a.parent,e}function s(t){return g.find(t.edges(),function(n){return t.edge(n).cutvalue<0})}function f(t,n,e){var r=e.v,i=e.w;n.hasEdge(r,i)||(r=e.w,i=e.v);var o=t.node(r),a=t.node(i),u=o,c=!1;o.lim>a.lim&&(u=a,c=!0);var s=g.filter(n.edges(),function(n){return c===p(t,t.node(n.v),u)&&c!==p(t,t.node(n.w),u)});return g.min(s,function(t){return y(n,t)})}function l(t,n,e,r){var o=e.v,a=e.w;t.removeEdge(o,a),t.setEdge(r.v,r.w,{}),u(t),i(t,n),h(t,n)}function h(t,n){var e=g.find(t.nodes(),function(t){return!n.node(t).parent}),r=m(t,e);r=r.slice(1),g.each(r,function(e){var r=t.node(e).parent,i=n.edge(e,r),o=!1;i||(i=n.edge(r,e),o=!0),n.node(e).rank=n.node(r).rank+(o?i.minlen:-i.minlen)})}function d(t,n,e){return t.hasEdge(n,e)}function p(t,n,e){return e.low<=n.lim&&
 n.lim<=e.lim}var g=t("../lodash"),v=t("./feasible-tree"),y=t("./util").slack,_=t("./util").longestPath,m=t("../graphlib").alg.preorder,w=t("../graphlib").alg.postorder,b=t("../util").simplify;n.exports=r,r.initLowLimValues=u,r.initCutValues=i,r.calcCutValue=a,r.leaveEdge=s,r.enterEdge=f,r.exchangeEdges=l},{"../graphlib":35,"../lodash":38,"../util":57,"./feasible-tree":53,"./util":56}],56:[function(t,n,e){"use strict";function r(t){function n(r){var i=t.node(r);if(o.has(e,r))return i.rank;e[r]=!0;var a=o.min(o.map(t.outEdges(r),function(e){return n(e.w)-t.edge(e).minlen}));return a===Number.POSITIVE_INFINITY&&(a=0),i.rank=a}var e={};o.each(t.sources(),n)}function i(t,n){return t.node(n.w).rank-t.node(n.v).rank-t.edge(n).minlen}var o=t("../lodash");n.exports={longestPath:r,slack:i}},{"../lodash":38}],57:[function(t,n,e){"use strict";function r(t,n,e,r){var i;do i=y.uniqueId(r);while(t.hasNode(i));return e.dummy=n,t.setNode(i,e),i}function i(t){var n=(new _).setGraph(t.graph());return 
 y.each(t.nodes(),function(e){n.setNode(e,t.node(e))}),y.each(t.edges(),function(e){var r=n.edge(e.v,e.w)||{weight:0,minlen:1},i=t.edge(e);n.setEdge(e.v,e.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),n}function o(t){var n=new _({multigraph:t.isMultigraph()}).setGraph(t.graph());return y.each(t.nodes(),function(e){t.children(e).length||n.setNode(e,t.node(e))}),y.each(t.edges(),function(e){n.setEdge(e,t.edge(e))}),n}function a(t){var n=y.map(t.nodes(),function(n){var e={};return y.each(t.outEdges(n),function(n){e[n.w]=(e[n.w]||0)+t.edge(n).weight}),e});return y.zipObject(t.nodes(),n)}function u(t){var n=y.map(t.nodes(),function(n){var e={};return y.each(t.inEdges(n),function(n){e[n.v]=(e[n.v]||0)+t.edge(n).weight}),e});return y.zipObject(t.nodes(),n)}function c(t,n){var e=t.x,r=t.y,i=n.x-e,o=n.y-r,a=t.width/2,u=t.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");var c,s;return Math.abs(o)*a>Math.abs(i)*u?(0>o&&(u=-u),c
 =u*i/o,s=u):(0>i&&(a=-a),c=a,s=a*o/i),{x:e+c,y:r+s}}function s(t){var n=y.map(y.range(d(t)+1),function(){return[]});return y.each(t.nodes(),function(e){var r=t.node(e),i=r.rank;y.isUndefined(i)||(n[i][r.order]=e)}),n}function f(t){var n=y.min(y.map(t.nodes(),function(n){return t.node(n).rank}));y.each(t.nodes(),function(e){var r=t.node(e);y.has(r,"rank")&&(r.rank-=n)})}function l(t){var n=y.min(y.map(t.nodes(),function(n){return t.node(n).rank})),e=[];y.each(t.nodes(),function(r){var i=t.node(r).rank-n;e[i]||(e[i]=[]),e[i].push(r)});var r=0,i=t.graph().nodeRankFactor;y.each(e,function(n,e){y.isUndefined(n)&&e%i!==0?--r:r&&y.each(n,function(n){t.node(n).rank+=r})})}function h(t,n,e,i){var o={width:0,height:0};return arguments.length>=4&&(o.rank=e,o.order=i),r(t,"border",o,n)}function d(t){return y.max(y.map(t.nodes(),function(n){var e=t.node(n).rank;return y.isUndefined(e)?void 0:e}))}function p(t,n){var e={lhs:[],rhs:[]};return y.each(t,function(t){n(t)?e.lhs.push(t):e.rhs.push(t)})
 ,e}function g(t,n){var e=y.now();try{return n()}finally{console.log(t+" time: "+(y.now()-e)+"ms")}}function v(t,n){return n()}var y=t("./lodash"),_=t("./graphlib").Graph;n.exports={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:u,intersectRect:c,buildLayerMatrix:s,normalizeRanks:f,removeEmptyRanks:l,addBorderNode:h,maxRank:d,partition:p,time:g,notime:v}},{"./graphlib":35,"./lodash":38}],58:[function(t,n,e){n.exports="0.7.3"},{}],59:[function(t,n,e){var r=t("./lib");n.exports={Graph:r.Graph,json:t("./lib/json"),alg:t("./lib/alg"),version:r.version}},{"./lib":75,"./lib/alg":66,"./lib/json":76}],60:[function(t,n,e){function r(t){function n(o){i.has(r,o)||(r[o]=!0,e.push(o),i.each(t.successors(o),n),i.each(t.predecessors(o),n))}var e,r={},o=[];return i.each(t.nodes(),function(t){e=[],n(t),e.length&&o.push(e)}),o}var i=t("../lodash");n.exports=r},{"../lodash":77}],61:[function(t,n,e){function r(t,n,e){o.isArray(n)||(n=[n]);var r=[],a={};return o.each
 (n,function(n){if(!t.hasNode(n))throw new Error("Graph does not have node: "+n);i(t,n,"post"===e,a,r)}),r}function i(t,n,e,r,a){o.has(r,n)||(r[n]=!0,e||a.push(n),o.each(t.neighbors(n),function(n){i(t,n,e,r,a)}),e&&a.push(n))}var o=t("../lodash");n.exports=r},{"../lodash":77}],62:[function(t,n,e){function r(t,n,e){return o.transform(t.nodes(),function(r,o){r[o]=i(t,o,n,e)},{})}var i=t("./dijkstra"),o=t("../lodash");n.exports=r},{"../lodash":77,"./dijkstra":63}],63:[function(t,n,e){function r(t,n,e,r){return i(t,String(n),e||u,r||function(n){return t.outEdges(n)})}function i(t,n,e,r){var i,o,u={},c=new a,s=function(t){var n=t.v!==i?t.v:t.w,r=u[n],a=e(t),s=o.distance+a;if(0>a)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+a);s<r.distance&&(r.distance=s,r.predecessor=i,c.decrease(n,s))};for(t.nodes().forEach(function(t){var e=t===n?0:Number.POSITIVE_INFINITY;u[t]={distance:e},c.add(t,e)});c.size()>0&&(i=c.removeMin(),o=u[i],o.distance!==Number.
 POSITIVE_INFINITY);)r(i).forEach(s);return u}var o=t("../lodash"),a=t("../data/priority-queue");n.exports=r;var u=o.constant(1)},{"../data/priority-queue":73,"../lodash":77}],64:[function(t,n,e){function r(t){return i.filter(o(t),function(n){return n.length>1||1===n.length&&t.hasEdge(n[0],n[0])})}var i=t("../lodash"),o=t("./tarjan");n.exports=r},{"../lodash":77,"./tarjan":71}],65:[function(t,n,e){function r(t,n,e){return i(t,n||a,e||function(n){return t.outEdges(n)})}function i(t,n,e){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(n){t!==n&&(r[t][n]={distance:Number.POSITIVE_INFINITY})}),e(t).forEach(function(e){var i=e.v===t?e.w:e.v,o=n(e);r[t][i]={distance:o,predecessor:t}})}),i.forEach(function(t){var n=r[t];i.forEach(function(e){var o=r[e];i.forEach(function(e){var r=o[t],i=n[e],a=o[e],u=r.distance+i.distance;u<a.distance&&(a.distance=u,a.predecessor=i.predecessor)})})}),r}var o=t("../lodash");n.exports=r;var a=o.constant(1)},{"
 ../lodash":77}],66:[function(t,n,e){n.exports={components:t("./components"),dijkstra:t("./dijkstra"),dijkstraAll:t("./dijkstra-all"),findCycles:t("./find-cycles"),floydWarshall:t("./floyd-warshall"),isAcyclic:t("./is-acyclic"),postorder:t("./postorder"),preorder:t("./preorder"),prim:t("./prim"),tarjan:t("./tarjan"),topsort:t("./topsort")}},{"./components":60,"./dijkstra":63,"./dijkstra-all":62,"./find-cycles":64,"./floyd-warshall":65,"./is-acyclic":67,"./postorder":68,"./preorder":69,"./prim":70,"./tarjan":71,"./topsort":72}],67:[function(t,n,e){function r(t){try{i(t)}catch(n){if(n instanceof i.CycleException)return!1;throw n}return!0}var i=t("./topsort");n.exports=r},{"./topsort":72}],68:[function(t,n,e){function r(t,n){return i(t,n,"post")}var i=t("./dfs");n.exports=r},{"./dfs":61}],69:[function(t,n,e){function r(t,n){return i(t,n,"pre")}var i=t("./dfs");n.exports=r},{"./dfs":61}],70:[function(t,n,e){function r(t,n){function e(t){var e=t.v===r?t.w:t.v,i=s.priority(e);if(void 0!==i
 ){var o=n(t);i>o&&(c[e]=r,s.decrease(e,o))}}var r,u=new o,c={},s=new a;if(0===t.nodeCount())return u;i.each(t.nodes(),function(t){s.add(t,Number.POSITIVE_INFINITY),u.setNode(t)}),s.decrease(t.nodes()[0],0);for(var f=!1;s.size()>0;){if(r=s.removeMin(),i.has(c,r))u.setEdge(r,c[r]);else{if(f)throw new Error("Input graph is not connected: "+t);f=!0}t.nodeEdges(r).forEach(e)}return u}var i=t("../lodash"),o=t("../graph"),a=t("../data/priority-queue");n.exports=r},{"../data/priority-queue":73,"../graph":74,"../lodash":77}],71:[function(t,n,e){function r(t){function n(u){var c=o[u]={onStack:!0,lowlink:e,index:e++};if(r.push(u),t.successors(u).forEach(function(t){i.has(o,t)?o[t].onStack&&(c.lowlink=Math.min(c.lowlink,o[t].index)):(n(t),c.lowlink=Math.min(c.lowlink,o[t].lowlink))}),c.lowlink===c.index){var s,f=[];do s=r.pop(),o[s].onStack=!1,f.push(s);while(u!==s);a.push(f)}}var e=0,r=[],o={},a=[];return t.nodes().forEach(function(t){i.has(o,t)||n(t)}),a}var i=t("../lodash");n.exports=r},{"..
 /lodash":77}],72:[function(t,n,e){function r(t){function n(u){if(o.has(r,u))throw new i;o.has(e,u)||(r[u]=!0,e[u]=!0,o.each(t.predecessors(u),n),delete r[u],a.push(u))}var e={},r={},a=[];if(o.each(t.sinks(),n),o.size(e)!==t.nodeCount())throw new i;return a}function i(){}var o=t("../lodash");n.exports=r,r.CycleException=i},{"../lodash":77}],73:[function(t,n,e){function r(){this._arr=[],this._keyIndices={}}var i=t("../lodash");n.exports=r,r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return i.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];return void 0!==n?this._arr[n].priority:void 0},r.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var e=this._keyIndices;if(t=String(t),!i.has(e,t)){var r=this._arr,o=r.length;return e[t]=o,r.push({key:t,priority:n}),th
 is._decrease(o),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var e=this._keyIndices[t];if(n>this._arr[e].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[e].priority+" New: "+n);this._arr[e].priority=n,this._decrease(e)},r.prototype._heapify=function(t){var n=this._arr,e=2*t,r=e+1,i=t;e<n.length&&(i=n[e].priority<n[i].priority?e:i,r<n.length&&(i=n[r].priority<n[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},r.prototype._decrease=function(t){for(var n,e=this._arr,r=e[t].priority;0!==t&&(n=t>>1,!(e[n].priority<r));)this._swap(t,n),t=n},r.prototype._swap=function(t,n){var e=this._arr,r=this._keyIndices,i=e[t],o=e[n];e[t]=o,e[n]=i,r[o.key]=t,r[i.key]=n}},{"../lodash":77}],74:[function(t,n,e){"use strict";function r(t){this._isDirected=s.has(t,"directed")?t.directed:!0,thi
 s._isMultigraph=s.has(t,"multigraph")?t.multigraph:!1,this._isCompound=s.has(t,"compound")?t.compound:!1,this._label=void 0,this._defaultNodeLabelFn=s.constant(void 0),this._defaultEdgeLabelFn=s.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[l]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function i(t,n){s.has(t,n)?t[n]++:t[n]=1}function o(t,n){--t[n]||delete t[n]}function a(t,n,e,r){if(!t&&n>e){var i=n;n=e,e=i}return n+h+e+h+(s.isUndefined(r)?f:r)}function u(t,n,e,r){if(!t&&n>e){var i=n;n=e,e=i}var o={v:n,w:e};return r&&(o.name=r),o}function c(t,n){return a(t,n.v,n.w,n.name)}var s=t("./lodash");n.exports=r;var f="\x00",l="\x00",h="";r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGrap
 h=function(t){return this._label=t,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(t){return s.isFunction(t)||(t=s.constant(t)),this._defaultNodeLabelFn=t,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return s.keys(this._nodes)},r.prototype.sources=function(){return s.filter(this.nodes(),function(t){return s.isEmpty(this._in[t])},this)},r.prototype.sinks=function(){return s.filter(this.nodes(),function(t){return s.isEmpty(this._out[t])},this)},r.prototype.setNodes=function(t,n){var e=arguments;return s.each(t,function(t){e.length>1?this.setNode(t,n):this.setNode(t)},this),this},r.prototype.setNode=function(t,n){return s.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=l,this._children[t]={},this._children[l][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]
 ={},++this._nodeCount,this)},r.prototype.node=function(t){return this._nodes[t]},r.prototype.hasNode=function(t){return s.has(this._nodes,t)},r.prototype.removeNode=function(t){var n=this;if(s.has(this._nodes,t)){var e=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],s.each(this.children(t),function(t){this.setParent(t)},this),delete this._children[t]),s.each(s.keys(this._in[t]),e),delete this._in[t],delete this._preds[t],s.each(s.keys(this._out[t]),e),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},r.prototype.setParent=function(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(s.isUndefined(n))n=l;else{n+="";for(var e=n;!s.isUndefined(e);e=this.parent(e))if(e===t)throw new Error("Setting "+n+" as parent of "+t+" would create create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._paren
 t[t]=n,this._children[n][t]=!0,this},r.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},r.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==l)return n}},r.prototype.children=function(t){if(s.isUndefined(t)&&(t=l),this._isCompound){var n=this._children[t];if(n)return s.keys(n)}else{if(t===l)return this.nodes();if(this.hasNode(t))return[]}},r.prototype.predecessors=function(t){var n=this._preds[t];return n?s.keys(n):void 0},r.prototype.successors=function(t){var n=this._sucs[t];return n?s.keys(n):void 0},r.prototype.neighbors=function(t){var n=this.predecessors(t);return n?s.union(n,this.successors(t)):void 0},r.prototype.setDefaultEdgeLabel=function(t){return s.isFunction(t)||(t=s.constant(t)),this._defaultEdgeLabelFn=t,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return s.values(this._edgeObjs)},r.prototype.setPath=function(t,n){var e=this,r=arguments;return s.redu
 ce(t,function(t,i){return r.length>1?e.setEdge(t,i,n):e.setEdge(t,i),i}),this},r.prototype.setEdge=function(){var t,n,e,r,o=!1;s.isPlainObject(arguments[0])?(t=arguments[0].v,n=arguments[0].w,e=arguments[0].name,2===arguments.length&&(r=arguments[1],o=!0)):(t=arguments[0],n=arguments[1],e=arguments[3],arguments.length>2&&(r=arguments[2],o=!0)),t=""+t,n=""+n,s.isUndefined(e)||(e=""+e);var c=a(this._isDirected,t,n,e);if(s.has(this._edgeLabels,c))return o&&(this._edgeLabels[c]=r),this;if(!s.isUndefined(e)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(n),this._edgeLabels[c]=o?r:this._defaultEdgeLabelFn(t,n,e);var f=u(this._isDirected,t,n,e);return t=f.v,n=f.w,Object.freeze(f),this._edgeObjs[c]=f,i(this._preds[n],t),i(this._sucs[t],n),this._in[n][c]=f,this._out[t][c]=f,this._edgeCount++,this},r.prototype.edge=function(t,n,e){var r=1===arguments.length?c(this._isDirected,arguments[0]):a(this._isDirected,t,n,e);return
  this._edgeLabels[r]},r.prototype.hasEdge=function(t,n,e){var r=1===arguments.length?c(this._isDirected,arguments[0]):a(this._isDirected,t,n,e);return s.has(this._edgeLabels,r)},r.prototype.removeEdge=function(t,n,e){var r=1===arguments.length?c(this._isDirected,arguments[0]):a(this._isDirected,t,n,e),i=this._edgeObjs[r];return i&&(t=i.v,n=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],o(this._preds[n],t),o(this._sucs[t],n),delete this._in[n][r],delete this._out[t][r],this._edgeCount--),this},r.prototype.inEdges=function(t,n){var e=this._in[t];if(e){var r=s.values(e);return n?s.filter(r,function(t){return t.v===n}):r}},r.prototype.outEdges=function(t,n){var e=this._out[t];if(e){var r=s.values(e);return n?s.filter(r,function(t){return t.w===n}):r}},r.prototype.nodeEdges=function(t,n){var e=this.inEdges(t,n);return e?e.concat(this.outEdges(t,n)):void 0}},{"./lodash":77}],75:[function(t,n,e){n.exports={Graph:t("./graph"),version:t("./version")}},{"./graph":74,"./version":78}],
 76:[function(t,n,e){function r(t){var n={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:i(t),edges:o(t)};return u.isUndefined(t.graph())||(n.value=u.clone(t.graph())),n}function i(t){return u.map(t.nodes(),function(n){var e=t.node(n),r=t.parent(n),i={v:n};return u.isUndefined(e)||(i.value=e),u.isUndefined(r)||(i.parent=r),i})}function o(t){return u.map(t.edges(),function(n){var e=t.edge(n),r={v:n.v,w:n.w};return u.isUndefined(n.name)||(r.name=n.name),u.isUndefined(e)||(r.value=e),r})}function a(t){var n=new c(t.options).setGraph(t.value);return u.each(t.nodes,function(t){n.setNode(t.v,t.value),t.parent&&n.setParent(t.v,t.parent)}),u.each(t.edges,function(t){n.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),n}var u=t("./lodash"),c=t("./graph");n.exports={write:r,read:a}},{"./graph":74,"./lodash":77}],77:[function(t,n,e){var r;if("function"==typeof t)try{r=t("lodash")}catch(i){}r||(r=window._),n.exports=r},{lodash:79}],78:[function(t,n,e){n.ex
 ports="1.0.5"},{}],79:[function(n,e,r){(function(n){(function(){function i(t,n){if(t!==n){var e=null===t,r=t===N,i=t===t,o=null===n,a=n===N,u=n===n;if(t>n&&!o||!i||e&&!a&&u||r&&u)return 1;if(n>t&&!e||!u||o&&!r&&i||a&&i)return-1}return 0}function o(t,n,e){for(var r=t.length,i=e?r:-1;e?i--:++i<r;)if(n(t[i],i,t))return i;return-1}function a(t,n,e){if(n!==n)return y(t,e);for(var r=e-1,i=t.length;++r<i;)if(t[r]===n)return r;return-1}function u(t){return"function"==typeof t||!1}function c(t){return null==t?"":t+""}function s(t,n){for(var e=-1,r=t.length;++e<r&&n.indexOf(t.charAt(e))>-1;);return e}function f(t,n){for(var e=t.length;e--&&n.indexOf(t.charAt(e))>-1;);return e}function l(t,n){return i(t.criteria,n.criteria)||t.index-n.index}function h(t,n,e){for(var r=-1,o=t.criteria,a=n.criteria,u=o.length,c=e.length;++r<u;){var s=i(o[r],a[r]);if(s){if(r>=c)return s;var f=e[r];return s*("asc"===f||f===!0?1:-1)}}return t.index-n.index}function d(t){return Vt[t]}function p(t){return Yt[t]}funct
 ion g(t,n,e){return n?t=Ht[t]:e&&(t=Kt[t]),"\\"+t}function v(t){return"\\"+Kt[t]}function y(t,n,e){for(var r=t.length,i=n+(e?0:-1);e?i--:++i<r;){var o=t[i];if(o!==o)return i}return-1}function _(t){return!!t&&"object"==typeof t}function m(t){return 160>=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function w(t,n){for(var e=-1,r=t.length,i=-1,o=[];++e<r;)t[e]===n&&(t[e]=V,o[++i]=e);return o}function b(t,n){for(var e,r=-1,i=t.length,o=-1,a=[];++r<i;){var u=t[r],c=n?n(u,r,t):u;r&&e===c||(e=c,a[++o]=u)}return a}function x(t){for(var n=-1,e=t.length;++n<e&&m(t.charCodeAt(n)););return n}function k(t){for(var n=t.length;n--&&m(t.charCodeAt(n)););return n}function E(t){return $t[t]}function I(t){function n(t){if(_(t)&&!Ru(t)&&!(t instanceof m)){if(t instanceof r)return t;if(na.call(t,"__chain__")&&na.call(t,"__wrapped__"))return dr(t)}return new r(t)}function e(){}function r(t,n,e){this.__wrapped__=t,this.__action
 s__=e||[],this.__chain__=!!n}function m(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ja,this.__views__=[]}function J(){var t=new m(this.__wrapped__);return t.__actions__=tn(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=tn(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=tn(this.__views__),t}function et(){if(this.__filtered__){var t=new m(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function it(){var t=this.__wrapped__.value(),n=this.__dir__,e=Ru(t),r=0>n,i=e?t.length:0,o=Ye(0,i,this.__views__),a=o.start,u=o.end,c=u-a,s=r?u:a-1,f=this.__iteratees__,l=f.length,h=0,d=ka(c,this.__takeCount__);if(!e||W>i||i==c&&d==c)return re(r&&e?t.reverse():t,this.__actions__);var p=[];t:for(;c--&&d>h;){s+=n;for(var g=-1,v=t[s];++g<l;){var y=f[g],_=y.iteratee,m=y.type,w=_(v);if(m==q)v=w;else if(!w){if(m==z)continue t;break t}}p[h++]=v
 }return p}function Vt(){this.__data__={}}function Yt(t){return this.has(t)&&delete this.__data__[t]}function $t(t){return"__proto__"==t?N:this.__data__[t]}function Xt(t){return"__proto__"!=t&&na.call(this.__data__,t)}function Ht(t,n){return"__proto__"!=t&&(this.__data__[t]=n),this}function Kt(t){var n=t?t.length:0;for(this.data={hash:ya(null),set:new la};n--;)this.push(t[n])}function Qt(t,n){var e=t.data,r="string"==typeof n||Si(n)?e.set.has(n):e.hash[n];return r?0:-1}function Jt(t){var n=this.data;"string"==typeof t||Si(t)?n.set.add(t):n.hash[t]=!0}function Zt(t,n){for(var e=-1,r=t.length,i=-1,o=n.length,a=Wo(r+o);++e<r;)a[e]=t[e];for(;++i<o;)a[e++]=n[i];return a}function tn(t,n){var e=-1,r=t.length;for(n||(n=Wo(r));++e<r;)n[e]=t[e];return n}function nn(t,n){for(var e=-1,r=t.length;++e<r&&n(t[e],e,t)!==!1;);return t}function en(t,n){for(var e=t.length;e--&&n(t[e],e,t)!==!1;);return t}function an(t,n){for(var e=-1,r=t.length;++e<r;)if(!n(t[e],e,t))return!1;return!0}function un(t,n,e
 ,r){for(var i=-1,o=t.length,a=r,u=a;++i<o;){var c=t[i],s=+n(c);e(s,a)&&(a=s,u=c)}return u}function cn(t,n){
+for(var e=-1,r=t.length,i=-1,o=[];++e<r;){var a=t[e];n(a,e,t)&&(o[++i]=a)}return o}function sn(t,n){for(var e=-1,r=t.length,i=Wo(r);++e<r;)i[e]=n(t[e],e,t);return i}function fn(t,n){for(var e=-1,r=n.length,i=t.length;++e<r;)t[i+e]=n[e];return t}function ln(t,n,e,r){var i=-1,o=t.length;for(r&&o&&(e=t[++i]);++i<o;)e=n(e,t[i],i,t);return e}function hn(t,n,e,r){var i=t.length;for(r&&i&&(e=t[--i]);i--;)e=n(e,t[i],i,t);return e}function dn(t,n){for(var e=-1,r=t.length;++e<r;)if(n(t[e],e,t))return!0;return!1}function pn(t,n){for(var e=t.length,r=0;e--;)r+=+n(t[e])||0;return r}function gn(t,n){return t===N?n:t}function vn(t,n,e,r){return t!==N&&na.call(r,e)?t:n}function yn(t,n,e){for(var r=-1,i=Du(n),o=i.length;++r<o;){var a=i[r],u=t[a],c=e(u,n[a],a,t,n);(c===c?c===u:u!==u)&&(u!==N||a in t)||(t[a]=c)}return t}function _n(t,n){return null==n?t:wn(n,Du(n),t)}function mn(t,n){for(var e=-1,r=null==t,i=!r&&Qe(t),o=i?t.length:0,a=n.length,u=Wo(a);++e<a;){var c=n[e];u[e]=i?Je(c,o)?t[c]:N:r?N:t[c]}
 return u}function wn(t,n,e){e||(e={});for(var r=-1,i=n.length;++r<i;){var o=n[r];e[o]=t[o]}return e}function bn(t,n,e){var r=typeof t;return"function"==r?n===N?t:ae(t,n,e):null==t?jo:"object"==r?Dn(t):n===N?So(t):Wn(t,n)}function xn(t,n,e,r,i,o,a){var u;if(e&&(u=i?e(t,r,i):e(t)),u!==N)return u;if(!Si(t))return t;var c=Ru(t);if(c){if(u=$e(t),!n)return tn(t,u)}else{var s=ra.call(t),f=s==Q;if(s!=tt&&s!=Y&&(!f||i))return Gt[s]?He(t,s,n):i?t:{};if(u=Xe(f?{}:t),!n)return _n(u,t)}o||(o=[]),a||(a=[]);for(var l=o.length;l--;)if(o[l]==t)return a[l];return o.push(t),a.push(u),(c?nn:An)(t,function(r,i){u[i]=xn(r,n,e,i,t,o,a)}),u}function kn(t,n,e){if("function"!=typeof t)throw new Ko(G);return ha(function(){t.apply(N,e)},n)}function En(t,n){var e=t?t.length:0,r=[];if(!e)return r;var i=-1,o=qe(),u=o==a,c=u&&n.length>=W?ge(n):null,s=n.length;c&&(o=Qt,u=!1,n=c);t:for(;++i<e;){var f=t[i];if(u&&f===f){for(var l=s;l--;)if(n[l]===f)continue t;r.push(f)}else o(n,f,0)<0&&r.push(f)}return r}function In(t
 ,n){var e=!0;return Ba(t,function(t,r,i){return e=!!n(t,r,i)}),e}function Nn(t,n,e,r){var i=r,o=i;return Ba(t,function(t,a,u){var c=+n(t,a,u);(e(c,i)||c===r&&c===o)&&(i=c,o=t)}),o}function Cn(t,n,e,r){var i=t.length;for(e=null==e?0:+e||0,0>e&&(e=-e>i?0:i+e),r=r===N||r>i?i:+r||0,0>r&&(r+=i),i=e>r?0:r>>>0,e>>>=0;i>e;)t[e++]=n;return t}function jn(t,n){var e=[];return Ba(t,function(t,r,i){n(t,r,i)&&e.push(t)}),e}function Rn(t,n,e,r){var i;return e(t,function(t,e,o){return n(t,e,o)?(i=r?e:t,!1):void 0}),i}function Tn(t,n,e,r){r||(r=[]);for(var i=-1,o=t.length;++i<o;){var a=t[i];_(a)&&Qe(a)&&(e||Ru(a)||Ii(a))?n?Tn(a,n,e,r):fn(r,a):e||(r[r.length]=a)}return r}function Ln(t,n){return Pa(t,n,to)}function An(t,n){return Pa(t,n,Du)}function On(t,n){return Fa(t,n,Du)}function Sn(t,n){for(var e=-1,r=n.length,i=-1,o=[];++e<r;){var a=n[e];Oi(t[a])&&(o[++i]=a)}return o}function Mn(t,n,e){if(null!=t){e!==N&&e in lr(t)&&(n=[e]);for(var r=0,i=n.length;null!=t&&i>r;)t=t[n[r++]];return r&&r==i?t:N}}fun
 ction Bn(t,n,e,r,i,o){return t===n?!0:null==t||null==n||!Si(t)&&!_(n)?t!==t&&n!==n:Un(t,n,Bn,e,r,i,o)}function Un(t,n,e,r,i,o,a){var u=Ru(t),c=Ru(n),s=$,f=$;u||(s=ra.call(t),s==Y?s=tt:s!=tt&&(u=qi(t))),c||(f=ra.call(n),f==Y?f=tt:f!=tt&&(c=qi(n)));var l=s==tt,h=f==tt,d=s==f;if(d&&!u&&!l)return Fe(t,n,s);if(!i){var p=l&&na.call(t,"__wrapped__"),g=h&&na.call(n,"__wrapped__");if(p||g)return e(p?t.value():t,g?n.value():n,r,i,o,a)}if(!d)return!1;o||(o=[]),a||(a=[]);for(var v=o.length;v--;)if(o[v]==t)return a[v]==n;o.push(t),a.push(n);var y=(u?Pe:De)(t,n,e,r,i,o,a);return o.pop(),a.pop(),y}function Pn(t,n,e){var r=n.length,i=r,o=!e;if(null==t)return!i;for(t=lr(t);r--;){var a=n[r];if(o&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++r<i;){a=n[r];var u=a[0],c=t[u],s=a[1];if(o&&a[2]){if(c===N&&!(u in t))return!1}else{var f=e?e(c,s,u):N;if(!(f===N?Bn(s,c,e,!0):f))return!1}}return!0}function Fn(t,n){var e=-1,r=Qe(t)?Wo(t.length):[];return Ba(t,function(t,i,o){r[++e]=n(t,i,o)}),r}function Dn(t)
 {var n=Ge(t);if(1==n.length&&n[0][2]){var e=n[0][0],r=n[0][1];return function(t){return null==t?!1:t[e]===r&&(r!==N||e in lr(t))}}return function(t){return Pn(t,n)}}function Wn(t,n){var e=Ru(t),r=tr(t)&&rr(n),i=t+"";return t=hr(t),function(o){if(null==o)return!1;var a=i;if(o=lr(o),!(!e&&r||a in o)){if(o=1==t.length?o:Mn(o,Hn(t,0,-1)),null==o)return!1;a=Nr(t),o=lr(o)}return o[a]===n?n!==N||a in o:Bn(n,o[a],N,!0)}}function zn(t,n,e,r,i){if(!Si(t))return t;var o=Qe(n)&&(Ru(n)||qi(n)),a=o?N:Du(n);return nn(a||n,function(u,c){if(a&&(c=u,u=n[c]),_(u))r||(r=[]),i||(i=[]),qn(t,n,c,zn,e,r,i);else{var s=t[c],f=e?e(s,u,c,t,n):N,l=f===N;l&&(f=u),f===N&&(!o||c in t)||!l&&(f===f?f===s:s!==s)||(t[c]=f)}}),t}function qn(t,n,e,r,i,o,a){for(var u=o.length,c=n[e];u--;)if(o[u]==c)return void(t[e]=a[u]);var s=t[e],f=i?i(s,c,e,t,n):N,l=f===N;l&&(f=c,Qe(c)&&(Ru(c)||qi(c))?f=Ru(s)?s:Qe(s)?tn(s):[]:Di(c)||Ii(c)?f=Ii(s)?Xi(s):Di(s)?s:{}:l=!1),o.push(c),a.push(f),l?t[e]=r(f,c,i,o,a):(f===f?f!==s:s===s)&&(t[e]
 =f)}function Gn(t){return function(n){return null==n?N:n[t]}}function Vn(t){var n=t+"";return t=hr(t),function(e){return Mn(e,t,n)}}function Yn(t,n){for(var e=t?n.length:0;e--;){var r=n[e];if(r!=i&&Je(r)){var i=r;da.call(t,r,1)}}return t}function $n(t,n){return t+_a(Na()*(n-t+1))}function Xn(t,n,e,r,i){return i(t,function(t,i,o){e=r?(r=!1,t):n(e,t,i,o)}),e}function Hn(t,n,e){var r=-1,i=t.length;n=null==n?0:+n||0,0>n&&(n=-n>i?0:i+n),e=e===N||e>i?i:+e||0,0>e&&(e+=i),i=n>e?0:e-n>>>0,n>>>=0;for(var o=Wo(i);++r<i;)o[r]=t[r+n];return o}function Kn(t,n){var e;return Ba(t,function(t,r,i){return e=n(t,r,i),!e}),!!e}function Qn(t,n){var e=t.length;for(t.sort(n);e--;)t[e]=t[e].value;return t}function Jn(t,n,e){var r=We(),i=-1;n=sn(n,function(t){return r(t)});var o=Fn(t,function(t){var e=sn(n,function(n){return n(t)});return{criteria:e,index:++i,value:t}});return Qn(o,function(t,n){return h(t,n,e)})}function Zn(t,n){var e=0;return Ba(t,function(t,r,i){e+=+n(t,r,i)||0}),e}function te(t,n){var e=
 -1,r=qe(),i=t.length,o=r==a,u=o&&i>=W,c=u?ge():null,s=[];c?(r=Qt,o=!1):(u=!1,c=n?[]:s);t:for(;++e<i;){var f=t[e],l=n?n(f,e,t):f;if(o&&f===f){for(var h=c.length;h--;)if(c[h]===l)continue t;n&&c.push(l),s.push(f)}else r(c,l,0)<0&&((n||u)&&c.push(l),s.push(f))}return s}function ne(t,n){for(var e=-1,r=n.length,i=Wo(r);++e<r;)i[e]=t[n[e]];return i}function ee(t,n,e,r){for(var i=t.length,o=r?i:-1;(r?o--:++o<i)&&n(t[o],o,t););return e?Hn(t,r?0:o,r?o+1:i):Hn(t,r?o+1:0,r?i:o)}function re(t,n){var e=t;e instanceof m&&(e=e.value());for(var r=-1,i=n.length;++r<i;){var o=n[r];e=o.func.apply(o.thisArg,fn([e],o.args))}return e}function ie(t,n,e){var r=0,i=t?t.length:r;if("number"==typeof n&&n===n&&La>=i){for(;i>r;){var o=r+i>>>1,a=t[o];(e?n>=a:n>a)&&null!==a?r=o+1:i=o}return i}return oe(t,n,jo,e)}function oe(t,n,e,r){n=e(n);for(var i=0,o=t?t.length:0,a=n!==n,u=null===n,c=n===N;o>i;){var s=_a((i+o)/2),f=e(t[s]),l=f!==N,h=f===f;if(a)var d=h||r;else d=u?h&&l&&(r||null!=f):c?h&&(r||l):null==f?!1:r?n>=
 f:n>f;d?i=s+1:o=s}return ka(o,Ta)}function ae(t,n,e){if("function"!=typeof t)return jo;if(n===N)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 3:return function(e,r,i){return t.call(n,e,r,i)};case 4:return function(e,r,i,o){return t.call(n,e,r,i,o)};case 5:return function(e,r,i,o,a){return t.call(n,e,r,i,o,a)}}return function(){return t.apply(n,arguments)}}function ue(t){var n=new aa(t.byteLength),e=new pa(n);return e.set(new pa(t)),n}function ce(t,n,e){for(var r=e.length,i=-1,o=xa(t.length-r,0),a=-1,u=n.length,c=Wo(u+o);++a<u;)c[a]=n[a];for(;++i<r;)c[e[i]]=t[i];for(;o--;)c[a++]=t[i++];return c}function se(t,n,e){for(var r=-1,i=e.length,o=-1,a=xa(t.length-i,0),u=-1,c=n.length,s=Wo(a+c);++o<a;)s[o]=t[o];for(var f=o;++u<c;)s[f+u]=n[u];for(;++r<i;)s[f+e[r]]=t[o++];return s}function fe(t,n){return function(e,r,i){var o=n?n():{};if(r=We(r,i,3),Ru(e))for(var a=-1,u=e.length;++a<u;){var c=e[a];t(o,c,r(c,a,e),e)}else Ba(e,function(n,e,i){t(o,n,r(n,e,i),i)});return o}}
 function le(t){return yi(function(n,e){var r=-1,i=null==n?0:e.length,o=i>2?e[i-2]:N,a=i>2?e[2]:N,u=i>1?e[i-1]:N;for("function"==typeof o?(o=ae(o,u,5),i-=2):(o="function"==typeof u?u:N,i-=o?1:0),a&&Ze(e[0],e[1],a)&&(o=3>i?N:o,i=1);++r<i;){var c=e[r];c&&t(n,c,o)}return n})}function he(t,n){return function(e,r){var i=e?za(e):0;if(!er(i))return t(e,r);for(var o=n?i:-1,a=lr(e);(n?o--:++o<i)&&r(a[o],o,a)!==!1;);return e}}function de(t){return function(n,e,r){for(var i=lr(n),o=r(n),a=o.length,u=t?a:-1;t?u--:++u<a;){var c=o[u];if(e(i[c],c,i)===!1)break}return n}}function pe(t,n){function e(){var i=this&&this!==rn&&this instanceof e?r:t;return i.apply(n,arguments)}var r=ye(t);return e}function ge(t){return ya&&la?new Kt(t):null}function ve(t){return function(n){for(var e=-1,r=Io(fo(n)),i=r.length,o="";++e<i;)o=t(o,r[e],e);return o}}function ye(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t
 (n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var e=Ma(t.prototype),r=t.apply(e,n);return Si(r)?r:e}}function _e(t){function n(e,r,i){i&&Ze(e,r,i)&&(r=N);var o=Ue(e,t,N,N,N,N,N,r);return o.placeholder=n.placeholder,o}return n}function me(t,n){return yi(function(e){var r=e[0];return null==r?r:(e.push(n),t.apply(N,e))})}function we(t,n){return function(e,r,i){if(i&&Ze(e,r,i)&&(r=N),r=We(r,i,3),1==r.length){e=Ru(e)?e:fr(e);var o=un(e,r,t,n);if(!e.length||o!==n)return o}return Nn(e,r,t,n)}}function be(t,n){return function(e,r,i){if(r=We(r,i,3),Ru(e)){var a=o(e,r,n);return a>-1?e[a]:N}return Rn(e,r,t)}}function xe(t){return function(n,e,r){return n&&n.length?(e=We(e,r,3),o(n,e,t)):-1}}function ke(t){return function(n,e,r){return e=We(e,r,3),Rn(n,e,t,!0)}}function Ee(t){return function(){for(var n,e=arguments.length,i=t?e:-1,o
 =0,a=Wo(e);t?i--:++i<e;){var u=a[o++]=arguments[i];if("function"!=typeof u)throw new Ko(G);!n&&r.prototype.thru&&"wrapper"==ze(u)&&(n=new r([],!0))}for(i=n?-1:e;++i<e;){u=a[i];var c=ze(u),s="wrapper"==c?Wa(u):N;n=s&&nr(s[0])&&s[1]==(M|L|O|B)&&!s[4].length&&1==s[9]?n[ze(s[0])].apply(n,s[3]):1==u.length&&nr(u)?n[c]():n.thru(u)}return function(){var t=arguments,r=t[0];if(n&&1==t.length&&Ru(r)&&r.length>=W)return n.plant(r).value();for(var i=0,o=e?a[i].apply(this,t):r;++i<e;)o=a[i].call(this,o);return o}}}function Ie(t,n){return function(e,r,i){return"function"==typeof r&&i===N&&Ru(e)?t(e,r):n(e,ae(r,i,3))}}function Ne(t){return function(n,e,r){return("function"!=typeof e||r!==N)&&(e=ae(e,r,3)),t(n,e,to)}}function Ce(t){return function(n,e,r){return("function"!=typeof e||r!==N)&&(e=ae(e,r,3)),t(n,e)}}function je(t){return function(n,e,r){var i={};return e=We(e,r,3),An(n,function(n,r,o){var a=e(n,r,o);r=t?a:r,n=t?n:a,i[r]=n}),i}}function Re(t){return function(n,e,r){return n=c(n),(t?n:""
 )+Oe(n,e,r)+(t?"":n)}}function Te(t){var n=yi(function(e,r){var i=w(r,n.placeholder);return Ue(e,t,N,r,i)});return n}function Le(t,n){return function(e,r,i,o){var a=arguments.length<3;return"function"==typeof r&&o===N&&Ru(e)?t(e,r,i,a):Xn(e,We(r,o,4),i,a,n)}}function Ae(t,n,e,r,i,o,a,u,c,s){function f(){for(var _=arguments.length,m=_,b=Wo(_);m--;)b[m]=arguments[m];if(r&&(b=ce(b,r,i)),o&&(b=se(b,o,a)),p||v){var x=f.placeholder,k=w(b,x);if(_-=k.length,s>_){var E=u?tn(u):N,I=xa(s-_,0),C=p?k:N,T=p?N:k,L=p?b:N,A=p?N:b;n|=p?O:S,n&=~(p?S:O),g||(n&=~(j|R));var M=[t,n,e,L,C,A,T,E,c,I],B=Ae.apply(N,M);return nr(t)&&qa(B,M),B.placeholder=x,B}}var U=h?e:this,P=d?U[t]:t;return u&&(b=cr(b,u)),l&&c<b.length&&(b.length=c),this&&this!==rn&&this instanceof f&&(P=y||ye(t)),P.apply(U,b)}var l=n&M,h=n&j,d=n&R,p=n&L,g=n&T,v=n&A,y=d?N:ye(t);return f}function Oe(t,n,e){var r=t.length;if(n=+n,r>=n||!wa(n))return"";var i=n-r;return e=null==e?" ":e+"",yo(e,va(i/e.length)).slice(0,i)}function Se(t,n,e,r){funct
 ion i(){for(var n=-1,u=arguments.length,c=-1,s=r.length,f=Wo(s+u);++c<s;)f[c]=r[c];for(;u--;)f[c++]=arguments[++n];var l=this&&this!==rn&&this instanceof i?a:t;return l.apply(o?e:this,f)}var o=n&j,a=ye(t);return i}function Me(t){var n=Vo[t];return function(t,e){return e=e===N?0:+e||0,e?(e=sa(10,e),n(t*e)/e):n(t)}}function Be(t){return function(n,e,r,i){var o=We(r);return null==r&&o===bn?ie(n,e,t):oe(n,e,o(r,i,1),t)}}function Ue(t,n,e,r,i,o,a,u){var c=n&R;if(!c&&"function"!=typeof t)throw new Ko(G);var s=r?r.length:0;if(s||(n&=~(O|S),r=i=N),s-=i?i.length:0,n&S){var f=r,l=i;r=i=N}var h=c?N:Wa(t),d=[t,n,e,r,i,f,l,o,a,u];if(h&&(ir(d,h),n=d[1],u=d[9]),d[9]=null==u?c?0:t.length:xa(u-s,0)||0,n==j)var p=pe(d[0],d[2]);else p=n!=O&&n!=(j|O)||d[4].length?Ae.apply(N,d):Se.apply(N,d);var g=h?Da:qa;return g(p,d)}function Pe(t,n,e,r,i,o,a){var u=-1,c=t.length,s=n.length;if(c!=s&&!(i&&s>c))return!1;for(;++u<c;){var f=t[u],l=n[u],h=r?r(i?l:f,i?f:l,u):N;if(h!==N){if(h)continue;return!1}if(i){if(!dn(n
 ,function(t){return f===t||e(f,t,r,i,o,a)}))return!1}else if(f!==l&&!e(f,l,r,i,o,a))return!1}return!0}function Fe(t,n,e){switch(e){case X:case H:return+t==+n;case K:return t.name==n.name&&t.message==n.message;case Z:return t!=+t?n!=+n:t==+n;case nt:case rt:return t==n+""}return!1}function De(t,n,e,r,i,o,a){var u=Du(t),c=u.length,s=Du(n),f=s.length;if(c!=f&&!i)return!1;for(var l=c;l--;){var h=u[l];if(!(i?h in n:na.call(n,h)))return!1}for(var d=i;++l<c;){h=u[l];var p=t[h],g=n[h],v=r?r(i?g:p,i?p:g,h):N;if(!(v===N?e(p,g,r,i,o,a):v))return!1;d||(d="constructor"==h)}if(!d){var y=t.constructor,_=n.constructor;if(y!=_&&"constructor"in t&&"constructor"in n&&!("function"==typeof y&&y instanceof y&&"function"==typeof _&&_ instanceof _))return!1}return!0}function We(t,e,r){var i=n.callback||No;return i=i===No?bn:i,r?i(t,e,r):i}function ze(t){for(var n=t.name,e=Sa[n],r=e?e.length:0;r--;){var i=e[r],o=i.func;if(null==o||o==t)return i.name}return n}function qe(t,e,r){var i=n.indexOf||Er;return i=i
 ===Er?a:i,t?i(t,e,r):i}function Ge(t){for(var n=no(t),e=n.length;e--;)n[e][2]=rr(n[e][1]);return n}function Ve(t,n){var e=null==t?N:t[n];return Ui(e)?e:N}function Ye(t,n,e){for(var r=-1,i=e.length;++r<i;){var o=e[r],a=o.size;switch(o.type){case"drop":t+=a;break;case"dropRight":n-=a;break;case"take":n=ka(n,t+a);break;case"takeRight":t=xa(t,n-a)}}return{start:t,end:n}}function $e(t){var n=t.length,e=new t.constructor(n);return n&&"string"==typeof t[0]&&na.call(t,"index")&&(e.index=t.index,e.input=t.input),e}function Xe(t){var n=t.constructor;return"function"==typeof n&&n instanceof n||(n=$o),new n}function He(t,n,e){var r=t.constructor;switch(n){case ot:return ue(t);case X:case H:return new r(+t);case at:case ut:case ct:case st:case ft:case lt:case ht:case dt:case pt:var i=t.buffer;return new r(e?ue(i):i,t.byteOffset,t.length);case Z:case rt:return new r(t);case nt:var o=new r(t.source,Ot.exec(t));o.lastIndex=t.lastIndex}return o}function Ke(t,n,e){null==t||tr(n,t)||(n=hr(n),t=1==n.le
 ngth?t:Mn(t,Hn(n,0,-1)),n=Nr(n));var r=null==t?t:t[n];return null==r?N:r.apply(t,e)}function Qe(t){return null!=t&&er(za(t))}function Je(t,n){return t="number"==typeof t||Bt.test(t)?+t:-1,n=null==n?Aa:n,t>-1&&t%1==0&&n>t}function Ze(t,n,e){if(!Si(e))return!1;var r=typeof n;if("number"==r?Qe(e)&&Je(n,e.length):"string"==r&&n in e){var i=e[n];return t===t?t===i:i!==i}return!1}function tr(t,n){var e=typeof t;if("string"==e&&Nt.test(t)||"number"==e)return!0;if(Ru(t))return!1;var r=!It.test(t);return r||null!=n&&t in lr(n)}function nr(t){var e=ze(t);if(!(e in m.prototype))return!1;var r=n[e];if(t===r)return!0;var i=Wa(r);return!!i&&t===i[0]}function er(t){return"number"==typeof t&&t>-1&&t%1==0&&Aa>=t}function rr(t){return t===t&&!Si(t)}function ir(t,n){var e=t[1],r=n[1],i=e|r,o=M>i,a=r==M&&e==L||r==M&&e==B&&t[7].length<=n[8]||r==(M|B)&&e==L;if(!o&&!a)return t;r&j&&(t[2]=n[2],i|=e&j?0:T);var u=n[3];if(u){var c=t[3];t[3]=c?ce(c,u,n[4]):tn(u),t[4]=c?w(t[3],V):tn(n[4])}return u=n[5],u&&(c=t[
 5],t[5]=c?se(c,u,n[6]):tn(u),t[6]=c?w(t[5],V):tn(n[6])),u=n[7],u&&(t[7]=tn(u)),r&M&&(t[8]=null==t[8]?n[8]:ka(t[8],n[8])),null==t[9]&&(t[9]=n[9]),t[0]=n[0],t[1]=i,t}function or(t,n){return t===N?n:Tu(t,n,or)}function ar(t,n){t=lr(t);for(var e=-1,r=n.length,i={};++e<r;){var o=n[e];o in t&&(i[o]=t[o])}return i}function ur(t,n){var e={};return Ln(t,function(t,r,i){n(t,r,i)&&(e[r]=t)}),e}function cr(t,n){for(var e=t.length,r=ka(n.length,e),i=tn(t);r--;){var o=n[r];t[r]=Je(o,e)?i[o]:N}return t}function sr(t){for(var n=to(t),e=n.length,r=e&&t.length,i=!!r&&er(r)&&(Ru(t)||Ii(t)),o=-1,a=[];++o<e;){var u=n[o];(i&&Je(u,r)||na.call(t,u))&&a.push(u)}return a}function fr(t){return null==t?[]:Qe(t)?Si(t)?t:$o(t):oo(t)}function lr(t){return Si(t)?t:$o(t)}function hr(t){if(Ru(t))return t;var n=[];return c(t).replace(Ct,function(t,e,r,i){n.push(r?i.replace(Lt,"$1"):e||t)}),n}function dr(t){return t instanceof m?t.clone():new r(t.__wrapped__,t.__chain__,tn(t.__actions__))}function pr(t,n,e){n=(e?Ze(t,
 n,e):null==n)?1:xa(_a(n)||1,1);for(var r=0,i=t?t.length:0,o=-1,a=Wo(va(i/n));i>r;)a[++o]=Hn(t,r,r+=n);return a}function gr(t){for(var n=-1,e=t?t.length:0,r=-1,i=[];++n<e;){var o=t[n];o&&(i[++r]=o)}return i}function vr(t,n,e){var r=t?t.length:0;return r?((e?Ze(t,n,e):null==n)&&(n=1),Hn(t,0>n?0:n)):[]}function yr(t,n,e){var r=t?t.length:0;return r?((e?Ze(t,n,e):null==n)&&(n=1),n=r-(+n||0),Hn(t,0,0>n?0:n)):[]}function _r(t,n,e){return t&&t.length?ee(t,We(n,e,3),!0,!0):[]}function mr(t,n,e){return t&&t.length?ee(t,We(n,e,3),!0):[]}function wr(t,n,e,r){var i=t?t.length:0;return i?(e&&"number"!=typeof e&&Ze(t,n,e)&&(e=0,r=i),Cn(t,n,e,r)):[]}function br(t){return t?t[0]:N}function xr(t,n,e){var r=t?t.length:0;return e&&Ze(t,n,e)&&(n=!1),r?Tn(t,n):[]}function kr(t){var n=t?t.length:0;return n?Tn(t,!0):[]}function Er(t,n,e){var r=t?t.length:0;if(!r)return-1;if("number"==typeof e)e=0>e?xa(r+e,0):e;else if(e){var i=ie(t,n);return r>i&&(n===n?n===t[i]:t[i]!==t[i])?i:-1}return a(t,n,e||0)}functi
 on Ir(t){return yr(t,1)}function Nr(t){var n=t?t.length:0;return n?t[n-1]:N}function Cr(t,n,e){var r=t?t.length:0;if(!r)return-1;var i=r;if("number"==typeof e)i=(0>e?xa(r+e,0):ka(e||0,r-1))+1;else if(e){i=ie(t,n,!0)-1;var o=t[i];return(n===n?n===o:o!==o)?i:-1}if(n!==n)return y(t,i,!0);for(;i--;)if(t[i]===n)return i;return-1}function jr(){var t=arguments,n=t[0];if(!n||!n.length)return n;for(var e=0,r=qe(),i=t.length;++e<i;)for(var o=0,a=t[e];(o=r(n,a,o))>-1;)da.call(n,o,1);return n}function Rr(t,n,e){var r=[];if(!t||!t.length)return r;var i=-1,o=[],a=t.length;for(n=We(n,e,3);++i<a;){var u=t[i];n(u,i,t)&&(r.push(u),o.push(i))}return Yn(t,o),r}function Tr(t){return vr(t,1)}function Lr(t,n,e){var r=t?t.length:0;return r?(e&&"number"!=typeof e&&Ze(t,n,e)&&(n=0,e=r),Hn(t,n,e)):[]}function Ar(t,n,e){var r=t?t.length:0;return r?((e?Ze(t,n,e):null==n)&&(n=1),Hn(t,0,0>n?0:n)):[]}function Or(t,n,e){var r=t?t.length:0;return r?((e?Ze(t,n,e):null==n)&&(n=1),n=r-(+n||0),Hn(t,0>n?0:n)):[]}function
  Sr(t,n,e){return t&&t.length?ee(t,We(n,e,3),!1,!0):[]}function Mr(t,n,e){return t&&t.length?ee(t,We(n,e,3)):[]}function Br(t,n,e,r){var i=t?t.length:0;if(!i)return[];null!=n&&"boolean"!=typeof n&&(r=e,e=Ze(t,n,r)?N:n,n=!1);var o=We();return(null!=e||o!==bn)&&(e=o(e,r,3)),n&&qe()==a?b(t,e):te(t,e)}function Ur(t){if(!t||!t.length)return[];var n=-1,e=0;t=cn(t,function(t){return Qe(t)?(e=xa(t.length,e),!0):void 0});for(var r=Wo(e);++n<e;)r[n]=sn(t,Gn(n));return r}function Pr(t,n,e){var r=t?t.length:0;if(!r)return[];var i=Ur(t);return null==n?i:(n=ae(n,e,4),sn(i,function(t){return ln(t,n,N,!0)}))}function Fr(){for(var t=-1,n=arguments.length;++t<n;){var e=arguments[t];if(Qe(e))var r=r?fn(En(r,e),En(e,r)):e}return r?te(r):[]}function Dr(t,n){var e=-1,r=t?t.length:0,i={};for(!r||n||Ru(t[0])||(n=[]);++e<r;){var o=t[e];n?i[o]=n[e]:o&&(i[o[0]]=o[1])}return i}function Wr(t){var e=n(t);return e.__chain__=!0,e}function zr(t,n,e){return n.call(e,t),t}function qr(t,n,e){return n.call(e,t)}functio
 n Gr(){return Wr(this)}function Vr(){return new r(this.value(),this.__chain__)}function Yr(t){for(var n,r=this;r instanceof e;){var i=dr(r);n?o.__wrapped__=i:n=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,n}function $r(){var t=this.__wrapped__,n=function(t){return e&&e.__dir__<0?t:t.reverse()};if(t instanceof m){var e=t;return this.__actions__.length&&(e=new m(this)),e=e.reverse(),e.__actions__.push({func:qr,args:[n],thisArg:N}),new r(e,this.__chain__)}return this.thru(n)}function Xr(){return this.value()+""}function Hr(){return re(this.__wrapped__,this.__actions__)}function Kr(t,n,e){var r=Ru(t)?an:In;return e&&Ze(t,n,e)&&(n=N),("function"!=typeof n||e!==N)&&(n=We(n,e,3)),r(t,n)}function Qr(t,n,e){var r=Ru(t)?cn:jn;return n=We(n,e,3),r(t,n)}function Jr(t,n){return iu(t,Dn(n))}function Zr(t,n,e,r){var i=t?za(t):0;return er(i)||(t=oo(t),i=t.length),e="number"!=typeof e||r&&Ze(n,e,r)?0:0>e?xa(i+e,0):e||0,"string"==typeof t||!Ru(t)&&zi(t)?i>=e&&t.indexOf(n,e)>-1:!!i&&qe(t,n,e)>-1}f
 unction ti(t,n,e){var r=Ru(t)?sn:Fn;return n=We(n,e,3),r(t,n)}function ni(t,n){return ti(t,So(n))}function ei(t,n,e){var r=Ru(t)?cn:jn;return n=We(n,e,3),r(t,function(t,e,r){return!n(t,e,r)})}function ri(t,n,e){if(e?Ze(t,n,e):null==n){t=fr(t);var r=t.length;return r>0?t[$n(0,r-1)]:N}var i=-1,o=$i(t),r=o.length,a=r-1;for(n=ka(0>n?0:+n||0,r);++i<n;){var u=$n(i,a),c=o[u];o[u]=o[i],o[i]=c}return o.length=n,o}function ii(t){return ri(t,ja)}function oi(t){var n=t?za(t):0;return er(n)?n:Du(t).length}function ai(t,n,e){var r=Ru(t)?dn:Kn;return e&&Ze(t,n,e)&&(n=N),("function"!=typeof n||e!==N)&&(n=We(n,e,3)),r(t,n)}function ui(t,n,e){if(null==t)return[];e&&Ze(t,n,e)&&(n=N);var r=-1;n=We(n,e,3);var i=Fn(t,function(t,e,i){return{criteria:n(t,e,i),index:++r,value:t}});return Qn(i,l)}function ci(t,n,e,r){return null==t?[]:(r&&Ze(n,e,r)&&(e=N),Ru(n)||(n=null==n?[]:[n]),Ru(e)||(e=null==e?[]:[e]),Jn(t,n,e))}function si(t,n){return Qr(t,Dn(n))}function fi(t,n){if("function"!=typeof n){if("function"!
 =typeof t)throw new Ko(G);var e=t;t=n,n=e}return t=wa(t=+t)?t:0,function(){return--t<1?n.apply(this,arguments):void 0}}function li(t,n,e){return e&&Ze(t,n,e)&&(n=N),n=t&&null==n?t.length:xa(+n||0,0),Ue(t,M,N,N,N,N,n)}function hi(t,n){var e;if("function"!=typeof n){if("function"!=typeof t)throw new Ko(G);var r=t;t=n,n=r}return function(){return--t>0&&(e=n.apply(this,arguments)),1>=t&&(n=N),e}}function di(t,n,e){function r(){d&&ua(d),s&&ua(s),g=0,s=d=p=N}function i(n,e){e&&ua(e),s=d=p=N,n&&(g=gu(),f=t.apply(h,c),d||s||(c=h=N))}function o(){var t=n-(gu()-l);0>=t||t>n?i(p,s):d=ha(o,t)}function a(){i(y,d)}function u(){if(c=arguments,l=gu(),h=this,p=y&&(d||!_),v===!1)var e=_&&!d;else{s||_||(g=l);var r=v-(l-g),i=0>=r||r>v;i?(s&&(s=ua(s)),g=l,f=t.apply(h,c)):s||(s=ha(a,r))}return i&&d?d=ua(d):d||n===v||(d=ha(o,n)),e&&(i=!0,f=t.apply(h,c)),!i||d||s||(c=h=N),f}var c,s,f,l,h,d,p,g=0,v=!1,y=!0;if("function"!=typeof t)throw new Ko(G);if(n=0>n?0:+n||0,e===!0){var _=!0;y=!1}else Si(e)&&(_=!!e.lead
 ing,v="maxWait"in e&&xa(+e.maxWait||0,n),y="trailing"in e?!!e.trailing:y);return u.cancel=r,u}function pi(t,n){if("function"!=typeof t||n&&"function"!=typeof n)throw new Ko(G);var e=functio

<TRUNCATED>

[4/4] samza git commit: SAMZA-1204: Visualize StreamGraph and ExecutionPlan

Posted by xi...@apache.org.
SAMZA-1204: Visualize StreamGraph and ExecutionPlan

Once a Samza application (using fluent API) is deployed, an execution plan will be generated by the ExecutionPlanner. The plan JSON will be written to a file (plan.json) under the ./plan directory, which also contains the plan.html and javscripts (js folder).

Author: Xinyu Liu <xi...@xiliu-ld.linkedin.biz>
Author: xinyuiscool <xi...@gmail.com>

Reviewers: Jake Maes <jm...@apache.org>

Closes #127 from xinyuiscool/SAMZA-1204


Project: http://git-wip-us.apache.org/repos/asf/samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/samza/commit/b71b253d
Tree: http://git-wip-us.apache.org/repos/asf/samza/tree/b71b253d
Diff: http://git-wip-us.apache.org/repos/asf/samza/diff/b71b253d

Branch: refs/heads/master
Commit: b71b253d2ad6bf1dc68c7bc6bb2e30782d86c7ff
Parents: ad1f161
Author: Xinyu Liu <xi...@xiliu-ld.linkedin.biz>
Authored: Tue May 2 10:09:22 2017 -0700
Committer: Xinyu Liu <xi...@xiliu-ld.linkedin.biz>
Committed: Tue May 2 10:09:22 2017 -0700

----------------------------------------------------------------------
 build.gradle                                    |   3 +
 .../apache/samza/execution/ExecutionPlan.java   |  11 +-
 .../samza/execution/ExecutionPlanner.java       |  10 +-
 .../org/apache/samza/execution/JobGraph.java    |  45 +++--
 .../samza/execution/JobGraphJsonGenerator.java  | 199 ++++++++++---------
 .../org/apache/samza/execution/JobNode.java     |  10 +-
 .../samza/operators/MessageStreamImpl.java      |  30 +--
 .../samza/operators/impl/RootOperatorImpl.java  |   5 +
 .../samza/operators/spec/OperatorSpec.java      |   6 +
 .../operators/spec/PartialJoinOperatorSpec.java |   8 +
 .../samza/operators/spec/SinkOperatorSpec.java  |   8 +
 .../operators/spec/StreamOperatorSpec.java      |   8 +
 .../operators/spec/WindowOperatorSpec.java      |   8 +
 .../samza/operators/util/OperatorJsonUtils.java |  89 +++++++++
 .../runtime/AbstractApplicationRunner.java      |  27 +++
 .../samza/runtime/LocalApplicationRunner.java   |   1 +
 .../samza/runtime/RemoteApplicationRunner.java  |   1 +
 .../samza/config/ShellCommandConfig.scala       |   5 +
 .../samza/execution/TestExecutionPlanner.java   |  15 +-
 .../apache/samza/execution/TestJobGraph.java    |  82 ++++----
 .../execution/TestJobGraphJsonGenerator.java    |   4 +-
 .../samza/operators/impl/TestOperatorImpl.java  |   5 +
 .../samza/operators/spec/TestOperatorSpecs.java |   6 +-
 samza-shell/src/main/assembly/src.xml           |   8 +
 samza-shell/src/main/bash/run-app.sh            |   9 +
 samza-shell/src/main/visualizer/js/d3.v3.min.js |   5 +
 .../src/main/visualizer/js/dagre-d3.min.js      |  28 +++
 .../src/main/visualizer/js/planToDagre.js       |  91 +++++++++
 samza-shell/src/main/visualizer/plan.html       | 118 +++++++++++
 29 files changed, 651 insertions(+), 194 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index dc56077..74e5161 100644
--- a/build.gradle
+++ b/build.gradle
@@ -71,6 +71,8 @@ rat {
     '**/non-responsive.less',
     '**/ropa-sans.css',
     '**/syntax.css',
+    '**/d3.v3.min.js',
+    '**/dagre-d3.min.js',
     '.idea/**',
     '.reviewboardrc',
     'docs/_site/**',
@@ -396,6 +398,7 @@ project(":samza-shell") {
     classifier = 'dist'
     from 'src/main/bash'
     from 'src/main/resources'
+    from 'src/main/visualizer'
   }
 
   artifacts {

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlan.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlan.java b/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlan.java
index 6e2b4c6..bde9bfb 100644
--- a/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlan.java
+++ b/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlan.java
@@ -20,6 +20,7 @@
 package org.apache.samza.execution;
 
 import java.util.List;
+import org.apache.samza.annotation.InterfaceStability;
 import org.apache.samza.config.JobConfig;
 import org.apache.samza.system.StreamSpec;
 
@@ -28,10 +29,11 @@ import org.apache.samza.system.StreamSpec;
  * This interface represents Samza {@link org.apache.samza.application.StreamApplication}
  * plans for physical execution.
  */
+@InterfaceStability.Unstable
 public interface ExecutionPlan {
 
   /**
-   * Returns the configs for single stage job, in the order of topologically sort.
+   * Returns the configs for single stage job, in topological sort order.
    * @return list of job configs
    */
   List<JobConfig> getJobConfigs();
@@ -43,9 +45,10 @@ public interface ExecutionPlan {
   List<StreamSpec> getIntermediateStreams();
 
   /**
-   * Returns the JSON representation of the plan for visualization
-   * @return json string
-   * @throws Exception exception
+   * Returns the JSON representation of the plan.
+   * @return JSON string
+   * @throws Exception exception during JSON serialization, including {@link java.io.IOException}
+   *                   and {@link org.codehaus.jackson.JsonGenerationException}
    */
   String getPlanAsJson() throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlanner.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlanner.java b/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlanner.java
index ac39eb8..d763d84 100644
--- a/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlanner.java
+++ b/samza-core/src/main/java/org/apache/samza/execution/ExecutionPlanner.java
@@ -61,6 +61,9 @@ public class ExecutionPlanner {
     // create physical job graph based on stream graph
     JobGraph jobGraph = createJobGraph(streamGraph);
 
+    // fetch the external streams partition info
+    updateExistingPartitions(jobGraph, streamManager);
+
     if (!jobGraph.getIntermediateStreamEdges().isEmpty()) {
       // figure out the partitions for internal streams
       calculatePartitions(streamGraph, jobGraph);
@@ -84,7 +87,7 @@ public class ExecutionPlanner {
     // For this phase, we have a single job node for the whole dag
     String jobName = config.get(JobConfig.JOB_NAME());
     String jobId = config.get(JobConfig.JOB_ID(), "1");
-    JobNode node = jobGraph.getOrCreateNode(jobName, jobId, streamGraph);
+    JobNode node = jobGraph.getOrCreateJobNode(jobName, jobId, streamGraph);
 
     // add sources
     sourceStreams.forEach(spec -> jobGraph.addSource(spec, node));
@@ -104,9 +107,6 @@ public class ExecutionPlanner {
    * Figure out the number of partitions of all streams
    */
   /* package private */ void calculatePartitions(StreamGraphImpl streamGraph, JobGraph jobGraph) {
-    // fetch the external streams partition info
-    updateExistingPartitions(jobGraph, streamManager);
-
     // calculate the partitions for the input streams of join operators
     calculateJoinInputPartitions(streamGraph, jobGraph);
 
@@ -167,7 +167,7 @@ public class ExecutionPlanner {
     Set<OperatorSpec> visited = new HashSet<>();
 
     streamGraph.getInputStreams().entrySet().forEach(entry -> {
-        StreamEdge streamEdge = jobGraph.getOrCreateEdge(entry.getKey());
+        StreamEdge streamEdge = jobGraph.getOrCreateStreamEdge(entry.getKey());
         // Traverses the StreamGraph to find and update mappings for all Joins reachable from this input StreamEdge
         findReachableJoins(entry.getValue(), streamEdge, joinSpecToStreamEdges, streamEdgeToJoinSpecs,
             outputStreamToJoinSpec, joinQ, visited);

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/execution/JobGraph.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/execution/JobGraph.java b/samza-core/src/main/java/org/apache/samza/execution/JobGraph.java
index ff5fbdf..35f27ab 100644
--- a/samza-core/src/main/java/org/apache/samza/execution/JobGraph.java
+++ b/samza-core/src/main/java/org/apache/samza/execution/JobGraph.java
@@ -30,6 +30,7 @@ import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
 import java.util.stream.Collectors;
+import org.apache.samza.config.ApplicationConfig;
 import org.apache.samza.config.Config;
 import org.apache.samza.config.JobConfig;
 import org.apache.samza.operators.StreamGraphImpl;
@@ -65,40 +66,46 @@ import org.slf4j.LoggerFactory;
     this.config = config;
   }
 
-  /**
-   * Returns the configs for single stage job, in the order of topologically sort.
-   * @return list of job configs
-   */
+  @Override
   public List<JobConfig> getJobConfigs() {
-    return getJobNodes().stream().map(JobNode::generateConfig).collect(Collectors.toList());
+    String json = "";
+    try {
+      json = getPlanAsJson();
+    } catch (Exception e) {
+      log.warn("Failed to generate plan JSON", e);
+    }
+
+    final String planJson = json;
+    return getJobNodes().stream().map(n -> n.generateConfig(planJson)).collect(Collectors.toList());
   }
 
-  /**
-   * Returns the intermediate streams that need to be created.
-   * @return intermediate {@link StreamSpec}s
-   */
+  @Override
   public List<StreamSpec> getIntermediateStreams() {
     return getIntermediateStreamEdges().stream()
         .map(streamEdge -> streamEdge.getStreamSpec())
         .collect(Collectors.toList());
   }
 
-  /**
-   * Returns the JSON representation of the plan for visualization
-   * @return json string
-   * @throws Exception
-   */
+  @Override
   public String getPlanAsJson() throws Exception {
     return jsonGenerator.toJson(this);
   }
 
   /**
+   * Returns the config for this application
+   * @return {@link ApplicationConfig}
+   */
+  public ApplicationConfig getApplicationConfig() {
+    return new ApplicationConfig(config);
+  }
+
+  /**
    * Add a source stream to a {@link JobNode}
    * @param input source stream
    * @param node the job node that consumes from the source
    */
   void addSource(StreamSpec input, JobNode node) {
-    StreamEdge edge = getOrCreateEdge(input);
+    StreamEdge edge = getOrCreateStreamEdge(input);
     edge.addTargetNode(node);
     node.addInEdge(edge);
     sources.add(edge);
@@ -110,7 +117,7 @@ import org.slf4j.LoggerFactory;
    * @param node the job node that outputs to the sink
    */
   void addSink(StreamSpec output, JobNode node) {
-    StreamEdge edge = getOrCreateEdge(output);
+    StreamEdge edge = getOrCreateStreamEdge(output);
     edge.addSourceNode(node);
     node.addOutEdge(edge);
     sinks.add(edge);
@@ -123,7 +130,7 @@ import org.slf4j.LoggerFactory;
    * @param to the target node
    */
   void addIntermediateStream(StreamSpec streamSpec, JobNode from, JobNode to) {
-    StreamEdge edge = getOrCreateEdge(streamSpec);
+    StreamEdge edge = getOrCreateStreamEdge(streamSpec);
     edge.addSourceNode(from);
     edge.addTargetNode(to);
     from.addOutEdge(edge);
@@ -137,7 +144,7 @@ import org.slf4j.LoggerFactory;
    * @param jobId id of the job
    * @return
    */
-  JobNode getOrCreateNode(String jobName, String jobId, StreamGraphImpl streamGraph) {
+  JobNode getOrCreateJobNode(String jobName, String jobId, StreamGraphImpl streamGraph) {
     String nodeId = JobNode.createId(jobName, jobId);
     JobNode node = nodes.get(nodeId);
     if (node == null) {
@@ -152,7 +159,7 @@ import org.slf4j.LoggerFactory;
    * @param streamSpec spec of the StreamEdge
    * @return stream edge
    */
-  StreamEdge getOrCreateEdge(StreamSpec streamSpec) {
+  StreamEdge getOrCreateStreamEdge(StreamSpec streamSpec) {
     String streamId = streamSpec.getId();
     StreamEdge edge = edges.get(streamId);
     if (edge == null) {

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/execution/JobGraphJsonGenerator.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/execution/JobGraphJsonGenerator.java b/samza-core/src/main/java/org/apache/samza/execution/JobGraphJsonGenerator.java
index 317616c..96c0538 100644
--- a/samza-core/src/main/java/org/apache/samza/execution/JobGraphJsonGenerator.java
+++ b/samza-core/src/main/java/org/apache/samza/execution/JobGraphJsonGenerator.java
@@ -19,95 +19,99 @@
 
 package org.apache.samza.execution;
 
+import com.google.common.base.Joiner;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
 import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import org.apache.samza.config.ApplicationConfig;
 import org.apache.samza.operators.MessageStream;
 import org.apache.samza.operators.MessageStreamImpl;
 import org.apache.samza.operators.spec.OperatorSpec;
-import org.apache.samza.operators.spec.PartialJoinOperatorSpec;
-import org.apache.samza.operators.spec.SinkOperatorSpec;
+import org.apache.samza.operators.util.OperatorJsonUtils;
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.codehaus.jackson.map.ObjectMapper;
 
+
 /**
  * This class generates the JSON representation of the {@link JobGraph}.
  */
-public class JobGraphJsonGenerator {
-
-  /**
-   * This class provides the necessary connection of operators for traversal.
-   */
-  static abstract class Traversable {
-    @JsonProperty("NextOperatorIds")
-    Set<Integer>  nextOperatorIds = new HashSet<>();
-  }
-
-  static final class OperatorJson extends Traversable {
-    @JsonProperty("OpCode")
-    String opCode;
-    @JsonProperty("OpId")
-    int opId;
-    @JsonProperty("OutputStreamId")
-    String outputStreamId;
-    @JsonProperty("PairedOpId")
-    int pairedOpId = -1;  //for join operator, we will have a pair nodes for two partial joins
-  }
+/* package private */ class JobGraphJsonGenerator {
 
   static final class StreamSpecJson {
-    @JsonProperty("Id")
+    @JsonProperty("id")
     String id;
-    @JsonProperty("SystemName")
+    @JsonProperty("systemName")
     String systemName;
-    @JsonProperty("PhysicalName")
+    @JsonProperty("physicalName")
     String physicalName;
-    @JsonProperty("PartitionCount")
+    @JsonProperty("partitionCount")
     int partitionCount;
   }
 
   static final class StreamEdgeJson {
-    @JsonProperty("StreamSpec")
+    @JsonProperty("streamSpec")
     StreamSpecJson streamSpec;
+    @JsonProperty("sourceJobs")
+    List<String> sourceJobs;
+    @JsonProperty("targetJobs")
+    List<String> targetJobs;
   }
 
   static final class OperatorGraphJson {
-    @JsonProperty("InputStreams")
-    List<InputStreamJson> inputStreams;
-    @JsonProperty("Operators")
-    Map<Integer, OperatorJson> operators = new HashMap<>();
+    @JsonProperty("inputStreams")
+    List<StreamJson> inputStreams;
+    @JsonProperty("outputStreams")
+    List<StreamJson> outputStreams;
+    @JsonProperty("operators")
+    Map<Integer, Map<String, Object>> operators = new HashMap<>();
+    @JsonProperty("canonicalOpIds")
+    Map<Integer, String> canonicalOpIds = new HashMap<>();
   }
 
-  static final class InputStreamJson extends Traversable {
-    @JsonProperty("StreamId")
+  static final class StreamJson {
+    @JsonProperty("streamId")
     String streamId;
+    @JsonProperty("nextOperatorIds")
+    Set<Integer>  nextOperatorIds = new HashSet<>();
   }
 
   static final class JobNodeJson {
-    @JsonProperty("JobName")
+    @JsonProperty("jobName")
     String jobName;
-    @JsonProperty("JobId")
+    @JsonProperty("jobId")
     String jobId;
-    @JsonProperty("OperatorGraph")
+    @JsonProperty("operatorGraph")
     OperatorGraphJson operatorGraph;
   }
 
   static final class JobGraphJson {
-    @JsonProperty("Jobs")
+    @JsonProperty("jobs")
     List<JobNodeJson> jobs;
-    @JsonProperty("Streams")
-    Map<String, StreamEdgeJson> streams;
+    @JsonProperty("sourceStreams")
+    Map<String, StreamEdgeJson> sourceStreams;
+    @JsonProperty("sinkStreams")
+    Map<String, StreamEdgeJson> sinkStreams;
+    @JsonProperty("intermediateStreams")
+    Map<String, StreamEdgeJson> intermediateStreams;
+    @JsonProperty("applicationName")
+    String applicationName;
+    @JsonProperty("applicationId")
+    String applicationId;
   }
 
-  // Mapping from the output stream to the join spec. Since StreamGraph creates two partial join operators for a join and they
-  // will have the same output stream, this mapping is used to choose one of them as the unique join spec representing this join
-  // (who register first in the map wins).
-  Map<MessageStream, OperatorSpec> outputStreamToJoinSpec = new HashMap<>();
+  // Mapping from the output stream to the ids.
+  // Logically they belong to the same operator, but in code we generate one operator for each input.
+  // This is to associate the operators that output to the same MessageStream.
+  Multimap<MessageStream, Integer> outputStreamToOpIds = HashMultimap.create();
 
   /**
    * Returns the JSON representation of a {@link JobGraph}
@@ -119,13 +123,18 @@ public class JobGraphJsonGenerator {
     JobGraphJson jobGraphJson = new JobGraphJson();
 
     // build StreamEdge JSON
-    jobGraphJson.streams = new HashMap<>();
-    jobGraph.getSources().forEach(e -> getOrCreateStreamEdgeJson(e, jobGraphJson.streams));
-    jobGraph.getSinks().forEach(e -> getOrCreateStreamEdgeJson(e, jobGraphJson.streams));
-    jobGraph.getIntermediateStreamEdges().forEach(e -> getOrCreateStreamEdgeJson(e, jobGraphJson.streams));
+    ApplicationConfig appConfig = jobGraph.getApplicationConfig();
+    jobGraphJson.applicationName = appConfig.getAppName();
+    jobGraphJson.applicationId = appConfig.getAppId();
+    jobGraphJson.sourceStreams = new HashMap<>();
+    jobGraphJson.sinkStreams = new HashMap<>();
+    jobGraphJson.intermediateStreams = new HashMap<>();
+    jobGraph.getSources().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sourceStreams));
+    jobGraph.getSinks().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sinkStreams));
+    jobGraph.getIntermediateStreamEdges().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.intermediateStreams));
 
     jobGraphJson.jobs = jobGraph.getJobNodes().stream()
-        .map(jobNode -> buildJobNodeJson(jobNode, jobGraphJson.streams))
+        .map(jobNode -> buildJobNodeJson(jobNode))
         .collect(Collectors.toList());
 
     ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -137,10 +146,9 @@ public class JobGraphJsonGenerator {
   /**
    * Create JSON POJO for a {@link JobNode}, including the {@link org.apache.samza.operators.StreamGraph} for this job
    * @param jobNode job node in the {@link JobGraph}
-   * @param streamEdges map of {@link org.apache.samza.execution.JobGraphJsonGenerator.StreamEdgeJson}
    * @return {@link org.apache.samza.execution.JobGraphJsonGenerator.JobNodeJson}
    */
-  private JobNodeJson buildJobNodeJson(JobNode jobNode, Map<String, StreamEdgeJson> streamEdges) {
+  private JobNodeJson buildJobNodeJson(JobNode jobNode) {
     JobNodeJson job = new JobNodeJson();
     job.jobName = jobNode.getJobName();
     job.jobId = jobNode.getJobId();
@@ -157,10 +165,27 @@ public class JobGraphJsonGenerator {
     OperatorGraphJson opGraph = new OperatorGraphJson();
     opGraph.inputStreams = new ArrayList<>();
     jobNode.getStreamGraph().getInputStreams().forEach((streamSpec, stream) -> {
-        InputStreamJson inputJson = new InputStreamJson();
-        inputJson.streamId = streamSpec.getId();
+        StreamJson inputJson = new StreamJson();
         opGraph.inputStreams.add(inputJson);
-        updateOperatorGraphJson((MessageStreamImpl) stream, inputJson, opGraph);
+        inputJson.streamId = streamSpec.getId();
+        Collection<OperatorSpec> specs = ((MessageStreamImpl) stream).getRegisteredOperatorSpecs();
+        inputJson.nextOperatorIds = specs.stream().map(OperatorSpec::getOpId).collect(Collectors.toSet());
+
+        updateOperatorGraphJson((MessageStreamImpl) stream, opGraph);
+
+        for (Map.Entry<MessageStream, Collection<Integer>> entry : outputStreamToOpIds.asMap().entrySet()) {
+          List<Integer> sortedIds = new ArrayList<>(entry.getValue());
+          Collections.sort(sortedIds);
+          String canonicalId = Joiner.on(',').join(sortedIds);
+          sortedIds.stream().forEach(id -> opGraph.canonicalOpIds.put(id, canonicalId));
+        }
+      });
+
+    opGraph.outputStreams = new ArrayList<>();
+    jobNode.getStreamGraph().getOutputStreams().keySet().forEach(streamSpec -> {
+        StreamJson outputJson = new StreamJson();
+        outputJson.streamId = streamSpec.getId();
+        opGraph.outputStreams.add(outputJson);
       });
     return opGraph;
   }
@@ -168,65 +193,30 @@ public class JobGraphJsonGenerator {
   /**
    * Traverse the {@StreamGraph} recursively and update the operator graph JSON POJO.
    * @param messageStream input
-   * @param parent parent node in the traveral
    * @param opGraph operator graph to build
    */
-  private void updateOperatorGraphJson(MessageStreamImpl messageStream, Traversable parent, OperatorGraphJson opGraph) {
+  private void updateOperatorGraphJson(MessageStreamImpl messageStream, OperatorGraphJson opGraph) {
     Collection<OperatorSpec> specs = messageStream.getRegisteredOperatorSpecs();
     specs.forEach(opSpec -> {
-        parent.nextOperatorIds.add(opSpec.getOpId());
+        opGraph.operators.put(opSpec.getOpId(), OperatorJsonUtils.operatorToMap(opSpec));
 
-        OperatorJson opJson = getOrCreateOperatorJson(opSpec, opGraph);
-        if (opSpec instanceof SinkOperatorSpec) {
-          opJson.outputStreamId = ((SinkOperatorSpec) opSpec).getOutputStream().getStreamSpec().getId();
-        } else if (opSpec.getNextStream() != null) {
-          updateOperatorGraphJson(opSpec.getNextStream(), opJson, opGraph);
+        if (opSpec.getOpCode() == OperatorSpec.OpCode.JOIN || opSpec.getOpCode() == OperatorSpec.OpCode.MERGE) {
+          outputStreamToOpIds.put(opSpec.getNextStream(), opSpec.getOpId());
         }
-      });
-  }
-
-  /**
-   * Get or create the JSON POJO for an operator.
-   * @param opSpec {@link OperatorSpec}
-   * @param opGraph {@link org.apache.samza.execution.JobGraphJsonGenerator.OperatorGraphJson}
-   * @return {@link org.apache.samza.execution.JobGraphJsonGenerator.OperatorJson}
-   */
-  private OperatorJson getOrCreateOperatorJson(OperatorSpec opSpec, OperatorGraphJson opGraph) {
-    Map<Integer, OperatorJson> operators = opGraph.operators;
-    OperatorJson opJson = operators.get(opSpec.getOpId());
-    if (opJson == null) {
-      opJson = new OperatorJson();
-      opJson.opCode = opSpec.getOpCode().name();
-      opJson.opId = opSpec.getOpId();
-      operators.put(opSpec.getOpId(), opJson);
-    }
 
-    if (opSpec instanceof PartialJoinOperatorSpec) {
-      // every join will have two partial join operators
-      // we will choose one of them in order to consolidate the inputs
-      // the first one who registered with the outputStreamToJoinSpec will win
-      MessageStream output = opSpec.getNextStream();
-      OperatorSpec joinSpec = outputStreamToJoinSpec.get(output);
-      if (joinSpec == null) {
-        joinSpec = opSpec;
-        outputStreamToJoinSpec.put(output, joinSpec);
-      } else if (joinSpec != opSpec) {
-        OperatorJson joinNode = operators.get(joinSpec.getOpId());
-        joinNode.pairedOpId = opJson.opId;
-        opJson.pairedOpId = joinNode.opId;
-      }
-    }
-
-    return opJson;
+        if (opSpec.getNextStream() != null) {
+          updateOperatorGraphJson(opSpec.getNextStream(), opGraph);
+        }
+      });
   }
 
   /**
    * Get or create the JSON POJO for a {@link StreamEdge}
    * @param edge {@link StreamEdge}
    * @param streamEdges map of streamId to {@link org.apache.samza.execution.JobGraphJsonGenerator.StreamEdgeJson}
-   * @return {@link org.apache.samza.execution.JobGraphJsonGenerator.StreamEdgeJson}
+   * @return JSON representation of the {@link StreamEdge}
    */
-  private StreamEdgeJson getOrCreateStreamEdgeJson(StreamEdge edge, Map<String, StreamEdgeJson> streamEdges) {
+  private StreamEdgeJson buildStreamEdgeJson(StreamEdge edge, Map<String, StreamEdgeJson> streamEdges) {
     String streamId = edge.getStreamSpec().getId();
     StreamEdgeJson edgeJson = streamEdges.get(streamId);
     if (edgeJson == null) {
@@ -237,6 +227,19 @@ public class JobGraphJsonGenerator {
       streamSpecJson.physicalName = edge.getStreamSpec().getPhysicalName();
       streamSpecJson.partitionCount = edge.getPartitionCount();
       edgeJson.streamSpec = streamSpecJson;
+
+      List<String> sourceJobs = new ArrayList<>();
+      edge.getSourceNodes().forEach(jobNode -> {
+          sourceJobs.add(jobNode.getJobName());
+        });
+      edgeJson.sourceJobs = sourceJobs;
+
+      List<String> targetJobs = new ArrayList<>();
+      edge.getTargetNodes().forEach(jobNode -> {
+          targetJobs.add(jobNode.getJobName());
+        });
+      edgeJson.targetJobs = targetJobs;
+
       streamEdges.put(streamId, edgeJson);
     }
     return edgeJson;

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/execution/JobNode.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/execution/JobNode.java b/samza-core/src/main/java/org/apache/samza/execution/JobNode.java
index e19c9ca..0484cf9 100644
--- a/samza-core/src/main/java/org/apache/samza/execution/JobNode.java
+++ b/samza-core/src/main/java/org/apache/samza/execution/JobNode.java
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
 public class JobNode {
   private static final Logger log = LoggerFactory.getLogger(JobNode.class);
   private static final String CONFIG_JOB_PREFIX = "jobs.%s.";
+  private static final String CONFIG_INTERNAL_EXECUTION_PLAN = "samza.internal.execution.plan";
 
   private final String jobName;
   private final String jobId;
@@ -92,7 +93,12 @@ public class JobNode {
     return outEdges;
   }
 
-  public JobConfig generateConfig() {
+  /**
+   * Generate the configs for a job
+   * @param executionPlanJson JSON representation of the execution plan
+   * @return config of the job
+   */
+  public JobConfig generateConfig(String executionPlanJson) {
     Map<String, String> configs = new HashMap<>();
     configs.put(JobConfig.JOB_NAME(), jobName);
 
@@ -100,6 +106,8 @@ public class JobNode {
     configs.put(TaskConfig.INPUT_STREAMS(), Joiner.on(',').join(inputs));
     log.info("Job {} has generated configs {}", jobName, configs);
 
+    configs.put(CONFIG_INTERNAL_EXECUTION_PLAN, executionPlanJson);
+
     String configPrefix = String.format(CONFIG_JOB_PREFIX, jobName);
     // TODO: Disallow user specifying job inputs/outputs. This info comes strictly from the pipeline.
     return new JobConfig(Util.rewriteConfig(extractScopedConfig(config, new MapConfig(configs), configPrefix)));

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/MessageStreamImpl.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/MessageStreamImpl.java b/samza-core/src/main/java/org/apache/samza/operators/MessageStreamImpl.java
index 69a41db..b9adeed 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/MessageStreamImpl.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/MessageStreamImpl.java
@@ -81,16 +81,16 @@ public class MessageStreamImpl<M> implements MessageStream<M> {
 
   @Override
   public MessageStream<M> filter(FilterFunction<? super M> filterFn) {
-    OperatorSpec<M> op = OperatorSpecs.createFilterOperatorSpec(
-        filterFn, new MessageStreamImpl<>(this.graph), this.graph.getNextOpId());
+    OperatorSpec<M> op = OperatorSpecs.createFilterOperatorSpec(filterFn, new MessageStreamImpl<>(this.graph),
+        this.graph.getNextOpId());
     this.registeredOperatorSpecs.add(op);
     return op.getNextStream();
   }
 
   @Override
   public <TM> MessageStream<TM> flatMap(FlatMapFunction<? super M, ? extends TM> flatMapFn) {
-    OperatorSpec<TM> op = OperatorSpecs.createStreamOperatorSpec(
-        flatMapFn, new MessageStreamImpl<>(this.graph), this.graph.getNextOpId());
+    OperatorSpec<TM> op = OperatorSpecs.createStreamOperatorSpec(flatMapFn, new MessageStreamImpl<>(this.graph),
+        this.graph.getNextOpId());
     this.registeredOperatorSpecs.add(op);
     return op.getNextStream();
   }
@@ -103,15 +103,15 @@ public class MessageStreamImpl<M> implements MessageStream<M> {
 
   @Override
   public <K, V> void sendTo(OutputStream<K, V, M> outputStream) {
-    SinkOperatorSpec<M> op = OperatorSpecs.createSendToOperatorSpec(
-        (OutputStreamInternal<K, V, M>) outputStream, this.graph.getNextOpId());
+    SinkOperatorSpec<M> op = OperatorSpecs.createSendToOperatorSpec((OutputStreamInternal<K, V, M>) outputStream,
+        this.graph.getNextOpId());
     this.registeredOperatorSpecs.add(op);
   }
 
   @Override
   public <K, WV> MessageStream<WindowPane<K, WV>> window(Window<M, K, WV> window) {
-    OperatorSpec<WindowPane<K, WV>> wndOp = OperatorSpecs.createWindowOperatorSpec(
-        (WindowInternal<M, K, WV>) window, new MessageStreamImpl<>(this.graph), this.graph.getNextOpId());
+    OperatorSpec<WindowPane<K, WV>> wndOp = OperatorSpecs.createWindowOperatorSpec((WindowInternal<M, K, WV>) window,
+        new MessageStreamImpl<>(this.graph), this.graph.getNextOpId());
     this.registeredOperatorSpecs.add(wndOp);
     return wndOp.getNextStream();
   }
@@ -175,9 +175,9 @@ public class MessageStreamImpl<M> implements MessageStream<M> {
     this.registeredOperatorSpecs.add(OperatorSpecs.createPartialJoinOperatorSpec(
         thisPartialJoinFn, otherPartialJoinFn, ttl.toMillis(), nextStream, this.graph.getNextOpId()));
 
-    ((MessageStreamImpl<OM>) otherStream).registeredOperatorSpecs
-        .add(OperatorSpecs.createPartialJoinOperatorSpec(
-            otherPartialJoinFn, thisPartialJoinFn, ttl.toMillis(), nextStream, this.graph.getNextOpId()));
+    ((MessageStreamImpl<OM>) otherStream).registeredOperatorSpecs.add(OperatorSpecs
+        .createPartialJoinOperatorSpec(otherPartialJoinFn, thisPartialJoinFn, ttl.toMillis(), nextStream,
+            this.graph.getNextOpId()));
 
     return nextStream;
   }
@@ -187,8 +187,11 @@ public class MessageStreamImpl<M> implements MessageStream<M> {
     MessageStreamImpl<M> nextStream = new MessageStreamImpl<>(this.graph);
 
     otherStreams.add(this);
-    otherStreams.forEach(other -> ((MessageStreamImpl<M>) other).registeredOperatorSpecs.
-        add(OperatorSpecs.createMergeOperatorSpec(nextStream, this.graph.getNextOpId())));
+    otherStreams.forEach(other -> {
+        OperatorSpec mergeOperatorSepc =
+            OperatorSpecs.createMergeOperatorSpec(nextStream, this.graph.getNextOpId());
+        ((MessageStreamImpl<M>) other).registeredOperatorSpecs.add(mergeOperatorSepc);
+      });
     return nextStream;
   }
 
@@ -213,5 +216,4 @@ public class MessageStreamImpl<M> implements MessageStream<M> {
   public Collection<OperatorSpec> getRegisteredOperatorSpecs() {
     return Collections.unmodifiableSet(this.registeredOperatorSpecs);
   }
-
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/impl/RootOperatorImpl.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/impl/RootOperatorImpl.java b/samza-core/src/main/java/org/apache/samza/operators/impl/RootOperatorImpl.java
index 0f18e97..059b567 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/impl/RootOperatorImpl.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/impl/RootOperatorImpl.java
@@ -62,6 +62,11 @@ public final class RootOperatorImpl<M> extends OperatorImpl<M, M> {
       public int getOpId() {
         return -1;
       }
+
+      @Override
+      public String getSourceLocation() {
+        return "";
+      }
     };
   }
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/spec/OperatorSpec.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/spec/OperatorSpec.java b/samza-core/src/main/java/org/apache/samza/operators/spec/OperatorSpec.java
index cc3c4ab..3ea52ca 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/spec/OperatorSpec.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/spec/OperatorSpec.java
@@ -63,6 +63,12 @@ public interface OperatorSpec<OM> {
   int getOpId();
 
   /**
+   * Return the user source code location that creates the operator
+   * @return source location
+   */
+  String getSourceLocation();
+
+  /**
    * Get the name for this operator based on its opCode and opId.
    * @return  the name for this operator
    */

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/spec/PartialJoinOperatorSpec.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/spec/PartialJoinOperatorSpec.java b/samza-core/src/main/java/org/apache/samza/operators/spec/PartialJoinOperatorSpec.java
index e85626f..92b4170 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/spec/PartialJoinOperatorSpec.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/spec/PartialJoinOperatorSpec.java
@@ -20,6 +20,7 @@ package org.apache.samza.operators.spec;
 
 import org.apache.samza.operators.MessageStreamImpl;
 import org.apache.samza.operators.functions.PartialJoinFunction;
+import org.apache.samza.operators.util.OperatorJsonUtils;
 
 
 /**
@@ -38,6 +39,7 @@ public class PartialJoinOperatorSpec<K, M, JM, RM> implements OperatorSpec<RM> {
   private final long ttlMs;
   private final MessageStreamImpl<RM> nextStream;
   private final int opId;
+  private final String sourceLocation;
 
   /**
    * Default constructor for a {@link PartialJoinOperatorSpec}.
@@ -58,6 +60,7 @@ public class PartialJoinOperatorSpec<K, M, JM, RM> implements OperatorSpec<RM> {
     this.ttlMs = ttlMs;
     this.nextStream = nextStream;
     this.opId = opId;
+    this.sourceLocation = OperatorJsonUtils.getSourceLocation();
   }
 
   @Override
@@ -86,4 +89,9 @@ public class PartialJoinOperatorSpec<K, M, JM, RM> implements OperatorSpec<RM> {
   public int getOpId() {
     return this.opId;
   }
+
+  @Override
+  public String getSourceLocation() {
+    return sourceLocation;
+  }
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/spec/SinkOperatorSpec.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/spec/SinkOperatorSpec.java b/samza-core/src/main/java/org/apache/samza/operators/spec/SinkOperatorSpec.java
index 0d135d3..afdd6b9 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/spec/SinkOperatorSpec.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/spec/SinkOperatorSpec.java
@@ -21,6 +21,7 @@ package org.apache.samza.operators.spec;
 import org.apache.samza.operators.MessageStreamImpl;
 import org.apache.samza.operators.functions.SinkFunction;
 import org.apache.samza.operators.stream.OutputStreamInternal;
+import org.apache.samza.operators.util.OperatorJsonUtils;
 import org.apache.samza.system.OutgoingMessageEnvelope;
 import org.apache.samza.system.SystemStream;
 import org.apache.samza.task.MessageCollector;
@@ -39,6 +40,7 @@ public class SinkOperatorSpec<M> implements OperatorSpec {
   private OutputStreamInternal<?, ?, M> outputStream; // may be null
   private final OperatorSpec.OpCode opCode;
   private final int opId;
+  private final String sourceLocation;
 
   /**
    * Constructs a {@link SinkOperatorSpec} with a user defined {@link SinkFunction}.
@@ -54,6 +56,7 @@ public class SinkOperatorSpec<M> implements OperatorSpec {
     this.sinkFn = sinkFn;
     this.opCode = opCode;
     this.opId = opId;
+    this.sourceLocation = OperatorJsonUtils.getSourceLocation();
   }
 
   /**
@@ -99,6 +102,11 @@ public class SinkOperatorSpec<M> implements OperatorSpec {
     return this.opId;
   }
 
+  @Override
+  public String getSourceLocation() {
+    return sourceLocation;
+  }
+
   /**
    * Creates a {@link SinkFunction} to send messages to the provided {@code output}.
    * @param outputStream  the {@link OutputStreamInternal} to send messages to

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/spec/StreamOperatorSpec.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/spec/StreamOperatorSpec.java b/samza-core/src/main/java/org/apache/samza/operators/spec/StreamOperatorSpec.java
index 204e566..c53efae 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/spec/StreamOperatorSpec.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/spec/StreamOperatorSpec.java
@@ -20,6 +20,7 @@ package org.apache.samza.operators.spec;
 
 import org.apache.samza.operators.MessageStreamImpl;
 import org.apache.samza.operators.functions.FlatMapFunction;
+import org.apache.samza.operators.util.OperatorJsonUtils;
 
 
 /**
@@ -34,6 +35,7 @@ public class StreamOperatorSpec<M, OM> implements OperatorSpec<OM> {
   private final MessageStreamImpl<OM> nextStream;
   private final OperatorSpec.OpCode opCode;
   private final int opId;
+  private final String sourceLocation;
 
   /**
    * Constructor for a {@link StreamOperatorSpec} that accepts an output {@link MessageStreamImpl}.
@@ -49,6 +51,7 @@ public class StreamOperatorSpec<M, OM> implements OperatorSpec<OM> {
     this.nextStream = nextStream;
     this.opCode = opCode;
     this.opId = opId;
+    this.sourceLocation = OperatorJsonUtils.getSourceLocation();
   }
 
   @Override
@@ -69,4 +72,9 @@ public class StreamOperatorSpec<M, OM> implements OperatorSpec<OM> {
   public int getOpId() {
     return this.opId;
   }
+
+  @Override
+  public String getSourceLocation() {
+    return sourceLocation;
+  }
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/spec/WindowOperatorSpec.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/spec/WindowOperatorSpec.java b/samza-core/src/main/java/org/apache/samza/operators/spec/WindowOperatorSpec.java
index 73b17b5..7ea07f6 100644
--- a/samza-core/src/main/java/org/apache/samza/operators/spec/WindowOperatorSpec.java
+++ b/samza-core/src/main/java/org/apache/samza/operators/spec/WindowOperatorSpec.java
@@ -20,6 +20,7 @@
 package org.apache.samza.operators.spec;
 
 import org.apache.samza.operators.MessageStreamImpl;
+import org.apache.samza.operators.util.OperatorJsonUtils;
 import org.apache.samza.operators.windows.WindowPane;
 import org.apache.samza.operators.windows.internal.WindowInternal;
 
@@ -36,6 +37,7 @@ public class WindowOperatorSpec<M, WK, WV> implements OperatorSpec<WindowPane<WK
   private final WindowInternal<M, WK, WV> window;
   private final MessageStreamImpl<WindowPane<WK, WV>> nextStream;
   private final int opId;
+  private final String sourceLocation;
 
   /**
    * Constructor for {@link WindowOperatorSpec}.
@@ -48,6 +50,7 @@ public class WindowOperatorSpec<M, WK, WV> implements OperatorSpec<WindowPane<WK
     this.nextStream = nextStream;
     this.window = window;
     this.opId = opId;
+    this.sourceLocation = OperatorJsonUtils.getSourceLocation();
   }
 
   @Override
@@ -68,4 +71,9 @@ public class WindowOperatorSpec<M, WK, WV> implements OperatorSpec<WindowPane<WK
   public int getOpId() {
     return this.opId;
   }
+
+  @Override
+  public String getSourceLocation() {
+    return sourceLocation;
+  }
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/operators/util/OperatorJsonUtils.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/operators/util/OperatorJsonUtils.java b/samza-core/src/main/java/org/apache/samza/operators/util/OperatorJsonUtils.java
new file mode 100644
index 0000000..b52fbc3
--- /dev/null
+++ b/samza-core/src/main/java/org/apache/samza/operators/util/OperatorJsonUtils.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.samza.operators.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.samza.operators.spec.OperatorSpec;
+import org.apache.samza.operators.spec.PartialJoinOperatorSpec;
+import org.apache.samza.operators.spec.SinkOperatorSpec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OperatorJsonUtils {
+  private static final Logger log = LoggerFactory.getLogger(OperatorJsonUtils.class);
+
+  private static final String OP_CODE = "opCode";
+  private static final String OP_ID = "opId";
+  private static final String SOURCE_LOCATION = "sourceLocation";
+  private static final String NEXT_OPERATOR_IDS = "nextOperatorIds";
+  private static final String OUTPUT_STREAM_ID = "outputStreamId";
+  private static final String TTL_MS = "ttlMs";
+
+  /**
+   * Format the operator properties into a map
+   * @param spec a {@link OperatorSpec} instance
+   * @return map of the operator properties
+   */
+  public static Map<String, Object> operatorToMap(OperatorSpec spec) {
+    Map<String, Object> map = new HashMap<>();
+    map.put(OP_CODE, spec.getOpCode().name());
+    map.put(OP_ID, spec.getOpId());
+    map.put(SOURCE_LOCATION, spec.getSourceLocation());
+
+    if (spec.getNextStream() != null) {
+      Collection<OperatorSpec> nextOperators = spec.getNextStream().getRegisteredOperatorSpecs();
+      map.put(NEXT_OPERATOR_IDS, nextOperators.stream().map(OperatorSpec::getOpId).collect(Collectors.toSet()));
+    } else {
+      map.put(NEXT_OPERATOR_IDS, Collections.emptySet());
+    }
+
+    if (spec instanceof SinkOperatorSpec) {
+      map.put(OUTPUT_STREAM_ID, ((SinkOperatorSpec) spec).getOutputStream().getStreamSpec().getId());
+    }
+
+    if (spec instanceof PartialJoinOperatorSpec) {
+      map.put(TTL_MS, ((PartialJoinOperatorSpec) spec).getTtlMs());
+    }
+
+    return map;
+  }
+
+  /**
+   * Return the location of source code that creates the operator.
+   * This function is invoked in the constructor of each operator.
+   * @return formatted source location including file and line number
+   */
+  public static String getSourceLocation() {
+    // The stack trace looks like:
+    // [0] Thread.getStackTrace()
+    // [1] OperatorJsonUtils.getSourceLocation()
+    // [2] SomeOperator.<init>()
+    // [3] OperatorSpecs.createSomeOperator()
+    // [4] MessageStreamImpl.someOperator()
+    // [5] User code that calls [2]
+    // we are only interested in [5] here
+    StackTraceElement location = Thread.currentThread().getStackTrace()[5];
+    return String.format("%s:%s", location.getFileName(), location.getLineNumber());
+  }
+}

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/runtime/AbstractApplicationRunner.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/runtime/AbstractApplicationRunner.java b/samza-core/src/main/java/org/apache/samza/runtime/AbstractApplicationRunner.java
index 692dc38..3c7c83d 100644
--- a/samza-core/src/main/java/org/apache/samza/runtime/AbstractApplicationRunner.java
+++ b/samza-core/src/main/java/org/apache/samza/runtime/AbstractApplicationRunner.java
@@ -18,22 +18,28 @@
  */
 package org.apache.samza.runtime;
 
+import java.io.File;
+import java.io.PrintWriter;
 import java.util.Map;
 import org.apache.samza.application.StreamApplication;
 import org.apache.samza.config.Config;
 import org.apache.samza.config.JavaSystemConfig;
+import org.apache.samza.config.ShellCommandConfig;
 import org.apache.samza.config.StreamConfig;
 import org.apache.samza.execution.ExecutionPlan;
 import org.apache.samza.execution.ExecutionPlanner;
 import org.apache.samza.execution.StreamManager;
 import org.apache.samza.operators.StreamGraphImpl;
 import org.apache.samza.system.StreamSpec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
  * Defines common, core behavior for implementations of the {@link ApplicationRunner} API
  */
 public abstract class AbstractApplicationRunner extends ApplicationRunner {
+  private static final Logger log = LoggerFactory.getLogger(AbstractApplicationRunner.class);
 
   private final StreamManager streamManager;
   private final ExecutionPlanner planner;
@@ -106,4 +112,25 @@ public abstract class AbstractApplicationRunner extends ApplicationRunner {
   final StreamManager getStreamManager() {
     return streamManager;
   }
+
+  /**
+   * Write the execution plan JSON to a file
+   * @param planJson JSON representation of the plan
+   */
+  final void writePlanJsonFile(String planJson) {
+    try {
+      String content = "plan='" + planJson + "'";
+      String planPath = System.getenv(ShellCommandConfig.EXECUTION_PLAN_DIR());
+      if (planPath != null && !planPath.isEmpty()) {
+        // Write the plan json to plan path
+        File file = new File(planPath + "/plan.json");
+        file.setReadable(true, false);
+        PrintWriter writer = new PrintWriter(file, "UTF-8");
+        writer.println(content);
+        writer.close();
+      }
+    } catch (Exception e) {
+      log.warn("Failed to write execution plan json to file", e);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/runtime/LocalApplicationRunner.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/runtime/LocalApplicationRunner.java b/samza-core/src/main/java/org/apache/samza/runtime/LocalApplicationRunner.java
index 5e83c3c..bff0f1c 100644
--- a/samza-core/src/main/java/org/apache/samza/runtime/LocalApplicationRunner.java
+++ b/samza-core/src/main/java/org/apache/samza/runtime/LocalApplicationRunner.java
@@ -110,6 +110,7 @@ public class LocalApplicationRunner extends AbstractApplicationRunner {
     try {
       // 1. initialize and plan
       ExecutionPlan plan = getExecutionPlan(app);
+      writePlanJsonFile(plan.getPlanAsJson());
 
       // 2. create the necessary streams
       createStreams(plan.getIntermediateStreams());

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/java/org/apache/samza/runtime/RemoteApplicationRunner.java
----------------------------------------------------------------------
diff --git a/samza-core/src/main/java/org/apache/samza/runtime/RemoteApplicationRunner.java b/samza-core/src/main/java/org/apache/samza/runtime/RemoteApplicationRunner.java
index 38eb195..d5f6e21 100644
--- a/samza-core/src/main/java/org/apache/samza/runtime/RemoteApplicationRunner.java
+++ b/samza-core/src/main/java/org/apache/samza/runtime/RemoteApplicationRunner.java
@@ -50,6 +50,7 @@ public class RemoteApplicationRunner extends AbstractApplicationRunner {
     try {
       // 1. initialize and plan
       ExecutionPlan plan = getExecutionPlan(app);
+      writePlanJsonFile(plan.getPlanAsJson());
 
       // 2. create the necessary streams
       getStreamManager().createStreams(plan.getIntermediateStreams());

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/main/scala/org/apache/samza/config/ShellCommandConfig.scala
----------------------------------------------------------------------
diff --git a/samza-core/src/main/scala/org/apache/samza/config/ShellCommandConfig.scala b/samza-core/src/main/scala/org/apache/samza/config/ShellCommandConfig.scala
index 1397ed5..3c0f320 100644
--- a/samza-core/src/main/scala/org/apache/samza/config/ShellCommandConfig.scala
+++ b/samza-core/src/main/scala/org/apache/samza/config/ShellCommandConfig.scala
@@ -53,6 +53,11 @@ object ShellCommandConfig {
    */
   val ENV_LOGGED_STORE_BASE_DIR = "LOGGED_STORE_BASE_DIR"
 
+  /**
+   * The directory path that contains the execution plan
+   */
+  val EXECUTION_PLAN_DIR = "EXECUTION_PLAN_DIR"
+
   val COMMAND_SHELL_EXECUTE = "task.execute"
   val TASK_JVM_OPTS = "task.opts"
   val TASK_JAVA_HOME = "task.java.home"

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/test/java/org/apache/samza/execution/TestExecutionPlanner.java
----------------------------------------------------------------------
diff --git a/samza-core/src/test/java/org/apache/samza/execution/TestExecutionPlanner.java b/samza-core/src/test/java/org/apache/samza/execution/TestExecutionPlanner.java
index b7f952a..5366dc3 100644
--- a/samza-core/src/test/java/org/apache/samza/execution/TestExecutionPlanner.java
+++ b/samza-core/src/test/java/org/apache/samza/execution/TestExecutionPlanner.java
@@ -220,11 +220,11 @@ public class TestExecutionPlanner {
     JobGraph jobGraph = planner.createJobGraph(streamGraph);
 
     ExecutionPlanner.updateExistingPartitions(jobGraph, streamManager);
-    assertTrue(jobGraph.getOrCreateEdge(input1).getPartitionCount() == 64);
-    assertTrue(jobGraph.getOrCreateEdge(input2).getPartitionCount() == 16);
-    assertTrue(jobGraph.getOrCreateEdge(input3).getPartitionCount() == 32);
-    assertTrue(jobGraph.getOrCreateEdge(output1).getPartitionCount() == 8);
-    assertTrue(jobGraph.getOrCreateEdge(output2).getPartitionCount() == 16);
+    assertTrue(jobGraph.getOrCreateStreamEdge(input1).getPartitionCount() == 64);
+    assertTrue(jobGraph.getOrCreateStreamEdge(input2).getPartitionCount() == 16);
+    assertTrue(jobGraph.getOrCreateStreamEdge(input3).getPartitionCount() == 32);
+    assertTrue(jobGraph.getOrCreateStreamEdge(output1).getPartitionCount() == 8);
+    assertTrue(jobGraph.getOrCreateStreamEdge(output2).getPartitionCount() == 16);
 
     jobGraph.getIntermediateStreamEdges().forEach(edge -> {
         assertTrue(edge.getPartitionCount() == -1);
@@ -264,11 +264,10 @@ public class TestExecutionPlanner {
   }
 
   @Test
-  public void testCalculateIntStreamPartitions() {
+  public void testCalculateIntStreamPartitions() throws Exception {
     ExecutionPlanner planner = new ExecutionPlanner(config, streamManager);
     StreamGraphImpl streamGraph = createSimpleGraph();
-    JobGraph jobGraph = planner.createJobGraph(streamGraph);
-    planner.calculatePartitions(streamGraph, jobGraph);
+    JobGraph jobGraph = (JobGraph) planner.plan(streamGraph);
 
     // the partitions should be the same as input1
     jobGraph.getIntermediateStreams().forEach(edge -> {

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/test/java/org/apache/samza/execution/TestJobGraph.java
----------------------------------------------------------------------
diff --git a/samza-core/src/test/java/org/apache/samza/execution/TestJobGraph.java b/samza-core/src/test/java/org/apache/samza/execution/TestJobGraph.java
index 4a4498c..bf131ce 100644
--- a/samza-core/src/test/java/org/apache/samza/execution/TestJobGraph.java
+++ b/samza-core/src/test/java/org/apache/samza/execution/TestJobGraph.java
@@ -59,14 +59,14 @@ public class TestJobGraph {
   private void createGraph1() {
     graph1 = new JobGraph(null);
 
-    JobNode n2 = graph1.getOrCreateNode("2", "1", null);
-    JobNode n3 = graph1.getOrCreateNode("3", "1", null);
-    JobNode n5 = graph1.getOrCreateNode("5", "1", null);
-    JobNode n7 = graph1.getOrCreateNode("7", "1", null);
-    JobNode n8 = graph1.getOrCreateNode("8", "1", null);
-    JobNode n9 = graph1.getOrCreateNode("9", "1", null);
-    JobNode n10 = graph1.getOrCreateNode("10", "1", null);
-    JobNode n11 = graph1.getOrCreateNode("11", "1", null);
+    JobNode n2 = graph1.getOrCreateJobNode("2", "1", null);
+    JobNode n3 = graph1.getOrCreateJobNode("3", "1", null);
+    JobNode n5 = graph1.getOrCreateJobNode("5", "1", null);
+    JobNode n7 = graph1.getOrCreateJobNode("7", "1", null);
+    JobNode n8 = graph1.getOrCreateJobNode("8", "1", null);
+    JobNode n9 = graph1.getOrCreateJobNode("9", "1", null);
+    JobNode n10 = graph1.getOrCreateJobNode("10", "1", null);
+    JobNode n11 = graph1.getOrCreateJobNode("11", "1", null);
 
     graph1.addSource(genStream(), n5);
     graph1.addSource(genStream(), n7);
@@ -92,13 +92,13 @@ public class TestJobGraph {
   private void createGraph2() {
     graph2 = new JobGraph(null);
 
-    JobNode n1 = graph2.getOrCreateNode("1", "1", null);
-    JobNode n2 = graph2.getOrCreateNode("2", "1", null);
-    JobNode n3 = graph2.getOrCreateNode("3", "1", null);
-    JobNode n4 = graph2.getOrCreateNode("4", "1", null);
-    JobNode n5 = graph2.getOrCreateNode("5", "1", null);
-    JobNode n6 = graph2.getOrCreateNode("6", "1", null);
-    JobNode n7 = graph2.getOrCreateNode("7", "1", null);
+    JobNode n1 = graph2.getOrCreateJobNode("1", "1", null);
+    JobNode n2 = graph2.getOrCreateJobNode("2", "1", null);
+    JobNode n3 = graph2.getOrCreateJobNode("3", "1", null);
+    JobNode n4 = graph2.getOrCreateJobNode("4", "1", null);
+    JobNode n5 = graph2.getOrCreateJobNode("5", "1", null);
+    JobNode n6 = graph2.getOrCreateJobNode("6", "1", null);
+    JobNode n7 = graph2.getOrCreateJobNode("7", "1", null);
 
     graph2.addSource(genStream(), n1);
     graph2.addIntermediateStream(genStream(), n1, n2);
@@ -119,8 +119,8 @@ public class TestJobGraph {
   private void createGraph3() {
     graph3 = new JobGraph(null);
 
-    JobNode n1 = graph3.getOrCreateNode("1", "1", null);
-    JobNode n2 = graph3.getOrCreateNode("2", "1", null);
+    JobNode n1 = graph3.getOrCreateJobNode("1", "1", null);
+    JobNode n2 = graph3.getOrCreateJobNode("2", "1", null);
 
     graph3.addSource(genStream(), n1);
     graph3.addIntermediateStream(genStream(), n1, n1);
@@ -135,7 +135,7 @@ public class TestJobGraph {
   private void createGraph4() {
     graph4 = new JobGraph(null);
 
-    JobNode n1 = graph4.getOrCreateNode("1", "1", null);
+    JobNode n1 = graph4.getOrCreateJobNode("1", "1", null);
 
     graph4.addSource(genStream(), n1);
     graph4.addIntermediateStream(genStream(), n1, n1);
@@ -160,9 +160,9 @@ public class TestJobGraph {
      * s3 -> 2
      *   |-> 3
      */
-    JobNode n1 = graph.getOrCreateNode("1", "1", null);
-    JobNode n2 = graph.getOrCreateNode("2", "1", null);
-    JobNode n3 = graph.getOrCreateNode("3", "1", null);
+    JobNode n1 = graph.getOrCreateJobNode("1", "1", null);
+    JobNode n2 = graph.getOrCreateJobNode("2", "1", null);
+    JobNode n3 = graph.getOrCreateJobNode("3", "1", null);
     StreamSpec s1 = genStream();
     StreamSpec s2 = genStream();
     StreamSpec s3 = genStream();
@@ -173,16 +173,16 @@ public class TestJobGraph {
 
     assertTrue(graph.getSources().size() == 3);
 
-    assertTrue(graph.getOrCreateNode("1", "1", null).getInEdges().size() == 2);
-    assertTrue(graph.getOrCreateNode("2", "1", null).getInEdges().size() == 1);
-    assertTrue(graph.getOrCreateNode("3", "1", null).getInEdges().size() == 1);
+    assertTrue(graph.getOrCreateJobNode("1", "1", null).getInEdges().size() == 2);
+    assertTrue(graph.getOrCreateJobNode("2", "1", null).getInEdges().size() == 1);
+    assertTrue(graph.getOrCreateJobNode("3", "1", null).getInEdges().size() == 1);
 
-    assertTrue(graph.getOrCreateEdge(s1).getSourceNodes().size() == 0);
-    assertTrue(graph.getOrCreateEdge(s1).getTargetNodes().size() == 1);
-    assertTrue(graph.getOrCreateEdge(s2).getSourceNodes().size() == 0);
-    assertTrue(graph.getOrCreateEdge(s2).getTargetNodes().size() == 1);
-    assertTrue(graph.getOrCreateEdge(s3).getSourceNodes().size() == 0);
-    assertTrue(graph.getOrCreateEdge(s3).getTargetNodes().size() == 2);
+    assertTrue(graph.getOrCreateStreamEdge(s1).getSourceNodes().size() == 0);
+    assertTrue(graph.getOrCreateStreamEdge(s1).getTargetNodes().size() == 1);
+    assertTrue(graph.getOrCreateStreamEdge(s2).getSourceNodes().size() == 0);
+    assertTrue(graph.getOrCreateStreamEdge(s2).getTargetNodes().size() == 1);
+    assertTrue(graph.getOrCreateStreamEdge(s3).getSourceNodes().size() == 0);
+    assertTrue(graph.getOrCreateStreamEdge(s3).getTargetNodes().size() == 2);
   }
 
   @Test
@@ -193,8 +193,8 @@ public class TestJobGraph {
      * 2 -> s3
      */
     JobGraph graph = new JobGraph(null);
-    JobNode n1 = graph.getOrCreateNode("1", "1", null);
-    JobNode n2 = graph.getOrCreateNode("2", "1", null);
+    JobNode n1 = graph.getOrCreateJobNode("1", "1", null);
+    JobNode n2 = graph.getOrCreateJobNode("2", "1", null);
     StreamSpec s1 = genStream();
     StreamSpec s2 = genStream();
     StreamSpec s3 = genStream();
@@ -203,15 +203,15 @@ public class TestJobGraph {
     graph.addSink(s3, n2);
 
     assertTrue(graph.getSinks().size() == 3);
-    assertTrue(graph.getOrCreateNode("1", "1", null).getOutEdges().size() == 1);
-    assertTrue(graph.getOrCreateNode("2", "1", null).getOutEdges().size() == 2);
-
-    assertTrue(graph.getOrCreateEdge(s1).getSourceNodes().size() == 1);
-    assertTrue(graph.getOrCreateEdge(s1).getTargetNodes().size() == 0);
-    assertTrue(graph.getOrCreateEdge(s2).getSourceNodes().size() == 1);
-    assertTrue(graph.getOrCreateEdge(s2).getTargetNodes().size() == 0);
-    assertTrue(graph.getOrCreateEdge(s3).getSourceNodes().size() == 1);
-    assertTrue(graph.getOrCreateEdge(s3).getTargetNodes().size() == 0);
+    assertTrue(graph.getOrCreateJobNode("1", "1", null).getOutEdges().size() == 1);
+    assertTrue(graph.getOrCreateJobNode("2", "1", null).getOutEdges().size() == 2);
+
+    assertTrue(graph.getOrCreateStreamEdge(s1).getSourceNodes().size() == 1);
+    assertTrue(graph.getOrCreateStreamEdge(s1).getTargetNodes().size() == 0);
+    assertTrue(graph.getOrCreateStreamEdge(s2).getSourceNodes().size() == 1);
+    assertTrue(graph.getOrCreateStreamEdge(s2).getTargetNodes().size() == 0);
+    assertTrue(graph.getOrCreateStreamEdge(s3).getSourceNodes().size() == 1);
+    assertTrue(graph.getOrCreateStreamEdge(s3).getTargetNodes().size() == 0);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/test/java/org/apache/samza/execution/TestJobGraphJsonGenerator.java
----------------------------------------------------------------------
diff --git a/samza-core/src/test/java/org/apache/samza/execution/TestJobGraphJsonGenerator.java b/samza-core/src/test/java/org/apache/samza/execution/TestJobGraphJsonGenerator.java
index c4ab922..2681f9c 100644
--- a/samza-core/src/test/java/org/apache/samza/execution/TestJobGraphJsonGenerator.java
+++ b/samza-core/src/test/java/org/apache/samza/execution/TestJobGraphJsonGenerator.java
@@ -125,6 +125,8 @@ public class TestJobGraphJsonGenerator {
     JobGraphJsonGenerator.JobGraphJson nodes = mapper.readValue(json, JobGraphJsonGenerator.JobGraphJson.class);
     assertTrue(nodes.jobs.get(0).operatorGraph.inputStreams.size() == 5);
     assertTrue(nodes.jobs.get(0).operatorGraph.operators.size() == 12);
-    assertTrue(nodes.streams.size() == 7);
+    assertTrue(nodes.sourceStreams.size() == 3);
+    assertTrue(nodes.sinkStreams.size() == 2);
+    assertTrue(nodes.intermediateStreams.size() == 2);
   }
 }

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/test/java/org/apache/samza/operators/impl/TestOperatorImpl.java
----------------------------------------------------------------------
diff --git a/samza-core/src/test/java/org/apache/samza/operators/impl/TestOperatorImpl.java b/samza-core/src/test/java/org/apache/samza/operators/impl/TestOperatorImpl.java
index bd18f0b..99bf854 100644
--- a/samza-core/src/test/java/org/apache/samza/operators/impl/TestOperatorImpl.java
+++ b/samza-core/src/test/java/org/apache/samza/operators/impl/TestOperatorImpl.java
@@ -217,6 +217,11 @@ public class TestOperatorImpl {
     public int getOpId() {
       return -1;
     }
+
+    @Override
+    public String getSourceLocation() {
+      return "";
+    }
   }
 }
 

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-core/src/test/java/org/apache/samza/operators/spec/TestOperatorSpecs.java
----------------------------------------------------------------------
diff --git a/samza-core/src/test/java/org/apache/samza/operators/spec/TestOperatorSpecs.java b/samza-core/src/test/java/org/apache/samza/operators/spec/TestOperatorSpecs.java
index d227206..cccafaf 100644
--- a/samza-core/src/test/java/org/apache/samza/operators/spec/TestOperatorSpecs.java
+++ b/samza-core/src/test/java/org/apache/samza/operators/spec/TestOperatorSpecs.java
@@ -57,8 +57,8 @@ public class TestOperatorSpecs {
   @Test
   public void testCreateStreamOperator() {
     FlatMapFunction<Object, TestMessageEnvelope> transformFn = m -> new ArrayList<TestMessageEnvelope>() { {
-          this.add(new TestMessageEnvelope(m.toString(), m.toString(), 12345L));
-        } };
+        this.add(new TestMessageEnvelope(m.toString(), m.toString(), 12345L));
+      } };
     MessageStreamImpl<TestMessageEnvelope> mockOutput = mock(MessageStreamImpl.class);
     StreamOperatorSpec<Object, TestMessageEnvelope> streamOp =
         OperatorSpecs.createStreamOperatorSpec(transformFn, mockOutput, 1);
@@ -78,7 +78,7 @@ public class TestOperatorSpecs {
   public void testCreateSinkOperator() {
     SystemStream testStream = new SystemStream("test-sys", "test-stream");
     SinkFunction<TestMessageEnvelope> sinkFn = (TestMessageEnvelope message, MessageCollector messageCollector,
-          TaskCoordinator taskCoordinator) -> {
+        TaskCoordinator taskCoordinator) -> {
       messageCollector.send(new OutgoingMessageEnvelope(testStream, message.getKey(), message.getMessage()));
     };
     SinkOperatorSpec<TestMessageEnvelope> sinkOp = OperatorSpecs.createSinkOperatorSpec(sinkFn, 1);

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-shell/src/main/assembly/src.xml
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/assembly/src.xml b/samza-shell/src/main/assembly/src.xml
index 5173fdf..cc15420 100644
--- a/samza-shell/src/main/assembly/src.xml
+++ b/samza-shell/src/main/assembly/src.xml
@@ -27,5 +27,13 @@
         <include>*</include>
       </includes>
     </fileSet>
+    <fileSet>
+      <outputDirectory>visualizer</outputDirectory>
+      <directory>${basedir}/src/main/visualizer</directory>
+      <fileMode>0644</fileMode>
+      <includes>
+        <include>*</include>
+      </includes>
+    </fileSet>
   </fileSets>
 </assembly>

http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-shell/src/main/bash/run-app.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/run-app.sh b/samza-shell/src/main/bash/run-app.sh
index 3e43463..3880e3c 100644
--- a/samza-shell/src/main/bash/run-app.sh
+++ b/samza-shell/src/main/bash/run-app.sh
@@ -16,6 +16,15 @@
 # specific language governing permissions and limitations
 # under the License.
 
+home_dir=`pwd`
+base_dir=$(dirname $0)/..
+cd $base_dir
+base_dir=`pwd`
+cd $home_dir
+
+export EXECUTION_PLAN_DIR="$base_dir/plan"
+mkdir -p $EXECUTION_PLAN_DIR
+
 [[ $JAVA_OPTS != *-Dlog4j.configuration* ]] && export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$(dirname $0)/log4j-console.xml"
 
 exec $(dirname $0)/run-class.sh org.apache.samza.runtime.ApplicationRunnerMain "$@"


[3/4] samza git commit: SAMZA-1204: Visualize StreamGraph and ExecutionPlan

Posted by xi...@apache.org.
http://git-wip-us.apache.org/repos/asf/samza/blob/b71b253d/samza-shell/src/main/visualizer/js/d3.v3.min.js
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/visualizer/js/d3.v3.min.js b/samza-shell/src/main/visualizer/js/d3.v3.min.js
new file mode 100644
index 0000000..1664873
--- /dev/null
+++ b/samza-shell/src/main/visualizer/js/d3.v3.min.js
@@ -0,0 +1,5 @@
+!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function i(n){return!isNaN(n)}function u(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+="")===bo||n[0]===_o?_o+n:n}function s(n){return(n+="")[0]===_o?n.slice(1):n}function h(n){return f(n)in this._}function p(n){return(n=f(n))in this._&&delete this
 ._[n]}function g(){var n=[];for(var t in this._)n.push(s(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=wo.length;r>e;++e){var i=wo[e]+t;if(i in n)return i}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,i=-1,u=r.length;++i<u;)(t=r[i].on)&&t.apply(this,arguments);return n}var e=[],r=new c;return t.on=function(t,i){var u,o=r.get(t);return arguments.length<2?o&&o.on:(o&&(o.on=null,e=e.slice(0,u=e.indexOf(o)).concat(e.slice(u+1)),r.remove(t)),i&&e.push(r.set(t,{on:i})),n)},t}function S(){ao.event.preventDefault()}function k(){for(var n,t=ao.event;n=t.sourceEvent;)t=n;return t}function N(n){for(var t=new _,e=0,r=arguments.length;++e<r;)t[arguments[e]]=w(t);return t.of
 =function(e,r){return function(i){try{var u=i.sourceEvent=ao.event;i.target=n,ao.event=i,t[i.type].apply(e,r)}finally{ao.event=u}}},t}function E(n){return ko(n,Co),n}function A(n){return"function"==typeof n?n:function(){return No(n,this)}}function C(n){return"function"==typeof n?n:function(){return Eo(n,this)}}function z(n,t){function e(){this.removeAttribute(n)}function r(){this.removeAttributeNS(n.space,n.local)}function i(){this.setAttribute(n,t)}function u(){this.setAttributeNS(n.space,n.local,t)}function o(){var e=t.apply(this,arguments);null==e?this.removeAttribute(n):this.setAttribute(n,e)}function a(){var e=t.apply(this,arguments);null==e?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,e)}return n=ao.ns.qualify(n),null==t?n.local?r:e:"function"==typeof t?n.local?a:o:n.local?u:i}function L(n){return n.trim().replace(/\s+/g," ")}function q(n){return new RegExp("(?:^|\\s+)"+ao.requote(n)+"(?:\\s+|$)","g")}function T(n){return(n+"").trim().split(/^|\s
 +/)}function R(n,t){function e(){for(var e=-1;++e<i;)n[e](this,t)}function r(){for(var e=-1,r=t.apply(this,arguments);++e<i;)n[e](this,r)}n=T(n).map(D);var i=n.length;return"function"==typeof t?r:e}function D(n){var t=q(n);return function(e,r){if(i=e.classList)return r?i.add(n):i.remove(n);var i=e.getAttribute("class")||"";r?(t.lastIndex=0,t.test(i)||e.setAttribute("class",L(i+" "+n))):e.setAttribute("class",L(i.replace(t," ")))}}function P(n,t,e){function r(){this.style.removeProperty(n)}function i(){this.style.setProperty(n,t,e)}function u(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(n):this.style.setProperty(n,r,e)}return null==t?r:"function"==typeof t?u:i}function U(n,t){function e(){delete this[n]}function r(){this[n]=t}function i(){var e=t.apply(this,arguments);null==e?delete this[n]:this[n]=e}return null==t?e:"function"==typeof t?i:r}function j(n){function t(){var t=this.ownerDocument,e=this.namespaceURI;return e===zo&&t.documentElement.namespaceURI===zo?
 t.createElement(n):t.createElementNS(e,n)}function e(){return this.ownerDocument.createElementNS(n.space,n.local)}return"function"==typeof n?n:(n=ao.ns.qualify(n)).local?e:t}function F(){var n=this.parentNode;n&&n.removeChild(this)}function H(n){return{__data__:n}}function O(n){return function(){return Ao(this,n)}}function I(n){return arguments.length||(n=e),function(t,e){return t&&e?n(t.__data__,e.__data__):!t-!e}}function Y(n,t){for(var e=0,r=n.length;r>e;e++)for(var i,u=n[e],o=0,a=u.length;a>o;o++)(i=u[o])&&t(i,o,e);return n}function Z(n){return ko(n,qo),n}function V(n){var t,e;return function(r,i,u){var o,a=n[u].update,l=a.length;for(u!=e&&(e=u,t=0),i>=t&&(t=i+1);!(o=a[t])&&++t<l;);return o}}function X(n,t,e){function r(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}function i(){var i=l(t,co(arguments));r.call(this),this.addEventListener(n,this[o]=i,i.$=e),i._=t}function u(){var t,e=new RegExp("^__on([^.]+)"+ao.requote(n)+"$");for(var r in this)if(t=r.matc
 h(e)){var i=this[r];this.removeEventListener(t[1],i,i.$),delete this[r]}}var o="__on"+n,a=n.indexOf("."),l=$;a>0&&(n=n.slice(0,a));var c=To.get(n);return c&&(n=c,l=B),a?t?i:r:t?b:u}function $(n,t){return function(e){var r=ao.event;ao.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ao.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++Do,i="click"+r,u=ao.select(t(e)).on("touchmove"+r,S).on("dragstart"+r,S).on("selectstart"+r,S);if(null==Ro&&(Ro="onselectstart"in e?!1:x(e.style,"userSelect")),Ro){var o=n(e).style,a=o[Ro];o[Ro]="none"}return function(n){if(u.on(r,null),Ro&&(o[Ro]=a),n){var t=function(){u.on(i,null)};u.on(i,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Po){var u=t(n);if(u.scrollX||u.scrollY){r=ao.select
 ("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Po=!(o.f||o.e),r.remove()}}return Po?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return ao.event.changedTouches[0].identifier}function K(n){return n>0?1:0>n?-1:0}function Q(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function nn(n){return n>1?0:-1>n?Fo:Math.acos(n)}function tn(n){return n>1?Io:-1>n?-Io:Math.asin(n)}function en(n){return((n=Math.exp(n))-1/n)/2}function rn(n){return((n=Math.exp(n))+1/n)/2}function un(n){return((n=Math.exp(2*n))-1)/(n+1)}function on(n){return(n=Math.sin(n/2))*n}function an(){}function ln(n,t,e){return this instanceof ln?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ln?new ln(n.h,n.s,n.l):_n(""+n,wn
 ,ln):new ln(n,t,e)}function cn(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(o-u)*n/60:180>n?o:240>n?u+(o-u)*(240-n)/60:u}function i(n){return Math.round(255*r(n))}var u,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,u=2*e-o,new mn(i(n+120),i(n),i(n-120))}function fn(n,t,e){return this instanceof fn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof fn?new fn(n.h,n.c,n.l):n instanceof hn?gn(n.l,n.a,n.b):gn((n=Sn((n=ao.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new fn(n,t,e)}function sn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new hn(e,Math.cos(n*=Yo)*t,Math.sin(n)*t)}function hn(n,t,e){return this instanceof hn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof hn?new hn(n.l,n.a,n.b):n instanceof fn?sn(n.h,n.c,n.l):Sn((n=mn(n)).r,n.g,n.b):new hn(n,t,e)}function pn(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=vn(i)*na,r=vn(r)*ta,u=vn(u)*ea,new mn(yn(3.2404542*i-1.53713
 85*r-.4985314*u),yn(-.969266*i+1.8760108*r+.041556*u),yn(.0556434*i-.2040259*r+1.0572252*u))}function gn(n,t,e){return n>0?new fn(Math.atan2(e,t)*Zo,Math.sqrt(t*t+e*e),n):new fn(NaN,NaN,n)}function vn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function dn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function yn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function mn(n,t,e){return this instanceof mn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof mn?new mn(n.r,n.g,n.b):_n(""+n,mn,cn):new mn(n,t,e)}function Mn(n){return new mn(n>>16,n>>8&255,255&n)}function xn(n){return Mn(n)+""}function bn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function _n(n,t,e){var r,i,u,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(Nn(i[0]),Nn(i[1]),Nn(i[2]))}return(u=ua.g
 et(n))?t(u.r,u.g,u.b):(null==n||"#"!==n.charAt(0)||isNaN(u=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&u)>>4,o=o>>4|o,a=240&u,a=a>>4|a,l=15&u,l=l<<4|l):7===n.length&&(o=(16711680&u)>>16,a=(65280&u)>>8,l=255&u)),t(o,a,l))}function wn(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-u,l=(o+u)/2;return a?(i=.5>l?a/(o+u):a/(2-o-u),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=NaN,i=l>0&&1>l?0:r),new ln(r,i,l)}function Sn(n,t,e){n=kn(n),t=kn(t),e=kn(e);var r=dn((.4124564*n+.3575761*t+.1804375*e)/na),i=dn((.2126729*n+.7151522*t+.072175*e)/ta),u=dn((.0193339*n+.119192*t+.9503041*e)/ea);return hn(116*i-16,500*(r-i),200*(i-u))}function kn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Nn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function En(n){return"function"==typeof n?n:function(){return n}}function An(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),
 Cn(t,e,n,r)}}function Cn(n,t,e,r){function i(){var n,t=l.status;if(!t&&Ln(l)||t>=200&&300>t||304===t){try{n=e.call(u,l)}catch(r){return void o.error.call(u,r)}o.load.call(u,n)}else o.error.call(u,l)}var u={},o=ao.dispatch("beforesend","progress","load","error"),a={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(n){var t=ao.event;ao.event=n;try{o.progress.call(u,l)}finally{ao.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.responseType=function(n){return arguments.length?(c=n,u):c},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(co(arguments)))}}),u.send=function(e,r,i){if(
 2===arguments.length&&"function"==typeof r&&(i=r,r=null),l.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),l.setRequestHeader)for(var f in a)l.setRequestHeader(f,a[f]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),o.beforesend.call(u,l),l.send(null==r?null:r),u},u.abort=function(){return l.abort(),u},ao.rebind(u,o,"on"),null==r?u:u.get(zn(r))}function zn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function Ln(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var i=e+t,u={c:n,t:i,n:null};return aa?aa.n=u:oa=u,aa=u,la||(ca=clearTimeout(ca),la=1,fa(Tn)),u}function Tn(){var n=Rn(),t=Dn()-n;t>24?(isFinite(t)&&(clearTimeout(ca),ca=setTimeout(Tn,t)),la=0):(la=1,fa(Tn))}function Rn(){for(var n=Date.now(),t=oa;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Dn(){for(var 
 n,t=oa,e=1/0;t;)t.c?(t.t<e&&(e=t.t),t=(n=t).n):t=n?n.n=t.n:oa=t.n;return aa=n,e}function Pn(n,t){return t-(n?Math.ceil(Math.log(n)/Math.LN10):1)}function Un(n,t){var e=Math.pow(10,3*xo(8-t));return{scale:t>8?function(n){return n/e}:function(n){return n*e},symbol:n}}function jn(n){var t=n.decimal,e=n.thousands,r=n.grouping,i=n.currency,u=r&&e?function(n,t){for(var i=n.length,u=[],o=0,a=r[0],l=0;i>0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),u.push(n.substring(i-=a,i+a)),!((l+=a+1)>t));)a=r[o=(o+1)%r.length];return u.reverse().join(e)}:m;return function(n){var e=ha.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",l=e[4]||"",c=e[5],f=+e[6],s=e[7],h=e[8],p=e[9],g=1,v="",d="",y=!1,m=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===o)&&(c=r="0",o="="),p){case"n":s=!0,p="g";break;case"%":g=100,d="%",p="f";break;case"p":g=100,d="%",p="r";break;case"b":case"o":case"x":case"X":"#"===l&&(v="0"+p.toLowerCase());case"c":m=!1;case"d":y=!0,h=0;break;case"s":g=-1,p="r"}"$"===l&&(v=i[0],d=i[1]),"r"!=p||h||(p
 ="g"),null!=h&&("g"==p?h=Math.max(1,Math.min(21,h)):"e"!=p&&"f"!=p||(h=Math.max(0,Math.min(20,h)))),p=pa.get(p)||Fn;var M=c&&s;return function(n){var e=d;if(y&&n%1)return"";var i=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>g){var l=ao.formatPrefix(n,h);n=l.scale(n),e=l.symbol+d}else n*=g;n=p(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=m?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!c&&s&&(x=u(x,1/0));var S=v.length+x.length+b.length+(M?0:i.length),k=f>S?new Array(S=f-S+1).join(r):"";return M&&(x=u(k+x,k.length?f-b.length:1/0)),i+=v,n=x+b,("<"===o?i+n+k:">"===o?k+i+n:"^"===o?k.substring(0,S>>=1)+i+n+k.substring(S):i+(M?n:k+n))+e}}}function Fn(n){return n+""}function Hn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function On(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new va(e-1)),1),e}function u(n,e){return t(n=new va(+n),e
 ),n}function o(n,r,u){var o=i(n),a=[];if(u>1)for(;r>o;)e(o)%u||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{va=Hn;var r=new Hn;return r._=n,o(r,t,e)}finally{va=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=o;var l=n.utc=In(n);return l.floor=l,l.round=In(r),l.ceil=In(i),l.offset=In(u),l.range=a,n}function In(n){return function(t,e){try{va=Hn;var r=new Hn;return r._=t,n(r,e)._}finally{va=Date}}}function Yn(n){function t(n){function t(t){for(var e,i,u,o=[],a=-1,l=0;++a<r;)37===n.charCodeAt(a)&&(o.push(n.slice(l,a)),null!=(i=ya[e=n.charAt(++a)])&&(e=n.charAt(++a)),(u=A[e])&&(e=u(t,null==i?"e"===e?" ":"0":i)),o.push(e),l=a+1);return o.push(n.slice(l,a)),o.join("")}var r=n.length;return t.parse=function(t){var r={y:1900,m:0,d:1,H:0,M:0,S:0,L:0,Z:null},i=e(r,n,t,0);if(i!=t.length)return null;"p"in r&&(r.H=r.H%12+12*r.p);var u=null!=r.Z&&va!==Hn,o=new(u?Hn:va);return"j"in r?o.setFullYear(r.y,0,r.j):"W"in r||"U"in r?("w"in r||(
 r.w="W"in r?1:0),o.setFullYear(r.y,0,1),o.setFullYear(r.y,0,"W"in r?(r.w+6)%7+7*r.W-(o.getDay()+5)%7:r.w+7*r.U-(o.getDay()+6)%7)):o.setFullYear(r.y,r.m,r.d),o.setHours(r.H+(r.Z/100|0),r.M+r.Z%100,r.S,r.L),u?o._:o},t.toString=function(){return n},t}function e(n,t,e,r){for(var i,u,o,a=0,l=t.length,c=e.length;l>a;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(o=t.charAt(a++),u=C[o in ya?t.charAt(a++):o],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){N.lastIndex=0;var r=N.exec(t.slice(e));return r?(n.m=E.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,A.c.toString(),t,r)}fun
 ction l(n,t,r){return e(n,A.x.toString(),t,r)}function c(n,t,r){return e(n,A.X.toString(),t,r)}function f(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var s=n.dateTime,h=n.date,p=n.time,g=n.periods,v=n.days,d=n.shortDays,y=n.months,m=n.shortMonths;t.utc=function(n){function e(n){try{va=Hn;var t=new va;return t._=n,r(t)}finally{va=Date}}var r=t(n);return e.parse=function(n){try{va=Hn;var t=r.parse(n);return t&&t._}finally{va=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ct;var M=ao.map(),x=Vn(v),b=Xn(v),_=Vn(d),w=Xn(d),S=Vn(y),k=Xn(y),N=Vn(m),E=Xn(m);g.forEach(function(n,t){M.set(n.toLowerCase(),t)});var A={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return m[n.getMonth()]},B:function(n){return y[n.getMonth()]},c:t(s),d:function(n,t){return Zn(n.getDate(),t,2)},e:function(n,t){return Zn(n.getDate(),t,2)},H:function(n,t){return Zn(n.getHours(),t,2)},I:function(n,t){return Zn(n.getHours()%12||12,t,2)},j:fu
 nction(n,t){return Zn(1+ga.dayOfYear(n),t,3)},L:function(n,t){return Zn(n.getMilliseconds(),t,3)},m:function(n,t){return Zn(n.getMonth()+1,t,2)},M:function(n,t){return Zn(n.getMinutes(),t,2)},p:function(n){return g[+(n.getHours()>=12)]},S:function(n,t){return Zn(n.getSeconds(),t,2)},U:function(n,t){return Zn(ga.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Zn(ga.mondayOfYear(n),t,2)},x:t(h),X:t(p),y:function(n,t){return Zn(n.getFullYear()%100,t,2)},Y:function(n,t){return Zn(n.getFullYear()%1e4,t,4)},Z:at,"%":function(){return"%"}},C={a:r,A:i,b:u,B:o,c:a,d:tt,e:tt,H:rt,I:rt,j:et,L:ot,m:nt,M:it,p:f,S:ut,U:Bn,w:$n,W:Wn,x:l,X:c,y:Gn,Y:Jn,Z:Kn,"%":lt};return t}function Zn(n,t,e){var r=0>n?"-":"",i=(r?-n:n)+"",u=i.length;return r+(e>u?new Array(e-u+1).join(t)+i:i)}function Vn(n){return new RegExp("^(?:"+n.map(ao.requote).join("|")+")","i")}function Xn(n){for(var t=new c,e=-1,r=n.length;++e<r;)t.set(n[e].toLowerCase(),e);return t}function $n(n,t,e){ma.lastIn
 dex=0;var r=ma.exec(t.slice(e,e+1));return r?(n.w=+r[0],e+r[0].length):-1}function Bn(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e));return r?(n.U=+r[0],e+r[0].length):-1}function Wn(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e));return r?(n.W=+r[0],e+r[0].length):-1}function Jn(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+4));return r?(n.y=+r[0],e+r[0].length):-1}function Gn(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.y=Qn(+r[0]),e+r[0].length):-1}function Kn(n,t,e){return/^[+-]\d{4}$/.test(t=t.slice(e,e+5))?(n.Z=-t,e+5):-1}function Qn(n){return n+(n>68?1900:2e3)}function nt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function tt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function et(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function rt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].len
 gth):-1}function it(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function ut(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ot(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function at(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=xo(t)/60|0,i=xo(t)%60;return e+Zn(r,"0",2)+Zn(i,"0",2)}function lt(n,t,e){Ma.lastIndex=0;var r=Ma.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ct(n){for(var t=n.length,e=-1;++e<t;)n[e][0]=this(n[e][0]);return function(t){for(var e=0,r=n[e];!r[1](t);)r=n[++e];return r[0](t)}}function ft(){}function st(n,t,e){var r=e.s=n+t,i=r-n,u=r-i;e.t=n-u+(t-i)}function ht(n,t){n&&wa.hasOwnProperty(n.type)&&wa[n.type](n,t)}function pt(n,t,e){var r,i=-1,u=n.length-e;for(t.lineStart();++i<u;)r=n[i],t.point(r[0],r[1],r[2]);t.lineEnd()}function gt(n,t){var e=-1,r=n.length;for(t.polygonStart();++e<r;)pt(n[e],t,1);t.polygonEnd
 ()}function vt(){function n(n,t){n*=Yo,t=t*Yo/2+Fo/4;var e=n-r,o=e>=0?1:-1,a=o*e,l=Math.cos(t),c=Math.sin(t),f=u*c,s=i*l+f*Math.cos(a),h=f*o*Math.sin(a);ka.add(Math.atan2(h,s)),r=n,i=l,u=c}var t,e,r,i,u;Na.point=function(o,a){Na.point=n,r=(t=o)*Yo,i=Math.cos(a=(e=a)*Yo/2+Fo/4),u=Math.sin(a)},Na.lineEnd=function(){n(t,e)}}function dt(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function yt(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function mt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Mt(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function xt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function bt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function _t(n){return[Math.atan2(n[1],n[0]),tn(n[2])]}function wt(n,t){return xo(n[0]-t[0])<Uo&&xo(n[1]-t[1])<Uo}function St(n,t){n*=Yo;var e=Math.cos(t*=Yo);kt(e*Math.cos(n),e*Math.sin(n),Math.sin(t))}function kt(n,t,e){++Ea,Ca+=(n-Ca)/Ea,za+=(t-za)/Ea,La+=
 (e-La)/Ea}function Nt(){function n(n,i){n*=Yo;var u=Math.cos(i*=Yo),o=u*Math.cos(n),a=u*Math.sin(n),l=Math.sin(i),c=Math.atan2(Math.sqrt((c=e*l-r*a)*c+(c=r*o-t*l)*c+(c=t*a-e*o)*c),t*o+e*a+r*l);Aa+=c,qa+=c*(t+(t=o)),Ta+=c*(e+(e=a)),Ra+=c*(r+(r=l)),kt(t,e,r)}var t,e,r;ja.point=function(i,u){i*=Yo;var o=Math.cos(u*=Yo);t=o*Math.cos(i),e=o*Math.sin(i),r=Math.sin(u),ja.point=n,kt(t,e,r)}}function Et(){ja.point=St}function At(){function n(n,t){n*=Yo;var e=Math.cos(t*=Yo),o=e*Math.cos(n),a=e*Math.sin(n),l=Math.sin(t),c=i*l-u*a,f=u*o-r*l,s=r*a-i*o,h=Math.sqrt(c*c+f*f+s*s),p=r*o+i*a+u*l,g=h&&-nn(p)/h,v=Math.atan2(h,p);Da+=g*c,Pa+=g*f,Ua+=g*s,Aa+=v,qa+=v*(r+(r=o)),Ta+=v*(i+(i=a)),Ra+=v*(u+(u=l)),kt(r,i,u)}var t,e,r,i,u;ja.point=function(o,a){t=o,e=a,ja.point=n,o*=Yo;var l=Math.cos(a*=Yo);r=l*Math.cos(o),i=l*Math.sin(o),u=Math.sin(a),kt(r,i,u)},ja.lineEnd=function(){n(t,e),ja.lineEnd=Et,ja.point=St}}function Ct(n,t){function e(e,r){return e=n(e,r),t(e[0],e[1])}return n.invert&&t.invert&&(e.inv
 ert=function(e,r){return e=t.invert(e,r),e&&n.invert(e[0],e[1])}),e}function zt(){return!0}function Lt(n,t,e,r,i){var u=[],o=[];if(n.forEach(function(n){if(!((t=n.length-1)<=0)){var t,e=n[0],r=n[t];if(wt(e,r)){i.lineStart();for(var a=0;t>a;++a)i.point((e=n[a])[0],e[1]);return void i.lineEnd()}var l=new Tt(e,n,null,!0),c=new Tt(e,null,l,!1);l.o=c,u.push(l),o.push(c),l=new Tt(r,n,null,!1),c=new Tt(r,null,l,!0),l.o=c,u.push(l),o.push(c)}}),o.sort(t),qt(u),qt(o),u.length){for(var a=0,l=e,c=o.length;c>a;++a)o[a].e=l=!l;for(var f,s,h=u[0];;){for(var p=h,g=!0;p.v;)if((p=p.n)===h)return;f=p.z,i.lineStart();do{if(p.v=p.o.v=!0,p.e){if(g)for(var a=0,c=f.length;c>a;++a)i.point((s=f[a])[0],s[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(g){f=p.p.z;for(var a=f.length-1;a>=0;--a)i.point((s=f[a])[0],s[1])}else r(p.x,p.p.x,-1,i);p=p.p}p=p.o,f=p.z,g=!g}while(!p.v);i.lineEnd()}}}function qt(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r<t;)i.n=e=n[r],e.p=i,i=e;i.n=e=n[0],e.p=i}}function Tt(n,t,e,r){this.x=n,t
 his.z=t,this.o=e,this.e=r,this.v=!1,this.n=this.p=null}function Rt(n,t,e,r){return function(i,u){function o(t,e){var r=i(t,e);n(t=r[0],e=r[1])&&u.point(t,e)}function a(n,t){var e=i(n,t);d.point(e[0],e[1])}function l(){m.point=a,d.lineStart()}function c(){m.point=o,d.lineEnd()}function f(n,t){v.push([n,t]);var e=i(n,t);x.point(e[0],e[1])}function s(){x.lineStart(),v=[]}function h(){f(v[0][0],v[0][1]),x.lineEnd();var n,t=x.clean(),e=M.buffer(),r=e.length;if(v.pop(),g.push(v),v=null,r)if(1&t){n=e[0];var i,r=n.length-1,o=-1;if(r>0){for(b||(u.polygonStart(),b=!0),u.lineStart();++o<r;)u.point((i=n[o])[0],i[1]);u.lineEnd()}}else r>1&&2&t&&e.push(e.pop().concat(e.shift())),p.push(e.filter(Dt))}var p,g,v,d=t(u),y=i.invert(r[0],r[1]),m={point:o,lineStart:l,lineEnd:c,polygonStart:function(){m.point=f,m.lineStart=s,m.lineEnd=h,p=[],g=[]},polygonEnd:function(){m.point=o,m.lineStart=l,m.lineEnd=c,p=ao.merge(p);var n=Ot(y,g);p.length?(b||(u.polygonStart(),b=!0),Lt(p,Ut,n,e,u)):n&&(b||(u.polygonSta
 rt(),b=!0),u.lineStart(),e(null,null,1,u),u.lineEnd()),b&&(u.polygonEnd(),b=!1),p=g=null},sphere:function(){u.polygonStart(),u.lineStart(),e(null,null,1,u),u.lineEnd(),u.polygonEnd()}},M=Pt(),x=t(M),b=!1;return m}}function Dt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:b,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Ut(n,t){return((n=n.x)[0]<0?n[1]-Io-Uo:Io-n[1])-((t=t.x)[0]<0?t[1]-Io-Uo:Io-t[1])}function jt(n){var t,e=NaN,r=NaN,i=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(u,o){var a=u>0?Fo:-Fo,l=xo(u-e);xo(l-Fo)<Uo?(n.point(e,r=(r+o)/2>0?Io:-Io),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(u,r),t=0):i!==a&&l>=Fo&&(xo(e-i)<Uo&&(e-=i*Uo),xo(u-a)<Uo&&(u-=a*Uo),r=Ft(e,r,u,o),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),t=0),n.point(e=u,r=o),i=a},lineEnd:function(){n.lineEnd(),e=r=
 NaN},clean:function(){return 2-t}}}function Ft(n,t,e,r){var i,u,o=Math.sin(n-e);return xo(o)>Uo?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*o)):(t+r)/2}function Ht(n,t,e,r){var i;if(null==n)i=e*Io,r.point(-Fo,i),r.point(0,i),r.point(Fo,i),r.point(Fo,0),r.point(Fo,-i),r.point(0,-i),r.point(-Fo,-i),r.point(-Fo,0),r.point(-Fo,i);else if(xo(n[0]-t[0])>Uo){var u=n[0]<t[0]?Fo:-Fo;i=e*u/2,r.point(-u,i),r.point(0,i),r.point(u,i)}else r.point(t[0],t[1])}function Ot(n,t){var e=n[0],r=n[1],i=[Math.sin(e),-Math.cos(e),0],u=0,o=0;ka.reset();for(var a=0,l=t.length;l>a;++a){var c=t[a],f=c.length;if(f)for(var s=c[0],h=s[0],p=s[1]/2+Fo/4,g=Math.sin(p),v=Math.cos(p),d=1;;){d===f&&(d=0),n=c[d];var y=n[0],m=n[1]/2+Fo/4,M=Math.sin(m),x=Math.cos(m),b=y-h,_=b>=0?1:-1,w=_*b,S=w>Fo,k=g*M;if(ka.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),u+=S?b+_*Ho:b,S^h>=e^y>=e){var N=mt(dt(s),dt(n));bt(N);var E=mt(i,N);bt(E);var A=(S^b>=0?-1:1)*tn(E[2]);(r>A||r==
 =A&&(N[0]||N[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=y,g=M,v=x,s=n}}return(-Uo>u||Uo>u&&-Uo>ka)^1&o}function It(n){function t(n,t){return Math.cos(n)*Math.cos(t)>u}function e(n){var e,u,l,c,f;return{lineStart:function(){c=l=!1,f=1},point:function(s,h){var p,g=[s,h],v=t(s,h),d=o?v?0:i(s,h):v?i(s+(0>s?Fo:-Fo),h):0;if(!e&&(c=l=v)&&n.lineStart(),v!==l&&(p=r(e,g),(wt(e,p)||wt(g,p))&&(g[0]+=Uo,g[1]+=Uo,v=t(g[0],g[1]))),v!==l)f=0,v?(n.lineStart(),p=r(g,e),n.point(p[0],p[1])):(p=r(e,g),n.point(p[0],p[1]),n.lineEnd()),e=p;else if(a&&e&&o^v){var y;d&u||!(y=r(g,e,!0))||(f=0,o?(n.lineStart(),n.point(y[0][0],y[0][1]),n.point(y[1][0],y[1][1]),n.lineEnd()):(n.point(y[1][0],y[1][1]),n.lineEnd(),n.lineStart(),n.point(y[0][0],y[0][1])))}!v||e&&wt(e,g)||n.point(g[0],g[1]),e=g,l=v,u=d},lineEnd:function(){l&&n.lineEnd(),e=null},clean:function(){return f|(c&&l)<<1}}}function r(n,t,e){var r=dt(n),i=dt(t),o=[1,0,0],a=mt(r,i),l=yt(a,a),c=a[0],f=l-c*c;if(!f)return!e&&n;var s=u*l/f,h=-u*c/f,p=mt(o,a),g=xt(o,s)
 ,v=xt(a,h);Mt(g,v);var d=p,y=yt(g,d),m=yt(d,d),M=y*y-m*(yt(g,g)-1);if(!(0>M)){var x=Math.sqrt(M),b=xt(d,(-y-x)/m);if(Mt(b,g),b=_t(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],N=t[1];w>S&&(_=w,w=S,S=_);var E=S-w,A=xo(E-Fo)<Uo,C=A||Uo>E;if(!A&&k>N&&(_=k,k=N,N=_),C?A?k+N>0^b[1]<(xo(b[0]-w)<Uo?k:N):k<=b[1]&&b[1]<=N:E>Fo^(w<=b[0]&&b[0]<=S)){var z=xt(d,(-y+x)/m);return Mt(z,g),[b,_t(z)]}}}function i(t,e){var r=o?n:Fo-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(n),o=u>0,a=xo(u)>Uo,l=ve(n,6*Yo);return Rt(t,e,l,o?[0,-n]:[-Fo,n-Fo])}function Yt(n,t,e,r){return function(i){var u,o=i.a,a=i.b,l=o.x,c=o.y,f=a.x,s=a.y,h=0,p=1,g=f-l,v=s-c;if(u=n-l,g||!(u>0)){if(u/=g,0>g){if(h>u)return;p>u&&(p=u)}else if(g>0){if(u>p)return;u>h&&(h=u)}if(u=e-l,g||!(0>u)){if(u/=g,0>g){if(u>p)return;u>h&&(h=u)}else if(g>0){if(h>u)return;p>u&&(p=u)}if(u=t-c,v||!(u>0)){if(u/=v,0>v){if(h>u)return;p>u&&(p=u)}else if(v>0){if(u>p)return;u>h&&(h=u)}if(u=r-c,v||!(0>u)){if(u/=v,0>v){if(u>p)return;u>h&&
 (h=u)}else if(v>0){if(h>u)return;p>u&&(p=u)}return h>0&&(i.a={x:l+h*g,y:c+h*v}),1>p&&(i.b={x:l+p*g,y:c+p*v}),i}}}}}}function Zt(n,t,e,r){function i(r,i){return xo(r[0]-n)<Uo?i>0?0:3:xo(r[0]-e)<Uo?i>0?2:1:xo(r[1]-t)<Uo?i>0?1:0:i>0?3:2}function u(n,t){return o(n.x,t.x)}function o(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function l(n){for(var t=0,e=d.length,r=n[1],i=0;e>i;++i)for(var u,o=1,a=d[i],l=a.length,c=a[0];l>o;++o)u=a[o],c[1]<=r?u[1]>r&&Q(c,u,n)>0&&++t:u[1]<=r&&Q(c,u,n)<0&&--t,c=u;return 0!==t}function c(u,a,l,c){var f=0,s=0;if(null==u||(f=i(u,l))!==(s=i(a,l))||o(u,a)<0^l>0){do c.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+l+4)%4)!==s)}else c.point(a[0],a[1])}function f(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function s(n,t){f(n,t)&&a.point(n,t)}function h(){C.point=g,d&&d.push(y=[]),S=!0,w=!1,b=_=NaN}function p(){v&&(g(m,M),x&&w&&E.rejoin(),v.push(E.buffer())),C.point=s,w&&a.lineEnd()}function g(n,t){n=
 Math.max(-Ha,Math.min(Ha,n)),t=Math.max(-Ha,Math.min(Ha,t));var e=f(n,t);if(d&&y.push([n,t]),S)m=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};A(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,y,m,M,x,b,_,w,S,k,N=a,E=Pt(),A=Yt(n,t,e,r),C={point:s,lineStart:h,lineEnd:p,polygonStart:function(){a=E,v=[],d=[],k=!0},polygonEnd:function(){a=N,v=ao.merge(v);var t=l([n,r]),e=k&&t,i=v.length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),c(null,null,1,a),a.lineEnd()),i&&Lt(v,u,t,c,a),a.polygonEnd()),v=d=y=null}};return C}}function Vt(n){var t=0,e=Fo/3,r=ae(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*Fo/180,e=n[1]*Fo/180):[t/Fo*180,e/Fo*180]},i}function Xt(n,t){function e(n,t){var e=Math.sqrt(u-2*i*Math.sin(t))/i;return[e*Math.sin(n*=i),o-e*Math.cos(n)]}var r=Math.sin(n),i=(r+Math.sin(t))/2,u=1+r*(2*i-r),o=M
 ath.sqrt(u)/i;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/i,tn((u-(n*n+e*e)*i*i)/(2*i))]},e}function $t(){function n(n,t){Ia+=i*n-r*t,r=n,i=t}var t,e,r,i;$a.point=function(u,o){$a.point=n,t=r=u,e=i=o},$a.lineEnd=function(){n(t,e)}}function Bt(n,t){Ya>n&&(Ya=n),n>Va&&(Va=n),Za>t&&(Za=t),t>Xa&&(Xa=t)}function Wt(){function n(n,t){o.push("M",n,",",t,u)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function i(){o.push("Z")}var u=Jt(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return u=Jt(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Jt(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Gt(n,t){Ca+=n,za+=t,++La}function Kt(){function n(n,r){var i=n-t,u=r-e,o=Math.sqrt(i*i+u*u);qa+=o*(t+n)/2,Ta+=o*(e+r)/2,Ra+=o,G
 t(t=n,e=r)}var t,e;Wa.point=function(r,i){Wa.point=n,Gt(t=r,e=i)}}function Qt(){Wa.point=Gt}function ne(){function n(n,t){var e=n-r,u=t-i,o=Math.sqrt(e*e+u*u);qa+=o*(r+n)/2,Ta+=o*(i+t)/2,Ra+=o,o=i*n-r*t,Da+=o*(r+n),Pa+=o*(i+t),Ua+=3*o,Gt(r=n,i=t)}var t,e,r,i;Wa.point=function(u,o){Wa.point=n,Gt(t=r=u,e=i=o)},Wa.lineEnd=function(){n(t,e)}}function te(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,Ho)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function i(){a.point=t}function u(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:i,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=i,a.point=t},pointRadius:function(n){return o=n,a},result:b};return a}function ee(n){function t(n){return(a?r:e)(n)}function e(t){return ue(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=NaN,S.point=u,t.lineStart()}function u(e,r){var u=dt([e,r]),o=n(e,r);i(M,x,m,b,_,
 w,M=o[0],x=o[1],m=e,b=u[0],_=u[1],w=u[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function l(){
+r(),S.point=c,S.lineEnd=f}function c(n,t){u(s=n,h=t),p=M,g=x,v=b,d=_,y=w,S.point=u}function f(){i(M,x,m,b,_,w,p,g,s,v,d,y,a,t),S.lineEnd=o,o()}var s,h,p,g,v,d,y,m,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=l},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function i(t,e,r,a,l,c,f,s,h,p,g,v,d,y){var m=f-t,M=s-e,x=m*m+M*M;if(x>4*u&&d--){var b=a+p,_=l+g,w=c+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),N=xo(xo(w)-1)<Uo||xo(r-h)<Uo?(r+h)/2:Math.atan2(_,b),E=n(N,k),A=E[0],C=E[1],z=A-t,L=C-e,q=M*z-m*L;(q*q/x>u||xo((m*z+M*L)/x-.5)>.3||o>a*p+l*g+c*v)&&(i(t,e,r,a,l,c,A,C,N,b/=S,_/=S,w,d,y),y.point(A,C),i(A,C,N,b,_,w,f,s,h,p,g,v,d,y))}}var u=.5,o=Math.cos(30*Yo),a=16;return t.precision=function(n){return arguments.length?(a=(u=n*n)>0&&16,t):Math.sqrt(u)},t}function re(n){var t=ee(function(t,e){return n([t*Zo,e*Zo])});return function(n){return le(t(n))}}function ie(n){this.stream=n}function ue(n,t){return{point:t,sphere:functio
 n(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function oe(n){return ae(function(){return n})()}function ae(n){function t(n){return n=a(n[0]*Yo,n[1]*Yo),[n[0]*h+l,c-n[1]*h]}function e(n){return n=a.invert((n[0]-l)/h,(c-n[1])/h),n&&[n[0]*Zo,n[1]*Zo]}function r(){a=Ct(o=se(y,M,x),u);var n=u(v,d);return l=p-n[0]*h,c=g+n[1]*h,i()}function i(){return f&&(f.valid=!1,f=null),t}var u,o,a,l,c,f,s=ee(function(n,t){return n=u(n,t),[n[0]*h+l,c-n[1]*h]}),h=150,p=480,g=250,v=0,d=0,y=0,M=0,x=0,b=Fa,_=m,w=null,S=null;return t.stream=function(n){return f&&(f.valid=!1),f=le(b(o,s(_(n)))),f.valid=!0,f},t.clipAngle=function(n){return arguments.length?(b=null==n?(w=n,Fa):It((w=+n)*Yo),i()):w},t.clipExtent=function(n){return arguments.length?(S=n,_=n?Zt(n[0][0],n[0][1],n[1][0],n[1][1]):m,i()):S},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return argum
 ents.length?(p=+n[0],g=+n[1],r()):[p,g]},t.center=function(n){return arguments.length?(v=n[0]%360*Yo,d=n[1]%360*Yo,r()):[v*Zo,d*Zo]},t.rotate=function(n){return arguments.length?(y=n[0]%360*Yo,M=n[1]%360*Yo,x=n.length>2?n[2]%360*Yo:0,r()):[y*Zo,M*Zo,x*Zo]},ao.rebind(t,s,"precision"),function(){return u=n.apply(this,arguments),t.invert=u.invert&&e,r()}}function le(n){return ue(n,function(t,e){n.point(t*Yo,e*Yo)})}function ce(n,t){return[n,t]}function fe(n,t){return[n>Fo?n-Ho:-Fo>n?n+Ho:n,t]}function se(n,t,e){return n?t||e?Ct(pe(n),ge(t,e)):pe(n):t||e?ge(t,e):fe}function he(n){return function(t,e){return t+=n,[t>Fo?t-Ho:-Fo>t?t+Ho:t,e]}}function pe(n){var t=he(n);return t.invert=he(-n),t}function ge(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*r+a*i;return[Math.atan2(l*u-f*o,a*r-c*i),tn(f*u+l*o)]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math
 .sin(t),f=c*u-l*o;return[Math.atan2(l*u+c*o,a*r+f*i),tn(f*r-a*i)]},e}function ve(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,o,a){var l=o*t;null!=i?(i=de(e,i),u=de(e,u),(o>0?u>i:i>u)&&(i+=o*Ho)):(i=n+o*Ho,u=n-.5*l);for(var c,f=i;o>0?f>u:u>f;f-=l)a.point((c=_t([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function de(n,t){var e=dt(t);e[0]-=n,bt(e);var r=nn(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Uo)%(2*Math.PI)}function ye(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function me(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function Me(n){return n.source}function xe(n){return n.target}function be(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),o=Math.cos(r),a=Math.sin(r),l=i*Math.cos(n),c=i*Math.sin(n),f=o*Math.cos(e),s=o*Math.sin(e),h=2*Math.asin(Math.sqrt(on(r-t)+i*o*on(e-n))),p=1/Math.sin(h),g=h?function(n){var t=Math.sin(n*=h)*p,e=Math.sin(h-n)*p,r=e*l+t*f,i=e*c+t*s
 ,o=e*u+t*a;return[Math.atan2(i,r)*Zo,Math.atan2(o,Math.sqrt(r*r+i*i))*Zo]}:function(){return[n*Zo,t*Zo]};return g.distance=h,g}function _e(){function n(n,i){var u=Math.sin(i*=Yo),o=Math.cos(i),a=xo((n*=Yo)-t),l=Math.cos(a);Ja+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*u-e*o*l)*a),e*u+r*o*l),t=n,e=u,r=o}var t,e,r;Ga.point=function(i,u){t=i*Yo,e=Math.sin(u*=Yo),r=Math.cos(u),Ga.point=n},Ga.lineEnd=function(){Ga.point=Ga.lineEnd=b}}function we(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),o=Math.cos(i);return[Math.atan2(n*u,r*o),Math.asin(r&&e*u/r)]},e}function Se(n,t){function e(n,t){o>0?-Io+Uo>t&&(t=-Io+Uo):t>Io-Uo&&(t=Io-Uo);var e=o/Math.pow(i(t),u);return[e*Math.sin(u*n),o-e*Math.cos(u*n)]}var r=Math.cos(n),i=function(n){return Math.tan(Fo/4+n/2)},u=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(i(t)/i(n)),o=r*Math.pow(i(n),u)/u;return u?(e.inver
 t=function(n,t){var e=o-t,r=K(u)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/u,2*Math.atan(Math.pow(o/r,1/u))-Io]},e):Ne}function ke(n,t){function e(n,t){var e=u-t;return[e*Math.sin(i*n),u-e*Math.cos(i*n)]}var r=Math.cos(n),i=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),u=r/i+n;return xo(i)<Uo?ce:(e.invert=function(n,t){var e=u-t;return[Math.atan2(n,e)/i,u-K(i)*Math.sqrt(n*n+e*e)]},e)}function Ne(n,t){return[n,Math.log(Math.tan(Fo/4+t/2))]}function Ee(n){var t,e=oe(n),r=e.scale,i=e.translate,u=e.clipExtent;return e.scale=function(){var n=r.apply(e,arguments);return n===e?t?e.clipExtent(null):e:n},e.translate=function(){var n=i.apply(e,arguments);return n===e?t?e.clipExtent(null):e:n},e.clipExtent=function(n){var o=u.apply(e,arguments);if(o===e){if(t=null==n){var a=Fo*r(),l=i();u([[l[0]-a,l[1]-a],[l[0]+a,l[1]+a]])}}else t&&(o=null);return o},e.clipExtent(null)}function Ae(n,t){return[Math.log(Math.tan(Fo/4+t/2)),-n]}function Ce(n){return n[0]}function ze(n){return n[1]}function Le(n){for(va
 r t=n.length,e=[0,1],r=2,i=2;t>i;i++){for(;r>1&&Q(n[e[r-2]],n[e[r-1]],n[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function qe(n,t){return n[0]-t[0]||n[1]-t[1]}function Te(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Re(n,t,e,r){var i=n[0],u=e[0],o=t[0]-i,a=r[0]-u,l=n[1],c=e[1],f=t[1]-l,s=r[1]-c,h=(a*(l-c)-s*(i-u))/(s*o-a*f);return[i+h*o,l+h*f]}function De(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Pe(){rr(this),this.edge=this.site=this.circle=null}function Ue(n){var t=cl.pop()||new Pe;return t.site=n,t}function je(n){Be(n),ol.remove(n),cl.push(n),rr(n)}function Fe(n){var t=n.circle,e=t.x,r=t.cy,i={x:e,y:r},u=n.P,o=n.N,a=[n];je(n);for(var l=u;l.circle&&xo(e-l.circle.x)<Uo&&xo(r-l.circle.cy)<Uo;)u=l.P,a.unshift(l),je(l),l=u;a.unshift(l),Be(l);for(var c=o;c.circle&&xo(e-c.circle.x)<Uo&&xo(r-c.circle.cy)<Uo;)o=c.N,a.push(c),je(c),c=o;a.push(c),Be(c);var f,s=a.length;for(f=1;s>f;++f)c=a[f],l=a[f-1],nr(c.edge,l.site,c.site,i);l=a[0],c=a[s-
 1],c.edge=Ke(l.site,c.site,null,i),$e(l),$e(c)}function He(n){for(var t,e,r,i,u=n.x,o=n.y,a=ol._;a;)if(r=Oe(a,o)-u,r>Uo)a=a.L;else{if(i=u-Ie(a,o),!(i>Uo)){r>-Uo?(t=a.P,e=a):i>-Uo?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=Ue(n);if(ol.insert(t,l),t||e){if(t===e)return Be(t),e=Ue(t.site),ol.insert(l,e),l.edge=e.edge=Ke(t.site,l.site),$e(t),void $e(e);if(!e)return void(l.edge=Ke(t.site,l.site));Be(t),Be(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,p=n.y-s,g=e.site,v=g.x-f,d=g.y-s,y=2*(h*d-p*v),m=h*h+p*p,M=v*v+d*d,x={x:(d*m-p*M)/y+f,y:(h*M-v*m)/y+s};nr(e.edge,c,g,x),l.edge=Ke(c,n,null,x),e.edge=Ke(n,g,null,x),$e(t),$e(e)}}function Oe(n,t){var e=n.site,r=e.x,i=e.y,u=i-t;if(!u)return r;var o=n.P;if(!o)return-(1/0);e=o.site;var a=e.x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/u-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+i-u/2)))/s+r:(r+a)/2}function Ie(n,t){var e=n.N;if(e)return Oe(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ye(n){this.site=n,this.edges=[]}function Z
 e(n){for(var t,e,r,i,u,o,a,l,c,f,s=n[0][0],h=n[1][0],p=n[0][1],g=n[1][1],v=ul,d=v.length;d--;)if(u=v[d],u&&u.prepare())for(a=u.edges,l=a.length,o=0;l>o;)f=a[o].end(),r=f.x,i=f.y,c=a[++o%l].start(),t=c.x,e=c.y,(xo(r-t)>Uo||xo(i-e)>Uo)&&(a.splice(o,0,new tr(Qe(u.site,f,xo(r-s)<Uo&&g-i>Uo?{x:s,y:xo(t-s)<Uo?e:g}:xo(i-g)<Uo&&h-r>Uo?{x:xo(e-g)<Uo?t:h,y:g}:xo(r-h)<Uo&&i-p>Uo?{x:h,y:xo(t-h)<Uo?e:p}:xo(i-p)<Uo&&r-s>Uo?{x:xo(e-p)<Uo?t:s,y:p}:null),u.site,null)),++l)}function Ve(n,t){return t.angle-n.angle}function Xe(){rr(this),this.x=this.y=this.arc=this.site=this.cy=null}function $e(n){var t=n.P,e=n.N;if(t&&e){var r=t.site,i=n.site,u=e.site;if(r!==u){var o=i.x,a=i.y,l=r.x-o,c=r.y-a,f=u.x-o,s=u.y-a,h=2*(l*s-c*f);if(!(h>=-jo)){var p=l*l+c*c,g=f*f+s*s,v=(s*p-c*g)/h,d=(l*g-f*p)/h,s=d+a,y=fl.pop()||new Xe;y.arc=n,y.site=i,y.x=v+o,y.y=s+Math.sqrt(v*v+d*d),y.cy=s,n.circle=y;for(var m=null,M=ll._;M;)if(y.y<M.y||y.y===M.y&&y.x<=M.x){if(!M.L){m=M.P;break}M=M.L}else{if(!M.R){m=M;break}M=M.R}ll.insert(
 m,y),m||(al=y)}}}}function Be(n){var t=n.circle;t&&(t.P||(al=t.N),ll.remove(t),fl.push(t),rr(t),n.circle=null)}function We(n){for(var t,e=il,r=Yt(n[0][0],n[0][1],n[1][0],n[1][1]),i=e.length;i--;)t=e[i],(!Je(t,n)||!r(t)||xo(t.a.x-t.b.x)<Uo&&xo(t.a.y-t.b.y)<Uo)&&(t.a=t.b=null,e.splice(i,1))}function Je(n,t){var e=n.b;if(e)return!0;var r,i,u=n.a,o=t[0][0],a=t[1][0],l=t[0][1],c=t[1][1],f=n.l,s=n.r,h=f.x,p=f.y,g=s.x,v=s.y,d=(h+g)/2,y=(p+v)/2;if(v===p){if(o>d||d>=a)return;if(h>g){if(u){if(u.y>=c)return}else u={x:d,y:l};e={x:d,y:c}}else{if(u){if(u.y<l)return}else u={x:d,y:c};e={x:d,y:l}}}else if(r=(h-g)/(v-p),i=y-r*d,-1>r||r>1)if(h>g){if(u){if(u.y>=c)return}else u={x:(l-i)/r,y:l};e={x:(c-i)/r,y:c}}else{if(u){if(u.y<l)return}else u={x:(c-i)/r,y:c};e={x:(l-i)/r,y:l}}else if(v>p){if(u){if(u.x>=a)return}else u={x:o,y:r*o+i};e={x:a,y:r*a+i}}else{if(u){if(u.x<o)return}else u={x:a,y:r*a+i};e={x:o,y:r*o+i}}return n.a=u,n.b=e,!0}function Ge(n,t){this.l=n,this.r=t,this.a=this.b=null}function Ke(n,t,
 e,r){var i=new Ge(n,t);return il.push(i),e&&nr(i,n,t,e),r&&nr(i,t,n,r),ul[n.i].edges.push(new tr(i,n,t)),ul[t.i].edges.push(new tr(i,t,n)),i}function Qe(n,t,e){var r=new Ge(n,null);return r.a=t,r.b=e,il.push(r),r}function nr(n,t,e,r){n.a||n.b?n.l===e?n.b=r:n.a=r:(n.a=r,n.l=t,n.r=e)}function tr(n,t,e){var r=n.a,i=n.b;this.edge=n,this.site=t,this.angle=e?Math.atan2(e.y-t.y,e.x-t.x):n.l===t?Math.atan2(i.x-r.x,r.y-i.y):Math.atan2(r.x-i.x,i.y-r.y)}function er(){this._=null}function rr(n){n.U=n.C=n.L=n.R=n.P=n.N=null}function ir(n,t){var e=t,r=t.R,i=e.U;i?i.L===e?i.L=r:i.R=r:n._=r,r.U=i,e.U=r,e.R=r.L,e.R&&(e.R.U=e),r.L=e}function ur(n,t){var e=t,r=t.L,i=e.U;i?i.L===e?i.L=r:i.R=r:n._=r,r.U=i,e.U=r,e.L=r.R,e.L&&(e.L.U=e),r.R=e}function or(n){for(;n.L;)n=n.L;return n}function ar(n,t){var e,r,i,u=n.sort(lr).pop();for(il=[],ul=new Array(n.length),ol=new er,ll=new er;;)if(i=al,u&&(!i||u.y<i.y||u.y===i.y&&u.x<i.x))u.x===e&&u.y===r||(ul[u.i]=new Ye(u),He(u),e=u.x,r=u.y),u=n.pop();else{if(!i)break
 ;Fe(i.arc)}t&&(We(t),Ze(t));var o={cells:ul,edges:il};return ol=ll=il=ul=null,o}function lr(n,t){return t.y-n.y||t.x-n.x}function cr(n,t,e){return(n.x-e.x)*(t.y-n.y)-(n.x-t.x)*(e.y-n.y)}function fr(n){return n.x}function sr(n){return n.y}function hr(){return{leaf:!0,nodes:[],point:null,x:null,y:null}}function pr(n,t,e,r,i,u){if(!n(t,e,r,i,u)){var o=.5*(e+i),a=.5*(r+u),l=t.nodes;l[0]&&pr(n,l[0],e,r,o,a),l[1]&&pr(n,l[1],o,r,i,a),l[2]&&pr(n,l[2],e,a,o,u),l[3]&&pr(n,l[3],o,a,i,u)}}function gr(n,t,e,r,i,u,o){var a,l=1/0;return function c(n,f,s,h,p){if(!(f>u||s>o||r>h||i>p)){if(g=n.point){var g,v=t-n.x,d=e-n.y,y=v*v+d*d;if(l>y){var m=Math.sqrt(l=y);r=t-m,i=e-m,u=t+m,o=e+m,a=g}}for(var M=n.nodes,x=.5*(f+h),b=.5*(s+p),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:c(n,f,s,x,b);break;case 1:c(n,x,s,h,b);break;case 2:c(n,f,b,x,p);break;case 3:c(n,x,b,h,p)}}}(n,r,i,u,o),a}function vr(n,t){n=ao.rgb(n),t=ao.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,o=t.g-r,a=t.b-i;return function
 (n){return"#"+bn(Math.round(e+u*n))+bn(Math.round(r+o*n))+bn(Math.round(i+a*n))}}function dr(n,t){var e,r={},i={};for(e in n)e in t?r[e]=Mr(n[e],t[e]):i[e]=n[e];for(e in t)e in n||(i[e]=t[e]);return function(n){for(e in r)i[e]=r[e](n);return i}}function yr(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function mr(n,t){var e,r,i,u=hl.lastIndex=pl.lastIndex=0,o=-1,a=[],l=[];for(n+="",t+="";(e=hl.exec(n))&&(r=pl.exec(t));)(i=r.index)>u&&(i=t.slice(u,i),a[o]?a[o]+=i:a[++o]=i),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:yr(e,r)})),u=pl.lastIndex;return u<t.length&&(i=t.slice(u),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?(t=l[0].x,function(n){return t(n)+""}):function(){return t}:(t=l.length,function(n){for(var e,r=0;t>r;++r)a[(e=l[r]).i]=e.x(n);return a.join("")})}function Mr(n,t){for(var e,r=ao.interpolators.length;--r>=0&&!(e=ao.interpolators[r](n,t)););return e}function xr(n,t){var e,r=[],i=[],u=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e
 ;++e)r.push(Mr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;o>e;++e)i[e]=t[e];return function(n){for(e=0;a>e;++e)i[e]=r[e](n);return i}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function kr(n){return n*n*n}function Nr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Er(n){return function(t){return Math.pow(t,n)}}function Ar(n){return 1-Math.cos(n*Io)}function Cr(n){return Math.pow(2,10*(n-1))}function zr(n){return 1-Math.sqrt(1-n*n)}function Lr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Ho*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Ho/t)}}function qr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Tr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)
 *n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Rr(n,t){n=ao.hcl(n),t=ao.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,o=t.c-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return sn(e+u*n,r+o*n,i+a*n)+""}}function Dr(n,t){n=ao.hsl(n),t=ao.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,o=t.s-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return cn(e+u*n,r+o*n,i+a*n)+""}}function Pr(n,t){n=ao.lab(n),t=ao.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,o=t.a-r,a=t.b-i;return function(n){return pn(e+u*n,r+o*n,i+a*n)+""}}function Ur(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function jr(n){var t=[n.a,n.b],e=[n.c,n.d],r=Hr(t),i=Fr(t,e),u=Hr(Or(e,t,-i))||0;t[0]*e[1]<e[0]*t[1]&&(t[0]*=-1,t[1]*=-1,r*=-1,i*=-1),this.rotate=(r?Math.atan2(t[1],t[0]):Math.atan2(-e[0],e[1]))*Zo,this.translate=[n.e,n.f],this.scale=[r,u],this.skew=u?Math.atan2(i,u)*Zo:0}function
  Fr(n,t){return n[0]*t[0]+n[1]*t[1]}function Hr(n){var t=Math.sqrt(Fr(n,n));return t&&(n[0]/=t,n[1]/=t),t}function Or(n,t,e){return n[0]+=e*t[0],n[1]+=e*t[1],n}function Ir(n){return n.length?n.pop()+",":""}function Yr(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push("translate(",null,",",null,")");r.push({i:i-4,x:yr(n[0],t[0])},{i:i-2,x:yr(n[1],t[1])})}else(t[0]||t[1])&&e.push("translate("+t+")")}function Zr(n,t,e,r){n!==t?(n-t>180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(Ir(e)+"rotate(",null,")")-2,x:yr(n,t)})):t&&e.push(Ir(e)+"rotate("+t+")")}function Vr(n,t,e,r){n!==t?r.push({i:e.push(Ir(e)+"skewX(",null,")")-2,x:yr(n,t)}):t&&e.push(Ir(e)+"skewX("+t+")")}function Xr(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push(Ir(e)+"scale(",null,",",null,")");r.push({i:i-4,x:yr(n[0],t[0])},{i:i-2,x:yr(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(Ir(e)+"scale("+t+")")}function $r(n,t){var e=[],r=[];return n=ao.transform(n),t=ao.transform(t),Yr(n.translate,t.translate,e,r),Zr(n.rotate,t.r
 otate,e,r),Vr(n.skew,t.skew,e,r),Xr(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,i=-1,u=r.length;++i<u;)e[(t=r[i]).i]=t.x(n);return e.join("")}}function Br(n,t){return t=(t-=n=+n)||1/t,function(e){return(e-n)/t}}function Wr(n,t){return t=(t-=n=+n)||1/t,function(e){return Math.max(0,Math.min(1,(e-n)/t))}}function Jr(n){for(var t=n.source,e=n.target,r=Kr(t,e),i=[t];t!==r;)t=t.parent,i.push(t);for(var u=i.length;e!==r;)i.splice(u,0,e),e=e.parent;return i}function Gr(n){for(var t=[],e=n.parent;null!=e;)t.push(n),n=e,e=e.parent;return t.push(n),t}function Kr(n,t){if(n===t)return n;for(var e=Gr(n),r=Gr(t),i=e.pop(),u=r.pop(),o=null;i===u;)o=i,i=e.pop(),u=r.pop();return o}function Qr(n){n.fixed|=2}function ni(n){n.fixed&=-7}function ti(n){n.fixed|=4,n.px=n.x,n.py=n.y}function ei(n){n.fixed&=-5}function ri(n,t,e){var r=0,i=0;if(n.charge=0,!n.leaf)for(var u,o=n.nodes,a=o.length,l=-1;++l<a;)u=o[l],null!=u&&(ri(u,t,e),n.charge+=u.charge,r+=u.charge*u.cx,i+=u.charge*u.cy);if(n.point){n.l
 eaf||(n.point.x+=Math.random()-.5,n.point.y+=Math.random()-.5);var c=t*e[n.point.index];n.charge+=n.pointCharge=c,r+=c*n.point.x,i+=c*n.point.y}n.cx=r/n.charge,n.cy=i/n.charge}function ii(n,t){return ao.rebind(n,t,"sort","children","value"),n.nodes=n,n.links=fi,n}function ui(n,t){for(var e=[n];null!=(n=e.pop());)if(t(n),(i=n.children)&&(r=i.length))for(var r,i;--r>=0;)e.push(i[r])}function oi(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(u=n.children)&&(i=u.length))for(var i,u,o=-1;++o<i;)e.push(u[o]);for(;null!=(n=r.pop());)t(n)}function ai(n){return n.children}function li(n){return n.value}function ci(n,t){return t.value-n.value}function fi(n){return ao.merge(n.map(function(n){return(n.children||[]).map(function(t){return{source:n,target:t}})}))}function si(n){return n.x}function hi(n){return n.y}function pi(n,t,e){n.y0=t,n.y=e}function gi(n){return ao.range(n.length)}function vi(n){for(var t=-1,e=n[0].length,r=[];++t<e;)r[t]=0;return r}function di(n){for(var t,e=1,r=0,
 i=n[0][1],u=n.length;u>e;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function yi(n){return n.reduce(mi,0)}function mi(n,t){return n+t[1]}function Mi(n,t){return xi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function xi(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function bi(n){return[ao.min(n),ao.max(n)]}function _i(n,t){return n.value-t.value}function wi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Si(n,t){n._pack_next=t,t._pack_prev=n}function ki(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return.999*i*i>e*e+r*r}function Ni(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),p=Math.max(n.y+n.r,p)}if((e=n.children)&&(c=e.length)){var e,r,i,u,o,a,l,c,f=1/0,s=-(1/0),h=1/0,p=-(1/0);if(e.forEach(Ei),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(i=e[1],i.x=i.r,i.y=0,t(i),c>2))for(u=e[2],zi(r,i,u),t(u),wi(r,u),r._pack_prev=u,wi(u,i),i=r._pack_next,o=3;c>o;o++){zi(r,i,u=e[o]);var g=0,v=1,d=1;for(a=i._pack_
 next;a!==i;a=a._pack_next,v++)if(ki(a,u)){g=1;break}if(1==g)for(l=r._pack_prev;l!==a._pack_prev&&!ki(l,u);l=l._pack_prev,d++);g?(d>v||v==d&&i.r<r.r?Si(r,i=a):Si(r=l,i),o--):(wi(r,u),i=u,t(u))}var y=(f+s)/2,m=(h+p)/2,M=0;for(o=0;c>o;o++)u=e[o],u.x-=y,u.y-=m,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(Ai)}}function Ei(n){n._pack_next=n._pack_prev=n}function Ai(n){delete n._pack_next,delete n._pack_prev}function Ci(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,o=i.length;++u<o;)Ci(i[u],t,e,r)}function zi(n,t,e){var r=n.r+e.r,i=t.x-n.x,u=t.y-n.y;if(r&&(i||u)){var o=t.r+e.r,a=i*i+u*u;o*=o,r*=r;var l=.5+(r-o)/(2*a),c=Math.sqrt(Math.max(0,2*o*(r+a)-(r-=a)*r-o*o))/(2*a);e.x=n.x+l*i+c*u,e.y=n.y+l*u-c*i}else e.x=n.x+r,e.y=n.y}function Li(n,t){return n.parent==t.parent?1:2}function qi(n){var t=n.children;return t.length?t[0]:n.t}function Ti(n){var t,e=n.children;return(t=e.length)?e[t-1]:n.t}function Ri(n,t,e){var r=e/(t.i-n.i);t.c-=r,t.s+=e,n.c+
 =r,t.z+=e,t.m+=e}function Di(n){for(var t,e=0,r=0,i=n.children,u=i.length;--u>=0;)t=i[u],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Pi(n,t,e){return n.a.parent===t.parent?n.a:e}function Ui(n){return 1+ao.max(n,function(n){return n.y})}function ji(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Fi(n){var t=n.children;return t&&t.length?Fi(t[0]):n}function Hi(n){var t,e=n.children;return e&&(t=e.length)?Hi(e[t-1]):n}function Oi(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Ii(n,t){var e=n.x+t[3],r=n.y+t[0],i=n.dx-t[1]-t[3],u=n.dy-t[0]-t[2];return 0>i&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Yi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Zi(n){return n.rangeExtent?n.rangeExtent():Yi(n.range())}function Vi(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Xi(n,t){var e,r=0,i=n.length-1,u=n[r],o=n[i];return u>o&&(e=r,r=i,i=e,e=u,u=o,o=e),n[r]=t.floor(u),n[i]=t.ceil(o),n}function $i(n){return n?{f
 loor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:Sl}function Bi(n,t,e,r){var i=[],u=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]<n[0]&&(n=n.slice().reverse(),t=t.slice().reverse());++o<=a;)i.push(e(n[o-1],n[o])),u.push(r(t[o-1],t[o]));return function(t){var e=ao.bisect(n,t,1,a)-1;return u[e](i[e](t))}}function Wi(n,t,e,r){function i(){var i=Math.min(n.length,t.length)>2?Bi:Vi,l=r?Wr:Br;return o=i(n,t,l,e),a=i(t,n,l,Mr),u}function u(n){return o(n)}var o,a;return u.invert=function(n){return a(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Ur)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Qi(n,t)},u.tickFormat=function(t,e){return nu(n,t,e)},u.nice=function(t){return Gi(n,t),i()},u.copy=function(){return Wi(n,
 t,e,r)},i()}function Ji(n,t){return ao.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Gi(n,t){return Xi(n,$i(Ki(n,t)[2])),Xi(n,$i(Ki(n,t)[2])),n}function Ki(n,t){null==t&&(t=10);var e=Yi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Qi(n,t){return ao.range.apply(ao,Ki(n,t))}function nu(n,t,e){var r=Ki(n,t);if(e){var i=ha.exec(e);if(i.shift(),"s"===i[8]){var u=ao.formatPrefix(Math.max(xo(r[0]),xo(r[1])));return i[7]||(i[7]="."+tu(u.scale(r[2]))),i[8]="f",e=ao.format(i.join("")),function(n){return e(u.scale(n))+u.symbol}}i[7]||(i[7]="."+eu(i[8],r)),e=i.join("")}else e=",."+tu(r[2])+"f";return ao.format(e)}function tu(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function eu(n,t){var e=tu(t[2]);return n in kl?Math.abs(e-tu(Math.max(xo(t[0]),xo(t[1]))))+ +("e"!==n):e-2*("%"===n)}function ru(n,t,e,r){function i(n){return(e?
 Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function u(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(i(t))}return o.invert=function(t){return u(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(i)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(i)),o):t},o.nice=function(){var t=Xi(r.map(i),e?Math:El);return n.domain(t),r=t.map(u),o},o.ticks=function(){var n=Yi(r),o=[],a=n[0],l=n[1],c=Math.floor(i(a)),f=Math.ceil(i(l)),s=t%1?2:t;if(isFinite(f-c)){if(e){for(;f>c;c++)for(var h=1;s>h;h++)o.push(u(c)*h);o.push(u(c))}else for(o.push(u(c));c++<f;)for(var h=s-1;h>0;h--)o.push(u(c)*h);for(c=0;o[c]<a;c++);for(f=o.length;o[f-1]>l;f--);o=o.slice(c,f)}return o},o.tickFormat=function(n,e){if(!arguments.length)return Nl;arguments.length<2?e=Nl:"function"!=typeof e&&(e=ao.format(e));var r=Math.max(1,t*n/o.ticks().length);return function(n){var o=n/u(Math.round(i(n)));return t-.5>o*t&&(o*=t),r>=o?e(n)
 :""}},o.copy=function(){return ru(n.copy(),t,e,r)},Ji(o,n)}function iu(n,t,e){function r(t){return n(i(t))}var i=uu(t),u=uu(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Qi(e,n)},r.tickFormat=function(n,t){return nu(e,n,t)},r.nice=function(n){return r.domain(Gi(e,n))},r.exponent=function(o){return arguments.length?(i=uu(t=o),u=uu(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return iu(n.copy(),t,e)},Ji(r,n)}function uu(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function ou(n,t){function e(e){return u[((i.get(e)||("range"===t.t?i.set(e,n.push(e)):NaN))-1)%u.length]}function r(t,e){return ao.range(n.length).map(function(n){return t+e*n})}var i,u,o;return e.domain=function(r){if(!arguments.length)return n;n=[],i=new c;for(var u,o=-1,a=r.length;++o<a;)i.has(u=r[o])||i.set(u,n.push(u));return e[t.t].apply(e,t.a)},e.range=function(n){return arg
 uments.length?(u=n,o=0,t={t:"range",a:arguments},e):u},e.rangePoints=function(i,a){arguments.length<2&&(a=0);var l=i[0],c=i[1],f=n.length<2?(l=(l+c)/2,0):(c-l)/(n.length-1+a);return u=r(l+f*a/2,f),o=0,t={t:"rangePoints",a:arguments},e},e.rangeRoundPoints=function(i,a){arguments.length<2&&(a=0);var l=i[0],c=i[1],f=n.length<2?(l=c=Math.round((l+c)/2),0):(c-l)/(n.length-1+a)|0;return u=r(l+Math.round(f*a/2+(c-l-(n.length-1+a)*f)/2),f),o=0,t={t:"rangeRoundPoints",a:arguments},e},e.rangeBands=function(i,a,l){arguments.length<2&&(a=0),arguments.length<3&&(l=a);var c=i[1]<i[0],f=i[c-0],s=i[1-c],h=(s-f)/(n.length-a+2*l);return u=r(f+h*l,h),c&&u.reverse(),o=h*(1-a),t={t:"rangeBands",a:arguments},e},e.rangeRoundBands=function(i,a,l){arguments.length<2&&(a=0),arguments.length<3&&(l=a);var c=i[1]<i[0],f=i[c-0],s=i[1-c],h=Math.floor((s-f)/(n.length-a+2*l));return u=r(f+Math.round((s-f-(n.length-a)*h)/2),h),c&&u.reverse(),o=Math.round(h*(1-a)),t={t:"rangeRoundBands",a:arguments},e},e.rangeBand=fu
 nction(){return o},e.rangeExtent=function(){return Yi(t.a[0])},e.copy=function(){return ou(n,t)},e.domain(n)}function au(n,t){function u(){var e=0,r=t.length;for(a=[];++e<r;)a[e-1]=ao.quantile(n,e/r);return o}function o(n){return isNaN(n=+n)?void 0:t[ao.bisect(a,n)]}var a;return o.domain=function(t){return arguments.length?(n=t.map(r).filter(i).sort(e),u()):n},o.range=function(n){return arguments.length?(t=n,u()):t},o.quantiles=function(){return a},o.invertExtent=function(e){return e=t.indexOf(e),0>e?[NaN,NaN]:[e>0?a[e-1]:n[0],e<a.length?a[e]:n[n.length-1]]},o.copy=function(){return au(n,t)},u()}function lu(n,t,e){function r(t){return e[Math.max(0,Math.min(o,Math.floor(u*(t-n))))]}function i(){return u=e.length/(t-n),o=e.length-1,r}var u,o;return r.domain=function(e){return arguments.length?(n=+e[0],t=+e[e.length-1],i()):[n,t]},r.range=function(n){return arguments.length?(e=n,i()):e},r.invertExtent=function(t){return t=e.indexOf(t),t=0>t?NaN:t/u+n,[t,t+1/u]},r.copy=function(){return
  lu(n,t,e)},i()}function cu(n,t){function e(e){return e>=e?t[ao.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return cu(n,t)},e}function fu(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Qi(n,t)},t.tickFormat=function(t,e){return nu(n,t,e)},t.copy=function(){return fu(n)},t}function su(){return 0}function hu(n){return n.innerRadius}function pu(n){return n.outerRadius}function gu(n){return n.startAngle}function vu(n){return n.endAngle}function du(n){return n&&n.padAngle}function yu(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function mu(n,t,e,r,i){var u=n[0]-t[0],o=n[1]-t[1],a=(i?r:-r)/Math.sqrt(u*u+o*o),l=a*o,c=-a*u,f=n[0]+l,s=n[1]+c,h=t[0]+l,p=t[1]+c,g=(f+h)/2,v=(s+p)/2,d=h-f,y=p-s,m=d*d+y*y,M=e-r,x=f*p-h*s,b=(0>y?-1:1)*Math
 .sqrt(Math.max(0,M*M*m-x*x)),_=(x*y-d*b)/m,w=(-x*d-y*b)/m,S=(x*y+d*b)/m,k=(-x*d+y*b)/m,N=_-g,E=w-v,A=S-g,C=k-v;return N*N+E*E>A*A+C*C&&(_=S,w=k),[[_-l,w-c],[_*e/M,w*e/M]]}function Mu(n){function t(t){function o(){c.push("M",u(n(f),a))}for(var l,c=[],f=[],s=-1,h=t.length,p=En(e),g=En(r);++s<h;)i.call(this,l=t[s],s)?f.push([+p.call(this,l,s),+g.call(this,l,s)]):f.length&&(o(),f=[]);return f.length&&o(),c.length?c.join(""):null}var e=Ce,r=ze,i=zt,u=xu,o=u.key,a=.7;return t.x=function(n){return arguments.length?(e=n,t):e},t.y=function(n){return arguments.length?(r=n,t):r},t.defined=function(n){return arguments.length?(i=n,t):i},t.interpolate=function(n){return arguments.length?(o="function"==typeof n?u=n:(u=Tl.get(n)||xu).key,t):o},t.tension=function(n){return arguments.length?(a=n,t):a},t}function xu(n){return n.length>1?n.join("L"):n+"Z"}function bu(n){return n.join("L")+"Z"}function _u(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t<e;)i.push("H",(r[0]+(r=n[t])[0])/2,"V",r[1])
 ;return e>1&&i.push("H",r[0]),i.join("")}function wu(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t<e;)i.push("V",(r=n[t])[1],"H",r[0]);return i.join("")}function Su(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t<e;)i.push("H",(r=n[t])[0],"V",r[1]);return i.join("")}function ku(n,t){return n.length<4?xu(n):n[1]+Au(n.slice(1,-1),Cu(n,t))}function Nu(n,t){return n.length<3?bu(n):n[0]+Au((n.push(n[0]),n),Cu([n[n.length-2]].concat(n,[n[1]]),t))}function Eu(n,t){return n.length<3?xu(n):n[0]+Au(n,Cu(n,t))}function Au(n,t){if(t.length<1||n.length!=t.length&&n.length!=t.length+2)return xu(n);var e=n.length!=t.length,r="",i=n[0],u=n[1],o=t[0],a=o,l=1;if(e&&(r+="Q"+(u[0]-2*o[0]/3)+","+(u[1]-2*o[1]/3)+","+u[0]+","+u[1],i=n[1],l=2),t.length>1){a=t[1],u=n[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(u[0]-a[0])+","+(u[1]-a[1])+","+u[0]+","+u[1];for(var c=2;c<t.length;c++,l++)u=n[l],a=t[c],r+="S"+(u[0]-a[0])+","+(u[1]-a[1])+","+u[0]+","+u[1]}if(e){var f=n[l];r+="Q"+(u[0]+2*a[0]/3
 )+","+(u[1]+2*a[1]/3)+","+f[0]+","+f[1]}return r}function Cu(n,t){for(var e,r=[],i=(1-t)/2,u=n[0],o=n[1],a=1,l=n.length;++a<l;)e=u,u=o,o=n[a],r.push([i*(o[0]-e[0]),i*(o[1]-e[1])]);return r}function zu(n){if(n.length<3)return xu(n);var t=1,e=n.length,r=n[0],i=r[0],u=r[1],o=[i,i,i,(r=n[1])[0]],a=[u,u,u,r[1]],l=[i,",",u,"L",Ru(Pl,o),",",Ru(Pl,a)];for(n.push(n[e-1]);++t<=e;)r=n[t],o.shift(),o.push(r[0]),a.shift(),a.push(r[1]),Du(l,o,a);return n.pop(),l.push("L",r),l.join("")}function Lu(n){if(n.length<4)return xu(n);for(var t,e=[],r=-1,i=n.length,u=[0],o=[0];++r<3;)t=n[r],u.push(t[0]),o.push(t[1]);for(e.push(Ru(Pl,u)+","+Ru(Pl,o)),--r;++r<i;)t=n[r],u.shift(),u.push(t[0]),o.shift(),o.push(t[1]),Du(e,u,o);return e.join("")}function qu(n){for(var t,e,r=-1,i=n.length,u=i+4,o=[],a=[];++r<4;)e=n[r%i],o.push(e[0]),a.push(e[1]);for(t=[Ru(Pl,o),",",Ru(Pl,a)],--r;++r<u;)e=n[r%i],o.shift(),o.push(e[0]),a.shift(),a.push(e[1]),Du(t,o,a);return t.join("")}function Tu(n,t){var e=n.length-1;if(e)for(va
 r r,i,u=n[0][0],o=n[0][1],a=n[e][0]-u,l=n[e][1]-o,c=-1;++c<=e;)r=n[c],i=c/e,r[0]=t*r[0]+(1-t)*(u+i*a),r[1]=t*r[1]+(1-t)*(o+i*l);return zu(n)}function Ru(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]}function Du(n,t,e){n.push("C",Ru(Rl,t),",",Ru(Rl,e),",",Ru(Dl,t),",",Ru(Dl,e),",",Ru(Pl,t),",",Ru(Pl,e))}function Pu(n,t){return(t[1]-n[1])/(t[0]-n[0])}function Uu(n){for(var t=0,e=n.length-1,r=[],i=n[0],u=n[1],o=r[0]=Pu(i,u);++t<e;)r[t]=(o+(o=Pu(i=u,u=n[t+1])))/2;return r[t]=o,r}function ju(n){for(var t,e,r,i,u=[],o=Uu(n),a=-1,l=n.length-1;++a<l;)t=Pu(n[a],n[a+1]),xo(t)<Uo?o[a]=o[a+1]=0:(e=o[a]/t,r=o[a+1]/t,i=e*e+r*r,i>9&&(i=3*t/Math.sqrt(i),o[a]=i*e,o[a+1]=i*r));for(a=-1;++a<=l;)i=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),u.push([i||0,o[a]*i||0]);return u}function Fu(n){return n.length<3?xu(n):n[0]+Au(n,ju(n))}function Hu(n){for(var t,e,r,i=-1,u=n.length;++i<u;)t=n[i],e=t[0],r=t[1]-Io,t[0]=e*Math.cos(r),t[1]=e*Math.sin(r);return n}function Ou(n){function t(t
 ){function l(){v.push("M",a(n(y),s),f,c(n(d.reverse()),s),"Z")}for(var h,p,g,v=[],d=[],y=[],m=-1,M=t.length,x=En(e),b=En(i),_=e===r?function(){
+return p}:En(r),w=i===u?function(){return g}:En(u);++m<M;)o.call(this,h=t[m],m)?(d.push([p=+x.call(this,h,m),g=+b.call(this,h,m)]),y.push([+_.call(this,h,m),+w.call(this,h,m)])):d.length&&(l(),d=[],y=[]);return d.length&&l(),v.length?v.join(""):null}var e=Ce,r=Ce,i=0,u=ze,o=zt,a=xu,l=a.key,c=a,f="L",s=.7;return t.x=function(n){return arguments.length?(e=r=n,t):r},t.x0=function(n){return arguments.length?(e=n,t):e},t.x1=function(n){return arguments.length?(r=n,t):r},t.y=function(n){return arguments.length?(i=u=n,t):u},t.y0=function(n){return arguments.length?(i=n,t):i},t.y1=function(n){return arguments.length?(u=n,t):u},t.defined=function(n){return arguments.length?(o=n,t):o},t.interpolate=function(n){return arguments.length?(l="function"==typeof n?a=n:(a=Tl.get(n)||xu).key,c=a.reverse||a,f=a.closed?"M":"L",t):l},t.tension=function(n){return arguments.length?(s=n,t):s},t}function Iu(n){return n.radius}function Yu(n){return[n.x,n.y]}function Zu(n){return function(){var t=n.apply(this,
 arguments),e=t[0],r=t[1]-Io;return[e*Math.cos(r),e*Math.sin(r)]}}function Vu(){return 64}function Xu(){return"circle"}function $u(n){var t=Math.sqrt(n/Fo);return"M0,"+t+"A"+t+","+t+" 0 1,1 0,"+-t+"A"+t+","+t+" 0 1,1 0,"+t+"Z"}function Bu(n){return function(){var t,e,r;(t=this[n])&&(r=t[e=t.active])&&(r.timer.c=null,r.timer.t=NaN,--t.count?delete t[e]:delete this[n],t.active+=.5,r.event&&r.event.interrupt.call(this,this.__data__,r.index))}}function Wu(n,t,e){return ko(n,Yl),n.namespace=t,n.id=e,n}function Ju(n,t,e,r){var i=n.id,u=n.namespace;return Y(n,"function"==typeof e?function(n,o,a){n[u][i].tween.set(t,r(e.call(n,n.__data__,o,a)))}:(e=r(e),function(n){n[u][i].tween.set(t,e)}))}function Gu(n){return null==n&&(n=""),function(){this.textContent=n}}function Ku(n){return null==n?"__transition__":"__transition_"+n+"__"}function Qu(n,t,e,r,i){function u(n){var t=v.delay;return f.t=t+l,n>=t?o(n-t):void(f.c=o)}function o(e){var i=g.active,u=g[i];u&&(u.timer.c=null,u.timer.t=NaN,--g.coun
 t,delete g[i],u.event&&u.event.interrupt.call(n,n.__data__,u.index));for(var o in g)if(r>+o){var c=g[o];c.timer.c=null,c.timer.t=NaN,--g.count,delete g[o]}f.c=a,qn(function(){return f.c&&a(e||1)&&(f.c=null,f.t=NaN),1},0,l),g.active=r,v.event&&v.event.start.call(n,n.__data__,t),p=[],v.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&p.push(r)}),h=v.ease,s=v.duration}function a(i){for(var u=i/s,o=h(u),a=p.length;a>0;)p[--a].call(n,o);return u>=1?(v.event&&v.event.end.call(n,n.__data__,t),--g.count?delete g[r]:delete n[e],1):void 0}var l,f,s,h,p,g=n[e]||(n[e]={active:0,count:0}),v=g[r];v||(l=i.time,f=qn(u,0,l),v=g[r]={tween:new c,time:l,timer:f,delay:i.delay,duration:i.duration,ease:i.ease,index:t},i=null,++g.count)}function no(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function to(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function eo(n){return n.toISOString()}function ro
 (n,t,e){function r(t){return n(t)}function i(n,e){var r=n[1]-n[0],i=r/e,u=ao.bisect(Kl,i);return u==Kl.length?[t.year,Ki(n.map(function(n){return n/31536e6}),e)[2]]:u?t[i/Kl[u-1]<Kl[u]/i?u-1:u]:[tc,Ki(n,e)[2]]}return r.invert=function(t){return io(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain(t),r):n.domain().map(io)},r.nice=function(n,t){function e(e){return!isNaN(e)&&!n.range(e,io(+e+1),t).length}var u=r.domain(),o=Yi(u),a=null==n?i(o,10):"number"==typeof n&&i(o,n);return a&&(n=a[0],t=a[1]),r.domain(Xi(u,t>1?{floor:function(t){for(;e(t=n.floor(t));)t=io(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=io(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Yi(r.domain()),u=null==n?i(e,10):"number"==typeof n?i(e,n):!n.range&&[{range:n},t];return u&&(n=u[0],t=u[1]),n.range(e[0],io(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return ro(n.copy(),t,e)},Ji(r,n)}function io(n){return new Date(n)}function uo(n){return JSON.parse(n.respon
 seText)}function oo(n){var t=fo.createRange();return t.selectNode(fo.body),t.createContextualFragment(n.responseText)}var ao={version:"3.5.17"},lo=[].slice,co=function(n){return lo.call(n)},fo=this.document;if(fo)try{co(fo.documentElement.childNodes)[0].nodeType}catch(so){co=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),fo)try{fo.createElement("DIV").style.setProperty("opacity",0,"")}catch(ho){var po=this.Element.prototype,go=po.setAttribute,vo=po.setAttributeNS,yo=this.CSSStyleDeclaration.prototype,mo=yo.setProperty;po.setAttribute=function(n,t){go.call(this,n,t+"")},po.setAttributeNS=function(n,t,e){vo.call(this,n,t,e+"")},yo.setProperty=function(n,t,e){mo.call(this,n,t+"",e)}}ao.ascending=e,ao.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},ao.min=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i<u;)if(null!=(r=n[i])&&r>=r){e=r;break}for(;++i<u;)null!=(r=n[i])&&e>r&&(e=r)}e
 lse{for(;++i<u;)if(null!=(r=t.call(n,n[i],i))&&r>=r){e=r;break}for(;++i<u;)null!=(r=t.call(n,n[i],i))&&e>r&&(e=r)}return e},ao.max=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i<u;)if(null!=(r=n[i])&&r>=r){e=r;break}for(;++i<u;)null!=(r=n[i])&&r>e&&(e=r)}else{for(;++i<u;)if(null!=(r=t.call(n,n[i],i))&&r>=r){e=r;break}for(;++i<u;)null!=(r=t.call(n,n[i],i))&&r>e&&(e=r)}return e},ao.extent=function(n,t){var e,r,i,u=-1,o=n.length;if(1===arguments.length){for(;++u<o;)if(null!=(r=n[u])&&r>=r){e=i=r;break}for(;++u<o;)null!=(r=n[u])&&(e>r&&(e=r),r>i&&(i=r))}else{for(;++u<o;)if(null!=(r=t.call(n,n[u],u))&&r>=r){e=i=r;break}for(;++u<o;)null!=(r=t.call(n,n[u],u))&&(e>r&&(e=r),r>i&&(i=r))}return[e,i]},ao.sum=function(n,t){var e,r=0,u=n.length,o=-1;if(1===arguments.length)for(;++o<u;)i(e=+n[o])&&(r+=e);else for(;++o<u;)i(e=+t.call(n,n[o],o))&&(r+=e);return r},ao.mean=function(n,t){var e,u=0,o=n.length,a=-1,l=o;if(1===arguments.length)for(;++a<o;)i(e=r(n[a]))?u+=e:--l;els
 e for(;++a<o;)i(e=r(t.call(n,n[a],a)))?u+=e:--l;return l?u/l:void 0},ao.quantile=function(n,t){var e=(n.length-1)*t+1,r=Math.floor(e),i=+n[r-1],u=e-r;return u?i+u*(n[r]-i):i},ao.median=function(n,t){var u,o=[],a=n.length,l=-1;if(1===arguments.length)for(;++l<a;)i(u=r(n[l]))&&o.push(u);else for(;++l<a;)i(u=r(t.call(n,n[l],l)))&&o.push(u);return o.length?ao.quantile(o.sort(e),.5):void 0},ao.variance=function(n,t){var e,u,o=n.length,a=0,l=0,c=-1,f=0;if(1===arguments.length)for(;++c<o;)i(e=r(n[c]))&&(u=e-a,a+=u/++f,l+=u*(e-a));else for(;++c<o;)i(e=r(t.call(n,n[c],c)))&&(u=e-a,a+=u/++f,l+=u*(e-a));return f>1?l/(f-1):void 0},ao.deviation=function(){var n=ao.variance.apply(this,arguments);return n?Math.sqrt(n):n};var Mo=u(e);ao.bisectLeft=Mo.left,ao.bisect=ao.bisectRight=Mo.right,ao.bisector=function(n){return u(1===n.length?function(t,r){return e(n(t),r)}:n)},ao.shuffle=function(n,t,e){(u=arguments.length)<3&&(e=n.length,2>u&&(t=0));for(var r,i,u=e-t;u;)i=Math.random()*u--|0,r=n[u+t],n[u+
 t]=n[i+t],n[i+t]=r;return n},ao.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ao.pairs=function(n){for(var t,e=0,r=n.length-1,i=n[0],u=new Array(0>r?0:r);r>e;)u[e]=[t=i,i=n[++e]];return u},ao.transpose=function(n){if(!(i=n.length))return[];for(var t=-1,e=ao.min(n,o),r=new Array(e);++t<e;)for(var i,u=-1,a=r[t]=new Array(i);++u<i;)a[u]=n[u][t];return r},ao.zip=function(){return ao.transpose(arguments)},ao.keys=function(n){var t=[];for(var e in n)t.push(e);return t},ao.values=function(n){var t=[];for(var e in n)t.push(n[e]);return t},ao.entries=function(n){var t=[];for(var e in n)t.push({key:e,value:n[e]});return t},ao.merge=function(n){for(var t,e,r,i=n.length,u=-1,o=0;++u<i;)o+=n[u].length;for(e=new Array(o);--i>=0;)for(r=n[i],t=r.length;--t>=0;)e[--o]=r[t];return e};var xo=Math.abs;ao.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,i=[],u=a(xo(e)),o=-1;if(n*=u
 ,t*=u,e*=u,0>e)for(;(r=n+e*++o)>t;)i.push(r/u);else for(;(r=n+e*++o)<t;)i.push(r/u);return i},ao.map=function(n,t){var e=new c;if(n instanceof c)n.forEach(function(n,t){e.set(n,t)});else if(Array.isArray(n)){var r,i=-1,u=n.length;if(1===arguments.length)for(;++i<u;)e.set(i,n[i]);else for(;++i<u;)e.set(t.call(n,r=n[i],i),r)}else for(var o in n)e.set(o,n[o]);return e};var bo="__proto__",_o="\x00";l(c,{has:h,get:function(n){return this._[f(n)]},set:function(n,t){return this._[f(n)]=t},remove:p,keys:g,values:function(){var n=[];for(var t in this._)n.push(this._[t]);return n},entries:function(){var n=[];for(var t in this._)n.push({key:s(t),value:this._[t]});return n},size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,s(t),this._[t])}}),ao.nest=function(){function n(t,o,a){if(a>=u.length)return r?r.call(i,o):e?o.sort(e):o;for(var l,f,s,h,p=-1,g=o.length,v=u[a++],d=new c;++p<g;)(h=d.get(l=v(f=o[p])))?h.push(f):d.set(l,[f]);return t?(f=t(),s=function(e,r){f.set(e,n(t,r,a))})
 :(f={},s=function(e,r){f[e]=n(t,r,a)}),d.forEach(s),f}function t(n,e){if(e>=u.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,i={},u=[],o=[];return i.map=function(t,e){return n(e,t,0)},i.entries=function(e){return t(n(ao.map,e,0),0)},i.key=function(n){return u.push(n),i},i.sortKeys=function(n){return o[u.length-1]=n,i},i.sortValues=function(n){return e=n,i},i.rollup=function(n){return r=n,i},i},ao.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+="")]=!0,n},remove:p,values:g,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),ao.behavior={},ao.rebind=function(n,t){for(var e,r=1,i=arguments.length;++r<i;)n[e=arguments[r]]=M(n,t,t[e]);return n};var wo=["webkit","ms","moz","Moz","o","O"];ao.dispatch=function(){for(var n=new _,t=-1,e=arguments.length;++t<e;)n[arguments[t]]=w(n);
 return n},_.prototype.on=function(n,t){var e=n.indexOf("."),r="";if(e>=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ao.event=null,ao.requote=function(n){return n.replace(So,"\\$&")};var So=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ko={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},No=function(n,t){return t.querySelector(n)},Eo=function(n,t){return t.querySelectorAll(n)},Ao=function(n,t){var e=n.matches||n[x(n,"matchesSelector")];return(Ao=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(No=function(n,t){return Sizzle(n,t)[0]||null},Eo=Sizzle,Ao=Sizzle.matchesSelector),ao.selection=function(){return ao.select(fo.documentElement)};var Co=ao.selection.prototype=[];Co.select=function(n){var t,e,r,i,u=[];n=A(n);for(var o=-1,a=this.length;++o<a;){u.push(t=[]),t.parentNode=(r=this[o]).parentN
 ode;for(var l=-1,c=r.length;++l<c;)(i=r[l])?(t.push(e=n.call(i,i.__data__,l,o)),e&&"__data__"in i&&(e.__data__=i.__data__)):t.push(null)}return E(u)},Co.selectAll=function(n){var t,e,r=[];n=C(n);for(var i=-1,u=this.length;++i<u;)for(var o=this[i],a=-1,l=o.length;++a<l;)(e=o[a])&&(r.push(t=co(n.call(e,e.__data__,a,i))),t.parentNode=e);return E(r)};var zo="http://www.w3.org/1999/xhtml",Lo={svg:"http://www.w3.org/2000/svg",xhtml:zo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};ao.ns={prefix:Lo,qualify:function(n){var t=n.indexOf(":"),e=n;return t>=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),Lo.hasOwnProperty(e)?{space:Lo[e],local:n}:n}},Co.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ao.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},Co.classed=function(n,t){if(argument
 s.length<2){if("string"==typeof n){var e=this.node(),r=(n=T(n)).length,i=-1;if(t=e.classList){for(;++i<r;)if(!t.contains(n[i]))return!1}else for(t=e.getAttribute("class");++i<r;)if(!q(n[i]).test(t))return!1;return!0}for(t in n)this.each(R(t,n[t]));return this}return this.each(R(n,t))},Co.style=function(n,e,r){var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(e="");for(r in n)this.each(P(r,n[r],e));return this}if(2>i){var u=this.node();return t(u).getComputedStyle(u,null).getPropertyValue(n)}r=""}return this.each(P(n,e,r))},Co.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(U(t,n[t]));return this}return this.each(U(n,t))},Co.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},Co.html=function(n){return arguments.length?this.ea
 ch("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},Co.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},Co.insert=function(n,t){return n=j(n),t=A(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},Co.remove=function(){return this.each(F)},Co.data=function(n,t){function e(n,e){var r,i,u,o=n.length,s=e.length,h=Math.min(o,s),p=new Array(s),g=new Array(s),v=new Array(o);if(t){var d,y=new c,m=new Array(o);for(r=-1;++r<o;)(i=n[r])&&(y.has(d=t.call(i,i.__data__,r))?v[r]=i:y.set(d,i),m[r]=d);for(r=-1;++r<s;)(i=y.get(d=t.call(e,u=e[r],r)))?i!==!0&&(p[r]=i,i.__data__=u):g[r]=H(u),y.set(d,!0);for(r=-1;++r<o;)r in m&&y.get(m[r])!==!0&&(v[r]=n[r])}else{for(r=-1;++r<h;)i=n[r],u=e[r],i?(i.__data__=u,p[r]=i):g[r]=H(u);for(;s>r;++r)g[r]=H(e[r]);for(;o>r
 ;++r)v[r]=n[r]}g.update=p,g.parentNode=p.parentNode=v.parentNode=n.parentNode,a.push(g),l.push(p),f.push(v)}var r,i,u=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++u<o;)(i=r[u])&&(n[u]=i.__data__);return n}var a=Z([]),l=E([]),f=E([]);if("function"==typeof n)for(;++u<o;)e(r=this[u],n.call(r,r.parentNode.__data__,u));else for(;++u<o;)e(r=this[u],n);return l.enter=function(){return a},l.exit=function(){return f},l},Co.datum=function(n){return arguments.length?this.property("__data__",n):this.property("__data__")},Co.filter=function(n){var t,e,r,i=[];"function"!=typeof n&&(n=O(n));for(var u=0,o=this.length;o>u;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return E(i)},Co.order=function(){for(var n=-1,t=this.length;++n<t;)for(var e,r=this[n],i=r.length-1,u=r[i];--i>=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Co.sort=function(n){n=
 I.apply(this,arguments);for(var t=-1,e=this.length;++t<e;)this[t].sort(n);return this.order()},Co.each=function(n){return Y(this,function(t,e,r){n.call(t,t.__data__,e,r)})},Co.call=function(n){var t=co(arguments);return n.apply(t[0]=this,t),this},Co.empty=function(){return!this.node()},Co.node=function(){for(var n=0,t=this.length;t>n;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Co.size=function(){var n=0;return Y(this,function(){++n}),n};var qo=[];ao.selection.enter=Z,ao.selection.enter.prototype=qo,qo.append=Co.append,qo.empty=Co.empty,qo.node=Co.node,qo.call=Co.call,qo.size=Co.size,qo.select=function(n){for(var t,e,r,i,u,o=[],a=-1,l=this.length;++a<l;){r=(i=this[a]).update,o.push(t=[]),t.parentNode=i.parentNode;for(var c=-1,f=i.length;++c<f;)(u=i[c])?(t.push(r[c]=e=n.call(i.parentNode,u.__data__,c,a)),e.__data__=u.__data__):t.push(null)}return E(o)},qo.insert=function(n,t){return arguments.length<2&&(t=V(this)),Co.insert.call(this,n,t)},ao.se
 lect=function(t){var e;return"string"==typeof t?(e=[No(t,fo)],e.parentNode=fo.documentElement):(e=[t],e.parentNode=n(t)),E([e])},ao.selectAll=function(n){var t;return"string"==typeof n?(t=co(Eo(n,fo)),t.parentNode=fo.documentElement):(t=co(n),t.parentNode=null),E([t])},Co.on=function(n,t,e){var r=arguments.length;if(3>r){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var To=ao.map({mouseenter:"mouseover",mouseleave:"mouseout"});fo&&To.forEach(function(n){"on"+n in fo&&To.remove(n)});var Ro,Do=0;ao.mouse=function(n){return J(n,k())};var Po=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ao.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,i=0,u=t.length;u>i;++i)if((r=t[i]).identifier===e)return J(n,r)},ao.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",o)}function e(n,t,e,u,o){return functi
 on(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],g|=n|e,M=r,p({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,v)&&(y.on(u+d,null).on(o+d,null),m(g),p({type:"dragend"}))}var c,f=this,s=ao.event.target.correspondingElement||ao.event.target,h=f.parentNode,p=r.of(f,arguments),g=0,v=n(),d=".drag"+(null==v?"":"-"+v),y=ao.select(e(s)).on(u+d,a).on(o+d,l),m=W(s),M=t(h,v);i?(c=i.apply(f,arguments),c=[c.x-M[0],c.y-M[1]]):c=[0,0],p({type:"dragstart"})}}var r=N(n,"drag","dragstart","dragend"),i=null,u=e(b,ao.mouse,t,"mousemove","mouseup"),o=e(G,ao.touch,m,"touchmove","touchend");return n.origin=function(t){return arguments.length?(i=t,n):i},ao.rebind(n,r,"on")},ao.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?co(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Uo=1e-6,jo=Uo*Uo,Fo=Math.PI,Ho=2*Fo,Oo=Ho-Uo,Io=Fo/2,Yo=Fo/180,Zo=180/Fo,Vo=Math.SQRT2,Xo=2,$o=4;ao.interpolateZoom=function(n,t){var e,r,i=n[0],u=n[1],o=n[
 2],a=t[0],l=t[1],c=t[2],f=a-i,s=l-u,h=f*f+s*s;if(jo>h)r=Math.log(c/o)/Vo,e=function(n){return[i+n*f,u+n*s,o*Math.exp(Vo*n*r)]};else{var p=Math.sqrt(h),g=(c*c-o*o+$o*h)/(2*o*Xo*p),v=(c*c-o*o-$o*h)/(2*c*Xo*p),d=Math.log(Math.sqrt(g*g+1)-g),y=Math.log(Math.sqrt(v*v+1)-v);r=(y-d)/Vo,e=function(n){var t=n*r,e=rn(d),a=o/(Xo*p)*(e*un(Vo*t+d)-en(d));return[i+a*f,u+a*s,o*e/rn(Vo*t+d)]}}return e.duration=1e3*r,e},ao.behavior.zoom=function(){function n(n){n.on(L,s).on(Wo+".zoom",p).on("dblclick.zoom",g).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function i(n){k.k=Math.max(A[0],Math.min(A[1],n))}function u(n,t){t=r(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:k.x,y:k.y,k:k.k},i(Math.pow(2,o)),u(d=e,r),t=ao.select(t),C>0&&(t=t.transition().duration(C)),t.call(n.event)}function a(){b&&b.domain(x.range().map(function(n){return(n-k.x)/k.k}).map(x.invert)),w&&w.domain(_.range().map(function(n){return(n-k.y)/k.k})
 .map(_.invert))}function l(n){z++||n({type:"zoomstart"})}function c(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function f(n){--z||(n({type:"zoomend"}),d=null)}function s(){function n(){a=1,u(ao.mouse(i),h),c(o)}function r(){s.on(q,null).on(T,null),p(a),f(o)}var i=this,o=D.of(i,arguments),a=0,s=ao.select(t(i)).on(q,n).on(T,r),h=e(ao.mouse(i)),p=W(i);Il.call(i),l(o)}function h(){function n(){var n=ao.touches(g);return p=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=e(n))}),n}function t(){var t=ao.event.target;ao.select(t).on(x,r).on(b,a),_.push(t);for(var e=ao.event.changedTouches,i=0,u=e.length;u>i;++i)d[e[i].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-M){var f=l[0];o(g,f,d[f.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),S()}M=c}else if(l.length>1){var f=l[0],s=l[1],h=f[0]-s[0],p=f[1]-s[1];y=h*h+p*p}}function r(){var n,t,e,r,o=ao.touches(g);Il.call(g);for(var a=0,l=o.length;l>a;++a,r=null)if(e=o[a],r=d[e.identifier]){if(t)break;n=e
 ,t=r}if(r){var f=(f=e[0]-n[0])*f+(f=e[1]-n[1])*f,s=y&&Math.sqrt(f/y);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],i(s*p)}M=null,u(n,t),c(v)}function a(){if(ao.event.touches.length){for(var t=ao.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var i in d)return void n()}ao.selectAll(_).on(m,null),w.on(L,s).on(R,h),N(),f(v)}var p,g=this,v=D.of(g,arguments),d={},y=0,m=".zoom-"+ao.event.changedTouches[0].identifier,x="touchmove"+m,b="touchend"+m,_=[],w=ao.select(g),N=W(g);t(),l(v),w.on(L,null).on(R,t)}function p(){var n=D.of(this,arguments);m?clearTimeout(m):(Il.call(this),v=e(d=y||ao.mouse(this)),l(n)),m=setTimeout(function(){m=null,f(n)},50),S(),i(Math.pow(2,.002*Bo())*k.k),u(d,v),c(n)}function g(){var n=ao.mouse(this),t=Math.log(k.k)/Math.LN2;o(this,n,e(n),ao.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var v,d,y,m,M,x,b,_,w,k={x:0,y:0,k:1},E=[960,500],A=Jo,C=250,z=0,L="mousedown.zoom",q="mousemove.zoom",T="mouseup.zoom",R="touchstart.zoo
 m",D=N(n,"zoomstart","zoom","zoomend");return Wo||(Wo="onwheel"in fo?(Bo=function(){return-ao.event.deltaY*(ao.event.deltaMode?120:1)},"wheel"):"onmousewheel"in fo?(Bo=function(){return ao.event.wheelDelta},"mousewheel"):(Bo=function(){return-ao.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=D.of(this,arguments),t=k;Hl?ao.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],i=d?d[0]:e/2,u=d?d[1]:r/2,o=ao.interpolateZoom([(i-k.x)/k.k,(u-k.y)/k.k,e/k.k],[(i-t.x)/t.k,(u-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:i-r[0]*a,y:u-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){f(n)}).each("end.zoom",function(){f(n)}):(this.__chart__=k,l(n),c(n),f(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},i(+t),a(),n):k.k},n.s
 caleExtent=function(t){return arguments.length?(A=null==t?Jo:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(y=t&&[+t[0],+t[1]],n):y},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(C=+t,n):C},n.x=function(t){return arguments.length?(b=t,x=t.copy(),k={x:0,y:0,k:1},n):b},n.y=function(t){return arguments.length?(w=t,_=t.copy(),k={x:0,y:0,k:1},n):w},ao.rebind(n,D,"on")};var Bo,Wo,Jo=[0,1/0];ao.color=an,an.prototype.toString=function(){return this.rgb()+""},ao.hsl=ln;var Go=ln.prototype=new an;Go.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,this.l/n)},Go.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,n*this.l)},Go.rgb=function(){return cn(this.h,this.s,this.l)},ao.hcl=fn;var Ko=fn.prototype=new an;Ko.brighter=function(n){return new fn(this.h,this.c,Math.min(100,this.l+Qo*(arguments.length?n:1)))},Ko.darker=function(n){return n
 ew fn(this.h,this.c,Math.max(0,this.l-Qo*(arguments.length?n:1)))},Ko.rgb=function(){return sn(this.h,this.c,this.l).rgb()},ao.lab=hn;var Qo=18,na=.95047,ta=1,ea=1.08883,ra=hn.prototype=new an;ra.brighter=function(n){return new hn(Math.min(100,this.l+Qo*(arguments.length?n:1)),this.a,this.b)},ra.darker=function(n){return new hn(Math.max(0,this.l-Qo*(arguments.length?n:1)),this.a,this.b)},ra.rgb=function(){return pn(this.l,this.a,this.b)},ao.rgb=mn;var ia=mn.prototype=new an;ia.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),new mn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new mn(i,i,i)},ia.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new mn(n*this.r,n*this.g,n*this.b)},ia.hsl=function(){return wn(this.r,this.g,this.b)},ia.toString=function(){return"#"+bn(this.r)+bn(this.g)+bn(this.b)};var ua=ao.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,
 aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,i
 ndianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,la

<TRUNCATED>