// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/declare dojo/on dojo/_base/lang ./_SeriesStyleItem dojo/Evented dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin".split(" "),function(e,f,g,h,k,l,m,n){return e([l,m,n,k],{baseClass:"infographic-series-styles",templateString:'\x3cdiv\x3e\x3cdiv class\x3d"field-style-list"data-dojo-attach-point\x3d"fieldStyleList"\x3e\x3c/div\x3e\x3c/div\x3e',constructor:function(){this.inherited(arguments);this.cacheDijits=[]},_clear:function(){this.cacheDijits&&Array.isArray(this.cacheDijits)&&
(this.cacheDijits.forEach(function(a){a.dijit.destroy()}),this.cacheDijits=[])},_removeDuplicateConfig:function(a){if(!a||2>a.length)return a;var b={};return a.filter(function(d){d=d.name;return b[d]?!1:(b[d]=1,!0)})},_classificationConfig:function(a){a=this._removeDuplicateConfig(a);var b={destroyedDijits:[],updatedConfig:[],newAddedConfig:[]},d=[],p=this.cacheDijits.map(function(c){return c.name});a.forEach(function(c){0>p.indexOf(c.name)?b.newAddedConfig.push(c):(d.push(c.name),b.updatedConfig.push(c))});
b.destroyedDijits=this.cacheDijits.filter(function(c){return 0>d.indexOf(c.name)});return b},updateConfig:function(a){a=this._classificationConfig(a);a.newAddedConfig.forEach(function(b){this._addNewItem(b)}.bind(this));a.updatedConfig.forEach(function(b){this._updateItem(b)}.bind(this));a.destroyedDijits.forEach(function(b){this._destroyItem(b)}.bind(this));this._setOpacityDisplay()},setConfig:function(a){a&&Array.isArray(a)&&(this._clear(),a.forEach(function(b){this._addNewItem(b)}.bind(this)),
this._setOpacityDisplay())},_destroyItem:function(a){this.cacheDijits=this.cacheDijits.filter(function(b){return b.name!==a.name});a.dijit&&"undefined"!==typeof a.dijit.destroy&&a.dijit.destroy()},_updateItem:function(a){this.cacheDijits.forEach(function(b){b.name===a.name&&b.dijit.setConfig(a)})},_addNewItem:function(a){var b=null;b=new h({textVisible:!0,colorSingleMode:!0,opacityVisible:!1});b.setConfig(a);b.placeAt(this.fieldStyleList,"last");this.own(f(b,"change",g.hitch(this,function(){this._onChange()})));
this.cacheDijits.push({name:a.name,dijit:b})},_onChange:function(){var a=this.getConfig();this.emit("change",a)},setOpacityDisplay:function(a){this.showOpacity=a;this._setOpacityDisplay()},_setOpacityDisplay:function(){this.cacheDijits.forEach(function(a){a.dijit.setOpacityDisplay(this.showOpacity)}.bind(this))},getConfig:function(){return!this.cacheDijits||0>=this.cacheDijits.length?[]:this.cacheDijits.map(function(a){return a.dijit.getConfig()})}})});