import e from"@arcgis/core/portal/Portal";import r from"@arcgis/core/portal/PortalItem";import{isVectorTileLayer as t}from"../utilities/_layers.js";import{checkArg as i}from"../utilities/checkArg.js";import{ERR_LAYER_TYPE_MISMATCH as a,applyLayerBaseToEsriApiLayer as l,applyBasemapLayerToEsriApiLayer as o,applyOperationalLayerToEsriApiLayer as s,fromEsriApiLayerToLayerBase as y,fromEsriApiLayerToOperationalLayer as c}from"./_layerHelper.js";export var VectorTileLayer;!function(p){async function n(y,c,p){i("layerJson",y).isNotMissing(),i("layerJson.layerType",y.layerType).satisfies((e=>!e||"VectorTileLayer"===e),a),i("layer",c).isNotMissing().satisfies(t,a),l(y,c),o(y,c),s(y,c),y.hasOwnProperty("styleUrl")&&(c.loaded?await c.loadStyle(y.styleUrl):c.url=y.styleUrl),y.hasOwnProperty("itemId")&&(c.portalItem?c.portalItem.id=y.itemId:c.portalItem=new r({id:y.itemId,portal:p||e.getDefault()}))}p.esriVectorTileLayerDefaults={visible:!0,opacity:1,minScale:0,maxScale:0},p.toEsriApiLayer=async function(e,r){i("layerJson",e).isNotMissing(),i("layerJson.layerType",e.layerType).satisfies((e=>!e||"VectorTileLayer"===e),a);const t=new((await import("@arcgis/core/layers/VectorTileLayer")).default);return await n(e,t,r),t},p.applyToEsriApiLayer=n,p.fromEsriApiVectorTileLayer=function(e){i("layer",e).isNotMissing();const r={...y(e,p.esriVectorTileLayerDefaults),...c(e),layerType:"VectorTileLayer"};return delete r.showLegend,e.portalItem&&(r.itemId=e.portalItem.id??void 0),e.url&&(r.styleUrl=e.url),r}}(VectorTileLayer||(VectorTileLayer={}));