/* ============================================================
   Төрмен — PUBLIC env (AUTO-GENERATED)
   Сгенерировано из Vercel Environment Variables
   Правьте .env → npm run config. SERVER ONLY ключи сюда не попадают.
   ============================================================ */
const TORMEN_ENV = {
  medusa: {
    backendUrl: 'https://tormen-production.up.railway.app',
    publishableKey: 'pk_0d48ffcb7e544a04ffcf0106496f6c1bc685804bb83bc12d24926ab5c66c7455',
  },
  telegram: {
    botUsername: 'tormen_bot',
    botUrl: 'https://t.me/tormen_bot',
  },
  posthog: {
    key: '',
    host: 'https://eu.i.posthog.com',
  },
  chat: {
    apiUrl: '',
  },
  payments: {
    kaspiTransferHint: '',
  },
  sanity: {
    projectId: 'afzbfjob',
    dataset: 'production',
    apiVersion: '2024-01-01',
  },
  app: {
    phone: '77007007070',
    address: 'Астана, ул. Сарым Батыра 11',
    city: 'Астана',
    workingHours: '09:00 — 21:00',
  },
};

function isMedusaConfigured(){
  const { backendUrl, publishableKey } = TORMEN_ENV.medusa;
  return backendUrl.startsWith('http')
    && publishableKey.startsWith('pk_')
    && publishableKey.length > 12;
}

function isPosthogConfigured(){
  return !!(TORMEN_ENV.posthog.key && TORMEN_ENV.posthog.key.length > 8);
}

function isChatApiConfigured(){
  return !!(TORMEN_ENV.chat.apiUrl && TORMEN_ENV.chat.apiUrl.startsWith('http'));
}

function isSanityConfigured(){
  const id = TORMEN_ENV.sanity?.projectId || '';
  return id.length > 4 && id !== 'YOUR_PROJECT_ID';
}

function tgMention(){
  return '@' + TORMEN_ENV.telegram.botUsername;
}

function openTelegram(url){
  const u = url || TORMEN_ENV.telegram.botUrl;
  if(u) window.open(u, '_blank', 'noopener,noreferrer');
}

Object.assign(window, {
  TORMEN_ENV,
  isMedusaConfigured,
  isPosthogConfigured,
  isChatApiConfigured,
  isSanityConfigured,
  tgMention,
  openTelegram,
});
