//>>built
define("dojox/data/RailsStore",["dojo","dojox","dojox/data/JsonRestStore"],function(c,h){c.declare("dojox.data.RailsStore",h.data.JsonRestStore,{constructor:function(){},preamble:function(a){if("string"==typeof a.target&&!a.service){var f=a.target.replace(/\/$/g,"");a.service=h.rpc.Rest(this.target,!0,null,function(a,b){var b=b||{},i=f,g,e;c.isObject(a)?(e="",g="?"+c.objectToQuery(a)):b.queryStr&&-1!=b.queryStr.indexOf("?")?(e=b.queryStr.replace(/\?.*/,""),g=b.queryStr.replace(/[^?]*\?/g,"?")):c.isString(b.query)&&
-1!=b.query.indexOf("?")?(e=b.query.replace(/\?.*/,""),g=b.query.replace(/[^?]*\?/g,"?")):(e=a?a.toString():"",g="");-1!=e.indexOf("=")&&(g=e,e="");var j=h.rpc._sync;h.rpc._sync=!1;return{url:e?i+"/"+e+".json"+g:i+".json"+g,handleAs:"json",contentType:"application/json",sync:j,headers:{Accept:"application/json,application/javascript",Range:b&&(0<=b.start||0<=b.count)?"items="+(b.start||"0")+"-"+(b.count&&b.count+(b.start||0)-1||""):void 0}}})}},fetch:function(a){function f(b){if(null==a.queryStr){if(null==
a.queryStr)a.queryStr="";if(c.isObject(a.query))a.queryStr="?"+c.objectToQuery(a.query);else if(c.isString(a.query))a.queryStr=a.query}a.queryStr=a.queryStr+(-1==a.queryStr.indexOf("?")?"?":"&")+c.objectToQuery(b)}a=a||{};if(a.start||a.count){if((a.start||0)%a.count)throw Error("The start parameter must be a multiple of the count parameter");f({page:(a.start||0)/a.count+1,per_page:a.count})}if(a.sort){var d={sortBy:[],sortDir:[]};c.forEach(a.sort,function(a){d.sortBy.push(a.attribute);d.sortDir.push(a.descending?
"DESC":"ASC")});f(d);delete a.sort}return this.inherited(arguments)},_processResults:function(a,f){var d;if("undefined"==typeof this.rootAttribute&&a[0])if(a[0][this.idAttribute])this.rootAttribute=!1;else for(d in a[0])if(a[0][d][this.idAttribute])this.rootAttribute=d;d=this.rootAttribute?c.map(a,function(a){return a[this.rootAttribute]},this):a;var b=a.length;return{totalCount:f.fullLength||(f.request.count==b?(f.request.start||0)+2*b:b),items:d}}});return h.data.RailsStore});