import{a as l,x as w,_ as F,d as $,r as f,c as O,o as v,w as r,B as k,l as c,t as p,bu as j,bi as S,ar as L,az as V,bj as q,p as h,Y as B,b5 as C}from"./app-BOG5ezKh.js";var P={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 b(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(i){return Object.getOwnPropertyDescriptor(o,i).enumerable}))),n.forEach(function(i){R(e,i,o[i])})}return e}function R(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var m=function(t,o){var n=b({},t,o.attrs);return l(w,b({},n,{icon:P}),null)};m.displayName="UploadOutlined";m.inheritAttrs=!1;const z=$({props:{acceptFormat:{default:"image/*,.pdf",type:String},formData:null,folder:String,uploadField:{default:"file",type:String}},components:{UploadOutlined:m,DownloadOutlined:q,DeleteOutlined:V},setup(e,{emit:t}){const o=h([]),n=h(!1),{t:i}=B();return{fileList:o,loading:n,customRequest:u=>{const d=new FormData;d.append("file",u.file),d.append("folder",e.folder),n.value=!0,axiosAdmin.post("upload-file",d,{headers:{"Content-Type":"multipart/form-data"}}).then(a=>{o.value=[],n.value=!1,t("onFileUploaded",{file:a.data.file,file_url:a.data.file_url})}).catch(a=>{n.value=!1;var s=i("messages.uploading_failed");a.status==422&&(a.data&&a.data.error&&a.data.error.details&&a.data.error.details.file[0]||a.data&&a.data.error&&a.data.error.details&&a.data.error.details.image[0])&&(s=a.data.error.details.file[0]),C.error(s)})}}}}),M={key:0},N={key:1};function T(e,t,o,n,i,D){const u=f("UploadOutlined"),d=k,a=j,s=f("DownloadOutlined"),_=S,g=L,y=f("DeleteOutlined");return e.formData[e.uploadField]==null?(v(),O("div",M,[l(a,{accept:e.acceptFormat,"file-list":e.fileList,"onUpdate:fileList":t[0]||(t[0]=U=>e.fileList=U),name:"file",customRequest:e.customRequest},{default:r(()=>[l(d,{loading:e.loading},{icon:r(()=>[l(u)]),default:r(()=>[c(" "+p(e.$t("common.upload")),1)]),_:1},8,["loading"])]),_:1},8,["accept","file-list","customRequest"])])):(v(),O("div",N,[l(g,{href:e.formData[`${e.uploadField}_url`],target:"_blank"},{default:r(()=>[l(_,{color:"success"},{icon:r(()=>[l(s)]),default:r(()=>[c(" "+p(e.$t("common.download")),1)]),_:1})]),_:1},8,["href"]),l(g,{onClick:t[1]||(t[1]=()=>{e.formData[e.uploadField]=void 0,e.formData[`${e.uploadField}_url`]=void 0})},{default:r(()=>[l(_,{color:"error"},{icon:r(()=>[l(y)]),default:r(()=>[c(" "+p(e.$t("common.delete")),1)]),_:1})]),_:1})]))}const E=F(z,[["render",T],["__file","/Users/rajeshkumawat/sites/stockifly/resources/js/common/core/ui/file/UploadFile.vue"]]);export{E as U,m as a};
