import i18n from "../global/i18n";
import { configStore } from "../store/store";
import { setDayjsLocale, setDayjsTimeZone } from "./dayjs";
export function setupLanguage(lang) {
    if (i18n.language !== lang) {
        i18n.changeLanguage(lang);
    }
    configStore.set('language', lang);
    setDayjsLocale(lang);
}
export function setupTheme(theme) {
    configStore.set('theme', theme);
}
export function setupBusinessId(businessId) {
    configStore.set('businessId', businessId || null);
}
export function setupShopId(shopId) {
    configStore.set('shopId', shopId || null);
}
export function setupAccessToken(accessToken) {
    configStore.set('accessToken', accessToken || null);
}
export function setupIsProduction(isProduction) {
    let value = false;
    if (typeof isProduction === 'boolean') {
        value = isProduction;
    }
    else if (typeof isProduction === 'string') {
        value = isProduction.toLowerCase() === 'true';
    }
    configStore.set('isProduction', value);
}
export function setupTimeZone(timeZone) {
    let _timeZone = timeZone;
    if (!timeZone || timeZone === 'null') {
        _timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    }
    configStore.set('timeZone', _timeZone);
    if (_timeZone) {
        setDayjsTimeZone(_timeZone);
    }
}
export function setupTranslationSettings(translationSettings) {
    configStore.set('translationSettings', translationSettings);
}
export function setupIsNotConnected(isNotConnected) {
    let value = false;
    if (typeof isNotConnected === 'boolean') {
        value = isNotConnected;
    }
    else if (typeof isNotConnected === 'string') {
        value = isNotConnected.toLowerCase() === 'true';
    }
    configStore.set('isNotConnected', value);
}
export function setupIsZwiz(isZwiz) {
    let value = false;
    if (typeof isZwiz === 'boolean') {
        value = isZwiz;
    }
    else if (typeof isZwiz === 'string') {
        value = isZwiz.toLowerCase() === 'true';
    }
    configStore.set('isZwiz', value);
}
export function setupConnectionList(connectionList) {
    configStore.set('connectionList', connectionList);
}
export function setupMemberList(memberList) {
    configStore.set('memberList', memberList);
}
export function setupZrmzApiUrl(zrmzApiUrl) {
    configStore.set('zrmzApiUrl', zrmzApiUrl);
}
export function setupOpenChatByFilter(openChatByFilter) {
    configStore.set('openChatByFilter', openChatByFilter);
}
export function setupPackage(_package) {
    configStore.set('package', _package);
}
export function setupIsShowWarningNotification(isShowWarning) {
    let value = false;
    if (isShowWarning === undefined)
        return;
    if (typeof isShowWarning === 'boolean') {
        value = isShowWarning;
    }
    else if (typeof isShowWarning === 'string') {
        value = isShowWarning.toLowerCase() === 'true';
    }
    configStore.set('isShowWarningNotification', value);
}
export function setupZwizSyncMessage(zwizSyncMessage) {
    let value = false;
    if (zwizSyncMessage === undefined)
        return;
    if (typeof zwizSyncMessage === 'boolean') {
        value = zwizSyncMessage;
    }
    else if (typeof zwizSyncMessage === 'string') {
        value = zwizSyncMessage.toLowerCase() === 'true';
    }
    configStore.set('zwizSyncMessage', value);
}
