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

@rpldy/uploader

Package Overview
Dependencies
Maintainers
0
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.8.1 to 1.8.2

2

lib/cjs/batchItemsSender.js

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

var _defaults = require("./defaults");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const reportItemsProgress = (items, completed, loaded, total, trigger) => {

@@ -15,0 +15,0 @@ items.forEach(item => {

@@ -68,3 +68,3 @@ "use strict";

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

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

var _batch = _interopRequireDefault(require("./batch"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const createProcessor = (trigger, cancellable, options, uploaderId) => {

@@ -15,0 +15,0 @@ const sender = (0, _batchItemsSender.default)(),

@@ -13,2 +13,2 @@ "use strict";

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

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

var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const getFinalizeAbortedItem = queue => (id, data) => (0, _processFinishedRequest.default)(queue, [{

@@ -15,0 +15,0 @@ id,

@@ -13,3 +13,3 @@ "use strict";

var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const preparePreRequestItems = (0, _preSendPrepare.getItemsPrepareUpdater)(_consts.UPLOADER_EVENTS.REQUEST_PRE_SEND, items => items, (items, options) => ({

@@ -16,0 +16,0 @@ items,

@@ -10,3 +10,3 @@ "use strict";

var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const getIsItemInActiveRequest = (queue, itemId) => {

@@ -13,0 +13,0 @@ return queue.getState().activeIds.flat().includes(itemId);

@@ -13,3 +13,3 @@ "use strict";

var _batchHelpers = require("./batchHelpers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const createUploaderQueue = (options, trigger, cancellable, sender, uploaderId) => {

@@ -16,0 +16,0 @@ const {

@@ -14,5 +14,5 @@ "use strict";

var _composeEnhancers = _interopRequireDefault(require("./composeEnhancers"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const EVENT_NAMES = Object.values(_consts.UPLOADER_EVENTS);

@@ -19,0 +19,0 @@ const EXT_OUTSIDE_ENHANCER_TIME = "Uploady - uploader extensions can only be registered by enhancers",

/*! 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={VY1i:(e,t,n)=>{"use strict";n.d(t,{yn:()=>S,Ay:()=>E});var r=n("k4c9");const a=(0,r.fO)({allowRegisterNonExistent:!0,canAddEvents:!0,canRemoveEvents:!0,collectStats:!1}),o=Symbol.for("__le__"),s=Symbol.for("__le__pack__"),i=e=>e?e[o]:null,d=e=>{const t=i(e);if(!t)throw new Error("Didnt find LE internal object. Something very bad happened!");return t},c=(e,t,n,a=!1)=>{((e,t)=>{if(!(0,r.Tn)(e))throw new Error("'cb' is not a valid function")})(n);const o=d(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:a}),o.registry[t]=s),()=>f.call(e,t,n)},l=(e,t)=>{const n=d(e).registry;return t?n[t]?n[t].slice():[]:Object.values(n).flat()},u={on:function(e,t){return c(this,e,t)},once:function(e,t){return c(this,e,t,!0)},off:f,getEvents:function(){return d(this).events.slice()}},p={trigger:function(e,...t){const n=l(this,e);let a;if(n.length){let o;1===t.length&&!0===t[0]?.[s]&&(o=t[0].resolve()),a=n.map((n=>{let r;return n.once&&m(this,e,n.cb),r=o?n.cb(...o):t.length?1===t.length?n.cb(t[0]):2===t.length?n.cb(t[0],t[1]):3===t.length?n.cb(t[0],t[1],t[2]):n.cb(...t):n.cb(),r})).filter((e=>!(void 0===e))).map((e=>(0,r.yL)(e)?e:Promise.resolve(e)))}return a&&(a.length?a:void 0)},addEvent:function(e){const t=d(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=d(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!!~d(this).events.indexOf(e)},hasEventRegistrations:function(e){return!!l(this,e).length},assign:function(e){const t=d(this);return g(e,t.options,t.events,t.registry,t.stats),h(e)}},h=e=>Object.keys(p).reduce(((t,n)=>(t[n]=p[n].bind(e),t)),{target:e,...p}),b=(e,t,n=!1)=>{const r=d(e).registry;!r[t]||!n&&r[t].length||delete r[t]},m=(e,t,n)=>{const r=d(e).registry;r[t]&&(n?(r[t]=r[t].filter((e=>e.cb!==n)),b(e,t)):b(e,t,!0))};function f(e,t){m(this,e,t)}const g=(e,t,n=[],r={},a={})=>{Object.defineProperties(e,{[o]:{value:Object.seal({registry:r,events:n,options:t,stats:a})},...Object.entries(u).reduce(((e,[t,n])=>(e[t]={value:n},e)),{})})},E=(e,t=[],n)=>{const r=e||{},o={...a,...n};return i(r)||g(r,o,t),h(r)},S=e=>{const t={resolve:()=>[].concat(e())};return Object.defineProperty(t,s,{value:!0,configurable:!1}),t}},ySws:(e,t,n)=>{"use strict";n.d(t,{wc:()=>o,cp:()=>a,Ay:()=>h,DH:()=>u,tN:()=>p});var r=n("k4c9");const a="rpldy-sender";class o extends Error{constructor(e){super(`${e} didn't receive upload URL`),this.name="MissingUrlError"}}const s=(e,t,...n)=>{"set"in e?e.set(t,...n):("delete"in e&&e.delete(t),e.append(t,...n))},i=[200,201,202,203,204],d=(e,t,n,a,o)=>{let i;const d=o?.getRequestData?o.getRequestData(e,n):((e,t)=>{let n;if(t.sendWithFormData)r.vF.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,r])=>{(t.formDataAllowUndefined||void 0!==r)&&s(n,e,r)})),((e,t,n)=>{const a=1===t.length;t.forEach(((t,o)=>{const i=a?n.paramName:(0,r.Tn)(n.formatGroupParamName)?n.formatGroupParamName(o,n.paramName):`${n.paramName}[${o}]`;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.vF.debugLog(`uploady.sender: sending item ${t.id} as request body`),n=t.file||t.url}return n})(e,n),c=(o=t,s=d,c)=>{const l=(0,r.h1)({...(0,r.Up)(n,["method","headers","withCredentials"]),preSend:t=>{t.upload.onprogress=t=>{t.lengthComputable&&a&&a(t,e.slice())}}},c),u=(0,r.Em)(o,s,l);return i=u.xhr,u},l=o?.preRequestHandler?o.preRequestHandler(c,e,t,n,a,o):c();return{url:t,count:e.length,pXhr:l,getXhr:()=>i,aborted:!1}},c=(e,t,n)=>{let r=e;const a=t?.["content-type"];if(n.forceJsonResponse||a?.includes("json"))try{r=JSON.parse(e)}catch{}return r},l=(e,t)=>e.pXhr.then((e=>(r.vF.debugLog("uploady.sender: received upload response ",e),((e,t)=>{const n=t.isSuccessfulCall?t.isSuccessfulCall(e):i.includes(e.status);return(0,r.yL)(n)?n:Promise.resolve(n)})(e,t).then((n=>{const a=n?r.aN.FINISHED:r.aN.ERROR,o=e.status,s=(0,r.tn)(e);return{status:o,state:a,response:{data:t.formatServerResponse?.(e.response,o,s)??c(e.response,s,t),headers:s}}}))))).catch((t=>{let n,a;return e.aborted?(n=r.aN.ABORTED,a="aborted"):(r.vF.debugLog("uploady.sender: upload failed: ",t),n=r.aN.ERROR,a=t),{error:!0,state:n,response:a,status:0}})),u=e=>(t,n,s,i)=>{if(!n)throw new o(a);r.vF.debugLog("uploady.sender: sending file: ",{items:t,url:n,options:s});const c=d(t,n,s,i,e);return{request:l(c,s),abort:()=>(e=>{let t=!1;const{aborted:n,getXhr:a}=e,o=a();return!n&&o&&o.readyState&&4!==o.readyState&&(r.vF.debugLog(`uploady.sender: cancelling request with ${e.count} items to: ${e.url}`),o.abort(),e.aborted=!0,t=!0),t})(c),senderType:a}},p=u(),h=p},k4c9:(e,t,n)=>{"use strict";n.d(t,{mX:()=>d,aN:()=>c,o8:()=>T,UT:()=>j,fO:()=>O,Uk:()=>x,fd:()=>R,Vd:()=>l,V1:()=>o(),Tn:()=>g(),Qd:()=>v,KV:()=>y(),yL:()=>w,hR:()=>E,vF:()=>r,h1:()=>I,tn:()=>G,Up:()=>N,Em:()=>$,tD:()=>C,nF:()=>s.A,x1:()=>m,w$:()=>L});var r={};n.r(r),n.d(r,{debugLog:()=>b,isDebugOn:()=>p,setDebug:()=>h});var a=n("3lvE"),o=n.n(a),s=n("6dsl");const i="__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"},l=()=>"object"==typeof window&&!!window.document;let u=null;const p=()=>("boolean"!=typeof u&&(u=l()&&("location"in window&&!!~window.location.search.indexOf("rpldy_debug=true")||!0===window[i])),!!u),h=e=>{l()&&(window[i]=e),u=!!e||null},b=(...e)=>{p()&&console.log(...e)},m=(e,t,...n)=>{const r=(t,...n)=>new Promise(((r,a)=>{const o=e(t,...n);o&&o.length?Promise.all(o).catch(a).then((e=>e&&r(!!~e.findIndex((e=>!1===e))))):r(!1)}));return t?r(t,...n):r};var f=n("5JaP"),g=n.n(f);const E=(e,t,n)=>{let r=!0;const a=(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=a(e),o=a(t);r=!!n.find(((e,t)=>e!==o[t]))}return!r};var S=n("Qpxl"),y=n.n(S);const O=e=>y()()?e:Object.freeze(e),v=e=>!!e&&"object"==typeof e&&("Object"===Object.getPrototypeOf(e)?.constructor.name||null===Object.getPrototypeOf(e)),A=e=>v(e)||Array.isArray(e),R=(e={})=>{const t=(n,...r)=>(n&&r.length&&r.forEach((r=>{r&&((e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n})(r,e).forEach((a=>{const o=r[a];e.predicate&&!e.predicate(a,o)||(void 0!==o||e.undefinedOverwrites)&&(A(o)?(void 0!==n[a]&&v(n[a])||(n[a]=Array.isArray(o)?[]:{}),t(n[a],o)):n[a]=o)}))})),n);return t},I=R(),T=(e,t=I)=>A(e)?t(Array.isArray(e)?[]:{},e):e,N=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),w=function(e){return!!e&&"object"==typeof e&&"function"==typeof e.then},D=l()&&window.requestIdleCallback,P=D?window.requestIdleCallback:setTimeout,_=D?window.cancelIdleCallback:clearTimeout,C=(e,t=0)=>{const n=P(e,D?{timeout:t}:t);return()=>_(n)},B=function(e){return null==e},L=(e,t,...n)=>{const r=(t,...n)=>new Promise(((r,a)=>{const o=e(t,...n);o&&o.length?Promise.all(o).catch(a).then((e=>{let t;if(e)for(;B(t)&&e.length;)t=e.pop();r(B(t)?void 0:t)})):r()}));return t?r(t,...n):r},F=Symbol.for("__rpldy-bi__");let H=0;const x=e=>!("object"!=typeof e||!e.id||!e.batchId||!0!==e[F]),j=(e,t,n=!1)=>{const r=x(e);H+=r?0:1;let a={id:r&&e.id&&"string"==typeof e.id?e.id:`${t}.item-${H}`,batchId:t,state:n?c.PENDING:c.ADDED,uploadStatus:0,total:0,completed:0,loaded:0,recycled:r,previousBatch:r?e.batchId:null};Object.defineProperty(a,F,{value:!0,writable:!0});const o=r?e.file||e.url:e;if("string"==typeof o)a=((e,t)=>(e.url=t,e))(a,o);else{if(!(e=>e&&(e instanceof File||e instanceof Blob||!("object"!=typeof e||!e.name||!e.type)))(o))throw new Error("Unknown type of file added: "+typeof o);a=((e,t)=>(e.file=t,e))(a,o)}return a},U=class extends Promise{constructor(e,t){super(e),this.xhr=t}},G=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){b("uploady.request: failed to read response headers",e)}return t},$=(e,t,n={})=>{const r=new XMLHttpRequest;return new U(((a,o)=>{r.onerror=()=>o(r),r.ontimeout=()=>o(r),r.onabort=()=>o(r),r.onload=()=>a(r),r.open(n?.method||"GET",e),((e,t)=>{t&&Object.keys(t).forEach((n=>{void 0!==t[n]&&e.setRequestHeader(n,t[n])}))})(r,n?.headers),r.withCredentials=!!n?.withCredentials,n?.preSend?.(r),r.send(t)}),r)}},"5JaP":e=>{e.exports=function(e){return"function"==typeof e}},Qpxl:e=>{e.exports=function(){return!0}},QBXY:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BATCH_STATES:()=>a.mX,DEFAULT_OPTIONS:()=>ne,FILE_STATES:()=>a.aN,MissingUrlError:()=>ee.wc,UPLOADER_EVENTS:()=>h,XHR_SENDER_TYPE:()=>ee.cp,composeEnhancers:()=>de,createUploader:()=>ue,default:()=>pe,getXhrSend:()=>ee.DH,send:()=>ee.tN});var r=n("VY1i"),a=n("k4c9");const o=(e,t,n)=>(a.vF.debugLog(`abort: aborting ${e.state} item - `,e),n(e.id,{status:0,state:a.aN.ABORTED,response:"aborted"}),!0),s={[a.aN.UPLOADING]:(e,t)=>(a.vF.debugLog("abort: aborting uploading item - ",e),t[e.id]()),[a.aN.ADDED]:o,[a.aN.PENDING]:o},i=(e,t,n)=>{const r=e?.state,a=!!r&&s[r];return!!a&&a(e,t,n)},d=(e,t,n,r)=>i(t[e],n,r),c=(e,t)=>{let n=!1;return 0!==t&&t&&(n=e>=t),n},l=(e,t,n,r,o)=>{const s=Object.values(n).flat(),i=c(s.length,o.fastAbortThreshold);return a.vF.debugLog(`abort: doing abort-all (${i?"fast":"normal"} abort)`),i?(e=>{Object.values(e).forEach((e=>e()))})(t):s.forEach((n=>d(n,e,t,r))),{isFast:i}},u=(e,t,n,r,o,s)=>{const d=0===t.fastAbortThreshold?0:t.fastAbortThreshold||s.fastAbortThreshold,l=c(r[e.id].length,d);return a.vF.debugLog(`abort: doing abort-batch on: ${e.id} (${l?"fast":"normal"} abort)`),l?((e,t)=>{e.items.forEach((({id:e})=>t[e]?.()))})(e,n):e.items.forEach((e=>i(e,n,o))),{isFast:l}},p=()=>e=>(e.update({abortAll:l,abortBatch:u,abortItem:d}),e),h=(0,a.fO)({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"}),b=(0,a.fO)({ITEM_PROGRESS:"ITEM_PROGRESS",BATCH_PROGRESS:"BATCH_PROGRESS"}),m=[a.aN.FINISHED,a.aN.ERROR,a.aN.CANCELLED,a.aN.ABORTED],f=Symbol.for("__rpldy-sstt-proxy__"),g=Symbol.for("__rpldy-sstt-state__"),E=e=>!(0,a.KV)()&&!!e&&!!~Object.getOwnPropertySymbols(e).indexOf(f),S=e=>Array.isArray(e)||(0,a.Qd)(e)&&!(e=>(0,a.Vd)()&&e instanceof File||e.name&&e.size&&e.uri)(e),y=(0,a.fd)({withSymbols:!0,predicate:e=>e!==f&&e!==g}),O=e=>!!(0,a.KV)()||e[g].isUpdateable,v=(e,t)=>{(0,a.KV)()||(e[g].isUpdateable=t)},A=(e,t)=>{let n;return S(e)&&(E(e)||(e[f]=!0,n=new Proxy(e,t)),Object.keys(e).forEach((n=>{e[n]=A(e[n],t)}))),n||e},R=e=>E(e)?(0,a.o8)(e,y):e,I=(e,t,n=!1)=>{e.updateState((e=>{const{batchId:r}=e.items[t]||{batchId:null};n&&delete e.items[t];const a=r?e.itemQueue[r].indexOf(t):-1;~a&&r&&e.itemQueue[r].splice(a,1);const o=e.activeIds.indexOf(t);~o&&e.activeIds.splice(o,1)}))},T=(e,t)=>!!e.getState().items[t],N=e=>m.includes(e.state),w=(0,a.fd)({undefinedOverwrites:!0}),D=(e,t,n,r,o,s)=>{const i=n(t),d=e.getState().batches[i[0].batchId].batchOptions,c=r?.(t,d)||t;return((e,t,n,r,o,s)=>(0,a.w$)(e.trigger,o,t,r).then((e=>(s?.(e),((e,t,n,r)=>{let o=n,s=t;if(r){if(a.vF.debugLog(`uploader.queue: REQUEST_PRE_SEND(${e}) event returned updated items/options`,r),r.items){if(r.items.length!==t.length||!(0,a.hR)(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&&(o=w({},n,r.options))}return{items:s,options:o,cancelled:!1===r}})(o,n,r,e)))))(e,c,i,d,s,o).then((t=>(t.cancelled||((e,t)=>{if(t.items[0]&&e.getState().batches[t.items[0].batchId]){e.updateState((e=>{t.items.forEach((t=>{N(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)))},P=(e,t,n=null,r=null)=>(a,o)=>D(a,o,t,n,r,e),_=P(h.BATCH_START,(e=>e.items),null,(({batch:e}={batch:!1})=>{if(e)throw new Error("BATCH_START event handlers cannot update batch data. Only items & options")})),C=[a.mX.ADDED,a.mX.PROCESSING,a.mX.UPLOADING],B=[a.mX.ABORTED,a.mX.CANCELLED,a.mX.FINISHED,a.mX.ERROR],L=(e,t)=>e.batches[t].batch,F=(e,t)=>{const n=e.getState(),r=n.items[t];return n.batches[r.batchId]},H=(e,t)=>F(e,t).batch,x=(e,t)=>{const n=((e,t)=>L(e.getState(),t))(e,t);n.items.forEach((({id:t})=>I(e,t,!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);const r=e.batchesStartPending.indexOf(t);~r&&e.batchesStartPending.splice(r,1)}))},U=(e,t,n,r=a.mX.FINISHED,o)=>{e.updateState((e=>{const n=L(e,t);n.state=r,o&&(n.additionalInfo=o)})),$(e,t,n),$(e,t,h.BATCH_FINALIZE)},G=(e,t)=>{a.vF.debugLog("uploady.uploader.batchHelpers: cancelling batch: ",t),U(e,t,h.BATCH_CANCEL,a.mX.CANCELLED),x(e,t),j(e,t)},$=(e,t,n)=>{const r=e.getState(),{batch:a,batchOptions:o}=r.batches[t],s=r.items,i={...R(a),items:a.items.map((({id:e})=>R(s[e])))};e.trigger(n,i,R(o))},Q=(e,t)=>{const n=L(e.getState(),t);return C.includes(n.state)},q=e=>B.includes(e.state),k={[a.aN.PENDING]:null,[a.aN.ADDED]:h.ITEM_START,[a.aN.FINISHED]:h.ITEM_FINISH,[a.aN.ERROR]:h.ITEM_ERROR,[a.aN.CANCELLED]:h.ITEM_CANCEL,[a.aN.ABORTED]:h.ITEM_ABORT,[a.aN.UPLOADING]:h.ITEM_PROGRESS},X=e=>!!~m.indexOf(e.state),M=(e,t,n)=>{t.forEach((t=>{const n=e.getState(),{id:r,info:o}=t;if(a.vF.debugLog("uploader.processor.queue: request finished for item - ",{id:r,info:o}),n.items[r]){e.updateState((e=>{const t=e.items[r];t.state=o.state,t.uploadResponse=o.response,t.uploadStatus=o.status,X(t)&&delete e.aborts[r]}));const t=e.getState().items[r];if(o.state===a.aN.FINISHED&&t.completed<100){const n=t.file?.size||0;e.handleItemProgress(t,100,n,n)}const{batchOptions:n}=F(e,r);k[t.state]&&e.trigger(k[t.state],t,n),X(t)&&(((e,t)=>{e.updateState((e=>{e.batches[t].finishedCounter+=1}))})(e,t.batchId),e.trigger(h.ITEM_FINALIZE,t,n))}I(e,r)})),(e=>{(0,a.tD)((()=>{const t=e.getState();Object.keys(t.batches).forEach((n=>{const{batch:r,finishedCounter:o}=t.batches[n],{orgItemCount:s}=r,i=q(r);s===o&&(i||100===r.completed||(e.updateState((e=>{const t=L(e,n);t.completed=100,t.loaded=t.items.reduce(((e,{loaded:t})=>e+t),0)})),$(e,n,h.BATCH_PROGRESS)),e.updateState((e=>{e.currentBatch===n&&(e.currentBatch=null)})),a.vF.debugLog(`uploady.uploader.batchHelpers: cleaning up batch: ${r.id}`),i||U(e,n,h.BATCH_FINISH),x(e,n),j(e,n))}))}))})(e),n(e)},V=P(h.REQUEST_PRE_SEND,(e=>e),((e,t)=>({items:e,options:t}))),K=({allowedItems:e,cancelledResults:t,queue:n,items:r,ids:o,next:s})=>{const i=e.length?V(n,e):Promise.resolve();let d=t;return i.catch((e=>{a.vF.debugLog("uploader.queue: encountered error while preparing items for request",e),((e,t,n,r)=>{const o=n.map((({id:t})=>({id:t,info:{status:0,state:a.aN.ERROR,response:e}})));M(t,o,r)})(e,n,r,s)})).then((e=>{let t;return e&&(e.cancelled?d=o.map((()=>!0)):e.items.some((e=>N(e)))?a.vF.debugLog("uploader.queue: send data contains aborted items - not sending"):((e,t,n)=>{const{items:r,options:o}=t,s=e.getState().batches[r[0].batchId]?.batch;if(s){let t;try{t=e.sender.send(r,s,o)}catch(e){a.vF.debugLog("uploader.queue: sender failed with unexpected error",e),t={request:Promise.resolve({status:0,state:a.aN.ERROR,response:e.message}),abort:()=>!1,senderType:"exception-handler"}}const{request:i}=t;((e,t,n)=>{e.updateState((e=>{t.forEach((t=>{e.items[t.id].state=a.aN.UPLOADING,e.aborts[t.id]=n.abort}))}))})(e,r,t),i.then((t=>{const a=r.map((e=>({id:e.id,info:t})));M(e,a,n)}))}})(n,{items:e.items,options:e.options},s)),((e,t,n,r)=>{const o=n.map(((e,n)=>e?t[n].id:null)).filter(Boolean);if(o.length){const t=o.map((e=>({id:e,info:{status:0,state:a.aN.CANCELLED,response:"cancel"}})));M(e,t,r)}return!!o.length})(n,r,d,s)||(t=s(n)),t}))},J=(e,t)=>e.getState().activeIds.flat().includes(t),z=e=>{let t;const n=(e=>{const t=e.getState(),n=t.itemQueue,[r,o]=(e=>{const t=e.getState(),n=t.itemQueue,r=t.items;let o=null,s=0,i=0,d=t.batchQueue[s];for(;d&&!o;){if(Q(e,d))for(o=n[d][i];o&&(J(e,o)||r[o].state!==a.aN.ADDED);)i+=1,o=n[d][i];o||(s+=1,d=t.batchQueue[s],i=0)}return o?[d,i]:null})(e)||[];let s,i=r&&~o?n[r][o]:null;if(i){const{batchOptions:e}=t.batches[r],n=e.maxGroupSize||0;s=e.grouped&&n>1?t.itemQueue[r].slice(o,o+n):[i]}return s})(e);if(n){const r=e.getCurrentActiveCount(),{concurrent:o=!1,maxConcurrent:s=0}=e.getOptions();(!r||o&&r<s)&&(a.vF.debugLog("uploader.processor: Processing next upload - ",{ids:n,currentCount:r}),t=((e,t)=>{let n;return((e,t)=>{const n=H(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=H(e,t);return e.getState().currentBatch!==n.id})(e,t[0])?((e,t)=>{const n=H(e,t);return e.updateState((e=>{e.batchesStartPending.push(n.id)})),_(e,n).then((({cancelled:r})=>{let a=!1;return e.updateState((e=>{const t=e.batchesStartPending.indexOf(n.id);e.batchesStartPending.splice(t,1)})),r||(a=!T(e,t),a||e.updateState((e=>{e.currentBatch=n.id}))),!r&&!a}))})(e,t[0]).then((n=>{let r=!n;return r&&(((e,t)=>{if(T(e,t)){const n=F(e,t),r=n?.batch.id;r?G(e,r):a.vF.debugLog(`uploady.uploader.batchHelpers: cancel batch called for batch already removed (item id = ${t})`)}})(e,t[0]),z(e)),r})).catch((n=>(a.vF.debugLog("uploader.processor: encountered error while preparing batch for request",n),((e,t,n)=>{const r=H(e,t),o=r.id;a.vF.debugLog("uploady.uploader.batchHelpers: failing batch: ",{batch:r}),U(e,o,h.BATCH_ERROR,a.mX.ERROR,n.message),x(e,o),j(e,o)})(e,t[0],n),z(e),!0))):Promise.resolve(!1)),n})(e,n).then((t=>{t||(((e,t,n)=>{const r=e.getState();let a=Object.values(r.items);a=a.filter((e=>t.includes(e.id)&&!N(e))),Promise.all(a.map((t=>{const{batchOptions:n}=F(e,t.id);return e.runCancellable(h.ITEM_START,t,n)}))).then((r=>{let o=r.map(((t,n)=>t?null:((e,t)=>{const n=t.getState().items[e];return n&&!N(n)?n:void 0})(a[n].id,e))).filter(Boolean);return{allowedItems:o,cancelledResults:r,queue:e,items:a,ids:t,next:n}})).then(K)})(e,n,z),o&&z(e))})))}return t},Y=z,Z=e=>(t,n)=>M(e,[{id:t,info:n}],Y),W=(e,t,n,r,o)=>{const{state:s,update:i}=(e=>{const t={set:(e,r,a)=>(O(n)&&(e[r]=A(a,t)),!0),get:(e,t)=>t===f?R(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)=>(O(n)&&delete e[t],!0)};(0,a.KV)()||E(e)||Object.defineProperty(e,g,{value:{isUpdateable:!1},configurable:!0});const n=(0,a.KV)()?e:A(e,t);return{state:n,update:e=>{if(!(0,a.KV)()&&O(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?R(e):E(n)?R(n):n}})({itemQueue:{},batchQueue:[],currentBatch:null,batchesStartPending:[],batches:{},items:{},activeIds:[],aborts:{}}),d=()=>s,c=e=>{i(e)},l=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}=H(e,t.id);r===n&&e.updateState((e=>{const n=L(e,r),a=n.items.findIndex((({id:e})=>e===t.id));~a&&n.items.splice(a,1)}))}})(p,e),c((t=>{t.items[e.id]=e}))},u=(e,n,r,a)=>{s.items[e.id]&&(c((t=>{const o=t.items[e.id];o.loaded=r,o.completed=n,o.total=a})),t(h.ITEM_PROGRESS,d().items[e.id]))};r.on(b.ITEM_PROGRESS,u),r.on(b.BATCH_PROGRESS,(e=>{const t=s.batches[e.id]?.batch.items;if(t){const[n,r]=t.reduce(((e,{id:t})=>{const{loaded:n,file:r}=s.items[t],a=r?.size||n||1;return e[0]+=n,e[1]+=a,e}),[0,0]);c((t=>{const a=t.batches[e.id].batch;a.total=r,a.loaded=n,a.completed=n/r})),$(p,e.id,h.BATCH_PROGRESS)}}));const p={uploaderId:o,getOptions:()=>e,getCurrentActiveCount:()=>s.activeIds.length,getState:d,updateState:c,trigger:t,runCancellable:(e,...t)=>{if(!(0,a.Tn)(n))throw new Error("Uploader queue - cancellable is of wrong type");return n(e,...t)},sender:r,handleItemProgress:u,clearAllUploads:()=>{p.updateState((e=>{e.itemQueue={},e.batchQueue=[],e.currentBatch=null,e.batches={},e.items={},e.activeIds=[]}))},clearBatchUploads:e=>{(0,a.tD)((()=>{a.vF.debugLog(`uploader.queue: started scheduled work to clear batch uploads (${e})`),d().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((({id:t})=>{delete e.items[t];const n=e.activeIds.indexOf(t);~n&&e.activeIds.splice(n,1)}))}))})(p,e)}))}};return(0,a.Vd)()&&a.vF.isDebugOn()&&(window[`__rpldy_${o}_queue_state`]=p),{updateState:c,getState:p.getState,runCancellable:p.runCancellable,uploadBatch:(e,t)=>{t&&c((n=>{n.batches[e.id].batchOptions=t})),Y(p)},addBatch:(e,t)=>(c((n=>{n.batches[e.id]={batch:e,batchOptions:t,finishedCounter:0},n.batchQueue.push(e.id),n.itemQueue[e.id]=e.items.map((({id:e})=>e))})),e.items.forEach(l),L(s,e.id)),abortItem:(...e)=>((e,t)=>{const n=e.getOptions().abortItem;(0,a.V1)(!!n,"Abort Item method not provided yet abortItem was called");const r=e.getState();return n(t,r.items,r.aborts,Z(e))})(p,...e),abortBatch:(...e)=>((e,t)=>{const n=e.getOptions().abortBatch;(0,a.V1)(!!n,"Abort Batch method not provided yet abortItem was called");const r=e.getState(),o=r.batches[t],s=o?.batch;if(s&&!q(s)){U(e,t,h.BATCH_ABORT,a.mX.ABORTED);const{isFast:i}=n(s,o.batchOptions,r.aborts,r.itemQueue,Z(e),e.getOptions());i&&e.clearBatchUploads(s.id)}})(p,...e),abortAll:(...e)=>(e=>{const t=e.getOptions().abortAll;(0,a.V1)(!!t,"Abort All method not provided yet abortAll was called"),e.trigger(h.ALL_ABORT);const n=e.getState(),{isFast:r}=t(n.items,n.aborts,n.itemQueue,Z(e),e.getOptions());r&&e.clearAllUploads()})(p,...e),clearPendingBatches:()=>{(e=>{const t=e.getState().batches;Object.keys(t).filter((e=>t[e].batch.state===a.mX.PENDING)).forEach((t=>{x(e,t),j(e,t)}))})(p)},uploadPendingBatches:e=>{((e,t)=>{e.updateState((e=>{Object.keys(e.batches).forEach((n=>{const r=e.batches[n],{batch:o,batchOptions:s}=r;o.state===a.mX.PENDING&&(o.items.forEach((e=>{e.state=a.aN.ADDED})),o.state=a.mX.ADDED,r.batchOptions=(0,a.h1)({},s,t))}))}))})(p,e),Y(p)},cancelBatch:e=>G(p,e.id)}};var ee=n("ySws");const te=()=>!0,ne=(0,a.fO)({autoUpload:!0,clearPendingOnAdd:!1,inputFieldName:"file",concurrent:!1,maxConcurrent:2,grouped:!1,maxGroupSize:5,method:"POST",params:{},fileFilter:te,forceJsonResponse:!1,withCredentials:!1,destination:{},send:null,sendWithFormData:!0,formDataAllowUndefined:!1,fastAbortThreshold:100}),re=()=>{const{trigger:e,target:t}=(0,r.Ay)({send:(t,n,r)=>{const o=r.destination,s=o?.url,i=(0,a.nF)((r=>((e,t,n,r)=>{((e,t,n,r,o)=>{e.forEach((e=>{a.vF.debugLog(`uploady.uploader.processor: file: ${e.id} progress event: loaded(${n}) - completed(${t})`),o(b.ITEM_PROGRESS,e,t,n,r)}))})(e,Math.min(n.loaded/n.total*100,100)/e.length,n.loaded/e.length,n.total,r),r(b.BATCH_PROGRESS,t)})(t,n,r,e)),50,!0);return((0,a.Tn)(r.send)?r.send:ee.Ay)(t,s,{method:o?.method||r.method||ne.method,paramName:o?.filesParamName||r.inputFieldName||"file",params:{...r.params,...o?.params},forceJsonResponse:r.forceJsonResponse,withCredentials:r.withCredentials,formatGroupParamName:r.formatGroupParamName,headers:o?.headers,sendWithFormData:r.sendWithFormData,formatServerResponse:r.formatServerResponse,formDataAllowUndefined:r.formDataAllowUndefined,isSuccessfulCall:r.isSuccessfulCall},i)}},Object.values(b));return t},ae=(0,a.Vd)()&&"FileList"in window,oe=(e,t=0)=>{let n=e;return(0,a.KV)()||(t<3&&E(e)?n=R(e):t<3&&S(e)&&(n=Array.isArray(e)?e.map((e=>oe(e,t+1))):Object.keys(e).reduce(((n,r)=>(n[r]=oe(e[r],t+1),n)),{}))),n};let se=0;const ie=(e,t,n,r)=>{const o=re(),s=W(n,e,t,o,r);return{abortBatch:e=>{s.abortBatch(e)},abort:e=>{e?s.abortItem(e):s.abortAll()},addNewBatch:(e,t)=>((e,t,n)=>{se+=1;const r=`batch-${se}`,o=(e=>ae&&e instanceof FileList||"[object FileList]"===e.toString())(e),s=Array.isArray(e)||o?e:[e],i=!n.autoUpload;return((e,t,n,r)=>{const o=r?Array.prototype.map.call(t,(e=>(0,a.Uk)(e)?e.file||e.url:e)):[];return Promise.all(Array.prototype.map.call(t,((e,t)=>{const n=(r||te)(o[t],t,o);return(0,a.yL)(n)?n.then((t=>!!t&&e)):!!n&&e}))).then((t=>t.filter(Boolean).map((t=>(0,a.UT)(t,e,n)))))})(r,s,i,n.fileFilter).then((e=>({id:r,uploaderId:t,items:e,state:i?a.mX.PENDING:a.mX.ADDED,completed:0,loaded:0,orgItemCount:e.length,additionalInfo:null})))})(e,r,t).then((e=>{let n;if(e.items.length){const o=s.addBatch(e,t);n=s.runCancellable(h.BATCH_ADD,o,t).then((e=>(e?s.cancelBatch(o):(a.vF.debugLog(`uploady.uploader [${r}]: new items added - auto upload =\n ${String(t.autoUpload)}`,o.items),t.autoUpload&&s.uploadBatch(o)),o)))}else a.vF.debugLog(`uploady.uploader: no items to add. batch ${e.id} is empty. check fileFilter if this isn't intended`);return n||Promise.resolve(null)})),clearPendingBatches:()=>{s.clearPendingBatches()},processPendingBatches:e=>{s.uploadPendingBatches(e)}}},de=(...e)=>(t,...n)=>e.reduce(((e,t)=>t(e,...n)||e),t),ce=Object.values(h);let le=0;const ue=e=>{le+=1;const t=`uploader-${le}`;let n=!1;const o={};a.vF.debugLog(`uploady.uploader: creating new instance (${t})`,{options:e,counter:le});let s=(e=>{return{...ne,...e,destination:e&&e.destination?(t=e.destination,{params:{},...t}):null};var t})(e);const i=()=>{b.clearPendingBatches()};let{trigger:d,target:c}=(0,r.Ay)({id:t,update:e=>(s=(0,a.h1)({},s,e),c),add:(e,t)=>{const n=(0,a.h1)({},s,t);return n.clearPendingOnAdd&&i(),b.addNewBatch(e,n).then((()=>{a.vF.debugLog("uploady.uploader: finished adding file data to be processed")}))},upload:e=>{b.processPendingBatches(e)},abort:e=>{b.abort(e)},abortBatch:e=>{b.abortBatch(e)},getOptions:()=>(0,a.o8)(s),clearPending:i,registerExtension:(e,t)=>{(0,a.V1)(n,"Uploady - uploader extensions can only be registered by enhancers"),(0,a.V1)(!o[e],"Uploady - uploader extension by this name [%s] already exists",e),a.vF.debugLog(`uploady.uploader: registering extension: ${e.toString()}`,t),o[e]=t},getExtension:e=>o[e]},ce,{canAddEvents:!1,canRemoveEvents:!1});const l=(e,...t)=>{const n=(0,r.yn)((()=>t.map(oe)));return d(e,n)},u=(0,a.x1)(l),h=((e,t,n,r)=>{const a=t.enhancer?(o=t.enhancer,de(p(),o)):p();var o;r(!0);const s=a(e,n);return r(!1),s||e})(c,s,l,(e=>{n=e})),b=ie(l,u,s,h.id);return(0,a.fO)(h)},pe=ue}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,r),o.exports}r.m=t,e=[],r.O=(t,n,a,o)=>{if(!n){var s=1/0;for(l=0;l<e.length;l++){for(var[n,a,o]=e[l],i=!0,d=0;d<n.length;d++)(!1&o||s>=o)&&Object.keys(r.O).every((e=>r.O[e](n[d])))?n.splice(d--,1):(i=!1,o<s&&(s=o));if(i){e.splice(l--,1);var c=a();void 0!==c&&(t=c)}}return t}o=o||0;for(var l=e.length;l>0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[n,a,o]},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.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={114:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,[s,i,d]=n,c=0;if(s.some((t=>0!==e[t]))){for(a in i)r.o(i,a)&&(r.m[a]=i[a]);if(d)var l=d(r)}for(t&&t(n);c<s.length;c++)o=s[c],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(l)},n=globalThis.webpackChunkrpldy=globalThis.webpackChunkrpldy||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.O(void 0,[461],(()=>r("VY1i"))),r.O(void 0,[461],(()=>r("k4c9"))),r.O(void 0,[461],(()=>r("ySws")));var a=r.O(void 0,[461],(()=>r("QBXY")));return r.O(a)})()));
!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={"g+8f":(e,t,n)=>{"use strict";n.d(t,{yn:()=>S,Ay:()=>E});var r=n("9Oim");const a=(0,r.fO)({allowRegisterNonExistent:!0,canAddEvents:!0,canRemoveEvents:!0,collectStats:!1}),o=Symbol.for("__le__"),s=Symbol.for("__le__pack__"),i=e=>e?e[o]:null,d=e=>{const t=i(e);if(!t)throw new Error("Didnt find LE internal object. Something very bad happened!");return t},c=(e,t,n,a=!1)=>{((e,t)=>{if(!(0,r.Tn)(e))throw new Error("'cb' is not a valid function")})(n);const o=d(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:a}),o.registry[t]=s),()=>f.call(e,t,n)},l=(e,t)=>{const n=d(e).registry;return t?n[t]?n[t].slice():[]:Object.values(n).flat()},u={on:function(e,t){return c(this,e,t)},once:function(e,t){return c(this,e,t,!0)},off:f,getEvents:function(){return d(this).events.slice()}},p={trigger:function(e,...t){const n=l(this,e);let a;if(n.length){let o;1===t.length&&!0===t[0]?.[s]&&(o=t[0].resolve()),a=n.map((n=>{let r;return n.once&&m(this,e,n.cb),r=o?n.cb(...o):t.length?1===t.length?n.cb(t[0]):2===t.length?n.cb(t[0],t[1]):3===t.length?n.cb(t[0],t[1],t[2]):n.cb(...t):n.cb(),r})).filter((e=>!(void 0===e))).map((e=>(0,r.yL)(e)?e:Promise.resolve(e)))}return a&&(a.length?a:void 0)},addEvent:function(e){const t=d(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=d(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!!~d(this).events.indexOf(e)},hasEventRegistrations:function(e){return!!l(this,e).length},assign:function(e){const t=d(this);return g(e,t.options,t.events,t.registry,t.stats),h(e)}},h=e=>Object.keys(p).reduce(((t,n)=>(t[n]=p[n].bind(e),t)),{target:e,...p}),b=(e,t,n=!1)=>{const r=d(e).registry;!r[t]||!n&&r[t].length||delete r[t]},m=(e,t,n)=>{const r=d(e).registry;r[t]&&(n?(r[t]=r[t].filter((e=>e.cb!==n)),b(e,t)):b(e,t,!0))};function f(e,t){m(this,e,t)}const g=(e,t,n=[],r={},a={})=>{Object.defineProperties(e,{[o]:{value:Object.seal({registry:r,events:n,options:t,stats:a})},...Object.entries(u).reduce(((e,[t,n])=>(e[t]={value:n},e)),{})})},E=(e,t=[],n)=>{const r=e||{},o={...a,...n};return i(r)||g(r,o,t),h(r)},S=e=>{const t={resolve:()=>[].concat(e())};return Object.defineProperty(t,s,{value:!0,configurable:!1}),t}},UjVA:(e,t,n)=>{"use strict";n.d(t,{wc:()=>o,cp:()=>a,Ay:()=>h,DH:()=>u,tN:()=>p});var r=n("9Oim");const a="rpldy-sender";class o extends Error{constructor(e){super(`${e} didn't receive upload URL`),this.name="MissingUrlError"}}const s=(e,t,...n)=>{"set"in e?e.set(t,...n):("delete"in e&&e.delete(t),e.append(t,...n))},i=[200,201,202,203,204],d=(e,t,n,a,o)=>{let i;const d=o?.getRequestData?o.getRequestData(e,n):((e,t)=>{let n;if(t.sendWithFormData)r.vF.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,r])=>{(t.formDataAllowUndefined||void 0!==r)&&s(n,e,r)})),((e,t,n)=>{const a=1===t.length;t.forEach(((t,o)=>{const i=a?n.paramName:(0,r.Tn)(n.formatGroupParamName)?n.formatGroupParamName(o,n.paramName):`${n.paramName}[${o}]`;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.vF.debugLog(`uploady.sender: sending item ${t.id} as request body`),n=t.file||t.url}return n})(e,n),c=(o=t,s=d,c)=>{const l=(0,r.h1)({...(0,r.Up)(n,["method","headers","withCredentials"]),preSend:t=>{t.upload.onprogress=t=>{t.lengthComputable&&a&&a(t,e.slice())}}},c),u=(0,r.Em)(o,s,l);return i=u.xhr,u},l=o?.preRequestHandler?o.preRequestHandler(c,e,t,n,a,o):c();return{url:t,count:e.length,pXhr:l,getXhr:()=>i,aborted:!1}},c=(e,t,n)=>{let r=e;const a=t?.["content-type"];if(n.forceJsonResponse||a?.includes("json"))try{r=JSON.parse(e)}catch{}return r},l=(e,t)=>e.pXhr.then((e=>(r.vF.debugLog("uploady.sender: received upload response ",e),((e,t)=>{const n=t.isSuccessfulCall?t.isSuccessfulCall(e):i.includes(e.status);return(0,r.yL)(n)?n:Promise.resolve(n)})(e,t).then((n=>{const a=n?r.aN.FINISHED:r.aN.ERROR,o=e.status,s=(0,r.tn)(e);return{status:o,state:a,response:{data:t.formatServerResponse?.(e.response,o,s)??c(e.response,s,t),headers:s}}}))))).catch((t=>{let n,a;return e.aborted?(n=r.aN.ABORTED,a="aborted"):(r.vF.debugLog("uploady.sender: upload failed: ",t),n=r.aN.ERROR,a=t),{error:!0,state:n,response:a,status:0}})),u=e=>(t,n,s,i)=>{if(!n)throw new o(a);r.vF.debugLog("uploady.sender: sending file: ",{items:t,url:n,options:s});const c=d(t,n,s,i,e);return{request:l(c,s),abort:()=>(e=>{let t=!1;const{aborted:n,getXhr:a}=e,o=a();return!n&&o&&o.readyState&&4!==o.readyState&&(r.vF.debugLog(`uploady.sender: cancelling request with ${e.count} items to: ${e.url}`),o.abort(),e.aborted=!0,t=!0),t})(c),senderType:a}},p=u(),h=p},"9Oim":(e,t,n)=>{"use strict";n.d(t,{mX:()=>d,aN:()=>c,o8:()=>T,UT:()=>j,fO:()=>v,Uk:()=>x,fd:()=>R,Vd:()=>l,V1:()=>o(),Tn:()=>g(),Qd:()=>y,KV:()=>O(),yL:()=>w,hR:()=>E,vF:()=>r,h1:()=>I,tn:()=>G,Up:()=>N,Em:()=>$,tD:()=>C,nF:()=>s.A,x1:()=>m,w$:()=>L});var r={};n.r(r),n.d(r,{debugLog:()=>b,isDebugOn:()=>p,setDebug:()=>h});var a=n("3lvE"),o=n.n(a),s=n("6dsl");const i="__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"},l=()=>"object"==typeof window&&!!window.document;let u=null;const p=()=>("boolean"!=typeof u&&(u=l()&&("location"in window&&!!~window.location.search.indexOf("rpldy_debug=true")||!0===window[i])),!!u),h=e=>{l()&&(window[i]=e),u=!!e||null},b=(...e)=>{p()&&console.log(...e)},m=(e,t,...n)=>{const r=(t,...n)=>new Promise(((r,a)=>{const o=e(t,...n);o&&o.length?Promise.all(o).catch(a).then((e=>e&&r(!!~e.findIndex((e=>!1===e))))):r(!1)}));return t?r(t,...n):r};var f=n("117w"),g=n.n(f);const E=(e,t,n)=>{let r=!0;const a=(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=a(e),o=a(t);r=!!n.find(((e,t)=>e!==o[t]))}return!r};var S=n("BZmj"),O=n.n(S);const v=e=>O()()?e:Object.freeze(e),y=e=>!!e&&"object"==typeof e&&("Object"===Object.getPrototypeOf(e)?.constructor.name||null===Object.getPrototypeOf(e)),A=e=>y(e)||Array.isArray(e),R=(e={})=>{const t=(n,...r)=>(n&&r.length&&r.forEach((r=>{r&&((e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n})(r,e).forEach((a=>{const o=r[a];e.predicate&&!e.predicate(a,o)||(void 0!==o||e.undefinedOverwrites)&&(A(o)?(void 0!==n[a]&&y(n[a])||(n[a]=Array.isArray(o)?[]:{}),t(n[a],o)):n[a]=o)}))})),n);return t},I=R(),T=(e,t=I)=>A(e)?t(Array.isArray(e)?[]:{},e):e,N=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),w=function(e){return!!e&&"object"==typeof e&&"function"==typeof e.then},D=l()&&window.requestIdleCallback,P=D?window.requestIdleCallback:setTimeout,_=D?window.cancelIdleCallback:clearTimeout,C=(e,t=0)=>{const n=P(e,D?{timeout:t}:t);return()=>_(n)},B=function(e){return null==e},L=(e,t,...n)=>{const r=(t,...n)=>new Promise(((r,a)=>{const o=e(t,...n);o&&o.length?Promise.all(o).catch(a).then((e=>{let t;if(e)for(;B(t)&&e.length;)t=e.pop();r(B(t)?void 0:t)})):r()}));return t?r(t,...n):r},F=Symbol.for("__rpldy-bi__");let H=0;const x=e=>!("object"!=typeof e||!e.id||!e.batchId||!0!==e[F]),j=(e,t,n=!1)=>{const r=x(e);H+=r?0:1;let a={id:r&&e.id&&"string"==typeof e.id?e.id:`${t}.item-${H}`,batchId:t,state:n?c.PENDING:c.ADDED,uploadStatus:0,total:0,completed:0,loaded:0,recycled:r,previousBatch:r?e.batchId:null};Object.defineProperty(a,F,{value:!0,writable:!0});const o=r?e.file||e.url:e;if("string"==typeof o)a=((e,t)=>(e.url=t,e))(a,o);else{if(!(e=>e&&(e instanceof File||e instanceof Blob||!("object"!=typeof e||!e.name||!e.type)))(o))throw new Error("Unknown type of file added: "+typeof o);a=((e,t)=>(e.file=t,e))(a,o)}return a},U=class extends Promise{constructor(e,t){super(e),this.xhr=t}},G=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){b("uploady.request: failed to read response headers",e)}return t},$=(e,t,n={})=>{const r=new XMLHttpRequest;return new U(((a,o)=>{r.onerror=()=>o(r),r.ontimeout=()=>o(r),r.onabort=()=>o(r),r.onload=()=>a(r),r.open(n?.method||"GET",e),((e,t)=>{t&&Object.keys(t).forEach((n=>{void 0!==t[n]&&e.setRequestHeader(n,t[n])}))})(r,n?.headers),r.withCredentials=!!n?.withCredentials,n?.preSend?.(r),r.send(t)}),r)}},"117w":e=>{e.exports=function(e){return"function"==typeof e}},BZmj:e=>{e.exports=function(){return!0}},vVPY:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BATCH_STATES:()=>a.mX,DEFAULT_OPTIONS:()=>ne,FILE_STATES:()=>a.aN,MissingUrlError:()=>ee.wc,UPLOADER_EVENTS:()=>h,XHR_SENDER_TYPE:()=>ee.cp,composeEnhancers:()=>de,createUploader:()=>ue,default:()=>pe,getXhrSend:()=>ee.DH,send:()=>ee.tN});var r=n("g+8f"),a=n("9Oim");const o=(e,t,n)=>(a.vF.debugLog(`abort: aborting ${e.state} item - `,e),n(e.id,{status:0,state:a.aN.ABORTED,response:"aborted"}),!0),s={[a.aN.UPLOADING]:(e,t)=>(a.vF.debugLog("abort: aborting uploading item - ",e),t[e.id]()),[a.aN.ADDED]:o,[a.aN.PENDING]:o},i=(e,t,n)=>{const r=e?.state,a=!!r&&s[r];return!!a&&a(e,t,n)},d=(e,t,n,r)=>i(t[e],n,r),c=(e,t)=>{let n=!1;return 0!==t&&t&&(n=e>=t),n},l=(e,t,n,r,o)=>{const s=Object.values(n).flat(),i=c(s.length,o.fastAbortThreshold);return a.vF.debugLog(`abort: doing abort-all (${i?"fast":"normal"} abort)`),i?(e=>{Object.values(e).forEach((e=>e()))})(t):s.forEach((n=>d(n,e,t,r))),{isFast:i}},u=(e,t,n,r,o,s)=>{const d=0===t.fastAbortThreshold?0:t.fastAbortThreshold||s.fastAbortThreshold,l=c(r[e.id].length,d);return a.vF.debugLog(`abort: doing abort-batch on: ${e.id} (${l?"fast":"normal"} abort)`),l?((e,t)=>{e.items.forEach((({id:e})=>t[e]?.()))})(e,n):e.items.forEach((e=>i(e,n,o))),{isFast:l}},p=()=>e=>(e.update({abortAll:l,abortBatch:u,abortItem:d}),e),h=(0,a.fO)({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"}),b=(0,a.fO)({ITEM_PROGRESS:"ITEM_PROGRESS",BATCH_PROGRESS:"BATCH_PROGRESS"}),m=[a.aN.FINISHED,a.aN.ERROR,a.aN.CANCELLED,a.aN.ABORTED],f=Symbol.for("__rpldy-sstt-proxy__"),g=Symbol.for("__rpldy-sstt-state__"),E=e=>!(0,a.KV)()&&!!e&&!!~Object.getOwnPropertySymbols(e).indexOf(f),S=e=>Array.isArray(e)||(0,a.Qd)(e)&&!(e=>(0,a.Vd)()&&e instanceof File||e.name&&e.size&&e.uri)(e),O=(0,a.fd)({withSymbols:!0,predicate:e=>e!==f&&e!==g}),v=e=>!!(0,a.KV)()||e[g].isUpdateable,y=(e,t)=>{(0,a.KV)()||(e[g].isUpdateable=t)},A=(e,t)=>{let n;return S(e)&&(E(e)||(e[f]=!0,n=new Proxy(e,t)),Object.keys(e).forEach((n=>{e[n]=A(e[n],t)}))),n||e},R=e=>E(e)?(0,a.o8)(e,O):e,I=(e,t,n=!1)=>{e.updateState((e=>{const{batchId:r}=e.items[t]||{batchId:null};n&&delete e.items[t];const a=r?e.itemQueue[r].indexOf(t):-1;~a&&r&&e.itemQueue[r].splice(a,1);const o=e.activeIds.indexOf(t);~o&&e.activeIds.splice(o,1)}))},T=(e,t)=>!!e.getState().items[t],N=e=>m.includes(e.state),w=(0,a.fd)({undefinedOverwrites:!0}),D=(e,t,n,r,o,s)=>{const i=n(t),d=e.getState().batches[i[0].batchId].batchOptions,c=r?.(t,d)||t;return((e,t,n,r,o,s)=>(0,a.w$)(e.trigger,o,t,r).then((e=>(s?.(e),((e,t,n,r)=>{let o=n,s=t;if(r){if(a.vF.debugLog(`uploader.queue: REQUEST_PRE_SEND(${e}) event returned updated items/options`,r),r.items){if(r.items.length!==t.length||!(0,a.hR)(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&&(o=w({},n,r.options))}return{items:s,options:o,cancelled:!1===r}})(o,n,r,e)))))(e,c,i,d,s,o).then((t=>(t.cancelled||((e,t)=>{if(t.items[0]&&e.getState().batches[t.items[0].batchId]){e.updateState((e=>{t.items.forEach((t=>{N(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)))},P=(e,t,n=null,r=null)=>(a,o)=>D(a,o,t,n,r,e),_=P(h.BATCH_START,(e=>e.items),null,(({batch:e}={batch:!1})=>{if(e)throw new Error("BATCH_START event handlers cannot update batch data. Only items & options")})),C=[a.mX.ADDED,a.mX.PROCESSING,a.mX.UPLOADING],B=[a.mX.ABORTED,a.mX.CANCELLED,a.mX.FINISHED,a.mX.ERROR],L=(e,t)=>e.batches[t].batch,F=(e,t)=>{const n=e.getState(),r=n.items[t];return n.batches[r.batchId]},H=(e,t)=>F(e,t).batch,x=(e,t)=>{const n=((e,t)=>L(e.getState(),t))(e,t);n.items.forEach((({id:t})=>I(e,t,!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);const r=e.batchesStartPending.indexOf(t);~r&&e.batchesStartPending.splice(r,1)}))},U=(e,t,n,r=a.mX.FINISHED,o)=>{e.updateState((e=>{const n=L(e,t);n.state=r,o&&(n.additionalInfo=o)})),$(e,t,n),$(e,t,h.BATCH_FINALIZE)},G=(e,t)=>{a.vF.debugLog("uploady.uploader.batchHelpers: cancelling batch: ",t),U(e,t,h.BATCH_CANCEL,a.mX.CANCELLED),x(e,t),j(e,t)},$=(e,t,n)=>{const r=e.getState(),{batch:a,batchOptions:o}=r.batches[t],s=r.items,i={...R(a),items:a.items.map((({id:e})=>R(s[e])))};e.trigger(n,i,R(o))},q=(e,t)=>{const n=L(e.getState(),t);return C.includes(n.state)},Q=e=>B.includes(e.state),M={[a.aN.PENDING]:null,[a.aN.ADDED]:h.ITEM_START,[a.aN.FINISHED]:h.ITEM_FINISH,[a.aN.ERROR]:h.ITEM_ERROR,[a.aN.CANCELLED]:h.ITEM_CANCEL,[a.aN.ABORTED]:h.ITEM_ABORT,[a.aN.UPLOADING]:h.ITEM_PROGRESS},X=e=>!!~m.indexOf(e.state),V=(e,t,n)=>{t.forEach((t=>{const n=e.getState(),{id:r,info:o}=t;if(a.vF.debugLog("uploader.processor.queue: request finished for item - ",{id:r,info:o}),n.items[r]){e.updateState((e=>{const t=e.items[r];t.state=o.state,t.uploadResponse=o.response,t.uploadStatus=o.status,X(t)&&delete e.aborts[r]}));const t=e.getState().items[r];if(o.state===a.aN.FINISHED&&t.completed<100){const n=t.file?.size||0;e.handleItemProgress(t,100,n,n)}const{batchOptions:n}=F(e,r);M[t.state]&&e.trigger(M[t.state],t,n),X(t)&&(((e,t)=>{e.updateState((e=>{e.batches[t].finishedCounter+=1}))})(e,t.batchId),e.trigger(h.ITEM_FINALIZE,t,n))}I(e,r)})),(e=>{(0,a.tD)((()=>{const t=e.getState();Object.keys(t.batches).forEach((n=>{const{batch:r,finishedCounter:o}=t.batches[n],{orgItemCount:s}=r,i=Q(r);s===o&&(i||100===r.completed||(e.updateState((e=>{const t=L(e,n);t.completed=100,t.loaded=t.items.reduce(((e,{loaded:t})=>e+t),0)})),$(e,n,h.BATCH_PROGRESS)),e.updateState((e=>{e.currentBatch===n&&(e.currentBatch=null)})),a.vF.debugLog(`uploady.uploader.batchHelpers: cleaning up batch: ${r.id}`),i||U(e,n,h.BATCH_FINISH),x(e,n),j(e,n))}))}))})(e),n(e)},k=P(h.REQUEST_PRE_SEND,(e=>e),((e,t)=>({items:e,options:t}))),K=({allowedItems:e,cancelledResults:t,queue:n,items:r,ids:o,next:s})=>{const i=e.length?k(n,e):Promise.resolve();let d=t;return i.catch((e=>{a.vF.debugLog("uploader.queue: encountered error while preparing items for request",e),((e,t,n,r)=>{const o=n.map((({id:t})=>({id:t,info:{status:0,state:a.aN.ERROR,response:e}})));V(t,o,r)})(e,n,r,s)})).then((e=>{let t;return e&&(e.cancelled?d=o.map((()=>!0)):e.items.some((e=>N(e)))?a.vF.debugLog("uploader.queue: send data contains aborted items - not sending"):((e,t,n)=>{const{items:r,options:o}=t,s=e.getState().batches[r[0].batchId]?.batch;if(s){let t;try{t=e.sender.send(r,s,o)}catch(e){a.vF.debugLog("uploader.queue: sender failed with unexpected error",e),t={request:Promise.resolve({status:0,state:a.aN.ERROR,response:e.message}),abort:()=>!1,senderType:"exception-handler"}}const{request:i}=t;((e,t,n)=>{e.updateState((e=>{t.forEach((t=>{e.items[t.id].state=a.aN.UPLOADING,e.aborts[t.id]=n.abort}))}))})(e,r,t),i.then((t=>{const a=r.map((e=>({id:e.id,info:t})));V(e,a,n)}))}})(n,{items:e.items,options:e.options},s)),((e,t,n,r)=>{const o=n.map(((e,n)=>e?t[n].id:null)).filter(Boolean);if(o.length){const t=o.map((e=>({id:e,info:{status:0,state:a.aN.CANCELLED,response:"cancel"}})));V(e,t,r)}return!!o.length})(n,r,d,s)||(t=s(n)),t}))},Z=(e,t)=>e.getState().activeIds.flat().includes(t),z=e=>{let t;const n=(e=>{const t=e.getState(),n=t.itemQueue,[r,o]=(e=>{const t=e.getState(),n=t.itemQueue,r=t.items;let o=null,s=0,i=0,d=t.batchQueue[s];for(;d&&!o;){if(q(e,d))for(o=n[d][i];o&&(Z(e,o)||r[o].state!==a.aN.ADDED);)i+=1,o=n[d][i];o||(s+=1,d=t.batchQueue[s],i=0)}return o?[d,i]:null})(e)||[];let s,i=r&&~o?n[r][o]:null;if(i){const{batchOptions:e}=t.batches[r],n=e.maxGroupSize||0;s=e.grouped&&n>1?t.itemQueue[r].slice(o,o+n):[i]}return s})(e);if(n){const r=e.getCurrentActiveCount(),{concurrent:o=!1,maxConcurrent:s=0}=e.getOptions();(!r||o&&r<s)&&(a.vF.debugLog("uploader.processor: Processing next upload - ",{ids:n,currentCount:r}),t=((e,t)=>{let n;return((e,t)=>{const n=H(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=H(e,t);return e.getState().currentBatch!==n.id})(e,t[0])?((e,t)=>{const n=H(e,t);return e.updateState((e=>{e.batchesStartPending.push(n.id)})),_(e,n).then((({cancelled:r})=>{let a=!1;return e.updateState((e=>{const t=e.batchesStartPending.indexOf(n.id);e.batchesStartPending.splice(t,1)})),r||(a=!T(e,t),a||e.updateState((e=>{e.currentBatch=n.id}))),!r&&!a}))})(e,t[0]).then((n=>{let r=!n;return r&&(((e,t)=>{if(T(e,t)){const n=F(e,t),r=n?.batch.id;r?G(e,r):a.vF.debugLog(`uploady.uploader.batchHelpers: cancel batch called for batch already removed (item id = ${t})`)}})(e,t[0]),z(e)),r})).catch((n=>(a.vF.debugLog("uploader.processor: encountered error while preparing batch for request",n),((e,t,n)=>{const r=H(e,t),o=r.id;a.vF.debugLog("uploady.uploader.batchHelpers: failing batch: ",{batch:r}),U(e,o,h.BATCH_ERROR,a.mX.ERROR,n.message),x(e,o),j(e,o)})(e,t[0],n),z(e),!0))):Promise.resolve(!1)),n})(e,n).then((t=>{t||(((e,t,n)=>{const r=e.getState();let a=Object.values(r.items);a=a.filter((e=>t.includes(e.id)&&!N(e))),Promise.all(a.map((t=>{const{batchOptions:n}=F(e,t.id);return e.runCancellable(h.ITEM_START,t,n)}))).then((r=>{let o=r.map(((t,n)=>t?null:((e,t)=>{const n=t.getState().items[e];return n&&!N(n)?n:void 0})(a[n].id,e))).filter(Boolean);return{allowedItems:o,cancelledResults:r,queue:e,items:a,ids:t,next:n}})).then(K)})(e,n,z),o&&z(e))})))}return t},J=z,W=e=>(t,n)=>V(e,[{id:t,info:n}],J),Y=(e,t,n,r,o)=>{const{state:s,update:i}=(e=>{const t={set:(e,r,a)=>(v(n)&&(e[r]=A(a,t)),!0),get:(e,t)=>t===f?R(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)=>(v(n)&&delete e[t],!0)};(0,a.KV)()||E(e)||Object.defineProperty(e,g,{value:{isUpdateable:!1},configurable:!0});const n=(0,a.KV)()?e:A(e,t);return{state:n,update:e=>{if(!(0,a.KV)()&&v(n))throw new Error("Can't call update on State already being updated!");try{y(n,!0),e(n)}finally{y(n,!1)}return n},unwrap:e=>e?R(e):E(n)?R(n):n}})({itemQueue:{},batchQueue:[],currentBatch:null,batchesStartPending:[],batches:{},items:{},activeIds:[],aborts:{}}),d=()=>s,c=e=>{i(e)},l=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}=H(e,t.id);r===n&&e.updateState((e=>{const n=L(e,r),a=n.items.findIndex((({id:e})=>e===t.id));~a&&n.items.splice(a,1)}))}})(p,e),c((t=>{t.items[e.id]=e}))},u=(e,n,r,a)=>{s.items[e.id]&&(c((t=>{const o=t.items[e.id];o.loaded=r,o.completed=n,o.total=a})),t(h.ITEM_PROGRESS,d().items[e.id]))};r.on(b.ITEM_PROGRESS,u),r.on(b.BATCH_PROGRESS,(e=>{const t=s.batches[e.id]?.batch.items;if(t){const[n,r]=t.reduce(((e,{id:t})=>{const{loaded:n,file:r}=s.items[t],a=r?.size||n||1;return e[0]+=n,e[1]+=a,e}),[0,0]);c((t=>{const a=t.batches[e.id].batch;a.total=r,a.loaded=n,a.completed=n/r})),$(p,e.id,h.BATCH_PROGRESS)}}));const p={uploaderId:o,getOptions:()=>e,getCurrentActiveCount:()=>s.activeIds.length,getState:d,updateState:c,trigger:t,runCancellable:(e,...t)=>{if(!(0,a.Tn)(n))throw new Error("Uploader queue - cancellable is of wrong type");return n(e,...t)},sender:r,handleItemProgress:u,clearAllUploads:()=>{p.updateState((e=>{e.itemQueue={},e.batchQueue=[],e.currentBatch=null,e.batches={},e.items={},e.activeIds=[]}))},clearBatchUploads:e=>{(0,a.tD)((()=>{a.vF.debugLog(`uploader.queue: started scheduled work to clear batch uploads (${e})`),d().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((({id:t})=>{delete e.items[t];const n=e.activeIds.indexOf(t);~n&&e.activeIds.splice(n,1)}))}))})(p,e)}))}};return(0,a.Vd)()&&a.vF.isDebugOn()&&(window[`__rpldy_${o}_queue_state`]=p),{updateState:c,getState:p.getState,runCancellable:p.runCancellable,uploadBatch:(e,t)=>{t&&c((n=>{n.batches[e.id].batchOptions=t})),J(p)},addBatch:(e,t)=>(c((n=>{n.batches[e.id]={batch:e,batchOptions:t,finishedCounter:0},n.batchQueue.push(e.id),n.itemQueue[e.id]=e.items.map((({id:e})=>e))})),e.items.forEach(l),L(s,e.id)),abortItem:(...e)=>((e,t)=>{const n=e.getOptions().abortItem;(0,a.V1)(!!n,"Abort Item method not provided yet abortItem was called");const r=e.getState();return n(t,r.items,r.aborts,W(e))})(p,...e),abortBatch:(...e)=>((e,t)=>{const n=e.getOptions().abortBatch;(0,a.V1)(!!n,"Abort Batch method not provided yet abortItem was called");const r=e.getState(),o=r.batches[t],s=o?.batch;if(s&&!Q(s)){U(e,t,h.BATCH_ABORT,a.mX.ABORTED);const{isFast:i}=n(s,o.batchOptions,r.aborts,r.itemQueue,W(e),e.getOptions());i&&e.clearBatchUploads(s.id)}})(p,...e),abortAll:(...e)=>(e=>{const t=e.getOptions().abortAll;(0,a.V1)(!!t,"Abort All method not provided yet abortAll was called"),e.trigger(h.ALL_ABORT);const n=e.getState(),{isFast:r}=t(n.items,n.aborts,n.itemQueue,W(e),e.getOptions());r&&e.clearAllUploads()})(p,...e),clearPendingBatches:()=>{(e=>{const t=e.getState().batches;Object.keys(t).filter((e=>t[e].batch.state===a.mX.PENDING)).forEach((t=>{x(e,t),j(e,t)}))})(p)},uploadPendingBatches:e=>{((e,t)=>{e.updateState((e=>{Object.keys(e.batches).forEach((n=>{const r=e.batches[n],{batch:o,batchOptions:s}=r;o.state===a.mX.PENDING&&(o.items.forEach((e=>{e.state=a.aN.ADDED})),o.state=a.mX.ADDED,r.batchOptions=(0,a.h1)({},s,t))}))}))})(p,e),J(p)},cancelBatch:e=>G(p,e.id)}};var ee=n("UjVA");const te=()=>!0,ne=(0,a.fO)({autoUpload:!0,clearPendingOnAdd:!1,inputFieldName:"file",concurrent:!1,maxConcurrent:2,grouped:!1,maxGroupSize:5,method:"POST",params:{},fileFilter:te,forceJsonResponse:!1,withCredentials:!1,destination:{},send:null,sendWithFormData:!0,formDataAllowUndefined:!1,fastAbortThreshold:100}),re=()=>{const{trigger:e,target:t}=(0,r.Ay)({send:(t,n,r)=>{const o=r.destination,s=o?.url,i=(0,a.nF)((r=>((e,t,n,r)=>{((e,t,n,r,o)=>{e.forEach((e=>{a.vF.debugLog(`uploady.uploader.processor: file: ${e.id} progress event: loaded(${n}) - completed(${t})`),o(b.ITEM_PROGRESS,e,t,n,r)}))})(e,Math.min(n.loaded/n.total*100,100)/e.length,n.loaded/e.length,n.total,r),r(b.BATCH_PROGRESS,t)})(t,n,r,e)),50,!0);return((0,a.Tn)(r.send)?r.send:ee.Ay)(t,s,{method:o?.method||r.method||ne.method,paramName:o?.filesParamName||r.inputFieldName||"file",params:{...r.params,...o?.params},forceJsonResponse:r.forceJsonResponse,withCredentials:r.withCredentials,formatGroupParamName:r.formatGroupParamName,headers:o?.headers,sendWithFormData:r.sendWithFormData,formatServerResponse:r.formatServerResponse,formDataAllowUndefined:r.formDataAllowUndefined,isSuccessfulCall:r.isSuccessfulCall},i)}},Object.values(b));return t},ae=(0,a.Vd)()&&"FileList"in window,oe=(e,t=0)=>{let n=e;return(0,a.KV)()||(t<3&&E(e)?n=R(e):t<3&&S(e)&&(n=Array.isArray(e)?e.map((e=>oe(e,t+1))):Object.keys(e).reduce(((n,r)=>(n[r]=oe(e[r],t+1),n)),{}))),n};let se=0;const ie=(e,t,n,r)=>{const o=re(),s=Y(n,e,t,o,r);return{abortBatch:e=>{s.abortBatch(e)},abort:e=>{e?s.abortItem(e):s.abortAll()},addNewBatch:(e,t)=>((e,t,n)=>{se+=1;const r=`batch-${se}`,o=(e=>ae&&e instanceof FileList||"[object FileList]"===e.toString())(e),s=Array.isArray(e)||o?e:[e],i=!n.autoUpload;return((e,t,n,r)=>{const o=r?Array.prototype.map.call(t,(e=>(0,a.Uk)(e)?e.file||e.url:e)):[];return Promise.all(Array.prototype.map.call(t,((e,t)=>{const n=(r||te)(o[t],t,o);return(0,a.yL)(n)?n.then((t=>!!t&&e)):!!n&&e}))).then((t=>t.filter(Boolean).map((t=>(0,a.UT)(t,e,n)))))})(r,s,i,n.fileFilter).then((e=>({id:r,uploaderId:t,items:e,state:i?a.mX.PENDING:a.mX.ADDED,completed:0,loaded:0,orgItemCount:e.length,additionalInfo:null})))})(e,r,t).then((e=>{let n;if(e.items.length){const o=s.addBatch(e,t);n=s.runCancellable(h.BATCH_ADD,o,t).then((e=>(e?s.cancelBatch(o):(a.vF.debugLog(`uploady.uploader [${r}]: new items added - auto upload =\n ${String(t.autoUpload)}`,o.items),t.autoUpload&&s.uploadBatch(o)),o)))}else a.vF.debugLog(`uploady.uploader: no items to add. batch ${e.id} is empty. check fileFilter if this isn't intended`);return n||Promise.resolve(null)})),clearPendingBatches:()=>{s.clearPendingBatches()},processPendingBatches:e=>{s.uploadPendingBatches(e)}}},de=(...e)=>(t,...n)=>e.reduce(((e,t)=>t(e,...n)||e),t),ce=Object.values(h);let le=0;const ue=e=>{le+=1;const t=`uploader-${le}`;let n=!1;const o={};a.vF.debugLog(`uploady.uploader: creating new instance (${t})`,{options:e,counter:le});let s=(e=>{return{...ne,...e,destination:e&&e.destination?(t=e.destination,{params:{},...t}):null};var t})(e);const i=()=>{b.clearPendingBatches()};let{trigger:d,target:c}=(0,r.Ay)({id:t,update:e=>(s=(0,a.h1)({},s,e),c),add:(e,t)=>{const n=(0,a.h1)({},s,t);return n.clearPendingOnAdd&&i(),b.addNewBatch(e,n).then((()=>{a.vF.debugLog("uploady.uploader: finished adding file data to be processed")}))},upload:e=>{b.processPendingBatches(e)},abort:e=>{b.abort(e)},abortBatch:e=>{b.abortBatch(e)},getOptions:()=>(0,a.o8)(s),clearPending:i,registerExtension:(e,t)=>{(0,a.V1)(n,"Uploady - uploader extensions can only be registered by enhancers"),(0,a.V1)(!o[e],"Uploady - uploader extension by this name [%s] already exists",e),a.vF.debugLog(`uploady.uploader: registering extension: ${e.toString()}`,t),o[e]=t},getExtension:e=>o[e]},ce,{canAddEvents:!1,canRemoveEvents:!1});const l=(e,...t)=>{const n=(0,r.yn)((()=>t.map(oe)));return d(e,n)},u=(0,a.x1)(l),h=((e,t,n,r)=>{const a=t.enhancer?(o=t.enhancer,de(p(),o)):p();var o;r(!0);const s=a(e,n);return r(!1),s||e})(c,s,l,(e=>{n=e})),b=ie(l,u,s,h.id);return(0,a.fO)(h)},pe=ue}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,r),o.exports}r.m=t,e=[],r.O=(t,n,a,o)=>{if(!n){var s=1/0;for(l=0;l<e.length;l++){for(var[n,a,o]=e[l],i=!0,d=0;d<n.length;d++)(!1&o||s>=o)&&Object.keys(r.O).every((e=>r.O[e](n[d])))?n.splice(d--,1):(i=!1,o<s&&(s=o));if(i){e.splice(l--,1);var c=a();void 0!==c&&(t=c)}}return t}o=o||0;for(var l=e.length;l>0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[n,a,o]},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.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={114:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,[s,i,d]=n,c=0;if(s.some((t=>0!==e[t]))){for(a in i)r.o(i,a)&&(r.m[a]=i[a]);if(d)var l=d(r)}for(t&&t(n);c<s.length;c++)o=s[c],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(l)},n=globalThis.webpackChunkrpldy=globalThis.webpackChunkrpldy||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.O(void 0,[461],(()=>r("g+8f"))),r.O(void 0,[461],(()=>r("9Oim"))),r.O(void 0,[461],(()=>r("UjVA")));var a=r.O(void 0,[461],(()=>r("vVPY")));return r.O(a)})()));
//# sourceMappingURL=rpldy-core.umd.min.js.map
{
"version": "1.8.1",
"version": "1.8.2",
"name": "@rpldy/uploader",

@@ -32,8 +32,8 @@ "description": "the processing and queuing engine for react-uploady",

"dependencies": {
"@rpldy/abort": "^1.8.1",
"@rpldy/life-events": "^1.8.1",
"@rpldy/raw-uploader": "^1.8.1",
"@rpldy/sender": "^1.8.1",
"@rpldy/shared": "^1.8.1",
"@rpldy/simple-state": "^1.8.1"
"@rpldy/abort": "^1.8.2",
"@rpldy/life-events": "^1.8.2",
"@rpldy/raw-uploader": "^1.8.2",
"@rpldy/sender": "^1.8.2",
"@rpldy/shared": "^1.8.2",
"@rpldy/simple-state": "^1.8.2"
},

@@ -46,3 +46,3 @@ "devDependencies": {

},
"gitHead": "42499e9a3b55c3996dcdf502df093da6b22d9927"
"gitHead": "3704b7109c8492d67ac9aba12e4e7a5060da074f"
}

@@ -18,4 +18,4 @@ import { Trigger } from "@rpldy/shared";

export interface CreateOptions extends RawCreateOptions {
enhancer?: UploaderEnhancer;
send?: SendMethod;
enhancer?: UploaderEnhancer | undefined;
send?: SendMethod | undefined;
}

@@ -22,0 +22,0 @@

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