export function getConfigApp(key: string) { const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {} if (config) { return config[key] } return null } let storeModeFromSettings: boolean | null = null let settingsBootstrapped = false function isSwitchOn(value: string | undefined | null): boolean { const v = (value ?? '').trim().toLowerCase() return v === 'true' || v === '1' || v === 'yes' } export function setStoreModeFromSettings(value: boolean): void { storeModeFromSettings = value } async function bootstrapSettingsFromApi(): Promise { if (settingsBootstrapped) return try { const { getConfiguration } = await import('@/api/configuration') const { parseMainWalletProductIds } = await import('@/components/mobile/utils/wallet') const rows = await getConfiguration() const list = Array.isArray(rows) ? rows : [] const isStoreRow = list.find((item) => item.key === 'is_store') const mainWalletRow = list.find((item) => item.key === 'main_wallet_products') storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet') setCachedMainWalletProductIds(parseMainWalletProductIds(mainWalletRow?.value)) } catch { storeModeFromSettings = false const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet') setCachedMainWalletProductIds([]) } finally { settingsBootstrapped = true } } /** is_store و main_wallet_products از API تنظیمات — نه از get_user */ export async function initStoreModeFromSettings(): Promise { if (storeModeFromSettings !== null) return storeModeFromSettings await bootstrapSettingsFromApi() return storeModeFromSettings === true } export async function initWalletSettingsFromApi(): Promise { await bootstrapSettingsFromApi() } export function isStoreApp(): boolean { return storeModeFromSettings === true }