import { IconBrandSpeedtest, IconReload, IconSettings, } from '@tabler/icons-solidjs' import { For, Show, createMemo, createSignal } from 'solid-js' import { twMerge } from 'tailwind-merge' import { Button, Collapse, ProxiesSettingsModal, ProxyCardGroups, ProxyNodePreview, RenderInTwoColumns, SubscriptionInfo, } from '~/components' import { MODAL } from '~/constants' import { filterProxiesByAvailability, formatTimeFromNow, sortProxiesByOrderingType, useStringBooleanMap, } from '~/helpers' import { useI18n } from '~/i18n' import { hideUnAvailableProxies, proxiesOrderingType, useProxies, } from '~/signals' enum ActiveTab { proxyProviders = 'proxyProviders', proxies = 'proxies', } export default () => { const { t } = useI18n() const { proxies, selectProxyInGroup, latencyTestByProxyGroupName, latencyMap, proxyProviders, updateProviderByProviderName, updateAllProvider, healthCheckByProviderName, } = useProxies() const { map: collapsedMap, set: setCollapsedMap } = useStringBooleanMap() const { map: latencyTestingMap, setWithCallback: setLatencyTestingMap } = useStringBooleanMap() const onLatencyTestClick = async (e: MouseEvent, name: string) => { e.stopPropagation() void setLatencyTestingMap(name, () => latencyTestByProxyGroupName(name)) } const { map: healthCheckingMap, setWithCallback: setHealthCheckingMap } = useStringBooleanMap() const { map: updatingMap, setWithCallback: setUpdatingMap } = useStringBooleanMap() const [isAllProviderUpdating, setIsAllProviderUpdating] = createSignal(false) const onHealthCheckClick = (e: MouseEvent, name: string) => { e.stopPropagation() void setHealthCheckingMap(name, () => healthCheckByProviderName(name)) } const onUpdateProviderClick = (e: MouseEvent, name: string) => { e.stopPropagation() void setUpdatingMap(name, () => updateProviderByProviderName(name)) } const onUpdateAllProviderClick = async (e: MouseEvent) => { e.stopPropagation() setIsAllProviderUpdating(true) try { await updateAllProvider() } catch {} setIsAllProviderUpdating(false) } const [activeTab, setActiveTab] = createSignal(ActiveTab.proxies) const tabs = () => [ { type: ActiveTab.proxies, name: t('proxies'), count: proxies().length, }, { type: ActiveTab.proxyProviders, name: t('proxyProviders'), count: proxyProviders().length, }, ] return (