// ЗОВ MiniApp — главный скрипт. // На входе: подписанный initData от Telegram. // Ходим на backend → получаем профиль (роль, статус) → рендерим меню. const tg = window.Telegram?.WebApp; const BACKEND_URL = "https://script.google.com/macros/s/AKfycbyxSwfD4hi5Y176nKV3tmnQq21kCQM3BBm34WGgObgAuybsAW7WPEuxlrPZ1a16viK3/exec"; const app = document.getElementById("app"); /* ----------------- Telegram WebApp setup ----------------- */ function setupTelegram() { const scheme = tg?.colorScheme || (window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light"); document.documentElement.setAttribute("data-theme", scheme); // Дизайн-вариант: brand (default) / a / c — сохраняется в localStorage. const savedVariant = (typeof localStorage !== "undefined" && localStorage.getItem("zov_variant")) || "brand"; document.documentElement.setAttribute("data-variant", savedVariant); if (!tg) return; try { tg.ready(); tg.expand(); if (tg.onEvent) tg.onEvent("themeChanged", () => { document.documentElement.setAttribute("data-theme", tg.colorScheme || "light"); }); if (tg.enableClosingConfirmation) tg.enableClosingConfirmation(); } catch (e) { console.warn(e); } } function setVariant(variant) { document.documentElement.setAttribute("data-variant", variant); try { localStorage.setItem("zov_variant", variant); } catch (e) {} // Перерисовать активную кнопку в свитчере document.querySelectorAll(".theme-switch button").forEach(b => { b.classList.toggle("active", b.dataset.variant === variant); }); haptic(); } function buildThemeSwitch() { const current = document.documentElement.getAttribute("data-variant") || "brand"; const node = el(`