<?php
declare(strict_types=1);
require_once __DIR__ . '/functions.php';
require_admin_login();
$conn = nay_theme_db();
nay_theme_ensure_settings($conn);
$values = nay_theme_get_values($conn);
$map = nay_theme_legacy_key_map();
foreach ($map as $modern => $legacy) {
    $value = trim((string)($values[$modern] ?? ''));
    nay_theme_upsert_setting($conn, $modern, $value, 'appearance_theme');
    nay_theme_upsert_setting($conn, $legacy, $value, 'home');
}
header('Location: /app/admin/themes/index.php?sync=1');
exit;
