@handled-ai/design-system 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (336) hide show
  1. package/README.md +14 -4
  2. package/dist/charts/bar-chart-component.d.ts +24 -0
  3. package/dist/charts/bar-chart-component.js +123 -0
  4. package/dist/charts/bar-chart-component.js.map +1 -0
  5. package/dist/charts/chart-tooltip.d.ts +26 -0
  6. package/dist/charts/chart-tooltip.js +69 -0
  7. package/dist/charts/chart-tooltip.js.map +1 -0
  8. package/dist/charts/chart.d.ts +64 -0
  9. package/dist/charts/chart.js +285 -0
  10. package/dist/charts/chart.js.map +1 -0
  11. package/dist/charts/donut-chart.d.ts +21 -0
  12. package/dist/charts/donut-chart.js +96 -0
  13. package/dist/charts/donut-chart.js.map +1 -0
  14. package/dist/charts/index.d.ts +11 -0
  15. package/dist/charts/index.js +10 -0
  16. package/dist/charts/index.js.map +1 -0
  17. package/dist/charts/pipeline-overview.d.ts +76 -0
  18. package/dist/charts/pipeline-overview.js +372 -0
  19. package/dist/charts/pipeline-overview.js.map +1 -0
  20. package/dist/charts/sankey-chart.d.ts +52 -0
  21. package/dist/charts/sankey-chart.js +219 -0
  22. package/dist/charts/sankey-chart.js.map +1 -0
  23. package/dist/charts/top-line-metrics.d.ts +26 -0
  24. package/dist/charts/top-line-metrics.js +224 -0
  25. package/dist/charts/top-line-metrics.js.map +1 -0
  26. package/dist/charts/trend-area-chart.d.ts +21 -0
  27. package/dist/charts/trend-area-chart.js +150 -0
  28. package/dist/charts/trend-area-chart.js.map +1 -0
  29. package/dist/charts/volume-analysis-chart.d.ts +19 -0
  30. package/dist/charts/volume-analysis-chart.js +121 -0
  31. package/dist/charts/volume-analysis-chart.js.map +1 -0
  32. package/dist/components/activity-detail.d.ts +38 -0
  33. package/dist/components/activity-detail.js +163 -0
  34. package/dist/components/activity-detail.js.map +1 -0
  35. package/dist/components/activity-log.d.ts +21 -0
  36. package/dist/components/activity-log.js +61 -0
  37. package/dist/components/activity-log.js.map +1 -0
  38. package/dist/components/agent-popover.d.ts +71 -0
  39. package/dist/components/agent-popover.js +282 -0
  40. package/dist/components/agent-popover.js.map +1 -0
  41. package/dist/components/agent-widget.d.ts +24 -0
  42. package/dist/components/agent-widget.js +117 -0
  43. package/dist/components/agent-widget.js.map +1 -0
  44. package/dist/components/avatar.d.ts +13 -0
  45. package/dist/components/avatar.js +140 -0
  46. package/dist/components/avatar.js.map +1 -0
  47. package/dist/components/badge.d.ts +12 -0
  48. package/dist/components/badge.js +75 -0
  49. package/dist/components/badge.js.map +1 -0
  50. package/dist/components/button.d.ts +13 -0
  51. package/dist/components/button.js +83 -0
  52. package/dist/components/button.js.map +1 -0
  53. package/dist/components/card.d.ts +11 -0
  54. package/dist/components/card.js +119 -0
  55. package/dist/components/card.js.map +1 -0
  56. package/dist/components/contact-list.d.ts +34 -0
  57. package/dist/components/contact-list.js +84 -0
  58. package/dist/components/contact-list.js.map +1 -0
  59. package/dist/components/dashboard-cards.d.ts +10 -0
  60. package/dist/components/dashboard-cards.js +164 -0
  61. package/dist/components/dashboard-cards.js.map +1 -0
  62. package/dist/components/data-table-display.d.ts +19 -0
  63. package/dist/components/data-table-display.js +109 -0
  64. package/dist/components/data-table-display.js.map +1 -0
  65. package/dist/components/data-table-filter.d.ts +18 -0
  66. package/dist/components/data-table-filter.js +107 -0
  67. package/dist/components/data-table-filter.js.map +1 -0
  68. package/dist/components/data-table-quick-views.d.ts +13 -0
  69. package/dist/components/data-table-quick-views.js +90 -0
  70. package/dist/components/data-table-quick-views.js.map +1 -0
  71. package/dist/components/data-table-toolbar.d.ts +18 -0
  72. package/dist/components/data-table-toolbar.js +45 -0
  73. package/dist/components/data-table-toolbar.js.map +1 -0
  74. package/dist/components/data-table.d.ts +39 -0
  75. package/dist/components/data-table.js +821 -0
  76. package/dist/components/data-table.js.map +1 -0
  77. package/dist/components/detail-view.d.ts +44 -0
  78. package/dist/components/detail-view.js +165 -0
  79. package/dist/components/detail-view.js.map +1 -0
  80. package/dist/components/dialog.d.ts +19 -0
  81. package/dist/components/dialog.js +188 -0
  82. package/dist/components/dialog.js.map +1 -0
  83. package/dist/components/dropdown-menu.d.ts +27 -0
  84. package/dist/components/dropdown-menu.js +279 -0
  85. package/dist/components/dropdown-menu.js.map +1 -0
  86. package/dist/components/entity-panel.d.ts +69 -0
  87. package/dist/components/entity-panel.js +584 -0
  88. package/dist/components/entity-panel.js.map +1 -0
  89. package/dist/components/inbox-row.d.ts +27 -0
  90. package/dist/components/inbox-row.js +139 -0
  91. package/dist/components/inbox-row.js.map +1 -0
  92. package/dist/components/inbox-toolbar.d.ts +21 -0
  93. package/dist/components/inbox-toolbar.js +203 -0
  94. package/dist/components/inbox-toolbar.js.map +1 -0
  95. package/dist/components/input.d.ts +5 -0
  96. package/dist/components/input.js +50 -0
  97. package/dist/components/input.js.map +1 -0
  98. package/dist/components/insights-filter-bar.d.ts +21 -0
  99. package/dist/components/insights-filter-bar.js +99 -0
  100. package/dist/components/insights-filter-bar.js.map +1 -0
  101. package/dist/components/item-list-display.d.ts +22 -0
  102. package/dist/components/item-list-display.js +240 -0
  103. package/dist/components/item-list-display.js.map +1 -0
  104. package/dist/components/item-list-filter.d.ts +16 -0
  105. package/dist/components/item-list-filter.js +87 -0
  106. package/dist/components/item-list-filter.js.map +1 -0
  107. package/dist/components/item-list-toolbar.d.ts +25 -0
  108. package/dist/components/item-list-toolbar.js +79 -0
  109. package/dist/components/item-list-toolbar.js.map +1 -0
  110. package/dist/components/item-list.d.ts +20 -0
  111. package/dist/components/item-list.js +702 -0
  112. package/dist/components/item-list.js.map +1 -0
  113. package/dist/components/label.d.ts +6 -0
  114. package/dist/components/label.js +55 -0
  115. package/dist/components/label.js.map +1 -0
  116. package/dist/components/message.d.ts +23 -0
  117. package/dist/components/message.js +117 -0
  118. package/dist/components/message.js.map +1 -0
  119. package/dist/components/metric-card.d.ts +25 -0
  120. package/dist/components/metric-card.js +107 -0
  121. package/dist/components/metric-card.js.map +1 -0
  122. package/dist/components/performance-metrics-table.d.ts +38 -0
  123. package/dist/components/performance-metrics-table.js +342 -0
  124. package/dist/components/performance-metrics-table.js.map +1 -0
  125. package/dist/components/preview-list.d.ts +14 -0
  126. package/dist/components/preview-list.js +83 -0
  127. package/dist/components/preview-list.js.map +1 -0
  128. package/dist/components/progress.d.ts +6 -0
  129. package/dist/components/progress.js +69 -0
  130. package/dist/components/progress.js.map +1 -0
  131. package/dist/components/quick-action-chat-area.d.ts +24 -0
  132. package/dist/components/quick-action-chat-area.js +178 -0
  133. package/dist/components/quick-action-chat-area.js.map +1 -0
  134. package/dist/components/quick-action-modal.d.ts +30 -0
  135. package/dist/components/quick-action-modal.js +288 -0
  136. package/dist/components/quick-action-modal.js.map +1 -0
  137. package/dist/components/quick-action-sidebar-nav.d.ts +51 -0
  138. package/dist/components/quick-action-sidebar-nav.js +528 -0
  139. package/dist/components/quick-action-sidebar-nav.js.map +1 -0
  140. package/dist/components/recommended-actions-section.d.ts +23 -0
  141. package/dist/components/recommended-actions-section.js +215 -0
  142. package/dist/components/recommended-actions-section.js.map +1 -0
  143. package/dist/components/report-card.d.ts +26 -0
  144. package/dist/components/report-card.js +69 -0
  145. package/dist/components/report-card.js.map +1 -0
  146. package/dist/components/score-analysis-modal.d.ts +26 -0
  147. package/dist/components/score-analysis-modal.js +141 -0
  148. package/dist/components/score-analysis-modal.js.map +1 -0
  149. package/dist/components/score-breakdown.d.ts +17 -0
  150. package/dist/components/score-breakdown.js +162 -0
  151. package/dist/components/score-breakdown.js.map +1 -0
  152. package/dist/components/score-feedback.d.ts +40 -0
  153. package/dist/components/score-feedback.js +209 -0
  154. package/dist/components/score-feedback.js.map +1 -0
  155. package/dist/components/score-ring.d.ts +14 -0
  156. package/dist/components/score-ring.js +79 -0
  157. package/dist/components/score-ring.js.map +1 -0
  158. package/dist/components/scroll-area.d.ts +7 -0
  159. package/dist/components/scroll-area.js +101 -0
  160. package/dist/components/scroll-area.js.map +1 -0
  161. package/dist/components/select.d.ts +17 -0
  162. package/dist/components/select.js +228 -0
  163. package/dist/components/select.js.map +1 -0
  164. package/dist/components/separator.d.ts +6 -0
  165. package/dist/components/separator.js +61 -0
  166. package/dist/components/separator.js.map +1 -0
  167. package/dist/components/sheet.d.ts +16 -0
  168. package/dist/components/sheet.js +168 -0
  169. package/dist/components/sheet.js.map +1 -0
  170. package/dist/components/sidebar.d.ts +73 -0
  171. package/dist/components/sidebar.js +723 -0
  172. package/dist/components/sidebar.js.map +1 -0
  173. package/dist/components/signal-feedback-inline.d.ts +51 -0
  174. package/dist/components/signal-feedback-inline.js +548 -0
  175. package/dist/components/signal-feedback-inline.js.map +1 -0
  176. package/dist/components/simple-data-table.d.ts +15 -0
  177. package/dist/components/simple-data-table.js +91 -0
  178. package/dist/components/simple-data-table.js.map +1 -0
  179. package/dist/components/skeleton.d.ts +5 -0
  180. package/dist/components/skeleton.js +44 -0
  181. package/dist/components/skeleton.js.map +1 -0
  182. package/dist/components/status-badge.d.ts +10 -0
  183. package/dist/components/status-badge.js +82 -0
  184. package/dist/components/status-badge.js.map +1 -0
  185. package/dist/components/styled-bar-list.d.ts +20 -0
  186. package/dist/components/styled-bar-list.js +59 -0
  187. package/dist/components/styled-bar-list.js.map +1 -0
  188. package/dist/components/suggested-actions.d.ts +110 -0
  189. package/dist/components/suggested-actions.js +1538 -0
  190. package/dist/components/suggested-actions.js.map +1 -0
  191. package/dist/components/table.d.ts +12 -0
  192. package/dist/components/table.js +147 -0
  193. package/dist/components/table.js.map +1 -0
  194. package/dist/components/tabs.d.ts +14 -0
  195. package/dist/components/tabs.js +129 -0
  196. package/dist/components/tabs.js.map +1 -0
  197. package/dist/components/textarea.d.ts +5 -0
  198. package/dist/components/textarea.js +47 -0
  199. package/dist/components/textarea.js.map +1 -0
  200. package/dist/components/timeline-activity.d.ts +34 -0
  201. package/dist/components/timeline-activity.js +181 -0
  202. package/dist/components/timeline-activity.js.map +1 -0
  203. package/dist/components/tooltip.d.ts +9 -0
  204. package/dist/components/tooltip.js +93 -0
  205. package/dist/components/tooltip.js.map +1 -0
  206. package/dist/components/view-mode-toggle.d.ts +16 -0
  207. package/dist/components/view-mode-toggle.js +24 -0
  208. package/dist/components/view-mode-toggle.js.map +1 -0
  209. package/dist/hooks/use-mobile.d.ts +3 -0
  210. package/dist/hooks/use-mobile.js +21 -0
  211. package/dist/hooks/use-mobile.js.map +1 -0
  212. package/dist/index.d.ts +68 -1878
  213. package/dist/index.js +69 -10918
  214. package/dist/index.js.map +1 -1
  215. package/dist/lib/icons.d.ts +18 -0
  216. package/dist/lib/icons.js +21 -0
  217. package/dist/lib/icons.js.map +1 -0
  218. package/dist/lib/utils.d.ts +5 -0
  219. package/dist/lib/utils.js +9 -0
  220. package/dist/lib/utils.js.map +1 -0
  221. package/dist/prototype/index.d.ts +20 -0
  222. package/dist/prototype/index.js +8 -0
  223. package/dist/prototype/index.js.map +1 -0
  224. package/dist/prototype/prototype-accounts-view.d.ts +22 -0
  225. package/dist/prototype/prototype-accounts-view.js +70 -0
  226. package/dist/prototype/prototype-accounts-view.js.map +1 -0
  227. package/dist/prototype/prototype-admin-view.d.ts +21 -0
  228. package/dist/prototype/prototype-admin-view.js +53 -0
  229. package/dist/prototype/prototype-admin-view.js.map +1 -0
  230. package/dist/prototype/prototype-config.d.ts +226 -0
  231. package/dist/prototype/prototype-config.js +1 -0
  232. package/dist/prototype/prototype-config.js.map +1 -0
  233. package/dist/prototype/prototype-inbox-view.d.ts +48 -0
  234. package/dist/prototype/prototype-inbox-view.js +701 -0
  235. package/dist/prototype/prototype-inbox-view.js.map +1 -0
  236. package/dist/prototype/prototype-insights-view.d.ts +23 -0
  237. package/dist/prototype/prototype-insights-view.js +335 -0
  238. package/dist/prototype/prototype-insights-view.js.map +1 -0
  239. package/dist/prototype/prototype-shell.d.ts +40 -0
  240. package/dist/prototype/prototype-shell.js +190 -0
  241. package/dist/prototype/prototype-shell.js.map +1 -0
  242. package/dist/prototype/prototype-work-queue-view.d.ts +8 -0
  243. package/dist/prototype/prototype-work-queue-view.js +17 -0
  244. package/dist/prototype/prototype-work-queue-view.js.map +1 -0
  245. package/dist/three/agent-orb.d.ts +39 -0
  246. package/dist/three/agent-orb.js +500 -0
  247. package/dist/three/agent-orb.js.map +1 -0
  248. package/dist/three/index.d.ts +2 -0
  249. package/dist/three/index.js +2 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/package.json +98 -17
  252. package/src/charts/bar-chart-component.tsx +150 -0
  253. package/src/charts/chart-tooltip.tsx +86 -0
  254. package/src/charts/chart.tsx +371 -0
  255. package/src/charts/donut-chart.tsx +112 -0
  256. package/src/charts/index.ts +13 -0
  257. package/src/charts/pipeline-overview.tsx +476 -0
  258. package/src/charts/sankey-chart.tsx +290 -0
  259. package/src/charts/top-line-metrics.tsx +261 -0
  260. package/src/charts/trend-area-chart.tsx +150 -0
  261. package/src/charts/volume-analysis-chart.tsx +124 -0
  262. package/src/components/activity-detail.tsx +233 -0
  263. package/src/components/activity-log.tsx +89 -0
  264. package/src/components/agent-popover.tsx +373 -0
  265. package/src/components/agent-widget.tsx +163 -0
  266. package/src/components/avatar.tsx +109 -0
  267. package/src/components/badge.tsx +48 -0
  268. package/src/components/button.tsx +59 -0
  269. package/src/components/card.tsx +92 -0
  270. package/src/components/contact-list.tsx +121 -0
  271. package/src/components/dashboard-cards.tsx +170 -0
  272. package/src/components/data-table-display.tsx +139 -0
  273. package/src/components/data-table-filter.tsx +138 -0
  274. package/src/components/data-table-quick-views.tsx +103 -0
  275. package/src/components/data-table-toolbar.tsx +56 -0
  276. package/src/components/data-table.tsx +915 -0
  277. package/src/components/detail-view.tsx +237 -0
  278. package/src/components/dialog.tsx +158 -0
  279. package/src/components/dropdown-menu.tsx +257 -0
  280. package/src/components/entity-panel.tsx +767 -0
  281. package/src/components/inbox-row.tsx +132 -0
  282. package/src/components/inbox-toolbar.tsx +213 -0
  283. package/src/components/input.tsx +21 -0
  284. package/src/components/insights-filter-bar.tsx +132 -0
  285. package/src/components/item-list-display.tsx +278 -0
  286. package/src/components/item-list-filter.tsx +118 -0
  287. package/src/components/item-list-toolbar.tsx +97 -0
  288. package/src/components/item-list.tsx +843 -0
  289. package/src/components/label.tsx +24 -0
  290. package/src/components/message.tsx +83 -0
  291. package/src/components/metric-card.tsx +178 -0
  292. package/src/components/performance-metrics-table.tsx +442 -0
  293. package/src/components/preview-list.tsx +62 -0
  294. package/src/components/progress.tsx +31 -0
  295. package/src/components/quick-action-chat-area.tsx +156 -0
  296. package/src/components/quick-action-modal.tsx +331 -0
  297. package/src/components/quick-action-sidebar-nav.tsx +592 -0
  298. package/src/components/recommended-actions-section.tsx +258 -0
  299. package/src/components/report-card.tsx +106 -0
  300. package/src/components/score-analysis-modal.tsx +172 -0
  301. package/src/components/score-breakdown.tsx +179 -0
  302. package/src/components/score-feedback.tsx +288 -0
  303. package/src/components/score-ring.tsx +87 -0
  304. package/src/components/scroll-area.tsx +58 -0
  305. package/src/components/select.tsx +190 -0
  306. package/src/components/separator.tsx +28 -0
  307. package/src/components/sheet.tsx +143 -0
  308. package/src/components/sidebar.tsx +726 -0
  309. package/src/components/signal-feedback-inline.tsx +591 -0
  310. package/src/components/simple-data-table.tsx +124 -0
  311. package/src/components/skeleton.tsx +15 -0
  312. package/src/components/status-badge.tsx +63 -0
  313. package/src/components/styled-bar-list.tsx +70 -0
  314. package/src/components/suggested-actions.tsx +1985 -0
  315. package/src/components/table.tsx +116 -0
  316. package/src/components/tabs.tsx +91 -0
  317. package/src/components/textarea.tsx +18 -0
  318. package/src/components/timeline-activity.tsx +234 -0
  319. package/src/components/tooltip.tsx +57 -0
  320. package/src/components/view-mode-toggle.tsx +39 -0
  321. package/src/hooks/use-mobile.ts +21 -0
  322. package/src/index.ts +77 -0
  323. package/src/lib/icons.ts +18 -0
  324. package/src/lib/utils.ts +6 -0
  325. package/src/prototype/index.ts +11 -0
  326. package/src/prototype/prototype-accounts-view.tsx +112 -0
  327. package/src/prototype/prototype-admin-view.tsx +67 -0
  328. package/src/prototype/prototype-config.ts +243 -0
  329. package/src/prototype/prototype-inbox-view.tsx +810 -0
  330. package/src/prototype/prototype-insights-view.tsx +379 -0
  331. package/src/prototype/prototype-shell.tsx +219 -0
  332. package/src/prototype/prototype-work-queue-view.tsx +30 -0
  333. package/src/styles/globals.css +299 -0
  334. package/src/three/agent-orb.tsx +557 -0
  335. package/src/three/index.ts +5 -0
  336. package/src/types/r3f.d.ts +8 -0
@@ -0,0 +1,1538 @@
1
+ "use client"
2
+
3
+ "use client";
4
+ var __defProp = Object.defineProperty;
5
+ var __defProps = Object.defineProperties;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
+ import * as React from "react";
25
+ import {
26
+ ChevronDown,
27
+ ChevronUp,
28
+ Clock,
29
+ MessageSquare,
30
+ Undo2,
31
+ Redo2,
32
+ Bold,
33
+ Italic,
34
+ Underline,
35
+ AlignLeft,
36
+ List,
37
+ Trash,
38
+ Sparkles,
39
+ ThumbsUp,
40
+ ThumbsDown,
41
+ Check,
42
+ RefreshCw,
43
+ ArrowLeft,
44
+ Mail,
45
+ Phone,
46
+ X,
47
+ Users,
48
+ ExternalLink,
49
+ Copy,
50
+ PenLine,
51
+ ClipboardList,
52
+ Globe
53
+ } from "lucide-react";
54
+ import { Button } from "./button.js";
55
+ function BrandIcon({ src, alt, className }) {
56
+ return /* @__PURE__ */ jsx(
57
+ "img",
58
+ {
59
+ src,
60
+ alt,
61
+ className: `${className != null ? className : ""} object-contain`,
62
+ draggable: false
63
+ }
64
+ );
65
+ }
66
+ function getActionTypeIcon(type, className, iconMap) {
67
+ switch (type) {
68
+ case "email":
69
+ return (iconMap == null ? void 0 : iconMap.gmail) ? /* @__PURE__ */ jsx(BrandIcon, { src: iconMap.gmail, alt: "Gmail", className }) : /* @__PURE__ */ jsx(Mail, { className });
70
+ case "slack":
71
+ return (iconMap == null ? void 0 : iconMap.slack) ? /* @__PURE__ */ jsx(BrandIcon, { src: iconMap.slack, alt: "Slack", className }) : /* @__PURE__ */ jsx(MessageSquare, { className });
72
+ case "ticket":
73
+ return (iconMap == null ? void 0 : iconMap.zendesk) ? /* @__PURE__ */ jsx(BrandIcon, { src: iconMap.zendesk, alt: "Zendesk", className }) : /* @__PURE__ */ jsx(MessageSquare, { className });
74
+ case "call":
75
+ return /* @__PURE__ */ jsx(Phone, { className });
76
+ case "manual":
77
+ return /* @__PURE__ */ jsx(ClipboardList, { className });
78
+ case "browser":
79
+ return /* @__PURE__ */ jsx(Globe, { className });
80
+ default:
81
+ return /* @__PURE__ */ jsx(Mail, { className });
82
+ }
83
+ }
84
+ const aiEditPills = ["Shorten it", "Make sound more like me", "Make longer", "Other"];
85
+ function AiEditPanel({ onApply }) {
86
+ const [selectedPills, setSelectedPills] = React.useState([]);
87
+ const [description, setDescription] = React.useState("");
88
+ const [applying, setApplying] = React.useState(false);
89
+ const togglePill = React.useCallback((pill) => {
90
+ setSelectedPills((prev) => prev.includes(pill) ? prev.filter((p) => p !== pill) : [...prev, pill]);
91
+ }, []);
92
+ const handleApply = React.useCallback(() => {
93
+ if (selectedPills.length === 0 && description.trim().length === 0) return;
94
+ setApplying(true);
95
+ onApply == null ? void 0 : onApply(selectedPills, description);
96
+ setTimeout(() => {
97
+ setApplying(false);
98
+ setSelectedPills([]);
99
+ setDescription("");
100
+ }, 2e3);
101
+ }, [selectedPills, description, onApply]);
102
+ const hasInput = selectedPills.length > 0 || description.trim().length > 0;
103
+ return /* @__PURE__ */ jsxs("div", { className: "mb-4 space-y-2.5 animate-in fade-in slide-in-from-top-2 duration-200", children: [
104
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: aiEditPills.map((pill) => /* @__PURE__ */ jsx(
105
+ "button",
106
+ {
107
+ onClick: () => togglePill(pill),
108
+ className: `px-2.5 py-1 rounded-full text-[11px] font-medium border transition-colors ${selectedPills.includes(pill) ? "bg-indigo-100 text-indigo-700 border-indigo-200 dark:bg-indigo-900/30 dark:text-indigo-300 dark:border-indigo-800" : "bg-background text-muted-foreground border-border hover:bg-muted/50 hover:text-foreground"}`,
109
+ children: pill
110
+ },
111
+ pill
112
+ )) }),
113
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
114
+ /* @__PURE__ */ jsx(
115
+ "input",
116
+ {
117
+ className: "flex-1 px-3 py-2 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-indigo-500 transition-colors placeholder:text-muted-foreground/50",
118
+ placeholder: "Describe changes...",
119
+ value: description,
120
+ onChange: (e) => setDescription(e.target.value),
121
+ onKeyDown: (e) => {
122
+ if (e.key === "Enter" && hasInput) handleApply();
123
+ }
124
+ }
125
+ ),
126
+ /* @__PURE__ */ jsx(
127
+ "button",
128
+ {
129
+ onClick: handleApply,
130
+ disabled: !hasInput || applying,
131
+ className: `px-4 h-9 rounded-md text-xs font-semibold transition-colors flex items-center gap-1.5 shrink-0 ${hasInput && !applying ? "bg-foreground text-background hover:bg-foreground/90" : "bg-muted text-muted-foreground cursor-not-allowed"}`,
132
+ children: applying ? /* @__PURE__ */ jsxs(Fragment, { children: [
133
+ /* @__PURE__ */ jsx(Sparkles, { className: "w-3 h-3 animate-pulse" }),
134
+ "Applying..."
135
+ ] }) : "Apply"
136
+ }
137
+ )
138
+ ] })
139
+ ] });
140
+ }
141
+ const positivePills = ["Tone", "Personalization", "Length", "CTA", "Other"];
142
+ const negativePills = ["Too formal", "Too casual", "Too long", "Missing context", "Wrong angle", "Factual error", "Other"];
143
+ function DraftFeedbackInline({
144
+ onRegenerateRequest,
145
+ onSubmitFeedback,
146
+ onDiscardRequest
147
+ }) {
148
+ const [thumbState, setThumbState] = React.useState(null);
149
+ const [selectedPills, setSelectedPills] = React.useState([]);
150
+ const [detailText, setDetailText] = React.useState("");
151
+ const [noted, setNoted] = React.useState(false);
152
+ const [regenerated, setRegenerated] = React.useState(false);
153
+ const togglePill = React.useCallback((pill) => {
154
+ setSelectedPills((prev) => prev.includes(pill) ? prev.filter((p) => p !== pill) : [...prev, pill]);
155
+ }, []);
156
+ const handleSubmit = React.useCallback(() => {
157
+ if (!thumbState) return;
158
+ onSubmitFeedback == null ? void 0 : onSubmitFeedback(thumbState, selectedPills, detailText);
159
+ setNoted(true);
160
+ setTimeout(() => {
161
+ setThumbState(null);
162
+ setSelectedPills([]);
163
+ setDetailText("");
164
+ setNoted(false);
165
+ }, 3e3);
166
+ }, [thumbState, selectedPills, detailText, onSubmitFeedback]);
167
+ const handleRegenerate = React.useCallback(() => {
168
+ if (!thumbState) return;
169
+ onRegenerateRequest == null ? void 0 : onRegenerateRequest(selectedPills, detailText);
170
+ setRegenerated(true);
171
+ setTimeout(() => {
172
+ setThumbState(null);
173
+ setSelectedPills([]);
174
+ setDetailText("");
175
+ setRegenerated(false);
176
+ }, 3e3);
177
+ }, [thumbState, selectedPills, detailText, onRegenerateRequest]);
178
+ const handleDiscard = React.useCallback(() => {
179
+ if (!thumbState) return;
180
+ onDiscardRequest == null ? void 0 : onDiscardRequest(selectedPills, detailText);
181
+ }, [thumbState, selectedPills, detailText, onDiscardRequest]);
182
+ if (noted) {
183
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 py-1 animate-in fade-in slide-in-from-top-1 duration-200", children: [
184
+ /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-emerald-500" }),
185
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Feedback recorded" })
186
+ ] });
187
+ }
188
+ if (regenerated) {
189
+ return /* @__PURE__ */ jsx("div", { className: "py-2 animate-in fade-in slide-in-from-top-1 duration-200", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3 py-2 rounded-md bg-indigo-50 dark:bg-indigo-950/30 border border-indigo-200 dark:border-indigo-800", children: [
190
+ /* @__PURE__ */ jsx(RefreshCw, { className: "w-3 h-3 text-indigo-500 animate-spin" }),
191
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-indigo-600 dark:text-indigo-400", children: "Regenerating draft..." })
192
+ ] }) });
193
+ }
194
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-0", children: [
195
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
196
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground font-medium", children: "How's this draft?" }),
197
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
198
+ /* @__PURE__ */ jsx(
199
+ "button",
200
+ {
201
+ onClick: () => {
202
+ setThumbState(thumbState === "up" ? null : "up");
203
+ setSelectedPills([]);
204
+ setDetailText("");
205
+ },
206
+ className: `p-1.5 rounded transition-colors ${thumbState === "up" ? "bg-emerald-100 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "hover:bg-muted text-muted-foreground hover:text-foreground"}`,
207
+ children: /* @__PURE__ */ jsx(ThumbsUp, { className: "w-4 h-4", fill: thumbState === "up" ? "currentColor" : "none" })
208
+ }
209
+ ),
210
+ /* @__PURE__ */ jsx(
211
+ "button",
212
+ {
213
+ onClick: () => {
214
+ setThumbState(thumbState === "down" ? null : "down");
215
+ setSelectedPills([]);
216
+ setDetailText("");
217
+ },
218
+ className: `p-1.5 rounded transition-colors ${thumbState === "down" ? "bg-red-100 text-red-600 dark:bg-red-900/30 dark:text-red-400" : "hover:bg-muted text-muted-foreground hover:text-foreground"}`,
219
+ children: /* @__PURE__ */ jsx(ThumbsDown, { className: "w-4 h-4", fill: thumbState === "down" ? "currentColor" : "none" })
220
+ }
221
+ )
222
+ ] })
223
+ ] }),
224
+ thumbState && /* @__PURE__ */ jsxs("div", { className: "pt-3 space-y-3 animate-in fade-in slide-in-from-top-2 duration-200", children: [
225
+ /* @__PURE__ */ jsxs("div", { children: [
226
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground mb-2 block font-medium", children: thumbState === "up" ? "What worked well?" : "What needs improvement?" }),
227
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: (thumbState === "up" ? positivePills : negativePills).map((pill) => /* @__PURE__ */ jsx(
228
+ "button",
229
+ {
230
+ onClick: () => togglePill(pill),
231
+ className: `px-2.5 py-1 rounded-full text-[11px] font-medium border transition-colors ${selectedPills.includes(pill) ? thumbState === "up" ? "bg-emerald-100 text-emerald-700 border-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-300 dark:border-emerald-800" : "bg-red-100 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-300 dark:border-red-800" : "bg-background text-muted-foreground border-border hover:bg-muted/50 hover:text-foreground"}`,
232
+ children: pill
233
+ },
234
+ pill
235
+ )) })
236
+ ] }),
237
+ /* @__PURE__ */ jsx(
238
+ "textarea",
239
+ {
240
+ value: detailText,
241
+ onChange: (e) => setDetailText(e.target.value),
242
+ placeholder: thumbState === "up" ? "Add specific praise (optional)..." : "Provide specific instructions (optional)...",
243
+ className: "w-full text-xs bg-background border border-border rounded-md px-2.5 py-2 text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-indigo-500/50 focus:border-indigo-500/50 resize-none min-h-[60px]"
244
+ }
245
+ ),
246
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 pt-1", children: thumbState === "down" ? /* @__PURE__ */ jsxs(Fragment, { children: [
247
+ /* @__PURE__ */ jsxs(
248
+ "button",
249
+ {
250
+ onClick: handleRegenerate,
251
+ disabled: selectedPills.length === 0 && detailText.length === 0,
252
+ className: `flex-1 py-1.5 rounded-md text-xs font-semibold transition-colors flex items-center justify-center gap-1.5 ${selectedPills.length > 0 || detailText.length > 0 ? "bg-foreground text-background hover:bg-foreground/90" : "bg-muted text-muted-foreground cursor-not-allowed"}`,
253
+ children: [
254
+ /* @__PURE__ */ jsx(RefreshCw, { className: "w-3 h-3" }),
255
+ "Regenerate draft"
256
+ ]
257
+ }
258
+ ),
259
+ /* @__PURE__ */ jsx(
260
+ "button",
261
+ {
262
+ onClick: handleDiscard,
263
+ className: "flex-1 py-1.5 rounded-md text-xs font-medium transition-colors border bg-background text-foreground border-border hover:bg-muted/50 flex items-center justify-center gap-1.5",
264
+ children: "Discard draft"
265
+ }
266
+ )
267
+ ] }) : /* @__PURE__ */ jsx(
268
+ "button",
269
+ {
270
+ onClick: handleSubmit,
271
+ className: "flex-1 py-1.5 rounded-md text-xs font-semibold transition-colors bg-foreground text-background hover:bg-foreground/90 border-transparent",
272
+ children: "Submit feedback"
273
+ }
274
+ ) })
275
+ ] })
276
+ ] });
277
+ }
278
+ function EditorToolbar() {
279
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 px-4 py-2 border-t border-border bg-muted/5 flex-wrap", children: [
280
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center mr-2 gap-1 shrink-0", children: [
281
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(Undo2, { className: "h-4 w-4" }) }),
282
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(Redo2, { className: "h-4 w-4" }) })
283
+ ] }),
284
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1 shrink-0" }),
285
+ /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "h-7 text-xs font-medium text-muted-foreground gap-1 px-2 hover:text-foreground shrink-0", children: [
286
+ "Sans Serif ",
287
+ /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" })
288
+ ] }),
289
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1 shrink-0" }),
290
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 shrink-0", children: [
291
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" }) }),
292
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(Italic, { className: "h-4 w-4" }) }),
293
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(Underline, { className: "h-4 w-4" }) })
294
+ ] }),
295
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1 shrink-0" }),
296
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 shrink-0", children: [
297
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(AlignLeft, { className: "h-4 w-4" }) }),
298
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" }) })
299
+ ] }),
300
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
301
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-red-600 hover:bg-red-50 shrink-0 ml-auto", children: /* @__PURE__ */ jsx(Trash, { className: "h-4 w-4" }) })
302
+ ] });
303
+ }
304
+ function FollowUpToggle({
305
+ checked,
306
+ onCheckedChange,
307
+ days
308
+ }) {
309
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
310
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-foreground", children: [
311
+ /* @__PURE__ */ jsx(Clock, { className: "w-4 h-4 text-muted-foreground" }),
312
+ /* @__PURE__ */ jsxs("span", { children: [
313
+ "Auto-draft follow-up in ",
314
+ days,
315
+ "d if no response"
316
+ ] })
317
+ ] }),
318
+ /* @__PURE__ */ jsx(
319
+ "button",
320
+ {
321
+ role: "switch",
322
+ "aria-checked": checked,
323
+ onClick: () => onCheckedChange(!checked),
324
+ className: `relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors ${checked ? "bg-foreground" : "bg-muted"}`,
325
+ children: /* @__PURE__ */ jsx(
326
+ "span",
327
+ {
328
+ className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow-sm transition-transform ${checked ? "translate-x-4" : "translate-x-0"}`
329
+ }
330
+ )
331
+ }
332
+ )
333
+ ] });
334
+ }
335
+ function ContactCard({
336
+ contact,
337
+ onConfirm,
338
+ onRemove,
339
+ onSwap,
340
+ variant = "primary",
341
+ showPhone = false
342
+ }) {
343
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
344
+ const [selectedEmail, setSelectedEmail] = React.useState(
345
+ (_c = (_b = contact.email) != null ? _b : (_a = contact.emails) == null ? void 0 : _a[0]) != null ? _c : ""
346
+ );
347
+ const [selectedPhone, setSelectedPhone] = React.useState(
348
+ (_f = (_e = contact.phone) != null ? _e : (_d = contact.phones) == null ? void 0 : _d[0]) != null ? _f : ""
349
+ );
350
+ const [showEmailPicker, setShowEmailPicker] = React.useState(false);
351
+ const [showPhonePicker, setShowPhonePicker] = React.useState(false);
352
+ const hasMultipleEmails = ((_h = (_g = contact.emails) == null ? void 0 : _g.length) != null ? _h : 0) > 1;
353
+ const hasMultiplePhones = ((_j = (_i = contact.phones) == null ? void 0 : _i.length) != null ? _j : 0) > 1;
354
+ const initials = contact.name.split(" ").map((n) => n[0]).join("");
355
+ if (variant === "alternative") {
356
+ const detail = showPhone ? (_m = (_l = contact.phone) != null ? _l : (_k = contact.phones) == null ? void 0 : _k[0]) != null ? _m : "" : (_p = (_o = contact.email) != null ? _o : (_n = contact.emails) == null ? void 0 : _n[0]) != null ? _p : "";
357
+ return /* @__PURE__ */ jsxs(
358
+ "button",
359
+ {
360
+ onClick: onSwap,
361
+ className: "flex items-center gap-3 w-full px-3 py-2 text-left hover:bg-muted/50 rounded-md transition-colors group",
362
+ children: [
363
+ /* @__PURE__ */ jsx("div", { className: "w-7 h-7 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground shrink-0", children: initials }),
364
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
365
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-foreground", children: contact.name }),
366
+ /* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground truncate", children: [
367
+ contact.role,
368
+ detail ? ` \xB7 ${detail}` : ""
369
+ ] })
370
+ ] }),
371
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity", children: "Select" })
372
+ ]
373
+ }
374
+ );
375
+ }
376
+ if (variant === "secondary") {
377
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-2.5 py-1.5 bg-muted/40 rounded-md text-sm group", children: [
378
+ /* @__PURE__ */ jsx("span", { className: "text-foreground text-xs", children: contact.name }),
379
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs truncate", children: (_q = contact.email) != null ? _q : selectedEmail }),
380
+ onRemove && /* @__PURE__ */ jsx(
381
+ "button",
382
+ {
383
+ onClick: onRemove,
384
+ className: "ml-auto text-muted-foreground hover:text-foreground transition-colors opacity-0 group-hover:opacity-100",
385
+ children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3" })
386
+ }
387
+ )
388
+ ] });
389
+ }
390
+ const needsConfirmation = !contact.confirmed && !!onConfirm;
391
+ return /* @__PURE__ */ jsxs(
392
+ "div",
393
+ {
394
+ className: `flex flex-wrap items-start gap-3 rounded-md ${needsConfirmation ? "border border-emerald-200/70 bg-emerald-50/40 p-2.5" : ""}`,
395
+ children: [
396
+ /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground shrink-0 mt-0.5", children: initials }),
397
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
398
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline gap-2", children: [
399
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: contact.name }),
400
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: contact.role }),
401
+ contact.confirmed && /* @__PURE__ */ jsx("span", { className: "inline-flex h-4 w-4 items-center justify-center rounded-full bg-emerald-100 text-emerald-700", children: /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) })
402
+ ] }),
403
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1.5 mt-0.5", children: showPhone ? /* @__PURE__ */ jsxs(Fragment, { children: [
404
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: selectedPhone }),
405
+ hasMultiplePhones && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
406
+ /* @__PURE__ */ jsx(
407
+ "button",
408
+ {
409
+ onClick: () => setShowPhonePicker(!showPhonePicker),
410
+ className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
411
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3" })
412
+ }
413
+ ),
414
+ showPhonePicker && /* @__PURE__ */ jsx("div", { className: "absolute top-full left-0 mt-1 bg-background border border-border rounded-md shadow-lg z-10 py-1 min-w-[180px]", children: contact.phones.map((p) => /* @__PURE__ */ jsx(
415
+ "button",
416
+ {
417
+ onClick: () => {
418
+ setSelectedPhone(p);
419
+ setShowPhonePicker(false);
420
+ },
421
+ className: `w-full text-left px-3 py-1.5 text-xs hover:bg-muted/50 transition-colors ${p === selectedPhone ? "text-foreground font-medium" : "text-muted-foreground"}`,
422
+ children: p
423
+ },
424
+ p
425
+ )) })
426
+ ] })
427
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
428
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: selectedEmail }),
429
+ hasMultipleEmails && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
430
+ /* @__PURE__ */ jsx(
431
+ "button",
432
+ {
433
+ onClick: () => setShowEmailPicker(!showEmailPicker),
434
+ className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
435
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3" })
436
+ }
437
+ ),
438
+ showEmailPicker && /* @__PURE__ */ jsx("div", { className: "absolute top-full left-0 mt-1 bg-background border border-border rounded-md shadow-lg z-10 py-1 min-w-[220px]", children: contact.emails.map((e) => /* @__PURE__ */ jsx(
439
+ "button",
440
+ {
441
+ onClick: () => {
442
+ setSelectedEmail(e);
443
+ setShowEmailPicker(false);
444
+ },
445
+ className: `w-full text-left px-3 py-1.5 text-xs hover:bg-muted/50 transition-colors ${e === selectedEmail ? "text-foreground font-medium" : "text-muted-foreground"}`,
446
+ children: e
447
+ },
448
+ e
449
+ )) })
450
+ ] })
451
+ ] }) })
452
+ ] }),
453
+ (onRemove || !contact.confirmed && onConfirm) && /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1.5 shrink-0 self-center", children: [
454
+ !contact.confirmed && onConfirm && /* @__PURE__ */ jsx(
455
+ "button",
456
+ {
457
+ onClick: onConfirm,
458
+ className: "h-7 rounded-md border border-emerald-700 bg-emerald-700 px-2.5 text-xs font-semibold text-white hover:bg-emerald-600 hover:border-emerald-600 transition-colors",
459
+ children: "Confirm recipient"
460
+ }
461
+ ),
462
+ onRemove && /* @__PURE__ */ jsx(
463
+ "button",
464
+ {
465
+ onClick: onRemove,
466
+ className: "h-7 w-7 inline-flex items-center justify-center rounded-md border border-border bg-background text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors",
467
+ "aria-label": "Remove contact",
468
+ children: /* @__PURE__ */ jsx(X, { className: "w-3.5 h-3.5" })
469
+ }
470
+ )
471
+ ] })
472
+ ]
473
+ }
474
+ );
475
+ }
476
+ function AccountContactsPopover({
477
+ contacts,
478
+ onSelect,
479
+ onSelectTo,
480
+ onSelectCc,
481
+ onSelectBcc,
482
+ onViewAll,
483
+ onOpenRecentActivity,
484
+ trigger,
485
+ iconMap
486
+ }) {
487
+ const [open, setOpen] = React.useState(false);
488
+ const triggerRef = React.useRef(null);
489
+ const [popoverStyle, setPopoverStyle] = React.useState({});
490
+ React.useEffect(() => {
491
+ if (open && triggerRef.current) {
492
+ const rect = triggerRef.current.getBoundingClientRect();
493
+ const popoverWidth = Math.min(448, window.innerWidth - 32);
494
+ let left = rect.right - popoverWidth;
495
+ if (left < 16) left = 16;
496
+ if (left + popoverWidth > window.innerWidth - 16) left = window.innerWidth - 16 - popoverWidth;
497
+ setPopoverStyle({ position: "fixed", top: rect.bottom + 4, left });
498
+ }
499
+ }, [open]);
500
+ return /* @__PURE__ */ jsxs("div", { children: [
501
+ /* @__PURE__ */ jsx("div", { ref: triggerRef, onClick: () => setOpen(!open), children: trigger }),
502
+ open && /* @__PURE__ */ jsxs(Fragment, { children: [
503
+ /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-40", onClick: () => setOpen(false) }),
504
+ /* @__PURE__ */ jsxs("div", { style: popoverStyle, className: "fixed bg-background border border-border rounded-lg shadow-xl z-50 w-[28rem] max-w-[calc(100vw-2rem)] py-2 animate-in fade-in slide-in-from-top-1 duration-150", children: [
505
+ /* @__PURE__ */ jsx("div", { className: "px-3 py-1.5 text-[11px] font-medium text-muted-foreground/60 uppercase tracking-wide", children: "Account Contacts" }),
506
+ /* @__PURE__ */ jsx("div", { className: "max-h-48 overflow-y-auto", children: contacts.map((c, i) => {
507
+ var _a, _b, _c, _d, _e, _f;
508
+ return /* @__PURE__ */ jsxs(
509
+ "div",
510
+ {
511
+ role: "button",
512
+ onClick: () => {
513
+ (onSelectTo != null ? onSelectTo : onSelect)(c);
514
+ setOpen(false);
515
+ },
516
+ className: "flex items-center gap-3 w-full px-3 py-2 text-left hover:bg-muted/50 transition-colors cursor-pointer",
517
+ children: [
518
+ /* @__PURE__ */ jsx("div", { className: "w-7 h-7 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground shrink-0", children: c.name.split(" ").map((n) => n[0]).join("") }),
519
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 overflow-hidden", children: [
520
+ /* @__PURE__ */ jsx("div", { className: "truncate text-sm font-medium text-foreground", children: c.name }),
521
+ /* @__PURE__ */ jsxs("div", { className: "truncate text-xs text-muted-foreground leading-tight", children: [
522
+ c.role,
523
+ " \xB7 ",
524
+ (_f = (_e = (_c = (_b = c.email) != null ? _b : (_a = c.emails) == null ? void 0 : _a[0]) != null ? _c : c.phone) != null ? _e : (_d = c.phones) == null ? void 0 : _d[0]) != null ? _f : ""
525
+ ] }),
526
+ c.lastActivity && /* @__PURE__ */ jsxs(
527
+ "button",
528
+ {
529
+ type: "button",
530
+ onClick: (e) => {
531
+ e.stopPropagation();
532
+ onOpenRecentActivity == null ? void 0 : onOpenRecentActivity();
533
+ setOpen(false);
534
+ },
535
+ className: "mt-1.5 flex max-w-full items-center gap-1.5 overflow-hidden rounded-md border border-border/70 bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",
536
+ children: [
537
+ /* @__PURE__ */ jsx(Clock, { className: "w-3 h-3 shrink-0" }),
538
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 font-medium", children: "Last activity" }),
539
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground/60", children: "\xB7" }),
540
+ /* @__PURE__ */ jsx("span", { className: "shrink-0", children: c.lastActivity.date }),
541
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground/60", children: "\xB7" }),
542
+ /* @__PURE__ */ jsx("span", { className: "truncate capitalize", children: c.lastActivity.type })
543
+ ]
544
+ }
545
+ )
546
+ ] }),
547
+ /* @__PURE__ */ jsxs("div", { className: "ml-2 flex items-center gap-1.5 shrink-0", children: [
548
+ onSelectTo && /* @__PURE__ */ jsx(
549
+ "button",
550
+ {
551
+ type: "button",
552
+ onClick: (e) => {
553
+ e.stopPropagation();
554
+ onSelectTo(c);
555
+ setOpen(false);
556
+ },
557
+ className: "h-6 rounded border border-border bg-background px-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/40",
558
+ children: "To"
559
+ }
560
+ ),
561
+ onSelectCc && /* @__PURE__ */ jsx(
562
+ "button",
563
+ {
564
+ type: "button",
565
+ onClick: (e) => {
566
+ e.stopPropagation();
567
+ onSelectCc(c);
568
+ setOpen(false);
569
+ },
570
+ className: "h-6 rounded border border-border bg-background px-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/40",
571
+ children: "Cc"
572
+ }
573
+ ),
574
+ onSelectBcc && /* @__PURE__ */ jsx(
575
+ "button",
576
+ {
577
+ type: "button",
578
+ onClick: (e) => {
579
+ e.stopPropagation();
580
+ onSelectBcc(c);
581
+ setOpen(false);
582
+ },
583
+ className: "h-6 rounded border border-border bg-background px-1.5 text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted/40",
584
+ children: "Bcc"
585
+ }
586
+ ),
587
+ /* @__PURE__ */ jsx(
588
+ "button",
589
+ {
590
+ type: "button",
591
+ onClick: (e) => {
592
+ e.stopPropagation();
593
+ if (c.salesforceUrl) {
594
+ window.open(c.salesforceUrl, "_blank", "noopener,noreferrer");
595
+ } else {
596
+ onViewAll == null ? void 0 : onViewAll();
597
+ }
598
+ },
599
+ className: "h-7 w-7 inline-flex items-center justify-center rounded-md border border-border bg-background hover:bg-muted/40 transition-colors shrink-0",
600
+ "aria-label": `Open ${c.name} in Salesforce`,
601
+ children: (iconMap == null ? void 0 : iconMap.salesforce) ? /* @__PURE__ */ jsx(BrandIcon, { src: iconMap.salesforce, alt: "Salesforce", className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5 text-muted-foreground" })
602
+ }
603
+ )
604
+ ] })
605
+ ]
606
+ },
607
+ i
608
+ );
609
+ }) }),
610
+ onViewAll && /* @__PURE__ */ jsxs(Fragment, { children: [
611
+ /* @__PURE__ */ jsx("div", { className: "h-px bg-border mx-3 my-1" }),
612
+ /* @__PURE__ */ jsxs(
613
+ "button",
614
+ {
615
+ onClick: () => {
616
+ onViewAll();
617
+ setOpen(false);
618
+ },
619
+ className: "flex items-center gap-2 w-full px-3 py-2 text-left text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",
620
+ children: [
621
+ /* @__PURE__ */ jsx(ExternalLink, { className: "w-3 h-3" }),
622
+ "View all contacts"
623
+ ]
624
+ }
625
+ )
626
+ ] })
627
+ ] })
628
+ ] })
629
+ ] });
630
+ }
631
+ function EmailHeader({
632
+ fromName,
633
+ fromEmail,
634
+ toContacts,
635
+ ccContacts,
636
+ initialSubject = "",
637
+ accountContacts,
638
+ bccContacts,
639
+ onAddToContact,
640
+ onRemoveToContact,
641
+ onConfirmToContact,
642
+ onUpdateToContact,
643
+ onCcAdd,
644
+ onCcRemove,
645
+ onBccAdd,
646
+ onBccRemove,
647
+ onOpenAccountDetails,
648
+ onOpenRecentActivity,
649
+ iconMap,
650
+ showSubject = false,
651
+ accountDetailsLabel = "Account details"
652
+ }) {
653
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
654
+ const hasUnconfirmedTo = toContacts.some((c) => !c.confirmed);
655
+ const [expandedToIndex, setExpandedToIndex] = React.useState(null);
656
+ const [showCcBcc, setShowCcBcc] = React.useState(
657
+ !!(((_a = ccContacts == null ? void 0 : ccContacts.length) != null ? _a : 0) > 0 || ((_b = bccContacts == null ? void 0 : bccContacts.length) != null ? _b : 0) > 0)
658
+ );
659
+ const [manualTo, setManualTo] = React.useState("");
660
+ const [manualCc, setManualCc] = React.useState("");
661
+ const [manualBcc, setManualBcc] = React.useState("");
662
+ const [subject, setSubject] = React.useState(initialSubject);
663
+ React.useEffect(() => {
664
+ var _a2, _b2;
665
+ if (((_a2 = ccContacts == null ? void 0 : ccContacts.length) != null ? _a2 : 0) > 0 || ((_b2 = bccContacts == null ? void 0 : bccContacts.length) != null ? _b2 : 0) > 0) {
666
+ setShowCcBcc(true);
667
+ }
668
+ }, [ccContacts, bccContacts]);
669
+ return /* @__PURE__ */ jsxs("div", { className: "mx-4 mt-3 rounded-md border border-border/60 bg-muted/[0.16] text-sm", children: [
670
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-2 border-b border-border/30", children: [
671
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-10 shrink-0", children: "From" }),
672
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline gap-1.5 min-w-0", children: [
673
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground", children: fromName }),
674
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground truncate", children: fromEmail })
675
+ ] })
676
+ ] }),
677
+ /* @__PURE__ */ jsxs("div", { className: `flex items-start gap-3 px-4 py-2 border-b border-border/30 ${hasUnconfirmedTo ? "bg-amber-50/35" : ""}`, children: [
678
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-10 shrink-0 mt-1.5", children: "To" }),
679
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
680
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
681
+ toContacts.map((contact, index) => {
682
+ var _a2, _b2, _c2;
683
+ return /* @__PURE__ */ jsxs(
684
+ "div",
685
+ {
686
+ onClick: () => setExpandedToIndex((prev) => prev === index ? null : index),
687
+ className: `inline-flex max-w-[300px] cursor-pointer items-start gap-2 rounded-md border px-2 py-1 text-xs ${contact.confirmed ? "border-border/80 bg-background text-foreground" : "border-amber-300 bg-amber-50 text-amber-800"}`,
688
+ children: [
689
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
690
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
691
+ /* @__PURE__ */ jsx("span", { className: "font-medium leading-none", children: contact.name }),
692
+ contact.confirmed && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-emerald-600" })
693
+ ] }),
694
+ /* @__PURE__ */ jsx("div", { className: "mt-0.5 truncate text-muted-foreground", children: (_c2 = (_b2 = contact.email) != null ? _b2 : (_a2 = contact.emails) == null ? void 0 : _a2[0]) != null ? _c2 : "no email" })
695
+ ] }),
696
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
697
+ !contact.confirmed && /* @__PURE__ */ jsx(
698
+ "button",
699
+ {
700
+ type: "button",
701
+ onClick: (e) => {
702
+ e.stopPropagation();
703
+ onConfirmToContact == null ? void 0 : onConfirmToContact(index);
704
+ },
705
+ className: "h-6 rounded px-1.5 text-[10px] font-semibold hover:bg-amber-100",
706
+ children: "Confirm"
707
+ }
708
+ ),
709
+ /* @__PURE__ */ jsx(
710
+ "button",
711
+ {
712
+ type: "button",
713
+ onClick: (e) => {
714
+ e.stopPropagation();
715
+ onRemoveToContact == null ? void 0 : onRemoveToContact(index);
716
+ setExpandedToIndex((prev) => prev === index ? null : prev);
717
+ },
718
+ className: "rounded p-0.5 text-muted-foreground hover:text-foreground hover:bg-muted/40",
719
+ "aria-label": "Remove recipient",
720
+ children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
721
+ }
722
+ )
723
+ ] })
724
+ ]
725
+ },
726
+ `${contact.name}-${index}`
727
+ );
728
+ }),
729
+ /* @__PURE__ */ jsx(
730
+ "input",
731
+ {
732
+ type: "text",
733
+ value: manualTo,
734
+ onChange: (e) => setManualTo(e.target.value),
735
+ placeholder: toContacts.length ? "Add recipient..." : "Type a name or email...",
736
+ className: "min-w-[140px] flex-1 text-sm bg-transparent border-none focus:outline-none focus:ring-0 placeholder:text-muted-foreground/40 py-1",
737
+ onKeyDown: (e) => {
738
+ if (e.key === "Enter" && manualTo.trim()) {
739
+ onAddToContact == null ? void 0 : onAddToContact({ name: manualTo.trim(), role: "", email: manualTo.trim(), confirmed: true });
740
+ setManualTo("");
741
+ }
742
+ }
743
+ }
744
+ )
745
+ ] }),
746
+ expandedToIndex !== null && toContacts[expandedToIndex] && /* @__PURE__ */ jsxs("div", { className: "mt-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground", children: [
747
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
748
+ /* @__PURE__ */ jsx("div", { className: "font-medium text-foreground text-sm", children: toContacts[expandedToIndex].name }),
749
+ /* @__PURE__ */ jsx(
750
+ "button",
751
+ {
752
+ type: "button",
753
+ onClick: () => {
754
+ const contact = toContacts[expandedToIndex];
755
+ if (contact.salesforceUrl) {
756
+ window.open(contact.salesforceUrl, "_blank", "noopener,noreferrer");
757
+ } else {
758
+ onOpenAccountDetails == null ? void 0 : onOpenAccountDetails();
759
+ }
760
+ },
761
+ className: "h-7 w-7 inline-flex items-center justify-center rounded-md border border-border bg-background hover:bg-muted/40 transition-colors shrink-0",
762
+ "aria-label": "Open in Salesforce",
763
+ children: (iconMap == null ? void 0 : iconMap.salesforce) ? /* @__PURE__ */ jsx(BrandIcon, { src: iconMap.salesforce, alt: "Salesforce", className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5 text-muted-foreground" })
764
+ }
765
+ )
766
+ ] }),
767
+ toContacts[expandedToIndex].role && /* @__PURE__ */ jsx("div", { className: "mt-1", children: toContacts[expandedToIndex].role }),
768
+ ((_d = (_c = toContacts[expandedToIndex].emails) == null ? void 0 : _c.length) != null ? _d : 0) > 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
769
+ /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground/70 mb-1", children: "Send using" }),
770
+ /* @__PURE__ */ jsx(
771
+ "select",
772
+ {
773
+ className: "h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground",
774
+ value: (_g = (_f = toContacts[expandedToIndex].email) != null ? _f : (_e = toContacts[expandedToIndex].emails) == null ? void 0 : _e[0]) != null ? _g : "",
775
+ onChange: (e) => onUpdateToContact == null ? void 0 : onUpdateToContact(expandedToIndex, __spreadProps(__spreadValues({}, toContacts[expandedToIndex]), {
776
+ email: e.target.value
777
+ })),
778
+ children: (_h = toContacts[expandedToIndex].emails) == null ? void 0 : _h.map((emailOption) => /* @__PURE__ */ jsx("option", { value: emailOption, children: emailOption }, emailOption))
779
+ }
780
+ )
781
+ ] }) : toContacts[expandedToIndex].email ? /* @__PURE__ */ jsx("div", { className: "mt-1", children: toContacts[expandedToIndex].email }) : null,
782
+ ((_j = (_i = toContacts[expandedToIndex].phones) == null ? void 0 : _i.length) != null ? _j : 0) > 0 ? /* @__PURE__ */ jsx("div", { className: "mt-1", children: (_k = toContacts[expandedToIndex].phones) == null ? void 0 : _k.join(" \xB7 ") }) : toContacts[expandedToIndex].phone ? /* @__PURE__ */ jsx("div", { className: "mt-1", children: toContacts[expandedToIndex].phone }) : null
783
+ ] }),
784
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center flex-wrap gap-1.5 mt-1.5", children: [
785
+ accountContacts && accountContacts.length > 0 && /* @__PURE__ */ jsx(
786
+ AccountContactsPopover,
787
+ {
788
+ contacts: accountContacts,
789
+ onSelect: (c) => onAddToContact == null ? void 0 : onAddToContact(__spreadProps(__spreadValues({}, c), { confirmed: true })),
790
+ onSelectTo: (c) => onAddToContact == null ? void 0 : onAddToContact(__spreadProps(__spreadValues({}, c), { confirmed: true })),
791
+ onSelectCc: (c) => onCcAdd == null ? void 0 : onCcAdd(__spreadProps(__spreadValues({}, c), { confirmed: true })),
792
+ onSelectBcc: (c) => onBccAdd == null ? void 0 : onBccAdd(__spreadProps(__spreadValues({}, c), { confirmed: true })),
793
+ onViewAll: onOpenAccountDetails,
794
+ onOpenRecentActivity,
795
+ iconMap,
796
+ trigger: /* @__PURE__ */ jsx("button", { className: "h-7 rounded-md border border-border bg-background px-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors", children: "Contacts" })
797
+ }
798
+ ),
799
+ /* @__PURE__ */ jsx(
800
+ "button",
801
+ {
802
+ type: "button",
803
+ onClick: onOpenAccountDetails,
804
+ className: "h-7 rounded-md border border-border bg-background px-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors",
805
+ children: accountDetailsLabel
806
+ }
807
+ ),
808
+ /* @__PURE__ */ jsx(
809
+ "button",
810
+ {
811
+ type: "button",
812
+ onClick: () => setShowCcBcc(true),
813
+ className: "h-7 rounded-md border border-border bg-background px-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors",
814
+ children: "Add Cc/Bcc"
815
+ }
816
+ )
817
+ ] })
818
+ ] })
819
+ ] }),
820
+ showCcBcc && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 px-4 py-2 border-b border-border/30 animate-in fade-in slide-in-from-top-1 duration-150", children: [
821
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-10 shrink-0 mt-1.5", children: "Cc" }),
822
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1.5", children: [
823
+ ccContacts == null ? void 0 : ccContacts.map((c, i) => /* @__PURE__ */ jsx(ContactCard, { contact: c, variant: "secondary", onRemove: () => onCcRemove == null ? void 0 : onCcRemove(i) }, i)),
824
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
825
+ /* @__PURE__ */ jsx(
826
+ "input",
827
+ {
828
+ type: "text",
829
+ value: manualCc,
830
+ onChange: (e) => setManualCc(e.target.value),
831
+ placeholder: "Add Cc...",
832
+ className: "text-sm bg-transparent border-none focus:outline-none focus:ring-0 placeholder:text-muted-foreground/40 py-1 w-28",
833
+ onKeyDown: (e) => {
834
+ if (e.key === "Enter" && manualCc.trim()) {
835
+ onCcAdd == null ? void 0 : onCcAdd({ name: manualCc.trim(), role: "", email: manualCc.trim(), confirmed: true });
836
+ setManualCc("");
837
+ }
838
+ }
839
+ }
840
+ ),
841
+ accountContacts && accountContacts.length > 0 && /* @__PURE__ */ jsx(
842
+ AccountContactsPopover,
843
+ {
844
+ contacts: accountContacts,
845
+ onSelect: (c) => onCcAdd == null ? void 0 : onCcAdd(c),
846
+ onViewAll: onOpenAccountDetails,
847
+ onOpenRecentActivity,
848
+ iconMap,
849
+ trigger: /* @__PURE__ */ jsx("button", { className: "text-xs text-muted-foreground hover:text-foreground transition-colors", children: /* @__PURE__ */ jsx(Users, { className: "w-3 h-3" }) })
850
+ }
851
+ )
852
+ ] })
853
+ ] }) })
854
+ ] }),
855
+ showCcBcc && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 px-4 py-2 border-b border-border/30 animate-in fade-in slide-in-from-top-1 duration-150", children: [
856
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-10 shrink-0 mt-1.5", children: "Bcc" }),
857
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1.5", children: [
858
+ bccContacts == null ? void 0 : bccContacts.map((c, i) => /* @__PURE__ */ jsx(ContactCard, { contact: c, variant: "secondary", onRemove: () => onBccRemove == null ? void 0 : onBccRemove(i) }, `${c.name}-${i}`)),
859
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
860
+ /* @__PURE__ */ jsx(
861
+ "input",
862
+ {
863
+ type: "text",
864
+ value: manualBcc,
865
+ onChange: (e) => setManualBcc(e.target.value),
866
+ placeholder: "Add Bcc...",
867
+ className: "text-sm bg-transparent border-none focus:outline-none focus:ring-0 placeholder:text-muted-foreground/40 py-1 w-28",
868
+ onKeyDown: (e) => {
869
+ if (e.key === "Enter" && manualBcc.trim()) {
870
+ onBccAdd == null ? void 0 : onBccAdd({ name: manualBcc.trim(), role: "", email: manualBcc.trim(), confirmed: true });
871
+ setManualBcc("");
872
+ }
873
+ }
874
+ }
875
+ ),
876
+ accountContacts && accountContacts.length > 0 && /* @__PURE__ */ jsx(
877
+ AccountContactsPopover,
878
+ {
879
+ contacts: accountContacts,
880
+ onSelect: (c) => onBccAdd == null ? void 0 : onBccAdd(c),
881
+ onViewAll: onOpenAccountDetails,
882
+ onOpenRecentActivity,
883
+ iconMap,
884
+ trigger: /* @__PURE__ */ jsx("button", { className: "text-xs text-muted-foreground hover:text-foreground transition-colors", children: /* @__PURE__ */ jsx(Users, { className: "w-3 h-3" }) })
885
+ }
886
+ )
887
+ ] })
888
+ ] }) })
889
+ ] }),
890
+ showSubject && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-2 border-b border-border/30", children: [
891
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-10 shrink-0", children: "Subj" }),
892
+ /* @__PURE__ */ jsx(
893
+ "input",
894
+ {
895
+ type: "text",
896
+ value: subject,
897
+ onChange: (e) => setSubject(e.target.value),
898
+ placeholder: "Subject...",
899
+ className: "flex-1 text-sm bg-transparent border-none focus:outline-none focus:ring-0 placeholder:text-muted-foreground/40 py-1 font-medium"
900
+ }
901
+ )
902
+ ] })
903
+ ] });
904
+ }
905
+ function SignatureBlock({
906
+ signature,
907
+ enabled,
908
+ onToggle
909
+ }) {
910
+ if (!enabled) {
911
+ return /* @__PURE__ */ jsx("div", { className: "px-3 py-2 border-t border-border/30", children: /* @__PURE__ */ jsxs(
912
+ "button",
913
+ {
914
+ onClick: onToggle,
915
+ className: "text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1.5",
916
+ children: [
917
+ /* @__PURE__ */ jsx(PenLine, { className: "w-3 h-3" }),
918
+ "Add signature"
919
+ ]
920
+ }
921
+ ) });
922
+ }
923
+ return /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-t border-border/30 bg-background/40", children: [
924
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-1", children: [
925
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground/60", children: "--" }),
926
+ /* @__PURE__ */ jsx("button", { onClick: onToggle, className: "text-xs text-muted-foreground hover:text-foreground transition-colors", children: "Remove" })
927
+ ] }),
928
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground/70 whitespace-pre-line leading-relaxed", children: signature })
929
+ ] });
930
+ }
931
+ function SuggestedActionCard({
932
+ action,
933
+ onDismiss,
934
+ onSend,
935
+ onSaveDraft,
936
+ accountContacts,
937
+ signature,
938
+ onDuplicate,
939
+ onOpenAccountDetails,
940
+ onOpenRecentActivity,
941
+ onMarkComplete,
942
+ onDispatchAgent,
943
+ iconMap,
944
+ sendLabel,
945
+ accountDetailsLabel,
946
+ dismissLabel = "Dismiss"
947
+ }) {
948
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
949
+ const isCall = action.type === "call";
950
+ const [expanded, setExpanded] = React.useState(action.type === "email" || isCall);
951
+ const [content, setContent] = React.useState(
952
+ isCall ? (_b = (_a = action.callMeta) == null ? void 0 : _a.talkTrack) != null ? _b : "" : (_d = (_c = action.content) == null ? void 0 : _c.replace(/<\/p>/gi, "\n\n").replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, "").replace(/\n\s*\n/g, "\n\n")) != null ? _d : ""
953
+ );
954
+ const [showAiEdit, setShowAiEdit] = React.useState(false);
955
+ const [feedbackOpen, setFeedbackOpen] = React.useState(false);
956
+ const [followUpEnabled, setFollowUpEnabled] = React.useState((_f = (_e = action.followUp) == null ? void 0 : _e.enabled) != null ? _f : false);
957
+ const [threadExpanded, setThreadExpanded] = React.useState(false);
958
+ const [expandedMessageId, setExpandedMessageId] = React.useState(null);
959
+ const [replyingToMessageId, setReplyingToMessageId] = React.useState(null);
960
+ const [ticketPriority, setTicketPriority] = React.useState((_h = (_g = action.ticket) == null ? void 0 : _g.priority) != null ? _h : "Medium");
961
+ const [ticketType, setTicketType] = React.useState((_j = (_i = action.ticket) == null ? void 0 : _i.type) != null ? _j : "Support Request");
962
+ const [ticketSubject, setTicketSubject] = React.useState((_l = (_k = action.ticket) == null ? void 0 : _k.subject) != null ? _l : "");
963
+ const [ticketDescription, setTicketDescription] = React.useState(
964
+ (_o = (_n = (_m = action.ticket) == null ? void 0 : _m.description) == null ? void 0 : _n.replace(/<\/p>/gi, "\n\n").replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, "").trim()) != null ? _o : ""
965
+ );
966
+ const [toContacts, setToContacts] = React.useState(((_p = action.emailMeta) == null ? void 0 : _p.to) ? [action.emailMeta.to] : []);
967
+ const [ccContacts, setCcContacts] = React.useState((_r = (_q = action.emailMeta) == null ? void 0 : _q.cc) != null ? _r : []);
968
+ const [bccContacts, setBccContacts] = React.useState(
969
+ ((_s = action.emailMeta) == null ? void 0 : _s.bcc) ? [{ name: action.emailMeta.bcc, role: "", email: action.emailMeta.bcc, confirmed: true }] : []
970
+ );
971
+ const [callContact, setCallContact] = React.useState((_t = action.callMeta) == null ? void 0 : _t.contact);
972
+ const [signatureEnabled, setSignatureEnabled] = React.useState(true);
973
+ const isNewEmail = action.type === "email" && !action.replyTo;
974
+ const isThreadReply = action.type === "email" && !!action.replyTo;
975
+ const canSend = isCall ? (_u = callContact == null ? void 0 : callContact.confirmed) != null ? _u : false : action.type === "email" ? toContacts.length > 0 && toContacts.every((contact) => contact.confirmed) : true;
976
+ const openInLabel = action.type === "email" ? "Open draft" : action.type === "ticket" ? "Open in Zendesk" : action.type === "slack" ? "Open in Slack" : "Open in App";
977
+ const addUniqueContact = React.useCallback((prev, contact) => {
978
+ var _a2, _b2, _c2;
979
+ const nextKey = `${contact.name}-${(_c2 = (_b2 = contact.email) != null ? _b2 : (_a2 = contact.emails) == null ? void 0 : _a2[0]) != null ? _c2 : ""}`;
980
+ if (prev.some((item) => {
981
+ var _a3, _b3, _c3;
982
+ return `${item.name}-${(_c3 = (_b3 = item.email) != null ? _b3 : (_a3 = item.emails) == null ? void 0 : _a3[0]) != null ? _c3 : ""}` === nextKey;
983
+ })) {
984
+ return prev;
985
+ }
986
+ return [...prev, contact];
987
+ }, []);
988
+ if (!expanded) {
989
+ return /* @__PURE__ */ jsxs(
990
+ "div",
991
+ {
992
+ onClick: () => setExpanded(true),
993
+ className: "p-4 flex items-center justify-between cursor-pointer hover:bg-muted/30 transition-colors",
994
+ children: [
995
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
996
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center w-7 h-7 shrink-0", children: getActionTypeIcon(action.type, "w-5 h-5", iconMap) }),
997
+ /* @__PURE__ */ jsxs("div", { children: [
998
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-foreground", children: action.label }),
999
+ ((_v = action.followUp) == null ? void 0 : _v.enabled) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs text-muted-foreground mt-1", children: [
1000
+ /* @__PURE__ */ jsx(Clock, { className: "w-3.5 h-3.5" }),
1001
+ /* @__PURE__ */ jsxs("span", { children: [
1002
+ "Follow-up in ",
1003
+ action.followUp.days,
1004
+ "d"
1005
+ ] })
1006
+ ] })
1007
+ ] })
1008
+ ] }),
1009
+ /* @__PURE__ */ jsx(ChevronDown, { className: "w-5 h-5 text-muted-foreground shrink-0" })
1010
+ ]
1011
+ }
1012
+ );
1013
+ }
1014
+ return /* @__PURE__ */ jsxs("div", { className: "animate-in fade-in zoom-in-95 duration-200", children: [
1015
+ /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 flex items-center justify-between bg-background border-b border-border/40", children: [
1016
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1017
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center w-7 h-7 shrink-0", children: getActionTypeIcon(action.type, "w-5 h-5", iconMap) }),
1018
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1019
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: action.label }),
1020
+ isThreadReply && /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 rounded-md border border-border/80 bg-muted/50 px-2 py-0.5 text-[11px] font-medium text-muted-foreground", children: [
1021
+ /* @__PURE__ */ jsx(Undo2, { className: "h-3 w-3" }),
1022
+ "Reply"
1023
+ ] })
1024
+ ] })
1025
+ ] }),
1026
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1027
+ /* @__PURE__ */ jsx(
1028
+ "button",
1029
+ {
1030
+ onClick: () => setFeedbackOpen(!feedbackOpen),
1031
+ className: `p-1.5 rounded transition-colors ${feedbackOpen ? "bg-emerald-100 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400" : "hover:bg-muted text-muted-foreground hover:text-foreground"}`,
1032
+ children: /* @__PURE__ */ jsx(ThumbsUp, { className: "w-3.5 h-3.5" })
1033
+ }
1034
+ ),
1035
+ /* @__PURE__ */ jsx(
1036
+ "button",
1037
+ {
1038
+ onClick: () => setFeedbackOpen(!feedbackOpen),
1039
+ className: "p-1.5 rounded transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",
1040
+ children: /* @__PURE__ */ jsx(ThumbsDown, { className: "w-3.5 h-3.5" })
1041
+ }
1042
+ ),
1043
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border/40 mx-0.5" }),
1044
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "4:15 PM" }),
1045
+ /* @__PURE__ */ jsx(
1046
+ "button",
1047
+ {
1048
+ onClick: () => setExpanded(false),
1049
+ className: "text-muted-foreground hover:text-foreground hover:bg-muted/50 p-2 rounded transition-colors",
1050
+ "aria-label": "Collapse",
1051
+ children: /* @__PURE__ */ jsx(ChevronUp, { className: "w-4 h-4" })
1052
+ }
1053
+ )
1054
+ ] })
1055
+ ] }),
1056
+ feedbackOpen && /* @__PURE__ */ jsx("div", { className: "px-5 py-3 border-b border-border/40 animate-in fade-in slide-in-from-top-2 duration-200", children: /* @__PURE__ */ jsx(
1057
+ DraftFeedbackInline,
1058
+ {
1059
+ onRegenerateRequest: (pills, detail) => console.log("Regenerate:", pills, detail),
1060
+ onSubmitFeedback: (type, pills, detail) => console.log("Feedback:", type, pills, detail),
1061
+ onDiscardRequest: (pills, detail) => {
1062
+ console.log("Discard:", pills, detail);
1063
+ onDismiss == null ? void 0 : onDismiss(action.id);
1064
+ }
1065
+ }
1066
+ ) }),
1067
+ isThreadReply && action.replyTo && /* @__PURE__ */ jsxs("div", { className: "border-b border-border/40", children: [
1068
+ action.threadMessages && action.threadMessages.length > 1 && /* @__PURE__ */ jsx("div", { className: "px-5 py-2 border-b border-border/40", children: /* @__PURE__ */ jsxs(
1069
+ "button",
1070
+ {
1071
+ onClick: () => setThreadExpanded(!threadExpanded),
1072
+ className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
1073
+ children: [
1074
+ action.threadMessages.length,
1075
+ " messages in this thread",
1076
+ /* @__PURE__ */ jsx("span", { className: "mx-1.5", children: "\xB7" }),
1077
+ /* @__PURE__ */ jsx("span", { className: "underline", children: threadExpanded ? "Hide thread" : "View thread" })
1078
+ ]
1079
+ }
1080
+ ) }),
1081
+ threadExpanded && action.threadMessages && action.threadMessages.length > 1 ? /* @__PURE__ */ jsx("div", { className: "bg-muted/20", children: action.threadMessages.map((msg, idx) => {
1082
+ const isExpMsg = expandedMessageId === msg.id;
1083
+ const isReplyingTo = !replyingToMessageId ? idx === action.threadMessages.length - 1 : replyingToMessageId === msg.id;
1084
+ const isLast = idx === action.threadMessages.length - 1;
1085
+ return /* @__PURE__ */ jsxs("div", { children: [
1086
+ /* @__PURE__ */ jsxs(
1087
+ "div",
1088
+ {
1089
+ className: "px-5 py-3 hover:bg-muted/30 cursor-pointer transition-colors group relative",
1090
+ onClick: () => setExpandedMessageId(isExpMsg ? null : msg.id),
1091
+ children: [
1092
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-1", children: [
1093
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1094
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-foreground", children: msg.from }),
1095
+ isReplyingTo && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground flex items-center gap-1", children: [
1096
+ /* @__PURE__ */ jsx(ArrowLeft, { className: "w-3 h-3" }),
1097
+ "Replying to this"
1098
+ ] })
1099
+ ] }),
1100
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1101
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: msg.time }),
1102
+ !isReplyingTo && !isExpMsg && /* @__PURE__ */ jsx(
1103
+ "button",
1104
+ {
1105
+ onClick: (e) => {
1106
+ e.stopPropagation();
1107
+ setReplyingToMessageId(msg.id);
1108
+ },
1109
+ className: "text-xs text-muted-foreground hover:text-foreground underline opacity-0 group-hover:opacity-100 transition-opacity",
1110
+ children: "Reply to this"
1111
+ }
1112
+ )
1113
+ ] })
1114
+ ] }),
1115
+ /* @__PURE__ */ jsx("div", { className: `text-sm text-muted-foreground leading-relaxed ${isExpMsg ? "" : "line-clamp-2"}`, children: isExpMsg ? msg.content : msg.preview }),
1116
+ isExpMsg && /* @__PURE__ */ jsx(
1117
+ "button",
1118
+ {
1119
+ onClick: (e) => {
1120
+ e.stopPropagation();
1121
+ setExpandedMessageId(null);
1122
+ },
1123
+ className: "text-xs text-muted-foreground hover:text-foreground underline mt-2",
1124
+ children: "Collapse"
1125
+ }
1126
+ )
1127
+ ]
1128
+ }
1129
+ ),
1130
+ !isLast && /* @__PURE__ */ jsx("div", { className: "h-px bg-border/40 mx-5" })
1131
+ ] }, msg.id);
1132
+ }) }) : /* @__PURE__ */ jsxs("div", { className: "px-5 py-3 bg-muted/30", children: [
1133
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-2", children: [
1134
+ /* @__PURE__ */ jsxs("span", { className: "text-xs font-semibold text-foreground", children: [
1135
+ action.replyTo.from,
1136
+ " to Me"
1137
+ ] }),
1138
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: action.replyTo.time })
1139
+ ] }),
1140
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground leading-relaxed line-clamp-3", children: action.replyTo.content })
1141
+ ] })
1142
+ ] }),
1143
+ action.type === "slack" && action.replyTo && /* @__PURE__ */ jsx("div", { className: "border-b border-border/40", children: /* @__PURE__ */ jsxs("div", { className: "px-5 py-3 bg-muted/30", children: [
1144
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-2", children: [
1145
+ /* @__PURE__ */ jsxs("span", { className: "text-xs font-semibold text-foreground", children: [
1146
+ action.replyTo.from,
1147
+ " to Me"
1148
+ ] }),
1149
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: action.replyTo.time })
1150
+ ] }),
1151
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground leading-relaxed line-clamp-3", children: action.replyTo.content })
1152
+ ] }) }),
1153
+ action.type === "email" && action.emailMeta && /* @__PURE__ */ jsxs("div", { children: [
1154
+ isThreadReply && /* @__PURE__ */ jsxs("div", { className: "mx-4 mt-3 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/[0.16] px-3 py-1.5 text-xs text-muted-foreground", children: [
1155
+ /* @__PURE__ */ jsx(Undo2, { className: "h-3 w-3" }),
1156
+ "Replying in existing thread"
1157
+ ] }),
1158
+ /* @__PURE__ */ jsx(
1159
+ EmailHeader,
1160
+ {
1161
+ fromName: action.emailMeta.from,
1162
+ fromEmail: action.emailMeta.fromEmail,
1163
+ toContacts,
1164
+ ccContacts,
1165
+ initialSubject: action.emailMeta.subject,
1166
+ accountContacts,
1167
+ bccContacts,
1168
+ onAddToContact: (c) => setToContacts((prev) => addUniqueContact(prev, c)),
1169
+ onRemoveToContact: (index) => setToContacts((prev) => prev.filter((_, idx) => idx !== index)),
1170
+ onConfirmToContact: (index) => setToContacts(
1171
+ (prev) => prev.map((contact, idx) => idx === index ? __spreadProps(__spreadValues({}, contact), { confirmed: true }) : contact)
1172
+ ),
1173
+ onUpdateToContact: (index, updatedContact) => setToContacts(
1174
+ (prev) => prev.map((contact, idx) => idx === index ? updatedContact : contact)
1175
+ ),
1176
+ onCcAdd: (c) => setCcContacts((prev) => addUniqueContact(prev, c)),
1177
+ onCcRemove: (i) => setCcContacts((prev) => prev.filter((_, idx) => idx !== i)),
1178
+ onBccAdd: (c) => setBccContacts((prev) => addUniqueContact(prev, c)),
1179
+ onBccRemove: (i) => setBccContacts((prev) => prev.filter((_, idx) => idx !== i)),
1180
+ onOpenAccountDetails,
1181
+ onOpenRecentActivity,
1182
+ iconMap,
1183
+ showSubject: isNewEmail,
1184
+ accountDetailsLabel
1185
+ }
1186
+ )
1187
+ ] }),
1188
+ isCall && /* @__PURE__ */ jsx("div", { className: "mx-4 mt-3 rounded-md border border-border/60 bg-muted/[0.16] px-3 py-2.5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1189
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-10 shrink-0 mt-1.5", children: "To" }),
1190
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
1191
+ callContact ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: /* @__PURE__ */ jsxs(
1192
+ "div",
1193
+ {
1194
+ className: `inline-flex max-w-[300px] items-start gap-2 rounded-md border px-2 py-1 text-xs ${callContact.confirmed ? "border-border/80 bg-background text-foreground" : "border-amber-300 bg-amber-50 text-amber-800"}`,
1195
+ children: [
1196
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1197
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
1198
+ /* @__PURE__ */ jsx("span", { className: "font-medium leading-none", children: callContact.name }),
1199
+ callContact.confirmed && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-emerald-600" })
1200
+ ] }),
1201
+ callContact.role && /* @__PURE__ */ jsx("div", { className: "mt-0.5 truncate text-muted-foreground", children: callContact.role }),
1202
+ (callContact.phone || ((_w = callContact.phones) == null ? void 0 : _w[0])) && /* @__PURE__ */ jsx("div", { className: "mt-0.5 truncate text-muted-foreground", children: (_y = callContact.phone) != null ? _y : (_x = callContact.phones) == null ? void 0 : _x[0] })
1203
+ ] }),
1204
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
1205
+ !callContact.confirmed && /* @__PURE__ */ jsx(
1206
+ "button",
1207
+ {
1208
+ type: "button",
1209
+ onClick: (e) => {
1210
+ e.stopPropagation();
1211
+ setCallContact(__spreadProps(__spreadValues({}, callContact), { confirmed: true }));
1212
+ },
1213
+ className: "h-6 rounded px-1.5 text-[10px] font-semibold hover:bg-amber-100",
1214
+ children: "Confirm"
1215
+ }
1216
+ ),
1217
+ /* @__PURE__ */ jsx(
1218
+ "button",
1219
+ {
1220
+ type: "button",
1221
+ onClick: (e) => {
1222
+ e.stopPropagation();
1223
+ setCallContact(void 0);
1224
+ },
1225
+ className: "rounded p-0.5 text-muted-foreground hover:text-foreground hover:bg-muted/40",
1226
+ "aria-label": "Remove recipient",
1227
+ children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
1228
+ }
1229
+ )
1230
+ ] })
1231
+ ]
1232
+ }
1233
+ ) }) : /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "No contact selected." }),
1234
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center flex-wrap gap-1.5 mt-1.5", children: [
1235
+ accountContacts && accountContacts.length > 0 && /* @__PURE__ */ jsx(
1236
+ AccountContactsPopover,
1237
+ {
1238
+ contacts: accountContacts,
1239
+ onSelect: (c) => setCallContact(__spreadProps(__spreadValues({}, c), { confirmed: true })),
1240
+ onViewAll: onOpenAccountDetails,
1241
+ onOpenRecentActivity,
1242
+ iconMap,
1243
+ trigger: /* @__PURE__ */ jsx("button", { className: "h-7 rounded-md border border-border bg-background px-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors", children: "Contacts" })
1244
+ }
1245
+ ),
1246
+ /* @__PURE__ */ jsx(
1247
+ "button",
1248
+ {
1249
+ type: "button",
1250
+ onClick: onOpenAccountDetails,
1251
+ className: "h-7 rounded-md border border-border bg-background px-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors",
1252
+ children: accountDetailsLabel != null ? accountDetailsLabel : "Account details"
1253
+ }
1254
+ )
1255
+ ] })
1256
+ ] })
1257
+ ] }) }),
1258
+ /* @__PURE__ */ jsx("div", { children: action.type === "ticket" ? /* @__PURE__ */ jsxs("div", { className: "p-5 space-y-4", children: [
1259
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1260
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
1261
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Priority" }),
1262
+ /* @__PURE__ */ jsxs(
1263
+ "select",
1264
+ {
1265
+ className: "w-full px-3 py-2 text-sm bg-background border border-border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-primary/20",
1266
+ value: ticketPriority,
1267
+ onChange: (e) => setTicketPriority(e.target.value),
1268
+ children: [
1269
+ /* @__PURE__ */ jsx("option", { children: "High" }),
1270
+ /* @__PURE__ */ jsx("option", { children: "Medium" }),
1271
+ /* @__PURE__ */ jsx("option", { children: "Low" })
1272
+ ]
1273
+ }
1274
+ )
1275
+ ] }),
1276
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
1277
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Type" }),
1278
+ /* @__PURE__ */ jsxs(
1279
+ "select",
1280
+ {
1281
+ className: "w-full px-3 py-2 text-sm bg-background border border-border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-primary/20",
1282
+ value: ticketType,
1283
+ onChange: (e) => setTicketType(e.target.value),
1284
+ children: [
1285
+ /* @__PURE__ */ jsx("option", { children: "Churn Risk" }),
1286
+ /* @__PURE__ */ jsx("option", { children: "Support Request" }),
1287
+ /* @__PURE__ */ jsx("option", { children: "Feature Request" })
1288
+ ]
1289
+ }
1290
+ )
1291
+ ] })
1292
+ ] }),
1293
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
1294
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Subject" }),
1295
+ /* @__PURE__ */ jsx(
1296
+ "input",
1297
+ {
1298
+ className: "w-full px-3 py-2 text-sm bg-background border border-border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-primary/20",
1299
+ value: ticketSubject,
1300
+ onChange: (e) => setTicketSubject(e.target.value)
1301
+ }
1302
+ )
1303
+ ] }),
1304
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
1305
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "Description" }),
1306
+ /* @__PURE__ */ jsx(
1307
+ "textarea",
1308
+ {
1309
+ className: "w-full min-h-[100px] px-3 py-2 text-sm bg-background border border-border rounded-md shadow-sm resize-none focus:outline-none focus:ring-1 focus:ring-primary/20",
1310
+ value: ticketDescription,
1311
+ onChange: (e) => setTicketDescription(e.target.value)
1312
+ }
1313
+ )
1314
+ ] })
1315
+ ] }) : isCall ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
1316
+ /* @__PURE__ */ jsx("div", { className: "px-4 pt-3 pb-3", children: /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border/60 bg-muted/[0.16] overflow-hidden", children: [
1317
+ /* @__PURE__ */ jsx("div", { className: "px-3 pt-2 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70", children: "Talk track" }),
1318
+ /* @__PURE__ */ jsx("div", { className: "px-3 pb-3", children: /* @__PURE__ */ jsx(
1319
+ "textarea",
1320
+ {
1321
+ className: "w-full min-h-[280px] text-sm leading-relaxed bg-transparent border-none resize-none focus:ring-0 focus:outline-none placeholder:text-muted-foreground/50 p-0 overflow-y-auto",
1322
+ value: content,
1323
+ onChange: (e) => setContent(e.target.value),
1324
+ placeholder: "Edit talk track..."
1325
+ }
1326
+ ) })
1327
+ ] }) }),
1328
+ /* @__PURE__ */ jsx(EditorToolbar, {})
1329
+ ] }) : action.type === "manual" ? /* @__PURE__ */ jsx("div", { className: "p-5 space-y-4", children: /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border/60 bg-muted/[0.16] overflow-hidden", children: [
1330
+ /* @__PURE__ */ jsx("div", { className: "px-3 pt-2 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70", children: "Task description" }),
1331
+ /* @__PURE__ */ jsx("div", { className: "px-3 pb-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm leading-relaxed text-foreground whitespace-pre-wrap", children: (_B = (_A = (_z = action.manualMeta) == null ? void 0 : _z.taskDescription) != null ? _A : action.content) != null ? _B : "" }) })
1332
+ ] }) }) : action.type === "browser" ? /* @__PURE__ */ jsx("div", { className: "p-5 space-y-4", children: /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border/60 bg-muted/[0.16] overflow-hidden", children: [
1333
+ /* @__PURE__ */ jsx("div", { className: "px-3 pt-2 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70", children: "Browser automation" }),
1334
+ /* @__PURE__ */ jsxs("div", { className: "px-3 pb-3 space-y-2", children: [
1335
+ ((_C = action.browserMeta) == null ? void 0 : _C.url) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
1336
+ /* @__PURE__ */ jsx(Globe, { className: "w-3.5 h-3.5 shrink-0" }),
1337
+ /* @__PURE__ */ jsx("a", { href: action.browserMeta.url, target: "_blank", rel: "noopener noreferrer", className: "text-primary underline underline-offset-2 truncate", children: action.browserMeta.url })
1338
+ ] }),
1339
+ /* @__PURE__ */ jsx("p", { className: "text-sm leading-relaxed text-foreground whitespace-pre-wrap", children: (_F = (_E = (_D = action.browserMeta) == null ? void 0 : _D.actionDescription) != null ? _E : action.content) != null ? _F : "" })
1340
+ ] })
1341
+ ] }) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
1342
+ /* @__PURE__ */ jsx("div", { className: "px-4 pt-3 pb-3", children: /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border/60 bg-muted/[0.16] overflow-hidden", children: [
1343
+ /* @__PURE__ */ jsx("div", { className: "px-3 pt-2 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70", children: "Draft" }),
1344
+ /* @__PURE__ */ jsx("div", { className: "px-3 pb-3", children: /* @__PURE__ */ jsx(
1345
+ "textarea",
1346
+ {
1347
+ className: "w-full min-h-[280px] text-sm leading-relaxed bg-transparent border-none resize-none focus:ring-0 focus:outline-none placeholder:text-muted-foreground/50 p-0 overflow-y-auto",
1348
+ value: content,
1349
+ onChange: (e) => setContent(e.target.value),
1350
+ placeholder: "Write your message..."
1351
+ }
1352
+ ) }),
1353
+ action.type === "email" && signature && /* @__PURE__ */ jsx(SignatureBlock, { signature, enabled: signatureEnabled, onToggle: () => setSignatureEnabled(!signatureEnabled) })
1354
+ ] }) }),
1355
+ /* @__PURE__ */ jsx(EditorToolbar, {})
1356
+ ] }) }),
1357
+ /* @__PURE__ */ jsx("div", { className: "bg-muted/10 border-t border-border/60", children: /* @__PURE__ */ jsxs("div", { className: "px-5 py-4", children: [
1358
+ showAiEdit && /* @__PURE__ */ jsx(AiEditPanel, { onApply: (pills, desc) => console.log("AI Edit:", pills, desc) }),
1359
+ action.followUp && /* @__PURE__ */ jsx("div", { className: "mb-3", children: /* @__PURE__ */ jsx(FollowUpToggle, { checked: followUpEnabled, onCheckedChange: setFollowUpEnabled, days: action.followUp.days }) }),
1360
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1361
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 overflow-x-auto no-scrollbar", children: [
1362
+ /* @__PURE__ */ jsx(
1363
+ Button,
1364
+ {
1365
+ variant: "ghost",
1366
+ size: "sm",
1367
+ className: `h-9 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/50 ${showAiEdit ? "bg-muted/50 text-foreground" : ""}`,
1368
+ onClick: () => setShowAiEdit(!showAiEdit),
1369
+ children: "AI Edit"
1370
+ }
1371
+ ),
1372
+ !isCall && action.type !== "email" && /* @__PURE__ */ jsx(
1373
+ Button,
1374
+ {
1375
+ variant: "ghost",
1376
+ size: "sm",
1377
+ className: "h-9 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/50",
1378
+ onClick: () => onSaveDraft == null ? void 0 : onSaveDraft(action.id),
1379
+ children: "Draft"
1380
+ }
1381
+ ),
1382
+ !isCall && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", className: "h-9 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/50 whitespace-nowrap", children: openInLabel }),
1383
+ /* @__PURE__ */ jsx(
1384
+ Button,
1385
+ {
1386
+ variant: "ghost",
1387
+ size: "sm",
1388
+ className: "h-9 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/50",
1389
+ onClick: () => onDismiss == null ? void 0 : onDismiss(action.id),
1390
+ children: dismissLabel
1391
+ }
1392
+ ),
1393
+ action.type === "email" && onDuplicate && /* @__PURE__ */ jsxs(
1394
+ Button,
1395
+ {
1396
+ variant: "ghost",
1397
+ size: "sm",
1398
+ className: "h-9 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/50 whitespace-nowrap",
1399
+ onClick: () => onDuplicate(action.id),
1400
+ children: [
1401
+ /* @__PURE__ */ jsx(Copy, { className: "w-3 h-3 mr-1.5" }),
1402
+ "Copy"
1403
+ ]
1404
+ }
1405
+ )
1406
+ ] }),
1407
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-2 shrink-0", children: [
1408
+ /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border/60" }),
1409
+ isCall ? /* @__PURE__ */ jsxs(Fragment, { children: [
1410
+ ((_G = action.callMeta) == null ? void 0 : _G.allowDispatchAgent) && /* @__PURE__ */ jsx(
1411
+ Button,
1412
+ {
1413
+ variant: "outline",
1414
+ size: "sm",
1415
+ className: "h-9 text-xs font-medium shadow-none",
1416
+ onClick: () => onDispatchAgent == null ? void 0 : onDispatchAgent(action.id, content),
1417
+ disabled: !canSend,
1418
+ children: "Dispatch agent"
1419
+ }
1420
+ ),
1421
+ /* @__PURE__ */ jsxs(
1422
+ Button,
1423
+ {
1424
+ size: "sm",
1425
+ className: `px-5 h-9 text-xs font-semibold shadow-sm ${canSend ? "bg-foreground text-background hover:bg-foreground/90" : "bg-muted text-muted-foreground cursor-not-allowed"}`,
1426
+ onClick: () => canSend && (onMarkComplete == null ? void 0 : onMarkComplete(action.id)),
1427
+ disabled: !canSend,
1428
+ children: [
1429
+ /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 mr-1.5" }),
1430
+ "Mark complete"
1431
+ ]
1432
+ }
1433
+ )
1434
+ ] }) : action.type === "manual" ? /* @__PURE__ */ jsxs(
1435
+ Button,
1436
+ {
1437
+ size: "sm",
1438
+ className: "px-5 h-9 text-xs font-semibold shadow-sm bg-foreground text-background hover:bg-foreground/90",
1439
+ onClick: () => onMarkComplete == null ? void 0 : onMarkComplete(action.id),
1440
+ children: [
1441
+ /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 mr-1.5" }),
1442
+ "Mark complete"
1443
+ ]
1444
+ }
1445
+ ) : action.type === "browser" ? /* @__PURE__ */ jsxs(
1446
+ Button,
1447
+ {
1448
+ size: "sm",
1449
+ className: "px-5 h-9 text-xs font-semibold shadow-sm bg-foreground text-background hover:bg-foreground/90",
1450
+ onClick: () => onSend == null ? void 0 : onSend(action.id),
1451
+ children: [
1452
+ /* @__PURE__ */ jsx(Globe, { className: "w-3.5 h-3.5 mr-1.5" }),
1453
+ sendLabel != null ? sendLabel : "Run"
1454
+ ]
1455
+ }
1456
+ ) : /* @__PURE__ */ jsx(
1457
+ Button,
1458
+ {
1459
+ size: "sm",
1460
+ className: `px-6 h-9 text-xs font-semibold shadow-sm ${canSend ? "bg-foreground text-background hover:bg-foreground/90" : "bg-muted text-muted-foreground cursor-not-allowed"}`,
1461
+ onClick: () => canSend && (onSend == null ? void 0 : onSend(action.id)),
1462
+ disabled: !canSend,
1463
+ children: sendLabel != null ? sendLabel : "Send"
1464
+ }
1465
+ )
1466
+ ] })
1467
+ ] })
1468
+ ] }) })
1469
+ ] });
1470
+ }
1471
+ function SuggestedActions({
1472
+ actions,
1473
+ title = "Suggested Actions",
1474
+ onDismiss,
1475
+ onSend,
1476
+ onSaveDraft,
1477
+ accountContacts,
1478
+ signature,
1479
+ onDuplicate,
1480
+ onOpenAccountDetails,
1481
+ onOpenRecentActivity,
1482
+ onMarkComplete,
1483
+ onDispatchAgent,
1484
+ iconMap,
1485
+ sendLabel,
1486
+ accountDetailsLabel,
1487
+ dismissLabel
1488
+ }) {
1489
+ const [dismissedIds, setDismissedIds] = React.useState(/* @__PURE__ */ new Set());
1490
+ const handleDismiss = React.useCallback(
1491
+ (id) => {
1492
+ setDismissedIds((prev) => /* @__PURE__ */ new Set([...prev, id]));
1493
+ onDismiss == null ? void 0 : onDismiss(id);
1494
+ },
1495
+ [onDismiss]
1496
+ );
1497
+ const visibleActions = actions.filter((a) => a.status !== "dismissed" && !dismissedIds.has(a.id));
1498
+ return /* @__PURE__ */ jsxs("div", { className: "py-6 border-t border-border", children: [
1499
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4", children: [
1500
+ /* @__PURE__ */ jsx("div", { className: "text-[11px] font-bold text-muted-foreground/70 uppercase tracking-wider", children: title }),
1501
+ /* @__PURE__ */ jsxs("span", { className: "text-[11px] text-muted-foreground", children: [
1502
+ visibleActions.length,
1503
+ " actions"
1504
+ ] })
1505
+ ] }),
1506
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: visibleActions.map((action) => /* @__PURE__ */ jsx(
1507
+ "div",
1508
+ {
1509
+ className: "group bg-background border border-border rounded-md overflow-hidden shadow-sm hover:shadow-md transition-all duration-200",
1510
+ children: /* @__PURE__ */ jsx(
1511
+ SuggestedActionCard,
1512
+ {
1513
+ action,
1514
+ onDismiss: handleDismiss,
1515
+ onSend,
1516
+ onSaveDraft,
1517
+ accountContacts,
1518
+ signature,
1519
+ onDuplicate,
1520
+ onOpenAccountDetails,
1521
+ onOpenRecentActivity,
1522
+ onMarkComplete,
1523
+ onDispatchAgent,
1524
+ iconMap,
1525
+ sendLabel,
1526
+ accountDetailsLabel,
1527
+ dismissLabel
1528
+ }
1529
+ )
1530
+ },
1531
+ action.id
1532
+ )) })
1533
+ ] });
1534
+ }
1535
+ export {
1536
+ SuggestedActions
1537
+ };
1538
+ //# sourceMappingURL=suggested-actions.js.map