solidity-code-metrics
Version:
Solidity Code Metrics
1 lines • 31.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-selection"),require("d3-dispatch"),require("d3-transition"),require("d3-timer"),require("d3-interpolate"),require("d3-zoom"),require("viz.js/viz"),require("d3-format"),require("d3-path")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-dispatch","d3-transition","d3-timer","d3-interpolate","d3-zoom","viz.js/viz","d3-format","d3-path"],e):e(t["d3-graphviz"]={},t.d3,t.d3,t.d3,t.d3,t.d3,t.d3,t.Viz,t.d3,t.d3)}(this,function(t,e,n,r,i,a,o,s,l,h){"use strict";function c(t){var e={},n=t.node().nodeName;e.tag=n,"#text"==n?e.text=t.text():"#comment"==n&&(e.comment=t.text()),e.attributes={};var r=t.node().attributes;if(r)for(var i=0;i<r.length;i++){var a=r[i],o=a.name,s=a.value;e.attributes[o]=s}var l=t.node().transform;if(l&&0!=l.baseVal.numberOfItems){var h=l.baseVal.consolidate().matrix;e.translation={x:h.e,y:h.f},e.scale=h.a}if("ellipse"==n&&(e.center={x:e.attributes.cx,y:e.attributes.cy}),"polygon"==n){var c=(g=t.attr("points").split(" ")).map(function(t){return t.split(",")[0]}),u=g.map(function(t){return t.split(",")[1]}),d=Math.min.apply(null,c),f=Math.max.apply(null,c),p={x:d,y:v=Math.min.apply(null,u),width:f-d,height:(y=Math.max.apply(null,u))-v};e.bbox=p,e.center={x:(d+f)/2,y:(v+y)/2}}if("path"==n){var g;(g=t.attr("d").split(/[A-Z ]/)).shift();var v,y;c=g.map(function(t){return+t.split(",")[0]}),u=g.map(function(t){return+t.split(",")[1]}),d=Math.min.apply(null,c),f=Math.max.apply(null,c),p={x:d,y:v=Math.min.apply(null,u),width:f-d,height:(y=Math.max.apply(null,u))-v};e.bbox=p,e.center={x:(d+f)/2,y:(v+y)/2},e.totalLength=t.node().getTotalLength()}return"text"==n&&(e.center={x:t.attr("x"),y:t.attr("y")}),"#text"==n?e.text=t.text():"#comment"==n&&(e.comment=t.text()),e}function u(t){var n=c(t);return n.children=[],e.selectAll(t.node().childNodes).each(function(){var t=u(e.select(this));t.parent=n,n.children.push(t)}),n}function d(t){return"#text"==t.tag?document.createTextNode(""):"#comment"==t.tag?document.createComment(t.comment):document.createElementNS("http://www.w3.org/2000/svg",t.tag)}function f(t){var n=d(t),r=e.select(n),i=t.attributes,a=!0,o=!1,s=void 0;try{for(var l,h=Object.keys(i)[Symbol.iterator]();!(a=(l=h.next()).done);a=!0){var c=l.value,u=i[c];r.attr(c,u)}}catch(t){o=!0,s=t}finally{try{!a&&h.return&&h.return()}finally{if(o)throw s}}return n}function p(t,n){var r=e.select(t.node().parentNode),i=f(n),a=r.insert(function(){return i},function(){return t.node()});return t.remove(),a}function g(t,n){!function(t,e){t.datum(e),t.data([e],function(t){return t.key})}(t,n),e.selectAll(t.node().childNodes).each(function(t,r){g(e.select(this),n.children[r])})}function v(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.select(this),i=(t.tag,t.attributes),a=r.node().attributes;if(a)for(var o=0;o<a.length;o++){var s=a[o],l=s.name;if("xmlns"!=l.split(":")[0]&&s.namespaceURI){var h=s.namespaceURI.split("/");l=h[h.length-1]+":"+l}l in i||(i[l]=null)}var c=!0,u=!1,f=void 0;try{for(var p,g=Object.keys(i)[Symbol.iterator]();!(c=(p=g.next()).done);c=!0){var y=p.value;r.attr(y,i[y])}}catch(t){u=!0,f=t}finally{try{!c&&g.return&&g.return()}finally{if(u)throw f}}t.text&&r.text(t.text),function(t,e){var n=t.selectAll(function(){return t.node().childNodes}),r=(n=n.data(function(t){return t.children},function(t){return t.tag+"-"+e})).enter().append(function(t){return d(t)}),i=n.exit();i=i.remove();var a={};(n=r.merge(n)).each(function(t){var e=t.tag;null==a[e]&&(a[e]=0);var n=a[e]++;v.call(this,t,n)})}(r,n)}function y(t){return Object.assign({},t)}function m(t){return Math.round(1e4*t)/1e4}s=s&&s.hasOwnProperty("default")?s.default:s;function _(){var t=this._selection,n=e.select(t.node().querySelector("svg"));if(0==n.size())return this;this._zoomSelection=n;var r=o.zoom().scaleExtent(this._options.zoomScaleExtent).translateExtent(this._options.zoomTranslateExtent).interpolate(a.interpolate).on("zoom",function(){e.select(n.node().querySelector("g")).attr("transform",e.event.transform)});this._zoomBehavior=r;var i=e.select(n.node().querySelector("g"));return n.call(r),this._active||x.call(this,i),this._originalTransform=o.zoomTransform(n.node()),this}function w(t){var e=this._translation,n=this._scale,r=t.datum().translation,i=t.datum().scale,a=o.zoomTransform(this._zoomSelection.node());return e&&(a=(a=a.scale(1/n)).translate(-e.x,-e.y)),a=(a=a.translate(r.x,r.y)).scale(i)}function x(t){this._zoomBehavior.transform(this._zoomSelection,w.call(this,t)),this._translation=t.datum().translation,this._scale=t.datum().scale,this._originalTransform=o.zoomIdentity.translate(t.datum().translation.x,t.datum().translation.y).scale(t.datum().scale)}function b(t,e){return function(){var n=t.map(function(t){return a.interpolate([t[0][0],t[0][1]],[t[1][0],t[1][1]])});return function(t){return t<1?"M"+n.map(function(e){return e(t)}).join("L"):e}}}function E(t){return"edge"==t.attributes.class||"a"==t.tag&&"g"==t.parent.tag&&"edge"==t.parent.parent.attributes.class}function P(t){return t.parent&&E(t.parent)}function z(t){var n=this._transition,r=this._options.fade&&null!=n,i=this._options.tweenPaths,s=this._options.tweenShapes,l=this._options.convertEqualSidedPolygons,h=this._options.growEnteringEdges&&null!=n,u=this._attributer,f=this;function g(t){var v=e.select(this);if("svg"==t.tag){var y=f._options;if(null!=y.width||null!=y.height){var m=y.width,_=y.height;null==m?m=4*t.attributes.width.replace("pt","")/3:(v.attr("width",m),t.attributes.width=m),null==_?_=4*t.attributes.height.replace("pt","")/3:(v.attr("height",_),t.attributes.height=_),y.fit||(v.attr("viewBox","0 0 "+3*m/4/y.scale+" "+3*_/4/y.scale),t.attributes.viewBox="0 0 "+3*m/4/y.scale+" "+3*_/4/y.scale)}1!=y.scale&&(y.fit||null==y.width&&null==y.height)&&(m=t.attributes.viewBox.split(" ")[2],_=t.attributes.viewBox.split(" ")[3],v.attr("viewBox","0 0 "+m/y.scale+" "+_/y.scale),t.attributes.viewBox="0 0 "+m/y.scale+" "+_/y.scale)}u&&v.each(u);var z=t.tag,N=t.attributes,k=v.node().attributes;if(k)for(var S=0;S<k.length;S++){var D=k[S],M=D.name;if("xmlns"!=M.split(":")[0]&&D.namespaceURI){var W=D.namespaceURI.split("/");M=W[W.length-1]+":"+M}M in N||(N[M]=null)}var j=!1,O=!1;if(s&&n){if("polygon"!=this.nodeName&&"ellipse"!=this.nodeName||!t.alternativeOld||(O=!0),"polygon"!=z&&"ellipse"!=z||!t.alternativeNew||(j=!0),"polygon"==this.nodeName&&"polygon"==z){var L=c(v).attributes.points;if(!l){var q=L.split(" ").length;(et=t.attributes.points).split(" ").length==q&&(j=!1,O=!1)}}if(O){var A=t.alternativeOld,T=p(v,A);T.data([t],function(){return t.key}),v=T}if(j)z="path",N=t.alternativeNew.attributes}var B=v;if(n&&(B=B.transition(n),r&&B.filter(function(t){return"#"==t.tag[0]?null:this}).style("opacity",1),B.filter(function(t){return"#"==t.tag[0]?null:this}).on("end",function(){e.select(this).attr("style",null)})),h&&"path"==z&&t.offset){var I=t.totalLength;v.attr("stroke-dasharray",I+" "+I).attr("stroke-dashoffset",I).attr("transform","translate("+t.offset.x+","+t.offset.y+")"),N["stroke-dashoffset"]=0,N.transform="translate(0,0)",B.attr("stroke-dashoffset",N["stroke-dashoffset"]).attr("transform",N.transform).on("start",function(){e.select(this).style("opacity",null)}).on("end",function(){e.select(this).attr("stroke-dashoffset",null).attr("stroke-dasharray",null).attr("transform",null)})}if(h&&"polygon"==z&&P(t)&&t.offset){var R=e.select(v.node().parentNode.querySelector("path")),U=R.node().getPointAtLength(0),F=R.node().getPointAtLength(t.totalLength),V=R.node().getPointAtLength(t.totalLength-1),Z=180*Math.atan2(F.y-V.y,F.x-V.x)/Math.PI,C=U.x-F.x+t.offset.x,$=U.y-F.y+t.offset.y;v.attr("transform","translate("+C+","+$+")"),B.attrTween("transform",function(){return function(e){var n=R.node().getPointAtLength(t.totalLength*e),r=R.node().getPointAtLength(t.totalLength*e+1),i=180*Math.atan2(r.y-n.y,r.x-n.x)/Math.PI-Z;return C=n.x-F.x+t.offset.x*(1-e),$=n.y-F.y+t.offset.y*(1-e),"translate("+C+","+$+") rotate("+i+" "+F.x+" "+F.y+")"}}).on("start",function(){e.select(this).style("opacity",null)}).on("end",function(){e.select(this).attr("transform",null)})}var G=i&&n&&"path"==z&&null!=v.attr("d"),H=!0,J=!1,K=void 0;try{for(var Q,X=Object.keys(N)[Symbol.iterator]();!(H=(Q=X.next()).done);H=!0){var Y=Q.value,tt=N[Y];if(G&&"d"==Y){var et;(et=(t.alternativeOld||t).points)&&B.attrTween("d",b(et,tt))}else{if("transform"==Y&&t.translation)if(n){var nt=B.on("end");B.on("start",function(){f._zoomBehavior&&B.tween("attr.transform",function(){var t=this;return function(e){t.setAttribute("transform",a.interpolateTransformSvg(o.zoomTransform(f._zoomSelection.node()).toString(),w.call(f,v).toString())(e))}})}).on("end",function(){nt.call(this),f._zoomBehavior&&x.call(f,v)})}else f._zoomBehavior&&(tt=w.call(f,v).toString());B.attr(Y,tt)}}}catch(t){J=!0,K=t}finally{try{!H&&X.return&&X.return()}finally{if(J)throw K}}j&&B.on("end",function(t,n,r){p(T=e.select(this),t).data([t],function(){return t.key})}),t.text&&B.text(t.text),function(t){var i=t.selectAll(function(){return t.node().childNodes}),a=(i=i.data(function(t){return t.children},function(t){return t.key})).enter().append(function(t){var e=d(t);return"#text"==t.tag&&r&&(e.nodeValue=t.text),e});(r||h&&E(t.datum()))&&a.filter(function(t){return"#"==t.tag[0]?null:this}).each(function(t){var n=e.select(this),r=!0,i=!1,a=void 0;try{for(var o,s=Object.keys(t.attributes)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var l=o.value,h=t.attributes[l];n.attr(l,h)}}catch(t){i=!0,a=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}).filter(function(t){return"svg"==t.tag||"g"==t.tag?null:this}).style("opacity",0);var o=i.exit();u&&o.each(u),n&&(o=o.transition(n),r&&o.filter(function(t){return"#"==t.tag[0]?null:this}).style("opacity",0)),o=o.remove(),(i=a.merge(i)).each(g)}(v)}var v=this._selection;if(null!=n){var y=this._jobs;if(f._active)return y.push(null),this;v.transition(n).transition().duration(0).on("end",function(){f._active=!1,0!=y.length&&(y.shift(),f.render())}),this._active=!0}null!=n&&v.transition(n).on("start",function(){f._dispatch.call("transitionStart",f)}).on("end",function(){f._dispatch.call("transitionEnd",f)}).transition().duration(0).on("start",function(){f._dispatch.call("restoreEnd",f),f._dispatch.call("end",f),t&&t.call(f)});var m=this._data,z=v.selectAll("svg").data([m],function(t){return t.key});return z=z.enter().append("svg").merge(z),g.call(z.node(),m),this._options.zoom&&!this._zoomBehavior&&_.call(this),f._dispatch.call("renderEnd",f),null==n&&(this._dispatch.call("end",this),t&&t.call(this)),this}function N(t,e){if("polygon"==t.tag){(u=y(t)).tag="path";var n=y(d=t.attributes),r=d.points;if("polygon"==e.tag){(m=t.bbox).cx=m.x+m.width/2,m.cy=m.y+m.height/2;for(var i=d.points.split(" "),a=i.map(function(t){var e=t.split(",");return[e[0]-m.cx,e[1]-m.cy]}),o=a[a.length-1][0],s=a[a.length-1][1],l=0;l<a.length;l++,o=N,s=k){var h=(N=a[l][0])-o;if(0!=(b=(k=a[l][1])-s))if(0<=(S=o-s*h/b)&&S<1/0&&(o<=S&&S<=N||N<=S&&S<=o))break}var c=[[m.cx+S,m.cy+0].join(",")];r=(c=(c=c.concat(i.slice(l))).concat(i.slice(0,l))).join(" ")}n.d="M"+r+"z",delete n.points,u.attributes=n}else{var u;(u=y(t)).tag="path";n=y(d=t.attributes);var d,f=d.cx,p=d.cy,g=d.rx,v=d.ry;if("polygon"==e.tag){var m;(m=e.bbox).cx=m.x+m.width/2,m.cy=m.y+m.height/2;var _=e.attributes.points.split(" ")[0].split(","),w=_[0],x=_[1],b=(h=w-m.cx,x-m.cy),E=Math.sqrt(Math.pow(h,2)+Math.pow(b,2)),P=h/E,z=-b/E}else P=1,z=0;var N,k,S;h=(S=g*-P)-(N=g*P),b=-v*-z-(k=-v*z);n.d="M "+f+" "+p+" m "+N+","+k+" a "+g+","+v+" 0 1,0 "+h+","+b+" a "+g+","+v+" 0 1,0 "+-h+","+-b+"z",delete n.cx,delete n.cy,delete n.rx,delete n.ry,u.attributes=n}return u}var k,S=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},D=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)};function M(t,e,n,r){var i=[t*n-(e=-e)*(r=-r),t*r+e*n];return[t=i[0],e=-(e=i[1])]}function W(t,e,n,r,i,a,o){var s=u(q(a));t.data([s]),v.call(t.node(),s),j(t,e,n,r,i,a,o)}function j(t,e,n,r,i,a,o){var s=o.shortening||0,l=[[0,-3.5],[10,0],[0,3.5],[0,-3.5]],c=r-e,u=i-n,d=Math.sqrt(c*c+u*u);if(0==d)var f=1,p=0;else f=c/d,p=u/d;if(r=e+(d-s-10-.174)*f,i=n+(d-s-10-.174)*p,a.URL||a.tooltip)var g=t.selectWithoutDataPropagation("g").selectWithoutDataPropagation("a"),v=g.selectWithoutDataPropagation("path"),y=g.selectWithoutDataPropagation("polygon");else v=t.selectWithoutDataPropagation("path"),y=t.selectWithoutDataPropagation("polygon");var m=h.path();m.moveTo(e,n),m.lineTo(r,i),v.attr("d",m),r=e+(d-s-10)*f,i=n+(d-s-10)*p;for(var _=0;_<l.length;_++){var w=l[_];l[_]=M(w[0],w[1],f,p)}for(_=0;_<l.length;_++){w=l[_];l[_]=[r+w[0],i+w[1]]}var x=[];for(_=0;_<l.length;_++){w=l[_];x.push(w.join(","))}var b=x.join(" ");return y.attr("points",b),this}function O(){return this._drawnEdge?(this._drawnEdge.g.remove(),this._drawnEdge=null,this):this}function L(){return this._drawnEdge?this._drawnEdge.g:e.select(null)}function q(t){var n="",r=!0,i=!1,a=void 0;try{for(var o,l=Object.keys(t)[Symbol.iterator]();!(r=(o=l.next()).done);r=!0){var h=o.value;null!=t[h]&&(n+=' "'+h+'"="'+t[h]+'"')}}catch(t){i=!0,a=t}finally{try{!r&&l.return&&l.return()}finally{if(i)throw a}}var c=s("digraph {a -> b ["+n+"]}",{format:"svg"}),u=(new window.DOMParser).parseFromString(c,"image/svg+xml");return e.select(document.createDocumentFragment()).append(function(){return u.documentElement}).select(".edge")}function A(t,e,n,r,i,a){var o=u(R(r,i));return t.data([o]),v.call(t.node(),o),T(t,e,n,i,a),this}function T(t,n,r,i,a){if(i.URL||i.tooltip)var o=t.selectWithoutDataPropagation("g").selectWithoutDataPropagation("a");else o=t;var s=o.selectAll("ellipse,polygon,path,polyline"),l=t.selectWithoutDataPropagation("text");if(0!=s.size()){var h=s.node().getBBox();h.cx=h.x+h.width/2,h.cy=h.y+h.height/2}else 0!=l.size()&&(h={x:+l.attr("x"),y:+l.attr("y"),width:0,height:0,cx:+l.attr("x"),cy:+l.attr("y")});return s.each(function(t,i){var a=e.select(this);if(a.attr("cx"))a.attr("cx",m(n)).attr("cy",m(r));else if(a.attr("points")){var o=a.attr("points").trim();a.attr("points",function(t,e,n){var r;return(r=t.split(" ")).map(function(t){return t.split(",")}),t=(t=(r=r.map(function(t){return[m(+e+ +t.split(",")[0]),m(+n+ +t.split(",")[1])]}).map(function(t){return t.join(",")})).join(" ")).replace(/-0\./g,"-.").replace(/ 0\./g," .")}(o,n-h.cx,r-h.cy))}else{var s=a.attr("d");a.attr("d",function(t,e,n){(i=t.split(/[A-Z ]/)).shift();var r=t.split(/[^[A-Z ]+/),i=(i.map(function(t){return t.split(",")}),i.map(function(t){return[m(+e+ +t.split(",")[0]),m(+n+ +t.split(",")[1])]}).map(function(t){return t.join(",")}));return t=(t=r.reduce(function(t,e,n){return t.concat(e,i[n])},[]).join("")).replace(/-0\./g,"-.").replace(/ 0\./g," .")}(s,n-h.cx,r-h.cy))}}),0!=l.size()&&l.attr("x",m(+l.attr("x")+n-h.cx)).attr("y",m(+l.attr("y")+r-h.cy)),this}function B(){if(!this._drawnNode)return this;var t=this._drawnNode.g;return t.empty()||t.remove(),this._drawnNode=null,this}function I(){return this._drawnNode?this._drawnNode.g:e.select(null)}function R(t,n){var r="",i=!0,a=!1,o=void 0;try{for(var l,h=Object.keys(n)[Symbol.iterator]();!(i=(l=h.next()).done);i=!0){var c=l.value;null!=n[c]&&(r+=' "'+c+'"="'+n[c]+'"')}}catch(t){a=!0,o=t}finally{try{!i&&h.return&&h.return()}finally{if(a)throw o}}var u=s('graph {"'+t+'" ['+r+"]}",{format:"svg"}),d=(new window.DOMParser).parseFromString(u,"image/svg+xml");return e.select(document.createDocumentFragment()).append(function(){return d.documentElement}).select(".node")}function U(t,r){if(this._options={useWorker:!0,engine:"dot",totalMemory:void 0,keyMode:"title",fade:!0,tweenPaths:!0,tweenShapes:!0,convertEqualSidedPolygons:!0,tweenPrecision:1,growEnteringEdges:!0,zoom:!0,zoomScaleExtent:[.1,10],zoomTranslateExtent:[[-1/0,-1/0],[1/0,1/0]],width:null,height:null,scale:1,fit:!1},r instanceof Object){var i=!0,a=!1,o=void 0;try{for(var l,h=Object.keys(r)[Symbol.iterator]();!(i=(l=h.next()).done);i=!0){var c=l.value;this._options[c]=r[c]}}catch(t){a=!0,o=t}finally{try{!i&&h.return&&h.return()}finally{if(a)throw o}}}else"boolean"==typeof r&&(this._options.useWorker=r);var u=this._options.useWorker;if("undefined"==typeof Worker&&(u=!1),u){var d=e.selectAll("script").filter(function(){return"javascript/worker"==e.select(this).attr("type")||e.select(this).attr("src")&&e.select(this).attr("src").match(/.*\/viz.js$/)});0==d.size()?(console.warn('No script tag of type "javascript/worker" was found and "useWorker" is true. Not using web worker.'),u=!1):(this._vizURL=d.attr("src"),this._vizURL||(console.warn('No "src" attribute of was found on the "javascript/worker" script tag and "useWorker" is true. Not using web worker.'),u=!1))}if(u){var f=new Blob(['\n onmessage = function(event) {\n if (event.data.vizURL) {\n importScripts(event.data.vizURL);\n }\n try {\n var svg = Viz(event.data.dot, event.data.options);\n }\n catch(error) {\n postMessage({\n type: "error",\n error: error.message,\n });\n return;\n }\n if (svg) {\n postMessage({\n type: "done",\n svg: svg,\n });\n } else {\n postMessage({\n type: "skip",\n });\n }\n }\n ']),p=window.URL.createObjectURL(f);this._worker=new Worker(p)}this._selection=t,this._active=!1,this._busy=!1,this._jobs=[],this._queue=[],this._keyModes=new Set(["title","id","tag-index","index"]),this._images=[],this._translation=void 0,this._scale=void 0,this._eventTypes=["initEnd","start","layoutStart","layoutEnd","dataExtractEnd","dataProcessPass1End","dataProcessPass2End","dataProcessEnd","renderStart","renderEnd","transitionStart","transitionEnd","restoreEnd","end"],this._dispatch=n.dispatch.apply(void 0,D(this._eventTypes)),function(){if(null==this._worker)s(""),this._dispatch.call("initEnd",this);else{var t=this._vizURL,e=this;this._worker.onmessage=function(t){e._dispatch.call("initEnd",this)},t.match(/^https?:\/\/|^\/\//i)||(t=new window.URL(t,document.location.href).href),this._worker.postMessage({dot:"",vizURL:t})}}.call(this),t.node().__graphviz__=this}function F(t,n){return e.select(t).graphviz(n)}U.prototype=F.prototype=(S(k={constructor:U,engine:function(t){return this._options.engine=t,this},addImage:function(t,e,n){return this._images.push({path:t,width:e,height:n}),this},totalMemory:function(t){return this._options.totalMemory=t,this},keyMode:function(t){if(!this._keyModes.has(t))throw Error("Illegal keyMode: "+t);if(t!=this._options.keyMode&&null!=this._data)throw Error("Too late to change keyMode");return this._options.keyMode=t,this},fade:function(t){return this._options.fade=t,this},tweenPaths:function(t){return this._options.tweenPaths=t,this},tweenShapes:function(t){return this._options.tweenShapes=t,t&&(this._options.tweenPaths=!0),this},convertEqualSidedPolygons:function(t){return this._options.convertEqualSidedPolygons=t,this},tweenPrecision:function(t){return this._options.tweenPrecision=t,this},growEnteringEdges:function(t){return this._options.growEnteringEdges=t,this},zoom:function(t){return this._options.zoom=t,this._options.zoom&&!this._zoomBehavior&&_.call(this),this},resetZoom:function(t){var e=this._zoomSelection;return t&&(e=e.transition(t)),e.call(this._zoomBehavior.transform,this._originalTransform),this},zoomBehavior:function(){return this._zoomBehavior||null},zoomSelection:function(){return this._zoomSelection||null},zoomScaleExtent:function(t){return this._options.zoomScaleExtent=t,this},zoomTranslateExtent:function(t){return this._options.zoomTranslateExtent=t,this},render:function(t){return this._busy?(this._queue.push(this.render.bind(this,t)),this):(this._dispatch.call("renderStart",this),this._transitionFactory?i.timeout(function(){this._transition=r.transition(this._transitionFactory()),z.call(this,t)}.bind(this),0):z.call(this,t),this)},dot:function(t,n){var r=this,i=this._worker,a=this._options.engine,o=this._images,l=this._options.totalMemory,h=this._options.keyMode,c=this._options.tweenPaths,d=this._options.tweenShapes;if("string"==typeof this._options.tweenPrecision&&this._options.tweenPrecision.includes("%"))var p=+this._options.tweenPrecision.split("%")[0]/100,g=this._options.tweenPrecision.includes("%");else p=this._options.tweenPrecision,g=!1;var v=this._options.growEnteringEdges,y={},m=this._dictionary||{},_={},w=this._nodeDictionary||{};function x(t,e){if(c&&e&&("path"==e.tag||t.alternativeOld&&"path"==t.alternativeOld.tag)){var n=(t.alternativeNew||t).attributes.d;if(t.alternativeOld)var r=f(t.alternativeOld);else r=f(e);(t.alternativeOld||(t.alternativeOld={})).points=function(t,e,n,r){for(var i=t,a=i.cloneNode(),o=i.getTotalLength(),s=(a.setAttribute("d",e),a).getTotalLength(),l=[0],h=0,c=r?n:n/Math.max(o,s);(h+=c)<1;)l.push(h);return l.push(1),l.map(function(t){var e=i.getPointAtLength(t*o),n=a.getPointAtLength(t*s);return[[e.x,e.y],[n.x,n.y]]})}(r,n,p,g)}}function b(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments[2];!function(t,e){var n=t.tag;if("index"==h)t.key=e;else if("#"!=n[0])if("id"==h)t.key=t.attributes.id;else if("title"==h){var r=t.children.find(function(t){return"title"==t.tag});r&&(r.children.length>0?t.key=r.children[0].text:t.key="")}null==t.key&&(d&&("ellipse"!=n&&"polygon"!=n||(n="path")),t.key=n+"-"+e)}(t,e),function(t,e){var n=(e?e.id+".":"")+t.key;t.id=n}(t,n);var r=t.id,i=m[r];!function(t){y[t.id]=t}(t),function(t,e){d&&t.id in m&&("polygon"!=e.tag&&"ellipse"!=e.tag&&"path"!=e.tag||e.tag==t.tag&&"polygon"!=t.tag||("path"!=e.tag&&(t.alternativeOld=N(e,t)),"path"!=t.tag&&(t.alternativeNew=N(t,e))))}(t,i),x(t,i);var a={};t.children.forEach(function(e){var n=e.tag;"ellipse"!=n&&"polygon"!=n||(n="path"),null==a[n]&&(a[n]=0),b(e,a[n]++,t)})}function E(t){!function(t){var e=t.tag;if(v&&t.parent&&"node"==t.parent.attributes.class&&"title"==e){if(t.children.length>0)var n=t.children[0].text;else n="";_[n]=t.parent}}(t),function(t){var e=t.id,n=t.tag,r=m[e];if(v&&!r&&t.parent&&P(t)&&("path"==n||"polygon"==n)){if("polygon"==n){var i=t.parent.children.find(function(t){return"path"==t.tag});t.totalLength=i.totalLength}var a=function(t){return function(t){return"edge"==t.parent.attributes.class?t.parent:t.parent.parent.parent}(t).children.find(function(t){return"title"==t.tag})}(t).children[0],o=a.text.split("->");2!=o.length&&(o=a.text.split("--"));var s=o[0],l=_[s],h=w[s];if(h){if((d=l.children.findIndex(function(t,e){return"g"==t.tag}))>=0){var c=l.children[d].children.findIndex(function(t,e){return"a"==t.tag});l=l.children[d].children[c]}(d=h.children.findIndex(function(t,e){return"g"==t.tag}))>=0&&(c=h.children[d].children.findIndex(function(t,e){return"a"==t.tag}),h=h.children[d].children[c]);for(var u=l.children,d=0;d<u.length;d++)if("polygon"==u[d].tag||"ellipse"==u[d].tag||"path"==u[d].tag||"text"==u[d].tag){var f=u[d];break}var p=h.children;for(d=0;d<p.length;d++)if("polygon"==p[d].tag||"ellipse"==p[d].tag||"path"==p[d].tag||"text"==p[d].tag){var g=p[d];break}t.offset=g&&f?{x:g.center.x-f.center.x,y:g.center.y-f.center.y}:{x:0,y:0}}}}(t),t.children.forEach(function(t){E(t)})}this._dispatch.call("start",this),this._busy=!0,this._dispatch.call("layoutStart",this);var z={format:"svg",engine:a,images:o,totalMemory:l};if(this._worker)i.postMessage({dot:t,options:z}),i.onmessage=function(t){switch(t.data.type){case"done":return S.call(r,t.data.svg);case"error":if(!r._onerror)throw t.data.error;r._onerror(t.data.error)}};else{try{var k=s(t,z)}catch(t){if(r._onerror)return r._onerror(t.message),this;throw t.message}S.call(this,k)}function S(t){this._dispatch.call("layoutEnd",this);var r=e.select(document.createDocumentFragment()).append("div"),i=(new window.DOMParser).parseFromString(t,"image/svg+xml");r.append(function(){return i.documentElement});var a=u(r.select("svg"));this._dispatch.call("dataExtractEnd",this),b(a),this._dispatch.call("dataProcessPass1End",this),E(a),this._dispatch.call("dataProcessPass2End",this),this._data=a,this._dictionary=y,this._nodeDictionary=_,this._extractData=function(t,e,n){var r=u(t);return b(r,e,n),E(r),r},this._busy=!1,this._dispatch.call("dataProcessEnd",this),n&&n.call(this),this._queue.length>0&&this._queue.shift().call(this)}return this},data:function(){return this._data||null},renderDot:function(t,e){var n=this;return this.dot(t,function(){n.render(e)}),this},transition:function(t){return t instanceof Function?this._transitionFactory=t:this._transition=r.transition(t),this},active:function(t){var e=this._selection.selectWithoutDataPropagation("svg");return 0!=e.size()?r.active(e.node(),t):null},options:function(t){if(void 0===t)return Object.assign({},this._options);var e=!0,n=!1,r=void 0;try{for(var i,a=Object.keys(t)[Symbol.iterator]();!(e=(i=a.next()).done);e=!0){var o=i.value;this._options[o]=t[o]}}catch(t){n=!0,r=t}finally{try{!e&&a.return&&a.return()}finally{if(n)throw r}}return this},width:function(t){return this._options.width=t,this},height:function(t){return this._options.height=t,this},scale:function(t){return this._options.scale=t,this},fit:function(t){return this._options.fit=t,this},attributer:function(t){return this._attributer=t,this},on:function(t,e){return this._dispatch.on(t,e),this},onerror:function(t){return this._onerror=t,this},logEvents:function(t){var e=this,n=Date.now(),r={},i=this._eventTypes,a=Math.max.apply(Math,D(i.map(function(t){return t.length}))),o=function(o){var s=i[o];r[s]=[],h=e,e.on(s+".log",t?function(){var t=Date.now(),e=r[s].length;r[s].push(t);var i="";if(i+="Event ",i+=l.format(" >2")(o)+" ",i+=s+" ".repeat(a-s.length),i+=l.format(" >5")(t-n)+" ","initEnd"!=s&&(i+=l.format(" >5")(t-r.start[e])),"dataProcessEnd"==s&&(i+=" prepare "+l.format(" >5")(t-r.layoutEnd[e])),"renderEnd"==s&&h._transition&&(i+=" transition start margin "+l.format(" >5")(h._transition.delay()-(t-r.renderStart[e])),c=h._transition.delay(),u=h._transition.duration()),"transitionStart"==s){var d=t-r.renderStart[e];i+=" transition delay "+l.format(" >5")(t-r.renderStart[e]),i+=" expected "+l.format(" >5")(c),i+=" diff "+l.format(" >5")(d-c)}if("transitionEnd"==s){var f=t-r.transitionStart[e];i+=" transition duration "+l.format(" >5")(f),i+=" expected "+l.format(" >5")(u),i+=" diff "+l.format(" >5")(f-u)}console.log(i),n=t}:null)};for(var s in i){var h,c,u;o(s)}return this},drawEdge:function(t,n,r,i,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if((a=Object.assign({},a)).style&&a.style.includes("invis"))var s=e.select(null);else{var l=this._selection.selectWithoutDataPropagation("svg").selectWithoutDataPropagation("g"),h=u(q(a));s=l.append("g").data([h]),v.call(s.node(),h),W(s,t,n,r,i,a,o)}return this._drawnEdge={g:s,x1:t,y1:n,x2:r,y2:i,attributes:a},this},updateDrawnEdge:function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(!this._drawnEdge)throw Error("No edge has been drawn");var o=this._drawnEdge.g;i=Object.assign(this._drawnEdge.attributes,i),this._drawnEdge.x1=t,this._drawnEdge.y1=e,this._drawnEdge.x2=n,this._drawnEdge.y2=r,!o.empty()||i.style&&i.style.includes("invis")||(o=this._selection.selectWithoutDataPropagation("svg").selectWithoutDataPropagation("g").append("g"),this._drawnEdge.g=o);return o.empty()||W(o,t,e,n,r,i,a),this},moveDrawnEdgeEndPoint:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this._drawnEdge)throw Error("No edge has been drawn");var r=this._drawnEdge.g,i=this._drawnEdge.x1,a=this._drawnEdge.y1,o=this._drawnEdge.attributes;return this._drawnEdge.x2=t,this._drawnEdge.y2=e,j(r,i,a,t,e,o,n),this},insertDrawnEdge:function(t){if(!this._drawnEdge)throw Error("No edge has been drawn");var e=this._drawnEdge.g;if(e.empty())return this;this._drawnEdge.attributes,e.selectWithoutDataPropagation("title").text(t);var n=this._selection.selectWithoutDataPropagation("svg").selectWithoutDataPropagation("g"),r=n.datum(),i=this._extractData(e,r.children.length,n.datum());return r.children.push(i),g(e,i),this._drawnEdge=null,this},removeDrawnEdge:O},"removeDrawnEdge",O),S(k,"drawnEdgeSelection",L),S(k,"drawnEdgeSelection",L),S(k,"drawNode",function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if((i=Object.assign({},i)).style&&i.style.includes("invis"))var o=e.select(null);else{var s=this._selection.selectWithoutDataPropagation("svg").selectWithoutDataPropagation("g"),l=u(R(r,i));o=s.append("g").data([l]),v.call(o.node(),l),A(o,t,n,r,i,a)}return this._drawnNode={g:o,nodeId:r,x:t,y:n,attributes:i},this}),S(k,"updateDrawnNode",function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(!this._drawnNode)throw Error("No node has been drawn");var a=this._drawnNode.g;null==n&&(n=this._drawnNode.nodeId),r=Object.assign(this._drawnNode.attributes,r),this._drawnNode.nodeId=n,this._drawnNode.x=t,this._drawnNode.y=e,!a.empty()||r.style&&r.style.includes("invis")||(a=this._selection.selectWithoutDataPropagation("svg").selectWithoutDataPropagation("g").append("g"),this._drawnNode.g=a);return a.empty()||A(a,t,e,n,r,i),this}),S(k,"moveDrawnNode",function(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2],!this._drawnNode)throw Error("No node has been drawn");var n=this._drawnNode.g,r=this._drawnNode.attributes;return this._drawnNode.x=t,this._drawnNode.y=e,n.empty()||T(n,t,e,r),this}),S(k,"insertDrawnNode",function(t){if(!this._drawnNode)throw Error("No node has been drawn");null==t&&(t=this._drawnNode.nodeId);var e=this._drawnNode.g;if(e.empty())return this;var n=this._drawnNode.attributes;if(e.selectWithoutDataPropagation("title").text(t),n.URL||n.tooltip)var r=e.selectWithoutDataPropagation("g").selectWithoutDataPropagation("a"),i=(r.selectWithoutDataPropagation("ellipse,polygon,path,polyline"),r.selectWithoutDataPropagation("text"));else e.selectWithoutDataPropagation("ellipse,polygon,path,polyline"),i=e.selectWithoutDataPropagation("text");i.text(n.label||t);var a=this._selection.selectWithoutDataPropagation("svg").selectWithoutDataPropagation("g"),o=a.datum(),s=this._extractData(e,o.children.length,a.datum());return o.children.push(s),g(e,s),this._drawnNode=null,this}),S(k,"removeDrawnNode",B),S(k,"removeDrawnNode",B),S(k,"drawnNodeSelection",I),S(k,"drawnNodeSelection",I),k);e.selection.prototype.graphviz=function(t){var e=this.node().__graphviz__;return e?(e.options(t),e._dispatch.call("initEnd",this)):e=new U(this,t),e},e.selection.prototype.selectWithoutDataPropagation=function(t){return e.select(this.size()>0?this.node().querySelector(t):null)},t.graphviz=F,Object.defineProperty(t,"__esModule",{value:!0})});