@wangeditor-next/core 1.8.4 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/src/config/interface.d.ts +8 -2
- package/dist/core/src/editor/interface.d.ts +2 -0
- package/dist/core/src/editor/plugins/with-history.d.ts +7 -0
- package/dist/core/src/to-html/elem2html.d.ts +2 -1
- package/dist/core/src/to-html/node2html.d.ts +6 -2
- package/dist/core/src/to-html/text2html.d.ts +2 -1
- package/dist/core/src/upload/createUploader.d.ts +4 -2
- package/dist/index.js +1 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -12
- package/dist/index.mjs.map +1 -1
- package/dist/upload.js +1 -12
- package/dist/upload.js.map +1 -1
- package/dist/upload.mjs +1 -12
- package/dist/upload.mjs.map +1 -1
- package/package.json +4 -2
package/dist/upload.js
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
!function(
|
|
2
|
-
/**
|
|
3
|
-
* Takes a string with placeholder variables like `%{smart_count} file selected`
|
|
4
|
-
* and replaces it with values from options `{smart_count: 5}`
|
|
5
|
-
*
|
|
6
|
-
* @license https://github.com/airbnb/polyglot.js/blob/master/LICENSE
|
|
7
|
-
* taken from https://github.com/airbnb/polyglot.js/blob/master/lib/polyglot.js#L299
|
|
8
|
-
*
|
|
9
|
-
* @param {string} phrase that needs interpolation, with placeholders
|
|
10
|
-
* @param {object} options with values that will be used to replace placeholders
|
|
11
|
-
* @returns {any[]} interpolated
|
|
12
|
-
*/function o(e,t){const r=/\$/g;let i=[e];if(null==t)return i;for(const e of Object.keys(t))if("_"!==e){let o=t[e];"string"==typeof o&&(o=r[Symbol.replace](o,"$$$$")),i=s(i,new RegExp(`%\\{${e}\\}`,"g"),o)}return i}var n=r("apply");function l(e){if(null==e||!e.strings)return;const t=this.locale;this.locale={...t,strings:{...t.strings,...e.strings}},this.locale.pluralize=e.pluralize||t.pluralize}return S=class{constructor(t){Object.defineProperty(this,n,{value:l}),this.locale={strings:{},pluralize:e=>1===e?0:1},Array.isArray(t)?t.forEach(e(this,n)[n],this):e(this,n)[n](t)}translate(e,t){return this.translateArray(e,t).join("")}translateArray(e,t){if(!i(this.locale.strings,e))throw new Error(`missing string: ${e}`);const r=this.locale.strings[e];if("object"==typeof r){if(t&&void 0!==t.smart_count){return o(r[this.locale.pluralize(t.smart_count)],t)}throw new Error("Attempted to use a string with plural forms, but no value was given for %{smart_count}")}return o(r,t)}},S}function J(){return x||(x=1,E=function(){var e={},t=e._fns={};return e.emit=function(e,r,i,s,o,n,l){var a=function(e){var r=t[e]?t[e]:[],i=e.indexOf(":"),s=-1===i?[e]:[e.substring(0,i),e.substring(i+1)],o=Object.keys(t),n=0,l=o.length;for(;n<l;n++){var a=o[n];if("*"===a&&(r=r.concat(t[a])),2===s.length&&s[0]===a){r=r.concat(t[a]);break}}return r}(e);a.length&&function(e,t,r){var i=0,s=t.length;for(;i<s&&t[i];i++)t[i].event=e,t[i].apply(t[i],r)}(e,a,[r,i,s,o,n,l])},e.on=function(e,r){t[e]||(t[e]=[]),t[e].push(r)},e.once=function(t,r){this.on(t,function i(){r.apply(this,arguments),e.off(t,i)})},e.off=function(e,t){var r=[];if(e&&t)for(var i=this._fns[e],s=0,o=i?i.length:0;s<o;s++)i[s]!==t&&r.push(i[s]);r.length?this._fns[e]=r:delete this._fns[e]},e}),E}function Z(){if(F)return U;F=1;var e=0;function t(t){return"__private_"+e+++"_"+t}var r=t("publish");class i{constructor(){Object.defineProperty(this,r,{value:s}),this.state={},this.callbacks=[]}getState(){return this.state}setState(e){const t={...this.state},i={...this.state,...e};this.state=i,function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}(this,r)[r](t,i,e)}subscribe(e){return this.callbacks.push(e),()=>{this.callbacks.splice(this.callbacks.indexOf(e),1)}}}function s(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.callbacks.forEach(e=>{e(...t)})}return i.VERSION="2.1.1",U=function(){return new i}}function ee(){if(k)return j;return k=1,j=function(e){const t=e.lastIndexOf(".");return-1===t||t===e.length-1?{name:e,extension:void 0}:{name:e.slice(0,t),extension:e.slice(t+1)}}}function te(){return $?T:($=1,T={md:"text/markdown",markdown:"text/markdown",mp4:"video/mp4",mp3:"audio/mp3",svg:"image/svg+xml",jpg:"image/jpeg",png:"image/png",gif:"image/gif",heic:"image/heic",heif:"image/heif",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",tab:"text/tab-separated-values",avi:"video/x-msvideo",mks:"video/x-matroska",mkv:"video/x-matroska",mov:"video/quicktime",dicom:"application/dicom",doc:"application/msword",docm:"application/vnd.ms-word.document.macroenabled.12",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",dot:"application/msword",dotm:"application/vnd.ms-word.template.macroenabled.12",dotx:"application/vnd.openxmlformats-officedocument.wordprocessingml.template",xla:"application/vnd.ms-excel",xlam:"application/vnd.ms-excel.addin.macroenabled.12",xlc:"application/vnd.ms-excel",xlf:"application/x-xliff+xml",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlsb:"application/vnd.ms-excel.sheet.binary.macroenabled.12",xlsm:"application/vnd.ms-excel.sheet.macroenabled.12",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xlt:"application/vnd.ms-excel",xltm:"application/vnd.ms-excel.template.macroenabled.12",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template",xlw:"application/vnd.ms-excel",txt:"text/plain",text:"text/plain",conf:"text/plain",log:"text/plain",pdf:"application/pdf",zip:"application/zip","7z":"application/x-7z-compressed",rar:"application/x-rar-compressed",tar:"application/x-tar",gz:"application/gzip",dmg:"application/x-apple-diskimage"})}function re(){if(B)return H;B=1;var e=W,t=h(),i=V();let s,o;function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var l=0;function a(e){return"__private_"+l+++"_"+e}const u=Q(),p=J(),d=r,c=Z(),f=function(){if(A)return R;A=1;const e=ee(),t=te();return R=function(r){var i;if(r.type)return r.type;const s=r.name?null==(i=e(r.name).extension)?void 0:i.toLowerCase():null;return s&&s in t?t[s]:"application/octet-stream"}}(),g=ee(),m=function(){if(N)return C;function e(e){let t="";return e.replace(/[^A-Z0-9]/gi,e=>(t+=`-${function(e){return e.charCodeAt(0).toString(32)}(e)}`,"/"))+t}return N=1,C=function(t){let r="uppy";return"string"==typeof t.name&&(r+=`-${e(t.name.toLowerCase())}`),void 0!==t.type&&(r+=`-${t.type}`),t.meta&&"string"==typeof t.meta.relativePath&&(r+=`-${e(t.meta.relativePath.toLowerCase())}`),void 0!==t.data.size&&(r+=`-${t.data.size}`),void 0!==t.data.lastModified&&(r+=`-${t.data.lastModified}`),r}}(),y=(M||(M=1,I=function(e){if(null==e&&"undefined"!=typeof navigator&&(e=navigator.userAgent),!e)return!0;const t=/Edge\/(\d+\.\d+)/.exec(e);if(!t)return!0;const r=t[1];let[i,s]=r.split(".");return i=parseInt(i,10),s=parseInt(s,10),i<15||15===i&&s<15063||i>18||18===i&&s>=18218}),I),_=z?L:(z=1,L=function(e,t){return t.name?t.name:"image"===e.split("/")[0]?`${e.split("/")[0]}.${e.split("/")[1]}`:"noname"}),v=q?D:(q=1,D={strings:{addBulkFilesFailed:{0:"Failed to add %{smart_count} file due to an internal error",1:"Failed to add %{smart_count} files due to internal errors"},youCanOnlyUploadX:{0:"You can only upload %{smart_count} file",1:"You can only upload %{smart_count} files"},youHaveToAtLeastSelectX:{0:"You have to select at least %{smart_count} file",1:"You have to select at least %{smart_count} files"},exceedsSize:"%{file} exceeds maximum allowed size of %{size}",missingRequiredMetaField:"Missing required meta fields",missingRequiredMetaFieldOnFile:"Missing required meta fields in %{fileName}",inferiorSize:"This file is smaller than the allowed size of %{size}",youCanOnlyUploadFileTypes:"You can only upload: %{types}",noMoreFilesAllowed:"Cannot add more files",noDuplicates:"Cannot add the duplicate file '%{fileName}', it already exists",companionError:"Connection with Companion failed",authAborted:"Authentication aborted",companionUnauthorizeHint:"To unauthorize to your %{provider} account, please go to %{url}",failedToUpload:"Failed to upload %{file}",noInternetConnection:"No Internet connection",connectedToInternet:"Connected to the Internet",noFilesFound:"You have no files or folders here",selectX:{0:"Select %{smart_count}",1:"Select %{smart_count}"},allFilesFromFolderNamed:"All files from folder %{name}",openFolderNamed:"Open folder %{name}",cancel:"Cancel",logOut:"Log out",filter:"Filter",resetFilter:"Reset filter",loading:"Loading...",authenticateWithTitle:"Please authenticate with %{pluginName} to select files",authenticateWith:"Connect to %{pluginName}",signInWithGoogle:"Sign in with Google",searchImages:"Search for images",enterTextToSearch:"Enter text to search for images",search:"Search",emptyFolderAdded:"No files were added from empty folder",folderAlreadyAdded:'The folder "%{folder}" was already added',folderAdded:{0:"Added %{smart_count} file from %{folder}",1:"Added %{smart_count} files from %{folder}"}}});var b=a("plugins"),w=a("restricter"),P=a("storeUnsubscribe"),S=a("emitter"),O=a("preProcessors"),E=a("uploaders"),x=a("postProcessors"),U=a("informAndEmit"),F=a("checkRequiredMetaFieldsOnFile"),j=a("checkRequiredMetaFields"),k=a("assertNewUploadAllowed"),T=a("checkAndCreateFileStateObject"),$=a("startIfAutoProceed"),X=a("addListeners"),K=a("updateOnlineStatus"),G=a("createUpload"),Y=a("getUpload"),re=a("removeUpload"),ie=a("runUpload");s=Symbol.for("uppy test: getPlugins"),o=Symbol.for("uppy test: createUpload");class se{constructor(e){Object.defineProperty(this,ie,{value:ge}),Object.defineProperty(this,re,{value:fe}),Object.defineProperty(this,Y,{value:he}),Object.defineProperty(this,G,{value:ce}),Object.defineProperty(this,X,{value:de}),Object.defineProperty(this,$,{value:pe}),Object.defineProperty(this,T,{value:ue}),Object.defineProperty(this,k,{value:ae}),Object.defineProperty(this,j,{value:le}),Object.defineProperty(this,F,{value:ne}),Object.defineProperty(this,U,{value:oe}),Object.defineProperty(this,b,{writable:!0,value:Object.create(null)}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,P,{writable:!0,value:void 0}),Object.defineProperty(this,S,{writable:!0,value:p()}),Object.defineProperty(this,O,{writable:!0,value:new Set}),Object.defineProperty(this,E,{writable:!0,value:new Set}),Object.defineProperty(this,x,{writable:!0,value:new Set}),Object.defineProperty(this,K,{writable:!0,value:this.updateOnlineStatus.bind(this)}),this.defaultLocale=v;const r={id:"uppy",autoProceed:!1,allowMultipleUploads:!0,allowMultipleUploadBatches:!0,debug:!1,restrictions:i.defaultOptions,meta:{},onBeforeFileAdded:e=>e,onBeforeUpload:e=>e,store:c(),logger:t.justErrorsLogger,infoTimeout:5e3};this.opts={...r,...e,restrictions:{...r.restrictions,...e&&e.restrictions}},e&&e.logger&&e.debug?this.log("You are using a custom `logger`, but also set `debug: true`, which uses built-in logger to output logs to console. Ignoring `debug: true` and using your custom `logger`.","warning"):e&&e.debug&&(this.opts.logger=t.debugLogger),this.log(`Using Core v${this.constructor.VERSION}`),this.i18nInit(),this.calculateProgress=d(this.calculateProgress.bind(this),500,{leading:!0,trailing:!0}),this.store=this.opts.store,this.setState({plugins:{},files:{},currentUploads:{},allowNewUpload:!0,capabilities:{uploadProgress:y(),individualCancellation:!0,resumableUploads:!1},totalProgress:0,meta:{...this.opts.meta},info:[],recoveredState:null}),n(this,w)[w]=new i.Restricter(()=>this.opts,this.i18n),n(this,P)[P]=this.store.subscribe((e,t,r)=>{this.emit("state-update",e,t,r),this.updateAll(t)}),this.opts.debug&&"undefined"!=typeof window&&(window[this.opts.id]=this),n(this,X)[X]()}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];n(this,S)[S].emit(e,...r)}on(e,t){return n(this,S)[S].on(e,t),this}once(e,t){return n(this,S)[S].once(e,t),this}off(e,t){return n(this,S)[S].off(e,t),this}updateAll(e){this.iteratePlugins(t=>{t.update(e)})}setState(e){this.store.setState(e)}getState(){return this.store.getState()}get state(){return this.getState()}setFileState(e,t){if(!this.getState().files[e])throw new Error(`Can’t set state for ${e} (the file could have been removed)`);this.setState({files:{...this.getState().files,[e]:{...this.getState().files[e],...t}}})}i18nInit(){const e=new u([this.defaultLocale,this.opts.locale]);this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.locale=e.locale}setOptions(e){this.opts={...this.opts,...e,restrictions:{...this.opts.restrictions,...e&&e.restrictions}},e.meta&&this.setMeta(e.meta),this.i18nInit(),e.locale&&this.iteratePlugins(e=>{e.setOptions()}),this.setState()}resetProgress(){const e={percentage:0,bytesUploaded:0,uploadComplete:!1,uploadStarted:null},t={...this.getState().files},r={};Object.keys(t).forEach(i=>{const s={...t[i]};s.progress={...s.progress,...e},r[i]=s}),this.setState({files:r,totalProgress:0}),this.emit("reset-progress")}addPreProcessor(e){n(this,O)[O].add(e)}removePreProcessor(e){return n(this,O)[O].delete(e)}addPostProcessor(e){n(this,x)[x].add(e)}removePostProcessor(e){return n(this,x)[x].delete(e)}addUploader(e){n(this,E)[E].add(e)}removeUploader(e){return n(this,E)[E].delete(e)}setMeta(e){const t={...this.getState().meta,...e},r={...this.getState().files};Object.keys(r).forEach(t=>{r[t]={...r[t],meta:{...r[t].meta,...e}}}),this.log("Adding metadata:"),this.log(e),this.setState({meta:t,files:r})}setFileMeta(e,t){const r={...this.getState().files};if(!r[e])return void this.log("Was trying to set metadata for a file that has been removed: ",e);const i={...r[e].meta,...t};r[e]={...r[e],meta:i},this.setState({files:r})}getFile(e){return this.getState().files[e]}getFiles(){const{files:e}=this.getState();return Object.values(e)}getObjectOfFilesPerState(){const{files:e,totalProgress:t,error:r}=this.getState(),i=Object.values(e),s=i.filter(e=>{let{progress:t}=e;return!t.uploadComplete&&t.uploadStarted}),o=i.filter(e=>!e.progress.uploadStarted),n=i.filter(e=>e.progress.uploadStarted||e.progress.preprocess||e.progress.postprocess),l=i.filter(e=>e.progress.uploadStarted),a=i.filter(e=>e.isPaused),u=i.filter(e=>e.progress.uploadComplete),p=i.filter(e=>e.error),d=s.filter(e=>!e.isPaused),c=i.filter(e=>e.progress.preprocess||e.progress.postprocess);return{newFiles:o,startedFiles:n,uploadStartedFiles:l,pausedFiles:a,completeFiles:u,erroredFiles:p,inProgressFiles:s,inProgressNotPausedFiles:d,processingFiles:c,isUploadStarted:l.length>0,isAllComplete:100===t&&u.length===i.length&&0===c.length,isAllErrored:!!r&&p.length===i.length,isAllPaused:0!==s.length&&a.length===s.length,isUploadInProgress:s.length>0,isSomeGhost:i.some(e=>e.isGhost)}}validateRestrictions(e,t){void 0===t&&(t=this.getFiles());try{return n(this,w)[w].validate(e,t),{result:!0}}catch(e){return{result:!1,reason:e.message}}}checkIfFileAlreadyExists(e){const{files:t}=this.getState();return!(!t[e]||t[e].isGhost)}addFile(e){n(this,k)[k](e);const{files:t}=this.getState();let r=n(this,T)[T](t,e);return t[r.id]&&t[r.id].isGhost&&(r={...t[r.id],data:e.data,isGhost:!1},this.log(`Replaced the blob in the restored ghost file: ${r.name}, ${r.id}`)),this.setState({files:{...t,[r.id]:r}}),this.emit("file-added",r),this.emit("files-added",[r]),this.log(`Added file: ${r.name}, ${r.id}, mime type: ${r.type}`),n(this,$)[$](),r.id}addFiles(e){n(this,k)[k]();const t={...this.getState().files},r=[],i=[];for(let s=0;s<e.length;s++)try{let i=n(this,T)[T](t,e[s]);t[i.id]&&t[i.id].isGhost&&(i={...t[i.id],data:e[s].data,isGhost:!1},this.log(`Replaced blob in a ghost file: ${i.name}, ${i.id}`)),t[i.id]=i,r.push(i)}catch(e){e.isRestriction||i.push(e)}if(this.setState({files:t}),r.forEach(e=>{this.emit("file-added",e)}),this.emit("files-added",r),r.length>5?this.log(`Added batch of ${r.length} files`):Object.keys(r).forEach(e=>{this.log(`Added file: ${r[e].name}\n id: ${r[e].id}\n type: ${r[e].type}`)}),r.length>0&&n(this,$)[$](),i.length>0){let e="Multiple errors occurred while adding files:\n";if(i.forEach(t=>{e+=`\n * ${t.message}`}),this.info({message:this.i18n("addBulkFilesFailed",{smart_count:i.length}),details:e},"error",this.opts.infoTimeout),"function"==typeof AggregateError)throw new AggregateError(i,e);{const t=new Error(e);throw t.errors=i,t}}}removeFiles(e,t){const{files:r,currentUploads:i}=this.getState(),s={...r},o={...i},n=Object.create(null);function l(e){return void 0===n[e]}e.forEach(e=>{r[e]&&(n[e]=r[e],delete s[e])}),Object.keys(o).forEach(e=>{const t=i[e].fileIDs.filter(l);if(0===t.length)return void delete o[e];const{capabilities:r}=this.getState();if(t.length!==i[e].fileIDs.length&&!r.individualCancellation)throw new Error("individualCancellation is disabled");o[e]={...i[e],fileIDs:t}});const a={currentUploads:o,files:s};0===Object.keys(s).length&&(a.allowNewUpload=!0,a.error=null,a.recoveredState=null),this.setState(a),this.calculateTotalProgress();const u=Object.keys(n);u.forEach(e=>{this.emit("file-removed",n[e],t)}),u.length>5?this.log(`Removed ${u.length} files`):this.log(`Removed files: ${u.join(", ")}`)}removeFile(e,t){void 0===t&&(t=null),this.removeFiles([e],t)}pauseResume(e){if(!this.getState().capabilities.resumableUploads||this.getFile(e).uploadComplete)return;const t=!(this.getFile(e).isPaused||!1);return this.setFileState(e,{isPaused:t}),this.emit("upload-pause",e,t),t}pauseAll(){const e={...this.getState().files};Object.keys(e).filter(t=>!e[t].progress.uploadComplete&&e[t].progress.uploadStarted).forEach(t=>{const r={...e[t],isPaused:!0};e[t]=r}),this.setState({files:e}),this.emit("pause-all")}resumeAll(){const e={...this.getState().files};Object.keys(e).filter(t=>!e[t].progress.uploadComplete&&e[t].progress.uploadStarted).forEach(t=>{const r={...e[t],isPaused:!1,error:null};e[t]=r}),this.setState({files:e}),this.emit("resume-all")}retryAll(){const e={...this.getState().files},t=Object.keys(e).filter(t=>e[t].error);if(t.forEach(t=>{const r={...e[t],isPaused:!1,error:null};e[t]=r}),this.setState({files:e,error:null}),this.emit("retry-all",t),0===t.length)return Promise.resolve({successful:[],failed:[]});const r=n(this,G)[G](t,{forceAllowNewUpload:!0});return n(this,ie)[ie](r)}cancelAll(e){let{reason:t="user"}=void 0===e?{}:e;if(this.emit("cancel-all",{reason:t}),"user"===t){const{files:e}=this.getState(),t=Object.keys(e);t.length&&this.removeFiles(t,"cancel-all"),this.setState({totalProgress:0,error:null,recoveredState:null})}}retryUpload(e){this.setFileState(e,{error:null,isPaused:!1}),this.emit("upload-retry",e);const t=n(this,G)[G]([e],{forceAllowNewUpload:!0});return n(this,ie)[ie](t)}reset(){this.cancelAll(...arguments)}logout(){this.iteratePlugins(e=>{e.provider&&e.provider.logout&&e.provider.logout()})}calculateProgress(e,t){if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const r=Number.isFinite(t.bytesTotal)&&t.bytesTotal>0;this.setFileState(e.id,{progress:{...this.getFile(e.id).progress,bytesUploaded:t.bytesUploaded,bytesTotal:t.bytesTotal,percentage:r?Math.round(t.bytesUploaded/t.bytesTotal*100):0}}),this.calculateTotalProgress()}calculateTotalProgress(){const e=this.getFiles().filter(e=>e.progress.uploadStarted||e.progress.preprocess||e.progress.postprocess);if(0===e.length)return this.emit("progress",0),void this.setState({totalProgress:0});const t=e.filter(e=>null!=e.progress.bytesTotal),r=e.filter(e=>null==e.progress.bytesTotal);if(0===t.length){const t=100*e.length,i=r.reduce((e,t)=>e+t.progress.percentage,0),s=Math.round(i/t*100);return void this.setState({totalProgress:s})}let i=t.reduce((e,t)=>e+t.progress.bytesTotal,0);const s=i/t.length;i+=s*r.length;let o=0;t.forEach(e=>{o+=e.progress.bytesUploaded}),r.forEach(e=>{o+=s*(e.progress.percentage||0)/100});let n=0===i?0:Math.round(o/i*100);n>100&&(n=100),this.setState({totalProgress:n}),this.emit("progress",n)}updateOnlineStatus(){void 0===window.navigator.onLine||window.navigator.onLine?(this.emit("is-online"),this.wasOffline&&(this.emit("back-online"),this.info(this.i18n("connectedToInternet"),"success",3e3),this.wasOffline=!1)):(this.emit("is-offline"),this.info(this.i18n("noInternetConnection"),"error",0),this.wasOffline=!0)}getID(){return this.opts.id}use(e,t){if("function"!=typeof e){throw new TypeError(`Expected a plugin class, but got ${null===e?"null":typeof e}. Please verify that the plugin was imported and spelled correctly.`)}const r=new e(this,t),i=r.id;if(!i)throw new Error("Your plugin must have an id");if(!r.type)throw new Error("Your plugin must have a type");const s=this.getPlugin(i);if(s){const e=`Already found a plugin named '${s.id}'. Tried to use: '${i}'.\nUppy plugins must have unique \`id\` options. See https://uppy.io/docs/plugins/#id.`;throw new Error(e)}return e.VERSION&&this.log(`Using ${i} v${e.VERSION}`),r.type in n(this,b)[b]?n(this,b)[b][r.type].push(r):n(this,b)[b][r.type]=[r],r.install(),this}getPlugin(e){for(const t of Object.values(n(this,b)[b])){const r=t.find(t=>t.id===e);if(null!=r)return r}}[s](e){return n(this,b)[b][e]}iteratePlugins(e){Object.values(n(this,b)[b]).flat(1).forEach(e)}removePlugin(e){this.log(`Removing plugin ${e.id}`),this.emit("plugin-remove",e),e.uninstall&&e.uninstall();const t=n(this,b)[b][e.type],r=t.findIndex(t=>t.id===e.id);-1!==r&&t.splice(r,1);const i={plugins:{...this.getState().plugins,[e.id]:void 0}};this.setState(i)}close(e){let{reason:t}=void 0===e?{}:e;this.log(`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`),this.cancelAll({reason:t}),n(this,P)[P](),this.iteratePlugins(e=>{this.removePlugin(e)}),"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener("online",n(this,K)[K]),window.removeEventListener("offline",n(this,K)[K]))}hideInfo(){const{info:e}=this.getState();this.setState({info:e.slice(1)}),this.emit("info-hidden")}info(e,t,r){void 0===t&&(t="info"),void 0===r&&(r=3e3);const i="object"==typeof e;this.setState({info:[...this.getState().info,{type:t,message:i?e.message:e,details:i?e.details:null}]}),setTimeout(()=>this.hideInfo(),r),this.emit("info-visible")}log(e,t){const{logger:r}=this.opts;switch(t){case"error":r.error(e);break;case"warning":r.warn(e);break;default:r.debug(e)}}restore(e){return this.log(`Core: attempting to restore upload "${e}"`),this.getState().currentUploads[e]?n(this,ie)[ie](e):(n(this,re)[re](e),Promise.reject(new Error("Nonexistent upload")))}[o](){return n(this,G)[G](...arguments)}addResultData(e,t){if(!n(this,Y)[Y](e))return void this.log(`Not setting result for an upload that has been removed: ${e}`);const{currentUploads:r}=this.getState(),i={...r[e],result:{...r[e].result,...t}};this.setState({currentUploads:{...r,[e]:i}})}upload(){var e;null!=(e=n(this,b)[b].uploader)&&e.length||this.log("No uploader type plugins are used","warning");let{files:t}=this.getState();const r=this.opts.onBeforeUpload(t);return!1===r?Promise.reject(new Error("Not starting the upload because onBeforeUpload returned false")):(r&&"object"==typeof r&&(t=r,this.setState({files:t})),Promise.resolve().then(()=>n(this,w)[w].validateMinNumberOfFiles(t)).catch(e=>{throw n(this,U)[U](e),e}).then(()=>{if(!n(this,j)[j](t))throw new i.RestrictionError(this.i18n("missingRequiredMetaField"))}).catch(e=>{throw e}).then(()=>{const{currentUploads:e}=this.getState(),r=Object.values(e).flatMap(e=>e.fileIDs),i=[];Object.keys(t).forEach(e=>{const t=this.getFile(e);t.progress.uploadStarted||-1!==r.indexOf(e)||i.push(t.id)});const s=n(this,G)[G](i);return n(this,ie)[ie](s)}).catch(e=>{throw this.emit("error",e),this.log(e,"error"),e}))}}function oe(e,t){const{message:r,details:i=""}=e;e.isRestriction?this.emit("restriction-failed",t,e):this.emit("error",e),this.info({message:r,details:i},"error",this.opts.infoTimeout),this.log(`${r} ${i}`.trim(),"error")}function ne(e){const{missingFields:t,error:r}=n(this,w)[w].getMissingRequiredMetaFields(e);return!(t.length>0)||(this.setFileState(e.id,{missingRequiredMetaFields:t}),this.log(r.message),this.emit("restriction-failed",e,r),!1)}function le(e){let t=!0;for(const r of Object.values(e))n(this,F)[F](r)||(t=!1);return t}function ae(e){const{allowNewUpload:t}=this.getState();if(!1===t){const t=new i.RestrictionError(this.i18n("noMoreFilesAllowed"));throw n(this,U)[U](t,e),t}}function ue(e,t){const r=f(t),s=_(r,t),o=g(s).extension,l=Boolean(t.isRemote),a=m({...t,type:r});if(this.checkIfFileAlreadyExists(a)){const e=new i.RestrictionError(this.i18n("noDuplicates",{fileName:s}));throw n(this,U)[U](e,t),e}const u=t.meta||{};u.name=s,u.type=r;const p=Number.isFinite(t.data.size)?t.data.size:null;let d={source:t.source||"",id:a,name:s,extension:o||"",meta:{...this.getState().meta,...u},type:r,data:t.data,progress:{percentage:0,bytesUploaded:0,bytesTotal:p,uploadComplete:!1,uploadStarted:null},size:p,isRemote:l,remote:t.remote||"",preview:t.preview};const c=this.opts.onBeforeFileAdded(d,e);if(!1===c){const e=new i.RestrictionError("Cannot add the file because onBeforeFileAdded returned false.");throw this.emit("restriction-failed",t,e),e}"object"==typeof c&&null!==c&&(d=c);try{const t=Object.keys(e).map(t=>e[t]);n(this,w)[w].validate(d,t)}catch(e){throw n(this,U)[U](e,d),e}return d}function pe(){this.opts.autoProceed&&!this.scheduledAutoProceed&&(this.scheduledAutoProceed=setTimeout(()=>{this.scheduledAutoProceed=null,this.upload().catch(e=>{e.isRestriction||this.log(e.stack||e.message||e)})},4))}function de(){const e=(e,t,r)=>{let i=e.message||"Unknown error";e.details&&(i+=` ${e.details}`),this.setState({error:i}),null!=t&&t.id in this.getState().files&&this.setFileState(t.id,{error:i,response:r})};this.on("error",e),this.on("upload-error",(t,r,i)=>{if(e(r,t,i),"object"==typeof r&&r.message){const e=new Error(r.message);e.details=r.message,r.details&&(e.details+=` ${r.details}`),e.message=this.i18n("failedToUpload",{file:null==t?void 0:t.name}),n(this,U)[U](e)}else n(this,U)[U](r)}),this.on("upload",()=>{this.setState({error:null})}),this.on("upload-started",e=>{null!=e&&this.getFile(e.id)?this.setFileState(e.id,{progress:{uploadStarted:Date.now(),uploadComplete:!1,percentage:0,bytesUploaded:0,bytesTotal:e.size}}):this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`)}),this.on("upload-progress",this.calculateProgress),this.on("upload-success",(e,t)=>{if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const r=this.getFile(e.id).progress;this.setFileState(e.id,{progress:{...r,postprocess:n(this,x)[x].size>0?{mode:"indeterminate"}:null,uploadComplete:!0,percentage:100,bytesUploaded:r.bytesTotal},response:t,uploadURL:t.uploadURL,isPaused:!1}),null==e.size&&this.setFileState(e.id,{size:t.bytesUploaded||r.bytesTotal}),this.calculateTotalProgress()}),this.on("preprocess-progress",(e,t)=>{null!=e&&this.getFile(e.id)?this.setFileState(e.id,{progress:{...this.getFile(e.id).progress,preprocess:t}}):this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`)}),this.on("preprocess-complete",e=>{if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const t={...this.getState().files};t[e.id]={...t[e.id],progress:{...t[e.id].progress}},delete t[e.id].progress.preprocess,this.setState({files:t})}),this.on("postprocess-progress",(e,t)=>{null!=e&&this.getFile(e.id)?this.setFileState(e.id,{progress:{...this.getState().files[e.id].progress,postprocess:t}}):this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`)}),this.on("postprocess-complete",e=>{if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const t={...this.getState().files};t[e.id]={...t[e.id],progress:{...t[e.id].progress}},delete t[e.id].progress.postprocess,this.setState({files:t})}),this.on("restored",()=>{this.calculateTotalProgress()}),this.on("dashboard:file-edit-complete",e=>{e&&n(this,F)[F](e)}),"undefined"!=typeof window&&window.addEventListener&&(window.addEventListener("online",n(this,K)[K]),window.addEventListener("offline",n(this,K)[K]),setTimeout(n(this,K)[K],3e3))}function ce(t,r){void 0===r&&(r={});const{forceAllowNewUpload:i=!1}=r,{allowNewUpload:s,currentUploads:o}=this.getState();if(!s&&!i)throw new Error("Cannot create a new upload: already uploading.");const n=(0,e.nanoid)();return this.emit("upload",{id:n,fileIDs:t}),this.setState({allowNewUpload:!1!==this.opts.allowMultipleUploadBatches&&!1!==this.opts.allowMultipleUploads,currentUploads:{...o,[n]:{fileIDs:t,step:0,result:{}}}}),n}function he(e){const{currentUploads:t}=this.getState();return t[e]}function fe(e){const t={...this.getState().currentUploads};delete t[e],this.setState({currentUploads:t})}async function ge(e){let{currentUploads:t}=this.getState(),r=t[e];const i=r.step||0,s=[...n(this,O)[O],...n(this,E)[E],...n(this,x)[x]];try{for(let o=i;o<s.length&&r;o++){const i=s[o],n={...r,step:o};this.setState({currentUploads:{...t,[e]:n}}),await i(n.fileIDs,e),t=this.getState().currentUploads,r=t[e]}}catch(t){throw n(this,re)[re](e),t}if(r){r.fileIDs.forEach(e=>{const t=this.getFile(e);t&&t.progress.postprocess&&this.emit("postprocess-complete",t)});const i=r.fileIDs.map(e=>this.getFile(e)),s=i.filter(e=>!e.error),o=i.filter(e=>e.error);await this.addResultData(e,{successful:s,failed:o,uploadID:e}),t=this.getState().currentUploads,r=t[e]}let o;return r&&(o=r.result,this.emit("complete",o),n(this,re)[re](e)),null==o&&this.log(`Not setting result for an upload that has been removed: ${e}`),o}return se.VERSION="2.3.4",H=se}var ie,se,oe,ne,le,ae,ue,pe,de,ce,he,fe,ge,me={},ye=[],_e=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ve=Array.isArray;function be(e,t){for(var r in t)e[r]=t[r];return e}function we(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Pe(e,t,r){var i,s,o,n={};for(o in t)"key"==o?i=t[o]:"ref"==o?s=t[o]:n[o]=t[o];if(arguments.length>2&&(n.children=arguments.length>3?ie.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===n[o]&&(n[o]=e.defaultProps[o]);return Se(e,n,i,s,null)}function Se(e,t,r,i,s){var o={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==s?++oe:s,__i:-1,__u:0};return null==s&&null!=se.vnode&&se.vnode(o),o}function Oe(e){return e.children}function Ee(e,t){this.props=e,this.context=t}function xe(e,t){if(null==t)return e.__?xe(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if(null!=(r=e.__k[t])&&null!=r.__e)return r.__e;return"function"==typeof e.type?xe(e):null}function Ue(e){var t,r;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(r=e.__k[t])&&null!=r.__e){e.__e=e.__c.base=r.__e;break}return Ue(e)}}function Fe(e){(!e.__d&&(e.__d=!0)&&le.push(e)&&!je.__r++||ae!=se.debounceRendering)&&((ae=se.debounceRendering)||ue)(je)}function je(){for(var e,t,r,i,s,o,n,l=1;le.length;)le.length>l&&le.sort(pe),e=le.shift(),l=le.length,e.__d&&(r=void 0,i=void 0,s=(i=(t=e).__v).__e,o=[],n=[],t.__P&&((r=be({},i)).__v=i.__v+1,se.vnode&&se.vnode(r),Ie(t.__P,r,i,t.__n,t.__P.namespaceURI,32&i.__u?[s]:null,o,null==s?xe(i):s,!!(32&i.__u),n),r.__v=i.__v,r.__.__k[r.__i]=r,Le(o,r,n),i.__e=i.__=null,r.__e!=s&&Ue(r)));je.__r=0}function ke(e,t,r,i,s,o,n,l,a,u,p){var d,c,h,f,g,m,y,_=i&&i.__k||ye,v=t.length;for(a=Te(r,t,_,a,v),d=0;d<v;d++)null!=(h=r.__k[d])&&(c=-1==h.__i?me:_[h.__i]||me,h.__i=d,m=Ie(e,h,c,s,o,n,l,a,u,p),f=h.__e,h.ref&&c.ref!=h.ref&&(c.ref&&qe(c.ref,null,h),p.push(h.ref,h.__c||f,h)),null==g&&null!=f&&(g=f),(y=!!(4&h.__u))||c.__k===h.__k?a=$e(h,a,e,y):"function"==typeof h.type&&void 0!==m?a=m:f&&(a=f.nextSibling),h.__u&=-7);return r.__e=g,a}function Te(e,t,r,i,s){var o,n,l,a,u,p=r.length,d=p,c=0;for(e.__k=new Array(s),o=0;o<s;o++)null!=(n=t[o])&&"boolean"!=typeof n&&"function"!=typeof n?(a=o+c,(n=e.__k[o]="string"==typeof n||"number"==typeof n||"bigint"==typeof n||n.constructor==String?Se(null,n,null,null,null):ve(n)?Se(Oe,{children:n},null,null,null):null==n.constructor&&n.__b>0?Se(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n).__=e,n.__b=e.__b+1,l=null,-1!=(u=n.__i=Re(n,r,a,d))&&(d--,(l=r[u])&&(l.__u|=2)),null==l||null==l.__v?(-1==u&&(s>p?c--:s<p&&c++),"function"!=typeof n.type&&(n.__u|=4)):u!=a&&(u==a-1?c--:u==a+1?c++:(u>a?c--:c++,n.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<p;o++)null!=(l=r[o])&&!(2&l.__u)&&(l.__e==i&&(i=xe(l)),He(l,l));return i}function $e(e,t,r,i){var s,o;if("function"==typeof e.type){for(s=e.__k,o=0;s&&o<s.length;o++)s[o]&&(s[o].__=e,t=$e(s[o],t,r,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=xe(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function Re(e,t,r,i){var s,o,n,l=e.key,a=e.type,u=t[r],p=null!=u&&!(2&u.__u);if(null===u&&null==e.key||p&&l==u.key&&a==u.type)return r;if(i>(p?1:0))for(s=r-1,o=r+1;s>=0||o<t.length;)if(null!=(u=t[n=s>=0?s--:o++])&&!(2&u.__u)&&l==u.key&&a==u.type)return n;return-1}function Ae(e,t,r){"-"==t[0]?e.setProperty(t,null==r?"":r):e[t]=null==r?"":"number"!=typeof r||_e.test(t)?r:r+"px"}function Ce(e,t,r,i,s){var o,n;e:if("style"==t)if("string"==typeof r)e.style.cssText=r;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)r&&t in r||Ae(e.style,t,"");if(r)for(t in r)i&&r[t]==i[t]||Ae(e.style,t,r[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(de,"$1")),n=t.toLowerCase(),t=n in e||"onFocusOut"==t||"onFocusIn"==t?n.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=r,r?i?r.u=i.u:(r.u=ce,e.addEventListener(t,o?fe:he,o)):e.removeEventListener(t,o?fe:he,o);else{if("http://www.w3.org/2000/svg"==s)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==r?"":r;break e}catch(e){}"function"==typeof r||(null==r||!1===r&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==r?"":r))}}function Ne(e){return function(t){if(this.l){var r=this.l[t.type+e];if(null==t.t)t.t=ce++;else if(t.t<r.u)return;return r(se.event?se.event(t):t)}}}function Ie(e,t,r,i,s,o,n,l,a,u){var p,d,c,h,f,g,m,y,_,v,b,w,P,S,O,E,x,U=t.type;if(null!=t.constructor)return null;128&r.__u&&(a=!!(32&r.__u),o=[l=t.__e=r.__e]),(p=se.__b)&&p(t);e:if("function"==typeof U)try{if(y=t.props,_="prototype"in U&&U.prototype.render,v=(p=U.contextType)&&i[p.__c],b=p?v?v.props.value:p.__:i,r.__c?m=(d=t.__c=r.__c).__=d.__E:(_?t.__c=d=new U(y,b):(t.__c=d=new Ee(y,b),d.constructor=U,d.render=Be),v&&v.sub(d),d.props=y,d.state||(d.state={}),d.context=b,d.__n=i,c=d.__d=!0,d.__h=[],d._sb=[]),_&&null==d.__s&&(d.__s=d.state),_&&null!=U.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=be({},d.__s)),be(d.__s,U.getDerivedStateFromProps(y,d.__s))),h=d.props,f=d.state,d.__v=t,c)_&&null==U.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),_&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(_&&null==U.getDerivedStateFromProps&&y!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(y,b),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(y,d.__s,b)||t.__v==r.__v){for(t.__v!=r.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),w=0;w<d._sb.length;w++)d.__h.push(d._sb[w]);d._sb=[],d.__h.length&&n.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(y,d.__s,b),_&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,f,g)})}if(d.context=b,d.props=y,d.__P=e,d.__e=!1,P=se.__r,S=0,_){for(d.state=d.__s,d.__d=!1,P&&P(t),p=d.render(d.props,d.state,d.context),O=0;O<d._sb.length;O++)d.__h.push(d._sb[O]);d._sb=[]}else do{d.__d=!1,P&&P(t),p=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(i=be(be({},i),d.getChildContext())),_&&!c&&null!=d.getSnapshotBeforeUpdate&&(g=d.getSnapshotBeforeUpdate(h,f)),E=p,null!=p&&p.type===Oe&&null==p.key&&(E=ze(p.props.children)),l=ke(e,ve(E)?E:[E],t,r,i,s,o,n,l,a,u),d.base=t.__e,t.__u&=-161,d.__h.length&&n.push(d),m&&(d.__E=d.__=null)}catch(e){if(t.__v=null,a||null!=o)if(e.then){for(t.__u|=a?160:128;l&&8==l.nodeType&&l.nextSibling;)l=l.nextSibling;o[o.indexOf(l)]=null,t.__e=l}else{for(x=o.length;x--;)we(o[x]);Me(t)}else t.__e=r.__e,t.__k=r.__k,e.then||Me(t);se.__e(e,t,r)}else null==o&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):l=t.__e=De(r.__e,t,r,i,s,o,n,a,u);return(p=se.diffed)&&p(t),128&t.__u?void 0:l}function Me(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(Me)}function Le(e,t,r){for(var i=0;i<r.length;i++)qe(r[i],r[++i],r[++i]);se.__c&&se.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){se.__e(e,t.__v)}})}function ze(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:ve(e)?e.map(ze):be({},e)}function De(e,t,r,i,s,o,n,l,a){var u,p,d,c,h,f,g,m=r.props,y=t.props,_=t.type;if("svg"==_?s="http://www.w3.org/2000/svg":"math"==_?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),null!=o)for(u=0;u<o.length;u++)if((h=o[u])&&"setAttribute"in h==!!_&&(_?h.localName==_:3==h.nodeType)){e=h,o[u]=null;break}if(null==e){if(null==_)return document.createTextNode(y);e=document.createElementNS(s,_,y.is&&y),l&&(se.__m&&se.__m(t,o),l=!1),o=null}if(null==_)m===y||l&&e.data==y||(e.data=y);else{if(o=o&&ie.call(e.childNodes),m=r.props||me,!l&&null!=o)for(m={},u=0;u<e.attributes.length;u++)m[(h=e.attributes[u]).name]=h.value;for(u in m)if(h=m[u],"children"==u);else if("dangerouslySetInnerHTML"==u)d=h;else if(!(u in y)){if("value"==u&&"defaultValue"in y||"checked"==u&&"defaultChecked"in y)continue;Ce(e,u,null,h,s)}for(u in y)h=y[u],"children"==u?c=h:"dangerouslySetInnerHTML"==u?p=h:"value"==u?f=h:"checked"==u?g=h:l&&"function"!=typeof h||m[u]===h||Ce(e,u,h,m[u],s);if(p)l||d&&(p.__html==d.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(d&&(e.innerHTML=""),ke("template"==t.type?e.content:e,ve(c)?c:[c],t,r,i,"foreignObject"==_?"http://www.w3.org/1999/xhtml":s,o,n,o?o[0]:r.__k&&xe(r,0),l,a),null!=o)for(u=o.length;u--;)we(o[u]);l||(u="value","progress"==_&&null==f?e.removeAttribute("value"):null!=f&&(f!==e[u]||"progress"==_&&!f||"option"==_&&f!=m[u])&&Ce(e,u,f,m[u],s),u="checked",null!=g&&g!=e[u]&&Ce(e,u,g,m[u],s))}return e}function qe(e,t,r){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==t||(e.__u=e(t))}else e.current=t}catch(e){se.__e(e,r)}}function He(e,t,r){var i,s;if(se.unmount&&se.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||qe(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){se.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&He(i[s],t,r||"function"!=typeof e.type);r||we(e.__e),e.__c=e.__=e.__e=void 0}function Be(e,t,r){return this.constructor(e,r)}function We(e,t,r){var i,s,o,n;t==document&&(t=document.documentElement),se.__&&se.__(e,t),s=(i="function"==typeof r)?null:r&&r.__k||t.__k,o=[],n=[],Ie(t,e=(!i&&r||t).__k=Pe(Oe,null,[e]),s||me,me,t.namespaceURI,!i&&r?[r]:s?null:t.firstChild?ie.call(t.childNodes):null,o,!i&&r?r:s?s.__e:t.firstChild,i,n),Le(o,e,n)}ie=ye.slice,se={__e:function(e,t,r,i){for(var s,o,n;t=t.__;)if((s=t.__c)&&!s.__)try{if((o=s.constructor)&&null!=o.getDerivedStateFromError&&(s.setState(o.getDerivedStateFromError(e)),n=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(e,i||{}),n=s.__d),n)return s.__E=s}catch(t){e=t}throw e}},oe=0,ne=function(e){return null!=e&&null==e.constructor},Ee.prototype.setState=function(e,t){var r;r=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=be({},this.state),"function"==typeof e&&(e=e(be({},r),this.props)),e&&be(r,e),null!=e&&this.__v&&(t&&this._sb.push(t),Fe(this))},Ee.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Fe(this))},Ee.prototype.render=Oe,le=[],ue="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,pe=function(e,t){return e.__v.__b-t.__v.__b},je.__r=0,de=/(PointerCapture)$|Capture$/i,ce=0,he=Ne(!1),fe=Ne(!0),ge=0;var Xe,Ke,Ge,Ve,Ye,Qe,Je,Ze,et,tt,rt,it=Object.freeze({__proto__:null,Component:Ee,Fragment:Oe,cloneElement:function(e,t,r){var i,s,o,n,l=be({},e.props);for(o in e.type&&e.type.defaultProps&&(n=e.type.defaultProps),t)"key"==o?i=t[o]:"ref"==o?s=t[o]:l[o]=void 0===t[o]&&null!=n?n[o]:t[o];return arguments.length>2&&(l.children=arguments.length>3?ie.call(arguments,2):r),Se(e.type,l,i||e.key,s||e.ref,null)},createContext:function(e){function t(e){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&r.forEach(function(e){e.__e=!0,Fe(e)})},this.sub=function(e){r.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){r&&r.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+ge++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t},createElement:Pe,createRef:function(){return{current:null}},h:Pe,hydrate:function e(t,r){We(t,r,e)},get isValidElement(){return ne},get options(){return se},render:We,toChildArray:function e(t,r){return r=r||[],null==t||"boolean"==typeof t||(ve(t)?t.some(function(t){e(t,r)}):r.push(t)),r}}),st=l(it);function ot(){if(Ve)return Ge;Ve=1;const e=Ke?Xe:(Ke=1,Xe=function(e){return(null==e?void 0:e.nodeType)===Node.ELEMENT_NODE});return Ge=function(t,r){return void 0===r&&(r=document),"string"==typeof t?r.querySelector(t):e(t)?t:null}}function nt(){if(Ze)return Je;Ze=1;const e=Q();return Je=class{constructor(e,t){void 0===t&&(t={}),this.uppy=e,this.opts=t}getPluginState(){const{plugins:e}=this.uppy.getState();return e[this.id]||{}}setPluginState(e){const{plugins:t}=this.uppy.getState();this.uppy.setState({plugins:{...t,[this.id]:{...t[this.id],...e}}})}setOptions(e){this.opts={...this.opts,...e},this.setPluginState(),this.i18nInit()}i18nInit(){const t=new e([this.defaultLocale,this.uppy.locale,this.opts.locale]);this.i18n=t.translate.bind(t),this.i18nArray=t.translateArray.bind(t),this.setPluginState()}addTarget(){throw new Error("Extend the addTarget method to add your plugin to another plugin's target")}install(){}uninstall(){}render(){throw new Error("Extend the render method to add your plugin to a DOM element")}update(){}afterUpdate(){}}}function lt(){if(tt)return et;tt=1;var e=st;function t(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var r=0;function i(e){return"__private_"+r+++"_"+e}const s=ot(),o=Qe?Ye:(Qe=1,Ye=function(e){for(var t;e&&!e.dir;)e=e.parentNode;return null==(t=e)?void 0:t.dir}),n=nt();var l=i("updateUI");class a extends n{constructor(){super(...arguments),Object.defineProperty(this,l,{writable:!0,value:void 0})}mount(r,i){const n=i.id,u=s(r);if(u){this.isTargetDOMEl=!0;const i=document.createElement("div");return i.classList.add("uppy-Root"),t(this,l)[l]=function(e){let t=null,r=null;return function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];return r=s,t||(t=Promise.resolve().then(()=>(t=null,e(...r)))),t}}(t=>{this.uppy.getPlugin(this.id)&&((0,e.render)(this.render(t),i),this.afterUpdate())}),this.uppy.log(`Installing ${n} to a DOM element '${r}'`),this.opts.replaceTargetContent&&(u.innerHTML=""),(0,e.render)(this.render(this.uppy.getState()),i),this.el=i,u.appendChild(i),i.dir=this.opts.direction||o(i)||"ltr",this.onMount(),this.el}let p;if("object"==typeof r&&r instanceof a)p=r;else if("function"==typeof r){const e=r;this.uppy.iteratePlugins(t=>{t instanceof e&&(p=t)})}if(p)return this.uppy.log(`Installing ${n} to ${p.id}`),this.parent=p,this.el=p.addTarget(i),this.onMount(),this.el;this.uppy.log(`Not installing ${n}`);let d=`Invalid target option given to ${n}.`;throw d+="function"==typeof r?" The given target is not a Plugin class. Please check that you're not specifying a React Component instead of a plugin. If you are using @uppy/* packages directly, make sure you have only 1 version of @uppy/core installed: run `npm ls @uppy/core` on the command line and verify that all the versions match and are deduped correctly.":"If you meant to target an HTML element, please make sure that the element exists. Check that the <script> tag initializing Uppy is right before the closing </body> tag at the end of the page. (see https://github.com/transloadit/uppy/issues/1042)\n\nIf you meant to target a plugin, please confirm that your `import` statements or `require` calls are correct.",new Error(d)}update(e){var r,i;null!=this.el&&(null==(r=(i=t(this,l))[l])||r.call(i,e))}unmount(){var e;this.isTargetDOMEl&&(null==(e=this.el)||e.remove());this.onUnmount()}onMount(){}onUnmount(){}}return et=a}var at,ut,pt,dt,ct,ht,ft,gt,mt,yt,_t=(rt||(rt=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Uppy=t.UIPlugin=t.BasePlugin=void 0,Object.defineProperty(t,"debugLogger",{enumerable:!0,get:function(){return r.debugLogger}});var r=h();e.exports=re();const i=lt();t.UIPlugin=i;const s=nt();t.BasePlugin=s;const o=re();t.Uppy=o;const n=lt(),l=nt();o.Uppy=o,o.UIPlugin=n,o.BasePlugin=l,o.debugLogger=r.debugLogger}(d,d.exports)),d.exports),vt=n(_t),bt={};function wt(){if(ut)return at;ut=1;class e extends Error{constructor(e,t){void 0===t&&(t=null),super("This looks like a network error, the endpoint might be blocked by an internet provider or a firewall."),this.cause=e,this.isNetworkError=!0,this.request=t}}return at=e}function Pt(){if(yt)return mt;let e;function t(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}yt=1;var r=0;function i(e){return"__private_"+r+++"_"+e}const s=function(){if(dt)return pt;dt=1;const e=wt();return pt=function(){return fetch(...arguments).catch(t=>{throw"AbortError"===t.name?t:new e(t)})},pt}(),o=function(){if(ht)return ct;ht=1;const e=Y();class t extends Error{constructor(t,r){void 0===r&&(r={}),super(t),this.cause=r.cause,this.cause&&e(this.cause,"isNetworkError")&&(this.isNetworkError=this.cause.isNetworkError)}}return ct=t}(),n=function(){if(gt)return ft;gt=1;class e extends Error{constructor(){super("Authorization required"),this.name="AuthError",this.isAuthError=!0}}return ft=e}();async function l(e){if(401===e.status)throw new n;const t=e.json();if(e.status<200||e.status>300){let r=`Failed request with status: ${e.status}. ${e.statusText}`;try{const e=await t;r=e.message?`${r} message: ${e.message}`:r,r=e.requestId?`${r} request-Id: ${e.requestId}`:r}finally{throw new Error(r)}}return t}var a=i("companionHeaders"),u=i("getPostResponseFunc"),p=i("getUrl"),d=i("errorHandler");e=Symbol.for("uppy test: getCompanionHeaders");class c{constructor(e,r){Object.defineProperty(this,d,{value:f}),Object.defineProperty(this,p,{value:h}),Object.defineProperty(this,a,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:e=>t=>e?t:this.onReceiveResponse(t)}),this.uppy=e,this.opts=r,this.onReceiveResponse=this.onReceiveResponse.bind(this),this.allowedHeaders=["accept","content-type","uppy-auth-token"],this.preflightDone=!1,t(this,a)[a]=null==r?void 0:r.companionHeaders}setCompanionHeaders(e){t(this,a)[a]=e}[e](){return t(this,a)[a]}get hostname(){const{companion:e}=this.uppy.getState(),t=this.opts.companionUrl;return(e&&e[t]?e[t]:t).replace(/\/$/,"")}headers(){return Promise.resolve({...c.defaultHeaders,...t(this,a)[a]})}onReceiveResponse(e){const t=this.uppy.getState().companion||{},r=this.opts.companionUrl,{headers:i}=e;return i.has("i-am")&&i.get("i-am")!==t[r]&&this.uppy.setState({companion:{...t,[r]:i.get("i-am")}}),e}preflight(e){return this.preflightDone?Promise.resolve(this.allowedHeaders.slice()):fetch(t(this,p)[p](e),{method:"OPTIONS"}).then(e=>(e.headers.has("access-control-allow-headers")&&(this.allowedHeaders=e.headers.get("access-control-allow-headers").split(",").map(e=>e.trim().toLowerCase())),this.preflightDone=!0,this.allowedHeaders.slice())).catch(e=>(this.uppy.log(`[CompanionClient] unable to make preflight request ${e}`,"warning"),this.preflightDone=!0,this.allowedHeaders.slice()))}preflightAndHeaders(e){return Promise.all([this.preflight(e),this.headers()]).then(e=>{let[t,r]=e;return Object.keys(r).forEach(e=>{t.includes(e.toLowerCase())||(this.uppy.log(`[CompanionClient] excluding disallowed header ${e}`),delete r[e])}),r})}get(e,r){return this.preflightAndHeaders(e).then(r=>s(t(this,p)[p](e),{method:"get",headers:r,credentials:this.opts.companionCookiesRule||"same-origin"})).then(t(this,u)[u](r)).then(l).catch(t(this,d)[d]("get",e))}post(e,r,i){const o="post";return this.preflightAndHeaders(e).then(i=>s(t(this,p)[p](e),{method:o,headers:i,credentials:this.opts.companionCookiesRule||"same-origin",body:JSON.stringify(r)})).then(t(this,u)[u](i)).then(l).catch(t(this,d)[d](o,e))}delete(e,r,i){const o="delete";return this.preflightAndHeaders(e).then(t=>s(`${this.hostname}/${e}`,{method:o,headers:t,credentials:this.opts.companionCookiesRule||"same-origin",body:r?JSON.stringify(r):null})).then(t(this,u)[u](i)).then(l).catch(t(this,d)[d](o,e))}}function h(e){return/^(https?:|)\/\//.test(e)?e:`${this.hostname}/${e}`}function f(e,r){return i=>{var s;return null!=(s=i)&&s.isAuthError||(i=new o(`Could not ${e} ${t(this,p)[p](r)}`,{cause:i})),Promise.reject(i)}}return c.VERSION="2.2.2",c.defaultHeaders={Accept:"application/json","Content-Type":"application/json","Uppy-Versions":`@uppy/companion-client=${c.VERSION}`},mt=c}var St,Ot,Et,xt,Ut,Ft,jt,kt,Tt={};function $t(){if(St)return Tt;return St=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.getItem=function(e){return Promise.resolve(localStorage.getItem(e))},Tt.removeItem=function(e){return new Promise(t=>{localStorage.removeItem(e),t()})},Tt.setItem=function(e,t){return new Promise(r=>{localStorage.setItem(e,t),r()})},Tt}function Rt(){if(kt)return bt;kt=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.Socket=bt.SearchProvider=bt.RequestClient=bt.Provider=void 0;const e=Pt();bt.RequestClient=e;const t=function(){if(Et)return Ot;Et=1;var e=$t();const t=Pt();return Ot=class extends t{constructor(e,t){super(e,t),this.provider=t.provider,this.id=this.provider,this.name=this.opts.name||this.id.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),this.pluginId=this.opts.pluginId,this.tokenKey=`companion-${this.pluginId}-auth-token`,this.companionKeysParams=this.opts.companionKeysParams,this.preAuthToken=null}headers(){return Promise.all([super.headers(),this.getAuthToken()]).then(e=>{let[t,r]=e;const i={};return r&&(i["uppy-auth-token"]=r),this.companionKeysParams&&(i["uppy-credentials-params"]=btoa(JSON.stringify({params:this.companionKeysParams}))),{...t,...i}})}onReceiveResponse(e){e=super.onReceiveResponse(e);const t=this.uppy.getPlugin(this.pluginId),r=t.getPluginState().authenticated?401!==e.status:e.status<400;return t.setPluginState({authenticated:r}),e}setAuthToken(e){return this.uppy.getPlugin(this.pluginId).storage.setItem(this.tokenKey,e)}getAuthToken(){return this.uppy.getPlugin(this.pluginId).storage.getItem(this.tokenKey)}async ensurePreAuth(){if(this.companionKeysParams&&!this.preAuthToken&&(await this.fetchPreAuthToken(),!this.preAuthToken))throw new Error("Could not load authentication data required for third-party login. Please try again later.")}authUrl(e){void 0===e&&(e={});const t=new URLSearchParams(e);return this.preAuthToken&&t.set("uppyPreAuthToken",this.preAuthToken),`${this.hostname}/${this.id}/connect?${t}`}fileUrl(e){return`${this.hostname}/${this.id}/get/${e}`}async fetchPreAuthToken(){if(this.companionKeysParams)try{const e=await this.post(`${this.id}/preauth/`,{params:this.companionKeysParams});this.preAuthToken=e.token}catch(e){this.uppy.log(`[CompanionClient] unable to fetch preAuthToken ${e}`,"warning")}}list(e){return this.get(`${this.id}/list/${e||""}`)}logout(){return this.get(`${this.id}/logout`).then(e=>Promise.all([e,this.uppy.getPlugin(this.pluginId).storage.removeItem(this.tokenKey)])).then(e=>{let[t]=e;return t})}static initPlugin(t,r,i){if(t.type="acquirer",t.files=[],i&&(t.opts={...i,...r}),r.serverUrl||r.serverPattern)throw new Error("`serverUrl` and `serverPattern` have been renamed to `companionUrl` and `companionAllowedHosts` respectively in the 0.30.5 release. Please consult the docs (for example, https://uppy.io/docs/instagram/ for the Instagram plugin) and use the updated options.`");if(r.companionAllowedHosts){const e=r.companionAllowedHosts;if(!("string"==typeof e||Array.isArray(e)||e instanceof RegExp))throw new TypeError(`${t.id}: the option "companionAllowedHosts" must be one of string, Array, RegExp`);t.opts.companionAllowedHosts=e}else/^(?!https?:\/\/).*$/i.test(r.companionUrl)?t.opts.companionAllowedHosts=`https://${r.companionUrl.replace(/^\/\//,"")}`:t.opts.companionAllowedHosts=new URL(r.companionUrl).origin;t.storage=t.opts.storage||e}},Ot}();bt.Provider=t;const r=function(){if(Ut)return xt;Ut=1;const e=Pt();return xt=class extends e{constructor(e,t){super(e,t),this.provider=t.provider,this.id=this.provider,this.name=this.opts.name||this.id.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),this.pluginId=this.opts.pluginId}fileUrl(e){return`${this.hostname}/search/${this.id}/get/${e}`}search(e,t){return this.get(`search/${this.id}/list?q=${encodeURIComponent(e)}${t?`&${t}`:""}`)}},xt}();bt.SearchProvider=r;const i=function(){if(jt)return Ft;let e,t;function r(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}jt=1;var i=0;function s(e){return"__private_"+i+++"_"+e}const o=J();var n=s("queued"),l=s("emitter"),a=s("isOpen"),u=s("socket"),p=s("handleMessage");return e=Symbol.for("uppy test: getSocket"),t=Symbol.for("uppy test: getQueued"),Ft=class{constructor(e){Object.defineProperty(this,n,{writable:!0,value:[]}),Object.defineProperty(this,l,{writable:!0,value:o()}),Object.defineProperty(this,a,{writable:!0,value:!1}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:e=>{try{const t=JSON.parse(e.data);this.emit(t.action,t.payload)}catch(e){console.log(e)}}}),this.opts=e,e&&!1===e.autoOpen||this.open()}get isOpen(){return r(this,a)[a]}[e](){return r(this,u)[u]}[t](){return r(this,n)[n]}open(){r(this,u)[u]=new WebSocket(this.opts.target),r(this,u)[u].onopen=()=>{for(r(this,a)[a]=!0;r(this,n)[n].length>0&&r(this,a)[a];){const e=r(this,n)[n].shift();this.send(e.action,e.payload)}},r(this,u)[u].onclose=()=>{r(this,a)[a]=!1},r(this,u)[u].onmessage=r(this,p)[p]}close(){var e;null==(e=r(this,u)[u])||e.close()}send(e,t){r(this,a)[a]?r(this,u)[u].send(JSON.stringify({action:e,payload:t})):r(this,n)[n].push({action:e,payload:t})}on(e,t){r(this,l)[l].on(e,t)}emit(e,t){r(this,l)[l].emit(e,t)}once(e,t){r(this,l)[l].once(e,t)}},Ft}();return bt.Socket=i,bt}var At,Ct,Nt,It,Mt,Lt,zt,Dt,qt,Ht,Bt,Wt,Xt,Kt,Gt,Vt,Yt,Qt={};function Jt(){if(At)return Qt;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}At=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.internalRateLimitedQueue=Qt.RateLimitedQueue=void 0;var t=0;function r(e){return"__private_"+t+++"_"+e}var i=r("activeRequests"),s=r("queuedHandlers"),o=r("paused"),n=r("pauseTimer"),l=r("downLimit"),a=r("upperLimit"),u=r("rateLimitingTimer"),p=r("call"),d=r("queueNext"),c=r("next"),h=r("queue"),f=r("dequeue"),g=r("resume"),m=r("increaseLimit");function y(t){e(this,i)[i]+=1;let r,s=!1;try{r=t()}catch(t){throw e(this,i)[i]-=1,t}return{abort:()=>{s||(s=!0,e(this,i)[i]-=1,r(),e(this,d)[d]())},done:()=>{s||(s=!0,e(this,i)[i]-=1,e(this,d)[d]())}}}function _(){queueMicrotask(()=>e(this,c)[c]())}function v(){if(e(this,o)[o]||e(this,i)[i]>=this.limit)return;if(0===e(this,s)[s].length)return;const t=e(this,s)[s].shift(),r=e(this,p)[p](t.fn);t.abort=r.abort,t.done=r.done}function b(t,r){void 0===r&&(r={});const i={fn:t,priority:r.priority||0,abort:()=>{e(this,f)[f](i)},done:()=>{throw new Error("Cannot mark a queued request as done: this indicates a bug")}},o=e(this,s)[s].findIndex(e=>i.priority>e.priority);return-1===o?e(this,s)[s].push(i):e(this,s)[s].splice(o,0,i),i}function w(t){const r=e(this,s)[s].indexOf(t);-1!==r&&e(this,s)[s].splice(r,1)}Qt.RateLimitedQueue=class{constructor(t){Object.defineProperty(this,f,{value:w}),Object.defineProperty(this,h,{value:b}),Object.defineProperty(this,c,{value:v}),Object.defineProperty(this,d,{value:_}),Object.defineProperty(this,p,{value:y}),Object.defineProperty(this,i,{writable:!0,value:0}),Object.defineProperty(this,s,{writable:!0,value:[]}),Object.defineProperty(this,o,{writable:!0,value:!1}),Object.defineProperty(this,n,{writable:!0,value:void 0}),Object.defineProperty(this,l,{writable:!0,value:1}),Object.defineProperty(this,a,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,g,{writable:!0,value:()=>this.resume()}),Object.defineProperty(this,m,{writable:!0,value:()=>{if(e(this,o)[o])e(this,u)[u]=setTimeout(e(this,m)[m],0);else{e(this,l)[l]=this.limit,this.limit=Math.ceil((e(this,a)[a]+e(this,l)[l])/2);for(let t=e(this,l)[l];t<=this.limit;t++)e(this,d)[d]();e(this,a)[a]-e(this,l)[l]>3?e(this,u)[u]=setTimeout(e(this,m)[m],2e3):e(this,l)[l]=Math.floor(e(this,l)[l]/2)}}}),this.limit="number"!=typeof t||0===t?1/0:t}run(t,r){return!e(this,o)[o]&&e(this,i)[i]<this.limit?e(this,p)[p](t):e(this,h)[h](t,r)}wrapPromiseFunction(e,t){var r=this;return function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];let n;const l=new Promise((i,o)=>{n=r.run(()=>{let t,r;try{r=Promise.resolve(e(...s))}catch(e){r=Promise.reject(e)}return r.then(e=>{t?o(t):(n.done(),i(e))},e=>{t?o(t):(n.done(),o(e))}),()=>{t=new Error("Cancelled")}},t)});return l.abort=()=>{n.abort()},l}}resume(){e(this,o)[o]=!1,clearTimeout(e(this,n)[n]);for(let t=0;t<this.limit;t++)e(this,d)[d]()}pause(t){void 0===t&&(t=null),e(this,o)[o]=!0,clearTimeout(e(this,n)[n]),null!=t&&(e(this,n)[n]=setTimeout(e(this,g)[g],t))}rateLimit(t){clearTimeout(e(this,u)[u]),this.pause(t),this.limit>1&&Number.isFinite(this.limit)&&(e(this,a)[a]=this.limit-1,this.limit=e(this,l)[l],e(this,u)[u]=setTimeout(e(this,m)[m],t))}get isPaused(){return e(this,o)[o]}};const P=Symbol("__queue");return Qt.internalRateLimitedQueue=P,Qt}function Zt(){return Gt?Kt:(Gt=1,Kt={strings:{timedOut:"Upload stalled for %{seconds} seconds, aborting."}})}var er=function(){if(Yt)return Vt;Yt=1;var e=W,t=Rt(),i=Jt();const s=nt(),o=Nt?Ct:(Nt=1,Ct=r(function(e,t,r){const{progress:i,bytesUploaded:s,bytesTotal:o}=t;i&&(e.uppy.log(`Upload progress: ${i}`),e.uppy.emit("upload-progress",r,{uploader:e,bytesUploaded:s,bytesTotal:o}))},300,{leading:!0,trailing:!0})),n=Mt?It:(Mt=1,It=function(e){const t=/^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i.exec(e)[1];return`${/^http:\/\//i.test(e)?"ws":"wss"}://${t}`}),l=zt?Lt:(zt=1,Lt=function(e){const t=[],r=[];function i(e){t.push(e)}function s(e){r.push(e)}return Promise.all(e.map(e=>e.then(i,s))).then(()=>({successful:t,failed:r}))}),a=function(){if(qt)return Dt;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}qt=1;var t=0;function r(e){return"__private_"+t+++"_"+e}var i=r("emitter"),s=r("events");return Dt=class{constructor(t){Object.defineProperty(this,i,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:[]}),e(this,i)[i]=t}on(t,r){return e(this,s)[s].push([t,r]),e(this,i)[i].on(t,r)}remove(){for(const[t,r]of e(this,s)[s].splice(0))e(this,i)[i].off(t,r)}}}(),u=function(){if(Bt)return Ht;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}Bt=1;var t=0;function r(e){return"__private_"+t+++"_"+e}var i=r("aliveTimer"),s=r("isDone"),o=r("onTimedOut"),n=r("timeout");return Ht=class{constructor(t,r){Object.defineProperty(this,i,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:!1}),Object.defineProperty(this,o,{writable:!0,value:void 0}),Object.defineProperty(this,n,{writable:!0,value:void 0}),e(this,n)[n]=t,e(this,o)[o]=r}progress(){e(this,s)[s]||e(this,n)[n]>0&&(clearTimeout(e(this,i)[i]),e(this,i)[i]=setTimeout(e(this,o)[o],e(this,n)[n]))}done(){e(this,s)[s]||(clearTimeout(e(this,i)[i]),e(this,i)[i]=null,e(this,s)[s]=!0)}}}(),p=wt(),d=Xt?Wt:(Xt=1,Wt=function(e){return!!e&&(0!==e.readyState&&4!==e.readyState||0===e.status)}),c=Zt();function h(e,t){let r=t;return r||(r=new Error("Upload error")),"string"==typeof r&&(r=new Error(r)),r instanceof Error||(r=Object.assign(new Error("Upload error"),{data:r})),d(e)?(r=new p(r,e),r):(r.request=e,r)}function f(e){return e.data.slice(0,e.data.size,e.meta.type)}class g extends s{constructor(e,t){super(e,t),this.type="uploader",this.id=this.opts.id||"XHRUpload",this.title="XHRUpload",this.defaultLocale=c;const r={formData:!0,fieldName:t.bundle?"files[]":"file",method:"post",metaFields:null,responseUrlFieldName:"url",bundle:!1,headers:{},timeout:3e4,limit:5,withCredentials:!1,responseType:"",getResponseData(t){let r={};try{r=JSON.parse(t)}catch(t){e.log(t)}return r},getResponseError(e,t){let r=new Error("Upload error");return d(t)&&(r=new p(r,t)),r},validateStatus:e=>e>=200&&e<300};if(this.opts={...r,...t},this.i18nInit(),this.handleUpload=this.handleUpload.bind(this),i.internalRateLimitedQueue in this.opts?this.requests=this.opts[i.internalRateLimitedQueue]:this.requests=new i.RateLimitedQueue(this.opts.limit),this.opts.bundle&&!this.opts.formData)throw new Error("`opts.formData` must be true when `opts.bundle` is enabled.");this.uploaderEvents=Object.create(null)}getOptions(e){const t=this.uppy.getState().xhrUpload,{headers:r}=this.opts,i={...this.opts,...t||{},...e.xhrUpload||{},headers:{}};return"function"==typeof r?i.headers=r(e):Object.assign(i.headers,this.opts.headers),t&&Object.assign(i.headers,t.headers),e.xhrUpload&&Object.assign(i.headers,e.xhrUpload.headers),i}addMetadata(e,t,r){(Array.isArray(r.metaFields)?r.metaFields:Object.keys(t)).forEach(r=>{e.append(r,t[r])})}createFormDataUpload(e,t){const r=new FormData;this.addMetadata(r,e.meta,t);const i=f(e);return e.name?r.append(t.fieldName,i,e.meta.name):r.append(t.fieldName,i),r}createBundledUpload(e,t){const r=new FormData,{meta:i}=this.uppy.getState();return this.addMetadata(r,i,t),e.forEach(e=>{const t=this.getOptions(e),i=f(e);e.name?r.append(t.fieldName,i,e.name):r.append(t.fieldName,i)}),r}upload(t,r,i){const s=this.getOptions(t);return this.uppy.log(`uploading ${r} of ${i}`),new Promise((r,i)=>{this.uppy.emit("upload-started",t);const o=s.formData?this.createFormDataUpload(t,s):t.data,n=new XMLHttpRequest;let l;this.uploaderEvents[t.id]=new a(this.uppy);const p=new u(s.timeout,()=>{n.abort(),l.done();const e=new Error(this.i18n("timedOut",{seconds:Math.ceil(s.timeout/1e3)}));this.uppy.emit("upload-error",t,e),i(e)}),d=(0,e.nanoid)();n.upload.addEventListener("loadstart",()=>{this.uppy.log(`[XHRUpload] ${d} started`)}),n.upload.addEventListener("progress",e=>{this.uppy.log(`[XHRUpload] ${d} progress: ${e.loaded} / ${e.total}`),p.progress(),e.lengthComputable&&this.uppy.emit("upload-progress",t,{uploader:this,bytesUploaded:e.loaded,bytesTotal:e.total})}),n.addEventListener("load",()=>{if(this.uppy.log(`[XHRUpload] ${d} finished`),p.done(),l.done(),this.uploaderEvents[t.id]&&(this.uploaderEvents[t.id].remove(),this.uploaderEvents[t.id]=null),s.validateStatus(n.status,n.responseText,n)){const e=s.getResponseData(n.responseText,n),i=e[s.responseUrlFieldName],o={status:n.status,body:e,uploadURL:i};return this.uppy.emit("upload-success",t,o),i&&this.uppy.log(`Download ${t.name} from ${i}`),r(t)}const e=s.getResponseData(n.responseText,n),o=h(n,s.getResponseError(n.responseText,n)),a={status:n.status,body:e};return this.uppy.emit("upload-error",t,o,a),i(o)}),n.addEventListener("error",()=>{this.uppy.log(`[XHRUpload] ${d} errored`),p.done(),l.done(),this.uploaderEvents[t.id]&&(this.uploaderEvents[t.id].remove(),this.uploaderEvents[t.id]=null);const e=h(n,s.getResponseError(n.responseText,n));return this.uppy.emit("upload-error",t,e),i(e)}),n.open(s.method.toUpperCase(),s.endpoint,!0),n.withCredentials=s.withCredentials,""!==s.responseType&&(n.responseType=s.responseType),l=this.requests.run(()=>{this.uppy.emit("upload-started",t);const e=this.getOptions(t);return Object.keys(e.headers).forEach(t=>{n.setRequestHeader(t,e.headers[t])}),n.send(o),()=>{p.done(),n.abort()}}),this.onFileRemove(t.id,()=>{l.abort(),i(new Error("File removed"))}),this.onCancelAll(t.id,e=>{let{reason:t}=e;"user"===t&&l.abort(),i(new Error("Upload cancelled"))})})}uploadRemote(e){const r=this.getOptions(e);return new Promise((i,s)=>{this.uppy.emit("upload-started",e);const l={};(Array.isArray(r.metaFields)?r.metaFields:Object.keys(e.meta)).forEach(t=>{l[t]=e.meta[t]});new(e.remote.providerOptions.provider?t.Provider:t.RequestClient)(this.uppy,e.remote.providerOptions).post(e.remote.url,{...e.remote.body,endpoint:r.endpoint,size:e.data.size,fieldname:r.fieldName,metadata:l,httpMethod:r.method,useFormData:r.formData,headers:r.headers}).then(l=>{const{token:u}=l,p=n(e.remote.companionUrl),d=new t.Socket({target:`${p}/api/${u}`,autoOpen:!1});let c;this.uploaderEvents[e.id]=new a(this.uppy),this.onFileRemove(e.id,()=>{d.send("cancel",{}),c.abort(),i(`upload ${e.id} was removed`)}),this.onCancelAll(e.id,function(t){let{reason:r}=void 0===t?{}:t;"user"===r&&(d.send("cancel",{}),c.abort()),i(`upload ${e.id} was canceled`)}),this.onRetry(e.id,()=>{d.send("pause",{}),d.send("resume",{})}),this.onRetryAll(e.id,()=>{d.send("pause",{}),d.send("resume",{})}),d.on("progress",t=>o(this,t,e)),d.on("success",t=>{const s=r.getResponseData(t.response.responseText,t.response),o=s[r.responseUrlFieldName],n={status:t.response.status,body:s,uploadURL:o};return this.uppy.emit("upload-success",e,n),c.done(),this.uploaderEvents[e.id]&&(this.uploaderEvents[e.id].remove(),this.uploaderEvents[e.id]=null),i()}),d.on("error",t=>{const i=t.response,o=i?r.getResponseError(i.responseText,i):Object.assign(new Error(t.error.message),{cause:t.error});this.uppy.emit("upload-error",e,o),c.done(),this.uploaderEvents[e.id]&&(this.uploaderEvents[e.id].remove(),this.uploaderEvents[e.id]=null),s(o)}),c=this.requests.run(()=>(d.open(),e.isPaused&&d.send("pause",{}),()=>d.close()))}).catch(t=>{this.uppy.emit("upload-error",e,t),s(t)})})}uploadBundle(e){return new Promise((t,r)=>{const{endpoint:i}=this.opts,{method:s}=this.opts,o=this.uppy.getState().xhrUpload,n=this.createBundledUpload(e,{...this.opts,...o||{}}),l=new XMLHttpRequest,a=t=>{e.forEach(e=>{this.uppy.emit("upload-error",e,t)})},p=new u(this.opts.timeout,()=>{l.abort();const e=new Error(this.i18n("timedOut",{seconds:Math.ceil(this.opts.timeout/1e3)}));a(e),r(e)});l.upload.addEventListener("loadstart",()=>{this.uppy.log("[XHRUpload] started uploading bundle"),p.progress()}),l.upload.addEventListener("progress",t=>{p.progress(),t.lengthComputable&&e.forEach(e=>{this.uppy.emit("upload-progress",e,{uploader:this,bytesUploaded:t.loaded/t.total*e.size,bytesTotal:e.size})})}),l.addEventListener("load",i=>{if(p.done(),this.opts.validateStatus(i.target.status,l.responseText,l)){const r=this.opts.getResponseData(l.responseText,l),s={status:i.target.status,body:r};return e.forEach(e=>{this.uppy.emit("upload-success",e,s)}),t()}const s=this.opts.getResponseError(l.responseText,l)||new Error("Upload error");return s.request=l,a(s),r(s)}),l.addEventListener("error",()=>{p.done();const e=this.opts.getResponseError(l.responseText,l)||new Error("Upload error");return a(e),r(e)}),this.uppy.on("cancel-all",function(e){let{reason:t}=void 0===e?{}:e;"user"===t&&(p.done(),l.abort())}),l.open(s.toUpperCase(),i,!0),l.withCredentials=this.opts.withCredentials,""!==this.opts.responseType&&(l.responseType=this.opts.responseType),Object.keys(this.opts.headers).forEach(e=>{l.setRequestHeader(e,this.opts.headers[e])}),l.send(n),e.forEach(e=>{this.uppy.emit("upload-started",e)})})}uploadFiles(e){const t=e.map((t,r)=>{const i=parseInt(r,10)+1,s=e.length;return t.error?Promise.reject(new Error(t.error)):t.isRemote?this.uploadRemote(t,i,s):this.upload(t,i,s)});return l(t)}onFileRemove(e,t){this.uploaderEvents[e].on("file-removed",r=>{e===r.id&&t(r.id)})}onRetry(e,t){this.uploaderEvents[e].on("upload-retry",r=>{e===r&&t()})}onRetryAll(e,t){this.uploaderEvents[e].on("retry-all",()=>{this.uppy.getFile(e)&&t()})}onCancelAll(e,t){var r=this;this.uploaderEvents[e].on("cancel-all",function(){r.uppy.getFile(e)&&t(...arguments)})}handleUpload(e){if(0===e.length)return this.uppy.log("[XHRUpload] No files to upload!"),Promise.resolve();0!==this.opts.limit||this.opts[i.internalRateLimitedQueue]||this.uppy.log("[XHRUpload] When uploading multiple files at once, consider setting the `limit` option (to `10` for example), to limit the number of concurrent uploads, which helps prevent memory and network issues: https://uppy.io/docs/xhr-upload/#limit-0","warning"),this.uppy.log("[XHRUpload] Uploading...");const t=e.map(e=>this.uppy.getFile(e));if(this.opts.bundle){if(t.some(e=>e.isRemote))throw new Error("Can’t upload remote files when the `bundle: true` option is set");if("function"==typeof this.opts.headers)throw new TypeError("`headers` may not be a function when the `bundle: true` option is set");return this.uploadBundle(t)}return this.uploadFiles(t).then(()=>null)}install(){if(this.opts.bundle){const{capabilities:e}=this.uppy.getState();this.uppy.setState({capabilities:{...e,individualCancellation:!1}})}this.uppy.addUploader(this.handleUpload)}uninstall(){if(this.opts.bundle){const{capabilities:e}=this.uppy.getState();this.uppy.setState({capabilities:{...e,individualCancellation:!0}})}this.uppy.removeUploader(this.handleUpload)}}return g.VERSION="2.1.3",Vt=g}(),tr=n(er);function rr(e,t){var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,o=r.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)n.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(s)throw s.error}}return n}(e.split("#"),2),s=r[0],o=r[1],n=[];i(t,function(e,t){n.push("".concat(t,"=").concat(e))});var l=n.join("&");return s=s.indexOf("?")>0?"".concat(s,"&").concat(l):"".concat(s,"?").concat(l),o?"".concat(s,"#").concat(o):s}function ir(e){return e||{name:""}}function sr(e){var t=e.server,r=void 0===t?"":t,i=e.fieldName,s=void 0===i?"":i,n=e.maxFileSize,l=void 0===n?10485760:n,a=e.maxNumberOfFiles,u=void 0===a?100:a,p=e.meta,d=void 0===p?{}:p,c=e.metaWithUrl,h=void 0!==c&&c,f=e.headers,g=void 0===f?{}:f,m=e.withCredentials,y=void 0!==m&&m,_=e.timeout,v=void 0===_?1e4:_,b=e.onBeforeUpload,w=void 0===b?function(e){return e}:b,P=e.onSuccess,S=void 0===P?function(e,t){}:P,O=e.onError,E=void 0===O?function(e,t,r){console.error("".concat(e.name," upload error"),t,r)}:O,x=e.onProgress,U=void 0===x?function(e){}:x;if(!r)throw new Error("Cannot get upload server address\n没有配置上传地址");if(!s)throw new Error("Cannot get fieldName\n没有配置 fieldName");var F=r;h&&(F=rr(F,d));var j=new vt(o({onBeforeUpload:function(e){return w(e)},restrictions:{maxFileSize:l,maxNumberOfFiles:u},meta:d},e.uppyConfig)).use(tr,o({endpoint:F,headers:g,formData:!0,fieldName:s,bundle:!1,withCredentials:y,timeout:v},e.xhrConfig));return j.on("upload-success",function(e,t){var r=(null!=t?t:{}).body,i=void 0===r?{}:r,s=ir(e);try{S(s,i)}catch(e){console.error("wangEditor upload file - onSuccess error",e)}}),j.on("progress",function(e){e<1||U(e)}),j.on("upload-error",function(e,t,r){var i=ir(e);try{E(i,t,r)}catch(e){console.error("wangEditor upload file - onError error",e)}}),j.on("restriction-failed",function(e,t){var r=ir(e);try{E(r,t,void 0)}catch(e){console.error("wangEditor upload file - onError error",e)}}),j}e.createUploader=function(e,t){return e.uploadAdapter?e.uploadAdapter({config:e,editor:t}):sr(e)},e.createUppyUploader=sr});
|
|
1
|
+
!function(r,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@uppy/core"),require("@uppy/xhr-upload"),require("lodash.foreach"),require("nanoid")):"function"==typeof define&&define.amd?define(["exports","@uppy/core","@uppy/xhr-upload","lodash.foreach","nanoid"],o):o((r="undefined"!=typeof globalThis?globalThis:r||self).WangEditorCoreUpload={},r.Uppy,r.XHRUpload,r.forEach)}(this,function(r,o,e,n){"use strict";var t=function(){return t=Object.assign||function(r){for(var o,e=1,n=arguments.length;e<n;e++)for(var t in o=arguments[e])Object.prototype.hasOwnProperty.call(o,t)&&(r[t]=o[t]);return r},t.apply(this,arguments)};function i(r,o){var e=function(r,o){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,t,i=e.call(r),a=[];try{for(;(void 0===o||o-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(r){t={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return a}(r.split("#"),2),t=e[0],i=e[1],a=[];n(o,function(r,o){a.push("".concat(o,"=").concat(r))});var u=a.join("&");return t=t.indexOf("?")>0?"".concat(t,"&").concat(u):"".concat(t,"?").concat(u),i?"".concat(t,"#").concat(i):t}function a(r){return r||{name:""}}function u(r){return Object.keys(r).reduce(function(o,e){return o[e]=String(r[e]),o},{})}function c(){if("undefined"!=typeof AbortSignal){var r=AbortSignal;"function"!=typeof r.any&&(r.any=function(r){var o,e,n=new AbortController,t=function(o){r.forEach(function(r){return r.removeEventListener("abort",t)});var e=o.target.reason;n.abort(e)};try{for(var i=function(r){var o="function"==typeof Symbol&&Symbol.iterator,e=o&&r[o],n=0;if(e)return e.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}(r),a=i.next();!a.done;a=i.next()){var u=a.value;if(u.aborted){var c=u.reason;return n.abort(c),n.signal}u.addEventListener("abort",t,{once:!0})}}catch(r){o={error:r}}finally{try{a&&!a.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return n.signal})}}function f(r){var n=r.server,f=void 0===n?"":n,l=r.fieldName,d=void 0===l?"":l,p=r.maxFileSize,s=void 0===p?10485760:p,v=r.maxNumberOfFiles,y=void 0===v?100:v,h=r.meta,m=void 0===h?{}:h,b=r.metaWithUrl,g=void 0!==b&&b,w=r.headers,E=void 0===w?{}:w,x=r.withCredentials,S=void 0!==x&&x,U=r.timeout,C=void 0===U?1e4:U,O=r.onBeforeUpload,j=void 0===O?function(r){return r}:O,N=r.onSuccess,A=void 0===N?function(r,o){}:N,q=r.onError,F=void 0===q?function(r,o,e){console.error("".concat(r.name," upload error"),o,e)}:q,T=r.onProgress,z=void 0===T?function(r){}:T;if(!f)throw new Error("Cannot get upload server address\n没有配置上传地址");if(!d)throw new Error("Cannot get fieldName\n没有配置 fieldName");var B=f;g&&(B=i(B,m)),c();var L=function(r){if(r)return"function"==typeof r?function(o){return u(r(o))}:u(r)}(E),P=new o(t({onBeforeUpload:function(r){return j(r)},restrictions:{maxFileSize:s,maxNumberOfFiles:y},meta:m},r.uppyConfig)).use(e,t({endpoint:B,headers:L,formData:!0,fieldName:d,bundle:!1,withCredentials:S,timeout:C},r.xhrConfig));return P.on("upload-success",function(r,o){var e=(null!=o?o:{}).body,n=void 0===e?{}:e,t=a(r);try{A(t,n)}catch(r){console.error("wangEditor upload file - onSuccess error",r)}}),P.on("progress",function(r){r<1||z(r)}),P.on("upload-error",function(r,o,e){var n=a(r);try{F(n,o,e)}catch(r){console.error("wangEditor upload file - onError error",r)}}),P.on("restriction-failed",function(r,o){var e=a(r);try{F(e,o,void 0)}catch(r){console.error("wangEditor upload file - onError error",r)}}),P}"function"==typeof SuppressedError&&SuppressedError,r.createUploader=function(r,o){return r.uploadAdapter?r.uploadAdapter({config:r,editor:o}):f(r)},r.createUppyUploader=f});
|
|
13
2
|
//# sourceMappingURL=upload.js.map
|