<?php

declare(strict_types=1);

namespace BeycanPress\Tokenico\Pages;

use BeycanPress\Tokenico\Service;
use BeycanPress\Tokenico\PluginHero\Page;
use BeycanPress\Tokenico\PluginHero\Helpers;

class Creator extends Page
{
    /**
     * @return void
     */
    public function __construct()
    {
        $param = defined('BP_TOKENICO_PRO_LOADED') ? esc_html__(' Premium', 'tokenico') : '';

        parent::__construct([
            'priority' => 1,
            'subMenu' => true,
            'slug' => 'tokenico-creator',
            'icon' => Helpers::getImageUrl('menu1.png'),
            'subMenuPageName' => esc_html__('Creator', 'tokenico'),
            'pageName' => sprintf(esc_html__('TokenICO%s', 'tokenico'), $param),
        ]);

        add_action('admin_head', function (): void {
            echo '<style>
                .toplevel_page_tokenico-creator .wp-menu-image img {
                    width: 18px!important;
                    margin-top: -3px!important;
                }
            </style>';
        });
    }

    /**
     * @return void
     */
    public function page(): void
    {
        Service::initAssets([
            'creator' => true,
        ]);

        Helpers::viewEcho('pages/creator');
    }
}
