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AvByB,GAAwB,EAAI,EAC7D9B,EAAKR,EAALG,MAAgB+B,SAAW,kBAAOhC,EAAKJ,EAALwC,GAAoB,EAAH,CACvD,CACJ,CAAC,SAAAL,EAEkBM,GACf/B,EAAKb,EAALQ,MAAqBe,KAAOqB,EAC5BrC,EAAKF,EAALG,KAAkB,MAClBD,EAAKH,EAALI,MAAkB,GAClBD,EAAKJ,EAALK,MAAoB,GACpBK,EAAKb,EAALQ,MAAqBa,MAAMa,OAASrB,EAAKb,EAALQ,MAAqBa,MAAMC,SAAW,EAC9E,CAEW,SAASuB,EAAUC,GAC9BA,EAAgBC,SAAQ,SAAAC,GACpB,IAAIvD,EAAQuD,EAChB,GACJ,C","sources":["webpack:///./html/wp-content/themes/ls/src/js/main/components/accordion/accordion.ts"],"sourcesContent":["export class Details {\n // Taken from https://css-tricks.com/how-to-animate-the-details-element-using-waapi/\n // If we didn't need to animate the element, this whole file could be deleted!\n #detailsElement: HTMLDetailsElement;\n #summary: HTMLElement | null;\n #content: HTMLElement | null;\n #isExpanding: boolean;\n #isClosing: boolean;\n #animation: Animation | null;\n #userPrefersReducedMotion: boolean;\n\n constructor(el: HTMLDetailsElement) {\n this.#detailsElement = el;\n this.#summary = el.querySelector('summary');\n this.#content = el.querySelector('[data-accordion=\"content\"]');\n this.#animation = null;\n this.#isClosing = false;\n this.#isExpanding = false;\n this.#userPrefersReducedMotion = window.matchMedia(\n '(prefers-reduced-motion: reduce)'\n ).matches;\n if (this.#summary && !this.#userPrefersReducedMotion) {\n this.#summary.addEventListener('click', e => {\n this.#handleClick(e);\n });\n }\n }\n\n #handleClick(event: Event) {\n event.preventDefault();\n this.#detailsElement.style.overflow = 'hidden';\n if (this.#isClosing || !this.#detailsElement.open) {\n this.#open();\n } else if (this.#isExpanding || this.#detailsElement.open) {\n this.#shrink();\n }\n }\n\n #shrink() {\n if (this.#summary && this.#content) {\n this.#isClosing = true;\n const startHeight = `${this.#detailsElement.offsetHeight}px`;\n const endHeight = `${this.#summary?.offsetHeight}px`;\n\n if (this.#animation) {\n this.#animation.cancel();\n }\n\n this.#animation = this.#detailsElement.animate(\n {\n // Set the keyframes from the startHeight to endHeight\n height: [startHeight, endHeight],\n },\n {\n duration: 400,\n easing: 'ease-out',\n }\n );\n\n this.#animation.onfinish = () => this.#onAnimationFinish(false);\n this.#animation.oncancel = () => (this.#isClosing = false);\n }\n }\n\n #open() {\n this.#detailsElement.style.height = `${this.#detailsElement.offsetHeight}px`;\n this.#detailsElement.open = true;\n window.requestAnimationFrame(() => this.#expand());\n }\n\n #expand() {\n if (this.#summary && this.#content) {\n this.#isExpanding = true;\n const startHeight = `${this.#detailsElement.offsetHeight}px`;\n const endHeight = `${\n this.#summary.offsetHeight + this.#content.offsetHeight\n }px`;\n\n if (this.#animation) {\n this.#animation.cancel();\n }\n\n this.#animation = this.#detailsElement.animate(\n {\n height: [startHeight, endHeight],\n },\n {\n duration: 400,\n easing: 'ease-out',\n }\n );\n this.#animation.onfinish = () => this.#onAnimationFinish(true);\n this.#animation.oncancel = () => (this.#isExpanding = false);\n }\n }\n\n #onAnimationFinish(isOpen: boolean) {\n this.#detailsElement.open = isOpen;\n this.#animation = null;\n this.#isClosing = false;\n this.#isExpanding = false;\n this.#detailsElement.style.height = this.#detailsElement.style.overflow = '';\n }\n}\nexport default function accordion(detailsElements: HTMLDetailsElement[]) {\n detailsElements.forEach(detailsElement => {\n new Details(detailsElement);\n });\n}\n"],"names":["Details","_createClass","el","_this","_classCallCheck","_Details_brand","_classPrivateFieldInitSpec","_detailsElement","_summary","_content","_isExpanding","_isClosing","_animation","_userPrefersReducedMotion","_classPrivateFieldSet","this","querySelector","window","matchMedia","matches","_classPrivateFieldGet","addEventListener","e","_assertClassBrand","_handleClick","call","event","preventDefault","style","overflow","open","_open","_shrink","_this2","_classPrivateFieldGet2","startHeight","concat","offsetHeight","endHeight","cancel","animate","height","duration","easing","onfinish","_onAnimationFinish","oncancel","_this3","requestAnimationFrame","_expand","_this4","isOpen","accordion","detailsElements","forEach","detailsElement"],"sourceRoot":""}