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 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 } /** is_store فقط از API تنظیمات (get_settings) خوانده می‌شود — نه از get_user */ export async function initStoreModeFromSettings(): Promise { if (storeModeFromSettings !== null) return storeModeFromSettings try { const { getConfiguration } = await import('@/api/configuration') const rows = await getConfiguration() const row = Array.isArray(rows) ? rows.find((item) => item.key === 'is_store') : null storeModeFromSettings = row ? isSwitchOn(row.value) : false } catch { storeModeFromSettings = false } return storeModeFromSettings } export function isStoreApp(): boolean { return storeModeFromSettings === true }