{"version":3,"file":"5183.73d99a44d5830439a18a.js","mappings":"+IAEA,MAAMA,EAAMC,SAASC,KAAKC,QAAQ,MAAO,IAEzC,MAAMC,EAEFC,WAAAA,CAAYC,GAGR,GAFAC,KAAKD,GAAKA,EACVC,KAAKC,UAAYF,EAAGG,aAAa,mBACZ,MAAlBF,KAAKC,UAAmB,CAEvB,IAAIE,EAASH,KAAKD,GAAGK,UAAUC,SAAS,QAExC,GAAIX,SAASY,KAAM,CACf,IAAIA,EAAOb,EAAIc,MAAM,KAAK,GACvBD,EAAKE,OAAS,GACVF,GAAQN,KAAKC,YAAWE,GAAS,EAE5C,CACA,IAAIM,EAAU,CAACC,MAAK,EAAMC,QAAQ,GAClCX,KAAKY,WAAaA,EAAAA,GAAWC,oBAAoBb,KAAKD,GAAIU,GACvDN,GAAQH,KAAKY,WAAWE,OAE3B,IAAIC,EAAYC,SAASC,iBAAiB,WAAWjB,KAAKC,eAC1C,MAAbc,GACCA,EAAUG,SAAQC,IACdA,EAAEC,iBAAiB,SAAQ,KACvBC,YAAW,KACPrB,KAAKY,WAAWE,MAAM,GACvB,IAAI,GACT,GAGd,CACJ,EAKG,SAASQ,EAAWC,GAEvBA,EAASL,SAASM,IAEQ,IAAlBA,EAAKC,UACL,IAAI5B,EAAqB2B,EAC7B,GAGR,C","sources":["webpack://UKCISA/./wwwroot/app/src/js/smart-collapse-trigger.js"],"sourcesContent":["import { Collapse as bsCollapse } from 'bootstrap';\r\n\r\nconst url = location.href.replace(/\\/$/, \"\");\r\n\r\nclass SmartCollapseTrigger {\r\n\r\n constructor(el) {\r\n this.el = el;\r\n this.contentId = el.getAttribute('aria-labelledby');\r\n if(this.contentId != null) {\r\n // is open already?\r\n let bsShow = this.el.classList.contains('show');\r\n // open if anchor is in page url\r\n if (location.hash) {\r\n let hash = url.split(\"#\")[1];\r\n if(hash.length > 0) {\r\n if(hash == this.contentId) bsShow = true;\r\n }\r\n }\r\n let options = {hide:true, toggle: false};\r\n this.bsCollapse = bsCollapse.getOrCreateInstance(this.el, options);\r\n if(bsShow) this.bsCollapse.show();\r\n // find any links to this collapse and expand if they're clicked.\r\n let findLinks = document.querySelectorAll(`[href=\"#${this.contentId}\"]`);\r\n if(findLinks != null) {\r\n findLinks.forEach(l => {\r\n l.addEventListener('click',() => {\r\n setTimeout(() => {\r\n this.bsCollapse.show();\r\n }, 500);\r\n });\r\n });\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new SmartCollapseTrigger(node);\r\n }\r\n });\r\n\r\n}"],"names":["url","location","href","replace","SmartCollapseTrigger","constructor","el","this","contentId","getAttribute","bsShow","classList","contains","hash","split","length","options","hide","toggle","bsCollapse","getOrCreateInstance","show","findLinks","document","querySelectorAll","forEach","l","addEventListener","setTimeout","createFrom","wrappers","node","nodeType"],"sourceRoot":""}