<?php

namespace MODELORA\Viewer;

if (! defined('ABSPATH')) {
    exit;
}

class Performance
{
    public function register(): void
    {
        add_filter('modelora_viewer_attributes', [$this, 'apply_performance_attributes']);
    }

    public function apply_performance_attributes(array $attributes): array
    {
        $settings = get_option('modelora_settings', []);

        if (! empty($settings['lazy_load'])) {
            $attributes['loading'] = 'lazy';
        }

        if (! empty($settings['progressive_loading'])) {
            $attributes['reveal'] = 'interaction';
        }

        if (! empty($settings['auto_lod'])) {
            $attributes['data-auto-lod'] = '1';
        }

        return $attributes;
    }
}
