{"version":3,"file":"UploadImage.vue_vue_type_script_setup_true_lang-HZYNKo3p.js","sources":["../../node_modules/.pnpm/js-base64@3.7.5/node_modules/js-base64/base64.mjs","../../node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js","../../node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js","../../node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/error.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/uuid.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/upload.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/noopUrlStorage.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/urlStorage.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/httpStack.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/isReactNative.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/uriToBlob.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/sources/isCordova.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/sources/readAsByteArray.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/sources/FileSource.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/sources/StreamSource.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/fileReader.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/fileSignature.js","../../node_modules/.pnpm/tus-js-client@3.1.3/node_modules/tus-js-client/lib.esm/browser/index.js","../../cognitocmsapi/Components/UploadImage.vue"],"sourcesContent":["/**\n * base64.ts\n *\n * Licensed under the BSD 3-Clause License.\n * http://opensource.org/licenses/BSD-3-Clause\n *\n * References:\n * http://en.wikipedia.org/wiki/Base64\n *\n * @author Dan Kogai (https://github.com/dankogai)\n */\nconst version = '3.7.5';\n/**\n * @deprecated use lowercase `version`.\n */\nconst VERSION = version;\nconst _hasatob = typeof atob === 'function';\nconst _hasbtoa = typeof btoa === 'function';\nconst _hasBuffer = typeof Buffer === 'function';\nconst _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;\nconst _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;\nconst b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\nconst b64chs = Array.prototype.slice.call(b64ch);\nconst b64tab = ((a) => {\n let tab = {};\n a.forEach((c, i) => tab[c] = i);\n return tab;\n})(b64chs);\nconst b64re = /^(?:[A-Za-z\\d+\\/]{4})*?(?:[A-Za-z\\d+\\/]{2}(?:==)?|[A-Za-z\\d+\\/]{3}=?)?$/;\nconst _fromCC = String.fromCharCode.bind(String);\nconst _U8Afrom = typeof Uint8Array.from === 'function'\n ? Uint8Array.from.bind(Uint8Array)\n : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));\nconst _mkUriSafe = (src) => src\n .replace(/=/g, '').replace(/[+\\/]/g, (m0) => m0 == '+' ? '-' : '_');\nconst _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\\+\\/]/g, '');\n/**\n * polyfill version of `btoa`\n */\nconst btoaPolyfill = (bin) => {\n // console.log('polyfilled');\n let u32, c0, c1, c2, asc = '';\n const pad = bin.length % 3;\n for (let i = 0; i < bin.length;) {\n if ((c0 = bin.charCodeAt(i++)) > 255 ||\n (c1 = bin.charCodeAt(i++)) > 255 ||\n (c2 = bin.charCodeAt(i++)) > 255)\n throw new TypeError('invalid character found');\n u32 = (c0 << 16) | (c1 << 8) | c2;\n asc += b64chs[u32 >> 18 & 63]\n + b64chs[u32 >> 12 & 63]\n + b64chs[u32 >> 6 & 63]\n + b64chs[u32 & 63];\n }\n return pad ? asc.slice(0, pad - 3) + \"===\".substring(pad) : asc;\n};\n/**\n * does what `window.btoa` of web browsers do.\n * @param {String} bin binary string\n * @returns {string} Base64-encoded string\n */\nconst _btoa = _hasbtoa ? (bin) => btoa(bin)\n : _hasBuffer ? (bin) => Buffer.from(bin, 'binary').toString('base64')\n : btoaPolyfill;\nconst _fromUint8Array = _hasBuffer\n ? (u8a) => Buffer.from(u8a).toString('base64')\n : (u8a) => {\n // cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326\n const maxargs = 0x1000;\n let strs = [];\n for (let i = 0, l = u8a.length; i < l; i += maxargs) {\n strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));\n }\n return _btoa(strs.join(''));\n };\n/**\n * converts a Uint8Array to a Base64 string.\n * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5\n * @returns {string} Base64 string\n */\nconst fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);\n// This trick is found broken https://github.com/dankogai/js-base64/issues/130\n// const utob = (src: string) => unescape(encodeURIComponent(src));\n// reverting good old fationed regexp\nconst cb_utob = (c) => {\n if (c.length < 2) {\n var cc = c.charCodeAt(0);\n return cc < 0x80 ? c\n : cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))\n + _fromCC(0x80 | (cc & 0x3f)))\n : (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))\n + _fromCC(0x80 | ((cc >>> 6) & 0x3f))\n + _fromCC(0x80 | (cc & 0x3f)));\n }\n else {\n var cc = 0x10000\n + (c.charCodeAt(0) - 0xD800) * 0x400\n + (c.charCodeAt(1) - 0xDC00);\n return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))\n + _fromCC(0x80 | ((cc >>> 12) & 0x3f))\n + _fromCC(0x80 | ((cc >>> 6) & 0x3f))\n + _fromCC(0x80 | (cc & 0x3f)));\n }\n};\nconst re_utob = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFFF]|[^\\x00-\\x7F]/g;\n/**\n * @deprecated should have been internal use only.\n * @param {string} src UTF-8 string\n * @returns {string} UTF-16 string\n */\nconst utob = (u) => u.replace(re_utob, cb_utob);\n//\nconst _encode = _hasBuffer\n ? (s) => Buffer.from(s, 'utf8').toString('base64')\n : _TE\n ? (s) => _fromUint8Array(_TE.encode(s))\n : (s) => _btoa(utob(s));\n/**\n * converts a UTF-8-encoded string to a Base64 string.\n * @param {boolean} [urlsafe] if `true` make the result URL-safe\n * @returns {string} Base64 string\n */\nconst encode = (src, urlsafe = false) => urlsafe\n ? _mkUriSafe(_encode(src))\n : _encode(src);\n/**\n * converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.\n * @returns {string} Base64 string\n */\nconst encodeURI = (src) => encode(src, true);\n// This trick is found broken https://github.com/dankogai/js-base64/issues/130\n// const btou = (src: string) => decodeURIComponent(escape(src));\n// reverting good old fationed regexp\nconst re_btou = /[\\xC0-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF]{2}|[\\xF0-\\xF7][\\x80-\\xBF]{3}/g;\nconst cb_btou = (cccc) => {\n switch (cccc.length) {\n case 4:\n var cp = ((0x07 & cccc.charCodeAt(0)) << 18)\n | ((0x3f & cccc.charCodeAt(1)) << 12)\n | ((0x3f & cccc.charCodeAt(2)) << 6)\n | (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;\n return (_fromCC((offset >>> 10) + 0xD800)\n + _fromCC((offset & 0x3FF) + 0xDC00));\n case 3:\n return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)\n | ((0x3f & cccc.charCodeAt(1)) << 6)\n | (0x3f & cccc.charCodeAt(2)));\n default:\n return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)\n | (0x3f & cccc.charCodeAt(1)));\n }\n};\n/**\n * @deprecated should have been internal use only.\n * @param {string} src UTF-16 string\n * @returns {string} UTF-8 string\n */\nconst btou = (b) => b.replace(re_btou, cb_btou);\n/**\n * polyfill version of `atob`\n */\nconst atobPolyfill = (asc) => {\n // console.log('polyfilled');\n asc = asc.replace(/\\s+/g, '');\n if (!b64re.test(asc))\n throw new TypeError('malformed base64.');\n asc += '=='.slice(2 - (asc.length & 3));\n let u24, bin = '', r1, r2;\n for (let i = 0; i < asc.length;) {\n u24 = b64tab[asc.charAt(i++)] << 18\n | b64tab[asc.charAt(i++)] << 12\n | (r1 = b64tab[asc.charAt(i++)]) << 6\n | (r2 = b64tab[asc.charAt(i++)]);\n bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)\n : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)\n : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);\n }\n return bin;\n};\n/**\n * does what `window.atob` of web browsers do.\n * @param {String} asc Base64-encoded string\n * @returns {string} binary string\n */\nconst _atob = _hasatob ? (asc) => atob(_tidyB64(asc))\n : _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')\n : atobPolyfill;\n//\nconst _toUint8Array = _hasBuffer\n ? (a) => _U8Afrom(Buffer.from(a, 'base64'))\n : (a) => _U8Afrom(_atob(a).split('').map(c => c.charCodeAt(0)));\n/**\n * converts a Base64 string to a Uint8Array.\n */\nconst toUint8Array = (a) => _toUint8Array(_unURI(a));\n//\nconst _decode = _hasBuffer\n ? (a) => Buffer.from(a, 'base64').toString('utf8')\n : _TD\n ? (a) => _TD.decode(_toUint8Array(a))\n : (a) => btou(_atob(a));\nconst _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/'));\n/**\n * converts a Base64 string to a UTF-8 string.\n * @param {String} src Base64 string. Both normal and URL-safe are supported\n * @returns {string} UTF-8 string\n */\nconst decode = (src) => _decode(_unURI(src));\n/**\n * check if a value is a valid Base64 string\n * @param {String} src a value to check\n */\nconst isValid = (src) => {\n if (typeof src !== 'string')\n return false;\n const s = src.replace(/\\s+/g, '').replace(/={0,2}$/, '');\n return !/[^\\s0-9a-zA-Z\\+/]/.test(s) || !/[^\\s0-9a-zA-Z\\-_]/.test(s);\n};\n//\nconst _noEnum = (v) => {\n return {\n value: v, enumerable: false, writable: true, configurable: true\n };\n};\n/**\n * extend String.prototype with relevant methods\n */\nconst extendString = function () {\n const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));\n _add('fromBase64', function () { return decode(this); });\n _add('toBase64', function (urlsafe) { return encode(this, urlsafe); });\n _add('toBase64URI', function () { return encode(this, true); });\n _add('toBase64URL', function () { return encode(this, true); });\n _add('toUint8Array', function () { return toUint8Array(this); });\n};\n/**\n * extend Uint8Array.prototype with relevant methods\n */\nconst extendUint8Array = function () {\n const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));\n _add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); });\n _add('toBase64URI', function () { return fromUint8Array(this, true); });\n _add('toBase64URL', function () { return fromUint8Array(this, true); });\n};\n/**\n * extend Builtin prototypes with relevant methods\n */\nconst extendBuiltins = () => {\n extendString();\n extendUint8Array();\n};\nconst gBase64 = {\n version: version,\n VERSION: VERSION,\n atob: _atob,\n atobPolyfill: atobPolyfill,\n btoa: _btoa,\n btoaPolyfill: btoaPolyfill,\n fromBase64: decode,\n toBase64: encode,\n encode: encode,\n encodeURI: encodeURI,\n encodeURL: encodeURI,\n utob: utob,\n btou: btou,\n decode: decode,\n isValid: isValid,\n fromUint8Array: fromUint8Array,\n toUint8Array: toUint8Array,\n extendString: extendString,\n extendUint8Array: extendUint8Array,\n extendBuiltins: extendBuiltins,\n};\n// makecjs:CUT //\nexport { version };\nexport { VERSION };\nexport { _atob as atob };\nexport { atobPolyfill };\nexport { _btoa as btoa };\nexport { btoaPolyfill };\nexport { decode as fromBase64 };\nexport { encode as toBase64 };\nexport { utob };\nexport { encode };\nexport { encodeURI };\nexport { encodeURI as encodeURL };\nexport { btou };\nexport { decode };\nexport { isValid };\nexport { fromUint8Array };\nexport { toUint8Array };\nexport { extendString };\nexport { extendUint8Array };\nexport { extendBuiltins };\n// and finally,\nexport { gBase64 as Base64 };\n","'use strict';\n\n/**\n * Check if we're required to add a port number.\n *\n * @see https://url.spec.whatwg.org/#default-port\n * @param {Number|String} port Port number we need to check\n * @param {String} protocol Protocol we need to check against.\n * @returns {Boolean} Is it a default port for the given protocol\n * @api private\n */\nmodule.exports = function required(port, protocol) {\n protocol = protocol.split(':')[0];\n port = +port;\n\n if (!port) return false;\n\n switch (protocol) {\n case 'http':\n case 'ws':\n return port !== 80;\n\n case 'https':\n case 'wss':\n return port !== 443;\n\n case 'ftp':\n return port !== 21;\n\n case 'gopher':\n return port !== 70;\n\n case 'file':\n return false;\n }\n\n return port !== 0;\n};\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , undef;\n\n/**\n * Decode a URI encoded string.\n *\n * @param {String} input The URI encoded string.\n * @returns {String|Null} The decoded string.\n * @api private\n */\nfunction decode(input) {\n try {\n return decodeURIComponent(input.replace(/\\+/g, ' '));\n } catch (e) {\n return null;\n }\n}\n\n/**\n * Attempts to encode a given input.\n *\n * @param {String} input The string that needs to be encoded.\n * @returns {String|Null} The encoded string.\n * @api private\n */\nfunction encode(input) {\n try {\n return encodeURIComponent(input);\n } catch (e) {\n return null;\n }\n}\n\n/**\n * Simple query string parser.\n *\n * @param {String} query The query string that needs to be parsed.\n * @returns {Object}\n * @api public\n */\nfunction querystring(query) {\n var parser = /([^=?#&]+)=?([^&]*)/g\n , result = {}\n , part;\n\n while (part = parser.exec(query)) {\n var key = decode(part[1])\n , value = decode(part[2]);\n\n //\n // Prevent overriding of existing properties. This ensures that build-in\n // methods like `toString` or __proto__ are not overriden by malicious\n // querystrings.\n //\n // In the case if failed decoding, we want to omit the key/value pairs\n // from the result.\n //\n if (key === null || value === null || key in result) continue;\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Transform a query string to an object.\n *\n * @param {Object} obj Object that should be transformed.\n * @param {String} prefix Optional prefix.\n * @returns {String}\n * @api public\n */\nfunction querystringify(obj, prefix) {\n prefix = prefix || '';\n\n var pairs = []\n , value\n , key;\n\n //\n // Optionally prefix with a '?' if needed\n //\n if ('string' !== typeof prefix) prefix = '?';\n\n for (key in obj) {\n if (has.call(obj, key)) {\n value = obj[key];\n\n //\n // Edge cases where we actually want to encode the value to an empty\n // string instead of the stringified value.\n //\n if (!value && (value === null || value === undef || isNaN(value))) {\n value = '';\n }\n\n key = encode(key);\n value = encode(value);\n\n //\n // If we failed to encode the strings, we should bail out as we don't\n // want to add invalid strings to the query.\n //\n if (key === null || value === null) continue;\n pairs.push(key +'='+ value);\n }\n }\n\n return pairs.length ? prefix + pairs.join('&') : '';\n}\n\n//\n// Expose the module.\n//\nexports.stringify = querystringify;\nexports.parse = querystring;\n","'use strict';\n\nvar required = require('requires-port')\n , qs = require('querystringify')\n , controlOrWhitespace = /^[\\x00-\\x20\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]+/\n , CRHTLF = /[\\n\\r\\t]/g\n , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\\/\\//\n , port = /:\\d+$/\n , protocolre = /^([a-z][a-z0-9.+-]*:)?(\\/\\/)?([\\\\/]+)?([\\S\\s]*)/i\n , windowsDriveLetter = /^[a-zA-Z]:/;\n\n/**\n * Remove control characters and whitespace from the beginning of a string.\n *\n * @param {Object|String} str String to trim.\n * @returns {String} A new string representing `str` stripped of control\n * characters and whitespace from its beginning.\n * @public\n */\nfunction trimLeft(str) {\n return (str ? str : '').toString().replace(controlOrWhitespace, '');\n}\n\n/**\n * These are the parse rules for the URL parser, it informs the parser\n * about:\n *\n * 0. The char it Needs to parse, if it's a string it should be done using\n * indexOf, RegExp using exec and NaN means set as current value.\n * 1. The property we should set when parsing this value.\n * 2. Indication if it's backwards or forward parsing, when set as number it's\n * the value of extra chars that should be split off.\n * 3. Inherit from location if non existing in the parser.\n * 4. `toLowerCase` the resulting value.\n */\nvar rules = [\n ['#', 'hash'], // Extract from the back.\n ['?', 'query'], // Extract from the back.\n function sanitize(address, url) { // Sanitize what is left of the address\n return isSpecial(url.protocol) ? address.replace(/\\\\/g, '/') : address;\n },\n ['/', 'pathname'], // Extract from the back.\n ['@', 'auth', 1], // Extract from the front.\n [NaN, 'host', undefined, 1, 1], // Set left over value.\n [/:(\\d*)$/, 'port', undefined, 1], // RegExp the back.\n [NaN, 'hostname', undefined, 1, 1] // Set left over.\n];\n\n/**\n * These properties should not be copied or inherited from. This is only needed\n * for all non blob URL's as a blob URL does not include a hash, only the\n * origin.\n *\n * @type {Object}\n * @private\n */\nvar ignore = { hash: 1, query: 1 };\n\n/**\n * The location object differs when your code is loaded through a normal page,\n * Worker or through a worker using a blob. And with the blobble begins the\n * trouble as the location object will contain the URL of the blob, not the\n * location of the page where our code is loaded in. The actual origin is\n * encoded in the `pathname` so we can thankfully generate a good \"default\"\n * location from it so we can generate proper relative URL's again.\n *\n * @param {Object|String} loc Optional default location object.\n * @returns {Object} lolcation object.\n * @public\n */\nfunction lolcation(loc) {\n var globalVar;\n\n if (typeof window !== 'undefined') globalVar = window;\n else if (typeof global !== 'undefined') globalVar = global;\n else if (typeof self !== 'undefined') globalVar = self;\n else globalVar = {};\n\n var location = globalVar.location || {};\n loc = loc || location;\n\n var finaldestination = {}\n , type = typeof loc\n , key;\n\n if ('blob:' === loc.protocol) {\n finaldestination = new Url(unescape(loc.pathname), {});\n } else if ('string' === type) {\n finaldestination = new Url(loc, {});\n for (key in ignore) delete finaldestination[key];\n } else if ('object' === type) {\n for (key in loc) {\n if (key in ignore) continue;\n finaldestination[key] = loc[key];\n }\n\n if (finaldestination.slashes === undefined) {\n finaldestination.slashes = slashes.test(loc.href);\n }\n }\n\n return finaldestination;\n}\n\n/**\n * Check whether a protocol scheme is special.\n *\n * @param {String} The protocol scheme of the URL\n * @return {Boolean} `true` if the protocol scheme is special, else `false`\n * @private\n */\nfunction isSpecial(scheme) {\n return (\n scheme === 'file:' ||\n scheme === 'ftp:' ||\n scheme === 'http:' ||\n scheme === 'https:' ||\n scheme === 'ws:' ||\n scheme === 'wss:'\n );\n}\n\n/**\n * @typedef ProtocolExtract\n * @type Object\n * @property {String} protocol Protocol matched in the URL, in lowercase.\n * @property {Boolean} slashes `true` if protocol is followed by \"//\", else `false`.\n * @property {String} rest Rest of the URL that is not part of the protocol.\n */\n\n/**\n * Extract protocol information from a URL with/without double slash (\"//\").\n *\n * @param {String} address URL we want to extract from.\n * @param {Object} location\n * @return {ProtocolExtract} Extracted information.\n * @private\n */\nfunction extractProtocol(address, location) {\n address = trimLeft(address);\n address = address.replace(CRHTLF, '');\n location = location || {};\n\n var match = protocolre.exec(address);\n var protocol = match[1] ? match[1].toLowerCase() : '';\n var forwardSlashes = !!match[2];\n var otherSlashes = !!match[3];\n var slashesCount = 0;\n var rest;\n\n if (forwardSlashes) {\n if (otherSlashes) {\n rest = match[2] + match[3] + match[4];\n slashesCount = match[2].length + match[3].length;\n } else {\n rest = match[2] + match[4];\n slashesCount = match[2].length;\n }\n } else {\n if (otherSlashes) {\n rest = match[3] + match[4];\n slashesCount = match[3].length;\n } else {\n rest = match[4]\n }\n }\n\n if (protocol === 'file:') {\n if (slashesCount >= 2) {\n rest = rest.slice(2);\n }\n } else if (isSpecial(protocol)) {\n rest = match[4];\n } else if (protocol) {\n if (forwardSlashes) {\n rest = rest.slice(2);\n }\n } else if (slashesCount >= 2 && isSpecial(location.protocol)) {\n rest = match[4];\n }\n\n return {\n protocol: protocol,\n slashes: forwardSlashes || isSpecial(protocol),\n slashesCount: slashesCount,\n rest: rest\n };\n}\n\n/**\n * Resolve a relative URL pathname against a base URL pathname.\n *\n * @param {String} relative Pathname of the relative URL.\n * @param {String} base Pathname of the base URL.\n * @return {String} Resolved pathname.\n * @private\n */\nfunction resolve(relative, base) {\n if (relative === '') return base;\n\n var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))\n , i = path.length\n , last = path[i - 1]\n , unshift = false\n , up = 0;\n\n while (i--) {\n if (path[i] === '.') {\n path.splice(i, 1);\n } else if (path[i] === '..') {\n path.splice(i, 1);\n up++;\n } else if (up) {\n if (i === 0) unshift = true;\n path.splice(i, 1);\n up--;\n }\n }\n\n if (unshift) path.unshift('');\n if (last === '.' || last === '..') path.push('');\n\n return path.join('/');\n}\n\n/**\n * The actual URL instance. Instead of returning an object we've opted-in to\n * create an actual constructor as it's much more memory efficient and\n * faster and it pleases my OCD.\n *\n * It is worth noting that we should not use `URL` as class name to prevent\n * clashes with the global URL instance that got introduced in browsers.\n *\n * @constructor\n * @param {String} address URL we want to parse.\n * @param {Object|String} [location] Location defaults for relative paths.\n * @param {Boolean|Function} [parser] Parser for the query string.\n * @private\n */\nfunction Url(address, location, parser) {\n address = trimLeft(address);\n address = address.replace(CRHTLF, '');\n\n if (!(this instanceof Url)) {\n return new Url(address, location, parser);\n }\n\n var relative, extracted, parse, instruction, index, key\n , instructions = rules.slice()\n , type = typeof location\n , url = this\n , i = 0;\n\n //\n // The following if statements allows this module two have compatibility with\n // 2 different API:\n //\n // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments\n // where the boolean indicates that the query string should also be parsed.\n //\n // 2. The `URL` interface of the browser which accepts a URL, object as\n // arguments. The supplied object will be used as default values / fall-back\n // for relative paths.\n //\n if ('object' !== type && 'string' !== type) {\n parser = location;\n location = null;\n }\n\n if (parser && 'function' !== typeof parser) parser = qs.parse;\n\n location = lolcation(location);\n\n //\n // Extract protocol information before running the instructions.\n //\n extracted = extractProtocol(address || '', location);\n relative = !extracted.protocol && !extracted.slashes;\n url.slashes = extracted.slashes || relative && location.slashes;\n url.protocol = extracted.protocol || location.protocol || '';\n address = extracted.rest;\n\n //\n // When the authority component is absent the URL starts with a path\n // component.\n //\n if (\n extracted.protocol === 'file:' && (\n extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||\n (!extracted.slashes &&\n (extracted.protocol ||\n extracted.slashesCount < 2 ||\n !isSpecial(url.protocol)))\n ) {\n instructions[3] = [/(.*)/, 'pathname'];\n }\n\n for (; i < instructions.length; i++) {\n instruction = instructions[i];\n\n if (typeof instruction === 'function') {\n address = instruction(address, url);\n continue;\n }\n\n parse = instruction[0];\n key = instruction[1];\n\n if (parse !== parse) {\n url[key] = address;\n } else if ('string' === typeof parse) {\n index = parse === '@'\n ? address.lastIndexOf(parse)\n : address.indexOf(parse);\n\n if (~index) {\n if ('number' === typeof instruction[2]) {\n url[key] = address.slice(0, index);\n address = address.slice(index + instruction[2]);\n } else {\n url[key] = address.slice(index);\n address = address.slice(0, index);\n }\n }\n } else if ((index = parse.exec(address))) {\n url[key] = index[1];\n address = address.slice(0, index.index);\n }\n\n url[key] = url[key] || (\n relative && instruction[3] ? location[key] || '' : ''\n );\n\n //\n // Hostname, host and protocol should be lowercased so they can be used to\n // create a proper `origin`.\n //\n if (instruction[4]) url[key] = url[key].toLowerCase();\n }\n\n //\n // Also parse the supplied query string in to an object. If we're supplied\n // with a custom parser as function use that instead of the default build-in\n // parser.\n //\n if (parser) url.query = parser(url.query);\n\n //\n // If the URL is relative, resolve the pathname against the base URL.\n //\n if (\n relative\n && location.slashes\n && url.pathname.charAt(0) !== '/'\n && (url.pathname !== '' || location.pathname !== '')\n ) {\n url.pathname = resolve(url.pathname, location.pathname);\n }\n\n //\n // Default to a / for pathname if none exists. This normalizes the URL\n // to always have a /\n //\n if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {\n url.pathname = '/' + url.pathname;\n }\n\n //\n // We should not add port numbers if they are already the default port number\n // for a given protocol. As the host also contains the port number we're going\n // override it with the hostname which contains no port number.\n //\n if (!required(url.port, url.protocol)) {\n url.host = url.hostname;\n url.port = '';\n }\n\n //\n // Parse down the `auth` for the username and password.\n //\n url.username = url.password = '';\n\n if (url.auth) {\n index = url.auth.indexOf(':');\n\n if (~index) {\n url.username = url.auth.slice(0, index);\n url.username = encodeURIComponent(decodeURIComponent(url.username));\n\n url.password = url.auth.slice(index + 1);\n url.password = encodeURIComponent(decodeURIComponent(url.password))\n } else {\n url.username = encodeURIComponent(decodeURIComponent(url.auth));\n }\n\n url.auth = url.password ? url.username +':'+ url.password : url.username;\n }\n\n url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host\n ? url.protocol +'//'+ url.host\n : 'null';\n\n //\n // The href is just the compiled result.\n //\n url.href = url.toString();\n}\n\n/**\n * This is convenience method for changing properties in the URL instance to\n * insure that they all propagate correctly.\n *\n * @param {String} part Property we need to adjust.\n * @param {Mixed} value The newly assigned value.\n * @param {Boolean|Function} fn When setting the query, it will be the function\n * used to parse the query.\n * When setting the protocol, double slash will be\n * removed from the final url if it is true.\n * @returns {URL} URL instance for chaining.\n * @public\n */\nfunction set(part, value, fn) {\n var url = this;\n\n switch (part) {\n case 'query':\n if ('string' === typeof value && value.length) {\n value = (fn || qs.parse)(value);\n }\n\n url[part] = value;\n break;\n\n case 'port':\n url[part] = value;\n\n if (!required(value, url.protocol)) {\n url.host = url.hostname;\n url[part] = '';\n } else if (value) {\n url.host = url.hostname +':'+ value;\n }\n\n break;\n\n case 'hostname':\n url[part] = value;\n\n if (url.port) value += ':'+ url.port;\n url.host = value;\n break;\n\n case 'host':\n url[part] = value;\n\n if (port.test(value)) {\n value = value.split(':');\n url.port = value.pop();\n url.hostname = value.join(':');\n } else {\n url.hostname = value;\n url.port = '';\n }\n\n break;\n\n case 'protocol':\n url.protocol = value.toLowerCase();\n url.slashes = !fn;\n break;\n\n case 'pathname':\n case 'hash':\n if (value) {\n var char = part === 'pathname' ? '/' : '#';\n url[part] = value.charAt(0) !== char ? char + value : value;\n } else {\n url[part] = value;\n }\n break;\n\n case 'username':\n case 'password':\n url[part] = encodeURIComponent(value);\n break;\n\n case 'auth':\n var index = value.indexOf(':');\n\n if (~index) {\n url.username = value.slice(0, index);\n url.username = encodeURIComponent(decodeURIComponent(url.username));\n\n url.password = value.slice(index + 1);\n url.password = encodeURIComponent(decodeURIComponent(url.password));\n } else {\n url.username = encodeURIComponent(decodeURIComponent(value));\n }\n }\n\n for (var i = 0; i < rules.length; i++) {\n var ins = rules[i];\n\n if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();\n }\n\n url.auth = url.password ? url.username +':'+ url.password : url.username;\n\n url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host\n ? url.protocol +'//'+ url.host\n : 'null';\n\n url.href = url.toString();\n\n return url;\n}\n\n/**\n * Transform the properties back in to a valid and full URL string.\n *\n * @param {Function} stringify Optional query stringify function.\n * @returns {String} Compiled version of the URL.\n * @public\n */\nfunction toString(stringify) {\n if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;\n\n var query\n , url = this\n , host = url.host\n , protocol = url.protocol;\n\n if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';\n\n var result =\n protocol +\n ((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : '');\n\n if (url.username) {\n result += url.username;\n if (url.password) result += ':'+ url.password;\n result += '@';\n } else if (url.password) {\n result += ':'+ url.password;\n result += '@';\n } else if (\n url.protocol !== 'file:' &&\n isSpecial(url.protocol) &&\n !host &&\n url.pathname !== '/'\n ) {\n //\n // Add back the empty userinfo, otherwise the original invalid URL\n // might be transformed into a valid one with `url.pathname` as host.\n //\n result += '@';\n }\n\n //\n // Trailing colon is removed from `url.host` when it is parsed. If it still\n // ends with a colon, then add back the trailing colon that was removed. This\n // prevents an invalid URL from being transformed into a valid one.\n //\n if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) {\n host += ':';\n }\n\n result += host + url.pathname;\n\n query = 'object' === typeof url.query ? stringify(url.query) : url.query;\n if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;\n\n if (url.hash) result += url.hash;\n\n return result;\n}\n\nUrl.prototype = { set: set, toString: toString };\n\n//\n// Expose the URL parser and some additional properties that might be useful for\n// others or testing.\n//\nUrl.extractProtocol = extractProtocol;\nUrl.location = lolcation;\nUrl.trimLeft = trimLeft;\nUrl.qs = qs;\n\nmodule.exports = Url;\n","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; } catch (e) { return typeof fn === \"function\"; } }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nvar DetailedError = /*#__PURE__*/function (_Error) {\n _inherits(DetailedError, _Error);\n var _super = _createSuper(DetailedError);\n function DetailedError(message) {\n var _this;\n var causingErr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var req = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var res = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n _classCallCheck(this, DetailedError);\n _this = _super.call(this, message);\n _this.originalRequest = req;\n _this.originalResponse = res;\n _this.causingError = causingErr;\n if (causingErr != null) {\n message += \", caused by \".concat(causingErr.toString());\n }\n if (req != null) {\n var requestId = req.getHeader('X-Request-ID') || 'n/a';\n var method = req.getMethod();\n var url = req.getURL();\n var status = res ? res.getStatus() : 'n/a';\n var body = res ? res.getBody() || '' : 'n/a';\n message += \", originated from request (method: \".concat(method, \", url: \").concat(url, \", response code: \").concat(status, \", response text: \").concat(body, \", request id: \").concat(requestId, \")\");\n }\n _this.message = message;\n return _this;\n }\n return _createClass(DetailedError);\n}( /*#__PURE__*/_wrapNativeSuper(Error));\nexport default DetailedError;","/**\n * Generate a UUID v4 based on random numbers. We intentioanlly use the less\n * secure Math.random function here since the more secure crypto.getRandomNumbers\n * is not available on all platforms.\n * This is not a problem for us since we use the UUID only for generating a\n * request ID, so we can correlate server logs to client errors.\n *\n * This function is taken from following site:\n * https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\n *\n * @return {string} The generate UUID\n */\nexport default function uuid() {\n /* eslint-disable no-bitwise */\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n var r = Math.random() * 16 | 0;\n var v = c === 'x' ? r : r & 0x3 | 0x8;\n return v.toString(16);\n });\n}","function _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { Base64 } from 'js-base64';\nimport URL from 'url-parse';\nimport DetailedError from './error.js';\nimport { log } from './logger.js';\nimport uuid from './uuid.js';\nvar defaultOptions = {\n endpoint: null,\n uploadUrl: null,\n metadata: {},\n fingerprint: null,\n uploadSize: null,\n onProgress: null,\n onChunkComplete: null,\n onSuccess: null,\n onError: null,\n onUploadUrlAvailable: null,\n overridePatchMethod: false,\n headers: {},\n addRequestId: false,\n onBeforeRequest: null,\n onAfterResponse: null,\n onShouldRetry: defaultOnShouldRetry,\n chunkSize: Infinity,\n retryDelays: [0, 1000, 3000, 5000],\n parallelUploads: 1,\n parallelUploadBoundaries: null,\n storeFingerprintForResuming: true,\n removeFingerprintOnSuccess: false,\n uploadLengthDeferred: false,\n uploadDataDuringCreation: false,\n urlStorage: null,\n fileReader: null,\n httpStack: null\n};\nvar BaseUpload = /*#__PURE__*/function () {\n function BaseUpload(file, options) {\n _classCallCheck(this, BaseUpload);\n // Warn about removed options from previous versions\n if ('resume' in options) {\n // eslint-disable-next-line no-console\n console.log('tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead.');\n }\n\n // The default options will already be added from the wrapper classes.\n this.options = options;\n\n // Cast chunkSize to integer\n this.options.chunkSize = Number(this.options.chunkSize);\n\n // The storage module used to store URLs\n this._urlStorage = this.options.urlStorage;\n\n // The underlying File/Blob object\n this.file = file;\n\n // The URL against which the file will be uploaded\n this.url = null;\n\n // The underlying request object for the current PATCH request\n this._req = null;\n\n // The fingerpinrt for the current file (set after start())\n this._fingerprint = null;\n\n // The key that the URL storage returned when saving an URL with a fingerprint,\n this._urlStorageKey = null;\n\n // The offset used in the current PATCH request\n this._offset = null;\n\n // True if the current PATCH request has been aborted\n this._aborted = false;\n\n // The file's size in bytes\n this._size = null;\n\n // The Source object which will wrap around the given file and provides us\n // with a unified interface for getting its size and slice chunks from its\n // content allowing us to easily handle Files, Blobs, Buffers and Streams.\n this._source = null;\n\n // The current count of attempts which have been made. Zero indicates none.\n this._retryAttempt = 0;\n\n // The timeout's ID which is used to delay the next retry\n this._retryTimeout = null;\n\n // The offset of the remote upload before the latest attempt was started.\n this._offsetBeforeRetry = 0;\n\n // An array of BaseUpload instances which are used for uploading the different\n // parts, if the parallelUploads option is used.\n this._parallelUploads = null;\n\n // An array of upload URLs which are used for uploading the different\n // parts, if the parallelUploads option is used.\n this._parallelUploadUrls = null;\n }\n\n /**\n * Use the Termination extension to delete an upload from the server by sending a DELETE\n * request to the specified upload URL. This is only possible if the server supports the\n * Termination extension. If the `options.retryDelays` property is set, the method will\n * also retry if an error ocurrs.\n *\n * @param {String} url The upload's URL which will be terminated.\n * @param {object} options Optional options for influencing HTTP requests.\n * @return {Promise} The Promise will be resolved/rejected when the requests finish.\n */\n _createClass(BaseUpload, [{\n key: \"findPreviousUploads\",\n value: function findPreviousUploads() {\n var _this = this;\n return this.options.fingerprint(this.file, this.options).then(function (fingerprint) {\n return _this._urlStorage.findUploadsByFingerprint(fingerprint);\n });\n }\n }, {\n key: \"resumeFromPreviousUpload\",\n value: function resumeFromPreviousUpload(previousUpload) {\n this.url = previousUpload.uploadUrl || null;\n this._parallelUploadUrls = previousUpload.parallelUploadUrls || null;\n this._urlStorageKey = previousUpload.urlStorageKey;\n }\n }, {\n key: \"start\",\n value: function start() {\n var _this2 = this;\n var file = this.file;\n if (!file) {\n this._emitError(new Error('tus: no file or stream to upload provided'));\n return;\n }\n if (!this.options.endpoint && !this.options.uploadUrl && !this.url) {\n this._emitError(new Error('tus: neither an endpoint or an upload URL is provided'));\n return;\n }\n var retryDelays = this.options.retryDelays;\n if (retryDelays != null && Object.prototype.toString.call(retryDelays) !== '[object Array]') {\n this._emitError(new Error('tus: the `retryDelays` option must either be an array or null'));\n return;\n }\n if (this.options.parallelUploads > 1) {\n // Test which options are incompatible with parallel uploads.\n for (var _i = 0, _arr = ['uploadUrl', 'uploadSize', 'uploadLengthDeferred']; _i < _arr.length; _i++) {\n var optionName = _arr[_i];\n if (this.options[optionName]) {\n this._emitError(new Error(\"tus: cannot use the \".concat(optionName, \" option when parallelUploads is enabled\")));\n return;\n }\n }\n }\n if (this.options.parallelUploadBoundaries) {\n if (this.options.parallelUploads <= 1) {\n this._emitError(new Error('tus: cannot use the `parallelUploadBoundaries` option when `parallelUploads` is disabled'));\n return;\n }\n if (this.options.parallelUploads !== this.options.parallelUploadBoundaries.length) {\n this._emitError(new Error('tus: the `parallelUploadBoundaries` must have the same length as the value of `parallelUploads`'));\n return;\n }\n }\n this.options.fingerprint(file, this.options).then(function (fingerprint) {\n if (fingerprint == null) {\n log('No fingerprint was calculated meaning that the upload cannot be stored in the URL storage.');\n } else {\n log(\"Calculated fingerprint: \".concat(fingerprint));\n }\n _this2._fingerprint = fingerprint;\n if (_this2._source) {\n return _this2._source;\n }\n return _this2.options.fileReader.openFile(file, _this2.options.chunkSize);\n }).then(function (source) {\n _this2._source = source;\n\n // First, we look at the uploadLengthDeferred option.\n // Next, we check if the caller has supplied a manual upload size.\n // Finally, we try to use the calculated size from the source object.\n if (_this2.options.uploadLengthDeferred) {\n _this2._size = null;\n } else if (_this2.options.uploadSize != null) {\n _this2._size = Number(_this2.options.uploadSize);\n if (Number.isNaN(_this2._size)) {\n _this2._emitError(new Error('tus: cannot convert `uploadSize` option into a number'));\n return;\n }\n } else {\n _this2._size = _this2._source.size;\n if (_this2._size == null) {\n _this2._emitError(new Error(\"tus: cannot automatically derive upload's size from input. Specify it manually using the `uploadSize` option or use the `uploadLengthDeferred` option\"));\n return;\n }\n }\n\n // If the upload was configured to use multiple requests or if we resume from\n // an upload which used multiple requests, we start a parallel upload.\n if (_this2.options.parallelUploads > 1 || _this2._parallelUploadUrls != null) {\n _this2._startParallelUpload();\n } else {\n _this2._startSingleUpload();\n }\n })[\"catch\"](function (err) {\n _this2._emitError(err);\n });\n }\n\n /**\n * Initiate the uploading procedure for a parallelized upload, where one file is split into\n * multiple request which are run in parallel.\n *\n * @api private\n */\n }, {\n key: \"_startParallelUpload\",\n value: function _startParallelUpload() {\n var _this$options$paralle,\n _this3 = this;\n var totalSize = this._size;\n var totalProgress = 0;\n this._parallelUploads = [];\n var partCount = this._parallelUploadUrls != null ? this._parallelUploadUrls.length : this.options.parallelUploads;\n\n // The input file will be split into multiple slices which are uploaded in separate\n // requests. Here we get the start and end position for the slices.\n var parts = (_this$options$paralle = this.options.parallelUploadBoundaries) !== null && _this$options$paralle !== void 0 ? _this$options$paralle : splitSizeIntoParts(this._source.size, partCount);\n\n // Attach URLs from previous uploads, if available.\n if (this._parallelUploadUrls) {\n parts.forEach(function (part, index) {\n part.uploadUrl = _this3._parallelUploadUrls[index] || null;\n });\n }\n\n // Create an empty list for storing the upload URLs\n this._parallelUploadUrls = new Array(parts.length);\n\n // Generate a promise for each slice that will be resolve if the respective\n // upload is completed.\n var uploads = parts.map(function (part, index) {\n var lastPartProgress = 0;\n return _this3._source.slice(part.start, part.end).then(function (_ref) {\n var value = _ref.value;\n return new Promise(function (resolve, reject) {\n // Merge with the user supplied options but overwrite some values.\n var options = _objectSpread(_objectSpread({}, _this3.options), {}, {\n // If available, the partial upload should be resumed from a previous URL.\n uploadUrl: part.uploadUrl || null,\n // We take manually care of resuming for partial uploads, so they should\n // not be stored in the URL storage.\n storeFingerprintForResuming: false,\n removeFingerprintOnSuccess: false,\n // Reset the parallelUploads option to not cause recursion.\n parallelUploads: 1,\n // Reset this option as we are not doing a parallel upload.\n parallelUploadBoundaries: null,\n metadata: {},\n // Add the header to indicate the this is a partial upload.\n headers: _objectSpread(_objectSpread({}, _this3.options.headers), {}, {\n 'Upload-Concat': 'partial'\n }),\n // Reject or resolve the promise if the upload errors or completes.\n onSuccess: resolve,\n onError: reject,\n // Based in the progress for this partial upload, calculate the progress\n // for the entire final upload.\n onProgress: function onProgress(newPartProgress) {\n totalProgress = totalProgress - lastPartProgress + newPartProgress;\n lastPartProgress = newPartProgress;\n _this3._emitProgress(totalProgress, totalSize);\n },\n // Wait until every partial upload has an upload URL, so we can add\n // them to the URL storage.\n onUploadUrlAvailable: function onUploadUrlAvailable() {\n _this3._parallelUploadUrls[index] = upload.url;\n // Test if all uploads have received an URL\n if (_this3._parallelUploadUrls.filter(function (u) {\n return Boolean(u);\n }).length === parts.length) {\n _this3._saveUploadInUrlStorage();\n }\n }\n });\n var upload = new BaseUpload(value, options);\n upload.start();\n\n // Store the upload in an array, so we can later abort them if necessary.\n _this3._parallelUploads.push(upload);\n });\n });\n });\n var req;\n // Wait until all partial uploads are finished and we can send the POST request for\n // creating the final upload.\n Promise.all(uploads).then(function () {\n req = _this3._openRequest('POST', _this3.options.endpoint);\n req.setHeader('Upload-Concat', \"final;\".concat(_this3._parallelUploadUrls.join(' ')));\n\n // Add metadata if values have been added\n var metadata = encodeMetadata(_this3.options.metadata);\n if (metadata !== '') {\n req.setHeader('Upload-Metadata', metadata);\n }\n return _this3._sendRequest(req, null);\n }).then(function (res) {\n if (!inStatusCategory(res.getStatus(), 200)) {\n _this3._emitHttpError(req, res, 'tus: unexpected response while creating upload');\n return;\n }\n var location = res.getHeader('Location');\n if (location == null) {\n _this3._emitHttpError(req, res, 'tus: invalid or missing Location header');\n return;\n }\n _this3.url = resolveUrl(_this3.options.endpoint, location);\n log(\"Created upload at \".concat(_this3.url));\n _this3._emitSuccess();\n })[\"catch\"](function (err) {\n _this3._emitError(err);\n });\n }\n\n /**\n * Initiate the uploading procedure for a non-parallel upload. Here the entire file is\n * uploaded in a sequential matter.\n *\n * @api private\n */\n }, {\n key: \"_startSingleUpload\",\n value: function _startSingleUpload() {\n // Reset the aborted flag when the upload is started or else the\n // _performUpload will stop before sending a request if the upload has been\n // aborted previously.\n this._aborted = false;\n\n // The upload had been started previously and we should reuse this URL.\n if (this.url != null) {\n log(\"Resuming upload from previous URL: \".concat(this.url));\n this._resumeUpload();\n return;\n }\n\n // A URL has manually been specified, so we try to resume\n if (this.options.uploadUrl != null) {\n log(\"Resuming upload from provided URL: \".concat(this.options.uploadUrl));\n this.url = this.options.uploadUrl;\n this._resumeUpload();\n return;\n }\n\n // An upload has not started for the file yet, so we start a new one\n log('Creating a new upload');\n this._createUpload();\n }\n\n /**\n * Abort any running request and stop the current upload. After abort is called, no event\n * handler will be invoked anymore. You can use the `start` method to resume the upload\n * again.\n * If `shouldTerminate` is true, the `terminate` function will be called to remove the\n * current upload from the server.\n *\n * @param {boolean} shouldTerminate True if the upload should be deleted from the server.\n * @return {Promise} The Promise will be resolved/rejected when the requests finish.\n */\n }, {\n key: \"abort\",\n value: function abort(shouldTerminate) {\n var _this4 = this;\n // Stop any parallel partial uploads, that have been started in _startParallelUploads.\n if (this._parallelUploads != null) {\n this._parallelUploads.forEach(function (upload) {\n upload.abort(shouldTerminate);\n });\n }\n\n // Stop any current running request.\n if (this._req !== null) {\n this._req.abort();\n // Note: We do not close the file source here, so the user can resume in the future.\n }\n this._aborted = true;\n\n // Stop any timeout used for initiating a retry.\n if (this._retryTimeout != null) {\n clearTimeout(this._retryTimeout);\n this._retryTimeout = null;\n }\n if (!shouldTerminate || this.url == null) {\n return Promise.resolve();\n }\n return BaseUpload.terminate(this.url, this.options)\n // Remove entry from the URL storage since the upload URL is no longer valid.\n .then(function () {\n return _this4._removeFromUrlStorage();\n });\n }\n }, {\n key: \"_emitHttpError\",\n value: function _emitHttpError(req, res, message, causingErr) {\n this._emitError(new DetailedError(message, causingErr, req, res));\n }\n }, {\n key: \"_emitError\",\n value: function _emitError(err) {\n var _this5 = this;\n // Do not emit errors, e.g. from aborted HTTP requests, if the upload has been stopped.\n if (this._aborted) return;\n\n // Check if we should retry, when enabled, before sending the error to the user.\n if (this.options.retryDelays != null) {\n // We will reset the attempt counter if\n // - we were already able to connect to the server (offset != null) and\n // - we were able to upload a small chunk of data to the server\n var shouldResetDelays = this._offset != null && this._offset > this._offsetBeforeRetry;\n if (shouldResetDelays) {\n this._retryAttempt = 0;\n }\n if (shouldRetry(err, this._retryAttempt, this.options)) {\n var delay = this.options.retryDelays[this._retryAttempt++];\n this._offsetBeforeRetry = this._offset;\n this._retryTimeout = setTimeout(function () {\n _this5.start();\n }, delay);\n return;\n }\n }\n if (typeof this.options.onError === 'function') {\n this.options.onError(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Publishes notification if the upload has been successfully completed.\n *\n * @api private\n */\n }, {\n key: \"_emitSuccess\",\n value: function _emitSuccess() {\n if (this.options.removeFingerprintOnSuccess) {\n // Remove stored fingerprint and corresponding endpoint. This causes\n // new uploads of the same file to be treated as a different file.\n this._removeFromUrlStorage();\n }\n if (typeof this.options.onSuccess === 'function') {\n this.options.onSuccess();\n }\n }\n\n /**\n * Publishes notification when data has been sent to the server. This\n * data may not have been accepted by the server yet.\n *\n * @param {number} bytesSent Number of bytes sent to the server.\n * @param {number} bytesTotal Total number of bytes to be sent to the server.\n * @api private\n */\n }, {\n key: \"_emitProgress\",\n value: function _emitProgress(bytesSent, bytesTotal) {\n if (typeof this.options.onProgress === 'function') {\n this.options.onProgress(bytesSent, bytesTotal);\n }\n }\n\n /**\n * Publishes notification when a chunk of data has been sent to the server\n * and accepted by the server.\n * @param {number} chunkSize Size of the chunk that was accepted by the server.\n * @param {number} bytesAccepted Total number of bytes that have been\n * accepted by the server.\n * @param {number} bytesTotal Total number of bytes to be sent to the server.\n * @api private\n */\n }, {\n key: \"_emitChunkComplete\",\n value: function _emitChunkComplete(chunkSize, bytesAccepted, bytesTotal) {\n if (typeof this.options.onChunkComplete === 'function') {\n this.options.onChunkComplete(chunkSize, bytesAccepted, bytesTotal);\n }\n }\n\n /**\n * Create a new upload using the creation extension by sending a POST\n * request to the endpoint. After successful creation the file will be\n * uploaded\n *\n * @api private\n */\n }, {\n key: \"_createUpload\",\n value: function _createUpload() {\n var _this6 = this;\n if (!this.options.endpoint) {\n this._emitError(new Error('tus: unable to create upload because no endpoint is provided'));\n return;\n }\n var req = this._openRequest('POST', this.options.endpoint);\n if (this.options.uploadLengthDeferred) {\n req.setHeader('Upload-Defer-Length', 1);\n } else {\n req.setHeader('Upload-Length', this._size);\n }\n\n // Add metadata if values have been added\n var metadata = encodeMetadata(this.options.metadata);\n if (metadata !== '') {\n req.setHeader('Upload-Metadata', metadata);\n }\n var promise;\n if (this.options.uploadDataDuringCreation && !this.options.uploadLengthDeferred) {\n this._offset = 0;\n promise = this._addChunkToRequest(req);\n } else {\n promise = this._sendRequest(req, null);\n }\n promise.then(function (res) {\n if (!inStatusCategory(res.getStatus(), 200)) {\n _this6._emitHttpError(req, res, 'tus: unexpected response while creating upload');\n return;\n }\n var location = res.getHeader('Location');\n if (location == null) {\n _this6._emitHttpError(req, res, 'tus: invalid or missing Location header');\n return;\n }\n _this6.url = resolveUrl(_this6.options.endpoint, location);\n log(\"Created upload at \".concat(_this6.url));\n if (typeof _this6.options.onUploadUrlAvailable === 'function') {\n _this6.options.onUploadUrlAvailable();\n }\n if (_this6._size === 0) {\n // Nothing to upload and file was successfully created\n _this6._emitSuccess();\n _this6._source.close();\n return;\n }\n _this6._saveUploadInUrlStorage().then(function () {\n if (_this6.options.uploadDataDuringCreation) {\n _this6._handleUploadResponse(req, res);\n } else {\n _this6._offset = 0;\n _this6._performUpload();\n }\n });\n })[\"catch\"](function (err) {\n _this6._emitHttpError(req, null, 'tus: failed to create upload', err);\n });\n }\n\n /*\n * Try to resume an existing upload. First a HEAD request will be sent\n * to retrieve the offset. If the request fails a new upload will be\n * created. In the case of a successful response the file will be uploaded.\n *\n * @api private\n */\n }, {\n key: \"_resumeUpload\",\n value: function _resumeUpload() {\n var _this7 = this;\n var req = this._openRequest('HEAD', this.url);\n var promise = this._sendRequest(req, null);\n promise.then(function (res) {\n var status = res.getStatus();\n if (!inStatusCategory(status, 200)) {\n // If the upload is locked (indicated by the 423 Locked status code), we\n // emit an error instead of directly starting a new upload. This way the\n // retry logic can catch the error and will retry the upload. An upload\n // is usually locked for a short period of time and will be available\n // afterwards.\n if (status === 423) {\n _this7._emitHttpError(req, res, 'tus: upload is currently locked; retry later');\n return;\n }\n if (inStatusCategory(status, 400)) {\n // Remove stored fingerprint and corresponding endpoint,\n // on client errors since the file can not be found\n _this7._removeFromUrlStorage();\n }\n if (!_this7.options.endpoint) {\n // Don't attempt to create a new upload if no endpoint is provided.\n _this7._emitHttpError(req, res, 'tus: unable to resume upload (new upload cannot be created without an endpoint)');\n return;\n }\n\n // Try to create a new upload\n _this7.url = null;\n _this7._createUpload();\n return;\n }\n var offset = parseInt(res.getHeader('Upload-Offset'), 10);\n if (Number.isNaN(offset)) {\n _this7._emitHttpError(req, res, 'tus: invalid or missing offset value');\n return;\n }\n var length = parseInt(res.getHeader('Upload-Length'), 10);\n if (Number.isNaN(length) && !_this7.options.uploadLengthDeferred) {\n _this7._emitHttpError(req, res, 'tus: invalid or missing length value');\n return;\n }\n if (typeof _this7.options.onUploadUrlAvailable === 'function') {\n _this7.options.onUploadUrlAvailable();\n }\n _this7._saveUploadInUrlStorage().then(function () {\n // Upload has already been completed and we do not need to send additional\n // data to the server\n if (offset === length) {\n _this7._emitProgress(length, length);\n _this7._emitSuccess();\n return;\n }\n _this7._offset = offset;\n _this7._performUpload();\n });\n })[\"catch\"](function (err) {\n _this7._emitHttpError(req, null, 'tus: failed to resume upload', err);\n });\n }\n\n /**\n * Start uploading the file using PATCH requests. The file will be divided\n * into chunks as specified in the chunkSize option. During the upload\n * the onProgress event handler may be invoked multiple times.\n *\n * @api private\n */\n }, {\n key: \"_performUpload\",\n value: function _performUpload() {\n var _this8 = this;\n // If the upload has been aborted, we will not send the next PATCH request.\n // This is important if the abort method was called during a callback, such\n // as onChunkComplete or onProgress.\n if (this._aborted) {\n return;\n }\n var req;\n\n // Some browser and servers may not support the PATCH method. For those\n // cases, you can tell tus-js-client to use a POST request with the\n // X-HTTP-Method-Override header for simulating a PATCH request.\n if (this.options.overridePatchMethod) {\n req = this._openRequest('POST', this.url);\n req.setHeader('X-HTTP-Method-Override', 'PATCH');\n } else {\n req = this._openRequest('PATCH', this.url);\n }\n req.setHeader('Upload-Offset', this._offset);\n var promise = this._addChunkToRequest(req);\n promise.then(function (res) {\n if (!inStatusCategory(res.getStatus(), 200)) {\n _this8._emitHttpError(req, res, 'tus: unexpected response while uploading chunk');\n return;\n }\n _this8._handleUploadResponse(req, res);\n })[\"catch\"](function (err) {\n // Don't emit an error if the upload was aborted manually\n if (_this8._aborted) {\n return;\n }\n _this8._emitHttpError(req, null, \"tus: failed to upload chunk at offset \".concat(_this8._offset), err);\n });\n }\n\n /**\n * _addChunktoRequest reads a chunk from the source and sends it using the\n * supplied request object. It will not handle the response.\n *\n * @api private\n */\n }, {\n key: \"_addChunkToRequest\",\n value: function _addChunkToRequest(req) {\n var _this9 = this;\n var start = this._offset;\n var end = this._offset + this.options.chunkSize;\n req.setProgressHandler(function (bytesSent) {\n _this9._emitProgress(start + bytesSent, _this9._size);\n });\n req.setHeader('Content-Type', 'application/offset+octet-stream');\n\n // The specified chunkSize may be Infinity or the calcluated end position\n // may exceed the file's size. In both cases, we limit the end position to\n // the input's total size for simpler calculations and correctness.\n if ((end === Infinity || end > this._size) && !this.options.uploadLengthDeferred) {\n end = this._size;\n }\n return this._source.slice(start, end).then(function (_ref2) {\n var value = _ref2.value,\n done = _ref2.done;\n var valueSize = value && value.size ? value.size : 0;\n\n // If the upload length is deferred, the upload size was not specified during\n // upload creation. So, if the file reader is done reading, we know the total\n // upload size and can tell the tus server.\n if (_this9.options.uploadLengthDeferred && done) {\n _this9._size = _this9._offset + valueSize;\n req.setHeader('Upload-Length', _this9._size);\n }\n\n // The specified uploadSize might not match the actual amount of data that a source\n // provides. In these cases, we cannot successfully complete the upload, so we\n // rather error out and let the user know. If not, tus-js-client will be stuck\n // in a loop of repeating empty PATCH requests.\n // See https://community.transloadit.com/t/how-to-abort-hanging-companion-uploads/16488/13\n var newSize = _this9._offset + valueSize;\n if (!_this9.options.uploadLengthDeferred && done && newSize !== _this9._size) {\n return Promise.reject(new Error(\"upload was configured with a size of \".concat(_this9._size, \" bytes, but the source is done after \").concat(newSize, \" bytes\")));\n }\n if (value === null) {\n return _this9._sendRequest(req);\n }\n _this9._emitProgress(_this9._offset, _this9._size);\n return _this9._sendRequest(req, value);\n });\n }\n\n /**\n * _handleUploadResponse is used by requests that haven been sent using _addChunkToRequest\n * and already have received a response.\n *\n * @api private\n */\n }, {\n key: \"_handleUploadResponse\",\n value: function _handleUploadResponse(req, res) {\n var offset = parseInt(res.getHeader('Upload-Offset'), 10);\n if (Number.isNaN(offset)) {\n this._emitHttpError(req, res, 'tus: invalid or missing offset value');\n return;\n }\n this._emitProgress(offset, this._size);\n this._emitChunkComplete(offset - this._offset, offset, this._size);\n this._offset = offset;\n if (offset === this._size) {\n // Yay, finally done :)\n this._emitSuccess();\n this._source.close();\n return;\n }\n this._performUpload();\n }\n\n /**\n * Create a new HTTP request object with the given method and URL.\n *\n * @api private\n */\n }, {\n key: \"_openRequest\",\n value: function _openRequest(method, url) {\n var req = openRequest(method, url, this.options);\n this._req = req;\n return req;\n }\n\n /**\n * Remove the entry in the URL storage, if it has been saved before.\n *\n * @api private\n */\n }, {\n key: \"_removeFromUrlStorage\",\n value: function _removeFromUrlStorage() {\n var _this10 = this;\n if (!this._urlStorageKey) return;\n this._urlStorage.removeUpload(this._urlStorageKey)[\"catch\"](function (err) {\n _this10._emitError(err);\n });\n this._urlStorageKey = null;\n }\n\n /**\n * Add the upload URL to the URL storage, if possible.\n *\n * @api private\n */\n }, {\n key: \"_saveUploadInUrlStorage\",\n value: function _saveUploadInUrlStorage() {\n var _this11 = this;\n // We do not store the upload URL\n // - if it was disabled in the option, or\n // - if no fingerprint was calculated for the input (i.e. a stream), or\n // - if the URL is already stored (i.e. key is set alread).\n if (!this.options.storeFingerprintForResuming || !this._fingerprint || this._urlStorageKey !== null) {\n return Promise.resolve();\n }\n var storedUpload = {\n size: this._size,\n metadata: this.options.metadata,\n creationTime: new Date().toString()\n };\n if (this._parallelUploads) {\n // Save multiple URLs if the parallelUploads option is used ...\n storedUpload.parallelUploadUrls = this._parallelUploadUrls;\n } else {\n // ... otherwise we just save the one available URL.\n storedUpload.uploadUrl = this.url;\n }\n return this._urlStorage.addUpload(this._fingerprint, storedUpload).then(function (urlStorageKey) {\n _this11._urlStorageKey = urlStorageKey;\n });\n }\n\n /**\n * Send a request with the provided body.\n *\n * @api private\n */\n }, {\n key: \"_sendRequest\",\n value: function _sendRequest(req) {\n var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return sendRequest(req, body, this.options);\n }\n }], [{\n key: \"terminate\",\n value: function terminate(url) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var req = openRequest('DELETE', url, options);\n return sendRequest(req, null, options).then(function (res) {\n // A 204 response indicates a successfull request\n if (res.getStatus() === 204) {\n return;\n }\n throw new DetailedError('tus: unexpected response while terminating upload', null, req, res);\n })[\"catch\"](function (err) {\n if (!(err instanceof DetailedError)) {\n err = new DetailedError('tus: failed to terminate upload', err, req, null);\n }\n if (!shouldRetry(err, 0, options)) {\n throw err;\n }\n\n // Instead of keeping track of the retry attempts, we remove the first element from the delays\n // array. If the array is empty, all retry attempts are used up and we will bubble up the error.\n // We recursively call the terminate function will removing elements from the retryDelays array.\n var delay = options.retryDelays[0];\n var remainingDelays = options.retryDelays.slice(1);\n var newOptions = _objectSpread(_objectSpread({}, options), {}, {\n retryDelays: remainingDelays\n });\n return new Promise(function (resolve) {\n return setTimeout(resolve, delay);\n }).then(function () {\n return BaseUpload.terminate(url, newOptions);\n });\n });\n }\n }]);\n return BaseUpload;\n}();\nfunction encodeMetadata(metadata) {\n return Object.entries(metadata).map(function (_ref3) {\n var _ref4 = _slicedToArray(_ref3, 2),\n key = _ref4[0],\n value = _ref4[1];\n return \"\".concat(key, \" \").concat(Base64.encode(String(value)));\n }).join(',');\n}\n\n/**\n * Checks whether a given status is in the range of the expected category.\n * For example, only a status between 200 and 299 will satisfy the category 200.\n *\n * @api private\n */\nfunction inStatusCategory(status, category) {\n return status >= category && status < category + 100;\n}\n\n/**\n * Create a new HTTP request with the specified method and URL.\n * The necessary headers that are included in every request\n * will be added, including the request ID.\n *\n * @api private\n */\nfunction openRequest(method, url, options) {\n var req = options.httpStack.createRequest(method, url);\n req.setHeader('Tus-Resumable', '1.0.0');\n var headers = options.headers || {};\n Object.entries(headers).forEach(function (_ref5) {\n var _ref6 = _slicedToArray(_ref5, 2),\n name = _ref6[0],\n value = _ref6[1];\n req.setHeader(name, value);\n });\n if (options.addRequestId) {\n var requestId = uuid();\n req.setHeader('X-Request-ID', requestId);\n }\n return req;\n}\n\n/**\n * Send a request with the provided body while invoking the onBeforeRequest\n * and onAfterResponse callbacks.\n *\n * @api private\n */\nfunction sendRequest(_x, _x2, _x3) {\n return _sendRequest2.apply(this, arguments);\n}\n/**\n * Checks whether the browser running this code has internet access.\n * This function will always return true in the node.js environment\n *\n * @api private\n */\nfunction _sendRequest2() {\n _sendRequest2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, body, options) {\n var res;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (!(typeof options.onBeforeRequest === 'function')) {\n _context.next = 3;\n break;\n }\n _context.next = 3;\n return options.onBeforeRequest(req);\n case 3:\n _context.next = 5;\n return req.send(body);\n case 5:\n res = _context.sent;\n if (!(typeof options.onAfterResponse === 'function')) {\n _context.next = 9;\n break;\n }\n _context.next = 9;\n return options.onAfterResponse(req, res);\n case 9:\n return _context.abrupt(\"return\", res);\n case 10:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return _sendRequest2.apply(this, arguments);\n}\nfunction isOnline() {\n var online = true;\n if (typeof window !== 'undefined' &&\n // eslint-disable-next-line no-undef\n 'navigator' in window &&\n // eslint-disable-next-line no-undef\n window.navigator.onLine === false) {\n // eslint-disable-line no-undef\n online = false;\n }\n return online;\n}\n\n/**\n * Checks whether or not it is ok to retry a request.\n * @param {Error|DetailedError} err the error returned from the last request\n * @param {number} retryAttempt the number of times the request has already been retried\n * @param {object} options tus Upload options\n *\n * @api private\n */\nfunction shouldRetry(err, retryAttempt, options) {\n // We only attempt a retry if\n // - retryDelays option is set\n // - we didn't exceed the maxium number of retries, yet, and\n // - this error was caused by a request or it's response and\n // - the error is server error (i.e. not a status 4xx except a 409 or 423) or\n // a onShouldRetry is specified and returns true\n // - the browser does not indicate that we are offline\n if (options.retryDelays == null || retryAttempt >= options.retryDelays.length || err.originalRequest == null) {\n return false;\n }\n if (options && typeof options.onShouldRetry === 'function') {\n return options.onShouldRetry(err, retryAttempt, options);\n }\n return defaultOnShouldRetry(err);\n}\n\n/**\n * determines if the request should be retried. Will only retry if not a status 4xx except a 409 or 423\n * @param {DetailedError} err\n * @returns {boolean}\n */\nfunction defaultOnShouldRetry(err) {\n var status = err.originalResponse ? err.originalResponse.getStatus() : 0;\n return (!inStatusCategory(status, 400) || status === 409 || status === 423) && isOnline();\n}\n\n/**\n * Resolve a relative link given the origin as source. For example,\n * if a HTTP request to http://example.com/files/ returns a Location\n * header with the value /upload/abc, the resolved URL will be:\n * http://example.com/upload/abc\n */\nfunction resolveUrl(origin, link) {\n return new URL(link, origin).toString();\n}\n\n/**\n * Calculate the start and end positions for the parts if an upload\n * is split into multiple parallel requests.\n *\n * @param {number} totalSize The byte size of the upload, which will be split.\n * @param {number} partCount The number in how many parts the upload will be split.\n * @return {object[]}\n * @api private\n */\nfunction splitSizeIntoParts(totalSize, partCount) {\n var partSize = Math.floor(totalSize / partCount);\n var parts = [];\n for (var i = 0; i < partCount; i++) {\n parts.push({\n start: partSize * i,\n end: partSize * (i + 1)\n });\n }\n parts[partCount - 1].end = totalSize;\n return parts;\n}\nBaseUpload.defaultOptions = defaultOptions;\nexport default BaseUpload;","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\n/* eslint no-unused-vars: \"off\" */\nvar NoopUrlStorage = /*#__PURE__*/function () {\n function NoopUrlStorage() {\n _classCallCheck(this, NoopUrlStorage);\n }\n _createClass(NoopUrlStorage, [{\n key: \"listAllUploads\",\n value: function listAllUploads() {\n return Promise.resolve([]);\n }\n }, {\n key: \"findUploadsByFingerprint\",\n value: function findUploadsByFingerprint(fingerprint) {\n return Promise.resolve([]);\n }\n }, {\n key: \"removeUpload\",\n value: function removeUpload(urlStorageKey) {\n return Promise.resolve();\n }\n }, {\n key: \"addUpload\",\n value: function addUpload(fingerprint, upload) {\n return Promise.resolve(null);\n }\n }]);\n return NoopUrlStorage;\n}();\nexport { NoopUrlStorage as default };","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar hasStorage = false;\ntry {\n hasStorage = 'localStorage' in window;\n\n // Attempt to store and read entries from the local storage to detect Private\n // Mode on Safari on iOS (see #49)\n // If the key was not used before, we remove it from local storage again to\n // not cause confusion where the entry came from.\n var key = 'tusSupport';\n var originalValue = localStorage.getItem(key);\n localStorage.setItem(key, originalValue);\n if (originalValue === null) localStorage.removeItem(key);\n} catch (e) {\n // If we try to access localStorage inside a sandboxed iframe, a SecurityError\n // is thrown. When in private mode on iOS Safari, a QuotaExceededError is\n // thrown (see #49)\n if (e.code === e.SECURITY_ERR || e.code === e.QUOTA_EXCEEDED_ERR) {\n hasStorage = false;\n } else {\n throw e;\n }\n}\nexport var canStoreURLs = hasStorage;\nexport var WebStorageUrlStorage = /*#__PURE__*/function () {\n function WebStorageUrlStorage() {\n _classCallCheck(this, WebStorageUrlStorage);\n }\n _createClass(WebStorageUrlStorage, [{\n key: \"findAllUploads\",\n value: function findAllUploads() {\n var results = this._findEntries('tus::');\n return Promise.resolve(results);\n }\n }, {\n key: \"findUploadsByFingerprint\",\n value: function findUploadsByFingerprint(fingerprint) {\n var results = this._findEntries(\"tus::\".concat(fingerprint, \"::\"));\n return Promise.resolve(results);\n }\n }, {\n key: \"removeUpload\",\n value: function removeUpload(urlStorageKey) {\n localStorage.removeItem(urlStorageKey);\n return Promise.resolve();\n }\n }, {\n key: \"addUpload\",\n value: function addUpload(fingerprint, upload) {\n var id = Math.round(Math.random() * 1e12);\n var key = \"tus::\".concat(fingerprint, \"::\").concat(id);\n localStorage.setItem(key, JSON.stringify(upload));\n return Promise.resolve(key);\n }\n }, {\n key: \"_findEntries\",\n value: function _findEntries(prefix) {\n var results = [];\n for (var i = 0; i < localStorage.length; i++) {\n var _key = localStorage.key(i);\n if (_key.indexOf(prefix) !== 0) continue;\n try {\n var upload = JSON.parse(localStorage.getItem(_key));\n upload.urlStorageKey = _key;\n results.push(upload);\n } catch (e) {\n // The JSON parse error is intentionally ignored here, so a malformed\n // entry in the storage cannot prevent an upload.\n }\n }\n return results;\n }\n }]);\n return WebStorageUrlStorage;\n}();","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\n/* eslint-disable max-classes-per-file */\nvar XHRHttpStack = /*#__PURE__*/function () {\n function XHRHttpStack() {\n _classCallCheck(this, XHRHttpStack);\n }\n _createClass(XHRHttpStack, [{\n key: \"createRequest\",\n value: function createRequest(method, url) {\n return new Request(method, url);\n }\n }, {\n key: \"getName\",\n value: function getName() {\n return 'XHRHttpStack';\n }\n }]);\n return XHRHttpStack;\n}();\nexport { XHRHttpStack as default };\nvar Request = /*#__PURE__*/function () {\n function Request(method, url) {\n _classCallCheck(this, Request);\n this._xhr = new XMLHttpRequest();\n this._xhr.open(method, url, true);\n this._method = method;\n this._url = url;\n this._headers = {};\n }\n _createClass(Request, [{\n key: \"getMethod\",\n value: function getMethod() {\n return this._method;\n }\n }, {\n key: \"getURL\",\n value: function getURL() {\n return this._url;\n }\n }, {\n key: \"setHeader\",\n value: function setHeader(header, value) {\n this._xhr.setRequestHeader(header, value);\n this._headers[header] = value;\n }\n }, {\n key: \"getHeader\",\n value: function getHeader(header) {\n return this._headers[header];\n }\n }, {\n key: \"setProgressHandler\",\n value: function setProgressHandler(progressHandler) {\n // Test support for progress events before attaching an event listener\n if (!('upload' in this._xhr)) {\n return;\n }\n this._xhr.upload.onprogress = function (e) {\n if (!e.lengthComputable) {\n return;\n }\n progressHandler(e.loaded);\n };\n }\n }, {\n key: \"send\",\n value: function send() {\n var _this = this;\n var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n return new Promise(function (resolve, reject) {\n _this._xhr.onload = function () {\n resolve(new Response(_this._xhr));\n };\n _this._xhr.onerror = function (err) {\n reject(err);\n };\n _this._xhr.send(body);\n });\n }\n }, {\n key: \"abort\",\n value: function abort() {\n this._xhr.abort();\n return Promise.resolve();\n }\n }, {\n key: \"getUnderlyingObject\",\n value: function getUnderlyingObject() {\n return this._xhr;\n }\n }]);\n return Request;\n}();\nvar Response = /*#__PURE__*/function () {\n function Response(xhr) {\n _classCallCheck(this, Response);\n this._xhr = xhr;\n }\n _createClass(Response, [{\n key: \"getStatus\",\n value: function getStatus() {\n return this._xhr.status;\n }\n }, {\n key: \"getHeader\",\n value: function getHeader(header) {\n return this._xhr.getResponseHeader(header);\n }\n }, {\n key: \"getBody\",\n value: function getBody() {\n return this._xhr.responseText;\n }\n }, {\n key: \"getUnderlyingObject\",\n value: function getUnderlyingObject() {\n return this._xhr;\n }\n }]);\n return Response;\n}();","var isReactNative = function isReactNative() {\n return typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative';\n};\nexport default isReactNative;","/**\n * uriToBlob resolves a URI to a Blob object. This is used for\n * React Native to retrieve a file (identified by a file://\n * URI) as a blob.\n */\nexport default function uriToBlob(uri) {\n return new Promise(function (resolve, reject) {\n var xhr = new XMLHttpRequest();\n xhr.responseType = 'blob';\n xhr.onload = function () {\n var blob = xhr.response;\n resolve(blob);\n };\n xhr.onerror = function (err) {\n reject(err);\n };\n xhr.open('GET', uri);\n xhr.send();\n });\n}","var isCordova = function isCordova() {\n return typeof window !== 'undefined' && (typeof window.PhoneGap !== 'undefined' || typeof window.Cordova !== 'undefined' || typeof window.cordova !== 'undefined');\n};\nexport default isCordova;","/**\n * readAsByteArray converts a File object to a Uint8Array.\n * This function is only used on the Apache Cordova platform.\n * See https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/index.html#read-a-file\n */\nexport default function readAsByteArray(chunk) {\n return new Promise(function (resolve, reject) {\n var reader = new FileReader();\n reader.onload = function () {\n var value = new Uint8Array(reader.result);\n resolve({\n value: value\n });\n };\n reader.onerror = function (err) {\n reject(err);\n };\n reader.readAsArrayBuffer(chunk);\n });\n}","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport isCordova from './isCordova.js';\nimport readAsByteArray from './readAsByteArray.js';\nvar FileSource = /*#__PURE__*/function () {\n // Make this.size a method\n function FileSource(file) {\n _classCallCheck(this, FileSource);\n this._file = file;\n this.size = file.size;\n }\n _createClass(FileSource, [{\n key: \"slice\",\n value: function slice(start, end) {\n // In Apache Cordova applications, a File must be resolved using\n // FileReader instances, see\n // https://cordova.apache.org/docs/en/8.x/reference/cordova-plugin-file/index.html#read-a-file\n if (isCordova()) {\n return readAsByteArray(this._file.slice(start, end));\n }\n var value = this._file.slice(start, end);\n var done = end >= this.size;\n return Promise.resolve({\n value: value,\n done: done\n });\n }\n }, {\n key: \"close\",\n value: function close() {\n // Nothing to do here since we don't need to release any resources.\n }\n }]);\n return FileSource;\n}();\nexport { FileSource as default };","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction len(blobOrArray) {\n if (blobOrArray === undefined) return 0;\n if (blobOrArray.size !== undefined) return blobOrArray.size;\n return blobOrArray.length;\n}\n\n/*\n Typed arrays and blobs don't have a concat method.\n This function helps StreamSource accumulate data to reach chunkSize.\n*/\nfunction concat(a, b) {\n if (a.concat) {\n // Is `a` an Array?\n return a.concat(b);\n }\n if (a instanceof Blob) {\n return new Blob([a, b], {\n type: a.type\n });\n }\n if (a.set) {\n // Is `a` a typed array?\n var c = new a.constructor(a.length + b.length);\n c.set(a);\n c.set(b, a.length);\n return c;\n }\n throw new Error('Unknown data type');\n}\nvar StreamSource = /*#__PURE__*/function () {\n function StreamSource(reader) {\n _classCallCheck(this, StreamSource);\n this._buffer = undefined;\n this._bufferOffset = 0;\n this._reader = reader;\n this._done = false;\n }\n _createClass(StreamSource, [{\n key: \"slice\",\n value: function slice(start, end) {\n if (start < this._bufferOffset) {\n return Promise.reject(new Error(\"Requested data is before the reader's current offset\"));\n }\n return this._readUntilEnoughDataOrDone(start, end);\n }\n }, {\n key: \"_readUntilEnoughDataOrDone\",\n value: function _readUntilEnoughDataOrDone(start, end) {\n var _this = this;\n var hasEnoughData = end <= this._bufferOffset + len(this._buffer);\n if (this._done || hasEnoughData) {\n var value = this._getDataFromBuffer(start, end);\n var done = value == null ? this._done : false;\n return Promise.resolve({\n value: value,\n done: done\n });\n }\n return this._reader.read().then(function (_ref) {\n var value = _ref.value,\n done = _ref.done;\n if (done) {\n _this._done = true;\n } else if (_this._buffer === undefined) {\n _this._buffer = value;\n } else {\n _this._buffer = concat(_this._buffer, value);\n }\n return _this._readUntilEnoughDataOrDone(start, end);\n });\n }\n }, {\n key: \"_getDataFromBuffer\",\n value: function _getDataFromBuffer(start, end) {\n // Remove data from buffer before `start`.\n // Data might be reread from the buffer if an upload fails, so we can only\n // safely delete data when it comes *before* what is currently being read.\n if (start > this._bufferOffset) {\n this._buffer = this._buffer.slice(start - this._bufferOffset);\n this._bufferOffset = start;\n }\n // If the buffer is empty after removing old data, all data has been read.\n var hasAllDataBeenRead = len(this._buffer) === 0;\n if (this._done && hasAllDataBeenRead) {\n return null;\n }\n // We already removed data before `start`, so we just return the first\n // chunk from the buffer.\n return this._buffer.slice(0, end - start);\n }\n }, {\n key: \"close\",\n value: function close() {\n if (this._reader.cancel) {\n this._reader.cancel();\n }\n }\n }]);\n return StreamSource;\n}();\nexport { StreamSource as default };","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport isReactNative from './isReactNative.js';\nimport uriToBlob from './uriToBlob.js';\nimport FileSource from './sources/FileSource.js';\nimport StreamSource from './sources/StreamSource.js';\nvar FileReader = /*#__PURE__*/function () {\n function FileReader() {\n _classCallCheck(this, FileReader);\n }\n _createClass(FileReader, [{\n key: \"openFile\",\n value: function () {\n var _openFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input, chunkSize) {\n var blob;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (!(isReactNative() && input && typeof input.uri !== 'undefined')) {\n _context.next = 11;\n break;\n }\n _context.prev = 1;\n _context.next = 4;\n return uriToBlob(input.uri);\n case 4:\n blob = _context.sent;\n return _context.abrupt(\"return\", new FileSource(blob));\n case 8:\n _context.prev = 8;\n _context.t0 = _context[\"catch\"](1);\n throw new Error(\"tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. \".concat(_context.t0));\n case 11:\n if (!(typeof input.slice === 'function' && typeof input.size !== 'undefined')) {\n _context.next = 13;\n break;\n }\n return _context.abrupt(\"return\", Promise.resolve(new FileSource(input)));\n case 13:\n if (!(typeof input.read === 'function')) {\n _context.next = 18;\n break;\n }\n chunkSize = Number(chunkSize);\n if (Number.isFinite(chunkSize)) {\n _context.next = 17;\n break;\n }\n return _context.abrupt(\"return\", Promise.reject(new Error('cannot create source for stream without a finite value for the `chunkSize` option')));\n case 17:\n return _context.abrupt(\"return\", Promise.resolve(new StreamSource(input, chunkSize)));\n case 18:\n return _context.abrupt(\"return\", Promise.reject(new Error('source object may only be an instance of File, Blob, or Reader in this environment')));\n case 19:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[1, 8]]);\n }));\n function openFile(_x, _x2) {\n return _openFile.apply(this, arguments);\n }\n return openFile;\n }()\n }]);\n return FileReader;\n}();\nexport { FileReader as default };","import isReactNative from './isReactNative.js';\n\n// TODO: Differenciate between input types\n\n/**\n * Generate a fingerprint for a file which will be used the store the endpoint\n *\n * @param {File} file\n * @param {Object} options\n * @param {Function} callback\n */\nexport default function fingerprint(file, options) {\n if (isReactNative()) {\n return Promise.resolve(reactNativeFingerprint(file, options));\n }\n return Promise.resolve(['tus-br', file.name, file.type, file.size, file.lastModified, options.endpoint].join('-'));\n}\nfunction reactNativeFingerprint(file, options) {\n var exifHash = file.exif ? hashCode(JSON.stringify(file.exif)) : 'noexif';\n return ['tus-rn', file.name || 'noname', file.size || 'nosize', exifHash, options.endpoint].join('/');\n}\nfunction hashCode(str) {\n /* eslint-disable no-bitwise */\n // from https://stackoverflow.com/a/8831937/151666\n var hash = 0;\n if (str.length === 0) {\n return hash;\n }\n for (var i = 0; i < str.length; i++) {\n var _char = str.charCodeAt(i);\n hash = (hash << 5) - hash + _char;\n hash &= hash; // Convert to 32bit integer\n }\n return hash;\n}","function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport BaseUpload from '../upload.js';\nimport NoopUrlStorage from '../noopUrlStorage.js';\nimport { enableDebugLog } from '../logger.js';\nimport DetailedError from '../error.js';\nimport { canStoreURLs, WebStorageUrlStorage } from './urlStorage.js';\nimport DefaultHttpStack from './httpStack.js';\nimport FileReader from './fileReader.js';\nimport fingerprint from './fileSignature.js';\nvar defaultOptions = _objectSpread(_objectSpread({}, BaseUpload.defaultOptions), {}, {\n httpStack: new DefaultHttpStack(),\n fileReader: new FileReader(),\n urlStorage: canStoreURLs ? new WebStorageUrlStorage() : new NoopUrlStorage(),\n fingerprint: fingerprint\n});\nvar Upload = /*#__PURE__*/function (_BaseUpload) {\n _inherits(Upload, _BaseUpload);\n var _super = _createSuper(Upload);\n function Upload() {\n var file = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck(this, Upload);\n options = _objectSpread(_objectSpread({}, defaultOptions), options);\n return _super.call(this, file, options);\n }\n _createClass(Upload, null, [{\n key: \"terminate\",\n value: function terminate(url) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n options = _objectSpread(_objectSpread({}, defaultOptions), options);\n return BaseUpload.terminate(url, options);\n }\n }]);\n return Upload;\n}(BaseUpload);\nvar _window = window,\n XMLHttpRequest = _window.XMLHttpRequest,\n Blob = _window.Blob;\nvar isSupported = XMLHttpRequest && Blob && typeof Blob.prototype.slice === 'function';\nexport { Upload, canStoreURLs, defaultOptions, isSupported, enableDebugLog, DefaultHttpStack, DetailedError };","\n \n