from django.core.management.base import BaseCommand
from inventory.models import ExteriorColors, InteriorColors


class Command(BaseCommand):
    help = "Populates the ExteriorColors and InteriorColors models with predefined data"

    exterior_colors = [
        {"rgb": "192, 192, 192", "name": "Silver Metallic", "arabic_name": "فضي معدني"},
        {"rgb": "0, 0, 0", "name": "Jet Black", "arabic_name": "أسود نفاث"},
        {"rgb": "255, 255, 255", "name": "Bright White", "arabic_name": "أبيض ناصع"},
        {"rgb": "128, 128, 128", "name": "Graphite Gray", "arabic_name": "رمادي غرافيتي"},
        {"rgb": "80, 80, 80", "name": "Gunmetal Gray", "arabic_name": "رمادي معدني"},
        {"rgb": "255, 0, 0", "name": "Racing Red", "arabic_name": "أحمر سباق"},
        {"rgb": "255, 69, 0", "name": "Inferno Orange", "arabic_name": "برتقالي جهنمي"},
        {"rgb": "0, 0, 255", "name": "Deep Blue Pearl", "arabic_name": "أزرق لؤلؤي عميق"},
        {"rgb": "75, 0, 130", "name": "Indigo Night", "arabic_name": "ليلة نيلي"},
        {"rgb": "255, 215, 0", "name": "Solar Gold", "arabic_name": "ذهبي شمسي"},
        {"rgb": "34, 139, 34", "name": "Emerald Green", "arabic_name": "أخضر زمردي"},
        {"rgb": "60, 179, 113", "name": "Forest Mist Green", "arabic_name": "أخضر ضباب الغابة"},
        {"rgb": "255, 140, 0", "name": "Burnt Amber", "arabic_name": "كهرماني محروق"},
        {"rgb": "160, 82, 45", "name": "Copper Brown", "arabic_name": "بني نحاسي"},
        {"rgb": "128, 0, 0", "name": "Crimson Maroon", "arabic_name": "ماروني قرمزي"},
        {"rgb": "245, 245, 220", "name": "Beige Champagne", "arabic_name": "بيج شامبين"},
        {"rgb": "169, 169, 169", "name": "Shadow Gray", "arabic_name": "رمادي ظل"},
        {"rgb": "255, 250, 205", "name": "Lemon Pearl", "arabic_name": "لؤلؤي ليموني"},
        {"rgb": "220, 220, 220", "name": "Platinum Silver", "arabic_name": "فضي بلاتيني"},
        {"rgb": "105, 105, 105", "name": "Charcoal Metallic", "arabic_name": "رمادي فحمي معدني"},
        {"rgb": "128, 0, 128", "name": "Royal Purple", "arabic_name": "أرجواني ملكي"},
        {"rgb": "210, 105, 30", "name": "Sunset Bronze", "arabic_name": "برونزي الغروب"},
        {"rgb": "0, 128, 128", "name": "Teal Lagoon", "arabic_name": "أزرق مخضر بحري"},
        {"rgb": "72, 61, 139", "name": "Midnight Blue", "arabic_name": "أزرق منتصف الليل"},
        {"rgb": "255, 20, 147", "name": "Blazing Pink", "arabic_name": "وردي لامع"},
        {"rgb": "192, 57, 43", "name": "Crimson Flame", "arabic_name": "لهب قرمزي"},
        {"rgb": "255, 228, 196", "name": "Cream Sand", "arabic_name": "كريم رملي"},
        {"rgb": "112, 128, 144", "name": "Steel Gray", "arabic_name": "رمادي فولاذي"},
        {"rgb": "0, 100, 0", "name": "Hunter Green", "arabic_name": "أخضر صياد"},
        {"rgb": "255, 223, 0", "name": "Bright Yellow", "arabic_name": "أصفر ساطع"},
        {"rgb": "85, 107, 47", "name": "Olive Metallic", "arabic_name": "زيتوني معدني"},
        {"rgb": "128, 128, 0", "name": "Mustard Gold", "arabic_name": "ذهبي خردلي"},
        {"rgb": "139, 69, 19", "name": "Cocoa Brown", "arabic_name": "بني كاكاو"},
        {"rgb": "255, 165, 0", "name": "Tangerine Flame", "arabic_name": "لهب المندرين"},
        {"rgb": "0, 0, 139", "name": "Navy Sapphire", "arabic_name": "كحلي ياقوتي"},
        {"rgb": "70, 130, 180", "name": "Skyline Blue", "arabic_name": "أزرق أفق"},
        {"rgb": "220, 20, 60", "name": "Crimson Passion", "arabic_name": "شغف قرمزي"},
        {"rgb": "189, 183, 107", "name": "Khaki Dune", "arabic_name": "كاكي كثيب"},
        {"rgb": "50, 205, 50", "name": "Lime Essence", "arabic_name": "ليموني نقي"},
        {"rgb": "139, 0, 139", "name": "Amethyst Glow", "arabic_name": "توهج جمشت"},
        {"rgb": "255, 215, 180", "name": "Rosé Gold", "arabic_name": "ذهبي وردي"},
        {"rgb": "46, 139, 87", "name": "Moss Green", "arabic_name": "أخضر طحلبي"},
        {"rgb": "72, 209, 204", "name": "Caribbean Aqua", "arabic_name": "أكوا كاريبي"},
        {"rgb": "255, 240, 245", "name": "Pearl Blush", "arabic_name": "تورد لؤلؤي"},
        {"rgb": "244, 164, 96", "name": "Sierra Sunset", "arabic_name": "غروب سييرا"},
        {"rgb": "139, 0, 0", "name": "Crimson Ruby", "arabic_name": "روبي قرمزي"},
        {"rgb": "192, 192, 192", "name": "Chrome", "arabic_name": "كروم"},
        {"rgb": "255, 105, 180", "name": "Hot Magenta", "arabic_name": "ماجنتا ساخن"},
        {"rgb": "0, 255, 255", "name": "Ice Blue", "arabic_name": "أزرق جليدي"},
        {"rgb": "184, 134, 11", "name": "Golden Bronze", "arabic_name": "برونزي ذهبي"},
        {"rgb": "128, 128, 64", "name": "Bronze Olive", "arabic_name": "زيتوني برونزي"},
    ]

    interior_colors = [
        {"rgb": "0, 0, 0", "name": "Jet Black", "arabic_name": "أسود نفاث"},
        {"rgb": "54, 69, 79", "name": "Charcoal Black", "arabic_name": "أسود فحمي"},
        {"rgb": "255, 255, 255", "name": "Bright White", "arabic_name": "أبيض ناصع"},
        {"rgb": "245, 245, 220", "name": "Off-White", "arabic_name": "أبيض مصفر"},
        {"rgb": "210, 180, 140", "name": "Beige", "arabic_name": "بيج"},
        {"rgb": "203, 194, 190", "name": "Sandstone", "arabic_name": "حجر رملي"},
        {"rgb": "80, 80, 80", "name": "Graphite Gray", "arabic_name": "رمادي غرافيتي"},
        {"rgb": "127, 128, 133", "name": "Ebony/Medium Slate", "arabic_name": "إيبوني/لائحة متوسطة"},
        {"rgb": "124, 79, 58", "name": "Mocha", "arabic_name": "موكا"},
        {"rgb": "193, 154, 107", "name": "Camel Tan", "arabic_name": "بيج الجمل"},
        {"rgb": "128, 0, 0", "name": "Maroon", "arabic_name": "مارون"},
        {"rgb": "0, 0, 128", "name": "Navy Blue", "arabic_name": "أزرق بحري"},
        {"rgb": "25, 25, 112", "name": "Midnight Blue", "arabic_name": "أزرق منتصف الليل"},
        {"rgb": "72, 60, 50", "name": "Taupe", "arabic_name": "توب"},
    ]

    def handle(self, *args, **kwargs):
        self.stdout.write("Populating Exterior Colors...")
        for color in self.exterior_colors:
            obj, created = ExteriorColors.objects.get_or_create(
                name=color["name"], arabic_name=color["arabic_name"], rgb=color["rgb"]
            )
            if created:
                self.stdout.write(f"Added Exterior Color: {obj.name} ({obj.rgb})")
            else:
                self.stdout.write(f"Exterior Color already exists: {obj.name} ({obj.rgb})")

        self.stdout.write("Populating Interior Colors...")
        for color in self.interior_colors:
            obj, created = InteriorColors.objects.get_or_create(
                name=color["name"], arabic_name=color["arabic_name"], rgb=color["rgb"]
            )
            if created:
                self.stdout.write(f"Added Interior Color: {obj.name} ({obj.rgb})")
            else:
                self.stdout.write(f"Interior Color already exists: {obj.name} ({obj.rgb})")

        self.stdout.write("Finished populating colors.")