import{isGeoJSONLayer as e}from"../utilities/_layers.js";import{checkArg as i}from"../utilities/checkArg.js";import{LayerDefinition as r}from"./LayerDefinition.js";import{PopupInfo as s}from"./PopupInfo.js";import{defaultPointRenderer as a}from"./Renderer.js";import{ERR_LAYER_TYPE_MISMATCH as n,applyLayerBaseToEsriApiLayer as o,applyOperationalLayerToEsriApiLayer as l,fromEsriApiLayerToLayerBase as p,fromEsriApiLayerToOperationalLayer as t}from"./_layerHelper.js";export var GeoJSONLayer;!function(y){async function f(a,p){i("layerJson",a).isNotMissing(),i("layerJson.layerType",a.layerType).satisfies((e=>!e||"GeoJSON"===e),n),i("layer",p).isNotMissing().satisfies(e,n),o(a,p),l(a,p),a.hasOwnProperty("popupInfo")&&null!=a.popupInfo&&(p.popupTemplate=s.toEsriApiPopupTemplate(a.popupInfo)),a.hasOwnProperty("screenSizePerspective")&&null!=a.screenSizePerspective&&(p.screenSizePerspectiveEnabled=a.screenSizePerspective),a.hasOwnProperty("showLabels")&&null!=a.showLabels&&(p.labelsVisible=a.showLabels),a.hasOwnProperty("url")&&(p.url=a.url),a.hasOwnProperty("layerDefinition")&&null!=a.layerDefinition&&(await r.applyToEsriApiLayer(a.layerDefinition,p),null!=a.layerDefinition.capabilities&&(p.editingEnabled=a.layerDefinition.capabilities.toLowerCase().split(",").includes("editing")))}y.esriGeoJSONLayerDefaults={labelsVisible:!0,legendEnabled:!0,popupEnabled:!0,visible:!0,minScale:0,maxScale:0,screenSizePerspective:!0},y.toEsriApiLayer=async function(e){i("layerJson",e).isNotMissing(),i("layerJson.layerType",e.layerType).satisfies((e=>!e||"GeoJSON"===e),n);const r=new((await import("@arcgis/core/layers/GeoJSONLayer")).default);return function(e){e.layerDefinition=e.layerDefinition||{},e.layerDefinition.drawingInfo=e.layerDefinition.drawingInfo||{},e.layerDefinition.drawingInfo.renderer=e.layerDefinition.drawingInfo.renderer||a}(e),await f(e,r),r},y.applyToEsriApiLayer=f,y.fromEsriApiGeoJSONLayer=function(e){i("layer",e).isNotMissing();const a={...p(e,y.esriGeoJSONLayerDefaults),...t(e),layerType:"GeoJSON",layerDefinition:r.fromEsriApiLayer(e,y.esriGeoJSONLayerDefaults),url:e.url??void 0};return e.popupTemplate&&(a.popupInfo=s.fromEsriApiPopupTemplate(e.popupTemplate)),e.screenSizePerspectiveEnabled!==y.esriGeoJSONLayerDefaults.screenSizePerspective&&(a.screenSizePerspective=e.screenSizePerspectiveEnabled),e.labelsVisible!==y.esriGeoJSONLayerDefaults.labelsVisible&&(a.showLabels=e.labelsVisible),a}}(GeoJSONLayer||(GeoJSONLayer={}));