/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import{strict as t}from"../../core/jsonMap.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{clone as i}from"../../core/lang.js";import{property as r,cast as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{Integer as a}from"../../core/accessorSupport/ensureType.js";import l from"../../geometry/Point.js";import c from"./DimensionalDefinition.js";import p from"./RasterFunction.js";import{reader as d}from"../../core/accessorSupport/decorators/reader.js";import{writer as u}from"../../core/accessorSupport/decorators/writer.js";var m;const h=t()({MT_FIRST:"first",MT_LAST:"last",MT_MIN:"min",MT_MAX:"max",MT_MEAN:"mean",MT_BLEND:"blend",MT_SUM:"sum"}),w=t()({esriMosaicNone:"none",esriMosaicCenter:"center",esriMosaicNadir:"nadir",esriMosaicViewpoint:"viewpoint",esriMosaicAttribute:"attribute",esriMosaicLockRaster:"lock-raster",esriMosaicNorthwest:"northwest",esriMosaicSeamline:"seamline"});function M(e){let t;switch(e?e.toLowerCase().replace("esrimosaic",""):""){case"byattribute":case"attribute":t="esriMosaicAttribute";break;case"lockraster":t="esriMosaicLockRaster";break;case"center":t="esriMosaicCenter";break;case"northwest":t="esriMosaicNorthwest";break;case"nadir":t="esriMosaicNadir";break;case"viewpoint":t="esriMosaicViewpoint";break;case"seamline":t="esriMosaicSeamline";break;default:t="esriMosaicNone"}return w.fromJSON(t)}let y=m=class extends o{constructor(e){super(e),this.ascending=!0,this.itemRasterFunction=null,this.lockRasterIds=null,this.method="none",this.multidimensionalDefinition=null,this.objectIds=null,this.operation="first",this.sortField=null,this.sortValue=null,this.viewpoint=null,this.where=null}readAscending(e,t){return null!=t.ascending?t.ascending:null==t.sortAscending||t.sortAscending}readMethod(e,t){return M(t.mosaicMethod||t.defaultMosaicMethod)}writeMultidimensionalDefinition(e,t,o){null!=e&&(e=e.filter(({variableName:e,dimensionName:t})=>e&&"*"!==e||t)).length&&(t[o]=e.map(e=>e.toJSON()))}readOperation(e,t){const o=t.mosaicOperation,i=t.mosaicOperator?.toLowerCase(),r=o||(i?h.toJSON(i):null);return h.fromJSON(r)||"first"}castSortValue(e){return null==e||"string"==typeof e||"number"==typeof e?e:`${e}`}clone(){return new m({ascending:this.ascending,itemRasterFunction:i(this.itemRasterFunction),lockRasterIds:i(this.lockRasterIds),method:this.method,multidimensionalDefinition:i(this.multidimensionalDefinition),objectIds:i(this.objectIds),operation:this.operation,sortField:this.sortField,sortValue:this.sortValue,viewpoint:i(this.viewpoint),where:this.where})}};e([r({type:Boolean,json:{write:!0}})],y.prototype,"ascending",void 0),e([d("ascending",["ascending","sortAscending"])],y.prototype,"readAscending",null),e([r({type:p,json:{name:"itemRenderingRule",write:!0}})],y.prototype,"itemRasterFunction",void 0),e([r({type:[a],json:{write:{overridePolicy(){return{enabled:"lock-raster"===this.method}}}}})],y.prototype,"lockRasterIds",void 0),e([r({type:w.apiValues,json:{type:w.jsonValues,write:{target:"mosaicMethod",writer:w.write,isRequired:!0}}})],y.prototype,"method",void 0),e([d("method",["mosaicMethod","defaultMosaicMethod"])],y.prototype,"readMethod",null),e([r({type:[c],json:{write:!0}})],y.prototype,"multidimensionalDefinition",void 0),e([u("multidimensionalDefinition")],y.prototype,"writeMultidimensionalDefinition",null),e([r({type:[a],json:{name:"fids",write:!0}})],y.prototype,"objectIds",void 0),e([r({type:h.apiValues,json:{type:h.jsonValues,read:{reader:h.read},write:{target:"mosaicOperation",writer:h.write}}})],y.prototype,"operation",void 0),e([d("operation",["mosaicOperation","mosaicOperator"])],y.prototype,"readOperation",null),e([r({type:String,json:{write:{overridePolicy(){return{enabled:"attribute"===this.method}}}}})],y.prototype,"sortField",void 0),e([r({type:[String,Number],json:{write:{allowNull:!0,overridePolicy(){return{enabled:"attribute"===this.method,allowNull:!0}}}}})],y.prototype,"sortValue",void 0),e([s("sortValue")],y.prototype,"castSortValue",null),e([r({type:l,json:{write:!0}})],y.prototype,"viewpoint",void 0),e([r({type:String,json:{write:!0}})],y.prototype,"where",void 0),y=m=e([n("esri.layers.support.MosaicRule")],y);export{y as default};
