const s=(e,t)=>{const n=e?.getColDef?.()?.filter;return n==="agNumberColumnFilter"?"number":n==="agDateColumnFilter"?"date":n==="agSetColumnFilter"?"set":t instanceof Date?"date":typeof t=="number"?"number":"text"},c=(e,t,n=!1)=>{switch(e){case"number":return{filterType:"number",type:n?"notEqual":"equals",filter:Number(t)};case"date":{const l=t instanceof Date?t:new Date(t);if(isNaN(l.getTime()))return null;const i=l.getFullYear(),o=String(l.getMonth()+1).padStart(2,"0"),r=String(l.getDate()).padStart(2,"0");return{filterType:"date",type:n?"notEqual":"equals",dateFrom:`${i}-${o}-${r} 00:00:00`}}case"set":return n?{filterType:"set",values:null}:{filterType:"set",values:[String(t)]};default:return{filterType:"text",type:n?"notContains":"contains",filter:String(t)}}},a=(e,t=30)=>{const n=String(e??"");return n.length>t?n.slice(0,t)+"…":n},f=e=>e?.getColDef?.()?.headerName||e?.getColId?.()||"",d=e=>e.value===null||e.value===void 0||e.value===""?null:e.value;function g(e){const t=d(e),n=e.column,l=f(n),i=t!=null?`"${a(t)}"`:"(vide)";return{name:`Filtrer : ${l} = ${i}`,icon:'<i class="pi pi-filter" style="color: var(--omag-500)"></i>',disabled:t==null,action:()=>{if(t==null)return;const o=s(n,t),r=c(o,t,!1);if(!r)return;const u=n.getColId();Promise.resolve(e.api.setColumnFilterModel(u,r)).then(()=>{e.api.onFilterChanged()})}}}function y(e){const t=d(e),n=e.column,l=f(n),i=t!=null?`"${a(t)}"`:"(vide)";return{name:`Exclure : ${l} ≠ ${i}`,icon:'<i class="pi pi-ban" style="color: #dc2626"></i>',disabled:t==null,action:()=>{if(t==null)return;const o=s(n,t),r=c(o,t,!0);if(!r)return;const u=n.getColId();Promise.resolve(e.api.setColumnFilterModel(u,r)).then(()=>{e.api.onFilterChanged()})}}}function p(e){return{name:"Effacer tous les filtres",icon:'<i class="pi pi-times-circle" style="color: #6b7280"></i>',action:()=>{e.api.setFilterModel(null),e.api.onFilterChanged()}}}function m(e){return[g(e),y(e),p(e),"separator"]}function C(e){return[...m(e),"copy","copyWithHeaders","separator","export"]}export{C as d,m as i};
