# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
    HR_photo: '%kernel.project_dir%/public/uploads/HR/profile_photo'
    logo_directory: '%kernel.project_dir%/public/uploads/logo'
    quotation_directory: '%kernel.project_dir%/public/uploads/quotation'
    web_vitals.storage_path: '%kernel.project_dir%/var/data/web-vitals.jsonl'
    web_vitals.budgets:
        LCP: 2500
        INP: 200
        CLS: 0.1
    env(MFA_EMAIL_SENDER): 'security@erpstarz.local'
    env(MFA_EMAIL_SENDER_NAME): 'STARZ ERP Security'
    env(MFA_CODE_DIGITS): '6'
    env(MFA_BACKUP_CODE_LENGTH): '10'
    env(MFA_BACKUP_CODE_COUNT): '8'
    env(AUTH_BYPASS_ENABLED): 'false'
    env(AUTH_BYPASS_EMAIL): 'bypass@erpstarz.local'
    default_efacture_url: 'https://api.finances.gov.tn/efacture/v1'
    default_efacture_key: ''
#    admin_email: '%admin_email%'
services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        public: false

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

    App\Controller\:
        resource: '../src/Controller/'
        tags: ['controller.service_arguments']
        public: true

    App\Service\TunisianEFactureService:
        arguments:
            $apiUrl: '%env(default:default_efacture_url:TUNISIAN_EFACTURE_API_URL)%'
            $apiKey: '%env(default:default_efacture_key:TUNISIAN_EFACTURE_API_KEY)%'

    # ── US Payroll: ACH / NACHA / EFTPS ──────────────────────────
    App\Service\AchSubmissionService:
        arguments:
            $projectDir: '%kernel.project_dir%'

    App\Service\EftpsTaxPaymentService:
        arguments:
            $projectDir: '%kernel.project_dir%'

    App\Service\NachaFileGenerator: ~

    App\Service\PayrollRunService: ~

    App\Service\PayrollDisbursementService: ~

    App\Service\PayrollJournalEntryService: ~

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones
    knp_snappy.pdf:
        class: Knp\Snappy\Pdf
        arguments:
            $binary: '%knp_snappy.pdf.binary%' # Path to the wkhtmltopdf binary
            $options: [] # Optional options for the PDF generator

    App\Service\Monitoring\WebVitalsConfig:
        arguments:
            $enabled: '%env(bool:WEB_VITALS_ENABLED)%'
            $assetPath: '%env(string:WEB_VITALS_ASSET)%'
            $ingestionEndpoint: '%env(string:WEB_VITALS_INGEST_ENDPOINT)%'
            $environment: '%kernel.environment%'

    App\Service\Monitoring\WebVitalsAggregationService:
        arguments:
            $budgets: '%web_vitals.budgets%'

    # Web Vitals: DB-backed implementations (replaces filesystem)
    App\Service\Monitoring\WebVitalsRepositoryInterface:
        alias: App\Service\Monitoring\DoctrineWebVitalsRepository
        public: true

    App\Service\Monitoring\MetricsRecorderInterface:
        alias: App\Service\Monitoring\DoctrineMetricsRecorder
        public: true

    App\Service\CompanyRegistry:
        arguments:
            $projectDir: '%kernel.project_dir%'
            $cache_pool: '@cache.app'

    App\Command\CompanySeedCommand:
        arguments:
            $projectDir: '%kernel.project_dir%'

    App\Service\Wms\WorkstationTokenManager:
        arguments:
            $appSecret: '%kernel.secret%'

    App\Service\Security\BackupCodeService:
        arguments:
            $codeLength: '%env(int:MFA_BACKUP_CODE_LENGTH)%'
            $codeCount: '%env(int:MFA_BACKUP_CODE_COUNT)%'

    App\EventSubscriber\AuthBypassSubscriber:
        arguments:
            $authBypassEnabled: '%env(bool:AUTH_BYPASS_ENABLED)%'
            $kernelEnvironment: '%kernel.environment%'
            $authBypassEmail: '%env(string:AUTH_BYPASS_EMAIL)%'

    App\EventSubscriber\SecurityHeadersSubscriber:
        arguments:
            $kernelEnvironment: '%kernel.environment%'

    App\EventSubscriber\RateLimitSubscriber:
        arguments:
            $wmsApiLimiter: '@limiter.wms_api'
            $webVitalsLimiter: '@limiter.web_vitals_ingestion'

    App\Doctrine\CompanyConnectionSwitcher:
        arguments:
            $connection: '@doctrine.dbal.default_connection'

    App\ArgumentResolver\EntityValueResolver:
        tags:
            - { name: controller.argument_value_resolver, priority: 100 }

    # ── Encryption Service for Sensitive Data ────────────────────
    App\Service\EncryptionService:
        arguments:
            $bankEncryptionKey: '%env(string:BANK_ENCRYPTION_KEY)%'
