{#if showForm} {#if error}
{error}
{/if}
form.icon = v} />
{#if !editing}
{/if}
{/if} {#if bots.length === 0 && !showForm} {:else}
{#each bots as bot}

{bot.name}

{#if bot.bot_username} @{bot.bot_username} {/if} {bot.update_mode === 'webhook' ? t('telegramBot.webhook') : t('telegramBot.polling')}

{bot.token_preview}

editBot(bot)} /> remove(bot.id)} variant="danger" />
{#if expandedSection[bot.id] === 'chats'}
{#if chatsLoading[bot.id]}

{t('common.loading')}

{:else if (chats[bot.id] || []).length === 0}

{t('telegramBot.noChats')}

{:else}
{#each chats[bot.id] as chat}
copyChatId(e, chat.chat_id)} title={t('telegramBot.clickToCopy')} role="button" tabindex="0">
{chat.title || chat.username || 'Unknown'} {chatTypeLabel(chat.type)} {#if chat.language_code}{chat.language_code.toUpperCase()}{/if} {chat.chat_id}
testChat(e, bot.id, chat.chat_id)} disabled={chatTesting[`${bot.id}_${chat.chat_id}`]} /> { e.stopPropagation(); deleteChat(bot.id, chat.id); }} variant="danger" />
{/each}
{/if}
{/if} {#if expandedSection[bot.id] === 'listeners'}
{#if botListenerLoading[bot.id]}

{t('common.loading')}

{:else if (botListenerStatus[bot.id] || []).length === 0}

{t('commandTracker.noListeners')}

{:else}
{#each botListenerStatus[bot.id] as trk}
{trk.name} {trk.enabled ? t('commandTracker.enabled') : t('commandTracker.disabled')}
{t('common.edit')}
{/each}
{/if}

{t('telegramBot.updateMode')}

{#if bot.update_mode === 'polling'} {t('telegramBot.pollingActive')} {/if} {#if bot.update_mode === 'webhook'} {#if webhookStatus[bot.id]} {@const ws = webhookStatus[bot.id]} {ws.url ? t('telegramBot.webhookActive') : t('telegramBot.webhookNotSet')} {#if ws.pending_update_count > 0} ({ws.pending_update_count} {t('telegramBot.pendingUpdates')}) {/if} {#if ws.last_error_message} {t('telegramBot.webhookError')}: {ws.last_error_message} {/if} {:else} {/if} {/if} {#if !settings.external_url && bot.update_mode === 'webhook'} {t('telegramBot.noExternalDomain')} {/if}
{/if}
{/each}
{/if} confirmDelete?.onconfirm()} oncancel={() => confirmDelete = null} />