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