{"version":3,"file":"chunks/0c9987109b59a45d28d7.js","mappings":"gWAEA,IAAMA,EAAY,qBA6BlB,QA1BMC,WACJ,WAAaC,EAAb,GAA6C,IAAfC,EAAe,EAAfA,a,4FAAe,SAC3CC,KAAKC,KAAKH,EAAeC,G,yCAG3B,SAAKD,EAAeC,GAClB,IAAMG,EAAuBC,EAAAA,EAAAA,aAAiBC,OAAOC,SAASC,MAIxDC,EADoBL,GAAwBM,OAAOC,KAAKP,GAAsBQ,SAASX,IAChDG,EAAqBH,GAG5DY,EAAmBJ,GACvBK,MAAMC,KAAKf,EAAcgB,iBAhBN,6DAgB0CC,KAC3D,qBAAGC,WAA4BC,aAAarB,GAAWsB,SAMrDC,EAHyBZ,GAAmBI,GAAoBA,EAAiBD,SAASH,GAG3D,IAAH,OAAOX,EAAP,YAAoBW,EAApB,KAAyC,WAC3ET,EAAcgB,iBAAiBK,GAAKC,SAAQ,SAAAC,GAAI,OAAIA,EAAKL,WAAWC,aAAa,SAASC,OAAS,iB,sEAtBjGrB","sources":["webpack:///./resources/js/components/generic/conditional-url-container.ts"],"sourcesContent":["import url from '../../utils/url';\n\nconst DATA_ATTR = 'data-urlparamvalue';\nconst CONDITIONALS_SEL = '.conditional .component--conditional-url-child-container';\n\nclass ConditionalURLContainer {\n constructor (componentRoot, { urlParamKey }) {\n this.init(componentRoot, urlParamKey);\n }\n\n init(componentRoot, urlParamKey) {\n const queryParamsAndValues = url.getUrlParams(window.location.href);\n\n // check whether our query param is present and has a value\n const queryParamMatches = queryParamsAndValues && Object.keys(queryParamsAndValues).includes(urlParamKey);\n const queryParamValue = queryParamMatches && queryParamsAndValues[urlParamKey];\n\n // get all the possible values to check against\n const queryParamValues = queryParamValue &&\n Array.from(componentRoot.querySelectorAll(CONDITIONALS_SEL)).map(\n ({ attributes }) => attributes.getNamedItem(DATA_ATTR).value\n );\n\n const queryParamValueMatches = queryParamValue && queryParamValues && queryParamValues.includes(queryParamValue);\n\n // if there's a match show the matched child(ren) otherwise show the default content\n const sel = queryParamValueMatches ? `[${DATA_ATTR}=${queryParamValue}]` : '.default';\n componentRoot.querySelectorAll(sel).forEach(node => node.attributes.getNamedItem('class').value += ' shown');\n }\n}\n\nexport default ConditionalURLContainer;"],"names":["DATA_ATTR","ConditionalURLContainer","componentRoot","urlParamKey","this","init","queryParamsAndValues","url","window","location","href","queryParamValue","Object","keys","includes","queryParamValues","Array","from","querySelectorAll","map","attributes","getNamedItem","value","sel","forEach","node"],"sourceRoot":""}