<div id="BehaviorTab" class="PrefTab">
    <fieldset class="settings">
        <legend>QBT_TR(Localization)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td><label for="locale_select">QBT_TR(User interface language:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td>
                        <select id="locale_select">
                            ${LANGUAGE_OPTIONS}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label for="dateFormatSelect">QBT_TR(Date format:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td>
                        <select id="dateFormatSelect">
                            <option value="default" selected>QBT_TR(Browser default)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Interface)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow" style="margin-bottom: 3px;">
            <label for="colorSchemeSelect">QBT_TR(Color scheme:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <select id="colorSchemeSelect">
                <option value="0">QBT_TR(Auto)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="1">QBT_TR(Light)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="2">QBT_TR(Dark)QBT_TR[CONTEXT=OptionsDialog]</option>
            </select>
        </div>
        <div class="formRow">
            <label for="displayDensitySelect">QBT_TR(Display density:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <select id="displayDensitySelect">
                <option value="default">QBT_TR(Default)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="compact">QBT_TR(Compact)QBT_TR[CONTEXT=OptionsDialog]</option>
            </select>
        </div>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Transfer list)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow" style="margin-bottom: 3px;" title="QBT_TR(Shows a confirmation dialog upon torrent deletion)QBT_TR[CONTEXT=OptionsDialog]">
            <input type="checkbox" id="confirmTorrentDeletion">
            <label for="confirmTorrentDeletion">QBT_TR(Confirm when deleting torrents)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow" style="margin-bottom: 3px;">
            <input type="checkbox" id="useAltRowColorsInput">
            <label for="useAltRowColorsInput">QBT_TR(Use alternating row colors)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <fieldset class="settings">
            <legend>QBT_TR(Action on double-click)QBT_TR[CONTEXT=OptionsDialog]</legend>
            <table>
                <tbody>
                    <tr>
                        <td><label for="dblclickDownloadSelect">QBT_TR(Downloading torrents:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                        <td>
                            <select id="dblclickDownloadSelect">
                                <option value="1" selected>QBT_TR(Start / stop torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
                                <option value="0">QBT_TR(No action)QBT_TR[CONTEXT=OptionsDialog]</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><label for="dblclickCompleteSelect">QBT_TR(Completed torrents:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                        <td>
                            <select id="dblclickCompleteSelect">
                                <option value="1" selected>QBT_TR(Start / stop torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
                                <option value="0">QBT_TR(No action)QBT_TR[CONTEXT=OptionsDialog]</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><label for="dblclickFiltersSelect">QBT_TR(Filters:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                        <td>
                            <select id="dblclickFiltersSelect">
                                <option value="1" selected>QBT_TR(Reset filter selection)QBT_TR[CONTEXT=OptionsDialog]</option>
                                <option value="0">QBT_TR(No action)QBT_TR[CONTEXT=OptionsDialog]</option>
                            </select>
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
        <div class="formRow" style="margin-bottom: 3px;">
            <input type="checkbox" id="hideZeroFiltersCheckbox">
            <label for="hideZeroFiltersCheckbox">QBT_TR(Auto hide zero status filters)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="filelog_checkbox" onclick="qBittorrent.Preferences.updateFileLogEnabled();">
            <label for="filelog_checkbox">QBT_TR(Log Files)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <div class="formRow">
            <label for="filelog_save_path_input">QBT_TR(Save path:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <input type="text" id="filelog_save_path_input" class="pathDirectory">
        </div>
        <table>
            <tbody>
                <tr>
                    <td><input type="checkbox" id="filelog_backup_checkbox" onclick="qBittorrent.Preferences.updateFileLogBackupEnabled();"></td>
                    <td><label id="filelogMaxSizeLabel" for="filelog_backup_checkbox">QBT_TR(Backup the log file after:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td><input id="filelog_max_size_input" type="number" min="1" max="1024000" value="65" onchange="qBittorrent.Preferences.numberInputLimiter(this);" aria-labelledby="filelogMaxSizeLabel">QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]</td>
                </tr>
                <tr>
                    <td><input type="checkbox" id="filelog_delete_old_checkbox" onclick="qBittorrent.Preferences.updateFileLogDeleteEnabled();"></td>
                    <td><label id="filelogDeleteOldLabel" for="filelog_delete_old_checkbox">QBT_TR(Delete backup logs older than:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td>
                        <input type="number" min="1" max="365" value="6" id="filelog_age_input" onchange="qBittorrent.Preferences.numberInputLimiter(this);" aria-labelledby="filelogDeleteOldLabel">
                        <select id="filelog_age_type_select" aria-labelledby="filelogDeleteOldLabel">
                            <option value="0">QBT_TR(days)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1" selected>QBT_TR(months)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="2">QBT_TR(years)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>

    <div class="formRow" style="margin-bottom: 3px;">
        <input type="checkbox" id="statusBarExternalIP">
        <label for="statusBarExternalIP">QBT_TR(Show external IP in status bar)QBT_TR[CONTEXT=OptionsDialog]</label>
    </div>

    <div class="formRow" style="margin-bottom: 5px;">
        <input type="checkbox" id="performanceWarning">
        <label for="performanceWarning">QBT_TR(Log performance warnings)QBT_TR[CONTEXT=OptionsDialog]</label>
    </div>

    <fieldset class="settings">
        <legend title="QBT_TR(Following settings are WebUI only)QBT_TR[CONTEXT=OptionsDialog]">QBT_TR(Custom WebUI settings)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow" style="margin-bottom: 3px;">
            <input type="checkbox" id="displayFullURLTrackerColumn">
            <label for="displayFullURLTrackerColumn">QBT_TR(Display full announce URL in the Tracker column)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow" style="margin-bottom: 3px;">
            <input type="checkbox" id="useVirtualList">
            <label for="useVirtualList">QBT_TR(Enable optimized table rendering (experimental))QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>
</div>

<div id="DownloadsTab" class="PrefTab invisible">
    <fieldset class="settings">
        <legend>QBT_TR(When adding a torrent)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <label for="contentlayout_select">QBT_TR(Torrent content layout:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <select id="contentlayout_select">
                <option value="Original">QBT_TR(Original)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="Subfolder">QBT_TR(Create subfolder)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="NoSubfolder">QBT_TR(Don't create subfolder)QBT_TR[CONTEXT=OptionsDialog]</option>
            </select>
        </div>
        <div class="formRow">
            <input type="checkbox" id="addToTopOfQueueCheckbox">
            <label for="addToTopOfQueueCheckbox">QBT_TR(Add to top of queue)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <input type="checkbox" id="dontstartdownloads_checkbox">
            <label for="dontstartdownloads_checkbox">QBT_TR(Do not start the download automatically)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <label for="stopConditionSelect">QBT_TR(Torrent stop condition:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <select id="stopConditionSelect">
                <option value="None">QBT_TR(None)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="MetadataReceived">QBT_TR(Metadata received)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="FilesChecked">QBT_TR(Files checked)QBT_TR[CONTEXT=OptionsDialog]</option>
            </select>
        </div>
        <fieldset class="settings">
            <legend>QBT_TR(When adding a duplicate torrent)QBT_TR[CONTEXT=OptionsDialog]</legend>
            <div class="formRow">
                <input type="checkbox" id="mergeTrackersInput">
                <label for="mergeTrackersInput">QBT_TR(Merge trackers to existing torrent)QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>
        </fieldset>
        <div class="formRow">
            <input type="checkbox" id="deletetorrentfileafter_checkbox">
            <label for="deletetorrentfileafter_checkbox">QBT_TR(Delete .torrent files afterwards)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>

    <div class="formRow">
        <input type="checkbox" id="preallocateall_checkbox">
        <label for="preallocateall_checkbox">QBT_TR(Pre-allocate disk space for all files)QBT_TR[CONTEXT=OptionsDialog]</label>
    </div>
    <div class="formRow">
        <span id="appendexttr">
            <input type="checkbox" id="appendext_checkbox">
            <label for="appendext_checkbox">QBT_TR(Append .!qB extension to incomplete files)QBT_TR[CONTEXT=OptionsDialog]</label>
        </span>
    </div>
    <div class="formRow">
        <span id="unwantedfoldertr">
            <input type="checkbox" id="unwantedfolder_checkbox">
            <label for="unwantedfolder_checkbox">QBT_TR(Keep unselected files in ".unwanted" folder)QBT_TR[CONTEXT=OptionsDialog]</label>
        </span>
    </div>

    <fieldset class="settings">
        <legend>QBT_TR(Saving Management)QBT_TR[CONTEXT=HttpServer]</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="default_tmm_combobox">QBT_TR(Default Torrent Management Mode:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="default_tmm_combobox">
                            <option value="false" selected>QBT_TR(Manual)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="true">QBT_TR(Automatic)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="torrent_changed_tmm_combobox">QBT_TR(When Torrent Category changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="torrent_changed_tmm_combobox">
                            <option value="true">QBT_TR(Relocate torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="false" selected>QBT_TR(Switch torrent to Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="save_path_changed_tmm_combobox">QBT_TR(When Default Save Path changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="save_path_changed_tmm_combobox">
                            <option value="true">QBT_TR(Relocate affected torrents)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="false" selected>QBT_TR(Switch affected torrents to Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="category_changed_tmm_combobox">QBT_TR(When Category Save Path changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="category_changed_tmm_combobox">
                            <option value="true">QBT_TR(Relocate affected torrents)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="false" selected>QBT_TR(Switch affected torrents to Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="formRow">
            <input type="checkbox" id="categoryPathsManualModeCheckbox" title="QBT_TR(Resolve relative Save Path against appropriate Category path instead of Default one)QBT_TR[CONTEXT=OptionsDialog]">
            <label for="categoryPathsManualModeCheckbox">QBT_TR(Use Category paths in Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="savepath_text">QBT_TR(Default Save Path:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="savepath_text" class="pathDirectory" autocorrect="off" autocapitalize="none">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="temppath_checkbox" onclick="qBittorrent.Preferences.updateTempDirEnabled();">
                        <label id="tempPathLabel" for="temppath_checkbox">QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="temppath_text" class="pathDirectory" autocorrect="off" autocapitalize="none" aria-labelledby="tempPathLabel">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="exportdir_checkbox" onclick="qBittorrent.Preferences.updateExportDirEnabled();">
                        <label id="exportDirLabel" for="exportdir_checkbox">QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="exportdir_text" class="pathDirectory" autocorrect="off" autocapitalize="none" aria-labelledby="exportDirLabel">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="exportdirfin_checkbox" onclick="qBittorrent.Preferences.updateExportDirFinEnabled();">
                        <label id="exportDirFinLabel" for="exportdirfin_checkbox">QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="exportdirfin_text" class="pathDirectory" autocorrect="off" autocapitalize="none" aria-labelledby="exportDirFinLabel">
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table id="watched_folders_tab" style="border: 1px solid black;">
            <thead>
                <tr>
                    <th scope="col">QBT_TR(Monitored Folder)QBT_TR[CONTEXT=ScanFoldersModel]</th>
                    <th scope="col">QBT_TR(Override Save Location)QBT_TR[CONTEXT=ScanFoldersModel]</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </fieldset>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="excludedFileNamesCheckbox" onclick="qBittorrent.Preferences.updateExcludedFileNamesEnabled();">
            <label id="excludedFileNamesLabel" for="excludedFileNamesCheckbox">QBT_TR(Excluded file names)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <textarea id="excludedFileNamesTextarea" rows="6" cols="70" aria-labelledby="excludedFileNamesLabel"></textarea>
    </fieldset>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="mail_notification_checkbox" onclick="qBittorrent.Preferences.updateMailNotification();">
            <label for="mail_notification_checkbox">QBT_TR(Email notification upon download completion)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="src_email_txt">QBT_TR(From:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="src_email_txt">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="dest_email_txt">QBT_TR(To:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="dest_email_txt">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="smtp_server_txt">QBT_TR(SMTP server:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="smtp_server_txt">
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="formRow">
            <input type="checkbox" id="mail_ssl_checkbox"><label for="mail_ssl_checkbox">QBT_TR(This server requires a secure connection (SSL))QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="mail_auth_checkbox" onclick="qBittorrent.Preferences.updateMailAuthSettings();">
                <label for="mail_auth_checkbox">QBT_TR(Authentication)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <label for="mail_username_text">QBT_TR(Username:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="mail_username_text">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="mail_password_text">QBT_TR(Password:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="password" id="mail_password_text" autocomplete="new-password">
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
        <div class="formRow">
            <input type="button" id="mail_test_button" value="QBT_TR(Send test email)QBT_TR[CONTEXT=OptionsDialog]" onclick="qBittorrent.Preferences.sendTestEmail();">
        </div>
    </fieldset>

    <fieldset class="settings">
        <legend>
            QBT_TR(Run external program)QBT_TR[CONTEXT=OptionsDialog]
        </legend>
        <div class="formRow">
            <input type="checkbox" id="autorunOnTorrentAddedCheckbox" onclick="qBittorrent.Preferences.updateAutoRunOnTorrentAdded();">
            <label id="autorunOnTorrentAddedLabel" for="autorunOnTorrentAddedCheckbox">QBT_TR(Run on torrent added:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <input type="text" id="autorunOnTorrentAddedProgram" aria-labelledby="autorunOnTorrentAddedLabel" style="width: 100%;">
        </div>
        <div class="formRow">
            <input type="checkbox" id="autorun_checkbox" onclick="qBittorrent.Preferences.updateAutoRun();">
            <label id="autorunLabel" for="autorun_checkbox">QBT_TR(Run on torrent finished:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <input type="text" id="autorunProg_txt" aria-labelledby="autorunLabel" style="width: 100%;">
        </div>
        <div style="font-style: italic;">QBT_TR(Supported parameters (case sensitive):)QBT_TR[CONTEXT=OptionsDialog]
            <ul>
                <li>QBT_TR(%N: Torrent name)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%L: Category)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%G: Tags (separated by comma))QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%F: Content path (same as root path for multifile torrent))QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%R: Root path (first torrent subdirectory path))QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%D: Save path)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%C: Number of files)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%Z: Torrent size (bytes))QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%T: Current tracker)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%I: Info hash v1)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%J: Info hash v2)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%K: Torrent ID)QBT_TR[CONTEXT=OptionsDialog]</li>
                <li>QBT_TR(%M: Comment)QBT_TR[CONTEXT=OptionsDialog]</li>
            </ul>
            QBT_TR(Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., "%N"))QBT_TR[CONTEXT=OptionsDialog]
        </div>
    </fieldset>
</div>

<div id="ConnectionTab" class="PrefTab invisible">
    <div class="formRow">
        <label for="enable_protocol_combobox">QBT_TR(Peer connection protocol:)QBT_TR[CONTEXT=OptionsDialog]</label>
        <select id="enable_protocol_combobox">
            <option value="0" selected>QBT_TR(TCP and μTP)QBT_TR[CONTEXT=OptionsDialog]</option>
            <option value="1">TCP</option>
            <option value="2">μTP</option>
        </select>
    </div>
    <fieldset class="settings">
        <legend>QBT_TR(Listening Port)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <label for="portValue">QBT_TR(Port used for incoming connections:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <input type="text" id="portValue" style="width: 6em;" title="QBT_TR(Set to 0 to let your system pick an unused port)QBT_TR[CONTEXT=OptionsDialog]">
            <button type="button" onclick="qBittorrent.Preferences.generateRandomPort();">QBT_TR(Random)QBT_TR[CONTEXT=OptionsDialog]</button>
        </div>
        <div class="formRow">
            <input type="checkbox" id="upnpCheckbox">
            <label for="upnpCheckbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Connections Limits)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <input type="checkbox" id="maxConnectionsCheckbox" onclick="qBittorrent.Preferences.updateMaxConnecEnabled();">
                        <label id="maxConnectionsLabel" for="maxConnectionsCheckbox">QBT_TR(Global maximum number of connections:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td><input type="text" id="maxConnectionsValue" aria-labelledby="maxConnectionsLabel" style="width: 6em;"></td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="maxConnectionsPerTorrentCheckbox" onclick="qBittorrent.Preferences.updateMaxConnecPerTorrentEnabled();">
                        <label id="maxConnectionsPerTorrentLabel" for="maxConnectionsPerTorrentCheckbox">QBT_TR(Maximum number of connections per torrent:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td><input type="text" id="maxConnectionsPerTorrentValue" aria-labelledby="maxConnectionsPerTorrentLabel" style="width: 6em;"></td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="maxUploadsCheckbox" onclick="qBittorrent.Preferences.updateMaxUploadsEnabled();">
                        <label id="maxUploadsLabel" for="maxUploadsCheckbox">QBT_TR(Global maximum number of upload slots:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td><input type="text" id="max_uploads_value" aria-labelledby="maxUploadsLabel" style="width: 6em;"></td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="maxUploadsPerTorrentCheckbox" onclick="qBittorrent.Preferences.updateMaxUploadsPerTorrentEnabled();">
                        <label id="maxUploadsPerTorrentLabel" for="maxUploadsPerTorrentCheckbox">QBT_TR(Maximum number of upload slots per torrent:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td><input type="text" id="maxUploadsPerTorrentValue" aria-labelledby="maxUploadsPerTorrentLabel" style="width: 6em;"></td>
                </tr>
            </tbody>
        </table>
    </fieldset>

    <fieldset class="settings" id="fieldsetI2p">
        <legend>
            <input type="checkbox" id="i2pEnabledCheckbox" onclick="qBittorrent.Preferences.updateI2PSettingsEnabled();">
            <label for="i2pEnabledCheckbox">QBT_TR(I2P (Experimental))QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="i2pAddress">QBT_TR(Host:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="i2pAddress">
                    </td>
                    <td>
                        <label for="i2pPort">QBT_TR(Port:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="number" id="i2pPort" min="0" max="65535" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 6em;">
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="formRow">
            <input type="checkbox" id="i2pMixedMode" title="QBT_TR(If &quot;mixed mode&quot; is enabled, I2P torrents are allowed to also get peers from other sources than the tracker, and connect to regular IPs, not providing any anonymization. This may be useful if the user is not interested in the anonymization of I2P, but still wants to be able to connect to I2P peers.)QBT_TR[CONTEXT=OptionsDialog]">
            <label for="i2pMixedMode">QBT_TR(Mixed mode)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Proxy Server)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="peer_proxy_type_select">QBT_TR(Type:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="peer_proxy_type_select" onchange="qBittorrent.Preferences.updatePeerProxySettings();">
                            <option value="None">QBT_TR((None))QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="SOCKS4">QBT_TR(SOCKS4)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="SOCKS5">QBT_TR(SOCKS5)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="HTTP">QBT_TR(HTTP)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                    <td>
                        <label for="peer_proxy_host_text">QBT_TR(Host:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="peer_proxy_host_text">
                    </td>
                    <td>
                        <label for="peer_proxy_port_value">QBT_TR(Port:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="peer_proxy_port_value" style="width: 6em;">
                    </td>
                </tr>
            </tbody>
        </table>

        <div class="formRow">
            <input type="checkbox" id="proxyHostnameLookupCheckbox" title="QBT_TR(If checked, hostname lookups are done via the proxy.)QBT_TR[CONTEXT=OptionsDialog]">
            <label for="proxyHostnameLookupCheckbox">QBT_TR(Perform hostname lookup via proxy)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>

        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="peer_proxy_auth_checkbox" onclick="qBittorrent.Preferences.updatePeerProxyAuthSettings();">
                <label for="peer_proxy_auth_checkbox">QBT_TR(Authentication)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <label for="peer_proxy_username_text">QBT_TR(Username:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="peer_proxy_username_text">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="peer_proxy_password_text">QBT_TR(Password:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="password" id="peer_proxy_password_text" autocomplete="new-password">
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="formRow">
                <span>QBT_TR(Note: The password is saved unencrypted)QBT_TR[CONTEXT=OptionsDialog]</span>
            </div>
        </fieldset>

        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="proxy_bittorrent_checkbox" onclick="qBittorrent.Preferences.updatePeerProxySettings();">
                <label for="proxy_bittorrent_checkbox">QBT_TR(Use proxy for BitTorrent purposes)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <div class="formRow">
                <input type="checkbox" id="use_peer_proxy_checkbox">
                <label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>
        </fieldset>
        <div class="formRow">
            <input type="checkbox" id="proxy_rss_checkbox">
            <label for="proxy_rss_checkbox">QBT_TR(Use proxy for RSS purposes)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <input type="checkbox" id="proxy_misc_checkbox">
            <label for="proxy_misc_checkbox">QBT_TR(Use proxy for general purposes)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>

    <fieldset class="settings">
        <legend>
            <label>QBT_TR(IP Filtering)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <div class="formRow">
            <input type="checkbox" id="ipfilter_text_checkbox" onclick="qBittorrent.Preferences.updateFilterSettings();">
            <label id="ipfilterTextLabel" for="ipfilter_text_checkbox">QBT_TR(Filter path (.dat, .p2p, .p2b):)QBT_TR[CONTEXT=OptionsDialog]</label>
            <input type="text" id="ipfilter_text" aria-labelledby="ipfilterTextLabel">
        </div>
        <div class="formRow">
            <input type="checkbox" id="ipfilter_trackers_checkbox">
            <label for="ipfilter_trackers_checkbox">QBT_TR(Apply to trackers)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <fieldset class="settings">
                <legend id="manuallyBannedIPAddressesLabel">QBT_TR(Manually banned IP addresses...)QBT_TR[CONTEXT=OptionsDialog]</legend>
                <textarea id="banned_IPs_textarea" aria-labelledby="manuallyBannedIPAddressesLabel" rows="5" cols="70"></textarea>
            </fieldset>
        </div>
    </fieldset>
</div>

<div id="SpeedTab" class="PrefTab invisible">
    <fieldset class="settings">
        <legend>QBT_TR(Global Rate Limits)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td rowspan="2">
                        <img src="images/slow_off.svg" style="height: 2.5em;" alt="QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow]">
                    </td>
                    <td><label for="upLimitValue">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td><input type="number" id="upLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
                </tr>
                <tr>
                    <td><label for="dlLimitValue">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td><input type="number" id="dlLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
                </tr>
            </tbody>
        </table>
        <i>QBT_TR(0 means unlimited)QBT_TR[CONTEXT=OptionsDialog]</i>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Alternative Rate Limits)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td rowspan="2">
                        <img src="images/slow.svg" style="height: 2.5em;" alt="QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow]">
                    </td>
                    <td><label for="altUpLimitValue">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td><input type="number" id="altUpLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
                </tr>
                <tr>
                    <td><label for="altDlLimitValue">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td><input type="number" id="altDlLimitValue" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
                </tr>
            </tbody>
        </table>
        <i>QBT_TR(0 means unlimited)QBT_TR[CONTEXT=OptionsDialog]</i>

        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="limitSchedulingCheckbox" onclick="qBittorrent.Preferences.updateSchedulingEnabled();">
                <label for="limitSchedulingCheckbox">QBT_TR(Schedule the use of alternative rate limits)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <div class="formRow">
                <label id="scheduleFromHourLabel">QBT_TR(From:)QBT_TR[CONTEXT=OptionsDialog]</label>
                <input type="text" id="schedule_from_hour" aria-labelledby="scheduleFromHourLabel" style="width: 3.6em;">:<input type="text" id="schedule_from_min" aria-labelledby="scheduleFromHourLabel" style="width: 3.6em;">
                <label id="scheduleToHourLabel">QBT_TR(To:)QBT_TR[CONTEXT=OptionsDialog]</label>
                <input type="text" id="schedule_to_hour" aria-labelledby="scheduleToHourLabel" style="width: 3.6em;">:<input type="text" id="schedule_to_min" aria-labelledby="scheduleToHourLabel" style="width: 3.6em;">
            </div>
            <div class="formRow">
                <label for="schedule_freq_select">QBT_TR(When:)QBT_TR[CONTEXT=OptionsDialog]</label>
                <select id="schedule_freq_select">
                    <option value="0">QBT_TR(Every day)QBT_TR[CONTEXT=OptionsDialog]</option>
                    <option value="1">QBT_TR(Weekdays)QBT_TR[CONTEXT=OptionsDialog]</option>
                    <option value="2">QBT_TR(Weekends)QBT_TR[CONTEXT=OptionsDialog]</option>
                    <option value="3">QBT_TR(Monday)QBT_TR[CONTEXT=HttpServer]</option>
                    <option value="4">QBT_TR(Tuesday)QBT_TR[CONTEXT=HttpServer]</option>
                    <option value="5">QBT_TR(Wednesday)QBT_TR[CONTEXT=HttpServer]</option>
                    <option value="6">QBT_TR(Thursday)QBT_TR[CONTEXT=HttpServer]</option>
                    <option value="7">QBT_TR(Friday)QBT_TR[CONTEXT=HttpServer]</option>
                    <option value="8">QBT_TR(Saturday)QBT_TR[CONTEXT=HttpServer]</option>
                    <option value="9">QBT_TR(Sunday)QBT_TR[CONTEXT=HttpServer]</option>
                </select>
            </div>
        </fieldset>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Rate Limits Settings)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <input type="checkbox" id="limit_utp_rate_checkbox">
            <label for="limit_utp_rate_checkbox">QBT_TR(Apply rate limit to µTP protocol)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <input type="checkbox" id="limit_tcp_overhead_checkbox">
            <label for="limit_tcp_overhead_checkbox">QBT_TR(Apply rate limit to transport overhead)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <input type="checkbox" id="limit_lan_peers_checkbox">
            <label for="limit_lan_peers_checkbox">QBT_TR(Apply rate limit to peers on LAN)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
    </fieldset>
</div>

<div id="BittorrentTab" class="PrefTab invisible">
    <fieldset class="settings">
        <legend>QBT_TR(Privacy)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <input type="checkbox" id="dht_checkbox">
            <label for="dht_checkbox">QBT_TR(Enable DHT (decentralized network) to find more peers)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <input type="checkbox" id="pex_checkbox">
            <label for="pex_checkbox">QBT_TR(Enable Peer Exchange (PeX) to find more peers)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <input type="checkbox" id="lsd_checkbox">
            <label for="lsd_checkbox">QBT_TR(Enable Local Peer Discovery to find more peers)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <div class="formRow">
            <label for="encryption_select">QBT_TR(Encryption mode:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <select id="encryption_select">
                <option value="0">QBT_TR(Allow encryption)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="1">QBT_TR(Require encryption)QBT_TR[CONTEXT=OptionsDialog]</option>
                <option value="2">QBT_TR(Disable encryption)QBT_TR[CONTEXT=OptionsDialog]</option>
            </select>
        </div>
        <div class="formRow">
            <input type="checkbox" id="anonymous_mode_checkbox">
            <label for="anonymous_mode_checkbox">QBT_TR(Enable anonymous mode)QBT_TR[CONTEXT=OptionsDialog] (<a target="_blank" href="https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode">QBT_TR(More information)QBT_TR[CONTEXT=HttpServer]</a>)</label>
        </div>
    </fieldset>

    <div class="formRow">
        <label for="maxActiveCheckingTorrents">QBT_TR(Max active checking torrents:)QBT_TR[CONTEXT=OptionsDialog]</label>
        <input type="number" id="maxActiveCheckingTorrents" style="width: 6em;" min="-1">
    </div>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="queueingCheckbox" onclick="qBittorrent.Preferences.updateQueueingSystem();">
            <label for="queueingCheckbox">QBT_TR(Torrent Queueing)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="maxActiveDlValue">QBT_TR(Maximum active downloads:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maxActiveDlValue" style="width: 6em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="maxActiveUpValue">QBT_TR(Maximum active uploads:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maxActiveUpValue" style="width: 6em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="maxActiveToValue">QBT_TR(Maximum active torrents:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maxActiveToValue" style="width: 6em;">
                    </td>
                </tr>
            </tbody>
        </table>
        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="dontCountSlowTorrentsCheckbox" onclick="qBittorrent.Preferences.updateSlowTorrentsSettings();">
                <label for="dontCountSlowTorrentsCheckbox">QBT_TR(Do not count slow torrents in these limits)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <label for="dlRateThresholdValue">QBT_TR(Download rate threshold:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="dlRateThresholdValue" style="width: 6em;">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="ulRateThresholdValue">QBT_TR(Upload rate threshold:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="ulRateThresholdValue" style="width: 6em;">&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="torrentInactiveTimerValue">QBT_TR(Torrent inactivity timer:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="torrentInactiveTimerValue" style="width: 6em;">&nbsp;&nbsp;QBT_TR(seconds)QBT_TR[CONTEXT=OptionsDialog]
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(Seeding Limits)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <input type="checkbox" id="maxRatioCheckbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();">
                        <label id="maxRatioLabel" for="maxRatioCheckbox">QBT_TR(When ratio reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maxRatioValue" style="width: 6em;" aria-labelledby="maxRatioLabel">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="maxSeedingTimeCheckbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();">
                        <label id="maxSeedingTimeLabel" for="maxSeedingTimeCheckbox">QBT_TR(When total seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maxSeedingTimeValue" style="width: 6em;" aria-labelledby="maxSeedingTimeLabel">QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="maxInactiveSeedingTimeCheckbox" onclick="qBittorrent.Preferences.updateMaxRatioTimeEnabled();">
                        <label id="maxInactiveSeedingTimeLabel" for="maxInactiveSeedingTimeCheckbox">QBT_TR(When inactive seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maxInactiveSeedingTimeValue" style="width: 6em;" aria-labelledby="maxInactiveSeedingTimeLabel">QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;"><label for="maxRatioSelect">QBT_TR(then)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                    <td>
                        <select id="maxRatioSelect">
                            <option value="0">QBT_TR(Stop torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Remove torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="3">QBT_TR(Remove torrent and its files)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="2">QBT_TR(Enable super seeding for torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="add_trackers_checkbox" onclick="qBittorrent.Preferences.updateAddTrackersEnabled();">
            <label id="addTrackersLabel" for="add_trackers_checkbox">QBT_TR(Automatically append these trackers to new downloads:)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <textarea id="add_trackers_textarea" rows="5" cols="70" aria-labelledby="addTrackersLabel"></textarea>
    </fieldset>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="addTrackersFromURLCheckbox" onclick="qBittorrent.Preferences.updateAddTrackersFromURLEnabled();">
            <label for="addTrackersFromURLCheckbox">QBT_TR(Automatically append trackers from URL to new downloads:)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <div class="formRow">
            <label for="addTrackersURL">QBT_TR(URL:)QBT_TR[CONTEXT=OptionsDialog]</label>
            <input type="text" id="addTrackersURL" style="width: 40em;">
        </div>
        <div class="formRow">
            <fieldset class="settings">
                <legend id="fetchedTrackersFromURLLabel">QBT_TR(Fetched trackers)QBT_TR[CONTEXT=OptionsDialog]</legend>
                <textarea id="addTrackersURLListTextarea" aria-labelledby="fetchedTrackersFromURLLabel" rows="5" cols="70" readonly></textarea>
            </fieldset>
        </div>
    </fieldset>
</div>

<div id="RSSTab" class="PrefTab invisible">
    <fieldset class="settings">
        <legend>QBT_TR(RSS Reader)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <input type="checkbox" id="enable_fetching_rss_feeds_checkbox">
            <label for="enable_fetching_rss_feeds_checkbox">QBT_TR(Enable fetching RSS feeds)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="feed_refresh_interval">QBT_TR(Feeds refresh interval:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="feed_refresh_interval" style="width: 6em;">&nbsp;&nbsp;QBT_TR( min)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="feedFetchDelay">QBT_TR(Same host request delay:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="feedFetchDelay" style="width: 6em;">&nbsp;&nbsp;QBT_TR( sec)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="maximum_article_number">QBT_TR(Maximum number of articles per feed:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="maximum_article_number" style="width: 6em;">
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(RSS Torrent Auto Downloader)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <input type="checkbox" id="enable_auto_downloading_rss_torrents_checkbox">
            <label for="enable_auto_downloading_rss_torrents_checkbox">QBT_TR(Enable auto downloading of RSS torrents)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <button type="button" style="margin: 0 1em; width: calc(100% - 2.2em)" onclick="window.qBittorrent.Rss.openRssDownloader();">QBT_TR(Edit auto downloading rules...)QBT_TR[CONTEXT=OptionsDialog]</button>
    </fieldset>

    <fieldset class="settings">
        <legend>QBT_TR(RSS Smart Episode Filter)QBT_TR[CONTEXT=OptionsDialog]</legend>
        <div class="formRow">
            <input type="checkbox" id="downlock_repack_proper_episodes">

            <label for="downlock_repack_proper_episodes">QBT_TR(Download REPACK/PROPER episodes)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <label for="rss_filter_textarea">QBT_TR(Filters:)QBT_TR[CONTEXT=OptionsDialog]</label><br>
        <textarea id="rss_filter_textarea" rows="6" cols="70"></textarea>
    </fieldset>
</div>

<div id="WebUITab" class="PrefTab invisible">
    <fieldset class="settings">
        <legend>QBT_TR(Web User Interface (Remote control))QBT_TR[CONTEXT=OptionsDialog]</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="webuiAddressValue">QBT_TR(IP address:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="webuiAddressValue">
                        <label for="webuiPortValue" style="margin-left: 10px;">QBT_TR(Port:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        <input type="text" id="webuiPortValue" style="width: 6em;">
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="formRow">
            <input type="checkbox" id="webuiUpnpCheckbox">
            <label for="webuiUpnpCheckbox">QBT_TR(Use UPnP / NAT-PMP to forward the port from my router)QBT_TR[CONTEXT=OptionsDialog]</label>
        </div>
        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="use_https_checkbox" onclick="qBittorrent.Preferences.updateHttpsSettings();">
                <label for="use_https_checkbox">QBT_TR(Use HTTPS instead of HTTP)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <label for="ssl_cert_text">QBT_TR(Certificate:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="ssl_cert_text" class="pathFile" style="width: 30em;">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="ssl_key_text">QBT_TR(Key:)QBT_TR[CONTEXT=OptionsDialog]</label>
                        </td>
                        <td>
                            <input type="text" id="ssl_key_text" class="pathFile" style="width: 30em;">
                        </td>
                    </tr>
                </tbody>
            </table>
            <div style="padding-left: 10px;"><a target="_blank" href="https://httpd.apache.org/docs/current/ssl/ssl_faq.html#aboutcerts">QBT_TR(Information about certificates)QBT_TR[CONTEXT=HttpServer]</a></div>
        </fieldset>

        <fieldset class="settings">
            <legend>QBT_TR(Authentication)QBT_TR[CONTEXT=OptionsDialog]</legend>
            <fieldset class="settings">
                <legend>QBT_TR(User)QBT_TR[CONTEXT=OptionsDialog]</legend>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                <label for="webui_username_text">QBT_TR(Username:)QBT_TR[CONTEXT=OptionsDialog]</label>
                            </td>
                            <td>
                                <input type="text" id="webui_username_text">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="webui_password_text">QBT_TR(Password:)QBT_TR[CONTEXT=OptionsDialog]</label>
                            </td>
                            <td>
                                <input type="password" id="webui_password_text" placeholder="QBT_TR(Change current password)QBT_TR[CONTEXT=OptionsDialog]" autocomplete="new-password">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
            <fieldset class="settings">
                <legend>QBT_TR(API Key)QBT_TR[CONTEXT=OptionsDialog]</legend>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                <label for="WebUIAPIKeyText">QBT_TR(Key:)QBT_TR[CONTEXT=OptionsDialog]</label>
                            </td>
                            <td>
                                <input type="text" disabled id="WebUIAPIKeyText" placeholder="QBT_TR(Generate a key)QBT_TR[CONTEXT=OptionsDialog]" style="width: 200px;">
                            </td>
                            <td>
                                <button type="button" disabled id="webUIAPIKeyCopyButton" style="padding: 0;" aria-label="QBT_TR(Copy API key)QBT_TR[CONTEXT=OptionsDialog]">
                                    <img class="copyImg" src="images/edit-copy.svg" alt="QBT_TR(Copy API key)QBT_TR[CONTEXT=OptionsDialog]" title="QBT_TR(Copy API key)QBT_TR[CONTEXT=OptionsDialog]" width="16" height="16" style="margin: 4px; top: 2px; position: relative;">
                                    <img class="checkImg" src="images/checked-completed.svg" alt="QBT_TR(Copied)QBT_TR[CONTEXT=OptionsDialog]" title="QBT_TR(Copied)QBT_TR[CONTEXT=OptionsDialog]" width="16" height="16" style="margin: 4px; top: 2px; position: relative; display: none;">
                                </button>
                            </td>
                            <td>
                                <button type="button" id="webUIAPIKeyRotateButton" style="padding: 0;" data-has-key="false" aria-label="QBT_TR(Generate API key)QBT_TR[CONTEXT=OptionsDialog]">
                                    <img src="images/force-recheck.svg" alt="QBT_TR(Generate API key)QBT_TR[CONTEXT=OptionsDialog]" title="QBT_TR(Generate API key)QBT_TR[CONTEXT=OptionsDialog]" width="16" height="16" style="margin: 4px; top: 2px; position: relative;">
                                </button>
                            </td>
                            <td>
                                <button type="button" disabled id="webUIAPIKeyDeleteButton" style="padding: 0;" data-has-key="false" aria-label="QBT_TR(Delete API key)QBT_TR[CONTEXT=OptionsDialog]">
                                    <img src="images/list-remove.svg" alt="QBT_TR(Delete API key)QBT_TR[CONTEXT=OptionsDialog]" title="QBT_TR(Delete API key)QBT_TR[CONTEXT=OptionsDialog]" width="16" height="16" style="margin: 4px; top: 2px; position: relative;">
                                </button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
            <div class="formRow">
                <input type="checkbox" id="bypass_local_auth_checkbox">
                <label for="bypass_local_auth_checkbox">QBT_TR(Bypass authentication for clients on localhost)QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>
            <div class="formRow">
                <input type="checkbox" id="bypass_auth_subnet_whitelist_checkbox" onclick="qBittorrent.Preferences.updateBypasssAuthSettings();">
                <label id="bypassAuthSubnetWhitelistLabel" for="bypass_auth_subnet_whitelist_checkbox">QBT_TR(Bypass authentication for clients in whitelisted IP subnets)QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>
            <div class="formRow" style="padding-left: 30px; padding-top: 5px;">
                <textarea id="bypass_auth_subnet_whitelist_textarea" rows="5" cols="48" placeholder="QBT_TR(Example: 172.17.32.0/24, fdff:ffff:c8::/40)QBT_TR[CONTEXT=OptionsDialog]" aria-labelledby="bypassAuthSubnetWhitelistLabel"></textarea>
            </div>
            <table>
                <tbody>
                    <tr>
                        <td><label for="webUIMaxAuthFailCountInput">QBT_TR(Ban client after consecutive failures:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                        <td><input type="number" id="webUIMaxAuthFailCountInput" style="width: 6em;" min="0"></td>
                    </tr>
                    <tr>
                        <td style="text-align: right;"><label for="webUIBanDurationInput">QBT_TR(ban for:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                        <td><input type="number" id="webUIBanDurationInput" style="width: 6em;" min="1">QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]</td>
                    </tr>
                </tbody>
            </table>
            <table>
                <tbody>
                    <tr>
                        <td><label for="webUISessionTimeoutInput">QBT_TR(Session timeout:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
                        <td><input type="number" id="webUISessionTimeoutInput" style="width: 6em;" min="0">&nbsp;&nbsp;QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]</td>
                    </tr>
                </tbody>
            </table>
        </fieldset>

        <fieldset class="settings">
            <legend><input type="checkbox" id="use_alt_webui_checkbox" onclick="qBittorrent.Preferences.updateAlternativeWebUISettings();">
                <label for="use_alt_webui_checkbox">QBT_TR(Use alternative WebUI)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <div class="formRow">
                <label for="webui_files_location_textarea">QBT_TR(Files location:)QBT_TR[CONTEXT=OptionsDialog]</label>
                <input type="text" id="webui_files_location_textarea" class="pathDirectory">
            </div>
            <div class="formRow">
                <a href="https://github.com/qbittorrent/qBittorrent/wiki/List-of-known-alternate-WebUIs" target="_blank">QBT_TR(List of alternative WebUI)QBT_TR[CONTEXT=OptionsDialog]</a>
            </div>
        </fieldset>

        <fieldset class="settings">
            <legend>QBT_TR(Security)QBT_TR[CONTEXT=OptionsDialog]</legend>
            <div class="formRow">
                <input type="checkbox" id="clickjacking_protection_checkbox">
                <label for="clickjacking_protection_checkbox">QBT_TR(Enable clickjacking protection)QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>
            <div class="formRow">
                <input type="checkbox" id="csrf_protection_checkbox">
                <label for="csrf_protection_checkbox">QBT_TR(Enable Cross-Site Request Forgery (CSRF) protection)QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>
            <div class="formRow">
                <input type="checkbox" id="secureCookieCheckbox">
                <label for="secureCookieCheckbox">QBT_TR(Enable cookie Secure flag (requires HTTPS or localhost connection))QBT_TR[CONTEXT=OptionsDialog]</label>
            </div>

            <fieldset class="settings">
                <legend>
                    <input type="checkbox" id="host_header_validation_checkbox" onclick="qBittorrent.Preferences.updateHostHeaderValidationSettings();">
                    <label for="host_header_validation_checkbox">QBT_TR(Enable Host header validation)QBT_TR[CONTEXT=OptionsDialog]</label>
                </legend>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                <label for="webuiDomainTextarea">QBT_TR(Server domains:)QBT_TR[CONTEXT=OptionsDialog]</label>
                            </td>
                            <td>
                                <textarea id="webuiDomainTextarea" rows="1" cols="60" title="QBT_TR(Whitelist for filtering HTTP Host header values.
In order to defend against DNS rebinding attack,
you should put in domain names used by WebUI server.

Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsDialog]"></textarea>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </fieldset>

        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="webUIUseCustomHTTPHeadersCheckbox" onclick="qBittorrent.Preferences.updateWebUICustomHTTPHeadersSettings();">
                <label id="webUIUseCustomHTTPHeadersLabel" for="webUIUseCustomHTTPHeadersCheckbox">QBT_TR(Add custom HTTP headers)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <textarea id="webUICustomHTTPHeadersTextarea" placeholder="QBT_TR(Header: value pairs, one per line)QBT_TR[CONTEXT=OptionsDialog]" aria-labelledby="webUIUseCustomHTTPHeadersLabel" style="width: 90%;"></textarea>
        </fieldset>

        <fieldset class="settings">
            <legend>
                <input type="checkbox" id="webUIReverseProxySupportCheckbox" onclick="qBittorrent.Preferences.updateWebUIReverseProxySettings();">
                <label for="webUIReverseProxySupportCheckbox">QBT_TR(Enable reverse proxy support)QBT_TR[CONTEXT=OptionsDialog]</label>
            </legend>
            <div class="formRow">
                <label for="webUIReverseProxiesListTextarea">QBT_TR(Trusted proxies list:)QBT_TR[CONTEXT=OptionsDialog]</label>
                <input type="text" id="webUIReverseProxiesListTextarea" title="QBT_TR(Specify reverse proxy IPs (or subnets, e.g. 0.0.0.0/24) in order to use forwarded client address (X-Forwarded-For header). Use ';' to split multiple entries.)QBT_TR[CONTEXT=OptionsDialog]">
            </div>
            <div class="formRow">
                <a href="https://github.com/qbittorrent/qBittorrent/wiki#reverse-proxy-setup-for-webui-access" target="_blank">QBT_TR(Reverse proxy setup examples)QBT_TR[CONTEXT=HttpServer]</a>
            </div>
        </fieldset>

    </fieldset>

    <fieldset class="settings">
        <legend>
            <input type="checkbox" id="use_dyndns_checkbox" onclick="qBittorrent.Preferences.updateDynDnsSettings();">
            <label id="UseDyndnsLabel" for="use_dyndns_checkbox">QBT_TR(Update my dynamic domain name)QBT_TR[CONTEXT=OptionsDialog]</label>
        </legend>
        <select id="dyndns_select" aria-labelledby="UseDyndnsLabel">
            <option value="0">DynDNS</option>
            <option value="1">NO-IP</option>
        </select>
        <input type="button" value="QBT_TR(Register)QBT_TR[CONTEXT=OptionsDialog]" onclick="qBittorrent.Preferences.registerDynDns();">
        <table style="margin-top: 10px;">
            <tbody>
                <tr>
                    <td>
                        <label for="dyndns_domain_text">QBT_TR(Domain name:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="dyndns_domain_text">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="dyndns_username_text">QBT_TR(Username:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="dyndns_username_text">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="dyndns_password_text">QBT_TR(Password:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="password" id="dyndns_password_text" autocomplete="new-password">
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>
</div>

<div id="AdvancedTab" class="PrefTab invisible">
    <fieldset class="settings">
        <legend>QBT_TR(qBittorrent Section)QBT_TR[CONTEXT=OptionsDialog]&nbsp;(<a href="https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced" target="_blank">QBT_TR(Open documentation)QBT_TR[CONTEXT=HttpServer]</a>)</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="resumeDataStorageType">QBT_TR(Resume data storage type (requires restart):)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="resumeDataStorageType" style="width: 15em;">
                            <option value="Legacy">QBT_TR(Fastresume files)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="SQLite">QBT_TR(SQLite database (experimental))QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr id="rowTorrentContentRemoveOption">
                    <td>
                        <label for="torrentContentRemoveOption">QBT_TR(Torrent content removing mode:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="torrentContentRemoveOption" style="width: 15em;">
                            <option value="Delete">QBT_TR(Delete files permanently)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="MoveToTrash">QBT_TR(Move files to trash (if possible))QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr id="rowMemoryWorkingSetLimit">
                    <td>
                        <label for="memoryWorkingSetLimit">QBT_TR(Physical memory (RAM) usage limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://wikipedia.org/wiki/Working_set" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="memoryWorkingSetLimit" style="width: 15em;">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="networkInterface">QBT_TR(Network interface:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="networkInterface" style="width: 15em;">
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="optionalIPAddressToBind">QBT_TR(Optional IP address to bind to:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <select id="optionalIPAddressToBind" style="width: 15em;">
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="saveResumeDataInterval">QBT_TR(Save resume data interval:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="saveResumeDataInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(min)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="saveStatisticsInterval">QBT_TR(Save statistics interval:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="saveStatisticsInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(min)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="torrentFileSizeLimit">QBT_TR(.torrent file size limit:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="torrentFileSizeLimit" style="width: 15em;">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="confirmTorrentRecheck">QBT_TR(Confirm torrent recheck:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="confirmTorrentRecheck">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="recheckTorrentsOnCompletion">QBT_TR(Recheck torrents on completion:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="recheckTorrentsOnCompletion">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="appInstanceName">QBT_TR(Customize application instance name:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="appInstanceName" style="width: 15em;" title="QBT_TR(It appends the text to the window title to help distinguish qBittorrent instances)QBT_TR[CONTEXT=OptionsDialog]">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="refreshInterval">QBT_TR(Refresh interval:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="refreshInterval" style="width: 15em;" title="QBT_TR(It controls the internal state update interval which in turn will affect UI updates)QBT_TR[CONTEXT=OptionsDialog]">&nbsp;&nbsp;QBT_TR(ms)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="resolvePeerHostNames">QBT_TR(Resolve peer host names:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="resolvePeerHostNames">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="resolvePeerCountries">QBT_TR(Resolve peer countries:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="resolvePeerCountries">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="reannounceWhenAddressChanged">QBT_TR(Reannounce to all trackers when IP or port changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="reannounceWhenAddressChanged">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="enableEmbeddedTracker">QBT_TR(Enable embedded tracker:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="enableEmbeddedTracker">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="embeddedTrackerPort">QBT_TR(Embedded tracker port:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="embeddedTrackerPort" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="embeddedTrackerPortForwarding">QBT_TR(Enable port forwarding for embedded tracker:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="embeddedTrackerPortForwarding">
                    </td>
                </tr>
                <tr id="rowMarkOfTheWeb">
                    <td>
                        <label for="markOfTheWeb">QBT_TR(Enable Mark-of-the-Web (MOTW) for downloaded files (require macOS or Windows):)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="markOfTheWeb">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="ignoreSSLErrors">QBT_TR(Ignore SSL errors:)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="checkbox" id="ignoreSSLErrors">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="pythonExecutablePath">QBT_TR(Python executable path (may require restart):)QBT_TR[CONTEXT=OptionsDialog]</label>
                    </td>
                    <td>
                        <input type="text" id="pythonExecutablePath" class="pathFile" placeholder="QBT_TR((Auto detect if empty))QBT_TR[CONTEXT=OptionsDialog]" style="width: 15em;">
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>
    <fieldset class="settings">
        <legend>QBT_TR(libtorrent Section)QBT_TR[CONTEXT=OptionsDialog]&nbsp;(<a href="https://www.libtorrent.org/reference-Settings.html" target="_blank">QBT_TR(Open documentation)QBT_TR[CONTEXT=HttpServer]</a>)</legend>
        <table>
            <tbody>
                <tr>
                    <td>
                        <label for="bdecodeDepthLimit">QBT_TR(Bdecode depth limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Bdecoding.html#bdecode()" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="bdecodeDepthLimit" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="bdecodeTokenLimit">QBT_TR(Bdecode token limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Bdecoding.html#bdecode()" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="bdecodeTokenLimit" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="asyncIOThreads">QBT_TR(Asynchronous I/O threads:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#aio_threads" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="asyncIOThreads" style="width: 15em;">
                    </td>
                </tr>
                <tr id="rowHashingThreads">
                    <td>
                        <label for="hashingThreads">QBT_TR(Hashing threads:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#hashing_threads" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="hashingThreads" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="filePoolSize">QBT_TR(File pool size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#file_pool_size" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="filePoolSize" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="outstandMemoryWhenCheckingTorrents">QBT_TR(Outstanding memory when checking torrents:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#checking_mem_usage" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="outstandMemoryWhenCheckingTorrents" style="width: 15em;">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr id="rowDiskCache">
                    <td>
                        <label for="diskCache">QBT_TR(Disk cache:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#cache_size" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="diskCache" style="width: 15em;">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr id="rowDiskCacheExpiryInterval">
                    <td>
                        <label for="diskCacheExpiryInterval">QBT_TR(Disk cache expiry interval:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#cache_expiry" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="diskCacheExpiryInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="diskQueueSize">QBT_TR(Disk queue size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="diskQueueSize" style="width: 15em;">&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr id="rowDiskIOType">
                    <td>
                        <label for="diskIOType">QBT_TR(Disk IO type (requires restart):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/single-page-ref.html#default-disk-io-constructor" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <select id="diskIOType" style="width: 15em;">
                            <option value="0">QBT_TR(Default)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Memory mapped files)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="2">QBT_TR(POSIX-compliant)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="3">QBT_TR(Simple pread/pwrite)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="diskIOReadMode">QBT_TR(Disk IO read mode:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#disk_io_read_mode" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <select id="diskIOReadMode" style="width: 15em;">
                            <option value="0">QBT_TR(Disable OS cache)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Enable OS cache)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="diskIOWriteMode">QBT_TR(Disk IO write mode:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <select id="diskIOWriteMode" style="width: 15em;">
                            <option value="0">QBT_TR(Disable OS cache)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Enable OS cache)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="2" id="diskIOWriteModeWriteThrough">QBT_TR(Write-through)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr id="rowCoalesceReadsAndWrites">
                    <td>
                        <label for="coalesceReadsAndWrites">QBT_TR(Coalesce reads &amp; writes:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#coalesce_reads" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="coalesceReadsAndWrites">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="pieceExtentAffinity">QBT_TR(Use piece extent affinity:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://libtorrent.org/single-page-ref.html#piece_extent_affinity" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="pieceExtentAffinity">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="sendUploadPieceSuggestions">QBT_TR(Send upload piece suggestions:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#suggest_mode" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="sendUploadPieceSuggestions">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="sendBufferWatermark">QBT_TR(Send buffer watermark:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="sendBufferWatermark" style="width: 15em;">&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="sendBufferLowWatermark">QBT_TR(Send buffer low watermark:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#send_buffer_low_watermark" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="sendBufferLowWatermark" style="width: 15em;">&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="sendBufferWatermarkFactor">QBT_TR(Send buffer watermark factor:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="sendBufferWatermarkFactor" style="width: 15em;">&nbsp;&nbsp;%
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="connectionSpeed">QBT_TR(Outgoing connections per second:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#connection_speed" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="connectionSpeed" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="socketSendBufferSize">QBT_TR(Socket send buffer size [0: system default]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#send_socket_buffer_size" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="socketSendBufferSize" style="width: 15em;">&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="socketReceiveBufferSize">QBT_TR(Socket receive buffer size [0: system default]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#recv_socket_buffer_size" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="socketReceiveBufferSize" style="width: 15em;">&nbsp;&nbsp;QBT_TR(KiB)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="socketBacklogSize">QBT_TR(Socket backlog size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#listen_queue_size" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="socketBacklogSize" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="outgoingPortsMin">QBT_TR(Outgoing ports (Min) [0: disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#outgoing_port" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="outgoingPortsMin" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="outgoingPortsMax">QBT_TR(Outgoing ports (Max) [0: disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#outgoing_port" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="outgoingPortsMax" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="UPnPLeaseDuration">QBT_TR(UPnP lease duration [0: permanent lease]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="UPnPLeaseDuration" style="width: 15em;">&nbsp;&nbsp;QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="peerDSCP">QBT_TR(Differentiated Services Code Point (DSCP) for connections to peers)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#peer_dscp" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="peerDSCP" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="utpTCPMixedModeAlgorithm">QBT_TR(μTP-TCP mixed mode algorithm:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <select id="utpTCPMixedModeAlgorithm" style="width: 15em;">
                            <option value="0">QBT_TR(Prefer TCP)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Peer proportional (throttles TCP))QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="hostnameCacheTTL">QBT_TR(Internal hostname resolver cache expiry interval)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#resolver_cache_timeout" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="hostnameCacheTTL" style="width: 15em;">&nbsp;&nbsp;QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="IDNSupportCheckbox">QBT_TR(Support internationalized domain name (IDN):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#allow_idna" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="IDNSupportCheckbox">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="allowMultipleConnectionsFromTheSameIPAddress">QBT_TR(Allow multiple connections from the same IP address:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="allowMultipleConnectionsFromTheSameIPAddress">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="validateHTTPSTrackerCertificate">QBT_TR(Validate HTTPS tracker certificate:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#validate_https_trackers" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="validateHTTPSTrackerCertificate">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="mitigateSSRF">QBT_TR(Server-side request forgery (SSRF) mitigation:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="mitigateSSRF">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="blockPeersOnPrivilegedPorts">QBT_TR(Disallow connection to peers on privileged ports:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://libtorrent.org/single-page-ref.html#no_connect_privileged_ports" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="blockPeersOnPrivilegedPorts">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="uploadSlotsBehavior">QBT_TR(Upload slots behavior:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#choking_algorithm" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <select id="uploadSlotsBehavior" style="width: 15em;">
                            <option value="0">QBT_TR(Fixed slots)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Upload rate based)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="uploadChokingAlgorithm">QBT_TR(Upload choking algorithm:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <select id="uploadChokingAlgorithm" style="width: 15em;">
                            <option value="0">QBT_TR(Round-robin)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="1">QBT_TR(Fastest upload)QBT_TR[CONTEXT=OptionsDialog]</option>
                            <option value="2">QBT_TR(Anti-leech)QBT_TR[CONTEXT=OptionsDialog]</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="announceAllTrackers">QBT_TR(Always announce to all trackers in a tier:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="announceAllTrackers">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="announceAllTiers">QBT_TR(Always announce to all tiers:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="checkbox" id="announceAllTiers">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="announceIP">QBT_TR(IP address reported to trackers (requires restart):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#announce_ip" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="announceIP" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="announcePort">QBT_TR(Port reported to trackers (requires restart) [0: listening port]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#announce_port" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="announcePort" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="maxConcurrentHTTPAnnounces">QBT_TR(Max concurrent HTTP announces:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="maxConcurrentHTTPAnnounces" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout [0: disabled]:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="stopTrackerTimeout" style="width: 15em;">&nbsp;&nbsp;QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="peerTurnover">QBT_TR(Peer turnover disconnect percentage:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#peer_turnover" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="peerTurnover" style="width: 15em;">&nbsp;&nbsp;%
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="peerTurnoverCutoff">QBT_TR(Peer turnover threshold percentage:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#peer_turnover" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="peerTurnoverCutoff" style="width: 15em;">&nbsp;&nbsp;%
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="peerTurnoverInterval">QBT_TR(Peer turnover disconnect interval:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#peer_turnover" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="peerTurnoverInterval" style="width: 15em;">&nbsp;&nbsp;QBT_TR(sec)QBT_TR[CONTEXT=OptionsDialog]
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="requestQueueSize">QBT_TR(Maximum outstanding requests to a single peer:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#max_out_request_queue" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="requestQueueSize" style="width: 15em;">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="dhtBootstrapNodes">QBT_TR(DHT bootstrap nodes:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#dht_bootstrap_nodes" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input type="text" id="dhtBootstrapNodes" placeholder="QBT_TR(Resets to default if empty)QBT_TR[CONTEXT=OptionsDialog]" style="width: 15em;">
                    </td>
                </tr>
                <tr id="rowI2pInboundQuantity">
                    <td>
                        <label for="i2pInboundQuantity">QBT_TR(I2P inbound quantity:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_inbound_quantity" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input id="i2pInboundQuantity" type="number" min="1" max="16" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;">
                    </td>
                </tr>
                <tr id="rowI2pOutboundQuantity">
                    <td>
                        <label for="i2pOutboundQuantity">QBT_TR(I2P outbound quantity:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_outbound_quantity" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input id="i2pOutboundQuantity" type="number" min="1" max="16" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;">
                    </td>
                </tr>
                <tr id="rowI2pInboundLength">
                    <td>
                        <label for="i2pInboundLength">QBT_TR(I2P inbound length:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_inbound_length" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input id="i2pInboundLength" type="number" min="0" max="7" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;">
                    </td>
                </tr>
                <tr id="rowI2pOutboundLength">
                    <td>
                        <label for="i2pOutboundLength">QBT_TR(I2P outbound length:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#i2p_outbound_length" target="_blank">(?)</a></label>
                    </td>
                    <td>
                        <input id="i2pOutboundLength" type="number" min="0" max="7" onchange="qBittorrent.Preferences.numberInputLimiter(this);" style="width: 15em;">
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>
</div>

<div style="text-align: center; margin-top: 1em;"><input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" onclick="qBittorrent.Preferences.applyPreferences();"></div>

<script>
    "use strict";

    window.qBittorrent ??= {};
    window.qBittorrent.Preferences ??= (() => {
        const exports = () => {
            return {
                setup: setup,
                numberInputLimiter: numberInputLimiter,
                updateFileLogEnabled: updateFileLogEnabled,
                updateFileLogBackupEnabled: updateFileLogBackupEnabled,
                updateFileLogDeleteEnabled: updateFileLogDeleteEnabled,
                updateTempDirEnabled: updateTempDirEnabled,
                updateExportDirEnabled: updateExportDirEnabled,
                updateExportDirFinEnabled: updateExportDirFinEnabled,
                addWatchFolder: addWatchFolder,
                updateExcludedFileNamesEnabled: updateExcludedFileNamesEnabled,
                changeWatchFolderSelect: changeWatchFolderSelect,
                updateMailNotification: updateMailNotification,
                updateMailAuthSettings: updateMailAuthSettings,
                sendTestEmail: sendTestEmail,
                updateAutoRun: updateAutoRun,
                updateAutoRunOnTorrentAdded: updateAutoRunOnTorrentAdded,
                generateRandomPort: generateRandomPort,
                updateMaxConnecEnabled: updateMaxConnecEnabled,
                updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled,
                updateMaxUploadsEnabled: updateMaxUploadsEnabled,
                updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled,
                updateI2PSettingsEnabled: updateI2PSettingsEnabled,
                updatePeerProxySettings: updatePeerProxySettings,
                updatePeerProxyAuthSettings: updatePeerProxyAuthSettings,
                updateFilterSettings: updateFilterSettings,
                updateSchedulingEnabled: updateSchedulingEnabled,
                updateQueueingSystem: updateQueueingSystem,
                updateSlowTorrentsSettings: updateSlowTorrentsSettings,
                updateMaxRatioTimeEnabled: updateMaxRatioTimeEnabled,
                updateAddTrackersEnabled: updateAddTrackersEnabled,
                updateAddTrackersFromURLEnabled: updateAddTrackersFromURLEnabled,
                updateHttpsSettings: updateHttpsSettings,
                updateBypasssAuthSettings: updateBypasssAuthSettings,
                updateAlternativeWebUISettings: updateAlternativeWebUISettings,
                updateHostHeaderValidationSettings: updateHostHeaderValidationSettings,
                updateWebUICustomHTTPHeadersSettings: updateWebUICustomHTTPHeadersSettings,
                updateWebUIReverseProxySettings: updateWebUIReverseProxySettings,
                updateDynDnsSettings: updateDynDnsSettings,
                updateWebuiLocaleSelect: updateWebuiLocaleSelect,
                registerDynDns: registerDynDns,
                rotateAPIKey: rotateAPIKey,
                deleteAPIKey: deleteAPIKey,
                applyPreferences: applyPreferences
            };
        };

        // Behavior tab
        const numberInputLimiter = (input) => {
            const inputNumber = Number(input.value);

            const min = input.getAttribute("min");
            if (min && (inputNumber < Number(min)))
                input.value = min;

            const max = input.getAttribute("max");
            if (max && (inputNumber > Number(max)))
                input.value = max;
        };

        const updateFileLogEnabled = () => {
            const isFileLogEnabled = document.getElementById("filelog_checkbox").checked;
            document.getElementById("filelog_save_path_input").disabled = !isFileLogEnabled;
            document.getElementById("filelog_backup_checkbox").disabled = !isFileLogEnabled;
            document.getElementById("filelog_delete_old_checkbox").disabled = !isFileLogEnabled;

            updateFileLogBackupEnabled();
            updateFileLogDeleteEnabled();
        };

        const updateFileLogBackupEnabled = () => {
            const pros = document.getElementById("filelog_backup_checkbox").getProperties("disabled", "checked");
            document.getElementById("filelog_max_size_input").disabled = pros.disabled || !pros.checked;
        };

        const updateFileLogDeleteEnabled = () => {
            const pros = document.getElementById("filelog_delete_old_checkbox").getProperties("disabled", "checked");
            document.getElementById("filelog_age_input").disabled = pros.disabled || !pros.checked;
            document.getElementById("filelog_age_type_select").disabled = pros.disabled || !pros.checked;
        };

        // Downloads tab
        let watchedFoldersTable;

        const updateTempDirEnabled = () => {
            const isTempDirEnabled = document.getElementById("temppath_checkbox").checked;
            document.getElementById("temppath_text").disabled = !isTempDirEnabled;
        };

        const changeWatchFolderSelect = (item) => {
            if (item.value === "other") {
                item.nextElementSibling.hidden = false;
                item.nextElementSibling.value = "QBT_TR(Type folder here)QBT_TR[CONTEXT=ScanFoldersModel]";
                item.nextElementSibling.select();
            }
            else {
                item.nextElementSibling.hidden = true;
                const text = item.options[item.selectedIndex].textContent;
                item.nextElementSibling.value = text;
            }
        };

        const addWatchFolder = (folder = "", sel = "default_folder", other = "") => {
            const pos = document.getElementById("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length;
            const myinput = `<input id='text_watch_${pos}' type='text' value='${folder}'>`;
            const disableInput = (sel !== "other");
            const mycb = "<div class='select-watched-folder-editable'>"
                + `<select id ='cb_watch_${pos}' onchange='qBittorrent.Preferences.changeWatchFolderSelect(this);'>`
                + "<option value='watch_folder'>QBT_TR(Monitored folder)QBT_TR[CONTEXT=ScanFoldersModel]</option>"
                + "<option value='default_folder'>QBT_TR(Default save location)QBT_TR[CONTEXT=ScanFoldersModel]</option>"
                + "<option value='other'>QBT_TR(Other...)QBT_TR[CONTEXT=ScanFoldersModel]</option>"
                + "</select>"
                + `<input id='cb_watch_txt_${pos}' type='text' ${disableInput ? "hidden " : ""}/>`
                + `<img src='images/list-add.svg' id='addFolderImg_${pos}' alt='Add' style='padding-left:170px;width:16px;cursor:pointer;' onclick='qBittorrent.Preferences.addWatchFolder();'>`
                + "</div>";

            watchedFoldersTable.push([myinput, mycb]);
            document.getElementById(`cb_watch_${pos}`).value = sel;
            if (disableInput) {
                const elt = document.getElementById(`cb_watch_${pos}`);
                other = elt.options[elt.selectedIndex].textContent;
            }
            document.getElementById(`cb_watch_txt_${pos}`).value = other;

            // hide previous img
            if (pos > 0)
                document.getElementById(`addFolderImg_${pos - 1}`).style.display = "none";
        };

        const getWatchedFolders = () => {
            const folders = {};

            const entryCount = document.getElementById("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length;
            for (let i = 0; i < entryCount; ++i) {
                const fpath = document.getElementById(`text_watch_${i}`).value.trim();
                if (fpath.length <= 0)
                    continue;

                const sel = document.getElementById(`cb_watch_${i}`).value.trim();

                let other;
                switch (sel) {
                    case "watch_folder":
                        other = 0;
                        break;
                    case "default_folder":
                        other = 1;
                        break;
                    case "other":
                        other = document.getElementById(`cb_watch_txt_${i}`).value.trim();
                        break;
                }

                folders[fpath] = other;
            }

            return folders;
        };

        const updateExcludedFileNamesEnabled = () => {
            const isAExcludedFileNamesEnabled = document.getElementById("excludedFileNamesCheckbox").checked;
            document.getElementById("excludedFileNamesTextarea").disabled = !isAExcludedFileNamesEnabled;
        };

        const updateExportDirEnabled = () => {
            const isExportDirEnabled = document.getElementById("exportdir_checkbox").checked;
            document.getElementById("exportdir_text").disabled = !isExportDirEnabled;
        };

        const updateExportDirFinEnabled = () => {
            const isExportDirFinEnabled = document.getElementById("exportdirfin_checkbox").checked;
            document.getElementById("exportdirfin_text").disabled = !isExportDirFinEnabled;
        };

        const updateMailNotification = () => {
            const isMailNotificationEnabled = document.getElementById("mail_notification_checkbox").checked;
            document.getElementById("src_email_txt").disabled = !isMailNotificationEnabled;
            document.getElementById("dest_email_txt").disabled = !isMailNotificationEnabled;
            document.getElementById("smtp_server_txt").disabled = !isMailNotificationEnabled;
            document.getElementById("mail_ssl_checkbox").disabled = !isMailNotificationEnabled;
            document.getElementById("mail_auth_checkbox").disabled = !isMailNotificationEnabled;
            document.getElementById("mail_test_button").disabled = !isMailNotificationEnabled;

            if (!isMailNotificationEnabled) {
                document.getElementById("mail_auth_checkbox").checked = !isMailNotificationEnabled;
                updateMailAuthSettings();
            }
        };

        const updateMailAuthSettings = () => {
            const isMailAuthEnabled = document.getElementById("mail_auth_checkbox").checked;
            document.getElementById("mail_username_text").disabled = !isMailAuthEnabled;
            document.getElementById("mail_password_text").disabled = !isMailAuthEnabled;
        };

        const sendTestEmail = () => {
            fetch("api/v2/app/sendTestEmail", {
                    method: "POST"
                })
                .then((response) => {
                    if (!response.ok) {
                        alert("QBT_TR(Could not contact qBittorrent)QBT_TR[CONTEXT=HttpServer]");
                        return;
                    }

                    alert("QBT_TR(Attempted to send email. Check your inbox to confirm success)QBT_TR[CONTEXT=OptionsDialog]");
                });
        };

        const updateAutoRunOnTorrentAdded = () => {
            const isAutoRunOnTorrentAddedEnabled = document.getElementById("autorunOnTorrentAddedCheckbox").checked;
            document.getElementById("autorunOnTorrentAddedProgram").disabled = !isAutoRunOnTorrentAddedEnabled;
        };

        const updateAutoRun = () => {
            const isAutoRunEnabled = document.getElementById("autorun_checkbox").checked;
            document.getElementById("autorunProg_txt").disabled = !isAutoRunEnabled;
        };

        // Connection tab

        const updateMaxConnecEnabled = () => {
            const isMaxConnecEnabled = document.getElementById("maxConnectionsCheckbox").checked;
            document.getElementById("maxConnectionsValue").disabled = !isMaxConnecEnabled;
        };

        const updateMaxConnecPerTorrentEnabled = () => {
            const isMaxConnecPerTorrentEnabled = document.getElementById("maxConnectionsPerTorrentCheckbox").checked;
            document.getElementById("maxConnectionsPerTorrentValue").disabled = !isMaxConnecPerTorrentEnabled;
        };

        const updateMaxUploadsEnabled = () => {
            const isMaxUploadsEnabled = document.getElementById("maxUploadsCheckbox").checked;
            document.getElementById("max_uploads_value").disabled = !isMaxUploadsEnabled;
        };

        const updateMaxUploadsPerTorrentEnabled = () => {
            const isMaxUploadsPerTorrentEnabled = document.getElementById("maxUploadsPerTorrentCheckbox").checked;
            document.getElementById("maxUploadsPerTorrentValue").disabled = !isMaxUploadsPerTorrentEnabled;
        };

        const updateI2PSettingsEnabled = () => {
            const isI2PEnabled = document.getElementById("i2pEnabledCheckbox").checked;
            document.getElementById("i2pAddress").disabled = !isI2PEnabled;
            document.getElementById("i2pPort").disabled = !isI2PEnabled;
            document.getElementById("i2pMixedMode").disabled = !isI2PEnabled;
        };

        const updatePeerProxySettings = () => {
            const proxyType = document.getElementById("peer_proxy_type_select").value;
            const isProxyDisabled = (proxyType === "None");
            const isProxySocks4 = (proxyType === "SOCKS4");

            document.getElementById("peer_proxy_host_text").disabled = isProxyDisabled;
            document.getElementById("peer_proxy_port_value").disabled = isProxyDisabled;

            document.getElementById("peer_proxy_auth_checkbox").disabled = (isProxyDisabled || isProxySocks4);
            document.getElementById("proxy_bittorrent_checkbox").disabled = isProxyDisabled;
            document.getElementById("use_peer_proxy_checkbox").disabled = (isProxyDisabled || !document.getElementById("proxy_bittorrent_checkbox").checked);
            document.getElementById("proxyHostnameLookupCheckbox").disabled = (isProxyDisabled || isProxySocks4);
            document.getElementById("proxy_rss_checkbox").disabled = (isProxyDisabled || isProxySocks4);
            document.getElementById("proxy_misc_checkbox").disabled = (isProxyDisabled || isProxySocks4);

            updatePeerProxyAuthSettings();
        };

        const updatePeerProxyAuthSettings = () => {
            const proxyType = document.getElementById("peer_proxy_type_select").value;
            const isProxyDisabled = (proxyType === "None");
            const isPeerProxyAuthEnabled = (!document.getElementById("peer_proxy_auth_checkbox").disabled && document.getElementById("peer_proxy_auth_checkbox").checked);
            document.getElementById("peer_proxy_username_text").disabled = (isProxyDisabled || !isPeerProxyAuthEnabled);
            document.getElementById("peer_proxy_password_text").disabled = (isProxyDisabled || !isPeerProxyAuthEnabled);
        };

        const updateFilterSettings = () => {
            const isIPFilterEnabled = document.getElementById("ipfilter_text_checkbox").checked;
            document.getElementById("ipfilter_text").disabled = !isIPFilterEnabled;
        };

        // Speed tab
        const updateSchedulingEnabled = () => {
            const isLimitSchedulingEnabled = document.getElementById("limitSchedulingCheckbox").checked;
            document.getElementById("schedule_from_hour").disabled = !isLimitSchedulingEnabled;
            document.getElementById("schedule_from_min").disabled = !isLimitSchedulingEnabled;
            document.getElementById("schedule_to_hour").disabled = !isLimitSchedulingEnabled;
            document.getElementById("schedule_to_min").disabled = !isLimitSchedulingEnabled;
            document.getElementById("schedule_freq_select").disabled = !isLimitSchedulingEnabled;
        };

        // Bittorrent tab
        const updateQueueingSystem = () => {
            const isQueueingEnabled = document.getElementById("queueingCheckbox").checked;
            document.getElementById("maxActiveDlValue").disabled = !isQueueingEnabled;
            document.getElementById("maxActiveUpValue").disabled = !isQueueingEnabled;
            document.getElementById("maxActiveToValue").disabled = !isQueueingEnabled;
            document.getElementById("dontCountSlowTorrentsCheckbox").disabled = !isQueueingEnabled;
            updateSlowTorrentsSettings();
        };

        const updateSlowTorrentsSettings = () => {
            const isDontCountSlowTorrentsEnabled = (!document.getElementById("dontCountSlowTorrentsCheckbox").disabled) && document.getElementById("dontCountSlowTorrentsCheckbox").checked;
            document.getElementById("dlRateThresholdValue").disabled = !isDontCountSlowTorrentsEnabled;
            document.getElementById("ulRateThresholdValue").disabled = !isDontCountSlowTorrentsEnabled;
            document.getElementById("torrentInactiveTimerValue").disabled = !isDontCountSlowTorrentsEnabled;
        };

        const updateMaxRatioTimeEnabled = () => {
            const isMaxRatioEnabled = document.getElementById("maxRatioCheckbox").checked;
            document.getElementById("maxRatioValue").disabled = !isMaxRatioEnabled;

            const isMaxSeedingTimeEnabled = document.getElementById("maxSeedingTimeCheckbox").checked;
            document.getElementById("maxSeedingTimeValue").disabled = !isMaxSeedingTimeEnabled;

            const isMaxInactiveSeedingTimeEnabled = document.getElementById("maxInactiveSeedingTimeCheckbox").checked;
            document.getElementById("maxInactiveSeedingTimeValue").disabled = !isMaxInactiveSeedingTimeEnabled;

            document.getElementById("maxRatioSelect").disabled = !(isMaxRatioEnabled || isMaxSeedingTimeEnabled || isMaxInactiveSeedingTimeEnabled);
        };

        const updateAddTrackersEnabled = () => {
            const isAddTrackersEnabled = document.getElementById("add_trackers_checkbox").checked;
            document.getElementById("add_trackers_textarea").disabled = !isAddTrackersEnabled;
        };

        const updateAddTrackersFromURLEnabled = () => {
            const isAddTrackersFromURLEnabled = document.getElementById("addTrackersFromURLCheckbox").checked;
            document.getElementById("addTrackersURL").disabled = !isAddTrackersFromURLEnabled;
        };

        // WebUI tab
        const updateHttpsSettings = () => {
            const isUseHttpsEnabled = document.getElementById("use_https_checkbox").checked;
            document.getElementById("ssl_cert_text").disabled = !isUseHttpsEnabled;
            document.getElementById("ssl_key_text").disabled = !isUseHttpsEnabled;
        };

        const updateBypasssAuthSettings = () => {
            const isBypassAuthSubnetWhitelistEnabled = document.getElementById("bypass_auth_subnet_whitelist_checkbox").checked;
            document.getElementById("bypass_auth_subnet_whitelist_textarea").disabled = !isBypassAuthSubnetWhitelistEnabled;
        };

        const updateAlternativeWebUISettings = () => {
            const isUseAlternativeWebUIEnabled = document.getElementById("use_alt_webui_checkbox").checked;
            document.getElementById("webui_files_location_textarea").disabled = !isUseAlternativeWebUIEnabled;
        };

        const updateHostHeaderValidationSettings = () => {
            const isHostHeaderValidationEnabled = document.getElementById("host_header_validation_checkbox").checked;
            document.getElementById("webuiDomainTextarea").disabled = !isHostHeaderValidationEnabled;
        };

        const updateWebUICustomHTTPHeadersSettings = () => {
            const isEnabled = document.getElementById("webUIUseCustomHTTPHeadersCheckbox").checked;
            document.getElementById("webUICustomHTTPHeadersTextarea").disabled = !isEnabled;
        };

        const updateWebUIReverseProxySettings = () => {
            const isEnabled = document.getElementById("webUIReverseProxySupportCheckbox").checked;
            document.getElementById("webUIReverseProxiesListTextarea").disabled = !isEnabled;
        };

        const updateDynDnsSettings = () => {
            const isDynDnsEnabled = document.getElementById("use_dyndns_checkbox").checked;
            document.getElementById("dyndns_select").disabled = !isDynDnsEnabled;
            document.getElementById("dyndns_domain_text").disabled = !isDynDnsEnabled;
            document.getElementById("dyndns_username_text").disabled = !isDynDnsEnabled;
            document.getElementById("dyndns_password_text").disabled = !isDynDnsEnabled;
        };

        const registerDynDns = () => {
            if (Number(document.getElementById("dyndns_select").value) === 1)
                window.open("http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html", "NO-IP Registration");
            else
                window.open("https://www.dyndns.com/account/services/hosts/add.html", "DynDNS Registration");
        };

        const generateRandomPort = () => {
            // don't use modulo operations to avoid 'modulo bias'
            const buffer = new Uint16Array(1);
            let port = crypto.getRandomValues(buffer)[0];
            while (port < 1024)
                port = crypto.getRandomValues(buffer)[0];
            document.getElementById("portValue").value = port;
        };

        const time_padding = (val) => {
            let ret = val.toString();
            if (ret.length === 1)
                ret = `0${ret}`;
            return ret;
        };

        // Advanced Tab
        const updateNetworkInterfaces = (default_iface, default_iface_name) => {
            for (const el of [...document.getElementById("networkInterface").children])
                el.remove();

            fetch("api/v2/app/networkInterfaceList", {
                    method: "GET",
                    cache: "no-store"
                })
                .then(async (response) => {
                    if (!response.ok) {
                        alert("Could not contact qBittorrent");
                        return;
                    }

                    const ifaces = await response.json();
                    if (!Array.isArray(ifaces))
                        return;

                    // add the current network interface to the options if needed
                    if (default_iface && !ifaces.some((item) => item.value === default_iface))
                        ifaces.push({ name: default_iface_name || default_iface, value: default_iface });

                    document.getElementById("networkInterface").options.add(new Option("QBT_TR(Any interface)QBT_TR[CONTEXT=OptionsDialog]", ""));
                    for (const item of ifaces)
                        document.getElementById("networkInterface").options.add(new Option(item.name, item.value));
                    document.getElementById("networkInterface").value = default_iface;
                });
        };

        const updateInterfaceAddresses = (iface, default_addr) => {
            for (const el of [...document.getElementById("optionalIPAddressToBind").children])
                el.remove();

            const url = new URL("api/v2/app/networkInterfaceAddressList", window.location);
            url.search = new URLSearchParams({
                iface: iface
            });
            fetch(url, {
                    method: "GET",
                    cache: "no-store"
                })
                .then(async (response) => {
                    if (!response.ok) {
                        alert("Could not contact qBittorrent");
                        return;
                    }

                    const addresses = await response.json();
                    if (!addresses)
                        return;

                    document.getElementById("optionalIPAddressToBind").options.add(new Option("QBT_TR(All addresses)QBT_TR[CONTEXT=OptionDialog]", ""));
                    document.getElementById("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv4 addresses)QBT_TR[CONTEXT=OptionDialog]", "0.0.0.0"));
                    document.getElementById("optionalIPAddressToBind").options.add(new Option("QBT_TR(All IPv6 addresses)QBT_TR[CONTEXT=OptionDialog]", "::"));
                    for (const item of addresses)
                        document.getElementById("optionalIPAddressToBind").options.add(new Option(item, item));
                    document.getElementById("optionalIPAddressToBind").value = default_addr;
                });
        };

        const updateWebuiLocaleSelect = (selected) => {
            const languages = [];
            for (let i = 0; i < document.getElementById("locale_select").options.length; ++i)
                languages.push(document.getElementById("locale_select").options[i].value);

            if (!languages.includes(selected)) {
                const lang = selected.split("_", 1)[0];
                selected = languages.includes(lang) ? lang : "en";
            }
            document.getElementById("locale_select").value = selected;
        };

        const updateColoSchemeSelect = (colorScheme) => {
            const combobox = document.getElementById("colorSchemeSelect");
            if (colorScheme === "light")
                combobox.options[1].selected = true;
            else if (colorScheme === "dark")
                combobox.options[2].selected = true;
            else
                combobox.options[0].selected = true;
        };

        const loadPreferences = () => {
            window.parent.qBittorrent.Cache.preferences.init()
                .then((pref) => {
                    const clientData = window.parent.qBittorrent.ClientData;
                    const dateFormat = clientData.get("date_format");
                    const colorScheme = clientData.get("color_scheme");
                    const displayDensity = clientData.get("display_density") ?? "default";
                    const fullUrlTrackerColumn = clientData.get("full_url_tracker_column");
                    const useVirtualList = clientData.get("use_virtual_list");
                    const hideZeroStatusFilters = clientData.get("hide_zero_status_filters");
                    const dblclickDownload = clientData.get("dblclick_download") ?? "1";
                    const dblclickComplete = clientData.get("dblclick_complete") ?? "1";
                    const dblclickFilter = clientData.get("dblclick_filter") ?? "1";
                    const useAltRowColors = clientData.get("use_alt_row_colors");

                    // Behavior tab
                    // Localization
                    updateWebuiLocaleSelect(pref.locale);
                    const now = new Date();
                    const dateFormatSelect = document.getElementById("dateFormatSelect");
                    for (const format of Object.keys(window.qBittorrent.Misc.DateFormatOptions)) {
                        const option = document.createElement("option");
                        option.value = format;
                        option.textContent = window.qBittorrent.Misc.formatDate(now, format);
                        option.selected = format === dateFormat;
                        dateFormatSelect.appendChild(option);
                    }

                    // Interface
                    updateColoSchemeSelect(colorScheme);
                    document.getElementById("displayDensitySelect").value = displayDensity;

                    document.getElementById("statusBarExternalIP").checked = pref.status_bar_external_ip;
                    document.getElementById("performanceWarning").checked = pref.performance_warning;
                    document.getElementById("displayFullURLTrackerColumn").checked = fullUrlTrackerColumn === true;
                    document.getElementById("useVirtualList").checked = useVirtualList === true;
                    document.getElementById("hideZeroFiltersCheckbox").checked = hideZeroStatusFilters === true;
                    document.getElementById("dblclickDownloadSelect").value = dblclickDownload;
                    document.getElementById("dblclickCompleteSelect").value = dblclickComplete;
                    document.getElementById("dblclickFiltersSelect").value = dblclickFilter;
                    document.getElementById("confirmTorrentDeletion").checked = pref.confirm_torrent_deletion;
                    document.getElementById("useAltRowColorsInput").checked = useAltRowColors === true;
                    document.getElementById("filelog_checkbox").checked = pref.file_log_enabled;
                    document.getElementById("filelog_save_path_input").value = pref.file_log_path;
                    document.getElementById("filelog_backup_checkbox").checked = pref.file_log_backup_enabled;
                    document.getElementById("filelog_max_size_input").value = pref.file_log_max_size;
                    document.getElementById("filelog_delete_old_checkbox").checked = pref.file_log_delete_old;
                    document.getElementById("filelog_age_input").value = pref.file_log_age;
                    document.getElementById("filelog_age_type_select").value = pref.file_log_age_type;
                    updateFileLogEnabled();

                    // Downloads tab
                    // When adding a torrent
                    let index = 0;
                    switch (pref.torrent_content_layout) {
                        case "Original":
                            index = 0;
                            break;
                        case "Subfolder":
                            index = 1;
                            break;
                        case "NoSubfolder":
                            index = 2;
                            break;
                    }
                    document.getElementById("contentlayout_select").getChildren("option")[index].selected = true;
                    document.getElementById("addToTopOfQueueCheckbox").checked = pref.add_to_top_of_queue;
                    document.getElementById("dontstartdownloads_checkbox").checked = pref.add_stopped_enabled;
                    switch (pref.torrent_stop_condition) {
                        case "None":
                            index = 0;
                            break;
                        case "MetadataReceived":
                            index = 1;
                            break;
                        case "FilesChecked":
                            index = 2;
                            break;
                    }
                    document.getElementById("stopConditionSelect").getChildren("option")[index].selected = true;
                    document.getElementById("mergeTrackersInput").checked = pref.merge_trackers;
                    document.getElementById("deletetorrentfileafter_checkbox").checked = pref.auto_delete_mode;

                    document.getElementById("preallocateall_checkbox").checked = pref.preallocate_all;
                    document.getElementById("appendext_checkbox").checked = pref.incomplete_files_ext;
                    document.getElementById("unwantedfolder_checkbox").checked = pref.use_unwanted_folder;

                    // Saving Management
                    document.getElementById("default_tmm_combobox").value = pref.auto_tmm_enabled;
                    document.getElementById("torrent_changed_tmm_combobox").value = pref.torrent_changed_tmm_enabled;
                    document.getElementById("save_path_changed_tmm_combobox").value = pref.save_path_changed_tmm_enabled;
                    document.getElementById("category_changed_tmm_combobox").value = pref.category_changed_tmm_enabled;
                    document.getElementById("categoryPathsManualModeCheckbox").checked = pref.use_category_paths_in_manual_mode;
                    document.getElementById("savepath_text").value = pref.save_path;
                    document.getElementById("temppath_checkbox").checked = pref.temp_path_enabled;
                    document.getElementById("temppath_text").value = pref.temp_path;
                    updateTempDirEnabled();
                    if (pref.export_dir !== "") {
                        document.getElementById("exportdir_checkbox").checked = true;
                        document.getElementById("exportdir_text").value = pref.export_dir;
                    }
                    else {
                        document.getElementById("exportdir_checkbox").checked = false;
                        document.getElementById("exportdir_text").value = "";
                    }
                    updateExportDirEnabled();
                    if (pref.export_dir_fin !== "") {
                        document.getElementById("exportdirfin_checkbox").checked = true;
                        document.getElementById("exportdirfin_text").value = pref.export_dir_fin;
                    }
                    else {
                        document.getElementById("exportdirfin_checkbox").checked = false;
                        document.getElementById("exportdirfin_text").value = "";
                    }
                    updateExportDirFinEnabled();

                    // Automatically add torrents from
                    for (const folder in pref.scan_dirs) {
                        if (!Object.hasOwn(pref.scan_dirs, folder))
                            continue;

                        const folderType = pref.scan_dirs[folder];
                        let sel = "other";
                        let other = folderType;
                        if (typeof folderType === "number") {
                            sel = (folderType === 0) ? "watch_folder" : "default_folder";
                            other = "";
                        }
                        addWatchFolder(folder, sel, other);
                    }
                    addWatchFolder();

                    // Excluded file names
                    document.getElementById("excludedFileNamesCheckbox").checked = pref.excluded_file_names_enabled;
                    document.getElementById("excludedFileNamesTextarea").value = pref.excluded_file_names;

                    // Email notification upon download completion
                    document.getElementById("mail_notification_checkbox").checked = pref.mail_notification_enabled;
                    document.getElementById("src_email_txt").value = pref.mail_notification_sender;
                    document.getElementById("dest_email_txt").value = pref.mail_notification_email;
                    document.getElementById("smtp_server_txt").value = pref.mail_notification_smtp;
                    document.getElementById("mail_ssl_checkbox").checked = pref.mail_notification_ssl_enabled;
                    document.getElementById("mail_auth_checkbox").checked = pref.mail_notification_auth_enabled;
                    document.getElementById("mail_username_text").value = pref.mail_notification_username;
                    document.getElementById("mail_password_text").value = pref.mail_notification_password;
                    updateMailNotification();
                    updateMailAuthSettings();

                    // Run an external program on torrent added
                    document.getElementById("autorunOnTorrentAddedCheckbox").checked = pref.autorun_on_torrent_added_enabled;
                    document.getElementById("autorunOnTorrentAddedProgram").value = pref.autorun_on_torrent_added_program;
                    updateAutoRunOnTorrentAdded();
                    // Run an external program on torrent finished
                    document.getElementById("autorun_checkbox").checked = pref.autorun_enabled;
                    document.getElementById("autorunProg_txt").value = pref.autorun_program;
                    updateAutoRun();

                    // Connection tab
                    // Listening Port
                    document.getElementById("portValue").value = Number(pref.listen_port);
                    document.getElementById("upnpCheckbox").checked = pref.upnp;

                    // Connections Limits
                    const maxConnec = Number(pref.max_connec);
                    if (maxConnec <= 0) {
                        document.getElementById("maxConnectionsCheckbox").checked = false;
                        document.getElementById("maxConnectionsValue").value = 500;
                    }
                    else {
                        document.getElementById("maxConnectionsCheckbox").checked = true;
                        document.getElementById("maxConnectionsValue").value = maxConnec;
                    }
                    updateMaxConnecEnabled();

                    const maxConnecPerTorrent = Number(pref.max_connec_per_torrent);
                    if (maxConnecPerTorrent <= 0) {
                        document.getElementById("maxConnectionsPerTorrentCheckbox").checked = false;
                        document.getElementById("maxConnectionsPerTorrentValue").value = 100;
                    }
                    else {
                        document.getElementById("maxConnectionsPerTorrentCheckbox").checked = true;
                        document.getElementById("maxConnectionsPerTorrentValue").value = maxConnecPerTorrent;
                    }
                    updateMaxConnecPerTorrentEnabled();

                    const maxUploads = Number(pref.max_uploads);
                    if (maxUploads <= 0) {
                        document.getElementById("maxUploadsCheckbox").checked = false;
                        document.getElementById("max_uploads_value").value = 8;
                    }
                    else {
                        document.getElementById("maxUploadsCheckbox").checked = true;
                        document.getElementById("max_uploads_value").value = maxUploads;
                    }
                    updateMaxUploadsEnabled();

                    const maxUploadsPerTorrent = Number(pref.max_uploads_per_torrent);
                    if (maxUploadsPerTorrent <= 0) {
                        document.getElementById("maxUploadsPerTorrentCheckbox").checked = false;
                        document.getElementById("maxUploadsPerTorrentValue").value = 4;
                    }
                    else {
                        document.getElementById("maxUploadsPerTorrentCheckbox").checked = true;
                        document.getElementById("maxUploadsPerTorrentValue").value = maxUploadsPerTorrent;
                    }
                    updateMaxUploadsPerTorrentEnabled();

                    // I2P
                    document.getElementById("i2pEnabledCheckbox").checked = pref.i2p_enabled;
                    document.getElementById("i2pAddress").value = pref.i2p_address;
                    document.getElementById("i2pPort").value = pref.i2p_port;
                    document.getElementById("i2pMixedMode").checked = pref.i2p_mixed_mode;
                    updateI2PSettingsEnabled();

                    // Proxy Server
                    document.getElementById("peer_proxy_type_select").value = pref.proxy_type;
                    document.getElementById("peer_proxy_host_text").value = pref.proxy_ip;
                    document.getElementById("peer_proxy_port_value").value = pref.proxy_port;
                    document.getElementById("peer_proxy_auth_checkbox").checked = pref.proxy_auth_enabled;
                    document.getElementById("peer_proxy_username_text").value = pref.proxy_username;
                    document.getElementById("peer_proxy_password_text").value = pref.proxy_password;
                    document.getElementById("proxyHostnameLookupCheckbox").checked = pref.proxy_hostname_lookup;
                    document.getElementById("proxy_bittorrent_checkbox").checked = pref.proxy_bittorrent;
                    document.getElementById("use_peer_proxy_checkbox").checked = pref.proxy_peer_connections;
                    document.getElementById("proxy_rss_checkbox").checked = pref.proxy_rss;
                    document.getElementById("proxy_misc_checkbox").checked = pref.proxy_misc;
                    updatePeerProxySettings();

                    // IP Filtering
                    document.getElementById("ipfilter_text_checkbox").checked = pref.ip_filter_enabled;
                    document.getElementById("ipfilter_text").value = pref.ip_filter_path;
                    document.getElementById("ipfilter_trackers_checkbox").checked = pref.ip_filter_trackers;
                    document.getElementById("banned_IPs_textarea").value = pref.banned_IPs;
                    updateFilterSettings();

                    // Speed tab
                    // Global Rate Limits
                    document.getElementById("upLimitValue").value = (Number(pref.up_limit) / 1024);
                    document.getElementById("dlLimitValue").value = (Number(pref.dl_limit) / 1024);
                    // Alternative Global Rate Limits
                    document.getElementById("altUpLimitValue").value = (Number(pref.alt_up_limit) / 1024);
                    document.getElementById("altDlLimitValue").value = (Number(pref.alt_dl_limit) / 1024);

                    document.getElementById("enable_protocol_combobox").value = pref.bittorrent_protocol;
                    document.getElementById("limit_utp_rate_checkbox").checked = pref.limit_utp_rate;
                    document.getElementById("limit_tcp_overhead_checkbox").checked = pref.limit_tcp_overhead;
                    document.getElementById("limit_lan_peers_checkbox").checked = pref.limit_lan_peers;

                    // Scheduling
                    document.getElementById("limitSchedulingCheckbox").checked = pref.scheduler_enabled;
                    document.getElementById("schedule_from_hour").value = time_padding(pref.schedule_from_hour);
                    document.getElementById("schedule_from_min").value = time_padding(pref.schedule_from_min);
                    document.getElementById("schedule_to_hour").value = time_padding(pref.schedule_to_hour);
                    document.getElementById("schedule_to_min").value = time_padding(pref.schedule_to_min);
                    document.getElementById("schedule_freq_select").value = pref.scheduler_days;
                    updateSchedulingEnabled();

                    // Bittorrent tab
                    // Privacy
                    document.getElementById("dht_checkbox").checked = pref.dht;
                    document.getElementById("pex_checkbox").checked = pref.pex;
                    document.getElementById("lsd_checkbox").checked = pref.lsd;
                    const encryption = Number(pref.encryption);
                    document.getElementById("encryption_select").getChildren("option")[encryption].selected = true;
                    document.getElementById("anonymous_mode_checkbox").checked = pref.anonymous_mode;

                    document.getElementById("maxActiveCheckingTorrents").value = pref.max_active_checking_torrents;

                    // Torrent Queueing
                    document.getElementById("queueingCheckbox").checked = pref.queueing_enabled;
                    document.getElementById("maxActiveDlValue").value = Number(pref.max_active_downloads);
                    document.getElementById("maxActiveUpValue").value = Number(pref.max_active_uploads);
                    document.getElementById("maxActiveToValue").value = Number(pref.max_active_torrents);
                    document.getElementById("dontCountSlowTorrentsCheckbox").checked = pref.dont_count_slow_torrents;
                    document.getElementById("dlRateThresholdValue").value = Number(pref.slow_torrent_dl_rate_threshold);
                    document.getElementById("ulRateThresholdValue").value = Number(pref.slow_torrent_ul_rate_threshold);
                    document.getElementById("torrentInactiveTimerValue").value = Number(pref.slow_torrent_inactive_timer);
                    updateQueueingSystem();

                    // Share Limiting
                    document.getElementById("maxRatioCheckbox").checked = pref.max_ratio_enabled;
                    document.getElementById("maxRatioValue").value = (pref.max_ratio_enabled ? pref.max_ratio : 1);
                    document.getElementById("maxSeedingTimeCheckbox").checked = pref.max_seeding_time_enabled;
                    document.getElementById("maxSeedingTimeValue").value = (pref.max_seeding_time_enabled ? Number(pref.max_seeding_time) : 1440);
                    document.getElementById("maxInactiveSeedingTimeCheckbox").checked = pref.max_inactive_seeding_time_enabled;
                    document.getElementById("maxInactiveSeedingTimeValue").value = (pref.max_inactive_seeding_time_enabled ? Number(pref.max_inactive_seeding_time) : 1440);
                    let maxRatioAct = 0;
                    switch (Number(pref.max_ratio_act)) {
                        case 0: // Stop
                            maxRatioAct = 0;
                            break;
                        case 1: // Remove
                            maxRatioAct = 1;
                            break;
                        case 2: // Enable super seeding
                            maxRatioAct = 3;
                            break;
                        case 3: // Remove torrent and files
                            maxRatioAct = 2;
                            break;
                    }
                    document.getElementById("maxRatioSelect").getChildren("option")[maxRatioAct].selected = true;
                    updateMaxRatioTimeEnabled();

                    // Add trackers
                    document.getElementById("add_trackers_checkbox").checked = pref.add_trackers_enabled;
                    document.getElementById("add_trackers_textarea").value = pref.add_trackers;
                    document.getElementById("addTrackersFromURLCheckbox").checked = pref.add_trackers_from_url_enabled;
                    document.getElementById("addTrackersURLListTextarea").value = pref.add_trackers_url_list;
                    document.getElementById("addTrackersURL").value = pref.add_trackers_url;
                    updateAddTrackersEnabled();
                    updateAddTrackersFromURLEnabled();

                    // RSS Tab
                    document.getElementById("enable_fetching_rss_feeds_checkbox").checked = pref.rss_processing_enabled;
                    document.getElementById("feed_refresh_interval").value = pref.rss_refresh_interval;
                    document.getElementById("feedFetchDelay").value = pref.rss_fetch_delay;
                    document.getElementById("maximum_article_number").value = pref.rss_max_articles_per_feed;
                    document.getElementById("enable_auto_downloading_rss_torrents_checkbox").checked = pref.rss_auto_downloading_enabled;
                    document.getElementById("downlock_repack_proper_episodes").checked = pref.rss_download_repack_proper_episodes;
                    document.getElementById("rss_filter_textarea").value = pref.rss_smart_episode_filters;

                    // WebUI tab
                    // HTTP Server
                    document.getElementById("webuiDomainTextarea").value = pref.web_ui_domain_list;
                    document.getElementById("webuiAddressValue").value = pref.web_ui_address;
                    document.getElementById("webuiPortValue").value = pref.web_ui_port;
                    document.getElementById("webuiUpnpCheckbox").checked = pref.web_ui_upnp;
                    document.getElementById("use_https_checkbox").checked = pref.use_https;
                    document.getElementById("ssl_cert_text").value = pref.web_ui_https_cert_path;
                    document.getElementById("ssl_key_text").value = pref.web_ui_https_key_path;
                    updateHttpsSettings();

                    // Authentication
                    document.getElementById("webui_username_text").value = pref.web_ui_username;
                    document.getElementById("bypass_local_auth_checkbox").checked = pref.bypass_local_auth;
                    document.getElementById("bypass_auth_subnet_whitelist_checkbox").checked = pref.bypass_auth_subnet_whitelist_enabled;
                    document.getElementById("bypass_auth_subnet_whitelist_textarea").value = pref.bypass_auth_subnet_whitelist;
                    updateBypasssAuthSettings();
                    document.getElementById("webUIMaxAuthFailCountInput").value = Number(pref.web_ui_max_auth_fail_count);
                    document.getElementById("webUIBanDurationInput").value = Number(pref.web_ui_ban_duration);
                    document.getElementById("webUISessionTimeoutInput").value = Number(pref.web_ui_session_timeout);

                    // API key
                    if (pref.web_ui_api_key.length > 0) {
                        document.getElementById("WebUIAPIKeyText").value = maskAPIKey(pref.web_ui_api_key);
                        document.getElementById("WebUIAPIKeyText").dataset.apiKey = pref.web_ui_api_key;
                        document.getElementById("webUIAPIKeyCopyButton").disabled = false;
                        document.getElementById("webUIAPIKeyRotateButton").dataset.hasKey = "true";
                        document.querySelector("#webUIAPIKeyRotateButton img").title = "QBT_TR(Rotate API key)QBT_TR[CONTEXT=OptionsDialog]";
                        document.getElementById("webUIAPIKeyDeleteButton").disabled = false;
                    }

                    // Use alternative WebUI
                    document.getElementById("use_alt_webui_checkbox").checked = pref.alternative_webui_enabled;
                    document.getElementById("webui_files_location_textarea").value = pref.alternative_webui_path;
                    updateAlternativeWebUISettings();

                    // Security
                    document.getElementById("clickjacking_protection_checkbox").checked = pref.web_ui_clickjacking_protection_enabled;
                    document.getElementById("csrf_protection_checkbox").checked = pref.web_ui_csrf_protection_enabled;
                    document.getElementById("secureCookieCheckbox").checked = pref.web_ui_secure_cookie_enabled;
                    document.getElementById("host_header_validation_checkbox").checked = pref.web_ui_host_header_validation_enabled;
                    updateHostHeaderValidationSettings();

                    // Custom HTTP headers
                    document.getElementById("webUIUseCustomHTTPHeadersCheckbox").checked = pref.web_ui_use_custom_http_headers_enabled;
                    document.getElementById("webUICustomHTTPHeadersTextarea").value = pref.web_ui_custom_http_headers;
                    updateWebUICustomHTTPHeadersSettings();

                    // Reverse Proxy
                    document.getElementById("webUIReverseProxySupportCheckbox").checked = pref.web_ui_reverse_proxy_enabled;
                    document.getElementById("webUIReverseProxiesListTextarea").value = pref.web_ui_reverse_proxies_list;
                    updateWebUIReverseProxySettings();

                    // Update my dynamic domain name
                    document.getElementById("use_dyndns_checkbox").checked = pref.dyndns_enabled;
                    document.getElementById("dyndns_select").value = pref.dyndns_service;
                    document.getElementById("dyndns_domain_text").value = pref.dyndns_domain;
                    document.getElementById("dyndns_username_text").value = pref.dyndns_username;
                    document.getElementById("dyndns_password_text").value = pref.dyndns_password;
                    updateDynDnsSettings();

                    // Advanced settings
                    // qBittorrent section
                    document.getElementById("resumeDataStorageType").value = pref.resume_data_storage_type;
                    document.getElementById("torrentContentRemoveOption").value = pref.torrent_content_remove_option;
                    document.getElementById("memoryWorkingSetLimit").value = pref.memory_working_set_limit;
                    updateNetworkInterfaces(pref.current_network_interface, pref.current_interface_name);
                    updateInterfaceAddresses(pref.current_network_interface, pref.current_interface_address);
                    document.getElementById("saveResumeDataInterval").value = pref.save_resume_data_interval;
                    document.getElementById("saveStatisticsInterval").value = pref.save_statistics_interval;
                    document.getElementById("torrentFileSizeLimit").value = (pref.torrent_file_size_limit / 1024 / 1024);
                    document.getElementById("confirmTorrentRecheck").checked = pref.confirm_torrent_recheck;
                    document.getElementById("recheckTorrentsOnCompletion").checked = pref.recheck_completed_torrents;
                    document.getElementById("appInstanceName").value = pref.app_instance_name;
                    document.getElementById("refreshInterval").value = pref.refresh_interval;
                    document.getElementById("resolvePeerHostNames").checked = pref.resolve_peer_host_names;
                    document.getElementById("resolvePeerCountries").checked = pref.resolve_peer_countries;
                    document.getElementById("reannounceWhenAddressChanged").checked = pref.reannounce_when_address_changed;
                    document.getElementById("enableEmbeddedTracker").checked = pref.enable_embedded_tracker;
                    document.getElementById("embeddedTrackerPort").value = pref.embedded_tracker_port;
                    document.getElementById("embeddedTrackerPortForwarding").checked = pref.embedded_tracker_port_forwarding;
                    document.getElementById("markOfTheWeb").checked = pref.mark_of_the_web;
                    document.getElementById("ignoreSSLErrors").checked = pref.ignore_ssl_errors;
                    document.getElementById("pythonExecutablePath").value = pref.python_executable_path;
                    // libtorrent section
                    document.getElementById("bdecodeDepthLimit").value = pref.bdecode_depth_limit;
                    document.getElementById("bdecodeTokenLimit").value = pref.bdecode_token_limit;
                    document.getElementById("asyncIOThreads").value = pref.async_io_threads;
                    document.getElementById("hashingThreads").value = pref.hashing_threads;
                    document.getElementById("filePoolSize").value = pref.file_pool_size;
                    document.getElementById("outstandMemoryWhenCheckingTorrents").value = pref.checking_memory_use;
                    document.getElementById("diskCache").value = pref.disk_cache;
                    document.getElementById("diskCacheExpiryInterval").value = pref.disk_cache_ttl;
                    document.getElementById("diskQueueSize").value = (pref.disk_queue_size / 1024);
                    document.getElementById("diskIOType").value = pref.disk_io_type;
                    document.getElementById("diskIOReadMode").value = pref.disk_io_read_mode;
                    document.getElementById("diskIOWriteMode").value = pref.disk_io_write_mode;
                    document.getElementById("coalesceReadsAndWrites").checked = pref.enable_coalesce_read_write;
                    document.getElementById("pieceExtentAffinity").checked = pref.enable_piece_extent_affinity;
                    document.getElementById("sendUploadPieceSuggestions").checked = pref.enable_upload_suggestions;
                    document.getElementById("sendBufferWatermark").value = pref.send_buffer_watermark;
                    document.getElementById("sendBufferLowWatermark").value = pref.send_buffer_low_watermark;
                    document.getElementById("sendBufferWatermarkFactor").value = pref.send_buffer_watermark_factor;
                    document.getElementById("connectionSpeed").value = pref.connection_speed;
                    document.getElementById("socketSendBufferSize").value = (pref.socket_send_buffer_size / 1024);
                    document.getElementById("socketReceiveBufferSize").value = (pref.socket_receive_buffer_size / 1024);
                    document.getElementById("socketBacklogSize").value = pref.socket_backlog_size;
                    document.getElementById("outgoingPortsMin").value = pref.outgoing_ports_min;
                    document.getElementById("outgoingPortsMax").value = pref.outgoing_ports_max;
                    document.getElementById("UPnPLeaseDuration").value = pref.upnp_lease_duration;
                    document.getElementById("peerDSCP").value = pref.peer_tos;
                    document.getElementById("utpTCPMixedModeAlgorithm").value = pref.utp_tcp_mixed_mode;
                    document.getElementById("hostnameCacheTTL").value = pref.hostname_cache_ttl;
                    document.getElementById("IDNSupportCheckbox").checked = pref.idn_support_enabled;
                    document.getElementById("allowMultipleConnectionsFromTheSameIPAddress").checked = pref.enable_multi_connections_from_same_ip;
                    document.getElementById("validateHTTPSTrackerCertificate").checked = pref.validate_https_tracker_certificate;
                    document.getElementById("mitigateSSRF").checked = pref.ssrf_mitigation;
                    document.getElementById("blockPeersOnPrivilegedPorts").checked = pref.block_peers_on_privileged_ports;
                    document.getElementById("uploadSlotsBehavior").value = pref.upload_slots_behavior;
                    document.getElementById("uploadChokingAlgorithm").value = pref.upload_choking_algorithm;
                    document.getElementById("announceAllTrackers").checked = pref.announce_to_all_trackers;
                    document.getElementById("announceAllTiers").checked = pref.announce_to_all_tiers;
                    document.getElementById("announceIP").value = pref.announce_ip;
                    document.getElementById("announcePort").value = pref.announce_port;
                    document.getElementById("maxConcurrentHTTPAnnounces").value = pref.max_concurrent_http_announces;
                    document.getElementById("stopTrackerTimeout").value = pref.stop_tracker_timeout;
                    document.getElementById("peerTurnover").value = pref.peer_turnover;
                    document.getElementById("peerTurnoverCutoff").value = pref.peer_turnover_cutoff;
                    document.getElementById("peerTurnoverInterval").value = pref.peer_turnover_interval;
                    document.getElementById("requestQueueSize").value = pref.request_queue_size;
                    document.getElementById("dhtBootstrapNodes").value = pref.dht_bootstrap_nodes;
                    document.getElementById("i2pInboundQuantity").value = pref.i2p_inbound_quantity;
                    document.getElementById("i2pOutboundQuantity").value = pref.i2p_outbound_quantity;
                    document.getElementById("i2pInboundLength").value = pref.i2p_inbound_length;
                    document.getElementById("i2pOutboundLength").value = pref.i2p_outbound_length;
                }).catch((error) => {
                    console.error(error);
                    alert("QBT_TR(Unable to load program preferences, qBittorrent is probably unreachable.)QBT_TR[CONTEXT=HttpServer]");
                });
        };

        const applyPreferences = () => {
            const settings = {};
            const clientData = {};
            // Validate form data

            // Behavior tab
            // Language
            settings["locale"] = document.getElementById("locale_select").value;
            clientData.date_format = document.getElementById("dateFormatSelect").getSelected()[0].value;
            const colorScheme = Number(document.getElementById("colorSchemeSelect").value);
            if (colorScheme === 0)
                clientData.color_scheme = null;
            else if (colorScheme === 1)
                clientData.color_scheme = "light";
            else
                clientData.color_scheme = "dark";
            const displayDensity = document.getElementById("displayDensitySelect").value;
            clientData.display_density = (displayDensity === "default") ? null : displayDensity;
            settings["status_bar_external_ip"] = document.getElementById("statusBarExternalIP").checked;
            settings["performance_warning"] = document.getElementById("performanceWarning").checked;
            clientData.full_url_tracker_column = document.getElementById("displayFullURLTrackerColumn").checked;
            clientData.use_virtual_list = document.getElementById("useVirtualList").checked;
            clientData.hide_zero_status_filters = document.getElementById("hideZeroFiltersCheckbox").checked;
            clientData.dblclick_download = document.getElementById("dblclickDownloadSelect").value;
            clientData.dblclick_complete = document.getElementById("dblclickCompleteSelect").value;
            clientData.dblclick_filter = document.getElementById("dblclickFiltersSelect").value;
            settings["confirm_torrent_deletion"] = document.getElementById("confirmTorrentDeletion").checked;
            clientData.use_alt_row_colors = document.getElementById("useAltRowColorsInput").checked;
            settings["file_log_enabled"] = document.getElementById("filelog_checkbox").checked;
            settings["file_log_path"] = document.getElementById("filelog_save_path_input").value;
            settings["file_log_backup_enabled"] = document.getElementById("filelog_backup_checkbox").checked;
            settings["file_log_max_size"] = Number(document.getElementById("filelog_max_size_input").value);
            settings["file_log_delete_old"] = document.getElementById("filelog_delete_old_checkbox").checked;
            settings["file_log_age"] = Number(document.getElementById("filelog_age_input").value);
            settings["file_log_age_type"] = Number(document.getElementById("filelog_age_type_select").value);

            // Downloads tab
            // When adding a torrent
            settings["torrent_content_layout"] = document.getElementById("contentlayout_select").getSelected()[0].value;
            settings["add_to_top_of_queue"] = document.getElementById("addToTopOfQueueCheckbox").checked;
            settings["add_stopped_enabled"] = document.getElementById("dontstartdownloads_checkbox").checked;
            settings["torrent_stop_condition"] = document.getElementById("stopConditionSelect").getSelected()[0].value;
            settings["merge_trackers"] = document.getElementById("mergeTrackersInput").checked;
            settings["auto_delete_mode"] = Number(document.getElementById("deletetorrentfileafter_checkbox").checked);

            settings["preallocate_all"] = document.getElementById("preallocateall_checkbox").checked;
            settings["incomplete_files_ext"] = document.getElementById("appendext_checkbox").checked;
            settings["use_unwanted_folder"] = document.getElementById("unwantedfolder_checkbox").checked;

            // Saving Management
            settings["auto_tmm_enabled"] = (document.getElementById("default_tmm_combobox").value === "true");
            settings["torrent_changed_tmm_enabled"] = (document.getElementById("torrent_changed_tmm_combobox").value === "true");
            settings["save_path_changed_tmm_enabled"] = (document.getElementById("save_path_changed_tmm_combobox").value === "true");
            settings["category_changed_tmm_enabled"] = (document.getElementById("category_changed_tmm_combobox").value === "true");
            settings["use_category_paths_in_manual_mode"] = document.getElementById("categoryPathsManualModeCheckbox").checked;
            settings["save_path"] = document.getElementById("savepath_text").value;
            settings["temp_path_enabled"] = document.getElementById("temppath_checkbox").checked;
            settings["temp_path"] = document.getElementById("temppath_text").value;
            if (document.getElementById("exportdir_checkbox").checked)
                settings["export_dir"] = document.getElementById("exportdir_text").value;
            else
                settings["export_dir"] = "";
            if (document.getElementById("exportdirfin_checkbox").checked)
                settings["export_dir_fin"] = document.getElementById("exportdirfin_text").value;
            else
                settings["export_dir_fin"] = "";

            // Automatically add torrents from
            settings["scan_dirs"] = getWatchedFolders();

            // Excluded file names
            settings["excluded_file_names_enabled"] = document.getElementById("excludedFileNamesCheckbox").checked;
            settings["excluded_file_names"] = document.getElementById("excludedFileNamesTextarea").value;

            // Email notification upon download completion
            settings["mail_notification_enabled"] = document.getElementById("mail_notification_checkbox").checked;
            settings["mail_notification_sender"] = document.getElementById("src_email_txt").value;
            settings["mail_notification_email"] = document.getElementById("dest_email_txt").value;
            settings["mail_notification_smtp"] = document.getElementById("smtp_server_txt").value;
            settings["mail_notification_ssl_enabled"] = document.getElementById("mail_ssl_checkbox").checked;
            settings["mail_notification_auth_enabled"] = document.getElementById("mail_auth_checkbox").checked;
            settings["mail_notification_username"] = document.getElementById("mail_username_text").value;
            settings["mail_notification_password"] = document.getElementById("mail_password_text").value;

            // Run an external program on torrent added
            settings["autorun_on_torrent_added_enabled"] = document.getElementById("autorunOnTorrentAddedCheckbox").checked;
            settings["autorun_on_torrent_added_program"] = document.getElementById("autorunOnTorrentAddedProgram").value;
            // Run an external program on torrent finished
            settings["autorun_enabled"] = document.getElementById("autorun_checkbox").checked;
            settings["autorun_program"] = document.getElementById("autorunProg_txt").value;

            // Connection tab
            // Listening Port
            const listenPort = Number(document.getElementById("portValue").value);
            if (Number.isNaN(listenPort) || (listenPort < 0) || (listenPort > 65535)) {
                alert("QBT_TR(The port used for incoming connections must be between 0 and 65535.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["listen_port"] = listenPort;
            settings["upnp"] = document.getElementById("upnpCheckbox").checked;

            // Connections Limits
            let maxConnec = -1;
            if (document.getElementById("maxConnectionsCheckbox").checked) {
                maxConnec = Number(document.getElementById("maxConnectionsValue").value);
                if (Number.isNaN(maxConnec) || (maxConnec <= 0)) {
                    alert("QBT_TR(Maximum number of connections limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_connec"] = maxConnec;

            let maxConnecPerTorrent = -1;
            if (document.getElementById("maxConnectionsPerTorrentCheckbox").checked) {
                maxConnecPerTorrent = Number(document.getElementById("maxConnectionsPerTorrentValue").value);
                if (Number.isNaN(maxConnecPerTorrent) || (maxConnecPerTorrent <= 0)) {
                    alert("QBT_TR(Maximum number of connections per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_connec_per_torrent"] = maxConnecPerTorrent;

            let maxUploads = -1;
            if (document.getElementById("maxUploadsCheckbox").checked) {
                maxUploads = Number(document.getElementById("max_uploads_value").value);
                if (Number.isNaN(maxUploads) || (maxUploads <= 0)) {
                    alert("QBT_TR(Global number of upload slots limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_uploads"] = maxUploads;

            let maxUploadsPerTorrent = -1;
            if (document.getElementById("maxUploadsPerTorrentCheckbox").checked) {
                maxUploadsPerTorrent = Number(document.getElementById("maxUploadsPerTorrentValue").value);
                if (Number.isNaN(maxUploadsPerTorrent) || (maxUploadsPerTorrent <= 0)) {
                    alert("QBT_TR(Maximum number of upload slots per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_uploads_per_torrent"] = maxUploadsPerTorrent;

            // I2P
            settings["i2p_enabled"] = document.getElementById("i2pEnabledCheckbox").checked;
            settings["i2p_address"] = document.getElementById("i2pAddress").value;
            settings["i2p_port"] = Number(document.getElementById("i2pPort").value);
            settings["i2p_mixed_mode"] = document.getElementById("i2pMixedMode").checked;

            // Proxy Server
            settings["proxy_type"] = document.getElementById("peer_proxy_type_select").value;
            settings["proxy_ip"] = document.getElementById("peer_proxy_host_text").value;
            settings["proxy_port"] = Number(document.getElementById("peer_proxy_port_value").value);
            settings["proxy_auth_enabled"] = document.getElementById("peer_proxy_auth_checkbox").checked;
            settings["proxy_username"] = document.getElementById("peer_proxy_username_text").value;
            settings["proxy_password"] = document.getElementById("peer_proxy_password_text").value;
            settings["proxy_hostname_lookup"] = document.getElementById("proxyHostnameLookupCheckbox").checked;
            settings["proxy_bittorrent"] = document.getElementById("proxy_bittorrent_checkbox").checked;
            settings["proxy_peer_connections"] = document.getElementById("use_peer_proxy_checkbox").checked;
            settings["proxy_rss"] = document.getElementById("proxy_rss_checkbox").checked;
            settings["proxy_misc"] = document.getElementById("proxy_misc_checkbox").checked;

            // IP Filtering
            settings["ip_filter_enabled"] = document.getElementById("ipfilter_text_checkbox").checked;
            settings["ip_filter_path"] = document.getElementById("ipfilter_text").value;
            settings["ip_filter_trackers"] = document.getElementById("ipfilter_trackers_checkbox").checked;
            settings["banned_IPs"] = document.getElementById("banned_IPs_textarea").value;

            // Speed tab
            // Global Rate Limits
            const upLimit = Number(document.getElementById("upLimitValue").value) * 1024;
            if (Number.isNaN(upLimit) || (upLimit < 0)) {
                alert("QBT_TR(Global upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["up_limit"] = upLimit;

            const dlLimit = Number(document.getElementById("dlLimitValue").value) * 1024;
            if (Number.isNaN(dlLimit) || (dlLimit < 0)) {
                alert("QBT_TR(Global download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["dl_limit"] = dlLimit;

            // Alternative Global Rate Limits
            const altUpLimit = Number(document.getElementById("altUpLimitValue").value) * 1024;
            if (Number.isNaN(altUpLimit) || (altUpLimit < 0)) {
                alert("QBT_TR(Alternative upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["alt_up_limit"] = altUpLimit;

            const altDlLimit = Number(document.getElementById("altDlLimitValue").value) * 1024;
            if (Number.isNaN(altDlLimit) || (altDlLimit < 0)) {
                alert("QBT_TR(Alternative download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["alt_dl_limit"] = altDlLimit;

            settings["bittorrent_protocol"] = Number(document.getElementById("enable_protocol_combobox").value);
            settings["limit_utp_rate"] = document.getElementById("limit_utp_rate_checkbox").checked;
            settings["limit_tcp_overhead"] = document.getElementById("limit_tcp_overhead_checkbox").checked;
            settings["limit_lan_peers"] = document.getElementById("limit_lan_peers_checkbox").checked;

            // Scheduler
            const schedulingEnabled = document.getElementById("limitSchedulingCheckbox").checked;
            settings["scheduler_enabled"] = schedulingEnabled;
            if (schedulingEnabled) {
                settings["schedule_from_hour"] = Number(document.getElementById("schedule_from_hour").value);
                settings["schedule_from_min"] = Number(document.getElementById("schedule_from_min").value);
                settings["schedule_to_hour"] = Number(document.getElementById("schedule_to_hour").value);
                settings["schedule_to_min"] = Number(document.getElementById("schedule_to_min").value);
                settings["scheduler_days"] = Number(document.getElementById("schedule_freq_select").value);
            }

            // Bittorrent tab
            // Privacy
            settings["dht"] = document.getElementById("dht_checkbox").checked;
            settings["pex"] = document.getElementById("pex_checkbox").checked;
            settings["lsd"] = document.getElementById("lsd_checkbox").checked;
            settings["encryption"] = Number(document.getElementById("encryption_select").getSelected()[0].value);
            settings["anonymous_mode"] = document.getElementById("anonymous_mode_checkbox").checked;

            settings["max_active_checking_torrents"] = Number(document.getElementById("maxActiveCheckingTorrents").value);

            // Torrent Queueing
            settings["queueing_enabled"] = document.getElementById("queueingCheckbox").checked;
            if (document.getElementById("queueingCheckbox").checked) {
                const maxActiveDownloads = Number(document.getElementById("maxActiveDlValue").value);
                if (Number.isNaN(maxActiveDownloads) || (maxActiveDownloads < -1)) {
                    alert("QBT_TR(Maximum active downloads must be greater than -1.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
                settings["max_active_downloads"] = maxActiveDownloads;

                const maxActiveUploads = Number(document.getElementById("maxActiveUpValue").value);
                if (Number.isNaN(maxActiveUploads) || (maxActiveUploads < -1)) {
                    alert("QBT_TR(Maximum active uploads must be greater than -1.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
                settings["max_active_uploads"] = maxActiveUploads;

                const maxActiveTorrents = Number(document.getElementById("maxActiveToValue").value);
                if (Number.isNaN(maxActiveTorrents) || (maxActiveTorrents < -1)) {
                    alert("QBT_TR(Maximum active torrents must be greater than -1.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
                settings["max_active_torrents"] = maxActiveTorrents;
                settings["dont_count_slow_torrents"] = document.getElementById("dontCountSlowTorrentsCheckbox").checked;

                const dlRateThreshold = Number(document.getElementById("dlRateThresholdValue").value);
                if (Number.isNaN(dlRateThreshold) || (dlRateThreshold < 1)) {
                    alert("QBT_TR(Download rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
                settings["slow_torrent_dl_rate_threshold"] = dlRateThreshold;

                const ulRateThreshold = Number(document.getElementById("ulRateThresholdValue").value);
                if (Number.isNaN(ulRateThreshold) || (ulRateThreshold < 1)) {
                    alert("QBT_TR(Upload rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
                settings["slow_torrent_ul_rate_threshold"] = ulRateThreshold;

                const torrentInactiveTimer = Number(document.getElementById("torrentInactiveTimerValue").value);
                if (Number.isNaN(torrentInactiveTimer) || (torrentInactiveTimer < 1)) {
                    alert("QBT_TR(Torrent inactivity timer must be greater than 0.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
                settings["slow_torrent_inactive_timer"] = torrentInactiveTimer;
            }

            // Share Ratio Limiting
            let maxRatio = -1;
            if (document.getElementById("maxRatioCheckbox").checked) {
                maxRatio = Number(document.getElementById("maxRatioValue").value);
                if (Number.isNaN(maxRatio) || (maxRatio < 0)) {
                    alert("QBT_TR(Share ratio limit must not have a negative value.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_ratio_enabled"] = document.getElementById("maxRatioCheckbox").checked;
            settings["max_ratio"] = maxRatio;

            let maxSeedingTime = -1;
            if (document.getElementById("maxSeedingTimeCheckbox").checked) {
                maxSeedingTime = Number(document.getElementById("maxSeedingTimeValue").value);
                if (Number.isNaN(maxSeedingTime) || (maxSeedingTime < 0)) {
                    alert("QBT_TR(Seeding time limit must not have a negative value.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_seeding_time_enabled"] = document.getElementById("maxSeedingTimeCheckbox").checked;
            settings["max_seeding_time"] = maxSeedingTime;

            let maxInactiveSeedingTime = -1;
            if (document.getElementById("maxInactiveSeedingTimeCheckbox").checked) {
                maxInactiveSeedingTime = Number(document.getElementById("maxInactiveSeedingTimeValue").value);
                if (Number.isNaN(maxInactiveSeedingTime) || (maxInactiveSeedingTime < 0)) {
                    alert("QBT_TR(Seeding time limit must not have a negative value.)QBT_TR[CONTEXT=HttpServer]");
                    return;
                }
            }
            settings["max_inactive_seeding_time_enabled"] = document.getElementById("maxInactiveSeedingTimeCheckbox").checked;
            settings["max_inactive_seeding_time"] = maxInactiveSeedingTime;
            settings["max_ratio_act"] = Number(document.getElementById("maxRatioSelect").value);

            // Add trackers
            settings["add_trackers_enabled"] = document.getElementById("add_trackers_checkbox").checked;
            settings["add_trackers"] = document.getElementById("add_trackers_textarea").value;
            settings["add_trackers_from_url_enabled"] = document.getElementById("addTrackersFromURLCheckbox").checked;
            settings["add_trackers_url"] = document.getElementById("addTrackersURL").value;

            // RSS Tab
            settings["rss_processing_enabled"] = document.getElementById("enable_fetching_rss_feeds_checkbox").checked;
            settings["rss_refresh_interval"] = Number(document.getElementById("feed_refresh_interval").value);
            settings["rss_fetch_delay"] = Number(document.getElementById("feedFetchDelay").value);
            settings["rss_max_articles_per_feed"] = Number(document.getElementById("maximum_article_number").value);
            settings["rss_auto_downloading_enabled"] = document.getElementById("enable_auto_downloading_rss_torrents_checkbox").checked;
            settings["rss_download_repack_proper_episodes"] = document.getElementById("downlock_repack_proper_episodes").checked;
            settings["rss_smart_episode_filters"] = document.getElementById("rss_filter_textarea").value;

            // WebUI tab
            // HTTP Server
            settings["web_ui_domain_list"] = document.getElementById("webuiDomainTextarea").value;
            const webUIAddress = document.getElementById("webuiAddressValue").value.toString();
            const webUIPort = Number(document.getElementById("webuiPortValue").value);
            if (Number.isNaN(webUIPort) || (webUIPort < 1) || (webUIPort > 65535)) {
                alert("QBT_TR(The port used for the WebUI must be between 1 and 65535.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["web_ui_address"] = webUIAddress;
            settings["web_ui_port"] = webUIPort;
            settings["web_ui_upnp"] = document.getElementById("webuiUpnpCheckbox").checked;

            const useHTTPS = document.getElementById("use_https_checkbox").checked;
            settings["use_https"] = useHTTPS;

            const httpsCertificate = document.getElementById("ssl_cert_text").value;
            settings["web_ui_https_cert_path"] = httpsCertificate;
            if (useHTTPS && (httpsCertificate.length === 0)) {
                alert("QBT_TR(HTTPS certificate should not be empty)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }

            const httpsKey = document.getElementById("ssl_key_text").value;
            settings["web_ui_https_key_path"] = httpsKey;
            if (useHTTPS && (httpsKey.length === 0)) {
                alert("QBT_TR(HTTPS key should not be empty)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }

            // Authentication
            const web_ui_username = document.getElementById("webui_username_text").value;
            if (web_ui_username.length < 3) {
                alert("QBT_TR(The WebUI username must be at least 3 characters long.)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }
            if (web_ui_username.includes(":")) {
                alert("QBT_TR(The WebUI username must not contain a colon.)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }
            const web_ui_password = document.getElementById("webui_password_text").value;
            if ((0 < web_ui_password.length) && (web_ui_password.length < 6)) {
                alert("QBT_TR(The WebUI password must be at least 6 characters long.)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }

            settings["web_ui_username"] = web_ui_username;
            if (web_ui_password.length > 0)
                settings["web_ui_password"] = web_ui_password;
            settings["bypass_local_auth"] = document.getElementById("bypass_local_auth_checkbox").checked;
            settings["bypass_auth_subnet_whitelist_enabled"] = document.getElementById("bypass_auth_subnet_whitelist_checkbox").checked;
            settings["bypass_auth_subnet_whitelist"] = document.getElementById("bypass_auth_subnet_whitelist_textarea").value;
            settings["web_ui_max_auth_fail_count"] = Number(document.getElementById("webUIMaxAuthFailCountInput").value);
            settings["web_ui_ban_duration"] = Number(document.getElementById("webUIBanDurationInput").value);
            settings["web_ui_session_timeout"] = Number(document.getElementById("webUISessionTimeoutInput").value);

            // Use alternative WebUI
            const alternative_webui_enabled = document.getElementById("use_alt_webui_checkbox").checked;
            const webui_files_location_textarea = document.getElementById("webui_files_location_textarea").value;
            if (alternative_webui_enabled && (webui_files_location_textarea.trim() === "")) {
                alert("QBT_TR(The alternative WebUI files location cannot be blank.)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }
            settings["alternative_webui_enabled"] = alternative_webui_enabled;
            settings["alternative_webui_path"] = webui_files_location_textarea;

            // Security
            settings["web_ui_clickjacking_protection_enabled"] = document.getElementById("clickjacking_protection_checkbox").checked;
            settings["web_ui_csrf_protection_enabled"] = document.getElementById("csrf_protection_checkbox").checked;
            settings["web_ui_secure_cookie_enabled"] = document.getElementById("secureCookieCheckbox").checked;
            settings["web_ui_host_header_validation_enabled"] = document.getElementById("host_header_validation_checkbox").checked;

            // Custom HTTP headers
            settings["web_ui_use_custom_http_headers_enabled"] = document.getElementById("webUIUseCustomHTTPHeadersCheckbox").checked;
            settings["web_ui_custom_http_headers"] = document.getElementById("webUICustomHTTPHeadersTextarea").value;

            // Reverse Proxy
            settings["web_ui_reverse_proxy_enabled"] = document.getElementById("webUIReverseProxySupportCheckbox").checked;
            settings["web_ui_reverse_proxies_list"] = document.getElementById("webUIReverseProxiesListTextarea").value;

            // Update my dynamic domain name
            settings["dyndns_enabled"] = document.getElementById("use_dyndns_checkbox").checked;
            settings["dyndns_service"] = Number(document.getElementById("dyndns_select").value);
            settings["dyndns_domain"] = document.getElementById("dyndns_domain_text").value;
            settings["dyndns_username"] = document.getElementById("dyndns_username_text").value;
            settings["dyndns_password"] = document.getElementById("dyndns_password_text").value;

            // Update advanced settings
            // qBittorrent section
            settings["resume_data_storage_type"] = document.getElementById("resumeDataStorageType").value;
            settings["torrent_content_remove_option"] = document.getElementById("torrentContentRemoveOption").value;
            settings["memory_working_set_limit"] = Number(document.getElementById("memoryWorkingSetLimit").value);
            settings["current_network_interface"] = document.getElementById("networkInterface").value;
            settings["current_interface_address"] = document.getElementById("optionalIPAddressToBind").value;
            settings["save_resume_data_interval"] = Number(document.getElementById("saveResumeDataInterval").value);
            settings["save_statistics_interval"] = Number(document.getElementById("saveStatisticsInterval").value);
            settings["torrent_file_size_limit"] = (document.getElementById("torrentFileSizeLimit").value * 1024 * 1024);
            settings["confirm_torrent_recheck"] = document.getElementById("confirmTorrentRecheck").checked;
            settings["recheck_completed_torrents"] = document.getElementById("recheckTorrentsOnCompletion").checked;
            settings["app_instance_name"] = document.getElementById("appInstanceName").value;
            settings["refresh_interval"] = Number(document.getElementById("refreshInterval").value);
            settings["resolve_peer_host_names"] = document.getElementById("resolvePeerHostNames").checked;
            settings["resolve_peer_countries"] = document.getElementById("resolvePeerCountries").checked;
            settings["reannounce_when_address_changed"] = document.getElementById("reannounceWhenAddressChanged").checked;
            settings["enable_embedded_tracker"] = document.getElementById("enableEmbeddedTracker").checked;
            settings["embedded_tracker_port"] = Number(document.getElementById("embeddedTrackerPort").value);
            settings["embedded_tracker_port_forwarding"] = document.getElementById("embeddedTrackerPortForwarding").checked;
            settings["mark_of_the_web"] = document.getElementById("markOfTheWeb").checked;
            settings["ignore_ssl_errors"] = document.getElementById("ignoreSSLErrors").checked;
            settings["python_executable_path"] = document.getElementById("pythonExecutablePath").value;

            // libtorrent section
            settings["bdecode_depth_limit"] = Number(document.getElementById("bdecodeDepthLimit").value);
            settings["bdecode_token_limit"] = Number(document.getElementById("bdecodeTokenLimit").value);
            settings["async_io_threads"] = Number(document.getElementById("asyncIOThreads").value);
            settings["hashing_threads"] = Number(document.getElementById("hashingThreads").value);
            settings["file_pool_size"] = Number(document.getElementById("filePoolSize").value);

            const outstandMemory = Number(document.getElementById("outstandMemoryWhenCheckingTorrents").value);
            if (Number.isNaN(outstandMemory) || (outstandMemory < 0) || (outstandMemory > 1024)) {
                alert("QBT_TR(Outstanding memory when checking torrents must be greater than 0 and less than 1024.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["checking_memory_use"] = outstandMemory;

            settings["disk_cache"] = Number(document.getElementById("diskCache").value);
            settings["disk_cache_ttl"] = Number(document.getElementById("diskCacheExpiryInterval").value);
            settings["disk_queue_size"] = (Number(document.getElementById("diskQueueSize").value) * 1024);
            settings["disk_io_type"] = Number(document.getElementById("diskIOType").value);
            settings["disk_io_read_mode"] = Number(document.getElementById("diskIOReadMode").value);
            settings["disk_io_write_mode"] = Number(document.getElementById("diskIOWriteMode").value);
            settings["enable_coalesce_read_write"] = document.getElementById("coalesceReadsAndWrites").checked;
            settings["enable_piece_extent_affinity"] = document.getElementById("pieceExtentAffinity").checked;
            settings["enable_upload_suggestions"] = document.getElementById("sendUploadPieceSuggestions").checked;
            settings["send_buffer_watermark"] = Number(document.getElementById("sendBufferWatermark").value);
            settings["send_buffer_low_watermark"] = Number(document.getElementById("sendBufferLowWatermark").value);
            settings["send_buffer_watermark_factor"] = Number(document.getElementById("sendBufferWatermarkFactor").value);
            settings["connection_speed"] = Number(document.getElementById("connectionSpeed").value);
            settings["socket_send_buffer_size"] = (document.getElementById("socketSendBufferSize").value * 1024);
            settings["socket_receive_buffer_size"] = (document.getElementById("socketReceiveBufferSize").value * 1024);
            settings["socket_backlog_size"] = Number(document.getElementById("socketBacklogSize").value);
            settings["outgoing_ports_min"] = Number(document.getElementById("outgoingPortsMin").value);
            settings["outgoing_ports_max"] = Number(document.getElementById("outgoingPortsMax").value);
            settings["upnp_lease_duration"] = Number(document.getElementById("UPnPLeaseDuration").value);

            const peerDSCP = Number(document.getElementById("peerDSCP").value);
            if (Number.isNaN(peerDSCP) || (peerDSCP < 0) || (peerDSCP > 255)) {
                alert("QBT_TR(Peer DSCP must be between 0 and 255.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["peer_tos"] = peerDSCP;

            settings["utp_tcp_mixed_mode"] = Number(document.getElementById("utpTCPMixedModeAlgorithm").value);
            settings["hostname_cache_ttl"] = Number(document.getElementById("hostnameCacheTTL").value);
            settings["idn_support_enabled"] = document.getElementById("IDNSupportCheckbox").checked;
            settings["enable_multi_connections_from_same_ip"] = document.getElementById("allowMultipleConnectionsFromTheSameIPAddress").checked;
            settings["validate_https_tracker_certificate"] = document.getElementById("validateHTTPSTrackerCertificate").checked;
            settings["ssrf_mitigation"] = document.getElementById("mitigateSSRF").checked;
            settings["block_peers_on_privileged_ports"] = document.getElementById("blockPeersOnPrivilegedPorts").checked;
            settings["upload_slots_behavior"] = Number(document.getElementById("uploadSlotsBehavior").value);
            settings["upload_choking_algorithm"] = Number(document.getElementById("uploadChokingAlgorithm").value);
            settings["announce_to_all_trackers"] = document.getElementById("announceAllTrackers").checked;
            settings["announce_to_all_tiers"] = document.getElementById("announceAllTiers").checked;
            settings["announce_ip"] = document.getElementById("announceIP").value;
            const announcePort = Number(document.getElementById("announcePort").value);
            if (Number.isNaN(announcePort) || (announcePort < 0) || (announcePort > 65535)) {
                alert("QBT_TR(The announce port must be between 0 and 65535.)QBT_TR[CONTEXT=OptionsDialog]");
                return;
            }
            settings["announce_port"] = announcePort;
            settings["max_concurrent_http_announces"] = Number(document.getElementById("maxConcurrentHTTPAnnounces").value);
            settings["stop_tracker_timeout"] = Number(document.getElementById("stopTrackerTimeout").value);

            const peerTurnover = Number(document.getElementById("peerTurnover").value);
            if (Number.isNaN(peerTurnover) || (peerTurnover < 0) || (peerTurnover > 100)) {
                alert("QBT_TR(Peer turnover must be between 0 and 100.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["peer_turnover"] = peerTurnover;

            const peerTurnoverCutoff = Number(document.getElementById("peerTurnoverCutoff").value);
            if (Number.isNaN(peerTurnoverCutoff) || (peerTurnoverCutoff < 0) || (peerTurnoverCutoff > 100)) {
                alert("QBT_TR(Peer turnover cutoff must be between 0 and 100.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["peer_turnover_cutoff"] = peerTurnoverCutoff;

            const peerTurnoverInterval = Number(document.getElementById("peerTurnoverInterval").value);
            if (Number.isNaN(peerTurnoverInterval) || (peerTurnoverInterval < 0) || (peerTurnoverInterval > 3600)) {
                alert("QBT_TR(Peer turnover interval must be greater than or equal to 0.)QBT_TR[CONTEXT=HttpServer]");
                return;
            }
            settings["peer_turnover_interval"] = peerTurnoverInterval;

            settings["request_queue_size"] = Number(document.getElementById("requestQueueSize").value);
            settings["dht_bootstrap_nodes"] = document.getElementById("dhtBootstrapNodes").value;
            settings["i2p_inbound_quantity"] = Number(document.getElementById("i2pInboundQuantity").value);
            settings["i2p_outbound_quantity"] = Number(document.getElementById("i2pOutboundQuantity").value);
            settings["i2p_inbound_length"] = Number(document.getElementById("i2pInboundLength").value);
            settings["i2p_outbound_length"] = Number(document.getElementById("i2pOutboundLength").value);

            // Send data to qBT
            Promise.allSettled([
                window.parent.qBittorrent.ClientData.set(clientData),
                window.parent.qBittorrent.Cache.preferences.set(settings)
            ]).then((results) => {
                if (results.every((result) => result.status === "fulfilled")) {
                    window.parent.location.reload();
                    window.parent.qBittorrent.Client.closeWindow(document.getElementById("preferencesPage"));
                }
                else {
                    // keep window open so user can reattempt saving
                    if (error.name === "ServerError")
                        alert(`QBT_TR(Error:)QBT_TR[CONTEXT=HttpServer] ${error.message}`);
                    else
                        alert("QBT_TR(Unable to save preferences, qBittorrent is probably unreachable.)QBT_TR[CONTEXT=HttpServer]");
                }
            });
        };

        const setup = () => {
            watchedFoldersTable = new HtmlTable(document.getElementById("watched_folders_tab"));

            const buildInfo = window.qBittorrent.Cache.buildInfo.get();

            // hide entries
            const libtorrentVersion = window.qBittorrent.Misc.parseVersion(buildInfo.libtorrent);
            if (libtorrentVersion.valid) {
                if (libtorrentVersion.major >= 2) {
                    document.getElementById("rowDiskCache").style.display = "none";
                    document.getElementById("rowDiskCacheExpiryInterval").style.display = "none";
                    document.getElementById("rowCoalesceReadsAndWrites").style.display = "none";
                }
                else {
                    document.getElementById("fieldsetI2p").style.display = "none";
                    document.getElementById("rowMemoryWorkingSetLimit").style.display = "none";
                    document.getElementById("rowHashingThreads").style.display = "none";
                    document.getElementById("rowDiskIOType").style.display = "none";
                    document.getElementById("rowI2pInboundQuantity").style.display = "none";
                    document.getElementById("rowI2pOutboundQuantity").style.display = "none";
                    document.getElementById("rowI2pInboundLength").style.display = "none";
                    document.getElementById("rowI2pOutboundLength").style.display = "none";
                }

                if (!((libtorrentVersion.major >= 2) && (libtorrentVersion.minor >= 0) && (libtorrentVersion.fix >= 6)))
                    document.getElementById("diskIOWriteModeWriteThrough").style.display = "none";
            }

            if ((buildInfo.platform === "linux") || (buildInfo.platform === "macos"))
                document.getElementById("rowMemoryWorkingSetLimit").style.display = "none";

            if ((buildInfo.platform !== "macos") && (buildInfo.platform !== "windows"))
                document.getElementById("rowMarkOfTheWeb").style.display = "none";

            document.getElementById("networkInterface").addEventListener("change", function(event) {
                updateInterfaceAddresses(this.value, "");
            });

            loadPreferences();

            window.qBittorrent.pathAutofill.attachPathAutofill();
        };

        // show static prefix plus 6 sensitive characters
        const maskAPIKey = (key) => (key.slice(0, 4) + "•".repeat(key.length - 10) + key.slice(key.length - 6));

        const rotateAPIKey = () => {
            fetch("api/v2/app/rotateAPIKey", {
                    method: "POST",
                })
                .then(async (response) => {
                    if (!response.ok) {
                        alert(await response.text());
                        return;
                    }

                    const { apiKey } = await response.json();
                    const apiKeyTextElem = document.getElementById("WebUIAPIKeyText");
                    apiKeyTextElem.value = maskAPIKey(apiKey);
                    apiKeyTextElem.dataset.apiKey = apiKey;

                    document.getElementById("webUIAPIKeyCopyButton").disabled = false;
                    document.getElementById("webUIAPIKeyRotateButton").dataset.hasKey = "true";
                    document.querySelector("#webUIAPIKeyRotateButton img").title = "QBT_TR(Rotate API key)QBT_TR[CONTEXT=OptionsDialog]";
                    document.getElementById("webUIAPIKeyDeleteButton").disabled = false;
                })
                .catch((error) => {
                    alert(`QBT_TR(Unable to rotate API key.)QBT_TR[CONTEXT=HttpServer] ${error.toString()}`);
                });
        };

        const deleteAPIKey = () => {
            fetch("api/v2/app/deleteAPIKey", {
                    method: "POST",
                })
                .then(async (response) => {
                    if (!response.ok) {
                        alert(await response.text());
                        return;
                    }

                    const apiKeyTextElem = document.getElementById("WebUIAPIKeyText");
                    apiKeyTextElem.value = "";
                    apiKeyTextElem.dataset.apiKey = "";

                    document.getElementById("webUIAPIKeyCopyButton").disabled = true;
                    document.getElementById("webUIAPIKeyRotateButton").dataset.hasKey = "false";
                    document.querySelector("#webUIAPIKeyRotateButton img").title = "QBT_TR(Generate API key)QBT_TR[CONTEXT=OptionsDialog]";
                    document.getElementById("webUIAPIKeyDeleteButton").disabled = true;
                })
                .catch((error) => {
                    alert(`QBT_TR(Unable to delete API key.)QBT_TR[CONTEXT=HttpServer] ${error.toString()}`);
                });
        };

        document.getElementById("webUIAPIKeyCopyButton").addEventListener("click", async (e) => {
            const apiKey = document.getElementById("WebUIAPIKeyText").dataset.apiKey;
            await clipboardCopy(apiKey);

            const copyImg = document.querySelector("#webUIAPIKeyCopyButton img.copyImg");
            const checkImg = document.querySelector("#webUIAPIKeyCopyButton img.checkImg");

            copyImg.style.display = "none";
            checkImg.style.display = "inline";

            setTimeout(() => {
                copyImg.style.display = "inline";
                checkImg.style.display = "none";
            }, 2000);
        });

        document.getElementById("webUIAPIKeyRotateButton").addEventListener("click", (e) => {
            const hasKey = e.target.parentElement.dataset.hasKey === "true";
            const title = hasKey
                ? "QBT_TR(Rotate API key)QBT_TR[CONTEXT=OptionsDialog]"
                : "QBT_TR(Generate API key)QBT_TR[CONTEXT=OptionsDialog]";
            const message = hasKey
                ? "QBT_TR(Rotate this API key? The current key will immediately stop working and a new key will be generated.)QBT_TR[CONTEXT=confirmRotateAPIKeyDialog]"
                : "QBT_TR(Generate an API key? This key can be used to interact with qBittorrent's API.)QBT_TR[CONTEXT=confirmRotateAPIKeyDialog]";

            new MochaUI.Modal({
                ...window.qBittorrent.Dialog.baseModalOptions,
                title: title,
                id: "confirmAPIKeyDialog",
                contentURL: "views/confirmAPIKey.html?v=${CACHEID}",
                data: {
                    action: "rotate",
                    message: message,
                },
            });
        });

        document.getElementById("webUIAPIKeyDeleteButton").addEventListener("click", (e) => {
            const title = "QBT_TR(Delete API key)QBT_TR[CONTEXT=OptionsDialog]";
            const message = "QBT_TR(Delete this API key? The current key will immediately stop working.)QBT_TR[CONTEXT=confirmRotateAPIKeyDialog]";
            new MochaUI.Modal({
                ...window.qBittorrent.Dialog.baseModalOptions,
                title: title,
                id: "confirmAPIKeyDialog",
                contentURL: "views/confirmAPIKey.html?v=${CACHEID}",
                data: {
                    action: "delete",
                    message: message,
                },
            });
        });

        return exports();
    })();
    Object.freeze(window.qBittorrent.Preferences);

    window.qBittorrent.Preferences.setup();
</script>
