ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 28.7 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/collections"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/core/no-animation"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/spin"),require("d3-shape"),require("d3-drag"),require("d3-selection"),require("d3-zoom"),require("@angular/animations"),require("ng-zorro-antd/core/util"),require("d3-transition"),require("dagre-compound"),require("ng-zorro-antd/core/polyfill")):"function"==typeof define&&define.amd?define("ng-zorro-antd/graph",["exports","@angular/cdk/collections","rxjs","rxjs/operators","@angular/common","@angular/core","ng-zorro-antd/core/no-animation","ng-zorro-antd/icon","ng-zorro-antd/spin","d3-shape","d3-drag","d3-selection","d3-zoom","@angular/animations","ng-zorro-antd/core/util","d3-transition","dagre-compound","ng-zorro-antd/core/polyfill"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].graph={}),t.ng.cdk.collections,t.rxjs,t.rxjs.operators,t.ng.common,t.ng.core,t["ng-zorro-antd"].core["no-animation"],t["ng-zorro-antd"].icon,t["ng-zorro-antd"].spin,t.d3Shape,t.d3Drag,t.d3Selection,t.d3Zoom,t.ng.animations,t["ng-zorro-antd"].core.util,t.d3Transition,t.dagreCompound,t["ng-zorro-antd"].core.polyfill)}(this,(function(t,e,n,i,o,r,a,s,h,c,d,p,l,u,m,g,f,y){"use strict";function v(){return function(t){return t}}var z={graph:{meta:{nodeSep:50,rankSep:50,edgeSep:5}},subScene:{meta:{paddingTop:20,paddingBottom:20,paddingLeft:20,paddingRight:20,labelHeight:20}},nodeSize:{meta:{width:50,maxLabelWidth:0,height:50},node:{width:50,height:50,labelOffset:10,maxLabelWidth:40},bridge:{width:5,height:5,radius:2,labelOffset:0}}};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function x(t,e,n,i){var o,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,i);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(r<3?o(a):r>3?o(e,n,a):o(e,n))||a);return r>3&&a&&Object.defineProperty(e,n,a),a}function b(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}Object.create;function w(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function S(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function C(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(S(arguments[e]));return t}Object.create;var O=function(){function t(t){var i;this._data=new n.BehaviorSubject({}),this.expansionModel=new e.SelectionModel(!0),t&&(null===(i=this.expansionModel)||void 0===i||i.clear(),this.dataSource=t,this._data.next(t))}return t.prototype.toggle=function(t){this.expansionModel.toggle(t)},t.prototype.expand=function(t){this.expansionModel.select(t)},t.prototype.collapse=function(t){this.expansionModel.deselect(t)},t.prototype.isExpanded=function(t){return this.expansionModel.isSelected(t)},t.prototype.collapseAll=function(){this.expansionModel.clear()},t.prototype.expandAll=function(){var t;(t=this.expansionModel).select.apply(t,C(Object.keys(this._data.value.compound||{})))},t.prototype.setData=function(t){var e;null===(e=this.expansionModel)||void 0===e||e.clear(),this.dataSource=t,this._data.next(t)},t.prototype.connect=function(){var t=this,e=[this._data,this.expansionModel.changed];return n.merge.apply(void 0,C(e)).pipe(i.map((function(){return t._data.value})))},t.prototype.disconnect=function(){},t}(),E=function(){};E.decorators=[{type:r.Component,args:[{selector:"svg:defs[nz-graph-defs]",template:'\n <svg:marker\n class="nz-graph-edge-marker"\n id="edge-end-arrow"\n viewBox="1 0 20 20"\n refX="8"\n refY="3.5"\n markerWidth="10"\n markerHeight="10"\n orient="auto"\n >\n <svg:polygon points="0 0, 10 3.5, 0 7"></svg:polygon>\n </svg:marker>\n '}]}],E.ctorParameters=function(){return[]};var k=function(){function t(t,e,n){this.elementRef=t,this.ngZone=e,this.cdr=n,this.line=c.line().x((function(t){return t.x})).y((function(t){return t.y})).curve(c.curveBasis),this.el=this.elementRef.nativeElement}return Object.defineProperty(t.prototype,"id",{get:function(){var t;return(null===(t=this.edge)||void 0===t?void 0:t.id)||this.edge.v+"--"+this.edge.w},enumerable:!1,configurable:!0}),t.prototype.ngOnInit=function(){this.initElementStyle()},t.prototype.ngOnChanges=function(t){var e=this,n=t.edge,o=t.customTemplate;n&&this.ngZone.onStable.pipe(i.take(1)).subscribe((function(){o&&e.initElementStyle(),e.setLine(),e.cdr.markForCheck()}))},t.prototype.initElementStyle=function(){this.path=this.el.querySelector("path"),this.setElementData()},t.prototype.setLine=function(){this.setPath(this.line(this.edge.points))},t.prototype.setPath=function(t){this.path.setAttribute("d",t)},t.prototype.setElementData=function(){this.path&&(this.path.setAttribute("id",this.id),this.path.setAttribute("data-edge",this.id),this.path.setAttribute("data-v",""+this.edge.v),this.path.setAttribute("data-w",""+this.edge.w))},t}();k.decorators=[{type:r.Component,args:[{selector:"[nz-graph-edge]",template:'\n <ng-container *ngIf="customTemplate" [ngTemplateOutlet]="customTemplate" [ngTemplateOutletContext]="{ $implicit: edge }"></ng-container>\n <svg:g *ngIf="!customTemplate">\n <path class="nz-graph-edge-line" [attr.marker-end]="\'url(#edge-end-arrow)\'"></path>\n <svg:text class="nz-graph-edge-text" text-anchor="middle" dy="10" *ngIf="edge.label">\n <textPath [attr.href]="\'#\' + id" startOffset="50%">{{ edge.label }}</textPath>\n </svg:text>\n </svg:g>\n ',changeDetection:r.ChangeDetectionStrategy.OnPush}]}],k.ctorParameters=function(){return[{type:r.ElementRef},{type:r.NgZone},{type:r.ChangeDetectorRef}]},k.propDecorators={edge:[{type:r.Input}],customTemplate:[{type:r.Input}]};var N=function(){};N.decorators=[{type:r.Directive,args:[{selector:"[nzGraphEdge]",exportAs:"nzGraphEdge"}]}];var A=function(){};A.decorators=[{type:r.Directive,args:[{selector:"[nzGraphGroupNode]",exportAs:"nzGraphGroupNode"}]}];var R=function(){function t(t,e,n,i,o,r){var a=this;this.svg=t,this.labelPadding=r,this.zoomG=e,this.mainZoom=n,this.maxWidth=o;var s=p.select(i),h=s.select("svg"),c=h.select("rect");this.canvas=s.select("canvas.viewport").node(),this.canvasRect=this.canvas.getBoundingClientRect();var l=function(t){var e=a.minimapOffset(),n=Number(c.attr("width")),i=Number(c.attr("height")),o=p.pointer(t,h.node());a.viewpointCoord.x=o[0]-n/2-e.x,a.viewpointCoord.y=o[1]-i/2-e.y,a.updateViewpoint()};this.viewpointCoord={x:0,y:0};var u=d.drag().subject(Object).on("drag",l);c.datum(this.viewpointCoord).call(u),h.on("click",(function(t){t.defaultPrevented||l(t)})),this.viewpoint=c.node(),this.minimapSvg=h.node(),this.minimap=i,this.canvasBuffer=s.select("canvas.buffer").node(),this.update()}return t.prototype.minimapOffset=function(){return{x:(this.canvasRect.width-this.minimapSize.width)/2,y:(this.canvasRect.height-this.minimapSize.height)/2}},t.prototype.updateViewpoint=function(){p.select(this.viewpoint).attr("x",this.viewpointCoord.x).attr("y",this.viewpointCoord.y);var t=-this.viewpointCoord.x*this.scaleMain/this.scaleMinimap,e=-this.viewpointCoord.y*this.scaleMain/this.scaleMinimap;p.select(this.svg).call(this.mainZoom.transform,l.zoomIdentity.translate(t,e).scale(this.scaleMain))},t.prototype.update=function(){var t,e,n,i,o=this,r=null;try{if(0===(r=this.zoomG.getBBox()).width)return}catch(t){return}var a=p.select(this.svg),s="";try{for(var h=w(new Array(document.styleSheets.length).keys()),c=h.next();!c.done;c=h.next()){var d=c.value;try{var l=document.styleSheets[d].cssRules||document.styleSheets[d].rules;if(null==l)continue;try{for(var u=(n=void 0,w(new Array(l.length).keys())),m=u.next();!m.done;m=u.next()){s+=l[m.value].cssText.replace(/ ?tf-[\w-]+ ?/g,"")+"\n"}}catch(t){n={error:t}}finally{try{m&&!m.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}catch(t){if("SecurityError"!==t.name)throw t}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(e=h.return)&&e.call(h)}finally{if(t)throw t.error}}var g=a.append("style");g.text(s);var f=p.select(this.zoomG),y=f.attr("transform");f.attr("transform",null),r.height+=2*this.labelPadding,r.width+=2*this.labelPadding,a.attr("width",r.width).attr("height",r.height),this.scaleMinimap=this.maxWidth/Math.max(r.width,r.height),this.minimapSize={width:r.width*this.scaleMinimap,height:r.height*this.scaleMinimap};var v=this.minimapOffset();p.select(this.minimapSvg).attr(this.minimapSize),p.select(this.canvasBuffer).attr(this.minimapSize),null!=this.translate&&null!=this.zoom&&requestAnimationFrame((function(){return o.zoom()}));var z=(new XMLSerializer).serializeToString(this.svg);g.remove(),a.attr("width","100%").attr("height","100%"),f.attr("transform",y);var x=new Image;x.onload=function(){var t=o.canvasBuffer.getContext("2d");t.clearRect(0,0,o.canvasBuffer.width,o.canvasBuffer.height),t.drawImage(x,v.x,v.y,o.minimapSize.width,o.minimapSize.height),requestAnimationFrame((function(){var t;p.select(o.canvasBuffer).style("display","block"),p.select(o.canvas).style("display","none"),t=S([o.canvasBuffer,o.canvas],2),o.canvas=t[0],o.canvasBuffer=t[1]}))},x.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(z)},t.prototype.zoom=function(t){if(null!=this.scaleMinimap){t&&(this.translate=[t.x,t.y],this.scaleMain=t.k);var e=this.svg.getBoundingClientRect(),n=this.minimapOffset(),i=p.select(this.viewpoint);this.viewpointCoord.x=-this.translate[0]*this.scaleMinimap/this.scaleMain,this.viewpointCoord.y=-this.translate[1]*this.scaleMinimap/this.scaleMain;var o=e.width*this.scaleMinimap/this.scaleMain,r=e.height*this.scaleMinimap/this.scaleMain;i.attr("x",this.viewpointCoord.x+n.x).attr("y",this.viewpointCoord.y+n.y).attr("width",o).attr("height",r);var a=this.minimapSize.width,s=this.minimapSize.height,h=this.viewpointCoord.x,c=this.viewpointCoord.y;(Math.min(Math.max(0,h+o),a)-Math.min(Math.max(0,h),a))*(Math.min(Math.max(0,c+r),s)-Math.min(Math.max(0,c),s))/(a*s)<.8?this.minimap.classList.remove("hidden"):this.minimap.classList.add("hidden")}},t}(),M=function(){function t(t){this.elementRef=t}return t.prototype.ngOnInit=function(){},t.prototype.init=function(t,e){var n=t.nativeElement.querySelector("svg"),i=t.nativeElement.querySelector("svg > g");this.minimap=new R(n,i,e,this.elementRef.nativeElement,150,0)},t.prototype.zoom=function(t){this.minimap&&this.minimap.zoom(t)},t.prototype.update=function(){this.minimap&&this.minimap.update()},t}();M.decorators=[{type:r.Component,args:[{selector:"nz-graph-minimap",template:'\n <svg>\n <defs>\n <filter id="minimapDropShadow" x="-20%" y="-20%" width="150%" height="150%">\n <feOffset result="offOut" in="SourceGraphic" dx="1" dy="1"></feOffset>\n <feColorMatrix\n result="matrixOut"\n in="offOut"\n type="matrix"\n values="0.1 0 0 0 0 0 0.1 0 0 0 0 0 0.1 0 0 0 0 0 0.5 0"\n ></feColorMatrix>\n <feGaussianBlur result="blurOut" in="matrixOut" stdDeviation="2"></feGaussianBlur>\n <feBlend in="SourceGraphic" in2="blurOut" mode="normal"></feBlend>\n </filter>\n </defs>\n <rect></rect>\n </svg>\n <canvas class="viewport"></canvas>\n \x3c!-- Additional canvas to use as buffer to avoid flickering between updates --\x3e\n <canvas class="buffer"></canvas>\n ',changeDetection:r.ChangeDetectionStrategy.OnPush,host:{"[class.nz-graph-minimap]":"true"}}]}],M.ctorParameters=function(){return[{type:r.ElementRef}]};var T=function(){function t(t,e,n){this.el=t,this.builder=e,this.renderer2=n,this.nodeClick=new r.EventEmitter,this.animationInfo=null,this.initialState=!0,this.animationPlayer=null}return t.prototype.triggerClick=function(t){t.preventDefault(),this.nodeClick.emit(this.node)},t.prototype.makeAnimation=function(){var t,e=this,i=this.getAnimationInfo();this.animationPlayer&&this.animationPlayer.destroy();var o=Object.assign({},this.animationInfo);this.initialState?(t=this.builder.build([u.style({transform:"translate("+i.x+"px, "+i.y+"px)"}),u.query("g",[u.style({width:i.width+"px",height:i.height+"px"})])]),this.initialState=!1):t=this.builder.build([u.style({transform:"translate("+o.x+"px, "+o.y+"px)"}),u.query("g",[u.style({width:o.width+"px",height:o.height+"px"})]),u.group([u.query("g",[u.animate("150ms ease-out",u.style({width:i.width+"px",height:i.height+"px"}))]),u.animate("150ms ease-out",u.style({transform:"translate("+i.x+"px, "+i.y+"px)"}))])]),this.animationInfo=i,this.animationPlayer=t.create(this.el.nativeElement),this.animationPlayer.play();var r=new n.Subject;return this.animationPlayer.onDone((function(){e.renderer2.setAttribute(e.el.nativeElement,"transform","translate("+i.x+", "+i.y+")"),r.next(),r.complete()})),r.asObservable()},t.prototype.makeNoAnimation=function(){var t=this.getAnimationInfo();this.renderer2.setAttribute(this.el.nativeElement,"transform","translate("+t.x+", "+t.y+")")},t.prototype.getAnimationInfo=function(){var t=this.nodeTransform(),e=t.x,n=t.y;return{width:this.node.width,height:this.node.height,x:e,y:n}},t.prototype.nodeTransform=function(){return{x:this.computeCXPositionOfNodeShape()-this.node.width/2,y:this.node.y-this.node.height/2}},t.prototype.computeCXPositionOfNodeShape=function(){return this.node.expanded?this.node.x:this.node.x-this.node.width/2+this.node.coreBox.width/2},t}();T.decorators=[{type:r.Component,args:[{selector:"[nz-graph-node]",template:'\n <svg:g>\n <ng-container\n *ngIf="customTemplate"\n [ngTemplateOutlet]="customTemplate"\n [ngTemplateOutletContext]="{ $implicit: node }"\n ></ng-container>\n <ng-container *ngIf="!customTemplate">\n <svg:rect class="nz-graph-node-rect" [attr.width]="node.width" [attr.height]="node.height"></svg:rect>\n <svg:text x="10" y="20">{{ node.id || node.name }}</svg:text>\n </ng-container>\n </svg:g>\n ',changeDetection:r.ChangeDetectionStrategy.OnPush,host:{"[id]":"node.id || node.name","[class.nz-graph-node-expanded]":"node.expanded","[class.nz-graph-group-node]":"node.type===0","[class.nz-graph-base-node]":"node.type===1","(click)":"triggerClick($event)"}}]}],T.ctorParameters=function(){return[{type:r.ElementRef},{type:u.AnimationBuilder},{type:r.Renderer2}]},T.propDecorators={node:[{type:r.Input}],noAnimation:[{type:r.Input}],customTemplate:[{type:r.Input}],nodeClick:[{type:r.Output}]},x([m.InputBoolean(),b("design:type",Boolean)],T.prototype,"noAnimation",void 0);var G=function(){};G.decorators=[{type:r.Directive,args:[{selector:"[nzGraphNode]",exportAs:"nzGraphNode"}]}];var I=function(t,e,n){var i=t.getBoundingClientRect(),o=e.getBBox();if(!o.width)return null;var r=(i.width-48)/i.width,a=n||Math.min(i.width/o.width,i.height/o.height,1)*r;return{x:(i.width-o.width*a)/2,y:(i.height-o.height*a)/2,k:a}};Selection.bind("transition",g.transition);var D=function(){function t(t,e){this.element=t,this.cdr=e,this.nzMinZoom=.1,this.nzMaxZoom=10,this.nzTransformEvent=new r.EventEmitter,this.nzZoomChange=new r.EventEmitter,this.destroy$=new n.Subject}return t.prototype.ngAfterViewInit=function(){this.bind()},t.prototype.ngOnDestroy=function(){this.unbind(),this.destroy$.next(),this.destroy$.complete()},t.prototype.bind=function(){var t=this;this.svgElement=this.element.nativeElement.querySelector("svg"),this.gZoomElement=this.element.nativeElement.querySelector("svg > g");var e=this.element.nativeElement.getBoundingClientRect(),n=e.width,i=e.height;this.svgSelection=p.select(this.svgElement),this.zoomBehavior=l.zoom().extent([[0,0],[n,i]]).scaleExtent([this.nzMinZoom,this.nzMaxZoom]).on("zoom",(function(e){t.zoomed(e)})),this.svgSelection.call(this.zoomBehavior,l.zoomIdentity.translate(0,0).scale(this.nzZoom||1)),this.reScale(0,this.nzZoom)},t.prototype.unbind=function(){var t;null===(t=this.svgSelection)||void 0===t||t.interrupt().selectAll("*").interrupt(),this.zoomBehavior&&this.zoomBehavior.on("end",null).on("zoom",null)},t.prototype.fitCenter=function(t){void 0===t&&(t=0),this.reScale(t)},t.prototype.focus=function(t,e){if(void 0===e&&(e=0),this.svgElement.getElementById(""+t)){var n=this.svgElement.getElementById(""+t),i=this.svgElement.getBoundingClientRect(),o=this.getRelativePositionInfo(n),r=l.zoomTransform(this.svgElement),a=(o.topLeft.x+o.bottomRight.x)/2,s=(o.topLeft.y+o.bottomRight.y)/2,h=i.left+i.width/2-a,c=i.top+i.height/2-s;this.svgSelection.transition().duration(e).call(this.zoomBehavior.translateBy,h/r.k,c/r.k)}},t.prototype.zoomed=function(t){var e=t.transform,n=e.x,i=e.y,o=e.k;this.gZoomElement.setAttribute("transform","translate("+n+", "+i+")scale("+o+")"),this.nzZoom=o,this.nzZoomChange.emit(this.nzZoom),this.nzTransformEvent.emit(e),this.cdr.markForCheck()},t.prototype.reScale=function(t,e){var n=this,i=I(this.svgElement,this.gZoomElement,e);if(i){var o=i.x,r=i.y,a=i.k,s=l.zoomIdentity.translate(o,r).scale(Math.max(a,this.nzMinZoom));this.svgSelection.transition().duration(t).call(this.zoomBehavior.transform,s).on("end.fitted",(function(){n.zoomBehavior.on("end.fitted",null)}))}},t.prototype.getRelativePositionInfo=function(t){var e=t.getBBox(),n=t.getScreenCTM(),i=this.svgElement.createSVGPoint(),o=this.svgElement.createSVGPoint();return i.x=e.x,i.y=e.y,o.x=e.x+e.width,o.y=e.y+e.height,{topLeft:i=i.matrixTransform(n),bottomRight:o=o.matrixTransform(n)}},t}();function B(t){return t&&"function"==typeof t.connect}D.decorators=[{type:r.Directive,args:[{selector:"[nz-graph-zoom]",exportAs:"nzGraphZoom"}]}],D.ctorParameters=function(){return[{type:r.ElementRef},{type:r.ChangeDetectorRef}]},D.propDecorators={nzZoom:[{type:r.Input}],nzMinZoom:[{type:r.Input}],nzMaxZoom:[{type:r.Input}],nzTransformEvent:[{type:r.Output}],nzZoomChange:[{type:r.Output}]};var j=function(){function t(t,e,i,o){this.cdr=t,this.elementRef=e,this.noAnimation=i,this.nzGraphZoom=o,this.nzRankDirection="LR",this.nzAutoSize=!1,this.nzGraphInitialized=new r.EventEmitter,this.nzGraphRendered=new r.EventEmitter,this.nzNodeClick=new r.EventEmitter,this.requestId=-1,this.transformStyle="",this.graphRenderedSubject$=new n.ReplaySubject(1),this.renderInfo={labelHeight:0},this.mapOfNodeAttr={},this.mapOfEdgeAttr={},this.zoom=1,this.typedNodes=function(t){return t},this.layoutSetting=z,this.destroy$=new n.Subject,this.nodeTrackByFun=function(t,e){return e.name},this.edgeTrackByFun=function(t,e){return e.v+"-"+e.w},this.subGraphTransform=function(t){return"translate("+(t.x-t.coreBox.width/2)+", "+(t.y-t.height/2+t.paddingTop)+")"},this.coreTransform=function(t){return"translate(0, "+(t.parentNodeName?t.labelHeight:0)+")"}}return t.prototype.ngOnInit=function(){var t=this;this.graphRenderedSubject$.pipe(i.take(1),i.takeUntil(this.destroy$)).subscribe((function(){t.nzGraphZoom||t.fitCenter(),t.nzGraphInitialized.emit(t)}))},t.prototype.ngOnChanges=function(t){var e=this,n=t.nzAutoFit,i=t.nzRankDirection,o=t.nzGraphData,r=t.nzGraphLayoutConfig;r&&(this.layoutSetting=this.mergeConfig(r.currentValue)),o&&this.dataSource!==this.nzGraphData&&this._switchDataSource(this.nzGraphData),(n&&!n.firstChange||i&&!i.firstChange)&&this.dataSource.dataSource&&this.drawGraph(this.dataSource.dataSource,{rankDirection:this.nzRankDirection,expanded:this.dataSource.expansionModel.selected||[]}).then((function(){e.cdr.markForCheck()})),this.cdr.markForCheck()},t.prototype.ngAfterViewInit=function(){},t.prototype.ngAfterContentChecked=function(){this.dataSource&&!this._dataSubscription&&this.observeRenderChanges()},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.dataSource&&"function"==typeof this.dataSource.disconnect&&this.dataSource.disconnect(),this._dataSubscription&&(this._dataSubscription.unsubscribe(),this._dataSubscription=null),y.cancelRequestAnimationFrame(this.requestId)},t.prototype.clickNode=function(t){this.nzNodeClick.emit(t)},t.prototype.fitCenter=function(){var t=I(this.elementRef.nativeElement.querySelector("svg"),this.elementRef.nativeElement.querySelector("svg > g")),e=t.x,n=t.y,i=t.k;i&&(this.zoom=i,this.transformStyle="translate("+e+", "+n+")scale("+i+")"),this.cdr.markForCheck()},t.prototype.drawGraph=function(t,e,n){var i=this;return void 0===n&&(n=!1),new Promise((function(o){i.requestId=requestAnimationFrame((function(){var r=i.buildGraphInfo(t,e);i.renderInfo=r,i.cdr.markForCheck(),i.requestId=requestAnimationFrame((function(){var t;i.drawNodes(!(null===(t=i.noAnimation)||void 0===t?void 0:t.nzNoAnimation)).then((function(){i.cdr.markForCheck(),n?i.resizeNodeSize().then((function(){var t=i.dataSource.dataSource;i.drawGraph(t,e,!1).then((function(){return o()}))})):(i.graphRenderedSubject$.next(),i.nzGraphRendered.emit(i),o())}))}))})),i.cdr.markForCheck()}))},t.prototype.drawNodes=function(t){var e=this;return void 0===t&&(t=!0),new Promise((function(n){t?e.makeNodesAnimation().subscribe((function(){n()})):(e.listOfNodeComponent.map((function(t){t.makeNoAnimation()})),n())}))},t.prototype.resizeNodeSize=function(){var t=this;return new Promise((function(e){var n,i=t.dataSource.dataSource,o=(null===(n=t.nzGraphZoom)||void 0===n?void 0:n.nzZoom)||t.zoom||1;t.listOfNodeElement.forEach((function(t){var e,n=t.nativeElement;if(n){var r=void 0,a=void 0,s=null===(e=n.querySelector("foreignObject > :first-child"))||void 0===e?void 0:e.getBoundingClientRect();if(s)r=s.width,a=s.height;else{var h=n.getBBox();r=h.width,a=h.height,o=1}var c=i.nodes.find((function(e){return""+e.id===t.nativeElement.id}));c&&r&&a&&(c.height=a/o,c.width=r/o)}})),e()}))},t.prototype._switchDataSource=function(t){this.dataSource&&"function"==typeof this.dataSource.disconnect&&this.nzGraphData.disconnect(),this._dataSubscription&&(this._dataSubscription.unsubscribe(),this._dataSubscription=null),this.dataSource=t,this.observeRenderChanges()},t.prototype.observeRenderChanges=function(){var t,e=this,n={rankDirection:this.nzRankDirection};if(B(this.dataSource)&&(t=this.dataSource.connect()),!t)throw Error("A valid data source must be provided.");this._dataSubscription=t.pipe(i.takeUntil(this.destroy$)).subscribe((function(t){n={rankDirection:e.nzRankDirection,expanded:e.nzGraphData.expansionModel.selected},e.drawGraph(t,n,e.nzAutoSize).then((function(){e.cdr.detectChanges()}))}))},t.prototype.buildGraphInfo=function(t,e){var n=this;this.parseInfo(t);var i=f.buildGraph(t,e,this.layoutSetting),o=function(t){t.forEach((function(t){1===t.type&&n.mapOfNodeAttr.hasOwnProperty(t.name)?Object.assign(t,n.mapOfNodeAttr[t.name]):0===t.type&&(t.edges.forEach((function(t){n.mapOfEdgeAttr.hasOwnProperty(t.v+"-"+t.w)&&Object.assign(t,n.mapOfEdgeAttr[t.v+"-"+t.w])})),o(t.nodes))}))};return o(i.nodes),i.edges.forEach((function(t){n.mapOfEdgeAttr.hasOwnProperty(t.v+"-"+t.w)&&Object.assign(t,n.mapOfEdgeAttr[t.v+"-"+t.w])})),i},t.prototype.makeNodesAnimation=function(){var t=this;return n.forkJoin.apply(void 0,C(this.listOfNodeComponent.map((function(t){return t.makeAnimation()})))).pipe(i.finalize((function(){t.cdr.detectChanges()})))},t.prototype.parseInfo=function(t){var e=this;t.nodes.forEach((function(t){e.mapOfNodeAttr[t.id]=t})),t.edges.forEach((function(t){e.mapOfEdgeAttr[t.v+"-"+t.w]=t}))},t.prototype.mergeConfig=function(t){var e=(null==t?void 0:t.layout)||{},n=(null==t?void 0:t.subScene)||{},i=(null==t?void 0:t.defaultNode)||{},o=(null==t?void 0:t.defaultCompoundNode)||{},r=z.nodeSize.bridge;return{graph:{meta:Object.assign(Object.assign({},z.graph.meta),e)},subScene:{meta:Object.assign(Object.assign({},z.subScene.meta),n)},nodeSize:{meta:Object.assign(Object.assign({},z.nodeSize.meta),o),node:Object.assign(Object.assign({},z.nodeSize.node),i),bridge:r}}},t}();j.decorators=[{type:r.Component,args:[{changeDetection:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None,selector:"nz-graph",exportAs:"nzGraph",template:'\n <ng-content></ng-content>\n <svg width="100%" height="100%">\n <svg:defs nz-graph-defs></svg:defs>\n <svg:g [attr.transform]="transformStyle">\n <ng-container\n [ngTemplateOutlet]="groupTemplate"\n [ngTemplateOutletContext]="{ renderNode: renderInfo, type: \'root\' }"\n ></ng-container>\n </svg:g>\n </svg>\n\n <ng-template #groupTemplate let-renderNode="renderNode" let-type="type">\n <svg:g [attr.transform]="type === \'sub\' ? subGraphTransform(renderNode) : null">\n <svg:g class="core" [attr.transform]="coreTransform(renderNode)">\n <svg:g class="nz-graph-edges">\n <ng-container *ngFor="let edge of renderNode.edges; trackBy: edgeTrackByFun">\n <g class="nz-graph-edge" nz-graph-edge [edge]="edge" [customTemplate]="customGraphEdgeTemplate"></g>\n </ng-container>\n </svg:g>\n\n <svg:g class="nz-graph-nodes">\n <ng-container *ngFor="let node of typedNodes(renderNode.nodes); trackBy: nodeTrackByFun">\n <g\n *ngIf="node.type === 1"\n class="nz-graph-node"\n nz-graph-node\n [node]="node"\n [customTemplate]="nodeTemplate"\n (nodeClick)="clickNode($event)"\n ></g>\n <g\n *ngIf="node.type === 0"\n class="nz-graph-node"\n nz-graph-node\n [node]="node"\n [customTemplate]="groupNodeTemplate"\n (nodeClick)="clickNode($event)"\n ></g>\n <ng-container\n *ngIf="node.expanded"\n [ngTemplateOutlet]="groupTemplate"\n [ngTemplateOutletContext]="{ renderNode: node, type: \'sub\' }"\n ></ng-container>\n </ng-container>\n </svg:g>\n </svg:g>\n </svg:g>\n </ng-template>\n ',host:{"[class.nz-graph]":"true","[class.nz-graph-auto-size]":"nzAutoSize"}}]}],j.ctorParameters=function(){return[{type:r.ChangeDetectorRef},{type:r.ElementRef},{type:a.NzNoAnimationDirective,decorators:[{type:r.Host},{type:r.Optional}]},{type:D,decorators:[{type:r.Optional}]}]},j.propDecorators={listOfNodeElement:[{type:r.ViewChildren,args:[T,{read:r.ElementRef}]}],listOfNodeComponent:[{type:r.ViewChildren,args:[T]}],nodeTemplate:[{type:r.ContentChild,args:[G,{static:!0,read:r.TemplateRef}]}],groupNodeTemplate:[{type:r.ContentChild,args:[A,{static:!0,read:r.TemplateRef}]}],customGraphEdgeTemplate:[{type:r.ContentChild,args:[N,{static:!0,read:r.TemplateRef}]}],nzGraphData:[{type:r.Input}],nzRankDirection:[{type:r.Input}],nzGraphLayoutConfig:[{type:r.Input}],nzAutoSize:[{type:r.Input}],nzGraphInitialized:[{type:r.Output}],nzGraphRendered:[{type:r.Output}],nzNodeClick:[{type:r.Output}]},x([m.InputBoolean(),b("design:type",Object)],j.prototype,"nzAutoSize",void 0);var P=[j,M,E,G,A,D,T,k,N],q=function(){};q.decorators=[{type:r.NgModule,args:[{declarations:C(P),imports:[o.CommonModule,s.NzIconModule,h.NzSpinModule,a.NzNoAnimationModule],exports:C(P)}]}],t.NZ_GRAPH_LAYOUT_SETTING=z,t.NzGraphComponent=j,t.NzGraphData=O,t.NzGraphEdgeComponent=k,t.NzGraphEdgeDirective=N,t.NzGraphGroupNodeDirective=A,t.NzGraphMinimapComponent=M,t.NzGraphModule=q,t.NzGraphNodeComponent=T,t.NzGraphNodeDirective=G,t.NzGraphZoomDirective=D,t.isDataSource=B,t.nzTypeDefinition=v,t.ɵa=E,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-graph.umd.min.js.map