@rpldy/uploader
Advanced tools
Comparing version 1.6.1 to 1.7.0-rc.0
/*! 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()}(self,(function(){return function(){var e,t={douX:function(e,t,n){"use strict";n.d(t,{uZ:function(){return v},ZP:function(){return E}});var r=n("7rGY"),o=(0,r.ZV)({allowRegisterNonExistent:!0,canAddEvents:!0,canRemoveEvents:!0,collectStats:!1});const a=Symbol.for("__le__"),s=Symbol.for("__le__pack__"),i=e=>e?e[a]:null,c=e=>{const t=i(e);if(!t)throw new Error("Didnt find LE internal object. Something very bad happened!");return t},u=function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];((e,t)=>{if(!(0,r.mf)(e))throw new Error("'cb' is not a valid function")})(n);const a=c(e);if(!a.options.allowRegisterNonExistent&&!~a.events.indexOf(t))throw new Error(`Cannot register for event ${t.toString()} that wasn't already defined (allowRegisterNonExistent = false)`);const s=a.registry[t]||[];return s.find((e=>e.cb===n))||(s.push({name:t,cb:n,once:o}),a.registry[t]=s),()=>b.call(e,t,n)},d=(e,t)=>{const n=c(e).registry;return t?n[t]?n[t].slice():[]:Object.values(n).flat()},l={on:function(e,t){return u(this,e,t)},once:function(e,t){return u(this,e,t,!0)},off:b,getEvents:function(){return c(this).events.slice()}},f={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=d(this,e);let i;if(a.length){let t;1===n.length&&!0===n[0]?.[s]&&(t=n[0].resolve()),i=a.map((r=>{let o;return r.once&&g(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=>!(void 0===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!!d(this,e).length},assign:function(e){const t=c(this);return m(e,t.options,t.events,t.registry,t.stats),h(e)}},h=e=>Object.keys(f).reduce(((t,n)=>(t[n]=f[n].bind(e),t)),{target:e,...f}),p=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]},g=(e,t,n)=>{const r=c(e).registry;r[t]&&(n?(r[t]=r[t].filter((e=>e.cb!==n)),p(e,t)):p(e,t,!0))};function b(e,t){g(this,e,t)}const m=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,{[a]:{value:Object.seal({registry:r,events:n,options:t,stats:o})},...Object.entries(l).reduce(((e,t)=>{let[n,r]=t;return e[n]={value:r},e}),{})})};var E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=e||{},r={...o,...arguments.length>2?arguments[2]:void 0};return i(n)||m(n,r,t),h(n)},v=e=>{const t={resolve:()=>[].concat(e())};return Object.defineProperty(t,s,{value:!0,configurable:!1}),t}},QwcM:function(e,t,n){"use strict";n.d(t,{PF:function(){return a},Ch:function(){return o},ZP:function(){return h},KZ:function(){return l},lW:function(){return f}});var r=n("7rGY");const o="rpldy-sender";class a extends Error{constructor(e){super(`${e} didn't receive upload URL`),this.name="MissingUrlError"}}const s=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];"set"in e?e.set(t,...r):("delete"in e&&e.delete(t),e.append(t,...r))};const i=[200,201,202,203,204],c=(e,t,n,o,a)=>{let i;const c=a?.getRequestData?a.getRequestData(e,n):((e,t)=>{let n;if(t.sendWithFormData)r.kg.debugLog(`uploady.sender: sending ${e.length} item(s) as form data`),n=((e,t)=>{const n=new FormData;return t.params&&Object.entries(t.params).forEach((e=>{let[r,o]=e;(t.formDataAllowUndefined||void 0!==o)&&s(n,r,o)})),((e,t,n)=>{const o=1===t.length;t.forEach(((t,a)=>{const i=o?n.paramName:(0,r.mf)(n.formatGroupParamName)?n.formatGroupParamName(a,n.paramName):`${n.paramName}[${a}]`;t.file?s(e,i,t.file,t.file.name):t.url&&s(e,i,t.url)}))})(n,e,t),n})(e,t);else{if(e.length>1)throw new Error(`XHR Sender - Request without form data can only contain 1 item. received ${e.length}`);const t=e[0];r.kg.debugLog(`uploady.sender: sending item ${t.id} as request body`),n=t.file||t.url}return n})(e,n),u=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c,u=arguments.length>2?arguments[2]:void 0;const d=(0,r.TS)({...(0,r.ei)(n,["method","headers","withCredentials"]),preSend:t=>{t.upload.onprogress=t=>{t.lengthComputable&&o&&o(t,e.slice())}}},u),l=(0,r.WY)(a,s,d);return i=l.xhr,l},d=a?.preRequestHandler?a.preRequestHandler(u,e,t,n,o,a):u();return{url:t,count:e.length,pXhr:d,getXhr:()=>i,aborted:!1}},u=(e,t,n)=>{let r=e;const o=t?.["content-type"];if(n.forceJsonResponse||o?.includes("json"))try{r=JSON.parse(e)}catch{}return r},d=(e,t)=>e.pXhr.then((e=>(r.kg.debugLog("uploady.sender: received upload response ",e),((e,t)=>{const n=t.isSuccessfulCall?t.isSuccessfulCall(e):i.includes(e.status);return(0,r.tI)(n)?n:Promise.resolve(n)})(e,t).then((n=>{const o=n?r.FD.FINISHED:r.FD.ERROR,a=e.status,s=(0,r.k7)(e);return{status:a,state:o,response:{data:t.formatServerResponse?.(e.response,a,s)??u(e.response,s,t),headers:s}}}))))).catch((t=>{let n,o;return e.aborted?(n=r.FD.ABORTED,o="aborted"):(r.kg.debugLog("uploady.sender: upload failed: ",t),n=r.FD.ERROR,o=t),{error:!0,state:n,response:o,status:0}}));var l=e=>(t,n,s,i)=>{if(!n)throw new a(o);r.kg.debugLog("uploady.sender: sending file: ",{items:t,url:n,options:s});const u=c(t,n,s,i,e);return{request:d(u,s),abort:()=>(e=>{let t=!1;const{aborted:n,getXhr:o}=e,a=o();return!n&&a&&a.readyState&&4!==a.readyState&&(r.kg.debugLog(`uploady.sender: cancelling request with ${e.count} items to: ${e.url}`),a.abort(),e.aborted=!0,t=!0),t})(u),senderType:o}};const f=l();var h=f},"7rGY":function(e,t,n){"use strict";n.d(t,{FG:function(){return c},FD:function(){return u},d9:function(){return D},Yc:function(){return H},ZV:function(){return y},$e:function(){return k},D8:function(){return R},Ym:function(){return d},kG:function(){return a()},mf:function(){return m()},PO:function(){return A},yv:function(){return S()},tI:function(){return T},sQ:function(){return E},kg:function(){return r},TS:function(){return I},k7:function(){return j},ei:function(){return w},WY:function(){return U},nK:function(){return F},P2:function(){return s.Z},tq:function(){return g},sc:function(){return L}});var r={};n.r(r),n.d(r,{debugLog:function(){return p},isDebugOn:function(){return f},setDebug:function(){return h}});var o=n("3lvE"),a=n.n(o),s=n("6dsl");const i="__rpldy-logger-debug__",c={PENDING:"pending",ADDED:"added",PROCESSING:"processing",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ABORTED:"aborted",ERROR:"error"},u={PENDING:"pending",ADDED:"added",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ERROR:"error",ABORTED:"aborted"};var d=()=>"object"==typeof window&&!!window.document;let l=null;const f=()=>("boolean"!=typeof l&&(l=d()&&("location"in window&&!!~window.location.search.indexOf("rpldy_debug=true")||!0===window[i])),!!l),h=e=>{d()&&(window[i]=e),l=!!e||null},p=function(){f()&&console.log(...arguments)};var g=function(e,t){const n=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new Promise(((n,o)=>{const a=e(t,...r);a&&a.length?Promise.all(a).catch(o).then((e=>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},b=n("i6OA"),m=n.n(b),E=(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},v=n("1XoD"),S=n.n(v),y=e=>S()()?e:Object.freeze(e),A=e=>!!e&&"object"==typeof e&&("Object"===Object.getPrototypeOf(e)?.constructor.name||null===Object.getPrototypeOf(e));const O=e=>A(e)||Array.isArray(e),R=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&&((e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n})(r,e).forEach((o=>{const a=r[o];e.predicate&&!e.predicate(o,a)||(void 0!==a||e.undefinedOverwrites)&&(O(a)?(void 0!==n[o]&&A(n[o])||(n[o]=Array.isArray(a)?[]:{}),t(n[o],a)):n[o]=a)}))})),n};return t};var I=R(),D=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:I;return O(e)?t(Array.isArray(e)?[]:{},e):e},w=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),T=function(e){return!!e&&"object"==typeof e&&"function"==typeof e.then};const P=d()&&window.requestIdleCallback,C=P?window.requestIdleCallback:setTimeout,_=P?window.cancelIdleCallback:clearTimeout;var F=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=C(e,P?{timeout:t}:t);return()=>_(n)},B=function(e){return null==e},L=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(;B(t)&&e.length;)t=e.pop();n(B(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};const N=Symbol.for("__rpldy-bi__");let G=0;const k=e=>!("object"!=typeof e||!e.id||!e.batchId||!0!==e[N]);var H=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=k(e);G+=r?0:1;let o={id:r&&e.id&&"string"==typeof e.id?e.id:`${t}.item-${G}`,batchId:t,state:n?u.PENDING:u.ADDED,uploadStatus:0,total:0,completed:0,loaded:0,recycled:r,previousBatch:r?e.batchId:null};Object.defineProperty(o,N,{value:!0,writable:!0});const a=r?e.file||e.url:e;if("string"==typeof a)o=((e,t)=>(e.url=t,e))(o,a);else{if(!(e=>e&&(e instanceof File||e instanceof Blob||!("object"!=typeof e||!e.name||!e.type)))(a))throw new Error("Unknown type of file added: "+typeof a);o=((e,t)=>(e.file=t,e))(o,a)}return o},x=class extends Promise{constructor(e,t){super(e),this.xhr=t}},j=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){p("uploady.request: failed to read response headers",e)}return t},U=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=new XMLHttpRequest;return new x(((o,a)=>{r.onerror=()=>a(r),r.ontimeout=()=>a(r),r.onabort=()=>a(r),r.onload=()=>o(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)}},i6OA:function(e){e.exports=function(e){return"function"==typeof e}},"1XoD":function(e){e.exports=function(){return!0}},"d+yt":function(e,t,n){"use strict";n.r(t),n.d(t,{BATCH_STATES:function(){return o.FG},DEFAULT_OPTIONS:function(){return ne},FILE_STATES:function(){return o.FD},MissingUrlError:function(){return ee.PF},UPLOADER_EVENTS:function(){return h},XHR_SENDER_TYPE:function(){return ee.Ch},composeEnhancers:function(){return ce},createUploader:function(){return le},default:function(){return fe},getXhrSend:function(){return ee.KZ},send:function(){return ee.lW}});var r=n("douX"),o=n("7rGY");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=e?.state,o=!!r&&s[r];return!!o&&o(e,t,n)},c=(e,t,n,r)=>i(t[e],n,r),u=(e,t)=>{let n=!1;return 0!==t&&t&&(n=e>=t),n},d=(e,t,n,r,a)=>{const s=Object.values(n).flat(),i=u(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=>c(n,e,t,r))),{isFast:i}},l=(e,t,n,r,a,s)=>{const c=0===t.fastAbortThreshold?0:t.fastAbortThreshold||s.fastAbortThreshold,d=u(r[e.id].length,c);return o.kg.debugLog(`abort: doing abort-batch on: ${e.id} (${d?"fast":"normal"} abort)`),d?((e,t)=>{e.items.forEach((e=>{let{id:n}=e;return t[n]?.()}))})(e,n):e.items.forEach((e=>i(e,n,a))),{isFast:d}};var f=()=>e=>(e.update({abortAll:d,abortBatch:l,abortItem:c}),e);const h=(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"}),p=(0,o.ZV)({ITEM_PROGRESS:"ITEM_PROGRESS",BATCH_PROGRESS:"BATCH_PROGRESS"}),g=[o.FD.FINISHED,o.FD.ERROR,o.FD.CANCELLED,o.FD.ABORTED],b=Symbol.for("__rpldy-sstt-proxy__"),m=Symbol.for("__rpldy-sstt-state__"),E=e=>!(0,o.yv)()&&!!e&&!!~Object.getOwnPropertySymbols(e).indexOf(b),v=e=>Array.isArray(e)||(0,o.PO)(e)&&!(e=>(0,o.Ym)()&&e instanceof File||e.name&&e.size&&e.uri)(e),S=(0,o.D8)({withSymbols:!0,predicate:e=>e!==b&&e!==m}),y=e=>!!(0,o.yv)()||e[m].isUpdateable,A=(e,t)=>{(0,o.yv)()||(e[m].isUpdateable=t)},O=(e,t)=>{let n;return v(e)&&(E(e)||(e[b]=!0,n=new Proxy(e,t)),Object.keys(e).forEach((n=>{e[n]=O(e[n],t)}))),n||e},R=e=>E(e)?(0,o.d9)(e,S):e;const I=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e.updateState((e=>{const{batchId:r}=e.items[t]||{batchId:null};n&&delete e.items[t];const o=r?e.itemQueue[r].indexOf(t):-1;~o&&r&&e.itemQueue[r].splice(o,1);const a=e.activeIds.indexOf(t);~a&&e.activeIds.splice(a,1)}))},D=(e,t)=>!!e.getState().items[t],w=e=>g.includes(e.state),T=(0,o.D8)({undefinedOverwrites:!0}),P=(e,t,n,r,a,s)=>{const i=n(t),c=e.getState().batches[i[0].batchId].batchOptions,u=r?.(t,c)||t;return((e,t,n,r,a,s)=>(0,o.sc)(e.trigger,a,t,r).then((e=>(s?.(e),((e,t,n,r)=>{let a=n,s=t;if(r){if(o.kg.debugLog(`uploader.queue: REQUEST_PRE_SEND(${e}) event returned updated items/options`,r),r.items){if(r.items.length!==t.length||!(0,o.sQ)(r.items,t,["id","batchId","recycled"]))throw new Error(`REQUEST_PRE_SEND(${e}) event handlers must return same items with same ids`);s=r.items}r.options&&(a=T({},n,r.options))}return{items:s,options:a,cancelled:!1===r}})(a,n,r,e)))))(e,u,i,c,s,a).then((t=>(t.cancelled||((e,t)=>{if(t.items[0]&&e.getState().batches[t.items[0].batchId]){e.updateState((e=>{t.items.forEach((t=>{w(e.items[t.id])||(e.items[t.id]=t)})),e.batches[t.items[0].batchId].batchOptions=t.options}));const n=e.getState();t.items=t.items.map((e=>n.items[e.id])),t.options=n.batches[t.items[0].batchId].batchOptions}})(e,t),t)))},C=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return(o,a)=>P(o,a,t,n,r,e)},_=C(h.BATCH_START,(e=>e.items),null,(function(){let{batch:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{batch:!1};if(e)throw new Error("BATCH_START event handlers cannot update batch data. Only items & options")})),F=[o.FG.ADDED,o.FG.PROCESSING,o.FG.UPLOADING],B=[o.FG.ABORTED,o.FG.CANCELLED,o.FG.FINISHED,o.FG.ERROR],L=(e,t)=>e.batches[t].batch,N=(e,t)=>{const n=e.getState(),r=n.items[t];return n.batches[r.batchId]},G=(e,t)=>N(e,t).batch,k=(e,t)=>{const n=((e,t)=>L(e.getState(),t))(e,t);n.items.forEach((t=>{let{id:n}=t;return I(e,n,!0)}))},H=(e,t)=>{e.updateState((e=>{delete e.batches[t],delete e.itemQueue[t];const n=e.batchQueue.indexOf(t);~n&&e.batchQueue.splice(n,1);const r=e.batchesStartPending.indexOf(t);~r&&e.batchesStartPending.splice(r,1)}))},x=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:o.FG.FINISHED,a=arguments.length>4?arguments[4]:void 0;e.updateState((e=>{const n=L(e,t);n.state=r,a&&(n.additionalInfo=a)})),U(e,t,n),U(e,t,h.BATCH_FINALIZE)},j=(e,t)=>{o.kg.debugLog("uploady.uploader.batchHelpers: cancelling batch: ",t),x(e,t,h.BATCH_CANCEL,o.FG.CANCELLED),k(e,t),H(e,t)},U=(e,t,n)=>{const r=e.getState(),{batch:o,batchOptions:a}=r.batches[t],s=r.items,i={...R(o),items:o.items.map((e=>{let{id:t}=e;return R(s[t])}))};e.trigger(n,i,R(a))},$=(e,t)=>{const n=L(e.getState(),t);return F.includes(n.state)},q=e=>B.includes(e.state),Q={[o.FD.PENDING]:null,[o.FD.ADDED]:h.ITEM_START,[o.FD.FINISHED]:h.ITEM_FINISH,[o.FD.ERROR]:h.ITEM_ERROR,[o.FD.CANCELLED]:h.ITEM_CANCEL,[o.FD.ABORTED]:h.ITEM_ABORT,[o.FD.UPLOADING]:h.ITEM_PROGRESS},M=e=>!!~g.indexOf(e.state);var 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];if(a.state===o.FD.FINISHED&&t.completed<100){const n=t.file?.size||0;e.handleItemProgress(t,100,n,n)}const{batchOptions:n}=N(e,r);Q[t.state]&&e.trigger(Q[t.state],t,n),M(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,o.nK)((()=>{const t=e.getState();Object.keys(t.batches).forEach((n=>{const{batch:r,finishedCounter:a}=t.batches[n],{orgItemCount:s}=r,i=q(r);s===a&&(i||100===r.completed||(e.updateState((e=>{const t=L(e,n);t.completed=100,t.loaded=t.items.reduce(((e,t)=>{let{loaded:n}=t;return e+n}),0)})),U(e,n,h.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,h.BATCH_FINISH),k(e,n),H(e,n))}))}))})(e),n(e)};const Y=C(h.REQUEST_PRE_SEND,(e=>e),((e,t)=>({items:e,options:t}))),X=e=>{let{allowedItems:t,cancelledResults:n,queue:r,items:a,ids:s,next:i}=e;const c=t.length?Y(r,t):Promise.resolve();let u=n;return c.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?u=s.map((()=>!0)):e.items.some((e=>w(e)))?o.kg.debugLog("uploader.queue: send data contains aborted items - not sending"):((e,t,n)=>{const{items:r,options:a}=t,s=e.getState().batches[r[0].batchId]?.batch;if(s){let t;try{t=e.sender.send(r,s,a)}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:i}=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,r,t),i.then((t=>{const o=r.map((e=>({id:e.id,info:t})));Z(e,o,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,u,i)||(t=i(r)),t}))};const W=(e,t)=>e.getState().activeIds.flat().includes(t),V=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,c=t.batchQueue[s];for(;c&&!a;){if($(e,c))for(a=n[c][i];a&&(W(e,a)||r[a].state!==o.FD.ADDED);)i+=1,a=n[c][i];a||(s+=1,c=t.batchQueue[s],i=0)}return a?[c,i]:null})(e)||[];let s,i=r&&~a?n[r][a]:null;if(i){const{batchOptions:e}=t.batches[r],n=e.maxGroupSize||0;s=e.grouped&&n>1?t.itemQueue[r].slice(a,a+n):[i]}return s})(e);if(n){const r=e.getCurrentActiveCount(),{concurrent:a=!1,maxConcurrent:s=0}=e.getOptions();(!r||a&&r<s)&&(o.kg.debugLog("uploader.processor: Processing next upload - ",{ids:n,currentCount:r}),t=((e,t)=>{let n;return((e,t)=>{const n=G(e,t);return e.getState().batchesStartPending.includes(n.id)})(e,t[0])?n=Promise.resolve(!0):(((e,t)=>{e.updateState((e=>{e.activeIds=e.activeIds.concat(t)}))})(e,t),n=((e,t)=>{const n=G(e,t);return e.getState().currentBatch!==n.id})(e,t[0])?((e,t)=>{const n=G(e,t);return e.updateState((e=>{e.batchesStartPending.push(n.id)})),_(e,n).then((r=>{let{cancelled:o}=r,a=!1;return e.updateState((e=>{const t=e.batchesStartPending.indexOf(n.id);e.batchesStartPending.splice(t,1)})),o||(a=!D(e,t),a||e.updateState((e=>{e.currentBatch=n.id}))),!o&&!a}))})(e,t[0]).then((n=>{let r=!n;return r&&(((e,t)=>{if(D(e,t)){const n=N(e,t),r=n?.batch.id;r?j(e,r):o.kg.debugLog(`uploady.uploader.batchHelpers: cancel batch called for batch already removed (item id = ${t})`)}})(e,t[0]),V(e)),r})).catch((n=>(o.kg.debugLog("uploader.processor: encountered error while preparing batch for request",n),((e,t,n)=>{const r=G(e,t),a=r.id;o.kg.debugLog("uploady.uploader.batchHelpers: failing batch: ",{batch:r}),x(e,a,h.BATCH_ERROR,o.FG.ERROR,n.message),k(e,a),H(e,a)})(e,t[0],n),V(e),!0))):Promise.resolve(!1)),n})(e,n).then((t=>{t||(((e,t,n)=>{const r=e.getState();let o=Object.values(r.items);o=o.filter((e=>t.includes(e.id)&&!w(e))),Promise.all(o.map((t=>{const{batchOptions:n}=N(e,t.id);return e.runCancellable(h.ITEM_START,t,n)}))).then((r=>{let a=r.map(((t,n)=>t?null:((e,t)=>{const n=t.getState().items[e];return n&&!w(n)?n:void 0})(o[n].id,e))).filter(Boolean);return{allowedItems:a,cancelledResults:r,queue:e,items:o,ids:t,next:n}})).then(X)})(e,n,V),a&&V(e))})))}return t};var z=V;const J=e=>(t,n)=>Z(e,[{id:t,info:n}],z);var K=(e,t,n,r,a)=>{const{state:s,update:i}=(e=>{const t={set:(e,r,o)=>(y(n)&&(e[r]=O(o,t)),!0),get:(e,t)=>t===b?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)=>(y(n)&&delete e[t],!0)};(0,o.yv)()||E(e)||Object.defineProperty(e,m,{value:{isUpdateable:!1},configurable:!0});const n=(0,o.yv)()?e:O(e,t);return{state:n,update:e=>{if(!(0,o.yv)()&&y(n))throw new Error("Can't call update on State already being updated!");try{A(n,!0),e(n)}finally{A(n,!1)}return n},unwrap:e=>e?R(e):E(n)?R(n):n}})({itemQueue:{},batchQueue:[],currentBatch:null,batchesStartPending:[],batches:{},items:{},activeIds:[],aborts:{}}),c=()=>s,u=e=>{i(e)},d=e=>{if(s.items[e.id]&&!e.recycled)throw new Error(`Uploader queue conflict - item ${e.id} already exists`);e.recycled&&((e,t)=>{const{previousBatch:n}=t;if(t.recycled&&n&&e.getState().batches[n]){const{id:r}=G(e,t.id);r===n&&e.updateState((e=>{const n=L(e,r),o=n.items.findIndex((e=>{let{id:n}=e;return n===t.id}));~o&&n.items.splice(o,1)}))}})(f,e),u((t=>{t.items[e.id]=e}))},l=(e,n,r,o)=>{s.items[e.id]&&(u((t=>{const a=t.items[e.id];a.loaded=r,a.completed=n,a.total=o})),t(h.ITEM_PROGRESS,c().items[e.id]))};r.on(p.ITEM_PROGRESS,l),r.on(p.BATCH_PROGRESS,(e=>{const t=s.batches[e.id]?.batch.items;if(t){const[n,r]=t.reduce(((e,t)=>{let{id:n}=t;const{loaded:r,file:o}=s.items[n],a=o?.size||r||1;return e[0]+=r,e[1]+=a,e}),[0,0]);u((t=>{const o=t.batches[e.id].batch;o.total=r,o.loaded=n,o.completed=n/r})),U(f,e.id,h.BATCH_PROGRESS)}}));const f={uploaderId:a,getOptions:()=>e,getCurrentActiveCount:()=>s.activeIds.length,getState:c,updateState:u,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:l,clearAllUploads:()=>{f.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})`),c().batches[e]&&((e,t)=>{e.updateState((e=>{const{items:n}=L(e,t);delete e.batches[t],delete e.itemQueue[t];const r=e.batchQueue.indexOf(t);~r&&e.batchQueue.splice(r,1),e.currentBatch===t&&(e.currentBatch=null),n.forEach((t=>{let{id:n}=t;delete e.items[n];const r=e.activeIds.indexOf(n);~r&&e.activeIds.splice(r,1)}))}))})(f,e)}))}};return(0,o.Ym)()&&o.kg.isDebugOn()&&(window[`__rpldy_${a}_queue_state`]=f),{updateState:u,getState:f.getState,runCancellable:f.runCancellable,uploadBatch:(e,t)=>{t&&u((n=>{n.batches[e.id].batchOptions=t})),z(f)},addBatch:(e,t)=>(u((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(d),L(s,e.id)),abortItem:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return((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,J(e))})(f,...t)},abortBatch:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return((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=a?.batch;if(s&&!q(s)){x(e,t,h.BATCH_ABORT,o.FG.ABORTED);const{isFast:i}=n(s,a.batchOptions,r.aborts,r.itemQueue,J(e),e.getOptions());i&&e.clearBatchUploads(s.id)}})(f,...t)},abortAll:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(e=>{const t=e.getOptions().abortAll;(0,o.kG)(!!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,J(e),e.getOptions());r&&e.clearAllUploads()})(f,...t)},clearPendingBatches:()=>{(e=>{const t=e.getState().batches;Object.keys(t).filter((e=>t[e].batch.state===o.FG.PENDING)).forEach((t=>{k(e,t),H(e,t)}))})(f)},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))}))}))})(f,e),z(f)},cancelBatch:e=>j(f,e.id)}},ee=n("QwcM");const te=()=>!0,ne=(0,o.ZV)({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});var re=()=>{const{trigger:e,target:t}=(0,r.ZP)({send:(t,n,r)=>{const a=r.destination,s=a?.url,i=(0,o.P2)((r=>((e,t,n,r)=>{((e,t,n,r,a)=>{e.forEach((e=>{o.kg.debugLog(`uploady.uploader.processor: file: ${e.id} progress event: loaded(${n}) - completed(${t})`),a(p.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(p.BATCH_PROGRESS,t)})(t,n,r,e)),50,!0);return((0,o.mf)(r.send)?r.send:ee.ZP)(t,s,{method:a?.method||r.method||ne.method,paramName:a?.filesParamName||r.inputFieldName||"file",params:{...r.params,...a?.params},forceJsonResponse:r.forceJsonResponse,withCredentials:r.withCredentials,formatGroupParamName:r.formatGroupParamName,headers:a?.headers,sendWithFormData:r.sendWithFormData,formatServerResponse:r.formatServerResponse,formDataAllowUndefined:r.formDataAllowUndefined,isSuccessfulCall:r.isSuccessfulCall},i)}},Object.values(p));return t};const oe=(0,o.Ym)()&&"FileList"in window,ae=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e;return(0,o.yv)()||(t<3&&E(e)?n=R(e):t<3&&v(e)&&(n=Array.isArray(e)?e.map((e=>ae(e,t+1))):Object.keys(e).reduce(((n,r)=>(n[r]=ae(e[r],t+1),n)),{}))),n};let se=0;var ie=(e,t,n,r)=>{const a=re(),s=K(n,e,t,a,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}`,a=(e=>oe&&e instanceof FileList||"[object FileList]"===e.toString())(e),s=Array.isArray(e)||a?e:[e],i=!n.autoUpload;return((e,t,n,r)=>{const a=r?Array.prototype.map.call(t,(e=>(0,o.$e)(e)?e.file||e.url:e)):[];return Promise.all(Array.prototype.map.call(t,((e,t)=>{const n=(r||te)(a[t],t,a);return(0,o.tI)(n)?n.then((t=>!!t&&e)):!!n&&e}))).then((t=>t.filter(Boolean).map((t=>(0,o.Yc)(t,e,n)))))})(r,s,i,n.fileFilter).then((e=>({id:r,uploaderId:t,items:e,state:i?o.FG.PENDING:o.FG.ADDED,completed:0,loaded:0,orgItemCount:e.length,additionalInfo:null})))})(e,r,t).then((e=>{let n;if(e.items.length){const a=s.addBatch(e,t);n=s.runCancellable(h.BATCH_ADD,a,t).then((e=>(e?s.cancelBatch(a):(o.kg.debugLog(`uploady.uploader [${r}]: new items added - auto upload =\n ${String(t.autoUpload)}`,a.items),t.autoUpload&&s.uploadBatch(a)),a)))}else o.kg.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)}}},ce=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.reduce(((e,t)=>t(e,...r)||e),e)}};const ue=Object.values(h);let de=0;var le=e=>{de+=1;const t=`uploader-${de}`;let n=!1;const a={};o.kg.debugLog(`uploady.uploader: creating new instance (${t})`,{options:e,counter:de});let s=(e=>{return{...ne,...e,destination:e&&e.destination?(t=e.destination,{params:{},...t}):null};var t})(e);const i=()=>{p.clearPendingBatches()};let{trigger:c,target:u}=(0,r.ZP)({id:t,update:e=>(s=(0,o.TS)({},s,e),u),add:(e,t)=>{const n=(0,o.TS)({},s,t);return n.clearPendingOnAdd&&i(),p.addNewBatch(e,n).then((()=>{o.kg.debugLog("uploady.uploader: finished adding file data to be processed")}))},upload:e=>{p.processPendingBatches(e)},abort:e=>{p.abort(e)},abortBatch:e=>{p.abortBatch(e)},getOptions:()=>(0,o.d9)(s),clearPending:i,registerExtension:(e,t)=>{(0,o.kG)(n,"Uploady - uploader extensions can only be registered by enhancers"),(0,o.kG)(!a[e],"Uploady - uploader extension by this name [%s] already exists",e),o.kg.debugLog(`uploady.uploader: registering extension: ${e.toString()}`,t),a[e]=t},getExtension:e=>a[e]},ue,{canAddEvents:!1,canRemoveEvents:!1});const d=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(ae)));return c(e,a)},l=(0,o.tq)(d),h=((e,t,n,r)=>{const o=t.enhancer?(a=t.enhancer,ce(f(),a)):f();var a;r(!0);const s=o(e,n);return r(!1),s||e})(u,s,d,(e=>{n=e})),p=ie(d,l,s,h.id);return(0,o.ZV)(h)},fe=le}},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=function(t,n,o,a){if(!n){var s=1/0;for(d=0;d<e.length;d++){n=e[d][0],o=e[d][1],a=e[d][2];for(var i=!0,c=0;c<n.length;c++)(!1&a||s>=a)&&Object.keys(r.O).every((function(e){return r.O[e](n[c])}))?n.splice(c--,1):(i=!1,a<s&&(s=a));if(i){e.splice(d--,1);var u=o();void 0!==u&&(t=u)}}return t}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[n,o,a]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(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=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e={321:0};r.O.j=function(t){return 0===e[t]};var t=function(t,n){var o,a,s=n[0],i=n[1],c=n[2],u=0;if(s.some((function(t){return 0!==e[t]}))){for(o in i)r.o(i,o)&&(r.m[o]=i[o]);if(c)var d=c(r)}for(t&&t(n);u<s.length;u++)a=s[u],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(d)},n=self.webpackChunkrpldy=self.webpackChunkrpldy||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}(),r.O(void 0,[429],(function(){return r("douX")})),r.O(void 0,[429],(function(){return r("7rGY")})),r.O(void 0,[429],(function(){return r("QwcM")}));var o=r.O(void 0,[429],(function(){return r("d+yt")}));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()}(self,(function(){return function(){var e,t={"3hgs":function(e,t,n){"use strict";n.d(t,{uZ:function(){return v},ZP:function(){return E}});var r=n("Z6oI"),o=(0,r.ZV)({allowRegisterNonExistent:!0,canAddEvents:!0,canRemoveEvents:!0,collectStats:!1});const a=Symbol.for("__le__"),s=Symbol.for("__le__pack__"),i=e=>e?e[a]:null,c=e=>{const t=i(e);if(!t)throw new Error("Didnt find LE internal object. Something very bad happened!");return t},u=function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];((e,t)=>{if(!(0,r.mf)(e))throw new Error("'cb' is not a valid function")})(n);const a=c(e);if(!a.options.allowRegisterNonExistent&&!~a.events.indexOf(t))throw new Error(`Cannot register for event ${t.toString()} that wasn't already defined (allowRegisterNonExistent = false)`);const s=a.registry[t]||[];return s.find((e=>e.cb===n))||(s.push({name:t,cb:n,once:o}),a.registry[t]=s),()=>b.call(e,t,n)},l=(e,t)=>{const n=c(e).registry;return t?n[t]?n[t].slice():[]:Object.values(n).flat()},d={on:function(e,t){return u(this,e,t)},once:function(e,t){return u(this,e,t,!0)},off:b,getEvents:function(){return c(this).events.slice()}},h={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=l(this,e);let i;if(a.length){let t;1===n.length&&!0===n[0]?.[s]&&(t=n[0].resolve()),i=a.map((r=>{let o;return r.once&&g(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=>!(void 0===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!!l(this,e).length},assign:function(e){const t=c(this);return m(e,t.options,t.events,t.registry,t.stats),f(e)}},f=e=>Object.keys(h).reduce(((t,n)=>(t[n]=h[n].bind(e),t)),{target:e,...h}),p=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]},g=(e,t,n)=>{const r=c(e).registry;r[t]&&(n?(r[t]=r[t].filter((e=>e.cb!==n)),p(e,t)):p(e,t,!0))};function b(e,t){g(this,e,t)}const m=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,{[a]:{value:Object.seal({registry:r,events:n,options:t,stats:o})},...Object.entries(d).reduce(((e,t)=>{let[n,r]=t;return e[n]={value:r},e}),{})})};var E=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=e||{},r={...o,...arguments.length>2?arguments[2]:void 0};return i(n)||m(n,r,t),f(n)},v=e=>{const t={resolve:()=>[].concat(e())};return Object.defineProperty(t,s,{value:!0,configurable:!1}),t}},"8IkK":function(e,t,n){"use strict";n.d(t,{PF:function(){return a},Ch:function(){return o},ZP:function(){return f},KZ:function(){return d},lW:function(){return h}});var r=n("Z6oI");const o="rpldy-sender";class a extends Error{constructor(e){super(`${e} didn't receive upload URL`),this.name="MissingUrlError"}}const s=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];"set"in e?e.set(t,...r):("delete"in e&&e.delete(t),e.append(t,...r))};const i=[200,201,202,203,204],c=(e,t,n,o,a)=>{let i;const c=a?.getRequestData?a.getRequestData(e,n):((e,t)=>{let n;if(t.sendWithFormData)r.kg.debugLog(`uploady.sender: sending ${e.length} item(s) as form data`),n=((e,t)=>{const n=new FormData;return t.params&&Object.entries(t.params).forEach((e=>{let[r,o]=e;(t.formDataAllowUndefined||void 0!==o)&&s(n,r,o)})),((e,t,n)=>{const o=1===t.length;t.forEach(((t,a)=>{const i=o?n.paramName:(0,r.mf)(n.formatGroupParamName)?n.formatGroupParamName(a,n.paramName):`${n.paramName}[${a}]`;t.file?s(e,i,t.file,t.file.name):t.url&&s(e,i,t.url)}))})(n,e,t),n})(e,t);else{if(e.length>1)throw new Error(`XHR Sender - Request without form data can only contain 1 item. received ${e.length}`);const t=e[0];r.kg.debugLog(`uploady.sender: sending item ${t.id} as request body`),n=t.file||t.url}return n})(e,n),u=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c,u=arguments.length>2?arguments[2]:void 0;const l=(0,r.TS)({...(0,r.ei)(n,["method","headers","withCredentials"]),preSend:t=>{t.upload.onprogress=t=>{t.lengthComputable&&o&&o(t,e.slice())}}},u),d=(0,r.WY)(a,s,l);return i=d.xhr,d},l=a?.preRequestHandler?a.preRequestHandler(u,e,t,n,o,a):u();return{url:t,count:e.length,pXhr:l,getXhr:()=>i,aborted:!1}},u=(e,t,n)=>{let r=e;const o=t?.["content-type"];if(n.forceJsonResponse||o?.includes("json"))try{r=JSON.parse(e)}catch{}return r},l=(e,t)=>e.pXhr.then((e=>(r.kg.debugLog("uploady.sender: received upload response ",e),((e,t)=>{const n=t.isSuccessfulCall?t.isSuccessfulCall(e):i.includes(e.status);return(0,r.tI)(n)?n:Promise.resolve(n)})(e,t).then((n=>{const o=n?r.FD.FINISHED:r.FD.ERROR,a=e.status,s=(0,r.k7)(e);return{status:a,state:o,response:{data:t.formatServerResponse?.(e.response,a,s)??u(e.response,s,t),headers:s}}}))))).catch((t=>{let n,o;return e.aborted?(n=r.FD.ABORTED,o="aborted"):(r.kg.debugLog("uploady.sender: upload failed: ",t),n=r.FD.ERROR,o=t),{error:!0,state:n,response:o,status:0}}));var d=e=>(t,n,s,i)=>{if(!n)throw new a(o);r.kg.debugLog("uploady.sender: sending file: ",{items:t,url:n,options:s});const u=c(t,n,s,i,e);return{request:l(u,s),abort:()=>(e=>{let t=!1;const{aborted:n,getXhr:o}=e,a=o();return!n&&a&&a.readyState&&4!==a.readyState&&(r.kg.debugLog(`uploady.sender: cancelling request with ${e.count} items to: ${e.url}`),a.abort(),e.aborted=!0,t=!0),t})(u),senderType:o}};const h=d();var f=h},Z6oI:function(e,t,n){"use strict";n.d(t,{FG:function(){return c},FD:function(){return u},d9:function(){return D},Yc:function(){return H},ZV:function(){return y},$e:function(){return k},D8:function(){return R},Ym:function(){return l},kG:function(){return a()},mf:function(){return m()},PO:function(){return A},yv:function(){return S()},tI:function(){return T},sQ:function(){return E},kg:function(){return r},TS:function(){return I},k7:function(){return j},ei:function(){return w},WY:function(){return U},nK:function(){return F},P2:function(){return s.Z},tq:function(){return g},sc:function(){return L}});var r={};n.r(r),n.d(r,{debugLog:function(){return p},isDebugOn:function(){return h},setDebug:function(){return f}});var o=n("3lvE"),a=n.n(o),s=n("6dsl");const i="__rpldy-logger-debug__",c={PENDING:"pending",ADDED:"added",PROCESSING:"processing",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ABORTED:"aborted",ERROR:"error"},u={PENDING:"pending",ADDED:"added",UPLOADING:"uploading",CANCELLED:"cancelled",FINISHED:"finished",ERROR:"error",ABORTED:"aborted"};var l=()=>"object"==typeof window&&!!window.document;let d=null;const h=()=>("boolean"!=typeof d&&(d=l()&&("location"in window&&!!~window.location.search.indexOf("rpldy_debug=true")||!0===window[i])),!!d),f=e=>{l()&&(window[i]=e),d=!!e||null},p=function(){h()&&console.log(...arguments)};var g=function(e,t){const n=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new Promise(((n,o)=>{const a=e(t,...r);a&&a.length?Promise.all(a).catch(o).then((e=>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},b=n("nstT"),m=n.n(b),E=(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},v=n("3REl"),S=n.n(v),y=e=>S()()?e:Object.freeze(e),A=e=>!!e&&"object"==typeof e&&("Object"===Object.getPrototypeOf(e)?.constructor.name||null===Object.getPrototypeOf(e));const O=e=>A(e)||Array.isArray(e),R=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&&((e,t)=>{const n=Object.keys(e);return t.withSymbols?n.concat(Object.getOwnPropertySymbols(e)):n})(r,e).forEach((o=>{const a=r[o];e.predicate&&!e.predicate(o,a)||(void 0!==a||e.undefinedOverwrites)&&(O(a)?(void 0!==n[o]&&A(n[o])||(n[o]=Array.isArray(a)?[]:{}),t(n[o],a)):n[o]=a)}))})),n};return t};var I=R(),D=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:I;return O(e)?t(Array.isArray(e)?[]:{},e):e},w=(e,t)=>e&&Object.keys(e).reduce(((n,r)=>(~t.indexOf(r)&&(n[r]=e[r]),n)),{}),T=function(e){return!!e&&"object"==typeof e&&"function"==typeof e.then};const P=l()&&window.requestIdleCallback,C=P?window.requestIdleCallback:setTimeout,_=P?window.cancelIdleCallback:clearTimeout;var F=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=C(e,P?{timeout:t}:t);return()=>_(n)},B=function(e){return null==e},L=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(;B(t)&&e.length;)t=e.pop();n(B(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};const N=Symbol.for("__rpldy-bi__");let G=0;const k=e=>!("object"!=typeof e||!e.id||!e.batchId||!0!==e[N]);var H=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=k(e);G+=r?0:1;let o={id:r&&e.id&&"string"==typeof e.id?e.id:`${t}.item-${G}`,batchId:t,state:n?u.PENDING:u.ADDED,uploadStatus:0,total:0,completed:0,loaded:0,recycled:r,previousBatch:r?e.batchId:null};Object.defineProperty(o,N,{value:!0,writable:!0});const a=r?e.file||e.url:e;if("string"==typeof a)o=((e,t)=>(e.url=t,e))(o,a);else{if(!(e=>e&&(e instanceof File||e instanceof Blob||!("object"!=typeof e||!e.name||!e.type)))(a))throw new Error("Unknown type of file added: "+typeof a);o=((e,t)=>(e.file=t,e))(o,a)}return o},x=class extends Promise{constructor(e,t){super(e),this.xhr=t}},j=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){p("uploady.request: failed to read response headers",e)}return t},U=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=new XMLHttpRequest;return new x(((o,a)=>{r.onerror=()=>a(r),r.ontimeout=()=>a(r),r.onabort=()=>a(r),r.onload=()=>o(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)}},nstT:function(e){e.exports=function(e){return"function"==typeof e}},"3REl":function(e){e.exports=function(){return!0}},SOti:function(e,t,n){"use strict";n.r(t),n.d(t,{BATCH_STATES:function(){return o.FG},DEFAULT_OPTIONS:function(){return ne},FILE_STATES:function(){return o.FD},MissingUrlError:function(){return ee.PF},UPLOADER_EVENTS:function(){return f},XHR_SENDER_TYPE:function(){return ee.Ch},composeEnhancers:function(){return ce},createUploader:function(){return de},default:function(){return he},getXhrSend:function(){return ee.KZ},send:function(){return ee.lW}});var r=n("3hgs"),o=n("Z6oI");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=e?.state,o=!!r&&s[r];return!!o&&o(e,t,n)},c=(e,t,n,r)=>i(t[e],n,r),u=(e,t)=>{let n=!1;return 0!==t&&t&&(n=e>=t),n},l=(e,t,n,r,a)=>{const s=Object.values(n).flat(),i=u(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=>c(n,e,t,r))),{isFast:i}},d=(e,t,n,r,a,s)=>{const c=0===t.fastAbortThreshold?0:t.fastAbortThreshold||s.fastAbortThreshold,l=u(r[e.id].length,c);return o.kg.debugLog(`abort: doing abort-batch on: ${e.id} (${l?"fast":"normal"} abort)`),l?((e,t)=>{e.items.forEach((e=>{let{id:n}=e;return t[n]?.()}))})(e,n):e.items.forEach((e=>i(e,n,a))),{isFast:l}};var h=()=>e=>(e.update({abortAll:l,abortBatch:d,abortItem:c}),e);const f=(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"}),p=(0,o.ZV)({ITEM_PROGRESS:"ITEM_PROGRESS",BATCH_PROGRESS:"BATCH_PROGRESS"}),g=[o.FD.FINISHED,o.FD.ERROR,o.FD.CANCELLED,o.FD.ABORTED],b=Symbol.for("__rpldy-sstt-proxy__"),m=Symbol.for("__rpldy-sstt-state__"),E=e=>!(0,o.yv)()&&!!e&&!!~Object.getOwnPropertySymbols(e).indexOf(b),v=e=>Array.isArray(e)||(0,o.PO)(e)&&!(e=>(0,o.Ym)()&&e instanceof File||e.name&&e.size&&e.uri)(e),S=(0,o.D8)({withSymbols:!0,predicate:e=>e!==b&&e!==m}),y=e=>!!(0,o.yv)()||e[m].isUpdateable,A=(e,t)=>{(0,o.yv)()||(e[m].isUpdateable=t)},O=(e,t)=>{let n;return v(e)&&(E(e)||(e[b]=!0,n=new Proxy(e,t)),Object.keys(e).forEach((n=>{e[n]=O(e[n],t)}))),n||e},R=e=>E(e)?(0,o.d9)(e,S):e;const I=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e.updateState((e=>{const{batchId:r}=e.items[t]||{batchId:null};n&&delete e.items[t];const o=r?e.itemQueue[r].indexOf(t):-1;~o&&r&&e.itemQueue[r].splice(o,1);const a=e.activeIds.indexOf(t);~a&&e.activeIds.splice(a,1)}))},D=(e,t)=>!!e.getState().items[t],w=e=>g.includes(e.state),T=(0,o.D8)({undefinedOverwrites:!0}),P=(e,t,n,r,a,s)=>{const i=n(t),c=e.getState().batches[i[0].batchId].batchOptions,u=r?.(t,c)||t;return((e,t,n,r,a,s)=>(0,o.sc)(e.trigger,a,t,r).then((e=>(s?.(e),((e,t,n,r)=>{let a=n,s=t;if(r){if(o.kg.debugLog(`uploader.queue: REQUEST_PRE_SEND(${e}) event returned updated items/options`,r),r.items){if(r.items.length!==t.length||!(0,o.sQ)(r.items,t,["id","batchId","recycled"]))throw new Error(`REQUEST_PRE_SEND(${e}) event handlers must return same items with same ids`);s=r.items}r.options&&(a=T({},n,r.options))}return{items:s,options:a,cancelled:!1===r}})(a,n,r,e)))))(e,u,i,c,s,a).then((t=>(t.cancelled||((e,t)=>{if(t.items[0]&&e.getState().batches[t.items[0].batchId]){e.updateState((e=>{t.items.forEach((t=>{w(e.items[t.id])||(e.items[t.id]=t)})),e.batches[t.items[0].batchId].batchOptions=t.options}));const n=e.getState();t.items=t.items.map((e=>n.items[e.id])),t.options=n.batches[t.items[0].batchId].batchOptions}})(e,t),t)))},C=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return(o,a)=>P(o,a,t,n,r,e)},_=C(f.BATCH_START,(e=>e.items),null,(function(){let{batch:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{batch:!1};if(e)throw new Error("BATCH_START event handlers cannot update batch data. Only items & options")})),F=[o.FG.ADDED,o.FG.PROCESSING,o.FG.UPLOADING],B=[o.FG.ABORTED,o.FG.CANCELLED,o.FG.FINISHED,o.FG.ERROR],L=(e,t)=>e.batches[t].batch,N=(e,t)=>{const n=e.getState(),r=n.items[t];return n.batches[r.batchId]},G=(e,t)=>N(e,t).batch,k=(e,t)=>{const n=((e,t)=>L(e.getState(),t))(e,t);n.items.forEach((t=>{let{id:n}=t;return I(e,n,!0)}))},H=(e,t)=>{e.updateState((e=>{delete e.batches[t],delete e.itemQueue[t];const n=e.batchQueue.indexOf(t);~n&&e.batchQueue.splice(n,1);const r=e.batchesStartPending.indexOf(t);~r&&e.batchesStartPending.splice(r,1)}))},x=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:o.FG.FINISHED,a=arguments.length>4?arguments[4]:void 0;e.updateState((e=>{const n=L(e,t);n.state=r,a&&(n.additionalInfo=a)})),U(e,t,n),U(e,t,f.BATCH_FINALIZE)},j=(e,t)=>{o.kg.debugLog("uploady.uploader.batchHelpers: cancelling batch: ",t),x(e,t,f.BATCH_CANCEL,o.FG.CANCELLED),k(e,t),H(e,t)},U=(e,t,n)=>{const r=e.getState(),{batch:o,batchOptions:a}=r.batches[t],s=r.items,i={...R(o),items:o.items.map((e=>{let{id:t}=e;return R(s[t])}))};e.trigger(n,i,R(a))},$=(e,t)=>{const n=L(e.getState(),t);return F.includes(n.state)},q=e=>B.includes(e.state),Q={[o.FD.PENDING]:null,[o.FD.ADDED]:f.ITEM_START,[o.FD.FINISHED]:f.ITEM_FINISH,[o.FD.ERROR]:f.ITEM_ERROR,[o.FD.CANCELLED]:f.ITEM_CANCEL,[o.FD.ABORTED]:f.ITEM_ABORT,[o.FD.UPLOADING]:f.ITEM_PROGRESS},M=e=>!!~g.indexOf(e.state);var 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];if(a.state===o.FD.FINISHED&&t.completed<100){const n=t.file?.size||0;e.handleItemProgress(t,100,n,n)}const{batchOptions:n}=N(e,r);Q[t.state]&&e.trigger(Q[t.state],t,n),M(t)&&(((e,t)=>{e.updateState((e=>{e.batches[t].finishedCounter+=1}))})(e,t.batchId),e.trigger(f.ITEM_FINALIZE,t,n))}I(e,r)})),(e=>{(0,o.nK)((()=>{const t=e.getState();Object.keys(t.batches).forEach((n=>{const{batch:r,finishedCounter:a}=t.batches[n],{orgItemCount:s}=r,i=q(r);s===a&&(i||100===r.completed||(e.updateState((e=>{const t=L(e,n);t.completed=100,t.loaded=t.items.reduce(((e,t)=>{let{loaded:n}=t;return e+n}),0)})),U(e,n,f.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,f.BATCH_FINISH),k(e,n),H(e,n))}))}))})(e),n(e)};const Y=C(f.REQUEST_PRE_SEND,(e=>e),((e,t)=>({items:e,options:t}))),K=e=>{let{allowedItems:t,cancelledResults:n,queue:r,items:a,ids:s,next:i}=e;const c=t.length?Y(r,t):Promise.resolve();let u=n;return c.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?u=s.map((()=>!0)):e.items.some((e=>w(e)))?o.kg.debugLog("uploader.queue: send data contains aborted items - not sending"):((e,t,n)=>{const{items:r,options:a}=t,s=e.getState().batches[r[0].batchId]?.batch;if(s){let t;try{t=e.sender.send(r,s,a)}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:i}=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,r,t),i.then((t=>{const o=r.map((e=>({id:e.id,info:t})));Z(e,o,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,u,i)||(t=i(r)),t}))};const W=(e,t)=>e.getState().activeIds.flat().includes(t),X=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,c=t.batchQueue[s];for(;c&&!a;){if($(e,c))for(a=n[c][i];a&&(W(e,a)||r[a].state!==o.FD.ADDED);)i+=1,a=n[c][i];a||(s+=1,c=t.batchQueue[s],i=0)}return a?[c,i]:null})(e)||[];let s,i=r&&~a?n[r][a]:null;if(i){const{batchOptions:e}=t.batches[r],n=e.maxGroupSize||0;s=e.grouped&&n>1?t.itemQueue[r].slice(a,a+n):[i]}return s})(e);if(n){const r=e.getCurrentActiveCount(),{concurrent:a=!1,maxConcurrent:s=0}=e.getOptions();(!r||a&&r<s)&&(o.kg.debugLog("uploader.processor: Processing next upload - ",{ids:n,currentCount:r}),t=((e,t)=>{let n;return((e,t)=>{const n=G(e,t);return e.getState().batchesStartPending.includes(n.id)})(e,t[0])?n=Promise.resolve(!0):(((e,t)=>{e.updateState((e=>{e.activeIds=e.activeIds.concat(t)}))})(e,t),n=((e,t)=>{const n=G(e,t);return e.getState().currentBatch!==n.id})(e,t[0])?((e,t)=>{const n=G(e,t);return e.updateState((e=>{e.batchesStartPending.push(n.id)})),_(e,n).then((r=>{let{cancelled:o}=r,a=!1;return e.updateState((e=>{const t=e.batchesStartPending.indexOf(n.id);e.batchesStartPending.splice(t,1)})),o||(a=!D(e,t),a||e.updateState((e=>{e.currentBatch=n.id}))),!o&&!a}))})(e,t[0]).then((n=>{let r=!n;return r&&(((e,t)=>{if(D(e,t)){const n=N(e,t),r=n?.batch.id;r?j(e,r):o.kg.debugLog(`uploady.uploader.batchHelpers: cancel batch called for batch already removed (item id = ${t})`)}})(e,t[0]),X(e)),r})).catch((n=>(o.kg.debugLog("uploader.processor: encountered error while preparing batch for request",n),((e,t,n)=>{const r=G(e,t),a=r.id;o.kg.debugLog("uploady.uploader.batchHelpers: failing batch: ",{batch:r}),x(e,a,f.BATCH_ERROR,o.FG.ERROR,n.message),k(e,a),H(e,a)})(e,t[0],n),X(e),!0))):Promise.resolve(!1)),n})(e,n).then((t=>{t||(((e,t,n)=>{const r=e.getState();let o=Object.values(r.items);o=o.filter((e=>t.includes(e.id)&&!w(e))),Promise.all(o.map((t=>{const{batchOptions:n}=N(e,t.id);return e.runCancellable(f.ITEM_START,t,n)}))).then((r=>{let a=r.map(((t,n)=>t?null:((e,t)=>{const n=t.getState().items[e];return n&&!w(n)?n:void 0})(o[n].id,e))).filter(Boolean);return{allowedItems:a,cancelledResults:r,queue:e,items:o,ids:t,next:n}})).then(K)})(e,n,X),a&&X(e))})))}return t};var V=X;const z=e=>(t,n)=>Z(e,[{id:t,info:n}],V);var J=(e,t,n,r,a)=>{const{state:s,update:i}=(e=>{const t={set:(e,r,o)=>(y(n)&&(e[r]=O(o,t)),!0),get:(e,t)=>t===b?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)=>(y(n)&&delete e[t],!0)};(0,o.yv)()||E(e)||Object.defineProperty(e,m,{value:{isUpdateable:!1},configurable:!0});const n=(0,o.yv)()?e:O(e,t);return{state:n,update:e=>{if(!(0,o.yv)()&&y(n))throw new Error("Can't call update on State already being updated!");try{A(n,!0),e(n)}finally{A(n,!1)}return n},unwrap:e=>e?R(e):E(n)?R(n):n}})({itemQueue:{},batchQueue:[],currentBatch:null,batchesStartPending:[],batches:{},items:{},activeIds:[],aborts:{}}),c=()=>s,u=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}=G(e,t.id);r===n&&e.updateState((e=>{const n=L(e,r),o=n.items.findIndex((e=>{let{id:n}=e;return n===t.id}));~o&&n.items.splice(o,1)}))}})(h,e),u((t=>{t.items[e.id]=e}))},d=(e,n,r,o)=>{s.items[e.id]&&(u((t=>{const a=t.items[e.id];a.loaded=r,a.completed=n,a.total=o})),t(f.ITEM_PROGRESS,c().items[e.id]))};r.on(p.ITEM_PROGRESS,d),r.on(p.BATCH_PROGRESS,(e=>{const t=s.batches[e.id]?.batch.items;if(t){const[n,r]=t.reduce(((e,t)=>{let{id:n}=t;const{loaded:r,file:o}=s.items[n],a=o?.size||r||1;return e[0]+=r,e[1]+=a,e}),[0,0]);u((t=>{const o=t.batches[e.id].batch;o.total=r,o.loaded=n,o.completed=n/r})),U(h,e.id,f.BATCH_PROGRESS)}}));const h={uploaderId:a,getOptions:()=>e,getCurrentActiveCount:()=>s.activeIds.length,getState:c,updateState:u,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:d,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})`),c().batches[e]&&((e,t)=>{e.updateState((e=>{const{items:n}=L(e,t);delete e.batches[t],delete e.itemQueue[t];const r=e.batchQueue.indexOf(t);~r&&e.batchQueue.splice(r,1),e.currentBatch===t&&(e.currentBatch=null),n.forEach((t=>{let{id:n}=t;delete e.items[n];const r=e.activeIds.indexOf(n);~r&&e.activeIds.splice(r,1)}))}))})(h,e)}))}};return(0,o.Ym)()&&o.kg.isDebugOn()&&(window[`__rpldy_${a}_queue_state`]=h),{updateState:u,getState:h.getState,runCancellable:h.runCancellable,uploadBatch:(e,t)=>{t&&u((n=>{n.batches[e.id].batchOptions=t})),V(h)},addBatch:(e,t)=>(u((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(l),L(s,e.id)),abortItem:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return((e,t)=>{const n=e.getOptions().abortItem;(0,o.kG)(!!n,"Abort Item method not provided yet abortItem was called");const r=e.getState();return n(t,r.items,r.aborts,z(e))})(h,...t)},abortBatch:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return((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=a?.batch;if(s&&!q(s)){x(e,t,f.BATCH_ABORT,o.FG.ABORTED);const{isFast:i}=n(s,a.batchOptions,r.aborts,r.itemQueue,z(e),e.getOptions());i&&e.clearBatchUploads(s.id)}})(h,...t)},abortAll:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(e=>{const t=e.getOptions().abortAll;(0,o.kG)(!!t,"Abort All method not provided yet abortAll was called"),e.trigger(f.ALL_ABORT);const n=e.getState(),{isFast:r}=t(n.items,n.aborts,n.itemQueue,z(e),e.getOptions());r&&e.clearAllUploads()})(h,...t)},clearPendingBatches:()=>{(e=>{const t=e.getState().batches;Object.keys(t).filter((e=>t[e].batch.state===o.FG.PENDING)).forEach((t=>{k(e,t),H(e,t)}))})(h)},uploadPendingBatches:e=>{((e,t)=>{e.updateState((e=>{Object.keys(e.batches).forEach((n=>{const r=e.batches[n],{batch:a,batchOptions:s}=r;a.state===o.FG.PENDING&&(a.items.forEach((e=>{e.state=o.FD.ADDED})),a.state=o.FG.ADDED,r.batchOptions=(0,o.TS)({},s,t))}))}))})(h,e),V(h)},cancelBatch:e=>j(h,e.id)}},ee=n("8IkK");const te=()=>!0,ne=(0,o.ZV)({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});var re=()=>{const{trigger:e,target:t}=(0,r.ZP)({send:(t,n,r)=>{const a=r.destination,s=a?.url,i=(0,o.P2)((r=>((e,t,n,r)=>{((e,t,n,r,a)=>{e.forEach((e=>{o.kg.debugLog(`uploady.uploader.processor: file: ${e.id} progress event: loaded(${n}) - completed(${t})`),a(p.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(p.BATCH_PROGRESS,t)})(t,n,r,e)),50,!0);return((0,o.mf)(r.send)?r.send:ee.ZP)(t,s,{method:a?.method||r.method||ne.method,paramName:a?.filesParamName||r.inputFieldName||"file",params:{...r.params,...a?.params},forceJsonResponse:r.forceJsonResponse,withCredentials:r.withCredentials,formatGroupParamName:r.formatGroupParamName,headers:a?.headers,sendWithFormData:r.sendWithFormData,formatServerResponse:r.formatServerResponse,formDataAllowUndefined:r.formDataAllowUndefined,isSuccessfulCall:r.isSuccessfulCall},i)}},Object.values(p));return t};const oe=(0,o.Ym)()&&"FileList"in window,ae=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e;return(0,o.yv)()||(t<3&&E(e)?n=R(e):t<3&&v(e)&&(n=Array.isArray(e)?e.map((e=>ae(e,t+1))):Object.keys(e).reduce(((n,r)=>(n[r]=ae(e[r],t+1),n)),{}))),n};let se=0;var ie=(e,t,n,r)=>{const a=re(),s=J(n,e,t,a,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}`,a=(e=>oe&&e instanceof FileList||"[object FileList]"===e.toString())(e),s=Array.isArray(e)||a?e:[e],i=!n.autoUpload;return((e,t,n,r)=>{const a=r?Array.prototype.map.call(t,(e=>(0,o.$e)(e)?e.file||e.url:e)):[];return Promise.all(Array.prototype.map.call(t,((e,t)=>{const n=(r||te)(a[t],t,a);return(0,o.tI)(n)?n.then((t=>!!t&&e)):!!n&&e}))).then((t=>t.filter(Boolean).map((t=>(0,o.Yc)(t,e,n)))))})(r,s,i,n.fileFilter).then((e=>({id:r,uploaderId:t,items:e,state:i?o.FG.PENDING:o.FG.ADDED,completed:0,loaded:0,orgItemCount:e.length,additionalInfo:null})))})(e,r,t).then((e=>{let n;if(e.items.length){const a=s.addBatch(e,t);n=s.runCancellable(f.BATCH_ADD,a,t).then((e=>(e?s.cancelBatch(a):(o.kg.debugLog(`uploady.uploader [${r}]: new items added - auto upload =\n ${String(t.autoUpload)}`,a.items),t.autoUpload&&s.uploadBatch(a)),a)))}else o.kg.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)}}},ce=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.reduce(((e,t)=>t(e,...r)||e),e)}};const ue=Object.values(f);let le=0;var de=e=>{le+=1;const t=`uploader-${le}`;let n=!1;const a={};o.kg.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=()=>{p.clearPendingBatches()};let{trigger:c,target:u}=(0,r.ZP)({id:t,update:e=>(s=(0,o.TS)({},s,e),u),add:(e,t)=>{const n=(0,o.TS)({},s,t);return n.clearPendingOnAdd&&i(),p.addNewBatch(e,n).then((()=>{o.kg.debugLog("uploady.uploader: finished adding file data to be processed")}))},upload:e=>{p.processPendingBatches(e)},abort:e=>{p.abort(e)},abortBatch:e=>{p.abortBatch(e)},getOptions:()=>(0,o.d9)(s),clearPending:i,registerExtension:(e,t)=>{(0,o.kG)(n,"Uploady - uploader extensions can only be registered by enhancers"),(0,o.kG)(!a[e],"Uploady - uploader extension by this name [%s] already exists",e),o.kg.debugLog(`uploady.uploader: registering extension: ${e.toString()}`,t),a[e]=t},getExtension:e=>a[e]},ue,{canAddEvents:!1,canRemoveEvents:!1});const l=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(ae)));return c(e,a)},d=(0,o.tq)(l),f=((e,t,n,r)=>{const o=t.enhancer?(a=t.enhancer,ce(h(),a)):h();var a;r(!0);const s=o(e,n);return r(!1),s||e})(u,s,l,(e=>{n=e})),p=ie(l,d,s,f.id);return(0,o.ZV)(f)},he=de}},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=function(t,n,o,a){if(!n){var s=1/0;for(l=0;l<e.length;l++){n=e[l][0],o=e[l][1],a=e[l][2];for(var i=!0,c=0;c<n.length;c++)(!1&a||s>=a)&&Object.keys(r.O).every((function(e){return r.O[e](n[c])}))?n.splice(c--,1):(i=!1,a<s&&(s=a));if(i){e.splice(l--,1);var u=o();void 0!==u&&(t=u)}}return t}a=a||0;for(var l=e.length;l>0&&e[l-1][2]>a;l--)e[l]=e[l-1];e[l]=[n,o,a]},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(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=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e={321:0};r.O.j=function(t){return 0===e[t]};var t=function(t,n){var o,a,s=n[0],i=n[1],c=n[2],u=0;if(s.some((function(t){return 0!==e[t]}))){for(o in i)r.o(i,o)&&(r.m[o]=i[o]);if(c)var l=c(r)}for(t&&t(n);u<s.length;u++)a=s[u],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(l)},n=self.webpackChunkrpldy=self.webpackChunkrpldy||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}(),r.O(void 0,[429],(function(){return r("3hgs")})),r.O(void 0,[429],(function(){return r("Z6oI")})),r.O(void 0,[429],(function(){return r("8IkK")}));var o=r.O(void 0,[429],(function(){return r("SOti")}));return r.O(o)}()})); | ||
//# sourceMappingURL=rpldy-core.umd.min.js.map |
{ | ||
"version": "1.6.1", | ||
"version": "1.7.0-rc.0", | ||
"name": "@rpldy/uploader", | ||
@@ -29,14 +29,14 @@ "description": "the processing and queuing engine for react-uploady", | ||
"scripts": { | ||
"build": "node ../../../scripts/build.js" | ||
"build": "node ../../../scripts/build.mjs" | ||
}, | ||
"dependencies": { | ||
"@rpldy/abort": "^1.6.1", | ||
"@rpldy/life-events": "^1.6.1", | ||
"@rpldy/raw-uploader": "^1.6.1", | ||
"@rpldy/sender": "^1.6.1", | ||
"@rpldy/shared": "^1.6.1", | ||
"@rpldy/simple-state": "^1.6.1" | ||
"@rpldy/abort": "^1.7.0-rc.0", | ||
"@rpldy/life-events": "^1.7.0-rc.0", | ||
"@rpldy/raw-uploader": "^1.7.0-rc.0", | ||
"@rpldy/sender": "^1.7.0-rc.0", | ||
"@rpldy/shared": "^1.7.0-rc.0", | ||
"@rpldy/simple-state": "^1.7.0-rc.0" | ||
}, | ||
"devDependencies": { | ||
"flow-bin": "^0.218.0" | ||
"flow-bin": "^0.223.2" | ||
}, | ||
@@ -46,3 +46,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "7ee476c3a37f9ae33e37427438cb7bc24ae4125c" | ||
"gitHead": "21fc1992774e791d46890505b792c7d7e8dfbe79" | ||
} |
@@ -54,3 +54,12 @@ import { Trigger } from "@rpldy/shared"; | ||
export { SendOptions } from "@rpldy/sender"; | ||
export { FileFilterMethod, Trigger } from "@rpldy/shared"; | ||
export { | ||
Batch, | ||
BatchItem, | ||
FileFilterMethod, | ||
Trigger, | ||
FILE_STATES, | ||
BATCH_STATES, | ||
} from "@rpldy/shared"; | ||
export { UploadAddMethod }; |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
161147
2987
1
Updated@rpldy/abort@^1.7.0-rc.0
Updated@rpldy/sender@^1.7.0-rc.0
Updated@rpldy/shared@^1.7.0-rc.0