PageSourceSearch

https://app.wonderchat.io/_next/static/chunks/pages/analytics-23d1967e5d6af974.js

js wonderchat.io collected 2026-09-24 17:15:08 UTC 49,155 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4583],{44813:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/analytics",function(){return t(38991)}])},25244:function(e,n,t){"use strict";t.d(n,{Q:function(){return p}});var s=t(85893),o=t(59007),i=t(27239),r=t(48783),a=t(81136),l=t(71293),d=t(13990),c=t(22757),u=t(33299),h=t(11163),x=t(99893),g=t(67294),m=t(39157);let p=(e,n)=>{let t=n=>{var t;let m=(0,h.useRouter)(),{data:p,status:b}=(0,u.useSession)(),j=(0,g.useRef)(!1),f=o.S.chatbot.claimTrialChatbot.useMutation({onSuccess:e=>{var n;let t="true"===m.query.onboardingV2;try{t||(t="true"===localStorage.getItem("onboardingV2")),localStorage.removeItem("trialChatbotId"),localStorage.removeItem("onboardingV2")}catch(e){}if(t){m.push("/onboarding?surveyOnly=true&onboardingV2=true&chatbotId=".concat(e.chatbotId));return}let s=(null==p?void 0:null===(n=p.user)||void 0===n?void 0:n.isOnboardingCompleted)?"/agents/settings/".concat(e.chatbotId):"/onboarding?surveyOnly=true&chatbotId=".concat(e.chatbotId);m.push(s)},onError:()=>{try{localStorage.removeItem("trialChatbotId")}catch(e){}}});return((0,g.useEffect)(()=>{var e;if(null==p?void 0:null===(e=p.user)||void 0===e?void 0:e.id){x.ZP.get_distinct_id()!==p.user.id&&x.ZP.identify(p.user.id,{email:p.user.email,name:p.user.name,subscription_type:p.user.subscriptionType});try{p.user.createdAt&&!localStorage.getItem("ph_account_created_at_set")&&(x.ZP.setPersonProperties(void 0,{account_created_at:p.user.createdAt}),localStorage.setItem("ph_account_created_at_set","1"))}catch(e){}}},[null==p?void 0:null===(t=p.user)||void 0===t?void 0:t.id]),(0,g.useEffect)(()=>{if(!(null==p?void 0:p.user)||j.current)return;let e=null,n=null,t=m.query.trialChatbotId,s=m.query.claimToken;if("string"==typeof t&&t)e=t,n="string"==typeof s?s:null;else try{e=localStorage.getItem("trialChatbotId"),n=localStorage.getItem("trialClaimToken")}catch(e){}e&&(j.current=!0,f.mutate({chatbotId:e,claimToken:null!=n?n:void 0}))},[p,m.query.trialChatbotId,m.query.claimToken]),(0,g.useEffect)(()=>{var e;p||"loading"===b||m.push("/auth/sign-in");let n=function(e,n){if("string"!=typeof e||!e)return null;try{let t=new URL(e,n);if(t.origin===n&&(t.pathname.startsWith("/workspace-v2/invite/")||t.pathname.startsWith("/workspace-v2/join/")))return"".concat(t.pathname).concat(t.search)}catch(e){}return null}(m.query.callbackUrl,window.location.origin);if(n){m.replace(n);return}let t="string"==typeof m.query.trialChatbotId&&!!m.query.trialChatbotId;if(!t)try{t=!!localStorage.getItem("trialChatbotId")}catch(e){}(!t||null==p||!p.user)&&((null==p?void 0:null===(e=p.user)||void 0===e?void 0:e.isOnboardingCompleted)||"loading"===b||"/onboarding"===m.pathname||m.push("/onboarding"))},[p,b,m]),f.isLoading)?(0,s.jsx)(i.M,{h:"100vh",flexDir:"column",children:(0,s.jsxs)(r.g,{spacing:4,children:[(0,s.jsx)(a.$,{size:"lg",color:"brand.500"}),(0,s.jsx)(l.x,{color:"gray.600",fontWeight:"medium",children:"Setting up your AI agent..."})]})}):p||"loading"!==b?(null==p?void 0:p.user)?p.user.isDisabled?(0,s.jsx)(i.M,{h:"calc(100vh - 60px)",flexDir:"column",children:(0,s.jsxs)(d.Z,{p:8,maxW:"600px",children:[(0,s.jsx)(c.X,{size:"lg",mb:4,color:"red.500",children:"Account Disabled"}),(0,s.jsx)(l.x,{children:"Your account has been disabled due to a late payment. Please contact support to resolve this issue."})]})}):(0,s.jsx)(e,{...n}):(0,s.jsx)(i.M,{h:"calc(100vh - 60px)",flexDir:"column",children:(0,s.jsx)(l.x,{children:"Redirecting you to sign in page ..."})}):(0,s.jsx)(i.M,{h:"calc(100vh - 60px)",flexDir:"column",children:(0,s.jsx)(l.x,{children:"Loading ..."})})};return t.getLayout=function(e){return(null==n?void 0:n.noLayout)?e:(0,s.jsx)(m.Z,{children:e})},t}},29355:function(e,n,t){"use strict";t.d(n,{y:function(){return g}});var s=t(85893),o=t(57747),i=t(61557),r=t(10991),a=t(40853),l=t(81136),d=t(99840),c=t(80510),u=t(4693),h=t(15115),x=t(64698);let g=e=>{let{data:n,columns:t,emptyMessage:g,isLoading:m,size:p="md",border:b=!1,caption:j,extraTableComponent:f,tableProps:v={},extraRows:y,rowProps:C}=e,S=new Map;for(let{key:e,render:n}of t)n&&e&&S.set(e,n);return(0,s.jsx)(o.xu,{...b&&{borderWidth:"thin",borderRadius:"lg",p:"2"},children:(0,s.jsx)(i.x,{children:(0,s.jsxs)(r.i,{fontSize:"sm",variant:"simple",size:p,...v,children:[j&&(0,s.jsx)(a.R,{children:j}),0===n.length&&(0,s.jsxs)(a.R,{w:"full",children:[m?(0,s.jsx)(l.$,{}):g||"No data to show",!!f&&!m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("br",{}),(0,s.jsx)("br",{}),f]})]}),(0,s.jsx)(d.h,{bgColor:"gray.50",children:(0,s.jsx)(c.Tr,{children:t.map(e=>{let{key:n,header:t,width:o}=e;return(0,s.jsx)(u.Th,{width:o,children:t},String(n))})})}),(0,s.jsxs)(h.p,{children:[n.map((e,n)=>(0,s.jsx)(c.Tr,{...null==C?void 0:C(e),children:t.map(n=>{var t,o;let{key:i,styleProps:r={}}=n;
1return(0,s.jsx)(x.Td,{maxW:"400px",wordBreak:"break-word",whiteSpace:"pre-wrap",...r,children:null!==(o=null===(t=S.get(i))||void 0===t?void 0:t(e))&&void 0!==o?o:String(e[i])},String(i))})},n)),y]})]})})})}},38991:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return eZ}});var s=t(85893),o=t(57747),i=t(5152),r=t.n(i);let a=r()(()=>Promise.all([t.e(2814),t.e(9596),t.e(9487)]).then(t.bind(t,9487)).then(e=>e.ResponsivePie),{loadableGenerated:{webpack:()=>[9487]},ssr:!1}),l=e=>{switch(e){case"WEBAPP":return"#4299E1";case"WHATSAPP":return"#48BB78";case"SLACK":return"#805AD5";case"MICROSOFT_TEAMS":return"#0078D4";default:return"#A0AEC0"}},d=e=>{switch(e){case"WEBAPP":return"Web App";case"WHATSAPP":return"WhatsApp";case"SLACK":return"Slack";case"MICROSOFT_TEAMS":return"MS Teams";default:return e}};function c(e){let{data:n}=e,t=n.reduce((e,n)=>e+n.count,0),i=n.map(e=>({id:e.type,label:d(e.type),value:e.count,percentage:(e.count/t*100).toFixed(1)}));return(0,s.jsx)(o.xu,{height:"200px",width:"100%",children:(0,s.jsx)(a,{data:i,tooltip:e=>{let{datum:n}=e;return(0,s.jsxs)("div",{style:{background:"white",padding:"9px 12px",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)"},children:[(0,s.jsxs)("strong",{children:[d(n.id),": "]}),n.value," (",n.data.percentage,"%)"]})},margin:{top:20,right:150,bottom:20,left:20},innerRadius:.4,padAngle:1,cornerRadius:4,activeOuterRadiusOffset:6,colors:e=>{let{id:n}=e;return l(n)},borderWidth:2,borderColor:{from:"color",modifiers:[["darker",.3]]},enableArcLinkLabels:!1,arcLabelsSkipAngle:30,arcLabelsTextColor:{from:"color",modifiers:[["darker",3]]},arcLabel:e=>e.data.percentage+"%",legends:[{anchor:"right",direction:"column",justify:!1,translateX:120,translateY:0,itemsSpacing:8,itemWidth:100,itemHeight:20,itemTextColor:"#333",itemDirection:"left-to-right",itemOpacity:1,symbolSize:14,symbolShape:"circle",effects:[{on:"hover",style:{itemTextColor:"#000"}}],data:i.map(e=>({id:e.id,label:"".concat(e.label," (").concat(e.percentage,"%)"),color:l(e.id)}))}]})})}var u=t(93677),h=t(93717),x=t(36948),g=t(75141),m=t(71293),p=t(48244),b=t(25694),j=t(13990),f=t(40607),v=t(32568),y=t(48783),C=t(93108),S=t(96854),w=t(55281),k=t(58166),D=t(34292),A=t(49289),T=t(78590),I=t(41664),R=t.n(I),z=t(67294),O=t(34052);let _="__unassigned__";function M(e){var n,t,i;let{agent:r,mode:a,pct:l,share:d}=e,c="resolved"===a?r.resolved:r.open,u=r.userId===_;return(0,s.jsxs)(o.xu,{position:"relative",borderRadius:"md",overflow:"hidden",children:[(0,s.jsx)(o.xu,{position:"absolute",top:0,bottom:0,left:0,width:"".concat(l,"%"),bg:u?"gray.100":"resolved"===a?"green.100":"orange.100",transition:"width 0.3s ease"}),(0,s.jsxs)(h.k,{position:"relative",align:"center",gap:2,px:2,py:"6px",children:[u?(0,s.jsx)(h.k,{boxSize:"24px",align:"center",justify:"center",borderRadius:"full",bg:"gray.200",color:"gray.500",flexShrink:0,children:(0,s.jsx)(x.J,{as:O.pBC,boxSize:3})}):(0,s.jsx)(g.q,{size:"xs",name:null!==(n=r.name)&&void 0!==n?n:void 0,src:null!==(t=r.image)&&void 0!==t?t:void 0}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"medium",color:u?"gray.500":"gray.800",noOfLines:1,flex:1,children:null!==(i=r.name)&&void 0!==i?i:"Unknown agent"}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"semibold",color:"gray.600",children:c}),(0,s.jsx)(m.x,{fontSize:"xs",color:"gray.400",w:"36px",textAlign:"right",children:"".concat(d,"%")})]})]})}function N(e){let{icon:n,iconColor:t,value:o,label:i,caption:r}=e;return(0,s.jsxs)(p.k,{px:4,_first:{pl:0},children:[(0,s.jsxs)(h.k,{align:"center",gap:1.5,mb:1,children:[(0,s.jsx)(x.J,{as:n,boxSize:3.5,color:t}),(0,s.jsx)(m.x,{fontSize:"sm",color:"gray.600",fontWeight:"medium",children:i})]}),(0,s.jsx)(b.J,{my:0,children:o}),(0,s.jsx)(m.x,{fontSize:"xs",color:"gray.500",children:r})]})}function W(e){let{children:n,dimmed:t,overlay:i}=e;return(0,s.jsxs)(j.Z,{borderRadius:"xl",variant:"outline",shadow:"lg",gridColumn:{base:"1 / 3",md:"span 6"},position:"relative",overflow:"hidden",children:[(0,s.jsxs)(f.e,{children:[(0,s.jsxs)(m.x,{fontSize:"md",fontWeight:"semibold",alignItems:"center",display:"flex",gap:"2",mb:"4",children:[(0,s.jsx)(x.J,{as:O.cZY,color:"brand.500"}),"Live chat",!t&&(0,s.jsx)(v.u,{placement:"top",label:"Counts live chats that started in the selected date range. Resolved, awaiting reply, and in conversation reflect each chat's current status.",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(o.xu,{opacity:t?.5:void 0,filter:t?"blur(3px) grayscale(1)":void 0,pointerEvents:t?"none":void 0,userSelect:t?"none":void 0,"aria-hidden":!!t||void 0,children:n})]}),i]})}function Z(e){let{chatbotId:n}=e;return(0,s.jsx)(h.k,{position:"absolute",inset:0,align:"center",justify:"center",p:6,bg:"whiteAlpha.600",children:(0,s.jsxs)(y.g,{spacing:3,bg:"white",borderWidth:"1px",borderColor:"gray.200",borderRadius:"xl",px:8,py:7,shadow:"md",textAlign:"center",maxW:"sm",children:[(0,s.jsx)(h.k,{boxSize:10,align:"center",justify:"center",borderRadius:"full",bg:"brand.50",children:(0,s.jsx)(x.J,{as:O.cZY,boxSize:5,color:"brand.500"})}),(0,s.jsx)(m.x,{fontSize:"md",fontWeight:"semibold",color:"gray.800",children:"Live chat is turned off"}),(0,s.jsx)(m.x,{fontSize:"sm",color:"gray.500",maxW:"17rem",children:"Enable it to let your team take over conversations and see resolution stats here."}),"all"!==n?(0,s.jsx)(C.z,{as:R(),href:"/agents/settings/".concat(n),size:"sm",colorScheme:"brand",variant:"solid",mt:1,children:"Enable live chat"}):(0,s.jsx)(m.x,{fontSize:"xs",color:"gray.400",mt:1,children:"Select a specific agent to enable it."})]})})}let L=[{userId:"a",name:"Agent",image:null,resolved:12,open:4},{userId:"b",name:"Agent",image:null,resolved:9,open:3},{userId:"c",name:"Agent",image:null,resolved:6,open:2}
1];function E(e){var n,t,i,r,a,l,d,c,u;let{data:x,isLoading:g,chatbotId:p}=e,[b,j]=(0,z.useState)("resolved"),{visibleAgents:f,hiddenCount:v}=(0,z.useMemo)(()=>{var e;let n=[...null!==(e=null==x?void 0:x.agents)&&void 0!==e?e:[]].sort((e,n)=>n[b]-e[b]).filter(e=>e[b]>0),t=n.slice(0,8);return{visibleAgents:t,hiddenCount:n.length-t.length}},[null==x?void 0:x.agents,b]);if(g)return(0,s.jsx)(W,{children:(0,s.jsx)(S.O,{height:"120px",borderRadius:"md"})});let y=!(null==x?void 0:x.liveChatEnabled),I={bgColor:"brand.500",color:"white",borderColor:"brand.500",_hover:{bgColor:"brand.300",borderColor:"brand.300"}},R=(y?0:"resolved"===b?null!==(n=null==x?void 0:x.unassignedResolved)&&void 0!==n?n:0:null!==(t=null==x?void 0:x.unassignedOpen)&&void 0!==t?t:0)>0?{userId:_,name:"resolved"===b?"Visitor resolved":"No agent yet",image:null,resolved:null!==(i=null==x?void 0:x.unassignedResolved)&&void 0!==i?i:0,open:null!==(r=null==x?void 0:x.unassignedOpen)&&void 0!==r?r:0}:null,E=y?L:[...f,...R?[R]:[]],F=E.reduce((e,n)=>Math.max(e,n[b]),0)||1,J=E.reduce((e,n)=>e+n[b],0)||1;return(0,s.jsx)(W,{dimmed:y,overlay:y?(0,s.jsx)(Z,{chatbotId:p}):null,children:(0,s.jsxs)(w.K,{direction:{base:"column",md:"row"},spacing:{base:6,md:0},divider:(0,s.jsx)(k.c,{borderColor:"gray.200",display:{base:"none",md:"block"}}),align:"stretch",children:[(0,s.jsx)(o.xu,{flex:{base:"1",md:"0 0 45%"},pr:{md:6},children:(0,s.jsxs)(D.U,{divider:(0,s.jsx)(k.c,{borderColor:"gray.200"}),align:"stretch",spacing:0,children:[(0,s.jsx)(N,{icon:O._rq,iconColor:"green.500",value:null!==(a=null==x?void 0:x.resolved)&&void 0!==a?a:0,label:"Resolved",caption:"".concat(null!==(l=null==x?void 0:x.numAgents)&&void 0!==l?l:0," agent").concat((null!==(d=null==x?void 0:x.numAgents)&&void 0!==d?d:0)===1?"":"s")}),(0,s.jsx)(N,{icon:O.EQ9,iconColor:"orange.500",value:null!==(c=null==x?void 0:x.awaitingReply)&&void 0!==c?c:0,label:"Open",caption:"Awaiting reply"}),(0,s.jsx)(N,{icon:O.TCC,iconColor:"blue.500",value:null!==(u=null==x?void 0:x.inConversation)&&void 0!==u?u:0,label:"Ongoing",caption:"In conversation"})]})}),(0,s.jsx)(A.i,{display:{base:"block",md:"none"}}),(0,s.jsxs)(o.xu,{flex:"1",pl:{md:6},children:[(0,s.jsxs)(h.k,{align:"center",justify:"space-between",mb:3,children:[(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"semibold",children:"By agent"}),(0,s.jsxs)(T.h,{isAttached:!0,variant:"outline",size:"xs",children:[(0,s.jsx)(C.z,{onClick:()=>j("resolved"),..."resolved"===b&&I,children:"Resolved"}),(0,s.jsx)(C.z,{onClick:()=>j("open"),..."open"===b&&I,children:"Open"})]})]}),0===E.length?(0,s.jsx)(m.x,{fontSize:"sm",color:"gray.500",children:"resolved"===b?"No resolved chats in this period":"No open chats in this period"}):(0,s.jsxs)(h.k,{direction:"column",gap:1,children:[E.map(e=>{let n="resolved"===b?e.resolved:e.open;return(0,s.jsx)(M,{agent:e,mode:b,pct:n/F*100,share:Math.round(n/J*100)},e.userId)}),v>0&&(0,s.jsx)(m.x,{fontSize:"xs",color:"gray.400",mt:1,children:"+ ".concat(v," more")})]})]})]})})}var F=t(89993);function J(e){let{row:n,pct:t,onClick:i}=e;return(0,s.jsxs)(o.xu,{position:"relative",borderRadius:"md",overflow:"hidden",cursor:i?"pointer":"default",onClick:i,_hover:i?{bg:"gray.50"}:void 0,children:[(0,s.jsx)(o.xu,{position:"absolute",top:0,bottom:0,left:0,width:"".concat(t,"%"),bg:n.muted?"gray.100":"brand.50",transition:"width 0.3s ease"}),(0,s.jsxs)(h.k,{position:"relative",align:"center",gap:2,px:3,py:"6px",children:[n.emoji&&(0,s.jsx)(m.x,{as:"span",fontSize:"lg",lineHeight:1,children:n.emoji}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"medium",color:n.muted?"gray.500":"gray.800",noOfLines:1,flex:1,children:n.label}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"semibold",color:"gray.600",children:n.count}),n.drillable&&(0,s.jsx)(x.J,{as:O.Tfp,color:"gray.400",boxSize:4})]})]})}function B(e){var n,t;let{topCountries:i,topRegions:r}=e,[a,l]=(0,z.useState)(null),{rows:d,selectedCountry:c}=(0,z.useMemo)(()=>(function(e,n,t){var s,o,i,r;let a=new Map;for(let e of n){if(!e.countryCode||!e.regionName)continue;let n=null!==(s=a.get(e.countryCode))&&void 0!==s?s:[];n.push(e),a.set(e.countryCode,n)}let l=t&&null!==(o=e.find(e=>e.countryCode===t))&&void 0!==o?o:null;if(l){let e=null!==(r=a.get(null!==(i=l.countryCode)&&void 0!==i?i:""))&&void 0!==r?r:[],n=e.map(e=>({key:e.regionName,label:e.regionName,count:e._count._all,drillable:!1,muted:!1})),t=e.reduce((e,n)=>e+n._count._all,0),s=l._count._all-t;return s>0&&n.push({key:"__unspecified__",label:"Unspecified",count:s,drillable:!1,muted:!0}
1),n.sort((e,n)=>n.count-e.count),{rows:n,selectedCountry:l}}return{rows:e.map(e=>{var n,t,s;return{key:e.countryCode,label:null!==(t=null!==(n=e.countryName)&&void 0!==n?n:e.countryCode)&&void 0!==t?t:"Unknown",emoji:e.countryFlagEmoji,count:e._count._all,drillable:a.has(null!==(s=e.countryCode)&&void 0!==s?s:""),muted:!1}}),selectedCountry:null}})(i,r,a),[i,r,a]),u=d.slice(0,8),g=d.length-u.length,p=u.reduce((e,n)=>Math.max(e,n.count),0)||1;return(0,s.jsxs)(o.xu,{children:[(0,s.jsx)(h.k,{align:"center",gap:2,mb:3,minH:"28px",children:c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(F.h,{"aria-label":"Back to countries",icon:(0,s.jsx)(O.YFh,{}),size:"xs",variant:"ghost",onClick:()=>l(null)}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"semibold",noOfLines:1,children:"".concat(null!==(n=c.countryFlagEmoji)&&void 0!==n?n:""," ").concat(null!==(t=c.countryName)&&void 0!==t?t:""," \xb7 by state")})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.J,{as:O.RsK,color:"brand.500"}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"semibold",children:"Chats by location"})]})}),0===d.length?(0,s.jsx)(o.xu,{fontSize:"sm",color:"gray.500",children:c?"No state data":"No location data"}):(0,s.jsxs)(h.k,{direction:"column",gap:1,children:[u.map(e=>(0,s.jsx)(J,{row:e,pct:e.count/p*100,onClick:e.drillable&&!c?()=>l(e.key):void 0},e.key)),g>0&&(0,s.jsx)(m.x,{fontSize:"xs",color:"gray.400",mt:1,children:"+ ".concat(g," more")})]})]})}var P=t(81136),V=t(76112),q=t(65688);function U(e){let{icon:n,title:t,description:o}=e;return(0,s.jsxs)(h.k,{flex:1,minH:"220px",direction:"column",align:"center",justify:"center",gap:2,px:6,children:[(0,s.jsx)(h.k,{boxSize:10,align:"center",justify:"center",borderRadius:"full",bg:"gray.100",children:(0,s.jsx)(x.J,{as:n,boxSize:5,color:"gray.400"})}),(0,s.jsx)(m.x,{fontSize:"sm",fontWeight:"semibold",color:"gray.700",mt:1,children:t}),(0,s.jsx)(m.x,{fontSize:"sm",color:"gray.500",textAlign:"center",maxW:"16rem",children:o})]})}let H=r()(()=>Promise.all([t.e(2814),t.e(9596),t.e(2862),t.e(6611)]).then(t.bind(t,86611)).then(e=>e.ResponsiveLine),{loadableGenerated:{webpack:()=>[86611]},ssr:!1});function Q(e){var n,t,o,i,r,a,l;let{data:d,loading:c}=e;if(c)return(0,s.jsx)(P.$,{size:"lg"});let u=null===(n=d[0])||void 0===n?void 0:n.data.reduce((e,n)=>{var t;return Math.max(e,+(null!==(t=n.y)&&void 0!==t?t:0))},0);if(0===d.length||(null===(t=d[0])||void 0===t?void 0:t.data)===void 0||(null===(o=d[0])||void 0===o?void 0:o.data.length)===0||0===u)return(0,s.jsx)(U,{icon:O.IC0,title:"No messages yet",description:"Chat messages sent in this date range will chart here."});let x=(0,V.Z)(null===(r=d[0])||void 0===r?void 0:null===(i=r.data[0])||void 0===i?void 0:i.x,"yyyy-MM-dd",new Date),g=(0,V.Z)(null===(l=d[0])||void 0===l?void 0:null===(a=l.data.at(-1))||void 0===a?void 0:a.x,"yyyy-MM-dd",new Date),p=(0,q.Z)(g,x);return(0,s.jsx)(H,{data:d,margin:{top:20,bottom:20,right:40,left:40},animate:!0,xScale:{type:"time",format:"%Y-%m-%d",useUTC:!1,precision:p>=1?"month":"day"},xFormat:"time:%Y-%m-%d",yScale:{type:"linear",min:0},axisLeft:{legend:"Messages count",legendOffset:12,format:e=>Number.isInteger(e)?e:""},axisBottom:{format:p>=1?"%Y-%b":"%b-%d",tickValues:3},curve:"monotoneX",enablePointLabel:!1,tooltip:e=>{let{point:n}=e;return(0,s.jsx)(j.Z,{p:2,bg:"white",borderWidth:1,borderColor:"border.tertiary",rounded:"md",children:(0,s.jsxs)(h.k,{flexDir:"column",alignItems:"center",children:[(0,s.jsx)(m.x,{fontSize:"small",children:p>=1?n.data.xFormatted.slice(0,-3):n.data.xFormatted}),(0,s.jsx)(m.x,{fontWeight:600,children:n.data.yFormatted})]})})},colors:["#3E63DD"],pointColor:"#6278FA",pointSize:5,useMesh:!0,enableSlices:!1,crosshairType:"bottom"})}let Y=r()(()=>Promise.all([t.e(2814),t.e(2846),t.e(5313)]).then(t.bind(t,55313)).then(e=>e.ResponsiveBar),{loadableGenerated:{webpack:()=>[null]},ssr:!1});function X(e){let{data:n,loading:t}=e;if(t)return(0,s.jsx)(P.$,{size:"lg"});if(!(null==n?void 0:n.sessionsByMessageCount))return(0,s.jsx)(h.k,{flex:1,justifyContent:"center",alignItems:"center",children:"No data"});let o=Object.entries(n.sessionsByMessageCount).map(e=>{let[n,t]=e;return{messages:n,count:t}});return o.some(e=>e.count>0)?(0,s.jsx)(Y,{data:o,keys:["count"],indexBy:"messages",margin:{top:20,right:20,bottom:50,left:60},padding:.3,colors:["#3E63DD"],borderColor:{from:"color",modifiers:[["dar
1ker",1.6]]},axisTop:null,axisRight:null,axisBottom:{tickSize:5,tickPadding:5,tickRotation:0,legend:"Messages per Session",legendPosition:"middle",legendOffset:40},axisLeft:{tickSize:5,tickPadding:5,tickRotation:0,legend:"Number of Sessions",legendPosition:"middle",legendOffset:-50,format:e=>Number.isInteger(e)?e:""},labelSkipWidth:12,labelSkipHeight:12,labelTextColor:"white",animate:!0,motionConfig:"wobbly",tooltip:e=>{let{data:n}=e;return(0,s.jsx)(j.Z,{p:2,bg:"white",borderWidth:1,borderColor:"border.tertiary",rounded:"md",children:(0,s.jsxs)(h.k,{flexDir:"column",alignItems:"center",children:[(0,s.jsx)(m.x,{fontSize:"small",children:"5+"===n.messages?"5+ messages":"".concat(n.messages," message").concat("1"!==n.messages?"s":"")}),(0,s.jsxs)(m.x,{fontWeight:600,children:[n.count," sessions"]})]})})}}):(0,s.jsx)(h.k,{flex:1,justifyContent:"center",alignItems:"center",children:"No data"})}var G=t(25244),K=t(30454),$=t(29355),ee=t(70386),en=t(22697),et=t(59007),es=t(67430),eo=t(6147),ei=t(8799),er=t(32782),ea=t(45349),el=t(5674),ed=t(35796),ec=t(20967),eu=t(73614),eh=t(85970),ex=t(5418),eg=t(41731),em=t(66712),ep=t(91170),eb=t(4040),ej=t(74970),ef=t(22757),ev=t(57035),ey=t(8371),eC=t(32883),eS=t(72800),ew=t(12903),ek=t(48494),eD=t(39359),eA=t(45343),eT=t(15394),eI=t(80258),eR=t(33299),ez=t(57408);let eO=new Date("2026-04-23T00:00:00");function e_(e){return new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))}function eM(e){return new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),23,59,59,999))}function eN(e){return null==e?"N/A":Math.round(e)}let eW=e=>{let{isMobile:n}=e;return(0,s.jsxs)(el.M,{columns:n?2:6,spacingY:12,spacingX:8,children:[(0,s.jsx)(j.Z,{borderRadius:"xl",variant:"outline",shadow:"lg",gridColumnStart:1,gridColumnEnd:n?3:4,children:(0,s.jsxs)(f.e,{children:[(0,s.jsx)(S.O,{height:"18px",width:"60%",mb:6,borderRadius:"md"}),(0,s.jsx)(S.O,{height:"32px",width:"40%",mb:6,borderRadius:"md"}),(0,s.jsx)(S.O,{height:"50px",width:"100%",borderRadius:"md"})]})}),(0,s.jsx)(j.Z,{borderRadius:"xl",variant:"outline",shadow:"lg",gridColumnStart:n?1:4,gridColumnEnd:n?3:7,children:(0,s.jsxs)(f.e,{children:[(0,s.jsx)(S.O,{height:"18px",width:"50%",mb:6,borderRadius:"md"}),(0,s.jsx)(S.O,{height:"32px",width:"35%",mb:6,borderRadius:"md"}),(0,s.jsx)(S.O,{height:"14px",width:"55%",borderRadius:"md"})]})}),[0,1].map(e=>(0,s.jsx)(j.Z,{borderRadius:"xl",variant:"outline",shadow:"lg",gridColumnStart:0===e?1:n?1:4,gridColumnEnd:0===e?n?3:4:n?3:7,children:(0,s.jsxs)(f.e,{children:[(0,s.jsx)(S.O,{height:"16px",width:"45%",mb:4,borderRadius:"md"}),(0,s.jsx)(S.O,{height:200,width:"100%",borderRadius:"md"})]})},"graph-".concat(e))),Array.from({length:8}).map((e,t)=>(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsxs)(f.e,{children:[(0,s.jsx)(S.O,{height:"13px",width:"60%",borderRadius:"md"}),(0,s.jsx)(S.O,{height:"26px",width:"40%",mt:3,borderRadius:"md"})]})},"stat-".concat(t)))]})};var eZ=(0,G.Q)(()=>{let e=(0,z.useContext)(ew.Z),n=(0,ed.S)({base:!0,md:!1}),{data:t,isLoading:i}=et.S.chatbot.getChatbotsBasicInfo.useQuery(),r=(0,eR.useSession)(),[a,l]=(0,ez.v1)("chatbotId",{history:"push",defaultValue:""}),[d,g]=(0,z.useState)([(0,ek.Z)((0,eD.Z)(new Date,1)),(0,eA.Z)(new Date)]),[y,k]=(0,z.useState)(null);(0,z.useEffect)(()=>{t&&t.length>0&&!t.some(e=>e.id===a)&&l(t[0].id,{history:"replace"})},[t,a,l]);let{data:I,isLoading:R,isError:_}=et.S.analytics.getAnalytics.useQuery({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:d[0],endDate:d[1]},{queryKey:["analytics.getAnalytics",{chatbotId:a}],enabled:!!a}),{data:M,isLoading:N}=et.S.analytics.getMessagesCountGraphData.useQuery({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:d[0],endDate:d[1]},{enabled:!!a,queryKey:["analytics.getMessagesCountGraphData",{chatbotId:a,startDate:d[0],endDate:d[1]}]}),{data:W,isLoading:Z}=et.S.analytics.getLiveChatAnalytics.useQuery({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:d[0],endDate:d[1]},{enabled:!!a&&2===d.length&&!!d[0]&&!!d[1]}),L=et.S.analytics.exportAllAnalytics.useMutation({onSuccess:n=>{var t,s;let o=n.map(e=>{var n,t,s,o,i,r,a,l,d;let{avgMessagesPerChatSession:c,avgDurationPerChatSession:u,numGood:h,numBad:x,numMessages:g,topCountries:m,topRegions:p,numEscalatedChats:b,chatbotName:j,numMessageCredits:f,numChatSessions:v,emails:y,tagCounts:C,numPendingCorrections:S,num1Csat:w,num2Csat:k,num3Csat:D,num4Csat:A,num5Csat:T,totalCsat:I,avgCsat:R,hasValidCsatData:z,resolutionRate:O,numResolved:_,numUnresolved:M,mostClickedLinks:N,chatlogTypeBreakdown:W,sessionsByMessageCount:Z,responseLatencyMetrics:L}=e,E=null===(n=Object.keys(y).sort((e,n)=>(0,V.Z)(e,"dd-MM-yyyy",new Date).getTime()-(0,V.Z)(n,"dd-MM-yyyy",new Date).getTime()))||void 0===n?void 0:n.reduce((e,n)=>{var t;return[...e,"".concat(n,": ").concat(null==y?void 0:null===(t=y[n])||void 0===t?void 0:t.join(", "))]},[]).join("\n");return{"Chatbot name":j,"No. of chat sessions":v,"Total no. of messages":g,"Total no. of message credits spent":Number(f.toFixed(2)),"Avg messages per chat session":Number(c.toFixed(2)),"Avg duration per 
1chat session (ms)":Math.round(u),"Response time samples":L.responseTimeCount,"Avg TTFT (ms)":eN(L.avgTimeToResponseMs),"Avg time to full response (ms)":eN(L.avgTimeToResponseFinishMs),"No. of good chat sessions":h,"No. of bad chat sessions":x,"No. of escalated chats":b,"No. of open actionables":S,"Emails collected":'"'+E+'"',"Tag counts":'"'+(null===(t=Object.keys(C))||void 0===t?void 0:t.reduce((e,n)=>[...e,"".concat(n,": ").concat(C[n])],[]).join("\n"))+'"',"Average CSAT score":z?R.toFixed(2):"N/A","Total CSAT responses":I,"CSAT score 1 (Very Dissatisfied)":w,"CSAT score 2 (Dissatisfied)":k,"CSAT score 3 (Neutral)":D,"CSAT score 4 (Satisfied)":A,"CSAT score 5 (Very Satisfied)":T,"Resolution rate":O?(100*O).toFixed(1)+"%":"N/A","No. of resolved chats":_,"No. of unresolved chats":M,"Most clicked links":'"'+(null==N?void 0:null===(o=N.slice(0,5))||void 0===o?void 0:null===(s=o.map(e=>"".concat(e.url,": ").concat(e.count)))||void 0===s?void 0:s.join("\n"))+'"',"Channel breakdown":'"'+(null==W?void 0:null===(i=W.map(e=>"".concat(e.type,": ").concat(e.count)))||void 0===i?void 0:i.join("\n"))+'"',"Sessions with 1 message":Z["1"]||0,"Sessions with 2 messages":Z["2"]||0,"Sessions with 3 messages":Z["3"]||0,"Sessions with 4 messages":Z["4"]||0,"Sessions with 5+ messages":Z["5+"]||0,"Top countries":'"'+(null==m?void 0:null===(a=m.slice(0,5))||void 0===a?void 0:null===(r=a.map(e=>{var n;return"".concat(null!==(n=e.countryName)&&void 0!==n?n:e.countryCode,": ").concat(e._count._all)}))||void 0===r?void 0:r.join("\n"))+'"',"Top states":'"'+(null==p?void 0:null===(d=p.slice(0,5))||void 0===d?void 0:null===(l=d.map(e=>"".concat(e.regionName," (").concat(e.countryCode,"): ").concat(e._count._all)))||void 0===l?void 0:l.join("\n"))+'"'}});(0,en.EZ)(o,"".concat(e.name||"Wonderchat"," Analytics for ").concat(null===(t=d[0])||void 0===t?void 0:t.toISOString()," - ").concat(null===(s=d[1])||void 0===s?void 0:s.toISOString(),".csv"))}}),F=et.S.analytics.exportAllAnalyticsBucketed.useMutation({onSuccess:(n,t)=>{var s,o;let i=n.map(e=>{let{chatbotName:n,period_start:t,period_end:s,numChatSessions:o,numMessages:i,numMessageCredits:r,avgMessagesPerChatSession:a,avgDurationPerChatSession:l,numGood:d,numBad:c,numEscalatedChats:u,num1Csat:h,num2Csat:x,num3Csat:g,num4Csat:m,num5Csat:p,totalCsat:b,avgCsat:j,hasValidCsatData:f,resolutionRate:v,numResolved:y,numUnresolved:C,emails:S,tags:w,channelBreakdown:k,sessionsByMessageCount:D,responseLatencyMetrics:A}=e;return{"Chatbot name":n,Period:"".concat(new Date(t).toISOString().slice(0,10)," - ").concat(new Date(s).toISOString().slice(0,10)),"No. of chat sessions":o,"Total no. of messages":i,"Total no. of message credits spent":Number(r.toFixed(2)),"Avg messages per chat session":Number(a.toFixed(2)),"Avg duration per chat session (ms)":Math.round(l),"Response time samples":A.responseTimeCount,"Avg TTFT (ms)":eN(A.avgTimeToResponseMs),"Avg time to full response (ms)":eN(A.avgTimeToResponseFinishMs),"No. of good chat sessions":d,"No. of bad chat sessions":c,"No. of escalated chats":u,"Emails collected":null!=S?S:"","Tag counts":null!=w?w:"","Average CSAT score":f?j.toFixed(2):"N/A","Total CSAT responses":b,"CSAT score 1 (Very Dissatisfied)":h,"CSAT score 2 (Dissatisfied)":x,"CSAT score 3 (Neutral)":g,"CSAT score 4 (Satisfied)":m,"CSAT score 5 (Very Satisfied)":p,"Resolution rate":v?(100*v).toFixed(1)+"%":"N/A","No. of resolved chats":y,"No. of unresolved chats":C,"Channel breakdown":null!=k?k:"","Sessions with 1 message":D["1"]||0,"Sessions with 2 messages":D["2"]||0,"Sessions with 3 messages":D["3"]||0,"Sessions with 4 messages":D["4"]||0,"Sessions with 5+ messages":D["5+"]||0}});(0,en.EZ)(i,"".concat(e.name||"Wonderchat"," Analytics by ").concat(t.granularity," for ").concat(null===(s=d[0])||void 0===s?void 0:s.toISOString()," - ").concat(null===(o=d[1])||void 0===o?void 0:o.toISOString(),".csv"))}}),J=et.S.analytics.getMostClickedLinks.useMutation({onSuccess:e=>{let n=e.map(e=>({URL:e.url,Count:e.count,Chatbot:e.bot.name}));(0,en.EZ)(n,"".concat(new Date,"_most_visited_links.csv"))}}),q=(0,z.useMemo)(()=>"all"===a?null:null==t?void 0:t.find(e=>e.id===a),[t,a]),{data:U,isLoading:H}=et.S.analytics.getFaqsByDateRange.useQuery({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:d[0],endDate:d[1]}
1,{enabled:!!a&&2===d.length&&!!d[0]&&!!d[1]}),Y=(0,z.useMemo)(()=>{var e,n;return!!(0,ee.N7)("ANALYTICS_DASHBOARD",null==q?void 0:null===(e=q.owner)||void 0===e?void 0:e.subscriptionType)||"all"===a&&null!==(n=null==t?void 0:t.some(e=>{var n;return(0,ee.N7)("ANALYTICS_DASHBOARD",null===(n=e.owner)||void 0===n?void 0:n.subscriptionType)}))&&void 0!==n&&n},[q,r,a,t]),G=(0,ec.q)();return i?(0,s.jsxs)(w.K,{gap:4,pb:8,children:[(0,s.jsxs)(h.k,{gap:4,flexDir:"row",alignItems:"flex-end",children:[(0,s.jsx)(S.O,{height:"40px",width:"220px",borderRadius:"md"}),(0,s.jsx)(S.O,{height:"40px",flex:1,borderRadius:"md"}),(0,s.jsx)(S.O,{height:"40px",width:"320px",borderRadius:"md"})]}),(0,s.jsxs)(j.Z,{borderRadius:"xl",children:[(0,s.jsx)(eu.O,{children:(0,s.jsx)(S.O,{height:"20px",width:"120px",borderRadius:"md"})}),(0,s.jsx)(f.e,{children:(0,s.jsx)(eW,{isMobile:n})})]})]}):_?(0,s.jsx)(o.xu,{children:"Error"}):t?(0,s.jsxs)(w.K,{gap:4,pb:8,children:[(0,s.jsxs)(h.k,{gap:4,flexDir:"row",alignItems:"flex-end",children:[(0,s.jsxs)(eh.NI,{width:"auto",children:[(0,s.jsx)(ex.l,{children:"Chatbot"}),(0,s.jsx)(eg.P,{onChange:e=>{l(e.target.value)},value:a,maxW:"sm",children:(null!=t?t:[]).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,s.jsx)(h.k,{flex:1,children:(0,s.jsx)(eS.ou,{selectedDates:d,onDateChange:e=>{if(k(null),e.length>1&&e[0]&&e[1]){g([(0,ek.Z)(e[0]),(0,eA.Z)(e[1])]);return}g(e)},propsConfigs:{dayOfMonthBtnProps:{selectedBtnProps:{background:"gray.400",color:"white"},defaultBtnProps:{_hover:{background:"gray.400",color:"white"}},isInRangeBtnProps:{background:"gray.400",color:"white"}}}})}),(0,s.jsx)(T.h,{isAttached:!0,variant:"outline",children:[{key:"today",label:"Today",dates:()=>[(0,ek.Z)(new Date),(0,eA.Z)(new Date)]},{key:"7d",label:"Last 7 days",dates:()=>[(0,ek.Z)((0,eT.Z)(new Date,7)),(0,eA.Z)(new Date)]},{key:"30d",label:"Last 30 days",dates:()=>[(0,ek.Z)((0,eT.Z)(new Date,30)),(0,eA.Z)(new Date)]},{key:"month",label:"This month",dates:()=>[(0,eI.Z)(new Date),(0,eA.Z)(new Date)]}].map(e=>(0,s.jsx)(C.z,{onClick:()=>{k(e.key),g(e.dates())},...y===e.key&&{bgColor:"brand.500",color:"white",borderColor:"brand.500",_hover:{bgColor:"brand.300",borderColor:"brand.300"}},children:e.label},e.key))}),(0,s.jsxs)(em.v,{children:[(0,s.jsx)(ep.j,{as:C.z,colorScheme:"brand",fontSize:"sm",isLoading:L.isLoading||F.isLoading,leftIcon:(0,s.jsx)(es._,{}),rightIcon:(0,s.jsx)(eo.v,{}),children:"Export"}),(0,s.jsxs)(eb.q,{minW:"9rem",children:[(0,s.jsx)(ej.s,{onClick:()=>{L.mutate({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:d[0],endDate:d[1]})},children:"Totals"}),(0,s.jsx)(ej.s,{isDisabled:!d[0]||!d[1],onClick:()=>{d[0]&&d[1]&&F.mutate({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:e_(d[0]),endDate:eM(d[1]),granularity:"week"})},children:"By week"}),(0,s.jsx)(ej.s,{isDisabled:!d[0]||!d[1],onClick:()=>{d[0]&&d[1]&&F.mutate({chatbotId:"all"===a?"ALL_CHATBOTS":a,startDate:e_(d[0]),endDate:eM(d[1]),granularity:"month"})},children:"By month"})]})]})]}),(0,s.jsxs)(j.Z,{borderRadius:"xl",children:[R&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eu.O,{children:(0,s.jsx)(ef.X,{size:"md",children:"Overview"})}),(0,s.jsx)(f.e,{children:(0,s.jsx)(eW,{isMobile:n})})]}),!R&&I&&(()=>{var e,t,i,r,l;let{numChatSessions:g,numBad:y,numGood:S,numMessages:k,messageCreditsUsed:T,avgMessagesPerChatSession:z,avgDurationPerChatSession:_,mostClickedLinks:L,totalClicks:F,topCountries:V,topRegions:q,numEscalatedChats:et,chatlogTypeBreakdown:es,widgetClickCount:eo,uniqueVisitorCount:ed,responseLatencyMetrics:ec}=I;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eu.O,{children:(0,s.jsx)(ef.X,{size:"md",children:"Overview"})}),(0,s.jsxs)(f.e,{children:[(0,s.jsxs)(el.M,{columns:n?2:6,spacingY:12,spacingX:8,children:[I.hasValidCsatData&&(0,s.jsx)(j.Z,{borderRadius:"xl",variant:"outline",gridColumnStart:1,gridColumnEnd:n?3:4,flex:1,shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{flex:1,justifyContent:"center",alignItems:"center",children:[(0,s.jsxs)(ev.d,{mb:"6",alignItems:"center",display:"flex",fontSize:"md",gap:"2",fontWeight:"semibold",w:"full",children:[(0,s.jsx)(x.J,{mr:2,as:O.jMy,color:"brand.500"}),"Overall Customer Satisfaction",(0,s.jsx)(v.u,{placement:"top",label:"Customer satisfaction scores are predicted from your chatlogs using AI",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsxs)(h.k,{flexDir:"column",gap:"4",children:[(0,s.jsxs)(D.U,{spacing:4,mb:6,children:[(0,s.jsxs)(p.k,{children:[(0,s.jsx)(ev.d,{display:"flex",alignItems:"center",gap:"2",children:"Average Score"}),(0,s.jsxs)(b.J,{display:"flex",gap:"2",alignItems:"center",children:[I.hasValidCsatData?I.avgCsat.toFixed(1):"-"," ",I.hasValidCsatData&&(0,s.jsx)(ey.Vp,{as:"span",fontWeight:"bold",colorScheme:(e=I.avgCsat)>3?"green":e>2?"yellow":e>0?"red":"gray",children:(t=I.avgCsat)>4?"Outstanding":t>3?"Good":t>2?"Ok":t>0?"Poor":""})]})]}),(0,s.jsx)(h.k,{fontSize:"4xl",gap:"2",alignItems:"center",children:I.hasValidCsatData?(l=I.avgCsat)>4?"\uD83E\uDD29":l>3?"\uD83D\uDE04":l>2?"\uD83D\uDE10":l>1?"\uD83D\uDE41":l>0?"\uD83D\uDE20":"":""})]}),(0,s.jsx)(o.xu,{height:"50px",position:"relative",w:"full",children:(0,s.jsxs)(h.k,{height:"100%",children:[0!==I.num5Csat&&(0,s.jsx)(o.xu,{bg:"green.500",w:I.hasValidCsatData?I.num5Csat/I.totalCsat*100+"%":"20%",minW:"5%",position:"relative",children:(0,s.jsx)(m.x,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:"\uD83E\uDD29"})}),0!==I.num4Csat&&(0,s.jsx)(o.xu,{bg:"green.300",w:I.hasValidCsatData?I.num4Csat/I.totalCsat*100+"%":"20%",minW:"5%",position:"relative",children:(0,s.jsx)(m.x,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:"\uD83D\uDE04"})}),0!==I.num3Csat&&(0,s.jsx)(o.xu,{bg:"yellow.400",minW:"5%",w:I.hasValidCsatData?I.num3Csat/I.totalCsat*100+"%":"20%",position:"relative",children:(0,s.jsx)(m.x,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:"\uD83D\uDE10"})}),0!==I.num2Csat&&(0,s.jsx)(o.xu,{bg:"red.300",minW:"5%",w:I.hasValidCsatData?I.num2Csat/I.totalCsat*100+"%":"20%",position:"relative",children:(0,s.jsx)(m.x,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:"\uD83D\uDE41"})}),0!==I.num1Csat&&(0,s.jsx)(o.xu,{bg:"red.500",minW:"5%",w:I.hasValidCsatData?I.num1Csat/I.totalCsat*100+"%":"20%",position:"relative",children:(0,s.jsx)(m.x,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:"\uD83D\uDE20"})})]})}),(0,s.jsxs)(h.k,{justify:"space-between",mt:2,children:[(0,s.jsxs)(m.x,{fontSize:"sm",fontWeight:"medium",children:["Very Satisfied (",I.hasValidCsatData?"".concat(Math.ceil(I.num5Csat/I.totalCsat*100),"%"):"-",")"]}),(0,s.jsxs)(m.x,{fontSize:"sm",fontWeight:"medium",children:["Very Dissatisfied (",I.hasValidCsatData?"".concat(Math.ceil(I.num1Csat/I.totalCsat*100),"%"):"-",")"]})]})]})]})})}),I.hasValidCsatData&&(0,s.jsx)(j.Z,{borderRadius:"xl",variant:"outline",shadow:"lg",gridColumnStart:n?1:4,gridColumnEnd:n?3:7,children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{mb:"6",alignItems:"center",display:"flex",fontSize:"md",gap:"2",fontWeight:"semibold",w:"full",children:[(0,s.jsx)(x.J,{mr:2,as:O._rq,color:"brand.500"}),"Resolution Rate",(0,s.jsx)(v.u,{placement:"top",label:"Resolutions are predicted from your chatlogs using AI",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(o.xu,{children:(0,s.jsxs)(p.k,{mb:6,children:[(0,s.jsxs)(ev.d,{display:"flex",alignItems:"center",gap:"2",children:["Overall Resolution Rate",(0,s.jsx)(v.u,{placement:"top",label:"Resolution rates are based on the number of resolved and unresolved chat sessions. Some chat sessions are considered neither resolved nor unresolved as they are not legitimate customer queries",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsxs)(b.J,{gap:"3",alignItems:"center",display:"flex",children:[Math.ceil(100*I.resolutionRate),"%",I.hasValidCsatData&&(0,s.jsx)(ey.Vp,{as:"span",fontWeight:"bold",colorScheme:(i=I.resolutionRate)>.5?"green":i>.3?"yellow":i>0?"red":"gray",children:(r=I.resolutionRate)>.7?"Outstanding":r>.5?"Good":r>.25?"Ok":r>0?"Poor":""})]})]})}),(0,s.jsx)(o.xu,{children:(0,s.jsxs)(p.k,{mb:6,children:[(0,s.jsx)(ev.d,{children:"Number of resolved chats"}),(0,s.jsx)(b.J,{children:I.numResolved})]})})]})})})]}),(0,s.jsxs)(o.xu,{position:"relative",mt:6,children:[(0,s.jsx)(o.xu,{filter:Y?void 0:"blur(8px)",pointerEvents:Y?void 0:"none",userSelect:Y?void 0:"none","aria-hidden":!Y||void 0,maxH:Y?void 0:"600px",overflow:Y?void 0:"hidden",children:(0,s.jsxs)(el.M,{columns:n?2:6,spacingY:12,
1spacingX:8,children:[(0,s.jsx)(j.Z,{borderRadius:"xl",variant:"outline",shadow:"lg",gridColumnStart:1,gridColumnEnd:n?3:7,children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{flex:1,justifyContent:"center",alignItems:"center",children:[(0,s.jsxs)(ev.d,{fontSize:"md",fontWeight:"semibold",alignItems:"center",display:"flex",mb:"1",children:[(0,s.jsx)(ei.k,{color:"brand.500",mr:2}),"Number of Chat Messages"]}),(0,s.jsx)(h.k,{height:200,children:(0,s.jsx)(Q,{data:null!=M?M:[],loading:N})})]})})}),(0,s.jsx)(E,{data:W,isLoading:Z,chatbotId:a}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{children:[(0,s.jsx)(ei.k,{color:"brand.500",mr:2}),"No. of Chat Sessions"]}),(0,s.jsx)(b.J,{my:2,children:g})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{display:"flex",alignItems:"center",gap:"2",children:[(0,s.jsx)(x.J,{color:"brand.500",as:O.WY8}),"Unique Visitors",(0,s.jsx)(v.u,{placement:"top",label:"Data available from Apr 23, 2026. Unique visitors who loaded a page with your widget. Deduped once per visitor per day.",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(b.J,{my:2,children:ed}),d[0]&&d[0]<eO&&(0,s.jsx)(m.x,{fontSize:"xs",color:"gray.500",mt:1,children:"Only counted from Apr 23, 2026 onward — earlier dates in this range have no data."})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{display:"flex",alignItems:"center",gap:"2",children:[(0,s.jsx)(x.J,{color:"brand.500",as:O.PS6}),"Widget Engagements",(0,s.jsx)(v.u,{placement:"top",label:"Data available from Jan 26, 2026. Number of unique widget button clicks (one per session)",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(b.J,{my:2,children:eo})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{display:"flex",alignItems:"center",gap:"2",children:[(0,s.jsx)(x.J,{color:"green",as:O.fmn}),"Good Chats",(0,s.jsx)(v.u,{placement:"top",label:"Number of chats rated as good by the participating user",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(b.J,{my:2,children:S})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{px:5,py:4,children:(0,s.jsxs)(o.xu,{children:[(0,s.jsxs)(h.k,{alignItems:"center",gap:"2",mb:4,fontSize:"md",fontWeight:"semibold",color:"gray.800",children:[(0,s.jsx)(x.J,{color:"brand.500",as:O.TCC}),(0,s.jsx)(m.x,{children:"Response speed"}),(0,s.jsx)(v.u,{placement:"top",label:"TTFT is time to first token. Full response is measured until the chatbot finishes generating the reply.",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsxs)(o.xu,{display:"grid",gridTemplateColumns:"minmax(108px, 1.45fr) minmax(52px, 0.75fr)",alignItems:"stretch",overflow:"hidden",children:[["Metric","Avg"].map((e,n)=>(0,s.jsx)(m.x,{px:0===n?0:2,py:2,bg:0===n?"white":"brand.50",color:0===n?"gray.500":"brand.500",fontSize:"xs",fontWeight:"bold",textAlign:0===n?"left":"right",textTransform:"uppercase",letterSpacing:"0",children:e},e)),[{label:"TTFT",value:ec.avgTimeToResponseMs},{label:"Full response",value:ec.avgTimeToResponseFinishMs}].flatMap(e=>{var n;return[(0,s.jsx)(m.x,{px:0,py:3,borderTop:"1px solid",borderColor:"gray.100",color:"gray.600",fontSize:"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:e.label},"".concat(e.label,"-label")),(0,s.jsx)(m.x,{px:2,py:3,bg:"brand.50",borderTop:"1px solid",borderColor:"gray.100",color:"brand.500",fontSize:"sm",fontWeight:"semibold",textAlign:"right",whiteSpace:"nowrap",children:null==(n=e.value)?"N/A":n<1e3?"".concat(Math.round(n),"ms"):"".concat((n/1e3).toFixed(n<1e4?1:0),"s")},"".concat(e.label,"-value"))]})]})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{display:"flex",alignItems:"center",gap:"2",children:[(0,s.jsx)(x.J,{color:"red",as:O.oLd}),"Bad Chats",(0,s.jsx)(v.u,{placement:"top",label:"Number of chats rated as bad by the participating user",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(b.J,{my:2,children:y})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{alignItems:"center",children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.LbG}),"No. of messages"]}),(0,s.jsx)(b.J,{my:2,children:k})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.LbG}),"Average no. of messages per chat session"]}),(0,s.jsx)(b.J,{my:2,children:z.toFixed(2)})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{alignItems:"center",display:"flex",gap:"2",children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.XiQ}),"Message credits used",(0,s.jsx)(v.u,{placement:"top",label:"A message refers to a 
1single exchange between the chatbot and the user. However, each message may consume more credits depending on the context length and AI model you have selected for your chatbot. More advanced models and longer context lengths consume more credits per message.",children:(0,s.jsx)(u.U,{color:"brand.300"})})]}),(0,s.jsx)(b.J,{my:2,children:(null==T?void 0:T.toLocaleString())||0})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsx)(B,{topCountries:V,topRegions:q})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.IC0}),"Chats by channel"]}),0===es.length?(0,s.jsx)(o.xu,{fontSize:"lg",children:"No channel data"}):(0,s.jsx)(c,{data:es})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.bcx}),"Number of escalated chats"]}),(0,s.jsx)(b.J,{my:2,children:et})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.TCC}),"Avg. chat duration"]}),(0,s.jsx)(b.J,{my:2,children:function(e){let n=Math.round(e/1e3);if(n<=0)return"0s";let t=Math.floor(n/3600),s=Math.floor(n%3600/60);return[t>0?"".concat(t,"h"):null,t>0||s>0?"".concat(s,"m"):null,"".concat(n%60,"s")].filter(Boolean).join(" ")}(_)})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumn:n?"span 1":"span 2",variant:"outline",shadow:"lg",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{fontSize:"md",fontWeight:"semibold",alignItems:"center",display:"flex",mb:"1",children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.IC0}),"Sessions by Message Count"]}),(0,s.jsx)(h.k,{height:200,children:(0,s.jsx)(X,{data:I,loading:R})})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumnStart:1,gridColumnEnd:3,variant:"outline",shadow:"lg",p:"2",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{children:[(0,s.jsx)(er.x,{mr:2,color:"brand.500"}),"Most visited links",L&&L.length>0&&(0,s.jsx)(C.z,{float:"right",colorScheme:"brand",size:"xs",isLoading:J.isLoading,onClick:async()=>{a&&J.mutate({chatbotId:"all"===a?"ALL_CHATBOTS":a})},children:"Export as CSV"})]}),0===L.length?(0,s.jsx)(m.x,{my:"2",layerStyle:"regularImportant",children:"No links clicked yet"}):(0,s.jsx)(o.xu,{my:"4",children:(0,s.jsx)($.y,{border:!0,caption:L.length>0?"Total clicks across all links: ".concat(F):"",data:L,columns:[{key:"url",header:"URL",render:e=>(0,s.jsx)(eC.r,{color:"blue.500",href:e.url,target:"_blank",rel:"noreferrer",children:e.url})},{key:"count",header:"Count"}],size:"sm"})})]})})}),(0,s.jsx)(j.Z,{borderRadius:"xl",gridColumnStart:n?1:3,gridColumnEnd:n?3:7,variant:"outline",shadow:"lg",alignSelf:"start",children:(0,s.jsx)(f.e,{children:(0,s.jsxs)(p.k,{children:[(0,s.jsxs)(ev.d,{fontSize:"md",fontWeight:"semibold",alignItems:"center",display:"flex",mb:"4",children:[(0,s.jsx)(x.J,{mr:2,color:"brand.500",as:O.QqI}),"Top Questions from Users",U&&U.length>0&&(0,s.jsx)(C.z,{float:"right",ml:"auto",colorScheme:"brand",size:"xs",onClick:()=>{var e,n;let t=U.map(e=>({Question:e.frequentlyAskedQuestion,Count:e._count}));(0,en.EZ)(t,"top_questions_".concat(null===(e=d[0])||void 0===e?void 0:e.toISOString(),"_").concat(null===(n=d[1])||void 0===n?void 0:n.toISOString(),".csv"))},children:"Export as CSV"})]}),H?(0,s.jsx)(h.k,{justify:"center",py:8,children:(0,s.jsx)(P.$,{})}):U&&U.length>0?(0,s.jsxs)(w.K,{spacing:0,divider:(0,s.jsx)(A.i,{}),children:[(0,s.jsxs)(h.k,{justifyContent:"space-between",alignItems:"center",py:2,children:[(0,s.jsx)(m.x,{fontSize:"xs",fontWeight:"semibold",color:"gray.500",textTransform:"uppercase",children:"Question"}),(0,s.jsx)(m.x,{fontSize:"xs",fontWeight:"semibold",color:"gray.500",textTransform:"uppercase",children:"Count"})]}),U.map(e=>{var n,t,o;return(0,s.jsxs)(h.k,{justifyContent:"space-between",alignItems:"center",py:3,children:[(0,s.jsx)(eC.r,{c
1olor:"blue.500",fontSize:"sm",href:"/chatlogs?".concat(e.chatbotId?"chatbotId=".concat(e.chatbotId,"&"):"","faq=").concat(encodeURIComponent(null!==(o=e.frequentlyAskedQuestion)&&void 0!==o?o:""),"&startDate=").concat(null===(n=d[0])||void 0===n?void 0:n.toISOString(),"&endDate=").concat(null===(t=d[1])||void 0===t?void 0:t.toISOString()),isExternal:!0,children:(0,s.jsxs)(h.k,{alignItems:"center",gap:"4px",children:[e.frequentlyAskedQuestion,(0,s.jsx)(ea.h,{})]})}),(0,s.jsx)(ey.Vp,{size:"sm",colorScheme:"gray",children:e._count})]},e.frequentlyAskedQuestion)})]}):(0,s.jsx)(m.x,{color:"gray.500",fontSize:"sm",children:"No frequently asked questions found for this date range"})]})})})]})}),!Y&&(0,s.jsx)(h.k,{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center",p:4,zIndex:2,children:(0,s.jsxs)(w.K,{alignItems:"center",spacing:4,bg:"white",p:8,borderRadius:"xl",shadow:"2xl",border:"1px solid",borderColor:"gray.200",maxW:"md",children:[(0,s.jsx)(x.J,{as:O.UIZ,boxSize:10,color:"brand.500"}),(0,s.jsx)(ef.X,{size:"md",textAlign:"center",children:"Upgrade to unlock full analytics"}),(0,s.jsx)(m.x,{textAlign:"center",color:"gray.600",fontSize:"sm",children:"Get detailed insights including message trends, confidence levels, channel breakdowns, top questions, and more with the ".concat((0,ee.Vo)("ANALYTICS_DASHBOARD")," plan.")}),(0,s.jsx)(C.z,{colorScheme:"brand",onClick:G.onOpen,children:"Upgrade Now"})]})})]}),(0,s.jsx)(K.C,{isOpen:G.isOpen,onClose:G.onClose})]})]})})()]})]}):(0,s.jsx)(o.xu,{children:"Create a chatbot to view analytics for it!"})})}},function(e){e.O(0,[2432,6152,5937,5445,260,2260,2832,512,9562,6057,5145,2553,8237,9093,2031,6406,4790,8100,9157,2888,9774,179],function(){return e(e.s=44813)}),_N_E=e.O()}]);

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.