/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/compilerUtils","../../../core/Evented","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass"],(function(e,t,o,r,n,a,p,i,s,d){"use strict";e.OperationHandle=function(e){function o(t){var o;return(o=e.call(this,t)||this).cancelled=!1,o.history={undo:[],redo:[]},o.type=null,o}t._inheritsLoose(o,e);var n=o.prototype;return n.addToHistory=function(e){this.history.redo=[],this.history.undo.push(e)},n.resetHistory=function(){this.history.redo=[],this.history.undo=[]},n.canUndo=function(){return this.history.undo.length>0},n.canRedo=function(){return this.history.redo.length>0},n.complete=function(){this._reset(),this.onEnd(),this.emit("complete")},n.cancel=function(){this.cancelled=!0,this.complete()},n._reset=function(){this.activeComponent.reset()},n.refreshComponent=function(){const e=this.activeComponent;e&&("box"!==e.type&&"reshape"!==e.type&&"graphic-mover"!==e.type||e.refresh())},t._createClass(o,[{key:"tool",get:function(){if(!this.activeComponent)return null;switch(this.activeComponent.type){case"graphic-mover":case"move-3d":return"move";case"box":case"transform-3d":return"transform";case"reshape":case"reshape-3d":return"reshape";case"draw-2d":case"draw-3d":return this.activeComponent.geometryType;default:r.neverReached(this.activeComponent)}return null}},{key:"undo",set:function(e){this._set("undo",(()=>{this.canUndo()&&e()}))}},{key:"redo",set:function(e){this._set("redo",(()=>{this.canRedo()&&e()}))}}]),o}(n.EventedAccessor),o.__decorate([a.property()],e.OperationHandle.prototype,"activeComponent",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"cancelled",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"history",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"tool",null),o.__decorate([a.property()],e.OperationHandle.prototype,"type",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"canUndo",null),o.__decorate([a.property()],e.OperationHandle.prototype,"canRedo",null),o.__decorate([a.property()],e.OperationHandle.prototype,"onEnd",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"undo",null),o.__decorate([a.property()],e.OperationHandle.prototype,"redo",null),o.__decorate([a.property()],e.OperationHandle.prototype,"toggleTool",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"addToSelection",void 0),o.__decorate([a.property()],e.OperationHandle.prototype,"removeFromSelection",void 0),e.OperationHandle=o.__decorate([d.subclass("esri.widgets.Sketch.support.OperationHandle")],e.OperationHandle),e.CreateOperationHandle=function(e){function o(){return e.apply(this,arguments)||this}return t._inheritsLoose(o,e),o}(e.OperationHandle),o.__decorate([a.property()],e.CreateOperationHandle.prototype,"activeComponent",void 0),e.CreateOperationHandle=o.__decorate([d.subclass("esri.widgets.Sketch.support.CreateOperationHandle")],e.CreateOperationHandle),e.UpdateOperationHandle=function(e){function o(t){return e.call(this,t)||this}return t._inheritsLoose(o,e),o}(e.OperationHandle),o.__decorate([a.property()],e.UpdateOperationHandle.prototype,"activeComponent",void 0),e.UpdateOperationHandle=o.__decorate([d.subclass("esri.widgets.Sketch.support.UpdateOperationHandle")],e.UpdateOperationHandle),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
