<?php
require_once __DIR__ . '/../app/bootstrap.php';

$basePath = app_base_path();
$path = static function (string $relative) use ($basePath): string {
    return ($basePath === '' ? '' : $basePath) . '/' . ltrim($relative, '/');
};

$manifest = [
    'name' => APP_NAME . ' - ' . BRAND_NAME . ' Pro POS',
    'short_name' => 'PH POS',
    'start_url' => $path('public/index.php'),
    'scope' => $path('') ?: '/',
    'display' => 'standalone',
    'background_color' => '#ffffff',
    'theme_color' => '#0B5FFF',
    'icons' => [
        ['src' => $path('public/assets/brand/icon-192.png'), 'sizes' => '192x192', 'type' => 'image/png'],
        ['src' => $path('public/assets/brand/icon-512.png'), 'sizes' => '512x512', 'type' => 'image/png'],
    ],
    'display_override' => ['window-controls-overlay', 'standalone', 'minimal-ui'],
    'orientation' => 'any',
    'description' => 'Multi-vendor marketplace and professional POS for ' . APP_NAME . ' / ' . BRAND_NAME . '.',
    'categories' => ['shopping', 'business', 'productivity'],
    'shortcuts' => [
        [
            'name' => 'Launch Pro POS',
            'short_name' => 'POS',
            'url' => $path('pos/register.php'),
            'icons' => [['src' => $path('public/assets/brand/icon-192.png'), 'sizes' => '192x192', 'type' => 'image/png']],
        ],
        [
            'name' => 'Open Shift',
            'short_name' => 'Shift',
            'url' => $path('pos/shifts.php'),
            'icons' => [['src' => $path('public/assets/brand/icon-192.png'), 'sizes' => '192x192', 'type' => 'image/png']],
        ],
        [
            'name' => 'Vendor Panel',
            'short_name' => 'Vendor',
            'url' => $path('vendor/pos.php'),
            'icons' => [['src' => $path('public/assets/brand/icon-192.png'), 'sizes' => '192x192', 'type' => 'image/png']],
        ],
    ],
];

header('Content-Type: application/manifest+json; charset=utf-8');
header('Cache-Control: public, max-age=3600');
echo json_encode($manifest, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
