e;++e)r=Math.max(r,t[e].x),o=Math.min(o,t[e].x),a=Math.min(a,t[e].y),s=Math.max(s,t[e].y);return new G(o,a,r-o,s-a)}}),F=M.extend({init:function(e){var t=this;M.fn.init.call(t),this.connection=e},route:function(){}}),P=M.extend({SAME_SIDE_DISTANCE_RATIO:5,init:function(e){var t=this;M.fn.init.call(t),this.connection=e},routePoints:function(e,t,n,i){var r;return r=n&&i?this._connectorPoints(e,t,n,i):this._floatingPoints(e,t,n)},route:function(){var e=this.connection._resolvedSourceConnector,t=this.connection._resolvedTargetConnector,n=this.connection.sourcePoint(),i=this.connection.targetPoint(),r=this.routePoints(n,i,e,t);this.connection.points(r)},_connectorSides:[{name:"Top",axis:"y",boundsPoint:"topLeft",secondarySign:1},{name:"Left",axis:"x",boundsPoint:"topLeft",secondarySign:1},{name:"Bottom",axis:"y",boundsPoint:"bottomRight",secondarySign:-1},{name:"Right",axis:"x",boundsPoint:"bottomRight",secondarySign:-1}],_connectorSide:function(e,t){var n,i,r,o,a,s=e.position(),l=e.shape.bounds(Me),c={topLeft:l.topLeft(),bottomRight:l.bottomRight()},d=this._connectorSides,u=V.util.MAX_NUM;for(a=0;d.length>a;a++)o=d[a],r=o.axis,n=Math.round(Math.abs(s[r]-c[o.boundsPoint][r])),u>n?(u=n,i=o):n===u&&(s[r]-t[r])*o.secondarySign>(s[i.axis]-t[i.axis])*i.secondarySign&&(i=o);return i.name},_sameSideDistance:function(e){var t=e.shape.bounds(Me);return Math.min(t.width,t.height)/this.SAME_SIDE_DISTANCE_RATIO},_connectorPoints:function(e,t,n,i){var r,o,a=this._connectorSide(n,t),s=this._connectorSide(i,e),l=t.x-e.x,c=t.y-e.y,d=this._sameSideDistance(n),u=[];return a===le||a==ue?s==le||s==ue?a==s?(o=a==le?Math.min(e.y,t.y)-d:Math.max(e.y,t.y)+d,u=[new Q(e.x,o),new Q(t.x,o)]):u=[new Q(e.x,e.y+c/2),new Q(t.x,e.y+c/2)]:u=[new Q(e.x,t.y)]:s==de||s==ce?a==s?(r=a==de?Math.min(e.x,t.x)-d:Math.max(e.x,t.x)+d,u=[new Q(r,e.y),new Q(r,t.y)]):u=[new Q(e.x+l/2,e.y),new Q(e.x+l/2,e.y+c)]:u=[new Q(t.x,e.y)],u},_floatingPoints:function(e,t,n){var i,r,o,a=n?this._connectorSide(n,t):null,s=this._startHorizontal(e,t,a),l=[e,e,t,t],c=t.x-e.x,d=t.y-e.y,u=l.length;for(o=1;u-1>o;++o)s?o%2!==0?(i=c/(u/2),r=0):(i=0,r=d/((u-1)/2)):o%2!==0?(i=0,r=d/(u/2)):(i=c/((u-1)/2),r=0),l[o]=new Q(l[o-1].x+i,l[o-1].y+r);return o--,l[u-2]=s&&o%2!==0||!s&&o%2===0?new Q(l[u-1].x,l[u-2].y):new Q(l[u-2].x,l[u-1].y),[l[1],l[2]]},_startHorizontal:function(e,t,n){var i;return i=null===n||n!==ce&&n!==de?Math.abs(e.x-t.x)>Math.abs(e.y-t.y):!0}}),z=j.extend({init:function(e,t){var n=this;n.diagram=e,n.options=Z({},n.options,t),n.visual=new q,n.diagram._adorners.push(n)},refresh:function(){}}),B=z.extend({init:function(e,t){var n,i,r,o=this;o.connection=e,n=o.connection.diagram,o._ts=n.toolService,z.fn.init.call(o,n,t),i=o.connection.sourcePoint(),r=o.connection.targetPoint(),o.spVisual=new X(Z(o.options.handles,{center:i})),o.epVisual=new X(Z(o.options.handles,{center:r})),o.visual.append(o.spVisual),o.visual.append(o.epVisual)},options:{handles:{}},_getCursor:function(){return oe.move},start:function(e){switch(this.handle=this._hitTest(e),this.startPoint=e,this._initialSource=this.connection.source(),this._initialTarget=this.connection.target(),this.handle){case-1:this.connection.targetConnector&&this._ts._connectionManipulation(this.connection,this.connection.targetConnector.shape);break;case 1:this.connection.sourceConnector&&this._ts._connectionManipulation(this.connection,this.connection.sourceConnector.shape)}},move:function(e,t){switch(e){case-1:this.connection.source(t);break;case 1:this.connection.target(t);break;default:var n=t.minus(this.startPoint);this.startPoint=t,this.connection.sourceConnector||this.connection.source(this.connection.sourcePoint().plus(n)),this.connection.targetConnector||this.connection.target(this.connection.targetPoint().plus(n))}return this.refresh(),!0},stop:function(e){var n,i=this.diagram.toolService,r=i.hoveredItem;return n=i._hoveredConnector?i._hoveredConnector._c:r&&r instanceof W.Shape?r.getConnector(se)||r.getConnector(e):e,-1===this.handle?this.connection.source(n):1===this.handle&&this.connection.target(n),this.handle=t,this._ts._connectionManipulation(),new f(this.connection,this._initialSource,this._initialTarget)},_hitTest:function(e){var t=this.connection.sourcePoint(),n=this.connection.targetPoint(),i=this.options.handles.width/2,r=this.options.handles.height/2,o=new G(t.x,t.y).inflate(i,r),a=new G(n.x,n.y).inflate(i,r);return o.contains(e)?-1:a.contains(e)?1:0},refresh:function(){this.spVisual.redraw({center:this.diagram.modelToLayer(this.connection.sourcePoint())}),this.epVisual.redraw({center:this.diagram.modelToLayer(this.connection.targetPoint())})}}),L=z.extend({init:function(e,t){var n=this;z.fn.init.call(n,e,t),n._refreshHandler=function(e){e.item==n.shape&&n.refresh()}},show:function(e){var t,n,i,r=this;for(r._visible=!0,r.shape=e,r.diagram.bind(_e,r._refreshHandler),t=e.connectors.length,r.connectors=[],r.visual.clear(),n=0;t>n;n++)i=new O(e.connectors[n]),r.connectors.push(i),r.visual.append(i.visual);r.visual.visible(!0),r.refresh()},destroy:function(){var e=this;e.diagram.unbind(_e,e._refreshHandler),e.shape=t,e._visible=t,e.visual.visible(!1)},_hitTest:function(e){var t,n;for(n=0;this.connectors.length>n;n++)if(t=this.connectors[n],t._hitTest(e)){t._hover(!0),this.diagram.toolService._hoveredConnector=t;break}},refresh:function(){if(this.shape){var t=this.shape.bounds();t=this.diagram.modelToLayer(t),this.visual.position(t.topLeft()),e.each(this.connectors,function(){this.refresh()})}}}),H=z.extend({init:function(e,t){var n=this;z.fn.init.call(n,e,t),n._manipulating=!1,n.map=[],n.shapes=[],n._initSelection(),n._createHandles(),n.redraw(),n.diagram.bind("select",function(e){n._initialize(e.selected)}),n._refreshHandler=function(){n._internalChange||(n.refreshBounds(),n.refresh())},n._rotatedHandler=function(){1==n.shapes.length&&(n._angle=n.shapes[0].rotate().angle),n._refreshHandler()},n.diagram.bind(_e,n._refreshHandler).bind(ve,n._rotatedHandler),n.refreshBounds(),n.refresh()},options:{handles:{fill:{color:"#fff"},stroke:{color:"#282828"},height:7,width:7,hover:{fill:{color:"#282828"},stroke:{color:"#282828"}}},selectable:{stroke:{color:"#778899",width:1,dashType:"dash"},fill:{color:Ie}},offset:10},_initSelection:function(){var e=this,t=e.diagram,n=t.options.selectable,i=Z({},e.options.selectable,n);e.rect=new $(i),e.visual.append(e.rect)},_resizable:function(){return this.options.editable&&this.options.editable.resize!==!1},_handleOptions:function(){return(this.options.editable.resize||{}).handles||this.options.handles},_createHandles:function(){var e,t,n,i;if(this._resizable())for(e=this._handleOptions(),i=-1;1>=i;i++)for(n=-1;1>=n;n++)(0!==i||0!==n)&&(t=new $(e),t.drawingElement._hover=re(this._hover,this),this.map.push({x:i,y:n,visual:t}),this.visual.append(t))},bounds:function(e){return e?(this._innerBounds=e.clone(),this._bounds=this.diagram.modelToLayer(e).inflate(this.options.offset,this.options.offset),t):this._bounds},_hitTest:function(e){var n,i,r,o,a=this.diagram.modelToLayer(e),s=this.map.length;if(this._angle&&(a=a.clone().rotate(this._bounds.center(),this._angle)),this._resizable())for(n=0;s>n;n++)if(o=this.map[n],i=new Q(o.x,o.y),r=this._getHandleBounds(i),r.offset(this._bounds.x,this._bounds.y),r.contains(a))return i;return this._bounds.contains(a)?new Q(0,0):t},_getHandleBounds:function(e){if(this._resizable()){var t=this._handleOptions(),n=t.width,i=t.height,r=new G(0,0,n,i);return 0>e.x?r.x=-n/2:0===e.x?r.x=Math.floor(this._bounds.width/2)-n/2:e.x>0&&(r.x=this._bounds.width+1-n/2),0>e.y?r.y=-i/2:0===e.y?r.y=Math.floor(this._bounds.height/2)-i/2:e.y>0&&(r.y=this._bounds.height+1-i/2),r}},_getCursor:function(e){var t,n=this._hitTest(e);if(n&&n.x>=-1&&1>=n.x&&n.y>=-1&&1>=n.y&&this._resizable()){if(t=this._angle,t&&(t=360-t,n.rotate(new Q(0,0),t),n=new Q(Math.round(n.x),Math.round(n.y))),-1==n.x&&-1==n.y)return"nw-resize";if(1==n.x&&1==n.y)return"se-resize";if(-1==n.x&&1==n.y)return"sw-resize";if(1==n.x&&-1==n.y)return"ne-resize";if(0===n.x&&-1==n.y)return"n-resize";if(0===n.x&&1==n.y)return"s-resize";if(1==n.x&&0===n.y)return"e-resize";if(-1==n.x&&0===n.y)return"w-resize"}return this._manipulating?oe.move:oe.select},_initialize:function(){var e,t,n=this,i=n.diagram.select();for(n.shapes=[],e=0;i.length>e;e++)t=i[e],t instanceof W.Shape&&(n.shapes.push(t),t._rotationOffset=new Q);n._angle=1==n.shapes.length?n.shapes[0].rotate().angle:0,n._startAngle=n._angle,n._rotates(),n._positions(),n.refreshBounds(),n.refresh(),n.redraw()},_rotates:function(){var e,t,n=this;for(n.initialRotates=[],e=0;n.shapes.length>e;e++)t=n.shapes[e],n.initialRotates.push(t.rotate().angle)},_positions:function(){var e,t,n=this;for(n.initialStates=[],e=0;n.shapes.length>e;e++)t=n.shapes[e],n.initialStates.push(t.bounds())},_hover:function(e,t){if(this._resizable()){var n=this._handleOptions(),i=n.hover,r=n.stroke,o=n.fill;e&&Y.isDefined(i.stroke)&&(r=Z({},r,i.stroke)),e&&Y.isDefined(i.fill)&&(o=i.fill),t.stroke(r.color,r.width,r.opacity),t.fill(o.color,o.opacity)}},start:function(e){var t,n;for(this._sp=e,this._cp=e,this._lp=e,this._manipulating=!0,this._internalChange=!0,this.shapeStates=[],t=0;this.shapes.length>t;t++)n=this.shapes[t],this.shapeStates.push(n.bounds())},redraw:function(){var e,t,n=this._resizable();for(e=0;this.map.length>e;e++)t=this.map[e],t.visual.visible(n)},angle:function(e){return ne(e)&&(this._angle=e),this._angle},rotate:function(){var e,t,n=this._innerBounds.center(),i=this.angle();for(this._internalChange=!0,e=0;this.shapes.length>e;e++)t=this.shapes[e],i=(i+this.initialRotates[e]-this._startAngle)%360,t.rotate(i,n);this.refresh()},move:function(e,n){var i,r,o,l,c,d,u,h,f,p,g,m,v,_,b=new Q,w=new Q,y=0;if(-2===e.y&&-1===e.x){for(l=this._innerBounds.center(),this._angle=this._truncateAngle(Y.findAngle(l,n)),d=0;this.shapes.length>d;d++)c=this.shapes[d],u=(this._angle+this.initialRotates[d]-this._startAngle)%360,c.rotate(u,l),c.hasOwnProperty("layout")&&c.layout(c),this._rotating=!0;this.refresh()}else{if(this.shouldSnap()){if(m=this._truncateDistance(n.minus(this._lp)),0===m.x&&0===m.y)return this._cp=n,t;i=m,this._lp=new Q(this._lp.x+m.x,this._lp.y+m.y)}else i=n.minus(this._cp);for(this.isDragHandle(e)?(w=b=i,r=!0):(this._angle&&i.rotate(new Q(0,0),this._angle),-1==e.x?b.x=i.x:1==e.x&&(w.x=i.x),-1==e.y?b.y=i.y:1==e.y&&(w.y=i.y)),r||(f=a(e,this._innerBounds),p=(this._innerBounds.width+i.x*e.x)/this._innerBounds.width,g=(this._innerBounds.height+i.y*e.y)/this._innerBounds.height),d=0;this.shapes.length>d;d++){if(c=this.shapes[d],o=c.bounds(),r){if(!s(c))continue;h=this._displaceBounds(o,b,w,r)}else h=o.clone(),h.scale(p,g,f,this._innerBounds.center(),c.rotate().angle),v=h.center(),v.rotate(o.center(),-this._angle),h=new G(v.x-h.width/2,v.y-h.height/2,h.width,h.height);h.width>=c.options.minWidth&&h.height>=c.options.minHeight&&(_=o,c.bounds(h),c.hasOwnProperty("layout")&&c.layout(c,_,h),(_.width!==h.width||_.height!==h.height)&&c.rotate(c.rotate().angle),y+=1)}y&&(y==d?(h=this._displaceBounds(this._innerBounds,b,w,r),this.bounds(h)):this.refreshBounds(),this.refresh()),this._positions()}this._cp=n},isDragHandle:function(e){return 0===e.x&&0===e.y},cancel:function(){var e,n=this.shapes,i=this.shapeStates;for(e=0;n.length>e;e++)n[e].bounds(i[e]);this.refreshBounds(),this.refresh(),this._manipulating=t,this._internalChange=t,this._rotating=t},_truncatePositionToGuides:function(e){return this.diagram.ruler?this.diagram.ruler.truncatePositionToGuides(e):e},_truncateSizeToGuides:function(e){return this.diagram.ruler?this.diagram.ruler.truncateSizeToGuides(e):e},_truncateAngle:function(e){var t=this.snapOptions(),n=Math.max(t.angle||fe,we);return t?Math.floor(e%360/n)*n:e%360},_truncateDistance:function(e){var t,n;return e instanceof W.Point?new W.Point(this._truncateDistance(e.x),this._truncateDistance(e.y)):(t=this.snapOptions()||{},n=Math.max(t.size||he,be),t?Math.floor(e/n)*n:e)},snapOptions:function(){var e=this.diagram.options.editable,t=((e||{}).drag||{}).snap||{};return t},shouldSnap:function(){var e=this.diagram.options.editable,t=(e||{}).drag,n=(t||{}).snap;return e!==!1&&t!==!1&&n!==!1},_displaceBounds:function(e,t,n,i){var r,o=e.topLeft().plus(t),a=e.bottomRight().plus(n),s=G.fromPoints(o,a);return i||(r=s.center(),r.rotate(e.center(),-this._angle),s=new G(r.x-s.width/2,r.y-s.height/2,s.width,s.height)),s},stop:function(){var e,n,i,r;if(this._cp!=this._sp)if(this._rotating)e=new w(this,this.shapes,this.initialRotates),this._rotating=!1;else if(this._diffStates()){if(this.diagram.ruler)for(n=0;this.shapes.length>n;n++)i=this.shapes[n],r=i.bounds(),r=this._truncateSizeToGuides(this._truncatePositionToGuides(r)),i.bounds(r),this.refreshBounds(),this.refresh();for(n=0;this.shapes.length>n;n++)i=this.shapes[n],i.updateModel();e=new m(this.shapes,this.shapeStates,this),this.diagram._syncShapeChanges()}return this._manipulating=t,this._internalChange=t,this._rotating=t,e},_diffStates:function(){var e,t=this.shapes,n=this.shapeStates;for(e=0;t.length>e;e++)if(!t[e].bounds().equals(n[e]))return!0;return!1},refreshBounds:function(){var e=1==this.shapes.length?this.shapes[0].bounds().clone():this.diagram.boundingBox(this.shapes,!0);this.bounds(e)},refresh:function(){var t,n,i,r,o=this;this.shapes.length>0?(n=this.bounds(),this.visual.visible(!0),this.visual.position(n.topLeft()),e.each(this.map,function(){t=o._getHandleBounds(new Q(this.x,this.y)),this.visual.position(t.topLeft())}),this.visual.position(n.topLeft()),i=new Q(n.width/2,n.height/2),this.visual.rotate(this._angle,i),this.rect.redraw({width:n.width,height:n.height}),this.rotationThumb&&(r=this.options.editable.rotate.thumb,this._rotationThumbBounds=new G(n.center().x,n.y+r.y,0,0).inflate(r.width),this.rotationThumb.redraw({x:n.width/2-r.width/2}))):this.visual.visible(!1)}}),N=j.extend({init:function(e){var t=e.options.selectable;this.options=Z({},this.options,t),this.visual=new $(this.options),this.diagram=e},options:{stroke:{color:"#778899",width:1,dashType:"dash"},fill:{color:Ie}},start:function(e){this._sp=this._ep=e,this.refresh(),this.diagram._adorn(this,!0)},end:function(){this._sp=this._ep=t,this.diagram._adorn(this,!1)},bounds:function(e){return e&&(this._bounds=e),this._bounds},move:function(e){this._ep=e,this.refresh()},refresh:function(){if(this._sp){var e=G.fromPoints(this.diagram.modelToLayer(this._sp),this.diagram.modelToLayer(this._ep));this.bounds(G.fromPoints(this._sp,this._ep)),this.visual.position(e.topLeft()),this.visual.redraw({height:e.height+1,width:e.width+1})}}}),O=j.extend({init:function(e){this.options=Z({},e.options),this._c=e,this.visual=new X(this.options),this.refresh()},_hover:function(e){var t=this.options,n=t.hover,i=t.stroke,r=t.fill;e&&Y.isDefined(n.stroke)&&(i=Z({},i,n.stroke)),e&&Y.isDefined(n.fill)&&(r=n.fill),this.visual.redraw({stroke:i,fill:r})},refresh:function(){var e=this._c.shape.diagram.modelToView(this._c.position()),t=e.minus(this._c.shape.bounds("transformed").topLeft()),n=new G(e.x,e.y,0,0);n.inflate(this.options.width/2,this.options.height/2),this._visualBounds=n,this.visual.redraw({center:new Q(t.x,t.y)})},_hitTest:function(e){var t=this._c.shape.diagram.modelToView(e);return this._visualBounds.contains(t)}}),Z(W,{CompositeUnit:u,TransformUnit:m,PanUndoUnit:b,AddShapeUnit:_,AddConnectionUnit:v,DeleteShapeUnit:g,DeleteConnectionUnit:p,ConnectionEditAdorner:B,ConnectionTool:A,ConnectorVisual:O,UndoRedoService:x,ResizingAdorner:H,Selector:N,ToolService:I,ConnectorsAdorner:L,LayoutUndoUnit:d,ConnectionEditUnit:h,ToFrontUnit:y,ToBackUnit:k,ConnectionRouterBase:R,PolylineRouter:F,CascadingRouter:P,SelectionTool:D,ScrollerTool:S,PointerTool:T,ConnectionEditTool:E,RotateUnit:w})}(window.kendo.jQuery)}(),function(){!function(e){var t=window.kendo,n=t.dataviz.diagram,i=n.Graph,r=n.Node,o=n.Link,a=t.deepExtend,s=n.Size,l=n.Rect,c=n.Dictionary,d=n.Set,u=n.Graph,h=n.Utils,f=n.Point,p=1e-6,g=Math.PI/180,m=h.contains,v=e.grep,_=t.Class.extend({defaultOptions:{type:"Tree",subtype:"Down",roots:null,animate:!1,limitToView:!1,friction:.9,nodeDistance:50,iterations:300,horizontalSeparation:90,verticalSeparation:50,underneathVerticalTopOffset:15,underneathHorizontalOffset:15,underneathVerticalSeparation:15,grid:{width:1500,offsetX:50,offsetY:50,componentSpacingX:20,componentSpacingY:20},layerSeparation:50,layeredIterations:2,startRadialAngle:0,endRadialAngle:360,radialSeparation:150,radialFirstLevelSeparation:200,keepComponentsInOneRadialLayout:!1,ignoreContainers:!0,layoutContainerChildren:!1,ignoreInvisible:!0,animateTransitions:!1},init:function(){},gridLayoutComponents:function(e){var t,n,i,r,o,a,s,l,c,d,u,p,g,m,v;if(!e)throw"No components supplied.";for(h.forEach(e,function(e){e.calcBounds()}),e.sort(function(e,t){return t.bounds.width-e.bounds.width}),t=this.options.grid.width,n=this.options.grid.componentSpacingX,i=this.options.grid.componentSpacingY,r=0,o=this.options.grid.offsetX,a=this.options.grid.offsetY,s=o,l=a,d=[],u=[];e.length>0;){for(s>=t&&(s=o,l+=r+i,r=0),p=e.pop(),this.moveToOffset(p,new f(s,l)),c=0;p.nodes.length>c;c++)u.push(p.nodes[c]);for(c=0;p.links.length>c;c++)d.push(p.links[c]);g=p.bounds,m=g.height,(0>=m||isNaN(m))&&(m=0),v=g.width,(0>=v||isNaN(v))&&(v=0),m>=r&&(r=m),s+=v+n}return{nodes:u,links:d}},moveToOffset:function(e,t){var n,i,r,o,a,s,c,d,u=e.bounds,h=t.x-u.x,p=t.y-u.y;for(n=0;e.nodes.length>n;n++)r=e.nodes[n],o=r.bounds(),0===o.width&&0===o.height&&0===o.x&&0===o.y&&(o=new l(0,0,0,0)),o.x+=h,o.y+=p,r.bounds(o);for(n=0;e.links.length>n;n++)if(a=e.links[n],a.points){for(s=[],c=a.points,i=0;c.length>i;i++)d=c[i],d.x+=h,d.y+=p,s.push(d);a.points=s}return this.currentHorizontalOffset+=u.width+this.options.grid.offsetX,new f(h,p)},transferOptions:function(e){this.options=t.deepExtend({},this.defaultOptions),h.isUndefined(e)||(this.options=t.deepExtend(this.options,e||{}))}}),b=t.Class.extend({init:function(e){this.nodeMap=new c,this.shapeMap=new c,this.nodes=[],this.edges=[],this.edgeMap=new c,this.finalNodes=[],this.finalLinks=[],this.ignoredConnections=[],this.ignoredShapes=[],this.hyperMap=new c,this.hyperTree=new i,this.finalGraph=null,this.diagram=e},convert:function(e){if(h.isUndefined(this.diagram))throw"No diagram to convert.";return this.options=t.deepExtend({ignoreInvisible:!0,ignoreContainers:!0,layoutContainerChildren:!1},e||{}),this.clear(),this._renormalizeShapes(),this._renormalizeConnections(),this.finalNodes=new c(this.nodes),this.finalLinks=new c(this.edges),this.finalGraph=new i,this.finalNodes.forEach(function(e){this.finalGraph.addNode(e)},this),this.finalLinks.forEach(function(e){this.finalGraph.addExistingLink(e)},this),this.finalGraph},mapConnection:function(e){return this.edgeMap.first(function(t){return m(this.edgeMap.get(t),e)})},mapShape:function(e){var t,n,i,r=this.nodeMap.keys();for(t=0,n=r.length;n>t;t++)if(i=r[t],m(this.nodeMap.get(i),e))return i},getEdge:function(e,t){return h.first(e.links,function(n){return n.getComplement(e)===t})},clear:function(){this.finalGraph=null,this.hyperTree=!this.options.ignoreContainers&&this.options.layoutContainerChildren?new u:null,this.hyperMap=!this.options.ignoreContainers&&this.options.layoutContainerChildren?new c:null,this.nodeMap=new c,this.shapeMap=new c,this.nodes=[],this.edges=[],this.edgeMap=new c,this.ignoredConnections=[],this.ignoredShapes=[],this.finalNodes=[],this.finalLinks=[]},listToRoot:function(e){var t=[],n=e.container;if(!n)return t;for(t.push(n);n.parentContainer;)n=n.parentContainer,t.push(n);return t.reverse(),t},firstNonIgnorableContainer:function(e){return e.isContainer&&!this._isIgnorableItem(e)?e:e.parentContainer?this.firstNonIgnorableContainer(e.parentContainer):null},isContainerConnection:function(e,t){return e.isContainer&&this.isDescendantOf(e,t)?!0:t.isContainer&&this.isDescendantOf(t,e)},isDescendantOf:function(e,t){var n,i,r,o;if(!e.isContainer)throw"Expecting a container.";if(e===t)return!1;if(m(e.children,t))return!0;for(n=[],i=0,r=e.children.length;r>i;i++)o=e.children[i],o.isContainer&&this.isDescendantOf(o,t)&&n.push(o);return n.length>0},isIgnorableItem:function(e){return this.options.ignoreInvisible?e.isCollapsed&&this._isVisible(e)?!1:!e.isCollapsed&&this._isVisible(e)?!1:!0:e.isCollapsed&&!this._isTop(e)},isShapeMapped:function(e){return e.isCollapsed&&!this._isVisible(e)&&!this._isTop(e)},leastCommonAncestor:function(e,t){var n,i,r,o,a,s;if(!e)throw"Parameter should not be null.";if(!t)throw"Parameter should not be null.";if(!this.hyperTree)throw"No hypertree available.";if(n=this.listToRoot(e),i=this.listToRoot(t),r=null,h.isEmpty(n)||h.isEmpty(i))return this.hyperTree.root.data;for(o=n[0],a=i[0],s=0;o===a&&(r=n[s],s++,!(s>=n.length||s>=i.length));)o=n[s],a=i[s];return r?v(this.hyperTree.nodes,function(e){return e.data.container===r}):this.hyperTree.root.data},_isTop:function(e){return!e.parentContainer},_isVisible:function(e){return e.visible()?e.parentContainer?this._isVisible(e.parentContainer):e.visible():!1},_isCollapsed:function(e){return e.isContainer&&e.isCollapsed?!0:e.parentContainer&&this._isCollapsed(e.parentContainer)},_renormalizeShapes:function(){var e,t,n,i;if(!this.options.ignoreContainers)throw"Containers are not supported yet, but stay tuned.";for(e=0,t=this.diagram.shapes.length;t>e;e++)n=this.diagram.shapes[e],this.options.ignoreInvisible&&!this._isVisible(n)||n.isContainer?this.ignoredShapes.push(n):(i=new r(n.id,n),i.isVirtual=!1,this.nodeMap.add(i,[n]),this.nodes.push(i))},_renormalizeConnections:function(){var e,t,n,i,r,a,s,l;if(0!==this.diagram.connections.length)for(e=0,t=this.diagram.connections.length;t>e;e++)if(n=this.diagram.connections[e],this.isIgnorableItem(n))this.ignoredConnections.push(n);else if(i=n.sourceConnector?n.sourceConnector.shape:null,r=n.targetConnector?n.targetConnector.shape:null,i&&r)if(!m(this.ignoredShapes,i)||this.shapeMap.containsKey(i))if(!m(this.ignoredShapes,r)||this.shapeMap.containsKey(r))if(this.shapeMap.containsKey(i)&&(i=this.shapeMap[i]),this.shapeMap.containsKey(r)&&(r=this.shapeMap[r]),a=this.mapShape(i),s=this.mapShape(r),a===s||this.areConnectedAlready(a,s))this.ignoredConnections.push(n);else{if(null===a||null===s)throw"A shape was not mapped to a node.";if(!this.options.ignoreContainers)throw"Containers are not supported yet, but stay tuned.";a.isVirtual||s.isVirtual?this.ignoredConnections.push(n):(l=new o(a,s,n.id,n),this.edgeMap.add(l,[n]),this.edges.push(l))}else this.ignoredConnections.push(n);else this.ignoredConnections.push(n);else this.ignoredConnections.push(n)},areConnectedAlready:function(e,t){return h.any(this.edges,function(n){return n.source===e&&n.target===t||n.source===t&&n.target===e})}}),w=_.extend({init:function(e){var t=this;if(_.fn.init.call(t),h.isUndefined(e))throw"Diagram is not specified.";this.diagram=e},layout:function(e){var t,i,r,o,a,s;if(this.transferOptions(e),t=new b(this.diagram),i=t.convert(e),!i.isEmpty()&&(r=i.getConnectedComponents(),!h.isEmpty(r))){for(o=0;r.length>o;o++)a=r[o],this.layoutGraph(a,e);return s=this.gridLayoutComponents(r),new n.LayoutState(this.diagram,s)}},layoutGraph:function(e,t){var n,i,r;for(h.isDefined(t)&&this.transferOptions(t),this.graph=e,n=9*this.options.nodeDistance,this.temperature=n,i=this._expectedBounds(),this.width=i.width,this.height=i.height,r=0;this.options.iterations>r;r++)this.refineStage=r>=5*this.options.iterations/6,this.tick(),this.temperature=this.refineStage?n/30:n*(1-r/(2*this.options.iterations))},tick:function(){var e,t,n;for(e=0;this.graph.nodes.length>e;e++)this._repulsion(this.graph.nodes[e]);for(e=0;this.graph.links.length>e;e++)this._attraction(this.graph.links[e]);for(e=0;this.graph.nodes.length>e;e++){if(t=this.graph.nodes[e],n=Math.sqrt(t.dx*t.dx+t.dy*t.dy),0===n)return;t.x+=Math.min(n,this.temperature)*t.dx/n,t.y+=Math.min(n,this.temperature)*t.dy/n,this.options.limitToView&&(t.x=Math.min(this.width,Math.max(t.width/2,t.x)),t.y=Math.min(this.height,Math.max(t.height/2,t.y)))}},_shake:function(e){var t=Math.random()*this.options.nodeDistance/4,n=2*Math.random()*Math.PI;e.x+=t*Math.cos(n),e.y-=t*Math.sin(n)},_InverseSquareForce:function(e,t,n){var i,r,o,a,s,l,c;return this.refineStage?(r=t.x-n.x,o=t.y-n.y,a=t.width/2,s=t.height/2,l=n.width/2,c=n.height/2,i=Math.pow(r,2)/Math.pow(a+l+this.options.nodeDistance,2)+Math.pow(o,2)/Math.pow(s+c+this.options.nodeDistance,2)):i=Math.pow(e,2)/Math.pow(this.options.nodeDistance,2),4*i/3},_SquareForce:function(e,t,n){return 1/this._InverseSquareForce(e,t,n)},_repulsion:function(e){e.dx=0,e.dy=0,h.forEach(this.graph.nodes,function(t){var n,i,r,o;if(t!==e){for(;e.x===t.x&&e.y===t.y;)this._shake(t);n=e.x-t.x,i=e.y-t.y,r=Math.sqrt(n*n+i*i),o=2*this._SquareForce(r,e,t),e.dx+=n/r*o,e.dy+=i/r*o}},this)},_attraction:function(e){var t,n,i,r,o,a,s=e.target,l=e.source;if(l!==s){for(;l.x===s.x&&l.y===s.y;)this._shake(s);t=l.x-s.x,n=l.y-s.y,i=Math.sqrt(t*t+n*n),r=5*this._InverseSquareForce(i,l,s),o=t/i*r,a=n/i*r,s.dx+=o,s.dy+=a,l.dx-=o,l.dy-=a}},_expectedBounds:function(){var e,t,n,i,r,o=this.graph.nodes.length,a=1.5,s=4;return 0===o?e:(e=h.fold(this.graph.nodes,function(e,t){var n=t.width*t.height;return n>0?e+=Math.sqrt(n):0},0,this),t=e/o,
n=t*Math.ceil(Math.sqrt(o)),i=n*Math.sqrt(a),r=n/Math.sqrt(a),{width:i*s,height:r*s})}}),y=t.Class.extend({init:function(e){this.center=null,this.options=e},layout:function(e,t){if(this.graph=e,this.graph.nodes&&0!==this.graph.nodes.length){if(!m(this.graph.nodes,t))throw"The given root is not in the graph.";this.center=t,this.graph.cacheRelationships(),this.layoutSwitch()}},layoutLeft:function(e){var t,n,i,r,o,a,l,c;for(this.setChildrenDirection(this.center,"Left",!1),this.setChildrenLayout(this.center,"Default",!1),t=0,n=0,r=0;e.length>r;r++)o=e[r],o.TreeDirection="Left",a=this.measure(o,s.Empty),n=Math.max(n,a.Width),t+=a.height+this.options.verticalSeparation;for(t-=this.options.verticalSeparation,l=this.center.x-this.options.horizontalSeparation,i=this.center.y+(this.center.height-t)/2,r=0;e.length>r;r++)o=e[r],c=new f(l-o.Size.width,i),this.arrange(o,c),i+=o.Size.height+this.options.verticalSeparation},layoutRight:function(e){var t,n,i,r,o,a,l,c;for(this.setChildrenDirection(this.center,"Right",!1),this.setChildrenLayout(this.center,"Default",!1),t=0,n=0,r=0;e.length>r;r++)o=e[r],o.TreeDirection="Right",a=this.measure(o,s.Empty),n=Math.max(n,a.Width),t+=a.height+this.options.verticalSeparation;for(t-=this.options.verticalSeparation,l=this.center.x+this.options.horizontalSeparation+this.center.width,i=this.center.y+(this.center.height-t)/2,r=0;e.length>r;r++)o=e[r],c=new f(l,i),this.arrange(o,c),i+=o.Size.height+this.options.verticalSeparation},layoutUp:function(e){var t,n,i,r,o,a,l;for(this.setChildrenDirection(this.center,"Up",!1),this.setChildrenLayout(this.center,"Default",!1),t=0,r=0;e.length>r;r++)i=e[r],i.TreeDirection="Up",o=this.measure(i,s.Empty),t+=o.width+this.options.horizontalSeparation;for(t-=this.options.horizontalSeparation,a=this.center.x+this.center.width/2-t/2,r=0;e.length>r;r++)i=e[r],n=this.center.y-this.options.verticalSeparation-i.Size.height,l=new f(a,n),this.arrange(i,l),a+=i.Size.width+this.options.horizontalSeparation},layoutDown:function(e){var t,n,i,r,o,a,l;for(this.setChildrenDirection(this.center,"Down",!1),this.setChildrenLayout(this.center,"Default",!1),i=0,n=0;e.length>n;n++)t=e[n],t.treeDirection="Down",o=this.measure(t,s.Empty),i+=o.width+this.options.horizontalSeparation;for(i-=this.options.horizontalSeparation,a=this.center.x+this.center.width/2-i/2,r=this.center.y+this.options.verticalSeparation+this.center.height,n=0;e.length>n;n++)t=e[n],l=new f(a,r),this.arrange(t,l),a+=t.Size.width+this.options.horizontalSeparation},layoutRadialTree:function(){var e,t;if(this.setChildrenDirection(this.center,"Radial",!1),this.setChildrenLayout(this.center,"Default",!1),this.previousRoot=null,e=this.options.startRadialAngle*g,t=this.options.endRadialAngle*g,e>=t)throw"Final angle should not be less than the start angle.";this.maxDepth=0,this.origin=new f(this.center.x,this.center.y),this.calculateAngularWidth(this.center,0),this.maxDepth>0&&this.radialLayout(this.center,this.options.radialFirstLevelSeparation,e,t),this.center.Angle=t-e},tipOverTree:function(e,t){var n,i,r,o,a,l,c;for(h.isUndefined(t)&&(t=0),this.setChildrenDirection(this.center,"Down",!1),this.setChildrenLayout(this.center,"Default",!1),this.setChildrenLayout(this.center,"Underneath",!1,t),n=0,o=0;e.length>o;o++)r=e[o],r.TreeDirection="Down",a=this.measure(r,s.Empty),n+=a.width+this.options.horizontalSeparation;for(n-=this.options.horizontalSeparation,n-=e[e.length-1].width,n+=e[e.length-1].associatedShape.bounds().width,l=this.center.x+this.center.width/2-n/2,i=this.center.y+this.options.verticalSeparation+this.center.height,o=0;e.length>o;o++)r=e[o],c=new f(l,i),this.arrange(r,c),l+=r.Size.width+this.options.horizontalSeparation},calculateAngularWidth:function(e,t){var n,i,r,o,a,s,l;if(t>this.maxDepth&&(this.maxDepth=t),n=0,i=1e3,r=1e3,o=0===t?0:Math.sqrt(i*i+r*r)/t,e.children.length>0){for(a=0,s=e.children.length;s>a;a++)l=e.children[a],n+=this.calculateAngularWidth(l,t+1);n=Math.max(o,n)}else n=o;return e.sectorAngle=n,n},sortChildren:function(e){var t,n,i,r,o,a,s,l,c,d,u,p=0;if(e.parents.length>1)throw"Node is not part of a tree.";if(n=e.parents[0],n&&(i=new f(n.x,n.y),r=new f(e.x,e.y),p=this.normalizeAngle(Math.atan2(i.y-r.y,i.x-r.x))),o=e.children.length,0===o)return null;for(a=[],s=[],t=0;o>t;++t)l=e.children[t],c=new f(l.x,l.y),s[t]=t,a[t]=this.normalizeAngle(-p+Math.atan2(c.y-c.y,c.x-c.x));for(h.bisort(a,s),d=[],u=e.children,t=0;o>t;++t)d.push(u[s[t]]);return d},normalizeAngle:function(e){for(;e>2*Math.PI;)e-=2*Math.PI;for(;0>e;)e+=2*Math.PI;return e},radialLayout:function(e,t,n,i){var r,o,a,s,l,c=i-n,d=c/2,u=e.sectorAngle,h=0,f=this.sortChildren(e);for(r=0,o=f.length;o>r;r++)a=f[r],s=a,l=s.sectorAngle/u,a.children.length>0&&this.radialLayout(a,t+this.options.radialSeparation,n+h*c,n+(h+l)*c),this.setPolarLocation(a,t,n+h*c+l*d),s.angle=l*c,h+=l},setPolarLocation:function(e,t,n){e.x=this.origin.x+t*Math.cos(n),e.y=this.origin.y+t*Math.sin(n),e.BoundingRectangle=new l(e.x,e.y,e.width,e.height)},setChildrenDirection:function(e,t,n){var i=e.treeDirection;this.graph.depthFirstTraversal(e,function(e){e.treeDirection=t}),n||(e.treeDirection=i)},setChildrenLayout:function(e,t,n,i){h.isUndefined(i)&&(i=0);var r=e.childrenLayout;i>0?(this.graph.assignLevels(e),this.graph.depthFirstTraversal(e,function(e){e.level>=i+1&&(e.childrenLayout=t)})):(this.graph.depthFirstTraversal(e,function(e){e.childrenLayout=t}),n||(e.childrenLayout=r))},measure:function(e,t){var n,i,r,o,a,l,c,d=0,u=0,f=new s(0,0);if(!e)throw"";if(i=e.associatedShape.bounds(),r=i.width,o=i.height,1!==e.parents.length)throw"Node not in a spanning tree.";if(a=e.parents[0],"Undefined"===e.treeDirection&&(e.treeDirection=a.treeDirection),h.isEmpty(e.children))f=new s(Math.abs(r)l;l++)c=e.children[l],n=this.measure(c,t),d=Math.max(d,n.width+this.options.underneathHorizontalOffset),u+=n.height+this.options.underneathVerticalSeparation;u-=this.options.underneathVerticalSeparation;break;case"Default":for(d=r,u=0,l=0;e.children.length>l;l++)c=e.children[l],n=this.measure(c,t),d=Math.max(d,r+this.options.horizontalSeparation+n.width),u+=n.height+this.options.verticalSeparation;u-=this.options.verticalSeparation;break;default:throw"Unhandled TreeDirection in the Right layout measuring."}break;case"Up":case"Down":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(d=r,u=o+this.options.underneathVerticalTopOffset,l=0;e.children.length>l;l++)c=e.children[l],n=this.measure(c,t),d=Math.max(d,n.width+this.options.underneathHorizontalOffset),u+=n.height+this.options.underneathVerticalSeparation;u-=this.options.underneathVerticalSeparation;break;case"Default":for(d=0,u=0,l=0;e.children.length>l;l++)c=e.children[l],n=this.measure(c,t),d+=n.width+this.options.horizontalSeparation,u=Math.max(u,n.height+this.options.verticalSeparation+o);d-=this.options.horizontalSeparation;break;default:throw"Unhandled TreeDirection in the Down layout measuring."}break;default:throw"Unhandled TreeDirection in the layout measuring."}f=new s(d,u)}return e.SectorAngle=Math.sqrt(d*d/4+u*u/4),e.Size=f,f},arrange:function(e,t){var n,i,r,o,a,s,c,d,u=e.associatedShape.bounds(),g=u.width,m=u.height;if(h.isEmpty(e.children))e.x=t.x,e.y=t.y,e.BoundingRectangle=new l(t.x,t.y,g,m);else switch(e.treeDirection){case"Left":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(d=t,e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),c=t.y+m+this.options.underneathVerticalTopOffset,n=0;o.children.length>n;n++)o=o.children[n],s=d.x-o.associatedShape.width-this.options.underneathHorizontalOffset,i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.underneathVerticalSeparation;break;case"Default":for(d=new f(t.x+e.Size.width-g,t.y+(e.Size.height-m)/2),e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=d.x-this.options.horizontalSeparation,c=t.y,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s-o.Size.width,c),this.arrange(o,i),c+=o.Size.height+this.options.verticalSeparation;break;default:throw"Unsupported TreeDirection"}break;case"Right":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(d=t,e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=t.x+g+this.options.underneathHorizontalOffset,c=t.y+m+this.options.underneathVerticalTopOffset,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.underneathVerticalSeparation;break;case"Default":for(d=new f(t.x,t.y+(e.Size.height-m)/2),e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=t.x+g+this.options.horizontalSeparation,c=t.y,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.verticalSeparation;break;default:throw"Unsupported TreeDirection"}break;case"Up":if(d=new f(t.x+(e.Size.width-g)/2,t.y+e.Size.height-m),e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),Math.abs(d.x-t.x)
n;n++)r=e.children[n],a+=r.Size.width+this.options.horizontalSeparation;a-=this.options.horizontalSeparation,s=t.x+(g-a)/2}else s=t.x;for(n=0;e.children.length>n;n++)o=e.children[n],c=d.y-this.options.verticalSeparation-o.Size.height,i=new f(s,c),this.arrange(o,i),s+=o.Size.width+this.options.horizontalSeparation;break;case"Down":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(d=t,e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=t.x+this.options.underneathHorizontalOffset,c=t.y+m+this.options.underneathVerticalTopOffset,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.underneathVerticalSeparation;break;case"Default":if(d=new f(t.x+(e.Size.width-g)/2,t.y),e.x=d.x,e.y=d.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),Math.abs(d.x-t.x)
n;n++)r=e.children[n],a+=r.Size.width+this.options.horizontalSeparation;a-=this.options.horizontalSeparation,s=t.x+(g-a)/2}else s=t.x;for(n=0;e.children.length>n;n++)o=e.children[n],c=d.y+this.options.verticalSeparation+m,i=new f(s,c),this.arrange(o,i),s+=o.Size.width+this.options.horizontalSeparation;break;default:throw"Unsupported TreeDirection"}break;case"None":break;default:throw"Unsupported TreeDirection"}},layoutSwitch:function(){var e,t,n,i,r,o;if(this.center&&!h.isEmpty(this.center.children))switch(e=this.options.subtype,h.isUndefined(e)&&(e="Down"),o=this.center.children,e.toLowerCase()){case"radial":case"radialtree":this.layoutRadialTree();break;case"mindmaphorizontal":case"mindmap":t=this.center.children,1===this.center.children.length?this.layoutRight(t):(r=o.length/2,n=v(this.center.children,function(e){return h.indexOf(o,e)=r}),this.layoutLeft(n),this.layoutRight(i));break;case"mindmapvertical":t=this.center.children,1===this.center.children.length?this.layoutDown(t):(r=o.length/2,n=v(this.center.children,function(e){return h.indexOf(o,e)=r}),this.layoutUp(n),this.layoutDown(i));break;case"right":this.layoutRight(this.center.children);break;case"left":this.layoutLeft(this.center.children);break;case"up":case"bottom":this.layoutUp(this.center.children);break;case"down":case"top":this.layoutDown(this.center.children);break;case"tipover":case"tipovertree":if(0>this.options.tipOverTreeStartLevel)throw"The tip-over level should be a positive integer.";this.tipOverTree(this.center.children,this.options.tipOverTreeStartLevel);break;case"undefined":case"none":}}}),k=_.extend({init:function(e){var t=this;if(_.fn.init.call(t),h.isUndefined(e))throw"No diagram specified.";this.diagram=e},layout:function(e){var t,i;return this.transferOptions(e),t=new b(this.diagram),this.graph=t.convert(),i=this.layoutComponents(),new n.LayoutState(this.diagram,i)},layoutComponents:function(){var e,t,n,i,r,o,a,s;if(!this.graph.isEmpty()&&(e=this.graph.getConnectedComponents(),!h.isEmpty(e))){for(t=new y(this.options),n=[],i=0;e.length>i;i++){if(r=e[i],o=this.getTree(r),!o)throw"Failed to find a spanning tree for the component.";a=o.root,s=o.tree,t.layout(s,a),n.push(s)}return this.gridLayoutComponents(n)}},getTree:function(e){var t,n,i,r,o,a=null;if(this.options.roots&&this.options.roots.length>0)for(t=0,n=e.nodes.length;n>t;t++)for(i=e.nodes[t],r=0;this.options.roots.length>r;r++)if(o=this.options.roots[r],o===i.associatedShape){a=i;break}if(!a&&(a=e.root(),!a))throw"Unable to find a root for the tree.";return this.getTreeForRoot(e,a)},getTreeForRoot:function(e,t){var n=e.getSpanningTree(t);return h.isUndefined(n)||n.isEmpty()?null:{tree:n,root:n.root}}}),x=_.extend({init:function(e){var t=this;if(_.fn.init.call(t),h.isUndefined(e))throw"Diagram is not specified.";this.diagram=e},layout:function(e){var t,i,r,o,a,s;if(this.transferOptions(e),t=new b(this.diagram),i=t.convert(e),!i.isEmpty()&&(r=i.getConnectedComponents(),!h.isEmpty(r))){for(o=0;r.length>o;o++)a=r[o],this.layoutGraph(a,e);return s=this.gridLayoutComponents(r),new n.LayoutState(this.diagram,s)}},_initRuntimeProperties:function(){var e,t;for(e=0;this.graph.nodes.length>e;e++)t=this.graph.nodes[e],t.layer=-1,t.downstreamLinkCount=0,t.upstreamLinkCount=0,t.isVirtual=!1,t.uBaryCenter=0,t.dBaryCenter=0,t.upstreamPriority=0,t.downstreamPriority=0,t.gridPosition=0},_prepare:function(e){var t,n,i,r,o,a,s,l,d,u,f,p,g=[];for(n=0;e.links.length>n;n++)e.links[n].depthOfDumminess=0;for(r=new c,h.forEach(e.nodes,function(e){0===e.incoming.length&&(r.set(e,0),g.push(e))});g.length>0;)for(o=g.shift(),t=0;o.outgoing.length>t;t++)i=o.outgoing[t],a=i.target,r.containsKey(a)?r.set(a,Math.max(r.get(o)+1,r.get(a))):r.set(a,r.get(o)+1),m(g,a)||g.push(a);for(s=0,r.forEachValue(function(e){s=Math.max(s,e)}),l=[],h.addRange(l,r.keys()),l.sort(function(e,t){var n=r.get(e),i=r.get(t);return h.sign(i-n)}),d=0;l.length>d;++d)if(u=l[d],f=Number.MAX_VALUE,0!==u.outgoing.length){for(n=0;u.outgoing.length>n;++n)i=u.outgoing[n],f=Math.min(f,r.get(i.target));f>1&&r.set(u,f-1)}for(this.layers=[],t=0;s+1>t;t++)this.layers.push([]);for(r.forEach(function(e,t){e.layer=t,this.layers[t].push(e)},this),n=0;this.layers.length>n;n++)for(p=this.layers[n],t=0;p.length>t;t++)p[t].gridPosition=t},layoutGraph:function(e,t){if(h.isUndefined(e))throw"No graph given or graph analysis of the diagram failed.";h.isDefined(t)&&this.transferOptions(t),this.graph=e,e.setItemIndices();var n=e.makeAcyclic();this._initRuntimeProperties(),this._prepare(e,t),this._dummify(),this._optimizeCrossings(),this._swapPairs(),this.arrangeNodes(),this._moveThingsAround(),this._dedummify(),h.forEach(n,function(e){e.points&&e.points.reverse()})},setMinDist:function(e,t,n){var i=e.layer,r=e.layerIndex;this.minDistances[i][r]=n},getMinDist:function(e,t){var n,i=0,r=e.layerIndex,o=t.layerIndex,a=e.layer,s=Math.min(r,o),l=Math.max(r,o);for(n=s;l>n;++n)i+=this.minDistances[a][n];return i},placeLeftToRight:function(e){var t,n,i,r,o,a,s,l,d,u,f=new c;for(i=0;this.layers.length>i;++i)if(r=e[i]){for(t=0;r.length>t;t++)n=r[t],f.containsKey(n)||this.placeLeft(n,f,i);for(o=Number.POSITIVE_INFINITY,t=0;r.length>t;t++)n=r[t],a=this.rightSibling(n),a&&this.nodeLeftClass.get(a)!==i&&(o=Math.min(o,f.get(a)-f.get(n)-this.getMinDist(n,a)));if(o===Number.POSITIVE_INFINITY){for(s=[],t=0;r.length>t;t++)for(n=r[t],l=[],h.addRange(l,this.upNodes.get(n)),h.addRange(l,this.downNodes.get(n)),d=0;l.length>d;d++)u=l[d],this.nodeLeftClass.get(u)t;t++)n=r[t],f.set(n,f.get(n)+o)}return f},placeRightToLeft:function(e){var t,n,i,r,o,a,s,l,d,u,f=new c;for(i=0;this.layers.length>i;++i)if(r=e[i]){for(t=0;r.length>t;t++)n=r[t],f.containsKey(n)||this.placeRight(n,f,i);for(o=Number.NEGATIVE_INFINITY,t=0;r.length>t;t++)n=r[t],a=this.leftSibling(n),a&&this.nodeRightClass.get(a)!==i&&(o=Math.max(o,f.get(a)-f.get(n)+this.getMinDist(a,n)));if(o===Number.NEGATIVE_INFINITY){for(s=[],t=0;r.length>t;t++)for(n=r[t],l=[],h.addRange(l,this.upNodes.get(n)),h.addRange(l,this.downNodes.get(n)),d=0;l.length>d;d++)u=l[d],this.nodeRightClass.get(u)t;t++)n=r[t],f.set(n,f.get(n)+o)}return f},_getLeftWing:function(){var e={value:null},t=this.computeClasses(e,1);return this.nodeLeftClass=e.value,t},_getRightWing:function(){var e={value:null},t=this.computeClasses(e,-1);return this.nodeRightClass=e.value,t},computeClasses:function(e,t){var n,i,r,o,a,s,l,d,u,h=0,f=e.value=new c;for(n=0;this.layers.length>n;++n)for(h=n,i=this.layers[n],r=1===t?0:i.length-1;r>=0&&i.length>r;r+=t)if(o=i[r],f.containsKey(o))h=f.get(o);else if(f.set(o,h),o.isVirtual)for(a=this._nodesInLink(o),s=0;a.length>s;s++)l=a[s],f.set(l,h);for(d=[],u=0;this.layers.length>u;u++)d.push(null);return f.forEach(function(e,t){null===d[t]&&(d[t]=[]),d[t].push(e)}),d},_isVerticalLayout:function(){return"up"===this.options.subtype.toLowerCase()||"down"===this.options.subtype.toLowerCase()||"vertical"===this.options.subtype.toLowerCase()},_isHorizontalLayout:function(){return"right"===this.options.subtype.toLowerCase()||"left"===this.options.subtype.toLowerCase()||"horizontal"===this.options.subtype.toLowerCase()},_isIncreasingLayout:function(){return"right"===this.options.subtype.toLowerCase()||"down"===this.options.subtype.toLowerCase()},_moveThingsAround:function(){function e(e,t){var n,i,r=Number.MIN_VALUE;for(n=0;e.length>n;++n)i=e[n],r=t._isVerticalLayout()?Math.max(r,i.height):Math.max(r,i.width);return r}var t,n,i,r,o,a,s,l,d,u,f,p,g,m,v,_,b,w,y,k,x,C,S,T,D,A,E;for(n=0;this.layers.length>n;++n)r=this.layers[n],r.sort(this._gridPositionComparer);for(this.minDistances=[],n=0;this.layers.length>n;++n)for(r=this.layers[n],this.minDistances[n]=[],o=0;r.length>o;++o)i=r[o],i.layerIndex=o,this.minDistances[n][o]=this.options.nodeDistance,r.length-1>o&&(this.minDistances[n][o]+=this._isVerticalLayout()?(i.width+r[o+1].width)/2:(i.height+r[o+1].height)/2);for(this.downNodes=new c,this.upNodes=new c,h.forEach(this.graph.nodes,function(e){this.downNodes.set(e,[]),this.upNodes.set(e,[])},this),h.forEach(this.graph.links,function(e){var t=e.source,n=e.target,i=null,r=null;t.layer>n.layer?(i=e.source,r=e.target):(r=e.source,i=e.target),this.downNodes.get(r).push(i),this.upNodes.get(i).push(r)},this),this.downNodes.forEachValue(function(e){e.sort(this._gridPositionComparer)},this),this.upNodes.forEachValue(function(e){e.sort(this._gridPositionComparer)},this),n=0;this.layers.length-1>n;++n)for(r=this.layers[n],a=0;r.length-1>a;a++)if(s=r[a],s.isVirtual&&(l=this.downNodes.get(s)[0],l.isVirtual))for(o=a+1;r.length>o;++o)i=r[o],i.isVirtual&&(d=this.downNodes.get(i)[0],d.isVirtual&&l.gridPosition>d.gridPosition&&(u=l.gridPosition,l.gridPosition=d.gridPosition,d.gridPosition=u,f=l.layerIndex,p=d.layerIndex,this.layers[n+1][f]=d,this.layers[n+1][p]=l,l.layerIndex=p,d.layerIndex=f));for(g=this._getLeftWing(),m=this._getRightWing(),v=this.placeLeftToRight(g),_=this.placeRightToLeft(m),b=new c,h.forEach(this.graph.nodes,function(e){b.set(e,(v.get(e)+_.get(e))/2)}),w=new c,y=new c,n=0;this.layers.length>n;++n)for(r=this.layers[n],k=-1,x=-1,o=0;r.length>o;++o)i=r[o],w.set(i,0),y.set(i,!1),i.isVirtual&&(-1===k?k=o:k===o-1?k=o:(x=o,w.set(r[k],0),b.get(i)-b.get(r[k])===this.getMinDist(r[k],i)?y.set(r[k],!0):y.set(r[k],!1),k=o));for(C=[1,-1],h.forEach(C,function(e){var n,i,r,o,a,s,l,c=1===e?0:this.layers.length-1;for(n=c;n>=0&&this.layers.length>n;n+=e){if(i=this.layers[n],r=this._firstVirtualNode(i),o=null,a=null,-1!==r)for(o=i[r],a=[],t=0;r>t;t++)a.push(i[t]);else o=null,a=i;if(a.length>0){for(this._sequencer(b,null,o,e,a),t=0;a.length-1>t;++t)this.setMinDist(a[t],a[t+1],b.get(a[t+1])-b.get(a[t]));o&&this.setMinDist(a[a.length-1],o,b.get(o)-b.get(a[a.length-1]))}for(;o;){if(s=this.nextVirtualNode(i,o)){if(w.get(o)===e){for(r=o.layerIndex,l=s.layerIndex,a=[],t=r+1;l>t;t++)a.push(i[t]);a.length>0&&this._sequencer(b,o,s,e,a),y.set(o,!0)}}else{for(r=o.layerIndex,a=[],t=r+1;i.length>t;t++)a.push(i[t]);if(a.length>0){for(this._sequencer(b,o,null,e,a),t=0;a.length-1>t;++t)this.setMinDist(a[t],a[t+1],b.get(a[t+1])-b.get(a[t]));this.setMinDist(o,a[0],b.get(a[0])-b.get(o))}}o=s}this.adjustDirections(n,e,w,y)}},this),S=this._isIncreasingLayout()?0:this.layers.length-1,T=function(e,t){return t._isIncreasingLayout()?t.layers.length>e:e>=0},D=this._isIncreasingLayout()?1:-1,A=0,t=S;T(t,this);t+=D){for(r=this.layers[t],E=e(r,this),o=0;r.length>o;++o)i=r[o],this._isVerticalLayout()?(i.x=b.get(i),i.y=A+E/2):(i.x=A+E/2,i.y=b.get(i));A+=this.options.layerSeparation+E}},adjustDirections:function(e,t,n,i){var r,o,a,s,l,c,d,u,h,f,p,g,m,v;if(!(0>e+t||e+t>=this.layers.length))for(r=null,o=null,a=this.layers[e+t],s=0;a.length>s;++s)if(l=a[s],l.isVirtual&&(c=this.getNeighborOnLayer(l,e),c.isVirtual)){if(r){for(d=i.get(o),u=this.layers[e],h=o.layerIndex,f=c.layerIndex,p=h+1;f>p;++p)u[p].isVirtual&&(d=d&&i.get(u[p]));if(d)for(n.set(r,t),g=r.layerIndex,m=l.layerIndex,v=g+1;m>v;++v)a[v].isVirtual&&n.set(a[v],t)}r=l,o=c}},getNeighborOnLayer:function(e,t){var n=this.upNodes.get(e)[0];return n.layer===t?n:(n=this.downNodes.get(e)[0],n.layer===t?n:null)},_sequencer:function(e,t,n,i,r){if(1===r.length&&this._sequenceSingle(e,t,n,i,r[0]),r.length>1){var o=r.length,a=this.intDiv(o,2);this._sequencer(e,t,n,i,r.slice(0,a)),this._sequencer(e,t,n,i,r.slice(a)),this.combineSequences(e,t,n,i,r)}},_sequenceSingle:function(e,t,n,i,r){var o=-1===i?this.downNodes.get(r):this.upNodes.get(r),a=o.length;0!==a&&(a%2===1?e.set(r,e.get(o[this.intDiv(a,2)])):e.set(r,(e.get(o[this.intDiv(a,2)-1])+e.get(o[this.intDiv(a,2)]))/2),t&&e.set(r,Math.max(e.get(r),e.get(t)+this.getMinDist(t,r))),n&&e.set(r,Math.min(e.get(r),e.get(n)-this.getMinDist(r,n))))},combineSequences:function(e,t,n,i,r){var o,a,s,l,c,d,u,h,f,p,g=r.length,m=this.intDiv(g,2),v=[];for(o=0;m>o;++o){for(a=0,l=-1===i?this.downNodes.get(r[o]):this.upNodes.get(r[o]),s=0;l.length>s;++s)c=l[s],e.get(c)>=e.get(r[o])?a++:(a--,v.push({k:e.get(c)+this.getMinDist(r[o],r[m-1]),v:2}));v.push({k:e.get(r[o])+this.getMinDist(r[o],r[m-1]),v:a})}for(t&&v.push({k:e.get(t)+this.getMinDist(t,r[m-1]),v:Number.MAX_VALUE}),v.sort(this._positionDescendingComparer),u=[],o=m;g>o;++o){for(a=0,l=-1===i?this.downNodes.get(r[o]):this.upNodes.get(r[o]),s=0;l.length>s;++s)c=l[s],e.get(c)<=e.get(r[o])?a++:(a--,u.push({k:e.get(c)-this.getMinDist(r[o],r[m]),v:2}));u.push({k:e.get(r[o])-this.getMinDist(r[o],r[m]),v:a})}for(n&&u.push({k:e.get(n)-this.getMinDist(n,r[m]),v:Number.MAX_VALUE}),u.sort(this._positionAscendingComparer),h=0,f=0,p=this.getMinDist(r[m-1],r[m]);e.get(r[m])-e.get(r[m-1]) h){if(0===v.length){e.set(r[m-1],e.get(r[m])-p);break}d=v.shift(),h+=d.v,e.set(r[m-1],d.k),e.set(r[m-1],Math.max(e.get(r[m-1]),e.get(r[m])-p))}else{if(0===u.length){e.set(r[m],e.get(r[m-1])+p);break}d=u.shift(),f+=d.v,e.set(r[m],d.k),e.set(r[m],Math.min(e.get(r[m]),e.get(r[m-1])+p))}for(o=m-2;o>=0;o--)e.set(r[o],Math.min(e.get(r[o]),e.get(r[m-1])-this.getMinDist(r[o],r[m-1])));for(o=m+1;g>o;o++)e.set(r[o],Math.max(e.get(r[o]),e.get(r[m])+this.getMinDist(r[o],r[m])))},placeLeft:function(e,t,n){var i=Number.NEGATIVE_INFINITY;h.forEach(this._getComposite(e),function(e){var r=this.leftSibling(e);r&&this.nodeLeftClass.get(r)===this.nodeLeftClass.get(e)&&(t.containsKey(r)||this.placeLeft(r,t,n),i=Math.max(i,t.get(r)+this.getMinDist(r,e)))},this),i===Number.NEGATIVE_INFINITY&&(i=0),h.forEach(this._getComposite(e),function(e){t.set(e,i)})},placeRight:function(e,t,n){var i=Number.POSITIVE_INFINITY;h.forEach(this._getComposite(e),function(e){var r=this.rightSibling(e);r&&this.nodeRightClass.get(r)===this.nodeRightClass.get(e)&&(t.containsKey(r)||this.placeRight(r,t,n),i=Math.min(i,t.get(r)-this.getMinDist(e,r)))},this),i===Number.POSITIVE_INFINITY&&(i=0),h.forEach(this._getComposite(e),function(e){t.set(e,i)})},leftSibling:function(e){var t=this.layers[e.layer],n=e.layerIndex;return 0===n?null:t[n-1]},rightSibling:function(e){var t=this.layers[e.layer],n=e.layerIndex;return n===t.length-1?null:t[n+1]},_getComposite:function(e){return e.isVirtual?this._nodesInLink(e):[e]},arrangeNodes:function(){var e,t,n,i,r,o,a,s;for(t=0;this.layers.length>t;t++)for(i=this.layers[t],n=0;i.length>n;n++)r=i[n],r.upstreamPriority=r.upstreamLinkCount,r.downstreamPriority=r.downstreamLinkCount;for(o=2,a=0;o>a;a++){for(e=this.layers.length-1;e>=1;e--)this.layoutLayer(!1,e);for(e=0;this.layers.length-1>e;e++)this.layoutLayer(!0,e)}for(s=Number.MAX_VALUE,t=0;this.layers.length>t;t++)for(i=this.layers[t],n=0;i.length>n;n++)r=i[n],s=Math.min(s,r.gridPosition);if(0>s)for(t=0;this.layers.length>t;t++)for(i=this.layers[t],n=0;i.length>n;n++)r=i[n],r.gridPosition=r.gridPosition-s},layoutLayer:function(e,t){var n,i,r,o;for(i=e?this.layers[n=t+1]:this.layers[n=t-1],r=[],o=0;i.length>o;o++)r.push(i[o]);r.sort(function(e,t){var n=(e.upstreamPriority+e.downstreamPriority)/2,i=(t.upstreamPriority+t.downstreamPriority)/2;return Math.abs(n-i)<1e-4?0:i>n?1:-1}),h.forEach(r,function(e){var t=e.gridPosition,n=this.calcBaryCenter(e),r=(e.upstreamPriority+e.downstreamPriority)/2;if(!(Math.abs(t-n)<1e-4||Math.abs(t-n)<.2501))if(n>t)for(;n>t&&this.moveRight(e,i,r);)t=e.gridPosition;else for(;t>n&&this.moveLeft(e,i,r);)t=e.gridPosition},this),n>0&&this.calcDownData(n-1),this.layers.length-1>n&&this.calcUpData(n+1)},moveRight:function(e,t,n){var i,r,o=h.indexOf(t,e);return o===t.length-1?(e.gridPosition=e.gridPosition+.5,!0):(i=t[o+1],r=(i.upstreamPriority+i.downstreamPriority)/2,i.gridPosition>e.gridPosition+1?(e.gridPosition=e.gridPosition+.5,!0):r>n||Math.abs(r-n)<1e-4?!1:this.moveRight(i,t,n)?(e.gridPosition=e.gridPosition+.5,!0):!1)},moveLeft:function(e,t,n){var i,r,o=h.indexOf(t,e);return 0===o?(e.gridPosition=e.gridPosition-.5,!0):(i=t[o-1],r=(i.upstreamPriority+i.downstreamPriority)/2,e.gridPosition-1>i.gridPosition?(e.gridPosition=e.gridPosition-.5,!0):r>n||Math.abs(r-n)<1e-4?!1:this.moveLeft(i,t,n)?(e.gridPosition=e.gridPosition-.5,!0):!1)},mapVirtualNode:function(e,t){this.nodeToLinkMap.set(e,t),this.linkToNodeMap.containsKey(t)||this.linkToNodeMap.set(t,[]),this.linkToNodeMap.get(t).push(e)},_nodesInLink:function(e){return this.linkToNodeMap.get(this.nodeToLinkMap.get(e))},_dummify:function(){var e,t,n,i,a,s,l,d,u,f,p,g,m,v,_,b,w,y;for(this.linkToNodeMap=new c,this.nodeToLinkMap=new c,u=this.graph.links.slice(0),d=0;u.length>d;d++){if(f=u[d],p=f.source,g=f.target,m=p.layer,v=g.layer,_=p.gridPosition,b=g.gridPosition,w=(b-_)/Math.abs(v-m),y=p,m-v>1){for(l=m-1;l>v;l--){for(n=new r,n.x=p.x,n.y=p.y,n.width=p.width/100,n.height=p.height/100,e=this.layers[l],t=(l-v)*w+_,t>e.length&&(t=e.length),_>=this.layers[m].length-1&&b>=this.layers[v].length-1?t=e.length:0===_&&0===b&&(t=0),n.layer=l,n.uBaryCenter=0,n.dBaryCenter=0,n.upstreamLinkCount=0,n.downstreamLinkCount=0,n.gridPosition=t,n.isVirtual=!0,h.insert(e,n,t),a=t+1;e.length>a;a++)i=e[a],i.gridPosition=i.gridPosition+1;s=new o(y,n),s.depthOfDumminess=0,y=n,this.graph.nodes.push(n),this.graph.addLink(s),n.index=this.graph.nodes.length-1,this.mapVirtualNode(n,f)}f.changeSource(y),f.depthOfDumminess=m-v-1}if(-1>m-v){for(l=m+1;v>l;l++){for(n=new r,n.x=p.x,n.y=p.y,n.width=p.width/100,n.height=p.height/100,e=this.layers[l],t=(l-m)*w+_,t>e.length&&(t=e.length),_>=this.layers[m].length-1&&b>=this.layers[v].length-1?t=e.length:0===_&&0===b&&(t=0),n.layer=l,n.uBaryCenter=0,n.dBaryCenter=0,n.upstreamLinkCount=0,n.downstreamLinkCount=0,n.gridPosition=t,n.isVirtual=!0,t&=t,h.insert(e,n,t),a=t+1;e.length>a;a++)i=e[a],i.gridPosition=i.gridPosition+1;s=new o(y,n),s.depthOfDumminess=0,y=n,this.graph.nodes.push(n),this.graph.addLink(s),n.index=this.graph.nodes.length-1,this.mapVirtualNode(n,f)}f.changeSource(y),f.depthOfDumminess=v-m-1}}},_dedummify:function(){for(var e,t,n,i,r,o,a,s,l=!0;l;)for(l=!1,e=0;this.graph.links.length>e;e++)if(t=this.graph.links[e],0!==t.depthOfDumminess){for(n=[],n.unshift({x:t.target.x,y:t.target.y}),n.unshift({x:t.source.x,y:t.source.y}),i=t,r=t.depthOfDumminess,o=0;r>o;o++)a=i.source,s=a.incoming[0],n.unshift({x:s.source.x,y:s.source.y}),i=s;t.changeSource(i.source),t.depthOfDumminess=0,n.length>2?(n.splice(0,1),n.splice(n.length-1),t.points=n):t.points=[],l=!0;break}},_optimizeCrossings:function(){for(var e,t=-1,n=3,i=0;0!==t&&!(i++>n);){for(t=0,e=this.layers.length-1;e>=1;e--)t+=this.optimizeLayerCrossings(!1,e);for(e=0;this.layers.length-1>e;e++)t+=this.optimizeLayerCrossings(!0,e)}},calcUpData:function(e){var t,n,i,r,o,a,s,l,c;if(0!==e){for(t=this.layers[e],o=new d,a=this.layers[e-1],n=0;a.length>n;n++)o.add(a[n]);for(n=0;t.length>n;n++){for(s=t[n],l=0,c=0,i=0;s.incoming.length>i;i++)r=s.incoming[i],o.contains(r.source)&&(c++,l+=r.source.gridPosition);for(i=0;s.outgoing.length>i;i++)r=s.outgoing[i],o.contains(r.target)&&(c++,l+=r.target.gridPosition);c>0?(s.uBaryCenter=l/c,s.upstreamLinkCount=c):(s.uBaryCenter=n,s.upstreamLinkCount=0)}}},calcDownData:function(e){var t,n,i,r,o,a,s,l,c;if(e!==this.layers.length-1){for(t=this.layers[e],o=new d,a=this.layers[e+1],n=0;a.length>n;n++)o.add(a[n]);for(n=0;t.length>n;n++){for(s=t[n],l=0,c=0,i=0;s.incoming.length>i;i++)r=s.incoming[i],o.contains(r.source)&&(c++,l+=r.source.gridPosition);for(i=0;s.outgoing.length>i;i++)r=s.outgoing[i],o.contains(r.target)&&(c++,l+=r.target.gridPosition);c>0?(s.dBaryCenter=l/c,s.downstreamLinkCount=c):(s.dBaryCenter=n,s.downstreamLinkCount=0)}}},optimizeLayerCrossings:function(e,t){var n,i,r,o,a,s,l,c;for(i=e?this.layers[n=t+1]:this.layers[n=t-1],r=i.slice(0),e?this.calcUpData(n):this.calcDownData(n),o=this,i.sort(function(e,t){var n,i=o.calcBaryCenter(e),r=o.calcBaryCenter(t);return Math.abs(i-r)<1e-4?e.degree()===t.degree()?o.compareByIndex(e,t):e.degree()0?-1:0>n?1:o.compareByIndex(e,t))}),s=0,a=0;i.length>a;a++)i[a]!==r[a]&&s++;if(s>0)for(l=0,a=0;i.length>a;a++)c=i[a],c.gridPosition=l++;return s},_swapPairs:function(){for(var e,t,n,i,r,o,a,s,l,c,d,u,h,f,p,g,m,v=this.options.layeredIterations,_=0;;){if(_++>v)break;for(e=1>=_%4,t=_%4===1,
n=e?0:this.layers.length-1;e?this.layers.length-1>=n:n>=0;n+=e?1:-1){for(i=this.layers[n],r=!1,o=!0,a=0,s=0;i.length-1>s;s++)l=0,c=0,d=0,o?(0!==n&&(l=this.countLinksCrossingBetweenTwoLayers(n-1,n)),n!==this.layers.length-1&&(c=this.countLinksCrossingBetweenTwoLayers(n,n+1)),e?l*=2:c*=2,d=l+c):d=a,0!==d&&(u=i[s],h=i[s+1],f=u.gridPosition,p=h.gridPosition,i[s]=h,i[s+1]=u,u.gridPosition=p,h.gridPosition=f,l=0,0!==n&&(l=this.countLinksCrossingBetweenTwoLayers(n-1,n)),c=0,n!==this.layers.length-1&&(c=this.countLinksCrossingBetweenTwoLayers(n,n+1)),e?l*=2:c*=2,g=l+c,m=!1,m=t?g>=d:g>d,m?(u=i[s],h=i[s+1],f=u.gridPosition,p=h.gridPosition,i[s]=h,i[s+1]=u,u.gridPosition=p,h.gridPosition=f,a=d,o=!1):(r=!0,o=!0));r&&(n!==this.layers.length-1&&this.calcUpData(n+1),0!==n&&this.calcDownData(n-1))}}},countLinksCrossingBetweenTwoLayers:function(e,t){var n,i,r,o,a,s,l,c,u,f,p,g,m,v,_,b,w,y,k,x,C=0,S=new d,T=this.layers[e];for(n=0;T.length>n;n++)S.add(T[n]);for(i=new d,r=this.layers[t],n=0;r.length>n;n++)i.add(r[n]);for(o=new d,a=[],s=[],S.forEach(function(e){h.addRange(s,e.incoming),h.addRange(s,e.outgoing)}),l=0;s.length>l;l++)c=s[l],S.contains(c.source)&&i.contains(c.target)?(o.add(c),a.push(c)):i.contains(c.source)&&S.contains(c.target)&&a.push(c);for(u=0;a.length>u;u++)for(f=a[u],p=0;a.length>p;p++)u!==p&&(g=a[p],o.contains(f)?(m=f.source,v=f.target):(m=f.target,v=f.source),o.contains(g)?(_=g.source,b=g.target):(_=g.target,b=g.source),w=m.gridPosition,y=v.gridPosition,k=_.gridPosition,x=b.gridPosition,0>(w-k)*(y-x)&&C++);return C/2},calcBaryCenter:function(e){var t=e.upstreamLinkCount,n=e.downstreamLinkCount,i=e.uBaryCenter,r=e.dBaryCenter;return t>0&&n>0?(i+r)/2:t>0?i:n>0?r:0},_gridPositionComparer:function(e,t){return t.gridPosition>e.gridPosition?-1:e.gridPosition>t.gridPosition?1:0},_positionAscendingComparer:function(e,t){return t.k>e.k?-1:e.k>t.k?1:0},_positionDescendingComparer:function(e,t){return t.k>e.k?1:e.k>t.k?-1:0},_firstVirtualNode:function(e){for(var t=0;e.length>t;t++)if(e[t].isVirtual)return t;return-1},compareByIndex:function(e,t){var n=e.index,i=t.index;return i>n?1:n>i?-1:0},intDiv:function(e,t){return(e-e%t)/t},nextVirtualNode:function(e,t){var n,i=t.layerIndex;for(n=i+1;e.length>n;++n)if(e[n].isVirtual)return e[n];return null}}),C=t.Class.extend({init:function(e,t){if(h.isUndefined(e))throw"No diagram given";this.diagram=e,this.nodeMap=new c,this.linkMap=new c,this.capture(t?t:e)},capture:function(e){var t,i,r,o,a,s,c,d,u;if(e instanceof n.Graph){for(o=0;e.nodes.length>o;o++)t=e.nodes[o],r=t.associatedShape,this.nodeMap.set(r.visual.id,new l(t.x,t.y,t.width,t.height));for(o=0;e.links.length>o;o++)s=e.links[o],a=s.associatedConnection,this.linkMap.set(a.visual.id,s.points())}else if(e instanceof Array)for(i=e,o=0;i.length>o;o++)t=i[o],r=t.associatedShape,r&&this.nodeMap.set(r.visual.id,new l(t.x,t.y,t.width,t.height));else if(e.hasOwnProperty("links")&&e.hasOwnProperty("nodes")){for(i=e.nodes,c=e.links,o=0;i.length>o;o++)t=i[o],r=t.associatedShape,r&&this.nodeMap.set(r.visual.id,new l(t.x,t.y,t.width,t.height));for(o=0;c.length>o;o++)s=c[o],a=s.associatedConnection,a&&this.linkMap.set(a.visual.id,s.points)}else{for(d=this.diagram.shapes,u=this.diagram.connections,o=0;d.length>o;o++)r=d[o],this.nodeMap.set(r.visual.id,r.bounds());for(o=0;u.length>o;o++)a=u[o],this.linkMap.set(a.visual.id,a.points())}}});a(n,{init:function(e){t.init(e,n.ui)},SpringLayout:w,TreeLayout:k,GraphAdapter:b,LayeredLayout:x,LayoutBase:_,LayoutState:C})}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e){var t=e.originalEvent,n=0;return t.wheelDelta?(n=-t.wheelDelta/40,n=n>0?_e.ceil(n):_e.floor(n)):t.detail&&(n=t.detail),n}function i(e){return e.options.name.toLowerCase()===Ie.toLowerCase()}function r(e,t){var n,r,o,a,s=ze,l=t.connectors;for(r=0;l.length>r;r++)o=l[r],i(o)||(a=e.distanceTo(o.position()),s>a&&(s=a,n=o));return n}function o(e,t){var n,i,r,o=[],a=e.drawingContainer().children,s=a.length;for(n=0;t.length>n;n++)for(i=t[n],r=0;s>r;r++)if(a[r]==i.drawingContainer()){o.push(r);break}return o}function a(e){var t=e.drawingContainer().clippedBBox(null);(0!==t.origin.x||0!==t.origin.y)&&e.position(-t.origin.x,-t.origin.y)}function s(e){var t={};return e=e||{},fe(e.text)&&null!==e.text&&(t.text=e.text),fe(e.x)&&null!==e.x&&(t.x=e.x),fe(e.y)&&null!==e.y&&(t.y=e.y),fe(e.width)&&null!==e.width&&(t.width=e.width),fe(e.height)&&null!==e.height&&(t.height=e.height),fe(e.type)&&null!==e.type&&(t.type=e.type),t}function l(e){var t={};return e=e||{},fe(e.text)&&null!==e.text&&(t.content=e.text),fe(e.type)&&null!==e.type&&(t.type=e.type),fe(e.from)&&null!==e.from&&(t.from=e.from),fe(e.fromConnector)&&null!==e.fromConnector&&(t.fromConnector=e.fromConnector),fe(e.fromX)&&null!==e.fromX&&(t.fromX=e.fromX),fe(e.fromY)&&null!==e.fromY&&(t.fromY=e.fromY),fe(e.to)&&null!==e.to&&(t.to=e.to),fe(e.toConnector)&&null!==e.toConnector&&(t.toConnector=e.toConnector),fe(e.toX)&&null!==e.toX&&(t.toX=e.toX),fe(e.toY)&&null!==e.toY&&(t.toY=e.toY),t}function c(t,n){var i,r=this.dataSource.reader.model;r&&(i=r.fn.fields.text?"text":r.idField,e(" ").appendTo(t).kendoDropDownList({dataValueField:r.idField,dataTextField:i,dataSource:this.dataSource.data().toJSON(),optionLabel:" ",valuePrimitive:!0}))}function d(e){this.dataItem=e,this.callbacks=[]}function u(){this.items={}}function h(e){var t=e;return e instanceof kendo.data.Model&&(t=e.toJSON(),t[e.idField]=e._defaultId),t}function f(e){var t,n,i=[],r=[];for(n=0;e.length>n;n++)t=e[n],t instanceof w?r.push(t):i.push(t);return{shapes:r,connections:i}}function p(e,t){return e.reader.model?new e.reader.model(t):new kendo.data.ObservableObject(t)}function g(e,t){fe(t[e])&&t.set(e,null)}function m(e,t,n){var i,r;for(r=0;n.length>r;r++)i=n[r],t&&!fe(t[i])&&(t[i]=e[i])}var v,_,b,w,y,k,x,C,S,T,D,A,E=kendo.dataviz,I=kendo.drawing,R=kendo.geometry,M=E.diagram,F=kendo.ui.Widget,P=kendo.Class,z=e.proxy,B=kendo.deepExtend,L=e.extend,H=kendo.data.HierarchicalDataSource,N=M.Canvas,O=M.Group,V=M.Rectangle,U=M.Circle,W=M.CompositeTransform,j=M.Rect,q=M.Path,G=M.DeleteShapeUnit,$=M.DeleteConnectionUnit,Y=M.TextBlock,K=M.Image,Q=M.Point,X=M.Intersect,J=M.ConnectionEditAdorner,Z=M.UndoRedoService,ee=M.ToolService,te=M.Selector,ne=M.ResizingAdorner,ie=M.ConnectorsAdorner,re=M.Cursors,oe=M.Utils,ae=kendo.Observable,se=M.ToBackUnit,le=M.ToFrontUnit,ce=M.PolylineRouter,de=M.CascadingRouter,ue=oe.isUndefined,he=oe.isDefined,fe=kendo.util.defined,pe=e.isArray,ge=kendo.isFunction,me=oe.isString,ve=e.isPlainObject,_e=Math,be=".kendoDiagram",we="cascading",ye="itemBoundsChange",ke="change",xe="click",Ce="drag",Se="dragEnd",Te="dragStart",De="mouseEnter",Ae="mouseLeave",Ee="error",Ie="Auto",Re="Top",Me="Right",Fe="Left",Pe="Bottom",ze=9007199254740992,Be="select",Le="itemRotate",He="pan",Ne="zoomStart",Oe="zoomEnd",Ve="none",Ue=600,We=600,je="rectangle",qe=100,Ge=100,$e=20,Ye=20,Ke=0,Qe="Yellow",Xe=Number.MAX_VALUE,Je=-Number.MAX_VALUE,Ze="absolute",et="transformed",tt="rotated",nt="transparent",it="width",rt="height",ot="x",at="y",st="DOMMouseScroll"+be+" mousewheel"+be,lt=.05,ct=5,dt=' #=text# ',ut=5;M.DefaultConnectors=[{name:Re},{name:Pe},{name:Fe},{name:Me},{name:Ie,position:function(e){return e.getPosition("center")}}],v={cancel:{text:"Cancel",imageClass:"k-cancel",className:"k-diagram-cancel",iconClass:"k-icon"},update:{text:"Update",imageClass:"k-update",className:"k-diagram-update",iconClass:"k-icon"}},M.shapeDefaults=function(e){var t={type:je,path:"",autoSize:!0,visual:null,x:Ke,y:Ke,minWidth:$e,minHeight:Ye,width:qe,height:Ge,hover:{},editable:{connect:!0,tools:[]},connectors:M.DefaultConnectors,rotation:{angle:0}};return oe.simpleExtend(t,e),t},_=ae.extend({init:function(e){var t=this;t.dataItem=(e||{}).dataItem,ae.fn.init.call(t),t.options=B({id:M.randomId()},t.options,e),t.isSelected=!1,t.visual=new O({id:t.options.id,autoSize:t.options.autoSize}),t._template()},options:{hover:{},cursor:re.grip,content:{align:"center middle"},selectable:!0,serializable:!0,enable:!0},_getCursor:function(e){return this.adorner?this.adorner._getCursor(e):this.options.cursor},visible:function(e){return ue(e)?this.visual.visible():(this.visual.visible(e),t)},bounds:function(){},refresh:function(){this.visual.redraw()},position:function(e){this.options.x=e.x,this.options.y=e.y,this.visual.position(e)},toString:function(){return this.options.id},serialize:function(){var e=B({},{options:this.options});return this.dataItem&&(e.dataItem=""+this.dataItem),e},_content:function(e){var n,i,r;return e!==t&&(n=this.options,M.Utils.isString(e)?n.content.text=e:B(n.content,e),i=n.content,r=this._contentVisual,r?this._updateContentVisual(i):this._createContentVisual(i)),this.options.content.text},_createContentVisual:function(e){e.text&&(this._contentVisual=new Y(e),this._contentVisual._includeInBBox=!1,this.visual.append(this._contentVisual))},_updateContentVisual:function(e){this._contentVisual.redraw(e)},_hitTest:function(e){var t=this.bounds();return this.visible()&&t.contains(e)&&this.options.enable},_template:function(){var e,t,n=this;n.options.content.template&&(e=n.dataItem||{},t=kendo.template(n.options.content.template,{paramName:"dataItem"}),n.options.content.text=t(e))},_canSelect:function(){return this.options.selectable!==!1},toJSON:function(){return{id:this.options.id}}}),b=P.extend({init:function(e,t){this.options=B({},this.options,t),this.connections=[],this.shape=e},options:{width:7,height:7,fill:{color:Qe},hover:{}},position:function(){return this.options.position?this.options.position(this.shape):this.shape.getPosition(this.options.name)},toJSON:function(){return{shapeId:""+this.shape,connector:this.options.name}}}),b.parse=function(e,t){var n,i,r=t.split(":"),o=r[0],a=r[1]||Ie;for(n=0;e.shapes.length>n;n++)if(i=e.shapes[n],i.options.id==o)return i.getConnector(a.trim())},w=_.extend({init:function(e,n){var i=this;_.fn.init.call(i,e),this.diagram=n,this.updateOptionsFromModel(),e=i.options,i.connectors=[],i.type=e.type,i.shapeVisual=w.createShapeVisual(i.options),i.visual.append(this.shapeVisual),i.updateBounds(),i.content(i.content()),i._createConnectors(),i.parentContainer=null,i.isContainer=!1,i.isCollapsed=!1,i.id=i.visual.id,e.hasOwnProperty("layout")&&e.layout!==t&&(i.layout=e.layout.bind(e))},options:M.shapeDefaults(),_setOptionsFromModel:function(e){var t=s(e||this.dataItem);this.options=B({},this.options,t),this.redrawVisual(),this.options.content&&(this._template(),this.content(this.options.content))},updateOptionsFromModel:function(e,t){var n,i;this.diagram&&this.diagram._isEditable&&(n=s(e||this.dataItem),e&&t?E.inArray(t,["x","y","width","height"])?(i=this.bounds(),i[t]=e[t],this.bounds(i)):(this.options.visual?this.redrawVisual():n.type&&(this.options=B({},this.options,n),this.redrawVisual()),this.options.content&&(this._template(),this.content(this.options.content))):this.options=B({},this.options,n))},redrawVisual:function(){this.visual.clear(),this._contentVisual=null,this.options.dataItem=this.dataItem,this.shapeVisual=w.createShapeVisual(this.options),this.visual.append(this.shapeVisual),this.updateBounds()},updateModel:function(e){var t,n,i=this.diagram;i&&i._isEditable&&(t=this._bounds,n=this.dataItem,n&&(i._suspendModelRefresh(),fe(n.x)&&t.x!==n.x&&n.set("x",t.x),fe(n.y)&&t.y!==n.y&&n.set("y",t.y),fe(n.width)&&t.width!==n.width&&n.set("width",t.width),fe(n.height)&&t.height!==n.height&&n.set("height",t.height),this.dataItem=n,i._resumeModelRefresh(),e&&i._syncShapeChanges()))},updateBounds:function(){var e=this.visual._measure(!0),t=this.options;this.bounds(new j(t.x,t.y,e.width,e.height)),this._rotate(),this._alignContent()},content:function(e){var t=this._content(e);return this._alignContent(),t},_alignContent:function(){var e,t,n,i,r,o=this.options.content||{},a=this._contentVisual;a&&o.align&&(e=this.visual._measure(),t=new M.RectAlign(e),n=a.drawingElement.bbox(null),i=new j(0,0,n.width(),n.height()),r=t.align(i,o.align),a.position(r.topLeft()))},_createConnectors:function(){var e,t,n=this.options,i=n.connectors.length,r=n.connectorDefaults;for(t=0;i>t;t++)e=new b(this,B({},r,n.connectors[t])),this.connectors.push(e)},bounds:function(e){var t,n;if(e)if(me(e))switch(e){case et:t=this._transformedBounds();break;case Ze:t=this._transformedBounds(),n=this.diagram._pan,t.x+=n.x,t.y+=n.y;break;case tt:t=this._rotatedBounds();break;default:t=this._bounds}else this._setBounds(e),this._triggerBoundsChange(),this.refreshConnections();else t=this._bounds;return t},_setBounds:function(e){var t=this.options,n=e.topLeft(),i=t.x=n.x,r=t.y=n.y,o=t.width=_e.max(e.width,t.minWidth),a=t.height=_e.max(e.height,t.minHeight);this._bounds=new j(i,r,o,a),this.visual.redraw({x:i,y:r,width:o,height:a})},position:function(e){return e?(this.bounds(new j(e.x,e.y,this._bounds.width,this._bounds.height)),t):this._bounds.topLeft()},clone:function(){var e=this.serialize();return e.options.id=M.randomId(),this.diagram&&this.diagram._isEditable&&fe(this.dataItem)&&(e.options.dataItem=h(this.dataItem)),new w(e.options)},select:function(e){var n,i,r=this.diagram;return ue(e)&&(e=!0),this._canSelect()&&this.isSelected!=e?(n=[],i=[],this.isSelected=e,this.isSelected?(r._selectedItems.push(this),n.push(this)):(oe.remove(r._selectedItems,this),i.push(this)),r._internalSelection||r._selectionChanged(n,i),!0):t},rotate:function(e,n,i){var r,o,a,s,l=this.visual.rotate();return e!==t&&(i!==!1&&this.diagram&&this.diagram.undoRedoService&&e!==l.angle&&this.diagram.undoRedoService.add(new M.RotateUnit(this.diagram._resizingAdorner,[this],[l.angle]),!1),r=this.bounds(),o=new Q(r.width/2,r.height/2),n&&(a=e-l.angle,s=r.center().rotate(n,360-a).minus(o),this._rotationOffset=this._rotationOffset.plus(s.minus(r.topLeft())),this.position(s)),this.visual.rotate(e,o),this.options.rotation.angle=e,this.diagram&&this.diagram._connectorsAdorner&&this.diagram._connectorsAdorner.refresh(),this.refreshConnections(),this.diagram&&this.diagram.trigger(Le,{item:this})),l},connections:function(e){var t,n,i,r,o,a,s,l=[];for(t=0;this.connectors.length>t;t++)for(o=this.connectors[t],r=o.connections,n=0,r;r.length>n;n++)i=r[n],"out"==e?(a=i.source(),a.shape&&a.shape==this&&l.push(i)):"in"==e?(s=i.target(),s.shape&&s.shape==this&&l.push(i)):l.push(i);return l},refreshConnections:function(){e.each(this.connections(),function(){this.refresh()})},getConnector:function(e){var t,n;if(!me(e))return e instanceof Q?r(e,this):this.connectors.length?this.connectors[0]:null;for(e=e.toLocaleLowerCase(),t=0;this.connectors.length>t;t++)if(n=this.connectors[t],n.options.name.toLocaleLowerCase()==e)return n},getPosition:function(e){var t=this.bounds(),n=e.charAt(0).toLowerCase()+e.slice(1);return ge(t[n])?this._transformPoint(t[n]()):t.center()},redraw:function(e){var t,n;e&&(t=this.options,this.shapeVisual.redraw(this._visualOptions(e)),this._diffNumericOptions(e,[it,rt,ot,at])&&(this.bounds(new j(t.x,t.y,t.width,t.height)),n=!0),e.connectors&&(t.connectors=e.connectors,this._updateConnectors()),t=B(t,e),(e.rotation||n)&&this._rotate(),t.content&&this.content(t.content))},_updateConnectors:function(){var e,t,n,i,r=this.connections();for(this.connectors=[],this._createConnectors(),i=0;r.length>i;i++)e=r[i],t=e.source(),n=e.target(),t.shape&&t.shape===this?e.source(this.getConnector(t.options.name)||null):n.shape&&n.shape===this&&e.target(this.getConnector(n.options.name)||null),e.updateModel()},_diffNumericOptions:M.diffNumericOptions,_visualOptions:function(e){return{data:e.path,source:e.source,hover:e.hover,fill:e.fill,stroke:e.stroke,startCap:e.startCap,endCap:e.endCap}},_triggerBoundsChange:function(){this.diagram&&this.diagram.trigger(ye,{item:this,bounds:this._bounds.clone()})},_transformPoint:function(e){var t=this.rotate(),n=this.bounds(),i=n.topLeft();return t.angle&&e.rotate(t.center().plus(i),360-t.angle),e},_transformedBounds:function(){var e=this.bounds(),t=e.topLeft(),n=e.bottomRight();return j.fromPoints(this.diagram.modelToView(t),this.diagram.modelToView(n))},_rotatedBounds:function(){var e=this.bounds().rotatedBounds(this.rotate().angle),t=e.topLeft(),n=e.bottomRight();return j.fromPoints(t,n)},_rotate:function(){var e=this.options.rotation;e&&e.angle&&this.rotate(e.angle),this._rotationOffset=new Q},_hover:function(e){var t=this.options,n=t.hover,i=t.stroke,r=t.fill;e&&he(n.stroke)&&(i=B({},i,n.stroke)),e&&he(n.fill)&&(r=n.fill),this.shapeVisual.redraw({stroke:i,fill:r}),t.editable&&t.editable.connect&&this.diagram._showConnectors(this,e)},_hitTest:function(e){if(this.visible()){var t,n=this.bounds(),i=this.rotate().angle;if(e.isEmpty&&!e.isEmpty())return X.rects(e,n,i?i:0);if(t=e.clone().rotate(n.center(),i),n.contains(t))return this}},toJSON:function(){return{shapeId:this.options.id}}}),w.createShapeVisual=function(e){var t,n,i,r;return delete e.diagram,t=B({},e,{x:0,y:0}),n=t.visual,i=(t.type+"").toLocaleLowerCase(),ge(n)?r=n.call(this,t):t.path?(t.data=t.path,r=new q(t),a(r)):r="rectangle"==i?new V(t):"circle"==i?new U(t):"text"==i?new Y(t):"image"==i?new K(t):new q(t),r},y=_.extend({init:function(e,t,n){var i=this;_.fn.init.call(i,n),this.updateOptionsFromModel(),this._initRouter(),i.path=new M.Polyline(i.options),i.path.fill(nt),i.visual.append(i.path),i._sourcePoint=i._targetPoint=new Q,i.source(e),i.target(t),i.content(i.options.content),i.definers=[],fe(n)&&n.points&&i.points(n.points),i.refresh()},options:{hover:{stroke:{}},startCap:Ve,endCap:Ve,points:[],selectable:!0,fromConnector:Ie,toConenctor:Ie},_setOptionsFromModel:function(e){this.updateOptionsFromModel(e||this.dataItem)},updateOptionsFromModel:function(e){var t,n,i,r;this.diagram&&this.diagram._isEditable&&(t=this.diagram._dataMap,n=l(e||this.dataItem),e?(fe(n.from)?(i=t[n.from],i&&fe(n.fromConnector)&&(i=i.getConnector(n.fromConnector)),this.source(i)):fe(n.fromX)&&fe(n.fromY)&&this.source(new Q(n.fromX,n.fromY)),fe(n.to)?(r=t[n.to],r&&fe(n.toConnector)&&(r=r.getConnector(n.toConnector)),this.target(r)):fe(n.toX)&&fe(n.toY)&&this.target(new Q(n.toX,n.toY)),fe(n.type)&&this.type()!==n.type&&(this.points([]),this.type(n.type)),this.dataItem=e,this._template(),this.redraw(this.options)):this.options=B({},n,this.options))},updateModel:function(e){if(this.diagram&&this.diagram._isEditable&&this.diagram.connectionsDataSource){var t=this.diagram.connectionsDataSource.getByUid(this.dataItem.uid);t&&(this.diagram._suspendModelRefresh(),fe(this.options.fromX)&&null!==this.options.fromX?(g("from",t),g("fromConnector",t),t.set("fromX",this.options.fromX),t.set("fromY",this.options.fromY)):(t.set("from",this.options.from),fe(t.fromConnector)&&t.set("fromConnector",this.sourceConnector?this.sourceConnector.options.name:null),g("fromX",t),g("fromY",t)),fe(this.options.toX)&&null!==this.options.toX?(g("to",t),g("toConnector",t),t.set("toX",this.options.toX),t.set("toY",this.options.toY)):(t.set("to",this.options.to),fe(t.toConnector)&&t.set("toConnector",this.targetConnector?this.targetConnector.options.name:null),g("toX",t),g("toY",t)),fe(this.options.type)&&fe(t.type)&&t.set("type",this.options.type),this.dataItem=t,this.diagram._resumeModelRefresh(),e&&this.diagram._syncConnectionChanges())}},sourcePoint:function(){return this._resolvedSourceConnector?this._resolvedSourceConnector.position():this._sourcePoint},source:function(e,n){var i,r,o;if(he(e)){if(r=e instanceof w,o=this.options.fromConnector||Ie,r&&!e.getConnector(o))return;n&&this.diagram&&this.diagram.undoRedoService.addCompositeItem(new M.ConnectionEditUnit(this,e)),e!==t&&(this.from=e),this._removeFromSourceConnector(),null===e?this.sourceConnector&&(this._sourcePoint=this._resolvedSourceConnector.position(),this._clearSourceConnector(),this._setFromOptions(null,this._sourcePoint)):e instanceof b?(i=e.shape.dataItem,i&&this._setFromOptions(i.id),this.sourceConnector=e,this.sourceConnector.connections.push(this)):e instanceof Q?(this._setFromOptions(null,e),this._sourcePoint=e,this.sourceConnector&&this._clearSourceConnector()):r&&(i=e.dataItem,i&&this._setFromOptions(i.id),this.sourceConnector=e.getConnector(o),this.sourceConnector.connections.push(this)),this.refresh()}return this.sourceConnector?this.sourceConnector:this._sourcePoint},_setFromOptions:function(e,t){this.options.from=e,t?(this.options.fromX=t.x,this.options.fromY=t.y):(this.options.fromX=null,this.options.fromY=null)},sourceDefiner:function(e){if(!e)return this._sourceDefiner||(this._sourceDefiner=new M.PathDefiner(this.sourcePoint(),null,null)),this._sourceDefiner;if(!(e instanceof M.PathDefiner))throw"The sourceDefiner needs to be a PathDefiner.";e.left=null,this._sourceDefiner=e,this.source(e.point)},targetPoint:function(){return this._resolvedTargetConnector?this._resolvedTargetConnector.position():this._targetPoint},target:function(e,n){var i,r,o;if(he(e)){if(r=e instanceof w,o=this.options.toConnector||Ie,r&&!e.getConnector(o))return;n&&this.diagram&&this.diagram.undoRedoService.addCompositeItem(new M.ConnectionEditUnit(this,t,e)),e!==t&&(this.to=e),this._removeFromTargetConnector(),null===e?this.targetConnector&&(this._targetPoint=this._resolvedTargetConnector.position(),this._clearTargetConnector(),this._setToOptions(null,this._targetPoint)):e instanceof b?(i=e.shape.dataItem,i&&this._setToOptions(i.id),this.targetConnector=e,this.targetConnector.connections.push(this)):e instanceof Q?(this._setToOptions(null,e),this._targetPoint=e,this.targetConnector&&this._clearTargetConnector()):r&&(i=e.dataItem,i&&this._setToOptions(i.id),this.targetConnector=e.getConnector(o),this.targetConnector.connections.push(this)),this.refresh()}return this.targetConnector?this.targetConnector:this._targetPoint},_setToOptions:function(e,t){this.options.to=e,t?(this.options.toX=t.x,this.options.toY=t.y):(this.options.toX=null,this.options.toY=null)},targetDefiner:function(e){if(!e)return this._targetDefiner||(this._targetDefiner=new M.PathDefiner(this.targetPoint(),null,null)),this._targetDefiner;if(!(e instanceof M.PathDefiner))throw"The sourceDefiner needs to be a PathDefiner.";e.right=null,this._targetDefiner=e,this.target(e.point)},_updateConnectors:function(){this._updateConnector(this.source(),"source"),this._updateConnector(this.target(),"target")},_updateConnector:function(e,t){var n,i,r,o,a=this,s=a.diagram;e instanceof b&&!s.getShapeById(e.shape.id)?(n=e.shape.dataItem,i=e.options.name,r=function(){var r=s._dataMap[n.id];e=r.getConnector(i),a[t](e,!1),a.updateModel()},s._dataMap[n.id]?r():(o=s._inactiveShapeItems.getByUid(n.uid),o&&s._deferredConnectionUpdates.push(o.onActivate(r)))):a[t](e,!1)},content:function(e){var t=this._content(e);return fe(e)&&this._alignContent(),t},_createContentVisual:function(e){var t;return ge(e.visual)?t=e.visual.call(this,e):e.text&&(t=new Y(e)),t&&(this._contentVisual=t,t._includeInBBox=!1,this.visual.append(t)),t},_updateContentVisual:function(e){ge(e.visual)?(this.visual.remove(this._contentVisual),this._createContentVisual(e)):this._contentVisual.redraw(e)},_alignContent:function(){var e,t,n,i,r,o,a,s,l,c,d,u,h,f,p,g;if(this._contentVisual){for(e=ut,t=this.allPoints(),n=_e.floor(t.length/2),i=n-1;i>0&&t[i].equals(t[n]);)i--,n++;r=t[n],o=t[i],a=this._contentVisual._measure(),s=a.width,l=a.height,c=t.length%2===0,d=o.distanceTo(r),c&&t.length>2&&d>0&&(o.y===r.y&&s>d||o.x===r.x&&l>d)&&(c=!1,e=0),c?(h=kendo.util.deg(_e.atan2(r.y-o.y,r.x-o.x)),u=new Q((r.x-o.x)/2+o.x,(r.y-o.y)/2+o.y),90===_e.abs(h)?(u.x+=e,u.y-=l/2):h%180===0?(u.x-=s/2,u.y-=l+e):-90>h||h>0&&90>h?u.y-=l:(0>h||h>90)&&(u.x-=s,u.y-=l)):(f=_e.floor(t.length/2),u=t[f].clone(),o=t[f-1],r=t[f+1],p=u.x>=o.x&&u.x>=r.x?e:-a.width-e,g=u.y>=o.y&&u.y>=r.y?e:-a.height-e,u.x+=p,u.y+=g),this._contentVisual.position(u)}},select:function(e){var n,i,r=this.diagram;return this._canSelect()&&this.isSelected!==e?(this.isSelected=e,n=[],i=[],this.isSelected?(this.adorner=new J(this,this.options.selection),r._adorn(this.adorner,!0),r._selectedItems.push(this),n.push(this)):this.adorner&&(r._adorn(this.adorner,!1),oe.remove(r._selectedItems,this),this.adorner=t,i.push(this)),this.adorner&&this.adorner.refresh(),r._internalSelection||r._selectionChanged(n,i),!0):t},bounds:function(e){return!e||me(e)?this._bounds:(this._bounds=e,t)},type:function(e){var n=this.options;return e?(e!==n.type&&(n.type=e,this._initRouter(),this.refresh()),t):n.type},_initRouter:function(){var e=(this.options.type||"").toLowerCase();this._router=e==we?new de(this):new ce(this)},points:function(e){var t,n,i,r;if(!e){if(i=[],he(this.definers))for(r=0;this.definers.length>r;r++)i.push(this.definers[r].point);return i}for(this.definers=[],t=0;e.length>t;t++)if(n=e[t],n instanceof M.Point)this.definers.push(new M.PathDefiner(n));else{if(!n.hasOwnProperty("x")||!n.hasOwnProperty("y"))throw"A Connection point needs to be a Point or an object with x and y properties.";this.definers.push(new M.PathDefiner(new Q(n.x,n.y)))}},allPoints:function(){var e,t=[this.sourcePoint()];if(this.definers)for(e=0;this.definers.length>e;e++)t.push(this.definers[e].point);return t.push(this.targetPoint()),t},refresh:function(){this._resolveConnectors(),this._refreshPath(),this._alignContent(),this.adorner&&this.adorner.refresh()},_resolveConnectors:function(){var e,t,n,o,a=this,s=a.source(),l=a.target();s instanceof Q?e=s:s instanceof b&&(i(s)?n=s.shape:(a._resolvedSourceConnector=s,e=s.position())),l instanceof Q?t=l:l instanceof b&&(i(l)?o=l.shape:(a._resolvedTargetConnector=l,t=l.position())),e?o&&(a._resolvedTargetConnector=r(e,o)):n&&(t?a._resolvedSourceConnector=r(t,n):o&&this._resolveAutoConnectors(n,o))},_resolveAutoConnectors:function(e,t){var n,r,o,a,s,l,c,d,u,h,f,p,g=ze,m=ze,v=e.connectors;for(h=0;v.length>h;h++)if(d=v[h],!i(d))for(a=d.position(),n=t.connectors,f=0;n.length>f;f++)u=n[f],i(u)||(s=u.position(),p=_e.round(a.distanceTo(s)),g>p&&this.diagram&&this._testRoutePoints(a,s,d,u)&&(g=p,r=d,o=u),m>p&&(l=d,c=u,m=p));r&&(l=r,c=o),this._resolvedSourceConnector=l,this._resolvedTargetConnector=c},_testRoutePoints:function(e,t,n,i){var r,o,a,s,l,c=this._router,d=!0;if(c instanceof de)for(r=c.routePoints(e,t,n,i),r.unshift(e),r.push(t),l=1;r.length>l;l++)if(o=r[l-1],a=r[l],s=new j(_e.min(o.x,a.x),_e.min(o.y,a.y),_e.abs(o.x-a.x),_e.abs(o.y-a.y)),s.width>0&&(s.x++,s.width-=2),s.height>0&&(s.y++,s.height-=2),!s.isEmpty()&&this.diagram._shapesQuadTree.hitTestRect(s)){d=!1;break}return d},redraw:function(e){if(e){this.options=B({},this.options,e);var t=this.options.points;fe(t)&&t.length>0&&(this.points(t),this._refreshPath()),(e&&e.content||e.text)&&this.content(e.content),this.path.redraw({fill:e.fill,stroke:e.stroke,startCap:e.startCap,endCap:e.endCap})}},clone:function(){var e=this.serialize();return this.diagram&&this.diagram._isEditable&&fe(this.dataItem)&&(e.options.dataItem=h(this.dataItem)),new y(this.from,this.to,e.options)},serialize:function(){var e=this.from.toJSON?this.from.toJSON:""+this.from,t=this.to.toJSON?this.to.toJSON:""+this.to,n=B({},{options:this.options,from:e,to:t});return fe(this.dataItem)&&(n.dataItem=""+this.dataItem),n.options.points=this.points(),n},_hitTest:function(e){if(this.visible()){var t=new Q(e.x,e.y),n=this.sourcePoint(),i=this.targetPoint();if(e.isEmpty&&!e.isEmpty()&&e.contains(n)&&e.contains(i))return this;if(this._router.hitTest(t))return this}},_hover:function(e){var t=(this.options.stroke||{}).color;e&&he(this.options.hover.stroke.color)&&(t=this.options.hover.stroke.color),this.path.redraw({stroke:{color:t}})},_refreshPath:function(){fe(this.path)&&(this._drawPath(),this.bounds(this._router.getBounds()))},_drawPath:function(){var e,t,n;this._router&&this._router.route(),e=this.sourcePoint(),t=this.targetPoint(),n=this.points(),this.path.redraw({points:[e].concat(n,[t])})},_clearSourceConnector:function(){oe.remove(this.sourceConnector.connections,this),this.sourceConnector=t,this._resolvedSourceConnector=t},_clearTargetConnector:function(){oe.remove(this.targetConnector.connections,this),this.targetConnector=t,this._resolvedTargetConnector=t},_removeFromSourceConnector:function(){this.sourceConnector&&oe.remove(this.sourceConnector.connections,this)},_removeFromTargetConnector:function(){this.targetConnector&&oe.remove(this.targetConnector.connections,this)},toJSON:function(){var e,t,n,i=this;return i.from&&i.from.toJSON?e=i.from.toJSON():(n=i._sourcePoint,e={x:n.x,y:n.y}),i.to&&i.to.toJSON?t=i.to.toJSON():(n=i._targetPoint,t={x:n.x,y:n.y}),{from:e,to:t}}}),k=F.extend({init:function(e,t){var n=this;kendo.destroy(e),F.fn.init.call(n,e,t),n._initTheme(),n._initElements(),n._extendLayoutOptions(n.options),n._initDefaults(t),n._initCanvas(),n.mainLayer=new O({id:"main-layer"}),n.canvas.append(n.mainLayer),n._shapesQuadTree=new A(n),n._pan=new Q,n._adorners=[],n.adornerLayer=new O({id:"adorner-layer"}),n.canvas.append(n.adornerLayer),n._createHandlers(),n._initialize(),n._fetchFreshData(),n._createGlobalToolBar(),n._resizingAdorner=new ne(n,{editable:n.options.editable}),n._connectorsAdorner=new ie(n),n._adorn(n._resizingAdorner,!0),n._adorn(n._connectorsAdorner,!0),n.selector=new te(n),n._clipboard=[],n.pauseMouseHandlers=!1,n._createShapes(),n._createConnections(),n.options.layout&&n.layout(n.options.layout),n.zoom(n.options.zoom),n.canvas.draw()},options:{name:"Diagram",theme:"default",layout:"",zoomRate:.1,zoom:1,zoomMin:0,zoomMax:2,dataSource:{},draggable:!0,template:"",autoBind:!0,editable:{rotate:{},resize:{},text:!0,tools:[],drag:{snap:{size:10,angle:10}},remove:!0},pannable:{key:"ctrl"},selectable:{key:"none"},tooltip:{enabled:!0,format:"{0}"},copy:{enabled:!0,offsetX:20,offsetY:20},shapeDefaults:M.shapeDefaults({undoable:!0}),connectionDefaults:{editable:{tools:[]},type:we},shapes:[],connections:[]},events:[Oe,Ne,He,Be,Le,ye,ke,xe,De,Ae,"toolBarClick","save","cancel","edit","remove","add","dataBound",Te,Ce,Se],items:function(){return e()},_createGlobalToolBar:function(){var e,t=this.options.editable;t&&(e=t.tools,!this._isEditable||e===!1||e&&0!==e.length||(e=["createShape","undo","redo","rotateClockwise","rotateAnticlockwise"]),e&&e.length&&(this.toolBar=new x(this,{tools:e||{},click:z(this._toolBarClick,this),modal:!1}),this.toolBar.element.css({textAlign:"left"}),this.element.prepend(this.toolBar.element),this._resize()))},createShape:function(){var e,t,n,i,r,o;(this.editor&&this.editor.end()||!this.editor)&&(e=this.dataSource,t=e.view()||[],n=t.length,i=p(e,{}),r=this._createShape(i,{}),this.trigger("add",{shape:r})||(e.insert(n,i),o=this._inactiveShapeItems.getByUid(i.uid),o.element=r,this.edit(r)))},_createShape:function(e,t){t=B({},this.options.shapeDefaults,t),t.dataItem=e;var n=new w(t,this);return n},createConnection:function(){var e,t,n,i,r;(this.editor&&this.editor.end()||!this.editor)&&(e=this.connectionsDataSource,t=e.view()||[],n=t.length,i=p(e,{}),r=this._createConnection(i),this.trigger("add",{connection:r})||(this._connectionsDataMap[i.uid]=r,e.insert(n,i),this.addConnection(r,!1),this.edit(r)))},_createConnection:function(e,t,n){var i,r=B({},this.options.connectionDefaults);return r.dataItem=e,i=new y(t||new Q,n||new Q,r)},editModel:function(e,t){var n,i,r,o;if(this.cancelEdit(),r=this.options.editable,"shape"==t)n=r.shapeEditors,i=r.shapeTemplate;else{if("connection"!=t)return;o=z(c,this),n=B({},{from:o,to:o},r.connectionEditors),i=r.connectionTemplate}this.editor=new S(this.element,{update:z(this._update,this),cancel:z(this._cancel,this),model:e,type:t,target:this,editors:n,template:i}),this.trigger("edit",this._editArgs())},edit:function(e){if(e.dataItem){var t=e instanceof w?"shape":"connection";this.editModel(e.dataItem,t)}},cancelEdit:function(){this.editor&&(this._getEditDataSource().cancelChanges(this.editor.model),this._destroyEditor())},saveEdit:function(){this.editor&&this.editor.end()&&!this.trigger("save",this._editArgs())&&this._getEditDataSource().sync()},_update:function(){this.editor&&this.editor.end()&&!this.trigger("save",this._editArgs())&&(this._getEditDataSource().sync(),
this._destroyEditor())},_cancel:function(){var e,t;this.editor&&!this.trigger("cancel",this._editArgs())&&(e=this.editor.model,this._getEditDataSource().cancelChanges(e),t=this._connectionsDataMap[e.uid]||this._dataMap[e.id],t&&t._setOptionsFromModel(e),this._destroyEditor())},_getEditDataSource:function(){return"shape"===this.editor.options.type?this.dataSource:this.connectionsDataSource},_editArgs:function(){var e={container:this.editor.element};return e[this.editor.options.type]=this.editor.model,e},_destroyEditor:function(){this.editor&&(this.editor.close(),this.editor=null)},_initElements:function(){this.wrapper=this.element.empty().css("position","relative").attr("tabindex",0).addClass("k-widget k-diagram"),this.scrollable=e("
").appendTo(this.element)},_initDefaults:function(e){var t=this.options,n=t.editable,i=t.shapeDefaults,r=t.connectionDefaults,o=(e||{}).shapeDefaults;n===!1?(i.editable=!1,r.editable=!1):(m(n,i.editable,["drag","remove","connect"]),m(n,r.editable,["drag","remove"])),o&&o.connectors&&(t.shapeDefaults.connectors=o.connectors)},_initCanvas:function(){var t=e("
").appendTo(this.scrollable)[0],n=this.viewport();this.canvas=new N(t,{width:n.width||Ue,height:n.height||We})},_createHandlers:function(){var e=this,t=e.element;t.on(st,z(e._wheel,e)),kendo.support.touch||kendo.support.mobileOS?(e._userEvents=new kendo.UserEvents(t,{multiTouch:!0,tap:z(e._tap,e)}),e._userEvents.bind(["gesturestart","gesturechange","gestureend"],{gesturestart:z(e._gestureStart,e),gesturechange:z(e._gestureChange,e),gestureend:z(e._gestureEnd,e)}),e.toolService=new ee(e),e.options.pannable!==!1&&e.scroller.enable()):(e.toolService=new ee(e),this.scroller.wrapper.on("mousemove"+be,z(e._mouseMove,e)).on("mouseup"+be,z(e._mouseUp,e)).on("mousedown"+be,z(e._mouseDown,e)).on("mouseover"+be,z(e._mouseover,e)).on("mouseout"+be,z(e._mouseout,e)),t.on("keydown"+be,z(e._keydown,e))),this._syncHandler=z(e._syncChanges,e),e._resizeHandler=z(e.resize,e,!1),kendo.onResize(e._resizeHandler),this.bind(Ne,z(e._destroyToolBar,e)),this.bind(He,z(e._destroyToolBar,e))},_tap:function(e){var t,n=this.toolService,i=this._caculateMobilePosition(e);n._updateHoveredItem(i),n.hoveredItem&&(t=n.hoveredItem,this.options.selectable!==!1&&(this._destroyToolBar(),t.isSelected?t.select(!1):this.select(t,{addToSelection:!0}),this._createToolBar()),this.trigger("click",{item:t,point:i}))},_caculateMobilePosition:function(e){return this.documentToModel(Q(e.x.location,e.y.location))},_gestureStart:function(e){var t,n;this._destroyToolBar(),this.scroller.disable(),t=this.documentToModel(new Q(e.center.x,e.center.y)),n={point:t,zoom:this.zoom()},this.trigger(Ne,n)||(this._gesture=e,this._initialCenter=t)},_gestureChange:function(e){var t,n,i=this._gesture,r=this._initialCenter,o=this.documentToView(new Q(e.center.x,e.center.y)),a=e.distance/i.distance,s=this._zoom,l=!1;_e.abs(a-1)>=lt&&(this._zoom=s=this._getValidZoom(s*a),this.options.zoom=s,this._gesture=e,l=!0),t=r.times(s),n=o.minus(t),(l||this._pan.distanceTo(n)>=ct)&&(this._panTransform(n),this._updateAdorners()),e.preventDefault()},_gestureEnd:function(){this.options.pannable!==!1&&this.scroller.enable(),this.trigger(Oe,{point:this._initialCenter,zoom:this.zoom()})},_resize:function(){var e=this.viewport();this.canvas&&this.canvas.size(e),this.scrollable&&this.toolBar&&this.scrollable.height(e.height)},_mouseover:function(e){var t=e.target._kendoNode;t&&t.srcElement._hover&&t.srcElement._hover(!0,t.srcElement)},_mouseout:function(e){var t=e.target._kendoNode;t&&t.srcElement._hover&&t.srcElement._hover(!1,t.srcElement)},_initTheme:function(){var e=this,t=E.ui.themes||{},n=((e.options||{}).theme||"").toLowerCase(),i=(t[n]||{}).diagram;e.options=B({},i,e.options),e.options.editable===!0&&B(e.options,{editable:(i||{}).editable})},_createShapes:function(){var e,t,n=this,i=n.options,r=i.shapes;for(t=0;r.length>t;t++)e=r[t],n.addShape(e)},_createConnections:function(){var e,t,n,i,r=this,o=r.options,a=o.connectionDefaults,s=o.connections;for(i=0;s.length>i;i++)e=s[i],t=r._findConnectionTarget(e.from),n=r._findConnectionTarget(e.to),r.connect(t,n,B({},a,e))},_findConnectionTarget:function(e){var t,n=this,i=me(e)?e:e.shapeId||e.id;return i?(t=n.getShapeById(i),e.connector&&(t=t.getConnector(e.connector))):t=new Q(e.x||0,e.y||0),t},destroy:function(){var e=this;F.fn.destroy.call(e),this._userEvents&&this._userEvents.destroy(),kendo.unbindResize(e._resizeHandler),e.clear(),e.element.off(be),e.scroller.wrapper.off(be),e.canvas.destroy(!0),e.canvas=t,e._destroyEditor(),e.destroyScroller(),e._destroyGlobalToolBar(),e._destroyToolBar()},destroyScroller:function(){var e=this.scroller;e&&(e.destroy(),e.element.remove(),this.scroller=null)},save:function(){var e,t,n,i={shapes:[],connections:[]};for(e=0;this.shapes.length>e;e++)n=this.shapes[e],n.options.serializable&&i.shapes.push(n.options);for(e=0;this.connections.length>e;e++)t=this.connections[e],i.connections.push(B({},t.options,t.toJSON()));return i},focus:function(){if(!this.element.is(kendo._activeElement())){var e,t=this.element,n=t[0],i=[],r=[],o=document.documentElement;do n=n.parentNode,n.scrollHeight>n.clientHeight&&(i.push(n),r.push(n.scrollTop));while(n!=o);for(t.focus(),e=0;i.length>e;e++)i[e].scrollTop=r[e]}},load:function(e){this.clear(),this.setOptions(e),this._createShapes(),this._createConnections()},setOptions:function(e){B(this.options,e)},clear:function(){var e=this;e.select(!1),e.mainLayer.clear(),e._shapesQuadTree.clear(),e._initialize()},connect:function(e,t,n){var i,r;return this.connectionsDataSource&&this._isEditable?(r=this.connectionsDataSource.add({}),i=this._connectionsDataMap[r.uid],i.source(e),i.target(t),i.redraw(n),i.updateModel()):(i=new y(e,t,B({},this.options.connectionDefaults,n)),this.addConnection(i)),i},connected:function(e,t){var n,i;for(n=0;this.connections.length>n;n++)if(i=this.connections[n],i.from==e&&i.to==t)return!0;return!1},addConnection:function(e,t){return t!==!1&&this.undoRedoService.add(new M.AddConnectionUnit(e,this),!1),e.diagram=this,e._setOptionsFromModel(),e.refresh(),this.mainLayer.append(e.visual),this.connections.push(e),this.trigger(ke,{added:[e],removed:[]}),e},_addConnection:function(e,t){var n,i=this.connectionsDataSource;if(i&&this._isEditable){if(n=p(i,h(e.dataItem)),e.dataItem=n,e.updateModel(),!this.trigger("add",{connection:e}))return this._connectionsDataMap[n.uid]=e,i.add(n),this.addConnection(e,t),e._updateConnectors(),e}else if(!this.trigger("add",{connection:e}))return this.addConnection(e,t),e._updateConnectors(),e},addShape:function(e,t){var n,i=this.options.shapeDefaults;if(e instanceof w)i=B({},i,t),e.redraw(t),n=e;else{if(e instanceof kendo.Class)return;i=B({},i,e||{}),n=new w(i)}return i.undoable&&this.undoRedoService.add(new M.AddShapeUnit(n,this),!1),this.shapes.push(n),n.diagram=this,this.mainLayer.append(n.visual),this._shapesQuadTree.insert(n),this.trigger(ke,{added:[n],removed:[]}),n.hasOwnProperty("layout")&&n.layout(n),n},_addShape:function(e,t){var n,i,r=this,o=r.dataSource;if(o&&this._isEditable){if(n=p(o,h(e.dataItem)),e.dataItem=n,e.updateModel(),!this.trigger("add",{shape:e}))return this.dataSource.add(n),i=this._inactiveShapeItems.getByUid(n.uid),i.element=e,i.undoable=t,e}else if(!this.trigger("add",{shape:e}))return this.addShape(e,{undoable:t})},remove:function(e,t){var n,i,r,o;for(e=pe(e)?e.slice(0):[e],n=f(e),i=n.shapes,r=n.connections,fe(t)||(t=!0),t&&this.undoRedoService.begin(),this._suspendModelRefresh(),o=i.length-1;o>=0;o--)this._removeItem(i[o],t,r);for(o=r.length-1;o>=0;o--)this._removeItem(r[o],t);this._resumeModelRefresh(),t&&this.undoRedoService.commit(!1),this.trigger(ke,{added:[],removed:e})},_removeShapeDataItem:function(e){this._isEditable&&(this.dataSource.remove(e.dataItem),delete this._dataMap[e.dataItem.id])},_removeConnectionDataItem:function(e){this._isEditable&&(this.connectionsDataSource.remove(e.dataItem),delete this._connectionsDataMap[e.dataItem.uid])},_triggerRemove:function(e){var t,n,i,r,o=[];for(r=0;e.length>r;r++)t=e[r],i=t.options.editable,n=t instanceof w?{shape:t}:{connection:t},i&&i.remove!==!1&&!this.trigger("remove",n)&&o.push(t);return o},undo:function(){this.undoRedoService.undo()},redo:function(){this.undoRedoService.redo()},select:function(e,t){if(!he(e))return this._selectedItems;t=B({addToSelection:!1},t);var n,i,r=t.addToSelection,o=[],a=[];for(r||this.deselect(),this._internalSelection=!0,e instanceof Array?o=e:e instanceof _&&(o=[e]),n=0;o.length>n;n++)i=o[n],i.select(!0)&&a.push(i);this._selectionChanged(a,[]),this._internalSelection=!1},selectAll:function(){this.select(this.shapes.concat(this.connections))},selectArea:function(e){var t,n,i,r;if(this._internalSelection=!0,r=[],e instanceof j)for(n=this.shapes.concat(this.connections),t=0;n.length>t;t++)i=n[t],e&&!i._hitTest(e)||!i.options.enable||i.select(!0)&&r.push(i);this._selectionChanged(r,[]),this._internalSelection=!1},deselect:function(e){this._internalSelection=!0;var t,n,i=[],r=[];for(e instanceof Array?r=e:e instanceof _?r.push(e):he(e)||(r=this._selectedItems.slice(0)),n=0;r.length>n;n++)t=r[n],t.select(!1)&&i.push(t);this._selectionChanged([],i),this._internalSelection=!1},toFront:function(e,t){var n,i,r;e||(e=this._selectedItems.slice()),n=this._getDiagramItems(e),!fe(t)||t?(i=o(this.mainLayer,n.visuals),r=new le(this,e,i),this.undoRedoService.add(r)):(this.mainLayer.toFront(n.visuals),this._fixOrdering(n,!0))},toBack:function(e,t){var n,i,r;e||(e=this._selectedItems.slice()),n=this._getDiagramItems(e),!fe(t)||t?(i=o(this.mainLayer,n.visuals),r=new se(this,e,i),this.undoRedoService.add(r)):(this.mainLayer.toBack(n.visuals),this._fixOrdering(n,!1))},bringIntoView:function(e,t){var n,i,r,o,a=this.viewport(),s=new M.RectAlign(a);0!==a.width&&0!==a.height&&(t=B({animate:!1,align:"center middle"},t),"none"==t.align&&(t.align="center middle"),e instanceof _?i=e.bounds(et):pe(e)?i=this.boundingBox(e):e instanceof j&&(i=e.clone()),r=i.clone(),i.zoom(this._zoom),(i.width>a.width||i.height>a.height)&&(this._zoom=this._getValidZoom(_e.min(a.width/r.width,a.height/r.height)),i=r.clone().zoom(this._zoom)),this._zoomMainLayer(),n=i.clone(),s.align(i,t.align),o=i.topLeft().minus(n.topLeft()),this.pan(o.times(-1),t.animate))},alignShapes:function(e){var t,n,i,r,o,a,s;if(ue(e)&&(e="Left"),t=this.select(),0!==t.length){switch(e.toLowerCase()){case"left":case"top":n=Xe;break;case"right":case"bottom":n=Je}for(r=0;t.length>r;r++)if(i=t[r],i instanceof w)switch(e.toLowerCase()){case"left":n=_e.min(n,i.options.x);break;case"top":n=_e.min(n,i.options.y);break;case"right":n=_e.max(n,i.options.x);break;case"bottom":n=_e.max(n,i.options.y)}for(o=[],a=[],r=0;t.length>r;r++)if(i=t[r],i instanceof w)switch(a.push(i),o.push(i.bounds()),e.toLowerCase()){case"left":case"right":i.position(new Q(n,i.options.y));break;case"top":case"bottom":i.position(new Q(i.options.x,n))}s=new M.TransformUnit(a,o),this.undoRedoService.add(s,!1)}},zoom:function(e,t){var n,i,r,o;return e&&(n=t?t.point:new M.Point(0,0),e=this._zoom=this._getValidZoom(e),ue(n)||(n=new M.Point(_e.round(n.x),_e.round(n.y)),i=n.times(e),r=this.modelToView(n),o=r.minus(i),this._storePan(new M.Point(_e.round(o.x),_e.round(o.y)))),t&&(t.zoom=e),this._panTransform(),this._updateAdorners()),this._zoom},_getPan:function(e){var t=this.canvas;return t.translate||(e=e.plus(this._pan)),e},pan:function(e,t){var n,i;e instanceof Q&&(n=this,i=n.scroller,e=n._getPan(e),e=e.times(-1),t?i.animatedScrollTo(e.x,e.y,function(){n._updateAdorners()}):(i.scrollTo(e.x,e.y),n._updateAdorners()))},viewport:function(){var e=this.element,t=e.width(),n=e.height();return this.toolBar&&(n-=this.toolBar.element.outerHeight()),new j(0,0,t,n)},copy:function(){var e,t;if(this.options.copy.enabled)for(this._clipboard=[],this._copyOffset=1,e=0;this._selectedItems.length>e;e++)t=this._selectedItems[e],this._clipboard.push(t)},cut:function(){var e,t;if(this.options.copy.enabled){for(this._clipboard=[],this._copyOffset=0,e=0;this._selectedItems.length>e;e++)t=this._selectedItems[e],this._clipboard.push(t);this.remove(this._clipboard,!0)}},paste:function(){var e,t,n,i,r,o,a,s;if(this._clipboard.length>0){for(i={},r=f(this._clipboard),o=r.connections,a=r.shapes,s={x:this._copyOffset*this.options.copy.offsetX,y:this._copyOffset*this.options.copy.offsetY},this.deselect(),n=0;a.length>n;n++)e=a[n],t=e.clone(),i[e.id]=t,t.position(new Q(e.options.x+s.x,e.options.y+s.y)),t.diagram=this,t=this._addShape(t),t&&t.select();for(n=0;o.length>n;n++)e=o[n],t=this._addConnection(e.clone()),t&&(this._updateCopiedConnection(t,e,"source",i,s),this._updateCopiedConnection(t,e,"target",i,s),t.select(!0),t.updateModel());this._syncChanges(),this._copyOffset+=1}},_updateCopiedConnection:function(e,t,n,i,r){var o,a,s,l=t[n](),c=this;l instanceof b&&i[l.shape.id]?(s=i[l.shape.id],c.getShapeById(s.id)?e[n](s.getConnector(l.options.name)):(a=c._inactiveShapeItems.getByUid(s.dataItem.uid),a&&(o=function(t){s=c._dataMap[t.id],e[n](s.getConnector(l.options.name)),e.updateModel()},c._deferredConnectionUpdates.push(a.onActivate(o))))):e[n](new Q(t[n+"Point"]().x+r.x,t[n+"Point"]().y+r.y))},boundingBox:function(e,t){var n,i,r,o=j.empty(),a=he(e)?this._getDiagramItems(e):{shapes:this.shapes};if(a.shapes.length>0)for(i=a.shapes[0],o=i.bounds(tt),r=1;a.shapes.length>r;r++)i=a.shapes[r],n=i.bounds(tt),t===!0&&(n.x-=i._rotationOffset.x,n.y-=i._rotationOffset.y),o=o.union(n);return o},_containerOffset:function(){var e=this.element.offset();return this.toolBar&&(e.top+=this.toolBar.element.outerHeight()),e},documentToView:function(e){var t=this._containerOffset();return new Q(e.x-t.left,e.y-t.top)},viewToDocument:function(e){var t=this._containerOffset();return new Q(e.x+t.left,e.y+t.top)},viewToModel:function(e){return this._transformWithMatrix(e,this._matrixInvert)},modelToView:function(e){return this._transformWithMatrix(e,this._matrix)},modelToLayer:function(e){return this._transformWithMatrix(e,this._layerMatrix)},layerToModel:function(e){return this._transformWithMatrix(e,this._layerMatrixInvert)},documentToModel:function(e){var t=this.documentToView(e);return this.canvas.translate||(t.x=t.x+this.scroller.scrollLeft,t.y=t.y+this.scroller.scrollTop),this.viewToModel(t)},modelToDocument:function(e){return this.viewToDocument(this.modelToView(e))},_transformWithMatrix:function(e,t){var n,i,r=e;return e instanceof Q?t&&(r=t.apply(e)):(n=this._transformWithMatrix(e.topLeft(),t),i=this._transformWithMatrix(e.bottomRight(),t),r=j.fromPoints(n,i)),r},setDataSource:function(e){this.options.dataSource=e,this._dataSource(),this.options.autoBind&&this.dataSource.fetch()},setConnectionsDataSource:function(e){this.options.connectionsDataSource=e,this._connectionDataSource(),this.options.autoBind&&this.connectionsDataSource.fetch()},layout:function(e){var t,n,i,r,o;switch(this.isLayouting=!0,ue(e)&&(e=this.options.layout),t=ue(e)||ue(e.type)?"Tree":e.type,t.toLowerCase()){case"tree":n=new M.TreeLayout(this);break;case"layered":n=new M.LayeredLayout(this);break;case"forcedirected":case"force":case"spring":case"springembedder":n=new M.SpringLayout(this);break;default:throw"Layout algorithm '"+t+"' is not supported."}i=new M.LayoutState(this),r=n.layout(e),r&&(o=new M.LayoutUndoUnit(i,r,e?e.animate:null),this.undoRedoService.add(o)),this.isLayouting=!1},getShapeById:function(e){var t;return(t=oe.first(this.shapes,function(t){return t.visual.id===e}))?t:t=oe.first(this.connections,function(t){return t.visual.id===e})},_extendLayoutOptions:function(e){e.layout&&(e.layout=B(M.LayoutBase.fn.defaultOptions||{},e.layout))},_selectionChanged:function(e,t){(e.length||t.length)&&this.trigger(Be,{selected:e,deselected:t})},_getValidZoom:function(e){return _e.min(_e.max(e,this.options.zoomMin),this.options.zoomMax)},_panTransform:function(e){var t=this,n=e||t._pan;t.canvas.translate?(t.scroller.scrollTo(n.x,n.y),t._zoomMainLayer()):(t._storePan(n),t._transformMainLayer())},_finishPan:function(){this.trigger(He,{total:this._pan,delta:Number.NaN})},_storePan:function(e){this._pan=e,this._storeViewMatrix()},_zoomMainLayer:function(){var e=this._zoom,t=new W(0,0,e,e);t.render(this.mainLayer),this._storeLayerMatrix(t),this._storeViewMatrix()},_transformMainLayer:function(){var e=this._pan,t=this._zoom,n=new W(e.x,e.y,t,t);n.render(this.mainLayer),this._storeLayerMatrix(n),this._storeViewMatrix()},_storeLayerMatrix:function(e){this._layerMatrix=e.toMatrix(),this._layerMatrixInvert=e.invert().toMatrix()},_storeViewMatrix:function(){var e=this._pan,t=this._zoom,n=new W(e.x,e.y,t,t);this._matrix=n.toMatrix(),this._matrixInvert=n.invert().toMatrix()},_toIndex:function(e,t){var n=this._getDiagramItems(e);this.mainLayer.toIndex(n.visuals,t),this._fixOrdering(n,!1)},_fixOrdering:function(e,t){var n,i,r=t?this.shapes.length-1:0,o=t?this.connections.length-1:0;for(n=0;e.shapes.length>n;n++)i=e.shapes[n],oe.remove(this.shapes,i),oe.insert(this.shapes,i,r);for(n=0;e.cons.length>n;n++)i=e.cons[n],oe.remove(this.connections,i),oe.insert(this.connections,i,o)},_getDiagramItems:function(e){var t,n,i={},r=e;for(i.visuals=[],i.shapes=[],i.cons=[],e?pe(e)||(r=[e]):r=this._selectedItems.slice(),t=0;r.length>t;t++)n=r[t],n instanceof w?(i.shapes.push(n),i.visuals.push(n.visual)):n instanceof y&&(i.cons.push(n),i.visuals.push(n.visual));return i},_removeItem:function(e,t,n){e.select(!1),e instanceof w?(this._removeShapeDataItem(e),this._removeShape(e,t,n)):e instanceof y&&(this._removeConnectionDataItem(e),this._removeConnection(e,t)),this.mainLayer.remove(e.visual)},_removeShape:function(e,t,n){var i,r,o,a,s=[],l=[];for(this.toolService._removeHover(),t&&this.undoRedoService.addCompositeItem(new G(e)),oe.remove(this.shapes,e),this._shapesQuadTree.remove(e),i=0;e.connectors.length>i;i++)for(o=e.connectors[i],a=0;o.connections.length>a;a++)r=o.connections[a],n&&E.inArray(r,n)||(r.sourceConnector==o?s.push(r):r.targetConnector==o&&l.push(r));for(i=0;s.length>i;i++)s[i].source(null,t),s[i].updateModel();for(i=0;l.length>i;i++)l[i].target(null,t),l[i].updateModel()},_removeConnection:function(e,t){e.sourceConnector&&oe.remove(e.sourceConnector.connections,e),e.targetConnector&&oe.remove(e.targetConnector.connections,e),t&&this.undoRedoService.addCompositeItem(new $(e)),oe.remove(this.connections,e)},_removeDataItems:function(e,t){var n,i,r,o;for(e=pe(e)?e:[e];e.length;)if(n=e.shift(),r=this._dataMap[n.uid],r&&(this._removeShapeConnections(r),this._removeItem(r,!1),delete this._dataMap[n.uid],t&&n.hasChildren&&n.loaded()))for(i=n.children.data(),o=0;i.length>o;o++)e.push(i[o])},_removeShapeConnections:function(e){var t,n=e.connections();if(n)for(t=0;n.length>t;t++)this._removeItem(n[t],!1)},_addDataItem:function(e,t){var n,i;if(fe(e))return(n=this._dataMap[e.id])?n:(i=B({},this.options.shapeDefaults),i.dataItem=e,n=new w(i,this),this.addShape(n,{undoable:t!==!1}),this._dataMap[e.id]=n,n)},_addDataItemByUid:function(e){var t,n;if(fe(e))return(t=this._dataMap[e.uid])?t:(n=B({},this.options.shapeDefaults),n.dataItem=e,t=new w(n,this),this.addShape(t),this._dataMap[e.uid]=t,t)},_addDataItems:function(e,t){var n,i,r,o,a;for(i=0;e.length>i;i++)n=e[i],r=this._addDataItemByUid(n),o=this._addDataItemByUid(t),o&&!this.connected(o,r)&&(a=this.connect(o,r))},_refreshSource:function(e){var t,n,i=this,r=e.node,o=e.action,a=e.items,s=i.options;if(!e.field){if("remove"==o)this._removeDataItems(e.items,!0);else{for(o&&"itemloaded"!==o||this._bindingRoots||(this._bindingRoots=!0,n=!0),o||r||i.clear(),this._addDataItems(a,r),t=0;a.length>t;t++)a[t].load();n&&(this.trigger("dataBound"),this._bindingRoots=!1)}s.layout&&i.layout(s.layout)}},_mouseDown:function(e){var t=this._calculatePosition(e);1==e.which&&this.toolService.start(t,this._meta(e))&&(this._destroyToolBar(),e.preventDefault())},_addItem:function(e){e instanceof w?this.addShape(e):e instanceof y&&this.addConnection(e)},_mouseUp:function(e){var t=this._calculatePosition(e);1==e.which&&this.toolService.end(t,this._meta(e))&&(this._createToolBar(),e.preventDefault())},_createToolBar:function(){var e,t,n,i,r,o,a,s,l,c=this.toolService.diagram;this.singleToolBar||1!==c.select().length||(e=c.select()[0],e&&e.options.editable!==!1&&(t=e.options.editable,n=t.tools,this._isEditable&&0===n.length&&(e instanceof w?n=["edit","rotateClockwise","rotateAnticlockwise"]:e instanceof y&&(n=["edit"]),t&&t.remove!==!1&&n.push("delete")),n&&n.length&&(i=20,this.singleToolBar=new x(c,{tools:n,click:z(this._toolBarClick,this),modal:!0}),o=this.singleToolBar._popup.element.outerWidth(),a=this.singleToolBar._popup.element.outerHeight(),e instanceof w?(s=this.modelToView(e.bounds(tt)),r=Q(s.x,s.y).minus(Q((o-s.width)/2,a+i))):e instanceof y&&(l=this.modelToView(e.bounds()),r=Q(l.x,l.y).minus(Q((o-l.width-20)/2,a+i))),r?(this.canvas.translate||(r=r.minus(Q(this.scroller.scrollLeft,this.scroller.scrollTop))),r=this.viewToDocument(r),r=Q(_e.max(r.x,0),_e.max(r.y,0)),this.singleToolBar.showAt(r)):this._destroyToolBar())))},_toolBarClick:function(e){this.trigger("toolBarClick",e),this._destroyToolBar()},_mouseMove:function(e){if(!this.pauseMouseHandlers){var t=this._calculatePosition(e);0!==e.which&&1!=e.which||!this.toolService.move(t,this._meta(e))||e.preventDefault()}},_keydown:function(e){this.toolService.keyDown(e.keyCode,this._meta(e))&&e.preventDefault()},_wheel:function(e){var t=n(e),i=this._calculatePosition(e),r=B(this._meta(e),{delta:t});this.toolService.wheel(i,r)&&e.preventDefault()},_meta:function(e){return{ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey}},_calculatePosition:function(e){var n=e.pageX===t?e.originalEvent:e,i=new Q(n.pageX,n.pageY),r=this.documentToModel(i);return r},_normalizePointZoom:function(e){return e.times(1/this.zoom())},_initialize:function(){this.shapes=[],this._selectedItems=[],this.connections=[],this._dataMap={},this._connectionsDataMap={},this._inactiveShapeItems=new u,this._deferredConnectionUpdates=[],this.undoRedoService=new Z({undone:this._syncHandler,redone:this._syncHandler}),this.id=M.randomId()},_fetchFreshData:function(){var e=this;e._dataSource(),e._isEditable&&e._connectionDataSource(),e.options.autoBind&&(e._isEditable?(this._loadingShapes=!0,this._loadingConnections=!0,e.dataSource.fetch(),e.connectionsDataSource.fetch()):e.dataSource.fetch())},_dataSource:function(){var e,t;fe(this.options.connectionsDataSource)?(this._isEditable=!0,e=this.options.dataSource||{},t=pe(e)?{data:e}:e,this.dataSource&&this._shapesRefreshHandler?this.dataSource.unbind("change",this._shapesRefreshHandler).unbind("requestStart",this._shapesRequestStartHandler).unbind("error",this._shapesErrorHandler):(this._shapesRefreshHandler=z(this._refreshShapes,this),this._shapesRequestStartHandler=z(this._shapesRequestStart,this),this._shapesErrorHandler=z(this._error,this)),this.dataSource=kendo.data.DataSource.create(t).bind("change",this._shapesRefreshHandler).bind("requestStart",this._shapesRequestStartHandler).bind("error",this._shapesErrorHandler)):(this._treeDataSource(),this._isEditable=!1)},_connectionDataSource:function(){var e,t=this.options.connectionsDataSource;t&&(e=pe(t)?{data:t}:t,this.connectionsDataSource&&this._connectionsRefreshHandler?this.connectionsDataSource.unbind("change",this._connectionsRefreshHandler).unbind("requestStart",this._connectionsRequestStartHandler).unbind("error",this._connectionsErrorHandler):(this._connectionsRefreshHandler=z(this._refreshConnections,this),this._connectionsRequestStartHandler=z(this._connectionsRequestStart,this),this._connectionsErrorHandler=z(this._connectionsError,this)),this.connectionsDataSource=kendo.data.DataSource.create(e).bind("change",this._connectionsRefreshHandler).bind("requestStart",this._connectionsRequestStartHandler).bind("error",this._connectionsErrorHandler))},_shapesRequestStart:function(e){"read"==e.type&&(this._loadingShapes=!0)},_connectionsRequestStart:function(e){"read"==e.type&&(this._loadingConnections=!0)},_error:function(){this._loadingShapes=!1},_connectionsError:function(){this._loadingConnections=!1},_refreshShapes:function(e){"remove"===e.action?this._shouldRefresh()&&this._removeShapes(e.items):"itemchange"===e.action?this._shouldRefresh()&&this._updateShapes(e.items,e.field):"add"===e.action?this._inactiveShapeItems.add(e.items):"sync"===e.action?this._syncShapes(e.items):this.refresh()},_shouldRefresh:function(){return!this._suspended},_suspendModelRefresh:function(){this._suspended=(this._suspended||0)+1},_resumeModelRefresh:function(){this._suspended=_e.max((this._suspended||0)-1,0)},refresh:function(){this._loadingShapes=!1,this._loadingConnections||this._rebindShapesAndConnections()},_rebindShapesAndConnections:function(){this.clear(),this._addShapes(this.dataSource.view()),this.connectionsDataSource&&this._addConnections(this.connectionsDataSource.view(),!1),this.options.layout&&this.layout(this.options.layout),this._redrawConnections(),this.trigger("dataBound")},refreshConnections:function(){this._loadingConnections=!1,this._loadingShapes||this._rebindShapesAndConnections()},_redrawConnections:function(){var e,t=this.connections;for(e=0;t.length>e;e++)t[e].refresh()},_removeShapes:function(e){var t,n,i=this._dataMap;for(n=0;e.length>n;n++)t=e[n],i[t.id]&&(this.remove(i[t.id],!1),i[t.id]=null)},_syncShapes:function(){var e=this,t=e._inactiveShapeItems;t.forEach(function(n){var i=n.dataItem,r=n.element;i.isNew()||(r?(r._setOptionsFromModel(),e.addShape(r,{undoable:n.undoable}),e._dataMap[i.id]=r):e._addDataItem(i),n.activate(),t.remove(i))})},_updateShapes:function(e,t){var n,i,r;for(n=0;e.length>n;n++)i=e[n],r=this._dataMap[i.id],r&&r.updateOptionsFromModel(i,t)},_addShapes:function(e){for(var t=0;e.length>t;t++)this._addDataItem(e[t],!1)},_refreshConnections:function(e){"remove"===e.action?this._shouldRefresh()&&this._removeConnections(e.items):"add"===e.action?this._addConnections(e.items):"sync"===e.action||("itemchange"===e.action?this._shouldRefresh()&&this._updateConnections(e.items):this.refreshConnections())},_removeConnections:function(e){for(var t=0;e.length>t;t++)this.remove(this._connectionsDataMap[e[t].uid],!1),this._connectionsDataMap[e[t].uid]=null},_updateConnections:function(e){var t,n,i;for(t=0;e.length>t;t++)n=e[t],i=this._connectionsDataMap[n.uid],i.updateOptionsFromModel(n)},_addConnections:function(e,t){var n,i,r=e.length;for(n=0;r>n;n++)i=e[n],this._addConnectionDataItem(i,t)},_addConnectionDataItem:function(e,t){var n,i,r,o;this._connectionsDataMap[e.uid]||(n=this._validateConnector(e.from),fe(n)&&null!==n||(n=new Q(e.fromX,e.fromY)),i=this._validateConnector(e.to),fe(i)&&null!==i||(i=new Q(e.toX,e.toY)),fe(n)&&fe(i)&&(r=B({},this.options.connectionDefaults),r.dataItem=e,o=new y(n,i,r),this._connectionsDataMap[e.uid]=o,this.addConnection(o,t)))},_validateConnector:function(e){var t;return fe(e)&&null!==e&&(t=this._dataMap[e]),t},_treeDataSource:function(){var e=this,t=e.options,n=t.dataSource;n=pe(n)?{data:n}:n,n.fields||(n.fields=[{field:"text"},{field:"url"},{field:"spriteCssClass"},{field:"imageUrl"}]),e.dataSource&&e._refreshHandler&&e._unbindDataSource(),e._refreshHandler=z(e._refreshSource,e),e._errorHandler=z(e._error,e),e.dataSource=H.create(n).bind(ke,e._refreshHandler).bind(Ee,e._errorHandler)},_unbindDataSource:function(){var e=this;e.dataSource.unbind(ke,e._refreshHandler).unbind(Ee,e._errorHandler)},_adorn:function(e,n){n!==t&&e&&(n?(this._adorners.push(e),this.adornerLayer.append(e.visual)):(oe.remove(this._adorners,e),this.adornerLayer.remove(e.visual)))},_showConnectors:function(e,t){t?this._connectorsAdorner.show(e):this._connectorsAdorner.destroy()},_updateAdorners:function(){var e,t,n=this._adorners;for(e=0;n.length>e;e++)t=n[e],t.refreshBounds&&t.refreshBounds(),t.refresh()},_refresh:function(){for(var e=0;this.connections.length>e;e++)this.connections[e].refresh()},_destroyToolBar:function(){this.singleToolBar&&(this.singleToolBar.hide(),this.singleToolBar.destroy(),this.singleToolBar=null)},_destroyGlobalToolBar:function(){this.toolBar&&(this.toolBar.hide(),this.toolBar.destroy(),this.toolBar=null)},exportDOMVisual:function(){var e=this.canvas._viewBox,t=R.transform().translate(-e.x,-e.y),n=new R.Rect([0,0],[e.width,e.height]),i=I.Path.fromRect(n),r=new I.Group({transform:t}),o=new I.Group({clip:i}),a=this.canvas.drawingElement.children[0];return o.append(r),r.children.push(a),o},exportVisual:function(){var e=R.transform().scale(1/this._zoom),t=new I.Group({transform:e}),n=this.mainLayer.drawingElement;return t.children.push(n),t},_syncChanges:function(){this._syncShapeChanges(),this._syncConnectionChanges()},_syncShapeChanges:function(){this.dataSource&&this._isEditable&&this.dataSource.sync()},_syncConnectionChanges:function(){var t=this;t.connectionsDataSource&&t._isEditable&&(e.when.apply(e,t._deferredConnectionUpdates).then(function(){t.connectionsDataSource.sync()}),t.deferredConnectionUpdates=[])}}),E.ExportMixin.extend(k.fn,!0),kendo.PDFMixin&&kendo.PDFMixin.extend(k.fn),x=kendo.Observable.extend({init:function(e,t){kendo.Observable.fn.init.call(this),this.diagram=e,this.options=B({},this.options,t),this._tools=[],this.createToolBar(),this.createTools(),this.appendTools(),this.options.modal&&this.createPopup(),this.bind(this.events,t)},events:["click"],createPopup:function(){this.container=e("
").append(this.element),this._popup=this.container.kendoPopup({}).getKendoPopup()},appendTools:function(){var e,t;for(e=0;this._tools.length>e;e++)t=this._tools[e],(t.buttons&&t.buttons.length||!fe(t.buttons))&&this._toolBar.add(t)},createToolBar:function(){this.element=e("
"),this._toolBar=this.element.kendoToolBar({click:z(this.click,this),resizable:!1}).getKendoToolBar(),this.element.css("border","none")},createTools:function(){for(var e=0;this.options.tools.length>e;e++)this.createTool(this.options.tools[e])},createTool:function(e){var t=(ve(e)?e.name:e)+"Tool";this[t]?this[t](e):this._tools.push(e)},showAt:function(e){this._popup&&this._popup.open(e.x,e.y)},hide:function(){this._popup&&this._popup.close()},newGroup:function(){return{type:"buttonGroup",buttons:[]}},editTool:function(){this._tools.push({spriteCssClass:"k-icon k-i-pencil",showText:"overflow",type:"button",text:"Edit",attributes:this._setAttributes({action:"edit"})})},deleteTool:function(){this._tools.push({spriteCssClass:"k-icon k-i-close",showText:"overflow",type:"button",text:"Delete",attributes:this._setAttributes({action:"delete"})})},rotateAnticlockwiseTool:function(e){this._appendGroup("rotate"),this._rotateGroup.buttons.push({spriteCssClass:"k-icon k-i-rotateccw",showText:"overflow",text:"RotateAnticlockwise",group:"rotate",attributes:this._setAttributes({action:"rotateAnticlockwise",step:e.step})})},rotateClockwiseTool:function(e){this._appendGroup("rotate"),this._rotateGroup.buttons.push({spriteCssClass:"k-icon k-i-rotatecw",attributes:this._setAttributes({action:"rotateClockwise",step:e.step}),showText:"overflow",text:"RotateClockwise",group:"rotate"})},createShapeTool:function(){this._appendGroup("create"),this._createGroup.buttons.push({spriteCssClass:"k-icon k-i-shape",showText:"overflow",text:"CreateShape",group:"create",attributes:this._setAttributes({action:"createShape"})})},createConnectionTool:function(){this._appendGroup("create"),this._createGroup.buttons.push({spriteCssClass:"k-icon k-i-connector",showText:"overflow",text:"CreateConnection",group:"create",attributes:this._setAttributes({action:"createConnection"})})},undoTool:function(){this._appendGroup("history"),this._historyGroup.buttons.push({spriteCssClass:"k-icon k-i-undo",showText:"overflow",text:"Undo",group:"history",attributes:this._setAttributes({action:"undo"})})},redoTool:function(){this._appendGroup("history"),this._historyGroup.buttons.push({spriteCssClass:"k-icon k-i-redo",showText:"overflow",text:"Redo",group:"history",attributes:this._setAttributes({action:"redo"})})},_appendGroup:function(e){var t="_"+e+"Group";this[t]||(this[t]=this.newGroup(),
this._tools.push(this[t]))},_setAttributes:function(e){var t={};return e.action&&(t[kendo.attr("action")]=e.action),e.step&&(t[kendo.attr("step")]=e.step),t},_getAttributes:function(e){var t,n={},i=e.attr(kendo.attr("action"));return i&&(n.action=i),t=e.attr(kendo.attr("step")),t&&(n.step=t),n},click:function(t){var n=this._getAttributes(e(t.target)),i=n.action;i&&this[i](n),this.trigger("click",this.eventData(i))},eventData:function(e){var t=this.selectedElements(),n=[],i=[];return t instanceof w?n.push(t):i.push(t),{shapes:n,connections:i,action:e}},"delete":function(){var e=this.diagram,t=e._triggerRemove(this.selectedElements());t.length&&(this.diagram.remove(t,!0),this.diagram._syncChanges())},edit:function(){this.diagram.edit(this.selectedElements()[0])},rotateClockwise:function(e){var t=parseFloat(e.step||90);this._rotate(t)},rotateAnticlockwise:function(e){var t=parseFloat(e.step||90);this._rotate(-t)},_rotate:function(e){var t=this.diagram._resizingAdorner;t.angle(t.angle()+e),t.rotate()},selectedElements:function(){return this.diagram.select()},createShape:function(){this.diagram.createShape()},createConnection:function(){this.diagram.createConnection()},undo:function(){this.diagram.undo()},redo:function(){this.diagram.redo()},destroy:function(){this.diagram=null,this.element=null,this.options=null,this._toolBar&&this._toolBar.destroy(),this._popup&&this._popup.destroy()}}),C=kendo.Observable.extend({init:function(e,t){kendo.Observable.fn.init.call(this),this.options=L(!0,{},this.options,t),this.element=e,this.model=this.options.model,this.fields=this._getFields(),this._initContainer(),this.createEditable()},options:{editors:{}},_initContainer:function(){this.wrapper=this.element},createEditable:function(){var e=this.options;this.editable=new kendo.ui.Editable(this.wrapper,{fields:this.fields,target:e.target,clearContainer:!1,model:this.model})},_isEditable:function(e){return this.model.editable&&this.model.editable(e)},_getFields:function(){var e,t,n,i=[],r=this.model.fields;for(e in r)t={},this._isEditable(e)&&(n=this.options.editors[e],n&&(t.editor=n),t.field=e,i.push(t));return i},end:function(){return this.editable.end()},destroy:function(){this.editable.destroy(),this.editable.element.find("["+kendo.attr("container-for")+"]").empty(),this.model=this.wrapper=this.element=this.columns=this.editable=null}}),S=C.extend({init:function(e,t){C.fn.init.call(this,e,t),this.bind(this.events,this.options),this.open()},events:["update","cancel"],options:{window:{modal:!0,resizable:!1,draggable:!0,title:"Edit",visible:!1}},_initContainer:function(){var t,n=this;this.wrapper=e('').attr(kendo.attr("uid"),this.model.uid),t="",this.options.template?(t+=this._renderTemplate(),this.fields=[]):t+=this._renderFields(),t+=this._renderButtons(),this.wrapper.append(e('
').append(t)),this.window=new kendo.ui.Window(this.wrapper,this.options.window),this.window.bind("close",function(e){e.userTriggered&&(e.sender.element.focus(),n._cancelClick(e))}),this._attachButtonEvents()},_renderTemplate:function(){var e=this.options.template;return"string"==typeof e&&(e=window.unescape(e)),e=kendo.template(e)(this.model)},_renderFields:function(){var e,t,n="";for(e=0;this.fields.length>e;e++)t=this.fields[e],n+=''+(t.field||"")+"
",this._isEditable(t.field)&&(n+="
');return n},_renderButtons:function(){var e='';return e+=this._createButton("update"),e+=this._createButton("cancel"),e+="
"},_createButton:function(e){return kendo.template(dt)(v[e])},_attachButtonEvents:function(){this._cancelClickHandler=z(this._cancelClick,this),this.window.element.on(xe+be,"a.k-diagram-cancel",this._cancelClickHandler),this._updateClickHandler=z(this._updateClick,this),this.window.element.on(xe+be,"a.k-diagram-update",this._updateClickHandler)},_updateClick:function(e){e.preventDefault(),this.trigger("update")},_cancelClick:function(e){e.preventDefault(),this.trigger("cancel")},open:function(){this.window.center().open()},close:function(){this.window.bind("deactivate",z(this.destroy,this)).close()},destroy:function(){this.window.close().destroy(),this.window.element.off(xe+be,"a.k-diagram-cancel",this._cancelClickHandler),this.window.element.off(xe+be,"a.k-diagram-update",this._updateClickHandler),this._cancelClickHandler=null,this._editUpdateClickHandler=null,this.window=null,C.fn.destroy.call(this)}}),d.fn=d.prototype={onActivate:function(t){var n=e.Deferred();return this.callbacks.push({callback:t,deferred:n}),n},activate:function(){var e,t,n=this.callbacks;for(t=0;n.length>t;t++)e=this.callbacks[t],e.callback(this.dataItem),e.deferred.resolve();this.callbacks=[]}},u.fn=u.prototype={add:function(e){for(var t=0;e.length>t;t++)this.items[e[t].uid]=new d(e[t])},forEach:function(e){for(var t in this.items)e(this.items[t])},getByUid:function(e){return this.items[e]},remove:function(e){delete this.items[e.uid]}},T=P.extend({init:function(){this.shapes=[]},_add:function(e,t){this.shapes.push({bounds:t,shape:e}),e._quadNode=this},insert:function(e,t){this._add(e,t)},remove:function(e){var t,n=this.shapes,i=n.length;for(t=0;i>t;t++)if(n[t].shape===e){n.splice(t,1);break}},hitTestRect:function(e){var t,n=this.shapes,i=n.length;for(t=0;i>t;t++)if(this._testRect(n[t].shape,e))return!0},_testRect:function(e,t){var n=e.rotate().angle;return X.rects(t,e.bounds(),-n)},_overlaps:function(e,t){var n=e.bottomRight(),i=t.bottomRight(),r=!(t.x>n.x||t.y>n.y||e.x>i.x||e.y>i.y);return r}}),D=T.extend({init:function(e){T.fn.init.call(this),this.children=[],this.rect=e},inBounds:function(e){var t=this.rect,n=t.bottomRight(),i=e.bottomRight(),r=e.x>=t.x&&e.y>=t.y&&n.x>=i.x&&n.y>=i.y;return r},overlapsBounds:function(e){return this._overlaps(this.rect,e)},insert:function(e,t){var n,i=!1,r=this.children,o=r.length;if(this.inBounds(t)){if(!o&&4>this.shapes.length)this._add(e,t);else{for(o||this._initChildren(),n=0;r.length>n;n++)if(r[n].insert(e,t)){i=!0;break}i||this._add(e,t)}i=!0}return i},_initChildren:function(){var e,t,n=this.rect,i=this.children,r=this.shapes,o=n.center(),a=n.width/2,s=n.height/2;for(i.push(new D(new j(n.x,n.y,a,s)),new D(new j(o.x,n.y,a,s)),new D(new j(n.x,o.y,a,s)),new D(new j(o.x,o.y,a,s))),t=r.length-1;t>=0;t--)for(e=0;i.length>e;e++)if(i[e].insert(r[t].shape,r[t].bounds)){r.splice(t,1);break}},hitTestRect:function(e){var t,n=this.children,i=n.length,r=!1;if(this.overlapsBounds(e))if(T.fn.hitTestRect.call(this,e))r=!0;else for(t=0;i>t;t++)if(n[t].hitTestRect(e)){r=!0;break}return r}}),A=P.extend({ROOT_SIZE:1e3,init:function(e){e.bind(ye,z(this._boundsChange,this)),e.bind(Le,z(this._boundsChange,this)),this.initRoots()},initRoots:function(){this.rootMap={},this.root=new T},clear:function(){this.initRoots()},_boundsChange:function(e){e.item._quadNode&&(e.item._quadNode.remove(e.item),this.insert(e.item))},insert:function(e){var t=e.bounds(tt),n=this.ROOT_SIZE,i=this.getSectors(t),r=i[0][0],o=i[1][0];this.inRoot(i)?this.root.insert(e,t):(this.rootMap[r]||(this.rootMap[r]={}),this.rootMap[r][o]||(this.rootMap[r][o]=new D(new j(r*n,o*n,n,n))),this.rootMap[r][o].insert(e,t))},remove:function(e){e._quadNode&&e._quadNode.remove(e)},inRoot:function(e){return e[0].length>1||e[1].length>1},getSectors:function(e){var t,n,i=this.ROOT_SIZE,r=e.bottomRight(),o=_e.floor(r.x/i),a=_e.floor(r.y/i),s=[[],[]];for(t=_e.floor(e.x/i);o>=t;t++)s[0].push(t);for(n=_e.floor(e.y/i);a>=n;n++)s[1].push(n);return s},hitTestRect:function(e){var t,n,i,r,o,a=this.getSectors(e);if(this.root.hitTestRect(e))return!0;for(t=0;a[0].length>t;t++)for(i=a[0][t],n=0;a[1].length>n;n++)if(r=a[1][n],o=(this.rootMap[i]||{})[r],o&&o.hitTestRect(e))return!0;return!1}}),E.ui.plugin(k),B(M,{Shape:w,Connection:y,Connector:b,DiagramToolBar:x,QuadNode:D,QuadRoot:T,ShapesQuadTree:A})}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e,t){if(null===t)return t;var n=y(e,!0);return n(t)}function i(e){return typeof e!==I}function r(e,t,n){var i,r,l=s(e),c=s(t),d=u(e)-u(t)<0,h=[];for(h.push(e),i=0;n>i;i++)r={r:o(l.r,c.r,i,n,d),g:o(l.g,c.g,i,n,d),b:o(l.b,c.b,i,n,d)},h.push(a(r));return h.push(t),h}function o(e,t,n,i,r){var o,a=f.min(f.abs(e),f.abs(t)),s=f.max(f.abs(e),f.abs(t)),l=(s-a)/(i+1),c=l*(n+1);return o=r?a+c:s-c}function a(e){return"#"+l(e.r)+l(e.g)+l(e.b)}function s(e){e=e.replace("#","");var t=c(e);return{r:d(t.r),g:d(t.g),b:d(t.b)}}function l(e){var t=f.round(e).toString(16).toUpperCase();return 1===t.length&&(t="0"+t),t}function c(e){var t=e.length,n={};return 3===t?(n.r=e[0],n.g=e[1],n.b=e[2]):(n.r=e.substring(0,2),n.g=e.substring(2,4),n.b=e.substring(4,6)),n}function d(e){return parseInt(e.toString(16),16)}function u(e){var t=0;return e&&(e=s(e),t=f.sqrt(.241*e.r*e.r+.691*e.g*e.g+.068*e.b*e.b)),t}function h(e){var t=f.pow(10,4);return f.round(e*t)/t}var f=Math,p=e.proxy,g=window.kendo,m=g.Class,v=g.ui.Widget,_=g.template,b=g.deepExtend,w=g.data.HierarchicalDataSource,y=g.getter,k=g.dataviz,x=".kendoTreeMap",C="change",S="dataBound",T="itemCreated",D=Number.MAX_VALUE,A="mouseover"+x,E="mouseleave"+x,I="undefined",R=v.extend({init:function(t,n){g.destroy(t),e(t).empty(),v.fn.init.call(this,t,n),this.wrapper=this.element,this._initTheme(this.options),this.element.addClass("k-widget k-treemap"),this._setLayout(),this._originalOptions=b({},this.options),this._initDataSource(),this._attachEvents(),g.notify(this,k.ui)},options:{name:"TreeMap",theme:"default",autoBind:!0,textField:"text",valueField:"value",colorField:"color"},events:[S,T],_initTheme:function(e){var t=this,n=k.ui.themes||{},i=((e||{}).theme||"").toLowerCase(),r=(n[i]||{}).treeMap;t.options=b({},r,e)},_attachEvents:function(){this.element.on(A,p(this._mouseover,this)).on(E,p(this._mouseleave,this))},_setLayout:function(){"horizontal"===this.options.type?(this._layout=new P(!1),this._view=new z(this,this.options)):"vertical"===this.options.type?(this._layout=new P(!0),this._view=new z(this,this.options)):(this._layout=new M,this._view=new F(this,this.options))},_initDataSource:function(){var e=this,t=e.options,n=t.dataSource;e._dataChangeHandler=p(e._onDataChange,e),e.dataSource=w.create(n).bind(C,e._dataChangeHandler),n&&e.options.autoBind&&e.dataSource.fetch()},setDataSource:function(e){var t=this;t.dataSource.unbind(C,t._dataChangeHandler),t.dataSource=e.bind(C,t._dataChangeHandler),e&&t.options.autoBind&&t.dataSource.fetch()},_onDataChange:function(e){var t,n,o,a,s,l,c=e.node,d=e.items,u=this.options;if(c){if(d.length){for(a=this._getByUid(c.uid),a.children=[],o=i(a.minColor)||i(a.maxColor)?r(a.minColor,a.maxColor,d.length)||[]:u.colors||[],n=0;d.length>n;n++)t=d[n],a.children.push(this._wrapItem(t));for(s=this._view.htmlSize(a),this._layout.compute(a.children,a.coord,s),n=0;a.children.length>n;n++)t=a.children[n],i(t.color)||("string"==typeof o[0]?t.color=o[n%o.length]:(l=o[n%o.length],l&&(t.color=l[0],t.minColor=l[0],t.maxColor=l[1])));this._view.render(a)}}else this.element.empty(),t=this._wrapItem(d[0]),this._layout.createRoot(t,this.element.outerWidth(),this.element.outerHeight(),"vertical"===this.options.type),this._view.createRoot(t),this._root=t;for(n=0;d.length>n;n++)d[n].load();c&&this.trigger(S,{node:c})},_contentSize:function(e){this.view.renderHeight(e)},_wrapItem:function(e){var t={};return i(this.options.valueField)&&(t.value=n(this.options.valueField,e)),i(this.options.colorField)&&(t.color=n(this.options.colorField,e)),i(this.options.textField)&&(t.text=n(this.options.textField,e)),t.level=e.level(),t.dataItem=e,t},_getByUid:function(e){for(var t,n=[this._root];n.length;){if(t=n.pop(),t.dataItem.uid===e)return t;t.children&&(n=n.concat(t.children))}},dataItem:function(t){var n=e(t).attr(g.attr("uid")),i=this.dataSource;return i&&i.getByUid(n)},findByUid:function(e){return this.element.find(".k-treemap-tile["+g.attr("uid")+"='"+e+"']")},_mouseover:function(t){var n=e(t.target);n.hasClass("k-leaf")&&(this._removeActiveState(),n.removeClass("k-state-hover").addClass("k-state-hover"))},_removeActiveState:function(){this.element.find(".k-state-hover").removeClass("k-state-hover")},_mouseleave:function(){this._removeActiveState()},destroy:function(){v.fn.destroy.call(this),this.element.off(x),this.dataSource&&this.dataSource.unbind(C,this._dataChangeHandler),this._root=null,g.destroy(this.element)},items:function(){return e()},getSize:function(){return g.dimensions(this.element)},_resize:function(){this.dataSource.fetch()},setOptions:function(e){var n=e.dataSource;e.dataSource=t,this._originalOptions=b(this._originalOptions,e),this.options=b({},this._originalOptions),this._setLayout(),this._initTheme(this.options),v.fn._setEvents.call(this,e),n&&this.setDataSource(w.create(n)),this.options.autoBind&&this.dataSource.fetch()}}),M=m.extend({createRoot:function(e,t,n){e.coord={width:t,height:n,top:0,left:0}},leaf:function(e){return!e.children},layoutChildren:function(e,t){var n,i,r,o,a=t.width*t.height,s=0,l=[];for(n=0;e.length>n;n++)l[n]=parseFloat(e[n].value),s+=l[n];for(n=0;l.length>n;n++)e[n].area=a*l[n]/s;i=this.layoutHorizontal()?t.height:t.width,e=new g.data.Query(e)._sortForGrouping("value","desc"),r=[e[0]],o=e.slice(1),this.squarify(o,r,i,t)},squarify:function(e,t,n,i){this.computeDim(e,t,n,i)},computeDim:function(e,n,i,r){var o,a,s;return e.length+n.length==1?(o=1==e.length?e:n,this.layoutLast(o,i,r),t):(e.length>=2&&0===n.length&&(n=[e[0]],e=e.slice(1)),0===e.length?(n.length>0&&this.layoutRow(n,i,r),t):(a=e[0],this.worstAspectRatio(n,i)>=this.worstAspectRatio([a].concat(n),i)?this.computeDim(e.slice(1),n.concat([a]),i,r):(s=this.layoutRow(n,i,r),this.computeDim(e,[],s.dim,s)),t))},layoutLast:function(e,t,n){e[0].coord=n},layoutRow:function(e,t,n){return this.layoutHorizontal()?this.layoutV(e,t,n):this.layoutH(e,t,n)},orientation:"h",layoutVertical:function(){return"v"===this.orientation},layoutHorizontal:function(){return"h"===this.orientation},layoutChange:function(){this.orientation=this.layoutVertical()?"h":"v"},worstAspectRatio:function(e,t){var n,i,r,o,a;if(!e||0===e.length)return D;for(n=0,i=0,r=D,o=0;e.length>o;o++)a=e[o].area,n+=a,r=a>r?r:a,i=i>a?i:a;return f.max(t*t*i/(n*n),n*n/(t*t*r))},compute:function(e,t,n){if(t.width>=t.height&&this.layoutHorizontal()||this.layoutChange(),e&&e.length>0){var i={width:t.width,height:t.height-n.text,top:0,left:0};this.layoutChildren(e,i)}},layoutV:function(e,t,n){var i,r,o,a=this._totalArea(e),s=0;for(t=h(a/t),i=0;e.length>i;i++)r=h(e[i].area/t),e[i].coord={height:r,width:t,top:n.top+s,left:n.left},s+=r;return o={height:n.height,width:n.width-t,top:n.top,left:n.left+t},o.dim=f.min(o.width,o.height),o.dim!=o.height&&this.layoutChange(),o},layoutH:function(e,t,n){var i,r,o=this._totalArea(e),a=h(o/t),s=n.top,l=0;for(i=0;e.length>i;i++)e[i].coord={height:a,width:h(e[i].area/a),top:s,left:n.left+l},l+=e[i].coord.width;return r={height:n.height-a,width:n.width,top:n.top+a,left:n.left},r.dim=f.min(r.width,r.height),r.dim!=r.width&&this.layoutChange(),r},_totalArea:function(e){var t,n=0;for(t=0;e.length>t;t++)n+=e[t].area;return n}}),F=m.extend({init:function(t,n){this.options=b({},this.options,n),this.treeMap=t,this.element=e(t.element),this.offset=0},htmlSize:function(e){var t,n,i=this._getByUid(e.dataItem.uid),r={text:0};return e.children&&(this._clean(i),t=this._getText(e),t&&(n=this._createTitle(e),i.append(n),r.text=n.height()),i.append(this._createWrap()),this.offset=(i.outerWidth()-i.innerWidth())/2),r},_getByUid:function(e){return this.element.find(".k-treemap-tile["+g.attr("uid")+"='"+e+"']")},render:function(e){var t,n,i,r,o=this._getByUid(e.dataItem.uid),a=e.children;if(a)for(t=o.find(".k-treemap-wrap"),n=0;a.length>n;n++)i=a[n],r=this._createLeaf(i),t.append(r),this.treeMap.trigger(T,{element:r})},createRoot:function(e){var t=this._createLeaf(e);this.element.append(t),this.treeMap.trigger(T,{element:t})},_clean:function(e){e.css("background-color",""),e.removeClass("k-leaf"),e.removeClass("k-inverse"),e.empty()},_createLeaf:function(t){return this._createTile(t).css("background-color",t.color).addClass("k-leaf").toggleClass("k-inverse",this._tileColorBrightness(t)>180).append(e("
").html(this._getText(t)))},_createTile:function(t){var n,r={width:t.coord.width,height:t.coord.height,left:t.coord.left,top:t.coord.top};return r.width+=r.left&&this.offset?2*this.offset:this.offset,r.height+=r.top?2*this.offset:this.offset,n=e("
").css({width:r.width,height:r.height,left:r.left,top:r.top}),i(t.dataItem)&&i(t.dataItem.uid)&&n.attr(g.attr("uid"),t.dataItem.uid),n},_getText:function(e){var t=e.text;return this.options.template&&(t=this._renderTemplate(e)),t},_renderTemplate:function(e){var t=_(this.options.template);return t({dataItem:e.dataItem,text:e.text})},_createTitle:function(t){return e("
").append(e("
").html(this._getText(t)))},_createWrap:function(){return e("
")},_tileColorBrightness:function(e){return u(e.color)}}),P=m.extend({createRoot:function(e,t,n,i){e.coord={width:t,height:n,top:0,left:0},e.vertical=i},init:function(e){this.vertical=e,this.quotient=e?1:0},compute:function(e,t,n){var i,r,o;e.length>0&&(i=t.width,r=t.height,this.vertical?r-=n.text:i-=n.text,o={width:i,height:r,top:0,left:0},this.layoutChildren(e,o))},layoutChildren:function(e,t){var n,i,r=t.width*t.height,o=0,a=[];for(n=0;e.length>n;n++)i=e[n],a[n]=parseFloat(e[n].value),o+=a[n],i.vertical=this.vertical;for(n=0;a.length>n;n++)e[n].area=r*a[n]/o;e=new g.data.Query(e)._sortForGrouping("value","desc"),this.sliceAndDice(e,t)},sliceAndDice:function(e,t){var n=this._totalArea(e);e[0].level%2===this.quotient?this.layoutHorizontal(e,t,n):this.layoutVertical(e,t,n)},layoutHorizontal:function(e,t,n){var i,r,o,a=0;for(i=0;e.length>i;i++)r=e[i],o=r.area/(n/t.width),r.coord={height:t.height,width:o,top:t.top,left:t.left+a},a+=o},layoutVertical:function(e,t,n){var i,r,o,a=0;for(i=0;e.length>i;i++)r=e[i],o=r.area/(n/t.height),r.coord={height:o,width:t.width,top:t.top+a,left:t.left},a+=o},_totalArea:function(e){var t,n=0;for(t=0;e.length>t;t++)n+=e[t].area;return n}}),z=F.extend({htmlSize:function(e){var t,n,i=this._getByUid(e.dataItem.uid),r={text:0,offset:0};return e.children&&(this._clean(i),t=this._getText(e),t&&(n=this._createTitle(e),i.append(n),r.text=e.vertical?n.height():n.width()),i.append(this._createWrap()),this.offset=(i.outerWidth()-i.innerWidth())/2),r},_createTitle:function(t){var n;return n=e(t.vertical?"
":"
"),n.append(e("
").html(this._getText(t)))}});k.ui.plugin(R)}(window.kendo.jQuery)}(),function(){"bundle all"}(),function(){!function(e){var t=window.kendo,n=t.mobile.ui,i=n.Shim,r=n.Widget,o="beforeOpen",a="open",s="close",l="init",c='
',d=n.View.extend({init:function(e,t){var n=this;r.fn.init.call(n,e,t),n._id(),n._wrap(),n._shim(),this.options.$angular||(n._layout(),n._scroller(),n._model()),n.element.css("display",""),n.trigger(l)},events:[l,o,a,s],options:{name:"ModalView",modal:!0,width:null,height:null},destroy:function(){r.fn.destroy.call(this),this.shim.destroy()},open:function(t){var n=this;n.target=e(t),n.shim.show(),n._invokeNgController(),n.trigger("show",{view:n})},openFor:function(e){this.trigger(o,{target:e})||(this.open(e),this.trigger(a,{target:e}))},close:function(){this.element.is(":visible")&&!this.trigger(s)&&this.shim.hide()},_wrap:function(){var e,t,n=this,i=n.element,r=n.options;e=i[0].style.width||"auto",t=i[0].style.height||"auto",i.addClass("km-modalview").wrap(c),n.wrapper=i.parent().css({width:r.width||e||300,height:r.height||t||300}).addClass("auto"==t?" km-auto-height":""),i.css({width:"",height:""})},_shim:function(){var e=this;e.shim=new i(e.wrapper,{modal:e.options.modal,position:"center center",align:"center center",effect:"fade:in",className:"km-modalview-root",hide:function(t){e.trigger(s)&&t.preventDefault()}})}});n.plugin(d)}(window.kendo.jQuery)}(),function(){!function(e,t){var n=window.kendo,i=n.mobile,r=n.support.mobileOS,o=n.effects.Transition,a=n.roleSelector,s="x",l=i.ui,c=!(r.ios&&7==r.majorVersion&&!r.appMode),d="beforeShow",u="init",h="show",f="hide",p="afterHide",g={enable:e.noop},m=l.View.extend({init:function(t,r){var o,s,l,d,h;if(e(t).parent().prepend(t),i.ui.Widget.fn.init.call(this,t,r),this.options.$angular||(this._layout(),this._scroller()),this._model(),o=this.element.closest(a("pane")).data("kendoMobilePane"))this.pane=o,this.pane.bind("viewShow",function(e){d._viewShow(e)}),this.pane.bind("sameViewRequested",function(){d.hide()}),s=this.userEvents=new n.UserEvents(o.element,{filter:a("view splitview"),allowSelection:!0});else{if(this.currentView=g,l=e(this.options.container),!l)throw Error("The drawer needs a container configuration option set.");s=this.userEvents=new n.UserEvents(l,{allowSelection:!0}),this._attachTransition(l)}d=this,h=function(e){d.visible&&(d.hide(),e.preventDefault())},this.options.swipeToOpen&&c?(s.bind("press",function(){d.transition.cancel()}),s.bind("start",function(e){d._start(e)}),s.bind("move",function(e){d._update(e)}),s.bind("end",function(e){d._end(e)}),s.bind("tap",h)):s.bind("press",h),this.leftPositioned="left"===this.options.position,this.visible=!1,this.element.hide().addClass("km-drawer").addClass(this.leftPositioned?"km-left-drawer":"km-right-drawer"),this.trigger(u)},options:{name:"Drawer",position:"left",views:[],swipeToOpenViews:[],swipeToOpen:!0,title:"",container:null},events:[d,f,p,u,h],show:function(){this._activate()&&this._show()},hide:function(){this.currentView&&(this.currentView.enable(),m.current=null,this._moveViewTo(0),this.trigger(f,{view:this}))},openFor:function(){this.visible?this.hide():this.show()},destroy:function(){l.View.fn.destroy.call(this),this.userEvents.destroy()},_activate:function(){if(this.visible)return!0;var e=this._currentViewIncludedIn(this.options.views);return!e||this.trigger(d,{view:this})?!1:(this._setAsCurrent(),this.element.show(),this.trigger(h,{view:this}),this._invokeNgController(),!0)},_currentViewIncludedIn:function(t){if(!this.pane||!t.length)return!0;var n=this.pane.view();return e.inArray(n.id.replace("#",""),t)>-1||e.inArray(n.element.attr("id"),t)>-1},_show:function(){this.currentView.enable(!1),this.visible=!0;var e=this.element.width();this.leftPositioned||(e=-e),this._moveViewTo(e)},_setAsCurrent:function(){m.last!==this&&(m.last&&m.last.element.hide(),this.element.show()),m.last=this,m.current=this},_moveViewTo:function(e){this.userEvents.cancel(),this.transition.moveTo({location:e,duration:400,ease:o.easeOutExpo})},_viewShow:function(e){return this.currentView&&this.currentView.enable(),this.currentView===e.view?(this.hide(),t):(this.currentView=e.view,this._attachTransition(e.view.element),t)},_attachTransition:function(e){var t=this,i=this.movable,r=i&&i.x;this.transition&&(this.transition.cancel(),this.movable.moveAxis("x",0)),i=this.movable=new n.ui.Movable(e),this.transition=new o({axis:s,movable:this.movable,onEnd:function(){0===i[s]&&(e[0].style.cssText="",t.element.hide(),t.trigger(p),t.visible=!1)}}),r&&(e.addClass("k-fx-hidden"),n.animationFrame(function(){e.removeClass("k-fx-hidden"),t.movable.moveAxis(s,r),t.hide()}))},_start:function(e){var i,r,o,a,s,l=e.sender;return Math.abs(e.x.velocity)e.x.velocity,(o&&s||a&&!s)&&this._activate()?(l.capture(),t):(l.cancel(),t))},_update:function(e){var t,n=this.movable,i=n.x+e.x.delta;t=this.leftPositioned?Math.min(Math.max(0,i),this.element.width()):Math.max(Math.min(0,i),-this.element.width()),this.movable.moveAxis(s,t),e.event.preventDefault(),e.event.stopPropagation()},_end:function(e){var t,n=e.x.velocity,i=Math.abs(this.movable.x)>this.element.width()/2,r=.8;t=this.leftPositioned?n>-r&&(n>r||i):r>n&&(-r>n||i),t?this._show():this.hide()}});l.plugin(m)}(window.kendo.jQuery)}(),function(){!function(e){var t=window.kendo,n=t.mobile.ui,i=n.Widget,r="
",o=n.View,a=o.extend({init:function(o,a){var s,l,c=this;i.fn.init.call(c,o,a),o=c.element,e.extend(c,a),c._id(),c.options.$angular?c._overlay():(c._layout(),c._overlay()),c._style(),l=o.children(c._locate("modalview")),c.options.$angular?l.each(function(n,i){t.compileMobileDirective(e(i),a.$angular[0])}):t.mobile.init(l),c.panes=[],c._paramsHistory=[],c.options.$angular?(c.element.children(t.directiveSelector("pane")).each(function(){s=t.compileMobileDirective(e(this),a.$angular[0]),c.panes.push(s)}),c.element.children(t.directiveSelector("header footer")).each(function(){t.compileMobileDirective(e(this),a.$angular[0])})):c.content.children(t.roleSelector("pane")).each(function(){s=t.initWidget(this,{},n.roles),c.panes.push(s)}),c.expandedPaneShim=e(r).appendTo(c.element),c._shimUserEvents=new t.UserEvents(c.expandedPaneShim,{tap:function(){c.collapsePanes()}})},_locate:function(e){return this.options.$angular?t.directiveSelector(e):t.roleSelector(e)},options:{name:"SplitView",style:"horizontal"},expandPanes:function(){this.element.addClass("km-expanded-splitview")},collapsePanes:function(){this.element.removeClass("km-expanded-splitview")},_layout:function(){var e=this,n=e.element;e.transition=t.attrValue(n,"transition"),t.mobile.ui.View.prototype._layout.call(this),t.mobile.init(this.header.add(this.footer)),e.element.addClass("km-splitview"),e.content.addClass("km-split-content")},_style:function(){var t,n=this.options.style,i=this.element;n&&(t=n.split(" "),e.each(t,function(){i.addClass("km-split-"+this)}))},showStart:function(){var t=this;t.element.css("display",""),t.inited?this._invokeNgController():(t.inited=!0,e.each(t.panes,function(){this.options.initial?this.navigateToInitial():this.navigate("")}),t.trigger("init",{view:t})),t.trigger("show",{view:t})}});n.plugin(a)}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e,t){var n=[];return p&&n.push("km-on-"+p.name),n.push(e.skin?"km-"+e.skin:"ios"==e.name&&e.majorVersion>6?"km-ios7":"km-"+e.name),("ios"==e.name&&7>e.majorVersion||"ios"!=e.name)&&n.push("km-"+e.name+e.majorVersion),n.push("km-"+e.majorVersion),n.push("km-m"+(e.minorVersion?e.minorVersion[0]:0)),e.variant&&(e.skin&&e.skin===e.name||!e.skin||e.setDefaultPlatform===!1)&&n.push("km-"+(e.skin?e.skin:e.name)+"-"+e.variant),e.cordova&&n.push("km-cordova"),n.push(e.appMode?"km-app":"km-web"),t&&t.statusBarStyle&&n.push("km-"+t.statusBarStyle+"-status-bar"),n.join(" ")}function i(t){return"km-wp-"+(t.noVariantSet?0===parseInt(e("
").css("background-color").split(",")[1],10)?"dark":"light":t.variant+" km-wp-"+t.variant+"-force")}function r(e){return p.wp?"-kendo-landscape"==e.css("animation-name"):Math.abs(window.orientation)/90==1}function o(e){return r(e)?y:v}function a(e){e.parent().addBack().css("min-height",window.innerHeight)}function s(){e("meta[name=viewport]").remove(),z.append(x({height:", width=device-width"+(r()?", height="+window.innerHeight+"px":d.mobileOS.flatVersion>=600&&700>d.mobileOS.flatVersion?", height="+window.innerWidth+"px":", height=device-height")}))}var l=window.kendo,c=l.mobile,d=l.support,u=c.ui.Widget,h=c.ui.Pane,f="ios7",p=d.mobileOS,g="blackberry"==p.device&&p.flatVersion>=600&&1e3>p.flatVersion&&p.appMode,m=.93,v="km-vertical",_="chrome"===p.browser,b=p.ios&&p.flatVersion>=700&&800>p.flatVersion&&(p.appMode||_),w=Math.abs(window.orientation)/90==1,y="km-horizontal",k={ios7:{ios:!0,browser:"default",device:"iphone",flatVersion:"700",majorVersion:"7",minorVersion:"0.0",name:"ios",tablet:!1},ios:{ios:!0,browser:"default",device:"iphone",flatVersion:"612",majorVersion:"6",minorVersion:"1.2",name:"ios",tablet:!1},android:{android:!0,browser:"default",device:"android",flatVersion:"442",majorVersion:"4",minorVersion:"4.2",name:"android",tablet:!1},blackberry:{blackberry:!0,browser:"default",device:"blackberry",flatVersion:"710",majorVersion:"7",minorVersion:"1.0",name:"blackberry",tablet:!1},meego:{meego:!0,browser:"default",device:"meego",flatVersion:"850",majorVersion:"8",minorVersion:"5.0",name:"meego",tablet:!1},wp:{wp:!0,browser:"default",device:"wp",flatVersion:"800",majorVersion:"8",minorVersion:"0.0",name:"wp",tablet:!1}},x=l.template(' ',{usedWithBlock:!1}),C=l.template(' ',{usedWithBlock:!1}),S=l.template("",{usedWithBlock:!1}),T=p.android&&"chrome"!=p.browser||p.blackberry,D=l.template(' ',{usedWithBlock:!1}),A=("iphone"==p.device||"ipod"==p.device)&&7>p.majorVersion,E=("iphone"==p.device||"ipod"==p.device)&&p.majorVersion>=7,I=E?"none":null,R="mobilesafari"==p.browser?60:0,M=20,F=e(window),P=window.screen,z=e("head"),B="init",L=e.proxy,H=u.extend({init:function(t,n){c.application=this,e(e.proxy(this,"bootstrap",t,n))},bootstrap:function(t,n){var i,r,o;t=e(t),t[0]||(t=e(document.body)),u.fn.init.call(this,t,n),this.element.removeAttr("data-"+l.ns+"role"),this._setupPlatform(),this._attachMeta(),this._setupElementClass(),this._attachHideBarHandlers(),i=e.extend({},this.options),delete i.name,r=this,o=function(){r.pane=new h(r.element,i),r.pane.navigateToInitial(),r.options.updateDocumentTitle&&r._setupDocumentTitle(),r._startHistory(),r.trigger(B)},this.options.$angular?setTimeout(o):o()},options:{name:"Application",hideAddressBar:!0,browserHistory:!0,historyTransition:I,modelScope:window,statusBarStyle:"black",transition:"",retina:!1,platform:null,skin:null,updateDocumentTitle:!0,useNativeScrolling:!1},events:[B],navigate:function(e,t){this.pane.navigate(e,t)},replace:function(e,t){this.pane.replace(e,t)},scroller:function(){return this.view().scroller},hideLoading:function(){if(!this.pane)throw Error("The mobile application instance is not fully instantiated. Please consider activating loading in the application init event handler.");this.pane.hideLoading()},showLoading:function(){if(!this.pane)throw Error("The mobile application instance is not fully instantiated. Please consider activating loading in the application init event handler.");this.pane.showLoading()},changeLoadingMessage:function(e){if(!this.pane)throw Error("The mobile application instance is not fully instantiated. Please consider changing the message in the application init event handler.");this.pane.changeLoadingMessage(e)},view:function(){return this.pane.view()},skin:function(e){var t=this;return arguments.length?(t.options.skin=e||"",t.element[0].className="km-pane",t._setupPlatform(),t._setupElementClass(),t.options.skin):t.options.skin},destroy:function(){u.fn.destroy.call(this),this.pane.destroy(),this.router.destroy()},_setupPlatform:function(){var t=this,r=t.options.platform,o=t.options.skin,a=[],s=p||k[f];r&&(s.setDefaultPlatform=!0,"string"==typeof r?(a=r.split("-"),s=e.extend({variant:a[1]},s,k[a[0]])):s=r),o&&(a=o.split("-"),p||(s.setDefaultPlatform=!1),s=e.extend({},s,{skin:a[0],variant:a[1]})),s.variant||(s.noVariantSet=!0,s.variant="dark"),t.os=s,t.osCssClass=n(t.os,t.options),"wp"==s.name&&(t.refreshBackgroundColorProxy||(t.refreshBackgroundColorProxy=e.proxy(function(){(t.os.variant&&t.os.skin&&t.os.skin===t.os.name||!t.os.skin)&&t.element.removeClass("km-wp-dark km-wp-light km-wp-dark-force km-wp-light-force").addClass(i(t.os));
},t)),e(document).off("visibilitychange",t.refreshBackgroundColorProxy),e(document).off("resume",t.refreshBackgroundColorProxy),s.skin||(t.element.parent().css("overflow","hidden"),e(document).on("visibilitychange",t.refreshBackgroundColorProxy),e(document).on("resume",t.refreshBackgroundColorProxy),t.refreshBackgroundColorProxy()))},_startHistory:function(){this.options.browserHistory?(this.router=new l.Router({pushState:this.options.pushState,root:this.options.root,hashBang:this.options.hashBang}),this.pane.bindToRouter(this.router),this.router.start()):this.options.initial||this.pane.navigate("")},_resizeToScreenHeight:function(){var t,n=e("meta[name=apple-mobile-web-app-status-bar-style]").attr("content").match(/black-translucent|hidden/),i=this.element;t=_?window.innerHeight:r(i)?n?w?P.availWidth+M:P.availWidth:w?P.availWidth:P.availWidth-M:n?w?P.availHeight:P.availHeight+M:w?P.availHeight-M:P.availHeight,i.height(t)},_setupElementClass:function(){var t,n=this,i=n.element;i.parent().addClass("km-root km-"+(n.os.tablet?"tablet":"phone")),i.addClass(n.osCssClass+" "+o(i)),this.options.useNativeScrolling&&i.parent().addClass("km-native-scrolling"),_&&i.addClass("km-ios-chrome"),d.wpDevicePixelRatio&&i.parent().css("font-size",d.wpDevicePixelRatio+"em"),this.options.retina&&(i.parent().addClass("km-retina"),i.parent().css("font-size",d.devicePixelRatio*m+"em")),g&&s(),n.options.useNativeScrolling?i.parent().addClass("km-native-scrolling"):T&&(t=(screen.availWidth>screen.availHeight?screen.availWidth:screen.availHeight)+200,e(S({width:t,height:t})).appendTo(z)),b&&n._resizeToScreenHeight(),l.onResize(function(){i.removeClass("km-horizontal km-vertical").addClass(o(i)),n.options.useNativeScrolling&&a(i),b&&n._resizeToScreenHeight(),g&&s(),l.resize(i)})},_clearExistingMeta:function(){z.find("meta").filter("[name|='apple-mobile-web-app'],[name|='msapplication-tap'],[name='viewport']").remove()},_attachMeta:function(){var e,t=this.options,n=t.icon;if(this._clearExistingMeta(),g||z.prepend(x({height:"",scale:this.options.retina?1/d.devicePixelRatio:"1.0"})),z.prepend(C(t)),n){"string"==typeof n&&(n={"":n});for(e in n)z.prepend(D({icon:n[e],size:e}))}t.useNativeScrolling&&a(this.element)},_attachHideBarHandlers:function(){var e=this,t=L(e,"_hideBar");!d.mobileOS.appMode&&e.options.hideAddressBar&&A&&!e.options.useNativeScrolling&&(e._initialHeight={},F.on("load",t),l.onResize(function(){setTimeout(window.scrollTo,0,0,1)}))},_setupDocumentTitle:function(){var e=this,n=document.title;e.pane.bind("viewShow",function(e){var i=e.view.title;document.title=i!==t?i:n})},_hideBar:function(){var t=this,n=t.element;n.height(l.support.transforms.css+"calc(100% + "+R+"px)"),e(window).trigger(l.support.resize)}});l.mobile.Application=H,l.ui.plugin(H,l.mobile,"Mobile")}(window.kendo.jQuery)}(),function(){!function(e,t){function n(t,n,i){e(n.target).closest(".km-button,.km-detail").toggleClass("km-state-active",i),d&&t.deactivateTimeoutID&&(clearTimeout(t.deactivateTimeoutID),t.deactivateTimeoutID=0)}function i(t){return e(''+t+" ")}var r=window.kendo,o=r.mobile,a=o.ui,s=a.Widget,l=r.support,c=l.mobileOS,d=c.android&&c.flatVersion>=300,u="click",h="disabled",f="km-state-disabled",p=s.extend({init:function(e,t){var i,o=this;s.fn.init.call(o,e,t),i="up"===o.options.clickOn,o._wrap(),o._style(),i||o.element.attr("data-navigate-on-press",!0),o.options.enable=o.options.enable&&!o.element.attr(h),o.enable(o.options.enable),o._userEvents=new r.UserEvents(o.element,{allowSelection:!i,press:function(e){o._activate(e)},release:function(e){n(o,e,!1),i||e.event.stopPropagation()}}),o._userEvents.bind(i?"tap":"press",function(e){o._release(e)}),d&&o.element.on("move",function(e){o._timeoutDeactivate(e)})},destroy:function(){s.fn.destroy.call(this),this._userEvents.destroy()},events:[u],options:{name:"Button",icon:"",style:"",badge:"",clickOn:"up",enable:!0},badge:function(e){var t=this.badgeElement=this.badgeElement||i(e).appendTo(this.element);return e||0===e?(t.html(e),this):e===!1?(t.empty().remove(),this.badgeElement=!1,this):t.html()},enable:function(e){var n=this.element;t===e&&(e=!0),this.options.enable=e,e?n.removeAttr(h):n.attr(h,h),n.toggleClass(f,!e)},_timeoutDeactivate:function(e){this.deactivateTimeoutID||(this.deactivateTimeoutID=setTimeout(n,500,this,e,!1))},_activate:function(e){var t=document.activeElement,i=t?t.nodeName:"";this.options.enable&&(n(this,e,!0),("INPUT"==i||"TEXTAREA"==i)&&t.blur())},_release:function(n){var i=this;if(!(n.which>1))return i.options.enable?(i.trigger(u,{target:e(n.target),button:i.element})&&n.preventDefault(),t):(n.preventDefault(),t)},_style:function(){var t,n=this.options.style,i=this.element;n&&(t=n.split(" "),e.each(t,function(){i.addClass("km-"+this)}))},_wrap:function(){var t=this,n=t.options.icon,r=t.options.badge,o=' ').children("span.km-text")),!l[0]&&n&&(s[0]||(o+=" km-notext"),t.iconElement=a.prepend(e(o+'" />'))),(r||0===r)&&(t.badgeElement=i(r).appendTo(a))}}),g=p.extend({options:{name:"BackButton",style:"back"},init:function(e,n){var i=this;p.fn.init.call(i,e,n),t===i.element.attr("href")&&i.element.attr("href","#:back")}}),m=p.extend({options:{name:"DetailButton",style:""},init:function(e,t){p.fn.init.call(this,e,t)},_style:function(){var t,n=this.options.style+" detail",i=this.element;n&&(t=n.split(" "),e.each(t,function(){i.addClass("km-"+this)}))},_wrap:function(){var t=this,n=t.options.icon,i=' ')))}});a.plugin(p),a.plugin(g),a.plugin(m)}(window.kendo.jQuery)}(),function(){!function(e,t){function n(t){return e(''+t+" ")}var i=window.kendo,r=i.mobile.ui,o=r.Widget,a="km-state-active",s="km-state-disabled",l="select",c="li:not(."+a+")",d=o.extend({init:function(e,t){var n=this;o.fn.init.call(n,e,t),n.element.addClass("km-buttongroup").find("li").each(n._button),n.element.on(n.options.selectOn,c,"_select"),n._enable=!0,n.select(n.options.index),n.options.enable||(n._enable=!1,n.wrapper.addClass(s))},events:[l],options:{name:"ButtonGroup",selectOn:"down",index:-1,enable:!0},current:function(){return this.element.find("."+a)},select:function(n){var i=this,r=-1;n!==t&&-1!==n&&i._enable&&!e(n).is("."+s)&&(i.current().removeClass(a),"number"==typeof n?(r=n,n=e(i.element[0].children[n])):n.nodeType&&(n=e(n),r=n.index()),n.addClass(a),i.selectedIndex=r)},badge:function(t,i){var r,o=this.element;return isNaN(t)||(t=o.children().get(t)),t=o.find(t),r=e(t.children(".km-badge")[0]||n(i).appendTo(t)),i||0===i?(r.html(i),this):i===!1?(r.empty().remove(),this):r.html()},enable:function(e){var n=this.wrapper;t===e&&(e=!0),e?n.removeClass(s):n.addClass(s),this._enable=this.options.enable=e},_button:function(){var t=e(this).addClass("km-button"),r=i.attrValue(t,"icon"),o=i.attrValue(t,"badge"),a=t.children("span"),s=t.find("img").addClass("km-image");a[0]||(a=t.wrapInner(" ").children("span")),a.addClass("km-text"),!s[0]&&r&&t.prepend(e(' ')),(o||0===o)&&n(o).appendTo(t)},_select:function(e){e.which>1||e.isDefaultPrevented()||!this._enable||(this.select(e.currentTarget),this.trigger(l,{index:this.selectedIndex}))}});r.plugin(d)}(window.kendo.jQuery)}(),function(){!function(e){var t=window.kendo,n=t.mobile.ui,i=n.Widget,r="km-collapsible",o="km-collapsible-header",a="km-collapsible-content",s="km-collapsibleinset",l="
",c="
",d="km-collapsed",u="km-expanded",h="km-animated",f="left",p="expand",g="collapse",m=i.extend({init:function(n,o){var a=this,l=e(n);i.fn.init.call(a,l,o),l.addClass(r),a._buildHeader(),a.content=l.children().not(a.header).wrapAll(c).parent(),a._userEvents=new t.UserEvents(a.header,{tap:function(){a.toggle()}}),l.addClass(a.options.collapsed?d:u),a.options.inset&&l.addClass(s),a.options.animation?(a.content.addClass(h),a.content.height(0),a.options.collapsed&&a.content.hide()):a.options.collapsed&&a.content.hide()},events:[p,g],options:{name:"Collapsible",collapsed:!0,collapseIcon:"arrow-n",expandIcon:"arrow-s",iconPosition:f,animation:!0,inset:!1},destroy:function(){i.fn.destroy.call(this),this._userEvents.destroy()},expand:function(e){var n=this.options.collapseIcon,i=this.content,r=t.support.mobileOS.ios;this.trigger(p)||(n&&this.header.find(".km-icon").removeClass().addClass("km-icon km-"+n),this.element.removeClass(d).addClass(u),this.options.animation&&!e?(i.off("transitionend"),i.show(),r&&i.removeClass(h),i.height(this._getContentHeight()),r&&i.addClass(h),t.resize(i)):i.show())},collapse:function(e){var t=this.options.expandIcon,n=this.content;this.trigger(g)||(t&&this.header.find(".km-icon").removeClass().addClass("km-icon km-"+t),this.element.removeClass(u).addClass(d),this.options.animation&&!e?(n.one("transitionend",function(){n.hide()}),n.height(0)):n.hide())},toggle:function(e){this.isCollapsed()?this.expand(e):this.collapse(e)},isCollapsed:function(){return this.element.hasClass(d)},resize:function(){!this.isCollapsed()&&this.options.animation&&this.content.height(this._getContentHeight())},_buildHeader:function(){var t=this.element.children(":header").wrapAll(l),n=e(' '),i=this.options.collapsed?this.options.expandIcon:this.options.collapseIcon,r=this.options.iconPosition;i&&(t.prepend(n),n.addClass("km-"+i)),this.header=t.parent(),this.header.addClass("km-icon-"+r)},_getContentHeight:function(){var e,t=this.content.attr("style");return this.content.css({position:"absolute",visibility:"hidden",height:"auto"}),e=this.content.height(),this.content.attr("style",t?t:""),e}});n.plugin(m)}(window.kendo.jQuery)}(),function(){!function(e,t){function n(){return this.nodeType===v.TEXT_NODE&&this.nodeValue.match(U)}function i(e,t){t&&!e[0].querySelector(".km-icon")&&e.prepend(' ')}function r(e){i(e,T(e,"icon")),i(e,T(e.children(C),"icon"))}function o(e){var t=e.parent(),r=e.add(t.children(m.roleSelector("detailbutton"))),o=t.contents().not(r).not(n);o.length||(e.addClass("km-listview-link").attr(m.attr("role"),"listview-link"),i(e,T(t,"icon")),i(e,T(e,"icon")))}function a(e){if(e[0].querySelector("input[type=checkbox],input[type=radio]")){var t=e.parent();t.contents().not(e).not(function(){return 3==this.nodeType})[0]||(e.addClass("km-listview-label"),e.children("[type=checkbox],[type=radio]").addClass("km-widget km-icon km-check"))}}function s(t,n){e(t).css("transform","translate3d(0px, "+n+"px, 0px)")}var l,c,d,u,h,f,p,g,m=window.kendo,v=window.Node,_=m.mobile,b=_.ui,w=m.data.DataSource,y=b.DataBoundWidget,k=".km-list > li, > li:not(.km-group-container)",x=".km-listview-link, .km-listview-label",C="["+m.attr("icon")+"]",S=e.proxy,T=m.attrValue,D="km-group-title",A="km-state-active",E='',I=m.template('#= this.headerTemplate(data) #
#= kendo.render(this.template, data.items)# '),R='
',M=m.template(''),F=".kendoMobileListView",P="styled",z="dataBound",B="dataBinding",L="itemChange",H="click",N="change",O="progress",V="function",U=/^\s+$/,W=/button/,j=m.Class.extend({init:function(e){var t,n,i=e.scroller();i&&(this.options=e.options,this.element=e.element,this.scroller=e.scroller(),this._shouldFixHeaders(),t=this,n=function(){t._cacheHeaders()},e.bind("resize",n),e.bind(P,n),e.bind(z,n),i.bind("scroll",function(e){t._fixHeader(e)}))},_fixHeader:function(t){if(this.fixedHeaders){var n,i,r,o=0,a=this.scroller,s=this.headers,l=t.scrollTop;do{if(n=s[o++],!n){r=e("
");break}i=n.offset,r=n.header}while(i+1>l);this.currentHeader!=o&&(a.fixedContainer.html(r.clone()),this.currentHeader=o)}},_shouldFixHeaders:function(){this.fixedHeaders="group"===this.options.type&&this.options.fixedHeaders},_cacheHeaders:function(){if(this._shouldFixHeaders(),this.fixedHeaders){var t=[],n=this.scroller.scrollTop;this.element.find("."+D).each(function(i,r){r=e(r),t.unshift({offset:r.position().top+n,header:r})}),this.headers=t,this._fixHeader({scrollTop:n})}}}),q=function(){return{page:1}},G=m.Class.extend({init:function(e){var t=this,n=e.options,i=e.scroller(),r=n.pullParameters||q;this.listView=e,this.scroller=i,e.bind("_dataSource",function(e){t.setDataSource(e.dataSource)}),i.setOptions({pullToRefresh:!0,pull:function(){t._pulled||(t._pulled=!0,t.dataSource.read(r.call(e,t._first)))},messages:{pullTemplate:n.messages.pullTemplate,releaseTemplate:n.messages.releaseTemplate,refreshTemplate:n.messages.refreshTemplate}})},setDataSource:function(e){var t=this;this._first=e.view()[0],this.dataSource=e,e.bind("change",function(){t._change()}),e.bind("error",function(){t._change()})},_change:function(){var e,t=this.scroller,n=this.dataSource;this._pulled&&t.pullHandled(),(this._pulled||!this._first)&&(e=n.view(),e[0]&&(this._first=e[0])),this._pulled=!1}}),$=m.Observable.extend({init:function(e){var t=this;m.Observable.fn.init.call(t),t.buffer=e.buffer,t.height=e.height,t.item=e.item,t.items=[],t.footer=e.footer,t.buffer.bind("reset",function(){t.refresh()})},refresh:function(){for(var e,t,n,i,r=this.buffer,o=this.items,a=!1;o.length;)o.pop().destroy();for(this.offset=r.offset,e=this.item,i=0;r.viewSize>i;i++){if(i===r.total()){a=!0;break}n=e(this.content(this.offset+o.length)),n.below(t),t=n,o.push(n)}this.itemCount=o.length,this.trigger("reset"),this._resize(),a&&this.trigger("endReached")},totalHeight:function(){if(!this.items[0])return 0;var e=this,t=e.items,n=t[0].top,i=t[t.length-1].bottom,r=(i-n)/e.itemCount,o=e.buffer.length-e.offset-e.itemCount;return(this.footer?this.footer.height:0)+i+o*r},batchUpdate:function(e){var t,n,i=this.height(),r=this.items,o=this.offset;if(r[0]){if(this.lastDirection)for(;r[r.length-1].bottom>e+2*i&&0!==this.offset;)this.offset--,t=r.pop(),t.update(this.content(this.offset)),t.above(r[0]),r.unshift(t);else for(;e-i>r[0].top;){if(n=this.offset+this.itemCount,n===this.buffer.total()){this.trigger("endReached");break}if(n===this.buffer.length)break;t=r.shift(),t.update(this.content(this.offset+this.itemCount)),t.below(r[r.length-1]),r.push(t),this.offset++}o!==this.offset&&this._resize()}},update:function(e){var t,n,i,r,o=this,a=this.items,s=this.height(),l=this.itemCount,c=s/2,d=(this.lastTop||0)>e,u=e-c,h=e+s+c;a[0]&&(this.lastTop=e,this.lastDirection=d,d?a[0].top>u&&a[a.length-1].bottom>h+c&&this.offset>0&&(this.offset--,t=a.pop(),n=a[0],t.update(this.content(this.offset)),a.unshift(t),t.above(n),o._resize()):h>a[a.length-1].bottom&&u-c>a[0].top&&(r=this.offset+l,r===this.buffer.total()?this.trigger("endReached"):r!==this.buffer.length&&(t=a.shift(),i=a[a.length-1],a.push(t),t.update(this.content(this.offset+this.itemCount)),o.offset++,t.below(i),o._resize())))},content:function(e){return this.buffer.at(e)},destroy:function(){this.unbind()},_resize:function(){var e=this.items,t=0,n=0,i=e[0],r=e[e.length-1];i&&(t=i.top,n=r.bottom),this.trigger("resize",{top:t,bottom:n}),this.footer&&this.footer.below(r)}});m.mobile.ui.VirtualList=$,l=m.Class.extend({init:function(t,n){var i=t.append([n],!0)[0],r=i.offsetHeight;e.extend(this,{top:0,element:i,listView:t,height:r,bottom:r})},update:function(e){this.element=this.listView.setDataItem(this.element,e)},above:function(e){e&&(this.height=this.element.offsetHeight,this.top=e.top-this.height,this.bottom=e.top,s(this.element,this.top))},below:function(e){e&&(this.height=this.element.offsetHeight,this.top=e.bottom,this.bottom=this.top+this.height,s(this.element,this.top))},destroy:function(){m.destroy(this.element),e(this.element).remove()}}),c='
',d=m.Class.extend({init:function(t){this.element=e(' ').appendTo(t.element),this._loadIcon=e(c).appendTo(this.element)},enable:function(){this.element.show(),this.height=this.element.outerHeight(!0)},disable:function(){this.element.hide(),this.height=0},below:function(e){e&&(this.top=e.bottom,this.bottom=this.height+this.top,s(this.element,this.top))}}),u=d.extend({init:function(t,n){this._loadIcon=e(c).hide(),this._loadButton=e(''+t.options.messages.loadMoreText+" ").hide(),this.element=e(' ').append(this._loadIcon).append(this._loadButton).appendTo(t.element);var i=this;this._loadButton.kendoMobileButton().data("kendoMobileButton").bind("click",function(){i._hideShowButton(),n.next()}),n.bind("resize",function(){i._showLoadButton()}),this.height=this.element.outerHeight(!0),this.disable()},_hideShowButton:function(){this._loadButton.hide(),this.element.addClass("km-scroller-refresh"),this._loadIcon.css("display","block")},_showLoadButton:function(){this._loadButton.show(),this.element.removeClass("km-scroller-refresh"),this._loadIcon.hide()}}),h=m.Class.extend({init:function(e){var t=this;this.chromeHeight=e.wrapper.children().not(e.element).outerHeight()||0,this.listView=e,this.scroller=e.scroller(),this.options=e.options,e.bind("_dataSource",function(e){t.setDataSource(e.dataSource,e.empty)}),e.bind("resize",function(){t.list.items.length&&(t.scroller.reset(),t.buffer.range(0),t.list.refresh())}),this.scroller.makeVirtual(),this.scroller.bind("scroll",function(e){t.list.update(e.scrollTop)}),this.scroller.bind("scrollEnd",function(e){t.list.batchUpdate(e.scrollTop)})},destroy:function(){this.list.unbind(),this.buffer.unbind()},setDataSource:function(t,n){var i,r,o,a,s=this,c=this.options,h=this.listView,f=h.scroller(),p=c.loadMore;if(this.dataSource=t,i=t.pageSize()||c.virtualViewSize,!i&&!n)throw Error("the DataSource does not have page size configured. Page Size setting is mandatory for the mobile listview virtual scrolling to work as expected.");this.buffer&&this.buffer.destroy(),r=new m.data.Buffer(t,Math.floor(i/2),p),o=p?new u(h,r):new d(h),this.list&&this.list.destroy(),a=new $({buffer:r,footer:o,item:function(e){return new l(h,e)},height:function(){return f.height()}}),a.bind("resize",function(){s.updateScrollerSize(),h.updateSize()}),a.bind("reset",function(){s.footer.enable()}),a.bind("endReached",function(){o.disable(),s.updateScrollerSize()}),r.bind("expand",function(){a.lastDirection=!1,a.batchUpdate(f.scrollTop)}),e.extend(this,{buffer:r,scroller:f,list:a,footer:o})},updateScrollerSize:function(){this.scroller.virtualSize(0,this.list.totalHeight()+this.chromeHeight)},refresh:function(){this.list.refresh()},reset:function(){this.buffer.range(0),this.list.refresh()}}),f=m.Class.extend({init:function(e){var t,n=this;this.listView=e,this.options=e.options,t=this,this._refreshHandler=function(e){t.refresh(e)},this._progressHandler=function(){e.showLoading()},e.bind("_dataSource",function(e){n.setDataSource(e.dataSource)})},destroy:function(){this._unbindDataSource()},reset:function(){},refresh:function(e){var n,i,r,o,a,s,l,c=e&&e.action,d=e&&e.items,u=this.listView,h=this.dataSource,f=this.options.appendOnRefresh,p=h.view(),g=h.group(),m=g&&g[0];return"itemchange"===c?(u._hasBindingTarget()||(n=u.findByDataItem(d)[0],n&&u.setDataItem(n,d[0])),t):(a="add"===c&&!m||f&&!u._filter,s="remove"===c&&!m,a?i=[]:s&&(i=u.findByDataItem(d)),u.trigger(B,{action:c||"rebind",items:d,removedItems:i,index:e&&e.index})?(this._shouldShowLoading()&&u.hideLoading(),t):("add"!==c||m?"remove"!==c||m?m?u.replaceGrouped(p):f&&!u._filter?(r=u.prepend(p),o=p):u.replace(p):(r=[],u.remove(d)):(l=p.indexOf(d[0]),l>-1&&(r=u.insertAt(d,l),o=d)),this._shouldShowLoading()&&u.hideLoading(),u.trigger(z,{ns:b,addedItems:r,addedDataItems:o}),t))},setDataSource:function(e){this.dataSource&&this._unbindDataSource(),this.dataSource=e,e.bind(N,this._refreshHandler),this._shouldShowLoading()&&this.dataSource.bind(O,this._progressHandler)},_unbindDataSource:function(){this.dataSource.unbind(N,this._refreshHandler).unbind(O,this._progressHandler)},_shouldShowLoading:function(){var e=this.options;return!e.pullToRefresh&&!e.loadMore&&!e.endlessScroll}}),p=m.Class.extend({init:function(t){var n=this,i=t.options.filterable,r="change paste",o=this;this.listView=t,this.options=i,t.element.before(M({placeholder:i.placeholder||"Search..."})),i.autoFilter!==!1&&(r+=" keyup"),this.element=t.wrapper.find(".km-search-form"),this.searchInput=t.wrapper.find("input[type=search]").closest("form").on("submit"+F,function(e){e.preventDefault()}).end().on("focus"+F,function(){n._oldFilter=n.searchInput.val()}).on(r.split(" ").join(F+" ")+F,S(this._filterChange,this)),this.clearButton=t.wrapper.find(".km-filter-reset").on(H,S(this,"_clearFilter")).hide(),this._dataSourceChange=e.proxy(this._refreshInput,this),t.bind("_dataSource",function(e){e.dataSource.bind("change",o._dataSourceChange)})},_refreshInput:function(){var e=this.listView.dataSource.filter(),t=this.listView._filter.searchInput;t.val(e&&e.filters[0].field===this.listView.options.filterable.field?e.filters[0].value:"")},_search:function(e){this._filter=!0,this.clearButton[e?"show":"hide"](),this.listView.dataSource.filter(e)},_filterChange:function(e){var t=this;"paste"==e.type&&this.options.autoFilter!==!1?setTimeout(function(){t._applyFilter()},1):this._applyFilter()},_applyFilter:function(){var e=this.options,t=this.searchInput.val(),n=t.length?{field:e.field,operator:e.operator||"startswith",ignoreCase:e.ignoreCase,value:t}:null;t!==this._oldFilter&&(this._oldFilter=t,this._search(n))},_clearFilter:function(e){this.searchInput.val(""),this._search(null),e.preventDefault()}}),g=y.extend({init:function(t,n){var i=this;y.fn.init.call(this,t,n),t=this.element,n=this.options,n.scrollTreshold&&(n.scrollThreshold=n.scrollTreshold),t.on("down",x,"_highlight").on("move up cancel",x,"_dim"),this._userEvents=new m.UserEvents(t,{filter:k,allowSelection:!0,tap:function(e){i._click(e)}}),t.css("-ms-touch-action","auto"),t.wrap(R),this.wrapper=this.element.parent(),this._headerFixer=new j(this),this._itemsCache={},this._templates(),this.virtual=n.endlessScroll||n.loadMore,this._style(),this.options.$angular&&(this.virtual||this.options.pullToRefresh)?setTimeout(e.proxy(this,"_start")):this._start()},_start:function(){var e=this.options;this.options.filterable&&(this._filter=new p(this)),this._itemBinder=this.virtual?new h(this):new f(this),this.options.pullToRefresh&&(this._pullToRefreshHandler=new G(this)),this.setDataSource(e.dataSource),this._enhanceItems(this.items()),m.notify(this,b)},events:[H,B,z,L],options:{name:"ListView",style:"",type:"flat",autoBind:!0,fixedHeaders:!1,template:"#:data#",headerTemplate:'#:value# ',appendOnRefresh:!1,loadMore:!1,endlessScroll:!1,scrollThreshold:30,pullToRefresh:!1,messages:{loadMoreText:"Press to load more",pullTemplate:"Pull to refresh",releaseTemplate:"Release to refresh",refreshTemplate:"Refreshing"},pullOffset:140,filterable:!1,virtualViewSize:null},refresh:function(){this._itemBinder.refresh()},reset:function(){this._itemBinder.reset()},setDataSource:function(e){var t=!e;this.dataSource=w.create(e),this.trigger("_dataSource",{dataSource:this.dataSource,empty:t}),this.options.autoBind&&!t&&(this.items().remove(),this.dataSource.fetch())},destroy:function(){y.fn.destroy.call(this),m.destroy(this.element),this._userEvents.destroy(),this._itemBinder&&this._itemBinder.destroy(),this.element.unwrap(),delete this.element,delete this.wrapper,delete this._userEvents},items:function(){return"group"===this.options.type?this.element.find(".km-list").children():this.element.children().not(".km-load-more")},scroller:function(){return this._scrollerInstance||(this._scrollerInstance=this.element.closest(".km-scroll-wrapper").data("kendoMobileScroller")),this._scrollerInstance},showLoading:function(){var e=this.view();e&&e.loader&&e.loader.show()},hideLoading:function(){var e=this.view();e&&e.loader&&e.loader.hide()},insertAt:function(e,t,n){var i=this;return i._renderItems(e,function(r){if(0===t?i.element.prepend(r):-1===t?i.element.append(r):i.items().eq(t-1).after(r),n)for(var o=0;r.length>o;o++)i.trigger(L,{item:r.eq(o),data:e[o],ns:b})})},append:function(e,t){return this.insertAt(e,-1,t)},prepend:function(e,t){return this.insertAt(e,0,t)},replace:function(e){return this.options.type="flat",this._angularItems("cleanup"),this.element.empty(),this._userEvents.cancel(),this._style(),this.insertAt(e,0)},replaceGrouped:function(t){this.options.type="group",this._angularItems("cleanup"),this.element.empty();var n=e(m.render(this.groupTemplate,t));this._enhanceItems(n.children("ul").children("li")),this.element.append(n),_.init(n),this._style(),this._angularItems("compile")},remove:function(e){var t=this.findByDataItem(e);this.angular("cleanup",function(){return{elements:t}}),m.destroy(t),t.remove()},findByDataItem:function(e){var t,n,i=[];for(t=0,n=e.length;n>t;t++)i[t]="[data-"+m.ns+"uid="+e[t].uid+"]";return this.element.find(i.join(","))},setDataItem:function(t,n){var i=this,r=function(r){var o=e(r[0]);m.destroy(t),i.angular("cleanup",function(){return{elements:[e(t)]}}),e(t).replaceWith(o),i.trigger(L,{item:o,data:n,ns:b})};return this._renderItems([n],r)[0]},updateSize:function(){this._size=this.getSize()},_renderItems:function(t,n){var i=e(m.render(this.template,t));return n(i),this.angular("compile",function(){return{elements:i,data:t.map(function(e){return{dataItem:e}})}}),_.init(i),this._enhanceItems(i),i},_dim:function(e){this._toggle(e,!1)},_highlight:function(e){this._toggle(e,!0)},_toggle:function(t,n){if(!(t.which>1)){var i=e(t.currentTarget),r=i.parent(),o=T(i,"role")||"",a=!o.match(W),s=t.isDefaultPrevented();a&&r.toggleClass(A,n&&!s)}},_templates:function(){var e=this.options.template,t=this.options.headerTemplate,n=' data-uid="#=arguments[0].uid || ""#"',i={},r={};typeof e===V&&(i.template=e,e="#=this.template(data)#"),this.template=S(m.template(""+e+" "),i),r.template=this.template,typeof t===V&&(r._headerTemplate=t,t="#=this._headerTemplate(data)#"),r.headerTemplate=m.template(t),this.groupTemplate=S(I,r)},_click:function(t){if(!(t.event.which>1||t.event.isDefaultPrevented())){var n,i=t.target,r=e(t.event.target),o=r.closest(m.roleSelector("button","detailbutton","backbutton")),a=m.widgetInstance(o,b),s=i.attr(m.attr("uid"));s&&(n=this.dataSource.getByUid(s)),this.trigger(H,{target:r,item:i,dataItem:n,button:a})&&t.preventDefault()}},_styleGroups:function(){var t=this.element.children();t.children("ul").addClass("km-list"),t.each(function(){var t=e(this),n=t.contents().first();t.addClass("km-group-container"),n.is("ul")||n.is("div."+D)||n.wrap(E)})},_style:function(){var e=this.options,t="group"===e.type,n=this.element,i="inset"===e.style;n.addClass("km-listview").toggleClass("km-list",!t).toggleClass("km-virtual-list",this.virtual).toggleClass("km-listinset",!t&&i).toggleClass("km-listgroup",t&&!i).toggleClass("km-listgroupinset",t&&i),n.parents(".km-listview")[0]||n.closest(".km-content").toggleClass("km-insetcontent",i),t&&this._styleGroups(),this.trigger(P)},_enhanceItems:function(t){t.each(function(){var t,n=e(this),i=!1;n.children().each(function(){t=e(this),t.is("a")?(o(t),i=!0):t.is("label")&&(a(t),i=!0)}),i||r(n)})}}),b.plugin(g)}(window.kendo.jQuery)}(),function(){!function(e,t){function n(n,i){var o=i.find("["+r.attr("align")+"="+n+"]");return o[0]?e('
').append(o).prependTo(i):t}function i(t){var n=t.siblings(),i=!!t.children("ul")[0],o=!!n[0]&&""===e.trim(t.text()),a=!(!r.mobile.application||!r.mobile.application.element.is(".km-android"));t.prevAll().toggleClass("km-absolute",i),t.toggleClass("km-show-title",o),t.toggleClass("km-fill-title",o&&!e.trim(t.html())),t.toggleClass("km-no-title",i),t.toggleClass("km-hide-title",a&&!n.children().is(":visible"))}var r=window.kendo,o=r.mobile,a=o.ui,s=a.Widget,l=s.extend({init:function(t,i){var r=this;s.fn.init.call(r,t,i),t=r.element,r.container().bind("show",e.proxy(this,"refresh")),t.addClass("km-navbar").wrapInner(e('
')),r.leftElement=n("left",t),r.rightElement=n("right",t),r.centerElement=t.find(".km-view-title")},options:{name:"NavBar"},title:function(e){this.element.find(r.roleSelector("view-title")).text(e),i(this.centerElement)},refresh:function(e){var t=e.view;this.title(t.options.title)},destroy:function(){s.fn.destroy.call(this),r.destroy(this.element)}});a.plugin(l)}(window.kendo.jQuery)}(),function(){!function(e,t){var n,i,r,o,a,s,l,c,d=window.kendo,u=d.mobile,h=u.ui,f=e.proxy,p=d.effects.Transition,g=d.ui.Pane,m=d.ui.PaneDimensions,v=h.DataBoundWidget,_=d.data.DataSource,b=d.data.Buffer,w=d.data.BatchBuffer,y=Math,k=y.abs,x=y.ceil,C=y.round,S=y.max,T=y.min,D=y.floor,A="change",E="changing",I="refresh",R="km-current-page",M="km-virtual-page",F="function",P="itemChange",z="cleanup",B=3,L=-1,H=0,N=1,O=-1,V=0,U=1,W=d.Class.extend({init:function(t){var n=this,i=e(" ");t.element.append(i),this._changeProxy=f(n,"_change"),this._refreshProxy=f(n,"_refresh"),t.bind(A,this._changeProxy),t.bind(I,this._refreshProxy),e.extend(n,{element:i,scrollView:t})},items:function(){return this.element.children()},_refresh:function(e){var t,n="";for(t=0;e.pageCount>t;t++)n+=" ";this.element.html(n),this.items().eq(e.page).addClass(R)},_change:function(e){this.items().removeClass(R).eq(e.page).addClass(R)},destroy:function(){this.scrollView.unbind(A,this._changeProxy),this.scrollView.unbind(I,this._refreshProxy),this.element.remove()}});d.mobile.ui.ScrollViewPager=W,n="transitionEnd",i="dragStart",r="dragEnd",o=d.Observable.extend({init:function(t,o){var a,s,l,c,u,h,f=this;d.Observable.fn.init.call(this),this.element=t,this.container=t.parent(),a=new d.ui.Movable(f.element),s=new p({axis:"x",movable:a,onEnd:function(){f.trigger(n)}}),l=new d.UserEvents(t,{start:function(e){2*k(e.x.velocity)>=k(e.y.velocity)?l.capture():l.cancel(),f.trigger(i,e),s.cancel()},allowSelection:!0,end:function(e){f.trigger(r,e)}}),c=new m({element:f.element,container:f.container}),u=c.x,u.bind(A,function(){f.trigger(A)}),h=new g({dimensions:c,userEvents:l,movable:a,elastic:!0}),e.extend(f,{duration:o&&o.duration||1,movable:a,transition:s,userEvents:l,dimensions:c,dimension:u,pane:h}),this.bind([n,i,r,A],o)},size:function(){return{width:this.dimensions.x.getSize(),height:this.dimensions.y.getSize()}},total:function(){return this.dimension.getTotal()},offset:function(){return-this.movable.x},updateDimension:function(){this.dimension.update(!0)},refresh:function(){this.dimensions.refresh()},moveTo:function(e){this.movable.moveAxis("x",-e)},transitionTo:function(e,t,n){n?this.moveTo(-e):this.transition.moveTo({location:e,duration:this.duration,ease:t})}}),d.mobile.ui.ScrollViewElasticPane=o,a=d.Observable.extend({init:function(e,t,n){var i=this;d.Observable.fn.init.call(this),i.element=e,i.pane=t,i._getPages(),this.page=0,this.pageSize=n.pageSize||1,this.contentHeight=n.contentHeight,this.enablePager=n.enablePager,this.pagerOverlay=n.pagerOverlay},scrollTo:function(e,t){this.page=e,this.pane.transitionTo(-e*this.pane.size().width,p.easeOutExpo,t)},paneMoved:function(e,t,n,i){var r,o,a=this,s=a.pane,l=s.size().width*a.pageSize,c=C,d=t?p.easeOutBack:p.easeOutExpo;e===O?c=x:e===U&&(c=D),o=c(s.offset()/l),r=S(a.minSnap,T(-o*l,a.maxSnap)),o!=a.page&&n&&n({currentPage:a.page,nextPage:o})&&(r=-a.page*s.size().width),
s.transitionTo(r,d,i)},updatePage:function(){var e=this.pane,t=C(e.offset()/e.size().width);return t!=this.page?(this.page=t,!0):!1},forcePageUpdate:function(){return this.updatePage()},resizeTo:function(e){var t,n,i=this.pane,r=e.width;this.pageElements.width(r),"100%"===this.contentHeight&&(t=this.element.parent().height(),this.enablePager===!0&&(n=this.element.parent().find("ol.km-pages"),!this.pagerOverlay&&n.length&&(t-=n.outerHeight(!0))),this.element.css("height",t),this.pageElements.css("height",t)),i.updateDimension(),this._paged||(this.page=D(i.offset()/r)),this.scrollTo(this.page,!0),this.pageCount=x(i.total()/r),this.minSnap=-(this.pageCount-1)*r,this.maxSnap=0},_getPages:function(){this.pageElements=this.element.find(d.roleSelector("page")),this._paged=this.pageElements.length>0}}),d.mobile.ui.ScrollViewContent=a,s=d.Observable.extend({init:function(e,t,n){var i=this;d.Observable.fn.init.call(this),i.element=e,i.pane=t,i.options=n,i._templates(),i.page=n.page||0,i.pages=[],i._initPages(),i.resizeTo(i.pane.size()),i.pane.dimension.forceEnabled()},setDataSource:function(e){this.dataSource=_.create(e),this._buffer(),this._pendingPageRefresh=!1,this._pendingWidgetRefresh=!1},_viewShow:function(){var e=this;e._pendingWidgetRefresh&&(setTimeout(function(){e._resetPages()},0),e._pendingWidgetRefresh=!1)},_buffer:function(){var e=this.options.itemsPerPage;this.buffer&&this.buffer.destroy(),this.buffer=e>1?new w(this.dataSource,e):new b(this.dataSource,3*e),this._resizeProxy=f(this,"_onResize"),this._resetProxy=f(this,"_onReset"),this._endReachedProxy=f(this,"_onEndReached"),this.buffer.bind({resize:this._resizeProxy,reset:this._resetProxy,endreached:this._endReachedProxy})},_templates:function(){var e=this.options.template,t=this.options.emptyTemplate,n={},i={};typeof e===F&&(n.template=e,e="#=this.template(data)#"),this.template=f(d.template(e),n),typeof t===F&&(i.emptyTemplate=t,t="#=this.emptyTemplate(data)#"),this.emptyTemplate=f(d.template(t),i)},_initPages:function(){var e,t,n=this.pages,i=this.element;for(t=0;B>t;t++)e=new l(i),n.push(e);this.pane.updateDimension()},resizeTo:function(e){var t,n,i,r=this.pages,o=this.pane;for(t=0;r.length>t;t++)r[t].setWidth(e.width);"auto"===this.options.contentHeight?this.element.css("height",this.pages[1].element.height()):"100%"===this.options.contentHeight&&(n=this.element.parent().height(),this.options.enablePager===!0&&(i=this.element.parent().find("ol.km-pages"),!this.options.pagerOverlay&&i.length&&(n-=i.outerHeight(!0))),this.element.css("height",n),r[0].element.css("height",n),r[1].element.css("height",n),r[2].element.css("height",n)),o.updateDimension(),this._repositionPages(),this.width=e.width},scrollTo:function(e){var t,n=this.buffer;n.syncDataSource(),t=n.at(e),t&&(this._updatePagesContent(e),this.page=e)},paneMoved:function(e,t,n,i){var r,o=this,a=o.pane,s=a.size().width,l=a.offset(),c=Math.abs(l)>=s/3,u=t?d.effects.Transition.easeOutBack:d.effects.Transition.easeOutExpo,h=o.page+2>o.buffer.total(),f=0;e===U?0!==o.page&&(f=-1):e!==O||h?l>0&&c&&!h?f=1:0>l&&c&&0!==o.page&&(f=-1):f=1,r=o.page,f&&(r=f>0?r+1:r-1),n&&n({currentPage:o.page,nextPage:r})&&(f=0),0===f?o._cancelMove(u,i):-1===f?o._moveBackward(i):1===f&&o._moveForward(i)},updatePage:function(){var e=this.pages;return 0===this.pane.offset()?!1:(this.pane.offset()>0?(e.push(this.pages.shift()),this.page++,this.setPageContent(e[2],this.page+1)):(e.unshift(this.pages.pop()),this.page--,this.setPageContent(e[0],this.page-1)),this._repositionPages(),this._resetMovable(),!0)},forcePageUpdate:function(){var e=this.pane.offset(),t=3*this.pane.size().width/4;return k(e)>t?this.updatePage():!1},_resetMovable:function(){this.pane.moveTo(0)},_moveForward:function(e){this.pane.transitionTo(-this.width,d.effects.Transition.easeOutExpo,e)},_moveBackward:function(e){this.pane.transitionTo(this.width,d.effects.Transition.easeOutExpo,e)},_cancelMove:function(e,t){this.pane.transitionTo(0,e,t)},_resetPages:function(){this.page=this.options.page||0,this._updatePagesContent(this.page),this._repositionPages(),this.trigger("reset")},_onResize:function(){this.pageCount=x(this.dataSource.total()/this.options.itemsPerPage),this._pendingPageRefresh&&(this._updatePagesContent(this.page),this._pendingPageRefresh=!1),this.trigger("resize")},_onReset:function(){this.pageCount=x(this.dataSource.total()/this.options.itemsPerPage),this._resetPages()},_onEndReached:function(){this._pendingPageRefresh=!0},_repositionPages:function(){var e=this.pages;e[0].position(L),e[1].position(H),e[2].position(N)},_updatePagesContent:function(e){var t=this.pages,n=e||0;this.setPageContent(t[0],n-1),this.setPageContent(t[1],n),this.setPageContent(t[2],n+1)},setPageContent:function(t,n){var i=this.buffer,r=this.template,o=this.emptyTemplate,a=null;n>=0&&(a=i.at(n),e.isArray(a)&&!a.length&&(a=null)),this.trigger(z,{item:t.element}),t.content(null!==a?r(a):o({})),d.mobile.init(t.element),this.trigger(P,{item:t.element,data:a,ns:d.mobile.ui})}}),d.mobile.ui.VirtualScrollViewContent=s,l=d.Class.extend({init:function(t){this.element=e("
"),this.width=t.width(),this.element.width(this.width),t.append(this.element)},content:function(e){this.element.html(e)},position:function(e){this.element.css("transform","translate3d("+this.width*e+"px, 0, 0)")},setWidth:function(e){this.width=e,this.element.width(e)}}),d.mobile.ui.VirtualPage=l,c=v.extend({init:function(e,t){var n,i,r,l=this;v.fn.init.call(l,e,t),t=l.options,e=l.element,d.stripWhitespace(e[0]),e.wrapInner("
").addClass("km-scrollview"),this.options.enablePager&&(this.pager=new W(this),this.options.pagerOverlay&&e.addClass("km-scrollview-overlay")),l.inner=e.children().first(),l.page=0,l.inner.css("height",t.contentHeight),l.pane=new o(l.inner,{duration:this.options.duration,transitionEnd:f(this,"_transitionEnd"),dragStart:f(this,"_dragStart"),dragEnd:f(this,"_dragEnd"),change:f(this,I)}),l.bind("resize",function(){l.pane.refresh()}),l.page=t.page,n=0===this.inner.children().length,i=n?new s(l.inner,l.pane,t):new a(l.inner,l.pane,t),i.page=l.page,i.bind("reset",function(){this._pendingPageRefresh=!1,l._syncWithContent(),l.trigger(I,{pageCount:i.pageCount,page:i.page})}),i.bind("resize",function(){l.trigger(I,{pageCount:i.pageCount,page:i.page})}),i.bind(P,function(e){l.trigger(P,e),l.angular("compile",function(){return{elements:e.item,data:[{dataItem:e.data}]}})}),i.bind(z,function(e){l.angular("cleanup",function(){return{elements:e.item}})}),l._content=i,l.setDataSource(t.dataSource),r=l.container(),r.nullObject?(l.viewInit(),l.viewShow()):r.bind("show",f(this,"viewShow")).bind("init",f(this,"viewInit"))},options:{name:"ScrollView",page:0,duration:400,velocityThreshold:.8,contentHeight:"auto",pageSize:1,itemsPerPage:1,bounceVelocityThreshold:1.6,enablePager:!0,pagerOverlay:!1,autoBind:!0,template:"",emptyTemplate:""},events:[E,A,I],destroy:function(){v.fn.destroy.call(this),d.destroy(this.element)},viewInit:function(){this.options.autoBind&&this._content.scrollTo(this._content.page,!0)},viewShow:function(){this.pane.refresh()},refresh:function(){var e=this._content;e.resizeTo(this.pane.size()),this.page=e.page,this.trigger(I,{pageCount:e.pageCount,page:e.page})},content:function(e){this.element.children().first().html(e),this._content._getPages(),this.pane.refresh()},value:function(e){var n=this.dataSource;return e?(this.scrollTo(n.indexOf(e),!0),t):n.at(this.page)},scrollTo:function(e,t){this._content.scrollTo(e,t),this._syncWithContent()},prev:function(){var e=this,n=e.page-1;e._content instanceof s?e._content.paneMoved(U,t,function(t){return e.trigger(E,t)}):n>-1&&e.scrollTo(n)},next:function(){var e=this,n=e.page+1;e._content instanceof s?e._content.paneMoved(O,t,function(t){return e.trigger(E,t)}):e._content.pageCount>n&&e.scrollTo(n)},setDataSource:function(e){if(this._content instanceof s){var t=!e;this.dataSource=_.create(e),this._content.setDataSource(this.dataSource),this.options.autoBind&&!t&&this.dataSource.fetch()}},items:function(){return this.element.find("."+M)},_syncWithContent:function(){var e,n,i=this._content.pages,r=this._content.buffer;this.page=this._content.page,e=r?r.at(this.page):t,e instanceof Array||(e=[e]),n=i?i[1].element:t,this.trigger(A,{page:this.page,element:n,data:e})},_dragStart:function(){this._content.forcePageUpdate()&&this._syncWithContent()},_dragEnd:function(e){var t=this,n=e.x.velocity,i=this.options.velocityThreshold,r=V,o=k(n)>this.options.bounceVelocityThreshold;n>i?r=U:-i>n&&(r=O),this._content.paneMoved(r,o,function(e){return t.trigger(E,e)})},_transitionEnd:function(){this._content.updatePage()&&this._syncWithContent()}}),h.plugin(c)}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e,t,n){return Math.max(t,Math.min(n,e))}var i=window.kendo,r=i.mobile.ui,o=r.Widget,a=i.support,s="change",l="km-switch-on",c="km-switch-off",d="margin-left",u="km-state-active",h="km-state-disabled",f="disabled",p=a.transitions.css+"transform",g=e.proxy,m=' {0} {1} ',v=o.extend({init:function(t,n){var r,a=this;o.fn.init.call(a,t,n),n=a.options,a.wrapper=e(i.format(m,n.onLabel,n.offLabel)),a.handle=a.wrapper.find(".km-switch-handle"),a.background=a.wrapper.find(".km-switch-background"),a.wrapper.insertBefore(a.element).prepend(a.element),a._drag(),a.origin=parseInt(a.background.css(d),10),a.constrain=0,a.snapPoint=0,t=a.element[0],t.type="checkbox",a._animateBackground=!0,r=a.options.checked,null===r&&(r=t.checked),a.check(r),a.options.enable=a.options.enable&&!a.element.attr(f),a.enable(a.options.enable),a.refresh(),i.notify(a,i.mobile.ui)},refresh:function(){var e=this,t=e.handle.outerWidth(!0);e.width=e.wrapper.width(),e.constrain=e.width-t,e.snapPoint=e.constrain/2,"number"!=typeof e.origin&&(e.origin=parseInt(e.background.css(d),10)),e.background.data("origin",e.origin),e.check(e.element[0].checked)},events:[s],options:{name:"Switch",onLabel:"on",offLabel:"off",checked:null,enable:!0},check:function(e){var n=this,i=n.element[0];return e===t?i.checked:(n._position(e?n.constrain:0),i.checked=e,n.wrapper.toggleClass(l,e).toggleClass(c,!e),t)},value:function(){return this.check.apply(this,arguments)},destroy:function(){o.fn.destroy.call(this),this.userEvents.destroy()},toggle:function(){var e=this;e.check(!e.element[0].checked)},enable:function(e){var n=this.element,i=this.wrapper;t===e&&(e=!0),this.options.enable=e,e?n.removeAttr(f):n.attr(f,f),i.toggleClass(h,!e)},_resize:function(){this.refresh()},_move:function(e){var t=this;e.preventDefault(),t._position(n(t.position+e.x.delta,0,t.width-t.handle.outerWidth(!0)))},_position:function(e){var t=this;t.position=e,t.handle.css(p,"translatex("+e+"px)"),t._animateBackground&&t.background.css(d,t.origin+e)},_start:function(){this.options.enable?(this.userEvents.capture(),this.handle.addClass(u)):this.userEvents.cancel()},_stop:function(){var e=this;e.handle.removeClass(u),e._toggle(e.position>e.snapPoint)},_toggle:function(e){var t,n=this,r=n.handle,o=n.element[0],a=o.checked,d=i.mobile.application&&i.mobile.application.os.wp?100:200;n.wrapper.toggleClass(l,e).toggleClass(c,!e),n.position=t=e*n.constrain,n._animateBackground&&n.background.kendoStop(!0,!0).kendoAnimate({effects:"slideMargin",offset:t,reset:!0,reverse:!e,axis:"left",duration:d}),r.kendoStop(!0,!0).kendoAnimate({effects:"slideTo",duration:d,offset:t+"px,0",reset:!0,complete:function(){a!==e&&(o.checked=e,n.trigger(s,{checked:e}))}})},_drag:function(){var e=this;e.userEvents=new i.UserEvents(e.wrapper,{tap:function(){e.options.enable&&e._toggle(!e.element[0].checked)},start:g(e._start,e),move:g(e._move,e),end:g(e._stop,e)})}});r.plugin(v)}(window.kendo.jQuery)}(),function(){!function(e){function t(t){return e(''+t+" ")}var n=window.kendo,i=n.mobile.ui,r=i.Widget,o="km-state-active",a="select",s=r.extend({init:function(t,n){var i=this;r.fn.init.call(i,t,n),i.container().bind("show",e.proxy(this,"refresh")),i.element.addClass("km-tabstrip").find("a").each(i._buildButton).eq(i.options.selectedIndex).addClass(o),i.element.on("down","a","_release")},events:[a],switchTo:function(t){var n,i,r=this.element.find("a"),o=0,a=r.length;if(!isNaN(t))return this._setActiveItem(r.eq(t)),!0;for(;a>o;o++)if(n=r[o],i=n.href.replace(/(\#.+)(\?.+)$/,"$1"),-1!==i.indexOf(t,i.length-t.length))return this._setActiveItem(e(n)),!0;return!1},switchByFullUrl:function(e){var t;t=this.element.find("a[href$='"+e+"']"),this._setActiveItem(t)},clear:function(){this.currentItem().removeClass(o)},currentItem:function(){return this.element.children("."+o)},badge:function(n,i){var r,o=this.element;return isNaN(n)||(n=o.children().get(n)),n=o.find(n),r=e(n.find(".km-badge")[0]||t(i).insertAfter(n.children(".km-icon"))),i||0===i?(r.html(i),this):i===!1?(r.empty().remove(),this):r.html()},_release:function(t){if(!(t.which>1)){var n=this,i=e(t.currentTarget);i[0]!==n.currentItem()[0]&&(n.trigger(a,{item:i})?t.preventDefault():n._setActiveItem(i))}},_setActiveItem:function(e){e[0]&&(this.clear(),e.addClass(o))},_buildButton:function(){var i=e(this),r=n.attrValue(i,"icon"),o=n.attrValue(i,"badge"),a=i.find("img"),s=e(' ');i.addClass("km-button").attr(n.attr("role"),"tab").contents().not(a).wrapAll(' '),a[0]?a.addClass("km-image").prependTo(i):(i.prepend(s),r&&(s.addClass("km-"+r),(o||0===o)&&t(o).insertAfter(s)))},refresh:function(e){var t=e.view.id;t&&!this.switchTo(e.view.id)&&this.switchTo(t)},options:{name:"TabStrip",selectedIndex:0,enable:!0}});i.plugin(s)}(window.kendo.jQuery)}(),function(){"bundle all"}();return window.kendo},typeof define=="function"&&define.amd?define:function(_,f){f()});