<?php

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

use App\Events\Company\CreateNotificationEvent;
use App\Listeners\Company\CreateNotificationByRequestListener;

use App\Events\Company\UpdateDateOfProjectWorkerTimeSheetEvent;
use App\Listeners\Company\UpdateDateOfProjectWorkerTimeSheetListener;

use App\Events\Company\DeleteAssignedAvailabilityEvent;
use App\Listeners\Company\DeleteAssignedAvailabilityListener;

use App\Events\Company\UpdateAssignedAvailabilityStartDateEvent;
use App\Events\Company\UpdateAssignedAvailabilityEndDateEvent;
use App\Listeners\Company\UpdateAssignedAvailabilityListener;

use App\Events\Company\ProjectWorkerAssignmentEvent;
use App\Listeners\Company\ProjectWorkerAssignmentListener;

use App\Events\Company\WorkerRateUpdatedEvent;
use App\Listeners\Company\UpdateSearchByWorkerRateUpdateListener;

use App\Events\Company\CreateSearchWorkerEvent;
use App\Listeners\Company\CreateSearchWorkerListener;

use App\Events\Company\UpdateSearchDataOnReservedWorker;
use App\Listeners\Company\UpdateSearchDataOnReservedListener;

use App\Events\Company\RequestWorkerApprovedEvent;
use App\Listeners\Company\RequestWorkerApprovedListener;

use App\Events\Company\InvoiceUpdateEvent;
use App\Listeners\Company\InvoiceUpdateNotificationListener;
use App\Listeners\Company\CalculateOutstandingByHoursRenderedListener;

use App\Events\Company\ApprovedTimesheetEvent;
use App\Listeners\Company\ApprovedTimesheetListener;
use App\Listeners\Company\CalculateProjectDailyExpenseListener;

use App\Events\Company\BorrowBillingNotificationEvent;
use App\Listeners\Company\BorrowBillingNotificationListener;

use App\Events\Company\LoanBillingNotificationEvent;
use App\Listeners\Company\LoanBillingNotificationListener;

use App\Events\Company\BulkUpdateBillableRateEvent;
use App\Listeners\Company\BulkUpdateBillableRateListener;

use App\Events\Company\Borrow\NotifyCompanyForWorkerRatingEvent;
use App\Listeners\Company\Borrow\NotifyCompanyForWorkerRatingListener;

use App\Events\Company\Borrow\AggregateWorkerRatingEvent;
use App\Listeners\Company\Borrow\AggregateWorkerRatingListener;

use App\Events\Company\Admin\NotificationForApprovedPaymentEvent;
use App\Listeners\Company\Admin\NotificationForApprovedPaymentListener;

use App\Events\Company\Rating\ProcessAggregateCompanyRatingEvent;
use App\Listeners\Company\Rating\ProcessAggregateCompanyRatingListener;

use App\Events\Company\WorkerRequest\NotificationOnNewAddedWorkerRequestEvent;
use App\Listeners\Company\WorkerRequest\NotificationOnNewAddedWorkerRequestListener;

use App\Events\Company\PusherNotificationEvent;
use App\Listeners\Company\PusherNotificationEventListener;

//  ADMIN EVENTS
use App\Events\Admin\ChangeCompanyServiceChargeEvent;
use App\Listeners\Admin\UpdateSearchByCompanyServiceChargeListener;

use App\Events\Admin\ChangeCompanyStatusEvent;
use App\Listeners\Admin\UpdateSearchByCompanyStatusListener;

use App\Events\Admin\NotifyTransactedCompanyOfBlockedCompanyEvent;
use App\Listeners\Admin\NotifyTransactedCompanyOfBlockedCompanyListener;


//  JOBSEEKER EVENTS
use App\Events\Jobseeker\CreateSearchDataForNewlyAcceptedWorkerEvent;
use App\Listeners\Jobseeker\CreateSearchDataForNewlyAcceptedWorkerListener;

//  JPWA EVENTS
use App\Events\Mobile\CreateSearchDataForInvitedWorkerEvent;
use App\Listeners\Mobile\CreateSearchDataForInvitedWorkerListener;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],

        CreateNotificationEvent::class => [
            CreateNotificationByRequestListener::class
        ],

        UpdateDateOfProjectWorkerTimeSheetEvent::class => [
            UpdateDateOfProjectWorkerTimeSheetListener::class
        ],

        DeleteAssignedAvailabilityEvent::class => [
            DeleteAssignedAvailabilityListener::class
        ],

        ProjectWorkerAssignmentEvent::class => [
            ProjectWorkerAssignmentListener::class
        ],

        WorkerRateUpdatedEvent::class => [
            UpdateSearchByWorkerRateUpdateListener::class
        ],

        CreateSearchWorkerEvent::class => [
            CreateSearchWorkerListener::class
        ],

        UpdateSearchDataOnReservedWorker::class => [
            UpdateSearchDataOnReservedListener::class
        ],

        RequestWorkerApprovedEvent::class => [
            RequestWorkerApprovedListener::class
        ],

        InvoiceUpdateEvent::class => [
            InvoiceUpdateNotificationListener::class,
            CalculateOutstandingByHoursRenderedListener::class
        ],

        ApprovedTimesheetEvent::class => [
            CalculateProjectDailyExpenseListener::class,
            ApprovedTimesheetListener::class
        ],

        BorrowBillingNotificationEvent::class => [
            BorrowBillingNotificationListener::class,
        ],

        LoanBillingNotificationEvent::class => [
            LoanBillingNotificationListener::class,
        ],

        BulkUpdateBillableRateEvent::class => [
            BulkUpdateBillableRateListener::class,
        ],

        NotifyCompanyForWorkerRatingEvent::class => [
            NotifyCompanyForWorkerRatingListener::class,
        ],

        AggregateWorkerRatingEvent::class => [
            AggregateWorkerRatingListener::class,
        ],

        AggregateWorkerRatingEvent::class => [
            AggregateWorkerRatingListener::class,
        ],

        ProcessAggregateCompanyRatingEvent::class => [
            ProcessAggregateCompanyRatingListener::class,
        ],

        NotificationForApprovedPaymentEvent::class => [
            NotificationForApprovedPaymentListener::class,
        ],

        NotificationOnNewAddedWorkerRequestEvent::class => [
            NotificationOnNewAddedWorkerRequestListener::class,
        ],

        PusherNotificationEvent::class => [
            PusherNotificationEventListener::class,
        ],

        // ADMIN
        ChangeCompanyServiceChargeEvent::class => [
            UpdateSearchByCompanyServiceChargeListener::class
        ],

        ChangeCompanyStatusEvent::class => [
            UpdateSearchByCompanyStatusListener::class
       ],

       NotifyTransactedCompanyOfBlockedCompanyEvent::class => [
            NotifyTransactedCompanyOfBlockedCompanyListener::class
        ],

        //JOBSEEKER
        CreateSearchDataForNewlyAcceptedWorkerEvent::class => [
            CreateSearchDataForNewlyAcceptedWorkerListener::class
        ],

        // PWA EVENTS
        CreateSearchDataForInvitedWorkerEvent::class => [
            CreateSearchDataForInvitedWorkerListener::class
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        Event::listen(
            UpdateAssignedAvailabilityStartDateEvent::class,
            [UpdateAssignedAvailabilityListener::class, 'updateAssignedAvailabilityStartDate']
        );
        Event::listen(
            UpdateAssignedAvailabilityEndDateEvent::class,
            [UpdateAssignedAvailabilityListener::class, 'updateAssignedAvailabilityEndDate']
        );
    }

    /**
     * Determine if events and listeners should be automatically discovered.
     *
     * @return bool
     */
    public function shouldDiscoverEvents()
    {
        return false;
    }
}
