//>>built
define("dojo/data/ObjectStore","../_base/lang,../Evented,../_base/declare,../_base/Deferred,../_base/array,../_base/connect,../regexp".split(","),function(h,o,p,j,k,q,r){function s(a){return"*"==a?".*":"?"==a?".":a}return p("dojo.data.ObjectStore",[o],{objectStore:null,constructor:function(a){this._dirtyObjects=[];if(a.labelAttribute)a.labelProperty=a.labelAttribute;h.mixin(this,a)},labelProperty:"label",getValue:function(a,c,b){return"function"===typeof a.get?a.get(c):c in a?a[c]:b},getValues:function(a,
c){var b=this.getValue(a,c);return b instanceof Array?b:void 0===b?[]:[b]},getAttributes:function(a){var c=[],b;for(b in a)a.hasOwnProperty(b)&&!("_"==b.charAt(0)&&"_"==b.charAt(1))&&c.push(b);return c},hasAttribute:function(a,c){return c in a},containsValue:function(a,c,b){return-1<k.indexOf(this.getValues(a,c),b)},isItem:function(a){return"object"==typeof a&&a&&!(a instanceof Date)},isItemLoaded:function(a){return a&&"function"!==typeof a.load},loadItem:function(a){var c;"function"===typeof a.item.load?
j.when(a.item.load(),function(b){c=b;var d=b instanceof Error?a.onError:a.onItem;d&&d.call(a.scope,b)}):a.onItem&&a.onItem.call(a.scope,a.item);return c},close:function(a){return a&&a.abort&&a.abort()},fetch:function(a){function c(b){a.onError&&a.onError.call(d,b,a)}var a=h.delegate(a,a&&a.queryOptions),b=this,d=a.scope||b,e=a.query;if("object"==typeof e){var e=h.delegate(e),f;for(f in e){var i=e[f];if("string"==typeof i)e[f]=RegExp("^"+r.escapeString(i,"*?\\").replace(/\\.|\*|\?/g,s)+"$",a.ignoreCase?
"mi":"m"),e[f].toString=function(a){return function(){return a}}(i)}}var g=this.objectStore.query(e,a);j.when(g.total,function(b){j.when(g,function(c){a.onBegin&&a.onBegin.call(d,b||c.length,a);if(a.onItem)for(var e=0;e<c.length;e++)a.onItem.call(d,c[e],a);a.onComplete&&a.onComplete.call(d,a.onItem?null:c,a);return c},c)},c);a.abort=function(){g.cancel&&g.cancel()};if(g.observe)this.observing&&this.observing.cancel(),this.observing=g.observe(function(a,c,d){if(-1==k.indexOf(b._dirtyObjects,a))if(-1==
c)b.onNew(a);else if(-1==d)b.onDelete(a);else for(var e in a)if(e!=b.objectStore.idProperty)b.onSet(a,e,null,a[e])},!0);this.onFetch(g);a.store=this;return a},getFeatures:function(){return{"dojo.data.api.Read":!!this.objectStore.get,"dojo.data.api.Identity":!0,"dojo.data.api.Write":!!this.objectStore.put,"dojo.data.api.Notification":!0}},getLabel:function(a){if(this.isItem(a))return this.getValue(a,this.labelProperty)},getLabelAttributes:function(){return[this.labelProperty]},getIdentity:function(a){return this.objectStore.getIdentity?
this.objectStore.getIdentity(a):a[this.objectStore.idProperty||"id"]},getIdentityAttributes:function(){return[this.objectStore.idProperty]},fetchItemByIdentity:function(a){var c;j.when(this.objectStore.get(a.identity),function(b){c=b;a.onItem.call(a.scope,b)},function(b){a.onError.call(a.scope,b)});return c},newItem:function(a,c){if(c){var b=this.getValue(c.parent,c.attribute,[]),b=b.concat([a]);a.__parent=b;this.setValue(c.parent,c.attribute,b)}this._dirtyObjects.push({object:a,save:!0});this.onNew(a);
return a},deleteItem:function(a){this.changing(a,!0);this.onDelete(a)},setValue:function(a,c,b){var d=a[c];this.changing(a);a[c]=b;this.onSet(a,c,d,b)},setValues:function(a,c,b){if(!h.isArray(b))throw Error("setValues expects to be passed an Array object as its value");this.setValue(a,c,b)},unsetAttribute:function(a,c){this.changing(a);var b=a[c];delete a[c];this.onSet(a,c,b,void 0)},changing:function(a,c){a.__isDirty=!0;for(var b=0;b<this._dirtyObjects.length;b++){var d=this._dirtyObjects[b];if(a==
d.object){if(c&&(d.object=!1,!this._saveNotNeeded))d.save=!0;return}}d=a instanceof Array?[]:{};for(b in a)a.hasOwnProperty(b)&&(d[b]=a[b]);this._dirtyObjects.push({object:!c&&a,old:d,save:!this._saveNotNeeded})},save:function(a){var a=a||{},c,b=[],d=[],e=this,f=this._dirtyObjects,i=f.length;try{q.connect(a,"onError",function(){if(!1!==a.revertOnError){var b=f;f=d;e.revert();e._dirtyObjects=b}else e._dirtyObjects=f.concat(d)});if(this.objectStore.transaction)var g=this.objectStore.transaction();for(var h=
0;h<f.length;h++){var l=f[h],m=l.object,n=l.old;delete m.__isDirty;m?c=this.objectStore.put(m,{overwrite:!!n}):"undefined"!=typeof n&&(c=this.objectStore.remove(this.getIdentity(n)));d.push(l);f.splice(h--,1);j.when(c,function(){--i||a.onComplete&&a.onComplete.call(a.scope,b)},function(b){i=-1;a.onError.call(a.scope,b)})}g&&g.commit()}catch(k){a.onError.call(a.scope,value)}},revert:function(){for(var a=this._dirtyObjects,c=a.length;0<c;){c--;var b=a[c],d=b.object,b=b.old;if(d&&b){for(var e in b)b.hasOwnProperty(e)&&
d[e]!==b[e]&&(this.onSet(d,e,d[e],b[e]),d[e]=b[e]);for(e in d)b.hasOwnProperty(e)||(this.onSet(d,e,d[e]),delete d[e])}else if(b)this.onNew(b);else this.onDelete(d);delete (d||b).__isDirty;a.splice(c,1)}},isDirty:function(a){return!a?!!this._dirtyObjects.length:a.__isDirty},onSet:function(){},onNew:function(){},onDelete:function(){},onFetch:function(){}})});