<?php

namespace DZ\ImageShield\Option;

use XF;
use XF\Entity\Option;
use XF\Option\AbstractOption;

/**
 * Option handler for blend/opacity configuration.
 */
class Blend extends AbstractOption
{
    /**
     * Render the option template.
     */
    public static function renderOption(Option $option, array $htmlParams): string
    {
        return self::getTemplate(
            'admin:dz_imageshield_option_blend',
            $option,
            $htmlParams
        );
    }

    /**
     * Verify and normalize the option value before saving.
     */
    public static function verifyOption(array &$value, Option $option, string $optionId): bool
    {
        // Normalize opacity
        $value['opacity'] = max(10, min(100, (int) ($value['opacity'] ?? 80)));

        return true;
    }
}
