blob: c32ecaf8e4d7e7f3f23516c85c0d54999a0f6c7e [file] [log] [blame]
'use strict';(function(d){function I(a){"string"!==typeof a&&(a=String(a));if(/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(a))throw new g("Invalid character in header field name");return a.toLowerCase()}function V(a){"string"!==typeof a&&(a=String(a));var b;var c=0;for(b=a.length;c<b;c++){var e=a.charCodeAt(c);if(9!==e&&10!==e&&13!==e&&32!==e)break}for(b=a.length-1;b>c&&(e=a.charCodeAt(b),9===e||10===e||13===e||32===e);b--);a=a.substring(c,b+1);c=0;for(b=a.length;c<b;c++)if(e=a.charCodeAt(c),256<=e||0===e||
10===e||13===e)throw new g("Invalid character in header field value");return a}function da(a,b){throw new g("Immutable header cannot be modified");}function ea(a,b){return!1}function fa(a,b){a=a.toLowerCase();return-1<ha.indexOf(a)||a.startsWith("proxy-")||a.startsWith("sec-")?!0:!1}function ia(a,b){a=a.toLowerCase();return-1<ja.indexOf(a)||"content-type"===a&&(b=b.split(";")[0].toLowerCase(),-1<ka.indexOf(b))?!1:!0}function R(a,b){return-1<la.indexOf(a.toLowerCase())?!0:!1}function h(a){this[k]=
new O;void 0===this[z]&&(this[z]=ea);if(void 0!==a){if(null===a||"object"!==typeof a)throw new g("Constructing Headers with invalid parameters");a instanceof h?a.forEach(function(a,c){this.append(c,a)},this):J.isArray(a)?a.forEach(function(a){if(2!==a.length)throw new g("Constructing Headers with invalid parameters");this.append(a[0],a[1])},this):Object.getOwnPropertyNames(a).forEach(function(b){this.append(b,a[b])},this)}}function K(a,b){var c=ma(h.prototype);c[z]=b;h.call(c,a);return c}function S(a){if(a.bodyUsed)return t.reject(new g("Body was already read"));
if(null===a.body)return t.resolve(new y(0));if(na(a.body))return t.reject(new g("ReadableStream was already locked"));var b=a.body.getReader(),c=[],e=0;return b.read().then(function oa(a){if(a.done){if(0===c.length)a=new y(0);else if(1===c.length)a=new y(c[0].buffer);else{a=new y(e);for(var d=0,f=c.length,h=0;d<f;d++)a.set(c[d],h),h+=c[d].length}return a}return a.value instanceof y?(e+=a.value.length,c.push(a.value),b.read().then(oa)):t.reject(new g("Invalid stream data type"))})}function W(){this._initBody=
function(a){this[T]=!1;this[n]=null===a||void 0===a?null:a instanceof U?a:new U({start:function(b){if(a)if("string"===typeof a)b.enqueue(FetchInternal.encodeToUTF8(a));else if(X.prototype.isPrototypeOf(a))b.enqueue(new y(a.slice(0)));else if(pa(a))b.enqueue(new y(a.buffer.slice(0)));else if(a instanceof Blob)b.enqueue(new y(FetchInternal.blobToArrayBuffer(a)));else throw new g("Unsupported BodyInit type");b.close()}});this[q].get("content-type")||("string"===typeof a?this[q].set("content-type","text/plain;charset=UTF-8"):
a instanceof Blob&&""!==a.type&&this[q].set("content-type",a.type))};L(this,{body:{get:function(){return this[n]}},bodyUsed:{get:function(){return this[T]?!0:this[n]?!!qa(this[n]):!1}}});this.arrayBuffer=function(){return this[D]?t.reject(new w):S(this).then(function(a){return a.buffer})};this.text=function(){return this[D]?t.reject(new w):S(this).then(function(a){return FetchInternal.decodeFromUTF8(a)})};this.json=function(){return this[D]?t.reject(new w):this.text().then(JSON.parse)};return this}
function m(a){var b=this;this[E]=null;a instanceof m?(this[E]=a.onabort,this[M]=a[M],this[r]=a[r]):(this[M]={is_aborted:!1},this[r]={});L(this,{aborted:{get:function(){return b[M].is_aborted}},onabort:{get:function(){return b[E]},set:function(a){return b[E]=a}}})}function A(a,b){var c=void 0!==b&&null!==b&&void 0===b.cloneBody;b=b||{};var e=b.body||b.cloneBody,d=b.headers;if(a instanceof A)this[B]=a.url,this[F]=a.cache,this[G]=a.credentials,void 0===d&&(d=a.headers),this[H]=a.integrity,this[C]=a.method,
this[p]=a.mode,c&&"navigate"===this[p]&&(this[p]="same-origin"),this[N]=a.redirect,e||null===a.body||(e=a.body,a[T]=!0),this[u]="signal"in b&&null==b.signal?new m:"signal"in b?b.signal:a[u];else{this[B]=String(a);if(!FetchInternal.isUrlValid(this[B],!1))throw new g("Invalid request URL");this[p]="cors";this[G]="same-origin";this[u]=b.signal&&null!=b.signal?new m(b.signal):new m}if(void 0!==b.window&&null!==b.window)throw new g("Invalid request window");this[F]=b.cache||this[F]||"default";if(-1===
ra.indexOf(this[F]))throw new g("Invalid request cache mode");this[G]=b.credentials||this[G]||"same-origin";if(-1===sa.indexOf(this[G]))throw new g("Invalid request credentials");void 0!==b.integrity?this[H]=b.integrity:void 0===this[H]&&(this[H]="");a=(b.method||this[C]||"GET").toUpperCase();if(-1===ta.indexOf(a))throw new g("Invalid request method");this[C]=a;if(b.mode&&-1===ua.indexOf(b.mode))throw new g("Invalid request mode");this[p]=b.mode||this[p]||"no-cors";if("no-cors"===this[p]){if(-1===
va.indexOf(this[C]))throw new g("Invalid request method for no-cors");if(""!==this[H])throw new g("Request integrity data is not allowed with no-cors");}if("same-origin"!==this[p]&&"only-if-cached"===this[F])throw new g("Request mode must be same-origin for only-if-cached");this[N]=b.redirect||this[N]||"follow";if(-1===wa.indexOf(this[N]))throw new g("Invalid request redirect mode");this[q]="no-cors"===this[p]?K(d,ia):K(d,fa);if(("GET"===this[C]||"HEAD"===this[C])&&e)throw new g("Request body is not allowed for GET or HEAD");
this._initBody(e)}function xa(a,b){var c=K(void 0,b);a.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(a){var b=a.split(":");if(a=b.shift().trim())b=b.join(":").trim(),c.append(a,b)});return c}function v(a,b){b||(b={});this[P]="default";this[x]="status"in b?b.status:200;if(200>this[x]||599<this[x])throw new Y("Invalid response status");this[Z]=200<=this[x]&&300>this[x];if("statusText"in b){var c=b.statusText;for(var e=0,d=c.length,f;e<d;e++)if(f=c.charCodeAt(e),9!==f&&(32>f||255<f||127===
f))throw g("Invalid response status text");}else c="OK";this[Q]=c;this[q]=K(b.headers,R);this[B]=b.url||"";if(a&&-1<ya.indexOf(this[x]))throw new g("Response body is not allowed with a null body status");this[D]=b.is_aborted||!1;this._initBody(a)}function aa(){ba(this,"signal",{value:new m,writable:!1})}if(!d.fetch){var J=d.Array,X=d.ArrayBuffer,ma=d.Object.create,L=d.Object.defineProperties,ba=d.Object.defineProperty,f=d.Symbol,za=f.iterator,O=d.Map,Y=d.RangeError,g=d.TypeError,y=d.Uint8Array,t=
d.Promise,U=d.ReadableStream,ca=d.ReadableStreamTee,qa=d.IsReadableStreamDisturbed,na=d.IsReadableStreamLocked,n=f("body"),T=f("bodyUsed"),F=f("cache"),G=f("credentials"),z=f("guardCallback"),q=f("headers"),H=f("integrity"),k=f("map"),C=f("method"),p=f("mode"),Z=f("ok"),N=f("redirect"),x=f("status"),Q=f("statusText"),P=f("type"),B=f("url"),D=f("is_aborted"),u=f("signal"),E=f("onabort"),M=f("abort_hash"),r=f("listeners"),ha="accept-charset accept-encoding access-control-request-headers access-control-request-method connection content-length cookie cookie2 date dnt expect host keep-alive origin referer te trailer transfer-encoding upgrade via".split(" "),
la=["set-cookie","set-cookie2"],ja=["accept","accept-language","content-language"],ka=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],ra="default no-store reload no-cache force-cache only-if-cached".split(" "),sa=["omit","same-origin","include"],ta="DELETE GET HEAD OPTIONS POST PUT".split(" "),va=["GET","HEAD","POST"],ua=["same-origin","no-cors","cors"],wa=["follow","error","manual"],ya=[101,204,205,304],Aa=[301,302,303,307,308],Ba="[object Int8Array];[object Uint8Array];[object Uint8ClampedArray];[object Int16Array];[object Uint16Array];[object Int32Array];[object Uint32Array];[object Float32Array];[object Float64Array]".split(";"),
pa=X.isView||function(a){return a&&-1<Ba.indexOf(Object.prototype.toString.call(a))},w=function(){L(this,{message:{value:"Aborted",writable:!1},name:{value:"AbortError",writable:!1},code:{value:20,writable:!1}})};w.prototype.constructor=w;h.prototype.append=function(a,b){if(2!==arguments.length)throw g("Invalid parameters to append");a=I(a);b=V(b);this[z](a,b)||(this[k].has(a)?this[k].set(a,this[k].get(a)+", "+b):this[k].set(a,b))};h.prototype["delete"]=function(a){if(1!==arguments.length)throw g("Invalid parameters to delete");
this[z](a,"invalid")||this[k].delete(I(a))};h.prototype.get=function(a){if(1!==arguments.length)throw g("Invalid parameters to get");a=I(a);var b=this[k].get(a);return void 0!==b?b:null};h.prototype.has=function(a){if(1!==arguments.length)throw g("Invalid parameters to has");return this[k].has(I(a))};h.prototype.set=function(a,b){if(2!==arguments.length)throw g("Invalid parameters to set");a=I(a);b=V(b);this[z](a,b)||this[k].set(a,b)};h.prototype.forEach=function(a,b){var c=this;J.from(this[k].entries()).sort().forEach(function(e){a.call(b,
e[1],e[0],c)})};h.prototype.keys=function(){return(new O(J.from(this[k].entries()).sort())).keys()};h.prototype.values=function(){return(new O(J.from(this[k].entries()).sort())).values()};h.prototype.entries=function(){return(new O(J.from(this[k].entries()).sort())).entries()};h.prototype[za]=h.prototype.entries;m.prototype.constructor=m;m.prototype.dispatchEvent=function(a){"abort"===a.type&&(this[M].is_aborted=!0,"function"===typeof this[E]&&this[E].call(this,a));if(a.type in this[r]){for(var b=
this[r][a.type],c=b.length-1;0<=c;c--)b[c].call(this,a);return!a.defaultPrevented}};m.prototype.addEventListener=function(a,b){a in this[r]||(this[r][a]=[]);this[r][a].push(b)};m.prototype.removeEventListener=function(a,b){if(a in this[r]){a=this[r][type];for(var c=0,e=a.length;c<e;c++)if(a[c]===b){a.splice(c,1);break}}};m.prototype.clone=function(){return new m(this)};d.AbortSignal=m;A.prototype.clone=function(){var a=null;null!==this[n]&&(a=ca(this[n],!0),this[n]=a[0],a=a[1]);return new A(this,
{cloneBody:a,signal:this[u].clone()})};L(A.prototype,{cache:{get:function(){return this[F]}},credentials:{get:function(){return this[G]}},headers:{get:function(){return this[q]}},integrity:{get:function(){return this[H]}},method:{get:function(){return this[C]}},mode:{get:function(){return this[p]}},redirect:{get:function(){return this[N]}},url:{get:function(){return this[B]}},signal:{get:function(){return this[u]}}});W.call(A.prototype);W.call(v.prototype);v.prototype.clone=function(){var a=null;
null!==this[n]&&(a=ca(this[n],!0),this[n]=a[0],a=a[1]);return new v(a,{status:this[x],statusText:this[Q],headers:K(this[q],R),url:this[B],is_aborted:this[D]})};L(v.prototype,{headers:{get:function(){return this[q]}},ok:{get:function(){return this[Z]}},status:{get:function(){return this[x]}},statusText:{get:function(){return this[Q]}},type:{get:function(){return this[P]}},url:{get:function(){return this[B]}}});v.error=function(){var a=new v(null);a[q][z]=da;a[P]="error";a[x]=0;a[Q]="";return a};v.redirect=
function(a,b){if(!FetchInternal.isUrlValid(a,!0))throw new g("Invalid URL for response redirect");void 0===b&&(b=302);if(-1===Aa.indexOf(b))throw new Y("Invalid status code for response redirect");return new v(null,{status:b,headers:{location:a}})};d.Headers=h;d.Request=A;d.Response=v;d.fetch=function(a,b){return new t(function(c,e){var d=!1,f=!1,h=new A(a,b),l=new XMLHttpRequest,k=null;if(h.signal.aborted)return e(new w);var m=new U({start:function(a){k=a},cancel:function(a){d=!0;l.abort()}}),n=
function(){if(!d){d=!0;m.cancel();if(k)try{k.close()}catch(Ca){}setTimeout(function(){try{l.abort()}catch(Ca){}},0)}},r=m.getReader;m.getReader=function(){var a=r.bind(this).call(),b=a.read,c=a.closed;a.read=function(){return h[u]&&h[u].aborted?(n(),t.reject(new w)):b.bind(this).call()};ba(a,"closed",{get:function(){return h[u]&&h[u].aborted?(n(),t.reject(new w)):c}});return a};l.onload=function(){k.close()};l.onreadystatechange=function(){if(l.readyState===l.HEADERS_RECEIVED){var a={status:l.status,
statusText:l.statusText,headers:xa(l.getAllResponseHeaders()||"",R)};a.url="responseURL"in l?l.responseURL:a.headers.get("X-Request-URL");try{var b=new v(m,a);h[u].addEventListener("abort",function(){b[D]=!0;n();e(new w)});b[P]=f?"cors":"basic";c(b)}catch(Da){e(Da)}}};l.onerror=function(){k.error(new g("Network request failed"));e(new g("Network request failed"))};l.ontimeout=function(){k.error(new g("Network request failed"));e(new g("Network request failed"))};l.open(h.method,h.url,!0);"include"===
h.credentials&&(l.withCredentials=!0);h.headers.forEach(function(a,b){l.setRequestHeader(b,a)});var p=function(a){d||k.enqueue(a)},q=function(a){f=a};null===h.body?l.fetch(p,q,null):S(h).then(function(a){l.fetch(p,q,a)})})};aa.prototype.abort=function(){this.signal.dispatchEvent(new Event("abort"))};d.AbortController=aa;d.fetch.polyfill=!0}})(this);