{"version":3,"file":"cost-of-living-CIO9SS1w.js","sources":["../../src/scripts/modules/cost-of-living.ts"],"sourcesContent":["import { Component } from '@verndale/core';\nimport { ConditionalDisplay } from '../helpers/global';\n\nclass CostOfLiving extends Component {\n setupDefaults() {\n this.dom = {\n bars: this.el.querySelectorAll('.v-section-cost__li'),\n tooltips: this.el.querySelectorAll('.v-section-overview__tooltip'),\n icons: this.el.querySelectorAll('.v-section-overview__tooltip-icon')\n };\n if (ConditionalDisplay(this.el.id)) {\n this.el.style.display = 'none';\n }\n\n this.updateBarValues();\n }\n\n addListeners() {\n document.body.addEventListener('mousedown', e => {\n this.handleCloseTooltip(e);\n });\n\n document.body.addEventListener('touchend', e => {\n this.handleCloseTooltip(e);\n });\n\n (this.dom.icons as NodeListOf).forEach(trigger => {\n trigger.addEventListener('mouseover', e => {\n this.handleTriggerTooltip(e);\n });\n\n trigger.addEventListener('mouseout', () => {\n this.handleCloseAll();\n });\n });\n }\n\n handleTriggerTooltip(e: Event) {\n this.handleCloseAll();\n const trigger = (e.currentTarget as HTMLElement).closest('.v-section-cost__heading');\n const tooltip = trigger?.querySelector('.v-section-overview__tooltip');\n\n if (tooltip) {\n if (tooltip.style.display === 'block') {\n tooltip.style.display = 'none';\n } else {\n tooltip.style.display = 'block';\n }\n }\n }\n\n handleCloseAll() {\n (this.dom.tooltips as NodeListOf).forEach(tooltip => {\n tooltip.style.display = 'none';\n });\n }\n\n handleCloseTooltip(e: Event) {\n if (!(e.target as HTMLElement)?.closest('.v-section-cost__heading')) {\n this.handleCloseAll();\n }\n }\n\n updateBarValues() {\n (this.dom.bars as NodeListOf).forEach(bar => {\n const value = bar.dataset.value;\n const barFill = bar.querySelector('.v-section-cost__li-bar');\n if (barFill && value) {\n (barFill as HTMLElement).style.setProperty('inset-inline-end', `calc(100% - ${value})`);\n }\n });\n }\n}\n\nexport default CostOfLiving;\n"],"names":["CostOfLiving","Component","ConditionalDisplay","trigger","e","tooltip","_a","bar","value","barFill"],"mappings":"8EA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