chordia-ui 4.0.5 → 4.0.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),w=require("../sortable.esm.cjs.js"),M=require("lucide-react"),ft=require("react-dom"),gt=require("../CustomFilterChips.cjs.js"),Ht=require("../useMediaQuery.cjs.js"),Ke=require("../DataTable2.cjs.js");require("motion/react");require("recharts");require("../AgentLiftAnalysisCard.cjs.js");require("../TourGuideTooltip.cjs.js");function He(){return r.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}function qt({size:p=10,color:c="currentColor"}){return r.jsxs("svg",{width:p,height:p,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"},"aria-hidden":"true",children:[r.jsx("path",{d:"M3.5 8H12.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round"}),r.jsx("path",{d:"M5 6.5L3.5 8L5 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M11 6.5L12.5 8L11 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6.8 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"}),r.jsx("path",{d:"M9.2 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"})]})}const Kt=()=>({userData:{email:"anonymous"}}),qe=p=>r.jsx("img",{...p});function Ut({children:p,content:c,direction:j="top",align:u="center",styling:C,indicatorColor:z}){const $=typeof c=="string"?c:c!=null?String(c):"",D=typeof z=="string"&&(z.startsWith("#")||z.startsWith("rgb")||z.startsWith("hsl")||z.startsWith("var("))?z:"var(--Grey-Strong, #2E3236)",[W,U]=i.useState(!1),[I,pe]=i.useState(!1),[L,g]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),f=i.useRef(null),E=i.useRef(null);if(!$)return p;i.useEffect(()=>{pe(!0)},[]);const b=i.useCallback(()=>{if(!f.current||!E.current||typeof window>"u")return;const h=f.current.getBoundingClientRect(),F=E.current.getBoundingClientRect(),Le=window.innerWidth,se=window.innerHeight,B=8,_=10,X=F.width,R=F.height,Q=h.top,T=se-h.bottom,Y=j==="bottom"?"bottom":"top";let oe=Y;Y==="top"&&Q<R+_+B&&T>Q?oe="bottom":Y==="bottom"&&T<R+_+B&&Q>T&&(oe="top");let S=h.left+h.width/2;u==="start"&&(S=h.left),u==="end"&&(S=h.right);let Z=oe==="top"?h.top-R-_:h.bottom+_,k=u==="start"?S:u==="end"?S-X:S-X/2;Z=Math.max(B,Math.min(Z,se-R-B)),k=Math.max(B,Math.min(k,Le-X-B));const me=Math.max(10,Math.min(S-k,X-10));g({top:Z,left:k,arrowLeft:me,placement:oe})},[u,j]);return i.useEffect(()=>{if(!W||!I)return;b();const h=()=>b();return window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[W,I,b]),r.jsxs("span",{ref:f,style:{display:"block",width:"100%"},onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1),children:[p,W&&I&&ft.createPortal(r.jsxs("span",{ref:E,style:{position:"fixed",top:`${L.top}px`,left:`${L.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 C=="object"?C:{}},children:[$,r.jsx("span",{style:{position:"absolute",left:`${L.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...L.placement==="top"?{top:"100%",borderTop:`7px solid ${D}`}:{bottom:"100%",borderBottom:`7px solid ${D}`}}})]}),document.body)]})}function Xt({data:p=[],columns:c=[],initialPageSize:j=10,onRowClick:u,totalCount:C=null,page:z=null,pageSize:$=null,onPageChange:D=null,onPageSizeChange:W=null,onFilterChange:U=null,columnFilters:I=null,onMaxColumnsError:pe=null,onSort:L=null,sortFields:g=[],tableId:f=null,isLoading:E=!1,filtersConfig:b=null,columnResizeMinWidth:h=100,columnResizeMaxWidth:F=280,enableMobileCards:Le=!0,onLoadMore:se=null,hasMore:B=null,mobileColumns:_=null,mobileFullLoading:X=!1,selectable:R=!1,selectedRowIds:Q=null,onSelectionChange:T=null,getRowId:Y=null}){var xt;const oe=Ht.useMediaQuery("(max-width: 640px)"),S=Le&&oe,{userData:Z}=Kt(),k=(Z==null?void 0:Z.email)||"anonymous",me=i.memo(({children:e,content:t,className:s=""})=>{const o=i.useRef(null),[n,l]=i.useState(!1);i.useEffect(()=>{const d=()=>{if(o.current){const P=o.current.scrollWidth>o.current.clientWidth;l(P)}};d();const N=setTimeout(d,0);return window.addEventListener("resize",d),()=>{clearTimeout(N),window.removeEventListener("resize",d)}},[e,t]);const a=r.jsx("span",{className:`truncate block ${s}`,ref:o,children:e});return n&&t?r.jsx(Ut,{content:t,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:a}):a});me.displayName="TruncatedCell";const be=C!==null&&D!==null,xe=U!==null,ie=L!==null,[ht,We]=i.useState(1),[mt,bt]=i.useState(j),Re=z!==null?z:ht,ye=$!==null?$:mt,ve=e=>{D?D(e):We(e)},Ue=e=>{W?W(e):bt(e)},V=9,y="action",ee=i.useRef(!1),ae=i.useMemo(()=>f?`dataTable_columns_${f}:${k}`:`dataTable_columns_${c.map(t=>t.id||t.key).sort().join("_")}:${k}`,[f,c,k]),le=i.useMemo(()=>f?`dataTable_manual_change_${f}:${k}`:null,[f,k]);i.useCallback((e,t)=>{if(typeof window>"u"||!e||!t||t.length===0)return null;try{const s=localStorage.getItem(e);if(s){const n=JSON.parse(s).filter(l=>t.some(a=>(a.id||a.key)===l));if(n.length>0)return n}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}return null},[]);const[te,Xe]=i.useState({}),[Ge,yt]=i.useState(null),[Je,Qe]=i.useState("asc"),Ye=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim()!=="":!0)),[]),Ze=i.useCallback((e,t)=>{const s=Object.keys(e||{}),o=Object.keys(t||{});return s.length!==o.length?!1:s.every(n=>e[n]===t[n])},[]);i.useEffect(()=>{if(!xe||I===null)return;const e=Ye(I);Xe(t=>Ze(t,e)?t:e)},[xe,I,Ye,Ze]),i.useCallback((e,t)=>e==="csat_score"&&t==="evaluation.csat_score"?t:e,[]);const fe=ie&&g.length>0?g[0][0]:Ge,we=ie&&g.length>0?g[0][1]:Je,[Qt,et]=i.useState(()=>c.map(e=>e.id||e.key)),H=i.useCallback(e=>{if(!e||e.length===0)return e;let t=Array.from(new Set(e));t.length>V&&(t=t.slice(0,V));const o=c.map(a=>a.id||a.key).includes(y);return!t.includes(y)&&o&&(t.length>=V?t=[...t.slice(0,V-1),y]:t=[...t,y]),[...t.filter(a=>a!==y),y]},[c]),[x,re]=i.useState(()=>{if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const o=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(o){const n=JSON.parse(o);if(Array.isArray(n)&&n.length>0){ee.current=!0;const l=n.filter(a=>c.some(d=>(d.id||d.key)===a));if(l.length>0)return l.slice(0,V)}}}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}const t=c.map(s=>s.id||s.key).slice(0,V);return H(t)}),[O,tt]=i.useState(!1),[Te,vt]=i.useState({top:0,left:0,width:0}),[wt,rt]=i.useState(new Set),[nt,st]=i.useState(new Set),[q,Oe]=i.useState(null),[jt,je]=i.useState(null),ce=i.useRef(null),Ae=i.useRef(null),de=i.useRef(null),[ot,Pe]=i.useState(null),[$e,St]=i.useState({}),kt=i.useRef(null),Se=i.useRef(null),v=e=>e.id||e.key,ke=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("px")){const o=parseFloat(t);return Number.isFinite(o)?o:null}const s=parseFloat(t);return Number.isFinite(s)&&`${s}`===t?s:null}return null},[]),Ie=i.useCallback((e,t)=>$e[e]!=null?`${$e[e]}px`:typeof t=="number"?`${t}px`:t||"auto",[$e]),Ce=i.useCallback(e=>{if(!Se.current)return;const{columnId:t,startX:s,startWidth:o,minWidth:n,maxWidth:l}=Se.current,a=e.clientX-s,d=Math.round(o+a),N=Math.min(l,Math.max(n,d));St(P=>({...P,[t]:N}))},[]),ge=i.useCallback(()=>{Se.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",Ce),document.removeEventListener("mouseup",ge)},[Ce]),Ct=i.useCallback((e,t,s)=>{var K;e.preventDefault(),e.stopPropagation();const o=t.id||t.key,n=ke(t.minWidth)??h,l=ke(t.maxWidth)??F,a=Math.min(n,l),d=Math.max(n,l),N=((K=e.currentTarget.closest("th"))==null?void 0:K.getBoundingClientRect().width)||0,P=ke(s),he=P??Math.max(a,Math.round(N)||a),ue=Math.min(d,Math.max(a,he));Se.current={columnId:o,startX:e.clientX,startWidth:ue,minWidth:a,maxWidth:d},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ce),document.addEventListener("mouseup",ge)},[F,h,Ce,ge,ke]);i.useEffect(()=>()=>ge(),[ge]);const Dt=w.useSensors(w.useSensor(w.PointerSensor),w.useSensor(w.KeyboardSensor,{coordinateGetter:w.sortableKeyboardCoordinates})),Ft=e=>{const{active:t,over:s}=e;if(s&&t.id!==s.id){if(t.id===y||s.id===y){ct("Cannot drop columns on the Action column"),Pe(null);return}ee.current=!0,re(o=>{const n=o.indexOf(t.id),l=o.indexOf(s.id);if(n!==-1&&l!==-1){const a=w.arrayMove(o,n,l),d=H(a);return Ne(d),d}return o}),et(o=>{const n=o.indexOf(t.id),l=o.indexOf(s.id);return w.arrayMove(o,n,l)})}Pe(null)},Mt=e=>{Pe(e.active.id)},De=i.useMemo(()=>xe?p||[]:!p||p.length===0?[]:p.filter(e=>Object.keys(te).every(t=>{const s=te[t];if(!s||s.trim()==="")return!0;const o=e[t];if(o==null)return!1;const n=String(o).toLowerCase();return s.toLowerCase().trim().split(/\s+/).filter(d=>d.length>0).every(d=>n.includes(d))})),[p,te,xe]),Fe=i.useMemo(()=>ie||!fe?De:[...De].sort((e,t)=>{const s=e[fe],o=t[fe];if(s==null)return 1;if(o==null)return-1;if(typeof s=="number"&&typeof o=="number")return we==="asc"?s-o:o-s;const n=String(s).toLowerCase(),l=String(o).toLowerCase();return we==="asc"?n.localeCompare(l):l.localeCompare(n)}),[De,fe,we,ie]),G=i.useMemo(()=>{if(be)return p||[];{const e=(Re-1)*ye,t=e+ye;return Fe.slice(e,t)}},[p,Fe,Re,ye,be]),Me=i.useCallback((e,t)=>Y?Y(e,t):(e==null?void 0:e.id)??t,[Y]),J=i.useMemo(()=>new Set(Array.isArray(Q)?Q:[]),[Q]),ne=i.useMemo(()=>G.map((e,t)=>Me(e,t)),[G,Me]),it=i.useMemo(()=>ne.reduce((e,t)=>J.has(t)?e+1:e,0),[ne,J]),ze=ne.length>0&&it===ne.length,zt=it>0&&!ze,at=i.useCallback(e=>{if(!T)return;const t=new Set(J);t.has(e)?t.delete(e):t.add(e),T(Array.from(t))},[T,J]),Et=i.useCallback(()=>{if(!T)return;const e=new Set(J);ze?ne.forEach(t=>e.delete(t)):ne.forEach(t=>e.add(t)),T(Array.from(e))},[T,J,ze,ne]),Be=({checked:e,indeterminate:t=!1,onToggle:s,ariaLabel:o})=>r.jsx("span",{role:"checkbox","aria-checked":t?"mixed":e,"aria-label":o,tabIndex:0,onClick:n=>{n.stopPropagation(),s()},onKeyDown:n=>{(n.key===" "||n.key==="Enter")&&(n.preventDefault(),n.stopPropagation(),s())},style:{width:16,height:16,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:e||t?"#0B0B0B":"#FFFFFF",border:`1px solid ${e||t?"#0B0B0B":"#676767"}`,cursor:"pointer",flexShrink:0},children:t?r.jsx(M.Minus,{size:11,color:"#FFFFFF",strokeWidth:3}):e?r.jsx(M.Check,{size:11,color:"#FFFFFF",strokeWidth:3}):null}),Ee=20,Nt=e=>{ie&&L?(L(e),D?D(1):We(1)):(Ge===e?Qe(Je==="asc"?"desc":"asc"):(yt(e),Qe("asc")),ve(1))},lt=(e,t)=>{const s=t&&t.trim()!==""?{...te,[e]:t}:Object.fromEntries(Object.entries(te).filter(([o])=>o!==e));Xe(s),xe&&U&&U(s),D?D(1):We(1)},ct=e=>{de.current||(typeof pe=="function"&&pe(e),de.current=setTimeout(()=>{de.current=null},3e3))},Ne=i.useCallback(e=>{if(typeof window<"u"&&ae&&e.length>0&&ee.current)try{localStorage.setItem(ae,JSON.stringify(e)),le&&localStorage.setItem(le,"true")}catch(t){console.warn("Failed to save columns to localStorage:",t)}},[ae,le]),_e=e=>{e!==y&&(ee.current=!0,re(t=>t.includes(e)?(de.current&&(clearTimeout(de.current),de.current=null),t.length===1||(st(s=>new Set(s).add(e)),setTimeout(()=>{re(s=>{const o=s.filter(l=>l!==e),n=H(o);return Ne(n),n}),st(s=>{const o=new Set(s);return o.delete(e),o})},200)),t):t.length>=V?(ct("Maximum 9 column selection allowed"),t):(rt(s=>new Set(s).add(e)),setTimeout(()=>{re(s=>{const o=s.includes(e)?s:[...s,e],n=H(o);return Ne(n),n}),rt(s=>{const o=new Set(s);return o.delete(e),o})},200),t)))},Lt=(e,t)=>{x[t]!==y&&Oe(t)},Wt=()=>{Oe(null),je(null)},Rt=(e,t)=>{e.preventDefault(),q!==null&&q!==t&&je(t)},Tt=()=>{je(null)},Ot=(e,t)=>{e.preventDefault(),q!==null&&q!==t&&x[t]!==y&&x[q]!==y&&(ee.current=!0,re(s=>{const o=w.arrayMove(s,q,t),n=H(o);return Ne(n),n})),Oe(null),je(null)};i.useEffect(()=>{et(e=>{const t=x.filter(n=>e.includes(n)),s=x.filter(n=>!e.includes(n)),o=e.filter(n=>!x.includes(n));return[...t,...s,...o]})},[x]),i.useEffect(()=>{if(typeof window<"u"&&ae&&x.length>0&&ee.current)try{const e=H(x);localStorage.setItem(ae,JSON.stringify(e)),le&&localStorage.setItem(le,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[x,ae,le]),i.useEffect(()=>{if(c.length>0&&x.length===0){if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){const n=o.filter(l=>c.some(a=>(a.id||a.key)===l));if(n.length>0){ee.current=!0,re(n.slice(0,V));return}}}}}catch(t){console.warn("Failed to load saved columns from localStorage:",t)}const e=c.map(t=>t.id||t.key);re(H(e.slice(0,V)))}},[c,f,k,H]);const A=i.useMemo(()=>{const e=x.map(t=>c.find(s=>v(s)===t)).filter(Boolean);return H(e.map(v)).map(t=>c.find(s=>v(s)===t)).filter(Boolean)},[c,x]),dt=i.useMemo(()=>A.some(e=>e.filterable===!0),[A]),At=i.useMemo(()=>Array.isArray(_)&&_.length>0?_.filter(e=>v(e)!==y):A.filter(e=>v(e)!==y),[_,A]),Pt=i.useRef(null),ut=i.useRef(null),Ve=S&&typeof se=="function"&&(B!==null?B:C!==null&&((p==null?void 0:p.length)||0)<C);i.useEffect(()=>{if(!S||!Ve)return;const e=ut.current;if(!e||typeof IntersectionObserver>"u")return;const t=new IntersectionObserver(s=>{var o;(o=s[0])!=null&&o.isIntersecting&&!E&&se()},{root:null,rootMargin:"120px"});return t.observe(e),()=>t.disconnect()},[S,Ve,E,se,p==null?void 0:p.length]),i.useEffect(()=>{if(!O||!ce.current)return;const e=()=>{if(ce.current){const t=ce.current.getBoundingClientRect();vt({top:t.bottom,left:t.left,width:Math.max(t.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[O]),i.useEffect(()=>{const e=t=>{O&&ce.current&&!ce.current.contains(t.target)&&Ae.current&&!Ae.current.contains(t.target)&&tt(!1)};if(O)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[O]);const $t=x.length===1?((xt=c.find(e=>(e.id||e.key)===x[0]))==null?void 0:xt.label)||"1 selected":`${x.length} selected`;function It({column:e,isHeaderRow:t=!0}){const s=v(e),o=s===y,n=Ie(s,e.width),{attributes:l,listeners:a,setNodeRef:d,transform:N,transition:P,isDragging:he}=w.useSortable({id:s}),ue={transform:w.CSS.Transform.toString(N),transition:P,opacity:he?.5:1,width:n,minWidth:n};let K=!1;if(ie&&g.length>0){const m=g[0][0];(m===s||m==="csat_score"&&s==="evaluation.csat_score")&&(K=!0)}else K=fe===s;const _t=we==="asc",Vt=e.filterable===!0;return t?r.jsx("th",{ref:d,style:{...ue,padding:"12px 14px",textAlign:o?"center":"left",fontWeight:650,fontSize:"11px",letterSpacing:"0.14em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.62)",cursor:e.sortable!==!1?"pointer":"default",width:n,borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:o?"center":"flex-start",position:"relative",minHeight:20},children:[!o&&r.jsx("div",{...l,...a,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:r.jsx(M.GripVertical,{size:12})}),r.jsx("span",{onClick:()=>e.sortable!==!1&&Nt(s),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&K&&r.jsx("span",{children:_t?r.jsx(M.ChevronUp,{size:12}):r.jsx(M.ChevronDown,{size:12})}),!o&&r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||s} column`,title:"Drag to resize column",onMouseDown:m=>Ct(m,e,n),onClick:m=>m.stopPropagation(),style:{position:"absolute",top:0,right:-1,width:14,height:"100%",cursor:"col-resize",zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(30, 33, 37, 0.56)"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(30, 33, 37, 0.08)",m.currentTarget.style.color="rgba(30, 33, 37, 0.86)"},onMouseLeave:m=>{m.currentTarget.style.background="transparent",m.currentTarget.style.color="rgba(30, 33, 37, 0.56)"},children:r.jsx(qt,{size:10,color:"currentColor"})})]})}):r.jsx("th",{style:{width:n,minWidth:n,backgroundColor:"var(--primary-foreground)"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:Vt?r.jsxs("div",{className:"relative",children:[r.jsx(M.Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),r.jsx("input",{type:"text",placeholder:"Filter...",value:te[s]||"",onChange:m=>{m.stopPropagation(),lt(s,m.target.value)},onKeyDown:m=>m.stopPropagation(),onMouseDown:m=>m.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"})]}):r.jsx("div",{className:"h-[34px]"})})}const pt=ot?c.find(e=>v(e)===ot):null,Bt=O?r.jsxs("div",{ref:Ae,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${Te.top}px`,left:`${Te.left}px`,width:Te.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:"0 0 8px 8px",boxShadow:"4px 4px 6px 0px #6D70681A, -4px 0px 6px 0px #6D70681A",border:"1px solid rgba(52, 58, 64, 0.12)",borderTop:"none"},children:[x.map((e,t)=>{const s=c.find(d=>v(d)===e);if(!s)return null;const o=x.indexOf(e),n=q===o,l=jt===o,a=e===y;return r.jsxs(i.Fragment,{children:[r.jsxs("div",{draggable:!a,onDragStart:a?void 0:d=>Lt(d,o),onDragEnd:a?void 0:Wt,onDragOver:a?void 0:d=>Rt(d,o),onDragLeave:a?void 0:Tt,onDrop:a?void 0:d=>Ot(d,o),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${a?"cursor-default opacity-100":"cursor-move"} ${!a&&n?"opacity-50":""} ${!a&&l&&q!==null&&q!==o?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!a&&r.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),r.jsx("button",{type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),a||_e(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${a?"bg-green-2 border-green-2 cursor-default":nt.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!nt.has(e)&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:s.label})]}),t<x.length-1&&r.jsx(He,{})]},`selected-${e}-${t}`)}),c.filter(e=>!x.includes(v(e))).map((e,t)=>{const s=v(e),o=wt.has(s),n=c.filter(l=>!x.includes(v(l))).indexOf(e);return r.jsxs(i.Fragment,{children:[x.length>0&&n===0&&r.jsx(He,{}),r.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 rounded cursor-pointer transition-colors",onClick:l=>{l.preventDefault(),_e(s)},children:[r.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),_e(s)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${o?"bg-green-2 border-green-2":"bg-white border-gray-300"}`,children:o&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),n<c.filter(l=>!x.includes(v(l))).length-1&&r.jsx(He,{})]},`unselected-${s}`)})]}):null;return r.jsxs("div",{className:"w-full",style:{backgroundColor:"var(--primary-foreground)",...S?{}:{top:"130px",position:"sticky",zIndex:35}},children:[!S&&c.length>0&&r.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex-shrink-0",children:[r.jsx("div",{className:"mb-1 ml-1.5",children:r.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),r.jsxs("div",{ref:ce,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 cursor-pointer transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>tt(!O),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:O?"8px 8px 0 0":"8px"},children:[r.jsx("span",{children:$t}),O?r.jsx(M.ChevronUp,{size:16}):r.jsx(M.ChevronDown,{size:16})]}),O&&ft.createPortal(Bt,document.body)]}),b&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),r.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:r.jsx(Ke.DataTableFilters,{dateRangePicker:b.dateRangePicker,onWeekToDate:b.onWeekToDate,exportConfig:b.exportConfig,filterChipsConfig:b.filterChipsConfig,trailingActions:b.trailingActions})})]}),(b==null?void 0:b.rightActions)&&r.jsx("div",{className:"ml-auto mt-[1.5rem] flex items-center gap-3 flex-shrink-0",children:b.rightActions})]})}),S&&c.length>0&&A.length>0&&r.jsxs("div",{ref:Pt,className:"custom-thin-scrollbar-hidden",style:{marginTop:"0.5rem",overflowX:"clip",display:"flex",flexDirection:"column",gap:"12px",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box"},children:[X?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"10px",padding:"56px 0"},children:[r.jsx(qe,{src:"/BrandLoading.gif",alt:"Loading",width:48,height:48,unoptimized:!0}),r.jsx("span",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.5)",fontFamily:"var(--font-sans)"},children:"Loading..."})]}):!E&&G.length===0?r.jsx("div",{style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"13px",fontFamily:"var(--font-sans)"},children:"No results found"}):G.map((e,t)=>{const s=Me(e,t),o=R&&J.has(s);return r.jsxs("div",{"data-row-id":e.id||t,onClick:u?n=>{n.stopPropagation(),u(e,t)}:void 0,style:{border:o?"1px solid rgba(52, 58, 64, 0.35)":"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"14px",background:o?"rgba(231, 212, 162, 0.18)":"var(--primary-foreground)",padding:"14px 16px",cursor:u?"pointer":"default",fontFamily:"var(--font-sans)",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box"},children:[R&&r.jsx("div",{onClick:n=>n.stopPropagation(),style:{display:"flex",justifyContent:"flex-end",marginBottom:"10px"},children:r.jsx(Be,{checked:o,onToggle:()=>at(s),ariaLabel:"Select row"})}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",minWidth:0},children:At.map(n=>{const l=v(n),a=e[l],d=n.render?n.render(a,e):a;return r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"12px"},children:[r.jsx("span",{style:{flexShrink:0,fontSize:"11px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.55)"},children:n.label}),r.jsx("span",{style:{flex:1,minWidth:0,textAlign:"right",fontSize:n.mobileEmphasis?"14px":"13px",fontWeight:n.mobileEmphasis?600:400,color:n.mobileEmphasis?"rgba(30, 33, 37, 0.95)":"rgba(30, 33, 37, 0.85)",wordBreak:"break-word",overflowWrap:"anywhere"},children:d})]},l)})})]},e.id||t)}),!X&&Ve&&r.jsx("div",{ref:ut,style:{height:"1px"}}),!X&&E&&r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:r.jsx(qe,{src:"/BrandLoading.gif",alt:"Loading",width:36,height:36,unoptimized:!0})})]}),!S&&c.length>0&&A.length>0?r.jsxs(w.DndContext,{sensors:Dt,collisionDetection:w.closestCenter,onDragStart:Mt,onDragEnd:Ft,children:[r.jsxs("div",{className:"rounded-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[E&&r.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:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[r.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),r.jsx(qe,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),r.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:kt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[r.jsxs("thead",{children:[r.jsxs("tr",{children:[R&&r.jsx("th",{rowSpan:dt?2:1,style:{width:Ee,minWidth:Ee,padding:"10px 4px",textAlign:"center",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",borderRight:"1px solid rgba(52, 58, 64, 0.04)",position:"sticky",top:0,zIndex:11,boxSizing:"border-box",verticalAlign:"middle"},children:r.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},children:r.jsx(Be,{checked:ze,indeterminate:zt,onToggle:Et,ariaLabel:"Select all rows on this page"})})}),r.jsx(w.SortableContext,{items:x,strategy:w.horizontalListSortingStrategy,children:A.map(e=>r.jsx(It,{column:e,isHeaderRow:!0},`header-${v(e)}`))})]}),dt&&r.jsx("tr",{children:A.map(e=>{const t=v(e),s=Ie(t,e.width),o=e.filterable===!0;return r.jsx("th",{style:{padding:"8px 14px",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:s,fontFamily:"var(--font-sans)"},children:o?r.jsxs("div",{style:{position:"relative"},children:[r.jsx("input",{type:"text",placeholder:"Filter...",value:te[t]||"",onChange:n=>{n.stopPropagation(),lt(t,n.target.value)},onKeyDown:n=>n.stopPropagation(),onMouseDown:n=>n.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"var(--primary-foreground)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:n=>{n.target.style.borderColor="rgba(231, 212, 162, 0.65)",n.target.style.background="var(--primary-foreground)"},onBlur:n=>{n.target.style.borderColor="rgba(52, 58, 64, 0.16)",n.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),r.jsx(M.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):r.jsx("div",{className:"h-[34px]"})},`filter-${t}`)})})]}),r.jsx("tbody",{children:!E&&G.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:A.length+(R?1:0),style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!E&&G.length>0?G.map((e,t)=>{const s=Me(e,t),o=R&&J.has(s);return r.jsxs("tr",{"data-row-id":e.id||t,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:u?"pointer":"default",transition:"background 0.15s ease",background:o?"rgba(231, 212, 162, 0.18)":"transparent"},onClick:u?n=>{n.stopPropagation(),u(e,t)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background=o?"rgba(231, 212, 162, 0.18)":"transparent"},children:[R&&r.jsx("td",{onClick:n=>n.stopPropagation(),style:{width:Ee,minWidth:Ee,padding:"10px 4px",textAlign:"center",borderRight:"1px solid rgba(52, 58, 64, 0.04)",boxSizing:"border-box"},children:r.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},children:r.jsx(Be,{checked:o,onToggle:()=>at(s),ariaLabel:"Select row"})})}),A.map(n=>{const l=v(n),a=Ie(l,n.width),d=e[l],N=n.render?n.render(d,e):d,P=a&&a!=="auto",he=typeof N=="string"&&N.trim()!=="",ue=P&&he,K=ue?r.jsx(me,{content:N,children:N}):N;return r.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:a,fontFamily:"var(--font-sans)",...ue&&{maxWidth:a||"200px"}},children:K},l)})]},t)}):null})]})})]}),r.jsx(w.DragOverlay,{children:pt?r.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(M.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),r.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:pt.label})]})}):null})]}):null,!S&&(be?C>0:Fe.length>0)&&r.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:r.jsx(gt.Pagination,{page:Re,pageSizeOptions:[5,10,20,50,100],pageSize:ye,totalCount:be?C:Fe.length,currentDataLength:G.length,onPageChange:ve,onPageSizeChange:W?e=>{Ue(e),ve(1)}:e=>{Ue(e),ve(1)},showPageSizeSelector:!0})})]})}function Gt({dateRangePicker:p,onWeekToDate:c,exportConfig:j,filterChipsConfig:u,trailingActions:C}){const[z,$]=i.useState(!1),D=i.useRef(null),W=i.useRef(null);i.useEffect(()=>{const g=f=>{W.current&&!W.current.contains(f.target)&&D.current&&!D.current.contains(f.target)&&$(!1)};if(z)return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[z]);const U=()=>{$(g=>!g)},I=g=>{$(!1),j!=null&&j.onExport&&j.onExport(g)},L=(()=>{if(!(u!=null&&u.filters))return!1;const g=u.filters,f=u.customFilters||[],E=Object.entries(g).some(([h,F])=>!!(Array.isArray(F)&&F.length||typeof F=="string"&&F.trim()!==""||F&&typeof F=="object"&&(F.min!=null||F.max!=null))),b=f.some(h=>h.active);return E||b})();return r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c&&r.jsxs("button",{onClick:c,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:[r.jsx(M.CalendarClock,{size:16}),r.jsx("span",{children:"Week to Date"})]}),p&&r.jsx(i.Suspense,{fallback:r.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:[r.jsx(M.CalendarClock,{size:16}),r.jsx("span",{children:"Loading..."})]}),children:p}),j&&r.jsxs("div",{className:"relative",children:[r.jsxs("button",{ref:D,onClick:U,disabled:j.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(M.Download,{size:16}),r.jsx("span",{children:j.isExporting?"Exporting...":"Export"})]}),r.jsx(M.ChevronDown,{size:16})]}),z&&r.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:(j.types||["csv"]).map(g=>r.jsxs("button",{onClick:()=>I(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))})]}),(L||C)&&r.jsxs(r.Fragment,{children:[L&&r.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),r.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[L&&u&&r.jsx(gt.CustomFilterChips,{filters:u.filters,onChange:u.onChange,onClear:u.onClear,customFilters:u.customFilters||[],fieldOptions:u.fieldOptions||{}}),C&&r.jsx("div",{className:"flex-shrink-0",children:C})]})]})]})}function Jt({title:p="Summary stats",stats:c=[],columns:j=2}){return r.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[r.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:p}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${j}, minmax(0, 1fr))`,gap:"10px"},children:c.map((u,C)=>r.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:u.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[u.accentColor&&r.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:u.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),r.jsx("div",{className:"text-[10px] tracking-[0.14em] uppercase",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650,lineHeight:1.1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),r.jsx("div",{style:{fontSize:"13px",color:u.valueStyle==="muted"?"rgba(30, 33, 37, 0.56)":"rgba(30, 33, 37, 0.78)",fontWeight:700,lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:u.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:u.value}),u.subtext&&r.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.subtext})]},C))})]})}exports.DataTable2=Ke.DataTable2;exports.DataTableFilters=Ke.DataTableFilters;exports.DataTable=Xt;exports.DataTableFilters2=Gt;exports.SummaryStatsPanel=Jt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),w=require("../sortable.esm.cjs.js"),M=require("lucide-react"),ft=require("react-dom"),gt=require("../CustomFilterChips.cjs.js"),Vt=require("../useMediaQuery.cjs.js"),Ke=require("../DataTable2.cjs.js");require("motion/react");require("recharts");require("../AgentLiftAnalysisCard.cjs.js");require("../TourGuideTooltip.cjs.js");function Ve(){return r.jsx("div",{style:{height:1,background:"rgba(52,58,64,0.08)"}})}function qt({size:p=10,color:c="currentColor"}){return r.jsxs("svg",{width:p,height:p,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"},"aria-hidden":"true",children:[r.jsx("path",{d:"M3.5 8H12.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round"}),r.jsx("path",{d:"M5 6.5L3.5 8L5 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M11 6.5L12.5 8L11 9.5",stroke:c,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6.8 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"}),r.jsx("path",{d:"M9.2 3V13",stroke:c,strokeWidth:"1.2",strokeLinecap:"round"})]})}const Kt=()=>({userData:{email:"anonymous"}}),qe=p=>r.jsx("img",{...p});function Ut({children:p,content:c,direction:j="top",align:u="center",styling:C,indicatorColor:z}){const $=typeof c=="string"?c:c!=null?String(c):"",D=typeof z=="string"&&(z.startsWith("#")||z.startsWith("rgb")||z.startsWith("hsl")||z.startsWith("var("))?z:"var(--Grey-Strong, #2E3236)",[W,U]=i.useState(!1),[I,pe]=i.useState(!1),[L,g]=i.useState({top:0,left:0,arrowLeft:0,placement:"top"}),f=i.useRef(null),E=i.useRef(null);if(!$)return p;i.useEffect(()=>{pe(!0)},[]);const b=i.useCallback(()=>{if(!f.current||!E.current||typeof window>"u")return;const h=f.current.getBoundingClientRect(),F=E.current.getBoundingClientRect(),Le=window.innerWidth,se=window.innerHeight,B=8,_=10,X=F.width,R=F.height,Q=h.top,T=se-h.bottom,Y=j==="bottom"?"bottom":"top";let oe=Y;Y==="top"&&Q<R+_+B&&T>Q?oe="bottom":Y==="bottom"&&T<R+_+B&&Q>T&&(oe="top");let S=h.left+h.width/2;u==="start"&&(S=h.left),u==="end"&&(S=h.right);let Z=oe==="top"?h.top-R-_:h.bottom+_,k=u==="start"?S:u==="end"?S-X:S-X/2;Z=Math.max(B,Math.min(Z,se-R-B)),k=Math.max(B,Math.min(k,Le-X-B));const me=Math.max(10,Math.min(S-k,X-10));g({top:Z,left:k,arrowLeft:me,placement:oe})},[u,j]);return i.useEffect(()=>{if(!W||!I)return;b();const h=()=>b();return window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[W,I,b]),r.jsxs("span",{ref:f,style:{display:"block",width:"100%"},onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1),children:[p,W&&I&&ft.createPortal(r.jsxs("span",{ref:E,style:{position:"fixed",top:`${L.top}px`,left:`${L.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 C=="object"?C:{}},children:[$,r.jsx("span",{style:{position:"absolute",left:`${L.arrowLeft}px`,transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",...L.placement==="top"?{top:"100%",borderTop:`7px solid ${D}`}:{bottom:"100%",borderBottom:`7px solid ${D}`}}})]}),document.body)]})}function Xt({data:p=[],columns:c=[],initialPageSize:j=10,onRowClick:u,totalCount:C=null,page:z=null,pageSize:$=null,onPageChange:D=null,onPageSizeChange:W=null,onFilterChange:U=null,columnFilters:I=null,onMaxColumnsError:pe=null,onSort:L=null,sortFields:g=[],tableId:f=null,isLoading:E=!1,filtersConfig:b=null,columnResizeMinWidth:h=100,columnResizeMaxWidth:F=280,enableMobileCards:Le=!0,onLoadMore:se=null,hasMore:B=null,mobileColumns:_=null,mobileFullLoading:X=!1,selectable:R=!1,selectedRowIds:Q=null,onSelectionChange:T=null,getRowId:Y=null}){var xt;const oe=Vt.useMediaQuery("(max-width: 640px)"),S=Le&&oe,{userData:Z}=Kt(),k=(Z==null?void 0:Z.email)||"anonymous",me=i.memo(({children:e,content:t,className:s=""})=>{const o=i.useRef(null),[n,l]=i.useState(!1);i.useEffect(()=>{const d=()=>{if(o.current){const P=o.current.scrollWidth>o.current.clientWidth;l(P)}};d();const N=setTimeout(d,0);return window.addEventListener("resize",d),()=>{clearTimeout(N),window.removeEventListener("resize",d)}},[e,t]);const a=r.jsx("span",{className:`truncate block ${s}`,ref:o,children:e});return n&&t?r.jsx(Ut,{content:t,styling:"bg-green-2 text-gray-900 px-3 py-2 text-sm rounded-lg shadow-md border border-gray-300 max-w-xs whitespace-normal",indicatorColor:"bg-green-2",direction:"top",children:a}):a});me.displayName="TruncatedCell";const be=C!==null&&D!==null,xe=U!==null,ie=L!==null,[ht,We]=i.useState(1),[mt,bt]=i.useState(j),Re=z!==null?z:ht,ye=$!==null?$:mt,ve=e=>{D?D(e):We(e)},Ue=e=>{W?W(e):bt(e)},H=9,y="action",ee=i.useRef(!1),ae=i.useMemo(()=>f?`dataTable_columns_${f}:${k}`:`dataTable_columns_${c.map(t=>t.id||t.key).sort().join("_")}:${k}`,[f,c,k]),le=i.useMemo(()=>f?`dataTable_manual_change_${f}:${k}`:null,[f,k]);i.useCallback((e,t)=>{if(typeof window>"u"||!e||!t||t.length===0)return null;try{const s=localStorage.getItem(e);if(s){const n=JSON.parse(s).filter(l=>t.some(a=>(a.id||a.key)===l));if(n.length>0)return n}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}return null},[]);const[te,Xe]=i.useState({}),[Ge,yt]=i.useState(null),[Je,Qe]=i.useState("asc"),Ye=i.useCallback(e=>!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim()!=="":!0)),[]),Ze=i.useCallback((e,t)=>{const s=Object.keys(e||{}),o=Object.keys(t||{});return s.length!==o.length?!1:s.every(n=>e[n]===t[n])},[]);i.useEffect(()=>{if(!xe||I===null)return;const e=Ye(I);Xe(t=>Ze(t,e)?t:e)},[xe,I,Ye,Ze]),i.useCallback((e,t)=>e==="csat_score"&&t==="evaluation.csat_score"?t:e,[]);const fe=ie&&g.length>0?g[0][0]:Ge,we=ie&&g.length>0?g[0][1]:Je,[Qt,et]=i.useState(()=>c.map(e=>e.id||e.key)),V=i.useCallback(e=>{if(!e||e.length===0)return e;let t=Array.from(new Set(e));t.length>H&&(t=t.slice(0,H));const o=c.map(a=>a.id||a.key).includes(y);return!t.includes(y)&&o&&(t.length>=H?t=[...t.slice(0,H-1),y]:t=[...t,y]),[...t.filter(a=>a!==y),y]},[c]),[x,re]=i.useState(()=>{if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const o=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(o){const n=JSON.parse(o);if(Array.isArray(n)&&n.length>0){ee.current=!0;const l=n.filter(a=>c.some(d=>(d.id||d.key)===a));if(l.length>0)return l.slice(0,H)}}}}catch(s){console.warn("Failed to load saved columns from localStorage:",s)}const t=c.map(s=>s.id||s.key).slice(0,H);return V(t)}),[O,tt]=i.useState(!1),[Te,vt]=i.useState({top:0,left:0,width:0}),[wt,rt]=i.useState(new Set),[nt,st]=i.useState(new Set),[q,Oe]=i.useState(null),[jt,je]=i.useState(null),ce=i.useRef(null),Ae=i.useRef(null),de=i.useRef(null),[ot,Pe]=i.useState(null),[$e,St]=i.useState({}),kt=i.useRef(null),Se=i.useRef(null),v=e=>e.id||e.key,ke=i.useCallback(e=>{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("px")){const o=parseFloat(t);return Number.isFinite(o)?o:null}const s=parseFloat(t);return Number.isFinite(s)&&`${s}`===t?s:null}return null},[]),Ie=i.useCallback((e,t)=>$e[e]!=null?`${$e[e]}px`:typeof t=="number"?`${t}px`:t||"auto",[$e]),Ce=i.useCallback(e=>{if(!Se.current)return;const{columnId:t,startX:s,startWidth:o,minWidth:n,maxWidth:l}=Se.current,a=e.clientX-s,d=Math.round(o+a),N=Math.min(l,Math.max(n,d));St(P=>({...P,[t]:N}))},[]),ge=i.useCallback(()=>{Se.current=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",Ce),document.removeEventListener("mouseup",ge)},[Ce]),Ct=i.useCallback((e,t,s)=>{var K;e.preventDefault(),e.stopPropagation();const o=t.id||t.key,n=ke(t.minWidth)??h,l=ke(t.maxWidth)??F,a=Math.min(n,l),d=Math.max(n,l),N=((K=e.currentTarget.closest("th"))==null?void 0:K.getBoundingClientRect().width)||0,P=ke(s),he=P??Math.max(a,Math.round(N)||a),ue=Math.min(d,Math.max(a,he));Se.current={columnId:o,startX:e.clientX,startWidth:ue,minWidth:a,maxWidth:d},document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ce),document.addEventListener("mouseup",ge)},[F,h,Ce,ge,ke]);i.useEffect(()=>()=>ge(),[ge]);const Dt=w.useSensors(w.useSensor(w.PointerSensor),w.useSensor(w.KeyboardSensor,{coordinateGetter:w.sortableKeyboardCoordinates})),Ft=e=>{const{active:t,over:s}=e;if(s&&t.id!==s.id){if(t.id===y||s.id===y){ct("Cannot drop columns on the Action column"),Pe(null);return}ee.current=!0,re(o=>{const n=o.indexOf(t.id),l=o.indexOf(s.id);if(n!==-1&&l!==-1){const a=w.arrayMove(o,n,l),d=V(a);return Ne(d),d}return o}),et(o=>{const n=o.indexOf(t.id),l=o.indexOf(s.id);return w.arrayMove(o,n,l)})}Pe(null)},Mt=e=>{Pe(e.active.id)},De=i.useMemo(()=>xe?p||[]:!p||p.length===0?[]:p.filter(e=>Object.keys(te).every(t=>{const s=te[t];if(!s||s.trim()==="")return!0;const o=e[t];if(o==null)return!1;const n=String(o).toLowerCase();return s.toLowerCase().trim().split(/\s+/).filter(d=>d.length>0).every(d=>n.includes(d))})),[p,te,xe]),Fe=i.useMemo(()=>ie||!fe?De:[...De].sort((e,t)=>{const s=e[fe],o=t[fe];if(s==null)return 1;if(o==null)return-1;if(typeof s=="number"&&typeof o=="number")return we==="asc"?s-o:o-s;const n=String(s).toLowerCase(),l=String(o).toLowerCase();return we==="asc"?n.localeCompare(l):l.localeCompare(n)}),[De,fe,we,ie]),G=i.useMemo(()=>{if(be)return p||[];{const e=(Re-1)*ye,t=e+ye;return Fe.slice(e,t)}},[p,Fe,Re,ye,be]),Me=i.useCallback((e,t)=>Y?Y(e,t):(e==null?void 0:e.id)??t,[Y]),J=i.useMemo(()=>new Set(Array.isArray(Q)?Q:[]),[Q]),ne=i.useMemo(()=>G.map((e,t)=>Me(e,t)),[G,Me]),it=i.useMemo(()=>ne.reduce((e,t)=>J.has(t)?e+1:e,0),[ne,J]),ze=ne.length>0&&it===ne.length,zt=it>0&&!ze,at=i.useCallback(e=>{if(!T)return;const t=new Set(J);t.has(e)?t.delete(e):t.add(e),T(Array.from(t))},[T,J]),Et=i.useCallback(()=>{if(!T)return;const e=new Set(J);ze?ne.forEach(t=>e.delete(t)):ne.forEach(t=>e.add(t)),T(Array.from(e))},[T,J,ze,ne]),Be=({checked:e,indeterminate:t=!1,onToggle:s,ariaLabel:o})=>r.jsx("span",{role:"checkbox","aria-checked":t?"mixed":e,"aria-label":o,tabIndex:0,onClick:n=>{n.stopPropagation(),s()},onKeyDown:n=>{(n.key===" "||n.key==="Enter")&&(n.preventDefault(),n.stopPropagation(),s())},style:{width:16,height:16,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",background:e||t?"#0B0B0B":"#FFFFFF",border:`1px solid ${e||t?"#0B0B0B":"#676767"}`,cursor:"pointer",flexShrink:0},children:t?r.jsx(M.Minus,{size:11,color:"#FFFFFF",strokeWidth:3}):e?r.jsx(M.Check,{size:11,color:"#FFFFFF",strokeWidth:3}):null}),Ee=46,Nt=e=>{ie&&L?(L(e),D?D(1):We(1)):(Ge===e?Qe(Je==="asc"?"desc":"asc"):(yt(e),Qe("asc")),ve(1))},lt=(e,t)=>{const s=t&&t.trim()!==""?{...te,[e]:t}:Object.fromEntries(Object.entries(te).filter(([o])=>o!==e));Xe(s),xe&&U&&U(s),D?D(1):We(1)},ct=e=>{de.current||(typeof pe=="function"&&pe(e),de.current=setTimeout(()=>{de.current=null},3e3))},Ne=i.useCallback(e=>{if(typeof window<"u"&&ae&&e.length>0&&ee.current)try{localStorage.setItem(ae,JSON.stringify(e)),le&&localStorage.setItem(le,"true")}catch(t){console.warn("Failed to save columns to localStorage:",t)}},[ae,le]),_e=e=>{e!==y&&(ee.current=!0,re(t=>t.includes(e)?(de.current&&(clearTimeout(de.current),de.current=null),t.length===1||(st(s=>new Set(s).add(e)),setTimeout(()=>{re(s=>{const o=s.filter(l=>l!==e),n=V(o);return Ne(n),n}),st(s=>{const o=new Set(s);return o.delete(e),o})},200)),t):t.length>=H?(ct("Maximum 9 column selection allowed"),t):(rt(s=>new Set(s).add(e)),setTimeout(()=>{re(s=>{const o=s.includes(e)?s:[...s,e],n=V(o);return Ne(n),n}),rt(s=>{const o=new Set(s);return o.delete(e),o})},200),t)))},Lt=(e,t)=>{x[t]!==y&&Oe(t)},Wt=()=>{Oe(null),je(null)},Rt=(e,t)=>{e.preventDefault(),q!==null&&q!==t&&je(t)},Tt=()=>{je(null)},Ot=(e,t)=>{e.preventDefault(),q!==null&&q!==t&&x[t]!==y&&x[q]!==y&&(ee.current=!0,re(s=>{const o=w.arrayMove(s,q,t),n=V(o);return Ne(n),n})),Oe(null),je(null)};i.useEffect(()=>{et(e=>{const t=x.filter(n=>e.includes(n)),s=x.filter(n=>!e.includes(n)),o=e.filter(n=>!x.includes(n));return[...t,...s,...o]})},[x]),i.useEffect(()=>{if(typeof window<"u"&&ae&&x.length>0&&ee.current)try{const e=V(x);localStorage.setItem(ae,JSON.stringify(e)),le&&localStorage.setItem(le,"true")}catch(e){console.warn("Failed to save columns to localStorage:",e)}},[x,ae,le]),i.useEffect(()=>{if(c.length>0&&x.length===0){if(typeof window<"u"&&f)try{if(localStorage.getItem(`dataTable_manual_change_${f}:${k}`)==="true"){const s=localStorage.getItem(`dataTable_columns_${f}:${k}`);if(s){const o=JSON.parse(s);if(Array.isArray(o)&&o.length>0){const n=o.filter(l=>c.some(a=>(a.id||a.key)===l));if(n.length>0){ee.current=!0,re(n.slice(0,H));return}}}}}catch(t){console.warn("Failed to load saved columns from localStorage:",t)}const e=c.map(t=>t.id||t.key);re(V(e.slice(0,H)))}},[c,f,k,V]);const A=i.useMemo(()=>{const e=x.map(t=>c.find(s=>v(s)===t)).filter(Boolean);return V(e.map(v)).map(t=>c.find(s=>v(s)===t)).filter(Boolean)},[c,x]),dt=i.useMemo(()=>A.some(e=>e.filterable===!0),[A]),At=i.useMemo(()=>Array.isArray(_)&&_.length>0?_.filter(e=>v(e)!==y):A.filter(e=>v(e)!==y),[_,A]),Pt=i.useRef(null),ut=i.useRef(null),He=S&&typeof se=="function"&&(B!==null?B:C!==null&&((p==null?void 0:p.length)||0)<C);i.useEffect(()=>{if(!S||!He)return;const e=ut.current;if(!e||typeof IntersectionObserver>"u")return;const t=new IntersectionObserver(s=>{var o;(o=s[0])!=null&&o.isIntersecting&&!E&&se()},{root:null,rootMargin:"120px"});return t.observe(e),()=>t.disconnect()},[S,He,E,se,p==null?void 0:p.length]),i.useEffect(()=>{if(!O||!ce.current)return;const e=()=>{if(ce.current){const t=ce.current.getBoundingClientRect();vt({top:t.bottom,left:t.left,width:Math.max(t.width||220,220)})}};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[O]),i.useEffect(()=>{const e=t=>{O&&ce.current&&!ce.current.contains(t.target)&&Ae.current&&!Ae.current.contains(t.target)&&tt(!1)};if(O)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[O]);const $t=x.length===1?((xt=c.find(e=>(e.id||e.key)===x[0]))==null?void 0:xt.label)||"1 selected":`${x.length} selected`;function It({column:e,isHeaderRow:t=!0}){const s=v(e),o=s===y,n=Ie(s,e.width),{attributes:l,listeners:a,setNodeRef:d,transform:N,transition:P,isDragging:he}=w.useSortable({id:s}),ue={transform:w.CSS.Transform.toString(N),transition:P,opacity:he?.5:1,width:n,minWidth:n};let K=!1;if(ie&&g.length>0){const m=g[0][0];(m===s||m==="csat_score"&&s==="evaluation.csat_score")&&(K=!0)}else K=fe===s;const _t=we==="asc",Ht=e.filterable===!0;return t?r.jsx("th",{ref:d,style:{...ue,padding:"12px 14px",textAlign:o?"center":"left",fontWeight:650,fontSize:"11px",letterSpacing:"0.14em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.62)",cursor:e.sortable!==!1?"pointer":"default",width:n,borderRight:"1px solid rgba(52, 58, 64, 0.06)",userSelect:"none",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",position:"sticky",top:0,zIndex:10,fontFamily:"var(--font-sans)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",justifyContent:o?"center":"flex-start",position:"relative",minHeight:20},children:[!o&&r.jsx("div",{...l,...a,style:{cursor:"grab",color:"rgba(30, 33, 37, 0.32)"},children:r.jsx(M.GripVertical,{size:12})}),r.jsx("span",{onClick:()=>e.sortable!==!1&&Nt(s),style:{cursor:e.sortable!==!1?"pointer":"default"},children:e.label.toUpperCase()}),e.sortable!==!1&&K&&r.jsx("span",{children:_t?r.jsx(M.ChevronUp,{size:12}):r.jsx(M.ChevronDown,{size:12})}),!o&&r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label||s} column`,title:"Drag to resize column",onMouseDown:m=>Ct(m,e,n),onClick:m=>m.stopPropagation(),style:{position:"absolute",top:0,right:-1,width:14,height:"100%",cursor:"col-resize",zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(30, 33, 37, 0.56)"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(30, 33, 37, 0.08)",m.currentTarget.style.color="rgba(30, 33, 37, 0.86)"},onMouseLeave:m=>{m.currentTarget.style.background="transparent",m.currentTarget.style.color="rgba(30, 33, 37, 0.56)"},children:r.jsx(qt,{size:10,color:"currentColor"})})]})}):r.jsx("th",{style:{width:n,minWidth:n,backgroundColor:"var(--primary-foreground)"},className:"sticky top-[57px] z-10 border-b border-[var(--border-strong)] px-4 py-2 text-left",children:Ht?r.jsxs("div",{className:"relative",children:[r.jsx(M.Filter,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-faint)] pointer-events-none"}),r.jsx("input",{type:"text",placeholder:"Filter...",value:te[s]||"",onChange:m=>{m.stopPropagation(),lt(s,m.target.value)},onKeyDown:m=>m.stopPropagation(),onMouseDown:m=>m.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"})]}):r.jsx("div",{className:"h-[34px]"})})}const pt=ot?c.find(e=>v(e)===ot):null,Bt=O?r.jsxs("div",{ref:Ae,className:"flex flex-col overflow-auto z-[49] min-w-[220px]",style:{position:"fixed",top:`${Te.top}px`,left:`${Te.left}px`,width:Te.width||220,maxHeight:"400px",fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:"0 0 8px 8px",boxShadow:"4px 4px 6px 0px #6D70681A, -4px 0px 6px 0px #6D70681A",border:"1px solid rgba(52, 58, 64, 0.12)",borderTop:"none"},children:[x.map((e,t)=>{const s=c.find(d=>v(d)===e);if(!s)return null;const o=x.indexOf(e),n=q===o,l=jt===o,a=e===y;return r.jsxs(i.Fragment,{children:[r.jsxs("div",{draggable:!a,onDragStart:a?void 0:d=>Lt(d,o),onDragEnd:a?void 0:Wt,onDragOver:a?void 0:d=>Rt(d,o),onDragLeave:a?void 0:Tt,onDrop:a?void 0:d=>Ot(d,o),className:`flex items-center gap-2 px-3 py-2 rounded transition-all ${a?"cursor-default opacity-100":"cursor-move"} ${!a&&n?"opacity-50":""} ${!a&&l&&q!==null&&q!==o?"ring-2 ring-green-2 ring-offset-1":""}`,children:[!a&&r.jsx("svg",{className:"h-4 w-4 text-gray-600 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8h16M4 12h16M4 16h16"})}),r.jsx("button",{type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),a||_e(e)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${a?"bg-green-2 border-green-2 cursor-default":nt.has(e)?"bg-white border-gray-300":"bg-green-2 border-green-2"}`,children:!nt.has(e)&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",style:{fontFamily:"var(--font-sans)"},children:s.label})]}),t<x.length-1&&r.jsx(Ve,{})]},`selected-${e}-${t}`)}),c.filter(e=>!x.includes(v(e))).map((e,t)=>{const s=v(e),o=wt.has(s),n=c.filter(l=>!x.includes(v(l))).indexOf(e);return r.jsxs(i.Fragment,{children:[x.length>0&&n===0&&r.jsx(Ve,{}),r.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 rounded cursor-pointer transition-colors",onClick:l=>{l.preventDefault(),_e(s)},children:[r.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),_e(s)},className:`h-4 w-4 rounded-[2px] border flex items-center justify-center transition-colors flex-shrink-0 ${o?"bg-green-2 border-green-2":"bg-white border-gray-300"}`,children:o&&r.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,style:{color:"#1E2125"},children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),r.jsx("span",{className:"text-sm text-gray-900 flex-1",children:e.label})]}),n<c.filter(l=>!x.includes(v(l))).length-1&&r.jsx(Ve,{})]},`unselected-${s}`)})]}):null;return r.jsxs("div",{className:"w-full",style:{backgroundColor:"var(--primary-foreground)",...S?{}:{top:"130px",position:"sticky",zIndex:35}},children:[!S&&c.length>0&&r.jsx("div",{className:"pt-2 pb-1",style:{position:"sticky",zIndex:35,backgroundColor:"var(--primary-foreground)"},children:r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsxs("div",{className:"flex-shrink-0",children:[r.jsx("div",{className:"mb-1 ml-1.5",children:r.jsx("p",{className:"text-xs font-medium text-gray-600",style:{fontFamily:"var(--font-sans)"},children:"Select Columns"})}),r.jsxs("div",{ref:ce,className:"inline-flex items-center justify-between gap-2 px-4 py-2.5 cursor-pointer transition-colors text-sm font-medium text-gray-900 border border-gray-300 min-w-[220px]",onClick:()=>tt(!O),style:{fontFamily:"var(--font-sans)",backgroundColor:"var(--primary-foreground)",borderRadius:O?"8px 8px 0 0":"8px"},children:[r.jsx("span",{children:$t}),O?r.jsx(M.ChevronUp,{size:16}):r.jsx(M.ChevronDown,{size:16})]}),O&&ft.createPortal(Bt,document.body)]}),b&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-9 mt-[1.5rem] w-px bg-gray-300 flex-shrink-0"}),r.jsx("div",{className:"flex-shrink-0 mt-[1.5rem]",children:r.jsx(Ke.DataTableFilters,{dateRangePicker:b.dateRangePicker,onWeekToDate:b.onWeekToDate,exportConfig:b.exportConfig,filterChipsConfig:b.filterChipsConfig,trailingActions:b.trailingActions})})]}),(b==null?void 0:b.rightActions)&&r.jsx("div",{className:"ml-auto mt-[1.5rem] flex items-center gap-3 flex-shrink-0",children:b.rightActions})]})}),S&&c.length>0&&A.length>0&&r.jsxs("div",{ref:Pt,className:"custom-thin-scrollbar-hidden",style:{marginTop:"0.5rem",overflowX:"clip",display:"flex",flexDirection:"column",gap:"12px",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box"},children:[X?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"10px",padding:"56px 0"},children:[r.jsx(qe,{src:"/BrandLoading.gif",alt:"Loading",width:48,height:48,unoptimized:!0}),r.jsx("span",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.5)",fontFamily:"var(--font-sans)"},children:"Loading..."})]}):!E&&G.length===0?r.jsx("div",{style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"13px",fontFamily:"var(--font-sans)"},children:"No results found"}):G.map((e,t)=>{const s=Me(e,t),o=R&&J.has(s);return r.jsxs("div",{"data-row-id":e.id||t,onClick:u?n=>{n.stopPropagation(),u(e,t)}:void 0,style:{border:o?"1px solid rgba(52, 58, 64, 0.35)":"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"14px",background:o?"rgba(231, 212, 162, 0.18)":"var(--primary-foreground)",padding:"14px 16px",cursor:u?"pointer":"default",fontFamily:"var(--font-sans)",width:"100%",maxWidth:"100%",minWidth:0,boxSizing:"border-box"},children:[R&&r.jsx("div",{onClick:n=>n.stopPropagation(),style:{display:"flex",justifyContent:"flex-end",marginBottom:"10px"},children:r.jsx(Be,{checked:o,onToggle:()=>at(s),ariaLabel:"Select row"})}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",minWidth:0},children:At.map(n=>{const l=v(n),a=e[l],d=n.render?n.render(a,e):a;return r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"12px"},children:[r.jsx("span",{style:{flexShrink:0,fontSize:"11px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.55)"},children:n.label}),r.jsx("span",{style:{flex:1,minWidth:0,textAlign:"right",fontSize:n.mobileEmphasis?"14px":"13px",fontWeight:n.mobileEmphasis?600:400,color:n.mobileEmphasis?"rgba(30, 33, 37, 0.95)":"rgba(30, 33, 37, 0.85)",wordBreak:"break-word",overflowWrap:"anywhere"},children:d})]},l)})})]},e.id||t)}),!X&&He&&r.jsx("div",{ref:ut,style:{height:"1px"}}),!X&&E&&r.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:r.jsx(qe,{src:"/BrandLoading.gif",alt:"Loading",width:36,height:36,unoptimized:!0})})]}),!S&&c.length>0&&A.length>0?r.jsxs(w.DndContext,{sensors:Dt,collisionDetection:w.closestCenter,onDragStart:Mt,onDragEnd:Ft,children:[r.jsxs("div",{className:"rounded-[14px]",style:{border:"1px solid rgba(52, 58, 64, 0.12)",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",overflow:"hidden",background:"var(--primary-foreground)",position:"relative",top:"0.5rem"},children:[E&&r.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:r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[r.jsx("p",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.6)",margin:0},children:"Loading..."}),r.jsx(qe,{src:"/BrandLoading.gif",alt:"Loading",width:50,height:50,unoptimized:!0,className:"mt-1"})]})}),r.jsx("div",{className:"overflow-x-auto custom-thin-scrollbar-hidden",ref:kt,style:{maxHeight:"500px",overflowY:"auto",position:"relative",zIndex:1},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",fontFamily:"var(--font-sans)"},children:[r.jsxs("thead",{children:[r.jsxs("tr",{children:[R&&r.jsx("th",{rowSpan:dt?2:1,style:{width:Ee,minWidth:Ee,padding:"10px 10px",textAlign:"center",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",borderRight:"1px solid rgba(52, 58, 64, 0.04)",position:"sticky",top:0,zIndex:11,boxSizing:"border-box",verticalAlign:"middle"},children:r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",lineHeight:0},children:r.jsx(Be,{checked:ze,indeterminate:zt,onToggle:Et,ariaLabel:"Select all rows on this page"})})}),r.jsx(w.SortableContext,{items:x,strategy:w.horizontalListSortingStrategy,children:A.map(e=>r.jsx(It,{column:e,isHeaderRow:!0},`header-${v(e)}`))})]}),dt&&r.jsx("tr",{children:A.map(e=>{const t=v(e),s=Ie(t,e.width),o=e.filterable===!0;return r.jsx("th",{style:{padding:"8px 14px",background:"var(--primary-foreground)",borderBottom:"1px solid rgba(52, 58, 64, 0.10)",position:"sticky",top:"41px",zIndex:10,width:s,fontFamily:"var(--font-sans)"},children:o?r.jsxs("div",{style:{position:"relative"},children:[r.jsx("input",{type:"text",placeholder:"Filter...",value:te[t]||"",onChange:n=>{n.stopPropagation(),lt(t,n.target.value)},onKeyDown:n=>n.stopPropagation(),onMouseDown:n=>n.stopPropagation(),style:{width:"100%",padding:"4px 8px 4px 26px",fontSize:"11.5px",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",background:"var(--primary-foreground)",color:"rgba(30, 33, 37, 0.78)",outline:"none",fontFamily:"var(--font-sans)"},onFocus:n=>{n.target.style.borderColor="rgba(231, 212, 162, 0.65)",n.target.style.background="var(--primary-foreground)"},onBlur:n=>{n.target.style.borderColor="rgba(52, 58, 64, 0.16)",n.target.style.background="var(--primary-foreground)"},autoComplete:"off"}),r.jsx(M.Filter,{size:11,style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",color:"rgba(30, 33, 37, 0.42)",pointerEvents:"none"}})]}):r.jsx("div",{className:"h-[34px]"})},`filter-${t}`)})})]}),r.jsx("tbody",{children:!E&&G.length===0?r.jsx("tr",{children:r.jsx("td",{colSpan:A.length+(R?1:0),style:{padding:"32px",textAlign:"center",color:"rgba(30, 33, 37, 0.42)",fontSize:"12px",fontFamily:"var(--font-sans)"},children:"No results found"})}):!E&&G.length>0?G.map((e,t)=>{const s=Me(e,t),o=R&&J.has(s);return r.jsxs("tr",{"data-row-id":e.id||t,style:{borderBottom:"1px solid rgba(52, 58, 64, 0.08)",cursor:u?"pointer":"default",transition:"background 0.15s ease",background:o?"rgba(231, 212, 162, 0.18)":"transparent"},onClick:u?n=>{n.stopPropagation(),u(e,t)}:void 0,onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.12)"},onMouseLeave:n=>{n.currentTarget.style.background=o?"rgba(231, 212, 162, 0.18)":"transparent"},children:[R&&r.jsx("td",{onClick:n=>n.stopPropagation(),style:{width:Ee,minWidth:Ee,padding:"10px 10px",textAlign:"center",verticalAlign:"middle",borderRight:"1px solid rgba(52, 58, 64, 0.04)",boxSizing:"border-box"},children:r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",lineHeight:0},children:r.jsx(Be,{checked:o,onToggle:()=>at(s),ariaLabel:"Select row"})})}),A.map(n=>{const l=v(n),a=Ie(l,n.width),d=e[l],N=n.render?n.render(d,e):d,P=a&&a!=="auto",he=typeof N=="string"&&N.trim()!=="",ue=P&&he,K=ue?r.jsx(me,{content:N,children:N}):N;return r.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:a,fontFamily:"var(--font-sans)",...ue&&{maxWidth:a||"200px"}},children:K},l)})]},t)}):null})]})})]}),r.jsx(w.DragOverlay,{children:pt?r.jsx("div",{className:"bg-[var(--paper-high)] border border-[var(--border-strong)] rounded px-4 py-2 shadow-lg",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(M.GripVertical,{size:14,className:"text-[var(--text-faint)]"}),r.jsx("span",{className:"text-sm font-semibold text-[var(--text-ink)]",children:pt.label})]})}):null})]}):null,!S&&(be?C>0:Fe.length>0)&&r.jsx("div",{className:"border-t border-gray-200 rounded-b-[14px]",style:{backgroundColor:"var(--primary-foreground)"},children:r.jsx(gt.Pagination,{page:Re,pageSizeOptions:[5,10,20,50,100],pageSize:ye,totalCount:be?C:Fe.length,currentDataLength:G.length,onPageChange:ve,onPageSizeChange:W?e=>{Ue(e),ve(1)}:e=>{Ue(e),ve(1)},showPageSizeSelector:!0})})]})}function Gt({dateRangePicker:p,onWeekToDate:c,exportConfig:j,filterChipsConfig:u,trailingActions:C}){const[z,$]=i.useState(!1),D=i.useRef(null),W=i.useRef(null);i.useEffect(()=>{const g=f=>{W.current&&!W.current.contains(f.target)&&D.current&&!D.current.contains(f.target)&&$(!1)};if(z)return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[z]);const U=()=>{$(g=>!g)},I=g=>{$(!1),j!=null&&j.onExport&&j.onExport(g)},L=(()=>{if(!(u!=null&&u.filters))return!1;const g=u.filters,f=u.customFilters||[],E=Object.entries(g).some(([h,F])=>!!(Array.isArray(F)&&F.length||typeof F=="string"&&F.trim()!==""||F&&typeof F=="object"&&(F.min!=null||F.max!=null))),b=f.some(h=>h.active);return E||b})();return r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c&&r.jsxs("button",{onClick:c,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:[r.jsx(M.CalendarClock,{size:16}),r.jsx("span",{children:"Week to Date"})]}),p&&r.jsx(i.Suspense,{fallback:r.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:[r.jsx(M.CalendarClock,{size:16}),r.jsx("span",{children:"Loading..."})]}),children:p}),j&&r.jsxs("div",{className:"relative",children:[r.jsxs("button",{ref:D,onClick:U,disabled:j.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(M.Download,{size:16}),r.jsx("span",{children:j.isExporting?"Exporting...":"Export"})]}),r.jsx(M.ChevronDown,{size:16})]}),z&&r.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:(j.types||["csv"]).map(g=>r.jsxs("button",{onClick:()=>I(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))})]}),(L||C)&&r.jsxs(r.Fragment,{children:[L&&r.jsx("div",{className:"h-9 mt-1 w-px bg-gray-300 flex-shrink-0"}),r.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[L&&u&&r.jsx(gt.CustomFilterChips,{filters:u.filters,onChange:u.onChange,onClear:u.onClear,customFilters:u.customFilters||[],fieldOptions:u.fieldOptions||{}}),C&&r.jsx("div",{className:"flex-shrink-0",children:C})]})]})]})}function Jt({title:p="Summary stats",stats:c=[],columns:j=2}){return r.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},children:[r.jsx("div",{className:"text-[11px] tracking-[0.14em] uppercase mb-[10px]",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650},children:p}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${j}, minmax(0, 1fr))`,gap:"10px"},children:c.map((u,C)=>r.jsxs("div",{style:{position:"relative",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",background:"rgba(255, 255, 255, 0.72)",padding:u.accentColor?"10px 10px 10px 14px":"10px",minHeight:"62px",display:"flex",flexDirection:"column",justifyContent:"center",gap:"5px",overflow:"hidden"},children:[u.accentColor&&r.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"4px",background:u.accentColor,borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px"}}),r.jsx("div",{className:"text-[10px] tracking-[0.14em] uppercase",style:{color:"rgba(30, 33, 37, 0.42)",fontWeight:650,lineHeight:1.1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),r.jsx("div",{style:{fontSize:"13px",color:u.valueStyle==="muted"?"rgba(30, 33, 37, 0.56)":"rgba(30, 33, 37, 0.78)",fontWeight:700,lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:u.valueStyle==="mono"?"ui-monospace, monospace":"inherit"},children:u.value}),u.subtext&&r.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.52)",lineHeight:1.15,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.subtext})]},C))})]})}exports.DataTable2=Ke.DataTable2;exports.DataTableFilters=Ke.DataTableFilters;exports.DataTable=Xt;exports.DataTableFilters2=Gt;exports.SummaryStatsPanel=Jt;
2
2
  //# sourceMappingURL=data.cjs.js.map