{ "version": 3, "sources": ["../../../Vettvangur.Frontend/src/scripts/utility/prefetch.ts"], "sourcesContent": ["const prefetch = {\n init() {\n // Event delegation used as there may be hundreds of same-site links on a page:\n document.body.addEventListener('mouseover', this.worker)\n },\n worker(event) {\n const target = event.target\n\n // Not a link? - if so exit\n if (target.tagName !== 'A') {\n return\n }\n\n // Read the attribute rather than the property!\n // - because the property is the full https:// address\n const href = target.getAttribute('href')\n\n // No href, or not a same-site link? - if so exit\n // - link attribute must start with a backslash\n if (!href || href.charAt(0) !== '/') {\n return\n }\n\n // Already prefetched? - if so exit\n const isAlreadyAdded = document.head.querySelector(`link[href=\"${href}\"]`)\n if (isAlreadyAdded) {\n return\n }\n\n // Is the same page? - if so exit\n const isSamePage = target.pathname === window.location.pathname\n if (isSamePage) {\n return\n }\n\n // Add prefetch link to head section\n const link = document.createElement('link')\n link.rel = 'prefetch'\n link.href = href\n document.head.appendChild(link)\n },\n}\n\nexport default prefetch\n"], "mappings": "gCAAA,IAAMA,EAAW,CACf,MAAO,CAEL,SAAS,KAAK,iBAAiB,YAAa,KAAK,MAAM,CACzD,EACA,OAAOC,EAAO,CACZ,IAAMC,EAASD,EAAM,OAGrB,GAAIC,EAAO,UAAY,IACrB,OAKF,IAAMC,EAAOD,EAAO,aAAa,MAAM,EAgBvC,GAZI,CAACC,GAAQA,EAAK,OAAO,CAAC,IAAM,KAKT,SAAS,KAAK,cAAc,cAAcA,KAAQ,GAMtDD,EAAO,WAAa,OAAO,SAAS,SAErD,OAIF,IAAME,EAAO,SAAS,cAAc,MAAM,EAC1CA,EAAK,IAAM,WACXA,EAAK,KAAOD,EACZ,SAAS,KAAK,YAAYC,CAAI,CAChC,CACF,EAEOC,EAAQL", "names": ["prefetch", "event", "target", "href", "link", "prefetch_default"] }