{"version":3,"file":"Swup.umd.js","sources":["../src/helpers/classify.ts","../src/helpers/getCurrentUrl.ts","../src/helpers/createHistoryRecord.ts","../src/helpers/updateHistoryRecord.ts","../node_modules/delegate-it/delegate.js","../src/helpers/delegateEvent.ts","../src/helpers/Location.ts","../src/modules/Cache.ts","../src/utils/index.ts","../src/modules/Classes.ts","../src/modules/Visit.ts","../src/modules/Hooks.ts","../src/modules/getAnchorElement.ts","../src/modules/awaitAnimations.ts","../src/modules/navigate.ts","../src/modules/fetchPage.ts","../src/modules/animatePageOut.ts","../src/modules/replaceContent.ts","../src/modules/scrollToContent.ts","../src/modules/animatePageIn.ts","../src/modules/renderPage.ts","../src/modules/plugins.ts","../src/modules/resolveUrl.ts","../src/Swup.ts"],"sourcesContent":["/** Turn a string into a slug by lowercasing and replacing whitespace. */\nexport const classify = (text: string, fallback?: string): string => {\n\tconst output = String(text)\n\t\t.toLowerCase()\n\t\t// .normalize('NFD') // split an accented letter in the base letter and the acent\n\t\t// .replace(/[\\u0300-\\u036f]/g, '') // remove all previously split accents\n\t\t.replace(/[\\s/_.]+/g, '-') // replace spaces and _./ with '-'\n\t\t.replace(/[^\\w-]+/g, '') // remove all non-word chars\n\t\t.replace(/--+/g, '-') // replace repeating '-' with single '-'\n\t\t.replace(/^-+|-+$/g, ''); // trim '-' from edges\n\treturn output || fallback || '';\n};\n","/** Get the current page URL: path name + query params. Optionally including hash. */\nexport const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {\n\treturn location.pathname + location.search + (hash ? location.hash : '');\n};\n","import { getCurrentUrl } from './getCurrentUrl.js';\n\nexport interface HistoryState {\n\turl: string;\n\tsource: 'swup';\n\trandom: number;\n\tindex?: number;\n\t[key: string]: unknown;\n}\n\n/** Create a new history record with a custom swup identifier. */\nexport const createHistoryRecord = (\n\turl: string,\n\tcustomData: Record = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data: HistoryState = {\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.pushState(data, '', url);\n};\n","import { HistoryState } from './createHistoryRecord.js';\nimport { getCurrentUrl } from './getCurrentUrl.js';\n\n/** Update the current history record with a custom swup identifier. */\nexport const updateHistoryRecord = (\n\turl: string | null = null,\n\tcustomData: Record = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst state = (history.state as HistoryState) || {};\n\tconst data: HistoryState = {\n\t\t...state,\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.replaceState(data, '', url);\n};\n","/** Keeps track of raw listeners added to the base elements to avoid duplication */\nconst ledger = new WeakMap();\nfunction editLedger(wanted, baseElement, callback, setup) {\n if (!wanted && !ledger.has(baseElement)) {\n return false;\n }\n const elementMap = ledger.get(baseElement)\n ?? new WeakMap();\n ledger.set(baseElement, elementMap);\n const setups = elementMap.get(callback) ?? new Set();\n elementMap.set(callback, setups);\n const existed = setups.has(setup);\n if (wanted) {\n setups.add(setup);\n }\n else {\n setups.delete(setup);\n }\n return existed && wanted;\n}\nfunction safeClosest(event, selector) {\n let target = event.target;\n if (target instanceof Text) {\n target = target.parentElement;\n }\n if (target instanceof Element && event.currentTarget instanceof Element) {\n // `.closest()` may match ancestors of `currentTarget` but we only need its children\n const closest = target.closest(selector);\n if (closest && event.currentTarget.contains(closest)) {\n return closest;\n }\n }\n}\n// This type isn't exported as a declaration, so it needs to be duplicated above\nfunction delegate(selector, type, callback, options = {}) {\n const { signal, base = document } = options;\n if (signal?.aborted) {\n return;\n }\n // Don't pass `once` to `addEventListener` because it needs to be handled in `delegate-it`\n const { once, ...nativeListenerOptions } = options;\n // `document` should never be the base, it's just an easy way to define \"global event listeners\"\n const baseElement = base instanceof Document ? base.documentElement : base;\n // Handle the regular Element usage\n const capture = Boolean(typeof options === 'object' ? options.capture : options);\n const listenerFn = (event) => {\n const delegateTarget = safeClosest(event, selector);\n if (delegateTarget) {\n const delegateEvent = Object.assign(event, { delegateTarget });\n callback.call(baseElement, delegateEvent);\n if (once) {\n baseElement.removeEventListener(type, listenerFn, nativeListenerOptions);\n editLedger(false, baseElement, callback, setup);\n }\n }\n };\n const setup = JSON.stringify({ selector, type, capture });\n const isAlreadyListening = editLedger(true, baseElement, callback, setup);\n if (!isAlreadyListening) {\n baseElement.addEventListener(type, listenerFn, nativeListenerOptions);\n }\n signal?.addEventListener('abort', () => {\n editLedger(false, baseElement, callback, setup);\n });\n}\nexport default delegate;\n","import delegate, { DelegateEventHandler, DelegateOptions, EventType } from 'delegate-it';\nimport { ParseSelector } from 'typed-query-selector/parser.js';\n\nexport type DelegateEventUnsubscribe = {\n\tdestroy: () => void;\n};\n\n/** Register a delegated event listener. */\nexport const delegateEvent = <\n\tSelector extends string,\n\tTElement extends Element = ParseSelector,\n\tTEvent extends EventType = EventType\n>(\n\tselector: Selector,\n\ttype: TEvent,\n\tcallback: DelegateEventHandler,\n\toptions?: DelegateOptions\n): DelegateEventUnsubscribe => {\n\tconst controller = new AbortController();\n\toptions = { ...options, signal: controller.signal };\n\tdelegate(selector, type, callback, options);\n\treturn { destroy: () => controller.abort() };\n};\n","/**\n * A helper for creating a Location from either an element\n * or a URL object/string\n *\n */\nexport class Location extends URL {\n\tconstructor(url: URL | string, base: string = document.baseURI) {\n\t\tsuper(url.toString(), base);\n\t}\n\n\t/**\n\t * The full local path including query params.\n\t */\n\tget url(): string {\n\t\treturn this.pathname + this.search;\n\t}\n\n\t/**\n\t * Instantiate a Location from an element's href attribute\n\t * @param el\n\t * @returns new Location instance\n\t */\n\tstatic fromElement(el: Element): Location {\n\t\tconst href = el.getAttribute('href') || el.getAttribute('xlink:href') || '';\n\t\treturn new Location(href);\n\t}\n\n\t/**\n\t * Instantiate a Location from a URL object or string\n\t * @param url\n\t * @returns new Location instance\n\t */\n\tstatic fromUrl(url: URL | string): Location {\n\t\treturn new Location(url);\n\t}\n}\n","import Swup from '../Swup.js';\nimport { Location } from '../helpers.js';\nimport { PageData } from './fetchPage.js';\n\nexport interface CacheData extends PageData {}\n\n/**\n * In-memory page cache.\n */\nexport class Cache {\n\t/** Swup instance this cache belongs to */\n\tprotected swup: Swup;\n\n\t/** Cached pages, indexed by URL */\n\tprotected pages: Map = new Map();\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\t/** Number of cached pages in memory. */\n\tget size(): number {\n\t\treturn this.pages.size;\n\t}\n\n\t/** All cached pages. */\n\tget all() {\n\t\tconst copy = new Map();\n\t\tthis.pages.forEach((page, key) => {\n\t\t\tcopy.set(key, { ...page });\n\t\t});\n\t\treturn copy;\n\t}\n\n\t/** Check if the given URL has been cached. */\n\thas(url: string): boolean {\n\t\treturn this.pages.has(this.resolve(url));\n\t}\n\n\t/** Return a shallow copy of the cached page object if available. */\n\tget(url: string): CacheData | undefined {\n\t\tconst result = this.pages.get(this.resolve(url));\n\t\tif (!result) return result;\n\t\treturn { ...result };\n\t}\n\n\t/** Create a cache record for the specified URL. */\n\tset(url: string, page: CacheData) {\n\t\turl = this.resolve(url);\n\t\tpage = { ...page, url };\n\t\tthis.pages.set(url, page);\n\t\tthis.swup.hooks.callSync('cache:set', { page });\n\t}\n\n\t/** Update a cache record, overwriting or adding custom data. */\n\tupdate(url: string, payload: object) {\n\t\turl = this.resolve(url);\n\t\tconst page = { ...this.get(url), ...payload, url } as CacheData;\n\t\tthis.pages.set(url, page);\n\t}\n\n\t/** Delete a cache record. */\n\tdelete(url: string): void {\n\t\tthis.pages.delete(this.resolve(url));\n\t}\n\n\t/** Empty the cache. */\n\tclear(): void {\n\t\tthis.pages.clear();\n\t\tthis.swup.hooks.callSync('cache:clear', undefined);\n\t}\n\n\t/** Remove all cache entries that return true for a given predicate function. */\n\tprune(predicate: (url: string, page: CacheData) => boolean): void {\n\t\tthis.pages.forEach((page, url) => {\n\t\t\tif (predicate(url, page)) {\n\t\t\t\tthis.delete(url);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Resolve URLs by making them local and letting swup resolve them. */\n\tprotected resolve(urlToResolve: string): string {\n\t\tconst { url } = Location.fromUrl(urlToResolve);\n\t\treturn this.swup.resolveUrl(url);\n\t}\n}\n","/** Find an element by selector. */\nexport const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector(selector);\n};\n\n/** Find a set of elements by selector. */\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\n/** Return a Promise that resolves after the next event loop. */\nexport const nextTick = (): Promise => {\n\treturn new Promise((resolve) => {\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t});\n};\n\n/** Check if an object is a Promise or a Thenable */\nexport function isPromise(obj: unknown): obj is PromiseLike {\n\treturn (\n\t\t!!obj &&\n\t\t(typeof obj === 'object' || typeof obj === 'function') &&\n\t\ttypeof (obj as Record).then === 'function'\n\t);\n}\n\n/** Call a function as a Promise. Resolves with the returned Promsise or immediately. */\n// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any\nexport function runAsPromise(func: Function, args: unknown[] = []): Promise {\n\treturn new Promise((resolve, reject) => {\n\t\tconst result: unknown = func(...args);\n\t\tif (isPromise(result)) {\n\t\t\tresult.then(resolve, reject);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n}\n\n/**\n * Force a layout reflow, e.g. after adding classnames\n * @returns The offset height, just here so it doesn't get optimized away by the JS engine\n * @see https://stackoverflow.com/a/21665117/3759615\n */\nexport function forceReflow(element?: HTMLElement) {\n\telement = element || document.body;\n\treturn element?.offsetHeight;\n}\n\n/** Escape a string with special chars to not break CSS selectors. */\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t}\n\treturn ident;\n};\n\n/** Fix for Chrome below v61 formatting CSS floats with comma in some locales. */\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n","import Swup from '../Swup.js';\nimport { queryAll } from '../utils.js';\n\nexport class Classes {\n\tprotected swup: Swup;\n\tprotected swupClasses = ['to-', 'is-changing', 'is-rendering', 'is-popstate', 'is-animating'];\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\tprotected get selectors(): string[] {\n\t\tconst { scope } = this.swup.visit.animation;\n\t\tif (scope === 'containers') return this.swup.visit.containers;\n\t\tif (scope === 'html') return ['html'];\n\t\tif (Array.isArray(scope)) return scope;\n\t\treturn [];\n\t}\n\n\tprotected get selector(): string {\n\t\treturn this.selectors.join(',');\n\t}\n\n\tprotected get targets(): HTMLElement[] {\n\t\tif (!this.selector.trim()) return [];\n\t\treturn queryAll(this.selector);\n\t}\n\n\tadd(...classes: string[]): void {\n\t\tthis.targets.forEach((target) => target.classList.add(...classes));\n\t}\n\n\tremove(...classes: string[]): void {\n\t\tthis.targets.forEach((target) => target.classList.remove(...classes));\n\t}\n\n\tclear(): void {\n\t\tthis.targets.forEach((target) => {\n\t\t\tconst remove = target.className.split(' ').filter((c) => this.isSwupClass(c));\n\t\t\ttarget.classList.remove(...remove);\n\t\t});\n\t}\n\n\tprotected isSwupClass(className: string): boolean {\n\t\treturn this.swupClasses.some((c) => className.startsWith(c));\n\t}\n}\n","import Swup, { Options } from '../Swup.js';\nimport { HistoryAction, HistoryDirection } from './navigate.js';\n\n/** An object holding details about the current visit. */\nexport interface Visit {\n\t/** The previous page, about to leave */\n\tfrom: VisitFrom;\n\t/** The next page, about to enter */\n\tto: VisitTo;\n\t/** The content containers, about to be replaced */\n\tcontainers: Options['containers'];\n\t/** Information about animated page transitions */\n\tanimation: VisitAnimation;\n\t/** What triggered this visit */\n\ttrigger: VisitTrigger;\n\t/** Cache behavior for this visit */\n\tcache: VisitCache;\n\t/** Browser history behavior on this visit */\n\thistory: VisitHistory;\n\t/** Scroll behavior on this visit */\n\tscroll: VisitScroll;\n}\n\nexport interface VisitFrom {\n\t/** The URL of the previous page */\n\turl: string;\n}\n\nexport interface VisitTo {\n\t/** The URL of the next page */\n\turl: string;\n\t/** The hash of the next page */\n\thash?: string;\n\t/** The HTML content of the next page */\n\thtml?: string;\n}\n\nexport interface VisitAnimation {\n\t/** Whether this visit is animated. Default: `true` */\n\tanimate: boolean;\n\t/** Whether to wait for the next page to load before starting the animation. Default: `false` */\n\twait: boolean;\n\t/** Name of a custom animation to run. */\n\tname?: string;\n\t/** Elements on which to add animation classes. Default: `html` element */\n\tscope: 'html' | 'containers' | string[];\n\t/** Selector for detecting animation timing. Default: `[class*=\"transition-\"]` */\n\tselector: Options['animationSelector'];\n}\n\nexport interface VisitScroll {\n\t/** Whether to reset the scroll position after the visit. Default: `true` */\n\treset: boolean;\n\t/** Anchor element to scroll to on the next page. */\n\ttarget?: string | false;\n}\n\nexport interface VisitTrigger {\n\t/** DOM element that triggered this visit. */\n\tel?: Element;\n\t/** DOM event that triggered this visit. */\n\tevent?: Event;\n}\n\nexport interface VisitCache {\n\t/** Whether this visit will try to load the requested page from cache. */\n\tread: boolean;\n\t/** Whether this visit will save the loaded page in cache. */\n\twrite: boolean;\n}\n\nexport interface VisitHistory {\n\t/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */\n\taction: HistoryAction;\n\t/** Whether this visit was triggered by a browser history navigation. */\n\tpopstate: boolean;\n\t/** The direction of travel in case of a browser history navigation: backward or forward. */\n\tdirection: HistoryDirection | undefined;\n}\n\nexport interface VisitInitOptions {\n\tto: string;\n\tfrom?: string;\n\thash?: string;\n\tel?: Element;\n\tevent?: Event;\n}\n\n/** Create a new visit object. */\nexport function createVisit(\n\tthis: Swup,\n\t{ to, from = this.currentPageUrl, hash, el, event }: VisitInitOptions\n): Visit {\n\treturn {\n\t\tfrom: { url: from },\n\t\tto: { url: to, hash },\n\t\tcontainers: this.options.containers,\n\t\tanimation: {\n\t\t\tanimate: true,\n\t\t\twait: false,\n\t\t\tname: undefined,\n\t\t\tscope: this.options.animationScope,\n\t\t\tselector: this.options.animationSelector\n\t\t},\n\t\ttrigger: {\n\t\t\tel,\n\t\t\tevent\n\t\t},\n\t\tcache: {\n\t\t\tread: this.options.cache,\n\t\t\twrite: this.options.cache\n\t\t},\n\t\thistory: {\n\t\t\taction: 'push',\n\t\t\tpopstate: false,\n\t\t\tdirection: undefined\n\t\t},\n\t\tscroll: {\n\t\t\treset: true,\n\t\t\ttarget: undefined\n\t\t}\n\t};\n}\n","import { DelegateEvent } from 'delegate-it';\n\nimport Swup from '../Swup.js';\nimport { isPromise, runAsPromise } from '../utils.js';\nimport { Visit } from './Visit.js';\nimport { FetchOptions, PageData } from './fetchPage.js';\n\nexport interface HookDefinitions {\n\t'animation:out:start': undefined;\n\t'animation:out:await': { skip: boolean };\n\t'animation:out:end': undefined;\n\t'animation:in:start': undefined;\n\t'animation:in:await': { skip: boolean };\n\t'animation:in:end': undefined;\n\t'animation:skip': undefined;\n\t'cache:clear': undefined;\n\t'cache:set': { page: PageData };\n\t'content:replace': { page: PageData };\n\t'content:scroll': undefined;\n\t'enable': undefined;\n\t'disable': undefined;\n\t'fetch:request': { url: string; options: FetchOptions };\n\t'fetch:error': { url: string; status: number; response: Response };\n\t'history:popstate': { event: PopStateEvent };\n\t'link:click': { el: HTMLAnchorElement; event: DelegateEvent };\n\t'link:self': undefined;\n\t'link:anchor': { hash: string };\n\t'link:newtab': { href: string };\n\t'page:load': { page?: PageData; cache?: boolean; options: FetchOptions };\n\t'page:view': { url: string; title: string };\n\t'scroll:top': { options: ScrollIntoViewOptions };\n\t'scroll:anchor': { hash: string; options: ScrollIntoViewOptions };\n\t'visit:start': undefined;\n\t'visit:end': undefined;\n}\n\nexport interface HookReturnValues {\n\t'content:scroll': Promise;\n\t'fetch:request': Promise;\n\t'page:load': Promise;\n\t'scroll:top': boolean;\n\t'scroll:anchor': boolean;\n}\n\nexport type HookArguments = HookDefinitions[T];\n\nexport type HookName = keyof HookDefinitions;\n\n/** A generic hook handler. */\nexport type Handler = (\n\t/** Context about the current visit. */\n\tvisit: Visit,\n\t/** Local arguments passed into the handler. */\n\targs: HookArguments\n) => Promise | unknown;\n\n/** A default hook handler with an expected return type. */\nexport type DefaultHandler = (\n\t/** Context about the current visit. */\n\tvisit: Visit,\n\t/** Local arguments passed into the handler. */\n\targs: HookArguments,\n\t/** Default handler to be executed. Available if replacing an internal hook handler. */\n\tdefaultHandler?: DefaultHandler\n) => T extends keyof HookReturnValues ? HookReturnValues[T] : Promise | unknown;\n\nexport type Handlers = {\n\t[K in HookName]: Handler[];\n};\n\n/** Unregister a previously registered hook handler. */\nexport type HookUnregister = () => void;\n\n/** Define when and how a hook handler is executed. */\nexport type HookOptions = {\n\t/** Execute the hook once, then remove the handler */\n\tonce?: boolean;\n\t/** Execute the hook before the internal default handler */\n\tbefore?: boolean;\n\t/** Set a priority for when to execute this hook. Lower numbers execute first. Default: `0` */\n\tpriority?: number;\n\t/** Replace the internal default handler with this hook handler */\n\treplace?: boolean;\n};\n\nexport type HookRegistration<\n\tT extends HookName,\n\tH extends Handler | DefaultHandler = Handler\n> = {\n\tid: number;\n\thook: T;\n\thandler: H;\n\tdefaultHandler?: DefaultHandler;\n} & HookOptions;\n\ntype HookLedger = Map, HookRegistration>;\n\ninterface HookRegistry extends Map> {\n\tget(key: K): HookLedger | undefined;\n\tset(key: K, value: HookLedger): this;\n}\n\n/**\n * Hook registry.\n *\n * Create, trigger and handle hooks.\n *\n */\nexport class Hooks {\n\t/** Swup instance this registry belongs to */\n\tprotected swup: Swup;\n\n\t/** Map of all registered hook handlers. */\n\tprotected registry: HookRegistry = new Map();\n\n\t// Can we deduplicate this somehow? Or make it error when not in sync with HookDefinitions?\n\t// https://stackoverflow.com/questions/53387838/how-to-ensure-an-arrays-values-the-keys-of-a-typescript-interface/53395649\n\tprotected readonly hooks: HookName[] = [\n\t\t'animation:out:start',\n\t\t'animation:out:await',\n\t\t'animation:out:end',\n\t\t'animation:in:start',\n\t\t'animation:in:await',\n\t\t'animation:in:end',\n\t\t'animation:skip',\n\t\t'cache:clear',\n\t\t'cache:set',\n\t\t'content:replace',\n\t\t'content:scroll',\n\t\t'enable',\n\t\t'disable',\n\t\t'fetch:request',\n\t\t'fetch:error',\n\t\t'history:popstate',\n\t\t'link:click',\n\t\t'link:self',\n\t\t'link:anchor',\n\t\t'link:newtab',\n\t\t'page:load',\n\t\t'page:view',\n\t\t'scroll:top',\n\t\t'scroll:anchor',\n\t\t'visit:start',\n\t\t'visit:end'\n\t];\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t\tthis.init();\n\t}\n\n\t/**\n\t * Create ledgers for all core hooks.\n\t */\n\tprotected init() {\n\t\tthis.hooks.forEach((hook) => this.create(hook));\n\t}\n\n\t/**\n\t * Create a new hook type.\n\t */\n\tcreate(hook: string) {\n\t\tif (!this.registry.has(hook as HookName)) {\n\t\t\tthis.registry.set(hook as HookName, new Map());\n\t\t}\n\t}\n\n\t/**\n\t * Check if a hook type exists.\n\t */\n\texists(hook: HookName): boolean {\n\t\treturn this.registry.has(hook);\n\t}\n\n\t/**\n\t * Get the ledger with all registrations for a hook.\n\t */\n\tprotected get(hook: T): HookLedger | undefined {\n\t\tconst ledger = this.registry.get(hook);\n\t\tif (ledger) {\n\t\t\treturn ledger;\n\t\t}\n\t\tconsole.error(`Unknown hook '${hook}'`);\n\t}\n\n\t/**\n\t * Remove all handlers of all hooks.\n\t */\n\tclear() {\n\t\tthis.registry.forEach((ledger) => ledger.clear());\n\t}\n\n\t/**\n\t * Register a new hook handler.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Object to specify how and when the handler is executed\n\t * Available options:\n\t * - `once`: Only execute the handler once\n\t * - `before`: Execute the handler before the default handler\n\t * - `priority`: Specify the order in which the handlers are executed\n\t * - `replace`: Replace the default handler with this handler\n\t * @returns A function to unregister the handler\n\t */\n\n\t// Overload: replacing default handler\n\ton(hook: T, handler: DefaultHandler, options: O & { replace: true }): HookUnregister; // prettier-ignore\n\t// Overload: passed in handler options\n\ton(hook: T, handler: Handler, options: O): HookUnregister; // prettier-ignore\n\t// Overload: no handler options\n\ton(hook: T, handler: Handler): HookUnregister; // prettier-ignore\n\t// Implementation\n\ton(\n\t\thook: T,\n\t\thandler: O['replace'] extends true ? DefaultHandler : Handler,\n\t\toptions: Partial = {}\n\t): HookUnregister {\n\t\tconst ledger = this.get(hook);\n\t\tif (!ledger) {\n\t\t\tconsole.warn(`Hook '${hook}' not found.`);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst id = ledger.size + 1;\n\t\tconst registration: HookRegistration = { ...options, id, hook, handler };\n\t\tledger.set(handler, registration);\n\n\t\treturn () => this.off(hook, handler);\n\t}\n\n\t/**\n\t * Register a new hook handler to run before the default handler.\n\t * Shortcut for `hooks.on(hook, handler, { before: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @returns A function to unregister the handler\n\t * @see on\n\t */\n\t// Overload: passed in handler options\n\tbefore(hook: T, handler: Handler, options: HookOptions): HookUnregister;\n\t// Overload: no handler options\n\tbefore(hook: T, handler: Handler): HookUnregister;\n\t// Implementation\n\tbefore(\n\t\thook: T,\n\t\thandler: Handler,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, before: true });\n\t}\n\n\t/**\n\t * Register a new hook handler to replace the default handler.\n\t * Shortcut for `hooks.on(hook, handler, { replace: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute instead of the default handler\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @returns A function to unregister the handler\n\t * @see on\n\t */\n\t// Overload: passed in handler options\n\treplace(hook: T, handler: DefaultHandler, options: HookOptions): HookUnregister; // prettier-ignore\n\t// Overload: no handler options\n\treplace(hook: T, handler: DefaultHandler): HookUnregister; // prettier-ignore\n\t// Implementation\n\treplace(\n\t\thook: T,\n\t\thandler: DefaultHandler,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, replace: true });\n\t}\n\n\t/**\n\t * Register a new hook handler to run once.\n\t * Shortcut for `hooks.on(hook, handler, { once: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @see on\n\t */\n\t// Overload: passed in handler options\n\tonce(hook: T, handler: Handler, options: HookOptions): HookUnregister;\n\t// Overload: no handler options\n\tonce(hook: T, handler: Handler): HookUnregister;\n\t// Implementation\n\tonce(\n\t\thook: T,\n\t\thandler: Handler,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, once: true });\n\t}\n\n\t/**\n\t * Unregister a hook handler.\n\t * @param hook Name of the hook the handler is registered for\n\t * @param handler The handler function that was registered.\n\t * If omitted, all handlers for the hook will be removed.\n\t */\n\t// Overload: unregister a specific handler\n\toff(hook: T, handler: Handler | DefaultHandler): void;\n\t// Overload: unregister all handlers\n\toff(hook: T): void;\n\t// Implementation\n\toff(hook: T, handler?: Handler | DefaultHandler): void {\n\t\tconst ledger = this.get(hook);\n\t\tif (ledger && handler) {\n\t\t\tconst deleted = ledger.delete(handler);\n\t\t\tif (!deleted) {\n\t\t\t\tconsole.warn(`Handler for hook '${hook}' not found.`);\n\t\t\t}\n\t\t} else if (ledger) {\n\t\t\tledger.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Trigger a hook asynchronously, executing its default handler and all registered handlers.\n\t * Will execute all handlers in order and `await` any `Promise`s they return.\n\t * @param hook Name of the hook to trigger\n\t * @param args Arguments to pass to the handler\n\t * @param defaultHandler A default implementation of this hook to execute\n\t * @returns The resolved return value of the executed default handler\n\t */\n\tasync call(\n\t\thook: T,\n\t\targs: HookArguments,\n\t\tdefaultHandler?: DefaultHandler\n\t): Promise>>> {\n\t\tconst { before, handler, after } = this.getHandlers(hook, defaultHandler);\n\t\tawait this.run(before, args);\n\t\tconst [result] = await this.run(handler, args);\n\t\tawait this.run(after, args);\n\t\tthis.dispatchDomEvent(hook, args);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Trigger a hook synchronously, executing its default handler and all registered handlers.\n\t * Will execute all handlers in order, but will **not** `await` any `Promise`s they return.\n\t * @param hook Name of the hook to trigger\n\t * @param args Arguments to pass to the handler\n\t * @param defaultHandler A default implementation of this hook to execute\n\t * @returns The (possibly unresolved) return value of the executed default handler\n\t */\n\tcallSync(\n\t\thook: T,\n\t\targs: HookArguments,\n\t\tdefaultHandler?: DefaultHandler\n\t): ReturnType> {\n\t\tconst { before, handler, after } = this.getHandlers(hook, defaultHandler);\n\t\tthis.runSync(before, args);\n\t\tconst [result] = this.runSync(handler, args);\n\t\tthis.runSync(after, args);\n\t\tthis.dispatchDomEvent(hook, args);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Execute the handlers for a hook, in order, as `Promise`s that will be `await`ed.\n\t * @param registrations The registrations (handler + options) to execute\n\t * @param args Arguments to pass to the handler\n\t */\n\n\t// Overload: running DefaultHandler: expect DefaultHandler return type\n\tprotected async run(registrations: HookRegistration>[], args: HookArguments): Promise>>[]>; // prettier-ignore\n\t// Overload: running user handler: expect no specific type\n\tprotected async run(registrations: HookRegistration[], args: HookArguments): Promise; // prettier-ignore\n\t// Implementation\n\tprotected async run[]>(\n\t\tregistrations: R,\n\t\targs: HookArguments\n\t): Promise>> | unknown[]> {\n\t\tconst results = [];\n\t\tfor (const { hook, handler, defaultHandler, once } of registrations) {\n\t\t\tconst result = await runAsPromise(handler, [this.swup.visit, args, defaultHandler]);\n\t\t\tresults.push(result);\n\t\t\tif (once) {\n\t\t\t\tthis.off(hook, handler);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Execute the handlers for a hook, in order, without `await`ing any returned `Promise`s.\n\t * @param registrations The registrations (handler + options) to execute\n\t * @param args Arguments to pass to the handler\n\t */\n\n\t// Overload: running DefaultHandler: expect DefaultHandler return type\n\tprotected runSync(registrations: HookRegistration>[], args: HookArguments ): ReturnType>[]; // prettier-ignore\n\t// Overload: running user handler: expect no specific type\n\tprotected runSync(registrations: HookRegistration[], args: HookArguments): unknown[]; // prettier-ignore\n\t// Implementation\n\tprotected runSync[]>(\n\t\tregistrations: R,\n\t\targs: HookArguments\n\t): (ReturnType> | unknown)[] {\n\t\tconst results = [];\n\t\tfor (const { hook, handler, defaultHandler, once } of registrations) {\n\t\t\tconst result = (handler as DefaultHandler)(this.swup.visit, args, defaultHandler);\n\t\t\tresults.push(result);\n\t\t\tif (isPromise(result)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Promise returned from handler for synchronous hook '${hook}'.` +\n\t\t\t\t\t\t`Swup will not wait for it to resolve.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (once) {\n\t\t\t\tthis.off(hook, handler);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Get all registered handlers for a hook, sorted by priority and registration order.\n\t * @param hook Name of the hook\n\t * @param defaultHandler The optional default handler of this hook\n\t * @returns An object with the handlers sorted into `before` and `after` arrays,\n\t * as well as a flag indicating if the original handler was replaced\n\t */\n\tprotected getHandlers(hook: T, defaultHandler?: DefaultHandler) {\n\t\tconst ledger = this.get(hook);\n\t\tif (!ledger) {\n\t\t\treturn { found: false, before: [], handler: [], after: [], replaced: false };\n\t\t}\n\n\t\tconst registrations = Array.from(ledger.values());\n\n\t\t// Let TypeScript know that replaced handlers are default handlers by filtering to true\n\t\tconst def = (T: HookRegistration): T is HookRegistration> => true;\n\t\tconst sort = this.sortRegistrations;\n\n\t\t// Filter into before, after, and replace handlers\n\t\tconst before = registrations.filter(({ before, replace }) => before && !replace).sort(sort);\n\t\tconst replace = registrations.filter(({ replace }) => replace).filter(def).sort(sort); // prettier-ignore\n\t\tconst after = registrations.filter(({ before, replace }) => !before && !replace).sort(sort);\n\t\tconst replaced = replace.length > 0;\n\n\t\t// Define main handler registration\n\t\t// Created as HookRegistration[] array to allow passing it into hooks.run() directly\n\t\tlet handler: HookRegistration>[] = [];\n\t\tif (defaultHandler) {\n\t\t\thandler = [{ id: 0, hook, handler: defaultHandler }];\n\t\t\tif (replaced) {\n\t\t\t\tconst index = replace.length - 1;\n\t\t\t\tconst replacingHandler = replace[index].handler;\n\t\t\t\tconst createDefaultHandler = (index: number): DefaultHandler | undefined => {\n\t\t\t\t\tconst next = replace[index - 1];\n\t\t\t\t\tif (next) {\n\t\t\t\t\t\treturn (visit, args) =>\n\t\t\t\t\t\t\tnext.handler(visit, args, createDefaultHandler(index - 1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn defaultHandler;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst nestedDefaultHandler = createDefaultHandler(index);\n\t\t\t\thandler = [\n\t\t\t\t\t{ id: 0, hook, handler: replacingHandler, defaultHandler: nestedDefaultHandler }\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\n\t\treturn { found: true, before, handler, after, replaced };\n\t}\n\n\t/**\n\t * Sort two hook registrations by priority and registration order.\n\t * @param a The registration object to compare\n\t * @param b The other registration object to compare with\n\t * @returns The sort direction\n\t */\n\tprotected sortRegistrations(\n\t\ta: HookRegistration,\n\t\tb: HookRegistration\n\t): number {\n\t\tconst priority = (a.priority ?? 0) - (b.priority ?? 0);\n\t\tconst id = a.id - b.id;\n\t\treturn priority || id || 0;\n\t}\n\n\t/**\n\t * Dispatch a custom event on the `document` for a hook. Prefixed with `swup:`\n\t * @param hook Name of the hook.\n\t */\n\tprotected dispatchDomEvent(hook: T, args?: HookArguments): void {\n\t\tconst detail = { hook, args, visit: this.swup.visit };\n\t\tdocument.dispatchEvent(new CustomEvent(`swup:${hook}`, { detail }));\n\t}\n}\n","import { escapeCssIdentifier as escape, query } from '../utils.js';\n\n/**\n * Find the anchor element for a given hash.\n *\n * @param hash Hash with or without leading '#'\n * @returns The element, if found, or null.\n *\n * @see https://html.spec.whatwg.org/#find-a-potential-indicated-element\n */\nexport const getAnchorElement = (hash?: string): Element | null => {\n\tif (hash && hash.charAt(0) === '#') {\n\t\thash = hash.substring(1);\n\t}\n\n\tif (!hash) {\n\t\treturn null;\n\t}\n\n\tconst decoded = decodeURIComponent(hash);\n\tlet element =\n\t\tdocument.getElementById(hash) ||\n\t\tdocument.getElementById(decoded) ||\n\t\tquery(`a[name='${escape(hash)}']`) ||\n\t\tquery(`a[name='${escape(decoded)}']`);\n\n\tif (!element && hash === 'top') {\n\t\telement = document.body;\n\t}\n\n\treturn element;\n};\n","import { queryAll, toMs } from '../utils.js';\nimport Swup, { Options } from '../Swup.js';\n\nconst TRANSITION = 'transition';\nconst ANIMATION = 'animation';\n\ntype AnimationTypes = typeof TRANSITION | typeof ANIMATION;\ntype AnimationProperties = 'Delay' | 'Duration';\ntype AnimationStyleKeys = `${AnimationTypes}${AnimationProperties}` | 'transitionProperty';\ntype AnimationStyleDeclarations = Pick;\n\nexport type AnimationDirection = 'in' | 'out';\n\n/**\n * Return a Promise that resolves when all CSS animations and transitions\n * are done on the page. Filters by selector or takes elements directly.\n */\nexport async function awaitAnimations(\n\tthis: Swup,\n\t{\n\t\telements,\n\t\tselector\n\t}: {\n\t\tselector: Options['animationSelector'];\n\t\telements?: NodeListOf | HTMLElement[];\n\t}\n): Promise {\n\t// Allow usage of swup without animations: { animationSelector: false }\n\tif (selector === false && !elements) {\n\t\treturn;\n\t}\n\n\t// Allow passing in elements\n\tlet animatedElements: HTMLElement[] = [];\n\tif (elements) {\n\t\tanimatedElements = Array.from(elements);\n\t} else if (selector) {\n\t\tanimatedElements = queryAll(selector, document.body);\n\t\t// Warn if no elements match the selector, but keep things going\n\t\tif (!animatedElements.length) {\n\t\t\tconsole.warn(`[swup] No elements found matching animationSelector \\`${selector}\\``);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst awaitedAnimations = animatedElements.map((el) => awaitAnimationsOnElement(el));\n\tconst hasAnimations = awaitedAnimations.filter(Boolean).length > 0;\n\tif (!hasAnimations) {\n\t\tif (selector) {\n\t\t\tconsole.warn(\n\t\t\t\t`[swup] No CSS animation duration defined on elements matching \\`${selector}\\``\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\tawait Promise.all(awaitedAnimations);\n}\n\nfunction awaitAnimationsOnElement(element: Element): Promise | false {\n\tconst { type, timeout, propCount } = getTransitionInfo(element);\n\n\t// Resolve immediately if no transition defined\n\tif (!type || !timeout) {\n\t\treturn false;\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tconst endEvent = `${type}end`;\n\t\tconst startTime = performance.now();\n\t\tlet propsTransitioned = 0;\n\n\t\tconst end = () => {\n\t\t\telement.removeEventListener(endEvent, onEnd);\n\t\t\tresolve();\n\t\t};\n\n\t\tconst onEnd: EventListener = (event) => {\n\t\t\t// Skip transitions on child elements\n\t\t\tif (event.target !== element) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isTransitionOrAnimationEvent(event)) {\n\t\t\t\tthrow new Error('Not a transition or animation event.');\n\t\t\t}\n\n\t\t\t// Skip transitions that happened before we started listening\n\t\t\tconst elapsedTime = (performance.now() - startTime) / 1000;\n\t\t\tif (elapsedTime < event.elapsedTime) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// End if all properties have transitioned\n\t\t\tif (++propsTransitioned >= propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t};\n\n\t\tsetTimeout(() => {\n\t\t\tif (propsTransitioned < propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t}, timeout + 1);\n\n\t\telement.addEventListener(endEvent, onEnd);\n\t});\n}\n\nexport function getTransitionInfo(element: Element, expectedType?: AnimationTypes) {\n\tconst styles = window.getComputedStyle(element) as AnimationStyleDeclarations;\n\n\tconst transitionDelays = getStyleProperties(styles, `${TRANSITION}Delay`);\n\tconst transitionDurations = getStyleProperties(styles, `${TRANSITION}Duration`);\n\tconst transitionTimeout = calculateTimeout(transitionDelays, transitionDurations);\n\tconst animationDelays = getStyleProperties(styles, `${ANIMATION}Delay`);\n\tconst animationDurations = getStyleProperties(styles, `${ANIMATION}Duration`);\n\tconst animationTimeout = calculateTimeout(animationDelays, animationDurations);\n\n\tlet type: AnimationTypes | null = null;\n\tlet timeout = 0;\n\tlet propCount = 0;\n\n\tif (expectedType === TRANSITION) {\n\t\tif (transitionTimeout > 0) {\n\t\t\ttype = TRANSITION;\n\t\t\ttimeout = transitionTimeout;\n\t\t\tpropCount = transitionDurations.length;\n\t\t}\n\t} else if (expectedType === ANIMATION) {\n\t\tif (animationTimeout > 0) {\n\t\t\ttype = ANIMATION;\n\t\t\ttimeout = animationTimeout;\n\t\t\tpropCount = animationDurations.length;\n\t\t}\n\t} else {\n\t\ttimeout = Math.max(transitionTimeout, animationTimeout);\n\t\ttype = timeout > 0 ? (transitionTimeout > animationTimeout ? TRANSITION : ANIMATION) : null;\n\t\tpropCount = type\n\t\t\t? type === TRANSITION\n\t\t\t\t? transitionDurations.length\n\t\t\t\t: animationDurations.length\n\t\t\t: 0;\n\t}\n\n\treturn {\n\t\ttype,\n\t\ttimeout,\n\t\tpropCount\n\t};\n}\n\nfunction isTransitionOrAnimationEvent(event: Event): event is TransitionEvent | AnimationEvent {\n\treturn [`${TRANSITION}end`, `${ANIMATION}end`].includes(event.type);\n}\n\nfunction getStyleProperties(styles: AnimationStyleDeclarations, key: AnimationStyleKeys): string[] {\n\treturn (styles[key] || '').split(', ');\n}\n\nfunction calculateTimeout(delays: string[], durations: string[]): number {\n\twhile (delays.length < durations.length) {\n\t\tdelays = delays.concat(delays);\n\t}\n\n\treturn Math.max(...durations.map((duration, i) => toMs(duration) + toMs(delays[i])));\n}\n","import Swup from '../Swup.js';\nimport { createHistoryRecord, updateHistoryRecord, getCurrentUrl, Location } from '../helpers.js';\nimport { FetchOptions, PageData } from './fetchPage.js';\nimport { VisitInitOptions } from './Visit.js';\n\nexport type HistoryAction = 'push' | 'replace';\nexport type HistoryDirection = 'forwards' | 'backwards';\nexport type NavigationToSelfAction = 'scroll' | 'navigate';\nexport type CacheControl = Partial<{ read: boolean; write: boolean }>;\n\n/** Define how to navigate to a page. */\ntype NavigationOptions = {\n\t/** Whether this visit is animated. Default: `true` */\n\tanimate?: boolean;\n\t/** Name of a custom animation to run. */\n\tanimation?: string;\n\t/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */\n\thistory?: HistoryAction;\n\t/** Whether this visit should read from or write to the cache. */\n\tcache?: CacheControl;\n};\n\n/**\n * Navigate to a new URL.\n * @param url The URL to navigate to.\n * @param options Options for how to perform this visit.\n * @returns Promise\n */\nexport function navigate(\n\tthis: Swup,\n\turl: string,\n\toptions: NavigationOptions & FetchOptions = {},\n\tinit: Omit = {}\n) {\n\tif (typeof url !== 'string') {\n\t\tthrow new Error(`swup.navigate() requires a URL parameter`);\n\t}\n\n\t// Check if the visit should be ignored\n\tif (this.shouldIgnoreVisit(url, { el: init.el, event: init.event })) {\n\t\twindow.location.href = url;\n\t\treturn;\n\t}\n\n\tconst { url: to, hash } = Location.fromUrl(url);\n\tthis.visit = this.createVisit({ ...init, to, hash });\n\tthis.performNavigation(options);\n}\n\n/**\n * Start a visit to a new URL.\n *\n * Internal method that assumes the visit context has already been created.\n *\n * As a user, you should call `swup.navigate(url)` instead.\n *\n * @param url The URL to navigate to.\n * @param options Options for how to perform this visit.\n * @returns Promise\n */\nexport async function performNavigation(\n\tthis: Swup,\n\toptions: NavigationOptions & FetchOptions = {}\n) {\n\tconst { el } = this.visit.trigger;\n\toptions.referrer = options.referrer || this.currentPageUrl;\n\n\tif (options.animate === false) {\n\t\tthis.visit.animation.animate = false;\n\t}\n\n\t// Clean up old animation classes\n\tif (!this.visit.animation.animate) {\n\t\tthis.classes.clear();\n\t}\n\n\t// Get history action from option or attribute on trigger element\n\tconst history = options.history || el?.getAttribute('data-swup-history') || undefined;\n\tif (history && ['push', 'replace'].includes(history)) {\n\t\tthis.visit.history.action = history as HistoryAction;\n\t}\n\n\t// Get custom animation name from option or attribute on trigger element\n\tconst animation = options.animation || el?.getAttribute('data-swup-animation') || undefined;\n\tif (animation) {\n\t\tthis.visit.animation.name = animation;\n\t}\n\n\t// Sanitize cache option\n\tif (typeof options.cache === 'object') {\n\t\tthis.visit.cache.read = options.cache.read ?? this.visit.cache.read;\n\t\tthis.visit.cache.write = options.cache.write ?? this.visit.cache.write;\n\t} else if (options.cache !== undefined) {\n\t\tthis.visit.cache = { read: !!options.cache, write: !!options.cache };\n\t}\n\t// Delete this so that window.fetch doesn't mis-interpret it\n\tdelete options.cache;\n\n\ttry {\n\t\tawait this.hooks.call('visit:start', undefined);\n\n\t\t// Begin loading page\n\t\tconst pagePromise = this.hooks.call('page:load', { options }, async (visit, args) => {\n\t\t\t// Read from cache\n\t\t\tlet cachedPage: PageData | undefined;\n\t\t\tif (this.visit.cache.read) {\n\t\t\t\tcachedPage = this.cache.get(visit.to.url);\n\t\t\t}\n\n\t\t\targs.page = cachedPage || (await this.fetchPage(visit.to.url, args.options));\n\t\t\targs.cache = !!cachedPage;\n\n\t\t\treturn args.page;\n\t\t});\n\n\t\t// Create/update history record if this is not a popstate call or leads to the same URL\n\t\tif (!this.visit.history.popstate) {\n\t\t\t// Add the hash directly from the trigger element\n\t\t\tconst newUrl = this.visit.to.url + this.visit.to.hash;\n\t\t\tif (\n\t\t\t\tthis.visit.history.action === 'replace' ||\n\t\t\t\tthis.visit.to.url === this.currentPageUrl\n\t\t\t) {\n\t\t\t\tupdateHistoryRecord(newUrl);\n\t\t\t} else {\n\t\t\t\tconst index = this.currentHistoryIndex + 1;\n\t\t\t\tcreateHistoryRecord(newUrl, { index });\n\t\t\t}\n\t\t}\n\n\t\tthis.currentPageUrl = getCurrentUrl();\n\n\t\t// Wait for page before starting to animate out?\n\t\tif (this.visit.animation.wait) {\n\t\t\tconst { html } = await pagePromise;\n\t\t\tthis.visit.to.html = html;\n\t\t}\n\n\t\t// Wait for page to load and leave animation to finish\n\t\tconst animationPromise = this.animatePageOut();\n\t\tconst [page] = await Promise.all([pagePromise, animationPromise]);\n\n\t\t// Render page: replace content and scroll to top/fragment\n\t\tawait this.renderPage(this.visit.to.url, page);\n\n\t\t// Wait for enter animation\n\t\tawait this.animatePageIn();\n\n\t\t// Finalize visit\n\t\tawait this.hooks.call('visit:end', undefined, () => this.classes.clear());\n\n\t\t// Reset visit info after finish?\n\t\t// if (this.visit.to && this.isSameResolvedUrl(this.visit.to.url, requestedUrl)) {\n\t\t// \tthis.createVisit({ to: undefined });\n\t\t// }\n\t} catch (error: unknown) {\n\t\t// Return early if error is undefined (probably aborted preload request)\n\t\tif (!error) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Log to console as we swallow almost all hook errors\n\t\tconsole.error(error);\n\n\t\t// Rewrite `skipPopStateHandling` to redirect manually when `history.go` is processed\n\t\tthis.options.skipPopStateHandling = () => {\n\t\t\twindow.location.href = this.visit.to.url + this.visit.to.hash;\n\t\t\treturn true;\n\t\t};\n\n\t\t// Go back to the actual page we're still at\n\t\twindow.history.go(-1);\n\t}\n}\n","import Swup from '../Swup.js';\nimport { Location } from '../helpers.js';\n\n/** A page object as used by swup and its cache. */\nexport interface PageData {\n\t/** The URL of the page */\n\turl: string;\n\t/** The complete HTML response received from the server */\n\thtml: string;\n}\n\n/** Define how a page is fetched. */\nexport interface FetchOptions extends Omit {\n\t/** The request method. */\n\tmethod?: 'GET' | 'POST';\n\t/** The body of the request: raw string, form data object or URL params. */\n\tbody?: string | FormData | URLSearchParams;\n}\n\nexport class FetchError extends Error {\n\turl: string;\n\tstatus: number;\n\tconstructor(message: string, details: { url: string; status: number }) {\n\t\tsuper(message);\n\t\tthis.name = 'FetchError';\n\t\tthis.url = details.url;\n\t\tthis.status = details.status;\n\t}\n}\n\n/**\n * Fetch a page from the server, return it and cache it.\n */\nexport async function fetchPage(\n\tthis: Swup,\n\turl: URL | string,\n\toptions: FetchOptions = {}\n): Promise {\n\turl = Location.fromUrl(url).url;\n\n\tconst headers = { ...this.options.requestHeaders, ...options.headers };\n\toptions = { ...options, headers };\n\n\t// Allow hooking before this and returning a custom response-like object (e.g. custom fetch implementation)\n\tconst response: Response = await this.hooks.call(\n\t\t'fetch:request',\n\t\t{ url, options },\n\t\t(visit, { url, options }) => fetch(url, options)\n\t);\n\n\tconst { status, url: responseUrl } = response;\n\tconst html = await response.text();\n\n\tif (status === 500) {\n\t\tthis.hooks.call('fetch:error', { status, response, url: responseUrl });\n\t\tthrow new FetchError(`Server error: ${responseUrl}`, { status, url: responseUrl });\n\t}\n\n\tif (!html) {\n\t\tthrow new FetchError(`Empty response: ${responseUrl}`, { status, url: responseUrl });\n\t}\n\n\t// Resolve real url after potential redirect\n\tconst { url: finalUrl } = Location.fromUrl(responseUrl);\n\tconst page = { url: finalUrl, html };\n\n\t// Write to cache for safe methods and non-redirects\n\tif (\n\t\tthis.visit.cache.write &&\n\t\t(!options.method || options.method === 'GET') &&\n\t\turl === finalUrl\n\t) {\n\t\tthis.cache.set(page.url, page);\n\t}\n\n\treturn page;\n}\n","import Swup from '../Swup.js';\nimport { classify } from '../helpers.js';\n\n/**\n * Perform the out/leave animation of the current page.\n * @returns Promise\n */\nexport const animatePageOut = async function (this: Swup) {\n\tif (!this.visit.animation.animate) {\n\t\tawait this.hooks.call('animation:skip', undefined);\n\t\treturn;\n\t}\n\n\tawait this.hooks.call('animation:out:start', undefined, (visit) => {\n\t\tthis.classes.add('is-changing', 'is-leaving', 'is-animating');\n\t\tif (visit.history.popstate) {\n\t\t\tthis.classes.add('is-popstate');\n\t\t}\n\t\tif (visit.animation.name) {\n\t\t\tthis.classes.add(`to-${classify(visit.animation.name)}`);\n\t\t}\n\t});\n\n\tawait this.hooks.call('animation:out:await', { skip: false }, async (visit, { skip }) => {\n\t\tif (skip) return;\n\t\tawait this.awaitAnimations({ selector: visit.animation.selector });\n\t});\n\n\tawait this.hooks.call('animation:out:end', undefined);\n};\n","import Swup, { Options } from '../Swup.js';\nimport { query, queryAll } from '../utils.js';\nimport { PageData } from './fetchPage.js';\n\n/**\n * Perform the replacement of content after loading a page.\n *\n * It takes an object with the page data as returned from `fetchPage` and a list\n * of container selectors to replace.\n *\n * @returns Whether all containers were replaced.\n */\nexport const replaceContent = function (\n\tthis: Swup,\n\t{ html }: PageData,\n\t{ containers }: { containers: Options['containers'] } = this.options\n): boolean {\n\tconst incomingDocument = new DOMParser().parseFromString(html, 'text/html');\n\n\t// Update browser title\n\tconst title = incomingDocument.querySelector('title')?.innerText || '';\n\tdocument.title = title;\n\n\t// Save persisted elements\n\tconst persistedElements = queryAll('[data-swup-persist]:not([data-swup-persist=\"\"])');\n\n\t// Update content containers\n\tconst replaced = containers\n\t\t.map((selector) => {\n\t\t\tconst currentEl = document.querySelector(selector);\n\t\t\tconst incomingEl = incomingDocument.querySelector(selector);\n\t\t\tif (currentEl && incomingEl) {\n\t\t\t\tcurrentEl.replaceWith(incomingEl);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!currentEl) {\n\t\t\t\tconsole.warn(`[swup] Container missing in current document: ${selector}`);\n\t\t\t}\n\t\t\tif (!incomingEl) {\n\t\t\t\tconsole.warn(`[swup] Container missing in incoming document: ${selector}`);\n\t\t\t}\n\t\t\treturn false;\n\t\t})\n\t\t.filter(Boolean);\n\n\t// Restore persisted elements\n\tpersistedElements.forEach((existing) => {\n\t\tconst key = existing.getAttribute('data-swup-persist');\n\t\tconst replacement = query(`[data-swup-persist=\"${key}\"]`);\n\t\tif (replacement && replacement !== existing) {\n\t\t\treplacement.replaceWith(existing);\n\t\t}\n\t});\n\n\treturn replaced.length === containers.length;\n};\n","import Swup from '../Swup.js';\n\n/**\n * Update the scroll position after page render.\n * @returns Promise\n */\nexport const scrollToContent = function (this: Swup): boolean {\n\tconst options: ScrollIntoViewOptions = { behavior: 'auto' };\n\tconst { target, reset } = this.visit.scroll;\n\tconst scrollTarget = target ?? this.visit.to.hash;\n\n\tlet scrolled = false;\n\n\tif (scrollTarget) {\n\t\tscrolled = this.hooks.callSync(\n\t\t\t'scroll:anchor',\n\t\t\t{ hash: scrollTarget, options },\n\t\t\t(visit, { hash, options }) => {\n\t\t\t\tconst anchor = this.getAnchorElement(hash);\n\t\t\t\tif (anchor) {\n\t\t\t\t\tanchor.scrollIntoView(options);\n\t\t\t\t}\n\t\t\t\treturn !!anchor;\n\t\t\t}\n\t\t);\n\t}\n\n\tif (reset && !scrolled) {\n\t\tscrolled = this.hooks.callSync('scroll:top', { options }, (visit, { options }) => {\n\t\t\twindow.scrollTo({ top: 0, left: 0, ...options });\n\t\t\treturn true;\n\t\t});\n\t}\n\n\treturn scrolled;\n};\n","import Swup from '../Swup.js';\nimport { nextTick } from '../utils.js';\n\n/**\n * Perform the in/enter animation of the next page.\n * @returns Promise\n */\nexport const animatePageIn = async function (this: Swup) {\n\tif (!this.visit.animation.animate) {\n\t\treturn;\n\t}\n\n\tconst animation = this.hooks.call(\n\t\t'animation:in:await',\n\t\t{ skip: false },\n\t\tasync (visit, { skip }) => {\n\t\t\tif (skip) return;\n\t\t\tawait this.awaitAnimations({ selector: visit.animation.selector });\n\t\t}\n\t);\n\n\tawait nextTick();\n\n\tawait this.hooks.call('animation:in:start', undefined, () => {\n\t\tthis.classes.remove('is-animating');\n\t});\n\n\tawait animation;\n\n\tawait this.hooks.call('animation:in:end', undefined);\n};\n","import { updateHistoryRecord, getCurrentUrl, classify } from '../helpers.js';\nimport Swup from '../Swup.js';\nimport { PageData } from './fetchPage.js';\n\n/**\n * Render the next page: replace the content and update scroll position.\n * @returns Promise\n */\nexport const renderPage = async function (this: Swup, requestedUrl: string, page: PageData) {\n\tconst { url, html } = page;\n\n\tthis.classes.remove('is-leaving');\n\n\t// do nothing if another page was requested in the meantime\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), requestedUrl)) {\n\t\treturn;\n\t}\n\n\t// update state if the url was redirected\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), url)) {\n\t\tupdateHistoryRecord(url);\n\t\tthis.currentPageUrl = getCurrentUrl();\n\t\tthis.visit.to.url = this.currentPageUrl;\n\t}\n\n\t// only add for animated page loads\n\tif (this.visit.animation.animate) {\n\t\tthis.classes.add('is-rendering');\n\t}\n\n\t// save html into visit context for easier retrieval\n\tthis.visit.to.html = html;\n\n\t// replace content: allow handlers and plugins to overwrite paga data and containers\n\tawait this.hooks.call('content:replace', { page }, (visit, { page }) => {\n\t\tconst success = this.replaceContent(page, { containers: visit.containers });\n\t\tif (!success) {\n\t\t\tthrow new Error('[swup] Container mismatch, aborting');\n\t\t}\n\t\tif (visit.animation.animate) {\n\t\t\t// Make sure to add these classes to new containers as well\n\t\t\tthis.classes.add('is-animating', 'is-changing', 'is-rendering');\n\t\t\tif (visit.animation.name) {\n\t\t\t\tthis.classes.add(`to-${classify(visit.animation.name)}`);\n\t\t\t}\n\t\t}\n\t});\n\n\t// scroll into view: either anchor or top of page\n\t// @ts-ignore: not returning a promise is intentional to allow users to pause in handler\n\tawait this.hooks.call('content:scroll', undefined, () => {\n\t\treturn this.scrollToContent();\n\t});\n\n\tawait this.hooks.call('page:view', { url: this.currentPageUrl, title: document.title });\n};\n","import Swup from '../Swup.js';\n\nexport type Plugin = {\n\t/** Identify as a swup plugin */\n\tisSwupPlugin: true;\n\t/** Name of this plugin */\n\tname: string;\n\t/** Version of this plugin. Currently not in use, defined here for backward compatiblity. */\n\tversion?: string;\n\t/** The swup instance that mounted this plugin */\n\tswup?: Swup;\n\t/** Version requirements of this plugin. Example: `{ swup: '>=4' }` */\n\trequires?: Record;\n\t/** Run on mount */\n\tmount: () => void;\n\t/** Run on unmount */\n\tunmount: () => void;\n\t_beforeMount?: () => void;\n\t_afterUnmount?: () => void;\n\t_checkRequirements?: () => boolean;\n};\n\nconst isSwupPlugin = (maybeInvalidPlugin: unknown): maybeInvalidPlugin is Plugin => {\n\t// @ts-ignore: this might be anything, object or no\n\treturn Boolean(maybeInvalidPlugin?.isSwupPlugin);\n};\n\n/** Install a plugin. */\nexport const use = function (this: Swup, plugin: unknown) {\n\tif (!isSwupPlugin(plugin)) {\n\t\tconsole.error('Not a swup plugin instance', plugin);\n\t\treturn;\n\t}\n\n\tplugin.swup = this;\n\tif (plugin._checkRequirements) {\n\t\tif (!plugin._checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (plugin._beforeMount) {\n\t\tplugin._beforeMount();\n\t}\n\tplugin.mount();\n\n\tthis.plugins.push(plugin);\n\n\treturn this.plugins;\n};\n\n/** Uninstall a plugin. */\nexport function unuse(this: Swup, pluginOrName: Plugin | string) {\n\tconst plugin = this.findPlugin(pluginOrName);\n\tif (!plugin) {\n\t\tconsole.error('No such plugin', plugin);\n\t\treturn;\n\t}\n\n\tplugin.unmount();\n\tif (plugin._afterUnmount) {\n\t\tplugin._afterUnmount();\n\t}\n\n\tthis.plugins = this.plugins.filter((p) => p !== plugin);\n\n\treturn this.plugins;\n}\n\n/** Find a plugin by name or reference. */\nexport function findPlugin(this: Swup, pluginOrName: Plugin | string) {\n\treturn this.plugins.find(\n\t\t(plugin) =>\n\t\t\tplugin === pluginOrName ||\n\t\t\tplugin.name === pluginOrName ||\n\t\t\tplugin.name === `Swup${String(pluginOrName)}`\n\t);\n}\n","import Swup from '../Swup.js';\n\n/**\n * Utility function to validate and run the global option 'resolveUrl'\n * @param {string} url\n * @returns {string} the resolved url\n */\nexport function resolveUrl(this: Swup, url: string): string {\n\tif (typeof this.options.resolveUrl !== 'function') {\n\t\tconsole.warn(`[swup] options.resolveUrl expects a callback function.`);\n\t\treturn url;\n\t}\n\tconst result = this.options.resolveUrl(url);\n\tif (!result || typeof result !== 'string') {\n\t\tconsole.warn(`[swup] options.resolveUrl needs to return a url`);\n\t\treturn url;\n\t}\n\tif (result.startsWith('//') || result.startsWith('http')) {\n\t\tconsole.warn(`[swup] options.resolveUrl needs to return a relative url`);\n\t\treturn url;\n\t}\n\treturn result;\n}\n\n/**\n * Compares the resolved version of two paths and returns true if they are the same\n * @param {string} url1\n * @param {string} url2\n * @returns {boolean}\n */\nexport function isSameResolvedUrl(this: Swup, url1: string, url2: string): boolean {\n\treturn this.resolveUrl(url1) === this.resolveUrl(url2);\n}\n","import { DelegateEvent } from 'delegate-it';\n\nimport version from './config/version.js';\n\nimport { delegateEvent, getCurrentUrl, Location, updateHistoryRecord } from './helpers.js';\nimport { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';\n\nimport { Cache } from './modules/Cache.js';\nimport { Classes } from './modules/Classes.js';\nimport { Visit, createVisit } from './modules/Visit.js';\nimport { Hooks } from './modules/Hooks.js';\nimport { getAnchorElement } from './modules/getAnchorElement.js';\nimport { awaitAnimations } from './modules/awaitAnimations.js';\nimport { navigate, performNavigation, NavigationToSelfAction } from './modules/navigate.js';\nimport { fetchPage } from './modules/fetchPage.js';\nimport { animatePageOut } from './modules/animatePageOut.js';\nimport { replaceContent } from './modules/replaceContent.js';\nimport { scrollToContent } from './modules/scrollToContent.js';\nimport { animatePageIn } from './modules/animatePageIn.js';\nimport { renderPage } from './modules/renderPage.js';\nimport { use, unuse, findPlugin, Plugin } from './modules/plugins.js';\nimport { isSameResolvedUrl, resolveUrl } from './modules/resolveUrl.js';\nimport { nextTick } from './utils.js';\nimport { HistoryState } from './helpers/createHistoryRecord.js';\n\n/** Options for customizing swup's behavior. */\nexport type Options = {\n\t/** Whether history visits are animated. Default: `false` */\n\tanimateHistoryBrowsing: boolean;\n\t/** Selector for detecting animation timing. Default: `[class*=\"transition-\"]` */\n\tanimationSelector: string | false;\n\t/** Elements on which to add animation classes. Default: `html` element */\n\tanimationScope: 'html' | 'containers';\n\t/** Enable in-memory page cache. Default: `true` */\n\tcache: boolean;\n\t/** Content containers to be replaced on page visits. Default: `['#swup']` */\n\tcontainers: string[];\n\t/** Callback for ignoring visits. Receives the element and event that triggered the visit. */\n\tignoreVisit: (url: string, { el, event }: { el?: Element; event?: Event }) => boolean;\n\t/** Selector for links that trigger visits. Default: `'a[href]'` */\n\tlinkSelector: string;\n\t/** How swup handles links to the same page. Default: `scroll` */\n\tlinkToSelf: NavigationToSelfAction;\n\t/** Plugins to register on startup. */\n\tplugins: Plugin[];\n\t/** Custom headers sent along with fetch requests. */\n\trequestHeaders: Record;\n\t/** Rewrite URLs before loading them. */\n\tresolveUrl: (url: string) => string;\n\t/** Callback for telling swup to ignore certain popstate events. */\n\tskipPopStateHandling: (event: PopStateEvent) => boolean;\n};\n\nconst defaults: Options = {\n\tanimateHistoryBrowsing: false,\n\tanimationSelector: '[class*=\"transition-\"]',\n\tanimationScope: 'html',\n\tcache: true,\n\tcontainers: ['#swup'],\n\tignoreVisit: (url, { el } = {}) => !!el?.closest('[data-no-swup]'),\n\tlinkSelector: 'a[href]',\n\tlinkToSelf: 'scroll',\n\tplugins: [],\n\tresolveUrl: (url) => url,\n\trequestHeaders: {\n\t\t'X-Requested-With': 'swup',\n\t\t'Accept': 'text/html, application/xhtml+xml'\n\t},\n\tskipPopStateHandling: (event) => (event.state as HistoryState)?.source !== 'swup'\n};\n\n/** Swup page transition library. */\nexport default class Swup {\n\t/** Library version */\n\treadonly version: string = version;\n\t/** Options passed into the instance */\n\toptions: Options;\n\t/** Default options before merging user options */\n\treadonly defaults: Options = defaults;\n\t/** Registered plugin instances */\n\tplugins: Plugin[] = [];\n\t/** Data about the current visit */\n\tvisit: Visit;\n\t/** Cache instance */\n\treadonly cache: Cache;\n\t/** Hook registry */\n\treadonly hooks: Hooks;\n\t/** Animation class manager */\n\treadonly classes: Classes;\n\t/** URL of the currently visible page */\n\tcurrentPageUrl: string = getCurrentUrl();\n\t/** Index of the current history entry */\n\tprotected currentHistoryIndex = 1;\n\t/** Delegated event subscription handle */\n\tprotected clickDelegate?: DelegateEventUnsubscribe;\n\n\t/** Install a plugin */\n\tuse = use;\n\t/** Uninstall a plugin */\n\tunuse = unuse;\n\t/** Find a plugin by name or instance */\n\tfindPlugin = findPlugin;\n\n\t/** Log a message. Has no effect unless debug plugin is installed */\n\tlog: (message: string, context?: unknown) => void = () => {};\n\n\t/** Navigate to a new URL */\n\tnavigate = navigate;\n\t/** Actually perform a navigation */\n\tprotected performNavigation = performNavigation;\n\t/** Create a new context for this visit */\n\tprotected createVisit = createVisit;\n\t/** Register a delegated event listener */\n\tdelegateEvent = delegateEvent;\n\t/** Fetch a page from the server */\n\tfetchPage = fetchPage;\n\t/** Resolve when animations on the page finish */\n\tawaitAnimations = awaitAnimations;\n\tprotected renderPage = renderPage;\n\t/** Replace the content after page load */\n\treplaceContent = replaceContent;\n\tprotected animatePageIn = animatePageIn;\n\tprotected animatePageOut = animatePageOut;\n\tprotected scrollToContent = scrollToContent;\n\t/** Find the anchor element for a given hash */\n\tgetAnchorElement = getAnchorElement;\n\n\t/** Get the current page URL */\n\tgetCurrentUrl = getCurrentUrl;\n\t/** Resolve a URL to its final location */\n\tresolveUrl = resolveUrl;\n\t/** Check if two URLs resolve to the same location */\n\tprotected isSameResolvedUrl = isSameResolvedUrl;\n\n\tconstructor(options: Partial = {}) {\n\t\t// Merge defaults and options\n\t\tthis.options = { ...this.defaults, ...options };\n\n\t\tthis.handleLinkClick = this.handleLinkClick.bind(this);\n\t\tthis.handlePopState = this.handlePopState.bind(this);\n\n\t\tthis.cache = new Cache(this);\n\t\tthis.classes = new Classes(this);\n\t\tthis.hooks = new Hooks(this);\n\t\tthis.visit = this.createVisit({ to: '' });\n\n\t\tif (!this.checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.enable();\n\t}\n\n\tprotected checkRequirements() {\n\t\tif (typeof Promise === 'undefined') {\n\t\t\tconsole.warn('Promise is not supported');\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Enable this instance, adding listeners and classnames. */\n\tasync enable() {\n\t\t// Add event listener\n\t\tconst { linkSelector } = this.options;\n\t\tthis.clickDelegate = this.delegateEvent(linkSelector, 'click', this.handleLinkClick);\n\n\t\twindow.addEventListener('popstate', this.handlePopState);\n\n\t\t// Set scroll restoration to manual if animating history visits\n\t\tif (this.options.animateHistoryBrowsing) {\n\t\t\twindow.history.scrollRestoration = 'manual';\n\t\t}\n\n\t\t// Initial save to cache\n\t\tif (this.options.cache) {\n\t\t\t// Disabled to avoid caching modified dom state: logic moved to preload plugin\n\t\t\t// https://github.com/swup/swup/issues/475\n\t\t}\n\n\t\t// Mount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.use(plugin));\n\n\t\t// Modify initial history record\n\t\tupdateHistoryRecord(null, { index: 1 });\n\n\t\t// Give consumers a chance to hook into enable\n\t\tawait nextTick();\n\n\t\t// Trigger enable hook\n\t\tawait this.hooks.call('enable', undefined, () => {\n\t\t\t// Add swup-enabled class to html tag\n\t\t\tdocument.documentElement.classList.add('swup-enabled');\n\t\t});\n\t}\n\n\t/** Disable this instance, removing listeners and classnames. */\n\tasync destroy() {\n\t\t// remove delegated listener\n\t\tthis.clickDelegate!.destroy();\n\n\t\t// remove popstate listener\n\t\twindow.removeEventListener('popstate', this.handlePopState);\n\n\t\t// empty cache\n\t\tthis.cache.clear();\n\n\t\t// unmount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.unuse(plugin));\n\n\t\t// trigger disable hook\n\t\tawait this.hooks.call('disable', undefined, () => {\n\t\t\t// remove swup-enabled class from html tag\n\t\t\tdocument.documentElement.classList.remove('swup-enabled');\n\t\t});\n\n\t\t// remove handlers\n\t\tthis.hooks.clear();\n\t}\n\n\t/** Determine if a visit should be ignored by swup, based on URL or trigger element. */\n\tshouldIgnoreVisit(href: string, { el, event }: { el?: Element; event?: Event } = {}) {\n\t\tconst { origin, url, hash } = Location.fromUrl(href);\n\n\t\t// Ignore if the new origin doesn't match the current one\n\t\tif (origin !== window.location.origin) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the link/form would open a new window (or none at all)\n\t\tif (el && this.triggerWillOpenNewWindow(el)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the visit should be ignored as per user options\n\t\tif (this.options.ignoreVisit(url + hash, { el, event })) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Finally, allow the visit\n\t\treturn false;\n\t}\n\n\tprotected handleLinkClick(event: DelegateEvent) {\n\t\tconst el = event.delegateTarget as HTMLAnchorElement;\n\t\tconst { href, url, hash } = Location.fromElement(el);\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { el, event })) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.visit = this.createVisit({ to: url, hash, el, event });\n\n\t\t// Exit early if control key pressed\n\t\tif (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n\t\t\tthis.hooks.call('link:newtab', { href });\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if other than left mouse button\n\t\tif (event.button !== 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hooks.callSync('link:click', { el, event }, () => {\n\t\t\tconst from = this.visit.from.url ?? '';\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Handle links to the same page\n\t\t\tif (!url || url === from) {\n\t\t\t\tif (hash) {\n\t\t\t\t\t// With hash: scroll to anchor\n\t\t\t\t\tthis.hooks.callSync('link:anchor', { hash }, () => {\n\t\t\t\t\t\tupdateHistoryRecord(url + hash);\n\t\t\t\t\t\tthis.scrollToContent();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// Without hash: scroll to top or load/reload page\n\t\t\t\t\tthis.hooks.callSync('link:self', undefined, () => {\n\t\t\t\t\t\tswitch (this.options.linkToSelf) {\n\t\t\t\t\t\t\tcase 'navigate':\n\t\t\t\t\t\t\t\treturn this.performNavigation();\n\t\t\t\t\t\t\tcase 'scroll':\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\treturn this.scrollToContent();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Exit early if the resolved path hasn't changed\n\t\t\tif (this.isSameResolvedUrl(url, from)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Finally, proceed with loading the page\n\t\t\tthis.performNavigation();\n\t\t});\n\t}\n\n\tprotected handlePopState(event: PopStateEvent) {\n\t\tconst href: string = (event.state as HistoryState)?.url ?? location.href;\n\n\t\t// Exit early if this event should be ignored\n\t\tif (this.options.skipPopStateHandling(event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(getCurrentUrl(), this.currentPageUrl)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { url, hash } = Location.fromUrl(href);\n\n\t\tthis.visit = this.createVisit({ to: url, hash, event });\n\n\t\t// Mark as history visit\n\t\tthis.visit.history.popstate = true;\n\n\t\t// Determine direction of history visit\n\t\tconst index = Number((event.state as HistoryState)?.index);\n\t\tif (index) {\n\t\t\tconst direction = index - this.currentHistoryIndex > 0 ? 'forwards' : 'backwards';\n\t\t\tthis.visit.history.direction = direction;\n\t\t}\n\n\t\t// Disable animation & scrolling for history visits\n\t\tthis.visit.animation.animate = false;\n\t\tthis.visit.scroll.reset = false;\n\t\tthis.visit.scroll.target = false;\n\n\t\t// Animated history visit: re-enable animation & scroll reset\n\t\tif (this.options.animateHistoryBrowsing) {\n\t\t\tthis.visit.animation.animate = true;\n\t\t\tthis.visit.scroll.reset = true;\n\t\t}\n\n\t\t// Does this even do anything?\n\t\t// if (!hash) {\n\t\t// \tevent.preventDefault();\n\t\t// }\n\n\t\tthis.hooks.callSync('history:popstate', { event }, () => {\n\t\t\tthis.performNavigation();\n\t\t});\n\t}\n\n\t/** Determine whether an element will open a new tab when clicking/activating. */\n\tprotected triggerWillOpenNewWindow(triggerEl: Element) {\n\t\tif (triggerEl.matches('[download], [target=\"_blank\"]')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n"],"names":["classify","text","fallback","String","toLowerCase","replace","getCurrentUrl","_temp","hash","location","pathname","search","createHistoryRecord","url","customData","data","random","Math","source","history","pushState","updateHistoryRecord","state","replaceState","ledger","WeakMap","editLedger","wanted","baseElement","callback","setup","has","elementMap","get","set","setups","Set","existed","add","delete","delegateEvent","selector","type","options","controller","AbortController","signal","base","document","aborted","once","nativeListenerOptions","Document","documentElement","capture","Boolean","listenerFn","event","delegateTarget","target","Text","parentElement","Element","currentTarget","closest","contains","safeClosest","Object","assign","call","removeEventListener","JSON","stringify","addEventListener","delegate","destroy","abort","Location","URL","constructor","baseURI","super","toString","this","fromElement","el","href","getAttribute","fromUrl","Cache","swup","pages","Map","size","all","copy","forEach","page","key","resolve","result","hooks","callSync","update","payload","clear","undefined","prune","predicate","urlToResolve","resolveUrl","query","context","querySelector","queryAll","Array","from","querySelectorAll","nextTick","Promise","requestAnimationFrame","isPromise","obj","then","escapeCssIdentifier","ident","window","CSS","escape","toMs","s","Number","slice","Classes","swupClasses","selectors","scope","visit","animation","containers","isArray","join","targets","trim","classList","arguments","remove","className","split","filter","c","isSwupClass","some","startsWith","createVisit","_ref","to","currentPageUrl","animate","wait","name","animationScope","animationSelector","trigger","cache","read","write","action","popstate","direction","scroll","reset","_iteratorSymbol","Symbol","iterator","pact","value","_Pact","o","_settle","bind","v","observer","onFulfilled","onRejected","e","_this","_isSettledPact","thenable","Hooks","registry","init","hook","create","exists","console","error","on","handler","warn","id","registration","off","before","args","defaultHandler","after","getHandlers","run","dispatchDomEvent","reject","runSync","registrations","_this2","results","body","check","step","_cycle","next","done","return","_fixup","TypeError","values","i","length","array","_forTo","_forOf","_ref2","func","runAsPromise","push","found","replaced","sort","sortRegistrations","_ref3","_ref4","T","_ref5","index","createDefaultHandler","a","b","priority","dispatchEvent","CustomEvent","detail","getAnchorElement","charAt","substring","decoded","decodeURIComponent","element","getElementById","awaitAnimations","elements","animatedElements","awaitedAnimations","map","timeout","propCount","expectedType","styles","getComputedStyle","transitionDelays","getStyleProperties","TRANSITION","transitionDurations","transitionTimeout","calculateTimeout","animationDelays","ANIMATION","animationDurations","animationTimeout","max","getTransitionInfo","endEvent","startTime","performance","now","propsTransitioned","end","onEnd","includes","isTransitionOrAnimationEvent","Error","elapsedTime","setTimeout","awaitAnimationsOnElement","delays","durations","concat","duration","performNavigation","referrer","classes","_temp2","animationPromise","animatePageOut","pagePromise","renderPage","animatePageIn","_temp3","_this$fetchPage","cachedPage","fetchPage","newUrl","currentHistoryIndex","html","_catch","skipPopStateHandling","go","navigate","shouldIgnoreVisit","headers","requestHeaders","fetch","response","status","responseUrl","FetchError","finalUrl","method","message","details","_exit","_result","skip","replaceContent","incomingDocument","DOMParser","parseFromString","title","innerText","persistedElements","currentEl","incomingEl","replaceWith","existing","replacement","scrollToContent","behavior","scrollTarget","scrolled","anchor","scrollIntoView","scrollTo","top","left","requestedUrl","isSameResolvedUrl","use","plugin","maybeInvalidPlugin","isSwupPlugin","_checkRequirements","_beforeMount","mount","plugins","unuse","pluginOrName","findPlugin","unmount","_afterUnmount","p","find","url1","url2","defaults","animateHistoryBrowsing","ignoreVisit","linkSelector","linkToSelf","Accept","version","clickDelegate","log","handleLinkClick","handlePopState","checkRequirements","enable","scrollRestoration","origin","triggerWillOpenNewWindow","metaKey","ctrlKey","shiftKey","altKey","button","preventDefault","triggerEl","matches"],"mappings":"uNACO,MAAMA,EAAWA,CAACC,EAAcC,IACvBC,OAAOF,GACpBG,cAGAC,QAAQ,YAAa,KACrBA,QAAQ,WAAY,IACpBA,QAAQ,OAAQ,KAChBA,QAAQ,WAAY,KACLH,GAAY,GCTjBI,EAAgB,SAAAC,GAAC,IAAAC,KAAEA,QAA6B,IAAzBD,EAAyB,CAAE,EAAAA,EAC9D,OAAOE,SAASC,SAAWD,SAASE,QAAUH,EAAOC,SAASD,KAAO,GACtE,ECQaI,EAAsB,SAClCC,EACAC,QAAA,IAAAA,IAAAA,EAAsC,CAAA,GAGtC,MAAMC,EAAqB,CAC1BF,IAFDA,EAAMA,GAAOP,EAAc,CAAEE,MAAM,IAGlCQ,OAAQC,KAAKD,SACbE,OAAQ,UACLJ,GAEJK,QAAQC,UAAUL,EAAM,GAAIF,EAC7B,ECnBaQ,EAAsB,SAClCR,EACAC,QADqB,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