//>>built
define("dojox/rpc/Rest",["dojo","dojox"],function(h,f){function k(c,d,a,f){c.addCallback(function(d){c.ioArgs.xhr&&a&&(a=c.ioArgs.xhr.getResponseHeader("Content-Range"),c.fullLength=a&&(a=a.match(/\/(.*)/))&&parseInt(a[1]));return d});return c}h.getObject("rpc.Rest",!0,f);f.rpc&&f.rpc.transportRegistry&&f.rpc.transportRegistry.register("REST",function(c){return"REST"==c},{getExecutor:function(c,d,a){return new f.rpc.Rest(d.name,(d.contentType||a._smd.contentType||"").match(/json|javascript/),null,
function(c,e){var b=a._getRequest(d,[c]);b.url=b.target+(b.data?"?"+b.data:"");e&&(0<=e.start||0<=e.count)&&(b.headers=b.headers||{},b.headers.Range="items\x3d"+(e.start||"0")+"-"+("count"in e&&Infinity!=e.count?e.count+(e.start||0)-1:""));return b})}});var g;g=f.rpc.Rest=function(c,d,a,l){function e(a){b[a]=function(c,d){return g._change(a,b,c,d)}}var b;b=function(a,c){return g._get(b,a,c)};b.isJson=d;b._schema=a;b.cache={serialize:d?(f.json&&f.json.ref||h).toJson:function(a){return a}};b._getRequest=
l||function(a,b){h.isObject(a)&&(a=(a=h.objectToQuery(a))?"?"+a:"");if(b&&b.sort&&!b.queryStr){a+=(a?"\x26":"?")+"sort(";for(var e=0;e<b.sort.length;e++){var g=b.sort[e];a+=(0<e?",":"")+(g.descending?"-":"+")+encodeURIComponent(g.attribute)}a+=")"}e={url:c+(null==a?"":a),handleAs:d?"json":"text",contentType:d?"application/json":"text/plain",sync:f.rpc._sync,headers:{Accept:d?"application/json,application/javascript":"*/*"}};b&&(0<=b.start||0<=b.count)&&(e.headers.Range="items\x3d"+(b.start||"0")+
"-"+("count"in b&&Infinity!=b.count?b.count+(b.start||0)-1:""));f.rpc._sync=!1;return e};e("put");e("post");e("delete");b.servicePath=c;return b};g._index={};g._timeStamps={};g._change=function(c,d,a,f){a=d._getRequest(a);a[c+"Data"]=f;return k(h.xhr(c.toUpperCase(),a,!0),d)};g._get=function(c,d,a){a=a||{};return k(h.xhrGet(c._getRequest(d,a)),c,0<=a.start||0<=a.count,d)};return g});