1import{v as ce,ai as ee,o as g,A as J,al as M,a4 as N,a5 as W,U as I,j as e,ag as de,T as n,C as b,G as d,ac as ue,E as R,a0 as he,I as Y,a7 as oe,D as z,L as D,X as L,aS as me,K as re,aT as pe,as as xe,am as ge,aM as je,H as fe,$ as ve,J as ne,F as be,ao as ye,S as we,W as Se}from"./index-dE8a1mPK.js";import{E as ze}from"./ErrorState-gVNyx0--.js";import{u as Ce}from"./useConfirm-4D74KrCi.js";import{I as ke}from"./IconAlertCircle-CMVlR14T.js";import{T}from"./Textarea-BtbUvWWM.js";import{P as Te}from"./Pill-yNBbBYnE.js";import{I as Ae}from"./IconTrash-DIXYcrq7.js";import{I as $}from"./IconDeviceFloppy-DgEyIcAH.js";import{R as te}from"./Radio-BhZSb0du.js";import{A as Pe,B as Be}from"./BannerPicker-BEfKaDj5.js";import{I as Re}from"./IconArrowLeft-cAVPTBNq.js";import{I as Ie}from"./IconExternalLink-DcQXcLz7.js";import{S as ie}from"./SegmentedControl-CNEtbfTu.js";import{A as Le}from"./AreaChart-DF3EymE-.js";import{S as Z}from"./SimpleGrid-DkEuk0DW.js";import{I as Ee}from"./IconHeartbeat-BJm5Ye4o.js";import{I as le}from"./IconFlame-BMTS6eFH.js";import{N as X}from"./NumberInput-EbCp_odp.js";import{T as x}from"./Table-5ftamFSf.js";import{S as Fe}from"./Switch-Bm85N10X.js";import"./IconCopy-B63sUmw8.js";import"./Code-YtMEZkZ5.js";import"./get-env-uyVen0u2.js";import"./InputsGroupFieldset-C0syow2C.js";import"./IconX-B50qDTAe.js";import"./FileButton-CykIGdWi.js";import"./IconUpload-CR5P8PK7.js";import"./Image-Ia4YApv6.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 Me=[["path",{d:"M5 7a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -10",key:"svg-0"}]],Ne=ce("outline","player-stop","PlayerStop",Me),De=["warm","witty","professional","bold","playful","direct","sharp","formal","curious","confident","friendly","contrarian"],V={name:"",tagline:"",description:"",value:"",audience:"",sellingPoints:"",tones:[],voiceNotes:"",replyLength:"",emojis:"",hashtags:"",pov:"",questions:"",topicsInclude:"",topicsExclude:"",hardRules:"",examples:"",ctaLink:"",ctaBlurb:""};function qe({accountId:a}){var S,A;const y=ee(),{confirm:m,ConfirmDialog:u}=Ce(),[t,C]=g.useState(V),p=J({queryKey:["account-brand",a],queryFn:()=>I.getAccountBrand(a),enabled:!!a});g.useEffect(()=>{var s;(s=p.data)!=null&&s.override&&C({...V,...p.data.override})},[p.data]);const k=M({mutationFn:s=>I.saveAccountBrand(a,s),onSuccess:()=>{y.invalidateQueries({queryKey:["account-brand",a]}),W("Override saved.")},onError:s=>N(s)}),w=M({mutationFn:()=>I.clearAccountBrand(a),onSuccess:()=>{C(V),y.invalidateQueries({queryKey:["account-brand",a]}),W("Override cleared. Account is back to the global brand.")},onError:s=>N(s)});if(p.isLoading)return e.jsx(de,{size:28});if(p.error)return e.jsx(n,{c:"red",children:p.error.message});const l=((S=p.data)==null?void 0:S.global)||{},j=((A=p.data)==null?void 0:A.override)||{},f=Object.keys(j).filter(s=>{const c=j[s];return typeof c=="string"?!!c.trim():Array.isArray(c)?c.length>0:c!=null}),v=Object.keys(l).some(s=>{const c=l[s];return typeof c=="string"?!!c.trim():Array.isArray(c)?c.length>0:!1});function r(s,c){C(P=>({...P,[s]:c}))}function h(s){C(c=>{const P=c.tones.includes(s);return{...c,tones:P?c.tones.filter(F=>F!==s):[...c.tones,s]}})}return e.jsxs(b,{gap:"md",children:[e.jsx(d,{justify:"space-between",wrap:"wrap",gap:"xs",children:e.jsxs(d,{gap:"xs",children:[e.jsx(ue,{size:18}),e.jsx(n,{fw:700,children:"Brand override"}),f.length>0?e.jsxs(R,{color:"violet",variant:"light",children:[f.length," field",f.length===1?"":"s"," overridden"]}):e.jsx(R,{color:"gray",variant:"light",children:"inheriting global"})]})}),!v&&e.jsxs(he,{color:"yellow",variant:"light",icon:e.jsx(ke,{size:16}),children:["You haven't set a global brand profile yet. Set one on the"," ",e.jsx(Y,{component:oe,to:"/brand",children:"Brand page"})," first â the override layers on top of it."]}),e.jsx(n,{size:"xs",c:"dimmed",children:"Fill in only the fields you want different on this account. Empty fields fall through to the global brand. Saving applies the patch immediately to auto-engage replies, automated posts, and DM co-pilot drafts on this account."}),e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Identity"}),e.jsx(D,{label:"Brand name",placeholder:l.name||"inherits from global",value:t.name,onChange:s=>r("name",s.currentTarget.value)}),e.jsx(D,{label:"One-line pitch",placeholder:l.tagline||"inherits from global",value:t.tagline,onChange:s=>r("tagline",s.currentTarget.value)}),e.jsx(T,{label:"Description",placeholder:l.description||"inherits from global",autosize:!0,minRows:2,value:t.description,onChange:s=>r("description",s.currentTarget.value)}),e.jsx(T,{label:"Value proposition",placeholder:l.value||"inherits from global",autosize:!0,minRows:2,value:t.value,onChange:s=>r("value",s.currentTarget.value)}),e.jsx(T,{label:"Audience",placeholder:l.audience||"inherits from global",autosize:!0,minRows:2,value:t.audie
6nce,onChange:s=>r("audience",s.currentTarget.value)}),e.jsx(T,{label:"Selling points",description:"One per line. Concrete reasons people pick you.",placeholder:l.sellingPoints||"inherits from global",autosize:!0,minRows:3,value:t.sellingPoints,onChange:s=>r("sellingPoints",s.currentTarget.value)})]})}),e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Voice & tone"}),e.jsxs(n,{size:"xs",c:"dimmed",children:["Empty = inherit",Array.isArray(l.tones)&&l.tones.length?` (global: ${l.tones.join(", ")})`:"","."]}),e.jsx(d,{gap:6,children:De.map(s=>e.jsx(Te,{size:"md",style:{cursor:"pointer",textTransform:"capitalize",background:t.tones.includes(s)?"var(--mantine-color-dark-9)":void 0,color:t.tones.includes(s)?"#fff":void 0},onClick:()=>h(s),children:s},s))}),e.jsx(T,{label:"Voice notes",placeholder:l.voiceNotes||"inherits from global",autosize:!0,minRows:2,value:t.voiceNotes,onChange:s=>r("voiceNotes",s.currentTarget.value)})]})}),e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"md",children:[e.jsx(n,{fw:600,size:"sm",children:"Chat guidelines"}),e.jsx(K,{label:`Reply length (global: ${l.replyLength||"â"})`,value:t.replyLength,onChange:s=>r("replyLength",s),options:[{value:"",label:"Inherit"},{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}]}),e.jsx(K,{label:`Emojis (global: ${l.emojis||"â"})`,value:t.emojis,onChange:s=>r("emojis",s),options:[{value:"",label:"Inherit"},{value:"never",label:"Never"},{value:"sometimes",label:"Sometimes"},{value:"often",label:"Often"}]}),e.jsx(K,{label:`Hashtags (global: ${l.hashtags||"â"})`,value:t.hashtags,onChange:s=>r("hashtags",s),options:[{value:"",label:"Inherit"},{value:"never",label:"Never"},{value:"sometimes",label:"Sometimes"},{value:"often",label:"Often"}]}),e.jsx(K,{label:`Voice (global: ${l.pov||"â"})`,value:t.pov,onChange:s=>r("pov",s),options:[{value:"",label:"Inherit"},{value:"i",label:'"I"'},{value:"we",label:'"We"'},{value:"brand",label:"Brand"}]}),e.jsx(K,{label:`Ask questions back (global: ${l.questions||"â"})`,value:t.questions,onChange:s=>r("questions",s),options:[{value:"",label:"Inherit"},{value:"rare",label:"Rarely"},{value:"balanced",label:"Balanced"},{value:"often",label:"Often"}]})]})}),e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Topics & rules"}),e.jsx(T,{label:"Topics to engage",placeholder:l.topicsInclude||"inherits from global",autosize:!0,minRows:3,value:t.topicsInclude,onChange:s=>r("topicsInclude",s.currentTarget.value),styles:{input:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"}}}),e.jsx(T,{label:"Topics to avoid",placeholder:l.topicsExclude||"inherits from global",autosize:!0,minRows:2,value:t.topicsExclude,onChange:s=>r("topicsExclude",s.currentTarget.value),styles:{input:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"}}}),e.jsx(T,{label:"Hard rules",placeholder:l.hardRules||"inherits from global",autosize:!0,minRows:2,value:t.hardRules,onChange:s=>r("hardRules",s.currentTarget.value)}),e.jsx(T,{label:"Sample posts",placeholder:l.examples||"inherits from global",autosize:!0,minRows:3,value:t.examples,onChange:s=>r("examples",s.currentTarget.value)})]})}),e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Promote"}),e.jsx(D,{label:"Link or offer",placeholder:l.ctaLink||"inherits from global",value:t.ctaLink,onChange:s=>r("ctaLink",s.currentTarget.value)}),e.jsx(T,{label:"How to introduce it",placeholder:l.ctaBlurb||"inherits from global",autosize:!0,minRows:2,value:t.ctaBlurb,onChange:s=>r("ctaBlurb",s.currentTarget.value)})]})}),e.jsxs(d,{justify:"space-between",wrap:"wrap",pb:"xl",children:[e.jsx(L,{variant:"default",leftSection:e.jsx(Ae,{size:14}),color:"red",onClick:async()=>{await m({title:"Clear this account's brand override?",body:"The account stops using its own brand and falls back to the global brand for every drafter call.",confirmLabel:"Clear override"})&&w.mutate()},disabled:f.length===0||w.isPending,children:"Clear override"}),e.jsx(L,{leftSection:e.jsx($,{size:14}),loading:k.isPending,onClick:()=>k.mutate(t),children:"Save override"})]}),e.jsx(u,{})]})}function K({label:a,value:y,onChange:m,options:u}){return e.jsx(te.Group,{label:a,value:y,onChange:m,children:e.jsx(d,{gap:"lg",mt:4,children:u.map(t=>e.jsx(te,{value:t.value,label:t.label},t.value||"inherit"))})})}function He({account:a}){const y=ee(),[m,u]=g.useState(a.displayName||""),[t,C]=g.useState(a.description||""),[p,k]=g.useState(a.location||""),[w,l]=g.useState(a.url||""),[j,f]=g.useState(null),[v,r]=g.useState(null),[h,S]=g.useState(null),[A,s]=g.useState(null),c=()=>{y.invalidateQueries({queryKey:["analytics-account",a.id]}),y.invalidateQueries({queryKey:["accounts"]})},P=M({mutationFn:()=>j?I.updateAccountProfile(a.id,{profileImageBase64:j}):Promise.reject(new Error("Pick a profile picture first")),onSuccess:()=>{W("Profile picture updated on X"),f(null),r(null),c()},onError:o=>N(o.message||"Profile picture update failed")}),F=M({mutationFn:()=>h?I.updateAccountProfile(a.id,{profileBannerBase64:h}):Promise.reject(new Error("Pick a banner first")),onSuccess:()=>{W("Banner updated on X"),S(null),s(null),c()},onError:o=>N(o.message||"Banner update failed")}),U=m&&m!==(a.displayName||"")||t!==(a.description||"")||p!==(a.location||"")||w!==(a.url||""),q=M({mutationFn:()=>{const o={};return m&&m!==(a.displayName||"")&&(o.name=m),t!==(a.description||"")&&(o.description=t),p!==(a.location||"")&&(o.location=p),w!==(a.url||"")&&(o.url=w),Object.keys(o).length===0?Promise.reject(new Error("Nothing changed")):I.updateAccountProfile(a.id,o)},onSuccess:()=>{W("Profile fields updated on X"),c()},onError:o=>N(o.message||"Profile fields update failed")}),H=t.length,i=H>140;return e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"md",children:[e.jsxs(d,{gap:"xs",justify:"space-between",wrap:"wrap",children:[e.jsxs(d,{gap:"xs",children:[e.jsx(me,{size:16}),e.jsx(n,{fw:600,size:"sm",children:"X profile"}),e.jsx(R,{variant:"light",size:"xs",children:"writes to X directly"})]}),e.jsx(n,{size:"xs",c:"dimmed",children:"Save each section independently."})]}),e.jsxs(b,{gap:"xs",children:[e.jsxs(d,{justify:"space-between",align:"center",children:[e.jsx(n,{size:"xs",fw:500,c:"dimmed",children:"Profile picture"}),e.jsx(L,{size:"xs",leftSection:e.jsx($,{size:12}),onClick:()=>P.mutate(),loading:P.isPending,disabled:!j,children:"Save profile picture"})]}),e.jsx(Pe,{value:v,currentUrl:a.avatar||null,onChange:(o,B)=>{f(o),r(B)}})]}),e.jsx(re,{}),e.jsxs(b,{gap:"xs",children:[e.jsxs(d,{justify:"space-between",align:"center",children:[e.jsx(n,{size:"xs",fw:500,c:"dimmed",children:"Banner"}),e.jsx(L,{size:"xs",leftSection:e.jsx($,{size:12}),onClick:()=>F.mutate(),loading:F.isPending,disabled:!h,children:"Save banner"})]}),e.jsx(Be,{value:A,currentUrl:a.banner||null,onChange:(o,B)=>{S(o),s(B)}})]}),e.jsx(re,{}),e.jsxs(b,{gap:"xs",children:[e.jsxs(d,{justify:"space-between",align:"center",children:[e.jsx(n,{size:"xs",fw:500,c:"dimmed",children:"Profile fields"}),e.jsx(L,{size:"xs",leftSection:e.jsx($,{size:12}),onClick:()=>q.mutate(),loading:q.isPending,disabled:!U,children:"Save fields"})]}),e.jsxs(d,{grow:!0,children:[e.jsx(D,{label:"Display name",description:"â¤50 chars",value:m,onChange:o=>u(o.currentTarget.value),maxLength:50}),e.jsx(D,{label:"Location",description:"â¤30 chars",value:p,onChange:o=>k(o.currentTarget.value),maxLength:30})]}),e.jsx(D,{label:"Website / URL",placeholder:"https://example.com",value:w,onChange:o=>l(o.currentTarget.value)}),e.jsx(T,{label:"Bio",description:e.jsxs(n,{size:"xs",c:i?"orange":"dimmed",component:"span",children:[H," / 160"]}),value:t,onChange:o=>C(o.currentTarget.value),minRows:3,autosize:!0,maxLength:160})]})]})})}const Oe=[{value:"7d",label:"7d"},{value:"30d",label:"30d"},{value:"90d",label:"90d"}],Ke={dms:"DMs",replies:"Replies",likes:"Likes",retweets:"Retweets",posts:"Posts",follows:"Follows",scrapes:"Scrapes"};function ws(){var S,A,s,c,P,F,U,q,H;const{id:a}=pe(),y=xe(),m=ee(),[u,t]=g.useState("30d"),[C,p]=g.useState(14),[k,w]=g.useState(""),l=J({queryKey:["analytics-account",a,u],queryFn:()=>I.analyticsAccount(a,u)}),j=J({queryKey:["account-actions",a,k],queryFn:()=>I.listActions({accountId:a,limit:100,...k?{status:k}:{}}),refetchInterval:9e4}),f=M({mutationFn:i=>I.patchAccount(a,i),onSuccess:(i,o)=>
6{m.invalidateQueries({queryKey:["analytics-account",a]}),m.invalidateQueries({queryKey:["accounts"]}),m.invalidateQueries({queryKey:["analytics-overview"]}),"warming"in o&&ge.show({color:o.warming?"green":"gray",message:o.warming?"Warming started.":"Warming stopped."})},onError:i=>N(i)});if(l.isLoading)return e.jsx(je,{});if(l.error)return e.jsx(ze,{error:l.error,onRetry:()=>l.refetch()});const v=l.data;if(!v)return null;const r=v.account,h=v.today||{byType:{},capsRemaining:{}};return e.jsxs(b,{gap:"md",children:[e.jsxs(d,{justify:"space-between",align:"flex-start",wrap:"wrap",gap:"sm",children:[e.jsxs(d,{gap:"xs",align:"center",wrap:"nowrap",style:{flex:"1 1 280px",minWidth:0},children:[e.jsx(L,{variant:"subtle",leftSection:e.jsx(Re,{size:14}),onClick:()=>y("/accounts"),px:"xs",children:"Accounts"}),e.jsx(fe,{src:r.avatar||void 0,radius:"xl",size:"md",children:(r.handle||"?").slice(0,1).toUpperCase()}),e.jsxs(b,{gap:2,style:{flex:1,minWidth:0},children:[e.jsxs(d,{gap:6,wrap:"nowrap",children:[e.jsxs(ve,{order:2,style:{wordBreak:"break-word"},children:["@",r.handle]}),e.jsx(Y,{href:`https://x.com/${r.handle}`,target:"_blank",rel:"noreferrer",children:e.jsx(Ie,{size:16})})]}),e.jsxs(d,{gap:"xs",wrap:"wrap",children:[e.jsx(R,{color:$e(r.status),children:r.status}),r.executionMode&&e.jsx(R,{variant:"light",color:"cyan",children:r.executionMode}),e.jsxs(R,{variant:"light",color:Ue(r.healthScore),children:["health ",r.healthScore??100]})]})]})]}),e.jsx(ie,{value:u,onChange:t,data:Oe,size:"xs"})]}),e.jsxs(z,{withBorder:!0,children:[e.jsx(n,{fw:600,size:"sm",mb:"xs",children:"Activity"}),e.jsx(Le,{h:200,data:v.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(Z,{cols:{base:2,sm:4},spacing:"md",children:[e.jsx(_,{label:`DMs sent (${u})`,value:((S=v.totals)==null?void 0:S.sent)||0}),e.jsx(_,{label:`Likes (${u})`,value:((A=v.totals)==null?void 0:A.likes)||0}),e.jsx(_,{label:`Retweets (${u})`,value:((s=v.totals)==null?void 0:s.retweets)||0}),e.jsx(_,{label:`Errors (${u})`,value:((c=v.totals)==null?void 0:c.errors)||0,tone:(((P=v.totals)==null?void 0:P.errors)||0)>0?"red":"gray"})]}),e.jsxs(z,{withBorder:!0,children:[e.jsxs(d,{justify:"space-between",mb:"xs",children:[e.jsxs(d,{gap:"xs",children:[e.jsx(Ee,{size:16}),e.jsx(n,{fw:600,size:"sm",children:"Today's usage vs caps"})]}),e.jsx(n,{size:"xs",c:"dimmed",children:"UTC day · resets at 00:00"})]}),e.jsx(Z,{cols:{base:2,sm:3,md:4,lg:7},spacing:"md",children:Object.entries(Ke).map(([i,o])=>{var ae;const B=(ae=r.dailyCaps)==null?void 0:ae[i],O=h.capsRemaining[i],Q=i==="dms"?"send-dm":i==="replies"?"reply":i.slice(0,-1),se=h.byType[Q]||0,E=B===void 0&&i!=="scrapes"?null:B??(i==="scrapes"?1500:0),G=E?Math.min(100,se/E*100):0;return e.jsx(z,{withBorder:!0,p:"xs",children:e.jsxs(b,{gap:4,children:[e.jsx(n,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:o}),e.jsxs(n,{size:"lg",fw:700,children:[se,E?e.jsxs(n,{span:!0,size:"xs",c:"dimmed",fw:400,children:[" / ",E]}):null]}),E!==null&&E>0&&e.jsx(ne,{value:G,size:"xs",color:G>80?"red":G>50?"yellow":"green"}),O!==void 0&&E>0&&e.jsxs(n,{size:"xs",c:"dimmed",children:[O," left"]}),E===null&&e.jsx(n,{size:"xs",c:"dimmed",children:"no cap set"})]})},i)})})]}),e.jsx(z,{withBorder:!0,children:e.jsxs(d,{justify:"space-between",align:"flex-start",wrap:"wrap",gap:"sm",children:[e.jsxs(b,{gap:4,style:{flex:"1 1 280px"},children:[e.jsxs(d,{gap:"xs",children:[e.jsx(le,{size:16}),e.jsx(n,{fw:600,size:"sm",children:"Warming"}),r.warmingStartedAt?e.jsxs(R,{color:"orange",variant:"light",children:["on · day ",Math.floor((Date.now()-r.warmingStartedAt)/864e5)+1," / ",r.warmingDays||14]}
6):e.jsx(R,{color:"gray",variant:"light",children:"off · full caps"})]}),e.jsxs(n,{size:"xs",c:"dimmed",children:["Fresh accounts get hit hard by full caps on day one. Warming ramps the effective ",e.jsx("code",{children:"dailyCaps"})," from 20% â 100% over the chosen window so X eases in. Worker dispatch checks this automatically."]}),r.warmingStartedAt&&e.jsx(ne,{size:"sm",value:Math.min(100,100*Math.min(1,(Date.now()-r.warmingStartedAt)/((r.warmingDays||14)*864e5))),color:"orange"})]}),e.jsxs(d,{gap:"xs",align:"flex-end",children:[!r.warmingStartedAt&&e.jsx(X,{label:"Days to ramp",size:"xs",value:C,onChange:i=>p(Number(i)||14),min:1,max:60,w:120}),r.warmingStartedAt?e.jsx(L,{size:"xs",variant:"light",color:"gray",leftSection:e.jsx(Ne,{size:14}),onClick:()=>f.mutate({warming:null}),loading:f.isPending,children:"Stop warming"}):e.jsx(L,{size:"xs",leftSection:e.jsx(le,{size:14}),onClick:()=>f.mutate({warming:!0,warmingDays:C}),loading:f.isPending,children:"Start warming"})]})]})}),e.jsx(He,{account:r}),e.jsx(We,{account:r,onSave:i=>f.mutate(i),saving:f.isPending}),e.jsxs(z,{withBorder:!0,p:0,children:[e.jsxs(d,{justify:"space-between",p:"md",children:[e.jsx(n,{fw:600,size:"sm",children:"Recent actions"}),e.jsxs(d,{gap:"xs",children:[e.jsx(ie,{size:"xs",value:k,onChange:w,data:[{value:"",label:"All"},{value:"failed",label:"Failed"},{value:"done",label:"Done"},{value:"queued",label:"Queued"}]}),e.jsxs(n,{size:"xs",c:"dimmed",children:[((U=(F=j.data)==null?void 0:F.actions)==null?void 0:U.length)||0," actions"]}),e.jsx(be,{variant:"subtle",onClick:()=>j.refetch(),loading:j.isRefetching,children:e.jsx(ye,{size:14})})]})]}),e.jsx(we.Autosize,{mah:420,children:e.jsxs(x,{stickyHeader:!0,highlightOnHover:!0,children:[e.jsx(x.Thead,{children:e.jsxs(x.Tr,{children:[e.jsx(x.Th,{children:"Status"}),e.jsx(x.Th,{children:"Type"}),e.jsx(x.Th,{children:"Campaign"}),e.jsx(x.Th,{children:"Target"}),e.jsx(x.Th,{children:"Scheduled"}),e.jsx(x.Th,{children:"Note"})]})}),e.jsx(x.Tbody,{children:(((q=j.data)==null?void 0:q.actions)||[]).map(i=>{var o,B,O,Q;return e.jsxs(x.Tr,{children:[e.jsx(x.Td,{children:e.jsx(R,{size:"sm",color:Qe(i.status),children:i.status})}),e.jsx(x.Td,{children:e.jsx(n,{size:"xs",children:i.type})}),e.jsx(x.Td,{children:i.campaignId?e.jsx(Y,{component:oe,to:`/campaigns/${i.campaignId}`,size:"xs",children:"view"}):e.jsx(n,{size:"xs",c:"dimmed",children:"â"})}),e.jsx(x.Td,{children:e.jsx(n,{size:"xs",truncate:!0,maw:200,children:((o=i.payload)==null?void 0:o.target)||"â"})}),e.jsx(x.Td,{children:e.jsx(n,{size:"xs",c:"dimmed",children:i.scheduledFor?new Date(i.scheduledFor).toLocaleString():"â"})}),e.jsx(x.Td,{children:e.jsx(Se,{label:i.error||((B=i.result)==null?void 0:B.reason)||"",multiline:!0,w:360,withArrow:!0,position:"top-end",disabled:!(i.error||(O=i.result)!=null&&O.reason),children:e.jsx(n,{size:"xs",c:i.status==="failed"?"red":"dimmed",lineClamp:3,maw:320,children:i.error||((Q=i.result)==null?void 0:Q.reason)||""})})})]},i.id)})})]})}),!j.isLoading&&(((H=j.data)==null?void 0:H.actions)||[]).length===0&&e.jsx(n,{size:"sm",c:"dimmed",ta:"center",p:"md",children:"No actions for this account yet."})]}),e.jsx(qe,{accountId:a})]})}function We({account:a,onSave:y,saving:m}){const u=a.workingHours||{},[t,C]=g.useState(Number.isFinite(u.startHour)?u.startHour:9),[p,k]=g.useState(Number.isFinite(u.endHour)?u.endHour:18),[w,l]=g.useState(!u||u.startHour===0&&u.endHour===24),[j,f]=g.useState(a.dailyCaps||{}),v=[{key:"dms",label:"DMs / day"},{key:"replies",label:"Replies / day"},{key:"likes",label:"Likes / day"},{key:"retweets",label:"Retweets / day"},{key:"posts",label:"Posts / day"},{key:"follows",label:"Follows / day"},{key:"scrapes",label:"Lead scrapes / day"}],r=()=>{const h={workingHours:w?{startHour:0,endHour:24}:{startHour:Math.max(0,Math.min(23,t)),endHour:Math.max(1,Math.min(24,p))},dailyCaps:Object.fromEntries(v.map(S=>[S.key,Math.max(0,Math.min(2e3,Number(j[S.key])||0))]))};y(h)};return e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:"sm",children:[e.jsx(d,{justify:"space-between",wrap:"wrap",children:e.jsxs("div",{children:[e.jsx(n,{fw:600,size:"sm",children:"Working hours + daily caps"}),e.jsx(n,{size:"xs",c:"dimmed",children:"Window the worker dispatches in (UTC) and per-type daily ceilings. Saving any field re-saves the whole block â pick aggressiveness preset on the Accounts page for quick defaults."})]})}),e.jsxs(d,{align:"flex-end",wrap:"wrap",gap:"sm",children:[e.jsx(Fe,{label:"Dispatch 24/7",description:"Skip the hours gate",checked:w,onChange:h=>l(h.currentTarget.checked)}),!w&&e.jsxs(e.Fragment,{children:[e.jsx(X,{label:"Start hour (UTC)",value:t,onChange:h=>C(Math.max(0,Math.min(23,Number(h)||0))),min:0,max:23,w:140}),e.jsx(X,{label:"End hour (UTC)",description:"exclusive · 18 = stops at 17:59",value:p,onChange:h=>k(Math.max(1,Math.min(24,Number(h)||0))),min:1,max:24,w:140})]})]}),e.jsx(Z,{cols:{base:2,sm:4,md:7},spacing:"xs",children:v.map(h=>e.jsx(X,{label:h.label,size:"xs",min:0,max:2e3,value:Number(j[h.key])||0,onChange:S=>f(A=>({...A,[h.key]:Number(S)||0}))},h.key))}),e.jsx(d,{justify:"flex-end",children:e.jsx(L,{size:"xs",onClick:r,loading:m,leftSection:e.jsx($,{size:14}),children:"Save"})})]})})}function _({label:a,value:y,sub:m,tone:u="gray"}){return e.jsx(z,{withBorder:!0,children:e.jsxs(b,{gap:4,children:[e.jsx(n,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:a}),e.jsx(n,{size:"xl",fw:700,c:u,children:y}),m&&e.jsx(n,{size:"xs",c:"dimmed",children:m})]})})}function $e(a){return a==="active"?"green":a==="needs_reauth"?"red":a==="cooldown"?"orange":a==="paused"?"gray":a==="banned"?"red":"gray"}function Ue(a){return a==null?"gray":a>=70?"green":a>=40?"yellow":"red"}function Qe(a){switch(a){case"done":return"green";case"failed":return"red";case"in-progress":return"blue";case"awaiting-approval":return"yellow";case"skipped":return"orange";default:return"gray"}}export{ws 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.