<?php declare(strict_types = 0);
/*
** Copyright (C) 2021-2026 initMAX s.r.o.
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/

/**
 * tetrisMAX widget form view (Zabbix 7.0 - 7.4).
 *
 * 6.4 loads this same manifest-v2 tree against the OLDER form API and needs a
 * different file: there the field views have no setFieldHint(). Probing field
 * by field inside one view hides that difference rather than handling it, so
 * 6.4 gets widget.edit.64.php - the SAME field, the same label, the same
 * tooltip.
 *
 * @var CView $this
 * @var array $data
 */

use Modules\TetrisMAX\Includes\Compat;
use Modules\TetrisMAX\Services\ProTeaser;
use Modules\TetrisMAX\Services\WidgetTranslator;

if (!Compat::hasFieldHintApi()) {
	require __DIR__.'/widget.edit.64.php';

	return;
}

$form = (new CWidgetFormView($data))
	->addField(
		(new CWidgetFieldRadioButtonListView($data['fields']['speed']))
			->setFieldHint(makeHelpIcon(WidgetTranslator::translate('form.hint.speed')))
	);

// PRO field rows from features.yaml teaser_fields - none for tetrisMAX, so
// this renders nothing; kept so the form is wired like every other widget.
ProTeaser::renderRows($form, $data['fields']);

// Edition badge (initmax-free) + "Give us feedback" link at the top of the
// form, drawn by the CI-injected ProTeaser (window.initmaxProTeaser).
$form
	->addJavaScript(ProTeaser::initJs())
	->show();
