import{g as a,N as w,_ as F,d as U,k as g,u as k,a7 as L,c as O,w as l,b as u,o as D,i as p,t as f}from"./app-CgV11GBz.js";import{D as S}from"./DeleteOutlined-CzplmvFG.js";import{D as V}from"./DownloadOutlined-CuI9rWeW.js";import{L as q}from"./Link-KYcQwxj2.js";import"./index-B74H0RZb.js";import{B}from"./useFlexGapSupport-CWWB0EO1.js";import{T as C}from"./index-Oi0DGWnW.js";import{_ as P}from"./index-BRlPehkT.js";var R={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"};function h(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?Object(arguments[t]):{},n=Object.keys(o);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(r){return Object.getOwnPropertyDescriptor(o,r).enumerable}))),n.forEach(function(r){j(e,r,o[r])})}return e}function j(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var c=function(t,o){var n=h({},t,o.attrs);return a(w,h({},n,{icon:R}),null)};c.displayName="UploadOutlined";c.inheritAttrs=!1;const N=U({props:{acceptFormat:{default:"image/*,.pdf",type:String},formData:null,folder:String,uploadField:{default:"file",type:String}},emit:["onDelete"],components:{UploadOutlined:c,DownloadOutlined:V,DeleteOutlined:S},setup(e,{emit:t}){const o=g([]),n=g(!1),{t:r}=k();return{fileList:o,loading:n,customRequest:s=>{const i=new FormData;i.append("file",s.file),i.append("folder",e.folder),n.value=!0,axiosAdmin.post("upload-file",i,{headers:{"Content-Type":"multipart/form-data"}}).then(d=>{o.value=[],n.value=!1,t("onFileUploaded",{file:d.data.file,file_url:d.data.file_url})}).catch(()=>{n.value=!1,L.error(r("messages.uploading_failed"))})}}}}),T={key:0},z={key:1};function A(e,t,o,n,r,v){const s=u("UploadOutlined"),i=B,d=P,b=u("DownloadOutlined"),m=C,_=q,y=u("DeleteOutlined");return e.formData[e.uploadField]==null?(D(),O("div",T,[a(d,{accept:e.acceptFormat,"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=$=>e.fileList=$),name:"file",customRequest:e.customRequest},{default:l(()=>[a(i,{loading:e.loading},{icon:l(()=>[a(s)]),default:l(()=>[p(" "+f(e.$t("common.upload")),1)]),_:1},8,["loading"])]),_:1},8,["accept","file-list","customRequest"])])):(D(),O("div",z,[a(_,{href:e.formData[`${e.uploadField}_url`],target:"_blank"},{default:l(()=>[a(m,{color:"success"},{icon:l(()=>[a(b)]),default:l(()=>[p(" "+f(e.$t("common.download")),1)]),_:1})]),_:1},8,["href"]),a(_,{onClick:t[1]||(t[1]=()=>{e.formData[e.uploadField]=void 0,e.formData[`${e.uploadField}_url`]=void 0,e.$emit("onDelete")})},{default:l(()=>[a(m,{color:"error"},{icon:l(()=>[a(y)]),default:l(()=>[p(" "+f(e.$t("common.delete")),1)]),_:1})]),_:1})]))}const X=F(N,[["render",A]]);export{X as U,c as a};
