{"version":3,"file":"mediaMasthead-BPs0jl37.js","sources":["../../src/scripts/modules/mediaMasthead.ts"],"sourcesContent":["import { Component } from '@verndale/core';\nimport { debounce } from '../helpers';\n\nclass MediaMasthead extends Component {\n resizeObserver: ResizeObserver;\n isProgramMasthead: boolean;\n\n constructor(el: HTMLElement) {\n super(el);\n\n this.resizeObserver = new ResizeObserver(this.updateVWProperty);\n this.resizeObserver.observe(document.documentElement);\n\n this.isProgramMasthead = this.el.classList.contains('program-masthead');\n this.dom = {\n programFeaturesRowInner: this.el.querySelector('.program-features-row__inner') as HTMLElement,\n programFeaturesRowCard: this.el.querySelectorAll(\n '.program-features-row__card'\n ) as NodeListOf,\n mediaMastheadInner: this.el.querySelector('.media-masthead__inner') as HTMLElement\n };\n\n //this.programInnerResize();\n }\n\n setupDefaults() {\n this.dom = {\n el: this.el\n };\n }\n\n addListeners() {\n //window.addEventListener('resize', debounce(this.programInnerResize.bind(this), 250));\n }\n\n updateVWProperty = debounce(() => {\n document.documentElement.style.setProperty(\n '--vw',\n `${document.documentElement.clientWidth / 100}px`\n );\n }, 250);\n\n programInnerResize() {\n if (this.isProgramMasthead) {\n const cardsLength = (this.dom.programFeaturesRowCard as NodeListOf)?.length || 0;\n let programFeaturesRowWidth = (this.dom.programFeaturesRowInner as HTMLElement).offsetWidth;\n\n if (programFeaturesRowWidth < 1439) {\n programFeaturesRowWidth = document.documentElement.clientWidth - 82;\n }\n\n if (cardsLength > 4) {\n // we need the width of the programFeaturesRow minus the last 2 cards if there are more than 5 cards\n const lastCardWidth = (this.dom.programFeaturesRowCard as NodeListOf)[\n cardsLength - 1\n ].offsetWidth;\n const secondLastCardWidth = (this.dom.programFeaturesRowCard as NodeListOf)[\n cardsLength - 2\n ].offsetWidth;\n\n const newWidth = `${programFeaturesRowWidth - lastCardWidth - secondLastCardWidth + 1}px`;\n (this.dom.mediaMastheadInner as HTMLElement).style.maxWidth = newWidth;\n }\n }\n }\n}\n\nexport default MediaMasthead;\n"],"names":["MediaMasthead","Component","el","__publicField","debounce","cardsLength","_a","programFeaturesRowWidth","lastCardWidth","secondLastCardWidth","newWidth"],"mappings":"kRAGA,MAAMA,UAAsBC,CAAU,CAIpC,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,EAJVC,EAAA,uBACAA,EAAA,0BA8BAA,EAAA,wBAAmBC,EAAS,IAAM,CAChC,SAAS,gBAAgB,MAAM,YAC7B,OACA,GAAG,SAAS,gBAAgB,YAAc,GAAG,IAAA,GAE9C,GAAG,GA9BJ,KAAK,eAAiB,IAAI,eAAe,KAAK,gBAAgB,EACzD,KAAA,eAAe,QAAQ,SAAS,eAAe,EAEpD,KAAK,kBAAoB,KAAK,GAAG,UAAU,SAAS,kBAAkB,EACtE,KAAK,IAAM,CACT,wBAAyB,KAAK,GAAG,cAAc,8BAA8B,EAC7E,uBAAwB,KAAK,GAAG,iBAC9B,6BACF,EACA,mBAAoB,KAAK,GAAG,cAAc,wBAAwB,CAAA,CAItE,CAEA,eAAgB,CACd,KAAK,IAAM,CACT,GAAI,KAAK,EAAA,CAEb,CAEA,cAAe,CAEf,CASA,oBAAqB,OACnB,GAAI,KAAK,kBAAmB,CAC1B,MAAMC,IAAeC,EAAA,KAAK,IAAI,yBAAT,YAAAA,EAA6D,SAAU,EACxF,IAAAC,EAA2B,KAAK,IAAI,wBAAwC,YAMhF,GAJIA,EAA0B,OACFA,EAAA,SAAS,gBAAgB,YAAc,IAG/DF,EAAc,EAAG,CAEnB,MAAMG,EAAiB,KAAK,IAAI,uBAC9BH,EAAc,CAChB,EAAE,YACII,EAAuB,KAAK,IAAI,uBACpCJ,EAAc,CAChB,EAAE,YAEIK,EAAW,GAAGH,EAA0BC,EAAgBC,EAAsB,CAAC,KACpF,KAAK,IAAI,mBAAmC,MAAM,SAAWC,CAChE,CACF,CACF,CACF"}