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C","sources":["webpack://UKCISA/./wwwroot/app/src/js/smart-bootstrap-tabs.js"],"sourcesContent":["import { Tab as bootstrapTab } from 'bootstrap';\r\n\r\nconst url = location.href.replace(/\\/$/, \"\");\r\nconst pageUrl = url.split(\"#\")[0];\r\n\r\nclass SmartTabs {\r\n\r\n constructor(el) {\r\n this.el = el;\r\n this.tabs = el.querySelectorAll('.nav-link');\r\n // update page url anchor when tabs changed\r\n if(this.tabs != null) {\r\n this.tabs.forEach(t => {\r\n let tabID = null;\r\n if(t.getAttribute('href')) {\r\n tabID = t.getAttribute('href');\r\n } else if(t.dataset.bsTarget) {\r\n tabID = t.dataset.bsTarget;\r\n }\r\n // update url and history on tab active\r\n t.addEventListener('shown.bs.tab', function (event) {\r\n let url = null;\r\n if(event.target.getAttribute('href')) {\r\n url = pageUrl + tabID;\r\n } else if(event.target.dataset.bsTarget) {\r\n url = pageUrl + tabID;\r\n }\r\n if(url) history.replaceState(null, null, url);\r\n })\r\n // add listeners for links to tab\r\n let findLinksToTabs = document.querySelectorAll(`a:not(.nav-link)[href=\"${tabID}\"]`);\r\n findLinksToTabs.forEach(l => {\r\n l.addEventListener('click', (e) => {\r\n let tab = bootstrapTab.getOrCreateInstance(t);\r\n if(tab != null) {\r\n e.preventDefault();\r\n tab.show();\r\n // focus on first focusable element inside tab content\r\n let firstEl = document.querySelector(tabID).querySelector('a,button,input,textarea,select,details,[tabindex]:not([tabindex=\"-1\"]');\r\n if(firstEl != null) firstEl.focus();\r\n }\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 SmartTabs(node);\r\n }\r\n });\r\n\r\n // set active tab on page load?\r\n if (location.hash) {\r\n let hash = url.split(\"#\")[1];\r\n if(hash.length > 0) {\r\n let findNav = document.querySelector(`.nav-link[href=\"#${hash}\"]`);\r\n if(!findNav) {\r\n findNav = document.querySelector(`.nav-link[data-bs-target=\"#${hash}\"]`);\r\n }\r\n if(findNav != null) {\r\n let tab = bootstrapTab.getOrCreateInstance(findNav);\r\n tab.show();\r\n }\r\n }\r\n }\r\n\r\n}"],"names":["url","location","href","replace","pageUrl","split","SmartTabs","constructor","el","this","tabs","querySelectorAll","forEach","t","tabID","getAttribute","dataset","bsTarget","addEventListener","event","target","history","replaceState","document","l","e","tab","bootstrapTab","getOrCreateInstance","preventDefault","show","firstEl","querySelector","focus","createFrom","wrappers","node","nodeType","hash","length","findNav"],"sourceRoot":""}