import"./index-BxIwIJfy.js";import{a as m}from"./vue-core-Di3IuVqe.js";function A(){const w=["montant","prix","total","tva","ttc","ht","qte","quantite","solde","mt","remise","entree","sortie","debit","credit","salaire","nb"],b=["date","created","updated","date_ech","dateech"],v=(t,a)=>a.some(o=>t.includes(o)),f=t=>v(t.toLowerCase(),w),h=t=>v(t.toLowerCase(),b),y=m({sortable:!0,filter:"agTextColumnFilter",floatingFilter:!1,resizable:!0,suppressHeaderMenuButton:!0,cellClass:t=>{const a=t.colDef?.field||"";return!f(a)&&!h(a)?"stringType":null}}),S=m({mode:"multiRow",checkboxes:!0,headerCheckbox:!0,enableClickSelection:!1}),p=(t,a,o=[],s={})=>{if(!t?.value?.api||!a?.value||a.value.length===0)return[];let d=0;const c={},u=[],g=a.value[0],x=[],i={};Object.keys(g).forEach(e=>{if(o.length>0?o.includes(e):f(e)){u.push(e);const n=s[e]||"sum";n==="sum"||n==="avg"?c[e]={type:n,value:0,count:0}:n==="min"?c[e]={type:n,value:1/0}:n==="max"?c[e]={type:n,value:-1/0}:c[e]={type:n,values:[]},i[e]=0}else i[e]=""}),t.value.api.forEachNodeAfterFilter(e=>{e.data&&(d++,x.push(e.data),u.forEach(l=>{const n=parseFloat(e.data[l])||0,r=c[l];switch(r.type){case"sum":r.value+=n;break;case"avg":r.value+=n,r.count++;break;case"min":r.value=Math.min(r.value,n);break;case"max":r.value=Math.max(r.value,n);break;case"first":case"last":r.values.push(n);break}}))});const C=Object.keys(g)[0];return i[C]=`${d} lignes`,Object.keys(c).forEach(e=>{const l=c[e];switch(l.type){case"sum":i[e]=l.value;break;case"avg":i[e]=l.count>0?l.value/l.count:0;break;case"min":case"max":i[e]=l.value!==1/0&&l.value!==-1/0?l.value:0;break;case"first":i[e]=l.values.length>0?l.values[0]:0;break;case"last":i[e]=l.values.length>0?l.values[l.values.length-1]:0;break}}),[i]};return{isNumericColumn:f,isDateColumn:h,defaultColDef:y,rowSelection:S,excelStyles:[{id:"stringType",dataType:"String"}],excelCellClass:t=>{const a=t.colDef?.field||"";return!f(a)&&!h(a)?"stringType":null},defaultExcelExportParams:{sheetName:"Données",skipPinnedBottom:!0},textValueSetter:t=>{const a=t.colDef.field,o=t.newValue??"";return t.data[a]!==o?(t.data[a]=o,!0):!1},numericValueSetter:t=>{const a=t.colDef.field,o=t.newValue??0,s=typeof o=="number"?o:parseFloat(o)||0;return t.data[a]!==s?(t.data[a]=s,!0):!1},createValueSetter:(t="")=>a=>{const o=a.colDef.field,s=a.newValue??t;return a.data[o]!==s?(a.data[o]=s,!0):!1},calculerTotaux:p,getContextMenuItems:(t,a,o,s,d=[],c={})=>{if(!t||!t.column||!t.column.getColDef)return["copy","copyWithHeaders","separator","export"];const u=t.column.getColDef().field;return u?(d.length>0?d.includes(u):f(u))?["copy","copyWithHeaders","separator",{name:"Afficher les totaux",icon:'<i class="pi pi-calculator"></i>',action:()=>{a.value=p(o,s,d,c)}},{name:"Masquer les totaux",icon:'<i class="pi pi-times"></i>',action:()=>{a.value=[]}},"separator","export"]:["copy","copyWithHeaders","separator","export"]:["copy","copyWithHeaders","separator","export"]},createGridEventHandlers:(t,a,o,s,d=[],c={},u=[])=>({onGridReady:e=>{t.value=e.api},onSelectionChanged:e=>e.api.getSelectedRows(),onFilterChanged:()=>{s?.value?.api&&a?.value&&a.value.length>0&&o?.value?.length>0&&setTimeout(()=>{o.value=p(s,a,d,c)},0)},onRowClick:(e,l)=>{if(e.node?.rowPinned||e.event.target.closest(".ag-selection-checkbox, .ag-checkbox, input"))return;window.getSelection&&window.getSelection().removeAllRanges();let n=null;if(u&&u.length>0){for(const r of u)if(e.data&&r in e.data&&e.data[r]!==null&&e.data[r]!==void 0){n=e.data[r];break}}else e.data&&"ndoc"in e.data&&e.data.ndoc!==null&&e.data.ndoc!==void 0&&(n=e.data.ndoc);n!=null&&l&&l(n)}})}}export{A as u};
