PageSourceSearch

https://dashboard.laburen.com/_next/static/chunks/pages/index-2523176d4ef32490.js

js laburen.com collected 2026-10-04 23:00:57 UTC 46,958 bytes, 1 lines download raw bytes

1try{!function(){var 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]="43ff14ef-64b3-4dec-9453-b33fb2b00e37",e._sentryDebugIdIdentifier="sentry-dbid-43ff14ef-64b3-4dec-9453-b33fb2b00e37")}()}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5405],{62189:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return r(68266)}])},68266:function(e,t,r){"use strict";r.r(t),r.d(t,{__N_SSP:function(){return ed},default:function(){return eu}});var o=r(97458),n=r(36604),s=r(41906),a=r(32726),i=r(59209),l=r(97181),c=r(43681),d=r(47568),u=r(24102),x=r(82860),m=r(52983),h=r(96062),g=r(34746);function p(){var e,t,r,o,n,s,a,i;let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"6m",c=(0,x.bp)(),d=null==c?void 0:null===(t=c.data)||void 0===t?void 0:null===(e=t.organization)||void 0===e?void 0:e.id,{data:u,error:m,mutate:p}=(0,h.ZP)((null==c?void 0:null===(o=c.data)||void 0===o?void 0:null===(r=o.user)||void 0===r?void 0:r.id)&&d?"/api/dashboard/stats?_org=".concat(d):null,g._i,{refreshInterval:3e4,revalidateOnFocus:!0}),{data:v,error:f,mutate:b}=(0,h.ZP)((null==c?void 0:null===(s=c.data)||void 0===s?void 0:null===(n=s.user)||void 0===n?void 0:n.id)&&d?"/api/dashboard/metrics?range=".concat(l,"&offset=0&_org=").concat(d):null,g._i,{refreshInterval:6e4,revalidateOnFocus:!0}),{data:y}=(0,h.ZP)((null==c?void 0:null===(i=c.data)||void 0===i?void 0:null===(a=i.user)||void 0===a?void 0:a.id)&&d?"/api/dashboard/metrics?range=".concat(l,"&offset=1&_org=").concat(d):null,g._i,{refreshInterval:6e4,revalidateOnFocus:!0}),j=!u&&!m||!v&&!f,C=!!u&&u.usage.agentQueries/u.usage.maxAgentQueries>.8,w=!!u&&u.usage.datastoreQueries/u.usage.maxDatastoreQueries>.8,Z=u?u.usage.agentQueries/u.usage.maxAgentQueries*100:0,S=u?u.usage.datastoreQueries/u.usage.maxDatastoreQueries*100:0,P=e=>(e||[]).reduce((e,t)=>e+(t.conversations||0),0),F=e=>(e||[]).reduce((e,t)=>e+(t.queries||0),0),k=e=>(e||[]).reduce((e,t)=>e+(t.newAgents||0),0),A=e=>(e||[]).reduce((e,t)=>e+(t.newDatastores||0),0),z=e=>(e||[]).reduce((e,t)=>e+(t.newForms||0),0),M=e=>(e||[]).reduce((e,t)=>e+(t.newContacts||0),0),D=P(v),W=P(y),N=F(v),E=F(y),B=z(v),I=z(y),U=(e,t)=>0===t?e>0?100:0:(e-t)/t*100,T=U(D,W),R=U(N,E),L=U(k(v),k(y)),H=U(A(v),A(y)),Q=U(M(v),M(y)),O=U(B,I),_=e=>null==e||Number.isNaN(e)?"N/A":"".concat(e>=0?"+":"").concat(e.toFixed(0),"%"),q=e=>null==e||Number.isNaN(e)?null:e>0?"up":e<0?"down":"equal";return{stats:u,metrics:v||[],isLoading:j,hasData:!!u,error:m||f,isNearAgentLimit:C,isNearDatastoreLimit:w,agentUsagePercentage:Z,datastoreUsagePercentage:S,trends:{agents:{value:_(L),isPositive:L>=0,direction:q(L)},datastores:{value:_(H),isPositive:H>=0,direction:q(H)},contacts:{value:_(Q),isPositive:Q>=0,direction:q(Q)},conversations:{value:_(T),isPositive:T>=0,direction:q(T)},forms:{value:_(O),isPositive:O>=0,direction:q(O)},queries:{value:_(R),isPositive:R>=0,direction:q(R)}},compare:{conversations:{current:D,previous:W,changePct:T},queries:{current:N,previous:E,changePct:R}},refreshStats:()=>{p(),b()},getPlanColor:e=>{switch(e){case"Corporativo":case"Empresarial":return"success";case"Profesional":return"primary";case"B\xe1sico":return"warning";default:return"neutral"}},getUsageColor:e=>e>=90?"danger":e>=80?"warning":e>=60?"primary":"success"}}var v=r(46870),f=r(53905),b=r(63351),y=r(76737),j=r(57332),C=r(80266),w=r(96),Z=r(3810),S=r(60706),P=r(71007),F=r(57330),k=r(35915),A=r(25536),z=r(6388),M=r(30888),D=r(1957),W=r(15929),N=r(87485);function E(e){var t,r,c,d;let{isOpen:u,onClose:x}=e,[h,g]=(0,m.useState)((0,k.WU)((0,A.W)(new Date,1),"yyyy-MM-dd")),[p,v]=(0,m.useState)((0,k.WU)(new Date,"yyyy-MM-dd")),[E,B]=(0,m.useState)(null),[I,U]=(0,m.useTransition)(),[T,R]=(0,m.useState)(null),[L,H]=(0,m.useState)("month"),Q=(0,P.F)(),O=Q.palette.primary[500],_=Q.palette.neutral[200],{tReport:q,currentLanguage:Y}=(0,N.ZP)(),[G,V]=(0,m.useState)(!1),[K,$]=(0,m.useState)(!1),J=e=>{let t=parseInt(e.replace("#",""),16);return[t>>16&255,t>>8&255,255&t]},X=async e=>{let t=await fetch(e),r=await t.blob();return new Promise((e,t)=>
1{let o=new FileReader;o.onloadend=()=>e(o.result),o.onerror=()=>t(o.error),o.readAsDataURL(r)})},ee=async e=>{var t;let r=new D.ZP("p","mm","a4"),o=r.internal.pageSize.width,n=r.internal.pageSize.height,s=20;r.setFillColor(...J(O)),r.rect(0,0,o,35,"F");try{let e=await X("/logo-white.png");r.addImage(e,"PNG",10,12,10,10)}catch(e){}r.setTextColor(255,255,255),r.setFontSize(24),r.setFont("helvetica","bold"),r.text("LABUREN",25,20),r.setFontSize(12),r.setFont("helvetica","normal"),r.text(q("executiveReport"),20,28),r.setFontSize(10),r.text("".concat(q("generatedOn")," ").concat((0,k.WU)(new Date,"dd/MM/yyyy HH:mm",{locale:M.es})),o-20,15,{align:"right"}),s=50,r.setTextColor(0,0,0),r.setFontSize(16),r.setFont("helvetica","bold"),r.text(q("organizationInfo"),20,s),s+=10,r.setFontSize(11),r.setFont("helvetica","normal"),r.text("".concat(q("organization"),": ").concat(e.organization.name),20,s),s+=6,r.text("".concat(q("plan"),": ").concat(e.organization.plan),20,s),s+=6,r.text("".concat(q("reportPeriod"),": ").concat(e.organization.reportPeriod.startDate," al ").concat(e.organization.reportPeriod.endDate),20,s),s+=15,r.setFillColor(...J(_)),r.rect(20,s-3,o-40,8,"F"),r.setFontSize(14),r.setFont("helvetica","bold"),r.setTextColor(...J(O)),r.text(q("executiveSummary"),22,s+2),s+=12,r.setTextColor(0,0,0);let a=[{label:q("metrics.aiAgents"),value:e.summary.totalAgents.toLocaleString()},{label:q("metrics.conversations"),value:e.summary.totalConversations.toLocaleString()},{label:q("metrics.messages"),value:e.summary.totalMessages.toLocaleString()},{label:q("metrics.leadsGenerated"),value:e.summary.totalLeads.toLocaleString()},{label:q("metrics.datastores"),value:e.summary.totalDatastores.toLocaleString()},{label:q("metrics.contacts"),value:e.summary.totalContacts.toLocaleString()}];(0,W.ZP)(r,{startY:s,head:[[q("metrics.metric"),q("metrics.value")]],body:a.map(e=>[e.label,e.value]),theme:"grid",headStyles:{fillColor:J(O),textColor:[255,255,255]},styles:{fontSize:10},margin:{left:20,right:20},columnStyles:{0:{cellWidth:80},1:{cellWidth:40}}}),s=r.lastAutoTable.finalY+15,r.setFillColor(...J(_)),r.rect(20,s-3,o-40,8,"F"),r.setFontSize(14),r.setFont("helvetica","bold"),r.setTextColor(...J(O)),r.text(q("performanceAnalysis"),22,s+2),s+=12,r.setTextColor(0,0,0);let i=[[q("performanceMetrics.agentQueries"),e.usage.agentQueries.toLocaleString()],[q("performanceMetrics.datastoreQueries"),e.usage.datastoreQueries.toLocaleString()],[q("performanceMetrics.avgMessagesPerConversation"),e.conversationMetrics.averageMessagesPerConversation.toFixed(1)],[q("performanceMetrics.satisfactionRate"),"".concat(e.conversationMetrics.responseQuality.satisfactionRate.toFixed(1),"%")],[q("performanceMetrics.leadConversionRate"),"".concat(e.leadGeneration.conversionRate.toFixed(1),"%")]];(0,W.ZP)(r,{startY:s,head:[[q("metrics.metric"),q("metrics.value")]],body:i,theme:"striped",headStyles:{fillColor:J(O),textColor:[255,255,255]},styles:{fontSize:10},margin:{left:20,right:20}}),(s=r.lastAutoTable.finalY+15)>n-60&&(r.addPage(),s=20),r.setFillColor(...J(_)),r.rect(20,s-3,o-40,8,"F"),r.setFontSize(14),r.setFont("helvetica","bold"),r.setTextColor(...J(O)),r.text(q("creditUsage"),22,s+2),s+=12,r.setTextColor(0,0,0);let l=[[q("totalCreditsConsumed"),((null===(t=e.creditUsage)||void 0===t?void 0:t.totalCreditsConsumed)||0).toFixed(2)]];if((0,W.ZP)(r,{startY:s,head:[[q("metrics.metric"),q("metrics.value")]],body:l,theme:"striped",headStyles:{fillColor:J(O),textColor:[255,255,255]},styles:{fontSize:10},margin:{left:20,right:20}}),(s=r.lastAutoTable.finalY+15)>n-60&&(r.addPage(),s=20),e.conversationMetrics.byChannel.length>0){r.setFillColor(...J(_)),r.rect(20,s-3,o-40,8,"F"),r.setFontSize(14),r.setFont("helvetica","bold"),r.setTextColor(...J(O)),r.text(q("channelDistribution"),22,s+2),s+=12;let t=e.conversationMetrics.byChannel.map(e=>[e.channel,e.count.toLocaleString(),"".concat(e.percentage.toFixed(1),"%")]);(0,W.ZP)(r,{startY:s,head:[[q("metrics.channel"),q("metrics.conversations"),q("metrics.percentage")]],body:t,theme:"striped",headStyles:{fillColor:J(O),textColor:[255,255,255]},styles:{fontSize:10},margin:{left:20,right:20}}),s=r.lastAutoTable.finalY+15}if(e.agentPerformance.length>0){s>n-80&&(r.addPage(),s=20),r.setFillColor(...J(_)),r.rect(20,s-3,o-40,8,"F"),r.setFontSize(14),r.setFont("helvetica","bold"),r.setTextColor(...J(O)),r.text(q("agentPerformance"),22,s+2),s+=12;let t=e.agentPerformance.slice(0,10).map(e=>
1[e.agentName||"Sin nombre",e.totalQueries.toLocaleString(),e.totalConversations.toLocaleString(),"".concat(e.responseQuality.satisfactionRate.toFixed(1),"%"),(e.creditsConsumed||0).toFixed(2)]);(0,W.ZP)(r,{startY:s,head:[[q("metrics.agent"),q("metrics.queries"),q("metrics.conversations"),q("metrics.satisfaction")]],body:t,theme:"striped",headStyles:{fillColor:J(O),textColor:[255,255,255]},styles:{fontSize:9},margin:{left:20,right:20}}),s=r.lastAutoTable.finalY+15}e.insights.length>0&&(s>n-60&&(r.addPage(),s=20),r.setFillColor(...J(_)),r.rect(20,s-3,o-40,8,"F"),r.setFontSize(14),r.setFont("helvetica","bold"),r.setTextColor(...J(O)),r.text(q("insightsRecommendations"),22,s+2),s+=12,r.setTextColor(0,0,0),r.setFontSize(10),r.setFont("helvetica","normal"),e.insights.forEach((e,t)=>{s>n-20&&(r.addPage(),s=20),r.setFont("helvetica","bold"),r.text("".concat(t+1,"."),22,s),r.setFont("helvetica","normal");let a=r.splitTextToSize(e,o-50);r.text(a,28,s),s+=5*a.length+3}));let c=(e,t)=>{r.setFillColor(...J(O)),r.rect(0,n-15,o,15,"F"),r.setTextColor(255,255,255),r.setFontSize(8),r.text("".concat(q("company.name")," - ").concat(q("company.tagline")),20,n-8),r.text("P\xe1gina ".concat(e," de ").concat(t),o-20,n-8,{align:"right"}),r.text(q("company.confidential"),o/2,n-4,{align:"center"})},d=r.getNumberOfPages();for(let e=1;e<=d;e++)r.setPage(e),c(e,d);let u="Reporte-Laburen-".concat(e.organization.name.replace(/\s+/g,"-"),"-").concat(h,"-").concat(p,".pdf");r.save(u)},et=e=>{let t,r,o;if(!E)return;if("pdf"===e){ee(E);return}if("json"===e)t=JSON.stringify(E,null,2),r="reporte-organizacion-".concat(h,"-").concat(p,".json"),o="application/json";else{var n;t=[[q("metrics.metric"),q("metrics.value")],[q("organization"),E.organization.name],[q("plan"),E.organization.plan],[q("csv.period"),"".concat(E.organization.reportPeriod.startDate," - ").concat(E.organization.reportPeriod.endDate)],[""],[q("csv.summary")],[q("metrics.aiAgents"),E.summary.totalAgents.toString()],[q("metrics.datastores"),E.summary.totalDatastores.toString()],[q("metrics.contacts"),E.summary.totalContacts.toString()],[q("metrics.conversations"),E.summary.totalConversations.toString()],[q("metrics.messages"),E.summary.totalMessages.toString()],[q("metrics.leadsGenerated"),E.summary.totalLeads.toString()],[q("csv.totalForms"),E.summary.totalForms.toString()],[""],[q("csv.resourceUsage")],[q("performanceMetrics.agentQueries"),E.usage.agentQueries.toString()],[q("performanceMetrics.datastoreQueries"),E.usage.datastoreQueries.toString()],[q("csv.uploadedBytes"),E.usage.uploadedBytes.toString()],[q("csv.tokensUsed"),E.usage.tokensUsed.toString()],[""],[q("creditUsage")],[q("totalCreditsConsumed"),((null===(n=E.creditUsage)||void 0===n?void 0:n.totalCreditsConsumed)||0).toFixed(2)],[""],[q("csv.creditsPerAgent")],[q("metrics.agent"),q("csv.creditsConsumed")],...E.agentPerformance.map(e=>[e.agentName||q("csv.unnamed"),(e.creditsConsumed||0).toFixed(2)]),[""],[q("csv.conversationMetrics")],[q("csv.avgMessagesPerConversation"),E.conversationMetrics.averageMessagesPerConversation.toFixed(1)],[q("csv.satisfactionRate"),E.conversationMetrics.responseQuality.satisfactionRate.toFixed(1)],[""],[q("csv.leadGeneration")],[q("csv.totalLeads"),E.leadGeneration.totalLeads.toString()],[q("csv.conversionRate"),E.leadGeneration.conversionRate.toFixed(1)],[""],[q("csv.insights")],...E.insights.map(e=>["",e])].map(e=>e.join(",")).join("\n"),r="reporte-organizacion-".concat(h,"-").concat(p,".csv"),o="text/csv;charset=utf-8;"}let s=new Blob([t],{type:o}),a=URL.createObjectURL(s),i=document.createElement("a");i.href=a,i.download=r,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)},er=e=>{let t;let r=new Date;switch(e){case"week":t=(0,z.t)(r,1);break;case"month":t=(0,A.W)(r,1);break;case"quarter":t=(0,A.W)(r,3);break;case"year":t=(0,A.W)(r,12)}g((0,k.WU)(t,"yyyy-MM-dd")),v((0,k.WU)(r,"yyyy-MM-dd")),H(e)};return(0,o.jsx)(f.ZP,{open:u,onClose:x,children:(0,o.jsxs)(b.Z,{size:"md",sx:{maxWidth:"500px",width:"100%",maxHeight:"90vh",overflow:"auto",p:3},children:[(0,o.jsx)(y.Z,{sx:{px:0,pt:0},children:(0,o.jsx)(a.ZP,{level:"h4",sx:{fontWeight:600},children:q("title")})}),(0,o.jsxs)(l.Z,{spacing:2.5,children:[(0,o.jsxs)(n.Z,{children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{mb:1.5,fontWeight:500},children:q("periodLabel")}),(0,o.jsxs)(l.Z,{className:"w-[55%] rounded-2xl p-2",direction:"row",spacing:1,sx:{mb:2,backgroundColor:"background.level1"},children:[(0,o.jsx)(i.Z,{size:"sm",variant:"week"===L?"solid":"outlined",onClick:()=>er("week"),sx:{fontSize:"13px",py:.75,px:2,borderRadius:"6px",fontWeight:500,backgroundColor:"week"===L?"background.surface":"transparent",borderWidth:"0px",borderColor:"transparent",color:"week"===L?"text.primary":"neutral.500",boxShadow:"week"===L?"0px 1px 3px rgba(0, 0, 0, 0.1)":"none","&:hover":{borderWidth:"1px",borderColor:"success.500",backgroundColor:"week"===L?"background.surface":"transparent",color:"week"===L?"text.primary":"neutral.500"}},children:q("periods.7d")}),(0,o.jsx)(i.Z,{size:"sm",variant:"month"===L?"solid":"outlined",onClick:()=>er("month"),sx:{fontSize:"13px",py:.75,px:2,borderRadius:"6px",fontWeight:500,backgroundColor:"month"===L?"background.surface":"transparent",borderWidth:"0px",borderColor:"transparent",color:"month"===L?"text.primary":"neutral.500",boxShadow:"month"===L?"0px 1px 3px rgba(0, 0, 0, 0.1)":"none","&:hover":{borderWidth:"1px",borderColor:"success.500",backgroundColor:"month"===L?"background.surface":"transparent",color:"month"===L?"text.primary":"neutral.500"}},children:q("periods.1m")}),(0,o.jsx)(i.Z,{size:"sm",variant:"quarter"===L?"solid":"outlined",onClick:()=>er("quarter"),sx:{fontSize:"13px",py:.75,px:2,borderRadius:"6px",fontWeight:500,backgroundColor:"quarter"===L?"background.surface":"transparent",borderWidth:"0px",borderColor:"transparent",color:"quarter"===L?"text.primary":"neutral.500",boxShadow:"quarter"===L?"0px 1px 3px rgba(0, 0, 0, 0.1)":"none","&:hover":{borderWidth:"1px",borderColor:"success.500",backgroundColor:"quarter"===L?"background.surface":"transparent",color:"quarter"===L?"text.primary":"neutral.500"}},children:q("periods.6m")}),(0,o.jsx)(i.Z,{size:"sm",variant:"year"===L?"solid":"outlined",onClick:()=>er("year"),sx:{fontSize:"13px",py:.75,px:2,borderRadius:"6px",fontWeight:500,backgroundColor:"year"===L?"background.surface":"transparent",borderWidth:"0px",borderColor:"transparent",color:"year"===L?"text.primary":"neutral.500",boxShadow:"year"===L?"0px 1px 3px rgba(0, 0, 0, 0.1)":"none","&:hover":{borderWidth:"1px",borderColor:"success.500",backgroundColor:"year"===L?"background.surface":"transparent",color:"year"===L?"text.primary":"neutral.500"}},children:q("periods.1y")})]}),(0,o.jsxs)(l.Z,{direction:"row",spacing:1.5,sx:{mb:1.5},children:[(0,o.jsxs)(j.Z,{sx:{flex:1},children:[(0,o.jsx)(C.Z,{sx:{fontSize:"12px",mb:.5,fontWeight:500},children:q("startDate")}),(0,o.jsx)(w.ZP,{type:"date",value:h,onChange:e=>{g(e.target.value),H(null)},placeholder:"00/00/0000",size:"sm",className:"rounded-xl",slotProps:{input:{sx:{fontSize:"13px"}}}})]}),(0,o.jsxs)(j.Z,{sx:{flex:1},children:[(0,o.jsx)(C.Z,{sx:{fontSize:"12px",mb:.5,fontWeight:500},children:q("endDate")}),(0,o.jsx)(w.ZP,{type:"date",value:p,onChange:e=>{v(e.target.value),H(null)},placeholder:"00/00/0000",size:"sm",slotProps:{input:{sx:{fontSize:"13px"}}}})]})]}),(0,o.jsx)(a.ZP,{level:"body-xs",color:"neutral",sx:{fontStyle:"italic",fontSize:"11px"},children:q("selectPeriod")})]}),(0,o.jsx)(i.Z,{onClick:()=>{V(!0),U(()=>{(async()=>{try{R(null);let e=await fetch("/api/dashboard/report?startDate=".concat(h,"&endDate=").concat(p,"&locale=").concat(Y));if(!e.ok)throw Error(q("errors.generateError"));let t=await e.json();B(t),V(!1),$(!0)}catch(e){V(!1),$(!1),R(e instanceof Error?e.message:q("errors.unknownError"))}})()})},loading:I||G,disabled:!h||!p||G,variant:E?"solid":"outlined",color:E?"success":"neutral",sx:{alignSelf:"flex-end",mt:1,width:"165px",backgroundColor:E?"success.500":"background.surface",border:E?"none":"2px s
1olid",borderColor:E?"transparent":"divider",color:E?"white":"text.tertiary",borderRadius:"12px","&:hover":{backgroundColor:E?"success.600 !important":"background.surface !important",borderColor:E?"transparent !important":"divider !important",color:E?"white !important":"text.tertiary !important"},"&:active":{backgroundColor:E?"success.700 !important":"background.surface !important",borderColor:E?"transparent !important":"divider !important",color:E?"white !important":"text.tertiary !important"},"&:disabled":{backgroundColor:E?"success.500":"background.surface",borderColor:E?"transparent":"divider",color:E?"white":"text.tertiary",opacity:.6}},children:q("generateReport")}),T&&(0,o.jsx)(s.Z,{color:"danger",variant:"soft",size:"sm",children:(0,o.jsx)(a.ZP,{level:"body-sm",children:T})}),I&&(0,o.jsx)(n.Z,{sx:{display:"flex",justifyContent:"center",py:3},children:(0,o.jsx)(Z.Z,{size:"lg"})}),(0,o.jsxs)(n.Z,{sx:{flexDirection:"column",textAlign:"center"},children:[(0,o.jsxs)("div",{className:"flex flex-row items-center gap-2 mb-5",children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600},children:q("company.name")}),(0,o.jsx)(S.Z,{className:"bg-[#EFF6F2] text-[#27AE60] border border-[#27AE60]",size:"sm",variant:"soft",color:"success",sx:{fontSize:"11px"},children:q("company.corporate")})]}),(0,o.jsxs)("div",{className:"flex flex-row items-center gap-4",children:[(0,o.jsxs)(a.ZP,{level:"body-xs",color:"neutral",sx:{fontSize:"11px"},children:[q("labels.start")," ",h?(0,k.WU)(new Date(h),"dd/MM/yyyy"):"00/00/0000"]}),(0,o.jsxs)(a.ZP,{level:"body-xs",color:"neutral",sx:{mb:0,fontSize:"11px"},children:[q("labels.end")," ",p?(0,k.WU)(new Date(p),"dd/MM/yyyy"):"00/00/0000"]})]})]}),(0,o.jsxs)(n.Z,{sx:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2,py:1},children:[(0,o.jsxs)(n.Z,{className:"text-center p-2 rounded-[10px]",sx:{border:"1px solid",borderColor:"divider"},children:[(0,o.jsx)(a.ZP,{level:"h3",sx:{color:E&&E.summary.totalConversations>0?"success.600":"text.tertiary",fontWeight:600,mb:.5,fontSize:"20px"},children:(null==E?void 0:E.summary.totalConversations)||0}),(0,o.jsx)(a.ZP,{level:"body-xs",color:"neutral",sx:{fontSize:"11px"},children:q("metrics.conversations")})]}),(0,o.jsxs)(n.Z,{className:"text-center p-2 rounded-[10px]",sx:{border:"1px solid",borderColor:"divider"},children:[(0,o.jsx)(a.ZP,{level:"h3",sx:{color:E&&E.summary.totalMessages>0?"success.600":"text.tertiary",fontWeight:600,mb:.5,fontSize:"20px"},children:(null==E?void 0:E.summary.totalMessages)||0}),(0,o.jsx)(a.ZP,{level:"body-xs",color:"neutral",sx:{fontSize:"11px"},children:q("metrics.messages")})]}),(0,o.jsxs)(n.Z,{className:"text-center p-2 rounded-[10px]",sx:{border:"1px solid",borderColor:"divider"},children:[(0,o.jsx)(a.ZP,{level:"h3",sx:{color:E&&E.summary.totalLeads>0?"success.600":"text.tertiary",fontWeight:600,mb:.5,fontSize:"20px"},children:(null==E?void 0:E.summary.totalLeads)||0}),(0,o.jsx)(a.ZP,{level:"body-xs",color:"neutral",sx:{fontSize:"11px"},children:q("metrics.leadsGenerated")})]}),(0,o.jsxs)(n.Z,{className:"text-center p-2 rounded-[10px]",sx:{border:"1px solid",borderColor:"divider"},children:[(0,o.jsx)(a.ZP,{level:"h3",sx:{color:E&&E.conversationMetrics.responseQuality.satisfactionRate>0?"success.600":"text.tertiary",fontWeight:600,mb:.5,fontSize:"20px"},children:E?"".concat(E.conversationMetrics.responseQuality.satisfactionRate.toFixed(1),"%"):"0"}),(0,o.jsx)(a.ZP,{level:"body-xs",color:"neutral",sx:{fontSize:"11px"},children:q("metrics.satisfaction")})]})]}),(0,o.jsxs)(n.Z,{children:[(0,o.jsx)(l.Z,{direction:"row",spacing:1,alignItems:"center",sx:{mb:1.5},children:(0,o.jsx)(a.ZP,{level:"title-sm",sx:{fontWeight:600},children:q("insights.title")})}),(0,o.jsxs)(l.Z,{className:"gap-2 ",spacing:1,children:[(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontSize:"13px"},children:q("insights.balancedConversations")}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600,fontSize:"13px",color:E&&E.conversationMetrics.averageMessagesPerConversation>0?"success.600":"neutral.700"},children:E&&E.conversationMetrics.averageMessagesPerConversation>0?"".concat(E.conversationMetrics.averageMessagesPerConversation.toFixed(1)," ").concat(q("insights.messagesAverage")):"-"})]}),(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontSize:"13px"},children:q("insights.responseQuality")}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600,fontSize:"13px",color:E&&E.conversationMetrics.responseQuality.satisfactionRate>0?"success.600":"neutral.700"},children:E&&E.conversationMetrics.responseQuality.satisfactionRate>0?"".concat(E.conversationMetrics.responseQuality.satisfactionRate.toFixed(1),"% ").concat(q("insights.satisfactory")):"-"})]}),(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontSize:"13px"},children:q("insights.mostActiveChannel")}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600,fontSize:"13px",color:(null==E?void 0:null===(t=E.conversationMetrics.byChannel[0])||void 0===t?void 0:t.channel)?"success.600":"neutral.700"},children:(null==E?void 0:null===(r=E.conversationMetrics.byChannel[0])||void 0===r?void 0:r.channel)?"".concat(E.conversationMetrics.byChannel[0].channel," ").concat(E.conversationMetrics.byChannel[0].percentage.toFixed(1),"%"):"-"})]}),(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontSize:"13px"},children:q("insights.mostActiveAgent")}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600,fontSize:"13px",color:(null==E?void 0:null===(c=E.agentPerformance[0])||void 0===c?void 0:c.agentName)?"success.600":"neutral.700"},children:(null==E?void 0:null===(d=E.agentPerformance[0])||void 0===d?void 0:d.agentName)?"".concat(E.agentPerformance[0].agentName," ").concat(E.agentPerformance[0].totalConversations," ").concat(q("insights.conversations")):"-"})]})]})]}),E&&(0,o.jsx)(i.Z,{onClick:()=>et("pdf"),endDecorator:(0,o.jsx)(F.Z,{}),variant:"outlined",sx:{cursor:"pointer",alignSelf:"flex-end",mt:1,width:"200px",backgroundColor:"background.surface",border:"2px s
1olid",borderColor:"divider",color:"text.primary",borderRadius:"12px","&:hover":{backgroundColor:"background.surface !important",borderColor:"success.500 !important",color:"text.primary !important"},"&:active":{backgroundColor:"background.surface !important",borderColor:"success.600 !important",color:"text.primary !important"},"& .MuiButton-endDecorator":{color:"text.primary"}},children:q("downloadReport")})]})]})})}var B=r(51915),I=r(61933),U=r(53955),T=r(25233),R=r(90647),L=r(53570),H=r(51463),Q=r(16511),O=r(4104),_=r(350),q=r(31713),Y=r(20998),G=r(23377);function V(){var e,t,r,o;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"6m",s=(0,x.bp)(),a=null==s?void 0:null===(t=s.data)||void 0===t?void 0:null===(e=t.organization)||void 0===e?void 0:e.id,{data:i,error:l,mutate:c,isLoading:d}=(0,h.ZP)((null==s?void 0:null===(o=s.data)||void 0===o?void 0:null===(r=o.user)||void 0===r?void 0:r.id)&&a?"/api/dashboard/roi?range=".concat(n,"&_org=").concat(a):null,g._i,{refreshInterval:6e4,revalidateOnFocus:!0,dedupingInterval:3e4});(0,m.useEffect)(()=>{let e=()=>{"true"===localStorage.getItem("roiConfigChanged")&&(localStorage.removeItem("roiConfigChanged"),c())};e(),window.addEventListener("storage",e);let t=setInterval(e,2e3);return()=>{window.removeEventListener("storage",e),clearInterval(t)}},[c]);let u=null==i?void 0:i.workspace,p=(null==i?void 0:i.byAgent)||[],v=null==i?void 0:i.chart,f=null==i?void 0:i.period;return{roiData:i,workspaceMetrics:u,agentMetrics:p,chartData:v,period:f,isLoading:d,isLoaded:!!i,hasError:!!l,error:l,refreshRoi:()=>{c()},getTrendColor:e=>{switch(e){case"up":return"success";case"down":return"danger";default:return"neutral"}},formatCurrency:e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),formatHours:e=>new Intl.NumberFormat("es-ES",{minimumFractionDigits:1,maximumFractionDigits:1}).format(e),formatTrend:e=>e||0===e?"".concat(e>=0?"+":"").concat(e.toFixed(1),"%"):"N/A"}}var K=r(87010);function $(e){var t,r,s;let{range:i="6m",agentCount:c=0}=e,d=(0,u.useRouter)(),x="dark"===(0,P.F)().palette.mode,{workspaceMetrics:h,isLoading:g,formatHours:v,formatTrend:f}=V(i),{metrics:b,trends:y,stats:j}=p(i),{tMetrics:C}=(0,N.ZP)(),w=e=>{switch(e){case"7d":return C("last7Days");case"month":default:return C("currentMonth");case"6m":return C("lastSixMonths");case"anual":return C("thisYear")}},S=m.useMemo(()=>b?b.reduce((e,t)=>e+(t.conversations||0),0):0,[b]),F=m.useMemo(()=>{var e;return(null==j?void 0:null===(e=j.usage)||void 0===e?void 0:e.agentQueries)||0},[j]),k=m.useMemo(()=>{var e;return(null==j?void 0:null===(e=j.usage)||void 0===e?void 0:e.maxAgentQueries)||1},[j]),A=e=>{if(!b||0===b.length)return[];switch(e){case"timeSaved":return b.map(e=>({value:e.conversations?e.conversations*((null==h?void 0:h.timeSavedHours)||0)/S:0}));case"credits":return b.map(e=>({value:e.queries||0}));case"conversations":return b.map(e=>({value:e.conversations||0}))}},z=e=>{let{title:t,description:r,value:s,icon:i,iconBgColor:c,iconColor:d,color:u="primary",trend:h,trendValue:p,periodLabel:v,dontShowGraph:f,chartData:b,onClick:y,suffix:j}=e;return(0,o.jsx)(I.Z,{variant:"outlined",className:"hover:shadow-md p-3 rounded-2xl transition-shadow h-full",sx:{height:"100%",borderColor:x?"neutral.700":"neutral.300",backgroundColor:x?"neutral.900":"background.page",cursor:y?"pointer":"default"},onClick:y,children:(0,o.jsxs)(U.Z,{sx:{height:"100%",display:"flex",flexDirection:"column",gap:2},children:[(0,o.jsx)(l.Z,{className:"w-full",direction:"row",alignItems:"flex-start",justifyContent:"space-between",sx:{minHeight:"60px"},children:(0,o.jsxs)(l.Z,{className:"flex flex-row items-center",direction:"row",alignItems:"flex-start",spacing:1.5,sx:{flex:1,minWidth:0},children:[(0,o.jsx)(T.Z,{size:"sm",sx:{flexShrink:0,width:40,height:40,backgroundColor:c||(x?"#1D3D16":"#E9F5E4"),color:d||"#0EA803"},children:m.cloneElement(i,{size:20})}),(0,o.jsxs)(l.Z,{spacing:.25,sx:{flex:1,minWidth:0},children:[(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600,color:x?"neutral.100":"text.primary"},children:t}),r&&(0,o.jsx)(a.ZP,{className:"w-full",level:"body-xs",sx:{lineHeight:1.4,color:x?"neutral.400":"#A1A1AA",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:r})]})]})}),(0,o.jsxs)(l.Z,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",sx:{flex:1},children:[g?(0,o.jsx)(Z.Z,{size:"sm"}):(0,o.jsx)(l.Z,{spacing:0,children:(0,o.jsxs)(l.Z,{direction:"row",alignItems:"baseline",spacing:.5,children:[(0,o.jsx)(a.ZP,{level:"h2",sx:{fontWeight:"bold",lineHeight:1,color:x?"neutral.50":"text.primary"}
1,children:"number"==typeof s?s.toLocaleString():s}),j&&(0,o.jsx)(a.ZP,{level:"body-sm",sx:{color:x?"neutral.400":"text.tertiary",fontWeight:400},children:j})]})}),b&&b.length>0&&!g&&!f&&(0,o.jsx)(n.Z,{sx:{width:80,height:50,flexShrink:0},children:(0,o.jsx)(q.h,{width:"100%",height:"100%",children:(0,o.jsxs)(Y.T,{data:b,children:[(0,o.jsx)("defs",{children:(0,o.jsxs)("linearGradient",{id:"gradient-".concat(u),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,o.jsx)("stop",{offset:"5%",stopColor:"warning"===u?"#E2B93B":"success"===u?"#16A34A":"#0284C7",stopOpacity:.4}),(0,o.jsx)("stop",{offset:"95%",stopColor:"warning"===u?"#E2B93B":"success"===u?"#16A34A":"#0284C7",stopOpacity:0})]})}),(0,o.jsx)(G.u,{type:"monotone",dataKey:"value",stroke:"warning"===u?"#E2B93B":"success"===u?"#16A34A":"#0284C7",fill:"url(#gradient-".concat(u,")"),strokeWidth:2.5,isAnimationActive:!1})]})})})]}),null!=h&&p&&!g&&(0,o.jsxs)(l.Z,{direction:"row",alignItems:"center",spacing:.5,sx:{mt:"auto"},children:["up"===h&&(0,o.jsx)(R.Z,{size:14,color:"#2AB014"}),"down"===h&&(0,o.jsx)(L.Z,{size:14,color:"#EF4444"}),"equal"===h&&(0,o.jsx)(H.Z,{size:14,color:x?"#6B7280":"#9CA3AF"}),(0,o.jsx)(a.ZP,{level:"body-xs",sx:{fontWeight:600,color:"up"===h?"#2AB014":"down"===h?"#EF4444":x?"#6B7280":"#9CA3AF"},children:p}),(0,o.jsx)(a.ZP,{level:"body-xs",sx:{color:x?"neutral.400":"#6B7280"},children:v||C("currentMonth")})]})]})})},M=(s=null==h?void 0:null===(t=h.trend)||void 0===t?void 0:t.direction)?"flat"===s?"equal":s:null,D=f(null==h?void 0:null===(r=h.trend)||void 0===r?void 0:r.percentageChange),W=y.conversations.direction,E=y.conversations.value,B=y.queries.direction,$=y.queries.value,J=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toFixed(2);return(0,o.jsxs)(n.Z,{sx:{display:"flex",gap:1.3,flexWrap:"wrap"},children:[(0,o.jsx)(n.Z,{sx:{flex:{xs:"1 1 100%",sm:"1 1 calc(50% - 8px)",md:"1 1 0"},minWidth:{md:0}},children:(0,o.jsx)(z,{title:C("timeSaved"),description:C("timeSavedDesc"),value:g?"-":v((null==h?void 0:h.timeSavedHours)||0),suffix:C("hours"),icon:(0,o.jsx)(Q.Z,{}),iconBgColor:x?"#1D2939":"#E0F2FE",iconColor:"#0284C7",color:"primary",trend:M,trendValue:D,periodLabel:w(i),chartData:A("timeSaved")})}),(0,o.jsx)(n.Z,{sx:{flex:{xs:"1 1 100%",sm:"1 1 calc(50% - 8px)",md:"1 1 0"},minWidth:{md:0}},children:(0,o.jsx)(z,{title:C("creditsUsed"),description:C("creditsUsedDesc"),value:g?"-":J(F),suffix:"/ ".concat(J(k)),icon:(0,o.jsx)(O.Z,{}),iconBgColor:x?"#2D2519":"#F6EFD9",iconColor:"#E2B93B",color:"warning",trend:B,trendValue:$,periodLabel:w(i),chartData:A("credits")})}),(0,o.jsx)(n.Z,{sx:{flex:{xs:"1 1 100%",sm:"1 1 calc(50% - 8px)",md:"1 1 0"},minWidth:{md:0}},children:(0,o.jsx)(z,{title:C("chatsAttended"),description:C("chatsAttendedDesc"),value:g?"-":S,icon:(0,o.jsx)(_.Z,{}),iconBgColor:x?"#2D2519":"#F6EFD9",iconColor:"#E2B93B",color:"primary",trend:W,trendValue:E,periodLabel:w(i),chartData:A("conversations"),dontShowGraph:!0,onClick:()=>d.push(K.n8.LOGS)})})]})}var J=r(95279),X=r(68325),ee=r(38052),et=r(68841),er=r(67145),eo=r(63140),en=r(9553);function es(e){var t;let{range:r="6m"}=e,{metrics:s,isLoading:i,compare:c,stats:d}=p(r),{workspaceMetrics:u,formatCurrency:x,formatHours:h}=V(r),g="dark"===(0,P.F)().palette.mode,{tChart:v,tMetrics:f}=(0,N.ZP)(),b=m.useMemo(()=>s?s.reduce((e,t)=>e+(t.conversations||0),0):0,[s]),y=(null==u?void 0:u.moneySavedUsd)||0,j=(null==u?void 0:u.timeSavedHours)||0,C=(null==d?void 0:null===(t=d.usage)||void 0===t?void 0:t.agentQueries)||0,{chartData:w,maxValue:S}=m.useMemo(()=>{let e=["ENE","FEB","MAR","ABR","MAY","JUN","JUL","AGO","SEPT","OCT","NOV","DIC"],t=["DOM","LUN","MAR","MIE","JUE","VIE","SAB"];if("7d"===r){let e=new Date,r=[];for(let o=6;o>=0;o--){let n=new Date(e);n.setDate(n.getDate()-o);let a=n.getDay(),i=null==s?void 0:s.find(e=>{if(e.date){let[t,r,o]=e.date.split("-").map(Number);return new Date(Date.UTC(t,r-1,o)).toDateString()===n.toDateString()}return!1}),l=(null==i?void 0:i.conversations)||0,c=(null==i?void 0:i.queries)||0,d=b>0?l/b:0,u=b>0?c/Math.max(b,1):0;r.push({label:t[a],moneySaved:Math.round(y*d),timeSaved:parseFloat((j*d).toFixed(1)),creditsUsed:Math.round(C*u)})}let o=Math.max(...r.map(e=>e.moneySaved+10*e.timeSaved+e.creditsUsed),1);return{chartData:r,maxValue:o}}if("anual"===r||"6m"===r||"month"===r){let t=new Date,o="6m"===r?6:12,n=new Map;
1(s||[]).forEach(e=>{let t;if(e.date){let[r,o,n]=e.date.split("-").map(Number);t=new Date(Date.UTC(r,o-1,n))}else{if(!e.month)return;t=new Date(e.month)}if(!Number.isNaN(t.getTime())){let r="".concat(t.getUTCFullYear(),"-").concat(t.getUTCMonth()),o=n.get(r)||{conversations:0,queries:0};n.set(r,{conversations:o.conversations+(e.conversations||0),queries:o.queries+(e.queries||0)})}});let a=[];for(let r=o-1;r>=0;r--){let o=(0,A.W)(t,r),s=(0,en.N)(o),i="".concat(s.getUTCFullYear(),"-").concat(s.getUTCMonth()),l=n.get(i),c=s.getUTCMonth(),d=(null==l?void 0:l.conversations)||0,u=(null==l?void 0:l.queries)||0,x=b>0?d/b:0,m=b>0?u/Math.max(b,1):0;a.push({label:e[c],moneySaved:Math.round(y*x),timeSaved:parseFloat((j*x).toFixed(1)),creditsUsed:Math.round(C*m)})}let i=Math.max(...a.map(e=>e.moneySaved+10*e.timeSaved+e.creditsUsed),1);return{chartData:a,maxValue:i}}return{chartData:[],maxValue:0}},[s,r,b,y,j,C]),F=m.useMemo(()=>w.some(e=>e.moneySaved>0||e.timeSaved>0||e.creditsUsed>0),[w]),k=m.useMemo(()=>0===C?0:Math.round(y/Math.max(C,1)*100),[y,C]),z=m.useMemo(()=>{var e;let t=null==c?void 0:null===(e=c.conversations)||void 0===e?void 0:e.changePct;return"number"!=typeof t||Number.isNaN(t)?0:Math.round(t)},[c]),M={moneySaved:"#22C55E",timeSaved:"#3B82F6",creditsUsed:"#EF4444"};return(0,o.jsx)(I.Z,{variant:"outlined",className:"rounded-2xl",sx:{height:"100%",width:"100%",backgroundColor:g?"neutral.900":"background.page",borderColor:g?"neutral.700":"neutral.200",display:"flex",flexDirection:"column"},children:(0,o.jsx)(U.Z,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:1,minHeight:0},children:(0,o.jsxs)(l.Z,{spacing:2,sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[(0,o.jsxs)(n.Z,{sx:{flexShrink:0},children:[(0,o.jsx)(a.ZP,{level:"title-lg",sx:{color:g?"neutral.100":"text.primary",fontWeight:600},children:v("roiTitle")}),(0,o.jsx)(a.ZP,{level:"body-xs",sx:{color:g?"neutral.400":"#A1A1AA",mt:.5},children:v("roiSubtitle")})]}),!i&&(0,o.jsxs)(l.Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},direction:"row",alignItems:"center",spacing:2,children:[(0,o.jsxs)(a.ZP,{level:"h1",sx:{fontSize:"2.5rem",fontWeight:700,lineHeight:1,color:g?"neutral.100":"neutral.900"},children:["+",k,"%"]}),(0,o.jsxs)(l.Z,{direction:"row",alignItems:"center",spacing:.5,children:[(0,o.jsx)(R.Z,{size:16,color:"#22C55E"}),(0,o.jsxs)(a.ZP,{level:"body-sm",sx:{color:"#22C55E",fontWeight:600,display:"flex",flexDirection:"row",alignItems:" center"},children:[z>=0?"+":"",z,"%",(0,o.jsx)("p",{className:"".concat(g?"text-neutral-400":"text-[#A1A1AA]"," pl-2 "),children:"ROI Total"})]})]})]}),i?(0,o.jsx)(n.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,minHeight:0},children:(0,o.jsx)(Z.Z,{})}):F?(0,o.jsx)(n.Z,{sx:{flex:1,minHeight:180},children:(0,o.jsx)(q.h,{width:"100%",height:"100%",children:(0,o.jsxs)(X.v,{data:w,margin:{top:8,right:0,left:0,bottom:0},barCategoryGap:"20%",children:[(0,o.jsx)(ee.K,{dataKey:"label",tick:{fontSize:11,fill:g?"#A3A3A3":"#6B7280"},tickLine:!1,axisLine:!1}),(0,o.jsx)(et.B,{hide:!0,domain:[0,"auto"]}),(0,o.jsx)(er.u,{cursor:{fill:g?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.05)"},contentStyle:{backgroundColor:g?"#262626":"#FFFFFF",border:"1px solid ".concat(g?"#404040":"#E5E7EB"),borderRadius:8,color:g?"#FAFAFA":"#171717"},formatter:(e,t)=>[{moneySaved:"$".concat(e.toLocaleString()),timeSaved:"".concat(e,"h"),creditsUsed:"$".concat(e.toLocaleString())}[t]||e,""]}),(0,o.jsx)(eo.$,{dataKey:"creditsUsed",stackId:"roi",fill:M.creditsUsed,radius:[0,0,4,4],maxBarSize:50}),(0,o.jsx)(eo.$,{dataKey:"timeSaved",stackId:"roi",fill:M.timeSaved,maxBarSize:50}),(0,o.jsx)(eo.$,{dataKey:"moneySaved",stackId:"roi",fill:M.moneySaved,radius:[4,4,0,0],maxBarSize:50})]})})}):(0,o.jsx)(n.Z,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flex:1,minHeight:180},children:(0,o.jsx)(a.ZP,{level:"body-md",sx:{color:g?"neutral.400":"neutral.600"},children:v("noData")})}),(0,o.jsxs)(l.Z,{spacing:1.5,sx:{flexShrink:0},children:[(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[(0,o.jsxs)(l.Z,{direction:"row",spacing:1,alignItems:"center",children:[(0,o.jsx)(n.Z,{sx:{width:12,height:12,borderRadius:"100px",backgroundColor:M.moneySaved}}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{color:g?"neutral.300":"neutral.700"},children:f("moneySaved")})]}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{fontWeight:600,color:g?"neutral.100":"text.primary"},children:x(y)})]}),(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[(0,o.jsxs)(l.Z,{direction:"row",spacing:1,alignItems:"center",children:[(0,o.jsx)(n.Z,{sx:{width:12,height:12,borderRadius:"100px",backgroundColor:M.timeSaved}}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{color:g?"neutral.300":"neutral.700"},children:f("timeRecovered")})]}),(0,o.jsxs)(a.ZP,{level:"body-sm",sx:{fontWeight:600,color:g?"neutral.100":"text.primary"},children:[h(j),"h"]})]}),(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[(0,o.jsxs)(l.Z,{direction:"row",spacing:1,alignItems:"center",children:[(0,o.jsx)(n.Z,{sx:{width:12,height:12,borderRadius:"100px",backgroundColor:M.creditsUsed}}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{color:g?"neutral.300":"neutral.700"},children:f("creditsUsed")})]}),(0,o.jsxs)(a.ZP,{level:"body-sm",sx:{fontWeight:600,color:g?"neutral.100":"text.primary"}
1,children:["$",C.toLocaleString()]})]})]}),(0,o.jsx)(J.Z,{sx:{my:.5}}),(0,o.jsxs)(l.Z,{spacing:1,sx:{flexShrink:0},children:[(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[(0,o.jsx)(a.ZP,{level:"body-xs",sx:{color:g?"neutral.400":"#A1A1AA"},children:v("avgHumanTime")}),(0,o.jsx)(a.ZP,{level:"body-xs",sx:{color:g?"neutral.300":"neutral.700"},children:v("avgHumanTimeValue")})]}),(0,o.jsxs)(l.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[(0,o.jsx)(a.ZP,{level:"body-xs",sx:{color:g?"neutral.400":"#A1A1AA"},children:v("estimatedRate")}),(0,o.jsx)(a.ZP,{level:"body-xs",sx:{color:g?"neutral.300":"neutral.700"},children:v("estimatedRateValue")})]})]})]})})})}var ea=r(9390);function ei(e){let{onAgentClick:t,limit:r=5}=e,{agentMetrics:s,isLoading:i,formatCurrency:c,formatHours:d}=V("month"),{metrics:u}=p("month"),{tMetrics:x}=(0,N.ZP)(),h="dark"===(0,P.F)().palette.mode,g=e=>{let t=e.split(" ");return t.length<=1?e:(0,o.jsxs)(o.Fragment,{children:[t[0],(0,o.jsx)("br",{}),t.slice(1).join(" ")]})},v=m.useMemo(()=>s?[...s].sort((e,t)=>t.moneySavedUsd-e.moneySavedUsd).slice(0,r):[],[s,r]),f=e=>e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toFixed(0);return i?(0,o.jsx)(I.Z,{className:"h-full rounded-2xl",variant:"outlined",sx:{backgroundColor:h?"neutral.900":"background.surface",borderColor:h?"neutral.700":"neutral.200"},children:(0,o.jsx)(U.Z,{sx:{display:"flex",justifyContent:"center",p:4,alignSelf:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(Z.Z,{sx:{paddingBottom:"250px"}})})}):(0,o.jsx)(I.Z,{variant:"outlined",className:"rounded-2xl",sx:{borderRadius:"md",height:"100%",backgroundColor:h?"neutral.900":"background.page",borderColor:h?"neutral.700":"neutral.200",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:(0,o.jsx)(U.Z,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0,p:2},children:(0,o.jsxs)(l.Z,{spacing:2,sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[(0,o.jsx)(n.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexShrink:0},children:(0,o.jsxs)(n.Z,{children:[(0,o.jsx)(a.ZP,{level:"h4",component:"h2",sx:{color:h?"neutral.100":"text.primary"},children:x("topAgents")}),(0,o.jsx)(a.ZP,{level:"body-sm",sx:{mt:.5,color:h?"neutral.400":"#A1A1AA"},children:x("topAgentsDesc")})]})}),(0,o.jsx)(n.Z,{sx:{flex:1,minHeight:0,overflow:"auto",borderRadius:"md"},children:v.length>0?(0,o.jsxs)(ea.Z,{sx:{width:"100%",tableLayout:"fixed","--TableCell-borderColor":"transparent","& th, & td":{borderBottom:"none !important",borderTop:"none !important"},"& thead th":{borderBottom:"none !important"},"& tbody tr":{borderBottom:"none !important"},"& tr":{borderBottom:"none !important"}},children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{children:[(0,o.jsx)("th",{style:{width:"30%",textAlign:"left",padding:"12px 8px",fontWeight:600,fontSize:"0.7rem",textTransform:"uppercase",color:h?"#A3A3A3":"#6B7280",backgroundColor:"transparent",borderBottom:"none",lineHeight:1.3},children:x("aiEmployee")}),(0,o.jsx)("th",{style:{width:"18%",textAlign:"center",padding:"12px 8px",fontWeight:600,fontSize:"0.7rem",textTransform:"uppercase",color:h?"#A3A3A3":"#6B7280",backgroundColor:"transparent",borderBottom:"none",lineHeight:1.3,whiteSpace:"normal",wordBreak:"break-word",overflow:"visible",textOverflow:"unset"}
1,children:g(x("timeRecovered"))}),(0,o.jsx)("th",{style:{width:"18%",textAlign:"center",padding:"12px 8px",fontWeight:600,fontSize:"0.7rem",textTransform:"uppercase",color:h?"#A3A3A3":"#6B7280",backgroundColor:"transparent",borderBottom:"none",lineHeight:1.3,whiteSpace:"normal",wordBreak:"break-word",overflow:"visible",textOverflow:"unset"},children:g(x("creditsConsumed"))}),(0,o.jsx)("th",{style:{width:"18%",textAlign:"center",padding:"12px 8px",fontWeight:600,fontSize:"0.7rem",textTransform:"uppercase",color:h?"#A3A3A3":"#6B7280",backgroundColor:"transparent",borderBottom:"none",lineHeight:1.3,whiteSpace:"normal",wordBreak:"break-word",overflow:"visible",textOverflow:"unset"},children:g(x("chatsAttended"))}),(0,o.jsx)("th",{style:{width:"17%",textAlign:"center",padding:"12px 8px",fontWeight:600,fontSize:"0.7rem",textTransform:"uppercase",color:h?"#A3A3A3":"#6B7280",backgroundColor:"transparent",borderBottom:"none",lineHeight:1.3,whiteSpace:"normal",wordBreak:"break-word",overflow:"visible",textOverflow:"unset"},children:g(x("roi"))})]})}),(0,o.jsx)("tbody",{children:v.map((e,r)=>(0,o.jsxs)("tr",{onClick:()=>null==t?void 0:t(e.agentId),style:{cursor:t?"pointer":"default",backgroundColor:"transparent",transition:"background-color 0.2s"},onMouseEnter:e=>{t&&(e.currentTarget.style.backgroundColor=h?"#262626":"#F5F5F5")},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[(0,o.jsx)("td",{style:{textAlign:"left",padding:"12px 8px"},children:(0,o.jsxs)(l.Z,{direction:"row",spacing:1.5,alignItems:"center",children:[(0,o.jsx)(T.Z,{alt:e.agentName,src:e.iconUrl,sx:{width:32,height:32}}),(0,o.jsx)(a.ZP,{level:"body-sm",fontWeight:500,sx:{color:h?"neutral.100":"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.agentName})]})}),(0,o.jsx)("td",{style:{textAlign:"center",padding:"12px 8px"},children:(0,o.jsxs)(a.ZP,{level:"body-sm",fontWeight:500,sx:{color:h?"neutral.400":"text.primary.500"},children:[d(e.timeSavedHours||0),"h"]})}),(0,o.jsx)("td",{style:{textAlign:"center",padding:"12px 8px"},children:(0,o.jsx)(a.ZP,{level:"body-sm",fontWeight:500,sx:{color:h?"neutral.300":"text.primary.500"},children:f(e.creditsConsumed||0)})}),(0,o.jsx)("td",{style:{textAlign:"center",padding:"12px 8px"},children:(0,o.jsx)(a.ZP,{level:"body-sm",fontWeight:500,sx:{color:h?"neutral.300":"text.primary.500"},children:(e.totalQueries||0).toLocaleString()})}),(0,o.jsx)("td",{style:{textAlign:"center",padding:"12px 8px"},children:(0,o.jsx)(a.ZP,{level:"body-sm",fontWeight:600,sx:{color:(e.moneySavedUsd||0)>0?h?"#86EFAC":"#16A34A":h?"neutral.400":"neutral.600"},children:c(e.moneySavedUsd||0)})})]},e.agentId))})]}):(0,o.jsx)(n.Z,{sx:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",px:3,textAlign:"center"},children:(0,o.jsx)(a.ZP,{level:"body-md",sx:{color:h?"neutral.400":"neutral.600"},children:x("noMovements")})})})]})})})}var el=r(51234),ec=r(43815),ed=!0;function eu(){var e,t,r,h,g,v;(0,u.useRouter)();let f=(0,x.bp)(),{open:b}=(0,B.Y)(),{open:y}=(0,el.o2)(),{open:j}=(0,ec.j1)(),{tPages:C,tMetrics:w,tWelcome:Z,tErrors:S,tCommon:P,tQuickActions:F,tChart:k,t:A}=(0,N.ZP)(),[z,M]=m.useState("6m"),{stats:D,isLoading:W,error:I,refreshStats:U}=p("6m"),[T,R]=m.useState(!1);return I?(0,o.jsx)(n.Z,{sx:{p:3},children:(0,o.jsxs)(s.Z,{color:"danger",variant:"soft",children:[(0,o.jsx)(a.ZP,{level:"title-md",children:S("loadingDashboard")}),(0,o.jsx)(a.ZP,{level:"body-sm",children:S("loadingDataMessage")}),(0,o.jsx)(i.Z,{variant:"outlined",color:"danger",onClick:U,sx:{mt:2},children:S("retry")})]})}):(0,o.jsxs)(n.Z,{component:"main",className:"MainContent",sx:e=>({px:{xs:2,md:6},pt:{xs:0,md:0},pb:{xs:2,sm:2,md:3},flex:1,display:"flex",flexDirection:"column",minWidth:0,width:"100%",gap:3,backgroundColor:"background.page"}),children:[(0,o.jsx)(l.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",width:"100%",spacing:1,children:(0,o.jsxs)(l.Z,{className:"w-full",spacing:1,children:[(0,o.jsxs)("div",{className:"flex flex-row w-full items-center justify-between ",children:[(0,o.jsx)(a.ZP,{level:"body-lg",color:"neutral",className:"text-neutral-500",children:Z("title",{name:(null==f?void 0:null===(r=f.data)||void 0===r?void 0:null===(t=r.user)||void 0===t?void 0:null===(e=t.name)||void 0===e?void 0:e.split(" ")[0])||(null==f?void 0:null===(v=f.data)||void 0===v?void 0:null===(g=v.user)||void 0===g?void 0:null===(h=g.email)||void 0===h?void 0:h.split("@")[0])||"Laburante"})}),(0,o.jsx)(i.Z,{className:"bg-[#262626] rounded-full",size:"md",onClick:()=>R(!0),children:F("generateReport")})]}),(0,o.jsx)(a.ZP,{level:"h1",className:"font-bold",children:Z("roiSubtitle")}),(0,o.jsx)(a.ZP,{level:"body-lg",children:Z("subtitle")})]})}),(0,o.jsxs)(c.Z,{className:"rounded-lg w-fit",value:z,onChange:(e,t)=>
1t&&M(t),size:"sm",sx:{minWidth:120,borderColor:"neutral.300",backgroundColor:"background.surface"},children:[(0,o.jsx)(d.Z,{value:"7d",children:k("range7d")}),(0,o.jsx)(d.Z,{value:"month",children:k("rangeMonth")}),(0,o.jsx)(d.Z,{value:"6m",children:k("range6m")}),(0,o.jsx)(d.Z,{value:"anual",children:k("rangeYear")})]}),(0,o.jsx)($,{range:z,agentCount:(null==D?void 0:D.agents)||0}),(0,o.jsxs)(n.Z,{className:"flex flex-row max-[1240px]:flex-col",sx:{display:"flex",gap:2.5,minHeight:"700px"},children:[(0,o.jsx)(n.Z,{className:"w-[50%] max-[1240px]:w-full",sx:{display:"flex",flexDirection:"column",height:"100%",gap:2.5},children:(0,o.jsx)(n.Z,{sx:{flex:1,minHeight:0},children:(0,o.jsx)(es,{range:z})})}),(0,o.jsx)(n.Z,{className:"w-[50%] max-[1240px]:w-full",sx:{minHeight:"500px"},children:(0,o.jsx)(ei,{})})]}),(0,o.jsx)(E,{isOpen:T,onClose:()=>R(!1)})]})}eu.getLayout=function(e){return(0,o.jsx)(v.Z,{children:e})}}},function(e){e.O(0,[256,7626,9667,9981,5287,7230,1551,8099,2149,3799,93,3963,321,2694,11,8673,3970,3223,2408,8915,2508,4919,2888,9774,179],function(){return e(e.s=62189)}),_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.