/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import r from"../../request.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{LoadableMixin as o}from"../../core/Loadable.js";import e from"../../core/Logger.js";import{EsriPromiseMixin as i}from"../../core/Promise.js";import{property as l,subclass as a}from"../../core/accessorSupport/decorators.js";import n from"./BuildingFieldStatistics.js";let u=class extends(o(i(s))){constructor(t){super(t),this.url=null,this.customParameters=null}get fields(){return this.loaded||"loading"===this.loadStatus?this._get("fields"):(e.getLogger(this).error("building summary statistics are not loaded"),null)}load(t){const r=null!=t?t.signal:null;return this.addResolvingPromise(this._fetchService(r)),Promise.resolve(this)}async _fetchService(t){const s=(await r(this.url,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:t})).data;this.read(s,{origin:"service"})}};t([l({constructOnly:!0,type:String})],u.prototype,"url",void 0),t([l({constructOnly:!0})],u.prototype,"customParameters",void 0),t([l({constructOnly:!0})],u.prototype,"apiKey",void 0),t([l({readOnly:!0,type:[n],json:{read:{source:"summary"}}})],u.prototype,"fields",null),u=t([a("esri.layers.support.BuildingSummaryStatistics")],u);export{u as default};
