/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{isDeleteItem as t,isAddAttachmentItem as e,isDeleteAttachmentItem as a,isAddItem as r,isModifyItem as s}from"./ApplySetItem.js";class p{constructor(){this.applyItems=new Map,this.featureState=null}get items(){return[...this.applyItems.values()]}get deleteItems(){return this.items.filter(t)}_add(t){this.applyItems.set(t.featureChangeId,t)}revert(){this.featureState?.clearAll(),this.applyItems.clear()}push(p){if(e(p)||a(p))return void this._add(p);const i=this.applyItems.get(p.featureChangeId);i?(r(i)&&t(p)&&(this.applyItems.delete(i.featureChangeId),this.featureState?.removeLocalState(i)),r(i)&&s(p)&&(i.graphic=p.graphic,this.featureState?.updateLocalState(i)),s(i)&&t(p)&&(this.applyItems.delete(i.featureChangeId),p.graphic=i.revertGraphic,this._add(p),this.featureState?.removeLocalState(i),this.featureState?.applyLocalState(p)),s(i)&&s(p)&&(i.graphic=p.graphic,this.featureState?.updateLocalState(i))):(this._add(p),this.featureState?.applyLocalState(p))}}export{p as ApplySet};
