/*
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/Accessor","../../core/Logger","../../core/maybe","../../core/promiseUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../DOMContainer","./interfaces","./ManipulatorCollection"],(function(e,t,i,o,a,n,r,s,l,c,u,p,d,h,v){"use strict";const y=a.getLogger("esri.views.interactive.InteractiveToolBase");e.InteractiveToolBase=function(e){function i(t){var i;return(i=e.call(this,t)||this).manipulators=new v.ManipulatorCollection,i.preferManipulatorCursor=!1,i.automaticManipulatorSelection=!0,i.hasFocusedManipulators=!1,i.created=!1,i.removeIncompleteOnCancel=!0,i._editableFlags=new Map([[h.EditableFlag.MANAGER,!0],[h.EditableFlag.USER,!0]]),i._creationFinishedResolver=r.createResolver(),i}t._inheritsLoose(i,e);var o=i.prototype;return o.destroy=function(){this.manipulators.destroy(),this._set("view",null)},o.onAdd=function(){this._syncVisible()},o.activate=function(){n.isNone(this.view)?y.error("Can't activate tool if view is not defined."):(d.isDOMContainer(this.view)&&this.view.focus(),this.onActivate())},o.deactivate=function(){this.onDeactivate()},o.handleInputEvent=function(e){this.onInputEvent(e)},o.handleInputEventAfter=function(e){this.onInputEventAfter(e)},o.setEditableFlag=function(e,t){this._editableFlags.set(e,t),this.manipulators.isToolEditable=this.internallyEditable,this._updateManipulatorAttachment(),e===h.EditableFlag.USER&&this.notifyChange("editable"),this.onEditableChange()},o.getEditableFlag=function(e){return this._editableFlags.get(e)},o.whenCreated=function(){return this._creationFinishedResolver.promise},o.onActivate=function(){},o.onDeactivate=function(){},o.onShow=function(){},o.onHide=function(){},o.onEditableChange=function(){},o.onInputEvent=function(e){},o.onInputEventAfter=function(e){},o.finishToolCreation=function(){this.created||this._creationFinishedResolver.resolve(this),this._set("created",!0)},o._syncVisible=function(){if(this.constructed)if(this.visible)this._show();else if(this._hide(),this.active)return void(this.view.activeTool=null)},o._show=function(){this._updateManipulatorAttachment(),this.onShow()},o._hide=function(){this._updateManipulatorAttachment(),this.onHide()},o._updateManipulatorAttachment=function(){this.visible?this.manipulators.attach():this.manipulators.detach()},t._createClass(i,[{key:"active",get:function(){return null!=this.view&&this.view.activeTool===this}},{key:"visible",set:function(e){this._get("visible")!==e&&(this._set("visible",e),this._syncVisible())}},{key:"editable",get:function(){return this.getEditableFlag(h.EditableFlag.USER)},set:function(e){this.setEditableFlag(h.EditableFlag.USER,e)}},{key:"updating",get:function(){return!1}},{key:"cursor",get:function(){return null}},{key:"internallyEditable",get:function(){return this.getEditableFlag(h.EditableFlag.USER)&&this.getEditableFlag(h.EditableFlag.MANAGER)}}]),i}(o),i.__decorate([s.property({constructOnly:!0})],e.InteractiveToolBase.prototype,"view",void 0),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"active",null),i.__decorate([s.property({value:!0})],e.InteractiveToolBase.prototype,"visible",null),i.__decorate([s.property({value:!0})],e.InteractiveToolBase.prototype,"editable",null),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"manipulators",void 0),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"updating",null),i.__decorate([s.property()],e.InteractiveToolBase.prototype,"cursor",null),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"preferManipulatorCursor",void 0),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"automaticManipulatorSelection",void 0),i.__decorate([s.property()],e.InteractiveToolBase.prototype,"hasFocusedManipulators",void 0),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"created",void 0),i.__decorate([s.property({readOnly:!0})],e.InteractiveToolBase.prototype,"removeIncompleteOnCancel",void 0),e.InteractiveToolBase=i.__decorate([p.subclass("esri.views.interactive.InteractiveToolBase")],e.InteractiveToolBase),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
