Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swup

Package Overview
Dependencies
Maintainers
3
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swup - npm Package Compare versions

Comparing version 4.3.0 to 4.3.1

2

dist/Swup.modern.js

@@ -1,2 +0,2 @@

import t from"delegate-it";import{match as e}from"path-to-regexp";function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},i.apply(this,arguments)}const s=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",n=({hash:t}={})=>location.pathname+location.search+(t?location.hash:""),o=(t,e={})=>{const s=i({url:t=t||n({hash:!0}),random:Math.random(),source:"swup"},e);history.pushState(s,"",t)},r=(t=null,e={})=>{t=t||n({hash:!0});const s=i({},history.state||{},{url:t,random:Math.random(),source:"swup"},e);history.replaceState(s,"",t)},a=(e,s,n,o)=>{const r=new AbortController;return o=i({},o,{signal:r.signal}),t(e,s,n,o),{destroy:()=>r.abort()}};class l extends URL{constructor(t,e=document.baseURI){super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new l(e)}static fromUrl(t){return new l(t)}}const h=(t,i)=>{try{return e(t,i)}catch(e){throw new Error(`[swup] Error parsing path "${String(t)}":\n${String(e)}`)}};class c{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,s)=>{t.set(s,i({},e))}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?i({},e):e}set(t,e){e=i({},e,{url:t=this.resolve(t)}),this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t);const s=i({},this.get(t),e,{url:t});this.pages.set(t,s)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0)}prune(t){this.pages.forEach((e,i)=>{t(i,e)&&this.delete(i)})}resolve(t){const{url:e}=l.fromUrl(t);return this.swup.resolveUrl(e)}}const u=(t,e=document)=>e.querySelector(t),p=(t,e=document)=>Array.from(e.querySelectorAll(t)),d=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function m(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function g(t,e=[]){return new Promise((i,s)=>{const n=t(...e);m(n)?n.then(i,s):i(n)})}function f(t){var e;return null==(e=t=t||document.body)?void 0:e.offsetHeight}const w=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,v=t=>1e3*Number(t.slice(0,-1).replace(",","."));class y{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?p(this.selector):[]}add(...t){this.targets.forEach(e=>e.classList.add(...t))}remove(...t){this.targets.forEach(e=>e.classList.remove(...t))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function k({to:t,from:e=this.currentPageUrl,hash:i,animate:s=!0,animation:n,el:o,event:r,action:a="push",resetScroll:l=!0}){return{from:{url:e},to:{url:t,hash:i},containers:this.options.containers,animation:{animate:s,wait:!1,name:n,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:o,event:r},cache:{read:this.options.cache,write:this.options.cache},history:{action:a,popstate:!1,direction:void 0},scroll:{reset:l,target:void 0}}}class S{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,s={}){const n=this.get(t);if(!n)return console.warn(`Hook '${t}' not found.`),()=>{};const o=i({},s,{id:n.size+1,hook:t,handler:e});return n.set(e,o),()=>this.off(t,e)}before(t,e,s={}){return this.on(t,e,i({},s,{before:!0}))}replace(t,e,s={}){return this.on(t,e,i({},s,{replace:!0}))}once(t,e,s={}){return this.on(t,e,i({},s,{once:!0}))}off(t,e){const i=this.get(t);i&&e?i.delete(e)||console.warn(`Handler for hook '${t}' not found.`):i&&i.clear()}async call(t,e,i){const{before:s,handler:n,after:o}=this.getHandlers(t,i);await this.run(s,e);const[r]=await this.run(n,e);return await this.run(o,e),this.dispatchDomEvent(t,e),r}callSync(t,e,i){const{before:s,handler:n,after:o}=this.getHandlers(t,i);this.runSync(s,e);const[r]=this.runSync(n,e);return this.runSync(o,e),this.dispatchDomEvent(t,e),r}async run(t,e){const i=[];for(const{hook:s,handler:n,defaultHandler:o,once:r}of t){const t=await g(n,[this.swup.visit,e,o]);i.push(t),r&&this.off(s,n)}return i}runSync(t,e){const i=[];for(const{hook:s,handler:n,defaultHandler:o,once:r}of t){const t=n(this.swup.visit,e,o);i.push(t),m(t)&&console.warn(`Promise returned from handler for synchronous hook '${s}'.Swup will not wait for it to resolve.`),r&&this.off(s,n)}return i}getHandlers(t,e){const i=this.get(t);if(!i)return{found:!1,before:[],handler:[],after:[],replaced:!1};const s=Array.from(i.values()),n=this.sortRegistrations,o=s.filter(({before:t,replace:e})=>t&&!e).sort(n),r=s.filter(({replace:t})=>t).filter(t=>!0).sort(n),a=s.filter(({before:t,replace:e})=>!t&&!e).sort(n),l=r.length>0;let h=[];if(e&&(h=[{id:0,hook:t,handler:e}],l)){const i=r.length-1,s=t=>{const i=r[t-1];return i?(e,n)=>i.handler(e,n,s(t-1)):e};h=[{id:0,hook:t,handler:r[i].handler,defaultHandler:s(i)}]}return{found:!0,before:o,handler:h,after:a,replaced:l}}sortRegistrations(t,e){var i,s;return(null!=(i=t.priority)?i:0)-(null!=(s=e.priority)?s:0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const b=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let i=document.getElementById(t)||document.getElementById(e)||u(`a[name='${w(t)}']`)||u(`a[name='${w(e)}']`);return i||"top"!==t||(i=document.body),i},U="transition",E="animation";async function P({elements:t,selector:e}){if(!1===e&&!t)return;let i=[];if(t)i=Array.from(t);else if(e&&(i=p(e,document.body),!i.length))return void console.warn(`[swup] No elements found matching animationSelector \`${e}\``);const s=i.map(t=>function(t){const{type:e,timeout:i,propCount:s}=function(t,e){const i=window.getComputedStyle(t),s=C(i,`${U}Delay`),n=C(i,`${U}Duration`),o=$(s,n),r=C(i,`${E}Delay`),a=C(i,`${E}Duration`),l=$(r,a);let h=null,c=0,u=0;return c=Math.max(o,l),h=c>0?o>l?U:E:null,u=h?h===U?n.length:a.length:0,{type:h,timeout:c,propCount:u}}(t);return!(!e||!i)&&new Promise(n=>{const o=`${e}end`,r=performance.now();let a=0;const l=()=>{t.removeEventListener(o,h),n()},h=e=>{if(e.target===t){if(!function(t){return[`${U}end`,`${E}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=s&&l()}};setTimeout(()=>{a<s&&l()},i+1),t.addEventListener(o,h)})}(t));s.filter(Boolean).length>0?await Promise.all(s):e&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${e}\``)}function C(t,e){return(t[e]||"").split(", ")}function $(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,i)=>v(e)+v(t[i])))}function x(t,e={},s={}){if("string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:s.el,event:s.event}))return void(window.location.href=t);const{url:n,hash:o}=l.fromUrl(t);this.visit=this.createVisit(i({},s,{to:n,hash:o})),this.performNavigation(e)}async function A(t={}){const{el:e}=this.visit.trigger;t.referrer=t.referrer||this.currentPageUrl,!1===t.animate&&(this.visit.animation.animate=!1),this.visit.animation.animate||this.classes.clear();const i=t.history||(null==e?void 0:e.getAttribute("data-swup-history"))||void 0;i&&["push","replace"].includes(i)&&(this.visit.history.action=i);const s=t.animation||(null==e?void 0:e.getAttribute("data-swup-animation"))||void 0;var a,l;s&&(this.visit.animation.name=s),"object"==typeof t.cache?(this.visit.cache.read=null!=(a=t.cache.read)?a:this.visit.cache.read,this.visit.cache.write=null!=(l=t.cache.write)?l:this.visit.cache.write):void 0!==t.cache&&(this.visit.cache={read:!!t.cache,write:!!t.cache}),delete t.cache;try{await this.hooks.call("visit:start",void 0);const e=this.hooks.call("page:load",{options:t},async(t,e)=>{let i;return this.visit.cache.read&&(i=this.cache.get(t.to.url)),e.page=i||await this.fetchPage(t.to.url,e.options),e.cache=!!i,e.page});if(!this.visit.history.popstate){const t=this.visit.to.url+this.visit.to.hash;"replace"===this.visit.history.action||this.visit.to.url===this.currentPageUrl?r(t):o(t,{index:this.currentHistoryIndex+1})}if(this.currentPageUrl=n(),this.visit.animation.wait){const{html:t}=await e;this.visit.to.html=t}const i=this.animatePageOut(),[s]=await Promise.all([e,i]);await this.renderPage(this.visit.to.url,s),await this.animatePageIn(),await this.hooks.call("visit:end",void 0,()=>this.classes.clear())}catch(t){if(!t)return;console.error(t),this.options.skipPopStateHandling=()=>(window.location.href=this.visit.to.url+this.visit.to.hash,!0),window.history.go(-1)}}class H extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}async function q(t,e={}){t=l.fromUrl(t).url;const s=i({},this.options.requestHeaders,e.headers);e=i({},e,{headers:s});const n=await this.hooks.call("fetch:request",{url:t,options:e},(t,{url:e,options:i})=>fetch(e,i)),{status:o,url:r}=n,a=await n.text();if(500===o)throw this.hooks.call("fetch:error",{status:o,response:n,url:r}),new H(`Server error: ${r}`,{status:o,url:r});if(!a)throw new H(`Empty response: ${r}`,{status:o,url:r});const{url:h}=l.fromUrl(r),c={url:h,html:a};return!this.visit.cache.write||e.method&&"GET"!==e.method||t!==h||this.cache.set(c.url,c),c}const L=async function(){this.visit.animation.animate?(await this.hooks.call("animation:out:start",void 0,t=>{this.classes.add("is-changing","is-leaving","is-animating"),t.history.popstate&&this.classes.add("is-popstate"),t.animation.name&&this.classes.add(`to-${s(t.animation.name)}`)}),await this.hooks.call("animation:out:await",{skip:!1},async(t,{skip:e})=>{e||await this.awaitAnimations({selector:t.animation.selector})}),await this.hooks.call("animation:out:end",void 0)):await this.hooks.call("animation:skip",void 0)},R=function({html:t},{containers:e}=this.options){var i;const s=(new DOMParser).parseFromString(t,"text/html"),n=(null==(i=s.querySelector("title"))?void 0:i.innerText)||"";document.title=n;const o=p('[data-swup-persist]:not([data-swup-persist=""])'),r=e.map(t=>{const e=document.querySelector(t),i=s.querySelector(t);return e&&i?(e.replaceWith(i),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),i||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return o.forEach(t=>{const e=t.getAttribute("data-swup-persist"),i=u(`[data-swup-persist="${e}"]`);i&&i!==t&&i.replaceWith(t)}),r.length===e.length},N=function(){const t={behavior:"auto"},{target:e,reset:s}=this.visit.scroll,n=e||this.visit.to.hash;let o=!1;return n&&(o=this.hooks.callSync("scroll:anchor",{hash:n,options:t},(t,{hash:e,options:i})=>{const s=this.getAnchorElement(e);return s&&s.scrollIntoView(i),!!s})),s&&!o&&(o=this.hooks.callSync("scroll:top",{options:t},(t,{options:e})=>(window.scrollTo(i({top:0,left:0},e)),!0))),o},I=async function(){if(!this.visit.animation.animate)return;const t=this.hooks.call("animation:in:await",{skip:!1},async(t,{skip:e})=>{e||await this.awaitAnimations({selector:t.animation.selector})});await d(),await this.hooks.call("animation:in:start",void 0,()=>{this.classes.remove("is-animating")}),await t,await this.hooks.call("animation:in:end",void 0)},D=async function(t,e){const{url:i,html:o}=e;this.classes.remove("is-leaving"),this.isSameResolvedUrl(n(),t)&&(this.isSameResolvedUrl(n(),i)||(r(i),this.currentPageUrl=n(),this.visit.to.url=this.currentPageUrl),this.visit.animation.animate&&this.classes.add("is-rendering"),this.visit.to.html=o,await this.hooks.call("content:replace",{page:e},(t,{page:e})=>{if(!this.replaceContent(e,{containers:t.containers}))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(this.classes.add("is-animating","is-changing","is-rendering"),t.animation.name&&this.classes.add(`to-${s(t.animation.name)}`))}),await this.hooks.call("content:scroll",void 0,()=>this.scrollToContent()),await this.hooks.call("page:view",{url:this.currentPageUrl,title:document.title}))},T=function(t){var e;if(e=t,Boolean(null==e?void 0:e.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function M(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function V(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function W(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function O(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const B={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:(t,{el:e}={})=>!(null==e||!e.closest("[data-no-swup]")),linkSelector:"a[href]",linkToSelf:"scroll",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>{var e;return"swup"!==(null==(e=t.state)?void 0:e.source)}};class _{constructor(t={}){this.version="4.3.0",this.options=void 0,this.defaults=B,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=n(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.use=T,this.unuse=M,this.findPlugin=V,this.log=()=>{},this.navigate=x,this.performNavigation=A,this.createVisit=k,this.delegateEvent=a,this.fetchPage=q,this.awaitAnimations=P,this.renderPage=D,this.replaceContent=R,this.animatePageIn=I,this.animatePageOut=L,this.scrollToContent=N,this.getAnchorElement=b,this.getCurrentUrl=n,this.resolveUrl=W,this.isSameResolvedUrl=O,this.options=i({},this.defaults,t),this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new c(this),this.classes=new y(this),this.hooks=new S(this),this.visit=this.createVisit({to:""}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}async enable(){const{linkSelector:t}=this.options;this.clickDelegate=this.delegateEvent(t,"click",this.handleLinkClick),window.addEventListener("popstate",this.handlePopState),this.options.plugins.forEach(t=>this.use(t)),r(null,{index:1}),await d(),await this.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})}async destroy(){this.clickDelegate.destroy(),window.removeEventListener("popstate",this.handlePopState),this.cache.clear(),this.options.plugins.forEach(t=>this.unuse(t)),await this.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")}),this.hooks.clear()}shouldIgnoreVisit(t,{el:e,event:i}={}){const{origin:s,url:n,hash:o}=l.fromUrl(t);return s!==window.location.origin||!(!e||!this.triggerWillOpenNewWindow(e))||!!this.options.ignoreVisit(n+o,{el:e,event:i})}handleLinkClick(t){const e=t.delegateTarget,{href:i,url:s,hash:n}=l.fromElement(e);this.shouldIgnoreVisit(i,{el:e,event:t})||(this.visit=this.createVisit({to:s,hash:n,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:i}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{var e;const i=null!=(e=this.visit.from.url)?e:"";t.preventDefault(),s&&s!==i?this.isSameResolvedUrl(s,i)||this.performNavigation():n?this.hooks.callSync("link:anchor",{hash:n},()=>{r(s+n),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>"navigate"===this.options.linkToSelf?this.performNavigation():this.scrollToContent())}))}handlePopState(t){var e,i,s;const o=null!=(e=null==(i=t.state)?void 0:i.url)?e:location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(n(),this.currentPageUrl))return;const{url:r,hash:a}=l.fromUrl(o);this.visit=this.createVisit({to:r,hash:a,event:t,animate:this.options.animateHistoryBrowsing,resetScroll:this.options.animateHistoryBrowsing}),this.visit.history.popstate=!0;const h=Number(null==(s=t.state)?void 0:s.index);h&&(this.visit.history.direction=h-this.currentHistoryIndex>0?"forwards":"backwards"),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation()})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}export{l as Location,s as classify,o as createHistoryRecord,_ as default,a as delegateEvent,w as escapeCssIdentifier,f as forceReflow,n as getCurrentUrl,m as isPromise,h as matchPath,d as nextTick,u as query,p as queryAll,g as runAsPromise,v as toMs,r as updateHistoryRecord};
import t from"delegate-it";import{match as e}from"path-to-regexp";function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},i.apply(this,arguments)}const s=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",n=({hash:t}={})=>location.pathname+location.search+(t?location.hash:""),o=(t,e={})=>{const s=i({url:t=t||n({hash:!0}),random:Math.random(),source:"swup"},e);history.pushState(s,"",t)},r=(t=null,e={})=>{t=t||n({hash:!0});const s=i({},history.state||{},{url:t,random:Math.random(),source:"swup"},e);history.replaceState(s,"",t)},a=(e,s,n,o)=>{const r=new AbortController;return o=i({},o,{signal:r.signal}),t(e,s,n,o),{destroy:()=>r.abort()}};class l extends URL{constructor(t,e=document.baseURI){super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new l(e)}static fromUrl(t){return new l(t)}}const h=(t,i)=>{try{return e(t,i)}catch(e){throw new Error(`[swup] Error parsing path "${String(t)}":\n${String(e)}`)}};class c{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,s)=>{t.set(s,i({},e))}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?i({},e):e}set(t,e){e=i({},e,{url:t=this.resolve(t)}),this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t);const s=i({},this.get(t),e,{url:t});this.pages.set(t,s)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0)}prune(t){this.pages.forEach((e,i)=>{t(i,e)&&this.delete(i)})}resolve(t){const{url:e}=l.fromUrl(t);return this.swup.resolveUrl(e)}}const u=(t,e=document)=>e.querySelector(t),p=(t,e=document)=>Array.from(e.querySelectorAll(t)),d=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function m(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function g(t,e=[]){return new Promise((i,s)=>{const n=t(...e);m(n)?n.then(i,s):i(n)})}function f(t){var e;return null==(e=t=t||document.body)?void 0:e.offsetHeight}const w=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,v=t=>1e3*Number(t.slice(0,-1).replace(",","."));class y{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?p(this.selector):[]}add(...t){this.targets.forEach(e=>e.classList.add(...t))}remove(...t){this.targets.forEach(e=>e.classList.remove(...t))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function k({to:t,from:e=this.currentPageUrl,hash:i,el:s,event:n}){return{from:{url:e},to:{url:t,hash:i},containers:this.options.containers,animation:{animate:!0,wait:!1,name:void 0,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:s,event:n},cache:{read:this.options.cache,write:this.options.cache},history:{action:"push",popstate:!1,direction:void 0},scroll:{reset:!0,target:void 0}}}class S{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,s={}){const n=this.get(t);if(!n)return console.warn(`Hook '${t}' not found.`),()=>{};const o=i({},s,{id:n.size+1,hook:t,handler:e});return n.set(e,o),()=>this.off(t,e)}before(t,e,s={}){return this.on(t,e,i({},s,{before:!0}))}replace(t,e,s={}){return this.on(t,e,i({},s,{replace:!0}))}once(t,e,s={}){return this.on(t,e,i({},s,{once:!0}))}off(t,e){const i=this.get(t);i&&e?i.delete(e)||console.warn(`Handler for hook '${t}' not found.`):i&&i.clear()}async call(t,e,i){const{before:s,handler:n,after:o}=this.getHandlers(t,i);await this.run(s,e);const[r]=await this.run(n,e);return await this.run(o,e),this.dispatchDomEvent(t,e),r}callSync(t,e,i){const{before:s,handler:n,after:o}=this.getHandlers(t,i);this.runSync(s,e);const[r]=this.runSync(n,e);return this.runSync(o,e),this.dispatchDomEvent(t,e),r}async run(t,e){const i=[];for(const{hook:s,handler:n,defaultHandler:o,once:r}of t){const t=await g(n,[this.swup.visit,e,o]);i.push(t),r&&this.off(s,n)}return i}runSync(t,e){const i=[];for(const{hook:s,handler:n,defaultHandler:o,once:r}of t){const t=n(this.swup.visit,e,o);i.push(t),m(t)&&console.warn(`Promise returned from handler for synchronous hook '${s}'.Swup will not wait for it to resolve.`),r&&this.off(s,n)}return i}getHandlers(t,e){const i=this.get(t);if(!i)return{found:!1,before:[],handler:[],after:[],replaced:!1};const s=Array.from(i.values()),n=this.sortRegistrations,o=s.filter(({before:t,replace:e})=>t&&!e).sort(n),r=s.filter(({replace:t})=>t).filter(t=>!0).sort(n),a=s.filter(({before:t,replace:e})=>!t&&!e).sort(n),l=r.length>0;let h=[];if(e&&(h=[{id:0,hook:t,handler:e}],l)){const i=r.length-1,s=t=>{const i=r[t-1];return i?(e,n)=>i.handler(e,n,s(t-1)):e};h=[{id:0,hook:t,handler:r[i].handler,defaultHandler:s(i)}]}return{found:!0,before:o,handler:h,after:a,replaced:l}}sortRegistrations(t,e){var i,s;return(null!=(i=t.priority)?i:0)-(null!=(s=e.priority)?s:0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const b=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let i=document.getElementById(t)||document.getElementById(e)||u(`a[name='${w(t)}']`)||u(`a[name='${w(e)}']`);return i||"top"!==t||(i=document.body),i},U="transition",E="animation";async function P({elements:t,selector:e}){if(!1===e&&!t)return;let i=[];if(t)i=Array.from(t);else if(e&&(i=p(e,document.body),!i.length))return void console.warn(`[swup] No elements found matching animationSelector \`${e}\``);const s=i.map(t=>function(t){const{type:e,timeout:i,propCount:s}=function(t,e){const i=window.getComputedStyle(t),s=C(i,`${U}Delay`),n=C(i,`${U}Duration`),o=$(s,n),r=C(i,`${E}Delay`),a=C(i,`${E}Duration`),l=$(r,a);let h=null,c=0,u=0;return c=Math.max(o,l),h=c>0?o>l?U:E:null,u=h?h===U?n.length:a.length:0,{type:h,timeout:c,propCount:u}}(t);return!(!e||!i)&&new Promise(n=>{const o=`${e}end`,r=performance.now();let a=0;const l=()=>{t.removeEventListener(o,h),n()},h=e=>{if(e.target===t){if(!function(t){return[`${U}end`,`${E}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=s&&l()}};setTimeout(()=>{a<s&&l()},i+1),t.addEventListener(o,h)})}(t));s.filter(Boolean).length>0?await Promise.all(s):e&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${e}\``)}function C(t,e){return(t[e]||"").split(", ")}function $(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,i)=>v(e)+v(t[i])))}function x(t,e={},s={}){if("string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:s.el,event:s.event}))return void(window.location.href=t);const{url:n,hash:o}=l.fromUrl(t);this.visit=this.createVisit(i({},s,{to:n,hash:o})),this.performNavigation(e)}async function A(t={}){const{el:e}=this.visit.trigger;t.referrer=t.referrer||this.currentPageUrl,!1===t.animate&&(this.visit.animation.animate=!1),this.visit.animation.animate||this.classes.clear();const i=t.history||(null==e?void 0:e.getAttribute("data-swup-history"))||void 0;i&&["push","replace"].includes(i)&&(this.visit.history.action=i);const s=t.animation||(null==e?void 0:e.getAttribute("data-swup-animation"))||void 0;var a,l;s&&(this.visit.animation.name=s),"object"==typeof t.cache?(this.visit.cache.read=null!=(a=t.cache.read)?a:this.visit.cache.read,this.visit.cache.write=null!=(l=t.cache.write)?l:this.visit.cache.write):void 0!==t.cache&&(this.visit.cache={read:!!t.cache,write:!!t.cache}),delete t.cache;try{await this.hooks.call("visit:start",void 0);const e=this.hooks.call("page:load",{options:t},async(t,e)=>{let i;return this.visit.cache.read&&(i=this.cache.get(t.to.url)),e.page=i||await this.fetchPage(t.to.url,e.options),e.cache=!!i,e.page});if(!this.visit.history.popstate){const t=this.visit.to.url+this.visit.to.hash;"replace"===this.visit.history.action||this.visit.to.url===this.currentPageUrl?r(t):o(t,{index:this.currentHistoryIndex+1})}if(this.currentPageUrl=n(),this.visit.animation.wait){const{html:t}=await e;this.visit.to.html=t}const i=this.animatePageOut(),[s]=await Promise.all([e,i]);await this.renderPage(this.visit.to.url,s),await this.animatePageIn(),await this.hooks.call("visit:end",void 0,()=>this.classes.clear())}catch(t){if(!t)return;console.error(t),this.options.skipPopStateHandling=()=>(window.location.href=this.visit.to.url+this.visit.to.hash,!0),window.history.go(-1)}}class H extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}async function q(t,e={}){t=l.fromUrl(t).url;const s=i({},this.options.requestHeaders,e.headers);e=i({},e,{headers:s});const n=await this.hooks.call("fetch:request",{url:t,options:e},(t,{url:e,options:i})=>fetch(e,i)),{status:o,url:r}=n,a=await n.text();if(500===o)throw this.hooks.call("fetch:error",{status:o,response:n,url:r}),new H(`Server error: ${r}`,{status:o,url:r});if(!a)throw new H(`Empty response: ${r}`,{status:o,url:r});const{url:h}=l.fromUrl(r),c={url:h,html:a};return!this.visit.cache.write||e.method&&"GET"!==e.method||t!==h||this.cache.set(c.url,c),c}const R=async function(){this.visit.animation.animate?(await this.hooks.call("animation:out:start",void 0,t=>{this.classes.add("is-changing","is-leaving","is-animating"),t.history.popstate&&this.classes.add("is-popstate"),t.animation.name&&this.classes.add(`to-${s(t.animation.name)}`)}),await this.hooks.call("animation:out:await",{skip:!1},async(t,{skip:e})=>{e||await this.awaitAnimations({selector:t.animation.selector})}),await this.hooks.call("animation:out:end",void 0)):await this.hooks.call("animation:skip",void 0)},L=function({html:t},{containers:e}=this.options){var i;const s=(new DOMParser).parseFromString(t,"text/html"),n=(null==(i=s.querySelector("title"))?void 0:i.innerText)||"";document.title=n;const o=p('[data-swup-persist]:not([data-swup-persist=""])'),r=e.map(t=>{const e=document.querySelector(t),i=s.querySelector(t);return e&&i?(e.replaceWith(i),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),i||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return o.forEach(t=>{const e=t.getAttribute("data-swup-persist"),i=u(`[data-swup-persist="${e}"]`);i&&i!==t&&i.replaceWith(t)}),r.length===e.length},N=function(){const t={behavior:"auto"},{target:e,reset:s}=this.visit.scroll,n=null!=e?e:this.visit.to.hash;let o=!1;return n&&(o=this.hooks.callSync("scroll:anchor",{hash:n,options:t},(t,{hash:e,options:i})=>{const s=this.getAnchorElement(e);return s&&s.scrollIntoView(i),!!s})),s&&!o&&(o=this.hooks.callSync("scroll:top",{options:t},(t,{options:e})=>(window.scrollTo(i({top:0,left:0},e)),!0))),o},I=async function(){if(!this.visit.animation.animate)return;const t=this.hooks.call("animation:in:await",{skip:!1},async(t,{skip:e})=>{e||await this.awaitAnimations({selector:t.animation.selector})});await d(),await this.hooks.call("animation:in:start",void 0,()=>{this.classes.remove("is-animating")}),await t,await this.hooks.call("animation:in:end",void 0)},D=async function(t,e){const{url:i,html:o}=e;this.classes.remove("is-leaving"),this.isSameResolvedUrl(n(),t)&&(this.isSameResolvedUrl(n(),i)||(r(i),this.currentPageUrl=n(),this.visit.to.url=this.currentPageUrl),this.visit.animation.animate&&this.classes.add("is-rendering"),this.visit.to.html=o,await this.hooks.call("content:replace",{page:e},(t,{page:e})=>{if(!this.replaceContent(e,{containers:t.containers}))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(this.classes.add("is-animating","is-changing","is-rendering"),t.animation.name&&this.classes.add(`to-${s(t.animation.name)}`))}),await this.hooks.call("content:scroll",void 0,()=>this.scrollToContent()),await this.hooks.call("page:view",{url:this.currentPageUrl,title:document.title}))},T=function(t){var e;if(e=t,Boolean(null==e?void 0:e.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function M(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function V(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function W(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function O(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const B={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:(t,{el:e}={})=>!(null==e||!e.closest("[data-no-swup]")),linkSelector:"a[href]",linkToSelf:"scroll",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>{var e;return"swup"!==(null==(e=t.state)?void 0:e.source)}};class _{constructor(t={}){this.version="4.3.1",this.options=void 0,this.defaults=B,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=n(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.use=T,this.unuse=M,this.findPlugin=V,this.log=()=>{},this.navigate=x,this.performNavigation=A,this.createVisit=k,this.delegateEvent=a,this.fetchPage=q,this.awaitAnimations=P,this.renderPage=D,this.replaceContent=L,this.animatePageIn=I,this.animatePageOut=R,this.scrollToContent=N,this.getAnchorElement=b,this.getCurrentUrl=n,this.resolveUrl=W,this.isSameResolvedUrl=O,this.options=i({},this.defaults,t),this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new c(this),this.classes=new y(this),this.hooks=new S(this),this.visit=this.createVisit({to:""}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}async enable(){const{linkSelector:t}=this.options;this.clickDelegate=this.delegateEvent(t,"click",this.handleLinkClick),window.addEventListener("popstate",this.handlePopState),this.options.animateHistoryBrowsing&&(window.history.scrollRestoration="manual"),this.options.plugins.forEach(t=>this.use(t)),r(null,{index:1}),await d(),await this.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})}async destroy(){this.clickDelegate.destroy(),window.removeEventListener("popstate",this.handlePopState),this.cache.clear(),this.options.plugins.forEach(t=>this.unuse(t)),await this.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")}),this.hooks.clear()}shouldIgnoreVisit(t,{el:e,event:i}={}){const{origin:s,url:n,hash:o}=l.fromUrl(t);return s!==window.location.origin||!(!e||!this.triggerWillOpenNewWindow(e))||!!this.options.ignoreVisit(n+o,{el:e,event:i})}handleLinkClick(t){const e=t.delegateTarget,{href:i,url:s,hash:n}=l.fromElement(e);this.shouldIgnoreVisit(i,{el:e,event:t})||(this.visit=this.createVisit({to:s,hash:n,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:i}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{var e;const i=null!=(e=this.visit.from.url)?e:"";t.preventDefault(),s&&s!==i?this.isSameResolvedUrl(s,i)||this.performNavigation():n?this.hooks.callSync("link:anchor",{hash:n},()=>{r(s+n),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>"navigate"===this.options.linkToSelf?this.performNavigation():this.scrollToContent())}))}handlePopState(t){var e,i,s;const o=null!=(e=null==(i=t.state)?void 0:i.url)?e:location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(n(),this.currentPageUrl))return;const{url:r,hash:a}=l.fromUrl(o);this.visit=this.createVisit({to:r,hash:a,event:t}),this.visit.history.popstate=!0;const h=Number(null==(s=t.state)?void 0:s.index);h&&(this.visit.history.direction=h-this.currentHistoryIndex>0?"forwards":"backwards"),this.visit.animation.animate=!1,this.visit.scroll.reset=!1,this.visit.scroll.target=!1,this.options.animateHistoryBrowsing&&(this.visit.animation.animate=!0,this.visit.scroll.reset=!0),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation()})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}export{l as Location,s as classify,o as createHistoryRecord,_ as default,a as delegateEvent,w as escapeCssIdentifier,f as forceReflow,n as getCurrentUrl,m as isPromise,h as matchPath,d as nextTick,u as query,p as queryAll,g as runAsPromise,v as toMs,r as updateHistoryRecord};
//# sourceMappingURL=Swup.modern.js.map

@@ -1,2 +0,2 @@

import t from"delegate-it";import{match as e}from"path-to-regexp";const n=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",r=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},i=function(t,e){void 0===e&&(e={});const n={url:t=t||r({hash:!0}),random:Math.random(),source:"swup",...e};history.pushState(n,"",t)},o=function(t,e){void 0===t&&(t=null),void 0===e&&(e={}),t=t||r({hash:!0});const n={...history.state||{},url:t,random:Math.random(),source:"swup",...e};history.replaceState(n,"",t)},s=(e,n,r,i)=>{const o=new AbortController;return i={...i,signal:o.signal},t(e,n,r,i),{destroy:()=>o.abort()}};class a extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new a(e)}static fromUrl(t){return new a(t)}}const c=(t,n)=>{try{return e(t,n)}catch(e){throw new Error(`[swup] Error parsing path "${String(t)}":\n${String(e)}`)}};class l{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,n)=>{t.set(n,{...e})}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?{...e}:e}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t);const n={...this.get(t),...e,url:t};this.pages.set(t,n)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0)}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=a.fromUrl(t);return this.swup.resolveUrl(e)}}const h=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},u=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},m=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function d(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function p(t,e){return void 0===e&&(e=[]),new Promise((n,r)=>{const i=t(...e);d(i)?i.then(n,r):n(i)})}function f(t){return t=t||document.body,t?.offsetHeight}const v=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,g=t=>1e3*Number(t.slice(0,-1).replace(",","."));class w{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?u(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function y(t){let{to:e,from:n=this.currentPageUrl,hash:r,animate:i=!0,animation:o,el:s,event:a,action:c="push",resetScroll:l=!0}=t;return{from:{url:n},to:{url:e,hash:r},containers:this.options.containers,animation:{animate:i,wait:!1,name:o,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:s,event:a},cache:{read:this.options.cache,write:this.options.cache},history:{action:c,popstate:!1,direction:void 0},scroll:{reset:l,target:void 0}}}const P="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function k(t,e,n){if(!t.s){if(n instanceof S){if(!n.s)return void(n.o=k.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,t,e),k.bind(null,t,2));t.s=e,t.v=n;const r=t.o;r&&r(t)}}const S=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const r=new t,i=this.s;if(i){const t=1&i?e:n;if(t){try{k(r,1,t(this.v))}catch(t){k(r,2,t)}return r}return this}return this.o=function(t){try{const i=t.v;1&t.s?k(r,1,e?e(i):i):n?k(r,1,n(i)):k(r,2,i)}catch(t){k(r,2,t)}},r},t}();function b(t){return t instanceof S&&1&t.s}class E{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const r=this.get(t);if(!r)return console.warn(`Hook '${t}' not found.`),()=>{};const i=r.size+1,o={...n,id:i,hook:t,handler:e};return r.set(e,o),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n){try{const r=this,{before:i,handler:o,after:s}=r.getHandlers(t,n);return Promise.resolve(r.run(i,e)).then(function(){return Promise.resolve(r.run(o,e)).then(function(n){let[i]=n;return Promise.resolve(r.run(s,e)).then(function(){return r.dispatchDomEvent(t,e),i})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n){const{before:r,handler:i,after:o}=this.getHandlers(t,n);this.runSync(r,e);const[s]=this.runSync(i,e);return this.runSync(o,e),this.dispatchDomEvent(t,e),s}run(t,e){try{const n=this,r=[],i=function(t,e,n){if("function"==typeof t[P]){var r,i,o,s=t[P]();if(function t(n){try{for(;!(r=s.next()).done;)if((n=e(r.value))&&n.then){if(!b(n))return void n.then(t,o||(o=k.bind(null,i=new S,2)));n=n.v}i?k(i,1,n):i=n}catch(t){k(i||(i=new S),2,t)}}(),s.return){var a=function(t){try{r.done||s.return()}catch(t){}return t};if(i&&i.then)return i.then(a,function(t){throw a(t)});a()}return i}if(!("length"in t))throw new TypeError("Object is not iterable");for(var c=[],l=0;l<t.length;l++)c.push(t[l]);return function(t,e,n){var r,i,o=-1;return function n(s){try{for(;++o<t.length;)if((s=e(o))&&s.then){if(!b(s))return void s.then(n,i||(i=k.bind(null,r=new S,2)));s=s.v}r?k(r,1,s):r=s}catch(t){k(r||(r=new S),2,t)}}(),r}(c,function(t){return e(c[t])})}(t,function(t){let{hook:i,handler:o,defaultHandler:s,once:a}=t;return Promise.resolve(p(o,[n.swup.visit,e,s])).then(function(t){r.push(t),a&&n.off(i,o)})});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(t){return Promise.reject(t)}}runSync(t,e){const n=[];for(const{hook:r,handler:i,defaultHandler:o,once:s}of t){const t=i(this.swup.visit,e,o);n.push(t),d(t)&&console.warn(`Promise returned from handler for synchronous hook '${r}'.Swup will not wait for it to resolve.`),s&&this.off(r,i)}return n}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const r=Array.from(n.values()),i=this.sortRegistrations,o=r.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(i),s=r.filter(t=>{let{replace:e}=t;return e}).filter(t=>!0).sort(i),a=r.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(i),c=s.length>0;let l=[];if(e&&(l=[{id:0,hook:t,handler:e}],c)){const n=s.length-1,r=t=>{const n=s[t-1];return n?(e,i)=>n.handler(e,i,r(t-1)):e};l=[{id:0,hook:t,handler:s[n].handler,defaultHandler:r(n)}]}return{found:!0,before:o,handler:l,after:a,replaced:c}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const U=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||h(`a[name='${v(t)}']`)||h(`a[name='${v(e)}']`);return n||"top"!==t||(n=document.body),n},C=function(t){let{elements:e,selector:n}=t;try{if(!1===n&&!e)return Promise.resolve();let t=[];if(e)t=Array.from(e);else if(n&&(t=u(n,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${n}\``),Promise.resolve();const r=t.map(t=>function(t){const{type:e,timeout:n,propCount:r}=function(t,e){const n=window.getComputedStyle(t),r=A(n,`${$}Delay`),i=A(n,`${$}Duration`),o=H(r,i),s=A(n,`${x}Delay`),a=A(n,`${x}Duration`),c=H(s,a);let l=null,h=0,u=0;return e===$?o>0&&(l=$,h=o,u=i.length):e===x?c>0&&(l=x,h=c,u=a.length):(h=Math.max(o,c),l=h>0?o>c?$:x:null,u=l?l===$?i.length:a.length:0),{type:l,timeout:h,propCount:u}}(t);return!(!e||!n)&&new Promise(i=>{const o=`${e}end`,s=performance.now();let a=0;const c=()=>{t.removeEventListener(o,l),i()},l=e=>{if(e.target===t){if(!function(t){return[`${$}end`,`${x}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-s)/1e3<e.elapsedTime||++a>=r&&c()}};setTimeout(()=>{a<r&&c()},n+1),t.addEventListener(o,l)})}(t));return r.filter(Boolean).length>0?Promise.resolve(Promise.all(r)).then(function(){}):(n&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${n}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},$="transition",x="animation";function A(t,e){return(t[e]||"").split(", ")}function H(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>g(e)+g(t[n])))}const j=function(t){void 0===t&&(t={});try{const e=this,{el:n}=e.visit.trigger;t.referrer=t.referrer||e.currentPageUrl,!1===t.animate&&(e.visit.animation.animate=!1),e.visit.animation.animate||e.classes.clear();const s=t.history||n?.getAttribute("data-swup-history")||void 0;s&&["push","replace"].includes(s)&&(e.visit.history.action=s);const a=t.animation||n?.getAttribute("data-swup-animation")||void 0;return a&&(e.visit.animation.name=a),"object"==typeof t.cache?(e.visit.cache.read=t.cache.read??e.visit.cache.read,e.visit.cache.write=t.cache.write??e.visit.cache.write):void 0!==t.cache&&(e.visit.cache={read:!!t.cache,write:!!t.cache}),delete t.cache,Promise.resolve(function(n,s){try{var a=Promise.resolve(e.hooks.call("visit:start",void 0)).then(function(){function n(){const t=e.animatePageOut();return Promise.resolve(Promise.all([s,t])).then(function(t){let[n]=t;return Promise.resolve(e.renderPage(e.visit.to.url,n)).then(function(){return Promise.resolve(e.animatePageIn()).then(function(){return Promise.resolve(e.hooks.call("visit:end",void 0,()=>e.classes.clear())).then(function(){})})})})}const s=e.hooks.call("page:load",{options:t},function(t,n){try{function r(t){return n.page=t,n.cache=!!i,n.page}let i;return e.visit.cache.read&&(i=e.cache.get(t.to.url)),Promise.resolve(i?r(i):Promise.resolve(e.fetchPage(t.to.url,n.options)).then(r))}catch(o){return Promise.reject(o)}});if(!e.visit.history.popstate){const t=e.visit.to.url+e.visit.to.hash;"replace"===e.visit.history.action||e.visit.to.url===e.currentPageUrl?o(t):i(t,{index:e.currentHistoryIndex+1})}e.currentPageUrl=r();const a=function(){if(e.visit.animation.wait)return Promise.resolve(s).then(function(t){let{html:n}=t;e.visit.to.html=n})}();return a&&a.then?a.then(n):n()})}catch(t){return s(t)}return a&&a.then?a.then(void 0,s):a}(0,function(t){t&&(console.error(t),e.options.skipPopStateHandling=()=>(window.location.href=e.visit.to.url+e.visit.to.hash,!0),window.history.go(-1))}))}catch(t){return Promise.reject(t)}};function q(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),"string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:n.el,event:n.event}))return void(window.location.href=t);const{url:r,hash:i}=a.fromUrl(t);this.visit=this.createVisit({...n,to:r,hash:i}),this.performNavigation(e)}const L=function(t,e){void 0===e&&(e={});try{const n=this;t=a.fromUrl(t).url;const r={...n.options.requestHeaders,...e.headers};return e={...e,headers:r},Promise.resolve(n.hooks.call("fetch:request",{url:t,options:e},(t,e)=>{let{url:n,options:r}=e;return fetch(n,r)})).then(function(r){const{status:i,url:o}=r;return Promise.resolve(r.text()).then(function(s){if(500===i)throw n.hooks.call("fetch:error",{status:i,response:r,url:o}),new R(`Server error: ${o}`,{status:i,url:o});if(!s)throw new R(`Empty response: ${o}`,{status:i,url:o});const{url:c}=a.fromUrl(o),l={url:c,html:s};return!n.visit.cache.write||e.method&&"GET"!==e.method||t!==c||n.cache.set(l.url,l),l})})}catch(t){return Promise.reject(t)}};class R extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}const N=function(){try{let e;const r=this;function t(t){return e?t:Promise.resolve(r.hooks.call("animation:out:start",void 0,t=>{r.classes.add("is-changing","is-leaving","is-animating"),t.history.popstate&&r.classes.add("is-popstate"),t.animation.name&&r.classes.add(`to-${n(t.animation.name)}`)})).then(function(){return Promise.resolve(r.hooks.call("animation:out:await",{skip:!1},function(t,e){let{skip:n}=e;try{return n?Promise.resolve():Promise.resolve(r.awaitAnimations({selector:t.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}})).then(function(){return Promise.resolve(r.hooks.call("animation:out:end",void 0)).then(function(){})})})}const i=function(){if(!r.visit.animation.animate)return Promise.resolve(r.hooks.call("animation:skip",void 0)).then(function(){e=1})}();return Promise.resolve(i&&i.then?i.then(t):t(i))}catch(o){return Promise.reject(o)}},I=function(t,e){let{html:n}=t,{containers:r}=void 0===e?this.options:e;const i=(new DOMParser).parseFromString(n,"text/html"),o=i.querySelector("title")?.innerText||"";document.title=o;const s=u('[data-swup-persist]:not([data-swup-persist=""])'),a=r.map(t=>{const e=document.querySelector(t),n=i.querySelector(t);return e&&n?(e.replaceWith(n),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),n||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return s.forEach(t=>{const e=t.getAttribute("data-swup-persist"),n=h(`[data-swup-persist="${e}"]`);n&&n!==t&&n.replaceWith(t)}),a.length===r.length},T=function(){const t={behavior:"auto"},{target:e,reset:n}=this.visit.scroll,r=e||this.visit.to.hash;let i=!1;return r&&(i=this.hooks.callSync("scroll:anchor",{hash:r,options:t},(t,e)=>{let{hash:n,options:r}=e;const i=this.getAnchorElement(n);return i&&i.scrollIntoView(r),!!i})),n&&!i&&(i=this.hooks.callSync("scroll:top",{options:t},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),i},D=function(){try{const t=this;if(!t.visit.animation.animate)return Promise.resolve();const e=t.hooks.call("animation:in:await",{skip:!1},function(e,n){let{skip:r}=n;try{return r?Promise.resolve():Promise.resolve(t.awaitAnimations({selector:e.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}});return Promise.resolve(m()).then(function(){return Promise.resolve(t.hooks.call("animation:in:start",void 0,()=>{t.classes.remove("is-animating")})).then(function(){return Promise.resolve(e).then(function(){return Promise.resolve(t.hooks.call("animation:in:end",void 0)).then(function(){})})})})}catch(t){return Promise.reject(t)}},M=function(t,e){try{const i=this,{url:s,html:a}=e;return i.classes.remove("is-leaving"),i.isSameResolvedUrl(r(),t)?(i.isSameResolvedUrl(r(),s)||(o(s),i.currentPageUrl=r(),i.visit.to.url=i.currentPageUrl),i.visit.animation.animate&&i.classes.add("is-rendering"),i.visit.to.html=a,Promise.resolve(i.hooks.call("content:replace",{page:e},(t,e)=>{let{page:r}=e;if(!i.replaceContent(r,{containers:t.containers}))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(i.classes.add("is-animating","is-changing","is-rendering"),t.animation.name&&i.classes.add(`to-${n(t.animation.name)}`))})).then(function(){return Promise.resolve(i.hooks.call("content:scroll",void 0,()=>i.scrollToContent())).then(function(){return Promise.resolve(i.hooks.call("page:view",{url:i.currentPageUrl,title:document.title})).then(function(){})})})):Promise.resolve()}catch(t){return Promise.reject(t)}},V=function(t){var e;if(e=t,Boolean(e?.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function W(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function B(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function _(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function O(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const F={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!!n?.closest("[data-no-swup]")},linkSelector:"a[href]",linkToSelf:"scroll",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>"swup"!==t.state?.source};class K{constructor(t){void 0===t&&(t={}),this.version="4.3.0",this.options=void 0,this.defaults=F,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=r(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.use=V,this.unuse=W,this.findPlugin=B,this.log=()=>{},this.navigate=q,this.performNavigation=j,this.createVisit=y,this.delegateEvent=s,this.fetchPage=L,this.awaitAnimations=C,this.renderPage=M,this.replaceContent=I,this.animatePageIn=D,this.animatePageOut=N,this.scrollToContent=T,this.getAnchorElement=U,this.getCurrentUrl=r,this.resolveUrl=_,this.isSameResolvedUrl=O,this.options={...this.defaults,...t},this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new l(this),this.classes=new w(this),this.hooks=new E(this),this.visit=this.createVisit({to:""}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}enable(){try{const t=this,{linkSelector:e}=t.options;return t.clickDelegate=t.delegateEvent(e,"click",t.handleLinkClick),window.addEventListener("popstate",t.handlePopState),t.options.plugins.forEach(e=>t.use(e)),o(null,{index:1}),Promise.resolve(m()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.handlePopState),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:r}=void 0===e?{}:e;const{origin:i,url:o,hash:s}=a.fromUrl(t);return i!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(o+s,{el:n,event:r})}handleLinkClick(t){const e=t.delegateTarget,{href:n,url:r,hash:i}=a.fromElement(e);this.shouldIgnoreVisit(n,{el:e,event:t})||(this.visit=this.createVisit({to:r,hash:i,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:n}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{const e=this.visit.from.url??"";t.preventDefault(),r&&r!==e?this.isSameResolvedUrl(r,e)||this.performNavigation():i?this.hooks.callSync("link:anchor",{hash:i},()=>{o(r+i),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>"navigate"===this.options.linkToSelf?this.performNavigation():this.scrollToContent())}))}handlePopState(t){const e=t.state?.url??location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(r(),this.currentPageUrl))return;const{url:n,hash:i}=a.fromUrl(e);this.visit=this.createVisit({to:n,hash:i,event:t,animate:this.options.animateHistoryBrowsing,resetScroll:this.options.animateHistoryBrowsing}),this.visit.history.popstate=!0;const o=Number(t.state?.index);o&&(this.visit.history.direction=o-this.currentHistoryIndex>0?"forwards":"backwards"),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation()})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}export{a as Location,n as classify,i as createHistoryRecord,K as default,s as delegateEvent,v as escapeCssIdentifier,f as forceReflow,r as getCurrentUrl,d as isPromise,c as matchPath,m as nextTick,h as query,u as queryAll,p as runAsPromise,g as toMs,o as updateHistoryRecord};
import t from"delegate-it";import{match as e}from"path-to-regexp";const n=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",i=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},r=function(t,e){void 0===e&&(e={});const n={url:t=t||i({hash:!0}),random:Math.random(),source:"swup",...e};history.pushState(n,"",t)},o=function(t,e){void 0===t&&(t=null),void 0===e&&(e={}),t=t||i({hash:!0});const n={...history.state||{},url:t,random:Math.random(),source:"swup",...e};history.replaceState(n,"",t)},s=(e,n,i,r)=>{const o=new AbortController;return r={...r,signal:o.signal},t(e,n,i,r),{destroy:()=>o.abort()}};class a extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new a(e)}static fromUrl(t){return new a(t)}}const c=(t,n)=>{try{return e(t,n)}catch(e){throw new Error(`[swup] Error parsing path "${String(t)}":\n${String(e)}`)}};class l{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,n)=>{t.set(n,{...e})}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?{...e}:e}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t);const n={...this.get(t),...e,url:t};this.pages.set(t,n)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0)}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=a.fromUrl(t);return this.swup.resolveUrl(e)}}const h=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},u=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},m=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function d(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function p(t,e){return void 0===e&&(e=[]),new Promise((n,i)=>{const r=t(...e);d(r)?r.then(n,i):n(r)})}function f(t){return t=t||document.body,t?.offsetHeight}const v=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,g=t=>1e3*Number(t.slice(0,-1).replace(",","."));class w{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?u(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function y(t){let{to:e,from:n=this.currentPageUrl,hash:i,el:r,event:o}=t;return{from:{url:n},to:{url:e,hash:i},containers:this.options.containers,animation:{animate:!0,wait:!1,name:void 0,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:r,event:o},cache:{read:this.options.cache,write:this.options.cache},history:{action:"push",popstate:!1,direction:void 0},scroll:{reset:!0,target:void 0}}}const P="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function k(t,e,n){if(!t.s){if(n instanceof S){if(!n.s)return void(n.o=k.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,t,e),k.bind(null,t,2));t.s=e,t.v=n;const i=t.o;i&&i(t)}}const S=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const i=new t,r=this.s;if(r){const t=1&r?e:n;if(t){try{k(i,1,t(this.v))}catch(t){k(i,2,t)}return i}return this}return this.o=function(t){try{const r=t.v;1&t.s?k(i,1,e?e(r):r):n?k(i,1,n(r)):k(i,2,r)}catch(t){k(i,2,t)}},i},t}();function b(t){return t instanceof S&&1&t.s}class E{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const i=this.get(t);if(!i)return console.warn(`Hook '${t}' not found.`),()=>{};const r=i.size+1,o={...n,id:r,hook:t,handler:e};return i.set(e,o),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n){try{const i=this,{before:r,handler:o,after:s}=i.getHandlers(t,n);return Promise.resolve(i.run(r,e)).then(function(){return Promise.resolve(i.run(o,e)).then(function(n){let[r]=n;return Promise.resolve(i.run(s,e)).then(function(){return i.dispatchDomEvent(t,e),r})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n){const{before:i,handler:r,after:o}=this.getHandlers(t,n);this.runSync(i,e);const[s]=this.runSync(r,e);return this.runSync(o,e),this.dispatchDomEvent(t,e),s}run(t,e){try{const n=this,i=[],r=function(t,e,n){if("function"==typeof t[P]){var i,r,o,s=t[P]();if(function t(n){try{for(;!(i=s.next()).done;)if((n=e(i.value))&&n.then){if(!b(n))return void n.then(t,o||(o=k.bind(null,r=new S,2)));n=n.v}r?k(r,1,n):r=n}catch(t){k(r||(r=new S),2,t)}}(),s.return){var a=function(t){try{i.done||s.return()}catch(t){}return t};if(r&&r.then)return r.then(a,function(t){throw a(t)});a()}return r}if(!("length"in t))throw new TypeError("Object is not iterable");for(var c=[],l=0;l<t.length;l++)c.push(t[l]);return function(t,e,n){var i,r,o=-1;return function n(s){try{for(;++o<t.length;)if((s=e(o))&&s.then){if(!b(s))return void s.then(n,r||(r=k.bind(null,i=new S,2)));s=s.v}i?k(i,1,s):i=s}catch(t){k(i||(i=new S),2,t)}}(),i}(c,function(t){return e(c[t])})}(t,function(t){let{hook:r,handler:o,defaultHandler:s,once:a}=t;return Promise.resolve(p(o,[n.swup.visit,e,s])).then(function(t){i.push(t),a&&n.off(r,o)})});return Promise.resolve(r&&r.then?r.then(function(){return i}):i)}catch(t){return Promise.reject(t)}}runSync(t,e){const n=[];for(const{hook:i,handler:r,defaultHandler:o,once:s}of t){const t=r(this.swup.visit,e,o);n.push(t),d(t)&&console.warn(`Promise returned from handler for synchronous hook '${i}'.Swup will not wait for it to resolve.`),s&&this.off(i,r)}return n}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const i=Array.from(n.values()),r=this.sortRegistrations,o=i.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(r),s=i.filter(t=>{let{replace:e}=t;return e}).filter(t=>!0).sort(r),a=i.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(r),c=s.length>0;let l=[];if(e&&(l=[{id:0,hook:t,handler:e}],c)){const n=s.length-1,i=t=>{const n=s[t-1];return n?(e,r)=>n.handler(e,r,i(t-1)):e};l=[{id:0,hook:t,handler:s[n].handler,defaultHandler:i(n)}]}return{found:!0,before:o,handler:l,after:a,replaced:c}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const U=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||h(`a[name='${v(t)}']`)||h(`a[name='${v(e)}']`);return n||"top"!==t||(n=document.body),n},C=function(t){let{elements:e,selector:n}=t;try{if(!1===n&&!e)return Promise.resolve();let t=[];if(e)t=Array.from(e);else if(n&&(t=u(n,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${n}\``),Promise.resolve();const i=t.map(t=>function(t){const{type:e,timeout:n,propCount:i}=function(t,e){const n=window.getComputedStyle(t),i=A(n,`${$}Delay`),r=A(n,`${$}Duration`),o=H(i,r),s=A(n,`${x}Delay`),a=A(n,`${x}Duration`),c=H(s,a);let l=null,h=0,u=0;return e===$?o>0&&(l=$,h=o,u=r.length):e===x?c>0&&(l=x,h=c,u=a.length):(h=Math.max(o,c),l=h>0?o>c?$:x:null,u=l?l===$?r.length:a.length:0),{type:l,timeout:h,propCount:u}}(t);return!(!e||!n)&&new Promise(r=>{const o=`${e}end`,s=performance.now();let a=0;const c=()=>{t.removeEventListener(o,l),r()},l=e=>{if(e.target===t){if(!function(t){return[`${$}end`,`${x}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-s)/1e3<e.elapsedTime||++a>=i&&c()}};setTimeout(()=>{a<i&&c()},n+1),t.addEventListener(o,l)})}(t));return i.filter(Boolean).length>0?Promise.resolve(Promise.all(i)).then(function(){}):(n&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${n}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},$="transition",x="animation";function A(t,e){return(t[e]||"").split(", ")}function H(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>g(e)+g(t[n])))}const j=function(t){void 0===t&&(t={});try{const e=this,{el:n}=e.visit.trigger;t.referrer=t.referrer||e.currentPageUrl,!1===t.animate&&(e.visit.animation.animate=!1),e.visit.animation.animate||e.classes.clear();const s=t.history||n?.getAttribute("data-swup-history")||void 0;s&&["push","replace"].includes(s)&&(e.visit.history.action=s);const a=t.animation||n?.getAttribute("data-swup-animation")||void 0;return a&&(e.visit.animation.name=a),"object"==typeof t.cache?(e.visit.cache.read=t.cache.read??e.visit.cache.read,e.visit.cache.write=t.cache.write??e.visit.cache.write):void 0!==t.cache&&(e.visit.cache={read:!!t.cache,write:!!t.cache}),delete t.cache,Promise.resolve(function(n,s){try{var a=Promise.resolve(e.hooks.call("visit:start",void 0)).then(function(){function n(){const t=e.animatePageOut();return Promise.resolve(Promise.all([s,t])).then(function(t){let[n]=t;return Promise.resolve(e.renderPage(e.visit.to.url,n)).then(function(){return Promise.resolve(e.animatePageIn()).then(function(){return Promise.resolve(e.hooks.call("visit:end",void 0,()=>e.classes.clear())).then(function(){})})})})}const s=e.hooks.call("page:load",{options:t},function(t,n){try{function i(t){return n.page=t,n.cache=!!r,n.page}let r;return e.visit.cache.read&&(r=e.cache.get(t.to.url)),Promise.resolve(r?i(r):Promise.resolve(e.fetchPage(t.to.url,n.options)).then(i))}catch(o){return Promise.reject(o)}});if(!e.visit.history.popstate){const t=e.visit.to.url+e.visit.to.hash;"replace"===e.visit.history.action||e.visit.to.url===e.currentPageUrl?o(t):r(t,{index:e.currentHistoryIndex+1})}e.currentPageUrl=i();const a=function(){if(e.visit.animation.wait)return Promise.resolve(s).then(function(t){let{html:n}=t;e.visit.to.html=n})}();return a&&a.then?a.then(n):n()})}catch(t){return s(t)}return a&&a.then?a.then(void 0,s):a}(0,function(t){t&&(console.error(t),e.options.skipPopStateHandling=()=>(window.location.href=e.visit.to.url+e.visit.to.hash,!0),window.history.go(-1))}))}catch(t){return Promise.reject(t)}};function q(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),"string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:n.el,event:n.event}))return void(window.location.href=t);const{url:i,hash:r}=a.fromUrl(t);this.visit=this.createVisit({...n,to:i,hash:r}),this.performNavigation(e)}const R=function(t,e){void 0===e&&(e={});try{const n=this;t=a.fromUrl(t).url;const i={...n.options.requestHeaders,...e.headers};return e={...e,headers:i},Promise.resolve(n.hooks.call("fetch:request",{url:t,options:e},(t,e)=>{let{url:n,options:i}=e;return fetch(n,i)})).then(function(i){const{status:r,url:o}=i;return Promise.resolve(i.text()).then(function(s){if(500===r)throw n.hooks.call("fetch:error",{status:r,response:i,url:o}),new L(`Server error: ${o}`,{status:r,url:o});if(!s)throw new L(`Empty response: ${o}`,{status:r,url:o});const{url:c}=a.fromUrl(o),l={url:c,html:s};return!n.visit.cache.write||e.method&&"GET"!==e.method||t!==c||n.cache.set(l.url,l),l})})}catch(t){return Promise.reject(t)}};class L extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}const N=function(){try{let e;const i=this;function t(t){return e?t:Promise.resolve(i.hooks.call("animation:out:start",void 0,t=>{i.classes.add("is-changing","is-leaving","is-animating"),t.history.popstate&&i.classes.add("is-popstate"),t.animation.name&&i.classes.add(`to-${n(t.animation.name)}`)})).then(function(){return Promise.resolve(i.hooks.call("animation:out:await",{skip:!1},function(t,e){let{skip:n}=e;try{return n?Promise.resolve():Promise.resolve(i.awaitAnimations({selector:t.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}})).then(function(){return Promise.resolve(i.hooks.call("animation:out:end",void 0)).then(function(){})})})}const r=function(){if(!i.visit.animation.animate)return Promise.resolve(i.hooks.call("animation:skip",void 0)).then(function(){e=1})}();return Promise.resolve(r&&r.then?r.then(t):t(r))}catch(o){return Promise.reject(o)}},I=function(t,e){let{html:n}=t,{containers:i}=void 0===e?this.options:e;const r=(new DOMParser).parseFromString(n,"text/html"),o=r.querySelector("title")?.innerText||"";document.title=o;const s=u('[data-swup-persist]:not([data-swup-persist=""])'),a=i.map(t=>{const e=document.querySelector(t),n=r.querySelector(t);return e&&n?(e.replaceWith(n),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),n||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return s.forEach(t=>{const e=t.getAttribute("data-swup-persist"),n=h(`[data-swup-persist="${e}"]`);n&&n!==t&&n.replaceWith(t)}),a.length===i.length},T=function(){const t={behavior:"auto"},{target:e,reset:n}=this.visit.scroll,i=e??this.visit.to.hash;let r=!1;return i&&(r=this.hooks.callSync("scroll:anchor",{hash:i,options:t},(t,e)=>{let{hash:n,options:i}=e;const r=this.getAnchorElement(n);return r&&r.scrollIntoView(i),!!r})),n&&!r&&(r=this.hooks.callSync("scroll:top",{options:t},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),r},D=function(){try{const t=this;if(!t.visit.animation.animate)return Promise.resolve();const e=t.hooks.call("animation:in:await",{skip:!1},function(e,n){let{skip:i}=n;try{return i?Promise.resolve():Promise.resolve(t.awaitAnimations({selector:e.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}});return Promise.resolve(m()).then(function(){return Promise.resolve(t.hooks.call("animation:in:start",void 0,()=>{t.classes.remove("is-animating")})).then(function(){return Promise.resolve(e).then(function(){return Promise.resolve(t.hooks.call("animation:in:end",void 0)).then(function(){})})})})}catch(t){return Promise.reject(t)}},M=function(t,e){try{const r=this,{url:s,html:a}=e;return r.classes.remove("is-leaving"),r.isSameResolvedUrl(i(),t)?(r.isSameResolvedUrl(i(),s)||(o(s),r.currentPageUrl=i(),r.visit.to.url=r.currentPageUrl),r.visit.animation.animate&&r.classes.add("is-rendering"),r.visit.to.html=a,Promise.resolve(r.hooks.call("content:replace",{page:e},(t,e)=>{let{page:i}=e;if(!r.replaceContent(i,{containers:t.containers}))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(r.classes.add("is-animating","is-changing","is-rendering"),t.animation.name&&r.classes.add(`to-${n(t.animation.name)}`))})).then(function(){return Promise.resolve(r.hooks.call("content:scroll",void 0,()=>r.scrollToContent())).then(function(){return Promise.resolve(r.hooks.call("page:view",{url:r.currentPageUrl,title:document.title})).then(function(){})})})):Promise.resolve()}catch(t){return Promise.reject(t)}},V=function(t){var e;if(e=t,Boolean(e?.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function W(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function B(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function _(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function O(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const F={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!!n?.closest("[data-no-swup]")},linkSelector:"a[href]",linkToSelf:"scroll",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>"swup"!==t.state?.source};class K{constructor(t){void 0===t&&(t={}),this.version="4.3.1",this.options=void 0,this.defaults=F,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=i(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.use=V,this.unuse=W,this.findPlugin=B,this.log=()=>{},this.navigate=q,this.performNavigation=j,this.createVisit=y,this.delegateEvent=s,this.fetchPage=R,this.awaitAnimations=C,this.renderPage=M,this.replaceContent=I,this.animatePageIn=D,this.animatePageOut=N,this.scrollToContent=T,this.getAnchorElement=U,this.getCurrentUrl=i,this.resolveUrl=_,this.isSameResolvedUrl=O,this.options={...this.defaults,...t},this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new l(this),this.classes=new w(this),this.hooks=new E(this),this.visit=this.createVisit({to:""}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}enable(){try{const t=this,{linkSelector:e}=t.options;return t.clickDelegate=t.delegateEvent(e,"click",t.handleLinkClick),window.addEventListener("popstate",t.handlePopState),t.options.animateHistoryBrowsing&&(window.history.scrollRestoration="manual"),t.options.plugins.forEach(e=>t.use(e)),o(null,{index:1}),Promise.resolve(m()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.handlePopState),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:i}=void 0===e?{}:e;const{origin:r,url:o,hash:s}=a.fromUrl(t);return r!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(o+s,{el:n,event:i})}handleLinkClick(t){const e=t.delegateTarget,{href:n,url:i,hash:r}=a.fromElement(e);this.shouldIgnoreVisit(n,{el:e,event:t})||(this.visit=this.createVisit({to:i,hash:r,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:n}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{const e=this.visit.from.url??"";t.preventDefault(),i&&i!==e?this.isSameResolvedUrl(i,e)||this.performNavigation():r?this.hooks.callSync("link:anchor",{hash:r},()=>{o(i+r),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>"navigate"===this.options.linkToSelf?this.performNavigation():this.scrollToContent())}))}handlePopState(t){const e=t.state?.url??location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(i(),this.currentPageUrl))return;const{url:n,hash:r}=a.fromUrl(e);this.visit=this.createVisit({to:n,hash:r,event:t}),this.visit.history.popstate=!0;const o=Number(t.state?.index);o&&(this.visit.history.direction=o-this.currentHistoryIndex>0?"forwards":"backwards"),this.visit.animation.animate=!1,this.visit.scroll.reset=!1,this.visit.scroll.target=!1,this.options.animateHistoryBrowsing&&(this.visit.animation.animate=!0,this.visit.scroll.reset=!0),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation()})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}export{a as Location,n as classify,r as createHistoryRecord,K as default,s as delegateEvent,v as escapeCssIdentifier,f as forceReflow,i as getCurrentUrl,d as isPromise,c as matchPath,m as nextTick,h as query,u as queryAll,p as runAsPromise,g as toMs,o as updateHistoryRecord};
//# sourceMappingURL=Swup.module.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).Swup=e()}(this,function(){const t=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",e=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},n=function(t,n){void 0===n&&(n={});const i={url:t=t||e({hash:!0}),random:Math.random(),source:"swup",...n};history.pushState(i,"",t)},i=function(t,n){void 0===t&&(t=null),void 0===n&&(n={}),t=t||e({hash:!0});const i={...history.state||{},url:t,random:Math.random(),source:"swup",...n};history.replaceState(i,"",t)},r=new WeakMap;function o(t,e,n,i){if(!t&&!r.has(e))return!1;const o=r.get(e)??new WeakMap;r.set(e,o);const s=o.get(n)??new Set;o.set(n,s);const a=s.has(i);return t?s.add(i):s.delete(i),a&&t}const s=(t,e,n,i)=>{const r=new AbortController;return function(t,e,n,i={}){const{signal:r,base:s=document}=i;if(r?.aborted)return;const{once:a,...c}=i,l=s instanceof Document?s.documentElement:s,h=Boolean("object"==typeof i?i.capture:i),u=i=>{const r=function(t,e){let n=t.target;if(n instanceof Text&&(n=n.parentElement),n instanceof Element&&t.currentTarget instanceof Element){const i=n.closest(e);if(i&&t.currentTarget.contains(i))return i}}(i,t);if(r){const t=Object.assign(i,{delegateTarget:r});n.call(l,t),a&&(l.removeEventListener(e,u,c),o(!1,l,n,d))}},d=JSON.stringify({selector:t,type:e,capture:h});o(!0,l,n,d)||l.addEventListener(e,u,c),r?.addEventListener("abort",()=>{o(!1,l,n,d)})}(t,e,n,i={...i,signal:r.signal}),{destroy:()=>r.abort()}};class a extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new a(e)}static fromUrl(t){return new a(t)}}class c{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,n)=>{t.set(n,{...e})}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?{...e}:e}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t);const n={...this.get(t),...e,url:t};this.pages.set(t,n)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0)}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=a.fromUrl(t);return this.swup.resolveUrl(e)}}const l=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},h=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},u=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function d(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}const m=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,f=t=>1e3*Number(t.slice(0,-1).replace(",","."));class p{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?h(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function v(t){let{to:e,from:n=this.currentPageUrl,hash:i,animate:r=!0,animation:o,el:s,event:a,action:c="push",resetScroll:l=!0}=t;return{from:{url:n},to:{url:e,hash:i},containers:this.options.containers,animation:{animate:r,wait:!1,name:o,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:s,event:a},cache:{read:this.options.cache,write:this.options.cache},history:{action:c,popstate:!1,direction:void 0},scroll:{reset:l,target:void 0}}}const g="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function w(t,e,n){if(!t.s){if(n instanceof y){if(!n.s)return void(n.o=w.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(w.bind(null,t,e),w.bind(null,t,2));t.s=e,t.v=n;const i=t.o;i&&i(t)}}const y=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const i=new t,r=this.s;if(r){const t=1&r?e:n;if(t){try{w(i,1,t(this.v))}catch(t){w(i,2,t)}return i}return this}return this.o=function(t){try{const r=t.v;1&t.s?w(i,1,e?e(r):r):n?w(i,1,n(r)):w(i,2,r)}catch(t){w(i,2,t)}},i},t}();function P(t){return t instanceof y&&1&t.s}class k{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const i=this.get(t);if(!i)return console.warn(`Hook '${t}' not found.`),()=>{};const r=i.size+1,o={...n,id:r,hook:t,handler:e};return i.set(e,o),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n){try{const i=this,{before:r,handler:o,after:s}=i.getHandlers(t,n);return Promise.resolve(i.run(r,e)).then(function(){return Promise.resolve(i.run(o,e)).then(function(n){let[r]=n;return Promise.resolve(i.run(s,e)).then(function(){return i.dispatchDomEvent(t,e),r})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n){const{before:i,handler:r,after:o}=this.getHandlers(t,n);this.runSync(i,e);const[s]=this.runSync(r,e);return this.runSync(o,e),this.dispatchDomEvent(t,e),s}run(t,e){try{const n=this,i=[],r=function(t,e,n){if("function"==typeof t[g]){var i,r,o,s=t[g]();if(function t(n){try{for(;!(i=s.next()).done;)if((n=e(i.value))&&n.then){if(!P(n))return void n.then(t,o||(o=w.bind(null,r=new y,2)));n=n.v}r?w(r,1,n):r=n}catch(t){w(r||(r=new y),2,t)}}(),s.return){var a=function(t){try{i.done||s.return()}catch(t){}return t};if(r&&r.then)return r.then(a,function(t){throw a(t)});a()}return r}if(!("length"in t))throw new TypeError("Object is not iterable");for(var c=[],l=0;l<t.length;l++)c.push(t[l]);return function(t,e,n){var i,r,o=-1;return function n(s){try{for(;++o<t.length;)if((s=e(o))&&s.then){if(!P(s))return void s.then(n,r||(r=w.bind(null,i=new y,2)));s=s.v}i?w(i,1,s):i=s}catch(t){w(i||(i=new y),2,t)}}(),i}(c,function(t){return e(c[t])})}(t,function(t){let{hook:r,handler:o,defaultHandler:s,once:a}=t;return Promise.resolve(function(t,e){return void 0===e&&(e=[]),new Promise((n,i)=>{const r=t(...e);d(r)?r.then(n,i):n(r)})}(o,[n.swup.visit,e,s])).then(function(t){i.push(t),a&&n.off(r,o)})});return Promise.resolve(r&&r.then?r.then(function(){return i}):i)}catch(t){return Promise.reject(t)}}runSync(t,e){const n=[];for(const{hook:i,handler:r,defaultHandler:o,once:s}of t){const t=r(this.swup.visit,e,o);n.push(t),d(t)&&console.warn(`Promise returned from handler for synchronous hook '${i}'.Swup will not wait for it to resolve.`),s&&this.off(i,r)}return n}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const i=Array.from(n.values()),r=this.sortRegistrations,o=i.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(r),s=i.filter(t=>{let{replace:e}=t;return e}).filter(t=>!0).sort(r),a=i.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(r),c=s.length>0;let l=[];if(e&&(l=[{id:0,hook:t,handler:e}],c)){const n=s.length-1,i=t=>{const n=s[t-1];return n?(e,r)=>n.handler(e,r,i(t-1)):e};l=[{id:0,hook:t,handler:s[n].handler,defaultHandler:i(n)}]}return{found:!0,before:o,handler:l,after:a,replaced:c}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const S=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||l(`a[name='${m(t)}']`)||l(`a[name='${m(e)}']`);return n||"top"!==t||(n=document.body),n},b=function(t){let{elements:e,selector:n}=t;try{if(!1===n&&!e)return Promise.resolve();let t=[];if(e)t=Array.from(e);else if(n&&(t=h(n,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${n}\``),Promise.resolve();const i=t.map(t=>function(t){const{type:e,timeout:n,propCount:i}=function(t,e){const n=window.getComputedStyle(t),i=C(n,`${E}Delay`),r=C(n,`${E}Duration`),o=$(i,r),s=C(n,`${U}Delay`),a=C(n,`${U}Duration`),c=$(s,a);let l=null,h=0,u=0;return e===E?o>0&&(l=E,h=o,u=r.length):e===U?c>0&&(l=U,h=c,u=a.length):(h=Math.max(o,c),l=h>0?o>c?E:U:null,u=l?l===E?r.length:a.length:0),{type:l,timeout:h,propCount:u}}(t);return!(!e||!n)&&new Promise(r=>{const o=`${e}end`,s=performance.now();let a=0;const c=()=>{t.removeEventListener(o,l),r()},l=e=>{if(e.target===t){if(!function(t){return[`${E}end`,`${U}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-s)/1e3<e.elapsedTime||++a>=i&&c()}};setTimeout(()=>{a<i&&c()},n+1),t.addEventListener(o,l)})}(t));return i.filter(Boolean).length>0?Promise.resolve(Promise.all(i)).then(function(){}):(n&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${n}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},E="transition",U="animation";function C(t,e){return(t[e]||"").split(", ")}function $(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>f(e)+f(t[n])))}const x=function(t){void 0===t&&(t={});try{const r=this,{el:o}=r.visit.trigger;t.referrer=t.referrer||r.currentPageUrl,!1===t.animate&&(r.visit.animation.animate=!1),r.visit.animation.animate||r.classes.clear();const s=t.history||o?.getAttribute("data-swup-history")||void 0;s&&["push","replace"].includes(s)&&(r.visit.history.action=s);const a=t.animation||o?.getAttribute("data-swup-animation")||void 0;return a&&(r.visit.animation.name=a),"object"==typeof t.cache?(r.visit.cache.read=t.cache.read??r.visit.cache.read,r.visit.cache.write=t.cache.write??r.visit.cache.write):void 0!==t.cache&&(r.visit.cache={read:!!t.cache,write:!!t.cache}),delete t.cache,Promise.resolve(function(o,s){try{var a=Promise.resolve(r.hooks.call("visit:start",void 0)).then(function(){function o(){const t=r.animatePageOut();return Promise.resolve(Promise.all([s,t])).then(function(t){let[e]=t;return Promise.resolve(r.renderPage(r.visit.to.url,e)).then(function(){return Promise.resolve(r.animatePageIn()).then(function(){return Promise.resolve(r.hooks.call("visit:end",void 0,()=>r.classes.clear())).then(function(){})})})})}const s=r.hooks.call("page:load",{options:t},function(t,e){try{function n(t){return e.page=t,e.cache=!!i,e.page}let i;return r.visit.cache.read&&(i=r.cache.get(t.to.url)),Promise.resolve(i?n(i):Promise.resolve(r.fetchPage(t.to.url,e.options)).then(n))}catch(o){return Promise.reject(o)}});if(!r.visit.history.popstate){const t=r.visit.to.url+r.visit.to.hash;"replace"===r.visit.history.action||r.visit.to.url===r.currentPageUrl?i(t):n(t,{index:r.currentHistoryIndex+1})}r.currentPageUrl=e();const a=function(){if(r.visit.animation.wait)return Promise.resolve(s).then(function(t){let{html:e}=t;r.visit.to.html=e})}();return a&&a.then?a.then(o):o()})}catch(t){return s(t)}return a&&a.then?a.then(void 0,s):a}(0,function(t){t&&(console.error(t),r.options.skipPopStateHandling=()=>(window.location.href=r.visit.to.url+r.visit.to.hash,!0),window.history.go(-1))}))}catch(t){return Promise.reject(t)}};function A(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),"string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:n.el,event:n.event}))return void(window.location.href=t);const{url:i,hash:r}=a.fromUrl(t);this.visit=this.createVisit({...n,to:i,hash:r}),this.performNavigation(e)}const j=function(t,e){void 0===e&&(e={});try{const n=this;t=a.fromUrl(t).url;const i={...n.options.requestHeaders,...e.headers};return e={...e,headers:i},Promise.resolve(n.hooks.call("fetch:request",{url:t,options:e},(t,e)=>{let{url:n,options:i}=e;return fetch(n,i)})).then(function(i){const{status:r,url:o}=i;return Promise.resolve(i.text()).then(function(s){if(500===r)throw n.hooks.call("fetch:error",{status:r,response:i,url:o}),new H(`Server error: ${o}`,{status:r,url:o});if(!s)throw new H(`Empty response: ${o}`,{status:r,url:o});const{url:c}=a.fromUrl(o),l={url:c,html:s};return!n.visit.cache.write||e.method&&"GET"!==e.method||t!==c||n.cache.set(l.url,l),l})})}catch(t){return Promise.reject(t)}};class H extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}const L=function(){try{let n;const i=this;function e(e){return n?e:Promise.resolve(i.hooks.call("animation:out:start",void 0,e=>{i.classes.add("is-changing","is-leaving","is-animating"),e.history.popstate&&i.classes.add("is-popstate"),e.animation.name&&i.classes.add(`to-${t(e.animation.name)}`)})).then(function(){return Promise.resolve(i.hooks.call("animation:out:await",{skip:!1},function(t,e){let{skip:n}=e;try{return n?Promise.resolve():Promise.resolve(i.awaitAnimations({selector:t.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}})).then(function(){return Promise.resolve(i.hooks.call("animation:out:end",void 0)).then(function(){})})})}const r=function(){if(!i.visit.animation.animate)return Promise.resolve(i.hooks.call("animation:skip",void 0)).then(function(){n=1})}();return Promise.resolve(r&&r.then?r.then(e):e(r))}catch(o){return Promise.reject(o)}},T=function(t,e){let{html:n}=t,{containers:i}=void 0===e?this.options:e;const r=(new DOMParser).parseFromString(n,"text/html"),o=r.querySelector("title")?.innerText||"";document.title=o;const s=h('[data-swup-persist]:not([data-swup-persist=""])'),a=i.map(t=>{const e=document.querySelector(t),n=r.querySelector(t);return e&&n?(e.replaceWith(n),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),n||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return s.forEach(t=>{const e=t.getAttribute("data-swup-persist"),n=l(`[data-swup-persist="${e}"]`);n&&n!==t&&n.replaceWith(t)}),a.length===i.length},q=function(){const t={behavior:"auto"},{target:e,reset:n}=this.visit.scroll,i=e||this.visit.to.hash;let r=!1;return i&&(r=this.hooks.callSync("scroll:anchor",{hash:i,options:t},(t,e)=>{let{hash:n,options:i}=e;const r=this.getAnchorElement(n);return r&&r.scrollIntoView(i),!!r})),n&&!r&&(r=this.hooks.callSync("scroll:top",{options:t},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),r},N=function(){try{const t=this;if(!t.visit.animation.animate)return Promise.resolve();const e=t.hooks.call("animation:in:await",{skip:!1},function(e,n){let{skip:i}=n;try{return i?Promise.resolve():Promise.resolve(t.awaitAnimations({selector:e.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}});return Promise.resolve(u()).then(function(){return Promise.resolve(t.hooks.call("animation:in:start",void 0,()=>{t.classes.remove("is-animating")})).then(function(){return Promise.resolve(e).then(function(){return Promise.resolve(t.hooks.call("animation:in:end",void 0)).then(function(){})})})})}catch(t){return Promise.reject(t)}},R=function(n,r){try{const o=this,{url:s,html:a}=r;return o.classes.remove("is-leaving"),o.isSameResolvedUrl(e(),n)?(o.isSameResolvedUrl(e(),s)||(i(s),o.currentPageUrl=e(),o.visit.to.url=o.currentPageUrl),o.visit.animation.animate&&o.classes.add("is-rendering"),o.visit.to.html=a,Promise.resolve(o.hooks.call("content:replace",{page:r},(e,n)=>{let{page:i}=n;if(!o.replaceContent(i,{containers:e.containers}))throw new Error("[swup] Container mismatch, aborting");e.animation.animate&&(o.classes.add("is-animating","is-changing","is-rendering"),e.animation.name&&o.classes.add(`to-${t(e.animation.name)}`))})).then(function(){return Promise.resolve(o.hooks.call("content:scroll",void 0,()=>o.scrollToContent())).then(function(){return Promise.resolve(o.hooks.call("page:view",{url:o.currentPageUrl,title:document.title})).then(function(){})})})):Promise.resolve()}catch(t){return Promise.reject(t)}},D=function(t){var e;if(e=t,Boolean(e?.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function I(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function M(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function W(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function V(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const B={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!!n?.closest("[data-no-swup]")},linkSelector:"a[href]",linkToSelf:"scroll",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>"swup"!==t.state?.source};return class{constructor(t){void 0===t&&(t={}),this.version="4.3.0",this.options=void 0,this.defaults=B,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=e(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.use=D,this.unuse=I,this.findPlugin=M,this.log=()=>{},this.navigate=A,this.performNavigation=x,this.createVisit=v,this.delegateEvent=s,this.fetchPage=j,this.awaitAnimations=b,this.renderPage=R,this.replaceContent=T,this.animatePageIn=N,this.animatePageOut=L,this.scrollToContent=q,this.getAnchorElement=S,this.getCurrentUrl=e,this.resolveUrl=W,this.isSameResolvedUrl=V,this.options={...this.defaults,...t},this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new c(this),this.classes=new p(this),this.hooks=new k(this),this.visit=this.createVisit({to:""}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}enable(){try{const t=this,{linkSelector:e}=t.options;return t.clickDelegate=t.delegateEvent(e,"click",t.handleLinkClick),window.addEventListener("popstate",t.handlePopState),t.options.plugins.forEach(e=>t.use(e)),i(null,{index:1}),Promise.resolve(u()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.handlePopState),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:i}=void 0===e?{}:e;const{origin:r,url:o,hash:s}=a.fromUrl(t);return r!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(o+s,{el:n,event:i})}handleLinkClick(t){const e=t.delegateTarget,{href:n,url:r,hash:o}=a.fromElement(e);this.shouldIgnoreVisit(n,{el:e,event:t})||(this.visit=this.createVisit({to:r,hash:o,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:n}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{const e=this.visit.from.url??"";t.preventDefault(),r&&r!==e?this.isSameResolvedUrl(r,e)||this.performNavigation():o?this.hooks.callSync("link:anchor",{hash:o},()=>{i(r+o),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>"navigate"===this.options.linkToSelf?this.performNavigation():this.scrollToContent())}))}handlePopState(t){const n=t.state?.url??location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(e(),this.currentPageUrl))return;const{url:i,hash:r}=a.fromUrl(n);this.visit=this.createVisit({to:i,hash:r,event:t,animate:this.options.animateHistoryBrowsing,resetScroll:this.options.animateHistoryBrowsing}),this.visit.history.popstate=!0;const o=Number(t.state?.index);o&&(this.visit.history.direction=o-this.currentHistoryIndex>0?"forwards":"backwards"),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation()})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).Swup=e()}(this,function(){const t=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",e=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},n=function(t,n){void 0===n&&(n={});const i={url:t=t||e({hash:!0}),random:Math.random(),source:"swup",...n};history.pushState(i,"",t)},i=function(t,n){void 0===t&&(t=null),void 0===n&&(n={}),t=t||e({hash:!0});const i={...history.state||{},url:t,random:Math.random(),source:"swup",...n};history.replaceState(i,"",t)},r=new WeakMap;function o(t,e,n,i){if(!t&&!r.has(e))return!1;const o=r.get(e)??new WeakMap;r.set(e,o);const s=o.get(n)??new Set;o.set(n,s);const a=s.has(i);return t?s.add(i):s.delete(i),a&&t}const s=(t,e,n,i)=>{const r=new AbortController;return function(t,e,n,i={}){const{signal:r,base:s=document}=i;if(r?.aborted)return;const{once:a,...c}=i,l=s instanceof Document?s.documentElement:s,h=Boolean("object"==typeof i?i.capture:i),u=i=>{const r=function(t,e){let n=t.target;if(n instanceof Text&&(n=n.parentElement),n instanceof Element&&t.currentTarget instanceof Element){const i=n.closest(e);if(i&&t.currentTarget.contains(i))return i}}(i,t);if(r){const t=Object.assign(i,{delegateTarget:r});n.call(l,t),a&&(l.removeEventListener(e,u,c),o(!1,l,n,d))}},d=JSON.stringify({selector:t,type:e,capture:h});o(!0,l,n,d)||l.addEventListener(e,u,c),r?.addEventListener("abort",()=>{o(!1,l,n,d)})}(t,e,n,i={...i,signal:r.signal}),{destroy:()=>r.abort()}};class a extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new a(e)}static fromUrl(t){return new a(t)}}class c{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){const t=new Map;return this.pages.forEach((e,n)=>{t.set(n,{...e})}),t}has(t){return this.pages.has(this.resolve(t))}get(t){const e=this.pages.get(this.resolve(t));return e?{...e}:e}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t);const n={...this.get(t),...e,url:t};this.pages.set(t,n)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear",void 0)}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=a.fromUrl(t);return this.swup.resolveUrl(e)}}const l=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},h=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},u=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function d(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}const m=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,f=t=>1e3*Number(t.slice(0,-1).replace(",","."));class p{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?h(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function v(t){let{to:e,from:n=this.currentPageUrl,hash:i,el:r,event:o}=t;return{from:{url:n},to:{url:e,hash:i},containers:this.options.containers,animation:{animate:!0,wait:!1,name:void 0,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:r,event:o},cache:{read:this.options.cache,write:this.options.cache},history:{action:"push",popstate:!1,direction:void 0},scroll:{reset:!0,target:void 0}}}const g="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function w(t,e,n){if(!t.s){if(n instanceof y){if(!n.s)return void(n.o=w.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(w.bind(null,t,e),w.bind(null,t,2));t.s=e,t.v=n;const i=t.o;i&&i(t)}}const y=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const i=new t,r=this.s;if(r){const t=1&r?e:n;if(t){try{w(i,1,t(this.v))}catch(t){w(i,2,t)}return i}return this}return this.o=function(t){try{const r=t.v;1&t.s?w(i,1,e?e(r):r):n?w(i,1,n(r)):w(i,2,r)}catch(t){w(i,2,t)}},i},t}();function P(t){return t instanceof y&&1&t.s}class k{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const i=this.get(t);if(!i)return console.warn(`Hook '${t}' not found.`),()=>{};const r=i.size+1,o={...n,id:r,hook:t,handler:e};return i.set(e,o),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n){try{const i=this,{before:r,handler:o,after:s}=i.getHandlers(t,n);return Promise.resolve(i.run(r,e)).then(function(){return Promise.resolve(i.run(o,e)).then(function(n){let[r]=n;return Promise.resolve(i.run(s,e)).then(function(){return i.dispatchDomEvent(t,e),r})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n){const{before:i,handler:r,after:o}=this.getHandlers(t,n);this.runSync(i,e);const[s]=this.runSync(r,e);return this.runSync(o,e),this.dispatchDomEvent(t,e),s}run(t,e){try{const n=this,i=[],r=function(t,e,n){if("function"==typeof t[g]){var i,r,o,s=t[g]();if(function t(n){try{for(;!(i=s.next()).done;)if((n=e(i.value))&&n.then){if(!P(n))return void n.then(t,o||(o=w.bind(null,r=new y,2)));n=n.v}r?w(r,1,n):r=n}catch(t){w(r||(r=new y),2,t)}}(),s.return){var a=function(t){try{i.done||s.return()}catch(t){}return t};if(r&&r.then)return r.then(a,function(t){throw a(t)});a()}return r}if(!("length"in t))throw new TypeError("Object is not iterable");for(var c=[],l=0;l<t.length;l++)c.push(t[l]);return function(t,e,n){var i,r,o=-1;return function n(s){try{for(;++o<t.length;)if((s=e(o))&&s.then){if(!P(s))return void s.then(n,r||(r=w.bind(null,i=new y,2)));s=s.v}i?w(i,1,s):i=s}catch(t){w(i||(i=new y),2,t)}}(),i}(c,function(t){return e(c[t])})}(t,function(t){let{hook:r,handler:o,defaultHandler:s,once:a}=t;return Promise.resolve(function(t,e){return void 0===e&&(e=[]),new Promise((n,i)=>{const r=t(...e);d(r)?r.then(n,i):n(r)})}(o,[n.swup.visit,e,s])).then(function(t){i.push(t),a&&n.off(r,o)})});return Promise.resolve(r&&r.then?r.then(function(){return i}):i)}catch(t){return Promise.reject(t)}}runSync(t,e){const n=[];for(const{hook:i,handler:r,defaultHandler:o,once:s}of t){const t=r(this.swup.visit,e,o);n.push(t),d(t)&&console.warn(`Promise returned from handler for synchronous hook '${i}'.Swup will not wait for it to resolve.`),s&&this.off(i,r)}return n}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const i=Array.from(n.values()),r=this.sortRegistrations,o=i.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(r),s=i.filter(t=>{let{replace:e}=t;return e}).filter(t=>!0).sort(r),a=i.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(r),c=s.length>0;let l=[];if(e&&(l=[{id:0,hook:t,handler:e}],c)){const n=s.length-1,i=t=>{const n=s[t-1];return n?(e,r)=>n.handler(e,r,i(t-1)):e};l=[{id:0,hook:t,handler:s[n].handler,defaultHandler:i(n)}]}return{found:!0,before:o,handler:l,after:a,replaced:c}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const S=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||l(`a[name='${m(t)}']`)||l(`a[name='${m(e)}']`);return n||"top"!==t||(n=document.body),n},b=function(t){let{elements:e,selector:n}=t;try{if(!1===n&&!e)return Promise.resolve();let t=[];if(e)t=Array.from(e);else if(n&&(t=h(n,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${n}\``),Promise.resolve();const i=t.map(t=>function(t){const{type:e,timeout:n,propCount:i}=function(t,e){const n=window.getComputedStyle(t),i=C(n,`${E}Delay`),r=C(n,`${E}Duration`),o=$(i,r),s=C(n,`${U}Delay`),a=C(n,`${U}Duration`),c=$(s,a);let l=null,h=0,u=0;return e===E?o>0&&(l=E,h=o,u=r.length):e===U?c>0&&(l=U,h=c,u=a.length):(h=Math.max(o,c),l=h>0?o>c?E:U:null,u=l?l===E?r.length:a.length:0),{type:l,timeout:h,propCount:u}}(t);return!(!e||!n)&&new Promise(r=>{const o=`${e}end`,s=performance.now();let a=0;const c=()=>{t.removeEventListener(o,l),r()},l=e=>{if(e.target===t){if(!function(t){return[`${E}end`,`${U}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-s)/1e3<e.elapsedTime||++a>=i&&c()}};setTimeout(()=>{a<i&&c()},n+1),t.addEventListener(o,l)})}(t));return i.filter(Boolean).length>0?Promise.resolve(Promise.all(i)).then(function(){}):(n&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${n}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},E="transition",U="animation";function C(t,e){return(t[e]||"").split(", ")}function $(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>f(e)+f(t[n])))}const x=function(t){void 0===t&&(t={});try{const r=this,{el:o}=r.visit.trigger;t.referrer=t.referrer||r.currentPageUrl,!1===t.animate&&(r.visit.animation.animate=!1),r.visit.animation.animate||r.classes.clear();const s=t.history||o?.getAttribute("data-swup-history")||void 0;s&&["push","replace"].includes(s)&&(r.visit.history.action=s);const a=t.animation||o?.getAttribute("data-swup-animation")||void 0;return a&&(r.visit.animation.name=a),"object"==typeof t.cache?(r.visit.cache.read=t.cache.read??r.visit.cache.read,r.visit.cache.write=t.cache.write??r.visit.cache.write):void 0!==t.cache&&(r.visit.cache={read:!!t.cache,write:!!t.cache}),delete t.cache,Promise.resolve(function(o,s){try{var a=Promise.resolve(r.hooks.call("visit:start",void 0)).then(function(){function o(){const t=r.animatePageOut();return Promise.resolve(Promise.all([s,t])).then(function(t){let[e]=t;return Promise.resolve(r.renderPage(r.visit.to.url,e)).then(function(){return Promise.resolve(r.animatePageIn()).then(function(){return Promise.resolve(r.hooks.call("visit:end",void 0,()=>r.classes.clear())).then(function(){})})})})}const s=r.hooks.call("page:load",{options:t},function(t,e){try{function n(t){return e.page=t,e.cache=!!i,e.page}let i;return r.visit.cache.read&&(i=r.cache.get(t.to.url)),Promise.resolve(i?n(i):Promise.resolve(r.fetchPage(t.to.url,e.options)).then(n))}catch(o){return Promise.reject(o)}});if(!r.visit.history.popstate){const t=r.visit.to.url+r.visit.to.hash;"replace"===r.visit.history.action||r.visit.to.url===r.currentPageUrl?i(t):n(t,{index:r.currentHistoryIndex+1})}r.currentPageUrl=e();const a=function(){if(r.visit.animation.wait)return Promise.resolve(s).then(function(t){let{html:e}=t;r.visit.to.html=e})}();return a&&a.then?a.then(o):o()})}catch(t){return s(t)}return a&&a.then?a.then(void 0,s):a}(0,function(t){t&&(console.error(t),r.options.skipPopStateHandling=()=>(window.location.href=r.visit.to.url+r.visit.to.hash,!0),window.history.go(-1))}))}catch(t){return Promise.reject(t)}};function A(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),"string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");if(this.shouldIgnoreVisit(t,{el:n.el,event:n.event}))return void(window.location.href=t);const{url:i,hash:r}=a.fromUrl(t);this.visit=this.createVisit({...n,to:i,hash:r}),this.performNavigation(e)}const j=function(t,e){void 0===e&&(e={});try{const n=this;t=a.fromUrl(t).url;const i={...n.options.requestHeaders,...e.headers};return e={...e,headers:i},Promise.resolve(n.hooks.call("fetch:request",{url:t,options:e},(t,e)=>{let{url:n,options:i}=e;return fetch(n,i)})).then(function(i){const{status:r,url:o}=i;return Promise.resolve(i.text()).then(function(s){if(500===r)throw n.hooks.call("fetch:error",{status:r,response:i,url:o}),new H(`Server error: ${o}`,{status:r,url:o});if(!s)throw new H(`Empty response: ${o}`,{status:r,url:o});const{url:c}=a.fromUrl(o),l={url:c,html:s};return!n.visit.cache.write||e.method&&"GET"!==e.method||t!==c||n.cache.set(l.url,l),l})})}catch(t){return Promise.reject(t)}};class H extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}const L=function(){try{let n;const i=this;function e(e){return n?e:Promise.resolve(i.hooks.call("animation:out:start",void 0,e=>{i.classes.add("is-changing","is-leaving","is-animating"),e.history.popstate&&i.classes.add("is-popstate"),e.animation.name&&i.classes.add(`to-${t(e.animation.name)}`)})).then(function(){return Promise.resolve(i.hooks.call("animation:out:await",{skip:!1},function(t,e){let{skip:n}=e;try{return n?Promise.resolve():Promise.resolve(i.awaitAnimations({selector:t.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}})).then(function(){return Promise.resolve(i.hooks.call("animation:out:end",void 0)).then(function(){})})})}const r=function(){if(!i.visit.animation.animate)return Promise.resolve(i.hooks.call("animation:skip",void 0)).then(function(){n=1})}();return Promise.resolve(r&&r.then?r.then(e):e(r))}catch(o){return Promise.reject(o)}},T=function(t,e){let{html:n}=t,{containers:i}=void 0===e?this.options:e;const r=(new DOMParser).parseFromString(n,"text/html"),o=r.querySelector("title")?.innerText||"";document.title=o;const s=h('[data-swup-persist]:not([data-swup-persist=""])'),a=i.map(t=>{const e=document.querySelector(t),n=r.querySelector(t);return e&&n?(e.replaceWith(n),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),n||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean);return s.forEach(t=>{const e=t.getAttribute("data-swup-persist"),n=l(`[data-swup-persist="${e}"]`);n&&n!==t&&n.replaceWith(t)}),a.length===i.length},q=function(){const t={behavior:"auto"},{target:e,reset:n}=this.visit.scroll,i=e??this.visit.to.hash;let r=!1;return i&&(r=this.hooks.callSync("scroll:anchor",{hash:i,options:t},(t,e)=>{let{hash:n,options:i}=e;const r=this.getAnchorElement(n);return r&&r.scrollIntoView(i),!!r})),n&&!r&&(r=this.hooks.callSync("scroll:top",{options:t},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),r},R=function(){try{const t=this;if(!t.visit.animation.animate)return Promise.resolve();const e=t.hooks.call("animation:in:await",{skip:!1},function(e,n){let{skip:i}=n;try{return i?Promise.resolve():Promise.resolve(t.awaitAnimations({selector:e.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}});return Promise.resolve(u()).then(function(){return Promise.resolve(t.hooks.call("animation:in:start",void 0,()=>{t.classes.remove("is-animating")})).then(function(){return Promise.resolve(e).then(function(){return Promise.resolve(t.hooks.call("animation:in:end",void 0)).then(function(){})})})})}catch(t){return Promise.reject(t)}},N=function(n,r){try{const o=this,{url:s,html:a}=r;return o.classes.remove("is-leaving"),o.isSameResolvedUrl(e(),n)?(o.isSameResolvedUrl(e(),s)||(i(s),o.currentPageUrl=e(),o.visit.to.url=o.currentPageUrl),o.visit.animation.animate&&o.classes.add("is-rendering"),o.visit.to.html=a,Promise.resolve(o.hooks.call("content:replace",{page:r},(e,n)=>{let{page:i}=n;if(!o.replaceContent(i,{containers:e.containers}))throw new Error("[swup] Container mismatch, aborting");e.animation.animate&&(o.classes.add("is-animating","is-changing","is-rendering"),e.animation.name&&o.classes.add(`to-${t(e.animation.name)}`))})).then(function(){return Promise.resolve(o.hooks.call("content:scroll",void 0,()=>o.scrollToContent())).then(function(){return Promise.resolve(o.hooks.call("page:view",{url:o.currentPageUrl,title:document.title})).then(function(){})})})):Promise.resolve()}catch(t){return Promise.reject(t)}},D=function(t){var e;if(e=t,Boolean(e?.isSwupPlugin)){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function I(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function M(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${String(t)}`)}function W(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function V(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}const B={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!!n?.closest("[data-no-swup]")},linkSelector:"a[href]",linkToSelf:"scroll",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>"swup"!==t.state?.source};return class{constructor(t){void 0===t&&(t={}),this.version="4.3.1",this.options=void 0,this.defaults=B,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=e(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.use=D,this.unuse=I,this.findPlugin=M,this.log=()=>{},this.navigate=A,this.performNavigation=x,this.createVisit=v,this.delegateEvent=s,this.fetchPage=j,this.awaitAnimations=b,this.renderPage=N,this.replaceContent=T,this.animatePageIn=R,this.animatePageOut=L,this.scrollToContent=q,this.getAnchorElement=S,this.getCurrentUrl=e,this.resolveUrl=W,this.isSameResolvedUrl=V,this.options={...this.defaults,...t},this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new c(this),this.classes=new p(this),this.hooks=new k(this),this.visit=this.createVisit({to:""}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}enable(){try{const t=this,{linkSelector:e}=t.options;return t.clickDelegate=t.delegateEvent(e,"click",t.handleLinkClick),window.addEventListener("popstate",t.handlePopState),t.options.animateHistoryBrowsing&&(window.history.scrollRestoration="manual"),t.options.plugins.forEach(e=>t.use(e)),i(null,{index:1}),Promise.resolve(u()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.handlePopState),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:i}=void 0===e?{}:e;const{origin:r,url:o,hash:s}=a.fromUrl(t);return r!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(o+s,{el:n,event:i})}handleLinkClick(t){const e=t.delegateTarget,{href:n,url:r,hash:o}=a.fromElement(e);this.shouldIgnoreVisit(n,{el:e,event:t})||(this.visit=this.createVisit({to:r,hash:o,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:n}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{const e=this.visit.from.url??"";t.preventDefault(),r&&r!==e?this.isSameResolvedUrl(r,e)||this.performNavigation():o?this.hooks.callSync("link:anchor",{hash:o},()=>{i(r+o),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>"navigate"===this.options.linkToSelf?this.performNavigation():this.scrollToContent())}))}handlePopState(t){const n=t.state?.url??location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(e(),this.currentPageUrl))return;const{url:i,hash:r}=a.fromUrl(n);this.visit=this.createVisit({to:i,hash:r,event:t}),this.visit.history.popstate=!0;const o=Number(t.state?.index);o&&(this.visit.history.direction=o-this.currentHistoryIndex>0?"forwards":"backwards"),this.visit.animation.animate=!1,this.visit.scroll.reset=!1,this.visit.scroll.target=!1,this.options.animateHistoryBrowsing&&(this.visit.animation.animate=!0,this.visit.scroll.reset=!0),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation()})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}}});
//# sourceMappingURL=Swup.umd.js.map

@@ -50,3 +50,3 @@ import Swup, { Options } from '../Swup.js';

/** Anchor element to scroll to on the next page. */
target?: string;
target?: string | false;
}

@@ -77,11 +77,6 @@ export interface VisitTrigger {

hash?: string;
animate?: boolean;
animation?: string;
targets?: string[];
el?: Element;
event?: Event;
action?: HistoryAction;
resetScroll?: boolean;
}
/** Create a new visit object. */
export declare function createVisit(this: Swup, { to, from, hash, animate, animation: name, el, event, action, resetScroll: reset }: VisitInitOptions): Visit;
export declare function createVisit(this: Swup, { to, from, hash, el, event }: VisitInitOptions): Visit;
{
"name": "swup",
"amdName": "Swup",
"version": "4.3.0",
"version": "4.3.1",
"description": "Versatile and extensible page transition library for server-rendered websites",

@@ -6,0 +6,0 @@ "type": "module",

@@ -10,3 +10,3 @@ import Swup from '../Swup.js';

const { target, reset } = this.visit.scroll;
const scrollTarget = target || this.visit.to.hash;
const scrollTarget = target ?? this.visit.to.hash;

@@ -13,0 +13,0 @@ let scrolled = false;

@@ -55,3 +55,3 @@ import Swup, { Options } from '../Swup.js';

/** Anchor element to scroll to on the next page. */
target?: string;
target?: string | false;
}

@@ -86,9 +86,4 @@

hash?: string;
animate?: boolean;
animation?: string;
targets?: string[];
el?: Element;
event?: Event;
action?: HistoryAction;
resetScroll?: boolean;
}

@@ -99,13 +94,3 @@

this: Swup,
{
to,
from = this.currentPageUrl,
hash,
animate = true,
animation: name,
el,
event,
action = 'push',
resetScroll: reset = true
}: VisitInitOptions
{ to, from = this.currentPageUrl, hash, el, event }: VisitInitOptions
): Visit {

@@ -117,5 +102,5 @@ return {

animation: {
animate,
animate: true,
wait: false,
name,
name: undefined,
scope: this.options.animationScope,

@@ -133,3 +118,3 @@ selector: this.options.animationSelector

history: {
action,
action: 'push',
popstate: false,

@@ -139,3 +124,3 @@ direction: undefined

scroll: {
reset,
reset: true,
target: undefined

@@ -142,0 +127,0 @@ }

@@ -170,2 +170,7 @@ import { DelegateEvent } from 'delegate-it';

// Set scroll restoration to manual if animating history visits
if (this.options.animateHistoryBrowsing) {
window.history.scrollRestoration = 'manual';
}
// Initial save to cache

@@ -314,14 +319,6 @@ if (this.options.cache) {

const { url, hash } = Location.fromUrl(href);
const animate = this.options.animateHistoryBrowsing;
const resetScroll = this.options.animateHistoryBrowsing;
this.visit = this.createVisit({
to: url,
hash,
event,
animate,
resetScroll
});
this.visit = this.createVisit({ to: url, hash, event });
// Mark as popstate visit
// Mark as history visit
this.visit.history.popstate = true;

@@ -336,2 +333,13 @@

// Disable animation & scrolling for history visits
this.visit.animation.animate = false;
this.visit.scroll.reset = false;
this.visit.scroll.target = false;
// Animated history visit: re-enable animation & scroll reset
if (this.options.animateHistoryBrowsing) {
this.visit.animation.animate = true;
this.visit.scroll.reset = true;
}
// Does this even do anything?

@@ -338,0 +346,0 @@ // if (!hash) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc