<?php

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound -- APD is the established namespace shared with the Pro add-on and retained for backward compatibility.
namespace APD\Front;

defined('ABSPATH') || exit;

class Renderer
{
    public function __construct(protected FrontContextBuilder $contextBuilder)
    {
    }

    public function render(array $atts = []) : string
    {
        $context = $this->contextBuilder->build($atts);
        $mountId = 'apd-mount-' . wp_generate_password(8, false, false);

        /** @var FrontAssets $assets */
        $assets = new FrontAssets();
        $assets->enqueue();

        ob_start();
        $config = $context['config'];
        $productId = (int) ($context['productId'] ?? 0);
        $configId = (int) ($context['configId'] ?? 0);
        $canSaveDesign = ! empty($context['canSaveDesign']);
        include ASUKA_PRODUCT_DESIGNER_PATH . 'templates/frontend/mount.php';
        return (string) ob_get_clean();
    }
}
