1import{v as P,ai as R,aj as u,ak as m,al as p,am as S,an as N}from"./9Rf3WUFA.js";import{c as i}from"./nZACWi0e.js";const C=()=>{const l=R(),g=P(),n=$fetch.create({baseURL:l.public.baseURL,headers:{Authorization:`Bearer ${localStorage.getItem("token")}`},async onResponseError({response:t}){}}),I=async(t,e,a)=>{const o=a.categorie+"/"+a.year+"/"+(t==null?void 0:t.name),s=a.categorie+"/"+a.year+"/"+(e==null?void 0:e.name);if(t){const c=await y(t,o);a.imgUrl=c}if(e){const c=await y(e,s);a.fichierImageUrl=c}return await n("/fichier",{method:"PATCH",body:a})},b=async(t,e,a)=>{const o=a.categorie+"/"+a.year+"/"+(t==null?void 0:t.name),s=a.categorie+"/"+a.year+"/"+(e==null?void 0:e.name);try{if(t){const c=await y(t,o);a.imgUrl=c}if(e){const c=await y(e,s);a.fichierImageUrl=c}return await n("/fichier",{method:"post",body:{fichier:a}})}catch{}},U=async t=>new Promise(async(e,a)=>{await n("/fichier/"+t._id,{method:"delete"}).finally(async()=>{const o=u(),s=m(o,t.imgUrl);await p(s).then(async()=>{const r=await h(t.categorie,t.year);e(r)}).catch(async()=>{const r=await h(t.categorie,t.year);e(r)})})}),h=async(t,e)=>new Promise(async(a,o)=>{const s=await n("/fichiers/"+t+"/"+e,{method:"get"});a(s)}),A=async()=>{const t=[i.INFOGRAPHIE,i.NEWSLETTER];return new Promise(async(e,a)=>{const o=await n("/publications",{body:t,method:"post"});e(o)})},y=async(t,e)=>{try{return new Promise((a,o)=>{const s=u(),r=m(s,e),c=S(r,t);c.on("state_changed",d=>{const G=d.bytesTransferred/d.totalBytes*100;switch(d.state){case"paused":break;case"running":break}},d=>{},()=>{N(c.snapshot.ref).then(async d=>{a(d)}).catch(d=>{o(d)})})})}catch{}},k=async(t,e)=>{const a="News/"+t.name;try{await y(t,a).then(async o=>(e.imgUrl=o,await n("/news",{headers:{Authorization:g.getIsConnected?`Bearer ${localStorage.getItem("token")}`:""},method:"post",body:{news:e}})))}catch{}},w=async()=>new Promise(async(t,e)=>{const a=await n("/news",{headers:{Authorization:`Bearer ${localStorage.getItem("token")}`},method:"get"});t(a)});return{postFichier:b,deleteFichier:U,getAll:h,onUpload:y,postNews:k,getAllNews:w,deleteNews:async t=>{try{return new Promise(async(e,a)=>{await n("/news/"+t._id,{method:"delete"}).finally(async()=>{const o=u(),s=m(o,t.imgUrl);await p(s).then(async()=>{const r=await w();e(r)}).catch(async()=>{const r=await w();e(r)})})})}catch{}},getOneNews:async t=>new Promise(async(e,a)=>{const o=await n("/news/"+t,{headers:{Authorization:`Bearer ${localStorage.getItem("token")}`},method:"get"});e(o)}),postMotDG:async(t,e)=>{const a="dg/photo";try{await y(t,a).then(async o=>(e.imgUrl=o,await n("/dg",{headers:{Authorization:g.getIsConnected?`Bearer ${localStorage.getItem("token")}`:""},method:"patch",body:{dg:e}})))}catch{}},getMotDG:async()=>new Promise(async(t,e)=>{const a=await n("/dg",{headers:{Authorization:`Bearer ${localStorage.getItem("token")}`},method:"get"});t(a)}),patchMotDG:async t=>{try{return await n("/dg",{headers:{Authorization:g.getIsConnected?`Bearer ${localStorage.getItem("token")}`:""},method:"patch",body:{dg:t}})}catch{}},getAllPublications:A,updateFichier:I}};export{C as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.