// 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
require({cache:{"url:widgets/BasemapGallery/setting/GroupSelector.html":'\x3cdiv\x3e\r\n  \x3cdiv class\x3d"select-tip"\x3e${nls.selectGroupTip}\x3c/div\x3e\r\n  \x3cdiv class\x3d"groups-section" data-dojo-attach-point\x3d"groupsSection"\x3e\r\n    \x3cselect class\x3d"groups-select" data-dojo-attach-point\x3d"groupsSelect"\r\n      data-dojo-attach-event\x3d"change:_onGroupsSelectChange"\x3e\r\n      \x3coption value\x3d"nodata"\x3e${nls.noneGroups}\x3c/option\x3e\r\n    \x3c/select\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"groupMapTableDiv"\x3e\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dojo/text!./GroupSelector.html dojo/_base/lang dojo/_base/array dojo/_base/html dojo/query dojo/on jimu/utils jimu/portalUrlUtils jimu/dijit/Search jimu/portalUtils ./MapTable ../utils dijit/form/Select".split(" "),function(l,m,n,p,q,b,r,g,y,t,u,v,z,w,x,k){return l([m,n,p],{templateString:q,baseClass:"basemap-group-selector",nls:null,type:"",multiple:!1,appConfig:null,map:null,spatialReference:null,_user:null,
_group:null,_webMapQueryString:"",_allGroupQuery:null,portal:null,postCreate:function(){this.inherited(arguments);this._webMapQueryString=" "+u.getItemQueryStringByTypes([this.type])+" ";this.portal=w.getPortal(this._getPortalUrl());this._allGroupQuery=this._getQuery();this.groupMapTable=new x({appConfig:this.appConfig,type:this.type,multiple:!0,folderUrl:this.folderUrl,portalUrl:this._getPortalUrl(),nls:this.nls,map:this.map,spatialReference:this.spatialReference});this.groupMapTable.placeAt(this.groupMapTableDiv);
this.own(t(this.groupMapTable,"selectionChange",b.hitch(this,this._checkBtnStatus)));this.portal.getUser().then(b.hitch(this,function(a){this._searchGroups(a)}))},postMixInProperties:function(){this.nls=b.mixin(this.nls,window.jimuNls.common,window.jimuNls.itemSelector)},_getQuery:function(a){return b.mixin({start:1,num:100,f:"json"},a||{})},_getPortalUrl:function(){return v.getStandardPortalUrl(window.portalUrl)},_onGroupSearch:function(){this._allGroupQuery.start=1;b.mixin(this._allGroupQuery,{sortField:"title",
sortOrder:"asc"});this.groupMapTable.search(this._allGroupQuery)},_searchGroups:function(a){this._resetGroupsSection();var d=a.getGroups(),e=this._getPortalUrl(),c,h;k.getBasemapGalleryGroup(e,'title:"ArcGIS Online Basemaps" AND owner:esri_en').then(b.hitch(this,function(f){c=f.id;this._createEsriDefaultOption(f.id);return c})).then(b.hitch(this,function(){return k.getBasemapGalleryGroup(e,this.portal.basemapGalleryGroupQuery)})).then(b.hitch(this,function(f){h=f.id;g.create("option",{value:f.id,
innerHTML:this.nls.defaultOrgGroup},this.groupsSelect)})).then(b.hitch(this,function(){this._createUserGroupsOption(d,[c,h]);this._onGroupsSelectChange()}),b.hitch(this,function(){this._createUserGroupsOption(d,[c,h]);this._onGroupsSelectChange()}))},_createEsriDefaultOption:function(a){g.create("option",{value:a,innerHTML:this.nls.defaultGroup},this.groupsSelect)},_createUserGroupsOption:function(a,d){if(0<a.length)for(var e=0;e<a.length;e++){var c=a[e];0>d.indexOf(c.id)&&g.create("option",{value:c.id,
innerHTML:c.title},this.groupsSelect)}},_resetGroupsSection:function(){g.empty(this.groupsSelect);this.groupMapTable.clear()},_onGroupsSelectChange:function(){var a=this.groupsSelect.value;var d=0<=a.indexOf(":")?a:"group:"+a;this.groupMapTable.clear();"nodata"!==a&&(this._getPortalUrl(),this._allGroupQuery=this._getQuery({q:d+" AND "+this._webMapQueryString}),this._onGroupSearch())},getSelectedBasemaps:function(){return r.map(this.groupMapTable.getSelectedMapItems(),function(a){return a.basemap})},
_checkBtnStatus:function(){0<this.getSelectedBasemaps().length?this.popup.enableButton(0):this.popup.disableButton(0)}})});