document.addEventListener("DOMContentLoaded", function () {
const accordions = document.querySelectorAll<HTMLElement>(".accordion");
const multipleCheckbox = document.getElementById(
"multiselect",
) as HTMLInputElement;
accordions.forEach(function (accordion) {
const expandIcon = accordion.querySelector<HTMLElement>(".expand-icon");
const collapseIcon = accordion.querySelector<HTMLElement>(".collapse-icon");
const description = accordion.querySelector<HTMLElement>(".description");
const titleSection = accordion.querySelector<HTMLElement>(".title-section");
if (!expandIcon || !collapseIcon || !description || !titleSection) return;
description.style.display = "none";
collapseIcon.style.display = "none";
if (accordion === accordions[0]) {
description.style.display = "block";
expandIcon.style.display = "none";
collapseIcon.style.display = "inline-block";
}
function toggleAccordion() {
const isExpanded = description.style.display === "block";
if (!multipleCheckbox.checked) {
accordions.forEach(function (otherAccordion) {
if (otherAccordion !== accordion) {
const otherDescription =
otherAccordion.querySelector<HTMLElement>(".description");
const otherExpandIcon =
otherAccordion.querySelector<HTMLElement>(".expand-icon");
const otherCollapseIcon =
otherAccordion.querySelector<HTMLElement>(".collapse-icon");
if (otherDescription && otherExpandIcon && otherCollapseIcon) {
otherDescription.style.display = "none";
otherExpandIcon.style.display = "inline-block";
otherCollapseIcon.style.display = "none";
}
}
});
}
description.style.display = isExpanded ? "none" : "block";
expandIcon.style.display = isExpanded ? "inline-block" : "none";
collapseIcon.style.display = isExpanded ? "none" : "inline-block";
}
expandIcon.addEventListener("click", toggleAccordion);
collapseIcon.addEventListener("click", toggleAccordion);
titleSection.addEventListener("click", toggleAccordion);
});
});