1import{as as U,o as r,A as V,al as W,a4 as Y,a5 as F,U as A,j as e,C as b,G as o,X as C,$ as _,E as J,D as Z,L as H,T as n,a0 as ee,aa as te,ae}from"./index-dE8a1mPK.js";import{a as se,c as K,f as re}from"./draftStorage-BA_l97c0.js";import{u as oe}from"./useDraftAutosave-BRfAYMIp.js";import{I as ne}from"./IconArrowLeft-cAVPTBNq.js";import{I as ie}from"./IconDeviceFloppy-DgEyIcAH.js";import{M as ce}from"./MultiSelect-CJSWniGq.js";import{N as g}from"./NumberInput-EbCp_odp.js";import{S as le}from"./Switch-Bm85N10X.js";import{S as ue}from"./Slider-BN-TlbvN.js";import"./OptionsDropdown-wonErrz5.js";import"./CheckIcon-DkMc45y2.js";import"./Pill-yNBbBYnE.js";import"./PillsInput-BO1u7Wrq.js";import"./InputsGroupFieldset-C0syow2C.js";const h="campaign:auto-engage";function be(){const i=U(),a=r.useMemo(()=>se(h),[]),s=(a==null?void 0:a.value)||{},[c,I]=r.useState(s.name||""),[l,R]=r.useState(s.accountIds||[]),[u,E]=r.useState(s.keywords||""),[x,N]=r.useState(s.minLikes??10),[f,L]=r.useState(s.maxAgeHours??6),[j,P]=r.useState(s.searchIntervalMin??20),[v,T]=r.useState(s.maxPerSearch??5),[m,z]=r.useState(s.pctLike??60),[d,D]=r.useState(s.pctRetweet??10),[p,q]=r.useState(s.pctReply??25),[w,O]=r.useState(!!s.approvalMode);oe(h,{name:c,accountIds:l,keywords:u,minLikes:x,maxAgeHours:f,searchIntervalMin:j,maxPerSearch:v,pctLike:m,pctRetweet:d,pctReply:p,approvalMode:w},{isEmpty:t=>!t.name.trim()&&!t.accountIds.length&&!t.keywords.trim()&&!t.approvalMode});const{data:y}=V({queryKey:["accounts"],queryFn:()=>A.listAccounts()}),S=m+d+p,k=Math.max(0,100-S);function Q(){return{keywords:u,filters:{minLikes:x,maxAgeHours:f},searchIntervalMin:j,maxPerSearch:v,actionMix:{like:m/100,retweet:d/100,reply:p/100,quote:k/100}}}const B=W({mutationFn:async()=>{const t=await A.createCampaign({type:"auto-engage",name:c,accountIds:l,approvalMode:w,config:Q()}),$=await A.startCampaign(t.id);return{id:t.id,...$}},onSuccess:()=>{F("Auto Engage running â first search queued"),K(h),i("/campaigns")},onError:t=>Y(t)}),G=c.trim()&&l.length===1&&u.trim(),X=((y==null?void 0:y.accounts)||[]).filter(t=>t.status==="active");return e.jsxs(b,{gap:"md",children:[e.jsxs(o,{children:[e.jsx(C,{variant:"subtle",leftSection:e.jsx(ne,{size:14}),onClick:()=>i("/campaigns"),children:"Back"}),e.jsx(_,{order:2,children:"New Auto Engage campaign"}),(a==null?void 0:a.ts)&&e.jsxs(J,{color:"blue",variant:"light",leftSection:e.jsx(ie,{size:12}),children:["Resumed from ",re(a.ts)]})]}),e.jsx(Z,{withBorder:!0,p:"lg",children:e.jsxs(b,{gap:"md",children:[e.jsx(H,{label:"Campaign name",placeholder:"Shopify SEO conversation",value:c,onChange:t=>I(t.currentTarget.value)}),e.jsx(ce,{label:"Account to engage from",description:"Auto Engage runs from one account at a time. Multi-account engagement on the same tweets gets flagged fast.",placeholder:"Pick one account",value:l,onChange:t=>R(t.slice(-1)),data:X.map(t=>({value:t.id,label:`@${t.handle}`})),maxValues:1}),e.jsx(H,{label:"Keywords or query",description:'X search syntax works â e.g., "shopify SEO" OR "ranktail"',placeholder:'"shopify SEO" OR "ranktail"',value:u,onChange:t=>E(t.currentTarget.value)}),e.jsxs(o,{grow:!0,children:[e.jsx(g,{label:"Min likes (filter)",value:x,onChange:t=>N(Number(t)||0),min:0}),e.jsx(g,{label:"Max tweet age (hours)",value:f,onChange:t=>L(Number(t)||0),min:1,max:168})]}),e.jsxs(o,{grow:!0,children:[e.jsx(g,{label:"Search every N minutes",value:j,onChange:t=>P(Number(t)||20),min:5,max:240}),e.jsx(g,{label:"Max tweets per search",value:v,onChange:t=>T(Number(t)||5),min:1,max:25})]}),e.jsxs(b,{gap:"xs",children:[e.jsx(n,{fw:600,size:"sm",children:"Action mix"}),e.jsxs(n,{size:"xs",c:"dimmed",children:["Probability per matching tweet. Quote-retweet gets the leftover ",k,"%."]}),e.jsx(M,{label:"Like",value:m,onChange:z}),e.jsx(M,{label:"Retweet",value:d,onChange:D}),e.jsx(M,{label:"Reply (AI-generated)",value:p,onChange:q}),S>100&&e.jsxs(n,{size:"xs",c:"red",children:["Total > 100% â slide some down. Quote = ",k,"%."]})]}),e.jsx(le,{label:"Approval mode",description:"If on, generated replies wait for manual approval. Likes/retweets always auto-execute.",checked:w,onChange:t=>O(t.currentTarget.checked)}),e.jsx(ee,{color:"orange",icon:e.jsx(te,{size:16}),variant:"light",children:"Auto-engagement at scale risks suspension if it doesn't look human. Caps + working hours + per-author cooldown apply automatically. Watch the History page during the first hour and pause if anything looks off."}),e.jsxs(o,{justify:"flex-end",gap:"xs",children:[(a==null?void 0:a.ts)&&e.jsx(C,{variant:"subtle",color:"gray",onClick:()=>{K(h),I(""),R([]),E(""),N(10),L(6),P(20),T(5),z(60),D(10),q(25),O(!1),F("Draft discarded")},children:"Discard draft"}),e.jsx(C,{leftSection:e.jsx(ae,{size:16}),onClick:()=>B.mutate(),disabled:!G||S>100,loading:B.isPending,children:"Create & start"})]})]})})]})}function M({label:i,value:a,onChange:s}){return e.jsxs(o,{align:"center",gap:"xs",wrap:"nowrap",children:[e.jsx(n,{size:"sm",w:170,children:i}),e.jsx(ue,{value:a,onChange:s,min:0,max:100,step:5,style:{flex:1},marks:[{value:0},{value:50},{value:100}]}),e.jsxs(n,{size:"sm",w:48,ta:"right",children:[a,"%"]})]})}export{be 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.