/**
 * 간격 반복 팩토리
 * 의존성 주입 및 객체 생성 관리
 */
// 서비스 구현들 import
import { DefaultIntervalStrategy, ConservativeIntervalStrategy, AdaptiveIntervalStrategy } from '../services/spaced-repetition/interval-calculation.service.js';
import { DefaultRecallProbabilityCalculator, EnhancedRecallProbabilityCalculator, AdaptiveRecallProbabilityCalculator } from '../services/spaced-repetition/recall-probability.service.js';
import { DefaultReviewScheduler, PriorityBasedReviewScheduler, AdaptiveReviewScheduler } from '../services/spaced-repetition/review-scheduling.service.js';
import { DefaultPerformanceAnalyzer, DetailedPerformanceAnalyzer, AdaptivePerformanceAnalyzer } from '../services/spaced-repetition/performance-analysis.service.js';
import { DefaultPriorityCalculator, WeightedPriorityCalculator, AdaptivePriorityCalculator, TimeBasedPriorityCalculator } from '../services/spaced-repetition/priority-calculation.service.js';
import { DefaultOptimalIntervalRecommender, AdaptiveOptimalIntervalRecommender, MLBasedOptimalIntervalRecommender, EnsembleOptimalIntervalRecommender } from '../services/spaced-repetition/optimal-interval.service.js';
/**
 * 간격 반복 팩토리
 */
export class SpacedRepetitionFactory {
    /**
     * 기본 설정으로 서비스 생성
     */
    static createDefaultService(config) {
        const defaultConfig = {
            weights: {
                importance: 0.6,
                usage: 0.4,
                helpful_feedback: 0.5,
                bad_feedback: 0.7
            },
            recallThreshold: 0.7,
            defaultInterval: 7,
            ...config
        };
        return this.createService(defaultConfig);
    }
    /**
     * 설정에 따라 서비스 생성
     */
    static createService(config) {
        // 의존성 생성
        const intervalStrategy = this.createIntervalStrategy(config.weights);
        const recallCalculator = this.createRecallCalculator();
        const necessityChecker = this.createNecessityChecker(config.recallThreshold);
        const scheduler = this.createReviewScheduler(intervalStrategy, recallCalculator, necessityChecker, config.recallThreshold);
        const performanceAnalyzer = this.createPerformanceAnalyzer();
        const priorityCalculator = this.createPriorityCalculator();
        const optimalRecommender = this.createOptimalRecommender();
        return new SpacedRepetitionServiceImpl(intervalStrategy, recallCalculator, necessityChecker, scheduler, performanceAnalyzer, priorityCalculator, optimalRecommender);
    }
    /**
     * 간격 계산 전략 생성
     */
    static createIntervalStrategy(weights, strategy = 'default') {
        switch (strategy) {
            case 'conservative':
                return new ConservativeIntervalStrategy(weights);
            case 'adaptive':
                return new AdaptiveIntervalStrategy(weights);
            default:
                return new DefaultIntervalStrategy(weights);
        }
    }
    /**
     * 리콜 확률 계산기 생성
     */
    static createRecallCalculator(type = 'default') {
        switch (type) {
            case 'enhanced':
                return new EnhancedRecallProbabilityCalculator();
            case 'adaptive':
                return new AdaptiveRecallProbabilityCalculator();
            default:
                return new DefaultRecallProbabilityCalculator();
        }
    }
    /**
     * 리뷰 필요성 판단기 생성
     */
    static createNecessityChecker(threshold) {
        return {
            needsReview: (timeSinceLastReview, interval, customThreshold) => {
                const recallProb = Math.exp(-timeSinceLastReview / interval);
                return recallProb <= (customThreshold || threshold);
            }
        };
    }
    /**
     * 리뷰 스케줄러 생성
     */
    static createReviewScheduler(intervalStrategy, recallCalculator, necessityChecker, recallThreshold, type = 'default') {
        switch (type) {
            case 'priority':
                return new PriorityBasedReviewScheduler(intervalStrategy, recallCalculator, necessityChecker, recallThreshold);
            case 'adaptive':
                return new AdaptiveReviewScheduler(intervalStrategy, recallCalculator, necessityChecker, recallThreshold);
            default:
                return new DefaultReviewScheduler(intervalStrategy, recallCalculator, necessityChecker, recallThreshold);
        }
    }
    /**
     * 성과 분석기 생성
     */
    static createPerformanceAnalyzer(type = 'default') {
        switch (type) {
            case 'detailed':
                return new DetailedPerformanceAnalyzer();
            case 'adaptive':
                return new AdaptivePerformanceAnalyzer();
            default:
                return new DefaultPerformanceAnalyzer();
        }
    }
    /**
     * 우선순위 계산기 생성
     */
    static createPriorityCalculator(type = 'default') {
        switch (type) {
            case 'weighted':
                return new WeightedPriorityCalculator();
            case 'adaptive':
                return new AdaptivePriorityCalculator();
            case 'time-based':
                return new TimeBasedPriorityCalculator();
            default:
                return new DefaultPriorityCalculator();
        }
    }
    /**
     * 최적 간격 추천기 생성
     */
    static createOptimalRecommender(type = 'default') {
        switch (type) {
            case 'adaptive':
                return new AdaptiveOptimalIntervalRecommender();
            case 'ml':
                return new MLBasedOptimalIntervalRecommender();
            case 'ensemble':
                return new EnsembleOptimalIntervalRecommender();
            default:
                return new DefaultOptimalIntervalRecommender();
        }
    }
}
/**
 * 간격 반복 서비스 구현
 */
class SpacedRepetitionServiceImpl {
    intervalStrategy;
    recallCalculator;
    necessityChecker;
    scheduler;
    performanceAnalyzer;
    priorityCalculator;
    optimalRecommender;
    constructor(intervalStrategy, recallCalculator, necessityChecker, scheduler, performanceAnalyzer, priorityCalculator, optimalRecommender) {
        this.intervalStrategy = intervalStrategy;
        this.recallCalculator = recallCalculator;
        this.necessityChecker = necessityChecker;
        this.scheduler = scheduler;
        this.performanceAnalyzer = performanceAnalyzer;
        this.priorityCalculator = priorityCalculator;
        this.optimalRecommender = optimalRecommender;
    }
    calculateNextInterval(currentInterval, features) {
        const result = this.intervalStrategy.calculateInterval(currentInterval, features);
        return result.nextInterval;
    }
    calculateRecallProbability(timeSinceLastReview, interval) {
        return this.recallCalculator.calculateRecallProbability(timeSinceLastReview, interval);
    }
    needsReview(timeSinceLastReview, interval, threshold) {
        return this.necessityChecker.needsReview(timeSinceLastReview, interval, threshold);
    }
    createReviewSchedule(memoryId, currentInterval, lastReviewDate, features) {
        return this.scheduler.createReviewSchedule(memoryId, currentInterval, lastReviewDate, features);
    }
    createBatchReviewSchedules(memories) {
        return this.scheduler.createBatchReviewSchedules(memories);
    }
    calculateReviewPriority(schedule) {
        return this.priorityCalculator.calculateReviewPriority(schedule);
    }
    analyzeReviewPerformance(schedules, actualRecall) {
        return this.performanceAnalyzer.analyzeReviewPerformance(schedules, actualRecall);
    }
    recommendOptimalInterval(currentInterval, recallHistory, features) {
        return this.optimalRecommender.recommendOptimalInterval(currentInterval, recallHistory, features);
    }
}
//# sourceMappingURL=spaced-repetition.factory.js.map