{"version":3,"sources":["kendo.dataviz.diagram.js"],"names":["f","define","$","objectKey","object","key","parts","push","sort","join","hashKey","str","i","hash","length","charCodeAt","zeroSize","width","height","baseline","measureText","text","style","measureBox","TextMetrics","current","measure","LRUCache","DEFAULT_OPTIONS","defaultMeasureBox","window","kendo","util","Class","extend","init","size","this","_size","_length","_map","put","value","map","entry","_head","_tail","newer","older","get","baselineMarkerSize","document","createElement","cssText","options","_cache","box","styleKey","cacheKey","cachedResult","baselineMarker","_baselineMarker","cloneNode","textContent","appendChild","body","String","offsetWidth","offsetHeight","offsetTop","parentNode","removeChild","marker","deepExtend","jQuery","amd","a1","a2","a3","undefined","Range","start","stop","step","rangeIntegerScale","x","k","range","j","Utils","sign","Infinity","Math","abs","findRadian","end","sngXComp","sngYComp","y","atan","PI","Easing","Ticker","diagram","dataviz","isArray","EPSILON","isNearZero","num","isDefined","obj","isUndefined","isObject","Object","has","hasOwnProperty","call","isString","prototype","toString","isBoolean","isType","type","isNumber","isNaN","parseFloat","isFinite","isEmpty","simpleExtend","destination","source","name","initArray","array","serializePoints","points","p","res","deserializePoints","s","v","split","Point","parseInt","randomInteger","lower","upper","floor","random","DFT","el","func","item","childNodes","getMatrixAngle","m","d","atan2","b","getMatrixScaling","sX","sqrt","a","c","sY","number","findAngle","center","forEach","arr","iterator","thisRef","any","predicate","remove","what","ax","indexOf","splice","contains","inArray","fold","list","acc","context","initial","arguments","find","result","index","first","constraint","insert","element","position","all","clear","bisort","sortfunc","n","addRange","apply","easeInOut","pos","cos","adapters","target","tick","interval","duration","lastTime","handlers","_this","transition","timerDelegate","onTimerEvent","addAdapter","onComplete","handler","removeHandler","grep","h","trigger","caller","onStep","seekTo","to","seekFromTo","from","max","min","Date","getTime","intervalId","setInterval","clearInterval","play","origin","initState","reverse","propagate","update","movement","now","timePassed","ui","intersectLine","start1","end1","start2","end2","isSegment","num1","num2","r","tangensdiff","normalVariable","mean","deviation","log","randomId","chars","charAt","round","PathDefiner","Rect","Size","Intersect","RectAlign","Polar","Matrix","MatrixVector","Geometry","HashTable","Dictionary","Queue","Set","Node","Link","Graph","Point2D","isFunction","HITTESTAREA","fn","plus","minus","offset","times","normalize","lengthSquared","middleOf","q","toPolar","useDegrees","halfpi","len","factor","isOnLine","temp","r1","r2","o1","u1","inflate","union","parse","tempStr","slice","xy","left","right","point","dx","dy","x1","y1","x2","y2","top","bottom","topLeft","topRight","bottomLeft","bottomRight","clone","equals","rect","rotatedBounds","angle","rotatedPoints","tl","tr","br","bl","rotate","delimiter","scale","scaleX","scaleY","staicPoint","adornerCenter","delta","scaled","thisCenter","zoom","overlaps","rectBottomRight","Empty","toRect","empty","fromPoints","lines","segments","rectWithLine","rects","rect1","rect2","intersect","reverseAngle","container","align","content","alignment","alignValues","toLowerCase","_singleAlign","_align","_left","_center","_right","stretch","_stretch","_top","middle","_middle","_bottom","alignCalc","e","applyRect","fromSVGMatrix","vm","fromMatrixVector","fromList","translation","unit","rotation","sin","scaling","nums","trim","substr","fromMatrix","_distanceToLineSquared","d2","pt1","pt2","vx","vy","dot","distanceToLine","distanceToPolyline","p1","p2","minimum","Number","MAX_VALUE","_buckets","add","_createGetBucket","_bucketExists","set","containsKey","hashId","_hash","bucket","hashes","_hashes","ht","_hashString","_objectHashId","ch","id","_hashId","Observable","dictionary","that","_hashTable","Error","forEachValue","forEachKey","keys","enqueue","next","dequeue","resource","kv","toArray","shape","links","outgoing","incoming","weight","associatedShape","bounds","data","shortForm","isVirtual","isIsolated","isLinkedTo","node","link","getComplement","getChildren","children","getParents","parents","copy","balance","owner","adjacentTo","removeLink","hasLinkTo","degree","incidentWith","getLinksWith","getNeighbors","neighbors","connection","sourceFound","targetFound","associatedConnection","getCommonNode","isBridging","v1","v2","getNodes","changeSource","changeTarget","changesNodes","w","oldSource","oldTarget","directTo","createReverseEdge","reversed","idOrDiagram","nodes","_nodeMap","_root","_hasCachedRelationships","cacheRelationships","forceRebuild","assignLevels","startNode","visited","child","level","root","found","getConnectedComponents","componentId","components","graph","componentIndex","setItemIndices","_collectConnectedNodes","addNodeAndOutgoings","setIds","nodeIndex","nextId","calcBounds","getSpanningTree","remaining","levelCount","ni","cn","newLink","treeLevels","tree","_addNode","pop","addLink","takeRandomNode","excludedNodes","incidenceLessThan","pool","isHealthy","hasNode","sourceOrLink","foundSource","foundTarget","addExistingLink","getNode","addNode","removeAllLinks","t","hasLink","linkOrId","nodeOrId","_removeNode","removeNode","areConnected","n1","n2","layoutRect","newNode","newLinks","saveMapping","save","nodeMap","linkMap","nOriginal","nCopy","linkOriginal","linkCopy","linearize","addIds","depthFirstTraversal","action","foundNode","_dftIterator","breadthFirstTraversal","queue","_stronglyConnectedComponents","excludeSingleItems","indices","lowLinks","connected","stack","component","findCycles","isAcyclic","isSubGraph","other","otherArray","thisArray","makeAcyclic","oneLink","oneNode","rev","N","intensityCatalog","flowIntensity","catalogEqualIntensity","sourceStack","targetStack","intensity","targets","li","targetLink","sources","si","sourceLink","maxdiff","ri","ril","u","vertexOrder","kk","reversedEdges","unshift","concat","Predefined","EightGraph","Mindmap","ThreeGraph","BinaryTree","levels","createBalancedTree","Linear","Tree","siblingsCount","Forest","trees","createBalancedForest","Workflow","Grid","previous","g","graphString","previousLink","part","lin","_addShape","kendoDiagram","shapeDefaults","radius","fill","undoable","addShape","_addConnection","connect","createDiagramFromGraph","doLayout","randomSize","opt","gli","sourceShape","targetShape","l","shi","clientWidth","clientHeight","color","SpringLayout","layoutGraph","limitToView","counter","lastAdded","news","parent","treeCount","createRandomConnectedGraph","nodeCount","maxIncidence","isTree","poolNode","randomAdditions","randomDiagram","shapeCount","diffNumericOptions","fields","field","elementOptions","hasChanges","sizeOptionsOrDefault","normalizeDrawingOptions","drawingOptions","getColor","TRANSPARENT","Color","toHex","lineAngle","xDiff","yDiff","deg","createSegment","Segment","toDrawingRect","Scale","Translation","Rotation","CompositeTransform","AutoSizeableMixin","Element","VisualBase","TextBlock","Rectangle","MarkerBase","CircleMarker","ArrowMarker","MarkerPathMixin","Path","Line","Polyline","Image","Group","Layout","Circle","Canvas","geometry","drawing","defined","Markers","none","arrowStart","filledCircle","arrowEnd","FULL_CIRCLE_ANGLE","START","END","WIDTH","HEIGHT","X","Y","toMatrix","format","invert","toMatrixVector","Length","ZERO","create","values","translate","transform","render","visual","_transform","_renderTransform","rotateMatrix","scaleMatrix","translatePoint","_setScale","originWidth","_originWidth","originHeight","_originHeight","_setTranslate","_initSize","autoSize","_measure","_updateSize","_diffNumericOptions","_originSize","visible","drawingContainer","redraw","drawingElement","matrix","_hover","force","startPoint","_measured","_boundingBox","rawBBox","stroke","opacity","_fill","_stroke","show","hover","strokeOptions","dashType","fillOptions","gradient","GradientClass","RadialGradient","LinearGradient","_textColor","_font","_initText","fontSize","fontFamily","Text","font","fontOptions","fontStyle","fontWeight","sizeChanged","textOptions","_initPath","_setPosition","_drawPath","closed","sizeOptions","elements","anchor","_transformToPath","path","transformCopy","positionMarker","targetSegment","_linePoints","endPoint","nextSegment","prevSegment","controlOut","controlIn","_getPath","MultiPath","paths","_normalizeMarkerOptions","startCap","endCap","_removeMarker","_markers","_createMarkers","_createMarker","markerType","append","_positionMarker","_capMap","_redrawMarker","pathChange","pathOptions","cap","pathCapType","optionsCap","created","_redrawMarkers","_createElements","_setData","multipath","_updatePath","_pointsDiffer","currentPoints","differ","_initImage","src","_rect","_childrenChange","_remove","removeAt","toFront","visuals","toBack","_reorderChildren","toIndex","group","drawingChildren","fixedPosition","boundingBox","childBoundingBox","_includeInBBox","clippedBBox","drawingRect","reflow","_initCircle","circleOptions","move","_circle","setRadius","surface","Surface","_translate","_viewBox","viewBox","setSize","draw","insertBefore","destroy","clearHtml","testKey","toUpperCase","hitToOppositeSide","hit","canDrag","editable","drag","hitTestShapeConnectors","connector","idx","connectors","HIT_TEST_DISTANCE","noMeta","meta","ctrlKey","altKey","shiftKey","PositionAdapter","LayoutUndoUnit","CompositeUnit","ConnectionEditUnit","ConnectionEditUndoUnit","DeleteConnectionUnit","DeleteShapeUnit","TransformUnit","AddConnectionUnit","AddShapeUnit","PanUndoUnit","RotateUnit","ToFrontUnit","ToBackUnit","UndoRedoService","EmptyTool","ScrollerTool","PointerTool","SelectionTool","ConnectionTool","ConnectionEditTool","ToolService","ConnectionRouterBase","LinearConnectionRouter","PolylineRouter","CascadingRouter","AdornerBase","ConnectionEditAdorner","ConnectorsAdorner","ResizingAdorner","Selector","ConnectorVisual","Movable","browser","support","proxy","Cursors","arrow","grip","cross","select","south","east","west","north","rowresize","colresize","AUTO","TOP","RIGHT","LEFT","BOTTOM","DEFAULT_SNAP_SIZE","DEFAULT_SNAP_ANGLE","DRAG_START","DRAG","DRAG_END","ITEMROTATE","ITEMBOUNDSCHANGE","MIN_SNAP_SIZE","MIN_SNAP_ANGLE","MOUSE_ENTER","MOUSE_LEAVE","ZOOM_START","ZOOM_END","SCROLL_MIN","SCROLL_MAX","FRICTION","FRICTION_MOBILE","VELOCITY_MULTIPLIER","PAN","ROTATED","SOURCE","TARGET","HANDLE_NAMES","-1","1","layoutState","pusher","getShapeById","subjects","froms","tos","initialState","finalState","animate","_initialState","_finalState","title","undo","setState","redo","state","ticker","conn","units","undoUnit","redoSource","redoTarget","_redoSource","_redoTarget","_undoSource","_undoTarget","_updateConnector","updateModel","undoSource","undoTarget","targetConnector","shapes","undoStates","adorner","redoStates","layout","refreshBounds","refresh","deselect","initialPosition","finalPosition","finalPos","pan","undoRotates","redoRotates","redoAngle","_angle","_innerBounds","_initialize","items","initialIndices","_toIndex","bind","events","capacity","begin","composite","cancel","commit","execute","_restart","addCompositeItem","count","toolService","tryActivate","getCursor","canvas","scroller","virtualScroll","tool","friction","mobileOS","scrollable","kendoMobileScroller","velocityMultiplier","mousewheelScrolling","scroll","_move","movableCanvas","dimension","makeVirtual","virtualSize","dimensions","disable","pannable","enabled","hoveredItem","hoveredAdorner","_hoveredConnector","enable","args","scrollPos","scrollLeft","scrollTop","_storePan","moveTo","_pan","selectSingle","handle","_hitTest","_resizingAdorner","isDragHandle","connections","undoRedoService","_getCursor","selectable","multiple","selector","isSelected","selectArea","_createConnection","_c","connectionHandle","_connectionManipulation","_removeHover","activeConnection","_cachedTouchTarget","cachedTouchTarget","sourceConnector","Shape","getConnector","_syncConnectionChanges","_connectorsAdorner","isActive","handleName","tools","activeTool","_updateHoveredItem","_activateTool","_updateCursor","focus","suspendTracking","updateHovered","resumeTracking","keyDown","toRemove","metaKey","_triggerRemove","_syncChanges","_destroyToolBar","_discardNewConnection","selectAll","cut","paste","wheel","z","zoomRate","zoomOptions","zoomMin","zoomMax","setTool","addToSelection","newConnection","cursor","css","msie","version","disabledShape","isNew","selectedConnections","_visible","_selectedItems","Connection","_hitTestItems","_hitTestElements","mainLayer","shapeIdx","connectionIdx","shapeHit","connectionHit","hitTest","rec","getBounds","allPoints","route","SAME_SIDE_DISTANCE_RATIO","routePoints","_connectorPoints","_floatingPoints","_resolvedSourceConnector","_resolvedTargetConnector","sourcePoint","targetPoint","_connectorSides","axis","boundsPoint","secondarySign","_connectorSide","sideDistance","minSide","side","shapeBounds","sides","MAX_NUM","_sameSideDistance","pointX","pointY","sourceConnectorSide","targetConnectorSide","deltaX","deltaY","sameSideDistance","shiftX","shiftY","cascadeStartHorizontal","_startHorizontal","sourceSide","horizontal","_adorners","sp","tp","_ts","spVisual","handles","epVisual","_initialSource","_initialTarget","ts","radiusX","radiusY","sourcePointDistance","distanceTo","targetPointDistance","sourceHandle","targetHandle","modelToLayer","_refreshHandler","ctr","_clearVisual","_keepCachedTouchTarget","visualChildren","childrenCount","unbind","each","_manipulating","_initSelection","_createHandles","selected","_internalChange","_rotatedHandler","_resizable","resize","_handleOptions","_bounds","handleBounds","handlesCount","_getHandleBounds","_rotationOffset","_startAngle","_rotates","_positions","initialRotates","initialStates","handleOptions","_sp","_cp","_lp","shapeStates","visibleHandles","currentAngle","dragging","newBounds","staticPoint","thr","newCenter","oldBounds","dtl","dbr","changed","_truncateAngle","_rotating","shouldSnap","_truncateDistance","_displaceBounds","minWidth","minHeight","states","_truncatePositionToGuides","ruler","truncatePositionToGuides","_truncateSizeToGuides","truncateSizeToGuides","snap","snapOptions","snapAngle","snapSize","_diffStates","_syncShapeChanges","thumb","rotationThumb","_rotationThumbBounds","_ep","_adorn","visualBounds","modelToView","relative","_visualBounds","HyperTree","DEG_TO_RAD","LayoutBase","defaultOptions","subtype","roots","nodeDistance","iterations","horizontalSeparation","verticalSeparation","underneathVerticalTopOffset","underneathHorizontalOffset","underneathVerticalSeparation","grid","offsetX","offsetY","componentSpacingX","componentSpacingY","layerSeparation","layeredIterations","startRadialAngle","endRadialAngle","radialSeparation","radialFirstLevelSeparation","keepComponentsInOneRadialLayout","ignoreContainers","layoutContainerChildren","ignoreInvisible","animateTransitions","gridLayoutComponents","maxWidth","startX","startY","resultLinkSet","resultNodeSet","boundingRect","currentHeight","currentWidth","moveToOffset","nodeBounds","newpoints","pt","deltax","deltay","currentHorizontalOffset","transferOptions","DiagramToHyperTreeAdapter","shapeMap","edges","edgeMap","finalNodes","finalLinks","ignoredConnections","ignoredShapes","hyperMap","hyperTree","finalGraph","convert","_renormalizeShapes","_renormalizeConnections","mapConnection","mapShape","getEdge","listToRoot","containerGraph","parentContainer","firstNonIgnorableContainer","isContainer","_isIgnorableItem","isContainerConnection","isDescendantOf","scope","containers","isIgnorableItem","isCollapsed","_isVisible","_isTop","isShapeMapped","leastCommonAncestor","al","xa","xb","_isCollapsed","sink","sourceNode","sinkNode","newEdge","areConnectedAlready","adapter","finalNodeSet","LayoutState","initialTemperature","guessBounds","temperature","_expectedBounds","refineStage","_repulsion","_attraction","_shake","rho","alpha","_InverseSquareForce","wn","hn","wm","hm","pow","_SquareForce","distance","av","squareSize","ratio","multiplier","area","ceil","TreeLayoutProcessor","treeGraph","layoutSwitch","layoutLeft","setChildrenDirection","setChildrenLayout","TreeDirection","Width","arrange","layoutRight","layoutUp","up","layoutDown","down","treeDirection","layoutRadialTree","startAngle","endAngle","previousRoot","maxDepth","calculateAngularWidth","radialLayout","Angle","tipOverTree","startFromLevel","aw","diameter","sectorAngle","sortChildren","pl","nl","col","basevalue","normalizeAngle","childNode","cp","childAngleFraction","deltaTheta","deltaThetaHalf","parentSector","fraction","sorted","setPolarLocation","BoundingRectangle","direction","includeStart","rootDirection","rootLayout","childrenLayout","givenSize","shapeWidth","shapeHeight","AngleToParent","SectorAngle","pp","childrenwidth","selfLocation","single","male","female","leftcount","tipOverTreeStartLevel","TreeLayout","layoutComponents","getTree","givenRootShape","getTreeForRoot","LayeredLayout","_initRuntimeProperties","layer","downstreamLinkCount","upstreamLinkCount","uBaryCenter","dBaryCenter","upstreamPriority","downstreamPriority","gridPosition","_prepare","targetLayer","sortedNodes","minLayer","layerMap","layerCount","shift","o2","o1layer","o2layer","layers","linksTo","_dummify","_optimizeCrossings","_swapPairs","arrangeNodes","_moveThingsAround","_dedummify","setMinDist","minDist","layerIndex","minDistances","getMinDist","dist","i1","i2","placeLeftToRight","leftClasses","classNodes","rightSibling","D","neighbor","leftPos","placeLeft","POSITIVE_INFINITY","nodeLeftClass","upNodes","downNodes","intDiv","placeRightToLeft","rightClasses","leftSibling","rightPos","placeRight","NEGATIVE_INFINITY","nodeRightClass","_getLeftWing","leftWing","computeClasses","_getRightWing","rightWing","wingPair","ndsinl","vnode","wings","currentWing","wing","_nodesInLink","classIndex","_isVerticalLayout","_isHorizontalLayout","_isIncreasingLayout","maximumHeight","ctx","MIN_VALUE","currentNode","currDown","downNode","order","placed","sequenceStart","sequenceEnd","directions","fromLayerIndex","reachedFinalLayerIndex","layerIncrement","_gridPositionComparer","dest","virtualStartIndex","virtualStart","sequence","virtualEnd","virtualEndIndex","_firstVirtualNode","_sequencer","nextVirtualNode","adjustDirections","prevBridge","prevBridgeTarget","nextBridge","nextBridgeTarget","clayer","j1","j2","getNeighborOnLayer","dir","_sequenceSingle","combineSequences","pair","rightHeap","leftRes","rightRes","leftHeap","_positionDescendingComparer","_positionAscendingComparer","leftClass","_getComposite","rightClass","maxLayoutIterations","it","gridPos","layoutLayer","iconsidered","considered","n1Priority","n2Priority","nodeGridPos","nodeBaryCenter","calcBaryCenter","nodePriority","moveRight","moveLeft","calcDownData","calcUpData","priority","rightNode","rightNodePriority","leftNode","leftNodePriority","mapVirtualNode","nodeToLinkMap","linkToNodeMap","addLinkBetweenLayers","o","oLayer","dLayer","oPos","dPos","upLayer","downLayer","depthOfDumminess","prevLink","dedum","moves","maxIterations","iter","optimizeLayerCrossings","sum","total","presorted","inode","compareValue","n1BaryCenter","n2BaryCenter","compareByIndex","downwards","secondPass","hasSwapped","calcCrossings","memCrossings","crossBefore","node1","node2","node1GridPos","node2GridPos","crossAfter","revert","countLinksCrossingBetweenTwoLayers","ulayer","dlayer","link1","link2","n11","n12","n21","n22","l1","l2","n11gp","n12gp","n21gp","n22gp","crossings","numerator","denominator","graphOrNodes","capture","diagramOrGraphOrNodes","Array","GraphAdapter","mwDelta","origEvent","originalEvent","wheelDelta","math","detail","isAutoConnector","closestConnector","resCtr","minimumDistance","MAXINT","indicesOfItems","filterShapeDataItem","dataItem","filterConnectionDataItem","fromConnector","fromX","fromY","toConnector","toX","toY","connectionSelector","textField","model","dataSource","reader","idField","appendTo","kendoDropDownList","dataValueField","dataTextField","toJSON","optionLabel","valuePrimitive","InactiveItem","callbacks","InactiveItemsCollection","cloneDataItem","Model","_defaultId","splitDiagramElements","createModel","ObservableObject","clearField","copyDefaultOptions","mainOptions","translateToOrigin","bbox","preventDefault","defaultButtons","DiagramElement","Connector","Diagram","DiagramToolBar","Editor","PopupEditor","QuadRoot","QuadNode","ShapesQuadTree","geom","Widget","outerWidth","_outerWidth","outerHeight","_outerHeight","HierarchicalDataSource","isPlainObject","SASS_THEMES","NS","CASCADING","CHANGE","CLICK","ERROR","SELECT","NONE","DEFAULT_CANVAS_WIDTH","DEFAULT_CANVAS_HEIGHT","DEFAULT_SHAPE_TYPE","DEFAULT_SHAPE_WIDTH","DEFAULT_SHAPE_HEIGHT","DEFAULT_SHAPE_MINWIDTH","DEFAULT_SHAPE_MINHEIGHT","DEFAULT_SHAPE_POSITION","DEFAULT_CONNECTION_BACKGROUND","ABSOLUTE","TRANSFORMED","MOUSEWHEEL_NS","MOBILE_ZOOM_RATE","MOBILE_PAN_DISTANCE","BUTTON_TEMPLATE","CONNECTION_CONTENT_OFFSET","DefaultConnectors","getPosition","imageClass","className","iconClass","extra","defaults","_template","serializable","serialize","json","_content","contentOptions","contentVisual","_contentVisual","_updateContentVisual","_createContentVisual","elementTemplate","template","paramName","_canSelect","shapeId","updateOptionsFromModel","createShapeVisual","updateBounds","_createConnectors","_setOptionsFromModel","modelOptions","redrawVisual","_isEditable","_redrawVisual","syncChanges","_suspendModelRefresh","_resumeModelRefresh","_rotate","_alignContent","containerRect","aligner","contentBounds","contentRect","alignedBounds","connectorDefaults","_transformedBounds","_rotatedBounds","_setBounds","_triggerBoundsChange","_layouting","refreshConnections","deselected","_internalSelection","_selectionChanged","sc","deltaAngle","newPosition","con","cons","nameOrPoint","toLocaleLowerCase","fnName","_transformPoint","shapeOptions","boundsChange","shapeVisual","_visualOptions","_updateConnectors","_showConnectors","rotatedPoint","visualOptions","visualTemplate","_initRouter","_sourcePoint","_targetPoint","_setSource","_setTarget","definers","dataMap","_dataMap","connectionsDataSource","getByUid","uid","shapeSource","defaultConnector","_removeFromSourceConnector","_clearSourceConnector","_setFromOptions","fromPoint","sourceDefiner","_sourceDefiner","shapeTarget","_removeFromTargetConnector","_clearTargetConnector","_setToOptions","toPoint","targetDefiner","_targetDefiner","instance","connectorName","setNewTarget","inactiveItem","_inactiveShapeItems","_deferredConnectionUpdates","onActivate","endIdx","startIdx","alignToPath","midIdx","selection","_router","definition","pts","_resolveConnectors","_refreshPath","sourceConnectors","targetConnectors","_resolveAutoConnectors","minNonConflictSource","minNonConflictTarget","minSource","minTarget","sourceIdx","targetIdx","minNonConflict","_testRoutePoints","exclude","router","passRoute","_getRouteExclude","_shapesQuadTree","hitTestRect","_isPointInsideShape","boundsX","boundsY","userOptions","_initTheme","_initElements","_extendLayoutOptions","_initDefaults","_interactionDefaults","_initCanvas","adornerLayer","_createHandlers","_clipboard","pauseMouseHandlers","_fetchFreshData","_createGlobalToolBar","_createOptionElements","theme","draggable","autoBind","tooltip","connectionDefaults","toolBar","click","_toolBarClick","modal","textAlign","prepend","_resize","createShape","view","editor","_createShape","edit","createConnection","_connectionsDataMap","addConnection","editModel","editorType","editors","connectionSelectorHandler","cancelEdit","shapeEditors","shapeTemplate","connectionEditors","connectionTemplate","_update","_cancel","_editArgs","_getEditDataSource","cancelChanges","_destroyEditor","saveEdit","sync","wrapper","close","attr","addClass","userShapeDefaults","mobile","canvasContainer","viewPort","viewport","on","_wheel","_keydown","_userEvents","UserEvents","multiTouch","fastTap","tap","_tap","_dragStart","_drag","_dragEnd","gesturestart","_gestureStart","gesturechange","_gestureChange","gestureend","_gestureEnd","_mouseover","_mouseout","_mouseMove","_mouseDown","_mouseUp","_syncHandler","_resizeHandler","onResize","event","_pauseMouseHandlers","_eventPositions","_meta","_createToolBar","ctrlPressed","focused","keyCode","touch","pageX","pageY","documentToModel","initialCenter","eventArgs","_gesture","_initialCenter","zoomedPoint","previousGesture","documentToView","scaleDelta","_zoom","updateZoom","_getValidZoom","_panTransform","_updateAdorners","_kendoNode","srcElement","themeOptions","themeName","themes","autoTheme","shapesLength","_createShapes","_createConnections","_findConnectionTarget","unbindResize","off","destroyScroller","_destroyGlobalToolBar","is","_activeElement","scrollContainer","offsets","documentElement","scrollHeight","load","setOptions","added","removed","_removeItem","_removeShapeDataItem","_removeConnectionDataItem","_getDiagramItems","_fixOrdering","bringIntoView","original","newPan","_zoomMainLayer","alignShapes","val","viewportVector","raw","hideTooltip","_getPan","animatedScrollTo","scrollTo","_copyOffset","copied","mapping","_updateCopiedConnection","sourceConnection","di","_containerOffset","containerOffset","viewToDocument","viewToModel","_transformWithMatrix","_matrixInvert","_matrix","_layerMatrix","layerToModel","_layerMatrixInvert","viewPoint","modelToDocument","setDataSource","_dataSource","fetch","setConnectionsDataSource","_connectionDataSource","_redrawConnections","getShapeByModelId","getShapeByModelUid","getConnectionByModelId","getConnectionByModelUid","_transformMainLayer","_finishPan","NaN","_storeViewMatrix","_storeLayerMatrix","canvasTransform","shapePos","conPos","removedConnections","_removeShape","_removeConnection","_removeDataItems","recursive","_removeShapeConnections","hasChildren","loaded","_addDataItem","_addDataItemByUid","_addDataItems","parentShape","_refreshSource","dataBound","_bindingRoots","_addItem","preventClosing","padding","popupWidth","popupHeight","connectionBounds","singleToolBar","_popup","showAt","one","_normalizePointZoom","undone","redone","_loadingShapes","_loadingConnections","dsOptions","ds","_shapesRefreshHandler","_shapesRequestStartHandler","_shapesErrorHandler","_refreshShapes","_shapesRequestStart","_error","DataSource","_treeDataSource","_connectionsRefreshHandler","_connectionsRequestStartHandler","_connectionsErrorHandler","_refreshConnections","_connectionsRequestStart","_connectionsError","_shouldRefresh","_removeShapes","_updateShapes","_syncShapes","_suspended","_rebindShapesAndConnections","_addShapes","_addConnections","inactiveItems","activate","dataItems","_removeConnections","_updateConnections","_addConnectionDataItem","_validateConnector","_unbindDataSource","_errorHandler","adorners","_refresh","hide","exportDOMVisual","scrollOffset","viewRect","clipPath","fromRect","wrap","clipWrap","clip","exportVisual","when","then","deferredConnectionUpdates","ExportMixin","PDFMixin","_tools","createToolBar","createTools","appendTools","createPopup","kendoPopup","getKendoPopup","buttons","_toolBar","kendoToolBar","resizable","getKendoToolBar","createTool","toolName","attributes","_setAttributes","open","newGroup","editTool","icon","showText","deleteTool","rotateAnticlockwiseTool","_appendGroup","_rotateGroup","rotateClockwiseTool","createShapeTool","_createGroup","createConnectionTool","undoTool","_historyGroup","redoTool","prop","_getAttributes","eventData","selectedElements","delete","selectedElemens","rotateClockwise","rotateAnticlockwise","_getFields","_initContainer","createEditable","Editable","clearContainer","modelFields","columns","formContent","_renderTemplate","_renderFields","_renderButtons","Window","userTriggered","sender","_cancelClick","_attachButtonEvents","unescape","form","_createButton","_cancelClickHandler","_updateClickHandler","_updateClick","_editUpdateClickHandler","callback","deffered","Deferred","deferred","resolve","_add","_quadNode","_testRect","inBounds","nodeRect","nodeBottomRight","overlapsBounds","inserted","_initChildren","childIdx","halfWidth","halfHeight","ROOT_SIZE","boundsChangeHandler","_boundsChange","initRoots","rootMap","rootSize","sectors","getSectors","inRoot","bottomX","bottomY","xIdx","yIdx","plugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,qBAAsB,cAAeD,IAC9C,YACG,SAAUE,GAmDP,QAASC,GAAUC,GAAnB,GAEaC,GADLC,IACJ,KAASD,IAAOD,GACZE,EAAMC,KAAKF,EAAMD,EAAOC,GAE5B,OAAOC,GAAME,OAAOC,KAAK,IAE7B,QAASC,GAAQC,GAAjB,GAEaC,GADLC,EAAO,UACX,KAASD,EAAI,EAAGA,EAAID,EAAIG,SAAUF,EAC9BC,IAASA,GAAQ,IAAMA,GAAQ,IAAMA,GAAQ,IAAMA,GAAQ,IAAMA,GAAQ,IACzEA,GAAQF,EAAII,WAAWH,EAE3B,OAAOC,KAAS,EAEpB,QAASG,KACL,OACIC,MAAO,EACPC,OAAQ,EACRC,SAAU,GAsDlB,QAASC,GAAYC,EAAMC,EAAOC,GAC9B,MAAOC,GAAYC,QAAQC,QAAQL,EAAMC,EAAOC,GA7HvD,GAEOI,GAuEAC,EACAC,EAKAL,CA9EJM,QAAOC,MAAMC,KAAOF,OAAOC,MAAMC,SAC7BL,EAAWI,MAAME,MAAMC,QACvBC,KAAM,SAAUC,GACZC,KAAKC,MAAQF,EACbC,KAAKE,QAAU,EACfF,KAAKG,SAETC,IAAK,SAAUpC,EAAKqC,GAAf,GACGC,GAAMN,KAAKG,KACXI,GACAvC,IAAKA,EACLqC,MAAOA,EAEXC,GAAItC,GAAOuC,EACNP,KAAKQ,OAGNR,KAAKS,MAAMC,MAAQH,EACnBA,EAAMI,MAAQX,KAAKS,MACnBT,KAAKS,MAAQF,GAJbP,KAAKQ,MAAQR,KAAKS,MAAQF,EAM1BP,KAAKE,SAAWF,K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,QAAUa,GAC3B+Y,GAAQA,EAAK60C,YAAYx/C,EAAMm/C,GAC/B,OAAO,CAInB,QAAO,KAyDfjtD,EAAQ6I,GAAGs7D,OAAOphB,GAClB9kD,EAAW8B,GACP48B,MAAOA,EACP2C,WAAYA,EACZwjB,UAAWA,EACXE,eAAgBA,EAChBI,SAAUA,EACVD,SAAUA,EACVE,eAAgBA,EAChBH,YAAaA,KAEnB5nD,OAAOC,MAAM2C,SACC,kBAAVzE,SAAwBA,OAAO0E,IAAM1E,OAAS,SAAU2E,EAAIC,EAAIC,IACrEA,GAAMD,OAEV,SAAU7E,EAAGC,QACVA,OAAO,yBACH,aACA,oBACA,mBACA,wBACA,gBACA,wBACA,uBACA,sBACA,2BACA,yBACA,uBACDD,IACL,WAmCE,MAAO8B,QAAOC,OACE,kBAAV9B,SAAwBA,OAAO0E,IAAM1E,OAAS,SAAU2E,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.dataviz.diagram.min.js","sourcesContent":["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('util/text-metrics', ['kendo.core'], f);\n}(function () {\n (function ($) {\n window.kendo.util = window.kendo.util || {};\n var LRUCache = kendo.Class.extend({\n init: function (size) {\n this._size = size;\n this._length = 0;\n this._map = {};\n },\n put: function (key, value) {\n var map = this._map;\n var entry = {\n key: key,\n value: value\n };\n map[key] = entry;\n if (!this._head) {\n this._head = this._tail = entry;\n } else {\n this._tail.newer = entry;\n entry.older = this._tail;\n this._tail = entry;\n }\n if (this._length >= this._size) {\n map[this._head.key] = null;\n this._head = this._head.newer;\n this._head.older = null;\n } else {\n this._length++;\n }\n },\n get: function (key) {\n var entry = this._map[key];\n if (entry) {\n if (entry === this._head && entry !== this._tail) {\n this._head = entry.newer;\n this._head.older = null;\n }\n if (entry !== this._tail) {\n if (entry.older) {\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n }\n entry.older = this._tail;\n entry.newer = null;\n this._tail.newer = entry;\n this._tail = entry;\n }\n return entry.value;\n }\n }\n });\n function objectKey(object) {\n var parts = [];\n for (var key in object) {\n parts.push(key + object[key]);\n }\n return parts.sort().join('');\n }\n function hashKey(str) {\n var hash = 2166136261;\n for (var i = 0; i < str.length; ++i) {\n hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);\n hash ^= str.charCodeAt(i);\n }\n return hash >>> 0;\n }\n function zeroSize() {\n return {\n width: 0,\n height: 0,\n baseline: 0\n };\n }\n var DEFAULT_OPTIONS = { baselineMarkerSize: 1 };\n var defaultMeasureBox;\n if (typeof document !== 'undefined') {\n defaultMeasureBox = document.createElement('div');\n defaultMeasureBox.style.cssText = 'position: absolute !important; top: -4000px !important; width: auto !important; height: auto !important;' + 'padding: 0 !important; margin: 0 !important; border: 0 !important;' + 'line-height: normal !important; visibility: hidden !important; white-space: nowrap!important;';\n }\n var TextMetrics = kendo.Class.extend({\n init: function (options) {\n this._cache = new LRUCache(1000);\n this.options = $.extend({}, DEFAULT_OPTIONS, options);\n },\n measure: function (text, style, box) {\n if (!text) {\n return zeroSize();\n }\n var styleKey = objectKey(style);\n var cacheKey = hashKey(text + styleKey);\n var cachedResult = this._cache.get(cacheKey);\n if (cachedResult) {\n return cachedResult;\n }\n var size = zeroSize();\n var measureBox = box || defaultMeasureBox;\n var baselineMarker = this._baselineMarker().cloneNode(false);\n for (var key in style) {\n var value = style[key];\n if (typeof value !== 'undefined') {\n measureBox.style[key] = value;\n }\n }\n measureBox.textContent = text;\n measureBox.appendChild(baselineMarker);\n document.body.appendChild(measureBox);\n if (String(text).length) {\n size.width = measureBox.offsetWidth - this.options.baselineMarkerSize;\n size.height = measureBox.offsetHeight;\n size.baseline = baselineMarker.offsetTop + this.options.baselineMarkerSize;\n }\n if (size.width > 0 && size.height > 0) {\n this._cache.put(cacheKey, size);\n }\n measureBox.parentNode.removeChild(measureBox);\n return size;\n },\n _baselineMarker: function () {\n var marker = document.createElement('div');\n marker.style.cssText = 'display: inline-block; vertical-align: baseline;width: ' + this.options.baselineMarkerSize + 'px; height: ' + this.options.baselineMarkerSize + 'px;overflow: hidden;';\n return marker;\n }\n });\n TextMetrics.current = new TextMetrics();\n function measureText(text, style, measureBox) {\n return TextMetrics.current.measure(text, style, measureBox);\n }\n kendo.deepExtend(kendo.util, {\n LRUCache: LRUCache,\n TextMetrics: TextMetrics,\n measureText: measureText,\n objectKey: objectKey,\n hashKey: hashKey\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('dataviz/diagram/utils', ['kendo.core'], f);\n}(function () {\n (function ($, undefined) {\n var kendo = window.kendo, diagram = kendo.dataviz.diagram = {}, deepExtend = kendo.deepExtend, isArray = $.isArray, EPSILON = 0.000001;\n var Utils = {};\n deepExtend(Utils, {\n isNearZero: function (num) {\n return Math.abs(num) < EPSILON;\n },\n isDefined: function (obj) {\n return typeof obj !== 'undefined';\n },\n isUndefined: function (obj) {\n return typeof obj === 'undefined' || obj === null;\n },\n isObject: function (obj) {\n return obj === Object(obj);\n },\n has: function (obj, key) {\n return Object.hasOwnProperty.call(obj, key);\n },\n isString: function (obj) {\n return Object.prototype.toString.call(obj) == '[object String]';\n },\n isBoolean: function (obj) {\n return Object.prototype.toString.call(obj) == '[object Boolean]';\n },\n isType: function (obj, type) {\n return Object.prototype.toString.call(obj) == '[object ' + type + ']';\n },\n isNumber: function (obj) {\n return !isNaN(parseFloat(obj)) && isFinite(obj);\n },\n isEmpty: function (obj) {\n if (obj === null) {\n return true;\n }\n if (isArray(obj) || Utils.isString(obj)) {\n return obj.length === 0;\n }\n for (var key in obj) {\n if (Utils.has(obj, key)) {\n return false;\n }\n }\n return true;\n },\n simpleExtend: function (destination, source) {\n if (!Utils.isObject(source)) {\n return;\n }\n for (var name in source) {\n destination[name] = source[name];\n }\n },\n initArray: function createIdArray(size, value) {\n var array = [];\n for (var i = 0; i < size; ++i) {\n array[i] = value;\n }\n return array;\n },\n serializePoints: function (points) {\n var res = [];\n for (var i = 0; i < points.length; i++) {\n var p = points[i];\n res.push(p.x + ';' + p.y);\n }\n return res.join(';');\n },\n deserializePoints: function (s) {\n var v = s.split(';'), points = [];\n if (v.length % 2 !== 0) {\n throw 'Not an array of points.';\n }\n for (var i = 0; i < v.length; i += 2) {\n points.push(new diagram.Point(parseInt(v[i], 10), parseInt(v[i + 1], 10)));\n }\n return points;\n },\n randomInteger: function (lower, upper) {\n return parseInt(Math.floor(Math.random() * upper) + lower, 10);\n },\n DFT: function (el, func) {\n func(el);\n if (el.childNodes) {\n for (var i = 0; i < el.childNodes.length; i++) {\n var item = el.childNodes[i];\n this.DFT(item, func);\n }\n }\n },\n getMatrixAngle: function (m) {\n if (m === null || m.d === 0) {\n return 0;\n }\n return Math.atan2(m.b, m.d) * 180 / Math.PI;\n },\n getMatrixScaling: function (m) {\n var sX = Math.sqrt(m.a * m.a + m.c * m.c);\n var sY = Math.sqrt(m.b * m.b + m.d * m.d);\n return [\n sX,\n sY\n ];\n }\n });\n function Range(start, stop, step) {\n if (typeof start == 'undefined' || typeof stop == 'undefined') {\n return [];\n }\n if (step && Utils.sign(stop - start) != Utils.sign(step)) {\n throw 'The sign of the increment should allow to reach the stop-value.';\n }\n step = step || 1;\n start = start || 0;\n stop = stop || start;\n if ((stop - start) / step === Infinity) {\n throw 'Infinite range defined.';\n }\n var range = [], i = -1, j;\n function rangeIntegerScale(x) {\n var k = 1;\n while (x * k % 1) {\n k *= 10;\n }\n return k;\n }\n var k = rangeIntegerScale(Math.abs(step));\n start *= k;\n stop *= k;\n step *= k;\n if (start > stop && step > 0) {\n step = -step;\n }\n if (step < 0) {\n while ((j = start + step * ++i) >= stop) {\n range.push(j / k);\n }\n } else {\n while ((j = start + step * ++i) <= stop) {\n range.push(j / k);\n }\n }\n return range;\n }\n function findRadian(start, end) {\n if (start == end) {\n return 0;\n }\n var sngXComp = end.x - start.x, sngYComp = start.y - end.y, atan = Math.atan(sngXComp / sngYComp);\n if (sngYComp >= 0) {\n return sngXComp < 0 ? atan + 2 * Math.PI : atan;\n }\n return atan + Math.PI;\n }\n Utils.sign = function (number) {\n return number ? number < 0 ? -1 : 1 : 0;\n };\n Utils.findAngle = function (center, end) {\n return findRadian(center, end) * 180 / Math.PI;\n };\n Utils.forEach = function (arr, iterator, thisRef) {\n for (var i = 0; i < arr.length; i++) {\n iterator.call(thisRef, arr[i], i, arr);\n }\n };\n Utils.any = function (arr, predicate) {\n for (var i = 0; i < arr.length; ++i) {\n if (predicate(arr[i])) {\n return arr[i];\n }\n }\n return null;\n };\n Utils.remove = function (arr, what) {\n var ax;\n while ((ax = Utils.indexOf(arr, what)) !== -1) {\n arr.splice(ax, 1);\n }\n return arr;\n };\n Utils.contains = function (arr, obj) {\n return Utils.indexOf(arr, obj) !== -1;\n };\n Utils.indexOf = function (arr, what) {\n return $.inArray(what, arr);\n };\n Utils.fold = function (list, iterator, acc, context) {\n var initial = arguments.length > 2;\n for (var i = 0; i < list.length; i++) {\n var value = list[i];\n if (!initial) {\n acc = value;\n initial = true;\n } else {\n acc = iterator.call(context, acc, value, i, list);\n }\n }\n if (!initial) {\n throw 'Reduce of empty array with no initial value';\n }\n return acc;\n };\n Utils.find = function (arr, iterator, context) {\n var result;\n Utils.any(arr, function (value, index, list) {\n if (iterator.call(context, value, index, list)) {\n result = value;\n return true;\n }\n return false;\n });\n return result;\n };\n Utils.first = function (arr, constraint, context) {\n if (arr.length === 0) {\n return null;\n }\n if (Utils.isUndefined(constraint)) {\n return arr[0];\n }\n return Utils.find(arr, constraint, context);\n };\n Utils.insert = function (arr, element, position) {\n arr.splice(position, 0, element);\n return arr;\n };\n Utils.all = function (arr, iterator, context) {\n var result = true;\n var value;\n for (var i = 0; i < arr.length; i++) {\n value = arr[i];\n result = result && iterator.call(context, value, i, arr);\n if (!result) {\n break;\n }\n }\n return result;\n };\n Utils.clear = function (arr) {\n arr.splice(0, arr.length);\n };\n Utils.bisort = function (a, b, sortfunc) {\n if (Utils.isUndefined(a)) {\n throw 'First array is not specified.';\n }\n if (Utils.isUndefined(b)) {\n throw 'Second array is not specified.';\n }\n if (a.length != b.length) {\n throw 'The two arrays should have equal length';\n }\n var all = [], i;\n for (i = 0; i < a.length; i++) {\n all.push({\n 'x': a[i],\n 'y': b[i]\n });\n }\n if (Utils.isUndefined(sortfunc)) {\n all.sort(function (m, n) {\n return m.x - n.x;\n });\n } else {\n all.sort(function (m, n) {\n return sortfunc(m.x, n.x);\n });\n }\n Utils.clear(a);\n Utils.clear(b);\n for (i = 0; i < all.length; i++) {\n a.push(all[i].x);\n b.push(all[i].y);\n }\n };\n Utils.addRange = function (arr, range) {\n arr.push.apply(arr, range);\n };\n var Easing = {\n easeInOut: function (pos) {\n return -Math.cos(pos * Math.PI) / 2 + 0.5;\n }\n };\n var Ticker = kendo.Class.extend({\n init: function () {\n this.adapters = [];\n this.target = 0;\n this.tick = 0;\n this.interval = 20;\n this.duration = 800;\n this.lastTime = null;\n this.handlers = [];\n var _this = this;\n this.transition = Easing.easeInOut;\n this.timerDelegate = function () {\n _this.onTimerEvent();\n };\n },\n addAdapter: function (a) {\n this.adapters.push(a);\n },\n onComplete: function (handler) {\n this.handlers.push(handler);\n },\n removeHandler: function (handler) {\n this.handlers = $.grep(this.handlers, function (h) {\n return h !== handler;\n });\n },\n trigger: function () {\n var _this = this;\n if (this.handlers) {\n Utils.forEach(this.handlers, function (h) {\n return h.call(_this.caller !== null ? _this.caller : _this);\n });\n }\n },\n onStep: function () {\n },\n seekTo: function (to) {\n this.seekFromTo(this.tick, to);\n },\n seekFromTo: function (from, to) {\n this.target = Math.max(0, Math.min(1, to));\n this.tick = Math.max(0, Math.min(1, from));\n this.lastTime = new Date().getTime();\n if (!this.intervalId) {\n this.intervalId = window.setInterval(this.timerDelegate, this.interval);\n }\n },\n stop: function () {\n if (this.intervalId) {\n window.clearInterval(this.intervalId);\n this.intervalId = null;\n this.trigger();\n }\n },\n play: function (origin) {\n if (this.adapters.length === 0) {\n return;\n }\n if (origin !== null) {\n this.caller = origin;\n }\n this.initState();\n this.seekFromTo(0, 1);\n },\n reverse: function () {\n this.seekFromTo(1, 0);\n },\n initState: function () {\n if (this.adapters.length === 0) {\n return;\n }\n for (var i = 0; i < this.adapters.length; i++) {\n this.adapters[i].initState();\n }\n },\n propagate: function () {\n var value = this.transition(this.tick);\n for (var i = 0; i < this.adapters.length; i++) {\n this.adapters[i].update(value);\n }\n },\n onTimerEvent: function () {\n var now = new Date().getTime();\n var timePassed = now - this.lastTime;\n this.lastTime = now;\n var movement = timePassed / this.duration * (this.tick < this.target ? 1 : -1);\n if (Math.abs(movement) >= Math.abs(this.tick - this.target)) {\n this.tick = this.target;\n } else {\n this.tick += movement;\n }\n try {\n this.propagate();\n } finally {\n this.onStep.call(this);\n if (this.target == this.tick) {\n this.stop();\n }\n }\n }\n });\n kendo.deepExtend(diagram, {\n init: function (element) {\n kendo.init(element, diagram.ui);\n },\n Utils: Utils,\n Range: Range,\n Ticker: Ticker\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('dataviz/diagram/math', [\n 'dataviz/diagram/utils',\n 'kendo.dataviz.core'\n ], f);\n}(function () {\n (function ($, undefined) {\n var kendo = window.kendo, diagram = kendo.dataviz.diagram, Class = kendo.Class, deepExtend = kendo.deepExtend, dataviz = kendo.dataviz, Utils = diagram.Utils, Point = dataviz.Point2D, isFunction = kendo.isFunction, contains = Utils.contains, map = $.map;\n var HITTESTAREA = 3, EPSILON = 0.000001;\n deepExtend(Point.fn, {\n plus: function (p) {\n return new Point(this.x + p.x, this.y + p.y);\n },\n minus: function (p) {\n return new Point(this.x - p.x, this.y - p.y);\n },\n offset: function (value) {\n return new Point(this.x - value, this.y - value);\n },\n times: function (s) {\n return new Point(this.x * s, this.y * s);\n },\n normalize: function () {\n if (this.length() === 0) {\n return new Point();\n }\n return this.times(1 / this.length());\n },\n length: function () {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n toString: function () {\n return '(' + this.x + ',' + this.y + ')';\n },\n lengthSquared: function () {\n return this.x * this.x + this.y * this.y;\n },\n middleOf: function MiddleOf(p, q) {\n return new Point(q.x - p.x, q.y - p.y).times(0.5).plus(p);\n },\n toPolar: function (useDegrees) {\n var factor = 1;\n if (useDegrees) {\n factor = 180 / Math.PI;\n }\n var a = Math.atan2(Math.abs(this.y), Math.abs(this.x));\n var halfpi = Math.PI / 2;\n var len = this.length();\n if (this.x === 0) {\n if (this.y === 0) {\n return new Polar(0, 0);\n }\n if (this.y > 0) {\n return new Polar(len, factor * halfpi);\n }\n if (this.y < 0) {\n return new Polar(len, factor * 3 * halfpi);\n }\n } else if (this.x > 0) {\n if (this.y === 0) {\n return new Polar(len, 0);\n }\n if (this.y > 0) {\n return new Polar(len, factor * a);\n }\n if (this.y < 0) {\n return new Polar(len, factor * (4 * halfpi - a));\n }\n } else {\n if (this.y === 0) {\n return new Polar(len, 2 * halfpi);\n }\n if (this.y > 0) {\n return new Polar(len, factor * (2 * halfpi - a));\n }\n if (this.y < 0) {\n return new Polar(len, factor * (2 * halfpi + a));\n }\n }\n },\n isOnLine: function (from, to) {\n if (from.x > to.x) {\n var temp = to;\n to = from;\n from = temp;\n }\n var r1 = new Rect(from.x, from.y).inflate(HITTESTAREA, HITTESTAREA), r2 = new Rect(to.x, to.y).inflate(HITTESTAREA, HITTESTAREA), o1, u1;\n if (r1.union(r2).contains(this)) {\n if (from.x === to.x || from.y === to.y) {\n return true;\n } else if (from.y < to.y) {\n o1 = r1.x + (r2.x - r1.x) * (this.y - (r1.y + r1.height)) / (r2.y + r2.height - (r1.y + r1.height));\n u1 = r1.x + r1.width + (r2.x + r2.width - (r1.x + r1.width)) * (this.y - r1.y) / (r2.y - r1.y);\n } else {\n o1 = r1.x + (r2.x - r1.x) * (this.y - r1.y) / (r2.y - r1.y);\n u1 = r1.x + r1.width + (r2.x + r2.width - (r1.x + r1.width)) * (this.y - (r1.y + r1.height)) / (r2.y + r2.height - (r1.y + r1.height));\n }\n return this.x > o1 && this.x < u1;\n }\n return false;\n }\n });\n deepExtend(Point, {\n parse: function (str) {\n var tempStr = str.slice(1, str.length - 1), xy = tempStr.split(','), x = parseInt(xy[0], 10), y = parseInt(xy[1], 10);\n if (!isNaN(x) && !isNaN(y)) {\n return new Point(x, y);\n }\n }\n });\n var PathDefiner = Class.extend({\n init: function (p, left, right) {\n this.point = p;\n this.left = left;\n this.right = right;\n }\n });\n var Rect = Class.extend({\n init: function (x, y, width, height) {\n this.x = x || 0;\n this.y = y || 0;\n this.width = width || 0;\n this.height = height || 0;\n },\n contains: function (point) {\n return point.x >= this.x && point.x <= this.x + this.width && point.y >= this.y && point.y <= this.y + this.height;\n },\n inflate: function (dx, dy) {\n if (dy === undefined) {\n dy = dx;\n }\n this.x -= dx;\n this.y -= dy;\n this.width += 2 * dx + 1;\n this.height += 2 * dy + 1;\n return this;\n },\n offset: function (dx, dy) {\n var x = dx, y = dy;\n if (dx instanceof Point) {\n x = dx.x;\n y = dx.y;\n }\n this.x += x;\n this.y += y;\n return this;\n },\n union: function (r) {\n var x1 = Math.min(this.x, r.x);\n var y1 = Math.min(this.y, r.y);\n var x2 = Math.max(this.x + this.width, r.x + r.width);\n var y2 = Math.max(this.y + this.height, r.y + r.height);\n return new Rect(x1, y1, x2 - x1, y2 - y1);\n },\n center: function () {\n return new Point(this.x + this.width / 2, this.y + this.height / 2);\n },\n top: function () {\n return new Point(this.x + this.width / 2, this.y);\n },\n right: function () {\n return new Point(this.x + this.width, this.y + this.height / 2);\n },\n bottom: function () {\n return new Point(this.x + this.width / 2, this.y + this.height);\n },\n left: function () {\n return new Point(this.x, this.y + this.height / 2);\n },\n topLeft: function () {\n return new Point(this.x, this.y);\n },\n topRight: function () {\n return new Point(this.x + this.width, this.y);\n },\n bottomLeft: function () {\n return new Point(this.x, this.y + this.height);\n },\n bottomRight: function () {\n return new Point(this.x + this.width, this.y + this.height);\n },\n clone: function () {\n return new Rect(this.x, this.y, this.width, this.height);\n },\n isEmpty: function () {\n return !this.width && !this.height;\n },\n equals: function (rect) {\n return this.x === rect.x && this.y === rect.y && this.width === rect.width && this.height === rect.height;\n },\n rotatedBounds: function (angle) {\n var rect = this.clone(), points = this.rotatedPoints(angle), tl = points[0], tr = points[1], br = points[2], bl = points[3];\n rect.x = Math.min(br.x, tl.x, tr.x, bl.x);\n rect.y = Math.min(br.y, tl.y, tr.y, bl.y);\n rect.width = Math.max(br.x, tl.x, tr.x, bl.x) - rect.x;\n rect.height = Math.max(br.y, tl.y, tr.y, bl.y) - rect.y;\n return rect;\n },\n rotatedPoints: function (angle) {\n var rect = this, c = rect.center(), br = rect.bottomRight().rotate(c, 360 - angle), tl = rect.topLeft().rotate(c, 360 - angle), tr = rect.topRight().rotate(c, 360 - angle), bl = rect.bottomLeft().rotate(c, 360 - angle);\n return [\n tl,\n tr,\n br,\n bl\n ];\n },\n toString: function (delimiter) {\n delimiter = delimiter || ' ';\n return this.x + delimiter + this.y + delimiter + this.width + delimiter + this.height;\n },\n scale: function (scaleX, scaleY, staicPoint, adornerCenter, angle) {\n var tl = this.topLeft();\n var thisCenter = this.center();\n tl.rotate(thisCenter, 360 - angle).rotate(adornerCenter, angle);\n var delta = staicPoint.minus(tl);\n var scaled = new Point(delta.x * scaleX, delta.y * scaleY);\n var position = delta.minus(scaled);\n tl = tl.plus(position);\n tl.rotate(adornerCenter, 360 - angle).rotate(thisCenter, angle);\n this.x = tl.x;\n this.y = tl.y;\n this.width *= scaleX;\n this.height *= scaleY;\n },\n zoom: function (zoom) {\n this.x *= zoom;\n this.y *= zoom;\n this.width *= zoom;\n this.height *= zoom;\n return this;\n },\n overlaps: function (rect) {\n var bottomRight = this.bottomRight();\n var rectBottomRight = rect.bottomRight();\n var overlaps = !(bottomRight.x < rect.x || bottomRight.y < rect.y || rectBottomRight.x < this.x || rectBottomRight.y < this.y);\n return overlaps;\n }\n });\n var Size = Class.extend({\n init: function (width, height) {\n this.width = width;\n this.height = height;\n }\n });\n Size.prototype.Empty = new Size(0, 0);\n Rect.toRect = function (rect) {\n if (!(rect instanceof Rect)) {\n rect = new Rect(rect.x, rect.y, rect.width, rect.height);\n }\n return rect;\n };\n Rect.empty = function () {\n return new Rect(0, 0, 0, 0);\n };\n Rect.fromPoints = function (p, q) {\n if (isNaN(p.x) || isNaN(p.y) || isNaN(q.x) || isNaN(q.y)) {\n throw 'Some values are NaN.';\n }\n return new Rect(Math.min(p.x, q.x), Math.min(p.y, q.y), Math.abs(p.x - q.x), Math.abs(p.y - q.y));\n };\n function isNearZero(num) {\n return Math.abs(num) < EPSILON;\n }\n function intersectLine(start1, end1, start2, end2, isSegment) {\n var tangensdiff = (end1.x - start1.x) * (end2.y - start2.y) - (end1.y - start1.y) * (end2.x - start2.x);\n if (isNearZero(tangensdiff)) {\n return;\n }\n var num1 = (start1.y - start2.y) * (end2.x - start2.x) - (start1.x - start2.x) * (end2.y - start2.y);\n var num2 = (start1.y - start2.y) * (end1.x - start1.x) - (start1.x - start2.x) * (end1.y - start1.y);\n var r = num1 / tangensdiff;\n var s = num2 / tangensdiff;\n if (isSegment && (r < 0 || r > 1 || s < 0 || s > 1)) {\n return;\n }\n return new Point(start1.x + r * (end1.x - start1.x), start1.y + r * (end1.y - start1.y));\n }\n var Intersect = {\n lines: function (start1, end1, start2, end2) {\n return intersectLine(start1, end1, start2, end2);\n },\n segments: function (start1, end1, start2, end2) {\n return intersectLine(start1, end1, start2, end2, true);\n },\n rectWithLine: function (rect, start, end) {\n return Intersect.segments(start, end, rect.topLeft(), rect.topRight()) || Intersect.segments(start, end, rect.topRight(), rect.bottomRight()) || Intersect.segments(start, end, rect.bottomLeft(), rect.bottomRight()) || Intersect.segments(start, end, rect.topLeft(), rect.bottomLeft());\n },\n rects: function (rect1, rect2, angle) {\n var tl = rect2.topLeft(), tr = rect2.topRight(), bl = rect2.bottomLeft(), br = rect2.bottomRight();\n var center = rect2.center();\n if (angle) {\n tl = tl.rotate(center, angle);\n tr = tr.rotate(center, angle);\n bl = bl.rotate(center, angle);\n br = br.rotate(center, angle);\n }\n var intersect = rect1.contains(tl) || rect1.contains(tr) || rect1.contains(bl) || rect1.contains(br) || Intersect.rectWithLine(rect1, tl, tr) || Intersect.rectWithLine(rect1, tl, bl) || Intersect.rectWithLine(rect1, tr, br) || Intersect.rectWithLine(rect1, bl, br);\n if (!intersect) {\n tl = rect1.topLeft();\n tr = rect1.topRight();\n bl = rect1.bottomLeft();\n br = rect1.bottomRight();\n if (angle) {\n var reverseAngle = 360 - angle;\n tl = tl.rotate(center, reverseAngle);\n tr = tr.rotate(center, reverseAngle);\n bl = bl.rotate(center, reverseAngle);\n br = br.rotate(center, reverseAngle);\n }\n intersect = rect2.contains(tl) || rect2.contains(tr) || rect2.contains(bl) || rect2.contains(br);\n }\n return intersect;\n }\n };\n var RectAlign = Class.extend({\n init: function (container) {\n this.container = Rect.toRect(container);\n },\n align: function (content, alignment) {\n var alignValues = alignment.toLowerCase().split(' ');\n for (var i = 0; i < alignValues.length; i++) {\n content = this._singleAlign(content, alignValues[i]);\n }\n return content;\n },\n _singleAlign: function (content, alignment) {\n if (isFunction(this[alignment])) {\n return this[alignment](content);\n } else {\n return content;\n }\n },\n left: function (content) {\n return this._align(content, this._left);\n },\n center: function (content) {\n return this._align(content, this._center);\n },\n right: function (content) {\n return this._align(content, this._right);\n },\n stretch: function (content) {\n return this._align(content, this._stretch);\n },\n top: function (content) {\n return this._align(content, this._top);\n },\n middle: function (content) {\n return this._align(content, this._middle);\n },\n bottom: function (content) {\n return this._align(content, this._bottom);\n },\n _left: function (container, content) {\n content.x = container.x;\n },\n _center: function (container, content) {\n content.x = (container.width - content.width) / 2 || 0;\n },\n _right: function (container, content) {\n content.x = container.width - content.width;\n },\n _top: function (container, content) {\n content.y = container.y;\n },\n _middle: function (container, content) {\n content.y = (container.height - content.height) / 2 || 0;\n },\n _bottom: function (container, content) {\n content.y = container.height - content.height;\n },\n _stretch: function (container, content) {\n content.x = 0;\n content.y = 0;\n content.height = container.height;\n content.width = container.width;\n },\n _align: function (content, alignCalc) {\n content = Rect.toRect(content);\n alignCalc(this.container, content);\n return content;\n }\n });\n var Polar = Class.extend({\n init: function (r, a) {\n this.r = r;\n this.angle = a;\n }\n });\n var Matrix = Class.extend({\n init: function (a, b, c, d, e, f) {\n this.a = a || 0;\n this.b = b || 0;\n this.c = c || 0;\n this.d = d || 0;\n this.e = e || 0;\n this.f = f || 0;\n },\n plus: function (m) {\n this.a += m.a;\n this.b += m.b;\n this.c += m.c;\n this.d += m.d;\n this.e += m.e;\n this.f += m.f;\n },\n minus: function (m) {\n this.a -= m.a;\n this.b -= m.b;\n this.c -= m.c;\n this.d -= m.d;\n this.e -= m.e;\n this.f -= m.f;\n },\n times: function (m) {\n return new Matrix(this.a * m.a + this.c * m.b, this.b * m.a + this.d * m.b, this.a * m.c + this.c * m.d, this.b * m.c + this.d * m.d, this.a * m.e + this.c * m.f + this.e, this.b * m.e + this.d * m.f + this.f);\n },\n apply: function (p) {\n return new Point(this.a * p.x + this.c * p.y + this.e, this.b * p.x + this.d * p.y + this.f);\n },\n applyRect: function (r) {\n return Rect.fromPoints(this.apply(r.topLeft()), this.apply(r.bottomRight()));\n },\n toString: function () {\n return 'matrix(' + this.a + ' ' + this.b + ' ' + this.c + ' ' + this.d + ' ' + this.e + ' ' + this.f + ')';\n }\n });\n deepExtend(Matrix, {\n fromSVGMatrix: function (vm) {\n var m = new Matrix();\n m.a = vm.a;\n m.b = vm.b;\n m.c = vm.c;\n m.d = vm.d;\n m.e = vm.e;\n m.f = vm.f;\n return m;\n },\n fromMatrixVector: function (v) {\n var m = new Matrix();\n m.a = v.a;\n m.b = v.b;\n m.c = v.c;\n m.d = v.d;\n m.e = v.e;\n m.f = v.f;\n return m;\n },\n fromList: function (v) {\n if (v.length !== 6) {\n throw 'The given list should consist of six elements.';\n }\n var m = new Matrix();\n m.a = v[0];\n m.b = v[1];\n m.c = v[2];\n m.d = v[3];\n m.e = v[4];\n m.f = v[5];\n return m;\n },\n translation: function (x, y) {\n var m = new Matrix();\n m.a = 1;\n m.b = 0;\n m.c = 0;\n m.d = 1;\n m.e = x;\n m.f = y;\n return m;\n },\n unit: function () {\n return new Matrix(1, 0, 0, 1, 0, 0);\n },\n rotation: function (angle, x, y) {\n var m = new Matrix();\n m.a = Math.cos(angle * Math.PI / 180);\n m.b = Math.sin(angle * Math.PI / 180);\n m.c = -m.b;\n m.d = m.a;\n m.e = x - x * m.a + y * m.b || 0;\n m.f = y - y * m.a - x * m.b || 0;\n return m;\n },\n scaling: function (scaleX, scaleY) {\n var m = new Matrix();\n m.a = scaleX;\n m.b = 0;\n m.c = 0;\n m.d = scaleY;\n m.e = 0;\n m.f = 0;\n return m;\n },\n parse: function (v) {\n var parts, nums;\n if (v) {\n v = v.trim();\n if (v.slice(0, 6).toLowerCase() === 'matrix') {\n nums = v.slice(7, v.length - 1).trim();\n parts = nums.split(',');\n if (parts.length === 6) {\n return Matrix.fromList(map(parts, function (p) {\n return parseFloat(p);\n }));\n }\n parts = nums.split(' ');\n if (parts.length === 6) {\n return Matrix.fromList(map(parts, function (p) {\n return parseFloat(p);\n }));\n }\n }\n if (v.slice(0, 1) === '(' && v.slice(v.length - 1) === ')') {\n v = v.substr(1, v.length - 1);\n }\n if (v.indexOf(',') > 0) {\n parts = v.split(',');\n if (parts.length === 6) {\n return Matrix.fromList(map(parts, function (p) {\n return parseFloat(p);\n }));\n }\n }\n if (v.indexOf(' ') > 0) {\n parts = v.split(' ');\n if (parts.length === 6) {\n return Matrix.fromList(map(parts, function (p) {\n return parseFloat(p);\n }));\n }\n }\n }\n return parts;\n }\n });\n var MatrixVector = Class.extend({\n init: function (a, b, c, d, e, f) {\n this.a = a || 0;\n this.b = b || 0;\n this.c = c || 0;\n this.d = d || 0;\n this.e = e || 0;\n this.f = f || 0;\n },\n fromMatrix: function FromMatrix(m) {\n var v = new MatrixVector();\n v.a = m.a;\n v.b = m.b;\n v.c = m.c;\n v.d = m.d;\n v.e = m.e;\n v.f = m.f;\n return v;\n }\n });\n function normalVariable(mean, deviation) {\n var x, y, r;\n do {\n x = Math.random() * 2 - 1;\n y = Math.random() * 2 - 1;\n r = x * x + y * y;\n } while (!r || r > 1);\n return mean + deviation * x * Math.sqrt(-2 * Math.log(r) / r);\n }\n function randomId(length) {\n if (Utils.isUndefined(length)) {\n length = 10;\n }\n var result = '';\n var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n for (var i = length; i > 0; --i) {\n result += chars.charAt(Math.round(Math.random() * (chars.length - 1)));\n }\n return result;\n }\n var Geometry = {\n _distanceToLineSquared: function (p, a, b) {\n function d2(pt1, pt2) {\n return (pt1.x - pt2.x) * (pt1.x - pt2.x) + (pt1.y - pt2.y) * (pt1.y - pt2.y);\n }\n if (a === b) {\n return d2(p, a);\n }\n var vx = b.x - a.x, vy = b.y - a.y, dot = (p.x - a.x) * vx + (p.y - a.y) * vy;\n if (dot < 0) {\n return d2(a, p);\n }\n dot = (b.x - p.x) * vx + (b.y - p.y) * vy;\n if (dot < 0) {\n return d2(b, p);\n }\n dot = (b.x - p.x) * vy - (b.y - p.y) * vx;\n return dot * dot / (vx * vx + vy * vy);\n },\n distanceToLine: function (p, a, b) {\n return Math.sqrt(this._distanceToLineSquared(p, a, b));\n },\n distanceToPolyline: function (p, points) {\n var minimum = Number.MAX_VALUE;\n if (Utils.isUndefined(points) || points.length === 0) {\n return Number.MAX_VALUE;\n }\n for (var s = 0; s < points.length - 1; s++) {\n var p1 = points[s];\n var p2 = points[s + 1];\n var d = this._distanceToLineSquared(p, p1, p2);\n if (d < minimum) {\n minimum = d;\n }\n }\n return Math.sqrt(minimum);\n }\n };\n var HashTable = kendo.Class.extend({\n init: function () {\n this._buckets = [];\n this.length = 0;\n },\n add: function (key, value) {\n var obj = this._createGetBucket(key);\n if (Utils.isDefined(value)) {\n obj.value = value;\n }\n return obj;\n },\n get: function (key) {\n if (this._bucketExists(key)) {\n return this._createGetBucket(key);\n }\n return null;\n },\n set: function (key, value) {\n this.add(key, value);\n },\n containsKey: function (key) {\n return this._bucketExists(key);\n },\n remove: function (key) {\n if (this._bucketExists(key)) {\n var hashId = this._hash(key);\n delete this._buckets[hashId];\n this.length--;\n return key;\n }\n },\n forEach: function (func) {\n var hashes = this._hashes();\n for (var i = 0, len = hashes.length; i < len; i++) {\n var hash = hashes[i];\n var bucket = this._buckets[hash];\n if (Utils.isUndefined(bucket)) {\n continue;\n }\n func(bucket);\n }\n },\n clone: function () {\n var ht = new HashTable();\n var hashes = this._hashes();\n for (var i = 0, len = hashes.length; i < len; i++) {\n var hash = hashes[i];\n var bucket = this._buckets[hash];\n if (Utils.isUndefined(bucket)) {\n continue;\n }\n ht.add(bucket.key, bucket.value);\n }\n return ht;\n },\n _hashes: function () {\n var hashes = [];\n for (var hash in this._buckets) {\n if (this._buckets.hasOwnProperty(hash)) {\n hashes.push(hash);\n }\n }\n return hashes;\n },\n _bucketExists: function (key) {\n var hashId = this._hash(key);\n return Utils.isDefined(this._buckets[hashId]);\n },\n _createGetBucket: function (key) {\n var hashId = this._hash(key);\n var bucket = this._buckets[hashId];\n if (Utils.isUndefined(bucket)) {\n bucket = { key: key };\n this._buckets[hashId] = bucket;\n this.length++;\n }\n return bucket;\n },\n _hash: function (key) {\n if (Utils.isNumber(key)) {\n return key;\n }\n if (Utils.isString(key)) {\n return this._hashString(key);\n }\n if (Utils.isObject(key)) {\n return this._objectHashId(key);\n }\n throw 'Unsupported key type.';\n },\n _hashString: function (s) {\n var result = 0;\n if (s.length === 0) {\n return result;\n }\n for (var i = 0; i < s.length; i++) {\n var ch = s.charCodeAt(i);\n result = result * 32 - result + ch;\n }\n return result;\n },\n _objectHashId: function (key) {\n var id = key._hashId;\n if (Utils.isUndefined(id)) {\n id = randomId();\n key._hashId = id;\n }\n return id;\n }\n });\n var Dictionary = kendo.Observable.extend({\n init: function (dictionary) {\n var that = this;\n kendo.Observable.fn.init.call(that);\n this._hashTable = new HashTable();\n this.length = 0;\n if (Utils.isDefined(dictionary)) {\n if ($.isArray(dictionary)) {\n for (var i = 0; i < dictionary.length; i++) {\n this.add(dictionary[i]);\n }\n } else {\n dictionary.forEach(function (k, v) {\n this.add(k, v);\n }, this);\n }\n }\n },\n add: function (key, value) {\n var entry = this._hashTable.get(key);\n if (!entry) {\n entry = this._hashTable.add(key);\n this.length++;\n this.trigger('changed');\n }\n entry.value = value;\n },\n set: function (key, value) {\n this.add(key, value);\n },\n get: function (key) {\n var entry = this._hashTable.get(key);\n if (entry) {\n return entry.value;\n }\n throw new Error('Cannot find key ' + key);\n },\n containsKey: function (key) {\n return this._hashTable.containsKey(key);\n },\n remove: function (key) {\n if (this.containsKey(key)) {\n this.trigger('changed');\n this.length--;\n return this._hashTable.remove(key);\n }\n },\n forEach: function (func, thisRef) {\n this._hashTable.forEach(function (entry) {\n func.call(thisRef, entry.key, entry.value);\n });\n },\n forEachValue: function (func, thisRef) {\n this._hashTable.forEach(function (entry) {\n func.call(thisRef, entry.value);\n });\n },\n forEachKey: function (func, thisRef) {\n this._hashTable.forEach(function (entry) {\n func.call(thisRef, entry.key);\n });\n },\n keys: function () {\n var keys = [];\n this.forEachKey(function (key) {\n keys.push(key);\n });\n return keys;\n }\n });\n var Queue = kendo.Class.extend({\n init: function () {\n this._tail = null;\n this._head = null;\n this.length = 0;\n },\n enqueue: function (value) {\n var entry = {\n value: value,\n next: null\n };\n if (!this._head) {\n this._head = entry;\n this._tail = this._head;\n } else {\n this._tail.next = entry;\n this._tail = this._tail.next;\n }\n this.length++;\n },\n dequeue: function () {\n if (this.length < 1) {\n throw new Error('The queue is empty.');\n }\n var value = this._head.value;\n this._head = this._head.next;\n this.length--;\n return value;\n },\n contains: function (item) {\n var current = this._head;\n while (current) {\n if (current.value === item) {\n return true;\n }\n current = current.next;\n }\n return false;\n }\n });\n var Set = kendo.Observable.extend({\n init: function (resource) {\n var that = this;\n kendo.Observable.fn.init.call(that);\n this._hashTable = new HashTable();\n this.length = 0;\n if (Utils.isDefined(resource)) {\n if (resource instanceof HashTable) {\n resource.forEach(function (d) {\n this.add(d);\n });\n } else if (resource instanceof Dictionary) {\n resource.forEach(function (k, v) {\n this.add({\n key: k,\n value: v\n });\n }, this);\n }\n }\n },\n contains: function (item) {\n return this._hashTable.containsKey(item);\n },\n add: function (item) {\n var entry = this._hashTable.get(item);\n if (!entry) {\n this._hashTable.add(item, item);\n this.length++;\n this.trigger('changed');\n }\n },\n get: function (item) {\n if (this.contains(item)) {\n return this._hashTable.get(item).value;\n } else {\n return null;\n }\n },\n hash: function (item) {\n return this._hashTable._hash(item);\n },\n remove: function (item) {\n if (this.contains(item)) {\n this._hashTable.remove(item);\n this.length--;\n this.trigger('changed');\n }\n },\n forEach: function (func, context) {\n this._hashTable.forEach(function (kv) {\n func(kv.value);\n }, context);\n },\n toArray: function () {\n var r = [];\n this.forEach(function (d) {\n r.push(d);\n });\n return r;\n }\n });\n var Node = kendo.Class.extend({\n init: function (id, shape) {\n this.links = [];\n this.outgoing = [];\n this.incoming = [];\n this.weight = 1;\n if (Utils.isDefined(id)) {\n this.id = id;\n } else {\n this.id = randomId();\n }\n if (Utils.isDefined(shape)) {\n this.associatedShape = shape;\n var b = shape.bounds();\n this.width = b.width;\n this.height = b.height;\n this.x = b.x;\n this.y = b.y;\n } else {\n this.associatedShape = null;\n }\n this.data = null;\n this.type = 'Node';\n this.shortForm = 'Node \\'' + this.id + '\\'';\n this.isVirtual = false;\n },\n isIsolated: function () {\n return Utils.isEmpty(this.links);\n },\n bounds: function (r) {\n if (!Utils.isDefined(r)) {\n return new diagram.Rect(this.x, this.y, this.width, this.height);\n }\n this.x = r.x;\n this.y = r.y;\n this.width = r.width;\n this.height = r.height;\n },\n isLinkedTo: function (node) {\n var that = this;\n return Utils.any(that.links, function (link) {\n return link.getComplement(that) === node;\n });\n },\n getChildren: function () {\n if (this.outgoing.length === 0) {\n return [];\n }\n var children = [];\n for (var i = 0, len = this.outgoing.length; i < len; i++) {\n var link = this.outgoing[i];\n children.push(link.getComplement(this));\n }\n return children;\n },\n getParents: function () {\n if (this.incoming.length === 0) {\n return [];\n }\n var parents = [];\n for (var i = 0, len = this.incoming.length; i < len; i++) {\n var link = this.incoming[i];\n parents.push(link.getComplement(this));\n }\n return parents;\n },\n clone: function () {\n var copy = new Node();\n if (Utils.isDefined(this.weight)) {\n copy.weight = this.weight;\n }\n if (Utils.isDefined(this.balance)) {\n copy.balance = this.balance;\n }\n if (Utils.isDefined(this.owner)) {\n copy.owner = this.owner;\n }\n copy.associatedShape = this.associatedShape;\n copy.x = this.x;\n copy.y = this.y;\n copy.width = this.width;\n copy.height = this.height;\n return copy;\n },\n adjacentTo: function (node) {\n return this.isLinkedTo(node) !== null;\n },\n removeLink: function (link) {\n if (link.source === this) {\n Utils.remove(this.links, link);\n Utils.remove(this.outgoing, link);\n link.source = null;\n }\n if (link.target === this) {\n Utils.remove(this.links, link);\n Utils.remove(this.incoming, link);\n link.target = null;\n }\n },\n hasLinkTo: function (node) {\n return Utils.any(this.outgoing, function (link) {\n return link.target === node;\n });\n },\n degree: function () {\n return this.links.length;\n },\n incidentWith: function (link) {\n return contains(this.links, link);\n },\n getLinksWith: function (node) {\n return Utils.all(this.links, function (link) {\n return link.getComplement(this) === node;\n }, this);\n },\n getNeighbors: function () {\n var neighbors = [];\n Utils.forEach(this.incoming, function (e) {\n neighbors.push(e.getComplement(this));\n }, this);\n Utils.forEach(this.outgoing, function (e) {\n neighbors.push(e.getComplement(this));\n }, this);\n return neighbors;\n }\n });\n var Link = kendo.Class.extend({\n init: function (source, target, id, connection) {\n if (Utils.isUndefined(source)) {\n throw 'The source of the new link is not set.';\n }\n if (Utils.isUndefined(target)) {\n throw 'The target of the new link is not set.';\n }\n var sourceFound, targetFound;\n if (Utils.isString(source)) {\n sourceFound = new Node(source);\n } else {\n sourceFound = source;\n }\n if (Utils.isString(target)) {\n targetFound = new Node(target);\n } else {\n targetFound = target;\n }\n this.source = sourceFound;\n this.target = targetFound;\n this.source.links.push(this);\n this.target.links.push(this);\n this.source.outgoing.push(this);\n this.target.incoming.push(this);\n if (Utils.isDefined(id)) {\n this.id = id;\n } else {\n this.id = randomId();\n }\n if (Utils.isDefined(connection)) {\n this.associatedConnection = connection;\n } else {\n this.associatedConnection = null;\n }\n this.type = 'Link';\n this.shortForm = 'Link \\'' + this.source.id + '->' + this.target.id + '\\'';\n },\n getComplement: function (node) {\n if (this.source !== node && this.target !== node) {\n throw 'The given node is not incident with this link.';\n }\n return this.source === node ? this.target : this.source;\n },\n getCommonNode: function (link) {\n if (this.source === link.source || this.source === link.target) {\n return this.source;\n }\n if (this.target === link.source || this.target === link.target) {\n return this.target;\n }\n return null;\n },\n isBridging: function (v1, v2) {\n return this.source === v1 && this.target === v2 || this.source === v2 && this.target === v1;\n },\n getNodes: function () {\n return [\n this.source,\n this.target\n ];\n },\n incidentWith: function (node) {\n return this.source === node || this.target === node;\n },\n adjacentTo: function (link) {\n return contains(this.source.links, link) || contains(this.target.links, link);\n },\n changeSource: function (node) {\n Utils.remove(this.source.links, this);\n Utils.remove(this.source.outgoing, this);\n node.links.push(this);\n node.outgoing.push(this);\n this.source = node;\n },\n changeTarget: function (node) {\n Utils.remove(this.target.links, this);\n Utils.remove(this.target.incoming, this);\n node.links.push(this);\n node.incoming.push(this);\n this.target = node;\n },\n changesNodes: function (v, w) {\n if (this.source === v) {\n this.changeSource(w);\n } else if (this.target === v) {\n this.changeTarget(w);\n }\n },\n reverse: function () {\n var oldSource = this.source;\n var oldTarget = this.target;\n this.source = oldTarget;\n Utils.remove(oldSource.outgoing, this);\n this.source.outgoing.push(this);\n this.target = oldSource;\n Utils.remove(oldTarget.incoming, this);\n this.target.incoming.push(this);\n return this;\n },\n directTo: function (target) {\n if (this.source !== target && this.target !== target) {\n throw 'The given node is not incident with this link.';\n }\n if (this.target !== target) {\n this.reverse();\n }\n },\n createReverseEdge: function () {\n var r = this.clone();\n r.reverse();\n r.reversed = true;\n return r;\n },\n clone: function () {\n var clone = new Link(this.source, this.target);\n return clone;\n }\n });\n var Graph = kendo.Class.extend({\n init: function (idOrDiagram) {\n this.links = [];\n this.nodes = [];\n this._nodeMap = new Dictionary();\n this.diagram = null;\n this._root = null;\n if (Utils.isDefined(idOrDiagram)) {\n if (Utils.isString(idOrDiagram)) {\n this.id = idOrDiagram;\n } else {\n this.diagram = idOrDiagram;\n this.id = idOrDiagram.id;\n }\n } else {\n this.id = randomId();\n }\n this.bounds = new Rect();\n this._hasCachedRelationships = false;\n this.type = 'Graph';\n },\n cacheRelationships: function (forceRebuild) {\n if (Utils.isUndefined(forceRebuild)) {\n forceRebuild = false;\n }\n if (this._hasCachedRelationships && !forceRebuild) {\n return;\n }\n for (var i = 0, len = this.nodes.length; i < len; i++) {\n var node = this.nodes[i];\n node.children = this.getChildren(node);\n node.parents = this.getParents(node);\n }\n this._hasCachedRelationships = true;\n },\n assignLevels: function (startNode, offset, visited) {\n if (!startNode) {\n throw 'Start node not specified.';\n }\n if (Utils.isUndefined(offset)) {\n offset = 0;\n }\n this.cacheRelationships();\n if (Utils.isUndefined(visited)) {\n visited = new Dictionary();\n Utils.forEach(this.nodes, function (n) {\n visited.add(n, false);\n });\n }\n visited.set(startNode, true);\n startNode.level = offset;\n var children = startNode.children;\n for (var i = 0, len = children.length; i < len; i++) {\n var child = children[i];\n if (!child || visited.get(child)) {\n continue;\n }\n this.assignLevels(child, offset + 1, visited);\n }\n },\n root: function (value) {\n if (Utils.isUndefined(value)) {\n if (!this._root) {\n var found = Utils.first(this.nodes, function (n) {\n return n.incoming.length === 0;\n });\n if (found) {\n return found;\n }\n return Utils.first(this.nodes);\n } else {\n return this._root;\n }\n } else {\n this._root = value;\n }\n },\n getConnectedComponents: function () {\n this.componentIndex = 0;\n this.setItemIndices();\n var componentId = Utils.initArray(this.nodes.length, -1);\n for (var v = 0; v < this.nodes.length; v++) {\n if (componentId[v] === -1) {\n this._collectConnectedNodes(componentId, v);\n this.componentIndex++;\n }\n }\n var components = [], i;\n for (i = 0; i < this.componentIndex; ++i) {\n components[i] = new Graph();\n }\n for (i = 0; i < componentId.length; ++i) {\n var graph = components[componentId[i]];\n graph.addNodeAndOutgoings(this.nodes[i]);\n }\n components.sort(function (a, b) {\n return b.nodes.length - a.nodes.length;\n });\n return components;\n },\n _collectConnectedNodes: function (setIds, nodeIndex) {\n setIds[nodeIndex] = this.componentIndex;\n var node = this.nodes[nodeIndex];\n Utils.forEach(node.links, function (link) {\n var next = link.getComplement(node);\n var nextId = next.index;\n if (setIds[nextId] === -1) {\n this._collectConnectedNodes(setIds, nextId);\n }\n }, this);\n },\n calcBounds: function () {\n if (this.isEmpty()) {\n this.bounds = new Rect();\n return this.bounds;\n }\n var b = null;\n for (var i = 0, len = this.nodes.length; i < len; i++) {\n var node = this.nodes[i];\n if (!b) {\n b = node.bounds();\n } else {\n b = b.union(node.bounds());\n }\n }\n this.bounds = b;\n return this.bounds;\n },\n getSpanningTree: function (root) {\n var tree = new Graph();\n var map = new Dictionary(), source, target;\n tree.root = root.clone();\n tree.root.level = 0;\n tree.root.id = root.id;\n map.add(root, tree.root);\n root.level = 0;\n var visited = [];\n var remaining = [];\n tree._addNode(tree.root);\n visited.push(root);\n remaining.push(root);\n var levelCount = 1;\n while (remaining.length > 0) {\n var next = remaining.pop();\n for (var ni = 0; ni < next.links.length; ni++) {\n var link = next.links[ni];\n var cn = link.getComplement(next);\n if (contains(visited, cn)) {\n continue;\n }\n cn.level = next.level + 1;\n if (levelCount < cn.level + 1) {\n levelCount = cn.level + 1;\n }\n if (!contains(remaining, cn)) {\n remaining.push(cn);\n }\n if (!contains(visited, cn)) {\n visited.push(cn);\n }\n if (map.containsKey(next)) {\n source = map.get(next);\n } else {\n source = next.clone();\n source.level = next.level;\n source.id = next.id;\n map.add(next, source);\n }\n if (map.containsKey(cn)) {\n target = map.get(cn);\n } else {\n target = cn.clone();\n target.level = cn.level;\n target.id = cn.id;\n map.add(cn, target);\n }\n var newLink = new Link(source, target);\n tree.addLink(newLink);\n }\n }\n var treeLevels = [];\n for (var i = 0; i < levelCount; i++) {\n treeLevels.push([]);\n }\n Utils.forEach(tree.nodes, function (node) {\n treeLevels[node.level].push(node);\n });\n tree.treeLevels = treeLevels;\n tree.cacheRelationships();\n return tree;\n },\n takeRandomNode: function (excludedNodes, incidenceLessThan) {\n if (Utils.isUndefined(excludedNodes)) {\n excludedNodes = [];\n }\n if (Utils.isUndefined(incidenceLessThan)) {\n incidenceLessThan = 4;\n }\n if (this.nodes.length === 0) {\n return null;\n }\n if (this.nodes.length === 1) {\n return contains(excludedNodes, this.nodes[0]) ? null : this.nodes[0];\n }\n var pool = $.grep(this.nodes, function (node) {\n return !contains(excludedNodes, node) && node.degree() <= incidenceLessThan;\n });\n if (Utils.isEmpty(pool)) {\n return null;\n }\n return pool[Utils.randomInteger(0, pool.length)];\n },\n isEmpty: function () {\n return Utils.isEmpty(this.nodes);\n },\n isHealthy: function () {\n return Utils.all(this.links, function (link) {\n return contains(this.nodes, link.source) && contains(this.nodes, link.target);\n }, this);\n },\n getParents: function (n) {\n if (!this.hasNode(n)) {\n throw 'The given node is not part of this graph.';\n }\n return n.getParents();\n },\n getChildren: function (n) {\n if (!this.hasNode(n)) {\n throw 'The given node is not part of this graph.';\n }\n return n.getChildren();\n },\n addLink: function (sourceOrLink, target, owner) {\n if (Utils.isUndefined(sourceOrLink)) {\n throw 'The source of the link is not defined.';\n }\n if (Utils.isUndefined(target)) {\n if (Utils.isDefined(sourceOrLink.type) && sourceOrLink.type === 'Link') {\n this.addExistingLink(sourceOrLink);\n return;\n } else {\n throw 'The target of the link is not defined.';\n }\n }\n var foundSource = this.getNode(sourceOrLink);\n if (Utils.isUndefined(foundSource)) {\n foundSource = this.addNode(sourceOrLink);\n }\n var foundTarget = this.getNode(target);\n if (Utils.isUndefined(foundTarget)) {\n foundTarget = this.addNode(target);\n }\n var newLink = new Link(foundSource, foundTarget);\n if (Utils.isDefined(owner)) {\n newLink.owner = owner;\n }\n this.links.push(newLink);\n return newLink;\n },\n removeAllLinks: function () {\n while (this.links.length > 0) {\n var link = this.links[0];\n this.removeLink(link);\n }\n },\n addExistingLink: function (link) {\n if (this.hasLink(link)) {\n return;\n }\n this.links.push(link);\n if (this.hasNode(link.source.id)) {\n var s = this.getNode(link.source.id);\n link.changeSource(s);\n } else {\n this.addNode(link.source);\n }\n if (this.hasNode(link.target.id)) {\n var t = this.getNode(link.target.id);\n link.changeTarget(t);\n } else {\n this.addNode(link.target);\n }\n },\n hasLink: function (linkOrId) {\n if (Utils.isString(linkOrId)) {\n return Utils.any(this.links, function (link) {\n return link.id === linkOrId;\n });\n }\n if (linkOrId.type === 'Link') {\n return contains(this.links, linkOrId);\n }\n throw 'The given object is neither an identifier nor a Link.';\n },\n getNode: function (nodeOrId) {\n var id = nodeOrId.id || nodeOrId;\n if (this._nodeMap.containsKey(id)) {\n return this._nodeMap.get(id);\n }\n },\n hasNode: function (nodeOrId) {\n var id = nodeOrId.id || nodeOrId;\n return this._nodeMap.containsKey(id);\n },\n _addNode: function (node) {\n this.nodes.push(node);\n this._nodeMap.add(node.id, node);\n },\n _removeNode: function (node) {\n Utils.remove(this.nodes, node);\n this._nodeMap.remove(node.id);\n },\n removeNode: function (nodeOrId) {\n var n = nodeOrId;\n if (Utils.isString(nodeOrId)) {\n n = this.getNode(nodeOrId);\n }\n if (Utils.isDefined(n)) {\n var links = n.links;\n n.links = [];\n for (var i = 0, len = links.length; i < len; i++) {\n var link = links[i];\n this.removeLink(link);\n }\n this._removeNode(n);\n } else {\n throw 'The identifier should be a Node or the Id (string) of a node.';\n }\n },\n areConnected: function (n1, n2) {\n return Utils.any(this.links, function (link) {\n return link.source == n1 && link.target == n2 || link.source == n2 && link.target == n1;\n });\n },\n removeLink: function (link) {\n Utils.remove(this.links, link);\n Utils.remove(link.source.outgoing, link);\n Utils.remove(link.source.links, link);\n Utils.remove(link.target.incoming, link);\n Utils.remove(link.target.links, link);\n },\n addNode: function (nodeOrId, layoutRect, owner) {\n var newNode = null;\n if (!Utils.isDefined(nodeOrId)) {\n throw 'No Node or identifier for a new Node is given.';\n }\n if (Utils.isString(nodeOrId)) {\n if (this.hasNode(nodeOrId)) {\n return this.getNode(nodeOrId);\n }\n newNode = new Node(nodeOrId);\n } else {\n if (this.hasNode(nodeOrId)) {\n return this.getNode(nodeOrId);\n }\n newNode = nodeOrId;\n }\n if (Utils.isDefined(layoutRect)) {\n newNode.bounds(layoutRect);\n }\n if (Utils.isDefined(owner)) {\n newNode.owner = owner;\n }\n this._addNode(newNode);\n return newNode;\n },\n addNodeAndOutgoings: function (node) {\n if (!this.hasNode(node)) {\n this._addNode(node);\n }\n var newLinks = node.outgoing;\n node.outgoing = [];\n Utils.forEach(newLinks, function (link) {\n this.addExistingLink(link);\n }, this);\n },\n setItemIndices: function () {\n var i;\n for (i = 0; i < this.nodes.length; ++i) {\n this.nodes[i].index = i;\n }\n for (i = 0; i < this.links.length; ++i) {\n this.links[i].index = i;\n }\n },\n clone: function (saveMapping) {\n var copy = new Graph();\n var save = Utils.isDefined(saveMapping) && saveMapping === true;\n if (save) {\n copy.nodeMap = new Dictionary();\n copy.linkMap = new Dictionary();\n }\n var map = new Dictionary();\n Utils.forEach(this.nodes, function (nOriginal) {\n var nCopy = nOriginal.clone();\n map.set(nOriginal, nCopy);\n copy._addNode(nCopy);\n if (save) {\n copy.nodeMap.set(nCopy, nOriginal);\n }\n });\n Utils.forEach(this.links, function (linkOriginal) {\n if (map.containsKey(linkOriginal.source) && map.containsKey(linkOriginal.target)) {\n var linkCopy = copy.addLink(map.get(linkOriginal.source), map.get(linkOriginal.target));\n if (save) {\n copy.linkMap.set(linkCopy, linkOriginal);\n }\n }\n });\n return copy;\n },\n linearize: function (addIds) {\n return Graph.Utils.linearize(this, addIds);\n },\n depthFirstTraversal: function (startNode, action) {\n if (Utils.isUndefined(startNode)) {\n throw 'You need to supply a starting node.';\n }\n if (Utils.isUndefined(action)) {\n throw 'You need to supply an action.';\n }\n if (!this.hasNode(startNode)) {\n throw 'The given start-node is not part of this graph';\n }\n var foundNode = this.getNode(startNode);\n var visited = [];\n this._dftIterator(foundNode, action, visited);\n },\n _dftIterator: function (node, action, visited) {\n action(node);\n visited.push(node);\n var children = node.getChildren();\n for (var i = 0, len = children.length; i < len; i++) {\n var child = children[i];\n if (contains(visited, child)) {\n continue;\n }\n this._dftIterator(child, action, visited);\n }\n },\n breadthFirstTraversal: function (startNode, action) {\n if (Utils.isUndefined(startNode)) {\n throw 'You need to supply a starting node.';\n }\n if (Utils.isUndefined(action)) {\n throw 'You need to supply an action.';\n }\n if (!this.hasNode(startNode)) {\n throw 'The given start-node is not part of this graph';\n }\n var foundNode = this.getNode(startNode);\n var queue = new Queue();\n var visited = [];\n queue.enqueue(foundNode);\n while (queue.length > 0) {\n var node = queue.dequeue();\n action(node);\n visited.push(node);\n var children = node.getChildren();\n for (var i = 0, len = children.length; i < len; i++) {\n var child = children[i];\n if (contains(visited, child) || contains(queue, child)) {\n continue;\n }\n queue.enqueue(child);\n }\n }\n },\n _stronglyConnectedComponents: function (excludeSingleItems, node, indices, lowLinks, connected, stack, index) {\n indices.add(node, index);\n lowLinks.add(node, index);\n index++;\n stack.push(node);\n var children = node.getChildren(), next;\n for (var i = 0, len = children.length; i < len; i++) {\n next = children[i];\n if (!indices.containsKey(next)) {\n this._stronglyConnectedComponents(excludeSingleItems, next, indices, lowLinks, connected, stack, index);\n lowLinks.add(node, Math.min(lowLinks.get(node), lowLinks.get(next)));\n } else if (contains(stack, next)) {\n lowLinks.add(node, Math.min(lowLinks.get(node), indices.get(next)));\n }\n }\n if (lowLinks.get(node) === indices.get(node)) {\n var component = [];\n do {\n next = stack.pop();\n component.push(next);\n } while (next !== node);\n if (!excludeSingleItems || component.length > 1) {\n connected.push(component);\n }\n }\n },\n findCycles: function (excludeSingleItems) {\n if (Utils.isUndefined(excludeSingleItems)) {\n excludeSingleItems = true;\n }\n var indices = new Dictionary();\n var lowLinks = new Dictionary();\n var connected = [];\n var stack = [];\n for (var i = 0, len = this.nodes.length; i < len; i++) {\n var node = this.nodes[i];\n if (indices.containsKey(node)) {\n continue;\n }\n this._stronglyConnectedComponents(excludeSingleItems, node, indices, lowLinks, connected, stack, 0);\n }\n return connected;\n },\n isAcyclic: function () {\n return Utils.isEmpty(this.findCycles());\n },\n isSubGraph: function (other) {\n var otherArray = other.linearize();\n var thisArray = this.linearize();\n return Utils.all(otherArray, function (s) {\n return contains(thisArray, s);\n });\n },\n makeAcyclic: function () {\n if (this.isEmpty() || this.nodes.length <= 1 || this.links.length <= 1) {\n return [];\n }\n if (this.nodes.length == 2) {\n var result = [];\n if (this.links.length > 1) {\n var oneLink = this.links[0];\n var oneNode = oneLink.source;\n for (var i = 0, len = this.links.length; i < len; i++) {\n var link = this.links[i];\n if (link.source == oneNode) {\n continue;\n }\n var rev = link.reverse();\n result.push(rev);\n }\n }\n return result;\n }\n var copy = this.clone(true);\n var N = this.nodes.length;\n var intensityCatalog = new Dictionary();\n var flowIntensity = function (node) {\n if (node.outgoing.length === 0) {\n return 2 - N;\n } else if (node.incoming.length === 0) {\n return N - 2;\n } else {\n return node.outgoing.length - node.incoming.length;\n }\n };\n var catalogEqualIntensity = function (node, intensityCatalog) {\n var intensity = flowIntensity(node, N);\n if (!intensityCatalog.containsKey(intensity)) {\n intensityCatalog.set(intensity, []);\n }\n intensityCatalog.get(intensity).push(node);\n };\n Utils.forEach(copy.nodes, function (v) {\n catalogEqualIntensity(v, intensityCatalog);\n });\n var sourceStack = [];\n var targetStack = [];\n while (copy.nodes.length > 0) {\n var source, target, intensity;\n if (intensityCatalog.containsKey(2 - N)) {\n var targets = intensityCatalog.get(2 - N);\n while (targets.length > 0) {\n target = targets.pop();\n for (var li = 0; li < target.links.length; li++) {\n var targetLink = target.links[li];\n source = targetLink.getComplement(target);\n intensity = flowIntensity(source, N);\n Utils.remove(intensityCatalog.get(intensity), source);\n source.removeLink(targetLink);\n catalogEqualIntensity(source, intensityCatalog);\n }\n copy._removeNode(target);\n targetStack.unshift(target);\n }\n }\n if (intensityCatalog.containsKey(N - 2)) {\n var sources = intensityCatalog.get(N - 2);\n while (sources.length > 0) {\n source = sources.pop();\n for (var si = 0; si < source.links.length; si++) {\n var sourceLink = source.links[si];\n target = sourceLink.getComplement(source);\n intensity = flowIntensity(target, N);\n Utils.remove(intensityCatalog.get(intensity), target);\n target.removeLink(sourceLink);\n catalogEqualIntensity(target, intensityCatalog);\n }\n sourceStack.push(source);\n copy._removeNode(source);\n }\n }\n if (copy.nodes.length > 0) {\n for (var k = N - 3; k > 2 - N; k--) {\n if (intensityCatalog.containsKey(k) && intensityCatalog.get(k).length > 0) {\n var maxdiff = intensityCatalog.get(k);\n var v = maxdiff.pop();\n for (var ri = 0; ri < v.links.length; ri++) {\n var ril = v.links[ri];\n var u = ril.getComplement(v);\n intensity = flowIntensity(u, N);\n Utils.remove(intensityCatalog.get(intensity), u);\n u.removeLink(ril);\n catalogEqualIntensity(u, intensityCatalog);\n }\n sourceStack.push(v);\n copy._removeNode(v);\n break;\n }\n }\n }\n }\n sourceStack = sourceStack.concat(targetStack);\n var vertexOrder = new Dictionary();\n for (var kk = 0; kk < this.nodes.length; kk++) {\n vertexOrder.set(copy.nodeMap.get(sourceStack[kk]), kk);\n }\n var reversedEdges = [];\n Utils.forEach(this.links, function (link) {\n if (vertexOrder.get(link.source) > vertexOrder.get(link.target)) {\n link.reverse();\n reversedEdges.push(link);\n }\n });\n return reversedEdges;\n }\n });\n Graph.Predefined = {\n EightGraph: function () {\n return Graph.Utils.parse([\n '1->2',\n '2->3',\n '3->4',\n '4->1',\n '3->5',\n '5->6',\n '6->7',\n '7->3'\n ]);\n },\n Mindmap: function () {\n return Graph.Utils.parse([\n '0->1',\n '0->2',\n '0->3',\n '0->4',\n '0->5',\n '1->6',\n '1->7',\n '7->8',\n '2->9',\n '9->10',\n '9->11',\n '3->12',\n '12->13',\n '13->14',\n '4->15',\n '4->16',\n '15->17',\n '15->18',\n '18->19',\n '18->20',\n '14->21',\n '14->22',\n '5->23',\n '23->24',\n '23->25',\n '6->26'\n ]);\n },\n ThreeGraph: function () {\n return Graph.Utils.parse([\n '1->2',\n '2->3',\n '3->1'\n ]);\n },\n BinaryTree: function (levels) {\n if (Utils.isUndefined(levels)) {\n levels = 5;\n }\n return Graph.Utils.createBalancedTree(levels, 2);\n },\n Linear: function (length) {\n if (Utils.isUndefined(length)) {\n length = 10;\n }\n return Graph.Utils.createBalancedTree(length, 1);\n },\n Tree: function (levels, siblingsCount) {\n return Graph.Utils.createBalancedTree(levels, siblingsCount);\n },\n Forest: function (levels, siblingsCount, trees) {\n return Graph.Utils.createBalancedForest(levels, siblingsCount, trees);\n },\n Workflow: function () {\n return Graph.Utils.parse([\n '0->1',\n '1->2',\n '2->3',\n '1->4',\n '4->3',\n '3->5',\n '5->6',\n '6->3',\n '6->7',\n '5->4'\n ]);\n },\n Grid: function (n, m) {\n var g = new diagram.Graph();\n if (n <= 0 && m <= 0) {\n return g;\n }\n for (var i = 0; i < n + 1; i++) {\n var previous = null;\n for (var j = 0; j < m + 1; j++) {\n var node = new Node(i.toString() + '.' + j.toString());\n g.addNode(node);\n if (previous) {\n g.addLink(previous, node);\n }\n if (i > 0) {\n var left = g.getNode((i - 1).toString() + '.' + j.toString());\n g.addLink(left, node);\n }\n previous = node;\n }\n }\n return g;\n }\n };\n Graph.Utils = {\n parse: function (graphString) {\n var previousLink, graph = new diagram.Graph(), parts = graphString.slice();\n for (var i = 0, len = parts.length; i < len; i++) {\n var part = parts[i];\n if (Utils.isString(part)) {\n if (part.indexOf('->') < 0) {\n throw 'The link should be specified as \\'a->b\\'.';\n }\n var p = part.split('->');\n if (p.length != 2) {\n throw 'The link should be specified as \\'a->b\\'.';\n }\n previousLink = new Link(p[0], p[1]);\n graph.addLink(previousLink);\n }\n if (Utils.isObject(part)) {\n if (!previousLink) {\n throw 'Specification found before Link definition.';\n }\n kendo.deepExtend(previousLink, part);\n }\n }\n return graph;\n },\n linearize: function (graph, addIds) {\n if (Utils.isUndefined(graph)) {\n throw 'Expected an instance of a Graph object in slot one.';\n }\n if (Utils.isUndefined(addIds)) {\n addIds = false;\n }\n var lin = [];\n for (var i = 0, len = graph.links.length; i < len; i++) {\n var link = graph.links[i];\n lin.push(link.source.id + '->' + link.target.id);\n if (addIds) {\n lin.push({ id: link.id });\n }\n }\n return lin;\n },\n _addShape: function (kendoDiagram, p, id, shapeDefaults) {\n if (Utils.isUndefined(p)) {\n p = new diagram.Point(0, 0);\n }\n if (Utils.isUndefined(id)) {\n id = randomId();\n }\n shapeDefaults = kendo.deepExtend({\n width: 20,\n height: 20,\n id: id,\n radius: 10,\n fill: '#778899',\n data: 'circle',\n undoable: false,\n x: p.x,\n y: p.y\n }, shapeDefaults);\n return kendoDiagram.addShape(shapeDefaults);\n },\n _addConnection: function (diagram, from, to, options) {\n return diagram.connect(from, to, options);\n },\n createDiagramFromGraph: function (diagram, graph, doLayout, randomSize) {\n if (Utils.isUndefined(diagram)) {\n throw 'The diagram surface is undefined.';\n }\n if (Utils.isUndefined(graph)) {\n throw 'No graph specification defined.';\n }\n if (Utils.isUndefined(doLayout)) {\n doLayout = true;\n }\n if (Utils.isUndefined(randomSize)) {\n randomSize = false;\n }\n var width = diagram.element.clientWidth || 200;\n var height = diagram.element.clientHeight || 200;\n var map = [], node, shape;\n for (var i = 0, len = graph.nodes.length; i < len; i++) {\n node = graph.nodes[i];\n var p = node.position;\n if (Utils.isUndefined(p)) {\n if (Utils.isDefined(node.x) && Utils.isDefined(node.y)) {\n p = new Point(node.x, node.y);\n } else {\n p = new Point(Utils.randomInteger(10, width - 20), Utils.randomInteger(10, height - 20));\n }\n }\n var opt = {};\n if (node.id === '0') {\n } else if (randomSize) {\n kendo.deepExtend(opt, {\n width: Math.random() * 150 + 20,\n height: Math.random() * 80 + 50,\n data: 'rectangle',\n fill: { color: '#778899' }\n });\n }\n shape = this._addShape(diagram, p, node.id, opt);\n var bounds = shape.bounds();\n if (Utils.isDefined(bounds)) {\n node.x = bounds.x;\n node.y = bounds.y;\n node.width = bounds.width;\n node.height = bounds.height;\n }\n map[node.id] = shape;\n }\n for (var gli = 0; gli < graph.links.length; gli++) {\n var link = graph.links[gli];\n var sourceShape = map[link.source.id];\n if (Utils.isUndefined(sourceShape)) {\n continue;\n }\n var targetShape = map[link.target.id];\n if (Utils.isUndefined(targetShape)) {\n continue;\n }\n this._addConnection(diagram, sourceShape, targetShape, { id: link.id });\n }\n if (doLayout) {\n var l = new diagram.SpringLayout(diagram);\n l.layoutGraph(graph, { limitToView: false });\n for (var shi = 0; shi < graph.nodes.length; shi++) {\n node = graph.nodes[shi];\n shape = map[node.id];\n shape.bounds(new Rect(node.x, node.y, node.width, node.height));\n }\n }\n },\n createBalancedTree: function (levels, siblingsCount) {\n if (Utils.isUndefined(levels)) {\n levels = 3;\n }\n if (Utils.isUndefined(siblingsCount)) {\n siblingsCount = 3;\n }\n var g = new diagram.Graph(), counter = -1, lastAdded = [], news;\n if (levels <= 0 || siblingsCount <= 0) {\n return g;\n }\n var root = new Node((++counter).toString());\n g.addNode(root);\n g.root = root;\n lastAdded.push(root);\n for (var i = 0; i < levels; i++) {\n news = [];\n for (var j = 0; j < lastAdded.length; j++) {\n var parent = lastAdded[j];\n for (var k = 0; k < siblingsCount; k++) {\n var item = new Node((++counter).toString());\n g.addLink(parent, item);\n news.push(item);\n }\n }\n lastAdded = news;\n }\n return g;\n },\n createBalancedForest: function (levels, siblingsCount, treeCount) {\n if (Utils.isUndefined(levels)) {\n levels = 3;\n }\n if (Utils.isUndefined(siblingsCount)) {\n siblingsCount = 3;\n }\n if (Utils.isUndefined(treeCount)) {\n treeCount = 5;\n }\n var g = new diagram.Graph(), counter = -1, lastAdded = [], news;\n if (levels <= 0 || siblingsCount <= 0 || treeCount <= 0) {\n return g;\n }\n for (var t = 0; t < treeCount; t++) {\n var root = new Node((++counter).toString());\n g.addNode(root);\n lastAdded = [root];\n for (var i = 0; i < levels; i++) {\n news = [];\n for (var j = 0; j < lastAdded.length; j++) {\n var parent = lastAdded[j];\n for (var k = 0; k < siblingsCount; k++) {\n var item = new Node((++counter).toString());\n g.addLink(parent, item);\n news.push(item);\n }\n }\n lastAdded = news;\n }\n }\n return g;\n },\n createRandomConnectedGraph: function (nodeCount, maxIncidence, isTree) {\n if (Utils.isUndefined(nodeCount)) {\n nodeCount = 40;\n }\n if (Utils.isUndefined(maxIncidence)) {\n maxIncidence = 4;\n }\n if (Utils.isUndefined(isTree)) {\n isTree = false;\n }\n var g = new diagram.Graph(), counter = -1;\n if (nodeCount <= 0) {\n return g;\n }\n var root = new Node((++counter).toString());\n g.addNode(root);\n if (nodeCount === 1) {\n return g;\n }\n if (nodeCount > 1) {\n for (var i = 1; i < nodeCount; i++) {\n var poolNode = g.takeRandomNode([], maxIncidence);\n if (!poolNode) {\n break;\n }\n var newNode = g.addNode(i.toString());\n g.addLink(poolNode, newNode);\n }\n if (!isTree && nodeCount > 1) {\n var randomAdditions = Utils.randomInteger(1, nodeCount);\n for (var ri = 0; ri < randomAdditions; ri++) {\n var n1 = g.takeRandomNode([], maxIncidence);\n var n2 = g.takeRandomNode([], maxIncidence);\n if (n1 && n2 && !g.areConnected(n1, n2)) {\n g.addLink(n1, n2);\n }\n }\n }\n return g;\n }\n },\n randomDiagram: function (diagram, shapeCount, maxIncidence, isTree, randomSize) {\n var g = kendo.dataviz.diagram.Graph.Utils.createRandomConnectedGraph(shapeCount, maxIncidence, isTree);\n Graph.Utils.createDiagramFromGraph(diagram, g, false, randomSize);\n }\n };\n kendo.deepExtend(diagram, {\n init: function (element) {\n kendo.init(element, diagram.ui);\n },\n Point: Point,\n Intersect: Intersect,\n Geometry: Geometry,\n Rect: Rect,\n Size: Size,\n RectAlign: RectAlign,\n Matrix: Matrix,\n MatrixVector: MatrixVector,\n normalVariable: normalVariable,\n randomId: randomId,\n Dictionary: Dictionary,\n HashTable: HashTable,\n Queue: Queue,\n Set: Set,\n Node: Node,\n Link: Link,\n Graph: Graph,\n PathDefiner: PathDefiner\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('dataviz/diagram/svg', [\n 'kendo.drawing',\n 'dataviz/diagram/math'\n ], f);\n}(function () {\n (function ($, undefined) {\n var kendo = window.kendo, diagram = kendo.dataviz.diagram, Class = kendo.Class, deepExtend = kendo.deepExtend, Point = diagram.Point, Rect = diagram.Rect, Matrix = diagram.Matrix, Utils = diagram.Utils, isNumber = Utils.isNumber, isString = Utils.isString, MatrixVector = diagram.MatrixVector, g = kendo.geometry, d = kendo.drawing, defined = d.util.defined, inArray = $.inArray;\n var TRANSPARENT = 'transparent', Markers = {\n none: 'none',\n arrowStart: 'ArrowStart',\n filledCircle: 'FilledCircle',\n arrowEnd: 'ArrowEnd'\n }, FULL_CIRCLE_ANGLE = 360, START = 'start', END = 'end', WIDTH = 'width', HEIGHT = 'height', X = 'x', Y = 'y';\n diagram.Markers = Markers;\n function diffNumericOptions(options, fields) {\n var elementOptions = this.options;\n var hasChanges = false;\n var value, field;\n for (var i = 0; i < fields.length; i++) {\n field = fields[i];\n value = options[field];\n if (isNumber(value) && elementOptions[field] !== value) {\n elementOptions[field] = value;\n hasChanges = true;\n }\n }\n return hasChanges;\n }\n var Scale = Class.extend({\n init: function (x, y) {\n this.x = x;\n this.y = y;\n },\n toMatrix: function () {\n return Matrix.scaling(this.x, this.y);\n },\n toString: function () {\n return kendo.format('scale({0},{1})', this.x, this.y);\n },\n invert: function () {\n return new Scale(1 / this.x, 1 / this.y);\n }\n });\n var Translation = Class.extend({\n init: function (x, y) {\n this.x = x;\n this.y = y;\n },\n toMatrixVector: function () {\n return new MatrixVector(0, 0, 0, 0, this.x, this.y);\n },\n toMatrix: function () {\n return Matrix.translation(this.x, this.y);\n },\n toString: function () {\n return kendo.format('translate({0},{1})', this.x, this.y);\n },\n plus: function (delta) {\n this.x += delta.x;\n this.y += delta.y;\n },\n times: function (factor) {\n this.x *= factor;\n this.y *= factor;\n },\n length: function () {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n normalize: function () {\n if (this.Length === 0) {\n return;\n }\n this.times(1 / this.length());\n },\n invert: function () {\n return new Translation(-this.x, -this.y);\n }\n });\n var Rotation = Class.extend({\n init: function (angle, x, y) {\n this.x = x || 0;\n this.y = y || 0;\n this.angle = angle;\n },\n toString: function () {\n if (this.x && this.y) {\n return kendo.format('rotate({0},{1},{2})', this.angle, this.x, this.y);\n } else {\n return kendo.format('rotate({0})', this.angle);\n }\n },\n toMatrix: function () {\n return Matrix.rotation(this.angle, this.x, this.y);\n },\n center: function () {\n return new Point(this.x, this.y);\n },\n invert: function () {\n return new Rotation(FULL_CIRCLE_ANGLE - this.angle, this.x, this.y);\n }\n });\n Rotation.ZERO = new Rotation(0);\n Rotation.create = function (rotation) {\n return new Rotation(rotation.angle, rotation.x, rotation.y);\n };\n Rotation.parse = function (str) {\n var values = str.slice(1, str.length - 1).split(','), angle = values[0], x = values[1], y = values[2];\n var rotation = new Rotation(angle, x, y);\n return rotation;\n };\n var CompositeTransform = Class.extend({\n init: function (x, y, scaleX, scaleY, angle, center) {\n this.translate = new Translation(x, y);\n if (scaleX !== undefined && scaleY !== undefined) {\n this.scale = new Scale(scaleX, scaleY);\n }\n if (angle !== undefined) {\n this.rotate = center ? new Rotation(angle, center.x, center.y) : new Rotation(angle);\n }\n },\n toString: function () {\n var toString = function (transform) {\n return transform ? transform.toString() : '';\n };\n return toString(this.translate) + toString(this.rotate) + toString(this.scale);\n },\n render: function (visual) {\n visual._transform = this;\n visual._renderTransform();\n },\n toMatrix: function () {\n var m = Matrix.unit();\n if (this.translate) {\n m = m.times(this.translate.toMatrix());\n }\n if (this.rotate) {\n m = m.times(this.rotate.toMatrix());\n }\n if (this.scale) {\n m = m.times(this.scale.toMatrix());\n }\n return m;\n },\n invert: function () {\n var rotate = this.rotate ? this.rotate.invert() : undefined, rotateMatrix = rotate ? rotate.toMatrix() : Matrix.unit(), scale = this.scale ? this.scale.invert() : undefined, scaleMatrix = scale ? scale.toMatrix() : Matrix.unit();\n var translatePoint = new Point(-this.translate.x, -this.translate.y);\n translatePoint = rotateMatrix.times(scaleMatrix).apply(translatePoint);\n var translate = new Translation(translatePoint.x, translatePoint.y);\n var transform = new CompositeTransform();\n transform.translate = translate;\n transform.rotate = rotate;\n transform.scale = scale;\n return transform;\n }\n });\n var AutoSizeableMixin = {\n _setScale: function () {\n var options = this.options;\n var originWidth = this._originWidth;\n var originHeight = this._originHeight;\n var scaleX = options.width / originWidth;\n var scaleY = options.height / originHeight;\n if (!isNumber(scaleX)) {\n scaleX = 1;\n }\n if (!isNumber(scaleY)) {\n scaleY = 1;\n }\n this._transform.scale = new Scale(scaleX, scaleY);\n },\n _setTranslate: function () {\n var options = this.options;\n var x = options.x || 0;\n var y = options.y || 0;\n this._transform.translate = new Translation(x, y);\n },\n _initSize: function () {\n var options = this.options;\n var transform = false;\n if (options.autoSize !== false && (defined(options.width) || defined(options.height))) {\n this._measure(true);\n this._setScale();\n transform = true;\n }\n if (defined(options.x) || defined(options.y)) {\n this._setTranslate();\n transform = true;\n }\n if (transform) {\n this._renderTransform();\n }\n },\n _updateSize: function (options) {\n var update = false;\n if (this.options.autoSize !== false && this._diffNumericOptions(options, [\n WIDTH,\n HEIGHT\n ])) {\n update = true;\n this._measure(true);\n this._setScale();\n }\n if (this._diffNumericOptions(options, [\n X,\n Y\n ])) {\n update = true;\n this._setTranslate();\n }\n if (update) {\n this._renderTransform();\n }\n return update;\n }\n };\n var Element = Class.extend({\n init: function (options) {\n var element = this;\n element.options = deepExtend({}, element.options, options);\n element.id = element.options.id;\n element._originSize = Rect.empty();\n element._transform = new CompositeTransform();\n },\n visible: function (value) {\n return this.drawingContainer().visible(value);\n },\n redraw: function (options) {\n if (options && options.id) {\n this.id = options.id;\n }\n },\n position: function (x, y) {\n var options = this.options;\n if (!defined(x)) {\n return new Point(options.x, options.y);\n }\n if (defined(y)) {\n options.x = x;\n options.y = y;\n } else if (x instanceof Point) {\n options.x = x.x;\n options.y = x.y;\n }\n this._transform.translate = new Translation(options.x, options.y);\n this._renderTransform();\n },\n rotate: function (angle, center) {\n if (defined(angle)) {\n this._transform.rotate = new Rotation(angle, center.x, center.y);\n this._renderTransform();\n }\n return this._transform.rotate || Rotation.ZERO;\n },\n drawingContainer: function () {\n return this.drawingElement;\n },\n _renderTransform: function () {\n var matrix = this._transform.toMatrix();\n this.drawingContainer().transform(new g.Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f));\n },\n _hover: function () {\n },\n _diffNumericOptions: diffNumericOptions,\n _measure: function (force) {\n var rect;\n if (!this._measured || force) {\n var box = this._boundingBox() || new g.Rect();\n var startPoint = box.topLeft();\n rect = new Rect(startPoint.x, startPoint.y, box.width(), box.height());\n this._originSize = rect;\n this._originWidth = rect.width;\n this._originHeight = rect.height;\n this._measured = true;\n } else {\n rect = this._originSize;\n }\n return rect;\n },\n _boundingBox: function () {\n return this.drawingElement.rawBBox();\n }\n });\n var VisualBase = Element.extend({\n init: function (options) {\n Element.fn.init.call(this, options);\n options = this.options;\n options.fill = normalizeDrawingOptions(options.fill);\n options.stroke = normalizeDrawingOptions(options.stroke);\n },\n options: {\n stroke: {\n color: 'gray',\n width: 1\n },\n fill: { color: TRANSPARENT }\n },\n fill: function (color, opacity) {\n this._fill({\n color: getColor(color),\n opacity: opacity\n });\n },\n stroke: function (color, width, opacity) {\n this._stroke({\n color: getColor(color),\n width: width,\n opacity: opacity\n });\n },\n redraw: function (options) {\n if (options) {\n var stroke = options.stroke;\n var fill = options.fill;\n if (stroke) {\n this._stroke(normalizeDrawingOptions(stroke));\n }\n if (fill) {\n this._fill(normalizeDrawingOptions(fill));\n }\n Element.fn.redraw.call(this, options);\n }\n },\n _hover: function (show) {\n var drawingElement = this.drawingElement;\n var options = this.options;\n var hover = options.hover;\n if (hover && hover.fill) {\n var fill = show ? normalizeDrawingOptions(hover.fill) : options.fill;\n drawingElement.fill(fill.color, fill.opacity);\n }\n },\n _stroke: function (strokeOptions) {\n var options = this.options;\n deepExtend(options, { stroke: strokeOptions });\n strokeOptions = options.stroke;\n var stroke = null;\n if (strokeOptions.width > 0) {\n stroke = {\n color: strokeOptions.color,\n width: strokeOptions.width,\n opacity: strokeOptions.opacity,\n dashType: strokeOptions.dashType\n };\n }\n this.drawingElement.options.set('stroke', stroke);\n },\n _fill: function (fillOptions) {\n var options = this.options;\n deepExtend(options, { fill: fillOptions || {} });\n var fill = options.fill;\n if (fill.gradient) {\n var gradient = fill.gradient;\n var GradientClass = gradient.type === 'radial' ? d.RadialGradient : d.LinearGradient;\n this.drawingElement.fill(new GradientClass(gradient));\n } else {\n this.drawingElement.fill(fill.color, fill.opacity);\n }\n }\n });\n var TextBlock = VisualBase.extend({\n init: function (options) {\n options = this._textColor(options);\n VisualBase.fn.init.call(this, options);\n this._font();\n this._initText();\n this._initSize();\n },\n options: {\n fontSize: 15,\n fontFamily: 'sans-serif',\n stroke: { width: 0 },\n fill: { color: 'black' },\n autoSize: true\n },\n _initText: function () {\n var options = this.options;\n this.drawingElement = new d.Text(defined(options.text) ? options.text : '', new g.Point(), { font: options.font });\n this._fill();\n this._stroke();\n },\n _textColor: function (options) {\n if (options && options.color) {\n options = deepExtend({}, options, { fill: { color: options.color } });\n }\n return options;\n },\n _font: function () {\n var options = this.options;\n if (options.fontFamily && defined(options.fontSize)) {\n var fontOptions = [];\n if (options.fontStyle) {\n fontOptions.push(options.fontStyle);\n }\n if (options.fontWeight) {\n fontOptions.push(options.fontWeight);\n }\n fontOptions.push(options.fontSize + (isNumber(options.fontSize) ? 'px' : ''));\n fontOptions.push(options.fontFamily);\n options.font = fontOptions.join(' ');\n } else {\n delete options.font;\n }\n },\n content: function (text) {\n return this.drawingElement.content(text);\n },\n redraw: function (options) {\n if (options) {\n var sizeChanged = false;\n var textOptions = this.options;\n options = this._textColor(options);\n VisualBase.fn.redraw.call(this, options);\n if (options.fontFamily || defined(options.fontSize) || options.fontStyle || options.fontWeight) {\n deepExtend(textOptions, {\n fontFamily: options.fontFamily,\n fontSize: options.fontSize,\n fontStyle: options.fontStyle,\n fontWeight: options.fontWeight\n });\n this._font();\n this.drawingElement.options.set('font', textOptions.font);\n sizeChanged = true;\n }\n if (options.text) {\n this.content(options.text);\n sizeChanged = true;\n }\n if (!this._updateSize(options) && sizeChanged) {\n this._initSize();\n }\n }\n }\n });\n deepExtend(TextBlock.fn, AutoSizeableMixin);\n var Rectangle = VisualBase.extend({\n init: function (options) {\n VisualBase.fn.init.call(this, options);\n this._initPath();\n this._setPosition();\n },\n _setPosition: function () {\n var options = this.options;\n var x = options.x;\n var y = options.y;\n if (defined(x) || defined(y)) {\n this.position(x || 0, y || 0);\n }\n },\n redraw: function (options) {\n if (options) {\n VisualBase.fn.redraw.call(this, options);\n if (this._diffNumericOptions(options, [\n WIDTH,\n HEIGHT\n ])) {\n this._drawPath();\n }\n if (this._diffNumericOptions(options, [\n X,\n Y\n ])) {\n this._setPosition();\n }\n }\n },\n _initPath: function () {\n var options = this.options;\n this.drawingElement = new d.Path({\n stroke: options.stroke,\n closed: true\n });\n this._fill();\n this._drawPath();\n },\n _drawPath: function () {\n var drawingElement = this.drawingElement;\n var sizeOptions = sizeOptionsOrDefault(this.options);\n var width = sizeOptions.width;\n var height = sizeOptions.height;\n drawingElement.segments.elements([\n createSegment(0, 0),\n createSegment(width, 0),\n createSegment(width, height),\n createSegment(0, height)\n ]);\n }\n });\n var MarkerBase = VisualBase.extend({\n init: function (options) {\n VisualBase.fn.init.call(this, options);\n var anchor = this.options.anchor;\n this.anchor = new g.Point(anchor.x, anchor.y);\n this.createElement();\n },\n options: {\n stroke: {\n color: TRANSPARENT,\n width: 0\n },\n fill: { color: 'black' }\n },\n _transformToPath: function (point, path) {\n var transform = path.transform();\n if (point && transform) {\n point = point.transformCopy(transform);\n }\n return point;\n },\n redraw: function (options) {\n if (options) {\n if (options.position) {\n this.options.position = options.position;\n }\n VisualBase.fn.redraw.call(this, options);\n }\n }\n });\n var CircleMarker = MarkerBase.extend({\n options: {\n radius: 4,\n anchor: {\n x: 0,\n y: 0\n }\n },\n createElement: function () {\n var options = this.options;\n this.drawingElement = new d.Circle(new g.Circle(this.anchor, options.radius), {\n fill: options.fill,\n stroke: options.stroke\n });\n },\n positionMarker: function (path) {\n var options = this.options;\n var position = options.position;\n var segments = path.segments;\n var targetSegment;\n var point;\n if (position == START) {\n targetSegment = segments[0];\n } else {\n targetSegment = segments[segments.length - 1];\n }\n if (targetSegment) {\n point = this._transformToPath(targetSegment.anchor(), path);\n this.drawingElement.transform(g.transform().translate(point.x, point.y));\n }\n }\n });\n var ArrowMarker = MarkerBase.extend({\n options: {\n path: 'M 0 0 L 10 5 L 0 10 L 3 5 z',\n anchor: {\n x: 10,\n y: 5\n }\n },\n createElement: function () {\n var options = this.options;\n this.drawingElement = d.Path.parse(options.path, {\n fill: options.fill,\n stroke: options.stroke\n });\n },\n positionMarker: function (path) {\n var points = this._linePoints(path);\n var start = points.start;\n var end = points.end;\n var transform = g.transform();\n if (start) {\n transform.rotate(lineAngle(start, end), end);\n }\n if (end) {\n var anchor = this.anchor;\n var translate = end.clone().translate(-anchor.x, -anchor.y);\n transform.translate(translate.x, translate.y);\n }\n this.drawingElement.transform(transform);\n },\n _linePoints: function (path) {\n var options = this.options;\n var segments = path.segments;\n var startPoint, endPoint, targetSegment;\n if (options.position == START) {\n targetSegment = segments[0];\n if (targetSegment) {\n endPoint = targetSegment.anchor();\n startPoint = targetSegment.controlOut();\n var nextSegment = segments[1];\n if (!startPoint && nextSegment) {\n startPoint = nextSegment.anchor();\n }\n }\n } else {\n targetSegment = segments[segments.length - 1];\n if (targetSegment) {\n endPoint = targetSegment.anchor();\n startPoint = targetSegment.controlIn();\n var prevSegment = segments[segments.length - 2];\n if (!startPoint && prevSegment) {\n startPoint = prevSegment.anchor();\n }\n }\n }\n if (endPoint) {\n return {\n start: this._transformToPath(startPoint, path),\n end: this._transformToPath(endPoint, path)\n };\n }\n }\n });\n var MarkerPathMixin = {\n _getPath: function (position) {\n var path = this.drawingElement;\n if (path instanceof d.MultiPath) {\n if (position == START) {\n path = path.paths[0];\n } else {\n path = path.paths[path.paths.length - 1];\n }\n }\n if (path && path.segments.length) {\n return path;\n }\n },\n _normalizeMarkerOptions: function (options) {\n var startCap = options.startCap;\n var endCap = options.endCap;\n if (isString(startCap)) {\n options.startCap = { type: startCap };\n }\n if (isString(endCap)) {\n options.endCap = { type: endCap };\n }\n },\n _removeMarker: function (position) {\n var marker = this._markers[position];\n if (marker) {\n this.drawingContainer().remove(marker.drawingElement);\n delete this._markers[position];\n }\n },\n _createMarkers: function () {\n var options = this.options;\n this._normalizeMarkerOptions(options);\n this._markers = {};\n this._markers[START] = this._createMarker(options.startCap, START);\n this._markers[END] = this._createMarker(options.endCap, END);\n },\n _createMarker: function (options, position) {\n var type = (options || {}).type;\n var path = this._getPath(position);\n var markerType, marker;\n if (!path) {\n this._removeMarker(position);\n return;\n }\n if (type == Markers.filledCircle) {\n markerType = CircleMarker;\n } else if (type == Markers.arrowStart || type == Markers.arrowEnd) {\n markerType = ArrowMarker;\n } else {\n this._removeMarker(position);\n }\n if (markerType) {\n marker = new markerType(deepExtend({}, options, { position: position }));\n marker.positionMarker(path);\n this.drawingContainer().append(marker.drawingElement);\n return marker;\n }\n },\n _positionMarker: function (position) {\n var marker = this._markers[position];\n if (marker) {\n var path = this._getPath(position);\n if (path) {\n marker.positionMarker(path);\n } else {\n this._removeMarker(position);\n }\n }\n },\n _capMap: {\n start: 'startCap',\n end: 'endCap'\n },\n _redrawMarker: function (pathChange, position, options) {\n this._normalizeMarkerOptions(options);\n var pathOptions = this.options;\n var cap = this._capMap[position];\n var pathCapType = (pathOptions[cap] || {}).type;\n var optionsCap = options[cap];\n var created = false;\n if (optionsCap) {\n pathOptions[cap] = deepExtend({}, pathOptions[cap], optionsCap);\n if (optionsCap.type && pathCapType != optionsCap.type) {\n this._removeMarker(position);\n this._markers[position] = this._createMarker(pathOptions[cap], position);\n created = true;\n } else if (this._markers[position]) {\n this._markers[position].redraw(optionsCap);\n }\n } else if (pathChange && !this._markers[position] && pathOptions[cap]) {\n this._markers[position] = this._createMarker(pathOptions[cap], position);\n created = true;\n }\n return created;\n },\n _redrawMarkers: function (pathChange, options) {\n if (!this._redrawMarker(pathChange, START, options) && pathChange) {\n this._positionMarker(START);\n }\n if (!this._redrawMarker(pathChange, END, options) && pathChange) {\n this._positionMarker(END);\n }\n }\n };\n var Path = VisualBase.extend({\n init: function (options) {\n VisualBase.fn.init.call(this, options);\n this.container = new d.Group();\n this._createElements();\n this._initSize();\n },\n options: { autoSize: true },\n drawingContainer: function () {\n return this.container;\n },\n data: function (value) {\n var options = this.options;\n if (value) {\n if (options.data != value) {\n options.data = value;\n this._setData(value);\n this._initSize();\n this._redrawMarkers(true, {});\n }\n } else {\n return options.data;\n }\n },\n redraw: function (options) {\n if (options) {\n VisualBase.fn.redraw.call(this, options);\n var pathOptions = this.options;\n var data = options.data;\n if (defined(data) && pathOptions.data != data) {\n pathOptions.data = data;\n this._setData(data);\n if (!this._updateSize(options)) {\n this._initSize();\n }\n this._redrawMarkers(true, options);\n } else {\n this._updateSize(options);\n this._redrawMarkers(false, options);\n }\n }\n },\n _createElements: function () {\n var options = this.options;\n this.drawingElement = d.Path.parse(options.data || '', { stroke: options.stroke });\n this._fill();\n this.container.append(this.drawingElement);\n this._createMarkers();\n },\n _setData: function (data) {\n var drawingElement = this.drawingElement;\n var multipath = d.Path.parse(data || '');\n var paths = multipath.paths.slice(0);\n multipath.paths.elements([]);\n drawingElement.paths.elements(paths);\n }\n });\n deepExtend(Path.fn, AutoSizeableMixin);\n deepExtend(Path.fn, MarkerPathMixin);\n var Line = VisualBase.extend({\n init: function (options) {\n VisualBase.fn.init.call(this, options);\n this.container = new d.Group();\n this._initPath();\n this._createMarkers();\n },\n drawingContainer: function () {\n return this.container;\n },\n redraw: function (options) {\n if (options) {\n options = options || {};\n var from = options.from;\n var to = options.to;\n if (from) {\n this.options.from = from;\n }\n if (to) {\n this.options.to = to;\n }\n if (from || to) {\n this._drawPath();\n this._redrawMarkers(true, options);\n } else {\n this._redrawMarkers(false, options);\n }\n VisualBase.fn.redraw.call(this, options);\n }\n },\n _initPath: function () {\n var options = this.options;\n var drawingElement = this.drawingElement = new d.Path({ stroke: options.stroke });\n this._fill();\n this._drawPath();\n this.container.append(drawingElement);\n },\n _drawPath: function () {\n var options = this.options;\n var drawingElement = this.drawingElement;\n var from = options.from || new Point();\n var to = options.to || new Point();\n drawingElement.segments.elements([\n createSegment(from.x, from.y),\n createSegment(to.x, to.y)\n ]);\n }\n });\n deepExtend(Line.fn, MarkerPathMixin);\n var Polyline = VisualBase.extend({\n init: function (options) {\n VisualBase.fn.init.call(this, options);\n this.container = new d.Group();\n this._initPath();\n this._createMarkers();\n },\n drawingContainer: function () {\n return this.container;\n },\n points: function (points) {\n var options = this.options;\n if (points) {\n options.points = points;\n this._updatePath();\n } else {\n return options.points;\n }\n },\n redraw: function (options) {\n if (options) {\n var points = options.points;\n VisualBase.fn.redraw.call(this, options);\n if (points && this._pointsDiffer(points)) {\n this.points(points);\n this._redrawMarkers(true, options);\n } else {\n this._redrawMarkers(false, options);\n }\n }\n },\n _initPath: function () {\n var options = this.options;\n this.drawingElement = new d.Path({ stroke: options.stroke });\n this._fill();\n this.container.append(this.drawingElement);\n if (options.points) {\n this._updatePath();\n }\n },\n _pointsDiffer: function (points) {\n var currentPoints = this.options.points;\n var differ = currentPoints.length !== points.length;\n if (!differ) {\n for (var i = 0; i < points.length; i++) {\n if (currentPoints[i].x !== points[i].x || currentPoints[i].y !== points[i].y) {\n differ = true;\n break;\n }\n }\n }\n return differ;\n },\n _updatePath: function () {\n var drawingElement = this.drawingElement;\n var options = this.options;\n var points = options.points;\n var segments = [];\n var point;\n for (var i = 0; i < points.length; i++) {\n point = points[i];\n segments.push(createSegment(point.x, point.y));\n }\n drawingElement.segments.elements(segments);\n },\n options: { points: [] }\n });\n deepExtend(Polyline.fn, MarkerPathMixin);\n var Image = Element.extend({\n init: function (options) {\n Element.fn.init.call(this, options);\n this._initImage();\n },\n redraw: function (options) {\n if (options) {\n if (options.source) {\n this.drawingElement.src(options.source);\n }\n if (this._diffNumericOptions(options, [\n WIDTH,\n HEIGHT,\n X,\n Y\n ])) {\n this.drawingElement.rect(this._rect());\n }\n Element.fn.redraw.call(this, options);\n }\n },\n _initImage: function () {\n var options = this.options;\n var rect = this._rect();\n this.drawingElement = new d.Image(options.source, rect, {});\n },\n _rect: function () {\n var sizeOptions = sizeOptionsOrDefault(this.options);\n var origin = new g.Point(sizeOptions.x, sizeOptions.y);\n var size = new g.Size(sizeOptions.width, sizeOptions.height);\n return new g.Rect(origin, size);\n }\n });\n var Group = Element.extend({\n init: function (options) {\n this.children = [];\n Element.fn.init.call(this, options);\n this.drawingElement = new d.Group();\n this._initSize();\n },\n options: { autoSize: false },\n append: function (visual) {\n this.drawingElement.append(visual.drawingContainer());\n this.children.push(visual);\n this._childrenChange = true;\n },\n remove: function (visual) {\n if (this._remove(visual)) {\n this._childrenChange = true;\n }\n },\n _remove: function (visual) {\n var index = inArray(visual, this.children);\n if (index >= 0) {\n this.drawingElement.removeAt(index);\n this.children.splice(index, 1);\n return true;\n }\n },\n clear: function () {\n this.drawingElement.clear();\n this.children = [];\n this._childrenChange = true;\n },\n toFront: function (visuals) {\n var visual;\n for (var i = 0; i < visuals.length; i++) {\n visual = visuals[i];\n if (this._remove(visual)) {\n this.append(visual);\n }\n }\n },\n toBack: function (visuals) {\n this._reorderChildren(visuals, 0);\n },\n toIndex: function (visuals, indices) {\n this._reorderChildren(visuals, indices);\n },\n _reorderChildren: function (visuals, indices) {\n var group = this.drawingElement;\n var drawingChildren = group.children.slice(0);\n var children = this.children;\n var fixedPosition = isNumber(indices);\n var i, index, toIndex, drawingElement, visual;\n for (i = 0; i < visuals.length; i++) {\n visual = visuals[i];\n drawingElement = visual.drawingContainer();\n index = inArray(visual, children);\n if (index >= 0) {\n drawingChildren.splice(index, 1);\n children.splice(index, 1);\n toIndex = fixedPosition ? indices : indices[i];\n drawingChildren.splice(toIndex, 0, drawingElement);\n children.splice(toIndex, 0, visual);\n }\n }\n group.clear();\n group.append.apply(group, drawingChildren);\n },\n redraw: function (options) {\n if (options) {\n if (this._childrenChange) {\n this._childrenChange = false;\n if (!this._updateSize(options)) {\n this._initSize();\n }\n } else {\n this._updateSize(options);\n }\n Element.fn.redraw.call(this, options);\n }\n },\n _boundingBox: function () {\n var children = this.children;\n var boundingBox;\n var visual, childBoundingBox;\n for (var i = 0; i < children.length; i++) {\n visual = children[i];\n if (visual.visible() && visual._includeInBBox !== false) {\n childBoundingBox = visual.drawingContainer().clippedBBox(null);\n if (childBoundingBox) {\n if (boundingBox) {\n boundingBox = g.Rect.union(boundingBox, childBoundingBox);\n } else {\n boundingBox = childBoundingBox;\n }\n }\n }\n }\n return boundingBox;\n }\n });\n deepExtend(Group.fn, AutoSizeableMixin);\n var Layout = Group.extend({\n init: function (rect, options) {\n this.children = [];\n Element.fn.init.call(this, options);\n this.drawingElement = new d.Layout(toDrawingRect(rect), options);\n this._initSize();\n },\n rect: function (rect) {\n if (rect) {\n this.drawingElement.rect(toDrawingRect(rect));\n } else {\n var drawingRect = this.drawingElement.rect();\n if (drawingRect) {\n return new Rect(drawingRect.origin.x, drawingRect.origin.y, drawingRect.size.width, drawingRect.size.height);\n }\n }\n },\n reflow: function () {\n this.drawingElement.reflow();\n },\n redraw: function (options) {\n kendo.deepExtend(this.drawingElement.options, options);\n Group.fn.redraw.call(this, options);\n }\n });\n var Circle = VisualBase.extend({\n init: function (options) {\n VisualBase.fn.init.call(this, options);\n this._initCircle();\n this._initSize();\n },\n redraw: function (options) {\n if (options) {\n var circleOptions = this.options;\n if (options.center) {\n deepExtend(circleOptions, { center: options.center });\n this._center.move(circleOptions.center.x, circleOptions.center.y);\n }\n if (this._diffNumericOptions(options, ['radius'])) {\n this._circle.setRadius(circleOptions.radius);\n }\n this._updateSize(options);\n VisualBase.fn.redraw.call(this, options);\n }\n },\n _initCircle: function () {\n var options = this.options;\n var width = options.width;\n var height = options.height;\n var radius = options.radius;\n if (!defined(radius)) {\n if (!defined(width)) {\n width = height;\n }\n if (!defined(height)) {\n height = width;\n }\n options.radius = radius = Math.min(width, height) / 2;\n }\n var center = options.center || {\n x: radius,\n y: radius\n };\n this._center = new g.Point(center.x, center.y);\n this._circle = new g.Circle(this._center, radius);\n this.drawingElement = new d.Circle(this._circle, { stroke: options.stroke });\n this._fill();\n }\n });\n deepExtend(Circle.fn, AutoSizeableMixin);\n var Canvas = Class.extend({\n init: function (element, options) {\n options = options || {};\n this.element = element;\n this.surface = d.Surface.create(element, options);\n if (kendo.isFunction(this.surface.translate)) {\n this.translate = this._translate;\n }\n this.drawingElement = new d.Group();\n this._viewBox = new Rect(0, 0, options.width, options.height);\n this.size(this._viewBox);\n },\n bounds: function () {\n var box = this.drawingElement.clippedBBox();\n return new Rect(0, 0, box.width(), box.height());\n },\n size: function (size) {\n var viewBox = this._viewBox;\n if (defined(size)) {\n viewBox.width = size.width;\n viewBox.height = size.height;\n this.surface.setSize(size);\n }\n return {\n width: viewBox.width,\n height: viewBox.height\n };\n },\n _translate: function (x, y) {\n var viewBox = this._viewBox;\n if (defined(x) && defined(y)) {\n viewBox.x = x;\n viewBox.y = y;\n this.surface.translate({\n x: x,\n y: y\n });\n }\n return {\n x: viewBox.x,\n y: viewBox.y\n };\n },\n draw: function () {\n this.surface.draw(this.drawingElement);\n },\n append: function (visual) {\n this.drawingElement.append(visual.drawingContainer());\n return this;\n },\n remove: function (visual) {\n this.drawingElement.remove(visual.drawingContainer());\n },\n insertBefore: function () {\n },\n clear: function () {\n this.drawingElement.clear();\n },\n destroy: function (clearHtml) {\n this.surface.destroy();\n if (clearHtml) {\n $(this.element).remove();\n }\n }\n });\n function sizeOptionsOrDefault(options) {\n return {\n x: options.x || 0,\n y: options.y || 0,\n width: options.width || 0,\n height: options.height || 0\n };\n }\n function normalizeDrawingOptions(options) {\n if (options) {\n var drawingOptions = options;\n if (isString(drawingOptions)) {\n drawingOptions = { color: drawingOptions };\n }\n if (drawingOptions.color) {\n drawingOptions.color = getColor(drawingOptions.color);\n }\n return drawingOptions;\n }\n }\n function getColor(value) {\n var color;\n if (value != TRANSPARENT) {\n color = new d.Color(value).toHex();\n } else {\n color = value;\n }\n return color;\n }\n function lineAngle(p1, p2) {\n var xDiff = p2.x - p1.x;\n var yDiff = p2.y - p1.y;\n var angle = d.util.deg(Math.atan2(yDiff, xDiff));\n return angle;\n }\n function createSegment(x, y) {\n return new d.Segment(new g.Point(x, y));\n }\n function toDrawingRect(rect) {\n if (rect) {\n return new g.Rect([\n rect.x,\n rect.y\n ], [\n rect.width,\n rect.height\n ]);\n }\n }\n kendo.deepExtend(diagram, {\n init: function (element) {\n kendo.init(element, diagram.ui);\n },\n diffNumericOptions: diffNumericOptions,\n Element: Element,\n Scale: Scale,\n Translation: Translation,\n Rotation: Rotation,\n Circle: Circle,\n Group: Group,\n Rectangle: Rectangle,\n Canvas: Canvas,\n Path: Path,\n Layout: Layout,\n Line: Line,\n MarkerBase: MarkerBase,\n ArrowMarker: ArrowMarker,\n CircleMarker: CircleMarker,\n Polyline: Polyline,\n CompositeTransform: CompositeTransform,\n TextBlock: TextBlock,\n Image: Image,\n VisualBase: VisualBase\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('dataviz/diagram/services', [\n 'kendo.drawing',\n 'dataviz/diagram/svg'\n ], f);\n}(function () {\n (function ($, undefined) {\n var kendo = window.kendo, dataviz = kendo.dataviz, diagram = dataviz.diagram, Class = kendo.Class, Group = diagram.Group, Rect = diagram.Rect, Rectangle = diagram.Rectangle, Utils = diagram.Utils, isUndefined = Utils.isUndefined, Point = diagram.Point, Circle = diagram.Circle, Ticker = diagram.Ticker, deepExtend = kendo.deepExtend, Movable = kendo.ui.Movable, browser = kendo.support.browser, util = kendo.drawing.util, defined = util.defined, inArray = $.inArray, proxy = $.proxy;\n var Cursors = {\n arrow: 'default',\n grip: 'pointer',\n cross: 'pointer',\n add: 'pointer',\n move: 'move',\n select: 'pointer',\n south: 's-resize',\n east: 'e-resize',\n west: 'w-resize',\n north: 'n-resize',\n rowresize: 'row-resize',\n colresize: 'col-resize'\n }, HIT_TEST_DISTANCE = 10, AUTO = 'Auto', TOP = 'Top', RIGHT = 'Right', LEFT = 'Left', BOTTOM = 'Bottom', DEFAULT_SNAP_SIZE = 10, DEFAULT_SNAP_ANGLE = 10, DRAG_START = 'dragStart', DRAG = 'drag', DRAG_END = 'dragEnd', ITEMROTATE = 'itemRotate', ITEMBOUNDSCHANGE = 'itemBoundsChange', MIN_SNAP_SIZE = 5, MIN_SNAP_ANGLE = 5, MOUSE_ENTER = 'mouseEnter', MOUSE_LEAVE = 'mouseLeave', ZOOM_START = 'zoomStart', ZOOM_END = 'zoomEnd', SCROLL_MIN = -20000, SCROLL_MAX = 20000, FRICTION = 0.9, FRICTION_MOBILE = 0.93, VELOCITY_MULTIPLIER = 5, TRANSPARENT = 'transparent', PAN = 'pan', ROTATED = 'rotated', SOURCE = 'source', TARGET = 'target', HANDLE_NAMES = {\n '-1': SOURCE,\n '1': TARGET\n };\n diagram.Cursors = Cursors;\n var PositionAdapter = kendo.Class.extend({\n init: function (layoutState) {\n this.layoutState = layoutState;\n this.diagram = layoutState.diagram;\n },\n initState: function () {\n this.froms = [];\n this.tos = [];\n this.subjects = [];\n function pusher(id, bounds) {\n var shape = this.diagram.getShapeById(id);\n if (shape) {\n this.subjects.push(shape);\n this.froms.push(shape.bounds().topLeft());\n this.tos.push(bounds.topLeft());\n }\n }\n this.layoutState.nodeMap.forEach(pusher, this);\n },\n update: function (tick) {\n if (this.subjects.length <= 0) {\n return;\n }\n for (var i = 0; i < this.subjects.length; i++) {\n this.subjects[i].position(new Point(this.froms[i].x + (this.tos[i].x - this.froms[i].x) * tick, this.froms[i].y + (this.tos[i].y - this.froms[i].y) * tick));\n }\n }\n });\n var LayoutUndoUnit = Class.extend({\n init: function (initialState, finalState, animate) {\n if (isUndefined(animate)) {\n this.animate = false;\n } else {\n this.animate = animate;\n }\n this._initialState = initialState;\n this._finalState = finalState;\n this.title = 'Diagram layout';\n },\n undo: function () {\n this.setState(this._initialState);\n },\n redo: function () {\n this.setState(this._finalState);\n },\n setState: function (state) {\n var diagram = state.diagram;\n if (this.animate) {\n state.linkMap.forEach(function (id, points) {\n var conn = diagram.getShapeById(id);\n conn.visible(false);\n if (conn) {\n conn.points(points);\n }\n });\n var ticker = new Ticker();\n ticker.addAdapter(new PositionAdapter(state));\n ticker.onComplete(function () {\n state.linkMap.forEach(function (id) {\n var conn = diagram.getShapeById(id);\n conn.visible(true);\n });\n });\n ticker.play();\n } else {\n state.nodeMap.forEach(function (id, bounds) {\n var shape = diagram.getShapeById(id);\n if (shape) {\n shape.position(bounds.topLeft());\n }\n });\n state.linkMap.forEach(function (id, points) {\n var conn = diagram.getShapeById(id);\n if (conn) {\n conn.points(points);\n }\n });\n }\n }\n });\n var CompositeUnit = Class.extend({\n init: function (unit) {\n this.units = [];\n this.title = 'Composite unit';\n if (unit !== undefined) {\n this.units.push(unit);\n }\n },\n add: function (undoUnit) {\n this.units.push(undoUnit);\n },\n undo: function () {\n for (var i = 0; i < this.units.length; i++) {\n this.units[i].undo();\n }\n },\n redo: function () {\n for (var i = 0; i < this.units.length; i++) {\n this.units[i].redo();\n }\n }\n });\n var ConnectionEditUnit = Class.extend({\n init: function (item, redoSource, redoTarget) {\n this.item = item;\n this._redoSource = redoSource;\n this._redoTarget = redoTarget;\n if (defined(redoSource)) {\n this._undoSource = item.source();\n }\n if (defined(redoTarget)) {\n this._undoTarget = item.target();\n }\n this.title = 'Connection Editing';\n },\n undo: function () {\n if (this._undoSource !== undefined) {\n this.item._updateConnector(this._undoSource, 'source');\n }\n if (this._undoTarget !== undefined) {\n this.item._updateConnector(this._undoTarget, 'target');\n }\n this.item.updateModel();\n },\n redo: function () {\n if (this._redoSource !== undefined) {\n this.item._updateConnector(this._redoSource, 'source');\n }\n if (this._redoTarget !== undefined) {\n this.item._updateConnector(this._redoTarget, 'target');\n }\n this.item.updateModel();\n }\n });\n var ConnectionEditUndoUnit = Class.extend({\n init: function (item, undoSource, undoTarget) {\n this.item = item;\n this._undoSource = undoSource;\n this._undoTarget = undoTarget;\n this._redoSource = item.source();\n this._redoTarget = item.target();\n this.title = 'Connection Editing';\n },\n undo: function () {\n this.item._updateConnector(this._undoSource, 'source');\n this.item._updateConnector(this._undoTarget, 'target');\n this.item.updateModel();\n },\n redo: function () {\n this.item._updateConnector(this._redoSource, 'source');\n this.item._updateConnector(this._redoTarget, 'target');\n this.item.updateModel();\n }\n });\n var DeleteConnectionUnit = Class.extend({\n init: function (connection) {\n this.connection = connection;\n this.diagram = connection.diagram;\n this.targetConnector = connection.targetConnector;\n this.title = 'Delete connection';\n },\n undo: function () {\n this.diagram._addConnection(this.connection, false);\n },\n redo: function () {\n this.diagram.remove(this.connection, false);\n }\n });\n var DeleteShapeUnit = Class.extend({\n init: function (shape) {\n this.shape = shape;\n this.diagram = shape.diagram;\n this.title = 'Deletion';\n },\n undo: function () {\n this.diagram._addShape(this.shape, false);\n this.shape.select(false);\n },\n redo: function () {\n this.shape.select(false);\n this.diagram.remove(this.shape, false);\n }\n });\n var TransformUnit = Class.extend({\n init: function (shapes, undoStates, adorner) {\n this.shapes = shapes;\n this.undoStates = undoStates;\n this.title = 'Transformation';\n this.redoStates = [];\n this.adorner = adorner;\n for (var i = 0; i < this.shapes.length; i++) {\n var shape = this.shapes[i];\n this.redoStates.push(shape.bounds());\n }\n },\n undo: function () {\n for (var i = 0; i < this.shapes.length; i++) {\n var shape = this.shapes[i];\n shape.bounds(this.undoStates[i]);\n if (shape.hasOwnProperty('layout')) {\n shape.layout(shape, this.redoStates[i], this.undoStates[i]);\n }\n shape.updateModel();\n }\n if (this.adorner) {\n this.adorner.refreshBounds();\n this.adorner.refresh();\n }\n },\n redo: function () {\n for (var i = 0; i < this.shapes.length; i++) {\n var shape = this.shapes[i];\n shape.bounds(this.redoStates[i]);\n if (shape.hasOwnProperty('layout')) {\n shape.layout(shape, this.undoStates[i], this.redoStates[i]);\n }\n shape.updateModel();\n }\n if (this.adorner) {\n this.adorner.refreshBounds();\n this.adorner.refresh();\n }\n }\n });\n var AddConnectionUnit = Class.extend({\n init: function (connection, diagram) {\n this.connection = connection;\n this.diagram = diagram;\n this.title = 'New connection';\n },\n undo: function () {\n this.diagram.remove(this.connection, false);\n },\n redo: function () {\n this.diagram._addConnection(this.connection, false);\n }\n });\n var AddShapeUnit = Class.extend({\n init: function (shape, diagram) {\n this.shape = shape;\n this.diagram = diagram;\n this.title = 'New shape';\n },\n undo: function () {\n this.diagram.deselect();\n this.diagram.remove(this.shape, false);\n },\n redo: function () {\n this.diagram._addShape(this.shape, false);\n }\n });\n var PanUndoUnit = Class.extend({\n init: function (initialPosition, finalPosition, diagram) {\n this.initial = initialPosition;\n this.finalPos = finalPosition;\n this.diagram = diagram;\n this.title = 'Pan Unit';\n },\n undo: function () {\n this.diagram.pan(this.initial);\n },\n redo: function () {\n this.diagram.pan(this.finalPos);\n }\n });\n var RotateUnit = Class.extend({\n init: function (adorner, shapes, undoRotates) {\n this.shapes = shapes;\n this.undoRotates = undoRotates;\n this.title = 'Rotation';\n this.redoRotates = [];\n this.redoAngle = adorner._angle;\n this.adorner = adorner;\n this.center = adorner._innerBounds.center();\n for (var i = 0; i < this.shapes.length; i++) {\n var shape = this.shapes[i];\n this.redoRotates.push(shape.rotate().angle);\n }\n },\n undo: function () {\n var i, shape;\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n shape.rotate(this.undoRotates[i], this.center, false);\n if (shape.hasOwnProperty('layout')) {\n shape.layout(shape);\n }\n shape.updateModel();\n }\n if (this.adorner) {\n this.adorner._initialize();\n this.adorner.refresh();\n }\n },\n redo: function () {\n var i, shape;\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n shape.rotate(this.redoRotates[i], this.center, false);\n if (shape.hasOwnProperty('layout')) {\n shape.layout(shape);\n }\n shape.updateModel();\n }\n if (this.adorner) {\n this.adorner._initialize();\n this.adorner.refresh();\n }\n }\n });\n var ToFrontUnit = Class.extend({\n init: function (diagram, items, initialIndices) {\n this.diagram = diagram;\n this.indices = initialIndices;\n this.items = items;\n this.title = 'Rotate Unit';\n },\n undo: function () {\n this.diagram._toIndex(this.items, this.indices);\n },\n redo: function () {\n this.diagram.toFront(this.items, false);\n }\n });\n var ToBackUnit = Class.extend({\n init: function (diagram, items, initialIndices) {\n this.diagram = diagram;\n this.indices = initialIndices;\n this.items = items;\n this.title = 'Rotate Unit';\n },\n undo: function () {\n this.diagram._toIndex(this.items, this.indices);\n },\n redo: function () {\n this.diagram.toBack(this.items, false);\n }\n });\n var UndoRedoService = kendo.Observable.extend({\n init: function (options) {\n kendo.Observable.fn.init.call(this, options);\n this.bind(this.events, options);\n this.stack = [];\n this.index = 0;\n this.capacity = 100;\n },\n events: [\n 'undone',\n 'redone'\n ],\n begin: function () {\n this.composite = new CompositeUnit();\n },\n cancel: function () {\n this.composite = undefined;\n },\n commit: function (execute) {\n if (this.composite.units.length > 0) {\n this._restart(this.composite, execute);\n }\n this.composite = undefined;\n },\n addCompositeItem: function (undoUnit) {\n if (this.composite) {\n this.composite.add(undoUnit);\n } else {\n this.add(undoUnit);\n }\n },\n add: function (undoUnit, execute) {\n this._restart(undoUnit, execute);\n },\n pop: function () {\n if (this.index > 0) {\n this.stack.pop();\n this.index--;\n }\n },\n count: function () {\n return this.stack.length;\n },\n undo: function () {\n if (this.index > 0) {\n this.index--;\n this.stack[this.index].undo();\n this.trigger('undone');\n }\n },\n redo: function () {\n if (this.stack.length > 0 && this.index < this.stack.length) {\n this.stack[this.index].redo();\n this.index++;\n this.trigger('redone');\n }\n },\n _restart: function (composite, execute) {\n this.stack.splice(this.index, this.stack.length - this.index);\n this.stack.push(composite);\n if (execute !== false) {\n this.redo();\n } else {\n this.index++;\n }\n if (this.stack.length > this.capacity) {\n this.stack.splice(0, this.stack.length - this.capacity);\n this.index = this.capacity;\n }\n },\n clear: function () {\n this.stack = [];\n this.index = 0;\n }\n });\n var EmptyTool = Class.extend({\n init: function (toolService) {\n this.toolService = toolService;\n },\n start: function () {\n },\n move: function () {\n },\n end: function () {\n },\n tryActivate: function () {\n return false;\n },\n getCursor: function () {\n return Cursors.arrow;\n }\n });\n var ScrollerTool = EmptyTool.extend({\n init: function (toolService) {\n var tool = this;\n var friction = kendo.support.mobileOS ? FRICTION_MOBILE : FRICTION;\n EmptyTool.fn.init.call(tool, toolService);\n var diagram = tool.toolService.diagram, canvas = diagram.canvas;\n var scroller = diagram.scroller = tool.scroller = $(diagram.scrollable).kendoMobileScroller({\n friction: friction,\n velocityMultiplier: VELOCITY_MULTIPLIER,\n mousewheelScrolling: false,\n zoom: false,\n scroll: proxy(tool._move, tool)\n }).data('kendoMobileScroller');\n if (canvas.translate) {\n tool.movableCanvas = new Movable(canvas.element);\n }\n var virtualScroll = function (dimension, min, max) {\n dimension.makeVirtual();\n dimension.virtualSize(min || SCROLL_MIN, max || SCROLL_MAX);\n };\n virtualScroll(scroller.dimensions.x);\n virtualScroll(scroller.dimensions.y);\n scroller.disable();\n },\n tryActivate: function (p, meta) {\n var toolService = this.toolService;\n var options = toolService.diagram.options.pannable;\n var enabled = meta.ctrlKey;\n if (defined(options.key)) {\n if (!options.key || options.key == 'none') {\n enabled = noMeta(meta) && !defined(toolService.hoveredItem);\n } else {\n enabled = meta[options.key + 'Key'];\n }\n }\n return options !== false && enabled && !defined(toolService.hoveredAdorner) && !defined(toolService._hoveredConnector);\n },\n start: function () {\n this.scroller.enable();\n },\n move: function () {\n },\n _move: function (args) {\n var tool = this, diagram = tool.toolService.diagram, canvas = diagram.canvas, scrollPos = new Point(args.scrollLeft, args.scrollTop);\n if (canvas.translate) {\n diagram._storePan(scrollPos.times(-1));\n tool.movableCanvas.moveTo(scrollPos);\n canvas.translate(scrollPos.x, scrollPos.y);\n } else {\n scrollPos = scrollPos.plus(diagram._pan.times(-1));\n }\n diagram.trigger(PAN, { pan: scrollPos });\n },\n end: function () {\n this.scroller.disable();\n },\n getCursor: function () {\n return Cursors.move;\n }\n });\n var PointerTool = Class.extend({\n init: function (toolService) {\n this.toolService = toolService;\n },\n tryActivate: function () {\n return true;\n },\n start: function (p, meta) {\n var toolService = this.toolService, diagram = toolService.diagram, hoveredItem = toolService.hoveredItem;\n if (hoveredItem) {\n toolService.selectSingle(hoveredItem, meta);\n if (hoveredItem.adorner) {\n this.adorner = hoveredItem.adorner;\n this.handle = this.adorner._hitTest(p);\n }\n }\n if (!this.handle) {\n this.handle = diagram._resizingAdorner._hitTest(p);\n if (this.handle) {\n this.adorner = diagram._resizingAdorner;\n }\n }\n if (this.adorner) {\n if (!this.adorner.isDragHandle(this.handle) || !diagram.trigger(DRAG_START, {\n shapes: this.adorner.shapes,\n connections: []\n })) {\n this.adorner.start(p);\n } else {\n toolService.startPoint = p;\n toolService.end(p);\n }\n }\n },\n move: function (p) {\n if (this.adorner) {\n this.adorner.move(this.handle, p);\n if (this.adorner.isDragHandle(this.handle)) {\n this.toolService.diagram.trigger(DRAG, {\n shapes: this.adorner.shapes,\n connections: []\n });\n }\n }\n },\n end: function () {\n var diagram = this.toolService.diagram, adorner = this.adorner, unit;\n if (adorner) {\n if (!adorner.isDragHandle(this.handle) || !diagram.trigger(DRAG_END, {\n shapes: adorner.shapes,\n connections: []\n })) {\n unit = adorner.stop();\n if (unit) {\n diagram.undoRedoService.add(unit, false);\n }\n } else {\n adorner.cancel();\n }\n }\n this.adorner = undefined;\n this.handle = undefined;\n },\n getCursor: function (p) {\n return this.toolService.hoveredItem ? this.toolService.hoveredItem._getCursor(p) : Cursors.arrow;\n }\n });\n var SelectionTool = Class.extend({\n init: function (toolService) {\n this.toolService = toolService;\n },\n tryActivate: function (p, meta) {\n var toolService = this.toolService;\n var selectable = toolService.diagram.options.selectable;\n var enabled = selectable && selectable.multiple !== false;\n if (enabled) {\n if (selectable.key && selectable.key != 'none') {\n enabled = meta[selectable.key + 'Key'];\n } else {\n enabled = noMeta(meta);\n }\n }\n return enabled && !defined(toolService.hoveredItem) && !defined(toolService.hoveredAdorner);\n },\n start: function (p) {\n var diagram = this.toolService.diagram;\n diagram.deselect();\n diagram.selector.start(p);\n },\n move: function (p) {\n var diagram = this.toolService.diagram;\n diagram.selector.move(p);\n },\n end: function (p, meta) {\n var diagram = this.toolService.diagram, hoveredItem = this.toolService.hoveredItem;\n var rect = diagram.selector.bounds();\n if ((!hoveredItem || !hoveredItem.isSelected) && !meta.ctrlKey) {\n diagram.deselect();\n }\n if (!rect.isEmpty()) {\n diagram.selectArea(rect);\n }\n diagram.selector.end();\n },\n getCursor: function () {\n return Cursors.arrow;\n }\n });\n var ConnectionTool = Class.extend({\n init: function (toolService) {\n this.toolService = toolService;\n this.type = 'ConnectionTool';\n },\n tryActivate: function () {\n return this.toolService._hoveredConnector;\n },\n start: function (p, meta) {\n var toolService = this.toolService, diagram = toolService.diagram, connector = toolService._hoveredConnector, connection = diagram._createConnection({}, connector._c, p);\n if (canDrag(connection) && !diagram.trigger(DRAG_START, {\n shapes: [],\n connections: [connection],\n connectionHandle: TARGET\n }) && diagram._addConnection(connection)) {\n toolService._connectionManipulation(connection, connector._c.shape, true);\n toolService._removeHover();\n toolService.selectSingle(toolService.activeConnection, meta);\n if (meta.type == 'touchmove') {\n diagram._cachedTouchTarget = connector.visual;\n }\n } else {\n connection.source(null);\n toolService.end(p);\n }\n },\n move: function (p) {\n var toolService = this.toolService;\n var connection = toolService.activeConnection;\n connection.target(p);\n toolService.diagram.trigger(DRAG, {\n shapes: [],\n connections: [connection],\n connectionHandle: TARGET\n });\n return true;\n },\n end: function (p) {\n var toolService = this.toolService, d = toolService.diagram, connection = toolService.activeConnection, hoveredItem = toolService.hoveredItem, connector = toolService._hoveredConnector, target, cachedTouchTarget = d._cachedTouchTarget;\n if (!connection) {\n return;\n }\n if (connector && connector._c != connection.sourceConnector) {\n target = connector._c;\n } else if (hoveredItem && hoveredItem instanceof diagram.Shape) {\n target = hoveredItem.getConnector(AUTO) || hoveredItem.getConnector(p);\n } else {\n target = p;\n }\n connection.target(target);\n if (!d.trigger(DRAG_END, {\n shapes: [],\n connections: [connection],\n connectionHandle: TARGET\n })) {\n connection.updateModel();\n d._syncConnectionChanges();\n } else {\n d.remove(connection, false);\n d.undoRedoService.pop();\n }\n toolService._connectionManipulation();\n if (cachedTouchTarget) {\n d._connectorsAdorner.visual.remove(cachedTouchTarget);\n d._cachedTouchTarget = null;\n }\n },\n getCursor: function () {\n return Cursors.arrow;\n }\n });\n var ConnectionEditTool = Class.extend({\n init: function (toolService) {\n this.toolService = toolService;\n this.type = 'ConnectionTool';\n },\n tryActivate: function (p, meta) {\n var toolService = this.toolService, diagram = toolService.diagram, selectable = diagram.options.selectable, item = toolService.hoveredItem, isActive = selectable !== false && item && item.path && !(item.isSelected && meta.ctrlKey);\n if (isActive) {\n this._c = item;\n }\n return isActive;\n },\n start: function (p, meta) {\n var toolService = this.toolService;\n var connection = this._c;\n toolService.selectSingle(connection, meta);\n var adorner = connection.adorner;\n var handle, name;\n if (adorner) {\n handle = adorner._hitTest(p);\n name = HANDLE_NAMES[handle];\n }\n if (canDrag(connection) && adorner && !toolService.diagram.trigger(DRAG_START, {\n shapes: [],\n connections: [connection],\n connectionHandle: name\n })) {\n this.handle = handle;\n this.handleName = name;\n adorner.start(p);\n } else {\n toolService.startPoint = p;\n toolService.end(p);\n }\n },\n move: function (p) {\n var adorner = this._c.adorner;\n if (canDrag(this._c) && adorner) {\n adorner.move(this.handle, p);\n this.toolService.diagram.trigger(DRAG, {\n shapes: [],\n connections: [this._c],\n connectionHandle: this.handleName\n });\n return true;\n }\n },\n end: function (p) {\n var connection = this._c;\n var adorner = connection.adorner;\n var toolService = this.toolService;\n var diagram = toolService.diagram;\n if (adorner) {\n if (canDrag(connection)) {\n var unit = adorner.stop(p);\n if (!diagram.trigger(DRAG_END, {\n shapes: [],\n connections: [connection],\n connectionHandle: this.handleName\n })) {\n diagram.undoRedoService.add(unit, false);\n connection.updateModel();\n diagram._syncConnectionChanges();\n } else {\n unit.undo();\n }\n }\n }\n },\n getCursor: function () {\n return Cursors.move;\n }\n });\n function testKey(key, str) {\n return str.charCodeAt(0) == key || str.toUpperCase().charCodeAt(0) == key;\n }\n var ToolService = Class.extend({\n init: function (diagram) {\n this.diagram = diagram;\n this.tools = [\n new ScrollerTool(this),\n new ConnectionEditTool(this),\n new ConnectionTool(this),\n new SelectionTool(this),\n new PointerTool(this)\n ];\n this.activeTool = undefined;\n },\n start: function (p, meta) {\n meta = deepExtend({}, meta);\n if (this.activeTool) {\n this.activeTool.end(p, meta);\n }\n this._updateHoveredItem(p);\n this._activateTool(p, meta);\n this.activeTool.start(p, meta);\n this._updateCursor(p);\n this.diagram.focus();\n this.diagram.canvas.surface.suspendTracking();\n this.startPoint = p;\n return true;\n },\n move: function (p, meta) {\n meta = deepExtend({}, meta);\n var updateHovered = true;\n if (this.activeTool) {\n updateHovered = this.activeTool.move(p, meta);\n }\n if (updateHovered) {\n this._updateHoveredItem(p);\n }\n this._updateCursor(p);\n return true;\n },\n end: function (p, meta) {\n meta = deepExtend({}, meta);\n if (this.activeTool) {\n this.activeTool.end(p, meta);\n }\n this.diagram.canvas.surface.resumeTracking();\n this.activeTool = undefined;\n this._updateCursor(p);\n return true;\n },\n keyDown: function (key, meta) {\n var diagram = this.diagram;\n meta = deepExtend({\n ctrlKey: false,\n metaKey: false,\n altKey: false\n }, meta);\n if ((meta.ctrlKey || meta.metaKey) && !meta.altKey) {\n if (testKey(key, 'a')) {\n diagram.selectAll();\n diagram._destroyToolBar();\n return true;\n } else if (testKey(key, 'z')) {\n diagram.undo();\n diagram._destroyToolBar();\n return true;\n } else if (testKey(key, 'y')) {\n diagram.redo();\n diagram._destroyToolBar();\n return true;\n } else if (testKey(key, 'c')) {\n diagram.copy();\n diagram._destroyToolBar();\n } else if (testKey(key, 'x')) {\n diagram.cut();\n diagram._destroyToolBar();\n } else if (testKey(key, 'v')) {\n diagram.paste();\n diagram._destroyToolBar();\n } else if (testKey(key, 'l')) {\n diagram.layout();\n diagram._destroyToolBar();\n } else if (testKey(key, 'd')) {\n diagram._destroyToolBar();\n diagram.copy();\n diagram.paste();\n }\n } else if (key === 46 || key === 8) {\n var toRemove = this.diagram._triggerRemove(diagram.select());\n if (toRemove.length) {\n this.diagram.remove(toRemove, true);\n this.diagram._syncChanges();\n this.diagram._destroyToolBar();\n }\n return true;\n } else if (key === 27) {\n this._discardNewConnection();\n diagram.deselect();\n diagram._destroyToolBar();\n return true;\n }\n },\n wheel: function (p, meta) {\n var diagram = this.diagram, delta = meta.delta, z = diagram.zoom(), options = diagram.options, zoomRate = options.zoomRate, zoomOptions = {\n point: p,\n meta: meta,\n zoom: z\n };\n if (diagram.trigger(ZOOM_START, zoomOptions)) {\n return;\n }\n if (delta < 0) {\n z += zoomRate;\n } else {\n z -= zoomRate;\n }\n z = kendo.dataviz.round(Math.max(options.zoomMin, Math.min(options.zoomMax, z)), 2);\n zoomOptions.zoom = z;\n diagram.zoom(z, zoomOptions);\n diagram.trigger(ZOOM_END, zoomOptions);\n return true;\n },\n setTool: function (tool, index) {\n tool.toolService = this;\n this.tools[index] = tool;\n },\n selectSingle: function (item, meta) {\n var diagram = this.diagram;\n var selectable = diagram.options.selectable;\n if (selectable && !item.isSelected && item.options.selectable !== false) {\n var addToSelection = meta.ctrlKey && selectable.multiple !== false;\n diagram.select(item, { addToSelection: addToSelection });\n }\n },\n _discardNewConnection: function () {\n if (this.newConnection) {\n this.diagram.remove(this.newConnection);\n this.newConnection = undefined;\n }\n },\n _activateTool: function (p, meta) {\n for (var i = 0; i < this.tools.length; i++) {\n var tool = this.tools[i];\n if (tool.tryActivate(p, meta)) {\n this.activeTool = tool;\n break;\n }\n }\n },\n _updateCursor: function (p) {\n var element = this.diagram.element;\n var cursor = this.activeTool ? this.activeTool.getCursor(p) : this.hoveredAdorner ? this.hoveredAdorner._getCursor(p) : this.hoveredItem ? this.hoveredItem._getCursor(p) : Cursors.arrow;\n element.css({ cursor: cursor });\n if (browser.msie && browser.version == 7) {\n element[0].style.cssText = element[0].style.cssText;\n }\n },\n _connectionManipulation: function (connection, disabledShape, isNew) {\n this.activeConnection = connection;\n this.disabledShape = disabledShape;\n if (isNew) {\n this.newConnection = this.activeConnection;\n } else {\n this.newConnection = undefined;\n }\n },\n _updateHoveredItem: function (p) {\n var hit = this._hitTest(p);\n var diagram = this.diagram;\n if (hit != this.hoveredItem && (!this.disabledShape || hit != this.disabledShape)) {\n if (this.hoveredItem) {\n diagram.trigger(MOUSE_LEAVE, { item: this.hoveredItem });\n this.hoveredItem._hover(false);\n }\n if (hit && hit.options.enable) {\n diagram.trigger(MOUSE_ENTER, { item: hit });\n this.hoveredItem = hit;\n this.hoveredItem._hover(true);\n } else {\n this.hoveredItem = undefined;\n }\n }\n },\n _removeHover: function () {\n if (this.hoveredItem) {\n this.hoveredItem._hover(false);\n this.hoveredItem = undefined;\n }\n },\n _hitTest: function (point) {\n var hit, d = this.diagram, item, i;\n if (this._hoveredConnector) {\n this._hoveredConnector._hover(false);\n this._hoveredConnector = undefined;\n }\n if (d._connectorsAdorner._visible) {\n hit = d._connectorsAdorner._hitTest(point);\n if (hit) {\n return hit;\n }\n }\n hit = this.diagram._resizingAdorner._hitTest(point);\n if (hit) {\n this.hoveredAdorner = d._resizingAdorner;\n if (hit.x !== 0 || hit.y !== 0) {\n return;\n }\n hit = undefined;\n } else {\n this.hoveredAdorner = undefined;\n }\n if (!this.activeTool || this.activeTool.type !== 'ConnectionTool') {\n var selectedConnections = [];\n for (i = 0; i < d._selectedItems.length; i++) {\n item = d._selectedItems[i];\n if (item instanceof diagram.Connection) {\n selectedConnections.push(item);\n }\n }\n hit = this._hitTestItems(selectedConnections, point);\n }\n return hit || this._hitTestElements(point);\n },\n _hitTestElements: function (point) {\n var diagram = this.diagram;\n var shapeHit = this._hitTestItems(diagram.shapes, point);\n var connectionHit = this._hitTestItems(diagram.connections, point);\n var hit;\n if ((!this.activeTool || this.activeTool.type != 'ConnectionTool') && shapeHit && connectionHit && !hitTestShapeConnectors(shapeHit, point)) {\n var mainLayer = diagram.mainLayer;\n var shapeIdx = inArray(shapeHit.visual, mainLayer.children);\n var connectionIdx = inArray(connectionHit.visual, mainLayer.children);\n hit = shapeIdx > connectionIdx ? shapeHit : connectionHit;\n }\n return hit || shapeHit || connectionHit;\n },\n _hitTestItems: function (array, point) {\n var i, item, hit;\n for (i = array.length - 1; i >= 0; i--) {\n item = array[i];\n hit = item._hitTest(point);\n if (hit) {\n return hit;\n }\n }\n }\n });\n var ConnectionRouterBase = kendo.Class.extend({\n init: function () {\n }\n });\n var LinearConnectionRouter = ConnectionRouterBase.extend({\n init: function (connection) {\n var that = this;\n ConnectionRouterBase.fn.init.call(that);\n this.connection = connection;\n },\n hitTest: function (p) {\n var rec = this.getBounds().inflate(HIT_TEST_DISTANCE);\n if (!rec.contains(p)) {\n return false;\n }\n return diagram.Geometry.distanceToPolyline(p, this.connection.allPoints()) < HIT_TEST_DISTANCE;\n },\n getBounds: function () {\n var points = this.connection.allPoints(), s = points[0], e = points[points.length - 1], right = Math.max(s.x, e.x), left = Math.min(s.x, e.x), top = Math.min(s.y, e.y), bottom = Math.max(s.y, e.y);\n for (var i = 1; i < points.length - 1; ++i) {\n right = Math.max(right, points[i].x);\n left = Math.min(left, points[i].x);\n top = Math.min(top, points[i].y);\n bottom = Math.max(bottom, points[i].y);\n }\n return new Rect(left, top, right - left, bottom - top);\n }\n });\n var PolylineRouter = LinearConnectionRouter.extend({\n init: function (connection) {\n var that = this;\n LinearConnectionRouter.fn.init.call(that);\n this.connection = connection;\n },\n route: function () {\n }\n });\n var CascadingRouter = LinearConnectionRouter.extend({\n SAME_SIDE_DISTANCE_RATIO: 5,\n init: function (connection) {\n var that = this;\n LinearConnectionRouter.fn.init.call(that);\n this.connection = connection;\n },\n routePoints: function (start, end, sourceConnector, targetConnector) {\n var result;\n if (sourceConnector && targetConnector) {\n result = this._connectorPoints(start, end, sourceConnector, targetConnector);\n } else {\n result = this._floatingPoints(start, end, sourceConnector);\n }\n return result;\n },\n route: function () {\n var sourceConnector = this.connection._resolvedSourceConnector;\n var targetConnector = this.connection._resolvedTargetConnector;\n var start = this.connection.sourcePoint();\n var end = this.connection.targetPoint();\n var points = this.routePoints(start, end, sourceConnector, targetConnector);\n this.connection.points(points);\n },\n _connectorSides: [\n {\n name: 'Top',\n axis: 'y',\n boundsPoint: 'topLeft',\n secondarySign: 1\n },\n {\n name: 'Left',\n axis: 'x',\n boundsPoint: 'topLeft',\n secondarySign: 1\n },\n {\n name: 'Bottom',\n axis: 'y',\n boundsPoint: 'bottomRight',\n secondarySign: -1\n },\n {\n name: 'Right',\n axis: 'x',\n boundsPoint: 'bottomRight',\n secondarySign: -1\n }\n ],\n _connectorSide: function (connector, targetPoint) {\n var position = connector.position();\n var shapeBounds = connector.shape.bounds(ROTATED);\n var bounds = {\n topLeft: shapeBounds.topLeft(),\n bottomRight: shapeBounds.bottomRight()\n };\n var sides = this._connectorSides;\n var min = util.MAX_NUM;\n var sideDistance;\n var minSide;\n var axis;\n var side;\n for (var idx = 0; idx < sides.length; idx++) {\n side = sides[idx];\n axis = side.axis;\n sideDistance = Math.round(Math.abs(position[axis] - bounds[side.boundsPoint][axis]));\n if (sideDistance < min) {\n min = sideDistance;\n minSide = side;\n } else if (sideDistance === min && (position[axis] - targetPoint[axis]) * side.secondarySign > (position[minSide.axis] - targetPoint[minSide.axis]) * minSide.secondarySign) {\n minSide = side;\n }\n }\n return minSide.name;\n },\n _sameSideDistance: function (connector) {\n var bounds = connector.shape.bounds(ROTATED);\n return Math.min(bounds.width, bounds.height) / this.SAME_SIDE_DISTANCE_RATIO;\n },\n _connectorPoints: function (start, end, sourceConnector, targetConnector) {\n var sourceConnectorSide = this._connectorSide(sourceConnector, end);\n var targetConnectorSide = this._connectorSide(targetConnector, start);\n var deltaX = end.x - start.x;\n var deltaY = end.y - start.y;\n var sameSideDistance = this._sameSideDistance(sourceConnector);\n var result = [];\n var pointX, pointY;\n if (sourceConnectorSide === TOP || sourceConnectorSide == BOTTOM) {\n if (targetConnectorSide == TOP || targetConnectorSide == BOTTOM) {\n if (sourceConnectorSide == targetConnectorSide) {\n if (sourceConnectorSide == TOP) {\n pointY = Math.min(start.y, end.y) - sameSideDistance;\n } else {\n pointY = Math.max(start.y, end.y) + sameSideDistance;\n }\n result = [\n new Point(start.x, pointY),\n new Point(end.x, pointY)\n ];\n } else {\n result = [\n new Point(start.x, start.y + deltaY / 2),\n new Point(end.x, start.y + deltaY / 2)\n ];\n }\n } else {\n result = [new Point(start.x, end.y)];\n }\n } else {\n if (targetConnectorSide == LEFT || targetConnectorSide == RIGHT) {\n if (sourceConnectorSide == targetConnectorSide) {\n if (sourceConnectorSide == LEFT) {\n pointX = Math.min(start.x, end.x) - sameSideDistance;\n } else {\n pointX = Math.max(start.x, end.x) + sameSideDistance;\n }\n result = [\n new Point(pointX, start.y),\n new Point(pointX, end.y)\n ];\n } else {\n result = [\n new Point(start.x + deltaX / 2, start.y),\n new Point(start.x + deltaX / 2, start.y + deltaY)\n ];\n }\n } else {\n result = [new Point(end.x, start.y)];\n }\n }\n return result;\n },\n _floatingPoints: function (start, end, sourceConnector) {\n var sourceConnectorSide = sourceConnector ? this._connectorSide(sourceConnector, end) : null;\n var cascadeStartHorizontal = this._startHorizontal(start, end, sourceConnectorSide);\n var points = [\n start,\n start,\n end,\n end\n ];\n var deltaX = end.x - start.x;\n var deltaY = end.y - start.y;\n var length = points.length;\n var shiftX;\n var shiftY;\n for (var idx = 1; idx < length - 1; ++idx) {\n if (cascadeStartHorizontal) {\n if (idx % 2 !== 0) {\n shiftX = deltaX / (length / 2);\n shiftY = 0;\n } else {\n shiftX = 0;\n shiftY = deltaY / ((length - 1) / 2);\n }\n } else {\n if (idx % 2 !== 0) {\n shiftX = 0;\n shiftY = deltaY / (length / 2);\n } else {\n shiftX = deltaX / ((length - 1) / 2);\n shiftY = 0;\n }\n }\n points[idx] = new Point(points[idx - 1].x + shiftX, points[idx - 1].y + shiftY);\n }\n idx--;\n if (cascadeStartHorizontal && idx % 2 !== 0 || !cascadeStartHorizontal && idx % 2 === 0) {\n points[length - 2] = new Point(points[length - 1].x, points[length - 2].y);\n } else {\n points[length - 2] = new Point(points[length - 2].x, points[length - 1].y);\n }\n return [\n points[1],\n points[2]\n ];\n },\n _startHorizontal: function (start, end, sourceSide) {\n var horizontal;\n if (sourceSide !== null && (sourceSide === RIGHT || sourceSide === LEFT)) {\n horizontal = true;\n } else {\n horizontal = Math.abs(start.x - end.x) > Math.abs(start.y - end.y);\n }\n return horizontal;\n }\n });\n var AdornerBase = Class.extend({\n init: function (diagram, options) {\n var that = this;\n that.diagram = diagram;\n that.options = deepExtend({}, that.options, options);\n that.visual = new Group();\n that.diagram._adorners.push(that);\n },\n refresh: function () {\n }\n });\n var ConnectionEditAdorner = AdornerBase.extend({\n init: function (connection, options) {\n var that = this, diagram;\n that.connection = connection;\n diagram = that.connection.diagram;\n that._ts = diagram.toolService;\n AdornerBase.fn.init.call(that, diagram, options);\n var sp = that.connection.sourcePoint();\n var tp = that.connection.targetPoint();\n that.spVisual = new Circle(deepExtend(that.options.handles, { center: sp }));\n that.epVisual = new Circle(deepExtend(that.options.handles, { center: tp }));\n that.visual.append(that.spVisual);\n that.visual.append(that.epVisual);\n },\n options: { handles: {} },\n _getCursor: function () {\n return Cursors.move;\n },\n start: function (p) {\n this.handle = this._hitTest(p);\n this.startPoint = p;\n this._initialSource = this.connection.source();\n this._initialTarget = this.connection.target();\n switch (this.handle) {\n case -1:\n if (this.connection.targetConnector) {\n this._ts._connectionManipulation(this.connection, this.connection.targetConnector.shape);\n }\n break;\n case 1:\n if (this.connection.sourceConnector) {\n this._ts._connectionManipulation(this.connection, this.connection.sourceConnector.shape);\n }\n break;\n }\n },\n move: function (handle, p) {\n switch (handle) {\n case -1:\n this.connection.source(p);\n break;\n case 1:\n this.connection.target(p);\n break;\n default:\n var delta = p.minus(this.startPoint);\n this.startPoint = p;\n if (!this.connection.sourceConnector) {\n this.connection.source(this.connection.sourcePoint().plus(delta));\n }\n if (!this.connection.targetConnector) {\n this.connection.target(this.connection.targetPoint().plus(delta));\n }\n break;\n }\n this.refresh();\n return true;\n },\n stop: function (p) {\n var ts = this.diagram.toolService, item = ts.hoveredItem, target;\n if (ts._hoveredConnector) {\n target = ts._hoveredConnector._c;\n } else if (item && item instanceof diagram.Shape) {\n target = item.getConnector(AUTO) || item.getConnector(p);\n } else {\n target = p;\n }\n if (this.handle === -1) {\n this.connection.source(target);\n } else if (this.handle === 1) {\n this.connection.target(target);\n }\n this.handle = undefined;\n this._ts._connectionManipulation();\n return new ConnectionEditUndoUnit(this.connection, this._initialSource, this._initialTarget);\n },\n _hitTest: function (point) {\n var sourcePoint = this.connection.sourcePoint();\n var targetPoint = this.connection.targetPoint();\n var radiusX = this.options.handles.width / 2 + HIT_TEST_DISTANCE;\n var radiusY = this.options.handles.height / 2 + HIT_TEST_DISTANCE;\n var sourcePointDistance = sourcePoint.distanceTo(point);\n var targetPointDistance = targetPoint.distanceTo(point);\n var sourceHandle = new Rect(sourcePoint.x, sourcePoint.y).inflate(radiusX, radiusY).contains(point);\n var targetHandle = new Rect(targetPoint.x, targetPoint.y).inflate(radiusX, radiusY).contains(point);\n var handle = 0;\n if (sourceHandle && (!targetHandle || sourcePointDistance < targetPointDistance)) {\n handle = -1;\n } else if (targetHandle && (!sourceHandle || targetPointDistance < sourcePointDistance)) {\n handle = 1;\n }\n return handle;\n },\n refresh: function () {\n this.spVisual.redraw({ center: this.diagram.modelToLayer(this.connection.sourcePoint()) });\n this.epVisual.redraw({ center: this.diagram.modelToLayer(this.connection.targetPoint()) });\n }\n });\n var ConnectorsAdorner = AdornerBase.extend({\n init: function (diagram, options) {\n var that = this;\n AdornerBase.fn.init.call(that, diagram, options);\n that._refreshHandler = function (e) {\n if (e.item == that.shape) {\n that.refresh();\n }\n };\n },\n show: function (shape) {\n var that = this, len, i, ctr;\n that._visible = true;\n that.shape = shape;\n that.diagram.bind(ITEMBOUNDSCHANGE, that._refreshHandler);\n len = shape.connectors.length;\n that.connectors = [];\n that._clearVisual();\n for (i = 0; i < len; i++) {\n ctr = new ConnectorVisual(shape.connectors[i]);\n that.connectors.push(ctr);\n that.visual.append(ctr.visual);\n }\n that.visual.visible(true);\n that.refresh();\n },\n _clearVisual: function () {\n var that = this;\n if (that.diagram._cachedTouchTarget) {\n that._keepCachedTouchTarget();\n } else {\n that.visual.clear();\n }\n },\n _keepCachedTouchTarget: function () {\n var that = this, visualChildren = that.visual.children;\n var childrenCount = visualChildren.length;\n var index = inArray(that.diagram._cachedTouchTarget, visualChildren);\n for (var i = childrenCount - 1; i >= 0; i--) {\n if (i == index) {\n continue;\n }\n that.visual.remove(visualChildren[i]);\n }\n },\n destroy: function () {\n var that = this;\n that.diagram.unbind(ITEMBOUNDSCHANGE, that._refreshHandler);\n that.shape = undefined;\n that._visible = undefined;\n that.visual.visible(false);\n },\n _hitTest: function (p) {\n var ctr, i;\n for (i = 0; i < this.connectors.length; i++) {\n ctr = this.connectors[i];\n if (ctr._hitTest(p)) {\n ctr._hover(true);\n this.diagram.toolService._hoveredConnector = ctr;\n break;\n }\n }\n },\n refresh: function () {\n if (this.shape) {\n var bounds = this.shape.bounds();\n bounds = this.diagram.modelToLayer(bounds);\n this.visual.position(bounds.topLeft());\n $.each(this.connectors, function () {\n this.refresh();\n });\n }\n }\n });\n function hitToOppositeSide(hit, bounds) {\n var result;\n if (hit.x == -1 && hit.y == -1) {\n result = bounds.bottomRight();\n } else if (hit.x == 1 && hit.y == 1) {\n result = bounds.topLeft();\n } else if (hit.x == -1 && hit.y == 1) {\n result = bounds.topRight();\n } else if (hit.x == 1 && hit.y == -1) {\n result = bounds.bottomLeft();\n } else if (hit.x === 0 && hit.y == -1) {\n result = bounds.bottom();\n } else if (hit.x === 0 && hit.y == 1) {\n result = bounds.top();\n } else if (hit.x == 1 && hit.y === 0) {\n result = bounds.left();\n } else if (hit.x == -1 && hit.y === 0) {\n result = bounds.right();\n }\n return result;\n }\n var ResizingAdorner = AdornerBase.extend({\n init: function (diagram, options) {\n var that = this;\n AdornerBase.fn.init.call(that, diagram, options);\n that._manipulating = false;\n that.map = [];\n that.shapes = [];\n that._initSelection();\n that._createHandles();\n that.redraw();\n that.diagram.bind('select', function (e) {\n that._initialize(e.selected);\n });\n that._refreshHandler = function () {\n if (!that._internalChange) {\n that.refreshBounds();\n that.refresh();\n }\n };\n that._rotatedHandler = function () {\n if (that.shapes.length == 1) {\n that._angle = that.shapes[0].rotate().angle;\n }\n that._refreshHandler();\n };\n that.diagram.bind(ITEMBOUNDSCHANGE, that._refreshHandler).bind(ITEMROTATE, that._rotatedHandler);\n that.refreshBounds();\n that.refresh();\n },\n options: {\n handles: {\n fill: { color: '#fff' },\n stroke: { color: '#282828' },\n height: 7,\n width: 7,\n hover: {\n fill: { color: '#282828' },\n stroke: { color: '#282828' }\n }\n },\n selectable: {\n stroke: {\n color: '#778899',\n width: 1,\n dashType: 'dash'\n },\n fill: { color: TRANSPARENT }\n },\n offset: 10\n },\n _initSelection: function () {\n var that = this;\n var diagram = that.diagram;\n var selectable = diagram.options.selectable;\n var options = deepExtend({}, that.options.selectable, selectable);\n that.rect = new Rectangle(options);\n that.visual.append(that.rect);\n },\n _resizable: function () {\n return this.options.editable && this.options.editable.resize !== false;\n },\n _handleOptions: function () {\n return (this.options.editable.resize || {}).handles || this.options.handles;\n },\n _createHandles: function () {\n var handles, item, y, x;\n if (this._resizable()) {\n handles = this._handleOptions();\n for (x = -1; x <= 1; x++) {\n for (y = -1; y <= 1; y++) {\n if (x !== 0 || y !== 0) {\n item = new Rectangle(handles);\n item.drawingElement._hover = proxy(this._hover, this);\n this.map.push({\n x: x,\n y: y,\n visual: item\n });\n this.visual.append(item);\n }\n }\n }\n }\n },\n bounds: function (value) {\n if (value) {\n this._innerBounds = value.clone();\n this._bounds = this.diagram.modelToLayer(value).inflate(this.options.offset, this.options.offset);\n } else {\n return this._bounds;\n }\n },\n _hitTest: function (p) {\n var tp = this.diagram.modelToLayer(p), i, hit, handleBounds, handlesCount = this.map.length, handle;\n if (this._angle) {\n tp = tp.clone().rotate(this._bounds.center(), this._angle);\n }\n if (this._resizable()) {\n for (i = 0; i < handlesCount; i++) {\n handle = this.map[i];\n hit = new Point(handle.x, handle.y);\n handleBounds = this._getHandleBounds(hit);\n handleBounds.offset(this._bounds.x, this._bounds.y);\n if (handleBounds.contains(tp)) {\n return hit;\n }\n }\n }\n if (this._bounds.contains(tp)) {\n return new Point(0, 0);\n }\n },\n _getHandleBounds: function (p) {\n if (this._resizable()) {\n var handles = this._handleOptions(), w = handles.width, h = handles.height, r = new Rect(0, 0, w, h);\n if (p.x < 0) {\n r.x = -w / 2;\n } else if (p.x === 0) {\n r.x = Math.floor(this._bounds.width / 2) - w / 2;\n } else if (p.x > 0) {\n r.x = this._bounds.width + 1 - w / 2;\n }\n if (p.y < 0) {\n r.y = -h / 2;\n } else if (p.y === 0) {\n r.y = Math.floor(this._bounds.height / 2) - h / 2;\n } else if (p.y > 0) {\n r.y = this._bounds.height + 1 - h / 2;\n }\n return r;\n }\n },\n _getCursor: function (point) {\n var hit = this._hitTest(point);\n if (hit && hit.x >= -1 && hit.x <= 1 && hit.y >= -1 && hit.y <= 1 && this._resizable()) {\n var angle = this._angle;\n if (angle) {\n angle = 360 - angle;\n hit.rotate(new Point(0, 0), angle);\n hit = new Point(Math.round(hit.x), Math.round(hit.y));\n }\n if (hit.x == -1 && hit.y == -1) {\n return 'nw-resize';\n }\n if (hit.x == 1 && hit.y == 1) {\n return 'se-resize';\n }\n if (hit.x == -1 && hit.y == 1) {\n return 'sw-resize';\n }\n if (hit.x == 1 && hit.y == -1) {\n return 'ne-resize';\n }\n if (hit.x === 0 && hit.y == -1) {\n return 'n-resize';\n }\n if (hit.x === 0 && hit.y == 1) {\n return 's-resize';\n }\n if (hit.x == 1 && hit.y === 0) {\n return 'e-resize';\n }\n if (hit.x == -1 && hit.y === 0) {\n return 'w-resize';\n }\n }\n return this._manipulating ? Cursors.move : Cursors.select;\n },\n _initialize: function () {\n var that = this, i, item, items = that.diagram.select();\n that.shapes = [];\n for (i = 0; i < items.length; i++) {\n item = items[i];\n if (item instanceof diagram.Shape) {\n that.shapes.push(item);\n item._rotationOffset = new Point();\n }\n }\n that._angle = that.shapes.length == 1 ? that.shapes[0].rotate().angle : 0;\n that._startAngle = that._angle;\n that._rotates();\n that._positions();\n that.refreshBounds();\n that.refresh();\n that.redraw();\n },\n _rotates: function () {\n var that = this, i, shape;\n that.initialRotates = [];\n for (i = 0; i < that.shapes.length; i++) {\n shape = that.shapes[i];\n that.initialRotates.push(shape.rotate().angle);\n }\n },\n _positions: function () {\n var that = this, i, shape;\n that.initialStates = [];\n for (i = 0; i < that.shapes.length; i++) {\n shape = that.shapes[i];\n that.initialStates.push(shape.bounds());\n }\n },\n _hover: function (value, element) {\n if (this._resizable()) {\n var handleOptions = this._handleOptions(), hover = handleOptions.hover, stroke = handleOptions.stroke, fill = handleOptions.fill;\n if (value && Utils.isDefined(hover.stroke)) {\n stroke = deepExtend({}, stroke, hover.stroke);\n }\n if (value && Utils.isDefined(hover.fill)) {\n fill = hover.fill;\n }\n element.stroke(stroke.color, stroke.width, stroke.opacity);\n element.fill(fill.color, fill.opacity);\n }\n },\n start: function (p) {\n this._sp = p;\n this._cp = p;\n this._lp = p;\n this._manipulating = true;\n this._internalChange = true;\n this.shapeStates = [];\n for (var i = 0; i < this.shapes.length; i++) {\n var shape = this.shapes[i];\n this.shapeStates.push(shape.bounds());\n }\n },\n redraw: function () {\n var i, handle, visibleHandles = this._resizable();\n for (i = 0; i < this.map.length; i++) {\n handle = this.map[i];\n handle.visual.visible(visibleHandles);\n }\n },\n angle: function (value) {\n if (defined(value)) {\n this._angle = value;\n }\n return this._angle;\n },\n rotate: function () {\n var center = this._innerBounds.center();\n var currentAngle = this.angle();\n this._internalChange = true;\n for (var i = 0; i < this.shapes.length; i++) {\n var shape = this.shapes[i];\n currentAngle = (currentAngle + this.initialRotates[i] - this._startAngle) % 360;\n shape.rotate(currentAngle, center);\n }\n this.refresh();\n },\n move: function (handle, p) {\n var delta, dragging, dtl = new Point(), dbr = new Point(), bounds, center, shape, i, angle, newBounds, changed = 0, staticPoint, scaleX, scaleY;\n if (handle.y === -2 && handle.x === -1) {\n center = this._innerBounds.center();\n this._angle = this._truncateAngle(Utils.findAngle(center, p));\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n angle = (this._angle + this.initialRotates[i] - this._startAngle) % 360;\n shape.rotate(angle, center);\n if (shape.hasOwnProperty('layout')) {\n shape.layout(shape);\n }\n this._rotating = true;\n }\n this.refresh();\n } else {\n if (this.shouldSnap()) {\n var thr = this._truncateDistance(p.minus(this._lp));\n if (thr.x === 0 && thr.y === 0) {\n this._cp = p;\n return;\n }\n delta = thr;\n this._lp = new Point(this._lp.x + thr.x, this._lp.y + thr.y);\n } else {\n delta = p.minus(this._cp);\n }\n if (this.isDragHandle(handle)) {\n dbr = dtl = delta;\n dragging = true;\n } else {\n if (this._angle) {\n delta.rotate(new Point(0, 0), this._angle);\n }\n if (handle.x == -1) {\n dtl.x = delta.x;\n } else if (handle.x == 1) {\n dbr.x = delta.x;\n }\n if (handle.y == -1) {\n dtl.y = delta.y;\n } else if (handle.y == 1) {\n dbr.y = delta.y;\n }\n }\n if (!dragging) {\n staticPoint = hitToOppositeSide(handle, this._innerBounds);\n scaleX = (this._innerBounds.width + delta.x * handle.x) / this._innerBounds.width;\n scaleY = (this._innerBounds.height + delta.y * handle.y) / this._innerBounds.height;\n }\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n bounds = shape.bounds();\n if (dragging) {\n if (!canDrag(shape)) {\n continue;\n }\n newBounds = this._displaceBounds(bounds, dtl, dbr, dragging);\n } else {\n newBounds = bounds.clone();\n newBounds.scale(scaleX, scaleY, staticPoint, this._innerBounds.center(), shape.rotate().angle);\n var newCenter = newBounds.center();\n newCenter.rotate(bounds.center(), -this._angle);\n newBounds = new Rect(newCenter.x - newBounds.width / 2, newCenter.y - newBounds.height / 2, newBounds.width, newBounds.height);\n }\n if (newBounds.width >= shape.options.minWidth && newBounds.height >= shape.options.minHeight) {\n var oldBounds = bounds;\n shape.bounds(newBounds);\n if (shape.hasOwnProperty('layout')) {\n shape.layout(shape, oldBounds, newBounds);\n }\n if (oldBounds.width !== newBounds.width || oldBounds.height !== newBounds.height) {\n shape.rotate(shape.rotate().angle);\n }\n changed += 1;\n }\n }\n if (changed) {\n if (changed == i) {\n newBounds = this._displaceBounds(this._innerBounds, dtl, dbr, dragging);\n this.bounds(newBounds);\n } else {\n this.refreshBounds();\n }\n this.refresh();\n }\n this._positions();\n }\n this._cp = p;\n },\n isDragHandle: function (handle) {\n return handle.x === 0 && handle.y === 0;\n },\n cancel: function () {\n var shapes = this.shapes;\n var states = this.shapeStates;\n for (var idx = 0; idx < shapes.length; idx++) {\n shapes[idx].bounds(states[idx]);\n }\n this.refreshBounds();\n this.refresh();\n this._manipulating = undefined;\n this._internalChange = undefined;\n this._rotating = undefined;\n },\n _truncatePositionToGuides: function (bounds) {\n if (this.diagram.ruler) {\n return this.diagram.ruler.truncatePositionToGuides(bounds);\n }\n return bounds;\n },\n _truncateSizeToGuides: function (bounds) {\n if (this.diagram.ruler) {\n return this.diagram.ruler.truncateSizeToGuides(bounds);\n }\n return bounds;\n },\n _truncateAngle: function (a) {\n var snap = this.snapOptions();\n var snapAngle = Math.max(snap.angle || DEFAULT_SNAP_ANGLE, MIN_SNAP_ANGLE);\n return snap ? Math.floor(a % 360 / snapAngle) * snapAngle : a % 360;\n },\n _truncateDistance: function (d) {\n if (d instanceof diagram.Point) {\n return new diagram.Point(this._truncateDistance(d.x), this._truncateDistance(d.y));\n } else {\n var snap = this.snapOptions() || {};\n var snapSize = Math.max(snap.size || DEFAULT_SNAP_SIZE, MIN_SNAP_SIZE);\n return snap ? Math.floor(d / snapSize) * snapSize : d;\n }\n },\n snapOptions: function () {\n var editable = this.diagram.options.editable;\n var snap = ((editable || {}).drag || {}).snap || {};\n return snap;\n },\n shouldSnap: function () {\n var editable = this.diagram.options.editable;\n var drag = (editable || {}).drag;\n var snap = (drag || {}).snap;\n return editable !== false && drag !== false && snap !== false;\n },\n _displaceBounds: function (bounds, dtl, dbr, dragging) {\n var tl = bounds.topLeft().plus(dtl), br = bounds.bottomRight().plus(dbr), newBounds = Rect.fromPoints(tl, br), newCenter;\n if (!dragging) {\n newCenter = newBounds.center();\n newCenter.rotate(bounds.center(), -this._angle);\n newBounds = new Rect(newCenter.x - newBounds.width / 2, newCenter.y - newBounds.height / 2, newBounds.width, newBounds.height);\n }\n return newBounds;\n },\n stop: function () {\n var unit, i, shape;\n if (this._cp != this._sp) {\n if (this._rotating) {\n unit = new RotateUnit(this, this.shapes, this.initialRotates);\n this._rotating = false;\n } else if (this._diffStates()) {\n if (this.diagram.ruler) {\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n var bounds = shape.bounds();\n bounds = this._truncateSizeToGuides(this._truncatePositionToGuides(bounds));\n shape.bounds(bounds);\n this.refreshBounds();\n this.refresh();\n }\n }\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n shape.updateModel();\n }\n unit = new TransformUnit(this.shapes, this.shapeStates, this);\n this.diagram._syncShapeChanges();\n }\n }\n this._manipulating = undefined;\n this._internalChange = undefined;\n this._rotating = undefined;\n return unit;\n },\n _diffStates: function () {\n var shapes = this.shapes;\n var states = this.shapeStates;\n for (var idx = 0; idx < shapes.length; idx++) {\n if (!shapes[idx].bounds().equals(states[idx])) {\n return true;\n }\n }\n return false;\n },\n refreshBounds: function () {\n var bounds = this.shapes.length == 1 ? this.shapes[0].bounds().clone() : this.diagram.boundingBox(this.shapes, true);\n this.bounds(bounds);\n },\n refresh: function () {\n var that = this, b, bounds;\n if (this.shapes.length > 0) {\n bounds = this.bounds();\n this.visual.visible(true);\n this.visual.position(bounds.topLeft());\n $.each(this.map, function () {\n b = that._getHandleBounds(new Point(this.x, this.y));\n this.visual.position(b.topLeft());\n });\n this.visual.position(bounds.topLeft());\n var center = new Point(bounds.width / 2, bounds.height / 2);\n this.visual.rotate(this._angle, center);\n this.rect.redraw({\n width: bounds.width,\n height: bounds.height\n });\n if (this.rotationThumb) {\n var thumb = this.options.editable.rotate.thumb;\n this._rotationThumbBounds = new Rect(bounds.center().x, bounds.y + thumb.y, 0, 0).inflate(thumb.width);\n this.rotationThumb.redraw({ x: bounds.width / 2 - thumb.width / 2 });\n }\n } else {\n this.visual.visible(false);\n }\n }\n });\n var Selector = Class.extend({\n init: function (diagram) {\n var selectable = diagram.options.selectable;\n this.options = deepExtend({}, this.options, selectable);\n this.visual = new Rectangle(this.options);\n this.diagram = diagram;\n },\n options: {\n stroke: {\n color: '#778899',\n width: 1,\n dashType: 'dash'\n },\n fill: { color: TRANSPARENT }\n },\n start: function (p) {\n this._sp = this._ep = p;\n this.refresh();\n this.diagram._adorn(this, true);\n },\n end: function () {\n this._sp = this._ep = undefined;\n this.diagram._adorn(this, false);\n },\n bounds: function (value) {\n if (value) {\n this._bounds = value;\n }\n return this._bounds;\n },\n move: function (p) {\n this._ep = p;\n this.refresh();\n },\n refresh: function () {\n if (this._sp) {\n var visualBounds = Rect.fromPoints(this.diagram.modelToLayer(this._sp), this.diagram.modelToLayer(this._ep));\n this.bounds(Rect.fromPoints(this._sp, this._ep));\n this.visual.position(visualBounds.topLeft());\n this.visual.redraw({\n height: visualBounds.height + 1,\n width: visualBounds.width + 1\n });\n }\n }\n });\n var ConnectorVisual = Class.extend({\n init: function (connector) {\n this.options = deepExtend({}, connector.options);\n this._c = connector;\n this.visual = new Circle(this.options);\n this.refresh();\n },\n _hover: function (value) {\n var options = this.options, hover = options.hover, stroke = options.stroke, fill = options.fill;\n if (value && Utils.isDefined(hover.stroke)) {\n stroke = deepExtend({}, stroke, hover.stroke);\n }\n if (value && Utils.isDefined(hover.fill)) {\n fill = hover.fill;\n }\n this.visual.redraw({\n stroke: stroke,\n fill: fill\n });\n },\n refresh: function () {\n var p = this._c.shape.diagram.modelToView(this._c.position()), relative = p.minus(this._c.shape.bounds('transformed').topLeft()), value = new Rect(p.x, p.y, 0, 0);\n value.inflate(this.options.width / 2, this.options.height / 2);\n this._visualBounds = value;\n this.visual.redraw({ center: new Point(relative.x, relative.y) });\n },\n _hitTest: function (p) {\n var tp = this._c.shape.diagram.modelToView(p);\n return this._visualBounds.contains(tp);\n }\n });\n function canDrag(element) {\n var editable = element.options.editable;\n return editable && editable.drag !== false;\n }\n function hitTestShapeConnectors(shape, point) {\n var connector, position, rect;\n for (var idx = 0; idx < shape.connectors.length; idx++) {\n connector = shape.connectors[idx];\n position = connector.position();\n rect = new Rect(position.x, position.y);\n rect.inflate(HIT_TEST_DISTANCE, HIT_TEST_DISTANCE);\n if (rect.contains(point)) {\n return connector;\n }\n }\n }\n function noMeta(meta) {\n return meta.ctrlKey === false && meta.altKey === false && meta.shiftKey === false;\n }\n deepExtend(diagram, {\n CompositeUnit: CompositeUnit,\n TransformUnit: TransformUnit,\n PanUndoUnit: PanUndoUnit,\n AddShapeUnit: AddShapeUnit,\n AddConnectionUnit: AddConnectionUnit,\n DeleteShapeUnit: DeleteShapeUnit,\n DeleteConnectionUnit: DeleteConnectionUnit,\n ConnectionEditAdorner: ConnectionEditAdorner,\n ConnectionTool: ConnectionTool,\n ConnectorVisual: ConnectorVisual,\n UndoRedoService: UndoRedoService,\n ResizingAdorner: ResizingAdorner,\n Selector: Selector,\n ToolService: ToolService,\n ConnectorsAdorner: ConnectorsAdorner,\n LayoutUndoUnit: LayoutUndoUnit,\n ConnectionEditUnit: ConnectionEditUnit,\n ToFrontUnit: ToFrontUnit,\n ToBackUnit: ToBackUnit,\n ConnectionRouterBase: ConnectionRouterBase,\n PolylineRouter: PolylineRouter,\n CascadingRouter: CascadingRouter,\n SelectionTool: SelectionTool,\n ScrollerTool: ScrollerTool,\n PointerTool: PointerTool,\n ConnectionEditTool: ConnectionEditTool,\n RotateUnit: RotateUnit\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('dataviz/diagram/layout', ['dataviz/diagram/math'], f);\n}(function () {\n (function ($, undefined) {\n var kendo = window.kendo, diagram = kendo.dataviz.diagram, Graph = diagram.Graph, Node = diagram.Node, Link = diagram.Link, deepExtend = kendo.deepExtend, Size = diagram.Size, Rect = diagram.Rect, Dictionary = diagram.Dictionary, Set = diagram.Set, HyperTree = diagram.Graph, Utils = diagram.Utils, Point = diagram.Point, EPSILON = 0.000001, DEG_TO_RAD = Math.PI / 180, contains = Utils.contains, grep = $.grep;\n var LayoutBase = kendo.Class.extend({\n defaultOptions: {\n type: 'Tree',\n subtype: 'Down',\n roots: null,\n animate: false,\n limitToView: false,\n friction: 0.9,\n nodeDistance: 50,\n iterations: 300,\n horizontalSeparation: 90,\n verticalSeparation: 50,\n underneathVerticalTopOffset: 15,\n underneathHorizontalOffset: 15,\n underneathVerticalSeparation: 15,\n grid: {\n width: 1500,\n offsetX: 50,\n offsetY: 50,\n componentSpacingX: 20,\n componentSpacingY: 20\n },\n layerSeparation: 50,\n layeredIterations: 2,\n startRadialAngle: 0,\n endRadialAngle: 360,\n radialSeparation: 150,\n radialFirstLevelSeparation: 200,\n keepComponentsInOneRadialLayout: false,\n ignoreContainers: true,\n layoutContainerChildren: false,\n ignoreInvisible: true,\n animateTransitions: false\n },\n init: function () {\n },\n gridLayoutComponents: function (components) {\n if (!components) {\n throw 'No components supplied.';\n }\n Utils.forEach(components, function (c) {\n c.calcBounds();\n });\n components.sort(function (a, b) {\n return b.bounds.width - a.bounds.width;\n });\n var maxWidth = this.options.grid.width, offsetX = this.options.grid.componentSpacingX, offsetY = this.options.grid.componentSpacingY, height = 0, startX = this.options.grid.offsetX, startY = this.options.grid.offsetY, x = startX, y = startY, i, resultLinkSet = [], resultNodeSet = [];\n while (components.length > 0) {\n if (x >= maxWidth) {\n x = startX;\n y += height + offsetY;\n height = 0;\n }\n var component = components.pop();\n this.moveToOffset(component, new Point(x, y));\n for (i = 0; i < component.nodes.length; i++) {\n resultNodeSet.push(component.nodes[i]);\n }\n for (i = 0; i < component.links.length; i++) {\n resultLinkSet.push(component.links[i]);\n }\n var boundingRect = component.bounds;\n var currentHeight = boundingRect.height;\n if (currentHeight <= 0 || isNaN(currentHeight)) {\n currentHeight = 0;\n }\n var currentWidth = boundingRect.width;\n if (currentWidth <= 0 || isNaN(currentWidth)) {\n currentWidth = 0;\n }\n if (currentHeight >= height) {\n height = currentHeight;\n }\n x += currentWidth + offsetX;\n }\n return {\n nodes: resultNodeSet,\n links: resultLinkSet\n };\n },\n moveToOffset: function (component, p) {\n var i, j, bounds = component.bounds, deltax = p.x - bounds.x, deltay = p.y - bounds.y;\n for (i = 0; i < component.nodes.length; i++) {\n var node = component.nodes[i];\n var nodeBounds = node.bounds();\n if (nodeBounds.width === 0 && nodeBounds.height === 0 && nodeBounds.x === 0 && nodeBounds.y === 0) {\n nodeBounds = new Rect(0, 0, 0, 0);\n }\n nodeBounds.x += deltax;\n nodeBounds.y += deltay;\n node.bounds(nodeBounds);\n }\n for (i = 0; i < component.links.length; i++) {\n var link = component.links[i];\n if (link.points) {\n var newpoints = [];\n var points = link.points;\n for (j = 0; j < points.length; j++) {\n var pt = points[j];\n pt.x += deltax;\n pt.y += deltay;\n newpoints.push(pt);\n }\n link.points = newpoints;\n }\n }\n this.currentHorizontalOffset += bounds.width + this.options.grid.offsetX;\n return new Point(deltax, deltay);\n },\n transferOptions: function (options) {\n this.options = kendo.deepExtend({}, this.defaultOptions);\n if (Utils.isUndefined(options)) {\n return;\n }\n this.options = kendo.deepExtend(this.options, options || {});\n }\n });\n var DiagramToHyperTreeAdapter = kendo.Class.extend({\n init: function (diagram) {\n this.nodeMap = new Dictionary();\n this.shapeMap = new Dictionary();\n this.nodes = [];\n this.edges = [];\n this.edgeMap = new Dictionary();\n this.finalNodes = [];\n this.finalLinks = [];\n this.ignoredConnections = [];\n this.ignoredShapes = [];\n this.hyperMap = new Dictionary();\n this.hyperTree = new Graph();\n this.finalGraph = null;\n this.diagram = diagram;\n },\n convert: function (options) {\n if (Utils.isUndefined(this.diagram)) {\n throw 'No diagram to convert.';\n }\n this.options = kendo.deepExtend({\n ignoreInvisible: true,\n ignoreContainers: true,\n layoutContainerChildren: false\n }, options || {});\n this.clear();\n this._renormalizeShapes();\n this._renormalizeConnections();\n this.finalNodes = new Dictionary(this.nodes);\n this.finalLinks = new Dictionary(this.edges);\n this.finalGraph = new Graph();\n this.finalNodes.forEach(function (n) {\n this.finalGraph.addNode(n);\n }, this);\n this.finalLinks.forEach(function (l) {\n this.finalGraph.addExistingLink(l);\n }, this);\n return this.finalGraph;\n },\n mapConnection: function (connection) {\n return this.edgeMap.get(connection.id);\n },\n mapShape: function (shape) {\n return this.nodeMap.get(shape.id);\n },\n getEdge: function (a, b) {\n return Utils.first(a.links, function (link) {\n return link.getComplement(a) === b;\n });\n },\n clear: function () {\n this.finalGraph = null;\n this.hyperTree = !this.options.ignoreContainers && this.options.layoutContainerChildren ? new HyperTree() : null;\n this.hyperMap = !this.options.ignoreContainers && this.options.layoutContainerChildren ? new Dictionary() : null;\n this.nodeMap = new Dictionary();\n this.shapeMap = new Dictionary();\n this.nodes = [];\n this.edges = [];\n this.edgeMap = new Dictionary();\n this.ignoredConnections = [];\n this.ignoredShapes = [];\n this.finalNodes = [];\n this.finalLinks = [];\n },\n listToRoot: function (containerGraph) {\n var list = [];\n var s = containerGraph.container;\n if (!s) {\n return list;\n }\n list.push(s);\n while (s.parentContainer) {\n s = s.parentContainer;\n list.push(s);\n }\n list.reverse();\n return list;\n },\n firstNonIgnorableContainer: function (shape) {\n if (shape.isContainer && !this._isIgnorableItem(shape)) {\n return shape;\n }\n return !shape.parentContainer ? null : this.firstNonIgnorableContainer(shape.parentContainer);\n },\n isContainerConnection: function (a, b) {\n if (a.isContainer && this.isDescendantOf(a, b)) {\n return true;\n }\n return b.isContainer && this.isDescendantOf(b, a);\n },\n isDescendantOf: function (scope, a) {\n if (!scope.isContainer) {\n throw 'Expecting a container.';\n }\n if (scope === a) {\n return false;\n }\n if (contains(scope.children, a)) {\n return true;\n }\n var containers = [];\n for (var i = 0, len = scope.children.length; i < len; i++) {\n var c = scope.children[i];\n if (c.isContainer && this.isDescendantOf(c, a)) {\n containers.push(c);\n }\n }\n return containers.length > 0;\n },\n isIgnorableItem: function (shape) {\n if (this.options.ignoreInvisible) {\n if (shape.isCollapsed && this._isVisible(shape)) {\n return false;\n }\n if (!shape.isCollapsed && this._isVisible(shape)) {\n return false;\n }\n return true;\n } else {\n return shape.isCollapsed && !this._isTop(shape);\n }\n },\n isShapeMapped: function (shape) {\n return shape.isCollapsed && !this._isVisible(shape) && !this._isTop(shape);\n },\n leastCommonAncestor: function (a, b) {\n if (!a) {\n throw 'Parameter should not be null.';\n }\n if (!b) {\n throw 'Parameter should not be null.';\n }\n if (!this.hyperTree) {\n throw 'No hypertree available.';\n }\n var al = this.listToRoot(a);\n var bl = this.listToRoot(b);\n var found = null;\n if (Utils.isEmpty(al) || Utils.isEmpty(bl)) {\n return this.hyperTree.root.data;\n }\n var xa = al[0];\n var xb = bl[0];\n var i = 0;\n while (xa === xb) {\n found = al[i];\n i++;\n if (i >= al.length || i >= bl.length) {\n break;\n }\n xa = al[i];\n xb = bl[i];\n }\n if (!found) {\n return this.hyperTree.root.data;\n } else {\n return grep(this.hyperTree.nodes, function (n) {\n return n.data.container === found;\n });\n }\n },\n _isTop: function (item) {\n return !item.parentContainer;\n },\n _isVisible: function (shape) {\n if (!shape.visible()) {\n return false;\n }\n return !shape.parentContainer ? shape.visible() : this._isVisible(shape.parentContainer);\n },\n _isCollapsed: function (shape) {\n if (shape.isContainer && shape.isCollapsed) {\n return true;\n }\n return shape.parentContainer && this._isCollapsed(shape.parentContainer);\n },\n _renormalizeShapes: function () {\n if (this.options.ignoreContainers) {\n for (var i = 0, len = this.diagram.shapes.length; i < len; i++) {\n var shape = this.diagram.shapes[i];\n if (this.options.ignoreInvisible && !this._isVisible(shape) || shape.isContainer) {\n this.ignoredShapes.push(shape);\n continue;\n }\n var node = new Node(shape.id, shape);\n node.isVirtual = false;\n this.nodeMap.add(shape.id, node);\n this.nodes.push(node);\n }\n } else {\n throw 'Containers are not supported yet, but stay tuned.';\n }\n },\n _renormalizeConnections: function () {\n if (this.diagram.connections.length === 0) {\n return;\n }\n for (var i = 0, len = this.diagram.connections.length; i < len; i++) {\n var conn = this.diagram.connections[i];\n if (this.isIgnorableItem(conn)) {\n this.ignoredConnections.push(conn);\n continue;\n }\n var source = !conn.sourceConnector ? null : conn.sourceConnector.shape;\n var sink = !conn.targetConnector ? null : conn.targetConnector.shape;\n if (!source || !sink) {\n this.ignoredConnections.push(conn);\n continue;\n }\n if (contains(this.ignoredShapes, source) && !this.shapeMap.containsKey(source)) {\n this.ignoredConnections.push(conn);\n continue;\n }\n if (contains(this.ignoredShapes, sink) && !this.shapeMap.containsKey(sink)) {\n this.ignoredConnections.push(conn);\n continue;\n }\n if (this.shapeMap.containsKey(source)) {\n source = this.shapeMap[source];\n }\n if (this.shapeMap.containsKey(sink)) {\n sink = this.shapeMap[sink];\n }\n var sourceNode = this.mapShape(source);\n var sinkNode = this.mapShape(sink);\n if (sourceNode === sinkNode || this.areConnectedAlready(sourceNode, sinkNode)) {\n this.ignoredConnections.push(conn);\n continue;\n }\n if (sourceNode === null || sinkNode === null) {\n throw 'A shape was not mapped to a node.';\n }\n if (this.options.ignoreContainers) {\n if (sourceNode.isVirtual || sinkNode.isVirtual) {\n this.ignoredConnections.push(conn);\n continue;\n }\n var newEdge = new Link(sourceNode, sinkNode, conn.id, conn);\n this.edgeMap.add(conn.id, newEdge);\n this.edges.push(newEdge);\n } else {\n throw 'Containers are not supported yet, but stay tuned.';\n }\n }\n },\n areConnectedAlready: function (n, m) {\n return Utils.any(this.edges, function (l) {\n return l.source === n && l.target === m || l.source === m && l.target === n;\n });\n }\n });\n var SpringLayout = LayoutBase.extend({\n init: function (diagram) {\n var that = this;\n LayoutBase.fn.init.call(that);\n if (Utils.isUndefined(diagram)) {\n throw 'Diagram is not specified.';\n }\n this.diagram = diagram;\n },\n layout: function (options) {\n this.transferOptions(options);\n var adapter = new DiagramToHyperTreeAdapter(this.diagram);\n var graph = adapter.convert(options);\n if (graph.isEmpty()) {\n return;\n }\n var components = graph.getConnectedComponents();\n if (Utils.isEmpty(components)) {\n return;\n }\n for (var i = 0; i < components.length; i++) {\n var component = components[i];\n this.layoutGraph(component, options);\n }\n var finalNodeSet = this.gridLayoutComponents(components);\n return new diagram.LayoutState(this.diagram, finalNodeSet);\n },\n layoutGraph: function (graph, options) {\n if (Utils.isDefined(options)) {\n this.transferOptions(options);\n }\n this.graph = graph;\n var initialTemperature = this.options.nodeDistance * 9;\n this.temperature = initialTemperature;\n var guessBounds = this._expectedBounds();\n this.width = guessBounds.width;\n this.height = guessBounds.height;\n for (var step = 0; step < this.options.iterations; step++) {\n this.refineStage = step >= this.options.iterations * 5 / 6;\n this.tick();\n this.temperature = this.refineStage ? initialTemperature / 30 : initialTemperature * (1 - step / (2 * this.options.iterations));\n }\n },\n tick: function () {\n var i;\n for (i = 0; i < this.graph.nodes.length; i++) {\n this._repulsion(this.graph.nodes[i]);\n }\n for (i = 0; i < this.graph.links.length; i++) {\n this._attraction(this.graph.links[i]);\n }\n for (i = 0; i < this.graph.nodes.length; i++) {\n var node = this.graph.nodes[i];\n var offset = Math.sqrt(node.dx * node.dx + node.dy * node.dy);\n if (offset === 0) {\n return;\n }\n node.x += Math.min(offset, this.temperature) * node.dx / offset;\n node.y += Math.min(offset, this.temperature) * node.dy / offset;\n if (this.options.limitToView) {\n node.x = Math.min(this.width, Math.max(node.width / 2, node.x));\n node.y = Math.min(this.height, Math.max(node.height / 2, node.y));\n }\n }\n },\n _shake: function (node) {\n var rho = Math.random() * this.options.nodeDistance / 4;\n var alpha = Math.random() * 2 * Math.PI;\n node.x += rho * Math.cos(alpha);\n node.y -= rho * Math.sin(alpha);\n },\n _InverseSquareForce: function (d, n, m) {\n var force;\n if (!this.refineStage) {\n force = Math.pow(d, 2) / Math.pow(this.options.nodeDistance, 2);\n } else {\n var deltax = n.x - m.x;\n var deltay = n.y - m.y;\n var wn = n.width / 2;\n var hn = n.height / 2;\n var wm = m.width / 2;\n var hm = m.height / 2;\n force = Math.pow(deltax, 2) / Math.pow(wn + wm + this.options.nodeDistance, 2) + Math.pow(deltay, 2) / Math.pow(hn + hm + this.options.nodeDistance, 2);\n }\n return force * 4 / 3;\n },\n _SquareForce: function (d, n, m) {\n return 1 / this._InverseSquareForce(d, n, m);\n },\n _repulsion: function (n) {\n n.dx = 0;\n n.dy = 0;\n Utils.forEach(this.graph.nodes, function (m) {\n if (m === n) {\n return;\n }\n while (n.x === m.x && n.y === m.y) {\n this._shake(m);\n }\n var vx = n.x - m.x;\n var vy = n.y - m.y;\n var distance = Math.sqrt(vx * vx + vy * vy);\n var r = this._SquareForce(distance, n, m) * 2;\n n.dx += vx / distance * r;\n n.dy += vy / distance * r;\n }, this);\n },\n _attraction: function (link) {\n var t = link.target;\n var s = link.source;\n if (s === t) {\n return;\n }\n while (s.x === t.x && s.y === t.y) {\n this._shake(t);\n }\n var vx = s.x - t.x;\n var vy = s.y - t.y;\n var distance = Math.sqrt(vx * vx + vy * vy);\n var a = this._InverseSquareForce(distance, s, t) * 5;\n var dx = vx / distance * a;\n var dy = vy / distance * a;\n t.dx += dx;\n t.dy += dy;\n s.dx -= dx;\n s.dy -= dy;\n },\n _expectedBounds: function () {\n var size, N = this.graph.nodes.length, ratio = 1.5, multiplier = 4;\n if (N === 0) {\n return size;\n }\n size = Utils.fold(this.graph.nodes, function (s, node) {\n var area = node.width * node.height;\n if (area > 0) {\n s += Math.sqrt(area);\n return s;\n }\n return 0;\n }, 0, this);\n var av = size / N;\n var squareSize = av * Math.ceil(Math.sqrt(N));\n var width = squareSize * Math.sqrt(ratio);\n var height = squareSize / Math.sqrt(ratio);\n return {\n width: width * multiplier,\n height: height * multiplier\n };\n }\n });\n var TreeLayoutProcessor = kendo.Class.extend({\n init: function (options) {\n this.center = null;\n this.options = options;\n },\n layout: function (treeGraph, root) {\n this.graph = treeGraph;\n if (!this.graph.nodes || this.graph.nodes.length === 0) {\n return;\n }\n if (!contains(this.graph.nodes, root)) {\n throw 'The given root is not in the graph.';\n }\n this.center = root;\n this.graph.cacheRelationships();\n this.layoutSwitch();\n },\n layoutLeft: function (left) {\n this.setChildrenDirection(this.center, 'Left', false);\n this.setChildrenLayout(this.center, 'Default', false);\n var h = 0, w = 0, y, i, node;\n for (i = 0; i < left.length; i++) {\n node = left[i];\n node.TreeDirection = 'Left';\n var s = this.measure(node, Size.Empty);\n w = Math.max(w, s.Width);\n h += s.height + this.options.verticalSeparation;\n }\n h -= this.options.verticalSeparation;\n var x = this.center.x - this.options.horizontalSeparation;\n y = this.center.y + (this.center.height - h) / 2;\n for (i = 0; i < left.length; i++) {\n node = left[i];\n var p = new Point(x - node.Size.width, y);\n this.arrange(node, p);\n y += node.Size.height + this.options.verticalSeparation;\n }\n },\n layoutRight: function (right) {\n this.setChildrenDirection(this.center, 'Right', false);\n this.setChildrenLayout(this.center, 'Default', false);\n var h = 0, w = 0, y, i, node;\n for (i = 0; i < right.length; i++) {\n node = right[i];\n node.TreeDirection = 'Right';\n var s = this.measure(node, Size.Empty);\n w = Math.max(w, s.Width);\n h += s.height + this.options.verticalSeparation;\n }\n h -= this.options.verticalSeparation;\n var x = this.center.x + this.options.horizontalSeparation + this.center.width;\n y = this.center.y + (this.center.height - h) / 2;\n for (i = 0; i < right.length; i++) {\n node = right[i];\n var p = new Point(x, y);\n this.arrange(node, p);\n y += node.Size.height + this.options.verticalSeparation;\n }\n },\n layoutUp: function (up) {\n this.setChildrenDirection(this.center, 'Up', false);\n this.setChildrenLayout(this.center, 'Default', false);\n var w = 0, y, node, i;\n for (i = 0; i < up.length; i++) {\n node = up[i];\n node.TreeDirection = 'Up';\n var s = this.measure(node, Size.Empty);\n w += s.width + this.options.horizontalSeparation;\n }\n w -= this.options.horizontalSeparation;\n var x = this.center.x + this.center.width / 2 - w / 2;\n for (i = 0; i < up.length; i++) {\n node = up[i];\n y = this.center.y - this.options.verticalSeparation - node.Size.height;\n var p = new Point(x, y);\n this.arrange(node, p);\n x += node.Size.width + this.options.horizontalSeparation;\n }\n },\n layoutDown: function (down) {\n var node, i;\n this.setChildrenDirection(this.center, 'Down', false);\n this.setChildrenLayout(this.center, 'Default', false);\n var w = 0, y;\n for (i = 0; i < down.length; i++) {\n node = down[i];\n node.treeDirection = 'Down';\n var s = this.measure(node, Size.Empty);\n w += s.width + this.options.horizontalSeparation;\n }\n w -= this.options.horizontalSeparation;\n var x = this.center.x + this.center.width / 2 - w / 2;\n y = this.center.y + this.options.verticalSeparation + this.center.height;\n for (i = 0; i < down.length; i++) {\n node = down[i];\n var p = new Point(x, y);\n this.arrange(node, p);\n x += node.Size.width + this.options.horizontalSeparation;\n }\n },\n layoutRadialTree: function () {\n this.setChildrenDirection(this.center, 'Radial', false);\n this.setChildrenLayout(this.center, 'Default', false);\n this.previousRoot = null;\n var startAngle = this.options.startRadialAngle * DEG_TO_RAD;\n var endAngle = this.options.endRadialAngle * DEG_TO_RAD;\n if (endAngle <= startAngle) {\n throw 'Final angle should not be less than the start angle.';\n }\n this.maxDepth = 0;\n this.origin = new Point(this.center.x, this.center.y);\n this.calculateAngularWidth(this.center, 0);\n if (this.maxDepth > 0) {\n this.radialLayout(this.center, this.options.radialFirstLevelSeparation, startAngle, endAngle);\n }\n this.center.Angle = endAngle - startAngle;\n },\n tipOverTree: function (down, startFromLevel) {\n if (Utils.isUndefined(startFromLevel)) {\n startFromLevel = 0;\n }\n this.setChildrenDirection(this.center, 'Down', false);\n this.setChildrenLayout(this.center, 'Default', false);\n this.setChildrenLayout(this.center, 'Underneath', false, startFromLevel);\n var w = 0, y, node, i;\n for (i = 0; i < down.length; i++) {\n node = down[i];\n node.TreeDirection = 'Down';\n var s = this.measure(node, Size.Empty);\n w += s.width + this.options.horizontalSeparation;\n }\n w -= this.options.horizontalSeparation;\n w -= down[down.length - 1].width;\n w += down[down.length - 1].associatedShape.bounds().width;\n var x = this.center.x + this.center.width / 2 - w / 2;\n y = this.center.y + this.options.verticalSeparation + this.center.height;\n for (i = 0; i < down.length; i++) {\n node = down[i];\n var p = new Point(x, y);\n this.arrange(node, p);\n x += node.Size.width + this.options.horizontalSeparation;\n }\n },\n calculateAngularWidth: function (n, d) {\n if (d > this.maxDepth) {\n this.maxDepth = d;\n }\n var aw = 0, w = 1000, h = 1000, diameter = d === 0 ? 0 : Math.sqrt(w * w + h * h) / d;\n if (n.children.length > 0) {\n for (var i = 0, len = n.children.length; i < len; i++) {\n var child = n.children[i];\n aw += this.calculateAngularWidth(child, d + 1);\n }\n aw = Math.max(diameter, aw);\n } else {\n aw = diameter;\n }\n n.sectorAngle = aw;\n return aw;\n },\n sortChildren: function (n) {\n var basevalue = 0, i;\n if (n.parents.length > 1) {\n throw 'Node is not part of a tree.';\n }\n var p = n.parents[0];\n if (p) {\n var pl = new Point(p.x, p.y);\n var nl = new Point(n.x, n.y);\n basevalue = this.normalizeAngle(Math.atan2(pl.y - nl.y, pl.x - nl.x));\n }\n var count = n.children.length;\n if (count === 0) {\n return null;\n }\n var angle = [];\n var idx = [];\n for (i = 0; i < count; ++i) {\n var c = n.children[i];\n var l = new Point(c.x, c.y);\n idx[i] = i;\n angle[i] = this.normalizeAngle(-basevalue + Math.atan2(l.y - l.y, l.x - l.x));\n }\n Utils.bisort(angle, idx);\n var col = [];\n var children = n.children;\n for (i = 0; i < count; ++i) {\n col.push(children[idx[i]]);\n }\n return col;\n },\n normalizeAngle: function (angle) {\n while (angle > Math.PI * 2) {\n angle -= 2 * Math.PI;\n }\n while (angle < 0) {\n angle += Math.PI * 2;\n }\n return angle;\n },\n radialLayout: function (node, radius, startAngle, endAngle) {\n var deltaTheta = endAngle - startAngle;\n var deltaThetaHalf = deltaTheta / 2;\n var parentSector = node.sectorAngle;\n var fraction = 0;\n var sorted = this.sortChildren(node);\n for (var i = 0, len = sorted.length; i < len; i++) {\n var childNode = sorted[i];\n var cp = childNode;\n var childAngleFraction = cp.sectorAngle / parentSector;\n if (childNode.children.length > 0) {\n this.radialLayout(childNode, radius + this.options.radialSeparation, startAngle + fraction * deltaTheta, startAngle + (fraction + childAngleFraction) * deltaTheta);\n }\n this.setPolarLocation(childNode, radius, startAngle + fraction * deltaTheta + childAngleFraction * deltaThetaHalf);\n cp.angle = childAngleFraction * deltaTheta;\n fraction += childAngleFraction;\n }\n },\n setPolarLocation: function (node, radius, angle) {\n node.x = this.origin.x + radius * Math.cos(angle);\n node.y = this.origin.y + radius * Math.sin(angle);\n node.BoundingRectangle = new Rect(node.x, node.y, node.width, node.height);\n },\n setChildrenDirection: function (node, direction, includeStart) {\n var rootDirection = node.treeDirection;\n this.graph.depthFirstTraversal(node, function (n) {\n n.treeDirection = direction;\n });\n if (!includeStart) {\n node.treeDirection = rootDirection;\n }\n },\n setChildrenLayout: function (node, layout, includeStart, startFromLevel) {\n if (Utils.isUndefined(startFromLevel)) {\n startFromLevel = 0;\n }\n var rootLayout = node.childrenLayout;\n if (startFromLevel > 0) {\n this.graph.assignLevels(node);\n this.graph.depthFirstTraversal(node, function (s) {\n if (s.level >= startFromLevel + 1) {\n s.childrenLayout = layout;\n }\n });\n } else {\n this.graph.depthFirstTraversal(node, function (s) {\n s.childrenLayout = layout;\n });\n if (!includeStart) {\n node.childrenLayout = rootLayout;\n }\n }\n },\n measure: function (node, givenSize) {\n var w = 0, h = 0, s;\n var result = new Size(0, 0);\n if (!node) {\n throw '';\n }\n var b = node.associatedShape.bounds();\n var shapeWidth = b.width;\n var shapeHeight = b.height;\n if (node.parents.length !== 1) {\n throw 'Node not in a spanning tree.';\n }\n var parent = node.parents[0];\n if (node.treeDirection === 'Undefined') {\n node.treeDirection = parent.treeDirection;\n }\n if (Utils.isEmpty(node.children)) {\n result = new Size(Math.abs(shapeWidth) < EPSILON ? 50 : shapeWidth, Math.abs(shapeHeight) < EPSILON ? 25 : shapeHeight);\n } else if (node.children.length === 1) {\n switch (node.treeDirection) {\n case 'Radial':\n s = this.measure(node.children[0], givenSize);\n w = shapeWidth + this.options.radialSeparation * Math.cos(node.AngleToParent) + s.width;\n h = shapeHeight + Math.abs(this.options.radialSeparation * Math.sin(node.AngleToParent)) + s.height;\n break;\n case 'Left':\n case 'Right':\n switch (node.childrenLayout) {\n case 'TopAlignedWithParent':\n break;\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n s = this.measure(node.children[0], givenSize);\n w = shapeWidth + s.width + this.options.underneathHorizontalOffset;\n h = shapeHeight + this.options.underneathVerticalTopOffset + s.height;\n break;\n case 'Default':\n s = this.measure(node.children[0], givenSize);\n w = shapeWidth + this.options.horizontalSeparation + s.width;\n h = Math.max(shapeHeight, s.height);\n break;\n default:\n throw 'Unhandled TreeDirection in the Radial layout measuring.';\n }\n break;\n case 'Up':\n case 'Down':\n switch (node.childrenLayout) {\n case 'TopAlignedWithParent':\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n s = this.measure(node.children[0], givenSize);\n w = Math.max(shapeWidth, s.width + this.options.underneathHorizontalOffset);\n h = shapeHeight + this.options.underneathVerticalTopOffset + s.height;\n break;\n case 'Default':\n s = this.measure(node.children[0], givenSize);\n h = shapeHeight + this.options.verticalSeparation + s.height;\n w = Math.max(shapeWidth, s.width);\n break;\n default:\n throw 'Unhandled TreeDirection in the Down layout measuring.';\n }\n break;\n default:\n throw 'Unhandled TreeDirection in the layout measuring.';\n }\n result = new Size(w, h);\n } else {\n var i, childNode;\n switch (node.treeDirection) {\n case 'Left':\n case 'Right':\n switch (node.childrenLayout) {\n case 'TopAlignedWithParent':\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n w = shapeWidth;\n h = shapeHeight + this.options.underneathVerticalTopOffset;\n for (i = 0; i < node.children.length; i++) {\n childNode = node.children[i];\n s = this.measure(childNode, givenSize);\n w = Math.max(w, s.width + this.options.underneathHorizontalOffset);\n h += s.height + this.options.underneathVerticalSeparation;\n }\n h -= this.options.underneathVerticalSeparation;\n break;\n case 'Default':\n w = shapeWidth;\n h = 0;\n for (i = 0; i < node.children.length; i++) {\n childNode = node.children[i];\n s = this.measure(childNode, givenSize);\n w = Math.max(w, shapeWidth + this.options.horizontalSeparation + s.width);\n h += s.height + this.options.verticalSeparation;\n }\n h -= this.options.verticalSeparation;\n break;\n default:\n throw 'Unhandled TreeDirection in the Right layout measuring.';\n }\n break;\n case 'Up':\n case 'Down':\n switch (node.childrenLayout) {\n case 'TopAlignedWithParent':\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n w = shapeWidth;\n h = shapeHeight + this.options.underneathVerticalTopOffset;\n for (i = 0; i < node.children.length; i++) {\n childNode = node.children[i];\n s = this.measure(childNode, givenSize);\n w = Math.max(w, s.width + this.options.underneathHorizontalOffset);\n h += s.height + this.options.underneathVerticalSeparation;\n }\n h -= this.options.underneathVerticalSeparation;\n break;\n case 'Default':\n w = 0;\n h = 0;\n for (i = 0; i < node.children.length; i++) {\n childNode = node.children[i];\n s = this.measure(childNode, givenSize);\n w += s.width + this.options.horizontalSeparation;\n h = Math.max(h, s.height + this.options.verticalSeparation + shapeHeight);\n }\n w -= this.options.horizontalSeparation;\n break;\n default:\n throw 'Unhandled TreeDirection in the Down layout measuring.';\n }\n break;\n default:\n throw 'Unhandled TreeDirection in the layout measuring.';\n }\n result = new Size(w, h);\n }\n node.SectorAngle = Math.sqrt(w * w / 4 + h * h / 4);\n node.Size = result;\n return result;\n },\n arrange: function (n, p) {\n var i, pp, child, node, childrenwidth, b = n.associatedShape.bounds();\n var shapeWidth = b.width;\n var shapeHeight = b.height;\n if (Utils.isEmpty(n.children)) {\n n.x = p.x;\n n.y = p.y;\n n.BoundingRectangle = new Rect(p.x, p.y, shapeWidth, shapeHeight);\n } else {\n var x, y;\n var selfLocation;\n switch (n.treeDirection) {\n case 'Left':\n switch (n.childrenLayout) {\n case 'TopAlignedWithParent':\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n selfLocation = p;\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n y = p.y + shapeHeight + this.options.underneathVerticalTopOffset;\n for (i = 0; i < node.children.length; i++) {\n node = node.children[i];\n x = selfLocation.x - node.associatedShape.width - this.options.underneathHorizontalOffset;\n pp = new Point(x, y);\n this.arrange(node, pp);\n y += node.Size.height + this.options.underneathVerticalSeparation;\n }\n break;\n case 'Default':\n selfLocation = new Point(p.x + n.Size.width - shapeWidth, p.y + (n.Size.height - shapeHeight) / 2);\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n x = selfLocation.x - this.options.horizontalSeparation;\n y = p.y;\n for (i = 0; i < n.children.length; i++) {\n node = n.children[i];\n pp = new Point(x - node.Size.width, y);\n this.arrange(node, pp);\n y += node.Size.height + this.options.verticalSeparation;\n }\n break;\n default:\n throw 'Unsupported TreeDirection';\n }\n break;\n case 'Right':\n switch (n.childrenLayout) {\n case 'TopAlignedWithParent':\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n selfLocation = p;\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n x = p.x + shapeWidth + this.options.underneathHorizontalOffset;\n y = p.y + shapeHeight + this.options.underneathVerticalTopOffset;\n for (i = 0; i < n.children.length; i++) {\n node = n.children[i];\n pp = new Point(x, y);\n this.arrange(node, pp);\n y += node.Size.height + this.options.underneathVerticalSeparation;\n }\n break;\n case 'Default':\n selfLocation = new Point(p.x, p.y + (n.Size.height - shapeHeight) / 2);\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n x = p.x + shapeWidth + this.options.horizontalSeparation;\n y = p.y;\n for (i = 0; i < n.children.length; i++) {\n node = n.children[i];\n pp = new Point(x, y);\n this.arrange(node, pp);\n y += node.Size.height + this.options.verticalSeparation;\n }\n break;\n default:\n throw 'Unsupported TreeDirection';\n }\n break;\n case 'Up':\n selfLocation = new Point(p.x + (n.Size.width - shapeWidth) / 2, p.y + n.Size.height - shapeHeight);\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n if (Math.abs(selfLocation.x - p.x) < EPSILON) {\n childrenwidth = 0;\n for (i = 0; i < n.children.length; i++) {\n child = n.children[i];\n childrenwidth += child.Size.width + this.options.horizontalSeparation;\n }\n childrenwidth -= this.options.horizontalSeparation;\n x = p.x + (shapeWidth - childrenwidth) / 2;\n } else {\n x = p.x;\n }\n for (i = 0; i < n.children.length; i++) {\n node = n.children[i];\n y = selfLocation.y - this.options.verticalSeparation - node.Size.height;\n pp = new Point(x, y);\n this.arrange(node, pp);\n x += node.Size.width + this.options.horizontalSeparation;\n }\n break;\n case 'Down':\n switch (n.childrenLayout) {\n case 'TopAlignedWithParent':\n case 'BottomAlignedWithParent':\n break;\n case 'Underneath':\n selfLocation = p;\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n x = p.x + this.options.underneathHorizontalOffset;\n y = p.y + shapeHeight + this.options.underneathVerticalTopOffset;\n for (i = 0; i < n.children.length; i++) {\n node = n.children[i];\n pp = new Point(x, y);\n this.arrange(node, pp);\n y += node.Size.height + this.options.underneathVerticalSeparation;\n }\n break;\n case 'Default':\n selfLocation = new Point(p.x + (n.Size.width - shapeWidth) / 2, p.y);\n n.x = selfLocation.x;\n n.y = selfLocation.y;\n n.BoundingRectangle = new Rect(n.x, n.y, n.width, n.height);\n if (Math.abs(selfLocation.x - p.x) < EPSILON) {\n childrenwidth = 0;\n for (i = 0; i < n.children.length; i++) {\n child = n.children[i];\n childrenwidth += child.Size.width + this.options.horizontalSeparation;\n }\n childrenwidth -= this.options.horizontalSeparation;\n x = p.x + (shapeWidth - childrenwidth) / 2;\n } else {\n x = p.x;\n }\n for (i = 0; i < n.children.length; i++) {\n node = n.children[i];\n y = selfLocation.y + this.options.verticalSeparation + shapeHeight;\n pp = new Point(x, y);\n this.arrange(node, pp);\n x += node.Size.width + this.options.horizontalSeparation;\n }\n break;\n default:\n throw 'Unsupported TreeDirection';\n }\n break;\n case 'None':\n break;\n default:\n throw 'Unsupported TreeDirection';\n }\n }\n },\n layoutSwitch: function () {\n if (!this.center) {\n return;\n }\n if (Utils.isEmpty(this.center.children)) {\n return;\n }\n var type = this.options.subtype;\n if (Utils.isUndefined(type)) {\n type = 'Down';\n }\n var single, male, female, leftcount;\n var children = this.center.children;\n switch (type.toLowerCase()) {\n case 'radial':\n case 'radialtree':\n this.layoutRadialTree();\n break;\n case 'mindmaphorizontal':\n case 'mindmap':\n single = this.center.children;\n if (this.center.children.length === 1) {\n this.layoutRight(single);\n } else {\n leftcount = children.length / 2;\n male = grep(this.center.children, function (n) {\n return Utils.indexOf(children, n) < leftcount;\n });\n female = grep(this.center.children, function (n) {\n return Utils.indexOf(children, n) >= leftcount;\n });\n this.layoutLeft(male);\n this.layoutRight(female);\n }\n break;\n case 'mindmapvertical':\n single = this.center.children;\n if (this.center.children.length === 1) {\n this.layoutDown(single);\n } else {\n leftcount = children.length / 2;\n male = grep(this.center.children, function (n) {\n return Utils.indexOf(children, n) < leftcount;\n });\n female = grep(this.center.children, function (n) {\n return Utils.indexOf(children, n) >= leftcount;\n });\n this.layoutUp(male);\n this.layoutDown(female);\n }\n break;\n case 'right':\n this.layoutRight(this.center.children);\n break;\n case 'left':\n this.layoutLeft(this.center.children);\n break;\n case 'up':\n case 'bottom':\n this.layoutUp(this.center.children);\n break;\n case 'down':\n case 'top':\n this.layoutDown(this.center.children);\n break;\n case 'tipover':\n case 'tipovertree':\n if (this.options.tipOverTreeStartLevel < 0) {\n throw 'The tip-over level should be a positive integer.';\n }\n this.tipOverTree(this.center.children, this.options.tipOverTreeStartLevel);\n break;\n case 'undefined':\n case 'none':\n break;\n }\n }\n });\n var TreeLayout = LayoutBase.extend({\n init: function (diagram) {\n var that = this;\n LayoutBase.fn.init.call(that);\n if (Utils.isUndefined(diagram)) {\n throw 'No diagram specified.';\n }\n this.diagram = diagram;\n },\n layout: function (options) {\n this.transferOptions(options);\n var adapter = new DiagramToHyperTreeAdapter(this.diagram);\n this.graph = adapter.convert();\n var finalNodeSet = this.layoutComponents();\n return new diagram.LayoutState(this.diagram, finalNodeSet);\n },\n layoutComponents: function () {\n if (this.graph.isEmpty()) {\n return;\n }\n var components = this.graph.getConnectedComponents();\n if (Utils.isEmpty(components)) {\n return;\n }\n var layout = new TreeLayoutProcessor(this.options);\n var trees = [];\n for (var i = 0; i < components.length; i++) {\n var component = components[i];\n var treeGraph = this.getTree(component);\n if (!treeGraph) {\n throw 'Failed to find a spanning tree for the component.';\n }\n var root = treeGraph.root;\n var tree = treeGraph.tree;\n layout.layout(tree, root);\n trees.push(tree);\n }\n return this.gridLayoutComponents(trees);\n },\n getTree: function (graph) {\n var root = null;\n if (this.options.roots && this.options.roots.length > 0) {\n for (var i = 0, len = graph.nodes.length; i < len; i++) {\n var node = graph.nodes[i];\n for (var j = 0; j < this.options.roots.length; j++) {\n var givenRootShape = this.options.roots[j];\n if (givenRootShape === node.associatedShape) {\n root = node;\n break;\n }\n }\n }\n }\n if (!root) {\n root = graph.root();\n if (!root) {\n throw 'Unable to find a root for the tree.';\n }\n }\n return this.getTreeForRoot(graph, root);\n },\n getTreeForRoot: function (graph, root) {\n var tree = graph.getSpanningTree(root);\n if (Utils.isUndefined(tree) || tree.isEmpty()) {\n return null;\n }\n return {\n tree: tree,\n root: tree.root\n };\n }\n });\n var LayeredLayout = LayoutBase.extend({\n init: function (diagram) {\n var that = this;\n LayoutBase.fn.init.call(that);\n if (Utils.isUndefined(diagram)) {\n throw 'Diagram is not specified.';\n }\n this.diagram = diagram;\n },\n layout: function (options) {\n this.transferOptions(options);\n var adapter = new DiagramToHyperTreeAdapter(this.diagram);\n var graph = adapter.convert(options);\n if (graph.isEmpty()) {\n return;\n }\n var components = graph.getConnectedComponents();\n if (Utils.isEmpty(components)) {\n return;\n }\n for (var i = 0; i < components.length; i++) {\n var component = components[i];\n this.layoutGraph(component, options);\n }\n var finalNodeSet = this.gridLayoutComponents(components);\n return new diagram.LayoutState(this.diagram, finalNodeSet);\n },\n _initRuntimeProperties: function () {\n for (var k = 0; k < this.graph.nodes.length; k++) {\n var node = this.graph.nodes[k];\n node.layer = -1;\n node.downstreamLinkCount = 0;\n node.upstreamLinkCount = 0;\n node.isVirtual = false;\n node.uBaryCenter = 0;\n node.dBaryCenter = 0;\n node.upstreamPriority = 0;\n node.downstreamPriority = 0;\n node.gridPosition = 0;\n }\n },\n _prepare: function (graph) {\n var current = [], i, l, link;\n var layerMap = new Dictionary();\n var layerCount = 0;\n var targetLayer, next, target;\n Utils.forEach(graph.nodes, function (node) {\n if (node.incoming.length === 0) {\n layerMap.set(node, 0);\n current.push(node);\n }\n });\n while (current.length > 0) {\n next = current.shift();\n for (i = 0; i < next.outgoing.length; i++) {\n link = next.outgoing[i];\n target = link.target;\n if (layerMap.containsKey(target)) {\n targetLayer = Math.max(layerMap.get(next) + 1, layerMap.get(target));\n } else {\n targetLayer = layerMap.get(next) + 1;\n }\n layerMap.set(target, targetLayer);\n if (targetLayer > layerCount) {\n layerCount = targetLayer;\n }\n if (!contains(current, target)) {\n current.push(target);\n }\n }\n }\n var sortedNodes = layerMap.keys();\n sortedNodes.sort(function (o1, o2) {\n var o1layer = layerMap.get(o1);\n var o2layer = layerMap.get(o2);\n return Utils.sign(o2layer - o1layer);\n });\n for (var n = 0; n < sortedNodes.length; ++n) {\n var node = sortedNodes[n];\n var minLayer = Number.MAX_VALUE;\n if (node.outgoing.length === 0) {\n continue;\n }\n for (l = 0; l < node.outgoing.length; ++l) {\n link = node.outgoing[l];\n minLayer = Math.min(minLayer, layerMap.get(link.target));\n }\n if (minLayer > 1) {\n layerMap.set(node, minLayer - 1);\n }\n }\n this.layers = [];\n var layer;\n for (i = 0; i < layerCount + 1; i++) {\n layer = [];\n layer.linksTo = {};\n this.layers.push(layer);\n }\n layerMap.forEach(function (node, layer) {\n node.layer = layer;\n this.layers[layer].push(node);\n }, this);\n for (l = 0; l < this.layers.length; l++) {\n layer = this.layers[l];\n for (i = 0; i < layer.length; i++) {\n layer[i].gridPosition = i;\n }\n }\n },\n layoutGraph: function (graph, options) {\n if (Utils.isUndefined(graph)) {\n throw 'No graph given or graph analysis of the diagram failed.';\n }\n if (Utils.isDefined(options)) {\n this.transferOptions(options);\n }\n this.graph = graph;\n graph.setItemIndices();\n var reversedEdges = graph.makeAcyclic();\n this._initRuntimeProperties();\n this._prepare(graph, options);\n this._dummify();\n this._optimizeCrossings();\n this._swapPairs();\n this.arrangeNodes();\n this._moveThingsAround();\n this._dedummify();\n Utils.forEach(reversedEdges, function (e) {\n if (e.points) {\n e.points.reverse();\n }\n });\n },\n setMinDist: function (m, n, minDist) {\n var l = m.layer;\n var i = m.layerIndex;\n this.minDistances[l][i] = minDist;\n },\n getMinDist: function (m, n) {\n var dist = 0, i1 = m.layerIndex, i2 = n.layerIndex, l = m.layer, min = Math.min(i1, i2), max = Math.max(i1, i2);\n for (var k = min; k < max; ++k) {\n dist += this.minDistances[l][k];\n }\n return dist;\n },\n placeLeftToRight: function (leftClasses) {\n var leftPos = new Dictionary(), n, node;\n for (var c = 0; c < this.layers.length; ++c) {\n var classNodes = leftClasses[c];\n if (!classNodes) {\n continue;\n }\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n if (!leftPos.containsKey(node)) {\n this.placeLeft(node, leftPos, c);\n }\n }\n var d = Number.POSITIVE_INFINITY;\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n var rightSibling = this.rightSibling(node);\n if (rightSibling && this.nodeLeftClass.get(rightSibling) !== c) {\n d = Math.min(d, leftPos.get(rightSibling) - leftPos.get(node) - this.getMinDist(node, rightSibling));\n }\n }\n if (d === Number.POSITIVE_INFINITY) {\n var D = [];\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n var neighbors = [];\n Utils.addRange(neighbors, this.upNodes.get(node));\n Utils.addRange(neighbors, this.downNodes.get(node));\n for (var e = 0; e < neighbors.length; e++) {\n var neighbor = neighbors[e];\n if (this.nodeLeftClass.get(neighbor) < c) {\n D.push(leftPos.get(neighbor) - leftPos.get(node));\n }\n }\n }\n D.sort();\n if (D.length === 0) {\n d = 0;\n } else if (D.length % 2 === 1) {\n d = D[this.intDiv(D.length, 2)];\n } else {\n d = (D[this.intDiv(D.length, 2) - 1] + D[this.intDiv(D.length, 2)]) / 2;\n }\n }\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n leftPos.set(node, leftPos.get(node) + d);\n }\n }\n return leftPos;\n },\n placeRightToLeft: function (rightClasses) {\n var rightPos = new Dictionary(), n, node;\n for (var c = 0; c < this.layers.length; ++c) {\n var classNodes = rightClasses[c];\n if (!classNodes) {\n continue;\n }\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n if (!rightPos.containsKey(node)) {\n this.placeRight(node, rightPos, c);\n }\n }\n var d = Number.NEGATIVE_INFINITY;\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n var leftSibling = this.leftSibling(node);\n if (leftSibling && this.nodeRightClass.get(leftSibling) !== c) {\n d = Math.max(d, rightPos.get(leftSibling) - rightPos.get(node) + this.getMinDist(leftSibling, node));\n }\n }\n if (d === Number.NEGATIVE_INFINITY) {\n var D = [];\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n var neighbors = [];\n Utils.addRange(neighbors, this.upNodes.get(node));\n Utils.addRange(neighbors, this.downNodes.get(node));\n for (var e = 0; e < neighbors.length; e++) {\n var neighbor = neighbors[e];\n if (this.nodeRightClass.get(neighbor) < c) {\n D.push(rightPos.get(node) - rightPos.get(neighbor));\n }\n }\n }\n D.sort();\n if (D.length === 0) {\n d = 0;\n } else if (D.length % 2 === 1) {\n d = D[this.intDiv(D.length, 2)];\n } else {\n d = (D[this.intDiv(D.length, 2) - 1] + D[this.intDiv(D.length, 2)]) / 2;\n }\n }\n for (n = 0; n < classNodes.length; n++) {\n node = classNodes[n];\n rightPos.set(node, rightPos.get(node) + d);\n }\n }\n return rightPos;\n },\n _getLeftWing: function () {\n var leftWing = { value: null };\n var result = this.computeClasses(leftWing, 1);\n this.nodeLeftClass = leftWing.value;\n return result;\n },\n _getRightWing: function () {\n var rightWing = { value: null };\n var result = this.computeClasses(rightWing, -1);\n this.nodeRightClass = rightWing.value;\n return result;\n },\n computeClasses: function (wingPair, d) {\n var currentWing = 0, wing = wingPair.value = new Dictionary();\n for (var l = 0; l < this.layers.length; ++l) {\n currentWing = l;\n var layer = this.layers[l];\n for (var n = d === 1 ? 0 : layer.length - 1; 0 <= n && n < layer.length; n += d) {\n var node = layer[n];\n if (!wing.containsKey(node)) {\n wing.set(node, currentWing);\n if (node.isVirtual) {\n var ndsinl = this._nodesInLink(node);\n for (var kk = 0; kk < ndsinl.length; kk++) {\n var vnode = ndsinl[kk];\n wing.set(vnode, currentWing);\n }\n }\n } else {\n currentWing = wing.get(node);\n }\n }\n }\n var wings = [];\n for (var i = 0; i < this.layers.length; i++) {\n wings.push(null);\n }\n wing.forEach(function (node, classIndex) {\n if (wings[classIndex] === null) {\n wings[classIndex] = [];\n }\n wings[classIndex].push(node);\n });\n return wings;\n },\n _isVerticalLayout: function () {\n return this.options.subtype.toLowerCase() === 'up' || this.options.subtype.toLowerCase() === 'down' || this.options.subtype.toLowerCase() === 'vertical';\n },\n _isHorizontalLayout: function () {\n return this.options.subtype.toLowerCase() === 'right' || this.options.subtype.toLowerCase() === 'left' || this.options.subtype.toLowerCase() === 'horizontal';\n },\n _isIncreasingLayout: function () {\n return this.options.subtype.toLowerCase() === 'right' || this.options.subtype.toLowerCase() === 'down';\n },\n _moveThingsAround: function () {\n var i, l, node, layer, n, w;\n for (l = 0; l < this.layers.length; ++l) {\n layer = this.layers[l];\n layer.sort(this._gridPositionComparer);\n }\n this.minDistances = [];\n for (l = 0; l < this.layers.length; ++l) {\n layer = this.layers[l];\n this.minDistances[l] = [];\n for (n = 0; n < layer.length; ++n) {\n node = layer[n];\n node.layerIndex = n;\n this.minDistances[l][n] = this.options.nodeDistance;\n if (n < layer.length - 1) {\n if (this._isVerticalLayout()) {\n this.minDistances[l][n] += (node.width + layer[n + 1].width) / 2;\n } else {\n this.minDistances[l][n] += (node.height + layer[n + 1].height) / 2;\n }\n }\n }\n }\n this.downNodes = new Dictionary();\n this.upNodes = new Dictionary();\n Utils.forEach(this.graph.nodes, function (node) {\n this.downNodes.set(node, []);\n this.upNodes.set(node, []);\n }, this);\n Utils.forEach(this.graph.links, function (link) {\n var origin = link.source;\n var dest = link.target;\n var down = null, up = null;\n if (origin.layer > dest.layer) {\n down = link.source;\n up = link.target;\n } else {\n up = link.source;\n down = link.target;\n }\n this.downNodes.get(up).push(down);\n this.upNodes.get(down).push(up);\n }, this);\n this.downNodes.forEachValue(function (list) {\n list.sort(this._gridPositionComparer);\n }, this);\n this.upNodes.forEachValue(function (list) {\n list.sort(this._gridPositionComparer);\n }, this);\n for (l = 0; l < this.layers.length - 1; ++l) {\n layer = this.layers[l];\n for (w = 0; w < layer.length - 1; w++) {\n var currentNode = layer[w];\n if (!currentNode.isVirtual) {\n continue;\n }\n var currDown = this.downNodes.get(currentNode)[0];\n if (!currDown.isVirtual) {\n continue;\n }\n for (n = w + 1; n < layer.length; ++n) {\n node = layer[n];\n if (!node.isVirtual) {\n continue;\n }\n var downNode = this.downNodes.get(node)[0];\n if (!downNode.isVirtual) {\n continue;\n }\n if (currDown.gridPosition > downNode.gridPosition) {\n var pos = currDown.gridPosition;\n currDown.gridPosition = downNode.gridPosition;\n downNode.gridPosition = pos;\n var i1 = currDown.layerIndex;\n var i2 = downNode.layerIndex;\n this.layers[l + 1][i1] = downNode;\n this.layers[l + 1][i2] = currDown;\n currDown.layerIndex = i2;\n downNode.layerIndex = i1;\n }\n }\n }\n }\n var leftClasses = this._getLeftWing();\n var rightClasses = this._getRightWing();\n var leftPos = this.placeLeftToRight(leftClasses);\n var rightPos = this.placeRightToLeft(rightClasses);\n var x = new Dictionary();\n Utils.forEach(this.graph.nodes, function (node) {\n x.set(node, (leftPos.get(node) + rightPos.get(node)) / 2);\n });\n var order = new Dictionary();\n var placed = new Dictionary();\n for (l = 0; l < this.layers.length; ++l) {\n layer = this.layers[l];\n var sequenceStart = -1, sequenceEnd = -1;\n for (n = 0; n < layer.length; ++n) {\n node = layer[n];\n order.set(node, 0);\n placed.set(node, false);\n if (node.isVirtual) {\n if (sequenceStart === -1) {\n sequenceStart = n;\n } else if (sequenceStart === n - 1) {\n sequenceStart = n;\n } else {\n sequenceEnd = n;\n order.set(layer[sequenceStart], 0);\n if (x.get(node) - x.get(layer[sequenceStart]) === this.getMinDist(layer[sequenceStart], node)) {\n placed.set(layer[sequenceStart], true);\n } else {\n placed.set(layer[sequenceStart], false);\n }\n sequenceStart = n;\n }\n }\n }\n }\n var directions = [\n 1,\n -1\n ];\n Utils.forEach(directions, function (d) {\n var start = d === 1 ? 0 : this.layers.length - 1;\n for (var l = start; 0 <= l && l < this.layers.length; l += d) {\n var layer = this.layers[l];\n var virtualStartIndex = this._firstVirtualNode(layer);\n var virtualStart = null;\n var sequence = null;\n if (virtualStartIndex !== -1) {\n virtualStart = layer[virtualStartIndex];\n sequence = [];\n for (i = 0; i < virtualStartIndex; i++) {\n sequence.push(layer[i]);\n }\n } else {\n virtualStart = null;\n sequence = layer;\n }\n if (sequence.length > 0) {\n this._sequencer(x, null, virtualStart, d, sequence);\n for (i = 0; i < sequence.length - 1; ++i) {\n this.setMinDist(sequence[i], sequence[i + 1], x.get(sequence[i + 1]) - x.get(sequence[i]));\n }\n if (virtualStart) {\n this.setMinDist(sequence[sequence.length - 1], virtualStart, x.get(virtualStart) - x.get(sequence[sequence.length - 1]));\n }\n }\n while (virtualStart) {\n var virtualEnd = this.nextVirtualNode(layer, virtualStart);\n if (!virtualEnd) {\n virtualStartIndex = virtualStart.layerIndex;\n sequence = [];\n for (i = virtualStartIndex + 1; i < layer.length; i++) {\n sequence.push(layer[i]);\n }\n if (sequence.length > 0) {\n this._sequencer(x, virtualStart, null, d, sequence);\n for (i = 0; i < sequence.length - 1; ++i) {\n this.setMinDist(sequence[i], sequence[i + 1], x.get(sequence[i + 1]) - x.get(sequence[i]));\n }\n this.setMinDist(virtualStart, sequence[0], x.get(sequence[0]) - x.get(virtualStart));\n }\n } else if (order.get(virtualStart) === d) {\n virtualStartIndex = virtualStart.layerIndex;\n var virtualEndIndex = virtualEnd.layerIndex;\n sequence = [];\n for (i = virtualStartIndex + 1; i < virtualEndIndex; i++) {\n sequence.push(layer[i]);\n }\n if (sequence.length > 0) {\n this._sequencer(x, virtualStart, virtualEnd, d, sequence);\n }\n placed.set(virtualStart, true);\n }\n virtualStart = virtualEnd;\n }\n this.adjustDirections(l, d, order, placed);\n }\n }, this);\n var fromLayerIndex = this._isIncreasingLayout() ? 0 : this.layers.length - 1;\n var reachedFinalLayerIndex = function (k, ctx) {\n if (ctx._isIncreasingLayout()) {\n return k < ctx.layers.length;\n } else {\n return k >= 0;\n }\n };\n var layerIncrement = this._isIncreasingLayout() ? +1 : -1, offset = 0;\n function maximumHeight(layer, ctx) {\n var height = Number.MIN_VALUE;\n for (var n = 0; n < layer.length; ++n) {\n var node = layer[n];\n if (ctx._isVerticalLayout()) {\n height = Math.max(height, node.height);\n } else {\n height = Math.max(height, node.width);\n }\n }\n return height;\n }\n for (i = fromLayerIndex; reachedFinalLayerIndex(i, this); i += layerIncrement) {\n layer = this.layers[i];\n var height = maximumHeight(layer, this);\n for (n = 0; n < layer.length; ++n) {\n node = layer[n];\n if (this._isVerticalLayout()) {\n node.x = x.get(node);\n node.y = offset + height / 2;\n } else {\n node.x = offset + height / 2;\n node.y = x.get(node);\n }\n }\n offset += this.options.layerSeparation + height;\n }\n },\n adjustDirections: function (l, d, order, placed) {\n if (l + d < 0 || l + d >= this.layers.length) {\n return;\n }\n var prevBridge = null, prevBridgeTarget = null;\n var layer = this.layers[l + d];\n for (var n = 0; n < layer.length; ++n) {\n var nextBridge = layer[n];\n if (nextBridge.isVirtual) {\n var nextBridgeTarget = this.getNeighborOnLayer(nextBridge, l);\n if (nextBridgeTarget.isVirtual) {\n if (prevBridge) {\n var p = placed.get(prevBridgeTarget);\n var clayer = this.layers[l];\n var i1 = prevBridgeTarget.layerIndex;\n var i2 = nextBridgeTarget.layerIndex;\n for (var i = i1 + 1; i < i2; ++i) {\n if (clayer[i].isVirtual) {\n p = p && placed.get(clayer[i]);\n }\n }\n if (p) {\n order.set(prevBridge, d);\n var j1 = prevBridge.layerIndex;\n var j2 = nextBridge.layerIndex;\n for (var j = j1 + 1; j < j2; ++j) {\n if (layer[j].isVirtual) {\n order.set(layer[j], d);\n }\n }\n }\n }\n prevBridge = nextBridge;\n prevBridgeTarget = nextBridgeTarget;\n }\n }\n }\n },\n getNeighborOnLayer: function (node, l) {\n var neighbor = this.upNodes.get(node)[0];\n if (neighbor.layer === l) {\n return neighbor;\n }\n neighbor = this.downNodes.get(node)[0];\n if (neighbor.layer === l) {\n return neighbor;\n }\n return null;\n },\n _sequencer: function (x, virtualStart, virtualEnd, dir, sequence) {\n if (sequence.length === 1) {\n this._sequenceSingle(x, virtualStart, virtualEnd, dir, sequence[0]);\n }\n if (sequence.length > 1) {\n var r = sequence.length, t = this.intDiv(r, 2);\n this._sequencer(x, virtualStart, virtualEnd, dir, sequence.slice(0, t));\n this._sequencer(x, virtualStart, virtualEnd, dir, sequence.slice(t));\n this.combineSequences(x, virtualStart, virtualEnd, dir, sequence);\n }\n },\n _sequenceSingle: function (x, virtualStart, virtualEnd, dir, node) {\n var neighbors = dir === -1 ? this.downNodes.get(node) : this.upNodes.get(node);\n var n = neighbors.length;\n if (n !== 0) {\n if (n % 2 === 1) {\n x.set(node, x.get(neighbors[this.intDiv(n, 2)]));\n } else {\n x.set(node, (x.get(neighbors[this.intDiv(n, 2) - 1]) + x.get(neighbors[this.intDiv(n, 2)])) / 2);\n }\n if (virtualStart) {\n x.set(node, Math.max(x.get(node), x.get(virtualStart) + this.getMinDist(virtualStart, node)));\n }\n if (virtualEnd) {\n x.set(node, Math.min(x.get(node), x.get(virtualEnd) - this.getMinDist(node, virtualEnd)));\n }\n }\n },\n combineSequences: function (x, virtualStart, virtualEnd, dir, sequence) {\n var r = sequence.length, t = this.intDiv(r, 2);\n var leftHeap = [], i, c, n, neighbors, neighbor, pair;\n for (i = 0; i < t; ++i) {\n c = 0;\n neighbors = dir === -1 ? this.downNodes.get(sequence[i]) : this.upNodes.get(sequence[i]);\n for (n = 0; n < neighbors.length; ++n) {\n neighbor = neighbors[n];\n if (x.get(neighbor) >= x.get(sequence[i])) {\n c++;\n } else {\n c--;\n leftHeap.push({\n k: x.get(neighbor) + this.getMinDist(sequence[i], sequence[t - 1]),\n v: 2\n });\n }\n }\n leftHeap.push({\n k: x.get(sequence[i]) + this.getMinDist(sequence[i], sequence[t - 1]),\n v: c\n });\n }\n if (virtualStart) {\n leftHeap.push({\n k: x.get(virtualStart) + this.getMinDist(virtualStart, sequence[t - 1]),\n v: Number.MAX_VALUE\n });\n }\n leftHeap.sort(this._positionDescendingComparer);\n var rightHeap = [];\n for (i = t; i < r; ++i) {\n c = 0;\n neighbors = dir === -1 ? this.downNodes.get(sequence[i]) : this.upNodes.get(sequence[i]);\n for (n = 0; n < neighbors.length; ++n) {\n neighbor = neighbors[n];\n if (x.get(neighbor) <= x.get(sequence[i])) {\n c++;\n } else {\n c--;\n rightHeap.push({\n k: x.get(neighbor) - this.getMinDist(sequence[i], sequence[t]),\n v: 2\n });\n }\n }\n rightHeap.push({\n k: x.get(sequence[i]) - this.getMinDist(sequence[i], sequence[t]),\n v: c\n });\n }\n if (virtualEnd) {\n rightHeap.push({\n k: x.get(virtualEnd) - this.getMinDist(virtualEnd, sequence[t]),\n v: Number.MAX_VALUE\n });\n }\n rightHeap.sort(this._positionAscendingComparer);\n var leftRes = 0, rightRes = 0;\n var m = this.getMinDist(sequence[t - 1], sequence[t]);\n while (x.get(sequence[t]) - x.get(sequence[t - 1]) < m) {\n if (leftRes < rightRes) {\n if (leftHeap.length === 0) {\n x.set(sequence[t - 1], x.get(sequence[t]) - m);\n break;\n } else {\n pair = leftHeap.shift();\n leftRes = leftRes + pair.v;\n x.set(sequence[t - 1], pair.k);\n x.set(sequence[t - 1], Math.max(x.get(sequence[t - 1]), x.get(sequence[t]) - m));\n }\n } else {\n if (rightHeap.length === 0) {\n x.set(sequence[t], x.get(sequence[t - 1]) + m);\n break;\n } else {\n pair = rightHeap.shift();\n rightRes = rightRes + pair.v;\n x.set(sequence[t], pair.k);\n x.set(sequence[t], Math.min(x.get(sequence[t]), x.get(sequence[t - 1]) + m));\n }\n }\n }\n for (i = t - 2; i >= 0; i--) {\n x.set(sequence[i], Math.min(x.get(sequence[i]), x.get(sequence[t - 1]) - this.getMinDist(sequence[i], sequence[t - 1])));\n }\n for (i = t + 1; i < r; i++) {\n x.set(sequence[i], Math.max(x.get(sequence[i]), x.get(sequence[t]) + this.getMinDist(sequence[i], sequence[t])));\n }\n },\n placeLeft: function (node, leftPos, leftClass) {\n var pos = Number.NEGATIVE_INFINITY;\n Utils.forEach(this._getComposite(node), function (v) {\n var leftSibling = this.leftSibling(v);\n if (leftSibling && this.nodeLeftClass.get(leftSibling) === this.nodeLeftClass.get(v)) {\n if (!leftPos.containsKey(leftSibling)) {\n this.placeLeft(leftSibling, leftPos, leftClass);\n }\n pos = Math.max(pos, leftPos.get(leftSibling) + this.getMinDist(leftSibling, v));\n }\n }, this);\n if (pos === Number.NEGATIVE_INFINITY) {\n pos = 0;\n }\n Utils.forEach(this._getComposite(node), function (v) {\n leftPos.set(v, pos);\n });\n },\n placeRight: function (node, rightPos, rightClass) {\n var pos = Number.POSITIVE_INFINITY;\n Utils.forEach(this._getComposite(node), function (v) {\n var rightSibling = this.rightSibling(v);\n if (rightSibling && this.nodeRightClass.get(rightSibling) === this.nodeRightClass.get(v)) {\n if (!rightPos.containsKey(rightSibling)) {\n this.placeRight(rightSibling, rightPos, rightClass);\n }\n pos = Math.min(pos, rightPos.get(rightSibling) - this.getMinDist(v, rightSibling));\n }\n }, this);\n if (pos === Number.POSITIVE_INFINITY) {\n pos = 0;\n }\n Utils.forEach(this._getComposite(node), function (v) {\n rightPos.set(v, pos);\n });\n },\n leftSibling: function (node) {\n var layer = this.layers[node.layer], layerIndex = node.layerIndex;\n return layerIndex === 0 ? null : layer[layerIndex - 1];\n },\n rightSibling: function (node) {\n var layer = this.layers[node.layer];\n var layerIndex = node.layerIndex;\n return layerIndex === layer.length - 1 ? null : layer[layerIndex + 1];\n },\n _getComposite: function (node) {\n return node.isVirtual ? this._nodesInLink(node) : [node];\n },\n arrangeNodes: function () {\n var i, l, ni, layer, node;\n for (l = 0; l < this.layers.length; l++) {\n layer = this.layers[l];\n for (ni = 0; ni < layer.length; ni++) {\n node = layer[ni];\n node.upstreamPriority = node.upstreamLinkCount;\n node.downstreamPriority = node.downstreamLinkCount;\n }\n }\n var maxLayoutIterations = 2;\n for (var it = 0; it < maxLayoutIterations; it++) {\n for (i = this.layers.length - 1; i >= 1; i--) {\n this.layoutLayer(false, i);\n }\n for (i = 0; i < this.layers.length - 1; i++) {\n this.layoutLayer(true, i);\n }\n }\n var gridPos = Number.MAX_VALUE;\n for (l = 0; l < this.layers.length; l++) {\n layer = this.layers[l];\n for (ni = 0; ni < layer.length; ni++) {\n node = layer[ni];\n gridPos = Math.min(gridPos, node.gridPosition);\n }\n }\n if (gridPos < 0) {\n for (l = 0; l < this.layers.length; l++) {\n layer = this.layers[l];\n for (ni = 0; ni < layer.length; ni++) {\n node = layer[ni];\n node.gridPosition = node.gridPosition - gridPos;\n }\n }\n }\n },\n layoutLayer: function (down, layer) {\n var iconsidered;\n var considered;\n if (down) {\n considered = this.layers[iconsidered = layer + 1];\n } else {\n considered = this.layers[iconsidered = layer - 1];\n }\n var sorted = [];\n for (var n = 0; n < considered.length; n++) {\n sorted.push(considered[n]);\n }\n sorted.sort(function (n1, n2) {\n var n1Priority = (n1.upstreamPriority + n1.downstreamPriority) / 2;\n var n2Priority = (n2.upstreamPriority + n2.downstreamPriority) / 2;\n if (Math.abs(n1Priority - n2Priority) < 0.0001) {\n return 0;\n }\n if (n1Priority < n2Priority) {\n return 1;\n }\n return -1;\n });\n Utils.forEach(sorted, function (node) {\n var nodeGridPos = node.gridPosition;\n var nodeBaryCenter = this.calcBaryCenter(node);\n var nodePriority = (node.upstreamPriority + node.downstreamPriority) / 2;\n if (Math.abs(nodeGridPos - nodeBaryCenter) < 0.0001) {\n return;\n }\n if (Math.abs(nodeGridPos - nodeBaryCenter) < 0.25 + 0.0001) {\n return;\n }\n if (nodeGridPos < nodeBaryCenter) {\n while (nodeGridPos < nodeBaryCenter) {\n if (!this.moveRight(node, considered, nodePriority)) {\n break;\n }\n nodeGridPos = node.gridPosition;\n }\n } else {\n while (nodeGridPos > nodeBaryCenter) {\n if (!this.moveLeft(node, considered, nodePriority)) {\n break;\n }\n nodeGridPos = node.gridPosition;\n }\n }\n }, this);\n if (iconsidered > 0) {\n this.calcDownData(iconsidered - 1);\n }\n if (iconsidered < this.layers.length - 1) {\n this.calcUpData(iconsidered + 1);\n }\n },\n moveRight: function (node, layer, priority) {\n var index = Utils.indexOf(layer, node);\n if (index === layer.length - 1) {\n node.gridPosition = node.gridPosition + 0.5;\n return true;\n }\n var rightNode = layer[index + 1];\n var rightNodePriority = (rightNode.upstreamPriority + rightNode.downstreamPriority) / 2;\n if (rightNode.gridPosition > node.gridPosition + 1) {\n node.gridPosition = node.gridPosition + 0.5;\n return true;\n }\n if (rightNodePriority > priority || Math.abs(rightNodePriority - priority) < 0.0001) {\n return false;\n }\n if (this.moveRight(rightNode, layer, priority)) {\n node.gridPosition = node.gridPosition + 0.5;\n return true;\n }\n return false;\n },\n moveLeft: function (node, layer, priority) {\n var index = Utils.indexOf(layer, node);\n if (index === 0) {\n node.gridPosition = node.gridPosition - 0.5;\n return true;\n }\n var leftNode = layer[index - 1];\n var leftNodePriority = (leftNode.upstreamPriority + leftNode.downstreamPriority) / 2;\n if (leftNode.gridPosition < node.gridPosition - 1) {\n node.gridPosition = node.gridPosition - 0.5;\n return true;\n }\n if (leftNodePriority > priority || Math.abs(leftNodePriority - priority) < 0.0001) {\n return false;\n }\n if (this.moveLeft(leftNode, layer, priority)) {\n node.gridPosition = node.gridPosition - 0.5;\n return true;\n }\n return false;\n },\n mapVirtualNode: function (node, link) {\n this.nodeToLinkMap.set(node, link);\n if (!this.linkToNodeMap.containsKey(link)) {\n this.linkToNodeMap.set(link, []);\n }\n this.linkToNodeMap.get(link).push(node);\n },\n _nodesInLink: function (node) {\n return this.linkToNodeMap.get(this.nodeToLinkMap.get(node));\n },\n _dummify: function () {\n this.linkToNodeMap = new Dictionary();\n this.nodeToLinkMap = new Dictionary();\n var layer, pos, newNode, node, r, newLink, i, l, links = this.graph.links.slice(0);\n var layers = this.layers;\n var addLinkBetweenLayers = function (upLayer, downLayer, link) {\n layers[upLayer].linksTo[downLayer] = layers[upLayer].linksTo[downLayer] || [];\n layers[upLayer].linksTo[downLayer].push(link);\n };\n for (l = 0; l < links.length; l++) {\n var link = links[l];\n var o = link.source;\n var d = link.target;\n var oLayer = o.layer;\n var dLayer = d.layer;\n var oPos = o.gridPosition;\n var dPos = d.gridPosition;\n var step = (dPos - oPos) / Math.abs(dLayer - oLayer);\n var p = o;\n if (oLayer - dLayer > 1) {\n for (i = oLayer - 1; i > dLayer; i--) {\n newNode = new Node();\n newNode.x = o.x;\n newNode.y = o.y;\n newNode.width = o.width / 100;\n newNode.height = o.height / 100;\n layer = layers[i];\n pos = (i - dLayer) * step + oPos;\n if (pos > layer.length) {\n pos = layer.length;\n }\n if (oPos >= layers[oLayer].length - 1 && dPos >= layers[dLayer].length - 1) {\n pos = layer.length;\n } else if (oPos === 0 && dPos === 0) {\n pos = 0;\n }\n newNode.layer = i;\n newNode.uBaryCenter = 0;\n newNode.dBaryCenter = 0;\n newNode.upstreamLinkCount = 0;\n newNode.downstreamLinkCount = 0;\n newNode.gridPosition = pos;\n newNode.isVirtual = true;\n Utils.insert(layer, newNode, pos);\n for (r = pos + 1; r < layer.length; r++) {\n node = layer[r];\n node.gridPosition = node.gridPosition + 1;\n }\n newLink = new Link(p, newNode);\n newLink.depthOfDumminess = 0;\n addLinkBetweenLayers(i - 1, i, newLink);\n p = newNode;\n this.graph._addNode(newNode);\n this.graph.addLink(newLink);\n newNode.index = this.graph.nodes.length - 1;\n this.mapVirtualNode(newNode, link);\n }\n addLinkBetweenLayers(dLayer - 1, dLayer, newLink);\n link.changeSource(p);\n link.depthOfDumminess = oLayer - dLayer - 1;\n } else if (oLayer - dLayer < -1) {\n for (i = oLayer + 1; i < dLayer; i++) {\n newNode = new Node();\n newNode.x = o.x;\n newNode.y = o.y;\n newNode.width = o.width / 100;\n newNode.height = o.height / 100;\n layer = layers[i];\n pos = (i - oLayer) * step + oPos;\n if (pos > layer.length) {\n pos = layer.length;\n }\n if (oPos >= layers[oLayer].length - 1 && dPos >= layers[dLayer].length - 1) {\n pos = layer.length;\n } else if (oPos === 0 && dPos === 0) {\n pos = 0;\n }\n newNode.layer = i;\n newNode.uBaryCenter = 0;\n newNode.dBaryCenter = 0;\n newNode.upstreamLinkCount = 0;\n newNode.downstreamLinkCount = 0;\n newNode.gridPosition = pos;\n newNode.isVirtual = true;\n pos &= pos;\n Utils.insert(layer, newNode, pos);\n for (r = pos + 1; r < layer.length; r++) {\n node = layer[r];\n node.gridPosition = node.gridPosition + 1;\n }\n newLink = new Link(p, newNode);\n newLink.depthOfDumminess = 0;\n addLinkBetweenLayers(i - 1, i, newLink);\n p = newNode;\n this.graph._addNode(newNode);\n this.graph.addLink(newLink);\n newNode.index = this.graph.nodes.length - 1;\n this.mapVirtualNode(newNode, link);\n }\n addLinkBetweenLayers(dLayer - 1, dLayer, link);\n link.changeSource(p);\n link.depthOfDumminess = dLayer - oLayer - 1;\n } else {\n addLinkBetweenLayers(oLayer, dLayer, link);\n }\n }\n },\n _dedummify: function () {\n var dedum = true;\n while (dedum) {\n dedum = false;\n for (var l = 0; l < this.graph.links.length; l++) {\n var link = this.graph.links[l];\n if (!link.depthOfDumminess) {\n continue;\n }\n var points = [];\n points.unshift({\n x: link.target.x,\n y: link.target.y\n });\n points.unshift({\n x: link.source.x,\n y: link.source.y\n });\n var temp = link;\n var depthOfDumminess = link.depthOfDumminess;\n for (var d = 0; d < depthOfDumminess; d++) {\n var node = temp.source;\n var prevLink = node.incoming[0];\n points.unshift({\n x: prevLink.source.x,\n y: prevLink.source.y\n });\n temp = prevLink;\n }\n link.changeSource(temp.source);\n link.depthOfDumminess = 0;\n if (points.length > 2) {\n points.splice(0, 1);\n points.splice(points.length - 1);\n link.points = points;\n } else {\n link.points = [];\n }\n dedum = true;\n break;\n }\n }\n },\n _optimizeCrossings: function () {\n var moves = -1, i;\n var maxIterations = 3;\n var iter = 0;\n while (moves !== 0) {\n if (iter++ > maxIterations) {\n break;\n }\n moves = 0;\n for (i = this.layers.length - 1; i >= 1; i--) {\n moves += this.optimizeLayerCrossings(false, i);\n }\n for (i = 0; i < this.layers.length - 1; i++) {\n moves += this.optimizeLayerCrossings(true, i);\n }\n }\n },\n calcUpData: function (layer) {\n if (layer === 0) {\n return;\n }\n var considered = this.layers[layer], i, l, link;\n var upLayer = new Set();\n var temp = this.layers[layer - 1];\n for (i = 0; i < temp.length; i++) {\n upLayer.add(temp[i]);\n }\n for (i = 0; i < considered.length; i++) {\n var node = considered[i];\n var sum = 0;\n var total = 0;\n for (l = 0; l < node.incoming.length; l++) {\n link = node.incoming[l];\n if (upLayer.contains(link.source)) {\n total++;\n sum += link.source.gridPosition;\n }\n }\n for (l = 0; l < node.outgoing.length; l++) {\n link = node.outgoing[l];\n if (upLayer.contains(link.target)) {\n total++;\n sum += link.target.gridPosition;\n }\n }\n if (total > 0) {\n node.uBaryCenter = sum / total;\n node.upstreamLinkCount = total;\n } else {\n node.uBaryCenter = i;\n node.upstreamLinkCount = 0;\n }\n }\n },\n calcDownData: function (layer) {\n if (layer === this.layers.length - 1) {\n return;\n }\n var considered = this.layers[layer], i, l, link;\n var downLayer = new Set();\n var temp = this.layers[layer + 1];\n for (i = 0; i < temp.length; i++) {\n downLayer.add(temp[i]);\n }\n for (i = 0; i < considered.length; i++) {\n var node = considered[i];\n var sum = 0;\n var total = 0;\n for (l = 0; l < node.incoming.length; l++) {\n link = node.incoming[l];\n if (downLayer.contains(link.source)) {\n total++;\n sum += link.source.gridPosition;\n }\n }\n for (l = 0; l < node.outgoing.length; l++) {\n link = node.outgoing[l];\n if (downLayer.contains(link.target)) {\n total++;\n sum += link.target.gridPosition;\n }\n }\n if (total > 0) {\n node.dBaryCenter = sum / total;\n node.downstreamLinkCount = total;\n } else {\n node.dBaryCenter = i;\n node.downstreamLinkCount = 0;\n }\n }\n },\n optimizeLayerCrossings: function (down, layer) {\n var iconsidered;\n var considered;\n if (down) {\n considered = this.layers[iconsidered = layer + 1];\n } else {\n considered = this.layers[iconsidered = layer - 1];\n }\n var presorted = considered.slice(0);\n if (down) {\n this.calcUpData(iconsidered);\n } else {\n this.calcDownData(iconsidered);\n }\n var that = this;\n considered.sort(function (n1, n2) {\n var n1BaryCenter = that.calcBaryCenter(n1), n2BaryCenter = that.calcBaryCenter(n2);\n if (Math.abs(n1BaryCenter - n2BaryCenter) < 0.0001) {\n if (n1.degree() === n2.degree()) {\n return that.compareByIndex(n1, n2);\n } else if (n1.degree() < n2.degree()) {\n return 1;\n }\n return -1;\n }\n var compareValue = (n2BaryCenter - n1BaryCenter) * 1000;\n if (compareValue > 0) {\n return -1;\n } else if (compareValue < 0) {\n return 1;\n }\n return that.compareByIndex(n1, n2);\n });\n var i, moves = 0;\n for (i = 0; i < considered.length; i++) {\n if (considered[i] !== presorted[i]) {\n moves++;\n }\n }\n if (moves > 0) {\n var inode = 0;\n for (i = 0; i < considered.length; i++) {\n var node = considered[i];\n node.gridPosition = inode++;\n }\n }\n return moves;\n },\n _swapPairs: function () {\n var maxIterations = this.options.layeredIterations;\n var iter = 0;\n while (true) {\n if (iter++ > maxIterations) {\n break;\n }\n var downwards = iter % 4 <= 1;\n var secondPass = iter % 4 === 1;\n for (var l = downwards ? 0 : this.layers.length - 1; downwards ? l <= this.layers.length - 1 : l >= 0; l += downwards ? 1 : -1) {\n var layer = this.layers[l];\n var hasSwapped = false;\n var calcCrossings = true;\n var memCrossings = 0;\n for (var n = 0; n < layer.length - 1; n++) {\n var up = 0;\n var down = 0;\n var crossBefore = 0;\n if (calcCrossings) {\n if (l !== 0) {\n up = this.countLinksCrossingBetweenTwoLayers(l - 1, l);\n }\n if (l !== this.layers.length - 1) {\n down = this.countLinksCrossingBetweenTwoLayers(l, l + 1);\n }\n if (downwards) {\n up *= 2;\n } else {\n down *= 2;\n }\n crossBefore = up + down;\n } else {\n crossBefore = memCrossings;\n }\n if (crossBefore === 0) {\n continue;\n }\n var node1 = layer[n];\n var node2 = layer[n + 1];\n var node1GridPos = node1.gridPosition;\n var node2GridPos = node2.gridPosition;\n layer[n] = node2;\n layer[n + 1] = node1;\n node1.gridPosition = node2GridPos;\n node2.gridPosition = node1GridPos;\n up = 0;\n if (l !== 0) {\n up = this.countLinksCrossingBetweenTwoLayers(l - 1, l);\n }\n down = 0;\n if (l !== this.layers.length - 1) {\n down = this.countLinksCrossingBetweenTwoLayers(l, l + 1);\n }\n if (downwards) {\n up *= 2;\n } else {\n down *= 2;\n }\n var crossAfter = up + down;\n var revert = false;\n if (secondPass) {\n revert = crossAfter >= crossBefore;\n } else {\n revert = crossAfter > crossBefore;\n }\n if (revert) {\n node1 = layer[n];\n node2 = layer[n + 1];\n node1GridPos = node1.gridPosition;\n node2GridPos = node2.gridPosition;\n layer[n] = node2;\n layer[n + 1] = node1;\n node1.gridPosition = node2GridPos;\n node2.gridPosition = node1GridPos;\n memCrossings = crossBefore;\n calcCrossings = false;\n } else {\n hasSwapped = true;\n calcCrossings = true;\n }\n }\n if (hasSwapped) {\n if (l !== this.layers.length - 1) {\n this.calcUpData(l + 1);\n }\n if (l !== 0) {\n this.calcDownData(l - 1);\n }\n }\n }\n }\n },\n countLinksCrossingBetweenTwoLayers: function (ulayer, dlayer) {\n var links = this.layers[ulayer].linksTo[dlayer];\n var link1, link2, n11, n12, n21, n22, l1, l2;\n var crossings = 0;\n var length = links.length;\n for (l1 = 0; l1 < length; l1++) {\n link1 = links[l1];\n for (l2 = l1 + 1; l2 < length; l2++) {\n link2 = links[l2];\n if (link1.target.layer === dlayer) {\n n11 = link1.source;\n n12 = link1.target;\n } else {\n n11 = link1.target;\n n12 = link1.source;\n }\n if (link2.target.layer === dlayer) {\n n21 = link2.source;\n n22 = link2.target;\n } else {\n n21 = link2.target;\n n22 = link2.source;\n }\n var n11gp = n11.gridPosition;\n var n12gp = n12.gridPosition;\n var n21gp = n21.gridPosition;\n var n22gp = n22.gridPosition;\n if ((n11gp - n21gp) * (n12gp - n22gp) < 0) {\n crossings++;\n }\n }\n }\n return crossings;\n },\n calcBaryCenter: function (node) {\n var upstreamLinkCount = node.upstreamLinkCount;\n var downstreamLinkCount = node.downstreamLinkCount;\n var uBaryCenter = node.uBaryCenter;\n var dBaryCenter = node.dBaryCenter;\n if (upstreamLinkCount > 0 && downstreamLinkCount > 0) {\n return (uBaryCenter + dBaryCenter) / 2;\n }\n if (upstreamLinkCount > 0) {\n return uBaryCenter;\n }\n if (downstreamLinkCount > 0) {\n return dBaryCenter;\n }\n return 0;\n },\n _gridPositionComparer: function (x, y) {\n if (x.gridPosition < y.gridPosition) {\n return -1;\n }\n if (x.gridPosition > y.gridPosition) {\n return 1;\n }\n return 0;\n },\n _positionAscendingComparer: function (x, y) {\n return x.k < y.k ? -1 : x.k > y.k ? 1 : 0;\n },\n _positionDescendingComparer: function (x, y) {\n return x.k < y.k ? 1 : x.k > y.k ? -1 : 0;\n },\n _firstVirtualNode: function (layer) {\n for (var c = 0; c < layer.length; c++) {\n if (layer[c].isVirtual) {\n return c;\n }\n }\n return -1;\n },\n compareByIndex: function (o1, o2) {\n var i1 = o1.index;\n var i2 = o2.index;\n if (i1 < i2) {\n return 1;\n }\n if (i1 > i2) {\n return -1;\n }\n return 0;\n },\n intDiv: function (numerator, denominator) {\n return (numerator - numerator % denominator) / denominator;\n },\n nextVirtualNode: function (layer, node) {\n var nodeIndex = node.layerIndex;\n for (var i = nodeIndex + 1; i < layer.length; ++i) {\n if (layer[i].isVirtual) {\n return layer[i];\n }\n }\n return null;\n }\n });\n var LayoutState = kendo.Class.extend({\n init: function (diagram, graphOrNodes) {\n if (Utils.isUndefined(diagram)) {\n throw 'No diagram given';\n }\n this.diagram = diagram;\n this.nodeMap = new Dictionary();\n this.linkMap = new Dictionary();\n this.capture(graphOrNodes ? graphOrNodes : diagram);\n },\n capture: function (diagramOrGraphOrNodes) {\n var node, nodes, shape, i, conn, link, links;\n if (diagramOrGraphOrNodes instanceof diagram.Graph) {\n for (i = 0; i < diagramOrGraphOrNodes.nodes.length; i++) {\n node = diagramOrGraphOrNodes.nodes[i];\n shape = node.associatedShape;\n this.nodeMap.set(shape.visual.id, new Rect(node.x, node.y, node.width, node.height));\n }\n for (i = 0; i < diagramOrGraphOrNodes.links.length; i++) {\n link = diagramOrGraphOrNodes.links[i];\n conn = link.associatedConnection;\n this.linkMap.set(conn.visual.id, link.points());\n }\n } else if (diagramOrGraphOrNodes instanceof Array) {\n nodes = diagramOrGraphOrNodes;\n for (i = 0; i < nodes.length; i++) {\n node = nodes[i];\n shape = node.associatedShape;\n if (shape) {\n this.nodeMap.set(shape.visual.id, new Rect(node.x, node.y, node.width, node.height));\n }\n }\n } else if (diagramOrGraphOrNodes.hasOwnProperty('links') && diagramOrGraphOrNodes.hasOwnProperty('nodes')) {\n nodes = diagramOrGraphOrNodes.nodes;\n links = diagramOrGraphOrNodes.links;\n for (i = 0; i < nodes.length; i++) {\n node = nodes[i];\n shape = node.associatedShape;\n if (shape) {\n this.nodeMap.set(shape.visual.id, new Rect(node.x, node.y, node.width, node.height));\n }\n }\n for (i = 0; i < links.length; i++) {\n link = links[i];\n conn = link.associatedConnection;\n if (conn) {\n this.linkMap.set(conn.visual.id, link.points);\n }\n }\n } else {\n var shapes = this.diagram.shapes;\n var connections = this.diagram.connections;\n for (i = 0; i < shapes.length; i++) {\n shape = shapes[i];\n this.nodeMap.set(shape.visual.id, shape.bounds());\n }\n for (i = 0; i < connections.length; i++) {\n conn = connections[i];\n this.linkMap.set(conn.visual.id, conn.points());\n }\n }\n }\n });\n deepExtend(diagram, {\n init: function (element) {\n kendo.init(element, diagram.ui);\n },\n SpringLayout: SpringLayout,\n TreeLayout: TreeLayout,\n GraphAdapter: DiagramToHyperTreeAdapter,\n LayeredLayout: LayeredLayout,\n LayoutBase: LayoutBase,\n LayoutState: LayoutState\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('dataviz/diagram/dom', [\n 'kendo.data',\n 'kendo.draganddrop',\n 'kendo.toolbar',\n 'kendo.editable',\n 'kendo.window',\n 'kendo.dropdownlist',\n 'kendo.dataviz.core',\n 'kendo.dataviz.themes',\n 'dataviz/diagram/svg',\n 'dataviz/diagram/services',\n 'dataviz/diagram/layout'\n ], f);\n}(function () {\n (function ($, undefined) {\n var dataviz = kendo.dataviz, draw = kendo.drawing, geom = kendo.geometry, diagram = dataviz.diagram, Widget = kendo.ui.Widget, Class = kendo.Class, proxy = $.proxy, deepExtend = kendo.deepExtend, outerWidth = kendo._outerWidth, outerHeight = kendo._outerHeight, extend = $.extend, HierarchicalDataSource = kendo.data.HierarchicalDataSource, Canvas = diagram.Canvas, Group = diagram.Group, Rectangle = diagram.Rectangle, Circle = diagram.Circle, CompositeTransform = diagram.CompositeTransform, Rect = diagram.Rect, Path = diagram.Path, DeleteShapeUnit = diagram.DeleteShapeUnit, DeleteConnectionUnit = diagram.DeleteConnectionUnit, TextBlock = diagram.TextBlock, Image = diagram.Image, Point = diagram.Point, Intersect = diagram.Intersect, ConnectionEditAdorner = diagram.ConnectionEditAdorner, UndoRedoService = diagram.UndoRedoService, ToolService = diagram.ToolService, Selector = diagram.Selector, ResizingAdorner = diagram.ResizingAdorner, ConnectorsAdorner = diagram.ConnectorsAdorner, Cursors = diagram.Cursors, Utils = diagram.Utils, Observable = kendo.Observable, ToBackUnit = diagram.ToBackUnit, ToFrontUnit = diagram.ToFrontUnit, PolylineRouter = diagram.PolylineRouter, CascadingRouter = diagram.CascadingRouter, isUndefined = Utils.isUndefined, isDefined = Utils.isDefined, defined = draw.util.defined, isArray = $.isArray, isFunction = kendo.isFunction, isString = Utils.isString, isPlainObject = $.isPlainObject, math = Math;\n var SASS_THEMES = [\n 'sass',\n 'default-v2',\n 'bootstrap-v4'\n ];\n var NS = '.kendoDiagram', CASCADING = 'cascading', ITEMBOUNDSCHANGE = 'itemBoundsChange', CHANGE = 'change', CLICK = 'click', DRAG = 'drag', DRAG_END = 'dragEnd', DRAG_START = 'dragStart', MOUSE_ENTER = 'mouseEnter', MOUSE_LEAVE = 'mouseLeave', ERROR = 'error', AUTO = 'Auto', TOP = 'Top', RIGHT = 'Right', LEFT = 'Left', BOTTOM = 'Bottom', MAXINT = 9007199254740992, SELECT = 'select', ITEMROTATE = 'itemRotate', PAN = 'pan', ZOOM_START = 'zoomStart', ZOOM_END = 'zoomEnd', NONE = 'none', DEFAULT_CANVAS_WIDTH = 600, DEFAULT_CANVAS_HEIGHT = 600, DEFAULT_SHAPE_TYPE = 'rectangle', DEFAULT_SHAPE_WIDTH = 100, DEFAULT_SHAPE_HEIGHT = 100, DEFAULT_SHAPE_MINWIDTH = 20, DEFAULT_SHAPE_MINHEIGHT = 20, DEFAULT_SHAPE_POSITION = 0, DEFAULT_CONNECTION_BACKGROUND = 'Yellow', MAX_VALUE = Number.MAX_VALUE, MIN_VALUE = -Number.MAX_VALUE, ABSOLUTE = 'absolute', TRANSFORMED = 'transformed', ROTATED = 'rotated', TRANSPARENT = 'transparent', WIDTH = 'width', HEIGHT = 'height', X = 'x', Y = 'y', MOUSEWHEEL_NS = 'DOMMouseScroll' + NS + ' mousewheel' + NS, MOBILE_ZOOM_RATE = 0.05, MOBILE_PAN_DISTANCE = 5, BUTTON_TEMPLATE = '#=text#', CONNECTION_CONTENT_OFFSET = 5;\n diagram.DefaultConnectors = [\n { name: TOP },\n { name: BOTTOM },\n { name: LEFT },\n { name: RIGHT },\n {\n name: AUTO,\n position: function (shape) {\n return shape.getPosition('center');\n }\n }\n ];\n var defaultButtons = {\n cancel: {\n text: 'Cancel',\n imageClass: 'k-i-cancel',\n className: 'k-diagram-cancel',\n iconClass: 'k-icon'\n },\n update: {\n text: 'Update',\n imageClass: 'k-i-checkmark',\n className: 'k-diagram-update',\n iconClass: 'k-icon'\n }\n };\n diagram.shapeDefaults = function (extra) {\n var defaults = {\n type: DEFAULT_SHAPE_TYPE,\n path: '',\n autoSize: true,\n visual: null,\n x: DEFAULT_SHAPE_POSITION,\n y: DEFAULT_SHAPE_POSITION,\n minWidth: DEFAULT_SHAPE_MINWIDTH,\n minHeight: DEFAULT_SHAPE_MINHEIGHT,\n width: DEFAULT_SHAPE_WIDTH,\n height: DEFAULT_SHAPE_HEIGHT,\n hover: {},\n editable: {\n connect: true,\n tools: []\n },\n connectors: diagram.DefaultConnectors,\n rotation: { angle: 0 }\n };\n Utils.simpleExtend(defaults, extra);\n return defaults;\n };\n function mwDelta(e) {\n var origEvent = e.originalEvent, delta = 0;\n if (origEvent.wheelDelta) {\n delta = -origEvent.wheelDelta / 40;\n delta = delta > 0 ? math.ceil(delta) : math.floor(delta);\n } else if (origEvent.detail) {\n delta = origEvent.detail;\n }\n return delta;\n }\n function isAutoConnector(connector) {\n return connector.options.name.toLowerCase() === AUTO.toLowerCase();\n }\n function closestConnector(point, connectors) {\n var minimumDistance = MAXINT, resCtr, connector;\n for (var i = 0; i < connectors.length; i++) {\n connector = connectors[i];\n if (!isAutoConnector(connector)) {\n var dist = point.distanceTo(connector.position());\n if (dist < minimumDistance) {\n minimumDistance = dist;\n resCtr = connector;\n }\n }\n }\n return resCtr;\n }\n function indicesOfItems(group, visuals) {\n var i, indices = [], visual;\n var children = group.drawingContainer().children;\n var length = children.length;\n for (i = 0; i < visuals.length; i++) {\n visual = visuals[i];\n for (var j = 0; j < length; j++) {\n if (children[j] == visual.drawingContainer()) {\n indices.push(j);\n break;\n }\n }\n }\n return indices;\n }\n var DiagramElement = Observable.extend({\n init: function (options) {\n var that = this;\n that.dataItem = (options || {}).dataItem;\n Observable.fn.init.call(that);\n that.options = deepExtend({ id: diagram.randomId() }, that.options, options);\n that.isSelected = false;\n that.visual = new Group({\n id: that.options.id,\n autoSize: that.options.autoSize\n });\n that.id = that.options.id;\n that._template();\n },\n options: {\n hover: {},\n cursor: Cursors.grip,\n content: { align: 'center middle' },\n selectable: true,\n serializable: true,\n enable: true\n },\n _getCursor: function (point) {\n if (this.adorner) {\n return this.adorner._getCursor(point);\n }\n return this.options.cursor;\n },\n visible: function (value) {\n if (isUndefined(value)) {\n return this.visual.visible();\n } else {\n this.visual.visible(value);\n }\n },\n bounds: function () {\n },\n refresh: function () {\n this.visual.redraw();\n },\n position: function (point) {\n this.options.x = point.x;\n this.options.y = point.y;\n this.visual.position(point);\n },\n toString: function () {\n return this.options.id;\n },\n serialize: function () {\n var json = deepExtend({}, { options: this.options });\n if (this.dataItem) {\n json.dataItem = this.dataItem.toString();\n }\n return json;\n },\n _content: function (content) {\n if (content !== undefined) {\n var options = this.options;\n if (diagram.Utils.isString(content)) {\n options.content.text = content;\n } else {\n deepExtend(options.content, content);\n }\n var contentOptions = options.content;\n var contentVisual = this._contentVisual;\n if (!contentVisual) {\n this._createContentVisual(contentOptions);\n } else {\n this._updateContentVisual(contentOptions);\n }\n }\n return this.options.content.text;\n },\n _createContentVisual: function (options) {\n if (options.text) {\n this._contentVisual = new TextBlock(options);\n this._contentVisual._includeInBBox = false;\n this.visual.append(this._contentVisual);\n }\n },\n _updateContentVisual: function (options) {\n this._contentVisual.redraw(options);\n },\n _hitTest: function (point) {\n var bounds = this.bounds();\n return this.visible() && bounds.contains(point) && this.options.enable;\n },\n _template: function () {\n var that = this;\n if (that.options.content.template) {\n var data = that.dataItem || {}, elementTemplate = kendo.template(that.options.content.template, { paramName: 'dataItem' });\n that.options.content.text = elementTemplate(data);\n }\n },\n _canSelect: function () {\n return this.options.selectable !== false;\n },\n toJSON: function () {\n return { id: this.options.id };\n }\n });\n var Connector = Class.extend({\n init: function (shape, options) {\n this.options = deepExtend({}, this.options, options);\n this.connections = [];\n this.shape = shape;\n },\n options: {\n width: 7,\n height: 7,\n fill: { color: DEFAULT_CONNECTION_BACKGROUND },\n hover: {}\n },\n position: function () {\n if (this.options.position) {\n return this.options.position(this.shape);\n } else {\n return this.shape.getPosition(this.options.name);\n }\n },\n toJSON: function () {\n return {\n shapeId: this.shape.toString(),\n connector: this.options.name\n };\n }\n });\n Connector.parse = function (diagram, str) {\n var tempStr = str.split(':'), id = tempStr[0], name = tempStr[1] || AUTO;\n for (var i = 0; i < diagram.shapes.length; i++) {\n var shape = diagram.shapes[i];\n if (shape.options.id == id) {\n return shape.getConnector(name.trim());\n }\n }\n };\n var Shape = DiagramElement.extend({\n init: function (options, diagram) {\n var that = this;\n DiagramElement.fn.init.call(that, options);\n this.diagram = diagram;\n this.updateOptionsFromModel();\n options = that.options;\n that.connectors = [];\n that.type = options.type;\n that.createShapeVisual();\n that.updateBounds();\n that.content(that.content());\n that._createConnectors();\n },\n options: diagram.shapeDefaults(),\n _setOptionsFromModel: function (model) {\n var modelOptions = filterShapeDataItem(model || this.dataItem);\n this.options = deepExtend({}, this.options, modelOptions);\n this.redrawVisual();\n },\n updateOptionsFromModel: function (model, field) {\n if (this.diagram && this.diagram._isEditable) {\n var modelOptions = filterShapeDataItem(model || this.dataItem);\n if (model && field) {\n if (!dataviz.inArray(field, [\n 'x',\n 'y',\n 'width',\n 'height'\n ])) {\n if (this.options.visual) {\n this._redrawVisual();\n } else if (modelOptions.type) {\n this.options = deepExtend({}, this.options, modelOptions);\n this._redrawVisual();\n }\n if (this.options.content) {\n this._template();\n this.content(this.options.content);\n }\n } else {\n var bounds = this.bounds();\n bounds[field] = model[field];\n this.bounds(bounds);\n }\n } else {\n this.options = deepExtend({}, this.options, modelOptions);\n }\n }\n },\n _redrawVisual: function () {\n this.visual.clear();\n this._contentVisual = null;\n this.options.dataItem = this.dataItem;\n this.createShapeVisual();\n this.updateBounds();\n },\n redrawVisual: function () {\n this._redrawVisual();\n if (this.options.content) {\n this._template();\n this.content(this.options.content);\n }\n },\n updateModel: function (syncChanges) {\n var diagram = this.diagram;\n if (diagram && diagram._isEditable) {\n var bounds = this._bounds;\n var model = this.dataItem;\n if (model) {\n diagram._suspendModelRefresh();\n if (defined(model.x) && bounds.x !== model.x) {\n model.set('x', bounds.x);\n }\n if (defined(model.y) && bounds.y !== model.y) {\n model.set('y', bounds.y);\n }\n if (defined(model.width) && bounds.width !== model.width) {\n model.set('width', bounds.width);\n }\n if (defined(model.height) && bounds.height !== model.height) {\n model.set('height', bounds.height);\n }\n this.dataItem = model;\n diagram._resumeModelRefresh();\n if (syncChanges) {\n diagram._syncShapeChanges();\n }\n }\n }\n },\n updateBounds: function () {\n var bounds = this.visual._measure(true);\n var options = this.options;\n this.bounds(new Rect(options.x, options.y, bounds.width, bounds.height));\n this._rotate();\n this._alignContent();\n },\n content: function (content) {\n var result = this._content(content);\n this._alignContent();\n return result;\n },\n _alignContent: function () {\n var contentOptions = this.options.content || {};\n var contentVisual = this._contentVisual;\n if (contentVisual && contentOptions.align) {\n var containerRect = this.visual._measure();\n var aligner = new diagram.RectAlign(containerRect);\n var contentBounds = contentVisual.drawingElement.bbox(null);\n var contentRect = new Rect(0, 0, contentBounds.width(), contentBounds.height());\n var alignedBounds = aligner.align(contentRect, contentOptions.align);\n contentVisual.position(alignedBounds.topLeft());\n }\n },\n _createConnectors: function () {\n var options = this.options, length = options.connectors.length, connectorDefaults = options.connectorDefaults, connector, i;\n for (i = 0; i < length; i++) {\n connector = new Connector(this, deepExtend({}, connectorDefaults, options.connectors[i]));\n this.connectors.push(connector);\n }\n },\n bounds: function (value) {\n var bounds;\n if (value) {\n if (isString(value)) {\n switch (value) {\n case TRANSFORMED:\n bounds = this._transformedBounds();\n break;\n case ABSOLUTE:\n bounds = this._transformedBounds();\n var pan = this.diagram._pan;\n bounds.x += pan.x;\n bounds.y += pan.y;\n break;\n case ROTATED:\n bounds = this._rotatedBounds();\n break;\n default:\n bounds = this._bounds;\n }\n } else {\n this._setBounds(value);\n this._triggerBoundsChange();\n if (!(this.diagram && this.diagram._layouting)) {\n this.refreshConnections();\n }\n }\n } else {\n bounds = this._bounds;\n }\n return bounds;\n },\n _setBounds: function (rect) {\n var options = this.options;\n var topLeft = rect.topLeft();\n var x = options.x = topLeft.x;\n var y = options.y = topLeft.y;\n var width = options.width = math.max(rect.width, options.minWidth);\n var height = options.height = math.max(rect.height, options.minHeight);\n this._bounds = new Rect(x, y, width, height);\n this.visual.redraw({\n x: x,\n y: y,\n width: width,\n height: height\n });\n },\n position: function (point) {\n if (point) {\n this.bounds(new Rect(point.x, point.y, this._bounds.width, this._bounds.height));\n } else {\n return this._bounds.topLeft();\n }\n },\n clone: function () {\n var json = this.serialize();\n json.options.id = diagram.randomId();\n if (this.diagram && this.diagram._isEditable && defined(this.dataItem)) {\n json.options.dataItem = cloneDataItem(this.dataItem);\n }\n return new Shape(json.options);\n },\n select: function (value) {\n var diagram = this.diagram, selected, deselected;\n if (isUndefined(value)) {\n value = true;\n }\n if (this._canSelect()) {\n if (this.isSelected != value) {\n selected = [];\n deselected = [];\n this.isSelected = value;\n if (this.isSelected) {\n diagram._selectedItems.push(this);\n selected.push(this);\n } else {\n Utils.remove(diagram._selectedItems, this);\n deselected.push(this);\n }\n if (!diagram._internalSelection) {\n diagram._selectionChanged(selected, deselected);\n }\n return true;\n }\n }\n },\n rotate: function (angle, center, undoable) {\n var rotate = this.visual.rotate();\n if (angle !== undefined) {\n if (undoable !== false && this.diagram && this.diagram.undoRedoService && angle !== rotate.angle) {\n this.diagram.undoRedoService.add(new diagram.RotateUnit(this.diagram._resizingAdorner, [this], [rotate.angle]), false);\n }\n var b = this.bounds(), sc = new Point(b.width / 2, b.height / 2), deltaAngle, newPosition;\n if (center) {\n deltaAngle = angle - rotate.angle;\n newPosition = b.center().rotate(center, 360 - deltaAngle).minus(sc);\n this._rotationOffset = this._rotationOffset.plus(newPosition.minus(b.topLeft()));\n this.position(newPosition);\n }\n this.visual.rotate(angle, sc);\n this.options.rotation.angle = angle;\n if (this.diagram && this.diagram._connectorsAdorner) {\n this.diagram._connectorsAdorner.refresh();\n }\n this.refreshConnections();\n if (this.diagram) {\n this.diagram.trigger(ITEMROTATE, { item: this });\n }\n }\n return rotate;\n },\n connections: function (type) {\n var result = [], i, j, con, cons, ctr;\n for (i = 0; i < this.connectors.length; i++) {\n ctr = this.connectors[i];\n cons = ctr.connections;\n for (j = 0, cons; j < cons.length; j++) {\n con = cons[j];\n if (type == 'out') {\n var source = con.source();\n if (source.shape && source.shape == this) {\n result.push(con);\n }\n } else if (type == 'in') {\n var target = con.target();\n if (target.shape && target.shape == this) {\n result.push(con);\n }\n } else {\n result.push(con);\n }\n }\n }\n return result;\n },\n refreshConnections: function () {\n $.each(this.connections(), function () {\n this.refresh();\n });\n },\n getConnector: function (nameOrPoint) {\n var i, ctr;\n if (isString(nameOrPoint)) {\n nameOrPoint = nameOrPoint.toLocaleLowerCase();\n for (i = 0; i < this.connectors.length; i++) {\n ctr = this.connectors[i];\n if (ctr.options.name.toLocaleLowerCase() == nameOrPoint) {\n return ctr;\n }\n }\n } else if (nameOrPoint instanceof Point) {\n return closestConnector(nameOrPoint, this.connectors);\n } else {\n return this.connectors.length ? this.connectors[0] : null;\n }\n },\n getPosition: function (side) {\n var b = this.bounds(), fnName = side.charAt(0).toLowerCase() + side.slice(1);\n if (isFunction(b[fnName])) {\n return this._transformPoint(b[fnName]());\n }\n return b.center();\n },\n redraw: function (options) {\n if (options) {\n var shapeOptions = this.options;\n var boundsChange;\n this.shapeVisual.redraw(this._visualOptions(options));\n if (this._diffNumericOptions(options, [\n WIDTH,\n HEIGHT,\n X,\n Y\n ])) {\n this.bounds(new Rect(shapeOptions.x, shapeOptions.y, shapeOptions.width, shapeOptions.height));\n boundsChange = true;\n }\n if (options.connectors) {\n shapeOptions.connectors = options.connectors;\n this._updateConnectors();\n }\n shapeOptions = deepExtend(shapeOptions, options);\n if (options.rotation || boundsChange) {\n this._rotate();\n }\n if (shapeOptions.content) {\n this.content(shapeOptions.content);\n }\n }\n },\n _updateConnectors: function () {\n var connections = this.connections();\n this.connectors = [];\n this._createConnectors();\n var connection;\n var source;\n var target;\n for (var idx = 0; idx < connections.length; idx++) {\n connection = connections[idx];\n source = connection.source();\n target = connection.target();\n if (source.shape && source.shape === this) {\n connection.source(this.getConnector(source.options.name) || null);\n } else if (target.shape && target.shape === this) {\n connection.target(this.getConnector(target.options.name) || null);\n }\n connection.updateModel();\n }\n },\n _diffNumericOptions: diagram.diffNumericOptions,\n _visualOptions: function (options) {\n return {\n data: options.path,\n source: options.source,\n hover: options.hover,\n fill: options.fill,\n stroke: options.stroke\n };\n },\n _triggerBoundsChange: function () {\n if (this.diagram) {\n this.diagram.trigger(ITEMBOUNDSCHANGE, {\n item: this,\n bounds: this._bounds.clone()\n });\n }\n },\n _transformPoint: function (point) {\n var rotate = this.rotate(), bounds = this.bounds(), tl = bounds.topLeft();\n if (rotate.angle) {\n point.rotate(rotate.center().plus(tl), 360 - rotate.angle);\n }\n return point;\n },\n _transformedBounds: function () {\n var bounds = this.bounds(), tl = bounds.topLeft(), br = bounds.bottomRight();\n return Rect.fromPoints(this.diagram.modelToView(tl), this.diagram.modelToView(br));\n },\n _rotatedBounds: function () {\n var bounds = this.bounds().rotatedBounds(this.rotate().angle), tl = bounds.topLeft(), br = bounds.bottomRight();\n return Rect.fromPoints(tl, br);\n },\n _rotate: function () {\n var rotation = this.options.rotation;\n if (rotation && rotation.angle) {\n this.rotate(rotation.angle);\n }\n this._rotationOffset = new Point();\n },\n _hover: function (value) {\n var options = this.options, hover = options.hover, stroke = options.stroke, fill = options.fill;\n if (value && isDefined(hover.stroke)) {\n stroke = deepExtend({}, stroke, hover.stroke);\n }\n if (value && isDefined(hover.fill)) {\n fill = hover.fill;\n }\n this.shapeVisual.redraw({\n stroke: stroke,\n fill: fill\n });\n if (options.editable && options.editable.connect) {\n this.diagram._showConnectors(this, value);\n }\n },\n _hitTest: function (value) {\n if (this.visible()) {\n var bounds = this.bounds(), rotatedPoint, angle = this.rotate().angle;\n if (value.isEmpty && !value.isEmpty()) {\n return Intersect.rects(value, bounds, angle ? angle : 0);\n } else {\n rotatedPoint = value.clone().rotate(bounds.center(), angle);\n if (bounds.contains(rotatedPoint)) {\n return this;\n }\n }\n }\n },\n toJSON: function () {\n return { shapeId: this.options.id };\n },\n createShapeVisual: function () {\n var options = this.options;\n var visualOptions = this._visualOptions(options);\n var visualTemplate = options.visual;\n var type = (options.type + '').toLocaleLowerCase();\n var shapeVisual;\n visualOptions.width = options.width;\n visualOptions.height = options.height;\n if (isFunction(visualTemplate)) {\n shapeVisual = visualTemplate.call(this, options);\n } else if (visualOptions.data) {\n shapeVisual = new Path(visualOptions);\n translateToOrigin(shapeVisual);\n } else if (type == 'rectangle') {\n shapeVisual = new Rectangle(visualOptions);\n } else if (type == 'circle') {\n shapeVisual = new Circle(visualOptions);\n } else if (type == 'text') {\n shapeVisual = new TextBlock(visualOptions);\n } else if (type == 'image') {\n shapeVisual = new Image(visualOptions);\n } else {\n shapeVisual = new Path(visualOptions);\n }\n this.shapeVisual = shapeVisual;\n this.visual.append(this.shapeVisual);\n }\n });\n var Connection = DiagramElement.extend({\n init: function (from, to, options) {\n var that = this;\n DiagramElement.fn.init.call(that, options);\n this.updateOptionsFromModel();\n this._initRouter();\n that.path = new diagram.Polyline(that.options);\n that.path.fill(TRANSPARENT);\n that.visual.append(that.path);\n that._sourcePoint = that._targetPoint = new Point();\n that._setSource(from);\n that._setTarget(to);\n that.content(that.options.content);\n that.definers = [];\n if (defined(options) && options.points) {\n that.points(options.points);\n }\n },\n options: {\n hover: { stroke: {} },\n startCap: NONE,\n endCap: NONE,\n points: [],\n selectable: true,\n fromConnector: AUTO,\n toConnector: AUTO\n },\n _setOptionsFromModel: function (model) {\n this.updateOptionsFromModel(model || this.dataItem);\n },\n updateOptionsFromModel: function (model) {\n if (this.diagram && this.diagram._isEditable) {\n var dataMap = this.diagram._dataMap;\n var options = filterConnectionDataItem(model || this.dataItem);\n if (model) {\n if (defined(options.from)) {\n var from = dataMap[options.from];\n if (from && defined(options.fromConnector)) {\n from = from.getConnector(options.fromConnector);\n }\n this.source(from);\n } else if (defined(options.fromX) && defined(options.fromY)) {\n this.source(new Point(options.fromX, options.fromY));\n }\n if (defined(options.to)) {\n var to = dataMap[options.to];\n if (to && defined(options.toConnector)) {\n to = to.getConnector(options.toConnector);\n }\n this.target(to);\n } else if (defined(options.toX) && defined(options.toY)) {\n this.target(new Point(options.toX, options.toY));\n }\n if (defined(options.type) && this.type() !== options.type) {\n this.points([]);\n this.type(options.type);\n }\n this.dataItem = model;\n this._template();\n this.redraw(this.options);\n } else {\n this.options = deepExtend({}, options, this.options);\n }\n }\n },\n updateModel: function (syncChanges) {\n if (this.diagram && this.diagram._isEditable) {\n if (this.diagram.connectionsDataSource) {\n var model = this.diagram.connectionsDataSource.getByUid(this.dataItem.uid);\n if (model) {\n this.diagram._suspendModelRefresh();\n if (defined(this.options.fromX) && this.options.fromX !== null) {\n clearField('from', model);\n clearField('fromConnector', model);\n model.set('fromX', this.options.fromX);\n model.set('fromY', this.options.fromY);\n } else {\n model.set('from', this.options.from);\n if (defined(model.fromConnector)) {\n model.set('fromConnector', this.sourceConnector ? this.sourceConnector.options.name : null);\n }\n clearField('fromX', model);\n clearField('fromY', model);\n }\n if (defined(this.options.toX) && this.options.toX !== null) {\n clearField('to', model);\n clearField('toConnector', model);\n model.set('toX', this.options.toX);\n model.set('toY', this.options.toY);\n } else {\n model.set('to', this.options.to);\n if (defined(model.toConnector)) {\n model.set('toConnector', this.targetConnector ? this.targetConnector.options.name : null);\n }\n clearField('toX', model);\n clearField('toY', model);\n }\n if (defined(this.options.type) && defined(model.type)) {\n model.set('type', this.options.type);\n }\n this.dataItem = model;\n this.diagram._resumeModelRefresh();\n if (syncChanges) {\n this.diagram._syncConnectionChanges();\n }\n }\n }\n }\n },\n sourcePoint: function () {\n return this._resolvedSourceConnector ? this._resolvedSourceConnector.position() : this._sourcePoint;\n },\n _setSource: function (source) {\n var shapeSource = source instanceof Shape;\n var defaultConnector = this.options.fromConnector || AUTO;\n var dataItem;\n if (shapeSource && !source.getConnector(defaultConnector)) {\n return;\n }\n if (source !== undefined) {\n this.from = source;\n }\n this._removeFromSourceConnector();\n if (source === null) {\n if (this.sourceConnector) {\n this._sourcePoint = (this._resolvedSourceConnector || this.sourceConnector).position();\n this._clearSourceConnector();\n this._setFromOptions(null, this._sourcePoint);\n }\n } else if (source instanceof Connector) {\n dataItem = source.shape.dataItem;\n if (dataItem) {\n this._setFromOptions(dataItem.id);\n }\n this.sourceConnector = source;\n this.sourceConnector.connections.push(this);\n } else if (source instanceof Point) {\n this._setFromOptions(null, source);\n this._sourcePoint = source;\n if (this.sourceConnector) {\n this._clearSourceConnector();\n }\n } else if (shapeSource) {\n dataItem = source.dataItem;\n if (dataItem) {\n this._setFromOptions(dataItem.id);\n }\n this.sourceConnector = source.getConnector(defaultConnector);\n this.sourceConnector.connections.push(this);\n }\n },\n source: function (source, undoable) {\n if (isDefined(source)) {\n if (undoable && this.diagram) {\n this.diagram.undoRedoService.addCompositeItem(new diagram.ConnectionEditUnit(this, source));\n }\n this._setSource(source);\n this.refresh();\n }\n return this.sourceConnector ? this.sourceConnector : this._sourcePoint;\n },\n _setFromOptions: function (from, fromPoint) {\n this.options.from = from;\n if (fromPoint) {\n this.options.fromX = fromPoint.x;\n this.options.fromY = fromPoint.y;\n } else {\n this.options.fromX = null;\n this.options.fromY = null;\n }\n },\n sourceDefiner: function (value) {\n if (value) {\n if (value instanceof diagram.PathDefiner) {\n value.left = null;\n this._sourceDefiner = value;\n this.source(value.point);\n } else {\n throw 'The sourceDefiner needs to be a PathDefiner.';\n }\n } else {\n if (!this._sourceDefiner) {\n this._sourceDefiner = new diagram.PathDefiner(this.sourcePoint(), null, null);\n }\n return this._sourceDefiner;\n }\n },\n targetPoint: function () {\n return this._resolvedTargetConnector ? this._resolvedTargetConnector.position() : this._targetPoint;\n },\n _setTarget: function (target) {\n var shapeTarget = target instanceof Shape;\n var defaultConnector = this.options.toConnector || AUTO;\n var dataItem;\n if (shapeTarget && !target.getConnector(defaultConnector)) {\n return;\n }\n if (target !== undefined) {\n this.to = target;\n }\n this._removeFromTargetConnector();\n if (target === null) {\n if (this.targetConnector) {\n this._targetPoint = (this._resolvedTargetConnector || this.targetConnector).position();\n this._clearTargetConnector();\n this._setToOptions(null, this._targetPoint);\n }\n } else if (target instanceof Connector) {\n dataItem = target.shape.dataItem;\n if (dataItem) {\n this._setToOptions(dataItem.id);\n }\n this.targetConnector = target;\n this.targetConnector.connections.push(this);\n } else if (target instanceof Point) {\n this._setToOptions(null, target);\n this._targetPoint = target;\n if (this.targetConnector) {\n this._clearTargetConnector();\n }\n } else if (shapeTarget) {\n dataItem = target.dataItem;\n if (dataItem) {\n this._setToOptions(dataItem.id);\n }\n this.targetConnector = target.getConnector(defaultConnector);\n this.targetConnector.connections.push(this);\n }\n },\n target: function (target, undoable) {\n if (isDefined(target)) {\n if (undoable && this.diagram) {\n this.diagram.undoRedoService.addCompositeItem(new diagram.ConnectionEditUnit(this, undefined, target));\n }\n this._setTarget(target);\n this.refresh();\n }\n return this.targetConnector ? this.targetConnector : this._targetPoint;\n },\n _setToOptions: function (to, toPoint) {\n this.options.to = to;\n if (toPoint) {\n this.options.toX = toPoint.x;\n this.options.toY = toPoint.y;\n } else {\n this.options.toX = null;\n this.options.toY = null;\n }\n },\n targetDefiner: function (value) {\n if (value) {\n if (value instanceof diagram.PathDefiner) {\n value.right = null;\n this._targetDefiner = value;\n this.target(value.point);\n } else {\n throw 'The sourceDefiner needs to be a PathDefiner.';\n }\n } else {\n if (!this._targetDefiner) {\n this._targetDefiner = new diagram.PathDefiner(this.targetPoint(), null, null);\n }\n return this._targetDefiner;\n }\n },\n _updateConnectors: function () {\n this._updateConnector(this.source(), 'source');\n this._updateConnector(this.target(), 'target');\n },\n _updateConnector: function (instance, name) {\n var that = this;\n var diagram = that.diagram;\n if (instance instanceof Connector && !diagram.getShapeById(instance.shape.id)) {\n var dataItem = instance.shape.dataItem;\n var connectorName = instance.options.name;\n var setNewTarget = function () {\n var shape = diagram._dataMap[dataItem.id];\n instance = shape.getConnector(connectorName);\n that[name](instance, false);\n that.updateModel();\n };\n if (diagram._dataMap[dataItem.id]) {\n setNewTarget();\n } else {\n var inactiveItem = diagram._inactiveShapeItems.getByUid(dataItem.uid);\n if (inactiveItem) {\n diagram._deferredConnectionUpdates.push(inactiveItem.onActivate(setNewTarget));\n }\n }\n } else {\n that[name](instance, false);\n }\n },\n content: function (content) {\n var result = this._content(content);\n if (defined(content)) {\n this._alignContent();\n }\n return result;\n },\n _createContentVisual: function (options) {\n var visual;\n if (isFunction(options.visual)) {\n visual = options.visual.call(this, options);\n } else if (options.text) {\n visual = new TextBlock(options);\n }\n if (visual) {\n this._contentVisual = visual;\n visual._includeInBBox = false;\n this.visual.append(visual);\n }\n return visual;\n },\n _updateContentVisual: function (options) {\n if (isFunction(options.visual)) {\n this.visual.remove(this._contentVisual);\n this._createContentVisual(options);\n } else {\n this._contentVisual.redraw(options);\n }\n },\n _alignContent: function () {\n if (this._contentVisual) {\n var offset = CONNECTION_CONTENT_OFFSET;\n var points = this.allPoints();\n var endIdx = math.floor(points.length / 2);\n var startIdx = endIdx - 1;\n while (startIdx > 0 && points[startIdx].equals(points[endIdx])) {\n startIdx--;\n endIdx++;\n }\n var endPoint = points[endIdx];\n var startPoint = points[startIdx];\n var boundingBox = this._contentVisual._measure();\n var width = boundingBox.width;\n var height = boundingBox.height;\n var alignToPath = points.length % 2 === 0;\n var distance = startPoint.distanceTo(endPoint);\n if (alignToPath && points.length > 2 && distance > 0 && (startPoint.y === endPoint.y && distance < width || startPoint.x === endPoint.x && distance < height)) {\n alignToPath = false;\n offset = 0;\n }\n var point;\n if (alignToPath) {\n var angle = draw.util.deg(math.atan2(endPoint.y - startPoint.y, endPoint.x - startPoint.x));\n point = new Point((endPoint.x - startPoint.x) / 2 + startPoint.x, (endPoint.y - startPoint.y) / 2 + startPoint.y);\n if (math.abs(angle) === 90) {\n point.x += offset;\n point.y -= height / 2;\n } else if (angle % 180 === 0) {\n point.x -= width / 2;\n point.y -= height + offset;\n } else if (angle < -90 || 0 < angle && angle < 90) {\n point.y -= height;\n } else if (angle < 0 || angle > 90) {\n point.x -= width;\n point.y -= height;\n }\n } else {\n var midIdx = math.floor(points.length / 2);\n point = points[midIdx].clone();\n startPoint = points[midIdx - 1];\n endPoint = points[midIdx + 1];\n var offsetX = startPoint.x <= point.x && endPoint.x <= point.x ? offset : -boundingBox.width - offset;\n var offsetY = startPoint.y <= point.y && endPoint.y <= point.y ? offset : -boundingBox.height - offset;\n point.x += offsetX;\n point.y += offsetY;\n }\n this._contentVisual.position(point);\n }\n },\n select: function (value) {\n var diagram = this.diagram, selected, deselected;\n if (this._canSelect()) {\n if (this.isSelected !== value) {\n this.isSelected = value;\n selected = [];\n deselected = [];\n if (this.isSelected) {\n this.adorner = new ConnectionEditAdorner(this, this.options.selection);\n diagram._adorn(this.adorner, true);\n diagram._selectedItems.push(this);\n selected.push(this);\n } else {\n if (this.adorner) {\n diagram._adorn(this.adorner, false);\n Utils.remove(diagram._selectedItems, this);\n this.adorner = undefined;\n deselected.push(this);\n }\n }\n if (this.adorner) {\n this.adorner.refresh();\n }\n if (!diagram._internalSelection) {\n diagram._selectionChanged(selected, deselected);\n }\n return true;\n }\n }\n },\n bounds: function (value) {\n if (value && !isString(value)) {\n this._bounds = value;\n } else {\n return this._bounds;\n }\n },\n type: function (value) {\n var options = this.options;\n if (value) {\n if (value !== options.type) {\n options.type = value;\n this._initRouter();\n this.refresh();\n }\n } else {\n return options.type;\n }\n },\n _initRouter: function () {\n var type = (this.options.type || '').toLowerCase();\n if (type == CASCADING) {\n this._router = new CascadingRouter(this);\n } else {\n this._router = new PolylineRouter(this);\n }\n },\n points: function (value) {\n if (value) {\n this.definers = [];\n for (var i = 0; i < value.length; i++) {\n var definition = value[i];\n if (definition instanceof diagram.Point) {\n this.definers.push(new diagram.PathDefiner(definition));\n } else if (definition.hasOwnProperty('x') && definition.hasOwnProperty('y')) {\n this.definers.push(new diagram.PathDefiner(new Point(definition.x, definition.y)));\n } else {\n throw 'A Connection point needs to be a Point or an object with x and y properties.';\n }\n }\n } else {\n var pts = [];\n if (isDefined(this.definers)) {\n for (var k = 0; k < this.definers.length; k++) {\n pts.push(this.definers[k].point);\n }\n }\n return pts;\n }\n },\n allPoints: function () {\n var pts = [this.sourcePoint()];\n if (this.definers) {\n for (var k = 0; k < this.definers.length; k++) {\n pts.push(this.definers[k].point);\n }\n }\n pts.push(this.targetPoint());\n return pts;\n },\n refresh: function () {\n this._resolveConnectors();\n this._refreshPath();\n this._alignContent();\n if (this.adorner) {\n this.adorner.refresh();\n }\n },\n _resolveConnectors: function () {\n var connection = this, sourcePoint, targetPoint, sourceConnectors, targetConnectors, source = connection.source(), target = connection.target();\n if (source instanceof Point) {\n sourcePoint = source;\n } else if (source instanceof Connector) {\n if (isAutoConnector(source)) {\n sourceConnectors = source.shape.connectors;\n } else {\n sourceConnectors = [source];\n }\n }\n if (target instanceof Point) {\n targetPoint = target;\n } else if (target instanceof Connector) {\n if (isAutoConnector(target)) {\n targetConnectors = target.shape.connectors;\n } else {\n targetConnectors = [target];\n }\n }\n if (sourcePoint) {\n if (targetConnectors) {\n connection._resolvedTargetConnector = closestConnector(sourcePoint, targetConnectors);\n }\n } else if (sourceConnectors) {\n if (targetPoint) {\n connection._resolvedSourceConnector = closestConnector(targetPoint, sourceConnectors);\n } else if (targetConnectors) {\n this._resolveAutoConnectors(sourceConnectors, targetConnectors);\n }\n }\n },\n _resolveAutoConnectors: function (sourceConnectors, targetConnectors) {\n var minNonConflict = MAXINT;\n var minDist = MAXINT;\n var minNonConflictSource, minNonConflictTarget;\n var sourcePoint, targetPoint;\n var minSource, minTarget;\n var sourceConnector, targetConnector;\n var sourceIdx, targetIdx;\n var dist;\n for (sourceIdx = 0; sourceIdx < sourceConnectors.length; sourceIdx++) {\n sourceConnector = sourceConnectors[sourceIdx];\n if (!isAutoConnector(sourceConnector)) {\n sourcePoint = sourceConnector.position();\n for (targetIdx = 0; targetIdx < targetConnectors.length; targetIdx++) {\n targetConnector = targetConnectors[targetIdx];\n if (!isAutoConnector(targetConnector)) {\n targetPoint = targetConnector.position();\n dist = math.round(sourcePoint.distanceTo(targetPoint));\n if (dist < minNonConflict && this.diagram && this._testRoutePoints(sourcePoint, targetPoint, sourceConnector, targetConnector)) {\n minNonConflict = dist;\n minNonConflictSource = sourceConnector;\n minNonConflictTarget = targetConnector;\n }\n if (dist < minDist) {\n minSource = sourceConnector;\n minTarget = targetConnector;\n minDist = dist;\n }\n }\n }\n }\n }\n if (minNonConflictSource) {\n minSource = minNonConflictSource;\n minTarget = minNonConflictTarget;\n }\n this._resolvedSourceConnector = minSource;\n this._resolvedTargetConnector = minTarget;\n },\n _testRoutePoints: function (sourcePoint, targetPoint, sourceConnector, targetConnector) {\n var router = this._router;\n var passRoute = true;\n if (router instanceof CascadingRouter) {\n var points = router.routePoints(sourcePoint, targetPoint, sourceConnector, targetConnector), start, end, rect, exclude;\n exclude = this._getRouteExclude(sourcePoint, targetPoint, sourceConnector.shape, targetConnector.shape);\n points.unshift(sourcePoint);\n points.push(targetPoint);\n for (var idx = 1; idx < points.length; idx++) {\n start = points[idx - 1];\n end = points[idx];\n rect = new Rect(math.min(start.x, end.x), math.min(start.y, end.y), math.abs(start.x - end.x), math.abs(start.y - end.y));\n if (rect.width > 0) {\n rect.x++;\n rect.width -= 2;\n }\n if (rect.height > 0) {\n rect.y++;\n rect.height -= 2;\n }\n if (!rect.isEmpty() && this.diagram._shapesQuadTree.hitTestRect(rect, exclude)) {\n passRoute = false;\n break;\n }\n }\n }\n return passRoute;\n },\n _getRouteExclude: function (sourcePoint, targetPoint, sourceShape, targetShape) {\n var exclude = [];\n if (this._isPointInsideShape(sourcePoint, sourceShape)) {\n exclude.push(sourceShape);\n }\n if (this._isPointInsideShape(targetPoint, targetShape)) {\n exclude.push(targetShape);\n }\n return exclude;\n },\n _isPointInsideShape: function (point, shape) {\n var bounds = shape.bounds(), rotatedPoint, angle = shape.rotate().angle, pointX, pointY, boundsX = bounds.x, boundsY = bounds.y;\n rotatedPoint = point.clone().rotate(bounds.center(), angle);\n pointX = rotatedPoint.x;\n pointY = rotatedPoint.y;\n return pointX > boundsX && pointX < boundsX + bounds.width && pointY > boundsY && pointY < boundsY + bounds.height;\n },\n redraw: function (options) {\n if (options) {\n this.options = deepExtend({}, this.options, options);\n var points = this.options.points;\n if (defined(points) && points.length > 0) {\n this.points(points);\n this._refreshPath();\n }\n if (options && options.content || options.text) {\n this.content(options.content);\n }\n this.path.redraw({\n fill: options.fill,\n stroke: options.stroke,\n startCap: options.startCap,\n endCap: options.endCap\n });\n }\n },\n clone: function () {\n var json = this.serialize();\n if (this.diagram && this.diagram._isEditable && defined(this.dataItem)) {\n json.options.dataItem = cloneDataItem(this.dataItem);\n }\n return new Connection(this.from, this.to, json.options);\n },\n serialize: function () {\n var from = this.from.toJSON ? this.from.toJSON : this.from.toString(), to = this.to.toJSON ? this.to.toJSON : this.to.toString();\n var json = deepExtend({}, {\n options: this.options,\n from: from,\n to: to\n });\n if (defined(this.dataItem)) {\n json.dataItem = this.dataItem.toString();\n }\n json.options.points = this.points();\n return json;\n },\n _hitTest: function (value) {\n if (this.visible()) {\n var p = new Point(value.x, value.y), from = this.sourcePoint(), to = this.targetPoint();\n if (value.isEmpty && !value.isEmpty() && value.contains(from) && value.contains(to)) {\n return this;\n }\n if (this._router.hitTest(p)) {\n return this;\n }\n }\n },\n _hover: function (value) {\n var color = (this.options.stroke || {}).color;\n if (value && isDefined(this.options.hover.stroke.color)) {\n color = this.options.hover.stroke.color;\n }\n this.path.redraw({ stroke: { color: color } });\n },\n _refreshPath: function () {\n if (!defined(this.path)) {\n return;\n }\n this._drawPath();\n this.bounds(this._router.getBounds());\n },\n _drawPath: function () {\n if (this._router) {\n this._router.route();\n }\n var source = this.sourcePoint();\n var target = this.targetPoint();\n var points = this.points();\n this.path.redraw({ points: [source].concat(points, [target]) });\n },\n _clearSourceConnector: function () {\n this.sourceConnector = undefined;\n this._resolvedSourceConnector = undefined;\n },\n _clearTargetConnector: function () {\n this.targetConnector = undefined;\n this._resolvedTargetConnector = undefined;\n },\n _removeFromSourceConnector: function () {\n if (this.sourceConnector) {\n Utils.remove(this.sourceConnector.connections, this);\n }\n },\n _removeFromTargetConnector: function () {\n if (this.targetConnector) {\n Utils.remove(this.targetConnector.connections, this);\n }\n },\n toJSON: function () {\n var connection = this;\n var from, to, point;\n if (connection.from && connection.from.toJSON) {\n from = connection.from.toJSON();\n } else {\n point = connection._sourcePoint;\n from = {\n x: point.x,\n y: point.y\n };\n }\n if (connection.to && connection.to.toJSON) {\n to = connection.to.toJSON();\n } else {\n point = connection._targetPoint;\n to = {\n x: point.x,\n y: point.y\n };\n }\n return {\n from: from,\n to: to\n };\n }\n });\n var Diagram = Widget.extend({\n init: function (element, userOptions) {\n var that = this;\n kendo.destroy(element);\n Widget.fn.init.call(that, element, userOptions);\n that._initTheme();\n that._initElements();\n that._extendLayoutOptions(that.options);\n that._initDefaults(userOptions);\n that._interactionDefaults();\n that._initCanvas();\n that.mainLayer = new Group({ id: 'main-layer' });\n that.canvas.append(that.mainLayer);\n that._shapesQuadTree = new ShapesQuadTree(that);\n that._pan = new Point();\n that._adorners = [];\n that.adornerLayer = new Group({ id: 'adorner-layer' });\n that.canvas.append(that.adornerLayer);\n that._createHandlers();\n that._initialize();\n that._resizingAdorner = new ResizingAdorner(that, { editable: that.options.editable });\n that._connectorsAdorner = new ConnectorsAdorner(that);\n that._adorn(that._resizingAdorner, true);\n that._adorn(that._connectorsAdorner, true);\n that.selector = new Selector(that);\n that._clipboard = [];\n that.pauseMouseHandlers = false;\n that._fetchFreshData();\n that._createGlobalToolBar();\n that._createOptionElements();\n that.zoom(that.options.zoom);\n that.canvas.draw();\n },\n options: {\n name: 'Diagram',\n theme: 'default',\n layout: '',\n zoomRate: 0.1,\n zoom: 1,\n zoomMin: 0,\n zoomMax: 2,\n dataSource: {},\n draggable: true,\n template: '',\n autoBind: true,\n editable: {\n rotate: {},\n resize: {},\n text: true,\n tools: [],\n drag: {\n snap: {\n size: 10,\n angle: 10\n }\n },\n remove: true\n },\n pannable: {},\n selectable: { key: 'none' },\n tooltip: {\n enabled: true,\n format: '{0}'\n },\n copy: {\n enabled: true,\n offsetX: 20,\n offsetY: 20\n },\n shapeDefaults: diagram.shapeDefaults({ undoable: true }),\n connectionDefaults: {\n editable: { tools: [] },\n type: CASCADING\n },\n shapes: [],\n connections: []\n },\n events: [\n ZOOM_END,\n ZOOM_START,\n PAN,\n SELECT,\n ITEMROTATE,\n ITEMBOUNDSCHANGE,\n CHANGE,\n CLICK,\n MOUSE_ENTER,\n MOUSE_LEAVE,\n 'toolBarClick',\n 'save',\n 'cancel',\n 'edit',\n 'remove',\n 'add',\n 'dataBound',\n DRAG_START,\n DRAG,\n DRAG_END\n ],\n items: function () {\n return $();\n },\n _createGlobalToolBar: function () {\n var editable = this.options.editable;\n if (editable) {\n var tools = editable.tools;\n if (this._isEditable && tools !== false && (!tools || tools.length === 0)) {\n tools = [\n 'createShape',\n 'undo',\n 'redo',\n 'rotateClockwise',\n 'rotateAnticlockwise'\n ];\n }\n if (tools && tools.length) {\n this.toolBar = new DiagramToolBar(this, {\n tools: tools || {},\n click: proxy(this._toolBarClick, this),\n modal: false\n });\n this.toolBar.element.css({ textAlign: 'left' });\n this.element.prepend(this.toolBar.element);\n this._resize();\n }\n }\n },\n createShape: function () {\n if (this.editor && this.editor.end() || !this.editor) {\n var dataSource = this.dataSource;\n var view = dataSource.view() || [];\n var index = view.length;\n var model = createModel(dataSource, {});\n var shape = this._createShape(model, {});\n if (!this.trigger('add', { shape: shape })) {\n dataSource.insert(index, model);\n var inactiveItem = this._inactiveShapeItems.getByUid(model.uid);\n inactiveItem.element = shape;\n this.edit(shape);\n }\n }\n },\n _createShape: function (dataItem, options) {\n options = deepExtend({}, this.options.shapeDefaults, options);\n options.dataItem = dataItem;\n var shape = new Shape(options, this);\n return shape;\n },\n createConnection: function () {\n if (this.editor && this.editor.end() || !this.editor) {\n var connectionsDataSource = this.connectionsDataSource;\n var view = connectionsDataSource.view() || [];\n var index = view.length;\n var model = createModel(connectionsDataSource, {});\n var connection = this._createConnection(model);\n if (!this.trigger('add', { connection: connection })) {\n this._connectionsDataMap[model.uid] = connection;\n connectionsDataSource.insert(index, model);\n this.addConnection(connection, false);\n this.edit(connection);\n }\n }\n },\n _createConnection: function (dataItem, source, target) {\n var options = deepExtend({}, this.options.connectionDefaults);\n options.dataItem = dataItem;\n var connection = new Connection(source || new Point(), target || new Point(), options);\n return connection;\n },\n editModel: function (dataItem, editorType) {\n this.cancelEdit();\n var editors, template;\n var editable = this.options.editable;\n if (editorType == 'shape') {\n editors = editable.shapeEditors;\n template = editable.shapeTemplate;\n } else if (editorType == 'connection') {\n var connectionSelectorHandler = proxy(connectionSelector, this);\n editors = deepExtend({}, {\n from: connectionSelectorHandler,\n to: connectionSelectorHandler\n }, editable.connectionEditors);\n template = editable.connectionTemplate;\n } else {\n return;\n }\n this.editor = new PopupEditor(this.element, {\n update: proxy(this._update, this),\n cancel: proxy(this._cancel, this),\n model: dataItem,\n type: editorType,\n target: this,\n editors: editors,\n template: template\n });\n this.trigger('edit', this._editArgs());\n },\n edit: function (item) {\n if (item.dataItem) {\n var editorType = item instanceof Shape ? 'shape' : 'connection';\n this.editModel(item.dataItem, editorType);\n }\n },\n cancelEdit: function () {\n if (this.editor) {\n this._getEditDataSource().cancelChanges(this.editor.model);\n this._destroyEditor();\n }\n },\n saveEdit: function () {\n if (this.editor && this.editor.end() && !this.trigger('save', this._editArgs())) {\n this._getEditDataSource().sync();\n }\n },\n _update: function () {\n if (this.editor && this.editor.end() && !this.trigger('save', this._editArgs())) {\n this._getEditDataSource().sync();\n this._destroyEditor();\n }\n },\n _cancel: function () {\n if (this.editor && !this.trigger('cancel', this._editArgs())) {\n var model = this.editor.model;\n this._getEditDataSource().cancelChanges(model);\n var element = this._connectionsDataMap[model.uid] || this._dataMap[model.id];\n if (element) {\n element._setOptionsFromModel(model);\n }\n this._destroyEditor();\n }\n },\n _getEditDataSource: function () {\n return this.editor.options.type === 'shape' ? this.dataSource : this.connectionsDataSource;\n },\n _editArgs: function () {\n var result = { container: this.editor.wrapper };\n result[this.editor.options.type] = this.editor.model;\n return result;\n },\n _destroyEditor: function () {\n if (this.editor) {\n this.editor.close();\n this.editor = null;\n }\n },\n _initElements: function () {\n this.wrapper = this.element.empty().css('position', 'relative').attr('tabindex', 0).addClass('k-widget k-diagram');\n this.scrollable = $('
').appendTo(this.element);\n },\n _initDefaults: function (userOptions) {\n var options = this.options;\n var editable = options.editable;\n var shapeDefaults = options.shapeDefaults;\n var connectionDefaults = options.connectionDefaults;\n var userShapeDefaults = (userOptions || {}).shapeDefaults;\n if (editable === false) {\n shapeDefaults.editable = false;\n connectionDefaults.editable = false;\n } else {\n copyDefaultOptions(editable, shapeDefaults.editable, [\n 'drag',\n 'remove',\n 'connect'\n ]);\n copyDefaultOptions(editable, connectionDefaults.editable, [\n 'drag',\n 'remove'\n ]);\n }\n if (userShapeDefaults && userShapeDefaults.connectors) {\n options.shapeDefaults.connectors = userShapeDefaults.connectors;\n }\n },\n _interactionDefaults: function () {\n var options = this.options;\n var selectable = options.selectable;\n var pannable = options.pannable;\n var mobile = kendo.support.mobileOS;\n if (selectable && !defined(selectable.multiple)) {\n options.selectable = deepExtend({ multiple: mobile ? false : true }, options.selectable);\n }\n if (pannable && !defined(pannable.key)) {\n options.pannable = deepExtend({ key: mobile ? 'none' : 'ctrl' }, options.pannable);\n }\n },\n _initCanvas: function () {\n var canvasContainer = $('
').appendTo(this.scrollable)[0];\n var viewPort = this.viewport();\n this.canvas = new Canvas(canvasContainer, {\n width: viewPort.width || DEFAULT_CANVAS_WIDTH,\n height: viewPort.height || DEFAULT_CANVAS_HEIGHT\n });\n },\n _createHandlers: function () {\n var that = this;\n var element = that.element;\n element.on(MOUSEWHEEL_NS, proxy(that._wheel, that)).on('keydown' + NS, proxy(that._keydown, that));\n that._userEvents = new kendo.UserEvents(this.scrollable, {\n multiTouch: true,\n fastTap: true,\n tap: proxy(that._tap, that),\n start: proxy(that._dragStart, that),\n move: proxy(that._drag, that),\n end: proxy(that._dragEnd, that),\n gesturestart: proxy(that._gestureStart, that),\n gesturechange: proxy(that._gestureChange, that),\n gestureend: proxy(that._gestureEnd, that)\n });\n that.toolService = new ToolService(that);\n this.scrollable.on('mouseover' + NS, proxy(that._mouseover, that)).on('mouseout' + NS, proxy(that._mouseout, that)).on('mousemove' + NS, proxy(that._mouseMove, that)).on('mousedown' + NS, proxy(that._mouseDown, that)).on('mouseup' + NS, proxy(that._mouseUp, that));\n this._syncHandler = proxy(that._syncChanges, that);\n that._resizeHandler = proxy(that.resize, that, false);\n kendo.onResize(that._resizeHandler);\n this.bind(ZOOM_START, proxy(that._destroyToolBar, that));\n this.bind(PAN, proxy(that._destroyToolBar, that));\n },\n _dragStart: function (e) {\n this._pauseMouseHandlers = true;\n var point = this._eventPositions(e, true);\n var event = e.event;\n if (this.toolService.start(point, this._meta(event))) {\n this._destroyToolBar();\n event.preventDefault();\n }\n },\n _drag: function (e) {\n var p = this._eventPositions(e);\n var event = e.event;\n if (this.toolService.move(p, this._meta(event))) {\n event.preventDefault();\n }\n },\n _dragEnd: function (e) {\n this._pauseMouseHandlers = false;\n var p = this._eventPositions(e);\n var event = e.event;\n if (this.toolService.end(p, this._meta(event))) {\n this._createToolBar();\n event.preventDefault();\n }\n },\n _mouseMove: function (e) {\n if (!this._pauseMouseHandlers) {\n var p = this._eventPositions(e);\n this.toolService._updateHoveredItem(p);\n this.toolService._updateCursor(p);\n }\n },\n _mouseDown: function () {\n this._pauseMouseHandlers = true;\n },\n _mouseUp: function () {\n this._pauseMouseHandlers = false;\n },\n _tap: function (e) {\n var toolService = this.toolService;\n var selectable = this.options.selectable;\n var point = this._eventPositions(e);\n var focused = this.focus();\n toolService._updateHoveredItem(point);\n if (toolService.hoveredItem) {\n var item = toolService.hoveredItem;\n this.trigger('click', {\n item: item,\n point: point\n });\n if (selectable && item.options.selectable !== false) {\n var multiple = selectable.multiple !== false;\n var ctrlPressed = kendo.support.mobileOS || this._meta(e.event).ctrlKey;\n if (item.isSelected) {\n if (ctrlPressed) {\n this._destroyToolBar();\n item.select(false);\n } else {\n this._createToolBar(focused);\n }\n } else {\n this._destroyToolBar();\n this.select(item, { addToSelection: multiple && ctrlPressed });\n this._createToolBar(focused);\n }\n }\n } else if (selectable) {\n this._destroyToolBar();\n this.deselect();\n }\n },\n _keydown: function (e) {\n if (this.toolService.keyDown(e.keyCode, this._meta(e))) {\n e.preventDefault();\n }\n },\n _wheel: function (e) {\n var delta = mwDelta(e), p = this._eventPositions(e), meta = deepExtend(this._meta(e), { delta: delta });\n if (this.toolService.wheel(p, meta)) {\n e.preventDefault();\n }\n },\n _meta: function (e) {\n return {\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n altKey: e.altKey,\n shiftKey: e.shiftKey,\n type: e.type\n };\n },\n _eventPositions: function (e, start) {\n var point;\n if (e.touch) {\n var field = start ? 'startLocation' : 'location';\n point = new Point(e.x[field], e.y[field]);\n } else {\n var event = e.originalEvent;\n point = new Point(event.pageX, event.pageY);\n }\n return this.documentToModel(point);\n },\n _gestureStart: function (e) {\n this._destroyToolBar();\n this.scroller.disable();\n var initialCenter = this.documentToModel(new Point(e.center.x, e.center.y));\n var eventArgs = {\n point: initialCenter,\n zoom: this.zoom()\n };\n if (this.trigger(ZOOM_START, eventArgs)) {\n return;\n }\n this._gesture = e;\n this._initialCenter = initialCenter;\n },\n _gestureChange: function (e) {\n var previousGesture = this._gesture;\n var initialCenter = this._initialCenter;\n var center = this.documentToView(new Point(e.center.x, e.center.y));\n var scaleDelta = e.distance / previousGesture.distance;\n var zoom = this._zoom;\n var updateZoom = false;\n if (math.abs(scaleDelta - 1) >= MOBILE_ZOOM_RATE) {\n this._zoom = zoom = this._getValidZoom(zoom * scaleDelta);\n this.options.zoom = zoom;\n this._gesture = e;\n updateZoom = true;\n }\n var zoomedPoint = initialCenter.times(zoom);\n var pan = center.minus(zoomedPoint);\n if (updateZoom || this._pan.distanceTo(pan) >= MOBILE_PAN_DISTANCE) {\n this._panTransform(pan);\n this._updateAdorners();\n }\n e.preventDefault();\n },\n _gestureEnd: function () {\n if (this.options.pannable !== false) {\n this.scroller.enable();\n }\n this.trigger(ZOOM_END, {\n point: this._initialCenter,\n zoom: this.zoom()\n });\n },\n _resize: function () {\n var viewport = this.viewport();\n if (this.canvas) {\n this.canvas.size(viewport);\n }\n if (this.scrollable && this.toolBar) {\n this.scrollable.height(viewport.height);\n }\n },\n _mouseover: function (e) {\n var node = e.target._kendoNode;\n if (node && node.srcElement._hover) {\n node.srcElement._hover(true, node.srcElement);\n }\n },\n _mouseout: function (e) {\n var node = e.target._kendoNode;\n if (node && node.srcElement._hover) {\n node.srcElement._hover(false, node.srcElement);\n }\n },\n _initTheme: function () {\n var that = this;\n var themeName = ((that.options || {}).theme || '').toLowerCase();\n var themes = dataviz.ui.themes || {};\n var themeOptions;\n if (SASS_THEMES.indexOf(themeName) != -1) {\n themeOptions = dataviz.autoTheme().diagram;\n } else {\n themeOptions = (themes[themeName] || {}).diagram;\n }\n that.options = deepExtend({}, themeOptions, that.options);\n if (that.options.editable === true) {\n deepExtend(that.options, { editable: (themeOptions || {}).editable });\n }\n },\n _createOptionElements: function () {\n var options = this.options;\n var shapesLength = options.shapes.length;\n if (shapesLength) {\n this._createShapes();\n }\n if (options.connections.length) {\n this._createConnections();\n }\n if (shapesLength && options.layout) {\n this.layout(options.layout);\n }\n },\n _createShapes: function () {\n var that = this, options = that.options, shapes = options.shapes, shape, i;\n for (i = 0; i < shapes.length; i++) {\n shape = shapes[i];\n that.addShape(shape);\n }\n },\n _createConnections: function () {\n var diagram = this, options = diagram.options, defaults = options.connectionDefaults, connections = options.connections, conn, source, target, i;\n for (i = 0; i < connections.length; i++) {\n conn = connections[i];\n source = diagram._findConnectionTarget(conn.from);\n target = diagram._findConnectionTarget(conn.to);\n diagram.connect(source, target, deepExtend({}, defaults, conn));\n }\n },\n _findConnectionTarget: function (options) {\n options = options || {};\n var diagram = this;\n var shapeId = isString(options) ? options : options.shapeId || options.id;\n var target;\n if (shapeId) {\n target = diagram.getShapeById(shapeId);\n if (options.connector) {\n target = target.getConnector(options.connector);\n }\n } else {\n target = new Point(options.x || 0, options.y || 0);\n }\n return target;\n },\n destroy: function () {\n var that = this;\n Widget.fn.destroy.call(that);\n if (this._userEvents) {\n this._userEvents.destroy();\n }\n kendo.unbindResize(that._resizeHandler);\n that.clear();\n that.element.off(NS);\n that.scroller.wrapper.off(NS);\n that.canvas.destroy(true);\n that.canvas = undefined;\n that._destroyEditor();\n that.destroyScroller();\n that._destroyGlobalToolBar();\n that._destroyToolBar();\n },\n destroyScroller: function () {\n var scroller = this.scroller;\n if (!scroller) {\n return;\n }\n scroller.destroy();\n scroller.element.remove();\n this.scroller = null;\n },\n save: function () {\n var json = {\n shapes: [],\n connections: []\n };\n var i, connection, shape;\n for (i = 0; i < this.shapes.length; i++) {\n shape = this.shapes[i];\n if (shape.options.serializable) {\n json.shapes.push(shape.options);\n }\n }\n for (i = 0; i < this.connections.length; i++) {\n connection = this.connections[i];\n json.connections.push(deepExtend({}, connection.options, connection.toJSON()));\n }\n return json;\n },\n focus: function () {\n if (!this.element.is(kendo._activeElement())) {\n var element = this.element, scrollContainer = element[0], containers = [], offsets = [], documentElement = document.documentElement, i;\n do {\n scrollContainer = scrollContainer.parentNode;\n if (scrollContainer.scrollHeight > scrollContainer.clientHeight) {\n containers.push(scrollContainer);\n offsets.push(scrollContainer.scrollTop);\n }\n } while (scrollContainer != documentElement);\n element.focus();\n for (i = 0; i < containers.length; i++) {\n containers[i].scrollTop = offsets[i];\n }\n return true;\n }\n },\n load: function (options) {\n this.clear();\n this.setOptions(options);\n this._createShapes();\n this._createConnections();\n },\n setOptions: function (options) {\n deepExtend(this.options, options);\n },\n clear: function () {\n var that = this;\n that.select(false);\n that.mainLayer.clear();\n that._shapesQuadTree.clear();\n that._initialize();\n },\n connect: function (source, target, options) {\n var connection;\n if (this.connectionsDataSource && this._isEditable) {\n var dataItem = this.connectionsDataSource.add({});\n connection = this._connectionsDataMap[dataItem.uid];\n connection.source(source);\n connection.target(target);\n connection.redraw(options);\n connection.updateModel();\n } else {\n connection = new Connection(source, target, deepExtend({}, this.options.connectionDefaults, options));\n this.addConnection(connection);\n }\n return connection;\n },\n connected: function (source, target) {\n for (var i = 0; i < this.connections.length; i++) {\n var c = this.connections[i];\n if (c.from == source && c.to == target) {\n return true;\n }\n }\n return false;\n },\n addConnection: function (connection, undoable) {\n if (undoable !== false) {\n this.undoRedoService.add(new diagram.AddConnectionUnit(connection, this), false);\n }\n connection.diagram = this;\n connection._setOptionsFromModel();\n connection.refresh();\n this.mainLayer.append(connection.visual);\n this.connections.push(connection);\n this.trigger(CHANGE, {\n added: [connection],\n removed: []\n });\n return connection;\n },\n _addConnection: function (connection, undoable) {\n var connectionsDataSource = this.connectionsDataSource;\n var dataItem;\n if (connectionsDataSource && this._isEditable) {\n dataItem = createModel(connectionsDataSource, cloneDataItem(connection.dataItem));\n connection.dataItem = dataItem;\n connection.updateModel();\n if (!this.trigger('add', { connection: connection })) {\n this._connectionsDataMap[dataItem.uid] = connection;\n connectionsDataSource.add(dataItem);\n this.addConnection(connection, undoable);\n connection._updateConnectors();\n return connection;\n }\n } else if (!this.trigger('add', { connection: connection })) {\n this.addConnection(connection, undoable);\n connection._updateConnectors();\n return connection;\n }\n },\n addShape: function (item, undoable) {\n var shape, shapeDefaults = this.options.shapeDefaults;\n if (item instanceof Shape) {\n shape = item;\n } else if (!(item instanceof kendo.Class)) {\n shapeDefaults = deepExtend({}, shapeDefaults, item || {});\n shape = new Shape(shapeDefaults, this);\n } else {\n return;\n }\n if (undoable !== false) {\n this.undoRedoService.add(new diagram.AddShapeUnit(shape, this), false);\n }\n this.shapes.push(shape);\n if (shape.diagram !== this) {\n this._shapesQuadTree.insert(shape);\n shape.diagram = this;\n }\n this.mainLayer.append(shape.visual);\n this.trigger(CHANGE, {\n added: [shape],\n removed: []\n });\n return shape;\n },\n _addShape: function (shape, undoable) {\n var that = this;\n var dataSource = that.dataSource;\n var dataItem;\n if (dataSource && this._isEditable) {\n dataItem = createModel(dataSource, cloneDataItem(shape.dataItem));\n shape.dataItem = dataItem;\n shape.updateModel();\n if (!this.trigger('add', { shape: shape })) {\n this.dataSource.add(dataItem);\n var inactiveItem = this._inactiveShapeItems.getByUid(dataItem.uid);\n inactiveItem.element = shape;\n inactiveItem.undoable = undoable;\n return shape;\n }\n } else if (!this.trigger('add', { shape: shape })) {\n return this.addShape(shape, undoable);\n }\n },\n remove: function (items, undoable) {\n items = isArray(items) ? items.slice(0) : [items];\n var elements = splitDiagramElements(items);\n var shapes = elements.shapes;\n var connections = elements.connections;\n var i;\n if (!defined(undoable)) {\n undoable = true;\n }\n if (undoable) {\n this.undoRedoService.begin();\n }\n this._suspendModelRefresh();\n for (i = shapes.length - 1; i >= 0; i--) {\n this._removeItem(shapes[i], undoable, connections);\n }\n for (i = connections.length - 1; i >= 0; i--) {\n this._removeItem(connections[i], undoable);\n }\n this._resumeModelRefresh();\n if (undoable) {\n this.undoRedoService.commit(false);\n }\n this.trigger(CHANGE, {\n added: [],\n removed: items\n });\n },\n _removeShapeDataItem: function (item) {\n if (this._isEditable) {\n this.dataSource.remove(item.dataItem);\n delete this._dataMap[item.dataItem.id];\n }\n },\n _removeConnectionDataItem: function (item) {\n if (this._isEditable) {\n this.connectionsDataSource.remove(item.dataItem);\n delete this._connectionsDataMap[item.dataItem.uid];\n }\n },\n _triggerRemove: function (items) {\n var toRemove = [];\n var item, args, editable;\n for (var idx = 0; idx < items.length; idx++) {\n item = items[idx];\n editable = item.options.editable;\n if (item instanceof Shape) {\n args = { shape: item };\n } else {\n args = { connection: item };\n }\n if (editable && editable.remove !== false && !this.trigger('remove', args)) {\n toRemove.push(item);\n }\n }\n return toRemove;\n },\n undo: function () {\n this.undoRedoService.undo();\n },\n redo: function () {\n this.undoRedoService.redo();\n },\n select: function (item, options) {\n if (isDefined(item)) {\n options = deepExtend({ addToSelection: false }, options);\n var addToSelection = options.addToSelection, items = [], selected = [], i, element;\n if (!addToSelection) {\n this.deselect();\n }\n this._internalSelection = true;\n if (item instanceof Array) {\n items = item;\n } else if (item instanceof DiagramElement) {\n items = [item];\n }\n for (i = 0; i < items.length; i++) {\n element = items[i];\n if (element.select(true)) {\n selected.push(element);\n }\n }\n this._selectionChanged(selected, []);\n this._internalSelection = false;\n } else {\n return this._selectedItems;\n }\n },\n selectAll: function () {\n this.select(this.shapes.concat(this.connections));\n },\n selectArea: function (rect) {\n var i, items, item;\n this._internalSelection = true;\n var selected = [];\n if (rect instanceof Rect) {\n items = this.shapes.concat(this.connections);\n for (i = 0; i < items.length; i++) {\n item = items[i];\n if ((!rect || item._hitTest(rect)) && item.options.enable) {\n if (item.select(true)) {\n selected.push(item);\n }\n }\n }\n }\n this._selectionChanged(selected, []);\n this._internalSelection = false;\n },\n deselect: function (item) {\n this._internalSelection = true;\n var deselected = [], items = [], element, i;\n if (item instanceof Array) {\n items = item;\n } else if (item instanceof DiagramElement) {\n items.push(item);\n } else if (!isDefined(item)) {\n items = this._selectedItems.slice(0);\n }\n for (i = 0; i < items.length; i++) {\n element = items[i];\n if (element.select(false)) {\n deselected.push(element);\n }\n }\n this._selectionChanged([], deselected);\n this._internalSelection = false;\n },\n toFront: function (items, undoable) {\n if (!items) {\n items = this._selectedItems.slice();\n }\n var result = this._getDiagramItems(items), indices;\n if (!defined(undoable) || undoable) {\n indices = indicesOfItems(this.mainLayer, result.visuals);\n var unit = new ToFrontUnit(this, items, indices);\n this.undoRedoService.add(unit);\n } else {\n this.mainLayer.toFront(result.visuals);\n this._fixOrdering(result, true);\n }\n },\n toBack: function (items, undoable) {\n if (!items) {\n items = this._selectedItems.slice();\n }\n var result = this._getDiagramItems(items), indices;\n if (!defined(undoable) || undoable) {\n indices = indicesOfItems(this.mainLayer, result.visuals);\n var unit = new ToBackUnit(this, items, indices);\n this.undoRedoService.add(unit);\n } else {\n this.mainLayer.toBack(result.visuals);\n this._fixOrdering(result, false);\n }\n },\n bringIntoView: function (item, options) {\n var viewport = this.viewport();\n var aligner = new diagram.RectAlign(viewport);\n var current, rect, original, newPan;\n if (viewport.width === 0 || viewport.height === 0) {\n return;\n }\n options = deepExtend({\n animate: false,\n align: 'center middle'\n }, options);\n if (options.align == 'none') {\n options.align = 'center middle';\n }\n if (item instanceof DiagramElement) {\n rect = item.bounds(TRANSFORMED);\n } else if (isArray(item)) {\n rect = this.boundingBox(item);\n } else if (item instanceof Rect) {\n rect = item.clone();\n }\n original = rect.clone();\n rect.zoom(this._zoom);\n if (rect.width > viewport.width || rect.height > viewport.height) {\n this._zoom = this._getValidZoom(math.min(viewport.width / original.width, viewport.height / original.height));\n rect = original.clone().zoom(this._zoom);\n }\n this._zoomMainLayer();\n current = rect.clone();\n aligner.align(rect, options.align);\n newPan = rect.topLeft().minus(current.topLeft());\n this.pan(newPan.times(-1), options.animate);\n },\n alignShapes: function (direction) {\n if (isUndefined(direction)) {\n direction = 'Left';\n }\n var items = this.select(), val, item, i;\n if (items.length === 0) {\n return;\n }\n switch (direction.toLowerCase()) {\n case 'left':\n case 'top':\n val = MAX_VALUE;\n break;\n case 'right':\n case 'bottom':\n val = MIN_VALUE;\n break;\n }\n for (i = 0; i < items.length; i++) {\n item = items[i];\n if (item instanceof Shape) {\n switch (direction.toLowerCase()) {\n case 'left':\n val = math.min(val, item.options.x);\n break;\n case 'top':\n val = math.min(val, item.options.y);\n break;\n case 'right':\n val = math.max(val, item.options.x);\n break;\n case 'bottom':\n val = math.max(val, item.options.y);\n break;\n }\n }\n }\n var undoStates = [];\n var shapes = [];\n for (i = 0; i < items.length; i++) {\n item = items[i];\n if (item instanceof Shape) {\n shapes.push(item);\n undoStates.push(item.bounds());\n switch (direction.toLowerCase()) {\n case 'left':\n case 'right':\n item.position(new Point(val, item.options.y));\n break;\n case 'top':\n case 'bottom':\n item.position(new Point(item.options.x, val));\n break;\n }\n }\n }\n var unit = new diagram.TransformUnit(shapes, undoStates);\n this.undoRedoService.add(unit, false);\n },\n zoom: function (zoom, options) {\n if (zoom) {\n var staticPoint = options ? options.point : new diagram.Point(0, 0);\n zoom = this._zoom = this._getValidZoom(zoom);\n if (!isUndefined(staticPoint)) {\n staticPoint = new diagram.Point(math.round(staticPoint.x), math.round(staticPoint.y));\n var zoomedPoint = staticPoint.times(zoom);\n var viewportVector = this.modelToView(staticPoint);\n var raw = viewportVector.minus(zoomedPoint);\n this._storePan(new diagram.Point(math.round(raw.x), math.round(raw.y)));\n }\n if (options) {\n options.zoom = zoom;\n }\n this._panTransform();\n this.canvas.surface.hideTooltip();\n this._updateAdorners();\n }\n return this._zoom;\n },\n _getPan: function (pan) {\n var canvas = this.canvas;\n if (!canvas.translate) {\n pan = pan.plus(this._pan);\n }\n return pan;\n },\n pan: function (pan, animate) {\n if (pan instanceof Point) {\n var that = this;\n var scroller = that.scroller;\n pan = that._getPan(pan);\n pan = pan.times(-1);\n if (animate) {\n scroller.animatedScrollTo(pan.x, pan.y, function () {\n that._updateAdorners();\n });\n } else {\n scroller.scrollTo(pan.x, pan.y);\n that._updateAdorners();\n }\n } else {\n return this._pan.times(-1);\n }\n },\n viewport: function () {\n var element = this.element;\n var width = element.width();\n var height = element.height();\n if (this.toolBar) {\n height -= outerHeight(this.toolBar.element);\n }\n return new Rect(0, 0, width, height);\n },\n copy: function () {\n if (this.options.copy.enabled) {\n this._clipboard = [];\n this._copyOffset = 1;\n for (var i = 0; i < this._selectedItems.length; i++) {\n var item = this._selectedItems[i];\n this._clipboard.push(item);\n }\n }\n },\n cut: function () {\n if (this.options.copy.enabled) {\n this._clipboard = [];\n this._copyOffset = 0;\n for (var i = 0; i < this._selectedItems.length; i++) {\n var item = this._selectedItems[i];\n this._clipboard.push(item);\n }\n this.remove(this._clipboard, true);\n }\n },\n paste: function () {\n if (this._clipboard.length > 0) {\n var item, copied, i;\n var mapping = {};\n var elements = splitDiagramElements(this._clipboard);\n var connections = elements.connections;\n var shapes = elements.shapes;\n var offset = {\n x: this._copyOffset * this.options.copy.offsetX,\n y: this._copyOffset * this.options.copy.offsetY\n };\n this.deselect();\n for (i = 0; i < shapes.length; i++) {\n item = shapes[i];\n copied = item.clone();\n mapping[item.id] = copied;\n copied.position(new Point(item.options.x + offset.x, item.options.y + offset.y));\n copied.diagram = this;\n copied = this._addShape(copied);\n if (copied) {\n copied.select();\n }\n }\n for (i = 0; i < connections.length; i++) {\n item = connections[i];\n copied = this._addConnection(item.clone());\n if (copied) {\n this._updateCopiedConnection(copied, item, 'source', mapping, offset);\n this._updateCopiedConnection(copied, item, 'target', mapping, offset);\n copied.select(true);\n copied.updateModel();\n }\n }\n this._syncChanges();\n this._copyOffset += 1;\n }\n },\n _updateCopiedConnection: function (connection, sourceConnection, connectorName, mapping, offset) {\n var onActivate, inactiveItem, targetShape;\n var target = sourceConnection[connectorName]();\n var diagram = this;\n if (target instanceof Connector && mapping[target.shape.id]) {\n targetShape = mapping[target.shape.id];\n if (diagram.getShapeById(targetShape.id)) {\n connection[connectorName](targetShape.getConnector(target.options.name));\n } else {\n inactiveItem = diagram._inactiveShapeItems.getByUid(targetShape.dataItem.uid);\n if (inactiveItem) {\n onActivate = function (item) {\n targetShape = diagram._dataMap[item.id];\n connection[connectorName](targetShape.getConnector(target.options.name));\n connection.updateModel();\n };\n diagram._deferredConnectionUpdates.push(inactiveItem.onActivate(onActivate));\n }\n }\n } else {\n connection[connectorName](new Point(sourceConnection[connectorName + 'Point']().x + offset.x, sourceConnection[connectorName + 'Point']().y + offset.y));\n }\n },\n boundingBox: function (items, origin) {\n var rect = Rect.empty(), temp, di = isDefined(items) ? this._getDiagramItems(items) : { shapes: this.shapes };\n if (di.shapes.length > 0) {\n var item = di.shapes[0];\n rect = item.bounds(ROTATED);\n for (var i = 1; i < di.shapes.length; i++) {\n item = di.shapes[i];\n temp = item.bounds(ROTATED);\n if (origin === true) {\n temp.x -= item._rotationOffset.x;\n temp.y -= item._rotationOffset.y;\n }\n rect = rect.union(temp);\n }\n }\n return rect;\n },\n _containerOffset: function () {\n var containerOffset = this.element.offset();\n if (this.toolBar) {\n containerOffset.top += outerHeight(this.toolBar.element);\n }\n return containerOffset;\n },\n documentToView: function (point) {\n var containerOffset = this._containerOffset();\n return new Point(point.x - containerOffset.left, point.y - containerOffset.top);\n },\n viewToDocument: function (point) {\n var containerOffset = this._containerOffset();\n return new Point(point.x + containerOffset.left, point.y + containerOffset.top);\n },\n viewToModel: function (point) {\n return this._transformWithMatrix(point, this._matrixInvert);\n },\n modelToView: function (point) {\n return this._transformWithMatrix(point, this._matrix);\n },\n modelToLayer: function (point) {\n return this._transformWithMatrix(point, this._layerMatrix);\n },\n layerToModel: function (point) {\n return this._transformWithMatrix(point, this._layerMatrixInvert);\n },\n documentToModel: function (point) {\n var viewPoint = this.documentToView(point);\n if (!this.canvas.translate) {\n viewPoint.x = viewPoint.x + this.scroller.scrollLeft;\n viewPoint.y = viewPoint.y + this.scroller.scrollTop;\n }\n return this.viewToModel(viewPoint);\n },\n modelToDocument: function (point) {\n return this.viewToDocument(this.modelToView(point));\n },\n _transformWithMatrix: function (point, matrix) {\n var result = point;\n if (point instanceof Point) {\n if (matrix) {\n result = matrix.apply(point);\n }\n } else {\n var tl = this._transformWithMatrix(point.topLeft(), matrix), br = this._transformWithMatrix(point.bottomRight(), matrix);\n result = Rect.fromPoints(tl, br);\n }\n return result;\n },\n setDataSource: function (dataSource) {\n this.options.dataSource = dataSource;\n this._dataSource();\n if (this.options.autoBind) {\n this.dataSource.fetch();\n }\n },\n setConnectionsDataSource: function (dataSource) {\n this.options.connectionsDataSource = dataSource;\n this._connectionDataSource();\n if (this.options.autoBind) {\n this.connectionsDataSource.fetch();\n }\n },\n layout: function (options) {\n this._layouting = true;\n var type;\n if (isUndefined(options)) {\n options = this.options.layout;\n }\n if (isUndefined(options) || isUndefined(options.type)) {\n type = 'Tree';\n } else {\n type = options.type;\n }\n var l;\n switch (type.toLowerCase()) {\n case 'tree':\n l = new diagram.TreeLayout(this);\n break;\n case 'layered':\n l = new diagram.LayeredLayout(this);\n break;\n case 'forcedirected':\n case 'force':\n case 'spring':\n case 'springembedder':\n l = new diagram.SpringLayout(this);\n break;\n default:\n throw 'Layout algorithm \\'' + type + '\\' is not supported.';\n }\n var initialState = new diagram.LayoutState(this);\n var finalState = l.layout(options);\n if (finalState) {\n var unit = new diagram.LayoutUndoUnit(initialState, finalState, options ? options.animate : null);\n this.undoRedoService.add(unit);\n }\n this._layouting = false;\n this._redrawConnections();\n },\n getShapeById: function (id) {\n var found;\n found = Utils.first(this.shapes, function (s) {\n return s.visual.id === id;\n });\n if (found) {\n return found;\n }\n found = Utils.first(this.connections, function (c) {\n return c.visual.id === id;\n });\n return found;\n },\n getShapeByModelId: function (id) {\n var shape;\n if (this._isEditable) {\n shape = this._dataMap[id];\n } else {\n shape = Utils.first(this.shapes, function (shape) {\n return (shape.dataItem || {}).id === id;\n });\n }\n return shape;\n },\n getShapeByModelUid: function (uid) {\n var shape;\n if (this._isEditable) {\n shape = Utils.first(this.shapes, function (shape) {\n return (shape.dataItem || {}).uid === uid;\n });\n } else {\n shape = this._dataMap[uid];\n }\n return shape;\n },\n getConnectionByModelId: function (id) {\n var connection;\n if (this.connectionsDataSource) {\n connection = Utils.first(this.connections, function (connection) {\n return (connection.dataItem || {}).id === id;\n });\n }\n return connection;\n },\n getConnectionByModelUid: function (uid) {\n var connection;\n if (this.connectionsDataSource) {\n connection = this._connectionsDataMap[uid];\n }\n return connection;\n },\n _extendLayoutOptions: function (options) {\n if (options.layout) {\n options.layout = deepExtend({}, diagram.LayoutBase.fn.defaultOptions || {}, options.layout);\n }\n },\n _selectionChanged: function (selected, deselected) {\n if (selected.length || deselected.length) {\n this.trigger(SELECT, {\n selected: selected,\n deselected: deselected\n });\n }\n },\n _getValidZoom: function (zoom) {\n return math.min(math.max(zoom, this.options.zoomMin), this.options.zoomMax);\n },\n _panTransform: function (pos) {\n var diagram = this, pan = pos || diagram._pan;\n if (diagram.canvas.translate) {\n diagram.scroller.scrollTo(pan.x, pan.y);\n diagram._zoomMainLayer();\n } else {\n diagram._storePan(pan);\n diagram._transformMainLayer();\n }\n },\n _finishPan: function () {\n this.trigger(PAN, {\n total: this._pan,\n delta: Number.NaN\n });\n },\n _storePan: function (pan) {\n this._pan = pan;\n this._storeViewMatrix();\n },\n _zoomMainLayer: function () {\n var zoom = this._zoom;\n var transform = new CompositeTransform(0, 0, zoom, zoom);\n transform.render(this.mainLayer);\n this._storeLayerMatrix(transform);\n this._storeViewMatrix();\n },\n _transformMainLayer: function () {\n var pan = this._pan, zoom = this._zoom;\n var transform = new CompositeTransform(pan.x, pan.y, zoom, zoom);\n transform.render(this.mainLayer);\n this._storeLayerMatrix(transform);\n this._storeViewMatrix();\n },\n _storeLayerMatrix: function (canvasTransform) {\n this._layerMatrix = canvasTransform.toMatrix();\n this._layerMatrixInvert = canvasTransform.invert().toMatrix();\n },\n _storeViewMatrix: function () {\n var pan = this._pan, zoom = this._zoom;\n var transform = new CompositeTransform(pan.x, pan.y, zoom, zoom);\n this._matrix = transform.toMatrix();\n this._matrixInvert = transform.invert().toMatrix();\n },\n _toIndex: function (items, indices) {\n var result = this._getDiagramItems(items);\n this.mainLayer.toIndex(result.visuals, indices);\n this._fixOrdering(result, false);\n },\n _fixOrdering: function (result, toFront) {\n var shapePos = toFront ? this.shapes.length - 1 : 0, conPos = toFront ? this.connections.length - 1 : 0, i, item;\n for (i = 0; i < result.shapes.length; i++) {\n item = result.shapes[i];\n Utils.remove(this.shapes, item);\n Utils.insert(this.shapes, item, shapePos);\n }\n for (i = 0; i < result.cons.length; i++) {\n item = result.cons[i];\n Utils.remove(this.connections, item);\n Utils.insert(this.connections, item, conPos);\n }\n },\n _getDiagramItems: function (items) {\n var i, result = {}, args = items;\n result.visuals = [];\n result.shapes = [];\n result.cons = [];\n if (!items) {\n args = this._selectedItems.slice();\n } else if (!isArray(items)) {\n args = [items];\n }\n for (i = 0; i < args.length; i++) {\n var item = args[i];\n if (item instanceof Shape) {\n result.shapes.push(item);\n result.visuals.push(item.visual);\n } else if (item instanceof Connection) {\n result.cons.push(item);\n result.visuals.push(item.visual);\n }\n }\n return result;\n },\n _removeItem: function (item, undoable, removedConnections) {\n item.select(false);\n if (item instanceof Shape) {\n this._removeShapeDataItem(item);\n this._removeShape(item, undoable, removedConnections);\n } else if (item instanceof Connection) {\n this._removeConnectionDataItem(item);\n this._removeConnection(item, undoable);\n }\n this.mainLayer.remove(item.visual);\n },\n _removeShape: function (shape, undoable, removedConnections) {\n var i, connection, connector, sources = [], targets = [];\n this.toolService._removeHover();\n if (undoable) {\n this.undoRedoService.addCompositeItem(new DeleteShapeUnit(shape));\n }\n Utils.remove(this.shapes, shape);\n this._shapesQuadTree.remove(shape);\n for (i = 0; i < shape.connectors.length; i++) {\n connector = shape.connectors[i];\n for (var j = 0; j < connector.connections.length; j++) {\n connection = connector.connections[j];\n if (!removedConnections || !dataviz.inArray(connection, removedConnections)) {\n if (connection.sourceConnector == connector) {\n sources.push(connection);\n } else if (connection.targetConnector == connector) {\n targets.push(connection);\n }\n }\n }\n }\n for (i = 0; i < sources.length; i++) {\n sources[i].source(null, undoable);\n sources[i].updateModel();\n }\n for (i = 0; i < targets.length; i++) {\n targets[i].target(null, undoable);\n targets[i].updateModel();\n }\n },\n _removeConnection: function (connection, undoable) {\n if (connection.sourceConnector) {\n Utils.remove(connection.sourceConnector.connections, connection);\n }\n if (connection.targetConnector) {\n Utils.remove(connection.targetConnector.connections, connection);\n }\n if (undoable) {\n this.undoRedoService.addCompositeItem(new DeleteConnectionUnit(connection));\n }\n Utils.remove(this.connections, connection);\n },\n _removeDataItems: function (items, recursive) {\n var item, children, shape, idx;\n items = isArray(items) ? items : [items];\n while (items.length) {\n item = items.shift();\n shape = this._dataMap[item.uid];\n if (shape) {\n this._removeShapeConnections(shape);\n this._removeItem(shape, false);\n delete this._dataMap[item.uid];\n if (recursive && item.hasChildren && item.loaded()) {\n children = item.children.data();\n for (idx = 0; idx < children.length; idx++) {\n items.push(children[idx]);\n }\n }\n }\n }\n },\n _removeShapeConnections: function (shape) {\n var connections = shape.connections();\n var idx;\n if (connections) {\n for (idx = 0; idx < connections.length; idx++) {\n this._removeItem(connections[idx], false);\n }\n }\n },\n _addDataItem: function (dataItem, undoable) {\n if (!defined(dataItem)) {\n return;\n }\n var shape = this._dataMap[dataItem.id];\n if (shape) {\n return shape;\n }\n var options = deepExtend({}, this.options.shapeDefaults);\n options.dataItem = dataItem;\n shape = new Shape(options, this);\n this.addShape(shape, undoable !== false);\n this._dataMap[dataItem.id] = shape;\n return shape;\n },\n _addDataItemByUid: function (dataItem) {\n if (!defined(dataItem)) {\n return;\n }\n var shape = this._dataMap[dataItem.uid];\n if (shape) {\n return shape;\n }\n var options = deepExtend({}, this.options.shapeDefaults);\n options.dataItem = dataItem;\n shape = new Shape(options, this);\n this.addShape(shape);\n this._dataMap[dataItem.uid] = shape;\n return shape;\n },\n _addDataItems: function (items, parent) {\n var item, idx, shape, parentShape, connection;\n for (idx = 0; idx < items.length; idx++) {\n item = items[idx];\n shape = this._addDataItemByUid(item);\n parentShape = this._addDataItemByUid(parent);\n if (parentShape && !this.connected(parentShape, shape)) {\n connection = this.connect(parentShape, shape);\n }\n }\n },\n _refreshSource: function (e) {\n var that = this, node = e.node, action = e.action, items = e.items, options = that.options, idx, dataBound;\n if (e.field) {\n for (idx = 0; idx < items.length; idx++) {\n if (this._dataMap[items[idx].uid]) {\n this._dataMap[items[idx].uid].redrawVisual();\n }\n }\n return;\n }\n if (action == 'remove') {\n this._removeDataItems(e.items, true);\n } else {\n if ((!action || action === 'itemloaded') && !this._bindingRoots) {\n this._bindingRoots = true;\n dataBound = true;\n }\n if (!action && !node) {\n that.clear();\n }\n this._addDataItems(items, node);\n for (idx = 0; idx < items.length; idx++) {\n items[idx].load();\n }\n }\n if (options.layout && (dataBound || action == 'remove' || action == 'add')) {\n that.layout(options.layout);\n }\n if (dataBound) {\n this.trigger('dataBound');\n this._bindingRoots = false;\n }\n },\n _addItem: function (item) {\n if (item instanceof Shape) {\n this.addShape(item);\n } else if (item instanceof Connection) {\n this.addConnection(item);\n }\n },\n _createToolBar: function (preventClosing) {\n var diagram = this.toolService.diagram;\n if (!this.singleToolBar && diagram.select().length === 1) {\n var element = diagram.select()[0];\n if (element && element.options.editable !== false) {\n var editable = element.options.editable;\n var tools = editable.tools;\n if (this._isEditable && tools.length === 0) {\n if (element instanceof Shape) {\n tools = [\n 'edit',\n 'rotateClockwise',\n 'rotateAnticlockwise'\n ];\n } else if (element instanceof Connection) {\n tools = ['edit'];\n }\n if (editable && editable.remove !== false) {\n tools.push('delete');\n }\n }\n if (tools && tools.length) {\n var padding = 20;\n var point;\n this.singleToolBar = new DiagramToolBar(diagram, {\n tools: tools,\n click: proxy(this._toolBarClick, this),\n modal: true\n });\n var popupWidth = outerWidth(this.singleToolBar._popup.element);\n var popupHeight = outerHeight(this.singleToolBar._popup.element);\n if (element instanceof Shape) {\n var shapeBounds = this.modelToView(element.bounds(ROTATED));\n point = new Point(shapeBounds.x, shapeBounds.y).minus(new Point((popupWidth - shapeBounds.width) / 2, popupHeight + padding));\n } else if (element instanceof Connection) {\n var connectionBounds = this.modelToView(element.bounds());\n point = new Point(connectionBounds.x, connectionBounds.y).minus(new Point((popupWidth - connectionBounds.width - 20) / 2, popupHeight + padding));\n }\n if (point) {\n if (!this.canvas.translate) {\n point = point.minus(new Point(this.scroller.scrollLeft, this.scroller.scrollTop));\n }\n point = this.viewToDocument(point);\n point = new Point(math.max(point.x, 0), math.max(point.y, 0));\n this.singleToolBar.showAt(point);\n if (preventClosing) {\n this.singleToolBar._popup.one('close', preventDefault);\n }\n } else {\n this._destroyToolBar();\n }\n }\n }\n }\n },\n _toolBarClick: function (e) {\n this.trigger('toolBarClick', e);\n this._destroyToolBar();\n },\n _normalizePointZoom: function (point) {\n return point.times(1 / this.zoom());\n },\n _initialize: function () {\n this.shapes = [];\n this._selectedItems = [];\n this.connections = [];\n this._dataMap = {};\n this._connectionsDataMap = {};\n this._inactiveShapeItems = new InactiveItemsCollection();\n this._deferredConnectionUpdates = [];\n this.undoRedoService = new UndoRedoService({\n undone: this._syncHandler,\n redone: this._syncHandler\n });\n this.id = diagram.randomId();\n },\n _fetchFreshData: function () {\n var that = this;\n that._dataSource();\n if (that._isEditable) {\n that._connectionDataSource();\n }\n if (that.options.autoBind) {\n if (that._isEditable) {\n this._loadingShapes = true;\n this._loadingConnections = true;\n that.dataSource.fetch();\n that.connectionsDataSource.fetch();\n } else {\n that.dataSource.fetch();\n }\n }\n },\n _dataSource: function () {\n if (defined(this.options.connectionsDataSource)) {\n this._isEditable = true;\n var dsOptions = this.options.dataSource || {};\n var ds = isArray(dsOptions) ? { data: dsOptions } : dsOptions;\n if (this.dataSource && this._shapesRefreshHandler) {\n this.dataSource.unbind('change', this._shapesRefreshHandler).unbind('requestStart', this._shapesRequestStartHandler).unbind('error', this._shapesErrorHandler);\n } else {\n this._shapesRefreshHandler = proxy(this._refreshShapes, this);\n this._shapesRequestStartHandler = proxy(this._shapesRequestStart, this);\n this._shapesErrorHandler = proxy(this._error, this);\n }\n this.dataSource = kendo.data.DataSource.create(ds).bind('change', this._shapesRefreshHandler).bind('requestStart', this._shapesRequestStartHandler).bind('error', this._shapesErrorHandler);\n } else {\n this._treeDataSource();\n this._isEditable = false;\n }\n },\n _connectionDataSource: function () {\n var dsOptions = this.options.connectionsDataSource;\n if (dsOptions) {\n var ds = isArray(dsOptions) ? { data: dsOptions } : dsOptions;\n if (this.connectionsDataSource && this._connectionsRefreshHandler) {\n this.connectionsDataSource.unbind('change', this._connectionsRefreshHandler).unbind('requestStart', this._connectionsRequestStartHandler).unbind('error', this._connectionsErrorHandler);\n } else {\n this._connectionsRefreshHandler = proxy(this._refreshConnections, this);\n this._connectionsRequestStartHandler = proxy(this._connectionsRequestStart, this);\n this._connectionsErrorHandler = proxy(this._connectionsError, this);\n }\n this.connectionsDataSource = kendo.data.DataSource.create(ds).bind('change', this._connectionsRefreshHandler).bind('requestStart', this._connectionsRequestStartHandler).bind('error', this._connectionsErrorHandler);\n }\n },\n _shapesRequestStart: function (e) {\n if (e.type == 'read') {\n this._loadingShapes = true;\n }\n },\n _connectionsRequestStart: function (e) {\n if (e.type == 'read') {\n this._loadingConnections = true;\n }\n },\n _error: function () {\n this._loadingShapes = false;\n },\n _connectionsError: function () {\n this._loadingConnections = false;\n },\n _refreshShapes: function (e) {\n if (e.action === 'remove') {\n if (this._shouldRefresh()) {\n this._removeShapes(e.items);\n }\n } else if (e.action === 'itemchange') {\n if (this._shouldRefresh()) {\n this._updateShapes(e.items, e.field);\n }\n } else if (e.action === 'add') {\n this._inactiveShapeItems.add(e.items);\n } else if (e.action === 'sync') {\n this._syncShapes(e.items);\n } else {\n this.refresh();\n }\n },\n _shouldRefresh: function () {\n return !this._suspended;\n },\n _suspendModelRefresh: function () {\n this._suspended = (this._suspended || 0) + 1;\n },\n _resumeModelRefresh: function () {\n this._suspended = math.max((this._suspended || 0) - 1, 0);\n },\n refresh: function () {\n this._loadingShapes = false;\n if (!this._loadingConnections) {\n this._rebindShapesAndConnections();\n }\n },\n _rebindShapesAndConnections: function () {\n this.clear();\n this._addShapes(this.dataSource.view());\n if (this.connectionsDataSource) {\n this._addConnections(this.connectionsDataSource.view(), false);\n }\n if (this.options.layout) {\n this.layout(this.options.layout);\n } else {\n this._redrawConnections();\n }\n this.trigger('dataBound');\n },\n refreshConnections: function () {\n this._loadingConnections = false;\n if (!this._loadingShapes) {\n this._rebindShapesAndConnections();\n }\n },\n _redrawConnections: function () {\n var connections = this.connections;\n for (var idx = 0; idx < connections.length; idx++) {\n connections[idx].refresh();\n }\n },\n _removeShapes: function (items) {\n var dataMap = this._dataMap;\n var item, i;\n for (i = 0; i < items.length; i++) {\n item = items[i];\n if (dataMap[item.id]) {\n this.remove(dataMap[item.id], false);\n dataMap[item.id] = null;\n }\n }\n },\n _syncShapes: function () {\n var diagram = this;\n var inactiveItems = diagram._inactiveShapeItems;\n inactiveItems.forEach(function (inactiveItem) {\n var dataItem = inactiveItem.dataItem;\n var shape = inactiveItem.element;\n if (!dataItem.isNew()) {\n if (shape) {\n shape._setOptionsFromModel();\n diagram.addShape(shape, inactiveItem.undoable);\n diagram._dataMap[dataItem.id] = shape;\n } else {\n diagram._addDataItem(dataItem);\n }\n inactiveItem.activate();\n inactiveItems.remove(dataItem);\n }\n });\n },\n _updateShapes: function (items, field) {\n for (var i = 0; i < items.length; i++) {\n var dataItem = items[i];\n var shape = this._dataMap[dataItem.id];\n if (shape) {\n shape.updateOptionsFromModel(dataItem, field);\n }\n }\n },\n _addShapes: function (dataItems) {\n for (var i = 0; i < dataItems.length; i++) {\n this._addDataItem(dataItems[i], false);\n }\n },\n _refreshConnections: function (e) {\n if (e.action === 'remove') {\n if (this._shouldRefresh()) {\n this._removeConnections(e.items);\n }\n } else if (e.action === 'add') {\n this._addConnections(e.items);\n } else if (e.action === 'sync') {\n } else if (e.action === 'itemchange') {\n if (this._shouldRefresh()) {\n this._updateConnections(e.items);\n }\n } else {\n this.refreshConnections();\n }\n },\n _removeConnections: function (items) {\n for (var i = 0; i < items.length; i++) {\n this.remove(this._connectionsDataMap[items[i].uid], false);\n this._connectionsDataMap[items[i].uid] = null;\n }\n },\n _updateConnections: function (items) {\n for (var i = 0; i < items.length; i++) {\n var dataItem = items[i];\n var connection = this._connectionsDataMap[dataItem.uid];\n connection.updateOptionsFromModel(dataItem);\n }\n },\n _addConnections: function (connections, undoable) {\n var length = connections.length;\n for (var i = 0; i < length; i++) {\n var dataItem = connections[i];\n this._addConnectionDataItem(dataItem, undoable);\n }\n },\n _addConnectionDataItem: function (dataItem, undoable) {\n if (!this._connectionsDataMap[dataItem.uid]) {\n var from = this._validateConnector(dataItem.from);\n if (!defined(from) || from === null) {\n from = new Point(dataItem.fromX, dataItem.fromY);\n }\n var to = this._validateConnector(dataItem.to);\n if (!defined(to) || to === null) {\n to = new Point(dataItem.toX, dataItem.toY);\n }\n if (defined(from) && defined(to)) {\n var options = deepExtend({}, this.options.connectionDefaults);\n options.dataItem = dataItem;\n var connection = new Connection(from, to, options);\n this._connectionsDataMap[dataItem.uid] = connection;\n this.addConnection(connection, undoable);\n }\n }\n },\n _validateConnector: function (value) {\n var connector;\n if (defined(value) && value !== null) {\n connector = this._dataMap[value];\n }\n return connector;\n },\n _treeDataSource: function () {\n var that = this, options = that.options, dataSource = options.dataSource;\n dataSource = isArray(dataSource) ? { data: dataSource } : dataSource;\n if (dataSource instanceof kendo.data.DataSource && !(dataSource instanceof kendo.data.HierarchicalDataSource)) {\n throw new Error('Incorrect DataSource type. If a single dataSource instance is set to the diagram then it should be a HierarchicalDataSource. You should set only the options instead of an instance or a HierarchicalDataSource instance or supply connectionsDataSource as well.');\n }\n if (!dataSource.fields) {\n dataSource.fields = [\n { field: 'text' },\n { field: 'url' },\n { field: 'spriteCssClass' },\n { field: 'imageUrl' }\n ];\n }\n if (that.dataSource && that._refreshHandler) {\n that._unbindDataSource();\n }\n that._refreshHandler = proxy(that._refreshSource, that);\n that._errorHandler = proxy(that._error, that);\n that.dataSource = HierarchicalDataSource.create(dataSource).bind(CHANGE, that._refreshHandler).bind(ERROR, that._errorHandler);\n },\n _unbindDataSource: function () {\n var that = this;\n that.dataSource.unbind(CHANGE, that._refreshHandler).unbind(ERROR, that._errorHandler);\n },\n _adorn: function (adorner, isActive) {\n if (isActive !== undefined && adorner) {\n if (isActive) {\n this._adorners.push(adorner);\n this.adornerLayer.append(adorner.visual);\n } else {\n Utils.remove(this._adorners, adorner);\n this.adornerLayer.remove(adorner.visual);\n }\n }\n },\n _showConnectors: function (shape, value) {\n if (value) {\n this._connectorsAdorner.show(shape);\n } else {\n this._connectorsAdorner.destroy();\n }\n },\n _updateAdorners: function () {\n var adorners = this._adorners;\n for (var i = 0; i < adorners.length; i++) {\n var adorner = adorners[i];\n if (adorner.refreshBounds) {\n adorner.refreshBounds();\n }\n adorner.refresh();\n }\n },\n _refresh: function () {\n for (var i = 0; i < this.connections.length; i++) {\n this.connections[i].refresh();\n }\n },\n _destroyToolBar: function () {\n if (this.singleToolBar) {\n this.singleToolBar.hide();\n this.singleToolBar.destroy();\n this.singleToolBar = null;\n }\n },\n _destroyGlobalToolBar: function () {\n if (this.toolBar) {\n this.toolBar.hide();\n this.toolBar.destroy();\n this.toolBar = null;\n }\n },\n exportDOMVisual: function () {\n var viewBox = this.canvas._viewBox;\n var scrollOffset = geom.transform().translate(-viewBox.x, -viewBox.y);\n var viewRect = new geom.Rect([\n 0,\n 0\n ], [\n viewBox.width,\n viewBox.height\n ]);\n var clipPath = draw.Path.fromRect(viewRect);\n var wrap = new draw.Group({ transform: scrollOffset });\n var clipWrap = new draw.Group({ clip: clipPath });\n var root = this.canvas.drawingElement.children[0];\n clipWrap.append(wrap);\n wrap.children.push(root);\n return clipWrap;\n },\n exportVisual: function () {\n var scale = geom.transform().scale(1 / this._zoom);\n var wrap = new draw.Group({ transform: scale });\n var root = this.mainLayer.drawingElement;\n wrap.children.push(root);\n return wrap;\n },\n _syncChanges: function () {\n this._syncShapeChanges();\n this._syncConnectionChanges();\n },\n _syncShapeChanges: function () {\n if (this.dataSource && this._isEditable) {\n this.dataSource.sync();\n }\n },\n _syncConnectionChanges: function () {\n var that = this;\n if (that.connectionsDataSource && that._isEditable) {\n $.when.apply($, that._deferredConnectionUpdates).then(function () {\n that.connectionsDataSource.sync();\n });\n that.deferredConnectionUpdates = [];\n }\n }\n });\n dataviz.ExportMixin.extend(Diagram.fn, true);\n if (kendo.PDFMixin) {\n kendo.PDFMixin.extend(Diagram.fn);\n }\n function filterShapeDataItem(dataItem) {\n var result = {};\n dataItem = dataItem || {};\n if (defined(dataItem.text) && dataItem.text !== null) {\n result.text = dataItem.text;\n }\n if (defined(dataItem.x) && dataItem.x !== null) {\n result.x = dataItem.x;\n }\n if (defined(dataItem.y) && dataItem.y !== null) {\n result.y = dataItem.y;\n }\n if (defined(dataItem.width) && dataItem.width !== null) {\n result.width = dataItem.width;\n }\n if (defined(dataItem.height) && dataItem.height !== null) {\n result.height = dataItem.height;\n }\n if (defined(dataItem.type) && dataItem.type !== null) {\n result.type = dataItem.type;\n }\n return result;\n }\n function filterConnectionDataItem(dataItem) {\n var result = {};\n dataItem = dataItem || {};\n if (defined(dataItem.text) && dataItem.text !== null) {\n result.content = dataItem.text;\n }\n if (defined(dataItem.type) && dataItem.type !== null) {\n result.type = dataItem.type;\n }\n if (defined(dataItem.from) && dataItem.from !== null) {\n result.from = dataItem.from;\n }\n if (defined(dataItem.fromConnector) && dataItem.fromConnector !== null) {\n result.fromConnector = dataItem.fromConnector;\n }\n if (defined(dataItem.fromX) && dataItem.fromX !== null) {\n result.fromX = dataItem.fromX;\n }\n if (defined(dataItem.fromY) && dataItem.fromY !== null) {\n result.fromY = dataItem.fromY;\n }\n if (defined(dataItem.to) && dataItem.to !== null) {\n result.to = dataItem.to;\n }\n if (defined(dataItem.toConnector) && dataItem.toConnector !== null) {\n result.toConnector = dataItem.toConnector;\n }\n if (defined(dataItem.toX) && dataItem.toX !== null) {\n result.toX = dataItem.toX;\n }\n if (defined(dataItem.toY) && dataItem.toY !== null) {\n result.toY = dataItem.toY;\n }\n return result;\n }\n var DiagramToolBar = kendo.Observable.extend({\n init: function (diagram, options) {\n kendo.Observable.fn.init.call(this);\n this.diagram = diagram;\n this.options = deepExtend({}, this.options, options);\n this._tools = [];\n this.createToolBar();\n this.createTools();\n this.appendTools();\n if (this.options.modal) {\n this.createPopup();\n }\n this.bind(this.events, options);\n },\n events: ['click'],\n createPopup: function () {\n this.container = $('
').append(this.element);\n this._popup = this.container.kendoPopup({}).getKendoPopup();\n },\n appendTools: function () {\n for (var i = 0; i < this._tools.length; i++) {\n var tool = this._tools[i];\n if (tool.buttons && tool.buttons.length || !defined(tool.buttons)) {\n this._toolBar.add(tool);\n }\n }\n },\n createToolBar: function () {\n this.element = $('
');\n this._toolBar = this.element.kendoToolBar({\n click: proxy(this.click, this),\n resizable: false\n }).getKendoToolBar();\n this.element.css('border', 'none');\n },\n createTools: function () {\n for (var i = 0; i < this.options.tools.length; i++) {\n this.createTool(this.options.tools[i]);\n }\n },\n createTool: function (tool) {\n if (!isPlainObject(tool)) {\n tool = { name: tool };\n }\n var toolName = tool.name + 'Tool';\n if (this[toolName]) {\n this[toolName](tool);\n } else {\n this._tools.push(deepExtend({}, tool, { attributes: this._setAttributes({ action: tool.name }) }));\n }\n },\n showAt: function (point) {\n if (this._popup) {\n this._popup.open(point.x, point.y);\n }\n },\n hide: function () {\n if (this._popup) {\n this._popup.close();\n }\n },\n newGroup: function () {\n return {\n type: 'buttonGroup',\n buttons: []\n };\n },\n editTool: function () {\n this._tools.push({\n icon: 'edit',\n showText: 'overflow',\n type: 'button',\n text: 'Edit',\n attributes: this._setAttributes({ action: 'edit' })\n });\n },\n deleteTool: function () {\n this._tools.push({\n icon: 'close',\n showText: 'overflow',\n type: 'button',\n text: 'Delete',\n attributes: this._setAttributes({ action: 'delete' })\n });\n },\n rotateAnticlockwiseTool: function (options) {\n this._appendGroup('rotate');\n this._rotateGroup.buttons.push({\n icon: 'rotate-left',\n showText: 'overflow',\n text: 'RotateAnticlockwise',\n group: 'rotate',\n attributes: this._setAttributes({\n action: 'rotateAnticlockwise',\n step: options.step\n })\n });\n },\n rotateClockwiseTool: function (options) {\n this._appendGroup('rotate');\n this._rotateGroup.buttons.push({\n icon: 'rotate-right',\n attributes: this._setAttributes({\n action: 'rotateClockwise',\n step: options.step\n }),\n showText: 'overflow',\n text: 'RotateClockwise',\n group: 'rotate'\n });\n },\n createShapeTool: function () {\n this._appendGroup('create');\n this._createGroup.buttons.push({\n icon: 'shape',\n showText: 'overflow',\n text: 'CreateShape',\n group: 'create',\n attributes: this._setAttributes({ action: 'createShape' })\n });\n },\n createConnectionTool: function () {\n this._appendGroup('create');\n this._createGroup.buttons.push({\n icon: 'connector',\n showText: 'overflow',\n text: 'CreateConnection',\n group: 'create',\n attributes: this._setAttributes({ action: 'createConnection' })\n });\n },\n undoTool: function () {\n this._appendGroup('history');\n this._historyGroup.buttons.push({\n icon: 'undo',\n showText: 'overflow',\n text: 'Undo',\n group: 'history',\n attributes: this._setAttributes({ action: 'undo' })\n });\n },\n redoTool: function () {\n this._appendGroup('history');\n this._historyGroup.buttons.push({\n icon: 'redo',\n showText: 'overflow',\n text: 'Redo',\n group: 'history',\n attributes: this._setAttributes({ action: 'redo' })\n });\n },\n _appendGroup: function (name) {\n var prop = '_' + name + 'Group';\n if (!this[prop]) {\n this[prop] = this.newGroup();\n this._tools.push(this[prop]);\n }\n },\n _setAttributes: function (attributes) {\n var attr = {};\n if (attributes.action) {\n attr[kendo.attr('action')] = attributes.action;\n }\n if (attributes.step) {\n attr[kendo.attr('step')] = attributes.step;\n }\n return attr;\n },\n _getAttributes: function (element) {\n var attr = {};\n var action = element.attr(kendo.attr('action'));\n if (action) {\n attr.action = action;\n }\n var step = element.attr(kendo.attr('step'));\n if (step) {\n attr.step = step;\n }\n return attr;\n },\n click: function (e) {\n var attributes = this._getAttributes($(e.target));\n var action = attributes.action;\n if (action && this[action]) {\n this[action](attributes);\n }\n this.trigger('click', this.eventData(action, e.target));\n },\n eventData: function (action, target) {\n var elements = this.selectedElements(), length = elements.length, shapes = [], connections = [], element;\n for (var idx = 0; idx < length; idx++) {\n element = elements[idx];\n if (element instanceof Shape) {\n shapes.push(element);\n } else {\n connections.push(element);\n }\n }\n return {\n shapes: shapes,\n connections: connections,\n action: action,\n target: target\n };\n },\n 'delete': function () {\n var diagram = this.diagram;\n var toRemove = diagram._triggerRemove(this.selectedElements());\n if (toRemove.length) {\n this.diagram.remove(toRemove, true);\n this.diagram._syncChanges();\n }\n },\n edit: function () {\n var selectedElemens = this.selectedElements();\n if (selectedElemens.length === 1) {\n this.diagram.edit(selectedElemens[0]);\n }\n },\n rotateClockwise: function (options) {\n var angle = parseFloat(options.step || 90);\n this._rotate(angle);\n },\n rotateAnticlockwise: function (options) {\n var angle = parseFloat(options.step || 90);\n this._rotate(-angle);\n },\n _rotate: function (angle) {\n var adorner = this.diagram._resizingAdorner;\n adorner.angle(adorner.angle() + angle);\n adorner.rotate();\n },\n selectedElements: function () {\n return this.diagram.select();\n },\n createShape: function () {\n this.diagram.createShape();\n },\n createConnection: function () {\n this.diagram.createConnection();\n },\n undo: function () {\n this.diagram.undo();\n },\n redo: function () {\n this.diagram.redo();\n },\n destroy: function () {\n this.diagram = null;\n this.element = null;\n this.options = null;\n if (this._toolBar) {\n this._toolBar.destroy();\n }\n if (this._popup) {\n this._popup.destroy();\n }\n }\n });\n var Editor = kendo.Observable.extend({\n init: function (element, options) {\n kendo.Observable.fn.init.call(this);\n this.options = extend(true, {}, this.options, options);\n this.element = element;\n this.model = this.options.model;\n this.fields = this._getFields();\n this._initContainer();\n this.createEditable();\n },\n options: { editors: {} },\n _initContainer: function () {\n this.wrapper = this.element;\n },\n createEditable: function () {\n var options = this.options;\n this.editable = new kendo.ui.Editable(this.wrapper, {\n fields: this.fields,\n target: options.target,\n clearContainer: false,\n model: this.model\n });\n },\n _isEditable: function (field) {\n return this.model.editable && this.model.editable(field);\n },\n _getFields: function () {\n var fields = [];\n var modelFields = this.model.fields;\n for (var field in modelFields) {\n var result = {};\n if (this._isEditable(field)) {\n var editor = this.options.editors[field];\n if (editor) {\n result.editor = editor;\n }\n result.field = field;\n fields.push(result);\n }\n }\n return fields;\n },\n end: function () {\n return this.editable.end();\n },\n destroy: function () {\n this.editable.destroy();\n this.editable.element.find('[' + kendo.attr('container-for') + ']').empty();\n this.model = this.wrapper = this.element = this.columns = this.editable = null;\n }\n });\n var PopupEditor = Editor.extend({\n init: function (element, options) {\n Editor.fn.init.call(this, element, options);\n this.bind(this.events, this.options);\n this.open();\n },\n events: [\n 'update',\n 'cancel'\n ],\n options: {\n window: {\n modal: true,\n resizable: false,\n draggable: true,\n title: 'Edit',\n visible: false\n }\n },\n _initContainer: function () {\n var that = this;\n this.wrapper = $('
').attr(kendo.attr('uid'), this.model.uid);\n var formContent = '';\n if (this.options.template) {\n formContent += this._renderTemplate();\n this.fields = [];\n } else {\n formContent += this._renderFields();\n }\n formContent += this._renderButtons();\n this.wrapper.append($('
').append(formContent));\n this.window = new kendo.ui.Window(this.wrapper.appendTo(this.element), this.options.window);\n this.window.bind('close', function (e) {\n if (e.userTriggered) {\n e.sender.element.focus();\n that._cancelClick(e);\n }\n });\n this._attachButtonEvents();\n },\n _renderTemplate: function () {\n var template = this.options.template;\n if (typeof template === 'string') {\n template = window.unescape(template);\n }\n template = kendo.template(template)(this.model);\n return template;\n },\n _renderFields: function () {\n var form = '';\n for (var i = 0; i < this.fields.length; i++) {\n var field = this.fields[i];\n form += '
';\n if (this._isEditable(field.field)) {\n form += '
';\n }\n }\n return form;\n },\n _renderButtons: function () {\n var form = '
';\n form += this._createButton('update');\n form += this._createButton('cancel');\n form += '
';\n return form;\n },\n _createButton: function (name) {\n return kendo.template(BUTTON_TEMPLATE)(defaultButtons[name]);\n },\n _attachButtonEvents: function () {\n this._cancelClickHandler = proxy(this._cancelClick, this);\n this.window.element.on(CLICK + NS, 'a.k-diagram-cancel', this._cancelClickHandler);\n this._updateClickHandler = proxy(this._updateClick, this);\n this.window.element.on(CLICK + NS, 'a.k-diagram-update', this._updateClickHandler);\n },\n _updateClick: function (e) {\n e.preventDefault();\n this.trigger('update');\n },\n _cancelClick: function (e) {\n e.preventDefault();\n this.trigger('cancel');\n },\n open: function () {\n this.window.center().open();\n },\n close: function () {\n this.window.bind('deactivate', proxy(this.destroy, this)).close();\n },\n destroy: function () {\n this.window.close().destroy();\n this.window.element.off(CLICK + NS, 'a.k-diagram-cancel', this._cancelClickHandler);\n this.window.element.off(CLICK + NS, 'a.k-diagram-update', this._updateClickHandler);\n this._cancelClickHandler = null;\n this._editUpdateClickHandler = null;\n this.window = null;\n Editor.fn.destroy.call(this);\n }\n });\n function connectionSelector(container, options) {\n var model = this.dataSource.reader.model;\n if (model) {\n var textField = model.fn.fields.text ? 'text' : model.idField;\n $('').appendTo(container).kendoDropDownList({\n dataValueField: model.idField,\n dataTextField: textField,\n dataSource: this.dataSource.data().toJSON(),\n optionLabel: ' ',\n valuePrimitive: true\n });\n }\n }\n function InactiveItem(dataItem) {\n this.dataItem = dataItem;\n this.callbacks = [];\n }\n InactiveItem.fn = InactiveItem.prototype = {\n onActivate: function (callback) {\n var deffered = $.Deferred();\n this.callbacks.push({\n callback: callback,\n deferred: deffered\n });\n return deffered;\n },\n activate: function () {\n var callbacks = this.callbacks;\n var item;\n for (var idx = 0; idx < callbacks.length; idx++) {\n item = this.callbacks[idx];\n item.callback(this.dataItem);\n item.deferred.resolve();\n }\n this.callbacks = [];\n }\n };\n function InactiveItemsCollection() {\n this.items = {};\n }\n InactiveItemsCollection.fn = InactiveItemsCollection.prototype = {\n add: function (items) {\n for (var idx = 0; idx < items.length; idx++) {\n this.items[items[idx].uid] = new InactiveItem(items[idx]);\n }\n },\n forEach: function (callback) {\n for (var uid in this.items) {\n callback(this.items[uid]);\n }\n },\n getByUid: function (uid) {\n return this.items[uid];\n },\n remove: function (item) {\n delete this.items[item.uid];\n }\n };\n var QuadRoot = Class.extend({\n init: function () {\n this.shapes = [];\n },\n _add: function (shape, bounds) {\n this.shapes.push({\n bounds: bounds,\n shape: shape\n });\n shape._quadNode = this;\n },\n insert: function (shape, bounds) {\n this._add(shape, bounds);\n },\n remove: function (shape) {\n var shapes = this.shapes;\n var length = shapes.length;\n for (var idx = 0; idx < length; idx++) {\n if (shapes[idx].shape === shape) {\n shapes.splice(idx, 1);\n break;\n }\n }\n },\n hitTestRect: function (rect, exclude) {\n var shapes = this.shapes;\n var length = shapes.length;\n for (var i = 0; i < length; i++) {\n if (this._testRect(shapes[i].shape, rect) && !dataviz.inArray(shapes[i].shape, exclude)) {\n return true;\n }\n }\n },\n _testRect: function (shape, rect) {\n var angle = shape.rotate().angle;\n var bounds = shape.bounds();\n var hit;\n if (!angle) {\n hit = bounds.overlaps(rect);\n } else {\n hit = Intersect.rects(rect, bounds, -angle);\n }\n return hit;\n }\n });\n var QuadNode = QuadRoot.extend({\n init: function (rect) {\n QuadRoot.fn.init.call(this);\n this.children = [];\n this.rect = rect;\n },\n inBounds: function (rect) {\n var nodeRect = this.rect;\n var nodeBottomRight = nodeRect.bottomRight();\n var bottomRight = rect.bottomRight();\n var inBounds = nodeRect.x <= rect.x && nodeRect.y <= rect.y && bottomRight.x <= nodeBottomRight.x && bottomRight.y <= nodeBottomRight.y;\n return inBounds;\n },\n overlapsBounds: function (rect) {\n return this.rect.overlaps(rect);\n },\n insert: function (shape, bounds) {\n var inserted = false;\n var children = this.children;\n var length = children.length;\n if (this.inBounds(bounds)) {\n if (!length && this.shapes.length < 4) {\n this._add(shape, bounds);\n } else {\n if (!length) {\n this._initChildren();\n }\n for (var idx = 0; idx < children.length; idx++) {\n if (children[idx].insert(shape, bounds)) {\n inserted = true;\n break;\n }\n }\n if (!inserted) {\n this._add(shape, bounds);\n }\n }\n inserted = true;\n }\n return inserted;\n },\n _initChildren: function () {\n var rect = this.rect, children = this.children, shapes = this.shapes, center = rect.center(), halfWidth = rect.width / 2, halfHeight = rect.height / 2, childIdx, shapeIdx;\n children.push(new QuadNode(new Rect(rect.x, rect.y, halfWidth, halfHeight)), new QuadNode(new Rect(center.x, rect.y, halfWidth, halfHeight)), new QuadNode(new Rect(rect.x, center.y, halfWidth, halfHeight)), new QuadNode(new Rect(center.x, center.y, halfWidth, halfHeight)));\n for (shapeIdx = shapes.length - 1; shapeIdx >= 0; shapeIdx--) {\n for (childIdx = 0; childIdx < children.length; childIdx++) {\n if (children[childIdx].insert(shapes[shapeIdx].shape, shapes[shapeIdx].bounds)) {\n shapes.splice(shapeIdx, 1);\n break;\n }\n }\n }\n },\n hitTestRect: function (rect, exclude) {\n var idx;\n var children = this.children;\n var length = children.length;\n var hit = false;\n if (this.overlapsBounds(rect)) {\n if (QuadRoot.fn.hitTestRect.call(this, rect, exclude)) {\n hit = true;\n } else {\n for (idx = 0; idx < length; idx++) {\n if (children[idx].hitTestRect(rect, exclude)) {\n hit = true;\n break;\n }\n }\n }\n }\n return hit;\n }\n });\n var ShapesQuadTree = Class.extend({\n ROOT_SIZE: 1000,\n init: function (diagram) {\n var boundsChangeHandler = proxy(this._boundsChange, this);\n diagram.bind(ITEMBOUNDSCHANGE, boundsChangeHandler);\n diagram.bind(ITEMROTATE, boundsChangeHandler);\n this.initRoots();\n },\n initRoots: function () {\n this.rootMap = {};\n this.root = new QuadRoot();\n },\n clear: function () {\n this.initRoots();\n },\n _boundsChange: function (e) {\n if (e.item._quadNode) {\n e.item._quadNode.remove(e.item);\n }\n this.insert(e.item);\n },\n insert: function (shape) {\n var bounds = shape.bounds(ROTATED);\n var rootSize = this.ROOT_SIZE;\n var sectors = this.getSectors(bounds);\n var x = sectors[0][0];\n var y = sectors[1][0];\n if (this.inRoot(sectors)) {\n this.root.insert(shape, bounds);\n } else {\n if (!this.rootMap[x]) {\n this.rootMap[x] = {};\n }\n if (!this.rootMap[x][y]) {\n this.rootMap[x][y] = new QuadNode(new Rect(x * rootSize, y * rootSize, rootSize, rootSize));\n }\n this.rootMap[x][y].insert(shape, bounds);\n }\n },\n remove: function (shape) {\n if (shape._quadNode) {\n shape._quadNode.remove(shape);\n }\n },\n inRoot: function (sectors) {\n return sectors[0].length > 1 || sectors[1].length > 1;\n },\n getSectors: function (rect) {\n var rootSize = this.ROOT_SIZE;\n var bottomRight = rect.bottomRight();\n var bottomX = math.floor(bottomRight.x / rootSize);\n var bottomY = math.floor(bottomRight.y / rootSize);\n var sectors = [\n [],\n []\n ];\n for (var x = math.floor(rect.x / rootSize); x <= bottomX; x++) {\n sectors[0].push(x);\n }\n for (var y = math.floor(rect.y / rootSize); y <= bottomY; y++) {\n sectors[1].push(y);\n }\n return sectors;\n },\n hitTestRect: function (rect, exclude) {\n var sectors = this.getSectors(rect);\n var xIdx, yIdx, x, y;\n var root;\n if (this.root.hitTestRect(rect, exclude)) {\n return true;\n }\n for (xIdx = 0; xIdx < sectors[0].length; xIdx++) {\n x = sectors[0][xIdx];\n for (yIdx = 0; yIdx < sectors[1].length; yIdx++) {\n y = sectors[1][yIdx];\n root = (this.rootMap[x] || {})[y];\n if (root && root.hitTestRect(rect, exclude)) {\n return true;\n }\n }\n }\n return false;\n }\n });\n function cloneDataItem(dataItem) {\n var result = dataItem;\n if (dataItem instanceof kendo.data.Model) {\n result = dataItem.toJSON();\n result[dataItem.idField] = dataItem._defaultId;\n }\n return result;\n }\n function splitDiagramElements(elements) {\n var connections = [];\n var shapes = [];\n var element, idx;\n for (idx = 0; idx < elements.length; idx++) {\n element = elements[idx];\n if (element instanceof Shape) {\n shapes.push(element);\n } else {\n connections.push(element);\n }\n }\n return {\n shapes: shapes,\n connections: connections\n };\n }\n function createModel(dataSource, model) {\n if (dataSource.reader.model) {\n return new dataSource.reader.model(model);\n }\n return new kendo.data.ObservableObject(model);\n }\n function clearField(field, model) {\n if (defined(model[field])) {\n model.set(field, null);\n }\n }\n function copyDefaultOptions(mainOptions, elementOptions, fields) {\n var field;\n for (var idx = 0; idx < fields.length; idx++) {\n field = fields[idx];\n if (elementOptions && !defined(elementOptions[field])) {\n elementOptions[field] = mainOptions[field];\n }\n }\n }\n function translateToOrigin(visual) {\n var bbox = visual.drawingContainer().clippedBBox(null);\n if (bbox.origin.x !== 0 || bbox.origin.y !== 0) {\n visual.position(-bbox.origin.x, -bbox.origin.y);\n }\n }\n function preventDefault(e) {\n e.preventDefault();\n }\n dataviz.ui.plugin(Diagram);\n deepExtend(diagram, {\n Shape: Shape,\n Connection: Connection,\n Connector: Connector,\n DiagramToolBar: DiagramToolBar,\n QuadNode: QuadNode,\n QuadRoot: QuadRoot,\n ShapesQuadTree: ShapesQuadTree,\n PopupEditor: PopupEditor\n });\n }(window.kendo.jQuery));\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));\n(function (f, define) {\n define('kendo.dataviz.diagram', [\n 'kendo.data',\n 'kendo.draganddrop',\n 'kendo.userevents',\n 'kendo.mobile.scroller',\n 'kendo.drawing',\n 'dataviz/diagram/utils',\n 'dataviz/diagram/math',\n 'dataviz/diagram/svg',\n 'dataviz/diagram/services',\n 'dataviz/diagram/layout',\n 'dataviz/diagram/dom'\n ], f);\n}(function () {\n var __meta__ = {\n id: 'dataviz.diagram',\n name: 'Diagram',\n category: 'dataviz',\n description: 'The Kendo DataViz Diagram ',\n depends: [\n 'data',\n 'userevents',\n 'mobile.scroller',\n 'draganddrop',\n 'drawing',\n 'dataviz.core',\n 'dataviz.themes',\n 'toolbar'\n ],\n features: [\n {\n id: 'dataviz.diagram-pdf-export',\n name: 'PDF export',\n description: 'Export Diagram as PDF',\n depends: ['pdf']\n },\n {\n id: 'dataviz.diagram-editing',\n name: 'Editing',\n description: 'Support for model editing',\n depends: [\n 'editable',\n 'window',\n 'dropdownlist'\n ]\n }\n ]\n };\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}