1import{createLogger}from"publishercore/logger";const SCROLL_KEY="search:scrollY",log=createLogger("searchScrollState");function saveScrollPosition(){sessionStorage.setItem(SCROLL_KEY,String(window.scrollY))}function restoreScrollPosition(){const e=sessionStorage.getItem(SCROLL_KEY);if(!e)return;window.scrollTo(0,Number(e)),sessionStorage.removeItem(SCROLL_KEY)}export function initSearchScrollState(e){if(!(e instanceof Element))return log.warn("initSearchScrollState called with a non-Element root",e),()=>{};if(e.dataset.searchScrollStateInitialized==="1")return restoreScrollPosition(),()=>{};const t=[...e.querySelectorAll("a")];return t.forEach(e=>{e.addEventListener("click",saveScrollPosition)}),e.dataset.searchScrollStateInitialized="1",restoreScrollPosition(),()=>{t.forEach(e=>{e.removeEventListener("click",saveScrollPosition)}),delete e.dataset.searchScrollStateInitialized}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.