@rpldy/uploader
Advanced tools
Comparing version 1.1.0-rc.0 to 1.1.0-rc.1
@@ -45,3 +45,3 @@ "use strict"; | ||
isFast | ||
} = abortBatchMethod(batch, batchData.batchOptions, state.aborts, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
} = abortBatchMethod(batch, batchData.batchOptions, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
@@ -63,3 +63,3 @@ if (isFast) { | ||
isFast | ||
} = abortAllMethod(state.items, state.aborts, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
} = abortAllMethod(state.items, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
@@ -66,0 +66,0 @@ if (isFast) { |
@@ -30,3 +30,3 @@ import { invariant, BATCH_STATES } from "@rpldy/shared"; | ||
isFast | ||
} = abortBatchMethod(batch, batchData.batchOptions, state.aborts, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
} = abortBatchMethod(batch, batchData.batchOptions, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
@@ -46,3 +46,3 @@ if (isFast) { | ||
isFast | ||
} = abortAllMethod(state.items, state.aborts, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
} = abortAllMethod(state.items, state.aborts, state.itemQueue, getFinalizeAbortedItem(queue), queue.getOptions()); | ||
@@ -49,0 +49,0 @@ if (isFast) { |
/*! 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("tU4p");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("tU4p");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},tU4p:(e,t,n)=>{"use strict";n.d(t,{FG:()=>d,FD:()=>c,d9:()=>j,Yc:()=>R,ZV:()=>B,D8:()=>k,Ym:()=>u,kG:()=>a(),mf:()=>C(),PO:()=>L,yv:()=>F(),tI:()=>U,sQ:()=>P,kg:()=>r,TS:()=>H,k7:()=>D,ei:()=>x,WY:()=>w,nK:()=>Q,P2:()=>i(),tq:()=>b,sc:()=>E});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},m=e=>null==e,E=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(;m(t)&&e.length;)t=e.pop();n(m(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},v=Symbol.for("__rpldy-bi__");let S=0;const y=(e,t)=>(e.url=t,e),A=(e,t)=>(e.file=t,e),O=e=>e&&(e instanceof File||e instanceof Blob||"object"==typeof e&&e.name&&e.type),R=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];S+=e.id&&e.batchId?0:1;const r=e.id&&e.batchId?e.id:`${t}.item-${S}`,o=n?c.PENDING:c.ADDED;let a={id:r,batchId:t,state:o,uploadStatus:0,completed:0,loaded:0,recycled:!1,previousBatch:null};if(Object.defineProperty(a,v,{value:!0,writable:!0}),"object"==typeof e&&!0===e[v]&&(a.recycled=!0,a.previousBatch=e.batchId,e=e.file||e.url),"string"==typeof e)a=y(a,e);else{if(!O(e))throw new Error("Unknown type of file added: "+typeof e);a=A(a,e)}return a},I=(e,t)=>{t&&Object.keys(t).forEach((n=>{void 0!==t[n]&&e.setRequestHeader(n,t[n])}))},D=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,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),I(r,n.headers),r.withCredentials=!!n.withCredentials,n.preSend&&n.preSend(r),r.send(t)}));return o.xhr=r,o};var T=n("wfJ/"),C=n.n(T);const P=(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 _=n("hSSe"),F=n.n(_);const B=e=>F()()?e:Object.freeze(e),L=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))},N=e=>L(e)||Array.isArray(e),G=(e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n},k=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&&G(r,e).forEach((o=>{const a=r[o];e.predicate&&!e.predicate(o,a)||(void 0!==a||e.undefinedOverwrites)&&(N(a)?(void 0!==n[o]&&L(n[o])||(n[o]=Array.isArray(a)?[]:{}),t(n[o],a)):n[o]=a)}))})),n};return t},H=k(),j=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H;return N(e)?t(Array.isArray(e)?[]:{},e):e},x=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),U=e=>!!e&&"object"==typeof e&&"function"==typeof e.then,q=u()&&window.requestIdleCallback,$=q?window.requestIdleCallback:setTimeout,M=q?window.cancelIdleCallback:clearTimeout,Q=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=$(e,q?{timeout:t}:t);return()=>M(n)}},"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("tU4p");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)=>{const a=Object.keys(e),s=d(a.length,r.fastAbortThreshold);return o.kg.debugLog(`abort: doing abort-all (${s?"fast":"normal"} abort)`),s?(e=>{Object.values(e).forEach((e=>e()))})(t):a.forEach((r=>l(r,e,t,n))),{isFast:s}},u=(e,t,n,r,a)=>{const s=0===t.fastAbortThreshold?0:t.fastAbortThreshold||a.fastAbortThreshold,l=d(e.items.length,s);return o.kg.debugLog(`abort: doing abort-batch on: ${e.id} (${l?"fast":"normal"} abort)`),l?((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,r))),{isFast:l}},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"),D=n.n(I);const w=(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=w({},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)},q=(e,t)=>{const n=N(e.getState(),t);return D()(B).call(B,n.state)},$=e=>D()(L).call(L,e.state),M={[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),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,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),M[t.state]&&e.trigger(M[t.state],t),Q(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=$(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=>D()(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 D()(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(q(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&&!D()(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&&!$(s)){x(e,t,A.BATCH_ABORT,o.FG.ABORTED);const{isFast:i}=n(s,a.batchOptions,r.aborts,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,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)=>Promise.all(Array.prototype.map.call(t,(e=>{const t=(r||oe)(e);return(0,o.tI)(t)?t.then((t=>!!t&&e)):!!t&&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("tU4p"))),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("tU4p");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("tU4p");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},tU4p:(e,t,n)=>{"use strict";n.d(t,{FG:()=>d,FD:()=>c,d9:()=>j,Yc:()=>R,ZV:()=>B,D8:()=>k,Ym:()=>u,kG:()=>a(),mf:()=>C(),PO:()=>L,yv:()=>F(),tI:()=>U,sQ:()=>P,kg:()=>r,TS:()=>H,k7:()=>D,ei:()=>x,WY:()=>w,nK:()=>M,P2:()=>i(),tq:()=>b,sc:()=>E});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},m=e=>null==e,E=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(;m(t)&&e.length;)t=e.pop();n(m(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},v=Symbol.for("__rpldy-bi__");let S=0;const y=(e,t)=>(e.url=t,e),A=(e,t)=>(e.file=t,e),O=e=>e&&(e instanceof File||e instanceof Blob||"object"==typeof e&&e.name&&e.type),R=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];S+=e.id&&e.batchId?0:1;const r=e.id&&e.batchId?e.id:`${t}.item-${S}`,o=n?c.PENDING:c.ADDED;let a={id:r,batchId:t,state:o,uploadStatus:0,completed:0,loaded:0,recycled:!1,previousBatch:null};if(Object.defineProperty(a,v,{value:!0,writable:!0}),"object"==typeof e&&!0===e[v]&&(a.recycled=!0,a.previousBatch=e.batchId,e=e.file||e.url),"string"==typeof e)a=y(a,e);else{if(!O(e))throw new Error("Unknown type of file added: "+typeof e);a=A(a,e)}return a},I=(e,t)=>{t&&Object.keys(t).forEach((n=>{void 0!==t[n]&&e.setRequestHeader(n,t[n])}))},D=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,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),I(r,n.headers),r.withCredentials=!!n.withCredentials,n.preSend&&n.preSend(r),r.send(t)}));return o.xhr=r,o};var T=n("wfJ/"),C=n.n(T);const P=(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 _=n("hSSe"),F=n.n(_);const B=e=>F()()?e:Object.freeze(e),L=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))},N=e=>L(e)||Array.isArray(e),G=(e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n},k=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&&G(r,e).forEach((o=>{const a=r[o];e.predicate&&!e.predicate(o,a)||(void 0!==a||e.undefinedOverwrites)&&(N(a)?(void 0!==n[o]&&L(n[o])||(n[o]=Array.isArray(a)?[]:{}),t(n[o],a)):n[o]=a)}))})),n};return t},H=k(),j=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H;return N(e)?t(Array.isArray(e)?[]:{},e):e},x=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),U=e=>!!e&&"object"==typeof e&&"function"==typeof e.then,q=u()&&window.requestIdleCallback,$=q?window.requestIdleCallback:setTimeout,Q=q?window.cancelIdleCallback:clearTimeout,M=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=$(e,q?{timeout:t}:t);return()=>Q(n)}},"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("tU4p");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"),D=n.n(I);const w=(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=w({},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)},q=(e,t)=>{const n=N(e.getState(),t);return D()(B).call(B,n.state)},$=e=>D()(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=$(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=>D()(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 D()(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(q(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&&!D()(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&&!$(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)=>Promise.all(Array.prototype.map.call(t,(e=>{const t=(r||oe)(e);return(0,o.tI)(t)?t.then((t=>!!t&&e)):!!t&&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("tU4p"))),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.1.0-rc.0", | ||
"version": "1.1.0-rc.1", | ||
"name": "@rpldy/uploader", | ||
@@ -33,8 +33,8 @@ "description": "the processing and queuing engine for react-uploady", | ||
"dependencies": { | ||
"@rpldy/abort": "^1.1.0-rc.0", | ||
"@rpldy/life-events": "^1.1.0-rc.0", | ||
"@rpldy/raw-uploader": "^1.1.0-rc.0", | ||
"@rpldy/sender": "^1.1.0-rc.0", | ||
"@rpldy/shared": "^1.1.0-rc.0", | ||
"@rpldy/simple-state": "^1.1.0-rc.0" | ||
"@rpldy/abort": "^1.1.0-rc.1", | ||
"@rpldy/life-events": "^1.1.0-rc.1", | ||
"@rpldy/raw-uploader": "^1.1.0-rc.1", | ||
"@rpldy/sender": "^1.1.0-rc.1", | ||
"@rpldy/shared": "^1.1.0-rc.1", | ||
"@rpldy/simple-state": "^1.1.0-rc.1" | ||
}, | ||
@@ -47,3 +47,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "a80346f4acdf01b889077da006328610142fa42e" | ||
"gitHead": "3bf60849416fa42f05bef7918f48e3ba866258ff" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164023
Updated@rpldy/abort@^1.1.0-rc.1
Updated@rpldy/sender@^1.1.0-rc.1
Updated@rpldy/shared@^1.1.0-rc.1