<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Http\RequestHandlers\CreateMediaObjectFromFile;
use Fisharebest\Webtrees\I18N;

/**
 * @var array<int|string,string> $media_types
 */
?>

<div class="modal fade" data-bs-backdrop="static" tabindex="-1" role="dialog" aria-hidden="true" id="modal-create-media-from-file">
    <form method="post" action="<?= e(route(CreateMediaObjectFromFile::class)) ?>" id="modal-create-media-from-file-form">
        <input type="hidden" name="action" value="create-media-object-from-file">
        <input type="hidden" name="tree" id="tree" value="">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h3 class="modal-title"><?= I18N::translate('Create a media object') ?></h3>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?= I18N::translate('close') ?>">
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row mb-3">
                        <label class="col-form-label col-sm-2" for="file">
                            <?= I18N::translate('Media file') ?>
                        </label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="file" name="file" value="" readonly>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-form-label col-sm-2" for="title">
                            <?= I18N::translate('Title') ?>
                        </label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="title" id="title">
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-form-label col-sm-2" for="type">
                            <?= I18N::translate('Media type') ?>
                        </label>
                        <div class="col-sm-10">
                            <?= view('components/select', ['name' => 'type', 'selected' => '', 'options' => $media_types]) ?>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <label class="col-form-label col-sm-2" for="note">
                            <?= I18N::translate('Note') ?>
                        </label>
                        <div class="col-sm-10">
                            <textarea class="form-control" id="note" name="note" rows="5" dir="auto"></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">
                        <?= view('icons/save') ?>
                        <?= I18N::translate('save') ?>
                    </button>
                    <button type="button" class="btn btn-text" data-bs-dismiss="modal">
                        <?= view('icons/cancel') ?>
                        <?= I18N::translate('cancel') ?>
                    </button>
                </div>
            </div>
        </div>

        <?= csrf_field() ?>
    </form>
</div>
