<?php

namespace App\Support\ActivityLog;

use App\Models\Attendance;
use App\Models\CashAccount;
use App\Models\CashTransaction;
use App\Models\Category;
use App\Models\Customer;
use App\Models\Cutting;
use App\Models\CuttingMaterial;
use App\Models\CuttingResult;
use App\Models\CuttingResultPrice;
use App\Models\Employee;
use App\Models\EmployeeAdvance;
use App\Models\Expense;
use App\Models\LeaveRequest;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Payroll;
use App\Models\PayrollAdjustment;
use App\Models\PayrollPeriod;
use App\Models\Product;
use App\Models\ProductVariant;
use App\Models\Purchase;
use App\Models\PurchaseItem;
use App\Models\RawMaterial;
use App\Models\RawMaterialPrice;
use App\Models\Rejection;
use App\Models\Supplier;
use App\Models\SystemConfiguration;
use App\Models\User;
use App\Models\UserProfile;
use App\Settings\MarketplaceSettings;

class ModelLabel
{
    /**
     * @var array<class-string, string>
     */
    private const LABELS = [
        Attendance::class => 'Presensi',
        CashAccount::class => 'Akun Kas',
        CashTransaction::class => 'Transaksi Kas',
        Category::class => 'Kategori',
        Customer::class => 'Pelanggan',
        Cutting::class => 'Cutting',
        CuttingMaterial::class => 'Bahan Cutting',
        CuttingResult::class => 'Hasil Cutting',
        CuttingResultPrice::class => 'Harga Hasil Cutting',
        Employee::class => 'Pegawai',
        EmployeeAdvance::class => 'Kasbon',
        Expense::class => 'Pengeluaran',
        LeaveRequest::class => 'Pengajuan Cuti',
        Order::class => 'Pesanan',
        OrderItem::class => 'Item Pesanan',
        Payroll::class => 'Gaji',
        PayrollAdjustment::class => 'Penyesuaian Gaji',
        PayrollPeriod::class => 'Periode Gaji',
        Product::class => 'Produk',
        ProductVariant::class => 'Varian Produk',
        Purchase::class => 'Belanja',
        PurchaseItem::class => 'Item Belanja',
        RawMaterial::class => 'Bahan Baku',
        RawMaterialPrice::class => 'Harga Bahan Baku',
        Rejection::class => 'Penolakan',
        Supplier::class => 'Supplier',
        SystemConfiguration::class => 'Konfigurasi Sistem',
        User::class => 'Pengguna',
        UserProfile::class => 'Profil Pengguna',
        MarketplaceSettings::class => 'Pengaturan Marketplace',
    ];

    public static function for(?string $modelClass): string
    {
        if ($modelClass === null) {
            return '-';
        }

        return self::LABELS[$modelClass] ?? class_basename($modelClass);
    }

    /**
     * @return list<array{value: string, label: string}>
     */
    public static function selectOptions(): array
    {
        return collect(self::LABELS)
            ->map(fn (string $label, string $class) => [
                'value' => $class,
                'label' => $label,
            ])
            ->sortBy('label')
            ->values()
            ->all();
    }
}
