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