<?php
declare(strict_types=1);

const APP_NAME = 'زایلون صنعت';
const APP_URL = 'http://localhost/zylon';
const APP_TIMEZONE = 'Asia/Tehran';

const DB_HOST = '127.0.0.1';
const DB_PORT = '3306';
const DB_NAME = 'zylon_db';
const DB_USER = 'root';
const DB_PASS = '';

const SESSION_NAME = 'zylon_session';
const DEFAULT_SHIPPING_FEE = 120000;
const ASSET_VERSION = '2026.05.04';

const PAYMENT_GATEWAY_MODE = 'sandbox'; // sandbox|production|mock
const ZARINPAL_MERCHANT_ID = '';
const ZARINPAL_CALLBACK_PATH = '/public/payment-callback.php';

date_default_timezone_set(APP_TIMEZONE);

function appPath(string $path = ''): string
{
    $basePath = parse_url(APP_URL, PHP_URL_PATH) ?: '';
    $basePath = rtrim($basePath, '/');
    $path = '/' . ltrim($path, '/');
    return $basePath . $path;
}

function assetPath(string $path): string
{
    $separator = strpos($path, '?') === false ? '?' : '&';
    return appPath($path) . $separator . 'v=' . urlencode(ASSET_VERSION);
}
