{"version":3,"file":"nrkno-masthead-render.min.js","sources":["../node_modules/@nrk/core-toggle/core-toggle.cjs.js","../node_modules/@nrk/core-icons/core-icons.mjs","../node_modules/@nrk/nrkno-login-connector/connector.js","../nrkno-masthead-banners.js","../nrkno-masthead-initialize.js","../nrkno-masthead.js"],"sourcesContent":["'use strict';\n\nvar name = \"@nrk/core-toggle\";\nvar version = \"2.2.2\";\n\nvar IS_BROWSER = typeof window !== 'undefined';\nvar IS_ANDROID = IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed\nvar IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform));\nvar HAS_EVENT_OPTIONS = (function (has) {\n if ( has === void 0 ) has = false;\n\n try { window.addEventListener('test', null, { get passive () { has = true; } }); } catch (e) {}\n return has\n})();\n\n/**\n* addEvent\n* @param {String} uuid An unique ID of the event to bind - ensurnes single instance\n* @param {String} type The type of event to bind\n* @param {Function} handler The function to call on event\n* @param {Boolean|Object} options useCapture or options object for addEventListener. Defaults to false\n*/\nfunction addEvent (uuid, type, handler, options) {\n if ( options === void 0 ) options = false;\n\n if (typeof window === 'undefined' || window[uuid = uuid + \"-\" + type]) { return } // Ensure single instance\n if (!HAS_EVENT_OPTIONS && typeof options === 'object') { options = Boolean(options.capture); } // Fix unsupported options\n var node = (type === 'resize' || type === 'load') ? window : document;\n node.addEventListener(window[uuid] = type, handler, options);\n}\n\n/**\n* dispatchEvent - with infinite loop prevention\n* @param {Element} elem The target object\n* @param {String} name The source object(s)\n* @param {Object} detail Detail object (bubbles and cancelable is set to true)\n* @return {Boolean} Whether the event was canceled\n*/\nvar IGNORE = 'prevent_recursive_dispatch_maximum_callstack';\nfunction dispatchEvent (element, name, detail) {\n if ( detail === void 0 ) detail = {};\n\n var ignore = \"\" + IGNORE + name;\n var event;\n\n if (element[ignore]) { return true } // We are already processing this event, so skip sending a new one\n else { element[ignore] = true; } // Add name to dispatching ignore\n\n if (typeof window.CustomEvent === 'function') {\n event = new window.CustomEvent(name, { bubbles: true, cancelable: true, detail: detail });\n } else {\n event = document.createEvent('CustomEvent');\n event.initCustomEvent(name, true, true, detail);\n }\n // IE reports incorrect event.defaultPrevented\n // but correct return value on element.dispatchEvent\n var result = element.dispatchEvent(event);\n element[ignore] = null; // Remove name from dispatching ignore\n\n return result // Follow W3C standard for return value\n}\n\n/**\n* getUUID\n* @return {String} A generated unique ID\n*/\nfunction getUUID (el) {\n return Date.now().toString(36) + Math.random().toString(36).slice(2, 5)\n}\n\n/**\n* queryAll\n* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element\n* @return {Element[]} Array of elements\n*/\nfunction queryAll (elements, context) {\n if ( context === void 0 ) context = document;\n\n if (elements) {\n if (elements.nodeType) { return [elements] }\n if (typeof elements === 'string') { return [].slice.call(context.querySelectorAll(elements)) }\n if (elements.length) { return [].slice.call(elements) }\n }\n return []\n}\n\nvar UUID = (\"data-\" + name + \"-\" + version).replace(/\\W+/g, '-'); // Strip invalid attribute characters\nvar ARIA = IS_ANDROID ? 'data' : 'aria'; // Andriod has a bug and reads only label instead of content\nvar KEYS = { ESC: 27 };\n\nfunction toggle (toggles, open) {\n var options = typeof open === 'object' ? open : { open: open };\n if (IS_IOS) { document.documentElement.style.cursor = 'pointer'; } // Fix iOS events for closing popups (https://stackoverflow.com/a/16006333/8819615)\n\n return queryAll(toggles).map(function (toggle) {\n var content = getContentElement(toggle);\n var isOpen = toggle.getAttribute('aria-expanded') === 'true';\n var open = typeof options.open === 'boolean' ? options.open : (options.open === 'toggle' ? !isOpen : isOpen);\n var popup = String((options.hasOwnProperty('popup') ? options.popup : toggle.getAttribute(UUID)) || false);\n\n if (options.value) { toggle.innerHTML = options.value; } // Set innerHTML before updating aria-label\n if (popup !== 'false' && popup !== 'true') { toggle.setAttribute('aria-label', ((toggle.textContent) + \", \" + popup)); } // Only update aria-label if popup-mode\n\n toggle.setAttribute(UUID, popup); // aria-haspopup triggers forms mode in JAWS, therefore store in uuid\n toggle.setAttribute('aria-controls', content.id = content.id || getUUID());\n content.setAttribute((ARIA + \"-labelledby\"), toggle.id = toggle.id || getUUID());\n setOpen(toggle, open);\n return toggle\n })\n}\n\nfunction getContentElement (toggle) {\n return document.getElementById(toggle.getAttribute('aria-controls')) || toggle.nextElementSibling\n}\n\naddEvent(UUID, 'keydown', function (event) {\n if (event.keyCode !== KEYS.ESC) { return }\n for (var el = event.target; el; el = el.parentElement) {\n var toggle = (el.id && document.querySelector((\"[aria-controls=\\\"\" + (el.id) + \"\\\"]\"))) || el;\n\n if (toggle.getAttribute(UUID) !== 'false' && toggle.getAttribute('aria-expanded') === 'true') {\n event.preventDefault(); // Prevent leaving maximized window in Safari\n toggle.focus();\n return setOpen(toggle, false)\n }\n }\n}, true); // Use capture to enable checking defaultPrevented (from ESC key) in parents\n\naddEvent(UUID, 'click', function (ref) {\n var target = ref.target;\n var defaultPrevented = ref.defaultPrevented;\n\n if (defaultPrevented) { return false } // Do not toggle if someone run event.preventDefault()\n\n for (var el = target, item = (void 0); el; el = el.parentElement) {\n var toggle = item && el.id && document.querySelector((\"[\" + UUID + \"][aria-controls=\\\"\" + (el.id) + \"\\\"]\"));\n if ((el.nodeName === 'BUTTON' || el.nodeName === 'A') && !el.hasAttribute(UUID)) { item = el; } // interactive element clicked\n if (toggle) {\n dispatchEvent(toggle, 'toggle.select', {\n relatedTarget: getContentElement(toggle),\n currentTarget: item,\n value: item.textContent.trim()\n });\n break\n }\n }\n\n queryAll((\"[\" + UUID + \"]\")).forEach(function (toggle) {\n var open = toggle.getAttribute('aria-expanded') === 'true';\n var popup = toggle.getAttribute(UUID) !== 'false';\n var content = getContentElement(toggle);\n\n if (toggle.contains(target)) { setOpen(toggle, !open); } // Click on toggle\n else if (popup && open) { setOpen(toggle, content.contains(target)); } // Click in content or outside\n });\n});\n\nfunction setOpen (toggle, open) {\n var content = getContentElement(toggle);\n var isOpen = toggle.getAttribute('aria-expanded') === 'true';\n var willOpen = typeof open === 'boolean' ? open : (open === 'toggle' ? !isOpen : isOpen);\n var isUpdate = isOpen === willOpen || dispatchEvent(toggle, 'toggle', { relatedTarget: content, isOpen: isOpen, willOpen: willOpen });\n var nextOpen = isUpdate ? willOpen : toggle.getAttribute('aria-expanded') === 'true'; // dispatchEvent can change attributes\n var focus = !isOpen && nextOpen && content.querySelector('[autofocus]');\n\n if (focus) { setTimeout(function () { return focus && focus.focus(); }); } // Move focus on next render (if element stil exists)\n\n toggle.setAttribute('aria-expanded', nextOpen);\n content[nextOpen ? 'removeAttribute' : 'setAttribute']('hidden', '');\n}\n\nmodule.exports = toggle;\n","export const nrk360 = ''\nexport const nrk404 = ''\nexport const nrkArrowDropdown = ''\nexport const nrkArrowLeftLong = ''\nexport const nrkArrowLeft = ''\nexport const nrkArrowRightLong = ''\nexport const nrkArrowRight = ''\nexport const nrkArticle = ''\nexport const nrkBack = ''\nexport const nrkBellActive = ''\nexport const nrkBell = ''\nexport const nrkBookmarkActive = ''\nexport const nrkBookmark = ''\nexport const nrkBroadcast = ''\nexport const nrkCalendar = ''\nexport const nrkCategory = ''\nexport const nrkCheckActive = ''\nexport const nrkCheck = ''\nexport const nrkChevronDown = ''\nexport const nrkChevronLeft = ''\nexport const nrkChevronRight = ''\nexport const nrkChevronUp = ''\nexport const nrkCloseActive = ''\nexport const nrkClose = ''\nexport const nrkComment = ''\nexport const nrkDice1Active = ''\nexport const nrkDice1 = ''\nexport const nrkDice2Active = ''\nexport const nrkDice2 = ''\nexport const nrkDice3Active = ''\nexport const nrkDice3 = ''\nexport const nrkDice4Active = ''\nexport const nrkDice4 = ''\nexport const nrkDice5Active = ''\nexport const nrkDice5 = ''\nexport const nrkDice6Active = ''\nexport const nrkDice6 = ''\nexport const nrkDownload = ''\nexport const nrkDuration = ''\nexport const nrkEllipsisActive = ''\nexport const nrkEllipsis = ''\nexport const nrkFullscreenActive = ''\nexport const nrkFullscreen = ''\nexport const nrkGallery = ''\nexport const nrkGeoActive = ''\nexport const nrkGeo = ''\nexport const nrkGeopointActive = ''\nexport const nrkGeopoint = ''\nexport const nrkGlobe = ''\nexport const nrkHardwareCamera = ''\nexport const nrkHardwareComputer = ''\nexport const nrkHardwareGame = ''\nexport const nrkHardwareLaptop = ''\nexport const nrkHardwareMobile = ''\nexport const nrkHardwarePrinter = ''\nexport const nrkHardwareRadio = ''\nexport const nrkHardwareSmartSpeaker = ''\nexport const nrkHardwareSmartWatch = ''\nexport const nrkHardwareSpeaker = ''\nexport const nrkHardwareTablet = ''\nexport const nrkHardwareTv = ''\nexport const nrkHardwareWatch = ''\nexport const nrkHeartActive = ''\nexport const nrkHeart = ''\nexport const nrkHelp = ''\nexport const nrkHomeActive = ''\nexport const nrkHome = ''\nexport const nrkInfo = ''\nexport const nrkLatestNewsActive = ''\nexport const nrkLatestNews = ''\nexport const nrkLink = ''\nexport const nrkList = ''\nexport const nrkLockActive = ''\nexport const nrkLock = ''\nexport const nrkLogoMgp = ''\nexport const nrkLogoNrk1Colorblack = ''\nexport const nrkLogoNrk1Colorgrey = ''\nexport const nrkLogoNrk1Colorwhite = ''\nexport const nrkLogoNrk1 = ''\nexport const nrkLogoNrk2Colorblack = ''\nexport const nrkLogoNrk2Colorgrey = ''\nexport const nrkLogoNrk2Colorwhite = ''\nexport const nrkLogoNrk2 = ''\nexport const nrkLogoNrk3Colorblack = ''\nexport const nrkLogoNrk3Colorgrey = ''\nexport const nrkLogoNrk3Colorwhite = ''\nexport const nrkLogoNrk3 = ''\nexport const nrkLogoNrkAlltidNyheter = ''\nexport const nrkLogoNrkFolkemusikk = ''\nexport const nrkLogoNrkJazz = ''\nexport const nrkLogoNrkKlassisk = ''\nexport const nrkLogoNrkMp3Symbol = ''\nexport const nrkLogoNrkMp3 = ''\nexport const nrkLogoNrkNyheterSymbolBlackwhite = ''\nexport const nrkLogoNrkNyheterSymbolColor = ''\nexport const nrkLogoNrkNyheterSymbol = ''\nexport const nrkLogoNrkNyheter = ''\nexport const nrkLogoNrkP1Pluss = ''\nexport const nrkLogoNrkP1 = ''\nexport const nrkLogoNrkP13Radioresepsjonen = ''\nexport const nrkLogoNrkP13 = ''\nexport const nrkLogoNrkP2 = ''\nexport const nrkLogoNrkP3NationalRapShow = ''\nexport const nrkLogoNrkP3Symbol = ''\nexport const nrkLogoNrkP3Urort = ''\nexport const nrkLogoNrkP3X = ''\nexport const nrkLogoNrkP3 = ''\nexport const nrkLogoNrkRadio = ''\nexport const nrkLogoNrkSapmi = ''\nexport const nrkLogoNrkSportSymbolBlackwhite = ''\nexport const nrkLogoNrkSportSymbolColor = ''\nexport const nrkLogoNrkSportSymbol = ''\nexport const nrkLogoNrkSport = ''\nexport const nrkLogoNrkSuperSentrert = ''\nexport const nrkLogoNrkSuperSymbol = ''\nexport const nrkLogoNrkSuper = ''\nexport const nrkLogoNrkTegnspraakColorblack = ''\nexport const nrkLogoNrkTegnspraakColorgrey = ''\nexport const nrkLogoNrkTegnspraakColorwhite = ''\nexport const nrkLogoNrkTegnspraak = ''\nexport const nrkLogoNrkTv = ''\nexport const nrkLogoNrk = ''\nexport const nrkLogoYrBlackwhite = ''\nexport const nrkLogoYrColor = ''\nexport const nrkLogoYr = ''\nexport const nrkLongreadActive = ''\nexport const nrkLongread = ''\nexport const nrkLyn = ''\nexport const nrkMat = ''\nexport const nrkMedia404Notfound = ''\nexport const nrkMediaAirplayActive = ''\nexport const nrkMediaAirplay = ''\nexport const nrkMediaChromecast1 = ''\nexport const nrkMediaChromecast2 = ''\nexport const nrkMediaChromecast3 = ''\nexport const nrkMediaChromecastActive = ''\nexport const nrkMediaChromecast = ''\nexport const nrkMediaCompleted = ''\nexport const nrkMediaDirekteActive = ''\nexport const nrkMediaDirekte = ''\nexport const nrkMediaDirektetvActive = ''\nexport const nrkMediaDirektetv = ''\nexport const nrkMediaFfw15sec = ''\nexport const nrkMediaFfw30sec = ''\nexport const nrkMediaFfw = ''\nexport const nrkMediaNext = ''\nexport const nrkMediaNy = ''\nexport const nrkMediaPause = ''\nexport const nrkMediaPictureInPictureActive = ''\nexport const nrkMediaPictureInPicture = ''\nexport const nrkMediaPlayFail = ''\nexport const nrkMediaPlay = ''\nexport const nrkMediaPrevious = ''\nexport const nrkMediaProgramguideActive = ''\nexport const nrkMediaProgramguide = ''\nexport const nrkMediaRwd15sec = ''\nexport const nrkMediaRwd30sec = ''\nexport const nrkMediaRwd = ''\nexport const nrkMediaSoundwave = ''\nexport const nrkMediaStop = ''\nexport const nrkMediaSubtitlesActive = ''\nexport const nrkMediaSubtitlesUnavailable = ''\nexport const nrkMediaSubtitles = ''\nexport const nrkMediaTheaterActive = ''\nexport const nrkMediaTheater = ''\nexport const nrkMediaTilgjengelighetGeoblocked = ''\nexport const nrkMediaTilgjengelighetIkkelengertilgjengelig = ''\nexport const nrkMediaTilgjengelighetKommer = ''\nexport const nrkMediaVolume1 = ''\nexport const nrkMediaVolume2 = ''\nexport const nrkMediaVolume3 = ''\nexport const nrkMediaVolumeMuted = ''\nexport const nrkMening = ''\nexport const nrkMinus = ''\nexport const nrkMoreActive = ''\nexport const nrkMore = ''\nexport const nrkNote1Off = ''\nexport const nrkNote1 = ''\nexport const nrkNote2 = ''\nexport const nrkOffline = ''\nexport const nrkOpenInNew = ''\nexport const nrkPerson = ''\nexport const nrkPlus = ''\nexport const nrkPoll = ''\nexport const nrkReload = ''\nexport const nrkReorder = ''\nexport const nrkSearchActive = ''\nexport const nrkSearch = ''\nexport const nrkSettingsActive = ''\nexport const nrkSettings = ''\nexport const nrkSomeEmail = ''\nexport const nrkSomeEmbed = ''\nexport const nrkSomeFacebook = ''\nexport const nrkSomeGoogle = ''\nexport const nrkSomeInstagram = ''\nexport const nrkSomePinterest = ''\nexport const nrkSomeShareIos = ''\nexport const nrkSomeShare = ''\nexport const nrkSomeSnapchat = ''\nexport const nrkSomeTommelnedActive = ''\nexport const nrkSomeTommelned = ''\nexport const nrkSomeTommeloppActive = ''\nexport const nrkSomeTommelopp = ''\nexport const nrkSomeTwitter = ''\nexport const nrkSomeYoutube = ''\nexport const nrkSpinner = ''\nexport const nrkStarActive = ''\nexport const nrkStar = ''\nexport const nrkTilgjengelighetHorbarhet = ''\nexport const nrkTilgjengelighetLydtekst = ''\nexport const nrkTilgjengelighetSynstolking = ''\nexport const nrkTilgjengelighetTegnspraak = ''\nexport const nrkTilgjengelighet = ''\nexport const nrkTrashActive = ''\nexport const nrkTrash = ''\nexport const nrkUpload = ''\nexport const nrkUserLoggedinActive = ''\nexport const nrkUserLoggedin = ''\nexport const nrkUserNotloggedinActive = ''\nexport const nrkUserNotloggedin = ''\nexport const nrkWarning = ''","/**\n * Connect takes a callback that will be called after retrieving the users session\n * @example\n * connect((user, session) => {\n * if (user) {\n * console.log(`${user.name} is logged in`)\n * } else {\n * session.login({abortPath: '%2Fminside'})\n * }\n * })\n */\nexport function connect(callback) {\n const key = 'onLoginReady';\n // Add callback queue placeholder if needed\n if (window[key] === undefined) {\n window[key] = function () {\n (window[key].q = window[key].q || []).push(arguments);\n };\n }\n\n // load script if needed\n loadOnce('/logginn.js');\n\n // add callback\n window[key](callback);\n}\n\n/**\n * loadOnce loads the given script IFF it is not already present in the DOM.\n * @param {string} src URL for script\n * @returns {undefined}\n */\nfunction loadOnce(src) {\n const hasScript = document.querySelector(`script[src=\"${src}\"]`);\n\n if (hasScript) {\n return;\n }\n\n const script = document.createElement('script');\n script.async = true;\n script.src = src;\n\n document.head.appendChild(script);\n}\n","import { nrkClose } from '@nrk/core-icons';\n\nexport function initializeLoginBanner(window, userName, showCookieBanner) {\n const canReplaceState = window.history && window.history.replaceState\n const loginBanner = document.body.insertAdjacentElement('afterbegin', document.createElement('div'))\n\n loginBanner.className = 'nrk-masthead__info-banner nrk-masthead__info-banner--login'\n if (showCookieBanner) {\n loginBanner.style = 'display: none;'\n }\n loginBanner.innerHTML = `Hei, du er nå logget på NRK.no fordi du allerede er logget på med din NRK-profil på denne enheten`\n loginBanner\n .querySelector('button')\n .addEventListener('click', () => loginBanner.parentElement.removeChild(loginBanner))\n loginBanner.querySelector('.nrk-masthead__semibold').textContent = `Hei ${userName}` // Use textContent for security\n\n if (canReplaceState) {\n const href = window.location.href.replace(/autoLogin=true&?/, '').replace(/[?|&]$/, '')\n window.history.replaceState(window.history.state, document.title, href)\n }\n}\n\n\n\nexport function initializeCookieBanner(cookieName) {\n const cookieDialog = document.body.insertAdjacentElement('afterbegin', document.createElement('div'))\n\n cookieDialog.className = 'nrk-masthead__info-banner nrk-masthead__info-banner--cookie'\n cookieDialog.innerHTML = `Vi bruker informasjonskapsler for å forbedre brukeropplevelsen. Besøk vår informasjonsside for mer detaljer, eller finn lenken i bunnen av NRK.no.`\n cookieDialog.querySelector('button').addEventListener('click', () => {\n cookieDialog.parentElement.removeChild(cookieDialog)\n const loginBanner = document.querySelector('.nrk-masthead__info-banner--login')\n if (loginBanner) {\n loginBanner.removeAttribute('style')\n }\n const expirationDate = new Date()\n expirationDate.setTime(expirationDate.getTime() + 1000 * 24 * 60 * 60 * 1000)\n document.cookie = `${cookieName}=1; expires=${expirationDate.toUTCString()}; path=/;`\n })\n}\n\nwindow.initializeCookieBanner = initializeCookieBanner;\n\nwindow.initializeLoginBanner = initializeLoginBanner;","import coreToggle from '@nrk/core-toggle'\nimport { nrkUserLoggedin } from '@nrk/core-icons'\nimport { connect } from '@nrk/nrkno-login-connector'\nimport { initializeCookieBanner, initializeLoginBanner } from './nrkno-masthead-banners'\n\nexport function initialize() {\n if (typeof document === 'undefined') return\n registerMBLScript()\n\n coreToggle('.nrk-masthead__bars, .nrk-masthead__more', { popup: true })\n\n const loginLinks = document.querySelectorAll('.nrk-masthead__user a')\n const loginLinksArray = Array.from(loginLinks)\n\n const cookieInfoCookieName = 'nrkno-cookie-information'\n const darkmodeCookieName = 'nrkno-darkmode'\n const allCookies = document.cookie.split(';')\n\n const isApp = window.location.search.indexOf('header=off') > 0\n let showCookieBanner = isApp ? false : true\n allCookies.forEach((cookie) => {\n if (cookie.trim().substring(0, cookieInfoCookieName.length) === cookieInfoCookieName) {\n showCookieBanner = false\n }\n if (cookie.trim().substring(0, darkmodeCookieName.length) === darkmodeCookieName) {\n handleDarkmodeCookie(cookie)\n }\n })\n\n if (loginLinksArray && loginLinksArray.length > 0) {\n connect((user) => {\n if (user) {\n loginLinksArray.forEach((loginLink) => {\n loginLink.href = 'https://www.nrk.no/minside'\n const span = document.createElement('span')\n span.textContent = user.name\n loginLink.innerHTML = nrkUserLoggedin\n loginLink.appendChild(span)\n })\n const isAutoLogin = window.location.search.indexOf('autoLogin=true') >= 0\n\n if (isAutoLogin) {\n initializeLoginBanner(window, user.name, showCookieBanner)\n }\n }\n loginLinksArray.forEach((loginLink) => {\n loginLink.removeAttribute('hidden')\n })\n })\n }\n\n if (showCookieBanner) {\n initializeCookieBanner(cookieInfoCookieName)\n }\n\n handleJumpToContent()\n}\n/**\n * Find, if any, the disabled jumpAnchor and \"enable\" it.\n */\nfunction handleJumpToContent() {\n const jumpAnchor = document.querySelector('#nrk-masthead__jump-anchor[class~=\"nrk-masthead__jump-anchor--disabled\"]')\n\n if (!jumpAnchor) {\n return\n }\n\n const mainElement = getMainElement()\n if (!mainElement) {\n // retry incase dom not loaded yet\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', handleJumpToContent)\n }\n return\n }\n\n if (!mainElement.id) {\n mainElement.id = 'innhold'\n }\n\n jumpAnchor.setAttribute('href', `#${mainElement.id}`)\n jumpAnchor.classList.remove('nrk-masthead__jump-anchor--disabled')\n jumpAnchor.classList.add('nrk-masthead__jump-anchor--enabled')\n // no-op if listener has not been added\n document.removeEventListener('DOMContentLoaded', handleJumpToContent)\n}\n\n/**\n * @returns {Element | undefined} the `main` element or the _best-effort_ main element.\n */\nfunction getMainElement() {\n const mainElement = document.querySelector('main, [role=\"main\"], #innhold')\n\n if (mainElement) {\n return mainElement\n }\n\n const bestEffortMainElement = document.querySelector('nrkno-player, article a, a > figure')\n\n if (!bestEffortMainElement) {\n return\n }\n\n if (bestEffortMainElement.tagName === 'FIGURE') {\n // return the parent/`a` tag\n return bestEffortMainElement.parentElement\n }\n\n return bestEffortMainElement\n}\n\n// Appends MBL Script to
so that page views are tracked\nfunction registerMBLScript() {\n const mblScript = document.createElement('script')\n mblScript.type = 'text/javascript'\n mblScript.src = 'https://log.medietall.no/analytics.js'\n mblScript.async = true\n\n document.head.appendChild(mblScript)\n}\n\n// Check for darkmode cookie and set correct html-class\nfunction handleDarkmodeCookie (cookie) {\n const value = cookie.substring(cookie.indexOf('=') + 1)\n // If darkmode cookie is \"on\", or if it's \"auto\" and the use has darkmode preference set in the OS/browser\n const prefersDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;\n if (value && (value === 'on' || (value === 'auto' && prefersDarkMode))) {\n if (!document.documentElement.className.includes('darkmode')) {\n document.documentElement.classList.add('darkmode')\n }\n // NTB Livesport sets darkmode differently:\n const dataTheme = document.documentElement.getAttribute('data-theme')\n if (dataTheme && dataTheme === 'light') {\n document.documentElement.setAttribute('data-theme', 'dark')\n document.documentElement.style.colorScheme = 'dark'\n }\n }\n}\n","import {\n nrkLogoNrk,\n nrkChevronDown,\n nrkUserNotloggedin,\n nrkSearch\n} from '@nrk/core-icons'\n\n/**\n * @typedef {Object} MastheadOptions\n * @property {boolean} [dark=false]\n * @property {boolean} [login=true]\n * @property {boolean} [search=true]\n * @property {boolean} [minimal=false]\n * @property {string} [nonce]\n * @property {JumpAnchorManualOptions | JumpAnchorAutoOptions | false} [jumpAnchor=false]\n */\n\n/**\n * @typedef {Object} JumpAnchorAutoOptions\n * @property {'auto'} strategy\n * @property {never} [jumpToId='']\n */\n\n/**\n * @typedef {Object} JumpAnchorManualOptions\n * @property {'manual'} strategy\n * @property {`#${string}`} jumpToId MUST include `#`\n */\n\n/**\n * Masthead\n * @param {MastheadOptions} [options]\n * @returns {string} raw html markup\n */\nexport function Masthead (options) {\n const { dark = false, login = true, search = true, minimal = false, jumpAnchor = false } = options || {}\n\n let hideMasthead = false\n let isFrontPage = false\n\n if (typeof window !== 'undefined') {\n const searchParams = new URLSearchParams(window.location.search)\n isFrontPage = window.location.origin === 'https://www.nrk.no' && window.location.pathname === '/'\n const headerParam = searchParams.get('header')\n hideMasthead = headerParam === 'off'\n }\n\n return /*html*/ `