<?php

namespace {
/*
 * This file is part of Contao.
 *
 * (c) Leo Feyer
 *
 * @license LGPL-3.0-or-later
 */
$GLOBALS['TL_DCA']['tl_settings'] = array(
    // Config
    'config' => array('dataContainer' => \Contao\DC_File::class, 'closed' => \true),
    // Palettes
    'palettes' => array('default' => '{global_legend},adminEmail;{date_legend},dateFormat,timeFormat,datimFormat,timeZone;{backend_legend:hide},doNotCollapse,resultsPerPage,maxResultsPerPage;{frontend_legend},folderUrl,doNotRedirectEmpty;{security_legend:hide},disableRefererCheck,allowedTags,allowedAttributes;{files_legend:hide},allowedDownload,gdMaxImgWidth,gdMaxImgHeight;{uploads_legend:hide},uploadTypes,maxFileSize,imageWidth,imageHeight;{cron_legend:hide},disableCron;{chmod_legend},defaultUser,defaultGroup,defaultChmod'),
    // Fields
    'fields' => array('dateFormat' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'helpwizard' => \true, 'decodeEntities' => \true, 'tl_class' => 'w50'), 'explanation' => 'dateFormat'), 'timeFormat' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'decodeEntities' => \true, 'tl_class' => 'w50')), 'datimFormat' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'decodeEntities' => \true, 'tl_class' => 'w50')), 'timeZone' => array('inputType' => 'select', 'options_callback' => static function () {
        return \Contao\System::getTimeZones();
    }, 'eval' => array('chosen' => \true, 'tl_class' => 'w50')), 'adminEmail' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'friendly', 'decodeEntities' => \true, 'tl_class' => 'w50')), 'disableCron' => array('inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50')), 'resultsPerPage' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'minval' => 1, 'nospace' => \true, 'tl_class' => 'w50 clr')), 'maxResultsPerPage' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'nospace' => \true, 'tl_class' => 'w50')), 'doNotCollapse' => array('inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50')), 'doNotRedirectEmpty' => array('inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50')), 'folderUrl' => array('inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50')), 'disableRefererCheck' => array('inputType' => 'checkbox'), 'allowedTags' => array('inputType' => 'text', 'eval' => array('useRawRequestData' => \true, 'tl_class' => 'long')), 'allowedAttributes' => array('label' => &$GLOBALS['TL_LANG']['tl_settings']['allowedAttributes'], 'inputType' => 'keyValueWizard', 'eval' => array('tl_class' => 'clr'), 'load_callback' => array(static function ($varValue) {
        $showWarning = \false;
        foreach (\Contao\StringUtil::deserialize($varValue, \true) as $row) {
            if (\in_array('*', \Contao\StringUtil::trimsplit(',', $row['value']), \true)) {
                $showWarning = \true;
                break;
            }
        }
        if ($showWarning) {
            $GLOBALS['TL_DCA']['tl_settings']['fields']['allowedAttributes']['label'][1] = '<span style="color: #c33;">' . $GLOBALS['TL_LANG']['tl_settings']['allowedAttributesWarning'] . '</span>';
        }
        return $varValue;
    }), 'save_callback' => array(static function ($strValue) {
        $arrValue = \Contao\StringUtil::deserialize($strValue, \true);
        $arrAllowedAttributes = array();
        foreach ($arrValue as $intIndex => $arrRow) {
            foreach (\Contao\StringUtil::trimsplit(',', \strtolower($arrRow['key'])) as $strKey) {
                $arrAllowedAttributes[$strKey] = \array_merge($arrAllowedAttributes[$strKey] ?? array(), \Contao\StringUtil::trimsplit(',', \strtolower($arrRow['value'])));
                $arrAllowedAttributes[$strKey] = \array_filter(\array_unique($arrAllowedAttributes[$strKey]));
                \sort($arrAllowedAttributes[$strKey]);
            }
        }
        \ksort($arrAllowedAttributes);
        $arrValue = array();
        foreach ($arrAllowedAttributes as $strTag => $arrAttributes) {
            $arrValue[] = array('key' => $strTag, 'value' => \implode(',', $arrAttributes));
        }
        return \serialize($arrValue);
    })), 'allowedDownload' => array('inputType' => 'text', 'eval' => array('tl_class' => 'w50')), 'gdMaxImgWidth' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'nospace' => \true, 'tl_class' => 'w50 clr')), 'gdMaxImgHeight' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'nospace' => \true, 'tl_class' => 'w50')), 'uploadTypes' => array('inputType' => 'text', 'eval' => array('tl_class' => 'w50')), 'maxFileSize' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'nospace' => \true, 'tl_class' => 'w50')), 'imageWidth' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'nospace' => \true, 'tl_class' => 'w50')), 'imageHeight' => array('inputType' => 'text', 'eval' => array('mandatory' => \true, 'rgxp' => 'natural', 'nospace' => \true, 'tl_class' => 'w50')), 'defaultUser' => array('inputType' => 'select', 'foreignKey' => 'tl_user.username', 'eval' => array('chosen' => \true, 'includeBlankOption' => \true, 'tl_class' => 'w50')), 'defaultGroup' => array('inputType' => 'select', 'foreignKey' => 'tl_user_group.name', 'eval' => array('chosen' => \true, 'includeBlankOption' => \true, 'tl_class' => 'w50')), 'defaultChmod' => array('inputType' => 'chmod', 'eval' => array('tl_class' => 'clr'))),
);
}

namespace {
$GLOBALS['TL_DCA']['tl_settings']['palettes']['default'] = \str_replace('{files_legend', '{recaptcha_legend},recaptchaType;{files_legend', $GLOBALS['TL_DCA']['tl_settings']['palettes']['default']);
$GLOBALS['TL_DCA']['tl_settings']['config']['onload_callback'][] = function () {
    switch (\Config::get('recaptchaType')) {
        case 'recaptcha3':
            $GLOBALS['TL_DCA']['tl_settings']['palettes']['default'] = \str_replace('recaptchaType', 'recaptchaType,recaptcha3GlobalThreshold,recaptchaPublicKey,recaptchaPrivateKey', $GLOBALS['TL_DCA']['tl_settings']['palettes']['default']);
            break;
        default:
            $GLOBALS['TL_DCA']['tl_settings']['palettes']['default'] = \str_replace('recaptchaType', 'recaptchaType,recaptchaPublicKey,recaptchaPrivateKey', $GLOBALS['TL_DCA']['tl_settings']['palettes']['default']);
            break;
    }
};
$GLOBALS['TL_DCA']['tl_settings']['fields'] += ['recaptchaType' => ['label' => &$GLOBALS['TL_LANG']['tl_settings']['recaptchaType'], 'inputType' => 'select', 'options_callback' => function () {
    return ['invisible' => 'reCAPTCHA v2: Invisible', 'recaptcha2' => 'reCAPTCHA v2: Checkbox', 'recaptcha3' => 'reCAPTCHA v3'];
}, 'eval' => ['tl_class' => 'w50', 'chosen' => \true, 'submitOnChange' => \true]], 'recaptchaPublicKey' => ['label' => &$GLOBALS['TL_LANG']['tl_settings']['recaptchaPublicKey'], 'inputType' => 'text', 'eval' => ['tl_class' => 'w50 clr']], 'recaptchaPrivateKey' => ['label' => &$GLOBALS['TL_LANG']['tl_settings']['recaptchaPrivateKey'], 'inputType' => 'text', 'eval' => ['tl_class' => 'w50']], 'recaptcha3GlobalThreshold' => ['label' => &$GLOBALS['TL_LANG']['tl_settings']['recaptcha3GlobalThreshold'], 'inputType' => 'text', 'default' => '0.5', 'eval' => ['tl_class' => 'w50']]];
}
