"use strict";

// Import dependencies
import("/js/core.js").then(() =>
	import("/js/damper.js").then(() => {
		const dependencies = setInterval(() => {
			if (
				typeof core === "function" &&
				typeof core.damper === "function"
			) {
				clearInterval(dependencies);
				clearTimeout(timeout);
				initialization();
			}
		}, 10);
		const timeout = setTimeout(() => {
			clearInterval(dependencies);
			initialization();
		}, 5000);

		function initialization() {
			if (typeof core.telegram === "undefined") {
				// Not initialized

				// Write to the core
				core.telegram = class telegram {
					/**
					 * Telegram WebApp API
					 *
					 * @see {@link https://core.telegram.org/bots/webapps#initializing-mini-apps}
					 */
					static api = window.Telegram.WebApp;
				};

				/* telegram.MainButton.text =
			typeof core === "object" && core.language === "ru"
				? "Корзина"
				: "Cart";
			telegram.MainButton.show(); */
			}
		}
	})
);
