!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tus=t()}(function(){return function n(o,i,u){function a(e,t){if(!i[e]){if(!o[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(s)return s(e,!0);throw(t=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",t}r=i[e]={exports:{}},o[e][0].call(r.exports,function(t){return a(o[e][1][t]||t)},r,r.exports,n,o,i,u)}return i[e].exports}for(var s="function"==typeof require&&require,t=0;t=this.size,Promise.resolve({value:t,done:e}))}},{key:"close",value:function(){}}])&&a(t.prototype,r),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();r.default=t},{"./isCordova.js":8,"./readAsByteArray.js":9}],7:[function(t,e,r){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){for(var r=0;rthis._bufferOffset&&(this._buffer=this._buffer.slice(t-this._bufferOffset),this._bufferOffset=t);var r=0===u(this._buffer);return this._done&&r?null:this._buffer.slice(0,e-t)}},{key:"close",value:function(){this._reader.cancel&&this._reader.cancel()}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();r.default=n},{}],8:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;r.default=function(){return"undefined"!=typeof window&&(void 0!==window.PhoneGap||void 0!==window.Cordova||void 0!==window.cordova)}},{}],9:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return new Promise(function(e,r){var n=new FileReader;n.onload=function(){var t=new Uint8Array(n.result);e({value:t})},n.onerror=function(t){r(t)},n.readAsArrayBuffer(t)})}},{}],10:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return new Promise(function(e,r){var n=new XMLHttpRequest;n.responseType="blob",n.onload=function(){var t=n.response;e(t)},n.onerror=function(t){r(t)},n.open("GET",t),n.send()})}},{}],11:[function(t,e,r){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);rthis._offsetBeforeRetry&&(this._retryAttempt=0),S(t,this._retryAttempt,this.options))return e=this.options.retryDelays[this._retryAttempt++],this._offsetBeforeRetry=this._offset,void(this._retryTimeout=setTimeout(function(){r.start()},e));if("function"!=typeof this.options.onError)throw t;this.options.onError(t)}}},{key:"_emitSuccess",value:function(){this.options.removeFingerprintOnSuccess&&this._removeFromUrlStorage(),"function"==typeof this.options.onSuccess&&this.options.onSuccess()}},{key:"_emitProgress",value:function(t,e){"function"==typeof this.options.onProgress&&this.options.onProgress(t,e)}},{key:"_emitChunkComplete",value:function(t,e,r){"function"==typeof this.options.onChunkComplete&&this.options.onChunkComplete(t,e,r)}},{key:"_createUpload",value:function(){var r,t,n=this;this.options.endpoint?(r=this._openRequest("POST",this.options.endpoint),this.options.uploadLengthDeferred?r.setHeader("Upload-Defer-Length",1):r.setHeader("Upload-Length",this._size),""!==(t=v(this.options.metadata))&&r.setHeader("Upload-Metadata",t),(this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,this._addChunkToRequest(r)):this._sendRequest(r,null)).then(function(t){var e;m(t.getStatus(),200)?null==(e=t.getHeader("Location"))?n._emitHttpError(r,t,"tus: invalid or missing Location header"):(n.url=E(n.options.endpoint,e),(0,u.log)("Created upload at ".concat(n.url)),"function"==typeof n.options.onUploadUrlAvailable&&n.options.onUploadUrlAvailable(),0===n._size?(n._emitSuccess(),n._source.close()):n._saveUploadInUrlStorage().then(function(){n.options.uploadDataDuringCreation?n._handleUploadResponse(r,t):(n._offset=0,n._performUpload())})):n._emitHttpError(r,t,"tus: unexpected response while creating upload")}).catch(function(t){n._emitHttpError(r,null,"tus: failed to create upload",t)})):this._emitError(new Error("tus: unable to create upload because no endpoint is provided"))}},{key:"_resumeUpload",value:function(){var o=this,i=this._openRequest("HEAD",this.url);this._sendRequest(i,null).then(function(t){var e=t.getStatus();if(!m(e,200))return 423===e?void o._emitHttpError(i,t,"tus: upload is currently locked; retry later"):(m(e,400)&&o._removeFromUrlStorage(),o.options.endpoint?(o.url=null,void o._createUpload()):void o._emitHttpError(i,t,"tus: unable to resume upload (new upload cannot be created without an endpoint)"));var r,n=parseInt(t.getHeader("Upload-Offset"),10);Number.isNaN(n)?o._emitHttpError(i,t,"tus: invalid or missing offset value"):(r=parseInt(t.getHeader("Upload-Length"),10),Number.isNaN(r)&&!o.options.uploadLengthDeferred?o._emitHttpError(i,t,"tus: invalid or missing length value"):("function"==typeof o.options.onUploadUrlAvailable&&o.options.onUploadUrlAvailable(),o._saveUploadInUrlStorage().then(function(){n===r?(o._emitProgress(r,r),o._emitSuccess()):(o._offset=n,o._performUpload())})))}).catch(function(t){o._emitHttpError(i,null,"tus: failed to resume upload",t)})}},{key:"_performUpload",value:function(){var e,r=this;this._aborted||(this.options.overridePatchMethod?(e=this._openRequest("POST",this.url)).setHeader("X-HTTP-Method-Override","PATCH"):e=this._openRequest("PATCH",this.url),e.setHeader("Upload-Offset",this._offset),this._addChunkToRequest(e).then(function(t){m(t.getStatus(),200)?r._handleUploadResponse(e,t):r._emitHttpError(e,t,"tus: unexpected response while uploading chunk")}).catch(function(t){r._aborted||r._emitHttpError(e,null,"tus: failed to upload chunk at offset ".concat(r._offset),t)}))}},{key:"_addChunkToRequest",value:function(n){var o=this,e=this._offset,t=this._offset+this.options.chunkSize;return n.setProgressHandler(function(t){o._emitProgress(e+t,o._size)}),n.setHeader("Content-Type","application/offset+octet-stream"),(t===1/0||t>this._size)&&!this.options.uploadLengthDeferred&&(t=this._size),this._source.slice(e,t).then(function(t){var e=t.value,t=t.done,r=e&&e.size?e.size:0,r=(o.options.uploadLengthDeferred&&t&&(o._size=o._offset+r,n.setHeader("Upload-Length",o._size)),o._offset+r);return!o.options.uploadLengthDeferred&&t&&r!==o._size?Promise.reject(new Error("upload was configured with a size of ".concat(o._size," bytes, but the source is done after ").concat(r," bytes"))):null===e?o._sendRequest(n):(o._emitProgress(o._offset,o._size),o._sendRequest(n,e))})}},{key:"_handleUploadResponse",value:function(t,e){var r=parseInt(e.getHeader("Upload-Offset"),10);Number.isNaN(r)?this._emitHttpError(t,e,"tus: invalid or missing offset value"):(this._emitProgress(r,this._size),this._emitChunkComplete(r-this._offset,r,this._size),(this._offset=r)===this._size?(this._emitSuccess(),this._source.close()):this._performUpload())}},{key:"_openRequest",value:function(t,e){t=b(t,e,this.options);return this._req=t}},{key:"_removeFromUrlStorage",value:function(){var e=this;this._urlStorageKey&&(this._urlStorage.removeUpload(this._urlStorageKey).catch(function(t){e._emitError(t)}),this._urlStorageKey=null)}},{key:"_saveUploadInUrlStorage",value:function(){var t,e=this;return this.options.storeFingerprintForResuming&&this._fingerprint&&null===this._urlStorageKey?(t={size:this._size,metadata:this.options.metadata,creationTime:(new Date).toString()},this._parallelUploads?t.parallelUploadUrls=this._parallelUploadUrls:t.uploadUrl=this.url,this._urlStorage.addUpload(this._fingerprint,t).then(function(t){e._urlStorageKey=t})):Promise.resolve()}},{key:"_sendRequest",value:function(t){return w(t,1=r.retryDelays.length||null==t.originalRequest)&&(r&&"function"==typeof r.onShouldRetry?r.onShouldRetry(t,e,r):(!m(e=t.originalResponse?t.originalResponse.getStatus():0,400)||409===e||423===e)&&(r=!0,r=!("undefined"!=typeof window&&"navigator"in window&&!1===window.navigator.onLine)&&r))}function E(t,e){return new o.default(e,t).toString()}g.defaultOptions=t,r.default=g},{"./error.js":12,"./logger.js":13,"./uuid.js":16,"js-base64":20,"url-parse":23}],16:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}},{}],17:[function(t,e,r){"use strict";r.byteLength=function(t){var t=f(t),e=t[0],t=t[1];return 3*(e+t)/4-t},r.toByteArray=function(t){var e,r,n=f(t),o=n[0],n=n[1],i=new l(function(t,e){return 3*(t+e)/4-e}(o,n)),u=0,a=0>16&255,i[u++]=e>>8&255,i[u++]=255&e;2===n&&(e=s[t.charCodeAt(r)]<<2|s[t.charCodeAt(r+1)]>>4,i[u++]=255&e);1===n&&(e=s[t.charCodeAt(r)]<<10|s[t.charCodeAt(r+1)]<<4|s[t.charCodeAt(r+2)]>>2,i[u++]=e>>8&255,i[u++]=255&e);return i},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,u=r-n;i>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}(n));return o.join("")}(t,i,u>2]+a[e<<4&63]+"==")):2==n&&(e=(t[r-2]<<8)+t[r-1],o.push(a[e>>10]+a[e>>4&63]+a[e<<2&63]+"="));return o.join("")};for(var a=[],s=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=n.length;o>>1;case"base64":return x(t).length;default:if(o)return n?-1:O(t).length;e=(""+e).toLowerCase(),o=!0}}function r(t,e,r){var n,o=!1;if((e=void 0===e||e<0?0:e)>this.length)return"";if((r=void 0===r||r>this.length?this.length:r)<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":var i=this,u=e,a=r,s=i.length;(!a||a<0||s=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:d(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?(o?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(t,e,r):d(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function d(t,e,r,n,o){var i=1,u=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u/=i=2,a/=2,r/=2}function s(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o)for(var l=-1,f=r;f>8,o.push(r%256),o.push(n);return o}(e,t.length-r),t,r,n)}function j(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o>>10&1023|55296),f=56320|1023&f),n.push(f),o+=c}var p=n,h=p.length;if(h<=m)return String.fromCharCode.apply(String,p);for(var d="",y=0;ye&&(t+=" ... "),""},c.prototype.compare=function(t,e,r,n,o){if(A(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),(e=void 0===e?0:e)<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(o<=n&&r<=e)return 0;if(o<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),u=(r>>>=0)-(e>>>=0),a=Math.min(i,u),s=this.slice(n,o),l=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||othis.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var i,u,a,s=!1;;)switch(n){case"hex":var l=this,f=t,c=e,p=r,h=(c=Number(c)||0,l.length-c);(!p||h<(p=Number(p)))&&(p=h),(h=f.length)/2t.length)throw new RangeError("Index out of range")}function w(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _(t,e,r,n,o){return e=+e,r>>>=0,o||w(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function S(t,e,r,n,o){return e=+e,r>>>=0,o||w(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length,r=((t=~~t)<0?(t+=r)<0&&(t=0):r>>=0,e>>>=0,r||y(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||y(t,e,this.length);for(var n=this[t+--e],o=1;0>>=0,e||y(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||y(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||y(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||y(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||y(t,e,this.length);for(var n=e,o=1,i=this[t+--n];0>>=0,e||y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||y(t,2,this.length);e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,e){t>>>=0,e||y(t,2,this.length);e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||y(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||y(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||y(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||y(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||b(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||b(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;0<=--o&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,n){t=+t,e>>>=0,n||b(this,t,e,r,(n=Math.pow(2,8*r-1))-1,-n);var o=0,i=1,u=0;for(this[e]=255&t;++o>0)-u&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){t=+t,e>>>=0,n||b(this,t,e,r,(n=Math.pow(2,8*r-1))-1,-n);var o=r-1,i=1,u=0;for(this[e+o]=255&t;0<=--o&&(i*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/i>>0)-u&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,1,127,-128),this[e]=255&(t=t<0?255+t+1:t),e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||b(this,t,e,4,2147483647,-2147483648),this[e]=(t=t<0?4294967295+t+1:t)>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return _(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return _(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return S(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return S(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r=r||0,n||0===n||(n=this.length),e>=t.length&&(e=t.length),(n=0=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length);var o=(n=t.length-e>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(i=e;i>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function x(t){return U.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(E,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function A(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function R(t){return t!=t}}.call(this)}.call(this,k("buffer").Buffer)},{"base64-js":17,buffer:18,ieee754:19}],19:[function(t,e,r){r.read=function(t,e,r,n,o){var i,u,a=8*o-n-1,s=(1<>1,f=-7,c=r?o-1:0,p=r?-1:1,o=t[e+c];for(c+=p,i=o&(1<<-f)-1,o>>=-f,f+=a;0>=-f,f+=n;0>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,h=n?1:-1,i=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=l):(u=Math.floor(Math.log(e)/Math.LN2),e*(n=Math.pow(2,-u))<1&&(u--,n*=2),2<=(e+=1<=u+f?c/n:c*Math.pow(2,1-f))*n&&(u++,n/=2),l<=u+f?(a=0,u=l):1<=u+f?(a=(e*n-1)*Math.pow(2,o),u+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),u=0));8<=o;t[r+p]=255&a,p+=h,a/=256,o-=8);for(u=u<>18&63]+S[e>>12&63]+S[e>>6&63]+S[63&e]}return i?o.slice(0,i-3)+"===".substring(i):o}function e(t,e){return(e=void 0===e?!1:e)?r(A(t)):A(t)}function n(t){var e;return t.length<2?(e=t.charCodeAt(0))<128?t:e<2048?j(192|e>>>6)+j(128|63&e):j(224|e>>>12&15)+j(128|e>>>6&63)+j(128|63&e):(e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320),j(240|e>>>18&7)+j(128|e>>>12&63)+j(128|e>>>6&63)+j(128|63&e))}function o(t){return t.replace(R,n)}function i(t,e){return(e=void 0===e?!1:e)?r(k(t)):k(t)}function u(t){return i(t,!0)}function a(t){switch(t.length){case 4:var e=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return j(55296+(e>>>10))+j(56320+(1023&e));case 3:return j((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return j((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}}function s(t){return t.replace(L,a)}function l(t){if(t=t.replace(/\s+/g,""),!U.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var e,r,n,o="",i=0;i>16&255):64===n?j(e>>16&255,e>>8&255):j(e>>16&255,e>>8&255,255&e);return o}function f(t){return C(c(t))}function c(t){return x(t.replace(/[-_]/g,function(t){return"-"==t?"+":"/"}))}function p(t){return I(c(t))}function h(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}}function d(){function t(t,e){Object.defineProperty(String.prototype,t,h(e))}t("fromBase64",function(){return p(this)}),t("toBase64",function(t){return i(this,t)}),t("toBase64URI",function(){return i(this,!0)}),t("toBase64URL",function(){return i(this,!0)}),t("toUint8Array",function(){return f(this)})}function y(){function t(t,e){Object.defineProperty(Uint8Array.prototype,t,h(e))}t("toBase64",function(t){return e(this,t)}),t("toBase64URI",function(){return e(this,!0)}),t("toBase64URL",function(){return e(this,!0)})}var g,v="function"==typeof atob,m="function"==typeof btoa,b="function"==typeof D,w="function"==typeof TextDecoder?new TextDecoder:void 0,_="function"==typeof TextEncoder?new TextEncoder:void 0,S=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),E=(g={},S.forEach(function(t,e){return g[t]=e}),g),U=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,j=String.fromCharCode.bind(String),O="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},x=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},P=m?function(t){return btoa(t)}:b?function(t){return D.from(t,"binary").toString("base64")}:t,A=b?function(t){return D.from(t).toString("base64")}:function(t){for(var e=[],r=0,n=t.length;r