//>>built
define("dojox/store/priority",["dojo/_base/lang","dojo/Deferred","dojo/when"],function(q,n,l){function m(){for(var a=h.length-1;a>=d;a--){var b=h[a],c=b&&b[b.length-1];if(c){b.pop();d++;try{c.executor(function(){d--;m()})}catch(g){c.def.reject(g),m()}}}}function r(){var a=new n;return{promise:{total:{then:function(b,c){return a.then(function(b){return b.results.total}).then(b,c)}},forEach:function(b,c){return a.then(function(a){return a.results.forEach(b,c)})},map:function(b,c){return a.then(function(a){return a.results.map(b,
c)})},filter:function(b,c){return a.then(function(a){return a.results.filter(b,c)})},then:function(b,c){return a.then(function(a){return l(a.results,b,c)})}},resolve:a.resolve,reject:a.reject}}var h=[],d=0;return function(a,b){b=b||{};var c=q.delegate(a);["add","put","query","remove","get"].forEach(function(g){var k=a[g];k&&(c[g]=function(c,e){e=e||{};var f,d;if(e.immediate)return k.call(a,c,e);e.immediate=!0;"query"===g?(d=function(b){var d=k.call(a,c,e);f.resolve({results:d});l(d,b,b)},f=r()):(d=
function(b){l(k.call(a,c,e),function(a){f.resolve(a);b()},function(a){f.reject(a);b()})},f=new n);var p=-1<e.priority?e.priority:-1<b.priority?b.priority:4;(h[p]||(h[p]=[])).push({executor:d,def:f});m();return f.promise})});return c}});