{"version":3,"sources":["webpack:///./node_modules/pathfinding/src/finders/DijkstraFinder.js","webpack:///./src/components/AlgorithmDef/shapes/line.js","webpack:///./src/components/AlgorithmDef/shapes/rect.js","webpack:///./node_modules/pathfinding/src/finders/AStarFinder.js","webpack:///./node_modules/pathfinding/src/core/Heuristic.js","webpack:///./node_modules/heap/lib/heap.js","webpack:///./node_modules/heap/index.js","webpack:///./node_modules/pathfinding/src/core/Util.js","webpack:///./src/service/lineDrawService.js","webpack:///./node_modules/pathfinding/src/finders/BiBestFirstFinder.js","webpack:///./node_modules/pathfinding/src/core/Node.js","webpack:///./node_modules/pathfinding/src/finders/IDAStarFinder.js","webpack:///./node_modules/pathfinding/src/finders/JumpPointFinderBase.js","webpack:///./node_modules/pathfinding/src/finders/JPFNeverMoveDiagonally.js","webpack:///./node_modules/pathfinding/src/finders/BiAStarFinder.js","webpack:///./node_modules/pathfinding/src/finders/BreadthFirstFinder.js","webpack:///./node_modules/pathfinding/src/finders/BiDijkstraFinder.js","webpack:///./node_modules/pathfinding/src/core/DiagonalMovement.js","webpack:///./node_modules/pathfinding/src/core/Grid.js","webpack:///./node_modules/pathfinding/src/finders/BiBreadthFirstFinder.js","webpack:///./node_modules/pathfinding/index.js","webpack:///./src/components/AlgorithmDef/shapes/funcs.js","webpack:///./node_modules/pathfinding/src/finders/JumpPointFinder.js","webpack:///./node_modules/pathfinding/src/finders/JPFMoveDiagonallyIfAtMostOneObstacle.js","webpack:///./node_modules/pathfinding/src/finders/BestFirstFinder.js","webpack:///./node_modules/pathfinding/src/finders/JPFAlwaysMoveDiagonally.js","webpack:///./node_modules/pathfinding/src/finders/JPFMoveDiagonallyIfNoObstacles.js","webpack:///./node_modules/pathfinding/src/PathFinding.js"],"names":["AStarFinder","DijkstraFinder","opt","call","this","heuristic","dx","dy","prototype","constructor","module","exports","SchemaLine","line","type","edit","svgView","Snap","a","group","startDrag","prevLine","nextLine","draw","dragNDrop","path","makepath","p","x","y","i","length","v","h","end","groupX","groupY","dX","dY","dA","m","attr","svgLineShadow","start","hover","draggableCircle","svgLine","append","circle","remove","mousedown","e","preventDefault","originClick","clientX","clientY","originPosition","$","mousemove","changeLenght","ind","document","mouseup","changeComplete","Object","assign","defPoint","Rect","id","width","height","text","url1","docId","subtype","yesno","lineDrawService","leftNode","topNode","rightNode","bottomNode","url2","url3","console","log","id1","dir1","nodes","view","circles","startDragAndDrop","startDrawLine","prevParam","point","DragAndDropClickPoint","dndTmpPoint","g","size","drawLines","addCirles","addListenerToHover","dragAndDrop","addEventListener","events","DIRECTION","params","lineComplate","DRAGANDDROP","reDrawLines","UPDATE_RECT","update","REMOVE_SHAPE","removeShape","res","textView","createText","node","getBoundingClientRect","changeWidth","checkTextWidth","currentSize","sizeRect","rect","getNextSize","getSizeRect","shape","polygon","undefined","createHint","el","createKK","click","dispatchEvent","SELECT_RECT","push","getCircle","getLastItem","offsetX","offsetY","dir","getDirection","getCirclePoint","forEach","id2","removeNodeLines","dir2","item","unmousedown","removeEventListener","changeMap","changeLineStartPoint","points","drawLine","unshift","getFirstLine","getLastLine","dir2Point","convertPointToA","step","target","tagName","offset","left","scrollTop","top","newPosition","Math","round","circlePointStart","circlePointEnd","lines","getLines","index","Heap","Util","Heuristic","DiagonalMovement","allowDiagonal","dontCrossCorners","manhattan","weight","diagonalMovement","OnlyWhenNoObstacles","IfAtMostOneObstacle","Never","octile","findPath","startX","startY","endX","endY","grid","neighbors","neighbor","l","ng","openList","nodeA","nodeB","f","startNode","getNodeAt","endNode","abs","SQRT2","opened","empty","pop","closed","backtrace","getNeighbors","parent","updateItem","euclidean","sqrt","F","chebyshev","max","defaultCmp","floor","heapify","heappop","heappush","heappushpop","heapreplace","insort","min","nlargest","nsmallest","_siftdown","_siftup","lo","hi","cmp","mid","Error","splice","apply","concat","array","lastelt","returnitem","_ref","_i","_len","_ref1","_results","_results1","_j","reverse","pos","indexOf","n","elem","result","slice","sort","los","startpos","newitem","parentpos","childpos","endpos","rightpos","replace","pushpop","peek","contains","clear","clone","heap","toArray","insert","front","has","copy","window","biBacktrace","pathA","pathB","pathLength","b","sum","interpolate","x0","y0","x1","y1","sx","sy","err","e2","expandPath","coord0","coord1","interpolated","interpolatedLen","j","expanded","len","smoothenPath","ex","ey","newPath","coord","testCoord","blocked","isWalkableAt","lastValidCoord","compressPath","lx","ly","ldx","ldy","sq","compressed","px","py","HOVER","CONNECT","pathFinder","listeners","initGrid","items","PF","Grid","finder","JumpPointFinder","trackJumpRecursion","updateGrid","ceil","x2","y2","setWalkableAt","shapeTmp","filter","pointFrom","pointTo","eventType","handler","BiAStarFinder","BiBestFirstFinder","orig","Node","walkable","IDAStarFinder","trackRecursion","timeLimit","Infinity","route","t","startTime","Date","getTime","bind","cost","search","cutoff","depth","k","neighbour","neighbours","retainCount","tested","cutOff","JumpPointFinderBase","_identifySuccessors","jumpPoint","jx","jy","d","jumpNode","_findNeighbors","_jump","JPFNeverMoveDiagonally","neighborNodes","neighborNode","startOpenList","endOpenList","BY_START","BY_END","BreadthFirstFinder","shift","BiDijkstraFinder","Always","width_or_matrix","matrix","_buildNodes","Array","isInside","s0","d0","s1","d1","s2","d2","s3","d3","thisNodes","newGrid","newNodes","BiBreadthFirstFinder","by","$state","rows","split","class","row","spans","tmpRow","textContent","getBBox","objid","selectAll","cnt","toString","onclick","router","arr","map","prevItem","optimizePath","currentPoint","foundedIndex","direct","o","s","transform","stroke","style","c","fill","event","tooltip","getElementById","innerHTML","display","pageX","pageY","onmouseout","_","optPoints","dif","tmp","JPFAlwaysMoveDiagonally","JPFMoveDiagonallyIfNoObstacles","JPFMoveDiagonallyIfAtMostOneObstacle","BestFirstFinder","isNextWalkable","isTopWalkable","isBottomWalkable","isRightWalkable","isLeftWalkable"],"mappings":"qGAAA,IAAIA,EAAc,EAAQ,QAa1B,SAASC,EAAeC,GACpBF,EAAYG,KAAKC,KAAMF,GACvBE,KAAKC,UAAY,SAASC,EAAIC,GAC1B,OAAO,GAIfN,EAAeO,UAAY,IAAIR,EAC/BC,EAA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BM,qBACpDxJ,EAAI,EAAGoK,EAAIqL,EAAcxV,OAAQD,EAAIoK,IAAKpK,EAC3C0V,EAAeD,EAAczV,GAC7BkK,EAAU1D,KAAK,CAACkP,EAAa5V,EAAG4V,EAAa3V,IAIrD,OAAOmK,GAGXtL,EAAOC,QAAUkb,G,qBC7KjBnb,EAAOC,QAAU,CACb,KAA8B,EAAQ,QACtC,KAA8B,EAAQ,QACtC,KAA8B,EAAQ,QACtC,KAA8B,EAAQ,QACtC,iBAA8B,EAAQ,QACtC,UAA8B,EAAQ,QACtC,YAA8B,EAAQ,QACtC,gBAA8B,EAAQ,QACtC,mBAA8B,EAAQ,QACtC,eAA8B,EAAQ,QACtC,cAA8B,EAAQ,QACtC,kBAA8B,EAAQ,QACtC,qBAA8B,EAAQ,QACtC,iBAA8B,EAAQ,QACtC,cAA8B,EAAQ,QACtC,gBAA8B,EAAQ","file":"js/chunk-22f4fbe2.799cf74b.js","sourcesContent":["var AStarFinder = require('./AStarFinder');\r\n\r\n/**\r\n * Dijkstra path-finder.\r\n * @constructor\r\n * @extends AStarFinder\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n */\r\nfunction DijkstraFinder(opt) {\r\n AStarFinder.call(this, opt);\r\n this.heuristic = function(dx, dy) {\r\n return 0;\r\n };\r\n}\r\n\r\nDijkstraFinder.prototype = new AStarFinder();\r\nDijkstraFinder.prototype.constructor = DijkstraFinder;\r\n\r\nmodule.exports = DijkstraFinder;\r\n","import $ from 'jquery'\r\nexport default class SchemaLine {\r\n\tconstructor(line, type, edit) {\r\n\t\tthis.svgView = Snap(\"#diagramSvg\");\r\n\t\tthis.line = line;\r\n\t\tthis.a = line.a;\r\n\t\tthis.type = type;\r\n\t\tthis.edit = true;\r\n\t\tthis.group = this.svgView.group();\r\n\t\tthis.startDrag = false;\r\n\t\tthis.prevLine = {}\r\n\t\tthis.nextLine = {}\r\n\t\tthis.draw();\r\n\t\tthis.dragNDrop();\r\n\t}\r\n\r\n\tdraw () {\r\n\t\tthis.path = [];\r\n\t\tlet x,y;\r\n\r\n\t\tthis.makepath = a => {\r\n\t\t\t//var a = l.a;\r\n\t\t\tvar p = \"M \" + a[0].x + \" \" + a[0].y + \" \";\r\n\t\t\tfor (var i = 1; i < a.length - 1; i++) {\r\n\t\t\t\tif (a[i].v) {\r\n\t\t\t\t\tvar dy = (a[i].y < a[i - 1].y) ? -8 : 8;\r\n\t\t\t\t\tvar dx = (a[i].x < a[i + 1].x) ? 8 : -8;\r\n\t\t\t\t\tp = p + \" V \" + (a[i].y - dy) + \" c 0 \" + dy + \" 0 \" + dy + \" \" + dx + \" \" + dy;\r\n\t\t\t\t}\r\n\t\t\t\tif (a[i].h) {\r\n\t\t\t\t\tvar dy = (a[i].y < a[i + 1].y) ? 8 : -8;\r\n\t\t\t\t\tvar dx = (a[i].x < a[i - 1].x) ? -8 : 8;\r\n\t\t\t\t\tp = p + \" H \" + (a[i].x - dx) + \" c \" + dx + \" 0 \" + dx + \" 0 \" + dx + \" \" + dy;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar i = a.length - 1;\r\n\t\t\tif (a[i].v) {\r\n\t\t\t\tvar dy = (a[i].y > a[i - 1].y) ? 0 : -0;\r\n\t\t\t\tif (this.line.end) {\r\n \t var dy = (a[i].y > a[i - 1].y) ? 14 : -14;\r\n\t\t\t\t}\r\n\t\t\t\tp = p + \" V \" + (a[i].y - dy);\r\n\t\t\t}\r\n\t\t\tif (a[i].h) {\r\n\t\t\t\tvar dx = (a[i].x > a[i - 1].x) ? 0 : -0;\r\n\t\t\t\tif (this.line.end) {\r\n \tvar dx = (a[i].x > a[i - 1].x) ? 14 : -14;\r\n\t\t\t\t}\r\n\t\t\t\tp = p + \" H \" + (a[i].x - dx);\r\n\t\t\t}\r\n\t\t\treturn p;\r\n\t\t};\r\n\r\n\r\n\t\tthis.groupX = this.line.a[0].x;\r\n\t\tthis.groupY = this.line.a[0].y;\r\n \tlet dX = this.line.a[1].x - this.line.a[0].x;\r\n \tlet dY = this.line.a[1].y - this.line.a[0].y;\r\n \tlet dA = [\r\n \t\t{\r\n \t\t\tx: 0, \r\n \t\t\ty: 0, \r\n \t\t\tm:true\r\n \t\t}, \r\n \t\t{\r\n \t\t\tx: dX, \r\n \t\t\ty: dY, \r\n \t\t\tv:this.line.a[1].v, \r\n \t\t\th:this.line.a[1].h\r\n \t\t}\r\n\t\t];\r\n\t\tthis.path = this.makepath(dA);\r\n\t\tthis.group.attr({\r\n \t\"transform\": `matrix(1,0,0,1,${this.groupX},${this.groupY})`\r\n\t\t});\r\n\r\n\t this.svgLineShadow = this.svgView.path(this.path)\r\n\t\t\t.attr({\r\n\t\t\t\t\"stroke\": \"#a2bbce\",\r\n\t\t\t\t\"stroke-linecap\": \"round\",\r\n\t\t\t\t\"stroke-linejoin\": \"round\",\r\n\t\t\t\t\"stroke-width\": 10,\r\n\t\t\t\t\"class\": \"path1\",\r\n\t\t\t\t\"opacity\": \"0\"\r\n\t\t\t});\r\n\t\tif (!this.line.end && !this.line.start)\r\n\t\t\tthis.group.hover(() => {\r\n\t\t\t\tif (this.draggableCircle)\r\n\t\t\t\t\tthis.draggableCircle.attr(\"opacity\", \"1\");\r\n\t\t\t\tthis.svgLineShadow.attr(\"opacity\", \"0.2\");\r\n\t\t\t}, () => {\r\n\t\t\t\tif (this.draggableCircle)\r\n\t\t\t\t\tthis.draggableCircle.attr(\"opacity\", \"0\");\r\n\t\t\t\tthis.svgLineShadow.attr(\"opacity\", \"0\");\r\n\t\t\t});\r\n\r\n\t\tthis.svgLine = this.svgView.path(this.path)\r\n\t\t\t.attr({\r\n\t\t\t\t\"stroke\": \"#a2bbce\",\r\n\t\t\t\t\"stroke-linecap\": \"round\",\r\n\t\t\t\t\"stroke-linejoin\": \"round\",\r\n\t\t\t\t\"stroke-width\": 2,\r\n\t\t\t\t\"fill\": \"none\",\r\n\t\t\t\t\"class\": \"path1\"\r\n\t\t\t});\r\n\r\n\t\tif (this.line.end) {\r\n\t\t\tthis.svgLine.attr({\r\n\t\t\t\t\"class\": \"path1 marker_end\"\r\n\t\t\t});\r\n\t\t}\r\n\r\n\r\n\t\tthis.group.append();\r\n\r\n\t\tthis.group.append(this.svgLine);\r\n\t\tthis.group.append(this.svgLineShadow);\r\n\r\n\t\tif (this.line.start) {\r\n\t\t\tthis.group.append(this.svgView.circle(0, 0, 5).attr({\r\n\t\t\t\t\"type\": \"M\",\r\n\t\t\t\t\"fill\": \"#2b6b8a\"\r\n\t\t\t}));\r\n\t\t}\r\n\r\n\t\tthis.draggableCircle = this.svgView.circle(dX / 2, dY / 2, 7).attr({\r\n\t\t\t\"stroke-width\": 2,\r\n\t\t\t\"opacity\": 0,\r\n\t\t\t\"fill\": \"#2b6b8a\"\r\n\t\t});\r\n\r\n\r\n\t\tthis.group.append(this.draggableCircle);\r\n\r\n\t}\r\n\r\n\tremove() {\r\n\t\tthis.group.remove();\r\n\t\t// this.circle.remove();\r\n\t\t// this.arrow.remove();\r\n\t}\r\n\r\n\tdragNDrop() {\r\n\t\tif (!this.line.start && !this.line.end) {\r\n\r\n\r\n\t\t\tthis.draggableCircle.mousedown( e => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tthis.startDrag = true;\r\n\t\t\t\tthis.originClick = {\r\n\t\t\t\t\tx: e.clientX,\r\n\t\t\t\t\ty: e.clientY\r\n\t\t\t\t};\r\n\t\t\t\tthis.originPosition = {\r\n\t\t\t\t\tx: this.groupX,\r\n\t\t\t\t\ty: this.groupY\r\n\t\t\t\t};\r\n\t\t\t});\r\n\r\n\r\n\t\t\t$(\"svg\").mousemove( e => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tif (this.startDrag) {\r\n\r\n\r\n\r\n\t\t\t\t\tif (this.line.a[1].v) {\r\n\t\t\t\t\t\tthis.groupX = this.originPosition.x - (this.originClick.x - e.clientX);\r\n\t\t\t\t\t\tthis.line.a[0].x = this.groupX;\r\n\t\t\t\t\t\tthis.line.a[1].x = this.groupX;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (this.line.a[1].h) {\r\n\t\t\t\t\t\tthis.groupY = this.originPosition.y - (this.originClick.y - e.clientY);\r\n\t\t\t\t\t\tthis.line.a[0].y = this.groupY;\r\n\t\t\t\t\t\tthis.line.a[1].y = this.groupY;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tthis.prevLine.changeLenght({x: (this.originClick.x - e.clientX), y: (this.originClick.y - e.clientY), a: this.line.a, ind: 1});\r\n\t\t\t\t\tthis.nextLine.changeLenght({x: (this.originClick.x - e.clientX), y: (this.originClick.y - e.clientY), a: this.line.a, ind: 0});\r\n\t\t\t\t\t\r\n\t\t\t this.group.attr({\r\n\t\t\t \t\"transform\": `matrix(1,0,0,1,${this.groupX},${this.groupY})`\r\n\t\t\t });\r\n\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t});\r\n\r\n\t\t\t$(document).mouseup( e => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\t\r\n\t\t\t\tif (this.startDrag) {\r\n\t\t\t\t\tthis.prevLine.changeComplete({x: (this.originClick.x - e.clientX), y: (this.originClick.y - e.clientY), a: this.line.a, ind: 1});\r\n\t\t\t\t\tthis.nextLine.changeComplete({x: (this.originClick.x - e.clientX), y: (this.originClick.y - e.clientY), a: this.line.a, ind: 0});\t\t\r\n //было angular.copy (разобраться для чего)\r\n this.a = Object.assign ({}, this.line.a)\r\n\t\t\t\t}\r\n\t\t\t\tthis.startDrag = false;\t\r\n\r\n\t\t\t});\r\n\r\n\t\t}\r\n\t}\r\n\r\n\tchangeLenght(defPoint) {\r\n\r\n\t\tthis.line.a[defPoint.ind] = {\r\n\r\n\t\t\tx: this.line.a[defPoint.ind].x,\r\n\t\t\ty: this.line.a[defPoint.ind].y,\r\n\t\t\tv: this.line.a[defPoint.ind].v,\r\n\t\t\tm: this.line.a[defPoint.ind].m,\r\n\t\t\th: this.line.a[defPoint.ind].h\r\n\t\t}\r\n\t\tif (this.line.a[1].h) {\r\n\t\t\tthis.line.a[defPoint.ind].x = this.a[defPoint.ind].x - defPoint.x\r\n\t\t}\r\n\t\tif (this.line.a[1].v) {\r\n\t\t\tthis.line.a[defPoint.ind].y = this.a[defPoint.ind].y - defPoint.y\r\n\t\t}\r\n\r\n\t\tthis.remove();\r\n\t\tthis.group = this.svgView.group();\r\n\t\tthis.draw();\r\n\r\n\t}\r\n\r\n\tchangeComplete(defPoint) {\r\n\r\n\t\tthis.line.a[defPoint.ind] = {\r\n\r\n\t\t\tx: this.line.a[defPoint.ind].x,\r\n\t\t\ty: this.line.a[defPoint.ind].y,\r\n\t\t\tv: this.line.a[defPoint.ind].v,\r\n\t\t\tm: this.line.a[defPoint.ind].m,\r\n\t\t\th: this.line.a[defPoint.ind].h\r\n\t\t}\r\n\r\n\r\n\t\tif (this.line.a[1].h) {\r\n\t\t\tthis.line.a[defPoint.ind].x = this.a[defPoint.ind].x - defPoint.x;\r\n\t\t\tthis.a[defPoint.ind].x = this.a[defPoint.ind].x - defPoint.x;\r\n\t\t}\r\n\t\tif (this.line.a[1].v) {\r\n\t\t\tthis.line.a[defPoint.ind].y = this.a[defPoint.ind].y - defPoint.y;\r\n\t\t\tthis.a[defPoint.ind].y = this.a[defPoint.ind].y - defPoint.y\r\n\t\t}\r\n\t\t// this.a = this.line.a;\r\n\t\tthis.remove();\r\n\t\tthis.group = this.svgView.group();\r\n\t\tthis.draw();\r\n\t\tthis.dragNDrop();\r\n\r\n\t}\r\n\r\n\tredraw(line, type) {\r\n\t\tthis.line = line;\r\n\t\tthis.type = type;\r\n\t\tthis.group.remove();\r\n\t\t// this.svgLine.clear();\r\n\t\tthis.group = this.svgView.group();\r\n\t\tthis.draw();\r\n\t}\r\n}\r\n","import {\r\n\tcreateText,\r\n\tgetCircle, \r\n\tgetLastItem, \r\n\tgetDirection, \r\n\tgetLines,\r\n\tconvertPointToA,\r\n\tgetCirclePoint,\r\n\tgetLastLine,\r\n getFirstLine,\r\n createHint,\r\n createKK\r\n} from \"./funcs.js\";\r\nimport SchemaLine from \"./line.js\";\r\nimport lineDrawService from '../../../service/lineDrawService'\r\n\r\nexport default class Rect {\r\n\tconstructor(id,x,y,width,height,text, url1, docId, subtype, yesno, lineDrawService, edit, leftNode, topNode, rightNode, bottomNode, url2, url3,) {\r\n\t\t\r\n\t\tconsole.log(docId)\r\n\r\n\t\tthis.id = id;\r\n\t\tthis.x = x;\r\n\t\tthis.y = y;\r\n\t\tthis.yesno = yesno;\r\n\t\tthis.subtype = subtype;\r\n\t\tthis.width = width;\r\n\t\tthis.height = height;\r\n\t\tthis.text = text;\r\n\t\tthis.url1 = url1;\r\n\t\tthis.docId = docId;\r\n\t\tthis.leftNode = leftNode || {id1: this.id, dir1: 1, a:[]};\r\n\t\tthis.topNode = topNode || {id1: this.id, dir1: 2, a:[]};\r\n\t\tthis.rightNode = rightNode || {id1: this.id, dir1: 3, a:[]};\r\n\t\tthis.bottomNode = bottomNode || {id1: this.id, dir1: 4, a:[]};\r\n\t\tthis.nodes = [this.leftNode, this.topNode, this.rightNode, this.bottomNode];\r\n\t\tthis.lineDrawService = lineDrawService;\r\n\t\tthis.view = Snap(\"#diagramSvg\");\r\n\t\tthis.circles = [];\r\n\t\tthis.startDragAndDrop = false;\r\n\t\tthis.startDrawLine = false;\r\n\t\tthis.prevParam = { point: { x:0,y:0 } };\r\n\t\tthis.DragAndDropClickPoint = { x: 0,y: 0 };\r\n\t\tthis.dndTmpPoint = { x: 0,y: 0 };\r\n\t\tthis.url2 = url2;\r\n\t\tthis.url3 = url3;\r\n\r\n this.group = this.view.g();\r\n \r\n\t\tthis.edit = edit;\r\n\r\n\t\tif (this.subtype == 'rect') {\r\n\t\t\tswitch (this.width) {\r\n\t\t\t\tcase 160:\r\n\t\t\t\t\tthis.size = \"bsSmall\";\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 240: \r\n\t\t\t\t\tthis.size = \"bsMedium\";\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 320:\r\n\t\t\t\t\tthis.size = \"bsLarge\";\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.draw();\r\n\t\tthis.drawLines();\r\n\t\tif (this.edit) {\r\n\t\t\tthis.addCirles();\r\n\t\t\tthis.addListenerToHover();\r\n\t\t\tthis.dragAndDrop();\r\n\t\t\t\r\n\t\t}\r\n\t\t//console.log(this.lineDrawService)\r\n\t\tthis.lineDrawService.addEventListener(this.lineDrawService.events.DIRECTION, this.id, params => this.lineComplate(params));\r\n\t\tthis.lineDrawService.addEventListener(this.lineDrawService.events.DRAGANDDROP, this.id, params => this.reDrawLines(params));\r\n\t\tthis.lineDrawService.addEventListener(this.lineDrawService.events.UPDATE_RECT, this.id, params => this.update(params));\r\n\t\tthis.lineDrawService.addEventListener(this.lineDrawService.events.REMOVE_SHAPE, this.id, params => this.removeShape(params));\r\n\t}\r\n\r\n\tcheckTextWidth() {\r\n\t\tlet res = true;\r\n\t\tthis.textView.remove()\r\n\t\tthis.textView = createText(this.view, this.text, this.id, this.width, this.url1, this.docId);\r\n\t\t\r\n\t\tif ((this.textView.node.getBoundingClientRect().width > this.width || this.textView.node.getBoundingClientRect().height > this.height) && this.size != 'bsLarge') {\r\n\t\t\tthis.changeWidth('up');\r\n\t\t\tres = false;\r\n\t\t\tthis.checkTextWidth();\r\n\t\t} else if ((this.textView.node.getBoundingClientRect().width > this.width && this.textView.node.getBoundingClientRect().height < this.height) && this.size != 'bsLarge') {\r\n\t\t\tthis.changeWidth('down');\r\n\t\t\tres = false;\r\n\t\t\tthis.checkTextWidth();\r\n\t\t}\r\n\t\t// $(this.textView).remove()\r\n\t\t// console.log(this.textView.remove());\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\tgetNextSize(type, currentSize) {\r\n\t\tlet size = currentSize\r\n\t\tif (type == 'up') {\r\n\r\n\t\t\tswitch (size) {\r\n\t\t\t\tcase 'bsSmall':\r\n\t\t\t\t\t\tsize = 'bsMedium'\r\n\t\t\t\t\tbreak; \r\n\t\t\t\tcase 'bsMedium':\r\n\t\t\t\t\t\tsize = 'bsLarge'\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif (type == 'down') {\r\n\r\n\t\t\tswitch (size) {\r\n\t\t\t\tcase 'bsLarge':\r\n\t\t\t\t\t\tsize = 'bsMedium'\r\n\t\t\t\t\tbreak; \r\n\t\t\t\tcase 'bsMedium':\r\n\t\t\t\t\t\tsize = 'bsSmall'\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn size\r\n\t}\r\n\r\n\tgetSizeRect(size) {\r\n\t\tlet sizeRect = {\r\n\t\t\twidth: 0,\r\n\t\t\theight: 0\r\n\t\t}\r\n\r\n\t\tswitch (size) {\r\n\t\t\tcase 'bsSmall': \r\n\t\t\t\t\tsizeRect.width = 160;\r\n\t\t\t\t\tsizeRect.height = 80;\r\n\t\t\t\tbreak; \r\n\t\t\tcase 'bsMedium': \r\n\t\t\t\t\tsizeRect.width = 240;\r\n\t\t\t\t\tsizeRect.height = 120;\r\n\t\t\t\tbreak; \r\n\t\t\tcase 'bsLarge':\r\n\t\t\t\t\tsizeRect.width = 320;\r\n\t\t\t\t\tsizeRect.height = 160;\r\n\t\t\t\tbreak; \r\n\t\t}\r\n\r\n\t\treturn sizeRect;\r\n\t}\r\n\r\n\tchangeWidth(type) {\r\n\t\tlet rect = {}; console.log(this.size, this.getNextSize(type, this.size))\r\n\t\tthis.size = this.getNextSize(type, this.size);\r\n\r\n\t\trect = this.getSizeRect(this.size); console.log(rect, this.size)\r\n\t\tthis.width = rect.width;\r\n\t\tthis.height = rect.height;\r\n\r\n\t}\r\n\r\n\tdraw() {\r\n\t\tthis.shape = this.group.rect();\r\n\t\tif (this.subtype == \"romb\") {\r\n // console.log('draw if',this)\r\n\t\t\tthis.shape = this.group.polygon( -this.width/2, 0, 0, this.height / 2, this.width / 2, 0, 0, -this.height / 2).attr({\r\n\t\t\t\t\"fill\": \"white\",\r\n\t\t\t\t\"stroke-width\": 4,\r\n\t\t\t\t\"stroke\": \"#22a1de\",\r\n\t\t\t\t\"opacity\": 0.7,\r\n\t\t\t\t\"rx\": 6,\r\n\t\t\t\t\"ry\": 6\r\n\t\t\t});\r\n\t\t\t// this.element.append(this.circleElement)\r\n\t\t\tif (this.yesno) {\r\n\t\t\t\tthis.group.append( this.group.text(100, -10, \"Нет\").attr({ }));\r\n\t\t\t\tthis.group.append( this.group.text(-110, -10, \"Да\").attr({ }));\r\n\t\t\t} else {\r\n\t\t\t\tthis.group.append( this.group.text(-120, -10, \"Нет\").attr({ }));\r\n\t\t\t\tthis.group.append( this.group.text(100, -10, \"Да\").attr({ }));\r\n }\r\n\t\t} else {\r\n\t\t\tthis.shape.attr({\r\n\t\t\t\twidth: this.width,\r\n\t\t\t\theight: this.height,\r\n\t\t\t\tx: -this.width / 2,\r\n\t\t\t\ty: -this.height / 2,\r\n\t\t\t\t\"fill\": \"white\",\r\n\t\t\t\t\"stroke-width\": 4,\r\n\t\t\t\t\"stroke\": \"#22a1de\",\r\n\t\t\t\t\"opacity\": 0.7,\r\n\t\t\t\t\"rx\": 6,\r\n\t\t\t\t\"ry\": 6\r\n\t\t\t});\r\n }\r\n if(this.url3 !== undefined && this.url3 !== '') {\r\n console.log(this)\r\n this.group.append(createHint((-this.width/2)+14, (-this.height/2)-5, 0, this).el)\r\n }\r\n if(this.url2 !== undefined && this.url2 !== '') {\r\n this.group.append(createKK((-this.width/2)+140, (-this.height/2)-14, 0, this).el)\r\n }\r\n\r\n\t\tthis.group.append(this.shape);\r\n\t\tthis.group.attr({\r\n\t\t\t\"transform\" : `matrix(1,0,0,1,${this.x},${this.y})`\r\n\t\t});\r\n\r\n\t\tthis.textView = createText(this.view, this.text, this.id, this.width, this.url1, this.docId);\r\n this.group.append(this.textView);\r\n\r\n\r\n\r\n // let test = ``\r\n // this.group.append(test);\r\n \r\n\r\n\t\tthis.group.click(() => {\r\n\t\t\tthis.lineDrawService.dispatchEvent(this.lineDrawService.events.SELECT_RECT, {id: this.id, rect: this});\r\n\t\t})\r\n\t}\r\n\r\n\taddCirles() {\r\n\t\tfor (let i = 1; i < 5; i++) {\r\n\t\t\tthis.circles.push(getCircle(i, this.view, this.width, this.height));\r\n\t\t\tthis.group.append(getLastItem(this.circles));\r\n\t\t}\r\n\t}\r\n\r\n\taddListenerToHover() {\r\n\r\n\t\tthis.group.mousemove( e => {\r\n\r\n\t\t\tlet x = e.offsetX - this.x;\r\n\t\t\tlet y = e.offsetY - this.y;\r\n\r\n\t\t\tthis.lineDrawService.dispatchEvent(this.lineDrawService.events.DIRECTION, {id: this.id, dir: getDirection(x,y), point:getCirclePoint(this.x, this.y, this.width, this.height, getDirection(x,y), 20)});\r\n\r\n\t\t});\r\n\t}\r\n\r\n\tremoveShape(params) {\r\n\t\tthis.nodes.forEach(node => {\r\n\t\t\tif ( node.id2 == params.id ) {\r\n\t\t\t\tthis.removeNodeLines(node);\r\n\t\t\t\tnode.id2 = node.dir2 = false;\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t}\r\n\r\n\tremove() {\r\n\r\n\t\tthis.circles.forEach(item => item.remove());\r\n\t\tthis.nodes.forEach(this.removeNodeLines);\r\n\t\tthis.textView.remove();\r\n\t\tthis.shape.remove();\r\n\t\tthis.group.unmousedown(this.mousedown);\r\n\t\tthis.group.remove();\t\r\n\t\tthis.lineDrawService.dispatchEvent(this.lineDrawService.events.REMOVE_SHAPE, {id: this.id});\r\n\r\n\t\tthis.lineDrawService.removeEventListener(this.lineDrawService.events.DIRECTION, this.id);\r\n\t\tthis.lineDrawService.removeEventListener(this.lineDrawService.events.DRAGANDDROP, this.id);\r\n\t\tthis.lineDrawService.removeEventListener(this.lineDrawService.events.UPDATE_RECT, this.id);\r\n\t\tthis.lineDrawService.removeEventListener(this.lineDrawService.events.REMOVE_SHAPE, this.id);\r\n\t}\r\n\r\n\tupdate(params) {\r\n\t\tif (params.id != this.id) return\r\n\r\n\t\tswitch (params.size) {\r\n\t\t\tcase 'bsSmall': \r\n\t\t\t\t\tthis.width = 160;\r\n\t\t\t\t\tthis. height = 80;\r\n\t\t\t\tbreak; \r\n\t\t\tcase 'bsMedium': \r\n\t\t\t\t\tthis.width = 240;\r\n\t\t\t\t\tthis. height = 120;\r\n\t\t\t\tbreak; \r\n\t\t\tcase 'bsLarge':\r\n\t\t\t\t\tthis.width = 320;\r\n\t\t\t\t\tthis. height = 160;\r\n\t\t\t\tbreak; \r\n\t\t}\r\n\t\tthis.size = params.size;\r\n\t\tthis.text = params.text;\r\n\t\tthis.url1 = params.url1;\r\n\t\tthis.url2 = params.url2;\r\n\t\tthis.url3 = params.url3;\r\n\t\tthis.checkTextWidth();\r\n\t\tthis.circles.forEach(item => item.remove());\r\n\t\tthis.nodes.forEach(this.removeNodeLines);\r\n\t\tthis.textView.remove();\r\n\t\tthis.shape.remove();\r\n\t\tthis.group.unmousedown(this.mousedown);\r\n\t\tthis.lineDrawService.changeMap(this);\r\n\t\tthis.lineDrawService.dispatchEvent(this.lineDrawService.events.DRAGANDDROP, {id: this.id, node: this});\t\r\n\t\tthis.draw();\r\n\t\tthis.drawLines();\r\n\t\tthis.changeLineStartPoint()\r\n\t\tif (this.edit) {\r\n\t\t\tthis.addCirles();\r\n\t\t\tthis.addListenerToHover();\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tlineComplate(params) {\r\n\t\tif (this.startDrawLine && this.id != params.id && params.point.x !== this.prevParam.point.x && params.point.y !== this.prevParam.point.y) {\r\n\t\t\tthis.prevParam = params;\r\n\t\t\tlet points = this.lineDrawService.drawLine(\r\n\t\t\t\t{\r\n\t\t\t\t\tx: this.DragAndDropClickPoint.x, \r\n\t\t\t\t\ty: this.DragAndDropClickPoint.y\r\n\t\t\t\t},\r\n\t\t\t\t{ \r\n\t\t\t\t\tx: params.point.x, \r\n\t\t\t\t\ty: params.point.y\r\n\t\t\t\t}\r\n\t\t\t);\r\n\t\t\tif (points.length) {\r\n\t\t\t\tlet node = this.nodes[this.DragAndDropClickPoint.dir - 1];\r\n\t\t\t\tif (this.subtype == 'romb') {\r\n\t\t\t\t\tpoints.unshift(getFirstLine(node.dir1, points[0], this.subtype, true));\r\n\t\t\t\t}\r\n\t\t\t\tpoints.push(getLastLine(params.dir, points[points.length - 1]));\r\n\t\t\t\tnode.id2 = params.id;\r\n\t\t\t\tnode.dir2 = params.dir;\r\n\t\t\t\tnode.dir2Point = params.point;\r\n\t\t\t\tnode.a = convertPointToA(points, this.lineDrawService.step);\r\n\t\t\t\tthis.drawLine(node);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tmousedown(e) {\r\n\r\n\t\tif (e.target.tagName == \"circle\") {\r\n\t\t\tthis.startDrawLine = true;\r\n\t\t\tthis.DragAndDropClickPoint = {\r\n\t\t\t\tx: +$(e.target).attr(\"cx\") + this.x,\r\n\t\t\t\ty: +$(e.target).attr(\"cy\") + this.y,\r\n\t\t\t\tdir: +$(e.target).attr(\"dir\")\r\n\t\t\t};\r\n\r\n\t\t} else {\r\n\t\t\tthis.startDragAndDrop = true;\r\n\t\t\tthis.dndTmpPoint = {\r\n\t\t\t\tx: this.x,\r\n\t\t\t\ty: this.y\r\n\t\t\t};\r\n\r\n\t\t\tthis.DragAndDropClickPoint = {\r\n\t\t\t\tx: e.clientX,\r\n\t\t\t\ty: e.clientY\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n\r\n\tdragAndDrop() {\r\n\r\n\t\tthis.group.mousedown(e => this.mousedown(e));\r\n\r\n\t\t$(\"svg\").mousemove(e => {\r\n\r\n\t\t\tif (this.startDrawLine && e.target.tagName == \"svg\") {\r\n\t\t\t\tlet node = this.nodes[this.DragAndDropClickPoint.dir - 1];\r\n\t\t\t\tlet points = this.lineDrawService.drawLine(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tx: this.DragAndDropClickPoint.x, \r\n\t\t\t\t\t\ty: this.DragAndDropClickPoint.y\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\tx: e.clientX - $(\"svg\").offset().left, \r\n\t\t\t\t\t\ty: $(document).scrollTop() - $(\"svg\").offset().top + e.clientY\r\n\t\t\t\t\t}\r\n\t\t\t\t);\r\n\r\n\t\t\t\tif (points.length && this.subtype == 'romb') {\r\n\t\t\t\t\tpoints.unshift(getFirstLine(node.dir1, points[0], this.subtype, true));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tnode.a = convertPointToA(points, this.lineDrawService.step);\r\n\t\t\t\tthis.drawLine(this.nodes[this.DragAndDropClickPoint.dir - 1]);\r\n\t\t\t\t\r\n\t\t\t}\r\n\r\n\t\t\tif (this.startDragAndDrop) {\r\n\t\t\t\tthis.newPosition = {\r\n\t\t\t\t\tx: Math.round( (e.clientX - (this.DragAndDropClickPoint.x - this.dndTmpPoint.x)) / this.lineDrawService.step ) * this.lineDrawService.step,\r\n\t\t\t\t\ty: Math.round( (e.clientY - (this.DragAndDropClickPoint.y - this.dndTmpPoint.y)) / this.lineDrawService.step ) * this.lineDrawService.step,\r\n\t\t\t\t};\r\n\t\t\t\tthis.x = this.newPosition.x;\r\n\t\t\t\tthis.y = this.newPosition.y;\r\n\t\t\t\tthis.group.attr({\r\n\t\t\t\t\t\"transform\" : `matrix(1,0,0,1,${this.newPosition.x},${this.newPosition.y})`\r\n\t\t\t\t});\r\n\t\t\t\tthis.lineDrawService.changeMap(this);\r\n\t\t\t\tthis.changeLineStartPoint();\r\n\t\t\t\tthis.lineDrawService.dispatchEvent(this.lineDrawService.events.DRAGANDDROP, {id: this.id, node: this});\t\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t$(document).mouseup(e => {\r\n\r\n\t\t\tif (this.startDragAndDrop ) {\r\n\t\t\t\tthis.startDragAndDrop = false;\r\n\t\t\t\tif ( this.newPosition ) {\r\n\t\t\t\t\tthis.x = Math.round( this.newPosition.x / this.lineDrawService.step ) * this.lineDrawService.step;\r\n\t\t\t\t\tthis.y = Math.round( this.newPosition.y / this.lineDrawService.step ) * this.lineDrawService.step;\r\n\t\t\t\t\tthis.lineDrawService.changeMap(this);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif ( e.target.tagName == \"svg\" && this.startDrawLine) {\r\n\t\t\t\tlet node = this.nodes[this.DragAndDropClickPoint.dir - 1];\r\n\t\t\t\tnode.a = [];\r\n\t\t\t\tnode.dir2 = node.id2 = false;\r\n\t\t\t\tthis.drawLine(this.nodes[this.DragAndDropClickPoint.dir - 1]);\r\n\t\t\t}\r\n\r\n\t\t\tthis.startDrawLine = false;\r\n\t\t});\r\n\t}\r\n\r\n\tdrawLines(params) {\r\n\t\tthis.nodes.forEach(node => this.drawLine(node));\r\n\t}\r\n\r\n\treDrawLines(params) {\r\n\r\n\t\tthis.nodes.forEach(item => {\r\n\t\t\tif (params.id == item.id2) {\r\n\r\n\t\t\t\tlet circlePointStart = getCirclePoint(this.x, this.y, this.width, this.height, item.dir1, 20);\r\n\t\t\t\tlet circlePointEnd = getCirclePoint(params.node.x, params.node.y, params.node.width, params.node.height, item.dir2, 20);\r\n\t\t\t\tlet points = this.lineDrawService.drawLine(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tx: circlePointStart.x, \r\n\t\t\t\t\t\ty: circlePointStart.y\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\tx: circlePointEnd.x, \r\n\t\t\t\t\t\ty: circlePointEnd.y\r\n\t\t\t\t\t}\r\n\t\t\t\t);\r\n\t\t\t\titem.dir2Point = circlePointEnd;\r\n\t\t\t\tif (points.length) {\r\n\t\t\t\t\tpoints.unshift(getFirstLine(item.dir1, points[0], this.subtype))\r\n\t\t\t\t\tpoints.push(getLastLine(item.dir2, points[points.length - 1]));\r\n\t\t\t\t\titem.a = convertPointToA(points, this.lineDrawService.step);\r\n\t\t\t\t} else {\r\n\t\t\t\t\titem.a = [];\r\n\t\t\t\t}\r\n\t\t\t\tthis.drawLine(item);\r\n\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tdrawLine(node) {\r\n\t\tif (node) {\r\n\t\t\tlet lines = getLines(node.a);\r\n\t\t\tthis.removeNodeLines(node);\r\n\t\t\tnode.lines = [];\r\n\t\t\tlines.forEach((item, index) => {\r\n\t\t\t\tnode.lines.push(new SchemaLine({\r\n\t\t\t\t\tstart: !index,\r\n\t\t\t\t\tend: index == lines.length - 1,\r\n\t\t\t\t\ta: item\r\n\t\t\t\t}));\r\n\t\t\t});\r\n\t\t\tnode.lines.forEach((item , index) => {\r\n\t\t\t\tif (node.lines[index - 1]) {\r\n\t\t\t\t\titem.prevLine = node.lines[index - 1];\r\n\t\t\t\t}\r\n\t\t\t\tif (node.lines[index + 1]) {\r\n\t\t\t\t\titem.nextLine = node.lines[index + 1];\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tchangeLineEndPoint(id, dir) {\r\n\t\tlet node = this.nodes[dir - 1];\r\n\t}\r\n\r\n\tchangeLineStartPoint() {\r\n\r\n\t\tthis.nodes.forEach(node => {\r\n\t\t\tif (node.id2) {\r\n\t\t\t\tlet circlePointStart = getCirclePoint(this.x, this.y, this.width, this.height, node.dir1, 20);\r\n\t\t\t\tlet circlePointEnd = node.a[node.a.length - 2];\r\n\t\t\t\tlet points = this.lineDrawService.drawLine(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tx: circlePointStart.x, \r\n\t\t\t\t\t\ty: circlePointStart.y\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\tx: node.dir2Point.x, \r\n\t\t\t\t\t\ty: node.dir2Point.y\r\n\t\t\t\t\t}\r\n\t\t\t\t);\r\n\t\t\t\tif (points.length) {\r\n\t\t\t\t\tpoints.unshift(getFirstLine(node.dir1, points[0], this.subtype))\r\n\t\t\t\t\tpoints.push(getLastLine(node.dir2, points[points.length - 1]));\r\n\t\t\t\t\tnode.a = convertPointToA(points, this.lineDrawService.step);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tnode.a = [];\r\n\t\t\t\t}\r\n\t\t\t\tthis.drawLine(node);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tremoveNodeLines(node) {\r\n\t\tif (node.lines) {\r\n\t\t\tnode.lines.forEach(item => item.remove());\r\n\t\t\tfor (let i = 0; i < node.lines.length; i++) {\r\n\t\t\t\tdelete node.lines[i];\r\n\t\t\t}\r\n\t\t\tnode.lines = [];\r\n\t\t} else {\r\n\t\t\tnode.lines = [];\r\n\t\t}\r\n\t}\r\n\r\n}\r\n","var Heap = require('heap');\r\nvar Util = require('../core/Util');\r\nvar Heuristic = require('../core/Heuristic');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * A* path-finder. Based upon https://github.com/bgrins/javascript-astar\r\n * @constructor\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching \r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n * @param {number} opt.weight Weight to apply to the heuristic to allow for\r\n * suboptimal paths, in order to speed up the search.\r\n */\r\nfunction AStarFinder(opt) {\r\n opt = opt || {};\r\n this.allowDiagonal = opt.allowDiagonal;\r\n this.dontCrossCorners = opt.dontCrossCorners;\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n this.weight = opt.weight || 1;\r\n this.diagonalMovement = opt.diagonalMovement;\r\n\r\n if (!this.diagonalMovement) {\r\n if (!this.allowDiagonal) {\r\n this.diagonalMovement = DiagonalMovement.Never;\r\n } else {\r\n if (this.dontCrossCorners) {\r\n this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;\r\n } else {\r\n this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;\r\n }\r\n }\r\n }\r\n\r\n // When diagonal movement is allowed the manhattan heuristic is not\r\n //admissible. It should be octile instead\r\n if (this.diagonalMovement === DiagonalMovement.Never) {\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n } else {\r\n this.heuristic = opt.heuristic || Heuristic.octile;\r\n }\r\n}\r\n\r\n/**\r\n * Find and return the the path.\r\n * @return {Array>} The path, including both start and\r\n * end positions.\r\n */\r\nAStarFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {\r\n var openList = new Heap(function(nodeA, nodeB) {\r\n return nodeA.f - nodeB.f;\r\n }),\r\n startNode = grid.getNodeAt(startX, startY),\r\n endNode = grid.getNodeAt(endX, endY),\r\n heuristic = this.heuristic,\r\n diagonalMovement = this.diagonalMovement,\r\n weight = this.weight,\r\n abs = Math.abs, SQRT2 = Math.SQRT2,\r\n node, neighbors, neighbor, i, l, x, y, ng;\r\n\r\n // set the `g` and `f` value of the start node to be 0\r\n startNode.g = 0;\r\n startNode.f = 0;\r\n\r\n // push the start node into the open list\r\n openList.push(startNode);\r\n startNode.opened = true;\r\n\r\n // while the open list is not empty\r\n while (!openList.empty()) {\r\n // pop the position of node which has the minimum `f` value.\r\n node = openList.pop();\r\n node.closed = true;\r\n\r\n // if reached the end position, construct the path and return it\r\n if (node === endNode) {\r\n return Util.backtrace(endNode);\r\n }\r\n\r\n // get neigbours of the current node\r\n neighbors = grid.getNeighbors(node, diagonalMovement);\r\n for (i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n\r\n if (neighbor.closed) {\r\n continue;\r\n }\r\n\r\n x = neighbor.x;\r\n y = neighbor.y;\r\n\r\n // get the distance between current node and the neighbor\r\n // and calculate the next g score\r\n ng = node.g + ((x - node.x === 0 || y - node.y === 0) ? 1 : SQRT2);\r\n\r\n // check if the neighbor has not been inspected yet, or\r\n // can be reached with smaller cost from the current node\r\n if (!neighbor.opened || ng < neighbor.g) {\r\n neighbor.g = ng;\r\n neighbor.h = neighbor.h || weight * heuristic(abs(x - endX), abs(y - endY));\r\n neighbor.f = neighbor.g + neighbor.h;\r\n neighbor.parent = node;\r\n\r\n if (!neighbor.opened) {\r\n openList.push(neighbor);\r\n neighbor.opened = true;\r\n } else {\r\n // the neighbor can be reached with smaller cost.\r\n // Since its f value has been updated, we have to\r\n // update its position in the open list\r\n openList.updateItem(neighbor);\r\n }\r\n }\r\n } // end for each neighbor\r\n } // end while not open list empty\r\n\r\n // fail to find the path\r\n return [];\r\n};\r\n\r\nmodule.exports = AStarFinder;\r\n","/**\r\n * @namespace PF.Heuristic\r\n * @description A collection of heuristic functions.\r\n */\r\nmodule.exports = {\r\n\r\n /**\r\n * Manhattan distance.\r\n * @param {number} dx - Difference in x.\r\n * @param {number} dy - Difference in y.\r\n * @return {number} dx + dy\r\n */\r\n manhattan: function(dx, dy) {\r\n return dx + dy;\r\n },\r\n\r\n /**\r\n * Euclidean distance.\r\n * @param {number} dx - Difference in x.\r\n * @param {number} dy - Difference in y.\r\n * @return {number} sqrt(dx * dx + dy * dy)\r\n */\r\n euclidean: function(dx, dy) {\r\n return Math.sqrt(dx * dx + dy * dy);\r\n },\r\n\r\n /**\r\n * Octile distance.\r\n * @param {number} dx - Difference in x.\r\n * @param {number} dy - Difference in y.\r\n * @return {number} sqrt(dx * dx + dy * dy) for grids\r\n */\r\n octile: function(dx, dy) {\r\n var F = Math.SQRT2 - 1;\r\n return (dx < dy) ? F * dx + dy : F * dy + dx;\r\n },\r\n\r\n /**\r\n * Chebyshev distance.\r\n * @param {number} dx - Difference in x.\r\n * @param {number} dy - Difference in y.\r\n * @return {number} max(dx, dy)\r\n */\r\n chebyshev: function(dx, dy) {\r\n return Math.max(dx, dy);\r\n }\r\n\r\n};\r\n","// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n if (typeof module !== \"undefined\" && module !== null ? module.exports : void 0) {\n module.exports = Heap;\n } else {\n window.Heap = Heap;\n }\n\n}).call(this);\n","module.exports = require('./lib/heap');\n","/**\r\n * Backtrace according to the parent records and return the path.\r\n * (including both start and end nodes)\r\n * @param {Node} node End node\r\n * @return {Array>} the path\r\n */\r\nfunction backtrace(node) {\r\n var path = [[node.x, node.y]];\r\n while (node.parent) {\r\n node = node.parent;\r\n path.push([node.x, node.y]);\r\n }\r\n return path.reverse();\r\n}\r\nexports.backtrace = backtrace;\r\n\r\n/**\r\n * Backtrace from start and end node, and return the path.\r\n * (including both start and end nodes)\r\n * @param {Node}\r\n * @param {Node}\r\n */\r\nfunction biBacktrace(nodeA, nodeB) {\r\n var pathA = backtrace(nodeA),\r\n pathB = backtrace(nodeB);\r\n return pathA.concat(pathB.reverse());\r\n}\r\nexports.biBacktrace = biBacktrace;\r\n\r\n/**\r\n * Compute the length of the path.\r\n * @param {Array>} path The path\r\n * @return {number} The length of the path\r\n */\r\nfunction pathLength(path) {\r\n var i, sum = 0, a, b, dx, dy;\r\n for (i = 1; i < path.length; ++i) {\r\n a = path[i - 1];\r\n b = path[i];\r\n dx = a[0] - b[0];\r\n dy = a[1] - b[1];\r\n sum += Math.sqrt(dx * dx + dy * dy);\r\n }\r\n return sum;\r\n}\r\nexports.pathLength = pathLength;\r\n\r\n\r\n/**\r\n * Given the start and end coordinates, return all the coordinates lying\r\n * on the line formed by these coordinates, based on Bresenham's algorithm.\r\n * http://en.wikipedia.org/wiki/Bresenham's_line_algorithm#Simplification\r\n * @param {number} x0 Start x coordinate\r\n * @param {number} y0 Start y coordinate\r\n * @param {number} x1 End x coordinate\r\n * @param {number} y1 End y coordinate\r\n * @return {Array>} The coordinates on the line\r\n */\r\nfunction interpolate(x0, y0, x1, y1) {\r\n var abs = Math.abs,\r\n line = [],\r\n sx, sy, dx, dy, err, e2;\r\n\r\n dx = abs(x1 - x0);\r\n dy = abs(y1 - y0);\r\n\r\n sx = (x0 < x1) ? 1 : -1;\r\n sy = (y0 < y1) ? 1 : -1;\r\n\r\n err = dx - dy;\r\n\r\n while (true) {\r\n line.push([x0, y0]);\r\n\r\n if (x0 === x1 && y0 === y1) {\r\n break;\r\n }\r\n \r\n e2 = 2 * err;\r\n if (e2 > -dy) {\r\n err = err - dy;\r\n x0 = x0 + sx;\r\n }\r\n if (e2 < dx) {\r\n err = err + dx;\r\n y0 = y0 + sy;\r\n }\r\n }\r\n\r\n return line;\r\n}\r\nexports.interpolate = interpolate;\r\n\r\n\r\n/**\r\n * Given a compressed path, return a new path that has all the segments\r\n * in it interpolated.\r\n * @param {Array>} path The path\r\n * @return {Array>} expanded path\r\n */\r\nfunction expandPath(path) {\r\n var expanded = [],\r\n len = path.length,\r\n coord0, coord1,\r\n interpolated,\r\n interpolatedLen,\r\n i, j;\r\n\r\n if (len < 2) {\r\n return expanded;\r\n }\r\n\r\n for (i = 0; i < len - 1; ++i) {\r\n coord0 = path[i];\r\n coord1 = path[i + 1];\r\n\r\n interpolated = interpolate(coord0[0], coord0[1], coord1[0], coord1[1]);\r\n interpolatedLen = interpolated.length;\r\n for (j = 0; j < interpolatedLen - 1; ++j) {\r\n expanded.push(interpolated[j]);\r\n }\r\n }\r\n expanded.push(path[len - 1]);\r\n\r\n return expanded;\r\n}\r\nexports.expandPath = expandPath;\r\n\r\n\r\n/**\r\n * Smoothen the give path.\r\n * The original path will not be modified; a new path will be returned.\r\n * @param {PF.Grid} grid\r\n * @param {Array>} path The path\r\n */\r\nfunction smoothenPath(grid, path) {\r\n var len = path.length,\r\n x0 = path[0][0], // path start x\r\n y0 = path[0][1], // path start y\r\n x1 = path[len - 1][0], // path end x\r\n y1 = path[len - 1][1], // path end y\r\n sx, sy, // current start coordinate\r\n ex, ey, // current end coordinate\r\n newPath,\r\n i, j, coord, line, testCoord, blocked;\r\n\r\n sx = x0;\r\n sy = y0;\r\n newPath = [[sx, sy]];\r\n\r\n for (i = 2; i < len; ++i) {\r\n coord = path[i];\r\n ex = coord[0];\r\n ey = coord[1];\r\n line = interpolate(sx, sy, ex, ey);\r\n\r\n blocked = false;\r\n for (j = 1; j < line.length; ++j) {\r\n testCoord = line[j];\r\n\r\n if (!grid.isWalkableAt(testCoord[0], testCoord[1])) {\r\n blocked = true;\r\n break;\r\n }\r\n }\r\n if (blocked) {\r\n lastValidCoord = path[i - 1];\r\n newPath.push(lastValidCoord);\r\n sx = lastValidCoord[0];\r\n sy = lastValidCoord[1];\r\n }\r\n }\r\n newPath.push([x1, y1]);\r\n\r\n return newPath;\r\n}\r\nexports.smoothenPath = smoothenPath;\r\n\r\n\r\n/**\r\n * Compress a path, remove redundant nodes without altering the shape\r\n * The original path is not modified\r\n * @param {Array>} path The path\r\n * @return {Array>} The compressed path\r\n */\r\nfunction compressPath(path) {\r\n\r\n // nothing to compress\r\n if(path.length < 3) {\r\n return path;\r\n }\r\n\r\n var compressed = [],\r\n sx = path[0][0], // start x\r\n sy = path[0][1], // start y\r\n px = path[1][0], // second point x\r\n py = path[1][1], // second point y\r\n dx = px - sx, // direction between the two points\r\n dy = py - sy, // direction between the two points\r\n lx, ly,\r\n ldx, ldy,\r\n sq, i;\r\n\r\n // normalize the direction\r\n sq = Math.sqrt(dx*dx + dy*dy);\r\n dx /= sq;\r\n dy /= sq;\r\n\r\n // start the new path\r\n compressed.push([sx,sy]);\r\n\r\n for(i = 2; i < path.length; i++) {\r\n\r\n // store the last point\r\n lx = px;\r\n ly = py;\r\n\r\n // store the last direction\r\n ldx = dx;\r\n ldy = dy;\r\n\r\n // next point\r\n px = path[i][0];\r\n py = path[i][1];\r\n\r\n // next direction\r\n dx = px - lx;\r\n dy = py - ly;\r\n\r\n // normalize\r\n sq = Math.sqrt(dx*dx + dy*dy);\r\n dx /= sq;\r\n dy /= sq;\r\n\r\n // if the direction has changed, store the point\r\n if ( dx !== ldx || dy !== ldy ) {\r\n compressed.push([lx,ly]);\r\n }\r\n }\r\n\r\n // store the last point\r\n compressed.push([px,py]);\r\n\r\n return compressed;\r\n}\r\nexports.compressPath = compressPath;\r\n","import PF from \"pathfinding\";\r\n\r\nconst lineDrawService = {};\r\nlineDrawService.step = 20;\r\nlineDrawService.events = {\r\n\tHOVER: \"HOVER\",\r\n\tDIRECTION: \"DIRECTION\",\r\n\tDRAGANDDROP: \"DRAGANDDROP\",\r\n\tCONNECT: \"CONNECT\",\r\n\tREMOVE_SHAPE: \"REMOVE_SHAPE\",\r\n\tSELECT_RECT: \"SELECT_RECT\",\r\n\tUPDATE_RECT: \"UPDATE_RECT\"\r\n};\r\nlineDrawService.width = 0;\r\nlineDrawService.height = 0;\r\nlineDrawService.items = [];\r\nlet pathFinder = {};\r\n\r\nlet listeners = [];\r\n\r\nlineDrawService.initGrid = (width, height, items) => {\r\n\r\n\tpathFinder = {\r\n\t\tgrid: new PF.Grid(width / lineDrawService.step + 2, height / lineDrawService.step + 2 ),\r\n\t\tfinder: new PF.JumpPointFinder({\r\n\t\t\ttrackJumpRecursion: true,\r\n\t\t\tdiagonalMovement: PF.DiagonalMovement.Never\r\n\t\t})\r\n\t};\r\n\r\n\tlineDrawService.updateGrid(width, height, items);\r\n\r\n};\r\n\r\nlineDrawService.updateGrid = (width, height, items) => {\r\n\r\n\tlineDrawService.items = items;\r\n\tlineDrawService.width = width;\r\n\tlineDrawService.height = height;\r\n\r\n\tpathFinder.grid = new PF.Grid(lineDrawService.width / lineDrawService.step + 2, lineDrawService.height / lineDrawService.step + 2 );\r\n\t\r\n\tlineDrawService.items.forEach( item => {\r\n\t\tfor (let i = Math.ceil(item.x1 / lineDrawService.step); i < Math.floor(item.x2 / lineDrawService.step ) + 1 ; i++) {\r\n\t\t\tfor (let j = Math.ceil( item.y1 / lineDrawService.step ); j < Math.floor( item.y2 / lineDrawService.step ) + 1; j++) {\r\n\t\t\t\tif (i != -1 && j != -1) {\r\n\t\t\t\t\tpathFinder.grid.setWalkableAt(i, j, false);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n};\r\n\r\nlineDrawService.changeMap = shape => {\r\n\tlet shapeTmp = lineDrawService.items.filter(item => item.id == shape.id)[0];\r\n\tif (shapeTmp) {\r\n\t\tshapeTmp.x1 = shape.x - shape.width / 2;\r\n\t\tshapeTmp.y1 = shape.y - shape.height / 2;\r\n\t\tshapeTmp.x2 = shape.x + shape.width / 2;\r\n\t\tshapeTmp.y2 = shape.y + shape.height / 2;\r\n\t}\r\n};\r\n\r\nlineDrawService.drawLine = (pointFrom, pointTo) => {\r\n\tlet result = [];\r\n\tlineDrawService.updateGrid(lineDrawService.width, lineDrawService.height, lineDrawService.items);\r\n\tresult = pathFinder.finder.findPath(Math.round(pointFrom.x / lineDrawService.step), Math.round(pointFrom.y / lineDrawService.step),Math.round(pointTo.x / lineDrawService.step),Math.round(pointTo.y / lineDrawService.step), pathFinder.grid);\r\n\t\r\n\tif (!result.length) {\r\n\t\tpathFinder.grid = new PF.Grid(lineDrawService.width / lineDrawService.step + 2, lineDrawService.height / lineDrawService.step + 2 );\r\n\t\tresult = pathFinder.finder.findPath(Math.round(pointFrom.x / lineDrawService.step), Math.round(pointFrom.y / lineDrawService.step),Math.round(pointTo.x / lineDrawService.step),Math.round(pointTo.y / lineDrawService.step), pathFinder.grid);\r\n\t}\r\n\treturn result;\r\n};\r\n\r\nlineDrawService.addEventListener = (eventType, id, handler) => {\r\n\tlisteners.push({eventType,id,handler});\r\n};\r\n\r\nlineDrawService.removeEventListener = (eventType, id) => { \r\n\t\t\t\r\n\tfor (let i = 0; i < listeners.length; i++) {\r\n\t\tif ( listeners[i] && listeners[i].eventType == eventType && listeners[i].id == id ) {\r\n\t\t\tdelete listeners[i];\r\n\t\t\ti++;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nlineDrawService.dispatchEvent = (eventType, params) => {\r\n\tlisteners.filter(item => item.eventType == eventType).forEach(item => item.handler(params));\r\n};\r\n\r\nexport default lineDrawService;","var BiAStarFinder = require('./BiAStarFinder');\r\n\r\n/**\r\n * Bi-direcitional Best-First-Search path-finder.\r\n * @constructor\r\n * @extends BiAStarFinder\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n */\r\nfunction BiBestFirstFinder(opt) {\r\n BiAStarFinder.call(this, opt);\r\n\r\n var orig = this.heuristic;\r\n this.heuristic = function(dx, dy) {\r\n return orig(dx, dy) * 1000000;\r\n };\r\n}\r\n\r\nBiBestFirstFinder.prototype = new BiAStarFinder();\r\nBiBestFirstFinder.prototype.constructor = BiBestFirstFinder;\r\n\r\nmodule.exports = BiBestFirstFinder;\r\n","/**\r\n * A node in grid. \r\n * This class holds some basic information about a node and custom \r\n * attributes may be added, depending on the algorithms' needs.\r\n * @constructor\r\n * @param {number} x - The x coordinate of the node on the grid.\r\n * @param {number} y - The y coordinate of the node on the grid.\r\n * @param {boolean} [walkable] - Whether this node is walkable.\r\n */\r\nfunction Node(x, y, walkable) {\r\n /**\r\n * The x coordinate of the node on the grid.\r\n * @type number\r\n */\r\n this.x = x;\r\n /**\r\n * The y coordinate of the node on the grid.\r\n * @type number\r\n */\r\n this.y = y;\r\n /**\r\n * Whether this node can be walked through.\r\n * @type boolean\r\n */\r\n this.walkable = (walkable === undefined ? true : walkable);\r\n}\r\n\r\nmodule.exports = Node;\r\n","var Util = require('../core/Util');\r\nvar Heuristic = require('../core/Heuristic');\r\nvar Node = require('../core/Node');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Iterative Deeping A Star (IDA*) path-finder.\r\n *\r\n * Recursion based on:\r\n * http://www.apl.jhu.edu/~hall/AI-Programming/IDA-Star.html\r\n *\r\n * Path retracing based on:\r\n * V. Nageshwara Rao, Vipin Kumar and K. Ramesh\r\n * \"A Parallel Implementation of Iterative-Deeping-A*\", January 1987.\r\n * ftp://ftp.cs.utexas.edu/.snapshot/hourly.1/pub/AI-Lab/tech-reports/UT-AI-TR-87-46.pdf\r\n *\r\n * @author Gerard Meier (www.gerardmeier.com)\r\n *\r\n * @constructor\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n * @param {number} opt.weight Weight to apply to the heuristic to allow for\r\n * suboptimal paths, in order to speed up the search.\r\n * @param {boolean} opt.trackRecursion Whether to track recursion for\r\n * statistical purposes.\r\n * @param {number} opt.timeLimit Maximum execution time. Use <= 0 for infinite.\r\n */\r\nfunction IDAStarFinder(opt) {\r\n opt = opt || {};\r\n this.allowDiagonal = opt.allowDiagonal;\r\n this.dontCrossCorners = opt.dontCrossCorners;\r\n this.diagonalMovement = opt.diagonalMovement;\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n this.weight = opt.weight || 1;\r\n this.trackRecursion = opt.trackRecursion || false;\r\n this.timeLimit = opt.timeLimit || Infinity; // Default: no time limit.\r\n\r\n if (!this.diagonalMovement) {\r\n if (!this.allowDiagonal) {\r\n this.diagonalMovement = DiagonalMovement.Never;\r\n } else {\r\n if (this.dontCrossCorners) {\r\n this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;\r\n } else {\r\n this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;\r\n }\r\n }\r\n }\r\n\r\n // When diagonal movement is allowed the manhattan heuristic is not\r\n // admissible, it should be octile instead\r\n if (this.diagonalMovement === DiagonalMovement.Never) {\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n } else {\r\n this.heuristic = opt.heuristic || Heuristic.octile;\r\n }\r\n}\r\n\r\n/**\r\n * Find and return the the path. When an empty array is returned, either\r\n * no path is possible, or the maximum execution time is reached.\r\n *\r\n * @return {Array>} The path, including both start and\r\n * end positions.\r\n */\r\nIDAStarFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {\r\n // Used for statistics:\r\n var nodesVisited = 0;\r\n\r\n // Execution time limitation:\r\n var startTime = new Date().getTime();\r\n\r\n // Heuristic helper:\r\n var h = function(a, b) {\r\n return this.heuristic(Math.abs(b.x - a.x), Math.abs(b.y - a.y));\r\n }.bind(this);\r\n\r\n // Step cost from a to b:\r\n var cost = function(a, b) {\r\n return (a.x === b.x || a.y === b.y) ? 1 : Math.SQRT2;\r\n };\r\n\r\n /**\r\n * IDA* search implementation.\r\n *\r\n * @param {Node} The node currently expanding from.\r\n * @param {number} Cost to reach the given node.\r\n * @param {number} Maximum search depth (cut-off value).\r\n * @param {Array>} The found route.\r\n * @param {number} Recursion depth.\r\n *\r\n * @return {Object} either a number with the new optimal cut-off depth,\r\n * or a valid node instance, in which case a path was found.\r\n */\r\n var search = function(node, g, cutoff, route, depth) {\r\n nodesVisited++;\r\n\r\n // Enforce timelimit:\r\n if (this.timeLimit > 0 &&\r\n new Date().getTime() - startTime > this.timeLimit * 1000) {\r\n // Enforced as \"path-not-found\".\r\n return Infinity;\r\n }\r\n\r\n var f = g + h(node, end) * this.weight;\r\n\r\n // We've searched too deep for this iteration.\r\n if (f > cutoff) {\r\n return f;\r\n }\r\n\r\n if (node == end) {\r\n route[depth] = [node.x, node.y];\r\n return node;\r\n }\r\n\r\n var min, t, k, neighbour;\r\n\r\n var neighbours = grid.getNeighbors(node, this.diagonalMovement);\r\n\r\n // Sort the neighbours, gives nicer paths. But, this deviates\r\n // from the original algorithm - so I left it out.\r\n //neighbours.sort(function(a, b){\r\n // return h(a, end) - h(b, end);\r\n //});\r\n\r\n \r\n /*jshint -W084 *///Disable warning: Expected a conditional expression and instead saw an assignment\r\n for (k = 0, min = Infinity; neighbour = neighbours[k]; ++k) {\r\n /*jshint +W084 *///Enable warning: Expected a conditional expression and instead saw an assignment\r\n if (this.trackRecursion) {\r\n // Retain a copy for visualisation. Due to recursion, this\r\n // node may be part of other paths too.\r\n neighbour.retainCount = neighbour.retainCount + 1 || 1;\r\n\r\n if(neighbour.tested !== true) {\r\n neighbour.tested = true;\r\n }\r\n }\r\n\r\n t = search(neighbour, g + cost(node, neighbour), cutoff, route, depth + 1);\r\n\r\n if (t instanceof Node) {\r\n route[depth] = [node.x, node.y];\r\n\r\n // For a typical A* linked list, this would work:\r\n // neighbour.parent = node;\r\n return t;\r\n }\r\n\r\n // Decrement count, then determine whether it's actually closed.\r\n if (this.trackRecursion && (--neighbour.retainCount) === 0) {\r\n neighbour.tested = false;\r\n }\r\n\r\n if (t < min) {\r\n min = t;\r\n }\r\n }\r\n\r\n return min;\r\n\r\n }.bind(this);\r\n\r\n // Node instance lookups:\r\n var start = grid.getNodeAt(startX, startY);\r\n var end = grid.getNodeAt(endX, endY);\r\n\r\n // Initial search depth, given the typical heuristic contraints,\r\n // there should be no cheaper route possible.\r\n var cutOff = h(start, end);\r\n\r\n var j, route, t;\r\n\r\n // With an overflow protection.\r\n for (j = 0; true; ++j) {\r\n\r\n route = [];\r\n\r\n // Search till cut-off depth:\r\n t = search(start, 0, cutOff, route, 0);\r\n\r\n // Route not possible, or not found in time limit.\r\n if (t === Infinity) {\r\n return [];\r\n }\r\n\r\n // If t is a node, it's also the end node. Route is now\r\n // populated with a valid path to the end node.\r\n if (t instanceof Node) {\r\n return route;\r\n }\r\n\r\n // Try again, this time with a deeper cut-off. The t score\r\n // is the closest we got to the end node.\r\n cutOff = t;\r\n }\r\n\r\n // This _should_ never to be reached.\r\n return [];\r\n};\r\n\r\nmodule.exports = IDAStarFinder;\r\n","/**\r\n * @author imor / https://github.com/imor\r\n */\r\nvar Heap = require('heap');\r\nvar Util = require('../core/Util');\r\nvar Heuristic = require('../core/Heuristic');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Base class for the Jump Point Search algorithm\r\n * @param {object} opt\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n */\r\nfunction JumpPointFinderBase(opt) {\r\n opt = opt || {};\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n this.trackJumpRecursion = opt.trackJumpRecursion || false;\r\n}\r\n\r\n/**\r\n * Find and return the path.\r\n * @return {Array>} The path, including both start and\r\n * end positions.\r\n */\r\nJumpPointFinderBase.prototype.findPath = function(startX, startY, endX, endY, grid) {\r\n var openList = this.openList = new Heap(function(nodeA, nodeB) {\r\n return nodeA.f - nodeB.f;\r\n }),\r\n startNode = this.startNode = grid.getNodeAt(startX, startY),\r\n endNode = this.endNode = grid.getNodeAt(endX, endY), node;\r\n\r\n this.grid = grid;\r\n\r\n\r\n // set the `g` and `f` value of the start node to be 0\r\n startNode.g = 0;\r\n startNode.f = 0;\r\n\r\n // push the start node into the open list\r\n openList.push(startNode);\r\n startNode.opened = true;\r\n\r\n // while the open list is not empty\r\n while (!openList.empty()) {\r\n // pop the position of node which has the minimum `f` value.\r\n node = openList.pop();\r\n node.closed = true;\r\n\r\n if (node === endNode) {\r\n return Util.expandPath(Util.backtrace(endNode));\r\n }\r\n\r\n this._identifySuccessors(node);\r\n }\r\n\r\n // fail to find the path\r\n return [];\r\n};\r\n\r\n/**\r\n * Identify successors for the given node. Runs a jump point search in the\r\n * direction of each available neighbor, adding any points found to the open\r\n * list.\r\n * @protected\r\n */\r\nJumpPointFinderBase.prototype._identifySuccessors = function(node) {\r\n var grid = this.grid,\r\n heuristic = this.heuristic,\r\n openList = this.openList,\r\n endX = this.endNode.x,\r\n endY = this.endNode.y,\r\n neighbors, neighbor,\r\n jumpPoint, i, l,\r\n x = node.x, y = node.y,\r\n jx, jy, dx, dy, d, ng, jumpNode,\r\n abs = Math.abs, max = Math.max;\r\n\r\n neighbors = this._findNeighbors(node);\r\n for(i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n jumpPoint = this._jump(neighbor[0], neighbor[1], x, y);\r\n if (jumpPoint) {\r\n\r\n jx = jumpPoint[0];\r\n jy = jumpPoint[1];\r\n jumpNode = grid.getNodeAt(jx, jy);\r\n\r\n if (jumpNode.closed) {\r\n continue;\r\n }\r\n\r\n // include distance, as parent may not be immediately adjacent:\r\n d = Heuristic.octile(abs(jx - x), abs(jy - y));\r\n ng = node.g + d; // next `g` value\r\n\r\n if (!jumpNode.opened || ng < jumpNode.g) {\r\n jumpNode.g = ng;\r\n jumpNode.h = jumpNode.h || heuristic(abs(jx - endX), abs(jy - endY));\r\n jumpNode.f = jumpNode.g + jumpNode.h;\r\n jumpNode.parent = node;\r\n\r\n if (!jumpNode.opened) {\r\n openList.push(jumpNode);\r\n jumpNode.opened = true;\r\n } else {\r\n openList.updateItem(jumpNode);\r\n }\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = JumpPointFinderBase;\r\n","/**\r\n * @author imor / https://github.com/imor\r\n */\r\nvar JumpPointFinderBase = require('./JumpPointFinderBase');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Path finder using the Jump Point Search algorithm allowing only horizontal\r\n * or vertical movements.\r\n */\r\nfunction JPFNeverMoveDiagonally(opt) {\r\n JumpPointFinderBase.call(this, opt);\r\n}\r\n\r\nJPFNeverMoveDiagonally.prototype = new JumpPointFinderBase();\r\nJPFNeverMoveDiagonally.prototype.constructor = JPFNeverMoveDiagonally;\r\n\r\n/**\r\n * Search recursively in the direction (parent -> child), stopping only when a\r\n * jump point is found.\r\n * @protected\r\n * @return {Array>} The x, y coordinate of the jump point\r\n * found, or null if not found\r\n */\r\nJPFNeverMoveDiagonally.prototype._jump = function(x, y, px, py) {\r\n var grid = this.grid,\r\n dx = x - px, dy = y - py;\r\n\r\n if (!grid.isWalkableAt(x, y)) {\r\n return null;\r\n }\r\n\r\n if(this.trackJumpRecursion === true) {\r\n grid.getNodeAt(x, y).tested = true;\r\n }\r\n\r\n if (grid.getNodeAt(x, y) === this.endNode) {\r\n return [x, y];\r\n }\r\n\r\n if (dx !== 0) {\r\n if ((grid.isWalkableAt(x, y - 1) && !grid.isWalkableAt(x - dx, y - 1)) ||\r\n (grid.isWalkableAt(x, y + 1) && !grid.isWalkableAt(x - dx, y + 1))) {\r\n return [x, y];\r\n }\r\n }\r\n else if (dy !== 0) {\r\n if ((grid.isWalkableAt(x - 1, y) && !grid.isWalkableAt(x - 1, y - dy)) ||\r\n (grid.isWalkableAt(x + 1, y) && !grid.isWalkableAt(x + 1, y - dy))) {\r\n return [x, y];\r\n }\r\n //When moving vertically, must check for horizontal jump points\r\n if (this._jump(x + 1, y, x, y) || this._jump(x - 1, y, x, y)) {\r\n return [x, y];\r\n }\r\n }\r\n else {\r\n throw new Error(\"Only horizontal and vertical movements are allowed\");\r\n }\r\n\r\n return this._jump(x + dx, y + dy, x, y);\r\n};\r\n\r\n/**\r\n * Find the neighbors for the given node. If the node has a parent,\r\n * prune the neighbors based on the jump point search algorithm, otherwise\r\n * return all available neighbors.\r\n * @return {Array>} The neighbors found.\r\n */\r\nJPFNeverMoveDiagonally.prototype._findNeighbors = function(node) {\r\n var parent = node.parent,\r\n x = node.x, y = node.y,\r\n grid = this.grid,\r\n px, py, nx, ny, dx, dy,\r\n neighbors = [], neighborNodes, neighborNode, i, l;\r\n\r\n // directed pruning: can ignore most neighbors, unless forced.\r\n if (parent) {\r\n px = parent.x;\r\n py = parent.y;\r\n // get the normalized direction of travel\r\n dx = (x - px) / Math.max(Math.abs(x - px), 1);\r\n dy = (y - py) / Math.max(Math.abs(y - py), 1);\r\n\r\n if (dx !== 0) {\r\n if (grid.isWalkableAt(x, y - 1)) {\r\n neighbors.push([x, y - 1]);\r\n }\r\n if (grid.isWalkableAt(x, y + 1)) {\r\n neighbors.push([x, y + 1]);\r\n }\r\n if (grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y]);\r\n }\r\n }\r\n else if (dy !== 0) {\r\n if (grid.isWalkableAt(x - 1, y)) {\r\n neighbors.push([x - 1, y]);\r\n }\r\n if (grid.isWalkableAt(x + 1, y)) {\r\n neighbors.push([x + 1, y]);\r\n }\r\n if (grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x, y + dy]);\r\n }\r\n }\r\n }\r\n // return all neighbors\r\n else {\r\n neighborNodes = grid.getNeighbors(node, DiagonalMovement.Never);\r\n for (i = 0, l = neighborNodes.length; i < l; ++i) {\r\n neighborNode = neighborNodes[i];\r\n neighbors.push([neighborNode.x, neighborNode.y]);\r\n }\r\n }\r\n\r\n return neighbors;\r\n};\r\n\r\nmodule.exports = JPFNeverMoveDiagonally;\r\n","var Heap = require('heap');\r\nvar Util = require('../core/Util');\r\nvar Heuristic = require('../core/Heuristic');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * A* path-finder.\r\n * based upon https://github.com/bgrins/javascript-astar\r\n * @constructor\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n * @param {number} opt.weight Weight to apply to the heuristic to allow for\r\n * suboptimal paths, in order to speed up the search.\r\n */\r\nfunction BiAStarFinder(opt) {\r\n opt = opt || {};\r\n this.allowDiagonal = opt.allowDiagonal;\r\n this.dontCrossCorners = opt.dontCrossCorners;\r\n this.diagonalMovement = opt.diagonalMovement;\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n this.weight = opt.weight || 1;\r\n\r\n if (!this.diagonalMovement) {\r\n if (!this.allowDiagonal) {\r\n this.diagonalMovement = DiagonalMovement.Never;\r\n } else {\r\n if (this.dontCrossCorners) {\r\n this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;\r\n } else {\r\n this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;\r\n }\r\n }\r\n }\r\n\r\n //When diagonal movement is allowed the manhattan heuristic is not admissible\r\n //It should be octile instead\r\n if (this.diagonalMovement === DiagonalMovement.Never) {\r\n this.heuristic = opt.heuristic || Heuristic.manhattan;\r\n } else {\r\n this.heuristic = opt.heuristic || Heuristic.octile;\r\n }\r\n}\r\n\r\n/**\r\n * Find and return the the path.\r\n * @return {Array>} The path, including both start and\r\n * end positions.\r\n */\r\nBiAStarFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {\r\n var cmp = function(nodeA, nodeB) {\r\n return nodeA.f - nodeB.f;\r\n },\r\n startOpenList = new Heap(cmp),\r\n endOpenList = new Heap(cmp),\r\n startNode = grid.getNodeAt(startX, startY),\r\n endNode = grid.getNodeAt(endX, endY),\r\n heuristic = this.heuristic,\r\n diagonalMovement = this.diagonalMovement,\r\n weight = this.weight,\r\n abs = Math.abs, SQRT2 = Math.SQRT2,\r\n node, neighbors, neighbor, i, l, x, y, ng,\r\n BY_START = 1, BY_END = 2;\r\n\r\n // set the `g` and `f` value of the start node to be 0\r\n // and push it into the start open list\r\n startNode.g = 0;\r\n startNode.f = 0;\r\n startOpenList.push(startNode);\r\n startNode.opened = BY_START;\r\n\r\n // set the `g` and `f` value of the end node to be 0\r\n // and push it into the open open list\r\n endNode.g = 0;\r\n endNode.f = 0;\r\n endOpenList.push(endNode);\r\n endNode.opened = BY_END;\r\n\r\n // while both the open lists are not empty\r\n while (!startOpenList.empty() && !endOpenList.empty()) {\r\n\r\n // pop the position of start node which has the minimum `f` value.\r\n node = startOpenList.pop();\r\n node.closed = true;\r\n\r\n // get neigbours of the current node\r\n neighbors = grid.getNeighbors(node, diagonalMovement);\r\n for (i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n\r\n if (neighbor.closed) {\r\n continue;\r\n }\r\n if (neighbor.opened === BY_END) {\r\n return Util.biBacktrace(node, neighbor);\r\n }\r\n\r\n x = neighbor.x;\r\n y = neighbor.y;\r\n\r\n // get the distance between current node and the neighbor\r\n // and calculate the next g score\r\n ng = node.g + ((x - node.x === 0 || y - node.y === 0) ? 1 : SQRT2);\r\n\r\n // check if the neighbor has not been inspected yet, or\r\n // can be reached with smaller cost from the current node\r\n if (!neighbor.opened || ng < neighbor.g) {\r\n neighbor.g = ng;\r\n neighbor.h = neighbor.h ||\r\n weight * heuristic(abs(x - endX), abs(y - endY));\r\n neighbor.f = neighbor.g + neighbor.h;\r\n neighbor.parent = node;\r\n\r\n if (!neighbor.opened) {\r\n startOpenList.push(neighbor);\r\n neighbor.opened = BY_START;\r\n } else {\r\n // the neighbor can be reached with smaller cost.\r\n // Since its f value has been updated, we have to\r\n // update its position in the open list\r\n startOpenList.updateItem(neighbor);\r\n }\r\n }\r\n } // end for each neighbor\r\n\r\n\r\n // pop the position of end node which has the minimum `f` value.\r\n node = endOpenList.pop();\r\n node.closed = true;\r\n\r\n // get neigbours of the current node\r\n neighbors = grid.getNeighbors(node, diagonalMovement);\r\n for (i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n\r\n if (neighbor.closed) {\r\n continue;\r\n }\r\n if (neighbor.opened === BY_START) {\r\n return Util.biBacktrace(neighbor, node);\r\n }\r\n\r\n x = neighbor.x;\r\n y = neighbor.y;\r\n\r\n // get the distance between current node and the neighbor\r\n // and calculate the next g score\r\n ng = node.g + ((x - node.x === 0 || y - node.y === 0) ? 1 : SQRT2);\r\n\r\n // check if the neighbor has not been inspected yet, or\r\n // can be reached with smaller cost from the current node\r\n if (!neighbor.opened || ng < neighbor.g) {\r\n neighbor.g = ng;\r\n neighbor.h = neighbor.h ||\r\n weight * heuristic(abs(x - startX), abs(y - startY));\r\n neighbor.f = neighbor.g + neighbor.h;\r\n neighbor.parent = node;\r\n\r\n if (!neighbor.opened) {\r\n endOpenList.push(neighbor);\r\n neighbor.opened = BY_END;\r\n } else {\r\n // the neighbor can be reached with smaller cost.\r\n // Since its f value has been updated, we have to\r\n // update its position in the open list\r\n endOpenList.updateItem(neighbor);\r\n }\r\n }\r\n } // end for each neighbor\r\n } // end while not open list empty\r\n\r\n // fail to find the path\r\n return [];\r\n};\r\n\r\nmodule.exports = BiAStarFinder;\r\n","var Util = require('../core/Util');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Breadth-First-Search path finder.\r\n * @constructor\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n */\r\nfunction BreadthFirstFinder(opt) {\r\n opt = opt || {};\r\n this.allowDiagonal = opt.allowDiagonal;\r\n this.dontCrossCorners = opt.dontCrossCorners;\r\n this.diagonalMovement = opt.diagonalMovement;\r\n\r\n if (!this.diagonalMovement) {\r\n if (!this.allowDiagonal) {\r\n this.diagonalMovement = DiagonalMovement.Never;\r\n } else {\r\n if (this.dontCrossCorners) {\r\n this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;\r\n } else {\r\n this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Find and return the the path.\r\n * @return {Array>} The path, including both start and\r\n * end positions.\r\n */\r\nBreadthFirstFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {\r\n var openList = [],\r\n diagonalMovement = this.diagonalMovement,\r\n startNode = grid.getNodeAt(startX, startY),\r\n endNode = grid.getNodeAt(endX, endY),\r\n neighbors, neighbor, node, i, l;\r\n\r\n // push the start pos into the queue\r\n openList.push(startNode);\r\n startNode.opened = true;\r\n\r\n // while the queue is not empty\r\n while (openList.length) {\r\n // take the front node from the queue\r\n node = openList.shift();\r\n node.closed = true;\r\n\r\n // reached the end position\r\n if (node === endNode) {\r\n return Util.backtrace(endNode);\r\n }\r\n\r\n neighbors = grid.getNeighbors(node, diagonalMovement);\r\n for (i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n\r\n // skip this neighbor if it has been inspected before\r\n if (neighbor.closed || neighbor.opened) {\r\n continue;\r\n }\r\n\r\n openList.push(neighbor);\r\n neighbor.opened = true;\r\n neighbor.parent = node;\r\n }\r\n }\r\n \r\n // fail to find the path\r\n return [];\r\n};\r\n\r\nmodule.exports = BreadthFirstFinder;\r\n","var BiAStarFinder = require('./BiAStarFinder');\r\n\r\n/**\r\n * Bi-directional Dijkstra path-finder.\r\n * @constructor\r\n * @extends BiAStarFinder\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n */\r\nfunction BiDijkstraFinder(opt) {\r\n BiAStarFinder.call(this, opt);\r\n this.heuristic = function(dx, dy) {\r\n return 0;\r\n };\r\n}\r\n\r\nBiDijkstraFinder.prototype = new BiAStarFinder();\r\nBiDijkstraFinder.prototype.constructor = BiDijkstraFinder;\r\n\r\nmodule.exports = BiDijkstraFinder;\r\n","var DiagonalMovement = {\r\n Always: 1,\r\n Never: 2,\r\n IfAtMostOneObstacle: 3,\r\n OnlyWhenNoObstacles: 4\r\n};\r\n\r\nmodule.exports = DiagonalMovement;","var Node = require('./Node');\r\nvar DiagonalMovement = require('./DiagonalMovement');\r\n\r\n/**\r\n * The Grid class, which serves as the encapsulation of the layout of the nodes.\r\n * @constructor\r\n * @param {number|Array>} width_or_matrix Number of columns of the grid, or matrix\r\n * @param {number} height Number of rows of the grid.\r\n * @param {Array>} [matrix] - A 0-1 matrix\r\n * representing the walkable status of the nodes(0 or false for walkable).\r\n * If the matrix is not supplied, all the nodes will be walkable. */\r\nfunction Grid(width_or_matrix, height, matrix) {\r\n var width;\r\n\r\n if (typeof width_or_matrix !== 'object') {\r\n width = width_or_matrix;\r\n } else {\r\n height = width_or_matrix.length;\r\n width = width_or_matrix[0].length;\r\n matrix = width_or_matrix;\r\n }\r\n\r\n /**\r\n * The number of columns of the grid.\r\n * @type number\r\n */\r\n this.width = width;\r\n /**\r\n * The number of rows of the grid.\r\n * @type number\r\n */\r\n this.height = height;\r\n\r\n /**\r\n * A 2D array of nodes.\r\n */\r\n this.nodes = this._buildNodes(width, height, matrix);\r\n}\r\n\r\n/**\r\n * Build and return the nodes.\r\n * @private\r\n * @param {number} width\r\n * @param {number} height\r\n * @param {Array>} [matrix] - A 0-1 matrix representing\r\n * the walkable status of the nodes.\r\n * @see Grid\r\n */\r\nGrid.prototype._buildNodes = function(width, height, matrix) {\r\n var i, j,\r\n nodes = new Array(height);\r\n\r\n for (i = 0; i < height; ++i) {\r\n nodes[i] = new Array(width);\r\n for (j = 0; j < width; ++j) {\r\n nodes[i][j] = new Node(j, i);\r\n }\r\n }\r\n\r\n\r\n if (matrix === undefined) {\r\n return nodes;\r\n }\r\n\r\n if (matrix.length !== height || matrix[0].length !== width) {\r\n throw new Error('Matrix size does not fit');\r\n }\r\n\r\n for (i = 0; i < height; ++i) {\r\n for (j = 0; j < width; ++j) {\r\n if (matrix[i][j]) {\r\n // 0, false, null will be walkable\r\n // while others will be un-walkable\r\n nodes[i][j].walkable = false;\r\n }\r\n }\r\n }\r\n\r\n return nodes;\r\n};\r\n\r\n\r\nGrid.prototype.getNodeAt = function(x, y) {\r\n return this.nodes[y][x];\r\n};\r\n\r\n\r\n/**\r\n * Determine whether the node at the given position is walkable.\r\n * (Also returns false if the position is outside the grid.)\r\n * @param {number} x - The x coordinate of the node.\r\n * @param {number} y - The y coordinate of the node.\r\n * @return {boolean} - The walkability of the node.\r\n */\r\nGrid.prototype.isWalkableAt = function(x, y) {\r\n return this.isInside(x, y) && this.nodes[y][x].walkable;\r\n};\r\n\r\n\r\n/**\r\n * Determine whether the position is inside the grid.\r\n * XXX: `grid.isInside(x, y)` is wierd to read.\r\n * It should be `(x, y) is inside grid`, but I failed to find a better\r\n * name for this method.\r\n * @param {number} x\r\n * @param {number} y\r\n * @return {boolean}\r\n */\r\nGrid.prototype.isInside = function(x, y) {\r\n return (x >= 0 && x < this.width) && (y >= 0 && y < this.height);\r\n};\r\n\r\n\r\n/**\r\n * Set whether the node on the given position is walkable.\r\n * NOTE: throws exception if the coordinate is not inside the grid.\r\n * @param {number} x - The x coordinate of the node.\r\n * @param {number} y - The y coordinate of the node.\r\n * @param {boolean} walkable - Whether the position is walkable.\r\n */\r\nGrid.prototype.setWalkableAt = function(x, y, walkable) {\r\n this.nodes[y][x].walkable = walkable;\r\n};\r\n\r\n\r\n/**\r\n * Get the neighbors of the given node.\r\n *\r\n * offsets diagonalOffsets:\r\n * +---+---+---+ +---+---+---+\r\n * | | 0 | | | 0 | | 1 |\r\n * +---+---+---+ +---+---+---+\r\n * | 3 | | 1 | | | | |\r\n * +---+---+---+ +---+---+---+\r\n * | | 2 | | | 3 | | 2 |\r\n * +---+---+---+ +---+---+---+\r\n *\r\n * When allowDiagonal is true, if offsets[i] is valid, then\r\n * diagonalOffsets[i] and\r\n * diagonalOffsets[(i + 1) % 4] is valid.\r\n * @param {Node} node\r\n * @param {DiagonalMovement} diagonalMovement\r\n */\r\nGrid.prototype.getNeighbors = function(node, diagonalMovement) {\r\n var x = node.x,\r\n y = node.y,\r\n neighbors = [],\r\n s0 = false, d0 = false,\r\n s1 = false, d1 = false,\r\n s2 = false, d2 = false,\r\n s3 = false, d3 = false,\r\n nodes = this.nodes;\r\n\r\n // ↑\r\n if (this.isWalkableAt(x, y - 1)) {\r\n neighbors.push(nodes[y - 1][x]);\r\n s0 = true;\r\n }\r\n // →\r\n if (this.isWalkableAt(x + 1, y)) {\r\n neighbors.push(nodes[y][x + 1]);\r\n s1 = true;\r\n }\r\n // ↓\r\n if (this.isWalkableAt(x, y + 1)) {\r\n neighbors.push(nodes[y + 1][x]);\r\n s2 = true;\r\n }\r\n // ←\r\n if (this.isWalkableAt(x - 1, y)) {\r\n neighbors.push(nodes[y][x - 1]);\r\n s3 = true;\r\n }\r\n\r\n if (diagonalMovement === DiagonalMovement.Never) {\r\n return neighbors;\r\n }\r\n\r\n if (diagonalMovement === DiagonalMovement.OnlyWhenNoObstacles) {\r\n d0 = s3 && s0;\r\n d1 = s0 && s1;\r\n d2 = s1 && s2;\r\n d3 = s2 && s3;\r\n } else if (diagonalMovement === DiagonalMovement.IfAtMostOneObstacle) {\r\n d0 = s3 || s0;\r\n d1 = s0 || s1;\r\n d2 = s1 || s2;\r\n d3 = s2 || s3;\r\n } else if (diagonalMovement === DiagonalMovement.Always) {\r\n d0 = true;\r\n d1 = true;\r\n d2 = true;\r\n d3 = true;\r\n } else {\r\n throw new Error('Incorrect value of diagonalMovement');\r\n }\r\n\r\n // ↖\r\n if (d0 && this.isWalkableAt(x - 1, y - 1)) {\r\n neighbors.push(nodes[y - 1][x - 1]);\r\n }\r\n // ↗\r\n if (d1 && this.isWalkableAt(x + 1, y - 1)) {\r\n neighbors.push(nodes[y - 1][x + 1]);\r\n }\r\n // ↘\r\n if (d2 && this.isWalkableAt(x + 1, y + 1)) {\r\n neighbors.push(nodes[y + 1][x + 1]);\r\n }\r\n // ↙\r\n if (d3 && this.isWalkableAt(x - 1, y + 1)) {\r\n neighbors.push(nodes[y + 1][x - 1]);\r\n }\r\n\r\n return neighbors;\r\n};\r\n\r\n\r\n/**\r\n * Get a clone of this grid.\r\n * @return {Grid} Cloned grid.\r\n */\r\nGrid.prototype.clone = function() {\r\n var i, j,\r\n\r\n width = this.width,\r\n height = this.height,\r\n thisNodes = this.nodes,\r\n\r\n newGrid = new Grid(width, height),\r\n newNodes = new Array(height);\r\n\r\n for (i = 0; i < height; ++i) {\r\n newNodes[i] = new Array(width);\r\n for (j = 0; j < width; ++j) {\r\n newNodes[i][j] = new Node(j, i, thisNodes[i][j].walkable);\r\n }\r\n }\r\n\r\n newGrid.nodes = newNodes;\r\n\r\n return newGrid;\r\n};\r\n\r\nmodule.exports = Grid;\r\n","var Util = require('../core/Util');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Bi-directional Breadth-First-Search path finder.\r\n * @constructor\r\n * @param {object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n */\r\nfunction BiBreadthFirstFinder(opt) {\r\n opt = opt || {};\r\n this.allowDiagonal = opt.allowDiagonal;\r\n this.dontCrossCorners = opt.dontCrossCorners;\r\n this.diagonalMovement = opt.diagonalMovement;\r\n\r\n if (!this.diagonalMovement) {\r\n if (!this.allowDiagonal) {\r\n this.diagonalMovement = DiagonalMovement.Never;\r\n } else {\r\n if (this.dontCrossCorners) {\r\n this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;\r\n } else {\r\n this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;\r\n }\r\n }\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Find and return the the path.\r\n * @return {Array>} The path, including both start and\r\n * end positions.\r\n */\r\nBiBreadthFirstFinder.prototype.findPath = function(startX, startY, endX, endY, grid) {\r\n var startNode = grid.getNodeAt(startX, startY),\r\n endNode = grid.getNodeAt(endX, endY),\r\n startOpenList = [], endOpenList = [],\r\n neighbors, neighbor, node,\r\n diagonalMovement = this.diagonalMovement,\r\n BY_START = 0, BY_END = 1,\r\n i, l;\r\n\r\n // push the start and end nodes into the queues\r\n startOpenList.push(startNode);\r\n startNode.opened = true;\r\n startNode.by = BY_START;\r\n\r\n endOpenList.push(endNode);\r\n endNode.opened = true;\r\n endNode.by = BY_END;\r\n\r\n // while both the queues are not empty\r\n while (startOpenList.length && endOpenList.length) {\r\n\r\n // expand start open list\r\n\r\n node = startOpenList.shift();\r\n node.closed = true;\r\n\r\n neighbors = grid.getNeighbors(node, diagonalMovement);\r\n for (i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n\r\n if (neighbor.closed) {\r\n continue;\r\n }\r\n if (neighbor.opened) {\r\n // if this node has been inspected by the reversed search,\r\n // then a path is found.\r\n if (neighbor.by === BY_END) {\r\n return Util.biBacktrace(node, neighbor);\r\n }\r\n continue;\r\n }\r\n startOpenList.push(neighbor);\r\n neighbor.parent = node;\r\n neighbor.opened = true;\r\n neighbor.by = BY_START;\r\n }\r\n\r\n // expand end open list\r\n\r\n node = endOpenList.shift();\r\n node.closed = true;\r\n\r\n neighbors = grid.getNeighbors(node, diagonalMovement);\r\n for (i = 0, l = neighbors.length; i < l; ++i) {\r\n neighbor = neighbors[i];\r\n\r\n if (neighbor.closed) {\r\n continue;\r\n }\r\n if (neighbor.opened) {\r\n if (neighbor.by === BY_START) {\r\n return Util.biBacktrace(neighbor, node);\r\n }\r\n continue;\r\n }\r\n endOpenList.push(neighbor);\r\n neighbor.parent = node;\r\n neighbor.opened = true;\r\n neighbor.by = BY_END;\r\n }\r\n }\r\n\r\n // fail to find the path\r\n return [];\r\n};\r\n\r\nmodule.exports = BiBreadthFirstFinder;\r\n","module.exports = require('./src/PathFinding');\r\n","import router from '../../../router/index'\r\n\r\nexport const createText = (view, text, id, width, url1, docId, $state) => {\r\n\r\n\tvar rows = text.split(\"\\n\");\r\n\tvar t = view.text(0, 0, \"\").attr({ class: \"txt\" });\r\n\r\n\tfor (var i = 0; i < rows.length; i++)\r\n\t{\r\n\t\tvar row = rows[i];\r\n\r\n\t\tif (row == \"\")\r\n\t\t{\r\n\t\t\trows.splice(i, 1);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tvar spans = row.split(\" \");\r\n\t\tvar tmpRow = spans[0];\r\n\t\tfor (var j = 1; j < spans.length; j++)\r\n\t\t{\r\n\t\t\tif (tmpRow != \"\") tmpRow += \" \";\r\n\t\t\ttmpRow += spans[j];\r\n\r\n\t\t\tt.node.textContent = tmpRow;\r\n\t\t\tif (t.node.getBBox().width > width)\r\n\t\t\t{\r\n\t\t\t\trows[i] = \"\";\r\n\t\t\t\tfor (var k = 0; k < j; k++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (rows[i] != \"\") rows[i] += \" \";\r\n\t\t\t\t\trows[i] += spans[k];\r\n\t\t\t\t}\r\n\t\t\t\trows.splice(i + 1, 0, \"\");\r\n\t\t\t\tfor (var k = j; k < spans.length; k++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (rows[i + 1] != \"\") rows[i + 1] += \" \";\r\n\t\t\t\t\trows[i + 1] += spans[k];\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tt.remove();\r\n\tt = view.text(0, 0, rows).attr({ class: \"txt\", objid: id });\r\n\tvar spans = t.selectAll(\"tspan\");\r\n\tvar cnt = spans.length;\r\n\tspans[0].attr({ x: 0, dy: (-cnt / 2 + 0.8).toString() + \"em\", objid: id });\r\n\tfor (var i = 1; i < spans.length; i++)\r\n\t\tspans[i].attr({ x: 0, dy: \"1em\", objid: id });\r\n\r\n\tif (url1) {\r\n\r\n\r\n\t\tif (url1.length > 2) {\r\n\t\t\tt.node.onclick = () => {\r\n router.push(`/algo/${url1}`)\r\n\t\t\t};\r\n\t\t} else {\r\n\t\t\tt.node.onclick = () => {\r\n\t\t\t\tconsole.log(docId, url1)\r\n router.push(`/schema/${docId}/${url1}`)\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n\r\n\tt.attr({\r\n\t\t\"text-anchor\": \"middle\",\r\n\t\t\"font-style\": \"normal\",\r\n\t\t\"font-variant\": \"normal\",\r\n\t\t\"font-weight\": \"500\",\r\n\t\t\"font-stretch\": \"normal\",\r\n\t\t\"font-size\": \"11px\",\r\n\t\t\"line-height\": \"normal\",\r\n\t\t\"font-family\": \"\\\"Roboto\\\", arial, helvetica, verdana\",\r\n\t\t\"fill\": url1 ? \"#3f51b5\" : \"#607482\" ,\r\n\t\t\"cursor\": url1 ? \"pointer\" : \"default\",\r\n\t\t\"user-select\": \"none\"\r\n\t});\r\n\treturn t;\r\n};\r\n\r\n\r\nexport const getCircle = ( dir, view, width, height ) => {\r\n\tlet result;\r\n\tswitch (dir) {\r\n\tcase 1:\r\n\t\tresult = view.circle(-(width / 2), 0, 7);\r\n\t\tbreak;\r\n\tcase 2:\r\n\t\tresult = view.circle(0, -(height / 2), 7);\r\n\t\tbreak;\r\n\tcase 3:\r\n\t\tresult = view.circle(width / 2, 0, 7);\r\n\t\tbreak;\r\n\tcase 4:\r\n\t\tresult = view.circle(0, height / 2, 7);\r\n\t\tbreak;\r\n\r\n\tdefault:\r\n\t\tresult = false;\r\n\t}\r\n\r\n\tresult.attr({\r\n\t\t\"stroke-width\": 2,\r\n\t\t\"opacity\": 0,\r\n\t\t\"fill\": \"#40aee3\",\r\n\t\t\"dir\": dir\r\n\t});\r\n\tresult.dir = dir;\r\n\r\n\tresult.hover( () => {\r\n\t\tresult.attr(\"opacity\", \"1\");\r\n\t}, () => {\r\n\t\tresult.attr(\"opacity\", \"0\");\r\n\t});\r\n\r\n\treturn result;\r\n};\r\n\r\nexport const getLastItem = arr => {\r\n\treturn arr[arr.length - 1];\r\n};\r\n\r\nexport const getDirection = ( x, y ) => {\r\n\r\n\tlet type = 1;\r\n\r\n\tif ( x < 50 && x > -50 && y > 0 ) {\r\n\r\n\t\ttype = 4;\r\n\r\n\t} else if( x < 50 && x > -50 && y <= 0 ) {\r\n\r\n\t\ttype = 2;\r\n\r\n\t} else if( x >= 50 ) {\r\n\r\n\t\ttype = 3;\r\n\r\n\t} else if( x <= -50 ) {\r\n\r\n\t\ttype = 1;\r\n\r\n\t}\r\n\r\n\treturn type;\r\n\r\n};\r\n\r\nexport const getLines = (a) => {\r\n\treturn a.map((item, index) => {\r\n\t\tif (index) {\r\n\t\t\tlet ind = index - 1;\r\n\t\t\tlet prevItem = a[ind];\r\n\t\t\treturn [\r\n\t\t\t\t{\r\n\t\t\t\t\tx: prevItem.x,\r\n\t\t\t\t\ty: prevItem.y,\r\n\t\t\t\t\tm: true\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\tx: item.x,\r\n\t\t\t\t\ty: item.y,\r\n\t\t\t\t\tm: prevItem.x == item.x && prevItem.y == item.y,\r\n\t\t\t\t\th: prevItem.x != item.x && prevItem.y == item.y,\r\n\t\t\t\t\tv: prevItem.x == item.x && prevItem.y != item.y\r\n\t\t\t\t}\r\n\t\t\t];\r\n\t\t}\r\n \r\n\r\n\t}).filter(item => item);\r\n};\r\n\r\nexport const optimizePath = array => {\r\n\tif (!array.length) return array;\r\n\tlet currentPoint = array[0];\r\n\tlet result = [];\r\n\tlet foundedIndex = 0;\r\n\r\n\tresult.push(currentPoint);\r\n\r\n\tarray.forEach((item, index) => {\r\n\r\n\t\tif (item[foundedIndex] !== currentPoint[foundedIndex]) {\r\n\t\t\tfoundedIndex = foundedIndex ? 0 : 1;\r\n\t\t\tresult.push(currentPoint);\r\n\t\t\tcurrentPoint = item;\r\n\r\n\t\t} else {\r\n\t\t\tcurrentPoint = item;\r\n\t\t}\r\n\t});\r\n\r\n\tresult.push(array[array.length - 1]);\r\n\treturn result;\r\n};\r\n\r\nexport const createHint = (x, y, direct, parent) => {\r\n var o = { x: parent.x + x, y: parent.y + y, type: 'H', parent: parent, direct: direct }, s = Snap(\"#diagramSvg\");\r\n var p = s.path(\"M 196.963 300.274L 246.494 300.172L 246.494 261.69C 246.494 251.252 251.36 241.39 264.38 232.849C 277.399 224.312 313.744 206.988 313.744 161.44C 313.744 115.89 275.577 84.582 243.494 77.94C 211.416 71.298 176.659 75.668 151.994 102.69C 129.907 126.887 125.253 146.027 125.253 188.255L 174.744 188.255L 174.744 178.44C 174.744 155.939 177.347 132.186 209.494 125.69C 227.04 122.144 243.488 127.648 253.244 137.19C 264.404 148.102 264.494 172.69 246.711 184.933L 218.815 203.912C 202.543 214.35 196.963 225.971 196.963 243.051L 196.963 300.274z\").attr({\r\n transform: `matrix(0.05,0,0,0.05,${x-16},${y-18})`,\r\n stroke: 'black',\r\n objid: o.id,\r\n style: 'cursor:pointer;'\r\n }),\r\n c = s.circle(x,y,16).attr({fill: 'white', objid: o.id, type: 'H', style: 'cursor:pointer;opacity:0'}),\r\n b = s.path(\"M 196.638 370.692L 196.638 319.687L 246.85 319.687L 246.85 370.692L 196.638 370.692z\").attr({\r\n transform: `matrix(0.05,0,0,0.05,${x-16},${y-18})`,\r\n stroke: 'black',\r\n objid: o.id,\r\n style: 'cursor:pointer;'\r\n });\r\n o.el = s.group().append(c).append(b).append(p)\r\n .click(event=> {\r\n let tooltip = document.getElementById(\"tooltip\");\r\n tooltip.innerHTML = parent.url3;\r\n tooltip.style.display = \"block\";\r\n tooltip.style.left = event.pageX + 30 + 'px';\r\n tooltip.style.top = event.pageY + -30 + 'px';\r\n })\r\n\r\n o.el.node.onmouseout = _ => {\r\n let tooltip = document.getElementById(\"tooltip\");\r\n tooltip.style.display = \"none\";\r\n }\r\n\r\n return o;\r\n}\r\nexport const createKK = (x, y, direct, parent) => {\r\n var o = { x: parent.x + x, y: parent.y + y, type: 'KK', parent: parent, direct: direct }, s = Snap(\"#diagramSvg\");\r\n\r\n if(parent.width == 240) x = 100\r\n if(parent.width == 320) x = 140\r\n \r\n var p = s.path(\"M10.2,-2.64a27.49,27.49,0,0,1-1.22,6.21,28.32,28.32,0,0,1-2.66,5.8,27.41,27.41,0,0,1-6.31.74,27,27,0,0,1-6.32-.73h0a27.7,27.7,0,0,1-3.91-12h0a27.44,27.44,0,0,1,4.67-4.3,27.09,27.09,0,0,1,5.55-3.11h0a27.68,27.68,0,0,1,5.53,3.1,27.21,27.21,0,0,1,4.68,4.32h0Zm-4.37,11.34a26.35,26.35,0,0,0,3.59-11.08h0a26.39,26.39,0,0,0-4.35-4,27,27,0,0,0-5.08-2.9,26.28,26.28,0,0,0-5.1,2.91,26.8,26.8,0,0,0-4.32,3.93h0a26.65,26.65,0,0,0,1.19,5.77,26.23,26.23,0,0,0,2.4,5.32h0a26.58,26.58,0,0,0,11.67,0h0Zm-5.83-4,5.79,3.94-5.79-7.1-5.79,7.1,5.79-3.94h0Zm0-3.17L8.2,-2.03a38.51,38.51,0,0,1-16.31,0l8.16,3.54h0Z\").attr({\r\n transform: `matrix(1,0,0,1,${x},${y})`,\r\n objid: o.id,\r\n style: 'cursor:pointer;'\r\n }),\r\n c = s.circle(x,y,16).attr({fill: 'white', objid: o.id, type: 'H', style: 'cursor:pointer;opacity:0'});\r\n o.el = s.group().append(c).append(p)\r\n .click(event=> {\r\n let tooltip = document.getElementById(\"tooltip\");\r\n tooltip.innerHTML = parent.url2;\r\n tooltip.style.display = \"block\";\r\n tooltip.style.left = event.pageX + 30 + 'px';\r\n tooltip.style.top = event.pageY + -30 + 'px';\r\n })\r\n\r\n o.el.node.onmouseout = _ => {\r\n let tooltip = document.getElementById(\"tooltip\");\r\n tooltip.style.display = \"none\";\r\n }\r\n return o;\r\n}\r\n\r\nexport const convertPointToA = (points, step) => {\r\n\tlet a = []; \r\n\tlet optPoints = optimizePath(points);\r\n\toptPoints.forEach( ( point, index ) => {\r\n\t\tlet prevItem = index ? optPoints[index - 1]: optPoints[index];\r\n\t\ta.push({\r\n\t\t\tx: point[0] * step,\r\n\t\t\ty: point[1] * step,\r\n\t\t\tm: prevItem[0] == point[0] && prevItem[1] == point[1],\r\n\t\t\th: prevItem[0] != point[0] && prevItem[1] == point[1],\r\n\t\t\tv: prevItem[0] == point[0] && prevItem[1] != point[1]\r\n\t\t});\r\n\t});\r\n\r\n\treturn a;\r\n\r\n};\r\n\r\nexport const getCirclePoint = (x, y, width, height, dir, dif) => {\r\n\r\n\tlet result = { x, y };\r\n\r\n\tswitch (dir) {\r\n\tcase 1:\r\n\t\tresult.x += -( width / 2 + dif );\r\n\t\tbreak;\r\n\tcase 2:\r\n\t\tresult.y += -( height / 2 + dif );\r\n\t\tbreak;\r\n\tcase 3:\r\n\t\tresult.x += ( width / 2 + dif );\r\n\t\tbreak;\r\n\tcase 4:\r\n\t\tresult.y += ( height / 2 + dif );\r\n\t\tbreak;\r\n\r\n\tdefault:\r\n\t\tresult = false;\r\n }\r\n\r\n\treturn result;\r\n\r\n\r\n};\r\n\r\nexport const getLastLine = (dir, point) => {\r\n\tlet result = [];\r\n\tswitch (dir) {\r\n\tcase 1:\r\n\t\tresult = [ point[0] + 1, point[1]];\r\n\t\tbreak;\r\n\tcase 2:\r\n\t\tresult = [ point[0], point[1] + 1];\r\n\t\tbreak;\r\n\tcase 3:\r\n\t\tresult = [ point[0] - 1, point[1]];\r\n\t\tbreak;\r\n\tcase 4:\r\n\t\tresult = [ point[0], point[1] - 1];\r\n\t\tbreak;\r\n\r\n\tdefault:\r\n\t\tresult = [0,0];\r\n\t}\r\n\r\n\treturn result;\r\n\r\n};\r\n\r\nexport const getFirstLine = (dir, point, rect, tmp) => {\r\n\tlet dif = rect == 'romb' ? 0.5 : 0\r\n\tdif = tmp ? -0.5 : dif;\r\n\tlet result = [];\r\n\tswitch (dir) {\r\n\tcase 1:\r\n\t\tdif = tmp ? 1.5 : dif;\r\n\t\tresult = [ point[0] + ( 1 - dif ) , point[1]];\r\n\t\tbreak;\r\n\tcase 2:\r\n\t\tdif = tmp ? 1.5 : dif;\r\n\t\tresult = [ point[0], point[1] + ( 1 - dif )];\r\n\t\tbreak;\r\n\tcase 3:\r\n\t\tresult = [ point[0] - ( 1 + dif ), point[1]];\r\n\t\tbreak;\r\n\tcase 4:\r\n\t\tresult = [ point[0], point[1] - ( 1 + dif )];\r\n\t\tbreak;\r\n\r\n\tdefault:\r\n\t\tresult = [0,0];\r\n\t}\r\n\r\n\treturn result;\r\n\r\n};\r\n\r\n","/**\r\n * @author aniero / https://github.com/aniero\r\n */\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\nvar JPFNeverMoveDiagonally = require('./JPFNeverMoveDiagonally');\r\nvar JPFAlwaysMoveDiagonally = require('./JPFAlwaysMoveDiagonally');\r\nvar JPFMoveDiagonallyIfNoObstacles = require('./JPFMoveDiagonallyIfNoObstacles');\r\nvar JPFMoveDiagonallyIfAtMostOneObstacle = require('./JPFMoveDiagonallyIfAtMostOneObstacle');\r\n\r\n/**\r\n * Path finder using the Jump Point Search algorithm\r\n * @param {Object} opt\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n * @param {DiagonalMovement} opt.diagonalMovement Condition under which diagonal\r\n * movement will be allowed.\r\n */\r\nfunction JumpPointFinder(opt) {\r\n opt = opt || {};\r\n if (opt.diagonalMovement === DiagonalMovement.Never) {\r\n return new JPFNeverMoveDiagonally(opt);\r\n } else if (opt.diagonalMovement === DiagonalMovement.Always) {\r\n return new JPFAlwaysMoveDiagonally(opt);\r\n } else if (opt.diagonalMovement === DiagonalMovement.OnlyWhenNoObstacles) {\r\n return new JPFMoveDiagonallyIfNoObstacles(opt);\r\n } else {\r\n return new JPFMoveDiagonallyIfAtMostOneObstacle(opt);\r\n }\r\n}\r\n\r\nmodule.exports = JumpPointFinder;\r\n","/**\r\n * @author imor / https://github.com/imor\r\n */\r\nvar JumpPointFinderBase = require('./JumpPointFinderBase');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Path finder using the Jump Point Search algorithm which moves\r\n * diagonally only when there is at most one obstacle.\r\n */\r\nfunction JPFMoveDiagonallyIfAtMostOneObstacle(opt) {\r\n JumpPointFinderBase.call(this, opt);\r\n}\r\n\r\nJPFMoveDiagonallyIfAtMostOneObstacle.prototype = new JumpPointFinderBase();\r\nJPFMoveDiagonallyIfAtMostOneObstacle.prototype.constructor = JPFMoveDiagonallyIfAtMostOneObstacle;\r\n\r\n/**\r\n * Search recursively in the direction (parent -> child), stopping only when a\r\n * jump point is found.\r\n * @protected\r\n * @return {Array>} The x, y coordinate of the jump point\r\n * found, or null if not found\r\n */\r\nJPFMoveDiagonallyIfAtMostOneObstacle.prototype._jump = function(x, y, px, py) {\r\n var grid = this.grid,\r\n dx = x - px, dy = y - py;\r\n\r\n if (!grid.isWalkableAt(x, y)) {\r\n return null;\r\n }\r\n\r\n if(this.trackJumpRecursion === true) {\r\n grid.getNodeAt(x, y).tested = true;\r\n }\r\n\r\n if (grid.getNodeAt(x, y) === this.endNode) {\r\n return [x, y];\r\n }\r\n\r\n // check for forced neighbors\r\n // along the diagonal\r\n if (dx !== 0 && dy !== 0) {\r\n if ((grid.isWalkableAt(x - dx, y + dy) && !grid.isWalkableAt(x - dx, y)) ||\r\n (grid.isWalkableAt(x + dx, y - dy) && !grid.isWalkableAt(x, y - dy))) {\r\n return [x, y];\r\n }\r\n // when moving diagonally, must check for vertical/horizontal jump points\r\n if (this._jump(x + dx, y, x, y) || this._jump(x, y + dy, x, y)) {\r\n return [x, y];\r\n }\r\n }\r\n // horizontally/vertically\r\n else {\r\n if( dx !== 0 ) { // moving along x\r\n if((grid.isWalkableAt(x + dx, y + 1) && !grid.isWalkableAt(x, y + 1)) ||\r\n (grid.isWalkableAt(x + dx, y - 1) && !grid.isWalkableAt(x, y - 1))) {\r\n return [x, y];\r\n }\r\n }\r\n else {\r\n if((grid.isWalkableAt(x + 1, y + dy) && !grid.isWalkableAt(x + 1, y)) ||\r\n (grid.isWalkableAt(x - 1, y + dy) && !grid.isWalkableAt(x - 1, y))) {\r\n return [x, y];\r\n }\r\n }\r\n }\r\n\r\n // moving diagonally, must make sure one of the vertical/horizontal\r\n // neighbors is open to allow the path\r\n if (grid.isWalkableAt(x + dx, y) || grid.isWalkableAt(x, y + dy)) {\r\n return this._jump(x + dx, y + dy, x, y);\r\n } else {\r\n return null;\r\n }\r\n};\r\n\r\n/**\r\n * Find the neighbors for the given node. If the node has a parent,\r\n * prune the neighbors based on the jump point search algorithm, otherwise\r\n * return all available neighbors.\r\n * @return {Array>} The neighbors found.\r\n */\r\nJPFMoveDiagonallyIfAtMostOneObstacle.prototype._findNeighbors = function(node) {\r\n var parent = node.parent,\r\n x = node.x, y = node.y,\r\n grid = this.grid,\r\n px, py, nx, ny, dx, dy,\r\n neighbors = [], neighborNodes, neighborNode, i, l;\r\n\r\n // directed pruning: can ignore most neighbors, unless forced.\r\n if (parent) {\r\n px = parent.x;\r\n py = parent.y;\r\n // get the normalized direction of travel\r\n dx = (x - px) / Math.max(Math.abs(x - px), 1);\r\n dy = (y - py) / Math.max(Math.abs(y - py), 1);\r\n\r\n // search diagonally\r\n if (dx !== 0 && dy !== 0) {\r\n if (grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x, y + dy]);\r\n }\r\n if (grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y]);\r\n }\r\n if (grid.isWalkableAt(x, y + dy) || grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x - dx, y) && grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x - dx, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x, y - dy) && grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y - dy]);\r\n }\r\n }\r\n // search horizontally/vertically\r\n else {\r\n if(dx === 0) {\r\n if (grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x, y + dy]);\r\n if (!grid.isWalkableAt(x + 1, y)) {\r\n neighbors.push([x + 1, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x - 1, y)) {\r\n neighbors.push([x - 1, y + dy]);\r\n }\r\n }\r\n }\r\n else {\r\n if (grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y]);\r\n if (!grid.isWalkableAt(x, y + 1)) {\r\n neighbors.push([x + dx, y + 1]);\r\n }\r\n if (!grid.isWalkableAt(x, y - 1)) {\r\n neighbors.push([x + dx, y - 1]);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n // return all neighbors\r\n else {\r\n neighborNodes = grid.getNeighbors(node, DiagonalMovement.IfAtMostOneObstacle);\r\n for (i = 0, l = neighborNodes.length; i < l; ++i) {\r\n neighborNode = neighborNodes[i];\r\n neighbors.push([neighborNode.x, neighborNode.y]);\r\n }\r\n }\r\n\r\n return neighbors;\r\n};\r\n\r\nmodule.exports = JPFMoveDiagonallyIfAtMostOneObstacle;\r\n","var AStarFinder = require('./AStarFinder');\r\n\r\n/**\r\n * Best-First-Search path-finder.\r\n * @constructor\r\n * @extends AStarFinder\r\n * @param {Object} opt\r\n * @param {boolean} opt.allowDiagonal Whether diagonal movement is allowed.\r\n * Deprecated, use diagonalMovement instead.\r\n * @param {boolean} opt.dontCrossCorners Disallow diagonal movement touching\r\n * block corners. Deprecated, use diagonalMovement instead.\r\n * @param {DiagonalMovement} opt.diagonalMovement Allowed diagonal movement.\r\n * @param {function} opt.heuristic Heuristic function to estimate the distance\r\n * (defaults to manhattan).\r\n */\r\nfunction BestFirstFinder(opt) {\r\n AStarFinder.call(this, opt);\r\n\r\n var orig = this.heuristic;\r\n this.heuristic = function(dx, dy) {\r\n return orig(dx, dy) * 1000000;\r\n };\r\n}\r\n\r\nBestFirstFinder.prototype = new AStarFinder();\r\nBestFirstFinder.prototype.constructor = BestFirstFinder;\r\n\r\nmodule.exports = BestFirstFinder;\r\n","/**\r\n * @author imor / https://github.com/imor\r\n */\r\nvar JumpPointFinderBase = require('./JumpPointFinderBase');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Path finder using the Jump Point Search algorithm which always moves\r\n * diagonally irrespective of the number of obstacles.\r\n */\r\nfunction JPFAlwaysMoveDiagonally(opt) {\r\n JumpPointFinderBase.call(this, opt);\r\n}\r\n\r\nJPFAlwaysMoveDiagonally.prototype = new JumpPointFinderBase();\r\nJPFAlwaysMoveDiagonally.prototype.constructor = JPFAlwaysMoveDiagonally;\r\n\r\n/**\r\n * Search recursively in the direction (parent -> child), stopping only when a\r\n * jump point is found.\r\n * @protected\r\n * @return {Array>} The x, y coordinate of the jump point\r\n * found, or null if not found\r\n */\r\nJPFAlwaysMoveDiagonally.prototype._jump = function(x, y, px, py) {\r\n var grid = this.grid,\r\n dx = x - px, dy = y - py;\r\n\r\n if (!grid.isWalkableAt(x, y)) {\r\n return null;\r\n }\r\n\r\n if(this.trackJumpRecursion === true) {\r\n grid.getNodeAt(x, y).tested = true;\r\n }\r\n\r\n if (grid.getNodeAt(x, y) === this.endNode) {\r\n return [x, y];\r\n }\r\n\r\n // check for forced neighbors\r\n // along the diagonal\r\n if (dx !== 0 && dy !== 0) {\r\n if ((grid.isWalkableAt(x - dx, y + dy) && !grid.isWalkableAt(x - dx, y)) ||\r\n (grid.isWalkableAt(x + dx, y - dy) && !grid.isWalkableAt(x, y - dy))) {\r\n return [x, y];\r\n }\r\n // when moving diagonally, must check for vertical/horizontal jump points\r\n if (this._jump(x + dx, y, x, y) || this._jump(x, y + dy, x, y)) {\r\n return [x, y];\r\n }\r\n }\r\n // horizontally/vertically\r\n else {\r\n if( dx !== 0 ) { // moving along x\r\n if((grid.isWalkableAt(x + dx, y + 1) && !grid.isWalkableAt(x, y + 1)) ||\r\n (grid.isWalkableAt(x + dx, y - 1) && !grid.isWalkableAt(x, y - 1))) {\r\n return [x, y];\r\n }\r\n }\r\n else {\r\n if((grid.isWalkableAt(x + 1, y + dy) && !grid.isWalkableAt(x + 1, y)) ||\r\n (grid.isWalkableAt(x - 1, y + dy) && !grid.isWalkableAt(x - 1, y))) {\r\n return [x, y];\r\n }\r\n }\r\n }\r\n\r\n return this._jump(x + dx, y + dy, x, y);\r\n};\r\n\r\n/**\r\n * Find the neighbors for the given node. If the node has a parent,\r\n * prune the neighbors based on the jump point search algorithm, otherwise\r\n * return all available neighbors.\r\n * @return {Array>} The neighbors found.\r\n */\r\nJPFAlwaysMoveDiagonally.prototype._findNeighbors = function(node) {\r\n var parent = node.parent,\r\n x = node.x, y = node.y,\r\n grid = this.grid,\r\n px, py, nx, ny, dx, dy,\r\n neighbors = [], neighborNodes, neighborNode, i, l;\r\n\r\n // directed pruning: can ignore most neighbors, unless forced.\r\n if (parent) {\r\n px = parent.x;\r\n py = parent.y;\r\n // get the normalized direction of travel\r\n dx = (x - px) / Math.max(Math.abs(x - px), 1);\r\n dy = (y - py) / Math.max(Math.abs(y - py), 1);\r\n\r\n // search diagonally\r\n if (dx !== 0 && dy !== 0) {\r\n if (grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x, y + dy]);\r\n }\r\n if (grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y]);\r\n }\r\n if (grid.isWalkableAt(x + dx, y + dy)) {\r\n neighbors.push([x + dx, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x - dx, y)) {\r\n neighbors.push([x - dx, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x, y - dy)) {\r\n neighbors.push([x + dx, y - dy]);\r\n }\r\n }\r\n // search horizontally/vertically\r\n else {\r\n if(dx === 0) {\r\n if (grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x + 1, y)) {\r\n neighbors.push([x + 1, y + dy]);\r\n }\r\n if (!grid.isWalkableAt(x - 1, y)) {\r\n neighbors.push([x - 1, y + dy]);\r\n }\r\n }\r\n else {\r\n if (grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y]);\r\n }\r\n if (!grid.isWalkableAt(x, y + 1)) {\r\n neighbors.push([x + dx, y + 1]);\r\n }\r\n if (!grid.isWalkableAt(x, y - 1)) {\r\n neighbors.push([x + dx, y - 1]);\r\n }\r\n }\r\n }\r\n }\r\n // return all neighbors\r\n else {\r\n neighborNodes = grid.getNeighbors(node, DiagonalMovement.Always);\r\n for (i = 0, l = neighborNodes.length; i < l; ++i) {\r\n neighborNode = neighborNodes[i];\r\n neighbors.push([neighborNode.x, neighborNode.y]);\r\n }\r\n }\r\n\r\n return neighbors;\r\n};\r\n\r\nmodule.exports = JPFAlwaysMoveDiagonally;\r\n","/**\r\n * @author imor / https://github.com/imor\r\n */\r\nvar JumpPointFinderBase = require('./JumpPointFinderBase');\r\nvar DiagonalMovement = require('../core/DiagonalMovement');\r\n\r\n/**\r\n * Path finder using the Jump Point Search algorithm which moves\r\n * diagonally only when there are no obstacles.\r\n */\r\nfunction JPFMoveDiagonallyIfNoObstacles(opt) {\r\n JumpPointFinderBase.call(this, opt);\r\n}\r\n\r\nJPFMoveDiagonallyIfNoObstacles.prototype = new JumpPointFinderBase();\r\nJPFMoveDiagonallyIfNoObstacles.prototype.constructor = JPFMoveDiagonallyIfNoObstacles;\r\n\r\n/**\r\n * Search recursively in the direction (parent -> child), stopping only when a\r\n * jump point is found.\r\n * @protected\r\n * @return {Array>} The x, y coordinate of the jump point\r\n * found, or null if not found\r\n */\r\nJPFMoveDiagonallyIfNoObstacles.prototype._jump = function(x, y, px, py) {\r\n var grid = this.grid,\r\n dx = x - px, dy = y - py;\r\n\r\n if (!grid.isWalkableAt(x, y)) {\r\n return null;\r\n }\r\n\r\n if(this.trackJumpRecursion === true) {\r\n grid.getNodeAt(x, y).tested = true;\r\n }\r\n\r\n if (grid.getNodeAt(x, y) === this.endNode) {\r\n return [x, y];\r\n }\r\n\r\n // check for forced neighbors\r\n // along the diagonal\r\n if (dx !== 0 && dy !== 0) {\r\n // if ((grid.isWalkableAt(x - dx, y + dy) && !grid.isWalkableAt(x - dx, y)) ||\r\n // (grid.isWalkableAt(x + dx, y - dy) && !grid.isWalkableAt(x, y - dy))) {\r\n // return [x, y];\r\n // }\r\n // when moving diagonally, must check for vertical/horizontal jump points\r\n if (this._jump(x + dx, y, x, y) || this._jump(x, y + dy, x, y)) {\r\n return [x, y];\r\n }\r\n }\r\n // horizontally/vertically\r\n else {\r\n if (dx !== 0) {\r\n if ((grid.isWalkableAt(x, y - 1) && !grid.isWalkableAt(x - dx, y - 1)) ||\r\n (grid.isWalkableAt(x, y + 1) && !grid.isWalkableAt(x - dx, y + 1))) {\r\n return [x, y];\r\n }\r\n }\r\n else if (dy !== 0) {\r\n if ((grid.isWalkableAt(x - 1, y) && !grid.isWalkableAt(x - 1, y - dy)) ||\r\n (grid.isWalkableAt(x + 1, y) && !grid.isWalkableAt(x + 1, y - dy))) {\r\n return [x, y];\r\n }\r\n // When moving vertically, must check for horizontal jump points\r\n // if (this._jump(x + 1, y, x, y) || this._jump(x - 1, y, x, y)) {\r\n // return [x, y];\r\n // }\r\n }\r\n }\r\n\r\n // moving diagonally, must make sure one of the vertical/horizontal\r\n // neighbors is open to allow the path\r\n if (grid.isWalkableAt(x + dx, y) && grid.isWalkableAt(x, y + dy)) {\r\n return this._jump(x + dx, y + dy, x, y);\r\n } else {\r\n return null;\r\n }\r\n};\r\n\r\n/**\r\n * Find the neighbors for the given node. If the node has a parent,\r\n * prune the neighbors based on the jump point search algorithm, otherwise\r\n * return all available neighbors.\r\n * @return {Array>} The neighbors found.\r\n */\r\nJPFMoveDiagonallyIfNoObstacles.prototype._findNeighbors = function(node) {\r\n var parent = node.parent,\r\n x = node.x, y = node.y,\r\n grid = this.grid,\r\n px, py, nx, ny, dx, dy,\r\n neighbors = [], neighborNodes, neighborNode, i, l;\r\n\r\n // directed pruning: can ignore most neighbors, unless forced.\r\n if (parent) {\r\n px = parent.x;\r\n py = parent.y;\r\n // get the normalized direction of travel\r\n dx = (x - px) / Math.max(Math.abs(x - px), 1);\r\n dy = (y - py) / Math.max(Math.abs(y - py), 1);\r\n\r\n // search diagonally\r\n if (dx !== 0 && dy !== 0) {\r\n if (grid.isWalkableAt(x, y + dy)) {\r\n neighbors.push([x, y + dy]);\r\n }\r\n if (grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y]);\r\n }\r\n if (grid.isWalkableAt(x, y + dy) && grid.isWalkableAt(x + dx, y)) {\r\n neighbors.push([x + dx, y + dy]);\r\n }\r\n }\r\n // search horizontally/vertically\r\n else {\r\n var isNextWalkable;\r\n if (dx !== 0) {\r\n isNextWalkable = grid.isWalkableAt(x + dx, y);\r\n var isTopWalkable = grid.isWalkableAt(x, y + 1);\r\n var isBottomWalkable = grid.isWalkableAt(x, y - 1);\r\n\r\n if (isNextWalkable) {\r\n neighbors.push([x + dx, y]);\r\n if (isTopWalkable) {\r\n neighbors.push([x + dx, y + 1]);\r\n }\r\n if (isBottomWalkable) {\r\n neighbors.push([x + dx, y - 1]);\r\n }\r\n }\r\n if (isTopWalkable) {\r\n neighbors.push([x, y + 1]);\r\n }\r\n if (isBottomWalkable) {\r\n neighbors.push([x, y - 1]);\r\n }\r\n }\r\n else if (dy !== 0) {\r\n isNextWalkable = grid.isWalkableAt(x, y + dy);\r\n var isRightWalkable = grid.isWalkableAt(x + 1, y);\r\n var isLeftWalkable = grid.isWalkableAt(x - 1, y);\r\n\r\n if (isNextWalkable) {\r\n neighbors.push([x, y + dy]);\r\n if (isRightWalkable) {\r\n neighbors.push([x + 1, y + dy]);\r\n }\r\n if (isLeftWalkable) {\r\n neighbors.push([x - 1, y + dy]);\r\n }\r\n }\r\n if (isRightWalkable) {\r\n neighbors.push([x + 1, y]);\r\n }\r\n if (isLeftWalkable) {\r\n neighbors.push([x - 1, y]);\r\n }\r\n }\r\n }\r\n }\r\n // return all neighbors\r\n else {\r\n neighborNodes = grid.getNeighbors(node, DiagonalMovement.OnlyWhenNoObstacles);\r\n for (i = 0, l = neighborNodes.length; i < l; ++i) {\r\n neighborNode = neighborNodes[i];\r\n neighbors.push([neighborNode.x, neighborNode.y]);\r\n }\r\n }\r\n\r\n return neighbors;\r\n};\r\n\r\nmodule.exports = JPFMoveDiagonallyIfNoObstacles;\r\n","module.exports = {\r\n 'Heap' : require('heap'),\r\n 'Node' : require('./core/Node'),\r\n 'Grid' : require('./core/Grid'),\r\n 'Util' : require('./core/Util'),\r\n 'DiagonalMovement' : require('./core/DiagonalMovement'),\r\n 'Heuristic' : require('./core/Heuristic'),\r\n 'AStarFinder' : require('./finders/AStarFinder'),\r\n 'BestFirstFinder' : require('./finders/BestFirstFinder'),\r\n 'BreadthFirstFinder' : require('./finders/BreadthFirstFinder'),\r\n 'DijkstraFinder' : require('./finders/DijkstraFinder'),\r\n 'BiAStarFinder' : require('./finders/BiAStarFinder'),\r\n 'BiBestFirstFinder' : require('./finders/BiBestFirstFinder'),\r\n 'BiBreadthFirstFinder' : require('./finders/BiBreadthFirstFinder'),\r\n 'BiDijkstraFinder' : require('./finders/BiDijkstraFinder'),\r\n 'IDAStarFinder' : require('./finders/IDAStarFinder'),\r\n 'JumpPointFinder' : require('./finders/JumpPointFinder'),\r\n};\r\n"],"sourceRoot":""}