<?php

namespace App\Data;

class Countries
{
    /**
     * All countries keyed by ISO2 code.
     * Fields: name, iso2, iso3, flag, dial_code, timezone, currency
     */
    public static function all(): array
    {
        // Return lowercase ISO2 code — used as the fi fi-{code} CSS class (flag-icons library)
        $f = fn(string $c): string => strtolower($c);

        return [

            // ── AFRICA ──────────────────────────────────────────────────────────
            'DZ' => ['name'=>'Algeria',                   'iso2'=>'DZ','iso3'=>'DZA','flag'=>$f('DZ'),'dial_code'=>'+213', 'timezone'=>'Africa/Algiers',         'currency'=>'DZD'],
            'AO' => ['name'=>'Angola',                    'iso2'=>'AO','iso3'=>'AGO','flag'=>$f('AO'),'dial_code'=>'+244', 'timezone'=>'Africa/Luanda',           'currency'=>'AOA'],
            'BJ' => ['name'=>'Benin',                     'iso2'=>'BJ','iso3'=>'BEN','flag'=>$f('BJ'),'dial_code'=>'+229', 'timezone'=>'Africa/Porto-Novo',       'currency'=>'XOF'],
            'BW' => ['name'=>'Botswana',                  'iso2'=>'BW','iso3'=>'BWA','flag'=>$f('BW'),'dial_code'=>'+267', 'timezone'=>'Africa/Gaborone',         'currency'=>'BWP'],
            'BF' => ['name'=>'Burkina Faso',              'iso2'=>'BF','iso3'=>'BFA','flag'=>$f('BF'),'dial_code'=>'+226', 'timezone'=>'Africa/Ouagadougou',      'currency'=>'XOF'],
            'BI' => ['name'=>'Burundi',                   'iso2'=>'BI','iso3'=>'BDI','flag'=>$f('BI'),'dial_code'=>'+257', 'timezone'=>'Africa/Bujumbura',        'currency'=>'BIF'],
            'CV' => ['name'=>'Cabo Verde',                'iso2'=>'CV','iso3'=>'CPV','flag'=>$f('CV'),'dial_code'=>'+238', 'timezone'=>'Atlantic/Cape_Verde',     'currency'=>'CVE'],
            'CM' => ['name'=>'Cameroon',                  'iso2'=>'CM','iso3'=>'CMR','flag'=>$f('CM'),'dial_code'=>'+237', 'timezone'=>'Africa/Douala',           'currency'=>'XAF'],
            'CF' => ['name'=>'Central African Republic',  'iso2'=>'CF','iso3'=>'CAF','flag'=>$f('CF'),'dial_code'=>'+236', 'timezone'=>'Africa/Bangui',           'currency'=>'XAF'],
            'TD' => ['name'=>'Chad',                      'iso2'=>'TD','iso3'=>'TCD','flag'=>$f('TD'),'dial_code'=>'+235', 'timezone'=>'Africa/Ndjamena',         'currency'=>'XAF'],
            'KM' => ['name'=>'Comoros',                   'iso2'=>'KM','iso3'=>'COM','flag'=>$f('KM'),'dial_code'=>'+269', 'timezone'=>'Indian/Comoro',           'currency'=>'KMF'],
            'CD' => ['name'=>'Congo (DRC)',                'iso2'=>'CD','iso3'=>'COD','flag'=>$f('CD'),'dial_code'=>'+243', 'timezone'=>'Africa/Kinshasa',         'currency'=>'CDF'],
            'CG' => ['name'=>'Congo (Republic)',           'iso2'=>'CG','iso3'=>'COG','flag'=>$f('CG'),'dial_code'=>'+242', 'timezone'=>'Africa/Brazzaville',      'currency'=>'XAF'],
            'DJ' => ['name'=>'Djibouti',                  'iso2'=>'DJ','iso3'=>'DJI','flag'=>$f('DJ'),'dial_code'=>'+253', 'timezone'=>'Africa/Djibouti',         'currency'=>'DJF'],
            'EG' => ['name'=>'Egypt',                     'iso2'=>'EG','iso3'=>'EGY','flag'=>$f('EG'),'dial_code'=>'+20',  'timezone'=>'Africa/Cairo',            'currency'=>'EGP'],
            'GQ' => ['name'=>'Equatorial Guinea',         'iso2'=>'GQ','iso3'=>'GNQ','flag'=>$f('GQ'),'dial_code'=>'+240', 'timezone'=>'Africa/Malabo',           'currency'=>'XAF'],
            'ER' => ['name'=>'Eritrea',                   'iso2'=>'ER','iso3'=>'ERI','flag'=>$f('ER'),'dial_code'=>'+291', 'timezone'=>'Africa/Asmara',           'currency'=>'ERN'],
            'SZ' => ['name'=>'Eswatini',                  'iso2'=>'SZ','iso3'=>'SWZ','flag'=>$f('SZ'),'dial_code'=>'+268', 'timezone'=>'Africa/Mbabane',          'currency'=>'SZL'],
            'ET' => ['name'=>'Ethiopia',                  'iso2'=>'ET','iso3'=>'ETH','flag'=>$f('ET'),'dial_code'=>'+251', 'timezone'=>'Africa/Addis_Ababa',      'currency'=>'ETB'],
            'GA' => ['name'=>'Gabon',                     'iso2'=>'GA','iso3'=>'GAB','flag'=>$f('GA'),'dial_code'=>'+241', 'timezone'=>'Africa/Libreville',       'currency'=>'XAF'],
            'GM' => ['name'=>'Gambia',                    'iso2'=>'GM','iso3'=>'GMB','flag'=>$f('GM'),'dial_code'=>'+220', 'timezone'=>'Africa/Banjul',           'currency'=>'GMD'],
            'GH' => ['name'=>'Ghana',                     'iso2'=>'GH','iso3'=>'GHA','flag'=>$f('GH'),'dial_code'=>'+233', 'timezone'=>'Africa/Accra',            'currency'=>'GHS'],
            'GN' => ['name'=>'Guinea',                    'iso2'=>'GN','iso3'=>'GIN','flag'=>$f('GN'),'dial_code'=>'+224', 'timezone'=>'Africa/Conakry',          'currency'=>'GNF'],
            'GW' => ['name'=>'Guinea-Bissau',             'iso2'=>'GW','iso3'=>'GNB','flag'=>$f('GW'),'dial_code'=>'+245', 'timezone'=>'Africa/Bissau',           'currency'=>'XOF'],
            'CI' => ['name'=>'Ivory Coast',               'iso2'=>'CI','iso3'=>'CIV','flag'=>$f('CI'),'dial_code'=>'+225', 'timezone'=>'Africa/Abidjan',          'currency'=>'XOF'],
            'KE' => ['name'=>'Kenya',                     'iso2'=>'KE','iso3'=>'KEN','flag'=>$f('KE'),'dial_code'=>'+254', 'timezone'=>'Africa/Nairobi',          'currency'=>'KES'],
            'LS' => ['name'=>'Lesotho',                   'iso2'=>'LS','iso3'=>'LSO','flag'=>$f('LS'),'dial_code'=>'+266', 'timezone'=>'Africa/Maseru',           'currency'=>'LSL'],
            'LR' => ['name'=>'Liberia',                   'iso2'=>'LR','iso3'=>'LBR','flag'=>$f('LR'),'dial_code'=>'+231', 'timezone'=>'Africa/Monrovia',         'currency'=>'LRD'],
            'LY' => ['name'=>'Libya',                     'iso2'=>'LY','iso3'=>'LBY','flag'=>$f('LY'),'dial_code'=>'+218', 'timezone'=>'Africa/Tripoli',          'currency'=>'LYD'],
            'MG' => ['name'=>'Madagascar',                'iso2'=>'MG','iso3'=>'MDG','flag'=>$f('MG'),'dial_code'=>'+261', 'timezone'=>'Indian/Antananarivo',     'currency'=>'MGA'],
            'MW' => ['name'=>'Malawi',                    'iso2'=>'MW','iso3'=>'MWI','flag'=>$f('MW'),'dial_code'=>'+265', 'timezone'=>'Africa/Blantyre',         'currency'=>'MWK'],
            'ML' => ['name'=>'Mali',                      'iso2'=>'ML','iso3'=>'MLI','flag'=>$f('ML'),'dial_code'=>'+223', 'timezone'=>'Africa/Bamako',           'currency'=>'XOF'],
            'MR' => ['name'=>'Mauritania',                'iso2'=>'MR','iso3'=>'MRT','flag'=>$f('MR'),'dial_code'=>'+222', 'timezone'=>'Africa/Nouakchott',       'currency'=>'MRU'],
            'MU' => ['name'=>'Mauritius',                 'iso2'=>'MU','iso3'=>'MUS','flag'=>$f('MU'),'dial_code'=>'+230', 'timezone'=>'Indian/Mauritius',        'currency'=>'MUR'],
            'MA' => ['name'=>'Morocco',                   'iso2'=>'MA','iso3'=>'MAR','flag'=>$f('MA'),'dial_code'=>'+212', 'timezone'=>'Africa/Casablanca',       'currency'=>'MAD'],
            'MZ' => ['name'=>'Mozambique',                'iso2'=>'MZ','iso3'=>'MOZ','flag'=>$f('MZ'),'dial_code'=>'+258', 'timezone'=>'Africa/Maputo',           'currency'=>'MZN'],
            'NA' => ['name'=>'Namibia',                   'iso2'=>'NA','iso3'=>'NAM','flag'=>$f('NA'),'dial_code'=>'+264', 'timezone'=>'Africa/Windhoek',         'currency'=>'NAD'],
            'NE' => ['name'=>'Niger',                     'iso2'=>'NE','iso3'=>'NER','flag'=>$f('NE'),'dial_code'=>'+227', 'timezone'=>'Africa/Niamey',           'currency'=>'XOF'],
            'NG' => ['name'=>'Nigeria',                   'iso2'=>'NG','iso3'=>'NGA','flag'=>$f('NG'),'dial_code'=>'+234', 'timezone'=>'Africa/Lagos',            'currency'=>'NGN'],
            'RW' => ['name'=>'Rwanda',                    'iso2'=>'RW','iso3'=>'RWA','flag'=>$f('RW'),'dial_code'=>'+250', 'timezone'=>'Africa/Kigali',           'currency'=>'RWF'],
            'ST' => ['name'=>'São Tomé & Príncipe',       'iso2'=>'ST','iso3'=>'STP','flag'=>$f('ST'),'dial_code'=>'+239', 'timezone'=>'Africa/Sao_Tome',         'currency'=>'STN'],
            'SN' => ['name'=>'Senegal',                   'iso2'=>'SN','iso3'=>'SEN','flag'=>$f('SN'),'dial_code'=>'+221', 'timezone'=>'Africa/Dakar',            'currency'=>'XOF'],
            'SC' => ['name'=>'Seychelles',                'iso2'=>'SC','iso3'=>'SYC','flag'=>$f('SC'),'dial_code'=>'+248', 'timezone'=>'Indian/Mahe',             'currency'=>'SCR'],
            'SL' => ['name'=>'Sierra Leone',              'iso2'=>'SL','iso3'=>'SLE','flag'=>$f('SL'),'dial_code'=>'+232', 'timezone'=>'Africa/Freetown',         'currency'=>'SLL'],
            'SO' => ['name'=>'Somalia',                   'iso2'=>'SO','iso3'=>'SOM','flag'=>$f('SO'),'dial_code'=>'+252', 'timezone'=>'Africa/Mogadishu',        'currency'=>'SOS'],
            'ZA' => ['name'=>'South Africa',              'iso2'=>'ZA','iso3'=>'ZAF','flag'=>$f('ZA'),'dial_code'=>'+27',  'timezone'=>'Africa/Johannesburg',     'currency'=>'ZAR'],
            'SS' => ['name'=>'South Sudan',               'iso2'=>'SS','iso3'=>'SSD','flag'=>$f('SS'),'dial_code'=>'+211', 'timezone'=>'Africa/Juba',             'currency'=>'SSP'],
            'SD' => ['name'=>'Sudan',                     'iso2'=>'SD','iso3'=>'SDN','flag'=>$f('SD'),'dial_code'=>'+249', 'timezone'=>'Africa/Khartoum',         'currency'=>'SDG'],
            'TZ' => ['name'=>'Tanzania',                  'iso2'=>'TZ','iso3'=>'TZA','flag'=>$f('TZ'),'dial_code'=>'+255', 'timezone'=>'Africa/Dar_es_Salaam',    'currency'=>'TZS'],
            'TG' => ['name'=>'Togo',                      'iso2'=>'TG','iso3'=>'TGO','flag'=>$f('TG'),'dial_code'=>'+228', 'timezone'=>'Africa/Lome',             'currency'=>'XOF'],
            'TN' => ['name'=>'Tunisia',                   'iso2'=>'TN','iso3'=>'TUN','flag'=>$f('TN'),'dial_code'=>'+216', 'timezone'=>'Africa/Tunis',            'currency'=>'TND'],
            'UG' => ['name'=>'Uganda',                    'iso2'=>'UG','iso3'=>'UGA','flag'=>$f('UG'),'dial_code'=>'+256', 'timezone'=>'Africa/Kampala',          'currency'=>'UGX'],
            'ZM' => ['name'=>'Zambia',                    'iso2'=>'ZM','iso3'=>'ZMB','flag'=>$f('ZM'),'dial_code'=>'+260', 'timezone'=>'Africa/Lusaka',           'currency'=>'ZMW'],
            'ZW' => ['name'=>'Zimbabwe',                  'iso2'=>'ZW','iso3'=>'ZWE','flag'=>$f('ZW'),'dial_code'=>'+263', 'timezone'=>'Africa/Harare',           'currency'=>'ZWL'],

            // ── AMERICAS ─────────────────────────────────────────────────────────
            'AG' => ['name'=>'Antigua & Barbuda',         'iso2'=>'AG','iso3'=>'ATG','flag'=>$f('AG'),'dial_code'=>'+1',   'timezone'=>'America/Antigua',              'currency'=>'XCD'],
            'AR' => ['name'=>'Argentina',                 'iso2'=>'AR','iso3'=>'ARG','flag'=>$f('AR'),'dial_code'=>'+54',  'timezone'=>'America/Argentina/Buenos_Aires','currency'=>'ARS'],
            'BS' => ['name'=>'Bahamas',                   'iso2'=>'BS','iso3'=>'BHS','flag'=>$f('BS'),'dial_code'=>'+1',   'timezone'=>'America/Nassau',               'currency'=>'BSD'],
            'BB' => ['name'=>'Barbados',                  'iso2'=>'BB','iso3'=>'BRB','flag'=>$f('BB'),'dial_code'=>'+1',   'timezone'=>'America/Barbados',             'currency'=>'BBD'],
            'BZ' => ['name'=>'Belize',                    'iso2'=>'BZ','iso3'=>'BLZ','flag'=>$f('BZ'),'dial_code'=>'+501', 'timezone'=>'America/Belize',               'currency'=>'BZD'],
            'BO' => ['name'=>'Bolivia',                   'iso2'=>'BO','iso3'=>'BOL','flag'=>$f('BO'),'dial_code'=>'+591', 'timezone'=>'America/La_Paz',               'currency'=>'BOB'],
            'BR' => ['name'=>'Brazil',                    'iso2'=>'BR','iso3'=>'BRA','flag'=>$f('BR'),'dial_code'=>'+55',  'timezone'=>'America/Sao_Paulo',            'currency'=>'BRL'],
            'CA' => ['name'=>'Canada',                    'iso2'=>'CA','iso3'=>'CAN','flag'=>$f('CA'),'dial_code'=>'+1',   'timezone'=>'America/Toronto',              'currency'=>'CAD'],
            'CL' => ['name'=>'Chile',                     'iso2'=>'CL','iso3'=>'CHL','flag'=>$f('CL'),'dial_code'=>'+56',  'timezone'=>'America/Santiago',             'currency'=>'CLP'],
            'CO' => ['name'=>'Colombia',                  'iso2'=>'CO','iso3'=>'COL','flag'=>$f('CO'),'dial_code'=>'+57',  'timezone'=>'America/Bogota',               'currency'=>'COP'],
            'CR' => ['name'=>'Costa Rica',                'iso2'=>'CR','iso3'=>'CRI','flag'=>$f('CR'),'dial_code'=>'+506', 'timezone'=>'America/Costa_Rica',           'currency'=>'CRC'],
            'CU' => ['name'=>'Cuba',                      'iso2'=>'CU','iso3'=>'CUB','flag'=>$f('CU'),'dial_code'=>'+53',  'timezone'=>'America/Havana',               'currency'=>'CUP'],
            'DM' => ['name'=>'Dominica',                  'iso2'=>'DM','iso3'=>'DMA','flag'=>$f('DM'),'dial_code'=>'+1',   'timezone'=>'America/Dominica',             'currency'=>'XCD'],
            'DO' => ['name'=>'Dominican Republic',        'iso2'=>'DO','iso3'=>'DOM','flag'=>$f('DO'),'dial_code'=>'+1',   'timezone'=>'America/Santo_Domingo',        'currency'=>'DOP'],
            'EC' => ['name'=>'Ecuador',                   'iso2'=>'EC','iso3'=>'ECU','flag'=>$f('EC'),'dial_code'=>'+593', 'timezone'=>'America/Guayaquil',            'currency'=>'USD'],
            'SV' => ['name'=>'El Salvador',               'iso2'=>'SV','iso3'=>'SLV','flag'=>$f('SV'),'dial_code'=>'+503', 'timezone'=>'America/El_Salvador',          'currency'=>'USD'],
            'GD' => ['name'=>'Grenada',                   'iso2'=>'GD','iso3'=>'GRD','flag'=>$f('GD'),'dial_code'=>'+1',   'timezone'=>'America/Grenada',              'currency'=>'XCD'],
            'GT' => ['name'=>'Guatemala',                 'iso2'=>'GT','iso3'=>'GTM','flag'=>$f('GT'),'dial_code'=>'+502', 'timezone'=>'America/Guatemala',            'currency'=>'GTQ'],
            'GY' => ['name'=>'Guyana',                    'iso2'=>'GY','iso3'=>'GUY','flag'=>$f('GY'),'dial_code'=>'+592', 'timezone'=>'America/Guyana',               'currency'=>'GYD'],
            'HT' => ['name'=>'Haiti',                     'iso2'=>'HT','iso3'=>'HTI','flag'=>$f('HT'),'dial_code'=>'+509', 'timezone'=>'America/Port-au-Prince',       'currency'=>'HTG'],
            'HN' => ['name'=>'Honduras',                  'iso2'=>'HN','iso3'=>'HND','flag'=>$f('HN'),'dial_code'=>'+504', 'timezone'=>'America/Tegucigalpa',          'currency'=>'HNL'],
            'JM' => ['name'=>'Jamaica',                   'iso2'=>'JM','iso3'=>'JAM','flag'=>$f('JM'),'dial_code'=>'+1',   'timezone'=>'America/Jamaica',              'currency'=>'JMD'],
            'MX' => ['name'=>'Mexico',                    'iso2'=>'MX','iso3'=>'MEX','flag'=>$f('MX'),'dial_code'=>'+52',  'timezone'=>'America/Mexico_City',          'currency'=>'MXN'],
            'NI' => ['name'=>'Nicaragua',                 'iso2'=>'NI','iso3'=>'NIC','flag'=>$f('NI'),'dial_code'=>'+505', 'timezone'=>'America/Managua',              'currency'=>'NIO'],
            'PA' => ['name'=>'Panama',                    'iso2'=>'PA','iso3'=>'PAN','flag'=>$f('PA'),'dial_code'=>'+507', 'timezone'=>'America/Panama',               'currency'=>'PAB'],
            'PY' => ['name'=>'Paraguay',                  'iso2'=>'PY','iso3'=>'PRY','flag'=>$f('PY'),'dial_code'=>'+595', 'timezone'=>'America/Asuncion',             'currency'=>'PYG'],
            'PE' => ['name'=>'Peru',                      'iso2'=>'PE','iso3'=>'PER','flag'=>$f('PE'),'dial_code'=>'+51',  'timezone'=>'America/Lima',                 'currency'=>'PEN'],
            'KN' => ['name'=>'Saint Kitts & Nevis',       'iso2'=>'KN','iso3'=>'KNA','flag'=>$f('KN'),'dial_code'=>'+1',   'timezone'=>'America/St_Kitts',             'currency'=>'XCD'],
            'LC' => ['name'=>'Saint Lucia',               'iso2'=>'LC','iso3'=>'LCA','flag'=>$f('LC'),'dial_code'=>'+1',   'timezone'=>'America/St_Lucia',             'currency'=>'XCD'],
            'VC' => ['name'=>'Saint Vincent & Grenadines','iso2'=>'VC','iso3'=>'VCT','flag'=>$f('VC'),'dial_code'=>'+1',   'timezone'=>'America/St_Vincent',           'currency'=>'XCD'],
            'SR' => ['name'=>'Suriname',                  'iso2'=>'SR','iso3'=>'SUR','flag'=>$f('SR'),'dial_code'=>'+597', 'timezone'=>'America/Paramaribo',           'currency'=>'SRD'],
            'TT' => ['name'=>'Trinidad & Tobago',         'iso2'=>'TT','iso3'=>'TTO','flag'=>$f('TT'),'dial_code'=>'+1',   'timezone'=>'America/Port_of_Spain',        'currency'=>'TTD'],
            'US' => ['name'=>'United States',             'iso2'=>'US','iso3'=>'USA','flag'=>$f('US'),'dial_code'=>'+1',   'timezone'=>'America/New_York',             'currency'=>'USD'],
            'UY' => ['name'=>'Uruguay',                   'iso2'=>'UY','iso3'=>'URY','flag'=>$f('UY'),'dial_code'=>'+598', 'timezone'=>'America/Montevideo',           'currency'=>'UYU'],
            'VE' => ['name'=>'Venezuela',                 'iso2'=>'VE','iso3'=>'VEN','flag'=>$f('VE'),'dial_code'=>'+58',  'timezone'=>'America/Caracas',              'currency'=>'VES'],

            // ── ASIA & MIDDLE EAST ────────────────────────────────────────────────
            'AF' => ['name'=>'Afghanistan',               'iso2'=>'AF','iso3'=>'AFG','flag'=>$f('AF'),'dial_code'=>'+93',  'timezone'=>'Asia/Kabul',              'currency'=>'AFN'],
            'AM' => ['name'=>'Armenia',                   'iso2'=>'AM','iso3'=>'ARM','flag'=>$f('AM'),'dial_code'=>'+374', 'timezone'=>'Asia/Yerevan',            'currency'=>'AMD'],
            'AZ' => ['name'=>'Azerbaijan',                'iso2'=>'AZ','iso3'=>'AZE','flag'=>$f('AZ'),'dial_code'=>'+994', 'timezone'=>'Asia/Baku',               'currency'=>'AZN'],
            'BH' => ['name'=>'Bahrain',                   'iso2'=>'BH','iso3'=>'BHR','flag'=>$f('BH'),'dial_code'=>'+973', 'timezone'=>'Asia/Bahrain',            'currency'=>'BHD'],
            'BD' => ['name'=>'Bangladesh',                'iso2'=>'BD','iso3'=>'BGD','flag'=>$f('BD'),'dial_code'=>'+880', 'timezone'=>'Asia/Dhaka',              'currency'=>'BDT'],
            'BT' => ['name'=>'Bhutan',                    'iso2'=>'BT','iso3'=>'BTN','flag'=>$f('BT'),'dial_code'=>'+975', 'timezone'=>'Asia/Thimphu',            'currency'=>'BTN'],
            'BN' => ['name'=>'Brunei',                    'iso2'=>'BN','iso3'=>'BRN','flag'=>$f('BN'),'dial_code'=>'+673', 'timezone'=>'Asia/Brunei',             'currency'=>'BND'],
            'KH' => ['name'=>'Cambodia',                  'iso2'=>'KH','iso3'=>'KHM','flag'=>$f('KH'),'dial_code'=>'+855', 'timezone'=>'Asia/Phnom_Penh',         'currency'=>'KHR'],
            'CN' => ['name'=>'China',                     'iso2'=>'CN','iso3'=>'CHN','flag'=>$f('CN'),'dial_code'=>'+86',  'timezone'=>'Asia/Shanghai',           'currency'=>'CNY'],
            'CY' => ['name'=>'Cyprus',                    'iso2'=>'CY','iso3'=>'CYP','flag'=>$f('CY'),'dial_code'=>'+357', 'timezone'=>'Asia/Nicosia',            'currency'=>'EUR'],
            'GE' => ['name'=>'Georgia',                   'iso2'=>'GE','iso3'=>'GEO','flag'=>$f('GE'),'dial_code'=>'+995', 'timezone'=>'Asia/Tbilisi',            'currency'=>'GEL'],
            'HK' => ['name'=>'Hong Kong',                 'iso2'=>'HK','iso3'=>'HKG','flag'=>$f('HK'),'dial_code'=>'+852', 'timezone'=>'Asia/Hong_Kong',          'currency'=>'HKD'],
            'IN' => ['name'=>'India',                     'iso2'=>'IN','iso3'=>'IND','flag'=>$f('IN'),'dial_code'=>'+91',  'timezone'=>'Asia/Kolkata',            'currency'=>'INR'],
            'ID' => ['name'=>'Indonesia',                 'iso2'=>'ID','iso3'=>'IDN','flag'=>$f('ID'),'dial_code'=>'+62',  'timezone'=>'Asia/Jakarta',            'currency'=>'IDR'],
            'IR' => ['name'=>'Iran',                      'iso2'=>'IR','iso3'=>'IRN','flag'=>$f('IR'),'dial_code'=>'+98',  'timezone'=>'Asia/Tehran',             'currency'=>'IRR'],
            'IQ' => ['name'=>'Iraq',                      'iso2'=>'IQ','iso3'=>'IRQ','flag'=>$f('IQ'),'dial_code'=>'+964', 'timezone'=>'Asia/Baghdad',            'currency'=>'IQD'],
            'IL' => ['name'=>'Israel',                    'iso2'=>'IL','iso3'=>'ISR','flag'=>$f('IL'),'dial_code'=>'+972', 'timezone'=>'Asia/Jerusalem',          'currency'=>'ILS'],
            'JP' => ['name'=>'Japan',                     'iso2'=>'JP','iso3'=>'JPN','flag'=>$f('JP'),'dial_code'=>'+81',  'timezone'=>'Asia/Tokyo',              'currency'=>'JPY'],
            'JO' => ['name'=>'Jordan',                    'iso2'=>'JO','iso3'=>'JOR','flag'=>$f('JO'),'dial_code'=>'+962', 'timezone'=>'Asia/Amman',              'currency'=>'JOD'],
            'KZ' => ['name'=>'Kazakhstan',                'iso2'=>'KZ','iso3'=>'KAZ','flag'=>$f('KZ'),'dial_code'=>'+7',   'timezone'=>'Asia/Almaty',             'currency'=>'KZT'],
            'KW' => ['name'=>'Kuwait',                    'iso2'=>'KW','iso3'=>'KWT','flag'=>$f('KW'),'dial_code'=>'+965', 'timezone'=>'Asia/Kuwait',             'currency'=>'KWD'],
            'KG' => ['name'=>'Kyrgyzstan',                'iso2'=>'KG','iso3'=>'KGZ','flag'=>$f('KG'),'dial_code'=>'+996', 'timezone'=>'Asia/Bishkek',            'currency'=>'KGS'],
            'LA' => ['name'=>'Laos',                      'iso2'=>'LA','iso3'=>'LAO','flag'=>$f('LA'),'dial_code'=>'+856', 'timezone'=>'Asia/Vientiane',          'currency'=>'LAK'],
            'LB' => ['name'=>'Lebanon',                   'iso2'=>'LB','iso3'=>'LBN','flag'=>$f('LB'),'dial_code'=>'+961', 'timezone'=>'Asia/Beirut',             'currency'=>'LBP'],
            'MO' => ['name'=>'Macau',                     'iso2'=>'MO','iso3'=>'MAC','flag'=>$f('MO'),'dial_code'=>'+853', 'timezone'=>'Asia/Macau',              'currency'=>'MOP'],
            'MY' => ['name'=>'Malaysia',                  'iso2'=>'MY','iso3'=>'MYS','flag'=>$f('MY'),'dial_code'=>'+60',  'timezone'=>'Asia/Kuala_Lumpur',       'currency'=>'MYR'],
            'MV' => ['name'=>'Maldives',                  'iso2'=>'MV','iso3'=>'MDV','flag'=>$f('MV'),'dial_code'=>'+960', 'timezone'=>'Indian/Maldives',         'currency'=>'MVR'],
            'MN' => ['name'=>'Mongolia',                  'iso2'=>'MN','iso3'=>'MNG','flag'=>$f('MN'),'dial_code'=>'+976', 'timezone'=>'Asia/Ulaanbaatar',        'currency'=>'MNT'],
            'MM' => ['name'=>'Myanmar',                   'iso2'=>'MM','iso3'=>'MMR','flag'=>$f('MM'),'dial_code'=>'+95',  'timezone'=>'Asia/Yangon',             'currency'=>'MMK'],
            'NP' => ['name'=>'Nepal',                     'iso2'=>'NP','iso3'=>'NPL','flag'=>$f('NP'),'dial_code'=>'+977', 'timezone'=>'Asia/Kathmandu',          'currency'=>'NPR'],
            'KP' => ['name'=>'North Korea',               'iso2'=>'KP','iso3'=>'PRK','flag'=>$f('KP'),'dial_code'=>'+850', 'timezone'=>'Asia/Pyongyang',          'currency'=>'KPW'],
            'OM' => ['name'=>'Oman',                      'iso2'=>'OM','iso3'=>'OMN','flag'=>$f('OM'),'dial_code'=>'+968', 'timezone'=>'Asia/Muscat',             'currency'=>'OMR'],
            'PK' => ['name'=>'Pakistan',                  'iso2'=>'PK','iso3'=>'PAK','flag'=>$f('PK'),'dial_code'=>'+92',  'timezone'=>'Asia/Karachi',            'currency'=>'PKR'],
            'PS' => ['name'=>'Palestine',                 'iso2'=>'PS','iso3'=>'PSE','flag'=>$f('PS'),'dial_code'=>'+970', 'timezone'=>'Asia/Hebron',             'currency'=>'ILS'],
            'PH' => ['name'=>'Philippines',               'iso2'=>'PH','iso3'=>'PHL','flag'=>$f('PH'),'dial_code'=>'+63',  'timezone'=>'Asia/Manila',             'currency'=>'PHP'],
            'QA' => ['name'=>'Qatar',                     'iso2'=>'QA','iso3'=>'QAT','flag'=>$f('QA'),'dial_code'=>'+974', 'timezone'=>'Asia/Qatar',              'currency'=>'QAR'],
            'SA' => ['name'=>'Saudi Arabia',              'iso2'=>'SA','iso3'=>'SAU','flag'=>$f('SA'),'dial_code'=>'+966', 'timezone'=>'Asia/Riyadh',             'currency'=>'SAR'],
            'SG' => ['name'=>'Singapore',                 'iso2'=>'SG','iso3'=>'SGP','flag'=>$f('SG'),'dial_code'=>'+65',  'timezone'=>'Asia/Singapore',          'currency'=>'SGD'],
            'KR' => ['name'=>'South Korea',               'iso2'=>'KR','iso3'=>'KOR','flag'=>$f('KR'),'dial_code'=>'+82',  'timezone'=>'Asia/Seoul',              'currency'=>'KRW'],
            'LK' => ['name'=>'Sri Lanka',                 'iso2'=>'LK','iso3'=>'LKA','flag'=>$f('LK'),'dial_code'=>'+94',  'timezone'=>'Asia/Colombo',            'currency'=>'LKR'],
            'SY' => ['name'=>'Syria',                     'iso2'=>'SY','iso3'=>'SYR','flag'=>$f('SY'),'dial_code'=>'+963', 'timezone'=>'Asia/Damascus',           'currency'=>'SYP'],
            'TW' => ['name'=>'Taiwan',                    'iso2'=>'TW','iso3'=>'TWN','flag'=>$f('TW'),'dial_code'=>'+886', 'timezone'=>'Asia/Taipei',             'currency'=>'TWD'],
            'TJ' => ['name'=>'Tajikistan',                'iso2'=>'TJ','iso3'=>'TJK','flag'=>$f('TJ'),'dial_code'=>'+992', 'timezone'=>'Asia/Dushanbe',           'currency'=>'TJS'],
            'TH' => ['name'=>'Thailand',                  'iso2'=>'TH','iso3'=>'THA','flag'=>$f('TH'),'dial_code'=>'+66',  'timezone'=>'Asia/Bangkok',            'currency'=>'THB'],
            'TL' => ['name'=>'Timor-Leste',               'iso2'=>'TL','iso3'=>'TLS','flag'=>$f('TL'),'dial_code'=>'+670', 'timezone'=>'Asia/Dili',               'currency'=>'USD'],
            'TR' => ['name'=>'Turkey',                    'iso2'=>'TR','iso3'=>'TUR','flag'=>$f('TR'),'dial_code'=>'+90',  'timezone'=>'Europe/Istanbul',         'currency'=>'TRY'],
            'TM' => ['name'=>'Turkmenistan',              'iso2'=>'TM','iso3'=>'TKM','flag'=>$f('TM'),'dial_code'=>'+993', 'timezone'=>'Asia/Ashgabat',           'currency'=>'TMT'],
            'AE' => ['name'=>'United Arab Emirates',      'iso2'=>'AE','iso3'=>'ARE','flag'=>$f('AE'),'dial_code'=>'+971', 'timezone'=>'Asia/Dubai',              'currency'=>'AED'],
            'UZ' => ['name'=>'Uzbekistan',                'iso2'=>'UZ','iso3'=>'UZB','flag'=>$f('UZ'),'dial_code'=>'+998', 'timezone'=>'Asia/Tashkent',           'currency'=>'UZS'],
            'VN' => ['name'=>'Vietnam',                   'iso2'=>'VN','iso3'=>'VNM','flag'=>$f('VN'),'dial_code'=>'+84',  'timezone'=>'Asia/Ho_Chi_Minh',        'currency'=>'VND'],
            'YE' => ['name'=>'Yemen',                     'iso2'=>'YE','iso3'=>'YEM','flag'=>$f('YE'),'dial_code'=>'+967', 'timezone'=>'Asia/Aden',               'currency'=>'YER'],

            // ── EUROPE ────────────────────────────────────────────────────────────
            'AL' => ['name'=>'Albania',                   'iso2'=>'AL','iso3'=>'ALB','flag'=>$f('AL'),'dial_code'=>'+355', 'timezone'=>'Europe/Tirane',           'currency'=>'ALL'],
            'AD' => ['name'=>'Andorra',                   'iso2'=>'AD','iso3'=>'AND','flag'=>$f('AD'),'dial_code'=>'+376', 'timezone'=>'Europe/Andorra',          'currency'=>'EUR'],
            'AT' => ['name'=>'Austria',                   'iso2'=>'AT','iso3'=>'AUT','flag'=>$f('AT'),'dial_code'=>'+43',  'timezone'=>'Europe/Vienna',           'currency'=>'EUR'],
            'BY' => ['name'=>'Belarus',                   'iso2'=>'BY','iso3'=>'BLR','flag'=>$f('BY'),'dial_code'=>'+375', 'timezone'=>'Europe/Minsk',            'currency'=>'BYN'],
            'BE' => ['name'=>'Belgium',                   'iso2'=>'BE','iso3'=>'BEL','flag'=>$f('BE'),'dial_code'=>'+32',  'timezone'=>'Europe/Brussels',         'currency'=>'EUR'],
            'BA' => ['name'=>'Bosnia & Herzegovina',      'iso2'=>'BA','iso3'=>'BIH','flag'=>$f('BA'),'dial_code'=>'+387', 'timezone'=>'Europe/Sarajevo',         'currency'=>'BAM'],
            'BG' => ['name'=>'Bulgaria',                  'iso2'=>'BG','iso3'=>'BGR','flag'=>$f('BG'),'dial_code'=>'+359', 'timezone'=>'Europe/Sofia',            'currency'=>'BGN'],
            'HR' => ['name'=>'Croatia',                   'iso2'=>'HR','iso3'=>'HRV','flag'=>$f('HR'),'dial_code'=>'+385', 'timezone'=>'Europe/Zagreb',           'currency'=>'EUR'],
            'CZ' => ['name'=>'Czech Republic',            'iso2'=>'CZ','iso3'=>'CZE','flag'=>$f('CZ'),'dial_code'=>'+420', 'timezone'=>'Europe/Prague',           'currency'=>'CZK'],
            'DK' => ['name'=>'Denmark',                   'iso2'=>'DK','iso3'=>'DNK','flag'=>$f('DK'),'dial_code'=>'+45',  'timezone'=>'Europe/Copenhagen',       'currency'=>'DKK'],
            'EE' => ['name'=>'Estonia',                   'iso2'=>'EE','iso3'=>'EST','flag'=>$f('EE'),'dial_code'=>'+372', 'timezone'=>'Europe/Tallinn',          'currency'=>'EUR'],
            'FI' => ['name'=>'Finland',                   'iso2'=>'FI','iso3'=>'FIN','flag'=>$f('FI'),'dial_code'=>'+358', 'timezone'=>'Europe/Helsinki',         'currency'=>'EUR'],
            'FR' => ['name'=>'France',                    'iso2'=>'FR','iso3'=>'FRA','flag'=>$f('FR'),'dial_code'=>'+33',  'timezone'=>'Europe/Paris',            'currency'=>'EUR'],
            'DE' => ['name'=>'Germany',                   'iso2'=>'DE','iso3'=>'DEU','flag'=>$f('DE'),'dial_code'=>'+49',  'timezone'=>'Europe/Berlin',           'currency'=>'EUR'],
            'GR' => ['name'=>'Greece',                    'iso2'=>'GR','iso3'=>'GRC','flag'=>$f('GR'),'dial_code'=>'+30',  'timezone'=>'Europe/Athens',           'currency'=>'EUR'],
            'HU' => ['name'=>'Hungary',                   'iso2'=>'HU','iso3'=>'HUN','flag'=>$f('HU'),'dial_code'=>'+36',  'timezone'=>'Europe/Budapest',         'currency'=>'HUF'],
            'IS' => ['name'=>'Iceland',                   'iso2'=>'IS','iso3'=>'ISL','flag'=>$f('IS'),'dial_code'=>'+354', 'timezone'=>'Atlantic/Reykjavik',      'currency'=>'ISK'],
            'IE' => ['name'=>'Ireland',                   'iso2'=>'IE','iso3'=>'IRL','flag'=>$f('IE'),'dial_code'=>'+353', 'timezone'=>'Europe/Dublin',           'currency'=>'EUR'],
            'IT' => ['name'=>'Italy',                     'iso2'=>'IT','iso3'=>'ITA','flag'=>$f('IT'),'dial_code'=>'+39',  'timezone'=>'Europe/Rome',             'currency'=>'EUR'],
            'XK' => ['name'=>'Kosovo',                    'iso2'=>'XK','iso3'=>'XKX','flag'=>$f('XK'),'dial_code'=>'+383', 'timezone'=>'Europe/Belgrade',         'currency'=>'EUR'],
            'LV' => ['name'=>'Latvia',                    'iso2'=>'LV','iso3'=>'LVA','flag'=>$f('LV'),'dial_code'=>'+371', 'timezone'=>'Europe/Riga',             'currency'=>'EUR'],
            'LI' => ['name'=>'Liechtenstein',             'iso2'=>'LI','iso3'=>'LIE','flag'=>$f('LI'),'dial_code'=>'+423', 'timezone'=>'Europe/Vaduz',            'currency'=>'CHF'],
            'LT' => ['name'=>'Lithuania',                 'iso2'=>'LT','iso3'=>'LTU','flag'=>$f('LT'),'dial_code'=>'+370', 'timezone'=>'Europe/Vilnius',          'currency'=>'EUR'],
            'LU' => ['name'=>'Luxembourg',                'iso2'=>'LU','iso3'=>'LUX','flag'=>$f('LU'),'dial_code'=>'+352', 'timezone'=>'Europe/Luxembourg',       'currency'=>'EUR'],
            'MT' => ['name'=>'Malta',                     'iso2'=>'MT','iso3'=>'MLT','flag'=>$f('MT'),'dial_code'=>'+356', 'timezone'=>'Europe/Malta',            'currency'=>'EUR'],
            'MD' => ['name'=>'Moldova',                   'iso2'=>'MD','iso3'=>'MDA','flag'=>$f('MD'),'dial_code'=>'+373', 'timezone'=>'Europe/Chisinau',         'currency'=>'MDL'],
            'MC' => ['name'=>'Monaco',                    'iso2'=>'MC','iso3'=>'MCO','flag'=>$f('MC'),'dial_code'=>'+377', 'timezone'=>'Europe/Monaco',           'currency'=>'EUR'],
            'ME' => ['name'=>'Montenegro',                'iso2'=>'ME','iso3'=>'MNE','flag'=>$f('ME'),'dial_code'=>'+382', 'timezone'=>'Europe/Podgorica',        'currency'=>'EUR'],
            'NL' => ['name'=>'Netherlands',               'iso2'=>'NL','iso3'=>'NLD','flag'=>$f('NL'),'dial_code'=>'+31',  'timezone'=>'Europe/Amsterdam',        'currency'=>'EUR'],
            'MK' => ['name'=>'North Macedonia',           'iso2'=>'MK','iso3'=>'MKD','flag'=>$f('MK'),'dial_code'=>'+389', 'timezone'=>'Europe/Skopje',           'currency'=>'MKD'],
            'NO' => ['name'=>'Norway',                    'iso2'=>'NO','iso3'=>'NOR','flag'=>$f('NO'),'dial_code'=>'+47',  'timezone'=>'Europe/Oslo',             'currency'=>'NOK'],
            'PL' => ['name'=>'Poland',                    'iso2'=>'PL','iso3'=>'POL','flag'=>$f('PL'),'dial_code'=>'+48',  'timezone'=>'Europe/Warsaw',           'currency'=>'PLN'],
            'PT' => ['name'=>'Portugal',                  'iso2'=>'PT','iso3'=>'PRT','flag'=>$f('PT'),'dial_code'=>'+351', 'timezone'=>'Europe/Lisbon',           'currency'=>'EUR'],
            'RO' => ['name'=>'Romania',                   'iso2'=>'RO','iso3'=>'ROU','flag'=>$f('RO'),'dial_code'=>'+40',  'timezone'=>'Europe/Bucharest',        'currency'=>'RON'],
            'RU' => ['name'=>'Russia',                    'iso2'=>'RU','iso3'=>'RUS','flag'=>$f('RU'),'dial_code'=>'+7',   'timezone'=>'Europe/Moscow',           'currency'=>'RUB'],
            'SM' => ['name'=>'San Marino',                'iso2'=>'SM','iso3'=>'SMR','flag'=>$f('SM'),'dial_code'=>'+378', 'timezone'=>'Europe/San_Marino',       'currency'=>'EUR'],
            'RS' => ['name'=>'Serbia',                    'iso2'=>'RS','iso3'=>'SRB','flag'=>$f('RS'),'dial_code'=>'+381', 'timezone'=>'Europe/Belgrade',         'currency'=>'RSD'],
            'SK' => ['name'=>'Slovakia',                  'iso2'=>'SK','iso3'=>'SVK','flag'=>$f('SK'),'dial_code'=>'+421', 'timezone'=>'Europe/Bratislava',       'currency'=>'EUR'],
            'SI' => ['name'=>'Slovenia',                  'iso2'=>'SI','iso3'=>'SVN','flag'=>$f('SI'),'dial_code'=>'+386', 'timezone'=>'Europe/Ljubljana',        'currency'=>'EUR'],
            'ES' => ['name'=>'Spain',                     'iso2'=>'ES','iso3'=>'ESP','flag'=>$f('ES'),'dial_code'=>'+34',  'timezone'=>'Europe/Madrid',           'currency'=>'EUR'],
            'SE' => ['name'=>'Sweden',                    'iso2'=>'SE','iso3'=>'SWE','flag'=>$f('SE'),'dial_code'=>'+46',  'timezone'=>'Europe/Stockholm',        'currency'=>'SEK'],
            'CH' => ['name'=>'Switzerland',               'iso2'=>'CH','iso3'=>'CHE','flag'=>$f('CH'),'dial_code'=>'+41',  'timezone'=>'Europe/Zurich',           'currency'=>'CHF'],
            'UA' => ['name'=>'Ukraine',                   'iso2'=>'UA','iso3'=>'UKR','flag'=>$f('UA'),'dial_code'=>'+380', 'timezone'=>'Europe/Kyiv',             'currency'=>'UAH'],
            'GB' => ['name'=>'United Kingdom',            'iso2'=>'GB','iso3'=>'GBR','flag'=>$f('GB'),'dial_code'=>'+44',  'timezone'=>'Europe/London',           'currency'=>'GBP'],
            'VA' => ['name'=>'Vatican City',              'iso2'=>'VA','iso3'=>'VAT','flag'=>$f('VA'),'dial_code'=>'+39',  'timezone'=>'Europe/Vatican',          'currency'=>'EUR'],

            // ── OCEANIA ───────────────────────────────────────────────────────────
            'AU' => ['name'=>'Australia',                 'iso2'=>'AU','iso3'=>'AUS','flag'=>$f('AU'),'dial_code'=>'+61',  'timezone'=>'Australia/Sydney',        'currency'=>'AUD'],
            'FJ' => ['name'=>'Fiji',                      'iso2'=>'FJ','iso3'=>'FJI','flag'=>$f('FJ'),'dial_code'=>'+679', 'timezone'=>'Pacific/Fiji',            'currency'=>'FJD'],
            'KI' => ['name'=>'Kiribati',                  'iso2'=>'KI','iso3'=>'KIR','flag'=>$f('KI'),'dial_code'=>'+686', 'timezone'=>'Pacific/Tarawa',          'currency'=>'AUD'],
            'MH' => ['name'=>'Marshall Islands',          'iso2'=>'MH','iso3'=>'MHL','flag'=>$f('MH'),'dial_code'=>'+692', 'timezone'=>'Pacific/Majuro',          'currency'=>'USD'],
            'FM' => ['name'=>'Micronesia',                'iso2'=>'FM','iso3'=>'FSM','flag'=>$f('FM'),'dial_code'=>'+691', 'timezone'=>'Pacific/Pohnpei',         'currency'=>'USD'],
            'NR' => ['name'=>'Nauru',                     'iso2'=>'NR','iso3'=>'NRU','flag'=>$f('NR'),'dial_code'=>'+674', 'timezone'=>'Pacific/Nauru',           'currency'=>'AUD'],
            'NZ' => ['name'=>'New Zealand',               'iso2'=>'NZ','iso3'=>'NZL','flag'=>$f('NZ'),'dial_code'=>'+64',  'timezone'=>'Pacific/Auckland',        'currency'=>'NZD'],
            'PW' => ['name'=>'Palau',                     'iso2'=>'PW','iso3'=>'PLW','flag'=>$f('PW'),'dial_code'=>'+680', 'timezone'=>'Pacific/Palau',           'currency'=>'USD'],
            'PG' => ['name'=>'Papua New Guinea',          'iso2'=>'PG','iso3'=>'PNG','flag'=>$f('PG'),'dial_code'=>'+675', 'timezone'=>'Pacific/Port_Moresby',    'currency'=>'PGK'],
            'WS' => ['name'=>'Samoa',                     'iso2'=>'WS','iso3'=>'WSM','flag'=>$f('WS'),'dial_code'=>'+685', 'timezone'=>'Pacific/Apia',            'currency'=>'WST'],
            'SB' => ['name'=>'Solomon Islands',           'iso2'=>'SB','iso3'=>'SLB','flag'=>$f('SB'),'dial_code'=>'+677', 'timezone'=>'Pacific/Guadalcanal',     'currency'=>'SBD'],
            'TO' => ['name'=>'Tonga',                     'iso2'=>'TO','iso3'=>'TON','flag'=>$f('TO'),'dial_code'=>'+676', 'timezone'=>'Pacific/Tongatapu',       'currency'=>'TOP'],
            'TV' => ['name'=>'Tuvalu',                    'iso2'=>'TV','iso3'=>'TUV','flag'=>$f('TV'),'dial_code'=>'+688', 'timezone'=>'Pacific/Funafuti',        'currency'=>'AUD'],
            'VU' => ['name'=>'Vanuatu',                   'iso2'=>'VU','iso3'=>'VUT','flag'=>$f('VU'),'dial_code'=>'+678', 'timezone'=>'Pacific/Efate',           'currency'=>'VUV'],
        ];
    }

    /**
     * Options list for the phone-code component.
     * Returns [value, flag, label, secondary, search] per entry, sorted by country name.
     */
    public static function forPhoneCode(): array
    {
        $list = [];
        foreach (self::all() as $country) {
            $list[] = [
                'value'     => $country['dial_code'] . '|' . $country['iso2'],
                'flag'      => $country['flag'],
                'label'     => $country['dial_code'],
                'secondary' => $country['name'],
                'search'    => strtolower($country['name'] . ' ' . $country['dial_code'] . ' ' . $country['iso2']),
            ];
        }
        usort($list, fn($a, $b) => strcmp($a['secondary'], $b['secondary']));
        return $list;
    }

    /**
     * Options list for the country/nationality component.
     * value = iso2 code.
     */
    public static function forCountry(): array
    {
        $list = [];
        foreach (self::all() as $country) {
            $list[] = [
                'value'  => $country['iso2'],
                'flag'   => $country['flag'],
                'label'  => $country['name'],
                'search' => strtolower($country['name'] . ' ' . $country['iso2'] . ' ' . $country['iso3']),
            ];
        }
        usort($list, fn($a, $b) => strcmp($a['label'], $b['label']));
        return $list;
    }

    /**
     * Options list for the timezone component.
     * Reads PHP's built-in timezone database and attaches country flags.
     */
    public static function forTimezone(): array
    {
        $countries = self::all();
        $list = [];

        // Skip Etc/ offsets and legacy backward-compat entries; keep named timezones
        $skip = ['Etc', 'SystemV', 'US', 'Canada', 'Brazil', 'Chile', 'Mexico', 'Cuba', 'Egypt', 'Eire',
                 'Factory', 'GB', 'GB-Eire', 'GMT', 'Hongkong', 'Iceland', 'Iran', 'Israel',
                 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'MST', 'NZ', 'NZ-CHAT',
                 'Navajo', 'Poland', 'Portugal', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT',
                 'UTC', 'Universal', 'W-SU', 'WET', 'Zulu'];

        foreach (\DateTimeZone::listIdentifiers() as $tz) {
            $region = explode('/', $tz)[0];
            if (in_array($region, $skip, true)) {
                continue;
            }
            if (!str_contains($tz, '/')) {
                continue;
            }

            try {
                $dtze   = new \DateTimeZone($tz);
                $dt     = new \DateTime('now', $dtze);
                $offset = $dt->getOffset();

                $h    = (int) floor(abs($offset) / 3600);
                $m    = (int) (abs($offset) % 3600 / 60);
                $sign = $offset >= 0 ? '+' : '-';
                $utc  = 'UTC' . $sign . str_pad($h, 2, '0', STR_PAD_LEFT) . ':' . str_pad($m, 2, '0', STR_PAD_LEFT);

                $location    = $dtze->getLocation();
                $countryCode = strtoupper($location['country_code'] ?? '');
                $countryData = $countries[$countryCode] ?? null;
                $flag        = $countryData ? $countryData['flag'] : '';
                $countryName = $countryData ? $countryData['name'] : '';

                $parts = explode('/', $tz);
                $city  = str_replace('_', ' ', end($parts));

                $list[] = [
                    'value'   => $tz,
                    'flag'    => $flag,
                    'label'   => str_replace('_', ' ', $tz),
                    'utc'     => $utc,
                    'offset'  => $offset,
                    'search'  => strtolower($tz . ' ' . $city . ' ' . $utc . ' ' . $countryName),
                ];
            } catch (\Exception) {
                continue;
            }
        }

        usort($list, fn($a, $b) => $a['offset'] <=> $b['offset'] ?: strcmp($a['value'], $b['value']));
        return $list;
    }

    /**
     * Returns a map of IANA timezone identifier → ISO2 country code.
     * Used by the country-select component to auto-detect the user's country from their device timezone.
     */
    public static function forGeoTimezoneMap(): array
    {
        $countries = self::all();
        $skip = ['Etc', 'SystemV', 'US', 'Canada', 'Brazil', 'Chile', 'Mexico', 'Cuba', 'Egypt', 'Eire',
                 'Factory', 'GB', 'GB-Eire', 'GMT', 'Hongkong', 'Iceland', 'Iran', 'Israel',
                 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'MST', 'NZ', 'NZ-CHAT',
                 'Navajo', 'Poland', 'Portugal', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT',
                 'UTC', 'Universal', 'W-SU', 'WET', 'Zulu'];

        $map = [];
        foreach (\DateTimeZone::listIdentifiers() as $tz) {
            $region = explode('/', $tz)[0];
            if (in_array($region, $skip, true) || !str_contains($tz, '/')) {
                continue;
            }
            try {
                $dtze  = new \DateTimeZone($tz);
                $loc   = $dtze->getLocation();
                $iso2  = strtoupper($loc['country_code'] ?? '');
                if ($iso2 && isset($countries[$iso2])) {
                    $map[$tz] = $iso2;
                }
            } catch (\Exception) {}
        }
        return $map;
    }
}
