{"version":3,"file":"chunks/8e490c331a6028.js","mappings":"6xBAEA,IAAMA,EAAY,qBA6BlB,QA1B6B,WAC3B,SAAAC,EAAaC,EAAaC,GAAmB,IAAfC,EAAWD,EAAXC,a,4FAAWC,CAAA,KAAAJ,GACvCK,KAAKC,KAAKL,EAAeE,EAC3B,C,QAoBC,O,EApBAH,G,EAAA,EAAAO,IAAA,OAAAC,MAED,SAAKP,EAAeE,GAClB,IAAMM,EAAuBC,EAAAA,EAAAA,aAAiBC,OAAOC,SAASC,MAIxDC,EADoBL,GAAwBM,OAAOC,KAAKP,GAAsBQ,SAASd,IAChDM,EAAqBN,GAG5De,EAAmBJ,GACvBK,MAAMC,KAAKnB,EAAcoB,iBAhBN,6DAgB0CC,KAC3D,SAAAC,GAAa,OAAAA,EAAVC,WAA4BC,aAAa1B,GAAWS,KAAK,IAM1DkB,EAHyBZ,GAAmBI,GAAoBA,EAAiBD,SAASH,GAG3D,IAAHa,OAAO5B,EAAS,KAAA4B,OAAIb,EAAe,KAAM,WAC3Eb,EAAcoB,iBAAiBK,GAAKE,SAAQ,SAAAC,GAAI,OAAIA,EAAKL,WAAWC,aAAa,SAASjB,OAAS,QAAQ,GAC7G,M,oEAACR,CAAA,CAvB0B,E","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","_ref","urlParamKey","_classCallCheck","this","init","key","value","queryParamsAndValues","url","window","location","href","queryParamValue","Object","keys","includes","queryParamValues","Array","from","querySelectorAll","map","_ref2","attributes","getNamedItem","sel","concat","forEach","node"],"sourceRoot":""}