import{validation}from"../../Validation.js";import{combineGlobalIds}from"./shared.js";import{inline,schedulePromiseCancellation,addToPath,post}from"./tools.js";import{isArcGisApiVersion3x}from"./ArcGisApiVersion.js";import{GenericActivityError}from"../../Errors.js";class DeleteFeatures{execute(e,t){var i=validation.urlOrLayer(e,isArcGisApiVersion3x),i=addToPath(i,"applyEdits"),s=validation.boolean("useGlobalIds",e.useGlobalIds,!1),o=validation.string("objectIdField",e.objectIdField,s?"GlobalID":"OBJECTID"),r=validation.string("gdbVersion",e.gdbVersion),a=validation.number("timeout",e.timeout);const l=[],n=[];for(const c of validation.array("features",e.features,validation.never))if("number"==typeof c)l.push(c);else if("string"==typeof c)s?n.push(c):(u=parseInt(c),isNaN(u)||l.push(u));else{const p=c.attributes;if("object"==typeof p){if(!p.hasOwnProperty(o))throw new GenericActivityError(`Error running the "Delete Features" activity. Feature does not have a "${o}" property. NOTE: The "Id Field" input is case-sensitive.`);var u=c.attributes[o];(s?n:l).push(u)}}r={deletes:s?combineGlobalIds(n):l.toString(),gdbVersion:r,useGlobalIds:s},a=post(i,r,a,t.cancellationToken.signal);schedulePromiseCancellation(t,a);const d=this;return inline(a,function(e){d.onApplyEditsComplete(e);var t=e.deleteResults&&e.deleteResults.every(e=>e.success);return{results:e.deleteResults,success:t}})}onApplyEditsComplete(e){}}DeleteFeatures.action="gcx:wf:arcgis::DeleteFeatures",DeleteFeatures.suite="gcx:wf:builtin";export{DeleteFeatures};