// 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/lang dojo/_base/array dojo/_base/html dojo/on dojo/keys dojo/Evented dijit/_WidgetBase dijit/_TemplatedMixin ./ViewStack ../utils".split(" "),function(m,g,k,d,h,e,n,p,q,r,l){return m([p,q,n],{baseClass:"jimu-tab",declaredClass:"jimu.dijit.TabContainer",templateString:'\x3cdiv\x3e\x3cdiv class\x3d"control" data-dojo-attach-point\x3d"controlNode"\x3e\x3c/div\x3e\x3cdiv class\x3d"jimu-container" data-dojo-attach-point\x3d"containerNode"\x3e\x3c/div\x3e\x3c/div\x3e',
postCreate:function(){this.inherited(arguments);if(0!==this.tabs.length){this.controlNodes=[];this.viewStack=new r(null,this.containerNode);this.own(h(this.containerNode,"keydown",g.hitch(this,function(a){a.keyCode===e.ESCAPE&&(a.stopPropagation(),this._currentCtrlNode.focus())})));var b=1/this.tabs.length*100;this.isNested&&d.addClass(this.domNode,"nested");k.forEach(this.tabs,function(a){this._createTab(a,b)},this);this.own(h(this.controlNode,"keydown",g.hitch(this,function(a){var c=a.target,f;
a.keyCode===e.RIGHT_ARROW?f=c.nextElementSibling?c.nextElementSibling:this.controlNodes[0]:a.keyCode===e.LEFT_ARROW?f=c.previousElementSibling?c.previousElementSibling:this.controlNodes[this.controlNodes.length-1]:a.keyCode===e.HOME?f=this.controlNodes[0]:a.keyCode===e.END&&(f=this.controlNodes[this.controlNodes.length-1]);f&&(c=f,f.focus())})))}},startup:function(){this.selected?this.selectTab(this.selected):0<this.tabs.length&&this.selectTab(this.tabs[0].title);l.setVerticalCenter(this.domNode)},
_createTab:function(b,a){a=d.create("div",{innerHTML:l.sanitizeHTML(b.title),"class":"tab jimu-vcenter-text",style:{width:this.isNested?"auto":a+"%"},label:b.title},this.controlNode);this.viewStack.viewType=b.content.domNode?"dijit":"dom";b.content.label=b.title;this.viewStack.addView(b.content);this.own(h(a,"click",g.hitch(this,function(c){this.onSelect(b.title,c)})));this.own(h(a,"keydown",g.hitch(this,function(c){if(c.keyCode===e.ENTER||c.keyCode===e.SPACE)this.onSelect(b.title,c)})));a.label=
b.title;this.controlNodes.push(a)},onSelect:function(b,a){d.hasClass(a.target,"jimu-state-selected")||this.selectTab(b,a)},selectTab:function(b){this._selectControl(b);this.viewStack.switchView(b);this.emit("tabChanged",b)},_selectControl:function(b){k.forEach(this.controlNodes,function(a){d.removeClass(a,"jimu-state-selected");d.setAttr(a,"tabindex","-1");a.label===b&&(this._currentCtrlNode=a,d.addClass(a,"jimu-state-selected"),d.setAttr(a,"tabindex","0"))},this)}})});