/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/JSONSupport","../../core/lang","../../core/accessorSupport/decorators/property","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/enumeration","../../core/accessorSupport/decorators/reader","../../core/accessorSupport/decorators/subclass","../../core/accessorSupport/decorators/writer"],(function(e,t,r,n,o,s,a,i,u,c){"use strict";var p;const l=new Set(["raster","raster2","dem","fillraster"]),f=new Set(["rasters"]),m=e=>e&&e.rasterFunction?_.fromJSON(e):e,y=e=>e&&e instanceof _?e.toJSON():e,d=e=>(null==e?void 0:e.functionName)&&!e.declaredClass,F=e=>d(e)?new _(e):e,w=e=>{if(null==e)return null;e=n.clone(e);const t={};for(const r of Object.keys(e))l.has(r.toLowerCase())?t[r]=m(e[r]):f.has(r.toLowerCase())&&Array.isArray(e[r])?t[r]=e[r].map(m):t[r]=e[r];return t};let _=p=function(t){function r(e){var r;return(r=t.call(this,e)||this).functionName=null,r.outputPixelType="unknown",r.variableName=null,r.rasterFunctionDefinition=null,r}e._inheritsLoose(r,t);var o=r.prototype;return o.readFunctionArguments=function(e){return w(e)},o.writeFunctionArguments=function(e,t,r){const n={};for(const o of Object.keys(e))l.has(o.toLowerCase())?n[o]=y(e[o]):f.has(o.toLowerCase())&&Array.isArray(e[o])?n[o]=e[o].map(y):n[o]=y(e[o]);t[r]=n},o.readFunctionName=function(e,t){const r=t.rasterFunctionInfos,n=t.name;return n||(r&&r.length&&"None"!==r[0].name?r[0].name:t.rasterFunctionDefinition?t.rasterFunctionDefinition.name:t.rasterFunction)},o.clone=function(){return new p({functionName:this.functionName,functionArguments:n.clone(this.functionArguments),outputPixelType:this.outputPixelType,variableName:this.variableName,rasterFunctionDefinition:n.clone(this.rasterFunctionDefinition)})},e._createClass(r,[{key:"functionArguments",set:function(e){if(e){const t=Object.keys(e);if(t.some((t=>l.has(t.toLowerCase())&&d(e[t])))||t.some((t=>f.has(t.toLowerCase())&&Array.isArray(e[t])&&e[t].some((e=>d(e)))))){e=n.clone(e);for(const r of t)l.has(r.toLowerCase())?e[r]=F(e[r]):f.has(r.toLowerCase())&&Array.isArray(e[r])&&(e[r]=e[r].map((e=>F(e))))}}this._set("functionArguments",e)}}]),r}(r.JSONSupport);t.__decorate([o.property({json:{type:Object,name:"rasterFunctionArguments"}})],_.prototype,"functionArguments",null),t.__decorate([i.reader("functionArguments")],_.prototype,"readFunctionArguments",null),t.__decorate([c.writer("functionArguments")],_.prototype,"writeFunctionArguments",null),t.__decorate([o.property({json:{type:String,write:{target:"rasterFunction"}}})],_.prototype,"functionName",void 0),t.__decorate([i.reader("functionName",["rasterFunction","rasterFunctionInfos","rasterFunctionDefinition"])],_.prototype,"readFunctionName",null),t.__decorate([a.enumeration({C128:"c128",C64:"c64",F32:"f32",F64:"f64",S16:"s16",S32:"s32",S8:"s8",U1:"u1",U16:"u16",U2:"u2",U32:"u32",U4:"u4",U8:"u8",UNKNOWN:"unknown"},{ignoreUnknown:!1}),o.property({json:{default:"unknown"}})],_.prototype,"outputPixelType",void 0),t.__decorate([o.property({type:String,json:{read:!0,write:!0}})],_.prototype,"variableName",void 0),t.__decorate([o.property({type:Object,json:{name:"rasterFunctionDefinition"}})],_.prototype,"rasterFunctionDefinition",void 0),_=p=t.__decorate([u.subclass("esri.layers.support.RasterFunction")],_);return _}));
