//>>built
define("dojox/form/_SelectStackMixin",["dojo/_base/lang","dojo/_base/array","dijit/_base/manager","dojo/_base/connect","dojo/_base/declare"],function(h,g,l,k,p){return p("dojox.form._SelectStackMixin",null,{stackId:"",stackPrefix:"",_paneIdFromOption:function(a){return(this.stackPrefix||"")+a},_optionValFromPane:function(a){var b=this.stackPrefix;return b&&0===a.indexOf(b)?a.substring(b.length):a},_togglePane:function(a,b){if(void 0==a._shown||a._shown!=b){var d=g.filter(a.getDescendants(),"return item.name;");
if(b){var e=a._savedStates||{};g.forEach(d,function(f){var c=e[f.id];void 0==c&&(c=!1);f.set("disabled",c)});delete a._savedStates}else e={},g.forEach(d,function(f){e[f.id]=f.disabled;f.set("disabled",!0)}),a._savedStates=e;a._shown=b}},_connectTitle:function(a,b){var d=h.hitch(this,function(e){this.updateOption({value:b,label:e})});a._setTitleAttr?this.connect(a,"_setTitleAttr",d):this.connect(a,"attr",function(e,f){"title"==e&&1<arguments.length&&d(f)})},onAddChild:function(a,b){if(!this._panes[a.id]){this._panes[a.id]=
a;var d=this._optionValFromPane(a.id);this.addOption({value:d,label:a.title});this._connectTitle(a,d)}a.onShow&&a.onHide&&void 0!=a._shown||(a.onShow=h.hitch(this,"_togglePane",a,!0),a.onHide=h.hitch(this,"_togglePane",a,!1),a.onHide())},_setValueAttr:function(a){"_savedValue"in this||this.inherited(arguments)},attr:function(a,b){"value"==a&&2==arguments.length&&"_savedValue"in this&&(this._savedValue=b);return this.inherited(arguments)},onRemoveChild:function(a){this._panes[a.id]&&(delete this._panes[a.id],
this.removeOption(this._optionValFromPane(a.id)))},onSelectChild:function(a){this._setValueAttr(this._optionValFromPane(a.id))},onStartup:function(a){var b=a.selected;this.addOption(g.filter(g.map(a.children,function(c){var m=this._optionValFromPane(c.id);this._connectTitle(c,m);var n=null;this._panes[c.id]||(this._panes[c.id]=c,n={value:m,label:c.title});c.onShow&&c.onHide&&void 0!=c._shown||(c.onShow=h.hitch(this,"_togglePane",c,!0),c.onHide=h.hitch(this,"_togglePane",c,!1),c.onHide());"_savedValue"in
this&&m===this._savedValue&&(b=c);return n},this),function(c){return c}));var d=this,e=function(){delete d._savedValue;d.onSelectChild(b);b._shown||d._togglePane(b,!0)};if(b!==a.selected){a=l.byId(this.stackId);var f=this.connect(a,"_showChild",function(c){this.disconnect(f);e()})}else e()},postMixInProperties:function(){this._savedValue=this.value;this.inherited(arguments);this.connect(this,"onChange","_handleSelfOnChange")},postCreate:function(){this.inherited(arguments);this._panes={};this._subscriptions=
[k.subscribe(this.stackId+"-startup",this,"onStartup"),k.subscribe(this.stackId+"-addChild",this,"onAddChild"),k.subscribe(this.stackId+"-removeChild",this,"onRemoveChild"),k.subscribe(this.stackId+"-selectChild",this,"onSelectChild")];var a=l.byId(this.stackId);if(a&&a._started)this.onStartup({children:a.getChildren(),selected:a.selectedChildWidget})},destroy:function(){g.forEach(this._subscriptions,k.unsubscribe);delete this._panes;this.inherited("destroy",arguments)},_handleSelfOnChange:function(a){if(a=
this._panes[this._paneIdFromOption(a)]){var b=l.byId(this.stackId);a==b.selectedChildWidget?b._transition(a):b.selectChild(a)}}})});