<?php

declare(strict_types=1);

namespace mirzaev\arming_bot;

// Files of the project
use mirzaev\arming_bot\controllers\core as controller,
	mirzaev\arming_bot\models\core as model;

// Framework for PHP
use mirzaev\minimal\core,
	mirzaev\minimal\router;

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

// Версия робота
define('ROBOT_VERSION', '1.0.0');
define('VIEWS', realpath('..' . DIRECTORY_SEPARATOR . 'views'));
define('STORAGE', realpath('..' . DIRECTORY_SEPARATOR . 'storage'));
define('SETTINGS', realpath('..' . DIRECTORY_SEPARATOR . 'settings'));
define('INDEX', __DIR__);
define('THEME', 'default');

// Initialize dependencies
require __DIR__ . DIRECTORY_SEPARATOR
	. '..' . DIRECTORY_SEPARATOR
	. '..' . DIRECTORY_SEPARATOR
	. '..' . DIRECTORY_SEPARATOR
	. '..' . DIRECTORY_SEPARATOR
	. 'vendor' . DIRECTORY_SEPARATOR
	. 'autoload.php';

// Initialize the router
$router = new router;

// Initialize routes
$router
	->write('/', 'catalog', 'index', 'GET')
	->write('/', 'catalog', 'index', 'POST')
	->write('/account/write', 'account', 'write', 'POST')
	->write('/session/write', 'session', 'write', 'POST')
	->write('/session/connect/telegram', 'session', 'telegram', 'POST')
	/* ->write('/category/$identifier', 'catalog', 'index', 'POST') */
	/* ->write('/category', 'catalog', 'index', 'POST') */
	/* ->write('/product/$identifier', 'catalog', 'product', 'POST') */
;

/*

// Initializing of routes
$router
	->write('/', 'catalog', 'index', 'GET')
	->write('/$sex', 'catalog', 'search', 'POST')
	->write('/$search', 'catalog', 'search', 'POST')
	->write('/search', 'catalog', 'search', 'POST')
	->write('/search/$asdasdasd', 'catalog', 'search', 'POST')
	->write('/ebala/$sex/$categories...', 'catalog', 'index', 'POST')
	->write('/$sex/$categories...', 'catalog', 'index', 'POST')
	->write('/$categories...', 'catalog', 'index', 'POST')
	->write('/ebala/$categories...', 'catalog', 'index', 'POST');

var_dump($router->routes);
echo "\n\n\n\n\n\n";
$router
	->sort();
var_dump($router->routes); */

// Initialize the core
$core = new core(namespace: __NAMESPACE__, router: $router, controller: new controller(false), model: new model(false));

// Handle the request
echo $core->start();
