Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rpldy/uploader

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rpldy/uploader - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0-rc.0

21

lib/cjs/batch.js

@@ -7,24 +7,20 @@ "use strict";

exports.default = void 0;
var _shared = require("@rpldy/shared");
var _defaults = require("./defaults");
var _utils = require("./utils");
let bCounter = 0;
const processFiles = (batchId, files, isPending, fileFilter) => {
//we need a simple array of (file, url) to pass to filter fn if its provided (files can be recycled batch items)
const all = fileFilter ? Array.prototype //$FlowExpectedError[method-unbinding] flow 0.153 !!!
.map.call(files, f => (0, _shared.getIsBatchItem)(f) ? f.file || f.url : f) : //in case no filter fn, no need to map it
const all = fileFilter ? Array.prototype
//$FlowExpectedError[method-unbinding] flow 0.153 !!!
.map.call(files, f => (0, _shared.getIsBatchItem)(f) ? f.file || f.url : f) :
//in case no filter fn, no need to map it
[];
return Promise.all(Array.prototype //$FlowExpectedError[method-unbinding] flow 0.153 !!!
return Promise.all(Array.prototype
//$FlowExpectedError[method-unbinding] flow 0.153 !!!
.map.call(files, (f, index) => {
const filterResult = (fileFilter || _defaults.DEFAULT_FILTER)(all[index], index, all);
return (0, _shared.isPromise)(filterResult) ? filterResult.then(result => !!result && f) : !!filterResult && f;
})).then(filtered => filtered.filter(Boolean).map(f => (0, _shared.createBatchItem)(f, batchId, isPending)));
};
const createBatch = (files, uploaderId, options) => {

@@ -34,5 +30,5 @@ bCounter += 1;

const isFileList = (0, _utils.getIsFileList)(files);
files = Array.isArray(files) || isFileList ? files : [files];
const usedFiles = Array.isArray(files) || isFileList ? files : [files];
const isPending = !options.autoUpload;
return processFiles(id, files, isPending, options.fileFilter).then(items => {
return processFiles(id, usedFiles, isPending, options.fileFilter).then(items => {
return {

@@ -50,4 +46,3 @@ id,

};
var _default = createBatch;
exports.default = _default;

@@ -7,15 +7,8 @@ "use strict";

exports.default = void 0;
var _shared = require("@rpldy/shared");
var _lifeEvents = _interopRequireDefault(require("@rpldy/life-events"));
var _sender = _interopRequireDefault(require("@rpldy/sender"));
var _consts = require("./consts");
var _defaults = require("./defaults");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//TODO (v2): Load using enhancer to allow using uploader (tree-shake) that doesnt import the defualt sender if not needed

@@ -25,15 +18,12 @@ const reportItemsProgress = (items, completed, loaded, trigger) => {

_shared.logger.debugLog(`uploady.uploader.processor: file: ${item.id} progress event: loaded(${loaded}) - completed(${completed})`);
trigger(_consts.SENDER_EVENTS.ITEM_PROGRESS, item, completed, loaded);
});
};
const onItemUploadProgress = (items, batch, e, trigger) => {
const completed = Math.min(e.loaded / e.total * 100, 100),
completedPerItem = completed / items.length,
loadedAverage = e.loaded / items.length;
completedPerItem = completed / items.length,
loadedAverage = e.loaded / items.length;
reportItemsProgress(items, completedPerItem, loadedAverage, trigger);
trigger(_consts.SENDER_EVENTS.BATCH_PROGRESS, batch);
};
const createBatchItemsSender = () => {

@@ -46,3 +36,3 @@ const {

const destination = batchOptions.destination,
url = destination === null || destination === void 0 ? void 0 : destination.url;
url = destination === null || destination === void 0 ? void 0 : destination.url;
const throttledProgress = (0, _shared.throttle)(e => onItemUploadProgress(items, batch, e, trigger), _consts.PROGRESS_DELAY, true);

@@ -53,3 +43,4 @@ const send = (0, _shared.isFunction)(batchOptions.send) ? batchOptions.send : _sender.default;

paramName: (destination === null || destination === void 0 ? void 0 : destination.filesParamName) || batchOptions.inputFieldName || _defaults.DEFAULT_PARAM_NAME,
params: { //TODO: might need to rethink the order here:
params: {
//TODO: might need to rethink the order here:
...batchOptions.params,

@@ -71,4 +62,3 @@ ...(destination === null || destination === void 0 ? void 0 : destination.params)

};
var _default = createBatchItemsSender;
exports.default = _default;

@@ -7,3 +7,2 @@ "use strict";

exports.default = void 0;
const composeEnhancers = function () {

@@ -13,3 +12,2 @@ for (var _len = arguments.length, enhancers = new Array(_len), _key = 0; _key < _len; _key++) {

}
return function (uploader) {

@@ -19,8 +17,6 @@ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

}
return enhancers.reduce((enhanced, e) => e(enhanced, ...args) || enhanced, uploader);
};
};
var _default = composeEnhancers;
exports.default = _default;

@@ -7,5 +7,3 @@ "use strict";

exports.UPLOADER_EVENTS = exports.SENDER_EVENTS = exports.PROGRESS_DELAY = exports.ITEM_FINALIZE_STATES = void 0;
var _shared = require("@rpldy/shared");
const UPLOADER_EVENTS = (0, _shared.devFreeze)({

@@ -12,0 +10,0 @@ BATCH_ADD: "BATCH-ADD",

@@ -7,10 +7,6 @@ "use strict";

exports.DEFAULT_PARAM_NAME = exports.DEFAULT_OPTIONS = exports.DEFAULT_FILTER = void 0;
var _shared = require("@rpldy/shared");
const DEFAULT_PARAM_NAME = "file";
exports.DEFAULT_PARAM_NAME = DEFAULT_PARAM_NAME;
const DEFAULT_FILTER = () => true;
exports.DEFAULT_FILTER = DEFAULT_FILTER;

@@ -17,0 +13,0 @@ const DEFAULT_OPTIONS = (0, _shared.devFreeze)({

@@ -51,13 +51,7 @@ "use strict";

exports.default = void 0;
var _uploader = _interopRequireDefault(require("./uploader"));
var _composeEnhancers = _interopRequireDefault(require("./composeEnhancers"));
var _consts = require("./consts");
var _defaults = require("./defaults");
var _sender = require("@rpldy/sender");
Object.keys(_sender).forEach(function (key) {

@@ -74,8 +68,5 @@ if (key === "default" || key === "__esModule") return;

});
var _shared = require("@rpldy/shared");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = _uploader.default;
exports.default = _default;

@@ -7,14 +7,9 @@ "use strict";

exports.default = void 0;
var _queue = _interopRequireDefault(require("./queue"));
var _batchItemsSender = _interopRequireDefault(require("./batchItemsSender"));
var _batch = _interopRequireDefault(require("./batch"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const createProcessor = (trigger, cancellable, options, uploaderId) => {
const sender = (0, _batchItemsSender.default)(),
queue = (0, _queue.default)(options, trigger, cancellable, sender, uploaderId);
queue = (0, _queue.default)(options, trigger, cancellable, sender, uploaderId);
const runCancellable = queue.runCancellable;

@@ -49,4 +44,3 @@ return {

};
var _default = createProcessor;
exports.default = _default;

@@ -6,19 +6,14 @@ "use strict";

});
exports.triggerUploaderBatchEvent = exports.removePendingBatches = exports.removeBatchItems = exports.preparePendingForUpload = exports.loadNewBatchForItem = exports.isNewBatchStarting = exports.incrementBatchFinishedCounter = exports.getIsBatchReady = exports.getIsBatchFinalized = exports.getBatchFromState = exports.getBatchFromItemId = exports.getBatchDataFromItemId = exports.finalizeBatch = exports.failBatchForItem = exports.detachRecycledFromPreviousBatch = exports.clearBatchData = exports.cleanUpFinishedBatches = exports.cancelBatchForItem = void 0;
exports.triggerUploaderBatchEvent = exports.removePendingBatches = exports.removeBatchItems = exports.preparePendingForUpload = exports.loadNewBatchForItem = exports.isNewBatchStarting = exports.isItemBatchStartPending = exports.incrementBatchFinishedCounter = exports.getIsBatchReady = exports.getIsBatchFinalized = exports.getBatchFromState = exports.getBatchFromItemId = exports.getBatchDataFromItemId = exports.finalizeBatch = exports.failBatchForItem = exports.detachRecycledFromPreviousBatch = exports.clearBatchData = exports.cleanUpFinishedBatches = exports.cancelBatchForItem = void 0;
var _shared = require("@rpldy/shared");
var _simpleState = require("@rpldy/simple-state");
var _consts = require("../consts");
var _preSendPrepare = require("./preSendPrepare");
var _itemHelpers = require("./itemHelpers");
const prepareBatchStartItems = (0, _preSendPrepare.getItemsPrepareUpdater)(_consts.UPLOADER_EVENTS.BATCH_START, batch => batch.items, null, function () {
let {
batch
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
batch: false
};
if (batch) {

@@ -30,11 +25,7 @@ throw new Error(`BATCH_START event handlers cannot update batch data. Only items & options`);

const BATCH_FINISHED_STATES = [_shared.BATCH_STATES.ABORTED, _shared.BATCH_STATES.CANCELLED, _shared.BATCH_STATES.FINISHED, _shared.BATCH_STATES.ERROR];
const getBatchFromState = (state, id) => state.batches[id].batch;
exports.getBatchFromState = getBatchFromState;
const getBatch = (queue, id) => {
return getBatchFromState(queue.getState(), id);
};
const getBatchDataFromItemId = (queue, itemId) => {

@@ -45,11 +36,7 @@ const state = queue.getState();

};
exports.getBatchDataFromItemId = getBatchDataFromItemId;
const getBatchFromItemId = (queue, itemId) => {
return getBatchDataFromItemId(queue, itemId).batch;
};
exports.getBatchFromItemId = getBatchFromItemId;
const removeBatchItems = (queue, batchId) => {

@@ -64,5 +51,3 @@ const batch = getBatch(queue, batchId);

};
exports.removeBatchItems = removeBatchItems;
const removeBatch = (queue, batchId) => {

@@ -73,9 +58,11 @@ queue.updateState(state => {

const batchQueueIndex = state.batchQueue.indexOf(batchId);
if (~batchQueueIndex) {
state.batchQueue.splice(batchQueueIndex, 1);
}
const pendingFlagIndex = state.batchesStartPending.indexOf(batchId);
if (~pendingFlagIndex) {
state.batchesStartPending.splice(pendingFlagIndex, 1);
}
});
};
const finalizeBatch = function (queue, batchId, eventType) {

@@ -87,3 +74,2 @@ let finalState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _shared.BATCH_STATES.FINISHED;

batch.state = finalState;
if (additionalInfo) {

@@ -96,13 +82,11 @@ batch.additionalInfo = additionalInfo;

};
exports.finalizeBatch = finalizeBatch;
const cancelBatchForItem = (queue, itemId) => {
if ((0, _itemHelpers.getIsItemExists)(queue, itemId)) {
const data = getBatchDataFromItemId(queue, itemId),
batchId = data === null || data === void 0 ? void 0 : data.batch.id; //in case batch is aborted while async batch-start is pending we can reach here after batch was already removed
batchId = data === null || data === void 0 ? void 0 : data.batch.id;
//in case batch is aborted while async batch-start is pending we can reach here after batch was already removed
if (batchId) {
_shared.logger.debugLog("uploady.uploader.batchHelpers: cancelling batch: ", batchId);
finalizeBatch(queue, batchId, _consts.UPLOADER_EVENTS.BATCH_CANCEL, _shared.BATCH_STATES.CANCELLED);

@@ -116,13 +100,9 @@ removeBatchItems(queue, batchId);

};
exports.cancelBatchForItem = cancelBatchForItem;
const failBatchForItem = (queue, itemId, err) => {
const batch = getBatchFromItemId(queue, itemId),
batchId = batch.id;
batchId = batch.id;
_shared.logger.debugLog("uploady.uploader.batchHelpers: failing batch: ", {
batch
});
finalizeBatch(queue, batchId, _consts.UPLOADER_EVENTS.BATCH_ERROR, _shared.BATCH_STATES.ERROR, err.message);

@@ -132,5 +112,8 @@ removeBatchItems(queue, batchId);

};
exports.failBatchForItem = failBatchForItem;
const isItemBatchStartPending = (queue, itemId) => {
const batch = getBatchFromItemId(queue, itemId);
return queue.getState().batchesStartPending.includes(batch.id);
};
exports.isItemBatchStartPending = isItemBatchStartPending;
const isNewBatchStarting = (queue, itemId) => {

@@ -140,7 +123,9 @@ const batch = getBatchFromItemId(queue, itemId);

};
exports.isNewBatchStarting = isNewBatchStarting;
const loadNewBatchForItem = (queue, itemId) => {
const batch = getBatchFromItemId(queue, itemId);
queue.updateState(state => {
//storing pending flag as for batch with async start handler an item can be aborted and we'll get here AGAIN before start handler returned
state.batchesStartPending.push(batch.id);
});
return prepareBatchStartItems(queue, batch).then(_ref2 => {

@@ -151,7 +136,9 @@ let {

let alreadyFinished = false;
queue.updateState(state => {
const pendingFlagIndex = state.batchesStartPending.indexOf(batch.id);
state.batchesStartPending.splice(pendingFlagIndex, 1);
});
if (!cancelled) {
//in case of async batch start, its possible that when batch is aborted, items are already removed from queue
alreadyFinished = !(0, _itemHelpers.getIsItemExists)(queue, itemId);
if (!alreadyFinished) {

@@ -163,9 +150,6 @@ queue.updateState(state => {

}
return !cancelled && !alreadyFinished;
});
};
exports.loadNewBatchForItem = loadNewBatchForItem;
const cleanUpFinishedBatches = queue => {

@@ -181,6 +165,6 @@ (0, _shared.scheduleIdleWork)(() => {

orgItemCount
} = batch; //shouldnt be the case, but if wasnt cleaned before, it will now
} = batch;
//shouldnt be the case, but if wasnt cleaned before, it will now
const alreadyFinalized = getIsBatchFinalized(batch);
if (orgItemCount === finishedCounter) {

@@ -198,7 +182,7 @@ //batch may not be updated with completed/loaded with 100% values

}, 0);
}); //ensure we trigger progress event with completed = 100 for all items
});
//ensure we trigger progress event with completed = 100 for all items
triggerUploaderBatchEvent(queue, batchId, _consts.UPLOADER_EVENTS.BATCH_PROGRESS);
}
queue.updateState(state => {

@@ -209,9 +193,6 @@ if (state.currentBatch === batchId) {

});
_shared.logger.debugLog(`uploady.uploader.batchHelpers: cleaning up batch: ${batch.id}`);
if (!alreadyFinalized) {
finalizeBatch(queue, batchId, _consts.UPLOADER_EVENTS.BATCH_FINISH);
}
removeBatchItems(queue, batchId);

@@ -223,11 +204,10 @@ removeBatch(queue, batchId);

};
exports.cleanUpFinishedBatches = cleanUpFinishedBatches;
const triggerUploaderBatchEvent = (queue, batchId, event) => {
const state = queue.getState(),
batch = getBatchFromState(state, batchId),
//get the most uptodate batch data
stateItems = state.items;
const eventBatch = { ...(0, _simpleState.unwrap)(batch),
batch = getBatchFromState(state, batchId),
//get the most uptodate batch data
stateItems = state.items;
const eventBatch = {
...(0, _simpleState.unwrap)(batch),
items: batch.items.map(_ref4 => {

@@ -242,5 +222,3 @@ let {

};
exports.triggerUploaderBatchEvent = triggerUploaderBatchEvent;
const getIsBatchReady = (queue, batchId) => {

@@ -250,5 +228,3 @@ const batch = getBatchFromState(queue.getState(), batchId);

};
exports.getIsBatchReady = getIsBatchReady;
const detachRecycledFromPreviousBatch = (queue, item) => {

@@ -258,3 +234,2 @@ const {

} = item;
if (item.recycled && previousBatch && queue.getState().batches[previousBatch]) {

@@ -264,3 +239,2 @@ const {

} = getBatchFromItemId(queue, item.id);
if (batchId === previousBatch) {

@@ -275,3 +249,2 @@ queue.updateState(state => {

});
if (~index) {

@@ -284,5 +257,3 @@ batch.items.splice(index, 1);

};
exports.detachRecycledFromPreviousBatch = detachRecycledFromPreviousBatch;
const preparePendingForUpload = (queue, uploadOptions) => {

@@ -297,3 +268,2 @@ queue.updateState(state => {

} = batchData;
if (batch.state === _shared.BATCH_STATES.PENDING) {

@@ -309,5 +279,3 @@ batch.items.forEach(item => {

};
exports.preparePendingForUpload = preparePendingForUpload;
const removePendingBatches = queue => {

@@ -320,5 +288,3 @@ const batches = queue.getState().batches;

};
exports.removePendingBatches = removePendingBatches;
const incrementBatchFinishedCounter = (queue, batchId) => {

@@ -329,6 +295,5 @@ queue.updateState(state => {

};
exports.incrementBatchFinishedCounter = incrementBatchFinishedCounter;
const getIsBatchFinalized = batch => BATCH_FINISHED_STATES.includes(batch.state);
const getIsBatchFinalized = batch => BATCH_FINISHED_STATES.includes(batch.state);
/**

@@ -338,6 +303,3 @@ * As this is a data-destructive method it is meant

*/
exports.getIsBatchFinalized = getIsBatchFinalized;
const clearBatchData = (queue, batchId) => {

@@ -351,11 +313,8 @@ queue.updateState(state => {

const indx = state.batchQueue.indexOf(batchId);
if (~indx) {
state.batchQueue.splice(indx, 1);
}
if (state.currentBatch === batchId) {
state.currentBatch = null;
}
items.forEach(_ref6 => {

@@ -367,3 +326,2 @@ let {

const activeIndex = state.activeIds.indexOf(id);
if (~activeIndex) {

@@ -375,3 +333,2 @@ state.activeIds.splice(activeIndex, 1);

};
exports.clearBatchData = clearBatchData;

@@ -12,5 +12,3 @@ "use strict";

});
var _uploaderQueue = _interopRequireDefault(require("./uploaderQueue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -6,4 +6,4 @@ "use strict";

});
exports.getIsItemExists = exports.finalizeItem = void 0;
exports.getIsItemFinalized = exports.getIsItemExists = exports.finalizeItem = void 0;
var _consts = require("../consts");
const finalizeItem = function (queue, id) {

@@ -14,16 +14,13 @@ let delItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

batchId
} = state.items[id] || {};
} = state.items[id] || {
batchId: null
};
if (delItem) {
delete state.items[id];
}
const index = batchId ? state.itemQueue[batchId].indexOf(id) : -1;
if (~index) {
if (~index && batchId) {
state.itemQueue[batchId].splice(index, 1);
}
const activeIndex = state.activeIds.indexOf(id);
if (~activeIndex) {

@@ -34,7 +31,6 @@ state.activeIds.splice(activeIndex, 1);

};
exports.finalizeItem = finalizeItem;
const getIsItemExists = (queue, itemId) => !!queue.getState().items[itemId];
exports.getIsItemExists = getIsItemExists;
exports.getIsItemExists = getIsItemExists;
const getIsItemFinalized = item => _consts.ITEM_FINALIZE_STATES.includes(item.state);
exports.getIsItemFinalized = getIsItemFinalized;

@@ -7,13 +7,12 @@ "use strict";

exports.getItemsPrepareUpdater = void 0;
var _shared = require("@rpldy/shared");
var _itemHelpers = require("./itemHelpers");
const mergeWithUndefined = (0, _shared.getMerge)({
undefinedOverwrites: true
});
const processPrepareResponse = (eventType, items, options, updated) => {
let usedOptions = options,
usedItems = items;
if (updated) {
_shared.logger.debugLog(`uploader.queue: REQUEST_PRE_SEND(${eventType}) event returned updated items/options`, updated);
if (updated.items) {

@@ -24,19 +23,16 @@ //can't change items count at this point.

}
items = updated.items;
usedItems = updated.items;
}
if (updated.options) {
options = mergeWithUndefined({}, options, updated.options);
usedOptions = mergeWithUndefined({}, options, updated.options);
}
}
return {
items,
options,
items: usedItems,
options: usedOptions,
cancelled: updated === false
};
};
const triggerItemsPrepareEvent = (queue, eventSubject, items, options, eventType, validateResponse) => (0, _shared.triggerUpdater)(queue.trigger, eventType, eventSubject, options) // $FlowIssue - https://github.com/facebook/flow/issues/8215
const triggerItemsPrepareEvent = (queue, eventSubject, items, options, eventType, validateResponse) => (0, _shared.triggerUpdater)(queue.trigger, eventType, eventSubject, options)
// $FlowIssue - https://github.com/facebook/flow/issues/8215
.then(updated => {

@@ -46,3 +42,2 @@ validateResponse === null || validateResponse === void 0 ? void 0 : validateResponse(updated);

});
const persistPrepareResponse = (queue, prepared) => {

@@ -54,7 +49,11 @@ //for async prepare, items could already be cancelled before we reach here

prepared.items.forEach(i => {
state.items[i.id] = i;
//update item if it is NOT finished (ex: aborted)
if (!(0, _itemHelpers.getIsItemFinalized)(state.items[i.id])) {
state.items[i.id] = i;
}
});
state.batches[prepared.items[0].batchId].batchOptions = prepared.options;
}); //use objects from internal state(proxies) - not objects from user-land!
});
//use objects from internal state(proxies) - not objects from user-land!
const updatedState = queue.getState();

@@ -65,3 +64,2 @@ prepared.items = prepared.items.map(item => updatedState.items[item.id]);

};
const prepareItems = (queue, subject, retrieveItemsFromSubject, createEventSubject, validateResponse, eventType) => {

@@ -75,7 +73,5 @@ const items = retrieveItemsFromSubject(subject);

}
return prepared;
});
};
const getItemsPrepareUpdater = function (eventType, retrieveItemsFromSubject) {

@@ -86,3 +82,2 @@ let createEventSubject = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

};
exports.getItemsPrepareUpdater = getItemsPrepareUpdater;

@@ -7,15 +7,8 @@ "use strict";

exports.processAbortItem = exports.processAbortBatch = exports.processAbortAll = void 0;
var _shared = require("@rpldy/shared");
var _consts = require("../consts");
var _processFinishedRequest = _interopRequireDefault(require("./processFinishedRequest"));
var _processQueueNext = _interopRequireDefault(require("./processQueueNext"));
var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const getFinalizeAbortedItem = queue => (id, data) => (0, _processFinishedRequest.default)(queue, [{

@@ -25,3 +18,2 @@ id,

}], _processQueueNext.default);
const processAbortItem = (queue, id) => {

@@ -33,5 +25,3 @@ const abortItemMethod = queue.getOptions().abortItem;

};
exports.processAbortItem = processAbortItem;
const processAbortBatch = (queue, id) => {

@@ -41,5 +31,4 @@ const abortBatchMethod = queue.getOptions().abortBatch;

const state = queue.getState(),
batchData = state.batches[id],
batch = batchData === null || batchData === void 0 ? void 0 : batchData.batch;
batchData = state.batches[id],
batch = batchData === null || batchData === void 0 ? void 0 : batchData.batch;
if (batch && !(0, _batchHelpers.getIsBatchFinalized)(batch)) {

@@ -50,3 +39,2 @@ (0, _batchHelpers.finalizeBatch)(queue, id, _consts.UPLOADER_EVENTS.BATCH_ABORT, _shared.BATCH_STATES.ABORTED);

} = abortBatchMethod(batch, batchData.batchOptions, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions());
if (isFast) {

@@ -57,5 +45,3 @@ queue.clearBatchUploads(batch.id);

};
exports.processAbortBatch = processAbortBatch;
const processAbortAll = queue => {

@@ -69,3 +55,2 @@ const abortAllMethod = queue.getOptions().abortAll;

} = abortAllMethod(state.items, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions());
if (isFast) {

@@ -75,3 +60,2 @@ queue.clearAllUploads();

};
exports.processAbortAll = processAbortAll;

@@ -7,13 +7,8 @@ "use strict";

exports.default = void 0;
var _shared = require("@rpldy/shared");
var _consts = require("../consts");
var _processFinishedRequest = _interopRequireDefault(require("./processFinishedRequest"));
var _preSendPrepare = require("./preSendPrepare");
var _itemHelpers = require("./itemHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const preparePreRequestItems = (0, _preSendPrepare.getItemsPrepareUpdater)(_consts.UPLOADER_EVENTS.REQUEST_PRE_SEND, items => items, (items, options) => ({

@@ -23,3 +18,2 @@ items,

}));
const updateUploadingState = (queue, items, sendResult) => {

@@ -34,6 +28,4 @@ queue.updateState(state => {

};
const sendAllowedItems = (queue, itemsSendData, next) => {
var _queue$getState$batch;
const {

@@ -44,13 +36,10 @@ items,

const batch = (_queue$getState$batch = queue.getState().batches[items[0].batchId]) === null || _queue$getState$batch === void 0 ? void 0 : _queue$getState$batch.batch;
if (batch) {
//batch can be removed when using async pre-send/batch-start returning after user abort
let sendResult;
try {
sendResult = queue.sender.send(items, batch, options);
} catch (ex) {
_shared.logger.debugLog(`uploader.queue: sender failed with unexpected error`, ex); //provide error result so file(s) are marked as failed
_shared.logger.debugLog(`uploader.queue: sender failed with unexpected error`, ex);
//provide error result so file(s) are marked as failed
sendResult = {

@@ -66,3 +55,2 @@ request: Promise.resolve({

}
const {

@@ -72,3 +60,4 @@ request

updateUploadingState(queue, items, sendResult);
request //wait for server request to return
request
//wait for server request to return
.then(requestInfo => {

@@ -83,6 +72,4 @@ const finishedData = items.map(item => ({

};
const reportCancelledItems = (queue, items, cancelledResults, next) => {
const cancelledItemsIds = cancelledResults.map((isCancelled, index) => isCancelled ? items[index].id : null).filter(Boolean);
if (cancelledItemsIds.length) {

@@ -102,3 +89,2 @@ const finishedData = cancelledItemsIds.map(id => ({

};
const reportPreparedError = (error, queue, items, next) => {

@@ -119,10 +105,9 @@ const finishedData = items.map(_ref => {

(0, _processFinishedRequest.default)(queue, finishedData, next); //report about failed items
}; //make sure item is still pending. Something might have changed while waiting for ITEM_START handling. Maybe someone called abort...
};
//make sure item is still pending. Something might have changed while waiting for ITEM_START handling. Maybe someone called abort...
const getAllowedItem = (id, queue) => {
const item = queue.getState().items[id];
return item && !_consts.ITEM_FINALIZE_STATES.includes(item.state) ? item : undefined;
return item && !(0, _itemHelpers.getIsItemFinalized)(item) ? item : undefined;
};
const processAllowedItems = _ref2 => {

@@ -138,16 +123,14 @@ let {

const afterPreparePromise = allowedItems.length ? preparePreRequestItems(queue, allowedItems) : Promise.resolve();
let finalCancelledResults = cancelledResults;
return afterPreparePromise.catch(err => {
_shared.logger.debugLog("uploader.queue: encountered error while preparing items for request", err);
reportPreparedError(err, queue, items, next);
}).then(itemsSendData => {
let nextP;
if (itemsSendData) {
if (itemsSendData.cancelled) {
cancelledResults = ids.map(() => true);
finalCancelledResults = ids.map(() => true);
} else {
//make sure files aren't aborted while async prepare was waiting
const hasAborted = itemsSendData.items.some(item => _consts.ITEM_FINALIZE_STATES.includes(item.state));
const hasAborted = itemsSendData.items.some(item => (0, _itemHelpers.getIsItemFinalized)(item));
if (!hasAborted) {

@@ -163,22 +146,25 @@ //we dont need to wait for the response here

}
} //if not cancelled we can go to process more items immediately (and not wait for upload responses)
}
if (!reportCancelledItems(queue, items, cancelledResults, next)) {
//if not cancelled we can go to process more items immediately (and not wait for upload responses)
if (!reportCancelledItems(queue, items, finalCancelledResults, next)) {
nextP = next(queue); //when concurrent is allowed, we can go ahead and process more
} //returning promise for testing purposes
}
//returning promise for testing purposes
return nextP;
});
}; //send group of items to be uploaded
};
//send group of items to be uploaded
const processBatchItems = (queue, ids, next) => {
const state = queue.getState(); //ids will have more than one when grouping is allowed
const state = queue.getState();
//ids will have more than one when grouping is allowed
let items = Object.values(state.items);
items = items.filter(item =>
//ensure item was not finalized (ex: aborted) while waiting for async BATCH_START
ids.includes(item.id) && !(0, _itemHelpers.getIsItemFinalized)(item));
let items = Object.values(state.items);
items = items.filter(item => !!~ids.indexOf(item.id)); //allow user code cancel items from start event handler(s)
//allow user code cancel items from start event handler(s)
//returning promise for testing purposes
return Promise.all(items.map(i => queue.runCancellable(_consts.UPLOADER_EVENTS.ITEM_START, i))).then(cancelledResults => {

@@ -196,4 +182,3 @@ let allowedItems = cancelledResults.map((isCancelled, index) => isCancelled ? null : getAllowedItem(items[index].id, queue)).filter(Boolean);

};
var _default = processBatchItems;
exports.default = _default;

@@ -7,11 +7,6 @@ "use strict";

exports.default = exports.FILE_STATE_TO_EVENT_MAP = void 0;
var _shared = require("@rpldy/shared");
var _consts = require("../consts");
var _batchHelpers = require("./batchHelpers");
var _itemHelpers = require("./itemHelpers");
const FILE_STATE_TO_EVENT_MAP = {

@@ -27,5 +22,3 @@ [_shared.FILE_STATES.PENDING]: null,

exports.FILE_STATE_TO_EVENT_MAP = FILE_STATE_TO_EVENT_MAP;
const getIsFinalized = item => !!~_consts.ITEM_FINALIZE_STATES.indexOf(item.state);
const processFinishedRequest = (queue, finishedData, next) => {

@@ -38,3 +31,2 @@ finishedData.forEach(itemData => {

} = itemData;
_shared.logger.debugLog("uploader.processor.queue: request finished for item - ", {

@@ -44,3 +36,2 @@ id,

});
if (state.items[id]) {

@@ -52,10 +43,9 @@ queue.updateState(state => {

item.uploadStatus = info.status;
if (getIsFinalized(item)) {
delete state.aborts[id];
}
}); //get most up-to-date item data
});
//get most up-to-date item data
const item = queue.getState().items[id];
if (info.state === _shared.FILE_STATES.FINISHED && item.completed < 100) {

@@ -65,3 +55,2 @@ //ensure we trigger progress event with completed = 100 for all items

}
if (FILE_STATE_TO_EVENT_MAP[item.state]) {

@@ -71,18 +60,16 @@ //trigger UPLOADER EVENT for item based on its state

}
if (getIsFinalized(item)) {
(0, _batchHelpers.incrementBatchFinishedCounter)(queue, item.batchId); //trigger FINALIZE event
(0, _batchHelpers.incrementBatchFinishedCounter)(queue, item.batchId);
//trigger FINALIZE event
queue.trigger(_consts.UPLOADER_EVENTS.ITEM_FINALIZE, item);
}
}
(0, _itemHelpers.finalizeItem)(queue, id);
}); //ensure finished batches are remove from state
});
//ensure finished batches are removed from state
(0, _batchHelpers.cleanUpFinishedBatches)(queue);
next(queue);
};
var _default = processFinishedRequest;
exports.default = _default;

@@ -7,31 +7,21 @@ "use strict";

exports.getNextIdGroup = exports.findNextItemIndex = exports.default = void 0;
var _shared = require("@rpldy/shared");
var _processBatchItems = _interopRequireDefault(require("./processBatchItems"));
var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const getIsItemInActiveRequest = (queue, itemId) => {
return queue.getState().activeIds // $FlowIssue - no flat
.flat().includes(itemId);
return queue.getState().activeIds.flat().includes(itemId);
};
const getIsItemReady = item => item.state === _shared.FILE_STATES.ADDED;
const findNextItemIndex = queue => {
const state = queue.getState(),
itemQueue = state.itemQueue,
items = state.items;
itemQueue = state.itemQueue,
items = state.items;
let nextItemId = null,
batchIndex = 0,
itemIndex = 0,
batchId = state.batchQueue[batchIndex];
batchIndex = 0,
itemIndex = 0,
batchId = state.batchQueue[batchIndex];
while (batchId && !nextItemId) {
if ((0, _batchHelpers.getIsBatchReady)(queue, batchId)) {
nextItemId = itemQueue[batchId][itemIndex];
while (nextItemId && (getIsItemInActiveRequest(queue, nextItemId) || !getIsItemReady(items[nextItemId]))) {

@@ -42,3 +32,2 @@ itemIndex += 1;

}
if (!nextItemId) {

@@ -50,24 +39,19 @@ batchIndex += 1;

}
return nextItemId ? [batchId, itemIndex] : null;
};
exports.findNextItemIndex = findNextItemIndex;
const getNextIdGroup = queue => {
const state = queue.getState(),
itemQueue = state.itemQueue,
[nextBatchId, nextItemIndex] = findNextItemIndex(queue) || [];
itemQueue = state.itemQueue,
[nextBatchId, nextItemIndex] = findNextItemIndex(queue) || [];
let nextId = nextBatchId && ~nextItemIndex ? itemQueue[nextBatchId][nextItemIndex] : null,
nextGroup;
nextGroup;
if (nextId) {
const {
batchOptions
} = state.batches[nextBatchId],
groupMax = batchOptions.maxGroupSize || 0;
batchOptions
} = state.batches[nextBatchId],
groupMax = batchOptions.maxGroupSize || 0;
if (batchOptions.grouped && groupMax > 1) {
const batchItems = state.itemQueue[nextBatchId]; //get ids for the batch with max of configured group size (never mix items from different batches)
const batchItems = state.itemQueue[nextBatchId];
//get ids for the batch with max of configured group size (never mix items from different batches)
nextGroup = batchItems.slice(nextItemIndex, nextItemIndex + groupMax);

@@ -78,8 +62,5 @@ } else {

}
return nextGroup;
};
exports.getNextIdGroup = getNextIdGroup;
const updateItemsAsActive = (queue, ids) => {

@@ -91,31 +72,29 @@ queue.updateState(state => {

};
const processNextWithBatch = (queue, ids) => {
let newBatchP;
updateItemsAsActive(queue, ids);
if ((0, _batchHelpers.isNewBatchStarting)(queue, ids[0])) {
newBatchP = (0, _batchHelpers.loadNewBatchForItem)(queue, ids[0]).then(allowBatch => {
let cancelled = !allowBatch;
if (cancelled) {
(0, _batchHelpers.cancelBatchForItem)(queue, ids[0]);
if (!(0, _batchHelpers.isItemBatchStartPending)(queue, ids[0])) {
updateItemsAsActive(queue, ids);
if ((0, _batchHelpers.isNewBatchStarting)(queue, ids[0])) {
newBatchP = (0, _batchHelpers.loadNewBatchForItem)(queue, ids[0]).then(allowBatch => {
let cancelled = !allowBatch;
if (cancelled) {
(0, _batchHelpers.cancelBatchForItem)(queue, ids[0]);
processNext(queue);
}
return cancelled;
}).catch(err => {
_shared.logger.debugLog("uploader.processor: encountered error while preparing batch for request", err);
(0, _batchHelpers.failBatchForItem)(queue, ids[0], err);
processNext(queue);
}
return cancelled;
}).catch(err => {
_shared.logger.debugLog("uploader.processor: encountered error while preparing batch for request", err);
(0, _batchHelpers.failBatchForItem)(queue, ids[0], err);
processNext(queue);
return true;
});
return true;
});
} else {
newBatchP = Promise.resolve(false);
}
} else {
newBatchP = Promise.resolve(false);
//dont continue processing while batch is pending start event handling
newBatchP = Promise.resolve(true);
}
return newBatchP;
};
const processNext = queue => {

@@ -125,10 +104,8 @@ //using promise only for testing purposes, actual code doesnt require awaiting on this method

const ids = getNextIdGroup(queue);
if (ids) {
const currentCount = queue.getCurrentActiveCount(),
{
concurrent = 0,
maxConcurrent = 0
} = queue.getOptions();
{
concurrent = !!0,
maxConcurrent = 0
} = queue.getOptions();
if (!currentCount || concurrent && currentCount < maxConcurrent) {

@@ -139,7 +116,5 @@ _shared.logger.debugLog("uploader.processor: Processing next upload - ", {

});
processPromise = processNextWithBatch(queue, ids).then(failedOrCancelled => {
if (!failedOrCancelled) {
(0, _processBatchItems.default)(queue, ids, processNext);
if (concurrent) {

@@ -153,7 +128,5 @@ //concurrent process next immediately (otherwise async event callbacks will hang processing next until they complete)

}
return processPromise;
};
var _default = processNext;
exports.default = _default;

@@ -7,17 +7,9 @@ "use strict";

exports.default = void 0;
var _shared = require("@rpldy/shared");
var _simpleState = _interopRequireDefault(require("@rpldy/simple-state"));
var _consts = require("../consts");
var _processQueueNext = _interopRequireDefault(require("./processQueueNext"));
var _processAbort = require("./processAbort");
var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const createUploaderQueue = (options, trigger, cancellable, sender, uploaderId) => {

@@ -31,2 +23,3 @@ const {

currentBatch: null,
batchesStartPending: [],
batches: {},

@@ -37,9 +30,6 @@ items: {},

});
const getState = () => state;
const updateState = updater => {
update(updater);
};
const add = item => {

@@ -49,7 +39,5 @@ if (state.items[item.id] && !item.recycled) {

}
if (item.recycled) {
(0, _batchHelpers.detachRecycledFromPreviousBatch)(queueState, item);
}
updateState(state => {

@@ -59,3 +47,2 @@ state.items[item.id] = item;

};
const handleItemProgress = (item, completed, loaded) => {

@@ -67,14 +54,12 @@ if (state.items[item.id]) {

stateItem.completed = completed;
}); //trigger item progress event for the outside
});
//trigger item progress event for the outside
trigger(_consts.UPLOADER_EVENTS.ITEM_PROGRESS, getState().items[item.id]);
}
};
sender.on(_consts.SENDER_EVENTS.ITEM_PROGRESS, handleItemProgress);
sender.on(_consts.SENDER_EVENTS.BATCH_PROGRESS, batch => {
var _state$batches$batch$;
const batchItems = (_state$batches$batch$ = state.batches[batch.id]) === null || _state$batches$batch$ === void 0 ? void 0 : _state$batches$batch$.batch.items;
if (batchItems) {

@@ -95,6 +80,6 @@ const [completed, loaded] = batchItems.reduce((res, _ref2) => {

updateState(state => {
const stateBatch = state.batches[batch.id].batch; //average of completed percentage for batch items
stateBatch.completed = completed / batchItems.length; //sum of loaded bytes for batch items
const stateBatch = state.batches[batch.id].batch;
//average of completed percentage for batch items
stateBatch.completed = completed / batchItems.length;
//sum of loaded bytes for batch items
stateBatch.loaded = loaded;

@@ -117,7 +102,5 @@ });

}
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return cancellable(name, ...args);

@@ -140,3 +123,2 @@ },

_shared.logger.debugLog(`uploader.queue: started scheduled work to clear batch uploads (${batchId})`);
if (getState().batches[batchId]) {

@@ -148,7 +130,5 @@ (0, _batchHelpers.clearBatchData)(queueState, batchId);

};
if ((0, _shared.hasWindow)() && _shared.logger.isDebugOn()) {
window[`__rpldy_${uploaderId}_queue_state`] = queueState;
}
return {

@@ -164,3 +144,2 @@ updateState,

}
(0, _processQueueNext.default)(queueState);

@@ -190,3 +169,2 @@ },

}
return (0, _processAbort.processAbortItem)(queueState, ...args);

@@ -198,3 +176,2 @@ },

}
return (0, _processAbort.processAbortBatch)(queueState, ...args);

@@ -206,3 +183,2 @@ },

}
return (0, _processAbort.processAbortAll)(queueState, ...args);

@@ -219,4 +195,3 @@ },

};
var _default = createUploaderQueue;
exports.default = _default;

@@ -7,32 +7,20 @@ "use strict";

exports.default = void 0;
var _lifeEvents = _interopRequireWildcard(require("@rpldy/life-events"));
var _shared = require("@rpldy/shared");
var _abort = _interopRequireDefault(require("@rpldy/abort"));
var _processor = _interopRequireDefault(require("./processor"));
var _consts = require("./consts");
var _utils = require("./utils");
var _composeEnhancers = _interopRequireDefault(require("./composeEnhancers"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const EVENT_NAMES = Object.values(_consts.UPLOADER_EVENTS);
const EXT_OUTSIDE_ENHANCER_TIME = "Uploady - uploader extensions can only be registered by enhancers",
EXT_ALREADY_EXISTS = "Uploady - uploader extension by this name [%s] already exists";
EXT_ALREADY_EXISTS = "Uploady - uploader extension by this name [%s] already exists";
let counter = 0;
const getComposedEnhancer = extEnhancer => (0, _composeEnhancers.default)((0, _abort.default)(), extEnhancer);
const getEnhancedUploader = (uploader, options, triggerWithUnwrap, setEnhancerTime) => {
//TODO: create raw-uploader without internal enhancers (while default-uploader will use abort & xhr-sender enhancers)
//TODO need new mechanism for registering and using internal methods (abort, send)

@@ -43,7 +31,7 @@ //that will use enhancers but also allow overrides without having to expose the method in the options (ie: send)

const enhanced = enhancer(uploader, triggerWithUnwrap);
setEnhancerTime(false); //graceful handling for enhancer forgetting to return uploader
setEnhancerTime(false);
//graceful handling for enhancer forgetting to return uploader
return enhanced || uploader;
};
const createUploader = options => {

@@ -54,3 +42,2 @@ counter += 1;

const extensions = {};
_shared.logger.debugLog(`uploady.uploader: creating new instance (${uploaderId})`, {

@@ -60,8 +47,7 @@ options,

});
let uploaderOptions = (0, _utils.getMandatoryOptions)(options);
const clearPending = () => {
processor.clearPendingBatches();
};
/**

@@ -71,7 +57,5 @@ * process batches that weren't auto-uploaded

const getOptions = () => {
return (0, _shared.clone)(uploaderOptions);
};
let {

@@ -85,3 +69,2 @@ trigger,

uploaderOptions = (0, _shared.merge)({}, uploaderOptions, updateOptions); //need deep merge for destination
return uploader;

@@ -91,10 +74,7 @@ },

const processOptions = (0, _shared.merge)({}, uploaderOptions, addOptions);
if (processOptions.clearPendingOnAdd) {
clearPending();
}
return processor.addNewBatch(files, uploader.id, processOptions).then(batch => {
let resultP;
if (batch.items.length) {

@@ -105,3 +85,2 @@ resultP = processor.runCancellable(_consts.UPLOADER_EVENTS.BATCH_ADD, batch, processOptions).then(isCancelled => {

${String(processOptions.autoUpload)}`, batch.items);
if (processOptions.autoUpload) {

@@ -118,3 +97,2 @@ processor.process(batch);

}
return resultP;

@@ -137,5 +115,3 @@ });

(0, _shared.invariant)(!extensions[name], EXT_ALREADY_EXISTS, name);
_shared.logger.debugLog(`uploady.uploader: registering extension: ${name.toString()}`, methods);
extensions[name] = methods;

@@ -150,6 +126,6 @@ },

});
/**
* ensures that data being exposed to client-land isnt a proxy, only pojos
*/
const triggerWithUnwrap = function (name) {

@@ -159,3 +135,2 @@ for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

}
//delays unwrap to the very last time on trigger. Will only unwrap if there are listeners

@@ -165,3 +140,2 @@ const lp = (0, _lifeEvents.createLifePack)(() => data.map(_utils.deepProxyUnwrap));

};
const cancellable = (0, _shared.triggerCancellable)(triggerWithUnwrap);

@@ -174,4 +148,3 @@ const enhancedUploader = getEnhancedUploader(uploader, uploaderOptions, triggerWithUnwrap, state => {

};
var _default = createUploader;
exports.default = _default;

@@ -7,11 +7,6 @@ "use strict";

exports.getMandatoryOptions = exports.getIsFileList = exports.deepProxyUnwrap = void 0;
var _shared = require("@rpldy/shared");
var _simpleState = require("@rpldy/simple-state");
var _defaults = require("./defaults");
const FILE_LIST_SUPPORT = (0, _shared.hasWindow)() && "FileList" in window;
const getMandatoryDestination = dest => {

@@ -23,5 +18,5 @@ return {

};
const getMandatoryOptions = options => {
return { ..._defaults.DEFAULT_OPTIONS,
return {
..._defaults.DEFAULT_OPTIONS,
...options,

@@ -31,7 +26,7 @@ destination: options && options.destination ? getMandatoryDestination(options.destination) : null

};
exports.getMandatoryOptions = getMandatoryOptions;
const getIsFileList = files =>
//in case files list was created in a different context(window) need to check toString
FILE_LIST_SUPPORT && files instanceof FileList || files.toString() === "[object FileList]";
const getIsFileList = files => //in case files list was created in a different context(window) need to check toString
FILE_LIST_SUPPORT && files instanceof FileList || files.toString() === "[object FileList]";
/***

@@ -41,10 +36,6 @@ * will unwrap object from proxy

*/
exports.getIsFileList = getIsFileList;
const deepProxyUnwrap = function (obj) {
let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let result = obj;
if (!(0, _shared.isProduction)()) {

@@ -60,6 +51,4 @@ if (level < 3 && (0, _simpleState.isProxy)(obj)) {

}
return result;
};
exports.deepProxyUnwrap = deepProxyUnwrap;

@@ -1,12 +0,14 @@

import { BATCH_STATES, createBatchItem, isPromise, getIsBatchItem } from "@rpldy/shared";
import { BATCH_STATES, createBatchItem, getIsBatchItem, isPromise } from "@rpldy/shared";
import { DEFAULT_FILTER } from "./defaults";
import { getIsFileList } from "./utils";
let bCounter = 0;
const processFiles = (batchId, files, isPending, fileFilter) => {
//we need a simple array of (file, url) to pass to filter fn if its provided (files can be recycled batch items)
const all = fileFilter ? Array.prototype //$FlowExpectedError[method-unbinding] flow 0.153 !!!
.map.call(files, f => getIsBatchItem(f) ? f.file || f.url : f) : //in case no filter fn, no need to map it
const all = fileFilter ? Array.prototype
//$FlowExpectedError[method-unbinding] flow 0.153 !!!
.map.call(files, f => getIsBatchItem(f) ? f.file || f.url : f) :
//in case no filter fn, no need to map it
[];
return Promise.all(Array.prototype //$FlowExpectedError[method-unbinding] flow 0.153 !!!
return Promise.all(Array.prototype
//$FlowExpectedError[method-unbinding] flow 0.153 !!!
.map.call(files, (f, index) => {

@@ -17,3 +19,2 @@ const filterResult = (fileFilter || DEFAULT_FILTER)(all[index], index, all);

};
const createBatch = (files, uploaderId, options) => {

@@ -23,5 +24,5 @@ bCounter += 1;

const isFileList = getIsFileList(files);
files = Array.isArray(files) || isFileList ? files : [files];
const usedFiles = Array.isArray(files) || isFileList ? files : [files];
const isPending = !options.autoUpload;
return processFiles(id, files, isPending, options.fileFilter).then(items => {
return processFiles(id, usedFiles, isPending, options.fileFilter).then(items => {
return {

@@ -39,3 +40,2 @@ id,

};
export default createBatch;
import { isFunction, logger, throttle } from "@rpldy/shared";
import addLife from "@rpldy/life-events"; //TODO (v2): Load using enhancer to allow using uploader (tree-shake) that doesnt import the defualt sender if not needed
import addLife from "@rpldy/life-events";
//TODO (v2): Load using enhancer to allow using uploader (tree-shake) that doesnt import the defualt sender if not needed
import defaultSend from "@rpldy/sender";
import { PROGRESS_DELAY, SENDER_EVENTS } from "./consts";
import { DEFAULT_OPTIONS, DEFAULT_PARAM_NAME } from "./defaults";
const reportItemsProgress = (items, completed, loaded, trigger) => {

@@ -14,11 +14,9 @@ items.forEach(item => {

};
const onItemUploadProgress = (items, batch, e, trigger) => {
const completed = Math.min(e.loaded / e.total * 100, 100),
completedPerItem = completed / items.length,
loadedAverage = e.loaded / items.length;
completedPerItem = completed / items.length,
loadedAverage = e.loaded / items.length;
reportItemsProgress(items, completedPerItem, loadedAverage, trigger);
trigger(SENDER_EVENTS.BATCH_PROGRESS, batch);
};
const createBatchItemsSender = () => {

@@ -31,3 +29,3 @@ const {

const destination = batchOptions.destination,
url = destination === null || destination === void 0 ? void 0 : destination.url;
url = destination === null || destination === void 0 ? void 0 : destination.url;
const throttledProgress = throttle(e => onItemUploadProgress(items, batch, e, trigger), PROGRESS_DELAY, true);

@@ -38,3 +36,4 @@ const send = isFunction(batchOptions.send) ? batchOptions.send : defaultSend;

paramName: (destination === null || destination === void 0 ? void 0 : destination.filesParamName) || batchOptions.inputFieldName || DEFAULT_PARAM_NAME,
params: { //TODO: might need to rethink the order here:
params: {
//TODO: might need to rethink the order here:
...batchOptions.params,

@@ -56,3 +55,2 @@ ...(destination === null || destination === void 0 ? void 0 : destination.params)

};
export default createBatchItemsSender;

@@ -5,3 +5,2 @@ const composeEnhancers = function () {

}
return function (uploader) {

@@ -11,7 +10,5 @@ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

}
return enhancers.reduce((enhanced, e) => e(enhanced, ...args) || enhanced, uploader);
};
};
export default composeEnhancers;
import createUploadQueue from "./queue";
import createItemsSender from "./batchItemsSender";
import createBatch from "./batch";
const createProcessor = (trigger, cancellable, options, uploaderId) => {
const sender = createItemsSender(),
queue = createUploadQueue(options, trigger, cancellable, sender, uploaderId);
queue = createUploadQueue(options, trigger, cancellable, sender, uploaderId);
const runCancellable = queue.runCancellable;

@@ -37,3 +36,2 @@ return {

};
export default createProcessor;

@@ -9,4 +9,5 @@ import { BATCH_STATES, logger, merge, FILE_STATES, scheduleIdleWork } from "@rpldy/shared";

batch
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
batch: false
};
if (batch) {

@@ -18,9 +19,6 @@ throw new Error(`BATCH_START event handlers cannot update batch data. Only items & options`);

const BATCH_FINISHED_STATES = [BATCH_STATES.ABORTED, BATCH_STATES.CANCELLED, BATCH_STATES.FINISHED, BATCH_STATES.ERROR];
const getBatchFromState = (state, id) => state.batches[id].batch;
const getBatch = (queue, id) => {
return getBatchFromState(queue.getState(), id);
};
const getBatchDataFromItemId = (queue, itemId) => {

@@ -31,7 +29,5 @@ const state = queue.getState();

};
const getBatchFromItemId = (queue, itemId) => {
return getBatchDataFromItemId(queue, itemId).batch;
};
const removeBatchItems = (queue, batchId) => {

@@ -46,3 +42,2 @@ const batch = getBatch(queue, batchId);

};
const removeBatch = (queue, batchId) => {

@@ -53,9 +48,11 @@ queue.updateState(state => {

const batchQueueIndex = state.batchQueue.indexOf(batchId);
if (~batchQueueIndex) {
state.batchQueue.splice(batchQueueIndex, 1);
}
const pendingFlagIndex = state.batchesStartPending.indexOf(batchId);
if (~pendingFlagIndex) {
state.batchesStartPending.splice(pendingFlagIndex, 1);
}
});
};
const finalizeBatch = function (queue, batchId, eventType) {

@@ -67,3 +64,2 @@ let finalState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : BATCH_STATES.FINISHED;

batch.state = finalState;
if (additionalInfo) {

@@ -76,8 +72,8 @@ batch.additionalInfo = additionalInfo;

};
const cancelBatchForItem = (queue, itemId) => {
if (getIsItemExists(queue, itemId)) {
const data = getBatchDataFromItemId(queue, itemId),
batchId = data === null || data === void 0 ? void 0 : data.batch.id; //in case batch is aborted while async batch-start is pending we can reach here after batch was already removed
batchId = data === null || data === void 0 ? void 0 : data.batch.id;
//in case batch is aborted while async batch-start is pending we can reach here after batch was already removed
if (batchId) {

@@ -93,6 +89,5 @@ logger.debugLog("uploady.uploader.batchHelpers: cancelling batch: ", batchId);

};
const failBatchForItem = (queue, itemId, err) => {
const batch = getBatchFromItemId(queue, itemId),
batchId = batch.id;
batchId = batch.id;
logger.debugLog("uploady.uploader.batchHelpers: failing batch: ", {

@@ -105,3 +100,6 @@ batch

};
const isItemBatchStartPending = (queue, itemId) => {
const batch = getBatchFromItemId(queue, itemId);
return queue.getState().batchesStartPending.includes(batch.id);
};
const isNewBatchStarting = (queue, itemId) => {

@@ -111,5 +109,8 @@ const batch = getBatchFromItemId(queue, itemId);

};
const loadNewBatchForItem = (queue, itemId) => {
const batch = getBatchFromItemId(queue, itemId);
queue.updateState(state => {
//storing pending flag as for batch with async start handler an item can be aborted and we'll get here AGAIN before start handler returned
state.batchesStartPending.push(batch.id);
});
return prepareBatchStartItems(queue, batch).then(_ref2 => {

@@ -120,7 +121,9 @@ let {

let alreadyFinished = false;
queue.updateState(state => {
const pendingFlagIndex = state.batchesStartPending.indexOf(batch.id);
state.batchesStartPending.splice(pendingFlagIndex, 1);
});
if (!cancelled) {
//in case of async batch start, its possible that when batch is aborted, items are already removed from queue
alreadyFinished = !getIsItemExists(queue, itemId);
if (!alreadyFinished) {

@@ -132,7 +135,5 @@ queue.updateState(state => {

}
return !cancelled && !alreadyFinished;
});
};
const cleanUpFinishedBatches = queue => {

@@ -148,6 +149,6 @@ scheduleIdleWork(() => {

orgItemCount
} = batch; //shouldnt be the case, but if wasnt cleaned before, it will now
} = batch;
//shouldnt be the case, but if wasnt cleaned before, it will now
const alreadyFinalized = getIsBatchFinalized(batch);
if (orgItemCount === finishedCounter) {

@@ -165,7 +166,7 @@ //batch may not be updated with completed/loaded with 100% values

}, 0);
}); //ensure we trigger progress event with completed = 100 for all items
});
//ensure we trigger progress event with completed = 100 for all items
triggerUploaderBatchEvent(queue, batchId, UPLOADER_EVENTS.BATCH_PROGRESS);
}
queue.updateState(state => {

@@ -177,7 +178,5 @@ if (state.currentBatch === batchId) {

logger.debugLog(`uploady.uploader.batchHelpers: cleaning up batch: ${batch.id}`);
if (!alreadyFinalized) {
finalizeBatch(queue, batchId, UPLOADER_EVENTS.BATCH_FINISH);
}
removeBatchItems(queue, batchId);

@@ -189,9 +188,9 @@ removeBatch(queue, batchId);

};
const triggerUploaderBatchEvent = (queue, batchId, event) => {
const state = queue.getState(),
batch = getBatchFromState(state, batchId),
//get the most uptodate batch data
stateItems = state.items;
const eventBatch = { ...unwrap(batch),
batch = getBatchFromState(state, batchId),
//get the most uptodate batch data
stateItems = state.items;
const eventBatch = {
...unwrap(batch),
items: batch.items.map(_ref4 => {

@@ -206,3 +205,2 @@ let {

};
const getIsBatchReady = (queue, batchId) => {

@@ -212,3 +210,2 @@ const batch = getBatchFromState(queue.getState(), batchId);

};
const detachRecycledFromPreviousBatch = (queue, item) => {

@@ -218,3 +215,2 @@ const {

} = item;
if (item.recycled && previousBatch && queue.getState().batches[previousBatch]) {

@@ -224,3 +220,2 @@ const {

} = getBatchFromItemId(queue, item.id);
if (batchId === previousBatch) {

@@ -235,3 +230,2 @@ queue.updateState(state => {

});
if (~index) {

@@ -244,3 +238,2 @@ batch.items.splice(index, 1);

};
const preparePendingForUpload = (queue, uploadOptions) => {

@@ -255,3 +248,2 @@ queue.updateState(state => {

} = batchData;
if (batch.state === BATCH_STATES.PENDING) {

@@ -267,3 +259,2 @@ batch.items.forEach(item => {

};
const removePendingBatches = queue => {

@@ -276,3 +267,2 @@ const batches = queue.getState().batches;

};
const incrementBatchFinishedCounter = (queue, batchId) => {

@@ -283,4 +273,4 @@ queue.updateState(state => {

};
const getIsBatchFinalized = batch => BATCH_FINISHED_STATES.includes(batch.state);
const getIsBatchFinalized = batch => BATCH_FINISHED_STATES.includes(batch.state);
/**

@@ -290,4 +280,2 @@ * As this is a data-destructive method it is meant

*/
const clearBatchData = (queue, batchId) => {

@@ -301,11 +289,8 @@ queue.updateState(state => {

const indx = state.batchQueue.indexOf(batchId);
if (~indx) {
state.batchQueue.splice(indx, 1);
}
if (state.currentBatch === batchId) {
state.currentBatch = null;
}
items.forEach(_ref6 => {

@@ -317,3 +302,2 @@ let {

const activeIndex = state.activeIds.indexOf(id);
if (~activeIndex) {

@@ -325,3 +309,2 @@ state.activeIds.splice(activeIndex, 1);

};
export { loadNewBatchForItem, isNewBatchStarting, cancelBatchForItem, getBatchFromItemId, getBatchDataFromItemId, cleanUpFinishedBatches, triggerUploaderBatchEvent, getIsBatchReady, getBatchFromState, detachRecycledFromPreviousBatch, preparePendingForUpload, removePendingBatches, incrementBatchFinishedCounter, getIsBatchFinalized, failBatchForItem, finalizeBatch, removeBatchItems, clearBatchData };
export { loadNewBatchForItem, isNewBatchStarting, cancelBatchForItem, getBatchFromItemId, getBatchDataFromItemId, cleanUpFinishedBatches, triggerUploaderBatchEvent, getIsBatchReady, getBatchFromState, detachRecycledFromPreviousBatch, preparePendingForUpload, removePendingBatches, incrementBatchFinishedCounter, getIsBatchFinalized, failBatchForItem, finalizeBatch, removeBatchItems, clearBatchData, isItemBatchStartPending };

@@ -0,1 +1,2 @@

import { ITEM_FINALIZE_STATES } from "../consts";
const finalizeItem = function (queue, id) {

@@ -6,16 +7,13 @@ let delItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

batchId
} = state.items[id] || {};
} = state.items[id] || {
batchId: null
};
if (delItem) {
delete state.items[id];
}
const index = batchId ? state.itemQueue[batchId].indexOf(id) : -1;
if (~index) {
if (~index && batchId) {
state.itemQueue[batchId].splice(index, 1);
}
const activeIndex = state.activeIds.indexOf(id);
if (~activeIndex) {

@@ -26,5 +24,4 @@ state.activeIds.splice(activeIndex, 1);

};
const getIsItemExists = (queue, itemId) => !!queue.getState().items[itemId];
export { finalizeItem, getIsItemExists };
const getIsItemFinalized = item => ITEM_FINALIZE_STATES.includes(item.state);
export { finalizeItem, getIsItemExists, getIsItemFinalized };
import { getMerge, isSamePropInArrays, logger, triggerUpdater } from "@rpldy/shared";
import { getIsItemFinalized } from "./itemHelpers";
const mergeWithUndefined = getMerge({
undefinedOverwrites: true
});
const processPrepareResponse = (eventType, items, options, updated) => {
let usedOptions = options,
usedItems = items;
if (updated) {
logger.debugLog(`uploader.queue: REQUEST_PRE_SEND(${eventType}) event returned updated items/options`, updated);
if (updated.items) {

@@ -15,19 +16,16 @@ //can't change items count at this point.

}
items = updated.items;
usedItems = updated.items;
}
if (updated.options) {
options = mergeWithUndefined({}, options, updated.options);
usedOptions = mergeWithUndefined({}, options, updated.options);
}
}
return {
items,
options,
items: usedItems,
options: usedOptions,
cancelled: updated === false
};
};
const triggerItemsPrepareEvent = (queue, eventSubject, items, options, eventType, validateResponse) => triggerUpdater(queue.trigger, eventType, eventSubject, options) // $FlowIssue - https://github.com/facebook/flow/issues/8215
const triggerItemsPrepareEvent = (queue, eventSubject, items, options, eventType, validateResponse) => triggerUpdater(queue.trigger, eventType, eventSubject, options)
// $FlowIssue - https://github.com/facebook/flow/issues/8215
.then(updated => {

@@ -37,3 +35,2 @@ validateResponse === null || validateResponse === void 0 ? void 0 : validateResponse(updated);

});
const persistPrepareResponse = (queue, prepared) => {

@@ -45,7 +42,11 @@ //for async prepare, items could already be cancelled before we reach here

prepared.items.forEach(i => {
state.items[i.id] = i;
//update item if it is NOT finished (ex: aborted)
if (!getIsItemFinalized(state.items[i.id])) {
state.items[i.id] = i;
}
});
state.batches[prepared.items[0].batchId].batchOptions = prepared.options;
}); //use objects from internal state(proxies) - not objects from user-land!
});
//use objects from internal state(proxies) - not objects from user-land!
const updatedState = queue.getState();

@@ -56,3 +57,2 @@ prepared.items = prepared.items.map(item => updatedState.items[item.id]);

};
const prepareItems = (queue, subject, retrieveItemsFromSubject, createEventSubject, validateResponse, eventType) => {

@@ -66,7 +66,5 @@ const items = retrieveItemsFromSubject(subject);

}
return prepared;
});
};
const getItemsPrepareUpdater = function (eventType, retrieveItemsFromSubject) {

@@ -77,3 +75,2 @@ let createEventSubject = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

};
export { getItemsPrepareUpdater };

@@ -6,3 +6,2 @@ import { invariant, BATCH_STATES } from "@rpldy/shared";

import { getIsBatchFinalized, finalizeBatch } from "./batchHelpers";
const getFinalizeAbortedItem = queue => (id, data) => processFinishedRequest(queue, [{

@@ -12,3 +11,2 @@ id,

}], processQueueNext);
const processAbortItem = (queue, id) => {

@@ -20,3 +18,2 @@ const abortItemMethod = queue.getOptions().abortItem;

};
const processAbortBatch = (queue, id) => {

@@ -26,5 +23,4 @@ const abortBatchMethod = queue.getOptions().abortBatch;

const state = queue.getState(),
batchData = state.batches[id],
batch = batchData === null || batchData === void 0 ? void 0 : batchData.batch;
batchData = state.batches[id],
batch = batchData === null || batchData === void 0 ? void 0 : batchData.batch;
if (batch && !getIsBatchFinalized(batch)) {

@@ -35,3 +31,2 @@ finalizeBatch(queue, id, UPLOADER_EVENTS.BATCH_ABORT, BATCH_STATES.ABORTED);

} = abortBatchMethod(batch, batchData.batchOptions, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions());
if (isFast) {

@@ -42,3 +37,2 @@ queue.clearBatchUploads(batch.id);

};
const processAbortAll = queue => {

@@ -52,3 +46,2 @@ const abortAllMethod = queue.getOptions().abortAll;

} = abortAllMethod(state.items, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions());
if (isFast) {

@@ -58,3 +51,2 @@ queue.clearAllUploads();

};
export { processAbortItem, processAbortBatch, processAbortAll };
import { FILE_STATES, logger } from "@rpldy/shared";
import { ITEM_FINALIZE_STATES, UPLOADER_EVENTS } from "../consts";
import { UPLOADER_EVENTS } from "../consts";
import processFinishedRequest from "./processFinishedRequest";
import { getItemsPrepareUpdater } from "./preSendPrepare";
import { getIsItemFinalized } from "./itemHelpers";
const preparePreRequestItems = getItemsPrepareUpdater(UPLOADER_EVENTS.REQUEST_PRE_SEND, items => items, (items, options) => ({

@@ -9,3 +10,2 @@ items,

}));
const updateUploadingState = (queue, items, sendResult) => {

@@ -20,6 +20,4 @@ queue.updateState(state => {

};
const sendAllowedItems = (queue, itemsSendData, next) => {
var _queue$getState$batch;
const {

@@ -30,12 +28,10 @@ items,

const batch = (_queue$getState$batch = queue.getState().batches[items[0].batchId]) === null || _queue$getState$batch === void 0 ? void 0 : _queue$getState$batch.batch;
if (batch) {
//batch can be removed when using async pre-send/batch-start returning after user abort
let sendResult;
try {
sendResult = queue.sender.send(items, batch, options);
} catch (ex) {
logger.debugLog(`uploader.queue: sender failed with unexpected error`, ex); //provide error result so file(s) are marked as failed
logger.debugLog(`uploader.queue: sender failed with unexpected error`, ex);
//provide error result so file(s) are marked as failed
sendResult = {

@@ -51,3 +47,2 @@ request: Promise.resolve({

}
const {

@@ -57,3 +52,4 @@ request

updateUploadingState(queue, items, sendResult);
request //wait for server request to return
request
//wait for server request to return
.then(requestInfo => {

@@ -68,6 +64,4 @@ const finishedData = items.map(item => ({

};
const reportCancelledItems = (queue, items, cancelledResults, next) => {
const cancelledItemsIds = cancelledResults.map((isCancelled, index) => isCancelled ? items[index].id : null).filter(Boolean);
if (cancelledItemsIds.length) {

@@ -87,3 +81,2 @@ const finishedData = cancelledItemsIds.map(id => ({

};
const reportPreparedError = (error, queue, items, next) => {

@@ -104,10 +97,9 @@ const finishedData = items.map(_ref => {

processFinishedRequest(queue, finishedData, next); //report about failed items
}; //make sure item is still pending. Something might have changed while waiting for ITEM_START handling. Maybe someone called abort...
};
//make sure item is still pending. Something might have changed while waiting for ITEM_START handling. Maybe someone called abort...
const getAllowedItem = (id, queue) => {
const item = queue.getState().items[id];
return item && !ITEM_FINALIZE_STATES.includes(item.state) ? item : undefined;
return item && !getIsItemFinalized(item) ? item : undefined;
};
const processAllowedItems = _ref2 => {

@@ -123,2 +115,3 @@ let {

const afterPreparePromise = allowedItems.length ? preparePreRequestItems(queue, allowedItems) : Promise.resolve();
let finalCancelledResults = cancelledResults;
return afterPreparePromise.catch(err => {

@@ -129,10 +122,8 @@ logger.debugLog("uploader.queue: encountered error while preparing items for request", err);

let nextP;
if (itemsSendData) {
if (itemsSendData.cancelled) {
cancelledResults = ids.map(() => true);
finalCancelledResults = ids.map(() => true);
} else {
//make sure files aren't aborted while async prepare was waiting
const hasAborted = itemsSendData.items.some(item => ITEM_FINALIZE_STATES.includes(item.state));
const hasAborted = itemsSendData.items.some(item => getIsItemFinalized(item));
if (!hasAborted) {

@@ -148,22 +139,25 @@ //we dont need to wait for the response here

}
} //if not cancelled we can go to process more items immediately (and not wait for upload responses)
}
if (!reportCancelledItems(queue, items, cancelledResults, next)) {
//if not cancelled we can go to process more items immediately (and not wait for upload responses)
if (!reportCancelledItems(queue, items, finalCancelledResults, next)) {
nextP = next(queue); //when concurrent is allowed, we can go ahead and process more
} //returning promise for testing purposes
}
//returning promise for testing purposes
return nextP;
});
}; //send group of items to be uploaded
};
//send group of items to be uploaded
const processBatchItems = (queue, ids, next) => {
const state = queue.getState(); //ids will have more than one when grouping is allowed
const state = queue.getState();
//ids will have more than one when grouping is allowed
let items = Object.values(state.items);
items = items.filter(item =>
//ensure item was not finalized (ex: aborted) while waiting for async BATCH_START
ids.includes(item.id) && !getIsItemFinalized(item));
let items = Object.values(state.items);
items = items.filter(item => !!~ids.indexOf(item.id)); //allow user code cancel items from start event handler(s)
//allow user code cancel items from start event handler(s)
//returning promise for testing purposes
return Promise.all(items.map(i => queue.runCancellable(UPLOADER_EVENTS.ITEM_START, i))).then(cancelledResults => {

@@ -181,3 +175,2 @@ let allowedItems = cancelledResults.map((isCancelled, index) => isCancelled ? null : getAllowedItem(items[index].id, queue)).filter(Boolean);

};
export default processBatchItems;

@@ -14,5 +14,3 @@ import { FILE_STATES, logger } from "@rpldy/shared";

};
const getIsFinalized = item => !!~ITEM_FINALIZE_STATES.indexOf(item.state);
const processFinishedRequest = (queue, finishedData, next) => {

@@ -29,3 +27,2 @@ finishedData.forEach(itemData => {

});
if (state.items[id]) {

@@ -37,10 +34,9 @@ queue.updateState(state => {

item.uploadStatus = info.status;
if (getIsFinalized(item)) {
delete state.aborts[id];
}
}); //get most up-to-date item data
});
//get most up-to-date item data
const item = queue.getState().items[id];
if (info.state === FILE_STATES.FINISHED && item.completed < 100) {

@@ -50,3 +46,2 @@ //ensure we trigger progress event with completed = 100 for all items

}
if (FILE_STATE_TO_EVENT_MAP[item.state]) {

@@ -56,17 +51,15 @@ //trigger UPLOADER EVENT for item based on its state

}
if (getIsFinalized(item)) {
incrementBatchFinishedCounter(queue, item.batchId); //trigger FINALIZE event
incrementBatchFinishedCounter(queue, item.batchId);
//trigger FINALIZE event
queue.trigger(UPLOADER_EVENTS.ITEM_FINALIZE, item);
}
}
finalizeItem(queue, id);
}); //ensure finished batches are remove from state
});
//ensure finished batches are removed from state
cleanUpFinishedBatches(queue);
next(queue);
};
export default processFinishedRequest;
import { FILE_STATES, logger } from "@rpldy/shared";
import processBatchItems from "./processBatchItems";
import { getIsBatchReady, isNewBatchStarting, cancelBatchForItem, loadNewBatchForItem, failBatchForItem } from "./batchHelpers";
import { getIsBatchReady, isNewBatchStarting, cancelBatchForItem, loadNewBatchForItem, failBatchForItem, isItemBatchStartPending } from "./batchHelpers";
const getIsItemInActiveRequest = (queue, itemId) => {
return queue.getState().activeIds // $FlowIssue - no flat
.flat().includes(itemId);
return queue.getState().activeIds.flat().includes(itemId);
};
const getIsItemReady = item => item.state === FILE_STATES.ADDED;
export const findNextItemIndex = queue => {
const state = queue.getState(),
itemQueue = state.itemQueue,
items = state.items;
itemQueue = state.itemQueue,
items = state.items;
let nextItemId = null,
batchIndex = 0,
itemIndex = 0,
batchId = state.batchQueue[batchIndex];
batchIndex = 0,
itemIndex = 0,
batchId = state.batchQueue[batchIndex];
while (batchId && !nextItemId) {
if (getIsBatchReady(queue, batchId)) {
nextItemId = itemQueue[batchId][itemIndex];
while (nextItemId && (getIsItemInActiveRequest(queue, nextItemId) || !getIsItemReady(items[nextItemId]))) {

@@ -30,3 +24,2 @@ itemIndex += 1;

}
if (!nextItemId) {

@@ -38,3 +31,2 @@ batchIndex += 1;

}
return nextItemId ? [batchId, itemIndex] : null;

@@ -44,16 +36,14 @@ };

const state = queue.getState(),
itemQueue = state.itemQueue,
[nextBatchId, nextItemIndex] = findNextItemIndex(queue) || [];
itemQueue = state.itemQueue,
[nextBatchId, nextItemIndex] = findNextItemIndex(queue) || [];
let nextId = nextBatchId && ~nextItemIndex ? itemQueue[nextBatchId][nextItemIndex] : null,
nextGroup;
nextGroup;
if (nextId) {
const {
batchOptions
} = state.batches[nextBatchId],
groupMax = batchOptions.maxGroupSize || 0;
batchOptions
} = state.batches[nextBatchId],
groupMax = batchOptions.maxGroupSize || 0;
if (batchOptions.grouped && groupMax > 1) {
const batchItems = state.itemQueue[nextBatchId]; //get ids for the batch with max of configured group size (never mix items from different batches)
const batchItems = state.itemQueue[nextBatchId];
//get ids for the batch with max of configured group size (never mix items from different batches)
nextGroup = batchItems.slice(nextItemIndex, nextItemIndex + groupMax);

@@ -64,6 +54,4 @@ } else {

}
return nextGroup;
};
const updateItemsAsActive = (queue, ids) => {

@@ -75,30 +63,29 @@ queue.updateState(state => {

};
const processNextWithBatch = (queue, ids) => {
let newBatchP;
updateItemsAsActive(queue, ids);
if (isNewBatchStarting(queue, ids[0])) {
newBatchP = loadNewBatchForItem(queue, ids[0]).then(allowBatch => {
let cancelled = !allowBatch;
if (cancelled) {
cancelBatchForItem(queue, ids[0]);
if (!isItemBatchStartPending(queue, ids[0])) {
updateItemsAsActive(queue, ids);
if (isNewBatchStarting(queue, ids[0])) {
newBatchP = loadNewBatchForItem(queue, ids[0]).then(allowBatch => {
let cancelled = !allowBatch;
if (cancelled) {
cancelBatchForItem(queue, ids[0]);
processNext(queue);
}
return cancelled;
}).catch(err => {
logger.debugLog("uploader.processor: encountered error while preparing batch for request", err);
failBatchForItem(queue, ids[0], err);
processNext(queue);
}
return cancelled;
}).catch(err => {
logger.debugLog("uploader.processor: encountered error while preparing batch for request", err);
failBatchForItem(queue, ids[0], err);
processNext(queue);
return true;
});
return true;
});
} else {
newBatchP = Promise.resolve(false);
}
} else {
newBatchP = Promise.resolve(false);
//dont continue processing while batch is pending start event handling
newBatchP = Promise.resolve(true);
}
return newBatchP;
};
const processNext = queue => {

@@ -108,10 +95,8 @@ //using promise only for testing purposes, actual code doesnt require awaiting on this method

const ids = getNextIdGroup(queue);
if (ids) {
const currentCount = queue.getCurrentActiveCount(),
{
concurrent = 0,
maxConcurrent = 0
} = queue.getOptions();
{
concurrent = !!0,
maxConcurrent = 0
} = queue.getOptions();
if (!currentCount || concurrent && currentCount < maxConcurrent) {

@@ -125,3 +110,2 @@ logger.debugLog("uploader.processor: Processing next upload - ", {

processBatchItems(queue, ids, processNext);
if (concurrent) {

@@ -135,6 +119,4 @@ //concurrent process next immediately (otherwise async event callbacks will hang processing next until they complete)

}
return processPromise;
};
export default processNext;

@@ -7,3 +7,2 @@ import { logger, hasWindow, isFunction, scheduleIdleWork } from "@rpldy/shared";

import { detachRecycledFromPreviousBatch, getBatchFromState, preparePendingForUpload, removePendingBatches, clearBatchData } from "./batchHelpers";
const createUploaderQueue = (options, trigger, cancellable, sender, uploaderId) => {

@@ -17,2 +16,3 @@ const {

currentBatch: null,
batchesStartPending: [],
batches: {},

@@ -23,9 +23,6 @@ items: {},

});
const getState = () => state;
const updateState = updater => {
update(updater);
};
const add = item => {

@@ -35,7 +32,5 @@ if (state.items[item.id] && !item.recycled) {

}
if (item.recycled) {
detachRecycledFromPreviousBatch(queueState, item);
}
updateState(state => {

@@ -45,3 +40,2 @@ state.items[item.id] = item;

};
const handleItemProgress = (item, completed, loaded) => {

@@ -53,14 +47,12 @@ if (state.items[item.id]) {

stateItem.completed = completed;
}); //trigger item progress event for the outside
});
//trigger item progress event for the outside
trigger(UPLOADER_EVENTS.ITEM_PROGRESS, getState().items[item.id]);
}
};
sender.on(SENDER_EVENTS.ITEM_PROGRESS, handleItemProgress);
sender.on(SENDER_EVENTS.BATCH_PROGRESS, batch => {
var _state$batches$batch$;
const batchItems = (_state$batches$batch$ = state.batches[batch.id]) === null || _state$batches$batch$ === void 0 ? void 0 : _state$batches$batch$.batch.items;
if (batchItems) {

@@ -81,6 +73,6 @@ const [completed, loaded] = batchItems.reduce((res, _ref2) => {

updateState(state => {
const stateBatch = state.batches[batch.id].batch; //average of completed percentage for batch items
stateBatch.completed = completed / batchItems.length; //sum of loaded bytes for batch items
const stateBatch = state.batches[batch.id].batch;
//average of completed percentage for batch items
stateBatch.completed = completed / batchItems.length;
//sum of loaded bytes for batch items
stateBatch.loaded = loaded;

@@ -103,7 +95,5 @@ });

}
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return cancellable(name, ...args);

@@ -126,3 +116,2 @@ },

logger.debugLog(`uploader.queue: started scheduled work to clear batch uploads (${batchId})`);
if (getState().batches[batchId]) {

@@ -134,7 +123,5 @@ clearBatchData(queueState, batchId);

};
if (hasWindow() && logger.isDebugOn()) {
window[`__rpldy_${uploaderId}_queue_state`] = queueState;
}
return {

@@ -150,3 +137,2 @@ updateState,

}
processQueueNext(queueState);

@@ -176,3 +162,2 @@ },

}
return processAbortItem(queueState, ...args);

@@ -184,3 +169,2 @@ },

}
return processAbortBatch(queueState, ...args);

@@ -192,3 +176,2 @@ },

}
return processAbortAll(queueState, ...args);

@@ -205,3 +188,2 @@ },

};
export default createUploaderQueue;

@@ -10,9 +10,8 @@ import addLife, { createLifePack } from "@rpldy/life-events";

const EXT_OUTSIDE_ENHANCER_TIME = "Uploady - uploader extensions can only be registered by enhancers",
EXT_ALREADY_EXISTS = "Uploady - uploader extension by this name [%s] already exists";
EXT_ALREADY_EXISTS = "Uploady - uploader extension by this name [%s] already exists";
let counter = 0;
const getComposedEnhancer = extEnhancer => composeEnhancers(getAbortEnhancer(), extEnhancer);
const getEnhancedUploader = (uploader, options, triggerWithUnwrap, setEnhancerTime) => {
//TODO: create raw-uploader without internal enhancers (while default-uploader will use abort & xhr-sender enhancers)
//TODO need new mechanism for registering and using internal methods (abort, send)

@@ -23,7 +22,7 @@ //that will use enhancers but also allow overrides without having to expose the method in the options (ie: send)

const enhanced = enhancer(uploader, triggerWithUnwrap);
setEnhancerTime(false); //graceful handling for enhancer forgetting to return uploader
setEnhancerTime(false);
//graceful handling for enhancer forgetting to return uploader
return enhanced || uploader;
};
const createUploader = options => {

@@ -39,6 +38,6 @@ counter += 1;

let uploaderOptions = getMandatoryOptions(options);
const clearPending = () => {
processor.clearPendingBatches();
};
/**

@@ -48,7 +47,5 @@ * process batches that weren't auto-uploaded

const getOptions = () => {
return clone(uploaderOptions);
};
let {

@@ -62,3 +59,2 @@ trigger,

uploaderOptions = merge({}, uploaderOptions, updateOptions); //need deep merge for destination
return uploader;

@@ -68,10 +64,7 @@ },

const processOptions = merge({}, uploaderOptions, addOptions);
if (processOptions.clearPendingOnAdd) {
clearPending();
}
return processor.addNewBatch(files, uploader.id, processOptions).then(batch => {
let resultP;
if (batch.items.length) {

@@ -82,3 +75,2 @@ resultP = processor.runCancellable(UPLOADER_EVENTS.BATCH_ADD, batch, processOptions).then(isCancelled => {

${String(processOptions.autoUpload)}`, batch.items);
if (processOptions.autoUpload) {

@@ -95,3 +87,2 @@ processor.process(batch);

}
return resultP;

@@ -124,6 +115,6 @@ });

});
/**
* ensures that data being exposed to client-land isnt a proxy, only pojos
*/
const triggerWithUnwrap = function (name) {

@@ -133,3 +124,2 @@ for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

}
//delays unwrap to the very last time on trigger. Will only unwrap if there are listeners

@@ -139,3 +129,2 @@ const lp = createLifePack(() => data.map(deepProxyUnwrap));

};
const cancellable = triggerCancellable(triggerWithUnwrap);

@@ -148,3 +137,2 @@ const enhancedUploader = getEnhancedUploader(uploader, uploaderOptions, triggerWithUnwrap, state => {

};
export default createUploader;

@@ -5,3 +5,2 @@ import { hasWindow, isProduction } from "@rpldy/shared";

const FILE_LIST_SUPPORT = hasWindow() && "FileList" in window;
const getMandatoryDestination = dest => {

@@ -13,5 +12,5 @@ return {

};
const getMandatoryOptions = options => {
return { ...DEFAULT_OPTIONS,
return {
...DEFAULT_OPTIONS,
...options,

@@ -21,5 +20,6 @@ destination: options && options.destination ? getMandatoryDestination(options.destination) : null

};
const getIsFileList = files =>
//in case files list was created in a different context(window) need to check toString
FILE_LIST_SUPPORT && files instanceof FileList || files.toString() === "[object FileList]";
const getIsFileList = files => //in case files list was created in a different context(window) need to check toString
FILE_LIST_SUPPORT && files instanceof FileList || files.toString() === "[object FileList]";
/***

@@ -29,8 +29,5 @@ * will unwrap object from proxy

*/
const deepProxyUnwrap = function (obj) {
let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let result = obj;
if (!isProduction()) {

@@ -46,6 +43,4 @@ if (level < 3 && isProxy(obj)) {

}
return result;
};
export { getMandatoryOptions, getIsFileList, deepProxyUnwrap };
/*! For license information please see polyfills-bundle.js.LICENSE.txt */
(globalThis.webpackChunkrpldy=globalThis.webpackChunkrpldy||[]).push([[429],{"/f+H":(r,t,e)=>{e("YD5V");var n=e("i386");r.exports=n("Array").includes},ooVa:(r,t,e)=>{var n=e("4FJc"),o=e("/f+H"),i=e("1ebZ"),u=Array.prototype,a=String.prototype;r.exports=function(r){var t=r.includes;return r===u||n(u,r)&&t===u.includes?o:"string"==typeof r||r===a||n(a,r)&&t===a.includes?i:t}},"1ebZ":(r,t,e)=>{e("sVkT");var n=e("i386");r.exports=n("String").includes},xFTL:(r,t,e)=>{var n=e("Q7os"),o=e("6mbc"),i=TypeError;r.exports=function(r){if(n(r))return r;throw i(o(r)+" is not a function")}},"/MEq":r=>{r.exports=function(){}},"5nPu":(r,t,e)=>{var n=e("YhFp"),o=String,i=TypeError;r.exports=function(r){if(n(r))return r;throw i(o(r)+" is not an object")}},RaJe:(r,t,e)=>{var n=e("F8JF"),o=e("RnN/"),i=e("wUDr"),u=function(r){return function(t,e,u){var a,c=n(t),s=i(c),p=o(u,s);if(r&&e!=e){for(;s>p;)if((a=c[p++])!=a)return!0}else for(;s>p;p++)if((r||p in c)&&c[p]===e)return r||p||0;return!r&&-1}};r.exports={includes:u(!0),indexOf:u(!1)}},Oxro:(r,t,e)=>{var n=e("cs8v"),o=n({}.toString),i=n("".slice);r.exports=function(r){return i(o(r),8,-1)}},q9xX:(r,t,e)=>{var n=e("dzfd"),o=e("Q7os"),i=e("Oxro"),u=e("ldlN")("toStringTag"),a=Object,c="Arguments"==i(function(){return arguments}());r.exports=n?i:function(r){var t,e,n;return void 0===r?"Undefined":null===r?"Null":"string"==typeof(e=function(r,t){try{return r[t]}catch(r){}}(t=a(r),u))?e:c?i(t):"Object"==(n=i(t))&&o(t.callee)?"Arguments":n}},OUDx:(r,t,e)=>{var n=e("ldlN")("match");r.exports=function(r){var t=/./;try{"/./"[r](t)}catch(e){try{return t[n]=!1,"/./"[r](t)}catch(r){}}return!1}},"5mbI":(r,t,e)=>{var n=e("LSUe"),o=e("OJsm"),i=e("4+07");r.exports=n?function(r,t,e){return o.f(r,t,i(1,e))}:function(r,t,e){return r[t]=e,r}},"4+07":r=>{r.exports=function(r,t){return{enumerable:!(1&r),configurable:!(2&r),writable:!(4&r),value:t}}},"9z2b":(r,t,e)=>{var n=e("C5Kv"),o=Object.defineProperty;r.exports=function(r,t){try{o(n,r,{value:t,configurable:!0,writable:!0})}catch(e){n[r]=t}return t}},LSUe:(r,t,e)=>{var n=e("/N04");r.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},"5ueL":(r,t,e)=>{var n=e("C5Kv"),o=e("YhFp"),i=n.document,u=o(i)&&o(i.createElement);r.exports=function(r){return u?i.createElement(r):{}}},V8HS:(r,t,e)=>{var n=e("B0vi");r.exports=n("navigator","userAgent")||""},cllr:(r,t,e)=>{var n,o,i=e("C5Kv"),u=e("V8HS"),a=i.process,c=i.Deno,s=a&&a.versions||c&&c.version,p=s&&s.v8;p&&(o=(n=p.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&u&&(!(n=u.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=u.match(/Chrome\/(\d+)/))&&(o=+n[1]),r.exports=o},i386:(r,t,e)=>{var n=e("vJFW");r.exports=function(r){return n[r+"Prototype"]}},uBOt:(r,t,e)=>{"use strict";var n=e("C5Kv"),o=e("KCDV"),i=e("cs8v"),u=e("Q7os"),a=e("/1D7").f,c=e("mny2"),s=e("vJFW"),p=e("/7Fa"),f=e("5mbI"),l=e("qg/F"),v=function(r){var t=function(e,n,i){if(this instanceof t){switch(arguments.length){case 0:return new r;case 1:return new r(e);case 2:return new r(e,n)}return new r(e,n,i)}return o(r,this,arguments)};return t.prototype=r.prototype,t};r.exports=function(r,t){var e,o,b,y,d,h,x,g,m=r.target,O=r.global,w=r.stat,S=r.proto,F=O?n:w?n[m]:(n[m]||{}).prototype,T=O?s:s[m]||f(s,m,{})[m],j=T.prototype;for(b in t)e=!c(O?b:m+(w?".":"#")+b,r.forced)&&F&&l(F,b),d=T[b],e&&(h=r.dontCallGetSet?(g=a(F,b))&&g.value:F[b]),y=e&&h?h:t[b],e&&typeof d==typeof y||(x=r.bind&&e?p(y,n):r.wrap&&e?v(y):S&&u(y)?i(y):y,(r.sham||y&&y.sham||d&&d.sham)&&f(x,"sham",!0),f(T,b,x),S&&(l(s,o=m+"Prototype")||f(s,o,{}),f(s[o],b,y),r.real&&j&&!j[b]&&f(j,b,y)))}},"/N04":r=>{r.exports=function(r){try{return!!r()}catch(r){return!0}}},KCDV:(r,t,e)=>{var n=e("63d8"),o=Function.prototype,i=o.apply,u=o.call;r.exports="object"==typeof Reflect&&Reflect.apply||(n?u.bind(i):function(){return u.apply(i,arguments)})},"/7Fa":(r,t,e)=>{var n=e("cs8v"),o=e("xFTL"),i=e("63d8"),u=n(n.bind);r.exports=function(r,t){return o(r),void 0===t?r:i?u(r,t):function(){return r.apply(t,arguments)}}},"63d8":(r,t,e)=>{var n=e("/N04");r.exports=!n((function(){var r=function(){}.bind();return"function"!=typeof r||r.hasOwnProperty("prototype")}))},FXr7:(r,t,e)=>{var n=e("63d8"),o=Function.prototype.call;r.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},cs8v:(r,t,e)=>{var n=e("63d8"),o=Function.prototype,i=o.bind,u=o.call,a=n&&i.bind(u,u);r.exports=n?function(r){return r&&a(r)}:function(r){return r&&function(){return u.apply(r,arguments)}}},B0vi:(r,t,e)=>{var n=e("vJFW"),o=e("C5Kv"),i=e("Q7os"),u=function(r){return i(r)?r:void 0};r.exports=function(r,t){return arguments.length<2?u(n[r])||u(o[r]):n[r]&&n[r][t]||o[r]&&o[r][t]}},SDul:(r,t,e)=>{var n=e("xFTL");r.exports=function(r,t){var e=r[t];return null==e?void 0:n(e)}},C5Kv:(r,t,e)=>{var n=function(r){return r&&r.Math==Math&&r};r.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e.g&&e.g)||function(){return this}()||Function("return this")()},"qg/F":(r,t,e)=>{var n=e("cs8v"),o=e("IV2t"),i=n({}.hasOwnProperty);r.exports=Object.hasOwn||function(r,t){return i(o(r),t)}},OYZz:(r,t,e)=>{var n=e("LSUe"),o=e("/N04"),i=e("5ueL");r.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},U6hY:(r,t,e)=>{var n=e("cs8v"),o=e("/N04"),i=e("Oxro"),u=Object,a=n("".split);r.exports=o((function(){return!u("z").propertyIsEnumerable(0)}))?function(r){return"String"==i(r)?a(r,""):u(r)}:u},Q7os:r=>{r.exports=function(r){return"function"==typeof r}},mny2:(r,t,e)=>{var n=e("/N04"),o=e("Q7os"),i=/#|\.prototype\./,u=function(r,t){var e=c[a(r)];return e==p||e!=s&&(o(t)?n(t):!!t)},a=u.normalize=function(r){return String(r).replace(i,".").toLowerCase()},c=u.data={},s=u.NATIVE="N",p=u.POLYFILL="P";r.exports=u},YhFp:(r,t,e)=>{var n=e("Q7os");r.exports=function(r){return"object"==typeof r?null!==r:n(r)}},x99Q:r=>{r.exports=!0},WNSC:(r,t,e)=>{var n=e("YhFp"),o=e("Oxro"),i=e("ldlN")("match");r.exports=function(r){var t;return n(r)&&(void 0!==(t=r[i])?!!t:"RegExp"==o(r))}},"d+gi":(r,t,e)=>{var n=e("B0vi"),o=e("Q7os"),i=e("4FJc"),u=e("XcY4"),a=Object;r.exports=u?function(r){return"symbol"==typeof r}:function(r){var t=n("Symbol");return o(t)&&i(t.prototype,a(r))}},wUDr:(r,t,e)=>{var n=e("5Xcx");r.exports=function(r){return n(r.length)}},rQiN:r=>{var t=Math.ceil,e=Math.floor;r.exports=Math.trunc||function(r){var n=+r;return(n>0?e:t)(n)}},"7+0/":(r,t,e)=>{var n=e("cllr"),o=e("/N04");r.exports=!!Object.getOwnPropertySymbols&&!o((function(){var r=Symbol();return!String(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},"5DMT":(r,t,e)=>{var n=e("WNSC"),o=TypeError;r.exports=function(r){if(n(r))throw o("The method doesn't accept regular expressions");return r}},OJsm:(r,t,e)=>{var n=e("LSUe"),o=e("OYZz"),i=e("Hr7U"),u=e("5nPu"),a=e("aCzT"),c=TypeError,s=Object.defineProperty,p=Object.getOwnPropertyDescriptor;t.f=n?i?function(r,t,e){if(u(r),t=a(t),u(e),"function"==typeof r&&"prototype"===t&&"value"in e&&"writable"in e&&!e.writable){var n=p(r,t);n&&n.writable&&(r[t]=e.value,e={configurable:"configurable"in e?e.configurable:n.configurable,enumerable:"enumerable"in e?e.enumerable:n.enumerable,writable:!1})}return s(r,t,e)}:s:function(r,t,e){if(u(r),t=a(t),u(e),o)try{return s(r,t,e)}catch(r){}if("get"in e||"set"in e)throw c("Accessors not supported");return"value"in e&&(r[t]=e.value),r}},"/1D7":(r,t,e)=>{var n=e("LSUe"),o=e("FXr7"),i=e("OA+L"),u=e("4+07"),a=e("F8JF"),c=e("aCzT"),s=e("qg/F"),p=e("OYZz"),f=Object.getOwnPropertyDescriptor;t.f=n?f:function(r,t){if(r=a(r),t=c(t),p)try{return f(r,t)}catch(r){}if(s(r,t))return u(!o(i.f,r,t),r[t])}},"4FJc":(r,t,e)=>{var n=e("cs8v");r.exports=n({}.isPrototypeOf)},"OA+L":(r,t)=>{"use strict";var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,o=n&&!e.call({1:2},1);t.f=o?function(r){var t=n(this,r);return!!t&&t.enumerable}:e},uOoV:(r,t,e)=>{var n=e("FXr7"),o=e("Q7os"),i=e("YhFp"),u=TypeError;r.exports=function(r,t){var e,a;if("string"===t&&o(e=r.toString)&&!i(a=n(e,r)))return a;if(o(e=r.valueOf)&&!i(a=n(e,r)))return a;if("string"!==t&&o(e=r.toString)&&!i(a=n(e,r)))return a;throw u("Can't convert object to primitive value")}},vJFW:r=>{r.exports={}},bGHA:r=>{var t=TypeError;r.exports=function(r){if(null==r)throw t("Can't call method on "+r);return r}},J6Qi:(r,t,e)=>{var n=e("C5Kv"),o=e("9z2b"),i="__core-js_shared__",u=n[i]||o(i,{});r.exports=u},"/13h":(r,t,e)=>{var n=e("x99Q"),o=e("J6Qi");(r.exports=function(r,t){return o[r]||(o[r]=void 0!==t?t:{})})("versions",[]).push({version:"3.23.5",mode:n?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.23.5/LICENSE",source:"https://github.com/zloirock/core-js"})},"RnN/":(r,t,e)=>{var n=e("+/Po"),o=Math.max,i=Math.min;r.exports=function(r,t){var e=n(r);return e<0?o(e+t,0):i(e,t)}},F8JF:(r,t,e)=>{var n=e("U6hY"),o=e("bGHA");r.exports=function(r){return n(o(r))}},"+/Po":(r,t,e)=>{var n=e("rQiN");r.exports=function(r){var t=+r;return t!=t||0===t?0:n(t)}},"5Xcx":(r,t,e)=>{var n=e("+/Po"),o=Math.min;r.exports=function(r){return r>0?o(n(r),9007199254740991):0}},IV2t:(r,t,e)=>{var n=e("bGHA"),o=Object;r.exports=function(r){return o(n(r))}},"f/ud":(r,t,e)=>{var n=e("FXr7"),o=e("YhFp"),i=e("d+gi"),u=e("SDul"),a=e("uOoV"),c=e("ldlN"),s=TypeError,p=c("toPrimitive");r.exports=function(r,t){if(!o(r)||i(r))return r;var e,c=u(r,p);if(c){if(void 0===t&&(t="default"),e=n(c,r,t),!o(e)||i(e))return e;throw s("Can't convert object to primitive value")}return void 0===t&&(t="number"),a(r,t)}},aCzT:(r,t,e)=>{var n=e("f/ud"),o=e("d+gi");r.exports=function(r){var t=n(r,"string");return o(t)?t:t+""}},dzfd:(r,t,e)=>{var n={};n[e("ldlN")("toStringTag")]="z",r.exports="[object z]"===String(n)},nbfi:(r,t,e)=>{var n=e("q9xX"),o=String;r.exports=function(r){if("Symbol"===n(r))throw TypeError("Cannot convert a Symbol value to a string");return o(r)}},"6mbc":r=>{var t=String;r.exports=function(r){try{return t(r)}catch(r){return"Object"}}},zTJy:(r,t,e)=>{var n=e("cs8v"),o=0,i=Math.random(),u=n(1..toString);r.exports=function(r){return"Symbol("+(void 0===r?"":r)+")_"+u(++o+i,36)}},XcY4:(r,t,e)=>{var n=e("7+0/");r.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},Hr7U:(r,t,e)=>{var n=e("LSUe"),o=e("/N04");r.exports=n&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},ldlN:(r,t,e)=>{var n=e("C5Kv"),o=e("/13h"),i=e("qg/F"),u=e("zTJy"),a=e("7+0/"),c=e("XcY4"),s=o("wks"),p=n.Symbol,f=p&&p.for,l=c?p:p&&p.withoutSetter||u;r.exports=function(r){if(!i(s,r)||!a&&"string"!=typeof s[r]){var t="Symbol."+r;a&&i(p,r)?s[r]=p[r]:s[r]=c&&f?f(t):l(t)}return s[r]}},YD5V:(r,t,e)=>{"use strict";var n=e("uBOt"),o=e("RaJe").includes,i=e("/N04"),u=e("/MEq");n({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(r){return o(this,r,arguments.length>1?arguments[1]:void 0)}}),u("includes")},sVkT:(r,t,e)=>{"use strict";var n=e("uBOt"),o=e("cs8v"),i=e("5DMT"),u=e("bGHA"),a=e("nbfi"),c=e("OUDx"),s=o("".indexOf);n({target:"String",proto:!0,forced:!c("includes")},{includes:function(r){return!!~s(a(u(this)),a(i(r)),arguments.length>1?arguments[1]:void 0)}})},Damn:(r,t,e)=>{var n=e("ooVa");r.exports=n},kvau:r=>{"use strict";r.exports=function(r,t,e,n,o,i,u,a){if(!r){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[e,n,o,i,u,a],p=0;(c=new Error(t.replace(/%s/g,(function(){return s[p++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}}},uDTZ:r=>{r.exports=function(r,t,e){var n=!1,o=!1;return function(){o=e&&!n;var i=this,u=arguments;if(n||(n=!0,setTimeout((function(){if(n=!1,!e)return r.apply(i,u)}),t)),o)return o=!1,r.apply(this,arguments)}}},i9fi:(r,t,e)=>{r.exports=e("Damn")}}]);
(globalThis.webpackChunkrpldy=globalThis.webpackChunkrpldy||[]).push([[429],{JVJY:(t,r,e)=>{var n=e("DkPT");t.exports=n},tDn9:(t,r,e)=>{var n=e("q/LL");e("cgHO"),t.exports=n},PeoI:(t,r,e)=>{var n=e("HlJs");t.exports=n},"4WBC":(t,r,e)=>{var n=e("GQnA");t.exports=n},o4zr:(t,r,e)=>{e("Pkdo");var n=e("dktu").Object,o=t.exports=function(t,r,e){return n.defineProperty(t,r,e)};n.defineProperty.sham&&(o.sham=!0)},HCkw:(t,r,e)=>{e("/JNE"),e("b4mI"),e("i3tW"),e("42Pb"),e("ZNvi"),e("IqmU"),e("kIAf"),e("Dmep"),e("5pn2"),e("58wy"),e("LoXx"),e("mA47"),e("msS4"),e("J04u"),e("jQUo"),e("7wkN"),e("qhvP"),e("Ui3k"),e("gXaK"),e("0axM");var n=e("dktu");t.exports=n.Symbol},I2R1:(t,r,e)=>{e("kQON"),e("b4mI"),e("Pkew"),e("Dmep");var n=e("vuoM");t.exports=n.f("iterator")},pJNU:(t,r,e)=>{e("cV27"),e("jQUo");var n=e("vuoM");t.exports=n.f("toPrimitive")},mhMO:(t,r,e)=>{t.exports=e("YRjr")},tfHg:(t,r,e)=>{t.exports=e("X2ar")},NzrZ:(t,r,e)=>{t.exports=e("RZi0")},uRV7:(t,r,e)=>{t.exports=e("nq0W")},YRjr:(t,r,e)=>{var n=e("JVJY");t.exports=n},X2ar:(t,r,e)=>{var n=e("tDn9");e("DIJN"),e("D45G"),e("/B0s"),e("dP0U"),e("v/w9"),e("Jm8n"),e("mAJt"),t.exports=n},RZi0:(t,r,e)=>{var n=e("PeoI");t.exports=n},nq0W:(t,r,e)=>{var n=e("4WBC");t.exports=n},Thnc:(t,r,e)=>{var n=e("+y2l"),o=e("EwF+"),i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not a function")}},L5f0:(t,r,e)=>{var n=e("+y2l"),o=String,i=TypeError;t.exports=function(t){if("object"==typeof t||n(t))return t;throw i("Can't set "+o(t)+" as a prototype")}},xE4W:t=>{t.exports=function(){}},b42z:(t,r,e)=>{var n=e("39uu"),o=String,i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not an object")}},Y4Ys:(t,r,e)=>{var n=e("pCEo"),o=e("RQhY"),i=e("x08Q"),u=function(t){return function(r,e,u){var a,c=n(r),s=i(c),f=o(u,s);if(t&&e!=e){for(;s>f;)if((a=c[f++])!=a)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===e)return t||f||0;return!t&&-1}};t.exports={includes:u(!0),indexOf:u(!1)}},"3uAa":(t,r,e)=>{var n=e("ZBQp"),o=e("zhhU"),i=e("Y4yM"),u=e("T/97"),a=e("x08Q"),c=e("Q0Rw"),s=o([].push),f=function(t){var r=1==t,e=2==t,o=3==t,f=4==t,p=6==t,v=7==t,l=5==t||p;return function(y,h,b,m){for(var d,g,x=u(y),S=i(x),O=n(h,b),w=a(S),j=0,Y=m||c,A=r?Y(y,w):e||v?Y(y,0):void 0;w>j;j++)if((l||j in S)&&(g=O(d=S[j],j,x),t))if(r)A[j]=g;else if(g)switch(t){case 3:return!0;case 5:return d;case 6:return j;case 2:s(A,d)}else switch(t){case 4:return!1;case 7:s(A,d)}return p?-1:o||f?f:A}};t.exports={forEach:f(0),map:f(1),filter:f(2),some:f(3),every:f(4),find:f(5),findIndex:f(6),filterReject:f(7)}},nJYk:(t,r,e)=>{var n=e("Bvq2"),o=e("A2Ma"),i=e("SqY4"),u=o("species");t.exports=function(t){return i>=51||!n((function(){var r=[];return(r.constructor={})[u]=function(){return{foo:1}},1!==r[t](Boolean).foo}))}},"6JCP":(t,r,e)=>{var n=e("RQhY"),o=e("x08Q"),i=e("bBVJ"),u=Array,a=Math.max;t.exports=function(t,r,e){for(var c=o(t),s=n(r,c),f=n(void 0===e?c:e,c),p=u(a(f-s,0)),v=0;s<f;s++,v++)i(p,v,t[s]);return p.length=v,p}},"61Qb":(t,r,e)=>{var n=e("zhhU");t.exports=n([].slice)},Hdor:(t,r,e)=>{var n=e("YiBS"),o=e("uuS6"),i=e("39uu"),u=e("A2Ma")("species"),a=Array;t.exports=function(t){var r;return n(t)&&(r=t.constructor,(o(r)&&(r===a||n(r.prototype))||i(r)&&null===(r=r[u]))&&(r=void 0)),void 0===r?a:r}},Q0Rw:(t,r,e)=>{var n=e("Hdor");t.exports=function(t,r){return new(n(t))(0===r?0:r)}},"/EgQ":(t,r,e)=>{var n=e("zhhU"),o=n({}.toString),i=n("".slice);t.exports=function(t){return i(o(t),8,-1)}},j5XY:(t,r,e)=>{var n=e("1jut"),o=e("+y2l"),i=e("/EgQ"),u=e("A2Ma")("toStringTag"),a=Object,c="Arguments"==i(function(){return arguments}());t.exports=n?i:function(t){var r,e,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=function(t,r){try{return t[r]}catch(t){}}(r=a(t),u))?e:c?i(r):"Object"==(n=i(r))&&o(r.callee)?"Arguments":n}},"9fuf":(t,r,e)=>{var n=e("Bvq2");t.exports=!n((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},"3bWX":t=>{t.exports=function(t,r){return{value:t,done:r}}},AnMC:(t,r,e)=>{var n=e("wbIY"),o=e("QYBB"),i=e("LGyv");t.exports=n?function(t,r,e){return o.f(t,r,i(1,e))}:function(t,r,e){return t[r]=e,t}},LGyv:t=>{t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},bBVJ:(t,r,e)=>{"use strict";var n=e("LHUf"),o=e("QYBB"),i=e("LGyv");t.exports=function(t,r,e){var u=n(r);u in t?o.f(t,u,i(0,e)):t[u]=e}},"/b46":(t,r,e)=>{var n=e("AnMC");t.exports=function(t,r,e,o){return o&&o.enumerable?t[r]=e:n(t,r,e),t}},E6FT:(t,r,e)=>{var n=e("OsYe"),o=Object.defineProperty;t.exports=function(t,r){try{o(n,t,{value:r,configurable:!0,writable:!0})}catch(e){n[t]=r}return r}},wbIY:(t,r,e)=>{var n=e("Bvq2");t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},D9Qm:t=>{var r="object"==typeof document&&document.all,e=void 0===r&&void 0!==r;t.exports={all:r,IS_HTMLDDA:e}},ejc7:(t,r,e)=>{var n=e("OsYe"),o=e("39uu"),i=n.document,u=o(i)&&o(i.createElement);t.exports=function(t){return u?i.createElement(t):{}}},PiPD:t=>{var r=TypeError;t.exports=function(t){if(t>9007199254740991)throw r("Maximum allowed index exceeded");return t}},eKLf:t=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},lxfd:t=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""},SqY4:(t,r,e)=>{var n,o,i=e("OsYe"),u=e("lxfd"),a=i.process,c=i.Deno,s=a&&a.versions||c&&c.version,f=s&&s.v8;f&&(o=(n=f.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&u&&(!(n=u.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=u.match(/Chrome\/(\d+)/))&&(o=+n[1]),t.exports=o},nleh:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},pevS:(t,r,e)=>{"use strict";var n=e("OsYe"),o=e("oLk2"),i=e("E890"),u=e("+y2l"),a=e("RLqH").f,c=e("oOVA"),s=e("dktu"),f=e("ZBQp"),p=e("AnMC"),v=e("Dm96"),l=function(t){var r=function(e,n,i){if(this instanceof r){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,i)}return o(t,this,arguments)};return r.prototype=t.prototype,r};t.exports=function(t,r){var e,o,y,h,b,m,d,g,x,S=t.target,O=t.global,w=t.stat,j=t.proto,Y=O?n:w?n[S]:(n[S]||{}).prototype,A=O?s:s[S]||p(s,S,{})[S],P=A.prototype;for(h in r)o=!(e=c(O?h:S+(w?".":"#")+h,t.forced))&&Y&&v(Y,h),m=A[h],o&&(d=t.dontCallGetSet?(x=a(Y,h))&&x.value:Y[h]),b=o&&d?d:r[h],o&&typeof m==typeof b||(g=t.bind&&o?f(b,n):t.wrap&&o?l(b):j&&u(b)?i(b):b,(t.sham||b&&b.sham||m&&m.sham)&&p(g,"sham",!0),p(A,h,g),j&&(v(s,y=S+"Prototype")||p(s,y,{}),p(s[y],h,b),t.real&&P&&(e||!P[h])&&p(P,h,b)))}},Bvq2:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},oLk2:(t,r,e)=>{var n=e("oYAv"),o=Function.prototype,i=o.apply,u=o.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?u.bind(i):function(){return u.apply(i,arguments)})},ZBQp:(t,r,e)=>{var n=e("E890"),o=e("Thnc"),i=e("oYAv"),u=n(n.bind);t.exports=function(t,r){return o(t),void 0===r?t:i?u(t,r):function(){return t.apply(r,arguments)}}},oYAv:(t,r,e)=>{var n=e("Bvq2");t.exports=!n((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},cQZY:(t,r,e)=>{var n=e("oYAv"),o=Function.prototype.call;t.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},swJg:(t,r,e)=>{var n=e("wbIY"),o=e("Dm96"),i=Function.prototype,u=n&&Object.getOwnPropertyDescriptor,a=o(i,"name"),c=a&&"something"===function(){}.name,s=a&&(!n||n&&u(i,"name").configurable);t.exports={EXISTS:a,PROPER:c,CONFIGURABLE:s}},E890:(t,r,e)=>{var n=e("/EgQ"),o=e("zhhU");t.exports=function(t){if("Function"===n(t))return o(t)}},zhhU:(t,r,e)=>{var n=e("oYAv"),o=Function.prototype,i=o.call,u=n&&o.bind.bind(i,i);t.exports=n?u:function(t){return function(){return i.apply(t,arguments)}}},mIMY:(t,r,e)=>{var n=e("dktu"),o=e("OsYe"),i=e("+y2l"),u=function(t){return i(t)?t:void 0};t.exports=function(t,r){return arguments.length<2?u(n[t])||u(o[t]):n[t]&&n[t][r]||o[t]&&o[t][r]}},"+Lan":(t,r,e)=>{var n=e("Thnc"),o=e("Cx3U");t.exports=function(t,r){var e=t[r];return o(e)?void 0:n(e)}},OsYe:(t,r,e)=>{var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e.g&&e.g)||function(){return this}()||Function("return this")()},Dm96:(t,r,e)=>{var n=e("zhhU"),o=e("T/97"),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,r){return i(o(t),r)}},bpon:t=>{t.exports={}},"7b0v":(t,r,e)=>{var n=e("mIMY");t.exports=n("document","documentElement")},d7IX:(t,r,e)=>{var n=e("wbIY"),o=e("Bvq2"),i=e("ejc7");t.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},Y4yM:(t,r,e)=>{var n=e("zhhU"),o=e("Bvq2"),i=e("/EgQ"),u=Object,a=n("".split);t.exports=o((function(){return!u("z").propertyIsEnumerable(0)}))?function(t){return"String"==i(t)?a(t,""):u(t)}:u},"6Jnn":(t,r,e)=>{var n=e("zhhU"),o=e("+y2l"),i=e("doUz"),u=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return u(t)}),t.exports=i.inspectSource},L1rz:(t,r,e)=>{var n,o,i,u=e("zOmE"),a=e("OsYe"),c=e("39uu"),s=e("AnMC"),f=e("Dm96"),p=e("doUz"),v=e("su3n"),l=e("bpon"),y="Object already initialized",h=a.TypeError,b=a.WeakMap;if(u||p.state){var m=p.state||(p.state=new b);m.get=m.get,m.has=m.has,m.set=m.set,n=function(t,r){if(m.has(t))throw h(y);return r.facade=t,m.set(t,r),r},o=function(t){return m.get(t)||{}},i=function(t){return m.has(t)}}else{var d=v("state");l[d]=!0,n=function(t,r){if(f(t,d))throw h(y);return r.facade=t,s(t,d,r),r},o=function(t){return f(t,d)?t[d]:{}},i=function(t){return f(t,d)}}t.exports={set:n,get:o,has:i,enforce:function(t){return i(t)?o(t):n(t,{})},getterFor:function(t){return function(r){var e;if(!c(r)||(e=o(r)).type!==t)throw h("Incompatible receiver, "+t+" required");return e}}}},YiBS:(t,r,e)=>{var n=e("/EgQ");t.exports=Array.isArray||function(t){return"Array"==n(t)}},"+y2l":(t,r,e)=>{var n=e("D9Qm"),o=n.all;t.exports=n.IS_HTMLDDA?function(t){return"function"==typeof t||t===o}:function(t){return"function"==typeof t}},uuS6:(t,r,e)=>{var n=e("zhhU"),o=e("Bvq2"),i=e("+y2l"),u=e("j5XY"),a=e("mIMY"),c=e("6Jnn"),s=function(){},f=[],p=a("Reflect","construct"),v=/^\s*(?:class|function)\b/,l=n(v.exec),y=!v.exec(s),h=function(t){if(!i(t))return!1;try{return p(s,f,t),!0}catch(t){return!1}},b=function(t){if(!i(t))return!1;switch(u(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return y||!!l(v,c(t))}catch(t){return!0}};b.sham=!0,t.exports=!p||o((function(){var t;return h(h.call)||!h(Object)||!h((function(){t=!0}))||t}))?b:h},oOVA:(t,r,e)=>{var n=e("Bvq2"),o=e("+y2l"),i=/#|\.prototype\./,u=function(t,r){var e=c[a(t)];return e==f||e!=s&&(o(r)?n(r):!!r)},a=u.normalize=function(t){return String(t).replace(i,".").toLowerCase()},c=u.data={},s=u.NATIVE="N",f=u.POLYFILL="P";t.exports=u},Cx3U:t=>{t.exports=function(t){return null==t}},"39uu":(t,r,e)=>{var n=e("+y2l"),o=e("D9Qm"),i=o.all;t.exports=o.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:n(t)||t===i}:function(t){return"object"==typeof t?null!==t:n(t)}},cEKj:t=>{t.exports=!0},yXj3:(t,r,e)=>{var n=e("mIMY"),o=e("+y2l"),i=e("Q3sF"),u=e("YtAO"),a=Object;t.exports=u?function(t){return"symbol"==typeof t}:function(t){var r=n("Symbol");return o(r)&&i(r.prototype,a(t))}},mdol:(t,r,e)=>{"use strict";var n=e("u4PT").IteratorPrototype,o=e("SJYm"),i=e("LGyv"),u=e("KHTo"),a=e("dGO/"),c=function(){return this};t.exports=function(t,r,e,s){var f=r+" Iterator";return t.prototype=o(n,{next:i(+!s,e)}),u(t,f,!1,!0),a[f]=c,t}},t6hZ:(t,r,e)=>{"use strict";var n=e("pevS"),o=e("cQZY"),i=e("cEKj"),u=e("swJg"),a=e("+y2l"),c=e("mdol"),s=e("V3kF"),f=e("7GIe"),p=e("KHTo"),v=e("AnMC"),l=e("/b46"),y=e("A2Ma"),h=e("dGO/"),b=e("u4PT"),m=u.PROPER,d=u.CONFIGURABLE,g=b.IteratorPrototype,x=b.BUGGY_SAFARI_ITERATORS,S=y("iterator"),O="keys",w="values",j="entries",Y=function(){return this};t.exports=function(t,r,e,u,y,b,A){c(e,r,u);var P,E,I,T=function(t){if(t===y&&D)return D;if(!x&&t in M)return M[t];switch(t){case O:case w:case j:return function(){return new e(this,t)}}return function(){return new e(this)}},L=r+" Iterator",U=!1,M=t.prototype,B=M[S]||M["@@iterator"]||y&&M[y],D=!x&&B||T(y),k="Array"==r&&M.entries||B;if(k&&(P=s(k.call(new t)))!==Object.prototype&&P.next&&(i||s(P)===g||(f?f(P,g):a(P[S])||l(P,S,Y)),p(P,L,!0,!0),i&&(h[L]=Y)),m&&y==w&&B&&B.name!==w&&(!i&&d?v(M,"name",w):(U=!0,D=function(){return o(B,this)})),y)if(E={values:T(w),keys:b?D:T(O),entries:T(j)},A)for(I in E)(x||U||!(I in M))&&l(M,I,E[I]);else n({target:r,proto:!0,forced:x||U},E);return i&&!A||M[S]===D||l(M,S,D,{name:y}),h[r]=D,E}},u4PT:(t,r,e)=>{"use strict";var n,o,i,u=e("Bvq2"),a=e("+y2l"),c=e("39uu"),s=e("SJYm"),f=e("V3kF"),p=e("/b46"),v=e("A2Ma"),l=e("cEKj"),y=v("iterator"),h=!1;[].keys&&("next"in(i=[].keys())?(o=f(f(i)))!==Object.prototype&&(n=o):h=!0),!c(n)||u((function(){var t={};return n[y].call(t)!==t}))?n={}:l&&(n=s(n)),a(n[y])||p(n,y,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:h}},"dGO/":t=>{t.exports={}},x08Q:(t,r,e)=>{var n=e("ZyXh");t.exports=function(t){return n(t.length)}},VJVo:t=>{var r=Math.ceil,e=Math.floor;t.exports=Math.trunc||function(t){var n=+t;return(n>0?e:r)(n)}},SJYm:(t,r,e)=>{var n,o=e("b42z"),i=e("wjB2"),u=e("nleh"),a=e("bpon"),c=e("7b0v"),s=e("ejc7"),f=e("su3n")("IE_PROTO"),p=function(){},v=function(t){return"<script>"+t+"<\/script>"},l=function(t){t.write(v("")),t.close();var r=t.parentWindow.Object;return t=null,r},y=function(){try{n=new ActiveXObject("htmlfile")}catch(t){}var t,r;y="undefined"!=typeof document?document.domain&&n?l(n):((r=s("iframe")).style.display="none",c.appendChild(r),r.src=String("javascript:"),(t=r.contentWindow.document).open(),t.write(v("document.F=Object")),t.close(),t.F):l(n);for(var e=u.length;e--;)delete y.prototype[u[e]];return y()};a[f]=!0,t.exports=Object.create||function(t,r){var e;return null!==t?(p.prototype=o(t),e=new p,p.prototype=null,e[f]=t):e=y(),void 0===r?e:i.f(e,r)}},wjB2:(t,r,e)=>{var n=e("wbIY"),o=e("OUCS"),i=e("QYBB"),u=e("b42z"),a=e("pCEo"),c=e("oBZR");r.f=n&&!o?Object.defineProperties:function(t,r){u(t);for(var e,n=a(r),o=c(r),s=o.length,f=0;s>f;)i.f(t,e=o[f++],n[e]);return t}},QYBB:(t,r,e)=>{var n=e("wbIY"),o=e("d7IX"),i=e("OUCS"),u=e("b42z"),a=e("LHUf"),c=TypeError,s=Object.defineProperty,f=Object.getOwnPropertyDescriptor;r.f=n?i?function(t,r,e){if(u(t),r=a(r),u(e),"function"==typeof t&&"prototype"===r&&"value"in e&&"writable"in e&&!e.writable){var n=f(t,r);n&&n.writable&&(t[r]=e.value,e={configurable:"configurable"in e?e.configurable:n.configurable,enumerable:"enumerable"in e?e.enumerable:n.enumerable,writable:!1})}return s(t,r,e)}:s:function(t,r,e){if(u(t),r=a(r),u(e),o)try{return s(t,r,e)}catch(t){}if("get"in e||"set"in e)throw c("Accessors not supported");return"value"in e&&(t[r]=e.value),t}},RLqH:(t,r,e)=>{var n=e("wbIY"),o=e("cQZY"),i=e("cEPT"),u=e("LGyv"),a=e("pCEo"),c=e("LHUf"),s=e("Dm96"),f=e("d7IX"),p=Object.getOwnPropertyDescriptor;r.f=n?p:function(t,r){if(t=a(t),r=c(r),f)try{return p(t,r)}catch(t){}if(s(t,r))return u(!o(i.f,t,r),t[r])}},jhEP:(t,r,e)=>{var n=e("/EgQ"),o=e("pCEo"),i=e("DPDV").f,u=e("6JCP"),a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return a&&"Window"==n(t)?function(t){try{return i(t)}catch(t){return u(a)}}(t):i(o(t))}},DPDV:(t,r,e)=>{var n=e("syO3"),o=e("nleh").concat("length","prototype");r.f=Object.getOwnPropertyNames||function(t){return n(t,o)}},ogVW:(t,r)=>{r.f=Object.getOwnPropertySymbols},V3kF:(t,r,e)=>{var n=e("Dm96"),o=e("+y2l"),i=e("T/97"),u=e("su3n"),a=e("9fuf"),c=u("IE_PROTO"),s=Object,f=s.prototype;t.exports=a?s.getPrototypeOf:function(t){var r=i(t);if(n(r,c))return r[c];var e=r.constructor;return o(e)&&r instanceof e?e.prototype:r instanceof s?f:null}},Q3sF:(t,r,e)=>{var n=e("zhhU");t.exports=n({}.isPrototypeOf)},syO3:(t,r,e)=>{var n=e("zhhU"),o=e("Dm96"),i=e("pCEo"),u=e("Y4Ys").indexOf,a=e("bpon"),c=n([].push);t.exports=function(t,r){var e,n=i(t),s=0,f=[];for(e in n)!o(a,e)&&o(n,e)&&c(f,e);for(;r.length>s;)o(n,e=r[s++])&&(~u(f,e)||c(f,e));return f}},oBZR:(t,r,e)=>{var n=e("syO3"),o=e("nleh");t.exports=Object.keys||function(t){return n(t,o)}},cEPT:(t,r)=>{"use strict";var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,o=n&&!e.call({1:2},1);r.f=o?function(t){var r=n(this,t);return!!r&&r.enumerable}:e},"7GIe":(t,r,e)=>{var n=e("zhhU"),o=e("b42z"),i=e("L5f0");t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,r=!1,e={};try{(t=n(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(e,[]),r=e instanceof Array}catch(t){}return function(e,n){return o(e),i(n),r?t(e,n):e.__proto__=n,e}}():void 0)},HAoi:(t,r,e)=>{"use strict";var n=e("1jut"),o=e("j5XY");t.exports=n?{}.toString:function(){return"[object "+o(this)+"]"}},"o/WT":(t,r,e)=>{var n=e("cQZY"),o=e("+y2l"),i=e("39uu"),u=TypeError;t.exports=function(t,r){var e,a;if("string"===r&&o(e=t.toString)&&!i(a=n(e,t)))return a;if(o(e=t.valueOf)&&!i(a=n(e,t)))return a;if("string"!==r&&o(e=t.toString)&&!i(a=n(e,t)))return a;throw u("Can't convert object to primitive value")}},dktu:t=>{t.exports={}},GHVm:(t,r,e)=>{var n=e("Cx3U"),o=TypeError;t.exports=function(t){if(n(t))throw o("Can't call method on "+t);return t}},KHTo:(t,r,e)=>{var n=e("1jut"),o=e("QYBB").f,i=e("AnMC"),u=e("Dm96"),a=e("HAoi"),c=e("A2Ma")("toStringTag");t.exports=function(t,r,e,s){if(t){var f=e?t:t.prototype;u(f,c)||o(f,c,{configurable:!0,value:r}),s&&!n&&i(f,"toString",a)}}},su3n:(t,r,e)=>{var n=e("1lkh"),o=e("PoCt"),i=n("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},doUz:(t,r,e)=>{var n=e("OsYe"),o=e("E6FT"),i="__core-js_shared__",u=n[i]||o(i,{});t.exports=u},"1lkh":(t,r,e)=>{var n=e("cEKj"),o=e("doUz");(t.exports=function(t,r){return o[t]||(o[t]=void 0!==r?r:{})})("versions",[]).push({version:"3.27.2",mode:n?"pure":"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"})},y9AQ:(t,r,e)=>{var n=e("zhhU"),o=e("x9K+"),i=e("jBKu"),u=e("GHVm"),a=n("".charAt),c=n("".charCodeAt),s=n("".slice),f=function(t){return function(r,e){var n,f,p=i(u(r)),v=o(e),l=p.length;return v<0||v>=l?t?"":void 0:(n=c(p,v))<55296||n>56319||v+1===l||(f=c(p,v+1))<56320||f>57343?t?a(p,v):n:t?s(p,v,v+2):f-56320+(n-55296<<10)+65536}};t.exports={codeAt:f(!1),charAt:f(!0)}},jGix:(t,r,e)=>{var n=e("SqY4"),o=e("Bvq2");t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},vDFq:(t,r,e)=>{var n=e("cQZY"),o=e("mIMY"),i=e("A2Ma"),u=e("/b46");t.exports=function(){var t=o("Symbol"),r=t&&t.prototype,e=r&&r.valueOf,a=i("toPrimitive");r&&!r[a]&&u(r,a,(function(t){return n(e,this)}),{arity:1})}},"4LQx":(t,r,e)=>{var n=e("jGix");t.exports=n&&!!Symbol.for&&!!Symbol.keyFor},RQhY:(t,r,e)=>{var n=e("x9K+"),o=Math.max,i=Math.min;t.exports=function(t,r){var e=n(t);return e<0?o(e+r,0):i(e,r)}},pCEo:(t,r,e)=>{var n=e("Y4yM"),o=e("GHVm");t.exports=function(t){return n(o(t))}},"x9K+":(t,r,e)=>{var n=e("VJVo");t.exports=function(t){var r=+t;return r!=r||0===r?0:n(r)}},ZyXh:(t,r,e)=>{var n=e("x9K+"),o=Math.min;t.exports=function(t){return t>0?o(n(t),9007199254740991):0}},"T/97":(t,r,e)=>{var n=e("GHVm"),o=Object;t.exports=function(t){return o(n(t))}},cWgI:(t,r,e)=>{var n=e("cQZY"),o=e("39uu"),i=e("yXj3"),u=e("+Lan"),a=e("o/WT"),c=e("A2Ma"),s=TypeError,f=c("toPrimitive");t.exports=function(t,r){if(!o(t)||i(t))return t;var e,c=u(t,f);if(c){if(void 0===r&&(r="default"),e=n(c,t,r),!o(e)||i(e))return e;throw s("Can't convert object to primitive value")}return void 0===r&&(r="number"),a(t,r)}},LHUf:(t,r,e)=>{var n=e("cWgI"),o=e("yXj3");t.exports=function(t){var r=n(t,"string");return o(r)?r:r+""}},"1jut":(t,r,e)=>{var n={};n[e("A2Ma")("toStringTag")]="z",t.exports="[object z]"===String(n)},jBKu:(t,r,e)=>{var n=e("j5XY"),o=String;t.exports=function(t){if("Symbol"===n(t))throw TypeError("Cannot convert a Symbol value to a string");return o(t)}},"EwF+":t=>{var r=String;t.exports=function(t){try{return r(t)}catch(t){return"Object"}}},PoCt:(t,r,e)=>{var n=e("zhhU"),o=0,i=Math.random(),u=n(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+u(++o+i,36)}},YtAO:(t,r,e)=>{var n=e("jGix");t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},OUCS:(t,r,e)=>{var n=e("wbIY"),o=e("Bvq2");t.exports=n&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},zOmE:(t,r,e)=>{var n=e("OsYe"),o=e("+y2l"),i=n.WeakMap;t.exports=o(i)&&/native code/.test(String(i))},"+UpH":(t,r,e)=>{var n=e("dktu"),o=e("Dm96"),i=e("vuoM"),u=e("QYBB").f;t.exports=function(t){var r=n.Symbol||(n.Symbol={});o(r,t)||u(r,t,{value:i.f(t)})}},vuoM:(t,r,e)=>{var n=e("A2Ma");r.f=n},A2Ma:(t,r,e)=>{var n=e("OsYe"),o=e("1lkh"),i=e("Dm96"),u=e("PoCt"),a=e("jGix"),c=e("YtAO"),s=n.Symbol,f=o("wks"),p=c?s.for||s:s&&s.withoutSetter||u;t.exports=function(t){return i(f,t)||(f[t]=a&&i(s,t)?s[t]:p("Symbol."+t)),f[t]}},"/JNE":(t,r,e)=>{"use strict";var n=e("pevS"),o=e("Bvq2"),i=e("YiBS"),u=e("39uu"),a=e("T/97"),c=e("x08Q"),s=e("PiPD"),f=e("bBVJ"),p=e("Q0Rw"),v=e("nJYk"),l=e("A2Ma"),y=e("SqY4"),h=l("isConcatSpreadable"),b=y>=51||!o((function(){var t=[];return t[h]=!1,t.concat()[0]!==t})),m=function(t){if(!u(t))return!1;var r=t[h];return void 0!==r?!!r:i(t)};n({target:"Array",proto:!0,arity:1,forced:!b||!v("concat")},{concat:function(t){var r,e,n,o,i,u=a(this),v=p(u,0),l=0;for(r=-1,n=arguments.length;r<n;r++)if(m(i=-1===r?u:arguments[r]))for(o=c(i),s(l+o),e=0;e<o;e++,l++)e in i&&f(v,l,i[e]);else s(l+1),f(v,l++,i);return v.length=l,v}})},kQON:(t,r,e)=>{"use strict";var n=e("pCEo"),o=e("xE4W"),i=e("dGO/"),u=e("L1rz"),a=e("QYBB").f,c=e("t6hZ"),s=e("3bWX"),f=e("cEKj"),p=e("wbIY"),v="Array Iterator",l=u.set,y=u.getterFor(v);t.exports=c(Array,"Array",(function(t,r){l(this,{type:v,target:n(t),index:0,kind:r})}),(function(){var t=y(this),r=t.target,e=t.kind,n=t.index++;return!r||n>=r.length?(t.target=void 0,s(void 0,!0)):s("keys"==e?n:"values"==e?r[n]:[n,r[n]],!1)}),"values");var h=i.Arguments=i.Array;if(o("keys"),o("values"),o("entries"),!f&&p&&"values"!==h.name)try{a(h,"name",{value:"values"})}catch(t){}},cV27:()=>{},AFTl:(t,r,e)=>{var n=e("pevS"),o=e("mIMY"),i=e("oLk2"),u=e("cQZY"),a=e("zhhU"),c=e("Bvq2"),s=e("YiBS"),f=e("+y2l"),p=e("39uu"),v=e("yXj3"),l=e("61Qb"),y=e("jGix"),h=o("JSON","stringify"),b=a(/./.exec),m=a("".charAt),d=a("".charCodeAt),g=a("".replace),x=a(1..toString),S=/[\uD800-\uDFFF]/g,O=/^[\uD800-\uDBFF]$/,w=/^[\uDC00-\uDFFF]$/,j=!y||c((function(){var t=o("Symbol")();return"[null]"!=h([t])||"{}"!=h({a:t})||"{}"!=h(Object(t))})),Y=c((function(){return'"\\udf06\\ud834"'!==h("\udf06\ud834")||'"\\udead"'!==h("\udead")})),A=function(t,r){var e=l(arguments),n=r;if((p(r)||void 0!==t)&&!v(t))return s(r)||(r=function(t,r){if(f(n)&&(r=u(n,this,t,r)),!v(r))return r}),e[1]=r,i(h,null,e)},P=function(t,r,e){var n=m(e,r-1),o=m(e,r+1);return b(O,t)&&!b(w,o)||b(w,t)&&!b(O,n)?"\\u"+x(d(t,0),16):t};h&&n({target:"JSON",stat:!0,arity:3,forced:j||Y},{stringify:function(t,r,e){var n=l(arguments),o=i(j?A:h,null,n);return Y&&"string"==typeof o?g(o,S,P):o}})},Ui3k:(t,r,e)=>{var n=e("OsYe");e("KHTo")(n.JSON,"JSON",!0)},gXaK:()=>{},Pkdo:(t,r,e)=>{var n=e("pevS"),o=e("wbIY"),i=e("QYBB").f;n({target:"Object",stat:!0,forced:Object.defineProperty!==i,sham:!o},{defineProperty:i})},g3YB:(t,r,e)=>{var n=e("pevS"),o=e("jGix"),i=e("Bvq2"),u=e("ogVW"),a=e("T/97");n({target:"Object",stat:!0,forced:!o||i((function(){u.f(1)}))},{getOwnPropertySymbols:function(t){var r=u.f;return r?r(a(t)):[]}})},b4mI:()=>{},"0axM":()=>{},Pkew:(t,r,e)=>{"use strict";var n=e("y9AQ").charAt,o=e("jBKu"),i=e("L1rz"),u=e("t6hZ"),a=e("3bWX"),c="String Iterator",s=i.set,f=i.getterFor(c);u(String,"String",(function(t){s(this,{type:c,string:o(t),index:0})}),(function(){var t,r=f(this),e=r.string,o=r.index;return o>=e.length?a(void 0,!0):(t=n(e,o),r.index+=t.length,a(t,!1))}))},"42Pb":(t,r,e)=>{e("+UpH")("asyncIterator")},D3w7:(t,r,e)=>{"use strict";var n=e("pevS"),o=e("OsYe"),i=e("cQZY"),u=e("zhhU"),a=e("cEKj"),c=e("wbIY"),s=e("jGix"),f=e("Bvq2"),p=e("Dm96"),v=e("Q3sF"),l=e("b42z"),y=e("pCEo"),h=e("LHUf"),b=e("jBKu"),m=e("LGyv"),d=e("SJYm"),g=e("oBZR"),x=e("DPDV"),S=e("jhEP"),O=e("ogVW"),w=e("RLqH"),j=e("QYBB"),Y=e("wjB2"),A=e("cEPT"),P=e("/b46"),E=e("1lkh"),I=e("su3n"),T=e("bpon"),L=e("PoCt"),U=e("A2Ma"),M=e("vuoM"),B=e("+UpH"),D=e("vDFq"),k=e("KHTo"),C=e("L1rz"),H=e("3uAa").forEach,Q=I("hidden"),F="Symbol",z=C.set,G=C.getterFor(F),R=Object.prototype,V=o.Symbol,J=V&&V.prototype,q=o.TypeError,N=o.QObject,K=w.f,Z=j.f,_=S.f,W=A.f,X=u([].push),$=E("symbols"),tt=E("op-symbols"),rt=E("wks"),et=!N||!N.prototype||!N.prototype.findChild,nt=c&&f((function(){return 7!=d(Z({},"a",{get:function(){return Z(this,"a",{value:7}).a}})).a}))?function(t,r,e){var n=K(R,r);n&&delete R[r],Z(t,r,e),n&&t!==R&&Z(R,r,n)}:Z,ot=function(t,r){var e=$[t]=d(J);return z(e,{type:F,tag:t,description:r}),c||(e.description=r),e},it=function(t,r,e){t===R&&it(tt,r,e),l(t);var n=h(r);return l(e),p($,n)?(e.enumerable?(p(t,Q)&&t[Q][n]&&(t[Q][n]=!1),e=d(e,{enumerable:m(0,!1)})):(p(t,Q)||Z(t,Q,m(1,{})),t[Q][n]=!0),nt(t,n,e)):Z(t,n,e)},ut=function(t,r){l(t);var e=y(r),n=g(e).concat(ft(e));return H(n,(function(r){c&&!i(at,e,r)||it(t,r,e[r])})),t},at=function(t){var r=h(t),e=i(W,this,r);return!(this===R&&p($,r)&&!p(tt,r))&&(!(e||!p(this,r)||!p($,r)||p(this,Q)&&this[Q][r])||e)},ct=function(t,r){var e=y(t),n=h(r);if(e!==R||!p($,n)||p(tt,n)){var o=K(e,n);return!o||!p($,n)||p(e,Q)&&e[Q][n]||(o.enumerable=!0),o}},st=function(t){var r=_(y(t)),e=[];return H(r,(function(t){p($,t)||p(T,t)||X(e,t)})),e},ft=function(t){var r=t===R,e=_(r?tt:y(t)),n=[];return H(e,(function(t){!p($,t)||r&&!p(R,t)||X(n,$[t])})),n};s||(P(J=(V=function(){if(v(J,this))throw q("Symbol is not a constructor");var t=arguments.length&&void 0!==arguments[0]?b(arguments[0]):void 0,r=L(t),e=function(t){this===R&&i(e,tt,t),p(this,Q)&&p(this[Q],r)&&(this[Q][r]=!1),nt(this,r,m(1,t))};return c&&et&&nt(R,r,{configurable:!0,set:e}),ot(r,t)}).prototype,"toString",(function(){return G(this).tag})),P(V,"withoutSetter",(function(t){return ot(L(t),t)})),A.f=at,j.f=it,Y.f=ut,w.f=ct,x.f=S.f=st,O.f=ft,M.f=function(t){return ot(U(t),t)},c&&(Z(J,"description",{configurable:!0,get:function(){return G(this).description}}),a||P(R,"propertyIsEnumerable",at,{unsafe:!0}))),n({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:V}),H(g(rt),(function(t){B(t)})),n({target:F,stat:!0,forced:!s},{useSetter:function(){et=!0},useSimple:function(){et=!1}}),n({target:"Object",stat:!0,forced:!s,sham:!c},{create:function(t,r){return void 0===r?d(t):ut(d(t),r)},defineProperty:it,defineProperties:ut,getOwnPropertyDescriptor:ct}),n({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:st}),D(),k(V,F),T[Q]=!0},ZNvi:()=>{},EfIp:(t,r,e)=>{var n=e("pevS"),o=e("mIMY"),i=e("Dm96"),u=e("jBKu"),a=e("1lkh"),c=e("4LQx"),s=a("string-to-symbol-registry"),f=a("symbol-to-string-registry");n({target:"Symbol",stat:!0,forced:!c},{for:function(t){var r=u(t);if(i(s,r))return s[r];var e=o("Symbol")(r);return s[r]=e,f[e]=r,e}})},IqmU:(t,r,e)=>{e("+UpH")("hasInstance")},kIAf:(t,r,e)=>{e("+UpH")("isConcatSpreadable")},Dmep:(t,r,e)=>{e("+UpH")("iterator")},i3tW:(t,r,e)=>{e("D3w7"),e("EfIp"),e("nIuI"),e("AFTl"),e("g3YB")},nIuI:(t,r,e)=>{var n=e("pevS"),o=e("Dm96"),i=e("yXj3"),u=e("EwF+"),a=e("1lkh"),c=e("4LQx"),s=a("symbol-to-string-registry");n({target:"Symbol",stat:!0,forced:!c},{keyFor:function(t){if(!i(t))throw TypeError(u(t)+" is not a symbol");if(o(s,t))return s[t]}})},"58wy":(t,r,e)=>{e("+UpH")("matchAll")},"5pn2":(t,r,e)=>{e("+UpH")("match")},LoXx:(t,r,e)=>{e("+UpH")("replace")},mA47:(t,r,e)=>{e("+UpH")("search")},msS4:(t,r,e)=>{e("+UpH")("species")},J04u:(t,r,e)=>{e("+UpH")("split")},jQUo:(t,r,e)=>{var n=e("+UpH"),o=e("vDFq");n("toPrimitive"),o()},"7wkN":(t,r,e)=>{var n=e("mIMY"),o=e("+UpH"),i=e("KHTo");o("toStringTag"),i(n("Symbol"),"Symbol")},qhvP:(t,r,e)=>{e("+UpH")("unscopables")},DIJN:(t,r,e)=>{e("+UpH")("asyncDispose")},cgHO:(t,r,e)=>{e("+UpH")("dispose")},D45G:(t,r,e)=>{e("+UpH")("matcher")},"/B0s":(t,r,e)=>{e("+UpH")("metadataKey")},"v/w9":(t,r,e)=>{e("+UpH")("metadata")},dP0U:(t,r,e)=>{e("+UpH")("observable")},Jm8n:(t,r,e)=>{e("+UpH")("patternMatch")},mAJt:(t,r,e)=>{e("+UpH")("replaceAll")},UUWy:(t,r,e)=>{e("kQON");var n=e("eKLf"),o=e("OsYe"),i=e("j5XY"),u=e("AnMC"),a=e("dGO/"),c=e("A2Ma")("toStringTag");for(var s in n){var f=o[s],p=f&&f.prototype;p&&i(p)!==c&&u(p,c,s),a[s]=a.Array}},DkPT:(t,r,e)=>{var n=e("o4zr");t.exports=n},"q/LL":(t,r,e)=>{var n=e("HCkw");e("UUWy"),t.exports=n},HlJs:(t,r,e)=>{var n=e("I2R1");e("UUWy"),t.exports=n},GQnA:(t,r,e)=>{var n=e("pJNU");t.exports=n},kvau:t=>{"use strict";t.exports=function(t,r,e,n,o,i,u,a){if(!t){var c;if(void 0===r)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[e,n,o,i,u,a],f=0;(c=new Error(r.replace(/%s/g,(function(){return s[f++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}}},uDTZ:t=>{t.exports=function(t,r,e){var n=!1,o=!1;return function(){o=e&&!n;var i=this,u=arguments;if(n||(n=!0,setTimeout((function(){if(n=!1,!e)return t.apply(i,u)}),r)),o)return o=!1,t.apply(this,arguments)}}},"1Vwn":(t,r,e)=>{t.exports=e("mhMO")},rhzV:(t,r,e)=>{t.exports=e("tfHg")},Ovso:(t,r,e)=>{t.exports=e("NzrZ")},"I/CL":(t,r,e)=>{t.exports=e("uRV7")},wVK4:(t,r,e)=>{"use strict";e.d(r,{Z:()=>c});var n=e("1Vwn"),o=e("rhzV"),i=e("Ovso");function u(t){return u="function"==typeof o&&"symbol"==typeof i?function(t){return typeof t}:function(t){return t&&"function"==typeof o&&t.constructor===o&&t!==o.prototype?"symbol":typeof t},u(t)}var a=e("I/CL");function c(t,r,e){return(r=function(t){var r=function(t,r){if("object"!==u(t)||null===t)return t;var e=t[a];if(void 0!==e){var n=e.call(t,r);if("object"!==u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"===u(r)?r:String(r)}(r))in t?n(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}}}]);
/*! For license information please see rpldy-core.umd.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rpldy=t():e.rpldy=t()}(globalThis,(()=>(()=>{var e,t={SKjz:(e,t,n)=>{"use strict";n.d(t,{uZ:()=>O,ZP:()=>A});var r=n("wU6r");const o=(0,r.ZV)({allowRegisterNonExistent:!0,canAddEvents:!0,canRemoveEvents:!0,collectStats:!1}),a=(e,t)=>{if(!(0,r.mf)(e))throw new Error(`'${t}' is not a valid function`)},s=e=>void 0===e,i=Symbol.for("__le__"),l=Symbol.for("__le__pack__"),d=e=>e?e[i]:null,c=e=>{const t=d(e);if(!t)throw new Error("Didnt find LE internal object. Something very bad happened!");return t},u=e=>!!d(e),h=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a(n,"cb");const o=c(e);if(!o.options.allowRegisterNonExistent&&!~o.events.indexOf(t))throw new Error(`Cannot register for event ${t.toString()} that wasn't already defined (allowRegisterNonExistent = false)`);const s=o.registry[t]||[];return s.find((e=>e.cb===n))||(s.push({name:t,cb:n,once:r}),o.registry[t]=s),()=>S.call(e,t,n)},p=(e,t)=>{const n=c(e).registry;return t?n[t]?n[t].slice():[]:Object.values(n).flat()},g={on:function(e,t){return h(this,e,t)},once:function(e,t){return h(this,e,t,!0)},off:S,getEvents:function(){return c(this).events.slice()}},f=()=>Object.entries(g).reduce(((e,t)=>{let[n,r]=t;return e[n]={value:r},e}),{}),b={trigger:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];const a=p(this,e);let i;if(a.length){var d;let t;1===n.length&&!0===(null===(d=n[0])||void 0===d?void 0:d[l])&&(t=n[0].resolve()),i=a.map((r=>{let o;return r.once&&v(this,e,r.cb),o=t?r.cb(...t):n.length?1===n.length?r.cb(n[0]):2===n.length?r.cb(n[0],n[1]):3===n.length?r.cb(n[0],n[1],n[2]):r.cb(...n):r.cb(),o})).filter((e=>!s(e))).map((e=>(0,r.tI)(e)?e:Promise.resolve(e)))}return i&&(i.length?i:void 0)},addEvent:function(e){const t=c(this);if(!t.options.canAddEvents)throw new Error("Cannot add new events (canAddEvents = false)");if(~t.events.indexOf(e))throw new Error(`Event '${e}' already defined`);t.events.push(e)},removeEvent:function(e){const t=c(this);if(!t.options.canRemoveEvents)throw new Error("Cannot remove events (canRemoveEvents = false)");{const n=t.events.indexOf(e);t.events.splice(n,1)}},hasEvent:function(e){return!!~c(this).events.indexOf(e)},hasEventRegistrations:function(e){return!!p(this,e).length},assign:function(e){const t=c(this);return y(e,t.options,t.events,t.registry,t.stats),m(e)}},m=e=>Object.keys(b).reduce(((t,n)=>(t[n]=b[n].bind(e),t)),{target:e,...b}),E=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=c(e).registry;!r[t]||!n&&r[t].length||delete r[t]},v=(e,t,n)=>{const r=c(e).registry;r[t]&&(n?(r[t]=r[t].filter((e=>e.cb!==n)),E(e,t)):E(e,t,!0))};function S(e,t){v(this,e,t)}const y=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Object.defineProperties(e,{[i]:{value:Object.seal({registry:r,events:n,options:t,stats:o})},...f()})},A=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0;return e=e||{},n={...o,...n},u(e)||y(e,n,t),m(e)},O=e=>{const t={resolve:()=>[].concat(e())};return Object.defineProperty(t,l,{value:!0,configurable:!1}),t}},Vmq3:(e,t,n)=>{"use strict";n.d(t,{PF:()=>i,Ch:()=>s,ZP:()=>f,KZ:()=>p,lW:()=>g});var r=n("i9fi"),o=n.n(r),a=n("wU6r");const s="rpldy-sender";class i extends Error{constructor(e){super(`${e} didn't receive upload URL`),this.name="MissingUrlError"}}const l=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];"set"in e?e.set(t,...r):("delete"in e&&e.delete(t),e.append(t,...r))},d=[200,201,202,203,204],c=(e,t,n,r,o)=>{let s;const i=null!=o&&o.getRequestData?o.getRequestData(e,n):((e,t)=>{let n;if(t.sendWithFormData)a.kg.debugLog(`uploady.sender: sending ${e.length} item(s) as form data`),n=((e,t)=>{const n=new FormData;return t.params&&Object.entries(t.params).forEach((e=>{let[r,o]=e;(t.formDataAllowUndefined||void 0!==o)&&l(n,r,o)})),((e,t,n)=>{const r=1===t.length;t.forEach(((t,o)=>{const s=r?n.paramName:(0,a.mf)(n.formatGroupParamName)?n.formatGroupParamName(o,n.paramName):`${n.paramName}[${o}]`;t.file?l(e,s,t.file,t.file.name):t.url&&l(e,s,t.url)}))})(n,e,t),n})(e,t);else{if(e.length>1)throw new Error(`XHR Sender - Request without form data can only contain 1 item. received ${e.length}`);const t=e[0];a.kg.debugLog(`uploady.sender: sending item ${t.id} as request body`),n=t.file||t.url}return n})(e,n),d=function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i,d=arguments.length>2?arguments[2]:void 0;d=(0,a.TS)({...(0,a.ei)(n,["method","headers","withCredentials"]),preSend:t=>{t.upload.onprogress=t=>{t.lengthComputable&&r&&r(t,e.slice())}}},d);const c=(0,a.WY)(o,l,d);return s=c.xhr,c},c=null!=o&&o.preRequestHandler?o.preRequestHandler(d,e,t,n,r,o):d();return{url:t,count:e.length,pXhr:c,getXhr:()=>s,aborted:!1}},u=(e,t,n)=>{let r=e;const a=null==t?void 0:t["content-type"];if(n.forceJsonResponse||null!=a&&o()(a).call(a,"json"))try{r=JSON.parse(e)}catch{}return r},h=(e,t)=>e.pXhr.then((e=>(a.kg.debugLog("uploady.sender: received upload response ",e),((e,t)=>{const n=t.isSuccessfulCall?t.isSuccessfulCall(e):o()(d).call(d,e.status);return(0,a.tI)(n)?n:Promise.resolve(n)})(e,t).then((n=>{var r,o;const s=n?a.FD.FINISHED:a.FD.ERROR,i=e.status,l=(0,a.k7)(e);return{status:i,state:s,response:{data:null!==(r=null===(o=t.formatServerResponse)||void 0===o?void 0:o.call(t,e.response,i,l))&&void 0!==r?r:u(e.response,l,t),headers:l}}}))))).catch((t=>{let n,r;return e.aborted?(n=a.FD.ABORTED,r="aborted"):(a.kg.debugLog("uploady.sender: upload failed: ",t),n=a.FD.ERROR,r=t),{error:!0,state:n,response:r,status:0}})),p=e=>(t,n,r,o)=>{if(!n)throw new i(s);a.kg.debugLog("uploady.sender: sending file: ",{items:t,url:n,options:r});const l=c(t,n,r,o,e);return{request:h(l,r),abort:()=>(e=>{let t=!1;const{aborted:n,getXhr:r}=e,o=r();return!n&&o&&o.readyState&&4!==o.readyState&&(a.kg.debugLog(`uploady.sender: cancelling request with ${e.count} items to: ${e.url}`),o.abort(),e.aborted=!0,t=!0),t})(l),senderType:s}},g=p(),f=g},wU6r:(e,t,n)=>{"use strict";n.d(t,{FG:()=>d,FD:()=>c,d9:()=>T,Yc:()=>q,ZV:()=>A,$e:()=>$,D8:()=>w,Ym:()=>u,kG:()=>a(),mf:()=>E(),PO:()=>O,yv:()=>y(),tI:()=>P,sQ:()=>v,kg:()=>r,TS:()=>D,k7:()=>M,ei:()=>C,WY:()=>Z,nK:()=>L,P2:()=>i(),tq:()=>b,sc:()=>G});var r={};n.r(r),n.d(r,{debugLog:()=>f,isDebugOn:()=>p,setDebug:()=>g});var o=n("kvau"),a=n.n(o),s=n("uDTZ"),i=n.n(s);const l="__rpldy-logger-debug__",d={PENDING:"pending",ADDED:"added",PROCESSING:"processing",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ABORTED:"aborted",ERROR:"error"},c={PENDING:"pending",ADDED:"added",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ERROR:"error",ABORTED:"aborted"},u=()=>"object"==typeof window&&!!window.document;let h;const p=()=>("boolean"!=typeof h&&(h=u()&&("location"in window&&!!~window.location.search.indexOf("rpldy_debug=true")||!0===window[l])),!!h),g=e=>{u()&&(window[l]=e),h=!!e||null},f=function(){p()&&console.log(...arguments)},b=function(e,t){const n=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new Promise(((n,o)=>{const a=e(t,...r);a&&a.length?Promise.all(a).catch(o).then((e=>e&&n(!!~e.findIndex((e=>!1===e))))):n(!1)}))};for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t?n(t,...o):n};var m=n("wfJ/"),E=n.n(m);const v=(e,t,n)=>{let r=!0;const o=(e=>{const t=[].concat(e);return e=>e.map((e=>t.map((t=>e[t])).join()))})(n);if(e&&t&&e.length===t.length){const n=o(e),a=o(t);r=!!n.find(((e,t)=>e!==a[t]))}return!r};var S=n("hSSe"),y=n.n(S);const A=e=>y()()?e:Object.freeze(e),O=e=>{var t;return!!e&&"object"==typeof e&&("Object"===(null===(t=Object.getPrototypeOf(e))||void 0===t?void 0:t.constructor.name)||null===Object.getPrototypeOf(e))},R=e=>O(e)||Array.isArray(e),I=(e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return n&&o.length&&o.forEach((r=>{r&&I(r,e).forEach((o=>{const a=r[o];e.predicate&&!e.predicate(o,a)||(void 0!==a||e.undefinedOverwrites)&&(R(a)?(void 0!==n[o]&&O(n[o])||(n[o]=Array.isArray(a)?[]:{}),t(n[o],a)):n[o]=a)}))})),n};return t},D=w(),T=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;return R(e)?t(Array.isArray(e)?[]:{},e):e},C=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),P=e=>!!e&&"object"==typeof e&&"function"==typeof e.then,_=u()&&window.requestIdleCallback,F=_?window.requestIdleCallback:setTimeout,B=_?window.cancelIdleCallback:clearTimeout,L=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=F(e,_?{timeout:t}:t);return()=>B(n)},N=function(e){return null==e},G=function(e,t){const n=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new Promise(((n,o)=>{const a=e(t,...r);a&&a.length?Promise.all(a).catch(o).then((e=>{let t;if(e)for(;N(t)&&e.length;)t=e.pop();n(N(t)?void 0:t)})):n()}))};for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t?n(t,...o):n},k=Symbol.for("__rpldy-bi__");let H=0;const j=(e,t)=>(e.url=t,e),x=(e,t)=>(e.file=t,e),U=e=>e&&(e instanceof File||e instanceof Blob||"object"==typeof e&&e.name&&e.type),$=e=>"object"==typeof e&&e.id&&e.batchId&&!0===e[k],q=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=$(e);H+=r?0:1;const o=r&&e.id?e.id:`${t}.item-${H}`,a=n?c.PENDING:c.ADDED;let s={id:o,batchId:t,state:a,uploadStatus:0,completed:0,loaded:0,recycled:r,previousBatch:r?e.batchId:null};if(Object.defineProperty(s,k,{value:!0,writable:!0}),r&&(e=e.file||e.url),"string"==typeof e)s=j(s,e);else{if(!U(e))throw new Error("Unknown type of file added: "+typeof e);s=x(s,e)}return s},Q=(e,t)=>{t&&Object.keys(t).forEach((n=>{void 0!==t[n]&&e.setRequestHeader(n,t[n])}))},M=e=>{let t;try{t=e.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce(((e,t)=>{const[n,r]=t.split(": ");return e[n]=r,e}),{})}catch(t){f("uploady.request: failed to read response headers",e)}return t},Z=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=new XMLHttpRequest,o=new Promise(((o,a)=>{r.onerror=()=>a(r),r.ontimeout=()=>a(r),r.onabort=()=>a(r),r.onload=()=>o(r),r.open(n.method||"GET",e),Q(r,n.headers),r.withCredentials=!!n.withCredentials,n.preSend&&n.preSend(r),r.send(t)}));return o.xhr=r,o}},"wfJ/":e=>{e.exports=function(e){return"function"==typeof e}},hSSe:e=>{e.exports=function(){return!0}},"4W+v":(e,t,n)=>{"use strict";n.r(t),n.d(t,{BATCH_STATES:()=>o.FG,DEFAULT_OPTIONS:()=>ae,FILE_STATES:()=>o.FD,MissingUrlError:()=>re.PF,UPLOADER_EVENTS:()=>A,XHR_SENDER_TYPE:()=>re.Ch,composeEnhancers:()=>ue,createUploader:()=>ge,default:()=>fe,getXhrSend:()=>re.KZ,send:()=>re.lW});var r=n("SKjz"),o=n("wU6r");const a=(e,t,n)=>(o.kg.debugLog(`abort: aborting ${e.state} item - `,e),n(e.id,{status:0,state:o.FD.ABORTED,response:"aborted"}),!0),s={[o.FD.UPLOADING]:(e,t)=>(o.kg.debugLog("abort: aborting uploading item - ",e),t[e.id]()),[o.FD.ADDED]:a,[o.FD.PENDING]:a},i=(e,t,n)=>{const r=null==e?void 0:e.state;return!(!r||!s[r])&&s[r](e,t,n)},l=(e,t,n,r)=>i(t[e],n,r),d=(e,t)=>{let n=!1;return 0!==t&&t&&(n=e>=t),n},c=(e,t,n,r,a)=>{const s=Object.values(n).flat(),i=d(s.length,a.fastAbortThreshold);return o.kg.debugLog(`abort: doing abort-all (${i?"fast":"normal"} abort)`),i?(e=>{Object.values(e).forEach((e=>e()))})(t):s.forEach((n=>l(n,e,t,r))),{isFast:i}},u=(e,t,n,r,a,s)=>{const l=0===t.fastAbortThreshold?0:t.fastAbortThreshold||s.fastAbortThreshold,c=d(r[e.id].length,l);return o.kg.debugLog(`abort: doing abort-batch on: ${e.id} (${c?"fast":"normal"} abort)`),c?((e,t)=>{e.items.forEach((e=>{var n;let{id:r}=e;return null===(n=t[r])||void 0===n?void 0:n.call(t)}))})(e,n):e.items.forEach((e=>i(e,n,a))),{isFast:c}},h=()=>e=>(e.update({abortAll:c,abortBatch:u,abortItem:l}),e),p=Symbol.for("__rpldy-sstt-proxy__"),g=Symbol.for("__rpldy-sstt-state__"),f=e=>!(0,o.yv)()&&!!e&&!!~Object.getOwnPropertySymbols(e).indexOf(p),b=e=>Array.isArray(e)||(0,o.PO)(e)&&!(e=>(0,o.Ym)()&&e instanceof File||e.name&&e.size&&e.uri)(e),m=(0,o.D8)({withSymbols:!0,predicate:e=>e!==p&&e!==g}),E=e=>!!(0,o.yv)()||e[g].isUpdateable,v=(e,t)=>{(0,o.yv)()||(e[g].isUpdateable=t)},S=(e,t)=>{let n;return b(e)&&(f(e)||(e[p]=!0,n=new Proxy(e,t)),Object.keys(e).forEach((n=>{e[n]=S(e[n],t)}))),n||e},y=e=>f(e)?(0,o.d9)(e,m):e,A=(0,o.ZV)({BATCH_ADD:"BATCH-ADD",BATCH_START:"BATCH-START",BATCH_PROGRESS:"BATCH_PROGRESS",BATCH_FINISH:"BATCH-FINISH",BATCH_ABORT:"BATCH-ABORT",BATCH_CANCEL:"BATCH-CANCEL",BATCH_ERROR:"BATCH-ERROR",BATCH_FINALIZE:"BATCH-FINALIZE",ITEM_START:"FILE-START",ITEM_CANCEL:"FILE-CANCEL",ITEM_PROGRESS:"FILE-PROGRESS",ITEM_FINISH:"FILE-FINISH",ITEM_ABORT:"FILE-ABORT",ITEM_ERROR:"FILE-ERROR",ITEM_FINALIZE:"FILE-FINALIZE",REQUEST_PRE_SEND:"REQUEST_PRE_SEND",ALL_ABORT:"ALL_ABORT"}),O=(0,o.ZV)({ITEM_PROGRESS:"ITEM_PROGRESS",BATCH_PROGRESS:"BATCH_PROGRESS"}),R=[o.FD.FINISHED,o.FD.ERROR,o.FD.CANCELLED,o.FD.ABORTED];var I=n("i9fi"),w=n.n(I);const D=(0,o.D8)({undefinedOverwrites:!0}),T=(e,t,n,r,a,s)=>{const i=n(t),l=e.getState().batches[i[0].batchId].batchOptions,d=(null==r?void 0:r(t,l))||t;return((e,t,n,r,a,s)=>(0,o.sc)(e.trigger,a,t,r).then((e=>(null==s||s(e),((e,t,n,r)=>{if(r){if(o.kg.debugLog(`uploader.queue: REQUEST_PRE_SEND(${e}) event returned updated items/options`,r),r.items){if(r.items.length!==t.length||!(0,o.sQ)(r.items,t,["id","batchId","recycled"]))throw new Error(`REQUEST_PRE_SEND(${e}) event handlers must return same items with same ids`);t=r.items}r.options&&(n=D({},n,r.options))}return{items:t,options:n,cancelled:!1===r}})(a,n,r,e)))))(e,d,i,l,s,a).then((t=>(t.cancelled||((e,t)=>{if(t.items[0]&&e.getState().batches[t.items[0].batchId]){e.updateState((e=>{t.items.forEach((t=>{e.items[t.id]=t})),e.batches[t.items[0].batchId].batchOptions=t.options}));const n=e.getState();t.items=t.items.map((e=>n.items[e.id])),t.options=n.batches[t.items[0].batchId].batchOptions}})(e,t),t)))},C=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return(o,a)=>T(o,a,t,n,r,e)},P=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e.updateState((e=>{const{batchId:r}=e.items[t]||{};n&&delete e.items[t];const o=r?e.itemQueue[r].indexOf(t):-1;~o&&e.itemQueue[r].splice(o,1);const a=e.activeIds.indexOf(t);~a&&e.activeIds.splice(a,1)}))},_=(e,t)=>!!e.getState().items[t],F=C(A.BATCH_START,(e=>e.items),null,(function(){let{batch:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e)throw new Error("BATCH_START event handlers cannot update batch data. Only items & options")})),B=[o.FG.ADDED,o.FG.PROCESSING,o.FG.UPLOADING],L=[o.FG.ABORTED,o.FG.CANCELLED,o.FG.FINISHED,o.FG.ERROR],N=(e,t)=>e.batches[t].batch,G=(e,t)=>{const n=e.getState(),r=n.items[t];return n.batches[r.batchId]},k=(e,t)=>G(e,t).batch,H=(e,t)=>{const n=((e,t)=>N(e.getState(),t))(e,t);n.items.forEach((t=>{let{id:n}=t;return P(e,n,!0)}))},j=(e,t)=>{e.updateState((e=>{delete e.batches[t],delete e.itemQueue[t];const n=e.batchQueue.indexOf(t);~n&&e.batchQueue.splice(n,1)}))},x=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:o.FG.FINISHED,a=arguments.length>4?arguments[4]:void 0;e.updateState((e=>{const n=N(e,t);n.state=r,a&&(n.additionalInfo=a)})),U(e,t,n),U(e,t,A.BATCH_FINALIZE)},U=(e,t,n)=>{const r=e.getState(),o=N(r,t),a=r.items,s={...y(o),items:o.items.map((e=>{let{id:t}=e;return y(a[t])}))};e.trigger(n,s)},$=(e,t)=>{const n=N(e.getState(),t);return w()(B).call(B,n.state)},q=e=>w()(L).call(L,e.state),Q={[o.FD.PENDING]:null,[o.FD.ADDED]:A.ITEM_START,[o.FD.FINISHED]:A.ITEM_FINISH,[o.FD.ERROR]:A.ITEM_ERROR,[o.FD.CANCELLED]:A.ITEM_CANCEL,[o.FD.ABORTED]:A.ITEM_ABORT,[o.FD.UPLOADING]:A.ITEM_PROGRESS},M=e=>!!~R.indexOf(e.state),Z=(e,t,n)=>{t.forEach((t=>{const n=e.getState(),{id:r,info:a}=t;if(o.kg.debugLog("uploader.processor.queue: request finished for item - ",{id:r,info:a}),n.items[r]){e.updateState((e=>{const t=e.items[r];t.state=a.state,t.uploadResponse=a.response,t.uploadStatus=a.status,M(t)&&delete e.aborts[r]}));const t=e.getState().items[r];a.state===o.FD.FINISHED&&t.completed<100&&e.handleItemProgress(t,100,t.file?t.file.size:0),Q[t.state]&&e.trigger(Q[t.state],t),M(t)&&(((e,t)=>{e.updateState((e=>{e.batches[t].finishedCounter+=1}))})(e,t.batchId),e.trigger(A.ITEM_FINALIZE,t))}P(e,r)})),(e=>{(0,o.nK)((()=>{const t=e.getState();Object.keys(t.batches).forEach((n=>{const{batch:r,finishedCounter:a}=t.batches[n],{orgItemCount:s}=r,i=q(r);s===a&&(i||100===r.completed||(e.updateState((e=>{const t=N(e,n);t.completed=100,t.loaded=t.items.reduce(((e,t)=>{let{loaded:n}=t;return e+n}),0)})),U(e,n,A.BATCH_PROGRESS)),e.updateState((e=>{e.currentBatch===n&&(e.currentBatch=null)})),o.kg.debugLog(`uploady.uploader.batchHelpers: cleaning up batch: ${r.id}`),i||x(e,n,A.BATCH_FINISH),H(e,n),j(e,n))}))}))})(e),n(e)},V=C(A.REQUEST_PRE_SEND,(e=>e),((e,t)=>({items:e,options:t}))),W=e=>{let{allowedItems:t,cancelledResults:n,queue:r,items:a,ids:s,next:i}=e;return(t.length?V(r,t):Promise.resolve()).catch((e=>{o.kg.debugLog("uploader.queue: encountered error while preparing items for request",e),((e,t,n,r)=>{const a=n.map((t=>{let{id:n}=t;return{id:n,info:{status:0,state:o.FD.ERROR,response:e}}}));Z(t,a,r)})(e,r,a,i)})).then((e=>{let t;return e&&(e.cancelled?n=s.map((()=>!0)):e.items.some((e=>w()(R).call(R,e.state)))?o.kg.debugLog("uploader.queue: send data contains aborted items - not sending"):((e,t,n)=>{var r;const{items:a,options:s}=t,i=null===(r=e.getState().batches[a[0].batchId])||void 0===r?void 0:r.batch;if(i){let t;try{t=e.sender.send(a,i,s)}catch(e){o.kg.debugLog("uploader.queue: sender failed with unexpected error",e),t={request:Promise.resolve({status:0,state:o.FD.ERROR,response:e.message}),abort:()=>!1,senderType:"exception-handler"}}const{request:r}=t;((e,t,n)=>{e.updateState((e=>{t.forEach((t=>{e.items[t.id].state=o.FD.UPLOADING,e.aborts[t.id]=n.abort}))}))})(e,a,t),r.then((t=>{const r=a.map((e=>({id:e.id,info:t})));Z(e,r,n)}))}})(r,{items:e.items,options:e.options},i)),((e,t,n,r)=>{const a=n.map(((e,n)=>e?t[n].id:null)).filter(Boolean);if(a.length){const t=a.map((e=>({id:e,info:{status:0,state:o.FD.CANCELLED,response:"cancel"}})));Z(e,t,r)}return!!a.length})(r,a,n,i)||(t=i(r)),t}))},Y=(e,t)=>{var n;return w()(n=e.getState().activeIds.flat()).call(n,t)},z=e=>{let t;const n=(e=>{const t=e.getState(),n=t.itemQueue,[r,a]=(e=>{const t=e.getState(),n=t.itemQueue,r=t.items;let a=null,s=0,i=0,l=t.batchQueue[s];for(;l&&!a;){if($(e,l))for(a=n[l][i];a&&(Y(e,a)||r[a].state!==o.FD.ADDED);)i+=1,a=n[l][i];a||(s+=1,l=t.batchQueue[s],i=0)}return a?[l,i]:null})(e)||[];let s,i=r&&~a?n[r][a]:null;if(i){const{batchOptions:e}=t.batches[r],n=e.maxGroupSize||0;s=e.grouped&&n>1?t.itemQueue[r].slice(a,a+n):[i]}return s})(e);if(n){const r=e.getCurrentActiveCount(),{concurrent:a=0,maxConcurrent:s=0}=e.getOptions();(!r||a&&r<s)&&(o.kg.debugLog("uploader.processor: Processing next upload - ",{ids:n,currentCount:r}),t=((e,t)=>{let n;return((e,t)=>{e.updateState((e=>{e.activeIds=e.activeIds.concat(t)}))})(e,t),n=((e,t)=>{const n=k(e,t);return e.getState().currentBatch!==n.id})(e,t[0])?((e,t)=>{const n=k(e,t);return F(e,n).then((r=>{let{cancelled:o}=r,a=!1;return o||(a=!_(e,t),a||e.updateState((e=>{e.currentBatch=n.id}))),!o&&!a}))})(e,t[0]).then((n=>{let r=!n;return r&&(((e,t)=>{if(_(e,t)){const n=G(e,t),r=null==n?void 0:n.batch.id;r?(o.kg.debugLog("uploady.uploader.batchHelpers: cancelling batch: ",r),x(e,r,A.BATCH_CANCEL,o.FG.CANCELLED),H(e,r),j(e,r)):o.kg.debugLog(`uploady.uploader.batchHelpers: cancel batch called for batch already removed (item id = ${t})`)}})(e,t[0]),z(e)),r})).catch((n=>(o.kg.debugLog("uploader.processor: encountered error while preparing batch for request",n),((e,t,n)=>{const r=k(e,t),a=r.id;o.kg.debugLog("uploady.uploader.batchHelpers: failing batch: ",{batch:r}),x(e,a,A.BATCH_ERROR,o.FG.ERROR,n.message),H(e,a),j(e,a)})(e,t[0],n),z(e),!0))):Promise.resolve(!1),n})(e,n).then((t=>{t||(((e,t,n)=>{const r=e.getState();let o=Object.values(r.items);o=o.filter((e=>!!~t.indexOf(e.id))),Promise.all(o.map((t=>e.runCancellable(A.ITEM_START,t)))).then((r=>{let a=r.map(((t,n)=>t?null:((e,t)=>{const n=t.getState().items[e];return n&&!w()(R).call(R,n.state)?n:void 0})(o[n].id,e))).filter(Boolean);return{allowedItems:a,cancelledResults:r,queue:e,items:o,ids:t,next:n}})).then(W)})(e,n,z),a&&z(e))})))}return t},K=z,X=e=>(t,n)=>Z(e,[{id:t,info:n}],K),J=(e,t)=>{const n=e.getOptions().abortItem;(0,o.kG)(!!n,"Abort Item method not provided yet abortItem was called");const r=e.getState();return n(t,r.items,r.aborts,X(e))},ee=(e,t)=>{const n=e.getOptions().abortBatch;(0,o.kG)(!!n,"Abort Batch method not provided yet abortItem was called");const r=e.getState(),a=r.batches[t],s=null==a?void 0:a.batch;if(s&&!q(s)){x(e,t,A.BATCH_ABORT,o.FG.ABORTED);const{isFast:i}=n(s,a.batchOptions,r.aborts,r.itemQueue,X(e),e.getOptions());i&&e.clearBatchUploads(s.id)}},te=e=>{const t=e.getOptions().abortAll;(0,o.kG)(!!t,"Abort All method not provided yet abortAll was called"),e.trigger(A.ALL_ABORT);const n=e.getState(),{isFast:r}=t(n.items,n.aborts,n.itemQueue,X(e),e.getOptions());r&&e.clearAllUploads()},ne=(e,t,n,r,a)=>{const{state:s,update:i}=(e=>{const t={set:(e,r,o)=>(E(n)&&(e[r]=S(o,t)),!0),get:(e,t)=>t===p?y(e):e[t],defineProperty:()=>{throw new Error("Simple State doesnt support defining property")},setPrototypeOf:()=>{throw new Error("Simple State doesnt support setting prototype")},deleteProperty:(e,t)=>(E(n)&&delete e[t],!0)};(0,o.yv)()||f(e)||Object.defineProperty(e,g,{value:{isUpdateable:!1},configurable:!0});const n=(0,o.yv)()?e:S(e,t);return{state:n,update:e=>{if(!(0,o.yv)()&&E(n))throw new Error("Can't call update on State already being updated!");try{v(n,!0),e(n)}finally{v(n,!1)}return n},unwrap:e=>e?y(e):f(n)?y(n):n}})({itemQueue:{},batchQueue:[],currentBatch:null,batches:{},items:{},activeIds:[],aborts:{}}),l=()=>s,d=e=>{i(e)},c=e=>{if(s.items[e.id]&&!e.recycled)throw new Error(`Uploader queue conflict - item ${e.id} already exists`);e.recycled&&((e,t)=>{const{previousBatch:n}=t;if(t.recycled&&n&&e.getState().batches[n]){const{id:r}=k(e,t.id);r===n&&e.updateState((e=>{const n=N(e,r),o=n.items.findIndex((e=>{let{id:n}=e;return n===t.id}));~o&&n.items.splice(o,1)}))}})(h,e),d((t=>{t.items[e.id]=e}))},u=(e,n,r)=>{s.items[e.id]&&(d((t=>{const o=t.items[e.id];o.loaded=r,o.completed=n})),t(A.ITEM_PROGRESS,l().items[e.id]))};r.on(O.ITEM_PROGRESS,u),r.on(O.BATCH_PROGRESS,(e=>{var n;const r=null===(n=s.batches[e.id])||void 0===n?void 0:n.batch.items;if(r){const[n,o]=r.reduce(((e,t)=>{let{id:n}=t;const{completed:r,loaded:o}=s.items[n];return e[0]+=r,e[1]+=o,e}),[0,0]);d((t=>{const a=t.batches[e.id].batch;a.completed=n/r.length,a.loaded=o})),t(A.BATCH_PROGRESS,s.batches[e.id].batch)}}));const h={uploaderId:a,getOptions:()=>e,getCurrentActiveCount:()=>s.activeIds.length,getState:l,updateState:d,trigger:t,runCancellable:function(e){if(!(0,o.mf)(n))throw new Error("Uploader queue - cancellable is of wrong type");for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return n(e,...r)},sender:r,handleItemProgress:u,clearAllUploads:()=>{h.updateState((e=>{e.itemQueue={},e.batchQueue=[],e.currentBatch=null,e.batches={},e.items={},e.activeIds=[]}))},clearBatchUploads:e=>{(0,o.nK)((()=>{o.kg.debugLog(`uploader.queue: started scheduled work to clear batch uploads (${e})`),l().batches[e]&&((e,t)=>{e.updateState((e=>{const{items:n}=N(e,t);delete e.batches[t],delete e.itemQueue[t];const r=e.batchQueue.indexOf(t);~r&&e.batchQueue.splice(r,1),e.currentBatch===t&&(e.currentBatch=null),n.forEach((t=>{let{id:n}=t;delete e.items[n];const r=e.activeIds.indexOf(n);~r&&e.activeIds.splice(r,1)}))}))})(h,e)}))}};return(0,o.Ym)()&&o.kg.isDebugOn()&&(window[`__rpldy_${a}_queue_state`]=h),{updateState:d,getState:h.getState,runCancellable:h.runCancellable,uploadBatch:(e,t)=>{t&&d((n=>{n.batches[e.id].batchOptions=t})),K(h)},addBatch:(e,t)=>(d((n=>{n.batches[e.id]={batch:e,batchOptions:t,finishedCounter:0},n.batchQueue.push(e.id),n.itemQueue[e.id]=e.items.map((e=>{let{id:t}=e;return t}))})),e.items.forEach(c),N(s,e.id)),abortItem:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return J(h,...t)},abortBatch:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ee(h,...t)},abortAll:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(h,...t)},clearPendingBatches:()=>{(e=>{const t=e.getState().batches;Object.keys(t).filter((e=>t[e].batch.state===o.FG.PENDING)).forEach((t=>{H(e,t),j(e,t)}))})(h)},uploadPendingBatches:e=>{((e,t)=>{e.updateState((e=>{Object.keys(e.batches).forEach((n=>{const r=e.batches[n],{batch:a,batchOptions:s}=r;a.state===o.FG.PENDING&&(a.items.forEach((e=>{e.state=o.FD.ADDED})),a.state=o.FG.ADDED,r.batchOptions=(0,o.TS)({},s,t))}))}))})(h,e),K(h)}}};var re=n("Vmq3");const oe=()=>!0,ae=(0,o.ZV)({autoUpload:!0,clearPendingOnAdd:!1,inputFieldName:"file",concurrent:!1,maxConcurrent:2,grouped:!1,maxGroupSize:5,method:"POST",params:{},fileFilter:oe,forceJsonResponse:!1,withCredentials:!1,destination:{},send:null,sendWithFormData:!0,formDataAllowUndefined:!1,fastAbortThreshold:100}),se=()=>{const{trigger:e,target:t}=(0,r.ZP)({send:(t,n,r)=>{const a=r.destination,s=null==a?void 0:a.url,i=(0,o.P2)((r=>((e,t,n,r)=>{((e,t,n,r)=>{e.forEach((e=>{o.kg.debugLog(`uploady.uploader.processor: file: ${e.id} progress event: loaded(${n}) - completed(${t})`),r(O.ITEM_PROGRESS,e,t,n)}))})(e,Math.min(n.loaded/n.total*100,100)/e.length,n.loaded/e.length,r),r(O.BATCH_PROGRESS,t)})(t,n,r,e)),50,!0);return((0,o.mf)(r.send)?r.send:re.ZP)(t,s,{method:(null==a?void 0:a.method)||r.method||ae.method,paramName:(null==a?void 0:a.filesParamName)||r.inputFieldName||"file",params:{...r.params,...null==a?void 0:a.params},forceJsonResponse:r.forceJsonResponse,withCredentials:r.withCredentials,formatGroupParamName:r.formatGroupParamName,headers:null==a?void 0:a.headers,sendWithFormData:r.sendWithFormData,formatServerResponse:r.formatServerResponse,formDataAllowUndefined:r.formDataAllowUndefined,isSuccessfulCall:r.isSuccessfulCall},i)}},Object.values(O));return t},ie=(0,o.Ym)()&&"FileList"in window,le=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e;return(0,o.yv)()||(t<3&&f(e)?n=y(e):t<3&&b(e)&&(n=Array.isArray(e)?e.map((e=>le(e,t+1))):Object.keys(e).reduce(((n,r)=>(n[r]=le(e[r],t+1),n)),{}))),n};let de=0;const ce=(e,t,n,r)=>{const a=se(),s=ne(n,e,t,a,r);return{process:(e,t)=>{s.uploadBatch(e,t)},abortBatch:e=>{s.abortBatch(e)},abort:e=>{e?s.abortItem(e):s.abortAll()},addNewBatch:(e,t,n)=>((e,t,n)=>{de+=1;const r=`batch-${de}`,a=(e=>ie&&e instanceof FileList||"[object FileList]"===e.toString())(e);e=Array.isArray(e)||a?e:[e];const s=!n.autoUpload;return((e,t,n,r)=>{const a=r?Array.prototype.map.call(t,(e=>(0,o.$e)(e)?e.file||e.url:e)):[];return Promise.all(Array.prototype.map.call(t,((e,t)=>{const n=(r||oe)(a[t],t,a);return(0,o.tI)(n)?n.then((t=>!!t&&e)):!!n&&e}))).then((t=>t.filter(Boolean).map((t=>(0,o.Yc)(t,e,n)))))})(r,e,s,n.fileFilter).then((e=>({id:r,uploaderId:t,items:e,state:s?o.FG.PENDING:o.FG.ADDED,completed:0,loaded:0,orgItemCount:e.length,additionalInfo:null})))})(e,t,n).then((e=>s.addBatch(e,n))),runCancellable:s.runCancellable,clearPendingBatches:()=>{s.clearPendingBatches()},processPendingBatches:e=>{s.uploadPendingBatches(e)}}},ue=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.reduce(((e,t)=>t(e,...r)||e),e)}},he=Object.values(A);let pe=0;const ge=e=>{pe+=1;const t=`uploader-${pe}`;let n=!1;const a={};o.kg.debugLog(`uploady.uploader: creating new instance (${t})`,{options:e,counter:pe});let s=(e=>{return{...ae,...e,destination:e&&e.destination?(t=e.destination,{params:{},...t}):null};var t})(e);const i=()=>{g.clearPendingBatches()};let{trigger:l,target:d}=(0,r.ZP)({id:t,update:e=>(s=(0,o.TS)({},s,e),d),add:(e,t)=>{const n=(0,o.TS)({},s,t);return n.clearPendingOnAdd&&i(),g.addNewBatch(e,d.id,n).then((e=>{let t;return e.items.length?t=g.runCancellable(A.BATCH_ADD,e,n).then((t=>{t?(e.state=o.FG.CANCELLED,c(A.BATCH_CANCEL,e)):(o.kg.debugLog(`uploady.uploader [${d.id}]: new items added - auto upload =\n ${String(n.autoUpload)}`,e.items),n.autoUpload&&g.process(e))})):o.kg.debugLog(`uploady.uploader: no items to add. batch ${e.id} is empty. check fileFilter if this isn't intended`),t}))},upload:e=>{g.processPendingBatches(e)},abort:e=>{g.abort(e)},abortBatch:e=>{g.abortBatch(e)},getOptions:()=>(0,o.d9)(s),clearPending:i,registerExtension:(e,t)=>{(0,o.kG)(n,"Uploady - uploader extensions can only be registered by enhancers"),(0,o.kG)(!a[e],"Uploady - uploader extension by this name [%s] already exists",e),o.kg.debugLog(`uploady.uploader: registering extension: ${e.toString()}`,t),a[e]=t},getExtension:e=>a[e]},he,{canAddEvents:!1,canRemoveEvents:!1});const c=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];const a=(0,r.uZ)((()=>n.map(le)));return l(e,a)},u=(0,o.tq)(c),p=((e,t,n,r)=>{const o=t.enhancer?(a=t.enhancer,ue(h(),a)):h();var a;r(!0);const s=o(e,n);return r(!1),s||e})(d,s,c,(e=>{n=e})),g=ce(c,u,s,p.id);return(0,o.ZV)(p)},fe=ge}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.m=t,e=[],r.O=(t,n,o,a)=>{if(!n){var s=1/0;for(c=0;c<e.length;c++){for(var[n,o,a]=e[c],i=!0,l=0;l<n.length;l++)(!1&a||s>=a)&&Object.keys(r.O).every((e=>r.O[e](n[l])))?n.splice(l--,1):(i=!1,a<s&&(s=a));if(i){e.splice(c--,1);var d=o();void 0!==d&&(t=d)}}return t}a=a||0;for(var c=e.length;c>0&&e[c-1][2]>a;c--)e[c]=e[c-1];e[c]=[n,o,a]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={321:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var o,a,[s,i,l]=n,d=0;if(s.some((t=>0!==e[t]))){for(o in i)r.o(i,o)&&(r.m[o]=i[o]);if(l)var c=l(r)}for(t&&t(n);d<s.length;d++)a=s[d],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(c)},n=globalThis.webpackChunkrpldy=globalThis.webpackChunkrpldy||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.O(void 0,[429],(()=>r("SKjz"))),r.O(void 0,[429],(()=>r("wU6r"))),r.O(void 0,[429],(()=>r("Vmq3")));var o=r.O(void 0,[429],(()=>r("4W+v")));return r.O(o)})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rpldy=t():e.rpldy=t()}(globalThis,(()=>(()=>{var e,t={SKjz:(e,t,n)=>{"use strict";n.d(t,{uZ:()=>O,ZP:()=>A});var r=n("E88u");const o=(0,r.ZV)({allowRegisterNonExistent:!0,canAddEvents:!0,canRemoveEvents:!0,collectStats:!1}),a=(e,t)=>{if(!(0,r.mf)(e))throw new Error(`'${t}' is not a valid function`)},s=e=>void 0===e,i=Symbol.for("__le__"),l=Symbol.for("__le__pack__"),d=e=>e?e[i]:null,c=e=>{const t=d(e);if(!t)throw new Error("Didnt find LE internal object. Something very bad happened!");return t},u=e=>!!d(e),h=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a(n,"cb");const o=c(e);if(!o.options.allowRegisterNonExistent&&!~o.events.indexOf(t))throw new Error(`Cannot register for event ${t.toString()} that wasn't already defined (allowRegisterNonExistent = false)`);const s=o.registry[t]||[];return s.find((e=>e.cb===n))||(s.push({name:t,cb:n,once:r}),o.registry[t]=s),()=>S.call(e,t,n)},p=(e,t)=>{const n=c(e).registry;return t?n[t]?n[t].slice():[]:Object.values(n).flat()},g={on:function(e,t){return h(this,e,t)},once:function(e,t){return h(this,e,t,!0)},off:S,getEvents:function(){return c(this).events.slice()}},f=()=>Object.entries(g).reduce(((e,t)=>{let[n,r]=t;return e[n]={value:r},e}),{}),b={trigger:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];const a=p(this,e);let i;if(a.length){var d;let t;1===n.length&&!0===(null===(d=n[0])||void 0===d?void 0:d[l])&&(t=n[0].resolve()),i=a.map((r=>{let o;return r.once&&v(this,e,r.cb),o=t?r.cb(...t):n.length?1===n.length?r.cb(n[0]):2===n.length?r.cb(n[0],n[1]):3===n.length?r.cb(n[0],n[1],n[2]):r.cb(...n):r.cb(),o})).filter((e=>!s(e))).map((e=>(0,r.tI)(e)?e:Promise.resolve(e)))}return i&&(i.length?i:void 0)},addEvent:function(e){const t=c(this);if(!t.options.canAddEvents)throw new Error("Cannot add new events (canAddEvents = false)");if(~t.events.indexOf(e))throw new Error(`Event '${e}' already defined`);t.events.push(e)},removeEvent:function(e){const t=c(this);if(!t.options.canRemoveEvents)throw new Error("Cannot remove events (canRemoveEvents = false)");{const n=t.events.indexOf(e);t.events.splice(n,1)}},hasEvent:function(e){return!!~c(this).events.indexOf(e)},hasEventRegistrations:function(e){return!!p(this,e).length},assign:function(e){const t=c(this);return y(e,t.options,t.events,t.registry,t.stats),m(e)}},m=e=>Object.keys(b).reduce(((t,n)=>(t[n]=b[n].bind(e),t)),{target:e,...b}),E=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=c(e).registry;!r[t]||!n&&r[t].length||delete r[t]},v=(e,t,n)=>{const r=c(e).registry;r[t]&&(n?(r[t]=r[t].filter((e=>e.cb!==n)),E(e,t)):E(e,t,!0))};function S(e,t){v(this,e,t)}const y=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Object.defineProperties(e,{[i]:{value:Object.seal({registry:r,events:n,options:t,stats:o})},...f()})},A=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0;const r=e||{},a={...o,...n};return u(r)||y(r,a,t),m(r)},O=e=>{const t={resolve:()=>[].concat(e())};return Object.defineProperty(t,l,{value:!0,configurable:!1}),t}},Vmq3:(e,t,n)=>{"use strict";n.d(t,{PF:()=>a,Ch:()=>o,ZP:()=>p,KZ:()=>u,lW:()=>h});var r=n("E88u");const o="rpldy-sender";class a extends Error{constructor(e){super(`${e} didn't receive upload URL`),this.name="MissingUrlError"}}const s=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];"set"in e?e.set(t,...r):("delete"in e&&e.delete(t),e.append(t,...r))},i=[200,201,202,203,204],l=(e,t,n,o,a)=>{let i;const l=null!=a&&a.getRequestData?a.getRequestData(e,n):((e,t)=>{let n;if(t.sendWithFormData)r.kg.debugLog(`uploady.sender: sending ${e.length} item(s) as form data`),n=((e,t)=>{const n=new FormData;return t.params&&Object.entries(t.params).forEach((e=>{let[r,o]=e;(t.formDataAllowUndefined||void 0!==o)&&s(n,r,o)})),((e,t,n)=>{const o=1===t.length;t.forEach(((t,a)=>{const i=o?n.paramName:(0,r.mf)(n.formatGroupParamName)?n.formatGroupParamName(a,n.paramName):`${n.paramName}[${a}]`;t.file?s(e,i,t.file,t.file.name):t.url&&s(e,i,t.url)}))})(n,e,t),n})(e,t);else{if(e.length>1)throw new Error(`XHR Sender - Request without form data can only contain 1 item. received ${e.length}`);const t=e[0];r.kg.debugLog(`uploady.sender: sending item ${t.id} as request body`),n=t.file||t.url}return n})(e,n),d=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l,d=arguments.length>2?arguments[2]:void 0;const c=(0,r.TS)({...(0,r.ei)(n,["method","headers","withCredentials"]),preSend:t=>{t.upload.onprogress=t=>{t.lengthComputable&&o&&o(t,e.slice())}}},d),u=(0,r.WY)(a,s,c);return i=u.xhr,u},c=null!=a&&a.preRequestHandler?a.preRequestHandler(d,e,t,n,o,a):d();return{url:t,count:e.length,pXhr:c,getXhr:()=>i,aborted:!1}},d=(e,t,n)=>{let r=e;const o=null==t?void 0:t["content-type"];if(n.forceJsonResponse||null!=o&&o.includes("json"))try{r=JSON.parse(e)}catch{}return r},c=(e,t)=>e.pXhr.then((e=>(r.kg.debugLog("uploady.sender: received upload response ",e),((e,t)=>{const n=t.isSuccessfulCall?t.isSuccessfulCall(e):i.includes(e.status);return(0,r.tI)(n)?n:Promise.resolve(n)})(e,t).then((n=>{var o,a;const s=n?r.FD.FINISHED:r.FD.ERROR,i=e.status,l=(0,r.k7)(e);return{status:i,state:s,response:{data:null!==(o=null===(a=t.formatServerResponse)||void 0===a?void 0:a.call(t,e.response,i,l))&&void 0!==o?o:d(e.response,l,t),headers:l}}}))))).catch((t=>{let n,o;return e.aborted?(n=r.FD.ABORTED,o="aborted"):(r.kg.debugLog("uploady.sender: upload failed: ",t),n=r.FD.ERROR,o=t),{error:!0,state:n,response:o,status:0}})),u=e=>(t,n,s,i)=>{if(!n)throw new a(o);r.kg.debugLog("uploady.sender: sending file: ",{items:t,url:n,options:s});const d=l(t,n,s,i,e);return{request:c(d,s),abort:()=>(e=>{let t=!1;const{aborted:n,getXhr:o}=e,a=o();return!n&&a&&a.readyState&&4!==a.readyState&&(r.kg.debugLog(`uploady.sender: cancelling request with ${e.count} items to: ${e.url}`),a.abort(),e.aborted=!0,t=!0),t})(d),senderType:o}},h=u(),p=h},E88u:(e,t,n)=>{"use strict";n.d(t,{FG:()=>d,FD:()=>c,d9:()=>T,Yc:()=>q,ZV:()=>A,$e:()=>$,D8:()=>D,Ym:()=>u,kG:()=>a(),mf:()=>E(),PO:()=>O,yv:()=>y(),tI:()=>C,sQ:()=>v,kg:()=>r,TS:()=>w,k7:()=>V,ei:()=>P,WY:()=>W,nK:()=>L,P2:()=>i(),tq:()=>b,sc:()=>G});var r={};n.r(r),n.d(r,{debugLog:()=>f,isDebugOn:()=>p,setDebug:()=>g});var o=n("kvau"),a=n.n(o),s=n("uDTZ"),i=n.n(s);const l="__rpldy-logger-debug__",d={PENDING:"pending",ADDED:"added",PROCESSING:"processing",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ABORTED:"aborted",ERROR:"error"},c={PENDING:"pending",ADDED:"added",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ERROR:"error",ABORTED:"aborted"},u=()=>"object"==typeof window&&!!window.document;let h=null;const p=()=>("boolean"!=typeof h&&(h=u()&&("location"in window&&!!~window.location.search.indexOf("rpldy_debug=true")||!0===window[l])),!!h),g=e=>{u()&&(window[l]=e),h=!!e||null},f=function(){p()&&console.log(...arguments)},b=function(e,t){const n=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new Promise(((n,o)=>{const a=e(t,...r);a&&a.length?Promise.all(a).catch(o).then((e=>e&&n(!!~e.findIndex((e=>!1===e))))):n(!1)}))};for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t?n(t,...o):n};var m=n("wfJ/"),E=n.n(m);const v=(e,t,n)=>{let r=!0;const o=(e=>{const t=[].concat(e);return e=>e.map((e=>t.map((t=>e[t])).join()))})(n);if(e&&t&&e.length===t.length){const n=o(e),a=o(t);r=!!n.find(((e,t)=>e!==a[t]))}return!r};var S=n("hSSe"),y=n.n(S);const A=e=>y()()?e:Object.freeze(e),O=e=>{var t;return!!e&&"object"==typeof e&&("Object"===(null===(t=Object.getPrototypeOf(e))||void 0===t?void 0:t.constructor.name)||null===Object.getPrototypeOf(e))},R=e=>O(e)||Array.isArray(e),I=(e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n},D=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];return n&&o.length&&o.forEach((r=>{r&&I(r,e).forEach((o=>{const a=r[o];e.predicate&&!e.predicate(o,a)||(void 0!==a||e.undefinedOverwrites)&&(R(a)?(void 0!==n[o]&&O(n[o])||(n[o]=Array.isArray(a)?[]:{}),t(n[o],a)):n[o]=a)}))})),n};return t},w=D(),T=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:w;return R(e)?t(Array.isArray(e)?[]:{},e):e},P=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),C=function(e){return!!e&&"object"==typeof e&&"function"==typeof e.then},_=u()&&window.requestIdleCallback,F=_?window.requestIdleCallback:setTimeout,B=_?window.cancelIdleCallback:clearTimeout,L=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=F(e,_?{timeout:t}:t);return()=>B(n)},N=function(e){return null==e},G=function(e,t){const n=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new Promise(((n,o)=>{const a=e(t,...r);a&&a.length?Promise.all(a).catch(o).then((e=>{let t;if(e)for(;N(t)&&e.length;)t=e.pop();n(N(t)?void 0:t)})):n()}))};for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t?n(t,...o):n},k=Symbol.for("__rpldy-bi__");let H=0;const x=(e,t)=>(e.url=t,e),j=(e,t)=>(e.file=t,e),U=e=>e&&(e instanceof File||e instanceof Blob||!("object"!=typeof e||!e.name||!e.type)),$=e=>!("object"!=typeof e||!e.id||!e.batchId||!0!==e[k]),q=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=$(e);H+=r?0:1;const o=r&&e.id&&"string"==typeof e.id?e.id:`${t}.item-${H}`,a=n?c.PENDING:c.ADDED;let s={id:o,batchId:t,state:a,uploadStatus:0,completed:0,loaded:0,recycled:r,previousBatch:r?e.batchId:null};Object.defineProperty(s,k,{value:!0,writable:!0});const i=r?e.file||e.url:e;if("string"==typeof i)s=x(s,i);else{if(!U(i))throw new Error("Unknown type of file added: "+typeof i);s=j(s,i)}return s};var Q=n("wVK4");const M=class extends Promise{constructor(e,t){super(e),(0,Q.Z)(this,"xhr",void 0),this.xhr=t}},Z=(e,t)=>{t&&Object.keys(t).forEach((n=>{void 0!==t[n]&&e.setRequestHeader(n,t[n])}))},V=e=>{let t;try{t=e.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce(((e,t)=>{const[n,r]=t.split(": ");return e[n]=r,e}),{})}catch(t){f("uploady.request: failed to read response headers",e)}return t},W=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=new XMLHttpRequest;return new M(((o,a)=>{var s;r.onerror=()=>a(r),r.ontimeout=()=>a(r),r.onabort=()=>a(r),r.onload=()=>o(r),r.open((null==n?void 0:n.method)||"GET",e),Z(r,null==n?void 0:n.headers),r.withCredentials=!(null==n||!n.withCredentials),null==n||null===(s=n.preSend)||void 0===s||s.call(n,r),r.send(t)}),r)}},"wfJ/":e=>{e.exports=function(e){return"function"==typeof e}},hSSe:e=>{e.exports=function(){return!0}},"4W+v":(e,t,n)=>{"use strict";n.r(t),n.d(t,{BATCH_STATES:()=>o.FG,DEFAULT_OPTIONS:()=>oe,FILE_STATES:()=>o.FD,MissingUrlError:()=>ne.PF,UPLOADER_EVENTS:()=>A,XHR_SENDER_TYPE:()=>ne.Ch,composeEnhancers:()=>ce,createUploader:()=>pe,default:()=>ge,getXhrSend:()=>ne.KZ,send:()=>ne.lW});var r=n("SKjz"),o=n("E88u");const a=(e,t,n)=>(o.kg.debugLog(`abort: aborting ${e.state} item - `,e),n(e.id,{status:0,state:o.FD.ABORTED,response:"aborted"}),!0),s={[o.FD.UPLOADING]:(e,t)=>(o.kg.debugLog("abort: aborting uploading item - ",e),t[e.id]()),[o.FD.ADDED]:a,[o.FD.PENDING]:a},i=(e,t,n)=>{const r=null==e?void 0:e.state,o=!!r&&s[r];return!!o&&o(e,t,n)},l=(e,t,n,r)=>i(t[e],n,r),d=(e,t)=>{let n=!1;return 0!==t&&t&&(n=e>=t),n},c=(e,t,n,r,a)=>{const s=Object.values(n).flat(),i=d(s.length,a.fastAbortThreshold);return o.kg.debugLog(`abort: doing abort-all (${i?"fast":"normal"} abort)`),i?(e=>{Object.values(e).forEach((e=>e()))})(t):s.forEach((n=>l(n,e,t,r))),{isFast:i}},u=(e,t,n,r,a,s)=>{const l=0===t.fastAbortThreshold?0:t.fastAbortThreshold||s.fastAbortThreshold,c=d(r[e.id].length,l);return o.kg.debugLog(`abort: doing abort-batch on: ${e.id} (${c?"fast":"normal"} abort)`),c?((e,t)=>{e.items.forEach((e=>{var n;let{id:r}=e;return null===(n=t[r])||void 0===n?void 0:n.call(t)}))})(e,n):e.items.forEach((e=>i(e,n,a))),{isFast:c}},h=()=>e=>(e.update({abortAll:c,abortBatch:u,abortItem:l}),e),p=Symbol.for("__rpldy-sstt-proxy__"),g=Symbol.for("__rpldy-sstt-state__"),f=e=>!(0,o.yv)()&&!!e&&!!~Object.getOwnPropertySymbols(e).indexOf(p),b=e=>Array.isArray(e)||(0,o.PO)(e)&&!(e=>(0,o.Ym)()&&e instanceof File||e.name&&e.size&&e.uri)(e),m=(0,o.D8)({withSymbols:!0,predicate:e=>e!==p&&e!==g}),E=e=>!!(0,o.yv)()||e[g].isUpdateable,v=(e,t)=>{(0,o.yv)()||(e[g].isUpdateable=t)},S=(e,t)=>{let n;return b(e)&&(f(e)||(e[p]=!0,n=new Proxy(e,t)),Object.keys(e).forEach((n=>{e[n]=S(e[n],t)}))),n||e},y=e=>f(e)?(0,o.d9)(e,m):e,A=(0,o.ZV)({BATCH_ADD:"BATCH-ADD",BATCH_START:"BATCH-START",BATCH_PROGRESS:"BATCH_PROGRESS",BATCH_FINISH:"BATCH-FINISH",BATCH_ABORT:"BATCH-ABORT",BATCH_CANCEL:"BATCH-CANCEL",BATCH_ERROR:"BATCH-ERROR",BATCH_FINALIZE:"BATCH-FINALIZE",ITEM_START:"FILE-START",ITEM_CANCEL:"FILE-CANCEL",ITEM_PROGRESS:"FILE-PROGRESS",ITEM_FINISH:"FILE-FINISH",ITEM_ABORT:"FILE-ABORT",ITEM_ERROR:"FILE-ERROR",ITEM_FINALIZE:"FILE-FINALIZE",REQUEST_PRE_SEND:"REQUEST_PRE_SEND",ALL_ABORT:"ALL_ABORT"}),O=(0,o.ZV)({ITEM_PROGRESS:"ITEM_PROGRESS",BATCH_PROGRESS:"BATCH_PROGRESS"}),R=[o.FD.FINISHED,o.FD.ERROR,o.FD.CANCELLED,o.FD.ABORTED],I=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e.updateState((e=>{const{batchId:r}=e.items[t]||{batchId:null};n&&delete e.items[t];const o=r?e.itemQueue[r].indexOf(t):-1;~o&&r&&e.itemQueue[r].splice(o,1);const a=e.activeIds.indexOf(t);~a&&e.activeIds.splice(a,1)}))},D=(e,t)=>!!e.getState().items[t],w=e=>R.includes(e.state),T=(0,o.D8)({undefinedOverwrites:!0}),P=(e,t,n,r,a,s)=>{const i=n(t),l=e.getState().batches[i[0].batchId].batchOptions,d=(null==r?void 0:r(t,l))||t;return((e,t,n,r,a,s)=>(0,o.sc)(e.trigger,a,t,r).then((e=>(null==s||s(e),((e,t,n,r)=>{let a=n,s=t;if(r){if(o.kg.debugLog(`uploader.queue: REQUEST_PRE_SEND(${e}) event returned updated items/options`,r),r.items){if(r.items.length!==t.length||!(0,o.sQ)(r.items,t,["id","batchId","recycled"]))throw new Error(`REQUEST_PRE_SEND(${e}) event handlers must return same items with same ids`);s=r.items}r.options&&(a=T({},n,r.options))}return{items:s,options:a,cancelled:!1===r}})(a,n,r,e)))))(e,d,i,l,s,a).then((t=>(t.cancelled||((e,t)=>{if(t.items[0]&&e.getState().batches[t.items[0].batchId]){e.updateState((e=>{t.items.forEach((t=>{w(e.items[t.id])||(e.items[t.id]=t)})),e.batches[t.items[0].batchId].batchOptions=t.options}));const n=e.getState();t.items=t.items.map((e=>n.items[e.id])),t.options=n.batches[t.items[0].batchId].batchOptions}})(e,t),t)))},C=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return(o,a)=>P(o,a,t,n,r,e)},_=C(A.BATCH_START,(e=>e.items),null,(function(){let{batch:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{batch:!1};if(e)throw new Error("BATCH_START event handlers cannot update batch data. Only items & options")})),F=[o.FG.ADDED,o.FG.PROCESSING,o.FG.UPLOADING],B=[o.FG.ABORTED,o.FG.CANCELLED,o.FG.FINISHED,o.FG.ERROR],L=(e,t)=>e.batches[t].batch,N=(e,t)=>{const n=e.getState(),r=n.items[t];return n.batches[r.batchId]},G=(e,t)=>N(e,t).batch,k=(e,t)=>{const n=((e,t)=>L(e.getState(),t))(e,t);n.items.forEach((t=>{let{id:n}=t;return I(e,n,!0)}))},H=(e,t)=>{e.updateState((e=>{delete e.batches[t],delete e.itemQueue[t];const n=e.batchQueue.indexOf(t);~n&&e.batchQueue.splice(n,1);const r=e.batchesStartPending.indexOf(t);~r&&e.batchesStartPending.splice(r,1)}))},x=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:o.FG.FINISHED,a=arguments.length>4?arguments[4]:void 0;e.updateState((e=>{const n=L(e,t);n.state=r,a&&(n.additionalInfo=a)})),j(e,t,n),j(e,t,A.BATCH_FINALIZE)},j=(e,t,n)=>{const r=e.getState(),o=L(r,t),a=r.items,s={...y(o),items:o.items.map((e=>{let{id:t}=e;return y(a[t])}))};e.trigger(n,s)},U=(e,t)=>{const n=L(e.getState(),t);return F.includes(n.state)},$=e=>B.includes(e.state),q={[o.FD.PENDING]:null,[o.FD.ADDED]:A.ITEM_START,[o.FD.FINISHED]:A.ITEM_FINISH,[o.FD.ERROR]:A.ITEM_ERROR,[o.FD.CANCELLED]:A.ITEM_CANCEL,[o.FD.ABORTED]:A.ITEM_ABORT,[o.FD.UPLOADING]:A.ITEM_PROGRESS},Q=e=>!!~R.indexOf(e.state),M=(e,t,n)=>{t.forEach((t=>{const n=e.getState(),{id:r,info:a}=t;if(o.kg.debugLog("uploader.processor.queue: request finished for item - ",{id:r,info:a}),n.items[r]){e.updateState((e=>{const t=e.items[r];t.state=a.state,t.uploadResponse=a.response,t.uploadStatus=a.status,Q(t)&&delete e.aborts[r]}));const t=e.getState().items[r];a.state===o.FD.FINISHED&&t.completed<100&&e.handleItemProgress(t,100,t.file?t.file.size:0),q[t.state]&&e.trigger(q[t.state],t),Q(t)&&(((e,t)=>{e.updateState((e=>{e.batches[t].finishedCounter+=1}))})(e,t.batchId),e.trigger(A.ITEM_FINALIZE,t))}I(e,r)})),(e=>{(0,o.nK)((()=>{const t=e.getState();Object.keys(t.batches).forEach((n=>{const{batch:r,finishedCounter:a}=t.batches[n],{orgItemCount:s}=r,i=$(r);s===a&&(i||100===r.completed||(e.updateState((e=>{const t=L(e,n);t.completed=100,t.loaded=t.items.reduce(((e,t)=>{let{loaded:n}=t;return e+n}),0)})),j(e,n,A.BATCH_PROGRESS)),e.updateState((e=>{e.currentBatch===n&&(e.currentBatch=null)})),o.kg.debugLog(`uploady.uploader.batchHelpers: cleaning up batch: ${r.id}`),i||x(e,n,A.BATCH_FINISH),k(e,n),H(e,n))}))}))})(e),n(e)},Z=C(A.REQUEST_PRE_SEND,(e=>e),((e,t)=>({items:e,options:t}))),V=e=>{let{allowedItems:t,cancelledResults:n,queue:r,items:a,ids:s,next:i}=e;const l=t.length?Z(r,t):Promise.resolve();let d=n;return l.catch((e=>{o.kg.debugLog("uploader.queue: encountered error while preparing items for request",e),((e,t,n,r)=>{const a=n.map((t=>{let{id:n}=t;return{id:n,info:{status:0,state:o.FD.ERROR,response:e}}}));M(t,a,r)})(e,r,a,i)})).then((e=>{let t;return e&&(e.cancelled?d=s.map((()=>!0)):e.items.some((e=>w(e)))?o.kg.debugLog("uploader.queue: send data contains aborted items - not sending"):((e,t,n)=>{var r;const{items:a,options:s}=t,i=null===(r=e.getState().batches[a[0].batchId])||void 0===r?void 0:r.batch;if(i){let t;try{t=e.sender.send(a,i,s)}catch(e){o.kg.debugLog("uploader.queue: sender failed with unexpected error",e),t={request:Promise.resolve({status:0,state:o.FD.ERROR,response:e.message}),abort:()=>!1,senderType:"exception-handler"}}const{request:r}=t;((e,t,n)=>{e.updateState((e=>{t.forEach((t=>{e.items[t.id].state=o.FD.UPLOADING,e.aborts[t.id]=n.abort}))}))})(e,a,t),r.then((t=>{const r=a.map((e=>({id:e.id,info:t})));M(e,r,n)}))}})(r,{items:e.items,options:e.options},i)),((e,t,n,r)=>{const a=n.map(((e,n)=>e?t[n].id:null)).filter(Boolean);if(a.length){const t=a.map((e=>({id:e,info:{status:0,state:o.FD.CANCELLED,response:"cancel"}})));M(e,t,r)}return!!a.length})(r,a,d,i)||(t=i(r)),t}))},W=(e,t)=>e.getState().activeIds.flat().includes(t),K=e=>{let t;const n=(e=>{const t=e.getState(),n=t.itemQueue,[r,a]=(e=>{const t=e.getState(),n=t.itemQueue,r=t.items;let a=null,s=0,i=0,l=t.batchQueue[s];for(;l&&!a;){if(U(e,l))for(a=n[l][i];a&&(W(e,a)||r[a].state!==o.FD.ADDED);)i+=1,a=n[l][i];a||(s+=1,l=t.batchQueue[s],i=0)}return a?[l,i]:null})(e)||[];let s,i=r&&~a?n[r][a]:null;if(i){const{batchOptions:e}=t.batches[r],n=e.maxGroupSize||0;s=e.grouped&&n>1?t.itemQueue[r].slice(a,a+n):[i]}return s})(e);if(n){const r=e.getCurrentActiveCount(),{concurrent:a=!1,maxConcurrent:s=0}=e.getOptions();(!r||a&&r<s)&&(o.kg.debugLog("uploader.processor: Processing next upload - ",{ids:n,currentCount:r}),t=((e,t)=>{let n;return((e,t)=>{const n=G(e,t);return e.getState().batchesStartPending.includes(n.id)})(e,t[0])?n=Promise.resolve(!0):(((e,t)=>{e.updateState((e=>{e.activeIds=e.activeIds.concat(t)}))})(e,t),n=((e,t)=>{const n=G(e,t);return e.getState().currentBatch!==n.id})(e,t[0])?((e,t)=>{const n=G(e,t);return e.updateState((e=>{e.batchesStartPending.push(n.id)})),_(e,n).then((r=>{let{cancelled:o}=r,a=!1;return e.updateState((e=>{const t=e.batchesStartPending.indexOf(n.id);e.batchesStartPending.splice(t,1)})),o||(a=!D(e,t),a||e.updateState((e=>{e.currentBatch=n.id}))),!o&&!a}))})(e,t[0]).then((n=>{let r=!n;return r&&(((e,t)=>{if(D(e,t)){const n=N(e,t),r=null==n?void 0:n.batch.id;r?(o.kg.debugLog("uploady.uploader.batchHelpers: cancelling batch: ",r),x(e,r,A.BATCH_CANCEL,o.FG.CANCELLED),k(e,r),H(e,r)):o.kg.debugLog(`uploady.uploader.batchHelpers: cancel batch called for batch already removed (item id = ${t})`)}})(e,t[0]),K(e)),r})).catch((n=>(o.kg.debugLog("uploader.processor: encountered error while preparing batch for request",n),((e,t,n)=>{const r=G(e,t),a=r.id;o.kg.debugLog("uploady.uploader.batchHelpers: failing batch: ",{batch:r}),x(e,a,A.BATCH_ERROR,o.FG.ERROR,n.message),k(e,a),H(e,a)})(e,t[0],n),K(e),!0))):Promise.resolve(!1)),n})(e,n).then((t=>{t||(((e,t,n)=>{const r=e.getState();let o=Object.values(r.items);o=o.filter((e=>t.includes(e.id)&&!w(e))),Promise.all(o.map((t=>e.runCancellable(A.ITEM_START,t)))).then((r=>{let a=r.map(((t,n)=>t?null:((e,t)=>{const n=t.getState().items[e];return n&&!w(n)?n:void 0})(o[n].id,e))).filter(Boolean);return{allowedItems:a,cancelledResults:r,queue:e,items:o,ids:t,next:n}})).then(V)})(e,n,K),a&&K(e))})))}return t},Y=K,z=e=>(t,n)=>M(e,[{id:t,info:n}],Y),X=(e,t)=>{const n=e.getOptions().abortItem;(0,o.kG)(!!n,"Abort Item method not provided yet abortItem was called");const r=e.getState();return n(t,r.items,r.aborts,z(e))},J=(e,t)=>{const n=e.getOptions().abortBatch;(0,o.kG)(!!n,"Abort Batch method not provided yet abortItem was called");const r=e.getState(),a=r.batches[t],s=null==a?void 0:a.batch;if(s&&!$(s)){x(e,t,A.BATCH_ABORT,o.FG.ABORTED);const{isFast:i}=n(s,a.batchOptions,r.aborts,r.itemQueue,z(e),e.getOptions());i&&e.clearBatchUploads(s.id)}},ee=e=>{const t=e.getOptions().abortAll;(0,o.kG)(!!t,"Abort All method not provided yet abortAll was called"),e.trigger(A.ALL_ABORT);const n=e.getState(),{isFast:r}=t(n.items,n.aborts,n.itemQueue,z(e),e.getOptions());r&&e.clearAllUploads()},te=(e,t,n,r,a)=>{const{state:s,update:i}=(e=>{const t={set:(e,r,o)=>(E(n)&&(e[r]=S(o,t)),!0),get:(e,t)=>t===p?y(e):e[t],defineProperty:()=>{throw new Error("Simple State doesnt support defining property")},setPrototypeOf:()=>{throw new Error("Simple State doesnt support setting prototype")},deleteProperty:(e,t)=>(E(n)&&delete e[t],!0)};(0,o.yv)()||f(e)||Object.defineProperty(e,g,{value:{isUpdateable:!1},configurable:!0});const n=(0,o.yv)()?e:S(e,t);return{state:n,update:e=>{if(!(0,o.yv)()&&E(n))throw new Error("Can't call update on State already being updated!");try{v(n,!0),e(n)}finally{v(n,!1)}return n},unwrap:e=>e?y(e):f(n)?y(n):n}})({itemQueue:{},batchQueue:[],currentBatch:null,batchesStartPending:[],batches:{},items:{},activeIds:[],aborts:{}}),l=()=>s,d=e=>{i(e)},c=e=>{if(s.items[e.id]&&!e.recycled)throw new Error(`Uploader queue conflict - item ${e.id} already exists`);e.recycled&&((e,t)=>{const{previousBatch:n}=t;if(t.recycled&&n&&e.getState().batches[n]){const{id:r}=G(e,t.id);r===n&&e.updateState((e=>{const n=L(e,r),o=n.items.findIndex((e=>{let{id:n}=e;return n===t.id}));~o&&n.items.splice(o,1)}))}})(h,e),d((t=>{t.items[e.id]=e}))},u=(e,n,r)=>{s.items[e.id]&&(d((t=>{const o=t.items[e.id];o.loaded=r,o.completed=n})),t(A.ITEM_PROGRESS,l().items[e.id]))};r.on(O.ITEM_PROGRESS,u),r.on(O.BATCH_PROGRESS,(e=>{var n;const r=null===(n=s.batches[e.id])||void 0===n?void 0:n.batch.items;if(r){const[n,o]=r.reduce(((e,t)=>{let{id:n}=t;const{completed:r,loaded:o}=s.items[n];return e[0]+=r,e[1]+=o,e}),[0,0]);d((t=>{const a=t.batches[e.id].batch;a.completed=n/r.length,a.loaded=o})),t(A.BATCH_PROGRESS,s.batches[e.id].batch)}}));const h={uploaderId:a,getOptions:()=>e,getCurrentActiveCount:()=>s.activeIds.length,getState:l,updateState:d,trigger:t,runCancellable:function(e){if(!(0,o.mf)(n))throw new Error("Uploader queue - cancellable is of wrong type");for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return n(e,...r)},sender:r,handleItemProgress:u,clearAllUploads:()=>{h.updateState((e=>{e.itemQueue={},e.batchQueue=[],e.currentBatch=null,e.batches={},e.items={},e.activeIds=[]}))},clearBatchUploads:e=>{(0,o.nK)((()=>{o.kg.debugLog(`uploader.queue: started scheduled work to clear batch uploads (${e})`),l().batches[e]&&((e,t)=>{e.updateState((e=>{const{items:n}=L(e,t);delete e.batches[t],delete e.itemQueue[t];const r=e.batchQueue.indexOf(t);~r&&e.batchQueue.splice(r,1),e.currentBatch===t&&(e.currentBatch=null),n.forEach((t=>{let{id:n}=t;delete e.items[n];const r=e.activeIds.indexOf(n);~r&&e.activeIds.splice(r,1)}))}))})(h,e)}))}};return(0,o.Ym)()&&o.kg.isDebugOn()&&(window[`__rpldy_${a}_queue_state`]=h),{updateState:d,getState:h.getState,runCancellable:h.runCancellable,uploadBatch:(e,t)=>{t&&d((n=>{n.batches[e.id].batchOptions=t})),Y(h)},addBatch:(e,t)=>(d((n=>{n.batches[e.id]={batch:e,batchOptions:t,finishedCounter:0},n.batchQueue.push(e.id),n.itemQueue[e.id]=e.items.map((e=>{let{id:t}=e;return t}))})),e.items.forEach(c),L(s,e.id)),abortItem:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return X(h,...t)},abortBatch:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return J(h,...t)},abortAll:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ee(h,...t)},clearPendingBatches:()=>{(e=>{const t=e.getState().batches;Object.keys(t).filter((e=>t[e].batch.state===o.FG.PENDING)).forEach((t=>{k(e,t),H(e,t)}))})(h)},uploadPendingBatches:e=>{((e,t)=>{e.updateState((e=>{Object.keys(e.batches).forEach((n=>{const r=e.batches[n],{batch:a,batchOptions:s}=r;a.state===o.FG.PENDING&&(a.items.forEach((e=>{e.state=o.FD.ADDED})),a.state=o.FG.ADDED,r.batchOptions=(0,o.TS)({},s,t))}))}))})(h,e),Y(h)}}};var ne=n("Vmq3");const re=()=>!0,oe=(0,o.ZV)({autoUpload:!0,clearPendingOnAdd:!1,inputFieldName:"file",concurrent:!1,maxConcurrent:2,grouped:!1,maxGroupSize:5,method:"POST",params:{},fileFilter:re,forceJsonResponse:!1,withCredentials:!1,destination:{},send:null,sendWithFormData:!0,formDataAllowUndefined:!1,fastAbortThreshold:100}),ae=()=>{const{trigger:e,target:t}=(0,r.ZP)({send:(t,n,r)=>{const a=r.destination,s=null==a?void 0:a.url,i=(0,o.P2)((r=>((e,t,n,r)=>{((e,t,n,r)=>{e.forEach((e=>{o.kg.debugLog(`uploady.uploader.processor: file: ${e.id} progress event: loaded(${n}) - completed(${t})`),r(O.ITEM_PROGRESS,e,t,n)}))})(e,Math.min(n.loaded/n.total*100,100)/e.length,n.loaded/e.length,r),r(O.BATCH_PROGRESS,t)})(t,n,r,e)),50,!0);return((0,o.mf)(r.send)?r.send:ne.ZP)(t,s,{method:(null==a?void 0:a.method)||r.method||oe.method,paramName:(null==a?void 0:a.filesParamName)||r.inputFieldName||"file",params:{...r.params,...null==a?void 0:a.params},forceJsonResponse:r.forceJsonResponse,withCredentials:r.withCredentials,formatGroupParamName:r.formatGroupParamName,headers:null==a?void 0:a.headers,sendWithFormData:r.sendWithFormData,formatServerResponse:r.formatServerResponse,formDataAllowUndefined:r.formDataAllowUndefined,isSuccessfulCall:r.isSuccessfulCall},i)}},Object.values(O));return t},se=(0,o.Ym)()&&"FileList"in window,ie=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e;return(0,o.yv)()||(t<3&&f(e)?n=y(e):t<3&&b(e)&&(n=Array.isArray(e)?e.map((e=>ie(e,t+1))):Object.keys(e).reduce(((n,r)=>(n[r]=ie(e[r],t+1),n)),{}))),n};let le=0;const de=(e,t,n,r)=>{const a=ae(),s=te(n,e,t,a,r);return{process:(e,t)=>{s.uploadBatch(e,t)},abortBatch:e=>{s.abortBatch(e)},abort:e=>{e?s.abortItem(e):s.abortAll()},addNewBatch:(e,t,n)=>((e,t,n)=>{le+=1;const r=`batch-${le}`,a=(e=>se&&e instanceof FileList||"[object FileList]"===e.toString())(e),s=Array.isArray(e)||a?e:[e],i=!n.autoUpload;return((e,t,n,r)=>{const a=r?Array.prototype.map.call(t,(e=>(0,o.$e)(e)?e.file||e.url:e)):[];return Promise.all(Array.prototype.map.call(t,((e,t)=>{const n=(r||re)(a[t],t,a);return(0,o.tI)(n)?n.then((t=>!!t&&e)):!!n&&e}))).then((t=>t.filter(Boolean).map((t=>(0,o.Yc)(t,e,n)))))})(r,s,i,n.fileFilter).then((e=>({id:r,uploaderId:t,items:e,state:i?o.FG.PENDING:o.FG.ADDED,completed:0,loaded:0,orgItemCount:e.length,additionalInfo:null})))})(e,t,n).then((e=>s.addBatch(e,n))),runCancellable:s.runCancellable,clearPendingBatches:()=>{s.clearPendingBatches()},processPendingBatches:e=>{s.uploadPendingBatches(e)}}},ce=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.reduce(((e,t)=>t(e,...r)||e),e)}},ue=Object.values(A);let he=0;const pe=e=>{he+=1;const t=`uploader-${he}`;let n=!1;const a={};o.kg.debugLog(`uploady.uploader: creating new instance (${t})`,{options:e,counter:he});let s=(e=>{return{...oe,...e,destination:e&&e.destination?(t=e.destination,{params:{},...t}):null};var t})(e);const i=()=>{g.clearPendingBatches()};let{trigger:l,target:d}=(0,r.ZP)({id:t,update:e=>(s=(0,o.TS)({},s,e),d),add:(e,t)=>{const n=(0,o.TS)({},s,t);return n.clearPendingOnAdd&&i(),g.addNewBatch(e,d.id,n).then((e=>{let t;return e.items.length?t=g.runCancellable(A.BATCH_ADD,e,n).then((t=>{t?(e.state=o.FG.CANCELLED,c(A.BATCH_CANCEL,e)):(o.kg.debugLog(`uploady.uploader [${d.id}]: new items added - auto upload =\n ${String(n.autoUpload)}`,e.items),n.autoUpload&&g.process(e))})):o.kg.debugLog(`uploady.uploader: no items to add. batch ${e.id} is empty. check fileFilter if this isn't intended`),t}))},upload:e=>{g.processPendingBatches(e)},abort:e=>{g.abort(e)},abortBatch:e=>{g.abortBatch(e)},getOptions:()=>(0,o.d9)(s),clearPending:i,registerExtension:(e,t)=>{(0,o.kG)(n,"Uploady - uploader extensions can only be registered by enhancers"),(0,o.kG)(!a[e],"Uploady - uploader extension by this name [%s] already exists",e),o.kg.debugLog(`uploady.uploader: registering extension: ${e.toString()}`,t),a[e]=t},getExtension:e=>a[e]},ue,{canAddEvents:!1,canRemoveEvents:!1});const c=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];const a=(0,r.uZ)((()=>n.map(ie)));return l(e,a)},u=(0,o.tq)(c),p=((e,t,n,r)=>{const o=t.enhancer?(a=t.enhancer,ce(h(),a)):h();var a;r(!0);const s=o(e,n);return r(!1),s||e})(d,s,c,(e=>{n=e})),g=de(c,u,s,p.id);return(0,o.ZV)(p)},ge=pe}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.m=t,e=[],r.O=(t,n,o,a)=>{if(!n){var s=1/0;for(c=0;c<e.length;c++){for(var[n,o,a]=e[c],i=!0,l=0;l<n.length;l++)(!1&a||s>=a)&&Object.keys(r.O).every((e=>r.O[e](n[l])))?n.splice(l--,1):(i=!1,a<s&&(s=a));if(i){e.splice(c--,1);var d=o();void 0!==d&&(t=d)}}return t}a=a||0;for(var c=e.length;c>0&&e[c-1][2]>a;c--)e[c]=e[c-1];e[c]=[n,o,a]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={321:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var o,a,[s,i,l]=n,d=0;if(s.some((t=>0!==e[t]))){for(o in i)r.o(i,o)&&(r.m[o]=i[o]);if(l)var c=l(r)}for(t&&t(n);d<s.length;d++)a=s[d],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(c)},n=globalThis.webpackChunkrpldy=globalThis.webpackChunkrpldy||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.O(void 0,[429],(()=>r("SKjz"))),r.O(void 0,[429],(()=>r("E88u"))),r.O(void 0,[429],(()=>r("Vmq3")));var o=r.O(void 0,[429],(()=>r("4W+v")));return r.O(o)})()));
//# sourceMappingURL=rpldy-core.umd.min.js.map
{
"version": "1.3.1",
"version": "1.4.0-rc.0",
"name": "@rpldy/uploader",

@@ -30,14 +30,14 @@ "description": "the processing and queuing engine for react-uploady",

"build": "node ../../../scripts/build.js",
"flow:copy": "flow-copy-source ./src ./lib/flow --ignore **/*.test.js --ignore **/*.mock.js; cp src/types.js lib/types.js"
"flow:copy": "flow-copy-source ./src ./lib --ignore **/*.test.js --ignore **/*.mock.js; cp src/types.js lib/types.js"
},
"dependencies": {
"@rpldy/abort": "^1.3.1",
"@rpldy/life-events": "^1.3.1",
"@rpldy/raw-uploader": "^1.3.1",
"@rpldy/sender": "^1.3.1",
"@rpldy/shared": "^1.3.1",
"@rpldy/simple-state": "^1.3.1"
"@rpldy/abort": "^1.4.0-rc.0",
"@rpldy/life-events": "^1.4.0-rc.0",
"@rpldy/raw-uploader": "^1.4.0-rc.0",
"@rpldy/sender": "^1.4.0-rc.0",
"@rpldy/shared": "^1.4.0-rc.0",
"@rpldy/simple-state": "^1.4.0-rc.0"
},
"devDependencies": {
"flow-bin": "^0.182.0"
"flow-bin": "^0.199.1"
},

@@ -47,3 +47,3 @@ "publishConfig": {

},
"gitHead": "8a2473ae6d9521c5f16f5ae525466075ac02fd1f"
"gitHead": "96a9141aa17e74962f1606d836f8f9f5c4b7aef0"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc