!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self)["vue-uploader"]=t(e.Vue)}(this,(function(e){"use strict";function t(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 i={exports:{}}; /*! * Uploader - Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads * @version v0.6.0 * @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&&(d.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 d(e){this.support=p,this.support&&(this.supportDirectory=h,r.defineNonEnumerable(this,"filePaths",{}),this.opts=r.extend({},d.defaults,e||{}),this.preventEvent=r.bind(this._preventEvent,this),n.call(this,this))}var c=function(e,t,i,r,s){s.readFinished(e.file[d.sliceName](i,r,t))};d.version=a,d.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:c,checkChunkUploadedByResponse:null,initialPaused:!1,processResponse:function(e,t){t(null,e)},processParams:function(e){return e}},d.utils=r,d.event=s,d.File=n,d.Chunk=o,d.prototype=r.extend({},n.prototype),r.extend(d.prototype,s),r.extend(d.prototype,{constructor:d,_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=d},{"./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").proxy.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.createElementBlock("label",o,[e.renderSlot(t.$slots,"default")],512)),[[e.vShow,s.support]])};const a={name:"uploader-drop",setup(){const t=e.inject("uploader").proxy.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.onMounted((()=>{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.createElementBlock("div",{class:e.normalizeClass(["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").proxy.uploader.support})},u={class:"uploader-unsupport"},p=e.createElementVNode("p",null,[e.createTextVNode(" Your browser, unfortunately, is not supported by Uploader.js. The library requires support for "),e.createElementVNode("a",{href:"http://www.w3.org/TR/FileAPI/"},"the HTML5 File API"),e.createTextVNode(" along with "),e.createElementVNode("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.createElementBlock("div",u,[e.renderSlot(t.$slots,"default",{},(()=>[p]))],512)),[[e.vShow,!s.support]])};const h=["fileProgress","fileSuccess","fileComplete","fileError"];const d={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),d=e.ref(!1),c=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(""),E=e.ref(""),k=e.ref(""),_=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(E.value)>-1&&(e=t)})),e})),b=e.computed((()=>{const e=Math.floor(100*m.value),t=`translateX(${Math.floor(e-100)}%)`;return{progress:`${e}%`,webkitTransform:t,mozTransform:t,msTransform:t,transform:t}})),x=e.computed((()=>`${r.utils.formatSize(u.value)} / s`)),R=e.computed((()=>{let e=l;return d.value?"success":e.value?"error":c.value?"uploading":a.value?"paused":"waiting"})),F=e.computed((()=>{const e=t.file.uploader.fileStatusText;let i=R.value;return i="function"==typeof e?e(R.value,o.value):e[R.value],i||R})),C=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})),N=()=>{a.value=t.file.paused,l.value=t.file.error,c.value=t.file.isUploading()},w=e=>{let t=e;try{t=JSON.parse(e)}catch(i){}o.value=t},D=(r,s)=>{const n=s[0],o=s[1],a=t.list?n:o;if(e.toRaw(t.file)===e.toRaw(a)){if(t.list&&"fileSuccess"===r)return void w(s[2]);i.setupState[r](...s)}},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(),N()},P=(e,t,i)=>{e&&w(i),U(),l.value=!1,d.value=!0,c.value=!1};return e.watch(R,((e,t)=>{t&&"uploading"===e&&"uploading"!==t?n=setTimeout((()=>{k.value="uploader-file-progressing"}),200):(clearTimeout(n),k.value="")})),e.onMounted((()=>{a.value=t.file.paused,l.value=t.file.error,u.value=t.file.averageSpeed,p.value=t.file.currentSpeed,d.value=t.file.isComplete(),c.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(),E.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:d,isUploading:c,size:f,formatedSize:v,uploadedSize:g,progress:m,timeRemaining:S,type:y,extension:E,progressingClass:k,fileCategory:_,progressStyle:b,formatedAverageSpeed:x,status:R,statusText:F,formatedTimeRemaining:C,actionCheck:N,pause:()=>{t.file.pause(),N(),U()},resume:()=>{t.file.resume(),N()},remove:()=>{t.file.cancel()},retry:()=>{t.file.retry(),N()},processResponse:w,fileEventsHandler:D,fileProgress:U,fileSuccess:P,fileComplete:()=>{P()},fileError:(e,t,i)=>{U(),w(i),l.value=!0,d.value=!1,c.value=!1}}}},c=["status"],f={class:"uploader-file-info"},v={class:"uploader-file-name"},g=["icon"],m={class:"uploader-file-size"},S=e.createElementVNode("div",{class:"uploader-file-meta"},null,-1),y={class:"uploader-file-status"},E={class:"uploader-file-actions"};d.render=function(t,i,r,s,n,o){return e.openBlock(),e.createElementBlock("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.createElementVNode("div",{class:e.normalizeClass(["uploader-file-progress",s.progressingClass]),style:e.normalizeStyle(s.progressStyle)},null,6),e.createElementVNode("div",f,[e.createElementVNode("div",v,[e.createElementVNode("i",{class:"uploader-file-icon",icon:s.fileCategory},null,8,g),e.createTextVNode(e.toDisplayString(r.file.name),1)]),e.createElementVNode("div",m,e.toDisplayString(s.formatedSize),1),S,e.createElementVNode("div",y,[e.withDirectives(e.createElementVNode("span",null,e.toDisplayString(s.statusText),513),[[e.vShow,"uploading"!==s.status]]),e.withDirectives(e.createElementVNode("span",null,[e.createElementVNode("span",null,e.toDisplayString(s.progressStyle.progress)+" ",1),e.createElementVNode("em",null,e.toDisplayString(s.formatedAverageSpeed)+" ",1),e.createElementVNode("i",null,e.toDisplayString(s.formatedTimeRemaining),1)],512),[[e.vShow,"uploading"===s.status]])]),e.createElementVNode("div",E,[e.createElementVNode("span",{class:"uploader-file-pause",onClick:i[0]||(i[0]=(...e)=>s.pause&&s.pause(...e))}),e.createElementVNode("span",{class:"uploader-file-resume",onClick:i[1]||(i[1]=(...e)=>s.resume&&s.resume(...e))},"️"),e.createElementVNode("span",{class:"uploader-file-retry",onClick:i[2]||(i[2]=(...e)=>s.retry&&s.retry(...e))}),e.createElementVNode("span",{class:"uploader-file-remove",onClick:i[3]||(i[3]=(...e)=>s.remove&&s.remove(...e))})])])]))],8,c)};const k={name:"uploader-list",components:{UploaderFile:d},setup(){const t=e.inject("uploader").proxy;return{fileList:e.computed((()=>t.fileList))}}},_={class:"uploader-list"};k.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-file");return e.openBlock(),e.createElementBlock("div",_,[e.renderSlot(t.$slots,"default",{fileList:s.fileList},(()=>[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.fileList,(t=>(e.openBlock(),e.createElementBlock("li",{key:t.id},[e.createVNode(a,{file:t,list:!0},null,8,["file"])])))),128))])]))])};const b={name:"uploader-files",components:{UploaderFile:d},setup(){const t=e.inject("uploader").proxy;return{files:e.computed((()=>t.files))}}},x={class:"uploader-files"};b.render=function(t,i,r,s,n,o){const a=e.resolveComponent("uploader-file");return e.openBlock(),e.createElementBlock("div",x,[e.renderSlot(t.$slots,"default",{files:s.files},(()=>[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.files,(t=>(e.openBlock(),e.createElementBlock("li",{key:t.id},[e.createVNode(a,{file:t},null,8,["file"])])))),128))])]))])};const R="fileAdded",F="filesAdded",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"})},onFileAdded:Function,onFilesAdded:Function},emits:["change","dragover","dragenter","dragleave","file-success","file-complete","file-progress","file-added","files-added","files-submitted","file-removed","file-retry","file-error","upload-start","complete"],setup(t,{emit:i}){const n=e.ref(!1),o=e.ref([]),a=e.ref([]),l=e.getCurrentInstance();let u=new r(t.options);const p=e=>{const r=e;if(t.onFileAdded){if(!1===t.onFileAdded(r)||r.ignored)return!1}else if(i(s(R),r),r.ignored)return!1},h=(e,r)=>{if(t.onFilesAdded){if(!1===t.onFilesAdded(e,r)||e.ignored||r.ignored)return!1}else if(i(s(F),e,r),e.ignored||r.ignored)return!1},d=()=>{o.value=[...u.files],a.value=[...u.fileList]},c=()=>{o.value=[...u.files],a.value=[...u.fileList],t.autoStart&&u.upload()},f=(...e)=>{const t=e[0],r={[R]:!0,[F]:!0,uploadStart:"uploadStart"}[t];if(r){if(!0===r)return;l.setupState[r](...e.slice(1))}e[0]=s(t),i(...e)};return t.options.initialPaused=!t.autoStart,u.fileStatusText=t.fileStatusText,u.on("catchAll",f),u.on(R,p),u.on(F,h),u.on("fileRemoved",d),u.on("filesSubmitted",c),e.onUnmounted((()=>{u.off("catchAll",f),u.off(R,p),u.off(F,h),u.off("fileRemoved",d),u.off("filesSubmitted",c),u=null})),e.provide("uploader",l),{uploader:u,started:n,files:o,fileList:a,uploadStart:()=>{n.value=!0},fileAdded:p,filesAdded:h,fileRemoved:d,filesSubmitted:c,allEvent:f}},components:{UploaderBtn:n,UploaderDrop:a,UploaderUnsupport:l,UploaderList:k,UploaderFiles:b,UploaderFile:d}},N={class:"uploader"},w=e.createElementVNode("p",null,"Drop files here to upload or",-1);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.createElementBlock("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((()=>[w,e.createVNode(l,null,{default:e.withCtx((()=>[e.createTextVNode("select files")])),_:1}),e.createVNode(l,{directory:!0},{default:e.withCtx((()=>[e.createTextVNode("select folder")])),_:1})])),_:1}),e.createVNode(p)]))])};return{version:"1.0.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(k.name,k),e.component(b.name,b),e.component(d.name,d)},Uploader:C,UploaderBtn:n,UploaderDrop:a,UploaderUnsupport:l,UploaderList:k,UploaderFiles:b,UploaderFile:d}}));