<?php

namespace Opencart\Extension\Alsendo\Providers;

class PickupLabelProvider
{
    private object $language;
    private ?string $regionCode;

    public function __construct(
        object $language,
        ?string $regionCode
    ) {
        $this->language = $language;
        $this->regionCode = $regionCode;
    }

    public function getPickupTypeLabels(): array
    {
        $ondemandText = $this->language->get('text_package_pickup_type_on_demand');
        $occasionalText = $this->language->get('text_package_pickup_type_occasional');

        if ($this->regionCode === 'czechia') {
            $ondemandText = $this->language->get('text_package_pickup_type_self_printed_label');
            $occasionalText = $this->language->get('text_package_pickup_type_label_provided_by_courier');
        }

        return [
            'SELF' => $this->language->get('text_package_pickup_type_self'),
            'COURIER' => $this->language->get('text_package_pickup_type_courier'),
            'NO_PICKUP' => $this->language->get('text_package_pickup_type_no_pickup'),
            'OCCASIONAL' => $occasionalText,
            'ON_DEMAND' => $this->language->get('text_package_pickup_type_on_demand'),
            'ONDEMAND' => $ondemandText,
            'REGULAR' => $this->language->get('text_package_pickup_type_regular'),
            'courier' => $this->language->get('text_package_pickup_type_courier'),
            'self' => $this->language->get('text_package_pickup_type_self'),
        ];
    }

    public function getLabel(?string $pickupType): ?string
    {
        if ($pickupType === null) {
            return null;
        }

        $pickupLabels = $this->getPickupTypeLabels();

        if (isset($pickupLabels[$pickupType])) {
            return $pickupLabels[$pickupType];
        }

        return null;
    }
} 