{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/scripts/toggle.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ClassNames","Selectors","Keys","forceReflow","el","offsetHeight","detectTransitionEnd","style","getComputedStyle","duration","transitionDuration","delay","transitionDelay","msDuration","parseFloat","split","isNaN","getTransitionDuration","Promise","resolve","addEventListener","handleTransitionEnd","e","target","removeEventListener","Accordion","root","options","config","this","_getConfig","_elements","_config","_state","activeIndex","isTransitioning","update","_handleClick","_handleKeyDown","attachEvents","accordions","document","querySelectorAll","forEach","hasAttribute","getAttribute","dataset","allowToggle","allowMultiple","trigger","triggers","panel","panels","setAttribute","currentHeight","getBoundingClientRect","height","then","classList","remove","add","targetHeight","closest","groupIndex","indexOf","togglePanel","keyCode","currentIndex","preventDefault","stopPropagation","nextIndex","groupCount","length","toggleCount","focus","slice","Error","isExpanded","isDisabled","_collapsePanel","_expandPanel","all","initAll","observer","MutationObserver","mutationsList","len","type","childList","subtree","getElementById","observe","querySelector"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,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":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","/**\r\n * Implementation of the accordion widget.\r\n * @see {@link https://www.w3.org/TR/wai-aria-practices/#accordion}\r\n */\r\n\r\nconst ClassNames = {\r\n PANEL_EXPANDED: \"toggle__panel--expanded\",\r\n}\r\n\r\nconst Selectors = {\r\n ROOT: \".toggle\",\r\n TRIGGER: \".toggle__trigger\",\r\n PANEL: \".toggle__panel\",\r\n}\r\n\r\nconst Keys = {\r\n ENTER: 13,\r\n SPACE: 32,\r\n END: 35,\r\n HOME: 36,\r\n UP: 38,\r\n DOWN: 40,\r\n}\r\n\r\n/**\r\n * Force a reflow\r\n * @param {HTMLElement} el The element whose styles have been changed\r\n */\r\nfunction forceReflow(el) {\r\n void el.offsetHeight\r\n}\r\n\r\n/**\r\n * Get transition duration for the specified element\r\n * @param {HTMLElement} el The element to compute transition duration on\r\n */\r\nfunction getTransitionDuration(el) {\r\n const style = getComputedStyle(el)\r\n\r\n const duration = style.transitionDuration || \"\"\r\n const delay = style.transitionDelay || \"\"\r\n\r\n if (!duration && !delay) {\r\n return 0\r\n }\r\n\r\n const floatDuration = parseFloat(duration.split(\",\"))\r\n const floatDelay = parseFloat(delay.split(\",\"))\r\n\r\n const msDuration = (floatDuration + floatDelay) * 1000\r\n return isNaN(msDuration) ? 0 : msDuration\r\n}\r\n\r\n/**\r\n * Detect the end of CSS transition.\r\n * @param {HTMLElement} el The element to detect transition end on\r\n */\r\nfunction detectTransitionEnd(el) {\r\n const duration = getTransitionDuration(el)\r\n\r\n if (duration == 0) {\r\n return Promise.resolve()\r\n }\r\n\r\n return new Promise(function(resolve) {\r\n function handleTransitionEnd(e) {\r\n if (e.target === el) {\r\n el.removeEventListener(\"transitionend\", handleTransitionEnd, false)\r\n resolve()\r\n }\r\n }\r\n\r\n el.addEventListener(\"transitionend\", handleTransitionEnd, false)\r\n })\r\n}\r\n\r\n/**\r\n * Accordion implementation\r\n */\r\nclass Accordion {\r\n /**\r\n * Create an Accordion\r\n * @param {HTMLElement} root The root node\r\n * @param {Object} options The options object\r\n * @param {boolean} options.allowToggle Allow for each header to both open and\r\n * close its panel. Makes it possible for all panels to be closed. Assumes\r\n * only one panel may be open.\r\n * @param {boolean} options.allowMultiple Allow for multiple accordion panels\r\n * to be expanded at the same time. Assumes allowToggle is set to\r\n * true.\r\n */\r\n constructor(root, options = {}) {\r\n const config = this._getConfig(options, root)\r\n\r\n // Prepare the initial state\r\n this._elements = { root }\r\n this._config = config\r\n this._state = {\r\n activeIndex: -1,\r\n isTransitioning: false,\r\n }\r\n\r\n // Traverse the DOM and initialize the rest of the state\r\n this.update()\r\n\r\n // Bind the event listeners\r\n this._handleClick = this._handleClick.bind(this)\r\n this._handleKeyDown = this._handleKeyDown.bind(this)\r\n\r\n this.attachEvents()\r\n }\r\n\r\n /**\r\n * Get configuration options from the provided object and data-*\r\n * attributes on the root element.\r\n * @param {object} options The configuration options\r\n * @return {object} an object containing configuration options\r\n */\r\n _getConfig(options, root) {\r\n const dataset = root.dataset\r\n\r\n const allowToggle = !!options.allowToggle || dataset.allowToggle === \"true\"\r\n const allowMultiple =\r\n allowToggle &&\r\n (!!options.allowMultiple || dataset.allowMultiple === \"true\")\r\n\r\n return {\r\n allowToggle,\r\n allowMultiple,\r\n }\r\n }\r\n\r\n /**\r\n * Collapse the specified panel\r\n * @param {number} i The index of the panel to be collapsed\r\n * @return {Promise} A Promise which resolves when the transition is complete\r\n */\r\n _collapsePanel(i) {\r\n const trigger = this._elements.triggers[i]\r\n const panel = this._elements.panels[i]\r\n\r\n trigger.setAttribute(\"aria-expanded\", \"false\")\r\n\r\n const currentHeight = panel.getBoundingClientRect().height\r\n panel.style.height = currentHeight + \"px\"\r\n forceReflow(panel)\r\n\r\n panel.style.height = \"0\"\r\n\r\n return detectTransitionEnd(panel).then(function() {\r\n panel.style.height = \"\"\r\n panel.classList.remove(ClassNames.PANEL_EXPANDED)\r\n })\r\n }\r\n\r\n /**\r\n * Expand the specified panel\r\n * @param {number} i The index of the panel to be expanded\r\n * @return {Promise} A Promise which resolves when the transition is complete\r\n */\r\n _expandPanel(i) {\r\n const trigger = this._elements.triggers[i]\r\n const panel = this._elements.panels[i]\r\n\r\n trigger.setAttribute(\"aria-expanded\", \"true\")\r\n\r\n panel.classList.add(ClassNames.PANEL_EXPANDED)\r\n const targetHeight = panel.getBoundingClientRect().height\r\n panel.style.height = \"0\"\r\n forceReflow(panel)\r\n\r\n panel.style.height = targetHeight + \"px\"\r\n\r\n return detectTransitionEnd(panel).then(function() {\r\n panel.style.height = \"\"\r\n })\r\n }\r\n\r\n /**\r\n * Handle the click event for accordion headers\r\n * @param {MouseEvent} e The event to be handled\r\n * @param {number} i The index of the corresponding accordion group\r\n */\r\n _handleClick(e) {\r\n const trigger = e.target.closest(Selectors.TRIGGER)\r\n if (!trigger) {\r\n return\r\n }\r\n\r\n const groupIndex = this._elements.triggers.indexOf(trigger)\r\n this.togglePanel(groupIndex)\r\n }\r\n\r\n /**\r\n * Handle the keydown event for accordion headers\r\n * @param {KeyboardEvent} e The event to be handled\r\n * @param {number} i The index of the corresponding accordion group\r\n */\r\n _handleKeyDown(e) {\r\n const { keyCode, target } = e\r\n\r\n\r\n const trigger = target.closest(Selectors.TRIGGER)\r\n if (!trigger) {\r\n return\r\n }\r\n\r\n const { triggers } = this._elements\r\n const currentIndex = triggers.indexOf(trigger)\r\n\r\n if (keyCode == Keys.ENTER || keyCode == Keys.SPACE) {\r\n // Expand/collapse the associated panel\r\n this.togglePanel(currentIndex)\r\n\r\n e.preventDefault()\r\n e.stopPropagation()\r\n } else {\r\n const groupCount = triggers.length\r\n let nextIndex\r\n\r\n switch (e.keyCode) {\r\n case Keys.END:\r\n // Move focus to the last accordion header\r\n nextIndex = toggleCount - 1\r\n break\r\n\r\n case Keys.HOME:\r\n // Move focus to the first accordion header\r\n nextIndex = 0\r\n break\r\n\r\n case Keys.DOWN:\r\n // Moves focus to the next accordion header\r\n nextIndex = (groupCount + currentIndex + 1) % groupCount\r\n break\r\n\r\n case Keys.UP:\r\n // Move focus to the previous accordion header\r\n nextIndex = (groupCount + currentIndex - 1) % groupCount\r\n break\r\n }\r\n\r\n if (typeof nextIndex !== \"undefined\") {\r\n this._elements.triggers[nextIndex].focus()\r\n e.preventDefault()\r\n e.stopPropagation()\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Re-initialize the accordion. You may call this method after manual DOM\r\n * manipulations such as adding or removing panels.\r\n */\r\n update() {\r\n if (this._state.isTransitioning) {\r\n return\r\n }\r\n\r\n const root = this._elements.root\r\n const config = this._config\r\n let activeIndex = this._state.activeIndex\r\n\r\n const triggers = [].slice.call(root.querySelectorAll(Selectors.TRIGGER))\r\n const panels = [].slice.call(root.querySelectorAll(Selectors.PANEL))\r\n\r\n if (triggers.length !== panels.length) {\r\n throw new Error()\r\n }\r\n\r\n for (let i = 0; i < triggers.length; i++) {\r\n const trigger = triggers[i]\r\n const panel = panels[i]\r\n\r\n let isExpanded = trigger.getAttribute(\"aria-expanded\") === \"true\"\r\n if (!config.allowMultiple && isExpanded) {\r\n if (activeIndex !== -1) {\r\n // Make sure that only one panel is expanded\r\n isExpanded = false\r\n } else {\r\n activeIndex = i\r\n }\r\n }\r\n\r\n // Make sure proper classes are applied\r\n if (isExpanded) {\r\n panel.classList.add(ClassNames.PANEL_EXPANDED)\r\n } else {\r\n panel.classList.remove(ClassNames.PANEL_EXPANDED)\r\n }\r\n }\r\n\r\n if (triggers.length > 0) {\r\n if (!config.allowToggle) {\r\n if (activeIndex < 0 || activeIndex >= triggers.length) {\r\n // Make sure at least one panel is expanded\r\n activeIndex = 0\r\n triggers[0].setAttribute(\"aria-expanded\", \"true\")\r\n panels[0].classList.add(ClassNames.PANEL_EXPANDED)\r\n }\r\n } else if (activeIndex >= triggers.length) {\r\n activeIndex = -1\r\n }\r\n } else {\r\n activeIndex = -1\r\n }\r\n\r\n root.setAttribute(\"data-accordion-initialised\", \"true\")\r\n this._elements.triggers = triggers\r\n this._elements.panels = panels\r\n this._state.activeIndex = activeIndex\r\n }\r\n\r\n /**\r\n * Toggle the specified panel\r\n * @param {number} The index of the panel to toggle\r\n */\r\n togglePanel(i) {\r\n if (i < 0 || i >= this._elements.panels.length) {\r\n return\r\n }\r\n\r\n if (this._state.isTransitioning) {\r\n return\r\n }\r\n\r\n if (!this._config.allowToggle && this._state.activeIndex === i) {\r\n // Configuration requires one panel to be expanded at all times\r\n return\r\n }\r\n\r\n const trigger = this._elements.triggers[i]\r\n const isExpanded = trigger.getAttribute(\"aria-expanded\") === \"true\"\r\n const isDisabled = trigger.getAttribute(\"aria-disabled\") === \"true\"\r\n\r\n if (isExpanded && isDisabled) {\r\n // The panel isn't permitted to be collapsed\r\n return\r\n }\r\n\r\n this._state.isTransitioning = true\r\n\r\n if (this._config.allowToggle) {\r\n if (isExpanded) {\r\n this._collapsePanel(i).then(() => {\r\n if (!this._config.allowMultiple) {\r\n this._state.activeIndex = -1\r\n }\r\n this._state.isTransitioning = false\r\n })\r\n } else {\r\n this._expandPanel(i).then(() => {\r\n if (!this._config.allowMultiple) {\r\n this._state.activeIndex = i\r\n }\r\n this._state.isTransitioning = false\r\n })\r\n }\r\n } else {\r\n Promise.all([\r\n this._collapsePanel(this._state.activeIndex),\r\n this._expandPanel(i),\r\n ]).then(() => {\r\n this._state.activeIndex = i\r\n this._state.isTransitioning = false\r\n })\r\n }\r\n }\r\n\r\n /**\r\n * Attach all event listeners\r\n */\r\n attachEvents() {\r\n const { root } = this._elements\r\n root.addEventListener(\"click\", this._handleClick, false)\r\n root.addEventListener(\"keydown\", this._handleKeyDown, false)\r\n }\r\n\r\n /**\r\n * Detach all event listeners\r\n */\r\n detachEvents() {\r\n const { root } = this._elements\r\n\r\n root.removeEventListener(\"click\", this._handleClick, false)\r\n root.removeEventListener(\"keydown\", this._handleKeyDown, false)\r\n }\r\n\r\n /**\r\n * Initialize all accordions on the page.\r\n */\r\n static initAll() {\r\n const accordions = document.querySelectorAll(Selectors.ROOT)\r\n ;[].forEach.call(accordions, function(el) {\r\n if (el.hasAttribute('data-accordion-initialised') === false || el.getAttribute('data-accordion-initialised') !== 'true') {\r\n new Accordion(el)\r\n }\r\n })\r\n }\r\n}\r\n\r\ndocument.addEventListener(\r\n \"DOMContentLoaded\",\r\n function() {\r\n Accordion.initAll()\r\n const callback = function(mutationsList) {\r\n for (let i = 0, len = mutationsList.length; i < len; i++) {\r\n if (mutationsList[i].type == \"childList\") {\r\n Accordion.initAll()\r\n break\r\n }\r\n }\r\n }\r\n const observer = new MutationObserver(callback)\r\n const config = {\r\n childList: true,\r\n subtree: true,\r\n }\r\n\r\n if (document.getElementById(\"root\") != null) {\r\n observer.observe(document.getElementById(\"root\"), config)\r\n }\r\n else if(document.querySelector('main') != null) {\r\n observer.observe(document.querySelector('main'), config)\r\n } \r\n },\r\n false\r\n)\r\n"],"sourceRoot":""}