Config = Config or {}
Config.Debug = false

-- Language for all in-game text and the UI. Must match a locales/<code>.json
-- file ('en', 'es', ...). Missing translations fall back to English.
-- To add a language: copy locales/en.json, translate the values, set the code here.
Config.Locale = 'en'

-- Error reporting (sends runtime errors to 9am.dev for diagnostics)
Config.ReportErrors = false

-- Interaction mode: 'target' | 'marker' | 'textui' | '3dtext'
Config.InteractionMode = 'textui'

-- Default garage where purchased vehicles are stored.
-- Auto-detected based on framework; override below if needed.
Config.DefaultGarage = GetResourceState('es_extended') == 'started' and 'VespucciBoulevard' or 'pillboxgarage'

-- Spawn purchased vehicle at the shop and warp player into it (true = spawn at shop, false = save to garage only)
Config.SpawnOnPurchase = true

-- Show a cloned copy of the player seated in the preview vehicle in catalog view
Config.ShowPreviewDriverPed = true

-- VAT applied to all vehicle purchases (0.1 = 10%)
Config.GlobalVAT = 0.1

-- Commission rate paid to sales representatives on in-person sales (0.10 = 10%)
Config.SalesCommission = 0.10

-- Vehicle catalog image URL template (%s = vehicle spawn model).
-- Per-vehicle override: add `image = 'https://...'` to an entry in vehicles.lua
-- (useful for addon vehicles that FiveM's CDN does not host).
Config.VehicleImageUrl = 'https://docs.fivem.net/vehicles/%s.webp'

-- License plate format for purchased vehicles.
-- 'A' = random letter, '0' = random digit, any other character is kept as-is.
-- Maximum 8 characters (GTA plate limit).
Config.PlateFormat = 'AAAA0000'

-- Phone dealership app (optional — supports lb-phone and cylex_phone; the
-- running one is detected automatically, nothing to configure).
-- Employees can open the dashboard from their phone; permissions apply as usual.
Config.PhoneApp = {
    enabled    = true,
    identifier = '9am-dealership',
    -- App icon shown in the phone. Defaults to the bundled icon (served from
    -- this resource); set any https:// image URL here to customize.
    icon       = nil,
}

-- NPC suppression inside dealership zones.
-- While a player is within `radius` of a dealership, ambient pedestrians,
-- wandering traffic, and parked-vehicle generators stop spawning around them.
-- Player-driven vehicles, dealer peds, and showroom vehicles are unaffected.
Config.NpcSuppression = {
    enabled  = true,  -- master toggle for the whole feature
    radius   = 60.0,  -- suppression radius (meters) around each shop's dealer ped
    peds     = true,  -- block ambient pedestrians & scenario peds
    vehicles = true,  -- block ambient traffic & parked vehicle generators
}

-- Shop definitions
-- Key must match the 'shop' field in vehicles.lua entries
Config.Shops = {}
-- Dealerships are DB-driven: table `9am_vehicleshop_dynamic_shops`, managed in-game
-- via /dealerships. The former static pdm/air/boats definitions were moved to
-- server/migrations.lua and are seeded into the database once on first boot.

-- Blocked vehicle models (too large to spawn safely)
Config.BlockedModels = {
    'cargoplane', 'titan', 'bombushka', 'volatol', 'alkonost',
    'tula', 'strikeforce', 'mogul', 'rogue', 'starling',
}

-- Color palette (colorIndex → GTA paint index) — used by both catalog and showroom.
-- Keep in sync with web/src/constants/catalogColors.ts.
Config.CatalogColors = {
    [0]  = 0,    -- Black
    [1]  = 134,  -- White
    [2]  = 4,    -- Silver
    [3]  = 27,   -- Red
    [4]  = 40,   -- Dark Red
    [5]  = 38,   -- Orange
    [6]  = 89,   -- Yellow
    [7]  = 92,   -- Lime Green
    [8]  = 53,   -- Green
    [9]  = 54,   -- Teal
    [10] = 87,   -- Light Blue
    [11] = 62,   -- Navy
    [12] = 145,  -- Purple
    [13] = 135,  -- Pink
    [14] = 98,   -- Brown
    [15] = 37,   -- Gold
    [16] = 3,    -- Graphite
}

-- ============================================================
-- Order System & Delivery Mission
-- ============================================================
Config.Orders = {
    preparationTime = 30, -- minutes until order is ready (lower it for testing)

    delivery = {
        enabled = true, -- if false, ready orders add to stock via "Receive" button directly

        truckModel = 'phantom',
        -- Port parking slots for trailer pre-spawn
        trailerSlots = {
            vector4(929.0, -3130.0, 6.0, 0.0),
            vector4(933.05, -3130.0, 6.0, 0.0),
            vector4(937.1, -3130.0, 6.0, 0.0),
            vector4(941.15, -3130.0, 6.0, 0.0),
            vector4(945.2, -3130.0, 6.0, 0.0),
            vector4(949.25, -3130.0, 6.0, 0.0),
            vector4(953.3, -3130.0, 6.0, 0.0),
            vector4(957.35, -3130.0, 6.0, 0.0),
            vector4(961.4, -3130.0, 6.0, 0.0),
            vector4(965.45, -3130.0, 6.0, 0.0),
            vector4(969.5, -3130.0, 6.0, 0.0),
        },
        carTrailer = {
            model = 'tr2',
            maxSlots = 6, -- 2 rows x 3 small slots
        },
        containerTrailer = {
            model = 'trailers4',
            maxSlots = 12,
        },
        -- Per-shop: truck spawn & delivery destination
        shops = {
            ['pdm'] = {
                truckSpawn    = vector4(-18.5449, -1105.3633, 26.7405, 160.0018),
                deliveryPoint = vector4(-45.0, -1082.0, 26.7, 70.0),
            },
            ['air'] = {
                truckSpawn    = vector4(-1330.0, -3040.0, 14.7, 56.0),
                deliveryPoint = vector4(-1340.0, -3050.0, 14.7, 56.0),
            },
            ['boats'] = {
                truckSpawn    = vector4(-711.2220, -1275.4685, 5.0678, 139.9744),
                deliveryPoint = vector4(-711.2220, -1275.4685, 5.0678, 139.9744),
            },
        },
    },

    -- Vehicle size by category (S=1 slot, M=1.5 slots, L=1.5 slots, XL=6 slots)
    -- Container accepts all sizes, Car Trailer accepts S/M/L only (XL = container only)
    vehicleSizes = {
        compacts       = 'S',
        sedans         = 'M',
        coupes         = 'M',
        sports         = 'M',
        muscle         = 'M',
        sportsclassics = 'M',
        super          = 'M',
        motorcycles    = 'S',
        offroad        = 'M',
        suvs           = 'L',
        vans           = 'M',
        cycles         = 'S',
        commercial     = 'XL',
        industrial     = 'XL',
        military       = 'XL',
        service        = 'M',
        emergency      = 'M',
        boats          = 'XL',
        helicopters    = 'XL',
        planes         = 'XL',
        utility        = 'M',
        open_wheel     = 'M',
    },

    -- Slot costs per size
    slotCosts = {
        S = 1,
        M = 1.5,
        L = 1.5,
        XL = 6,
    },

    -- Models too large for car trailer — forced to XL (container only)
    containerOnlyModels = {
        'burrito3', 'gburrito2', 'caracara', 'caracara2',
        'contender', 'trophytruck2', 'dubsta', 'dubsta3',
        'patriot', 'patriot2', 'mesa3', 'moonbeam', 'paradise',
    },
}

-- ============================================================
-- Test Drive System
-- ============================================================
Config.TestDrive = {
    duration          = 60,    -- seconds the player can drive
    useRoutingBucket  = false, -- true = test drive in isolated bucket; false = normal world
    endKey            = 73,    -- X key (control index) to end test drive early
    cooldownSeconds   = 60,    -- cooldown between test drives per player
}

-- ============================================================
-- Vehicle Finance System
-- ============================================================
Config.Finance = {
    minDownPaymentPercent = 0.25,   -- 25% minimum down payment
    maxDownPaymentPercent = 0.90,   -- highest down payment the buyer can choose
    interestRate          = 0.10,   -- 10% interest on financed amount
    totalPayments         = 12,     -- default number of installments
    minPayments           = 2,      -- fewest installments the buyer can choose
    maxPayments           = 24,     -- most installments the buyer can choose
    paymentIntervalHours  = 12,     -- hours between auto-deductions (real-time)
    autoDeductFrom        = 'bank', -- auto-deduct from this account type
}

return Config
