PageSourceSearch

https://app.xlift.ai/assets/CampaignDetailPage-BGBOHbbt.js

js xlift.ai collected 2026-10-05 13:20:33 UTC 31,738 bytes, 11 lines download raw bytes

1import{v as we,o as k,j as e,C as y,G as u,X as R,a8 as qe,T as n,W as fe,F as G,ao as ve,aT as Re,as as De,ai as be,A as M,al as H,a4 as L,a5 as K,U as T,aM as Fe,$ as Me,E as S,ax as Ee,ay as $e,ar as $,ag as Pe,D as I,S as O,I as _,a7 as ye,J as Se,Z as ze,L as Te}from"./index-dE8a1mPK.js";import{E as Be}from"./ErrorState-gVNyx0--.js";import{u as He}from"./useConfirm-4D74KrCi.js";import{H as X}from"./HandleLink-CMsO54nu.js";import{T as Le}from"./Textarea-BtbUvWWM.js";import{I as Ke}from"./IconX-B50qDTAe.js";import{I as ke}from"./IconEdit-yVOCeDQ1.js";import{T as Qe}from"./ThreadEditor-CdQzLMVP.js";import{c as Ne,R as Oe}from"./RiskBadge-DX_mBJmP.js";import{I as _e}from"./IconArrowLeft-cAVPTBNq.js";import{I as We}from"./IconCopy-B63sUmw8.js";import{I as Ue}from"./IconClock-DGXUTa2e.js";import{S as Ce}from"./SegmentedControl-CNEtbfTu.js";import{S as Ge}from"./SimpleGrid-DkEuk0DW.js";import{A as Xe}from"./AreaChart-DF3EymE-.js";import{T as t}from"./Table-5ftamFSf.js";import{I as Ae}from"./IconExternalLink-DcQXcLz7.js";import{M as Je}from"./MultiSelect-CJSWniGq.js";import{S as Ve}from"./Switch-Bm85N10X.js";import"./Code-YtMEZkZ5.js";import"./get-env-uyVen0u2.js";import"./IconPlus-B47PY1MC.js";import"./IconArrowDown-DMfekS2f.js";import"./IconTrash-DIXYcrq7.js";import"./grid-chart.module.css-B4DgdMZ7.js";import"./OptionsDropdown-wonErrz5.js";import"./CheckIcon-DkMc45y2.js";import"./Pill-yNBbBYnE.js";import"./PillsInput-BO1u7Wrq.js";import"./InputsGroupFieldset-C0syow2C.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 Ye=[["path",{d:"M3 6a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2",key:"svg-0"}],["path",{d:"M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-10",key:"svg-1"}],["path",{d:"M10 12l4 0",key:"svg-2"}]],Ze=we("outline","archive","Archive",Ye);/**
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 es=[["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M11 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],ss=we("outline","dots-vertical","DotsVertical",es);function ts({value:s,onSave:h,onRegenerate:c,editable:a=!0,charLimit:o=null,placeholder:l="No content yet",monospaceLook:d=!1,minRows:j=2,maxRows:g=16}){const w=a&&typeof h=="function",[x,v]=k.useState("read"),[p,m]=k.useState(s||""),[q,i]=k.useState(null),b=k.useRef(null);k.useEffect(()=>{x==="read"&&m(s||"")},[s,x]),k.useEffect(()=>{if(x==="edit"&&b.current){b.current.focus();const f=b.current.value.length;b.current.setSelectionRange(f,f)}},[x]);async function E(){if(p===s){v("read");return}v("saving"),i(null);try{await h(p),v("read")}catch(f){i((f==null?void 0:f.message)||"Save failed"),v("edit")}}function D(){m(s||""),i(null),v("read")}async function P(){if(c){v("regen"),i(null);try{await c()}catch(f){i((f==null?void 0:f.message)||"Regenerate failed")}finally{v("read")}}}const J={whiteSpace:"pre-wrap",wordBreak:"break-word",background:"var(--xb-bg-soft, rgba(0,0,0,0.03))",padding:10,borderRadius:6,lineHeight:1.55,...d&&{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:13}},Q=!s||!String(s).trim(),F=(p||"").length,N=o&&F>o,W=o&&F>o*.9&&!N;return x==="edit"||x==="saving"?e.jsxs(y,{gap:6,children:[e.jsx(Le,{ref:b,value:p,onChange:f=>m(f.currentTarget.value),onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),D()),(f.metaKey||f.ctrlKey)&&f.key==="Enter"&&(f.preventDefault(),E())},autosize:!0,minRows:j,maxRows:g,disabled:x==="saving",styles:{input:{fontFamily:d?"ui-monospace, SFMono-Regular, monospace":void 0,fontSize:d?13:void 0,lineHeight:1.55}}}),e.jsxs(u,{justify:"space-between",wrap:"wrap",gap:6,children:[e.jsxs(u,{gap:"xs",children:[e.jsx(R,{size:"xs",leftSection:e.jsx(qe,{size:12}),onClick:E,loading:x==="saving",disabled:N,children:"Save"}),e.jsx(R,{size:"xs",variant:"default",leftSection:e.jsx(Ke,{size:12}),onClick:D,disabled:x==="saving",children:"Cancel"}),e.jsx(n,{size:"xs",c:"dimmed",children:"⌘↵ to save · esc to cancel"})]}),o&&e.jsxs(n,{size:"xs",c:N?"red":W?"orange":"dimmed",children:[F," / ",o]})]}),q&&e.jsx(n,{size:"xs",c:"red",children:q})]}):e.jsxs(y,{gap:6,children:[e.jsx("div",{style:J,children:Q?e.jsx(n,{c:"dimmed",fs:"italic",size:"sm",children:l}):e.jsx(n,{size:"sm",component:"div",style:{whiteSpace:"pre-wrap"},children:s})}),(w||c||o)&&e.jsxs(u,{justify:"space-between",gap:6,children:[e.jsxs(u,{gap:6,children:[w&&e.jsx(fe,{label:"Edit",children:e.jsx(G,{variant:"subtle",size:"sm",onClick:()=>v("edit"),disabled:x==="regen","aria-label":"Edit content",children:e.jsx(ke,{size:14})})}),c&&e.jsx(fe,{label:"Regenerate",children:e.jsx(G,{variant:"subtle",size:"sm",onClick:P,loading:x==="regen","aria-label":"Regenerate content",children:e.jsx(ve,{size:14})})})]}),o&&!Q&&e.jsxs(n,{size:"xs",c:F>o?"red":"dimmed",children:[F," / ",o]})]}),q&&e.jsx(n,{size:"xs",c:"red",children:q})]})}const rs=[{value:"7d",label:"7d"},{value:"30d",label:"30d"},{value:"90d",label:"90d"}];function _s(){var V,Y,Z,ee,se,te,re,ae,ne,ie,le,de,ce,oe,he,ue,xe,pe,me,je;const{id:s}=Re(),h=De(),c=be(),{confirm:a,ConfirmDialog:o}=He(),[l,d]=k.useState("30d"),[j,g]=k.useState(!1),[w,x]=k.useState(!1),v=M({queryKey:["campaign",s],queryFn:()=>T.getCampaign(s)}),p=M({queryKey:["analytics-campaign",s,l],queryFn:()=>
11T.analyticsCampaign(s,l)}),m=M({queryKey:["campaign-actions",s],queryFn:()=>T.listActions({campaignId:s,limit:100}),refetchInterval:9e4}),q=M({queryKey:["campaign-schedule",s],queryFn:()=>T.getCampaignSchedule(s),refetchInterval:18e4}),i=(V=v.data)==null?void 0:V.campaign,b=p.data,E=((Y=i==null?void 0:i.config)==null?void 0:Y.listId)||null,D=M({queryKey:["list",E],queryFn:()=>T.getList(E),enabled:!!E}),P=k.useMemo(()=>{var C,A;const r=Array.isArray((C=i==null?void 0:i.config)==null?void 0:C.steps)?i.config.steps:(A=i==null?void 0:i.config)!=null&&A.templateId?[{templateId:i.config.templateId}]:[];return[...new Set(r.map(B=>B.templateId).filter(Boolean))]},[i]),J=M({queryKey:["campaign-templates",s,P.join(",")],queryFn:async()=>{const r=await Promise.all(P.map(A=>T.getTemplate(A).catch(()=>null))),C={};return r.forEach((A,B)=>{A!=null&&A.template&&(C[P[B]]=A.template)}),C},enabled:P.length>0}),Q=H({mutationFn:()=>T.startCampaign(s),onSuccess:r=>{K(`Started — ${r.scheduled||0} actions queued`),c.invalidateQueries({queryKey:["campaign",s]}),c.invalidateQueries({queryKey:["campaign-actions",s]})},onError:r=>L(r)}),F=H({mutationFn:()=>T.pauseCampaign(s),onSuccess:()=>{K("Paused"),c.invalidateQueries({queryKey:["campaign",s]})},onError:r=>L(r)}),N=H({mutationFn:()=>T.deleteCampaign(s),onSuccess:()=>{K("Archived"),c.invalidateQueries({queryKey:["campaigns"]}),h("/campaigns")},onError:r=>L(r)}),W=H({mutationFn:()=>T.cloneCampaign(s),onSuccess:r=>{K("Cloned — opening draft"),c.invalidateQueries({queryKey:["campaigns"]}),r!=null&&r.id&&h(`/campaigns/${r.id}`)},onError:r=>L(r)}),f=H({mutationFn:r=>T.bulkRescheduleActions({campaignId:s,deltaMs:r}),onSuccess:r=>{K(`Rescheduled ${r.touched||0} queued actions`),c.invalidateQueries({queryKey:["campaign",s]}),c.invalidateQueries({queryKey:["actions"]})},onError:r=>L(r)});return v.isLoading?e.jsx(Fe,{}):v.error?e.jsx(Be,{error:v.error,onRetry:()=>v.refetch()}):i?e.jsxs(y,{gap:"md",children:[e.jsxs(u,{justify:"space-between",align:"flex-start",wrap:"wrap",gap:"sm",children:[e.jsxs(u,{gap:"xs",align:"center",wrap:"nowrap",style:{flex:"1 1 280px",minWidth:0},children:[e.jsx(R,{variant:"subtle",leftSection:e.jsx(_e,{size:14}),onClick:()=>h("/campaigns"),px:"xs",children:"Campaigns"}),e.jsxs(y,{gap:2,style:{flex:1,minWidth:0},children:[e.jsx(Me,{order:2,style:{wordBreak:"break-word"},children:i.name}),e.jsxs(u,{gap:"xs",wrap:"wrap",children:[e.jsx(S,{children:i.type}),e.jsx(S,{color:cs(i.status),children:i.status}),i.approvalMode&&e.jsx(S,{variant:"light",color:"yellow",children:"approval mode"}),(()=>{const{level:r,reasons:C}=Ne(i);return e.jsx(Oe,{level:r,reasons:C})})(),e.jsxs(n,{size:"xs",c:"dimmed",children:["created ",i.createdAt?new Date(i.createdAt).toLocaleDateString():"—"]})]})]})]}),e.jsxs(u,{gap:"xs",wrap:"wrap",children:[i.status==="running"?e.jsx(R,{leftSection:e.jsx(Ee,{size:14}),variant:"light",color:"orange",onClick:()=>F.mutate(),loading:F.isPending,children:"Pause"}):i.status!=="archived"?e.jsx(R,{leftSection:e.jsx($e,{size:14}),onClick:()=>Q.mutate(),loading:Q.isPending,children:i.status==="paused"?"Resume":"Start"}):null,e.jsx(R,{variant:"default",leftSection:e.jsx(ke,{size:14}),onClick:()=>g(!0),children:"Edit"}),e.jsxs($,{position:"bottom-end",withArrow:!0,children:[e.jsx($.Target,{children:e.jsx(G,{variant:"default",size:"lg",children:e.jsx(ss,{size:16})})}),e.jsxs($.Dropdown,{children:[e.jsx($.Item,{leftSection:e.jsx(We,{size:14}),onClick:()=>W.mutate(),disabled:W.isPending,children:"Clone campaign"}),e.jsx($.Item,{leftSection:e.jsx(Ue,{size:14}),onClick:()=>x(!0),disabled:f.isPending,children:"Bulk reschedule"}),e.jsx($.Divider,{}),e.jsx($.Item,{color:"red",leftSection:e.jsx(Ze,{size:14}),onClick:async()=>{await a({title:`Archive "${i.name}"?`,body:"The campaign stops dispatching new actions immediately. Already-queued actions stay in place. You can spin a fresh draft anytime via Clone.",confirmLabel:"Archive"})&&N.mutate()},children:"Archive"})]})]})]})]}),e.jsxs(u,{justify:"space-between",children:[e.jsx(Ce,{value:l,onChange:d,data:rs,size:"xs"}),e.jsx(n,{size:"xs",c:"dimmed",children:b!=null&&b.cached?"cached · refreshes hourly":"live"})]}),p.isLoading&&e.jsx(Pe,{}),b&&e.jsxs(e.Fragment,{children:[e.jsxs(Ge,{cols:{base:2,sm:4},spacing:"md",children:[e.jsx(U,{label:`Sent (${l})`,value:((Z=b.totals)==null?void 0:Z.sent)||0}),e.jsx(U,{label:"Reply rate",value:`${b.replyRate||0}%`,sub:`${((ee=b.totals)==null?void 0:ee.replies)||0} detected`,tone:(((se=b.totals)==null?void 0:se.replies)||0)>0?"green":"gray"}),e.jsx(U,{label:"Queued",value:((te=i.metrics)==null?void 0:te.queued)||0}),e.jsx(U,{label:"Errors",value:((re=b.totals)==null?void 0:re.errors)||0,tone:(((ae=b.totals)==null?void 0:ae.errors)||0)>0?"red":"gray"})]}),q.data&&q.data.totalQueued+q.data.totalAwaitingApproval>0&&e.jsx(ds,{data:q.data}),e.jsx(is,{campaign:i,templates:J.data||{},list:((ne=D.data)==null?void 0:ne.list)||null}),e.jsxs(I,{withBorder:!0,children:[e.jsx(n,{fw:600,size:"sm",mb:"xs",children:"Activity"}),e.jsx(Xe,{h:200,data:b.series||[],dataKey:"day",type:"stacked",withLegend:!0,withDots:!1,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:"likes",color:"pink.5",label:"Likes"},{name:"retweets",color:"cyan.6",label:"Retweets"},{name:"posts",color:"violet.6",label:"Posts"},{name:"errors",color:"red.6",label:"Errors"}]})]}),((ie=b.sequenceSteps)==null?void 0:ie.length)>0&&e.jsxs(I,{withBorder:!0,children:[e.jsx(n,{fw:600,size:"sm",mb:"xs",children:"Per-step performance"}),e.jsxs(t,{highlightOnHover:!0,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:"Step"}),e.jsx(t.Th,{ta:"right",children:"Sent"}),e.jsx(t.Th,{ta:"right",children:"Replies"}),e.jsx(t.Th,{ta:"right",children:"Reply rate"}),e.jsx(t.Th,{ta:"right",children:"Errors"})]})}),e.jsx(t.Tbody,{children:b.sequenceSteps.map(r=>e.jsxs(t.Tr,{children:[e.jsxs(t.Td,{children:["#",r.step+1]}),e.jsx(t.Td,{ta:"right",children:r.sent}),e.jsx(t.Td,{ta:"right",children:r.replies}),e.jsxs(t.Td,{ta:"right",children:[r.replyRate,"%"]}),e.jsx(t.Td,{ta:"right",children:r.errors})]},r.step))})]})]}),((le=b.byAccount)==null?void 0:le.length)>0&&e.jsxs(I,{withBorder:!0,children:[e.jsxs(u,{justify:"space-between",mb:"xs",wrap:"wrap",gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Per-account breakdown"}),e.jsxs(n,{size:"xs",c:"dimmed",children:[b.byAccount.length," accounts on this campaign"]})]}),e.jsx(O.Autosize,{children:e.jsxs(t,{highlightOnHover:!0,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:"Account"}),e.jsx(t.Th,{ta:"right",children:"Sent"}),e.jsx(t.Th,{ta:"right",children:"Replies"}),e.jsx(t.Th,{ta:"right",children:"Reply rate"}),e.jsx(t.Th,{ta:"right",children:"Errors"}),e.jsx(t.Th,{ta:"right",children:"Share"}),e.jsx(t.Th,{})]})}),e.jsx(t.Tbody,{children:b.byAccount.map(r=>e.jsxs(t.Tr,{children:[e.jsx(t.Td,{children:e.jsxs(_,{component:ye,to:`/accounts/${r.accountId}`,size:"xs",fw:500,children:["@",r.handle]})}),e.jsx(t.Td,{ta:"right",children:r.sent+r.likes+r.retweets+r.posts}),e.jsx(t.Td,{ta:"right",children:r.replies}),e.jsx(t.Td,{ta:"right",children:r.replyRate>0?e.jsxs(S,{size:"xs",color:"green",variant:"light",children:[r.replyRate,"%"]}):"—"}),e.jsx(t.Td,{ta:"right",children:r.errors>
110?e.jsx(S,{size:"xs",color:"red",variant:"light",children:r.errors}):"—"}),e.jsx(t.Td,{ta:"right",w:120,children:e.jsxs(u,{gap:6,wrap:"nowrap",justify:"flex-end",children:[e.jsx(Se,{value:r.share,size:"sm",w:60}),e.jsxs(n,{size:"xs",c:"dimmed",children:[r.share,"%"]})]})}),e.jsx(t.Td,{})]},r.accountId))})]})})]})]}),e.jsx(us,{actions:((de=m.data)==null?void 0:de.actions)||[],campaignType:i.type}),i.type==="sequence"&&e.jsx(ps,{campaignId:i.id,steps:((ce=i.config)==null?void 0:ce.sequenceSteps)||[],stopOnReply:((oe=i.config)==null?void 0:oe.stopOnReply)!==!1}),e.jsxs(I,{withBorder:!0,p:0,children:[e.jsxs(u,{justify:"space-between",p:"md",children:[e.jsx(n,{fw:600,size:"sm",children:"Action queue"}),e.jsxs(u,{gap:"xs",children:[e.jsxs(n,{size:"xs",c:"dimmed",children:[((ue=(he=m.data)==null?void 0:he.actions)==null?void 0:ue.length)||0," actions"]}),e.jsx(G,{variant:"subtle",onClick:()=>m.refetch(),loading:m.isRefetching,children:e.jsx(ve,{size:14})})]})]}),e.jsx(O.Autosize,{mah:420,children:e.jsxs(t,{stickyHeader:!0,highlightOnHover:!0,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:"Status"}),e.jsx(t.Th,{children:"Type"}),e.jsx(t.Th,{children:"Target"}),e.jsx(t.Th,{children:"Scheduled"}),e.jsx(t.Th,{children:"Executed"}),e.jsx(t.Th,{children:"Note"})]})}),e.jsx(t.Tbody,{children:(((xe=m.data)==null?void 0:xe.actions)||[]).map(r=>{var C,A,B,ge;return e.jsxs(t.Tr,{children:[e.jsx(t.Td,{children:e.jsx(S,{size:"sm",color:Ie(r.status),children:r.status})}),e.jsx(t.Td,{children:e.jsx(n,{size:"xs",children:r.type})}),e.jsx(t.Td,{children:(A=(C=r.payload)==null?void 0:C.target)!=null&&A.startsWith("@")?e.jsx(X,{handle:r.payload.target,size:"xs",truncate:!0,maw:180}):e.jsx(n,{size:"xs",truncate:!0,maw:200,children:((B=r.payload)==null?void 0:B.target)||"—"})}),e.jsx(t.Td,{children:e.jsx(n,{size:"xs",c:"dimmed",children:r.scheduledFor?new Date(r.scheduledFor).toLocaleString():"—"})}),e.jsx(t.Td,{children:e.jsx(n,{size:"xs",c:"dimmed",children:r.executedAt?new Date(r.executedAt).toLocaleString():"—"})}),e.jsx(t.Td,{children:e.jsx(n,{size:"xs",c:r.status==="failed"?"red":"dimmed",lineClamp:1,maw:260,children:r.error||((ge=r.result)==null?void 0:ge.reason)||""})})]},r.id)})})]})}),!m.isLoading&&(((pe=m.data)==null?void 0:pe.actions)||[]).length===0&&e.jsxs(n,{size:"sm",c:"dimmed",ta:"center",p:"md",children:["No actions queued yet. ",i.status!=="running"?"Click Start to materialize the queue.":"The scheduler will create actions as the campaign runs."]})]}),E&&D.data&&e.jsxs(I,{withBorder:!0,p:0,children:[e.jsxs(u,{justify:"space-between",p:"md",children:[e.jsxs(u,{gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Prospects"}),e.jsx(_,{component:ye,to:"/lists",size:"xs",children:(me=D.data.list)==null?void 0:me.name})]}),e.jsxs(n,{size:"xs",c:"dimmed",children:[((je=D.data.handles)==null?void 0:je.length)||0," total"]})]}),e.jsx(O.Autosize,{mah:420,children:e.jsxs(t,{stickyHeader:!0,highlightOnHover:!0,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:"Handle"}),e.jsx(t.Th,{children:"DM status"}),i.type==="follow-unfollow"&&e.jsx(t.Th,{children:"Follow status"}),e.jsx(t.Th,{children:"Last action"}),e.jsx(t.Th,{})]})}),e.jsx(t.Tbody,{children:(D.data.handles||[]).map(r=>{var C;return e.jsxs(t.Tr,{children:[e.jsx(t.Td,{children:e.jsx(X,{handle:r.handle,size:"xs",fw:500})}),e.jsx(t.Td,{children:e.jsx(S,{size:"sm",color:os(r.status),children:r.status||"pending"})}),i.type==="follow-unfollow"&&e.jsx(t.Td,{children:e.jsx(S,{size:"sm",color:hs(r.followStatus),children:r.followStatus||"pending"})}),e.jsx(t.Td,{children:e.jsx(n,{size:"xs",c:"dimmed",children:(C=r.lastDmAt)!=null&&C._seconds?new Date(r.lastDmAt._seconds*1e3).toLocaleString():"—"})}),e.jsx(t.Td,{children:e.jsx(_,{href:`https://x.com/${r.handle}`,target:"_blank",rel:"noreferrer",size:"xs",children:e.jsx(Ae,{size:12})})})]},r.handle)})})]})})]}),j&&e.jsx(ns,{campaign:i,onClose:()=>g(!1),onSaved:()=>{c.invalidateQueries({queryKey:["campaign",s]}),c.invalidateQueries({queryKey:["campaigns"]}),g(!1)}}),e.jsx(as,{opened:w,onClose:()=>x(!1),onSubmit:r=>{f.mutate(r),x(!1)},loading:f.isPending}),e.jsx(o,{})]}):null}function as({opened:s,onClose:h,onSubmit:c,loading:a}){const[o,l]=k.useState(24),[d,j]=k.useState("later");return e.jsx(ze,{opened:s,onClose:h,title:"Bulk reschedule",centered:!0,children:e.jsxs(y,{children:[e.jsx(n,{size:"sm",c:"dimmed",children:"Shifts every queued + awaiting-approval action in this campaign. Working hours, daily caps, and the kill switch still apply at dispatch."}),e.jsxs(u,{grow:!0,children:[e.jsx(Te,{label:"Hours",type:"number",min:1,value:String(o),onChange:g=>l(Math.max(1,Number(g.currentTarget.value)||1))}),e.jsx(Ce,{data:[{label:"Later",value:"later"},{label:"Earlier",value:"earlier"}],value:d,onChange:j,mt:22})]}),e.jsxs(u,{justify:"flex-end",children:[e.jsx(R,{variant:"default",onClick:h,children:"Cancel"}),e.jsx(R,{onClick:()=>c((d==="later"?1:-1)*o*36e5),loading:a,children:"Reschedule"})]})]})})}function ns({campaign:s,onClose:h,onSaved:c}){var p;const[a,o]=k.useState(s.name||""),[l,d]=k.useState(s.accountIds||[]),[j,g]=k.useState(!!s.approvalMode),x=(((p=M({queryKey:["accounts"],queryFn:()=>T.listAccounts()}).data)==null?void 0:p.accounts)||[]).filter(m=>m.status==="active"),v=H({mutationFn:()=>T.updateCampaign(s.id,{name:a.trim(),accountIds:l,approvalMode:j}),onSuccess:()=>{K("Saved"),c()},onError:m=>L(m)});return e.jsx(ze,{opened:!0,onClose:h,title:"Edit campaign",size:"md",children:e.jsxs(y,{children:[e.jsx(Te,{label:"Name",value:a,onChange:m=>o(m.currentTarget.value)}
11),e.jsx(Je,{label:"Accounts",value:l,onChange:d,data:x.map(m=>({value:m.id,label:`@${m.handle}`}))}),e.jsx(Ve,{label:"Approval mode",description:"Route every action through manual approval before send.",checked:j,onChange:m=>g(m.currentTarget.checked)}),e.jsx(n,{size:"xs",c:"dimmed",children:"Type, list, and sequence config can't be edited live — create a new campaign for major changes."}),e.jsxs(u,{justify:"flex-end",children:[e.jsx(R,{variant:"subtle",onClick:h,children:"Cancel"}),e.jsx(R,{onClick:()=>v.mutate(),loading:v.isPending,disabled:!a.trim()||!l.length,children:"Save"})]})]})})}function is({campaign:s,templates:h,list:c}){var d,j;const a=(s==null?void 0:s.config)||{},o=s==null?void 0:s.type,l=Array.isArray(a.steps)&&a.steps.length?a.steps:a.templateId?[{templateId:a.templateId,delayHours:0}]:[];return e.jsxs(I,{withBorder:!0,children:[e.jsxs(u,{justify:"space-between",mb:"xs",wrap:"wrap",children:[e.jsxs(y,{gap:0,children:[e.jsx(n,{fw:600,size:"sm",children:"Campaign config"}),e.jsx(n,{size:"xs",c:"dimmed",children:"What goes out, when, and to whom."})]}),e.jsxs(u,{gap:6,wrap:"wrap",children:[e.jsx(S,{variant:"dot",color:ls(o),children:o||"unknown"}),(s==null?void 0:s.approvalMode)&&e.jsx(S,{color:"yellow",variant:"light",children:"approval mode"}),c&&e.jsxs(S,{variant:"light",children:["list: ",c.name||c.id]})]})]}),o==="dm-outreach"&&e.jsx(y,{gap:"xs",children:l.length===0?e.jsx(n,{size:"sm",c:"dimmed",children:"No sequence steps configured."}):l.map((g,w)=>{const x=h[g.templateId];return e.jsxs(I,{withBorder:!0,padding:"sm",bg:"rgba(0,0,0,0.02)",children:[e.jsxs(u,{justify:"space-between",wrap:"wrap",gap:6,mb:4,children:[e.jsxs(u,{gap:6,children:[e.jsxs(S,{color:"blue",variant:"filled",size:"sm",children:["Step ",w+1]}),(x==null?void 0:x.name)&&e.jsx(n,{size:"sm",fw:500,children:x.name})]}),e.jsxs(n,{size:"xs",c:"dimmed",children:[w===0?"sent on materialization":`+${g.delayHours||0}h after step ${w}`,g.skipIfReplied!==!1&&w>0?" · skip if replied":""]})]}),x?e.jsx(n,{size:"sm",style:{whiteSpace:"pre-wrap",background:"var(--xb-bg-soft)",padding:8,borderRadius:4,fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:13},children:x.body||"(empty template)"}):e.jsx(n,{size:"sm",c:"dimmed",fs:"italic",children:"Template not loaded yet…"})]},g.id||`${g.templateId||"step"}-${w}`)})}),o==="auto-engage"&&e.jsxs(y,{gap:4,children:[e.jsx(z,{label:"Search query",value:a.query||"(none)",mono:!0}),e.jsx(z,{label:"Action mix",value:["like","retweet","reply"].map(g=>{var w;return`${g}: ${((w=a.mix)==null?void 0:w[g])??0}%`}).join(" · ")}),e.jsx(z,{label:"Reply template",value:((d=h[a.replyTemplateId])==null?void 0:d.name)||a.replyTemplateId||"(none)"}),((j=h[a.replyTemplateId])==null?void 0:j.body)&&e.jsx(n,{size:"sm",mt:4,style:{whiteSpace:"pre-wrap",background:"var(--xb-bg-soft)",padding:8,borderRadius:4,fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:13},children:h[a.replyTemplateId].body}),e.jsx(z,{label:"Min likes",value:a.minLikes??0}),e.jsx(z,{label:"Min followers",value:a.minFollowers??0}),a.tweetAgeMaxHours&&e.jsx(z,{label:"Max tweet age",value:`${a.tweetAgeMaxHours}h`})]}),o==="auto-posts"&&e.jsxs(y,{gap:4,children:[e.jsx(z,{label:"Topic / prompt",value:a.topic||a.prompt||"(brand default)"}),e.jsx(z,{label:"Posts per day",value:a.postsPerDay??"—"}),e.jsx(z,{label:"Tone",value:a.tone||"(brand default)"})]}),o==="follow-unfollow"&&e.jsxs(y,{gap:4,children:[e.jsx(z,{label:"Follow target",value:a.targetHandle?`@${a.targetHandle}`:a.listId?`list: ${(c==null?void 0:c.name)||a.listId}`:"(none)"}),e.jsx(z,{label:"Daily follows",value:a.dailyFollows??"—"}),e.jsx(z,{label:"Unfollow after (days)",value:a.unfollowAfterDays??"—"}),e.jsx(z,{label:"Skip if follows back",value:a.skipIfFollowsBack?"yes":"no"})]}),o==="reply-boost"&&e.jsxs(y,{gap:4,children:[e.jsx(z,{label:"Fires at",value:`${a.minLikes??5} likes on your post`}),e.jsx(z,{label:"Post age limit",value:`${a.windowMin??90} min`}),e.jsx(z,{label:"Commenters per post",value:a.maxPerBoost??10}),e.jsx(z,{label:"Min commenter followers",value:a.minFollowers||"any"}),e.jsx(z,{label:"Actions",value:(a.actions||["like","reply"]).join(", ")})]})]})}function z({label:s,value:h,mono:c}){return e.jsxs(u,{gap:8,wrap:"wrap",align:"flex-start",children:[e.jsx(n,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,style:{minWidth:140},children:s}),e.jsx(n,{size:"sm",style:c?{fontFamily:"ui-monospace, monospace"}:void 0,children:String(h)})]})}function ls(s){switch(s){case"dm-outreach":return"blue";case"auto-engage":return"green";case"auto-posts":return"violet";case"follow-unfollow":return"teal";case"reply-boost":return"orange";default:return"gray"}}function ds({data:s}){const{totalQueued:h,totalAwaitingApproval:c,nextDispatchAt:a,etaAt:o,byDay:l=[],accounts:d=[]}=s,j=h+c,g=Math.max(1,...l.map(p=>
11p.count)),w=l.length,x=o?new Date(o).toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"—",v=a?new Date(a).toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"—";return e.jsxs(I,{withBorder:!0,children:[e.jsxs(u,{justify:"space-between",wrap:"wrap",mb:"sm",children:[e.jsxs("div",{children:[e.jsx(n,{fw:600,children:"Schedule overview"}),e.jsxs(n,{size:"xs",c:"dimmed",children:[j," action",j===1?"":"s"," pending",c>0?` (${c} awaiting approval)`:"",w>0?` · spans ${w} day${w===1?"":"s"}`:""]})]}),e.jsxs(u,{gap:"xl",wrap:"wrap",children:[e.jsxs(y,{gap:2,children:[e.jsx(n,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:"Next dispatch"}),e.jsx(n,{size:"sm",fw:500,children:v})]}),e.jsxs(y,{gap:2,children:[e.jsx(n,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:"Finishes around"}),e.jsx(n,{size:"sm",fw:500,children:x})]})]})]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(n,{size:"xs",c:"dimmed",mb:4,children:"Per-day breakdown"}),e.jsxs(y,{gap:4,mb:"md",children:[l.slice(0,14).map(p=>e.jsxs(u,{gap:"sm",wrap:"nowrap",children:[e.jsx(n,{size:"xs",c:"dimmed",w:92,children:new Date(p.date+"T00:00:00Z").toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}),e.jsx("div",{style:{flex:1,height:8,background:"var(--xb-bg-soft)",border:"1px solid var(--xb-line)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{style:{width:`${p.count/g*100}%`,height:"100%",background:"var(--mantine-color-text)"}})}),e.jsx(n,{size:"xs",w:40,ta:"right",children:p.count})]},p.date)),l.length>14&&e.jsxs(n,{size:"xs",c:"dimmed",ta:"center",children:["+",l.length-14," more days"]})]})]}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(n,{size:"xs",c:"dimmed",mb:4,children:"Per-account caps + working hours"}),e.jsx(y,{gap:6,children:d.map(p=>{const m=p.workingHours||{},q=m.startHour!=null&&m.endHour!=null?`${m.startHour}:00–${m.endHour}:00${m.tz?` (${m.tz})`:""}`:"24/7",i=p.effectiveDailyCap?Math.min(100,Math.round(p.todayUsed/p.effectiveDailyCap*100)):0;return e.jsxs(u,{gap:"sm",wrap:"nowrap",style:{paddingBottom:6,borderBottom:"1px solid var(--xb-line-soft)"},children:[e.jsxs(y,{gap:0,style:{minWidth:120},children:[e.jsx(X,{handle:p.handle,accountId:p.id,size:"sm",fw:500}),e.jsx(n,{size:"xs",c:"dimmed",children:q})]}),e.jsxs(y,{gap:0,style:{flex:1},children:[e.jsxs(n,{size:"xs",c:"dimmed",children:[p.todayUsed??0," / ",p.effectiveDailyCap??"—"," today · ",p.queuedForAccount," queued"]}),p.effectiveDailyCap>0&&e.jsx("div",{style:{height:6,background:"var(--xb-bg-soft)",border:"1px solid var(--xb-line)",borderRadius:3,marginTop:4,overflow:"hidden"},children:e.jsx("div",{style:{width:`${i}%`,height:"100%",background:i>80?"repeating-linear-gradient(45deg, var(--mantine-color-text), var(--mantine-color-text) 4px, transparent 4px, transparent 8px)":"var(--mantine-color-text)"}})})]})]},p.id)})})]})]})}function U({label:s,value:h,sub:c,tone:a="gray"}){return e.jsx(I,{withBorder:!0,children:e.jsxs(y,{gap:4,children:[e.jsx(n,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:s}),e.jsx(n,{size:"xl",fw:700,c:a,children:h}),c&&e.jsx(n,{size:"xs",c:"dimmed",children:c})]})})}function cs(s){switch(s){case"running":return"green";case"paused":return"orange";case"done":return"gray";case"archived":return"gray";default:return"gray"}}function Ie(s){switch(s){case"done":return"green";case"failed":return"red";case"in-progress":return"blue";case"awaiting-approval":return"yellow";case"skipped":return"orange";case"queued":return"gray";default:return"gray"}}function os(s){return s==="dmd"?"blue":s==="replied"?"green":s==="failed"?"red":"gray"}function hs(s){return s==="follows-back"?"green":s==="no-follow-back"?"orange":s==="unfollowed"?"gray":s==="followed"?"blue":"gray"}function us({actions:s,campaignType:h}){const c=new Set(["post","thread","reply","send-dm"]),a=(s||[]).filter(l=>{var d,j;return c.has(l.type)?l.type==="thread"?Array.isArray((d=l.payload)==null?void 0:d.posts)&&l.payload.posts.length>0:!!((j=l.payload)!=null&&j.text):!1}).slice().sort((l,d)=>
11{const j=l.scheduledFor?new Date(l.scheduledFor).getTime():1/0,g=d.scheduledFor?new Date(d.scheduledFor).getTime():1/0;return j-g});if(a.length===0)return null;const o=h==="auto-posts"?"Scheduled posts":h==="auto-engage"?"Drafted replies":h==="dm-outreach"?"Scheduled DMs":"Scheduled content";return e.jsxs(I,{withBorder:!0,children:[e.jsxs(u,{justify:"space-between",mb:"sm",wrap:"wrap",children:[e.jsxs(y,{gap:0,children:[e.jsx(n,{fw:600,size:"sm",children:o}),e.jsxs(n,{size:"xs",c:"dimmed",children:["Full text of every ",h==="auto-posts"?"post":"message"," the campaign will dispatch, in order. Scroll to review."]})]}),e.jsx(S,{variant:"light",children:a.length})]}),e.jsx(O.Autosize,{mah:640,children:e.jsx(y,{gap:"sm",children:a.map(l=>e.jsx(xs,{action:l,campaignType:h},l.id))})})]})}function xs({action:s,campaignType:h}){var x,v,p;const c=be(),a=s.status||"queued",o=s.executedAt?`executed ${new Date(s.executedAt).toLocaleString()}`:s.scheduledFor?`scheduled ${new Date(s.scheduledFor).toLocaleString()}`:"no schedule",l=(x=s.payload)==null?void 0:x.target,d=((v=s.result)==null?void 0:v.tweetUrl)||((p=s.result)!=null&&p.tweetId?`https://x.com/i/web/status/${s.result.tweetId}`:null),j=["queued","awaiting-approval"].includes(a),g=s.type==="post"||s.type==="reply"?280:null;async function w(m){await T.patchAction(s.id,{text:m}),c.invalidateQueries({queryKey:["campaign-actions"]})}return e.jsxs(I,{withBorder:!0,padding:"sm",radius:"sm",children:[e.jsxs(u,{justify:"space-between",mb:6,wrap:"wrap",gap:6,children:[e.jsxs(u,{gap:6,wrap:"wrap",children:[e.jsx(S,{size:"sm",color:Ie(a),children:a}),e.jsx(S,{size:"sm",variant:"dot",children:s.type}),l&&l.startsWith("@")&&e.jsx(X,{handle:l,size:"xs",fw:500})]}),e.jsxs(u,{gap:8,wrap:"wrap",children:[e.jsx(n,{size:"xs",c:"dimmed",children:o}),d&&e.jsxs(_,{href:d,target:"_blank",rel:"noreferrer",size:"xs",children:[e.jsx(Ae,{size:12})," view on X"]})]})]}),s.type==="thread"?e.jsx(Qe,{value:s.payload.posts||[],readOnly:!0,charLimit:280}):e.jsx(ts,{value:s.payload.text,onSave:j?w:void 0,editable:j,charLimit:g}),s.error&&e.jsx(n,{size:"xs",c:"red",mt:6,children:s.error})]})}function ps({campaignId:s,steps:h,stopOnReply:c}){var l;const{data:a,isLoading:o}=M({queryKey:["sequence-progress",s],queryFn:()=>T.sequenceProgress(s),refetchInterval:6e4,enabled:!!s});return o||!a?null:e.jsx(I,{withBorder:!0,children:e.jsxs(y,{gap:"sm",children:[e.jsxs(u,{gap:"xs",children:[e.jsx(n,{fw:600,children:"Sequence progress"}),e.jsxs(S,{variant:"light",children:[a.active," active"]}),e.jsxs(S,{variant:"light",color:"gray",children:[a.terminal," done"]}),e.jsxs(S,{variant:"light",color:"blue",children:[a.total," total"]}),c&&e.jsx(S,{variant:"light",color:"grape",children:"stop on reply: ON"})]}),e.jsx(y,{gap:6,children:h.map((d,j)=>{var x;const g=((x=a.byStep)==null?void 0:x[j])||0,w=a.total?g/a.total*100:0;return e.jsxs("div",{children:[e.jsxs(u,{justify:"space-between",gap:"xs",mb:2,children:[e.jsxs(n,{size:"xs",children:["Step ",j+1," · ",e.jsx(n,{component:"span",c:"dimmed",children:d.type})]}),e.jsxs(n,{size:"xs",c:"dimmed",children:[g," waiting"]})]}),e.jsx(Se,{value:w,size:"xs"})]},d.id||`${d.templateId||"step"}-${j}`)})}),((l=a.sample)==null?void 0:l.length)>0&&e.jsx(O,{h:220,mt:"sm",children:e.jsxs(t,{verticalSpacing:4,fz:"xs",children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:"Prospect"}),e.jsx(t.Th,{children:"Step"}),e.jsx(t.Th,{children:"State"}),e.jsx(t.Th,{children:"Next due"})]})}),e.jsx(t.Tbody,{children:a.sample.map(d=>{var j;return e.jsxs(t.Tr,{children:[e.jsx(t.Td,{children:e.jsxs(_,{href:`https://x.com/${d.handle}`,target:"_blank",rel:"noreferrer",children:["@",d.handle]})}),e.jsx(t.Td,{children:d.terminal?"—":`${d.stepIndex+1} / ${h.length}`}),e.jsx(t.Td,{children:d.terminal?e.jsx(S,{size:"xs",color:"gray",children:d.terminalReason||"done"}):(j=d.lastStep)!=null&&j.skipped?e.jsx(S,{size:"xs",color:"grape",variant:"light",children:"last skipped"}):e.jsx(S,{size:"xs",color:"green",variant:"light",children:"running"})}),e.jsx(t.Td,{children:e.jsx(n,{size:"xs",c:"dimmed",children:d.terminal?"—":d.nextDueAt?new Date(d.nextDueAt).toLocaleStr
11ing():"—"})})]},d.id)})})]})})]})})}export{_s 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.