{"version":3,"file":"tabs.js","names":[],"sources":["../resources/javascript/tabs.js"],"sourcesContent":["/**\n * Script for handling tab functionality with accessibility in mind.\n * Utilizes ARIA attributes to enhance accessibility.\n */\n\ndocument.addEventListener('DOMContentLoaded', () => {\n    /**\n     * Selects the tab selector element, tab buttons, and tab content areas.\n     */\n    const tabSelect = document.querySelector('[data-tab-select]');\n    const tabButtons = document.querySelectorAll('[data-tab-button]');\n    const tabContents = document.querySelectorAll('[data-tab-content]');\n\n    /**\n     * Handles the visibility of tab contents based on the selected tab.\n     * @param {string} value - The identifier of the currently active tab content.\n     */\n    const handleEvent = value => {\n        for (const content of tabContents) {\n            // Toggle the 'hidden' attribute based on whether the content's identifier matches the passed in value\n            content.toggleAttribute(\n                'hidden',\n                value !== content.dataset.tabContent\n            );\n        }\n    };\n\n    /**\n     * Adds click event listeners to each tab button.\n     */\n    for (const button of tabButtons) {\n        button.addEventListener('click', event => {\n            const currentButton = event.currentTarget;\n            const tabId = currentButton.dataset.tabButton;\n\n            // Iterate over all buttons to set the 'aria-expanded' attribute\n            for (const btn of tabButtons) {\n                btn.setAttribute(\n                    'aria-expanded',\n                    btn === currentButton ? 'true' : 'false'\n                );\n            }\n\n            // Handle the display of the tab content associated with the clicked button\n            handleEvent(tabId);\n\n            currentButton.closest('.product-tabs')?.scrollIntoView({\n                behavior: 'smooth',\n                block: 'start',\n            });\n        });\n    }\n\n    /**\n     * Adds change event listener to the tab select element.\n     */\n    tabSelect?.addEventListener('change', event => {\n        handleEvent(event.currentTarget.value);\n    });\n});\n"],"mappings":"AAKA,SAAS,iBAAiB,uBAA0B,CAIhD,IAAM,EAAY,SAAS,cAAc,mBAAmB,EACtD,EAAa,SAAS,iBAAiB,mBAAmB,EAC1D,EAAc,SAAS,iBAAiB,oBAAoB,EAM5D,EAAc,GAAS,CACzB,IAAK,IAAM,KAAW,EAElB,EAAQ,gBACJ,SACA,IAAU,EAAQ,QAAQ,UAC9B,CAER,EAKA,IAAK,IAAM,KAAU,EACjB,EAAO,iBAAiB,QAAS,GAAS,CAAA,IAAA,EACtC,IAAM,EAAgB,EAAM,cACtB,EAAQ,EAAc,QAAQ,UAGpC,IAAK,IAAM,KAAO,EACd,EAAI,aACA,gBACA,IAAQ,EAAgB,OAAS,OACrC,EAIJ,EAAY,CAAK,GAEjB,EAAA,EAAc,QAAQ,eAAe,IAAC,MAAtC,EAAwC,eAAe,CACnD,SAAU,SACV,MAAO,OACX,CAAC,CACL,CAAC,EAML,GAAW,iBAAiB,SAAU,GAAS,CAC3C,EAAY,EAAM,cAAc,KAAK,CACzC,CAAC,CACL,CAAC"}