//>>built
define("dojo/request/xhr",["../errors/RequestError","./watch","./handlers","./util","../has"],function(l,s,m,h,e){function t(a,b){var c=a.xhr;a.status=a.xhr.status;a.text=c.responseText;if("xml"===a.options.handleAs)a.data=c.responseXML;if(!b)try{m(a)}catch(d){b=d}b?this.reject(b):h.checkStatus(c.status)?this.resolve(a):(b=new l("Unable to load "+a.url+" status: "+c.status,a),this.reject(b))}function u(a){return this.xhr.getResponseHeader(a)}function i(a,b,c){var d=h.parseArgs(a,h.deepCreate(v,b),
e("native-formdata")&&b&&b.data&&b.data instanceof FormData),a=d.url,b=d.options,n,f=h.deferred(d,o,p,r,t,function(){n&&n()}),g=d.xhr=i._create();if(!g)return f.cancel(new l("XHR was not created")),c?f:f.promise;d.getHeader=u;q&&(n=q(g,f,d));var m=b.data,w=!b.sync,x=b.method;try{g.open(x,a,w,b.user||void 0,b.password||void 0);if(b.withCredentials)g.withCredentials=b.withCredentials;var j=b.headers,a="application/x-www-form-urlencoded";if(j)for(var k in j)"content-type"===k.toLowerCase()?a=j[k]:j[k]&&
g.setRequestHeader(k,j[k]);a&&!1!==a&&g.setRequestHeader("Content-Type",a);(!j||!("X-Requested-With"in j))&&g.setRequestHeader("X-Requested-With","XMLHttpRequest");h.notify&&h.notify.emit("send",d,f.promise.cancel);g.send(m)}catch(y){f.reject(y)}s(f);g=null;return c?f:f.promise}e.add("native-xhr",function(){return"undefined"!==typeof XMLHttpRequest});e.add("dojo-force-activex-xhr",function(){return e("activex")&&!document.addEventListener&&"file:"===window.location.protocol});e.add("native-xhr2",
function(){if(e("native-xhr")){var a=new XMLHttpRequest;return"undefined"!==typeof a.addEventListener&&("undefined"===typeof opera||"undefined"!==typeof a.upload)}});e.add("native-formdata",function(){return"function"===typeof FormData});var p,r,q,o;e("native-xhr2")?(p=function(){return!this.isFulfilled()},o=function(a,b){b.xhr.abort()},q=function(a,b,c){function d(){b.handleResponse(c)}function e(a){a=new l("Unable to load "+c.url+" status: "+a.target.status,c);b.handleResponse(c,a)}function f(a){if(a.lengthComputable)c.loaded=
a.loaded,c.total=a.total,b.progress(c)}a.addEventListener("load",d,!1);a.addEventListener("error",e,!1);a.addEventListener("progress",f,!1);return function(){a.removeEventListener("load",d,!1);a.removeEventListener("error",e,!1);a.removeEventListener("progress",f,!1);a=null}}):(p=function(a){return a.xhr.readyState},r=function(a){return 4===a.xhr.readyState},o=function(a,b){var c=b.xhr,d=typeof c.abort;("function"===d||"object"===d||"unknown"===d)&&c.abort()});var v={data:null,query:null,sync:!1,
method:"GET"};i._create=function(){throw Error("XMLHTTP not available");};if(e("native-xhr")&&!e("dojo-force-activex-xhr"))i._create=function(){return new XMLHttpRequest};else if(e("activex"))try{new ActiveXObject("Msxml2.XMLHTTP"),i._create=function(){return new ActiveXObject("Msxml2.XMLHTTP")}}catch(z){try{new ActiveXObject("Microsoft.XMLHTTP"),i._create=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}catch(A){}}h.addCommonMethods(i);return i});