1import{v as M,o as K,A as w,j as e,ab as se,ac as re,ad as te,ae as H,C as p,G as i,$ as ie,D as j,T as t,af as ne,aa as F,X as k,a7 as f,E as m,ag as ae,Y as oe,I as Y,J as le,ah as G,U as v}from"./index-dE8a1mPK.js";import{H as ce}from"./HandleLink-CMsO54nu.js";import{E as de}from"./ErrorState-gVNyx0--.js";import{u as he}from"./time-format-A04hRRvf.js";import{S as pe}from"./Select-DebRlW67.js";import{S as me}from"./SegmentedControl-CNEtbfTu.js";import{I as Z}from"./IconArrowRight-Ajq43paw.js";import{S as U}from"./SimpleGrid-DkEuk0DW.js";import{I as xe}from"./IconSend-D-OEBegQ.js";import{I as ge}from"./IconMessageReply-B0QqDoCF.js";import{I as ue}from"./IconHeart-CFNXoJCy.js";import{I as je}from"./IconRepeat-BAxCrsfr.js";import{A as ye}from"./AreaChart-DF3EymE-.js";import{I as we}from"./IconHeartbeat-BJm5Ye4o.js";import{I as ve}from"./IconClock-DGXUTa2e.js";import"./IconExternalLink-DcQXcLz7.js";import"./IconCopy-B63sUmw8.js";import"./Code-YtMEZkZ5.js";import"./OptionsDropdown-wonErrz5.js";import"./CheckIcon-DkMc45y2.js";import"./get-env-uyVen0u2.js";import"./grid-chart.module.css-B4DgdMZ7.js";/** 2 * @license @tabler/icons-react v3.43.0 - MIT 3 * 4 * This source code is licensed under the MIT license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const fe=[["path",{d:"M3 6a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M7 8h10",key:"svg-1"}],["path",{d:"M7 12h10",key:"svg-2"}],["path",{d:"M7 16h10",key:"svg-3"}]],be=M("outline","article","Article",fe);/** 7 * @license @tabler/icons-react v3.43.0 - MIT 8 * 9 * This source code is licensed under the MIT license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ze=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]],B=M("outline","circle-check","CircleCheck",ze);/** 12 * @license @tabler/icons-react v3.43.0 - MIT 13 * 14 * This source code is licensed under the MIT license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ke=[["path",{d:"M8.56 3.69a9 9 0 0 0 -2.92 1.95",key:"svg-0"}],["path",{d:"M3.69 8.56a9 9 0 0 0 -.69 3.44",key:"svg-1"}],["path",{d:"M3.69 15.44a9 9 0 0 0 1.95 2.92",key:"svg-2"}],["path",{d:"M8.56 20.31a9 9 0 0 0 3.44 .69",key:"svg-3"}],["path",{d:"M15.44 20.31a9 9 0 0 0 2.92 -1.95",key:"svg-4"}],["path",{d:"M20.31 15.44a9 9 0 0 0 .69 -3.44",key:"svg-5"}],["path",{d:"M20.31 8.56a9 9 0 0 0 -1.95 -2.92",key:"svg-6"}],["path",{d:"M15.44 3.69a9 9 0 0 0 -3.44 -.69",key:"svg-7"}]],Se=M("outline","circle-dashed","CircleDashed",ke);/** 17 * @license @tabler/icons-react v3.43.0 - MIT 18 * 19 * This source code is licensed under the MIT license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Ce=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]],Q=M("outline","circle-x","CircleX",Ce),Ie=[{value:"7d",label:"7d"},{value:"30d",label:"30d"},{value:"90d",label:"90d"}];function ss(){var q,L,O,_,N,E,P,W;const[r,x]=K.useState("7d"),[o,a]=K.useState(null),c=w({queryKey:["analytics-overview",r,o],queryFn:()=>v.analyticsOverview(r,o),refetchOnWindowFocus:!1}),g=w({queryKey:["accounts"],queryFn:()=>v.listAccounts()}),u=w({queryKey:["campaigns"],queryFn:()=>v.listCampaigns()}),d=w({queryKey:["lists"],queryFn:()=>v.listLists()}),n=w({queryKey:["brand"],queryFn:()=>v.getBrand()}),C=w({queryKey:["actions-awaiting-approval-overview"],queryFn:()=>v.listActions({status:"awaiting-approval",limit:100}),refetchInterval:12e4}),b=w({queryKey:["activity-today"],queryFn:()=>v.analyticsActivityToday(),refetchInterval:6e4}),y=((q=g.data)==null?void 0:q.accounts)||[],S=((L=u.data)==null?void 0:L.campaigns)||[],l=c.data,h=(l==null?void 0:l.totals)||{sent:0,replies:0,likes:0,retweets:0,posts:0,errors:0},I=y.filter(s=>s.status==="needs_reauth").length;S.filter(s=>s.status==="running").length;const A=(((O=C.data)==null?void 0:O.actions)||[]).length,T=h.errors||0,R=[{id:"account",label:"Connect an X account",desc:"Paste cookies once. Everything that sends or scrapes uses this account.",done:y.length>0,to:"/accounts",icon:e.jsx(se,{size:16})},{id:"brand",label:"Set up your brand profile",desc:"Identity + voice + hard rules. The AI uses this to draft DMs and posts in your tone.",done:!!((N=(_=n.data)==null?void 0:_.brand)!=null&&N.tagline||(P=(E=n.data)==null?void 0:E.brand)!=null&&P.description),to:"/brand",icon:e.jsx(re,{size:16})},{id:"list",label:"Build a prospect list",desc:"Scrape leads by keyword / followers-of / engagers and save them into a list to target.",done:(((W=d.data)==null?void 0:W.lists)||[]).length>0,to:"/leads",icon:e.jsx(te,{size:16})},{id:"campaign",label:"Launch your first campaign",desc:"Pick a list + template + accounts. Approval mode is on by default so you review before sends go out.",done:S.length>0,to:"/campaigns/new",icon:e.jsx(H,{size:16})}],V=R.some(s=>!s.done),ee=R.filter(s=>s.done).length;return e.jsxs(p,{gap:"md",children:[e.jsxs(i,{justify:"space-between",wrap:"wrap",gap:"xs",children:[e.jsx(ie,{order:2,children:"Overview"}),e.jsxs(i,{gap:"xs",wrap:"wrap",children:[e.jsx(pe,{size:"xs",placeholder:"All accounts",value:o,onChange:a,clearable:!0,data:y.map(s=>({value:s.id,label:`@${s.handle}`})),disabled:!y.length,style:{minWidth:160}}),e.jsx(me,{value:r,onChange:x,data:Ie,size:"xs"})]})]}),(A>0||T>0)&&e.jsxs(j,{withBorder:!0,children:[e.jsx(t,{fw:600,size:"sm",mb:6,children:"Needs your attention"}),e.jsxs(p,{gap:6,children:[A>0&&e.jsx(J,{color:"yellow",icon:e.jsx(ne,{size:18}),title:`${A} action${A===1?"":"s"} awaiting approval`,body:"Campaigns with approval mode pause every action here until you review.",cta:"Review",to:"/approvals"}),T>0&&e.jsx(J,{color:"red",icon:e.jsx(F,{size:18}),title:`${T} failed action${T===1?"":"s"} in the last ${r}`,body:"Open History to see which accounts + campaigns are throwing errors.",cta:"Open History",to:"/history"})]})]}),I>0&&e.jsx(j,{withBorder:!0,bg:"rgba(244,33,46,0.06)",children:e.jsxs(i,{wrap:"wrap",gap:"sm",children:[e.jsx(F,{color:"rgb(244,33,46)"}),e.jsxs(p,{gap:2,style:{flex:"1 1 240px",minWidth:0},children:[e.jsxs(t,{fw:600,children:[I," account",I>1?"s":""," need",I>1?"":"s"," re-authentication"]}),e.jsx(t,{size:"sm",c:"dimmed",children:"Their auth_token expired or was invali
21dated. Re-paste from Cookie-Editor to resume."})]}),e.jsx(k,{component:f,to:"/accounts",variant:"light",children:"Open Accounts"})]})}),V&&e.jsxs(j,{withBorder:!0,children:[e.jsxs(i,{justify:"space-between",wrap:"wrap",gap:"xs",mb:"xs",children:[e.jsx(t,{fw:700,children:"Get to your first send"}),e.jsxs(m,{variant:"light",color:"blue",children:[ee," / ",R.length]})]}),e.jsx(p,{gap:4,children:R.map(s=>e.jsxs(i,{justify:"space-between",wrap:"nowrap",gap:"xs",style:{padding:"6px 0",borderTop:"1px solid var(--xb-line-soft)"},children:[e.jsxs(i,{gap:"xs",wrap:"nowrap",align:"flex-start",style:{minWidth:0,flex:1},children:[s.done?e.jsx(B,{size:18,color:"var(--mantine-color-green-6)",style:{marginTop:2}}):e.jsx(Se,{size:18,color:"var(--mantine-color-dimmed)",style:{marginTop:2}}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs(i,{gap:6,wrap:"nowrap",children:[s.icon,e.jsx(t,{size:"sm",fw:500,td:s.done?"line-through":void 0,c:s.done?"dimmed":void 0,children:s.label})]}),!s.done&&s.desc&&e.jsx(t,{size:"xs",c:"dimmed",mt:2,children:s.desc})]})]}),!s.done&&e.jsx(k,{component:f,to:s.to,size:"xs",variant:"light",rightSection:e.jsx(Z,{size:12}),children:"Go"})]},s.id))})]}),e.jsx($e,{data:b.data,loading:b.isLoading}),c.isLoading&&e.jsx(ae,{}),c.error&&e.jsx(de,{error:c.error,onRetry:()=>c.refetch()}),l&&e.jsxs(e.Fragment,{children:[e.jsxs(U,{cols:{base:2,sm:3,md:6},spacing:"md",children:[e.jsx(z,{icon:e.jsx(xe,{size:18}),label:`DMs/replies sent (${r})`,value:h.sent}),e.jsx(z,{icon:e.jsx(ge,{size:18}),label:"Reply rate",value:`${l.replyRate}%`,sub:`${h.replies} detected`,tone:h.replies>0?"green":"gray"}),e.jsx(z,{icon:e.jsx(ue,{size:18}),label:`Likes (${r})`,value:h.likes}),e.jsx(z,{icon:e.jsx(je,{size:18}),label:`Retweets (${r})`,value:h.retweets}),e.jsx(z,{icon:e.jsx(be,{size:18}),label:`Posts (${r})`,value:h.posts}),e.jsx(z,{icon:e.jsx(F,{size:18}),label:`Errors (${r})`,value:h.errors,tone:h.errors>0?"red":"gray"})]}),e.jsxs(j,{withBorder:!0,children:[e.jsxs(i,{justify:"space-between",mb:"xs",children:[e.jsxs(i,{gap:"xs",children:[e.jsx(oe,{size:16}),e.jsx(t,{fw:600,size:"sm",children:"Activity"})]}),e.jsx(t,{size:"xs",c:"dimmed",children:l.cached?"cached · refreshes hourly":"live"})]}),e.jsx(ye,{h:240,data:l.series,dataKey:"day",type:"stacked",withLegend:!0,withDots:!1,tooltipProps:{wrapperStyle:{zIndex:3}},series:[{name:"dms",color:"blue.6",label:"DMs"},{name:"repliesOut",color:"indigo.6",label:"Replies out"},{name:"replies",color:"green.6",label:"Replies in"},{name:"followBacks",color:"lime.5",label:"Followed back"},{name:"likes",color:"pink.5",label:"Likes"},{name:"retweets",color:"cyan.6",label:"Retweets"},{name:"posts",color:"violet.6",label:"Posts"},{name:"follows",color:"teal.6",label:"Follows"},{name:"errors",color:"red.6",label:"Errors"}]})]}),e.jsxs(U,{cols:{base:1,md:2},spacing:"md",children:[e.jsx(j,{withBorder:!0,children:e.jsxs(p,{gap:"sm",children:[e.jsxs(i,{gap:"xs",children:[e.jsx(H,{size:16}),e.jsx(t,{fw:600,size:"sm",children:"Top campaigns"})]}),l.topCampaigns.length===0&&e.jsx(t,{size:"sm",c:"dimmed",children:"No campaign activity in this range yet."}),l.topCampaigns.map(s=>{var $;return e.jsxs(i,{justify:"space-between",wrap:"wrap",gap:6,children:[e.jsxs(p,{gap:2,style:{flex:"1 1 220px",minWidth:0},children:[e.jsx(Y,{component:f,to:`/campaigns/${s.id}`,size:"sm",fw:500,truncate:!0,children:s.name}),(($=s.handles)==null?void 0:$.length)>0&&e.jsxs(i,{gap:6,wrap:"wrap",children:[s.handles.slice(0,3).map(D=>e.jsx(ce,{handle:D,size:"xs"},D)),s.handles.length>3&&e.jsxs(m,{variant:"dot",size:"xs",children:["+",s.handles.length-3]})]})]}),e.jsxs(i,{gap:6,wrap:"wrap",children:[e.jsxs(m,{variant:"light",children:[s.sent," sent"]}),s.replies>0&&e.jsxs(m,{variant:"light",color:"green",children:[s.replyRate,"% reply"]}),s.errors>0&&e.jsxs(m,{variant:"light",color:"red",children:[s.errors," err"]})]})]},s.id)})]})}),e.jsx(j,{withBorder:!0,children:e.jsxs(p,{gap:"sm",children:[e.jsxs(i,{gap:"xs",children:[e.jsx(we,{size:16}),e.jsx(t,{fw:600,size:"sm",children:"Account health"})]}),l.health.accountsTotal===0?e.jsx(t,{size:"sm",c:"dimmed",children:"No accounts connected. Add one in Accounts to start."}):e.jsxs(e.Fragment,{children:[e.jsxs(i,{justify:"space-between",children:[e.jsx(t,{size:"sm",c:"dimmed",children:"Average score"}),e.jsxs(t,{size:"sm",fw:600,children:[l.health.avg??"â","/100"]})]}),e.jsx(le,{value:l.health.avg??0,color:(l.health.avg??100)>=70?"green":(l.health.avg??100)>=40?"yellow":"red",size:"sm"}),e.jsx(i,{gap:"xs",mt:"xs",children:Object.entries(l.health.accountStatus).map(([s,$])=>e.jsxs(m,{variant:"light",color:Me(s),children:[$," ",s]},s))}),e.jsxs(i,{gap:"xs",mt:"xs",children:[e.jsx(k,{component:f,to:"/campaigns/new",size:"xs",children:"New campaign"}),e.jsx(k,{component:f,to:"/leads",size:"xs",variant:"light",children:"Find leads"}),e.jsx(k,{component:f,to:"/accounts",size:"xs",variant:"subtle",children:"Accounts"})]})]})]})})]}),e.jsx(Ae,{range:r,accountId:o})]})]})}function Ae({range:r,accountId:x}){const{data:o,isLoading:a}=w({queryKey:["best-time",r,x],queryFn:()=>v.bestTimeToPost({range:r,accountId:x||void 0}),refetchOnWindowFocus:!1});if(a||!o||!o.sampleSize||o.sampleSize<10)return null;const c=Math.max(1,...(o.cells||[]).map(d=>d.engagement||d.count||0)),g=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u=(o.top||[])[0];return e.jsxs(j,{withBorder:!0,children:[e.jsxs(i,{justify:"space-between",wrap:"wrap",mb:"sm",children:[e.jsxs(p,{gap:0,children:[e.jsxs(i,{gap:"xs",children:[e.jsx(ve,{size:16}),e.jsx(t,{fw:600,size:"sm",children:"Best time to post"})]}),e.jsxs(t,{size:"xs",c:"dimmed",children:["From ",o.sampleSize," of your own posts/replies/quotes in the last ",r,", by UTC weekday + hour."]})]}),u&&e.jsxs(m,{variant:"light",color:"blue",children:["Peak: ",g[u.day]," ",u.hour,":00 UTC"]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto repeat(24,
211fr)",gap:1,fontSize:9},children:[e.jsx("div",{}),Array.from({length:24}).map((d,n)=>e.jsx("div",{style:{textAlign:"center",color:"var(--mantine-color-dimmed)"},children:n%3===0?n:""},n)),g.map((d,n)=>e.jsxs(Te,{children:[e.jsx("div",{style:{color:"var(--mantine-color-dimmed)",paddingRight:4},children:d}),Array.from({length:24}).map((C,b)=>{const y=(o.cells||[]).find(h=>h.day===n&&h.hour===b)||{count:0,engagement:0},S=(y.engagement||y.count||0)/c,l=S>0?`rgba(29, 155, 240, ${.1+S*.8})`:"rgba(0,0,0,0.04)";return e.jsx("div",{title:`${d} ${b}:00 UTC · ${y.count} posts · ${y.engagement} engagement`,style:{background:l,height:18,borderRadius:2}},b)})]},n))]})]})}function Te(r){return r.children}const Re={post:"Posts",reply:"Replies",quote:"Quotes",thread:"Threads","send-dm":"DMs",like:"Likes",retweet:"Retweets",follow:"Follows",unfollow:"Unfollows",bookmark:"Bookmarks"};function X(r){return Re[r]||r}function $e({data:r,loading:x}){const o=he();if(x&&!r)return e.jsxs(j,{withBorder:!0,children:[e.jsxs(i,{gap:"xs",children:[e.jsx(G,{size:18}),e.jsx(t,{fw:600,size:"sm",children:"Today"})]}),e.jsx(t,{size:"xs",c:"dimmed",mt:4,children:"Loadingâ¦"})]});if(!r)return null;const{totals:a,buckets:c,recent:g,timeZone:u}=r,d=((a==null?void 0:a.ok)||0)+((a==null?void 0:a.error)||0);return e.jsxs(j,{withBorder:!0,children:[e.jsxs(i,{justify:"space-between",wrap:"wrap",gap:"xs",mb:6,children:[e.jsxs(i,{gap:"xs",children:[e.jsx(G,{size:18}),e.jsx(t,{fw:600,size:"sm",children:"Today"}),u&&e.jsx(m,{variant:"light",size:"xs",color:"gray",children:u})]}),e.jsxs(i,{gap:"xs",children:[(a==null?void 0:a.error)>0&&e.jsxs(m,{color:"red",variant:"light",leftSection:e.jsx(Q,{size:12}),children:[a.error," failed"]}),e.jsxs(m,{color:"green",variant:"light",leftSection:e.jsx(B,{size:12}),children:[(a==null?void 0:a.ok)||0," done"]})]})]}),d===0?e.jsx(t,{size:"sm",c:"dimmed",children:"Nothing dispatched yet today. Campaigns will surface here the moment they run."}):e.jsxs(p,{gap:6,children:[e.jsx(i,{gap:"xs",wrap:"wrap",children:c.map(n=>e.jsxs(m,{variant:"light",color:n.error>0&&n.ok===0?"red":"blue",title:n.error>0?`${n.error} failed`:void 0,children:[n.ok,n.error>0?` · ${n.error} â`:""," ",X(n.type)]},n.type))}),g&&g.length>0&&e.jsxs(p,{gap:2,mt:4,children:[g.slice(0,6).map((n,C)=>e.jsxs(i,{gap:"xs",wrap:"nowrap",style:{fontSize:12},children:[n.ok?e.jsx(B,{size:12,color:"var(--mantine-color-green-6)"}):e.jsx(Q,{size:12,color:"var(--mantine-color-red-6)"}),e.jsx(t,{size:"xs",c:"dimmed",style:{minWidth:60},children:o.time(n.ts)}),e.jsx(t,{size:"xs",fw:500,style:{minWidth:60},children:X(n.type)}),e.jsxs(t,{size:"xs",c:"dimmed",style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.target||"â",n.error?` · ${String(n.error).slice(0,80)}`:""]})]},C)),e.jsx(Y,{component:f,to:"/history",size:"xs",mt:2,children:"See all history â"})]})]})]})}function z({icon:r,label:x,value:o,sub:a,tone:c="gray"}){return e.jsx(j,{withBorder:!0,children:e.jsxs(p,{gap:6,children:[e.jsxs(i,{gap:"xs",c:"dimmed",children:[r,e.jsx(t,{size:"xs",tt:"uppercase",fw:600,truncate:!0,children:x})]}),e.jsx(t,{size:"xl",fw:700,c,children:o}),a&&e.jsx(t,{size:"xs",c:"dimmed",children:a})]})})}function Me(r){return r==="active"?"green":r==="needs_reauth"?"red":r==="cooldown"?"orange":"gray"}function J({color:r,icon:x,title:o,body:a,cta:c,to:g}){const u=r==="red"?"rgba(244,33,46,0.05)":r==="yellow"?"rgba(255,196,0,0.07)":"rgba(0,0,0,0.02)",d=r==="red"?"var(--mantine-color-red-7)":r==="yellow"?"var(--mantine-color-yellow-7)":"var(--mantine-color-dimmed)";return e.jsxs(i,{wrap:"nowrap",gap:"sm",style:{padding:"8px 10px",background:u,borderRadius:6},children:[e.jsx("div",{style:{color:d,flexShrink:0},children:x}),e.jsxs(p,{gap:0,style:{flex:1,minWidth:0},children:[e.jsx(t,{size:"sm",fw:500,children:o}),e.jsx(t,{size:"xs",c:"dimmed",children:a})]}),e.jsx(k,{component:f,to:g,size:"xs",variant:"light",rightSection:e.jsx(Z,{size:12}),children:c})]})}export{ss 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.