PageSourceSearch

https://multibot-premium-prod.up.railway.app/assets/Insights.DvMJn5ka.js

js multibot-premium-prod.up.railway.app collected 2026-10-03 12:15:29 UTC 16,081 bytes, 1 lines download raw bytes

1import{a as e}from"./rolldown-runtime.B0Z9INg1.js";import{J as t,K as n}from"./advanced-inputs.CBkcmbZa.js";import{_r as r,ct as i,dn as a}from"./vendor.Dd5JR0lN.js";import{t as o}from"./i18n.mgdc0_67.js";import{r as s}from"./routing.BFlqluFm.js";import{Ep as c,Ff as l,Gs as u,Jd as d,Va as f,Wc as p,ed as m,hp as h,i as g,in as _,mn as ee,tp as v,yi as y}from"./hooks.Cul6Zwkk.js";import{n as te,t as b}from"./queries.CgI9jRuf.js";var x=e(t(),1),S=864e5;function C(e,t){let n=new Date(e);return{startDate:new Date(e.getTime()-t*S),endDate:n}}var w=n(),T=[{value:`24h`,labelKey:`com_insights_range_24_hours`,days:1},{value:`7d`,labelKey:`com_insights_range_7_days`,days:7},{value:`30d`,labelKey:`com_insights_range_30_days`,days:30}],E=350,D=350;function O(e,t){return new Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(e)}function k(e,t){return new Intl.NumberFormat(t).format(e)}function A(e,t){return new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`,year:`numeric`}).format(new Date(e))}function j(e,t){let n=new Date(e),r=new Date,i=Math.floor((r.getTime()-n.getTime())/6e4),a=new Intl.RelativeTimeFormat(t,{numeric:`auto`,style:`narrow`});return i<1?a.format(0,`minute`):i<60?a.format(-i,`minute`):i<1440?a.format(-Math.floor(i/60),`hour`):i<10080?a.format(-Math.floor(i/1440),`day`):new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`,...n.getFullYear()===r.getFullYear()?{}:{year:`numeric`}}).format(n)}function M(e,t){return e||t(`com_insights_unknown_user`)}function N(e){return e?.response?.status}function P(e){let t=T.find(t=>t.value===e)?.days??7;return C(new Date,t)}function F({children:e,className:t}){return(0,w.jsx)(`section`,{className:p(`min-w-0 rounded-lg border border-border-light bg-surface-primary p-5`,t),children:e})}function I({message:e}){return(0,w.jsx)(`div`,{className:`flex min-h-40 items-center justify-center text-sm text-text-secondary`,children:e})}function L({message:e}){return(0,w.jsxs)(F,{className:`flex min-h-52 flex-col items-center justify-center gap-3`,children:[(0,w.jsx)(l,{className:`size-7 text-text-secondary`}),(0,w.jsx)(`span`,{className:`text-sm text-text-secondary`,children:e})]})}function R({values:e,label:t,locale:n}){let r=(0,x.useId)().replace(/:/g,``),[i,a]=(0,x.useState)(),o=(0,x.useMemo)(()=>{if(e.length<2)return[];let t=Math.max(1,...e.map(e=>e.value));return e.map((n,r)=>({...n,x:r/(e.length-1)*300,y:52-n.value/t*46}))},[e]);if(o.length<2)return(0,w.jsx)(`div`,{className:`h-14`});let s=o.map(e=>`${e.x},${e.y}`).join(` `),c=`M 0 56 L ${o.map(e=>`${e.x} ${e.y}`).join(` L `)} L 300 56 Z`,l=i==null?void 0:o[i],u=new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`});return(0,w.jsxs)(`div`,{className:`relative mt-2 h-14 w-full text-status-info outline-none`,role:`img`,tabIndex:0,"aria-label":t,onFocus:()=>a(o.length-1),onBlur:()=>a(void 0),onMouseLeave:()=>a(void 0),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect(),n=Math.max(0,Math.min(1,(e.clientX-t.left)/t.width));a(Math.round(n*(o.length-1)))},children:[(0,w.jsxs)(`svg`,{className:`h-full w-full overflow-visible`,viewBox:`0 0 300 56`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`pattern`,{id:r,width:`6`,height:`6`,patternUnits:`userSpaceOnUse`,children:(0,w.jsx)(`path`,{d:`M-1 1 L1 -1 M0 6 L6 0 M5 7 L7 5`,stroke:`currentColor`,strokeWidth:`0.8`,opacity:`0.22`})})}),(0,w.jsx)(`path`,{d:c,fill:`url(#${r})`}),(0,w.jsx)(`polyline`,{points:s,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`})]}),l&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`pointer-events-none absolute top-0 h-full w-px bg-border-medium`,style:{left:`${l.x/300*100}%`}}),(0,w.jsx)(`span`,{className:`pointer-events-none absolute size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-status-info ring-2 ring-surface-primary`,style:{left:`${l.x/300*100}%`,top:`${l.y/56*100}%`}}),(0,w.jsxs)(`span`,{className:`pointer-events-none absolute bottom-full mb-2 -translate-x-1/2 whitespace-nowrap rounded-lg border border-border-light bg-surface-primary px-2.5 py-1.5 text-xs text-text-primary shadow-lg`,style:{left:`${Math.max(14,Math.min(86,l.x/300*100))}%`},children:[u.format(new Date(l.date)),` `,(0,w.jsx)(`strong`,{children:k(l.value,n)})]})]})]})}function z({card:e,locale:t}
1){let n=f();return(0,w.jsxs)(F,{children:[(0,w.jsx)(`h2`,{className:`text-lg font-normal text-text-secondary`,children:e.title}),(0,w.jsx)(`div`,{className:`mt-3 text-4xl font-semibold tabular-nums leading-none text-text-primary`,children:O(e.value,t)}),(0,w.jsx)(R,{values:e.sparkline,label:n(`com_insights_sparkline_accessibility`,{label:e.title}),locale:t})]})}function B({title:e,children:t}){return(0,w.jsxs)(F,{className:`overflow-hidden`,children:[(0,w.jsx)(`h2`,{className:`mb-3 text-base font-semibold text-text-primary`,children:e}),t]})}function V({name:e,email:t,localize:n}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`truncate text-text-primary`,children:M(e,n)}),(0,w.jsx)(`div`,{className:`truncate text-xs text-text-secondary`,children:t})]})}function H({rows:e,localize:t,locale:n}){return(0,w.jsx)(B,{title:t(`com_insights_top_users`),children:e.length===0?(0,w.jsx)(I,{message:t(`com_insights_no_data`)}):(0,w.jsx)(`div`,{className:`overflow-x-auto`,children:(0,w.jsxs)(`table`,{className:`w-full min-w-[420px] text-left text-sm`,children:[(0,w.jsx)(`thead`,{className:`border-b border-border-medium text-xs text-text-secondary`,children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:t(`com_insights_user`)}),(0,w.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:t(`com_insights_messages`)}),(0,w.jsx)(`th`,{className:`px-2 py-2 text-right font-medium`,children:t(`com_insights_chats`)})]})}),(0,w.jsx)(`tbody`,{className:`divide-y divide-border-light`,children:e.map(e=>(0,w.jsxs)(`tr`,{className:`hover:bg-surface-hover`,children:[(0,w.jsx)(`td`,{className:`px-2 py-3`,children:(0,w.jsx)(V,{...e,localize:t})}),(0,w.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:k(e.messages,n)}),(0,w.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:k(e.conversations,n)})]},e.userId))})]})})})}function U({rows:e,localize:t,locale:n}){let r=t(`com_insights_churned_users_definition`);return(0,w.jsx)(B,{title:(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[t(`com_insights_churned_users`),(0,w.jsx)(v,{description:r,render:(0,w.jsx)(`button`,{type:`button`,"aria-label":r,className:`text-text-secondary hover:text-text-primary`,children:(0,w.jsx)(a,{className:`size-4`,"aria-hidden":`true`})})})]}),children:e.length===0?(0,w.jsx)(I,{message:t(`com_insights_no_data`)}):(0,w.jsx)(`div`,{className:`overflow-x-auto`,children:(0,w.jsxs)(`table`,{className:`w-full min-w-[560px] table-fixed text-left text-sm`,children:[(0,w.jsx)(`thead`,{className:`border-b border-border-medium text-xs text-text-secondary`,children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{className:`w-[34%] px-2 py-2 font-medium`,children:t(`com_insights_user`)}),(0,w.jsx)(`th`,{className:`w-[12%] px-2 py-2 text-right font-medium`,children:t(`com_insights_messages`)}),(0,w.jsx)(`th`,{className:`w-[12%] px-2 py-2 text-right font-medium`,children:t(`com_insights_chats`)}),(0,w.jsx)(`th`,{className:`w-[21%] px-2 py-2 text-right font-medium`,children:t(`com_insights_first_seen`)}),(0,w.jsx)(`th`,{className:`w-[21%] px-2 py-2 text-right font-medium`,children:t(`com_insights_last_seen`)})]})}),(0,w.jsx)(`tbody`,{className:`divide-y divide-border-light`,children:e.map(e=>(0,w.jsxs)(`tr`,{className:`hover:bg-surface-hover`,children:[(0,w.jsx)(`td`,{className:`overflow-hidden px-2 py-3`,children:(0,w.jsx)(V,{...e,localize:t})}),(0,w.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:k(e.messages,n)}),(0,w.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:k(e.conversations,n)}),(0,w.jsx)(`td`,{className:`whitespace-nowrap px-2 py-3 text-right text-text-secondary`,children:A(e.firstSeen,n)}),(0,w.jsx)(`td`,{className:`whitespace-nowrap px-2 py-3 text-right text-text-secondary`,children:A(e.lastSeen,n)})]},e.userId))})]})})})}function W({rows:e,search:t,activeSearch:n,page:r,pages:a,isFetching:o,setPage:s,setSearch:c,localize:u,locale:f}){return(0,w.jsxs)(F,{className:`overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`mb-3 flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`h2`,{className:`text-base font-semibold`,children:u(`com_insights_latest_conversations`)}),o&&(0,w.jsx)(l,{className:`size-4 text-text-secondary`})]}),(0,w.jsxs)(`div`,{className:`relative w-full sm:max-w-md`,children:[(0,w.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-secondary`,"aria-hidden":`true`}),(0,w.jsx)(d,{"aria-label":u(`com_insights_search_placeholder`),className:`pl-9`,maxLength:200,onChange:e=>c(e.target.value),placeholder:u(`com_insights_search_placeholder`),value:t})]})]}),(0,w.jsx)(`div`,{className:`overflow-x-auto`,children:(0,w.jsxs)(`table`,{className:`w-full min-w-[760px] table-fixed text-left text-sm`,children:[(0,w.jsx)(`thead`,{className:`border-b border-border-medium text-xs text-text-secondary`,children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{className:`w-[120px] px-2 py-2 font-medium`,children:u(`com_insights_date`)}),(0,w.jsx)(`th`,{className:`w-[192px] px-2 py-2 font-medium`,children:u(`com_insights_user`)}),(0,w.jsx)(`th`,{className:`px-2 py-2 font-medium`,children:u(`com_insights_first_message`)}),(0,w.jsx)(`th`,{className:`w-20 px-2 py-2 text-right font-medium`,children:u(`com_insights_messages`)}),(0,w.jsx)(`th`,{className:`w-20 px-2 py-2 text-right font-medium`,children:u(`com_insights_total_tokens`)})]})}
1),(0,w.jsx)(`tbody`,{className:`divide-y divide-border-light`,children:e.map(e=>(0,w.jsxs)(`tr`,{className:`hover:bg-surface-hover`,children:[(0,w.jsx)(`td`,{className:`whitespace-nowrap px-2 py-3 text-text-secondary`,children:j(e.date,f)}),(0,w.jsx)(`td`,{className:`px-2 py-3`,children:(0,w.jsx)(V,{...e,localize:u})}),(0,w.jsx)(`td`,{className:`max-w-xl px-2 py-3`,children:(0,w.jsx)(`span`,{className:`line-clamp-2`,children:e.firstMessage||u(`com_insights_no_message`)})}),(0,w.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:k(e.messages,f)}),(0,w.jsx)(`td`,{className:`px-2 py-3 text-right tabular-nums`,children:O(e.totalTokens,f)})]},`${e.conversationId}:${e.userId}`))})]})}),e.length===0&&(0,w.jsx)(I,{message:u(n?`com_insights_no_search_results`:`com_insights_no_data`)}),(0,w.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-border-light pt-3 text-sm text-text-secondary`,children:[(0,w.jsx)(`span`,{children:u(`com_insights_page_of`,{page:r,pages:a})}),(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(m,{variant:`outline`,size:`sm`,disabled:o||r<=1,onClick:()=>s(e=>Math.max(1,e-1)),children:u(`com_ui_prev`)}),(0,w.jsx)(m,{variant:`outline`,size:`sm`,disabled:o||r>=a,onClick:()=>s(e=>e+1),children:u(`com_ui_next`)})]})]})]})}function G(){let e=f(),{i18n:t}=o(),n=t.resolvedLanguage??t.language??`en`,i=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,{user:a}=ee(),{data:l,isLoading:d}=u(),[v,S]=(0,x.useState)(`7d`),[C,O]=(0,x.useState)(),[k,A]=(0,x.useState)(``),[j,M]=(0,x.useState)(``),[I,R]=(0,x.useState)(1),B=(0,x.useRef)(),V=h(`(max-width: 768px)`),G=l?.insightsEnabled===!0,K=a?.role===c.ADMIN&&G,q=b(a?.id,{enabled:K}),J=G&&q.data?.access===!0,Y=(0,x.useMemo)(()=>{let e={page:I,pageSize:10,search:j,timeZone:i};return C?{...e,range:`custom`,fromTimestamp:C.startDate.toISOString(),toTimestamp:C.endDate.toISOString()}:{...e,range:v}},[C,I,v,j,i]),X=(0,x.useMemo)(()=>C??P(v),[C,v]),Z=te(Y,{enabled:J}),Q=Z.data;g(`${e(`com_insights_title`)} | LibreChat`),(0,x.useEffect)(()=>()=>{B.current!=null&&window.clearTimeout(B.current)},[]),(0,x.useEffect)(()=>{let e=k.trim().slice(0,200),t=e.length>=3?e:``;if(t===j)return;let n=window.setTimeout(()=>{M(t),R(1)},D);return()=>window.clearTimeout(n)},[j,k]);let ne=(0,x.useMemo)(()=>Q?[{id:`conversations`,title:e(`com_insights_total_conversations`),value:Q.summary.totalConversations,sparkline:Q.daily.map(e=>({date:e.date,value:e.conversations}))},{id:`users`,title:e(`com_insights_total_users`),value:Q.summary.totalUsers,sparkline:Q.daily.map(e=>({date:e.date,value:e.users}))},{id:`messages`,title:e(`com_insights_messages`),value:Q.summary.totalMessages,sparkline:Q.daily.map(e=>({date:e.date,value:e.messages}))},{id:`tokens`,title:e(`com_insights_total_tokens`),value:Q.summary.totalTokens,sparkline:Q.daily.map(e=>({date:e.date,value:e.totalTokens}))}]:[],[Q,e]),re=(e,t)=>{B.current!=null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{O({startDate:new Date(e),endDate:new Date(t)}),R(1),B.current=void 0},E)};if(d||K&&q.isLoading)return(0,w.jsx)(`div`,{className:`h-full w-full bg-presentation p-4`,children:(0,w.jsx)(L,{message:e(`com_insights_loading`)})});let $=N(q.error);return q.isError&&$!==403&&$!==404?(0,w.jsx)(`div`,{className:`h-full w-full bg-presentation p-4`,children:(0,w.jsxs)(F,{className:`flex items-center gap-2`,children:[(0,w.jsx)(r,{className:`size-4 text-status-error`}),(0,w.jsx)(`span`,{className:`text-sm`,children:e(`com_insights_load_error`)})]})}):J?(0,w.jsxs)(`div`,{className:`flex h-full w-full min-w-0 flex-col bg-presentation text-text-primary`,children:[(0,w.jsxs)(`header`,{className:`z-20 flex min-h-14 w-full flex-shrink-0 flex-col gap-3 border-b border-border-light bg-presentation px-4 py-3 sm:px-5 md:flex-row md:items-center md:justify-between md:px-6 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[V&&(0,w.jsx)(y,{}),(0,w.jsx)(`h1`,{className:`text-base font-semibold`,children:e(`com_insights_title`)})]}),(0,w.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center gap-2 md:flex-nowrap`,children:[(0,w.jsx)(`div`,{className:`inline-flex rounded-lg border border-border-light p-0.5`,children:T.map(t=>(0,w.jsx)(m,{size:`sm`,variant:`ghost`,"aria-pressed":!C&&v===t.value,className:p(`h-8 rounded-md px-3`,!C&&v===t.value&&`bg-surface-active-alt`),onClick:()=>{B.current!=null&&(window.clearTimeout(B.current),B.current=void 0),S(t.value),O(void 0),R(1)},children:e(t.labelKey)},t.value))}),(0,w.jsx)(`div`,{className:`w-full min-w-0 sm:w-[340px]`,children:(0,w.jsx)(_,{endDate:X.endDate,futureDatesDisabled:!0,labels:{apply:e(`com_ui_done`),cancel:e(`com_ui_cancel`),endDate:e(`com_insights_end_date`),invalidRange:e(`com_insights_invalid_date_range`,{days:30}),startDate:e(`com_insights_start_date`)},locale:n,maxRangeLength:30,onSelectDateRange:re,placeholder:e(`com_insights_date_range_placeholder`),startDate:X.startDate})})]})]}),(0,w.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,children:(0,w.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-5 px-4 py-4 sm:px-5 md:px-6 lg:px-8`,children:[Z.isLoading&&(0,w.jsx)(L,{message:e(`com_insights_loading`)}),Z.isError&&(0,w.jsxs)(F,{className:`flex items-center gap-2`,children:[(0,w.jsx)(r,{className:`size-4 text-status-error`}),(0,w.jsx)(`span`,{className:`text-sm`,children:e(`com_insights_load_error`)})]}),Q&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`grid w-full grid-cols-[repeat(auto-fit,minmax(min(100%,220px),1fr))] gap-3`,children:ne.map(e=>(0,w.jsx)(z,{card:e,locale:n},e.id))}),(0,w.jsxs)(`div`,{className:`grid w-full grid-cols-[repeat(auto-fit,minmax(min(100%,580px),1fr))] gap-3`,children:[(0,w.jsx)(H,{rows:Q.topUsers,localize:e,locale:n}),(0,w.jsx)(U,{rows:Q.churnedUsers,localize:e,locale:n})]}),(0,w.jsx)(W,{rows:Q.latest.conversations,search:k,activeSearch:j,page:Q.latest.page,pages:Q.latest.pages,isFetching:Z.isFetching,setPage:R,setSearch:A,localize:e,locale:n})]})]})})]}):(0,w.jsx)(s,{to:`/c/new`,replace:!0})}export{G as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.