//>>built
define("dojox/store/transaction",["dojo/store/Memory","dojo/store/Cache","dojo/when","dojo/aspect","dojo/_base/lang"],function(x,y,p,z,A){var v,w={},B=1;return function(h){function q(a){return function m(b,e){var d=this;if(l){var g=f[a](b,e);p(g,null,function(n){d.errorHandler(n)&&(l=!1,e.error=n,m.call(d,b,e),l=!0)});return g}var r="remove"===a?b:d.getIdentity(b);void 0!==r&&(g=k.get(r));return p(g,function(n){return p(t.add({objectId:r,method:a,target:b,previous:n,options:e,storeId:u}),function(){return b})})}}
h=h||{};var f=h.masterStore,k=h.cachingStore,u=f.id||f.storeName||f.name||(f.id=B++);u&&(w[u]=f);var t=h.transactionLogStore||v||(v=new x),l=!0;z.before(f,"notify",function(a,c){a?k.put(a):k.remove(c)});return new y(A.delegate(f,{put:q("put"),add:q("add"),remove:q("remove"),errorHandler:function(a){return!0},commit:function(){l=!0;var a=this;return t.query({}).map(function(c){var b=c.method,e=w[c.storeId],m=c.target;try{var d=e[b](m,c.options)}catch(g){d=a.errorHandler(g);if(!0===d)return g;!1===
d&&("add"===b?k.remove(c.objectId):k.put(m),e.notify&&e.notify("add"===b?null:c.previous,"remove"===b?void 0:c.objectId));d=g}t.remove(c.id);return d})},transaction:function(){l=!1;var a=this;return{commit:function(){return a.commit()}}}}),k,h)}});