gojs
Version:
Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams
2 lines • 109 kB
JavaScript
/*! Copyright (C) 1998-2020 by Northwoods Software Corporation. All Rights Reserved. */
window.gfp=function(t){var e={};function a(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)a.d(n,o,function(e){return t[e]}.bind(null,o));return n},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=3)}([function(t,e){t.exports=window.go},function(t,e,a){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)e.hasOwnProperty(a)&&(t[a]=e[a])})(t,e)},function(t,e){function a(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)});Object.defineProperty(e,"__esModule",{value:!0});var i=a(0),r=function(t){function e(){var e=t.call(this)||this;return e._buildingWall=null,e._isBuildingDivider=!1,e.name="WallBuilding",e._startPoint=null,e._endPoint=null,e._wallReshapingTool=null,e._isBuildingDivider=!1,e}return o(e,t),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._startPoint},set:function(t){this._startPoint=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._endPoint},set:function(t){this._endPoint=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wallReshapingTool",{get:function(){return this._wallReshapingTool},set:function(t){this._wallReshapingTool=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buildingWall",{get:function(){return this._buildingWall},set:function(t){this._buildingWall=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBuildingDivider",{get:function(){return this._isBuildingDivider},set:function(t){this._isBuildingDivider=t},enumerable:!0,configurable:!0}),e.prototype.doActivate=function(){this.endPoint=null,this.startTransaction(this.name),this.diagram.isMouseCaptured=!0;var t=this,e=t.diagram,a=t.diagram.lastInput.documentPoint,n=!1,o=e.findNodesByExample({category:"WallGroup"});o.iterator.each(function(o){if(e.isPointInWall(o,a)&&null===t.buildingWall){var i=a.projectOntoLineSegmentPoint(o.data.startpoint,o.data.endpoint);a=i,n=!0}}),o.iterator.each(function(t){var e=t.data.startpoint,o=t.data.endpoint;Math.sqrt(e.distanceSquaredPoint(a))<15&&(a=e,n=!0),Math.sqrt(o.distanceSquaredPoint(a))<15&&(a=o,n=!0)});var r=e.model.modelData.gridSize;t.diagram.toolManager.draggingTool.isGridSnapEnabled&&!n||(r=1e-4);var l=r*Math.round(a.x/r),d=r*Math.round(a.y/r);a=new i.Point(l,d),this.startPoint=a,this.wallReshapingTool=e.toolManager.mouseDownTools.elt(3),this.isActive=!0},e.prototype.doMouseDown=function(){var t=this.diagram;this.diagram.currentCursor="crosshair";var e={key:"wall",category:"WallGroup",caption:this.isBuildingDivider?"Divider":"Wall",type:this.isBuildingDivider?"Divider":"Wall",startpoint:this.startPoint,endpoint:this.startPoint,smpt1:this.startPoint,smpt2:this.startPoint,empt1:this.startPoint,empt2:this.startPoint,thickness:this._isBuildingDivider?.005:parseFloat(t.model.modelData.wallThickness),color:"lightgray",isGroup:!0,notes:"",isDivider:this.isBuildingDivider};this.diagram.model.addNodeData(e);var a=t.findPartForKey(e.key);this.buildingWall=a,t.updateWall(a);var n=t.findPartForData(e);null!==n&&(this.transactionResult=this.name,t.raiseDiagramEvent("PartCreated",n),null!==this.wallReshapingTool&&(this.wallReshapingTool.isEnabled=!0,t.select(n),this.wallReshapingTool.isBuilding=!0,this.wallReshapingTool.adornedShape=n.findObject("SHAPE"),this.wallReshapingTool.doActivate()))},e.prototype.doKeyDown=function(){var t=this.diagram;if("Esc"===t.lastInput.key){var e=t.selection.first();t.remove(e),t.pointNodes.iterator.each(function(e){t.remove(e)}),t.dimensionLinks.iterator.each(function(e){t.remove(e)}),t.pointNodes.clear(),t.dimensionLinks.clear(),this.doDeactivate()}i.Tool.prototype.doKeyDown.call(this)},e.prototype.doMouseMove=function(){null!==this.wallReshapingTool&&(this.diagram.currentCursor="crosshair",this.wallReshapingTool.doMouseMove())},e.prototype.doDeactivate=function(){var t=this.diagram;this.buildingWall=null,this.diagram.currentCursor="",this.diagram.isMouseCaptured=!1,null!==this.wallReshapingTool&&(this.wallReshapingTool.isEnabled=!1,this.wallReshapingTool.adornedShape=null,this.wallReshapingTool.doMouseUp(),this.wallReshapingTool.doDeactivate(),this.wallReshapingTool.isBuilding=!1),t.updateWallDimensions(),this.stopTransaction(),this.isActive=!1},e}(i.Tool);e.WallBuildingTool=r},function(t,e,a){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)e.hasOwnProperty(a)&&(t[a]=e[a])})(t,e)},function(t,e){function a(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)});Object.defineProperty(e,"__esModule",{value:!0});var i=a(0),r=function(t){function e(){var e=t.call(this)||this,a=new i.Shape;return a.figure="Diamond",a.desiredSize=new i.Size(12,12),a.fill="lightblue",a.stroke="dodgerblue",a.cursor="move",e._handleArchetype=a,e._handle=null,e._adornedShape=null,e._reshapeObjectName="SHAPE",e._angle=0,e._length=0,e._isBuilding=!1,e._isIntersecting=!1,e._joinedWalls=new i.Set,e._returnPoint=null,e._returnData=null,e._joinedWalls=new i.Set,e._wallIntersecting=null,e}return o(e,t),Object.defineProperty(e.prototype,"handleArchetype",{get:function(){return this._handleArchetype},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"handle",{get:function(){return this._handle},set:function(t){this._handle=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"adornedShape",{get:function(){return this._adornedShape},set:function(t){this._adornedShape=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._length},set:function(t){this._length=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reshapeObjectName",{get:function(){return this._reshapeObjectName},set:function(t){this._reshapeObjectName=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBuilding",{get:function(){return this._isBuilding},set:function(t){this._isBuilding=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"returnData",{get:function(){return this._returnData},set:function(t){this._returnData=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"returnPoint",{get:function(){return this._returnPoint},set:function(t){this._returnPoint=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isIntersecting",{get:function(){return this._isIntersecting},set:function(t){this._isIntersecting=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wallIntersecting",{get:function(){return this._wallIntersecting},set:function(t){this._wallIntersecting=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"joinedWalls",{get:function(){return this._joinedWalls},set:function(t){this._joinedWalls=t},enumerable:!0,configurable:!0}),e.prototype.updateAdornments=function(t){if(!(null===t||t instanceof i.Link)){if(t.isSelected&&!this.diagram.isReadOnly){var e=t.findObject(this.reshapeObjectName);if(null!==e&&null!==e.part&&"WallGroup"===e.part.data.category){var a=e,n=t.findAdornment(this.name);if(null===n&&(n=this.makeAdornment(a)),null!==n&&null!==a.part&&null!=a.geometry){var o=a.geometry.bounds,r=a.part.actualBounds,l=n.findObject("BODY");if(null===l)return;return l.desiredSize=o.size,n.elements.each(function(e){if(void 0!==e.name){var a=0,n=0;switch(e.name){case"sPt":a=t.data.startpoint.x-r.x,n=t.data.startpoint.y-r.y;break;case"ePt":a=t.data.endpoint.x-r.x,n=t.data.endpoint.y-r.y}var l=Math.min((a-o.x)/o.width,1),d=Math.min((n-o.y)/o.height,1);l<0&&(l=0),d<0&&(d=0),l>1&&(l=1),d>1&&(d=1),isNaN(l)&&(l=0),isNaN(d)&&(d=0),e.alignment=new i.Spot(Math.max(0,l),Math.max(0,d))}}),t.addAdornment(this.name,n),void(n.location=a.getDocumentPoint(i.Spot.Center))}}}t.removeAdornment(this.name)}},e.prototype.canStart=function(){if(!this.isEnabled)return!1;var t=this.diagram;return null!==t&&!t.isReadOnly&&(!!t.allowReshape&&(!!t.lastInput.left&&(null!==this.findToolHandleAt(t.firstInput.documentPoint,this.name)||this.isBuilding)))},e.prototype.doActivate=function(){var t=this.diagram;if(null!==t){if(this.isBuilding){if(null!==this.adornedShape&&null!==this.adornedShape.part){var e=this.adornedShape.part;this.handle=this.findToolHandleAt(e.data.endpoint,this.name),this.returnPoint=e.data.startpoint}}else{if(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name),null===this.handle)return;var a=this.handle.part.adornedObject;e=a.part;if(!a)return;this.adornedShape=a,this.returnPoint="sPt"===this.handle.name?e.data.startpoint:e.data.endpoint;var n=e.memberParts;if(0!==n.count){var o=new i.Map;n.iterator.each(function(t){o.add(t.data.key,t.location)}),this.returnData=o}}this.startTransaction(this.name),this.isActive=!0}},e.prototype.doMouseMove=function(){var t=this.diagram,e=this;if(null!==e.handle){var a=e.handle.part.adornedPart,n=t.lastInput.documentPoint;if(e.isActive&&null!==t){if(t.lastInput.shift){var o="sPt"===e.handle.name?a.data.endpoint:a.data.startpoint,r=o.directionPoint(n),l=Math.sqrt(o.distanceSquaredPoint(n));r=45*Math.round(r/45);var d=new i.Point(o.x+l,o.y),s=o.x,u=o.y;d=(d=(d=d.offset(-s,-u)).rotate(r)).offset(s,u),n=d}t.findNodesByExample({category:"WallGroup"}).iterator.each(function(o){if(o.data.key!==a.data.key){var i=o.data.startpoint,r=o.data.endpoint;t.isPointInWall(o,n)&&(n=n.projectOntoLineSegmentPoint(o.data.startpoint,o.data.endpoint),e.isIntersecting=!0),Math.sqrt(i.distanceSquaredPoint(n))<10?n=i:Math.sqrt(r.distanceSquaredPoint(n))<10&&(n=r)}});var p=e.getClosestIntersectingWall(n);if(null!==p&&null===e.wallIntersecting||null!==e.wallIntersecting&&void 0!==e.wallIntersecting&&null!==e.wallIntersecting.data&&e.performMiteringOnWall(e.wallIntersecting),null!=p){e.isIntersecting=!0,e.wallIntersecting=p,n=n.projectOntoLineSegmentPoint(p.data.startpoint,p.data.endpoint);var c=Math.sqrt(n.distanceSquaredPoint(p.data.startpoint)),g=Math.sqrt(n.distanceSquaredPoint(p.data.endpoint));c<25?n=p.data.startpoint:g<10&&(n=p.data.endpoint)}else e.isIntersecting=!1,null!==e.wallIntersecting&&void 0!==e.wallIntersecting&&null!==e.wallIntersecting.data&&null===t.getWallsIntersection(a,e.wallIntersecting)&&(e.wallIntersecting=null);e.calcAngleAndLengthFromHandle(n),e.reshape(n)}e.performMiteringOnWall(a),t.updateWallDimensions(),t.updateWallAngles()}},e.prototype.getClosestIntersectingWall=function(t){if(null===this.handle)return null;var e=this.handle.part.adornedPart,a="sPt"===this.handle.name?e.data.endpoint:e.data.startpoint,n={key:"wall",category:"WallGroup",caption:"Wall",type:"Wall",startpoint:a,smpt1:a,smpt2:a,endpoint:t,empt1:t,empt2:t,thickness:parseFloat(this.diagram.model.modelData.wallThickness),isGroup:!0,notes:""};this.diagram.model.addNodeData(n);var o=this.diagram.findPartForKey(n.key),i=this.diagram,r=this.diagram.findNodesByExample({category:"WallGroup"}),l=null,d=Number.MAX_VALUE;return r.iterator.each(function(t){if(t.data.key!==e.data.key&&t.data.key!==o.data.key){var n=i.getWallsIntersection(o,t),r=!1,s=parseFloat(Math.sqrt(t.data.startpoint.distanceSquaredPoint(a)).toFixed(2)),u=parseFloat(Math.sqrt(a.distanceSquaredPoint(t.data.endpoint)).toFixed(2)),p=parseFloat(Math.sqrt(t.data.startpoint.distanceSquaredPoint(t.data.endpoint)).toFixed(2));if(Math.abs(s+u-p)<=.1&&(r=!0),null!==n&&!r){var c=Math.sqrt(a.distanceSquaredPoint(n));c<d&&(d=c,l=t)}}}),i.remove(o),l},e.prototype.pointsApproximatelyEqual=function(t,e){var a=t.x,n=e.x,o=t.y,i=e.y,r=Math.abs(n-a);return Math.abs(i-o)<.05&&r<.05},e.prototype.performMitering=function(t,e){var a=this.diagram,n=t.data.startpoint,o=t.data.endpoint,r=e.data.startpoint,l=e.data.endpoint,d=t.data.thickness,s=e.data.thickness,u=Math.sqrt(n.distanceSquaredPoint(o)),p=Math.sqrt(r.distanceSquaredPoint(l)),c=a.getWallsIntersection(t,e);if(null!==c){var g=this.pointsApproximatelyEqual(n,c)?o:n,f=this.pointsApproximatelyEqual(r,c)?l:r,h=null,m=null;this.pointsApproximatelyEqual(n,c)||this.pointsApproximatelyEqual(o,c)?this.pointsApproximatelyEqual(r,c)||this.pointsApproximatelyEqual(l,c)||(h=e,m=t):(h=t,m=e),null!==h&&null!==m&&t.data.key===m.data.key&&(f=this.isClockwise(g,c,h.data.startpoint)?h.data.startpoint:h.data.endpoint),null!==h&&null!==m&&e.data.key===m.data.key&&(g=this.isClockwise(c,f,h.data.startpoint)?h.data.startpoint:h.data.endpoint);var y=c.directionPoint(g),v=c.directionPoint(f),P=Math.abs(y-v+360)%360;if(!(Math.abs(P-180)<.1)){P*=Math.PI/180;var w=Math.abs(s/(2*Math.sin(P))),k=Math.abs(d/(2*Math.sin(P))),x=Math.sqrt(g.distanceSquaredPoint(c)),b=Math.sqrt(c.distanceSquaredPoint(f)),S=(g.x-c.x)/x*w,A=(g.y-c.y)/x*w,M=(f.x-c.x)/b*k,W=(f.y-c.y)/b*k,T=new i.Point(c.x+S+M,c.y+A+W),N=new i.Point(c.x-S-M,c.y-A-W),O=Math.min(u,p);if(!(Math.sqrt(T.distanceSquaredPoint(c))>O)){var j=this.isClockwise(c,g,T)?N:T;if(!isNaN(j.x)&&!isNaN(j.y)){if(this.pointsApproximatelyEqual(n,c)||this.pointsApproximatelyEqual(o,c)){var D=null;this.pointsApproximatelyEqual(g,n)?D=this.isClockwise(g,c,j)?"empt1":"empt2":this.pointsApproximatelyEqual(g,o)&&(D=this.isClockwise(g,c,j)?"smpt2":"smpt1"),null!==D&&(a.model.setDataProperty(t.data,D,j),a.updateWall(t))}if(this.pointsApproximatelyEqual(r,c)||this.pointsApproximatelyEqual(l,c)){D=null;this.pointsApproximatelyEqual(f,r)?D=this.isClockwise(f,c,j)?"empt1":"empt2":this.pointsApproximatelyEqual(f,l)&&(D=this.isClockwise(f,c,j)?"smpt2":"smpt1"),null!==D&&(a.model.setDataProperty(e.data,D,j),a.updateWall(e))}}}}}},e.prototype.getAllWallIntersectionPoints=function(){var t=this,e=t.diagram,a=e.findNodesByExample({category:"WallGroup"}),n=new i.Set;return a.iterator.each(function(a){e.findNodesByExample({category:"WallGroup"}).iterator.each(function(o){if(o.data.key!==a.data.key){var r=e.getWallsIntersection(a,o),l=!0;null!==r&&(n.iterator.each(function(e){var a=i.Point.parse(e);t.pointsApproximatelyEqual(a,r)&&(l=!1)}),l&&n.add(i.Point.stringify(r)))}})}),n},e.prototype.getAllWallsAtIntersection=function(t,e){null==e&&(e=!0);var a=this,n=a.diagram,o=new i.List;return null===t?o:(n.findObjectsNear(t,1,function(t){return null!==t.part?t.part:null},function(n){if(!(n instanceof i.Group&&"WallGroup"===n.category)||!e&&n.data.isDivider||o.contains(n))return!1;var r=n.data.startpoint,l=n.data.endpoint;return a.isPointOnSegment(r,l,t)},!0,o),o)},e.prototype.doWallsShareAnEndpoint=function(t,e){var a=t.data.startpoint,n=t.data.endpoint,o=e.data.startpoint,i=e.data.endpoint;return!!(this.pointsApproximatelyEqual(a,o)||this.pointsApproximatelyEqual(a,i)||this.pointsApproximatelyEqual(n,o)||this.pointsApproximatelyEqual(n,i))},e.prototype.maybeSplitWall=function(){var t=this;if(null!==t.handle){var e=t.handle.part.adornedPart,a="sPt"===t.handle.name?e.data.startpoint:e.data.endpoint,n=t.joinedWalls,o=t.getAllWallsAtIntersection(a);if(o.remove(e),n.iterator.each(function(t){o.remove(t)}),1===o.count)null!==(i=o.first())&&(t.doWallsShareAnEndpoint(e,i)||t.maybePerformWallSplit(i,a));if(t.isBuilding){var i,r=a===e.data.startpoint?e.data.endpoint:e.data.startpoint,l=t.getAllWallsAtIntersection(r);if(l.remove(e),n.iterator.each(function(t){o.remove(t)}),1===l.count)null!==(i=l.first())&&(t.doWallsShareAnEndpoint(e,i)||t.maybePerformWallSplit(i,r))}null!==n&&n.iterator.each(function(e){t.splitNewWall(e)})}},e.prototype.splitNewWall=function(t){var e=this,a=this.diagram,n=a.findNodesByExample({category:"WallGroup"}),o=new i.Set;n.iterator.each(function(e){var n=a.getWallsIntersection(t,e);null!==n&&o.add(n)}),o.iterator.each(function(t){e.getAllWallsAtIntersection(t).iterator.each(function(a){var n=a.data.startpoint,o=a.data.endpoint;e.pointsApproximatelyEqual(n,t)||e.pointsApproximatelyEqual(o,t)||e.maybePerformWallSplit(a,t)})})},e.prototype.maybePerformWallSplit=function(t,e){var a=this,n=a.diagram,o=t.data.startpoint,r=t.data.endpoint,l=t.data.isDivider?"Divider":"Wall",d={key:"wall",category:"WallGroup",caption:l,type:l,color:t.data.color,startpoint:o,endpoint:e,smpt1:o,smpt2:o,empt1:e,empt2:e,thickness:t.data.thickness,isGroup:!0,notes:"",isDivider:t.data.isDivider},s={key:"wall",category:"WallGroup",caption:l,type:l,color:t.data.color,startpoint:e,endpoint:r,smpt1:e,smpt2:e,empt1:r,empt2:r,thickness:t.data.thickness,isGroup:!0,notes:"",isDivider:t.data.isDivider},u=Math.sqrt(d.startpoint.distanceSquaredPoint(d.endpoint)),p=Math.sqrt(s.startpoint.distanceSquaredPoint(s.endpoint)),c=n.findNodesByExample({category:"WallGroup"}),g=!1;if(c.iterator.each(function(t){var n=t.data.startpoint,i=t.data.endpoint;(a.pointsApproximatelyEqual(o,n)&&a.pointsApproximatelyEqual(e,i)||a.pointsApproximatelyEqual(o,i)&&a.pointsApproximatelyEqual(e,n))&&(g=!0),(a.pointsApproximatelyEqual(e,n)&&a.pointsApproximatelyEqual(r,i)||a.pointsApproximatelyEqual(e,i)&&a.pointsApproximatelyEqual(r,n))&&(g=!0)}),u>1&&p>1&&!g){n.model.addNodeData(d),n.model.addNodeData(s);var f=n.findNodeForData(d),h=n.findNodeForData(s);if(a.premiterWall(f),a.premiterWall(h),a.performMiteringAtPoint(e,!1),null!==a.handle){var m=n.findNodesByExample({category:"RoomNode"}),y=a.handle.part.adornedPart;m.iterator.each(function(o){for(var r=o.data.boundaryWalls,l=function(l){var d=r[l];if(d[0]===t.data.key){var s=!1,u=a.pointsApproximatelyEqual(y.data.startpoint,e)?y.data.endpoint:y.data.startpoint;if(a.getAllWallsAtIntersection(u).iterator.each(function(t){for(var e=0;e<r.length;e++){var a=r[e][0];t.data.key===a&&t.data.key!==y.data.key&&(s=!0)}}),s){var p=!1,c=a.pointsApproximatelyEqual(f.data.startpoint,e)?f.data.endpoint:f.data.startpoint,g=a.getAllWallsAtIntersection(c);g.remove(t),g.iterator.each(function(t){for(var e=function(e){var o=r[e][0];if(t.data.key===o&&f.data.key!==t.data.key){var i=n.findNodeForKey(o),l=a.pointsApproximatelyEqual(i.data.startpoint,c)?i.data.endpoint:i.data.startpoint;a.getAllWallsAtIntersection(l).iterator.each(function(t){for(var e=0;e<r.length;e++){var a=r[e][0];a===t.data.key&&a!==i.data.key&&(p=!0)}})}},o=0;o<r.length;o++)e(o)});var m=p?f:h,v=a.getUpdatedEntry(d,m);n.startTransaction(),(w=r.slice())[l]=v,n.model.setDataProperty(o.data,"boundaryWalls",w),n.commitTransaction()}else{var P=new i.List;P.add(y),P.add(f),P.add(h),P=n.sortWallsClockwiseWithSetStartWall(P,y);var w,k=a.getUpdatedEntry(d,P.toArray()[1]),x=a.getUpdatedEntry(d,P.toArray()[2]);n.startTransaction(),(w=r.slice()).splice(l,1,x),w.splice(l+1,0,k),n.model.setDataProperty(o.data,"boundaryWalls",w),n.commitTransaction()}}},d=0;d<r.length;d++)l(d)})}var v=n.findNodesByExample({group:t.data.key}),P=new i.Set;P.add(f),P.add(h),a.maintainWallParts(v,P),n.remove(t),a.premiterWall(f),a.premiterWall(h);var w=a.pointsApproximatelyEqual(f.data.startpoint,e)?f.data.endpoint:f.data.startpoint,k=a.pointsApproximatelyEqual(h.data.startpoint,e)?h.data.endpoint:h.data.startpoint;a.performMiteringAtPoint(e,!1),a.performMiteringAtPoint(w,!1),a.performMiteringAtPoint(k,!1)}},e.prototype.splitAllWalls=function(){var t=this;t.getAllWallIntersectionPoints().iterator.each(function(e){var a=i.Point.parse(e);t.getAllWallsAtIntersection(a).iterator.each(function(e){var n=e.data.startpoint,o=e.data.endpoint;t.pointsApproximatelyEqual(n,a)||t.pointsApproximatelyEqual(o,a)||t.maybePerformWallSplit(e,a)})})},e.prototype.areWallsParallel=function(t,e){this.diagram;var a=t.data.startpoint,n=t.data.endpoint,o=e.data.startpoint,i=e.data.endpoint,r=!1,l=+a.directionPoint(n),d=+o.directionPoint(i);return(Math.abs(l-d)<1||Math.abs(l-d)>179&&Math.abs(l-d)<181)&&(r=!0),r},e.prototype.isWallColinear=function(t,e){var a=this;this.diagram;if(t.data.isDivider!==e.data.isDivider)return!1;var n=t.data.startpoint,o=t.data.endpoint,i=e.data.startpoint,r=e.data.endpoint,l=!1;if(a.areWallsParallel(t,e)){var d=null;if(a.pointsApproximatelyEqual(n,i)||a.pointsApproximatelyEqual(n,r)?d=n:(a.pointsApproximatelyEqual(o,i)||a.pointsApproximatelyEqual(o,r))&&(d=o),null!==d){var s=a.getAllWallsAtIntersection(d),u=!1;s.iterator.each(function(e){a.areWallsParallel(e,t)||(u=!0)}),u||(l=!0)}}return l},e.prototype.findAllColinearWalls=function(t,e){null==e&&(e=new i.Set),e.add(t);var a=this;return a.diagram.findNodesByExample({category:"WallGroup"}).iterator.each(function(n){a.isWallColinear(t,n)&&void 0!==e&&!e.contains(n)&&(e.add(n),a.findAllColinearWalls(n,e))}),e},e.prototype.joinColinearWalls=function(){if(null!==this.handle){var t=this.handle.part.adornedPart,e=this.findAllColinearWalls(t),a=this.performColinearWallJoining(e,t);null!==a&&this.joinedWalls.add(a);var n=this.getAllWallsAtIntersection(this.returnPoint);if(2===n.count){var o=n.toArray(),r=o[0],l=o[1];if(this.isWallColinear(r,l)){var d=new i.Set;d.add(r),d.add(l);var s=this.performColinearWallJoining(d,r);null!==s&&this.joinedWalls.add(s)}}}},e.prototype.performColinearWallJoining=function(t,e){var a=this,n=a.diagram,o=new i.Set,r=t.first();if(null===r)return null;void 0===e&&(e=r);r.data.category;if(t.iterator.each(function(t){t.data.category}),t.count>1){var l=null,d=null,s=0,u=t.copy(),p=new i.Set;t.iterator.each(function(t){var e=n.findNodesByExample({group:t.data.key});p.addAll(e),u.iterator.each(function(e){for(var a=[t.data.startpoint,t.data.endpoint],n=[e.data.startpoint,e.data.endpoint],o=0;o<a.length;o++)for(var i=a[o],r=0;r<n.length;r++){var u=n[r],p=Math.sqrt(i.distanceSquaredPoint(u));p>s&&(s=p,l=i,d=u)}}),o.add(t)});var c={key:"wall",category:"WallGroup",caption:"Wall",type:"Wall",color:e.data.color,startpoint:l,endpoint:d,smpt1:l,smpt2:l,empt1:d,empt2:d,thickness:e.data.thickness,isGroup:!0,notes:""};n.model.addNodeData(c);var g=n.findNodeForData(c);n.findNodesByExample({category:"RoomNode"}).iterator.each(function(e){for(var o=e.data.boundaryWalls,i=0;i<o.length;i++){var r=o[i],l=r[0],d=n.findNodeForKey(l);if(t.contains(d)){a.performMiteringOnWall(g);var s=a.getUpdatedEntry(r,g);n.startTransaction();var u=o.slice();u[i]=s,n.model.setDataProperty(e.data,"boundaryWalls",u),n.commitTransaction()}}});var f=new i.Set;return f.add(g),a.performMiteringOnWall(g),a.maintainWallParts(p,f),o.iterator.each(function(t){n.remove(t)}),a.performMiteringOnWall(g),g}return null},e.prototype.maintainWallParts=function(t,e){var a=this.diagram,n=[];t.iterator.each(function(t){var o=t.location;e.iterator.each(function(e){if(a.isPointInWall(e,o)){var i=a.findClosestLocOnWall(e,t);null!==i?(a.model.setDataProperty(t.data,"group",e.data.key),t.location=i.projectOntoLineSegmentPoint(e.data.startpoint,e.data.endpoint),"WindowNode"===t.category&&a.model.setDataProperty(t.data,"height",e.data.thickness),"DoorNode"===t.category&&a.model.setDataProperty(t.data,"doorOpeningHeight",e.data.thickness)):n.push(t)}})});for(var o=0;o<n.length;o++)a.remove(n[o])},e.prototype.getUpdatedEntry=function(t,e){var a=this.diagram,n=t[0],o=a.findNodeForKey(n),r=t[1],l=[e.data.key,null],d=o.data["smpt"+r],s=o.data["empt"+r];function u(t,e,a){var n=(e.y-t.y)/(e.x-t.x),o=t.y+(a-t.x)*n;return new i.Point(a,o)}var p=u(d,s,e.data.smpt1.x),c=u(d,s,e.data.smpt2.x),g=e.data.smpt1.distanceSquaredPoint(p),f=e.data.smpt2.distanceSquaredPoint(c);return l[1]=g<f?1:2,l},e.prototype.joinAllColinearWalls=function(){var t=this,e=t.diagram.findNodesByExample({category:"WallGroup"}),a=new i.Set;e.iterator.each(function(e){if(!a.contains(e)){a.add(e);var n=new i.Set;n.add(e),t.findAllColinearWalls(e,n),a.addAll(n),t.performColinearWallJoining(n,e)}}),t.premiterAllWalls()},e.prototype.translateAndRotatePoint=function(t,e,a){var n=t.copy(),o=t.copy();return o.offset(0,a),o.offset(-n.x,-n.y).rotate(e).offset(n.x,n.y),o},e.prototype.premiterWall=function(t,e){var a=this.diagram,n=t.data.startpoint.directionPoint(t.data.endpoint),o=t.data.thickness,i=t.data.startpoint,r=t.data.endpoint;switch(e){case"smpt1":var l=this.translateAndRotatePoint(i,n,o/2);a.model.setDataProperty(t.data,"smpt1",l);break;case"smpt2":var d=this.translateAndRotatePoint(i,n+180,o/2);a.model.setDataProperty(t.data,"smpt2",d);break;case"empt1":var s=this.translateAndRotatePoint(r,n,o/2);a.model.setDataProperty(t.data,"empt1",s);break;case"empt2":var u=this.translateAndRotatePoint(r,n+180,o/2);a.model.setDataProperty(t.data,"empt2",u);break;default:s=this.translateAndRotatePoint(r,n,o/2);a.model.setDataProperty(t.data,"empt1",s);u=this.translateAndRotatePoint(r,n+180,o/2);a.model.setDataProperty(t.data,"empt2",u);l=this.translateAndRotatePoint(i,n,o/2);a.model.setDataProperty(t.data,"smpt1",l);d=this.translateAndRotatePoint(i,n+180,o/2);a.model.setDataProperty(t.data,"smpt2",d)}a.updateWall(t)},e.prototype.premiterAllWalls=function(){var t=this;t.diagram.findNodesByExample({category:"WallGroup"}).iterator.each(function(e){t.premiterWall(e)})},e.prototype.performMiteringOnWall=function(t){var e=t.data.startpoint,a=t.data.endpoint;this.premiterWall(t),this.performMiteringAtPoint(e,!0),this.performMiteringAtPoint(a,!0)},e.prototype.performMiteringAtPoint=function(t,e){null==e&&(e=!0);var a=this,n=a.diagram,o=a.getAllWallsAtIntersection(t,!1);e&&o.iterator.each(function(e){if(a.pointsApproximatelyEqual(e.data.startpoint,t)||a.pointsApproximatelyEqual(e.data.endpoint,t)){var n=a.pointsApproximatelyEqual(e.data.startpoint,t)?"s":"e";a.premiterWall(e,n+"mpt1"),a.premiterWall(e,n+"mpt2")}}),o.sort(function(e,o){var i=n.getWallsIntersection(e,o);if(null===i)return 0;var r=e.data.startpoint,l=e.data.endpoint,d=o.data.startpoint,s=o.data.endpoint,u=a.pointsApproximatelyEqual(t,r)?l:r,p=a.pointsApproximatelyEqual(t,d)?s:d,c=i.directionPoint(u),g=i.directionPoint(p);return c>g?1:c<g?-1:0}),o.reverse();for(var i=o.toArray(),r=0;r<i.length;r++){var l=i[r],d=null;d=r+1===i.length?i[0]:i[r+1],a.performMitering(l,d)}},e.prototype.performAllMitering=function(){var t=this,e=t.diagram;t.premiterAllWalls(),t.getAllWallIntersectionPoints().iterator.each(function(a){var n=i.Point.parse(a),o=t.getAllWallsAtIntersection(n);o.sort(function(a,o){var i=e.getWallsIntersection(a,o);if(null===i)return 0;var r=a.data.startpoint,l=a.data.endpoint,d=o.data.startpoint,s=o.data.endpoint,u=t.pointsApproximatelyEqual(n,r)?l:r,p=t.pointsApproximatelyEqual(n,d)?s:d,c=i.directionPoint(u),g=i.directionPoint(p);return c>g?1:c<g?-1:0}),o.reverse();for(var r=o.toArray(),l=0;l<r.length;l++){var d=r[l],s=null;s=l+1===r.length?r[0]:r[l+1],t.performMitering(d,s)}})},e.prototype.isClockwise=function(t,e,a){return(e.x-t.x)*(a.y-t.y)-(e.y-t.y)*(a.x-t.x)>0},e.prototype.isPointOnSegment=function(t,e,a){var n=Math.sqrt(t.distanceSquaredPoint(a)),o=Math.sqrt(e.distanceSquaredPoint(a)),i=Math.sqrt(t.distanceSquaredPoint(e));return Math.abs(i-(n+o))<=.1},e.prototype.doMouseUp=function(){var t=this.diagram;if(null!==this.handle){this.doMouseMove();var e=this.handle.part.adornedPart;this.joinColinearWalls(),this.maybeSplitWall(),this.joinedWalls.clear();var a=new i.Set;a.add(e),t.updateAllRoomBoundaries(a),this.stopTool()}},e.prototype.doDeactivate=function(){var t=this.diagram,e=t;if(null!==this.handle){var a=this.handle.part.adornedPart,n=a.data.startpoint,o=a.data.endpoint;if(Math.sqrt(n.distanceSquared(o.x,o.y))<1){t.remove(a),a.memberParts.iterator.each(function(e){t.remove(e)});var i=[];e.pointNodes.iterator.each(function(t){-1!==t.data.key.indexOf(a.data.key)&&i.push(t)}),2===i.length&&(t.remove(i[0]),t.remove(i[1]))}"Esc"!==t.lastInput.key||this.isBuilding||(t.skipsUndoManager=!0,t.startTransaction("reset to old data"),"sPt"===this.handle.name?a.data.startpoint=this.returnPoint:a.data.endpoint=this.returnPoint,this.performAllMitering(),e.updateWall(a),this.returnData&&this.returnData.iterator.each(function(e){var n=e.key,o=e.value,i=t.findPartForKey(n);i.location=o,i.rotateObject.angle=a.rotateObject.angle}),t.commitTransaction("reset to old data"),t.skipsUndoManager=!1);var r=this.diagram.findNodesByExample({category:"GLPointNode"});t.removeParts(r,!0),e.updateWallDimensions(),t.commitTransaction(this.name),this.isActive=!1}},e.prototype.makeAdornment=function(t){var e=new i.Adornment;e.type=i.Panel.Spot,e.locationObjectName="BODY",e.locationSpot=i.Spot.Center;var a=new i.Shape;return a.name="BODY",a.fill=null,a.stroke=null,a.strokeWidth=0,e.add(a),(a=this.makeHandle()).name="sPt",e.add(a),(a=this.makeHandle()).name="ePt",e.add(a),e.category=this.name,e.adornedObject=t,e},e.prototype.makeHandle=function(){return this.handleArchetype.copy()},e.prototype.calcAngleAndLengthFromHandle=function(t){var e=this.handle;if(null!==e&&null!==this.adornedShape){var a=null,n=this.adornedShape.part;if(null!==n){for(var o,r=n.adornments.iterator;r.next();){var l=r.value;l.category===this.name&&(o=l)}if(void 0!==o){for(var d=o.elements;d.next();){var s=d.value;void 0!==s.name&&s.name!==e.name&&(a=s)}if(null!==a){var u=a.getDocumentPoint(i.Spot.Center),p=t.y-u.y,c=t.x-u.x,g=Math.atan2(p,c)*(180/Math.PI);g<0&&(g+=360),this.angle=g;var f=Math.sqrt(t.distanceSquared(u.x,u.y));this.length=f}}}}},e.prototype.snapPointToGrid=function(t){var e=this.diagram,a=e.toolManager.draggingTool.isGridSnapEnabled?e.model.modelData.gridSize:1,n=a*Math.round(t.x/a),o=a*Math.round(t.y/a);return new i.Point(n,o)},e.prototype.reshape=function(t){var e=this.diagram,a=this.adornedShape;if(null!==a&&null!==this.handle){var n=a.part;if(null!==n){if(this.diagram.lastInput.shift&&!this.isIntersecting){var o=void 0;o="sPt"===this.handle.name?n.data.endpoint:n.data.startpoint;var r=e.model.modelData.gridSize,l=e.model.modelData.gridSize;this.diagram.toolManager.draggingTool.isGridSnapEnabled||(l=1);var d=this.angle,s=this.length;if(d>67.5&&d<112.5){var u=o.y+s;u=l*Math.round(u/l),t=new i.Point(o.x,u)}if(d>112.5&&d<202.5){var p=o.x-s;p=l*Math.round(p/l),t=new i.Point(p,o.y)}if(d>247.5&&d<292.5){u=o.y-s;u=l*Math.round(u/l),t=new i.Point(o.x,u)}if(d>337.5||d<22.5){p=o.x+s;p=l*Math.round(p/l),t=new i.Point(p,o.y)}if(d>22.5&&d<67.5){p=Math.sin(.785)*s;p=l*Math.round(p/l)+o.x;u=Math.cos(.785)*s;u=l*Math.round(u/l)+o.y,t=new i.Point(p,u)}if(d>112.5&&d<157.5){p=Math.sin(.785)*s;p=o.x-l*Math.round(p/l);u=Math.cos(.785)*s;u=l*Math.round(u/l)+o.y,t=new i.Point(p,u)}if(d>202.5&&d<247.5){p=Math.sin(.785)*s;p=o.x-l*Math.round(p/l);u=Math.cos(.785)*s;u=o.y-l*Math.round(u/l),t=new i.Point(p,u)}if(d>292.5&&d<337.5){p=Math.sin(.785)*s;p=o.x+l*Math.round(p/l);u=Math.cos(.785)*s;u=o.y-l*Math.round(u/l),t=new i.Point(p,u)}l=r}t=!this.diagram.toolManager.draggingTool.isGridSnapEnabled||this.isIntersecting||this.diagram.lastInput.shift?new i.Point(t.x,t.y):this.snapPointToGrid(t);var c=this.handle.name;if(void 0!==c){var g="sPt"===c?n.data.endpoint:n.data.startpoint,f="sPt"===c?n.data.startpoint:n.data.endpoint;this.reshapeWall(n,g,f,t,e),this.updateAdornments(n),this.showMatches(),e.updateWallDimensions()}}}},e.prototype.showMatches=function(){var t=this,e=t.diagram;if(e.model.modelData.preferences.showWallGuidelines&&null!==t.adornedShape&&null!==t.handle){var a,n=t.adornedShape.part;a="sPt"===t.handle.name?n.data.startpoint:n.data.endpoint;var o=t.adornedShape.part,i=e.findNodesByExample({category:"GLPointNode"});e.removeParts(i,!0),this.diagram.findNodesByExample({category:"WallGroup"}).iterator.each(function(e){if(null!==o&&e.data.key!==o.data.key){e.findObject("SHAPE");var n=e.data.startpoint,i=e.data.endpoint;t.checkPtLinedUp(n,a.x,n.x,a),t.checkPtLinedUp(n,a.y,n.y,a),t.checkPtLinedUp(i,a.x,i.x,a),t.checkPtLinedUp(i,a.y,i.y,a)}})}},e.prototype.checkPtLinedUp=function(t,e,a,n){function o(){var t=i.GraphObject.make;return t(i.Node,"Spot",{locationSpot:i.Spot.TopLeft,locationObjectName:"SHAPE",desiredSize:new i.Size(1,1)},new i.Binding("location","loc",i.Point.parse).makeTwoWay(i.Point.stringify),t(i.Shape,{stroke:null,strokeWidth:1,name:"SHAPE",fill:"black"}))}var r,l=this.diagram;if(Math.abs(e-a)<2){var d={category:"GLPointNode",loc:i.Point.stringify(t),key:"glpt"},s={key:"movingPt",category:"GLPointNode",loc:i.Point.stringify(n)},u={key:"guideline",category:"guideLine",from:"movingPt",to:d.key,stroke:"blue"},p=o(),c=o(),g=(r=i.GraphObject.make)(i.Link,r(i.Shape,{stroke:"black",strokeWidth:2,name:"SHAPE"},new i.Binding("strokeWidth","width"),new i.Binding("stroke","stroke")));l.add(p),l.add(c),l.add(g),p.data=d,c.data=s,g.data=u,g.fromNode=p,g.toNode=c}},e.prototype.reshapeWall=function(t,e,a,n,o){var r=t.memberParts,l=[],d=t.data.startpoint.directionPoint(t.data.endpoint);r.iterator.each(function(t){l.push(t)});for(var s=new i.Map,u=null,p=Number.MAX_VALUE,c=0;c<l.length;c++){var g=l[c],f=Math.sqrt(g.location.distanceSquaredPoint(e));s.add(g.data.key,f);var h=this.getWallPartEndpoints(g),m=Math.min(Math.sqrt(h[0].distanceSquaredPoint(a)),Math.sqrt(h[1].distanceSquaredPoint(a)));m<p&&(p=m,u=g)}if(null!==u){var y=u.location,v=u.data.length,P=d,w=new i.Point(y.x+v/2,y.y),k=new i.Point(y.x-v/2,y.y);w.offset(-y.x,-y.y).rotate(P).offset(y.x,y.y),k.offset(-y.x,-y.y).rotate(P).offset(y.x,y.y);var x=Math.sqrt(e.distanceSquaredPoint(w)),b=Math.sqrt(e.distanceSquaredPoint(k)),S=void 0,A=void 0;x>b?(S=x,A=w):(S=b,A=k),Math.sqrt(e.distanceSquaredPoint(n))<S&&(n=A)}a===t.data.endpoint?o.model.setDataProperty(t.data,"endpoint",n):o.model.setDataProperty(t.data,"startpoint",n),o.updateWall(t),s.iterator.each(function(n){var r=o.findPartForKey(n.key),l=n.value,d=Math.sqrt(e.distanceSquaredPoint(a)),s=new i.Point(e.x+l/d*(a.x-e.x),e.y+l/d*(a.y-e.y));r.location=s;var u=t.data.startpoint.directionPoint(t.data.endpoint),p=t.data.endpoint.directionPoint(t.data.startpoint),c=Math.abs(r.angle-u)<Math.abs(r.angle-p)?u:p;r.angle=c})},e.prototype.getWallPartEndpoints=function(t){var e=t.location,a=t.data.length,n=0;n=null!==t.containingGroup?t.containingGroup.rotateObject.angle:180;var o=new i.Point(e.x+a/2,e.y),r=new i.Point(e.x-a/2,e.y);o.offset(-e.x,-e.y).rotate(n).offset(e.x,e.y),r.offset(-e.x,-e.y).rotate(n).offset(e.x,e.y);var l=[];return l.push(o),l.push(r),l},e}(i.Tool);e.WallReshapingTool=r},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),t.exports={Floorplan:a(4).Floorplan,FloorplanPalette:a(6).FloorplanPalette,WallBuildingTool:a(1).WallBuildingTool,WallReshapingTool:a(2).WallReshapingTool}},function(t,e,a){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)e.hasOwnProperty(a)&&(t[a]=e[a])})(t,e)},function(t,e){function a(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)});Object.defineProperty(e,"__esModule",{value:!0});var i=a(0),r=a(5),l=a(1),d=a(2),s=function(t){function e(e){var a=t.call(this,e)||this;a._palettes=[],a._pointNodes=new i.Set,a._dimensionLinks=new i.Set,a._angleNodes=new i.Set;var n=i.GraphObject.make;a.allowLink=!1,a.undoManager.isEnabled=!0,a.layout.isInitial=!1,a.layout.isOngoing=!1,a.model=n(i.GraphLinksModel,{modelData:{units:"meters",unitsAbbreviation:"m",unitsConversionFactor:.02,gridSize:10,wallThickness:10,preferences:{showWallGuidelines:!0,showWallLengths:!0,showWallAngles:!0,showOnlySmallWallAngles:!0,showGrid:!0,gridSnap:!0}}}),a.grid=n(i.Panel,"Grid",{gridCellSize:new i.Size(a.model.modelData.gridSize,a.model.modelData.gridSize),visible:!0},n(i.Shape,"LineH",{stroke:"lightgray"}),n(i.Shape,"LineV",{stroke:"lightgray"})),a.contextMenu=g(),a.commandHandler.canGroupSelection=function(){return!0},a.commandHandler.canUngroupSelection=function(){return!0},a.commandHandler.archetypeGroupData={isGroup:!0},a.addDiagramListener("SelectionCopied",function(t){var e=t.diagram;e.selection.iterator.each(function(t){if("WallGroup"===t.category){var a=t;e.updateWall(a)}})}),a.addDiagramListener("ExternalObjectsDropped",function(t){var e=[],a=t.diagram;for(var n in a.selection.iterator.each(function(t){if("FloorNode"===t.category){var n=t,o=a.lastInput.documentPoint;a.maybeAddRoomNode(o,n.data.floorImage),e.push(n)}}),e)t.diagram.remove(e[n])}),a.addDiagramListener("ClipboardPasted",function(t){var e=t.diagram;t.diagram.selection.iterator.each(function(t){if("WallGroup"===t.category){var a=t;e.updateWall(a)}})}),a.addDiagramListener("ChangedSelection",function(t){var e=t.diagram;e.skipsUndoManager=!0,e.startTransaction("remove dimension links and angle nodes"),e.pointNodes.iterator.each(function(e){t.diagram.remove(e)}),e.dimensionLinks.iterator.each(function(e){t.diagram.remove(e)});var a=[];e.links.iterator.each(function(t){"DimensionLink"===t.data.category&&a.push(t)});for(var n=0;n<a.length;n++)t.diagram.remove(a[n]);e.pointNodes.clear(),e.dimensionLinks.clear(),e.angleNodes.iterator.each(function(e){t.diagram.remove(e)}),e.angleNodes.clear(),e.commitTransaction("remove dimension links and angle nodes"),e.skipsUndoManager=!1,e.updateWallDimensions(),e.updateWallAngles()}),a.addDiagramListener("SelectionDeleted",function(t){var e=t.diagram.toolManager.mouseDownTools.elt(3);e.joinAllColinearWalls(),e.splitAllWalls(),e.performAllMitering();var a=t.subject,n=new i.Set;a.iterator.each(function(t){if(t instanceof i.Group&&"WallGroup"===t.data.category){var e=t;n.add(e)}}),t.diagram.updateAllRoomBoundaries(n)}),a.nodeTemplateMap.add("",function(){var t=i.GraphObject.make;return t(i.Node,"Spot",{resizable:!0,rotatable:!0,toolTip:m(),resizeAdornmentTemplate:y(),rotateAdornmentTemplate:v(),contextMenu:g(),locationObjectName:"SHAPE",resizeObjectName:"SHAPE",rotateObjectName:"SHAPE",minSize:new i.Size(5,5),locationSpot:i.Spot.Center,selectionAdornmentTemplate:A(null)},new i.Binding("location","loc",i.Point.parse).makeTwoWay(i.Point.stringify),new i.Binding("layerName","isSelected",function(t){return t?"Foreground":""}).ofObject(),t(i.Shape,"Ellipse",{name:"SHAPE",stroke:"#000000",fill:"white"},new i.Binding("geometryString","geo"),new i.Binding("figure","shape").makeTwoWay(),new i.Binding("width").makeTwoWay(),new i.Binding("height").makeTwoWay(),new i.Binding("angle").makeTwoWay(),new i.Binding("fill","texture",function(t,e){return w(e,t)}),new i.Binding("fill","usesTexture",function(t,e){var a=e.part;if(null===a)return null;var n=a.data.texture;return w(e,n)})))}()),a.nodeTemplateMap.add("MultiPurposeNode",function(){var t=i.GraphObject.make;return t(i.Node,"Spot",{contextMenu:g(),toolTip:m(),locationSpot:i.Spot.Center,resizeAdornmentTemplate:y(),rotateAdornmentTemplate:v(),selectionAdornmentTemplate:A(null),locationObjectName:"SHAPE",resizable:!0,rotatable:!0,resizeObjectName:"SHAPE",rotateObjectName:"SHAPE",minSize:new i.Size(5,5)},new i.Binding("location","loc",i.Point.parse).makeTwoWay(i.Point.stringify),new i.Binding("layerName","isSelected",function(t){return t?"Foreground":""}).ofObject(),t(i.Shape,{strokeWidth:1,name:"SHAPE",fill:"rgba(128, 128, 128, 0.5)"},new i.Binding("angle").makeTwoWay(),new i.Binding("width").makeTwoWay(),new i.Binding("height").makeTwoWay(),new i.Binding("fill","texture",function(t,e){return w(e,t)}),new i.Binding("fill","usesTexture",function(t,e){var a=e.part;if(null===a)return null;var n=a.data.texture;return w(e,n)}),new i.Binding("stroke","isSelected",function(t,e){return t?i.Brush.lightenBy(e.stroke,.5):function(t){0===t.indexOf("#")&&(t=t.slice(1));3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);if(6!==t.length)throw new Error("Invalid HEX color.");var e=(255-parseInt(t.slice(0,2),16)).toString(16),a=(255-parseInt(t.slice(2,4),16)).toString(16),n=(255-parseInt(t.slice(4,6),16)).toString(16);return"#"+P(e)+P(a)+P(n)}(e.part.data.color)}).ofObject()),t(i.Panel,"Auto",new i.Binding("visible","showLabel"),t(i.Shape,"RoundedRectangle",{fill:"beige",opacity:.5,stroke:null}),t(i.TextBlock,{margin:5,wrap:i.TextBlock.WrapFit,textAlign:"center",editable:!0,isMultiline:!1,stroke:"black",font:"10pt sans-serif"},new i.Binding("text").makeTwoWay(),new i.Binding("angle","angle").makeTwoWay(),new i.Binding("font","height",function(t){return t>25?"10pt sans-serif":t<25&&t>15?"8pt sans-serif":"6pt sans-serif"}))))}()),a.nodeTemplateMap.add("WindowNode",function(){var t=i.GraphObject.make;return t(i.Node,"Spot",{contextMenu:g(),selectionObjectName:"SHAPE",selectionAdorned:!1,locationSpot:i.Spot.Center,toolTip:m(),minSize:new i.Size(5,5),resizable:!0,resizeAdornmentTemplate:T(),resizeObjectName:"SHAPE",rotatable:!1,dragComputation:W,layerName:"Foreground"},new i.Binding("location","loc",i.Point.parse).makeTwoWay(i.Point.stringify),new i.Binding("angle").makeTwoWay(),t(i.Shape,{name:"SHAPE",fill:"white",strokeWidth:0},new i.Binding("width","length").makeTwoWay(),new i.Binding("height").makeTwoWay(),new i.Binding("stroke","isSelected",function(t,e){return t?"dodgerblue":"black"}).ofObject(),new i.Binding("fill","isSelected",function(t,e){return t?"lightgray":"white"}).ofObject()),t(i.Shape,{name:"LINESHAPE",fill:"darkgray",strokeWidth:0,height:10},new i.Binding("width","length",function(t,e){return t-10}),new i.Binding("height","height",function(t,e){return t/5}),new i.Binding("stroke","isSelected",function(t,e){return t?"dodgerblue":"black"}).ofObject()))}()),a.nodeTemplateMap.add("PaletteWallNode",function(){var t=i.GraphObject.make;return t(i.Node,"Spot",{selectionAdorned:!1},t(i.Shape,{name:"SHAPE",fill:"black",strokeWidth:0,height:10,figure:"Rectangle"},new i.Binding("width","length").makeTwoWay(),new i.Binding("height").makeTwoWay(),new i.Binding("fill","isSelected",function(t,e){return t?"dodgerblue":"black"}).ofObject(),new i.Binding("stroke","isSelected",function(t,e){return t?"dodgerblue":"black"}).ofObject()))}()),a.nodeTemplateMap.add("DoorNode",function(){var t=i.GraphObject.make;return t(i.Node,"Spot",{contextMenu:g(),selectionObjectName:"SHAPE",selectionAdornmentTemplate:N(),locationSpot:i.Spot.BottomCenter,resizable:!0,resizeObjectName:"OPENING_SHAPE",toolTip:m(),minSize:new i.Size(10,10),dragComputation:W,resizeAdornmentTemplate:T(),layerName:"Foreground"},new i.Binding("location","loc",i.Point.parse).makeTwoWay(i.Point.stringify),new i.Binding("angle").makeTwoWay(),new i.Binding("locationSpot","doorOpeningHeight",function(t,e){return new i.Spot(.5,1,0,-t/2)}),t(i.Shape,{name:"SHAPE",fill:"rgba(0, 0, 0, 0)"},new i.Binding("width","length"),new i.Binding("height","length").makeTwoWay(),new i.Binding("stroke","isSelected",function(t,e){return t?"dodgerblue":"black"}).ofObject(),new i.Binding("geometryString","swing",function(t){return"left"===t?"F1 M0,0 v-150 a150,150 0 0,1 150,150 ":"F1 M275,175 v-150 a150,150 0 0,0 -150,150 "})),t(i.Shape,{name:"OPENING_SHAPE",fill:"white",strokeWidth:0,height:5,width:40,alignment:i.Spot.BottomCenter,alignmentFocus:i.Spot.Top},new i.Binding("height","doorOpeningHeight").makeTwoWay(),new i.Binding("stroke","isSelected",function(t,e){return t?"dodgerblue":"black"}).ofObject(),new i.Binding("fill","isSelected",function(t,e){return t?"lightgray":"white"}).ofObject(),new i.Binding("width","length").makeTwoWay()))}()),a.nodeTemplateMap.add("RoomNode",function(){var t=i.GraphObject.make;return t(i.Node,"Spot",{contextMenu:g(),toolTip:c(),selectionObjectName:"SHAPE",rotateObjectName:"SHAPE",locationSpot:i.Spot.TopLeft,reshapable:!0,copyable:!1,minSize:new i.Size(1,1),movable:!1,selectionAdornmentTemplate:A(["floor1.jpg","floor2.jpg","floor3.jpg","floor4.jpg","floor5.jpg","floor6.jpg","floor7.jpg"]),locationObjectName:"SHAPE",layerName:"Background"},new i.Binding("location","isSelected",function(t,e){var a=e.data.loc;if(t){var n=e.findObject("SHAPE").strokeWidth,o=new i.Point(a.x-2*n,a.y-2*n);return o}return void 0!==a?a:e.location}).ofObject(),t(i.Shape,{name:"SHAPE",fill:S(null),stroke:"black",strokeWidth:1},new i.Binding("stroke","isSelected",function(t,e){if(null!=e.part.containingGroup){var a=e.part.containingGroup;t&&(a.data.isSelected=!0)}return t?"dodgerblue":"black"}).ofObject(),new i.Binding("strokeWidth","isSelected",function(t,e){return t?5:1}).ofObject(),new i.Binding("fill","floorImage",function(t){return S(t)})),t(i.Panel,"Horizontal",{cursor:"move",name:"ROOM_LABEL",_isNodeLabel:!0},new i.Binding("alignment","labelAlignment"),t(i.Panel,"Auto",new i.Binding("visible","showLabel"),t(i.Shape,"RoundedRectangle",{fill:"beige",opacity:.5,stroke:null,strokeWidth:3,name:"ROOM_LABEL_SHAPE"},new i.Binding("stroke","isSelected",function(t){return t?"dodgerblue":null}).ofObject()),t(i.Panel,"Vertical",t(i.TextBlock,"Room Name",{editable:!0,cursor:"text",font:"normal normal bold 13px sans-serif"},new i.Binding("text","name").makeTwoWay()),t(i.TextBlock,"Room Size",{name:"ROOM_LABEL_SIZE"},new i.Binding("text","",function(t){var e=t.diagram,a=e.getRoomArea(t),n=e.convertPixelsToUnits(e.convertPixelsToUnits(a)).toFixed(2);return n+e.model.modelData.unitsAbbreviation+String.fromCharCode(178)}).ofObject()))),t("Button",{desiredSize:new i.Size(15,15),click:function(t,e){var a=e.part;if(null!==a){t.diagram.model.setDataProperty(a.data,"showFlooringOptions",!a.data.showFlooringOptions);var n=t.diagram;n.select(a)}},toolTip:t(i.Adornment,"Auto",t(i.Shape,{fill:"#FFFFCC"}),t(i.TextBlock,{margin:4,text:"Show/ hide floor types"}))},new i.Binding("visible","isSelected").ofObject(),t(i.Shape,"TriangleDown",{desiredSize:new i.Size(10,10)},new i.Binding("figure","showFlooringOptions",function(t){return t?"TriangleUp":"TriangleDown"})))))}()),a.groupTemplateMap.add("",function(){var t=i.GraphObject.make;return t(i.Group,"Vertical",{contextMenu:g(),toolTip:c()},new i.Binding("location","loc"),t(i.Panel,"Auto",t(i.Shape,"RoundedRectangle",{fill:"rgba(128,128,128,0.15)",stroke:"rgba(128, 128, 128, .05)",name:"SHAPE",strokeCap:"square"},new i.Binding("fill","isSelected",function(t,e){return t?"rgba(128, 128, 128, .15)":"rgba(128, 128, 128, 0.10)"}).ofObject()),t(i.Placeholder,{padding:5})))}()),a.groupTemplateMap.add("WallGroup",function(){var t=i.GraphObject.make;return t(i.Group,"Spot",{contextMenu:g(),toolTip:c(),selectionObjectName:"SHAPE",rotateObjectName:"SHAPE",locationSpot:i.Spot.TopLeft,reshapable:!0,minSize:new i.Size(1,1),selectionAdorned:!1,mouseDrop:k,mouseDragEnter:x,mouseDragLeave:b,dragComputation:function(t,e,a){var n=t.location,o=t.location.copy(),r=t.diagram,l=(r.toolManager.draggingTool,0);if(r.selection.iterator.each(function(e){"WallGroup"===e.category&&(l++,e.data.key,t.data.key),"RoomNode"===e.category&&(e.isSelected=!1)}),l>1)return n;var d=r.grid.gridCellSize;a.x-=d.width/2,a.y-=d.height/2;var s=r.toolManager.mouseDownTools.elt(3),u=new i.Map,p=s.getAllWallsAtIntersection(t.data.startpoint,!0);p.iterator.each(function(e){e.data.key!==t.data.key&&(s.pointsApproximatelyEqual(e.data.startpoint,t.data.startpoint)?u.add(e.data.key,{connectedTo:"startpoint",connectedFrom:"startpoint"}):s.pointsApproximatelyEqual(e.data.endpoint,t.data.startpoint)&&u.add(e.data.key,{connectedTo:"startpoint",connectedFrom:"endpoint"}))});var c=s.getAllWallsAtIntersection(t.data.endpoint,!0);c.iterator.each(function(e){e.data.key!==t.data.key&&(s.pointsApproximatelyEqual(e.data.startpoint,t.data.endpoint)?u.add(e.data.key,{connectedTo:"endpoint",connectedFrom:"startpoint"}):s.pointsApproximatelyEqual(e.data.endpoint,t.data.endpoint)&&u.add(e.data.key,{connectedTo:"endpoint",connectedFrom:"endpoint"}))});var g=r.toolManager.draggingTool.isGridSnapEnabled?a:e,f=t,h=new i.Set;function m(e){var a=e.x-n.x,o=e.y-n.y;r.model.set(t.data,"startpoint",new i.Point(t.data.startpoint.x+a,t.data.startpoint.y+o)),r.model.set(t.data,"endpoint",new i.Point(t.data.endpoint.x+a,t.data.endpoint.y+o)),s.performMiteringOnWall(f),u.iterator.each(function(e){var a=e.key,n=e.value,o=r.findNodeForKey(a);null!=o&&o.data.key!==f.data.key&&(r.model.set(o.data,n.connectedFrom,t.data[n.connectedTo]),s.performMiteringOnWall(o))}),s.performMiteringAtPoint(f.data.startpoint,!0),s.performMiteringAtPoint(f.data.endpoint,!0),n=f.location,u.iterator.each(function(t){var e=r.findNodeForKey(t.key);h.add(e)}),h.add(f),r.updateWallDimensions(h),r.updateWallAngles()}m(g);var y=r.findNodesByExample({category:"WallGroup"});return y.iterator.each(function(t){var e=t;if(f&&f.data.key!==e.data.key&&r.getWallsIntersection(f,e)&&!h.contains(e))return m(o),o}),f.location},copyable:!1},t(i.Shape,{name:"SHAPE",fill:"lightgray",stroke:"black",strokeWidth:1},new i.Binding("fill","color"),new i.Binding("stroke","isSelected",function(t,e){if(null!=e.part.containingGroup){var a=e.part.containingGroup;t&&(a.data.isSelected=!0)}return t?"dodgerblue":"black"}).ofObject()))}());var o=new l.WallBuildingTool;a.toolManager.mouseDownTools.insertAt(0,o);var s=new d.WallReshapingTool;a.toolManager.mouseDownTools.insertAt(3,s),o.isEnabled=!1;var u=new r.NodeLabelDraggingTool;return a.toolManager.mouseMoveTools.insertAt(3,u),a.toolManager.draggingTool.doDeactivate=function(){var t=this.diagram;t.updateWallAngles(),this.isGridSnapEnabled=this.diagram.model.modelData.preferences.gridSnap;var e=null;if(t.selection.iterator.each(function(t){"WallGroup"===t.category&&null==e?e=t:"WallGroup"===t.category&&null!==e&&(e=void 0)}),e){var a=new i.Set;a.add(e),t.updateAllRoomBoundaries(a),t.toolManager.mouseDownTools.elt(3).performMiteringOnWall(e),t.updateWall(e)}i.DraggingTool.prototype.doDeactivate.call(this)},a.toolManager.draggingTool.doMouseMove=function(){this.diagram.lastInput.shift?this.isGridSnapEnabled=!1:this.isG