/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as o}from"tslib";import{clone as r}from"../../core/lang.js";import{property as t,subclass as e}from"../../core/accessorSupport/decorators.js";import s from"./AlgorithmicColorRamp.js";import p from"./ColorRamp.js";import{writer as i}from"../../core/accessorSupport/decorators/writer.js";import{reader as l}from"../../core/accessorSupport/decorators/reader.js";var a;let m=a=class extends p{constructor(o){super(o),this.colorRamps=null,this.type="multipart",this.weights=void 0}writeColorRamps(o,r,t,e){const s=o?.map(o=>o.toJSON(e)),{weights:p}=this;if(s&&p?.length&&s.length===p?.length){const o=100/p.reduce((o,r)=>o+r);let r=0;s.forEach((t,e)=>{t.start=r,r+=p[e]*o,t.stop=r})}r.colorRamps=s}readWeights(o,r){const t=r.colorRamps?.map(({start:o,stop:r})=>null==o||null==r?-1:r-o);if(!t?.some(o=>o<0))return t}clone(){return new a({colorRamps:r(this.colorRamps)})}};o([t({type:[s],json:{write:{isRequired:!0}}})],m.prototype,"colorRamps",void 0),o([i("colorRamps")],m.prototype,"writeColorRamps",null),o([t({type:["multipart"],json:{write:{isRequired:!0}}})],m.prototype,"type",void 0),o([t({type:[Number]})],m.prototype,"weights",void 0),o([l("weights",["colorRamps"])],m.prototype,"readWeights",null),m=a=o([e("esri.rest.support.MultipartColorRamp")],m);export{m as default};
