import{w as f,f as w,o as a,c as i,b as d,B as p,a as _,z as x,s as F,F as S,A as C,E as b,d as k,r as h}from"./vendor-0kGcmQpG.js";import{_ as B,a as N,s as y}from"./index-Bn9WoKhP.js";const $={class:"statistiques-tiers p-3"},D={class:"flex justify-between items-center mb-3"},V={class:"text-lg font-semibold m-0"},A={key:0,class:"flex justify-center p-4"},E={key:1,class:"statistiques-liste"},I={class:"element"},L={key:0,class:"valeur"},T={key:2,class:"text-center text-gray-500 p-4"},j={__name:"StatistiquesTiers",props:{code:{type:String,required:!0},type:{type:String,default:"C",validator:o=>["C","F"].includes(o)},show:{type:Boolean,default:!0}},emits:["close"],setup(o){const s=o,l=h(!1),r=h([]),u=async()=>{if(s.code){l.value=!0;try{const e=new Date().getFullYear(),t=await N.post(`${y.lienApi}/statistiques_tiers/${y.db}`,{type:s.type,code:s.code,anneeFiscale:e});r.value=t.data||[]}catch{r.value=[]}finally{l.value=!1}}},m=e=>e?.toLowerCase().startsWith("statistiques")||e?.toLowerCase().startsWith("infos"),v=e=>{const t=e.valeur;if(t==null||t==="")return"-";const c=parseFloat(t);return!isNaN(c)&&!e.element.includes("telephone")&&!e.element.includes("mail")?new Intl.NumberFormat("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}).format(c):t};return f(()=>s.code,()=>{s.code&&u()},{immediate:!1}),f(()=>s.show,e=>{e&&s.code&&u()}),w(()=>{s.code&&s.show&&u()}),(e,t)=>{const c=x,g=F;return a(),i("div",$,[d("div",D,[d("h3",V,p(o.type==="C"?"Statistiques Client":"Statistiques Fournisseur"),1),_(c,{icon:"pi pi-times",text:"",rounded:"",onClick:t[0]||(t[0]=n=>e.$emit("close"))})]),l.value?(a(),i("div",A,[_(g,{style:{width:"40px",height:"40px"}})])):r.value.length>0?(a(),i("div",E,[(a(!0),i(S,null,C(r.value,(n,q)=>(a(),i("div",{key:q,class:b(["statistique-ligne",{titre:m(n.element)}])},[d("span",I,p(n.element),1),m(n.element)?k("",!0):(a(),i("span",L,p(v(n)),1))],2))),128))])):(a(),i("div",T," Aucune donnee disponible "))])}}},M=B(j,[["__scopeId","data-v-abea9d6c"]]);export{M as S};
