/*
 * GCX Next — универсальный загрузчик для нескольких корневых тренингов.
 */
(function (window, document, location) {
  "use strict";

  // ===== НАСТРОЙКИ =====
  var ROOTS = [
    {
      id: "935727501",
      bundle: "https://edu.wowmarketing-school.ru/pl/cms/layout/js?id=97136&hash=5ce28be7bc2e69d92006af5bde32bbb8&bundle=1&v=20260905-174"
    },
    {
      id: "935991198",
      bundle: "/pl/cms/layout/js?id=102526&hash=cbc86d1436c791e1def80063d3362035&bundle=1"
    },
    {
      id: "936004537",
      bundle: "/pl/cms/layout/js?id=102526&hash=cbc86d1436c791e1def80063d3362035&bundle=1"
    }
            
  ];
  // ===== /НАСТРОЙКИ =====

  if (window.__GCX_NEXT_UNIVERSAL_LOADER__) return;
  window.__GCX_NEXT_UNIVERSAL_LOADER__ = true;

  ROOTS.forEach(function (root) {
    root.path = "/teach/control/stream/view/id/" + root.id;
  });

  var loginPath = "/cms/system/login";
  var rawPath = location.pathname.replace(/\/$/, "");
  var editorSuffix = "/editMode/1";
  var editorPath = rawPath.slice(-editorSuffix.length) === editorSuffix;
  var path = editorPath ? rawPath.slice(0, -editorSuffix.length) : rawPath;
  var maxGateAttempts = 300;

  function findRoot(value) {
    var pathname;
    try {
      pathname = new URL(String(value || ""), location.origin).pathname;
    } catch (error) {
      return null;
    }
    pathname = pathname.replace(/\/$/, "");
    for (var index = 0; index < ROOTS.length; index += 1) {
      if (ROOTS[index].path === pathname) return ROOTS[index];
    }
    return null;
  }

  function isRootPath(value) {
    return !!findRoot(value);
  }

  function rootForPage() {
    var direct = findRoot(path);
    if (direct) return direct;
    var containers = document.querySelectorAll(".main-page-block .container, .gc-main-content .container");
    for (var i = 0; i < containers.length; i += 1) {
      var links = containers[i].querySelectorAll("a[href]");
      for (var j = 0; j < links.length; j += 1) {
        var root = findRoot(links[j].getAttribute("href"));
        if (root) return root;
      }
    }
    return null;
  }

  function currentRoot() {
    return (nestedStreamPath() || lessonPath()) ? rootForPage() : findRoot(path);
  }

  function pageBelongsToRoot() {
    if (window.__GCX_NEXT_CONFIRMED_SCOPE__ === true) return true;
    return !!rootForPage();
  }

  function installLegacyAccountChromeGuard() {
    var styleId = "gcx-next-legacy-account-chrome-guard";
    if (!document.getElementById(styleId)) {
      var style = document.createElement("style");
      style.id = styleId;
      style.setAttribute("data-gcx-next-theme-asset", "true");
      style.textContent = "html.gcx-next-account-chrome-guard .new-burger,html.gcx-next-account-chrome-guard #gcAccountUserMenu .new-menu__support,html.gcx-next-account-chrome-guard #gcAccountUserMenu .new-menu__user{display:none!important;height:0!important;margin:0!important;min-height:0!important;opacity:0!important;overflow:hidden!important;padding:0!important;pointer-events:none!important;visibility:hidden!important;width:0!important}html.gcx-next-account-chrome-guard.gcx-next-login-account-chrome #gcAccountUserMenu,html.gcx-next-account-chrome-guard.gcx-next-login-account-chrome .gcx-next-account-menu,html.gcx-next-account-chrome-guard.gcx-next-editor-account-chrome #gcAccountUserMenu,html.gcx-next-account-chrome-guard.gcx-next-editor-account-chrome .gcx-next-account-menu{display:none!important;height:0!important;margin:0!important;min-height:0!important;opacity:0!important;overflow:hidden!important;padding:0!important;pointer-events:none!important;visibility:hidden!important;width:0!important}html.gcx-next-account-chrome-guard.gcx-next-editor-account-chrome #redesignedNoticeTopPanel{box-sizing:border-box!important;left:0!important;max-width:100vw!important;right:0!important;width:100%!important}html.gcx-next-account-chrome-guard.gcx-next-editor-account-chrome .gc-main-content.with-left-menu{margin-left:0!important;max-width:none!important;width:auto!important}";
      (document.head || document.documentElement).appendChild(style);
    }
    document.documentElement.classList.add("gcx-next-account-chrome-guard");
    if (path === loginPath) document.documentElement.classList.add("gcx-next-login-account-chrome");
    if (editorMode()) document.documentElement.classList.add("gcx-next-editor-account-chrome");
  }

  function guardLegacyAccountChrome(attempt) {
    var rawId = window.accountUserId;
    if (rawId == null || rawId === "") {
      if (attempt < maxGateAttempts && typeof window.setTimeout === "function") {
        window.setTimeout(function () { guardLegacyAccountChrome(attempt + 1); }, attempt < 80 ? 0 : 25);
      }
      return;
    }
    var id = String(rawId);
    if (!(/^[1-9][0-9]*$/.test(id)) || !routeAllowed() || ((nestedStreamPath() || lessonPath()) && !pageBelongsToRoot())) return;
    installLegacyAccountChromeGuard();
    if (!editorMode() && path !== loginPath) {
      document.documentElement.classList.add("gcx-next-account-menu-active");
      disableLegacyMenuCss();
      installGlobalChromeStyles();
      installAccountMenuRuntime();
    }
  }

  function editorMode() {
    return editorPath || /(?:^|[?&])editMode=1(?:&|$)/.test(location.search);
  }

  function nativeAccountUserId() {
    var value = window.accountUserId;
    if (value == null || value === "") value = window.__GCX_NEXT_ALLOWED_USER_ID__;
    if (value != null && value !== "") return String(value);
    var scripts = document.scripts || [];
    for (var index = 0; index < scripts.length; index += 1) {
      var match = String(scripts[index].textContent || "").match(/window\.accountUserId\s*=\s*(-?\d+)/);
      if (match) return match[1];
    }
    return "";
  }

  function nestedStreamPath() {
    return /^\/teach\/control\/stream\/view\/id\/\d+$/.test(path) && !isRootPath(path);
  }

  function lessonPath() {
    return /^\/(?:pl\/)?teach\/control\/lesson\/(?:view|webview)\/id\/\d+$/.test(path) ||
      /^\/(?:pl\/)?teach\/control\/lesson\/(?:view|webview)$/.test(path);
  }

  function rootZoomFromDocument(scope) {
    var rows = scope.querySelectorAll(".xdget-trainingList .stream-table tr[data-training-id], .xdget-trainingList .training-row[data-training-id]");
    for (var index = 0; index < rows.length; index += 1) {
      var title = String(((rows[index].querySelector(".stream-title") || {}).textContent || "")).replace(/\s+/g, " ").trim();
      if (!/(?:^|\s)(?:zoom|зум)(?:\s|$)|эфир|разбор/i.test(title)) continue;
      var anchor = rows[index].querySelector("a[href]");
      if (anchor) return { title: title, href: anchor.getAttribute("href") };
    }
    return null;
  }

  async function resolveRootZoom() {
    if (!isRootPath(path) ||
        typeof window.fetch !== "function" ||
        typeof window.DOMParser !== "function") return null;
    if (document.readyState === "loading") {
      await new Promise(function (resolve) {
        document.addEventListener("DOMContentLoaded", resolve, { once: true });
      });
    }
    var direct = rootZoomFromDocument(document);
    if (direct) return direct;
    try {
      var response = await window.fetch(path, { credentials: "same-origin" });
      if (!response.ok) return null;
      var parsed = new window.DOMParser().parseFromString(await response.text(), "text/html");
      return rootZoomFromDocument(parsed);
    } catch (error) {
      return null;
    }
  }

  function routeAllowed() {
    if (path === "/teach/control" || path === "/teach/control/stream" || path === "/teach/control/stream/index" || path === "/pl/talks/conversation" || path === "/cms/system/contact" || path === "/wow-shop" || path === "/usrs-rating_10" || path === loginPath) return true;
    return isRootPath(path) || nestedStreamPath() || lessonPath();
  }

  function managedRootExists(){function e(e,t){var n=!0;return Array.prototype.forEach.call(e.querySelectorAll(t),function(e){function t(){e.__gcxNextCriticalReady=!0,window.dispatchEvent(new window.Event("gcx-next:managed-ready"))}function r(){"function"==typeof e.decode?e.decode().then(t,t):t()}e.loading="eager",e.decoding="async",e.__gcxNextCriticalReady||(n=!1,e.__gcxNextCriticalBound||(e.__gcxNextCriticalBound=!0,e.complete?r():(e.addEventListener("load",r,{once:!0}),e.addEventListener("error",t,{once:!0}))))}),n}if("/usrs-rating_10"===path)return!!document.querySelector(".gcx-rating-root.is-ready");if(isRootPath(path)){var t=document.querySelector(".gcx-next-root");return!!t&&e(t,".gcx-next-hero img, .gcx-next-rating-symbol img")}var n=document.querySelector(".gcx-next-module-root");if(n)return n.classList.contains("is-ready")&&e(n,".gcx-next-module-hero img");var r=document.querySelector(".gcx-next-faculties-root");if(r)return r.classList.contains("is-ready")&&e(r,".gcx-next-faculties-hero img");var o=document.querySelector(".gcx-next-niches-root");if(o)return o.classList.contains("is-ready")&&e(o,".gcx-next-niches-hero img, .gcx-next-niches-grid > .gcx-next-niche-card:nth-child(-n+4) img");var c=document.querySelector(".gcx-next-zoom-root");if(c)return c.classList.contains("is-ready")&&e(c,".gcx-next-zoom-hero-v2 img, .gcx-next-zoom-card-v2:nth-child(-n+2) img");var i=document.querySelector(".gcx-next-registration-v2-root");if(i)return i.classList.contains("is-ready")&&e(i,"img[loading='eager']");var a=document.querySelector(".gcx-next-lesson-page");if(a)return a.classList.contains("is-ready")&&e(a,".gcx-next-lesson-cover img");var g=document.querySelector(".gcx-next-root");return!!g&&e(g,"img[loading='eager']")}

  function disableLegacyMenuCss() {
    var links = document.querySelectorAll('link[rel~="stylesheet"][href]');
    Array.prototype.forEach.call(links, function (link) {
      var href;
      try {
        href = new URL(link.href, location.href);
      } catch (error) {
        return;
      }
      var publicLegacyMenu = /^\/pl\/layout\/39482\/[^/]+\/[^/]+\.css$/.test(href.pathname);
      var bundledLegacyMenu = href.pathname === "/pl/cms/layout/css" && href.searchParams.get("id") === "39482";
      if (!publicLegacyMenu && !bundledLegacyMenu) return;
      link.disabled = true;
      link.setAttribute("media", "not all");
      link.setAttribute("data-gcx-next-disabled-legacy-theme", "true");
    });
  }

  function installGlobalChromeStyles() {
    if (document.getElementById("gcx-next-global-chrome-style")) return;
    var style = document.createElement("style");
    style.id = "gcx-next-global-chrome-style";
    style.setAttribute("data-gcx-next-theme-asset", "true");
    style.textContent = [
      "@media(min-width:1024px){html.gcx-next-managed .gcx-next-account-menu{background:transparent!important;display:block!important;height:0!important;inset:0 auto auto 0!important;overflow:visible!important;padding:0!important;position:fixed!important;visibility:visible!important;width:0!important;z-index:9700!important}html.gcx-next-managed .gcx-account-menu__wrap{display:block!important;height:57px!important;left:29px!important;margin:0!important;position:fixed!important;top:29px!important;transform:none!important;visibility:visible!important;width:148px!important;z-index:9700!important}html.gcx-next-managed .gcx-account-menu__open{align-items:center!important;appearance:none!important;background:#8c103a!important;border:0!important;border-radius:12px!important;box-shadow:none!important;box-sizing:border-box!important;color:#fff!important;display:flex!important;font:400 18px/19.44px \"Geologica\",Arial,sans-serif!important;height:57px!important;justify-content:flex-start!important;margin:0!important;min-height:57px!important;padding:0 24px!important;text-transform:none!important;transform:none!important;width:148px!important}html.gcx-next-managed .gcx-account-menu__open:before{background:url(\"data:image/svg+xml;base64,PHN2ZyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIiBvdmVyZmxvdz0idmlzaWJsZSIgc3R5bGU9ImRpc3BsYXk6IGJsb2NrOyIgd2lkdGg9IjI0IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMjQgMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGlkPSJNZW51IGljb24iPgo8bGluZSBpZD0iTGluZSA0OSIgeTE9IjAuNSIgeDI9IjI0IiB5Mj0iMC41IiBzdHJva2U9IndoaXRlIi8+CjxsaW5lIGlkPSJMaW5lIDUwIiB5MT0iNy41IiB4Mj0iMjQiIHkyPSI3LjUiIHN0cm9rZT0id2hpdGUiLz4KPGxpbmUgaWQ9IkxpbmUgNTEiIHkxPSIxNS41IiB4Mj0iMjQiIHkyPSIxNS41IiBzdHJva2U9IndoaXRlIi8+CjwvZz4KPC9zdmc+Cg==\") center/24px 16px no-repeat!important;content:\"\"!important;display:block!important;flex:0 0 24px!important;height:16px!important;margin:0 21px 0 0!important;width:24px!important}html.gcx-next-managed .gcx-account-menu__open:after{display:none!important}html.gcx-next-managed .gcx-account-menu__panel{left:0!important;position:absolute!important;top:69px!important}}",
      "@media(min-width:1024px) and (max-width:1919px){html.gcx-next-managed .gcx-account-menu__wrap{height:clamp(43px,2.96875vw,57px)!important;left:clamp(18px,1.5104167vw,29px)!important;top:clamp(18px,1.5104167vw,29px)!important;width:clamp(112px,7.7083333vw,148px)!important}html.gcx-next-managed .gcx-account-menu__open{font-size:clamp(14px,.9375vw,18px)!important;height:clamp(43px,2.96875vw,57px)!important;min-height:clamp(43px,2.96875vw,57px)!important;padding:0 clamp(16px,1.25vw,24px)!important;width:clamp(112px,7.7083333vw,148px)!important}html.gcx-next-managed .gcx-account-menu__open:before{margin-right:clamp(11px,1.09375vw,21px)!important}html.gcx-next-managed .gcx-account-menu__panel{top:calc(clamp(43px,2.96875vw,57px) + 12px)!important}}",
      "@media(min-width:1024px){html.gcx-next-managed .gcx-account-menu__panel{display:none!important}html.gcx-next-managed .gcx-account-menu__panel.js-visible{display:block!important}}",
      "html.gcx-next-managed #gcAccountUserMenu .new-menu[data-gcx-account-native-source=true]{display:none!important;opacity:0!important;pointer-events:none!important;visibility:hidden!important}html.gcx-next-managed .gcx-account-menu__panel{background:#fff!important;border:1px solid #e8e8e8!important;border-radius:20px!important;box-shadow:0 18px 44px rgba(83,8,29,.16)!important;box-sizing:border-box!important;color:#0e0e0e!important;display:none!important;max-height:calc(100vh - 127px)!important;max-width:calc(100vw - 58px)!important;overscroll-behavior:contain!important;overflow:auto!important;padding:12px!important;width:360px!important;z-index:9701!important}html.gcx-next-managed .gcx-account-menu__panel.js-visible{display:block!important}html.gcx-next-managed .gcx-account-menu__group{display:block!important;margin:0!important;padding:0!important;position:static!important}html.gcx-next-managed .gcx-account-menu__group-button{align-items:center!important;appearance:none!important;background:transparent!important;border:0!important;border-radius:12px!important;box-sizing:border-box!important;color:#0e0e0e!important;cursor:pointer!important;display:flex!important;font:400 16px/1.25 \"Geologica\",Arial,sans-serif!important;min-height:48px!important;padding:10px 16px!important;text-align:left!important;text-transform:none!important;width:100%!important}html.gcx-next-managed .gcx-account-menu__group-button:hover,html.gcx-next-managed .gcx-account-menu__group-button:focus-visible{background:#f9edf1!important;color:#8c103a!important;outline:none!important}html.gcx-next-managed .gcx-account-menu__submenu{background:#fff!important;border-radius:19px!important;box-sizing:border-box!important;display:none!important;inset:0!important;min-height:100%!important;overflow:auto!important;padding:12px!important;position:absolute!important;z-index:2!important}html.gcx-next-managed .gcx-account-menu__submenu.js-visible{display:flex!important;flex-direction:column!important}html.gcx-next-managed .gcx-account-menu__back,html.gcx-next-managed .gcx-account-menu__link{align-items:center!important;border-radius:10px!important;box-sizing:border-box!important;color:#0e0e0e!important;display:flex!important;font:400 14px/1.35 \"Geologica\",Arial,sans-serif!important;min-height:40px!important;padding:9px 13px!important;text-decoration:none!important}html.gcx-next-managed .gcx-account-menu__back{appearance:none!important;background:transparent!important;border:0!important;color:#8c103a!important;cursor:pointer!important;font-weight:500!important;margin-bottom:4px!important;text-align:left!important;text-transform:none!important;width:100%!important}html.gcx-next-managed .gcx-account-menu__link:hover,html.gcx-next-managed .gcx-account-menu__link:focus-visible{background:#f9edf1!important;color:#8c103a!important;outline:none!important}",
      "html.gcx-next-admin-system-menu-open.gcx-next-managed .gcx-next-account-menu,html.gcx-next-admin-system-menu-open.gcx-next-managed .gcx-account-menu__wrap,html.gcx-next-admin-system-menu-open.gcx-next-managed .gcx-account-menu__open{display:none!important;opacity:0!important;pointer-events:none!important;visibility:hidden!important}@media(max-width:1023px){html.gcx-next-managed .gcx-next-account-menu,html.gcx-next-managed .gcx-account-menu__wrap{display:none!important;opacity:0!important;pointer-events:none!important;visibility:hidden!important}}",
      "html.gcx-next-managed .new-burger{display:none!important;height:0!important;margin:0!important;min-height:0!important;opacity:0!important;overflow:hidden!important;padding:0!important;pointer-events:none!important;visibility:hidden!important;width:0!important}",
      "html.gcx-next-isolation-active body #redesignedNoticeTopPanel,html.gcx-next-isolation-active.gcx-next-managed body #redesignedNoticeTopPanel{box-sizing:border-box!important;left:50%!important;margin:0!important;max-width:1156px!important;right:auto!important;transform:translateX(-50%)!important;width:calc(100vw - 48px)!important}html.gcx-next-isolation-active body #redesignedNoticeTopPanel>*,html.gcx-next-isolation-active.gcx-next-managed body #redesignedNoticeTopPanel>*{border-radius:14px!important;box-sizing:border-box!important;overflow:hidden!important}@media(max-width:600px){html.gcx-next-isolation-active body #redesignedNoticeTopPanel,html.gcx-next-isolation-active.gcx-next-managed body #redesignedNoticeTopPanel{width:calc(100vw - 24px)!important}}"
    ].join("")
      .replace(
        /html\.gcx-next-admin-system-menu-open\.gcx-next-managed/g,
        "html.gcx-next-admin-system-menu-open.gcx-next-account-menu-active"
      )
      .replace(/html\.gcx-next-managed/g, "html.gcx-next-account-menu-active");
    (document.head || document.documentElement).appendChild(style);
  }

  function accountMenuElement(tag, className, text) {
    var node = document.createElement(tag);
    if (className) node.className = className;
    if (text !== undefined) node.textContent = text;
    return node;
  }

  function accountMenuLink(className, text, href) {
    var node = accountMenuElement("a", className, text);
    node.href = href;
    return node;
  }

  function setAccountFallbackMenuOpen(menu, open) {
    var button = menu && menu.querySelector(".gcx-account-menu__open");
    var items = menu && menu.querySelector(".gcx-account-menu__panel");
    if (!button || !items) return;
    items.classList.toggle("js-visible", Boolean(open));
    button.setAttribute("aria-expanded", open ? "true" : "false");
    if (!open) {
      Array.prototype.forEach.call(items.querySelectorAll(".gcx-account-menu__submenu.js-visible"), function (submenu) {
        submenu.classList.remove("js-visible");
      });
    }
  }

  function bindAccountFallbackMenu(menu) {
    var button = menu.querySelector(".gcx-account-menu__open");
    var items = menu.querySelector(".gcx-account-menu__panel");
    if (!button || !items) return;
    button.setAttribute("aria-haspopup", "true");
    button.setAttribute("aria-expanded", "false");
    if (menu.__gcxAccountMenuButton !== button) {
      menu.__gcxAccountMenuButton = button;
      button.addEventListener("click", function (event) {
        var currentItems = menu.querySelector(".gcx-account-menu__panel");
        if (!currentItems) return;
        event.preventDefault();
        event.stopImmediatePropagation();
        event.stopPropagation();
        setAccountFallbackMenuOpen(menu, !currentItems.classList.contains("js-visible"));
      }, true);
    }
    if (menu.__gcxAccountMenuBound) return;
    menu.__gcxAccountMenuBound = true;
    menu.addEventListener("click", function (event) {
      var item = event.target.closest(".gcx-account-menu__group-button[data-menu]");
      var back = event.target.closest(".gcx-account-menu__back");
      if (item) {
        var name = item.getAttribute("data-menu");
        var submenu = menu.querySelector('.gcx-account-menu__submenu[data-menu="' + String(name || "") + '"]');
        if (submenu) {
          event.preventDefault();
          submenu.classList.add("js-visible");
        }
      } else if (back) {
        event.preventDefault();
        var current = back.closest(".gcx-account-menu__submenu");
        if (current) current.classList.remove("js-visible");
      }
    });
    document.addEventListener("click", function (event) {
      if (!menu.contains(event.target)) setAccountFallbackMenuOpen(menu, false);
    });
    document.addEventListener("keydown", function (event) {
      if (event.key === "Escape") setAccountFallbackMenuOpen(menu, false);
    });
  }

  function appendAccountFallbackMenuGroup(main, label, name, links) {
    var wrap = accountMenuElement("div", "gcx-account-menu__group");
    var item = accountMenuElement("button", "gcx-account-menu__group-button", label);
    var submenu = accountMenuElement("div", "gcx-account-menu__submenu");
    item.type = "button";
    item.setAttribute("data-menu", name);
    submenu.setAttribute("data-menu", name);
    var back = accountMenuElement("button", "gcx-account-menu__back", "\u2190 \u041d\u0430\u0437\u0430\u0434");
    back.type = "button";
    submenu.appendChild(back);
    links.forEach(function (entry) {
      var link;
      if (entry && entry.nodeType === 1) {
        link = entry.cloneNode(false);
        link.removeAttribute("id");
        link.removeAttribute("style");
        link.className = "gcx-account-menu__link";
        link.textContent = accountMenuSourceText(entry);
      } else {
        link = accountMenuLink("gcx-account-menu__link", entry[0], entry[1]);
      }
      if (link.textContent && link.getAttribute("href")) submenu.appendChild(link);
    });
    wrap.appendChild(item);
    wrap.appendChild(submenu);
    main.appendChild(wrap);
  }

  function accountMenuSourceText(node) {
    if (!node) return "";
    var clone = node.cloneNode(true);
    Array.prototype.forEach.call(clone.querySelectorAll('[class*="counter"],[class*="count"],.badge'), function (counter) {
      if (counter.parentNode) counter.parentNode.removeChild(counter);
    });
    return String(clone.textContent || "").replace(/\s+/g, " ").trim();
  }

  function buildAccountMenuFromNative(items, nativeMenu) {
    if (!items || !nativeMenu) return false;
    var groups = [];
    Array.prototype.forEach.call(nativeMenu.querySelectorAll(".new-menu__item-wrap"), function (wrap, index) {
      var item = null;
      Array.prototype.some.call(wrap.children || [], function (child) {
        if (child.classList && child.classList.contains("new-menu__item")) {
          item = child;
          return true;
        }
        return false;
      });
      var links = Array.prototype.filter.call(wrap.querySelectorAll(".new-menu__submenu a[href]"), function (link) {
        return Boolean(accountMenuSourceText(link) && link.getAttribute("href"));
      });
      var label = accountMenuSourceText(item);
      if (!label || !links.length) return;
      groups.push({ label: label, name: "native-" + index, links: links });
    });
    if (!groups.length) return false;
    var signature = groups.map(function (group) {
      return group.label + ":" + group.links.map(function (link) {
        return accountMenuSourceText(link) + "@" + String(link.getAttribute("href") || "");
      }).join("|");
    }).join("||");
    if (items.getAttribute("data-gcx-account-menu-signature") === signature) return true;
    var main = accountMenuElement("div", "");
    main.id = "gcx-next-account-main-menu";
    groups.forEach(function (group) {
      appendAccountFallbackMenuGroup(main, group.label, group.name, group.links);
    });
    items.textContent = "";
    items.appendChild(main);
    items.setAttribute("data-gcx-account-menu-ready", "true");
    items.setAttribute("data-gcx-account-menu-source", "native");
    items.setAttribute("data-gcx-account-menu-signature", signature);
    return true;
  }

  function buildAccountFallbackMenuItems(items) {
    var main = accountMenuElement("div", "");
    main.id = "gcx-next-account-main-menu";
    appendAccountFallbackMenuGroup(main, "\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435", "teach", [
      ["\u0422\u0440\u0435\u043d\u0438\u043d\u0433\u0438", "/teach/control/stream"],
      ["\u0427\u0430\u0442\u044b", "/c/my"],
      ["\u0420\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435", "/pl/teach/control/schedule"],
      ["\u041b\u0435\u043d\u0442\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432", "/teach/control/answers/my"],
      ["\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f", "/user/control/user/questionary"]
    ]);
    appendAccountFallbackMenuGroup(main, "\u0421\u043b\u0443\u0436\u0431\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438", "notifications", [
      ["\u041c\u043e\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f", "/pl/talks/conversation"]
    ]);
    appendAccountFallbackMenuGroup(main, "\u041f\u043e\u043a\u0443\u043f\u043a\u0438", "sales", [
      ["\u041c\u043e\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0438", "/sales/control/userProduct/my"]
    ]);
    items.textContent = "";
    items.appendChild(main);
    items.setAttribute("data-gcx-account-menu-ready", "true");
    items.setAttribute("data-gcx-account-menu-source", "fallback");
  }

  function hydrateAccountFallbackMenu(menu) {
    if (typeof window.fetch !== "function" || typeof window.DOMParser !== "function") return;
    var menuRoot = currentRoot();
    var menuSourcePath = menuRoot ? menuRoot.path : "/teach/control/stream";
    window.fetch(menuSourcePath, { credentials: "same-origin" }).then(function (response) {
      if (!response.ok) return "";
      var finalUrl = new window.URL(response.url, location.origin);
      if (finalUrl.origin !== location.origin || finalUrl.pathname !== menuSourcePath) return "";
      return response.text();
    }).then(function (html) {
      if (!html || !menu.isConnected) return;
      var parsed = new window.DOMParser().parseFromString(html, "text/html");
      var source = parsed.querySelector(".new-menu");
      var target = menu.querySelector(".gcx-account-menu__panel");
      if (!source || !target) return;
      buildAccountMenuFromNative(target, source);
    }).catch(function () {});
  }

  function ensureAccountMenu() {
    var nativeMenu = document.querySelector("#gcAccountUserMenu .new-menu");
    if (nativeMenu) {
      nativeMenu.classList.remove("gcx-next-account-menu");
      nativeMenu.setAttribute("data-gcx-account-native-source", "true");
      nativeMenu.setAttribute("aria-hidden", "true");
    }
    if (!document.body) return null;
    var existing = document.querySelector(".gcx-next-account-menu-fallback");
    if (!existing) {
      var host = accountMenuElement("div", "gcx-next-account-menu-host");
      existing = accountMenuElement("div", "gcx-next-account-menu gcx-next-account-menu-fallback");
      var menuWrap = accountMenuElement("div", "gcx-account-menu__wrap");
      var button = accountMenuElement("button", "gcx-account-menu__open", "\u041c\u0435\u043d\u044e");
      var menuItems = accountMenuElement("div", "gcx-account-menu__panel");
      button.type = "button";
      buildAccountFallbackMenuItems(menuItems);
      menuWrap.appendChild(button);
      menuWrap.appendChild(menuItems);
      existing.appendChild(menuWrap);
      host.appendChild(existing);
      document.body.insertBefore(host, document.body.firstChild);
      bindAccountFallbackMenu(existing);
      hydrateAccountFallbackMenu(existing);
    }
    var items = existing.querySelector(".gcx-account-menu__panel");
    if (nativeMenu && items) buildAccountMenuFromNative(items, nativeMenu);
    return existing;
  }

  function installAccountMenuRuntime() {
    if (window.__GCX_NEXT_ACCOUNT_MENU_RUNTIME__) return;
    window.__GCX_NEXT_ACCOUNT_MENU_RUNTIME__ = true;
    [0, 100, 500, 1500, 4000, 8000].forEach(function (delay) {
      window.setTimeout(ensureAccountMenu, delay);
    });
    if (document.readyState === "loading") {
      document.addEventListener("DOMContentLoaded", ensureAccountMenu, { once: true });
    } else {
      ensureAccountMenu();
    }
    window.addEventListener("load", ensureAccountMenu, { once: true });
    if (typeof window.MutationObserver === "function") {
      window.__GCX_NEXT_ACCOUNT_MENU_OBSERVER__ = new window.MutationObserver(ensureAccountMenu);
      window.__GCX_NEXT_ACCOUNT_MENU_OBSERVER__.observe(document.documentElement, {
        childList: true,
        subtree: true
      });
    }
  }

  function beginStyleIsolation() {
    if (window.__GCX_NEXT_STYLE_ISOLATION__) return;
    var records = [];
    var observer = null;
    var isolationStyle = document.getElementById("gcx-next-isolation-style");
    var createdIsolationStyle = false;

    if (!isolationStyle) {
      isolationStyle = document.createElement("style");
      isolationStyle.id = "gcx-next-isolation-style";
      isolationStyle.setAttribute("data-gcx-next-theme-asset", "true");
      isolationStyle.textContent = "html.gcx-next-isolation-active .gcx-next-root,html.gcx-next-isolation-active .gcx-next-module-root,html.gcx-next-isolation-active .gcx-next-faculties-root,html.gcx-next-isolation-active .gcx-next-niches-root,html.gcx-next-isolation-active .gcx-next-zoom-root,html.gcx-next-isolation-active .gcx-next-admin-toolbar,html.gcx-next-isolation-active .gcx-next-system-panel,html.gcx-next-isolation-active .gcx-next-preloader{box-sizing:border-box;color:#0e0e0e;font-family:\"Geologica\",Arial,sans-serif;isolation:isolate;min-width:0;text-size-adjust:100%;-webkit-text-size-adjust:100%}html.gcx-next-isolation-active .gcx-next-root,html.gcx-next-isolation-active .gcx-next-module-root,html.gcx-next-isolation-active .gcx-next-faculties-root,html.gcx-next-isolation-active .gcx-next-niches-root,html.gcx-next-isolation-active .gcx-next-zoom-root{contain:style;display:block}html.gcx-next-isolation-active.gcx-next-managed .new-burger{display:none !important;opacity:0 !important;pointer-events:none !important;visibility:hidden !important}html.gcx-next-isolation-active.gcx-next-managed #redesignedNoticeTopPanel{left:0 !important;max-width:none !important;right:0 !important;width:auto !important}html.gcx-next-isolation-active:is(.gcx-next-root,.gcx-next-module-root,.gcx-next-faculties-root,.gcx-next-niches-root,.gcx-next-zoom-root,.gcx-next-admin-toolbar,.gcx-next-system-panel,.gcx-next-preloader) *,html.gcx-next-isolation-active:is(.gcx-next-root,.gcx-next-module-root,.gcx-next-faculties-root,.gcx-next-niches-root,.gcx-next-zoom-root,.gcx-next-admin-toolbar,.gcx-next-system-panel,.gcx-next-preloader) *::before,html.gcx-next-isolation-active:is(.gcx-next-root,.gcx-next-module-root,.gcx-next-faculties-root,.gcx-next-niches-root,.gcx-next-zoom-root,.gcx-next-admin-toolbar,.gcx-next-system-panel,.gcx-next-preloader) *::after{box-sizing:border-box}html.gcx-next-isolation-active:is(.gcx-next-root,.gcx-next-module-root,.gcx-next-faculties-root,.gcx-next-niches-root,.gcx-next-zoom-root,.gcx-next-admin-toolbar,.gcx-next-system-panel,.gcx-next-preloader):is(button,input,select,textarea){font:inherit}html.gcx-next-isolation-active:is(.gcx-next-root,.gcx-next-module-root,.gcx-next-faculties-root,.gcx-next-niches-root,.gcx-next-zoom-root,.gcx-next-admin-toolbar,.gcx-next-system-panel,.gcx-next-preloader):is(img,svg,video,canvas){max-width:100%}@media (prefers-reduced-motion:reduce){html.gcx-next-isolation-active:is(.gcx-next-root,.gcx-next-module-root,.gcx-next-faculties-root,.gcx-next-niches-root,.gcx-next-zoom-root,.gcx-next-admin-toolbar,.gcx-next-system-panel,.gcx-next-preloader){scroll-behavior:auto}}";
      (document.head || document.documentElement).appendChild(isolationStyle);
      createdIsolationStyle = true;
    }

    function attribute(node, name) {
      return node && typeof node.getAttribute === "function" ? String(node.getAttribute(name) || "") : "";
    }

    function isLegacyLayoutStyle(node) {
      var tag = String(node && node.tagName || "").toLowerCase();
      if (attribute(node, "data-gcx-next-theme-asset") === "true") return false;
      if (tag === "link") {
        var href = attribute(node, "href").trim();
        if (/\/pl\/layout\/39482\/[^/?#]+\/[^?#]+\.css(?:[?#]|$)/i.test(href) ||
            (/\/pl\/cms\/layout\/css(?:[/?#]|$)/i.test(href) && /[?&](?:amp;)?id=39482(?:[&#]|$)/i.test(href))) {
          return false;
        }
        return /\/pl\/cms\/layout\/css(?:[/?#]|$)/i.test(href) || /\/pl\/layout\/[^/?#]+\/[^/?#]+\/[^?#]+\.css(?:[?#]|$)/i.test(href);
      }
      if (tag === "style") {
        return /@import[\s\S]{0,240}\/pl\/layout\/[^;]+\.css/i.test(String(node.textContent || ""));
      }
      return false;
    }

    function suppress(node) {
      if (!isLegacyLayoutStyle(node) || attribute(node, "data-gcx-next-legacy-suppressed") === "true") return;
      records.push({
        node: node,
        disabled: !!node.disabled,
        hadMedia: typeof node.hasAttribute === "function" && node.hasAttribute("media"),
        media: attribute(node, "media")
      });
      if (typeof node.setAttribute === "function") {
        node.setAttribute("data-gcx-next-legacy-suppressed", "true");
        node.setAttribute("media", "not all");
      }
      node.disabled = true;
    }

    function scan(node) {
      suppress(node);
      if (!node || typeof node.querySelectorAll !== "function") return;
      Array.prototype.forEach.call(node.querySelectorAll('link[rel~="stylesheet"][href], style'), suppress);
    }

    function restore() {
      if (observer) observer.disconnect();
      records.forEach(function (record) {
        var node = record.node;
        if (!node) return;
        node.disabled = record.disabled;
        if (typeof node.removeAttribute === "function") node.removeAttribute("data-gcx-next-legacy-suppressed");
        if (record.hadMedia && typeof node.setAttribute === "function") node.setAttribute("media", record.media);
        else if (typeof node.removeAttribute === "function") node.removeAttribute("media");
      });
      document.documentElement.classList.remove("gcx-next-isolation-active");
      if (createdIsolationStyle && isolationStyle && isolationStyle.parentNode) isolationStyle.parentNode.removeChild(isolationStyle);
      window.__GCX_NEXT_STYLE_ISOLATION__ = null;
    }

    scan(document);
    document.documentElement.classList.add("gcx-next-isolation-active");
    if (typeof window.MutationObserver === "function") {
      observer = new window.MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
          if (mutation.type === "attributes") scan(mutation.target);
          Array.prototype.forEach.call(mutation.addedNodes || [], scan);
        });
      });
      observer.observe(document.documentElement, {
        attributes: true,
        attributeFilter: ["href", "rel"],
        childList: true,
        subtree: true
      });
    }
    [0, 100, 400, 1000, 2500, 5000].forEach(function (delay) {
      window.setTimeout(function () { scan(document); }, delay);
    });
    if (document.readyState === "loading") {
      document.addEventListener("DOMContentLoaded", function () { scan(document); }, { once: true });
    }
    if (typeof window.addEventListener === "function") {
      window.addEventListener("load", function () { scan(document); }, { once: true });
    }
    window.__GCX_NEXT_STYLE_ISOLATION__ = { restore: restore, records: records };
  }

  function settleStyleIsolation() {
    if (managedRootExists()) {
      window.__GCX_NEXT_STYLE_ISOLATION_COMMITTED__ = true;
      return;
    }
    var isolation = window.__GCX_NEXT_STYLE_ISOLATION__;
    if (isolation && typeof isolation.restore === "function") isolation.restore();
  }

  function retryGate(attempt, needsScopeProof) {
    if (attempt >= maxGateAttempts || typeof window.setTimeout !== "function") return;
    var delay = attempt < 80 ? 0 : (needsScopeProof ? 16 : 25);
    window.setTimeout(function () { gate(attempt + 1); }, delay);
  }

  var PRELOADER_LOGO = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTAyLjAxIDQxMy4wOSI+CiAgPGRlZnM+CiAgICA8c3R5bGU+CiAgICAgIC5jbHMtMSB7CiAgICAgICAgZmlsbDogIzgwMWYzYjsKICAgICAgICBmaWxsLXJ1bGU6IGV2ZW5vZGQ7CiAgICAgIH0KICAgIDwvc3R5bGU+CiAgPC9kZWZzPgogIDxnIGlkPSJMYXllcl8xLTIiIGRhdGEtbmFtZT0iTGF5ZXIgMSI+CiAgICA8cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xMzEuMjksMzcxL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uNTIsMS45NSwzLjMsMS45NSwzLjgzLDBsLjYtMi4yNWMxMS4xOC00My4yOCw0NC45NC03Ny4wNCw4OC4yMS04OC4yMWwyLjI1LS42YzEuOTQtLjUyLDEuOTQtMy4zLDAtMy44M2wtMi4yNS0uNmMtNDMuMjgtMTEuMS03Ny4wNC00NC45My04OC4yMS04OC4yMWwtLjYtMi4yNVoiLz4KICA8L2c+Cjwvc3ZnPgo=";

  function chatiumRequest(){return/(?:^|[?&])__webview=1(?:&|$)/.test(location.search)||/\/teach\/control\/lesson\/webview(?:\/|$)/.test(path)||/\b(?:chatium_body|gc-chtm-webview)\b/.test(String(document.body?document.body.className:""))||/Chatium/i.test(String((window.navigator||{}).userAgent||""))}

  function showPreloader(){if("/wow-shop"!==path){var t=document.getElementById("gcx-next-preloader-pending-style");if(!document.body)return t||((t=document.createElement("style")).id="gcx-next-preloader-pending-style",t.setAttribute("data-gcx-next-theme-asset","true"),t.textContent="html.gcx-next-preloading body{opacity:0!important}",(document.head||document.documentElement).appendChild(t)),document.documentElement.classList.add("gcx-next-preloading"),void(window.__GCX_NEXT_PRELOADER_BODY_WAIT__||(window.__GCX_NEXT_PRELOADER_BODY_WAIT__=!0,document.addEventListener("DOMContentLoaded",function(){window.__GCX_NEXT_PRELOADER_BODY_WAIT__=!1,showPreloader()},{once:!0})));if(chatiumRequest()){if(window.__GCX_NEXT_CHATIUM_PRELOADER__)return window.__GCX_NEXT_HIDE_PRELOADER__=window.__GCX_NEXT_CHATIUM_PRELOADER__.finish||window.__GCX_NEXT_CHATIUM_PRELOADER__.hide,void window.__GCX_NEXT_CHATIUM_PRELOADER__.check();var e=document.head||document.documentElement;(p=document.getElementById("gcx-next-chatium-early-style"))||((p=document.createElement("style")).id="gcx-next-chatium-early-style",p.setAttribute("data-gcx-next-theme-asset","true"),p.textContent=["html.gcx-next-chatium-early,html.gcx-next-chatium-early body{background:#f7f5f5!important;min-height:100%!important;overflow:hidden!important}","html.gcx-next-chatium-early body>*{opacity:0!important;pointer-events:none!important;visibility:hidden!important}",'html.gcx-next-chatium-early body::before{background:radial-gradient(circle at 50% 44%,rgba(251,73,66,.09),transparent 34%),linear-gradient(145deg,#faf8f8,#f4f3f3)!important;content:""!important;display:block!important;height:100dvh!important;inset:0!important;opacity:1!important;pointer-events:auto!important;position:fixed!important;visibility:visible!important;width:100vw!important;z-index:999997!important}','html.gcx-next-chatium-early body::after{--gcx-logo:230px auto;--gcx-y:111px;background-image:url("'+PRELOADER_LOGO+'"),linear-gradient(90deg,rgba(140,16,58,.1),rgba(140,16,58,.1))!important;background-position:center top,center top var(--gcx-y)!important;background-repeat:no-repeat!important;background-size:var(--gcx-logo),156px 3px!important;color:#786f72!important;content:"Собираем ваш WOW-момент"!important;display:block!important;font:600 10px/1.3 Arial,sans-serif!important;left:50%!important;letter-spacing:.16em!important;padding-top:127px!important;position:fixed!important;text-align:center!important;text-transform:uppercase!important;top:50%!important;transform:translate(-50%,-50%)!important;width:320px!important;z-index:999998!important}','html.gcx-next-chatium-early::after{animation:gcx-next-chatium-progress 1.55s linear .1s infinite!important;background:linear-gradient(90deg,#8c103a,#fb4942)!important;border-radius:99px!important;content:""!important;display:block!important;height:3px!important;left:calc(50% - 78px)!important;pointer-events:none!important;position:fixed!important;top:calc(50% + 42px)!important;transform:scaleX(0);transform-origin:left center!important;width:156px!important;z-index:999999!important}',"@keyframes gcx-next-chatium-progress{0%{opacity:1;transform:scaleX(0)}70%{opacity:1;transform:scaleX(1)}82%{opacity:0;transform:scaleX(1)}83%,100%{opacity:0;transform:scaleX(0)}}","@media(max-width:430px){html.gcx-next-chatium-early body::after{--gcx-logo:205px auto;--gcx-y:102px;padding-top:118px!important;width:260px!important}html.gcx-next-chatium-early::after{top:calc(50% + 38px)!important}}"].join(""),e.insertBefore(p,e.firstChild||null),window.__GCX_NEXT_CHATIUM_PRELOADER_STARTED_AT__=Date.now()),document.documentElement.classList.add("gcx-next-chatium-early","gcx-next-preloading"),t&&t.parentNode&&t.parentNode.removeChild(t);var n=window.__GCX_NEXT_CHATIUM_PRELOADER_STARTED_AT__||Date.now(),i=null,o=!1,a=!1;function r(){o||(o=!0,i&&i.disconnect(),window.removeEventListener("gcx-next:rating-ready",c),window.removeEventListener("gcx-next:course-ready",c),window.removeEventListener("gcx-next:managed-ready",c),settleStyleIsolation(),document.documentElement.classList.remove("gcx-next-chatium-early","gcx-next-preloading"),p&&p.parentNode&&p.parentNode.removeChild(p),window.__GCX_NEXT_HIDE_PRELOADER__!==d&&window.__GCX_NEXT_HIDE_PRELOADER__!==r||(window.__GCX_NEXT_HIDE_PRELOADER__=null),window.__GCX_NEXT_CHATIUM_PRELOADER__=null,function(){window.__GCX_NEXT_PRELOADER_HIDDEN__=!0;try{window.dispatchEvent(new window.CustomEvent("gcx-next:preloader-hidden"))}catch(e){var t=document.createEvent("Event");t.initEvent("gcx-next:preloader-hidden",!1,!1),window.dispatchEvent(t)}}())}function d(){o||a||(a=!0,window.setTimeout(r,_(n)))}function c(){!o&&managedRootExists()&&(window.__GCX_NEXT_STYLE_ISOLATION_COMMITTED__=!0,d())}return"function"==typeof window.MutationObserver&&(i=new window.MutationObserver(c)).observe(document.documentElement,{childList:!0,subtree:!0}),window.addEventListener("gcx-next:rating-ready",c),window.addEventListener("gcx-next:course-ready",c),window.addEventListener("gcx-next:managed-ready",c),window.__GCX_NEXT_CHATIUM_PRELOADER__={hide:r,check:c,finish:d},window.__GCX_NEXT_HIDE_PRELOADER__=d,c(),void window.setTimeout(r,8e3)}if(!document.getElementById("gcx-next-preloader")){var m=document.body||document.documentElement;if(e=document.head||document.documentElement,m&&e){var p;(p=document.createElement("style")).id="gcx-next-preloader-style",p.setAttribute("data-gcx-next-theme-asset","true"),p.textContent=["html.gcx-next-preloading,html.gcx-next-preloading body{overflow:hidden!important}","html.gcx-next-preloading body>*:not(#gcx-next-preloader){visibility:hidden!important}",".gcx-next-preloader{align-items:center!important;background:radial-gradient(circle at 50% 44%,rgba(251,73,66,.09),transparent 34%),linear-gradient(145deg,#faf8f8,#f4f3f3)!important;contain:strict!important;display:flex!important;height:100dvh!important;inset:0!important;justify-content:center!important;margin:0!important;max-height:none!important;max-width:none!important;opacity:1!important;overscroll-behavior:contain!important;padding:0!important;position:fixed!important;touch-action:none!important;transition:opacity .24s ease-in,visibility .24s ease-in!important;visibility:visible!important;width:100vw!important;z-index:999999!important}",".gcx-next-preloader.is-leaving{opacity:0;visibility:hidden}",".gcx-next-preloader__scene{align-items:center;display:flex;flex-direction:column;max-width:calc(100vw - 48px);width:320px}",".gcx-next-preloader__logo{animation:gcx-next-loader-in .56s cubic-bezier(.16,1,.3,1) forwards;display:block;height:auto;opacity:0;transform:translateY(10px);width:230px}",".gcx-next-preloader__track{background:rgba(140,16,58,.1);border-radius:99px;height:3px;margin-top:28px;overflow:hidden;width:156px}",".gcx-next-preloader__track i{animation:gcx-next-loader-progress 1.55s linear .1s infinite;background:linear-gradient(90deg,#8c103a,#fb4942);border-radius:inherit;display:block;height:100%;transform:scaleX(0);transform-origin:left center;width:100%}",".gcx-next-preloader__caption{color:#786f72;font-family:Arial,sans-serif;font-size:10px;font-weight:600;letter-spacing:.16em;margin-top:13px;text-transform:uppercase}","@keyframes gcx-next-loader-in{to{opacity:1;transform:none}}","@keyframes gcx-next-loader-progress{0%{opacity:1;transform:scaleX(0)}70%{opacity:1;transform:scaleX(1)}82%{opacity:0;transform:scaleX(1)}83%,100%{opacity:0;transform:scaleX(0)}}","@media(max-width:430px){.gcx-next-preloader__scene{width:260px}.gcx-next-preloader__logo{width:205px}}","@media(prefers-reduced-motion:reduce){.gcx-next-preloader,.gcx-next-preloader *{animation:none!important;transition:none!important}.gcx-next-preloader__logo{opacity:1;transform:none}.gcx-next-preloader__track i{transform:scaleX(.72)}}"].join("");var l=document.createElement("div");l.id="gcx-next-preloader",l.className="gcx-next-preloader",l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),l.setAttribute("aria-label","Загрузка нового интерфейса"),l.innerHTML='<div class="gcx-next-preloader__scene"><img class="gcx-next-preloader__logo" src="'+PRELOADER_LOGO+'" alt="WOW Маркетинг"><span class="gcx-next-preloader__track" aria-hidden="true"><i></i></span><span class="gcx-next-preloader__caption">Собираем ваш WOW-момент</span></div>',document.documentElement.classList.add("gcx-next-preloading"),e.appendChild(p),m.appendChild(l),t&&t.parentNode&&t.parentNode.removeChild(t);var s=Date.now();i=null,o=!1,a=!1,"function"==typeof window.MutationObserver&&(i=new window.MutationObserver(g)).observe(document.documentElement,{childList:!0,subtree:!0}),window.addEventListener("gcx-next:rating-ready",g),window.addEventListener("gcx-next:course-ready",g),window.addEventListener("gcx-next:managed-ready",g),window.__GCX_NEXT_HIDE_PRELOADER__=d,g(),window.setTimeout(x,8e3)}}}function _(t){var e=Math.max(0,Date.now()-t);if(e<1387)return 1387-e;var n=(e-100)%1550;return n>=1287?0:1287-n}function x(){o||(o=!0,i&&i.disconnect(),window.removeEventListener("gcx-next:rating-ready",g),window.removeEventListener("gcx-next:course-ready",g),window.removeEventListener("gcx-next:managed-ready",g),settleStyleIsolation(),l.classList.add("is-leaving"),window.setTimeout(function(){document.documentElement.classList.remove("gcx-next-preloading"),l.parentNode&&l.parentNode.removeChild(l),p.parentNode&&p.parentNode.removeChild(p),window.__GCX_NEXT_HIDE_PRELOADER__!==d&&window.__GCX_NEXT_HIDE_PRELOADER__!==x||(window.__GCX_NEXT_HIDE_PRELOADER__=null),window.__GCX_NEXT_PRELOADER_HIDDEN__=!0;try{window.dispatchEvent(new window.CustomEvent("gcx-next:preloader-hidden"))}catch(e){var t=document.createEvent("Event");t.initEvent("gcx-next:preloader-hidden",!1,!1),window.dispatchEvent(t)}},220))}function d(){o||a||(a=!0,window.setTimeout(x,_(s)))}function g(){managedRootExists()&&(window.__GCX_NEXT_STYLE_ISOLATION_COMMITTED__=!0,d())}}

  function gate(attempt) {
    var rawId = nativeAccountUserId();
    if (!rawId) {
      if (routeAllowed()) retryGate(attempt, false);
      return;
    }
    var id = String(rawId);
    if (!(/^[1-9][0-9]*$/.test(id)) || !routeAllowed()) return;
    window.__GCX_NEXT_ALLOWED_USER_ID__ = id;
    if (isRootPath(path) && !window.__GCX_NEXT_ZOOM_STREAM__) window.__GCX_NEXT_ZOOM_STREAM__ = resolveRootZoom();
    if ((nestedStreamPath() || lessonPath()) && !pageBelongsToRoot()) {
      retryGate(attempt, true);
      return;
    }
    guardLegacyAccountChrome(attempt);
    if (window.__GCX_NEXT_ENTRY_LOADER_STARTED__) return;
    window.__GCX_NEXT_ENTRY_LOADER_STARTED__ = true;
    if (!editorMode()) disableLegacyMenuCss();
    if (path !== "/wow-shop" && !editorMode()) beginStyleIsolation();
    if (!editorMode()) {
      installGlobalChromeStyles();
      installAccountMenuRuntime();
    }
    window.__GCX_NEXT_SHOW_PRELOADER__ = showPreloader;
    showPreloader();

    // Тренинг страницы → его бандл. Общие страницы → бандл первого тренинга.
    var activeRoot = currentRoot() || ROOTS[0];
    window.__GCX_NEXT_ACTIVE_ROOT__ = activeRoot.path;

    var script = document.createElement("script");
    script.src = activeRoot.bundle;
    script.async = true;
    script.onerror = function () {
      if (typeof window.__GCX_NEXT_HIDE_PRELOADER__ === "function") window.__GCX_NEXT_HIDE_PRELOADER__();
    };
    (document.head || document.documentElement).appendChild(script);
  }

  guardLegacyAccountChrome(0);
  gate(0);
})(window, document, location);