{"version":3,"file":"Panels-dDOoi4iS.js","sources":["../../ClientApp/src/js/components/Panels.ts"],"sourcesContent":["const Panels = (panelContainerId: string, callback?: () => void) => {\r\n const panelContainer = document.getElementById(panelContainerId);\r\n\r\n if (!panelContainer) {\r\n console.warn(`Panel container with id \"${panelContainerId}\" not found.`);\r\n return;\r\n }\r\n\r\n // Function to deactivate all panels\r\n const deactivateAllPanels = () => {\r\n const allPanels =\r\n panelContainer.querySelectorAll('[data-panelid]');\r\n allPanels.forEach(panel => {\r\n panel.classList.remove('active'); // Remove the active class to hide all panels\r\n });\r\n };\r\n\r\n // Function to deactivate all buttons\r\n const deactivateAllButtons = () => {\r\n const allButtons =\r\n panelContainer.querySelectorAll('.js-btn-tab-nav');\r\n allButtons.forEach(button => {\r\n button.classList.remove('active'); // Remove the active class from all buttons\r\n });\r\n };\r\n\r\n // Function to toggle the panel visibility with optional callback\r\n const togglePanel = (panelId: string) => {\r\n const panel = panelContainer.querySelector(`[data-panelid=\"${panelId}\"]`);\r\n\r\n if (!panel) {\r\n return; // Exit if the panel with the given ID doesn't exist\r\n }\r\n\r\n deactivateAllPanels(); // Deactivate all panels before activating the selected one\r\n panel.classList.add('active'); // Add the active class to the selected panel\r\n\r\n // Call the callback function if provided\r\n if (callback) {\r\n callback();\r\n }\r\n };\r\n\r\n // Event handler for panel buttons\r\n const handlePanelClick = (event: Event) => {\r\n event.preventDefault();\r\n const panelBtn = event.target as HTMLButtonElement;\r\n\r\n if (panelBtn.classList.contains('active')) {\r\n return; // Exit if the clicked button is already active\r\n }\r\n\r\n const panelId = panelBtn.dataset.target;\r\n\r\n if (panelId) {\r\n deactivateAllButtons(); // Remove the active class from all buttons\r\n panelBtn.classList.add('active'); // Add the active class to the clicked button\r\n togglePanel(panelId); // Toggle the panel associated with the clicked button\r\n }\r\n };\r\n\r\n // Initialize by adding event listeners to all buttons with the class 'js-btn-tab-nav'\r\n const initPanels = () => {\r\n const panelBtns =\r\n panelContainer.querySelectorAll('.js-btn-tab-nav');\r\n panelBtns.forEach(panelBtn => {\r\n panelBtn.addEventListener('click', handlePanelClick);\r\n });\r\n };\r\n\r\n initPanels();\r\n};\r\n\r\nexport default Panels;\r\n"],"names":["Panels","panelContainerId","callback","panelContainer","deactivateAllPanels","panel","deactivateAllButtons","button","togglePanel","panelId","handlePanelClick","event","panelBtn"],"mappings":"AAAM,MAAAA,EAAS,CAACC,EAA0BC,IAA0B,CAC1D,MAAAC,EAAiB,SAAS,eAAeF,CAAgB,EAE/D,GAAI,CAACE,EAAgB,CACT,QAAA,KAAK,4BAA4BF,CAAgB,cAAc,EACvE,MACJ,CAGA,MAAMG,EAAsB,IAAM,CAE1BD,EAAe,iBAA8B,gBAAgB,EACvD,QAAiBE,GAAA,CACjBA,EAAA,UAAU,OAAO,QAAQ,CAAA,CAClC,CAAA,EAICC,EAAuB,IAAM,CAE3BH,EAAe,iBAAoC,iBAAiB,EAC7D,QAAkBI,GAAA,CAClBA,EAAA,UAAU,OAAO,QAAQ,CAAA,CACnC,CAAA,EAICC,EAAeC,GAAoB,CACrC,MAAMJ,EAAQF,EAAe,cAAc,kBAAkBM,CAAO,IAAI,EAEnEJ,IAIeD,IACdC,EAAA,UAAU,IAAI,QAAQ,EAGxBH,GACSA,IACb,EAIEQ,EAAoBC,GAAiB,CACvCA,EAAM,eAAe,EACrB,MAAMC,EAAWD,EAAM,OAEvB,GAAIC,EAAS,UAAU,SAAS,QAAQ,EACpC,OAGE,MAAAH,EAAUG,EAAS,QAAQ,OAE7BH,IACqBH,IACZM,EAAA,UAAU,IAAI,QAAQ,EAC/BJ,EAAYC,CAAO,EACvB,GAIe,IAAM,CAEjBN,EAAe,iBAAoC,iBAAiB,EAC9D,QAAoBS,GAAA,CACjBA,EAAA,iBAAiB,QAASF,CAAgB,CAAA,CACtD,CAAA,IAIT"}