import { BertSmsClassifier } from './services/spamshield/src/classifier/sms-classifier';

// Mock SpamShieldService for testing
class MockSpamShield {
  async checkReputation(phoneNumber: string) {
    return {
      score: 0,
      isSpam: false,
      source: 'fallback',
    };
  }
}

async function testClassifier(): Promise<void> {
  console.log('=== SMS Classifier Feature Flag Test ===\n');
  
  // Test 1: Classifier with enabled feature flag
  console.log('Test 1: Classifier with enabled feature flag');
  const mockShield = new MockSpamShield();
  const classifier = new BertSmsClassifier(mockShield as any);
  
  const result = await classifier.classify(
    'Congratulations! You have won $1,000,000! Click here: http://bit.ly/12345 to claim your prize now! Call 555-1234 immediately!'
  );
  
  console.log('Input:', result.body);
  console.log('Classification:', result.isSpam ? 'SPAM' : 'NOT SPAM');
  console.log('Score:', result.score);
  console.log('Features:', result.features);
  console.log('');
  
  // Test 2: Classifier with benign message
  console.log('Test 2: Classifier with benign message');
  const benignResult = await classifier.classify(
    'Hello! Just checking in to see how you are doing. Hope you have a great day!'
  );
  
  console.log('Input:', benignResult.body);
  console.log('Classification:', benignResult.isSpam ? 'SPAM' : 'NOT SPAM');
  console.log('Score:', benignResult.score);
  console.log('');
  
  // Test 3: Classifier metrics
  console.log('Test 3: Classifier metrics');
  const metrics = classifier.getMetrics();
  console.log('Total classified:', metrics.totalClassified);
  console.log('Spam detected:', metrics.spamDetected);
  console.log('Accuracy:', metrics.totalClassified > 0 
    ? ((metrics.spamDetected / metrics.totalClassified) * 100).toFixed(1) + '%'
    : '0%');
  console.log('');
  
  console.log('=== All tests completed successfully ===');
}

export { testClassifier };

if (import.meta.env?.MODE !== 'test') {
  testClassifier().catch(console.error);
}
