PageSourceSearch

https://www.fusionsales.ai/mission-control/assets/AppGate-C_5HQc6h.js

js fusionsales.ai collected 2026-10-05 15:18:47 UTC 209,400 bytes, 217 lines download raw bytes

1var yt=Object.defineProperty;var vt=(s,t,a)=>t in s?yt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var As=(s,t,a)=>vt(s,typeof t!="symbol"?t+"":t,a);import{r as l,j as e}from"./index-Dbasalh1.js";import{s as je,a as zs,M as ys,R as Bs,C as Nt,b as C,r as wt,c as kt,d as Ct,e as We,p as vs,n as Ns,f as ue,g as us,D as St,A as bs,h as ws,i as ls,F as _t,E as $t,V as At,w as Et,O as Lt,j as It}from"./store-DWHTlA-T.js";import{c as D,u as Fs,O as Mt,X as ce,k as Rt,h as K,l as Re,S as is,a as rs,A as ze,e as me,T as Es,M as Ls,b as Pt,g as we,C as Dt,m as Hs,j as Gs,U as Tt,n as qt,f as Ot,B as zt,R as Bt,i as de,N as Ft}from"./Logo-Bpok_oyQ.js";import{L as G,P as ds,M as Be,c as ks,r as he,u as se,a as _e,b as Ws,d as Us,e as te,G as Vs,C as Ks,f as Ht,s as Gt,g as Ys,T as Wt,I as Ut}from"./Intake-rwaBYIYZ.js";import"./quoteDoc-DAQq_sWT.js";/**
2 * @license lucide-react v0.469.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Vt=D("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
7 * @license lucide-react v0.469.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Qs=D("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
12 * @license lucide-react v0.469.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Cs=D("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
17 * @license lucide-react v0.469.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Zs=D("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
22 * @license lucide-react v0.469.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Kt=D("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/**
27 * @license lucide-react v0.469.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const Xs=D("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
32 * @license lucide-react v0.469.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const Js=D("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
37 * @license lucide-react v0.469.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Is=D("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/**
42 * @license lucide-react v0.469.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const Yt=D("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
47 * @license lucide-react v0.469.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const et=D("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
52 * @license lucide-react v0.469.0 - ISC
53 *
54 * This source code is licensed under the ISC license.
55 * See the LICENSE file in the root directory of this source tree.
56 */const Fe=D("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
57 * @license lucide-react v0.469.0 - ISC
58 *
59 * This source code is licensed under the ISC license.
60 * See the LICENSE file in the root directory of this source tree.
61 */const Qt=D("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/**
62 * @license lucide-react v0.469.0 - ISC
63 *
64 * This source code is licensed under the ISC license.
65 * See the LICENSE file in the root directory of this source tree.
66 */const He=D("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
67 * @license lucide-react v0.469.0 - ISC
68 *
69 * This source code is licensed under the ISC license.
70 * See the LICENSE file in the root directory of this source tree.
71 */const Zt=D("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);/**
72 * @license lucide-react v0.469.0 - ISC
73 *
74 * This source code is licensed under the ISC license.
75 * See the LICENSE file in the root directory of this source tree.
76 */const Xt=D("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
77 * @license lucide-react v0.469.0 - ISC
78 *
79 * This source code is licensed under the ISC license.
80 * See the LICENSE file in the root directory of this source tree.
81 */const st=D("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
82 * @license lucide-react v0.469.0 - ISC
83 *
84 * This source code is licensed under the ISC license.
85 * See the LICENSE file in the root directory of this source tree.
86 */const Jt=D("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
87 * @license lucide-react v0.469.0 - ISC
88 *
89 * This source code is licensed under the ISC license.
90 * See the LICENSE file in the root directory of this source tree.
91 */const ea=D("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
92 * @license lucide-react v0.469.0 - ISC
93 *
94 * This source code is licensed under the ISC license.
95 * See the LICENSE file in the root directory of this source tree.
96 */const ss=D("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
97 * @license lucide-react v0.469.0 - ISC
98 *
99 * This source code is licensed under the ISC license.
100 * See the LICENSE file in the root directory of this source tree.
101 */const sa=D("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/**
102 * @license lucide-react v0.469.0 - ISC
103 *
104 * This source code is licensed under the ISC license.
105 * See the LICENSE file in the root directory of this source tree.
106 */const ta=D("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
107 * @license lucide-react v0.469.0 - ISC
108 *
109 * This source code is licensed under the ISC license.
110 * See the LICENSE file in the root directory of this source tree.
111 */const ts=D("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
112 * @license lucide-react v0.469.0 - ISC
113 *
114 * This source code is licensed under the ISC license.
115 * See the LICENSE file in the root directory of this source tree.
116 */const aa=D("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/**
117 * @license lucide-react v0.469.0 - ISC
118 *
119 * This source code is licensed under the ISC license.
120 * See the LICENSE file in the root directory of this source tree.
121 */const be=D("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
122 * @license lucide-react v0.469.0 - ISC
123 *
124 * This source code is licensed under the ISC license.
125 * See the LICENSE file in the root directory of this source tree.
126 */const na=D("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
127 * @license lucide-react v0.469.0 - ISC
128 *
129 * This source code is licensed under the ISC license.
130 * See the LICENSE file in the root directory of this source tree.
131 */const la=D("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/**
132 * @license lucide-react v0.469.0 - ISC
133 *
134 * This source code is licensed under the ISC license.
135 * See the LICENSE file in the root directory of this source tree.
136 */const ia=D("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
137 * @license lucide-react v0.469.0 - ISC
138 *
139 * This source code is licensed under the ISC license.
140 * See the LICENSE file in the root directory of this source tree.
141 */const ra=D("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
142 * @license lucide-react v0.469.0 - ISC
143 *
144 * This source code is licensed under the ISC license.
145 * See the LICENSE file in the root directory of this source tree.
146 */const gs=D("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
147 * @license lucide-react v0.469.0 - ISC
148 *
149 * This source code is licensed under the ISC license.
150 * See the LICENSE file in the root directory of this source tree.
151 */const Ge=D("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
152 * @license lucide-react v0.469.0 - ISC
153 *
154 * This source code is licensed under the ISC license.
155 * See the LICENSE file in the root directory of this source tree.
156 */const Ue=D("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
157 * @license lucide-react v0.469.0 - ISC
158 *
159 * This source code is licensed under the ISC license.
160 * See the LICENSE file in the root directory of this source tree.
161 */const fs=D("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/**
162 * @license lucide-react v0.469.0 - ISC
163 *
164 * This source code is licensed under the ISC license.
165 * See the LICENSE file in the root directory of this source tree.
166 */const ke=D("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
167 * @license lucide-react v0.469.0 - ISC
168 *
169 * This source code is licensed under the ISC license.
170 * See the LICENSE file in the root directory of this source tree.
171 */const es=D("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:"m3
171kijz"}],["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"}]]);/**
172 * @license lucide-react v0.469.0 - ISC
173 *
174 * This source code is licensed under the ISC license.
175 * See the LICENSE file in the root directory of this source tree.
176 */const tt=D("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
177 * @license lucide-react v0.469.0 - ISC
178 *
179 * This source code is licensed under the ISC license.
180 * See the LICENSE file in the root directory of this source tree.
181 */const da=D("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
182 * @license lucide-react v0.469.0 - ISC
183 *
184 * This source code is licensed under the ISC license.
185 * See the LICENSE file in the root directory of this source tree.
186 */const xs=D("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/**
187 * @license lucide-react v0.469.0 - ISC
188 *
189 * This source code is licensed under the ISC license.
190 * See the LICENSE file in the root directory of this source tree.
191 */const Ae=D("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
192 * @license lucide-react v0.469.0 - ISC
193 *
194 * This source code is licensed under the ISC license.
195 * See the LICENSE file in the root directory of this source tree.
196 */const Ce=D("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
197 * @license lucide-react v0.469.0 - ISC
198 *
199 * This source code is licensed under the ISC license.
200 * See the LICENSE file in the root directory of this source tree.
201 */const as=D("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
202 * @license lucide-react v0.469.0 - ISC
203 *
204 * This source code is licensed under the ISC license.
205 * See the LICENSE file in the root directory of this source tree.
206 */const ca=D("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/**
207 * @license lucide-react v0.469.0 - ISC
208 *
209 * This source code is licensed under the ISC license.
210 * See the LICENSE file in the root directory of this source tree.
211 */const oa=D("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
212 * @license lucide-react v0.469.0 - ISC
213 *
214 * This source code is licensed under the ISC license.
215 * See the LICENSE file in the root directory of this source tree.
216 */const Se=D("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function xa({children:s}){const[t,a]=l.useState(null),[i,m]=l.useState(!1),[r,u]=l.useState(""),[h,d]=l.useState(""),[n,x]=l.useState("password"),[v,o]=l.useState(!1),[j,L]=l.useState(!1),[k,E]=l.useState(null);if(l.useEffect(()=>{if(!je){m(!0);return}je.auth.getSession().then(({data:N})=>{a(N.session),m(!0)});const{data:$}=je.auth.onAuthStateChange((N,w)=>a(w));return()=>$.subscription.unsubscribe()},[]),!zs)return e.jsx(e.Fragment,{children:s});if(!i)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-canvas text-slate-400",children:"Loading…"});if(t)return e.jsx(e.Fragment,{children:s});const I=async $=>{$.preventDefault(),E(null),o(!0);const{error:N}=await je.auth.signInWithPassword({email:r,password:h});N&&E(N.message),o(!1)},T=async $=>{$.preventDefault(),E(null),o(!0);const{error:N}=await je.auth.signInWithOtp({email:r,options:{emailRedirectTo:window.location.origin,shouldCreateUser:!1}});N?E(N.message):L(!0),o(!1)};return e.jsx("div",{className:"flex h-screen items-center justify-center bg-navy-900 px-4",children:e.jsxs("div",{className:"w-full max-w-sm rounded-2xl bg-white p-8 shadow-pop",children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-brand-500 text-lg font-bold text-white",children:"F"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-800",children:"FusionSales.ai"}),e.jsx("div",{className:"text-xs text-slate-500",children:"Command Center · team access"})]})]}),j?e.jsxs("div",{className:"rounded-lg bg-emerald-50 p-4 text-sm text-emerald-700",children:["Check ",e.jsx("span",{className:"font-medium",children:r})," for a sign-in link."]}):n==="password"?e.jsxs("form",{onSubmit:I,className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600",children:"Email"}),e.jsx("input",{type:"email",required:!0,value:r,onChange:$=>u($.target.value),placeholder:"[email protected]",className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100"}),e.jsx("label",{className:"block text-sm font-medium text-slate-600",children:"Password"}),e.jsx("input",{type:"password",required:!0,value:h,onChange:$=>d($.target.value),placeholder:"••••••••",className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100"}),k&&e.jsx("div",{className:"text-sm text-red-600",children:k}),e.jsx("button",{type:"submit",disabled:v,className:"w-full rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-60",children:v?"Signing in…":"Sign in"}),e.jsx("button",{type:"button",onClick:()=>{x("magiclink"),E(null)},className:"w-full text-center text-xs text-slate-400 hover:text-slate-600",children:"Email me a magic link instead"})]}):e.jsxs("form",{onSubmit:T,className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600",children:"Work email"}),e.jsx("input",{type:"email",required:!0,value:r,onChange:$=>u($.target.value),placeholder:"[email protected]",className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100"}),k&&e.jsx("div",{className:"text-sm text-red-600",children:k}),e.jsx("button",{type:"submit",disabled:v,className:"w-full rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-60",children:v?"Sending…":"Email me a magic link"}),e.jsx("button",{type:"button",onClick:()=>{x("password"),E(null)},className:"w-full text-center text-xs text-slate-400 hover:text-slate-600",children:"Use a password instead"}),e.jsx("p",{className:"text-center text-xs text-slate-400",children:"Only allowlisted team emails can sign in."})]})]})})}class ma extends l.Component{constructor(){super(...arguments);As(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}render(){return this.state.error?e.jsxs("div",{className:"mx-auto max-w-lg rounded-xl border border-red-200 bg-red-50 p-6 text-center",children:[e.jsx("div",{className:"font-semibold text-red-700",children:"Something went wrong on this screen."}),e.jsx("div",{className:"mt-1 text-sm text-red-600",children:this.state.error.message}),e.jsx("button",{onClick:()=>this.setState({error:null}),className:"mt-4 rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700",children:"Try again"})]}):this.props.children}}const ha={email:"",name:"",role:"operator",ready:!1};let Oe=null,Ye=null;const js=new Set;async function pa(){var m;if(!zs||!je)return{email:"[email protected]",name:"Dev",role:"admin",ready:!0};const{data:s}=await je.auth.getUser(),t=((m=s.user)==null?void 0:m.email)??"";let a="operator",i=t?t.split("@")[0]:"";if(t){const{data:r}=await je.from("team_members").select("role, name").eq("email",t).maybeSingle();(r==null?void 0:r.role)==="admin"&&(a="admin"),r!=null&&r.name&&(i=r.name)}return{email:t,name:i,role:a,ready:!0}}function ua(){return Oe?Promise.resolve(Oe):(Ye||(Ye=pa().then(s=>(Oe=s,js.forEach(t=>t(s)),s)).finally(()=>{Ye=null})),Ye)}function ba(){Oe=null}function Le(){const[s,t]=l.useState(Oe??ha);return l.useEffect(()=>{let a=!0;return js.add(t),ua().then(i=>{a&&t(i)}),()=>{a=!1,js.delete(t)}},[]),s}const at=[{to:"/",label:"Command Center",icon:ta,end:!0,adminOnly:!1},{to:"/clients",label:"Clients",icon:Se,end:!1,adminOnly:!1},{to:"/campaigns",label:"Campaigns",icon:ys,end:!1,adminOnly:!1},{to:"/approvals",label:"Approvals",icon:Ae,end:!1,adminOnly:!1},{to:"/leads",label:"Warm Leads",icon:He,end:!1,adminOnly:!1},{to:"/content",label:"Content",icon:Bs,end:!1,adminOnly:!1},{to:"/intake",label:"New quote",icon:Nt,end:!1,adminOnly:!1},{to:"/activity",label:"Activity",icon:Vt,end:!1,adminOnly:!1},{to:"/settings",label:"Settings",icon:tt,end:!1,adminOnly:!0}];let Ie=null;function ga(){const[s,t]=l.useState((Ie==null?void 0:Ie.report)??null);return l.useEffect(()=>{if(Ie&&Date.now()-Ie.at<5*6e4)return;let a=!0;return C.health().then(i=>{Ie={at:Date.now(),report:i},a&&t(i)}).catch(()=>{}),()=>{a=!1}},[]),s}function fa({open:s,onClose:t}){const{role:a,ready:i}=Le(),m=ga(),r=at.filter(d=>!d.adminOnly||a==="admin"),u=d=>d==="ok"?"bg-emerald-400":d==="warn"?"bg-amber-400":"bg-slate-500",h=m?m.checks.filter(d=>d.key!=="supabase"&&d.key!=="cron"):[];return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"fixed inset-0 z-30 bg-slate-900/40 lg:hidden",onClick:t}),e.jsxs("aside",{className:`fixed inset-y-0 left-0 z-40 flex w-60 shrink-0 flex-col bg-navy-900 text-slate-300 transition-transform lg:static lg:translate-x-0 ${s?"translate-x-0":"-translate-x-full"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-brand-500 font-bold text-white",children:"F"}),e.jsxs("div",{className:"leading-tight",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:"FusionSales.ai"}),e.jsx("div",{className:"text-[11px] text-slate-400",children:"Command Center"})]})]}),e.jsx("button",{onClick:t,"aria-label":"Close menu",className:"rounded-lg p-1 text-slate-400 hover:bg-navy-800 lg:hidden",children:e.jsx(ce,{className:"h-5 w-5"})})]}),e.jsxs("nav",{className:"mt-2 flex-1 space-y-1 px-3",children:[r.map(({to:d,label:n,icon:x,end:v})=>e.jsxs(Rt,{to:d,end:v,onClick:t,className:({isActive:o})=>`flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition ${o?"bg-brand-600 text-white":"text-slate-300 hover:bg-navy-800 hover:text-white"}`,children:[e.jsx(x,{className:"h-4 w-4"}),n]},d)),!i&&e.jsx("div",{className:"px-3 py-2 text-[11px] text-slate-500",children:"Loading your role…"})]}),e.jsx(K,{to:a==="admin"?"/settings":"/",className:"block border-t border-navy-700 px-5 py-4 text-[11px] text-slate-400 hover:bg-navy-800",title:a==="admin"?"Open Settings for the full connection status":"Connection status",children:m?e.jsx("div",{className:"space-y-1",children:h.map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${u(d.status)}`}),d.label," · ",d.status==="ok"?"connected":d.status==="warn"?"needs attention":"not connected"]},d.key))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-3 w-3 animate-spin"})," Checking connections…"]})})]})]})}function ja({onMenu:s}){var n;const{pathname:t}=Fs(),a=Re(),{name:i,role:m}=Le(),[r,u]=l.useState(""),h=((n=at.find(x=>x.end?t===x.to:t.startsWith(x.to)&&x.to!=="/"))==null?void 0:n.label)??(t==="/"?"Command Center":"Mission Control"),d=async()=>{var x;await((x=je)==null?void 0:x.auth.signOut()),ba(),window.location.assign("/")};return e.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:s,"aria-label":"Open menu",className:"rounded-lg p-1.5 text-slate-500 hover:bg-slate-100 lg:hidden",children:e.jsx(ia,{className:"h-5 w-5"})}),e.jsx("div",{className:"text-sm font-semibold text-slate-700",children:h})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("form",{onSubmit:x=>{x.preventDefault(),r.trim()&&(a(`/clients?q=${encodeURIComponent(r.trim())}`),u(""))},className:"relative hidden md:block",children:[e.jsx(is,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:r,onChange:x=>u(x.target.value),"aria-label":"Search clients",placeholder:"Search clients…",className:"w-64 roun
216ded-lg border border-slate-200 bg-slate-50 py-2 pl-9 pr-3 text-sm outline-none focus:border-brand-400 focus:bg-white focus:ring-2 focus:ring-brand-100"})]}),e.jsxs(K,{to:"/clients?new=1",className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-2 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(ds,{className:"h-4 w-4"})," ",e.jsx("span",{className:"hidden sm:inline",children:"New client"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"hidden text-right sm:block",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-700",children:i||"Team"}),e.jsx("div",{className:"text-[10px] capitalize text-slate-400",children:m})]}),e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-brand-100 text-sm font-semibold text-brand-700","aria-hidden":!0,children:(i||"T").charAt(0).toUpperCase()}),e.jsx("button",{onClick:()=>void d(),title:"Sign out","aria-label":"Sign out",className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(na,{className:"h-4 w-4"})})]})]})]})}function ya(){const[s,t]=l.useState(!1),{pathname:a}=Fs();return l.useEffect(()=>{t(!1)},[a]),e.jsxs("div",{className:"flex h-screen overflow-hidden bg-canvas",children:[e.jsx(fa,{open:s,onClose:()=>t(!1)}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx(ja,{onMenu:()=>t(!0)}),e.jsx("main",{className:"flex-1 overflow-y-auto",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 py-5 sm:px-6 sm:py-6",children:e.jsx(ma,{children:e.jsx(Mt,{})})})})]})]})}function W({children:s,className:t=""}){return e.jsx("div",{className:`rounded-xl border border-slate-200 bg-white shadow-card ${t}`,children:s})}const va="inline-flex items-center justify-center gap-1.5 rounded-lg font-medium transition-all duration-150 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-300 disabled:opacity-50 disabled:pointer-events-none active:scale-[0.97]",Na={sm:"h-8 px-3 text-[13px]",md:"h-9 px-4 text-sm"},wa={primary:"bg-brand-600 text-white hover:bg-brand-700 shadow-sm",secondary:"border border-slate-200 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-300",ghost:"text-slate-600 hover:bg-slate-100",danger:"border border-slate-200 bg-white text-red-600 hover:bg-red-50 hover:border-red-200",success:"bg-emerald-600 text-white hover:bg-emerald-700 shadow-sm"};function ie({variant:s="secondary",size:t="md",className:a="",...i}){return e.jsx("button",{className:`${va} ${Na[t]} ${wa[s]} ${a}`,...i})}function nt({on:s,onChange:t,disabled:a,size:i="md",label:m}){const r=i==="sm"?{track:"h-[18px] w-8",knob:"h-3.5 w-3.5",on:"translate-x-[14px]"}:{track:"h-5 w-9",knob:"h-4 w-4",on:"translate-x-4"};return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":m,disabled:a,onClick:t,className:`relative inline-flex ${r.track} shrink-0 items-center rounded-full px-0.5 transition-colors duration-200 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-300 disabled:opacity-50 ${s?"bg-emerald-500":"bg-slate-300"}`,children:e.jsx("span",{className:`inline-block ${r.knob} rounded-full bg-white shadow-sm transition-transform duration-200 ease-out ${s?r.on:"translate-x-0"}`})})}const ka={live:"bg-emerald-500",warming:"bg-amber-500",paused:"bg-slate-300"};function Ca({status:s,className:t=""}){return e.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-full ${ka[s]} ${t}`})}function ae({children:s,className:t=""}){return e.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset ${t}`,children:s})}function Ve({role:s,className:t=""}){const a=wt(s);return e.jsx("span",{className:`inline-flex h-8 w-8 items-center justify-center rounded-lg ${kt(s)} ${t}`,children:l.createElement(a,{className:"h-4 w-4"})})}function Sa({activeRoles:s}){return e.jsx("div",{className:"flex items-center gap-1",children:Ct.map(t=>e.jsx("span",{title:We[t],className:`h-2 w-2 rounded-full ${s.includes(t)?"bg-brand-500":"bg-slate-300"}`},t))})}function ns({pct:s,tone:t="brand"}){const a=s>=100?"bg-red-500":t==="amber"?"bg-amber-500":"bg-brand-500";return e.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:`h-full rounded-full ${a}`,style:{width:`${Math.min(100,s)}%`}})})}
216function Qe({icon:s,label:t,value:a,accent:i="text-brand-600"}){return e.jsxs(W,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-slate-500",children:t}),e.jsx(s,{className:`h-4 w-4 ${i}`})]}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-slate-800",children:a})]})}function Ee({icon:s,title:t,hint:a}){return e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-dashed border-slate-300 bg-white/50 px-6 py-12 text-center",children:[e.jsx(s,{className:"mb-3 h-8 w-8 text-slate-400"}),e.jsx("div",{className:"font-medium text-slate-600",children:t}),a&&e.jsx("div",{className:"mt-1 text-sm text-slate-400",children:a})]})}function ye({children:s,action:t}){return e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wide text-slate-500",children:s}),t]})}const Ze=({rows:s=3})=>e.jsx("div",{className:"space-y-2 p-5",children:Array.from({length:s}).map((t,a)=>e.jsx("div",{className:"h-4 animate-pulse rounded bg-slate-100",style:{width:`${70-a*12}%`}},a))});function _a(){const[s,t]=l.useState(null),[a,i]=l.useState(null),[m,r]=l.useState(null),[u,h]=l.useState(null),[d,n]=l.useState(null),[x,v]=l.useState({});return l.useEffect(()=>{C.commandSummary().then(t).catch(()=>t({activeCampaigns:0,sentToday:0,pendingApprovals:0,warmLeads:0})),C.listApprovalViews().then(o=>i(o.filter(j=>j.approval.state==="pending").slice(0,8))).catch(()=>i([])),C.listWarmLeads().then(o=>r(o.slice(0,8))).catch(()=>r([])),C.listActivity().then(o=>h(o.slice(0,8))).catch(()=>h([])),C.listClients().then(o=>n(o.filter(j=>j.stage!=="paused"))).catch(()=>n([])),C.clientPipeline().then(v).catch(()=>{})},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[e.jsx(Qe,{icon:ys,label:"Live campaigns",value:(s==null?void 0:s.activeCampaigns)??"—"}),e.jsx(Qe,{icon:rs,label:"Sent today",value:(s==null?void 0:s.sentToday)??"—",accent:"text-indigo-600"}),e.jsx(K,{to:"/approvals",children:e.jsx(Qe,{icon:Ae,label:"Pending approvals",value:(s==null?void 0:s.pendingApprovals)??"—",accent:"text-amber-600"})}),e.jsx(K,{to:"/leads",children:e.jsx(Qe,{icon:He,label:"Warm replies",value:(s==null?void 0:s.warmLeads)??"—",accent:"text-emerald-600"})})]}),e.jsxs("section",{children:[e.jsx(ye,{action:e.jsxs(K,{to:"/clients",className:"inline-flex items-center gap-1 text-xs font-medium text-brand-600 hover:underline",children:["All clients ",e.jsx(ze,{className:"h-3 w-3"})]}),children:"Clients today"}),e.jsxs(W,{children:[d===null&&e.jsx(Ze,{}),(d==null?void 0:d.length)===0&&e.jsxs("div",{className:"p-5 text-sm text-slate-500",children:["No active clients yet. New quotes appear under ",e.jsx(K,{to:"/clients",className:"text-brand-600 underline",children:"Clients"}),"."]}),d==null?void 0:d.map(o=>{const j=x[o.id],L=vs(o.checklist),k=j!=null&&j.toReview?{label:`Review ${j.toReview} lead${j.toReview===1?"":"s"}`,icon:Ue,to:`/clients/${o.id}`,tone:"text-brand-700 bg-brand-50"}:j!=null&&j.needEmail?{label:`Find ${j.needEmail} email${j.needEmail===1?"":"s"}`,icon:Be,to:`/clients/${o.id}`,tone:"text-amber-700 bg-amber-50"}:j!=null&&j.pendingApprovals?{label:`Approve ${j.pendingApprovals} sequence${j.pendingApprovals===1?"":"s"}`,icon:Ae,to:"/approvals",tone:"text-amber-700 bg-amber-50"}:j!=null&&j.warm?{label:`Reply to ${j.warm} warm lead${j.warm===1?"":"s"}`,icon:He,to:"/leads",tone:"text-emerald-700 bg-emerald-50"}:o.stage==="live"?{label:"Running · nothing waiting",icon:Se,to:`/clients/${o.id}`,tone:"text-slate-500 bg-slate-50"}:{label:Ns(o.checklist),icon:Se,to:`/clients/${o.id}`,tone:"text-slate-600 bg-slate-50"};return e.jsxs(K,{to:k.to,className:"flex items-center justify-between gap-4 border-b border-slate-100 px-5 py-3 last:border-0 hover:bg-slate-50",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${o.stage==="live"?"bg-emerald-500":"bg-amber-500"}`}),e.jsx("span",{className:"truncate text-sm font-medium text-slate-800",children:o.company||o.name||"Client"}),o.kind==="own"&&e.jsx("span",{className:"rounded-full bg-indigo-50 px-1.5 py-0.5 text-[10px] font-medium text-indigo-700",children:"your brand"}),e.jsx("span",{className:"text-[11px] text-slate-400",children:o.stage==="live"?"live":`onboarding ${L.done}/${L.total}`})]}),e.jsx("div",{className:"ml-4 truncate text-xs text-slate-500",children:j?`${j.leads} lead${j.leads===1?"":"s"} in pipeline`:"no research yet"})]}),e.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-semibold ${k.tone}`,children:[e.jsx(k.icon,{className:"h-3.5 w-3.5"})," ",k.label]})]},o.id)})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-6 lg:col-span-2",children:[e.jsxs("section",{children:[e.jsx(ye,{action:e.jsx(K,{to:"/approvals",className:"text-xs font-medium text-brand-600 hover:underline",children:"View all"}),children:"Needs your approval"}),e.jsxs(W,{children:[a===null&&e.jsx(Ze,{}),(a==null?void 0:a.length)===0&&e.jsx("div",{className:"p-5 text-sm text-slate-500",children:"Nothing pending — you're clear."}),a==null?void 0:a.map(({approval:o,campaign:j,prospect:L})=>{var k;return e.jsxs(K,{to:"/approvals",className:"flex items-center justify-between gap-3 border-b border-slate-100 px-5 py-3 last:border-0 hover:bg-slate-50",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-medium text-slate-800",children:[(L==null?void 0:L.company)??"Prospect"," — ",(k=o.sequence[0])==null?void 0:k.subject]}),e.jsxs("div",{className:"text-xs text-slate-500",children:[(j==null?void 0:j.name)??"campaign"," · ",o.sequence.length,"-touch · ",o.methodology.framework]})]}),e.jsx(ae,{className:"bg-amber-100 text-amber-700 ring-amber-600/20",children:"pending"})]},o.id)})]})]}),e.jsxs("section",{children:[e.jsx(ye,{action:e.jsx(K,{to:"/leads",className:"text-xs font-medium text-brand-600 hover:underline",children:"View all"}),children:"Replies to action"}),e.jsxs(W,{children:[m===null&&e.jsx(Ze,{}),(m==null?void 0:m.length)===0&&e.jsx("div",{className:"p-5 text-sm text-slate-500",children:"No replies yet. They land here the moment Instantly reports one."}),m==null?void 0:m.map(({event:o,campaign:j,prospect:L})=>e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-slate-100 px-5 py-3 last:border-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-sm font-medium text-slate-800",children:[(L==null?void 0:L.company)??(j==null?void 0:j.name),(L==null?void 0:L.contact_name)&&e.jsxs("span",{className:"font-normal text-slate-500",children:[" · ",L.contact_name]})]}),e.jsxs("div",{className:"truncate text-xs text-slate-500",children:["“",o.reply_text,"”"]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[e.jsx(ae,{className:`${ks[o.classification??"cold"]} ring-0`,children:o.classification}),e.jsx("span",{className:"text-[11px] text-slate-400",children:he(o.created_at)})]})]},o.id))]})]})]}),e.jsxs("section",{children:[e.jsx(ye,{action:e.jsx(K,{to:"/activity",className:"text-xs font-medium text-brand-600 hover:underline",children:"Full log"}),children:"Live activity"}),e.jsxs(W,{className:"p-2",children:[u===null&&e.jsx(Ze,{rows:5}),(u==null?void 0:u.length)===0&&e.jsx("div",{className:"p-3 text-sm text-slate-500",children:"Nothing logged yet."}),e.jsx("ul",{className:"space-y-1",children:u==null?void 0:u.map(o=>e.jsxs("li",{className:"flex gap-3 rounded-lg p-2 hover:bg-slate-50",children:[o.agent_role&&e.jsx(Ve,{role:o.agent_role}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-slate-700",children:o.message}),e.jsxs("div",{className:"text-[11px] text-slate-400",children:[o.agent_role?We[o.agent_role]||ue(o.agent_role).label:"System"," · ",he(o.created_at)]})]})]},o.id))})]})]})]})]})}function cs({kind:s,id:t,ids:a,onClose:i,onDeleted:m}){const r=a&&a.length?a:t?[t]:[],u=r.join(","),[h,d]=l.useState(null),[n,x]=l.useState(null),[v,o]=l.useState(""),[j,L]=l.useState(!1);l.useEffect(()=>{let N=!1;return C.deletePreview(s,r).then(w=>
216{N||d(w)}).catch(w=>{N||x(w.message)}),()=>{N=!0}},[s,u]),l.useEffect(()=>{const N=w=>{w.key==="Escape"&&i()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[i]);const k=(h==null?void 0:h.confirmWord)||"DELETE",E=v.trim()===k&&!j&&!!h,I=async()=>{if(E){L(!0),x(null);try{await C.deleteRecord(s,r,v.trim()),m()}catch(N){x(N.message),L(!1)}}},T=r.length>1,$=(s==="signup"?"quote":s)+(T?"s":"");return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/50 p-4",onClick:i,role:"dialog","aria-modal":"true","aria-labelledby":"delete-title",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl bg-white p-6 shadow-pop",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-700",children:[e.jsx(as,{className:"h-5 w-5"}),e.jsxs("h2",{id:"delete-title",className:"text-base font-semibold",children:["Delete ",T?`these ${r.length}`:"this"," ",$," permanently?"]})]}),e.jsx("button",{onClick:i,"aria-label":"Close",className:"rounded-lg p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(ce,{className:"h-4 w-4"})})]}),n&&e.jsx("div",{className:"mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:n}),!h&&!n&&e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(G,{className:"h-4 w-4 animate-spin"})," Checking what this would remove…"]}),h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4 rounded-xl border border-slate-200 bg-slate-50 p-4",children:[e.jsx("div",{className:"font-semibold text-slate-900",children:h.title}),h.subtitle&&e.jsx("div",{className:"text-xs text-slate-500",children:h.subtitle}),e.jsx("ul",{className:"mt-3 space-y-1 text-sm text-slate-700",children:h.items.map(N=>e.jsxs("li",{className:"flex justify-between gap-3",children:[e.jsx("span",{children:N.label}),e.jsx("span",{className:"tabular-nums font-medium",children:N.n})]},N.label))}),h.warn&&e.jsx("p",{className:"mt-3 text-xs font-medium text-amber-700",children:h.warn}),h.stopsFollowups&&e.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Their follow-up emails stop immediately."})]}),e.jsxs("p",{className:"mt-4 text-sm text-slate-600",children:["This cannot be undone. Nothing in Instantly is changed. Prefer ",e.jsx("strong",{children:"Pause"})," or ",e.jsx("strong",{children:"Reject"})," if you might need this again."]}),e.jsxs("label",{className:"mt-4 block text-xs font-medium uppercase tracking-wide text-slate-500",children:["Type ",e.jsx("span",{className:"font-mono text-slate-900",children:k})," to confirm",e.jsx("input",{autoFocus:!0,value:v,onChange:N=>o(N.target.value),onKeyDown:N=>{N.key==="Enter"&&I()},spellCheck:!1,autoComplete:"off",className:"mt-1.5 w-full rounded-lg border border-slate-300 px-3 py-2 font-mono text-sm tracking-widest text-slate-900 focus:border-red-400 focus:outline-none focus:ring-2 focus:ring-red-200",placeholder:k})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{onClick:i,className:"rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Keep it"}),e.jsxs("button",{onClick:()=>void I(),disabled:!E,className:"inline-flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-500 disabled:cursor-not-allowed disabled:opacity-40",children:[j?e.jsx(G,{className:"h-4 w-4 animate-spin"}):e.jsx(Ce,{className:"h-4 w-4"})," Delete permanently"]})]})]})]})})}const $a=["all","live","warming","paused"];function Aa(){const s=Re(),{role:t}=Le(),a=t==="admin",[i,m]=l.useState([]),[r,u]=l.useState(!1),[h,d]=l.useState(""),[n,x]=l.useState("all"),[v,o]=l.useState("all"),[j,L]=l.useState(null),[k,E]=l.useState(null),[I,T]=l.useState(new Set),[$,N]=l.useState(null),w=()=>C.listCampaignsWithAgents().then(y=>{m(y),u(!0)}).catch(()=>u(!0));l.useEffect(()=>{w()},[]),l.useEffect(()=>{const y=()=>E(null);return window.addEventListener("click",y),()=>window.removeEventListener("click",y)},[]);const b=async(y,Y)=>{L(y.id),m(Z=>Z.map(f=>f.id===y.id?{...f,status:Y}:f));try{await C.updateCampaign(y.id,{status:Y})}catch{await w()}finally{L(null)}},B=y=>b(y,y.status==="paused"?"live":"paused"),z=async()=>{for(const y of i.filter(Y=>I.has(Y.id)&&Y.status!=="paused"))await b(y,"paused");T(new Set)},X=l.useMemo(()=>["all",...Array.from(new Set(i.map(y=>
216y.business_unit).filter(Boolean)))],[i]),A=l.useMemo(()=>i.filter(y=>!(n!=="all"&&y.status!==n||v!=="all"&&y.business_unit!==v||h&&!`${y.name} ${y.audience} ${y.business_unit??""}`.toLowerCase().includes(h.toLowerCase()))),[i,h,n,v]),V=A.length>0&&A.every(y=>I.has(y.id)),g=()=>T(V?new Set:new Set(A.map(y=>y.id))),H=y=>T(Y=>{const Z=new Set(Y);return Z.has(y)?Z.delete(y):Z.add(y),Z});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[e.jsx(is,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:h,onChange:y=>d(y.target.value),placeholder:"Search campaigns…",className:"w-full rounded-lg border border-slate-200 bg-white py-2 pl-9 pr-3 text-sm outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100"})]}),e.jsx("div",{className:"flex rounded-lg border border-slate-200 bg-white p-0.5",children:$a.map(y=>e.jsx("button",{onClick:()=>x(y),className:`rounded-md px-3 py-1.5 text-sm font-medium capitalize transition ${n===y?"bg-brand-600 text-white":"text-slate-600 hover:bg-slate-100"}`,children:y},y))}),e.jsx("select",{value:v,onChange:y=>o(y.target.value),className:"rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm outline-none focus:border-brand-400",children:X.map(y=>e.jsx("option",{value:y,children:y==="all"?"All business units":y},y))}),e.jsxs(K,{to:"/clients",className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",title:"Campaigns are created from a client's workspace",children:[e.jsx(Se,{className:"h-4 w-4"})," New campaigns start from Clients"]})]}),I.size>0?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-xl border border-slate-900 bg-slate-900 px-4 py-2.5 text-sm text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-semibold",children:[I.size," selected"]}),e.jsxs("button",{onClick:()=>T(new Set),className:"inline-flex items-center gap-1 text-xs text-slate-300 hover:text-white",children:[e.jsx(ce,{className:"h-3.5 w-3.5"})," Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>void z(),className:"inline-flex items-center gap-1.5 rounded-lg bg-white/10 px-3 py-1.5 text-xs font-semibold hover:bg-white/20",children:[e.jsx(gs,{className:"h-3.5 w-3.5"})," Pause"]}),a?e.jsxs("button",{onClick:()=>N(Array.from(I)),className:"inline-flex items-center gap-1.5 rounded-lg bg-red-500 px-3 py-1.5 text-xs font-semibold hover:bg-red-400",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"})," Delete ",I.size,"…"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-slate-300",children:[e.jsx(be,{className:"h-3.5 w-3.5"})," delete is admin-only"]})]})]}):e.jsxs("div",{className:"text-xs text-slate-500",children:[A.length," of ",i.length," campaigns · tick rows to pause or delete several at once"]}),r?A.length===0?e.jsx(Ee,{icon:ys,title:i.length===0?"No campaigns yet":"No campaigns match",hint:i.length===0?"Campaigns are created from a client's page.":"Adjust your search or filters."}):e.jsx(W,{className:"overflow-x-auto lg:overflow-visible",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500",children:[e.jsx("th",{className:"w-10 px-4 py-3",children:e.jsx("input",{type:"checkbox","aria-label":"Select all shown",checked:V,onChange:g,className:"h-4 w-4 rounded border-slate-300 text-brand-600"})}),e.jsx("th",{className:"px-2 py-3 font-semibold",children:"Campaign"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Business unit"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Team"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Daily"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"AI spend (MTD)"}),e.jsx("th",{className:"px-3 py-3 text-center font-semibold",children:"Approvals"}),e.jsx("th",{className:"px-3 py-3 text-right font-semibold",children:"Run"}),e.jsx("th",{className:"px-3 py-3"})]})}),e.jsx("tbody",{children:A.map(y=>{const Y=y.agents.filter(O=>O.enabled&&O.status!=="paused").map(O=>O.role),Z=y.agents.filter(O=>O.status==="awaiting_approval").length,f=Math.round(y.spend_mtd_usd/y.monthly_budget_usd*100),R=I.has(y.id);return e.jsxs("tr",{className:`group border-b border-slate-100 last:border-0 ${R?"bg-brand-50/60":"hover:bg-brand-50/40"}`,children:[e.jsx("td",{className:"px-4 py-3.5 align-top",children:e.jsx("input",{type:"checkbox","aria-label":`Select ${y.name}`,checked:R,onChange:()=>
216H(y.id),className:"mt-1 h-4 w-4 rounded border-slate-300 text-brand-600"})}),e.jsx("td",{className:"max-w-[26rem] px-2 py-3.5 align-top",children:e.jsxs(K,{to:`/campaigns/${y.slug}`,className:"flex items-start gap-2.5",children:[e.jsx("span",{title:y.status,className:"mt-1.5",children:e.jsx(Ca,{status:y.status})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-slate-800 group-hover:text-brand-700",children:y.name}),e.jsx("div",{className:"line-clamp-1 text-xs text-slate-500",children:y.audience})]})]})}),e.jsx("td",{className:"px-3 py-3.5 text-slate-600",children:y.business_unit}),e.jsx("td",{className:"px-3 py-3.5",children:e.jsx(Sa,{activeRoles:Y})}),e.jsxs("td",{className:"px-3 py-3.5 text-slate-600",children:[y.daily_send_target,"/day"]}),e.jsx("td",{className:"px-3 py-3.5",children:e.jsx("div",{className:"w-28",children:y.spend_mtd_usd>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1 text-xs text-slate-600",children:[se(y.spend_mtd_usd)," / ",se(y.monthly_budget_usd)]}),e.jsx(ns,{pct:f,tone:f>=80?"amber":"brand"})]}):e.jsx("span",{className:"text-xs text-slate-400",title:"Per-campaign AI spend is tracked once the bridge is on",children:"—"})})}),e.jsx("td",{className:"px-3 py-3.5 text-center",children:Z>0?e.jsx(ae,{className:"bg-amber-100 text-amber-700 ring-amber-600/20",children:Z}):e.jsx("span",{className:"text-slate-300",children:"—"})}),e.jsx("td",{className:"px-3 py-3.5 text-right",children:e.jsx(nt,{on:y.status!=="paused",disabled:j===y.id,onChange:()=>B(y),label:`Turn ${y.name} ${y.status==="paused"?"on":"off"}`})}),e.jsxs("td",{className:"relative px-3 py-3.5 text-right",onClick:O=>O.stopPropagation(),children:[e.jsxs("button",{onClick:()=>E(k===y.id?null:y.id),"aria-label":"Campaign actions",className:"inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2.5 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50",children:["Actions ",e.jsx(et,{className:"h-3.5 w-3.5"})]}),k===y.id&&e.jsxs("div",{className:"absolute right-3 top-12 z-20 w-52 overflow-hidden rounded-xl border border-slate-200 bg-white py-1 text-left text-sm shadow-pop",children:[e.jsxs("button",{onClick:()=>s(`/campaigns/${y.slug}`),className:"flex w-full items-center gap-2 px-3 py-2 text-slate-700 hover:bg-slate-50",children:[e.jsx(ze,{className:"h-4 w-4 text-slate-400"})," Open"]}),y.status!=="paused"?e.jsxs("button",{onClick:()=>{E(null),b(y,"paused")},className:"flex w-full items-center gap-2 px-3 py-2 text-slate-700 hover:bg-slate-50",children:[e.jsx(gs,{className:"h-4 w-4 text-slate-400"})," Pause"]}):e.jsxs("button",{onClick:()=>{E(null),b(y,"live")},className:"flex w-full items-center gap-2 px-3 py-2 text-slate-700 hover:bg-slate-50",children:[e.jsx(Ge,{className:"h-4 w-4 text-slate-400"})," Resume"]}),a?e.jsxs("button",{onClick:()=>{E(null),N([y.id])},className:"flex w-full items-center gap-2 border-t border-slate-100 px-3 py-2 text-red-600 hover:bg-red-50",children:[e.jsx(Ce,{className:"h-4 w-4"})," Delete campaign…"]}):e.jsxs("div",{className:"flex w-full items-center gap-2 border-t border-slate-100 px-3 py-2 text-slate-400",children:[e.jsx(be,{className:"h-4 w-4"})," Delete (admin only)"]})]})]})]},y.id)})})]})}):e.jsx(W,{className:"h-48 animate-pulse bg-slate-50"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"The switch pauses or resumes sending. Delete removes the campaign and everything under it (leads, sequences, events) and cannot be undone. Nothing in Instantly is changed by a delete here."}),$&&e.jsx(cs,{kind:"campaign",ids:$,onClose:()=>N(null),onDeleted:()=>{N(null),T(new Set),w()}})]})}function Ea({agent:s,campaign:t,prospects:a,activity:i,onClose:m}){const[r,u]=l.useState(s.enabled),[h,d]=l.useState(!!s.instructions_override),[n,x]=l.useState(s.instructions_override??""),[v,o]=l.useState(!1),j=_e();l.useEffect(()=>{const w=b=>{b.key==="Escape"&&m()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[m]);const L=async()=>{const w=!r;u(w);try{await C.setAgentEnabled(s.id,w),j.success(`${ue(s.role).label} ${w?"enabled":"disabled"}.`)}catch(b){u(!w),j.error(te(b))}},k=async()=>{o(!0);try{await C.updateAgent(s.id,{instructions_override:n.trim()||null}),j.success("Instructions saved."),m()}catch(w){j.error(te(w))}finally{o(!1)}},[E,I]=l.useState(null);l.useEffect(()=>{let w=!1;return C.teamSynopsis(t.id).then(b=>{w||I(b)}
216).catch(()=>{}),()=>{w=!0}},[t.id]);const T=E==null?void 0:E.team.find(w=>w.role===s.role),$=ue(s.role),N=Math.round(s.spend_mtd_usd/s.monthly_budget_usd*100);return e.jsxs("div",{className:"fixed inset-0 z-40 flex justify-end",role:"dialog","aria-modal":"true","aria-label":`${ue(s.role).label} details`,children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/30",onClick:m}),e.jsxs("aside",{className:"relative z-10 flex h-full w-full max-w-md flex-col bg-white shadow-pop",children:[e.jsxs("div",{className:"flex items-start justify-between border-b border-slate-200 p-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ve,{role:s.role,className:"h-10 w-10"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold text-slate-800",children:We[s.role]}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.name," · ",s.model]})]})]}),e.jsx("button",{onClick:m,className:"rounded-lg p-1.5 text-slate-400 hover:bg-slate-100","aria-label":"Close",children:e.jsx(ce,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`inline-block rounded-full px-2.5 py-1 text-xs font-medium ${Us[s.status]}`,children:Ws[s.status]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-slate-600",children:r?"Enabled":"Disabled"}),e.jsx(nt,{on:r,onChange:()=>void L(),label:"Enable agent"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Mission"}),e.jsx("p",{className:"text-sm text-slate-700",children:ue(s.role).mission}),us(s.role)&&e.jsxs("div",{className:"mt-2 rounded-lg border border-brand-100 bg-brand-50/60 p-3",children:[e.jsx("div",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-wide text-brand-700",children:"Who they think like"}),e.jsx("p",{className:"text-sm text-slate-700",children:us(s.role)})]}),$.principles.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:"Rules they never break"}),e.jsx("ul",{className:"space-y-1 text-sm text-slate-700",children:$.principles.map(w=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-brand-500"}),w]},w))})]}),$.stack.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:"Works with"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:$.stack.map(w=>e.jsx(ae,{className:"bg-white text-slate-600 ring-slate-200",children:w},w))})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:"This period, in numbers"}),T?e.jsx("ul",{className:"space-y-1 text-sm text-slate-700",children:T.facts.map(w=>e.jsxs("li",{children:["· ",w]},w))}):e.jsx("div",{className:"text-xs text-slate-400",children:"Loading…"}),T&&T.recent.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-xs text-slate-500",children:T.recent.map((w,b)=>e.jsx("li",{children:w},b))}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-400",children:"This is what the client report says about this expert, in plain language."})]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:ue(s.role).kpis.map(w=>e.jsx(ae,{className:"bg-slate-100 text-slate-600 ring-slate-400/20",children:w},w))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Current task"}),e.jsx("div",{className:"rounded-lg bg-slate-50 p-3 text-sm text-slate-700",children:s.current_task??"Paused — no active task."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-xs font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx("span",{children:"Budget burn (MTD)"}),e.jsxs("span",{className:N>=80?"text-amber-600":"text-slate-400",children:[N,"%"]})]}),e.jsxs("div",{className:"mb-1 text-sm text-slate-600",children:[se(s.spend_mtd_usd)," of ",se(s.monthly_budget_usd)," monthly cap"]}),e.jsx(ns,{pct:N,tone:N>=80?"amber":"brand"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Last output"}),e.jsx(La,{agent:s,prospects:a})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Recent activity"}),i.length===0?e.jsx("div",{className:"text-sm text-slate-400",children:"No recent activity for this role."}):e.jsx("ul",{className:"space-y-2",children:i.map(w=>e.jsxs("li",{className:"rounded-lg border border-slate-100 p-2.5 text-sm text-slate-600",children:[w.message,e.jsx("div",{className:"mt-0.5 text-[11px] text-slate-400",children:he(w.created_at)})]},w.id))})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-3",children:[e.jsxs("button",{onClick:()=>d(w=>!w),className:"flex w-full items-center justify-between text-sm font-medium text-slate-500 hover:text-slate-700",children:["Advanced · instruction override",e.jsx(Cs,{className:`h-4 w-4 transition ${h?"rotate-180":""}`})]}),h&&e.jsx("textarea",{value:n,onChange:w=>x(w.target.value),placeholder:"Leave blank to use the standard methodology prompt for this role…",className:"mt-2 h-28 w-full rounded-lg border border-slate-200 p-2.5 text-sm outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-slate-200 p-4",children:[e.jsx("button",{onClick:m,className:"rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Close"}),e.jsx("button",{onClick:()=>void k(),disabled:v||n===(s.instructions_override??""),className:"rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50",children:v?"Saving…":"Save changes"})]})]})]})}function La({agent:s,prospects:t}){const a=t.find(i=>i.dossier);if(s.role==="research"&&(a!=null&&a.dossier)){const i=a.dossier;return e.jsxs("div",{className:"space-y-2 rounded-lg border border-slate-200 p-3 text-sm",children:[e.jsxs("div",{className:"font-medium text-slate-800",children:[a.company," — dossier"]}),e.jsxs("div",{className:"text-slate-600",children:[e.jsx("span",{className:"font-medium",children:"Pain:"})," ",i.pain_hypothesis]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-700",children:"Hooks:"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:i.personalization_hooks.map(m=>e.jsx(ae,{className:"bg-sky-50 text-sky-700 ring-sky-600/20",children:m},m))})]})]})}return s.role==="prospect"?e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3 text-sm text-slate-600",children:[t.length," prospects sourced · ",t.filter(i=>i.email_verified).length," emails verified via SuperSearch."]}):s.role==="messaging"?e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3 text-sm text-slate-600",children:["Drafted sequences applying ",e.jsx("span",{className:"font-medium text-slate-700",children:"trigger-based outreach + clear story messaging"}),"; queued to Approvals for review."]}):s.role==="responses"?e.jsx("div",{className:"rounded-lg border border-slate-200 p-3 text-sm text-slate-600",children:"Latest: classified inbou
216nd replies; warm ones routed to the Team Lead for high-value offer framing."}):s.role==="outreach"?e.jsx("div",{className:"rounded-lg border border-slate-200 p-3 text-sm text-slate-600",children:"Sending approved sequences via Instantly on the campaign sender; holding unapproved drafts."}):e.jsx("div",{className:"rounded-lg border border-slate-200 p-3 text-sm text-slate-600",children:"Owns targets and routing; surfaces warm-intent replies with a suggested next step."})}const Ia=["live","warming","paused"];function Ma({campaign:s,onClose:t,onSaved:a}){const[i,m]=l.useState({name:s.name,audience:s.audience,status:s.status,business_unit:s.business_unit??"",instantly_sender:s.instantly_sender??"",daily_send_target:s.daily_send_target}),[r,u]=l.useState(!1),h=(n,x)=>m(v=>({...v,[n]:x})),d=async()=>{u(!0);try{await C.updateCampaign(s.id,i),a(),t()}finally{u(!1)}};return e.jsxs("div",{className:"fixed inset-0 z-40 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/30",onClick:t}),e.jsxs("aside",{className:"relative z-10 flex h-full w-full max-w-md flex-col bg-white shadow-pop",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold text-slate-800",children:"Campaign settings"}),e.jsx("div",{className:"text-xs text-slate-500",children:s.name})]}),e.jsx("button",{onClick:t,className:"rounded-lg p-1.5 text-slate-400 hover:bg-slate-100","aria-label":"Close",children:e.jsx(ce,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-5",children:[e.jsx(Me,{label:"Name",children:e.jsx("input",{className:De,value:i.name??"",onChange:n=>h("name",n.target.value)})}),e.jsx(Me,{label:"ICP / audience",hint:"Who this campaign targets — feeds every agent's messaging.",children:e.jsx("textarea",{className:`${De} h-24`,value:i.audience??"",onChange:n=>h("audience",n.target.value),placeholder:"e.g. Founders at seed/Series A B2B SaaS who run their own outbound"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Me,{label:"Status",children:e.jsx("select",{className:De,value:i.status,onChange:n=>h("status",n.target.value),children:Ia.map(n=>e.jsx("option",{value:n,children:n},n))})}),e.jsx(Me,{label:"Daily send target",children:e.jsx("input",{type:"number",min:1,max:100,className:De,value:i.daily_send_target??0,onChange:n=>h("daily_send_target",Number(n.target.value))})})]}),e.jsx(Me,{label:"Business unit",children:e.jsx("input",{className:De,value:i.business_unit??"",onChange:n=>h("business_unit",n.target.value)})}),e.jsx(Me,{label:"Sending inboxes",children:e.jsxs("div",{className:"rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-500",children:[i.instantly_sender?e.jsx("span",{className:"text-slate-700",children:i.instantly_sender}):"None chosen yet."," Managed in the client's ",e.jsx("strong",{children:"Sending setup"}),", where inboxes are picked from the Instantly workspace so they're real and warmed."]})})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-slate-200 p-4",children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:d,disabled:r,className:"rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50",children:r?"Saving…":"Save settings"})]})]})]})}const De="w-full rounded-lg border border-slate-200 px-3 py-2 text-sm outline-none focus:border-brand-400 focus:ring-2 focus:ring-brand-100";function Me({label:s,hint:t,children:a}){return e.jsxs("label",{className:"block",children:[e.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-500",children:s}),t&&e.jsx("div",{className:"mb-1.5 text-xs text-slate-400",children:t}),a]})}const Ms={high:{label:"Strong signal",cls:"bg-emerald-50 text-emerald-700 ring-emerald-200"},medium:{label:"Good signal",cls:"bg-amber-50 text-amber-700 ring-amber-200"},low:{label:"Weak signal",cls:"bg-slate-100 text-slate-500 ring-slate-200"}};function lt({set:s,fallbackLines:t,onGenerate:a,onRun:i,running:m,busy:r,leadCounts:u,canGenerate:h=!0,emptyHint:d}
216){var L,k;const[n,x]=l.useState(!1),v=async()=>{x(!0);try{await a()}finally{x(!1)}},o=(L=s==null?void 0:s.signals)!=null&&L.length?s.signals:(t||[]).map(E=>({signal:E,why_now:"",detect_via:[],window_days:60,priority:"medium",query:E})),j=!!((k=s==null?void 0:s.signals)!=null&&k.length);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 text-brand-600"}),e.jsx("h3",{className:"text-sm font-semibold text-slate-800",children:"Intent signals"}),e.jsx("span",{className:"text-xs text-slate-400",children:"· the moments that make this ICP buy now — what the research bot hunts"})]}),h&&e.jsxs("button",{onClick:()=>void v(),disabled:n||!!r,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[n?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(me,{className:"h-3.5 w-3.5"})," ",j?"Regenerate from ICP":"Generate from ICP"]})]}),(s==null?void 0:s.rationale)&&j&&e.jsx("p",{className:"mt-2 text-xs text-slate-500",children:s.rationale}),o.length===0?e.jsx("p",{className:"mt-3 rounded-xl border border-dashed border-slate-200 p-4 text-sm text-slate-500",children:d||"No signals yet. Generate them from the ICP — the bot will then know exactly which moments to look for."}):e.jsx("ul",{className:"mt-3 grid gap-2 lg:grid-cols-2",children:o.map(E=>{const I=Ms[E.priority]||Ms.medium,T=(u==null?void 0:u[E.query])??0,$=m===E.query;return e.jsxs("li",{className:"flex flex-col gap-2 rounded-xl border border-slate-200 p-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-900",children:E.signal}),E.why_now&&e.jsx("p",{className:"mt-0.5 text-xs leading-snug text-slate-600",children:E.why_now})]}),e.jsx("span",{className:`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold ring-1 ${I.cls}`,children:I.label})]}),j&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-slate-500",children:[E.detect_via.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(is,{className:"h-3 w-3"})," ",E.detect_via.join(" · ")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Yt,{className:"h-3 w-3"})," within ",E.window_days," days"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-slate-100 pt-2",children:[e.jsxs("span",{className:"truncate text-[11px] text-slate-400",title:E.query,children:[T?`${T} lead${T===1?"":"s"} found`:"not researched yet",j?` · brief: ${E.query}`:""]}),i&&e.jsx("button",{onClick:()=>i(E),disabled:!!r,className:"inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 transition hover:border-brand-300 hover:text-brand-700 disabled:opacity-50",children:$?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"})," Searching…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"h-3.5 w-3.5"})," Run"]})})]})]},E.query)})})]})}function Ra({campaign:s,onChanged:t}){const[a,i]=l.useState(!1),m=n=>typeof n=="string"?n.split("</parameter>")[0].split("<parameter")[0].trim():n,r=s.strategy?{...s.strategy,thesis:m(s.strategy.thesis),positioning:m(s.strategy.positioning),offer_framing:m(s.strategy.offer_framing)}:s.strategy,u=r?{...r,positioning:r.positioning||"",offer_framing:r.offer_framing||"",channels:r.channels||[],angles:r.angles||[],sequence_plan:r.sequence_plan||[],experiments:r.experiments||[],kpis:r.kpis||[]}:null,h=!!r&&!(r.channels&&r.angles&&r.sequence_plan&&r.kpis),d=async()=>{i(!0);
216try{await C.generateStrategy(s.id),t()}finally{i(!1)}};return u?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs text-slate-500",children:["Generated ",he(u.generated_at)," · optimized for conversations started",h&&e.jsx("span",{className:"ml-2 font-medium text-amber-600",children:"This strategy is incomplete — regenerate it."})]}),e.jsxs("button",{onClick:d,disabled:a,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-sm font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50",children:[e.jsx(ke,{className:`h-4 w-4 ${a?"animate-spin":""}`})," Regenerate"]})]}),s.learning&&e.jsx(Pa,{campaign:s,learning:s.learning,onChanged:t}),e.jsxs(W,{className:"p-5",children:[e.jsx(fe,{icon:Es,children:"Thesis"}),e.jsx("p",{className:"text-sm leading-relaxed text-slate-700",children:u.thesis}),e.jsx(fe,{icon:Es,className:"mt-4",children:"Positioning"}),e.jsx("p",{className:"text-sm leading-relaxed text-slate-700",children:u.positioning})]}),e.jsx(W,{className:"p-5",children:e.jsx(lt,{set:u.intent_triggers??null,onGenerate:async()=>{await C.generateIntentSignals({campaignId:s.id}),t()},emptyHint:"No intent signals yet. Generate them from this campaign's ICP; research itself runs from the client page."})}),e.jsxs(W,{className:"p-5",children:[e.jsx(fe,{icon:fs,children:"Channel plan"}),e.jsx("div",{className:"space-y-2",children:u.channels.map(n=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-slate-100 p-3",children:[e.jsxs(ae,{className:n.priority==="primary"?"bg-brand-100 text-brand-700 ring-brand-600/20":"bg-slate-100 text-slate-500 ring-slate-400/20",children:[n.channel," · ",n.priority]}),e.jsx("span",{className:"text-sm text-slate-600",children:n.rationale})]},n.channel))})]}),e.jsxs(W,{className:"p-5",children:[e.jsx(fe,{icon:Ls,children:"Conversation-starter angles"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:u.angles.map(n=>e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-800",children:n.name}),e.jsx("div",{className:"mt-1 text-xs text-slate-500",children:n.hypothesis}),e.jsxs("div",{className:"mt-2 rounded bg-slate-50 p-2 text-xs italic text-slate-600",children:["“",n.opener,"”"]})]},n.name))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(W,{className:"p-5",children:[e.jsx(fe,{icon:fs,children:"Sequence plan"}),e.jsx("ol",{className:"space-y-2",children:u.sequence_plan.map(n=>e.jsxs("li",{className:"flex items-center gap-3 text-sm",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-brand-100 text-xs font-semibold text-brand-700",children:n.step}),e.jsxs("span",{className:"w-20 shrink-0 text-xs font-medium text-slate-500",children:[n.channel," · ",n.timing]}),e.jsx("span",{className:"text-slate-700",children:n.intent})]},n.step))}),e.jsx(fe,{icon:Ls,className:"mt-4",children:"Offer framing"}),e.jsx("p",{className:"text-sm leading-relaxed text-slate-700",children:u.offer_framing})]}),e.jsxs(W,{className:"p-5",children:[e.jsx(fe,{icon:Zt,children:"Experiments"}),e.jsx("ul",{className:"space-y-2",children:u.experiments.map((n,x)=>e.jsxs("li",{className:"rounded-lg border border-slate-100 p-2.5 text-sm",children:[e.jsx("div",{className:"text-slate-700",children:n.test}),e.jsxs("div",{className:"mt-0.5 text-xs text-emerald-600",children:["metric: ",n.metric]})]},x))}),e.jsx(fe,{icon:Xt,className:"mt-4",children:"KPIs"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.kpis.map(n=>e.jsx(ae,{className:"bg-slate-100 text-slate-600 ring-slate-400/20",children:n},n))})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ee,{icon:me,title:"No strategy yet",hint:"Generate an intelligent GTM + outreach strategy from this campaign's ICP — built to start conversations."}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("button",{onClick:d,disabled:a,className:"inline-flex items-center gap-2 rounded-lg bg-brand-600 px-5 py-2.5 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50",children:[e.jsx(me,{className:"h-4 w-4"})," ",a?"Generating…":"Generate GTM strategy"]}
216)})]})}function Pa({campaign:s,learning:t,onChanged:a}){const[i,m]=l.useState(""),r=[...t.results].sort((n,x)=>x.conversations/x.prospects-n.conversations/n.prospects),u=Math.max(...r.map(n=>n.conversations/n.prospects),1e-4),h=t.results.some(n=>n.status==="winner"),d=async n=>{m(n);try{await C.promoteAngle(s.id,n),a()}finally{m("")}};return e.jsxs(W,{className:"border-brand-200 bg-brand-50/40 p-5",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsx(fe,{icon:Pt,children:"Learning loop · conversations started"}),e.jsxs("span",{className:"text-[11px] text-slate-400",children:["updated ",he(t.updated_at)]})]}),e.jsx("p",{className:"mb-3 text-sm text-slate-600",children:t.recommendation}),e.jsx("div",{className:"space-y-2",children:r.map(n=>{const x=n.conversations/n.prospects*100,v=n===r[0];return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"w-44 shrink-0 text-sm font-medium text-slate-700",children:[n.status==="winner"&&e.jsx(ca,{className:"mr-1 inline h-3.5 w-3.5 text-amber-500"}),n.angle]}),e.jsx("div",{className:"h-2.5 flex-1 overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:`h-full rounded-full ${n.status==="winner"?"bg-amber-500":v?"bg-brand-500":"bg-slate-300"}`,style:{width:`${x/u*100}%`}})}),e.jsxs("div",{className:"w-16 shrink-0 text-right text-xs text-slate-500",children:[x.toFixed(1),"/100"]}),!h&&e.jsx("button",{onClick:()=>d(n.angle),disabled:i!=="",className:"shrink-0 rounded-md border border-brand-200 bg-white px-2 py-1 text-xs font-medium text-brand-700 hover:bg-brand-50 disabled:opacity-50",children:i===n.angle?"…":"Promote"})]},n.angle)})}),h&&e.jsx("div",{className:"mt-3 text-xs text-emerald-600",children:"✓ Winner promoted — the Copywriter now leads with it. Regenerate the strategy to build the next round of tests."})]})}function fe({icon:s,children:t,className:a=""}){return e.jsxs("div",{className:`mb-2 flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-slate-400 ${a}`,children:[e.jsx(s,{className:"h-3.5 w-3.5"})," ",t]})}function Da({campaignId:s,staffedKeys:t,onToggle:a,onClose:i}){const[m,r]=l.useState(new Set(t)),[u,h]=l.useState(""),d=async x=>{const v=!m.has(x);h(x);const o=new Set(m);v?o.add(x):o.delete(x),r(o);try{await a(s,x,v)}catch{r(new Set(m))}finally{h("")}},n=[...m].reduce((x,v)=>x+ue(v).budgetUsd,0);return e.jsxs("div",{className:"fixed inset-0 z-40 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/30",onClick:i}),e.jsxs("aside",{className:"relative z-10 flex h-full w-full max-w-2xl flex-col bg-canvas shadow-pop",children:[e.jsxs("div",{className:"flex items-start justify-between border-b border-slate-200 bg-white px-6 py-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold text-slate-800",children:"Staff your experts"}),e.jsxs("div",{className:"text-sm text-slate-500",children:[m.size," on this campaign · est. ",se(n),"/mo"]})]}),e.jsx("button",{onClick:i,className:"rounded-lg p-1.5 text-slate-400 hover:bg-slate-100","aria-label":"Close",children:e.jsx(ce,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"border-b border-slate-200 bg-brand-50/50 px-6 py-2.5 text-xs text-slate-600",children:"Paperclip + Claude orchestrate whichever experts you staff — coordinating them to keep the project moving forward as much as possible. Each expert applies a named, best-in-class business playbook."}),e.jsx("div",{className:"flex-1 space-y-6 overflow-y-auto p-6",children:St.map(x=>{const v=bs.filter(o=>o.department===x);return e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-slate-400",children:x}),e.jsx("div",{className:"space-y-2",children:v.map(o=>{const j=m.has(o.key);return e.jsxs("div",{className:`flex items-start gap-3 rounded-xl border bg-white p-3 transition ${j?"border-brand-300 ring-1 ring-brand-200":"border-slate-200"}`,children:[e.jsx(Ve,{role:o.key,className:"h-9 w-9 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-slate-800",children:o.label}),o.core&&e.jsx("span",{className:"rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-500",children:"core"})]}),e.jsx("div",{className:"text-xs text-slate-500",children:o.mission}),e.jsx("div",{className:"mt-1 text-[11px] italic text-brand-700/80",children:us(o.key)}),e.jsxs("div",{className:"mt-1 text-[11px] text-slate-400",children:["KPI: ",o.kpis.join(" · ")," · ",o.model.replace("claude-","")," · ",se(o.budgetUsd),"/mo"]})]}),e.jsxs("button",{onClick:()=>d(o.key),disabled:u===o.key,className:`shrink-0 inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-sm font-medium transition disabled:opacity-50 ${j?"bg-brand-600 text-white hover:bg-brand-700":"border border-slate-200 bg-white text-slate-600 hover:bg-slate-50"}`,children:[j?e.jsx(we,{className:"h-4 w-4"}):e.jsx(ds,{className:"h-4 w-4"}),j?"On":"Add"]})]},o.key)})})]},x)})}),e.jsx("div",{className:"flex justify-end border-t border-slate-200 bg-white px-6 py-3",children:e.jsx("button",{onClick:i,className:"rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700",children:"Done"})})]})]})}function Ta({campaignId:s}){const[t,a]=l.useState(null),[i,m]=l.useState(!1),[r,u]=l.useState(!1),[h,d]=l.useState(!1);l.useEffect(()=>{let v=!0;return C.latestBriefing(s).then(o=>{v&&(a(o),d(!0))}),()=>{v=!1}},[s]);const n=async()=>{m(!0);try{a(await C.generateBriefing(s))}catch{}finally{m(!1)}},x=t==null?void 0:t.body;return e.jsxs("div",{className:"rounded-xl border border-brand-200 bg-gradient-to-br from-brand-50 to-white p-5 shadow-card",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-brand-700",children:[e.jsx(Dt,{className:"h-4 w-4"})," Next Move",t&&e.jsxs("span",{className:"ml-1 font-normal normal-case text-slate-400",children:["· updated ",he(t.created_at)]})]}),e.jsxs(ie,{variant:"primary",size:"sm",onClick:n,disabled:i,children:[e.jsx(ke,{className:`h-4 w-4 ${i?"animate-spin":""}`}
216)," ",i?"Thinking…":"Ask now"]})]}),!x&&e.jsx("p",{className:"text-sm text-slate-500",children:h?"Ask your team what to do next on this project.":"Loading…"}),x&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-lg font-semibold leading-snug text-slate-800",children:x.headline}),e.jsx("p",{className:"mt-1 text-sm text-slate-600",children:x.why_now}),x.actions.length>0&&e.jsx("ol",{className:"mt-3 space-y-1.5",children:x.actions.map((v,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-slate-700",children:[e.jsx("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-brand-600 text-xs font-semibold text-white",children:o+1}),v]},o))}),e.jsxs("button",{onClick:()=>u(v=>!v),className:"mt-3 inline-flex items-center gap-1 text-xs font-medium text-brand-600 hover:underline",children:[r?"Hide":"Show"," the full read ",e.jsx(Cs,{className:`h-3.5 w-3.5 transition ${r?"rotate-180":""}`})]}),r&&e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsx(Xe,{title:"Working",items:x.working,tone:"emerald"}),e.jsx(Xe,{title:"Stuck",items:x.stuck,tone:"amber"}),e.jsx(Xe,{title:"Risks",items:x.risks,tone:"red"}),e.jsx(Xe,{title:"Opportunities",items:x.opportunities,tone:"brand"})]})]})]})}function Xe({title:s,items:t,tone:a}){if(!t||t.length===0)return null;const i={emerald:"bg-emerald-500",amber:"bg-amber-500",red:"bg-red-500",brand:"bg-brand-500"}[a];return e.jsxs("div",{className:"rounded-lg border border-slate-100 bg-white p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx(ze,{className:"h-3 w-3"})," ",s]}),e.jsx("ul",{className:"space-y-1",children:t.map((m,r)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-slate-600",children:[e.jsx("span",{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${i}`}),m]},r))})]})}const Je=({icon:s,label:t,children:a})=>e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx(s,{className:"h-3.5 w-3.5"})," ",t]}),e.jsx("div",{className:"mt-1 text-sm text-slate-800",children:a})]}),Rs=s=>String(s||"").replace(/^https?:\/\//,"").replace(/^www\./,"").split("/")[0];function qa({campaign:s}){const t=Re(),[a,i]=l.useState(void 0),[m,r]=l.useState(!1);l.useEffect(()=>{let n=!1;return C.getClientByCampaign(s.id).then(x=>{n||i(x)}).catch(()=>{n||i(null)}),()=>{n=!0}},[s.id]);const u=String(s.instantly_sender||"").split(",").map(n=>n.trim()).filter(n=>n.includes("@")),h=!!s.instantly_campaign_id,d=async n=>{r(!0);try{const x=await C.createClientFromCampaign(s.id,n);t(`/clients/${x.id}`)}finally{r(!1)}};return e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-card",children:[e.jsxs("div",{className:"grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Je,{icon:Se,label:"Client",children:a===void 0?e.jsx("span",{className:"text-slate-400",children:"…"}):a?e.jsxs(K,{to:`/clients/${a.id}`,className:"inline-flex items-center gap-1 font-medium text-brand-700 hover:underline",children:[a.company||a.name," ",e.jsx(Qs,{className:"h-3.5 w-3.5"})]}):e.jsx("span",{className:"text-slate-500",children:"Not linked to a client"})}),e.jsx(Je,{icon:Vs,label:"Website",children:a!=null&&a.website?e.jsx("a",{href:a.website.startsWith("http")?a.website:`https://${a.website}`,target:"_blank",rel:"noopener noreferrer",className:"text-brand-700 hover:underline",children:Rs(a.website)}):a?e.jsx(K,{to:`/clients/${a.id}`,className:"text-slate-400 hover:text-brand-600",children:"add on the client page"}):e.jsx("span",{className:"text-slate-400",children:"—"})}),e.jsx(Je,{icon:ss,label:"Sends from",children:u.length?e.jsxs("span",{title:u.join(", "),children:[u.length," inbox",u.length===1?"":"es"," ",e.jsxs("span",{className:"text-slate-400",children:["· ",Rs(u[0].split("@")[1]),u.length>1?" …":""]})]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-700",children:[e.jsx(Ks,{className:"h-3.5 w-3.5"})," no inboxes chosen"]})}),e.jsx(Je,{icon:ts,label:"Instantly",children:h?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-xs font-semibold text-emerald-700 ring-1 ring-emerald-200",children:[e.jsx(we,{className:"h-3.5 w-3.5"})," Connected"]}):e.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-slate-100 px-2 py-0.5 text-xs font-semibold text-slate-500 ring-1 ring-slate-200",children:"Not connected"})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-slate-100 pt-4",children:[e.jsx("p",{className:"text-xs text-slate-500",children:a?"Inboxes, the Instantly campaign, replies, and launch are all managed in this client's Sending setup.":"This campaign has no workspace yet. Give it one to get intent signals, research, email finding, sequences, Sending setup, and reports. Is it one of your own brands, or a paying customer?"}),a?e.jsxs(K,{to:`/clients/${a.id}`,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 py-2 text-sm font-semibold text-white hover:bg-brand-500",children:[e.jsx(ss,{className:"h-4 w-4"})," Open Sending setup"]}):a===null?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>void d("own"),disabled:m,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 py-2 text-sm font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[m?e.jsx(G,{className:"h-4 w-4 animate-spin"}):e.jsx(me,{className:"h-4 w-4"})," One of my brands"]}),e.jsxs("button",{onClick:()=>void d("customer"),disabled:m,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3.5 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[e.jsx(Se,{className:"h-4 w-4"})," A customer"]})]}):null]})]})}const Oa=[{id:"strategy",label:"Strategy",icon:me},{id:"team",label:"Team",icon:Se},{id:"pipeline",label:"Pipeline",icon:st},{id:"approvals",label:"Approvals",icon:Ae},{id:"recording",label:"Recording",icon:Jt}];function za(){const{slug:s}=Hs(),[t,a]=l.useState(null),[i,m]=l.useState([]),[r,u]=l.useState([]),[h,d]=l.useState([]),[n,x]=l.useState("strategy"),[v,o]=l.useState(null),[j,L]=l.useState(!1),[k,E]=l.useState(!1),[I,T]=l.useState(!1),[$,N]=l.useState(null),w=_e(),{role:b}=Le(),B=Re(),[z,X]=l.useState(!1),[A,V]=l.useState(0);if(l.useEffect(()=>{let f=!0;return(async()=>{const O=(await C.listCampaignsWithAgents().catch(()=>[])).find(J=>J.slug===s)??null;f&&(a(O),T(!0),O&&(C.listProspects(O.id).then(J=>f&&m(J)),C.listApprovalViews(O.id).then(J=>f&&u(J)),C.listActivity(O.id).then(J=>f&&d(J))))})(),()=>{f=!1}},[s,A]),!t)return I?e.jsxs("div",{className:"py-20 text-center",children:[e.jsx("div",{className:"text-slate-700",children:"No campaign at this address."}),e.jsx(K,{to:"/campaigns",className:"mt-2 inline-block text-sm text-brand-600 underline",children:"Back to campaigns"})]}):e.jsx("div",{className:"py-20 text-center text-slate-500",children:"Loading c
216ampaign…"});const g=Math.round(t.spend_mtd_usd/t.monthly_budget_usd*100),H=i.filter(f=>f.stage==="warm").length,y=async(f,R)=>{if(!$){N(f);try{await C.decideApproval(f,R,await ws()),w.success(R==="approved"?"Approved.":R==="revised"?"Sent back.":"Rejected."),V(O=>O+1)}catch(O){w.error(te(O))}finally{N(null)}}},Y=async f=>{if(!$){N("status");try{await C.updateCampaign(t.id,{status:f}),w.success(f==="live"?"Campaign resumed.":"Campaign paused."),V(R=>R+1)}catch(R){w.error(te(R))}finally{N(null)}}},Z=r.filter(f=>f.approval.state==="pending");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs(K,{to:"/campaigns",className:"inline-flex items-center gap-1 text-sm text-slate-500 hover:text-brand-600",children:[e.jsx(Gs,{className:"h-4 w-4"})," Campaigns"]}),e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-800",children:t.name}),e.jsx(ae,{className:Ht[t.status],children:t.status})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-slate-400",children:[t.business_unit&&e.jsx("span",{className:"text-slate-500",children:t.business_unit}),e.jsxs("span",{children:[t.daily_send_target,"/day target"]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(ie,{variant:"secondary",onClick:()=>L(!0),children:[e.jsx(tt,{className:"h-4 w-4"})," Settings"]}),b==="admin"&&e.jsxs(ie,{variant:"secondary",onClick:()=>E(!0),title:"Delete this campaign permanently (asks you to type DELETE)",children:[e.jsx(Ce,{className:"h-4 w-4"})," Delete"]}),k&&e.jsx(cs,{kind:"campaign",id:t.id,onClose:()=>E(!1),onDeleted:()=>B("/campaigns")}),t.status==="paused"?e.jsxs(ie,{variant:"success",onClick:()=>void Y("live"),children:[e.jsx(Ge,{className:"h-4 w-4"})," Resume"]}):e.jsxs(ie,{variant:"secondary",onClick:()=>void Y("paused"),children:[e.jsx(gs,{className:"h-4 w-4"})," Pause"]})]})]}),e.jsx(qa,{campaign:t}),e.jsx(Ta,{campaignId:t.id}),e.jsx(Ba,{text:t.audience}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-4",children:[e.jsxs(W,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-500",children:"Prospects"}),e.jsx("div",{className:"mt-1 text-xl font-semibold text-slate-800",children:i.length})]}),e.jsxs(W,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-500",children:"Conversations"}),e.jsx("div",{className:"mt-1 text-xl font-semibold text-emerald-600",children:H})]}),e.jsxs(W,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-slate-500",children:"Daily target"}),e.jsxs("div",{className:"mt-1 text-xl font-semibold text-slate-800",children:[t.daily_send_target,"/day"]})]}),e.jsxs(W,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs uppercase tracking-wide text-slate-500",children:[e.jsx("span",{children:"AI spend (MTD)"}),t.spend_mtd_usd>0&&e.jsxs("span",{className:g>=80?"text-amber-600":"text-slate-400",children:[g,"%"]})]}),e.jsx("div",{className:"mt-1 text-xl font-semibold text-slate-800",children:t.spend_mtd_usd>0?e.jsxs(e.Fragment,{children:[se(t.spend_mtd_usd)," ",e.jsxs("span",{className:"text-sm font-normal text-slate-400",children:["/ ",se(t.monthly_budget_usd)]})]}):e.jsx("span",{className:"text-base font-medium text-slate-400",children:"not tracked yet"})}),t.spend_mtd_usd>0&&e.jsx("div",{className:"mt-2",children:e.jsx(ns,{pct:g,tone:g>=80?"amber":"brand"})})]})]}),e.jsx("div",{className:"flex gap-1 border-b border-slate-200",children:Oa.map(({id:f,label:R,icon:O})=>{const J=f==="approvals"?r.length:void 0;return e.jsxs("button",{onClick:()=>x(f),className:`inline-flex items-center gap-2 border-b-2 px-4 py-2.5 text-sm font-medium transition ${n===f?"border-brand-600 text-brand-700":"border-transparent text-slate-500 hover:text-slate-700"}`,children:[e.jsx(O,{className:"h-4 w-4"})," ",R,J?e.jsx("span",{className:"rounded-full bg-amber-100 px-1.5 text-xs text-amber-700",children:J}):null]},f)})}),n==="strategy"&&e.jsx(Ra,{campaign:t,onChanged:()=>V(f=>f+1)}),n==="team"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:[t.agents.length," experts staffed · est."," ",se(t.agents.reduce((f,R)=>f+R.monthly_budget_usd,0)),"/mo"]}),e.jsxs(ie,{variant:"primary",onClick:()=>X(!0),children:[e.jsx(Tt,{className:"h-4 w-4"})," Manage experts"]}
216)]}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[...t.agents].sort((f,R)=>bs.findIndex(O=>O.key===f.role)-bs.findIndex(O=>O.key===R.role)).map(f=>{const R=f.monthly_budget_usd?Math.round(f.spend_mtd_usd/f.monthly_budget_usd*100):0;return e.jsx("button",{onClick:()=>o(f),className:"text-left",children:e.jsxs(W,{className:"h-full p-4 transition hover:shadow-pop",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ve,{role:f.role}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-800",children:ue(f.role).label}),e.jsx("div",{className:"text-xs text-slate-400",children:f.model.replace("claude-","")})]})]}),e.jsx(Zs,{className:"h-4 w-4 text-slate-300"})]}),e.jsx("div",{className:"mt-3",children:e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${Us[f.status]}`,children:Ws[f.status]})}),e.jsx("div",{className:"mt-2 line-clamp-2 min-h-[2.5rem] text-sm text-slate-600",children:f.current_task??ue(f.role).mission}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"mb-1 flex justify-between text-xs text-slate-500",children:[e.jsxs("span",{children:[se(f.spend_mtd_usd)," / ",se(f.monthly_budget_usd)]}),e.jsxs("span",{children:[R,"%"]})]}),e.jsx(ns,{pct:R,tone:R>=80?"amber":"brand"})]})]})},f.id)})})]}),n==="pipeline"&&e.jsx(W,{className:"overflow-hidden",children:i.length===0?e.jsx(Ee,{icon:st,title:"No prospects yet",hint:"The Prospector will populate this."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[46rem] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500",children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Prospect"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Stage"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Angle"}),e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Pain hypothesis"})]})}),e.jsx("tbody",{children:i.map(f=>{var R;return e.jsxs("tr",{className:"border-b border-slate-100 last:border-0 align-top hover:bg-slate-50",children:[e.jsxs("td",{className:"px-5 py-3",children:[e.jsx("div",{className:"font-medium text-slate-800",children:f.company}),e.jsxs("div",{className:"text-xs text-slate-500",children:[f.contact_name," · ",f.title]})]}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${Gt[f.stage]}`,children:f.stage})}),e.jsx("td",{className:"px-3 py-3 text-slate-600",children:f.angle}),e.jsx("td",{className:"px-5 py-3 text-slate-600",children:(R=f.dossier)==null?void 0:R.pain_hypothesis})]},f.id)})})]})})}),n==="approvals"&&e.jsx("div",{className:"space-y-4",children:Z.length===0?e.jsx(Ee,{icon:Ae,title:"Nothing to approve",hint:"Drafts from the Copywriter land here."}):Z.map(({approval:f,prospect:R})=>e.jsxs(W,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-800",children:R==null?void 0:R.company}),e.jsxs("div",{className:"text-xs text-slate-500",children:[R==null?void 0:R.contact_name," · ",R==null?void 0:R.title," · ",f.methodology.framework]})]}),e.jsx(ae,{className:"bg-amber-100 text-amber-700 ring-amber-600/20",children:f.state})]}),e.jsxs("div",{className:"mt-2 rounded-lg bg-slate-50 p-3 text-xs text-slate-500",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Methodology:"})," ",f.methodology.notes]}),e.jsx("div",{className:"mt-3 space-y-3",children:f.sequence.map(O=>e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3",children:[e.jsx("div",{className:"mb-1 flex items-center justify-between",children:e.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-400",children:["Step ",O.step," · day ",O.send_day]})}),e.jsx("div",{className:"text-sm font-medium text-slate-800",children:O.subject}),e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-sm text-slate-600",children:O.body})]},O.step))}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx(ie,{variant:"primary",onClick:()=>void y(f.id,"approved"),children:"Approve"}),e.jsx(ie,{variant:"secondary",onClick:()=>void y(f.id,"revised"),children:"Revise"}),e.jsx(ie,{variant:"danger",onClick:()=>void y(f.id,"rejected"),children:"Reject"})]})]},f.id))}),n==="recording"&&e.jsxs(W,{className:"p-5",children:[e.jsx(ye,{children:"Campaign recording"}),h.length===0?e.jsx("div",{className:"text-sm text-slate-500",children:"No recorded activity yet."}):e.jsx("ol",{className:"relative ml-3 border-l border-slate-200",children:h.map(f=>e.jsxs("li",{className:"mb-5 ml-5 last:mb-0",children:[e.jsx("span",{className:"absolute -left-[7px] mt-1 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-brand-500 ring-4 ring-white"}),e.jsxs("div",{className:"flex items-center gap-2",children:[f.agent_role&&e.jsx("span",{className:"text-xs font-medium text-slate-700",children:We[f.agent_role]}
216),e.jsx("span",{className:"text-[11px] text-slate-400",children:he(f.created_at)})]}),e.jsx("div",{className:"mt-0.5 text-sm text-slate-600",children:f.message})]},f.id))})]}),H>0&&n==="team"&&e.jsxs(W,{className:"p-4",children:[e.jsx(ye,{children:"Warm leads"}),e.jsx("div",{className:"space-y-2",children:i.filter(f=>f.stage==="warm").map(f=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-emerald-50/60 px-3 py-2",children:[e.jsxs("div",{className:"text-sm font-medium text-slate-800",children:[f.company," · ",e.jsx("span",{className:"font-normal text-slate-500",children:f.contact_name})]}),e.jsxs(ae,{className:`${ks.warm} ring-0`,children:["warm · ",f.angle]})]},f.id))})]}),v&&e.jsx(Ea,{agent:v,campaign:t,prospects:i,activity:h.filter(f=>f.agent_role===v.role),onClose:()=>o(null)}),j&&e.jsx(Ma,{campaign:t,onClose:()=>L(!1),onSaved:()=>V(f=>f+1)}),z&&e.jsx(Da,{campaignId:t.id,staffedKeys:t.agents.map(f=>f.role),onToggle:async(f,R,O)=>{O?await C.staffAgent(f,R):await C.unstaffAgent(f,R),V(J=>J+1)},onClose:()=>X(!1)})]})}function Ba({text:s}){const[t,a]=l.useState(!1),i=s.length>180;return e.jsxs(W,{className:"p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Ideal Customer Profile"}),i&&e.jsx("button",{onClick:()=>a(m=>!m),className:"shrink-0 text-xs font-medium text-brand-600 hover:underline",children:t?"Show less":"Show more"})]}),e.jsx("p",{className:`text-sm leading-relaxed text-slate-600 ${t?"":"line-clamp-2"}`,children:s})]})}const $e={onboarding:{label:"Onboarding",cls:"bg-amber-50 text-amber-700 ring-1 ring-amber-200",dot:"bg-amber-500"},live:{label:"Live",cls:"bg-emerald-50 text-emerald-700 ring-1 ring-emerald-200",dot:"bg-emerald-500"},paused:{label:"Paused",cls:"bg-slate-100 text-slate-500 ring-1 ring-slate-200",dot:"bg-slate-400"}};function it(s){const t=ls(s.checklist);switch(s.stage){case"onboarding":return[{key:"go-live",label:"Mark live",next:"live",tone:t?"success":"secondary",hint:t?void 0:"Go-live steps are not all done yet"},{key:"pause",label:"Pause",next:"paused",tone:"secondary"}];case"live":return[{key:"pause",label:"Pause",next:"paused",tone:"secondary"}];case"paused":return[{key:"resume",label:"Resume",next:Ps(s),tone:"success",hint:`Back to ${$e[Ps(s)].label.toLowerCase()}`}]}}const Ps=s=>ls(s.checklist)?"live":"onboarding",Ds={live:0,onboarding:1,paused:2};function Fa(s){const t=[];return typeof s.monthly=="number"&&s.monthly>0&&t.push(`${se(s.monthly)}/mo`),s.services&&t.push(s.services.split("·").map(a=>a.trim()).filter(Boolean).slice(0,3).join(" · ")),t.join(" · ")}function Ha({p:s}){if(!s)return e.jsx("span",{className:"text-xs text-slate-300",children:"—"});const t=[s.toReview>0&&{icon:Ue,n:s.toReview,label:"to review",cls:"bg-brand-50 text-brand-700"},s.needEmail>0&&{icon:Be,n:s.needEmail,label:"need email",cls:"bg-amber-50 text-amber-700"},s.pendingApprovals>0&&{icon:Ae,n:s.pendingApprovals,label:"to approve",cls:"bg-amber-50 text-amber-700"},s.warm>0&&{icon:He,n:s.warm,label:"warm",cls:"bg-emerald-50 text-emerald-700"}].filter(Boolean);return t.length===0?e.jsx("span",{className:"text-xs text-slate-400",children:s.leads?`${s.leads} lead${s.leads===1?"":"s"} · clear`:"no leads yet"}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(a=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-semibold ${a.cls}`,children:[e.jsx(a.icon,{className:"h-3 w-3"})," ",a.n," ",a.label]},a.label))})}function Ga(){const s=Re(),t=_e(),[a,i]=qt(),{role:m}=Le(),[r,u]=l.useState(a.get("new")==="1"),[h,d]=l.useState(""),[n,x]=l.useState("customer"),v=m==="admin",[o,j]=l.useState([]),[L,k]=l.useState([]),[E,I]=l.useState({}),[T,$]=l.useState(!0),[N,w]=l.useState(!1),[b,B]=l.useState(a.get("q")||""),[z,X]=l.useState("all"),[A,V]=l.useState(null),[g,H]=l.useState(null),y=async()=>{$(!0);try{const[S,F]=await Promise.all([C.listSignups(),C.listClients()]);j(S.filter(M=>M.status!=="converted")),k(F),C.clientPipeline().then(I).catch(()=>I({}))}finally{$(!1)}};l.useEffect(()=>{y()},[]),l.useEffect(()=>{const S=()=>V(null);return window.addEventListener("click",S),()=>window.removeEventListener("click",S)},[]);const Y=async S=>{w(!0);try{const F=await C.createClientFromSignup(S);t.success("Client created — onboarding checklist is ready."),s(`/clients/${F.id}`)}catch(F){t.error(te(F))}finally{w(!1)}},Z=async()=>{const S=h.trim();if(S){w(!0);try{const F=await C.createBlankClient(S);n==="own"&&await C.updateClient(F.id,{kind:"own"}).catch(()=>{}),u(!1),d(""),a.delete("new"),i(a,{replace:!0}),s(`/clients/${F.id}`)}catch(F){t.error(te(F))}finally{w(!1)}}},f=async(S,F)=>{const M=S.stage;k(ne=>ne.map(c=>c.id===S.id?{...c,stage:F}:c));try{await C.updateClient(S.id,{stage:F}),t.success(`${S.company||S.name}: ${$e[F].label.toLowerCase()}.`)}catch(ne){k(c=>c.map(_=>_.id===S.id?{..._,stage:M}:_)),t.error(te(ne))}},R=l.useMemo(()=>({live:L.filter(S=>S.stage==="live").length,onboarding:L.filter(S=>S.stage==="onboarding").length,paused:L.filter(S=>S.stage==="paused").length}),[L]),O=S=>S.kind==="own"?"own":"customer",J=l.useMemo(()=>{const S=b.trim().toLowerCase();return L.filter(F=>z==="all"||F.stage===z).filter(F=>!S||[F.company,F.name,F.email,F.industry].some(M=>(M||"").toLowerCase().includes(S))).sort((F,M)=>(Ds[F.stage]??9)-(Ds[M.stage]??9)||(F.company||F.name||"").localeCompare(M.company||M.name||""))},[L,z,b]);return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.18em] text-brand-600",children:[e.jsx(Se,{className:"h-3.5 w-3.5"})," Delivery"]}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-tight text-slate-900",children:"Clients"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Every customer, where they are, and what needs a human next."})]}),e.jsxs("button",{onClick:()=>u(!0),disabled:N,className:"inline-flex items-center gap-2 rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-50",children:[e.jsx(ds,{className:"h-4 w-4"})," Add client"]})]}),o.length>0&&e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-3 text-sm font-semibold text-slate-700",children:["New quotes to onboard ",e.jsx("span",{className:"ml-1 font-normal text-slate-400",children:o.length})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:o.map(S=>e.jsxs("div",{className:"group rounded-2xl border border-brand-200 bg-brand-50/40 p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-base font-semibold text-slate-900",children:S.company||S.name||"New lead"}),e.jsx("div",{className:"truncate text-sm text-slate-500",children:[S.name,S.email].filter(
216Boolean).join(" · ")||S.industry})]}),typeof S.quote_monthly=="number"&&e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsxs("div",{className:"text-sm font-semibold text-slate-900",children:[se(S.quote_monthly),"/mo"]}),typeof S.quote_setup=="number"&&e.jsxs("div",{className:"text-[11px] text-slate-400",children:["+ ",se(S.quote_setup)," setup"]})]})]}),S.services&&e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-slate-500",children:S.services}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsxs("button",{onClick:()=>Y(S.id),disabled:N,className:"inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-brand-500 disabled:opacity-50",children:[e.jsx(me,{className:"h-4 w-4"})," Start onboarding ",e.jsx(ze,{className:"h-4 w-4"})]}),v?e.jsxs("button",{onClick:()=>H({kind:"signup",id:S.id}),title:"Remove this quote — for test entries and spam",className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-semibold text-slate-500 hover:bg-red-50 hover:text-red-700",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"})," Delete quote"]}):e.jsxs("span",{className:"text-[11px] text-slate-400",title:"Only an admin can delete",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"admin"]})]})]},S.id))})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-slate-100 p-0.5 text-xs font-medium",children:["all","live","onboarding","paused"].map(S=>e.jsxs("button",{onClick:()=>X(S),className:`rounded-md px-3 py-1.5 capitalize transition ${z===S?"bg-white text-slate-900 shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:[S,S!=="all"&&e.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:R[S]})]},S))}),e.jsxs("label",{className:"relative",children:[e.jsx(is,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:b,onChange:S=>B(S.target.value),placeholder:"Search clients",className:"w-56 rounded-lg border border-slate-200 bg-white py-2 pl-9 pr-3 text-sm focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-100"})]})]}),T?e.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-400",children:"Loading…"}):J.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-white p-8 text-center text-sm text-slate-400",children:L.length===0?"No clients yet. Convert a quote above, or add one manually.":"No clients match."}):e.jsx("div",{className:"space-y-6",children:["customer","own"].map(S=>{const F=J.filter(M=>O(M)===S);return F.length===0?null:e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-slate-500",children:[S==="customer"?"Customers":"Your brands"," ",e.jsx("span",{className:"font-normal text-slate-400",children:F.length}),S==="own"&&e.jsx("span",{className:"rounded-full bg-slate-100 px-2 py-0.5 text-[10px] font-medium normal-case tracking-normal text-slate-500",children:"outbound we run for our own companies"})]}),e.jsx("div",{className:"overflow-x-auto lg:overflow-visible rounded-2xl border border-slate-200 bg-white shadow-card",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-100 text-[11px] uppercase tracking-wide text-slate-400",children:[e.jsx("th",{className:"px-5 py-3 font-medium",children:"Client"}),e.jsx("th",{className:"px-5 py-3 font-medium",children:"Stage"}),e.jsx("th",{className:"px-5 py-3 font-medium",children:"Needs a human"}),e.jsx("th",{className:"px-5 py-3 font-medium",children:"Onboarding"}),e.jsx("th",{className:"px-5 py-3 font-medium",children:"Next step"}),e.jsx("th",{className:"px-3 py-3"})]})}),e.jsx("tbody",{children:F.map(M=>{const ne=vs(M.checklist),c=$e[M.stage]??$e.onboarding,_=ls(M.checklist),q=Fa(M);return e.jsxs("tr",{onClick:()=>s(`/clients/${M.id}`),onKeyDown:U=>{U.key==="Enter"&&s(`/clients/${M.id}`)},tabIndex:0,role:"link","aria-label":`Open ${M.company||M.name||"client"}`,className:"cursor-pointer border-b border-slate-50 transition last:border-0 hover:bg-slate-50 focus:bg-brand-50/60 focus:outline-none",children:[e.jsxs("td",{className:"px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${c.dot}`}),e.jsx("div",{className:"font-medium text-slate-900",children:M.company||M.name||"Client"})]}),e.jsxs("div",{className:"ml-4 text-xs text-slate-400",children:[[M.name,M.email].filter(
216Boolean).join(" · "),q&&e.jsx("span",{className:"text-slate-300",children:" · "}),q&&e.jsx("span",{className:"text-slate-500",children:q})]})]}),e.jsx("td",{className:"px-5 py-3",children:e.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-[11px] font-medium ${c.cls}`,children:c.label})}),e.jsx("td",{className:"px-5 py-3",children:e.jsx(Ha,{p:E[M.id]})}),e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 w-20 overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:`h-full rounded-full ${_?"bg-emerald-500":"bg-brand-500"}`,style:{width:`${ne.done/ne.total*100}%`}})}),e.jsxs("span",{className:"text-xs tabular-nums text-slate-500",children:[ne.done,"/",ne.total]})]})}),e.jsx("td",{className:"px-5 py-3 text-sm text-slate-600",children:M.stage==="live"?e.jsx("span",{className:"text-slate-400",children:"running"}):M.stage==="paused"?e.jsx("span",{className:"text-slate-400",children:"paused"}):Ns(M.checklist)}),e.jsxs("td",{className:"relative px-3 py-3 text-right",onClick:U=>U.stopPropagation(),children:[e.jsxs("button",{onClick:()=>V(A===M.id?null:M.id),"aria-label":"Client actions",className:"inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2.5 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50",children:["Actions ",e.jsx(et,{className:"h-3.5 w-3.5"})]}),A===M.id&&e.jsxs("div",{className:"absolute right-3 top-10 z-20 w-48 overflow-hidden rounded-xl border border-slate-200 bg-white py-1 text-left text-sm shadow-pop",children:[e.jsxs("button",{onClick:()=>s(`/clients/${M.id}`),className:"flex w-full items-center gap-2 px-3 py-2 text-slate-700 hover:bg-slate-50",children:[e.jsx(ze,{className:"h-4 w-4 text-slate-400"})," Open"]}),it(M).map(U=>e.jsxs("button",{onClick:()=>{V(null),f(M,U.next)},title:U.hint,className:"flex w-full items-center gap-2 px-3 py-2 text-slate-700 hover:bg-slate-50",children:[U.key==="pause"?e.jsx(Xs,{className:"h-4 w-4 text-slate-400"}):e.jsx(Js,{className:"h-4 w-4 text-slate-400"})," ",U.label,U.key==="resume"&&U.hint?e.jsx("span",{className:"ml-auto text-[10px] text-slate-400",children:U.hint}):null]},U.key)),v?e.jsxs("button",{onClick:()=>{V(null),H({kind:"client",id:M.id})},className:"flex w-full items-center gap-2 border-t border-slate-100 px-3 py-2 text-red-600 hover:bg-red-50",children:[e.jsx(Ce,{className:"h-4 w-4"})," Delete client…"]}):e.jsxs("div",{className:"flex w-full items-center gap-2 border-t border-slate-100 px-3 py-2 text-slate-400",children:[e.jsx(be,{className:"h-4 w-4"})," Delete (admin only)"]})]})]})]},M.id)})})]})})]},S)})}),e.jsxs("p",{className:"mt-3 text-[11px] text-slate-400",children:["Open a client and use ",e.jsx("strong",{children:"Actions"})," here, or the ",e.jsx("strong",{children:"Danger zone"})," at the bottom of its page. Pause keeps everything. Delete is admin-only, asks you to type DELETE, and cannot be undone."]})]}),g&&e.jsx(cs,{kind:g.kind,id:g.id,onClose:()=>H(null),onDeleted:()=>{H(null),y()}}),r&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/50 p-4",onClick:()=>u(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-client-title",children:e.jsxs("form",{onSubmit:S=>{S.preventDefault(),Z()},className:"w-full max-w-md rounded-2xl bg-white p-6 shadow-pop",onClick:S=>S.stopPropagation(),children:[e.jsx("h2",{id:"add-client-title",className:"text-base font-semibold text-slate-900",children:"Add a client"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Quotes from the website arrive on their own. Use this for an existing customer or one of your own brands."}),e.jsxs("label",{className:"mt-4 block text-xs font-medium text-slate-600",children:["Company name",e.jsx("input",{autoFocus:!0,value:h,onChange:S=>d(S.target.value),placeholder:"e.g. Moonbrush, Inc.",className:"mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-100"})]}),e.jsx("div",{className:"mt-3 flex gap-2 text-sm",children:["customer","own"].map(S=>e.jsxs("label",{className:`flex flex-1 cursor-pointer items-center gap-2 rounded-lg border px-3 py-2 ${n===S?"border-brand-500 bg-brand-50 text-brand-800":"border-slate-200 text-slate-600"}`,children:[e.jsx("input",{type:"radio",name:"kind",checked:n===S,onChange:()=>x(S),className:"text-brand-600"}
216)," ",S==="customer"?"A paying customer":"One of my own brands"]},S))}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>u(!1),className:"rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:N||!h.trim(),className:"rounded-lg bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:N?"Creating…":"Create client"})]})]})})]})}const Wa=["What do I do next?","How do I set up Instantly?","How do I set up the intent agent?","How do I warm up the inboxes?"];function Ua({context:s,suggestions:t=Wa}){const[a,i]=l.useState([]),[m,r]=l.useState(""),[u,h]=l.useState(!1),d=l.useRef(null);l.useEffect(()=>{var x;(x=d.current)==null||x.scrollTo({top:d.current.scrollHeight,behavior:"smooth"})},[a,u]);const n=async x=>{const v=x.trim();if(!v||u)return;const o=[...a,{role:"user",content:v}];i(o),r(""),h(!0);try{const j=await C.askCoach(o,s);i([...o,{role:"assistant",content:j}])}catch{i([...o,{role:"assistant",content:"I couldn’t reach the coach just now — try again in a moment. If it keeps failing, flag it for the owner."}])}finally{h(!1)}};return e.jsxs("section",{className:"flex flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 bg-navy-950 px-4 py-3 text-white",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-white/10",children:e.jsx(me,{className:"h-4 w-4 text-brand-300"})}),e.jsxs("div",{className:"leading-tight",children:[e.jsx("div",{className:"text-sm font-semibold",children:"Onboarding coach"}),e.jsxs("div",{className:"text-[11px] text-slate-400",children:["Ask anything",s!=null&&s.company?` about ${s.company}`:""," · steps, Instantly, research"]})]})]}),e.jsxs("div",{ref:d,className:"flex-1 space-y-3 overflow-y-auto px-4 py-4",style:{maxHeight:"22rem",minHeight:"11rem"},children:[e.jsx(ms,{role:"assistant",children:"Hi 👋 I’m your onboarding coach. I’ll walk you through this client step by step — kickoff, Instantly, the intent agent, sequences, and going live. Ask me anything, or tap a starter below."}),a.length===0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:t.map(x=>e.jsx("button",{onClick:()=>n(x),className:"rounded-full border border-slate-200 bg-white px-3 py-1.5 text-xs font-medium text-slate-600 transition hover:border-brand-300 hover:text-brand-700",children:x},x))}),a.map((x,v)=>e.jsx(ms,{role:x.role,children:x.content},v)),u&&e.jsx(ms,{role:"assistant",children:e.jsxs("span",{className:"inline-flex gap-1",children:[e.jsx("span",{className:"pulse-dot h-1.5 w-1.5 rounded-full bg-slate-400"}),e.jsx("span",{className:"pulse-dot h-1.5 w-1.5 rounded-full bg-slate-400",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"pulse-dot h-1.5 w-1.5 rounded-full bg-slate-400",style:{animationDelay:"0.4s"}})]})})]}),e.jsxs("form",{onSubmit:x=>{x.preventDefault(),n(m)},className:"flex items-center gap-2 border-t border-slate-100 p-3",children:[e.jsx("input",{value:m,onChange:x=>r(x.target.value),placeholder:"Ask the coach…",className:"h-10 flex-1 rounded-xl border border-slate-200 bg-white px-3 text-sm outline-none transition focus:border-brand-400 focus:ring-4 focus:ring-brand-50"}),e.jsx("button",{type:"submit",disabled:u||!m.trim(),"aria-label":"Send",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-brand-600 text-white transition hover:bg-brand-500 disabled:opacity-50",children:e.jsx(rs,{className:"h-4 w-4"})})]})]})}function ms({role:s,children:t}){const a=s==="user";return e.jsx("div",{className:`flex ${a?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl px-3.5 py-2 text-sm leading-relaxed ${a?"bg-brand-600 text-white":"bg-slate-100 text-slate-700"}`,children:t})})}const Va={high:{label:"High",cls:"bg-emerald-50 text-emerald-700 ring-emerald-200"},medium:{label:"Medium",cls:"bg-amber-50 text-amber-700 ring-amber-200"},low:{label:"Low",cls:"bg-slate-100 text-slate-500 ring-slate-200"}},Ka={web:"public web",supersearch:"Instantly SuperSearch",findymail:"Findymail",prospeo:"Prospeo",leadmagic:"LeadMagic",icypeas:"Icypeas",wiza:"Wiza",manual:"entered by hand"},Ya=s=>
216{var a,i;const t=((i=(a=s.dossier)==null?void 0:a.enrichment)==null?void 0:i.provider)||s.email_source||"";return t?` · ${Ka[t]||t}`:""},Ts=s=>(s||"").split(`
217`).map(t=>t.replace(/^[-•*\d.)\s]+/,"").trim()).filter(t=>t.length>3);function Qa({client:s,onCampaignLinked:t}){var ne;const a=Ts(s.triggers),[i,m]=l.useState([]),[r,u]=l.useState(!0),[h,d]=l.useState(null),[n,x]=l.useState(!1),[v,o]=l.useState([]),[j,L]=l.useState("pending"),[k,E]=l.useState(null),[I,T]=l.useState(a),$=async()=>{var c;if(s.campaign_id)try{const _=await C.getCampaign(s.campaign_id);E(((c=_==null?void 0:_.strategy)==null?void 0:c.intent_triggers)??null)}catch{}};l.useEffect(()=>{$()},[s.campaign_id]),l.useEffect(()=>{T(Ts(s.triggers))},[s.triggers]);const N=async()=>{const c=await C.generateIntentSignals({clientId:s.id});E(c),T(c.signals.map(_=>_.query)),o(_=>[`Generated ${c.signals.length} intent signals from the ICP (${c.signals.filter(q=>q.priority==="high").length} strong). Run the strong ones first.`,..._])},w=async()=>{u(!0);try{m(await C.listClientProspects(s.id))}finally{u(!1)}};l.useEffect(()=>{w()},[s.id,s.campaign_id]);const b=async(c,_)=>{d(c);try{const q=await C.runResearch(s.id,c,_?{why_now:_.why_now,detect_via:_.detect_via,window_days:_.window_days}:void 0);q.campaignId&&!s.campaign_id&&(t==null||t(q.campaignId)),o(U=>[`“${c}” → found ${q.found}, ${q.added} new to review${q.skipped?`, ${q.skipped} already in pipeline`:""}.${q.notes?` ${q.notes}`:""}`,...U]),await w()}catch(q){o(U=>[`“${c}” → ${q.message}`,...U])}finally{d(null)}},B=async()=>{var _;x(!0);const c=(_=k==null?void 0:k.signals)!=null&&_.length?k.signals:I.map(q=>({query:q}));for(const q of c)await b(q.query,q.why_now?q:void 0);x(!1)},z=async(c,_)=>{var U;const q=(U=i.find(le=>le.id===c))==null?void 0:U.review_state;m(le=>le.map(Q=>Q.id===c?{...Q,review_state:_}:Q));try{await C.reviewProspect(c,_)}catch(le){m(Q=>Q.map(Pe=>Pe.id===c?{...Pe,review_state:q}:Pe)),o(Q=>[`Review → ${le.message}`,...Q])}},X=async()=>{const c=i.filter(_=>_.review_state==="pending"&&_.confidence==="high");for(const _ of c)await z(_.id,"approved")},A={pending:i.filter(c=>c.review_state==="pending").length,approved:i.filter(c=>c.review_state==="approved").length,rejected:i.filter(c=>c.review_state==="rejected").length},V=i.filter(c=>c.review_state==="approved"&&c.stage==="research"&&!!c.email).length,[g,H]=l.useState(!1),y=async()=>{H(!0);try{const c=await C.draftSequences(s.id);o(_=>[c.drafted?`Drafted ${c.drafted} trigger-based sequence${c.drafted===1?"":"s"} → waiting in Approvals.${c.remaining?` ${c.remaining} more approved lead${c.remaining===1?"":"s"} still to draft — run again.`:""}`:c.message||"Nothing to draft.",...c.errors||[],..._]),await w()}catch(c){o(_=>[`Draft → ${c.message}`,..._])}finally{H(!1)}},Y=c=>{var _,q;return["not_found","named_not_found"].includes(((q=(_=c.dossier)==null?void 0:_.enrichment)==null?void 0:q.status)||"")},Z=i.filter(c=>c.review_state==="approved"&&!c.email&&(c.stage==="research"||c.stage==="contact")&&!Y(c)).length,[f,R]=l.useState(null),[O,J]=l.useState(!1),S=async c=>{R(c);try{const _=await C.findEmails(s.id,{action:c}),q=[];_.found&&q.push(`Found ${_.found} work email${_.found===1?"":"s"} via Instantly${_.added?` (+${_.added} additional decision-maker${_.added===1?"":"s"} added to the queue)`:""}: ${(_.results||[]).map(U=>`${U.company} → ${U.who?`${U.who} · `:""}${U.email}`).join(", ")}`),_.message&&q.push(_.message),!_.found&&!_.message&&q.push("No emails found for the remaining leads yet."),o(U=>[...q,..._.notes||[],...(_.errors||[]).map(le=>`Email search → ${le}`),...U]),J(_.pending>0),await w()}catch(_){o(q=>[`Email search → ${_.message}`,...q])}finally{R(null)}},F=i.filter(c=>j==="all"||c.review_state===j),M=h!==null||n;return e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white shadow-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 text-brand-600"}),e.jsx("h2",{className:"text-sm font-semibold text-slate-800",children:"Intent research"}),e.jsx("span",{className:"text-xs text-slate-400",children:"· real companies showing a buying signal, with evidence"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>void w(),disabled:r,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50",children:[e.jsx(ke,{className:`h-3.5 w-3.5 ${r?"animate-spin":""}`})," Refresh"]}),e.jsxs("button",{onClick:B,disabled:M||(((ne=k==null?void 0:k.signals)==null?void 0:ne.length)??I.length)===0,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 py-1.5 text-xs font-semibold text-white transition hover:bg-brand-500 disabled:opacity-50",children:[n?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ge,{className:"h-3.5 w-3.5"})," Run all triggers"]})]})]}),e.jsxs("div",{className:"border-b border-slate-100 px-6 py-4",children:[e.jsx(lt,{set:k,fallbackLines:I,onGenerate:N,onRun:c=>void b(c.query,c.why_now?c:void 0),running:h,busy:M,leadCounts:i.reduce((c,_)=>(_.trigger&&(c[_.trigger]=(c[_.trigger]||0)+1),c),{}),emptyHint:s.icp?"No signals yet. Generate them from the ICP — the bot will then know exactly which moments to look for.":"Add the ICP in Client details first, then generate the intent signals from it."}),M&&e.jsx("p",{className:"mt-3 text-xs text-slate-400",children:"Research reads live sources on the web — each signal takes about a minute."}),v.length>0&&e.jsx("ul",{className:"mt-3 space-y-1 rounded-lg bg-slate-50 p-3 text-xs text-slate-600",children:v.slice(0,4).map((c,_)=>e.jsx("li",{children:c},_))})]}),e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"flex gap-1",children:["pending","approved","rejected","all"].map(c=>e.jsxs("button",{onClick:()=>L(c),className:`rounded-lg px-3 py-1.5 text-xs font-semibold capitalize transition ${j===c?"bg-slate-900 text-white":"text-slate-500 hover:bg-slate-100"}`,children:[c,c!=="all"&&e.jsx("span",{className:"ml-1 opacity-70",children:A[c]})]},c))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[A.pending>0&&i.some(c=>c.review_state==="pending"&&c.confidence==="high")&&e.jsxs("button",{onClick:X,className:"inline-flex items-center gap-1.5 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 hover:bg-emerald-100",children:[e.jsx(we,{className:"h-3.5 w-3.5"})," Approve all high-confidence"]}),Z>0&&e.jsxs("button",{onClick:()=>void S("find"),disabled:f!==null||M,title:"Claude public-web search → Instantly SuperSearch → Findymail/Prospeo/LeadMagic/Icypeas/Wiza. Every address is verified before it is saved.",className:"inline-flex items-center gap-1.5 rounded-lg border border-brand-200 bg-brand-50 px-3 py-1.5 text-xs font-semibold text-brand-700 hover:bg-brand-100 disabled:opacity-50",children:[f==="find"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Be,{className:"h-3.5 w-3.5"})," Find emails for ",Z," approved lead",Z===1?"":"s"]}),O&&Z>0&&e.jsxs("button",{onClick:()=>void S("sync"),disabled:f!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50",children:[f==="sync"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ke,{className:"h-3.5 w-3.5"})," Check again"]}),V>0&&e.jsxs("button",{onClick:()=>void y(),disabled:g||M,className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-900 px-3 py-1.5 text-xs font-semibold text-white hover:bg-slate-800 disabled:opacity-50",children:[g?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ge,{className:"h-3.5 w-3.5"})," Draft sequences for ",V," approved lead",V===1?"":"s"]})]})]}),r&&i.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-slate-400",children:"Loading…"}):F.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 py-8 text-center text-sm text-slate-400",children:i.length===0?"Run a trigger above to find leads.":`No ${j} leads.`}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 text-left text-[11px] uppercase tracking-wide text-slate-400",children:[e.jsx("th",{className:"pb-2 pr-3 font-medium",children:"Company · person"}),e.jsx("th",{className:"pb-2 pr-3 font-medium",children:"Signal & evidence"}),e.jsx("th",{className:"pb-2 pr-3 font-medium",children:"Email"}),e.jsx("th",{className:"pb-2 pr-3 font-medium",children:"Confidence"}),e.jsx("th",{className:"pb-2 font-medium text-right",children:"Review"})]})}),e.jsx("tbody",{children:F.map(c=>{var q,U,le,Q;const _=Va[c.confidence||"low"];return e.jsxs("tr",{className:"border-b border-slate-100 align-top last:border-0",children:[e.jsxs("td",{className:"py-3 pr-3",children:[e.jsx("div",{className:"font-medium text-slate-900",children:c.company}),e.jsx("div",{className:"text-xs text-slate-500",children:c.contact_name?`${c.contact_name}${c.title?` · ${c.title}`:""}`:e.jsx("span",{className:"italic text-slate-400",children:"decision-maker not named in sources"})})]}),e.jsxs("td",{className:"py-3 pr-3 max-w-md",children:[e.jsx("div",{className:"text-xs font-semibold text-brand-700",children:c.trigger}),e.jsx("div",{className:"mt-0.5 text-xs leading-snug text-slate-600",children:c.evidence}),c.evidence_url&&e.jsxs("a",{href:c.evidence_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[11px] text-slate-400 hover:text-brand-600",children:["source ",e.jsx(Fe,{className:"h-3 w-3"})]})]}),e.jsx("td",{className:"py-3 pr-3 text-xs",children:c.email?e.jsxs("div",{children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-slate-700",children:[e.jsx(Be,{className:"h-3.5 w-3.5 text-emerald-500"})," ",c.email]}),e.jsxs("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-slate-400",children:[c.email_verified?e.jsx("span",{className:"text-emerald-600",children:"verified"}):"unverified",Ya(c)]})]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-slate-400",title:((U=(q=c.dossier)==null?void 0:q.enrichment)==null?void 0:U.status)==="named_not_found"?"This person is not in SuperSearch; decision-makers at the company were added as separate leads.":void 0,children:[e.jsx(la,{className:"h-3.5 w-3.5"})," ",Y(c)?((Q=(le=c.dossier)==null?void 0:le.enrichment)==null?void 0:Q.status)==="named_not_found"?"not in SuperSearch · see alternates":"not found":c.review_state==="approved"?"not found yet":"not public"]})}),e.jsx("td",{className:"py-3 pr-3",children:e.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-[11px] font-semibold ring-1 ${_.cls}`,children:_.label})}),e.jsx("td",{className:"py-3 text-right",children:c.review_state==="pending"?e.jsxs("div",{className:"inline-flex gap-1",children:[e.jsx("button",{onClick:()=>void z(c.id,"approved"),"aria-label":"Approve lead",className:"rounded-lg bg-emerald-600 p-1.5 text-white hover:bg-emerald-500",children:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>void z(c.id,"rejected"),"aria-label":"Reject lead",className:"rounded-lg border border-slate-200 p-1.5 text-slate-500 hover:bg-slate-50",children:e.jsx(ce,{className:"h-4 w-4"})})]}):e.jsx("span",{className:`text-[11px] font-semibold ${c.review_state==="approved"?"text-emerald-600":"text-slate-400"}`,children:c.review_state})})]},c.id)})})]})}),e.jsxs("p",{className:"mt-3 text-[11px] text-slate-400",children:["Flow: approve a lead → ",e.jsx("strong",{children:"Find emails"}
217)," (Instantly SuperSearch finds and verifies a work address) → ",e.jsx("strong",{children:"Draft sequences"})," → approve the sequence. Nothing is contacted until that last approval."]})]})]})}function rt({title:s,body:t,confirmLabel:a="Confirm",tone:i="primary",noteLabel:m,notePlaceholder:r,requireNote:u,onConfirm:h,onClose:d}){const[n,x]=l.useState(""),[v,o]=l.useState(!1),[j,L]=l.useState(null),k=l.useRef(null);l.useEffect(()=>{var T;const I=$=>{$.key==="Escape"&&!v&&d()};return window.addEventListener("keydown",I),(T=k.current)==null||T.focus(),()=>window.removeEventListener("keydown",I)},[d,v]);const E=async()=>{if(u&&!n.trim()){L("Add a short note first.");return}o(!0),L(null);try{await h(n.trim())}catch(I){L(I instanceof Error?I.message:"Something went wrong"),o(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/50 p-4",onClick:()=>!v&&d(),role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl bg-white p-6 shadow-pop",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{id:"confirm-title",className:"text-base font-semibold text-slate-900",children:s}),e.jsx("button",{onClick:d,disabled:v,"aria-label":"Close",className:"rounded-lg p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(ce,{className:"h-4 w-4"})})]}),t&&e.jsx("div",{className:"mt-3 text-sm text-slate-600",children:t}),m&&e.jsxs("label",{className:"mt-4 block text-xs font-medium text-slate-600",children:[m,e.jsx("textarea",{value:n,onChange:I=>x(I.target.value),rows:3,placeholder:r,className:"mt-1 w-full rounded-lg border border-slate-200 px-3 py-2 text-sm focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-100"})]}),j&&e.jsx("div",{className:"mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:j}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{onClick:d,disabled:v,className:"rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Cancel"}),e.jsxs("button",{ref:k,onClick:()=>void E(),disabled:v,className:`inline-flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-semibold text-white disabled:opacity-50 ${i==="danger"?"bg-red-600 hover:bg-red-500":"bg-brand-600 hover:bg-brand-500"}`,children:[v&&e.jsx(G,{className:"h-4 w-4 animate-spin"})," ",a]})]})]})})}function Za({client:s}){const[t,a]=l.useState([]),[i,m]=l.useState(!0),[r,u]=l.useState(null),[h,d]=l.useState(null),[n,x]=l.useState(null),[v,o]=l.useState(null),j=async()=>{m(!0);try{a(await C.listReports(s.id))}finally{m(!1)}};l.useEffect(()=>{j()},[s.id]);const L=async N=>{u(N),o(null);try{const w=await C.generateReport(s.id,N);a(b=>[w,...b]),x(w)}catch(w){o(w.message)}finally{u(null)}},k=async N=>{const w=s.kind==="own",b=s.email||(w?await ws():"");if(!b||b==="operator"){o("Add the client’s email in Client details first.");return}I({r:N,to:b})},[E,I]=l.useState(null),T=async(N,w)=>{d(N.id),o(null);try{await C.sendReport(N.id,w),a(b=>b.map(B=>B.id===N.id?{...B,status:"sent",sent_to:w,sent_at:new Date().toISOString()}:B)),(n==null?void 0:n.id)===N.id&&x(null),I(null)}catch(b){throw o(b.message),b}finally{d(null)}},$=N=>new Date(N).toLocaleDateString("en-US",{month:"short",day:"numeric"});return e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white shadow-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_t,{className:"h-4 w-4 text-brand-600"}),e.jsx("h2",{className:"text-sm font-semibold text-slate-800",children:"Client reports"}),e.jsx("span",{className:"text-xs text-slate-400",children:"· what we accomplished, built from the real data"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>void L("weekly"),disabled:!!r,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 py-1.5 text-xs font-semibold text-white transition hover:bg-brand-500 disabled:opacity-50",children:[r==="weekly"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(me,{className:"h-3.5 w-3.5"})," Generate weekly report"]}),e.jsxs("button",{onClick:()=>void L("monthly"),disabled:!!r,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3.5 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-50 disabled:opacity-50",children:[r==="monthly"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(me,{className:"h-3.5 w-3.5"})," Monthly roadmap"]})]})]}),v&&e.jsx("div",{className:"mx-6 mt-4 rounded-lg bg-red-50 px-3 py-2 text-xs text-red-700",children:v}),e.jsxs("div",{className:"px-6 py-4",children:[i&&t.length===0?e.jsx("div",{className:"py-6 text-center text-sm text-slate-400",children:"Loading…"}):t.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-slate-200 py-8 text-center text-sm text-slate-400",children:"No reports yet. Generate this week’s — it rolls up the leads found (with evidence), outreach activity, content, and next priorities."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(N=>{var w,b;return e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-900",children:[N.kind==="monthly"?"Monthly Strategic Roadmap":"Weekly Report",e.jsxs("span",{className:"text-xs font-normal text-slate-400",children:[$(N.period_start)," – ",$(N.period_end)]}),N.status==="sent"?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-semibold text-emerald-700 ring-1 ring-emerald-200",children:[e.jsx(Ys,{className:"h-3 w-3"})," sent"]}):e.jsx("span",{className:"rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-semibold text-amber-700 ring-1 ring-amber-200",children:"draft"})]}),e.jsx("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:(b=(w=N.body)==null?void 0:w.narrative)==null?void 0:b.headline}),N.status==="sent"&&e.jsxs("div",{className:"text-[11px] text-slate-400",children:["Sent to ",N.sent_to," · ",N.sent_at?$(N.sent_at):""]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{onClick:()=>x(N),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-medium text-slate-700 hover:bg-slate-50",children:[e.jsx($t,{className:"h-3.5 w-3.5"})," Preview"]}),N.status!=="sent"&&e.jsxs("button",{onClick:()=>void k(N),disabled:h===N.id,className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-900 px-3 py-1.5 text-xs font-semibold text-white hover:bg-slate-800 disabled:opacity-50",children:[h===N.id?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(rs,{className:"h-3.5 w-3.5"})," ",s.kind==="own"?"Send to me":"Send to client"]})]})]},N.id)})}),e.jsx("p",{className:"mt-3 text-[11px] text-slate-400",children:"Reports are drafts until you send them. Every number comes from the campaign tables; the narrative is written from those numbers and never invents results."})]}),n&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-navy-950/70 p-4 backdrop-blur-sm",onClick:()=>x(null),children:e.jsxs("div",{className:"flex h-[92vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl bg-white shadow-elevated",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 px-5 py-3",children:[e.jsxs("div",{className:"text-sm font-semibold text-slate-800",children:["Preview — exactly what ",s.company||"the client"," will receive"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.status!=="sent"&&e.jsxs("button",{onClick:()=>void k(n),disabled:h===n.id,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[h===n.id?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Be,{className:"h-3.5 w-3.5"})," Send to ",s.email||(s.kind==="own"?"me":"client")]}),e.jsx("button",{onClick:()=>x(null),"aria-label":"Close",className:"rounded-lg p-1.5 text-slate-400 hover:bg-slate-100 hover:text-slate-700",children:e.jsx(ce,{className:"h-4 w-4"})})]})]}),e.jsx("iframe",{title:"Report preview",srcDoc:n.html,className:"h-full w-full flex-1 bg-[#eef1f6]",sandbox:""})]})}),E&&e.jsx(rt,{title:`Send the ${E.r.kind} report?`,body:e.jsxs("span",{children:["It goes to ",e.jsx("strong",{children:E.to})," from the FusionSales.ai relay. Each report can be sent once."]}),confirmLabel:"Send report",onConfirm:()=>T(E.r,E.to),onClose:()=>I(null)})]})}const Te=["Connected to Instantly","Choose sending inboxes","Campaign in Instantly","Replies wired back","Launch"];function qe({n:s,title:t,done:a,blocked:i,children:m,what:r}
217){return e.jsxs("li",{className:`flex gap-4 rounded-xl border p-4 ${a?"border-emerald-200 bg-emerald-50/40":i?"border-slate-100 bg-slate-50/60 opacity-70":"border-slate-200"}`,children:[e.jsx("div",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-bold ${a?"bg-emerald-500 text-white":i?"bg-slate-200 text-slate-400":"bg-brand-600 text-white"}`,children:a?e.jsx(we,{className:"h-4 w-4",strokeWidth:3}):s}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-800",children:t}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-500",children:r}),m&&e.jsx("div",{className:"mt-3",children:m})]})]})}function Xa({client:s}){var $s;const[t,a]=l.useState(null),[i,m]=l.useState(null),[r,u]=l.useState(null),[h,d]=l.useState(null),[n,x]=l.useState(new Set),[v,o]=l.useState(!1),[j,L]=l.useState([]),[k,E]=l.useState(""),[I,T]=l.useState(""),[$,N]=l.useState(null),[w,b]=l.useState(""),[B,z]=l.useState(!0),[X,A]=l.useState(null),[V,g]=l.useState(!1),[H,y]=l.useState(""),[Y,Z]=l.useState([]),[f,R]=l.useState(new Set),[O,J]=l.useState(""),[S,F]=l.useState(""),[M,ne]=l.useState(""),[c,_]=l.useState(null),[q,U]=l.useState(""),le=async()=>{m(null);try{const p=await C.instantly("status",s.id);a(p),p.inboxes&&x(new Set(p.inboxes.chosen)),!p.connected&&p.error&&m(p.error)}catch(p){m(p.message)}};l.useEffect(()=>{le()},[s.id]);const Q=async(p,re)=>{u(p),m(null),A(null);try{await re(),await le()}catch(xe){m(xe.message)}finally{u(null)}},Pe=()=>Q("accounts",async()=>{const p=await C.instantly("accounts",s.id);d(p.items)}),dt=()=>Q("save",async()=>{const p=await C.instantly("save-accounts",s.id,{emails:Array.from(n)});A(`${p.emails.length} inbox${p.emails.length===1?"":"es"} saved${p.synced?" and updated in Instantly":""}.`),d(null)}),ct=()=>Q("list",async()=>{const p=await C.instantly("list-campaigns",s.id);L(p.items),o(!0)}),ot=()=>Q("link",async()=>{const p=await C.instantly("link-campaign",s.id,{instantlyCampaignId:k});o(!1),p.note&&A(p.note)}),xt=()=>Q("create",async()=>{await C.instantly("create-campaign",s.id,{dailyLimit:I||void 0}),A("Campaign created in Instantly as a draft. Nothing sends until you lau
217nch.")}),mt=()=>Q("unlink",async()=>{await C.instantly("unlink-campaign",s.id)}),ht=()=>Q("webhook",async()=>{var re,xe,ee;const p=await C.instantly("register-webhook",s.id);A((re=p.test)!=null&&re.success?"Instantly delivered a test event to Mission Control. Replies will land in Warm Leads.":`Registered, but the test did not confirm (${((xe=p.test)==null?void 0:xe.error)||((ee=p.test)==null?void 0:ee.status_code)||"no response"}). Try again in a minute.`)}),pt=()=>{const p=String(s.website||"").replace(/^https?:\/\//,"").replace(/^www\./,"").split("/")[0];y(p),Z([]),R(new Set),_(null),U("");const[re,...xe]=String(s.name||"").trim().split(/\s+/);F(re||""),ne(xe.join(" "));const ee=(re||"").toLowerCase(),Ke=(xe.join("")||"").toLowerCase();J([ee,ee&&Ke?`${ee}.${Ke}`:"",ee&&Ke?`${ee[0]}${Ke}`:""].filter(Boolean).join(", ")),g(!0)},ut=()=>Q("suggest",async()=>{const p=await C.instantly("suggest-domains",s.id,{domain:H});Z(p.domains),y(p.base),_(null)}),Ss=()=>({domains:Array.from(f),prefixes:O.split(",").map(p=>p.trim()).filter(Boolean),firstName:S,lastName:M,forwardingDomain:H}),bt=()=>Q("quote",async()=>{_(await C.instantly("simulate-order",s.id,Ss())),U("")}),gt=()=>Q("order",async()=>{const p=await C.instantly("place-order",s.id,{...Ss(),confirm:q.trim()});_(p),p.placed?(A(`Order placed: ${p.mailboxes} inbox${p.mailboxes===1?"":"es"} on ${p.domains} domain${p.domains===1?"":"s"}. Instantly sets them up and starts warm-up automatically — come back in about two weeks and choose them in step 2.`),g(!1)):p.checkoutRequired&&p.checkoutUrl?(A("Instantly needs you to finish checkout in a new tab."),window.open(p.checkoutUrl,"_blank","noopener")):m(`Instantly did not place the order: ${p.error||p.paymentFailure||(p.problems||[]).join("; ")||"unknown reason"}`)}),ft=()=>Q("preview",async()=>{const p=await C.launch("preview",s.id);N(p),b("")}),_s=()=>Q("launch",async()=>{const p=await C.launch("launch",s.id,{confirm:w.trim(),activate:B});N(null),A(`${p.pushed} lead${p.pushed===1?"":"s"} handed to Instantly. Campaign is ${p.status}${p.activated?" — sending starts on the next business-hours window":""}.`)}),P=t,ve=!!(P!=null&&P.isAdmin),oe=!!(P!=null&&P.connected),Ne=oe&&((P==null?void 0:P.inboxes.chosen.length)??0)>0,ge=oe&&!!(P!=null&&P.campaign.linked),os=oe&&!!(P!=null&&P.webhook.registered),jt=ge&&((P==null?void 0:P.launch.ready)??0)>0;return e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white shadow-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"h-4 w-4 text-brand-600"}),e.jsx("h2",{className:"text-sm font-semibold text-slate-800",children:"Sending setup"}),e.jsx("span",{className:"text-xs text-slate-400",children:"· Instantly is the engine, this is the path to it"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[P&&e.jsxs("span",{className:"text-xs text-slate-400",children:[[oe,Ne,ge,os].filter(Boolean).length,"/4 ready",P.launch.inSequence?` · ${P.launch.inSequence} lead${P.launch.inSequence===1?"":"s"} in sequence`:""]}),e.jsxs("button",{onClick:()=>void le(),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50",children:[e.jsx(ke,{className:"h-3.5 w-3.5"})," Refresh"]})]})]}),e.jsxs("div",{className:"px-6 py-5",children:[i&&e.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:i}),X&&e.jsx("div",{className:"mb-4 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-800",children:X}),!P&&!i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-400",children:[e.jsx(G,{className:"h-4 w-4 animate-spin"})," Checking Instantly…"]}),P&&e.jsxs("ol",{className:"space-y-3",children:[e.jsx(qe,{n:1,title:Te[0],done:oe,what:"Mission Control talks to your Instantly workspace with the API key on the server. Nothing in Instantly changes unless someone clicks a step below.",children:oe?e.jsxs("p",{className:"text-xs text-slate-600",children:["Workspace reachable · ",e.jsx("strong",{children:P.workspace.ready})," of ",P.workspace.inboxes," inboxes are active and warmed."]}):e.jsx("p",{className:"text-xs text-red-600",children:"Not connected. The server needs INSTANTLY_API_KEY."})}),e.jsxs(qe,{n:2,title:Te[1],done:Ne,blocked:!oe,what:"Pick the inboxes that send for this client. Use their look-alike domains, never the
217ir main domain. Only inboxes that are active and warmed will land in the inbox.",children:[Ne&&!h&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-slate-600",children:[e.jsx(ss,{className:"h-3.5 w-3.5 text-slate-400"})," ",P.inboxes.chosen.join(", ")," ",e.jsxs("span",{className:"text-slate-400",children:["· ",P.inboxes.ready,"/",P.inboxes.chosen.length," warmed"]})]}),!h&&ve&&oe&&e.jsxs("button",{onClick:Pe,disabled:r!==null,className:"mt-2 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[r==="accounts"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ss,{className:"h-3.5 w-3.5"})," ",Ne?"Change inboxes":"Choose inboxes"]}),!ve&&oe&&!Ne&&e.jsxs("p",{className:"text-xs text-slate-400",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"An admin chooses inboxes."]}),h&&e.jsxs("div",{className:"rounded-xl border border-slate-200",children:[e.jsx("div",{className:"max-h-64 overflow-y-auto",children:h.map(p=>e.jsxs("label",{className:`flex cursor-pointer items-center gap-3 border-b border-slate-100 px-3 py-2 text-xs last:border-0 hover:bg-slate-50 ${p.ready?"":"opacity-60"}`,children:[e.jsx("input",{type:"checkbox",checked:n.has(p.email),onChange:re=>x(xe=>{const ee=new Set(xe);return re.target.checked?ee.add(p.email):ee.delete(p.email),ee}),className:"h-3.5 w-3.5 rounded border-slate-300 text-brand-600"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-slate-800",children:p.email}),e.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${p.ready?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:p.ready?`warmed ${p.score??""}`:`${p.status} · ${p.warmup}`}),e.jsxs("span",{className:"text-slate-400",children:[p.dailyLimit,"/day"]})]},p.email))}),e.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-slate-100 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-slate-500",children:[n.size," chosen · about ",n.size*30," sends/day"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>d(null),className:"rounded-lg px-3 py-1.5 text-xs font-medium text-slate-500 hover:bg-slate-100",children:"Cancel"}),e.jsxs("button",{onClick:dt,disabled:r!==null||n.size===0,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[r==="save"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(we,{className:"h-3.5 w-3.5"})," Save inboxes"]})]})]})]}),!V&&e.jsxs("p",{className:"mt-2 text-[11px] text-slate-400",children:["No inboxes for this client yet?"," ",ve?e.jsx("button",{onClick:pt,className:"font-semibold text-brand-600 hover:underline",children:"Order look-alike inboxes through Instantly"}):e.jsx("span",{children:"an admin can order look-alike inboxes here"})," ","(Google mailboxes on a domain like ",e.jsxs("span",{className:"font-mono",children:["try",(s.website||"client.com").replace(/^https?:\/\//,"").replace(/^www\./,"").split("/")[0]]}),", warm-up included, about two weeks to ready). Or add your own in ",e.jsx("a",{href:"https://app.instantly.ai/app/accounts",target:"_blank",rel:"noopener noreferrer",className:"text-brand-600 underline",children:"Instantly → Email accounts"}),"."]}),V&&e.jsxs("div",{className:"mt-3 space-y-3 rounded-xl border border-brand-200 bg-brand-50/30 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-800",children:[e.jsx(xs,{className:"h-4 w-4 text-brand-600"})," Order inboxes for ",s.company]}),e.jsx("button",{onClick:()=>g(!1),"aria-label":"Close",className:"rounded-lg p-1 text-slate-400 hover:bg-white",children:e.jsx(ce,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Cold email never goes out on the client's real domain. Instantly registers a look-alike domain, creates Google mailboxes on it, forwards the domain to the real site, and warms the inboxes. Nothing is bought until you type ORDER."}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("label",{className:"text-xs text-slate-600",children:["Client's real domain",e.jsx("input",{value:H,onChange:p=>y(p.target.value),placeholder:"fusion-advisory.com",className:"mt-1 block w-56 rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-xs"})]}),e.jsxs("button",{onClick:ut,disabled:r!==null||!H.includes("."),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[r==="suggest"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Vs,{className:"h-3.5 w-3.5"})," Suggest look-alike domains"]})]}),Y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Y.map(p=>
217e.jsxs("label",{className:`cursor-pointer rounded-full border px-2.5 py-1 font-mono text-[11px] ${f.has(p)?"border-brand-500 bg-brand-600 text-white":"border-slate-200 bg-white text-slate-700 hover:border-brand-300"}`,children:[e.jsx("input",{type:"checkbox",className:"sr-only",checked:f.has(p),onChange:re=>{_(null),R(xe=>{const ee=new Set(xe);return re.target.checked?ee.add(p):ee.delete(p),ee})}}),p]},p))}),f.size>0&&e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("label",{className:"text-xs text-slate-600 sm:col-span-1",children:["Sender first name",e.jsx("input",{value:S,onChange:p=>{F(p.target.value),_(null)},className:"mt-1 block w-full rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-xs"})]}),e.jsxs("label",{className:"text-xs text-slate-600 sm:col-span-1",children:["Sender last name",e.jsx("input",{value:M,onChange:p=>{ne(p.target.value),_(null)},className:"mt-1 block w-full rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-xs"})]}),e.jsxs("label",{className:"text-xs text-slate-600 sm:col-span-1",children:["Mailbox names, comma-separated (max 5)",e.jsx("input",{value:O,onChange:p=>{J(p.target.value),_(null)},placeholder:"mike, mike.sweigart, msweigart",className:"mt-1 block w-full rounded-lg border border-slate-200 bg-white px-2 py-1.5 font-mono text-xs"})]})]}),f.size>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:bt,disabled:r!==null||!S||!M||!O.trim(),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[r==="quote"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xs,{className:"h-3.5 w-3.5"})," Get the price"]}),e.jsx("span",{className:"text-[11px] text-slate-400",children:"Priced by Instantly, nothing is charged yet."})]}),c&&!c.placed&&e.jsx("div",{className:`rounded-lg border p-3 text-xs ${c.valid?"border-slate-200 bg-white":"border-amber-200 bg-amber-50"}`,children:c.valid?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"font-semibold text-slate-800",children:[c.mailboxes," mailbox",c.mailboxes===1?"":"es"," on ",c.domains," domain",c.domains===1?"":"s"]}),e.jsx("div",{className:"mt-1 text-slate-600",children:(c.addresses||[]).join(", ")}),e.jsxs("div",{className:"mt-2 text-slate-700",children:[e.jsxs("strong",{children:["$",c.monthly,"/month"]})," for the mailboxes",c.yearly?` + ${c.yearly}/year for the domain${c.domains===1?"":"s"}`:""," · ",e.jsxs("strong",{children:["$",c.today," charged today"]}),c.card?` to the ${c.card} on file with Instantly`:"","."]}),e.jsxs("label",{className:"mt-3 block text-[11px] font-medium uppercase tracking-wide text-slate-500",children:["Type ",e.jsx("span",{className:"font-mono text-slate-900",children:"ORDER"})," to buy",e.jsx("input",{value:q,onChange:p=>U(p.target.value),spellCheck:!1,autoComplete:"off",placeholder:"ORDER",className:"mt-1 w-40 rounded-lg border border-slate-300 bg-white px-2 py-1.5 font-mono text-xs tracking-widest"})]}),e.jsxs("button",{onClick:gt,disabled:q.trim()!=="ORDER"||r!==null,className:"mt-2 inline-flex items-center gap-1.5 rounded-lg bg-slate-900 px-3 py-1.5 text-xs font-semibold text-white hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-40",children:[r==="order"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xs,{className:"h-3.5 w-3.5"})," Place order · $",c.today]})]}):e.jsxs("div",{className:"text-amber-800",children:[e.jsx(as,{className:"mr-1 inline h-3.5 w-3.5"}),"Instantly can't place this order: ",c.error||(c.problems||[]).join("; ")||"check the domain and names","."]})})]})]}),e.jsxs(qe,{n:3,title:Te[2],done:ge,blocked:!Ne,what:"The client's campaign inside Instantly. Its four email steps are filled per lead from the sequence you approved, so every person gets their own copy. Business days, 9 to 5, stops on reply.",children:[ge&&P.campaign.linked&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-slate-600",children:[e.jsx("span",{className:"font-medium text-slate-800",children:P.campaign.name}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${P.campaign.status==="active"?"bg-emerald-50 text-emerald-700":"bg-slate-100 text-slate-600"}`,children:P.campaign.status}),e.jsxs("span",{className:"text-slate-400",children:[P.campaign.email_list.length," inbox",P.campaign.email_list.length===1?"":"es",P.campaign.daily_limit?` · ${P.campaign.daily_limit}/day`:""]}),e.jsxs("a",{href:`https://app.instantly.ai/app/campaign/${P.campaign.id}/analytics`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-brand-600 hover:underline",children:["Open in Instantly ",e.jsx(Fe,{className:"h-3 w-3"})]}),ve&&e.jsx("button",{onClick:mt,disabled:r!==null,className:"text-slate-400 hover:text-slate-700",children:"Unlink"})]}),!ge&&Ne&&ve&&!v&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-slate-600",children:["Daily cap ",e.jsx("input",{type:"number",min:5,max:500,value:
217I,onChange:p=>T(p.target.value?Number(p.target.value):""),placeholder:String(P.inboxes.chosen.length*30),className:"w-20 rounded-lg border border-slate-200 px-2 py-1 text-xs"})]}),e.jsxs("button",{onClick:xt,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[r==="create"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ds,{className:"h-3.5 w-3.5"})," Create campaign in Instantly"]}),e.jsxs("button",{onClick:ct,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[r==="list"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ts,{className:"h-3.5 w-3.5"})," Link an existing one"]})]}),v&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{value:k,onChange:p=>E(p.target.value),className:"rounded-lg border border-slate-200 px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"",children:"Pick an Instantly campaign…"}),j.map(p=>e.jsxs("option",{value:p.id,children:[p.name," · ",p.status]},p.id))]}),e.jsxs("button",{onClick:ot,disabled:!k||r!==null,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[r==="link"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ts,{className:"h-3.5 w-3.5"})," Link"]}),e.jsx("button",{onClick:()=>o(!1),className:"rounded-lg px-2 py-1.5 text-xs text-slate-500 hover:bg-slate-100",children:e.jsx(ce,{className:"h-3.5 w-3.5"})})]}),!ve&&!ge&&Ne&&e.jsxs("p",{className:"text-xs text-slate-400",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"An admin creates or links the campaign."]})]}),e.jsx(qe,{n:4,title:Te[3],done:os,blocked:!oe,what:"Instantly posts every send, open, click, reply, bounce and unsubscribe back here. Replies are sorted warm, cool, cold on arrival and show up in Warm Leads. One click, done once for the whole workspace.",children:os?e.jsxs("p",{className:"text-xs text-slate-600",children:["Wired · Instantly posts to Mission Control (",P.webhook.eventType||"all events",")."]}):ve&&oe?e.jsxs("button",{onClick:ht,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[r==="webhook"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(fs,{className:"h-3.5 w-3.5"})," Connect replies"]}):e.jsxs("p",{className:"text-xs text-slate-400",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"An admin connects replies."]})}),e.jsxs(qe,{n:5,title:Te[4],done:!1,blocked:!ge,what:`Hands the approved sequences and their verified leads to the Instantly campaign and starts it. Only leads with an approved ${P.launch.stepCount}-touch sequence and a verified email go. Admin-only, typed confirmation.`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:P.launch.ready})," lead",P.launch.ready===1?"":"s"," ready to launch",P.launch.inSequence?` · ${P.launch.inSequence} already in sequence`:""]}),ve?e.jsxs("button",{onClick:ft,disabled:r!==null||!ge,className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-900 px-3.5 py-1.5 text-xs font-semibold text-white hover:bg-slate-800 disabled:opacity-40",children:[r==="preview"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(es,{className:"h-3.5 w-3.5"})," Review & launch…"]}):e.jsxs("span",{className:"text-xs text-slate-400",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"Launch is admin-only."]})]}),!jt&&ge&&e.jsx("p",{className:"mt-2 text-[11px] text-slate-400",children:"Approve leads → Find emails → Draft sequences → approve the sequences in Approvals. Then this lights up."})]})]})]}),$&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/50 p-4",onClick:()=>N(null),role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"w-full max-w-2xl rounded-2xl bg-white p-6 shadow-pop",onClick:p=>p.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(es,{className:"h-5 w-5 text-slate-900"}),e.jsx("h2",{className:"text-base font-semibold text-slate-900",children:"Launch to Instantly"})]}),e.jsx("button",{onClick:()=>N(null),"aria-label":"Close",className:"rounded-lg p-1 text-slate-400 hover:bg-slate-100",children:e.jsx(ce,{className:"h-4 w-4"})})]}),$.campaign&&e.jsxs("div",{className:"mt-4 rounded-xl border border-slate-200 bg-slate-50 p-4 text-sm text-slate-700",children:[e.jsxs("div",{className:"font-semibold text-slate-900",children:[$.campaign.name," ",e.jsx("span",{className:"ml-2 roun
217ded-full bg-slate-200 px-2 py-0.5 text-[10px] font-semibold text-slate-600",children:$.campaign.status})]}),e.jsxs("div",{className:"mt-1 text-xs text-slate-500",children:["Sends from ",$.campaign.inboxes.join(", "),$.campaign.dailyLimit?` · up to ${$.campaign.dailyLimit}/day`:""," · business days · stops on reply"]})]}),$.blockers.length>0&&e.jsxs("div",{className:"mt-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800",children:[e.jsx(as,{className:"mr-1 inline h-4 w-4"}),$.blockers.join(" ")]}),e.jsx("div",{className:"mt-4 max-h-64 overflow-auto rounded-xl border border-slate-200",children:e.jsxs("table",{className:"w-full min-w-[34rem] text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-100 text-left text-[10px] uppercase tracking-wide text-slate-400",children:[e.jsx("th",{className:"px-3 py-2 font-medium",children:"Lead"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Email"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"First subject"})]})}),e.jsxs("tbody",{children:[$.leads.map(p=>e.jsxs("tr",{className:"border-b border-slate-50 last:border-0",children:[e.jsxs("td",{className:"px-3 py-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:p.who||p.company}),e.jsxs("div",{className:"text-slate-400",children:[p.company,p.title?` · ${p.title}`:""]})]}),e.jsx("td",{className:"px-3 py-2 text-slate-700",children:p.email}),e.jsx("td",{className:"px-3 py-2 text-slate-600",children:p.firstSubject})]},p.email)),$.leads.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"px-3 py-4 text-center text-slate-400",children:"Nothing ready to launch."})})]})]})}),$.excluded.length>0&&e.jsxs("details",{className:"mt-3 text-xs text-slate-500",children:[e.jsxs("summary",{className:"cursor-pointer font-medium",children:[$.excluded.length," not included — why"]}),e.jsx("ul",{className:"mt-2 space-y-1",children:$.excluded.map((p,re)=>e.jsxs("li",{children:[p.who," · ",p.company,": ",p.reason]},re))})]}),e.jsxs("label",{className:"mt-4 flex items-center gap-2 text-sm text-slate-700",children:[e.jsx("input",{type:"checkbox",checked:B,onChange:p=>z(p.target.checked),className:"h-4 w-4 rounded border-slate-300 text-brand-600"})," Start sending now (otherwise leads load into the campaign and it stays ",(($s=$.campaign)==null?void 0:$s.status)||"paused",")"]}),e.jsxs("label",{className:"mt-4 block text-xs font-medium uppercase tracking-wide text-slate-500",children:["Type ",e.jsx("span",{className:"font-mono text-slate-900",children:$.confirmWord})," to confirm",e.jsx("input",{value:w,onChange:p=>b(p.target.value),onKeyDown:p=>{p.key==="Enter"&&_s()},spellCheck:!1,autoComplete:"off",placeholder:$.confirmWord,className:"mt-1.5 w-full rounded-lg border border-slate-300 px-3 py-2 font-mono text-sm tracking-widest focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-100"})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>N(null),className:"rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Not yet"}),e.jsxs("button",{onClick:_s,disabled:w.trim()!==$.confirmWord||$.blockers.length>0||$.leads.length===0||r!==null,className:"inline-flex items-center gap-2 rounded-lg bg-slate-900 px-4 py-2 text-sm font-semibold text-white hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-40",children:[r==="launch"?e.jsx(G,{className:"h-4 w-4 animate-spin"}):e.jsx(es,{className:"h-4 w-4"})," Launch ",$.leads.length," lead",$.leads.length===1?"":"s"]})]})]})})]})}const qs={scripted:"bg-slate-100 text-slate-600",rendering:"bg-amber-50 text-amber-700",ready:"bg-emerald-50 text-emerald-700",failed:"bg-red-50 text-red-700"};function Ja({client:s}){var V;const[t,a]=l.useState(null),[i,m]=l.useState(null),[r,u]=l.useState(null),[h,d]=l.useState(null),[n,x]=l.useState(null),[v,o]=l.useState(null),[j,L]=l.useState(!1),[k,E]=l.useState(null),I=async()=>{m(null);try{const g=await C.video("status",s.id);a(g),E(g.settings),!g.connected&&g.error&&d(g.error)}catch(g){m(g.message)}};l.useEffect(()=>{I()},[s.id]);const T=async(g,H)=>{u(g),m(null),d(null);try{await H(),await I()}catch(y){m(y.message)}finally{u(null)}},$=()=>T("pick",async()=>{const[g,H]=await Promise.all([C.video("avatars",s.id),C.video("voices",s.id)]);x(g.items),o(H.items),L(!0)}),N=()=>T("save",async()=>{k&&(await C.video("save-settings",s.id,k),L(!1),d("Video settings saved."))}),w=()=>T("script",async()=>{const g=await C.video("script",s.id);
217d(`Scripted "${g.post.title}". Review it below, then render.`)}),b=g=>T(`render-${g}`,async()=>{const H=await C.video("render",s.id,{postId:g});d(`Sent to HeyGen. It renders in a few minutes${H.watch_url?" — you can watch it build in HeyGen":""}; click Check status.`)}),B=()=>T("poll",async()=>{const g=await C.video("poll",s.id),H=g.items.filter(y=>{var Y;return((Y=y.video)==null?void 0:Y.status)==="ready"}).length;d(H?`${H} video${H===1?"":"s"} finished.`:g.items.length?"Still rendering.":"Nothing rendering right now.")}),z=!!(t!=null&&t.connected),X=!!(t!=null&&t.isAdmin),A=t==null?void 0:t.settings;return e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white shadow-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{className:"h-4 w-4 text-brand-600"}),e.jsx("h2",{className:"text-sm font-semibold text-slate-800",children:"Video"}),e.jsx("span",{className:"text-xs text-slate-400",children:"· the Video Content Director scripts it, HeyGen renders it, a human approves it"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&z&&e.jsxs("span",{className:"text-xs text-slate-400",children:[A!=null&&A.per_month?`${t.thisMonth}/${A.per_month} this month`:"cadence off",((V=t.account)==null?void 0:V.balance)!=null?` · HeyGen balance ${t.account.balance}`:""]}),e.jsxs("button",{onClick:()=>void I(),className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50",children:[e.jsx(ke,{className:"h-3.5 w-3.5"})," Refresh"]})]})]}),e.jsxs("div",{className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700",children:i}),h&&e.jsx("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-800",children:h}),!t&&!i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-400",children:[e.jsx(G,{className:"h-4 w-4 animate-spin"})," Checking HeyGen…"]}),t&&!z&&e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900",children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[e.jsx(Ks,{className:"h-4 w-4"})," HeyGen isn't connected yet"]}),e.jsx("p",{className:"mt-1 text-xs",children:"Create an API key in HeyGen (Settings → API) and have it added to the server as HEYGEN_API_KEY. Scripts can be written now; rendering starts once the key is in."})]}),t&&e.jsxs("div",{className:"rounded-xl border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-slate-700",children:[e.jsxs("span",{children:[e.jsx("strong",{children:(A==null?void 0:A.per_month)??0})," video",(A==null?void 0:A.per_month)===1?"":"s"," a month"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(oa,{className:"h-3.5 w-3.5 text-slate-400"})," ",(A==null?void 0:A.avatar_name)||e.jsx("span",{className:"text-amber-700",children:"no avatar chosen"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ra,{className:"h-3.5 w-3.5 text-slate-400"})," ",(A==null?void 0:A.voice_name)||"avatar default voice"]}),e.jsxs("span",{className:"text-slate-500",children:[A==null?void 0:A.orientation," · ",A==null?void 0:A.duration_seconds,"s"]})]}),X&&z&&!j&&e.jsxs("button",{onClick:$,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[r==="pick"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Is,{className:"h-3.5 w-3.5"})," Choose avatar, voice & cadence"]}),!X&&e.jsxs("span",{className:"text-xs text-slate-400",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"An admin sets the cadence and avatar."]})]}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-400",children:"On the 1st and 15th the Director writes the next script and sends it to render until the month's count is met. Every finished video waits here for approval — nothing posts itself."}),j&&k&&e.jsxs("div",{className:"mt-4 space-y-4 border-t border-slate-100 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("label",{className:"text-xs text-slate-600",children:["Videos per month",e.jsx("select",{value:k.per_month,onChange:g=>E({...k,per_month:Number(g.target.value)}),className:"mt-1 block rounded-lg border border-slate-200 px-2 py-1.5 text-xs",children:[0,1,2,3,4].map(g=>e.jsx("option",{value:g,children:g},g))})]}),e.jsxs("label",{className:"text-xs text-slate-600",children:["Orientation",e.jsxs("select",{value:k.orientation,onChange:g=>E({...k,orientation:g.target.value}),className:"mt-1 block rounded-lg border border-slate-200 px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"portrait",children:"Portrait (LinkedIn, Reels, Shorts)"}),e.jsx("option",{value:"landscape",children:"Landscape (YouTube, site)"})]})]}),e.jsxs("label",{className:"text-xs text-slate-600",children:["Length (seconds)",e.jsx("input",{type:"number",min:20,max:120,value:k.duration_seconds,onChange:g=>E({...k,duration_seconds:Number(g.target.value)}),className:"mt-1 block w-24 rounded-lg border border-slate-200 px-2 py-1.5 text-xs"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-slate-600",children:"Avatar (your own first)"}),e.jsxs("div",{className:"flex max-h-56 flex-wrap gap-2 overflow-y-auto",children:[(n||[]).map(g=>e.jsxs("button",{onClick:()=>E({...k,avatar_id:g.id,avatar_name:g.name,voice_id:k.voice_id||g.default_voice_id||null}),className:`w-24 rounded-xl border p-1.5 text-left ${k.avatar_id===g.id?"border-brand-500 ring-2 ring-brand-100":"border-slate-200 hover:border-brand-300"}`,children:[g.preview?e.jsx("img",{src:g.preview,alt:"",className:"h-24 w-full rounded-lg object-cover"}):e.jsx("div",{className:"h-24 w-full rounded-lg bg-slate-100"}),e.jsx("div",{className:"mt-1 truncate text-[11px] font-medium text-slate-700",children:g.name}),g.own&&e.jsx("div",{className:"text-[10px] text-brand-600",children:"yours"})]},g.id)),n&&n.length===0&&e.jsx("span",{className:"text-xs text-slate-400",children:"No avatars returned by HeyGen."})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-slate-600",children:"Voice (your clones first)"}),e.jsxs("select",{value:k.voice_id||"",onChange:g=>{const H=(v||[]).find(y=>y.id===g.target.value);E({...k,voice_id:(H==null?void 0:H.id)||null,voice_name:(H==null?void 0:H.name)||null})},className:"w-full max-w-md rounded-lg border border-slate-200 px-2 py-1.5 text-xs",children:[e.jsx("option",{value:"",children:"Use the avatar's default voice"}),(v||[]).map(g=>e.jsxs("option",{value:g.id,children:[g.own?"★ ":"",g.name,g.gender?` · ${g.gender}`:""]},g.id))]})]}),e.jsxs("label",{className:"block text-xs text-slate-600",children:["Style paragraph (optional — colors, typography, motion;
217 leave blank for the clean founder look)",e.jsx("textarea",{value:k.style||"",onChange:g=>E({...k,style:g.target.value}),rows:3,className:"mt-1 w-full rounded-lg border border-slate-200 px-2 py-1.5 text-xs",placeholder:"Style: … palette with hex codes, art direction, how things move, transitions, one line for the vibe."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:N,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-50",children:[r==="save"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(we,{className:"h-3.5 w-3.5"})," Save"]}),e.jsx("button",{onClick:()=>L(!1),className:"rounded-lg px-3 py-1.5 text-xs font-medium text-slate-500 hover:bg-slate-100",children:"Cancel"})]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:w,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-900 px-3.5 py-1.5 text-xs font-semibold text-white hover:bg-slate-800 disabled:opacity-50",children:[r==="script"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(me,{className:"h-3.5 w-3.5"})," Write the next script"]}),z&&t.videos.some(g=>g.video.status==="rendering")&&e.jsxs("button",{onClick:B,disabled:r!==null,className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[r==="poll"?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ke,{className:"h-3.5 w-3.5"})," Check status"]})]}),t&&t.videos.length>0&&e.jsx("ul",{className:"space-y-3",children:t.videos.map(g=>e.jsxs("li",{className:"flex flex-col gap-3 rounded-xl border border-slate-200 p-4 sm:flex-row",children:[e.jsx("div",{className:"w-full shrink-0 sm:w-44",children:g.video.status==="ready"&&g.video.video_url?e.jsx("video",{src:g.video.video_url,poster:g.video.thumbnail_url||void 0,controls:!0,className:"w-full rounded-lg bg-black"}):g.video.thumbnail_url?e.jsx("img",{src:g.video.thumbnail_url,alt:"",className:"w-full rounded-lg"}):e.jsx("div",{className:"flex aspect-[9/16] max-h-44 w-full items-center justify-center rounded-lg bg-slate-100 text-xs text-slate-400",children:g.video.status==="rendering"?"rendering…":"script"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-semibold text-slate-900",children:g.title}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${qs[g.video.status]||qs.scripted}`,children:g.video.status}),g.video.duration?e.jsxs("span",{className:"text-[11px] text-slate-400",children:[Math.round(g.video.duration),"s"]}):null]}),g.hook&&e.jsxs("p",{className:"mt-1 text-sm text-slate-700",children:["“",g.hook,"”"]}),g.why&&e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:g.why}),g.video.error&&e.jsx("p",{className:"mt-1 text-xs text-red-600",children:g.video.error}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[g.video.status==="scripted"&&(X?e.jsxs("button",{onClick:()=>b(g.id),disabled:r!==null||!z||!(A!=null&&A.avatar_id),title:A!=null&&A.avatar_id?"Sends the script to HeyGen — uses HeyGen credits":"Choose an avatar first",className:"inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-brand-500 disabled:opacity-40",children:[r===`render-${g.id}`?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Is,{className:"h-3.5 w-3.5"})," Render in HeyGen"]}):e.jsxs("span",{className:"text-xs text-slate-400",children:[e.jsx(be,{className:"mr-1 inline h-3 w-3"}),"Rendering is admin-only."]})),g.video.session_id&&e.jsxs("a",{href:`https://app.heygen.com/video-agent/${g.video.session_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-brand-600 hover:underline",children:["Open in HeyGen ",e.jsx(Fe,{className:"h-3 w-3"})]}),g.video.video_url&&e.jsxs("a",{href:g.video.video_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-brand-600 hover:underline",children:["Download MP4 ",e.jsx(Fe,{className:"h-3 w-3"})]})]}),g.caption&&g.video.status==="ready"&&e.jsxs("p",{className:"mt-2 rounded-lg bg-slate-50 p-2 text-xs text-slate-600",children:[e.jsx("span",{className:"font-medium text-slate-500",children:"Caption:"})," ",g.caption]})]})]},g.id))}),t&&t.videos.length===0&&e.jsx("p",{className:"rounded-xl border border-dashed border-slate-200 p-4 text-sm text-slate-500",children:"No videos yet. Write the first script — it draws on the ICP, the intent signals, and the latest article."})]})]})}function en(){const{id:s=""}=Hs(),t=Re(),[a,i]=l.useState(null),[m,r]=l.useState(!0),[u,h]=l.useState(null),d=_e(),[n,x]=l.useState(new Set),[v,o]=l.useState(!1),{role:j}=Le(),L=b=>x(B=>{const z=new Set(B);return z.has(b)?z.delete(b):z.add(b),z});l.useEffect(()=>{let b=!1;return(async()=>{r(!0);try{const B=await C.getClient(s);b||i(B)}catch(B){b||h(te(B))}finally{b||r(!1)}})(),()=>{b=!0}},[s]);const k=async b=>{if(!a)return;const B=a;i({...a,...b});try{await C.updateClient(a.id,b),"stage"in b&&b.stage&&d.success(`${a.company||a.name}: ${$e[b.stage].label.toLowerCase()}.`)}catch(z){i(B),d.error(te(z))}},E=a?Et(a.checklist):[],I=b=>k({checklist:E.map(B=>B.key===b?{...B,done:!B.done}:B)}),T=(b,B)=>k({checklist:E.map(z=>z.key===b?{...z,note:B}:z)});if(m)return e.jsx("div",{className:"py-16 text-center text-sm text-slate-400",children:"Loading…"});if(u)return e.jsxs("div",{className:"py-16 text-center text-sm text-red-600",children:["Couldn't load this client: ",u,". ",e.jsx("button",{onClick:()=>window.location.reload(),className:"underline",children:"Try again"})]});if(!a)return e.jsxs("div",{className:"py-16 text-center text-sm text-slate-400",children:["Client not found. ",e.jsx(K,{to:"/clients",className:"text-brand-600 underline",children:"Back to Clients"})]});const $=vs(a.checklist),N=$e[a.stage]??$e.onboarding,w=ls(a.checklist);return e.jsxs("div",{className:"space-y-6",children:[v&&e.jsx(cs,{kind:"client",id:a.id,onClose:()=>o(!1),onDeleted:()=>t("/clients")}),e.jsxs("button",{onClick:()=>t("/clients"),className:"inline-flex items-center gap-1.5 text-sm text-slate-500 transition hover:text-slate-900",children:[e.jsx(Gs,{className:"h-4 w-4"})," Clients"]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-slate-900",children:a.company||a.name||"Client"}),e.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-[11px] font-medium ${N.cls}`,children:N.label}),e.jsx("button",{onClick:()=>k({kind:a.kind==="own"?"customer":"own"}),title:"Click to switch between one of your own brands and a paying customer",className:`inline-flex rounded-full px-2.5 py-0.5 text-[11px] font-medium ring-1 ${a.kind==="own"?"bg-indigo-50 text-indigo-700 ring-indigo-200":"bg-slate-50 text-slate-600 ring-slate-200"}`,children:a.kind==="own"?"Your brand":"Customer"})]}),e.jsx("div",{className:"mt-1 text-sm text-slate-500",children:[a.name,a.email].filter(
217Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[it(a).map(b=>e.jsxs("button",{onClick:()=>k({stage:b.next}),title:b.hint,className:`inline-flex items-center gap-1.5 rounded-lg px-3.5 py-2 text-sm font-semibold transition ${b.tone==="success"?"bg-emerald-600 text-white hover:bg-emerald-500":"border border-slate-200 text-slate-600 hover:bg-slate-50"}`,children:[b.key==="go-live"?e.jsx(es,{className:"h-4 w-4"}):b.key==="pause"?e.jsx(Xs,{className:"h-4 w-4"}):e.jsx(Js,{className:"h-4 w-4"})," ",b.label]},b.key)),j==="admin"&&e.jsxs("button",{onClick:()=>o(!0),title:"Delete this client permanently (asks you to type DELETE)",className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-400 hover:border-red-200 hover:bg-red-50 hover:text-red-600",children:[e.jsx(Ce,{className:"h-4 w-4"})," Delete"]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[e.jsx("div",{className:"h-2 w-full max-w-md overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:`h-full rounded-full ${w?"bg-emerald-500":"bg-brand-500"}`,style:{width:`${$.done/$.total*100}%`}})}),e.jsxs("span",{className:"shrink-0 text-xs font-medium tabular-nums text-slate-500",children:[$.done,"/",$.total," steps"]})]}),e.jsxs("p",{className:"mt-2 text-xs text-slate-400",children:["Live when these are done: warmed inboxes · first campaign sending · first blog published · weekly report running.",w&&a.stage!=="live"&&e.jsx("span",{className:"ml-1 font-medium text-emerald-600",children:"All go-live steps complete — mark live."})]})]}),e.jsx(Qa,{client:a,onCampaignLinked:b=>i(B=>B&&{...B,campaign_id:b})}),e.jsx(Xa,{client:a}),e.jsx(Ja,{client:a}),e.jsx(Za,{client:a}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[1fr_340px]",children:[e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white p-6 shadow-card",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-700",children:"Onboarding checklist"}),e.jsx("ol",{className:"mt-4 space-y-3",children:Lt.map((b,B)=>{const z=E.find(V=>V.key===b.key),X=(z==null?void 0:z.done)??!1,A=It(b.key);return e.jsx("li",{className:`rounded-xl border p-4 transition ${X?"border-emerald-200 bg-emerald-50/40":"border-slate-200"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>I(b.key),"aria-label":X?"Mark incomplete":"Mark complete",className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-md border transition ${X?"border-emerald-500 bg-emerald-500 text-white":"border-slate-300 hover:border-brand-400"}`,children:X&&e.jsx(we,{className:"h-3.5 w-3.5",strokeWidth:3})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400",children:B+1}),e.jsx("span",{className:`text-sm font-semibold ${X?"text-slate-500 line-through":"text-slate-800"}`,children:b.label}),b.live&&e.jsx("span",{className:"rounded-full bg-slate-100 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-slate-400",children:"go-live"})]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-500",children:b.hint}),(A==null?void 0:A.steps)&&A.steps.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:()=>L(b.key),className:"inline-flex items-center gap-1 text-[11px] font-semibold text-brand-600 transition hover:text-brand-700",children:[n.has(b.key)?e.jsx(Cs,{className:"h-3.5 w-3.5"}):e.jsx(Zs,{className:"h-3.5 w-3.5"}),"How to do this — ",A.steps.length," steps"]}),n.has(b.key)&&e.jsx("ol",{className:"mt-2 space-y-2 rounded-xl bg-slate-50 p-3.5",children:A.steps.map((V,g)=>e.jsxs("li",{className:"flex gap-2.5 text-xs leading-relaxed text-slate-600",children:[e.jsx("span",{className:"mt-px flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-brand-100 text-[9px] font-bold text-brand-700",children:g+1}),e.jsx("span",{children:V})]},g))})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(sn,{value:(z==null?void 0:z.note)??"",onSave:V=>T(b.key,V)}),(A==null?void 0:A.link)&&(A.link.external?e.jsxs("a",{href:A.link.to,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-slate-200 px-2.5 py-1 text-[11px] font-medium text-slate-600 hover:bg-slate-50",children:[A.link.label," ",e.jsx(Fe,{className:"h-3 w-3"})]}):e.jsxs(K,{to:A.link.to,className:"inline-flex items-center gap-1 rounded-md border border-slate-200 px-2.5 py-1 text-[11px] font-medium text-slate-600 hover:bg-slate-50",children:[A.link.label," ",e.jsx(Qs,{className:"h-3 w-3"})]}))]})]})]})},b.key)})})]}),e.jsxs("aside",{className:"space-y-6",children:[e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-card",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-700",children:"Client details"}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx(pe,{label:"Contact name",value:a.name,onSave:b=>k({name:b})}),e.jsx(pe,{label:"Email",value:a.email,onSave:b=>k({email:b})}
217),e.jsx(pe,{label:"Phone",value:a.phone,onSave:b=>k({phone:b})}),e.jsx(pe,{label:"Website",value:a.website,onSave:b=>k({website:b}),placeholder:"https://"}),e.jsx(pe,{label:"Industry",value:a.industry,onSave:b=>k({industry:b})}),e.jsx(pe,{label:"Plan / services",value:a.services,onSave:b=>k({services:b})}),typeof a.monthly=="number"&&e.jsxs("p",{className:"text-xs text-slate-400",children:[se(a.monthly),"/mo",typeof a.setup=="number"?` · ${se(a.setup)} setup`:""]})]})]}),e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 text-brand-600"}),e.jsx("h2",{className:"text-sm font-semibold text-slate-700",children:"Intent triggers"})]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-500",children:"The buying signals the intent agent seeks — seeded from the website analysis, refined with the client. Keep the 3–5 that best predict a purchase; the Research step points the agent at these."}),e.jsx("div",{className:"mt-3",children:e.jsx(hs,{label:"Signals to watch",value:a.triggers,onSave:b=>k({triggers:b}),placeholder:"e.g. posted a job for a controller · opened a new location · switched to NetSuite · raised funding"})})]}),e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-card",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-700",children:"Delivery setup"}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx(pe,{label:"Sending domains",value:a.sending_domains,onSave:b=>k({sending_domains:b}),placeholder:"e.g. getcompany.com, trycompany.com"}),e.jsx(pe,{label:"Instantly campaign ID",value:a.instantly_campaign_id,onSave:b=>k({instantly_campaign_id:b})}),e.jsx(pe,{label:"Calendly",value:a.calendly,onSave:b=>k({calendly:b})}),e.jsx(pe,{label:"Socials",value:a.socials,onSave:b=>k({socials:b})}),e.jsx(hs,{label:"Brand voice notes",value:a.brand_notes,onSave:b=>k({brand_notes:b}),placeholder:"Tone, examples, words to use/avoid…"}),e.jsx(hs,{label:"Do-not-contact",value:a.do_not_contact,onSave:b=>k({do_not_contact:b}),placeholder:"Domains / people to exclude"})]})]}),e.jsx(Ua,{context:{company:a.company,stage:a.stage,step:a.stage==="live"?"Live — maintaining":Ns(a.checklist),triggers:a.triggers,industry:a.industry,services:a.services}})]})]}),e.jsxs("section",{className:"rounded-2xl border border-red-100 bg-white p-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-red-700",children:"Danger zone"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("p",{className:"max-w-xl text-sm text-slate-600",children:["Deleting removes this client, its campaign, and every lead, sequence, event, and report under it. It cannot be undone, and nothing in Instantly is changed. If you might need it again, ",e.jsx("strong",{children:"Pause"})," instead."]}),j==="admin"?e.jsxs("button",{onClick:()=>o(!0),className:"inline-flex items-center gap-2 rounded-lg border border-red-200 bg-red-50 px-4 py-2 text-sm font-semibold text-red-700 hover:bg-red-100",children:[e.jsx(Ce,{className:"h-4 w-4"})," Delete this client…"]}):e.jsx("span",{className:"text-xs text-slate-400",children:"Only an admin can delete a client."})]})]})]})}function pe({label:s,value:t,onSave:a,placeholder:i}){const[m,r]=l.useState(t??"");return l.useEffect(()=>r(t??""),[t]),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-slate-500",children:s}),e.jsx("input",{value:m,onChange:u=>r(u.target.value),onBlur:()=>m!==(t??"")&&a(m),placeholder:i,className:"mt-1 h-10 w-full rounded-lg border border-slate-200 bg-white px-3 text-sm outline-none transition focus:border-brand-400 focus:ring-2 focus:ring-brand-100"})]})}function hs({label:s,value:t,onSave:a,placeholder:i}){const[m,r]=l.useState(t??"");return l.useEffect(()=>r(t??""),[t]),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-slate-500",children:s}),e.jsx("textarea",{value:m,onChange:u=>r(u.target.value),onBlur:()=>m!==(t??"")&&a(m),placeholder:i,rows:2,className:"mt-1 w-full resize-y rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm outline-none transition focus:border-brand-400 focus:ring-2 focus:ring-brand-100"})]})}function sn({value:s,onSave:t}){const[a,i]=l.useState(s??"");return l.useEffect(()=>i(s??""),[s]),e.jsx("input",{value:a,onChange:m=>i(m.target.value),onBlur:()=>a!==(s??"")&&t(a),placeholder:"Add a note…",className:"h-8 flex-1 min-w-[8rem] rounded-md border border-slate-200 bg-white px-2.5 text-[12px] outline-none transition focus:border-brand-400 focus:ring-2 focus:ring-brand-100"})}function tn(){var n;const s=_e(),[t,a]=l.useState(null),[i,m]=l.useState(null),[r,u]=l.useState(null),h=()=>C.listApprovalViews().then(x=>a(x.filter(v=>v.approval.state==="pending"))).catch(x=>{a([]),s.error(te(x))});l.useEffect(()=>{h()},[]);const d=async(x,v,o)=>{if(!i){m(x);try{await C.decideApproval(x,v,await ws(),o),s.success(v==="approved"?"Approved — it will go out on the next launch.":v==="revised"?"Sent back to the Copywriter with your note.":"Rejected."),await h()}catch(j){s.error(te(j))}finally{m(null)}}};return t===null?e.jsx("div",{className:"space-y-4",children:[0,1].map(x=>e.jsx(W,{className:"h-40 animate-pulse bg-slate-50"},x))}
217):t.length===0?e.jsx(Ee,{icon:Ae,title:"No approvals pending",hint:"Drafts from the Copywriter land here before anything sends."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:[t.length," sequence",t.length===1?"":"s"," awaiting your approval · nothing sends without a click."]}),t.map(x=>{const{approval:v,campaign:o,prospect:j}=x;return e.jsxs(W,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-800",children:(j==null?void 0:j.company)??"Prospect"}),e.jsxs("div",{className:"text-xs text-slate-500",children:[[j==null?void 0:j.contact_name,j==null?void 0:j.title].filter(Boolean).join(" · "),o&&e.jsxs(e.Fragment,{children:[" · ",e.jsx(K,{to:`/campaigns/${o.slug}`,className:"text-brand-600 hover:underline",children:o.name})]})]}),(j==null?void 0:j.trigger)&&e.jsxs("div",{className:"mt-1 text-xs text-brand-700",children:["Signal: ",j.trigger]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx(ae,{className:"bg-amber-100 text-amber-700 ring-amber-600/20",children:v.state}),e.jsx("span",{className:"text-[11px] text-slate-400",children:he(v.created_at)})]})]}),e.jsxs("div",{className:"mt-2 rounded-lg bg-slate-50 p-3 text-xs text-slate-500",children:[e.jsxs("span",{className:"font-medium text-slate-600",children:[v.methodology.framework,":"]})," ",v.methodology.notes]}),e.jsx("div",{className:"mt-3 space-y-3",children:v.sequence.map(L=>e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3",children:[e.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-400",children:["Step ",L.step," · day ",L.send_day]}),e.jsx("div",{className:"mt-1 text-sm font-medium text-slate-800",children:L.subject}),e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-sm text-slate-600",children:L.body})]},L.step))}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(ie,{variant:"primary",disabled:i!==null,onClick:()=>d(v.id,"approved"),children:i===v.id?"Working…":"Approve"}),e.jsx(ie,{variant:"secondary",disabled:i!==null,onClick:()=>u(x),children:"Send back with a note"}),e.jsx(ie,{variant:"danger",disabled:i!==null,onClick:()=>d(v.id,"rejected"),children:"Reject"})]})]},v.id)}),r&&e.jsx(rt,{title:`Send back: ${((n=r.prospect)==null?void 0:n.company)??"this sequence"}`,body:"Tell the Copywriter what to change. The note is logged on the campaign and the sequence leaves this queue until it's redrafted.",noteLabel:"What should change?",notePlaceholder:"e.g. First line is generic — lead with the funding news. Drop the second follow-up.",requireNote:!0,confirmLabel:"Send back",onConfirm:async x=>{await d(r.approval.id,"revised",x),u(null)},onClose:()=>u(null)})]})}function an(){const s=_e(),[t,a]=l.useState(null),[i,m]=l.useState("all");if(l.useEffect(()=>{C.listWarmLeads().then(a).catch(h=>{a([]),s.error(te(h))})},[]),t===null)return e.jsx("div",{className:"space-y-3",children:[0,1,2].map(h=>e.jsx(W,{className:"h-24 animate-pulse bg-slate-50"},h))});if(t.length===0)return e.jsx(Ee,{icon:He,title:"No replies to action yet",hint:"When Instantly reports a reply, the Follow-up Rep sorts it and warm or cool ones land here."});const r=t.filter(h=>h.event.classification==="warm").length,u=t.filter(h=>i==="all"||h.event.classification===i);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:[e.jsx("strong",{className:"text-slate-800",children:r})," warm · ",t.length-r," cool · reply to warm ones within the hour"]}),e.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-slate-100 p-0.5 text-xs font-medium",children:["all","warm","cool"].map(h=>e.jsx("button",{onClick:()=>m(h),className:`rounded-md px-3 py-1.5 capitalize ${i===h?"bg-white text-slate-900 shadow-sm":"text-slate-500 hover:text-slate-800"}`,children:h},h))})]}),u.map(({event:h,campaign:d,prospect:n})=>e.jsx(W,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col items-start justify-between gap-4 sm:flex-row",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-slate-800",children:(n==null?void 0:n.company)??(d==null?void 0:d.name)??"Prospect"}),(n==null?void 0:n.contact_name)&&e.jsxs("span",{className:"text-sm text-slate-500",children:["· ",n.contact_name,n.title?`, ${n.title}`:""]}),e.jsx(ae,{className:`${ks[h.classification??"cold"]} ring-0`,children:h.classification})]}),e.jsxs("div",{className:"mt-1 rounded-lg bg-slate-50 p-3 text-sm text-slate-700",children:["“",h.reply_text,"”"]}),e.jsxs("div",{className:"mt-1.5 text-xs text-slate-400",children:[d?e.jsx(K,{to:`/campaigns/${d.slug}`,className:"text-brand-600 hover:underline",children:d.name}):"campaign unknown"," · ",he(h.created_at)]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2 sm:flex-col",children:[n!=null&&n.email?e.jsxs("a",{href:`mailto:${n.email}?subject=${encodeURIComponent("Re: your reply")}`,className:`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium ${h.classification==="warm"?"bg-brand-600 text-white hover:bg-brand-700":"border border-slate-200 bg-white text-slate-700 hover:bg-slate-50"}`,children:[e.jsx(me,{className:"h-4 w-4"})," Reply now"]}):e.jsx("span",{className:"text-xs text-slate-400",children:"no email on file"}),d&&e.jsx(K,{to:`/campaigns/${d.slug}`,className:"rounded-lg border border-slate-200 bg-white px-3 py-2 text-center text-sm font-medium text-slate-600 hover:bg-slate-50",children:"Open campaign"})]})]})},h.id))]})}function nn(){const[s,t]=l.useState(null),[a,i]=l.useState(null),m=()=>
217C.listContentViews("draft").then(t).catch(()=>t([]));l.useEffect(()=>{m()},[]);const r=async(u,h)=>{i(u);try{await C.decideContent(u,h),await m()}finally{i(null)}};return s===null?e.jsx("div",{className:"space-y-4",children:[0,1].map(u=>e.jsx(W,{className:"h-32 animate-pulse bg-slate-50"},u))}):s.length===0?e.jsx(Ee,{icon:Bs,title:"No content to review",hint:"When the Content Engine drafts a blog + social pack, it lands here for approval before publishing."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:[s.length," content ",s.length===1?"draft":"drafts"," awaiting review · nothing publishes without a click."]}),s.map(({post:u,campaign:h})=>e.jsx(ln,{view:{post:u,campaign:h},busy:a===u.id,onDecide:r},u.id))]})}function ln({view:s,busy:t,onDecide:a}){const{post:i,campaign:m}=s,[r,u]=l.useState(!1),h=i.social;return e.jsxs(W,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-800",children:i.title}),e.jsxs("div",{className:"mt-0.5 text-xs text-slate-500",children:[m&&e.jsx(K,{to:`/campaigns/${m.slug}`,className:"text-brand-600 hover:underline",children:m.name})," · ",he(i.created_at)," · /",i.slug]}),i.meta_description&&e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:i.meta_description})]}),e.jsx(ae,{className:"shrink-0 bg-amber-100 text-amber-700 ring-amber-600/20",children:i.status})]}),e.jsxs("div",{className:"mt-3 rounded-lg bg-slate-50 p-4",children:[e.jsx("div",{className:`whitespace-pre-wrap text-sm leading-relaxed text-slate-700 ${r?"":"line-clamp-6"}`,children:i.body_md}),e.jsx("button",{onClick:()=>u(d=>!d),className:"mt-2 text-xs font-medium text-brand-600 hover:underline",children:r?"Show less":"Read full post"})]}),i.tidbits&&i.tidbits.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:"Tidbits"}),e.jsx("ul",{className:"space-y-1",children:i.tidbits.map((d,n)=>e.jsx("li",{className:"rounded-lg border border-slate-100 p-2 text-sm text-slate-600",children:d},n))})]}),h&&e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-3",children:[e.jsx(ps,{icon:aa,label:"LinkedIn",text:h.linkedin}),e.jsx(ps,{icon:sa,label:"Instagram",text:h.instagram}),e.jsx(ps,{icon:Qt,label:"Facebook",text:h.facebook})]}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-slate-100 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx(ea,{className:"h-3.5 w-3.5"})," Featured image"]}),i.image_url?e.jsx("img",{src:i.image_url,alt:"",className:"rounded-md"}):e.jsx("p",{className:"text-sm italic text-slate-500",children:i.image_prompt||"No image prompt."})]}),(h==null?void 0:h.sources)&&h.sources.length>0&&e.jsxs("div",{className:"rounded-lg border border-slate-100 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx(ts,{className:"h-3.5 w-3.5"})," Sources"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:h.sources.map(d=>e.jsx(ae,{className:"bg-slate-100 text-slate-600 ring-slate-400/20",children:d},d))})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx(ie,{variant:"primary",disabled:t,onClick:()=>a(i.id,"approved"),children:t?"Working…":"Approve for publishing"}),e.jsx(ie,{variant:"danger",disabled:t,onClick:()=>a(i.id,"rejected"),children:"Reject"})]})]})}function ps({icon:s,label:t,text:a}){return e.jsxs("div",{className:"rounded-lg border border-slate-100 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx(s,{className:"h-3.5 w-3.5"})," ",t]}),e.jsx("p",{className:"whitespace-pre-wrap text-sm text-slate-600",children:a})]})}function rn(){const s=_e(),[t,a]=l.useState(null),[i,m]=l.useState([]),[r,u]=l.useState("");l.useEffect(()=>{C.listActivity().then(a).catch(n=>{a([]),s.error(te(n))}),C.listCampaigns().then(m).catch(()=>{})},[]);const h=n=>i.find(x=>x.id===n),d=(t||[]).filter(n=>{var x;return!r.trim()||`${n.message} ${((x=h(n.campaign_id))==null?void 0:x.name)||""} ${n.agent_role||""}`.toLowerCase().includes(r.trim().toLowerCase())});return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"text-sm text-slate-500",children:["Everything the team and the experts did, newest first",t&&t.length>=200?" · showing the latest 200":"","."]}),e.jsx("input",{value:r,onChange:n=>u(n.target.value),"aria-label":"Filter activity",placeholder:"Filter…",className:"w-56 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-sm focus:border-brand-400 focus:outline-none focus:ring-2 focus:ring-brand-100"})]}),e.jsxs(W,{className:"p-2",children:[t===null&&e.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3,4].map(n=>e.jsx("div",{className:"h-4 animate-pulse rounded bg-slate-100",style:{width:`${80-n*8}%`}},n))}),(t==null?void 0:t.length)===0&&e.jsx("div",{className:"p-4 text-sm text-slate-500",children:"Nothing logged yet. Actions across clients and campaigns appear here."}),t&&t.length>0&&d.length===0&&e.jsx("div",{className:"p-4 text-sm text-slate-500",children:"Nothing matches that filter."}),e.jsx("ul",{children:d.map(n=>{const x=h(n.campaign_id);return e.jsxs("li",{className:"flex gap-3 rounded-lg p-3 hover:bg-slate-50",children:[n.agent_role?e.jsx(Ve,{role:n.agent_role}):e.jsx("div",{className:"h-8 w-8 rounded-lg bg-slate-100"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-slate-700",children:n.message}),e.jsxs("div",{className:"mt-0.5 text-[11px] text-slate-400",children:[n.agent_role?We[n.agent_role]||ue(n.agent_role).label:"System",x&&e.jsxs(e.Fragment,{children:[" · ",e.jsx(K,{to:`/campaigns/${x.slug}`,className:"text-brand-600 hover:underline",children:x.name})]})," · ",he(n.created_at)]})]})]},n.id)})})]})]})}const dn={ok:Ys,warn:as,off:Kt},Os={ok:"text-emerald-600",warn:"text-amber-600",off:"text-slate-400"};function cn(){const s=_e(),[t,a]=l.useState(null),[i,m]=l.useState(null),[r,u]=l.useState(!1),h=async()=>{u(!0);try{m(await C.health())}catch(d){s.error(te(d))}finally{u(!1)}};return l.useEffect(()=>{C.listSuppressionConflicts().then(a).catch(d=>{a([]),s.error(te(d))}),h()},[]),e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("section",{children:[e.jsx(ye,{action:e.jsxs("button",{onClick:()=>void h(),disabled:r,className:"inline-flex items-center gap-1.5 text-xs font-medium text-brand-600 hover:underline disabled:opacity-50",children:[r?e.jsx(G,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ke,{className:"h-3.5 w-3.5"})," Check again"]}),children:"Connections"}),e.jsxs(W,{children:[!i&&e.jsx("div",{className:"p-5 text-sm text-slate-500",children:r?"Checking each connection…":"Not checked yet."}),i==null?void 0:i.checks.map(d=>{const n=dn[d.status];return e.jsxs("div",{className:"flex items-start gap-3 border-b border-slate-100 px-5 py-3 last:border-0",children:[e.jsx(n,{className:`mt-0.5 h-4 w-4 shrink-0 ${Os[d.status]}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"text-sm font-medium text-slate-800",children:[d.label," ",e.jsxs("span",{className:"font-normal text-slate-400",children:["· ",d.detail]})]}),d.note&&e.jsx("div",{className:`text-xs ${d.status==="ok"?"text-slate-500":"text-amber-700"}`,children:d.note})]}),e.jsx("span",{className:`text-[11px] font-semibold uppercase tracking-wide ${Os[d.status]}`,children:d.status==="ok"?"connected":d.status==="warn"?"attention":"off"})]},d.key)}),i&&e.jsxs("div",{className:"px-5 py-2 text-[11px] text-slate-400",children:["Checked ",new Date(i.checked_at).toLocaleTimeString(),". Every line is a live call, not a label."]})]})]}),e.jsxs("section",{children:[e.jsx(ye,{children:"Suppression & conflicts"}),e.jsxs(W,{className:"p-5",children:[t===null?e.jsx("div",{className:"text-sm text-slate-500",children:"Checking for people targeted by more than one campaign…"}):t.length===0?e.jsxs("div",{className:"flex items-start gap-3 text-sm text-slate-600",children:[e.jsx(Ot,{className:"mt-0.5 h-4 w-4 text-emerald-600"})," No conflicts. Nobody is in more than one campaign's pipeline."]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3 text-sm text-amber-800",children:[e.jsx(da,{className:"mt-0.5 h-4 w-4"})," ",t.length," ",t.length===1?"person is":"people are"," in more than one campaign. Keep one, remove the rest, so two of our companies never write to the same inbox."]}),e.jsx("ul",{className:"divide-y divide-slate-100 rounded-lg border border-slate-200",children:t.map(d=>e.jsxs("li",{className:"px-3 py-2 text-sm",children:[e.jsx("span",{className:"font-medium text-slate-800",children:d.contact_name||d.email})," ",e.jsxs("span",{className:"text-slate-400",children:["· ",d.email]}),e.jsx("div",{className:"mt-0.5 flex flex-wrap gap-2 text-xs",children:d.campaigns.map(n=>e.jsx(K,{to:`/campaigns/${n.slug}`,className:"text-brand-600 hover:underline",children:n.name},n.id))})]},d.email))})]}),e.jsx("p",{className:"mt-3 text-xs text-slate-500",children:"Unsubscribes and bounces land on the suppression list automatically and are checked before every launch."})]})]}),e.jsxs("section",{children:[e.jsx(ye,{children:"Safety rules, as built"}),e.jsx(W,{className:"divide-y divide-slate-100 px-5",children:[["Human gate on everything outbound","Leads are reviewed by a person; sequences are approved by a person; launch needs an admin typing LAUNCH."],["Team-only access","Only emails on the team allowlist can sign in or call any server function. Admin-only: delete, launch, inbox orders, video rendering."],["No invented facts","Research keeps only sourced, dated evidence. The email finder never guesses an address. Scripts and reports may not invent customers, results, or scarcity."],["Deliverability first","Only warmed inboxes chosen per client, about 30 sends per inbox per day, text-only, suppression and do-not-contact checked before every launch."],["Nothing spends money silently","Inbox orders and video renders show the cost and require a typed confirmation."]].map(([d,n])=>e.jsxs("div",{className:"py-3",children:[e.jsx("div",{className:"text-sm font-medium text-slate-800",children:d}),e.jsx("div",{className:"text-xs text-slate-500",children:n})]},d))})]})]})}function on({children:s}){const{role:t,ready:a}=Le();return a?t==="admin"?s:e.jsx(Ft,{to:"/",replace:!0}):e.jsx("div",{className:"py-16 text-center text-sm text-slate-400",children:"Loading…"})}function xn(){return e.jsxs("div",{className:"py-20 text-center",children:[e.jsx("div",{className:"text-lg font-semibold text-slate-800",children:"That page doesn't exist"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Check the link, or head back to the Command Center."}),e.jsx(K,{to:"/",className:"mt-4 inline-block rounded-lg bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-500",children:"Command Center"})]})}function mn(){return e.jsx(Wt,{children:e.jsx(zt,{children:e.jsx(Bt,{children:e.jsxs(de,{element:e.jsx(ya,{}),children:[e.jsx(de,{index:!0,element:e.jsx(_a,{})}),e.jsx(de,{path:"clients",element:e.jsx(Ga,{})}),e.jsx(de,{path:"clients/:id",element:e.jsx(en,{})}),e.jsx(de,{path:"campaigns",element:e.jsx(Aa,{})}),e.jsx(de,{path:"campaigns/:slug",element:e.jsx(za,{})}),e.jsx(de,{path:"approvals",element:e.jsx(tn,{})}),e.jsx(de,{path:"leads",element:e.jsx(an,{})}),e.jsx(de,{path:"content",element:e.jsx(nn,{})}),e.jsx(de,{path:"intake",element:e.jsx(Ut,{})}),e.jsx(de,{path:"activity",element:e.jsx(rn,{})}),e.jsx(de,{path:"settings",element:e.jsx(on,{children:e.jsx(cn,{})})}),e.jsx(de,{path:"*",element:e.jsx(xn,{})})]})})})})}
217function jn(){return e.jsx(xa,{children:e.jsx(mn,{})})}export{jn 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.