import{__decorate as e}from"tslib";import{InvalidOperationError as r}from"../InvalidOperationError.js";import{layerToJson as t}from"../json/LayerJson.js";import{DefaultArcGISRequestHelper as a}from"../support/ArcGISRequestHelper.js";import{serializable as i}from"../support/Serializable.js";import{isImageryTileLayer as o}from"../utilities/_layers.js";import{LayerExtension as n,LayerExtensionSchema as l}from"./_LayerExtension.js";import{PopupTemplateFeatureSettings as s}from"./support/PopupTemplateFeatureSettings.js";let y=class extends n{get layer(){return super.layer}get supportsSublayers(){return!1}_getProjectWebmapJSON(){const e=super._getProjectWebmapJSON();if(!e||this.dynamicallyAddedLayer)return e;const{layerDefinition:r}=t(this.layer);if(r?.drawingInfo){const{drawingInfo:t}=r;e.layerDefinition={},t&&(e.layerDefinition.drawingInfo=t)}return e}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"ArcGISTiledImageServiceLayer",url:""}}}}_isSupportedLayer(e){return o(e)}_createSchema(){return new p(this)}async _initializeLayer(){if(await super._initializeLayer(),!this.layer.url)throw new r("Imagery tile layer must have a URL.")}async _onInitialize(){if(await super._onInitialize(),!this.layer.tileInfo)throw new Error(`The layer at URL "${this.layer.url}" is not an imagery tile layer or does not have a tiling scheme defined.`)}async _applyPortalItemProperties(e){if("Image Service"!==e.type)throw new Error(`Cannot create Imagery Tile Layer from Portal item that has type: ${e.type}`);const r=await n._getLayerData(e.url,new a);if("Elevation"===r.cacheType)throw new Error("Cannot create Imagery Tile Layer from Portal item that references an Elevation layer");if(!r.tileInfo)throw new Error("Cannot create Imagery Tile Layer from Portal item that does not reference a tiled map service");this.layer.url=e.url,this.layer.title=this.layer.title||e.title}_createFeatureSettings(){return new m(this)}};y=e([i],y);export{y as ImageryTileLayerExtension};let p=class extends l{_getPropertyBindings(){return{spatialReference:{property:"spatialReference",readonly:!0}}}};p=e([i],p);let m=class extends s{};m=e([i],m);