import{_ as v}from"./index-BxIwIJfy.js";import{b as r,c,d as a,F as M,C as V,q as k,t as u,p as b,a as C,y as x}from"./vue-core-Di3IuVqe.js";const F=["accept"],j={class:"flex items-center flex-wrap gap-2"},z=["title"],N={class:"puce-nom"},w={class:"puce-taille"},B=["onClick"],J={key:0,class:"text-red-500",style:{"margin-top":"6px"}},S={__name:"FichiersJoints",props:{modelValue:{type:Array,default:()=>[]},tailleMaxMo:{type:Number,default:10},accept:{type:String,default:".pdf,.doc,.docx,.xls,.xlsx,.csv,.ppt,.pptx,.txt,.jpg,.jpeg,.png,.webp,.gif,.heic"}},emits:["update:modelValue"],setup(n,{emit:g}){const l=n,d=g,m=C(null),h=x(()=>l.tailleMaxMo*1024*1024),p=t=>t.size>h.value,f=x(()=>{const t=l.modelValue.filter(p);return t.length?`${t.length} fichier(s) dépassent ${l.tailleMaxMo} Mo et seront refusés.`:""}),_=t=>{const e=Number(t)||0;return e<1024?`${e} o`:e<1024*1024?`${(e/1024).toFixed(0)} Ko`:`${(e/(1024*1024)).toFixed(1)} Mo`},$=t=>{const e=Array.from(t.target.files||[]),s=new Set(l.modelValue.map(o=>`${o.name}|${o.size}`)),i=e.filter(o=>!s.has(`${o.name}|${o.size}`));d("update:modelValue",[...l.modelValue,...i]),t.target.value=""},y=t=>{const e=[...l.modelValue];e.splice(t,1),d("update:modelValue",e)};return(t,e)=>(r(),c("div",null,[a("input",{ref_key:"champ",ref:m,type:"file",multiple:"",class:"hidden",accept:n.accept,onChange:$},null,40,F),a("div",j,[a("button",{type:"button",class:"lien-joindre",onClick:e[0]||(e[0]=s=>m.value?.click())},[...e[1]||(e[1]=[a("i",{class:"pi pi-paperclip"},null,-1),a("span",null,"Joindre un fichier",-1)])]),(r(!0),c(M,null,V(n.modelValue,(s,i)=>(r(),c("span",{key:`${s.name}-${i}`,class:k(["puce-fichier",{"puce-trop-lourde":p(s)}]),title:p(s)?`Dépasse ${n.tailleMaxMo} Mo`:s.name},[e[2]||(e[2]=a("i",{class:"pi pi-file"},null,-1)),a("span",N,u(s.name),1),a("span",w,u(_(s.size)),1),a("i",{class:"pi pi-times puce-retirer",onClick:o=>y(i)},null,8,B)],10,z))),128))]),f.value?(r(),c("p",J,u(f.value),1)):b("",!0)]))}},E=v(S,[["__scopeId","data-v-f16fb731"]]);export{E as F};
