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