//>>built
define("dijit/form/_FormSelectWidget","dojo/_base/array dojo/_base/Deferred dojo/aspect dojo/data/util/sorter dojo/_base/declare dojo/dom dojo/dom-class dojo/_base/kernel dojo/_base/lang dojo/query dojo/when dojo/store/util/QueryResults ./_FormValueWidget".split(" "),function(e,p,q,t,u,v,w,r,f,x,y,z,A){return u("dijit.form._FormSelectWidget",A,{multiple:!1,options:null,store:null,_setStoreAttr:function(a){this._created&&this._deprecatedSetStore(a)},query:null,_setQueryAttr:function(a){this._created&&
this._deprecatedSetStore(this.store,this.selectedValue,{query:a})},queryOptions:null,_setQueryOptionsAttr:function(a){this._created&&this._deprecatedSetStore(this.store,this.selectedValue,{queryOptions:a})},labelAttr:"",onFetch:null,sortByLabel:!0,loadChildrenOnOpen:!1,onLoadDeferred:null,getOptions:function(a){var c=this.options||[];if(null==a)return c;if(f.isArrayLike(a))return e.map(a,function(b){return this.getOptions(b)},this);f.isString(a)&&(a={value:a});f.isObject(a)&&(e.some(c,function(b,
k){for(var d in a)if(!(d in b)||b[d]!=a[d])return!1;a=k;return!0})||(a=-1));return 0<=a&&a<c.length?c[a]:null},addOption:function(a){e.forEach(f.isArrayLike(a)?a:[a],function(c){c&&f.isObject(c)&&this.options.push(c)},this);this._loadChildren()},removeOption:function(a){a=this.getOptions(f.isArrayLike(a)?a:[a]);e.forEach(a,function(c){c&&(this.options=e.filter(this.options,function(b){return b.value!==c.value||b.label!==c.label}),this._removeOptionItem(c))},this);this._loadChildren()},updateOption:function(a){e.forEach(f.isArrayLike(a)?
a:[a],function(c){var b=this.getOptions({value:c.value}),k;if(b)for(k in c)b[k]=c[k]},this);this._loadChildren()},setStore:function(a,c,b){r.deprecated(this.declaredClass+"::setStore(store, selectedValue, fetchArgs) is deprecated. Use set('query', fetchArgs.query), set('queryOptions', fetchArgs.queryOptions), set('store', store), or set('value', selectedValue) instead.","","2.0");this._deprecatedSetStore(a,c,b)},_deprecatedSetStore:function(a,c,b){var k=this.store;b=b||{};if(k!==a){for(var d;d=this._notifyConnections.pop();)d.remove();
a.get||(f.mixin(a,{_oldAPI:!0,get:function(h){var l=new p;this.fetchItemByIdentity({identity:h,onItem:function(g){l.resolve(g)},onError:function(g){l.reject(g)}});return l.promise},query:function(h,l){var g=new p(function(){m.abort&&m.abort()});g.total=new p;var m=this.fetch(f.mixin({query:h,onBegin:function(n){g.total.resolve(n)},onComplete:function(n){g.resolve(n)},onError:function(n){g.reject(n)}},l));return new z(g)}}),a.getFeatures()["dojo.data.api.Notification"]&&(this._notifyConnections=[q.after(a,
"onNew",f.hitch(this,"_onNewItem"),!0),q.after(a,"onDelete",f.hitch(this,"_onDeleteItem"),!0),q.after(a,"onSet",f.hitch(this,"_onSetItem"),!0)]));this._set("store",a)}this.options&&this.options.length&&this.removeOption(this.options);this._queryRes&&this._queryRes.close&&this._queryRes.close();this._observeHandle&&this._observeHandle.remove&&(this._observeHandle.remove(),this._observeHandle=null);b.query&&this._set("query",b.query);b.queryOptions&&this._set("queryOptions",b.queryOptions);a&&a.query&&
(this._loadingStore=!0,this.onLoadDeferred=new p,this._queryRes=a.query(this.query,this.queryOptions),y(this._queryRes,f.hitch(this,function(h){if(this.sortByLabel&&!b.sort&&h.length)if(a.getValue)h.sort(t.createSortFunction([{attribute:a.getLabelAttributes(h[0])[0]}],a));else{var l=this.labelAttr;h.sort(function(g,m){return g[l]>m[l]?1:m[l]>g[l]?-1:0})}b.onFetch&&(h=b.onFetch.call(this,h,b));e.forEach(h,function(g){this._addOptionForItem(g)},this);this._queryRes.observe&&(this._observeHandle=this._queryRes.observe(f.hitch(this,
function(g,m,n){m==n?this._onSetItem(g):(-1!=m&&this._onDeleteItem(g),-1!=n&&this._onNewItem(g))}),!0));this._loadingStore=!1;this.set("value","_pendingValue"in this?this._pendingValue:c);delete this._pendingValue;this.loadChildrenOnOpen?this._pseudoLoadChildren(h):this._loadChildren();this.onLoadDeferred.resolve(!0);this.onSetStore()}),f.hitch(this,function(h){this.onLoadDeferred.reject(h)})));return k},_setValueAttr:function(a,c){this._onChangeActive||(c=null);if(this._loadingStore)this._pendingValue=
a;else if(null!=a){a=f.isArrayLike(a)?e.map(a,function(d){return f.isObject(d)?d:{value:d}}):f.isObject(a)?[a]:[{value:a}];a=e.filter(this.getOptions(a),function(d){return d&&d.value});var b=this.getOptions()||[];this.multiple||a[0]&&a[0].value||!b.length||(a[0]=b[0]);e.forEach(b,function(d){d.selected=e.some(a,function(h){return h.value===d.value})});b=e.map(a,function(d){return d.value});if("undefined"!=typeof b&&"undefined"!=typeof b[0]){var k=e.map(a,function(d){return d.label});this._setDisplay(this.multiple?
k:k[0]);this.inherited(arguments,[this.multiple?b:b[0],c]);this._updateSelection()}}},_getDisplayedValueAttr:function(){var a=e.map([].concat(this.get("selectedOptions")),function(c){return c&&"label"in c?c.label:c?c.value:null},this);return this.multiple?a:a[0]},_setDisplayedValueAttr:function(a){this.set("value",this.getOptions("string"==typeof a?{label:a}:a))},_loadChildren:function(){this._loadingStore||(e.forEach(this._getChildren(),function(a){a.destroyRecursive()}),e.forEach(this.options,this._addOptionItem,
this),this._updateSelection())},_updateSelection:function(){this.focusedChild=null;this._set("value",this._getValueFromOpts());var a=[].concat(this.value);if(a&&a[0]){var c=this;e.forEach(this._getChildren(),function(b){var k=e.some(a,function(d){return b.option&&d===b.option.value});k&&!c.multiple&&(c.focusedChild=b);w.toggle(b.domNode,this.baseClass.replace(/\s+|$/g,"SelectedOption "),k);b.domNode.setAttribute("aria-selected",k?"true":"false")},this)}},_getValueFromOpts:function(){var a=this.getOptions()||
[];if(!this.multiple&&a.length){var c=e.filter(a,function(b){return b.selected})[0];if(c&&c.value)return c.value;a[0].selected=!0;return a[0].value}return this.multiple?e.map(e.filter(a,function(b){return b.selected}),function(b){return b.value})||[]:""},_onNewItem:function(a,c){c&&c.parent||this._addOptionForItem(a)},_onDeleteItem:function(a){this.removeOption({value:this.store.getIdentity(a)})},_onSetItem:function(a){this.updateOption(this._getOptionObjForItem(a))},_getOptionObjForItem:function(a){var c=
this.store,b=this.labelAttr&&this.labelAttr in a?a[this.labelAttr]:c.getLabel(a);return{value:b?c.getIdentity(a):null,label:b,item:a}},_addOptionForItem:function(a){var c=this.store;c.isItemLoaded&&!c.isItemLoaded(a)?c.loadItem({item:a,onItem:function(b){this._addOptionForItem(b)},scope:this}):(a=this._getOptionObjForItem(a),this.addOption(a))},constructor:function(a){this._oValue=(a||{}).value||null;this._notifyConnections=[]},buildRendering:function(){this.inherited(arguments);v.setSelectable(this.focusNode,
!1)},_fillContent:function(){this.options||(this.options=this.srcNodeRef?x("\x3e *",this.srcNodeRef).map(function(a){return"separator"===a.getAttribute("type")?{value:"",label:"",selected:!1,disabled:!1}:{value:a.getAttribute("data-"+r._scopeName+"-value")||a.getAttribute("value"),label:String(a.innerHTML),selected:a.getAttribute("selected")||!1,disabled:a.getAttribute("disabled")||!1}},this):[]);this.value?this.multiple&&"string"==typeof this.value&&this._set("value",this.value.split(",")):this._set("value",
this._getValueFromOpts())},postCreate:function(){this.inherited(arguments);q.after(this,"onChange",f.hitch(this,"_updateSelection"));var a=this.store;a&&(a.getIdentity||a.getFeatures()["dojo.data.api.Identity"])&&(this.store=null,this._deprecatedSetStore(a,this._oValue,{query:this.query,queryOptions:this.queryOptions}));this._storeInitialized=!0},startup:function(){this._loadChildren();this.inherited(arguments)},destroy:function(){for(var a;a=this._notifyConnections.pop();)a.remove();this._queryRes&&
this._queryRes.close&&this._queryRes.close();this._observeHandle&&this._observeHandle.remove&&(this._observeHandle.remove(),this._observeHandle=null);this.inherited(arguments)},_addOptionItem:function(){},_removeOptionItem:function(){},_setDisplay:function(){},_getChildren:function(){return[]},_getSelectedOptionsAttr:function(){return this.getOptions({selected:!0})},_pseudoLoadChildren:function(){},onSetStore:function(){}})});