importefrom"is-url";importtfrom"nanoid/non-secure";importrfrom"is-plain-object";importifrom"vue";import{Provideass,Modelaso,Propasa,Watchasn,Componentasl,Injectash}from"vue-property-decorator";constu=(e,t)=>({classification:e,component:"FormularioInput"+(t||e[0].toUpperCase()+e.substr(1))});vard=Object.assign(Object.assign({},["text","email","number","color","date","hidden","month","password","search","tel","time","url","week","datetime-local"].reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:u("text")}),{})),{range:u("slider"),textarea:u("textarea","TextArea"),checkbox:u("box"),radio:u("box"),submit:u("button"),button:u("button"),select:u("select"),file:u("file"),image:u("file"),group:u("group")});classp{constructor(e,t={},r={}){this.input=e,this.fileList=e.files,this.files=[],this.options=Object.assign({mimes:{}},r),this.results=!1,this.context=t,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)}rehydrateFileList(e){constt=e.reduce((e,t)=>{constr=t[this.options?this.options.fileUrlKey:"url"],i=!(!r||-1===r.lastIndexOf("."))&&r.substr(r.lastIndexOf(".")+1),s=this.options.mimes[i]||!1;returne.push(Object.assign({},t,r?{name:r.substr(r.lastIndexOf("/")+1||0),type:t.type?t.type:s,previewData:r}:{})),e},[]);this.results=e,this.addFileList(t)}addFileList(e){for(letr=0;r<e.length;r++){consti=e[r],s=t();this.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:i.name||"file-upload",file:i,uuid:s,path:!1,removeFile:()=>this.removeFile(s),previewData:i.previewData||!1})}}hasUploader(){return!!this.context.uploader}uploaderIsAxios(){returnthis.hasUploader&&"function"==typeofthis.context.uploader.request&&"function"==typeofthis.context.uploader.get&&"function"==typeofthis.context.uploader.delete&&"function"==typeofthis.context.uploader.post}getUploader(...e){if(this.uploaderIsAxios()){constt=newFormData;if(t.append(this.context.name||"file",e[0]),!1===this.context.uploadUrl)thrownewError("No uploadURL specified: https://vueformulate.com/guide/inputs/file/#props");returnthis.context.uploader.post(this.context.uploadUrl,t,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:t=>{e[1](Math.round(100*t.loaded/t.total))}}).then(e=>e.data).catch(e[2])}returnthis.context.uploader(...e)}upload(){returnthis.results?Promise.resolve(this.results):newPromise((e,t)=>{if(!this.hasUploader)returnt(newError("No uploader has been defined"));Promise.all(this.files.map(e=>e.path?Promise.resolve(e.path):this.getUploader(e.file,t=>{e.progress=t,t>=100&&(e.complete||(e.justFinished=!0,setTimeout(()=>{e.justFinished=!1},this.options.uploadJustCompleteDuration)),e.complete=!0)},t=>{e.progress=0,e.error=t,e.complete=!0},this.options))).then(t=>{this.results=t,e(t)}).catch(e=>{thrownewError(e)})})}removeFile(e){if(this.files=this.files.filter(t=>t.uuid!==e),this.context.performValidation(),window&&this.fileListinstanceofFileList){conste=newDataTransfer;this.files.map(({file:t})=>e.items.add(t)),this.fileList=e.files,this.input=e}}loadPreviews(){this.files.map(e=>{if(!e.previewData&&window&&window.FileReader&&/^image\//.test(e.file.type)){constt=newFileReader;t.onload=t=>Object.assign(e,{previewData:t.target.result}),t.readAsDataURL(e.file)}})}getFileList(){returnthis.fileList}getFiles(){returnthis.files}toString(){conste=this.files.length?this.files.length+" files":"empty";returnthis.results?JSON.stringify(this.results,null," "):`FileUpload(${e})`}}functionc(e,t){if(e===t)return!0;if(!e||!t)return!1;constr=Object.keys(e);if(Object.keys(t).length!==r.length)return!1;if(einstanceofDate&&tinstanceofDate)returne.getTime()===t.getTime();if(0===r.length)returne===t;for(leti=0;i<r.length;i++){consts=r[i];if(e[s]!==t[s])return!1}return!0}functionf(e){return"string"==typeofe?e.replace(/([_][a-z0-9])/gi,t=>0!==e.indexOf(t)&&"_"!==e[e.indexOf(t)-1]?t.toUpperCase().replace("_",""):t):e}functionm(e){return"string"==typeofe&&/^[\^]/.test(e.charAt(0))?[f(e.substr(1)),e.charAt(0)]:[f(e),null]}functiong(e){returne?"string"==t