define(["exports","./when-422ea0ae","./Check-741c5f3c","./defaultValue-81eec7ed","./combine-3c023bda","./Math-e73894ab","./RuntimeError-26acdd3b"],(function(e,t,r,n,o,s,i){"use strict";var a=t.createCommonjsModule((function(e,r){!function(n){var o=r&&!r.nodeType&&r,s=e&&!e.nodeType&&e,i="object"==typeof t.commonjsGlobal&&t.commonjsGlobal;i.global!==i&&i.window!==i&&i.self!==i||(n=i);var a,u,c=2147483647,l=36,p=/^xn--/,h=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,f={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},m=Math.floor,g=String.fromCharCode;function v(e){throw new RangeError(f[e])}function y(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function b(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+y((e=e.replace(d,".")).split("."),t).join(".")}function _(e){for(var t,r,n=[],o=0,s=e.length;o=55296&&t<=56319&&o65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=g(e)})).join("")}function A(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function q(e,t,r){var n=0;for(e=r?m(e/700):e>>1,e+=m(e/t);e>455;n+=l)e=m(e/35);return m(n+36*e/(e+38))}function k(e){var t,r,n,o,s,i,a,u,p,h,d,f=[],g=e.length,y=0,b=128,_=72;for((r=e.lastIndexOf("-"))<0&&(r=0),n=0;n=128&&v("not-basic"),f.push(e.charCodeAt(n));for(o=r>0?r+1:0;o=g&&v("invalid-input"),((u=(d=e.charCodeAt(o++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:l)>=l||u>m((c-y)/i))&&v("overflow"),y+=u*i,!(u<(p=a<=_?1:a>=_+26?26:a-_));a+=l)i>m(c/(h=l-p))&&v("overflow"),i*=h;_=q(y-s,t=f.length+1,0==s),m(y/t)>c-b&&v("overflow"),b+=m(y/t),y%=t,f.splice(y++,0,b)}return w(f)}function I(e){var t,r,n,o,s,i,a,u,p,h,d,f,y,b,w,k=[];for(f=(e=_(e)).length,t=128,r=0,s=72,i=0;i=t&&dm((c-r)/(y=n+1))&&v("overflow"),r+=(a-t)*y,t=a,i=0;ic&&v("overflow"),d==t){for(u=r,p=l;!(u<(h=p<=s?1:p>=s+26?26:p-s));p+=l)w=u-h,b=l-h,k.push(g(A(h+w%b,0))),u=m(w/b);k.push(g(A(u,0))),s=q(r,y,n==o),r=0,++n}++r,++t}return k.join("")}if(a={version:"1.3.2",ucs2:{decode:_,encode:w},decode:k,encode:I,toASCII:function(e){return b(e,(function(e){return h.test(e)?"xn--"+I(e):e}))},toUnicode:function(e){return b(e,(function(e){return p.test(e)?k(e.slice(4).toLowerCase()):e}))}},o&&s)if(e.exports==o)s.exports=a;else for(u in a)a.hasOwnProperty(u)&&(o[u]=a[u]);else n.punycode=a}(t.commonjsGlobal)})),u=t.createCommonjsModule((function(e){ /*! * URI.js - Mutating URLs * IPv6 Support * * Version: 1.19.11 * * Author: Rodney Rehm * Web: http://medialize.github.io/URI.js/ * * Licensed under * MIT License http://www.opensource.org/licenses/mit-license * */var r,n;r=t.commonjsGlobal,n=function(e){var t=e&&e.IPv6;return{best:function(e){var t,r,n=e.toLowerCase().split(":"),o=n.length,s=8;for(""===n[0]&&""===n[1]&&""===n[2]?(n.shift(),n.shift()):""===n[0]&&""===n[1]?n.shift():""===n[o-1]&&""===n[o-2]&&n.pop(),-1!==n[(o=n.length)-1].indexOf(".")&&(s=7),t=0;t1;a++)r.splice(0,1);n[i]=r.join("")}var u=-1,c=0,l=0,p=-1,h=!1;for(i=0;ic&&(u=p,c=l)):"0"===n[i]&&(h=!0,p=i,l=1);l>c&&(u=p,c=l),c>1&&n.splice(u,c,""),o=n.length;var d="";for(""===n[0]&&(d=":"),i=0;i=e.length-1)return!1;var n=e.lastIndexOf(".",t-1);if(n<=0||n>=t-1)return!1;var o=r.list[e.slice(t+1)];return!!o&&o.indexOf(" "+e.slice(n+1,t)+" ")>=0},is:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return!1;if(e.lastIndexOf(".",t-1)>=0)return!1;var n=r.list[e.slice(t+1)];return!!n&&n.indexOf(" "+e.slice(0,t)+" ")>=0},get:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return null;var n=e.lastIndexOf(".",t-1);if(n<=0||n>=t-1)return null;var o=r.list[e.slice(t+1)];return o?o.indexOf(" "+e.slice(n+1,t)+" ")<0?null:e.slice(n+1):null},noConflict:function(){return e.SecondLevelDomains===this&&(e.SecondLevelDomains=t),this}};return r},e.exports?e.exports=n():r.SecondLevelDomains=n(r)})),l=t.createCommonjsModule((function(e){ /*! * URI.js - Mutating URLs * * Version: 1.19.11 * * Author: Rodney Rehm * Web: http://medialize.github.io/URI.js/ * * Licensed under * MIT License http://www.opensource.org/licenses/mit-license * */var r,n;r=t.commonjsGlobal,n=function(e,t,r,n){var o=n&&n.URI;function s(e,t){var r=arguments.length>=1,n=arguments.length>=2;if(!(this instanceof s))return r?n?new s(e,t):new s(e):new s;if(void 0===e){if(r)throw new TypeError("undefined is not a valid argument for URI");e="undefined"!=typeof location?location.href+"":""}if(null===e&&r)throw new TypeError("null is not a valid argument for URI");return this.href(e),void 0!==t?this.absoluteTo(t):this}s.version="1.19.11";var i=s.prototype,a=Object.prototype.hasOwnProperty;function u(e){return e.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function c(e){return void 0===e?"Undefined":String(Object.prototype.toString.call(e)).slice(8,-1)}function l(e){return"Array"===c(e)}function p(e,t){var r,n,o={};if("RegExp"===c(t))o=null;else if(l(t))for(r=0,n=t.length;r]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,s.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},s.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,s.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,s.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},s.hostProtocols=["http","https"],s.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,s.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},s.getDomAttribute=function(e){if(e&&e.nodeName){var t=e.nodeName.toLowerCase();if("input"!==t||"image"===e.type)return s.domAttributes[t]}},s.encode=g,s.decode=decodeURIComponent,s.iso8859=function(){s.encode=escape,s.decode=unescape},s.unicode=function(){s.encode=g,s.decode=decodeURIComponent},s.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},s.encodeQuery=function(e,t){var r=s.encode(e+"");return void 0===t&&(t=s.escapeQuerySpace),t?r.replace(/%20/g,"+"):r},s.decodeQuery=function(e,t){e+="",void 0===t&&(t=s.escapeQuerySpace);try{return s.decode(t?e.replace(/\+/g,"%20"):e)}catch(t){return e}};var v,y={encode:"encode",decode:"decode"},b=function(e,t){return function(r){try{return s[t](r+"").replace(s.characters[e][t].expression,(function(r){return s.characters[e][t].map[r]}))}catch(e){return r}}};for(v in y)s[v+"PathSegment"]=b("pathname",y[v]),s[v+"UrnPathSegment"]=b("urnpath",y[v]);var _=function(e,t,r){return function(n){var o;o=r?function(e){return s[t](s[r](e))}:s[t];for(var i=(n+"").split(e),a=0,u=i.length;a-1&&(t.fragment=e.substring(r+1)||null,e=e.substring(0,r)),(r=e.indexOf("?"))>-1&&(t.query=e.substring(r+1)||null,e=e.substring(0,r)),"//"===(e=(e=e.replace(/^(https?|ftp|wss?)?:+[/\\]*/i,"$1://")).replace(/^[/\\]{2,}/i,"//")).substring(0,2)?(t.protocol=null,e=e.substring(2),e=s.parseAuthority(e,t)):(r=e.indexOf(":"))>-1&&(t.protocol=e.substring(0,r)||null,t.protocol&&!t.protocol.match(s.protocol_expression)?t.protocol=void 0:"//"===e.substring(r+1,r+3).replace(/\\/g,"/")?(e=e.substring(r+3),e=s.parseAuthority(e,t)):(e=e.substring(r+1),t.urn=!0)),t.path=e,t},s.parseHost=function(e,t){e||(e="");var r,n,o=(e=e.replace(/\\/g,"/")).indexOf("/");if(-1===o&&(o=e.length),"["===e.charAt(0))r=e.indexOf("]"),t.hostname=e.substring(1,r)||null,t.port=e.substring(r+2,o)||null,"/"===t.port&&(t.port=null);else{var i=e.indexOf(":"),a=e.indexOf("/"),u=e.indexOf(":",i+1);-1!==u&&(-1===a||u-1?o:e.length-1);return i>-1&&(-1===o||i-1?d.slice(0,f)+d.slice(f).replace(i,""):d.replace(i,"")).length<=c[0].length||r.ignore&&r.ignore.test(d))){var v=t(d,l,h=l+d.length,e);void 0!==v?(v=String(v),e=e.slice(0,l)+v+e.slice(h),n.lastIndex=l+v.length):n.lastIndex=h}}return n.lastIndex=0,e},s.ensureValidHostname=function(t,r){var n=!!t,o=!1;if(!!r&&(o=h(s.hostProtocols,r)),o&&!n)throw new TypeError("Hostname cannot be empty, if protocol is "+r);if(t&&t.match(s.invalid_hostname_characters)){if(!e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(e.toASCII(t).match(s.invalid_hostname_characters))throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_]')}},s.ensureValidPort=function(e){if(e){var t=Number(e);if(!(/^[0-9]+$/.test(t)&&t>0&&t<65536))throw new TypeError('Port "'+e+'" is not a valid port')}},s.noConflict=function(e){if(e){var t={URI:this.noConflict()};return n.URITemplate&&"function"==typeof n.URITemplate.noConflict&&(t.URITemplate=n.URITemplate.noConflict()),n.IPv6&&"function"==typeof n.IPv6.noConflict&&(t.IPv6=n.IPv6.noConflict()),n.SecondLevelDomains&&"function"==typeof n.SecondLevelDomains.noConflict&&(t.SecondLevelDomains=n.SecondLevelDomains.noConflict()),t}return n.URI===this&&(n.URI=o),this},i.build=function(e){return!0===e?this._deferred_build=!0:(void 0===e||this._deferred_build)&&(this._string=s.build(this._parts),this._deferred_build=!1),this},i.clone=function(){return new s(this)},i.valueOf=i.toString=function(){return this.build(!1)._string},i.protocol=w("protocol"),i.username=w("username"),i.password=w("password"),i.hostname=w("hostname"),i.port=w("port"),i.query=A("query","?"),i.fragment=A("fragment","#"),i.search=function(e,t){var r=this.query(e,t);return"string"==typeof r&&r.length?"?"+r:r},i.hash=function(e,t){var r=this.fragment(e,t);return"string"==typeof r&&r.length?"#"+r:r},i.pathname=function(e,t){if(void 0===e||!0===e){var r=this._parts.path||(this._parts.hostname?"/":"");return e?(this._parts.urn?s.decodeUrnPath:s.decodePath)(r):r}return this._parts.urn?this._parts.path=e?s.recodeUrnPath(e):"":this._parts.path=e?s.recodePath(e):"/",this.build(!t),this},i.path=i.pathname,i.href=function(e,t){var r;if(void 0===e)return this.toString();this._string="",this._parts=s._parts();var n=e instanceof s,o="object"==typeof e&&(e.hostname||e.path||e.pathname);if(e.nodeName&&(e=e[s.getDomAttribute(e)]||"",o=!1),!n&&o&&void 0!==e.pathname&&(e=e.toString()),"string"==typeof e||e instanceof String)this._parts=s.parse(String(e),this._parts);else{if(!n&&!o)throw new TypeError("invalid input");var i=n?e._parts:e;for(r in i)"query"!==r&&a.call(this._parts,r)&&(this._parts[r]=i[r]);i.query&&this.query(i.query,!1)}return this.build(!t),this},i.is=function(e){var t=!1,n=!1,o=!1,i=!1,a=!1,u=!1,c=!1,l=!this._parts.urn;switch(this._parts.hostname&&(l=!1,n=s.ip4_expression.test(this._parts.hostname),o=s.ip6_expression.test(this._parts.hostname),a=(i=!(t=n||o))&&r&&r.has(this._parts.hostname),u=i&&s.idn_expression.test(this._parts.hostname),c=i&&s.punycode_expression.test(this._parts.hostname)),e.toLowerCase()){case"relative":return l;case"absolute":return!l;case"domain":case"name":return i;case"sld":return a;case"ip":return t;case"ip4":case"ipv4":case"inet4":return n;case"ip6":case"ipv6":case"inet6":return o;case"idn":return u;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return c}return null};var q=i.protocol,k=i.port,I=i.hostname;i.protocol=function(e,t){if(e&&!(e=e.replace(/:(\/\/)?$/,"")).match(s.protocol_expression))throw new TypeError('Protocol "'+e+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return q.call(this,e,t)},i.scheme=i.protocol,i.port=function(e,t){return this._parts.urn?void 0===e?"":this:(void 0!==e&&(0===e&&(e=null),e&&(":"===(e+="").charAt(0)&&(e=e.substring(1)),s.ensureValidPort(e))),k.call(this,e,t))},i.hostname=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0!==e){var r={preventInvalidHostname:this._parts.preventInvalidHostname};if("/"!==s.parseHost(e,r))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');e=r.hostname,this._parts.preventInvalidHostname&&s.ensureValidHostname(e,this._parts.protocol)}return I.call(this,e,t)},i.origin=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var r=this.protocol();return this.authority()?(r?r+"://":"")+this.authority():""}var n=s(e);return this.protocol(n.protocol()).authority(n.authority()).build(!t),this},i.host=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?s.buildHost(this._parts):"";if("/"!==s.parseHost(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},i.authority=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?s.buildAuthority(this._parts):"";if("/"!==s.parseAuthority(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},i.userinfo=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var r=s.buildUserinfo(this._parts);return r?r.substring(0,r.length-1):r}return"@"!==e[e.length-1]&&(e+="@"),s.parseUserinfo(e,this._parts),this.build(!t),this},i.resource=function(e,t){var r;return void 0===e?this.path()+this.search()+this.hash():(r=s.parse(e),this._parts.path=r.path,this._parts.query=r.query,this._parts.fragment=r.fragment,this.build(!t),this)},i.subdomain=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,r)||""}var n=this._parts.hostname.length-this.domain().length,o=this._parts.hostname.substring(0,n),i=new RegExp("^"+u(o));if(e&&"."!==e.charAt(e.length-1)&&(e+="."),-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");return e&&s.ensureValidHostname(e,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(i,e),this.build(!t),this},i.domain=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("boolean"==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.match(/\./g);if(r&&r.length<2)return this._parts.hostname;var n=this._parts.hostname.length-this.tld(t).length-1;return n=this._parts.hostname.lastIndexOf(".",n-1)+1,this._parts.hostname.substring(n)||""}if(!e)throw new TypeError("cannot set domain empty");if(-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");if(s.ensureValidHostname(e,this._parts.protocol),!this._parts.hostname||this.is("IP"))this._parts.hostname=e;else{var o=new RegExp(u(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(o,e)}return this.build(!t),this},i.tld=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("boolean"==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var n=this._parts.hostname.lastIndexOf("."),o=this._parts.hostname.substring(n+1);return!0!==t&&r&&r.list[o.toLowerCase()]&&r.get(this._parts.hostname)||o}var s;if(!e)throw new TypeError("cannot set TLD empty");if(e.match(/[^a-zA-Z0-9-]/)){if(!r||!r.is(e))throw new TypeError('TLD "'+e+'" contains characters other than [A-Z0-9]');s=new RegExp(u(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(s,e)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");s=new RegExp(u(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(s,e)}return this.build(!t),this},i.directory=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e||!0===e){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var r=this._parts.path.length-this.filename().length-1,n=this._parts.path.substring(0,r)||(this._parts.hostname?"/":"");return e?s.decodePath(n):n}var o=this._parts.path.length-this.filename().length,i=this._parts.path.substring(0,o),a=new RegExp("^"+u(i));return this.is("relative")||(e||(e="/"),"/"!==e.charAt(0)&&(e="/"+e)),e&&"/"!==e.charAt(e.length-1)&&(e+="/"),e=s.recodePath(e),this._parts.path=this._parts.path.replace(a,e),this.build(!t),this},i.filename=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("string"!=typeof e){if(!this._parts.path||"/"===this._parts.path)return"";var r=this._parts.path.lastIndexOf("/"),n=this._parts.path.substring(r+1);return e?s.decodePathSegment(n):n}var o=!1;"/"===e.charAt(0)&&(e=e.substring(1)),e.match(/\.?\//)&&(o=!0);var i=new RegExp(u(this.filename())+"$");return e=s.recodePath(e),this._parts.path=this._parts.path.replace(i,e),o?this.normalizePath(t):this.build(!t),this},i.suffix=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e||!0===e){if(!this._parts.path||"/"===this._parts.path)return"";var r,n,o=this.filename(),i=o.lastIndexOf(".");return-1===i?"":(r=o.substring(i+1),n=/^[a-z0-9%]+$/i.test(r)?r:"",e?s.decodePathSegment(n):n)}"."===e.charAt(0)&&(e=e.substring(1));var a,c=this.suffix();if(c)a=e?new RegExp(u(c)+"$"):new RegExp(u("."+c)+"$");else{if(!e)return this;this._parts.path+="."+s.recodePath(e)}return a&&(e=s.recodePath(e),this._parts.path=this._parts.path.replace(a,e)),this.build(!t),this},i.segment=function(e,t,r){var n=this._parts.urn?":":"/",o=this.path(),s="/"===o.substring(0,1),i=o.split(n);if(void 0!==e&&"number"!=typeof e&&(r=t,t=e,e=void 0),void 0!==e&&"number"!=typeof e)throw new Error('Bad segment "'+e+'", must be 0-based integer');if(s&&i.shift(),e<0&&(e=Math.max(i.length+e,0)),void 0===t)return void 0===e?i:i[e];if(null===e||void 0===i[e])if(l(t)){i=[];for(var a=0,u=t.length;a0){const e=n.substring(0,o),r=n.substring(o+2);t[e]=r}}return t}(this.responseHeaders))}function I(){this._listeners=[],this._scopes=[],this._toRemove=[],this._insideRaiseEvent=!1}function x(e,t){return t-e}function C(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}function S(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}q.prototype.cancel=function(){this.cancelled=!0},q.prototype.clone=function(e){return n.defined(e)?(e.url=this.url,e.requestFunction=this.requestFunction,e.cancelFunction=this.cancelFunction,e.priorityFunction=this.priorityFunction,e.priority=this.priority,e.throttle=this.throttle,e.throttleByServer=this.throttleByServer,e.type=this.type,e.serverKey=this.serverKey,e.state=this.RequestState.UNISSUED,e.deferred=void 0,e.cancelled=!1,e):new q(this)},k.prototype.toString=function(){let e="Request has failed.";return n.defined(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e},Object.defineProperties(I.prototype,{numberOfListeners:{get:function(){return this._listeners.length-this._toRemove.length}}}),I.prototype.addEventListener=function(e,t){this._listeners.push(e),this._scopes.push(t);const r=this;return function(){r.removeEventListener(e,t)}},I.prototype.removeEventListener=function(e,t){const r=this._listeners,n=this._scopes;let o=-1;for(let s=0;s0){for(s.sort(x),e=0;e=0;--t)this.heapify(t)},C.prototype.insert=function(e){const t=this._array,r=this._comparator,o=this._maximumLength;let s,i=this._length++;for(io&&(s=t[o],this._length=o),s},C.prototype.pop=function(e){if(e=n.defaultValue(e,0),0===this._length)return;const t=this._array,r=t[e];return S(t,e,--this._length),this.heapify(e),t[this._length]=void 0,r};const R={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0};let E=20;const O=new C({comparator:function(e,t){return e.priority-t.priority}});O.maximumLength=E,O.reserve(E);const P=[];let z={};const T="undefined"!=typeof document?new l(document.location.href):new l,U=new I;function j(){}function Q(e){n.defined(e.priorityFunction)&&(e.priority=e.priorityFunction())}function F(e){return e.state===w.UNISSUED&&(e.state=w.ISSUED,e.deferred=t.when.defer()),e.deferred.promise}function B(e){const t=F(e);return e.state=w.ACTIVE,P.push(e),++R.numberOfActiveRequests,++R.numberOfActiveRequestsEver,++z[e.serverKey],e.requestFunction().then(function(e){return function(t){if(e.state===w.CANCELLED)return;const r=e.deferred;--R.numberOfActiveRequests,--z[e.serverKey],U.raiseEvent(),e.state=w.RECEIVED,e.deferred=void 0,r.resolve(t)}}(e)).otherwise(function(e){return function(t){e.state!==w.CANCELLED&&(++R.numberOfFailedRequests,--R.numberOfActiveRequests,--z[e.serverKey],U.raiseEvent(t),e.state=w.FAILED,e.deferred.reject(t))}}(e)),t}function D(e){const t=e.state===w.ACTIVE;if(e.state=w.CANCELLED,++R.numberOfCancelledRequests,n.defined(e.deferred)){const t=e.deferred;e.deferred=void 0,t.reject()}t&&(--R.numberOfActiveRequests,--z[e.serverKey],++R.numberOfCancelledActiveRequests),n.defined(e.cancelFunction)&&e.cancelFunction()}j.maximumRequests=50,j.maximumRequestsPerServer=6,j.requestsByServer={"api.cesium.com:443":18,"assets.cesium.com:443":18},j.throttleRequests=!0,j.debugShowStatistics=!1,j.requestCompletedEvent=U,Object.defineProperties(j,{statistics:{get:function(){return R}},priorityHeapLength:{get:function(){return E},set:function(e){if(ee;){D(O.pop())}E=e,O.maximumLength=e,O.reserve(e)}}}),j.serverHasOpenSlots=function(e,t){t=n.defaultValue(t,1);const r=n.defaultValue(j.requestsByServer[e],j.maximumRequestsPerServer);return z[e]+t<=r},j.heapHasOpenSlots=function(e){return O.length+e<=E},j.update=function(){let e,t,r=0;const n=P.length;for(e=0;e0&&(P[e-r]=t):++r;P.length-=r;const o=O.internalArray,s=O.length;for(e=0;e0;)t=O.pop(),t.cancelled?D(t):!t.throttleByServer||j.serverHasOpenSlots(t.serverKey)?(B(t),++a):D(t);!function(){if(!j.debugShowStatistics)return;0===R.numberOfActiveRequests&&R.lastNumberOfActiveRequests>0&&(R.numberOfAttemptedRequests>0&&(console.log(`Number of attempted requests: ${R.numberOfAttemptedRequests}`),R.numberOfAttemptedRequests=0),R.numberOfCancelledRequests>0&&(console.log(`Number of cancelled requests: ${R.numberOfCancelledRequests}`),R.numberOfCancelledRequests=0),R.numberOfCancelledActiveRequests>0&&(console.log(`Number of cancelled active requests: ${R.numberOfCancelledActiveRequests}`),R.numberOfCancelledActiveRequests=0),R.numberOfFailedRequests>0&&(console.log(`Number of failed requests: ${R.numberOfFailedRequests}`),R.numberOfFailedRequests=0));R.lastNumberOfActiveRequests=R.numberOfActiveRequests}()},j.getServerKey=function(e){let t=new l(e);""===t.scheme()&&(t=new l(e).absoluteTo(T),t.normalize());let r=t.authority();/:/.test(r)||(r=`${r}:${"https"===t.scheme()?"443":"80"}`);const o=z[r];return n.defined(o)||(z[r]=0),r},j.request=function(e){if(_(e.url)||g(e.url))return U.raiseEvent(),e.state=w.RECEIVED,e.requestFunction();if(++R.numberOfAttemptedRequests,n.defined(e.serverKey)||(e.serverKey=j.getServerKey(e.url)),j.throttleRequests&&e.throttleByServer&&!j.serverHasOpenSlots(e.serverKey))return;if(!j.throttleRequests||!e.throttle)return B(e);if(P.length>=j.maximumRequests)return;Q(e);const t=O.insert(e);if(n.defined(t)){if(t===e)return;D(t)}return F(e)},j.clearForSpecs=function(){for(;O.length>0;){D(O.pop())}const e=P.length;for(let t=0;t0}}}),X.prototype.toString=function(){return this.getUrlComponent(!0,!0)},X.prototype.getUrlComponent=function(e,t){if(this.isDataUri)return this._url;const r=new l(this._url);e&&$(r,this);let o=r.toString().replace(/%7B/g,"{").replace(/%7D/g,"}");const s=this._templateValues;return o=o.replace(/{(.*?)}/g,(function(e,t){const r=s[t];return n.defined(r)?encodeURIComponent(r):e})),t&&n.defined(this.proxy)&&(o=this.proxy.getURL(o)),o},X.prototype.setQueryParameters=function(e,t){this._queryParameters=t?J(this._queryParameters,e,!1):J(e,this._queryParameters,!1)},X.prototype.appendQueryParameters=function(e){this._queryParameters=J(e,this._queryParameters,!0)},X.prototype.setTemplateValues=function(e,t){this._templateValues=t?o.combine(this._templateValues,e):o.combine(e,this._templateValues)},X.prototype.getDerivedResource=function(e){const t=this.clone();if(t._retryCount=0,n.defined(e.url)){const r=new l(e.url);M(r,t,!0,n.defaultValue(e.preserveQueryParameters,!1)),r.fragment(""),""!==r.scheme()?t._url=r.toString():t._url=r.absoluteTo(new l(h(this._url))).toString()}return n.defined(e.queryParameters)&&(t._queryParameters=o.combine(e.queryParameters,t._queryParameters)),n.defined(e.templateValues)&&(t._templateValues=o.combine(e.templateValues,t.templateValues)),n.defined(e.headers)&&(t.headers=o.combine(e.headers,t.headers)),n.defined(e.proxy)&&(t.proxy=e.proxy),n.defined(e.request)&&(t.request=e.request),n.defined(e.retryCallback)&&(t.retryCallback=e.retryCallback),n.defined(e.retryAttempts)&&(t.retryAttempts=e.retryAttempts),t},X.prototype.retryOnError=function(e){const r=this.retryCallback;if("function"!=typeof r||this._retryCount>=this.retryAttempts)return t.when(!1);const n=this;return t.when(r(this,e)).then((function(e){return++n._retryCount,e}))},X.prototype.clone=function(e){return n.defined(e)||(e=new X({url:this._url})),e._url=this._url,e._queryParameters=p(this._queryParameters),e._templateValues=p(this._templateValues),e.headers=p(this.headers),e.proxy=this.proxy,e.retryCallback=this.retryCallback,e.retryAttempts=this.retryAttempts,e._retryCount=0,e.request=this.request.clone(),e},X.prototype.getBaseUri=function(e){return function(e,t){let r="";const n=e.lastIndexOf("/");return-1!==n&&(r=e.substring(0,n+1)),t?(0!==(e=new l(e)).query().length&&(r+=`?${e.query()}`),0!==e.fragment().length&&(r+=`#${e.fragment()}`),r):r}(this.getUrlComponent(e),e)},X.prototype.appendForwardSlash=function(){var e;this._url=(0!==(e=this._url).length&&"/"===e[e.length-1]||(e=`${e}/`),e)},X.prototype.fetchArrayBuffer=function(){return this.fetch({responseType:"arraybuffer"})},X.fetchArrayBuffer=function(e){return new X(e).fetchArrayBuffer()},X.prototype.fetchBlob=function(){return this.fetch({responseType:"blob"})},X.fetchBlob=function(e){return new X(e).fetchBlob()},X.prototype.fetchImage=function(e){e=n.defaultValue(e,n.defaultValue.EMPTY_OBJECT);const r=n.defaultValue(e.preferImageBitmap,!1),o=n.defaultValue(e.preferBlob,!1),s=n.defaultValue(e.flipY,!1),i=n.defaultValue(e.skipColorSpaceConversion,!1);if(Y(this.request),!H||this.isDataUri||this.isBlobUri||!this.hasHeaders&&!o)return G({resource:this,flipY:s,skipColorSpaceConversion:i,preferImageBitmap:r});const a=this.fetchBlob();if(!n.defined(a))return;let u,c,l,p;return X.supportsImageBitmapOptions().then((function(e){return u=e,c=u&&r,a})).then((function(e){if(!n.defined(e))return;if(p=e,c)return X.createImageBitmapFromBlob(e,{flipY:s,premultiplyAlpha:!1,skipColorSpaceConversion:i});const t=window.URL.createObjectURL(e);return l=new X({url:t}),G({resource:l,flipY:s,skipColorSpaceConversion:i,preferImageBitmap:!1})})).then((function(e){if(n.defined(e))return e.blob=p,c||window.URL.revokeObjectURL(l.url),e})).otherwise((function(e){return n.defined(l)&&window.URL.revokeObjectURL(l.url),e.blob=p,t.when.reject(e)}))},X.fetchImage=function(e){return new X(e).fetchImage({flipY:e.flipY,skipColorSpaceConversion:e.skipColorSpaceConversion,preferBlob:e.preferBlob,preferImageBitmap:e.preferImageBitmap})},X.prototype.fetchText=function(){return this.fetch({responseType:"text"})},X.fetchText=function(e){return new X(e).fetchText()},X.prototype.fetchJson=function(){const e=this.fetch({responseType:"text",headers:{Accept:"application/json,*/*;q=0.01"}});if(n.defined(e))return e.then((function(e){if(n.defined(e))return JSON.parse(e)}))},X.fetchJson=function(e){return new X(e).fetchJson()},X.prototype.fetchXML=function(){return this.fetch({responseType:"document",overrideMimeType:"text/xml"})},X.fetchXML=function(e){return new X(e).fetchXML()},X.prototype.fetchJsonp=function(e){let t;e=n.defaultValue(e,"callback"),Y(this.request);do{t=`loadJsonp${s.CesiumMath.nextRandomNumber().toString().substring(2,8)}`}while(n.defined(window[t]));return Z(this,e,t)},X.fetchJsonp=function(e){return new X(e).fetchJsonp(e.callbackParameterName)},X.prototype._makeRequest=function(e){const r=this;Y(r.request);const s=r.request;s.url=r.url,s.requestFunction=function(){const i=e.responseType,a=o.combine(e.headers,r.headers),u=e.overrideMimeType,c=e.method,l=e.data,p=t.when.defer(),h=X._Implementations.loadWithXhr(r.url,i,c,l,a,p,u);return n.defined(h)&&n.defined(h.abort)&&(s.cancelFunction=function(){h.abort()}),p.promise};const i=j.request(s);if(n.defined(i))return i.then((function(e){return s.cancelFunction=void 0,e})).otherwise((function(n){return s.cancelFunction=void 0,s.state!==w.FAILED?t.when.reject(n):r.retryOnError(n).then((function(o){return o?(s.state=w.UNISSUED,s.deferred=void 0,r.fetch(e)):t.when.reject(n)}))}))};const W=/^data:(.*?)(;base64)?,(.*)$/;function ee(e,t){const r=decodeURIComponent(t);return e?atob(r):r}function te(e,t){const r=ee(e,t),n=new ArrayBuffer(r.length),o=new Uint8Array(n);for(let e=0;e=300)return void s.reject(new k(e.statusCode,e,e.headers));const r=[];e.on("data",(function(e){r.push(e)})),e.on("end",(function(){const n=Buffer.concat(r);"gzip"===e.headers["content-encoding"]?l.gunzip(n,(function(e,r){e?s.reject(new i.RuntimeError("Error decompressing response.")):s.resolve(re(r,t))})):s.resolve(re(n,t))}))})).on("error",(function(e){s.reject(new k)})).end()}(e,t,r,0,s,a);const l=new XMLHttpRequest;if(L.contains(e)&&(l.withCredentials=!0),l.open(r,e,!0),n.defined(u)&&n.defined(l.overrideMimeType)&&l.overrideMimeType(u),n.defined(s))for(const e in s)s.hasOwnProperty(e)&&l.setRequestHeader(e,s[e]);n.defined(t)&&(l.responseType=t);let p=!1;return"string"==typeof e&&(p=0===e.indexOf("file://")||"undefined"!=typeof window&&"file://"===window.location.origin),l.onload=function(){if((l.status<200||l.status>=300)&&(!p||0!==l.status))return void a.reject(new k(l.status,l.response,l.getAllResponseHeaders()));const e=l.response,o=l.responseType;if("HEAD"===r||"OPTIONS"===r){const e=l.getAllResponseHeaders().trim().split(/[\r\n]+/),t={};return e.forEach((function(e){const r=e.split(": "),n=r.shift();t[n]=r.join(": ")})),void a.resolve(t)}if(204===l.status)a.resolve();else if(!n.defined(e)||n.defined(t)&&o!==t)if("json"===t&&"string"==typeof e)try{a.resolve(JSON.parse(e))}catch(e){a.reject(e)}else(""===o||"document"===o)&&n.defined(l.responseXML)&&l.responseXML.hasChildNodes()?a.resolve(l.responseXML):""!==o&&"text"!==o||!n.defined(l.responseText)?a.reject(new i.RuntimeError("Invalid XMLHttpRequest response type.")):a.resolve(l.responseText);else a.resolve(e)},l.onerror=function(e){a.reject(new k)},l.send(o),l},X._Implementations.loadAndExecuteScript=function(e,r,n){return function(e){const r=t.when.defer(),n=document.createElement("script");n.async=!0,n.src=e;const o=document.getElementsByTagName("head")[0];return n.onload=function(){n.onload=void 0,o.removeChild(n),r.resolve()},n.onerror=function(e){r.reject(e)},o.appendChild(n),r.promise}(e).otherwise(n.reject)},X._DefaultImplementations={},X._DefaultImplementations.createImage=X._Implementations.createImage,X._DefaultImplementations.loadWithXhr=X._Implementations.loadWithXhr,X._DefaultImplementations.loadAndExecuteScript=X._Implementations.loadAndExecuteScript,X.DEFAULT=Object.freeze(new X({url:"undefined"==typeof document?"":document.location.href.split("?")[0]})),e.Event=I,e.Resource=X,e.URI=l,e.clone=p,e.getAbsoluteUri=h,e.isCrossOriginUrl=y}));