uploadzx
Version:
Browser-only TypeScript upload library with tus integration for resumable uploads
1,320 lines (1,308 loc) • 152 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js
var require_requires_port = __commonJS({
"node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.js"(exports, module) {
module.exports = function required(port, protocol) {
protocol = protocol.split(":")[0];
port = +port;
if (!port) return false;
switch (protocol) {
case "http":
case "ws":
return port !== 80;
case "https":
case "wss":
return port !== 443;
case "ftp":
return port !== 21;
case "gopher":
return port !== 70;
case "file":
return false;
}
return port !== 0;
};
}
});
// node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js
var require_querystringify = __commonJS({
"node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js"(exports) {
var has = Object.prototype.hasOwnProperty;
var undef;
function decode2(input) {
try {
return decodeURIComponent(input.replace(/\+/g, " "));
} catch (e) {
return null;
}
}
function encode2(input) {
try {
return encodeURIComponent(input);
} catch (e) {
return null;
}
}
function querystring(query) {
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
while (part = parser.exec(query)) {
var key = decode2(part[1]), value = decode2(part[2]);
if (key === null || value === null || key in result) continue;
result[key] = value;
}
return result;
}
function querystringify(obj, prefix) {
prefix = prefix || "";
var pairs = [], value, key;
if ("string" !== typeof prefix) prefix = "?";
for (key in obj) {
if (has.call(obj, key)) {
value = obj[key];
if (!value && (value === null || value === undef || isNaN(value))) {
value = "";
}
key = encode2(key);
value = encode2(value);
if (key === null || value === null) continue;
pairs.push(key + "=" + value);
}
}
return pairs.length ? prefix + pairs.join("&") : "";
}
exports.stringify = querystringify;
exports.parse = querystring;
}
});
// node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js
var require_url_parse = __commonJS({
"node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.js"(exports, module) {
var required = require_requires_port();
var qs = require_querystringify();
var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
var CRHTLF = /[\n\r\t]/g;
var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
var port = /:\d+$/;
var protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i;
var windowsDriveLetter = /^[a-zA-Z]:/;
function trimLeft(str) {
return (str ? str : "").toString().replace(controlOrWhitespace, "");
}
var rules = [
["#", "hash"],
// Extract from the back.
["?", "query"],
// Extract from the back.
function sanitize(address, url) {
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
},
["/", "pathname"],
// Extract from the back.
["@", "auth", 1],
// Extract from the front.
[NaN, "host", void 0, 1, 1],
// Set left over value.
[/:(\d*)$/, "port", void 0, 1],
// RegExp the back.
[NaN, "hostname", void 0, 1, 1]
// Set left over.
];
var ignore = { hash: 1, query: 1 };
function lolcation(loc) {
var globalVar;
if (typeof window !== "undefined") globalVar = window;
else if (typeof globalThis !== "undefined") globalVar = globalThis;
else if (typeof self !== "undefined") globalVar = self;
else globalVar = {};
var location = globalVar.location || {};
loc = loc || location;
var finaldestination = {}, type = typeof loc, key;
if ("blob:" === loc.protocol) {
finaldestination = new Url(unescape(loc.pathname), {});
} else if ("string" === type) {
finaldestination = new Url(loc, {});
for (key in ignore) delete finaldestination[key];
} else if ("object" === type) {
for (key in loc) {
if (key in ignore) continue;
finaldestination[key] = loc[key];
}
if (finaldestination.slashes === void 0) {
finaldestination.slashes = slashes.test(loc.href);
}
}
return finaldestination;
}
function isSpecial(scheme) {
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
}
function extractProtocol(address, location) {
address = trimLeft(address);
address = address.replace(CRHTLF, "");
location = location || {};
var match = protocolre.exec(address);
var protocol = match[1] ? match[1].toLowerCase() : "";
var forwardSlashes = !!match[2];
var otherSlashes = !!match[3];
var slashesCount = 0;
var rest;
if (forwardSlashes) {
if (otherSlashes) {
rest = match[2] + match[3] + match[4];
slashesCount = match[2].length + match[3].length;
} else {
rest = match[2] + match[4];
slashesCount = match[2].length;
}
} else {
if (otherSlashes) {
rest = match[3] + match[4];
slashesCount = match[3].length;
} else {
rest = match[4];
}
}
if (protocol === "file:") {
if (slashesCount >= 2) {
rest = rest.slice(2);
}
} else if (isSpecial(protocol)) {
rest = match[4];
} else if (protocol) {
if (forwardSlashes) {
rest = rest.slice(2);
}
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
rest = match[4];
}
return {
protocol,
slashes: forwardSlashes || isSpecial(protocol),
slashesCount,
rest
};
}
function resolve(relative, base) {
if (relative === "") return base;
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
while (i--) {
if (path[i] === ".") {
path.splice(i, 1);
} else if (path[i] === "..") {
path.splice(i, 1);
up++;
} else if (up) {
if (i === 0) unshift = true;
path.splice(i, 1);
up--;
}
}
if (unshift) path.unshift("");
if (last === "." || last === "..") path.push("");
return path.join("/");
}
function Url(address, location, parser) {
address = trimLeft(address);
address = address.replace(CRHTLF, "");
if (!(this instanceof Url)) {
return new Url(address, location, parser);
}
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
if ("object" !== type && "string" !== type) {
parser = location;
location = null;
}
if (parser && "function" !== typeof parser) parser = qs.parse;
location = lolcation(location);
extracted = extractProtocol(address || "", location);
relative = !extracted.protocol && !extracted.slashes;
url.slashes = extracted.slashes || relative && location.slashes;
url.protocol = extracted.protocol || location.protocol || "";
address = extracted.rest;
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
instructions[3] = [/(.*)/, "pathname"];
}
for (; i < instructions.length; i++) {
instruction = instructions[i];
if (typeof instruction === "function") {
address = instruction(address, url);
continue;
}
parse = instruction[0];
key = instruction[1];
if (parse !== parse) {
url[key] = address;
} else if ("string" === typeof parse) {
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
if (~index) {
if ("number" === typeof instruction[2]) {
url[key] = address.slice(0, index);
address = address.slice(index + instruction[2]);
} else {
url[key] = address.slice(index);
address = address.slice(0, index);
}
}
} else if (index = parse.exec(address)) {
url[key] = index[1];
address = address.slice(0, index.index);
}
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
if (instruction[4]) url[key] = url[key].toLowerCase();
}
if (parser) url.query = parser(url.query);
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
url.pathname = resolve(url.pathname, location.pathname);
}
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
url.pathname = "/" + url.pathname;
}
if (!required(url.port, url.protocol)) {
url.host = url.hostname;
url.port = "";
}
url.username = url.password = "";
if (url.auth) {
index = url.auth.indexOf(":");
if (~index) {
url.username = url.auth.slice(0, index);
url.username = encodeURIComponent(decodeURIComponent(url.username));
url.password = url.auth.slice(index + 1);
url.password = encodeURIComponent(decodeURIComponent(url.password));
} else {
url.username = encodeURIComponent(decodeURIComponent(url.auth));
}
url.auth = url.password ? url.username + ":" + url.password : url.username;
}
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
url.href = url.toString();
}
function set(part, value, fn) {
var url = this;
switch (part) {
case "query":
if ("string" === typeof value && value.length) {
value = (fn || qs.parse)(value);
}
url[part] = value;
break;
case "port":
url[part] = value;
if (!required(value, url.protocol)) {
url.host = url.hostname;
url[part] = "";
} else if (value) {
url.host = url.hostname + ":" + value;
}
break;
case "hostname":
url[part] = value;
if (url.port) value += ":" + url.port;
url.host = value;
break;
case "host":
url[part] = value;
if (port.test(value)) {
value = value.split(":");
url.port = value.pop();
url.hostname = value.join(":");
} else {
url.hostname = value;
url.port = "";
}
break;
case "protocol":
url.protocol = value.toLowerCase();
url.slashes = !fn;
break;
case "pathname":
case "hash":
if (value) {
var char = part === "pathname" ? "/" : "#";
url[part] = value.charAt(0) !== char ? char + value : value;
} else {
url[part] = value;
}
break;
case "username":
case "password":
url[part] = encodeURIComponent(value);
break;
case "auth":
var index = value.indexOf(":");
if (~index) {
url.username = value.slice(0, index);
url.username = encodeURIComponent(decodeURIComponent(url.username));
url.password = value.slice(index + 1);
url.password = encodeURIComponent(decodeURIComponent(url.password));
} else {
url.username = encodeURIComponent(decodeURIComponent(value));
}
}
for (var i = 0; i < rules.length; i++) {
var ins = rules[i];
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
}
url.auth = url.password ? url.username + ":" + url.password : url.username;
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
url.href = url.toString();
return url;
}
function toString(stringify) {
if (!stringify || "function" !== typeof stringify) stringify = qs.stringify;
var query, url = this, host = url.host, protocol = url.protocol;
if (protocol && protocol.charAt(protocol.length - 1) !== ":") protocol += ":";
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
if (url.username) {
result += url.username;
if (url.password) result += ":" + url.password;
result += "@";
} else if (url.password) {
result += ":" + url.password;
result += "@";
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
result += "@";
}
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
host += ":";
}
result += host + url.pathname;
query = "object" === typeof url.query ? stringify(url.query) : url.query;
if (query) result += "?" !== query.charAt(0) ? "?" + query : query;
if (url.hash) result += url.hash;
return result;
}
Url.prototype = { set, toString };
Url.extractProtocol = extractProtocol;
Url.location = lolcation;
Url.trimLeft = trimLeft;
Url.qs = qs;
module.exports = Url;
}
});
// src/utils/index.ts
function formatFileSize(bytes) {
if (bytes === 0) return "0 Bytes";
const k = 1024;
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
}
function formatUploadSpeed(bytesPerSecond) {
if (bytesPerSecond === 0) return "0 B/s";
const k = 1024;
const sizes = ["B/s", "KB/s", "MB/s", "GB/s"];
const i = Math.floor(Math.log(bytesPerSecond) / Math.log(k));
const sizeIndex = Math.min(i, sizes.length - 1);
const value = bytesPerSecond / Math.pow(k, sizeIndex);
const decimals = sizeIndex === 0 ? 0 : sizeIndex === 1 ? 1 : 2;
return parseFloat(value.toFixed(decimals)) + " " + sizes[sizeIndex];
}
function generateFileId() {
return crypto.randomUUID();
}
function validateFile(file, options = {}) {
if (options.maxSize && file.size > options.maxSize) {
return `File size exceeds maximum of ${formatFileSize(options.maxSize)}`;
}
if (options.allowedTypes && options.allowedTypes.length > 0) {
const isAllowed = options.allowedTypes.some((type) => {
if (type.endsWith("/*")) {
const baseType = type.slice(0, -2);
return file.type.startsWith(baseType);
}
return file.type === type;
});
if (!isAllowed) {
return `File type ${file.type} is not allowed`;
}
}
return null;
}
function isFileSystemAccessSupported() {
return typeof window !== "undefined" && "showOpenFilePicker" in window && "showSaveFilePicker" in window && "showDirectoryPicker" in window;
}
function isSafari() {
if (typeof window === "undefined") return false;
const userAgent = window.navigator.userAgent;
const vendor = window.navigator.vendor;
return /Safari/.test(userAgent) && /Apple Computer/.test(vendor) && !/Chrome/.test(userAgent) && !/Chromium/.test(userAgent);
}
function getBrowserInfo() {
if (typeof window === "undefined") {
return { name: "Unknown", version: "Unknown", isFileSystemAccessSupported: false };
}
const userAgent = window.navigator.userAgent;
let browserName = "Unknown";
let version2 = "Unknown";
if (isSafari()) {
browserName = "Safari";
const match = userAgent.match(/Version\/([0-9._]+)/);
version2 = match ? match[1] : "Unknown";
} else if (/Chrome/.test(userAgent)) {
browserName = "Chrome";
const match = userAgent.match(/Chrome\/([0-9.]+)/);
version2 = match ? match[1] : "Unknown";
} else if (/Firefox/.test(userAgent)) {
browserName = "Firefox";
const match = userAgent.match(/Firefox\/([0-9.]+)/);
version2 = match ? match[1] : "Unknown";
} else if (/Edge/.test(userAgent)) {
browserName = "Edge";
const match = userAgent.match(/Edge\/([0-9.]+)/);
version2 = match ? match[1] : "Unknown";
}
return {
name: browserName,
version: version2,
isFileSystemAccessSupported: isFileSystemAccessSupported()
};
}
function createMockFileHandle(file) {
const mockHandle = {
kind: "file",
name: file.name,
getFile: async () => file,
queryPermission: async () => "granted",
requestPermission: async () => "granted",
createWritable: async () => {
throw new Error("Write operations not supported in Safari fallback mode");
},
isSameEntry: async () => false
};
return mockHandle;
}
async function getFileHandlesFromDataTransfer(dataTransfer) {
const items = Array.from(dataTransfer.items).filter((item) => item.kind === "file");
const results = [];
for (const item of items) {
try {
if (item.getAsFileSystemHandle && isFileSystemAccessSupported()) {
const handle = await item.getAsFileSystemHandle();
if (handle && handle.kind === "file") {
const file2 = await handle.getFile();
results.push({ file: file2, handle });
continue;
}
}
} catch (error) {
console.warn("Failed to get file handle from drag item:", error);
}
const file = item.getAsFile();
if (file) {
const mockHandle = createMockFileHandle(file);
results.push({ file, handle: mockHandle });
}
}
return results;
}
async function getFilesFromDragEvent(event) {
if (!event.dataTransfer) {
return [];
}
return getFileHandlesFromDataTransfer(event.dataTransfer);
}
function debounce(func, wait) {
let timeout = null;
return (...args) => {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
func(...args);
}, wait);
};
}
// src/core/FilePicker.ts
var FilePicker = class {
constructor(options = {}) {
this.options = {
multiple: true,
useFileSystemAccess: false,
...options
};
}
generateUUID() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c == "x" ? r : r & 3 | 8;
return v.toString(16);
});
}
async pickFiles() {
if (this.options.useFileSystemAccess && isFileSystemAccessSupported()) {
console.log("Picking files with file system access");
return this.pickWithFileSystemAccess();
} else if (this.options.useFileSystemAccess && !isFileSystemAccessSupported()) {
console.log("Picking files with input (Safari fallback for File System Access)");
return this.pickWithInputAndMockHandles();
}
console.log("Picking files with input");
return this.pickWithInput();
}
async pickWithFileSystemAccess() {
try {
const fileHandles = await window.showOpenFilePicker({
multiple: this.options.multiple,
types: this.options.accept ? [
{
description: "Files",
accept: { "*/*": [this.options.accept] }
}
] : void 0
});
const uploadFiles = [];
for (const fileHandle of fileHandles) {
const file = await fileHandle.getFile();
uploadFiles.push({
id: this.generateUUID(),
file,
fileHandle,
name: file.name,
size: file.size,
type: file.type
});
}
return uploadFiles;
} catch (error) {
if (error.name === "AbortError") {
return [];
}
throw error;
}
}
async pickWithInputAndMockHandles() {
return new Promise((resolve) => {
const input = document.createElement("input");
input.type = "file";
input.multiple = this.options.multiple || false;
if (this.options.accept) {
input.accept = this.options.accept;
}
input.onchange = () => {
const files = Array.from(input.files || []);
const uploadFiles = files.map((file) => {
const mockHandle = this.createMockFileHandle(file);
return {
id: this.generateUUID(),
file,
fileHandle: mockHandle,
name: file.name,
size: file.size,
type: file.type
};
});
resolve(uploadFiles);
};
input.click();
});
}
createMockFileHandle(file) {
const mockHandle = {
kind: "file",
name: file.name,
getFile: async () => file,
queryPermission: async () => "granted",
requestPermission: async () => "granted",
createWritable: async () => {
throw new Error("Write operations not supported in Safari fallback mode");
},
isSameEntry: async () => false
};
return mockHandle;
}
async pickWithInput() {
return new Promise((resolve) => {
const input = document.createElement("input");
input.type = "file";
input.multiple = this.options.multiple || false;
if (this.options.accept) {
input.accept = this.options.accept;
}
input.onchange = () => {
const files = Array.from(input.files || []);
const uploadFiles = files.map((file) => ({
id: this.generateUUID(),
file,
name: file.name,
size: file.size,
type: file.type
}));
resolve(uploadFiles);
};
input.click();
});
}
};
// node_modules/.pnpm/tus-js-client@4.3.1/node_modules/tus-js-client/lib.esm/error.js
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof(o);
}
function _createClass(Constructor, protoProps, staticProps) {
Object.defineProperty(Constructor, "prototype", { writable: false });
return Constructor;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _callSuper(t, o, e) {
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
}
function _possibleConstructorReturn(self2, 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(self2);
}
function _assertThisInitialized(self2) {
if (self2 === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self2;
}
function _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);
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
if (Class2 === null || !_isNativeFunction(Class2)) return Class2;
if (typeof Class2 !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class2)) return _cache.get(Class2);
_cache.set(Class2, Wrapper);
}
function Wrapper() {
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class2.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });
return _setPrototypeOf(Wrapper, Class2);
};
return _wrapNativeSuper(Class);
}
function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
} catch (t2) {
}
return (_isNativeReflectConstruct = function _isNativeReflectConstruct3() {
return !!t;
})();
}
function _isNativeFunction(fn) {
try {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
} catch (e) {
return typeof fn === "function";
}
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf3(o2, p2) {
o2.__proto__ = p2;
return o2;
};
return _setPrototypeOf(o, p);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf3(o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
};
return _getPrototypeOf(o);
}
var DetailedError = /* @__PURE__ */ function(_Error) {
function DetailedError2(message) {
var _this;
var causingErr = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
var req = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
var res = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
_classCallCheck(this, DetailedError2);
_this = _callSuper(this, DetailedError2, [message]);
_this.originalRequest = req;
_this.originalResponse = res;
_this.causingError = causingErr;
if (causingErr != null) {
message += ", caused by ".concat(causingErr.toString());
}
if (req != null) {
var requestId = req.getHeader("X-Request-ID") || "n/a";
var method = req.getMethod();
var url = req.getURL();
var status = res ? res.getStatus() : "n/a";
var body = res ? res.getBody() || "" : "n/a";
message += ", originated from request (method: ".concat(method, ", url: ").concat(url, ", response code: ").concat(status, ", response text: ").concat(body, ", request id: ").concat(requestId, ")");
}
_this.message = message;
return _this;
}
_inherits(DetailedError2, _Error);
return _createClass(DetailedError2);
}(/* @__PURE__ */ _wrapNativeSuper(Error));
var error_default = DetailedError;
function log(msg) {
return;
}
// node_modules/.pnpm/tus-js-client@4.3.1/node_modules/tus-js-client/lib.esm/noopUrlStorage.js
function _typeof2(o) {
"@babel/helpers - typeof";
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof2(o);
}
function _classCallCheck2(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties2(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, _toPropertyKey2(descriptor.key), descriptor);
}
}
function _createClass2(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties2(Constructor.prototype, protoProps);
Object.defineProperty(Constructor, "prototype", { writable: false });
return Constructor;
}
function _toPropertyKey2(t) {
var i = _toPrimitive2(t, "string");
return "symbol" == _typeof2(i) ? i : i + "";
}
function _toPrimitive2(t, r) {
if ("object" != _typeof2(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r);
if ("object" != _typeof2(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (String )(t);
}
var NoopUrlStorage = /* @__PURE__ */ function() {
function NoopUrlStorage2() {
_classCallCheck2(this, NoopUrlStorage2);
}
return _createClass2(NoopUrlStorage2, [{
key: "listAllUploads",
value: function listAllUploads() {
return Promise.resolve([]);
}
}, {
key: "findUploadsByFingerprint",
value: function findUploadsByFingerprint(_fingerprint) {
return Promise.resolve([]);
}
}, {
key: "removeUpload",
value: function removeUpload(_urlStorageKey) {
return Promise.resolve();
}
}, {
key: "addUpload",
value: function addUpload(_fingerprint, _upload) {
return Promise.resolve(null);
}
}]);
}();
// node_modules/.pnpm/js-base64@3.7.7/node_modules/js-base64/base64.mjs
var version = "3.7.7";
var VERSION = version;
var _hasBuffer = typeof Buffer === "function";
var _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var b64chs = Array.prototype.slice.call(b64ch);
var b64tab = ((a) => {
let tab = {};
a.forEach((c, i) => tab[c] = i);
return tab;
})(b64chs);
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
var _fromCC = String.fromCharCode.bind(String);
var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
var _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, "");
var btoaPolyfill = (bin) => {
let u32, c0, c1, c2, asc = "";
const pad = bin.length % 3;
for (let i = 0; i < bin.length; ) {
if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
throw new TypeError("invalid character found");
u32 = c0 << 16 | c1 << 8 | c2;
asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
}
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
};
var _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
var _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
const maxargs = 4096;
let strs = [];
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
}
return _btoa(strs.join(""));
};
var fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
var cb_utob = (c) => {
if (c.length < 2) {
var cc = c.charCodeAt(0);
return cc < 128 ? c : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
} else {
var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
}
};
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var utob = (u) => u.replace(re_utob, cb_utob);
var _encode = _hasBuffer ? (s) => Buffer.from(s, "utf8").toString("base64") : _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
var encodeURI = (src) => encode(src, true);
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
var cb_btou = (cccc) => {
switch (cccc.length) {
case 4:
var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
case 3:
return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
default:
return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
}
};
var btou = (b) => b.replace(re_btou, cb_btou);
var atobPolyfill = (asc) => {
asc = asc.replace(/\s+/g, "");
if (!b64re.test(asc))
throw new TypeError("malformed base64.");
asc += "==".slice(2 - (asc.length & 3));
let u24, bin = "", r1, r2;
for (let i = 0; i < asc.length; ) {
u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
}
return bin;
};
var _atob = typeof atob === "function" ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
var _toUint8Array = _hasBuffer ? (a) => _U8Afrom(Buffer.from(a, "base64")) : (a) => _U8Afrom(_atob(a).split("").map((c) => c.charCodeAt(0)));
var toUint8Array = (a) => _toUint8Array(_unURI(a));
var _decode = _hasBuffer ? (a) => Buffer.from(a, "base64").toString("utf8") : _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
var _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
var decode = (src) => _decode(_unURI(src));
var isValid = (src) => {
if (typeof src !== "string")
return false;
const s = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
};
var _noEnum = (v) => {
return {
value: v,
enumerable: false,
writable: true,
configurable: true
};
};
var extendString = function() {
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
_add("fromBase64", function() {
return decode(this);
});
_add("toBase64", function(urlsafe) {
return encode(this, urlsafe);
});
_add("toBase64URI", function() {
return encode(this, true);
});
_add("toBase64URL", function() {
return encode(this, true);
});
_add("toUint8Array", function() {
return toUint8Array(this);
});
};
var extendUint8Array = function() {
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
_add("toBase64", function(urlsafe) {
return fromUint8Array(this, urlsafe);
});
_add("toBase64URI", function() {
return fromUint8Array(this, true);
});
_add("toBase64URL", function() {
return fromUint8Array(this, true);
});
};
var extendBuiltins = () => {
extendString();
extendUint8Array();
};
var gBase64 = {
version,
VERSION,
atob: _atob,
atobPolyfill,
btoa: _btoa,
btoaPolyfill,
fromBase64: decode,
toBase64: encode,
encode,
encodeURI,
encodeURL: encodeURI,
utob,
btou,
decode,
isValid,
fromUint8Array,
toUint8Array,
extendString,
extendUint8Array,
extendBuiltins
};
// node_modules/.pnpm/tus-js-client@4.3.1/node_modules/tus-js-client/lib.esm/upload.js
var import_url_parse = __toESM(require_url_parse());
// node_modules/.pnpm/tus-js-client@4.3.1/node_modules/tus-js-client/lib.esm/uuid.js
function uuid() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0;
var v = c === "x" ? r : r & 3 | 8;
return v.toString(16);
});
}
// node_modules/.pnpm/tus-js-client@4.3.1/node_modules/tus-js-client/lib.esm/upload.js
function _regeneratorRuntime() {
_regeneratorRuntime = function _regeneratorRuntime3() {
return e;
};
var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r2) {
t2[e2] = r2.value;
}, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
function define(t2, e2, r2) {
return Object.defineProperty(t2, e2, { value: r2, enumerable: true, configurable: true, writable: true }), t2[e2];
}
try {
define({}, "");
} catch (t2) {
define = function define2(t3, e2, r2) {
return t3[e2] = r2;
};
}
function wrap(t2, e2, r2, n2) {
var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c2 = new Context(n2 || []);
return o(a2, "_invoke", { value: makeInvokeMethod(t2, r2, c2) }), a2;
}
function tryCatch(t2, e2, r2) {
try {
return { type: "normal", arg: t2.call(e2, r2) };
} catch (t3) {
return { type: "throw", arg: t3 };
}
}
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(t2) {
["next", "throw", "return"].forEach(function(e2) {
define(t2, e2, function(t3) {
return this._invoke(e2, t3);
});
});
}
function AsyncIterator(t2, e2) {
function invoke(r3, o2, i2, a2) {
var c2 = tryCatch(t2[r3], t2, o2);
if ("throw" !== c2.type) {
var u2 = c2.arg, h2 = u2.value;
return h2 && "object" == _typeof3(h2) && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
invoke("next", t3, i2, a2);
}, function(t3) {
invoke("throw", t3, i2, a2);
}) : e2.resolve(h2).then(function(t3) {
u2.value = t3, i2(u2);
}, function(t3) {
return invoke("throw", t3, i2, a2);
});
}
a2(c2.arg);
}
var r2;
o(this, "_invoke", { value: function value(t3, n2) {
function callInvokeWithMethodAndArg() {
return new e2(function(e3, r3) {
invoke(t3, n2, e3, r3);
});
}
return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
} });
}
function makeInvokeMethod(e2, r2, n2) {
var o2 = h;
return function(i2, a2) {
if (o2 === f) throw Error("Generator is already running");
if (o2 === s) {
if ("throw" === i2) throw a2;
return { value: t, done: true };
}
for (n2.method = i2, n2.arg = a2; ; ) {
var c2 = n2.delegate;
if (c2) {
var u2 = maybeInvokeDelegate(c2, n2);
if (u2) {
if (u2 === y) continue;
return u2;
}
}
if ("next" === n2.method) n2.sent = n2._sent = n2.arg;
else if ("throw" === n2.method) {
if (o2 === h) throw o2 = s, n2.arg;
n2.dispatchException(n2.arg);
} else "return" === n2.method && n2.abrupt("return", n2.arg);
o2 = f;
var p2 = tryCatch(e2, r2, n2);
if ("normal" === p2.type) {
if (o2 = n2.done ? s : l, p2.arg === y) continue;
return { value: p2.arg, done: n2.done };
}
"throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
}
};
}
function maybeInvokeDelegate(e2, r2) {
var n2 = r2.method, o2 = e2.iterator[n2];
if (o2 === t) return r2.delegate = null, "throw" === n2 && e2.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e2, r2), "throw" === r2.method) || "return" !== n2 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
var i2 = tryCatch(o2, e2.iterator, r2.arg);
if ("throw" === i2.type) return r2.method = "throw", r2.arg = i2.arg, r2.delegate = null, y;
var a2 = i2.arg;
return a2 ? a2.done ? (r2[e2.resultName] = a2.value, r2.next = e2.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y);
}
function pushTryEntry(t2) {
var e2 = { tryLoc: t2[0] };
1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
}
function resetTryEntry(t2) {
var e2 = t2.completion || {};
e2.type = "normal", delete e2.arg, t2.completion = e2;
}
function Context(t2) {
this.tryEntries = [{ tryLoc: "root" }], t2.forEach(pushTryEntry, this), this.reset(true);
}
function values(e2) {
if (e2 || "" === e2) {
var r2 = e2[a];
if (r2) return r2.call(e2);
if ("function" == typeof e2.next) return e2;
if (!isNaN(e2.length)) {
var o2 = -1, i2 = function next() {
for (; ++o2 < e2.length; ) if (n.call(e2, o2)) return next.value = e2[o2], next.done = false, next;
return next.value = t, next.done = true, next;
};
return i2.next = i2;
}
}
throw new TypeError(_typeof3(e2) + " is not iterable");
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
var e2 = "function" == typeof t2 && t2.constructor;
return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
}, e.mark = function(t2) {
return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
}, e.awrap = function(t2) {
return { __await: t2 };
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function() {
return this;
}), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n2, o2, i2) {
void 0 === i2 && (i2 = Promise);
var a2 = new AsyncIterator(wrap(t2, r2, n2, o2), i2);
return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
return t3.done ? t3.value : a2.next();
});
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
return this;
}), define(g, "toString", function() {
return "[object Generator]";
}), e.keys = function(t2) {
var e2 = Object(t2), r2 = [];
for (var n2 in e2) r2.push(n2);
return r2.reverse(), function next() {
for (; r2.length; ) {
var t3 = r2.pop();
if (t3 in e2) return next.value = t3, next.done = false, next;
}
return next.done = true, next;
};
}, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e2) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2) for (var r2 in this) "t" === r2.charAt(0) && n.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t);
}, stop: function stop() {
this.done = true;
var t2 = this.tryEntries[0].completion;
if ("throw" === t2.type) throw t2.arg;
return this.rval;
}, dispatchException: function dispatchException(e2) {
if (this.done) throw e2;
var r2 = this;
function handle(n2, o3) {
return a2.type = "throw", a2.arg = e2, r2.next = n2, o3 && (r2.method = "next", r2.arg = t), !!o3;
}
for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
var i2 = this.tryEntries[o2], a2 = i2.completion;
if ("root" === i2.tryLoc) return handle("end");
if (i2.tryLoc <= this.prev) {
var c2 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
if (c2 && u2) {
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
} else if (c2) {
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
} else {
if (!u2) throw Error("try statement without catch or finally");
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
}
}
}
}, abrupt: function abrupt(t2, e2) {
for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) {
var o2 = this.tryEntries[r2];
if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
var i2 = o2;
break;
}
}
i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
var a2 = i2 ? i2.completion : {};
return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
}, complete: function complete(t2, e2) {
if ("throw" === t2.type) throw t2.arg;
return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
}, finish: function finish(t2) {
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
var r2 = this.tryEntries[e2];
if (r2.finallyLoc === t2) return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y;
}
}, "catch": function _catch(t2) {
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
var r2 = this.tryEntries[e2];
if (r2.tryLoc === t2) {
var n2 = r2.completion;
if ("throw" === n2.type) {
var o2 = n2.arg;
resetTryEntry(r2);
}
return o2;
}
}
throw Error("illegal catch attempt");
}, delegateYield: function delegateYield(e2, r2, n2) {
return this.delegate = { iterator: values(e2), resultName: r2, nextLoc: n2 }, "next" === this.method && (this.arg = t), y;
} }, e;
}
function 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);
}
}
function _asyncToGenerator(fn) {
return function() {
var self2 = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self2, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(void 0);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _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.");
}
function _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 = true, o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
} catch (r2) {
o = true, n = r2;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {