/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{JSONSupport as t}from"../core/JSONSupport.js";import{property as r,subclass as s}from"../core/accessorSupport/decorators.js";import{emitApplyEditsEvent as i}from"../layers/mixins/EditBusLayer.js";import n from"./UtilityNetwork.js";import{isVersionInEditSession as o,currentSessionId as d,isSafeToEditVersion as a}from"../versionManagement/support/versionManagementUtils.js";let l=class extends t{constructor(e){super(e),this.utilityNetwork=null}get networkServiceUrl(){return this.utilityNetwork?.networkServiceUrl??null}get featureServiceUrl(){return this.utilityNetwork?.featureServiceUrl??null}get gdbVersion(){return this.utilityNetwork?.gdbVersion??null}get historicMoment(){return this.utilityNetwork?.historicMoment??null}async insertGap(e,t,r){const[{insertGap:s},{default:n}]=await Promise.all([import("../rest/networks/unitIdentifiers/insertGap.js"),import("../rest/networks/unitIdentifiers/support/InsertGapParameters.js")]),l=new n({object:e,firstUnit:t,numUnits:r});o(this.featureServiceUrl,this.gdbVersion||null)?(l.sessionId=d,await a(this.featureServiceUrl,this.gdbVersion,!0)):l.sessionId=null,l.gdbVersion=this.gdbVersion;const u=i(this.featureServiceUrl,null,this.gdbVersion,!1),c=await s(this.networkServiceUrl,l);u.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:c.exceededTransferLimit,historicMoment:c.moment,editedFeatures:c.serviceEdits||void 0})}async reset(e){const[{reset:t},{default:r}]=await Promise.all([import("../rest/networks/unitIdentifiers/reset.js"),import("../rest/networks/unitIdentifiers/support/ResetParameters.js")]),s=new r({objects:e});o(this.featureServiceUrl,this.gdbVersion||null)?(s.sessionId=d,await a(this.featureServiceUrl,this.gdbVersion,!0)):s.sessionId=null,s.gdbVersion=this.gdbVersion;const n=i(this.featureServiceUrl,null,this.gdbVersion,!1),l=await t(this.networkServiceUrl,s);n.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:l.exceededTransferLimit,historicMoment:l.moment,editedFeatures:l.serviceEdits||void 0})}async resize(e,t){const[{resize:r},{default:s}]=await Promise.all([import("../rest/networks/unitIdentifiers/resize.js"),import("../rest/networks/unitIdentifiers/support/ResizeParameters.js")]),n=new s({object:e,numUnits:t});o(this.featureServiceUrl,this.gdbVersion||null)?(n.sessionId=d,await a(this.featureServiceUrl,this.gdbVersion,!0)):n.sessionId=null,n.gdbVersion=this.gdbVersion;const l=i(this.featureServiceUrl,null,this.gdbVersion,!1),u=await r(this.networkServiceUrl,n);l.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:u.exceededTransferLimit,historicMoment:u.moment,editedFeatures:u.serviceEdits||void 0})}async query(e){const[{queryUnitIdentifiers:t},{default:r}]=await Promise.all([import("../rest/networks/unitIdentifiers/queryUnitIdentifiers.js"),import("../rest/networks/unitIdentifiers/support/QueryUnitIdentifiersParameters.js")]),s=new r({objects:e});o(this.featureServiceUrl,this.gdbVersion||null)?s.sessionId=d:s.sessionId=null,s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment;return await t(this.networkServiceUrl,s)}};e([r({type:n,constructOnly:!0})],l.prototype,"utilityNetwork",void 0),e([r()],l.prototype,"networkServiceUrl",null),e([r()],l.prototype,"featureServiceUrl",null),e([r()],l.prototype,"gdbVersion",null),e([r()],l.prototype,"historicMoment",null),l=e([s("esri.networks.UnitIdentifierManager")],l);const u=l;export{u as default};
