diff --git a/dist/vue-simple-uploader.es.js b/dist/vue-simple-uploader.es.js index 0dadf40..7786901 100644 --- a/dist/vue-simple-uploader.es.js +++ b/dist/vue-simple-uploader.es.js @@ -1,8 +1,8 @@ -import{ref as e,inject as t,onMounted as i,nextTick as s,withDirectives as r,openBlock as n,createBlock as o,renderSlot as a,vShow as l,onBeforeUnmount as u,createVNode as h,createTextVNode as p,getCurrentInstance as f,computed as d,watch as c,onUnmounted as v,toDisplayString as g,resolveComponent as m,Fragment as S,renderList as y,provide as _,reactive as b,withCtx as k}from"vue";function R(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var E={exports:{}},F=E.exports=function e(t,i,s){function r(o,a){if(!i[o]){if(!t[o]){if(!a&&R)return R(o);if(n)return n(o,!0);throw new Error("Cannot find module '"+o+"'")}var l=i[o]={exports:{}};t[o][0].call(l.exports,(function(e){var i=t[o][1][e];return r(i||e)}),l,l.exports,e,t,i,s)}return i[o].exports}for(var n=R,o=0;o-1?t=n.SUCCESS:this.uploader.opts.permanentErrors.indexOf(this.xhr.status)>-1||!e&&this.retries>=this.uploader.opts.maxChunkRetries?t=n.ERROR:(this.abort(),t=n.PENDING);var i=this.processedState;return i&&i.err&&(t=n.ERROR),t}return n.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===n.SUCCESS||e===n.ERROR?1:e===n.PENDING?0:this.total>0?this.loaded/this.total:0},sizeUploaded:function(){var e=this.endByte-this.startByte;return this.status()!==n.SUCCESS&&(e=this.progress()*e),e},prepareXhrRequest:function(e,t,i,r){var n=s.evalOpts(this.uploader.opts.query,this.file,this,t);n=s.extend(this.getParams(),n),n=this.uploader.opts.processParams(n,this.file,this,t);var o=s.evalOpts(this.uploader.opts.target,this.file,this,t),a=null;if("GET"===e||"octet"===i){var l=[];s.each(n,(function(e,t){l.push([encodeURIComponent(t),encodeURIComponent(e)].join("="))})),o=this.getTarget(o,l),a=r||null}else a=new FormData,s.each(n,(function(e,t){a.append(t,e)})),void 0!==r&&a.append(this.uploader.opts.fileParameterName,r,this.file.name);return this.xhr.open(e,o,!0),this.xhr.withCredentials=this.uploader.opts.withCredentials,s.each(s.evalOpts(this.uploader.opts.headers,this.file,this,t),(function(e,t){this.xhr.setRequestHeader(t,e)}),this),a}}),t.exports=r},{"./utils":5}],2:[function(e,t,i){var s=e("./utils").each,r={_eventData:null,on:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]||(this._eventData[e]=[]);var i=!1;s(this._eventData[e],(function(e){if(e===t)return i=!0,!1})),i||this._eventData[e].push(t)},off:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]&&this._eventData[e].length&&(t?s(this._eventData[e],(function(i,s){if(i===t)return this._eventData[e].splice(s,1),!1}),this):this._eventData[e]=[])},trigger:function(e){if(this._eventData||(this._eventData={}),!this._eventData[e])return!0;var t=this._eventData[e].slice.call(arguments,1),i=!1;return s(this._eventData[e],(function(e){i=!1===e.apply(this,t)||i}),this),!i}};t.exports=r},{"./utils":5}],3:[function(e,t,i){var s=e("./utils"),r=e("./event"),n=e("./file"),o=e("./chunk"),a="0.6.0",l="undefined"==typeof window,u=!l&&window.navigator.msPointerEnabled,h=function(){if(l)return!1;var e="slice",t=s.isDefined(window.File)&&s.isDefined(window.Blob)&&s.isDefined(window.FileList),i=null;return t&&(i=window.Blob.prototype,s.each(["slice","webkitSlice","mozSlice"],(function(t){if(i[t])return e=t,!1})),t=!!i[e]),t&&(f.sliceName=e),i=null,t}(),p=function(){if(l)return!1;var e=window.document.createElement("input");e.type="file";var t="webkitdirectory"in e||"directory"in e;return e=null,t}();function f(e){this.support=h,this.support&&(this.supportDirectory=p,s.defineNonEnumerable(this,"filePaths",{}),this.opts=s.extend({},f.defaults,e||{}),this.preventEvent=s.bind(this._preventEvent,this),n.call(this,this))}var d=function(e,t,i,s,r){r.readFinished(e.file[f.sliceName](i,s,t))};f.version=a,f.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,preprocess:null,method:"multipart",testMethod:"GET",uploadMethod:"POST",prioritizeFirstAndLastChunk:!1,allowDuplicateUploads:!1,target:"/",testChunks:!0,generateUniqueIdentifier:null,maxChunkRetries:0,chunkRetryInterval:null,permanentErrors:[404,415,500,501],successStatuses:[200,201,202],onDropStopPropagation:!1,initFileFn:null,readFileFn:d,checkChunkUploadedByResponse:null,initialPaused:!1,processResponse:function(e,t){t(null,e)},processParams:function(e){return e}},f.utils=s,f.event=r,f.File=n,f.Chunk=o,f.prototype=s.extend({},n.prototype),s.extend(f.prototype,r),s.extend(f.prototype,{constructor:f,_trigger:function(e){var t=s.toArray(arguments),i=!this.trigger.apply(this,arguments);return"catchAll"!==e&&(t.unshift("catchAll"),i=!this.trigger.apply(this,t)||i),!i},_triggerAsync:function(){var e=arguments;s.nextTick((function(){this._trigger.apply(this,e)}),this)},addFiles:function(e,t){var i=[],r=this.fileList.length;s.each(e,(function(e){if((!u||u&&e.size>0)&&(e.size%4096!=0||"."!==e.name&&"."!==e.fileName)){var s=this.generateUniqueIdentifier(e);if(this.opts.allowDuplicateUploads||!this.getFromUniqueIdentifier(s)){var r=new n(this,e,this);r.uniqueIdentifier=s,this._trigger("fileAdded",r,t)?i.push(r):n.prototype.removeFile.call(this,r)}}}),this);var o=this.fileList.slice(r);this._trigger("filesAdded",i,o,t)?(s.each(i,(function(e){this.opts.singleFile&&this.files.length>0&&this.removeFile(this.files[0]),this.files.push(e)}),this),this._trigger("filesSubmitted",i,o,t)):s.each(o,(function(e){n.prototype.removeFile.call(this,e)}),this)},addFile:function(e,t){this.addFiles([e],t)},cancel:function(){for(var e=this.fileList.length-1;e>=0;e--)this.fileList[e].cancel()},removeFile:function(e){n.prototype.removeFile.call(this,e),this._trigger("fileRemoved",e)},generateUniqueIdentifier:function(e){var t=this.opts.generateUniqueIdentifier;if(s.isFunction(t))return t(e);var i=e.relativePath||e.webkitRelativePath||e.fileName||e.name;return e.size+"-"+i.replace(/[^0-9a-zA-Z_-]/gim,"")},getFromUniqueIdentifier:function(e){var t=!1;return s.each(this.files,(function(i){if(i.uniqueIdentifier===e)return t=i,!1})),t},uploadNextChunk:function(e){var t=!1,i=o.STATUS.PENDING,r=this.uploader.opts.checkChunkUploadedByResponse;if(this.opts.prioritizeFirstAndLastChunk&&(s.each(this.files,(function(e){if(!e.paused&&(!r||e._firstResponse||!e.isUploading()))return e.chunks.length&&e.chunks[0].status()===i?(e.chunks[0].send(),t=!0,!1):e.chunks.length>1&&e.chunks[e.chunks.length-1].status()===i?(e.chunks[e.chunks.length-1].send(),t=!0,!1):void 0})),t))return t;if(s.each(this.files,(function(e){if(!e.paused){if(r&&!e._firstResponse&&e.isUploading())return;s.each(e.chunks,(function(e){if(e.status()===i)return e.send(),t=!0,!1}))}if(t)return!1})),t)return!0;var n=!1;return s.each(this.files,(function(e){if(!e.isComplete())return n=!0,!1})),n||e||!this.files.length||this._triggerAsync("complete"),n},upload:function(e){var t=this._shouldUploadNext();if(!1!==t){!e&&this._trigger("uploadStart");for(var i=!1,s=1;s<=this.opts.simultaneousUploads-t&&((i=this.uploadNextChunk(!e)||i)||!e);s++);i||e||this._triggerAsync("complete")}},_shouldUploadNext:function(){var e=0,t=!0,i=this.opts.simultaneousUploads,r=o.STATUS.UPLOADING;return s.each(this.files,(function(n){return s.each(n.chunks,(function(s){if(s.status()===r&&++e>=i)return t=!1,!1})),t})),t&&e},assignBrowse:function(e,t,i,r){void 0===e.length&&(e=[e]),s.each(e,(function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),s.extend(n.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(n),e.addEventListener("click",(function(t){"label"!==e.tagName.toLowerCase()&&n.click()}),!1)),this.opts.singleFile||i||n.setAttribute("multiple","multiple"),t&&n.setAttribute("webkitdirectory","webkitdirectory"),r&&s.each(r,(function(e,t){n.setAttribute(t,e)}));var o=this;n.addEventListener("change",(function(e){o._trigger(e.type,e),e.target.value&&(o.addFiles(e.target.files,e),e.target.value="")}),!1)}),this)},onDrop:function(e){this._trigger(e.type,e),this.opts.onDropStopPropagation&&e.stopPropagation(),e.preventDefault(),this._parseDataTransfer(e.dataTransfer,e)},_parseDataTransfer:function(e,t){e.items&&e.items[0]&&e.items[0].webkitGetAsEntry?this.webkitReadDataTransfer(e,t):this.addFiles(e.files,t)},webkitReadDataTransfer:function(e,t){var i=this,r=e.items.length,n=[];function o(e){e.readEntries((function(t){t.length?(r+=t.length,s.each(t,(function(e){if(e.isFile){var t=e.fullPath;e.file((function(e){a(e,t)}),l)}else e.isDirectory&&o(e.createReader())})),o(e)):u()}),l)}function a(e,t){e.relativePath=t.substring(1),n.push(e),u()}function l(e){throw e}function u(){0==--r&&i.addFiles(n,t)}s.each(e.items,(function(e){var t=e.webkitGetAsEntry();t?t.isFile?a(e.getAsFile(),t.fullPath):o(t.createReader()):u()}))},_assignHelper:function(e,t,i){void 0===e.length&&(e=[e]);var r=i?"removeEventListener":"addEventListener";s.each(e,(function(e){s.each(t,(function(t,i){e[r](i,t,!1)}),this)}),this)},_preventEvent:function(e){s.preventEvent(e),this._trigger(e.type,e)},assignDrop:function(e){this._onDrop=s.bind(this.onDrop,this),this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop})},unAssignDrop:function(e){this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop},!0),this._onDrop=null}}),t.exports=f},{"./chunk":1,"./event":2,"./file":4,"./utils":5}],4:[function(e,t,i){var s=e("./utils"),r=e("./chunk");function n(e,t,i){s.defineNonEnumerable(this,"uploader",e),this.isRoot=this.isFolder=e===this,s.defineNonEnumerable(this,"parent",i||null),s.defineNonEnumerable(this,"files",[]),s.defineNonEnumerable(this,"fileList",[]),s.defineNonEnumerable(this,"chunks",[]),s.defineNonEnumerable(this,"_errorFiles",[]),s.defineNonEnumerable(this,"file",null),this.id=s.uid(),this.isRoot||!t?this.file=null:s.isString(t)?(this.isFolder=!0,this.file=null,this.path=t,this.parent.path&&(t=t.substr(this.parent.path.length)),this.name="/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t):(this.file=t,this.fileType=this.file.type,this.name=t.fileName||t.name,this.size=t.size,this.relativePath=t.relativePath||t.webkitRelativePath||this.name,this._parseFile()),this.paused=e.opts.initialPaused,this.error=!1,this.allError=!1,this.aborted=!1,this.completed=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevUploadedSize=0,this._prevProgress=0,this.bootstrap()}function o(e){var t=[],i=e.split("/"),s=i.length,r=1;if(i.splice(s-1,1),s--,i.length)for(;r<=s;)t.push(i.slice(0,r++).join("/")+"/");return t}s.extend(n.prototype,{_parseFile:function(){var e=o(this.relativePath);if(e.length){var t=this.uploader.filePaths;s.each(e,(function(i,s){var r=t[i];r||(r=new n(this.uploader,i,this.parent),t[i]=r,this._updateParentFileList(r)),this.parent=r,r.files.push(this),e[s+1]||r.fileList.push(this)}),this)}else this._updateParentFileList()},_updateParentFileList:function(e){e||(e=this);var t=this.parent;t&&t.fileList.push(e)},_eachAccess:function(e,t){this.isFolder?s.each(this.files,(function(t,i){return e.call(this,t,i)}),this):t.call(this,this)},bootstrap:function(){if(!this.isFolder){var e=this.uploader.opts;s.isFunction(e.initFileFn)&&e.initFileFn.call(this,this),this.abort(!0),this._resetError(),this._prevProgress=0;for(var t=e.forceChunkSize?Math.ceil:Math.floor,i=Math.max(t(this.size/e.chunkSize),1),n=0;n=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(e,t,i){var s=this.uploader,n=r.STATUS,o=this,a=this.getRoot(),l=function(){o._measureSpeed(),s._trigger("fileProgress",a,o,e),o._lastProgressCallback=Date.now()};switch(t){case n.PROGRESS:this._checkProgress()&&l();break;case n.ERROR:this._error(),this.abort(!0),s._trigger("fileError",a,this,i,e);break;case n.SUCCESS:if(this._updateUploadedChunks(i,e),this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var u=Date.now()-this._lastProgressCallback;u0?e/t:this.isComplete()?1:0)}),(function(){if(this.error)i=1;else{if(1===this.chunks.length)return this._prevProgress=Math.max(this._prevProgress,this.chunks[0].progress()),void(i=this._prevProgress);var e=0;s.each(this.chunks,(function(t){e+=t.progress()*(t.endByte-t.startByte)}));var t=e/this.size;this._prevProgress=Math.max(this._prevProgress,t>.9999?1:t),i=this._prevProgress}})),i},getSize:function(){var e=0;return this._eachAccess((function(t){e+=t.size}),(function(){e+=this.size})),e},getFormatSize:function(){var e=this.getSize();return s.formatSize(e)},getRoot:function(){if(this.isRoot)return this;for(var e=this.parent;e;){if(e.parent===this.uploader)return e;e=e.parent}return this},sizeUploaded:function(){var e=0;return this._eachAccess((function(t){e+=t.sizeUploaded()}),(function(){s.each(this.chunks,(function(t){e+=t.sizeUploaded()}))})),e},timeRemaining:function(){var e=0,t=0,i=0;return this._eachAccess((function(r,n){r.paused||r.error||(t+=r.size-r.sizeUploaded(),i+=r.averageSpeed),n===this.files.length-1&&(e=s(t,i))}),(function(){if(this.paused||this.error)e=0;else{var t=this.size-this.sizeUploaded();e=s(t,this.averageSpeed)}})),e;function s(e,t){return e&&!t?Number.POSITIVE_INFINITY:e||t?Math.floor(e/t):0}},removeFile:function(e){if(e.isFolder)for(;e.files.length;){var t=e.files[e.files.length-1];this._removeFile(t)}this._removeFile(e)},_delFilePath:function(e){e.path&&this.filePaths&&delete this.filePaths[e.path],s.each(e.fileList,(function(e){this._delFilePath(e)}),this)},_removeFile:function(e){if(!e.isFolder){s.each(this.files,(function(t,i){if(t===e)return this.files.splice(i,1),!1}),this),e.abort();for(var t,i=e.parent;i&&i!==this;)t=i.parent,i._removeFile(e),i=t}e.parent===this&&s.each(this.fileList,(function(t,i){if(t===e)return this.fileList.splice(i,1),!1}),this),this.isRoot||!this.isFolder||this.files.length||(this.parent._removeFile(this),this.uploader._delFilePath(this)),e.parent=null},getType:function(){return this.isFolder?"folder":this.file.type&&this.file.type.split("/")[1]},getExtension:function(){return this.isFolder?"":this.name.substr(2+(~-this.name.lastIndexOf(".")>>>0)).toLowerCase()}}),t.exports=n},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var s=Object.prototype,r=Array.prototype,n=s.toString,o=function(e){return"[object Function]"===n.call(e)},a=Array.isArray||function(e){return"[object Array]"===n.call(e)},l=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===s},u=0,h={uid:function(){return++u},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(h.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),r.slice.call(e,t,i)},isPlainObject:l,isFunction:o,isArray:a,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(h.isDefined(e.length))for(var s=0,r=e.length;s-1?t=n.SUCCESS:this.uploader.opts.permanentErrors.indexOf(this.xhr.status)>-1||!e&&this.retries>=this.uploader.opts.maxChunkRetries?t=n.ERROR:(this.abort(),t=n.PENDING);var i=this.processedState;return i&&i.err&&(t=n.ERROR),t}return n.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===n.SUCCESS||e===n.ERROR?1:e===n.PENDING?0:this.total>0?this.loaded/this.total:0},sizeUploaded:function(){var e=this.endByte-this.startByte;return this.status()!==n.SUCCESS&&(e=this.progress()*e),e},prepareXhrRequest:function(e,t,i,r){var n=s.evalOpts(this.uploader.opts.query,this.file,this,t);n=s.extend(this.getParams(),n),n=this.uploader.opts.processParams(n,this.file,this,t);var o=s.evalOpts(this.uploader.opts.target,this.file,this,t),a=null;if("GET"===e||"octet"===i){var l=[];s.each(n,(function(e,t){l.push([encodeURIComponent(t),encodeURIComponent(e)].join("="))})),o=this.getTarget(o,l),a=r||null}else a=new FormData,s.each(n,(function(e,t){a.append(t,e)})),void 0!==r&&a.append(this.uploader.opts.fileParameterName,r,this.file.name);return this.xhr.open(e,o,!0),this.xhr.withCredentials=this.uploader.opts.withCredentials,s.each(s.evalOpts(this.uploader.opts.headers,this.file,this,t),(function(e,t){this.xhr.setRequestHeader(t,e)}),this),a}}),t.exports=r},{"./utils":5}],2:[function(e,t,i){var s=e("./utils").each,r={_eventData:null,on:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]||(this._eventData[e]=[]);var i=!1;s(this._eventData[e],(function(e){if(e===t)return i=!0,!1})),i||this._eventData[e].push(t)},off:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]&&this._eventData[e].length&&(t?s(this._eventData[e],(function(i,s){if(i===t)return this._eventData[e].splice(s,1),!1}),this):this._eventData[e]=[])},trigger:function(e){if(this._eventData||(this._eventData={}),!this._eventData[e])return!0;var t=this._eventData[e].slice.call(arguments,1),i=!1;return s(this._eventData[e],(function(e){i=!1===e.apply(this,t)||i}),this),!i}};t.exports=r},{"./utils":5}],3:[function(e,t,i){var s=e("./utils"),r=e("./event"),n=e("./file"),o=e("./chunk"),a="0.6.0",l="undefined"==typeof window,u=!l&&window.navigator.msPointerEnabled,h=function(){if(l)return!1;var e="slice",t=s.isDefined(window.File)&&s.isDefined(window.Blob)&&s.isDefined(window.FileList),i=null;return t&&(i=window.Blob.prototype,s.each(["slice","webkitSlice","mozSlice"],(function(t){if(i[t])return e=t,!1})),t=!!i[e]),t&&(f.sliceName=e),i=null,t}(),p=function(){if(l)return!1;var e=window.document.createElement("input");e.type="file";var t="webkitdirectory"in e||"directory"in e;return e=null,t}();function f(e){this.support=h,this.support&&(this.supportDirectory=p,s.defineNonEnumerable(this,"filePaths",{}),this.opts=s.extend({},f.defaults,e||{}),this.preventEvent=s.bind(this._preventEvent,this),n.call(this,this))}var d=function(e,t,i,s,r){r.readFinished(e.file[f.sliceName](i,s,t))};f.version=a,f.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,preprocess:null,method:"multipart",testMethod:"GET",uploadMethod:"POST",prioritizeFirstAndLastChunk:!1,allowDuplicateUploads:!1,target:"/",testChunks:!0,generateUniqueIdentifier:null,maxChunkRetries:0,chunkRetryInterval:null,permanentErrors:[404,415,500,501],successStatuses:[200,201,202],onDropStopPropagation:!1,initFileFn:null,readFileFn:d,checkChunkUploadedByResponse:null,initialPaused:!1,processResponse:function(e,t){t(null,e)},processParams:function(e){return e}},f.utils=s,f.event=r,f.File=n,f.Chunk=o,f.prototype=s.extend({},n.prototype),s.extend(f.prototype,r),s.extend(f.prototype,{constructor:f,_trigger:function(e){var t=s.toArray(arguments),i=!this.trigger.apply(this,arguments);return"catchAll"!==e&&(t.unshift("catchAll"),i=!this.trigger.apply(this,t)||i),!i},_triggerAsync:function(){var e=arguments;s.nextTick((function(){this._trigger.apply(this,e)}),this)},addFiles:function(e,t){var i=[],r=this.fileList.length;s.each(e,(function(e){if((!u||u&&e.size>0)&&(e.size%4096!=0||"."!==e.name&&"."!==e.fileName)){var s=this.generateUniqueIdentifier(e);if(this.opts.allowDuplicateUploads||!this.getFromUniqueIdentifier(s)){var r=new n(this,e,this);r.uniqueIdentifier=s,this._trigger("fileAdded",r,t)?i.push(r):n.prototype.removeFile.call(this,r)}}}),this);var o=this.fileList.slice(r);this._trigger("filesAdded",i,o,t)?(s.each(i,(function(e){this.opts.singleFile&&this.files.length>0&&this.removeFile(this.files[0]),this.files.push(e)}),this),this._trigger("filesSubmitted",i,o,t)):s.each(o,(function(e){n.prototype.removeFile.call(this,e)}),this)},addFile:function(e,t){this.addFiles([e],t)},cancel:function(){for(var e=this.fileList.length-1;e>=0;e--)this.fileList[e].cancel()},removeFile:function(e){n.prototype.removeFile.call(this,e),this._trigger("fileRemoved",e)},generateUniqueIdentifier:function(e){var t=this.opts.generateUniqueIdentifier;if(s.isFunction(t))return t(e);var i=e.relativePath||e.webkitRelativePath||e.fileName||e.name;return e.size+"-"+i.replace(/[^0-9a-zA-Z_-]/gim,"")},getFromUniqueIdentifier:function(e){var t=!1;return s.each(this.files,(function(i){if(i.uniqueIdentifier===e)return t=i,!1})),t},uploadNextChunk:function(e){var t=!1,i=o.STATUS.PENDING,r=this.uploader.opts.checkChunkUploadedByResponse;if(this.opts.prioritizeFirstAndLastChunk&&(s.each(this.files,(function(e){if(!e.paused&&(!r||e._firstResponse||!e.isUploading()))return e.chunks.length&&e.chunks[0].status()===i?(e.chunks[0].send(),t=!0,!1):e.chunks.length>1&&e.chunks[e.chunks.length-1].status()===i?(e.chunks[e.chunks.length-1].send(),t=!0,!1):void 0})),t))return t;if(s.each(this.files,(function(e){if(!e.paused){if(r&&!e._firstResponse&&e.isUploading())return;s.each(e.chunks,(function(e){if(e.status()===i)return e.send(),t=!0,!1}))}if(t)return!1})),t)return!0;var n=!1;return s.each(this.files,(function(e){if(!e.isComplete())return n=!0,!1})),n||e||!this.files.length||this._triggerAsync("complete"),n},upload:function(e){var t=this._shouldUploadNext();if(!1!==t){!e&&this._trigger("uploadStart");for(var i=!1,s=1;s<=this.opts.simultaneousUploads-t&&((i=this.uploadNextChunk(!e)||i)||!e);s++);i||e||this._triggerAsync("complete")}},_shouldUploadNext:function(){var e=0,t=!0,i=this.opts.simultaneousUploads,r=o.STATUS.UPLOADING;return s.each(this.files,(function(n){return s.each(n.chunks,(function(s){if(s.status()===r&&++e>=i)return t=!1,!1})),t})),t&&e},assignBrowse:function(e,t,i,r){void 0===e.length&&(e=[e]),s.each(e,(function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),s.extend(n.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(n),e.addEventListener("click",(function(t){"label"!==e.tagName.toLowerCase()&&n.click()}),!1)),this.opts.singleFile||i||n.setAttribute("multiple","multiple"),t&&n.setAttribute("webkitdirectory","webkitdirectory"),r&&s.each(r,(function(e,t){n.setAttribute(t,e)}));var o=this;n.addEventListener("change",(function(e){o._trigger(e.type,e),e.target.value&&(o.addFiles(e.target.files,e),e.target.value="")}),!1)}),this)},onDrop:function(e){this._trigger(e.type,e),this.opts.onDropStopPropagation&&e.stopPropagation(),e.preventDefault(),this._parseDataTransfer(e.dataTransfer,e)},_parseDataTransfer:function(e,t){e.items&&e.items[0]&&e.items[0].webkitGetAsEntry?this.webkitReadDataTransfer(e,t):this.addFiles(e.files,t)},webkitReadDataTransfer:function(e,t){var i=this,r=e.items.length,n=[];function o(e){e.readEntries((function(t){t.length?(r+=t.length,s.each(t,(function(e){if(e.isFile){var t=e.fullPath;e.file((function(e){a(e,t)}),l)}else e.isDirectory&&o(e.createReader())})),o(e)):u()}),l)}function a(e,t){e.relativePath=t.substring(1),n.push(e),u()}function l(e){throw e}function u(){0==--r&&i.addFiles(n,t)}s.each(e.items,(function(e){var t=e.webkitGetAsEntry();t?t.isFile?a(e.getAsFile(),t.fullPath):o(t.createReader()):u()}))},_assignHelper:function(e,t,i){void 0===e.length&&(e=[e]);var r=i?"removeEventListener":"addEventListener";s.each(e,(function(e){s.each(t,(function(t,i){e[r](i,t,!1)}),this)}),this)},_preventEvent:function(e){s.preventEvent(e),this._trigger(e.type,e)},assignDrop:function(e){this._onDrop=s.bind(this.onDrop,this),this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop})},unAssignDrop:function(e){this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop},!0),this._onDrop=null}}),t.exports=f},{"./chunk":1,"./event":2,"./file":4,"./utils":5}],4:[function(e,t,i){var s=e("./utils"),r=e("./chunk");function n(e,t,i){s.defineNonEnumerable(this,"uploader",e),this.isRoot=this.isFolder=e===this,s.defineNonEnumerable(this,"parent",i||null),s.defineNonEnumerable(this,"files",[]),s.defineNonEnumerable(this,"fileList",[]),s.defineNonEnumerable(this,"chunks",[]),s.defineNonEnumerable(this,"_errorFiles",[]),s.defineNonEnumerable(this,"file",null),this.id=s.uid(),this.isRoot||!t?this.file=null:s.isString(t)?(this.isFolder=!0,this.file=null,this.path=t,this.parent.path&&(t=t.substr(this.parent.path.length)),this.name="/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t):(this.file=t,this.fileType=this.file.type,this.name=t.fileName||t.name,this.size=t.size,this.relativePath=t.relativePath||t.webkitRelativePath||this.name,this._parseFile()),this.paused=e.opts.initialPaused,this.error=!1,this.allError=!1,this.aborted=!1,this.completed=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevUploadedSize=0,this._prevProgress=0,this.bootstrap()}function o(e){var t=[],i=e.split("/"),s=i.length,r=1;if(i.splice(s-1,1),s--,i.length)for(;r<=s;)t.push(i.slice(0,r++).join("/")+"/");return t}s.extend(n.prototype,{_parseFile:function(){var e=o(this.relativePath);if(e.length){var t=this.uploader.filePaths;s.each(e,(function(i,s){var r=t[i];r||(r=new n(this.uploader,i,this.parent),t[i]=r,this._updateParentFileList(r)),this.parent=r,r.files.push(this),e[s+1]||r.fileList.push(this)}),this)}else this._updateParentFileList()},_updateParentFileList:function(e){e||(e=this);var t=this.parent;t&&t.fileList.push(e)},_eachAccess:function(e,t){this.isFolder?s.each(this.files,(function(t,i){return e.call(this,t,i)}),this):t.call(this,this)},bootstrap:function(){if(!this.isFolder){var e=this.uploader.opts;s.isFunction(e.initFileFn)&&e.initFileFn.call(this,this),this.abort(!0),this._resetError(),this._prevProgress=0;for(var t=e.forceChunkSize?Math.ceil:Math.floor,i=Math.max(t(this.size/e.chunkSize),1),n=0;n=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(e,t,i){var s=this.uploader,n=r.STATUS,o=this,a=this.getRoot(),l=function(){o._measureSpeed(),s._trigger("fileProgress",a,o,e),o._lastProgressCallback=Date.now()};switch(t){case n.PROGRESS:this._checkProgress()&&l();break;case n.ERROR:this._error(),this.abort(!0),s._trigger("fileError",a,this,i,e);break;case n.SUCCESS:if(this._updateUploadedChunks(i,e),this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var u=Date.now()-this._lastProgressCallback;u0?e/t:this.isComplete()?1:0)}),(function(){if(this.error)i=1;else{if(1===this.chunks.length)return this._prevProgress=Math.max(this._prevProgress,this.chunks[0].progress()),void(i=this._prevProgress);var e=0;s.each(this.chunks,(function(t){e+=t.progress()*(t.endByte-t.startByte)}));var t=e/this.size;this._prevProgress=Math.max(this._prevProgress,t>.9999?1:t),i=this._prevProgress}})),i},getSize:function(){var e=0;return this._eachAccess((function(t){e+=t.size}),(function(){e+=this.size})),e},getFormatSize:function(){var e=this.getSize();return s.formatSize(e)},getRoot:function(){if(this.isRoot)return this;for(var e=this.parent;e;){if(e.parent===this.uploader)return e;e=e.parent}return this},sizeUploaded:function(){var e=0;return this._eachAccess((function(t){e+=t.sizeUploaded()}),(function(){s.each(this.chunks,(function(t){e+=t.sizeUploaded()}))})),e},timeRemaining:function(){var e=0,t=0,i=0;return this._eachAccess((function(r,n){r.paused||r.error||(t+=r.size-r.sizeUploaded(),i+=r.averageSpeed),n===this.files.length-1&&(e=s(t,i))}),(function(){if(this.paused||this.error)e=0;else{var t=this.size-this.sizeUploaded();e=s(t,this.averageSpeed)}})),e;function s(e,t){return e&&!t?Number.POSITIVE_INFINITY:e||t?Math.floor(e/t):0}},removeFile:function(e){if(e.isFolder)for(;e.files.length;){var t=e.files[e.files.length-1];this._removeFile(t)}this._removeFile(e)},_delFilePath:function(e){e.path&&this.filePaths&&delete this.filePaths[e.path],s.each(e.fileList,(function(e){this._delFilePath(e)}),this)},_removeFile:function(e){if(!e.isFolder){s.each(this.files,(function(t,i){if(t===e)return this.files.splice(i,1),!1}),this),e.abort();for(var t,i=e.parent;i&&i!==this;)t=i.parent,i._removeFile(e),i=t}e.parent===this&&s.each(this.fileList,(function(t,i){if(t===e)return this.fileList.splice(i,1),!1}),this),this.isRoot||!this.isFolder||this.files.length||(this.parent._removeFile(this),this.uploader._delFilePath(this)),e.parent=null},getType:function(){return this.isFolder?"folder":this.file.type&&this.file.type.split("/")[1]},getExtension:function(){return this.isFolder?"":this.name.substr(2+(~-this.name.lastIndexOf(".")>>>0)).toLowerCase()}}),t.exports=n},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var s=Object.prototype,r=Array.prototype,n=s.toString,o=function(e){return"[object Function]"===n.call(e)},a=Array.isArray||function(e){return"[object Array]"===n.call(e)},l=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===s},u=0,h={uid:function(){return++u},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(h.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),r.slice.call(e,t,i)},isPlainObject:l,isFunction:o,isArray:a,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(h.isDefined(e.length))for(var s=0,r=e.length;s * @link https://github.com/simple-uploader/Uploader * @license MIT - */function x(e){return e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}const C={name:"uploader-btn",props:{directory:{type:Boolean,default:!1},single:{type:Boolean,default:!1},attrs:{type:Object,default:()=>({})}},setup(r){const n=e(null),o=t("uploader"),a=o.support;return i((()=>{s((()=>{o.assignBrowse(n.value,r.directory,r.single,r.attrs)}))})),{btn:n,support:a}}},P={class:"uploader-btn",ref:"btn"};C.render=function(e,t,i,s,u,h){return r((n(),o("label",P,[a(e.$slots,"default")],512)),[[l,s.support]])};const U={name:"uploader-drop",setup(){const i=t("uploader");let r=e(null),n=e("");const o=i.support,a=()=>{n="uploader-dragover"},l=()=>{n=""},h=()=>{n="uploader-droped"};return s((()=>{const e=r.value;i.assignDrop(e),i.on("dragenter",a),i.on("dragleave",l),i.on("drop",h)})),u((()=>{const e=r.value;i.off("dragenter",a),i.off("dragleave",l),i.off("drop",h),i.unAssignDrop(e)})),{drop:r,dropClass:n,support:o,onDragEnter:a,onDragLeave:l,onDrop:h}}};U.render=function(e,t,i,s,u,h){return r((n(),o("div",{class:["uploader-drop",s.dropClass],ref:"drop"},[a(e.$slots,"default")],2)),[[l,s.support]])};const w={name:"uploader-unsupport",setup:()=>({support:t("uploader").support})},A={class:"uploader-unsupport"},D=h("p",null,[p(" Your browser, unfortunately, is not supported by Uploader.js. The library requires support for "),h("a",{href:"http://www.w3.org/TR/FileAPI/"},"the HTML5 File API"),p(" along with "),h("a",{href:"http://www.w3.org/TR/FileAPI/#normalization-of-params"},"file slicing"),p(". ")],-1);w.render=function(e,t,i,s,u,h){return r((n(),o("div",A,[a(e.$slots,"default",{},(()=>[D]))],512)),[[l,!s.support]])};const z=["fileProgress","fileSuccess","fileComplete","fileError"];const T={name:"uploader-file",props:{file:{type:Object,default:()=>({})},list:{type:Boolean,default:!1}},setup(t){const s=f();let r={},n=0;const o=e(null),a=e(!1),l=e(!1),u=e(0),h=e(0),p=e(!1),g=e(!1),m=e(0),S=e(""),y=e(0),_=e(0),b=e(0),k=e(""),R=e(""),E=e(""),x=d((()=>{let e=t.file.isFolder?"folder":"unknown";const i=t.file.uploader.opts.categoryMap||{image:["gif","jpg","jpeg","png","bmp","webp"],video:["mp4","m3u8","rmvb","avi","swf","3gp","mkv","flv"],audio:["mp3","wav","wma","ogg","aac","flac"],document:["doc","txt","docx","pages","epub","pdf","numbers","csv","xls","xlsx","keynote","ppt","pptx"]};return Object.keys(i).forEach((t=>{i[t].indexOf(R.value)>-1&&(e=t)})),e})),C=d((()=>{_.value=Math.floor(100*_.value);const e=`translateX(${Math.floor(_.value-100)}%)`;return{progress:`${_.value}%`,webkitTransform:e,mozTransform:e,msTransform:e,transform:e}})),P=d((()=>`${F.utils.formatSize(u.value)} / s`)),U=d((()=>{let e=l;return p.value?"success":e.value?"error":g.value?"uploading":a.value?"paused":"waiting"})),w=d((()=>{const e=t.file.uploader.fileStatusText;let i=U.value;return i="function"==typeof e?e(U.value,o.value):e[U.value],i||U})),A=d((()=>{const e=t.file;if(b.value===Number.POSITIVE_INFINITY||0===b.value)return"";let i=function(e){const t=Math.floor(e/31536e3);if(t)return t+" year"+o(t);const i=Math.floor((e%=31536e3)/86400);if(i)return i+" day"+o(i);const s=Math.floor((e%=86400)/3600);if(s)return s+" hour"+o(s);const r=Math.floor((e%=3600)/60);if(r)return r+" minute"+o(r);const n=e%60;return n+" second"+o(n);function o(e){return e>1?"s":""}}(b.value);const s=e.uploader.opts.parseTimeRemaining;return s&&(i=s(b.value,i)),i})),D=()=>{a.value=t.file.paused,l.value=t.file.error,g.value=t.file.isUploading()},T=e=>{let t=e;try{t=JSON.parse(e)}catch(i){}o.value=t},N=(e,i)=>{const r=i[0],n=i[1],o=t.list?r:n;if(JSON.stringify(t.file)===JSON.stringify(o)){if(t.list&&"fileSuccess"===e)return void T(i[2]);s.setupState[`_${e}`](i)}},I=()=>{_.value=t.file.progress(),u.value=t.file.averageSpeed,h.value=t.file.currentSpeed,b.value=t.file.timeRemaining(),y.value=t.file.sizeUploaded(),D()},L=(e,t,i)=>{e&&T(i),I(),l.value=!1,p.value=!0,g.value=!1};return c(U,((e,t)=>{t&&"uploading"===e&&"uploading"!==t?n=setTimeout((()=>{E.value="uploader-file-progressing"}),200):(clearTimeout(n),E.value="")})),i((()=>{a.value=t.file.paused,l.value=t.file.error,u.value=t.file.averageSpeed,h.value=t.file.currentSpeed,p.value=t.file.isComplete(),g.value=t.file.isUploading(),m.value=t.file.getSize(),S.value=t.file.getFormatSize(),y.value=t.file.sizeUploaded(),_.value=t.file.progress(),b.value=t.file.timeRemaining(),k.value=t.file.getType(),R.value=t.file.getExtension();z.forEach((e=>{t.file.uploader.on(e,(e=>(r[e]=(...t)=>{N(e,t)},r[e]))(e))}))})),v((()=>{z.forEach((e=>{t.file.uploader.off(e,r[e])})),r=null})),{response:o,paused:a,error:l,averageSpeed:u,currentSpeed:h,isComplete:p,isUploading:g,size:m,formatedSize:S,uploadedSize:y,progress:_,timeRemaining:b,type:k,extension:R,progressingClass:E,fileCategory:x,progressStyle:C,formatedAverageSpeed:P,status:U,statusText:w,formatedTimeRemaining:A,actionCheck:D,pause:()=>{t.file.pause(),D(),I()},resume:()=>{t.file.resume(),D()},remove:()=>{t.file.cancel()},retry:()=>{t.file.retry(),D()},processResponse:T,fileEventsHandler:N,fileProgress:I,fileSuccess:L,fileComplete:()=>{L()},fileError:(e,t,i)=>{I(),T(i),l.value=!0,p.value=!1,g.value=!1}}}},N={class:"uploader-file-info"},I={class:"uploader-file-name"},L={class:"uploader-file-size"},O=h("div",{class:"uploader-file-meta"},null,-1),B={class:"uploader-file-status"},G={class:"uploader-file-actions"};T.render=function(e,t,i,s,u,f){return n(),o("div",{class:"uploader-file",status:s.status},[a(e.$slots,"default",{file:i.file,list:i.list,status:s.status,paused:s.paused,error:s.error,response:s.response,averageSpeed:s.averageSpeed,formatedAverageSpeed:s.formatedAverageSpeed,currentSpeed:s.currentSpeed,isComplete:s.isComplete,isUploading:s.isUploading,size:s.size,formatedSize:s.formatedSize,uploadedSize:s.uploadedSize,progress:s.progress,progressStyle:s.progressStyle,progressingClass:s.progressingClass,timeRemaining:s.timeRemaining,formatedTimeRemaining:s.formatedTimeRemaining,type:s.type,extension:s.extension,fileCategory:s.fileCategory},(()=>[h("div",{class:["uploader-file-progress",s.progressingClass],style:s.progressStyle},null,6),h("div",N,[h("div",I,[h("i",{class:"uploader-file-icon",icon:s.fileCategory},null,8,["icon"]),p(g(i.file.name),1)]),h("div",L,g(s.formatedSize),1),O,h("div",B,[r(h("span",null,g(s.statusText),513),[[l,"uploading"!==s.status]]),r(h("span",null,[h("span",null,g(s.progressStyle.progress)+" ",1),h("em",null,g(s.formatedAverageSpeed)+" ",1),h("i",null,g(s.formatedTimeRemaining),1)],512),[[l,"uploading"===s.status]])]),h("div",G,[h("span",{class:"uploader-file-pause",onClick:t[1]||(t[1]=(...e)=>s.pause&&s.pause(...e))}),h("span",{class:"uploader-file-resume",onClick:t[2]||(t[2]=(...e)=>s.resume&&s.resume(...e))},"️"),h("span",{class:"uploader-file-retry",onClick:t[3]||(t[3]=(...e)=>s.retry&&s.retry(...e))}),h("span",{class:"uploader-file-remove",onClick:t[4]||(t[4]=(...e)=>s.remove&&s.remove(...e))})])])]))],8,["status"])};const M={name:"uploader-list",components:{UploaderFile:T},setup:()=>({fileList:t("uploader").fileList})},j={class:"uploader-list"};M.render=function(e,t,i,s,r,l){const u=m("uploader-file");return n(),o("div",j,[a(e.$slots,"default",{fileList:s.fileList},(()=>[h("ul",null,[(n(!0),o(S,null,y(s.fileList,(e=>(n(),o("li",{key:e.id},[h(u,{file:e,list:!0},null,8,["file"])])))),128))])]))])};const q={name:"uploader-files",components:{UploaderFile:T},setup:()=>({files:t("uploader").files})},$={class:"uploader-files"};q.render=function(e,t,i,s,r,l){const u=m("uploader-file");return n(),o("div",$,[a(e.$slots,"default",{files:s.files},(()=>[h("ul",null,[(n(!0),o(S,null,y(s.files,(e=>(n(),o("li",{key:e.id},[h(u,{file:e},null,8,["file"])])))),128))])]))])};const H={name:"uploader",props:{options:{type:Object,default:()=>({})},autoStart:{type:Boolean,default:!0},fileStatusText:{type:[Object,Function],default:()=>({success:"success",error:"error",uploading:"uploading",paused:"paused",waiting:"waiting"})}},setup(t,{emit:i}){const s=e(null),r=e(!1),n=e([]),o=e([]),a=f();let l=new F(t.options);const u=()=>{r.value=!0},h=e=>{const t=b(e);if(i(x("fileAdded"),t),t.ignored)return!1},p=(e,t)=>{if(i(x("filesAdded"),e,t),e.ignored||t.ignored)return!1},d=e=>{n.value=l.files,o.value=l.fileList},c=(e,i)=>{n.value=l.files,o.value=l.fileList,t.autoStart&&l.upload()},g=(...e)=>{const t=e[0],s={fileAdded:!0,filesAdded:!0,uploadStart:"uploadStart"}[t];if(s){if(!0===s)return;a[s].apply(a[s],e.slice(1))}e[0]=x(t),i.apply(a,e)};return t.options.initialPaused=!t.autoStart,l.fileStatusText=t.fileStatusText,l.on("catchAll",g),l.on("fileAdded",h),l.on("filesAdded",p),l.on("fileRemoved",d),l.on("filesSubmitted",c),l.uploadStart=u,v((()=>{l.off("catchAll",g),l.off("fileAdded",h),l.off("filesAdded",p),l.off("fileRemoved",d),l.off("filesSubmitted",c),l=null})),_("uploader",b(l)),{uploader:l,started:r,files:n,fileList:o,uploadStart:u,fileAdded:h,filesAdded:p,fileRemoved:d,filesSubmitted:c,allEvent:g,uploaderList:s}},components:{UploaderBtn:C,UploaderDrop:U,UploaderUnsupport:w,UploaderList:M,UploaderFiles:q,UploaderFile:T}},X={class:"uploader"},Y=h("p",null,"Drop files here to upload or",-1),J=p("select files"),V=p("select folder");H.render=function(e,t,i,s,r,l){const u=m("uploader-unsupport"),p=m("uploader-btn"),f=m("uploader-drop"),d=m("uploader-list");return n(),o("div",X,[a(e.$slots,"default",{files:s.files,fileList:s.fileList,started:s.started},(()=>[h(u),h(f,null,{default:k((()=>[Y,h(p,null,{default:k((()=>[J])),_:1}),h(p,{directory:!0},{default:k((()=>[V])),_:1})])),_:1}),h(d)]))])};const Z={version:"1.0.0-beta.2",install:function(e,t){e.component(H.name,H),e.component(C.name,C),e.component(U.name,U),e.component(w.name,w),e.component(M.name,M),e.component(q.name,q),e.component(T.name,T)},Uploader:H,UploaderBtn:C,UploaderDrop:U,UploaderUnsupport:w,UploaderList:M,UploaderFiles:q,UploaderFile:T};export default Z; + */function F(e){return e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}const C={name:"uploader-btn",props:{directory:{type:Boolean,default:!1},single:{type:Boolean,default:!1},attrs:{type:Object,default:()=>({})}},setup(r){const n=e(null),o=t("uploader"),a=o.support;return i((()=>{s((()=>{o.assignBrowse(n.value,r.directory,r.single,r.attrs)}))})),{btn:n,support:a}}},P={class:"uploader-btn",ref:"btn"};C.render=function(e,t,i,s,u,h){return r((n(),o("label",P,[a(e.$slots,"default")],512)),[[l,s.support]])};const U={name:"uploader-drop",setup(){const i=t("uploader");let r=e(null),n=e("");const o=i.support,a=()=>{n="uploader-dragover"},l=()=>{n=""},h=()=>{n="uploader-droped"};return s((()=>{const e=r.value;i.assignDrop(e),i.on("dragenter",a),i.on("dragleave",l),i.on("drop",h)})),u((()=>{const e=r.value;i.off("dragenter",a),i.off("dragleave",l),i.off("drop",h),i.unAssignDrop(e)})),{drop:r,dropClass:n,support:o,onDragEnter:a,onDragLeave:l,onDrop:h}}};U.render=function(e,t,i,s,u,h){return r((n(),o("div",{class:["uploader-drop",s.dropClass],ref:"drop"},[a(e.$slots,"default")],2)),[[l,s.support]])};const w={name:"uploader-unsupport",setup:()=>({support:t("uploader").support})},A={class:"uploader-unsupport"},D=h("p",null,[p(" Your browser, unfortunately, is not supported by Uploader.js. The library requires support for "),h("a",{href:"http://www.w3.org/TR/FileAPI/"},"the HTML5 File API"),p(" along with "),h("a",{href:"http://www.w3.org/TR/FileAPI/#normalization-of-params"},"file slicing"),p(". ")],-1);w.render=function(e,t,i,s,u,h){return r((n(),o("div",A,[a(e.$slots,"default",{},(()=>[D]))],512)),[[l,!s.support]])};const z=["fileProgress","fileSuccess","fileComplete","fileError"];const T={name:"uploader-file",props:{file:{type:Object,default:()=>({})},list:{type:Boolean,default:!1}},setup(t){const s=f();let r={},n=0;const o=e(null),a=e(!1),l=e(!1),u=e(0),h=e(0),p=e(!1),g=e(!1),m=e(0),S=e(""),y=e(0),_=e(0),b=e(0),k=e(""),R=e(""),E=e(""),F=d((()=>{let e=t.file.isFolder?"folder":"unknown";const i=t.file.uploader.opts.categoryMap||{image:["gif","jpg","jpeg","png","bmp","webp"],video:["mp4","m3u8","rmvb","avi","swf","3gp","mkv","flv"],audio:["mp3","wav","wma","ogg","aac","flac"],document:["doc","txt","docx","pages","epub","pdf","numbers","csv","xls","xlsx","keynote","ppt","pptx"]};return Object.keys(i).forEach((t=>{i[t].indexOf(R.value)>-1&&(e=t)})),e})),C=d((()=>{_.value=Math.floor(100*_.value);const e=`translateX(${Math.floor(_.value-100)}%)`;return{progress:`${_.value}%`,webkitTransform:e,mozTransform:e,msTransform:e,transform:e}})),P=d((()=>`${x.utils.formatSize(u.value)} / s`)),U=d((()=>{let e=l;return p.value?"success":e.value?"error":g.value?"uploading":a.value?"paused":"waiting"})),w=d((()=>{const e=t.file.uploader.fileStatusText;let i=U.value;return i="function"==typeof e?e(U.value,o.value):e[U.value],i||U})),A=d((()=>{const e=t.file;if(b.value===Number.POSITIVE_INFINITY||0===b.value)return"";let i=function(e){const t=Math.floor(e/31536e3);if(t)return t+" year"+o(t);const i=Math.floor((e%=31536e3)/86400);if(i)return i+" day"+o(i);const s=Math.floor((e%=86400)/3600);if(s)return s+" hour"+o(s);const r=Math.floor((e%=3600)/60);if(r)return r+" minute"+o(r);const n=e%60;return n+" second"+o(n);function o(e){return e>1?"s":""}}(b.value);const s=e.uploader.opts.parseTimeRemaining;return s&&(i=s(b.value,i)),i})),D=()=>{a.value=t.file.paused,l.value=t.file.error,g.value=t.file.isUploading()},T=e=>{let t=e;try{t=JSON.parse(e)}catch(i){}o.value=t},N=(e,i)=>{const r=i[0],n=i[1],o=t.list?r:n;if(JSON.stringify(t.file)===JSON.stringify(o)){if(t.list&&"fileSuccess"===e)return void T(i[2]);s.ctx[`${e}`](i)}},I=()=>{_.value=t.file.progress(),u.value=t.file.averageSpeed,h.value=t.file.currentSpeed,b.value=t.file.timeRemaining(),y.value=t.file.sizeUploaded(),D()},L=(e,t,i)=>{e&&T(i),I(),l.value=!1,p.value=!0,g.value=!1};return c(U,((e,t)=>{t&&"uploading"===e&&"uploading"!==t?n=setTimeout((()=>{E.value="uploader-file-progressing"}),200):(clearTimeout(n),E.value="")})),i((()=>{a.value=t.file.paused,l.value=t.file.error,u.value=t.file.averageSpeed,h.value=t.file.currentSpeed,p.value=t.file.isComplete(),g.value=t.file.isUploading(),m.value=t.file.getSize(),S.value=t.file.getFormatSize(),y.value=t.file.sizeUploaded(),_.value=t.file.progress(),b.value=t.file.timeRemaining(),k.value=t.file.getType(),R.value=t.file.getExtension();z.forEach((e=>{t.file.uploader.on(e,(e=>(r[e]=(...t)=>{N(e,t)},r[e]))(e))}))})),v((()=>{z.forEach((e=>{t.file.uploader.off(e,r[e])})),r=null})),{response:o,paused:a,error:l,averageSpeed:u,currentSpeed:h,isComplete:p,isUploading:g,size:m,formatedSize:S,uploadedSize:y,progress:_,timeRemaining:b,type:k,extension:R,progressingClass:E,fileCategory:F,progressStyle:C,formatedAverageSpeed:P,status:U,statusText:w,formatedTimeRemaining:A,actionCheck:D,pause:()=>{t.file.pause(),D(),I()},resume:()=>{t.file.resume(),D()},remove:()=>{t.file.cancel()},retry:()=>{t.file.retry(),D()},processResponse:T,fileEventsHandler:N,fileProgress:I,fileSuccess:L,fileComplete:()=>{L()},fileError:(e,t,i)=>{I(),T(i),l.value=!0,p.value=!1,g.value=!1}}}},N={class:"uploader-file-info"},I={class:"uploader-file-name"},L={class:"uploader-file-size"},O=h("div",{class:"uploader-file-meta"},null,-1),B={class:"uploader-file-status"},G={class:"uploader-file-actions"};T.render=function(e,t,i,s,u,f){return n(),o("div",{class:"uploader-file",status:s.status},[a(e.$slots,"default",{file:i.file,list:i.list,status:s.status,paused:s.paused,error:s.error,response:s.response,averageSpeed:s.averageSpeed,formatedAverageSpeed:s.formatedAverageSpeed,currentSpeed:s.currentSpeed,isComplete:s.isComplete,isUploading:s.isUploading,size:s.size,formatedSize:s.formatedSize,uploadedSize:s.uploadedSize,progress:s.progress,progressStyle:s.progressStyle,progressingClass:s.progressingClass,timeRemaining:s.timeRemaining,formatedTimeRemaining:s.formatedTimeRemaining,type:s.type,extension:s.extension,fileCategory:s.fileCategory},(()=>[h("div",{class:["uploader-file-progress",s.progressingClass],style:s.progressStyle},null,6),h("div",N,[h("div",I,[h("i",{class:"uploader-file-icon",icon:s.fileCategory},null,8,["icon"]),p(g(i.file.name),1)]),h("div",L,g(s.formatedSize),1),O,h("div",B,[r(h("span",null,g(s.statusText),513),[[l,"uploading"!==s.status]]),r(h("span",null,[h("span",null,g(s.progressStyle.progress)+" ",1),h("em",null,g(s.formatedAverageSpeed)+" ",1),h("i",null,g(s.formatedTimeRemaining),1)],512),[[l,"uploading"===s.status]])]),h("div",G,[h("span",{class:"uploader-file-pause",onClick:t[1]||(t[1]=(...e)=>s.pause&&s.pause(...e))}),h("span",{class:"uploader-file-resume",onClick:t[2]||(t[2]=(...e)=>s.resume&&s.resume(...e))},"️"),h("span",{class:"uploader-file-retry",onClick:t[3]||(t[3]=(...e)=>s.retry&&s.retry(...e))}),h("span",{class:"uploader-file-remove",onClick:t[4]||(t[4]=(...e)=>s.remove&&s.remove(...e))})])])]))],8,["status"])};const M={name:"uploader-list",components:{UploaderFile:T},setup:()=>({fileList:t("uploader").fileList})},j={class:"uploader-list"};M.render=function(e,t,i,s,r,l){const u=m("uploader-file");return n(),o("div",j,[a(e.$slots,"default",{fileList:s.fileList},(()=>[h("ul",null,[(n(!0),o(S,null,y(s.fileList,(e=>(n(),o("li",{key:e.id},[h(u,{file:e,list:!0},null,8,["file"])])))),128))])]))])};const q={name:"uploader-files",components:{UploaderFile:T},setup:()=>({files:t("uploader").files})},$={class:"uploader-files"};q.render=function(e,t,i,s,r,l){const u=m("uploader-file");return n(),o("div",$,[a(e.$slots,"default",{files:s.files},(()=>[h("ul",null,[(n(!0),o(S,null,y(s.files,(e=>(n(),o("li",{key:e.id},[h(u,{file:e},null,8,["file"])])))),128))])]))])};const H={name:"uploader",props:{options:{type:Object,default:()=>({})},autoStart:{type:Boolean,default:!0},fileStatusText:{type:[Object,Function],default:()=>({success:"success",error:"error",uploading:"uploading",paused:"paused",waiting:"waiting"})}},setup(t,{emit:i}){const s=e(null),r=e(!1),n=e([]),o=e([]),a=f();let l=new x(t.options);const u=()=>{r.value=!0},h=e=>{const t=b(e);if(i(F("fileAdded"),t),t.ignored)return!1},p=(e,t)=>{if(i(F("filesAdded"),e,t),e.ignored||t.ignored)return!1},d=e=>{n.value=l.files,o.value=l.fileList},c=(e,i)=>{n.value=l.files,o.value=l.fileList,t.autoStart&&l.upload()},g=(...e)=>{const t=e[0],s={fileAdded:!0,filesAdded:!0,uploadStart:"uploadStart"}[t];if(s){if(!0===s)return;a.ctx[s].apply(a.ctx[s],e.slice(1))}e[0]=F(t),i.apply(a.ctx,e)};return t.options.initialPaused=!t.autoStart,l.fileStatusText=t.fileStatusText,l.on("catchAll",g),l.on("fileAdded",h),l.on("filesAdded",p),l.on("fileRemoved",d),l.on("filesSubmitted",c),l.uploadStart=u,v((()=>{l.off("catchAll",g),l.off("fileAdded",h),l.off("filesAdded",p),l.off("fileRemoved",d),l.off("filesSubmitted",c),l=null})),_("uploader",b(l)),{uploader:l,started:r,files:n,fileList:o,uploadStart:u,fileAdded:h,filesAdded:p,fileRemoved:d,filesSubmitted:c,allEvent:g,uploaderList:s}},components:{UploaderBtn:C,UploaderDrop:U,UploaderUnsupport:w,UploaderList:M,UploaderFiles:q,UploaderFile:T}},X={class:"uploader"},Y=h("p",null,"Drop files here to upload or",-1),J=p("select files"),V=p("select folder");H.render=function(e,t,i,s,r,l){const u=m("uploader-unsupport"),p=m("uploader-btn"),f=m("uploader-drop"),d=m("uploader-list");return n(),o("div",X,[a(e.$slots,"default",{files:s.files,fileList:s.fileList,started:s.started},(()=>[h(u),h(f,null,{default:k((()=>[Y,h(p,null,{default:k((()=>[J])),_:1}),h(p,{directory:!0},{default:k((()=>[V])),_:1})])),_:1}),h(d)]))])};const Z={version:"1.0.0-beta.3",install:function(e,t){e.component(H.name,H),e.component(C.name,C),e.component(U.name,U),e.component(w.name,w),e.component(M.name,M),e.component(q.name,q),e.component(T.name,T)},Uploader:H,UploaderBtn:C,UploaderDrop:U,UploaderUnsupport:w,UploaderList:M,UploaderFiles:q,UploaderFile:T};export default Z; diff --git a/dist/vue-simple-uploader.umd.js b/dist/vue-simple-uploader.umd.js index 752c181..90bfa93 100644 --- a/dist/vue-simple-uploader.umd.js +++ b/dist/vue-simple-uploader.umd.js @@ -5,4 +5,4 @@ * @author dolymood * @link https://github.com/simple-uploader/Uploader * @license MIT - */i.exports=function e(i,r,s){function n(a,l){if(!r[a]){if(!i[a]){if(!l&&t)return t(a);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=r[a]={exports:{}};i[a][0].call(u.exports,(function(e){var t=i[a][1][e];return n(t||e)}),u,u.exports,e,i,r,s)}return r[a].exports}for(var o=t,a=0;a-1?t=n.SUCCESS:this.uploader.opts.permanentErrors.indexOf(this.xhr.status)>-1||!e&&this.retries>=this.uploader.opts.maxChunkRetries?t=n.ERROR:(this.abort(),t=n.PENDING);var i=this.processedState;return i&&i.err&&(t=n.ERROR),t}return n.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===n.SUCCESS||e===n.ERROR?1:e===n.PENDING?0:this.total>0?this.loaded/this.total:0},sizeUploaded:function(){var e=this.endByte-this.startByte;return this.status()!==n.SUCCESS&&(e=this.progress()*e),e},prepareXhrRequest:function(e,t,i,s){var n=r.evalOpts(this.uploader.opts.query,this.file,this,t);n=r.extend(this.getParams(),n),n=this.uploader.opts.processParams(n,this.file,this,t);var o=r.evalOpts(this.uploader.opts.target,this.file,this,t),a=null;if("GET"===e||"octet"===i){var l=[];r.each(n,(function(e,t){l.push([encodeURIComponent(t),encodeURIComponent(e)].join("="))})),o=this.getTarget(o,l),a=s||null}else a=new FormData,r.each(n,(function(e,t){a.append(t,e)})),void 0!==s&&a.append(this.uploader.opts.fileParameterName,s,this.file.name);return this.xhr.open(e,o,!0),this.xhr.withCredentials=this.uploader.opts.withCredentials,r.each(r.evalOpts(this.uploader.opts.headers,this.file,this,t),(function(e,t){this.xhr.setRequestHeader(t,e)}),this),a}}),t.exports=s},{"./utils":5}],2:[function(e,t,i){var r=e("./utils").each,s={_eventData:null,on:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]||(this._eventData[e]=[]);var i=!1;r(this._eventData[e],(function(e){if(e===t)return i=!0,!1})),i||this._eventData[e].push(t)},off:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]&&this._eventData[e].length&&(t?r(this._eventData[e],(function(i,r){if(i===t)return this._eventData[e].splice(r,1),!1}),this):this._eventData[e]=[])},trigger:function(e){if(this._eventData||(this._eventData={}),!this._eventData[e])return!0;var t=this._eventData[e].slice.call(arguments,1),i=!1;return r(this._eventData[e],(function(e){i=!1===e.apply(this,t)||i}),this),!i}};t.exports=s},{"./utils":5}],3:[function(e,t,i){var r=e("./utils"),s=e("./event"),n=e("./file"),o=e("./chunk"),a="0.6.0",l="undefined"==typeof window,u=!l&&window.navigator.msPointerEnabled,p=function(){if(l)return!1;var e="slice",t=r.isDefined(window.File)&&r.isDefined(window.Blob)&&r.isDefined(window.FileList),i=null;return t&&(i=window.Blob.prototype,r.each(["slice","webkitSlice","mozSlice"],(function(t){if(i[t])return e=t,!1})),t=!!i[e]),t&&(c.sliceName=e),i=null,t}(),h=function(){if(l)return!1;var e=window.document.createElement("input");e.type="file";var t="webkitdirectory"in e||"directory"in e;return e=null,t}();function c(e){this.support=p,this.support&&(this.supportDirectory=h,r.defineNonEnumerable(this,"filePaths",{}),this.opts=r.extend({},c.defaults,e||{}),this.preventEvent=r.bind(this._preventEvent,this),n.call(this,this))}var d=function(e,t,i,r,s){s.readFinished(e.file[c.sliceName](i,r,t))};c.version=a,c.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,preprocess:null,method:"multipart",testMethod:"GET",uploadMethod:"POST",prioritizeFirstAndLastChunk:!1,allowDuplicateUploads:!1,target:"/",testChunks:!0,generateUniqueIdentifier:null,maxChunkRetries:0,chunkRetryInterval:null,permanentErrors:[404,415,500,501],successStatuses:[200,201,202],onDropStopPropagation:!1,initFileFn:null,readFileFn:d,checkChunkUploadedByResponse:null,initialPaused:!1,processResponse:function(e,t){t(null,e)},processParams:function(e){return e}},c.utils=r,c.event=s,c.File=n,c.Chunk=o,c.prototype=r.extend({},n.prototype),r.extend(c.prototype,s),r.extend(c.prototype,{constructor:c,_trigger:function(e){var t=r.toArray(arguments),i=!this.trigger.apply(this,arguments);return"catchAll"!==e&&(t.unshift("catchAll"),i=!this.trigger.apply(this,t)||i),!i},_triggerAsync:function(){var e=arguments;r.nextTick((function(){this._trigger.apply(this,e)}),this)},addFiles:function(e,t){var i=[],s=this.fileList.length;r.each(e,(function(e){if((!u||u&&e.size>0)&&(e.size%4096!=0||"."!==e.name&&"."!==e.fileName)){var r=this.generateUniqueIdentifier(e);if(this.opts.allowDuplicateUploads||!this.getFromUniqueIdentifier(r)){var s=new n(this,e,this);s.uniqueIdentifier=r,this._trigger("fileAdded",s,t)?i.push(s):n.prototype.removeFile.call(this,s)}}}),this);var o=this.fileList.slice(s);this._trigger("filesAdded",i,o,t)?(r.each(i,(function(e){this.opts.singleFile&&this.files.length>0&&this.removeFile(this.files[0]),this.files.push(e)}),this),this._trigger("filesSubmitted",i,o,t)):r.each(o,(function(e){n.prototype.removeFile.call(this,e)}),this)},addFile:function(e,t){this.addFiles([e],t)},cancel:function(){for(var e=this.fileList.length-1;e>=0;e--)this.fileList[e].cancel()},removeFile:function(e){n.prototype.removeFile.call(this,e),this._trigger("fileRemoved",e)},generateUniqueIdentifier:function(e){var t=this.opts.generateUniqueIdentifier;if(r.isFunction(t))return t(e);var i=e.relativePath||e.webkitRelativePath||e.fileName||e.name;return e.size+"-"+i.replace(/[^0-9a-zA-Z_-]/gim,"")},getFromUniqueIdentifier:function(e){var t=!1;return r.each(this.files,(function(i){if(i.uniqueIdentifier===e)return t=i,!1})),t},uploadNextChunk:function(e){var t=!1,i=o.STATUS.PENDING,s=this.uploader.opts.checkChunkUploadedByResponse;if(this.opts.prioritizeFirstAndLastChunk&&(r.each(this.files,(function(e){if(!e.paused&&(!s||e._firstResponse||!e.isUploading()))return e.chunks.length&&e.chunks[0].status()===i?(e.chunks[0].send(),t=!0,!1):e.chunks.length>1&&e.chunks[e.chunks.length-1].status()===i?(e.chunks[e.chunks.length-1].send(),t=!0,!1):void 0})),t))return t;if(r.each(this.files,(function(e){if(!e.paused){if(s&&!e._firstResponse&&e.isUploading())return;r.each(e.chunks,(function(e){if(e.status()===i)return e.send(),t=!0,!1}))}if(t)return!1})),t)return!0;var n=!1;return r.each(this.files,(function(e){if(!e.isComplete())return n=!0,!1})),n||e||!this.files.length||this._triggerAsync("complete"),n},upload:function(e){var t=this._shouldUploadNext();if(!1!==t){!e&&this._trigger("uploadStart");for(var i=!1,r=1;r<=this.opts.simultaneousUploads-t&&((i=this.uploadNextChunk(!e)||i)||!e);r++);i||e||this._triggerAsync("complete")}},_shouldUploadNext:function(){var e=0,t=!0,i=this.opts.simultaneousUploads,s=o.STATUS.UPLOADING;return r.each(this.files,(function(n){return r.each(n.chunks,(function(r){if(r.status()===s&&++e>=i)return t=!1,!1})),t})),t&&e},assignBrowse:function(e,t,i,s){void 0===e.length&&(e=[e]),r.each(e,(function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),r.extend(n.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(n),e.addEventListener("click",(function(t){"label"!==e.tagName.toLowerCase()&&n.click()}),!1)),this.opts.singleFile||i||n.setAttribute("multiple","multiple"),t&&n.setAttribute("webkitdirectory","webkitdirectory"),s&&r.each(s,(function(e,t){n.setAttribute(t,e)}));var o=this;n.addEventListener("change",(function(e){o._trigger(e.type,e),e.target.value&&(o.addFiles(e.target.files,e),e.target.value="")}),!1)}),this)},onDrop:function(e){this._trigger(e.type,e),this.opts.onDropStopPropagation&&e.stopPropagation(),e.preventDefault(),this._parseDataTransfer(e.dataTransfer,e)},_parseDataTransfer:function(e,t){e.items&&e.items[0]&&e.items[0].webkitGetAsEntry?this.webkitReadDataTransfer(e,t):this.addFiles(e.files,t)},webkitReadDataTransfer:function(e,t){var i=this,s=e.items.length,n=[];function o(e){e.readEntries((function(t){t.length?(s+=t.length,r.each(t,(function(e){if(e.isFile){var t=e.fullPath;e.file((function(e){a(e,t)}),l)}else e.isDirectory&&o(e.createReader())})),o(e)):u()}),l)}function a(e,t){e.relativePath=t.substring(1),n.push(e),u()}function l(e){throw e}function u(){0==--s&&i.addFiles(n,t)}r.each(e.items,(function(e){var t=e.webkitGetAsEntry();t?t.isFile?a(e.getAsFile(),t.fullPath):o(t.createReader()):u()}))},_assignHelper:function(e,t,i){void 0===e.length&&(e=[e]);var s=i?"removeEventListener":"addEventListener";r.each(e,(function(e){r.each(t,(function(t,i){e[s](i,t,!1)}),this)}),this)},_preventEvent:function(e){r.preventEvent(e),this._trigger(e.type,e)},assignDrop:function(e){this._onDrop=r.bind(this.onDrop,this),this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop})},unAssignDrop:function(e){this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop},!0),this._onDrop=null}}),t.exports=c},{"./chunk":1,"./event":2,"./file":4,"./utils":5}],4:[function(e,t,i){var r=e("./utils"),s=e("./chunk");function n(e,t,i){r.defineNonEnumerable(this,"uploader",e),this.isRoot=this.isFolder=e===this,r.defineNonEnumerable(this,"parent",i||null),r.defineNonEnumerable(this,"files",[]),r.defineNonEnumerable(this,"fileList",[]),r.defineNonEnumerable(this,"chunks",[]),r.defineNonEnumerable(this,"_errorFiles",[]),r.defineNonEnumerable(this,"file",null),this.id=r.uid(),this.isRoot||!t?this.file=null:r.isString(t)?(this.isFolder=!0,this.file=null,this.path=t,this.parent.path&&(t=t.substr(this.parent.path.length)),this.name="/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t):(this.file=t,this.fileType=this.file.type,this.name=t.fileName||t.name,this.size=t.size,this.relativePath=t.relativePath||t.webkitRelativePath||this.name,this._parseFile()),this.paused=e.opts.initialPaused,this.error=!1,this.allError=!1,this.aborted=!1,this.completed=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevUploadedSize=0,this._prevProgress=0,this.bootstrap()}function o(e){var t=[],i=e.split("/"),r=i.length,s=1;if(i.splice(r-1,1),r--,i.length)for(;s<=r;)t.push(i.slice(0,s++).join("/")+"/");return t}r.extend(n.prototype,{_parseFile:function(){var e=o(this.relativePath);if(e.length){var t=this.uploader.filePaths;r.each(e,(function(i,r){var s=t[i];s||(s=new n(this.uploader,i,this.parent),t[i]=s,this._updateParentFileList(s)),this.parent=s,s.files.push(this),e[r+1]||s.fileList.push(this)}),this)}else this._updateParentFileList()},_updateParentFileList:function(e){e||(e=this);var t=this.parent;t&&t.fileList.push(e)},_eachAccess:function(e,t){this.isFolder?r.each(this.files,(function(t,i){return e.call(this,t,i)}),this):t.call(this,this)},bootstrap:function(){if(!this.isFolder){var e=this.uploader.opts;r.isFunction(e.initFileFn)&&e.initFileFn.call(this,this),this.abort(!0),this._resetError(),this._prevProgress=0;for(var t=e.forceChunkSize?Math.ceil:Math.floor,i=Math.max(t(this.size/e.chunkSize),1),n=0;n=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(e,t,i){var r=this.uploader,n=s.STATUS,o=this,a=this.getRoot(),l=function(){o._measureSpeed(),r._trigger("fileProgress",a,o,e),o._lastProgressCallback=Date.now()};switch(t){case n.PROGRESS:this._checkProgress()&&l();break;case n.ERROR:this._error(),this.abort(!0),r._trigger("fileError",a,this,i,e);break;case n.SUCCESS:if(this._updateUploadedChunks(i,e),this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var u=Date.now()-this._lastProgressCallback;u0?e/t:this.isComplete()?1:0)}),(function(){if(this.error)i=1;else{if(1===this.chunks.length)return this._prevProgress=Math.max(this._prevProgress,this.chunks[0].progress()),void(i=this._prevProgress);var e=0;r.each(this.chunks,(function(t){e+=t.progress()*(t.endByte-t.startByte)}));var t=e/this.size;this._prevProgress=Math.max(this._prevProgress,t>.9999?1:t),i=this._prevProgress}})),i},getSize:function(){var e=0;return this._eachAccess((function(t){e+=t.size}),(function(){e+=this.size})),e},getFormatSize:function(){var e=this.getSize();return r.formatSize(e)},getRoot:function(){if(this.isRoot)return this;for(var e=this.parent;e;){if(e.parent===this.uploader)return e;e=e.parent}return this},sizeUploaded:function(){var e=0;return this._eachAccess((function(t){e+=t.sizeUploaded()}),(function(){r.each(this.chunks,(function(t){e+=t.sizeUploaded()}))})),e},timeRemaining:function(){var e=0,t=0,i=0;return this._eachAccess((function(s,n){s.paused||s.error||(t+=s.size-s.sizeUploaded(),i+=s.averageSpeed),n===this.files.length-1&&(e=r(t,i))}),(function(){if(this.paused||this.error)e=0;else{var t=this.size-this.sizeUploaded();e=r(t,this.averageSpeed)}})),e;function r(e,t){return e&&!t?Number.POSITIVE_INFINITY:e||t?Math.floor(e/t):0}},removeFile:function(e){if(e.isFolder)for(;e.files.length;){var t=e.files[e.files.length-1];this._removeFile(t)}this._removeFile(e)},_delFilePath:function(e){e.path&&this.filePaths&&delete this.filePaths[e.path],r.each(e.fileList,(function(e){this._delFilePath(e)}),this)},_removeFile:function(e){if(!e.isFolder){r.each(this.files,(function(t,i){if(t===e)return this.files.splice(i,1),!1}),this),e.abort();for(var t,i=e.parent;i&&i!==this;)t=i.parent,i._removeFile(e),i=t}e.parent===this&&r.each(this.fileList,(function(t,i){if(t===e)return this.fileList.splice(i,1),!1}),this),this.isRoot||!this.isFolder||this.files.length||(this.parent._removeFile(this),this.uploader._delFilePath(this)),e.parent=null},getType:function(){return this.isFolder?"folder":this.file.type&&this.file.type.split("/")[1]},getExtension:function(){return this.isFolder?"":this.name.substr(2+(~-this.name.lastIndexOf(".")>>>0)).toLowerCase()}}),t.exports=n},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var r=Object.prototype,s=Array.prototype,n=r.toString,o=function(e){return"[object Function]"===n.call(e)},a=Array.isArray||function(e){return"[object Array]"===n.call(e)},l=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===r},u=0,p={uid:function(){return++u},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(p.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),s.slice.call(e,t,i)},isPlainObject:l,isFunction:o,isArray:a,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(p.isDefined(e.length))for(var r=0,s=e.length;r`-${e.toLowerCase()}`))}const n={name:"uploader-btn",props:{directory:{type:Boolean,default:!1},single:{type:Boolean,default:!1},attrs:{type:Object,default:()=>({})}},setup(t){const i=e.ref(null),r=e.inject("uploader"),s=r.support;return e.onMounted((()=>{e.nextTick((()=>{r.assignBrowse(i.value,t.directory,t.single,t.attrs)}))})),{btn:i,support:s}}},o={class:"uploader-btn",ref:"btn"};n.render=function(t,i,r,s,n,a){return e.withDirectives((e.openBlock(),e.createBlock("label",o,[e.renderSlot(t.$slots,"default")],512)),[[e.vShow,s.support]])};const a={name:"uploader-drop",setup(){const t=e.inject("uploader");let i=e.ref(null),r=e.ref("");const s=t.support,n=()=>{r="uploader-dragover"},o=()=>{r=""},a=()=>{r="uploader-droped"};return e.nextTick((()=>{const e=i.value;t.assignDrop(e),t.on("dragenter",n),t.on("dragleave",o),t.on("drop",a)})),e.onBeforeUnmount((()=>{const e=i.value;t.off("dragenter",n),t.off("dragleave",o),t.off("drop",a),t.unAssignDrop(e)})),{drop:i,dropClass:r,support:s,onDragEnter:n,onDragLeave:o,onDrop:a}}};a.render=function(t,i,r,s,n,o){return e.withDirectives((e.openBlock(),e.createBlock("div",{class:["uploader-drop",s.dropClass],ref:"drop"},[e.renderSlot(t.$slots,"default")],2)),[[e.vShow,s.support]])};const l={name:"uploader-unsupport",setup:()=>({support:e.inject("uploader").support})},u={class:"uploader-unsupport"},p=e.createVNode("p",null,[e.createTextVNode(" Your browser, unfortunately, is not supported by Uploader.js. The library requires support for "),e.createVNode("a",{href:"http://www.w3.org/TR/FileAPI/"},"the HTML5 File API"),e.createTextVNode(" along with "),e.createVNode("a",{href:"http://www.w3.org/TR/FileAPI/#normalization-of-params"},"file slicing"),e.createTextVNode(". ")],-1);l.render=function(t,i,r,s,n,o){return e.withDirectives((e.openBlock(),e.createBlock("div",u,[e.renderSlot(t.$slots,"default",{},(()=>[p]))],512)),[[e.vShow,!s.support]])};const h=["fileProgress","fileSuccess","fileComplete","fileError"];const c={name:"uploader-file",props:{file:{type:Object,default:()=>({})},list:{type:Boolean,default:!1}},setup(t){const i=e.getCurrentInstance();let s={},n=0;const o=e.ref(null),a=e.ref(!1),l=e.ref(!1),u=e.ref(0),p=e.ref(0),c=e.ref(!1),d=e.ref(!1),f=e.ref(0),v=e.ref(""),g=e.ref(0),m=e.ref(0),S=e.ref(0),y=e.ref(""),k=e.ref(""),_=e.ref(""),b=e.computed((()=>{let e=t.file.isFolder?"folder":"unknown";const i=t.file.uploader.opts.categoryMap||{image:["gif","jpg","jpeg","png","bmp","webp"],video:["mp4","m3u8","rmvb","avi","swf","3gp","mkv","flv"],audio:["mp3","wav","wma","ogg","aac","flac"],document:["doc","txt","docx","pages","epub","pdf","numbers","csv","xls","xlsx","keynote","ppt","pptx"]};return Object.keys(i).forEach((t=>{i[t].indexOf(k.value)>-1&&(e=t)})),e})),x=e.computed((()=>{m.value=Math.floor(100*m.value);const e=`translateX(${Math.floor(m.value-100)}%)`;return{progress:`${m.value}%`,webkitTransform:e,mozTransform:e,msTransform:e,transform:e}})),R=e.computed((()=>`${r.utils.formatSize(u.value)} / s`)),E=e.computed((()=>{let e=l;return c.value?"success":e.value?"error":d.value?"uploading":a.value?"paused":"waiting"})),C=e.computed((()=>{const e=t.file.uploader.fileStatusText;let i=E.value;return i="function"==typeof e?e(E.value,o.value):e[E.value],i||E})),N=e.computed((()=>{const e=t.file;if(S.value===Number.POSITIVE_INFINITY||0===S.value)return"";let i=function(e){const t=Math.floor(e/31536e3);if(t)return t+" year"+o(t);const i=Math.floor((e%=31536e3)/86400);if(i)return i+" day"+o(i);const r=Math.floor((e%=86400)/3600);if(r)return r+" hour"+o(r);const s=Math.floor((e%=3600)/60);if(s)return s+" minute"+o(s);const n=e%60;return n+" second"+o(n);function o(e){return e>1?"s":""}}(S.value);const r=e.uploader.opts.parseTimeRemaining;return r&&(i=r(S.value,i)),i})),F=()=>{a.value=t.file.paused,l.value=t.file.error,d.value=t.file.isUploading()},w=e=>{let t=e;try{t=JSON.parse(e)}catch(i){}o.value=t},D=(e,r)=>{const s=r[0],n=r[1],o=t.list?s:n;if(JSON.stringify(t.file)===JSON.stringify(o)){if(t.list&&"fileSuccess"===e)return void w(r[2]);i.setupState[`_${e}`](r)}},U=()=>{m.value=t.file.progress(),u.value=t.file.averageSpeed,p.value=t.file.currentSpeed,S.value=t.file.timeRemaining(),g.value=t.file.sizeUploaded(),F()},P=(e,t,i)=>{e&&w(i),U(),l.value=!1,c.value=!0,d.value=!1};return e.watch(E,((e,t)=>{t&&"uploading"===e&&"uploading"!==t?n=setTimeout((()=>{_.value="uploader-file-progressing"}),200):(clearTimeout(n),_.value="")})),e.onMounted((()=>{a.value=t.file.paused,l.value=t.file.error,u.value=t.file.averageSpeed,p.value=t.file.currentSpeed,c.value=t.file.isComplete(),d.value=t.file.isUploading(),f.value=t.file.getSize(),v.value=t.file.getFormatSize(),g.value=t.file.sizeUploaded(),m.value=t.file.progress(),S.value=t.file.timeRemaining(),y.value=t.file.getType(),k.value=t.file.getExtension();h.forEach((e=>{t.file.uploader.on(e,(e=>(s[e]=(...t)=>{D(e,t)},s[e]))(e))}))})),e.onUnmounted((()=>{h.forEach((e=>{t.file.uploader.off(e,s[e])})),s=null})),{response:o,paused:a,error:l,averageSpeed:u,currentSpeed:p,isComplete:c,isUploading:d,size:f,formatedSize:v,uploadedSize:g,progress:m,timeRemaining:S,type:y,extension:k,progressingClass:_,fileCategory:b,progressStyle:x,formatedAverageSpeed:R,status:E,statusText:C,formatedTimeRemaining:N,actionCheck:F,pause:()=>{t.file.pause(),F(),U()},resume:()=>{t.file.resume(),F()},remove:()=>{t.file.cancel()},retry:()=>{t.file.retry(),F()},processResponse:w,fileEventsHandler:D,fileProgress:U,fileSuccess:P,fileComplete:()=>{P()},fileError:(e,t,i)=>{U(),w(i),l.value=!0,c.value=!1,d.value=!1}}}},d={class:"uploader-file-info"},f={class:"uploader-file-name"},v={class:"uploader-file-size"},g=e.createVNode("div",{class:"uploader-file-meta"},null,-1),m={class:"uploader-file-status"},S={class:"uploader-file-actions"};c.render=function(t,i,r,s,n,o){return e.openBlock(),e.createBlock("div",{class:"uploader-file",status:s.status},[e.renderSlot(t.$slots,"default",{file:r.file,list:r.list,status:s.status,paused:s.paused,error:s.error,response:s.response,averageSpeed:s.averageSpeed,formatedAverageSpeed:s.formatedAverageSpeed,currentSpeed:s.currentSpeed,isComplete:s.isComplete,isUploading:s.isUploading,size:s.size,formatedSize:s.formatedSize,uploadedSize:s.uploadedSize,progress:s.progress,progressStyle:s.progressStyle,progressingClass:s.progressingClass,timeRemaining:s.timeRemaining,formatedTimeRemaining:s.formatedTimeRemaining,type:s.type,extension:s.extension,fileCategory:s.fileCategory},(()=>[e.createVNode("div",{class:["uploader-file-progress",s.progressingClass],style:s.progressStyle},null,6),e.createVNode("div",d,[e.createVNode("div",f,[e.createVNode("i",{class:"uploader-file-icon",icon:s.fileCategory},null,8,["icon"]),e.createTextVNode(e.toDisplayString(r.file.name),1)]),e.createVNode("div",v,e.toDisplayString(s.formatedSize),1),g,e.createVNode("div",m,[e.withDirectives(e.createVNode("span",null,e.toDisplayString(s.statusText),513),[[e.vShow,"uploading"!==s.status]]),e.withDirectives(e.createVNode("span",null,[e.createVNode("span",null,e.toDisplayString(s.progressStyle.progress)+" ",1),e.createVNode("em",null,e.toDisplayString(s.formatedAverageSpeed)+" ",1),e.createVNode("i",null,e.toDisplayString(s.formatedTimeRemaining),1)],512),[[e.vShow,"uploading"===s.status]])]),e.createVNode("div",S,[e.createVNode("span",{class:"uploader-file-pause",onClick:i[1]||(i[1]=(...e)=>s.pause&&s.pause(...e))}),e.createVNode("span",{class:"uploader-file-resume",onClick:i[2]||(i[2]=(...e)=>s.resume&&s.resume(...e))},"️"),e.createVNode("span",{class:"uploader-file-retry",onClick:i[3]||(i[3]=(...e)=>s.retry&&s.retry(...e))}),e.createVNode("span",{class:"uploader-file-remove",onClick:i[4]||(i[4]=(...e)=>s.remove&&s.remove(...e))})])])]))],8,["status"])};const y={name:"uploader-list",components:{UploaderFile:c},setup:()=>({fileList:e.inject("uploader").fileList})},k={class:"uploader-list"};y.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-file");return e.openBlock(),e.createBlock("div",k,[e.renderSlot(t.$slots,"default",{fileList:s.fileList},(()=>[e.createVNode("ul",null,[(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(s.fileList,(t=>(e.openBlock(),e.createBlock("li",{key:t.id},[e.createVNode(a,{file:t,list:!0},null,8,["file"])])))),128))])]))])};const _={name:"uploader-files",components:{UploaderFile:c},setup:()=>({files:e.inject("uploader").files})},b={class:"uploader-files"};_.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-file");return e.openBlock(),e.createBlock("div",b,[e.renderSlot(t.$slots,"default",{files:s.files},(()=>[e.createVNode("ul",null,[(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(s.files,(t=>(e.openBlock(),e.createBlock("li",{key:t.id},[e.createVNode(a,{file:t},null,8,["file"])])))),128))])]))])};const x="fileAdded",R="filesAdded",E="uploadStart",C={name:"uploader",props:{options:{type:Object,default:()=>({})},autoStart:{type:Boolean,default:!0},fileStatusText:{type:[Object,Function],default:()=>({success:"success",error:"error",uploading:"uploading",paused:"paused",waiting:"waiting"})}},setup(t,{emit:i}){const n=e.ref(null),o=e.ref(!1),a=e.ref([]),l=e.ref([]),u=e.getCurrentInstance();let p=new r(t.options);const h=()=>{o.value=!0},c=t=>{const r=e.reactive(t);if(i(s(x),r),r.ignored)return!1},d=(e,t)=>{if(i(s(R),e,t),e.ignored||t.ignored)return!1},f=e=>{a.value=p.files,l.value=p.fileList},v=(e,i)=>{a.value=p.files,l.value=p.fileList,t.autoStart&&p.upload()},g=(...e)=>{const t=e[0],r={[x]:!0,[R]:!0,[E]:"uploadStart"}[t];if(r){if(!0===r)return;u[r].apply(u[r],e.slice(1))}e[0]=s(t),i.apply(u,e)};return t.options.initialPaused=!t.autoStart,p.fileStatusText=t.fileStatusText,p.on("catchAll",g),p.on(x,c),p.on(R,d),p.on("fileRemoved",f),p.on("filesSubmitted",v),p.uploadStart=h,e.onUnmounted((()=>{p.off("catchAll",g),p.off(x,c),p.off(R,d),p.off("fileRemoved",f),p.off("filesSubmitted",v),p=null})),e.provide("uploader",e.reactive(p)),{uploader:p,started:o,files:a,fileList:l,uploadStart:h,fileAdded:c,filesAdded:d,fileRemoved:f,filesSubmitted:v,allEvent:g,uploaderList:n}},components:{UploaderBtn:n,UploaderDrop:a,UploaderUnsupport:l,UploaderList:y,UploaderFiles:_,UploaderFile:c}},N={class:"uploader"},F=e.createVNode("p",null,"Drop files here to upload or",-1),w=e.createTextVNode("select files"),D=e.createTextVNode("select folder");C.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-unsupport"),l=e.resolveComponent("uploader-btn"),u=e.resolveComponent("uploader-drop"),p=e.resolveComponent("uploader-list");return e.openBlock(),e.createBlock("div",N,[e.renderSlot(t.$slots,"default",{files:s.files,fileList:s.fileList,started:s.started},(()=>[e.createVNode(a),e.createVNode(u,null,{default:e.withCtx((()=>[F,e.createVNode(l,null,{default:e.withCtx((()=>[w])),_:1}),e.createVNode(l,{directory:!0},{default:e.withCtx((()=>[D])),_:1})])),_:1}),e.createVNode(p)]))])};return{version:"1.0.0-beta.2",install:function(e,t){e.component(C.name,C),e.component(n.name,n),e.component(a.name,a),e.component(l.name,l),e.component(y.name,y),e.component(_.name,_),e.component(c.name,c)},Uploader:C,UploaderBtn:n,UploaderDrop:a,UploaderUnsupport:l,UploaderList:y,UploaderFiles:_,UploaderFile:c}})); + */i.exports=function e(i,r,s){function n(a,l){if(!r[a]){if(!i[a]){if(!l&&t)return t(a);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=r[a]={exports:{}};i[a][0].call(u.exports,(function(e){var t=i[a][1][e];return n(t||e)}),u,u.exports,e,i,r,s)}return r[a].exports}for(var o=t,a=0;a-1?t=n.SUCCESS:this.uploader.opts.permanentErrors.indexOf(this.xhr.status)>-1||!e&&this.retries>=this.uploader.opts.maxChunkRetries?t=n.ERROR:(this.abort(),t=n.PENDING);var i=this.processedState;return i&&i.err&&(t=n.ERROR),t}return n.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===n.SUCCESS||e===n.ERROR?1:e===n.PENDING?0:this.total>0?this.loaded/this.total:0},sizeUploaded:function(){var e=this.endByte-this.startByte;return this.status()!==n.SUCCESS&&(e=this.progress()*e),e},prepareXhrRequest:function(e,t,i,s){var n=r.evalOpts(this.uploader.opts.query,this.file,this,t);n=r.extend(this.getParams(),n),n=this.uploader.opts.processParams(n,this.file,this,t);var o=r.evalOpts(this.uploader.opts.target,this.file,this,t),a=null;if("GET"===e||"octet"===i){var l=[];r.each(n,(function(e,t){l.push([encodeURIComponent(t),encodeURIComponent(e)].join("="))})),o=this.getTarget(o,l),a=s||null}else a=new FormData,r.each(n,(function(e,t){a.append(t,e)})),void 0!==s&&a.append(this.uploader.opts.fileParameterName,s,this.file.name);return this.xhr.open(e,o,!0),this.xhr.withCredentials=this.uploader.opts.withCredentials,r.each(r.evalOpts(this.uploader.opts.headers,this.file,this,t),(function(e,t){this.xhr.setRequestHeader(t,e)}),this),a}}),t.exports=s},{"./utils":5}],2:[function(e,t,i){var r=e("./utils").each,s={_eventData:null,on:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]||(this._eventData[e]=[]);var i=!1;r(this._eventData[e],(function(e){if(e===t)return i=!0,!1})),i||this._eventData[e].push(t)},off:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]&&this._eventData[e].length&&(t?r(this._eventData[e],(function(i,r){if(i===t)return this._eventData[e].splice(r,1),!1}),this):this._eventData[e]=[])},trigger:function(e){if(this._eventData||(this._eventData={}),!this._eventData[e])return!0;var t=this._eventData[e].slice.call(arguments,1),i=!1;return r(this._eventData[e],(function(e){i=!1===e.apply(this,t)||i}),this),!i}};t.exports=s},{"./utils":5}],3:[function(e,t,i){var r=e("./utils"),s=e("./event"),n=e("./file"),o=e("./chunk"),a="0.6.0",l="undefined"==typeof window,u=!l&&window.navigator.msPointerEnabled,p=function(){if(l)return!1;var e="slice",t=r.isDefined(window.File)&&r.isDefined(window.Blob)&&r.isDefined(window.FileList),i=null;return t&&(i=window.Blob.prototype,r.each(["slice","webkitSlice","mozSlice"],(function(t){if(i[t])return e=t,!1})),t=!!i[e]),t&&(c.sliceName=e),i=null,t}(),h=function(){if(l)return!1;var e=window.document.createElement("input");e.type="file";var t="webkitdirectory"in e||"directory"in e;return e=null,t}();function c(e){this.support=p,this.support&&(this.supportDirectory=h,r.defineNonEnumerable(this,"filePaths",{}),this.opts=r.extend({},c.defaults,e||{}),this.preventEvent=r.bind(this._preventEvent,this),n.call(this,this))}var d=function(e,t,i,r,s){s.readFinished(e.file[c.sliceName](i,r,t))};c.version=a,c.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,preprocess:null,method:"multipart",testMethod:"GET",uploadMethod:"POST",prioritizeFirstAndLastChunk:!1,allowDuplicateUploads:!1,target:"/",testChunks:!0,generateUniqueIdentifier:null,maxChunkRetries:0,chunkRetryInterval:null,permanentErrors:[404,415,500,501],successStatuses:[200,201,202],onDropStopPropagation:!1,initFileFn:null,readFileFn:d,checkChunkUploadedByResponse:null,initialPaused:!1,processResponse:function(e,t){t(null,e)},processParams:function(e){return e}},c.utils=r,c.event=s,c.File=n,c.Chunk=o,c.prototype=r.extend({},n.prototype),r.extend(c.prototype,s),r.extend(c.prototype,{constructor:c,_trigger:function(e){var t=r.toArray(arguments),i=!this.trigger.apply(this,arguments);return"catchAll"!==e&&(t.unshift("catchAll"),i=!this.trigger.apply(this,t)||i),!i},_triggerAsync:function(){var e=arguments;r.nextTick((function(){this._trigger.apply(this,e)}),this)},addFiles:function(e,t){var i=[],s=this.fileList.length;r.each(e,(function(e){if((!u||u&&e.size>0)&&(e.size%4096!=0||"."!==e.name&&"."!==e.fileName)){var r=this.generateUniqueIdentifier(e);if(this.opts.allowDuplicateUploads||!this.getFromUniqueIdentifier(r)){var s=new n(this,e,this);s.uniqueIdentifier=r,this._trigger("fileAdded",s,t)?i.push(s):n.prototype.removeFile.call(this,s)}}}),this);var o=this.fileList.slice(s);this._trigger("filesAdded",i,o,t)?(r.each(i,(function(e){this.opts.singleFile&&this.files.length>0&&this.removeFile(this.files[0]),this.files.push(e)}),this),this._trigger("filesSubmitted",i,o,t)):r.each(o,(function(e){n.prototype.removeFile.call(this,e)}),this)},addFile:function(e,t){this.addFiles([e],t)},cancel:function(){for(var e=this.fileList.length-1;e>=0;e--)this.fileList[e].cancel()},removeFile:function(e){n.prototype.removeFile.call(this,e),this._trigger("fileRemoved",e)},generateUniqueIdentifier:function(e){var t=this.opts.generateUniqueIdentifier;if(r.isFunction(t))return t(e);var i=e.relativePath||e.webkitRelativePath||e.fileName||e.name;return e.size+"-"+i.replace(/[^0-9a-zA-Z_-]/gim,"")},getFromUniqueIdentifier:function(e){var t=!1;return r.each(this.files,(function(i){if(i.uniqueIdentifier===e)return t=i,!1})),t},uploadNextChunk:function(e){var t=!1,i=o.STATUS.PENDING,s=this.uploader.opts.checkChunkUploadedByResponse;if(this.opts.prioritizeFirstAndLastChunk&&(r.each(this.files,(function(e){if(!e.paused&&(!s||e._firstResponse||!e.isUploading()))return e.chunks.length&&e.chunks[0].status()===i?(e.chunks[0].send(),t=!0,!1):e.chunks.length>1&&e.chunks[e.chunks.length-1].status()===i?(e.chunks[e.chunks.length-1].send(),t=!0,!1):void 0})),t))return t;if(r.each(this.files,(function(e){if(!e.paused){if(s&&!e._firstResponse&&e.isUploading())return;r.each(e.chunks,(function(e){if(e.status()===i)return e.send(),t=!0,!1}))}if(t)return!1})),t)return!0;var n=!1;return r.each(this.files,(function(e){if(!e.isComplete())return n=!0,!1})),n||e||!this.files.length||this._triggerAsync("complete"),n},upload:function(e){var t=this._shouldUploadNext();if(!1!==t){!e&&this._trigger("uploadStart");for(var i=!1,r=1;r<=this.opts.simultaneousUploads-t&&((i=this.uploadNextChunk(!e)||i)||!e);r++);i||e||this._triggerAsync("complete")}},_shouldUploadNext:function(){var e=0,t=!0,i=this.opts.simultaneousUploads,s=o.STATUS.UPLOADING;return r.each(this.files,(function(n){return r.each(n.chunks,(function(r){if(r.status()===s&&++e>=i)return t=!1,!1})),t})),t&&e},assignBrowse:function(e,t,i,s){void 0===e.length&&(e=[e]),r.each(e,(function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),r.extend(n.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(n),e.addEventListener("click",(function(t){"label"!==e.tagName.toLowerCase()&&n.click()}),!1)),this.opts.singleFile||i||n.setAttribute("multiple","multiple"),t&&n.setAttribute("webkitdirectory","webkitdirectory"),s&&r.each(s,(function(e,t){n.setAttribute(t,e)}));var o=this;n.addEventListener("change",(function(e){o._trigger(e.type,e),e.target.value&&(o.addFiles(e.target.files,e),e.target.value="")}),!1)}),this)},onDrop:function(e){this._trigger(e.type,e),this.opts.onDropStopPropagation&&e.stopPropagation(),e.preventDefault(),this._parseDataTransfer(e.dataTransfer,e)},_parseDataTransfer:function(e,t){e.items&&e.items[0]&&e.items[0].webkitGetAsEntry?this.webkitReadDataTransfer(e,t):this.addFiles(e.files,t)},webkitReadDataTransfer:function(e,t){var i=this,s=e.items.length,n=[];function o(e){e.readEntries((function(t){t.length?(s+=t.length,r.each(t,(function(e){if(e.isFile){var t=e.fullPath;e.file((function(e){a(e,t)}),l)}else e.isDirectory&&o(e.createReader())})),o(e)):u()}),l)}function a(e,t){e.relativePath=t.substring(1),n.push(e),u()}function l(e){throw e}function u(){0==--s&&i.addFiles(n,t)}r.each(e.items,(function(e){var t=e.webkitGetAsEntry();t?t.isFile?a(e.getAsFile(),t.fullPath):o(t.createReader()):u()}))},_assignHelper:function(e,t,i){void 0===e.length&&(e=[e]);var s=i?"removeEventListener":"addEventListener";r.each(e,(function(e){r.each(t,(function(t,i){e[s](i,t,!1)}),this)}),this)},_preventEvent:function(e){r.preventEvent(e),this._trigger(e.type,e)},assignDrop:function(e){this._onDrop=r.bind(this.onDrop,this),this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop})},unAssignDrop:function(e){this._assignHelper(e,{dragover:this.preventEvent,dragenter:this.preventEvent,dragleave:this.preventEvent,drop:this._onDrop},!0),this._onDrop=null}}),t.exports=c},{"./chunk":1,"./event":2,"./file":4,"./utils":5}],4:[function(e,t,i){var r=e("./utils"),s=e("./chunk");function n(e,t,i){r.defineNonEnumerable(this,"uploader",e),this.isRoot=this.isFolder=e===this,r.defineNonEnumerable(this,"parent",i||null),r.defineNonEnumerable(this,"files",[]),r.defineNonEnumerable(this,"fileList",[]),r.defineNonEnumerable(this,"chunks",[]),r.defineNonEnumerable(this,"_errorFiles",[]),r.defineNonEnumerable(this,"file",null),this.id=r.uid(),this.isRoot||!t?this.file=null:r.isString(t)?(this.isFolder=!0,this.file=null,this.path=t,this.parent.path&&(t=t.substr(this.parent.path.length)),this.name="/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t):(this.file=t,this.fileType=this.file.type,this.name=t.fileName||t.name,this.size=t.size,this.relativePath=t.relativePath||t.webkitRelativePath||this.name,this._parseFile()),this.paused=e.opts.initialPaused,this.error=!1,this.allError=!1,this.aborted=!1,this.completed=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevUploadedSize=0,this._prevProgress=0,this.bootstrap()}function o(e){var t=[],i=e.split("/"),r=i.length,s=1;if(i.splice(r-1,1),r--,i.length)for(;s<=r;)t.push(i.slice(0,s++).join("/")+"/");return t}r.extend(n.prototype,{_parseFile:function(){var e=o(this.relativePath);if(e.length){var t=this.uploader.filePaths;r.each(e,(function(i,r){var s=t[i];s||(s=new n(this.uploader,i,this.parent),t[i]=s,this._updateParentFileList(s)),this.parent=s,s.files.push(this),e[r+1]||s.fileList.push(this)}),this)}else this._updateParentFileList()},_updateParentFileList:function(e){e||(e=this);var t=this.parent;t&&t.fileList.push(e)},_eachAccess:function(e,t){this.isFolder?r.each(this.files,(function(t,i){return e.call(this,t,i)}),this):t.call(this,this)},bootstrap:function(){if(!this.isFolder){var e=this.uploader.opts;r.isFunction(e.initFileFn)&&e.initFileFn.call(this,this),this.abort(!0),this._resetError(),this._prevProgress=0;for(var t=e.forceChunkSize?Math.ceil:Math.floor,i=Math.max(t(this.size/e.chunkSize),1),n=0;n=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(e,t,i){var r=this.uploader,n=s.STATUS,o=this,a=this.getRoot(),l=function(){o._measureSpeed(),r._trigger("fileProgress",a,o,e),o._lastProgressCallback=Date.now()};switch(t){case n.PROGRESS:this._checkProgress()&&l();break;case n.ERROR:this._error(),this.abort(!0),r._trigger("fileError",a,this,i,e);break;case n.SUCCESS:if(this._updateUploadedChunks(i,e),this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var u=Date.now()-this._lastProgressCallback;u0?e/t:this.isComplete()?1:0)}),(function(){if(this.error)i=1;else{if(1===this.chunks.length)return this._prevProgress=Math.max(this._prevProgress,this.chunks[0].progress()),void(i=this._prevProgress);var e=0;r.each(this.chunks,(function(t){e+=t.progress()*(t.endByte-t.startByte)}));var t=e/this.size;this._prevProgress=Math.max(this._prevProgress,t>.9999?1:t),i=this._prevProgress}})),i},getSize:function(){var e=0;return this._eachAccess((function(t){e+=t.size}),(function(){e+=this.size})),e},getFormatSize:function(){var e=this.getSize();return r.formatSize(e)},getRoot:function(){if(this.isRoot)return this;for(var e=this.parent;e;){if(e.parent===this.uploader)return e;e=e.parent}return this},sizeUploaded:function(){var e=0;return this._eachAccess((function(t){e+=t.sizeUploaded()}),(function(){r.each(this.chunks,(function(t){e+=t.sizeUploaded()}))})),e},timeRemaining:function(){var e=0,t=0,i=0;return this._eachAccess((function(s,n){s.paused||s.error||(t+=s.size-s.sizeUploaded(),i+=s.averageSpeed),n===this.files.length-1&&(e=r(t,i))}),(function(){if(this.paused||this.error)e=0;else{var t=this.size-this.sizeUploaded();e=r(t,this.averageSpeed)}})),e;function r(e,t){return e&&!t?Number.POSITIVE_INFINITY:e||t?Math.floor(e/t):0}},removeFile:function(e){if(e.isFolder)for(;e.files.length;){var t=e.files[e.files.length-1];this._removeFile(t)}this._removeFile(e)},_delFilePath:function(e){e.path&&this.filePaths&&delete this.filePaths[e.path],r.each(e.fileList,(function(e){this._delFilePath(e)}),this)},_removeFile:function(e){if(!e.isFolder){r.each(this.files,(function(t,i){if(t===e)return this.files.splice(i,1),!1}),this),e.abort();for(var t,i=e.parent;i&&i!==this;)t=i.parent,i._removeFile(e),i=t}e.parent===this&&r.each(this.fileList,(function(t,i){if(t===e)return this.fileList.splice(i,1),!1}),this),this.isRoot||!this.isFolder||this.files.length||(this.parent._removeFile(this),this.uploader._delFilePath(this)),e.parent=null},getType:function(){return this.isFolder?"folder":this.file.type&&this.file.type.split("/")[1]},getExtension:function(){return this.isFolder?"":this.name.substr(2+(~-this.name.lastIndexOf(".")>>>0)).toLowerCase()}}),t.exports=n},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var r=Object.prototype,s=Array.prototype,n=r.toString,o=function(e){return"[object Function]"===n.call(e)},a=Array.isArray||function(e){return"[object Array]"===n.call(e)},l=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===r},u=0,p={uid:function(){return++u},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(p.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),s.slice.call(e,t,i)},isPlainObject:l,isFunction:o,isArray:a,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(p.isDefined(e.length))for(var r=0,s=e.length;r`-${e.toLowerCase()}`))}const n={name:"uploader-btn",props:{directory:{type:Boolean,default:!1},single:{type:Boolean,default:!1},attrs:{type:Object,default:()=>({})}},setup(t){const i=e.ref(null),r=e.inject("uploader"),s=r.support;return e.onMounted((()=>{e.nextTick((()=>{r.assignBrowse(i.value,t.directory,t.single,t.attrs)}))})),{btn:i,support:s}}},o={class:"uploader-btn",ref:"btn"};n.render=function(t,i,r,s,n,a){return e.withDirectives((e.openBlock(),e.createBlock("label",o,[e.renderSlot(t.$slots,"default")],512)),[[e.vShow,s.support]])};const a={name:"uploader-drop",setup(){const t=e.inject("uploader");let i=e.ref(null),r=e.ref("");const s=t.support,n=()=>{r="uploader-dragover"},o=()=>{r=""},a=()=>{r="uploader-droped"};return e.nextTick((()=>{const e=i.value;t.assignDrop(e),t.on("dragenter",n),t.on("dragleave",o),t.on("drop",a)})),e.onBeforeUnmount((()=>{const e=i.value;t.off("dragenter",n),t.off("dragleave",o),t.off("drop",a),t.unAssignDrop(e)})),{drop:i,dropClass:r,support:s,onDragEnter:n,onDragLeave:o,onDrop:a}}};a.render=function(t,i,r,s,n,o){return e.withDirectives((e.openBlock(),e.createBlock("div",{class:["uploader-drop",s.dropClass],ref:"drop"},[e.renderSlot(t.$slots,"default")],2)),[[e.vShow,s.support]])};const l={name:"uploader-unsupport",setup:()=>({support:e.inject("uploader").support})},u={class:"uploader-unsupport"},p=e.createVNode("p",null,[e.createTextVNode(" Your browser, unfortunately, is not supported by Uploader.js. The library requires support for "),e.createVNode("a",{href:"http://www.w3.org/TR/FileAPI/"},"the HTML5 File API"),e.createTextVNode(" along with "),e.createVNode("a",{href:"http://www.w3.org/TR/FileAPI/#normalization-of-params"},"file slicing"),e.createTextVNode(". ")],-1);l.render=function(t,i,r,s,n,o){return e.withDirectives((e.openBlock(),e.createBlock("div",u,[e.renderSlot(t.$slots,"default",{},(()=>[p]))],512)),[[e.vShow,!s.support]])};const h=["fileProgress","fileSuccess","fileComplete","fileError"];const c={name:"uploader-file",props:{file:{type:Object,default:()=>({})},list:{type:Boolean,default:!1}},setup(t){const i=e.getCurrentInstance();let s={},n=0;const o=e.ref(null),a=e.ref(!1),l=e.ref(!1),u=e.ref(0),p=e.ref(0),c=e.ref(!1),d=e.ref(!1),f=e.ref(0),v=e.ref(""),g=e.ref(0),m=e.ref(0),S=e.ref(0),y=e.ref(""),k=e.ref(""),_=e.ref(""),b=e.computed((()=>{let e=t.file.isFolder?"folder":"unknown";const i=t.file.uploader.opts.categoryMap||{image:["gif","jpg","jpeg","png","bmp","webp"],video:["mp4","m3u8","rmvb","avi","swf","3gp","mkv","flv"],audio:["mp3","wav","wma","ogg","aac","flac"],document:["doc","txt","docx","pages","epub","pdf","numbers","csv","xls","xlsx","keynote","ppt","pptx"]};return Object.keys(i).forEach((t=>{i[t].indexOf(k.value)>-1&&(e=t)})),e})),x=e.computed((()=>{m.value=Math.floor(100*m.value);const e=`translateX(${Math.floor(m.value-100)}%)`;return{progress:`${m.value}%`,webkitTransform:e,mozTransform:e,msTransform:e,transform:e}})),R=e.computed((()=>`${r.utils.formatSize(u.value)} / s`)),E=e.computed((()=>{let e=l;return c.value?"success":e.value?"error":d.value?"uploading":a.value?"paused":"waiting"})),C=e.computed((()=>{const e=t.file.uploader.fileStatusText;let i=E.value;return i="function"==typeof e?e(E.value,o.value):e[E.value],i||E})),N=e.computed((()=>{const e=t.file;if(S.value===Number.POSITIVE_INFINITY||0===S.value)return"";let i=function(e){const t=Math.floor(e/31536e3);if(t)return t+" year"+o(t);const i=Math.floor((e%=31536e3)/86400);if(i)return i+" day"+o(i);const r=Math.floor((e%=86400)/3600);if(r)return r+" hour"+o(r);const s=Math.floor((e%=3600)/60);if(s)return s+" minute"+o(s);const n=e%60;return n+" second"+o(n);function o(e){return e>1?"s":""}}(S.value);const r=e.uploader.opts.parseTimeRemaining;return r&&(i=r(S.value,i)),i})),F=()=>{a.value=t.file.paused,l.value=t.file.error,d.value=t.file.isUploading()},w=e=>{let t=e;try{t=JSON.parse(e)}catch(i){}o.value=t},D=(e,r)=>{const s=r[0],n=r[1],o=t.list?s:n;if(JSON.stringify(t.file)===JSON.stringify(o)){if(t.list&&"fileSuccess"===e)return void w(r[2]);i.ctx[`${e}`](r)}},U=()=>{m.value=t.file.progress(),u.value=t.file.averageSpeed,p.value=t.file.currentSpeed,S.value=t.file.timeRemaining(),g.value=t.file.sizeUploaded(),F()},P=(e,t,i)=>{e&&w(i),U(),l.value=!1,c.value=!0,d.value=!1};return e.watch(E,((e,t)=>{t&&"uploading"===e&&"uploading"!==t?n=setTimeout((()=>{_.value="uploader-file-progressing"}),200):(clearTimeout(n),_.value="")})),e.onMounted((()=>{a.value=t.file.paused,l.value=t.file.error,u.value=t.file.averageSpeed,p.value=t.file.currentSpeed,c.value=t.file.isComplete(),d.value=t.file.isUploading(),f.value=t.file.getSize(),v.value=t.file.getFormatSize(),g.value=t.file.sizeUploaded(),m.value=t.file.progress(),S.value=t.file.timeRemaining(),y.value=t.file.getType(),k.value=t.file.getExtension();h.forEach((e=>{t.file.uploader.on(e,(e=>(s[e]=(...t)=>{D(e,t)},s[e]))(e))}))})),e.onUnmounted((()=>{h.forEach((e=>{t.file.uploader.off(e,s[e])})),s=null})),{response:o,paused:a,error:l,averageSpeed:u,currentSpeed:p,isComplete:c,isUploading:d,size:f,formatedSize:v,uploadedSize:g,progress:m,timeRemaining:S,type:y,extension:k,progressingClass:_,fileCategory:b,progressStyle:x,formatedAverageSpeed:R,status:E,statusText:C,formatedTimeRemaining:N,actionCheck:F,pause:()=>{t.file.pause(),F(),U()},resume:()=>{t.file.resume(),F()},remove:()=>{t.file.cancel()},retry:()=>{t.file.retry(),F()},processResponse:w,fileEventsHandler:D,fileProgress:U,fileSuccess:P,fileComplete:()=>{P()},fileError:(e,t,i)=>{U(),w(i),l.value=!0,c.value=!1,d.value=!1}}}},d={class:"uploader-file-info"},f={class:"uploader-file-name"},v={class:"uploader-file-size"},g=e.createVNode("div",{class:"uploader-file-meta"},null,-1),m={class:"uploader-file-status"},S={class:"uploader-file-actions"};c.render=function(t,i,r,s,n,o){return e.openBlock(),e.createBlock("div",{class:"uploader-file",status:s.status},[e.renderSlot(t.$slots,"default",{file:r.file,list:r.list,status:s.status,paused:s.paused,error:s.error,response:s.response,averageSpeed:s.averageSpeed,formatedAverageSpeed:s.formatedAverageSpeed,currentSpeed:s.currentSpeed,isComplete:s.isComplete,isUploading:s.isUploading,size:s.size,formatedSize:s.formatedSize,uploadedSize:s.uploadedSize,progress:s.progress,progressStyle:s.progressStyle,progressingClass:s.progressingClass,timeRemaining:s.timeRemaining,formatedTimeRemaining:s.formatedTimeRemaining,type:s.type,extension:s.extension,fileCategory:s.fileCategory},(()=>[e.createVNode("div",{class:["uploader-file-progress",s.progressingClass],style:s.progressStyle},null,6),e.createVNode("div",d,[e.createVNode("div",f,[e.createVNode("i",{class:"uploader-file-icon",icon:s.fileCategory},null,8,["icon"]),e.createTextVNode(e.toDisplayString(r.file.name),1)]),e.createVNode("div",v,e.toDisplayString(s.formatedSize),1),g,e.createVNode("div",m,[e.withDirectives(e.createVNode("span",null,e.toDisplayString(s.statusText),513),[[e.vShow,"uploading"!==s.status]]),e.withDirectives(e.createVNode("span",null,[e.createVNode("span",null,e.toDisplayString(s.progressStyle.progress)+" ",1),e.createVNode("em",null,e.toDisplayString(s.formatedAverageSpeed)+" ",1),e.createVNode("i",null,e.toDisplayString(s.formatedTimeRemaining),1)],512),[[e.vShow,"uploading"===s.status]])]),e.createVNode("div",S,[e.createVNode("span",{class:"uploader-file-pause",onClick:i[1]||(i[1]=(...e)=>s.pause&&s.pause(...e))}),e.createVNode("span",{class:"uploader-file-resume",onClick:i[2]||(i[2]=(...e)=>s.resume&&s.resume(...e))},"️"),e.createVNode("span",{class:"uploader-file-retry",onClick:i[3]||(i[3]=(...e)=>s.retry&&s.retry(...e))}),e.createVNode("span",{class:"uploader-file-remove",onClick:i[4]||(i[4]=(...e)=>s.remove&&s.remove(...e))})])])]))],8,["status"])};const y={name:"uploader-list",components:{UploaderFile:c},setup:()=>({fileList:e.inject("uploader").fileList})},k={class:"uploader-list"};y.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-file");return e.openBlock(),e.createBlock("div",k,[e.renderSlot(t.$slots,"default",{fileList:s.fileList},(()=>[e.createVNode("ul",null,[(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(s.fileList,(t=>(e.openBlock(),e.createBlock("li",{key:t.id},[e.createVNode(a,{file:t,list:!0},null,8,["file"])])))),128))])]))])};const _={name:"uploader-files",components:{UploaderFile:c},setup:()=>({files:e.inject("uploader").files})},b={class:"uploader-files"};_.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-file");return e.openBlock(),e.createBlock("div",b,[e.renderSlot(t.$slots,"default",{files:s.files},(()=>[e.createVNode("ul",null,[(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(s.files,(t=>(e.openBlock(),e.createBlock("li",{key:t.id},[e.createVNode(a,{file:t},null,8,["file"])])))),128))])]))])};const x="fileAdded",R="filesAdded",E="uploadStart",C={name:"uploader",props:{options:{type:Object,default:()=>({})},autoStart:{type:Boolean,default:!0},fileStatusText:{type:[Object,Function],default:()=>({success:"success",error:"error",uploading:"uploading",paused:"paused",waiting:"waiting"})}},setup(t,{emit:i}){const n=e.ref(null),o=e.ref(!1),a=e.ref([]),l=e.ref([]),u=e.getCurrentInstance();let p=new r(t.options);const h=()=>{o.value=!0},c=t=>{const r=e.reactive(t);if(i(s(x),r),r.ignored)return!1},d=(e,t)=>{if(i(s(R),e,t),e.ignored||t.ignored)return!1},f=e=>{a.value=p.files,l.value=p.fileList},v=(e,i)=>{a.value=p.files,l.value=p.fileList,t.autoStart&&p.upload()},g=(...e)=>{const t=e[0],r={[x]:!0,[R]:!0,[E]:"uploadStart"}[t];if(r){if(!0===r)return;u.ctx[r].apply(u.ctx[r],e.slice(1))}e[0]=s(t),i.apply(u.ctx,e)};return t.options.initialPaused=!t.autoStart,p.fileStatusText=t.fileStatusText,p.on("catchAll",g),p.on(x,c),p.on(R,d),p.on("fileRemoved",f),p.on("filesSubmitted",v),p.uploadStart=h,e.onUnmounted((()=>{p.off("catchAll",g),p.off(x,c),p.off(R,d),p.off("fileRemoved",f),p.off("filesSubmitted",v),p=null})),e.provide("uploader",e.reactive(p)),{uploader:p,started:o,files:a,fileList:l,uploadStart:h,fileAdded:c,filesAdded:d,fileRemoved:f,filesSubmitted:v,allEvent:g,uploaderList:n}},components:{UploaderBtn:n,UploaderDrop:a,UploaderUnsupport:l,UploaderList:y,UploaderFiles:_,UploaderFile:c}},N={class:"uploader"},F=e.createVNode("p",null,"Drop files here to upload or",-1),w=e.createTextVNode("select files"),D=e.createTextVNode("select folder");C.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-unsupport"),l=e.resolveComponent("uploader-btn"),u=e.resolveComponent("uploader-drop"),p=e.resolveComponent("uploader-list");return e.openBlock(),e.createBlock("div",N,[e.renderSlot(t.$slots,"default",{files:s.files,fileList:s.fileList,started:s.started},(()=>[e.createVNode(a),e.createVNode(u,null,{default:e.withCtx((()=>[F,e.createVNode(l,null,{default:e.withCtx((()=>[w])),_:1}),e.createVNode(l,{directory:!0},{default:e.withCtx((()=>[D])),_:1})])),_:1}),e.createVNode(p)]))])};return{version:"1.0.0-beta.3",install:function(e,t){e.component(C.name,C),e.component(n.name,n),e.component(a.name,a),e.component(l.name,l),e.component(y.name,y),e.component(_.name,_),e.component(c.name,c)},Uploader:C,UploaderBtn:n,UploaderDrop:a,UploaderUnsupport:l,UploaderList:y,UploaderFiles:_,UploaderFile:c}})); diff --git a/package.json b/package.json index 60f47b9..b9ad0e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-simple-uploader", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.3", "description": "A Vue.js upload component powered by simple-uploader.js", "main": "dist/vue-simple-uploader.umd.js", "module": "dist/vue-simple-uploader.es.js",