{"version":3,"file":"index.cjs","sources":["../src/history/getFirstNavigationEntry.ts","../src/history/isPageReload.ts","../src/ensurePrefix.ts","../src/url/createSafeURL.ts","../src/url/urlToPath.ts","../src/errors.ts"],"sourcesContent":["/**\n * Returns the first navigation entry from window.performance.\n * @returns First navigation entry or null, in case performance functionality is not supported\n * or navigation entry was not found.\n */\nexport function getFirstNavigationEntry(): PerformanceNavigationTiming | undefined {\n  return performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming | undefined;\n}\n","import { getFirstNavigationEntry } from './getFirstNavigationEntry.js';\n\n/**\n * @returns True, if the current page was reloaded.\n * @see https://stackoverflow.com/a/36444134/11894710\n */\nexport function isPageReload(): boolean {\n  const entry = getFirstNavigationEntry();\n  return !!entry && entry.type === 'reload';\n}\n","/**\n * Ensures that the specified value starts with the specified prefix. If it doesn't, function\n * appends it.\n * @param value - value to check.\n * @param prefix - prefix to add.\n * @returns Value with the prefix.\n */\nexport function ensurePrefix(value: string, prefix: string): string {\n  return value.startsWith(prefix) ? value : `${prefix}${value}`;\n}\n","import { ensurePrefix } from '@/ensurePrefix.js';\n\nimport type { URLLike } from './types.js';\n\n/**\n * Safely creates a new instance of URL with some predefined protocol \"http://\" and host \"a\".\n * @param urlOrPath - URL instance or path.\n */\nexport function createSafeURL(urlOrPath: string | Partial<URLLike>): URL {\n  return new URL(\n    typeof urlOrPath === 'string' ? urlOrPath : [\n      urlOrPath.pathname || '',\n      ensurePrefix(urlOrPath.search || '', '?'),\n      ensurePrefix(urlOrPath.hash || '', '#'),\n    ].join(''),\n    'http://a',\n  );\n}\n","import { createSafeURL } from './createSafeURL.js';\nimport type { URLLike } from './types.js';\n\n/**\n * Extracts path part from a URL.\n * @param urlOrPath - URL instance or path.\n */\nexport function urlToPath(urlOrPath: string | Partial<URLLike>): string {\n  const isAbsolute = (\n    typeof urlOrPath === 'string'\n      ? urlOrPath\n      : urlOrPath.pathname || ''\n  ).startsWith('/');\n  const url = createSafeURL(urlOrPath);\n  const { pathname } = url;\n\n  return `${isAbsolute ? pathname : pathname.slice(1)}${url.search}${url.hash}`;\n}\n","export const ERR_HISTORY_EMPTY = 'ERR_NAVIGATION_HISTORY_EMPTY';\nexport const ERR_CURSOR_INVALID = 'ERR_NAVIGATION_CURSOR_INVALID';"],"names":["getFirstNavigationEntry","isPageReload","entry","ensurePrefix","value","prefix","createSafeURL","urlOrPath","urlToPath","isAbsolute","url","pathname","ERR_HISTORY_EMPTY","ERR_CURSOR_INVALID"],"mappings":"gFAKO,SAASA,GAAmE,CACjF,OAAO,YAAY,iBAAiB,YAAY,EAAE,CAAC,CACrD,CCDO,SAASC,GAAwB,CACtC,MAAMC,EAAQF,EAAwB,EACtC,MAAO,CAAC,CAACE,GAASA,EAAM,OAAS,QACnC,CCFgB,SAAAC,EAAaC,EAAeC,EAAwB,CAC3D,OAAAD,EAAM,WAAWC,CAAM,EAAID,EAAQ,GAAGC,CAAM,GAAGD,CAAK,EAC7D,CCDO,SAASE,EAAcC,EAA2C,CACvE,OAAO,IAAI,IACT,OAAOA,GAAc,SAAWA,EAAY,CAC1CA,EAAU,UAAY,GACtBJ,EAAaI,EAAU,QAAU,GAAI,GAAG,EACxCJ,EAAaI,EAAU,MAAQ,GAAI,GAAG,CAAA,EACtC,KAAK,EAAE,EACT,UACF,CACF,CCVO,SAASC,EAAUD,EAA8C,CAChE,MAAAE,GACJ,OAAOF,GAAc,SACjBA,EACAA,EAAU,UAAY,IAC1B,WAAW,GAAG,EACVG,EAAMJ,EAAcC,CAAS,EAC7B,CAAE,SAAAI,GAAaD,EAErB,MAAO,GAAGD,EAAaE,EAAWA,EAAS,MAAM,CAAC,CAAC,GAAGD,EAAI,MAAM,GAAGA,EAAI,IAAI,EAC7E,CCjBO,MAAME,EAAoB,+BACpBC,EAAqB"}