{"version":3,"file":"sidebar-overlay.js","sources":["../../../../../Flow.Showcase.Static.Bundler/Root/modules/sidebar-overlay.module.ts","../../../../../Flow.Showcase.Static.Bundler/Root/entrypoints/sidebar-overlay.ts"],"sourcesContent":["// @ts-nocheck\n\n/** @type {WeakMap} */\nconst sidebarOverlayMap = new WeakMap();\n\n/**\n *\n * @param {HTMLElement} element\n * @returns {SidebarOverlay | undefined}\n */\nexport function getSidebarOverlayFromElement(element) {\n return sidebarOverlayMap.get(element);\n}\n\n// Продолжительность движения сайдбара в секундах при открытии/закрытии\nconst sidebarTransformTransitionDuration = 0.3;\n\nexport class SidebarOverlay {\n\n /**\n *\n * @param {HTMLElement} element\n */\n constructor(element) {\n sidebarOverlayMap.set(element, this);\n\n /** @type {HTMLElement} */\n this.element = element;\n this.element.style.setProperty(\"--transform-transition-duration\", `${sidebarTransformTransitionDuration}s`);\n\n /** @type {boolean} */\n this.isOpen = false;\n\n /** @type {number | undefined} */\n this.visibilityTimeoutId = undefined;\n\n // Закрытие сайдбара при клике на элемент с атрибутом data-sidebar-overlay-close\n element.querySelectorAll(\"[data-sidebar-overlay-close]\").forEach(closeEl => {\n if (closeEl instanceof HTMLElement) {\n closeEl.addEventListener(\"click\", () => this.close());\n }\n })\n\n /**\n * Задник для сайдбара\n * @type {HTMLElement}\n */\n this.backdrop = document.createElement(\"div\");\n this.backdrop.setAttribute(\"data-sidebar-overlay-backdrop\", \"\");\n // Закрытие сайдбара при клике на задник\n this.backdrop.addEventListener(\"click\", () => this.close());\n this.element.after(this.backdrop);\n }\n\n open() {\n if (this.isOpen) {\n return;\n }\n clearTimeout(this.visibilityTimeoutId);\n this.isOpen = true;\n this.element.dataset.visibility = \"visible\";\n this.element.dataset.open = this.isOpen.toString();\n this.backdrop.dataset.visibility = \"visible\";\n }\n\n close() {\n if (!this.isOpen) {\n return;\n }\n this.isOpen = false;\n this.visibilityTimeoutId = setTimeout(() => {\n this.element.dataset.visibility = \"hidden\";\n }, sidebarTransformTransitionDuration * 1000);\n this.element.dataset.open = this.isOpen.toString();\n this.backdrop.dataset.visibility = \"hidden\";\n }\n}\n","// @ts-nocheck\n\nimport {\n getSidebarOverlayFromElement,\n SidebarOverlay,\n} from \"../modules/sidebar-overlay.module.ts\";\n\n// Инициализация элементов sidebar-overlay\ndocument\n .querySelectorAll(\"[data-sidebar-overlay]\")\n .forEach(\n (element) => new SidebarOverlay(/** @type {HTMLElement} */ (element))\n );\n\n// Открытие сайдбара при клике на элемент с атрибутом data-sidebar-overlay-open\ndocument.querySelectorAll(\"[data-sidebar-overlay-open]\").forEach((openEl) => {\n if (!(openEl instanceof HTMLElement)) {\n return;\n }\n openEl.addEventListener(\"click\", () => {\n const sidebarId = openEl.dataset.sidebarOverlayId;\n if (sidebarId === undefined) {\n return;\n }\n const sidebarElement = document.querySelector(`#${sidebarId}`);\n if (!(sidebarElement instanceof HTMLElement)) {\n return;\n }\n const sidebar = getSidebarOverlayFromElement(sidebarElement);\n if (sidebar !== undefined) {\n sidebar.open();\n }\n });\n});\n"],"names":["sidebarOverlayMap","getSidebarOverlayFromElement","element","sidebarTransformTransitionDuration","SidebarOverlay","closeEl","openEl","sidebarId","sidebarElement","sidebar"],"mappings":"AAGA,MAAMA,MAAwB,QAOvB,SAASC,EAA6BC,EAAS,CAC3C,OAAAF,EAAkB,IAAIE,CAAO,CACxC,CAGA,MAAMC,EAAqC,GAEpC,MAAMC,CAAe,CAMxB,YAAYF,EAAS,CACCF,EAAA,IAAIE,EAAS,IAAI,EAGnC,KAAK,QAAUA,EACf,KAAK,QAAQ,MAAM,YAAY,kCAAmC,GAAGC,CAAkC,GAAG,EAG1G,KAAK,OAAS,GAGd,KAAK,oBAAsB,OAG3BD,EAAQ,iBAAiB,8BAA8B,EAAE,QAAmBG,GAAA,CACpEA,aAAmB,aACnBA,EAAQ,iBAAiB,QAAS,IAAM,KAAK,OAAO,CACxD,CACH,EAMI,KAAA,SAAW,SAAS,cAAc,KAAK,EACvC,KAAA,SAAS,aAAa,g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