import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import React, { useState, useEffect } from 'react';
import { Card, CardContent, CardHeader } from '@ballerine/ui';
import {
Brain,
FileSearch,
UserCheck,
Building,
ExternalLink,
Ban,
Sparkles,
Info,
MessagesSquare,
ThumbsUp,
ThumbsDown,
} from 'lucide-react';
// Enhanced AI icon with subtle animation effect
const AITechIcon = () => {
const [animationFrame, setAnimationFrame] = useState(0);
useEffect(() => {
// Simple pulse animation
const interval = setInterval(() => {
setAnimationFrame(prev => (prev + 1) % 20);
}, 100);
return () => clearInterval(interval);
}, []);
const pulseIntensity = Math.sin(animationFrame * 0.3) * 0.15 + 0.85;
return (
{/* Animated glow effect */}
{/* Neural network nodes effect */}
);
};
// Technical model information
interface AIModelInfo {
name: string;
version: string;
dataPoints: number;
confidenceScore: number;
lastUpdated: string;
}
const defaultModelInfo: AIModelInfo = {
name: 'RiskDetect™',
version: '4.2.1',
dataPoints: 1673940,
confidenceScore: 96.7,
lastUpdated: '2 hours ago',
};
// Enhanced Ask AI Component connected to actions
const AskAIPanel = ({
actions = [],
}: {
actions?: Array<{ icon: React.ElementType; label: string; onClick?: () => void }>;
}) => {
const [showPremiumTooltip, setShowPremiumTooltip] = useState(false);
const [activeQuestion, setActiveQuestion] = useState(null);
const [showMoreActions, setShowMoreActions] = useState(false);
const [inputValue, setInputValue] = useState('');
const [isLoading, setIsLoading] = useState(false);
const askButtonRef = React.useRef(null);
// Handle the Ask AI button click
const handleAskAI = () => {
if (inputValue.trim() || activeQuestion) {
setIsLoading(true);
// Show loading for 2 seconds before showing premium tooltip
setTimeout(() => {
setIsLoading(false);
setShowPremiumTooltip(true);
}, 2000);
}
};
// When a premade question is clicked, set it as the input value
const handleQuestionClick = (question: string) => {
setActiveQuestion(question);
setInputValue(question);
};
return (
AI ASSISTANT
setInputValue(e.target.value)}
/>
{activeQuestion ? (
) : (
)}
{['Why is this high risk?', 'What actions should I take?', 'Find similar cases'].map(
question => (
),
)}
{/* Actions suggested by AI - integration with actions */}
AI Recommended Actions
{showMoreActions
? actions.map((action, index) => (
))
: actions
.slice(0, 3)
.map((action, index) => (
))}
{actions.length > 3 && !showMoreActions && (
)}
{showMoreActions && (
)}
{showPremiumTooltip && (
Premium Feature
Advanced AI Assistant capabilities require a premium subscription.
With Premium AI, you can:
- Get instant case analysis and risk assessments
- Receive tailored action recommendations
- Access advanced document verification
)}
);
};
// Also enhance the ActionButton to match the Apple Intelligence aesthetic
const ActionButton = ({
icon: Icon,
label,
onClick = () => {
/* no-op default */
},
}: {
icon: React.ElementType;
label: string;
onClick?: () => void;
}) => {
const [showPremiumTooltip, setShowPremiumTooltip] = useState(false);
return (
{showPremiumTooltip && (
Premium feature
Upgrade your plan to unlock this action
)}
);
};
const RiskIndicator = ({ score, size = 'md' }: { score: number; size?: 'sm' | 'md' | 'lg' }) => {
let color = 'bg-green-500';
let textColor = 'text-green-700';
let label = 'Low';
if (score > 80) {
color = 'bg-red-500';
textColor = 'text-red-700';
label = 'High';
} else if (score > 50) {
color = 'bg-yellow-500';
textColor = 'text-yellow-700';
label = 'Medium';
}
const sizeClasses = {
sm: 'text-xs',
md: 'text-sm',
lg: 'text-base',
};
return (
{label} Risk ({score}/100)
);
};
interface Finding {
text: string;
confidence?: number; // Added confidence score for each finding
source?: {
label?: string;
tooltip: string;
dataPoints?: number; // Number of data points analyzed
};
}
interface ParagraphSection {
type: 'paragraph' | 'heading';
content: string;
}
interface BulletSection {
type: 'bullets';
content: Finding[];
}
type Section = ParagraphSection | BulletSection;
interface SummaryCardData {
companyName: string;
riskScore: number;
analysisDate: string; // When the analysis was performed
businessInfo: {
claimedType: string;
actualType: string;
chargebackRatio: string;
uboStatus: string;
};
}
interface AISummaryContentProps {
sections?: Section[];
summaryData?: SummaryCardData;
actions?: Array<{
icon: React.ElementType;
label: string;
onClick?: () => void;
}>;
modelInfo?: AIModelInfo;
}
// Component for showing a high-tech "neural connection" visualization
const NeuralConnectionDot = () => {
return (
);
};
// Enhanced finding component with confidence indicators
const FindingWithSource = ({ finding }: { finding: Finding }) => {
const [showTooltip, setShowTooltip] = useState(false);
if (!finding.source) {
return {finding.text};
}
return (
{finding.text}{' '}
setShowTooltip(true)}
onMouseLeave={() => setShowTooltip(false)}
>
· Source
{showTooltip && (
Analysis performed by RiskDetect™ AI using advanced machine learning algorithms and
natural language processing.
)}
);
};
const defaultSections: Section[] = [
{
type: 'paragraph',
content:
'Based on comprehensive analysis of GreenTech Solutions Ltd, this entity presents critical risk factors requiring immediate attention:',
},
{ type: 'heading', content: '1) Risk Assessment' },
{
type: 'bullets',
content: [
{
text: 'Severe business activity mismatch: The business is declared as operating in the business of eco-friendly office supplies but web presence indicates the operation of a crypto trading platform',
confidence: 99.2,
source: {
tooltip:
'Onsite text mentions "crypto-trading", "copy-trading features" and other elements likely to be associated with a crypto-trading platform.',
dataPoints: 7834,
},
},
{
text: 'Significant discrepancies between declared business activities and actual operations',
confidence: 97.8,
source: {
tooltip:
'MCC classification does not match declared business activity. Website and social media content are inconsistent with the claimed business model.',
dataPoints: 12405,
},
},
],
},
{ type: 'heading', content: '2) Key Compliance Concerns:' },
{
type: 'bullets',
content: [
{
text: 'Concealed UBO Carlton Ellington Cushnie (40%) identified through OSINT investigation',
confidence: 96.7,
source: {
tooltip: 'Undeclared UBO was found in registry check.',
dataPoints: 8412,
},
},
{
text: 'UBO linked to high-risk jurisdiction',
confidence: 94.3,
source: {
tooltip:
'OSINT reveals connections between the UBO Carlton Ellington Cushnie and a high-risk jurisdiction (Cayman Islands).',
dataPoints: 15692,
},
},
{
text: 'Operates without required business licensing for actual services',
confidence: 98.1,
source: {
tooltip:
'No evidence of a valid license for the operation of a crypto-trading platform was found to be associated with the entity.',
dataPoints: 4231,
},
},
],
},
{ type: 'heading', content: 'Customer & Operational Issues:' },
{
type: 'bullets',
content: [
{
text: 'Multiple customer complaints about inability to withdraw funds',
confidence: 97.9,
source: {
tooltip: '23 complaints were recovered relating to withdrawal of funds from account.',
dataPoints: 9871,
},
},
{
text: 'Consistent refusal to process customer refunds',
confidence: 96.5,
source: {
tooltip:
'Analysis of online reviews reveals pattern of refund denial and customer service avoidance.',
dataPoints: 14387,
},
},
],
},
{ type: 'heading', content: '4) Recommended Actions:' },
{
type: 'bullets',
content: [
{
text: 'Reject merchant application due to deceptive business practices',
confidence: 99.8,
source: {
tooltip:
'Clear evidence of misrepresentation of business activities and potential illicit operations.',
dataPoints: 21543,
},
},
{
text: 'Flag UBO in monitoring systems for enhanced due diligence in future applications',
confidence: 98.9,
source: {
tooltip:
'Add associated UBO information to internal watchlists to prevent potential future merchant onboarding through different entities.',
dataPoints: 7698,
},
},
{
text: 'Add to internal high-risk merchant database to prevent re-application',
confidence: 99.1,
source: {
tooltip:
'Permanent flagging in merchant screening system recommended based on severity of findings.',
dataPoints: 9432,
},
},
],
},
];
const defaultSummaryData: SummaryCardData = {
companyName: 'GreenTech Solutions Ltd',
riskScore: 98,
analysisDate: 'October 12, 2023 • 14:37 UTC',
businessInfo: {
claimedType: 'Claimed: Eco-friendly Retail',
actualType: 'Massage Parlor (Suspicious)',
chargebackRatio: '8.3% (High)',
uboStatus: 'Failed - Hidden UBO',
},
};
const defaultActions = [
{ icon: FileSearch, label: 'Background Check on Carlton Cushnie' },
{ icon: UserCheck, label: 'Verify Business Operations' },
{ icon: FileSearch, label: 'Request Licensing Documentation' },
{ icon: Building, label: 'On-Site Verification' },
{ icon: ExternalLink, label: 'Report to Authorities' },
{ icon: Ban, label: 'Reject Application' },
];
// New component: Simple version of the AI Summary Content
const SimpleAISummaryContent = ({
sections = defaultSections,
}: Omit) => {
// Get yesterday's date with fixed time
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const [feedbackGiven, setFeedbackGiven] = useState<'like' | 'dislike' | null>(null);
return (
{sections.map((section, sectionIndex) => {
if (section.type === 'paragraph' || section.type === 'heading') {
return (
{section.type === 'heading' ? (
{section.content}
) : (
{section.content}
)}
);
}
if (section.type === 'bullets') {
return (
{section.content.map((bullet, bulletIndex) => (
-
))}
);
}
return null;
})}
Was this case analysis helpful?
);
};
const AISummaryContent = ({
sections = defaultSections,
summaryData = defaultSummaryData,
actions = defaultActions,
}: AISummaryContentProps) => {
// Get yesterday's date with fixed time
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const analysisDate =
yesterday.toLocaleString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric',
}) + ' • 14:37 UTC';
const [feedbackGiven, setFeedbackGiven] = useState<'like' | 'dislike' | null>(null);
return (
{sections.map((section, sectionIndex) => {
if (section.type === 'paragraph' || section.type === 'heading') {
return (
{section.type === 'heading' ? (
{section.content}
) : (
{section.content}
)}
);
}
if (section.type === 'bullets') {
return (
{section.content.map((bullet, bulletIndex) => (
-
))}
);
}
return null;
})}
{/* AI Assistant with actions */}
Was this AI risk assessment helpful?
);
};
export const useAISummaryBlock = ({
isDemoAccount,
sections,
summaryData,
actions,
modelInfo = defaultModelInfo,
useAdvancedAI = true, // Feature flag to toggle between simple/advanced versions
isEnabled = true,
}: {
isDemoAccount: boolean;
sections?: Section[];
summaryData?: SummaryCardData;
actions?: Array<{
icon: React.ElementType;
label: string;
onClick?: () => void;
}>;
modelInfo?: AIModelInfo;
useAdvancedAI?: boolean; // Feature flag parameter
isEnabled?: boolean;
}) => {
if (!isDemoAccount || !isEnabled) {
return [];
}
return createBlocksTyped()
.addBlock()
.addCell({
type: 'node',
value: (
AI Risk Assessment
{useAdvancedAI ? (
) : (
)}
),
})
.build();
};