<?php

use Silvanus\includes\blocks\AcfBlockFields;

try {
    $fields = new AcfBlockFields('Two Column Media + Text', __FILE__);

    $fields->addContainerSettings();

    $fields->addTrueFalse('swap_sides', [
        'label' => 'Swap sides',
        'ui' => 1,
        'default_value' => 0,
        'instructions' => 'If enabled, media appears on the left and content on the right (desktop). On mobile, content always stacks on top.',
    ]);

    $fields->addNumber('column_gap', [
        'label' => 'Column gap (px)',
        'default_value' => 100,
        'min' => 0,
        'max' => 300,
        'step' => 5,
        'instructions' => 'Space between columns on desktop. Default: 100px.',
    ]);

    $fields->addText('title', [
        'label' => 'Title',
        'required' => 0,
    ]);

    $fields->addWysiwyg('body', [
        'label' => 'Body',
        'required' => 0,
        'tabs' => 'all',
        'toolbar' => 'full',
        'media_upload' => 0,
    ]);

    $fields->addLink('button', [
        'label' => 'Button',
        'return_format' => 'array',
        'required' => 0,
    ]);

    $fields->addImage('media_image', [
        'label' => 'Image',
        'return_format' => 'id',
        'preview_size' => 'medium',
        'library' => 'all',
        'mime_types' => 'png,jpg,jpeg,webp,svg',
        'required' => 0,
        'instructions' => 'Optional. Use either Image OR Video.',
    ]);

    $fields->addFile('media_video', [
        'label' => 'Video',
        'return_format' => 'array',
        'library' => 'all',
        'mime_types' => 'mp4,webm,ogg',
        'required' => 0,
        'instructions' => 'Optional. Use either Video OR Image.',
    ]);

    return $fields->build();
} catch (\StoutLogic\AcfBuilder\FieldNameCollisionException $e) {
    // no-op
}