(function() { function initialize() { window.CIT_CONFIG = {"accessToken":null,"channelId":"Direct","chatDomain":"https://chat.mos.ru","sessionData":null,"counters":{"ya":["32628510"]},"locale":"ru-RU"}; const bootstrap = (async function() { function getCookie(name) { const matches = document.cookie.match( new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + "=([^;]*)"), ); return matches ? decodeURIComponent(matches[1]) : undefined; } function getClientId() { if (window.CIT_CONFIG?.counters?.ya?.length == 0) return undefined; const firstCounterId = window.CIT_CONFIG.counters.ya[0]; const counter = window["yaCounter" + firstCounterId]; if (!counter) return undefined; return counter.getClientID(); } function getElkPersonId() { return new Promise((resolve, reject) => { if (!window?.ELK) { reject("CIT_ERROR: No ELK available."); } window.ELK.ready(() => { window.ELK.loadUserProfileData({ blocks: ["PERSON"], done: function (data) { resolve(data.PERSON?.ITEM_ID); }, fail: function (err) { reject(err); }, }); }); }); } const additionalData = { mosId: getCookie("mos_id"), clientId: getClientId(), elkPersonId: await getElkPersonId(), }; window.CIT_CONFIG.sessionData = { ...window.CIT_CONFIG?.sessionData, ...additionalData }; if (additionalData.elkPersonId) { window.CIT_CONFIG.accessToken = additionalData.elkPersonId; } }); bootstrap(); const mainLoader = document.createElement("link"); mainLoader.setAttribute("href", "https://chat.mos.ru/client/scripts/cit.spec.https.chat.mos.ru.main.a693e64795b856a01137.js"); mainLoader.setAttribute("rel", "preload"); mainLoader.setAttribute("as", "script"); document.head.appendChild(mainLoader); const polyfillsLoader = document.createElement("link"); polyfillsLoader.setAttribute("href", "https://chat.mos.ru/client/scripts/polyfills.ffe92bf324674dd7b38b.js"); polyfillsLoader.setAttribute("rel", "preload"); polyfillsLoader.setAttribute("as", "script"); document.head.appendChild(polyfillsLoader); const runtimeLoader = document.createElement("link"); runtimeLoader.setAttribute("href", "https://chat.mos.ru/client/scripts/runtime.7848d5d8467f5c23046f.js"); runtimeLoader.setAttribute("rel", "preload"); runtimeLoader.setAttribute("as", "script"); document.head.appendChild(runtimeLoader); const stylesLoader = document.createElement("link"); stylesLoader.setAttribute("href", "https://chat.mos.ru/client/scripts/styles.8ade617b387abb3aea26.css"); stylesLoader.setAttribute("rel", "preload"); stylesLoader.setAttribute("as", "style"); document.head.appendChild(stylesLoader); const styles = document.createElement("link"); styles.setAttribute("href", "https://chat.mos.ru/client/scripts/styles.8ade617b387abb3aea26.css"); styles.setAttribute("rel", "stylesheet"); document.head.appendChild(styles); const appRoot = document.createElement("cit-chat-widget"); document.body.appendChild(appRoot); const main = document.createElement("script"); main.setAttribute("src", "https://chat.mos.ru/client/scripts/cit.spec.https.chat.mos.ru.main.a693e64795b856a01137.js"); main.setAttribute("defer", "defer"); document.body.appendChild(main); const polyfills = document.createElement("script"); polyfills.setAttribute("src", "https://chat.mos.ru/client/scripts/polyfills.ffe92bf324674dd7b38b.js"); polyfills.setAttribute("defer", "defer"); document.body.appendChild(polyfills); const runtime = document.createElement("script"); runtime.setAttribute("src", "https://chat.mos.ru/client/scripts/runtime.7848d5d8467f5c23046f.js"); runtime.setAttribute("defer", "defer"); document.body.appendChild(runtime); }; if (document.readyState == "interactive" || document.readyState == "complete") { initialize(); } else { window.addEventListener("load", initialize); } } )();