1import{cQ as Ne,cN as we,cW as ve,cE as _e,cn as d,cx as c,cP as Ce,c5 as e,z as Se,az as M,ar as z,m as Pe,aq as $e,d as J,ba as Fe,aG as Ee,aC as Te,Y as G,o as H,R as Le,af as Re,ad as De}from"./index-BUmD633_.js";import{g as qe}from"./ticketAging-CFwhOili.js";import{g as Ie}from"./ticketClosingTime-CS2zE4AV.js";import{m as Be,a as Ue}from"./crmPropertyMappers-CMo9A5an.js";import{b as _,L as Ae,o as Oe}from"./crmBadges-CUOmyiJi.js";import"./prospectLifecycle-BbnbKfrp.js";const Me={low:"bg-gray-100 text-gray-800",medium:"bg-yellow-100 text-yellow-800",high:"bg-orange-100 text-orange-800",urgent:"bg-red-100 text-red-800"},We=()=>{const{contactId:f}=Ne(),C=we(),[Q]=ve(),{profile:k}=_e(),[r,V]=d.useState(null),[W,S]=d.useState(!0),[P,j]=d.useState(null),[g,Y]=d.useState([]),[$,F]=d.useState([]),[E,T]=d.useState([]),[N,K]=d.useState([]),[X,L]=d.useState(!1),[y,Z]=d.useState(!0),[m,ee]=d.useState(0),[x,R]=d.useState(1),o=10,[D,te]=d.useState([]),[q,re]=d.useState([]),[w,ae]=d.useState(!1);d.useEffect(()=>{f&&se(),ie()},[f]),d.useEffect(()=>{r!=null&&r.id&&(de(),ne())},[r==null?void 0:r.id]),d.useEffect(()=>{r&&y&&le()},[r==null?void 0:r.hubspot_id,r==null?void 0:r.external_id,y,x]),d.useEffect(()=>{r!=null&&r.id&&ce()},[r==null?void 0:r.id]);const se=async()=>{try{S(!0),j(null);const{data:t,error:a}=await c.from("crm_contacts").select("*").eq("id",f).maybeSingle();if(a)throw a;if(!t){j("Contact not found");return}V({...Be(t),raw_data:t.raw_data??null})}catch(t){const a=t instanceof Error?t.message:"Failed to fetch contact";j(a)}finally{S(!1)}},de=async()=>{if(r!=null&&r.id)try{const{data:t}=await c.from("crm_property_contacts").select("role, crm_properties(id, sabeeapp_hotel_id, hubspot_id, name, industry, sabeeapp_status, origin)").eq("contact_id",r.id).eq("is_current",!0),a=[];t&&t.forEach(s=>{const n=s.crm_properties;if(!n)return;const l=Ue(n);a.push({id:l.id,hubspot_id:l.hubspot_id,external_id:l.external_id,name:l.name,industry:l.industry,status:l.status,origin:l.origin,role:s.role})}),Y(a)}catch(t){console.error("Failed to fetch property links:",t)}},ne=async()=>{if(r!=null&&r.id)try{const{data:t}=await c.from("crm_contact_identities").select("kind, value").eq("contact_id",r.id).order("kind");F(t||[])}catch(t){console.error("Failed to fetch contact identities:",t),F([])}},ie=async()=>{try{const{data:t}=await c.from("hubspot_ticket_pipelines").select("stage_id, stage_label, is_closed");t&&te(t)}catch(t){console.error("Failed to fetch pipeline stages:",t)}},le=async()=>{if(r)try{L(!0);const t="id, hubspot_id, subject, status, priority, category, created_at, closed_date, source, sabeeapp_closed_at, sabeeapp_closing_duration_seconds",a=c.from("hubspot_tickets").select(t).eq("crm_contact_id",r.id),s=r.hubspot_id?c.from("hubspot_tickets").select(t).eq("contact_id",r.hubspot_id).is("crm_contact_id",null):Promise.resolve({data:[],error:null}),n=g.map(i=>i.id),l=n.length>0?c.from("hubspot_tickets").select(t).in("property_id",n):Promise.resolve({data:[],error:null}),u=[];for(const i of g)i.hubspot_id&&u.push(i.hubspot_id),i.external_id&&u.push(i.external_id);const ue=u.length>0?c.from("hubspot_tickets").select(t).in("company_id",u).is("property_id",null):Promise.resolve({data:[],error:null}),[pe,fe,ke,je]=await Promise.all([a,s,l,ue]),A=new Set,h=[],p=i=>{(i||[]).forEach(b=>{A.has(b.hubspot_id)||(A.add(b.hubspot_id),h.push(b))})};p(pe.data||[]),p(fe.data||[]),p(ke.data||[]),p(je.data||[]),h.sort((i,b)=>new Date(b.created_at).getTime()-new Date(i.created_at).getTime()),ee(h.length),K(h);const O=(x-1)*o;T(h.slice(O,O+o))}catch(t){console.error("Failed to fetch tickets:",t)}finally{L(!1)}},ce=async()=>{if(r!=null&&r.id)try{const{data:t}=await c.from("contact_segment_members").select("contact_segments!segment_id(id, name, color)").eq("contact_id",r.id),a=[];t&&t.forEach(s=>{const n=s.contact_segments;n&&a.push(n)}),re(a)}catch(t){console.error("Failed to fetch segments:",t)}},v=()=>{const t=new URLSearchParams;Q.forEach((s,n)=>{t.set(n,s)});const a=t.toString();C(`/crm-contacts${a?`?${a}`:""}`)},I=t=>{if(t.name)return t.name;
1const a=[t.firstname,t.lastname].filter(Boolean);return a.length>0?a.join(" "):"Unnamed Contact"},xe=t=>{var a,s;return t.name?t.name[0].toUpperCase():(((a=t.firstname)==null?void 0:a[0])||((s=t.lastname)==null?void 0:s[0])||"?").toUpperCase()},B=t=>{if(!t)return e.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"});const a=t.toLowerCase();return a==="active"||a==="customer"?e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/40 text-green-800 dark:text-green-200",children:t}):a==="inactive"||a==="churned"||a==="cancelled"?e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-100",children:t}):e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-200",children:t})},oe=t=>t==="client"?e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/40 text-green-800 dark:text-green-200",children:"Client"}):t==="prospect"?e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-amber-100 dark:bg-amber-900/40 text-amber-800 dark:text-amber-200",children:"Prospect"}):e.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"}),ge=t=>{if(!t)return"-";const a=D.find(s=>s.stage_id===t);return a?a.stage_label:t},me=t=>{if(!t)return"bg-gray-100 text-gray-800";const a=D.find(s=>s.stage_id===t);return a?a.is_closed?"bg-green-100 text-green-800":"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"},ye=t=>t&&Me[t.toLowerCase()]||"bg-gray-100 text-gray-800",he=t=>t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"-",U=t=>t?new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-";if(d.useEffect(()=>{if(N.length>0){const t=(x-1)*o;T(N.slice(t,t+o))}},[x,N]),Ce({title:r?I(r):"Contact"}),W)return e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})})});if(P&&!r)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Se,{className:"w-16 h-16 mx-auto text-red-500 mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-50 mb-2",children:"Contact Not Found"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6",children:P}),e.jsxs("button",{onClick:v,className:"inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:[e.jsx(M,{className:"w-5 h-5 mr-2"}),"Back to Contacts"]})]})});if(!r)return null;const be=I(r);return e.jsxs("div",{className:"p-6",children:[e.jsxs("nav",{className:"flex items-center text-sm text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-4",children:[e.jsx("button",{onClick:v,className:"hover:text-gray-700 dark:text-gray-200 transition-colors",children:"Contacts"}),e.jsx("span",{className:"mx-2",children:"/"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-50 font-medium",children:be})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"w-14 h-14 bg-green-100 dark:bg-green-900/40 rounded-full flex items-center justify-center mr-4 flex-shrink-0",children:e.jsx("span",{className:"text-green-600 dark:text-green-300 font-bold text-xl",children:xe(r)})}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsx(_,{origin:r.origin||r.source})}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300 mt-0.5",children:["ID: ",r.sabeeapp_user_id||r.hubspot_id||"â"]})]})]}),e.jsxs("button",{onClick:v,className:"inline-flex items-center px-4 py-2 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700/60 dark:bg-gray-900 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 rounded-lg transition-colors",children:[e.jsx(M,{className:"w-5 h-5 mr-2"}),"Back"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Identity"})}),e.jsx("div",{className:"px-4 py-3",children:e.jsxs("dl",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Origin"}),e.jsx("dd",{children:e.jsx(_,{origin:r.origin||r.source})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Status"}),e.jsx("dd",{children:r.status?B(r.status):r.lifecycle_override?e.jsx(Ae,{stage:r.lifecycle_override}):e.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Client Type"}),e.jsx("dd",{children:oe(r.client_status)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Job Title"}),e.jsx("dd",{className:"text-sm text-gray-900 dark:text-gray-50",children:r.job_title?e.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded text-xs font-medium bg-blue-50 dark:bg-blue-950/30 text-blue-700 dark:text-blue-300 border border-blue-100",children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5 flex-shrink-0"}),r.job_title]}):e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"-"})})]}),r.linkedin_url&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"LinkedIn"}),e.jsx("dd",{children:e.jsx("a",{href:r.linkedin_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dar
1k:text-blue-300 hover:underline",children:r.linkedin_url})})]}),r.role&&e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Property role"}),e.jsxs("dd",{className:"text-sm text-gray-900 dark:text-gray-50 flex items-center",children:[e.jsx(z,{className:"w-4 h-4 mr-1.5 text-gray-400 dark:text-gray-500 flex-shrink-0"}),r.role]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Synced"}),e.jsx("dd",{className:"text-sm text-gray-900 dark:text-gray-50",children:U(r.synced_at)})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Contact Details"})}),e.jsx("div",{className:"px-4 py-3",children:e.jsxs("dl",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Email"}),r.email?e.jsx("dd",{children:e.jsxs("a",{href:`mailto:${r.email}`,className:"text-sm text-blue-600 dark:text-blue-300 hover:text-blue-800 dark:text-blue-200 flex items-center",children:[e.jsx(Pe,{className:"w-4 h-4 mr-2 flex-shrink-0"}),r.email]})}):e.jsx("dd",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 mb-1",children:"Phone"}),r.phone?e.jsx("dd",{children:e.jsxs("a",{href:`tel:${r.phone}`,className:"text-sm text-gray-900 dark:text-gray-50 flex items-center hover:text-blue-600 dark:text-blue-300 transition-colors",children:[e.jsx($e,{className:"w-4 h-4 mr-2 text-gray-400 dark:text-gray-500 flex-shrink-0"}),r.phone]})}):e.jsx("dd",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Properties"}),g.length>0&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-200",children:g.length})]})}),e.jsx("div",{className:"px-4 py-3",children:g.length===0?e.jsxs("p",{className:"text-sm text-gray-400 dark:text-gray-500 flex items-center",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),"No properties linked"]}):e.jsx("div",{className:"space-y-2",children:g.map(t=>e.jsxs("div",{className:"flex items-center gap-3 py-1.5 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsx(J,{className:"w-4 h-4 text-gray-400 dark:text-gray-500 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(Fe,{to:`/crm-properties/${t.id}`,className:"text-sm font-medium text-blue-600 dark:text-blue-300 hover:text-blue-800 dark:hover:text-blue-200 transition-colors truncate block",children:t.name||"Unnamed property"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.role&&e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:t.role}),t.industry&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 dark:text-gray-500",children:t.industry}),B(t.status),e.jsx(_,{origin:t.origin})]})]})]},t.id))})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Identities"})}),e.jsx("div",{className:"px-4 py-3",children:$.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No alternate identities"}):e.jsx("dl",{className:"space-y-2",children:$.map((t,a)=>e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("dt",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase w-24 shrink-0",children:t.kind}),e.jsx("dd",{className:"text-gray-900 dark:text-gray-50 break-all",children:t.value})]},`${t.kind}-${a}
1`))})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Ee,{className:"w-4 h-4 mr-2 text-gray-500 dark:text-gray-400 dark:text-gray-500"}),e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Segments"})]})}),e.jsx("div",{className:"px-4 py-3",children:q.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No segments"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium",style:{backgroundColor:t.color+"22",color:t.color,border:`1px solid ${t.color}44`},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:t.color}}),t.name]},t.id))})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsxs("button",{onClick:()=>Z(!y),className:"w-full px-4 py-3 flex items-center justify-between bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-700 dark:bg-gray-800 transition-colors border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(Te,{className:"w-5 h-5 mr-2 text-gray-600 dark:text-gray-300"}),e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Tickets"}),m>0&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 dark:bg-red-900/40 text-red-800 dark:text-red-200",children:m})]}),y?e.jsx(G,{className:"w-5 h-5 text-gray-500 dark:text-gray-400 dark:text-gray-500"}):e.jsx(H,{className:"w-5 h-5 text-gray-500 dark:text-gray-400 dark:text-gray-500"})]}),y&&e.jsx("div",{className:"px-4 py-3",children:X?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Le,{className:"w-6 h-6 animate-spin text-gray-400 dark:text-gray-500"})}):E.length===0?e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 dark:text-gray-500 text-center py-4",children:"No tickets found for this contact"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 w-80",children:"Subject"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500",children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500",children:"Priority"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500",children:"Category"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500 whitespace-nowrap",children:"Created"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 dark:text-gray-500",children:"Age"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:E.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/60 dark:bg-gray-900 cursor-pointer",onClick:()=>C(`/crm-tickets/${t.hubspot_id}`),children:[e.jsxs("td",{className:"px-3 py-2 w-80 max-w-xs",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-50 hover:text-red-600 dark:text-red-300 transition-colors",children:t.subject||"No Subject"}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-0.5",children:["ID: ",t.hubspot_id]})]}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap",children:t.status?e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${me(t.status)}`,children:ge(t.status)}):e.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap",children:t.priority?e.jsxs("span",{className:`px-2 py-1 text-xs font-medium rounded-full flex items-center w-fit ${ye(t.priority)}`,children:[e.jsx(Re,{className:"w-3 h-3 mr-1"}),he(t.priority)]}):e.jsx("span",{className:"text-sm text-gray-400 dark:text-gray-500",children:"-"})}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap text-sm text-gray-900 dark:text-gray-50",children:t.category||"-"}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap text-sm text-gray-900 dark:text-gray-50",children:U(t.created_at)}),e.jsx("td",{className:"px-3 py-2 whitespace-nowrap",children:(()=>{const a=Ie(t);if(a)return e.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-800",title:"Closing time",children:a.label});const s=qe(t.created_at,t.source==="sabeeapp"?t.sabeeapp_closed_at??null:t.closed_date);return e.jsx("span",{className:`inline-flex items-center px-2 py-1 text-xs font-medium rounded-full ${s.bgClass} ${s.colorClass}`,children:s.label})})()})]},t.id))})]})}),m>o&&e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-200",children:["Showing ",(x-1)*o+1," to"," ",Math.min(x*o,m)," of ",m]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{onClick:()=>R(t=>Math.max(1,t-1)),disabled:x===1,className:"px-3 py-1 border border-gray-300 dark:border-gray-600 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50 dark:hover:bg-gray-700/60 dark:bg-gray-900",children:"Previous"}),e.jsx("button",{onClick:()=>R(t=>t+1),disabled:x*o>=m,className:"px-3 py-1 border border-gray-300 dark:border-gray-600 rounded text-sm disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50 dark:hover:bg-gray-700/60 dark:bg-gray-900",children:"Next"})]})]})]})})]}),(k==null?void 0:k.role)==="admin"&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsxs("button",{onClick:()=>ae(!w),className:"w-full px-4 py-3 flex items-center justify-between bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-700 dark:bg-gray-800 transition-colors border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(De,{className:"w-5 h-5 mr-2 text-gray-600 dark:text-gray-300"}),e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Raw Data"}),e.jsx("span",{className:"ml-2 text-xs text-gray-400 dark:text-gray-500",children:"(Admin only)"})]}),w?e.jsx(G,{className:"w-5 h-5 text-gray-500 dark:text-gray-400 dark:text-gray-500"}):e.jsx(H,{className:"w-5 h-5 text-gray-500 dark:text-gray-400 dark:text-gray-500"})]}),w&&e.jsx("div",{className:"px-4 py-3",children:e.jsx("pre",{className:"text-xs bg-gray-50 dark:bg-gray-900 rounded-lg p-4 overflow-auto max-h-96 text-gray-700 dark:text-gray-200",children:JSON.stringify(r.raw_data,null,2)})})]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 dark:text-gray-500 text-center py-2",children:["Last synced: ",new Date(r.synced_at).toLocaleStr
1ing()," ⢠Origin: ",Oe(r.origin||r.source)]})]})]})};export{We as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.