import{isGroupLayer as i}from"../utilities/_layers.js";import{checkArg as r}from"../utilities/checkArg.js";import{LayerBase as e}from"./_LayerBase.js";import{ERR_LAYER_TYPE_MISMATCH as s,applyLayerBaseToEsriApiLayer as a,applyOperationalLayerToEsriApiLayer as y,fromEsriApiLayerToLayerBase as o,fromEsriApiLayerToOperationalLayer as t}from"./_layerHelper.js";export var GroupLayer;!function(l){async function p(o,t,l){r("layerJson",o).isNotMissing();const p=o.layerType||o.type;r("layerJson.layerType",p).satisfies((i=>!i||"GroupLayer"===i),s),r("layer",t).isNotMissing().satisfies(i,s),a(o,t),y(o,t),o.hasOwnProperty("visibilityMode")&&null!=o.visibilityMode&&(t.visibilityMode=o.visibilityMode),o.hasOwnProperty("layers")&&null!=o.layers&&await e.applyToEsriApiLayers(t.layers,o.layers,l)}l.toEsriApiLayer=async function(i,e){r("layerJson",i).isNotMissing();const a=i.layerType||i.type;r("layerJson.layerType",a).satisfies((i=>!i||"GroupLayer"===i),s);const y=new((await import("@arcgis/core/layers/GroupLayer")).default);return await p(i,y,e),y},l.applyToEsriApiLayer=p,l.fromEsriApiGroupLayer=function(i){r("groupLayer",i).isNotMissing();const s={...o(i),...t(i),layerType:"GroupLayer",layers:[]};return i.visibilityMode&&(s.visibilityMode=i.visibilityMode),i.layers.forEach((i=>{s.layers.push(e.fromEsriApiLayer(i))})),s}}(GroupLayer||(GroupLayer={}));