chordia-ui 3.8.4 → 3.8.5

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.
Files changed (30) hide show
  1. package/dist/DataTable2.cjs.js +1 -1
  2. package/dist/DataTable2.cjs.js.map +1 -1
  3. package/dist/DataTable2.es.js +520 -516
  4. package/dist/DataTable2.es.js.map +1 -1
  5. package/dist/Toast.cjs.js +2 -2
  6. package/dist/Toast.cjs.js.map +1 -1
  7. package/dist/Toast.es.js +41 -41
  8. package/dist/Toast.es.js.map +1 -1
  9. package/dist/components/UpdatedInteractionDetails.cjs.js +4 -4
  10. package/dist/components/UpdatedInteractionDetails.cjs.js.map +1 -1
  11. package/dist/components/UpdatedInteractionDetails.es.js +1285 -935
  12. package/dist/components/UpdatedInteractionDetails.es.js.map +1 -1
  13. package/dist/components/navigation.cjs.js +1 -1
  14. package/dist/components/navigation.cjs.js.map +1 -1
  15. package/dist/components/navigation.es.js +59 -57
  16. package/dist/components/navigation.es.js.map +1 -1
  17. package/dist/components/reports.cjs.js +2 -2
  18. package/dist/components/reports.cjs.js.map +1 -1
  19. package/dist/components/reports.es.js +2 -1
  20. package/dist/components/reports.es.js.map +1 -1
  21. package/package.json +1 -1
  22. package/src/components/UpdatedInteractionDetails/UpdatedCoachingSynthesisCard.jsx +33 -2
  23. package/src/components/UpdatedInteractionDetails/UpdatedGuidance.jsx +450 -87
  24. package/src/components/UpdatedInteractionDetails/UpdatedInteractionContext.jsx +45 -10
  25. package/src/components/UpdatedInteractionDetails/UpdatedInteractionDetails.jsx +23 -7
  26. package/src/components/common/AskCompass.jsx +5 -2
  27. package/src/components/data/DataTable2.jsx +34 -28
  28. package/src/components/navigation/Sidebar.jsx +3 -1
  29. package/src/components/reports/ReportsDetails.jsx +1 -1
  30. package/src/components/reports/ReportsList.jsx +1 -0
@@ -1,2 +1,2 @@
1
- "use strict";const t=require("react/jsx-runtime"),i=require("react"),T=require("./sortable.esm.cjs.js"),W=require("lucide-react"),Ve=require("react-dom"),wt=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./TourGuideTooltip.cjs.js");function Ft({dateRangePicker:r,onWeekToDate:l,exportConfig:d,filterChipsConfig:f,trailingActions:v}){const[y,c]=i.useState(!1),g=i.useRef(null),E=i.useRef(null);i.useEffect(()=>{const S=F=>{E.current&&!E.current.contains(F.target)&&g.current&&!g.current.contains(F.target)&&c(!1)};if(y)return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[y]);const w=()=>{c(S=>!S)},j=S=>{c(!1),d!=null&&d.onExport&&d.onExport(S)},M=(()=>{if(!(f!=null&&f.filters))return!1;const S=f.filters,F=f.customFilters||[],G=Object.entries(S).some(([C,$])=>!!(Array.isArray($)&&$.length||typeof $=="string"&&$.trim()!==""||$&&typeof $=="object"&&($.min!=null||$.max!=null))),L=F.some(C=>C.active);return G||L})();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(W.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),r&&t.jsx(i.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(W.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:r}),d&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:g,onClick:w,disabled:d.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(W.Download,{size:16}),t.jsx("span",{children:d.isExporting?"Exporting...":"Export"})]}),t.jsx(W.ChevronDown,{size:16})]}),y&&t.jsx("div",{ref:E,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:(d.types||["csv"]).map(S=>t.jsxs("button",{onClick:()=>j(S),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 ",S.toUpperCase()]},S))})]}),(M||v)&&t.jsxs(t.Fragment,{children:[M&&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:[M&&f&&t.jsx(wt.CustomFilterChips,{filters:f.filters,onChange:f.onChange,onClear:f.onClear,customFilters:f.customFilters||[],fieldOptions:f.fieldOptions||{}}),v&&t.jsx("div",{className:"flex-shrink-0",children:v})]})]})]})}function et(r){if(r==null)return NaN;const l=String(r).replace(/[,$%]|pp/gi,"").trim(),d=parseFloat(l);return Number.isFinite(d)?d:NaN}function Jt(r){if(r==null)return NaN;const l=String(r).trim(),d=l.match(/^(\d+):(\d+)(?::(\d+))?$/);if(d){const w=+d[1],j=+d[2],N=d[3]!=null?+d[3]:null;return N!=null?w*3600+j*60+N:w*60+j}let f=0,v=!1;const y=l.match(/(\d+)\s*d\b/i),c=l.match(/(\d+)\s*h\b/i),g=l.match(/(\d+)\s*m(?!s)\b/i),E=l.match(/(\d+)\s*s\b/i);return y&&(f+=+y[1]*86400,v=!0),c&&(f+=+c[1]*3600,v=!0),g&&(f+=+g[1]*60,v=!0),E&&(f+=+E[1],v=!0),v?f:NaN}function Yt(r){if(!r)return null;const l=String(r).trim(),d=l.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(d){const v=d[3].length===2?2e3+ +d[3]:+d[3],y=new Date(v,+d[1]-1,+d[2]);return isNaN(y.getTime())?null:y}const f=new Date(l);return isNaN(f.getTime())?null:f}function Qt(r){if(!r||r.length===0)return"text";const l=r.slice(0,25),d=f=>l.every(f);return d(f=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(f)||/^\d{4}-\d{2}-\d{2}/.test(f))?"date":d(f=>/^\d+\s*[dhms]\b/i.test(f)||/^\d+:\d+(:\d+)?$/.test(f))?"duration":d(f=>/^-?[\d,.]+(%|pp)?$/i.test(f))?"number":"text"}function Ce(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 bt(r){if(r==null||r===""||isNaN(r))return"";const l=Number(r),d=Math.floor(l/3600),f=Math.floor(l%3600/60),v=Math.floor(l%60);return d>0?`${d}h ${f}m`:f>0?`${f}m ${v}s`:`${v}s`}function Zt(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,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}if(r.type==="durationRange"){const l=r.minSec!==""&&r.minSec!=null?bt(r.minSec):null,d=r.maxSec!==""&&r.maxSec!=null?bt(r.maxSec):null;return l&&d?`${l} – ${d}`:l?`≥ ${l}`:d?`≤ ${d}`:""}if(r.type==="scoreRange"){if(Array.isArray(r.values)&&r.values.length>0)return r.values.slice().sort((f,v)=>f-v).join(", ");const l=r.min!==""&&r.min!=null?r.min:null,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}return r.type==="dateRange"?r.from&&r.to?`${r.from} – ${r.to}`:r.from?`from ${r.from}`:r.to?`to ${r.to}`:"":""}function Vt(r){return Array.isArray(r)?Math.max(0,r.length-1):0}function en(r){return Array.isArray(r)?r.slice(1).map(String).join(", "):""}function tn({count:r,values:l}){const[d,f]=i.useState(!1);return t.jsxs("span",{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!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,d&&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 nn({leftLabel:r,rightLabel:l,leftValue:d,rightValue:f,onLeftChange:v,onRightChange:y,type:c="number",placeholderLeft:g="Min",placeholderRight:E="Max"}){const w={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"},j={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:j,children:r}),t.jsx("input",{type:c,value:d,onChange:N=>v(N.target.value),placeholder:g,style:w})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:l}),t.jsx("input",{type:c,value:f,onChange:N=>y(N.target.value),placeholder:E,style:w})]})]})}const St=[{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 vt(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 d=Number(r);return Number.isFinite(d)?d:null}function Qe({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 Ze({minValue:r,maxValue:l,onMinChange:d,onMaxChange:f,inputType:v="number",inputMode:y="decimal",step:c,placeholder:g="0.0",unit:E}){const w={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:v,inputMode:y,step:c,placeholder:g,value:r,onChange:j=>d(j.target.value),style:w})]}),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:v,inputMode:y,step:c,placeholder:g,value:l,onChange:j=>f(j.target.value),style:w})]})]}),E&&t.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Input values in ",E==="sec"?"seconds":E]})]})}function rn({column:r,columnId:l,filterType:d="text",position:f,popoverRef:v,distinctValues:y,initialValue:c,onApply:g,onCancel:E}){const w=d==="text",j=d==="number",N=d==="date",M=d==="duration",S=d==="score",F=i.useMemo(()=>{if(!S||!Array.isArray(y)||y.length===0)return!1;let m=1/0,h=-1/0;for(const x of y){const O=et(x);Number.isFinite(O)&&(O<m&&(m=O),O>h&&(h=O))}return Number.isFinite(m)&&Number.isFinite(h)&&m>=0&&h<=5},[S,y]),[G,L]=i.useState(()=>w?new Set(Array.isArray(c)?c:[]):new Set),[C,$]=i.useState(""),[oe,se]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.min!=null?c.min:""),[D,Z]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.max!=null?c.max:""),[U,A]=i.useState(new Set),[q,ce]=i.useState(()=>M&&(c==null?void 0:c.type)==="durationRange"&&c.minSec!=null&&c.minSec!==""?String(c.minSec):""),[J,ie]=i.useState(()=>M&&(c==null?void 0:c.type)==="durationRange"&&c.maxSec!=null&&c.maxSec!==""?String(c.maxSec):""),[Y,V]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[K,de]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[ye,X]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[z,ee]=i.useState(()=>N&&(c==null?void 0:c.type)==="dateRange"&&c.from||""),[Q,ae]=i.useState(()=>N&&(c==null?void 0:c.type)==="dateRange"&&c.to||"");i.useEffect(()=>{w&&L(new Set(Array.isArray(c)?c:[]))},[l,w]);const _=i.useMemo(()=>{const m=C.trim().toLowerCase();return m?y.filter(h=>String(h).toLowerCase().includes(m)):y},[y,C]),pe=m=>{L(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},be=()=>{w&&L(new Set),j&&(se(""),Z("")),M&&(A(new Set),ce(""),ie("")),S&&(V(new Set),de(""),X("")),N&&(ee(""),ae("")),$("")},De=m=>{A(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},R=m=>{V(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})},fe=()=>{if(w)return g(Array.from(G));if(j)return g({type:"range",min:oe===""?"":Number(oe),max:D===""?"":Number(D)});if(M){const m=vt(q),h=vt(J),x=m!=null||h!=null;let O="",ue="";if(x)O=m??"",ue=h??"";else if(U.size>0){const Se=St.filter(te=>U.has(te.id));O=Math.min(...Se.map(te=>te.minSec)),ue=Se.some(te=>te.maxSec==null)?"":Math.max(...Se.map(te=>te.maxSec))}return g({type:"durationRange",minSec:O,maxSec:ue})}if(S){const m=K===""?null:Number(K),h=ye===""?null:Number(ye);return m!=null||h!=null?g({type:"scoreRange",values:[],min:m!=null&&Number.isFinite(m)?m:"",max:h!=null&&Number.isFinite(h)?h:""}):g({type:"scoreRange",values:Array.from(Y).sort((O,ue)=>O-ue),min:"",max:""})}if(N)return g({type:"dateRange",from:z,to:Q})};return t.jsxs("div",{ref:v,role:"dialog","aria-label":`Filter ${r.label||l}`,style:{position:"fixed",top:f.top,left:f.left,zIndex:50,width:w?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:[w&&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(W.Search,{size:16,color:"#989898",strokeWidth:2}),t.jsx("input",{autoFocus:!0,type:"text",value:C,onChange:m=>$(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:_.length===0?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):_.map(m=>{const h=G.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(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("input",{type:"checkbox",checked:h,onChange:()=>pe(m),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),t.jsx("span",{onClick:x=>{x.preventDefault(),pe(m)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]},m)})})]}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Filter"}),t.jsx(Ze,{minValue:oe,maxValue:D,onMinChange:se,onMaxChange:Z})]}),M&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Duration"}),r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:St.map(m=>{const h=U.has(m.id);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>De(m.id),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),De(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(W.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(Ze,{minValue:q,maxValue:J,onMinChange:ce,onMaxChange:ie,inputType:"number",inputMode:"numeric",placeholder:"0",unit:"sec"})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{children:r.label||"Score"}),F&&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=Y.has(m);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>R(m),onKeyDown:x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),R(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(W.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"}})]}),F&&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(Ze,{minValue:K,maxValue:ye,onMinChange:de,onMaxChange:X,step:"0.1"})]}),N&&t.jsx(nn,{leftLabel:"From",rightLabel:"To",leftValue:z,rightValue:Q,onLeftChange:ee,onRightChange:ae,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:be,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:M&&r.filterShowPresets===!0||S&&F&&r.filterShowPresets===!0?"View All":"Reset"}),t.jsx("button",{type:"button",onClick:fe,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 on=()=>({userData:{email:"anonymous"}}),sn=r=>t.jsx("img",{...r});function an({children:r,content:l,direction:d="top",align:f="center",styling:v,indicatorColor:y}){const c=typeof l=="string"?l:l!=null?String(l):"",g=typeof y=="string"&&(y.startsWith("#")||y.startsWith("rgb")||y.startsWith("hsl")||y.startsWith("var("))?y:"var(--Grey-Strong, #2E3236)",[E,w]=i.useState(!1),[j,N]=i.useState(!1),[M,S]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),F=i.useRef(null),G=i.useRef(null);if(!c)return r;i.useEffect(()=>{N(!0)},[]);const L=i.useCallback(()=>{if(!F.current||!G.current||typeof window>"u")return;const C=F.current.getBoundingClientRect(),$=G.current.getBoundingClientRect(),oe=window.innerWidth,se=window.innerHeight,D=8,Z=10,U=$.width,A=$.height,q=C.top,ce=se-C.bottom,J=d==="bottom"?"bottom":"top";let ie=J;J==="top"&&q<A+Z+D&&ce>q?ie="bottom":J==="bottom"&&ce<A+Z+D&&q>ce&&(ie="top");let Y=C.left+C.width/2;f==="start"&&(Y=C.left),f==="end"&&(Y=C.right);let V=ie==="top"?C.top-A-Z:C.bottom+Z,K=f==="start"?Y:f==="end"?Y-U:Y-U/2;V=Math.max(D,Math.min(V,se-A-D)),K=Math.max(D,Math.min(K,oe-U-D));const de=Math.max(10,Math.min(Y-K,U-10));S({top:V,left:K,arrowLeft:de,placement:ie})},[f,d]);return i.useEffect(()=>{if(!E||!j)return;L();const C=()=>L();return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[E,j,L]),t.jsxs("span",{ref:F,style:{display:"block",width:"100%"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:[r,E&&j&&Ve.createPortal(t.jsxs("span",{ref:G,style:{position:"fixed",top:`${M.top}px`,left:`${M.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,t.jsx("span",{style:{position:"absolute",left:`${M.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...M.placement==="top"?{top:"100%",borderTop:`7px solid ${g}`}:{bottom:"100%",borderBottom:`7px solid ${g}`}}})]}),document.body)]})}function ln({data:r=[],columns:l=[],initialPageSize:d=10,onRowClick:f,totalCount:v=null,page:y=null,pageSize:c=null,onPageChange:g=null,onPageSizeChange:E=null,onFilterChange:w=null,columnFilters:j=null,onMaxColumnsError:N=null,onSort:M=null,sortFields:S=[],tableId:F=null,isLoading:G=!1,filtersConfig:L=null,columnResizeMinWidth:C=120,columnResizeMaxWidth:$=280,onVisibleColumnsChange:oe=null}){var yt;const{userData:se}=on(),D=(se==null?void 0:se.email)||"anonymous",Z=i.memo(({children:e,content:n,className:o=""})=>{const a=i.useRef(null),[s,p]=i.useState(!1);i.useEffect(()=>{const b=()=>{if(a.current){const P=a.current.scrollWidth>a.current.clientWidth;p(P)}};b();const I=setTimeout(b,0);return window.addEventListener("resize",b),()=>{clearTimeout(I),window.removeEventListener("resize",b)}},[e,n]);const u=t.jsx("span",{className:`truncate block ${o}`,ref:a,children:e});return s&&n?t.jsx(an,{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:u}):u});Z.displayName="TruncatedCell";const U=v!==null&&g!==null,A=w!==null,q=M!==null,[ce,J]=i.useState(1),[ie,Y]=i.useState(d),V=y!==null?y:ce,K=c!==null?c:ie,de=e=>{g?g(e):J(e)},ye=e=>{E?E(e):Y(e)},X=50,z="action",ee=i.useRef(!1),Q=i.useMemo(()=>F?`dataTable_columns_${F}:${D}`:`dataTable_columns_${l.map(n=>n.id||n.key).sort().join("_")}:${D}`,[F,l,D]),ae=i.useMemo(()=>F?`dataTable_manual_change_${F}:${D}`:null,[F,D]);i.useCallback((e,n)=>{if(typeof window>"u"||!e||!n||n.length===0)return null;try{const o=localStorage.getItem(e);if(o){const s=JSON.parse(o).filter(p=>n.some(u=>(u.id||u.key)===p));if(s.length>0)return s}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}return null},[]);const[_,pe]=i.useState({}),[be,De]=i.useState(""),[R,fe]=i.useState(null),[m,h]=i.useState({top:0,left:0}),x=i.useRef(null),O=i.useRef({}),[ue,Se]=i.useState(null),[Oe,te]=i.useState("asc"),Te=i.useCallback((e,n)=>{const o=Ce(n);pe(a=>{const s={...a};return o?s[e]=n:delete s[e],s}),g?g(1):J(1),A&&w&&w(o?{..._,[e]:n}:Object.fromEntries(Object.entries(_).filter(([a])=>a!==e)))},[_,w,A,g]),jt=i.useCallback(()=>{pe({}),De(""),g?g(1):J(1),A&&w&&w({})},[w,A,g]),_e=i.useCallback(e=>{if(!r||r.length===0)return[];const n=new Set,o=[];for(const a of r){const s=a[e];if(s==null)continue;const p=typeof s=="object"?JSON.stringify(s):String(s);n.has(p)||(n.add(p),o.push(p))}return o.sort((a,s)=>a.localeCompare(s))},[r]),kt=i.useCallback(e=>{const n=l.find(o=>H(o)===e);return n&&n.filterType?n.filterType:Qt(_e(e))},[l,_e]),Re=i.useCallback(e=>{const a=typeof window<"u"?window.innerWidth:1/0;let s=e.left;return s+280>a-8&&(s=Math.max(8,e.right-280)),{top:e.bottom+6,left:s}},[]),Ct=i.useCallback((e,n)=>{if(!n){fe(e);return}const o=n.getBoundingClientRect();h(Re(o)),fe(a=>a===e?null:e)},[Re]);i.useEffect(()=>{if(!R)return;const e=n=>{if(x.current&&x.current.contains(n.target))return;const o=O.current[R];o&&o.contains(n.target)||fe(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[R]),i.useEffect(()=>{if(!R)return;const e=()=>{const n=O.current[R];if(!n)return;const o=n.getBoundingClientRect();h(Re(o))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[R,Re]),i.useLayoutEffect(()=>{if(!R)return;const e=x.current,n=O.current[R];if(!e||!n)return;const o=e.offsetWidth,a=n.getBoundingClientRect(),s=8,p=typeof window<"u"?window.innerWidth:1/0;if(!(a.left+o>p-s))return;const b=Math.max(s,a.right-o);h(I=>I.left===b?I:{...I,left:b})},[R,m.top]);const tt=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim()!=="":!0)),[]),nt=i.useCallback((e,n)=>{const o=Object.keys(e||{}),a=Object.keys(n||{});return o.length!==a.length?!1:o.every(s=>e[s]===n[s])},[]);i.useEffect(()=>{if(!A||j===null)return;const e=tt(j);pe(n=>nt(n,e)?n:e)},[A,j,tt,nt]),i.useCallback((e,n)=>e==="csat_score"&&n==="evaluation.csat_score"?n:e,[]);const ve=q&&S.length>0?S[0][0]:ue,Ee=q&&S.length>0?S[0][1]:Oe,[cn,rt]=i.useState(()=>l.map(e=>e.id||e.key)),ne=i.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 a=l.map(u=>u.id||u.key).includes(z);return!n.includes(z)&&a&&(n.length>=X?n=[...n.slice(0,X-1),z]:n=[...n,z]),[...n.filter(u=>u!==z),z]},[l]),[B,we]=i.useState(()=>{if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const a=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(a){const s=JSON.parse(a);if(Array.isArray(s)&&s.length>0){ee.current=!0;const p=s.filter(u=>l.some(b=>(b.id||b.key)===u));if(p.length>0)return p.slice(0,X)}}}}catch(o){console.warn("Failed to load saved columns from localStorage:",o)}const n=l.map(o=>o.id||o.key).slice(0,X);return ne(n)}),[re,He]=i.useState(!1),[me,Me]=i.useState([]),[ot,Dt]=i.useState({top:0,left:0,width:0}),[st,it]=i.useState(new Set),[at,lt]=i.useState(new Set),ze=i.useRef(null);ze.current===null&&(ze.current=[...B]);const[le,qe]=i.useState(null),[Rt,Be]=i.useState(null),he=i.useRef(null),Ke=i.useRef(null),Xe=i.useRef(null),[ct,Ge]=i.useState(null),[Ue,Et]=i.useState({}),Mt=i.useRef(null),Ne=i.useRef(null),H=e=>e.id||e.key,We=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=e.trim();if(n.endsWith("px")){const a=parseFloat(n);return Number.isFinite(a)?a:null}const o=parseFloat(n);return Number.isFinite(o)&&`${o}`===n?o:null}return null},[]),dt=i.useCallback((e,n)=>Ue[e]!=null?`${Ue[e]}px`:typeof n=="number"?`${n}px`:n||"auto",[Ue]),$e=i.useCallback(e=>{if(!Ne.current)return;const{columnId:n,startX:o,startWidth:a,minWidth:s,maxWidth:p}=Ne.current,u=e.clientX-o,b=Math.round(a+u),I=Math.min(p,Math.max(s,b));Et(P=>({...P,[n]:I}))},[]),Fe=i.useCallback(()=>{Ne.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",Fe)},[$e]),zt=i.useCallback((e,n,o)=>{var Pe;e.preventDefault(),e.stopPropagation();const a=n.id||n.key,s=We(n.minWidth)??C,p=We(n.maxWidth)??$,u=Math.min(s,p),b=Math.max(s,p),I=((Pe=e.currentTarget.closest("th"))==null?void 0:Pe.getBoundingClientRect().width)||0,P=We(o),ke=P??Math.max(u,Math.round(I)||u),Je=Math.min(b,Math.max(u,ke));Ne.current={columnId:a,startX:e.clientX,startWidth:Je,minWidth:u,maxWidth:b},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",Fe)},[$,C,$e,Fe,We]);i.useEffect(()=>()=>Fe(),[Fe]);const Bt=T.useSensors(T.useSensor(T.PointerSensor),T.useSensor(T.KeyboardSensor,{coordinateGetter:T.sortableKeyboardCoordinates})),Nt=e=>{const{active:n,over:o}=e;if(o&&n.id!==o.id){if(n.id===z||o.id===z){ft("Cannot drop columns on the Action column"),Ge(null);return}ee.current=!0,we(a=>{const s=a.indexOf(n.id),p=a.indexOf(o.id);if(s!==-1&&p!==-1){const u=T.arrayMove(a,s,p),b=ne(u);return pt(b),b}return a}),rt(a=>{const s=a.indexOf(n.id),p=a.indexOf(o.id);return T.arrayMove(a,s,p)})}Ge(null)},Wt=e=>{Ge(e.active.id)},Ae=i.useMemo(()=>{if(A)return r||[];if(!r||r.length===0)return[];const e=be.trim().toLowerCase(),n=Object.entries(_).filter(([,o])=>Ce(o));return r.filter(o=>{for(const[a,s]of n){const p=o[a];if(p==null)return!1;if(Array.isArray(s)){const u=String(p);if(!s.some(b=>String(b)===u))return!1;continue}if(s.type==="range"){const u=et(p);if(isNaN(u)||s.min!==""&&s.min!=null&&u<Number(s.min)||s.max!==""&&s.max!=null&&u>Number(s.max))return!1;continue}if(s.type==="durationRange"){const u=Jt(p);if(isNaN(u)||s.minSec!==""&&s.minSec!=null&&u<Number(s.minSec)||s.maxSec!==""&&s.maxSec!=null&&u>Number(s.maxSec))return!1;continue}if(s.type==="scoreRange"){const u=et(p);if(isNaN(u))return!1;if(Array.isArray(s.values)&&s.values.length>0){const b=Math.floor(u);if(!s.values.includes(b))return!1;continue}if(s.min!==""&&s.min!=null&&u<Number(s.min)||s.max!==""&&s.max!=null&&u>Number(s.max))return!1;continue}if(s.type==="dateRange"){const u=Yt(p);if(!u)return!1;if(s.from){const b=new Date(s.from+"T00:00:00");if(u<b)return!1}if(s.to){const b=new Date(s.to+"T23:59:59");if(u>b)return!1}continue}}return!(e&&!Object.values(o).some(s=>s==null?!1:String(s).toLowerCase().includes(e)))})},[r,_,be,A]),je=i.useMemo(()=>q||!ve?Ae:[...Ae].sort((e,n)=>{const o=e[ve],a=n[ve];if(o==null)return 1;if(a==null)return-1;if(typeof o=="number"&&typeof a=="number")return Ee==="asc"?o-a:a-o;const s=String(o).toLowerCase(),p=String(a).toLowerCase();return Ee==="asc"?s.localeCompare(p):p.localeCompare(s)}),[Ae,ve,Ee,q]),Ie=i.useMemo(()=>{if(U)return je;{const e=(V-1)*K,n=e+K;return je.slice(e,n)}},[je,V,K,U]),ut=e=>{q&&M?(M(e),g?g(1):J(1)):(ue===e?te(Oe==="asc"?"desc":"asc"):(Se(e),te("asc")),de(1))},$t=(e,n)=>{const o=(n||"").split(/\s+/).map(a=>a.trim()).filter(Boolean);Te(e,o)},ft=e=>{Xe.current||(typeof N=="function"&&N(e),Xe.current=setTimeout(()=>{Xe.current=null},3e3))},pt=i.useCallback(e=>{if(typeof window<"u"&&Q&&e.length>0&&ee.current)try{localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(n){console.warn("Failed to save columns to localStorage:",n)}},[Q,ae]),At=e=>{e!==z&&Me(n=>n.includes(e)?n.length===1?n:n.filter(o=>o!==e):n.length>=X?(ft("Maximum 9 column selection allowed"),n):ne([...n,e]))},It=(e,n)=>{me[n]!==z&&qe(n)},Pt=()=>{qe(null),Be(null)},Lt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&Be(n)},Ot=()=>{Be(null)},Tt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&me[n]!==z&&me[le]!==z&&Me(o=>{const a=T.arrayMove(o,le,n);return ne(a)}),qe(null),Be(null)};i.useEffect(()=>{rt(e=>{const n=B.filter(s=>e.includes(s)),o=B.filter(s=>!e.includes(s)),a=e.filter(s=>!B.includes(s));return[...n,...o,...a]})},[B]),i.useEffect(()=>{if(typeof window<"u"&&Q&&B.length>0&&ee.current)try{const e=ne(B);localStorage.setItem(Q,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[B,Q,ae]),i.useEffect(()=>{oe&&oe(B.filter(e=>e!==z))},[B,oe]),i.useEffect(()=>{if(l.length>0&&B.length===0){if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${D}`)==="true"){const o=localStorage.getItem(`dataTable_columns_${F}:${D}`);if(o){const a=JSON.parse(o);if(Array.isArray(a)&&a.length>0){const s=a.filter(p=>l.some(u=>(u.id||u.key)===p));if(s.length>0){ee.current=!0,we(s.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);we(ne(e.slice(0,X)))}},[l,F,D,ne]);const xe=i.useMemo(()=>{const e=B.map(n=>l.find(o=>H(o)===n)).filter(Boolean);return ne(e.map(H)).map(n=>l.find(o=>H(o)===n)).filter(Boolean)},[l,B]);i.useMemo(()=>xe.some(e=>e.filterable===!0),[xe]),i.useEffect(()=>{if(!re||!he.current)return;const e=()=>{if(he.current){const n=he.current.getBoundingClientRect(),o=217,a=Math.max(8,n.right-o);Dt({top:n.bottom,left:a,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)}},[re]),i.useEffect(()=>{const e=n=>{re&&he.current&&!he.current.contains(n.target)&&Ke.current&&!Ke.current.contains(n.target)&&He(!1)};if(re)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[re]),i.useEffect(()=>{re&&(Me(B),it(new Set),lt(new Set))},[re,B]),B.length===1?(yt=l.find(e=>(e.id||e.key)===B[0]))!=null&&yt.label:`${B.length}`;function _t({column:e,isHeaderRow:n=!0}){const o=H(e),a=o===z,s=dt(o,e.width),[p,u]=i.useState(!1),{attributes:b,listeners:I,setNodeRef:P,transform:ke,transition:Je,isDragging:Pe}=T.useSortable({id:o}),qt={transform:T.CSS.Transform.toString(ke),transition:Je,opacity:Pe?.5:1,width:s,minWidth:s};let ge=!1;if(q&&S.length>0){const k=S[0][0];(k===o||k==="csat_score"&&o==="evaluation.csat_score")&&(ge=!0)}else ge=ve===o;const Kt=Ee==="asc",Xt=e.filterable===!0;if(!n)return t.jsx("th",{style:{width:s,minWidth:s,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:Xt?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:_[o]||"",onChange:k=>{k.stopPropagation(),$t(o,k.target.value)},onKeyDown:k=>k.stopPropagation(),onMouseDown:k=>k.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 Ye=R===o,Le=Ce(_[o]),Gt=e.sortable!==!1&&(p||ge),Ut=e.filterable!==!1&&!a&&(p||Ye||Le);return t.jsxs("th",{ref:P,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...qt,padding:"0 12px",height:36,textAlign:a?"center":"left",fontWeight:500,fontSize:"14px",letterSpacing:"normal",textTransform:"none",color:"#0b0b0b",cursor:e.sortable!==!1?"pointer":"default",width:s,...typeof s=="string"&&s.endsWith("px")?{maxWidth:s}:{},borderRight:"1px solid #e6e6e6",boxSizing:"border-box",userSelect:"none",whiteSpace:"nowrap",wordBreak:"normal",overflowWrap:"normal",verticalAlign:"middle",background:p||Ye?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!a&&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:a?"center":"flex-start",position:"relative",minHeight:20,minWidth:0,width:"100%",overflow:"hidden"},children:[!a&&t.jsx("div",{...b,...I,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:p?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&ut(o),title:typeof e.label=="string"?e.label:void 0,style:{cursor:e.sortable!==!1?"pointer":"default",flex:a?"none":1,minWidth:0,lineHeight:"20px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),Gt&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),ut(o)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:ge?"#0b0b0b":"rgba(11, 11, 11, 0.55)",flexShrink:0},children:ge?Kt?t.jsx(W.ArrowUp,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowDown,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowUpDown,{size:14,strokeWidth:1.75})}),Ut&&t.jsxs("button",{type:"button",ref:k=>{O.current[o]=k},onClick:k=>{k.stopPropagation(),Ct(o,k.currentTarget)},title:"Filter",style:{position:"relative",background:Ye||Le?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Le?"#0b0b0b":"rgba(11, 11, 11, 0.7)",flexShrink:0},children:[t.jsx(W.ListFilter,{size:14,strokeWidth:1.75}),Le&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!a&&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}}),!a&&t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||o} column`,title:"Drag to resize column",onMouseDown:k=>zt(k,e,s),onClick:k=>k.stopPropagation(),onMouseEnter:k=>{k.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const mt=ct?l.find(e=>H(e)===ct):null,ht=({col:e,columnId:n,isSelected:o,draggable:a,isAction:s,actualIndex:p})=>{const u=a&&le===p,b=a&&Rt===p&&le!==null&&le!==p;o?at.has(n):st.has(n);const I=o?!at.has(n):st.has(n);return t.jsxs("div",{draggable:a,onDragStart:a?P=>It(P,p):void 0,onDragEnd:a?Pt:void 0,onDragOver:a?P=>Lt(P,p):void 0,onDragLeave:a?Ot:void 0,onDrop:a?P=>Tt(P,p):void 0,onClick:()=>{s||At(n)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:s?"default":a?"grab":"pointer",opacity:u?.5:1,background:b?"#F2F2F0":"transparent",borderRadius:6},children:[t.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:a?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14,strokeWidth:1.75})}),t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:I?"#0B0B0B":"#FFFFFF",border:`1px solid ${I?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:I&&t.jsx(W.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})]})},Ht=re?t.jsxs("div",{ref:Ke,style:{position:"fixed",top:`${ot.top}px`,left:`${ot.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:[me.map((e,n)=>{if(e===z)return null;const o=l.find(a=>H(a)===e);return o?t.jsx(i.Fragment,{children:ht({col:o,columnId:e,isSelected:!0,draggable:!0,isAction:!1,actualIndex:n})},`selected-${e}-${n}`):null}),l.filter(e=>{const n=H(e);return n!==z&&!me.includes(n)}).map(e=>{const n=H(e);return t.jsx(i.Fragment,{children:ht({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=ze.current?[...ze.current]:l.map(H).slice(0,X),o=ne(n);if(ee.current=!1,Me(o),we(o),it(new Set),lt(new Set),typeof window<"u"&&Q)try{localStorage.removeItem(Q)}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();const n=ne(me);ee.current=!0,we(n),pt(n),He(!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,xt=R?l.find(e=>H(e)===R):null,gt=xt?t.jsx(rn,{column:xt,columnId:R,filterType:kt(R),position:m,popoverRef:x,distinctValues:_e(R),initialValue:_[R],onApply:e=>{Te(R,e),fe(null)},onCancel:()=>fe(null)},R):null;return t.jsxs("div",{className:"w-full",children:[gt&&Ve.createPortal(gt,document.body),l.length>0&&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:[L&&t.jsx("div",{style:{marginRight:"auto"},children:t.jsx(Ft,{dateRangePicker:L.dateRangePicker,onWeekToDate:L.onWeekToDate,exportConfig:L.exportConfig,filterChipsConfig:L.filterChipsConfig,trailingActions:L.trailingActions})}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{ref:he,type:"button",onClick:()=>He(!re),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(W.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),re&&Ve.createPortal(Ht,document.body)]})]})}),Object.keys(_).length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(_).map(([e,n])=>{const o=l.find(u=>H(u)===e);if(!o||!Ce(n))return null;const a=Zt(n),s=Vt(n),p=en(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:[o.label,": "]}),t.jsx("span",{children:a})]}),s>0&&t.jsx(tn,{count:s,values:p}),t.jsx("button",{type:"button",onClick:()=>Te(e,[]),"aria-label":`Remove ${o.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:t.jsx(W.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),t.jsx("button",{type:"button",onClick:jt,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&&xe.length>0?t.jsxs(T.DndContext,{sensors:Bt,collisionDetection:T.closestCenter,onDragStart:Wt,onDragEnd:Nt,children:[t.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[G&&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(sn,{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:Mt,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(T.SortableContext,{items:B,strategy:T.horizontalListSortingStrategy,children:xe.map(e=>t.jsx(_t,{column:e,isHeaderRow:!0},`header-${H(e)}`))})})}),t.jsx("tbody",{children:!G&&Ie.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:xe.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!G&&Ie.length>0?Ie.map((e,n)=>t.jsx("tr",{"data-row-id":e.id||n,style:{borderBottom:"1px solid #e6e6e6",cursor:f?"pointer":"default",transition:"background 0.15s ease"},onClick:f?o=>{o.stopPropagation(),f(e,n)}:void 0,onMouseEnter:o=>{o.currentTarget.style.background="#E6E6E6"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:xe.map(o=>{const a=H(o),s=dt(a,o.width),p=e[a],u=o.render?o.render(p,e):p,b=s&&s!=="auto",I=typeof u=="string"&&u.trim()!=="",P=b&&I,ke=P?t.jsx(Z,{content:u,children:u}):u;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:s,fontFamily:"var(--font-sans)",...P&&{maxWidth:s||"200px"}},children:ke},a)})},n)):null})]})})]}),t.jsx(T.DragOverlay,{children:mt?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(W.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:mt.label})]})}):null})]}):null,(()=>{const e=!A&&(be.trim()!==""||Object.values(_).some(o=>Ce(o))),n=U?e?je.length:v:je.length;return n<=0?null:t.jsx(wt.Pagination,{page:V,pageSizeOptions:[5,10,20,50,100],pageSize:K,totalCount:n,currentDataLength:Ie.length,onPageChange:de,onPageSizeChange:o=>{ye(o),de(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=ln;exports.DataTableFilters=Ft;
1
+ "use strict";const t=require("react/jsx-runtime"),i=require("react"),T=require("./sortable.esm.cjs.js"),W=require("lucide-react"),Ze=require("react-dom"),Ft=require("./CustomFilterChips.cjs.js");require("motion/react");require("recharts");require("./TourGuideTooltip.cjs.js");function jt({dateRangePicker:r,onWeekToDate:l,exportConfig:d,filterChipsConfig:f,trailingActions:v}){const[y,c]=i.useState(!1),x=i.useRef(null),D=i.useRef(null);i.useEffect(()=>{const S=F=>{D.current&&!D.current.contains(F.target)&&x.current&&!x.current.contains(F.target)&&c(!1)};if(y)return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[y]);const w=()=>{c(S=>!S)},j=S=>{c(!1),d!=null&&d.onExport&&d.onExport(S)},E=(()=>{if(!(f!=null&&f.filters))return!1;const S=f.filters,F=f.customFilters||[],G=Object.entries(S).some(([C,A])=>!!(Array.isArray(A)&&A.length||typeof A=="string"&&A.trim()!==""||A&&typeof A=="object"&&(A.min!=null||A.max!=null))),$=F.some(C=>C.active);return G||$})();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(W.CalendarClock,{size:16}),t.jsx("span",{children:"Week to Date"})]}),r&&t.jsx(i.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(W.CalendarClock,{size:16}),t.jsx("span",{children:"Loading..."})]}),children:r}),d&&t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:x,onClick:w,disabled:d.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(W.Download,{size:16}),t.jsx("span",{children:d.isExporting?"Exporting...":"Export"})]}),t.jsx(W.ChevronDown,{size:16})]}),y&&t.jsx("div",{ref:D,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:(d.types||["csv"]).map(S=>t.jsxs("button",{onClick:()=>j(S),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 ",S.toUpperCase()]},S))})]}),(E||v)&&t.jsxs(t.Fragment,{children:[E&&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:[E&&f&&t.jsx(Ft.CustomFilterChips,{filters:f.filters,onChange:f.onChange,onClear:f.onClear,customFilters:f.customFilters||[],fieldOptions:f.fieldOptions||{}}),v&&t.jsx("div",{className:"flex-shrink-0",children:v})]})]})]})}function Ve(r){if(r==null)return NaN;const l=String(r).replace(/[,$%]|pp/gi,"").trim(),d=parseFloat(l);return Number.isFinite(d)?d:NaN}function Yt(r){if(r==null)return NaN;const l=String(r).trim(),d=l.match(/^(\d+):(\d+)(?::(\d+))?$/);if(d){const w=+d[1],j=+d[2],B=d[3]!=null?+d[3]:null;return B!=null?w*3600+j*60+B:w*60+j}let f=0,v=!1;const y=l.match(/(\d+)\s*d\b/i),c=l.match(/(\d+)\s*h\b/i),x=l.match(/(\d+)\s*m(?!s)\b/i),D=l.match(/(\d+)\s*s\b/i);return y&&(f+=+y[1]*86400,v=!0),c&&(f+=+c[1]*3600,v=!0),x&&(f+=+x[1]*60,v=!0),D&&(f+=+D[1],v=!0),v?f:NaN}function Qt(r){if(!r)return null;const l=String(r).trim(),d=l.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/);if(d){const v=d[3].length===2?2e3+ +d[3]:+d[3],y=new Date(v,+d[1]-1,+d[2]);return isNaN(y.getTime())?null:y}const f=new Date(l);return isNaN(f.getTime())?null:f}function Zt(r){if(!r||r.length===0)return"text";const l=r.slice(0,25),d=f=>l.every(f);return d(f=>/^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(f)||/^\d{4}-\d{2}-\d{2}/.test(f))?"date":d(f=>/^\d+\s*[dhms]\b/i.test(f)||/^\d+:\d+(:\d+)?$/.test(f))?"duration":d(f=>/^-?[\d,.]+(%|pp)?$/i.test(f))?"number":"text"}function ke(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 St(r){if(r==null||r===""||isNaN(r))return"";const l=Number(r),d=Math.floor(l/3600),f=Math.floor(l%3600/60),v=Math.floor(l%60);return d>0?`${d}h ${f}m`:f>0?`${f}m ${v}s`:`${v}s`}function Vt(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,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}if(r.type==="durationRange"){const l=r.minSec!==""&&r.minSec!=null?St(r.minSec):null,d=r.maxSec!==""&&r.maxSec!=null?St(r.maxSec):null;return l&&d?`${l} – ${d}`:l?`≥ ${l}`:d?`≤ ${d}`:""}if(r.type==="scoreRange"){if(Array.isArray(r.values)&&r.values.length>0)return r.values.slice().sort((f,v)=>f-v).join(", ");const l=r.min!==""&&r.min!=null?r.min:null,d=r.max!==""&&r.max!=null?r.max:null;return l!=null&&d!=null?`${l} – ${d}`:l!=null?`≥ ${l}`:d!=null?`≤ ${d}`:""}return r.type==="dateRange"?r.from&&r.to?`${r.from} – ${r.to}`:r.from?`from ${r.from}`:r.to?`to ${r.to}`:"":""}function en(r){return Array.isArray(r)?Math.max(0,r.length-1):0}function tn(r){return Array.isArray(r)?r.slice(1).map(String).join(", "):""}function nn({count:r,values:l}){const[d,f]=i.useState(!1);return t.jsxs("span",{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!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,d&&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 rn({leftLabel:r,rightLabel:l,leftValue:d,rightValue:f,onLeftChange:v,onRightChange:y,type:c="number",placeholderLeft:x="Min",placeholderRight:D="Max"}){const w={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"},j={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:j,children:r}),t.jsx("input",{type:c,value:d,onChange:B=>v(B.target.value),placeholder:x,style:w})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{style:j,children:l}),t.jsx("input",{type:c,value:f,onChange:B=>y(B.target.value),placeholder:D,style:w})]})]})}const vt=[{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 wt(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 d=Number(r);return Number.isFinite(d)?d:null}function Ye({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 Qe({minValue:r,maxValue:l,onMinChange:d,onMaxChange:f,inputType:v="number",inputMode:y="decimal",step:c,placeholder:x="0.0",unit:D}){const w={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:v,inputMode:y,step:c,placeholder:x,value:r,onChange:j=>d(j.target.value),style:w})]}),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:v,inputMode:y,step:c,placeholder:x,value:l,onChange:j=>f(j.target.value),style:w})]})]}),D&&t.jsxs("span",{style:{fontSize:11,color:"#676767",fontFamily:"var(--font-sans)"},children:["Input values in ",D==="sec"?"seconds":D]})]})}function sn({column:r,columnId:l,filterType:d="text",position:f,popoverRef:v,distinctValues:y,initialValue:c,onApply:x,onCancel:D}){const w=d==="text",j=d==="number",B=d==="date",E=d==="duration",S=d==="score",F=i.useMemo(()=>{if(!S||!Array.isArray(y)||y.length===0)return!1;let p=1/0,h=-1/0;for(const g of y){const P=Ve(g);Number.isFinite(P)&&(P<p&&(p=P),P>h&&(h=P))}return Number.isFinite(p)&&Number.isFinite(h)&&p>=0&&h<=5},[S,y]),[G,$]=i.useState(()=>w?new Set(Array.isArray(c)?c:[]):new Set),[C,A]=i.useState(""),[oe,ce]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.min!=null?c.min:""),[_,N]=i.useState(()=>j&&(c==null?void 0:c.type)==="range"&&c.max!=null?c.max:""),[Y,Q]=i.useState(new Set),[O,K]=i.useState(()=>E&&(c==null?void 0:c.type)==="durationRange"&&c.minSec!=null&&c.minSec!==""?String(c.minSec):""),[de,U]=i.useState(()=>E&&(c==null?void 0:c.type)==="durationRange"&&c.maxSec!=null&&c.maxSec!==""?String(c.maxSec):""),[Z,ue]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&Array.isArray(c.values)?new Set(c.values):new Set),[J,ie]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.min!=null&&c.min!==""?String(c.min):""),[fe,Ce]=i.useState(()=>S&&(c==null?void 0:c.type)==="scoreRange"&&c.max!=null&&c.max!==""?String(c.max):""),[X,M]=i.useState(()=>B&&(c==null?void 0:c.type)==="dateRange"&&c.from||""),[ee,V]=i.useState(()=>B&&(c==null?void 0:c.type)==="dateRange"&&c.to||"");i.useEffect(()=>{w&&$(new Set(Array.isArray(c)?c:[]))},[l,w]);const ae=i.useMemo(()=>{const p=C.trim().toLowerCase();return p?y.filter(h=>String(h).toLowerCase().includes(p)):y},[y,C]),H=p=>{$(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})},be=()=>{w&&$(new Set),j&&(ce(""),N("")),E&&(Q(new Set),K(""),U("")),S&&(ue(new Set),ie(""),Ce("")),B&&(M(""),V("")),A("")},pe=p=>{Q(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})},De=p=>{ue(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})},R=()=>{if(w)return x(Array.from(G));if(j)return x({type:"range",min:oe===""?"":Number(oe),max:_===""?"":Number(_)});if(E){const p=wt(O),h=wt(de),g=p!=null||h!=null;let P="",te="";if(g)P=p??"",te=h??"";else if(Y.size>0){const me=vt.filter(ne=>Y.has(ne.id));P=Math.min(...me.map(ne=>ne.minSec)),te=me.some(ne=>ne.maxSec==null)?"":Math.max(...me.map(ne=>ne.maxSec))}return x({type:"durationRange",minSec:P,maxSec:te})}if(S){const p=J===""?null:Number(J),h=fe===""?null:Number(fe);return p!=null||h!=null?x({type:"scoreRange",values:[],min:p!=null&&Number.isFinite(p)?p:"",max:h!=null&&Number.isFinite(h)?h:""}):x({type:"scoreRange",values:Array.from(Z).sort((P,te)=>P-te),min:"",max:""})}if(B)return x({type:"dateRange",from:X,to:ee})};return t.jsxs("div",{ref:v,role:"dialog","aria-label":`Filter ${r.label||l}`,style:{position:"fixed",top:f.top,left:f.left,zIndex:50,width:w?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:[w&&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(W.Search,{size:16,color:"#989898",strokeWidth:2}),t.jsx("input",{autoFocus:!0,type:"text",value:C,onChange:p=>A(p.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:ae.length===0?t.jsx("div",{style:{fontSize:13,color:"#676767",padding:"8px 4px",textAlign:"center"},children:"No values"}):ae.map(p=>{const h=G.has(p);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(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("input",{type:"checkbox",checked:h,onChange:()=>H(p),style:{position:"absolute",opacity:0,pointerEvents:"none"},tabIndex:-1}),t.jsx("span",{onClick:g=>{g.preventDefault(),H(p)},style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]},p)})})]}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Ye,{children:r.label||"Filter"}),t.jsx(Qe,{minValue:oe,maxValue:_,onMinChange:ce,onMaxChange:N})]}),E&&t.jsxs(t.Fragment,{children:[t.jsx(Ye,{children:r.label||"Duration"}),r.filterShowPresets===!0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:vt.map(p=>{const h=Y.has(p.id);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>pe(p.id),onKeyDown:g=>{(g.key===" "||g.key==="Enter")&&(g.preventDefault(),pe(p.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(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:p.label})]},p.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(Qe,{minValue:O,maxValue:de,onMinChange:K,onMaxChange:U,inputType:"number",inputMode:"numeric",placeholder:"0",unit:"sec"})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Ye,{children:r.label||"Score"}),F&&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(p=>{const h=Z.has(p);return t.jsxs("div",{role:"checkbox","aria-checked":h,tabIndex:0,onClick:()=>De(p),onKeyDown:g=>{(g.key===" "||g.key==="Enter")&&(g.preventDefault(),De(p))},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(W.Check,{size:14,color:"#FFFFFF",strokeWidth:3})}),t.jsx("span",{style:{fontSize:14,lineHeight:"20px",color:"#0B0B0B",fontFamily:"var(--font-sans)"},children:p})]},p)})}),t.jsx("div",{style:{height:1,background:"#D9D9D9",margin:"0 -12px"}})]}),F&&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(Qe,{minValue:J,maxValue:fe,onMinChange:ie,onMaxChange:Ce,step:"0.1"})]}),B&&t.jsx(rn,{leftLabel:"From",rightLabel:"To",leftValue:X,rightValue:ee,onLeftChange:M,onRightChange:V,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:be,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontSize:14,fontWeight:500,color:"#323232",fontFamily:"var(--font-sans)"},children:E&&r.filterShowPresets===!0||S&&F&&r.filterShowPresets===!0?"View All":"Reset"}),t.jsx("button",{type:"button",onClick:R,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 on=()=>({userData:{email:"anonymous"}}),an=r=>t.jsx("img",{...r});function ln({children:r,content:l,direction:d="top",align:f="center",styling:v,indicatorColor:y}){const c=typeof l=="string"?l:l!=null?String(l):"",x=typeof y=="string"&&(y.startsWith("#")||y.startsWith("rgb")||y.startsWith("hsl")||y.startsWith("var("))?y:"var(--Grey-Strong, #2E3236)",[D,w]=i.useState(!1),[j,B]=i.useState(!1),[E,S]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),F=i.useRef(null),G=i.useRef(null);if(!c)return r;i.useEffect(()=>{B(!0)},[]);const $=i.useCallback(()=>{if(!F.current||!G.current||typeof window>"u")return;const C=F.current.getBoundingClientRect(),A=G.current.getBoundingClientRect(),oe=window.innerWidth,ce=window.innerHeight,_=8,N=10,Y=A.width,Q=A.height,O=C.top,K=ce-C.bottom,de=d==="bottom"?"bottom":"top";let U=de;de==="top"&&O<Q+N+_&&K>O?U="bottom":de==="bottom"&&K<Q+N+_&&O>K&&(U="top");let Z=C.left+C.width/2;f==="start"&&(Z=C.left),f==="end"&&(Z=C.right);let ue=U==="top"?C.top-Q-N:C.bottom+N,J=f==="start"?Z:f==="end"?Z-Y:Z-Y/2;ue=Math.max(_,Math.min(ue,ce-Q-_)),J=Math.max(_,Math.min(J,oe-Y-_));const ie=Math.max(10,Math.min(Z-J,Y-10));S({top:ue,left:J,arrowLeft:ie,placement:U})},[f,d]);return i.useEffect(()=>{if(!D||!j)return;$();const C=()=>$();return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[D,j,$]),t.jsxs("span",{ref:F,style:{display:"block",width:"100%"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:[r,D&&j&&Ze.createPortal(t.jsxs("span",{ref:G,style:{position:"fixed",top:`${E.top}px`,left:`${E.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,t.jsx("span",{style:{position:"absolute",left:`${E.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...E.placement==="top"?{top:"100%",borderTop:`7px solid ${x}`}:{bottom:"100%",borderBottom:`7px solid ${x}`}}})]}),document.body)]})}function cn({data:r=[],columns:l=[],initialPageSize:d=10,onRowClick:f,totalCount:v=null,page:y=null,pageSize:c=null,onPageChange:x=null,onPageSizeChange:D=null,onFilterChange:w=null,columnFilters:j=null,onMaxColumnsError:B=null,onSort:E=null,sortFields:S=[],tableId:F=null,isLoading:G=!1,filtersConfig:$=null,columnResizeMinWidth:C=120,columnResizeMaxWidth:A=280,onVisibleColumnsChange:oe=null,hideColumnPicker:ce=!1}){var bt;const{userData:_}=on(),N=(_==null?void 0:_.email)||"anonymous",Y=i.memo(({children:e,content:n,className:s=""})=>{const a=i.useRef(null),[o,m]=i.useState(!1);i.useEffect(()=>{const b=()=>{if(a.current){const L=a.current.scrollWidth>a.current.clientWidth;m(L)}};b();const I=setTimeout(b,0);return window.addEventListener("resize",b),()=>{clearTimeout(I),window.removeEventListener("resize",b)}},[e,n]);const u=t.jsx("span",{className:`truncate block ${s}`,ref:a,children:e});return o&&n?t.jsx(ln,{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:u}):u});Y.displayName="TruncatedCell";const Q=v!==null&&x!==null,O=w!==null,K=E!==null,[de,U]=i.useState(1),[Z,ue]=i.useState(d),J=y!==null?y:de,ie=c!==null?c:Z,fe=e=>{x?x(e):U(e)},Ce=e=>{D?D(e):ue(e)},X=50,M="action",ee=i.useRef(!1),V=i.useMemo(()=>F?`dataTable_columns_${F}:${N}`:`dataTable_columns_${l.map(n=>n.id||n.key).sort().join("_")}:${N}`,[F,l,N]),ae=i.useMemo(()=>F?`dataTable_manual_change_${F}:${N}`:null,[F,N]);i.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(m=>n.some(u=>(u.id||u.key)===m));if(o.length>0)return o}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}return null},[]);const[H,be]=i.useState({}),[pe,De]=i.useState(""),[R,p]=i.useState(null),[h,g]=i.useState({top:0,left:0}),P=i.useRef(null),te=i.useRef({}),[me,et]=i.useState(null),[ne,tt]=i.useState("asc"),Pe=i.useCallback((e,n)=>{const s=ke(n);be(a=>{const o={...a};return s?o[e]=n:delete o[e],o}),x?x(1):U(1),O&&w&&w(s?{...H,[e]:n}:Object.fromEntries(Object.entries(H).filter(([a])=>a!==e)))},[H,w,O,x]),kt=i.useCallback(()=>{be({}),De(""),x?x(1):U(1),O&&w&&w({})},[w,O,x]),Te=i.useCallback(e=>{if(!r||r.length===0)return[];const n=new Set,s=[];for(const a of r){const o=a[e];if(o==null)continue;const m=typeof o=="object"?JSON.stringify(o):String(o);n.has(m)||(n.add(m),s.push(m))}return s.sort((a,o)=>a.localeCompare(o))},[r]),Ct=i.useCallback(e=>{const n=l.find(s=>q(s)===e);return n&&n.filterType?n.filterType:Zt(Te(e))},[l,Te]),Re=i.useCallback(e=>{const a=typeof window<"u"?window.innerWidth:1/0;let o=e.left;return o+280>a-8&&(o=Math.max(8,e.right-280)),{top:e.bottom+6,left:o}},[]),Dt=i.useCallback((e,n)=>{if(!n){p(e);return}const s=n.getBoundingClientRect();g(Re(s)),p(a=>a===e?null:e)},[Re]);i.useEffect(()=>{if(!R)return;const e=n=>{if(P.current&&P.current.contains(n.target))return;const s=te.current[R];s&&s.contains(n.target)||p(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[R]),i.useEffect(()=>{if(!R)return;const e=()=>{const n=te.current[R];if(!n)return;const s=n.getBoundingClientRect();g(Re(s))};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[R,Re]),i.useLayoutEffect(()=>{if(!R)return;const e=P.current,n=te.current[R];if(!e||!n)return;const s=e.offsetWidth,a=n.getBoundingClientRect(),o=8,m=typeof window<"u"?window.innerWidth:1/0;if(!(a.left+s>m-o))return;const b=Math.max(o,a.right-s);g(I=>I.left===b?I:{...I,left:b})},[R,h.top]);const nt=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim()!=="":!0)),[]),rt=i.useCallback((e,n)=>{const s=Object.keys(e||{}),a=Object.keys(n||{});return s.length!==a.length?!1:s.every(o=>e[o]===n[o])},[]);i.useEffect(()=>{if(!O||j===null)return;const e=nt(j);be(n=>rt(n,e)?n:e)},[O,j,nt,rt]),i.useCallback((e,n)=>e==="csat_score"&&n==="evaluation.csat_score"?n:e,[]);const Se=K&&S.length>0?S[0][0]:me,Ee=K&&S.length>0?S[0][1]:ne,[dn,st]=i.useState(()=>l.map(e=>e.id||e.key)),re=i.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 a=l.map(u=>u.id||u.key).includes(M);return!n.includes(M)&&a&&(n.length>=X?n=[...n.slice(0,X-1),M]:n=[...n,M]),[...n.filter(u=>u!==M),M]},[l]),[z,ve]=i.useState(()=>{if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${N}`)==="true"){const a=localStorage.getItem(`dataTable_columns_${F}:${N}`);if(a){const o=JSON.parse(a);if(Array.isArray(o)&&o.length>0){ee.current=!0;const m=o.filter(u=>l.some(b=>(b.id||b.key)===u));if(m.length>0)return m.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 re(n)}),[se,_e]=i.useState(!1),[he,Me]=i.useState([]),[ot,Rt]=i.useState({top:0,left:0,width:0}),[it,at]=i.useState(new Set),[lt,ct]=i.useState(new Set),ze=i.useRef(null);ze.current===null&&(ze.current=[...z]);const[le,He]=i.useState(null),[Et,Be]=i.useState(null),xe=i.useRef(null),qe=i.useRef(null),Ke=i.useRef(null),[dt,Xe]=i.useState(null),[Ge,Mt]=i.useState({}),zt=i.useRef(null),Ne=i.useRef(null),q=e=>e.id||e.key,We=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const n=e.trim();if(n.endsWith("px")){const a=parseFloat(n);return Number.isFinite(a)?a:null}const s=parseFloat(n);return Number.isFinite(s)&&`${s}`===n?s:null}return null},[]),ut=i.useCallback((e,n)=>Ge[e]!=null?`${Ge[e]}px`:typeof n=="number"?`${n}px`:n||"auto",[Ge]),$e=i.useCallback(e=>{if(!Ne.current)return;const{columnId:n,startX:s,startWidth:a,minWidth:o,maxWidth:m}=Ne.current,u=e.clientX-s,b=Math.round(a+u),I=Math.min(m,Math.max(o,b));Mt(L=>({...L,[n]:I}))},[]),we=i.useCallback(()=>{Ne.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",we)},[$e]),Bt=i.useCallback((e,n,s)=>{var Le;e.preventDefault(),e.stopPropagation();const a=n.id||n.key,o=We(n.minWidth)??C,m=We(n.maxWidth)??A,u=Math.min(o,m),b=Math.max(o,m),I=((Le=e.currentTarget.closest("th"))==null?void 0:Le.getBoundingClientRect().width)||0,L=We(s),je=L??Math.max(u,Math.round(I)||u),Ue=Math.min(b,Math.max(u,je));Ne.current={columnId:a,startX:e.clientX,startWidth:Ue,minWidth:u,maxWidth:b},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",$e),document.addEventListener("mouseup",we)},[A,C,$e,we,We]);i.useEffect(()=>()=>we(),[we]);const Nt=T.useSensors(T.useSensor(T.PointerSensor),T.useSensor(T.KeyboardSensor,{coordinateGetter:T.sortableKeyboardCoordinates})),Wt=e=>{const{active:n,over:s}=e;if(s&&n.id!==s.id){if(n.id===M||s.id===M){pt("Cannot drop columns on the Action column"),Xe(null);return}ee.current=!0,ve(a=>{const o=a.indexOf(n.id),m=a.indexOf(s.id);if(o!==-1&&m!==-1){const u=T.arrayMove(a,o,m),b=re(u);return mt(b),b}return a}),st(a=>{const o=a.indexOf(n.id),m=a.indexOf(s.id);return T.arrayMove(a,o,m)})}Xe(null)},$t=e=>{Xe(e.active.id)},Ae=i.useMemo(()=>{if(O)return r||[];if(!r||r.length===0)return[];const e=pe.trim().toLowerCase(),n=Object.entries(H).filter(([,s])=>ke(s));return r.filter(s=>{for(const[a,o]of n){const m=s[a];if(m==null)return!1;if(Array.isArray(o)){const u=String(m);if(!o.some(b=>String(b)===u))return!1;continue}if(o.type==="range"){const u=Ve(m);if(isNaN(u)||o.min!==""&&o.min!=null&&u<Number(o.min)||o.max!==""&&o.max!=null&&u>Number(o.max))return!1;continue}if(o.type==="durationRange"){const u=Yt(m);if(isNaN(u)||o.minSec!==""&&o.minSec!=null&&u<Number(o.minSec)||o.maxSec!==""&&o.maxSec!=null&&u>Number(o.maxSec))return!1;continue}if(o.type==="scoreRange"){const u=Ve(m);if(isNaN(u))return!1;if(Array.isArray(o.values)&&o.values.length>0){const b=Math.floor(u);if(!o.values.includes(b))return!1;continue}if(o.min!==""&&o.min!=null&&u<Number(o.min)||o.max!==""&&o.max!=null&&u>Number(o.max))return!1;continue}if(o.type==="dateRange"){const u=Qt(m);if(!u)return!1;if(o.from){const b=new Date(o.from+"T00:00:00");if(u<b)return!1}if(o.to){const b=new Date(o.to+"T23:59:59");if(u>b)return!1}continue}}return!(e&&!Object.values(s).some(o=>o==null?!1:String(o).toLowerCase().includes(e)))})},[r,H,pe,O]),Fe=i.useMemo(()=>K||!Se?Ae:[...Ae].sort((e,n)=>{const s=e[Se],a=n[Se];if(s==null)return 1;if(a==null)return-1;if(typeof s=="number"&&typeof a=="number")return Ee==="asc"?s-a:a-s;const o=String(s).toLowerCase(),m=String(a).toLowerCase();return Ee==="asc"?o.localeCompare(m):m.localeCompare(o)}),[Ae,Se,Ee,K]),Ie=i.useMemo(()=>{if(Q)return Fe;{const e=(J-1)*ie,n=e+ie;return Fe.slice(e,n)}},[Fe,J,ie,Q]),ft=e=>{K&&E?(E(e),x?x(1):U(1)):(me===e?tt(ne==="asc"?"desc":"asc"):(et(e),tt("asc")),fe(1))},At=(e,n)=>{const s=(n||"").split(/\s+/).map(a=>a.trim()).filter(Boolean);Pe(e,s)},pt=e=>{Ke.current||(typeof B=="function"&&B(e),Ke.current=setTimeout(()=>{Ke.current=null},3e3))},mt=i.useCallback(e=>{if(typeof window<"u"&&V&&e.length>0&&ee.current)try{localStorage.setItem(V,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(n){console.warn("Failed to save columns to localStorage:",n)}},[V,ae]),It=e=>{e!==M&&Me(n=>n.includes(e)?n.length===1?n:n.filter(s=>s!==e):n.length>=X?(pt("Maximum 9 column selection allowed"),n):re([...n,e]))},Lt=(e,n)=>{he[n]!==M&&He(n)},Ot=()=>{He(null),Be(null)},Pt=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&Be(n)},Tt=()=>{Be(null)},_t=(e,n)=>{e.preventDefault(),le!==null&&le!==n&&he[n]!==M&&he[le]!==M&&Me(s=>{const a=T.arrayMove(s,le,n);return re(a)}),He(null),Be(null)};i.useEffect(()=>{st(e=>{const n=z.filter(o=>e.includes(o)),s=z.filter(o=>!e.includes(o)),a=e.filter(o=>!z.includes(o));return[...n,...s,...a]})},[z]),i.useEffect(()=>{if(typeof window<"u"&&V&&z.length>0&&ee.current)try{const e=re(z);localStorage.setItem(V,JSON.stringify(e)),ae&&localStorage.setItem(ae,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[z,V,ae]),i.useEffect(()=>{oe&&oe(z.filter(e=>e!==M))},[z,oe]),i.useEffect(()=>{if(l.length>0&&z.length===0){if(typeof window<"u"&&F)try{if(localStorage.getItem(`dataTable_manual_change_${F}:${N}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${F}:${N}`);if(s){const a=JSON.parse(s);if(Array.isArray(a)&&a.length>0){const o=a.filter(m=>l.some(u=>(u.id||u.key)===m));if(o.length>0){ee.current=!0,ve(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);ve(re(e.slice(0,X)))}},[l,F,N,re]);const ge=i.useMemo(()=>{const e=z.map(n=>l.find(s=>q(s)===n)).filter(Boolean);return re(e.map(q)).map(n=>l.find(s=>q(s)===n)).filter(Boolean)},[l,z]);i.useMemo(()=>ge.some(e=>e.filterable===!0),[ge]),i.useEffect(()=>{if(!se||!xe.current)return;const e=()=>{if(xe.current){const n=xe.current.getBoundingClientRect(),s=217,a=Math.max(8,n.right-s);Rt({top:n.bottom,left:a,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)}},[se]),i.useEffect(()=>{const e=n=>{se&&xe.current&&!xe.current.contains(n.target)&&qe.current&&!qe.current.contains(n.target)&&_e(!1)};if(se)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[se]),i.useEffect(()=>{se&&(Me(z),at(new Set),ct(new Set))},[se,z]),z.length===1?(bt=l.find(e=>(e.id||e.key)===z[0]))!=null&&bt.label:`${z.length}`;function Ht({column:e,isHeaderRow:n=!0}){const s=q(e),a=s===M,o=ut(s,e.width),[m,u]=i.useState(!1),{attributes:b,listeners:I,setNodeRef:L,transform:je,transition:Ue,isDragging:Le}=T.useSortable({id:s}),Kt={transform:T.CSS.Transform.toString(je),transition:Ue,opacity:Le?.5:1,width:o,minWidth:o};let ye=!1;if(K&&S.length>0){const k=S[0][0];(k===s||k==="csat_score"&&s==="evaluation.csat_score")&&(ye=!0)}else ye=Se===s;const Xt=Ee==="asc",Gt=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:Gt?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:H[s]||"",onChange:k=>{k.stopPropagation(),At(s,k.target.value)},onKeyDown:k=>k.stopPropagation(),onMouseDown:k=>k.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 Je=R===s,Oe=ke(H[s]),Ut=e.sortable!==!1&&(m||ye),Jt=e.filterable!==!1&&!a&&(m||Je||Oe);return t.jsxs("th",{ref:L,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...Kt,padding:"0 12px",height:36,textAlign:a?"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:m||Je?"#e6e6e6":"#f2f2f0",borderBottom:"1px solid #e6e6e6",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)",transition:"background 100ms ease"},children:[!a&&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:a?"center":"flex-start",position:"relative",minHeight:20,minWidth:0,width:"100%",overflow:"hidden"},children:[!a&&t.jsx("div",{...b,...I,style:{cursor:"grab",color:"rgba(11, 11, 11, 0.36)",display:"inline-flex",alignItems:"center",visibility:m?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14})}),t.jsx("span",{onClick:()=>e.sortable!==!1&&ft(s),title:typeof e.label=="string"?e.label:void 0,style:{cursor:e.sortable!==!1?"pointer":"default",flex:a?"none":1,minWidth:0,lineHeight:"20px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),Ut&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),ft(s)},title:"Sort",style:{background:"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:ye?"#0b0b0b":"rgba(11, 11, 11, 0.55)",flexShrink:0},children:ye?Xt?t.jsx(W.ArrowUp,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowDown,{size:14,strokeWidth:1.75}):t.jsx(W.ArrowUpDown,{size:14,strokeWidth:1.75})}),Jt&&t.jsxs("button",{type:"button",ref:k=>{te.current[s]=k},onClick:k=>{k.stopPropagation(),Dt(s,k.currentTarget)},title:"Filter",style:{position:"relative",background:Je||Oe?"#D8D8D8":"transparent",border:"none",padding:4,borderRadius:4,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",color:Oe?"#0b0b0b":"rgba(11, 11, 11, 0.7)",flexShrink:0},children:[t.jsx(W.ListFilter,{size:14,strokeWidth:1.75}),Oe&&t.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:6,height:6,borderRadius:"50%",background:"#0B0B0B"}})]})]}),!a&&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}}),!a&&t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||s} column`,title:"Drag to resize column",onMouseDown:k=>Bt(k,e,o),onClick:k=>k.stopPropagation(),onMouseEnter:k=>{k.currentTarget.style.background="rgba(30, 33, 37, 0.18)"},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},style:{position:"absolute",top:0,right:-2,width:4,height:"100%",cursor:"col-resize",zIndex:4,background:"transparent"}})]})}const ht=dt?l.find(e=>q(e)===dt):null,xt=({col:e,columnId:n,isSelected:s,draggable:a,isAction:o,actualIndex:m})=>{const u=a&&le===m,b=a&&Et===m&&le!==null&&le!==m;s?lt.has(n):it.has(n);const I=s?!lt.has(n):it.has(n);return t.jsxs("div",{draggable:a,onDragStart:a?L=>Lt(L,m):void 0,onDragEnd:a?Ot:void 0,onDragOver:a?L=>Pt(L,m):void 0,onDragLeave:a?Tt:void 0,onDrop:a?L=>_t(L,m):void 0,onClick:()=>{o||It(n)},style:{display:"flex",alignItems:"center",gap:4,padding:"2px 0",cursor:o?"default":a?"grab":"pointer",opacity:u?.5:1,background:b?"#F2F2F0":"transparent",borderRadius:6},children:[t.jsx("span",{style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#989898",visibility:a?"visible":"hidden",flexShrink:0},children:t.jsx(W.GripVertical,{size:14,strokeWidth:1.75})}),t.jsx("span",{style:{width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:I?"#0B0B0B":"#FFFFFF",border:`1px solid ${I?"#0B0B0B":"#676767"}`,flexShrink:0,marginLeft:8},children:I&&t.jsx(W.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})]})},qt=se?t.jsxs("div",{ref:qe,style:{position:"fixed",top:`${ot.top}px`,left:`${ot.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:[he.map((e,n)=>{if(e===M)return null;const s=l.find(a=>q(a)===e);return s?t.jsx(i.Fragment,{children:xt({col:s,columnId:e,isSelected:!0,draggable:!0,isAction:!1,actualIndex:n})},`selected-${e}-${n}`):null}),l.filter(e=>{const n=q(e);return n!==M&&!he.includes(n)}).map(e=>{const n=q(e);return t.jsx(i.Fragment,{children:xt({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=ze.current?[...ze.current]:l.map(q).slice(0,X),s=re(n);if(ee.current=!1,Me(s),ve(s),at(new Set),ct(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"}),t.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation();const n=re(he);ee.current=!0,ve(n),mt(n),_e(!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,gt=R?l.find(e=>q(e)===R):null,yt=gt?t.jsx(sn,{column:gt,columnId:R,filterType:Ct(R),position:h,popoverRef:P,distinctValues:Te(R),initialValue:H[R],onApply:e=>{Pe(R,e),p(null)},onCancel:()=>p(null)},R):null;return t.jsxs("div",{className:"w-full",children:[yt&&Ze.createPortal(yt,document.body),l.length>0&&($||!ce)&&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:[$&&t.jsx("div",{style:{marginRight:"auto"},children:t.jsx(jt,{dateRangePicker:$.dateRangePicker,onWeekToDate:$.onWeekToDate,exportConfig:$.exportConfig,filterChipsConfig:$.filterChipsConfig,trailingActions:$.trailingActions})}),!ce&&t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{ref:xe,type:"button",onClick:()=>_e(!se),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(W.Settings2,{size:20,strokeWidth:1.75}),"Columns"]}),se&&Ze.createPortal(qt,document.body)]})]})}),Object.keys(H).length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",padding:"8px 0"},children:[Object.entries(H).map(([e,n])=>{const s=l.find(u=>q(u)===e);if(!s||!ke(n))return null;const a=Vt(n),o=en(n),m=tn(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:a})]}),o>0&&t.jsx(nn,{count:o,values:m}),t.jsx("button",{type:"button",onClick:()=>Pe(e,[]),"aria-label":`Remove ${s.label} filter`,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",display:"inline-flex",color:"#676767"},children:t.jsx(W.X,{size:14,strokeWidth:2})})]},`chip-${e}`)}),t.jsx("button",{type:"button",onClick:kt,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&&ge.length>0?t.jsxs(T.DndContext,{sensors:Nt,collisionDetection:T.closestCenter,onDragStart:$t,onDragEnd:Wt,children:[t.jsxs("div",{style:{borderRadius:8,border:"1px solid #E6E6E6",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[G&&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(an,{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:zt,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(T.SortableContext,{items:z,strategy:T.horizontalListSortingStrategy,children:ge.map(e=>t.jsx(Ht,{column:e,isHeaderRow:!0},`header-${q(e)}`))})})}),t.jsx("tbody",{children:!G&&Ie.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:ge.length,style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!G&&Ie.length>0?Ie.map((e,n)=>t.jsx("tr",{"data-row-id":e.id||n,style:{borderBottom:"1px solid #e6e6e6",cursor:f?"pointer":"default",transition:"background 0.15s ease"},onClick:f?s=>{s.stopPropagation(),f(e,n)}:void 0,onMouseEnter:s=>{s.currentTarget.style.background="#E6E6E6"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:ge.map(s=>{const a=q(s),o=ut(a,s.width),m=e[a],u=s.render?s.render(m,e):m,b=o&&o!=="auto",I=typeof u=="string"&&u.trim()!=="",L=b&&I,je=L?t.jsx(Y,{content:u,children:u}):u;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)",...L&&{maxWidth:o||"200px"}},children:je},a)})},n)):null})]})})]}),t.jsx(T.DragOverlay,{children:ht?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(W.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),t.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:ht.label})]})}):null})]}):null,(()=>{const e=!O&&(pe.trim()!==""||Object.values(H).some(s=>ke(s))),n=Q?e?Fe.length:v:Fe.length;return n<=0?null:t.jsx(Ft.Pagination,{page:J,pageSizeOptions:[5,10,20,50,100],pageSize:ie,totalCount:n,currentDataLength:Ie.length,onPageChange:fe,onPageSizeChange:s=>{Ce(s),fe(1)},showPageSizeSelector:!0})})()]})}exports.DataTable2=cn;exports.DataTableFilters=jt;
2
2
  //# sourceMappingURL=DataTable2.cjs.js.map