<?php

namespace App\Services\Meta;

/**
 * Ads Manager's detailed-targeting browse menu as of May 2024.
 *
 * Each item is the name a buyer can pick. The catalog searches Meta with that
 * name and stores the id Meta returns. Search boxes (schools, job titles,
 * employers, fields of study) stay open queries. Country-sized expat and
 * device lists are included because they are browse rows, and the choice
 * card can filter them.
 */
class MetaTargetingBrowse
{
    /**
     * @return array<string, array{label: string, categories: array<string, array<string, mixed>>}>
     */
    /**
     * Closed browse labels a buyer can pick. Search boxes (job titles, schools) are not listed.
     *
     * @return list<string>
     */
    public static function namedItems(): array
    {
        $items = [];

        foreach (self::tree() as $group) {
            foreach (is_array($group['categories'] ?? null) ? $group['categories'] : [] as $category) {
                if (! is_array($category)) {
                    continue;
                }

                foreach (is_array($category['items'] ?? null) ? $category['items'] : [] as $item) {
                    if (is_string($item) && $item !== '') {
                        $items[$item] = true;
                    }
                }

                foreach (is_array($category['facets'] ?? null) ? $category['facets'] : [] as $facet) {
                    if (! is_array($facet)) {
                        continue;
                    }

                    foreach (is_array($facet['items'] ?? null) ? $facet['items'] : [] as $item) {
                        if (is_string($item) && $item !== '') {
                            $items[$item] = true;
                        }
                    }
                }
            }
        }

        return array_keys($items);
    }

    public static function tree(): array
    {
        return [
            'demographics' => [
                'label' => 'Demographics',
                'categories' => [
                    'education' => [
                        'label' => 'Education',
                        'facets' => [
                            self::facet('education_level', 'Education level', 'education_statuses', 'education_statuses', 'enum', false, ''),
                            self::facet('fields_of_study', 'Fields of study', 'education_majors', 'education_majors', 'object', true, 'Computer science'),
                            self::facet('schools', 'Schools', 'education_schools', 'education_schools', 'object', true, 'Harvard'),
                            self::facet('undergrad_years', 'Undergrad years', 'education_schools', 'education_schools', 'object', true, 'Undergrad years', true),
                        ],
                    ],
                    'income' => self::named('Income', 'behaviors', 'behaviors', [
                        'Household income: top 10% of ZIP codes (US)',
                        'Household income: top 10-25% of ZIP codes (US)',
                        'Household income: top 25-50% of ZIP codes (US)',
                        'Household income: top 5% of ZIP codes (US)',
                    ]),
                    'life_events' => self::named('Life events', 'life_events', 'life_events', [
                        'Anniversary within 30 days',
                        'Anniversary within 31-60 days',
                        'Away from family',
                        'Away from home town',
                        'Long-distance relationship',
                        'New job',
                        'New relationship',
                        'Newly engaged (1 year)',
                        'Newly engaged (3 months)',
                        'Newly engaged (6 months)',
                        'Newlywed (1 year)',
                        'Newlywed (3 months)',
                        'Newlywed (6 months)',
                        'Recently moved',
                    ]),
                    'date_of_birth' => self::named('Date of birth', 'life_events', 'life_events', [
                        'Upcoming birthday',
                    ]),
                    'month_of_birth' => self::named('Month of birth', 'life_events', 'life_events', [
                        'Birthday in January',
                        'Birthday in February',
                        'Birthday in March',
                        'Birthday in April',
                        'Birthday in May',
                        'Birthday in June',
                        'Birthday in July',
                        'Birthday in August',
                        'Birthday in September',
                        'Birthday in October',
                        'Birthday in November',
                        'Birthday in December',
                    ]),
                    'friends_of' => self::named('Friends of', 'behaviors', 'behaviors', [
                        'Friends of men with a birthday in 0-7 days',
                        'Friends of men with a birthday in 7-30 days',
                        'Friends of people who recently moved',
                        'Friends of people with birthdays in a month',
                        'Friends of people with birthdays in a week',
                        'Friends of women with a birthday in 0-7 days',
                        'Friends of women with a birthday in 7-30 days',
                    ]),
                    'parents' => self::named('Parents', 'family_statuses', 'family_statuses', [
                        'Parents (All)',
                        'Parents (up to 12 months)',
                        'Parents with adult children (aged 18-26)',
                        'Parents with pre-schoolers (3-5 years)',
                        'Parents with pre-teens (aged 9-12)',
                        'Parents with primary school-age children (6-8 years)',
                        'Parents with teenagers (aged 13-17)',
                        'Parents with toddlers (aged 1-2)',
                    ]),
                    'relationship' => [
                        'label' => 'Relationship',
                        'facets' => [
                            self::facet('relationship_status', 'Relationship status', 'relationship_statuses', 'relationship_statuses', 'enum', false, ''),
                        ],
                    ],
                    'industries' => self::named('Industries', 'industries', 'industries', [
                        'Administrative services',
                        'Architecture and engineering',
                        'Arts, entertainment, sport and media',
                        'Business and finance',
                        'Business decision maker titles and interests',
                        'Business decision makers',
                        'Cleaning and maintenance services',
                        'Community and social services',
                        'Companies founded before 2000',
                        'Companies founded between 2000 and 2009',
                        'Companies founded between 2010 and now',
                        'Company revenue: $1M to $10M',
                        'Company revenue: less than $1M',
                        'Company revenue: more than $10M',
                        'Company size: 1-10 employees',
                        'Company size: 101-500 employees',
                        'Company size: 11-100 employees',
                        'Company size: more than 500 employees',
                        'Computation and mathematics',
                        'Construction and extraction',
                        'Education and libraries',
                        'Farming, fishing and forestry',
                        'Food and restaurants',
                        'Government employees (global)',
                        'Healthcare and medical services',
                        'IT and technical services',
                        'IT decision makers',
                        'Installation and repair services',
                        'Large business-to-business enterprise employees (500+ employees)',
                        'Legal services',
                        'Life, physical and social sciences',
                        'Management',
                        'Medium business-to-business enterprise employees (200-500 employees)',
                        'Military (global)',
                        'Production',
                        'Protective services',
                        'Sales',
                        'Small business-to-business enterprise employees (10-200 employees)',
                        'Transport and moving',
                        'Veterans (US)',
                    ]),
                    'work' => [
                        'label' => 'Work',
                        'facets' => [
                            self::facet('job_titles', 'Job titles', 'work_positions', 'work_positions', 'object', true, 'Software engineer'),
                            self::facet('employers', 'Employers', 'work_employers', 'work_employers', 'object', true, 'Microsoft'),
                        ],
                    ],
                ],
            ],
            'interests' => [
                'label' => 'Interests',
                'categories' => [
                    'business_and_industry' => self::named('Business and industry', 'interests', 'interests', [
                        'Advertising (marketing)',
                        'Agriculture (industry)',
                        'Architecture (architecture)',
                        'Aviation (air travel)',
                        'Investment banking (banking)',
                        'Online banking (banking)',
                        'Retail banking (banking)',
                        'Business (business & finance)',
                        'Construction (industry)',
                        'Economics (economics)',
                        'Engineering (science)',
                        'Entrepreneurship (business & finance)',
                        'Higher education (education)',
                        'Management (business & finance)',
                        'Marketing (business & finance)',
                        'Fashion design (design)',
                        'Graphic design (visual art)',
                        'Interior design (design)',
                        'Real estate (industry)',
                        'Retail (industry)',
                        'Sales (business & finance)',
                        'Science (science)',
                        'Small business (business & finance)',
                        'Credit cards (credit & lending)',
                        'Insurance (business & finance)',
                        'Investment (business & finance)',
                        'Mortgage loans (banking)',
                        'Digital marketing (marketing)',
                        'Email marketing (marketing)',
                        'Online advertising (marketing)',
                        'Search engine optimization (software)',
                        'Social media (online media)',
                        'Social media marketing (marketing)',
                        'Web design (websites)',
                        'Web development (websites)',
                        'Web hosting (computing)',
                    ]),
                    'games' => self::named('Games', 'interests', 'interests', [
                        'Action games (video games)',
                        'Board games (games)',
                        'Browser games (video games)',
                        'Card games (games)',
                        'Casino games (gambling)',
                        'First-person shooter games (video games)',
                        'Gambling (gambling)',
                        'Massively multiplayer online games (video games)',
                        'Massively multiplayer online role-playing games (video games)',
                        'Online games (video games)',
                        'Online poker (gambling)',
                        'Puzzle video games (video games)',
                        'Racing games (video game)',
                        'Role-playing games (video games)',
                        'Simulation games (video games)',
                        'Sports games (video games)',
                        'Strategy games (games)',
                        'Video games (gaming)',
                        'Word games (games)',
                    ]),
                    'entertainment_events' => self::named('Entertainment events', 'interests', 'interests', [
                        'Ballet (dance)',
                        'Bars (bars, clubs & nightlife)',
                        'Concerts (music event)',
                        'Dancehalls (music)',
                        'Music festivals (events)',
                        'Nightclubs (bars, clubs & nightlife)',
                        'Parties (event)',
                        'Plays (performing arts)',
                        'Theatre (performing arts)',
                    ]),
                    'movies' => self::named('Movies', 'interests', 'interests', [
                        'Action movies (movies)',
                        'Animated movies (movies)',
                        'Anime movies (movies)',
                        'Bollywood movies (movies)',
                        'Comedy movies (movies)',
                        'Documentary movies (movies)',
                        'Drama movies (movies)',
                        'Horror movies (movies)',
                        'Musical theatre (performing arts)',
                        'Science fiction movies (movies)',
                        'Thriller movies (movies)',
                    ]),
                    'music' => self::named('Music', 'interests', 'interests', [
                        'Blues music (music)',
                        'Classical music (music)',
                        'Country music (music)',
                        'Dance music (music)',
                        'Electronic music (music)',
                        'Heavy metal music (music)',
                        'Hip hop music (music)',
                        'Jazz music (music)',
                        'Music videos (entertainment & media)',
                        'Pop music (music)',
                        'Rhythm and blues music (music)',
                        'Rock music (music)',
                        'Soul music (music)',
                    ]),
                    'reading' => self::named('Reading', 'interests', 'interests', [
                        'Books (publications)',
                        'Comics (comics & cartoons)',
                        'E-books (publications)',
                        'Fiction books (publications)',
                        'Literature (publications)',
                        'Magazines (publications)',
                        'Manga (anime & manga)',
                        'Mystery fiction (entertainment & media)',
                        'Newspapers (publications)',
                        'Non-fiction books (publications)',
                        'Romance novels (publications)',
                    ]),
                    'tv' => self::named('TV', 'interests', 'interests', [
                        'TV game shows (television show)',
                        'TV reality shows (movies & television)',
                        'TV talkshows (television show)',
                    ]),
                    'family_and_relationships' => self::named('Family and relationships', 'interests', 'interests', [
                        'Family (social concept)',
                        'Fatherhood (children & parenting)',
                        'Friendship (relationships)',
                        'Marriage (weddings)',
                        'Motherhood (children & parenting)',
                        'Parenting (children & parenting)',
                        'Weddings (weddings)',
                    ]),
                    'fitness_and_wellness' => self::named('Fitness and wellness', 'interests', 'interests', [
                        'Bodybuilding (sport)',
                        'Physical exercise (fitness)',
                        'Physical fitness (fitness)',
                        'Running (sport)',
                        'Weight training (weightlifting)',
                        'Yoga',
                    ]),
                    'alcoholic_beverages' => self::named('Alcoholic beverages', 'interests', 'interests', [
                        'Beer (alcoholic drinks)',
                        'Distilled beverage (liquor)',
                        'Wine (alcoholic drinks)',
                    ]),
                    'beverages' => self::named('Beverages', 'interests', 'interests', [
                        'Coffee (food & drink)',
                        'Energy drinks (nonalcoholic beverage)',
                        'Juice (nonalcoholic beverage)',
                        'Soft drinks (nonalcoholic beverage)',
                        'Tea (nonalcoholic beverage)',
                    ]),
                    'cooking' => self::named('Cooking', 'interests', 'interests', [
                        'Baking (cooking)',
                        'Recipes (food & drink)',
                    ]),
                    'cuisine' => self::named('Cuisine', 'interests', 'interests', [
                        'Chinese cuisine (food & drink)',
                        'French cuisine (food & drink)',
                        'German cuisine (food & drink)',
                        'Greek cuisine (food & drink)',
                        'Indian cuisine (food & drink)',
                        'Italian cuisine (food & drink)',
                        'Japanese cuisine (food & drink)',
                        'Korean cuisine (food & drink)',
                        'Latin American cuisine (food & drink)',
                        'Mexican cuisine (food & drink)',
                        'Middle Eastern cuisine (food & drink)',
                        'Spanish cuisine (food & drink)',
                        'Thai cuisine (food & drink)',
                        'Vietnamese cuisine (food & drink)',
                    ]),
                    'food' => self::named('Food', 'interests', 'interests', [
                        'Barbecue (cooking)',
                        'Chocolate (food & drink)',
                        'Desserts (food & drink)',
                        'Fast food (food & drink)',
                        'Organic food (food & drink)',
                        'Pizza (food & drink)',
                        'Seafood (food & drink)',
                        'Veganism (diets)',
                        'Vegetarianism (diets)',
                    ]),
                    'restaurants' => self::named('Restaurants', 'interests', 'interests', [
                        'Coffeehouses (coffee)',
                        'Diners (restaurant)',
                        'Fast casual restaurants (restaurant)',
                        'Fast food restaurants (dining)',
                    ]),
                    'hobbies' => self::named('Hobbies and activities', 'interests', 'interests', [
                        'Current events (politics)',
                    ]),
                    'arts_and_music' => self::named('Arts and music', 'interests', 'interests', [
                        'Acting (performing arts)',
                        'Crafts (hobbies)',
                        'Dance (art)',
                        'Drawing (visual art)',
                        'Drums (instruments)',
                        'Fine art (visual art)',
                        'Guitar (instruments)',
                        'Painting (visual art)',
                        'Performing arts (performing arts)',
                        'Photography (visual art)',
                        'Sculpture (art)',
                        'Singing (music)',
                        'Writing (communication)',
                    ]),
                    'home_and_garden' => self::named('Home and garden', 'interests', 'interests', [
                        'Do it yourself (DIY)',
                        'Furniture (home furnishings)',
                        'Gardening (outdoor activities)',
                        'Home Appliances (consumer electronics)',
                        'Home improvement (home & garden)',
                    ]),
                    'pets' => self::named('Pets', 'interests', 'interests', [
                        'Birds (animals)',
                        'Cats (animals)',
                        'Dogs (animals)',
                        'Fish (animals)',
                        'Horses (animals)',
                        'Pet food (pet supplies)',
                        'Rabbits (animals)',
                        'Reptiles (animals)',
                    ]),
                    'politics_and_social_issues' => self::named('Politics and social issues', 'interests', 'interests', [
                        'Charity and causes (social causes)',
                        'Community issues (law & government)',
                        'Law (law & legal services)',
                        'Politics (politics)',
                        'Volunteering (social causes)',
                    ]),
                    'travel_and_tourism' => self::named('Travel', 'interests', 'interests', [
                        'Adventure travel (travel & tourism)',
                        'Air travel (transportation)',
                        'Beaches (places)',
                        'Car rentals (transportation)',
                        'Cruises (travel & tourism business)',
                        'Ecotourism (travel & tourism)',
                        'Hotels (lodging)',
                        'Lakes (body of water)',
                        'Mountains (places)',
                        'Nature (science)',
                        'Theme parks (leisure)',
                        'Tourism (industry)',
                        'Vacations (social concept)',
                    ]),
                    'vehicles' => self::named('Vehicles', 'interests', 'interests', [
                        'Automobiles (vehicles)',
                        'Boats (watercraft)',
                        'Electric vehicle (vehicle)',
                        'Hybrids (vehicle)',
                        'Minivans (vehicle)',
                        'Motorcycles (vehicles)',
                        'RVs (vehicle)',
                        'SUVs (vehicles)',
                        'Scooters (vehicle)',
                        'Trucks (vehicles)',
                    ]),
                    'beauty' => self::named('Beauty', 'interests', 'interests', [
                        'Beauty salons (cosmetics)',
                        'Cosmetics (personal care)',
                        'Fragrances (cosmetics)',
                        'Hair products (hair care)',
                        'Spas (personal care)',
                        'Tattoos (body art)',
                    ]),
                    'clothing' => self::named('Clothing', 'interests', 'interests', [
                        'Children\'s clothing (apparel)',
                        'Men\'s clothing (apparel)',
                        'Shoes (footwear)',
                        'Women\'s clothing (apparel)',
                    ]),
                    'fashion_accessories' => self::named('Fashion accessories', 'interests', 'interests', [
                        'Dresses (apparel)',
                        'Handbags (accessories)',
                        'Jewelry (apparel)',
                        'Sunglasses (eyewear)',
                    ]),
                    'shopping' => self::named('Shopping', 'interests', 'interests', [
                        'Boutiques (retailers)',
                        'Coupons (coupons & discounts)',
                        'Discount stores (retail)',
                        'Luxury goods (retail)',
                        'Online shopping (retail)',
                        'Shopping malls (retail)',
                        'Toys (toys)',
                    ]),
                    'outdoor_recreation' => self::named('Outdoor recreation', 'interests', 'interests', [
                        'Boating (outdoors activities)',
                        'Camping (outdoors activities)',
                        'Fishing (outdoors activities)',
                        'Horseback riding (horse sport)',
                        'Hunting (sport)',
                        'Mountain biking (cycling)',
                        'Surfing (water sport)',
                    ]),
                    'sports' => self::named('Sports', 'interests', 'interests', [
                        'American football (sport)',
                        'Association football (Soccer)',
                        'Auto racing (motor sports)',
                        'Baseball (sport)',
                        'Basketball (sport)',
                        'College football (college sports)',
                        'Golf (sport)',
                        'Marathons (running event)',
                        'Skiing (skiing & snowboarding)',
                        'Snowboarding (skiing & snowboarding)',
                        'Swimming (water sport)',
                        'Tennis (sport)',
                        'Triathlons (athletics)',
                        'Volleyball (sport)',
                    ]),
                    'computers' => self::named('Computers', 'interests', 'interests', [
                        'Computer memory (computer hardware)',
                        'Computer monitors (computer hardware)',
                        'Computer processors (computer hardware)',
                        'Computer servers (computing)',
                        'Desktop computers (consumer electronics)',
                        'Free software (software)',
                        'Hard drives (computer hardware)',
                        'Network storage (computers & electronics)',
                        'Software (computers & electronics)',
                        'Tablet computers (computers & electronics)',
                    ]),
                    'consumer_electronics' => self::named('Consumer electronics', 'interests', 'interests', [
                        'Audio equipment (electronics)',
                        'Camcorders (consumer electronics)',
                        'Cameras (photography)',
                        'E-book readers (consumer electronics)',
                        'GPS devices (consumer electronics)',
                        'Mobile phones (smart phone)',
                        'Portable media players (audio equipment)',
                        'Projectors (consumer electronics)',
                        'Smartphones (consumer electronics)',
                        'Televisions (consumer electronics)',
                    ]),
                ],
            ],
            'behaviors' => [
                'label' => 'Behaviors',
                'categories' => [
                    'travel' => self::named('Travel', 'behaviors', 'behaviors', [
                        'Commuters',
                        'Frequent international travellers',
                        'Frequent travellers',
                        'Returned from travelling one week ago',
                        'Returned from travelling two weeks ago',
                    ]),
                    'anniversary' => self::named('Anniversary', 'behaviors', 'behaviors', [
                        'Anniversary (within 61-90 days)',
                    ]),
                    'facebook_access_mobile' => self::named('Facebook access (mobile)', 'behaviors', 'behaviors', [
                        'Recently detected devices',
                        'Recently detected iPhone 14 devices',
                    ]),
                    'consumer_classification' => self::named('Consumer classification', 'behaviors', 'behaviors', [
                        'People in Argentina who prefer high-value goods',
                        'People in Argentina who prefer mid- and high-value goods',
                        'People in Brazil who favor high-value goods',
                        'People in Brazil who prefer mid- and high-value goods',
                        'People in Chile who favor high-value goods',
                        'People in Chile who prefer mid- and high-value goods',
                        'People in India who favor high-value goods',
                        'People in India who prefer mid- and high-value goods',
                        'People in Indonesia who favor high-value goods',
                        'People in Indonesia who prefer mid- and high-value goods',
                        'People in Malaysia who favor high-value goods',
                        'People in Malaysia who prefer mid- and high-value goods',
                        'People in Mexico who favor high-value goods',
                        'People in Mexico who prefer mid- and high-value goods',
                        'People in Pakistan who favor high-value goods',
                        'People in Pakistan who prefer mid- and high-value goods',
                        'People in South Africa who favor high-value goods',
                        'People in South Africa who prefer mid- and high-value goods',
                        'People in the Kingdom of Saudi Arabia who favor high-value goods',
                        'People in the Kingdom of Saudi Arabia who prefer mid- and high-value goods',
                        'People in the Philippines who favor high-value goods',
                        'People in the Philippines who prefer mid- and high-value goods',
                        'People in the UAE who favor high-value goods',
                        'People in the UAE who prefer mid- and high-value goods',
                        'People in Turkey who favor high-value goods',
                        'People in Turkey who prefer mid- and high-value goods',
                    ]),
                    'canvas_gaming' => self::named('Canvas Gaming', 'behaviors', 'behaviors', [
                        'Played Canvas games (last 14 days)',
                        'Played Canvas games (last 3 days)',
                        'Played Canvas games (last 7 days)',
                        'Played Canvas games (yesterday)',
                    ]),
                    'facebook_page_admins' => self::named('Facebook Page admins', 'behaviors', 'behaviors', [
                        'Business Page admins',
                        'Community and club Page admins',
                        'Facebook Page admins',
                        'Food and restaurant Page admins',
                        'Health and beauty Page admins',
                        'New Page admins',
                        'Retail Page admins',
                        'Sport Page admins',
                        'Travel and tourism Page admins',
                    ]),
                    'internet_browser' => self::named('Internet browser used', 'behaviors', 'behaviors', [
                        'Facebook access (browser): Chrome',
                        'Facebook access (browser): Firefox',
                        'Facebook access (browser): Internet Explorer',
                        'Facebook access (browser): Microsoft Edge',
                        'Facebook access (browser): Opera',
                        'Facebook access (browser): Safari',
                    ]),
                    'operating_system_used' => self::named('Operating system used', 'behaviors', 'behaviors', [
                        'Facebook access (OS): Mac OS X',
                        'Facebook access (OS): Mac Sierra',
                        'Facebook access (OS): Windows 10',
                        'Facebook access (OS): Windows 7',
                        'Facebook access (OS): Windows 8',
                        'Facebook access (OS): Windows Vista',
                        'Facebook access (OS): Windows XP',
                    ]),
                    'digital_activities' => self::named('Digital activities', 'behaviors', 'behaviors', [
                        'All creators',
                        'Console gamers',
                        'Early technology adopters',
                        'Facebook Lite app users',
                        'Facebook Payments users (30 days)',
                        'Facebook Payments users (90 days)',
                        'Facebook access: older devices and OS',
                        'Food and drink creators',
                        'Health and wellness creators',
                        'Instagram business profile admins',
                        'Internet personality creators',
                        'New active business (< 12 months)',
                        'New active business (< 24 months)',
                        'New active business (< 6 months)',
                        'People who have visited Facebook Gaming',
                        'Shops admins',
                        'Small business owners',
                        'Travel and outdoors creators',
                        'Music creators',
                    ]),
                    'expats' => self::named('Expats', 'behaviors', 'behaviors', self::expats()),
                    'mobile_device_user' => self::named('Mobile device user', 'behaviors', 'behaviors', self::mobileDevices()),
                    'network_connection' => self::named('Network connection', 'behaviors', 'behaviors', [
                        'Facebook access (network type): 2G',
                        'Facebook access (network type): 3G',
                        'Facebook access (network type): 4G',
                        'Facebook access (network type): Wi-Fi',
                    ]),
                    'device_use_time' => self::named('Device use time', 'behaviors', 'behaviors', [
                        'Uses a mobile device (less than 1 month)',
                        'Uses a mobile device (1-3 months)',
                        'Uses a mobile device (4-6 months)',
                        'Uses a mobile device (7-9 months)',
                        'Uses a mobile device (10-12 months)',
                        'Uses a mobile device (13-18 months)',
                        'Uses a mobile device (19-24 months)',
                        'Uses a mobile device (25 months+)',
                    ]),
                    'more_categories' => self::named('More categories', 'behaviors', 'behaviors', [
                        'Interested in upcoming events',
                        'Marketing API developers (last 90 days)',
                    ]),
                    'purchase' => self::named('Purchase behaviour', 'behaviors', 'behaviors', [
                        'Engaged shoppers',
                    ]),
                    'soccer' => self::named('Soccer', 'behaviors', 'behaviors', [
                        'Football fans (high content engagement)',
                        'Football fans (moderate content engagement)',
                        'Friends of football fans',
                    ]),
                    'mobile' => [
                        'label' => 'Device and operating system',
                        'facets' => [
                            self::facet('mobile_devices', 'Device', 'user_device', 'user_device', 'device', true, 'iPhone'),
                            self::facet('mobile_os', 'Operating system', 'user_os', 'user_os', 'device', true, 'iOS'),
                        ],
                    ],
                ],
            ],
        ];
    }

    /**
     * @param  list<string>  $items
     * @return array{label: string, field: string, limit: string, shape: string, items: list<string>}
     */
    private static function named(string $label, string $field, string $limit, array $items): array
    {
        return [
            'label' => $label,
            'field' => $field,
            'limit' => $limit,
            'shape' => 'object',
            'items' => $items,
        ];
    }

    /**
     * @return array{key: string, label: string, field: string, limit: string, shape: string, searchable: bool, query: string, direct: bool}
     */
    private static function facet(
        string $key,
        string $label,
        string $field,
        string $limit,
        string $shape,
        bool $searchable,
        string $query,
        bool $direct = false,
    ): array {
        return [
            'key' => $key,
            'label' => $label,
            'field' => $field,
            'limit' => $limit,
            'shape' => $shape,
            'searchable' => $searchable,
            'query' => $query,
            'direct' => $direct,
        ];
    }

    /** @return list<string> */
    private static function expats(): array
    {
        $countries = [
            'Algeria', 'Argentina', 'Australia', 'Austria', 'Bangladesh', 'Belgium', 'Brazil', 'Cameroon',
            'Canada', 'Chile', 'China', 'Colombia', 'Cuba', 'Cyprus', 'Czech Republic', 'Côte d\'Ivoire',
            'DR Congo', 'Denmark', 'Dominican Republic', 'El Salvador', 'Estonia', 'Ethiopia', 'Finland',
            'France', 'Germany', 'Ghana', 'Greece', 'Guatemala', 'Haiti', 'Honduras', 'Hong Kong',
            'Hungary', 'India', 'Indonesia', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan',
            'Kenya', 'Kuwait', 'Latvia', 'Lebanon', 'Lithuania', 'Luxembourg', 'Malaysia', 'Malta',
            'Mexico', 'Monaco', 'Morocco', 'Nepal', 'New Zealand', 'Nicaragua', 'Nigeria', 'Norway',
            'Peru', 'Philippines', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'Romania', 'Russia',
            'Rwanda', 'Saudi Arabia', 'Senegal', 'Serbia', 'Sierra Leone', 'Singapore', 'Slovakia',
            'Slovenia', 'South Africa', 'South Korea', 'Spain', 'Sri Lanka', 'Sweden', 'Switzerland',
            'Tanzania', 'Thailand', 'UAE', 'Uganda', 'Venezuela', 'Vietnam', 'Zambia', 'Zimbabwe',
            'the Netherlands', 'the UK', 'the United States',
        ];

        return [
            'Family of those who live abroad',
            'Friends of those who live abroad',
            ...array_map(fn (string $country): string => "Lived in {$country}", $countries),
            'Lives abroad',
        ];
    }

    /** @return list<string> */
    private static function mobileDevices(): array
    {
        return [
            'Android: 360 degree media not supported',
            'Android: 360 degree media supported',
            'Facebook access (mobile): all mobile devices',
            'Facebook access (mobile): feature phones',
            'Facebook access (mobile): smartphones and tablets',
            'Facebook access (mobile): tablets',
            'New smartphone and tablet users',
            'Owns: OnePlus',
            'Owns: Kindle Fire',
            'Facebook access (mobile): iPad 1',
            'Facebook access (mobile): iPad 2',
            'Facebook access (mobile): iPad 3',
            'Facebook access (mobile): iPhone 4',
            'Facebook access (mobile): iPhone 4S',
            'Facebook access (mobile): iPhone 5',
            'Facebook access (mobile): iPhone 5C',
            'Facebook access (mobile): iPhone 5S',
            'Facebook access (mobile): iPhone 8',
            'Facebook access (mobile): iPhone 8 Plus',
            'Facebook access (mobile): iPhone X',
            'Facebook access (mobile): iPhone XR',
            'Facebook access (mobile): iPhone XS',
            'Facebook access (mobile): iPhone XS Max',
            'Facebook access (mobile): iPod Touch',
            'Owns: iPad 4',
            'Owns: iPad Air',
            'Owns: iPad Air 2',
            'Owns: iPad Mini 1',
            'Owns: iPad Mini 2',
            'Owns: iPad Mini 3',
            'Owns: iPhone 6',
            'Owns: iPhone 6 Plus',
            'Owns: iPhone 6S',
            'Owns: iPhone 6S Plus',
            'Owns: iPhone 7',
            'Owns: iPhone 7 Plus',
            'Owns: iPhone SE',
            'Curve 9220',
            'Owns: Google Pixel',
            'Owns: Nexus 5',
            'Owns: Alcatel',
            'Owns: Cherry Mobile',
            'Owns: Gionee',
            'Owns: Huawei',
            'Owns: Karbonn',
            'Owns: Micromax',
            'Owns: Oppo',
            'Owns: Tecno',
            'Owns: VIVO devices',
            'Owns: Xiaomi',
            'Owns: ZTE',
            'Facebook access (mobile): HTC Android mobile devices',
            'Facebook access (mobile): Motorola Android mobile devices',
            'Facebook access (mobile): Samsung Android mobile devices',
            'Facebook access (mobile): Sony Android mobile devices',
            'Facebook access (mobile): LG Android mobile devices',
            'Owns: HTC One',
            'Owns: LG G2 devices',
            'Owns: LG G3',
            'Owns: LG V10',
            'Galaxy Note II',
            'Galaxy Tab',
            'Owns: Galaxy Grand',
            'Owns: Galaxy Grand 2',
            'Owns: Galaxy Note 3',
            'Owns: Galaxy Note 4',
            'Owns: Galaxy Note 5',
            'Owns: Galaxy Note 7',
            'Owns: Galaxy Note 8',
            'Owns: Galaxy S 4 Mini',
            'Owns: Galaxy S III Mini',
            'Owns: Galaxy S III devices',
            'Owns: Galaxy S4',
            'Owns: Galaxy S5',
            'Owns: Galaxy S6',
            'Owns: Galaxy S7',
            'Owns: Galaxy S7 Edge',
            'Owns: Galaxy S8',
            'Owns: Galaxy S8+',
            'Owns: Galaxy S9',
            'Owns: Galaxy S9+',
            'Owns: Galaxy Tab 2',
            'Owns: Galaxy Tab 3',
            'Owns: Galaxy Tab 4',
            'Owns: Galaxy Tab Pro',
            'Owns: Galaxy Tab S',
            'Owns: Galaxy Y devices',
            'Owns: Xperia M',
            'Owns: Xperia SL',
            'Owns: Xperia Z',
            'Owns: Xperia Z Ultra',
            'Owns: Xperia Z3',
            'Xperia T',
            'Facebook access (mobile): Android devices',
            'Facebook access (mobile): Apple (iOS) devices',
            'Facebook access (mobile): Windows phones',
        ];
    }
}
