/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../core/maybe","../EditGeometry"],(function(e,t,r){"use strict";let i=function(){function e(e,t,r=0){this.editGeometry=e,this.vertices=t,this.minNumberOfVertices=r,this.removedVertices=null}var i=e.prototype;return i.apply=function(){let e="redo";null==this.removedVertices?(this.removedVertices=[],this.vertices.forEach((e=>{const r=this._removeVertex(e);t.isSome(r)&&this.removedVertices.push(r)})),e="apply"):this.removedVertices.forEach((e=>{this._removeVertex(e.removedVertex)})),this.editGeometry.notifyChanges({operation:e,removedVertices:this.vertices})},i.undo=function(){this.removedVertices.forEach((e=>{this._undoRemoveVertex(e)})),this.editGeometry.notifyChanges({operation:"undo",addedVertices:this.vertices})},i.accumulate=function(){return!1},i._removeVertex=function(e){const t=e.component;if(t.vertices.length<=this.minNumberOfVertices)return null;const i={removedVertex:e,createdEdge:null},s=e.leftEdge,d=e.rightEdge;return t.vertices.splice(t.vertices.indexOf(e),1),s&&(t.edges.splice(t.edges.indexOf(s),1),s.leftVertex.rightEdge=null),d&&(t.edges.splice(t.edges.indexOf(d),1),d.rightVertex.leftEdge=null),0===e.index&&d&&this.vertices.length>0&&t.swapVertices(t.vertices.indexOf(d.rightVertex),0),s&&d&&(i.createdEdge=new r.Edge(t,s.leftVertex,d.rightVertex),t.edges.push(i.createdEdge)),d&&t.updateVertexIndex(d.rightVertex,d.rightVertex.index-1),i},i._undoRemoveVertex=function(e){const t=e.removedVertex,r=e.removedVertex.component,i=t.leftEdge,s=t.rightEdge;e.createdEdge&&r.edges.splice(r.edges.indexOf(e.createdEdge),1),r.vertices.push(t),i&&(r.edges.push(i),i.leftVertex.rightEdge=i),s&&(r.edges.push(s),s.rightVertex.leftEdge=s),r.updateVertexIndex(t,t.index)},e}();e.RemoveVertices=i,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
