import{__decorate as e}from"tslib";import{InvalidOperationError as r}from"../InvalidOperationError.js";import{serializable as t}from"../support/Serializable.js";import{isVectorTileLayer as a}from"../utilities/_layers.js";import{LayerExtension as i,LayerExtensionSchema as l}from"./_LayerExtension.js";let o=class extends i{get layer(){return super.layer}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"VectorTileLayer"}}}}_isSupportedLayer(e){return a(e)}_createSchema(){return new s(this)}async _initializeLayer(){if(await super._initializeLayer(),!this.layer.url)throw new r("Vector 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 a vector tile layer or does not have a tiling scheme defined.`)}async _applyPortalItemProperties(e){if("Vector Tile Service"!==e.type)throw new Error(`Cannot create Vector Tiled Layer from Portal item that has type: ${e.type}`);let r=`${e.itemUrl}/resources/styles/root.json`;try{await this.requestHelper.request(r,{query:{f:"json"}})}catch{r=e.url}r&&(this.layer.loaded?await this.layer.loadStyle(r):this.layer.url=r)}};o=e([t],o);export{o as VectorTileLayerExtension};let s=class extends l{_getPropertyBindings(){return{spatialReference:{property:"spatialReference",readonly:!0,sync:!1}}}};s=e([t],s);