<?php

declare(strict_types=1);

namespace Kylin\SensitiveWord;

use Illuminate\Support\ServiceProvider;
use Kylin\SensitiveWord\Services\SensitiveWordService;

/**
 * 敏感词过滤服务提供者
 *
 * 提供高效的敏感词检测与过滤功能，支持：
 *  - DFA 算法高效匹配
 *  - 变体检测（谐音/拆字/拼音/符号插入/全角/零宽字符）
 *  - 词库版本管理
 *  - 17 类风险分类
 *  - 三种过滤模式（replace/block/warn）
 *  - 审计日志
 */
class SensitiveWordServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__ . '/../config/kylin-sensitive-word.php', 'kylin-sensitive-word');
        $this->app->singleton(SensitiveWordService::class);
    }

    public function boot(): void
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__ . '/../config/kylin-sensitive-word.php' => config_path('kylin-sensitive-word.php'),
            ], 'kylin-sensitive-word-config');

            $this->publishes([
                __DIR__ . '/../database/migrations/' => database_path('migrations'),
            ], 'kylin-sensitive-word-migrations');
        }

        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
        $this->loadRoutesFrom(__DIR__ . '/../routes/api.php');
    }
}
