/*
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/Evented","../../core/HandleOwner","../../core/maybe","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./DrawOperation","./drawSurfaces","../interactive/InteractiveToolBase"],(function(e,t,o,r,n,a,i,s,p,d,l,c,u,h){"use strict";e.DrawTool=function(e){function o(t){var o;return(o=e.call(this,t)||this).defaultZ=0,o.elevationInfo=null,o.hasZ=!0,o.mode=null,o.snapToScene=null,o.type="draw-3d",o}t._inheritsLoose(o,e);var r=o.prototype;return r.initialize=function(){const e=a.unwrapOr(this.elevationInfo,{mode:this.hasZ?"absolute-height":"on-the-ground",offset:0}),t=this.view;this.drawOperation=new c.DrawOperation({view:t,manipulators:this.manipulators,geometryType:this.geometryType,drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:"3d"===t.type?new u.SceneDrawSurface(t,e):null,elevationDrawSurface:"3d"===t.type?new u.ElevationDrawSurface(e,this.defaultZ,t):null,hasM:!1,elevationInfo:e}),this.handles.add([this.drawOperation.on("vertex-add",(e=>this.onVertexAdd(e))),this.drawOperation.on("vertex-remove",(e=>this.onVertexRemove(e))),this.drawOperation.on("vertex-update",(e=>this.onVertexUpdate(e))),this.drawOperation.on("cursor-update",(e=>this.onCursorUpdate(e))),this.drawOperation.on("complete",(e=>this.onComplete(e)))]),this.finishToolCreation()},r.destroy=function(){this.drawOperation=a.destroyMaybe(this.drawOperation),this._set("view",null)},r.completeCreateOperation=function(){this.drawOperation.complete()},r.onDeactivate=function(){this.drawOperation.isCompleted||this.drawOperation.cancel()},r.getVertexCoords=function(){return this.drawOperation.vertices},r.onInputEvent=function(e){this.drawOperation.onInputEvent(e)},r.redo=function(){this.drawOperation.redo()},r.reset=function(){},r.undo=function(){this.drawOperation.undo()},r.onComplete=function(e){this.emit("complete",e)},r.onCursorUpdate=function(e){this.emit("cursor-update",e)},r.onVertexAdd=function(e){this.emit("vertex-add",e)},r.onVertexRemove=function(e){this.emit("vertex-remove",e)},r.onVertexUpdate=function(e){this.emit("vertex-update",e)},t._createClass(o,[{key:"canRedo",get:function(){return this.drawOperation.canRedo}},{key:"canUndo",get:function(){return this.drawOperation.canUndo}},{key:"enabled",set:function(e){this.drawOperation.interactive=e,this._set("enabled",e)}},{key:"updating",get:function(){var e,t;return null!=(e=null==(t=this.drawOperation)?void 0:t.updating)&&e}}]),o}(n.HandleOwnerMixin(r.EventedMixin(h.InteractiveToolBase))),o.__decorate([i.property({constructOnly:!0,nonNullable:!0})],e.DrawTool.prototype,"defaultZ",void 0),o.__decorate([i.property()],e.DrawTool.prototype,"drawOperation",void 0),o.__decorate([i.property({constructOnly:!0})],e.DrawTool.prototype,"elevationInfo",void 0),o.__decorate([i.property({value:!0})],e.DrawTool.prototype,"enabled",null),o.__decorate([i.property({constructOnly:!0})],e.DrawTool.prototype,"geometryType",void 0),o.__decorate([i.property({constructOnly:!0})],e.DrawTool.prototype,"hasZ",void 0),o.__decorate([i.property({constructOnly:!0})],e.DrawTool.prototype,"mode",void 0),o.__decorate([i.property()],e.DrawTool.prototype,"snapToScene",void 0),o.__decorate([i.property({readOnly:!0})],e.DrawTool.prototype,"type",void 0),o.__decorate([i.property({readOnly:!0})],e.DrawTool.prototype,"updating",null),o.__decorate([i.property({constructOnly:!0,nonNullable:!0})],e.DrawTool.prototype,"view",void 0),e.DrawTool=o.__decorate([l.subclass("esri.views.draw.DrawTool")],e.DrawTool),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
