import React from 'react';
import PropTypes from 'prop-types';
import { connect, useStoreActions } from './StateProvider';
import { getConfigs, fetchConfigs, updateConfigs } from '../store/configs';
import {
getClashAPIConfig,
getSelectedChartStyleIndex,
getLatencyTestUrl,
clearStorage,
} from '../store/app';
import ContentHeader from './ContentHeader';
import Switch from './SwitchThemed';
import ToggleSwitch from './ToggleSwitch';
import Input, { SelfControlledInput } from './Input';
import Button from './Button';
import Selection from './Selection';
import TrafficChartSample from './TrafficChartSample';
import s0 from './Config.module.css';
const { useEffect, useState, useCallback, useRef } = React;
const propsList = [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }];
const optionsRule = [
{
label: 'Global',
value: 'Global',
},
{
label: 'Rule',
value: 'Rule',
},
{
label: 'Direct',
value: 'Direct',
},
];
const optionsLogLevel = [
{
label: 'info',
value: 'info',
},
{
label: 'warning',
value: 'warning',
},
{
label: 'error',
value: 'error',
},
{
label: 'debug',
value: 'debug',
},
{
label: 'silent',
value: 'silent',
},
];
const mapState = (s) => ({
configs: getConfigs(s),
apiConfig: getClashAPIConfig(s),
});
const mapState2 = (s) => ({
selectedChartStyleIndex: getSelectedChartStyleIndex(s),
latencyTestUrl: getLatencyTestUrl(s),
apiConfig: getClashAPIConfig(s),
});
const Config = connect(mapState2)(ConfigImpl);
export default connect(mapState)(ConfigContainer);
function ConfigContainer({ dispatch, configs, apiConfig }) {
useEffect(() => {
dispatch(fetchConfigs(apiConfig));
}, [dispatch, apiConfig]);
return