chordia-ui 4.0.7 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";const t=require("react/jsx-runtime"),a=require("react"),H=require("./sortable.esm.cjs.js"),$=require("lucide-react"),ft=require("react-dom"),Et=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./AgentLiftAnalysisCard.cjs.js");require("./TourGuideTooltip.cjs.js");function Mt({dateRangePicker:r,onWeekToDate:l,exportConfig:u,filterChipsConfig:p,trailingActions:S}){const[b,c]=a.useState(!1),y=a.useRef(null),M=a.useRef(null);a.useEffect(()=>{const j=v=>{M.current&&!M.current.contains(v.target)&&y.current&&!y.current.contains(v.target)&&c(!1)};if(b)return document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[b]);const F=()=>{c(j=>!j)},k=j=>{c(!1),u!=null&&u.onExport&&u.onExport(j)},T=(()=>{if(!(p!=null&&p.filters))return!1;const j=p.filters,v=p.customFilters||[],z=Object.entries(j).some(([R,E])=>!!(Array.isArray(E)&&E.length||typeof E=="string"&&E.trim()!==""||E&&typeof E=="object"&&(E.min!=null||E.max!=null))),I=v.some(R=>R.active);return z||I})();return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[l&&t.jsxs("button",{onClick:l,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900",style:{fontFamily:"var(--font-sans)"},children:[t.jsx($.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),r&&t.jsx(a.Suspense,{fallback:t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-400",children:[t.jsx($.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:r}),u&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:y,onClick:F,disabled:u.isExporting,className:"inline-flex items-center justify-between gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px]",style:{fontFamily:"var(--font-sans)"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($.Download,{size:16}),t.jsx("span",{children:u.isExporting?"Exporting...":"Export"})]}),t.jsx($.ChevronDown,{size:16})]}),b&&t.jsx("div",{ref:M,className:"absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[120px]",children:(u.types||["csv"]).map(j=>t.jsxs("button",{onClick:()=>k(j),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors",style:{fontFamily:"var(--font-sans)"},children:["Export ",j.toUpperCase()]},j))})]}),(T||S)&&t.jsxs(t.Fragment,{children:[T&&t.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[T&&p&&t.jsx(Et.CustomFilterChips,{filters:p.filters,onChange:p.onChange,onClear:p.onClear,customFilters:p.customFilters||[],fieldOptions:p.fieldOptions||{}}),S&&t.jsx("div",{className:"flex-shrink-0",children:S})]})]})]})}function pt(r){if(r==null)return NaN;const l=String(r).replace(/[,$%]|pp/gi,"").trim(),u=parseFloat(l);return Number.isFinite(u)?u:NaN}function en(r){if(r==null)return NaN;const l=String(r).trim(),u=l.match(/^(\d+):(\d+)(?::(\d+))?$/);if(u){const F=+u[1],k=+u[2],D=u[3]!=null?+u[3]:null;return D!=null?F*3600+k*60+D:F*60+k}let p=0,S=!1;const b=l.match(/(\d+)\s*d\b/i),c=l.match(/(\d+)\s*h\b/i),y=l.match(/(\d+)\s*m(?!s)\b/i),M=l.match(/(\d+)\s*s\b/i);return b&&(p+=+b[1]*86400,S=!0),c&&(p+=+c[1]*3600,S=!0),y&&(p+=+y[1]*60,S=!0),M&&(p+=+M[1],S=!0),S?p:NaN}function tn(r){if(!r)return null;const l=String(r).trim(),u=l.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(u){const S=u[3].length===2?2e3+ +u[3]:+u[3],b=new Date(S,+u[1]-1,+u[2]);return isNaN(b.getTime())?null:b}const p=new Date(l);return isNaN(p.getTime())?null:p}function nn(r){if(!r||r.length===0)return"text";const l=r.slice(0,25),u=p=>l.every(p);return u(p=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(p)||/^\d{4}-\d{2}-\d{2}/.test(p))?"date":u(p=>/^\d+\s*[dhms]\b/i.test(p)||/^\d+:\d+(:\d+)?$/.test(p))?"duration":u(p=>/^-?[\d,.]+(%|pp)?$/i.test(p))?"number":"text"}function Ie(r){return r?Array.isArray(r)?r.length>0:r.type==="range"?r.min!==""&&r.min!==void 0&&r.min!==null||r.max!==""&&r.max!==void 0&&r.max!==null:r.type==="durationRange"?r.minSec!==""&&r.minSec!=null||r.maxSec!==""&&r.maxSec!=null:r.type==="scoreRange"?Array.isArray(r.values)&&r.values.length>0||r.min!==""&&r.min!=null||r.max!==""&&r.max!=null:r.type==="dateRange"?!!(r.from||r.to):!1:!1}function Ct(r){if(r==null||r===""||isNaN(r))return"";const l=Number(r),u=Math.floor(l/3600),p=Math.floor(l%3600/60),S=Math.floor(l%60);return u>0?`${u}h ${p}m`:p>0?`${p}m ${S}s`:`${S}s`}function rn(r){if(!r)return"";if(Array.isArray(r))return r.length===0?"":String(r[0]);if(r.type==="range"){const l=r.min!==""&&r.min!=null?r.min:null,u=r.max!==""&&r.max!=null?r.max:null;return l!=null&&u!=null?`${l} – ${u}`:l!=null?`≥ ${l}`:u!=null?`≤ ${u}`:""}if(r.type==="durationRange"){const l=r.minSec!==""&&r.minSec!=null?Ct(r.minSec):null,u=r.maxSec!==""&&r.maxSec!=null?Ct(r.maxSec):null;return l&&u?`${l} – ${u}`:l?`≥ ${l}`:u?`≤ ${u}`:""}if(r.type==="scoreRange"){if(Array.isArray(r.values)&&r.values.length>0)return r.values.slice().sort((p,S)=>p-S).join(", ");const l=r.min!==""&&r.min!=null?r.min:null,u=r.max!==""&&r.max!=null?r.max:null;return l!=null&&u!=null?`${l} – ${u}`:l!=null?`≥ ${l}`:u!=null?`≤ ${u}`:""}return r.type==="dateRange"?r.from&&r.to?`${r.from} – ${r.to}`:r.from?`from ${r.from}`:r.to?`to ${r.to}`:"":""}function sn(r){return Array.isArray(r)?Math.max(0,r.length-1):0}function on(r){return Array.isArray(r)?r.slice(1).map(String).join(", "):""}function an({count:r,values:l}){const[u,p]=a.useState(!1);return t.jsxs("span",{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:22,minWidth:22,padding:"0 6px",background:"#D8D8D8",color:"#0B0B0B",borderRadius:14,fontSize:12,fontWeight:500,lineHeight:1,cursor:"pointer"},children:["+",r,u&&t.jsx("span",{role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",background:"#1E2125",color:"#FFFFFF",fontFamily:"var(--font-sans)",fontSize:12,fontWeight:400,lineHeight:"20px",padding:"6px 10px",borderRadius:8,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100,boxShadow:"0 6px 16px rgba(11, 11, 11, 0.18)"},children:l})]})}function ln({leftLabel:r,rightLabel:l,leftValue:u,rightValue:p,onLeftChange:S,onRightChange:b,type:c="number",placeholderLeft:y="Min",placeholderRight:M="Max"}){const F={width:"100%",height:32,borderRadius:8,border:"1px solid #D9D9D9",background:"#FFFFFF",padding:"0 10px",fontFamily:"var(--font-sans)",fontSize:14,color:"#0B0B0B",outline:"none",boxSizing:"border-box"},k={fontSize:12,color:"#676767",marginBottom:4,fontFamily:"var(--font-sans)"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:k,children:r}),t.jsx("input",{type:c,value:u,onChange:D=>S(D.target.value),placeholder:y,style:F})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:k,children:l}),t.jsx("input",{type:c,value:p,onChange:D=>b(D.target.value),placeholder:M,style:F})]})]})}const Dt=[{id:"0-60",label:"0 to 60 Sec",minSec:0,maxSec:60},{id:"60-120",label:"1m to 2 m",minSec:60,maxSec:120},{id:"120-180",label:"2m to 3 m",minSec:120,maxSec:180},{id:"180-240",label:"3m to 4m",minSec:180,maxSec:240},{id:"240-300",label:"4m to 5m",minSec:240,maxSec:300},{id:"300+",label:"5 mins and above",minSec:300,maxSec:null}];function Rt(r){if(r==null||r==="")return null;const l=String(r).trim().match(/^(\d{1,3}):(\d{2})$/);if(l)return Number(l[1])*60+Number(l[2]);const u=Number(r);return Number.isFinite(u)?u:null}function dt({children:r}){return t.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0 2px",fontFamily:"var(--font-sans)"},children:r})}function ut({minValue:r,maxValue:l,onMinChange:u,onMaxChange:p,inputType:S="number",inputMode:b="decimal",step:c,placeholder:y="0.0",unit:M}){const F={width:"100%",height:30,border:"1px solid #ACADAD",borderRadius:4,padding:"6px 10px",fontSize:13,color:"#0B0B0B",fontFamily:"var(--font-sans)",outline:"none",boxSizing:"border-box"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Min From"}),t.jsx("input",{type:S,inputMode:b,step:c,placeholder:y,value:r,onChange:k=>u(k.target.value),style:F})]}),t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#323232",paddingBottom:8,fontFamily:"var(--font-sans)"},children:"to"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Max"}),t.jsx("input",{type:S,inputMode:b,step:c,placeholder:y,value:l,onChange:k=>p(k.target.value),style:F})]})]}),M&&t.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Enter durations in ",M==="sec"?"seconds":M]})]})}function cn({column:r,columnId:l,filterType:u="text",position:p,popoverRef:S,distinctValues:b,initialValue:c,onApply:y,onCancel:M,onSearch:F=null,searchMinChars:k=3}){const D=u==="text",T=u==="number",j=u==="date",v=u==="duration",z=u==="score",I=/duration/i.test(String((r==null?void 0:r.label)||l||"")),R=a.useMemo(()=>{if(!z||!Array.isArray(b)||b.length===0)return!1;let m=1/0,h=-1/0;for(const x of b){const w=pt(x);Number.isFinite(w)&&(w<m&&(m=w),w>h&&(h=w))}return Number.isFinite(m)&&Number.isFinite(h)&&m>=0&&h<=5},[z,b]),[E,ie]=a.useState(()=>D?new Set(Array.isArray(c)?c:[]):new Set),[me,U]=a.useState(""),[W,ne]=a.useState(()=>T&&(c==null?void 0:c.type)==="range"&&c.min!=null?c.min:""),[Y,_]=a.useState(()=>T&&(c==null?void 0:c.type)==="range"&&c.max!=null?c.max:""),[q,he]=a.useState(new Set),[Q,V]=a.useState(()=>v&&(c==null?void 0:c.type)==="durationRange"&&c.minSec!=null&&c.minSec!==""?String(c.minSec):""),[xe,ee]=a.useState(()=>v&&(c==null?void 0:c.type)==="durationRange"&&c.maxSec!=null&&c.maxSec!==""?String(c.maxSec):""),[ae,Se]=a.useState(()=>z&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[Ee,X]=a.useState(()=>z&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[B,re]=a.useState(()=>z&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[te,le]=a.useState(()=>j&&(c==null?void 0:c.type)==="dateRange"&&c.from||""),[K,ve]=a.useState(()=>j&&(c==null?void 0:c.type)==="dateRange"&&c.to||"");a.useEffect(()=>{D&&ie(new Set(Array.isArray(c)?c:[]))},[l,D]);const[we,Me]=a.useState(null),[N,ce]=a.useState(!1),ye=a.useRef(0),Z=me.trim(),be=D&&typeof F=="function"&&Z.length>=k;a.useEffect(()=>{if(!D||typeof F!="function")return;if(Z.length<k){Me(null),ce(!1);return}const m=++ye.current;ce(!0);const h=setTimeout(async()=>{try{const x=await F(Z);if(m!==ye.current)return;const w=Array.isArray(x)?x.map(A=>A&&typeof A=="object"?A.label??A.value:A).filter(A=>A!=null&&A!=="").map(String):[];Me(w)}catch{m===ye.current&&Me([])}finally{m===ye.current&&ce(!1)}},300);return()=>clearTimeout(h)},[D,F,Z,k]);const ge=a.useMemo(()=>{const m=Z.toLowerCase(),h=be?we||[]:m?b.filter(w=>String(w).toLowerCase().includes(m)):b,x=new Map;for(const w of h)x.set(String(w),w);for(const w of E)x.set(String(w),w);return Array.from(x.values()).sort((w,A)=>{const de=E.has(w),Ae=E.has(A);return de!==Ae?de?-1:1:String(w).localeCompare(String(A))})},[b,Z,E,be,we]),ze=m=>{ie(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},tt=()=>{D&&ie(new Set),T&&(ne(""),_("")),v&&(he(new Set),V(""),ee("")),z&&(Se(new Set),X(""),re("")),j&&(le(""),ve("")),U("")},Be=m=>{he(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},Ne=m=>{Se(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},We=()=>{if(D)return y(Array.from(E));if(T)return y({type:"range",min:W===""?"":Number(W),max:Y===""?"":Number(Y)});if(v){const m=Rt(Q),h=Rt(xe),x=m!=null||h!=null;let w="",A="";if(x)w=m??"",A=h??"";else if(q.size>0){const de=Dt.filter(J=>q.has(J.id));w=Math.min(...de.map(J=>J.minSec)),A=de.some(J=>J.maxSec==null)?"":Math.max(...de.map(J=>J.maxSec))}return y({type:"durationRange",minSec:w,maxSec:A})}if(z){const m=Ee===""?null:Number(Ee),h=B===""?null:Number(B);return m!=null||h!=null?y({type:"scoreRange",values:[],min:m!=null&&Number.isFinite(m)?m:"",max:h!=null&&Number.isFinite(h)?h:""}):y({type:"scoreRange",values:Array.from(ae).sort((w,A)=>w-A),min:"",max:""})}if(j)return y({type:"dateRange",from:te,to:K})};return t.jsxs("div",{ref:S,role:"dialog","aria-label":`Filter ${r.label||l}`,style:{position:"fixed",top:p.top,left:p.left,zIndex:50,width:D?240:220,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,padding:12,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 8px 24px rgba(11, 11, 11, 0.10)",fontFamily:"var(--font-sans)"},children:[D&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{background:"#D8D8D8",height:32,borderRadius:10,padding:1,display:"flex",alignItems:"center"},children:t.jsxs("div",{style:{background:"#FFFFFF",flex:1,height:30,borderRadius:10,display:"flex",alignItems:"center",gap:8,padding:"0 8px"},children:[t.jsx($.Search,{size:16,color:"#989898",strokeWidth:2}),t.jsx("input",{autoFocus:!0,type:"text",value:me,onChange:m=>U(m.target.value),placeholder:"Search",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:14,color:"#0B0B0B",minWidth:0,fontFamily:"var(--font-sans)"}})]})}),t.jsx("div",{style:{maxHeight:220,overflowY:"auto",display:"flex",flexDirection:"column",gap:4},children:typeof F=="function"&&Z.length>0&&Z.length<k?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:`Type at least ${k} characters to search`}):N?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"Searching…"}):ge.length===0?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):ge.map(m=>{const h=E.has(m);return t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"6px 4px",cursor:"pointer",borderRadius:6},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx($.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("input",{type:"checkbox",checked:h,onChange:()=>ze(m),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),t.jsx("span",{onClick:x=>{x.preventDefault(),ze(m)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]},m)})})]}),T&&t.jsxs(t.Fragment,{children:[t.jsx(dt,{children:r.label||"Filter"}),t.jsx(ut,{minValue:W,maxValue:Y,onMinChange:ne,onMaxChange:_,placeholder:I?"00":"0.0",unit:I?"sec":void 0})]}),v&&t.jsxs(t.Fragment,{children:[t.jsx(dt,{children:r.label||"Duration"}),r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:Dt.map(m=>{const h=q.has(m.id);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>Be(m.id),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),Be(m.id))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx($.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:m.label})]},m.id)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"})]}),t.jsx(ut,{minValue:Q,maxValue:xe,onMinChange:V,onMaxChange:ee,inputType:"number",inputMode:"numeric",placeholder:"00",unit:"sec"})]}),z&&t.jsxs(t.Fragment,{children:[t.jsx(dt,{children:r.label||"Score"}),R&&r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[1,2,3,4,5].map(m=>{const h=ae.has(m);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>Ne(m),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),Ne(m))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:h?"#0B0B0B":"#FFFFFF",border:`1px solid ${h?"#0B0B0B":"#676767"}`,flexShrink:0},children:h&&t.jsx($.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:m})]},m)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}})]}),R&&r.filterShowPresets===!0&&t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"}),t.jsx(ut,{minValue:Ee,maxValue:B,onMinChange:X,onMaxChange:re,step:"0.1"})]}),j&&t.jsx(ln,{leftLabel:"From",rightLabel:"To",leftValue:te,rightValue:K,onLeftChange:le,onRightChange:ve,type:"date",placeholderLeft:"",placeholderRight:""}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("button",{type:"button",onClick:tt,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:v&&r.filterShowPresets===!0||z&&R&&r.filterShowPresets===!0?"View All":"Reset"}),t.jsx("button",{type:"button",onClick:We,style:{background:"#0B0B0B",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Apply"})]})]})}const dn=()=>({userData:{email:"anonymous"}}),un=r=>t.jsx("img",{...r});function fn({children:r,content:l,direction:u="top",align:p="center",styling:S,indicatorColor:b}){const c=typeof l=="string"?l:l!=null?String(l):"",y=typeof b=="string"&&(b.startsWith("#")||b.startsWith("rgb")||b.startsWith("hsl")||b.startsWith("var("))?b:"var(--Grey-Strong, #2E3236)",[M,F]=a.useState(!1),[k,D]=a.useState(!1),[T,j]=a.useState({top:0,left:0,arrowLeft:0,placement:"top"}),v=a.useRef(null),z=a.useRef(null);if(!c)return r;a.useEffect(()=>{D(!0)},[]);const I=a.useCallback(()=>{if(!v.current||!z.current||typeof window>"u")return;const R=v.current.getBoundingClientRect(),E=z.current.getBoundingClientRect(),ie=window.innerWidth,me=window.innerHeight,U=8,W=10,ne=E.width,Y=E.height,_=R.top,q=me-R.bottom,he=u==="bottom"?"bottom":"top";let Q=he;he==="top"&&_<Y+W+U&&q>_?Q="bottom":he==="bottom"&&q<Y+W+U&&_>q&&(Q="top");let V=R.left+R.width/2;p==="start"&&(V=R.left),p==="end"&&(V=R.right);let xe=Q==="top"?R.top-Y-W:R.bottom+W,ee=p==="start"?V:p==="end"?V-ne:V-ne/2;xe=Math.max(U,Math.min(xe,me-Y-U)),ee=Math.max(U,Math.min(ee,ie-ne-U));const ae=Math.max(10,Math.min(V-ee,ne-10));j({top:xe,left:ee,arrowLeft:ae,placement:Q})},[p,u]);return a.useEffect(()=>{if(!M||!k)return;I();const R=()=>I();return window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[M,k,I]),t.jsxs("span",{ref:v,style:{display:"block",width:"100%"},onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),children:[r,M&&k&&ft.createPortal(t.jsxs("span",{ref:z,style:{position:"fixed",top:`${T.top}px`,left:`${T.left}px`,background:"var(--Grey-Strong, #2E3236)",color:"var(--Grey-White, #FFF)",fontSize:"12px",lineHeight:1.3,fontWeight:500,padding:"8px 10px",borderRadius:"6px",whiteSpace:"normal",maxWidth:"320px",width:"max-content",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.2)",zIndex:99999,pointerEvents:"none",...typeof S=="object"?S:{}},children:[c,t.jsx("span",{style:{position:"absolute",left:`${T.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...T.placement==="top"?{top:"100%",borderTop:`7px solid ${y}`}:{bottom:"100%",borderBottom:`7px solid ${y}`}}})]}),document.body)]})}function pn({data:r=[],columns:l=[],initialPageSize:u=10,onRowClick:p,totalCount:S=null,page:b=null,pageSize:c=null,onPageChange:y=null,onPageSizeChange:M=null,onFilterChange:F=null,columnFilters:k=null,onMaxColumnsError:D=null,onSort:T=null,sortFields:j=[],tableId:v=null,isLoading:z=!1,filtersConfig:I=null,columnResizeMinWidth:R=120,columnResizeMaxWidth:E=280,onVisibleColumnsChange:ie=null,hideColumnPicker:me=!1}){var kt;const{userData:U}=dn(),W=(U==null?void 0:U.email)||"anonymous",ne=a.memo(({children:e,content:n,className:s=""})=>{const i=a.useRef(null),[o,f]=a.useState(!1);a.useEffect(()=>{const g=()=>{if(i.current){const P=i.current.scrollWidth>i.current.clientWidth;f(P)}};g();const L=setTimeout(g,0);return window.addEventListener("resize",g),()=>{clearTimeout(L),window.removeEventListener("resize",g)}},[e,n]);const d=t.jsx("span",{className:`truncate block ${s}`,ref:i,children:e});return o&&n?t.jsx(fn,{content:n,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:d}):d});ne.displayName="TruncatedCell";const Y=S!==null&&y!==null,_=F!==null,q=T!==null,[he,Q]=a.useState(1),[V,xe]=a.useState(u),ee=b!==null?b:he,ae=c!==null?c:V,Se=e=>{y?y(e):Q(e)},Ee=e=>{M?M(e):xe(e)},X=50,B="action",re=a.useRef(!1),te=a.useMemo(()=>v?`dataTable_columns_${v}:${W}`:`dataTable_columns_${l.map(n=>n.id||n.key).sort().join("_")}:${W}`,[v,l,W]),le=a.useMemo(()=>v?`dataTable_manual_change_${v}:${W}`:null,[v,W]);a.useCallback((e,n)=>{if(typeof window>"u"||!e||!n||n.length===0)return null;try{const s=localStorage.getItem(e);if(s){const o=JSON.parse(s).filter(f=>n.some(d=>(d.id||d.key)===f));if(o.length>0)return o}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}return null},[]);const[K,ve]=a.useState({}),[we,Me]=a.useState(""),[N,ce]=a.useState(null),[ye,Z]=a.useState({top:0,left:0}),be=a.useRef(null),ge=a.useRef({}),[ze,tt]=a.useState(null),[Be,Ne]=a.useState("asc"),We=a.useCallback((e,n)=>{const s=Ie(n);ve(i=>{const o={...i};return s?o[e]=n:delete o[e],o}),y?y(1):Q(1),_&&F&&F(s?{...K,[e]:n}:Object.fromEntries(Object.entries(K).filter(([i])=>i!==e)))},[K,F,_,y]),m=a.useCallback(()=>{ve({}),Me(""),y?y(1):Q(1),_&&F&&F({})},[F,_,y]),h=a.useCallback(e=>{const n=l.find(o=>(o.id||o.key)===e);if(n&&Array.isArray(n.filterOptions)){const o=new Set,f=[];for(const d of n.filterOptions){if(d==null||d==="")continue;const g=typeof d=="object"?JSON.stringify(d):String(d);o.has(g)||(o.add(g),f.push(g))}return f.sort((d,g)=>d.localeCompare(g))}if(!r||r.length===0)return[];const s=new Set,i=[];for(const o of r){const f=o[e];if(f==null)continue;const d=typeof f=="object"?JSON.stringify(f):String(f);s.has(d)||(s.add(d),i.push(d))}return i.sort((o,f)=>o.localeCompare(f))},[r,l]),x=a.useCallback(e=>{const n=l.find(s=>G(s)===e);return n&&n.filterType?n.filterType:nn(h(e))},[l,h]),w=a.useCallback(e=>{const i=typeof window<"u"?window.innerWidth:1/0;let o=e.left;return o+280>i-8&&(o=Math.max(8,e.right-280)),{top:e.bottom+6,left:o}},[]),A=a.useCallback((e,n)=>{if(!n){ce(e);return}const s=n.getBoundingClientRect();Z(w(s)),ce(i=>i===e?null:e)},[w]);a.useEffect(()=>{if(!N)return;const e=n=>{if(be.current&&be.current.contains(n.target))return;const s=ge.current[N];s&&s.contains(n.target)||Object.values(ge.current).some(o=>o&&o.contains(n.target))||ce(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]),a.useEffect(()=>{if(!N)return;const e=()=>{const n=ge.current[N];if(!n)return;const s=n.getBoundingClientRect();Z(w(s))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[N,w]),a.useLayoutEffect(()=>{if(!N)return;const e=be.current,n=ge.current[N];if(!e||!n)return;const s=e.offsetWidth,i=n.getBoundingClientRect(),o=8,f=typeof window<"u"?window.innerWidth:1/0;if(!(i.left+s>f-o))return;const g=Math.max(o,i.right-s);Z(L=>L.left===g?L:{...L,left:g})},[N,ye.top]);const de=a.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim()!=="":!0)),[]),Ae=a.useCallback((e,n)=>{const s=Object.keys(e||{}),i=Object.keys(n||{});return s.length!==i.length?!1:s.every(o=>e[o]===n[o])},[]);a.useEffect(()=>{if(!_||k===null)return;const e=de(k);ve(n=>Ae(n,e)?n:e)},[_,k,de,Ae]),a.useCallback((e,n)=>e==="csat_score"&&n==="evaluation.csat_score"?n:e,[]);const J=q&&j.length>0?j[0][0]:ze,_e=q&&j.length>0?j[0][1]:Be,[mn,mt]=a.useState(()=>l.map(e=>e.id||e.key)),se=a.useCallback(e=>{if(!e||e.length===0)return e;let n=Array.from(new Set(e));n.length>X&&(n=n.slice(0,X));const i=l.map(d=>d.id||d.key).includes(B);return!n.includes(B)&&i&&(n.length>=X?n=[...n.slice(0,X-1),B]:n=[...n,B]),[...n.filter(d=>d!==B),B]},[l]),[O,Oe]=a.useState(()=>{if(typeof window<"u"&&v)try{if(localStorage.getItem(`dataTable_manual_change_${v}:${W}`)==="true"){const i=localStorage.getItem(`dataTable_columns_${v}:${W}`);if(i){const o=JSON.parse(i);if(Array.isArray(o)&&o.length>0){re.current=!0;const f=o.filter(d=>l.some(g=>(g.id||g.key)===d));if(f.length>0)return f.slice(0,X)}}}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}const n=l.map(s=>s.id||s.key).slice(0,X);return se(n)}),[oe,nt]=a.useState(!1),[ue,Fe]=a.useState([]),[ht,zt]=a.useState({top:0,left:0,width:0}),[He,je]=a.useState(new Set),[qe,ke]=a.useState(new Set),fe=a.useRef({}),Ke=a.useRef(null);Ke.current===null&&(Ke.current=[...O]);const[pe,rt]=a.useState(null),[Bt,Ge]=a.useState(null),Ce=a.useRef(null),st=a.useRef(null),ot=a.useRef(null),[xt,it]=a.useState(null),[at,Nt]=a.useState({}),Wt=a.useRef(null),Ue=a.useRef(null),G=e=>e.id||e.key,Xe=a.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=e.trim();if(n.endsWith("px")){const i=parseFloat(n);return Number.isFinite(i)?i:null}const s=parseFloat(n);return Number.isFinite(s)&&`${s}`===n?s:null}return null},[]),gt=a.useCallback((e,n)=>at[e]!=null?`${at[e]}px`:typeof n=="number"?`${n}px`:n||"auto",[at]),Je=a.useCallback(e=>{if(!Ue.current)return;const{columnId:n,startX:s,startWidth:i,minWidth:o,maxWidth:f}=Ue.current,d=e.clientX-s,g=Math.round(i+d),L=Math.min(f,Math.max(o,g));Nt(P=>({...P,[n]:L}))},[]),Te=a.useCallback(()=>{Ue.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",Je),document.removeEventListener("mouseup",Te)},[Je]),At=a.useCallback((e,n,s)=>{var Ve;e.preventDefault(),e.stopPropagation();const i=n.id||n.key,o=Xe(n.minWidth)??R,f=Xe(n.maxWidth)??E,d=Math.min(o,f),g=Math.max(o,f),L=((Ve=e.currentTarget.closest("th"))==null?void 0:Ve.getBoundingClientRect().width)||0,P=Xe(s),Pe=P??Math.max(d,Math.round(L)||d),lt=Math.min(g,Math.max(d,Pe));Ue.current={columnId:i,startX:e.clientX,startWidth:lt,minWidth:d,maxWidth:g},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Je),document.addEventListener("mouseup",Te)},[E,R,Je,Te,Xe]);a.useEffect(()=>()=>Te(),[Te]);const Ot=H.useSensors(H.useSensor(H.PointerSensor),H.useSensor(H.KeyboardSensor,{coordinateGetter:H.sortableKeyboardCoordinates})),Tt=e=>{const{active:n,over:s}=e;if(s&&n.id!==s.id){if(n.id===B||s.id===B){bt("Cannot drop columns on the Action column"),it(null);return}re.current=!0,Oe(i=>{const o=i.indexOf(n.id),f=i.indexOf(s.id);if(o!==-1&&f!==-1){const d=H.arrayMove(i,o,f),g=se(d);return St(g),g}return i}),mt(i=>{const o=i.indexOf(n.id),f=i.indexOf(s.id);return H.arrayMove(i,o,f)})}it(null)},$t=e=>{it(e.active.id)},Ye=a.useMemo(()=>{if(_)return r||[];if(!r||r.length===0)return[];const e=we.trim().toLowerCase(),n=Object.entries(K).filter(([,s])=>Ie(s));return r.filter(s=>{for(const[i,o]of n){const f=s[i];if(f==null)return!1;if(Array.isArray(o)){const d=String(f);if(!o.some(g=>String(g)===d))return!1;continue}if(o.type==="range"){const d=pt(f);if(isNaN(d)||o.min!==""&&o.min!=null&&d<Number(o.min)||o.max!==""&&o.max!=null&&d>Number(o.max))return!1;continue}if(o.type==="durationRange"){const d=en(f);if(isNaN(d)||o.minSec!==""&&o.minSec!=null&&d<Number(o.minSec)||o.maxSec!==""&&o.maxSec!=null&&d>Number(o.maxSec))return!1;continue}if(o.type==="scoreRange"){const d=pt(f);if(isNaN(d))return!1;if(Array.isArray(o.values)&&o.values.length>0){const g=Math.floor(d);if(!o.values.includes(g))return!1;continue}if(o.min!==""&&o.min!=null&&d<Number(o.min)||o.max!==""&&o.max!=null&&d>Number(o.max))return!1;continue}if(o.type==="dateRange"){const d=tn(f);if(!d)return!1;if(o.from){const g=new Date(o.from+"T00:00:00");if(d<g)return!1}if(o.to){const g=new Date(o.to+"T23:59:59");if(d>g)return!1}continue}}return!(e&&!Object.values(s).some(o=>o==null?!1:String(o).toLowerCase().includes(e)))})},[r,K,we,_]),$e=a.useMemo(()=>q||!J?Ye:[...Ye].sort((e,n)=>{const s=e[J],i=n[J];if(s==null)return 1;if(i==null)return-1;if(typeof s=="number"&&typeof i=="number")return _e==="asc"?s-i:i-s;const o=String(s).toLowerCase(),f=String(i).toLowerCase();return _e==="asc"?o.localeCompare(f):f.localeCompare(o)}),[Ye,J,_e,q]),Qe=a.useMemo(()=>{if(Y)return $e;{const e=(ee-1)*ae,n=e+ae;return $e.slice(e,n)}},[$e,ee,ae,Y]),yt=e=>{q&&T?(T(e),y?y(1):Q(1)):(ze===e?Ne(Be==="asc"?"desc":"asc"):(tt(e),Ne("asc")),Se(1))},Lt=(e,n)=>{const s=(n||"").split(/\s+/).map(i=>i.trim()).filter(Boolean);We(e,s)},bt=e=>{ot.current||(typeof D=="function"&&D(e),ot.current=setTimeout(()=>{ot.current=null},3e3))},St=a.useCallback(e=>{if(typeof window<"u"&&te&&e.length>0&&re.current)try{localStorage.setItem(te,JSON.stringify(e)),le&&localStorage.setItem(le,"true")}catch(n){console.warn("Failed to save columns to localStorage:",n)}},[te,le]),vt=250,Ze=()=>{Object.values(fe.current).forEach(e=>clearTimeout(e)),fe.current={}},Pt=()=>{const e=ue.filter(n=>!qe.has(n));return He.forEach(n=>{e.includes(n)||e.push(n)}),se(e)},It=e=>{if(e===B)return;if(fe.current[e]){clearTimeout(fe.current[e]),delete fe.current[e],je(s=>{const i=new Set(s);return i.delete(e),i}),ke(s=>{const i=new Set(s);return i.delete(e),i});return}if(ue.includes(e)){if(ue.length-qe.size<=1)return;ke(i=>new Set(i).add(e)),fe.current[e]=setTimeout(()=>{Fe(i=>i.filter(o=>o!==e)),ke(i=>{const o=new Set(i);return o.delete(e),o}),delete fe.current[e]},vt)}else{if(ue.length+He.size>=X){bt("Maximum 9 column selection allowed");return}je(i=>new Set(i).add(e)),fe.current[e]=setTimeout(()=>{Fe(i=>se([...i,e])),je(i=>{const o=new Set(i);return o.delete(e),o}),delete fe.current[e]},vt)}},_t=(e,n)=>{ue[n]!==B&&rt(n)},Ht=()=>{rt(null),Ge(null)},qt=(e,n)=>{e.preventDefault(),pe!==null&&pe!==n&&Ge(n)},Kt=()=>{Ge(null)},Gt=(e,n)=>{e.preventDefault(),pe!==null&&pe!==n&&ue[n]!==B&&ue[pe]!==B&&Fe(s=>{const i=H.arrayMove(s,pe,n);return se(i)}),rt(null),Ge(null)};a.useEffect(()=>{mt(e=>{const n=O.filter(o=>e.includes(o)),s=O.filter(o=>!e.includes(o)),i=e.filter(o=>!O.includes(o));return[...n,...s,...i]})},[O]),a.useEffect(()=>{if(typeof window<"u"&&te&&O.length>0&&re.current)try{const e=se(O);localStorage.setItem(te,JSON.stringify(e)),le&&localStorage.setItem(le,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[O,te,le]),a.useEffect(()=>{ie&&ie(O.filter(e=>e!==B))},[O,ie]),a.useEffect(()=>{if(l.length>0&&O.length===0){if(typeof window<"u"&&v)try{if(localStorage.getItem(`dataTable_manual_change_${v}:${W}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${v}:${W}`);if(s){const i=JSON.parse(s);if(Array.isArray(i)&&i.length>0){const o=i.filter(f=>l.some(d=>(d.id||d.key)===f));if(o.length>0){re.current=!0,Oe(o.slice(0,X));return}}}}}catch(n){console.warn("Failed to load saved columns from localStorage:",n)}const e=l.map(n=>n.id||n.key);Oe(se(e.slice(0,X)))}},[l,v,W,se]);const De=a.useMemo(()=>{const e=O.map(n=>l.find(s=>G(s)===n)).filter(Boolean);return se(e.map(G)).map(n=>l.find(s=>G(s)===n)).filter(Boolean)},[l,O]);a.useMemo(()=>De.some(e=>e.filterable===!0),[De]),a.useEffect(()=>{if(!oe||!Ce.current)return;const e=()=>{if(Ce.current){const n=Ce.current.getBoundingClientRect(),s=217,i=Math.max(8,n.right-s);zt({top:n.bottom,left:i,width:Math.max(n.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[oe]),a.useEffect(()=>{const e=n=>{oe&&Ce.current&&!Ce.current.contains(n.target)&&st.current&&!st.current.contains(n.target)&&nt(!1)};if(oe)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[oe]),a.useEffect(()=>{oe&&(Ze(),Fe(O),je(new Set),ke(new Set))},[oe,O]),a.useEffect(()=>()=>Ze(),[]),O.length===1?(kt=l.find(e=>(e.id||e.key)===O[0]))!=null&&kt.label:`${O.length}`;function Ut({column:e,isHeaderRow:n=!0}){const s=G(e),i=s===B,o=gt(s,e.width),[f,d]=a.useState(!1),{attributes:g,listeners:L,setNodeRef:P,transform:Pe,transition:lt,isDragging:Ve}=H.useSortable({id:s}),Jt={transform:H.CSS.Transform.toString(Pe),transition:lt,opacity:Ve?.5:1,width:o,minWidth:o};let Re=!1;if(q&&j.length>0){const C=j[0][0];(C===s||C==="csat_score"&&s==="evaluation.csat_score")&&(Re=!0)}else Re=J===s;const Yt=_e==="asc",Qt=e.filterable===!0;if(!n)return t.jsx("th",{style:{width:o,minWidth:o,backgroundColor:"var(--primary-foreground)",borderRight:"1px solid #e6e6e6",borderBottom:"1px solid #e6e6e6",boxSizing:"border-box"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:Qt?t.jsxs("div",{className:"relative",children:[t.jsx(Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),t.jsx("input",{type:"text",placeholder:"Filter...",value:K[s]||"",onChange:C=>{C.stopPropagation(),Lt(s,C.target.value)},onKeyDown:C=>C.stopPropagation(),onMouseDown:C=>C.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded text-[var(--text-ink)] placeholder:text-[var(--text-faint)] focus:outline-none focus:border-[var(--border-hover)] focus:ring-1 focus:ring-[var(--focus)] transition-colors",style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)"},autoComplete:"off"})]}):t.jsx("div",{className:"h-[34px]"})});const ct=N===s,et=Ie(K[s]),Zt=e.sortable!==!1&&(f||Re),Vt=e.filterable!==!1&&!i&&(f||ct||et);return t.jsxs("th",{ref:P,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{...Jt,padding:"0 12px",height:36,textAlign:i?"center":"left",fontWeight:500,fontSize:"14px",letterSpacing:"normal",textTransform:"none",color:"#0b0b0b",cursor:e.sortable!==!1?"pointer":"default",width:o,...typeof o=="string"&&o.endsWith("px")?{maxWidth:o}:{},borderRight:"1px solid #e6e6e6",boxSizing:"border-box",userSelect:"none",whiteSpace:"nowrap",wordBreak:"normal",overflowWrap:"normal",verticalAlign:"middle",background:f||ct?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:i?"center":"flex-start",position:"relative",minHeight:20,minWidth:0,width:"100%",overflow:"hidden"},children:[!i&&t.jsx("div",{...g,...L,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:f?"visible":"hidden",flexShrink:0},children:t.jsx($.GripVertical,{size:14})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&yt(s),title:typeof e.label=="string"?e.label:void 0,style:{cursor:e.sortable!==!1?"pointer":"default",flex:i?"none":1,minWidth:0,lineHeight:"20px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),Zt&&t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),yt(s)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Re?"#0b0b0b":"rgba(11, 11, 11, 0.55)",flexShrink:0},children:Re?Yt?t.jsx($.ArrowUp,{size:14,strokeWidth:1.75}):t.jsx($.ArrowDown,{size:14,strokeWidth:1.75}):t.jsx($.ArrowUpDown,{size:14,strokeWidth:1.75})}),Vt&&t.jsxs("button",{type:"button",ref:C=>{ge.current[s]=C},onClick:C=>{C.stopPropagation(),A(s,C.currentTarget)},title:"Filter",style:{position:"relative",background:ct||et?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:et?"#0b0b0b":"rgba(11, 11, 11, 0.7)",flexShrink:0},children:[t.jsx($.ListFilter,{size:14,strokeWidth:1.75}),et&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!i&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),!i&&t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||s} column`,title:"Drag to resize column",onMouseDown:C=>At(C,e,o),onClick:C=>C.stopPropagation(),onMouseEnter:C=>{C.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const wt=xt?l.find(e=>G(e)===xt):null,Ft=({col:e,columnId:n,isSelected:s,draggable:i,isAction:o,actualIndex:f})=>{const d=i&&pe===f,g=i&&Bt===f&&pe!==null&&pe!==f;s?qe.has(n):He.has(n);const L=s?!qe.has(n):He.has(n);return t.jsxs("div",{draggable:i,onDragStart:i?P=>_t(P,f):void 0,onDragEnd:i?Ht:void 0,onDragOver:i?P=>qt(P,f):void 0,onDragLeave:i?Kt:void 0,onDrop:i?P=>Gt(P,f):void 0,onClick:()=>{o||It(n)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:o?"default":i?"grab":"pointer",opacity:d?.5:1,background:g?"#F2F2F0":"transparent",borderRadius:6},children:[t.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:i?"visible":"hidden",flexShrink:0},children:t.jsx($.GripVertical,{size:14,strokeWidth:1.75})}),t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:L?"#0B0B0B":"#FFFFFF",border:`1px solid ${L?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:L&&t.jsx($.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{flex:1,fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",marginLeft:8},children:e.label})]})},Xt=oe?t.jsxs("div",{ref:st,style:{position:"fixed",top:`${ht.top}px`,left:`${ht.left}px`,width:217,maxHeight:320,zIndex:49,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,overflow:"hidden",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)",boxShadow:"0 8px 24px rgba(11, 11, 11, 0.08)"},children:[t.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:12},children:[ue.map((e,n)=>{if(e===B)return null;const s=l.find(i=>G(i)===e);return s?t.jsx(a.Fragment,{children:Ft({col:s,columnId:e,isSelected:!0,draggable:!0,isAction:!1,actualIndex:n})},`selected-${e}-${n}`):null}),l.filter(e=>{const n=G(e);return n!==B&&!ue.includes(n)}).map(e=>{const n=G(e);return t.jsx(a.Fragment,{children:Ft({col:e,columnId:n,isSelected:!1,draggable:!1,isAction:!1,actualIndex:-1})},`unselected-${n}`)})]}),t.jsxs("div",{style:{flexShrink:0,borderTop:"1px solid #D9D9D9",padding:"8px 12px",background:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"space-between",height:46,boxSizing:"border-box"},children:[t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=Ke.current?[...Ke.current]:l.map(G).slice(0,X),s=se(n);if(re.current=!1,Ze(),Fe(s),Oe(s),je(new Set),ke(new Set),typeof window<"u"&&te)try{localStorage.removeItem(te)}catch{}},style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"}),t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),Ze();const n=Pt();Fe(n),je(new Set),ke(new Set),re.current=!0,Oe(n),St(n),nt(!1)},style:{background:"#2E3236",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,cursor:"pointer"},children:"Apply"})]})]}):null,Le=N?l.find(e=>G(e)===N):null,jt=Le?t.jsx(cn,{column:Le,columnId:N,filterType:x(N),position:ye,popoverRef:be,distinctValues:h(N),initialValue:K[N],onSearch:typeof Le.onFilterSearch=="function"?Le.onFilterSearch:null,searchMinChars:Le.filterSearchMinChars??3,onApply:e=>{We(N,e),ce(null)},onCancel:()=>ce(null)},N):null;return t.jsxs("div",{className:"w-full",children:[jt&&ft.createPortal(jt,document.body),l.length>0&&(I||!me)&&t.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:16,flexWrap:"wrap"},children:[I&&t.jsx("div",{style:{marginRight:"auto"},children:t.jsx(Mt,{dateRangePicker:I.dateRangePicker,onWeekToDate:I.onWeekToDate,exportConfig:I.exportConfig,filterChipsConfig:I.filterChipsConfig,trailingActions:I.trailingActions})}),!me&&t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{ref:Ce,type:"button",onClick:()=>nt(!oe),style:{display:"inline-flex",alignItems:"center",gap:10,height:32,padding:"0 16px",background:"#FFFFFF",border:"1px solid #D9D9D9",borderRadius:10,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,color:"#2E3236",whiteSpace:"nowrap"},children:[t.jsx($.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),oe&&ft.createPortal(Xt,document.body)]})]})}),Object.keys(K).length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(K).map(([e,n])=>{const s=l.find(d=>G(d)===e);if(!s||!Ie(n))return null;const i=rn(n),o=sn(n),f=on(n);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,height:28,padding:"0 12px",borderRadius:20,border:"1px solid #B2B2B0",background:"#F2F2F0",fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",whiteSpace:"nowrap"},children:[t.jsxs("span",{children:[t.jsxs("span",{style:{color:"#676767"},children:[s.label,": "]}),t.jsx("span",{children:i})]}),o>0&&t.jsx(an,{count:o,values:f}),t.jsx("button",{type:"button",onClick:()=>We(e,[]),"aria-label":`Remove ${s.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:t.jsx($.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),t.jsx("button",{type:"button",onClick:m,style:{marginLeft:"auto",background:"transparent",border:"none",padding:"0 4px",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"})]}),l.length>0&&De.length>0?t.jsxs(H.DndContext,{sensors:Ot,collisionDetection:H.closestCenter,onDragStart:$t,onDragEnd:Tt,children:[t.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem",...z?{minHeight:320}:{}},children:[z&&t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(2px)",zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"14px"},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[t.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),t.jsx(un,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),t.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:Wt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:t.jsxs("table",{style:{width:"auto",minWidth:"100%",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)",border:"1px solid #e6e6e6",boxSizing:"border-box"},children:[t.jsx("thead",{children:t.jsx("tr",{children:t.jsx(H.SortableContext,{items:O,strategy:H.horizontalListSortingStrategy,children:De.map(e=>t.jsx(Ut,{column:e,isHeaderRow:!0},`header-${G(e)}`))})})}),t.jsx("tbody",{children:!z&&Qe.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:De.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!z&&Qe.length>0?Qe.map((e,n)=>t.jsx("tr",{"data-row-id":e.id||n,style:{borderBottom:"1px solid #e6e6e6",cursor:p?"pointer":"default",transition:"background 0.15s ease"},onClick:p?s=>{s.stopPropagation(),p(e,n)}:void 0,onMouseEnter:s=>{s.currentTarget.style.background="#E6E6E6"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:De.map(s=>{const i=G(s),o=gt(i,s.width),f=e[i],d=s.render?s.render(f,e):f,g=o&&o!=="auto",L=typeof d=="string"&&d.trim()!=="",P=g&&L,Pe=P?t.jsx(ne,{content:d,children:d}):d;return t.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid #e6e6e6",boxSizing:"border-box",width:o,fontFamily:"var(--font-sans)",...P&&{maxWidth:o||"200px"}},children:Pe},i)})},n)):null})]})})]}),t.jsx(H.DragOverlay,{children:wt?t.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:wt.label})]})}):null})]}):null,(()=>{const e=!_&&(we.trim()!==""||Object.values(K).some(s=>Ie(s))),n=Y?e?$e.length:S:$e.length;return n<=0?null:t.jsx(Et.Pagination,{page:ee,pageSizeOptions:[5,10,20,50,100],pageSize:ae,totalCount:n,currentDataLength:Qe.length,onPageChange:Se,onPageSizeChange:s=>{Ee(s),Se(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=pn;exports.DataTableFilters=Mt;
1
+ "use strict";const n=require("react/jsx-runtime"),l=require("react"),H=require("./sortable.esm.cjs.js"),T=require("lucide-react"),bt=require("react-dom"),Pt=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./AgentLiftAnalysisCard.cjs.js");require("./TourGuideTooltip.cjs.js");function It({dateRangePicker:s,onWeekToDate:a,exportConfig:u,filterChipsConfig:p,trailingActions:v}){const[S,c]=l.useState(!1),y=l.useRef(null),N=l.useRef(null);l.useEffect(()=>{const j=b=>{N.current&&!N.current.contains(b.target)&&y.current&&!y.current.contains(b.target)&&c(!1)};if(S)return document.addEventListener("mousedown",j),()=>{document.removeEventListener("mousedown",j)}},[S]);const F=()=>{c(j=>!j)},k=j=>{c(!1),u!=null&&u.onExport&&u.onExport(j)},I=(()=>{if(!(p!=null&&p.filters))return!1;const j=p.filters,b=p.customFilters||[],W=Object.entries(j).some(([R,z])=>!!(Array.isArray(z)&&z.length||typeof z=="string"&&z.trim()!==""||z&&typeof z=="object"&&(z.min!=null||z.max!=null))),O=b.some(R=>R.active);return W||O})();return n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[a&&n.jsxs("button",{onClick:a,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900",style:{fontFamily:"var(--font-sans)"},children:[n.jsx(T.CalendarClock,{size:16}),n.jsx("span",{children:"Week to Date"})]}),s&&n.jsx(l.Suspense,{fallback:n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-400",children:[n.jsx(T.CalendarClock,{size:16}),n.jsx("span",{children:"Loading..."})]}),children:s}),u&&n.jsxs("div",{className:"relative",children:[n.jsxs("button",{ref:y,onClick:F,disabled:u.isExporting,className:"inline-flex items-center justify-between gap-2 rounded-lg border border-gray-300 bg-white/80 px-4 py-2.5 transition-colors hover:bg-white text-sm font-medium text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px]",style:{fontFamily:"var(--font-sans)"},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(T.Download,{size:16}),n.jsx("span",{children:u.isExporting?"Exporting...":"Export"})]}),n.jsx(T.ChevronDown,{size:16})]}),S&&n.jsx("div",{ref:N,className:"absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[120px]",children:(u.types||["csv"]).map(j=>n.jsxs("button",{onClick:()=>k(j),className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors",style:{fontFamily:"var(--font-sans)"},children:["Export ",j.toUpperCase()]},j))})]}),(I||v)&&n.jsxs(n.Fragment,{children:[I&&n.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),n.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[I&&p&&n.jsx(Pt.CustomFilterChips,{filters:p.filters,onChange:p.onChange,onClear:p.onClear,customFilters:p.customFilters||[],fieldOptions:p.fieldOptions||{}}),v&&n.jsx("div",{className:"flex-shrink-0",children:v})]})]})]})}function St(s){if(s==null)return NaN;const a=String(s).replace(/[,$%]|pp/gi,"").trim(),u=parseFloat(a);return Number.isFinite(u)?u:NaN}function xn(s){if(s==null)return NaN;const a=String(s).trim(),u=a.match(/^(\d+):(\d+)(?::(\d+))?$/);if(u){const F=+u[1],k=+u[2],D=u[3]!=null?+u[3]:null;return D!=null?F*3600+k*60+D:F*60+k}let p=0,v=!1;const S=a.match(/(\d+)\s*d\b/i),c=a.match(/(\d+)\s*h\b/i),y=a.match(/(\d+)\s*m(?!s)\b/i),N=a.match(/(\d+)\s*s\b/i);return S&&(p+=+S[1]*86400,v=!0),c&&(p+=+c[1]*3600,v=!0),y&&(p+=+y[1]*60,v=!0),N&&(p+=+N[1],v=!0),v?p:NaN}function gn(s){if(!s)return null;const a=String(s).trim(),u=a.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(u){const v=u[3].length===2?2e3+ +u[3]:+u[3],S=new Date(v,+u[1]-1,+u[2]);return isNaN(S.getTime())?null:S}const p=new Date(a);return isNaN(p.getTime())?null:p}function yn(s){if(!s||s.length===0)return"text";const a=s.slice(0,25),u=p=>a.every(p);return u(p=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(p)||/^\d{4}-\d{2}-\d{2}/.test(p))?"date":u(p=>/^\d+\s*[dhms]\b/i.test(p)||/^\d+:\d+(:\d+)?$/.test(p))?"duration":u(p=>/^-?[\d,.]+(%|pp)?$/i.test(p))?"number":"text"}function Ke(s){return s?Array.isArray(s)?s.length>0:s.type==="range"?s.min!==""&&s.min!==void 0&&s.min!==null||s.max!==""&&s.max!==void 0&&s.max!==null:s.type==="durationRange"?s.minSec!==""&&s.minSec!=null||s.maxSec!==""&&s.maxSec!=null:s.type==="scoreRange"?Array.isArray(s.values)&&s.values.length>0||s.min!==""&&s.min!=null||s.max!==""&&s.max!=null:s.type==="dateRange"?!!(s.from||s.to):!1:!1}function Tt(s){if(s==null||s===""||isNaN(s))return"";const a=Number(s),u=Math.floor(a/3600),p=Math.floor(a%3600/60),v=Math.floor(a%60);return u>0?`${u}h ${p}m`:p>0?`${p}m ${v}s`:`${v}s`}function bn(s){if(!s)return"";if(Array.isArray(s))return s.length===0?"":String(s[0]);if(s.type==="range"){const a=s.min!==""&&s.min!=null?s.min:null,u=s.max!==""&&s.max!=null?s.max:null;return a!=null&&u!=null?`${a} – ${u}`:a!=null?`≥ ${a}`:u!=null?`≤ ${u}`:""}if(s.type==="durationRange"){const a=s.minSec!==""&&s.minSec!=null?Tt(s.minSec):null,u=s.maxSec!==""&&s.maxSec!=null?Tt(s.maxSec):null;return a&&u?`${a} – ${u}`:a?`≥ ${a}`:u?`≤ ${u}`:""}if(s.type==="scoreRange"){if(Array.isArray(s.values)&&s.values.length>0)return s.values.slice().sort((p,v)=>p-v).join(", ");const a=s.min!==""&&s.min!=null?s.min:null,u=s.max!==""&&s.max!=null?s.max:null;return a!=null&&u!=null?`${a} – ${u}`:a!=null?`≥ ${a}`:u!=null?`≤ ${u}`:""}return s.type==="dateRange"?s.from&&s.to?`${s.from} – ${s.to}`:s.from?`from ${s.from}`:s.to?`to ${s.to}`:"":""}function Sn(s){return Array.isArray(s)?Math.max(0,s.length-1):0}function vn(s){return Array.isArray(s)?s.slice(1).map(String).join(", "):""}function wn({count:s,values:a}){const[u,p]=l.useState(!1);return n.jsxs("span",{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:22,minWidth:22,padding:"0 6px",background:"#D8D8D8",color:"#0B0B0B",borderRadius:14,fontSize:12,fontWeight:500,lineHeight:1,cursor:"pointer"},children:["+",s,u&&n.jsx("span",{role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",background:"#1E2125",color:"#FFFFFF",fontFamily:"var(--font-sans)",fontSize:12,fontWeight:400,lineHeight:"20px",padding:"6px 10px",borderRadius:8,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100,boxShadow:"0 6px 16px rgba(11, 11, 11, 0.18)"},children:a})]})}function Fn({leftLabel:s,rightLabel:a,leftValue:u,rightValue:p,onLeftChange:v,onRightChange:S,type:c="number",placeholderLeft:y="Min",placeholderRight:N="Max"}){const F={width:"100%",height:32,borderRadius:8,border:"1px solid #D9D9D9",background:"#FFFFFF",padding:"0 10px",fontFamily:"var(--font-sans)",fontSize:14,color:"#0B0B0B",outline:"none",boxSizing:"border-box"},k={fontSize:12,color:"#676767",marginBottom:4,fontFamily:"var(--font-sans)"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[n.jsx("span",{style:k,children:s}),n.jsx("input",{type:c,value:u,onChange:D=>v(D.target.value),placeholder:y,style:F})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[n.jsx("span",{style:k,children:a}),n.jsx("input",{type:c,value:p,onChange:D=>S(D.target.value),placeholder:N,style:F})]})]})}const $t=[{id:"0-60",label:"0 to 60 Sec",minSec:0,maxSec:60},{id:"60-120",label:"1m to 2 m",minSec:60,maxSec:120},{id:"120-180",label:"2m to 3 m",minSec:120,maxSec:180},{id:"180-240",label:"3m to 4m",minSec:180,maxSec:240},{id:"240-300",label:"4m to 5m",minSec:240,maxSec:300},{id:"300+",label:"5 mins and above",minSec:300,maxSec:null}];function Lt(s){if(s==null||s==="")return null;const a=String(s).trim().match(/^(\d{1,3}):(\d{2})$/);if(a)return Number(a[1])*60+Number(a[2]);const u=Number(s);return Number.isFinite(u)?u:null}function gt({children:s}){return n.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0 2px",fontFamily:"var(--font-sans)"},children:s})}function yt({minValue:s,maxValue:a,onMinChange:u,onMaxChange:p,inputType:v="number",inputMode:S="decimal",step:c,placeholder:y="0.0",unit:N}){const F={width:"100%",height:30,border:"1px solid #ACADAD",borderRadius:4,padding:"6px 10px",fontSize:13,color:"#0B0B0B",fontFamily:"var(--font-sans)",outline:"none",boxSizing:"border-box"};return n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[n.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Min From"}),n.jsx("input",{type:v,inputMode:S,step:c,placeholder:y,value:s,onChange:k=>u(k.target.value),style:F})]}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#323232",paddingBottom:8,fontFamily:"var(--font-sans)"},children:"to"}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1,minWidth:0},children:[n.jsx("span",{style:{fontSize:12,color:"#2E3236",fontFamily:"var(--font-sans)"},children:"Max"}),n.jsx("input",{type:v,inputMode:S,step:c,placeholder:y,value:a,onChange:k=>p(k.target.value),style:F})]})]}),N&&n.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Enter durations in ",N==="sec"?"seconds":N]})]})}function jn({column:s,columnId:a,filterType:u="text",position:p,popoverRef:v,distinctValues:S,initialValue:c,onApply:y,onCancel:N,onSearch:F=null,searchMinChars:k=3}){const D=u==="text",I=u==="number",j=u==="date",b=u==="duration",W=u==="score",O=/duration/i.test(String((s==null?void 0:s.label)||a||"")),R=l.useMemo(()=>{if(!W||!Array.isArray(S)||S.length===0)return!1;let h=1/0,m=-1/0;for(const x of S){const w=St(x);Number.isFinite(w)&&(w<h&&(h=w),w>m&&(m=w))}return Number.isFinite(h)&&Number.isFinite(m)&&h>=0&&m<=5},[W,S]),[z,ie]=l.useState(()=>D?new Set(Array.isArray(c)?c:[]):new Set),[pe,K]=l.useState(""),[Y,U]=l.useState(()=>I&&(c==null?void 0:c.type)==="range"&&c.min!=null?c.min:""),[Q,re]=l.useState(()=>I&&(c==null?void 0:c.type)==="range"&&c.max!=null?c.max:""),[E,le]=l.useState(new Set),[ne,$]=l.useState(()=>b&&(c==null?void 0:c.type)==="durationRange"&&c.minSec!=null&&c.minSec!==""?String(c.minSec):""),[J,ae]=l.useState(()=>b&&(c==null?void 0:c.type)==="durationRange"&&c.maxSec!=null&&c.maxSec!==""?String(c.maxSec):""),[ce,Ue]=l.useState(()=>W&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[$e,Fe]=l.useState(()=>W&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[he,je]=l.useState(()=>W&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[Ge,G]=l.useState(()=>j&&(c==null?void 0:c.type)==="dateRange"&&c.from||""),[L,Z]=l.useState(()=>j&&(c==null?void 0:c.type)==="dateRange"&&c.to||"");l.useEffect(()=>{D&&ie(new Set(Array.isArray(c)?c:[]))},[a,D]);const[Le,V]=l.useState(null),[me,q]=l.useState(!1),xe=l.useRef(0),ee=pe.trim(),Xe=D&&typeof F=="function"&&ee.length>=k;l.useEffect(()=>{if(!D||typeof F!="function")return;if(ee.length<k){V(null),q(!1);return}const h=++xe.current;q(!0);const m=setTimeout(async()=>{try{const x=await F(ee);if(h!==xe.current)return;const w=Array.isArray(x)?x.map(M=>M&&typeof M=="object"?M.label??M.value:M).filter(M=>M!=null&&M!=="").map(String):[];V(w)}catch{h===xe.current&&V([])}finally{h===xe.current&&q(!1)}},300);return()=>clearTimeout(m)},[D,F,ee,k]);const B=l.useMemo(()=>{const h=ee.toLowerCase(),m=Xe?Le||[]:h?S.filter(w=>String(w).toLowerCase().includes(h)):S,x=new Map;for(const w of m)x.set(String(w),w);for(const w of z)x.set(String(w),w);return Array.from(x.values()).sort((w,M)=>{const ye=String(w)==="NA",Ce=String(M)==="NA";if(ye!==Ce)return ye?-1:1;const te=z.has(w),De=z.has(M);return te!==De?te?-1:1:String(w).localeCompare(String(M))})},[S,ee,z,Xe,Le]),ge=h=>{ie(m=>{const x=new Set(m);return x.has(h)?x.delete(h):x.add(h),x})},Je=()=>{D&&ie(new Set),I&&(U(""),re("")),b&&(le(new Set),$(""),ae("")),W&&(Ue(new Set),Fe(""),je("")),j&&(G(""),Z("")),K("")},ke=h=>{le(m=>{const x=new Set(m);return x.has(h)?x.delete(h):x.add(h),x})},be=h=>{Ue(m=>{const x=new Set(m);return x.has(h)?x.delete(h):x.add(h),x})},Se=()=>{if(D)return y(Array.from(z));if(I)return y({type:"range",min:Y===""?"":Number(Y),max:Q===""?"":Number(Q)});if(b){const h=Lt(ne),m=Lt(J),x=h!=null||m!=null;let w="",M="";if(x)w=h??"",M=m??"";else if(E.size>0){const ye=$t.filter(te=>E.has(te.id));w=Math.min(...ye.map(te=>te.minSec)),M=ye.some(te=>te.maxSec==null)?"":Math.max(...ye.map(te=>te.maxSec))}return y({type:"durationRange",minSec:w,maxSec:M})}if(W){const h=$e===""?null:Number($e),m=he===""?null:Number(he);return h!=null||m!=null?y({type:"scoreRange",values:[],min:h!=null&&Number.isFinite(h)?h:"",max:m!=null&&Number.isFinite(m)?m:""}):y({type:"scoreRange",values:Array.from(ce).sort((w,M)=>w-M),min:"",max:""})}if(j)return y({type:"dateRange",from:Ge,to:L})};return n.jsxs("div",{ref:v,role:"dialog","aria-label":`Filter ${s.label||a}`,style:{position:"fixed",top:p.top,left:p.left,zIndex:50,width:D?240:220,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,padding:12,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 8px 24px rgba(11, 11, 11, 0.10)",fontFamily:"var(--font-sans)"},children:[D&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{background:"#D8D8D8",height:32,borderRadius:10,padding:1,display:"flex",alignItems:"center"},children:n.jsxs("div",{style:{background:"#FFFFFF",flex:1,height:30,borderRadius:10,display:"flex",alignItems:"center",gap:8,padding:"0 8px"},children:[n.jsx(T.Search,{size:16,color:"#989898",strokeWidth:2}),n.jsx("input",{autoFocus:!0,type:"text",value:pe,onChange:h=>K(h.target.value),placeholder:"Search",style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:14,color:"#0B0B0B",minWidth:0,fontFamily:"var(--font-sans)"}})]})}),n.jsx("div",{style:{maxHeight:220,overflowY:"auto",display:"flex",flexDirection:"column",gap:4},children:typeof F=="function"&&ee.length>0&&ee.length<k?n.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:`Type at least ${k} characters to search`}):me?n.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"Searching…"}):B.length===0?n.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):B.map(h=>{const m=z.has(h);return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"6px 4px",cursor:"pointer",borderRadius:6},children:[n.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:m?"#0B0B0B":"#FFFFFF",border:`1px solid ${m?"#0B0B0B":"#676767"}`,flexShrink:0},children:m&&n.jsx(T.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),n.jsx("input",{type:"checkbox",checked:m,onChange:()=>ge(h),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),n.jsx("span",{onClick:x=>{x.preventDefault(),ge(h)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]},h)})})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx(gt,{children:s.label||"Filter"}),n.jsx(yt,{minValue:Y,maxValue:Q,onMinChange:U,onMaxChange:re,placeholder:O?"00":"0.0",unit:O?"sec":void 0})]}),b&&n.jsxs(n.Fragment,{children:[n.jsx(gt,{children:s.label||"Duration"}),s.filterShowPresets===!0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:$t.map(h=>{const m=E.has(h.id);return n.jsxs("div",{role:"checkbox","aria-checked":m,tabIndex:0,onClick:()=>ke(h.id),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),ke(h.id))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[n.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:m?"#0B0B0B":"#FFFFFF",border:`1px solid ${m?"#0B0B0B":"#676767"}`,flexShrink:0},children:m&&n.jsx(T.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),n.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:h.label})]},h.id)})}),n.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),n.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"})]}),n.jsx(yt,{minValue:ne,maxValue:J,onMinChange:$,onMaxChange:ae,inputType:"number",inputMode:"numeric",placeholder:"00",unit:"sec"})]}),W&&n.jsxs(n.Fragment,{children:[n.jsx(gt,{children:s.label||"Score"}),R&&s.filterShowPresets===!0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[1,2,3,4,5].map(h=>{const m=ce.has(h);return n.jsxs("div",{role:"checkbox","aria-checked":m,tabIndex:0,onClick:()=>be(h),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),be(h))},style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer",userSelect:"none"},children:[n.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:m?"#0B0B0B":"#FFFFFF",border:`1px solid ${m?"#0B0B0B":"#676767"}`,flexShrink:0},children:m&&n.jsx(T.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),n.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:h})]},h)})}),n.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}})]}),R&&s.filterShowPresets===!0&&n.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#0B0B0B",lineHeight:"20px",padding:"4px 0",fontFamily:"var(--font-sans)"},children:"Custom Range"}),n.jsx(yt,{minValue:$e,maxValue:he,onMinChange:Fe,onMaxChange:je,step:"0.1"})]}),j&&n.jsx(Fn,{leftLabel:"From",rightLabel:"To",leftValue:Ge,rightValue:L,onLeftChange:G,onRightChange:Z,type:"date",placeholderLeft:"",placeholderRight:""}),n.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}}),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx("button",{type:"button",onClick:Je,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:b&&s.filterShowPresets===!0||W&&R&&s.filterShowPresets===!0?"View All":"Reset"}),n.jsx("button",{type:"button",onClick:Se,style:{background:"#0B0B0B",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Apply"})]})]})}const kn=()=>({userData:{email:"anonymous"}}),Cn=s=>n.jsx("img",{...s});function Dn({children:s,content:a,direction:u="top",align:p="center",styling:v,indicatorColor:S}){const c=typeof a=="string"?a:a!=null?String(a):"",y=typeof S=="string"&&(S.startsWith("#")||S.startsWith("rgb")||S.startsWith("hsl")||S.startsWith("var("))?S:"var(--Grey-Strong, #2E3236)",[N,F]=l.useState(!1),[k,D]=l.useState(!1),[I,j]=l.useState({top:0,left:0,arrowLeft:0,placement:"top"}),b=l.useRef(null),W=l.useRef(null);if(!c)return s;l.useEffect(()=>{D(!0)},[]);const O=l.useCallback(()=>{if(!b.current||!W.current||typeof window>"u")return;const R=b.current.getBoundingClientRect(),z=W.current.getBoundingClientRect(),ie=window.innerWidth,pe=window.innerHeight,K=8,Y=10,U=z.width,Q=z.height,re=R.top,E=pe-R.bottom,le=u==="bottom"?"bottom":"top";let ne=le;le==="top"&&re<Q+Y+K&&E>re?ne="bottom":le==="bottom"&&E<Q+Y+K&&re>E&&(ne="top");let $=R.left+R.width/2;p==="start"&&($=R.left),p==="end"&&($=R.right);let J=ne==="top"?R.top-Q-Y:R.bottom+Y,ae=p==="start"?$:p==="end"?$-U:$-U/2;J=Math.max(K,Math.min(J,pe-Q-K)),ae=Math.max(K,Math.min(ae,ie-U-K));const ce=Math.max(10,Math.min($-ae,U-10));j({top:J,left:ae,arrowLeft:ce,placement:ne})},[p,u]);return l.useEffect(()=>{if(!N||!k)return;O();const R=()=>O();return window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[N,k,O]),n.jsxs("span",{ref:b,style:{display:"block",width:"100%"},onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),children:[s,N&&k&&bt.createPortal(n.jsxs("span",{ref:W,style:{position:"fixed",top:`${I.top}px`,left:`${I.left}px`,background:"var(--Grey-Strong, #2E3236)",color:"var(--Grey-White, #FFF)",fontSize:"12px",lineHeight:1.3,fontWeight:500,padding:"8px 10px",borderRadius:"6px",whiteSpace:"normal",maxWidth:"320px",width:"max-content",boxShadow:"0 6px 18px rgba(0, 0, 0, 0.2)",zIndex:99999,pointerEvents:"none",...typeof v=="object"?v:{}},children:[c,n.jsx("span",{style:{position:"absolute",left:`${I.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...I.placement==="top"?{top:"100%",borderTop:`7px solid ${y}`}:{bottom:"100%",borderBottom:`7px solid ${y}`}}})]}),document.body)]})}function Rn({data:s=[],columns:a=[],initialPageSize:u=10,onRowClick:p,totalCount:v=null,page:S=null,pageSize:c=null,onPageChange:y=null,onPageSizeChange:N=null,onFilterChange:F=null,columnFilters:k=null,onMaxColumnsError:D=null,onSort:I=null,sortFields:j=[],tableId:b=null,isLoading:W=!1,filtersConfig:O=null,columnResizeMinWidth:R=120,columnResizeMaxWidth:z=280,onVisibleColumnsChange:ie=null,hideColumnPicker:pe=!1,selectable:K=!1,selectedRowIds:Y=null,onSelectionChange:U=null,getRowId:Q=null}){var Ot;const{userData:re}=kn(),E=(re==null?void 0:re.email)||"anonymous",le=l.memo(({children:e,content:t,className:o=""})=>{const i=l.useRef(null),[r,f]=l.useState(!1);l.useEffect(()=>{const g=()=>{if(i.current){const _=i.current.scrollWidth>i.current.clientWidth;f(_)}};g();const A=setTimeout(g,0);return window.addEventListener("resize",g),()=>{clearTimeout(A),window.removeEventListener("resize",g)}},[e,t]);const d=n.jsx("span",{className:`truncate block ${o}`,ref:i,children:e});return r&&t?n.jsx(Dn,{content:t,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:d}):d});le.displayName="TruncatedCell";const ne=v!==null&&y!==null,$=F!==null,J=I!==null,[ae,ce]=l.useState(1),[Ue,$e]=l.useState(u),Fe=S!==null?S:ae,he=c!==null?c:Ue,je=e=>{y?y(e):ce(e)},Ge=e=>{N?N(e):$e(e)},G=50,L="action",Z=l.useRef(!1),Le=l.useRef(null),V=l.useMemo(()=>b?`dataTable_columns_${b}:${E}`:`dataTable_columns_${a.map(t=>t.id||t.key).sort().join("_")}:${E}`,[b,a,E]),me=l.useMemo(()=>b?`dataTable_manual_change_${b}:${E}`:null,[b,E]);l.useCallback((e,t)=>{if(typeof window>"u"||!e||!t||t.length===0)return null;try{const o=localStorage.getItem(e);if(o){const r=JSON.parse(o).filter(f=>t.some(d=>(d.id||d.key)===f));if(r.length>0)return r}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}return null},[]);const[q,xe]=l.useState({}),[ee,Xe]=l.useState(""),[B,ge]=l.useState(null),[Je,ke]=l.useState({top:0,left:0}),be=l.useRef(null),Se=l.useRef({}),[h,m]=l.useState(null),[x,w]=l.useState("asc"),M=l.useCallback((e,t)=>{const o=Ke(t);xe(i=>{const r={...i};return o?r[e]=t:delete r[e],r}),y?y(1):ce(1),$&&F&&F(o?{...q,[e]:t}:Object.fromEntries(Object.entries(q).filter(([i])=>i!==e)))},[q,F,$,y]),ye=l.useCallback(()=>{xe({}),Xe(""),y?y(1):ce(1),$&&F&&F({})},[F,$,y]),Ce=l.useCallback(e=>{const t=a.find(r=>(r.id||r.key)===e);if(t&&Array.isArray(t.filterOptions)){const r=new Set,f=[];for(const d of t.filterOptions){if(d==null||d==="")continue;const g=typeof d=="object"?JSON.stringify(d):String(d);r.has(g)||(r.add(g),f.push(g))}return f.sort((d,g)=>d.localeCompare(g))}if(!s||s.length===0)return[];const o=new Set,i=[];for(const r of s){const f=r[e];if(f==null)continue;const d=typeof f=="object"?JSON.stringify(f):String(f);o.has(d)||(o.add(d),i.push(d))}return i.sort((r,f)=>r.localeCompare(f))},[s,a]),te=l.useCallback(e=>{const t=a.find(o=>X(o)===e);return t&&t.filterType?t.filterType:yn(Ce(e))},[a,Ce]),De=l.useCallback(e=>{const i=typeof window<"u"?window.innerWidth:1/0;let r=e.left;return r+280>i-8&&(r=Math.max(8,e.right-280)),{top:e.bottom+6,left:r}},[]),_t=l.useCallback((e,t)=>{if(!t){ge(e);return}const o=t.getBoundingClientRect();ke(De(o)),ge(i=>i===e?null:e)},[De]);l.useEffect(()=>{if(!B)return;const e=t=>{if(be.current&&be.current.contains(t.target))return;const o=Se.current[B];o&&o.contains(t.target)||Object.values(Se.current).some(r=>r&&r.contains(t.target))||ge(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[B]),l.useEffect(()=>{if(!B)return;const e=()=>{const t=Se.current[B];if(!t)return;const o=t.getBoundingClientRect();ke(De(o))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[B,De]),l.useLayoutEffect(()=>{if(!B)return;const e=be.current,t=Se.current[B];if(!e||!t)return;const o=e.offsetWidth,i=t.getBoundingClientRect(),r=8,f=typeof window<"u"?window.innerWidth:1/0;if(!(i.left+o>f-r))return;const g=Math.max(r,i.right-o);ke(A=>A.left===g?A:{...A,left:g})},[B,Je.top]);const vt=l.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim()!=="":!0)),[]),wt=l.useCallback((e,t)=>{const o=Object.keys(e||{}),i=Object.keys(t||{});return o.length!==i.length?!1:o.every(r=>e[r]===t[r])},[]);l.useEffect(()=>{if(!$||k===null)return;const e=vt(k);xe(t=>wt(t,e)?t:e)},[$,k,vt,wt]),l.useCallback((e,t)=>e==="csat_score"&&t==="evaluation.csat_score"?t:e,[]);const Pe=J&&j.length>0?j[0][0]:h,Ye=J&&j.length>0?j[0][1]:x,[En,Ft]=l.useState(()=>a.map(e=>e.id||e.key)),se=l.useCallback(e=>{if(!e||e.length===0)return e;let t=Array.from(new Set(e));t.length>G&&(t=t.slice(0,G));const i=a.map(d=>d.id||d.key).includes(L);return!t.includes(L)&&i&&(t.length>=G?t=[...t.slice(0,G-1),L]:t=[...t,L]),[...t.filter(d=>d!==L),L]},[a]),[P,Re]=l.useState(()=>{if(typeof window<"u"&&b)try{if(localStorage.getItem(`dataTable_manual_change_${b}:${E}`)==="true"){const i=localStorage.getItem(`dataTable_columns_${b}:${E}`);if(i){const r=JSON.parse(i);if(Array.isArray(r)&&r.length>0){Z.current=!0;const f=r.filter(d=>a.some(g=>(g.id||g.key)===d));if(f.length>0)return f.slice(0,G)}}}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}const t=a.map(o=>o.id||o.key).slice(0,G);return se(t)}),[oe,ct]=l.useState(!1),[de,Ee]=l.useState([]),[jt,Ht]=l.useState({top:0,left:0,width:0}),[Qe,Me]=l.useState(new Set),[Ze,ze]=l.useState(new Set),ue=l.useRef({}),Ve=l.useRef(null);Ve.current===null&&(Ve.current=[...P]);const[fe,dt]=l.useState(null),[qt,et]=l.useState(null),Be=l.useRef(null),ut=l.useRef(null),ft=l.useRef(null),[kt,pt]=l.useState(null),[ht,Kt]=l.useState({}),Ut=l.useRef(null),tt=l.useRef(null),X=e=>e.id||e.key,nt=l.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("px")){const i=parseFloat(t);return Number.isFinite(i)?i:null}const o=parseFloat(t);return Number.isFinite(o)&&`${o}`===t?o:null}return null},[]),Ct=l.useCallback((e,t)=>ht[e]!=null?`${ht[e]}px`:typeof t=="number"?`${t}px`:t||"auto",[ht]),rt=l.useCallback(e=>{if(!tt.current)return;const{columnId:t,startX:o,startWidth:i,minWidth:r,maxWidth:f}=tt.current,d=e.clientX-o,g=Math.round(i+d),A=Math.min(f,Math.max(r,g));Kt(_=>({..._,[t]:A}))},[]),Ie=l.useCallback(()=>{tt.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",rt),document.removeEventListener("mouseup",Ie)},[rt]),Gt=l.useCallback((e,t,o)=>{var Oe;e.preventDefault(),e.stopPropagation();const i=t.id||t.key,r=nt(t.minWidth)??R,f=nt(t.maxWidth)??z,d=Math.min(r,f),g=Math.max(r,f),A=((Oe=e.currentTarget.closest("th"))==null?void 0:Oe.getBoundingClientRect().width)||0,_=nt(o),qe=_??Math.max(d,Math.round(A)||d),We=Math.min(g,Math.max(d,qe));tt.current={columnId:i,startX:e.clientX,startWidth:We,minWidth:d,maxWidth:g},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",rt),document.addEventListener("mouseup",Ie)},[z,R,rt,Ie,nt]);l.useEffect(()=>()=>Ie(),[Ie]);const Xt=H.useSensors(H.useSensor(H.PointerSensor),H.useSensor(H.KeyboardSensor,{coordinateGetter:H.sortableKeyboardCoordinates})),Jt=e=>{const{active:t,over:o}=e;if(o&&t.id!==o.id){if(t.id===L||o.id===L){Mt("Cannot drop columns on the Action column"),pt(null);return}Z.current=!0,Re(i=>{const r=i.indexOf(t.id),f=i.indexOf(o.id);if(r!==-1&&f!==-1){const d=H.arrayMove(i,r,f),g=se(d);return zt(g),g}return i}),Ft(i=>{const r=i.indexOf(t.id),f=i.indexOf(o.id);return H.arrayMove(i,r,f)})}pt(null)},Yt=e=>{pt(e.active.id)},st=l.useMemo(()=>{if($)return s||[];if(!s||s.length===0)return[];const e=ee.trim().toLowerCase(),t=Object.entries(q).filter(([,o])=>Ke(o));return s.filter(o=>{for(const[i,r]of t){const f=o[i];if(f==null)return!1;if(Array.isArray(r)){const d=String(f);if(!r.some(g=>String(g)===d))return!1;continue}if(r.type==="range"){const d=St(f);if(isNaN(d)||r.min!==""&&r.min!=null&&d<Number(r.min)||r.max!==""&&r.max!=null&&d>Number(r.max))return!1;continue}if(r.type==="durationRange"){const d=xn(f);if(isNaN(d)||r.minSec!==""&&r.minSec!=null&&d<Number(r.minSec)||r.maxSec!==""&&r.maxSec!=null&&d>Number(r.maxSec))return!1;continue}if(r.type==="scoreRange"){const d=St(f);if(isNaN(d))return!1;if(Array.isArray(r.values)&&r.values.length>0){const g=Math.floor(d);if(!r.values.includes(g))return!1;continue}if(r.min!==""&&r.min!=null&&d<Number(r.min)||r.max!==""&&r.max!=null&&d>Number(r.max))return!1;continue}if(r.type==="dateRange"){const d=gn(f);if(!d)return!1;if(r.from){const g=new Date(r.from+"T00:00:00");if(d<g)return!1}if(r.to){const g=new Date(r.to+"T23:59:59");if(d>g)return!1}continue}}return!(e&&!Object.values(o).some(r=>r==null?!1:String(r).toLowerCase().includes(e)))})},[s,q,ee,$]),_e=l.useMemo(()=>J||!Pe?st:[...st].sort((e,t)=>{const o=e[Pe],i=t[Pe];if(o==null)return 1;if(i==null)return-1;if(typeof o=="number"&&typeof i=="number")return Ye==="asc"?o-i:i-o;const r=String(o).toLowerCase(),f=String(i).toLowerCase();return Ye==="asc"?r.localeCompare(f):f.localeCompare(r)}),[st,Pe,Ye,J]),Ae=l.useMemo(()=>{if(ne)return _e;{const e=(Fe-1)*he,t=e+he;return _e.slice(e,t)}},[_e,Fe,he,ne]),mt=l.useCallback((e,t)=>Q?Q(e,t):(e==null?void 0:e.id)??t,[Q]),ve=l.useMemo(()=>new Set(Array.isArray(Y)?Y:[]),[Y]),we=l.useMemo(()=>Ae.map((e,t)=>mt(e,t)),[Ae,mt]),Dt=l.useMemo(()=>we.reduce((e,t)=>ve.has(t)?e+1:e,0),[we,ve]),ot=we.length>0&&Dt===we.length,Qt=Dt>0&&!ot,Zt=l.useCallback(e=>{if(!U)return;const t=new Set(ve);t.has(e)?t.delete(e):t.add(e),U(Array.from(t))},[U,ve]),Vt=l.useCallback(()=>{if(!U)return;const e=new Set(ve);ot?we.forEach(t=>e.delete(t)):we.forEach(t=>e.add(t)),U(Array.from(e))},[U,ve,ot,we]),Rt=({checked:e,indeterminate:t=!1,onToggle:o,ariaLabel:i})=>n.jsx("span",{role:"checkbox","aria-checked":t?"mixed":e,"aria-label":i,tabIndex:0,onClick:r=>{r.stopPropagation(),o()},onKeyDown:r=>{(r.key===" "||r.key==="Enter")&&(r.preventDefault(),r.stopPropagation(),o())},style:{width:16,height:16,borderRadius:5,display:"inline-flex",alignItems:"center",justifyContent:"center",background:e||t?"#0B0B0B":"#FFFFFF",border:`1px solid ${e||t?"#0B0B0B":"#676767"}`,cursor:"pointer",flexShrink:0},children:t?n.jsx(T.Minus,{size:11,color:"#FFFFFF",strokeWidth:3}):e?n.jsx(T.Check,{size:11,color:"#FFFFFF",strokeWidth:3}):null}),it=44,Et=e=>{J&&I?(I(e),y?y(1):ce(1)):(h===e?w(x==="asc"?"desc":"asc"):(m(e),w("asc")),je(1))},en=(e,t)=>{const o=(t||"").split(/\s+/).map(i=>i.trim()).filter(Boolean);M(e,o)},Mt=e=>{ft.current||(typeof D=="function"&&D(e),ft.current=setTimeout(()=>{ft.current=null},3e3))},zt=l.useCallback(e=>{if(typeof window<"u"&&V&&e.length>0&&Z.current)try{localStorage.setItem(V,JSON.stringify(e)),me&&localStorage.setItem(me,"true")}catch(t){console.warn("Failed to save columns to localStorage:",t)}},[V,me]),Bt=250,lt=()=>{Object.values(ue.current).forEach(e=>clearTimeout(e)),ue.current={}},tn=()=>{const e=de.filter(t=>!Ze.has(t));return Qe.forEach(t=>{e.includes(t)||e.push(t)}),se(e)},nn=e=>{if(e===L)return;if(ue.current[e]){clearTimeout(ue.current[e]),delete ue.current[e],Me(o=>{const i=new Set(o);return i.delete(e),i}),ze(o=>{const i=new Set(o);return i.delete(e),i});return}if(de.includes(e)){if(de.length-Ze.size<=1)return;ze(i=>new Set(i).add(e)),ue.current[e]=setTimeout(()=>{Ee(i=>i.filter(r=>r!==e)),ze(i=>{const r=new Set(i);return r.delete(e),r}),delete ue.current[e]},Bt)}else{if(de.length+Qe.size>=G){Mt("Maximum 9 column selection allowed");return}Me(i=>new Set(i).add(e)),ue.current[e]=setTimeout(()=>{Ee(i=>se([...i,e])),Me(i=>{const r=new Set(i);return r.delete(e),r}),delete ue.current[e]},Bt)}},rn=(e,t)=>{de[t]!==L&&dt(t)},sn=()=>{dt(null),et(null)},on=(e,t)=>{e.preventDefault(),fe!==null&&fe!==t&&et(t)},ln=()=>{et(null)},an=(e,t)=>{e.preventDefault(),fe!==null&&fe!==t&&de[t]!==L&&de[fe]!==L&&Ee(o=>{const i=H.arrayMove(o,fe,t);return se(i)}),dt(null),et(null)};l.useEffect(()=>{Ft(e=>{const t=P.filter(r=>e.includes(r)),o=P.filter(r=>!e.includes(r)),i=e.filter(r=>!P.includes(r));return[...t,...o,...i]})},[P]),l.useEffect(()=>{if(typeof window<"u"&&V&&P.length>0&&Z.current)try{const e=se(P);localStorage.setItem(V,JSON.stringify(e)),me&&localStorage.setItem(me,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[P,V,me]),l.useEffect(()=>{ie&&ie(P.filter(e=>e!==L))},[P,ie]),l.useEffect(()=>{if(a.length>0&&P.length===0){if(typeof window<"u"&&b)try{if(localStorage.getItem(`dataTable_manual_change_${b}:${E}`)==="true"){const o=localStorage.getItem(`dataTable_columns_${b}:${E}`);if(o){const i=JSON.parse(o);if(Array.isArray(i)&&i.length>0){const r=i.filter(f=>a.some(d=>(d.id||d.key)===f));if(r.length>0){Z.current=!0,Re(r.slice(0,G));return}}}}}catch(t){console.warn("Failed to load saved columns from localStorage:",t)}const e=a.map(t=>t.id||t.key);Re(se(e.slice(0,G)))}},[a,b,E,se]),l.useEffect(()=>{if(!(typeof window>"u"||!b)&&!(!a||a.length===0)&&Le.current!==E&&(Le.current=E,!Z.current))try{if(!(localStorage.getItem(`dataTable_manual_change_${b}:${E}`)==="true"))return;const t=localStorage.getItem(`dataTable_columns_${b}:${E}`);if(!t)return;const o=JSON.parse(t);if(!Array.isArray(o)||o.length===0)return;const i=o.filter(r=>a.some(f=>(f.id||f.key)===r));i.length>0&&(Z.current=!0,Re(i.slice(0,G)))}catch(e){console.warn("Failed to re-load saved columns after user resolved:",e)}},[E,b,a]);const Ne=l.useMemo(()=>{const e=P.map(t=>a.find(o=>X(o)===t)).filter(Boolean);return se(e.map(X)).map(t=>a.find(o=>X(o)===t)).filter(Boolean)},[a,P]);l.useMemo(()=>Ne.some(e=>e.filterable===!0),[Ne]),l.useEffect(()=>{if(!oe||!Be.current)return;const e=()=>{if(Be.current){const t=Be.current.getBoundingClientRect(),o=217,i=Math.max(8,t.right-o);Ht({top:t.bottom,left:i,width:Math.max(t.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[oe]),l.useEffect(()=>{const e=t=>{oe&&Be.current&&!Be.current.contains(t.target)&&ut.current&&!ut.current.contains(t.target)&&ct(!1)};if(oe)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[oe]),l.useEffect(()=>{oe&&(lt(),Ee(P),Me(new Set),ze(new Set))},[oe,P]),l.useEffect(()=>()=>lt(),[]),P.length===1?(Ot=a.find(e=>(e.id||e.key)===P[0]))!=null&&Ot.label:`${P.length}`;function cn({column:e,isHeaderRow:t=!0}){const o=X(e),i=o===L,r=Ct(o,e.width),[f,d]=l.useState(!1),{attributes:g,listeners:A,setNodeRef:_,transform:qe,transition:We,isDragging:Oe}=H.useSortable({id:o}),un={transform:H.CSS.Transform.toString(qe),transition:We,opacity:Oe?.5:1,width:r,minWidth:r};let Te=!1;if(J&&j.length>0){const C=j[0][0];(C===o||C==="csat_score"&&o==="evaluation.csat_score")&&(Te=!0)}else Te=Pe===o;const fn=Ye==="asc",pn=e.filterable===!0;if(!t)return n.jsx("th",{style:{width:r,minWidth:r,backgroundColor:"var(--primary-foreground)",borderRight:"1px solid #e6e6e6",borderBottom:"1px solid #e6e6e6",boxSizing:"border-box"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:pn?n.jsxs("div",{className:"relative",children:[n.jsx(Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),n.jsx("input",{type:"text",placeholder:"Filter...",value:q[o]||"",onChange:C=>{C.stopPropagation(),en(o,C.target.value)},onKeyDown:C=>C.stopPropagation(),onMouseDown:C=>C.stopPropagation(),className:"w-full pl-7 pr-2 py-1.5 text-xs border border-[var(--border)] rounded text-[var(--text-ink)] placeholder:text-[var(--text-faint)] focus:outline-none focus:border-[var(--border-hover)] focus:ring-1 focus:ring-[var(--focus)] transition-colors",style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)"},autoComplete:"off"})]}):n.jsx("div",{className:"h-[34px]"})});const xt=B===o,at=Ke(q[o]),hn=e.sortable!==!1&&(f||Te),mn=e.filterable!==!1&&!i&&(f||xt||at);return n.jsxs("th",{ref:_,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{...un,padding:"0 12px",height:36,textAlign:i?"center":"left",fontWeight:500,fontSize:"14px",letterSpacing:"normal",textTransform:"none",color:"#0b0b0b",cursor:e.sortable!==!1?"pointer":"default",width:r,...typeof r=="string"&&r.endsWith("px")?{maxWidth:r}:{},borderRight:"1px solid #e6e6e6",boxSizing:"border-box",userSelect:"none",whiteSpace:"nowrap",wordBreak:"normal",overflowWrap:"normal",verticalAlign:"middle",background:f||xt?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!i&&n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:i?"center":"flex-start",position:"relative",minHeight:20,minWidth:0,width:"100%",overflow:"hidden"},children:[!i&&n.jsx("div",{...g,...A,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:f?"visible":"hidden",flexShrink:0},children:n.jsx(T.GripVertical,{size:14})}),n.jsx("span",{onClick:()=>e.sortable!==!1&&Et(o),title:typeof e.label=="string"?e.label:void 0,style:{cursor:e.sortable!==!1?"pointer":"default",flex:i?"none":1,minWidth:0,lineHeight:"20px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),hn&&n.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),Et(o)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Te?"#0b0b0b":"rgba(11, 11, 11, 0.55)",flexShrink:0},children:Te?fn?n.jsx(T.ArrowUp,{size:14,strokeWidth:1.75}):n.jsx(T.ArrowDown,{size:14,strokeWidth:1.75}):n.jsx(T.ArrowUpDown,{size:14,strokeWidth:1.75})}),mn&&n.jsxs("button",{type:"button",ref:C=>{Se.current[o]=C},onClick:C=>{C.stopPropagation(),_t(o,C.currentTarget)},title:"Filter",style:{position:"relative",background:xt||at?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:at?"#0b0b0b":"rgba(11, 11, 11, 0.7)",flexShrink:0},children:[n.jsx(T.ListFilter,{size:14,strokeWidth:1.75}),at&&n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!i&&n.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:1,height:16,background:"#e6e6e6",pointerEvents:"none",zIndex:1}}),!i&&n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||o} column`,title:"Drag to resize column",onMouseDown:C=>Gt(C,e,r),onClick:C=>C.stopPropagation(),onMouseEnter:C=>{C.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const At=kt?a.find(e=>X(e)===kt):null,Nt=({col:e,columnId:t,isSelected:o,draggable:i,isAction:r,actualIndex:f})=>{const d=i&&fe===f,g=i&&qt===f&&fe!==null&&fe!==f;o?Ze.has(t):Qe.has(t);const A=o?!Ze.has(t):Qe.has(t);return n.jsxs("div",{draggable:i,onDragStart:i?_=>rn(_,f):void 0,onDragEnd:i?sn:void 0,onDragOver:i?_=>on(_,f):void 0,onDragLeave:i?ln:void 0,onDrop:i?_=>an(_,f):void 0,onClick:()=>{r||nn(t)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:r?"default":i?"grab":"pointer",opacity:d?.5:1,background:g?"#F2F2F0":"transparent",borderRadius:6},children:[n.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:i?"visible":"hidden",flexShrink:0},children:n.jsx(T.GripVertical,{size:14,strokeWidth:1.75})}),n.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:A?"#0B0B0B":"#FFFFFF",border:`1px solid ${A?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:A&&n.jsx(T.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),n.jsx("span",{style:{flex:1,fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",marginLeft:8},children:e.label})]})},dn=oe?n.jsxs("div",{ref:ut,style:{position:"fixed",top:`${jt.top}px`,left:`${jt.left}px`,width:217,maxHeight:320,zIndex:49,background:"#FFFFFF",border:"1px solid #E6E6E6",borderRadius:10,overflow:"hidden",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)",boxShadow:"0 8px 24px rgba(11, 11, 11, 0.08)"},children:[n.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:12},children:[de.map((e,t)=>{if(e===L)return null;const o=a.find(i=>X(i)===e);return o?n.jsx(l.Fragment,{children:Nt({col:o,columnId:e,isSelected:!0,draggable:!0,isAction:!1,actualIndex:t})},`selected-${e}-${t}`):null}),a.filter(e=>{const t=X(e);return t!==L&&!de.includes(t)}).map(e=>{const t=X(e);return n.jsx(l.Fragment,{children:Nt({col:e,columnId:t,isSelected:!1,draggable:!1,isAction:!1,actualIndex:-1})},`unselected-${t}`)})]}),n.jsxs("div",{style:{flexShrink:0,borderTop:"1px solid #D9D9D9",padding:"8px 12px",background:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"space-between",height:46,boxSizing:"border-box"},children:[n.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const t=Ve.current?[...Ve.current]:a.map(X).slice(0,G),o=se(t);if(Z.current=!1,lt(),Ee(o),Re(o),Me(new Set),ze(new Set),typeof window<"u"&&V)try{localStorage.removeItem(V)}catch{}},style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"}),n.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),lt();const t=tn();Ee(t),Me(new Set),ze(new Set),Z.current=!0,Re(t),zt(t),ct(!1)},style:{background:"#2E3236",color:"#FFFFFF",border:"none",borderRadius:10,height:28,padding:"0 14px",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,cursor:"pointer"},children:"Apply"})]})]}):null,He=B?a.find(e=>X(e)===B):null,Wt=He?n.jsx(jn,{column:He,columnId:B,filterType:te(B),position:Je,popoverRef:be,distinctValues:Ce(B),initialValue:q[B],onSearch:typeof He.onFilterSearch=="function"?He.onFilterSearch:null,searchMinChars:He.filterSearchMinChars??3,onApply:e=>{M(B,e),ge(null)},onCancel:()=>ge(null)},B):null;return n.jsxs("div",{className:"w-full",children:[Wt&&bt.createPortal(Wt,document.body),a.length>0&&(O||!pe)&&n.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:16,flexWrap:"wrap"},children:[O&&n.jsx("div",{style:{marginRight:"auto"},children:n.jsx(It,{dateRangePicker:O.dateRangePicker,onWeekToDate:O.onWeekToDate,exportConfig:O.exportConfig,filterChipsConfig:O.filterChipsConfig,trailingActions:O.trailingActions})}),(O==null?void 0:O.rightActions)&&n.jsx("div",{style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:O.rightActions}),!pe&&n.jsxs("div",{style:{position:"relative"},children:[n.jsxs("button",{ref:Be,type:"button",onClick:()=>ct(!oe),style:{display:"inline-flex",alignItems:"center",gap:10,height:32,padding:"0 16px",background:"#FFFFFF",border:"1px solid #D9D9D9",borderRadius:10,cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:600,color:"#2E3236",whiteSpace:"nowrap"},children:[n.jsx(T.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),oe&&bt.createPortal(dn,document.body)]})]})}),Object.keys(q).length>0&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(q).map(([e,t])=>{const o=a.find(d=>X(d)===e);if(!o||!Ke(t))return null;const i=bn(t),r=Sn(t),f=vn(t);return n.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,height:28,padding:"0 12px",borderRadius:20,border:"1px solid #B2B2B0",background:"#F2F2F0",fontFamily:"var(--font-sans)",fontSize:14,lineHeight:"20px",color:"#0B0B0B",whiteSpace:"nowrap"},children:[n.jsxs("span",{children:[n.jsxs("span",{style:{color:"#676767"},children:[o.label,": "]}),n.jsx("span",{children:i})]}),r>0&&n.jsx(wn,{count:r,values:f}),n.jsx("button",{type:"button",onClick:()=>M(e,[]),"aria-label":`Remove ${o.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:n.jsx(T.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),n.jsx("button",{type:"button",onClick:ye,style:{marginLeft:"auto",background:"transparent",border:"none",padding:"0 4px",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:14,fontWeight:500,color:"#323232"},children:"Reset"})]}),a.length>0&&Ne.length>0?n.jsxs(H.DndContext,{sensors:Xt,collisionDetection:H.closestCenter,onDragStart:Yt,onDragEnd:Jt,children:[n.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem",...W?{minHeight:320}:{}},children:[W&&n.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(2px)",zIndex:20,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"14px"},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[n.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),n.jsx(Cn,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),n.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:Ut,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:n.jsxs("table",{style:{width:"auto",minWidth:"100%",tableLayout:"fixed",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)",border:"1px solid #e6e6e6",boxSizing:"border-box"},children:[n.jsx("thead",{children:n.jsxs("tr",{children:[K&&n.jsx("th",{style:{width:it,minWidth:it,padding:"10px 8px",textAlign:"center",verticalAlign:"middle",background:"#f2f2f0",borderRight:"1px solid #e6e6e6",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,boxSizing:"border-box"},children:n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",lineHeight:0},children:n.jsx(Rt,{checked:ot,indeterminate:Qt,onToggle:Vt,ariaLabel:"Select all rows on this page"})})}),n.jsx(H.SortableContext,{items:P,strategy:H.horizontalListSortingStrategy,children:Ne.map(e=>n.jsx(cn,{column:e,isHeaderRow:!0},`header-${X(e)}`))})]})}),n.jsx("tbody",{children:!W&&Ae.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:Ne.length+(K?1:0),style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!W&&Ae.length>0?Ae.map((e,t)=>{const o=mt(e,t),i=K&&ve.has(o);return n.jsxs("tr",{"data-row-id":e.id||t,style:{borderBottom:"1px solid #e6e6e6",cursor:p?"pointer":"default",transition:"background 0.15s ease",background:i?"#F2F4F7":"transparent"},onClick:p?r=>{r.stopPropagation(),p(e,t)}:void 0,onMouseEnter:r=>{r.currentTarget.style.background="#E6E6E6"},onMouseLeave:r=>{r.currentTarget.style.background=i?"#F2F4F7":"transparent"},children:[K&&n.jsx("td",{onClick:r=>r.stopPropagation(),style:{width:it,minWidth:it,padding:"10px 8px",textAlign:"center",verticalAlign:"middle",borderRight:"1px solid #e6e6e6",boxSizing:"border-box"},children:n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",lineHeight:0},children:n.jsx(Rt,{checked:i,onToggle:()=>Zt(o),ariaLabel:"Select row"})})}),Ne.map(r=>{const f=X(r),d=Ct(f,r.width),g=e[f],A=r.render?r.render(g,e):g,_=d&&d!=="auto",qe=typeof A=="string"&&A.trim()!=="",We=_&&qe,Oe=We?n.jsx(le,{content:A,children:A}):A;return n.jsx("td",{style:{padding:"10px 14px",color:"rgba(30, 33, 37, 0.78)",fontSize:"13px",borderRight:"1px solid #e6e6e6",boxSizing:"border-box",width:d,fontFamily:"var(--font-sans)",...We&&{maxWidth:d||"200px"}},children:Oe},f)})]},t)}):null})]})})]}),n.jsx(H.DragOverlay,{children:At?n.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(T.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),n.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:At.label})]})}):null})]}):null,(()=>{const e=!$&&(ee.trim()!==""||Object.values(q).some(o=>Ke(o))),t=ne?e?_e.length:v:_e.length;return t<=0?null:n.jsx(Pt.Pagination,{page:Fe,pageSizeOptions:[5,10,20,50,100],pageSize:he,totalCount:t,currentDataLength:Ae.length,onPageChange:je,onPageSizeChange:o=>{Ge(o),je(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=Rn;exports.DataTableFilters=It;
2
2
  //# sourceMappingURL=DataTable2.cjs.js.map