// 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/_base/array","dijit/_WidgetBase","jimu/dijit/SimpleTable","../LayerOrderUtil"],function(f,c,g,h,k){return f([g],{baseClass:"jimu-widget-setting-gp-layer-order",postCreate:function(){this.inherited(arguments);this.table=new h({fields:[{name:"layerName",title:this.nls.layer,type:"text"},{name:"actions",title:this.nls.action,type:"actions",actions:["up","down"]}]});this.table.placeAt(this.domNode)},startup:function(){this.inherited(arguments);this.table.startup()},
setConfig:function(a){this.config=a;this.table.clear();this.layerOrderUtil=new k(this.config,null);0===this.config.layerOrder.length&&(this.config.layerOrder=this.layerOrderUtil.getCandidateParamNames(!1));0<this.config.layerOrder.length&&this._initLayerTable()},acceptValue:function(){if(this.config){var a,d;if(0<this.config.layerOrder.length){var b=c.map(this.table.getData(),function(l){return l.layerName});if(0<b.length){var e=a=0;for(d=this.config.layerOrder.length;e<d;e++){var m=this.config.layerOrder[e];
-1!==c.indexOf(b,m)&&(this.config.layerOrder[e]=b[a],a+=1)}}}}},_initLayerTable:function(){var a=[],d=this.layerOrderUtil.getCandidateParamNames(!0);a=c.filter(this.config.layerOrder,function(b){return-1!==c.indexOf(d,b)},this);c.forEach(a,function(b){this.table.addRow({layerName:b})},this)}})});