@burdenoff/microfe-headshotmarketing 2026.1117.1 → 2026.1124.1

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 (35) hide show
  1. package/dist/generated/wspace-operations.d.ts +742 -0
  2. package/dist/generated/wspace-operations.js +752 -351
  3. package/dist/generated/wspace-operations.js.map +1 -1
  4. package/dist/generated/wspace-types.js +41 -33
  5. package/dist/generated/wspace-types.js.map +1 -1
  6. package/dist/headshotmarketing/pages/ads/AdBudgetAiPanel.d.ts +7 -0
  7. package/dist/headshotmarketing/pages/ads/AdBudgetAiPanel.js +133 -0
  8. package/dist/headshotmarketing/pages/ads/AdBudgetAiPanel.js.map +1 -0
  9. package/dist/headshotmarketing/pages/ads/AdCampaignDetailsPage.js +54 -49
  10. package/dist/headshotmarketing/pages/ads/AdCampaignDetailsPage.js.map +1 -1
  11. package/dist/headshotmarketing/pages/ai/AiDecisionCard.d.ts +31 -0
  12. package/dist/headshotmarketing/pages/ai/AiDecisionCard.js +150 -0
  13. package/dist/headshotmarketing/pages/ai/AiDecisionCard.js.map +1 -0
  14. package/dist/headshotmarketing/pages/ai/AiOperationsPage.d.ts +2 -18
  15. package/dist/headshotmarketing/pages/ai/AiOperationsPage.js +607 -8
  16. package/dist/headshotmarketing/pages/ai/AiOperationsPage.js.map +1 -1
  17. package/dist/headshotmarketing/pages/ai/aiDecisionHelpers.d.ts +53 -0
  18. package/dist/headshotmarketing/pages/ai/aiDecisionHelpers.js +50 -0
  19. package/dist/headshotmarketing/pages/ai/aiDecisionHelpers.js.map +1 -0
  20. package/dist/headshotmarketing/pages/campaigns/CampaignAiPanel.d.ts +7 -0
  21. package/dist/headshotmarketing/pages/campaigns/CampaignAiPanel.js +267 -0
  22. package/dist/headshotmarketing/pages/campaigns/CampaignAiPanel.js.map +1 -0
  23. package/dist/headshotmarketing/pages/campaigns/CampaignDetailsPage.js +258 -251
  24. package/dist/headshotmarketing/pages/campaigns/CampaignDetailsPage.js.map +1 -1
  25. package/dist/headshotmarketing/pages/crm/DealNextActionPanel.d.ts +14 -0
  26. package/dist/headshotmarketing/pages/crm/DealNextActionPanel.js +116 -0
  27. package/dist/headshotmarketing/pages/crm/DealNextActionPanel.js.map +1 -0
  28. package/dist/headshotmarketing/pages/crm/LeadAiDecisionPanel.d.ts +20 -0
  29. package/dist/headshotmarketing/pages/crm/LeadAiDecisionPanel.js +319 -0
  30. package/dist/headshotmarketing/pages/crm/LeadAiDecisionPanel.js.map +1 -0
  31. package/dist/headshotmarketing/pages/crm/LeadsPage.js +78 -41
  32. package/dist/headshotmarketing/pages/crm/LeadsPage.js.map +1 -1
  33. package/dist/headshotmarketing/pages/crm/PipelinePage.js +126 -102
  34. package/dist/headshotmarketing/pages/crm/PipelinePage.js.map +1 -1
  35. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"AiOperationsPage.js","names":["AiOperationsPage","AiPage"],"sources":["../../../../src/headshotmarketing/pages/ai/AiOperationsPage.tsx"],"sourcesContent":["/**\n * AI Operations Page\n *\n * Binds the shared fe-libs `AiPage` (BOFF-3601 read-only slice) into the\n * HeadshotMarketing route tree at `/headshotmarketing/ai/operations`. The\n * shared page renders the workspace model/provider catalog, recorded AI\n * usage by model / surface / trigger, and the AI credit balance — the\n * cost-per-workspace surface (readiness criterion 10.2) — and degrades to\n * an explicit unavailable state when the AI runtime or permissions are\n * missing (criterion 9.1).\n *\n * When BOFF-3601 ships the interactive AI-ops primitives (model picker,\n * agent-activity feed, decision cards), they bind here — this page is the\n * seam, not a bespoke picker/feed implementation.\n *\n * @module headshotmarketing/pages/ai\n */\n\nimport { AiPage } from \"@burdenoff/fe-libs/shared/pages\";\n\nexport function AiOperationsPage() {\n return (\n <AiPage productName=\"HeadshotMarketing\" productId=\"headshotmarketing\" />\n );\n}\n"],"mappings":";;;AAoBA,SAAgBA,IAAmB;CACjC,OACE,kBAACC,GAAD;EAAQ,aAAY;EAAoB,WAAU;CAAqB,CAAA;AAE3E"}
1
+ {"version":3,"file":"AiOperationsPage.js","names":["AGENT_RUNS_PAGE_SIZE","RUN_STATUS_MAP","HeadshotmarketingAiToolExecutionStatus","AiOperationsPage","useHeadshotMarketing","loopData","loopLoading","loopError","refetchLoop","useHeadshotmarketingAutonomousLoopStatusQuery","configureLoop","savingLoop","useHeadshotmarketingConfigureAutonomousLoopMutation","budgetDraft","setBudgetDraft","useState","loopFeedback","setLoopFeedback","loopActionError","setLoopActionError","loopStatus","effectiveBudgetInput","handleConfigureLoop","parsedBudget","dailyBudget","nextEnabled","err","audienceData","audienceLoading","audienceError","refetchAudiences","useHeadshotmarketingAudienceSuggestionsQuery","HeadshotmarketingAudienceSuggestionStatus","applyAudience","useHeadshotmarketingApplyAudienceSuggestionMutation","dismissAudience","useHeadshotmarketingDismissAudienceSuggestionMutation","busyDecisionId","setBusyDecisionId","decisionErrors","setDecisionErrors","dismissedBudgetIds","setDismissedBudgetIds","budgetRecData","budgetRecLoading","budgetRecError","refetchBudgetRecs","useHeadshotmarketingAdBudgetRecommendationsQuery","applyBudgetRec","useApplyHeadshotmarketingAdBudgetRecommendationMutation","proposedAudiences","pendingBudgetRecs","useMemo","rec","handleApplyAudience","suggestionId","next","prev","handleDismissAudience","handleApplyBudgetRec","id","statusFilter","setStatusFilter","triggerFilter","setTriggerFilter","runsFilter","filter","mappedStatus","runsData","runsLoading","runsError","refetchRuns","useHeadshotmarketingAgentRunsQuery","agentRuns","totalRuns","pageInfo","handleLoadMoreRuns","fetchMore","fetchMoreResult","pendingCount","AiPage","Bot","ShieldCheck","RefreshCw","AlertTriangle","s","cn","Sparkles","navigate","basePath","ChevronRight","chips","summarizeAudienceCriteria","suggestion","AiDecisionCard","formatNumber","chip","computeBudgetDelta","direction","deltaPct","formatCurrency","delta","Activity","i","run","formatAiProvenance","formatAiLatency","formatAiCost","formatDate"],"sources":["../../../../src/headshotmarketing/pages/ai/AiOperationsPage.tsx"],"sourcesContent":["/**\n * AI Operations Page\n *\n * Binds the shared fe-libs `AiPage` (BOFF-3601 — credits, 7-day usage summary,\n * spend breakdown by model/surface/trigger, shared invocation history,\n * workspace model route controls, and model/provider catalog) at\n * `/headshotmarketing/ai/operations`, and layers HeadshotMarketing's\n * domain-specific AI Operations command center underneath:\n *\n * 1. Autonomous marketing loop status & opt-in/budget control (propose-only)\n * 2. Pending AI decision cards (proposed audience segments & ad budget\n * reallocation recommendations) with explicit Apply / Dismiss confirmation\n * 3. Product-level AI runs audit (`headshotmarketingAgentRuns`) with status\n * and trigger filters plus cursor pagination\n *\n * Every section degrades gracefully when the AI runtime or permissions are\n * unavailable without affecting non-AI CRUD routes (criterion 9.1).\n *\n * @module headshotmarketing/pages/ai\n */\n\nimport { useMemo, useState, type FC } from \"react\";\nimport {\n Activity,\n AlertTriangle,\n Bot,\n ChevronRight,\n RefreshCw,\n ShieldCheck,\n Sparkles,\n} from \"lucide-react\";\nimport { AiPage } from \"@burdenoff/fe-libs/shared/pages\";\nimport {\n HeadshotmarketingAiToolExecutionStatus,\n HeadshotmarketingAudienceSuggestionStatus,\n} from \"../../../generated/wspace-types\";\nimport {\n useApplyHeadshotmarketingAdBudgetRecommendationMutation,\n useHeadshotmarketingAdBudgetRecommendationsQuery,\n useHeadshotmarketingAgentRunsQuery,\n useHeadshotmarketingApplyAudienceSuggestionMutation,\n useHeadshotmarketingAudienceSuggestionsQuery,\n useHeadshotmarketingAutonomousLoopStatusQuery,\n useHeadshotmarketingConfigureAutonomousLoopMutation,\n useHeadshotmarketingDismissAudienceSuggestionMutation,\n type HeadshotmarketingAdBudgetRecommendationsQuery,\n type HeadshotmarketingAgentRunsQuery,\n type HeadshotmarketingAudienceSuggestionsQuery,\n type HeadshotmarketingAutonomousLoopStatusQuery,\n} from \"../../../generated/wspace-operations\";\nimport { useHeadshotMarketing } from \"../../context/HeadshotMarketingContext\";\nimport {\n cn,\n formatCurrency,\n formatDate,\n formatNumber,\n} from \"../../utils/helpers\";\nimport { AiDecisionCard } from \"./AiDecisionCard\";\nimport {\n computeBudgetDelta,\n formatAiCost,\n formatAiLatency,\n formatAiProvenance,\n summarizeAudienceCriteria,\n} from \"./aiDecisionHelpers\";\n\nconst AGENT_RUNS_PAGE_SIZE = 15;\n\nconst RUN_STATUS_MAP: Record<string, HeadshotmarketingAiToolExecutionStatus> = {\n [HeadshotmarketingAiToolExecutionStatus.Completed]:\n HeadshotmarketingAiToolExecutionStatus.Completed,\n [HeadshotmarketingAiToolExecutionStatus.Failed]:\n HeadshotmarketingAiToolExecutionStatus.Failed,\n [HeadshotmarketingAiToolExecutionStatus.Running]:\n HeadshotmarketingAiToolExecutionStatus.Running,\n};\n\ntype LoopStatusItem =\n HeadshotmarketingAutonomousLoopStatusQuery[\"headshotmarketingAutonomousLoopStatus\"];\ntype AudienceSuggestionItem =\n HeadshotmarketingAudienceSuggestionsQuery[\"headshotmarketingAudienceSuggestions\"][\"items\"][number];\ntype AdBudgetRecItem =\n HeadshotmarketingAdBudgetRecommendationsQuery[\"headshotmarketingAdBudgetRecommendations\"][\"items\"][number];\ntype AgentRunItem =\n HeadshotmarketingAgentRunsQuery[\"headshotmarketingAgentRuns\"][\"items\"][number];\n\nexport const AiOperationsPage: FC = () => {\n const { navigate, basePath } = useHeadshotMarketing();\n\n // ---- Autonomous marketing loop state ------------------------------------\n const {\n data: loopData,\n loading: loopLoading,\n error: loopError,\n refetch: refetchLoop,\n } = useHeadshotmarketingAutonomousLoopStatusQuery({\n fetchPolicy: \"network-only\",\n });\n const [configureLoop, { loading: savingLoop }] =\n useHeadshotmarketingConfigureAutonomousLoopMutation();\n const [budgetDraft, setBudgetDraft] = useState<string>(\"\");\n const [loopFeedback, setLoopFeedback] = useState<string | null>(null);\n const [loopActionError, setLoopActionError] = useState<string | null>(null);\n\n const loopStatus: LoopStatusItem | null =\n loopData?.headshotmarketingAutonomousLoopStatus ?? null;\n const effectiveBudgetInput =\n budgetDraft !== \"\" ? budgetDraft : String(loopStatus?.dailyBudget ?? 25);\n\n const handleConfigureLoop = async (nextEnabled: boolean): Promise<void> => {\n setLoopFeedback(null);\n setLoopActionError(null);\n const parsedBudget = Number(effectiveBudgetInput);\n const dailyBudget =\n Number.isFinite(parsedBudget) && parsedBudget >= 1 && parsedBudget <= 500\n ? Math.round(parsedBudget)\n : undefined;\n try {\n await configureLoop({\n variables: {\n input: {\n enabled: nextEnabled,\n dailyBudget,\n },\n },\n });\n await refetchLoop();\n setLoopFeedback(\n nextEnabled\n ? \"Autonomous loop enabled (propose-only).\"\n : \"Autonomous loop paused.\",\n );\n } catch (err) {\n setLoopActionError(\n err instanceof Error\n ? err.message\n : \"Could not update autonomous loop settings.\",\n );\n }\n };\n\n // ---- Pending AI decisions: Audience suggestions -------------------------\n const {\n data: audienceData,\n loading: audienceLoading,\n error: audienceError,\n refetch: refetchAudiences,\n } = useHeadshotmarketingAudienceSuggestionsQuery({\n variables: {\n filter: { status: HeadshotmarketingAudienceSuggestionStatus.Proposed },\n pagination: { limit: 10, offset: 0 },\n },\n fetchPolicy: \"network-only\",\n });\n const [applyAudience] = useHeadshotmarketingApplyAudienceSuggestionMutation();\n const [dismissAudience] =\n useHeadshotmarketingDismissAudienceSuggestionMutation();\n const [busyDecisionId, setBusyDecisionId] = useState<string | null>(null);\n const [decisionErrors, setDecisionErrors] = useState<Record<string, string>>(\n {},\n );\n const [dismissedBudgetIds, setDismissedBudgetIds] = useState<Set<string>>(\n () => new Set(),\n );\n\n // ---- Pending AI decisions: Ad budget recommendations --------------------\n const {\n data: budgetRecData,\n loading: budgetRecLoading,\n error: budgetRecError,\n refetch: refetchBudgetRecs,\n } = useHeadshotmarketingAdBudgetRecommendationsQuery({\n variables: { pagination: { limit: 10, offset: 0 } },\n fetchPolicy: \"network-only\",\n });\n const [applyBudgetRec] =\n useApplyHeadshotmarketingAdBudgetRecommendationMutation();\n\n const proposedAudiences: AudienceSuggestionItem[] =\n audienceData?.headshotmarketingAudienceSuggestions.items ?? [];\n\n const pendingBudgetRecs = useMemo<AdBudgetRecItem[]>(\n () =>\n (\n budgetRecData?.headshotmarketingAdBudgetRecommendations.items ?? []\n ).filter(\n (rec: AdBudgetRecItem) =>\n !rec.appliedAt && !dismissedBudgetIds.has(rec.id),\n ),\n [budgetRecData, dismissedBudgetIds],\n );\n\n const handleApplyAudience = async (suggestionId: string): Promise<void> => {\n setBusyDecisionId(suggestionId);\n setDecisionErrors((prev) => {\n const next = { ...prev };\n delete next[suggestionId];\n return next;\n });\n try {\n await applyAudience({\n variables: { input: { suggestionId, confirm: true } },\n });\n await refetchAudiences();\n } catch (err) {\n setDecisionErrors((prev) => ({\n ...prev,\n [suggestionId]:\n err instanceof Error\n ? err.message\n : \"Failed to apply audience suggestion.\",\n }));\n } finally {\n setBusyDecisionId(null);\n }\n };\n\n const handleDismissAudience = async (suggestionId: string): Promise<void> => {\n setBusyDecisionId(suggestionId);\n setDecisionErrors((prev) => {\n const next = { ...prev };\n delete next[suggestionId];\n return next;\n });\n try {\n await dismissAudience({ variables: { id: suggestionId } });\n await refetchAudiences();\n } catch (err) {\n setDecisionErrors((prev) => ({\n ...prev,\n [suggestionId]:\n err instanceof Error\n ? err.message\n : \"Failed to dismiss audience suggestion.\",\n }));\n } finally {\n setBusyDecisionId(null);\n }\n };\n\n const handleApplyBudgetRec = async (id: string): Promise<void> => {\n setBusyDecisionId(id);\n setDecisionErrors((prev) => {\n const next = { ...prev };\n delete next[id];\n return next;\n });\n try {\n await applyBudgetRec({ variables: { id } });\n await refetchBudgetRecs();\n } catch (err) {\n setDecisionErrors((prev) => ({\n ...prev,\n [id]:\n err instanceof Error\n ? err.message\n : \"Failed to apply budget recommendation.\",\n }));\n } finally {\n setBusyDecisionId(null);\n }\n };\n\n // ---- Product AI runs ledger (`headshotmarketingAgentRuns`) --------------\n const [statusFilter, setStatusFilter] = useState<string>(\"all\");\n const [triggerFilter, setTriggerFilter] = useState<string>(\"all\");\n\n const runsFilter = useMemo(() => {\n const filter: {\n status?: HeadshotmarketingAiToolExecutionStatus;\n trigger?: string;\n } = {};\n const mappedStatus = RUN_STATUS_MAP[statusFilter];\n if (mappedStatus) {\n filter.status = mappedStatus;\n }\n if (triggerFilter !== \"all\") {\n filter.trigger = triggerFilter;\n }\n return Object.keys(filter).length > 0 ? filter : undefined;\n }, [statusFilter, triggerFilter]);\n\n const {\n data: runsData,\n loading: runsLoading,\n error: runsError,\n fetchMore,\n refetch: refetchRuns,\n } = useHeadshotmarketingAgentRunsQuery({\n variables: {\n filter: runsFilter,\n page: { first: AGENT_RUNS_PAGE_SIZE },\n },\n fetchPolicy: \"network-only\",\n });\n\n const agentRuns: AgentRunItem[] =\n runsData?.headshotmarketingAgentRuns.items ?? [];\n const totalRuns = runsData?.headshotmarketingAgentRuns.totalCount ?? 0;\n const pageInfo = runsData?.headshotmarketingAgentRuns.pageInfo;\n\n const handleLoadMoreRuns = async (): Promise<void> => {\n if (!pageInfo?.hasNextPage || !pageInfo.endCursor) return;\n await fetchMore({\n variables: {\n filter: runsFilter,\n page: { first: AGENT_RUNS_PAGE_SIZE, after: pageInfo.endCursor },\n },\n updateQuery: (prev, { fetchMoreResult }) => {\n if (!fetchMoreResult) return prev;\n return {\n headshotmarketingAgentRuns: {\n ...fetchMoreResult.headshotmarketingAgentRuns,\n items: [\n ...prev.headshotmarketingAgentRuns.items,\n ...fetchMoreResult.headshotmarketingAgentRuns.items,\n ],\n },\n };\n },\n });\n };\n\n const pendingCount = proposedAudiences.length + pendingBudgetRecs.length;\n\n return (\n <div className=\"space-y-8 pb-10\">\n {/* Shared platform AI Operations surface (BOFF-3601):\n credits, 7-day summary, spend breakdown, shared invocation history,\n workspace model route picker, and model/provider catalog. */}\n <AiPage\n productName=\"HeadshotMarketing\"\n productId=\"headshotmarketing\"\n enableModelRoutes\n />\n\n {/* HeadshotMarketing product AI Operations command center */}\n <div className=\"mx-auto w-full max-w-6xl space-y-6 px-4 sm:px-6\">\n {/* 1. Autonomous Marketing Loop (propose-only) */}\n <section\n aria-labelledby=\"hsm-autonomous-loop-heading\"\n className=\"rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-4\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <Bot\n className=\"h-4 w-4 text-action-primary-bg\"\n aria-hidden=\"true\"\n />\n <h2\n id=\"hsm-autonomous-loop-heading\"\n className=\"text-base font-semibold text-text-primary\"\n >\n Autonomous Marketing Loop\n </h2>\n <span className=\"inline-flex items-center gap-1 rounded-full bg-status-info-bg px-2 py-0.5 text-[11px] font-semibold text-status-info-text\">\n <ShieldCheck className=\"h-3 w-3\" aria-hidden=\"true\" />\n Propose-only\n </span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Scheduled lead scoring, budget optimization, and anomaly\n detection run via FluidGrids and queue proposals for explicit\n human review.\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => void refetchLoop()}\n className=\"inline-flex items-center gap-1.5 rounded-md border border-border-seam bg-gloss-card px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <RefreshCw className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n Refresh\n </button>\n </div>\n\n {loopError && !loopStatus ? (\n <div\n role=\"status\"\n className=\"flex items-center gap-2 rounded-md border border-border-subtle bg-bg-sunken/50 px-3 py-2.5 text-xs text-text-secondary\"\n >\n <AlertTriangle className=\"h-4 w-4 shrink-0 text-status-warning-text\" />\n <span>\n Autonomous loop status is currently unavailable. All manual\n marketing workflows continue operating normally.\n </span>\n </div>\n ) : loopLoading && !loopStatus ? (\n <div className=\"h-16 animate-pulse rounded-md bg-bg-sunken/50\" />\n ) : loopStatus ? (\n <div className=\"space-y-4\">\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/40 p-3\">\n <p className=\"text-xs text-text-secondary\">\n Workspace Status\n </p>\n <p className=\"mt-1 text-sm font-semibold text-text-primary\">\n {loopStatus.enabled ? \"Enabled (Propose-only)\" : \"Paused\"}\n </p>\n {!loopStatus.flagEnabled && (\n <p className=\"mt-0.5 text-[11px] text-status-warning-text\">\n Workspace feature flag is off; scheduled runs will no-op.\n </p>\n )}\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/40 p-3\">\n <p className=\"text-xs text-text-secondary\">\n Daily Decision Budget\n </p>\n <p className=\"mt-1 text-sm font-semibold tabular-nums text-text-primary\">\n {loopStatus.decisionsUsedToday} / {loopStatus.dailyBudget}{\" \"}\n used today\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/40 p-3\">\n <p className=\"text-xs text-text-secondary\">\n Scheduled Cadences\n </p>\n <p className=\"mt-1 text-sm font-semibold tabular-nums text-text-primary\">\n {loopStatus.schedules.filter((s) => s.enabled).length} of{\" \"}\n {loopStatus.schedules.length} active\n </p>\n </div>\n </div>\n\n <div className=\"flex flex-wrap items-end gap-3 border-t border-border-subtle pt-3\">\n <div>\n <label\n htmlFor=\"hsm-loop-daily-budget\"\n className=\"block text-xs font-medium text-text-secondary\"\n >\n Daily decision cap (1–500)\n </label>\n <input\n id=\"hsm-loop-daily-budget\"\n type=\"number\"\n min={1}\n max={500}\n value={effectiveBudgetInput}\n onChange={(e) => setBudgetDraft(e.target.value)}\n className=\"mt-1 w-28 rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <button\n type=\"button\"\n disabled={savingLoop}\n onClick={() => void handleConfigureLoop(!loopStatus.enabled)}\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium disabled:opacity-60\",\n loopStatus.enabled\n ? \"border border-border-seam bg-gloss-card text-text-primary hover:bg-bg-sunken\"\n : \"bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg/90\",\n )}\n >\n {savingLoop\n ? \"Saving...\"\n : loopStatus.enabled\n ? \"Pause autonomous loop\"\n : \"Enable autonomous loop\"}\n </button>\n {loopStatus.enabled && (\n <button\n type=\"button\"\n disabled={savingLoop}\n onClick={() => void handleConfigureLoop(true)}\n className=\"inline-flex items-center gap-1.5 rounded-md border border-border-seam bg-gloss-card px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-60\"\n >\n Update cap\n </button>\n )}\n </div>\n\n {loopFeedback && (\n <p role=\"status\" className=\"text-xs text-status-success-text\">\n {loopFeedback}\n </p>\n )}\n {loopActionError && (\n <p role=\"alert\" className=\"text-xs text-status-error-text\">\n {loopActionError}\n </p>\n )}\n </div>\n ) : null}\n </section>\n\n {/* 2. Pending AI Decision Cards (Human-in-the-loop review queue) */}\n <section\n aria-labelledby=\"hsm-pending-decisions-heading\"\n className=\"rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-4\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <Sparkles\n className=\"h-4 w-4 text-action-primary-bg\"\n aria-hidden=\"true\"\n />\n <h2\n id=\"hsm-pending-decisions-heading\"\n className=\"text-base font-semibold text-text-primary\"\n >\n Pending AI Decisions\n </h2>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium tabular-nums text-text-secondary\">\n {pendingCount}\n </span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Every proposed audience segment and budget shift stays pending\n until you explicitly apply or dismiss it.\n </p>\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => navigate(basePath + \"/crm/leads\")}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-subtle px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n Score Leads\n <ChevronRight className=\"h-3.5 w-3.5\" />\n </button>\n <button\n type=\"button\"\n onClick={() => navigate(basePath + \"/crm/pipeline\")}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-subtle px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n Deal Next Actions\n <ChevronRight className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n </div>\n\n {(audienceError || budgetRecError) && pendingCount === 0 && (\n <div\n role=\"status\"\n className=\"flex items-center gap-2 rounded-md border border-border-subtle bg-bg-sunken/50 px-3 py-2.5 text-xs text-text-secondary\"\n >\n <AlertTriangle className=\"h-4 w-4 shrink-0 text-status-warning-text\" />\n <span>\n Pending AI decisions are temporarily unavailable. Non-AI\n campaign and CRM controls remain available.\n </span>\n </div>\n )}\n\n {audienceLoading && budgetRecLoading && pendingCount === 0 ? (\n <div className=\"h-24 animate-pulse rounded-md bg-bg-sunken/50\" />\n ) : pendingCount === 0 && !audienceError && !budgetRecError ? (\n <p className=\"rounded-md border border-dashed border-border-subtle py-6 text-center text-xs text-text-secondary\">\n No pending AI proposals right now. Generate audience suggestions\n on a campaign, budget proposals on an ad campaign, or score leads\n from CRM.\n </p>\n ) : (\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-2\">\n {proposedAudiences.map((suggestion) => {\n const chips = summarizeAudienceCriteria(suggestion.criteria);\n return (\n <AiDecisionCard\n key={suggestion.id}\n testId={`decision-card-audience-${suggestion.id}`}\n title={suggestion.name}\n subtitle={`Audience proposal · ${formatNumber(suggestion.previewCount)} matching contacts`}\n badge=\"Audience segment\"\n badgeTone=\"info\"\n rationale={suggestion.rationale}\n provider={suggestion.provider}\n model={suggestion.model}\n source={suggestion.source}\n applyLabel=\"Confirm & create audience\"\n dismissLabel=\"Dismiss\"\n busy={busyDecisionId === suggestion.id}\n error={decisionErrors[suggestion.id] ?? null}\n onApply={() => void handleApplyAudience(suggestion.id)}\n onDismiss={() => void handleDismissAudience(suggestion.id)}\n >\n {chips.length > 0 && (\n <div className=\"flex flex-wrap gap-1.5\">\n {chips.map((chip) => (\n <span\n key={chip}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-[11px] text-text-secondary\"\n >\n {chip}\n </span>\n ))}\n </div>\n )}\n </AiDecisionCard>\n );\n })}\n\n {pendingBudgetRecs.map((rec) => {\n const { delta, deltaPct, direction } = computeBudgetDelta(\n rec.currentBudget,\n rec.recommendedBudget,\n );\n return (\n <AiDecisionCard\n key={rec.id}\n testId={`decision-card-budget-${rec.id}`}\n title=\"Ad budget reallocation proposal\"\n subtitle={`Ad campaign ${rec.adCampaignId}`}\n badge={\n direction === \"increase\"\n ? `+${deltaPct}%`\n : direction === \"decrease\"\n ? `${deltaPct}%`\n : \"Hold\"\n }\n badgeTone={\n direction === \"increase\"\n ? \"success\"\n : direction === \"decrease\"\n ? \"warning\"\n : \"info\"\n }\n confidence={rec.confidence}\n rationale={rec.rationale}\n source={rec.source}\n metrics={\n <div className=\"grid grid-cols-3 gap-2 rounded-md border border-border-subtle bg-bg-sunken/40 p-2.5 text-xs\">\n <div>\n <p className=\"text-text-secondary\">Current</p>\n <p className=\"font-semibold tabular-nums text-text-primary\">\n {formatCurrency(rec.currentBudget)}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">Proposed</p>\n <p className=\"font-semibold tabular-nums text-text-primary\">\n {formatCurrency(rec.recommendedBudget)}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">Change</p>\n <p className=\"font-semibold tabular-nums text-text-primary\">\n {delta >= 0 ? \"+\" : \"\"}\n {formatCurrency(delta)}\n </p>\n </div>\n </div>\n }\n applyLabel=\"Apply budget change\"\n dismissLabel=\"Dismiss\"\n busy={busyDecisionId === rec.id}\n error={decisionErrors[rec.id] ?? null}\n onApply={() => void handleApplyBudgetRec(rec.id)}\n onDismiss={() =>\n setDismissedBudgetIds((prev) => new Set(prev).add(rec.id))\n }\n />\n );\n })}\n </div>\n )}\n </section>\n\n {/* 3. Workspace AI Runs Audit (`headshotmarketingAgentRuns`) */}\n <section\n aria-labelledby=\"hsm-agent-runs-heading\"\n className=\"rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-4\"\n >\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div className=\"space-y-0.5\">\n <div className=\"flex items-center gap-2\">\n <Activity\n className=\"h-4 w-4 text-action-primary-bg\"\n aria-hidden=\"true\"\n />\n <h2\n id=\"hsm-agent-runs-heading\"\n className=\"text-base font-semibold text-text-primary\"\n >\n HeadshotMarketing AI Run Activity\n </h2>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium tabular-nums text-text-secondary\">\n {formatNumber(totalRuns)}\n </span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Product-level audit feed of lead scoring, audience segmentation,\n budget optimization, content tools, and agent runs reconciled to\n the shared AI ledger.\n </p>\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n <select\n aria-label=\"Filter runs by status\"\n value={statusFilter}\n onChange={(e) => setStatusFilter(e.target.value)}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs text-text-primary\"\n >\n <option value=\"all\">All statuses</option>\n <option\n value={HeadshotmarketingAiToolExecutionStatus.Completed}\n >\n Completed\n </option>\n <option value={HeadshotmarketingAiToolExecutionStatus.Failed}>\n Failed\n </option>\n <option value={HeadshotmarketingAiToolExecutionStatus.Running}>\n Running\n </option>\n </select>\n <select\n aria-label=\"Filter runs by trigger\"\n value={triggerFilter}\n onChange={(e) => setTriggerFilter(e.target.value)}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs text-text-primary\"\n >\n <option value=\"all\">All triggers</option>\n <option value=\"manual\">Manual</option>\n <option value=\"scheduled\">Scheduled</option>\n <option value=\"event\">Event</option>\n </select>\n <button\n type=\"button\"\n onClick={() => void refetchRuns()}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-seam bg-gloss-card px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <RefreshCw className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n Refresh\n </button>\n </div>\n </div>\n\n {runsError && agentRuns.length === 0 ? (\n <div\n role=\"status\"\n className=\"flex items-center gap-2 rounded-md border border-border-subtle bg-bg-sunken/50 px-3 py-2.5 text-xs text-text-secondary\"\n >\n <AlertTriangle className=\"h-4 w-4 shrink-0 text-status-warning-text\" />\n <span>\n AI run activity is unavailable right now (requires AI ledger\n read permission or active AI service).\n </span>\n </div>\n ) : runsLoading && agentRuns.length === 0 ? (\n <div className=\"space-y-2\">\n {[0, 1, 2].map((i) => (\n <div\n key={i}\n className=\"h-10 animate-pulse rounded-md bg-bg-sunken/50\"\n />\n ))}\n </div>\n ) : agentRuns.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border-subtle py-6 text-center text-xs text-text-secondary\">\n No AI runs recorded for this workspace yet.\n </p>\n ) : (\n <div className=\"space-y-3\">\n <div className=\"overflow-x-auto\">\n <table className=\"w-full text-left text-xs\">\n <thead>\n <tr className=\"border-b border-border-subtle text-text-secondary\">\n <th className=\"py-2 pr-3 font-medium\">Operation</th>\n <th className=\"py-2 pr-3 font-medium\">Model / Source</th>\n <th className=\"py-2 pr-3 font-medium\">Trigger</th>\n <th className=\"py-2 pr-3 font-medium\">Decision</th>\n <th className=\"py-2 pr-3 font-medium\">Latency</th>\n <th className=\"py-2 pr-3 font-medium\">Cost</th>\n <th className=\"py-2 pr-3 font-medium\">Status</th>\n <th className=\"py-2 font-medium\">When</th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border-subtle\">\n {agentRuns.map((run) => (\n <tr key={run.id} className=\"text-text-primary\">\n <td className=\"py-2.5 pr-3 font-medium\">\n {run.operationKey}\n </td>\n <td className=\"py-2.5 pr-3 text-text-secondary\">\n {formatAiProvenance({\n provider: run.provider,\n model: run.model,\n })}\n </td>\n <td className=\"py-2.5 pr-3 capitalize text-text-secondary\">\n {run.trigger}\n </td>\n <td className=\"py-2.5 pr-3 text-text-secondary\">\n {run.decision ?? \"—\"}\n </td>\n <td className=\"py-2.5 pr-3 tabular-nums text-text-secondary\">\n {formatAiLatency(run.latencyMs ?? run.durationMs)}\n </td>\n <td className=\"py-2.5 pr-3 tabular-nums text-text-secondary\">\n {formatAiCost({\n costUsd: run.costUsd,\n simulated: run.simulated,\n })}\n </td>\n <td className=\"py-2.5 pr-3\">\n <span\n className={cn(\n \"inline-flex rounded-full px-2 py-0.5 text-[11px] font-medium\",\n run.status ===\n HeadshotmarketingAiToolExecutionStatus.Completed\n ? \"bg-status-success-bg text-status-success-text\"\n : run.status ===\n HeadshotmarketingAiToolExecutionStatus.Failed\n ? \"bg-status-error-bg text-status-error-text\"\n : \"bg-status-warning-bg text-status-warning-text\",\n )}\n >\n {run.status.toLowerCase()}\n </span>\n </td>\n <td className=\"py-2.5 whitespace-nowrap text-text-secondary\">\n {formatDate(run.createdAt, \"relative\")}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n\n {pageInfo?.hasNextPage && (\n <div className=\"flex justify-center pt-1\">\n <button\n type=\"button\"\n onClick={() => void handleLoadMoreRuns()}\n className=\"rounded-md border border-border-seam bg-gloss-card px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n Load more runs\n </button>\n </div>\n )}\n </div>\n )}\n </section>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAkEA,IAAMA,IAAuB,IAEvBC,KAAyE;EAC5EC,EAAuC,YACtCA,EAAuC;EACxCA,EAAuC,SACtCA,EAAuC;EACxCA,EAAuC,UACtCA,EAAuC;AAC3C,GAWaC,UAA6B;CACxC,IAAM,EAAE,aAAU,gBAAaC,EAAqB,GAG9C,EACJ,MAAMC,IACN,SAASC,IACT,OAAOC,IACP,SAASC,MACPC,GAA8C,EAChD,aAAa,eACf,CAAC,GACK,CAACC,IAAe,EAAE,SAASC,OAC/BC,GAAoD,GAChD,CAACC,GAAaC,MAAkBC,EAAiB,EAAE,GACnD,CAACC,GAAcC,KAAmBF,EAAwB,IAAI,GAC9D,CAACG,GAAiBC,KAAsBJ,EAAwB,IAAI,GAEpEK,IACJf,IAAU,yCAAyC,M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YAAI,WAAU;YACX,UAAAG,GAAa;aACZ,SAASH,EAAI;aACb,WAAWA,EAAI;YACjB,CAAC;WACC,CAAA;WACJ,kBAAC,MAAD;YAAI,WAAU;YACZ,UAAA,kBAAC,QAAD;aACE,WAAWlB,EACT,gEACAkB,EAAI,WACFtG,EAAuC,YACrC,kDACAsG,EAAI,WACFtG,EAAuC,SACvC,8CACA,+CACR;aAEC,UAAAsG,EAAI,OAAO,YAAY;YACpB,CAAA;WACJ,CAAA;WACJ,kBAAC,MAAD;YAAI,WAAU;YACX,UAAAI,GAAWJ,EAAI,WAAW,UAAU;WACnC,CAAA;UACF;SA5CK,GAAAA,EAAI,EA4CT,CACL;QACI,CAAA,CACF;;MACJ,CAAA,GAEJ7B,GAAU,eACT,kBAAC,OAAD;OAAK,WAAU;OACb,UAAA,kBAAC,UAAD;QACE,MAAK;QACL,eAAe,KAAKC,GAAmB;QACvC,WAAU;QACX,UAAA;OAEO,CAAA;MACL,CAAA,CAEJ;KAEA,CAAA,CAAA;;GACN;EACF,CAAA,CAAA;;AAET"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Pure formatting and batching helpers for HeadshotMarketing AI decision
3
+ * surfaces (BOFF-3736 / BOFF-3782).
4
+ *
5
+ * @module headshotmarketing/pages/ai
6
+ */
7
+ export declare const AI_DISCLAIMER_TEXT = "AI-generated recommendation \u2014 review rationale and verify before applying or publishing.";
8
+ export interface RationaleFactorItem {
9
+ factor: string;
10
+ impact: number;
11
+ detail: string;
12
+ }
13
+ /**
14
+ * Human-readable provenance label for an AI decision.
15
+ * Never fabricates a provider or model when a deterministic fallback ran.
16
+ */
17
+ export declare function formatAiProvenance(input: {
18
+ provider?: string | null;
19
+ model?: string | null;
20
+ source?: string | null;
21
+ }): string;
22
+ /**
23
+ * Format server-priced USD cost or credit charge without rounding tiny
24
+ * per-call fractions down to "$0".
25
+ */
26
+ export declare function formatAiCost(input: {
27
+ costUsd?: number | null;
28
+ creditsCharged?: number | null;
29
+ simulated?: boolean;
30
+ }): string;
31
+ /** Format latency in ms or seconds. */
32
+ export declare function formatAiLatency(latencyMs?: number | null): string;
33
+ /** Compute signed budget delta and percentage change for reallocation cards. */
34
+ export declare function computeBudgetDelta(currentBudget: number, recommendedBudget: number): {
35
+ delta: number;
36
+ deltaPct: number;
37
+ direction: "increase" | "decrease" | "unchanged";
38
+ };
39
+ /** Human-readable label for a Deal next-best-action enum value. */
40
+ export declare function formatNextActionLabel(action: string): string;
41
+ /** Human-readable label for a score rationale factor key. */
42
+ export declare function formatFactorName(factor: string): string;
43
+ /**
44
+ * Extract compact, safe display chips from an audience suggestion's JSON
45
+ * criteria object.
46
+ */
47
+ export declare function summarizeAudienceCriteria(criteria: unknown): string[];
48
+ /**
49
+ * Partition a requested batch lead-scoring total into sequential chunk sizes
50
+ * bounded by the backend's 25-lead per-request limit (default step size 5 so
51
+ * progress updates visibly and cancellation can stop cleanly between steps).
52
+ */
53
+ export declare function buildBatchChunks(totalLeads: number, stepSize?: number): number[];
@@ -0,0 +1,50 @@
1
+ // src/headshotmarketing/pages/ai/aiDecisionHelpers.ts
2
+ var e = "AI-generated recommendation — review rationale and verify before applying or publishing.";
3
+ function t(e) {
4
+ let t = e.source?.trim() ?? "";
5
+ if (t === "RULES_FALLBACK" || t === "deterministic-heuristic" || e.provider === "deterministic") return "Rules fallback";
6
+ let n = e.provider?.trim(), r = e.model?.trim();
7
+ return n && r ? r.startsWith(`${n}/`) ? r : `${n} / ${r}` : r || n || (t.startsWith("llm:") ? t.slice(4) || "AI model" : t === "MODEL" ? "AI model" : t || "AI model");
8
+ }
9
+ function n(e) {
10
+ return e.simulated ? "Simulated ($0)" : typeof e.costUsd == "number" && Number.isFinite(e.costUsd) ? e.costUsd === 0 ? "$0.00" : e.costUsd < .01 ? `$${e.costUsd.toFixed(4)}` : `$${e.costUsd.toFixed(2)}` : typeof e.creditsCharged == "number" && Number.isFinite(e.creditsCharged) ? `${e.creditsCharged} ${e.creditsCharged === 1 ? "credit" : "credits"}` : "Metered";
11
+ }
12
+ function r(e) {
13
+ return typeof e != "number" || !Number.isFinite(e) ? "—" : e < 1e3 ? `${Math.round(e)} ms` : `${(e / 1e3).toFixed(1)} s`;
14
+ }
15
+ function i(e, t) {
16
+ let n = t - e;
17
+ return {
18
+ delta: n,
19
+ deltaPct: e > 0 ? Math.round(n / e * 100) : 0,
20
+ direction: n > .005 ? "increase" : n < -.005 ? "decrease" : "unchanged"
21
+ };
22
+ }
23
+ function a(e) {
24
+ switch (e) {
25
+ case "ADVANCE_STAGE": return "Advance pipeline stage";
26
+ case "RE_ENGAGE": return "Re-engage prospect";
27
+ case "ASSIGN_CONTENT": return "Share targeted content";
28
+ case "MARK_COLD": return "Mark deal cold";
29
+ default: return e.toLowerCase().split("_").filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1)).join(" ");
30
+ }
31
+ }
32
+ function o(e) {
33
+ return e.replace(/[_-]+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
34
+ }
35
+ function s(e) {
36
+ if (!e || typeof e != "object" || Array.isArray(e)) return [];
37
+ let t = Object.fromEntries(Object.entries(e)), n = [];
38
+ return Array.isArray(t.statuses) && t.statuses.length > 0 && n.push(`Status: ${t.statuses.map(String).join(", ")}`), Array.isArray(t.tagsAny) && t.tagsAny.length > 0 && n.push(`Tags: ${t.tagsAny.map(String).join(", ")}`), Array.isArray(t.sourcesAny) && t.sourcesAny.length > 0 && n.push(`Sources: ${t.sourcesAny.map(String).join(", ")}`), typeof t.minScore == "number" && n.push(`Min score: ${t.minScore}`), typeof t.maxScore == "number" && n.push(`Max score: ${t.maxScore}`), typeof t.activeWithinDays == "number" && n.push(`Active ≤ ${t.activeWithinDays}d`), Array.isArray(t.jobTitleContainsAny) && t.jobTitleContainsAny.length > 0 && n.push(`Titles: ${t.jobTitleContainsAny.map(String).join(", ")}`), n;
39
+ }
40
+ function c(e, t = 5) {
41
+ let n = Math.max(0, Math.floor(e)), r = Math.max(1, Math.min(25, Math.floor(t))), i = [], a = n;
42
+ for (; a > 0;) {
43
+ let e = Math.min(r, a);
44
+ i.push(e), a -= e;
45
+ }
46
+ return i;
47
+ }
48
+ export { e as AI_DISCLAIMER_TEXT, c as buildBatchChunks, i as computeBudgetDelta, n as formatAiCost, r as formatAiLatency, t as formatAiProvenance, o as formatFactorName, a as formatNextActionLabel, s as summarizeAudienceCriteria };
49
+
50
+ //# sourceMappingURL=aiDecisionHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aiDecisionHelpers.js","names":["AI_DISCLAIMER_TEXT","formatAiProvenance","source","input","provider","model","formatAiCost","formatAiLatency","latencyMs","computeBudgetDelta","delta","recommendedBudget","currentBudget","formatNextActionLabel","action","part","formatFactorName","factor","ch","summarizeAudienceCriteria","criteria","rec","chips","buildBatchChunks","safeTotal","totalLeads","safeStep","stepSize","chunks","remaining","next"],"sources":["../../../../src/headshotmarketing/pages/ai/aiDecisionHelpers.ts"],"sourcesContent":["/**\n * Pure formatting and batching helpers for HeadshotMarketing AI decision\n * surfaces (BOFF-3736 / BOFF-3782).\n *\n * @module headshotmarketing/pages/ai\n */\n\nexport const AI_DISCLAIMER_TEXT =\n \"AI-generated recommendation — review rationale and verify before applying or publishing.\";\n\nexport interface RationaleFactorItem {\n factor: string;\n impact: number;\n detail: string;\n}\n\n/**\n * Human-readable provenance label for an AI decision.\n * Never fabricates a provider or model when a deterministic fallback ran.\n */\nexport function formatAiProvenance(input: {\n provider?: string | null;\n model?: string | null;\n source?: string | null;\n}): string {\n const source = input.source?.trim() ?? \"\";\n if (\n source === \"RULES_FALLBACK\" ||\n source === \"deterministic-heuristic\" ||\n input.provider === \"deterministic\"\n ) {\n return \"Rules fallback\";\n }\n\n const provider = input.provider?.trim();\n const model = input.model?.trim();\n if (provider && model) {\n return model.startsWith(`${provider}/`) ? model : `${provider} / ${model}`;\n }\n if (model) return model;\n if (provider) return provider;\n\n if (source.startsWith(\"llm:\")) {\n return source.slice(4) || \"AI model\";\n }\n if (source === \"MODEL\") return \"AI model\";\n return source || \"AI model\";\n}\n\n/**\n * Format server-priced USD cost or credit charge without rounding tiny\n * per-call fractions down to \"$0\".\n */\nexport function formatAiCost(input: {\n costUsd?: number | null;\n creditsCharged?: number | null;\n simulated?: boolean;\n}): string {\n if (input.simulated) return \"Simulated ($0)\";\n if (typeof input.costUsd === \"number\" && Number.isFinite(input.costUsd)) {\n if (input.costUsd === 0) return \"$0.00\";\n return input.costUsd < 0.01\n ? `$${input.costUsd.toFixed(4)}`\n : `$${input.costUsd.toFixed(2)}`;\n }\n if (\n typeof input.creditsCharged === \"number\" &&\n Number.isFinite(input.creditsCharged)\n ) {\n return `${input.creditsCharged} ${input.creditsCharged === 1 ? \"credit\" : \"credits\"}`;\n }\n return \"Metered\";\n}\n\n/** Format latency in ms or seconds. */\nexport function formatAiLatency(latencyMs?: number | null): string {\n if (typeof latencyMs !== \"number\" || !Number.isFinite(latencyMs)) {\n return \"—\";\n }\n if (latencyMs < 1000) return `${Math.round(latencyMs)} ms`;\n return `${(latencyMs / 1000).toFixed(1)} s`;\n}\n\n/** Compute signed budget delta and percentage change for reallocation cards. */\nexport function computeBudgetDelta(\n currentBudget: number,\n recommendedBudget: number,\n): {\n delta: number;\n deltaPct: number;\n direction: \"increase\" | \"decrease\" | \"unchanged\";\n} {\n const delta = recommendedBudget - currentBudget;\n const deltaPct =\n currentBudget > 0 ? Math.round((delta / currentBudget) * 100) : 0;\n const direction =\n delta > 0.005 ? \"increase\" : delta < -0.005 ? \"decrease\" : \"unchanged\";\n return { delta, deltaPct, direction };\n}\n\n/** Human-readable label for a Deal next-best-action enum value. */\nexport function formatNextActionLabel(action: string): string {\n switch (action) {\n case \"ADVANCE_STAGE\":\n return \"Advance pipeline stage\";\n case \"RE_ENGAGE\":\n return \"Re-engage prospect\";\n case \"ASSIGN_CONTENT\":\n return \"Share targeted content\";\n case \"MARK_COLD\":\n return \"Mark deal cold\";\n default:\n return action\n .toLowerCase()\n .split(\"_\")\n .filter(Boolean)\n .map((part) => part[0].toUpperCase() + part.slice(1))\n .join(\" \");\n }\n}\n\n/** Human-readable label for a score rationale factor key. */\nexport function formatFactorName(factor: string): string {\n return factor\n .replace(/[_-]+/g, \" \")\n .trim()\n .replace(/\\b\\w/g, (ch) => ch.toUpperCase());\n}\n\n/**\n * Extract compact, safe display chips from an audience suggestion's JSON\n * criteria object.\n */\nexport function summarizeAudienceCriteria(criteria: unknown): string[] {\n if (!criteria || typeof criteria !== \"object\" || Array.isArray(criteria)) {\n return [];\n }\n const rec: Record<string, unknown> = Object.fromEntries(\n Object.entries(criteria),\n );\n const chips: string[] = [];\n\n if (Array.isArray(rec.statuses) && rec.statuses.length > 0) {\n chips.push(`Status: ${rec.statuses.map(String).join(\", \")}`);\n }\n if (Array.isArray(rec.tagsAny) && rec.tagsAny.length > 0) {\n chips.push(`Tags: ${rec.tagsAny.map(String).join(\", \")}`);\n }\n if (Array.isArray(rec.sourcesAny) && rec.sourcesAny.length > 0) {\n chips.push(`Sources: ${rec.sourcesAny.map(String).join(\", \")}`);\n }\n if (typeof rec.minScore === \"number\") {\n chips.push(`Min score: ${rec.minScore}`);\n }\n if (typeof rec.maxScore === \"number\") {\n chips.push(`Max score: ${rec.maxScore}`);\n }\n if (typeof rec.activeWithinDays === \"number\") {\n chips.push(`Active ≤ ${rec.activeWithinDays}d`);\n }\n if (\n Array.isArray(rec.jobTitleContainsAny) &&\n rec.jobTitleContainsAny.length > 0\n ) {\n chips.push(`Titles: ${rec.jobTitleContainsAny.map(String).join(\", \")}`);\n }\n return chips;\n}\n\n/**\n * Partition a requested batch lead-scoring total into sequential chunk sizes\n * bounded by the backend's 25-lead per-request limit (default step size 5 so\n * progress updates visibly and cancellation can stop cleanly between steps).\n */\nexport function buildBatchChunks(totalLeads: number, stepSize = 5): number[] {\n const safeTotal = Math.max(0, Math.floor(totalLeads));\n const safeStep = Math.max(1, Math.min(25, Math.floor(stepSize)));\n const chunks: number[] = [];\n let remaining = safeTotal;\n while (remaining > 0) {\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M,KAAK,cAAcD,EAAI,UAAU,GAErC,OAAOA,EAAI,oBAAqB,YAClCC,EAAM,KAAK,YAAYD,EAAI,iBAAiB,EAAE,GAG9C,MAAM,QAAQA,EAAI,mBAAmB,KACrCA,EAAI,oBAAoB,SAAS,KAEjCC,EAAM,KAAK,WAAWD,EAAI,oBAAoB,IAAI,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,GAEjEC;AACT;AAOA,SAAgBC,EAAiB,GAAoB,IAAW,GAAa;CAC3E,IAAMC,IAAY,KAAK,IAAI,GAAG,KAAK,MAAMC,CAAU,CAAC,GAC9CC,IAAW,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAMC,CAAQ,CAAC,CAAC,GACzDC,IAAmB,CAAC,GACtBC,IAAYL;CAChB,OAAOK,IAAY,IAAG;EACpB,IAAMC,IAAO,KAAK,IAAIJ,GAAUG,CAAS;EAEzC,AADAD,EAAO,KAAKE,CAAI,GAChB,KAAaA;CACf;CACA,OAAOF;AACT"}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ interface CampaignAiPanelProps {
3
+ campaignId: string;
4
+ campaignName: string;
5
+ }
6
+ export declare const CampaignAiPanel: FC<CampaignAiPanelProps>;
7
+ export {};
@@ -0,0 +1,267 @@
1
+ import { useHeadshotmarketingApplyAudienceSuggestionMutation as e, useHeadshotmarketingAudienceSuggestionsQuery as t, useHeadshotmarketingDismissAudienceSuggestionMutation as n, useHeadshotmarketingOptimizeCampaignBudgetMutation as r, useHeadshotmarketingSuggestAudienceSegmentMutation as i } from "../../../generated/wspace-operations.js";
2
+ import { HeadshotmarketingAudienceSuggestionStatus as a } from "../../../generated/wspace-types.js";
3
+ import { formatCurrency as o, formatNumber as s } from "../../utils/helpers.js";
4
+ import { AiDecisionCard as c } from "../ai/AiDecisionCard.js";
5
+ import { formatAiProvenance as l, summarizeAudienceCriteria as u } from "../ai/aiDecisionHelpers.js";
6
+ import { useState as d } from "react";
7
+ import { AlertTriangle as f, Sparkles as p, TrendingUp as m } from "lucide-react";
8
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
9
+ // src/headshotmarketing/pages/campaigns/CampaignAiPanel.tsx
10
+ var _ = ({ campaignId: _, campaignName: v }) => {
11
+ let [y, b] = d(""), [x, S] = d(""), [C, w] = d(null), [T, E] = d(null), [D, O] = d({}), [k, A] = d(null), [j, M] = d(null), { data: N, loading: P, error: F, refetch: I } = t({
12
+ variables: {
13
+ filter: {
14
+ campaignId: _,
15
+ status: a.Proposed
16
+ },
17
+ pagination: {
18
+ limit: 10,
19
+ offset: 0
20
+ }
21
+ },
22
+ fetchPolicy: "network-only"
23
+ }), [L, { loading: R }] = i(), [z] = e(), [B] = n(), [V, { loading: H }] = r(), U = N?.headshotmarketingAudienceSuggestions.items ?? [], W = async () => {
24
+ let e = y.trim();
25
+ if (!e) {
26
+ w("Describe the audience goal before requesting a proposal.");
27
+ return;
28
+ }
29
+ w(null);
30
+ let t = Number(x);
31
+ try {
32
+ await L({ variables: { input: {
33
+ campaignId: _,
34
+ goal: e,
35
+ maxSize: x !== "" && Number.isFinite(t) && t > 0 ? Math.round(t) : void 0
36
+ } } }), b(""), S(""), await I();
37
+ } catch (e) {
38
+ w(e instanceof Error ? e.message : "AI audience segmentation is currently unavailable.");
39
+ }
40
+ }, G = async (e) => {
41
+ E(e), O((t) => {
42
+ let n = { ...t };
43
+ return delete n[e], n;
44
+ });
45
+ try {
46
+ await z({ variables: { input: {
47
+ suggestionId: e,
48
+ confirm: !0
49
+ } } }), await I();
50
+ } catch (t) {
51
+ O((n) => ({
52
+ ...n,
53
+ [e]: t instanceof Error ? t.message : "Failed to apply audience suggestion."
54
+ }));
55
+ } finally {
56
+ E(null);
57
+ }
58
+ }, K = async (e) => {
59
+ E(e), O((t) => {
60
+ let n = { ...t };
61
+ return delete n[e], n;
62
+ });
63
+ try {
64
+ await B({ variables: { id: e } }), await I();
65
+ } catch (t) {
66
+ O((n) => ({
67
+ ...n,
68
+ [e]: t instanceof Error ? t.message : "Failed to dismiss audience suggestion."
69
+ }));
70
+ } finally {
71
+ E(null);
72
+ }
73
+ }, q = async () => {
74
+ M(null);
75
+ try {
76
+ let e = await V({ variables: { input: {
77
+ campaignId: _,
78
+ dryRun: !1
79
+ } } });
80
+ A(e.data?.headshotmarketingOptimizeCampaignBudget ?? null);
81
+ } catch (e) {
82
+ M(e instanceof Error ? e.message : "AI budget optimizer is currently unavailable.");
83
+ }
84
+ };
85
+ return /* @__PURE__ */ g("div", {
86
+ className: "space-y-6",
87
+ children: [/* @__PURE__ */ g("section", {
88
+ className: "rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-4",
89
+ children: [
90
+ /* @__PURE__ */ h("div", {
91
+ className: "flex flex-wrap items-start justify-between gap-2",
92
+ children: /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ g("h4", {
93
+ className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
94
+ children: [/* @__PURE__ */ h(p, {
95
+ className: "h-4 w-4 text-action-primary-bg",
96
+ "aria-hidden": "true"
97
+ }), "AI Audience Suggestions"]
98
+ }), /* @__PURE__ */ g("p", {
99
+ className: "mt-0.5 text-xs text-text-secondary",
100
+ children: [
101
+ "Propose a targeted contact segment for ",
102
+ v,
103
+ ". Suggestions preview matching contacts and never create an audience until you confirm."
104
+ ]
105
+ })] })
106
+ }),
107
+ /* @__PURE__ */ g("div", {
108
+ className: "flex flex-col gap-2 sm:flex-row",
109
+ children: [
110
+ /* @__PURE__ */ h("input", {
111
+ type: "text",
112
+ value: y,
113
+ onChange: (e) => b(e.target.value),
114
+ placeholder: "Describe campaign goal (e.g. re-engage high-score enterprise leads)...",
115
+ "aria-label": "Campaign audience goal",
116
+ className: "flex-1 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
117
+ }),
118
+ /* @__PURE__ */ h("input", {
119
+ type: "number",
120
+ min: 1,
121
+ value: x,
122
+ onChange: (e) => S(e.target.value),
123
+ placeholder: "Max contacts",
124
+ "aria-label": "Maximum audience size",
125
+ className: "w-full sm:w-36 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
126
+ }),
127
+ /* @__PURE__ */ g("button", {
128
+ type: "button",
129
+ disabled: R,
130
+ onClick: () => void W(),
131
+ className: "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-60",
132
+ children: [/* @__PURE__ */ h(p, {
133
+ className: "h-4 w-4",
134
+ "aria-hidden": "true"
135
+ }), R ? "Proposing..." : "Suggest Audience"]
136
+ })
137
+ ]
138
+ }),
139
+ C && /* @__PURE__ */ h("div", {
140
+ role: "alert",
141
+ className: "rounded-md border border-status-error-border/40 bg-status-error-bg/15 px-3 py-2 text-xs text-status-error-text",
142
+ children: C
143
+ }),
144
+ F && U.length === 0 ? /* @__PURE__ */ h("p", {
145
+ className: "text-xs text-text-secondary",
146
+ children: "AI audience suggestions are temporarily unavailable."
147
+ }) : P && U.length === 0 ? /* @__PURE__ */ h("div", { className: "h-16 animate-pulse rounded-md bg-bg-sunken/50" }) : U.length > 0 ? /* @__PURE__ */ h("div", {
148
+ className: "grid grid-cols-1 gap-4 lg:grid-cols-2",
149
+ children: U.map((e) => {
150
+ let t = u(e.criteria);
151
+ return /* @__PURE__ */ h(c, {
152
+ testId: `campaign-audience-suggestion-${e.id}`,
153
+ title: e.name,
154
+ subtitle: `${s(e.previewCount)} matching contacts · Goal: ${e.goal}`,
155
+ badge: "Proposed",
156
+ badgeTone: "info",
157
+ rationale: e.rationale,
158
+ provider: e.provider,
159
+ model: e.model,
160
+ source: e.source,
161
+ applyLabel: "Confirm & create audience",
162
+ dismissLabel: "Dismiss",
163
+ busy: T === e.id,
164
+ error: D[e.id] ?? null,
165
+ onApply: () => void G(e.id),
166
+ onDismiss: () => void K(e.id),
167
+ children: t.length > 0 && /* @__PURE__ */ h("div", {
168
+ className: "flex flex-wrap gap-1.5",
169
+ children: t.map((e) => /* @__PURE__ */ h("span", {
170
+ className: "rounded-full bg-bg-sunken px-2.5 py-0.5 text-[11px] text-text-secondary",
171
+ children: e
172
+ }, e))
173
+ })
174
+ }, e.id);
175
+ })
176
+ }) : /* @__PURE__ */ h("p", {
177
+ className: "text-xs text-text-secondary",
178
+ children: "No pending AI audience proposals for this campaign."
179
+ })
180
+ ]
181
+ }), /* @__PURE__ */ g("section", {
182
+ className: "rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-3",
183
+ children: [
184
+ /* @__PURE__ */ g("div", {
185
+ className: "flex flex-wrap items-center justify-between gap-3",
186
+ children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ g("h4", {
187
+ className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
188
+ children: [/* @__PURE__ */ h(m, {
189
+ className: "h-4 w-4 text-action-primary-bg",
190
+ "aria-hidden": "true"
191
+ }), "AI Campaign Budget Optimizer"]
192
+ }), /* @__PURE__ */ h("p", {
193
+ className: "mt-0.5 text-xs text-text-secondary",
194
+ children: "Analyze linked ad campaigns and queue propose-only budget shifts for human approval."
195
+ })] }), /* @__PURE__ */ g("button", {
196
+ type: "button",
197
+ disabled: H,
198
+ onClick: () => void q(),
199
+ className: "inline-flex items-center gap-1.5 rounded-md border border-border-seam bg-gloss-card px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-60",
200
+ children: [/* @__PURE__ */ h(p, {
201
+ className: "h-3.5 w-3.5",
202
+ "aria-hidden": "true"
203
+ }), H ? "Analyzing..." : "Propose budget reallocation"]
204
+ })]
205
+ }),
206
+ j && /* @__PURE__ */ h("div", {
207
+ role: "alert",
208
+ className: "rounded-md border border-status-error-border/40 bg-status-error-bg/15 px-3 py-2 text-xs text-status-error-text",
209
+ children: j
210
+ }),
211
+ k && /* @__PURE__ */ g("div", {
212
+ className: "rounded-md border border-border-subtle bg-bg-sunken/40 p-3 space-y-2 text-xs",
213
+ children: [
214
+ /* @__PURE__ */ h("p", {
215
+ className: "font-medium text-text-primary",
216
+ children: k.summary
217
+ }),
218
+ /* @__PURE__ */ g("p", {
219
+ className: "text-text-secondary",
220
+ children: [
221
+ "Source:",
222
+ " ",
223
+ l({
224
+ provider: k.provider,
225
+ model: k.model,
226
+ source: k.source
227
+ })
228
+ ]
229
+ }),
230
+ k.deltas.length > 0 && /* @__PURE__ */ h("ul", {
231
+ className: "divide-y divide-border-subtle rounded-md border border-border-subtle bg-gloss-card",
232
+ children: k.deltas.map((e) => /* @__PURE__ */ g("li", {
233
+ className: "flex flex-wrap items-center justify-between gap-2 px-3 py-2",
234
+ children: [/* @__PURE__ */ h("span", {
235
+ className: "font-medium text-text-primary",
236
+ children: e.adCampaignName
237
+ }), /* @__PURE__ */ g("span", {
238
+ className: "tabular-nums text-text-secondary",
239
+ children: [
240
+ o(e.currentBudget),
241
+ " →",
242
+ " ",
243
+ o(e.proposedBudget),
244
+ " (",
245
+ e.delta >= 0 ? "+" : "",
246
+ e.deltaPct.toFixed(0),
247
+ "%)"
248
+ ]
249
+ })]
250
+ }, e.adCampaignId))
251
+ }),
252
+ /* @__PURE__ */ g("p", {
253
+ className: "flex items-center gap-1.5 text-[11px] text-text-secondary",
254
+ children: [/* @__PURE__ */ h(f, {
255
+ className: "h-3 w-3 shrink-0",
256
+ "aria-hidden": "true"
257
+ }), /* @__PURE__ */ h("span", { children: "AI-generated recommendation — review rationale and verify before applying or publishing." })]
258
+ })
259
+ ]
260
+ })
261
+ ]
262
+ })]
263
+ });
264
+ };
265
+ export { _ as CampaignAiPanel };
266
+
267
+ //# sourceMappingURL=CampaignAiPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CampaignAiPanel.js","names":["CampaignAiPanel","goal","setGoal","useState","maxSize","setMaxSize","suggestError","setSuggestError","busyId","setBusyId","cardErrors","setCardErrors","budgetPreview","setBudgetPreview","optimizeError","setOptimizeError","queryError","useHeadshotmarketingAudienceSuggestionsQuery","HeadshotmarketingAudienceSuggestionStatus","suggestAudience","suggesting","useHeadshotmarketingSuggestAudienceSegmentMutation","applySuggestion","useHeadshotmarketingApplyAudienceSuggestionMutation","dismissSuggestion","useHeadshotmarketingDismissAudienceSuggestionMutation","optimizeBudget","optimizing","useHeadshotmarketingOptimizeCampaignBudgetMutation","suggestions","data","handleSuggest","trimmed","parsedMax","refetch","err","handleApply","suggestionId","next","prev","handleDismiss","handleOptimizeBudget","res","Sparkles","campaignName","loading","chips","summarizeAudienceCriteria","suggestion","AiDecisionCard","formatNumber","chip","TrendingUp","formatAiProvenance","d","formatCurrency","AlertTriangle"],"sources":["../../../../src/headshotmarketing/pages/campaigns/CampaignAiPanel.tsx"],"sourcesContent":["/**\n * Campaign AI Decision Panel (BOFF-3736 / BOFF-3782)\n *\n * Mounted on the Campaign Details route:\n * 1. Propose AI Audience Segments (`headshotmarketingSuggestAudienceSegment`)\n * and render pending suggestions as confirmation-gated `AiDecisionCard`s\n * with previewed contact count and explicit Apply (`confirm: true`) /\n * Dismiss actions.\n * 2. Propose-only Campaign Budget Optimizer\n * (`headshotmarketingOptimizeCampaignBudget`) that generates ad-budget\n * reallocation proposals without mutating ad budgets.\n *\n * @module headshotmarketing/pages/campaigns\n */\n\nimport { useState, type FC } from \"react\";\nimport { Sparkles, TrendingUp, AlertTriangle } from \"lucide-react\";\nimport {\n useHeadshotmarketingApplyAudienceSuggestionMutation,\n useHeadshotmarketingAudienceSuggestionsQuery,\n useHeadshotmarketingDismissAudienceSuggestionMutation,\n useHeadshotmarketingOptimizeCampaignBudgetMutation,\n useHeadshotmarketingSuggestAudienceSegmentMutation,\n type HeadshotmarketingAudienceSuggestionsQuery,\n type HeadshotmarketingOptimizeCampaignBudgetMutation,\n} from \"../../../generated/wspace-operations\";\nimport { HeadshotmarketingAudienceSuggestionStatus } from \"../../../generated/wspace-types\";\nimport { formatCurrency, formatNumber } from \"../../utils/helpers\";\nimport { AiDecisionCard } from \"../ai/AiDecisionCard\";\nimport {\n AI_DISCLAIMER_TEXT,\n formatAiProvenance,\n summarizeAudienceCriteria,\n} from \"../ai/aiDecisionHelpers\";\n\ntype OptimizeBudgetResult =\n HeadshotmarketingOptimizeCampaignBudgetMutation[\"headshotmarketingOptimizeCampaignBudget\"];\n\ntype AudienceSuggestionItem =\n HeadshotmarketingAudienceSuggestionsQuery[\"headshotmarketingAudienceSuggestions\"][\"items\"][number];\n\ninterface CampaignAiPanelProps {\n campaignId: string;\n campaignName: string;\n}\n\nexport const CampaignAiPanel: FC<CampaignAiPanelProps> = ({\n campaignId,\n campaignName,\n}) => {\n const [goal, setGoal] = useState(\"\");\n const [maxSize, setMaxSize] = useState<string>(\"\");\n const [suggestError, setSuggestError] = useState<string | null>(null);\n const [busyId, setBusyId] = useState<string | null>(null);\n const [cardErrors, setCardErrors] = useState<Record<string, string>>({});\n const [budgetPreview, setBudgetPreview] =\n useState<OptimizeBudgetResult | null>(null);\n const [optimizeError, setOptimizeError] = useState<string | null>(null);\n\n const {\n data,\n loading,\n error: queryError,\n refetch,\n } = useHeadshotmarketingAudienceSuggestionsQuery({\n variables: {\n filter: {\n campaignId,\n status: HeadshotmarketingAudienceSuggestionStatus.Proposed,\n },\n pagination: { limit: 10, offset: 0 },\n },\n fetchPolicy: \"network-only\",\n });\n\n const [suggestAudience, { loading: suggesting }] =\n useHeadshotmarketingSuggestAudienceSegmentMutation();\n const [applySuggestion] =\n useHeadshotmarketingApplyAudienceSuggestionMutation();\n const [dismissSuggestion] =\n useHeadshotmarketingDismissAudienceSuggestionMutation();\n const [optimizeBudget, { loading: optimizing }] =\n useHeadshotmarketingOptimizeCampaignBudgetMutation();\n\n const suggestions: AudienceSuggestionItem[] =\n data?.headshotmarketingAudienceSuggestions.items ?? [];\n\n const handleSuggest = async (): Promise<void> => {\n const trimmed = goal.trim();\n if (!trimmed) {\n setSuggestError(\n \"Describe the audience goal before requesting a proposal.\",\n );\n return;\n }\n setSuggestError(null);\n const parsedMax = Number(maxSize);\n try {\n await suggestAudience({\n variables: {\n input: {\n campaignId,\n goal: trimmed,\n maxSize:\n maxSize !== \"\" && Number.isFinite(parsedMax) && parsedMax > 0\n ? Math.round(parsedMax)\n : undefined,\n },\n },\n });\n setGoal(\"\");\n setMaxSize(\"\");\n await refetch();\n } catch (err) {\n setSuggestError(\n err instanceof Error\n ? err.message\n : \"AI audience segmentation is currently unavailable.\",\n );\n }\n };\n\n const handleApply = async (suggestionId: string): Promise<void> => {\n setBusyId(suggestionId);\n setCardErrors((prev) => {\n const next = { ...prev };\n delete next[suggestionId];\n return next;\n });\n try {\n await applySuggestion({\n variables: { input: { suggestionId, confirm: true } },\n });\n await refetch();\n } catch (err) {\n setCardErrors((prev) => ({\n ...prev,\n [suggestionId]:\n err instanceof Error\n ? err.message\n : \"Failed to apply audience suggestion.\",\n }));\n } finally {\n setBusyId(null);\n }\n };\n\n const handleDismiss = async (suggestionId: string): Promise<void> => {\n setBusyId(suggestionId);\n setCardErrors((prev) => {\n const next = { ...prev };\n delete next[suggestionId];\n return next;\n });\n try {\n await dismissSuggestion({ variables: { id: suggestionId } });\n await refetch();\n } catch (err) {\n setCardErrors((prev) => ({\n ...prev,\n [suggestionId]:\n err instanceof Error\n ? err.message\n : \"Failed to dismiss audience suggestion.\",\n }));\n } finally {\n setBusyId(null);\n }\n };\n\n const handleOptimizeBudget = async (): Promise<void> => {\n setOptimizeError(null);\n try {\n const res = await optimizeBudget({\n variables: { input: { campaignId, dryRun: false } },\n });\n setBudgetPreview(\n res.data?.headshotmarketingOptimizeCampaignBudget ?? null,\n );\n } catch (err) {\n setOptimizeError(\n err instanceof Error\n ? err.message\n : \"AI budget optimizer is currently unavailable.\",\n );\n }\n };\n\n return (\n <div className=\"space-y-6\">\n {/* AI Audience Suggestions */}\n <section className=\"rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-4\">\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <div>\n <h4 className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Sparkles\n className=\"h-4 w-4 text-action-primary-bg\"\n aria-hidden=\"true\"\n />\n AI Audience Suggestions\n </h4>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Propose a targeted contact segment for {campaignName}. Suggestions\n preview matching contacts and never create an audience until you\n confirm.\n </p>\n </div>\n </div>\n\n <div className=\"flex flex-col gap-2 sm:flex-row\">\n <input\n type=\"text\"\n value={goal}\n onChange={(e) => setGoal(e.target.value)}\n placeholder=\"Describe campaign goal (e.g. re-engage high-score enterprise leads)...\"\n aria-label=\"Campaign audience goal\"\n className=\"flex-1 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <input\n type=\"number\"\n min={1}\n value={maxSize}\n onChange={(e) => setMaxSize(e.target.value)}\n placeholder=\"Max contacts\"\n aria-label=\"Maximum audience size\"\n className=\"w-full sm:w-36 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <button\n type=\"button\"\n disabled={suggesting}\n onClick={() => void handleSuggest()}\n className=\"inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-60\"\n >\n <Sparkles className=\"h-4 w-4\" aria-hidden=\"true\" />\n {suggesting ? \"Proposing...\" : \"Suggest Audience\"}\n </button>\n </div>\n\n {suggestError && (\n <div\n role=\"alert\"\n className=\"rounded-md border border-status-error-border/40 bg-status-error-bg/15 px-3 py-2 text-xs text-status-error-text\"\n >\n {suggestError}\n </div>\n )}\n\n {queryError && suggestions.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n AI audience suggestions are temporarily unavailable.\n </p>\n ) : loading && suggestions.length === 0 ? (\n <div className=\"h-16 animate-pulse rounded-md bg-bg-sunken/50\" />\n ) : suggestions.length > 0 ? (\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-2\">\n {suggestions.map((suggestion) => {\n const chips = summarizeAudienceCriteria(suggestion.criteria);\n return (\n <AiDecisionCard\n key={suggestion.id}\n testId={`campaign-audience-suggestion-${suggestion.id}`}\n title={suggestion.name}\n subtitle={`${formatNumber(suggestion.previewCount)} matching contacts · Goal: ${suggestion.goal}`}\n badge=\"Proposed\"\n badgeTone=\"info\"\n rationale={suggestion.rationale}\n provider={suggestion.provider}\n model={suggestion.model}\n source={suggestion.source}\n applyLabel=\"Confirm & create audience\"\n dismissLabel=\"Dismiss\"\n busy={busyId === suggestion.id}\n error={cardErrors[suggestion.id] ?? null}\n onApply={() => void handleApply(suggestion.id)}\n onDismiss={() => void handleDismiss(suggestion.id)}\n >\n {chips.length > 0 && (\n <div className=\"flex flex-wrap gap-1.5\">\n {chips.map((chip) => (\n <span\n key={chip}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-[11px] text-text-secondary\"\n >\n {chip}\n </span>\n ))}\n </div>\n )}\n </AiDecisionCard>\n );\n })}\n </div>\n ) : (\n <p className=\"text-xs text-text-secondary\">\n No pending AI audience proposals for this campaign.\n </p>\n )}\n </section>\n\n {/* Propose-only AI Budget Optimizer */}\n <section className=\"rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop space-y-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div>\n <h4 className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <TrendingUp\n className=\"h-4 w-4 text-action-primary-bg\"\n aria-hidden=\"true\"\n />\n AI Campaign Budget Optimizer\n </h4>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Analyze linked ad campaigns and queue propose-only budget shifts\n for human approval.\n </p>\n </div>\n <button\n type=\"button\"\n disabled={optimizing}\n onClick={() => void handleOptimizeBudget()}\n className=\"inline-flex items-center gap-1.5 rounded-md border border-border-seam bg-gloss-card px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-60\"\n >\n <Sparkles className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n {optimizing ? \"Analyzing...\" : \"Propose budget reallocation\"}\n </button>\n </div>\n\n {optimizeError && (\n <div\n role=\"alert\"\n className=\"rounded-md border border-status-error-border/40 bg-status-error-bg/15 px-3 py-2 text-xs text-status-error-text\"\n >\n {optimizeError}\n </div>\n )}\n\n {budgetPreview && (\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/40 p-3 space-y-2 text-xs\">\n <p className=\"font-medium text-text-primary\">\n {budgetPreview.summary}\n </p>\n <p className=\"text-text-secondary\">\n Source:{\" \"}\n {formatAiProvenance({\n provider: budgetPreview.provider,\n model: budgetPreview.model,\n source: budgetPreview.source,\n })}\n </p>\n {budgetPreview.deltas.length > 0 && (\n <ul className=\"divide-y divide-border-subtle rounded-md border border-border-subtle bg-gloss-card\">\n {budgetPreview.deltas.map((d) => (\n <li\n key={d.adCampaignId}\n className=\"flex flex-wrap items-center justify-between gap-2 px-3 py-2\"\n >\n <span className=\"font-medium text-text-primary\">\n {d.adCampaignName}\n </span>\n <span className=\"tabular-nums text-text-secondary\">\n {formatCurrency(d.currentBudget)} →{\" \"}\n {formatCurrency(d.proposedBudget)} (\n {d.delta >= 0 ? \"+\" : \"\"}\n {d.deltaPct.toFixed(0)}%)\n </span>\n </li>\n ))}\n </ul>\n )}\n <p className=\"flex items-center gap-1.5 text-[11px] text-text-secondary\">\n <AlertTriangle className=\"h-3 w-3 shrink-0\" aria-hidden=\"true\" />\n <span>{AI_DISCLAIMER_TEXT}</span>\n </p>\n </div>\n )}\n </section>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AA8CA,IAAaA,KAA6C,EACxD,eACA,sBACI;CACJ,IAAM,CAACC,GAAMC,KAAWC,EAAS,EAAE,GAC7B,CAACC,GAASC,KAAcF,EAAiB,EAAE,GAC3C,CAACG,GAAcC,KAAmBJ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