/*
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","../../Color","../../core/maybe","../../core/accessorSupport/decorators/aliasOf","../../core/arrayUtils","../../core/has","../../core/accessorSupport/decorators/cast","../../core/accessorSupport/decorators/property","../../core/accessorSupport/decorators/subclass","../../renderers/support/ClassBreakInfo","./SmartMappingSliderBase","./ClassedSizeSlider/ClassedSizeSliderViewModel","./support/utils","../support/widgetUtils","../support/decorators/messageBundle","../support/jsxFactory"],(function(e,r,s,t,i,a,o,l,n,c,d,p,m,u,h,b,g){"use strict";var k;const f={base:"esri-classed-size-slider",rampElement:"esri-classed-size-slider__ramp",sliderContainer:"esri-classed-size-slider__slider-container",histogramContainer:"esri-classed-size-slider__histogram-container",track:"esri-classed-size-slider--interactive-track",esriWidget:"esri-widget",esriWidgetPanel:"esri-widget--panel",widgetIcon:"esri-icon-edit",disabled:"esri-disabled"},w={trackFillColor:new s([149,149,149]),trackBackgroundColor:new s([224,224,224])};let y=k=function(r){function s(e,s){var t;return(t=r.call(this,e,s)||this)._rampNode=null,t.breaks=null,t.label=void 0,t.messages=null,t.style={...w},t.viewModel=new m,t}e._inheritsLoose(s,r);var i=s.prototype;return i.castStyle=function(e){return{...w,...e}},s.fromRendererResult=function(e,r){const{renderer:{classBreakInfos:s}}=e,t=s.map((e=>{const r=e.symbol;let s;switch(r.type){case"simple-line":s=r.width;break;case"simple-marker":s=r.size;break;case"picture-marker":s=r.height}return{min:e.minValue,max:e.maxValue,size:s}}));return new k({breaks:t,histogramConfig:{bins:r?r.bins:[]}})},i.updateClassBreakInfos=function(e){const r=this.breaks;if(r.length===e.length)return e.map(((e,s)=>{const t=e.symbol;switch(t.type){case"simple-line":t.width=r[s].size;break;case"simple-marker":t.size=r[s].size;break;case"picture-marker":{const e=r[s].size,i=t.width,a=t.height;t.height=e,t.width=e/a*i;break}}return new d({minValue:r[s].min,maxValue:r[s].max,symbol:t})}));console.error(`Number of input breakInfos must match number of slider breaks: ${r.length}`)},i.updateFromRendererResult=function(e,r){const{renderer:{classBreakInfos:s}}=e,t=s.map((e=>{const r=e.symbol;let s;switch(r.type){case"simple-line":s=r.width;break;case"simple-marker":s=r.size;break;case"picture-marker":s=r.height}return{min:e.minValue,max:e.maxValue,size:s}}));this.set({breaks:t}),null!=r&&r.bins&&(this.histogramConfig.bins=r.bins)},i.render=function(){const{state:e,label:r,visibleElements:s}=this,t="disabled"===e,i=this.classes(f.base,f.esriWidget,f.esriWidgetPanel,{[f.disabled]:t,[f.track]:s.interactiveTrack});return g.tsx("div",{"aria-label":r,class:i},t?null:this.renderContent(this.renderRamp(),f.sliderContainer,f.histogramContainer))},i.renderRamp=function(){const{style:{trackBackgroundColor:e}}=this;return g.tsx("div",{afterCreate:h.storeNode,bind:this,class:f.rampElement,"data-node-ref":"_rampNode"},g.tsx("svg",{xmlns:"http://www.w3.org/2000/svg"},g.tsx("rect",{x:"0",y:"0",fill:u.getFillFromColor(e),height:"100%",width:"100%"}),this.renderPath()))},i.renderPath=function(){if(!this._rampNode)return;const{offsetHeight:e=0,offsetWidth:r=0}=this._rampNode;if(t.isNone(e)||t.isNone(r))return;const{breaks:s,viewModel:{max:i,min:a},style:{trackFillColor:o}}=this,l=i-a,n=r/s.length,c=s.map((r=>e-Math.round((r.min-a)/l*e)+1)).reverse(),d=s[0].size>s[s.length-1].size||!1;let p=d?n:r,m=`M${p} 0 `;return c.forEach(((e,s)=>{const t=n*(s+1);m+=`L${p} ${e} `,p=d?n+t:r-t,m+=`L${p} ${e} `})),m+=`L0 ${e} L0 ${e} L0 0 Z`,g.tsx("path",{d:m,fill:u.getFillFromColor(o)})},s}(p.SmartMappingSliderBase);r.__decorate([i.aliasOf("viewModel.breaks")],y.prototype,"breaks",void 0),r.__decorate([n.property({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],y.prototype,"label",void 0),r.__decorate([n.property(),b.messageBundle("esri/widgets/smartMapping/ClassedSizeSlider/t9n/ClassedSizeSlider")],y.prototype,"messages",void 0),r.__decorate([n.property()],y.prototype,"style",void 0),r.__decorate([l.cast("style")],y.prototype,"castStyle",null),r.__decorate([n.property()],y.prototype,"viewModel",void 0),y=k=r.__decorate([c.subclass("esri.widgets.smartMapping.ClassedSizeSlider")],y);return y}));
