1import{r as a,R as oe,j as e,a as we,u as Se,b as Ne,e as Le,f as Ce,c as Me,d as Ae,E as Ee}from"./tiptap-DhiOex2s.js";import{C as le}from"./ConfirmModal-DOCjyizl.js";import{S as ye}from"./SelectDropdown-BQKDK5uu.js";import{A as _e,n as Ie}from"./app-CzmKNL49.js";import{s as Pe,h as Re}from"./EmailMarketing-CgIIKpuu.js";import{a as Te,I as Ve,b as be}from"./SequenceIcons-g6dgd_10.js";import{b as Fe}from"./QuestionMarkCircleIcon-DJ5WutWA.js";import{c as Oe,a as Be}from"./KeyIcon-DlsEt8FE.js";import"./translateUi-CjnDG24r.js";import"./useTranslation-BNRVKauE.js";import"./useSelectDropdown-LDfO5ZBA.js";import"./dropdownFlip-69LYEV6_.js";/* empty css */import"./DashboardLayout-CW3khL0l.js";import"./useLayoutFillViewport-8H_hlwFz.js";import"./authApi-Ct6x04f1.js";import"./auth-0n2aIWft.js";import"./settings-TpopaF38.js";import"./dashboard-Cr01TR7f.js";import"./leads-B60GwSmS.js";import"./callingAgent-CLLJLF4F.js";import"./crm-DouVBd_i.js";import"./LanguageSwitcher-DFIZo8yj.js";import"./aiTokensGate-DqkuM3Tf.js";import"./subscription-5Jg1YSG8.js";import"./tableStyles-BVuRQy1a.js";import"./useAppLayout-B9BeOwyc.js";import"./leadGenerator-w6JnmDkj.js";import"./AnalyticsCard-7PxUfTgz.js";import"./DataTable-BYJZYtsI.js";import"./TablePaginationBar-CcG4DTXK.js";import"./FilterDropdown-BZ2FmqIi.js";import"./useClientTablePagination-DOzLvsla.js";import"./DateFilterDropdown-CMqG8R5T.js";import"./useDateFilterDropdown-Dea4atNP.js";import"./StatusPill-Dp0WlVE5.js";import"./statusPillThemes-DN01zhHK.js";import"./emailMarketingLeadsFlowUrl-CWgsRiJo.js";import"./Checkbox-Bdrmivhf.js";import"./leads.constants-CxLdOgPP.js";import"./leads.formatters-hUOsqWMH.js";import"./emailMarketingCampaignService-Ceg4VKKN.js";import"./IconArrowLeft-E15zUsVP.js";import"./AiCreationChatPanel-ERWu2AOM.js";import"./ChatMessageText-CAnhejvq.js";import"./Toggle-ey35Cz2u.js";import"./businessWebsiteScrapeService-C93dd1xI.js";import"./aiCreationChatHelpers-C1F2bQD3.js";import"./product-QySh7dH4.js";import"./wizardService-BQvVXhTr.js";import"./emailMarketingImportService-5ADL1CCW.js";import"./emailMarketingUtils-DTEO32gQ.js";import"./mailConnectionService-B1q_DNde.js";import"./useAiTokensGate-BHez6djR.js";import"./tableDateFilter-BVJpkXmn.js";import"./GlobalTableSearch-D8Ah76-n.js";function $e({open:r,tooltip:n}){const t=a.useRef(null),o=a.useRef(null),[s,b]=a.useState({top:0,left:0,placement:"top"}),m=a.useCallback(()=>{const i=t.current,g=o.current;if(!i||!g)return;const d=i.getBoundingClientRect(),f=g.getBoundingClientRect(),w=8,j=12;let p="top",L=d.top-f.height-w;L<j&&(p="bottom",L=d.bottom+w);let N=d.left+d.width/2-f.width/2;N=Math.max(j,Math.min(N,window.innerWidth-f.width-j)),p==="bottom"&&L+f.height>window.innerHeight-j&&(L=Math.max(j,window.innerHeight-f.height-j)),b({top:L,left:N,placement:p})},[]);return a.useLayoutEffect(()=>
1{r&&m()},[r,n,m]),a.useLayoutEffect(()=>{if(!r)return;const i=()=>m();window.addEventListener("resize",i),window.addEventListener("scroll",i,!0);const g=new ResizeObserver(()=>m());return t.current&&g.observe(t.current),o.current&&g.observe(o.current),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0),g.disconnect()}},[r,m]),{anchorRef:t,popoverRef:o,pos:s}}function De({editor:r}){const[n,t]=a.useState(!1),[o,s]=a.useState("https://"),[b,m]=a.useState(""),i=a.useCallback(()=>{if(!r)return;const f=r.getAttributes("link").href;s(f||"https://"),m(""),t(!0)},[r]),g=a.useCallback(()=>{t(!1),m("")},[]),d=a.useCallback(()=>{if(!r)return;const f=String(o||"").trim();if(f===""){r.chain().focus().extendMarkRange("link").unsetLink().run(),t(!1);return}if(!/^https?:\/\//i.test(f)){m("Enter a valid URL starting with http:// or https://");return}const{from:w,to:j,empty:p}=r.state.selection;if(p){r.chain().focus().insertContent(f).setTextSelection({from:w,to:w+f.length}).setLink({href:f}).run(),t(!1);return}r.chain().focus().extendMarkRange("link").setLink({href:f}).run(),t(!1)},[r,o]);return{linkModalOpen:n,linkUrl:o,setLinkUrl:s,linkError:b,openLinkModal:i,closeLinkModal:g,confirmLinkModal:d}}function qe(){const[r,n]=a.useState(!1),t=a.useRef(null),o=a.useRef(null),s=a.useRef(null),[b,m]=a.useState(null),i=a.useCallback(()=>{const d=o.current;if(!d)return;const f=d.getBoundingClientRect(),w=window.innerHeight,j=window.innerWidth,p=4,L=8,N=240,A=w-f.bottom-p-L,P=f.top-p-L,R=A>=Math.min(N,160)||A>=P,O=Math.min(N,Math.max(120,R?A:P)),F=R?f.bottom+p:Math.max(L,f.top-p-O),_=Math.min(320,Math.max(260,f.width));let T=f.right-_;T=Math.max(L,Math.min(T,j-_-L)),m({top:F,left:T,width:_,maxHeight:O})},[]);a.useEffect(()=>{if(!r)return;const d=w=>{var j,p;(j=t.current)!=null&&j.contains(w.target)||(p=s.current)!=null&&p.contains(w.target)||n(!1)},f=w=>{w.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[r]),a.useLayoutEffect(()=>{if(!r)return;i();const d=()=>i();return window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[r,i]),a.useEffect(()=>{r||m(null)},[r]);const g=a.useCallback(d=>{d||(r||i(),n(f=>!f))},[r,i]);return{open:r,setOpen:n,wrapRef:t,triggerRef:o,listRef:s,placement:b,layoutList:i,toggleOpen:g}}const he=/\{\{\s*([^}]+?)\s*\}\}/g;function re(r){return String(r??"").replace(/^\uFEFF/,"").trim().replace(/\s+/g," ").toLowerCase()}function ce(r){const n=String(r??"").trim().split(/\s+/).filter(Boolean);return n.length===0?"":n.map((t,o)=>{const s=t.replace(/[^a-zA-Z0-9]/g,"");return s?o===0?s.toLowerCase():s.charAt(0).toUpperCase()+s.slice(1).toLowerCase():""}).join("")}function je(r){const n=ce(r);return n?n.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase():""}function He(r,n,t){const o=String(t??"").trim();if(!o)return;const s=String(n??"").trim();if(!s)return;r[re(s)]=o;const b=ce(s);b&&(r[re(b)]=o);const m=je(s);m&&(r[re(m)]=o)}function Ue(r,n){const t=String(n??"").trim();if(!t)return"";const o=[re(t),re(ce(t)),re(je(t))];for(const s of o)if(s&&r[s]!=null&&String(r[s]).trim()!=="")return String(r[s]);return""}function We(r={}){const n={};return Object.entries(r).forEach(([t,o])=>{He(n,t,o)}),n}function ge(r,n={}){let t=String(r??"");return t=t.replace(/\{\{((?:<[^>]+>|\s|&[#\w]+;|[^}])*)\}\}/g,(o,s)=>{const b=String(s).replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();return b?`{{${b}}}`:""}),t=t.replace(he,(o,s)=>Ue(s,n)),t=t.replace(he,""),t=t.replace(/<p[^>]*>\s*(?:<br\s*\/?>)?\s*<\/p>/gi,""),t}function Ke(r){const n=/\{\{\s*([^}]+?)\s*\}\}/g,t=[],o=new Set;let s;const b=String(r??"");for(;(s=n.exec(b))!==null;){const m=String(s[1]??"").replace(/<[^>]+>/g,"").trim();!m||o.has(m)||(o.add(m),t.push(m))}return t}function Ge(r){const n=String(r||"");if(typeof window<"u"&&typeof window.DOMParser<"u")try{const m=new window.DOMParser().parseFromString(`<div id="crm-preview-root">${n}</div>`,"text/html").getElementById("crm-preview-root");return m?(m.querySelectorAll("style,script,link,meta").forEach(i=>
1i.remove()),m.querySelectorAll("*").forEach(i=>{i.removeAttribute("style"),i.removeAttribute("color"),i.removeAttribute("bgcolor"),i.removeAttribute("class"),i.removeAttribute("id")}),m.innerHTML):n}catch{}return n.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/\s(?:color|bgcolor|class|id)=(".*?"|'.*?'|[^\s>]+)/gi,"").replace(/style\s*=\s*(['"])(.*?)\1/gi,"")}const Qe="Variants let you create multiple versions of the same email step. Each lead may receive a different variant to compare which subject line or message performs better.",Je="Steps help you build an automated email sequence. Each step is sent based on your schedule and campaign settings.",Ye=[{title:"Sender first name",token:"{{firstName}}",context:"Sender"},{title:"Sender last name",token:"{{lastName}}",context:"Sender"},{title:"Your company name",token:"{{companyName}}",context:"Sender"},{title:"Sender signature",token:"{{accountSignature}}",context:"Sender"},{title:"Lead first name",token:"{{leadFirstName}}",context:"Lead"},{title:"Lead last name",token:"{{leadLastName}}",context:"Lead"},{title:"Lead company name",token:"{{leadCompanyName}}",context:"Lead"},{title:"Lead email",token:"{{email}}",context:"Lead"},{title:"Lead phone",token:"{{phone}}",context:"Lead"},{title:"Lead website",token:"{{website}}",context:"Lead"},{title:"Personalization",token:"{{personalization}}",context:"Lead"}],Ze="focus-gradient-ring relative inline-flex min-w-[160px] max-w-full cursor-pointer items-center rounded-lg border border-zinc-300 bg-white px-3 py-2 pr-10 text-left text-sm shadow-sm transition hover:border-zinc-400 dark:border-zinc-600 dark:bg-zinc-800 dark:hover:border-zinc-500",Xe="overflow-y-auto overflow-x-hidden rounded-lg border border-zinc-300 bg-[#F9FAFB] py-1 shadow-xl dark:border-zinc-600 dark:bg-zinc-800",et="cursor-pointer px-3 py-2.5 text-left transition-colors hover:bg-sky-50 dark:hover:bg-sky-950/40";function tt({open:r,subject:n="",html:t="",campaignId:o,stepSortOrder:s,mailConnections:b=[],manualLeads:m=[],canTestSend:i=!1}){const g=a.useRef(null),[d,f]=a.useState("campaign"),[w,j]=a.useState(!1),[p,L]=a.useState(""),[N,A]=a.useState(()=>
1new Set),[P,R]=a.useState(()=>({})),[O,F]=a.useState(!1),[_,T]=a.useState(null);a.useEffect(()=>{r&&(f("campaign"),j(!1),L(""),A(new Set),R({}),T(null))},[r,o]);const q=a.useMemo(()=>{const C=`${n||""} 2${t||""}`;return Ke(C)},[n,t]),B=a.useMemo(()=>We(P),[P]),G=a.useMemo(()=>ge(t,B),[t,B]),Z=a.useMemo(()=>ge(n,B),[n,B]),W="#111827",Y=a.useMemo(()=>Ge(G),[G]);a.useEffect(()=>{const C=g.current;if(!C)return;const E=C.querySelectorAll("*");[C,...E].forEach(y=>{y instanceof HTMLElement&&(y.style.setProperty("color",W,"important"),y.style.setProperty("-webkit-text-fill-color",W,"important"),y.style.removeProperty("opacity"),y.style.removeProperty("filter"),y.style.removeProperty("mix-blend-mode"),y.style.removeProperty("text-shadow"))}),C.querySelectorAll("a").forEach(y=>{if(!(y instanceof HTMLElement))return;const z="#155DFC";y.style.setProperty("color",z,"important"),y.style.setProperty("-webkit-text-fill-color",z,"important")})},[Y,W]);const D=a.useMemo(()=>{const C=[{value:"campaign",label:"Campaign default (Options tab)"},{value:"app",label:"Application mailer (no connected inbox)"}];return b.forEach(E=>{C.push({value:String(E.id),label:E.label?`${E.fromEmail} (${E.label})`:E.fromEmail})}),C},[b]),M=a.useMemo(()=>{const C=p.trim().toLowerCase(),E=Array.isArray(m)?m:[];return C?E.filter(I=>{const y=String(I.name||"").toLowerCase(),z=String(I.email||"").toLowerCase(),x=String(I.company||"").toLowerCase();return y.includes(C)||z.includes(C)||x.includes(C)}).slice(0,80):E.slice(0,80)},[m,p]),K=typeof s=="number"&&s>=0,Q=i&&!!o&&K&&N.size>0&&N.size<=50,ne=a.useCallback(C=>{A(E=>{const I=new Set(E);return I.has(C)?I.delete(C):I.size<50&&I.add(C),I})},[]),X=a.useCallback(async()=>{var C,E,I,y;if(!(!Q||!o)){F(!0),T(null);try{const z={step_sort_order:s,recipient_mode:"manual",manual_lead_ids:Array.from(N),schedule:"immediate",custom_variables:P};d==="app"?z.force_application_mailer=!0:d!=="campaign"&&(z.mail_connection_id=parseInt(d,10));const x=await Pe(o,z);x!=null&&x.scheduled?T({type:"ok",text:"Scheduled successfully."}):T({type:"ok",text:`Done: ${(x==null?void 0:x.sent_ok)??0} sent, ${(x==null?void 0:x.sent_fail)??0} failed (${(x==null?void 0:x.recipient_count)??0} recipients).`})}catch(z){const x=((E=(C=z==null?void 0:z.response)==null?void 0:C.data)==null?void 0:E.message)||((y=(I=z==null?void 0:z.response)==null?void 0:I.data)!=null&&y.errors&&typeof z.response.data.errors=="object"?Object.values(z.response.data.errors).flat()[0]:null)||(z==null?void 0:z.message)||"Could not send.";T({type:"err",text:String(x)})}finally{F(!1)}}},[Q,o,s,N,d,P]);return{previewRef:g,sendMailbox:d,setSendMailbox:f,leadPickerOpen:w,setLeadPickerOpen:j,leadSearch:p,setLeadSearch:L,selectedLeadIds:N,variableValues:P,setVariableValues:R,sending:O,sendMessage:_,detectedVariables:q,renderedSubject:Z,previewHtml:Y,mailboxOptions:D,filteredLeads:M,stepReady:K,canSend:Q,toggleLead:ne,sendTest:X}}function ve(r){if(typeof r=="number"&&Number.isFinite(r)&&r>0)return Math.floor(r);if(typeof r!="string")return null;const n=r.match(/^(?:step|var)-(\d+)$/);if(!n)return null;const t=Number(n[1]);return Number.isFinite(t)&&t>0?t:null}const rt=[{value:"days",label:"Days"},{value:"hours",label:"Hours"},{value:"minutes",label:"Minutes"}];function nt(r,n){const t=String(r??""),o=t.trim();if(!o)return`<p>${n}</p>`;if(!/<[a-z][\s\S]*>/i.test(o))return`<p>${o} ${n}</p>`;const s=t.lastIndexOf("</p>");return s!==-1?`${t.slice(0,s)} ${n}${t.slice(s)}`:`${t} ${n}`}function ie(r){return`${r}-${Math.random().toString(36).slice(2,10)}`}function at(r){return String.fromCharCode(65+r)}function te(r){const n=r==null?void 0:r.steps;return n&&n.length>0?n.map((t,o)=>{const s=t.delay_after_previous_value,b=t.delay_after_previous_unit,m=b==="days"||b==="hours"||b==="minutes";return{id:`step-${t.id}`,sortOrder:typeof t.sort_order=="number"?t.sort_order:o,...o>0?{delayAfterPrevious:{value:s!=null&&Number(s)>=1?Number(s):1,unit:m?b:"days"}}:{},variants:t.variants.map(i=>({id:`var-${i.id}`,label:i.label||"A",subject:typeof i.subject=="string"?i.subject:"",enabled:i.enabled!==!1,body:typeof i.body=="str
2ing"?i.body:""}))}}):[{id:ie("step"),variants:[{id:ie("var"),label:"A",subject:"",enabled:!0,body:""}]}]}function it(r){const n=String(r??"").trim();return n?n.replace(/<[^>]*>/g," ").replace(/ | /gi," ").replace(/\s+/g," ").trim().length>0:!1}function st(r){const n=Array.isArray(r)?r:[];return n.length===0?!1:n.every(t=>(Array.isArray(t==null?void 0:t.variants)?t.variants:[]).some(s=>(s==null?void 0:s.enabled)!==!1&&String((s==null?void 0:s.subject)??"").trim()!==""&&it(s==null?void 0:s.body)))}function se(r){return JSON.stringify((Array.isArray(r)?r:[]).map(n=>({delayAfterPrevious:n!=null&&n.delayAfterPrevious?{value:Number(n.delayAfterPrevious.value),unit:n.delayAfterPrevious.unit}:null,variants:(Array.isArray(n==null?void 0:n.variants)?n.variants:[]).map(t=>({label:String((t==null?void 0:t.label)??""),enabled:(t==null?void 0:t.enabled)!==!1,subject:String((t==null?void 0:t.subject)??""),body:String((t==null?void 0:t.body)??"")}))})))}function ot({campaignId:r,initialSequences:n,onDirtyChange:t,editorFocusRequest:o=null,onEditorFocusConsumed:s,onSaved:b,onCompletenessChange:m}){const i=JSON.stringify((n==null?void 0:n.steps)??null),g=a.useRef(s);g.current=s;const[d,f]=a.useState(()=>te(n)),[w,j]=a.useState(()=>{const u=te(n)[0],v=u==null?void 0:u.variants[0];return u&&v?{stepId:u.id,variantId:v.id}:{stepId:"",variantId:""}});a.useEffect(()=>{const l=te(n);f(l);const u=l[0],v=u==null?void 0:u.variants[0];u&&v&&j({stepId:u.id,variantId:v.id})},[r,i,n]);const p=a.useRef(se(te(n))),L=a.useRef(!1);a.useEffect(()=>{const l=se(te(n));p.current=l,L.current=!1,t==null||t(!1)},[r,i]),a.useEffect(()=>{const u=se(d)!==p.current;u!==L.current&&(L.current=u,t==null||t(u)),m==null||m(st(d)&&!u)},[d,t,m]),a.useEffect(()=>{var h;const l=o;if(!l||l.token==null||l.stepId==null||l.variantId==null)return;const u=`step-${l.stepId}`,v=`var-${l.variantId}`,k=d.find(S=>S.id===u),c=(h=k==null?void 0:k.variants)==null?void 0:h.find(S=>S.id===v);if(!k||!c){queueMicrotask(()=>{var S;return(S=g.current)==null?void 0:S.call(g)});return}j({stepId:u,variantId:v}),queueMicrotask(()=>{var $;const S=typeof document<"u"?document.getElementById(`email-seq-variant-${v}`):null;S==null||S.scrollIntoView({behavior:"smooth",block:"nearest"}),($=g.current)==null||$.call(g)})},[o==null?void 0:o.token,o==null?void 0:o.stepId,o==null?void 0:o.variantId,d]);
2const[N,A]=a.useState(!1),[P,R]=a.useState(""),[O,F]=a.useState(()=>new Set),[_,T]=a.useState(null),[q,B]=a.useState(null),[G,Z]=a.useState(!1),W=a.useCallback((l,u)=>{f(v=>{const k=l+1;return k>=v.length?v:v.map((c,h)=>{if(h!==k)return c;const S=c.delayAfterPrevious??{value:1,unit:"days"};return{...c,delayAfterPrevious:{...S,...u}}})})},[]),Y=a.useCallback(async()=>{var u,v,k;if(!r){R("Missing campaign.");return}const l=[];for(const c of d)for(const h of c.variants)h.enabled!==!1&&String(h.subject??"").trim()===""&&l.push({stepId:c.id,variantId:h.id});if(l.length>0){F(new Set(l.map(c=>c.variantId))),j({stepId:l[0].stepId,variantId:l[0].variantId}),R("Enter a subject line for every enabled variant before saving.");return}F(c=>c.size===0?c:new Set),A(!0),R("");try{const c=await Re(r,{steps:d.map((h,S)=>{var de,ue,me,pe,fe;const $=S>0?String(((me=(ue=(de=d[S-1])==null?void 0:de.variants)==null?void 0:ue[0])==null?void 0:me.subject)??"").trim():"",V=ve(h.id);return{...V!=null?{id:V}:{},delay_after_previous_value:S===0?null:Math.max(1,Number(((pe=h.delayAfterPrevious)==null?void 0:pe.value)??1)||1),delay_after_previous_unit:S===0?null:((fe=h.delayAfterPrevious)==null?void 0:fe.unit)??"days",variants:h.variants.map(ee=>{const xe=ve(ee.id);return{...xe!=null?{id:xe}:{},label:ee.label,subject:String(ee.subject??"").trim()!==""?ee.subject:$,body:ee.body,enabled:ee.enabled}})}})});if(c!=null&&c.steps&&Array.isArray(c.steps)){const h=te(c);f(h),p.current=se(h),L.current=!1,t==null||t(!1);const S=h[0],$=S==null?void 0:S.variants[0];S&&$&&j({stepId:S.id,variantId:$.id})}_e.reload({only:["campaignSequences","activeCampaign","campaigns"],preserveScroll:!0,preserveState:!0}),Ie.success("Sequences saved. Variants are synced as send-ready templates.",{durationMs:2400}),b==null||b("sequences")}catch(c){const h=((v=(u=c==null?void 0:c.response)==null?void 0:u.data)==null?void 0:v.message)||(typeof((k=c==null?void 0:c.response)==null?void 0:k.data)=="string"?c.response.data:null)||(c==null?void 0:c.message)||"Could not save sequences.";R(typeof h=="string"?h:"Could not save sequences.")}finally{A(!1)}},[r,t,b,d]),D=a.useMemo(()=>{for(const v of d){const k=v.variants.find(c=>c.id===w.variantId&&v.id===w.stepId);if(k)return{step:v,variant:k}}const l=d[0],u=l==null?void 0:l.variants[0];return l&&u?{step:l,variant:u}:null},[d,w.stepId,w.variantId]),M=a.useCallback((l,u)=>{j({stepId:l,variantId:u})},[]),K=a.useCallback((l,u,v)=>{f(k=>k.map(c=>c.id!==l?c:{...c,variants:c.variants.map(h=>h.id===u?{...h,...v}:h)})),Object.prototype.hasOwnProperty.call(v,"subject")&&String(v.subject??"").trim()!==""&&F(k=>{if(!k.has(u))return k;const c=new Set(k);return c.delete(u),c})},[]),Q=a.useCallback(()=>{let l=null,u=null;f(v=>{var $,V;const k=v[v.length-1],c=String(((V=($=k==null?void 0:k.variants)==null?void 0:$[0])==null?void 0:V.subject)??"").trim(),h=ie("step"),S=ie("var");return l=h,u=S,[...v,{id:h,delayAfterPrevious:{value:1,unit:"days"},variants:[{id:S,label:"A",subject:c,enabled:!0,body:""}]}]}),queueMicrotask(()=>{!l||!u||j({stepId:l,variantId:u})})},[]),ne=a.useCallback(l=>{let u=null;f(v=>v.map(k=>{if(k.id!==l)return k;const c=k.variants.length,h=at(c),S={id:ie("var"),label:h,subject:"",enabled:!0,body:""};return u=S.id,{...k,variants:[...k.variants,S]}})),queueMicrotask(()=>{u&&j({stepId:l,variantId:u})})},[]),X=a.useCallback((l,u)=>{f(v=>{var $;const k=v.find(V=>V.id===l);if(!k||k.variants.length<=1)return v;const c=k.variants.filter(V=>V.id!==u),h=($=c[0])==null?void 0:$.id,S=v.map(V=>V.id===l?{...V,variants:c}:V);return queueMicrotask(()=>{j(V=>V.stepId===l&&V.variantId===u&&h?{stepId:l,variantId:h}:V)}),S})},[]),C=a.useCallback((l,u,v)=>{T({stepId:l,variantId:u,label:v||"this variant"})},[]),E=a.useCallback(()=>{T(null)},[]),I=a.useCallback(()=>{_&&(X(_.stepId,_.variantId),T(null))},[_,X]),y=a.useCallback(l=>{f(u=>{if(u.length<=1)return u;const k=u.filter(c=>c.id!==l).map((c,h)=>h===0?{id:c.id,variants:c.variants}:{...c,delayAfterPrevious:c.delayAfterPrevious??{value:1,unit:"days"}});return queueMicrotask(()=>{j(c=>{if(c.stepId!==l)return c;const h=k[0];return h!=null&&h.variants[0]?{stepId:h.id,variantId:h.variants[0].id}:c})}),k})},[]),z=a.useCallback((l,u)=>{B({stepId:l,stepNumber:u})},[]),x=a.useCallback(()=>{B(null)},[]),H=a.useCallback(()=>{q&&(y(q.stepId),B(null))},[q,y]),ae=a.useCallback(l=>{!l||!D||K(D.step.id,D.variant.id,{body:nt(D.variant.body,l)})},[D,K]),U=a.useCallback(l=>l.subject.trim()?l.subject:"<Empty subject>",[]),ze=a.useCallback(l=>O.has(l),[O]);return{steps:d,selection:w,selected:D,saveLoading:N,saveError:P,invali
2dSubjectIds:O,isSubjectInvalid:ze,variantDeleteTarget:_,stepDeleteTarget:q,previewOpen:G,setPreviewOpen:Z,patchFollowingStepDelay:W,saveSequences:Y,selectVariant:M,patchVariant:K,addStep:Q,addVariant:ne,requestRemoveVariant:C,closeVariantDeleteModal:E,confirmRemoveVariant:I,requestRemoveStep:z,closeStepDeleteModal:x,confirmRemoveStep:H,insertVariableIntoBody:ae,subjectDisplay:U}}function ke({tooltip:r,className:n="",children:t}){const[o,s]=a.useState(!1),{anchorRef:b,popoverRef:m,pos:i}=$e({open:o,tooltip:r}),g=oe.Children.only(t),d=oe.isValidElement(g)?oe.cloneElement(g,{onClick:w=>{typeof g.props.onClick=="function"&&g.props.onClick(w),s(!1)}}):g,f=e.jsx("div",{ref:m,role:"tooltip",style:{top:i.top,left:i.left},className:"pointer-events-none fixed z-10000 w-[min(19rem,calc(100vw-2rem))]",children:e.jsxs("div",{className:"relative rounded-lg border border-zinc-200 bg-white px-4 py-3 shadow-[0_4px_24px_-4px_rgba(0,0,0,0.08),0_2px_8px_-2px_rgba(0,0,0,0.04)] dark:border-zinc-600 dark:bg-zinc-800 dark:shadow-[0_4px_24px_-4px_rgba(0,0,0,0.35)]",children:[e.jsx("p",{className:"text-left text-[13px] leading-relaxed text-zinc-600 dark:text-zinc-300",children:r}),i.placement==="top"?e.jsx("span",{"aria-hidden":!0,className:"absolute left-1/2 top-full -mt-px -translate-x-1/2 border-x-[9px] border-x-transparent border-t-[9px] border-t-white dark:border-t-zinc-800"}):e.jsx("span",{"aria-hidden":!0,className:"absolute bottom-full left-1/2 -mb-px -translate-x-1/2 border-x-[9px] border-x-transparent border-b-[9px] border-b-white dark:border-b-zinc-800"})]})});return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:b,className:["relative w-full",n].filter(Boolean).join(" "),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:d}),o&&typeof document<"u"?we.createPortal(f,document.body):null]})}function J({onClick:r,active:n,title:t,children:o}){return e.jsxs("button",{type:"button",onClick:r,className:`group relative cursor-pointer rounded p-1.5 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-200 dark:hover:bg-zinc-700 hover:text-zinc-900 dark:hover:text-zinc-100 ${n?"bg-zinc-200 dark:bg-zinc-700 text-zinc-900 dark:text-zinc-100":""}`,"aria-label":t,children:[o,e.jsx("span",{className:"pointer-events-none absolute left-1/2 top-full z-300 mt-2 w-max -translate-x-1/2 rounded-md bg-zinc-900 px-2 py-1 text-xs font-medium text-white opacity-0 shadow-sm transition-opacity group-hover:opacity-100 dark:bg-zinc-950",children:t})]})}function lt({value:r="",onChange:n,placeholder:t,rightSlot:o=null}){const s=a.useMemo(()=>r==null?"":String(r),[r]),b=a.useRef(s),m=a.useRef(!1),i=Se({extensions:[Ne,Le,Ce.configure({types:["paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Me.configure({placeholder:t}),Ae.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}})],content:s||"",editorProps:{attributes:{class:"min-h-[180px] outline-none text-zinc-900 dark:text-zinc-100 text-sm p-3"}},onUpdate:({editor:N})=>{if(m.current)return;const A=N.getHTML();b.current=A,n==null||n(A)},immediatelyRender:!1}),{linkModalOpen:g,linkUrl:d,setLinkUrl:f,linkError:w,openLinkModal:j,closeLinkModal:p,confirmLinkModal:L}=De({editor:i});return a.useEffect(()=>{if(!i||m.current)return;const N=s||"";N!==b.current&&(m.current=!0,i.commands.setContent(N,!1),m.current=!1,b.current=N)},[i,s]),i?e.jsxs(e.Fragment,{children:[e.jsx(le,{open:g,title:"Insert link",message:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-zinc-700 dark:text-zinc-300",children:"URL"}),e.jsx("input",{type:"text",value:d,onChange:N=>f(N.target.value),className:"w-full rounded-lg border border-zinc-300 bg-white px-3 py-2.5 text-sm text-zinc-900 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20 dark:border-zinc-600 dark:bg-zinc-900 dark:text-zinc-100",placeholder:"https://example.com",autoFocus:!0})]}),w?e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:w}):null,e.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Tip: select text first to link it; otherwise the URL is inserted and linked."})]}),confirmLabel:"Insert link",cancelLabel:"Cancel",variant:"primary",onConfirm:L,onClose:p}),e.jsxs("div",{className:"flex min-h-[220px] flex-1 flex-col overflow-hidden rounded-lg border border-zinc-300 bg-white dark:border-zinc-600 dark:bg-zinc-800",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex shrink-0 flex-row flex-wrap items-center justify-between gap-2 border-b border-zinc-200 bg-zinc-50 p-1 dark:border-zinc-600 dark:bg-zinc-800/80",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5",children:[e.jsx(J,{onClick:()=>i.chain().focus().toggleBold().run(),active:i.isActive("bold"),title:"Bold",children:e.jsx("span",{className:"font-bold",children:"B"})}),e.jsx(J,{onClick:()=>i.chain().focus().toggleItalic().run(),active:i.isActive("italic"),title:"Italic",children:e.jsx("span",{className:"italic",children:"I"})}),e.jsx(J,{onClick:()=>i.chain().focus().toggleUnderline().run(),active:i.isActive("underline"),title:"Underline",children:e.jsx("span",{className:"underline",children:"U"})}),e.jsx("div",{className:"mx-0.5 h-5 w-px bg-zinc-200 dark:bg-zinc-600"}),e.jsx(J,{onClick:()=>i.chain().focus().toggleBulletList().run(),active:i.isActive("bulletList"),title:"Bullet list",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,
2children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 6h13M8 12h13M8 18h13M4 6h.01M4 12h.01M4 18h.01"})})}),e.jsx(J,{onClick:()=>i.chain().focus().toggleOrderedList().run(),active:i.isActive("orderedList"),title:"Numbered list",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 6h13M8 12h13M8 18h13M3 7h1m-1 5h1m-1 6h1m0-12h1v2H3m0 10h2"})})}),e.jsx("div",{className:"mx-0.5 h-5 w-px bg-zinc-200 dark:bg-zinc-600"}),e.jsx(J,{onClick:j,active:i.isActive("link"),title:"Link",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}),e.jsx("div",{className:"mx-0.5 h-5 w-px bg-zinc-200 dark:bg-zinc-600"}),e.jsx(J,{onClick:()=>i.chain().focus().setTextAlign("left").run(),active:i.isActive({textAlign:"left"}),title:"Align left",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h10M4 14h16M4 18h10"})})}),e.jsx(J,{onClick:()=>i.chain().focus().setTextAlign("center").run(),active:i.isActive({textAlign:"center"}),title:"Align center",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M7 10h10M4 14h16M7 18h10"})})}),e.jsx(J,{onClick:()=>i.chain().focus().setTextAlign("right").run(),active:i.isActive({textAlign:"right"}),title:"Align right",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M10 10h10M4 14h16M10 18h10"})})})]}),o?e.jsx("div",{className:"flex items-center gap-2 pr-1",children:o}):null]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-y-contain [scrollbar-gutter:stable]",children:e.jsx(Ee,{editor:i})}),e.jsx("style",{children:` 3 /* Tailwind reset removes list markers; restore them for ProseMirror content. */ 4 .ProseMirror p { margin: 0.25em 0; } 5 .ProseMirror p:first-child { margin-top: 0; } 6 .ProseMirror ul { list-style-type: disc; padding-left: 1.5rem; margin: 0.25em 0; } 7 .ProseMirror ol { list-style-type: decimal; padding-left: 1.5rem; margin: 0.25em 0; } 8 .ProseMirror li { margin: 0.1em 0; } 9 .ProseMirror a { color: #155DFC; text-decoration: underline; cursor: pointer; } 10 .dark .ProseMirror a { color: #60a5fa; } 11 `})]})]}):e.jsx("div",{className:"rounded-lg border border-zinc-300 bg-white dark:border-zinc-600 dark:bg-zinc-800",children:e.jsx("div",{className:"min-h-[220px] p-3 text-sm text-zinc-500 dark:text-zinc-400",children:t})})}function ct({checked:r,onChange:n,ariaLabel:t}){return e.jsx("button",{type:"button",role:"switch","aria-checked":r,"aria-label":t,onClick:()=>n(!r),className:["relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-violet-500 focus:ring-offset-2 dark:focus:ring-offset-zinc-900",r?"bg-linear-to-r from-[#155DFC] to-[#9810FA]":"bg-zinc-200 dark:bg-zinc-600"].join(" "),children:e.jsx("span",{className:["pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition",r?"translate-x-5":"translate-x-0.5"].join(" ")})})}function dt({onInsert:r,disabled:n=!1}){const{open:t,setOpen:o,wrapRef:s,triggerRef:b,listRef:m,placement:i,toggleOpen:g}=qe();return e.jsxs("div",{className:"relative shrink-0",ref:s,children:[e.jsxs("button",{ref:b,type:"button",disabled:n,onClick:()=>g(n),className:[Ze,n?"cursor-not-allowed opacity-50":""].join(" "),"aria-expanded":t,"aria-haspopup":"listbox","aria-label":"Insert variables",children:[e.jsx("span",{className:"text-brand-gradient block truncate pr-1 font-semibold",children:"Insert variables"}),e.jsx("span",{className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 text-zinc-500 dark:text-zinc-400",children:t?e.jsx(Te,{className:"h-5 w-5"}):e.jsx(Ve,{className:"h-5 w-5"})})]}),t&&i&&typeof document<"u"&&we.createPortal(e.jsx("ul",{ref:m,role:"listbox","aria-label":"Variables",className:Xe,style:{position:"fixed",zIndex:300,top:i.top,left
11:i.left,width:i.width,maxHeight:i.maxHeight,overscrollBehavior:"contain"},children:Ye.map(d=>e.jsx("li",{role:"option",onClick:()=>{r(d.token),o(!1)},className:et,children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5",children:[e.jsx("span",{className:["inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide",d.context==="Sender"?"bg-violet-100 text-violet-700 dark:bg-violet-900/35 dark:text-violet-200":"bg-sky-100 text-sky-700 dark:bg-sky-900/35 dark:text-sky-200"].join(" "),children:d.context}),e.jsx("span",{className:"font-semibold text-zinc-900 dark:text-zinc-100",children:d.title}),e.jsx("span",{className:"min-w-0 break-all font-mono text-sm font-normal text-zinc-500 dark:text-zinc-400",children:d.token})]})},d.token))}),document.body)]})}function ut({open:r,onClose:n,subject:t="",html:o="",campaignId:s,stepSortOrder:b,mailConnections:m=[],manualLeads:i=[],canTestSend:g=!1}){const{previewRef:d,sendMailbox:f,setSendMailbox:w,leadPickerOpen:j,setLeadPickerOpen:p,leadSearch:L,setLeadSearch:N,selectedLeadIds:A,variableValues:P,setVariableValues:R,sending:O,sendMessage:F,detectedVariables:_,renderedSubject:T,previewHtml:q,mailboxOptions:B,filteredLeads:G,stepReady:Z,canSend:W,toggleLead:Y,sendTest:D}=tt({open:r,subject:t,html:o,campaignId:s,stepSortOrder:b,mailConnections:m,manualLeads:i,canTestSend:g});return r?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-6 sm:p-8",role:"presentation",children:[e.jsx("div",{className:"fixed inset-0 bg-zinc-900/60 dark:bg-zinc-950/70","aria-hidden":!0}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"campaign-variant-preview-title",className:"relative z-10 flex h-[calc(100vh-3rem)] w-[calc(100vw-3rem)] max-w-6xl flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white p-6 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900 sm:h-[calc(100vh-4rem)] sm:w-[calc(100vw-4rem)]",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"h-5 w-5 text-zinc-500 dark:text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("h2",{id:"campaign-variant-preview-title",className:"text-lg font-semibold text-zinc-900 dark:text-zinc-100",children:"Email Preview"})]}),e.jsx("button",{type:"button",onClick:n,className:"cursor-pointer rounded-md p-1 text-zinc-500 transition hover:bg-zinc-100 hover:text-zinc-800 dark:hover:bg-zinc-800 dark:hover:text-zinc-200","aria-label":"Close",children:e.jsx(Fe,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"mt-5 grid min-h-0 flex-1 grid-cols-1 gap-6 lg:grid-cols-[340px_minmax(0,1fr)] lg:items-start",children:[e.jsxs("aside",{className:"min-h-0 space-y-4 overflow-y-auto rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900/60",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-zinc-700 dark:text-zinc-200",children:[e.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M22 2L11 13"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M22 2l-7 20-4-9-9-4z"})]}),"Send test (this sequence step)"]}),Z?null:e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Save your sequence first so this step exists on the server. Then you can send a real test to selected leads."}),e.jsx("div",{children:e.jsx(ye,{value:f,options:B,onChange:w,label:"Send from:",placeholder:"Selectâ¦",variant:"light"})}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-semibold text-zinc-600 dark:text-zinc-300",children:"Load data for lead"}),e.jsxs("button",{type:"button",onClick:()=>p(M=>!M),className:"flex w-full items-center justify-between rounded-lg border border-zinc-200 bg-white px-3 py-2 text-sm text-zinc-700 transition hover:border-zinc-300 dark:border-zinc-600 dark:bg-zinc-950 dark:text-zinc-200",children:[e.jsx("span",{children:A.size>0?`${A.size} lead(s) selected`:"Enter email address"}),j?e.jsx(Oe,{className:"h-4 w-4 text-zinc-400"}):e.jsx(Be,{className:"h-4 w-4 text-zinc-400"})]}),j?e.jsxs("div",{className:"mt-2 rounded-lg border border-zinc-100 p-2 dark:border-zinc-800",children:[e.jsx("input",{type:"search",value:L,onChange:M=>N(M.target.value),placeholder:"Search name or emailâ¦",className:"w-full rounded-lg border border-zinc-200 bg-white px-3 py-2 text-sm text-zinc-900 placeholder:text-zinc-400 focus:border-violet-500 focus:outline-none focus:ring-1 focus:ring-violet-500 dark:border-zinc-600 dark:bg-zinc-950 dark:text-zinc-100"}),e.jsx("div",{className:"mt-2 max-h-44 space-y-1 overflow-y-auto",children:G.length===0?e.jsx("p",{className:"px-1 py-2 text-xs text-zinc-500 dark:text-zinc-400",children:"No leads match. My Leads need an email address."}):G.map(M=>e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-zinc-50 dark:hover:bg-zinc-800/80",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 rounded border-zinc-300 text-violet-600 focus:ring-violet-500 dark:border-zinc-600",checked:A.has(M.id),onChange:()=>Y(M.id)}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium text-zinc-900 dark:text-zinc-100",children:M.email}),M.name?e.jsx("span",{className:"text-zinc-500 dark:text-zinc-400",children:M.name}):null]})]},M.id))})]}):null]}),_.length>0?e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-semibold text-zinc-600 dark:text-zinc-300",children:"Variables"}),e.jsx("div",{className:"max-h-56 space-y-2 overflow-y-auto rounded-lg border border-zinc-100 p-2 dark:border-zinc-800",children:_.map(M=>e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[11px] font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400",children:M}),e.jsx("input",{type:"text",value:P[M]??"",onChange:K=>
11R(Q=>({...Q,[M]:K.target.value})),placeholder:"Enter variable value",className:"w-full rounded-lg border border-zinc-200 bg-white px-3 py-2 text-sm text-zinc-900 placeholder:text-zinc-400 focus:border-violet-500 focus:outline-none focus:ring-1 focus:ring-violet-500 dark:border-zinc-600 dark:bg-zinc-950 dark:text-zinc-100"})]},M))})]}):null]}),e.jsxs("section",{className:"min-h-0 space-y-4 overflow-y-auto rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900/60",children:[e.jsx("div",{className:"space-y-2 text-sm text-zinc-600 dark:text-zinc-300",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Subject:"})," ",e.jsx("span",{className:"text-zinc-900 dark:text-zinc-100",children:T||"â"})]})}),F?e.jsx("p",{className:F.type==="ok"?"rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-900 dark:border-emerald-900/40 dark:bg-emerald-950/30 dark:text-emerald-200":"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/35 dark:text-red-200",role:"status",children:F.text}):null,e.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-white p-4 dark:border-zinc-700 dark:bg-white",children:[e.jsx("div",{ref:d,className:"campaign-email-preview prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:q||'<p class="text-zinc-500">(Empty body)</p>'}}),e.jsx("style",{children:` 12 .campaign-email-preview { color: #111827 !important; } 13 .campaign-email-preview p, 14 .campaign-email-preview div, 15 .campaign-email-preview span, 16 .campaign-email-preview li, 17 .campaign-email-preview td, 18 .campaign-email-preview th, 19 .campaign-email-preview h1, 20 .campaign-email-preview h2, 21 .campaign-email-preview h3, 22 .campaign-email-preview h4, 23 .campaign-email-preview h5, 24 .campaign-email-preview h6 { color: #111827 !important; } 25 .campaign-email-preview * { border-color: currentColor; } 26 .campaign-email-preview a { color: #155DFC !important; text-decoration: underline; cursor: pointer; } 27 .campaign-email-preview ul { list-style-type: disc; padding-left: 1.5rem; } 28 .campaign-email-preview ol { list-style-type: decimal; padding-left: 1.5rem; } 29 html.dark .campaign-email-preview, 30 .dark .campaign-email-preview, 31 [data-theme="dark"] .campaign-email-preview { color: #e5e7eb !important; } 32 html.dark .campaign-email-preview *, 33 .dark .campaign-email-preview *, 34 [data-theme="dark"] .campaign-email-preview * { color: #e5e7eb !important; } 35 html.dark .campaign-email-preview p, 36 html.dark .campaign-email-preview div, 37 html.dark .campaign-email-preview span, 38 html.dark .campaign-email-preview li, 39 html.dark .campaign-email-preview td, 40 html.dark .campaign-email-preview th, 41 html.dark .campaign-email-preview h1, 42 html.dark .campaign-email-preview h2, 43 html.dark .campaign-email-preview h3, 44 html.dark .campaign-email-preview h4, 45 html.dark .campaign-email-preview h5, 46 html.dark .campaign-email-preview h6, 47 .dark .campaign-email-preview p, 48 .dark .campaign-email-preview div, 49 .dark .campaign-email-preview span, 50 .dark .campaign-email-preview li, 51 .dark .campaign-email-preview td, 52 .dark .campaign-email-preview th, 53 .dark .campaign-email-preview h1, 54 .dark .campaign-email-preview h2, 55 .dark .campaign-email-preview h3, 56 .dark .campaign-email-preview h4, 57 .dark .campaign-email-preview h5, 58 .dark .campaign-email-preview h6, 59 [data-theme="dark"] .campaign-email-preview p, 60 [data-theme="dark"] .campaign-email-preview div, 61 [data-theme="dark"] .campaign-email-preview span, 62 [data-theme="dark"] .campaign-email-preview li, 63 [data-theme="dark"] .campaign-email-preview td, 64 [data-theme="dark"] .campaign-email-preview th, 65 [data-theme="dark"] .campaign-email-preview h1, 66 [data-theme="dark"] .campaign-email-preview h2, 67 [data-theme="dark"] .campaign-email-preview h3, 68 [data-theme="dark"] .campaign-email-preview h4, 69 [data-theme="dark"] .campaign-email-preview h5, 70 [data-theme="dark"] .campaign-email-preview h6 { color: #e5e7eb !important; } 71 html.dark .campaign-email-preview a, 72 .dark .campaign-email-preview a, 73 [data-theme="dark"] .campaign-email-preview a { color: #60a5fa !important; } 74 `})]}),g?null:e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400/90",children:"Test sends are only available during the campaign's scheduled window."}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:n,className:"cursor-pointer rounded-lg border border-zinc-300 bg-white px-4 py-2 text-sm font-semibold text-zinc-700 shadow-sm transition hover:bg-zinc-50 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700",children:"Close"}),e.jsx("button",{type:"button",disabled:!W||O,onClick:D,className:["inline-flex items-center rounded-lg px-4 py-2 text-sm font-semibold text-white shadow-sm transition btn-primary-gradient",!W||O?"cursor-not-allowed opacity-50":"hover:opacity-90"].join(" "),children:O?"Sendingâ¦":"Send test"})]})]})]})]})]}):null}function mt({campaignId:r,initialSequences:n,mailConnections:t=[],emailAudience:o=null,canTestSend:s=!1,onDirtyChange:b,editorFocusRequest:m=null,onEditorFocusConsumed:i,onSaved:g,onCompletenessChange:d}){var C,E,I;const f=ot({campaignId:r,initialSequences:n,onDirtyChange:b,editorFocusRequest:m,onEditorFocusConsumed:i,onSaved:g,onCompletenessChange:d}),{steps:w,selection:j,selected:p,saveLoading:L,saveError:N,isSubjectInvalid:A,variantDeleteTarget:P,stepDeleteTarget:R,previewOpen:O,setPreviewOpen:F,patchFollowingStepDelay:_,saveSequences:T,selectVariant:q,patchVariant:B,addStep:G,addVariant:Z,requestRemoveVariant:W,closeVariantDeleteModal:Y,confirmRemoveVariant:D,requestRemoveStep:M,closeStepDeleteModal:K,confirmRemoveStep:Q,insertVariableIntoBody:ne,subjectDisplay:X}=f;return e.jsxs(e.Fragment,{children:[e.jsx(ut,{open:O,onClose:()=>F(!1),subject:((C=p==null?void 0:p.variant)==null?void 0:C.subject)??"",html:((E=p==null?void 0:p.variant)==null?void 0:E.body)??"",campaignId:r,stepSortOrder:(I=p==null?void 0:p.step)==null?void 0:I.sortOrder,mailConnections:t,manualLeads:(o==null?void 0:o.manualLeads)??[],canTestSend:s}),e.jsx(le,{open:P!=null,title:"Delete variant?",message:e.jsxs("p",{className:"text-sm text-zinc-600 dark:text-zinc-300",children:["Remove variant ",e.jsx("strong",{className:"text-zinc-900 dark:text-zinc-100",children:P==null?void 0:P.label})," from this step? This cannot be undone after you save the sequence."]}),confirmLabel:"Delete variant",cancelLabel:"Cancel",variant:"danger",onConfirm:D,onClose:Y}),e.jsx(le,{open:R!=null,title:"Delete step?",message:e.jsxs("p",{className:"text-sm text-zinc-600 dark:text-zinc-300",children:["Remove ",e.jsxs("strong",{className:"text-zinc-900 dark:text-zinc-100",children:["Step ",R==null?void 0:R.stepNumber]})," and all of its variants? This cannot be undone after you save the sequence."]}),confirmLabel:"Delete step",cancelLabel:"Cancel",variant:"danger",onConfirm:Q,onClose:K}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(260px,320px)_1fr] lg:items-stretch",children:[e.jsxs("div",{className:"flex min-h-[480px] max-h-[min(70vh,720px)] flex-col gap-4 overflow-y-auto pr-1",children:[w.map((y,z)=>e.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900/90",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsxs("h3",{className:"text-sm font-bold text-zinc-900 dark:text-zinc-100",children:["Step ",z+1]}),w.length>1?e.jsx("button",{type:"button",onClick:()=>M(y.id,z+1),className:"cursor-pointer rounded p-1 text-zinc-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/40 dark:hover:text-red-400","aria-label":`Remove step ${z+1}`,children:e.jsx(be,{})}):null]}),e.jsx("div",{className:"space-y-3",children:y.variants.map(x=>{const H=j.stepId===y.id&&j.variantId===x.id,ae=!(w.length===1&&y.variants.length===1);return e.jsxs("div",{id:`email-seq-variant-${x.id}`,className:["flex cursor-pointer items-center gap-2 rounded-lg border p-2 transition",H?"border-sky-400 bg-sky-50/80 dark:border-sky-600 dark:bg-sky-950/30":"border-zinc-100 bg-zinc-50/80 dark:border-zinc-700 dark:bg-zinc-800/50"].join(" "),onClick:()=>q(y.id,x.id),onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),q(y.id,x.id))},role:"button",tabIndex:0,children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-r from-[#2B7FFF] to-[#AD46FF] p-px",children:e.jsx("span",{className:"flex h-full w-full items-center justify-center rounded-full bg-white text-xs font-bold dark:bg-zinc-900",children:e.jsx("span",{className:"bg-gradient-to-r from-[#2B7FFF] to-[#AD46FF] bg-clip-text text-transparent",children:x.label})})}),e.jsx("span",{className:["min-w-0 flex-1 truncate text-xs",A(x.id)?"font-medium text-red-600 dark:text-red-400":"text-zinc-500 dark:text-zinc-400"].join(" "),children:A(x.id)?"Subject required":X(x)}),ae?e.jsx("div",{onClick:U=>U.stopPropagation(),children:e.jsx(ct,{checked:x.enabled,onChange:U=>B(y.id,x.id,{enabled:U}),ariaLabel:`Variant ${x.label} enabled`})}):e.jsx("span",{className:"w-11 shrink-0","aria-hidden":!0}),y.variants.length>1?e.jsx("button",{type:"button",onClick:U=>{U.stopPropagation(),W(y.id,x.id,x.label)},className:"shrink-0 cursor-pointer rounded p-1 text-zinc-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/40 dark:hover:text-red-400","aria-label":`Remove variant ${x.label}`,children:e.jsx(be,{})}):e.jsx("span",{className:"w-7 shrink-0","aria-hidden":!0})]},x.id)})}),e.jsx(ke,{className:"mt-3",tooltip:Qe,children:e.jsx("button",{type:"button",onClick:()=>Z(y.id),className:"w-full cursor-pointer rounded-lg border-2 border-dotted border-transparent bg-origin-border py-2 text-sm font-semibold transition hover:opacity-90 [background-clip:padding-box,border-box] [background-image:linear-gradient(#fff,#fff),linear-gradient(to_right,#2B7FFF,#AD46FF)] dark:[background-image:linear-gradient(#18181b,#18181b),linear-gradient(to_right,#2B7FFF,#AD46FF)]",children:e.jsx("span",{className:"bg-gradient-to-r from-[#2B7FFF] to-[#AD46FF] bg-clip-text text-transparent",children:"+ Add Variant"})})}),z<w.length-1?e.jsxs("div",{className:"mt-4 flex flex-row flex-wrap items-center gap-x-2 gap-y-2 border-t border-zinc-100 pt-4 dark:border-zinc-800",children:[e.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-200",children:"Send next message in"}),e.jsx("input",{type:"number",inputMode:"numeric",min:1,max:999999,value:(w[z+1].delayAfterPrevious??{value:1}).value,onFocus:x=>{if((w[z+1].delayAfterPrevious??{value:1}).value===1){const ae=x.target;requestAnimationFrame(()=>{ae.select()})}},onChange:x=>{const H=parseInt(x.target.value,10);_(z,{value:Number.isFinite(H)&&H>=1?H:1})},onBlur:x=>{const H=parseInt(x.target.value,10);(!Number.isFinite(H)||H<1)&&_(z,{value:1})},className:"input-no-spinner w-16 shrink-0 rounded-md border border-zinc-300 bg-white px-2 py-2 text-center text-sm text-zinc-900 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20 dark:border-zinc-600 dark:bg-zinc-950 dark:text-zinc-100","aria-label":"Delay before step after this one is sent"}),e.jsx("div",{className:"min-w-30 shrink-0",children:e.jsx(ye,{value:(w[z+1].delayAfterPrevious??{unit:"days"}
74).unit,options:rt,onChange:x=>_(z,{unit:x}),variant:"light","aria-label":"Delay unit before next step",className:"w-30!"})})]}):null]},y.id)),e.jsx(ke,{tooltip:Je,children:e.jsx("button",{type:"button",onClick:G,className:"w-full cursor-pointer rounded-xl border-2 border-dotted border-transparent bg-origin-border py-3 text-sm font-semibold transition hover:opacity-90 [background-clip:padding-box,border-box] [background-image:linear-gradient(#fff,#fff),linear-gradient(to_right,#155DFC,#9810FA)] dark:[background-image:linear-gradient(#18181b,#18181b),linear-gradient(to_right,#155DFC,#9810FA)]",children:e.jsx("span",{className:"bg-gradient-to-r from-[#155DFC] to-[#9810FA] bg-clip-text text-transparent",children:"+ Add Step"})})})]}),e.jsx("div",{className:"flex min-h-[480px] max-h-[min(70vh,720px)] flex-col overflow-hidden rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900/90 sm:p-6",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("label",{htmlFor:"campaign-seq-subject",className:"mb-1.5 block text-sm font-bold text-zinc-900 dark:text-zinc-100",children:"Subject Line"}),e.jsx("input",{id:"campaign-seq-subject",type:"text",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,"aria-invalid":A(p.variant.id),value:p.variant.subject,onChange:y=>B(p.step.id,p.variant.id,{subject:y.target.value}),placeholder:"Enter a subject line",className:["w-full rounded-lg border bg-white px-3 py-2.5 text-sm text-zinc-900 placeholder:text-zinc-400 focus:outline-none focus:ring-2 dark:bg-zinc-800 dark:text-zinc-100 dark:placeholder:text-zinc-500",A(p.variant.id)?"border-red-400 focus:border-red-500 focus:ring-red-500/20 dark:border-red-500":"border-zinc-300 focus:border-sky-500 focus:ring-sky-500/20 dark:border-zinc-600"].join(" ")}),A(p.variant.id)?e.jsx("p",{className:"mt-1.5 text-xs font-medium text-red-600 dark:text-red-400",children:"A subject line is required before you can save this sequence."}):null]}),e.jsxs("div",{className:"mt-6 flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsx("span",{className:"mb-1.5 block shrink-0 text-sm font-bold text-zinc-900 dark:text-zinc-100",children:"Body"}),e.jsx(lt,{value:p.variant.body??"",onChange:y=>B(p.step.id,p.variant.id,{body:y}),placeholder:"Start typing your email content here⦠Insert variables like {{firstName}} or {{companyName}} to personalize your emails.",rightSlot:e.jsx(dt,{onInsert:ne})},`${p.step.id}-${p.variant.id}`)]}),e.jsxs("div",{className:"mt-6 flex shrink-0 flex-col gap-2 border-t border-zinc-100 pt-4 dark:border-zinc-800",children:[N?e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:N}):null,e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>F(!0),className:"inline-flex cursor-pointer items-center rounded-lg border border-zinc-300 bg-white px-4 py-2 text-sm font-semibold text-zinc-700 shadow-sm transition hover:bg-zinc-50 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700",children:"Preview"}),e.jsx("button",{type:"button",onClick:T,disabled:L||!r,className:"inline-flex cursor-pointer items-center rounded-lg px-5 py-2 text-sm font-semibold text-white shadow-sm transition btn-primary-gradient hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:L?"Savingâ¦":"Save"})]})]})]}):e.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:"Select a variant to edit."})})]})]})}function pt({campaignId:r,campaignSequences:n,mailConnections:t,emailAudience:o,canTestSend:s=!1,onDirtyChange:b,editorFocusRequest:m,onEditorFocusConsumed:i,onSaved:g,onCompletenessChange:d}){return e.jsx(mt,{campaignId:r,initialSequences:n,mailConnections:t,emailAudience:o,canTestSend:s,onDirtyChange:b,editorFocusRequest:m,onEditorFocusConsumed:i,onSaved:g,onCompletenessChange:d})}const br=a.memo(pt);export{br 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.