UNPKG

@wcardinal/wcardinal-geditor

Version:

WebGL-based graphic editor, tester and viewer for supervisory systems

9 lines (8 loc) 624 kB
/* WinterCardinal Graphic Editor v1.4.0 Copyright (C) TOSHIBA Coorporation SPDX-License-Identifier: Apache-2.0 Material Design icons by Google Apache license version 2.0. */ !function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}"function"==typeof SuppressedError&&SuppressedError;var o=function(t){function e(e,n){var i=t.call(this)||this;return i._commands=e,i._selection=n,i}return i(e,t),Object.defineProperty(e.prototype,"commands",{get:function(){return this._commands},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){var t=this._selection,e=this._commands;t.lock();for(var n=0,i=e.length;n<i;++n)e[n].redo();return t.unlock(),!0},e.prototype.undo=function(){var t=this._selection;t.lock();for(var e=this._commands,n=e.length-1;0<=n;--n)e[n].undo();return t.unlock(),!0},e.prototype.destroy=function(){for(var t=this._commands,e=0,n=t.length;e<n;++e)t[e].destroy()},e}(t.DCommandBase),r=function(e){function n(t,n,i,o,r,a,l,u,s,p,h){var c=e.call(this)||this;return c._diagram=t,c._canvas=n,c._name=i,c._label=o,c._width=r,c._height=a,c._category=l,c._summary=u,c._description=s,c._backgroundColor=p,c._backgroundAlpha=h,c}return i(n,e),Object.defineProperty(n.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"category",{get:function(){return this._category},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"summary",{get:function(){return this._summary},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"description",{get:function(){return this._description},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"backgroundColor",{get:function(){return this._backgroundColor},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"backgroundAlpha",{get:function(){return this._backgroundAlpha},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return this.redo()},n.prototype.redo=function(){var e=this._canvas,n=this._name;this._name=e.name,e.name=n;var i=this._label;this._label=e.label,e.label=i;var o=this._width;this._width=e.width,e.width=o;var r=this._height;this._height=e.height,e.height=r;var a=this._category;this._category=e.category,e.category=a;var l=this._summary;this._summary=e.summary,e.summary=l;var u=this._description;this._description=e.description,e.description=u;var s=this._backgroundColor,p=this._backgroundAlpha,h=new t.DBaseStateSetImpl,c=e.background;return this._backgroundColor=c.getColor(h),this._backgroundAlpha=c.getAlpha(h),c.color=s,c.alpha=p,this._diagram.emit("change",this._diagram),!0},n.prototype.undo=function(){return this.redo()},n}(t.DCommandBase),a=function(e){function n(t,n,i){var o=e.call(this)||this;return o._diagram=t,o._color=n,o._alpha=i,o}return i(n,e),Object.defineProperty(n.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"color",{get:function(){return this._color},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return this.redo()},n.prototype.redo=function(){var e=this._diagram.canvas;if(null!=e){var n=e.background,i=this._color,o=this._alpha,r=new t.DBaseStateSetImpl;this._color=n.getColor(r),this._alpha=n.getAlpha(r),n.color=i,n.alpha=o,this._diagram.emit("change",this._diagram)}return!0},n.prototype.undo=function(){return this.redo()},n}(t.DCommandBase),l=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._category=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"category",{get:function(){return this._category},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._category;return this._category=t.category,t.category=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),u=function(t){function e(e,n){var i=t.call(this)||this;return i._diagram=e,i._canvas=n,i}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e}(t.DCommandCreate),s=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._description=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){return this._description},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._description;return this._description=t.description,t.description=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),p=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._height=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._height;return this._height=t.height,t.y=t.y+.5*(t.height-e),t.height=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),h=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._label=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"label",{get:function(){return this._label},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._label;return this._label=t.label,t.label=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),c=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._name=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._name;return this._name=t.name,t.name=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),d=function(t){function e(e,n){var i=t.call(this)||this;return i._diagram=e,i._canvas=n,i}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e}(t.DCommandCreate),g=function(t){function e(e,n){var i=t.call(this)||this;return i._snapper=e,i._index=n,i}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._index;return this._snapper.target.swap(t-1,t),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),f=function(t){function e(e,n){var i=t.call(this)||this;return i._snapper=e,i._target=n,i}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){return this._snapper.target.add(this._target),!0},e.prototype.undo=function(){var t=this._snapper.target;return t.remove(t.size-1),!0},e}(t.DCommandBase),y=function(t){function e(e,n,i){var o=t.call(this)||this;return o._snapper=e,o._index=n,o._target=i,o}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){return this._snapper.target.remove(this._index),!0},e.prototype.undo=function(){return this._snapper.target.add(this._target,this._index),!0},e}(t.DCommandBase),v=function(t){function e(e,n){var i=t.call(this)||this;return i._snapper=e,i._size=n,i}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._snapper,e=this._size;return this._size=t.grid.size,t.grid.size=e,!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),b=function(t){function e(e){var n=t.call(this)||this;return n._snapper=e,n}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._snapper.grid;return t.visible=!t.visible,!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),m=function(t){function e(e){var n=t.call(this)||this;return n._snapper=e,n}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._snapper.grid;return t.enable=!t.enable,!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),_=function(t){function e(e,n,i,o){var r=t.call(this)||this;return r._snapper=e,r._oldValue=n,r._newValue=i,r._index=e.target.values.indexOf(r._oldValue),r._list=o,r}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"newValue",{get:function(){return this._newValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._index;if(0<=t){var e=this._list,n=this._newValue,i=this._snapper;e.data.selection.contains(this._oldValue)?(i.target.replace(t,n),e.data.selection.clearAndAdd(n)):i.target.replace(t,n)}return!0},e.prototype.undo=function(){var t=this._index;if(0<=t){var e=this._list,n=this._oldValue,i=this._snapper;e.data.selection.contains(this._newValue)?(i.target.replace(t,n),e.data.selection.clearAndAdd(n)):i.target.replace(t,n)}return!0},e}(t.DCommandBase),S=function(t){function e(e,n){var i=t.call(this)||this;return i._snapper=e,i._index=n,i}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._index;return this._snapper.target.swap(t,t+1),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),w=function(t){function e(e){var n=t.call(this)||this;return n._snapper=e,n}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._snapper.target;return t.visible=!t.visible,!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),T=function(t){function e(e){var n=t.call(this)||this;return n._snapper=e,n}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._snapper.target;return t.enable=!t.enable,!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),E=function(t){function e(e){var n=t.call(this)||this;return n._snapper=e,n}return i(e,t),Object.defineProperty(e.prototype,"snapper",{get:function(){return this._snapper},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._snapper;return t.enable=!t.enable,!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),C=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._summary=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"summary",{get:function(){return this._summary},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._summary;return this._summary=t.summary,t.summary=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),D=function(t){function e(e,n,i){var o=t.call(this)||this;return o._diagram=e,o._canvas=n,o._width=i,o}return i(e,t),Object.defineProperty(e.prototype,"diagram",{get:function(){return this._diagram},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){var t=this._canvas,e=this._width;return this._width=t.width,t.x=t.x+.5*(t.width-e),t.width=e,this._diagram.emit("change",this._diagram),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),L=function(e){function n(t,n){var i=e.call(this)||this;return i._index=t,i._layerContainer=n,i}return i(n,e),Object.defineProperty(n.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"layerContainer",{get:function(){return this._layerContainer},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return this.redo()},n.prototype.redo=function(){var e=this._index,n=this._layerContainer,i=n.children,o=i[e];return i[e]=i[e+1],i[e+1]=o,n.onChildrenChange(e),n.emit("change",n),t.DApplications.update(n),!0},n.prototype.undo=function(){return this.redo(),!0},n}(t.DCommandBase),A=function(){function t(t,e,n){this.enable=t,this.color=e,this.alpha=n}return t.prototype.isEqual=function(t){return this.enable===t.enable&&this.color===t.color&&this.alpha===t.alpha},t.from=function(e){return new t(e.background.enable,e.background.color,e.background.alpha)},t}(),B=function(){function e(t,e,n,i,o,r,a,l,u){this.name=t,this.x=e,this.y=n,this.width=i,this.height=o,this.background=r,this.visible=a,this.interactive=l,this.gesture=u}return e.prototype.isEqual=function(t){return this.name===t.name&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height&&this.background.isEqual(t.background)&&this.visible===t.visible&&this.interactive===t.interactive&&this.gesture===t.gesture},e.prototype.copyTo=function(e){e.name=this.name,e.position.set(this.x,this.y),e.width=this.width,e.height=this.height,e.background.copy(this.background);var n=e.state;n.lock(),n.set(t.EShapeLayerState.INVISIBLE,!this.visible),n.set(t.EShapeLayerState.INTERACTIVE,this.interactive);var i=this.gesture;return n.set(t.EShapeLayerState.DRAGGABLE,!!(i&t.EShapeActionValueGestureOperationType.DRAG)),n.set(t.EShapeLayerState.PINCHABLE,!!(i&t.EShapeActionValueGestureOperationType.PINCH)),n.unlock(),this},e.from=function(n){var i=(n.state.is(t.EShapeLayerState.DRAGGABLE)?t.EShapeActionValueGestureOperationType.DRAG:t.EShapeActionValueGestureOperationType.NONE)|(n.state.is(t.EShapeLayerState.PINCHABLE)?t.EShapeActionValueGestureOperationType.PINCH:t.EShapeActionValueGestureOperationType.NONE);return new e(n.name,n.position.x,n.position.y,n.width,n.height,A.from(n),!n.state.is(t.EShapeLayerState.INVISIBLE),n.state.is(t.EShapeLayerState.INTERACTIVE),i)},e}(),O=function(t){function e(e,n,i){var o=t.call(this)||this;return o._layer=e,o._layerContainer=i,o._oldValue=B.from(e),o._newValue=n,o}return i(e,t),Object.defineProperty(e.prototype,"layer",{get:function(){return this._layer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"newValue",{get:function(){return this._newValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerContainer",{get:function(){return this._layerContainer},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){this._newValue.copyTo(this._layer);var t=this._layerContainer;return t.emit("change",t),!0},e.prototype.undo=function(){this._oldValue.copyTo(this._layer);var t=this._layerContainer;return t.emit("change",t),!0},e}(t.DCommandBase),P=function(t){function e(e,n,i){var o=t.call(this)||this;return o._value=e,o._layerContainer=n,o._layerActive=n.active,o._layerCreated=null,o._selection=i,o._selectionStored=null,o}return i(e,t),e.prototype.newLayer=function(t,e){var n=e.create(t.name,!0);return t.copyTo(n),n},Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerContainer",{get:function(){return this._layerContainer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerActive",{get:function(){return this._layerActive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerCreated",{get:function(){return this._layerCreated},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectionStored",{get:function(){return this._selectionStored},enumerable:!1,configurable:!0}),e.prototype.execute=function(){var t=this._selection;return t.isEmpty()?this._selectionStored=null:(this._selectionStored=t.store(),t.clear()),this._layerCreated=this.newLayer(this._value,this._layerContainer),this._layerCreated.reference+=1,!0},e.prototype.redo=function(){null!=this._selectionStored&&this._selection.clear();var t=this._layerCreated;return null!=t&&this._layerContainer.attach(t,!0),!0},e.prototype.undo=function(){var t=this._layerCreated;null!=t&&this._layerContainer.detach(t,this._layerActive);var e=this._selectionStored;return null!=e&&this._selection.restore(e),!0},e.prototype.destroy=function(){var t=this._layerCreated;null!=t&&(t.reference-=1,null==t.parent&&t.reference<=0&&t.destroy()),this._layerActive=null},e}(t.DCommandBase),I=function(t){function e(e,n,i){var o=t.call(this)||this;return o._layerContainer=n,o._layerActive=n.active,o._layer=e,e.reference+=1,o._layerIndex=-1,o._selection=i,o._selectionStored=null,o}return i(e,t),Object.defineProperty(e.prototype,"layerContainer",{get:function(){return this._layerContainer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerActive",{get:function(){return this._layerActive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layer",{get:function(){return this._layer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layerIndex",{get:function(){return this._layerIndex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectionStored",{get:function(){return this._selectionStored},enumerable:!1,configurable:!0}),e.prototype.execute=function(){var t=this._layer,e=this._layerContainer,n=this._selection;return t!==e.active||n.isEmpty()?this._selectionStored=null:(this._selectionStored=n.store(),n.clear()),this._layerIndex=e.delete(t,!0),!0},e.prototype.redo=function(){return null!=this._selectionStored&&this._selection.clear(),this._layerContainer.delete(this._layer,!0),!0},e.prototype.undo=function(){return this._layerContainer.attachAt(this._layer,this._layerIndex,this._layer===this._layerActive),null!=this._selectionStored&&this._selection.restore(this._selectionStored),!0},e.prototype.destroy=function(){var t=this._layer;t.reference-=1,null==t.parent&&t.reference<=0&&t.destroy(),this._layerActive=null,this._selectionStored=null},e}(t.DCommandBase),x=function(e){function n(t,n){var i=e.call(this)||this;return i._index=t,i._layerContainer=n,i}return i(n,e),Object.defineProperty(n.prototype,"index",{get:function(){return this._index},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"layerContainer",{get:function(){return this._layerContainer},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return this.redo()},n.prototype.redo=function(){var e=this._index,n=this._layerContainer,i=n.children,o=i[e];return i[e]=i[e-1],i[e-1]=o,n.onChildrenChange(e),n.emit("change",n),t.DApplications.update(n),!0},n.prototype.undo=function(){return this.redo(),!0},n}(t.DCommandBase),R=function(t){function e(e,n){var i=t.call(this)||this;return i._selection=n,i._value=e,i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){for(var t=this._value,e=this._selection.get(),n=0,i=e.length;n<i;++n)e[n].action.add(t);return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){for(var t=this._selection.get(),e=0,n=t.length;e<n;++e){var i=t[e];i.action.remove(i.action.size()-1)}return this._selection.update("PROPERTY"),!0},e}(t.DCommandBase),k=function(t){function e(e,n){var i=t.call(this)||this;return i._selection=n,i._target=e,i._indices=[],i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),e.prototype.execute=function(){for(var t=this._target,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i],a=r.action.indexOf(t);e.push(a),0<a&&r.action.swap(a-1,a)}return this._indices=e,this._selection.update("PROPERTY"),!0},e.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n],r=e[n];0<r&&o.action.swap(r-1,r)}return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),V=function(t){function e(e,n){var i=t.call(this)||this;return i._selection=n,i._target=e,i._indices=[],i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),e.prototype.execute=function(){for(var t=this._target,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i],a=r.action.indexOf(t);e.push(a),0<=a&&r.action.remove(a)}return this._selection.update("PROPERTY"),!0},e.prototype.redo=function(){for(var t=this._indices,e=this._selection.get(),n=0,i=e.length;n<i;++n){var o=e[n],r=t[n];0<=r&&o.action.remove(r)}return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){for(var t=this._target,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i],a=e[i];0<=a&&r.action.add(t,a)}return this._selection.update("PROPERTY"),!0},e}(t.DCommandBase),M=function(t){function e(e,n,i,o){var r=t.call(this)||this;return r._selection=i,r._oldValue=e,r._newValue=n,r._list=o,r._indices=[],r._oldValues=[],r}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"newValue",{get:function(){return this._newValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldValues",{get:function(){return this._oldValues},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!1,configurable:!0}),e.prototype.execute=function(){for(var t=this._oldValue,e=this._newValue,n=this._indices,i=this._oldValues,o=this._selection.get(),r=0,a=o.length;r<a;++r){var l=o[r],u=l.action.indexOf(t);n.push(u),0<=u?(i.push(l.action.get(u)),l.action.set(u,e)):i.push(e)}var s=this._list;return s.data.selection.contains(t)&&s.data.selection.clearAndAdd(e),this._selection.update("PROPERTY"),!0},e.prototype.redo=function(){for(var t=this._newValue,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=e[i];0<=r&&n[i].action.set(r,t)}var a=this._list;return a.data.selection.contains(this._oldValue)&&a.data.selection.clearAndAdd(t),this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){for(var t=this._indices,e=this._oldValues,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=t[i];0<=r&&n[i].action.set(r,e[i])}var a=this._list;return a.data.selection.contains(this._newValue)&&a.data.selection.clearAndAdd(this._oldValue),this._selection.update("PROPERTY"),!0},e}(t.DCommandBase),N=function(t){function e(e,n){var i=t.call(this)||this;i._selection=n,i._target=e;for(var o=[],r=i._selection.get(),a=0,l=r.length;a<l;++a){var u=r[a].action,s=u.indexOf(e);o.push(s),0<=s&&s<u.size()-1&&u.swap(s+1,s)}return i._indices=o,i._selection.update("PROPERTY"),i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n].action,r=e[n];0<=r&&r<o.size()-1&&o.swap(r+1,r)}return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),F=function(t){function e(e,n,i,o){var r=t.call(this)||this;r._shapes=e;for(var a=0,l=e.length;a<l;++a)e[a].reference+=1;return r._parent=n,r._selection=i,r._select=o,r}return i(e,t),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shapes",{get:function(){return this._shapes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectionStored",{get:function(){return this._selectionStored},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"select",{get:function(){return this._select},enumerable:!1,configurable:!0}),e.prototype.execute=function(){var t=this._selection;return t.lock(),this._select&&(this._selectionStored=t.store(),t.clearAndAddAll(this._shapes)),t.update("TREE"),t.unlock(),!0},e.prototype.redo=function(){for(var t=this._shapes,e=this._parent,n=0,i=t.length;n<i;++n)t[n].attach(e);var o=this._selection;return o.lock(),this._select&&o.clearAndAddAll(t),o.update("TREE"),o.unlock(),!0},e.prototype.undo=function(){for(var t=this._shapes,e=0,n=t.length;e<n;++e)t[e].detach();var i=this._selection,o=this._selectionStored;return i.lock(),this._select&&null!=o&&i.restore(o),i.update("TREE"),i.unlock(),!0},e.prototype.destroy=function(){for(var t=this._shapes,e=0,n=t.length;e<n;++e){var i=t[e];i.reference-=1,null==i.parent&&i.reference<=0&&i.destroy()}},e}(t.DCommandBase),j=function(e){function n(t,n){var i=e.call(this)||this;return i._selection=n,i._value=t,i}return i(n,e),Object.defineProperty(n.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return this.redo()},n.prototype.redo=function(){for(var e=this._value,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i];t.EShapeCapabilities.contains(r,t.EShapeCapability.DATA_MAPPING)&&r.data.mapping.add(e)}return this._selection.update("PROPERTY"),!0},n.prototype.undo=function(){for(var e=this._selection.get(),n=0,i=e.length;n<i;++n){var o=e[n];if(t.EShapeCapabilities.contains(o,t.EShapeCapability.DATA_MAPPING)){var r=o.data.getMapping();r&&r.remove(r.size()-1)}}return this._selection.update("PROPERTY"),!0},n}(t.DCommandBase),z=function(e){function n(n,i){var o=e.call(this)||this;o._selection=i,o._target=n;for(var r=[],a=o._selection.get(),l=0,u=a.length;l<u;++l){var s=a[l];if(t.EShapeCapabilities.contains(s,t.EShapeCapability.DATA_MAPPING)){var p=s.data.getMapping();if(p){var h=p.indexOf(n);r.push(h),0<h&&p.swap(h-1,h)}else r.push(-1)}else r.push(-1)}return o._indices=r,o._selection.update("PROPERTY"),o}return i(n,e),Object.defineProperty(n.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return!0},n.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n],r=e[n];if(0<r){var a=o.data.getMapping();a&&a.swap(r-1,r)}}return this._selection.update("PROPERTY"),!0},n.prototype.undo=function(){return this.redo()},n}(t.DCommandBase),H=function(e){function n(n,i){var o=e.call(this)||this;o._selection=i,o._target=n;for(var r=[],a=o._selection.get(),l=0,u=a.length;l<u;++l){var s=a[l];if(t.EShapeCapabilities.contains(s,t.EShapeCapability.DATA_MAPPING)){var p=s.data.getMapping();if(p){var h=p.indexOf(n);r.push(h),0<=h&&p.remove(h)}else r.push(-1)}else r.push(-1)}return o._indices=r,o._selection.update("PROPERTY"),o}return i(n,e),Object.defineProperty(n.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return!0},n.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n],r=e[n];if(0<=r){var a=o.data.getMapping();a&&a.remove(r)}}return this._selection.update("PROPERTY"),!0},n.prototype.undo=function(){for(var t=this._target,e=this._selection.get(),n=this._indices,i=0,o=e.length;i<o;++i){var r=e[i],a=n[i];if(0<=a){var l=r.data.getMapping();l&&l.add(t,a)}}return this._selection.update("PROPERTY"),!0},n}(t.DCommandBase),G=function(e){function n(n,i,o,r){var a=e.call(this)||this;a._selection=o,a._oldValue=n,a._newValue=i,a._list=r;for(var l=[],u=[],s=a._selection.get(),p=0,h=s.length;p<h;++p){var c=s[p];if(t.EShapeCapabilities.contains(c,t.EShapeCapability.DATA_MAPPING)){var d=c.data.getMapping();if(d){var g=d.indexOf(n);l.push(g),0<=g?(u.push(d.get(g)),d.set(g,i)):u.push(i)}else l.push(-1),u.push(i)}else l.push(-1),u.push(i)}return a._indices=l,a._oldValues=u,r.data.selection.contains(n)&&r.data.selection.clearAndAdd(i),a._selection.update("PROPERTY"),a}return i(n,e),Object.defineProperty(n.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"newValue",{get:function(){return this._newValue},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"oldValues",{get:function(){return this._oldValues},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"list",{get:function(){return this._list},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return!0},n.prototype.redo=function(){for(var t=this._newValue,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i],a=e[i];if(0<=a){var l=r.data.getMapping();l&&l.set(a,t)}}var u=this._list;return u.data.selection.contains(this._oldValue)&&u.data.selection.clearAndAdd(t),this._selection.update("PROPERTY"),!0},n.prototype.undo=function(){for(var t=this._indices,e=this._oldValues,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i],a=t[i];if(0<=a){var l=r.data.getMapping();l&&l.set(a,e[i])}}var u=this._list;return u.data.selection.contains(this._newValue)&&u.data.selection.clearAndAdd(this._oldValue),this._selection.update("PROPERTY"),!0},n}(t.DCommandBase),U=function(e){function n(n,i){var o=e.call(this)||this;o._selection=i,o._target=n;for(var r=[],a=o._selection.get(),l=0,u=a.length;l<u;++l){var s=a[l];if(t.EShapeCapabilities.contains(s,t.EShapeCapability.DATA_MAPPING)){var p=s.data.getMapping();if(p){var h=p.indexOf(n);r.push(h),0<=h&&h<p.size()-1&&p.swap(h+1,h)}else r.push(-1)}else r.push(-1)}return o._indices=r,o._selection.update("PROPERTY"),o}return i(n,e),Object.defineProperty(n.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),n.prototype.execute=function(){return!0},n.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n],r=e[n],a=o.data.getMapping();a&&0<=r&&r<a.size()-1&&a.swap(r+1,r)}return this._selection.update("PROPERTY"),!0},n.prototype.undo=function(){return this.redo()},n}(t.DCommandBase),Y=function(t){function e(e,n){var i=t.call(this)||this;return i._selection=n,i._value=e,i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return this.redo()},e.prototype.redo=function(){for(var t=this._value,e=this._selection.get(),n=0,i=e.length;n<i;++n)e[n].data.add(t);return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){for(var t=this._selection.get(),e=0,n=t.length;e<n;++e){var i=t[e];i.data.remove(i.data.size()-1)}return this._selection.update("PROPERTY"),!0},e}(t.DCommandBase),X=function(t){function e(e,n){var i=t.call(this)||this;i._selection=n,i._target=e;for(var o=[],r=i._selection.get(),a=0,l=r.length;a<l;++a){var u=r[a],s=u.data.indexOf(e);o.push(s),0<s&&u.data.swap(s-1,s)}return i._indices=o,i._selection.update("PROPERTY"),i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n],r=e[n];0<r&&o.data.swap(r-1,r)}return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),W=function(t){function e(e,n){var i=t.call(this)||this;i._selection=n,i._target=e;for(var o=[],r=i._selection.get(),a=0,l=r.length;a<l;++a){var u=r[a],s=u.data.indexOf(e);o.push(s),0<=s&&u.data.remove(s)}return i._indices=o,i._selection.update("PROPERTY"),i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){for(var t=this._indices,e=this._selection.get(),n=0,i=e.length;n<i;++n){var o=e[n],r=t[n];0<=r&&o.data.remove(r)}return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){for(var t=this._target,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=n[i],a=e[i];0<=a&&r.data.add(t,a)}return this._selection.update("PROPERTY"),!0},e}(t.DCommandBase),K=function(t){function e(e,n,i,o){var r=t.call(this)||this;r._selection=i,r._oldValue=e,r._newValue=n,r._list=o;for(var a=[],l=[],u=r._selection.get(),s=0,p=u.length;s<p;++s){var h=u[s],c=h.data.indexOf(e);a.push(c),0<=c?(l.push(h.data.get(c)),h.data.set(c,n)):l.push(n)}return r._indices=a,r._oldValues=l,o.data.selection.contains(e)&&o.data.selection.clearAndAdd(n),r._selection.update("PROPERTY"),r}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"newValue",{get:function(){return this._newValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"oldValues",{get:function(){return this._oldValues},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){for(var t=this._newValue,e=this._indices,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=e[i];0<=r&&n[i].data.set(r,t)}var a=this._list;return a.data.selection.contains(this._oldValue)&&a.data.selection.clearAndAdd(t),this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){for(var t=this._indices,e=this._oldValues,n=this._selection.get(),i=0,o=n.length;i<o;++i){var r=t[i];0<=r&&n[i].data.set(r,e[i])}var a=this._list;return a.data.selection.contains(this._newValue)&&a.data.selection.clearAndAdd(this._oldValue),this._selection.update("PROPERTY"),!0},e}(t.DCommandBase),Z=function(t){function e(e,n){var i=t.call(this)||this;i._selection=n,i._target=e;for(var o=[],r=i._selection.get(),a=0,l=r.length;a<l;++a){var u=r[a].data,s=u.indexOf(e);o.push(s),0<=s&&s<u.size()-1&&u.swap(s+1,s)}return i._indices=o,i._selection.update("PROPERTY"),i}return i(e,t),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){for(var t=this._selection.get(),e=this._indices,n=0,i=t.length;n<i;++n){var o=t[n].data,r=e[n];0<=r&&r<o.size()-1&&o.swap(r+1,r)}return this._selection.update("PROPERTY"),!0},e.prototype.undo=function(){return this.redo()},e}(t.DCommandBase),q=function(){function e(){}return e.toIndices=function(t){for(var e=[],n=0,i=t.length;n<i;++n)e.push(t[n].index);return e},e.toDepth=function(e){for(var n=0,i=e.parent;i instanceof t.EShapeBase;)n+=1,i=i.parent;return n},e.toSharedParent=function(e,n){if(this.toDepth(e)<this.toDepth(n)){for(var i=e.parent;i instanceof t.EShapeBase;){if(this.isParent(n,i))return i;i=i.parent}return i}for(var o=n.parent;o instanceof t.EShapeBase;){if(this.isParent(e,o))return o;o=o.parent}return o},e.toOfParent=function(e,n){for(var i=e.parent;i!==n&&i instanceof t.EShapeBase;)e=i,i=i.parent;return e},e.isParent=function(e,n){for(var i=e.parent;i instanceof t.EShapeBase;){if(i===n)return!0;i=i.parent}return!1},e.toSelected=function(e){for(var n=e;n instanceof t.EShapeBase;){if(n.selected)return n;n=n.parent}return null},e.findChildById=function(t,n,i){for(var o=t.children,r=0,a=o.length;r<a;++r){var l=o[r];if(l.id===n)return l;if(!0===i){var u=e.findChildById(l,n,i);if(null!=u)return u}}return null},e.findChildByType=function(t,n,i){for(var o=t.children,r=0,a=o.length;r<a;++r){var l=o[r];if(l.type===n)return l;if(!0===i){var u=e.findChildByType(l,n,i);if(null!=u)return u}}return null},e.findChild=function(t,n,i){for(var o=t.children,r=0,a=o.length;r<a;++r){var l=o[r];if(n(l))return l;if(!0===i){var u=e.findChild(l,n,i);if(null!=u)return u}}return null},e.findChildrenByType=function(t,n,i,o){o=o||[];for(var r=t.children,a=0,l=r.length;a<l;++a){var u=r[a];u.type===n&&o.push(u),!0===i&&e.findChildrenByType(u,n,i,o)}return o},e.findChildren=function(t,n,i,o){o=o||[];for(var r=t.children,a=0,l=r.length;a<l;++a){var u=r[a];n(u)&&o.push(u),!0===i&&e.findChildren(u,n,i,o)}return o},e.COMPARATOR_INDEX=function(t,e){return t.index-e.index},e}(),J=function(){function t(){}return t.addAll=function(t,e){for(var n=0,i=t.length;n<i;++n){var o=t[n];e.add(o),this.addAll(o.children,e)}return e},t.delete=function(e,n,i,o){var r,a=e.children,l=a.length;null!=o||(o=null!==(r=t.EXCEPTIONS)&&void 0!==r?r:t.EXCEPTIONS=new Set);for(var u=0;u<l;++u)(h=a[u]).selected?(h.index=l+u,o.add(h),this.addAll(h.children,o)):h.index=u;if(a.sort(q.COMPARATOR_INDEX),!0===i){for(u=l-1;0<=u;--u){if(!(h=a[u]).selected){t.EXCEPTIONS===o&&o.clear();var s=a.length-(u+1);if(0<s){var p=a.splice(u+1,s);return null!=n&&(n.length=0),e.onChildTransformChange(),e.toDirty(),p}return null!=n&&(n.length=0),null}h.index-=l,h.parent=null,h.selected=!1,h.uploaded=void 0,h.onDetach(o)}return t.EXCEPTIONS===o&&o.clear(),0<a.length?(p=a.splice(0,a.length),null!=n&&(n.length=0),e.onChildTransformChange(),e.toDirty(),p):(null!=n&&(n.length=0),null)}for(u=l-1;0<=u;--u){var h;if(!(h=a[u]).selected)return t.EXCEPTIONS===o&&o.clear(),a.length=u+1,null!=n&&(n.length=0),e.onChildTransformChange(),e.toDirty(),null;h.parent=null,h.selected=!1,h.uploaded=void 0,h.onDetach(o)}return t.EXCEPTIONS===o&&o.clear(),0<a.length?(a.length=0,null!=n&&(n.length=0),e.onChildTransformChange(),e.toDirty()):null!=n&&(n.length=0),null},t}(),Q=function(t){function e(e,n,i,o,r){var a=t.call(this)||this;a._shapes=e;for(var l=0,u=e.length;l<u;++l)e[l].reference+=1;return a._indices=n,a._parent=i,a._selection=o,a._select=r,a}return i(e,t),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shapes",{get:function(){return this._shapes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"select",{get:function(){return this._select},enumerable:!1,configurable:!0}),e.prototype.execute=function(){return!0},e.prototype.redo=function(){var t=this._selection;if(this._select)t.delete(!1);else{for(var e=this._shapes,n=0,i=e.length;n<i;++n)e[n].selected=!0;J.delete(this._parent,void 0,!1),t.update("TREE")}return!0},e.prototype.undo=function(){for(var t=this._shapes,e=this._indices,n=this._parent,i=0,o=t.length;i<o;++i)t[i].attach(n,e[i]);var r=this._selection;return r.lock(),this._select&&r.clearAndAddAll(t),r.update("TREE"),r.unlock(),!0},e.prototype.destroy=function(){for(var t=this._shapes,e=0,n=t.length;e<n;++e){var i=t[e];i.reference-=1,null==i.parent&&i.reference<=0&&i.destroy()}t.length=0},e}(t.DCommandBase),$=function(e){function n(t,n){var i=e.call(this)||this;return i._parent=t,i._selection=n,i._before=[],i._deleteds=[],i._indices=[],i._createds=[],i}return i(n,e),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"selection",{get:function(){return this._selection},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"before",{get:function(){return this._before},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deleteds",{get:function(){return this._deleteds},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"indices",{get:function(){return this._indices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"createds",{get:function(){return this._createds},enumerable:!1,configurable:!0}),n.prototype.execute=function(){var e=this._selection;this._before=e.store(),e.lock();for(var n=e.get(),i=n.length-1;0<=i;--i){var o=n[i];t.EShapeCapabilities.contains(o,t.EShapeCapability.GROUPING)||(o.selected=!1,n.splice(i,1))}var r=this._parent,a=new Set,l=J.delete(r,n,!0,a)||[];this._deleteds=l,i=0;for(var u=l.length;i<u;++i)l[i].reference+=1;var s=e.modifier,p=s.position.x+.5*s.width,h=s.position.y+.5*s.height,c=s.width,d=s.height,g=new t.EShapeGroup(t.EShapeResourceManagerDeserializationMode.EDITOR);g.transform.position.set(p,h),g.size.set(c,d),g.attach(r);var f=g.children;for(i=0,u=l.length;i<u;++i){var y=l[i].clone();y.lock(t.EShapeLockPart.ALL);var v=y.transform.position;if(v.set(v.x-p,v.y-h),y instanceof t.EShapeConnectorLine){var b=y.edge,m=b.tail,_=m.acceptor,S=_.shape,w=m.local;null==S?w.set(w.x-p,w.y-h):a.has(S)||(_.shape=null,w.set(w.x-p,w.y-h));var T=b.head,E=T.acceptor,C=E.shape,D=T.local;null==C?D.set(D.x-p,D.y-h):a.has(C)||(E.shape=null,D.set(D.x-p,D.y-h))}y.parent=g,f.push(y)}for(t.EShapeConnectors.moveAll(l,f,l,f),i=0,u=f.length;i<u;++i)f[i].unlock(t.EShapeLockPart.ALL,!0);return g.onChildTransformChange(),g.toDirty(),g.onAttach(),g.reference+=1,this._createds=[g],a.clear(),this._indices=q.toIndices(l),e.clearAndAddAll(this._createds),e.update("TREE"),e.unlock(),!0},n.prototype.redo=function(){var t=this._selection;t.lock(),t.clearAndAddAll(this._deleteds),t.delete(!1);for(var e=this._parent,n=this._createds,i=0,o=n.length;i<o;++i)n[i].attach(e);return t.update("TREE"),t.unlock(),!0},n.prototype.undo=function(){var t=this._parent,e=this._selection;e.lock();for(var n=this._createds,i=n.length-1;0<=i;--i)n[i].detach();for(var o=this._deleteds,r=this._indices,a=(i=0,o.length);i<a;++i)o[i].attach(t,r[i]);return this._selection.restore(this._before),