/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/Error","../../core/lang","../../core/maybe","../../core/object","../../core/accessorSupport/extensions/serializableProperty/writer","../../layers/support/layerUtils"],(function(e,t,n,i,r,o,l){"use strict";const a=new Set(["bing-maps","imagery","imagery-tile","map-image","open-street-map","tile","unknown","unsupported","vector-tile","web-tile","wms","wmts"]),s=new Set(["csv","feature","geo-rss","geojson","group","imagery","imagery-tile","kml","map-image","map-notes","ogc-feature","route","tile","unknown","unsupported","vector-tile","web-tile","wfs","wms","wmts"]);function u(e){a.delete(e),s.delete(e)}function c(e){a.add(e),s.add(e)}function d(e){return"basemap"===e.layerContainerType?a:"operational-layers"===e.layerContainerType?s:null}function p(e,t){if(t.restrictedWebMapWriting){const n=d(t);return!i.isSome(n)||n.has(e.type)&&!l.isFeatureCollectionLayer(e)}return!0}function m(e,t){if(l.isFeatureCollectionLayer(e)){const n=r.getDeepValue("featureCollection.layers",t),i=n&&n[0]&&n[0].layerDefinition;i&&y(e,i)}else if("stream"===e.type){y(e,t.layerDefinition=t.layerDefinition||{})}else"group"!==e.type&&y(e,t)}function y(e,t){"maxScale"in e&&(t.maxScale=o.numberToJSON(e.maxScale)),"minScale"in e&&(t.minScale=o.numberToJSON(e.minScale))}function f(e,t){if(m(e,t),"blendMode"in e&&(t.blendMode=e.blendMode,"normal"===t.blendMode&&delete t.blendMode),t.opacity=o.numberToJSON(e.opacity),t.title=e.title||"Layer",t.visibility=e.visible,"legendEnabled"in e&&"wmts"!==e.type)if(l.isFeatureCollectionLayer(e)){const n=t.featureCollection;n&&(n.showLegend=e.legendEnabled)}else t.showLegend=e.legendEnabled}function g(e,r,o){if(!("write"in e)||!e.write)return o&&o.messages&&o.messages.push(new t("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted`,{layer:e})),null;if(p(e,o)){const t={};return e.write(t,o)?t:null}return i.isSome(r)&&f(e,r=n.clone(r)),r}e.disableRestrictedWriting=c,e.enableRestrictedWriting=u,e.getLayerJSON=g,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
