<?php

namespace GriffinForms\Includes\Onboarding\Builderdetectors;

use GriffinForms\Traits\Singleton;

class Gutenberg extends \GriffinForms\Format
{
    use Singleton;

    public function detect(\WP_Post $post): ?array
    {
        if (!function_exists('has_blocks')) {
            return null;
        }

        $content = (string) $post->post_content;
        if ($content === '' || !has_blocks($content)) {
            return null;
        }

        return [
            'classification' => 'caution',
            'builder_key' => 'gutenberg',
            'confidence' => 'high',
            'reasons' => [
                'Block-editor content was detected via has_blocks().',
                'Placement uses the native GriffinForms block when block editor support is available, with a shortcode fallback when needed.',
            ],
        ];
    }
}
