<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Phase 1: which campaigns to dump
    |--------------------------------------------------------------------------
    */

    'platforms' => array_values(array_filter(array_map(
        trim(...),
        explode(',', (string) env('CAMPAIGN_PERF_PLATFORMS', 'meta')),
    ))),

    'external_ids' => array_values(array_filter(array_map(
        trim(...),
        explode(',', (string) env('CAMPAIGN_PERF_EXTERNAL_IDS', '')),
    ))),

    'limit' => (int) env('CAMPAIGN_PERF_LIMIT', 5),

    /*
    | First daily dump (or a campaign whose stored history does not reach start)
    | pulls from platform start through today, capped by max_history_days.
    | Later daily dumps refresh the previous 24 hours.
    |
    | Hourly ingest uses fixed windows in PerformanceWindows: lifetime backfill on
    | first run, then a 3-hour refresh each hourly cron. Analysis hour lengths
    | (3, 5, 7) are also fixed there — not env-driven.
    */
    'backfill_days' => (int) env('CAMPAIGN_PERF_BACKFILL_DAYS', 7),

    'daily_lookback_hours' => (int) env('CAMPAIGN_PERF_DAILY_LOOKBACK_HOURS', 24),

    'max_history_days' => (int) env('CAMPAIGN_PERF_MAX_HISTORY_DAYS', 730),

    'learning_window_days' => (int) env('CAMPAIGN_PERF_LEARNING_DAYS', 3),
    'max_test_spend' => (float) env('CAMPAIGN_PERF_MAX_TEST_SPEND', 40),
    'zero_click_spend_floor' => (float) env('CAMPAIGN_PERF_ZERO_CLICK_SPEND', 10),
    'max_cpc' => (float) env('CAMPAIGN_PERF_MAX_CPC', 2),
    'llm_enabled' => true,
    'skip_llm_while_learning' => true,
    'skip_llm_when_paused_zero_spend' => true,

    /*
    |--------------------------------------------------------------------------
    | Whale affiliate rollup (arb_adops_campaign_performance)
    |--------------------------------------------------------------------------
    |
    | Read-only join on whale.campaign_id = external_campaign_id. Campaigns
    | without matching rows are skipped. Table must exist outside ARB migrations.
    |
    */

    'whale_enabled' => (bool) env('CAMPAIGN_PERF_WHALE', false),

];
