# 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:
    locale:            'fr'
    app_locales:       [fr,en]
    google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%'
    whatsapp.access_token: '%env(WHATSAPP_ACCESS_TOKEN)%'
    whatsapp.phone_number_id: '%env(WHATSAPP_PHONE_NUMBER_ID)%'
    openai_api_key: '%env(OPENAI_API_KEY)%'
    google_drive_credentials_path: '%env(resolve:GOOGLE_DRIVE_CREDENTIALS_PATH)%'
    
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.

    
    app.menu_builder:
        class: App\Menu\MenuBuilder
        arguments: ["@knp_menu.factory"]

    app.main_menu:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ["@app.menu_builder", createMainMenu]
        arguments: ["@request_stack"]
        tags:
            - { name: knp_menu.menu, alias: main }

    app.footer_menu:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ["@app.menu_builder", createFooterMenu]
        arguments: ["@request_stack"]
        tags:
            - { name: knp_menu.menu, alias: footer }

    gedmo.listener.sortable:
        class: Gedmo\Sortable\SortableListener
        calls:
            - [setAnnotationReader, ['@annotation_reader']]
        tags:
            - { name: doctrine.event_subscriber, connection: default }

    App\EventListener\GenerateJsonEventListener:
        arguments:
            $transunitadmin: '@App\Admin\TransUnitAdmin'
        tags:
            - { name: doctrine.event_subscriber , connection: default }

    # 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'

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    # ---------------------------------------------------------------------------
    # Remote SFTP media storage
    #
    # SonataMediaBundle v4.6 has no generic "gaufrette" filesystem option, so
    # we register the SFTP Gaufrette filesystem as a plain service and override
    # sonata.media.filesystem — all provider reads/writes go to medias.natea.info.
    # "filesystem.local" in sonata_media.yaml satisfies config validation only.
    #
    # Fill SFTP_* vars in .env.local — never commit real credentials.
    # ---------------------------------------------------------------------------

    # Must come AFTER App\: resource block so this definition is not overwritten.
    App\Command\MigrateFilesToSftpCommand:
        arguments:
            $localMediaDir: '%kernel.project_dir%/public/upload/media'

    # Sonata Media filesystem (used via MediaFilesystemPass in Kernel.php)
    App\Storage\SftpAdapter:
        arguments:
            $host:              '%env(SFTP_HOST)%'
            $port:              '%env(int:SFTP_PORT)%'
            $username:          '%env(SFTP_USER)%'
            $password:          '%env(SFTP_PASSWORD)%'
            $root:              '%env(SFTP_ROOT)%'
            $sshKeyPath:        '%env(SFTP_KEY_PATH)%'

    # Separate SFTP adapter for gallery uploads (different remote root)
    app.sftp.gallery:
        class: App\Storage\SftpAdapter
        arguments:
            $host:              '%env(SFTP_HOST)%'
            $port:              '%env(int:SFTP_PORT)%'
            $username:          '%env(SFTP_USER)%'
            $password:          '%env(SFTP_PASSWORD)%'
            $root:              '%env(SFTP_GALLERY_ROOT)%'
            $sshKeyPath:        '%env(SFTP_KEY_PATH)%'

    App\Controller\AdminController:
        arguments:
            $gallerySftp: '@app.sftp.gallery'
            $cdnUrl:      '%env(CDN_URL)%'

    # sonata.media.filesystem is overridden via MediaFilesystemPass (Kernel.php)
    # A plain services.yaml override cannot replace a bundle alias reliably.
    App\Services\WhatsAppService:
        arguments:
            $client: '@http_client'
            $accessToken: '%whatsapp.access_token%'
            $phoneNumberId: '%whatsapp.phone_number_id%'
            $kernel: '@kernel'

    App\Services\ChatGptApiService:
        arguments:
            $httpClient: '@http_client'
            $openAiApiKey: '%env(OPENAI_API_KEY)%'
            $produitsRepository: '@App\Repository\ProduitsRepository'
            $entityManager: '@doctrine.orm.entity_manager'
        public: false

    App\Services\AiAssistantService:
        arguments:
            $cache: '@cache.app'
        public: false

    App\Services\WhatsappConversationService:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $whatsAppService: '@App\Services\WhatsAppService'
            $httpClient: '@http_client'
            $chatGptApiService: '@App\Services\ChatGptApiService'
            $kernel: '@kernel'
            $chatContextService: '@App\Services\ChatContextService'


    App\Services\OpenAIClient:
        arguments:
            $apiKey: '%env(OPENAI_API_KEY)%'

    App\Services\AudioTranscriptionService:
        arguments:
            $logger: '@logger'
            $kernel: '@kernel'

    App\Services\GoogleDriveStorage:
        arguments:
            $credentialsPath: '%google_drive_credentials_path%'
            $logger: '@logger'

    admin.categories:
        class: App\Admin\CategoriesAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Categories, controller: ~, manager_type: orm, group: admin, label: Categories prestations }

    admin.produits:
        class: App\Admin\ProduitsAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Produits, controller: ~, manager_type: orm, group: admin, label: Prestations }

    admin.duree:
        class: App\Admin\DureeAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Duree, controller: ~, manager_type: orm, group: admin, label: Option }

    admin.prix_produits:
        class: App\Admin\PrixProduitsAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\PrixProduits, controller: ~, manager_type: orm, group: admin, label: PrixProduits }

    admin.produit_associe:
        class: App\Admin\ProduitAssocieAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ProduitAssocie, controller: ~, manager_type: orm, group: admin, label: ProduitAssocie }

    admin.galerie:
        class: App\Admin\GalerieAdmin
        calls:
            - [setTemplate, ['list', 'admin/_gallery.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\Galerie, controller: ~, manager_type: orm, group: admin, label: Galerie }

    admin.formulaire_contact:
        class: App\Admin\FormulaireContactAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\FormulaireContact, controller: App\Controller\ActionController , manager_type: orm, group: admin, label: Contact }

    admin.regle_fermeture:
        class: App\Admin\RegleFermetureAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\RegleFermeture, controller: ~, manager_type: orm, group: admin, label: Règle de fermeture }

    admin.regle_remise:
        class: App\Admin\RegleRemiseAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\RegleRemise, controller: ~, manager_type: orm, group: admin, label: Règle de remise }

    admin.formules_produits:
        class: App\Admin\FormulesProduitsAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\FormulesProduits, controller: ~, manager_type: orm, group: admin, label: FormulesProduits }

    admin.code_promo:
        class: App\Admin\CodePromoAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\CodePromo, controller: ~, manager_type: orm, group: admin, label: Code Promo }

    admin.cheque_cadeaux:
        class: App\Admin\ChequeCadeauxAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ChequeCadeaux, controller: ~, manager_type: orm, group: admin, label:  Réservations Chèque cadeau }

    admin.tarif_hotels:
        class: App\Admin\TarifHotelsAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\TarifHotels, controller: ~, manager_type: orm, group: admin, label: Tarifs transports }

    admin.regle_remise_produit:
        class: App\Admin\RegleRemiseProduitAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\RegleRemiseProduit, controller: ~, manager_type: orm, group: admin, label: RegleRemiseProduit }

    admin.pages:
        class: App\Admin\PagesAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Pages, controller: ~, manager_type: orm, group: admin, label: Pages }

    admin.translation:
        class: App\Admin\TranslationAdmin
        tags:
            - { name: sonata.admin, model_class: Lexik\Bundle\TranslationBundle\Entity\Translation, controller: ~, manager_type: orm, group: admin, label: Traduction }

    admin.trans_unit:
        class: App\Admin\TransUnitAdmin
        tags:
            - { name: sonata.admin, model_class: Lexik\Bundle\TranslationBundle\Entity\TransUnit, controller: ~, manager_type: orm, group: admin, label: Traduction , show_in_roles_matrix: false}

    admin.reservations:
        class: App\Admin\ReservationsAdmin
        calls:
            - [setTemplate, ['show', 'admin/_show_order.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\Reservations, controller: App\Controller\ActionController, manager_type: orm, group: admin, label: Réservations Natea }

    admin.regle_fermeture_produit:
        class: App\Admin\RegleFermetureProduitAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\RegleFermetureProduit, controller: ~, manager_type: orm, group: admin, label: RegleFermetureProduit , show_in_roles_matrix: false }

    admin.tranche_horaire:
        class: App\Admin\TrancheHoraireAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\TrancheHoraire, controller: ~, manager_type: orm, group: admin, label: Tranche Horaire }

    admin.archive_reservation:
        class: App\Admin\ArchiveReservationAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Reservations, controller: ~, manager_type: orm, group: admin, label: Archive }

    admin.reservations_items:
        class: App\Admin\ReservationsItemsAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ReservationsItems, controller: ~, manager_type: orm, group: admin, label: ReservationsItems , show_in_roles_matrix: false }

    admin.variables:
        class: App\Admin\VariablesAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Variables, controller: ~, manager_type: orm, group: admin, label: Variables}

    admin.resource_cabine:
        class: App\Admin\ResourceCabineAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ResourceCabine, controller: ~, manager_type: orm, group: admin, label: Gestion des cabines }

    admin.resource_employer:
        class: App\Admin\ResourceEmployerAdmin
        calls:
            - [setTemplate, ['list', 'admin/resourceEmployerAdmin.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\ResourceEmployer, controller: ~, manager_type: orm, group: admin, label: Gestion des employés }


    admin.categories_produit_boutique:
        class: App\Admin\CategoriesProduitBoutiqueAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\CategoriesProduitBoutique, controller: ~, manager_type: orm, group: admin, label: Categories Boutique }

    admin.produits_boutique:
        class: App\Admin\ProduitsBoutiqueAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ProduitsBoutique, controller: ~, manager_type: orm, group: admin, label: Produits Boutique }

    admin.prescripteur:
        class: App\Admin\PrescripteurAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Prescripteur, controller: App\Controller\ActionController, manager_type: orm, group: admin, label: Gestion des prescripteurs }

    admin.vente:
        class: App\Admin\VenteAdmin
        calls:
            - [setTemplate, ['list', 'admin/venteListing.html.twig']]
            - [setTemplate, ['edit', 'admin/vente.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\Vente, controller: App\Controller\ActionController , manager_type: orm, group: admin, label: Gestion des ventes }

    admin.vente_detail:
        class: App\Admin\VenteDetailAdmin
        tags:
            - { default: true, name: sonata.admin, model_class: App\Entity\VenteDetail, controller: ~, manager_type: orm, group: admin, label: Vente Detail }

    admin.vente_paiement:
        class: App\Admin\VentePaiementAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\VentePaiement, controller: ~, manager_type: orm, group: admin, label: Vente Paiement }

    admin.planning:
        class: App\Admin\PlanningAdmin
        calls:
            - [setTemplate, ['list', 'admin/_calendar.html.twig']]
        tags:
            - { name: sonata.admin, model_class: 'App\Entity\Vente', controller: ~, manager_type: orm, group: admin, label: Planning Natea }

    admin.resource_employe_conges:
        class: App\Admin\ResourceEmployeCongesAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ResourceEmployeConges, controller: ~, manager_type: orm, group: admin, label: ResourceEmployeConges }

    admin.prescripteur_commission:
        class: App\Admin\PrescripteurCommissionAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\PrescripteurCommission, controller: ~, manager_type: orm, group: admin, label: PrescripteurCommission }

    admin.prescripteur_commission_product:
        class: App\Admin\PrescripteurCommissionProductAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\PrescripteurCommissionProduct, controller: ~, manager_type: orm, group: admin, label: PrescripteurCommissionProduct }

    admin.type_prescripteur:
        class: App\Admin\TypePrescripteurAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\TypePrescripteur, controller: ~, manager_type: orm, group: admin, label: Type Prescripteur }

    admin.type_depenses:
        class: App\Admin\TypeDepensesAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\TypeDepenses, controller: ~, manager_type: orm, group: admin, label: Type depenses }

    admin.charges:
        class: App\Admin\ChargesAdmin
        calls:
            - [setTemplate, ['list', 'admin/charges.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\Charges, controller: ~, manager_type: orm, group: admin, label: Gestion des Charges }

    admin.ressource_employe_heuresup:
        class: App\Admin\RessourceEmployeHeuresupAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\RessourceEmployeHeuresup, controller: ~, manager_type: orm, group: admin, label: RessourceEmployeHeuresup }

    admin.product_commission:
        class: App\Admin\ProductCommissionAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ProductCommission, controller: ~, manager_type: orm, group: admin, label: Commission prescripteur }

    admin.tarif_airport:
        class: App\Admin\TarifAirportAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\TarifAirport, controller: ~, manager_type: orm, group: admin, label: TarifAirport }

    admin.canaux:
        class: App\Admin\CanauxAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Canaux, controller: ~, manager_type: orm, group: admin, label: Canaux }

    admin.reservant:
        class: App\Admin\ReservantAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Reservant, controller: App\Controller\ActionController , manager_type: orm, group: admin, label: Clients }

    admin.reservation_amazight:
        class: App\Admin\ReservationAmazightAdmin
        calls:
            - [setTemplate, ['show', 'admin/_show_order.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\Reservations, controller: App\Controller\ActionController, manager_type: orm, group: admin, label: Réservations Amazigh }

    admin.planing_amazight:
        class: App\Admin\PlaningAmazightAdmin
        calls:
            - [setTemplate, ['list', 'admin/_calendar.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\Vente, controller: ~, manager_type: orm, group: admin, label: Planning amazigh }

    admin.slider:
        class: App\Admin\SliderAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Slider, controller: ~, manager_type: orm, group: admin, label: Slider }

    admin.abonnement:
        class: App\Admin\AbonnementAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\Abonnement, controller: ~, manager_type: orm, group: admin, label: Abonnement Prestation }

    admin.abonnement_product:
        class: App\Admin\AbonnementProductAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\AbonnementProduct, controller: ~, manager_type: orm, group: admin, label: AbonnementProduct }

    admin.resa_abonnement:
        class: App\Admin\ResaAbonnementAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ResaAbonnement, controller: ~, manager_type: orm, group: admin, label: Réservations Abonnement }

    admin.chat_gpt_config:
        class: App\Admin\ChatGptConfigAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ChatGptConfig, controller: ~, manager_type: orm, group: admin, label: Configuration }

    admin.chat_gpt_working:
        class: App\Admin\ChatGptWorkingAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ChatGptWorking, controller: ~, manager_type: orm, group: admin, label: ChatGptWorking }

    admin.chat_gpt:
        class: App\Admin\ChatGptAdmin
        tags:
            - { name: sonata.admin, model_class: App\Entity\ChatGpt, controller: ~, manager_type: orm, group: admin, label: Prompt }


    admin.whatsapp_conversations:
        class: App\Admin\WhatsappConversationsAdmin
        calls:
            - [setTemplate, ['show', 'admin/whatsappListing.html.twig']]
        tags:
            - { name: sonata.admin, model_class: App\Entity\WhatsappConversations, controller: ~, manager_type: orm, group: admin, label: Suivi des envois }