PageSourceSearch

https://app.meetcosmo.ai/_next/static/chunks/2499.a319e7282efb3cc8.js

js meetcosmo.ai collected 2026-10-05 15:23:53 UTC 9,767 bytes, 1 lines download raw bytes

1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="88f43aab-e86f-425f-a5cd-ee074ef7c31e",e._sentryDebugIdIdentifier="sentry-dbid-88f43aab-e86f-425f-a5cd-ee074ef7c31e")}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2499],{85685:function(e,t){t.Z=e=>{let t=new Date(e);if("Invalid Date"===t.toString()&&"Invalid Date"===(t=new Date(e+"Z")).toString())return"";let n=new Date;if(t.toLocaleDateString()===n.toLocaleDateString())return t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone});let a=(n.getTime()-t.getTime())/864e5;return a<5&&a>=0?t.toLocaleDateString(void 0,{weekday:"long",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}):t.toLocaleDateString(void 0,{month:"short",day:"numeric",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone})}},64639:function(e,t,n){n.d(t,{Z:function(){return a}});let a=(0,n(27132).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},53612:function(e,t,n){n.d(t,{Z:function(){return a}});let a=(0,n(27132).Z)("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},67340:function(e,t,n){n.d(t,{Z:function(){return a}});let a=(0,n(27132).Z)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},52499:function(e,t,n){n.r(t),n.d(t,{default:function(){return w}});var a=n(16372),r=n(83149),s=n(45361),l=n.n(s),o=n(47418),i=n(67340),c=n(5872),d=n(53612),u=n(64639),m=n(85685),p=n(54958),f=n(50896),h=n(15942),g=n(88064);let x=e=>e?"@".concat(e):null,v=e=>e?(0,a.jsxs)("div",{className:"flex items-center gap-2","data-sentry-component":"formatInstagramDisplayName","data-sentry-source-file":"chat-table.tsx",children:[(0,a.jsx)(o.Z,{className:"w-[20px] h-[20px] text-foreground","data-sentry-element":"Instagram","data-sentry-source-file":"chat-table.tsx"}),(0,a.jsx)("span",{children:e})]}):null,y=e=>e?(0,a.jsxs)("div",{className:"flex items-center gap-2","data-sentry-component":"formatWhatsAppDisplayName","data-sentry-source-file":"chat-table.tsx",children:[(0,a.jsx)(f.y,{className:"w-[20px] h-[20px] text-foreground","data-sentry-element":"WhatsAppIcon","data-sentry-source-file":"chat-table.tsx"}),(0,a.jsx)("span",{children:e})]}):null,b=e=>e?(0,a.jsxs)("div",{className:"flex items-center gap-2","data-sentry-component":"formatAdminDisplayName","data-sentry-source-file":"chat-table.tsx",children:[(0,a.jsx)(i.Z,{className:"w-[20px] h-[20px] text-foreground","data-sentry-element":"Shield","data-sentry-source-file":"chat-table.tsx"}),(0,a.jsx)("span",{children:e})]}):null,_=e=>e?(0,a.jsxs)("div",{className:"flex items-center gap-2","data-sentry-component":"formatWebDisplayName","data-sentry-source-file":"chat-table.tsx",children:[(0,a.jsx)(c.Z,{className:"w-[20px] h-[20px] text-foreground","data-sentry-element":"Globe","data-sentry-source-file":"chat-table.tsx"}),(0,a.jsx)("span",{children:e})]}):null;function w(e){let{data:t,handleClick:n,pagination:s,accessToken:o,phoneNum:i,messages:c=[],sendMessage:f,getOlderMessages:w,isBotEnabled:j,setIsBotEnabled:N,endOfConvo:k,setSelectedChat:S,searchQuery:Z,activeFilters:D,sourceFilters:C={instagram:!1,whatsapp:!1,web:!1},selectedChat:I,showCampaignConvos:q=!1,showMerchantConvos:E=!1,isByNumber:L}=e,T=(0,r.useCallback)(e=>{var t;return e.ig_profile_name||e.ig_username?"instagram":(null===(t=e.phone_number)||void 0===t?void 0:t.startsWith("web_"))?"web":"whatsapp"},[]),A=(0,r.useCallback)(e=>C.instagram||C.whatsapp||C.web?e.filter(e=>C[T(e)]):e,[C,T]),[R,W]=(0,r.useState)(!1),[F,M]=(0,r.useState)(()=>A(t)),[O,U]=(0,r.useState)(!1),[V,z]=(0,r.useState)(!0),[B,G]=(0,r.useState)(1),H=(0,r.useRef)(null),P=(0,r.useRef)(!1),J=e=>{console.log("Card clicked, chat:",e),n(e),L||S(e)},K=async()=>
1{if(P.current||O||!V)return;P.current=!0,U(!0);let e=B+1;try{let t=new URLSearchParams({n:s.per_page.toString(),start:((e-1)*s.per_page).toString(),order_by:"last_message_sent_at"});(null==Z?void 0:Z.trim())&&t.append("search",Z.trim()),D.support?t.append("notification_filter","live_agent"):D.question&&t.append("notification_filter","user_question"),E&&t.append("include_merchant_user_conversations","true"),q&&t.append("include_campaign_conversations","true");let n=await fetch("".concat("https://cosmo-backend-web-development.onrender.com","/api/v1/conversations?").concat(t.toString()),{headers:{token:o}}),{conversations:a}=await n.json();(null==a?void 0:a.length)>0?(M(e=>{let t=new Set(e.map(e=>e.id)),n=a.filter(e=>!t.has(e.id));return A([...e,...n])}),G(e),z(a.length===s.per_page)):z(!1)}catch(e){console.error("Error loading more conversations:",e)}finally{P.current=!1,U(!1)}},Q=(0,r.useCallback)(l()(()=>{if(H.current){let{scrollTop:e,scrollHeight:t,clientHeight:n}=H.current;t-e<=1.2*n&&K()}},200),[K]);return((0,r.useEffect)(()=>{if(!R)return;let e=H.current;if(e)return e.addEventListener("scroll",Q),()=>{e.removeEventListener("scroll",Q),Q.cancel()}},[R,Q]),(0,r.useEffect)(()=>{G(1),z(!0),M(A(t)),P.current=!1},[Z,D.support,D.question,C.instagram,C.whatsapp,C.web,q,E,t,A]),(0,r.useEffect)(()=>{if(W(!0),i&&(null==t?void 0:t.length)){let e=decodeURIComponent(i).replace(/\s+/g,""),n=t.find(t=>{var n;return((null===(n=t.phone_number)||void 0===n?void 0:n.replace(/\s+/g,""))||"")===e});n?(console.log("Setting initial chat:",n),console.log("Matched phone:",e,"with:",n.phone_number),J(n)):(console.log("No initial chat found for phone number:",e),console.log("Available phone numbers:",t.map(e=>e.phone_number)))}},[t,i,J]),R)?(0,a.jsxs)("div",{ref:H,className:"h-full overflow-y-auto overflow-x-hidden px-2 custom-scrollbar","data-sentry-component":"ChatTable","data-sentry-source-file":"chat-table.tsx",children:[(null==Z?void 0:Z.trim())&&(0,a.jsx)("div",{className:"px-2 py-1 mb-2",children:(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Showing results for “",(0,a.jsx)("span",{className:"font-medium",children:Z.trim()}),"”"]})}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-2 pt-2",children:0===F.length?(0,a.jsx)("div",{className:"flex items-center justify-center h-full w-full min-h-full",children:(0,a.jsx)("span",{className:"text-muted-foreground",children:"No conversations yet!"})}):(0,a.jsxs)(a.Fragment,{children:[F.map(e=>{var t,n,r,s,l,o,i;return(0,a.jsxs)(g.Zb,{className:(0,p.cn)("relative flex flex-col gap-2 p-2 cursor-pointer transition-colors rounded-md","hover:bg-muted dark:hover:bg-secondary",(null==I?void 0:I.id)===e.id&&"bg-muted dark:bg-secondary"),onClick:()=>J(e),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)("div",{className:(0,p.cn)("font-medium text-xs",(null==I?void 0:I.id)===e.id?"text-foreground dark:text-white":"text-foreground"),children:e.is_merchant_user?b(null!==(r=null!==(n=e.name)&&void 0!==n?n:e.profile_name)&&void 0!==r?r:"null"):e.ig_profile_name?v(e.ig_profile_name):(null===(t=e.phone_number)||void 0===t?void 0:t.startsWith("web_"))?_(null!==(l=null!==(s=e.name)&&void 0!==s?s:e.profile_name)&&void 0!==l?l:"null"):y(null!==(i=null!==(o=e.name)&&void 0!==o?o:e.profile_name)&&void 0!==i?i:"null")})}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,m.Z)(e.last_message_sent_at||"")})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground line-clamp-1",children:e.ig_username?x(e.ig_username):e.phone_number}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[e.is_merchant_user&&(0,a.jsx)(h.C,{variant:"secondary",children:"Admin"}),e.is_campaign&&(0,a.jsx)(h.C,{variant:"secondary",children:"Campaign"}),e.user_question_request&&(0,a.jsx)(h.C,{variant:"secondary",className:"bg-yellow-500/10 text-yellow-500 hover:bg-yellow-500/20 border-yellow-500/20",children:(0,a.jsx)(d.Z,{className:"h-3 w-3"})}),e.user_support_request_reason&&(0,a.jsxs)(h.C,{variant:"secondary",className:"bg-red-500/10 text-red-500 hover:bg-red-500/20 border-red-500/20",children:[(0,a.jsx)(u.Z,{className:"h-3 w-3 mr-1"}),e.user_support_request_type||"Support Request"]})]})]})]},e.id)}),O&&(0,a.jsx)("div",{className:"w-full py-4 text-center text-sm text-muted-foreground",children:"Loading more conversations..."}),!O&&V&&F.length>=s.per_page&&(0,a.jsx)("div",{className:"h-4"})]})})]}):null}},15942:function(e,t,n){n.d(t,{C:function(){return o}});var a=n(16372);n(83149);var r=n(93100),s=n(54958);let l=(0,r.j)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function o(e){let{className:t,variant:n,...r}=e;return(0,a.jsx)("div",{className:(0,s.cn)(l({variant:n}),t),...r,"data-sentry-component":"Badge","data-sentry-source-file":"badge.tsx"})}}}]);

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.