UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.17 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{QueueProcessor as o}from"../../../support/QueueProcessor.js";function i(e){return e.some((e=>e.globalId))}function n(e){return e.filter((e=>!e.error)).map((e=>e.objectId??e.globalId)).filter((e=>null!=e))}function d(e,t){const s=new Set(e);for(const r of t.values())s.add(r);return s}function a(e,t){const s=new Set(e);for(const r of t.values())s.delete(r);return s}let c=class extends t{constructor(e){super(e),this._hasGlobalIds=!1,this._notifyUpdating=()=>{this.notifyChange("updating")}}normalizeCtorArgs(e){return this._queueProcessor=new o({concurrency:1,process:e.process}),{}}destroy(){this.clear()}get updating(){return this._queueProcessor.length>0}clear(){this._queueProcessor.clear()}push(e){const t=this._queueProcessor,s=t.last();switch(e.type){case"update":case"refresh":if(s?.type===e.type)return;t.push(e).then(this._notifyUpdating,this._notifyUpdating);break;case"edit":{const r="processed-edit"===s?.type?s:null;r&&t.popLast();const o=this._mergeEdits(r,e);for(const e of o)e&&t.push(e).then(this._notifyUpdating,this._notifyUpdating);break}}this.notifyChange("updating")}_mergeEdits(e,t){const{addedFeatures:s,deletedFeatures:r,updatedFeatures:o}=t.edits;if(this._hasGlobalIds=this._hasGlobalIds||i(s)||i(o)||i(r),this._hasGlobalIds){return[e,{type:"processed-edit",edits:{addOrModified:[...s,...o],removed:r}}]}const c=new Set(n(e?.edits.addOrModified??[])),p=new Set(n(e?.edits.removed??[])),u=new Set([...n(s),...n(o)]),l=new Set(n(r));return[{type:"processed-edit",edits:{addOrModified:Array.from(d(a(c,l),u)).map((e=>({objectId:e}))),removed:Array.from(d(a(p,u),l)).map((e=>({objectId:e})))}}]}};e([s({readOnly:!0})],c.prototype,"updating",null),e([s()],c.prototype,"process",void 0),c=e([r("esri.views.2d.layers.support.FeatureCommandQueue")],c);const p=c;export{p as default};