// 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/DataAggregation/js/UI/templates/PageContainer.html":'\x3cdiv style\x3d"height: 100%;" class\x3d"no-select"\x3e\r\n  \x3cdiv class\x3d"control-node" data-dojo-attach-point\x3d"controlNode"\x3e\r\n    \x3ctable data-dojo-attach-point\x3d"controlTable" class\x3d"control-table" cellpading\x3d"0"\x3e\r\n      \x3ctbody\x3e\r\n        \x3ctr data-dojo-attach-point\x3d"controlTr" style\x3d"line-height:20px;"\x3e\r\n          \x3c!--BACK--\x3e\r\n          \x3ctd nowrap class\x3d"page-item-td-left" data-dojo-attach-point\x3d"backTd"\r\n            data-dojo-attach-event\x3d"onclick:_prevView , onkeydown:_prevView" \x3e\r\n            \x3cdiv class\x3d"float-left bg-img bg-back-img margin-right-5" data-dojo-attach-point\x3d"backImage" tabindex\x3d"0"\r\n            role\x3d"button" aria-label\x3d"${nls.back}"\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"page-item-div main-text" title\x3d"${nls.back}" label\x3d"${nls.back}"\x3e${nls.back}\x3c/div\x3e\r\n          \x3c/td\x3e\r\n          \x3c!--HOME--\x3e\r\n          \x3ctd nowrap align\x3d"center" class\x3d"page-item-td-center " data-dojo-attach-point\x3d"homeTd"\r\n            data-dojo-attach-event\x3d"onclick:_homeView , onkeydown:_homeView"\x3e\r\n            \x3cdiv\x3e\r\n              \x3cdiv class\x3d"bg-home bg-home-img" data-dojo-attach-point\x3d"homeImage" tabindex\x3d"0"\r\n                role\x3d"button" aria-label\x3d"${nls.startPage.homeButtonLabel}"\x3e\r\n              \x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"page-item-div"\x3e\x3c/div\x3e\r\n          \x3c/td\x3e\r\n          \x3c!--NEXT--\x3e\r\n          \x3ctd nowrap class\x3d"page-item-td-right" data-dojo-attach-point\x3d"nextTd"\r\n            data-dojo-attach-event\x3d"onclick:_nextView , onkeydown:_nextView"\x3e\r\n            \x3cdiv class\x3d"float-right bg-img bg-next-img margin-left-5" data-dojo-attach-point\x3d"nextImage" tabindex\x3d"0"\r\n              role\x3d"button" aria-label\x3d"${nls.next}"\x3e\x3c/div\x3e\r\n            \x3cdiv class\x3d"page-item-div main-text" title\x3d"${nls.next}" label\x3d"${nls.next}"\x3e${nls.next}\x3c/div\x3e\r\n          \x3c/td\x3e\r\n        \x3c/tr\x3e\r\n      \x3c/tbody\x3e\r\n    \x3c/table\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv class\x3d"container-node" data-dojo-attach-point\x3d"containerNode"\x3e\x3c/div\x3e\r\n  \x3cdiv class\x3d"tab-shelter" data-dojo-attach-point\x3d"shelter"\x3e\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/html dojo/topic dojo/Evented dojo/query dojo/keys dojo/dom-class dojo/dom-attr dojo/Deferred dojo/_base/xhr dijit/_WidgetBase dijit/_TemplatedMixin dojo/text!./templates/PageContainer.html jimu/dijit/ViewStack".split(" "),function(u,f,n,k,p,v,w,l,m,q,r,x,y,z,A,B){return u([y,z,v],{templateString:A,selected:"",tabs:null,average:!1,nls:null,baseClass:"jimu-tab3",declaredClass:"PageContainer",views:[],_currentIndex:-1,_homeIndex:0,
theme:"",styleColor:"",altHomeIndex:0,nextDisabled:!1,_backLabels:[],constructor:function(a){f.mixin(this,a);this.theme=this.appConfig.theme.name;this._darkThemes=["DartTheme","DashboardTheme"];this.own(p.subscribe("appConfigChanged",f.hitch(this,this._onAppConfigChanged)));this.own(p.subscribe("builder/styleChanged",f.hitch(this,this._onBuilderStyleChanged)))},postCreate:function(){this.inherited(arguments);this.displayControllerOnStart||this.toggleController(!0);this._validateIsDark(this.appConfig)},
startup:function(){this.inherited(arguments);this._started=!0;this._initSelf();this.selected?this.selectView(this.selected):0<this.views.length&&this.selectView(this._homeIndex);this._backLabels=[]},_onBuilderStyleChanged:function(a){this.setStyleColor(a.styleColor)},_onAppConfigChanged:function(a,b,c){this.appConfig=a?a:this.appConfig;switch(b){case "themeChange":this._validateIsDark(a);this.emit("theme-change",a,b,c);break;case "layoutChange":this.emit("layout-change",a,b,c);break;case "styleChange":this._validateIsDark(a);
this.emit("style-change",a,b,c);break;case "widgetChange":this.emit("widget-change",a,b,c);break;case "mapChange":this.emit("map-change",a,b,c)}},_validateIsDark:function(a){this._setThemeAndColors(a).then(f.hitch(this,function(){this.updateImageNodes();this._updateViewTheme(this.theme);for(var b=0;b<this.views.length;b++){var c=this.views[b];c.theme=this.theme;c.updateImageNodes()}}))},_setThemeAndColors:function(a){var b=new r;a=a&&a.theme&&a.theme.name?a:this.appConfig;this.theme=a.theme.name;
this._getStyleColor(a.theme.styles[0]).then(f.hitch(this,function(c){this.style=c;this._darkThemes="light"===c.name&&"DashboardTheme"===this.theme?["DartTheme"]:["DartTheme","DashboardTheme"];this.isDarkTheme=-1<this._darkThemes.indexOf(this.theme);this.styleColor=c.styleColor;b.resolve(!0)}));return b},_getStyleColor:function(a){var b=new r,c=a?a:this.appConfig.theme.styles[0];x.get({url:"./themes/"+this.theme+"/manifest.json",handleAs:"json",load:f.hitch(this,function(d){d=d.styles;for(var e=0;e<
d.length;e++){var g=d[e];g.name===c&&b.resolve(g)}})});return b},selectView:function(a,b){!b&&0<a&&(b=this.getSelectedTitle(),(b=this.getViewByTitle(b))&&this._backLabels[this._backLabels.length-1]!==b.label&&a!==b.index&&(this._backLabels.push(b.label),this.backDisabled=!1));this.viewStack.switchView(a);this._updateDomNodes(a);this._currentIndex=a;this.emit("view-changed",a)},showShelter:function(){k.setStyle(this.shelter,"display","block")},hideShelter:function(){k.setStyle(this.shelter,"display",
"none")},_initSelf:function(){this.viewStack?this.viewStack._currentView=void 0:this.viewStack=new B(null,this.containerNode);this._initViews()},_initViews:function(){n.forEach(this.views,f.hitch(this,function(a){this.addView(a)}))},_prevView:function(a){a&&"keydown"===a.type&&a.keyCode!==l.ENTER&&a.keyCode!==l.SPACE||this._navView("back-view")},_homeView:function(a){a&&"keydown"===a.type&&a.keyCode!==l.ENTER&&a.keyCode!==l.SPACE||this._navView("home-view")},_nextView:function(a){a&&"keydown"===a.type&&
a.keyCode!==l.ENTER&&a.keyCode!==l.SPACE||this._navView("next-view")},_navView:function(a){var b=this.getSelectedTitle(),c=this.getViewByTitle(b),d="home-view"===a&&c.altHomeIndex?c.altHomeIndex:this._homeIndex,e,g=!1;if("back-view"===a&&0<this._backLabels.length){var t;for(e=this._backLabels.length-1;0<=e&&(!(t=this.getViewByTitle(this._backLabels[e]))||this._backLabels[e]===b);e--)this._backLabels.splice(e,1);e=t.index;g=!0}"next-view"===a&&"undefined"===typeof c&&0<this._backLabels.length&&(this._currentIndex=
(c=this.getViewByTitle(this._backLabels[this._backLabels.length-1]))&&c.index?c.index:this._currentIndex);"undefined"===typeof e&&(e="next-view"===a?c.altNextIndex:"back-view"===a?c.altBackIndex:void 0);if("undefined"!==typeof e&&"home-view"!==a)var h=this.getViewByIndex(e);else"next-view"===a?this._currentIndex<this.viewCount-1&&(h=this.getViewByIndex(this._currentIndex+1)):"back-view"===a?h=this._currentIndex-1<=this._homeIndex?this.getViewByIndex(this._homeIndex):this.getViewByIndex(this._currentIndex-
1):(d!==this._homeIndex&&this._backLabels&&0<this._backLabels.length&&(g=!0),h=this.getViewByIndex(d));h&&(b={currentView:c,navView:h},this.emit(a,b),c.validate?c.validate(a,b).then(f.hitch(this,function(C){C&&this._navigate(h.index,g,c.index,a,h.label)})):this._navigate(h.index,g,c.index,a,h.label))},_navigate:function(a,b,c,d,e){0<c&&"next-view"===d&&this._backLabels[this._backLabels.length-1]!==this.views[c].label&&(this._backLabels.push(this.views[c].label),this.backDisabled=!1);if(b){for(b=this._backLabels.length-
1;0<=b;b--)if(this._backLabels[b]===e){this._backLabels.splice(b,1);break}0===this._backLabels.length&&(this.backDisabled=!0)}this._currentIndex=a;this.selectView(a,!0);this.emit("nav-view",a)},getSelectedIndex:function(){return this._currentIndex},getSelectedTitle:function(){return this.viewStack.getSelectedLabel()},getViewByIndex:function(a){if(this.views.length>a)return this.views[a]},getViewByTitle:function(a){for(var b=0;b<this.views.length;b++){var c=this.views[b];if(c.label===a)return c}},
_updateControlImage:function(a,b){b?(k.addClass(a,"control-disbaled"),q.set(a,"tabindex","-1")):(k.removeClass(a,"control-disbaled"),q.set(a,"tabindex","0"))},_updateControl:function(a,b){b?k.addClass(a,"control-disbaled"):k.removeClass(a,"control-disbaled")},_updateViews:function(){this.viewCount=this.views.length;for(var a=0;a<this.views.length;a++){var b=this.views[a];b.setStyleColor(this.styleColor);"undefined"!==typeof b.index&&b.index!==a&&this.emit("view-index-change",{oldIndex:b.index,newIndex:a});
b.index=a}this.emit("views-updated",this)},addView:function(a){a.pageContainer=this;this._containsView(a.label)||this.views.push(a);this.viewStack.getViewByLabel(a.label)||this.viewStack.addView(a);this._updateViews();this.emit("view-added",a)},removeViewByTitle:function(a){a=this.getViewByTitle(a);this.removeViewByIndex(a.index)},removeView:function(a){this.removeViewByIndex(a.index)},removeViewByIndex:function(a){var b=this.getViewByIndex(a),c=b.label;this.viewStack.removeView(b);this.views.splice(a,
1);this._updateViews();this._backLabels=this._backLabels.filter(function(d){return d!==c});0===this._backLabels.length&&(this.backDisabled=!0);this._navView("next-view");this.emit("view-removed",b)},_clearViews:function(){n.forEach(this.views,f.hitch(this,function(a){this.viewStack.removeView(a)}));this.views=[];this._backLabels=[]},_containsView:function(a){for(var b=0;b<this.views.length;b++)if(this.views[b].label===a)return!0;return!1},setStyleColor:function(a){this.styleColor=a;n.forEach(this.views,
f.hitch(this,function(b){b.styleColor=a}))},updateImageNodes:function(){var a=this.isDarkTheme;this._updateImageNode(a,"bg-back-img","bg-back-img-white");this._updateImageNode(a,"bg-home-img","bg-home-img-white");this._updateImageNode(a,"bg-next-img","bg-next-img-white")},_updateDomNodes:function(a){var b=this.views[a],c=this._homeIndex,d=this.backDisabled?this.backDisabled:a===this._homeIndex?!0:!1;this._updateControl(this.backTd,d);this._updateControlImage(this.backImage,d);d=a===c?!0:!1;this._updateControl(this.homeTd,
d);this._updateControlImage(this.homeImage,d);b=b&&"undefined"!==typeof b.altNextIndex;a=this.nextDisabled?this.nextDisabled:a!==c||this.nextDisabled?b?!1:this.nextDisabled:!1;this._updateControl(this.nextTd,a);this._updateControlImage(this.nextImage,a)},_updateImageNode:function(a,b,c){var d=a?b:c,e=a?c:b;a=w("."+d,this.domNode);n.forEach(a,function(g){m.remove(g,d);m.add(g,e)})},_updateViewTheme:function(a){this.theme=a;n.forEach(this.views,f.hitch(this,function(b){b.theme=a}))},toggleController:function(a){this.controlTable&&
(a?m.contains(this.controlTable,"display-none")||m.add(this.controlTable,"display-none"):m.contains(this.controlTable,"display-none")&&m.remove(this.controlTable,"display-none"))},reset:function(){this._clearViews();this.views=[];this._currentIndex=-1;this._homeIndex=0;this.nextDisabled=!1;this.backDisabled=!0;this.selected="";this._validateIsDark(this.appConfig)}})});