// Detector Registry - Central export of all detector modules
// Import and register detectors by category

// URL Detectors
import { DomainReputationDetector } from './url-detectors/domain-reputation.js';
import { PathAnalysisDetector } from './url-detectors/path-analysis.js';
import { ParameterAnalysisDetector } from './url-detectors/parameter-analysis.js';
import { LookalikeD omainDetector } from './url-detectors/lookalike-domain.js';

// Resource Detectors
import { ExtensionAnalysisDetector } from './resource-detectors/extension-analysis.js';
import { MimeTypeAnalysisDetector } from './resource-detectors/mime-type-analysis.js';

// Permission Detectors
import { HighRiskPermissionsDetector } from './permission-detectors/high-risk-permissions.js';

// Social Engineering Detectors
import { TyposquattingDetector } from './social-engineering/typosquatting.js';
import { ClickjackingDetector } from './social-engineering/clickjacking.js';
import { FakeChromeDetector } from './social-engineering/fake-chrome.js';
import { CommandPatternDetector } from './social-engineering/command-pattern.js';
import { BrowserInBrowserDetector } from './social-engineering/browser-in-browser.js';
import { TabnabbingDetector } from './social-engineering/tabnabbing.js';
import { DialogTrapDetector } from './social-engineering/dialog-trap.js';

// Code Injection Detectors
import { HtmlSmugglingDetector } from './code-injection/html-smuggling.js';
import { FormjackingDetector } from './code-injection/formjacking.js';
import { MalvertisingDetector } from './code-injection/malvertising.js';
import { WasmMiningDetector } from './code-injection/wasm-mining.js';
import { XssDetector } from './code-injection/xss-detector.js';

// Data Theft Detectors
import { AutofillHarvestingDetector } from './data-theft/autofill-harvesting.js';
import { OverlayCredentialDetector } from './data-theft/overlay-credential.js';
import { ClipboardPoisoningDetector } from './data-theft/clipboard-poisoning.js';
import { ExfilChannelDetector } from './data-theft/exfil-channel.js';
import { SessionHijackingDetector } from './data-theft/session-hijacking.js';

// Malicious Extension Detectors
import { PermissionDriftDetector } from './malicious-extensions/permission-drift.js';
import { OverbroadPermissionsDetector } from './malicious-extensions/overbroad-permissions.js';

// Cross-Site Attack Detectors
import { CsrfDetector } from './cross-site/csrf-detector.js';
import { PrivateNetworkDetector } from './cross-site/private-network.js';
import { JsonpDetector } from './cross-site/jsonp-detector.js';

/**
 * Get all detector instances
 * @returns {array} - Array of detector instances
 */
export function getAllDetectors() {
  return [
    // URL Detectors
    new DomainReputationDetector(),
    new PathAnalysisDetector(),
    new ParameterAnalysisDetector(),
    new LookalikeD omainDetector(),

    // Resource Detectors
    new ExtensionAnalysisDetector(),
    new MimeTypeAnalysisDetector(),

    // Permission Detectors
    new HighRiskPermissionsDetector(),

    // Social Engineering Detectors
    new TyposquattingDetector(),
    new ClickjackingDetector(),
    new FakeChromeDetector(),
    new CommandPatternDetector(),
    new BrowserInBrowserDetector(),
    new TabnabbingDetector(),
    new DialogTrapDetector(),

    // Code Injection Detectors
    new HtmlSmugglingDetector(),
    new FormjackingDetector(),
    new MalvertisingDetector(),
    new WasmMiningDetector(),
    new XssDetector(),

    // Data Theft Detectors
    new AutofillHarvestingDetector(),
    new OverlayCredentialDetector(),
    new ClipboardPoisoningDetector(),
    new ExfilChannelDetector(),
    new SessionHijackingDetector(),

    // Malicious Extension Detectors
    new PermissionDriftDetector(),
    new OverbroadPermissionsDetector(),

    // Cross-Site Attack Detectors
    new CsrfDetector(),
    new PrivateNetworkDetector(),
    new JsonpDetector()
  ];
}

/**
 * Get detectors by category
 * @param {string} category - Category name
 * @returns {array} - Array of detector instances for category
 */
export function getDetectorsByCategory(category) {
  const allDetectors = getAllDetectors();
  return allDetectors.filter(d => d.category === category);
}

/**
 * Get detector count by category
 * @returns {object} - Category counts
 */
export function getDetectorStats() {
  const allDetectors = getAllDetectors();
  const stats = {
    total: allDetectors.length,
    byCategory: {}
  };

  for (const detector of allDetectors) {
    const category = detector.category;
    stats.byCategory[category] = (stats.byCategory[category] || 0) + 1;
  }

  return stats;
}

// Export individual detector classes for advanced usage
export {
  // URL
  DomainReputationDetector,
  PathAnalysisDetector,
  ParameterAnalysisDetector,
  LookalikeD omainDetector,

  // Resource
  ExtensionAnalysisDetector,
  MimeTypeAnalysisDetector,

  // Permission
  HighRiskPermissionsDetector,

  // Social Engineering
  TyposquattingDetector,
  ClickjackingDetector,
  FakeChromeDetector,
  CommandPatternDetector,
  BrowserInBrowserDetector,
  TabnabbingDetector,
  DialogTrapDetector,

  // Code Injection
  HtmlSmugglingDetector,
  FormjackingDetector,
  MalvertisingDetector,
  WasmMiningDetector,
  XssDetector,

  // Data Theft
  AutofillHarvestingDetector,
  OverlayCredentialDetector,
  ClipboardPoisoningDetector,
  ExfilChannelDetector,
  SessionHijackingDetector,

  // Malicious Extensions
  PermissionDriftDetector,
  OverbroadPermissionsDetector,

  // Cross-Site
  CsrfDetector,
  PrivateNetworkDetector,
  JsonpDetector
};
