//>>built
define("dojox/data/KeyValueStore","dojo/_base/declare dojo/_base/lang dojo/_base/xhr dojo/_base/kernel dojo/data/util/simpleFetch dojo/data/util/filter".split(" "),function(n,q,v,w,x,r){n=n("dojox.data.KeyValueStore",null,{constructor:function(a){a.url&&(this.url=a.url);this._keyValueString=a.data;this._keyValueVar=a.dataVar;this._keyAttribute="key";this._valueAttribute="value";this._storeProp="_keyValueStore";this._features={"dojo.data.api.Read":!0,"dojo.data.api.Identity":!0};this._loadInProgress=
!1;this._queuedFetches=[];a&&"urlPreventCache"in a&&(this.urlPreventCache=a.urlPreventCache?!0:!1)},url:"",data:"",urlPreventCache:!1,_assertIsItem:function(a){if(!this.isItem(a))throw Error("dojox.data.KeyValueStore: a function was passed an item argument that was not an item");},_assertIsAttribute:function(a,b){if(!q.isString(b))throw Error("dojox.data.KeyValueStore: a function was passed an attribute argument that was not an attribute object nor an attribute name string");},getValue:function(a,
b,c){this._assertIsItem(a);this._assertIsAttribute(a,b);a=b==this._keyAttribute?a[this._keyAttribute]:a[this._valueAttribute];void 0===a&&(a=c);return a},getValues:function(a,b){var c=this.getValue(a,b);return c?[c]:[]},getAttributes:function(a){return[this._keyAttribute,this._valueAttribute,a[this._keyAttribute]]},hasAttribute:function(a,b){this._assertIsItem(a);this._assertIsAttribute(a,b);return b==this._keyAttribute||b==this._valueAttribute||b==a[this._keyAttribute]},containsValue:function(a,
b,c){var d=void 0;"string"===typeof c&&(d=r.patternToRegExp(c,!1));return this._containsValue(a,b,c,d)},_containsValue:function(a,b,c,d){a=this.getValues(a,b);for(b=0;b<a.length;++b){var f=a[b];if("string"===typeof f&&d)return null!==f.match(d);if(c===f)return!0}return!1},isItem:function(a){return a&&a[this._storeProp]===this?!0:!1},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(a){},getFeatures:function(){return this._features},close:function(a){},getLabel:function(a){return a[this._keyAttribute]},
getLabelAttributes:function(a){return[this._keyAttribute]},_fetchItems:function(a,b,c){var d=this,f=function(e,h){var k=null;if(e.query){k=[];var l=e.queryOptions?e.queryOptions.ignoreCase:!1,m={},g;for(g in e.query){var p=e.query[g];"string"===typeof p&&(m[g]=r.patternToRegExp(p,l))}for(l=0;l<h.length;++l){var t=!0,u=h[l];for(g in e.query)p=e.query[g],d._containsValue(u,g,p,m[g])||(t=!1);t&&k.push(u)}}else if(e.identity)for(g in k=[],h){if(m=h[g],m[d._keyAttribute]==e.identity){k.push(m);break}}else 0<
h.length&&(k=h.slice(0,h.length));b(k,e)};if(this._loadFinished)f(a,this._arrayOfAllItems);else if(""!==this.url)this._loadInProgress?this._queuedFetches.push({args:a,filter:f}):(this._loadInProgress=!0,c=v.get({url:d.url,handleAs:"json-comment-filtered",preventCache:this.urlPreventCache}),c.addCallback(function(e){d._processData(e);f(a,d._arrayOfAllItems);d._handleQueuedFetches()}),c.addErrback(function(e){d._loadInProgress=!1;throw e;}));else if(this._keyValueString)this._processData(eval(this._keyValueString)),
this._keyValueString=null,f(a,this._arrayOfAllItems);else if(this._keyValueVar)this._processData(this._keyValueVar),this._keyValueVar=null,f(a,this._arrayOfAllItems);else throw Error("dojox.data.KeyValueStore: No source data was provided as either URL, String, or Javascript variable data input.");},_handleQueuedFetches:function(){if(0<this._queuedFetches.length){for(var a=0;a<this._queuedFetches.length;a++){var b=this._queuedFetches[a],c=b.filter,d=b.args;c?c(d,this._arrayOfAllItems):this.fetchItemByIdentity(b.args)}this._queuedFetches=
[]}},_processData:function(a){this._arrayOfAllItems=[];for(var b=0;b<a.length;b++)this._arrayOfAllItems.push(this._createItem(a[b]));this._loadFinished=!0;this._loadInProgress=!1},_createItem:function(a){var b={};b[this._storeProp]=this;for(var c in a){b[this._keyAttribute]=c;b[this._valueAttribute]=a[c];break}return b},getIdentity:function(a){return this.isItem(a)?a[this._keyAttribute]:null},getIdentityAttributes:function(a){return[this._keyAttribute]},fetchItemByIdentity:function(a){a.oldOnItem=
a.onItem;a.onItem=null;a.onComplete=this._finishFetchItemByIdentity;this.fetch(a)},_finishFetchItemByIdentity:function(a,b){var c=b.scope||w.global;a.length?b.oldOnItem.call(c,a[0]):b.oldOnItem.call(c,null)}});q.extend(n,x);return n});