import{y as F,g as T,I as D,b as I,f as M}from"./primevue-CfIk0_DY.js";import{_ as N,u as A,s as f,b as B,S as U}from"./index-BxIwIJfy.js";import{o as L,b as p,k as O,l as v,d as s,v as r,f as q,c as b,F as R,C as P,t as S,p as W,a as d,E as X}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const G={class:"flex flex-col",style:{gap:"14px"}},H={class:"field"},J={class:"field"},K={class:"field"},Q={class:"field"},Y=["accept"],Z={key:0,class:"liste-fichiers"},ee={class:"nom-fichier"},se={class:"taille-fichier"},oe=["onClick"],te=10*1024*1024,ie={__name:"Suggestions",setup(le){const{showError:y,showSuccess:h,showWarn:V}=A(),x=[".pdf",".doc",".docx",".xls",".xlsx"],_=["Suggestion","Bug","Question","Demande de fonctionnalité","Autre"],l=X({type:"Suggestion",sujet:"",message:""}),a=d([]),k=d(null),c=d(!1),n=d(!1);L(()=>{n.value=!0});const j=()=>{n.value=!1,U("Suggestions")},$=o=>o<1024*1024?`${Math.round(o/1024)} Ko`:`${(o/(1024*1024)).toFixed(1)} Mo`,w=o=>{const e=[];for(const i of Array.from(o.target.files||[])){const m=i.name.slice(i.name.lastIndexOf(".")).toLowerCase();x.includes(m)?i.size>te?e.push(`${i.name} (plus de 10 Mo)`):a.value.some(u=>u.name===i.name&&u.size===i.size)||a.value.push(i):e.push(`${i.name} (format non autorisé)`)}o.target.value="",e.length&&V(`Fichier(s) ignoré(s) : ${e.join(", ")}`)},C=async()=>{if(!l.message.trim()){y("Le message est obligatoire.");return}c.value=!0;try{const o=new FormData;o.append("type",l.type),o.append("sujet",l.sujet),o.append("message",l.message),o.append("nom",f.state.userCloud?.Nom||"");for(const i of a.value)o.append("fichiers",i);const e=await B.post(`${f.lienApi}/suggestions/${f.db}`,o,{headers:{"Content-Type":"multipart/form-data"}});Object.assign(l,{type:"Suggestion",sujet:"",message:""}),a.value=[],h(e.data?.message||"Votre message a été envoyé avec succès."),n.value=!1}catch(o){y(o.response?.data?.message||"Erreur lors de l'envoi.")}finally{c.value=!1}};return(o,e)=>{const i=F,m=T,u=D,g=I,z=M;return p(),O(z,{visible:n.value,"onUpdate:visible":e[5]||(e[5]=t=>n.value=t),modal:"",draggable:!1,style:{width:"600px"},breakpoints:{"640px":"95vw"},onHide:j},{header:v(()=>[...e[6]||(e[6]=[s("div",{class:"flex items-center gap-2"},[s("i",{class:"pi pi-lightbulb suggestion-icone"}),s("span",{class:"font-semibold"},"Suggestions & Support")],-1)])]),footer:v(()=>[r(g,{label:"Fermer",icon:"pi pi-times",text:"",severity:"secondary",onClick:e[4]||(e[4]=t=>n.value=!1)}),r(g,{label:"Envoyer",icon:"pi pi-send",loading:c.value,onClick:C},null,8,["loading"])]),default:v(()=>[e[15]||(e[15]=s("p",{class:"suggestion-intro"}," Une idée d'amélioration, un bug à signaler ou besoin d'aide ? Écrivez-nous directement. ",-1)),s("div",G,[s("div",H,[e[7]||(e[7]=s("label",{class:"block mb-1",for:"sugg-type"},"Type",-1)),r(i,{id:"sugg-type",modelValue:l.type,"onUpdate:modelValue":e[0]||(e[0]=t=>l.type=t),options:_,size:"small",class:"w-full"},null,8,["modelValue"])]),s("div",J,[e[8]||(e[8]=s("label",{class:"block mb-1",for:"sugg-sujet"},"Sujet",-1)),r(m,{id:"sugg-sujet",modelValue:l.sujet,"onUpdate:modelValue":e[1]||(e[1]=t=>l.sujet=t),size:"small",class:"w-full",placeholder:"Résumez en quelques mots"},null,8,["modelValue"])]),s("div",K,[e[9]||(e[9]=s("label",{class:"block mb-1",for:"sugg-message"},[q("Message "),s("span",{class:"obligatoire"},"*")],-1)),r(u,{id:"sugg-message",modelValue:l.message,"onUpdate:modelValue":e[2]||(e[2]=t=>l.message=t),rows:"6",class:"w-full",placeholder:"Décrivez votre suggestion, le bug rencontré ou votre question..."},null,8,["modelValue"])]),s("div",Q,[e[12]||(e[12]=s("label",{class:"block mb-1"},"Pièces jointes",-1)),s("input",{ref_key:"champFichiers",ref:k,type:"file",multiple:"",accept:x.join(","),class:"hidden",onChange:w},null,40,Y),r(g,{label:"Joindre des fichiers",icon:"pi pi-paperclip",outlined:"",size:"small",onClick:e[3]||(e[3]=t=>k.value.click())}),a.value.length?(p(),b("div",Z,[(p(!0),b(R,null,P(a.value,(t,E)=>(p(),b("div",{key:t.name+t.size,class:"ligne-fichier"},[e[11]||(e[11]=s("i",{class:"pi pi-file"},null,-1)),s("span",ee,S(t.name),1),s("span",se,S($(t.size)),1),s("button",{type:"button",class:"retirer-fichier",title:"Retirer ce fichier",onClick:ae=>a.value.splice(E,1)},[...e[10]||(e[10]=[s("i",{class:"pi pi-times"},null,-1)])],8,oe)]))),128))])):W("",!0),e[13]||(e[13]=s("small",{class:"aide-fichiers"},"PDF, Word, Excel — 10 Mo maximum par fichier.",-1))]),e[14]||(e[14]=s("div",{class:"encart-info"},[s("i",{class:"pi pi-info-circle"}),s("span",null," Vos messages sont envoyés directement à l'équipe OMAG. Nous les lisons tous et vous répondrons par e-mail si nécessaire. ")],-1))])]),_:1},8,["visible"])}}},me=N(ie,[["__scopeId","data-v-2ef43b9a"]]);export{me as default};
