@ultrst-armada/floks 1.6.0 → 1.7.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.
@@ -0,0 +1,1263 @@
1
+ import {
2
+ BaseSelect,
3
+ BaseTextarea
4
+ } from "./chunk-KIFQA7L6.js";
5
+ import {
6
+ BaseInput
7
+ } from "./chunk-W42SJGOJ.js";
8
+ import {
9
+ BaseButton
10
+ } from "./chunk-A2CDQISJ.js";
11
+
12
+ // src/components/ai/model-card/providerIconHelper.ts
13
+ import { Cpu, Zap, CloudLightning, Gauge, Globe, Workflow, FolderHeart, HelpCircle } from "lucide-react";
14
+ var getProviderIcon = (provider) => {
15
+ switch (provider.toLowerCase()) {
16
+ case "google":
17
+ return CloudLightning;
18
+ case "groq":
19
+ return Gauge;
20
+ case "cerebras":
21
+ return Cpu;
22
+ case "openrouter":
23
+ return Globe;
24
+ case "together":
25
+ return Workflow;
26
+ case "nvidia":
27
+ return Zap;
28
+ case "huggingface":
29
+ return FolderHeart;
30
+ default:
31
+ return HelpCircle;
32
+ }
33
+ };
34
+
35
+ // src/components/ai/model-card/ModelCardHeader.tsx
36
+ import { AlertOctagon, RefreshCw, Key } from "lucide-react";
37
+ import { jsx, jsxs } from "react/jsx-runtime";
38
+ var ModelCardHeader = ({
39
+ model: m,
40
+ rankIndex,
41
+ isTopMatch,
42
+ matchScore,
43
+ providerStatus,
44
+ isUnavailable = false,
45
+ onRefreshRoute,
46
+ onOpenKeyManager
47
+ }) => {
48
+ const ProviderIcon = getProviderIcon(m.providerId);
49
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
50
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-1", children: [
51
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-wrap", children: [
52
+ rankIndex !== void 0 && !isUnavailable && /* @__PURE__ */ jsx(
53
+ "span",
54
+ {
55
+ className: `px-1 py-0.5 rounded text-[9px] font-black tracking-tight uppercase border ${isTopMatch ? "bg-emerald-400 text-slate-950 border-emerald-600 shadow-sm" : rankIndex < 3 ? "bg-indigo-300 text-indigo-950 dark:bg-indigo-900 dark:text-indigo-100 border-indigo-700" : "bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-600"}`,
56
+ children: isTopMatch ? "\u2605 #1 MATCH" : `#${rankIndex + 1}`
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 px-1 py-0.5 rounded border border-slate-700/50 bg-slate-200/80 dark:bg-slate-800/80 text-[8px] font-bold", children: [
60
+ /* @__PURE__ */ jsx(ProviderIcon, { size: 9 }),
61
+ m.providerId.toUpperCase()
62
+ ] }),
63
+ providerStatus === "missing-key" && /* @__PURE__ */ jsxs(
64
+ "span",
65
+ {
66
+ onClick: (e) => {
67
+ e.stopPropagation();
68
+ onOpenKeyManager?.(m.providerId);
69
+ },
70
+ title: `No API key configured for ${m.providerId.toUpperCase()}. Click to add.`,
71
+ className: "px-1 py-0.5 rounded bg-amber-500/20 text-amber-700 dark:text-amber-300 border border-amber-600/50 text-[7.5px] font-bold cursor-pointer hover:bg-amber-500/40 transition-colors flex items-center gap-0.5",
72
+ children: [
73
+ /* @__PURE__ */ jsx(Key, { size: 8 }),
74
+ " KEY NEEDED"
75
+ ]
76
+ }
77
+ )
78
+ ] }),
79
+ matchScore !== void 0 && !isUnavailable && /* @__PURE__ */ jsx("div", { className: "text-right shrink-0", children: /* @__PURE__ */ jsx(
80
+ "div",
81
+ {
82
+ className: `text-xs font-black leading-none ${isTopMatch ? "text-emerald-600 dark:text-emerald-400" : "text-indigo-600 dark:text-indigo-400"}`,
83
+ children: matchScore
84
+ }
85
+ ) })
86
+ ] }),
87
+ isUnavailable && /* @__PURE__ */ jsxs("div", { className: "bg-rose-600 text-white font-bold text-[8px] px-1.5 py-0.5 rounded flex items-center justify-between gap-1 border border-rose-800 shadow-sm", children: [
88
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 truncate", children: [
89
+ /* @__PURE__ */ jsx(AlertOctagon, { size: 10, className: "shrink-0" }),
90
+ " ROUTE UNAVAILABLE"
91
+ ] }),
92
+ onRefreshRoute && /* @__PURE__ */ jsx(
93
+ BaseButton,
94
+ {
95
+ size: "sm",
96
+ variant: "ghost",
97
+ onClick: (e) => {
98
+ e.stopPropagation();
99
+ onRefreshRoute(m.id);
100
+ },
101
+ title: "Probe & refresh route status",
102
+ className: "bg-white/20 hover:bg-white/40 p-0.5 rounded shrink-0",
103
+ children: /* @__PURE__ */ jsx(RefreshCw, { size: 9 })
104
+ }
105
+ )
106
+ ] }),
107
+ /* @__PURE__ */ jsx(
108
+ "h4",
109
+ {
110
+ className: "font-extrabold text-xs text-slate-900 dark:text-slate-100 leading-snug line-clamp-2 pt-0.5",
111
+ title: m.name,
112
+ children: m.name
113
+ }
114
+ )
115
+ ] });
116
+ };
117
+
118
+ // src/components/ai/model-card/ModelCardFooter.tsx
119
+ import { Cpu as Cpu2, Zap as Zap2, Activity, MessageSquare, Check, Play } from "lucide-react";
120
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
121
+ var ModelCardFooter = ({
122
+ model: m,
123
+ isSelectedForTest,
124
+ onSelectForTest,
125
+ onOpenChat
126
+ }) => {
127
+ return /* @__PURE__ */ jsxs2("div", { className: "space-y-1 pt-1 border-t border-slate-700/20 text-[8.5px] text-slate-500 font-mono", children: [
128
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between", children: [
129
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1.5", children: [
130
+ /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-0.5", title: "Intelligence Rating", children: [
131
+ /* @__PURE__ */ jsx2(Cpu2, { size: 9, className: "text-indigo-500" }),
132
+ m.intelligenceRating ?? 85
133
+ ] }),
134
+ /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-0.5", title: "Tool Rating", children: [
135
+ /* @__PURE__ */ jsx2(Zap2, { size: 9, className: "text-amber-500" }),
136
+ m.toolRating ?? 80
137
+ ] }),
138
+ /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-0.5", title: "Speed Rating", children: [
139
+ /* @__PURE__ */ jsx2(Activity, { size: 9, className: "text-rose-500" }),
140
+ m.speedRating ?? 90
141
+ ] })
142
+ ] }),
143
+ /* @__PURE__ */ jsxs2("span", { className: "font-bold", children: [
144
+ "$",
145
+ m.costPer1kInputUsd ?? m.inputCostPer1k ?? 0,
146
+ "/k"
147
+ ] })
148
+ ] }),
149
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-1 pt-0.5", children: [
150
+ /* @__PURE__ */ jsx2(
151
+ BaseButton,
152
+ {
153
+ size: "sm",
154
+ variant: "secondary",
155
+ onClick: (e) => {
156
+ e.stopPropagation();
157
+ onOpenChat?.(m.id, m.providerId);
158
+ },
159
+ className: "text-[8px] flex items-center gap-1 font-bold px-1.5 py-0.5",
160
+ icon: /* @__PURE__ */ jsx2(MessageSquare, { size: 9, className: "text-indigo-500" }),
161
+ children: "CHAT"
162
+ }
163
+ ),
164
+ onSelectForTest && /* @__PURE__ */ jsx2(
165
+ BaseButton,
166
+ {
167
+ size: "sm",
168
+ variant: isSelectedForTest ? "accent" : "secondary",
169
+ onClick: (e) => {
170
+ e.stopPropagation();
171
+ onSelectForTest(m.id, m.providerId);
172
+ },
173
+ className: "p-1",
174
+ children: isSelectedForTest ? /* @__PURE__ */ jsx2(Check, { size: 11 }) : /* @__PURE__ */ jsx2(Play, { size: 11 })
175
+ }
176
+ )
177
+ ] })
178
+ ] });
179
+ };
180
+
181
+ // src/components/ai/model-card/ModelCard.tsx
182
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
183
+ var ModelCard = ({
184
+ model: m,
185
+ rankIndex,
186
+ isTopMatch,
187
+ matchScore,
188
+ isSelectedForTest,
189
+ providerStatus,
190
+ isUnavailable = false,
191
+ onSelectForTest,
192
+ onDoubleClick,
193
+ onOpenChat,
194
+ onRefreshRoute,
195
+ onOpenKeyManager,
196
+ visualSlot
197
+ }) => {
198
+ const handleCardDoubleClick = (e) => {
199
+ e.stopPropagation();
200
+ const chatFn = onOpenChat || onDoubleClick;
201
+ if (chatFn && !isUnavailable) {
202
+ chatFn(m.id, m.providerId);
203
+ }
204
+ };
205
+ return /* @__PURE__ */ jsxs3(
206
+ "div",
207
+ {
208
+ onDoubleClick: handleCardDoubleClick,
209
+ title: isUnavailable ? "Route currently unavailable" : `Double click to chat with ${m.name}`,
210
+ className: `p-3 rounded-xl border-2 font-mono text-xs flex flex-col justify-between relative transition-all duration-100 cursor-pointer select-none group min-h-[220px] ${isUnavailable ? "opacity-60 grayscale filter border-slate-600 bg-slate-200/60 dark:bg-slate-900/60 shadow-none" : isTopMatch ? "border-emerald-500 bg-emerald-50/80 dark:bg-emerald-950/40 shadow-md" : isSelectedForTest ? "border-indigo-600 bg-indigo-50/80 dark:bg-indigo-950/40 shadow-md" : "border-slate-300 dark:border-slate-700 bg-white/90 dark:bg-slate-900/90 text-slate-900 dark:text-slate-100 shadow-sm hover:border-slate-400 dark:hover:border-slate-500 hover:shadow-md"}`,
211
+ children: [
212
+ /* @__PURE__ */ jsx3(
213
+ ModelCardHeader,
214
+ {
215
+ model: m,
216
+ rankIndex,
217
+ isTopMatch,
218
+ matchScore,
219
+ providerStatus,
220
+ isUnavailable,
221
+ onRefreshRoute,
222
+ onOpenKeyManager
223
+ }
224
+ ),
225
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1 flex flex-col items-center justify-center my-2 py-2 relative", children: [
226
+ visualSlot ? visualSlot : /* @__PURE__ */ jsx3("div", { className: "w-12 h-12 rounded-full border border-dashed border-slate-400 dark:border-slate-600 flex items-center justify-center text-[10px] text-slate-400", children: "AI" }),
227
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1 mt-1 text-[8px] font-extrabold font-mono", children: [
228
+ /* @__PURE__ */ jsxs3("span", { className: "px-1 py-0.5 rounded bg-slate-200/90 dark:bg-slate-800/90 border border-slate-400/50 dark:border-slate-600/50 text-slate-700 dark:text-slate-300", children: [
229
+ m.contextWindow && m.contextWindow >= 1e6 ? `${(m.contextWindow / 1e6).toFixed(1)}M` : m.contextWindow ? `${(m.contextWindow / 1e3).toFixed(0)}k` : "128k",
230
+ " ",
231
+ "ctx"
232
+ ] }),
233
+ /* @__PURE__ */ jsx3(
234
+ "span",
235
+ {
236
+ className: `px-1 py-0.5 rounded border font-black ${m.isFree ? "bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 border-emerald-500/50" : "bg-amber-500/20 text-amber-600 dark:text-amber-400 border-amber-500/50"}`,
237
+ children: m.isFree ? "FREE" : "PAID"
238
+ }
239
+ )
240
+ ] })
241
+ ] }),
242
+ /* @__PURE__ */ jsx3(
243
+ ModelCardFooter,
244
+ {
245
+ model: m,
246
+ isSelectedForTest,
247
+ onSelectForTest,
248
+ onOpenChat: onOpenChat || onDoubleClick
249
+ }
250
+ )
251
+ ]
252
+ }
253
+ );
254
+ };
255
+
256
+ // src/components/ai/model-picker/AIProviderSelector.tsx
257
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
258
+ var AIProviderSelector = ({
259
+ providers,
260
+ selectedProvider,
261
+ onSelectProvider,
262
+ className = ""
263
+ }) => {
264
+ return /* @__PURE__ */ jsx4("div", { className: `flex items-center gap-1.5 flex-wrap ${className}`, children: providers.map((p) => {
265
+ const Icon = getProviderIcon(p);
266
+ const isSelected = selectedProvider?.toLowerCase() === p.toLowerCase();
267
+ return /* @__PURE__ */ jsxs4(
268
+ "button",
269
+ {
270
+ type: "button",
271
+ onClick: () => onSelectProvider(p),
272
+ className: `flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono font-bold transition-all border ${isSelected ? "bg-indigo-600 text-white border-indigo-700 shadow-sm" : "bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-300 dark:border-slate-700 hover:border-slate-400"}`,
273
+ children: [
274
+ /* @__PURE__ */ jsx4(Icon, { size: 12 }),
275
+ /* @__PURE__ */ jsx4("span", { className: "uppercase", children: p })
276
+ ]
277
+ },
278
+ p
279
+ );
280
+ }) });
281
+ };
282
+
283
+ // src/components/ai/model-picker/AIModelPicker.tsx
284
+ import { useState } from "react";
285
+ import { ChevronDown, Check as Check2, Sparkles } from "lucide-react";
286
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
287
+ var AIModelPicker = ({
288
+ models,
289
+ selectedModelId,
290
+ onSelectModel,
291
+ className = ""
292
+ }) => {
293
+ const [isOpen, setIsOpen] = useState(false);
294
+ const current = models.find((m) => m.id === selectedModelId) || models[0];
295
+ const CurrentIcon = current ? getProviderIcon(current.providerId) : Sparkles;
296
+ return /* @__PURE__ */ jsxs5("div", { className: `relative inline-block text-left font-mono text-xs ${className}`, children: [
297
+ /* @__PURE__ */ jsxs5(
298
+ "button",
299
+ {
300
+ type: "button",
301
+ onClick: () => setIsOpen(!isOpen),
302
+ className: "flex items-center gap-2 px-2.5 py-1.5 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-800 dark:text-slate-200 hover:border-slate-400 font-bold shadow-sm",
303
+ children: [
304
+ /* @__PURE__ */ jsx5(CurrentIcon, { size: 13, className: "text-indigo-500" }),
305
+ /* @__PURE__ */ jsx5("span", { className: "truncate max-w-[140px]", children: current ? current.name : "Select Model" }),
306
+ /* @__PURE__ */ jsx5(ChevronDown, { size: 13, className: "text-slate-400" })
307
+ ]
308
+ }
309
+ ),
310
+ isOpen && /* @__PURE__ */ jsx5("div", { className: "absolute z-50 mt-1 w-64 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 shadow-xl py-1 max-h-60 overflow-y-auto", children: models.map((m) => {
311
+ const Icon = getProviderIcon(m.providerId);
312
+ const isSelected = m.id === current?.id;
313
+ return /* @__PURE__ */ jsxs5(
314
+ "button",
315
+ {
316
+ type: "button",
317
+ onClick: () => {
318
+ onSelectModel(m);
319
+ setIsOpen(false);
320
+ },
321
+ className: `w-full flex items-center justify-between px-3 py-2 text-left hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors ${isSelected ? "bg-indigo-50 dark:bg-indigo-950/40 text-indigo-600 dark:text-indigo-400" : ""}`,
322
+ children: [
323
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 truncate", children: [
324
+ /* @__PURE__ */ jsx5(Icon, { size: 12, className: "text-slate-400 shrink-0" }),
325
+ /* @__PURE__ */ jsx5("span", { className: "truncate font-semibold", children: m.name })
326
+ ] }),
327
+ isSelected && /* @__PURE__ */ jsx5(Check2, { size: 13, className: "text-indigo-600 shrink-0" })
328
+ ]
329
+ },
330
+ m.id
331
+ );
332
+ }) })
333
+ ] });
334
+ };
335
+
336
+ // src/components/ai/key-manager/SingleKeyCard.tsx
337
+ import { CheckCircle, AlertTriangle, XCircle, Trash2, RefreshCw as RefreshCw2 } from "lucide-react";
338
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
339
+ var SingleKeyCard = ({
340
+ id,
341
+ providerId,
342
+ label,
343
+ keyMasked,
344
+ status,
345
+ isActive,
346
+ lastLatencyMs = 0,
347
+ totalCalls = 0,
348
+ onVerify,
349
+ onDelete,
350
+ onToggleActive
351
+ }) => {
352
+ const Icon = getProviderIcon(providerId);
353
+ const isValid = status === "active" || status === "valid";
354
+ return /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between p-3 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono text-xs shadow-sm", children: [
355
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
356
+ /* @__PURE__ */ jsx6("div", { className: "w-8 h-8 rounded-lg bg-slate-100 dark:bg-slate-800 flex items-center justify-center border border-slate-300 dark:border-slate-700", children: /* @__PURE__ */ jsx6(Icon, { size: 16, className: "text-indigo-500" }) }),
357
+ /* @__PURE__ */ jsxs6("div", { children: [
358
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
359
+ /* @__PURE__ */ jsx6("span", { className: "font-bold text-slate-900 dark:text-slate-100", children: label }),
360
+ /* @__PURE__ */ jsx6("span", { className: "text-[10px] uppercase px-1.5 py-0.5 rounded border border-slate-400/40 bg-slate-100 dark:bg-slate-800 text-slate-500 font-semibold", children: providerId })
361
+ ] }),
362
+ /* @__PURE__ */ jsx6("div", { className: "text-[11px] text-slate-400 tracking-wider pt-0.5", children: keyMasked })
363
+ ] })
364
+ ] }),
365
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
366
+ /* @__PURE__ */ jsxs6("div", { className: "text-right text-[10px] text-slate-400", children: [
367
+ /* @__PURE__ */ jsxs6("div", { children: [
368
+ lastLatencyMs,
369
+ "ms"
370
+ ] }),
371
+ /* @__PURE__ */ jsxs6("div", { children: [
372
+ totalCalls,
373
+ " calls"
374
+ ] })
375
+ ] }),
376
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1", children: [
377
+ isValid ? /* @__PURE__ */ jsx6(CheckCircle, { size: 15, className: "text-emerald-500" }) : status === "rate-limited" ? /* @__PURE__ */ jsx6(AlertTriangle, { size: 15, className: "text-amber-500" }) : /* @__PURE__ */ jsx6(XCircle, { size: 15, className: "text-rose-500" }),
378
+ onVerify && /* @__PURE__ */ jsx6(
379
+ BaseButton,
380
+ {
381
+ size: "sm",
382
+ variant: "ghost",
383
+ onClick: () => onVerify(id),
384
+ title: "Verify Key",
385
+ className: "p-1 text-slate-500 hover:text-indigo-600",
386
+ children: /* @__PURE__ */ jsx6(RefreshCw2, { size: 13 })
387
+ }
388
+ ),
389
+ onDelete && /* @__PURE__ */ jsx6(
390
+ BaseButton,
391
+ {
392
+ size: "sm",
393
+ variant: "ghost",
394
+ onClick: () => onDelete(id),
395
+ title: "Delete Key",
396
+ className: "p-1 text-slate-500 hover:text-rose-600",
397
+ children: /* @__PURE__ */ jsx6(Trash2, { size: 13 })
398
+ }
399
+ )
400
+ ] })
401
+ ] })
402
+ ] });
403
+ };
404
+
405
+ // src/components/ai/key-manager/SingleKeyForm.tsx
406
+ import { useState as useState2 } from "react";
407
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
408
+ var SingleKeyForm = ({
409
+ providers,
410
+ onSubmit,
411
+ onCancel,
412
+ isLoading = false
413
+ }) => {
414
+ const [providerId, setProviderId] = useState2(providers[0] || "google");
415
+ const [label, setLabel] = useState2("");
416
+ const [key, setKey] = useState2("");
417
+ const handleSubmit = (e) => {
418
+ e.preventDefault();
419
+ if (!key.trim()) return;
420
+ onSubmit({
421
+ providerId,
422
+ label: label.trim() || `${providerId.toUpperCase()} Key`,
423
+ key: key.trim()
424
+ });
425
+ setKey("");
426
+ setLabel("");
427
+ };
428
+ return /* @__PURE__ */ jsxs7("form", { onSubmit: handleSubmit, className: "p-4 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono text-xs space-y-3", children: [
429
+ /* @__PURE__ */ jsx7("div", { className: "font-bold text-sm text-slate-900 dark:text-slate-100", children: "Add API Key" }),
430
+ /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-3", children: [
431
+ /* @__PURE__ */ jsxs7("div", { children: [
432
+ /* @__PURE__ */ jsx7("label", { className: "block text-[11px] text-slate-500 mb-1", children: "Provider" }),
433
+ /* @__PURE__ */ jsx7(
434
+ BaseSelect,
435
+ {
436
+ value: providerId,
437
+ onChange: (e) => setProviderId(e.target.value),
438
+ options: providers.map((p) => ({ label: p.toUpperCase(), value: p }))
439
+ }
440
+ )
441
+ ] }),
442
+ /* @__PURE__ */ jsxs7("div", { children: [
443
+ /* @__PURE__ */ jsx7("label", { className: "block text-[11px] text-slate-500 mb-1", children: "Label" }),
444
+ /* @__PURE__ */ jsx7(
445
+ BaseInput,
446
+ {
447
+ value: label,
448
+ onChange: (e) => setLabel(e.target.value),
449
+ placeholder: "e.g. Production Key"
450
+ }
451
+ )
452
+ ] })
453
+ ] }),
454
+ /* @__PURE__ */ jsxs7("div", { children: [
455
+ /* @__PURE__ */ jsx7("label", { className: "block text-[11px] text-slate-500 mb-1", children: "API Key / Token" }),
456
+ /* @__PURE__ */ jsx7(
457
+ BaseInput,
458
+ {
459
+ type: "password",
460
+ value: key,
461
+ onChange: (e) => setKey(e.target.value),
462
+ placeholder: "Paste provider key..."
463
+ }
464
+ )
465
+ ] }),
466
+ /* @__PURE__ */ jsxs7("div", { className: "flex justify-end gap-2 pt-1", children: [
467
+ onCancel && /* @__PURE__ */ jsx7(BaseButton, { type: "button", variant: "secondary", onClick: onCancel, children: "Cancel" }),
468
+ /* @__PURE__ */ jsx7(BaseButton, { type: "submit", variant: "accent", disabled: isLoading || !key.trim(), children: isLoading ? "Saving..." : "Add Key" })
469
+ ] })
470
+ ] });
471
+ };
472
+
473
+ // src/components/ai/key-manager/KeyProviderFilterBar.tsx
474
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
475
+ var KeyProviderFilterBar = ({
476
+ providers,
477
+ activeFilter,
478
+ onFilterChange,
479
+ counts = {}
480
+ }) => {
481
+ return /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-1.5 flex-wrap font-mono text-xs", children: [
482
+ /* @__PURE__ */ jsxs8(
483
+ "button",
484
+ {
485
+ type: "button",
486
+ onClick: () => onFilterChange(void 0),
487
+ className: `px-3 py-1 rounded-lg border font-bold transition-all ${!activeFilter ? "bg-indigo-600 text-white border-indigo-700" : "bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 border-slate-300 dark:border-slate-700"}`,
488
+ children: [
489
+ "ALL (",
490
+ Object.values(counts).reduce((a, b) => a + b, 0),
491
+ ")"
492
+ ]
493
+ }
494
+ ),
495
+ providers.map((p) => {
496
+ const Icon = getProviderIcon(p);
497
+ const isSelected = activeFilter?.toLowerCase() === p.toLowerCase();
498
+ const count = counts[p] ?? 0;
499
+ return /* @__PURE__ */ jsxs8(
500
+ "button",
501
+ {
502
+ type: "button",
503
+ onClick: () => onFilterChange(p),
504
+ className: `flex items-center gap-1.5 px-2.5 py-1 rounded-lg border font-bold transition-all ${isSelected ? "bg-indigo-600 text-white border-indigo-700" : "bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 border-slate-300 dark:border-slate-700"}`,
505
+ children: [
506
+ /* @__PURE__ */ jsx8(Icon, { size: 12 }),
507
+ /* @__PURE__ */ jsx8("span", { className: "uppercase", children: p }),
508
+ count > 0 && /* @__PURE__ */ jsxs8("span", { className: "text-[10px] opacity-75", children: [
509
+ "(",
510
+ count,
511
+ ")"
512
+ ] })
513
+ ]
514
+ },
515
+ p
516
+ );
517
+ })
518
+ ] });
519
+ };
520
+
521
+ // src/components/ai/key-manager/KeyModelVerificationSuite.tsx
522
+ import { useState as useState3 } from "react";
523
+ import { ShieldCheck, RefreshCw as RefreshCw3 } from "lucide-react";
524
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
525
+ var KeyModelVerificationSuite = ({
526
+ onVerifyAll,
527
+ totalKeys,
528
+ validKeys
529
+ }) => {
530
+ const [isRunning, setIsRunning] = useState3(false);
531
+ const handleRun = async () => {
532
+ setIsRunning(true);
533
+ try {
534
+ await onVerifyAll();
535
+ } finally {
536
+ setIsRunning(false);
537
+ }
538
+ };
539
+ return /* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between p-3 rounded-xl border border-slate-300 dark:border-slate-700 bg-slate-50 dark:bg-slate-900/50 font-mono text-xs", children: [
540
+ /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3", children: [
541
+ /* @__PURE__ */ jsx9(ShieldCheck, { size: 18, className: "text-indigo-500" }),
542
+ /* @__PURE__ */ jsxs9("div", { children: [
543
+ /* @__PURE__ */ jsx9("div", { className: "font-bold text-slate-900 dark:text-slate-100", children: "Verification Engine" }),
544
+ /* @__PURE__ */ jsxs9("div", { className: "text-[11px] text-slate-500", children: [
545
+ validKeys,
546
+ " of ",
547
+ totalKeys,
548
+ " keys verified active"
549
+ ] })
550
+ ] })
551
+ ] }),
552
+ /* @__PURE__ */ jsxs9(
553
+ BaseButton,
554
+ {
555
+ size: "sm",
556
+ variant: "secondary",
557
+ onClick: handleRun,
558
+ disabled: isRunning || totalKeys === 0,
559
+ className: "flex items-center gap-1.5",
560
+ children: [
561
+ /* @__PURE__ */ jsx9(RefreshCw3, { size: 12, className: isRunning ? "animate-spin" : "" }),
562
+ isRunning ? "Testing..." : "Verify All"
563
+ ]
564
+ }
565
+ )
566
+ ] });
567
+ };
568
+
569
+ // src/components/ai/key-manager/KeyListContainer.tsx
570
+ import { useState as useState4 } from "react";
571
+ import { Plus } from "lucide-react";
572
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
573
+ var KeyListContainer = ({
574
+ keys,
575
+ providers,
576
+ onAddKey,
577
+ onVerifyKey,
578
+ onDeleteKey,
579
+ onToggleActive
580
+ }) => {
581
+ const [filter, setFilter] = useState4();
582
+ const [showForm, setShowForm] = useState4(false);
583
+ const filteredKeys = filter ? keys.filter((k) => k.providerId.toLowerCase() === filter.toLowerCase()) : keys;
584
+ const counts = {};
585
+ for (const k of keys) {
586
+ counts[k.providerId] = (counts[k.providerId] || 0) + 1;
587
+ }
588
+ return /* @__PURE__ */ jsxs10("div", { className: "space-y-4 font-mono", children: [
589
+ /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between gap-3", children: [
590
+ /* @__PURE__ */ jsx10(
591
+ KeyProviderFilterBar,
592
+ {
593
+ providers,
594
+ activeFilter: filter,
595
+ onFilterChange: setFilter,
596
+ counts
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsxs10(
600
+ BaseButton,
601
+ {
602
+ size: "sm",
603
+ variant: "accent",
604
+ onClick: () => setShowForm(!showForm),
605
+ className: "flex items-center gap-1.5 shrink-0",
606
+ children: [
607
+ /* @__PURE__ */ jsx10(Plus, { size: 13 }),
608
+ showForm ? "Close Form" : "New Key"
609
+ ]
610
+ }
611
+ )
612
+ ] }),
613
+ showForm && /* @__PURE__ */ jsx10(
614
+ SingleKeyForm,
615
+ {
616
+ providers,
617
+ onSubmit: (data) => {
618
+ onAddKey(data);
619
+ setShowForm(false);
620
+ },
621
+ onCancel: () => setShowForm(false)
622
+ }
623
+ ),
624
+ /* @__PURE__ */ jsx10("div", { className: "space-y-2", children: filteredKeys.length === 0 ? /* @__PURE__ */ jsx10("div", { className: "p-8 text-center text-slate-400 border border-dashed border-slate-300 dark:border-slate-700 rounded-xl text-xs", children: "No API keys found for current filter. Add one to enable inference." }) : filteredKeys.map((k) => /* @__PURE__ */ jsx10(
625
+ SingleKeyCard,
626
+ {
627
+ ...k,
628
+ onVerify: onVerifyKey,
629
+ onDelete: onDeleteKey,
630
+ onToggleActive
631
+ },
632
+ k.id
633
+ )) })
634
+ ] });
635
+ };
636
+
637
+ // src/components/ai/key-manager/KeyBackupModal.tsx
638
+ import { useEffect, useState as useState7 } from "react";
639
+ import { Download as Download2, Upload as Upload2, FileText, X as X2 } from "lucide-react";
640
+
641
+ // src/components/ai/key-manager/KeyBackupExportTab.tsx
642
+ import { useState as useState5 } from "react";
643
+ import { Download, Copy, Check as Check3 } from "lucide-react";
644
+ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
645
+ var KeyBackupExportTab = ({ exportPayload, fileNamePrefix = "ai-keys-backup" }) => {
646
+ const [copied, setCopied] = useState5(false);
647
+ const jsonString = exportPayload ? JSON.stringify(exportPayload, null, 2) : "";
648
+ const handleDownload = () => {
649
+ if (!exportPayload) return;
650
+ const blob = new Blob([jsonString], { type: "application/json" });
651
+ const url = URL.createObjectURL(blob);
652
+ const anchor = document.createElement("a");
653
+ anchor.href = url;
654
+ anchor.download = `${fileNamePrefix}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.json`;
655
+ document.body.appendChild(anchor);
656
+ anchor.click();
657
+ anchor.remove();
658
+ URL.revokeObjectURL(url);
659
+ };
660
+ const handleCopy = async () => {
661
+ if (!jsonString) return;
662
+ await navigator.clipboard.writeText(jsonString);
663
+ setCopied(true);
664
+ window.setTimeout(() => setCopied(false), 2e3);
665
+ };
666
+ const metadata = exportPayload && typeof exportPayload === "object" ? exportPayload.exportMetadata : void 0;
667
+ return /* @__PURE__ */ jsxs11("div", { className: "space-y-3", children: [
668
+ /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center justify-between gap-2 p-2.5 rounded bg-slate-800/80 border border-slate-700", children: [
669
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-3", children: [
670
+ /* @__PURE__ */ jsx11("span", { className: "text-slate-200 font-bold", children: "EXPORT PAYLOAD" }),
671
+ /* @__PURE__ */ jsxs11("span", { className: "text-[10px] text-emerald-400", children: [
672
+ metadata?.totalKeys || 0,
673
+ " KEYS"
674
+ ] }),
675
+ /* @__PURE__ */ jsxs11("span", { className: "text-[10px] text-indigo-400", children: [
676
+ metadata?.totalEmailProfiles || 0,
677
+ " SECTIONS"
678
+ ] })
679
+ ] }),
680
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
681
+ /* @__PURE__ */ jsx11(BaseButton, { size: "sm", variant: "secondary", "aria-label": "Copy JSON payload", onClick: handleCopy, disabled: !jsonString, children: copied ? /* @__PURE__ */ jsx11(Check3, { size: 14 }) : /* @__PURE__ */ jsx11(Copy, { size: 14 }) }),
682
+ /* @__PURE__ */ jsx11(BaseButton, { size: "sm", variant: "success", "aria-label": "Export backup file", onClick: handleDownload, disabled: !jsonString, children: /* @__PURE__ */ jsx11(Download, { size: 14 }) })
683
+ ] })
684
+ ] }),
685
+ /* @__PURE__ */ jsx11("pre", { className: "p-3 bg-slate-950 rounded-lg border border-slate-800 text-slate-200 text-[11px] max-h-72 overflow-y-auto whitespace-pre-wrap select-all", children: jsonString || "Loading export payload..." })
686
+ ] });
687
+ };
688
+
689
+ // src/components/ai/key-manager/KeyBackupImportTab.tsx
690
+ import { useState as useState6 } from "react";
691
+ import { Upload, X, ShieldCheck as ShieldCheck2, AlertCircle as AlertCircle2, RefreshCw as RefreshCw4 } from "lucide-react";
692
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
693
+ var KeyBackupImportTab = ({ onImport, onClose, onRefreshKeys }) => {
694
+ const [text, setText] = useState6("");
695
+ const [status, setStatus] = useState6(null);
696
+ const [busy, setBusy] = useState6(false);
697
+ const handleFile = (event) => {
698
+ const file = event.target.files?.[0];
699
+ if (!file) return;
700
+ const reader = new FileReader();
701
+ reader.onload = () => {
702
+ setText(String(reader.result || ""));
703
+ setStatus(null);
704
+ };
705
+ reader.readAsText(file);
706
+ };
707
+ const handleImport = async () => {
708
+ if (!text.trim()) return;
709
+ setBusy(true);
710
+ setStatus(null);
711
+ try {
712
+ let payload;
713
+ try {
714
+ payload = JSON.parse(text);
715
+ } catch {
716
+ setStatus({ success: false, message: "Invalid JSON format." });
717
+ return;
718
+ }
719
+ const result = await onImport(payload);
720
+ setStatus({ success: result.success, message: result.message || result.error || (result.success ? "Import complete." : "Import failed.") });
721
+ if (result.success) onRefreshKeys?.();
722
+ } catch (error) {
723
+ setStatus({ success: false, message: error instanceof Error ? error.message : "Import failed." });
724
+ } finally {
725
+ setBusy(false);
726
+ }
727
+ };
728
+ return /* @__PURE__ */ jsxs12("div", { className: "space-y-3", children: [
729
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between p-2.5 rounded bg-slate-800/80 border border-slate-700", children: [
730
+ /* @__PURE__ */ jsx12("span", { className: "text-slate-200 font-bold", children: "IMPORT PAYLOAD" }),
731
+ /* @__PURE__ */ jsxs12("label", { className: "inline-flex items-center justify-center p-2 rounded bg-indigo-600 text-white font-bold cursor-pointer", children: [
732
+ /* @__PURE__ */ jsx12(Upload, { size: 14 }),
733
+ /* @__PURE__ */ jsx12(BaseInput, { type: "file", accept: ".json", onChange: handleFile, className: "hidden" })
734
+ ] })
735
+ ] }),
736
+ /* @__PURE__ */ jsx12(BaseTextarea, { value: text, onChange: (event) => setText(event.target.value), placeholder: "Paste backup JSON string here...", rows: 8, className: "w-full text-[11px]" }),
737
+ status && /* @__PURE__ */ jsxs12("div", { className: `p-2.5 rounded flex items-center gap-2 text-[11px] border ${status.success ? "bg-emerald-950/80 text-emerald-200 border-emerald-700" : "bg-rose-950/80 text-rose-200 border-rose-700"}`, children: [
738
+ status.success ? /* @__PURE__ */ jsx12(ShieldCheck2, { size: 14 }) : /* @__PURE__ */ jsx12(AlertCircle2, { size: 14 }),
739
+ /* @__PURE__ */ jsx12("span", { children: status.message })
740
+ ] }),
741
+ /* @__PURE__ */ jsxs12("div", { className: "flex justify-end gap-2 pt-1", children: [
742
+ /* @__PURE__ */ jsx12(BaseButton, { size: "sm", variant: "secondary", onClick: onClose, children: /* @__PURE__ */ jsx12(X, { size: 14 }) }),
743
+ /* @__PURE__ */ jsx12(BaseButton, { size: "sm", variant: "success", onClick: handleImport, disabled: !text.trim() || busy, children: busy ? /* @__PURE__ */ jsx12(RefreshCw4, { size: 14, className: "animate-spin" }) : /* @__PURE__ */ jsx12(ShieldCheck2, { size: 14 }) })
744
+ ] })
745
+ ] });
746
+ };
747
+
748
+ // src/components/ai/key-manager/KeyBackupModal.tsx
749
+ import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
750
+ var KeyBackupModal = ({
751
+ isOpen,
752
+ onClose,
753
+ loadExportPayload,
754
+ onImport,
755
+ onRefreshKeys,
756
+ title = "API KEYS BACKUP & RECOVERY"
757
+ }) => {
758
+ const [activeTab, setActiveTab] = useState7("export");
759
+ const [payload, setPayload] = useState7(null);
760
+ useEffect(() => {
761
+ if (isOpen) loadExportPayload().then(setPayload).catch(() => setPayload(null));
762
+ }, [isOpen, loadExportPayload]);
763
+ if (!isOpen) return null;
764
+ return /* @__PURE__ */ jsx13("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/70 backdrop-blur-sm", onWheel: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs13("div", { className: "w-full max-w-2xl bg-slate-900 border-2 border-slate-700 rounded-xl shadow-2xl font-mono text-xs overflow-hidden flex flex-col max-h-[90vh]", onWheel: (e) => e.stopPropagation(), children: [
765
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between p-3 border-b-2 border-slate-700 bg-slate-800 text-slate-100", children: [
766
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
767
+ /* @__PURE__ */ jsx13(FileText, { size: 16 }),
768
+ /* @__PURE__ */ jsx13("span", { className: "font-extrabold text-sm", children: title })
769
+ ] }),
770
+ /* @__PURE__ */ jsx13(BaseButton, { size: "sm", variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx13(X2, { size: 16 }) })
771
+ ] }),
772
+ /* @__PURE__ */ jsxs13("div", { className: "flex border-b-2 border-slate-700 bg-slate-950", children: [
773
+ /* @__PURE__ */ jsxs13(BaseButton, { size: "sm", variant: activeTab === "export" ? "accent" : "ghost", onClick: () => setActiveTab("export"), className: "flex-1 rounded-none", children: [
774
+ /* @__PURE__ */ jsx13(Download2, { size: 14 }),
775
+ " EXPORT"
776
+ ] }),
777
+ /* @__PURE__ */ jsxs13(BaseButton, { size: "sm", variant: activeTab === "import" ? "accent" : "ghost", onClick: () => setActiveTab("import"), className: "flex-1 rounded-none", children: [
778
+ /* @__PURE__ */ jsx13(Upload2, { size: 14 }),
779
+ " IMPORT"
780
+ ] })
781
+ ] }),
782
+ /* @__PURE__ */ jsx13("div", { className: "p-4 overflow-y-auto space-y-3 flex-1", children: activeTab === "export" ? /* @__PURE__ */ jsx13(KeyBackupExportTab, { exportPayload: payload }) : /* @__PURE__ */ jsx13(KeyBackupImportTab, { onImport, onClose, onRefreshKeys }) })
783
+ ] }) });
784
+ };
785
+
786
+ // src/components/ai/key-manager/EmailProfileCard.tsx
787
+ import { useState as useState9 } from "react";
788
+ import { Mail } from "lucide-react";
789
+
790
+ // src/components/ai/key-manager/EmailProviderRow.tsx
791
+ import { Plus as Plus2, ExternalLink } from "lucide-react";
792
+
793
+ // src/components/ai/key-manager/ExistingKeyControl.tsx
794
+ import { useState as useState8 } from "react";
795
+ import { CheckCircle2, AlertTriangle as AlertTriangle2, RefreshCw as RefreshCw5, Trash2 as Trash22, Edit2, Check as Check4, X as X3 } from "lucide-react";
796
+ import { Fragment, jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
797
+ var ExistingKeyControl = ({ providerKey, usageStats = [], onVerifyKey, onDeleteKey, onUpdateKeyLabel }) => {
798
+ const [editing, setEditing] = useState8(false);
799
+ const [label, setLabel] = useState8("");
800
+ const stats = usageStats.filter((item) => item.keyId === providerKey.id);
801
+ const day = stats.reduce((sum, item) => sum + item.dayCount, 0);
802
+ const week = stats.reduce((sum, item) => sum + item.weekCount, 0);
803
+ const month = stats.reduce((sum, item) => sum + item.monthCount, 0);
804
+ return /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between flex-1 gap-2", children: [
805
+ /* @__PURE__ */ jsxs14("div", { className: "flex flex-col min-w-0", children: [
806
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1.5 min-w-0", children: [
807
+ editing ? /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
808
+ /* @__PURE__ */ jsx14(BaseInput, { value: label, onChange: (e) => setLabel(e.target.value), className: "p-1 text-[10px] w-32", autoFocus: true }),
809
+ /* @__PURE__ */ jsx14(BaseButton, { size: "sm", variant: "success", onClick: () => {
810
+ if (label.trim()) {
811
+ onUpdateKeyLabel(providerKey.id, label.trim());
812
+ setEditing(false);
813
+ }
814
+ }, className: "p-0.5", children: /* @__PURE__ */ jsx14(Check4, { size: 10 }) }),
815
+ /* @__PURE__ */ jsx14(BaseButton, { size: "sm", variant: "danger", onClick: () => setEditing(false), className: "p-0.5", children: /* @__PURE__ */ jsx14(X3, { size: 10 }) })
816
+ ] }) : /* @__PURE__ */ jsxs14(Fragment, { children: [
817
+ /* @__PURE__ */ jsx14("span", { className: "text-[10px] text-slate-500 font-bold truncate", children: providerKey.key ? `${providerKey.key.slice(0, 10)}...` : "ENV" }),
818
+ /* @__PURE__ */ jsx14(BaseButton, { size: "sm", variant: "ghost", onClick: () => {
819
+ setEditing(true);
820
+ setLabel(providerKey.label);
821
+ }, className: "p-0.5", children: /* @__PURE__ */ jsx14(Edit2, { size: 10 }) })
822
+ ] }),
823
+ providerKey.status === "active" && /* @__PURE__ */ jsx14(CheckCircle2, { size: 13, className: "text-emerald-600" }),
824
+ providerKey.status === "invalid" && /* @__PURE__ */ jsx14(AlertTriangle2, { size: 13, className: "text-rose-600" }),
825
+ providerKey.status === "checking" && /* @__PURE__ */ jsx14("span", { className: "text-[9px] text-amber-500 animate-pulse", children: "Verifying..." })
826
+ ] }),
827
+ providerKey.lifespan && /* @__PURE__ */ jsx14("div", { className: "text-[9px] text-slate-500", children: providerKey.lifespan })
828
+ ] }),
829
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1 text-[9px] bg-slate-200/80 dark:bg-slate-900/80 px-1.5 py-0.5 rounded border border-slate-700/50", children: [
830
+ /* @__PURE__ */ jsxs14("span", { children: [
831
+ day,
832
+ "D"
833
+ ] }),
834
+ /* @__PURE__ */ jsxs14("span", { children: [
835
+ week,
836
+ "W"
837
+ ] }),
838
+ /* @__PURE__ */ jsxs14("span", { children: [
839
+ month,
840
+ "M"
841
+ ] })
842
+ ] }),
843
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1.5 shrink-0", children: [
844
+ /* @__PURE__ */ jsx14(BaseButton, { size: "sm", variant: "secondary", "aria-label": "Re-verify key", onClick: () => onVerifyKey(providerKey.id), children: /* @__PURE__ */ jsx14(RefreshCw5, { size: 11 }) }),
845
+ /* @__PURE__ */ jsx14(BaseButton, { size: "sm", variant: "danger", "aria-label": "Delete key", onClick: () => onDeleteKey(providerKey.id), children: /* @__PURE__ */ jsx14(Trash22, { size: 11 }) })
846
+ ] })
847
+ ] });
848
+ };
849
+
850
+ // src/components/ai/key-manager/EmailProviderRow.tsx
851
+ import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
852
+ var EmailProviderRow = ({
853
+ providerMeta,
854
+ providerKey,
855
+ usageStats,
856
+ isTargetedKey,
857
+ isTargetedProvider,
858
+ acquisitionLink,
859
+ inputValue,
860
+ onInputChange,
861
+ onSaveKey,
862
+ onVerifyKey,
863
+ onDeleteKey,
864
+ onUpdateKeyLabel
865
+ }) => {
866
+ const highlighted = isTargetedKey || isTargetedProvider;
867
+ return /* @__PURE__ */ jsxs15("div", { className: `flex flex-col sm:flex-row sm:items-center justify-between p-2 rounded-md border gap-2 ${isTargetedKey ? "border-cyan-400 ring-2 ring-cyan-400" : isTargetedProvider ? "border-amber-500 ring-2 ring-amber-500" : "border-slate-700/60"}`, "data-highlighted": highlighted, children: [
868
+ /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2 shrink-0", children: /* @__PURE__ */ jsx15("span", { className: "font-bold text-[10px] w-20", children: providerMeta.name.split(" ")[0].toUpperCase() }) }),
869
+ providerKey ? /* @__PURE__ */ jsx15(ExistingKeyControl, { providerKey, usageStats, onVerifyKey, onDeleteKey, onUpdateKeyLabel }) : /* @__PURE__ */ jsxs15("div", { className: "flex items-center flex-1 gap-2", children: [
870
+ /* @__PURE__ */ jsx15(BaseInput, { type: "password", placeholder: `Paste ${providerMeta.name.split(" ")[0]} Key`, value: inputValue, onChange: (e) => onInputChange(e.target.value), className: "flex-1 text-[10px]" }),
871
+ /* @__PURE__ */ jsx15(BaseButton, { size: "sm", variant: "accent", onClick: onSaveKey, disabled: !inputValue.trim(), children: /* @__PURE__ */ jsx15(Plus2, { size: 12 }) }),
872
+ acquisitionLink && /* @__PURE__ */ jsx15("a", { href: acquisitionLink, target: "_blank", rel: "noreferrer", className: "p-1 rounded border border-slate-700", children: /* @__PURE__ */ jsx15(ExternalLink, { size: 12 }) })
873
+ ] })
874
+ ] });
875
+ };
876
+
877
+ // src/components/ai/key-manager/EmailProfileCard.tsx
878
+ import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
879
+ var EmailProfileCard = ({
880
+ email,
881
+ providers,
882
+ keys,
883
+ usageStats,
884
+ targetKeyId,
885
+ targetProviderId,
886
+ onAddKey,
887
+ onVerifyKey,
888
+ onDeleteKey,
889
+ onUpdateKeyLabel,
890
+ getAcquisitionLink
891
+ }) => {
892
+ const [inputs, setInputs] = useState9({});
893
+ return /* @__PURE__ */ jsxs16("div", { className: "p-4 rounded-xl border-2 border-slate-700 bg-slate-50/80 dark:bg-slate-900/80 font-mono text-xs space-y-3", children: [
894
+ /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2 pb-2 border-b border-slate-700/20", children: [
895
+ /* @__PURE__ */ jsx16(Mail, { size: 14 }),
896
+ /* @__PURE__ */ jsx16("span", { className: "font-bold text-sm", children: email })
897
+ ] }),
898
+ /* @__PURE__ */ jsx16("div", { className: "space-y-2", children: providers.map((provider) => {
899
+ const key = keys.find((entry) => entry.label === email && entry.providerId === provider.id);
900
+ return /* @__PURE__ */ jsx16(
901
+ EmailProviderRow,
902
+ {
903
+ email,
904
+ providerMeta: provider,
905
+ providerKey: key,
906
+ usageStats,
907
+ isTargetedKey: Boolean(targetKeyId && key?.id === targetKeyId),
908
+ isTargetedProvider: Boolean(!targetKeyId && targetProviderId && provider.id === targetProviderId && key),
909
+ acquisitionLink: getAcquisitionLink?.(provider.id),
910
+ inputValue: inputs[provider.id] || "",
911
+ onInputChange: (value) => setInputs((current) => ({ ...current, [provider.id]: value })),
912
+ onSaveKey: () => {
913
+ const value = inputs[provider.id]?.trim();
914
+ if (!value) return;
915
+ onAddKey({ providerId: provider.id, label: email, key: value });
916
+ setInputs((current) => ({ ...current, [provider.id]: "" }));
917
+ },
918
+ onVerifyKey,
919
+ onDeleteKey,
920
+ onUpdateKeyLabel
921
+ },
922
+ provider.id
923
+ );
924
+ }) })
925
+ ] });
926
+ };
927
+
928
+ // src/components/ai/key-manager/EmailProfileRegistrationForm.tsx
929
+ import { Plus as Plus3 } from "lucide-react";
930
+ import { jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
931
+ var EmailProfileRegistrationForm = ({
932
+ value,
933
+ onChange,
934
+ onSubmit,
935
+ placeholder = "Register Email Profile"
936
+ }) => /* @__PURE__ */ jsxs17("form", { onSubmit, className: "p-3 rounded-lg border-2 border-slate-700 bg-slate-200/40 dark:bg-slate-800/40 flex items-center gap-2 font-mono text-xs", children: [
937
+ /* @__PURE__ */ jsx17(BaseInput, { type: "email", placeholder, value, onChange: (e) => onChange(e.target.value), className: "flex-1" }),
938
+ /* @__PURE__ */ jsx17(BaseButton, { type: "submit", variant: "accent", disabled: !value.trim(), children: /* @__PURE__ */ jsx17(Plus3, { size: 14 }) })
939
+ ] });
940
+
941
+ // src/components/ai/chat/AgentExecutionCard.tsx
942
+ import { Terminal, CheckCircle2 as CheckCircle22, Clock, AlertCircle as AlertCircle3 } from "lucide-react";
943
+ import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
944
+ var AgentExecutionCard = ({
945
+ agentName,
946
+ status,
947
+ toolName,
948
+ durationMs,
949
+ outputPreview
950
+ }) => {
951
+ return /* @__PURE__ */ jsxs18("div", { className: "p-3 rounded-xl border border-slate-300 dark:border-slate-800 bg-slate-50 dark:bg-slate-900/40 font-mono text-xs space-y-2", children: [
952
+ /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-between", children: [
953
+ /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
954
+ /* @__PURE__ */ jsx18(Terminal, { size: 14, className: "text-indigo-500" }),
955
+ /* @__PURE__ */ jsx18("span", { className: "font-bold text-slate-800 dark:text-slate-200", children: agentName }),
956
+ toolName && /* @__PURE__ */ jsx18("span", { className: "text-[10px] px-1.5 py-0.5 rounded bg-indigo-50 dark:bg-indigo-950 text-indigo-600 dark:text-indigo-400 border border-indigo-200 dark:border-indigo-800", children: toolName })
957
+ ] }),
958
+ /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
959
+ durationMs !== void 0 && /* @__PURE__ */ jsxs18("span", { className: "flex items-center gap-1 text-[10px] text-slate-400", children: [
960
+ /* @__PURE__ */ jsx18(Clock, { size: 10 }),
961
+ durationMs,
962
+ "ms"
963
+ ] }),
964
+ status === "completed" && /* @__PURE__ */ jsx18(CheckCircle22, { size: 14, className: "text-emerald-500" }),
965
+ status === "failed" && /* @__PURE__ */ jsx18(AlertCircle3, { size: 14, className: "text-rose-500" }),
966
+ status === "running" && /* @__PURE__ */ jsx18("div", { className: "w-3 h-3 rounded-full border-2 border-indigo-500 border-t-transparent animate-spin" })
967
+ ] })
968
+ ] }),
969
+ outputPreview && /* @__PURE__ */ jsx18("pre", { className: "p-2 rounded bg-slate-900 text-slate-100 text-[10.5px] overflow-x-auto max-h-24", children: outputPreview })
970
+ ] });
971
+ };
972
+
973
+ // src/components/ai/chat/DirectChatHeader.tsx
974
+ import { Bot, RotateCcw } from "lucide-react";
975
+ import { jsx as jsx19, jsxs as jsxs19 } from "react/jsx-runtime";
976
+ var DirectChatHeader = ({
977
+ title = "AI Assistant",
978
+ modelName,
979
+ providerId,
980
+ onClearHistory,
981
+ actionsSlot
982
+ }) => {
983
+ return /* @__PURE__ */ jsxs19("div", { className: "flex items-center justify-between px-4 py-2.5 border-b border-slate-300 dark:border-slate-800 bg-white dark:bg-slate-900 font-mono text-xs", children: [
984
+ /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2.5", children: [
985
+ /* @__PURE__ */ jsx19("div", { className: "w-7 h-7 rounded-lg bg-indigo-50 dark:bg-indigo-950 flex items-center justify-center text-indigo-600 dark:text-indigo-400", children: /* @__PURE__ */ jsx19(Bot, { size: 16 }) }),
986
+ /* @__PURE__ */ jsxs19("div", { children: [
987
+ /* @__PURE__ */ jsx19("div", { className: "font-bold text-slate-900 dark:text-slate-100", children: title }),
988
+ modelName && /* @__PURE__ */ jsxs19("div", { className: "text-[10px] text-slate-400 flex items-center gap-1.5", children: [
989
+ /* @__PURE__ */ jsx19("span", { children: modelName }),
990
+ providerId && /* @__PURE__ */ jsxs19("span", { className: "uppercase font-semibold", children: [
991
+ "(",
992
+ providerId,
993
+ ")"
994
+ ] })
995
+ ] })
996
+ ] })
997
+ ] }),
998
+ /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
999
+ actionsSlot,
1000
+ onClearHistory && /* @__PURE__ */ jsx19(
1001
+ BaseButton,
1002
+ {
1003
+ size: "sm",
1004
+ variant: "ghost",
1005
+ onClick: onClearHistory,
1006
+ title: "Clear Chat History",
1007
+ className: "p-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",
1008
+ children: /* @__PURE__ */ jsx19(RotateCcw, { size: 13 })
1009
+ }
1010
+ )
1011
+ ] })
1012
+ ] });
1013
+ };
1014
+
1015
+ // src/components/ai/chat/DirectChatMessageList.tsx
1016
+ import { User, Bot as Bot2 } from "lucide-react";
1017
+ import { jsx as jsx20, jsxs as jsxs20 } from "react/jsx-runtime";
1018
+ var DirectChatMessageList = ({
1019
+ messages,
1020
+ isStreaming = false,
1021
+ className = ""
1022
+ }) => {
1023
+ return /* @__PURE__ */ jsxs20("div", { className: `space-y-4 p-4 overflow-y-auto font-mono text-xs ${className}`, children: [
1024
+ messages.length === 0 ? /* @__PURE__ */ jsxs20("div", { className: "h-full flex flex-col items-center justify-center text-center text-slate-400 p-8 space-y-2", children: [
1025
+ /* @__PURE__ */ jsx20(Bot2, { size: 28, className: "opacity-40" }),
1026
+ /* @__PURE__ */ jsx20("p", { children: "No messages yet. Send a prompt to start conversation." })
1027
+ ] }) : messages.map((m) => {
1028
+ const isUser = m.role === "user";
1029
+ return /* @__PURE__ */ jsxs20(
1030
+ "div",
1031
+ {
1032
+ className: `flex gap-3 ${isUser ? "justify-end" : "justify-start"}`,
1033
+ children: [
1034
+ !isUser && /* @__PURE__ */ jsx20("div", { className: "w-6 h-6 rounded-full bg-indigo-50 dark:bg-indigo-950 text-indigo-600 dark:text-indigo-400 flex items-center justify-center shrink-0 mt-0.5", children: /* @__PURE__ */ jsx20(Bot2, { size: 13 }) }),
1035
+ /* @__PURE__ */ jsxs20(
1036
+ "div",
1037
+ {
1038
+ className: `max-w-[80%] rounded-xl p-3 border leading-relaxed ${isUser ? "bg-indigo-600 text-white border-indigo-700" : "bg-white dark:bg-slate-900 text-slate-800 dark:text-slate-200 border-slate-300 dark:border-slate-800 shadow-sm"}`,
1039
+ children: [
1040
+ /* @__PURE__ */ jsx20("div", { className: "whitespace-pre-wrap", children: m.content }),
1041
+ m.timestamp && /* @__PURE__ */ jsx20(
1042
+ "div",
1043
+ {
1044
+ className: `text-[9px] mt-1 text-right ${isUser ? "text-indigo-200" : "text-slate-400"}`,
1045
+ children: m.timestamp
1046
+ }
1047
+ )
1048
+ ]
1049
+ }
1050
+ ),
1051
+ isUser && /* @__PURE__ */ jsx20("div", { className: "w-6 h-6 rounded-full bg-slate-200 dark:bg-slate-800 text-slate-700 dark:text-slate-300 flex items-center justify-center shrink-0 mt-0.5", children: /* @__PURE__ */ jsx20(User, { size: 13 }) })
1052
+ ]
1053
+ },
1054
+ m.id
1055
+ );
1056
+ }),
1057
+ isStreaming && /* @__PURE__ */ jsxs20("div", { className: "flex gap-3 justify-start items-center text-slate-400 text-[11px]", children: [
1058
+ /* @__PURE__ */ jsx20("div", { className: "w-2 h-2 rounded-full bg-indigo-500 animate-ping" }),
1059
+ /* @__PURE__ */ jsx20("span", { children: "Generating response..." })
1060
+ ] })
1061
+ ] });
1062
+ };
1063
+
1064
+ // src/components/ai/chat/DirectChatInput.tsx
1065
+ import { useState as useState10 } from "react";
1066
+ import { Send } from "lucide-react";
1067
+ import { jsx as jsx21, jsxs as jsxs21 } from "react/jsx-runtime";
1068
+ var DirectChatInput = ({
1069
+ onSendMessage,
1070
+ disabled = false,
1071
+ placeholder = "Type a prompt... (Shift+Enter for new line)",
1072
+ toolsSlot
1073
+ }) => {
1074
+ const [content, setContent] = useState10("");
1075
+ const handleKeyDown = (e) => {
1076
+ if (e.key === "Enter" && !e.shiftKey) {
1077
+ e.preventDefault();
1078
+ handleSend();
1079
+ }
1080
+ };
1081
+ const handleSend = () => {
1082
+ if (!content.trim() || disabled) return;
1083
+ onSendMessage(content.trim());
1084
+ setContent("");
1085
+ };
1086
+ return /* @__PURE__ */ jsxs21("div", { className: "p-3 border-t border-slate-300 dark:border-slate-800 bg-white dark:bg-slate-900 font-mono text-xs", children: [
1087
+ /* @__PURE__ */ jsx21("div", { className: "flex items-center justify-between pb-2", children: /* @__PURE__ */ jsx21("div", { className: "flex items-center gap-2", children: toolsSlot }) }),
1088
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-end gap-2", children: [
1089
+ /* @__PURE__ */ jsx21("div", { className: "flex-1", children: /* @__PURE__ */ jsx21(
1090
+ BaseTextarea,
1091
+ {
1092
+ value: content,
1093
+ onChange: (e) => setContent(e.target.value),
1094
+ onKeyDown: handleKeyDown,
1095
+ placeholder,
1096
+ disabled,
1097
+ rows: 2
1098
+ }
1099
+ ) }),
1100
+ /* @__PURE__ */ jsx21(
1101
+ BaseButton,
1102
+ {
1103
+ variant: "accent",
1104
+ onClick: handleSend,
1105
+ disabled: disabled || !content.trim(),
1106
+ className: "p-2.5 h-[42px] flex items-center justify-center shrink-0",
1107
+ children: /* @__PURE__ */ jsx21(Send, { size: 15 })
1108
+ }
1109
+ )
1110
+ ] })
1111
+ ] });
1112
+ };
1113
+
1114
+ // src/components/ai/execution-status/TimelineScrubber.tsx
1115
+ import { useEffect as useEffect2, useRef, useState as useState11 } from "react";
1116
+ import { Play as Play2, Pause, SkipBack, SkipForward, Clock as Clock2 } from "lucide-react";
1117
+ import { jsx as jsx22, jsxs as jsxs22 } from "react/jsx-runtime";
1118
+ var TimelineScrubber = ({
1119
+ logs,
1120
+ currentIndex,
1121
+ onIndexChange,
1122
+ isPlaying: controlledIsPlaying,
1123
+ onPlayPauseToggle
1124
+ }) => {
1125
+ const [internalPlaying, setInternalPlaying] = useState11(false);
1126
+ const isPlaying = controlledIsPlaying !== void 0 ? controlledIsPlaying : internalPlaying;
1127
+ const playIntervalRef = useRef(null);
1128
+ const togglePlay = (p) => {
1129
+ if (onPlayPauseToggle) onPlayPauseToggle(p);
1130
+ else setInternalPlaying(p);
1131
+ };
1132
+ useEffect2(() => {
1133
+ if (isPlaying) {
1134
+ playIntervalRef.current = setInterval(() => {
1135
+ if (logs.length > 0) {
1136
+ onIndexChange((currentIndex + 1) % logs.length);
1137
+ }
1138
+ }, 1500);
1139
+ } else if (playIntervalRef.current) {
1140
+ clearInterval(playIntervalRef.current);
1141
+ }
1142
+ return () => {
1143
+ if (playIntervalRef.current) clearInterval(playIntervalRef.current);
1144
+ };
1145
+ }, [isPlaying, currentIndex, logs.length, onIndexChange]);
1146
+ if (logs.length === 0) return null;
1147
+ const currentLog = logs[currentIndex];
1148
+ const progressPercent = currentIndex / Math.max(1, logs.length - 1) * 100;
1149
+ return /* @__PURE__ */ jsxs22("div", { className: "border border-slate-300 dark:border-slate-800 bg-white dark:bg-slate-900 rounded-xl p-3 font-mono text-xs space-y-3 shadow-sm", children: [
1150
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between pb-2 border-b border-slate-200 dark:border-slate-800", children: [
1151
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
1152
+ /* @__PURE__ */ jsx22(Clock2, { size: 14, className: "text-amber-500" }),
1153
+ /* @__PURE__ */ jsx22("span", { className: "font-bold text-slate-800 dark:text-slate-200", children: "TIMELINE RECONSTRUCTION" })
1154
+ ] }),
1155
+ currentLog && /* @__PURE__ */ jsxs22("span", { className: "text-[10px] text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-950/60 border border-amber-300 dark:border-amber-800 rounded px-1.5 py-0.5", children: [
1156
+ "Frame ",
1157
+ currentIndex + 1,
1158
+ "/",
1159
+ logs.length,
1160
+ " \u2014 ",
1161
+ currentLog.latencyMs ?? 0,
1162
+ "ms \u2014 ",
1163
+ currentLog.modelId || "N/A"
1164
+ ] })
1165
+ ] }),
1166
+ /* @__PURE__ */ jsxs22("div", { className: "relative h-4 flex items-center", children: [
1167
+ /* @__PURE__ */ jsx22("div", { className: "absolute inset-x-0 h-1.5 bg-slate-200 dark:bg-slate-800 rounded-full overflow-hidden", children: /* @__PURE__ */ jsx22(
1168
+ "div",
1169
+ {
1170
+ className: "h-full bg-amber-500 transition-all duration-150",
1171
+ style: { width: `${progressPercent}%` }
1172
+ }
1173
+ ) }),
1174
+ /* @__PURE__ */ jsx22(
1175
+ "input",
1176
+ {
1177
+ type: "range",
1178
+ min: "0",
1179
+ max: logs.length - 1,
1180
+ value: currentIndex,
1181
+ onChange: (e) => {
1182
+ onIndexChange(parseInt(e.target.value, 10));
1183
+ togglePlay(false);
1184
+ },
1185
+ className: "absolute inset-x-0 w-full h-full opacity-0 cursor-pointer z-10"
1186
+ }
1187
+ ),
1188
+ /* @__PURE__ */ jsx22(
1189
+ "div",
1190
+ {
1191
+ className: "absolute w-3 h-3 bg-amber-500 border border-white dark:border-slate-900 rounded-full pointer-events-none transition-all duration-150",
1192
+ style: { left: `calc(${progressPercent}% - 6px)` }
1193
+ }
1194
+ )
1195
+ ] }),
1196
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-center gap-3 pt-1", children: [
1197
+ /* @__PURE__ */ jsx22(
1198
+ BaseButton,
1199
+ {
1200
+ size: "sm",
1201
+ variant: "secondary",
1202
+ onClick: () => {
1203
+ onIndexChange(Math.max(0, currentIndex - 1));
1204
+ togglePlay(false);
1205
+ },
1206
+ disabled: currentIndex === 0,
1207
+ className: "p-1",
1208
+ children: /* @__PURE__ */ jsx22(SkipBack, { size: 13 })
1209
+ }
1210
+ ),
1211
+ /* @__PURE__ */ jsx22(
1212
+ BaseButton,
1213
+ {
1214
+ size: "sm",
1215
+ variant: "accent",
1216
+ onClick: () => togglePlay(!isPlaying),
1217
+ className: "p-1.5",
1218
+ children: isPlaying ? /* @__PURE__ */ jsx22(Pause, { size: 14 }) : /* @__PURE__ */ jsx22(Play2, { size: 14 })
1219
+ }
1220
+ ),
1221
+ /* @__PURE__ */ jsx22(
1222
+ BaseButton,
1223
+ {
1224
+ size: "sm",
1225
+ variant: "secondary",
1226
+ onClick: () => {
1227
+ onIndexChange(Math.min(logs.length - 1, currentIndex + 1));
1228
+ togglePlay(false);
1229
+ },
1230
+ disabled: currentIndex === logs.length - 1,
1231
+ className: "p-1",
1232
+ children: /* @__PURE__ */ jsx22(SkipForward, { size: 13 })
1233
+ }
1234
+ )
1235
+ ] })
1236
+ ] });
1237
+ };
1238
+
1239
+ export {
1240
+ getProviderIcon,
1241
+ ModelCardHeader,
1242
+ ModelCardFooter,
1243
+ ModelCard,
1244
+ AIProviderSelector,
1245
+ AIModelPicker,
1246
+ SingleKeyCard,
1247
+ SingleKeyForm,
1248
+ KeyProviderFilterBar,
1249
+ KeyModelVerificationSuite,
1250
+ KeyListContainer,
1251
+ KeyBackupExportTab,
1252
+ KeyBackupImportTab,
1253
+ KeyBackupModal,
1254
+ ExistingKeyControl,
1255
+ EmailProviderRow,
1256
+ EmailProfileCard,
1257
+ EmailProfileRegistrationForm,
1258
+ AgentExecutionCard,
1259
+ DirectChatHeader,
1260
+ DirectChatMessageList,
1261
+ DirectChatInput,
1262
+ TimelineScrubber
1263
+ };