1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[258],{94900:function(e,t,a){a.d(t,{Z:function(){return l}});var s=a(62898);let l=(0,s.Z)("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]])},64411:function(e,t,a){a.d(t,{Z:function(){return l}});var s=a(62898);let l=(0,s.Z)("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]])},54258:function(e,t,a){a.d(t,{i:function(){return RexCampaignLauncherModal}});var s=a(57437),l=a(2265),n=a(91393),i=a(79303),r=a(64411),d=a(82549),o=a(86264),c=a(38438),m=a(62898);let u=(0,m.Z)("Video",[["path",{d:"m22 8-6 4 6 4V8Z",key:"50v9me"}],["rect",{width:"14",height:"12",x:"2",y:"6",rx:"2",ry:"2",key:"1rqjg6"}]]);var x=a(94900),p=a(62442),h=a(9883),g=a(46047);let b="All 50 States ( Recommended for best results)";function RexCampaignLauncherModal(e){let{open:t,brokerRecordId:a,brokerName:m,seed:f,onClose:y,onLaunched:v}=e,[j,k]=(0,l.useState)(!1),[N,w]=(0,l.useState)(null),[C,S]=(0,l.useState)([]),[Z,U]=(0,l.useState)(new Set),[I,R]=(0,l.useState)({}),[L,_]=(0,l.useState)(!0),[A,P]=(0,l.useState)(""),[T,q]=(0,l.useState)(20),[M,z]=(0,l.useState)([]),[B,E]=(0,l.useState)(!1),[F,V]=(0,l.useState)(null);(0,l.useEffect)(()=>{if(!t)return;U(new Set),R({}),V(null),E(!1),"number"==typeof f.dailyBudgetUsd&&f.dailyBudgetUsd>0&&q(f.dailyBudgetUsd);let e=(f.states||"").trim();e&&e!==b?(_(!1),P(e)):(_(!0),P(""));let a=(f.prescreenerQuestions||[]).map(e=>((null==e?void 0:e.label)||"").trim()).filter(Boolean);z(a)},[t,f.dailyBudgetUsd,f.states]),(0,l.useEffect)(()=>{if(!t)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[t]);let O=(0,l.useCallback)(async()=>{if(a){k(!0),w(null);try{var e,t,s;let[l,n]=await Promise.all([fetch("/api/ad-image-creation?brokerRecordId=".concat(encodeURIComponent(a)),{headers:(0,g.GY)(),cache:"no-store"}),fetch("/api/heygen/video-ads?brokerRecordId=".concat(encodeURIComponent(a)),{headers:(0,g.GY)(),cache:"no-store"})]),i=[];if(l.ok){let a=await l.json(),s=null!==(e=a.records)&&void 0!==e?e:[];for(let e of s){let a=e.fields["Headline Text"]||"";for(let s of["Image","Image 2"]){let l=e.fields[s],n=Array.isArray(l)?null===(t=l[0])||void 0===t?void 0:t.url:void 0;n&&i.push({key:"img:".concat(e.id,":").concat(s),type:"image",imageUrl:n,headline:a})}}}if(n.ok){let e=await n.json(),t=null!==(s=e.records)&&void 0!==s?s:[];for(let e of t){let t=e.fields.Status,a=e.fields["Video URL"],s={key:"vid:".concat(e.id),type:"video",videoAdId:e.id,thumbnailUrl:e.fields["Thumbnail URL"],title:e.fields.Title||"Video ad",headline:e.fields.Brief||e.fields.Title||""};"ready"===t&&a?i.push({...s,pending:!1}):("generating"===t||"queued"===t)&&i.push({...s,pending:!0})}}S(i),0===i.length&&w("You don't have any finished ads yet. Ask me to create an image or video ad first.")}catch(e){w("Could not load your ads. Try reopening the launcher.")}finally{k(!1)}}},[a]);(0,l.useEffect)(()=>{t&&O()},[t,O]);let toggle=e=>{U(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},Y=Z.size,G=C.some(e=>Z.has(e.key)&&"video"===e.type&&e.pending),$=L?b:A.trim(),D=Y>0&&T>0&&(L||A.trim().length>0)&&!B,launch=async()=>{if(!D)return;E(!0),V(null);let e=[],t=[];for(let a of C){var s,l;if(!Z.has(a.key))continue;let n=I[a.key];if("image"===a.type)e.push({imageUrl:a.imageUrl,headline:(null!==(s=null!=n?n:a.headline)&&void 0!==s?s:"").trim()});else{let e=(null!==(l=null!=n?n:a.headline)&&void 0!==l?l:"").trim();t.push({videoAdId:a.videoAdId,...e?{headline:e}:{}})}}try{let s=await fetch("/api/agent/launch-campaign",{method:"POST",headers:{"Content-Type":"application/json",...(0,g.GY)()},body:JSON.stringify({recordId:a,dailyBudgetUsd:T,states:$,adPath:f.adPath||void 0,calendarLink:f.calendarLink||void 0,statics:e,videos:t,prescreenerQuestions:M.map(e=>
1e.trim()).filter(Boolean).map(e=>({label:e}))})}),l=await s.json();if(!s.ok)throw Error((null==l?void 0:l.error)||"Launch failed â please try again.");"deferred"===l.status?v({deferred:!0,message:l.message}):v({jobId:String(l.jobId)})}catch(e){V(e.message)}finally{E(!1)}},H=(0,l.useMemo)(()=>0===Y?"Select ads to launch":G?"Launch when ready \xb7 $".concat(T,"/day"):"Launch ".concat(Y," ad").concat(1===Y?"":"s"," \xb7 $").concat(T,"/day"),[Y,T,G]);return(0,s.jsx)(n.M,{children:t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[60] bg-ink-900/35 backdrop-blur-sm",onClick:y}),(0,s.jsx)(i.E.div,{initial:{opacity:0,y:20,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:20,scale:.98},transition:{duration:.22,ease:"easeOut"},className:"fixed inset-0 z-[60] flex items-center justify-center p-3 sm:p-4",onClick:e=>e.target===e.currentTarget&&y(),children:(0,s.jsxs)("div",{className:"relative flex max-h-[92vh] w-full max-w-3xl flex-col overflow-hidden rounded-3xl border border-cream-edge bg-white text-ink-900 shadow-[0_40px_120px_-20px_rgba(99,102,241,0.3)]",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-cream-edge px-6 py-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-2 rounded-full border border-plum-300/60 bg-plum-500/10 px-3 py-1 text-[10px] font-semibold uppercase tracking-[0.22em] text-plum-700",children:[(0,s.jsx)(r.Z,{className:"h-3 w-3"}),"Launch a campaign"]}),f.adPath?(0,s.jsx)("span",{className:"hidden font-mono-data text-[10px] uppercase tracking-[0.2em] text-ink-900/45 sm:inline",children:f.adPath}):null]}),(0,s.jsx)("button",{onClick:y,"aria-label":"Close",className:"rounded-full p-2 text-ink-900/55 transition hover:bg-cream-warm hover:text-ink-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-plum-400",children:(0,s.jsx)(d.Z,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:[(0,s.jsxs)("h2",{className:"text-xl font-semibold tracking-tight text-ink-900 sm:text-2xl",children:[m?"".concat(m,", pick "):"Pick ","the ads to launch"]}),(0,s.jsx)("p",{className:"mt-1 text-sm text-ink-900/60",children:"Select any mix of image and video ads. I'll launch exactly what you choose â most brokers run 2â3."}),j?(0,s.jsxs)("div",{className:"mt-8 flex items-center justify-center gap-2 text-ink-900/55",children:[(0,s.jsx)(o.Z,{className:"h-4 w-4 animate-spin"})," Loading your adsâ¦"]}):N?(0,s.jsx)("div",{className:"mt-6 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800",children:N}):(0,s.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3 sm:grid-cols-3",children:C.map(e=>{var t;let a=Z.has(e.key);return(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>toggle(e.key),"aria-pressed":a,"data-testid":"launch-tile","data-asset-type":e.type,className:"group relative aspect-square overflow-hidden rounded-2xl border-2 bg-cream-warm text-left transition ".concat(a?"border-plum-400 shadow-[0_0_0_1px_rgba(168,85,247,0.35)]":"border-cream-edge hover:border-plum-200"),children:["video"===e.type&&e.pending?(0,s.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1.5 bg-gradient-to-br from-plum-100 to-cream-warm text-plum-700",children:[(0,s.jsx)(o.Z,{className:"h-5 w-5 animate-spin"}),(0,s.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em]",children:"Renderingâ¦"})]}):(0,s.jsx)("img",{src:"image"===e.type?e.imageUrl:e.thumbnailUrl,alt:"image"===e.type?e.headline:e.title,className:"h-full w-full object-cover"}),(0,s.jsx)("span",{className:"absolute left-2 top-2 inline-flex items-center gap-1 rounded-full bg-ink-900/70 px-2 py-0.5 text-[9px] font-semibold uppercase tracking-[0.16em] text-white backdrop-blur",children:"image"===e.type?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.Z,{className:"h-2.5 w-2.5"})," Image"]}):e.pending?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{className:"h-2.5 w-2.5 animate-spin"})," Rendering"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u,{className:"h-2.5 w-2.5"})," Video"]})}),"video"===e.type&&!e.pending&&(0,s.jsx)("span",{className:"pointer-events-none absolute inset-0 grid place-items-center",children:(0,s.jsx)("span",{className:"grid h-9 w-9 place-items-center rounded-full bg-white/85 text-ink-900 shadow",children:(0,s.jsx)(x.Z,{className:"h-4 w-4"})})}),(0,s.jsx)("span",{className:"absolute right-2 top-2 grid h-6 w-6 place-items-center rounded-full transition ".concat(a?"bg-plum-500 text-white":"bg-white/80 text-ink-900/40"),children:(0,s.jsx)(p.Z,{className:"h-3.5 w-3.5"})})]}),a&&(0,s.jsx)("textarea",{value:null!==(t=I[e.key])&&void 0!==t?t:e.headline,onChange:t=>R(a=>({...a,[e.key]:t.target.value})),rows:2,placeholder:"Primary textâ¦",className:"mt-2 w-full resize-none rounded-xl border border-cream-edge bg-white p-2 text-[12px] leading-snug text-ink-900 outline-none transition focus:border-plum-400"})]},e.key)})}),(0,s.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"rounded-2xl border border-cream-edge bg-cream-warm p-4",children:[(0,s.jsx)("label",{className:"mb-2 block text-[11px] font-semibold uppercase tracking-[0.22em] text-plum-700",children:"Daily budget (USD)"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-mono-data text-lg text-ink-900",children:"$"}),(0,s.jsx)("input",{type:"number",min:1,value:T,onChange:e=>q(Math.max(1,Number(e.target.value)||0)),className:"w-full rounded-xl border border-cream-edge bg-white p-2 font-mono-data text-sm text-ink-900 outline-none transition focus:border-plum-400"}),(0,s.jsx)("span",{className:"text-[11px] text-ink-900/55",children:"/day"})]})]}),(0,s.jsxs)("div",{className:"rounded-2xl border border-cream-edge bg-cream-warm p-4",children:[(0,s.jsx)("label",{className:"mb-2 block text-[11px] font-semibold uppercase tracking-[0.22em] text-plum-700",children:"Target states"}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm text-ink-900",children:[(0,s.jsx)("input",{type:"checkbox",checked:L,onChange:e=>_(e.target.checked),className:"h-4 w-4 accent-plum-500"}),"All 50 states (recommended)"]}),!L&&(0,s.jsx)("input",{type:"text",value:A,onChange:e=>P(e.target.value),placeholder:"e.g. California, Texas, Florida",className:"mt-2 w-full rounded-xl border border-cream-edge bg-white p-2 text-sm text-ink-900 outline-none transition focus:border-plum-400"})]})]}),(0,s.jsxs)("div",{className:"mt-4 rounded-2xl border border-cream-edge bg-cream-warm p-4",children:[(0,s.jsxs)("label",{className:"mb-1 block text-[11px] font-semibold uppercase tracking-[0.22em] text-plum-700",children:["Screening questions ",(0,s.jsx)("span",{className:"text-ink-900/40",children:"(optional)"})]}),(0,s.jsx)("p",{className:"mb-3 text-[11px] text-ink-900/55",children:"Asked on your lead form after name, email & phone. More questions = higher-intent leads, but fewer of them."}),M.length>0&&(0,s.jsx)("div",{className:"space-y-2",children:M.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"text",value:e,onCh
1ange:e=>z(a=>a.map((a,s)=>s===t?e.target.value:a)),placeholder:"e.g. What's your target loan amount?",className:"w-full rounded-xl border border-cream-edge bg-white p-2 text-sm text-ink-900 outline-none transition focus:border-plum-400"}),(0,s.jsx)("button",{type:"button","aria-label":"Remove question",onClick:()=>z(e=>e.filter((e,a)=>a!==t)),className:"rounded-full p-1.5 text-ink-900/40 transition hover:bg-rose-50 hover:text-rose-500",children:(0,s.jsx)(d.Z,{className:"h-4 w-4"})})]},t))}),M.length<3?(0,s.jsxs)("button",{type:"button",onClick:()=>z(e=>[...e,""]),className:"mt-2 inline-flex items-center gap-1.5 rounded-full border border-plum-200 px-3 py-1.5 text-[12px] font-semibold text-plum-700 transition hover:bg-plum-50",children:[(0,s.jsx)(h.Z,{className:"h-3.5 w-3.5"})," Add a question"]}):(0,s.jsx)("p",{className:"mt-2 text-[11px] text-amber-600",children:"3 is a good max â more questions sharply cuts lead volume."})]}),G&&(0,s.jsxs)("div",{className:"mt-4 flex items-start gap-2 rounded-xl border border-plum-200 bg-plum-50 p-3 text-sm text-plum-800",children:[(0,s.jsx)(o.Z,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin"}),(0,s.jsx)("span",{children:"One of your selected videos is still rendering. I'll hold this campaign and launch it automatically the moment the render finishes â no need to come back."})]}),F&&(0,s.jsx)("div",{className:"mt-4 rounded-xl border border-rose-200 bg-rose-50 p-3 text-sm text-rose-700",children:F})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between border-t border-cream-edge px-6 py-4",children:[(0,s.jsxs)("span",{className:"font-mono-data text-[11px] uppercase tracking-[0.18em] text-ink-900/55",children:[(0,s.jsx)("span",{className:"num-tabular text-ink-900",children:Y})," ","selected"]}),(0,s.jsxs)("button",{type:"button",onClick:launch,disabled:!D,"data-testid":"launch-submit",className:"group relative inline-flex items-center overflow-hidden rounded-full cta-gradient px-7 py-3 text-sm font-semibold text-white transition hover:opacity-95 disabled:cursor-not-allowed disabled:opacity-40",children:[(0,s.jsx)("span",{className:"relative z-10 inline-flex items-center gap-2",children:B?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{className:"h-4 w-4 animate-spin"})," Launchingâ¦"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Z,{className:"h-4 w-4"})," ",H]})}),(0,s.jsx)("span",{className:"cta-shimmer-overlay","aria-hidden":!0})]})]})]})})]})})}}}]);
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.