/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../request","../../core/promiseUtils","../../core/urlUtils","../../core/Version","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/reader","../../core/accessorSupport/decorators/subclass","../../geometry/Extent","../../geometry/SpatialReference","../support/commonProperties"],(function(e,r,t,o,s,p,i,a,l,n,u,c,d,y,b,h){"use strict";const f=e=>{let l=function(e){function t(){var r;return(r=e.apply(this,arguments)||this).capabilities=void 0,r.copyright=null,r.fullExtent=null,r.legendEnabled=!0,r.spatialReference=null,r.version=void 0,r}r._inheritsLoose(t,e);var a=t.prototype;return a.readCapabilities=function(e,r){var t,o;const s=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!s)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};const p=this.type,a=s.includes("data"),l=s.includes("query"),n=s.includes("map"),u=!!r.exportTilesAllowed,c=s.includes("tilemap"),d="tile"!==p&&!!r.supportsDynamicLayers,y="tile"!==p&&(!r.tileInfo||d),b="tile"!==p&&(!r.tileInfo||d),h="tile"!==p,f=r.cimVersion&&i.Version.parse(r.cimVersion),_=null!=(t=null==f?void 0:f.since(1,4))&&t,m=null!=(o=null==f?void 0:f.since(2,0))&&o;return{operations:{supportsExportMap:n,supportsExportTiles:u,supportsIdentify:l,supportsQuery:a,supportsTileMap:c},exportMap:n?{supportsArcadeExpressionForLabeling:_,supportsSublayersChanges:h,supportsDynamicLayers:d,supportsSublayerVisibility:y,supportsSublayerDefinitionExpression:b,supportsCIMSymbols:m}:null,exportTiles:u?{maxExportTilesCount:+r.maxExportTilesCount}:null}},a.readVersion=function(e,r){let t=r.currentVersion;return t||(t=r.hasOwnProperty("capabilities")||r.hasOwnProperty("tables")?10:r.hasOwnProperty("supportedImageFormatTypes")?9.31:9.3),t},a.fetchSublayerInfo=function(){var e=r._asyncToGenerator((function*(e,r){return yield this.fetchAllLayersAndTables(r),this._allLayersAndTablesMap.get(e)}));function t(r,t){return e.apply(this,arguments)}return t}(),a.fetchAllLayersAndTables=function(){var e=r._asyncToGenerator((function*(e){yield this.load(e),this._allLayersAndTablesPromise||(this._allLayersAndTablesPromise=o(p.urlToObject(this.url).path+"/layers",{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey}}).then((e=>{this._allLayersAndTablesMap=new Map;for(const r of e.data.layers)this._allLayersAndTablesMap.set(r.id,r);return{result:e.data}}),(e=>({error:e}))));const r=yield this._allLayersAndTablesPromise;if(s.throwIfAborted(e),"result"in r)return r.result;throw r.error}));function t(r){return e.apply(this,arguments)}return t}(),t}(e);return t.__decorate([a.property({readOnly:!0})],l.prototype,"capabilities",void 0),t.__decorate([c.reader("service","capabilities",["capabilities","exportTilesAllowed","maxExportTilesCount","supportsDynamicLayers","tileInfo"])],l.prototype,"readCapabilities",null),t.__decorate([a.property({json:{read:{source:"copyrightText"}}})],l.prototype,"copyright",void 0),t.__decorate([a.property({type:y})],l.prototype,"fullExtent",void 0),t.__decorate([a.property(h.id)],l.prototype,"id",void 0),t.__decorate([a.property({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend"}}})],l.prototype,"legendEnabled",void 0),t.__decorate([a.property(h.popupEnabled)],l.prototype,"popupEnabled",void 0),t.__decorate([a.property({type:b})],l.prototype,"spatialReference",void 0),t.__decorate([a.property({readOnly:!0})],l.prototype,"version",void 0),t.__decorate([c.reader("version",["currentVersion","capabilities","tables","supportedImageFormatTypes"])],l.prototype,"readVersion",null),l=t.__decorate([d.subclass("esri.layers.mixins.ArcGISMapService")],l),l};e.ArcGISMapService=f,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
