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

swup

Package Overview
Dependencies
Maintainers
1
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 3.0.0-rc.2 to 3.0.0-rc.3

2

dist/Swup.modern.js

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

import t from"delegate-it";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},e.apply(this,arguments)}const n=({hash:t}={})=>location.pathname+location.search+(t?location.hash:""),i=(t=null,i={})=>{t=t||n({hash:!0});const s=e({},history.state,{url:t,random:Math.random(),source:"swup"},i);history.replaceState(s,"",t)},s=["base"],o=(e,n,i,o={})=>{let{base:r=document}=o,a=function(t,e){if(null==t)return{};var n,i,s={},o=Object.keys(t);for(i=0;i<o.length;i++)e.indexOf(n=o[i])>=0||(s[n]=t[n]);return s}(o,s);const l=t(r,e,n,i,a);return{destroy:()=>l.destroy()}},r=(t,e=document)=>e.querySelector(t),a=(t,e=document)=>Array.from(e.querySelectorAll(t)),l=t=>1e3*Number(t.slice(0,-1).replace(",","."));class u 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 u(e)}static fromUrl(t){return new u(t)}}const c=t=>/^to-/.test(t)||["is-changing","is-rendering","is-popstate"].includes(t),h=()=>{const t=document.documentElement.className.split(" ").filter(c);document.documentElement.classList.remove(...t)};class d{constructor(t){this.pages={},this.last=null,this.swup=void 0,this.swup=t}getCacheUrl(t){return this.swup.resolveUrl(u.fromUrl(t).url)}cacheUrl(t){t.url=this.getCacheUrl(t.url),t.url in this.pages==0&&(this.pages[t.url]=t),t.responseURL=this.getCacheUrl(t.responseURL),this.last=this.pages[t.url],this.swup.log(`Cache (${Object.keys(this.pages).length})`,this.pages)}getPage(t){return t=this.getCacheUrl(t),this.pages[t]}getCurrentPage(){return this.getPage(n())}exists(t){return(t=this.getCacheUrl(t))in this.pages}empty(){this.pages={},this.last=null,this.swup.log("Cache cleared")}remove(t){delete this.pages[this.getCacheUrl(t)]}}const p=function({popstate:t,skipTransition:e}){if(e)return this.triggerEvent("transitionEnd",t),this.cleanupAnimationClasses(),[Promise.resolve()];var n;n=()=>{this.triggerEvent("animationInStart"),document.documentElement.classList.remove("is-animating")},requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})});const i=this.getAnimationPromises("in");return Promise.all(i).then(()=>{this.triggerEvent("animationInDone"),this.triggerEvent("transitionEnd",t),this.cleanupAnimationClasses()}),i},g=t=>{return t?("#"===t.charAt(0)&&(t=t.substring(1)),e=t=decodeURIComponent(t),t=window.CSS&&window.CSS.escape?CSS.escape(e):e,r(`#${t}`)||r(`a[name='${t}']`)):null;var e};let m="transition",f="transitionend",v="animation",w="animationend";function E(t){const e=this.options.animationSelector;if(!1===e)return[Promise.resolve()];const n=a(e,document.body);return n.length?n.map(t=>function(t,e,n=null){const{type:i,timeout:s,propCount:o}=function(t,e=null){const n=window.getComputedStyle(t),i=`${m}Duration`,s=`${v}Delay`,o=`${v}Duration`,r=n[`${m}Delay`].split(", "),a=(n[i]||"").split(", "),l=P(r,a),u=(n[s]||"").split(", "),c=(n[o]||"").split(", "),h=P(u,c);let d="",p=0,g=0;return"transition"===e?l>0&&(d="transition",p=l,g=a.length):"animation"===e?h>0&&(d="animation",p=h,g=c.length):(p=Math.max(l,h),d=p>0?l>h?"transition":"animation":null,g=d?"transition"===d?a.length:c.length:0),{type:d,timeout:p,propCount:g}}(t,n);return i&&s?new Promise(e=>{const n="transition"===i?f:w,r=performance.now();let a=0;const l=()=>{t.removeEventListener(n,u),e()},u=e=>{if(e.target===t){if(!(t=>!!t.elapsedTime)(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=o&&l()}};setTimeout(()=>{a<o&&l()},s+1),t.addEventListener(n,u)}):(console.warn(`[swup] No CSS transition duration defined for element of selector ${e}`),Promise.resolve())}(t,e)):(console.warn(`[swup] No animated elements found by selector ${e}`),[Promise.resolve()])}function P(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>l(e)+l(t[n])))}void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(m="WebkitTransition",f="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(v="WebkitAnimation",w="webkitAnimationEnd");const b=function(t){const n=((t,e)=>{var n,i;let s=document.createElement("html");s.innerHTML=t;let o=[];e.forEach(t=>{if(null==r(t,s))return console.warn(`[swup] Container ${t} not found on page.`),null;a(t).length!==a(t,s).length&&console.warn("[swup] Mismatched number of containers found on new page."),a(t).forEach((e,n)=>{a(t,s)[n].setAttribute("data-swup",String(o.length)),o.push(a(t,s)[n].outerHTML)})});const l=(null==(n=r("title",s))?void 0:n.innerText)||"",u=null==(i=r("body",s))?void 0:i.className;return s.innerHTML="",s=null,{title:l,pageClass:u,blocks:o,originalContent:t}})(t.responseText,this.options.containers);return n?e({},n,{responseURL:t.responseURL||window.location.href}):(console.warn("[swup] Received page is invalid."),null)};function S(t){const n=this.options.requestHeaders,{url:i}=t;return this.cache.exists(i)?(this.triggerEvent("pageRetrievedFromCache"),Promise.resolve(this.cache.getPage(i))):new Promise((s,o)=>{((t,n)=>{const i={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}},{url:s,method:o,headers:r,data:a}=e({},i,t),l=new XMLHttpRequest;l.onreadystatechange=function(){4===l.readyState&&n(l)},l.open(o,s,!0),Object.entries(r).forEach(([t,e])=>{l.setRequestHeader(t,e)}),l.send(a)})(e({},t,{headers:n}),t=>{if(500===t.status)return this.triggerEvent("serverError"),void o(i);const n=this.getPageData(t);if(!n||!n.blocks.length)return void o(i);const r=e({},n,{url:i});this.cache.cacheUrl(r),this.triggerEvent("pageLoaded"),s(r)})})}const U=function(t,{popstate:e,skipTransition:n}={popstate:null}){if(n)return this.triggerEvent("animationSkipped"),[Promise.resolve()];this.triggerEvent("animationOutStart"),document.documentElement.classList.add("is-changing","is-leaving","is-animating"),e&&document.documentElement.classList.add("is-popstate");const i=this.getAnimationPromises("out");return Promise.all(i).then(()=>{this.triggerEvent("animationOutDone")}),i},k=function(t,i){const{url:s,customTransition:o}=t,r=!(!i||this.options.animateHistoryBrowsing);var a;this.triggerEvent("transitionStart",i||void 0),this.updateTransition(n(),s,o),null!=o&&document.documentElement.classList.add(`to-${a=o,String(a).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/,"")||""}`);const l=this.leavePage(t,{popstate:i,skipTransition:r});i||((t,i={})=>{const s=e({url:t=t||n({hash:!0}),random:Math.random(),source:"swup"},i);history.pushState(s,"",t)})(s+(this.scrollToElement||"")),this.currentPageUrl=n();const u=this.fetchPage(t);Promise.all([u,...l]).then(([t])=>{this.renderPage(t,{popstate:i,skipTransition:r})}).catch(t=>{void 0!==t&&(this.options.skipPopStateHandling=()=>(window.location=t,!0),history.go(-1))})},y=function({blocks:t,title:e}){return t.forEach((t,e)=>{document.body.querySelector(`[data-swup="${e}"]`).outerHTML=t}),document.title=e,Promise.resolve()},C=function(t,e){t&&e?this._handlers[t].includes(e)?this._handlers[t]=this._handlers[t].filter(t=>t!==e):console.warn(`Handler for event '${t}' not found.`):t?this._handlers[t]=[]:Object.keys(this._handlers).forEach(t=>{this._handlers[t]=[]})},L=function(t,e){this._handlers[t]?this._handlers[t].push(e):console.warn(`Unsupported event ${t}.`)},T=function(t){if(t.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 H(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 R(t){return this.plugins.find(e=>e===t||e.name===t)}const A=function(t,{popstate:s,skipTransition:o}={popstate:null}){if(document.documentElement.classList.remove("is-leaving"),!this.isSameResolvedUrl(n(),t.url))return;const{url:r}=u.fromUrl(t.responseURL);this.isSameResolvedUrl(n(),r)||(this.cache.cacheUrl(e({},t,{url:r})),this.currentPageUrl=n(),i(r)),o||document.documentElement.classList.add("is-rendering"),this.triggerEvent("willReplaceContent",s||void 0),this.replaceContent(t).then(()=>{this.triggerEvent("contentReplaced",s||void 0),this.triggerEvent("pageView",s||void 0),this.options.cache||this.cache.empty(),this.enterPage({popstate:s||void 0,skipTransition:o}),this.scrollToElement=null})},$=function(t,e){this._handlers[t].forEach(t=>{try{t(e)}catch(t){console.error(t)}});const n=new CustomEvent(`swup:${t}`,{detail:t});document.dispatchEvent(n)},_=function(t,e,n){this.transition={from:t,to:e,custom:n}};class O{constructor(t={}){this.version="3.0.0-rc.1",this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]},this.scrollToElement=null,this.options=void 0,this.plugins=[],this.transition={},this.cache=void 0,this.currentPageUrl=n(),this.delegatedListeners={},this.boundPopStateHandler=void 0,this.loadPage=k,this.leavePage=U,this.renderPage=A,this.replaceContent=y,this.enterPage=p,this.triggerEvent=$,this.delegateEvent=o,this.on=L,this.off=C,this.updateTransition=_,this.getAnimationPromises=E,this.getPageData=b,this.fetchPage=S,this.getAnchorElement=g,this.log=()=>{},this.use=T,this.unuse=H,this.findPlugin=R,this.getCurrentUrl=n,this.cleanupAnimationClasses=h,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',cache:!0,containers:["#swup"],ignoreVisit:(t,{el:e}={})=>!(null==e||!e.closest("[data-no-swup]")),linkSelector:"a[href]",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)}},this.options=e({},this.defaults,t),this.boundPopStateHandler=this.popStateHandler.bind(this),this.cache=new d(this),this.enable()}enable(){"undefined"!=typeof Promise?(this.delegatedListeners.click=o(this.options.linkSelector,"click",this.linkClickHandler.bind(this)),window.addEventListener("popstate",this.boundPopStateHandler),((t,e)=>{let n=0;this.options.containers.forEach(e=>{null==r(e,t)?console.warn(`[swup] Container ${e} not found on page.`):a(e).forEach((i,s)=>{a(e,t)[s].setAttribute("data-swup",String(n)),n++})})})(document.documentElement),this.options.plugins.forEach(t=>this.use(t)),i(),this.triggerEvent("enabled"),document.documentElement.classList.add("swup-enabled"),this.triggerEvent("pageView")):console.warn("Promise is not supported")}destroy(){this.delegatedListeners.click.destroy(),window.removeEventListener("popstate",this.boundPopStateHandler),this.cache.empty(),this.options.plugins.forEach(t=>{this.unuse(t)}),a("[data-swup]").forEach(t=>{t.removeAttribute("data-swup")}),this.off(),this.triggerEvent("disabled"),document.documentElement.classList.remove("swup-enabled")}shouldIgnoreVisit(t,{el:e}={}){const{origin:n}=u.fromUrl(t);return n!==window.location.origin||!(!e||!this.triggerWillOpenNewWindow(e))||!!this.options.ignoreVisit(t,{el:e})}linkClickHandler(t){const e=t.delegateTarget,{href:i,url:s,hash:o}=u.fromElement(e);if(this.shouldIgnoreVisit(i,{el:e}))return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return void this.triggerEvent("openPageInNewTab",t);if(0!==t.button)return;if(this.triggerEvent("clickLink",t),t.preventDefault(),!s||s===n())return void this.handleLinkToSamePage(s,o,t);if(this.isSameResolvedUrl(s,n()))return;this.scrollToElement=o||null;const r=e.getAttribute("data-swup-transition")||void 0;this.loadPage({url:s,customTransition:r},null)}handleLinkToSamePage(t,e,n){if(e){if(this.triggerEvent("samePageWithHash",n),!g(e))return console.warn(`Element for offset not found (#${e})`);i(t+e)}else this.triggerEvent("samePage",n)}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(t){var e,i;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(n(),this.currentPageUrl))return;const{url:s,hash:o}=u.fromUrl(null!=(e=null==(i=t.state)?void 0:i.url)?e:location.href);o?this.scrollToElement=o:t.preventDefault(),this.triggerEvent("popState",t),this.options.animateHistoryBrowsing||(document.documentElement.classList.remove("is-animating"),h()),this.loadPage({url:s},t)}resolveUrl(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)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}}export{O as default};
import t from"delegate-it";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},e.apply(this,arguments)}const n=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/,"")||e||"",i=({hash:t}={})=>location.pathname+location.search+(t?location.hash:""),s=(t,n={})=>{const s=e({url:t=t||i({hash:!0}),random:Math.random(),source:"swup"},n);history.pushState(s,"",t)},o=(t=null,n={})=>{t=t||i({hash:!0});const s=e({},history.state,{url:t,random:Math.random(),source:"swup"},n);history.replaceState(s,"",t)},r=["base"],a=(e,n,i,s={})=>{let{base:o=document}=s,a=function(t,e){if(null==t)return{};var n,i,s={},o=Object.keys(t);for(i=0;i<o.length;i++)e.indexOf(n=o[i])>=0||(s[n]=t[n]);return s}(s,r);const l=t(o,e,n,i,a);return{destroy:()=>l.destroy()}},l=(t,e=document)=>e.querySelector(t),c=(t,e=document)=>Array.from(e.querySelectorAll(t)),u=t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})},h=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,d=t=>1e3*Number(t.slice(0,-1).replace(",",".")),p=(t,e)=>{var n,i;let s=document.createElement("html");s.innerHTML=t;let o=[];e.forEach(t=>{if(null==l(t,s))return console.warn(`[swup] Container ${t} not found on page.`),null;c(t).length!==c(t,s).length&&console.warn("[swup] Mismatched number of containers found on new page."),c(t).forEach((e,n)=>{c(t,s)[n].setAttribute("data-swup",String(o.length)),o.push(c(t,s)[n].outerHTML)})});const r=(null==(n=l("title",s))?void 0:n.innerText)||"",a=null==(i=l("body",s))?void 0:i.className;return s.innerHTML="",s=null,{title:r,pageClass:a,blocks:o,originalContent:t}},g=(t,n)=>{const i={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}},{url:s,method:o,headers:r,data:a}=e({},i,t),l=new XMLHttpRequest;return l.onreadystatechange=function(){4===l.readyState&&n(l)},l.open(o,s,!0),Object.entries(r).forEach(([t,e])=>{l.setRequestHeader(t,e)}),l.send(a),l};class m 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 m(e)}static fromUrl(t){return new m(t)}}const f=(t,e)=>{let n=0;e.forEach(e=>{null==l(e,t)?console.warn(`[swup] Container ${e} not found on page.`):c(e).forEach((i,s)=>{c(e,t)[s].setAttribute("data-swup",String(n)),n++})})},v=t=>/^to-/.test(t)||["is-changing","is-rendering","is-popstate"].includes(t),w=()=>{const t=document.documentElement.className.split(" ").filter(v);document.documentElement.classList.remove(...t)},E=t=>String(t).split(".").concat(["0","0"]).slice(0,3).join("."),P=(t,e)=>e.every(e=>{const[,n,i]=e.match(/^([\D]+)?(.*)$/)||[];var s,o;return((t,e)=>{const n={"":t=>0===t,">":t=>t>0,">=":t=>t>=0,"<":t=>t<0,"<=":t=>t<=0};return(n[e]||n[""])(t)})((o=i,s=E(s=t),o=E(o),s.localeCompare(o,void 0,{numeric:!0})),n||">=")});class b{constructor(t){this.pages={},this.last=null,this.swup=void 0,this.swup=t}getCacheUrl(t){return this.swup.resolveUrl(m.fromUrl(t).url)}cacheUrl(t){t.url=this.getCacheUrl(t.url),t.url in this.pages==0&&(this.pages[t.url]=t),t.responseURL=this.getCacheUrl(t.responseURL),this.last=this.pages[t.url],this.swup.log(`Cache (${Object.keys(this.pages).length})`,this.pages)}getPage(t){return t=this.getCacheUrl(t),this.pages[t]}getCurrentPage(){return this.getPage(i())}exists(t){return(t=this.getCacheUrl(t))in this.pages}empty(){this.pages={},this.last=null,this.swup.log("Cache cleared")}remove(t){delete this.pages[this.getCacheUrl(t)]}}const S=function({popstate:t,skipTransition:e}){if(e)return this.triggerEvent("transitionEnd",t),this.cleanupAnimationClasses(),[Promise.resolve()];u(()=>{this.triggerEvent("animationInStart"),document.documentElement.classList.remove("is-animating")});const n=this.getAnimationPromises("in");return Promise.all(n).then(()=>{this.triggerEvent("animationInDone"),this.triggerEvent("transitionEnd",t),this.cleanupAnimationClasses()}),n},U=t=>t?("#"===t.charAt(0)&&(t=t.substring(1)),t=decodeURIComponent(t),t=h(t),l(`#${t}`)||l(`a[name='${t}']`)):null;let y="transition",k="transitionend",C="animation",L="animationend";function T(t){const e=this.options.animationSelector;if(!1===e)return[Promise.resolve()];const n=c(e,document.body);return n.length?n.map(t=>function(t,e,n=null){const{type:i,timeout:s,propCount:o}=function(t,e=null){const n=window.getComputedStyle(t),i=`${y}Duration`,s=`${C}Delay`,o=`${C}Duration`,r=n[`${y}Delay`].split(", "),a=(n[i]||"").split(", "),l=H(r,a),c=(n[s]||"").split(", "),u=(n[o]||"").split(", "),h=H(c,u);let d="",p=0,g=0;return"transition"===e?l>0&&(d="transition",p=l,g=a.length):"animation"===e?h>0&&(d="animation",p=h,g=u.length):(p=Math.max(l,h),d=p>0?l>h?"transition":"animation":null,g=d?"transition"===d?a.length:u.length:0),{type:d,timeout:p,propCount:g}}(t,n);return i&&s?new Promise(e=>{const n="transition"===i?k:L,r=performance.now();let a=0;const l=()=>{t.removeEventListener(n,c),e()},c=e=>{if(e.target===t){if(!(t=>!!t.elapsedTime)(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=o&&l()}};setTimeout(()=>{a<o&&l()},s+1),t.addEventListener(n,c)}):(console.warn(`[swup] No CSS transition duration defined for element of selector ${e}`),Promise.resolve())}(t,e)):(console.warn(`[swup] No animated elements found by selector ${e}`),[Promise.resolve()])}function H(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>d(e)+d(t[n])))}void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(y="WebkitTransition",k="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(C="WebkitAnimation",L="webkitAnimationEnd");const R=function(t){const n=p(t.responseText,this.options.containers);return n?e({},n,{responseURL:t.responseURL||window.location.href}):(console.warn("[swup] Received page is invalid."),null)};function A(t){const n=this.options.requestHeaders,{url:i}=t;return this.cache.exists(i)?(this.triggerEvent("pageRetrievedFromCache"),Promise.resolve(this.cache.getPage(i))):new Promise((s,o)=>{g(e({},t,{headers:n}),t=>{if(500===t.status)return this.triggerEvent("serverError"),void o(i);const n=this.getPageData(t);if(!n||!n.blocks.length)return void o(i);const r=e({},n,{url:i});this.cache.cacheUrl(r),this.triggerEvent("pageLoaded"),s(r)})})}const $=function(t,{popstate:e,skipTransition:n}={popstate:null}){if(n)return this.triggerEvent("animationSkipped"),[Promise.resolve()];this.triggerEvent("animationOutStart"),document.documentElement.classList.add("is-changing","is-leaving","is-animating"),e&&document.documentElement.classList.add("is-popstate");const i=this.getAnimationPromises("out");return Promise.all(i).then(()=>{this.triggerEvent("animationOutDone")}),i},_=function(t,e){const{url:o,customTransition:r}=t,a=!(!e||this.options.animateHistoryBrowsing);this.triggerEvent("transitionStart",e||void 0),this.updateTransition(i(),o,r),null!=r&&document.documentElement.classList.add(`to-${n(r)}`);const l=this.leavePage(t,{popstate:e,skipTransition:a});e||s(o+(this.scrollToElement||"")),this.currentPageUrl=i();const c=this.fetchPage(t);Promise.all([c,...l]).then(([t])=>{this.renderPage(t,{popstate:e,skipTransition:a})}).catch(t=>{void 0!==t&&(this.options.skipPopStateHandling=()=>(window.location=t,!0),history.go(-1))})},O=function({blocks:t,title:e}){return t.forEach((t,e)=>{document.body.querySelector(`[data-swup="${e}"]`).outerHTML=t}),document.title=e,Promise.resolve()},x=function(t,e){t&&e?this._handlers[t].includes(e)?this._handlers[t]=this._handlers[t].filter(t=>t!==e):console.warn(`Handler for event '${t}' not found.`):t?this._handlers[t]=[]:Object.keys(this._handlers).forEach(t=>{this._handlers[t]=[]})},D=function(t,e){this._handlers[t]?this._handlers[t].push(e):console.warn(`Unsupported event ${t}.`)},q=function(t){if(t.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 N(t){return this.plugins.find(e=>e===t||e.name===t)}const W=function(t,{popstate:n,skipTransition:s}={popstate:null}){if(document.documentElement.classList.remove("is-leaving"),!this.isSameResolvedUrl(i(),t.url))return;const{url:r}=m.fromUrl(t.responseURL);this.isSameResolvedUrl(i(),r)||(this.cache.cacheUrl(e({},t,{url:r})),this.currentPageUrl=i(),o(r)),s||document.documentElement.classList.add("is-rendering"),this.triggerEvent("willReplaceContent",n||void 0),this.replaceContent(t).then(()=>{this.triggerEvent("contentReplaced",n||void 0),this.triggerEvent("pageView",n||void 0),this.options.cache||this.cache.empty(),this.enterPage({popstate:n||void 0,skipTransition:s}),this.scrollToElement=null})},I=function(t,e){this._handlers[t].forEach(t=>{try{t(e)}catch(t){console.error(t)}});const n=new CustomEvent(`swup:${t}`,{detail:t});document.dispatchEvent(n)},j=function(t,e,n){this.transition={from:t,to:e,custom:n}};class V{constructor(t={}){this.version="3.0.0-rc.3",this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]},this.scrollToElement=null,this.options=void 0,this.plugins=[],this.transition={},this.cache=void 0,this.currentPageUrl=i(),this.delegatedListeners={},this.boundPopStateHandler=void 0,this.loadPage=_,this.leavePage=$,this.renderPage=W,this.replaceContent=O,this.enterPage=S,this.triggerEvent=I,this.delegateEvent=a,this.on=D,this.off=x,this.updateTransition=j,this.getAnimationPromises=T,this.getPageData=R,this.fetchPage=A,this.getAnchorElement=U,this.log=()=>{},this.use=q,this.unuse=M,this.findPlugin=N,this.getCurrentUrl=i,this.cleanupAnimationClasses=w,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',cache:!0,containers:["#swup"],ignoreVisit:(t,{el:e}={})=>!(null==e||!e.closest("[data-no-swup]")),linkSelector:"a[href]",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)}},this.options=e({},this.defaults,t),this.boundPopStateHandler=this.popStateHandler.bind(this),this.cache=new b(this),this.enable()}enable(){"undefined"!=typeof Promise?(this.delegatedListeners.click=a(this.options.linkSelector,"click",this.linkClickHandler.bind(this)),window.addEventListener("popstate",this.boundPopStateHandler),f(document.documentElement,this.options.containers),this.options.plugins.forEach(t=>this.use(t)),o(),this.triggerEvent("enabled"),document.documentElement.classList.add("swup-enabled"),this.triggerEvent("pageView")):console.warn("Promise is not supported")}destroy(){this.delegatedListeners.click.destroy(),window.removeEventListener("popstate",this.boundPopStateHandler),this.cache.empty(),this.options.plugins.forEach(t=>{this.unuse(t)}),c("[data-swup]").forEach(t=>{t.removeAttribute("data-swup")}),this.off(),this.triggerEvent("disabled"),document.documentElement.classList.remove("swup-enabled")}shouldIgnoreVisit(t,{el:e}={}){const{origin:n}=m.fromUrl(t);return n!==window.location.origin||!(!e||!this.triggerWillOpenNewWindow(e))||!!this.options.ignoreVisit(t,{el:e})}linkClickHandler(t){const e=t.delegateTarget,{href:n,url:s,hash:o}=m.fromElement(e);if(this.shouldIgnoreVisit(n,{el:e}))return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return void this.triggerEvent("openPageInNewTab",t);if(0!==t.button)return;if(this.triggerEvent("clickLink",t),t.preventDefault(),!s||s===i())return void this.handleLinkToSamePage(s,o,t);if(this.isSameResolvedUrl(s,i()))return;this.scrollToElement=o||null;const r=e.getAttribute("data-swup-transition")||void 0;this.loadPage({url:s,customTransition:r},null)}handleLinkToSamePage(t,e,n){if(e){if(this.triggerEvent("samePageWithHash",n),!U(e))return console.warn(`Element for offset not found (#${e})`);o(t+e)}else this.triggerEvent("samePage",n)}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(t){var e,n;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(i(),this.currentPageUrl))return;const{url:s,hash:o}=m.fromUrl(null!=(e=null==(n=t.state)?void 0:n.url)?e:location.href);o?this.scrollToElement=o:t.preventDefault(),this.triggerEvent("popState",t),this.options.animateHistoryBrowsing||(document.documentElement.classList.remove("is-animating"),w()),this.loadPage({url:s},t)}resolveUrl(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)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}}export{m as Location,n as classify,w as cleanupAnimationClasses,s as createHistoryRecord,V as default,a as delegateEvent,h as escapeCssIdentifier,g as fetch,i as getCurrentUrl,p as getDataFromHtml,f as markSwupElements,u as nextTick,l as query,c as queryAll,d as toMs,o as updateHistoryRecord,P as versionSatisfies};
//# sourceMappingURL=Swup.modern.js.map

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

import t from"delegate-it";const e=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},n=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)},i=function(e,n,i,s){let{base:o=document,...r}=void 0===s?{}:s;const a=t(o,e,n,i,r);return{destroy:()=>a.destroy()}},s=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},o=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},r=t=>1e3*Number(t.slice(0,-1).replace(",","."));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 l=t=>/^to-/.test(t)||["is-changing","is-rendering","is-popstate"].includes(t),u=()=>{const t=document.documentElement.className.split(" ").filter(l);document.documentElement.classList.remove(...t)};class c{constructor(t){this.pages={},this.last=null,this.swup=void 0,this.swup=t}getCacheUrl(t){return this.swup.resolveUrl(a.fromUrl(t).url)}cacheUrl(t){t.url=this.getCacheUrl(t.url),t.url in this.pages==0&&(this.pages[t.url]=t),t.responseURL=this.getCacheUrl(t.responseURL),this.last=this.pages[t.url],this.swup.log("Cache ("+Object.keys(this.pages).length+")",this.pages)}getPage(t){return t=this.getCacheUrl(t),this.pages[t]}getCurrentPage(){return this.getPage(e())}exists(t){return(t=this.getCacheUrl(t))in this.pages}empty(){this.pages={},this.last=null,this.swup.log("Cache cleared")}remove(t){delete this.pages[this.getCacheUrl(t)]}}const h=function(t){let{popstate:e,skipTransition:n}=t;if(n)return this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses(),[Promise.resolve()];var i;i=()=>{this.triggerEvent("animationInStart"),document.documentElement.classList.remove("is-animating")},requestAnimationFrame(()=>{requestAnimationFrame(()=>{i()})});const s=this.getAnimationPromises("in");return Promise.all(s).then(()=>{this.triggerEvent("animationInDone"),this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses()}),s},d=t=>{return t?("#"===t.charAt(0)&&(t=t.substring(1)),e=t=decodeURIComponent(t),t=window.CSS&&window.CSS.escape?CSS.escape(e):e,s("#"+t)||s("a[name='"+t+"']")):null;var e};let p="transition",g="transitionend",m="animation",v="animationend";function f(t){const e=this.options.animationSelector;if(!1===e)return[Promise.resolve()];const n=o(e,document.body);return n.length?n.map(t=>function(t,e,n){void 0===n&&(n=null);const{type:i,timeout:s,propCount:o}=function(t,e){void 0===e&&(e=null);const n=window.getComputedStyle(t),i=p+"Duration",s=m+"Delay",o=m+"Duration",r=n[p+"Delay"].split(", "),a=(n[i]||"").split(", "),l=w(r,a),u=(n[s]||"").split(", "),c=(n[o]||"").split(", "),h=w(u,c);let d="",g=0,v=0;return"transition"===e?l>0&&(d="transition",g=l,v=a.length):"animation"===e?h>0&&(d="animation",g=h,v=c.length):(g=Math.max(l,h),d=g>0?l>h?"transition":"animation":null,v=d?"transition"===d?a.length:c.length:0),{type:d,timeout:g,propCount:v}}(t,n);return i&&s?new Promise(e=>{const n="transition"===i?g:v,r=performance.now();let a=0;const l=()=>{t.removeEventListener(n,u),e()},u=e=>{if(e.target===t){if(!(t=>!!t.elapsedTime)(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=o&&l()}};setTimeout(()=>{a<o&&l()},s+1),t.addEventListener(n,u)}):(console.warn("[swup] No CSS transition duration defined for element of selector "+e),Promise.resolve())}(t,e)):(console.warn("[swup] No animated elements found by selector "+e),[Promise.resolve()])}function w(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>r(e)+r(t[n])))}void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(p="WebkitTransition",g="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(m="WebkitAnimation",v="webkitAnimationEnd");const E=function(t){const e=((t,e)=>{var n,i;let r=document.createElement("html");r.innerHTML=t;let a=[];e.forEach(t=>{if(null==s(t,r))return console.warn("[swup] Container "+t+" not found on page."),null;o(t).length!==o(t,r).length&&console.warn("[swup] Mismatched number of containers found on new page."),o(t).forEach((e,n)=>{o(t,r)[n].setAttribute("data-swup",String(a.length)),a.push(o(t,r)[n].outerHTML)})});const l=(null==(n=s("title",r))?void 0:n.innerText)||"",u=null==(i=s("body",r))?void 0:i.className;return r.innerHTML="",r=null,{title:l,pageClass:u,blocks:a,originalContent:t}})(t.responseText,this.options.containers);return e?{...e,responseURL:t.responseURL||window.location.href}:(console.warn("[swup] Received page is invalid."),null)};function P(t){const e=this.options.requestHeaders,{url:n}=t;return this.cache.exists(n)?(this.triggerEvent("pageRetrievedFromCache"),Promise.resolve(this.cache.getPage(n))):new Promise((i,s)=>{((t,e)=>{const n={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}},{url:i,method:s,headers:o,data:r}={...n,...t},a=new XMLHttpRequest;a.onreadystatechange=function(){4===a.readyState&&e(a)},a.open(s,i,!0),Object.entries(o).forEach(t=>{let[e,n]=t;a.setRequestHeader(e,n)}),a.send(r)})({...t,headers:e},t=>{if(500===t.status)return this.triggerEvent("serverError"),void s(n);const e=this.getPageData(t);if(!e||!e.blocks.length)return void s(n);const o={...e,url:n};this.cache.cacheUrl(o),this.triggerEvent("pageLoaded"),i(o)})})}const S=function(t,e){let{popstate:n,skipTransition:i}=void 0===e?{popstate:null}:e;if(i)return this.triggerEvent("animationSkipped"),[Promise.resolve()];this.triggerEvent("animationOutStart"),document.documentElement.classList.add("is-changing","is-leaving","is-animating"),n&&document.documentElement.classList.add("is-popstate");const s=this.getAnimationPromises("out");return Promise.all(s).then(()=>{this.triggerEvent("animationOutDone")}),s},b=function(t,n){const{url:i,customTransition:s}=t,o=!(!n||this.options.animateHistoryBrowsing);this.triggerEvent("transitionStart",n||void 0),this.updateTransition(e(),i,s),null!=s&&document.documentElement.classList.add("to-"+(String(s).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/,"")||""));const r=this.leavePage(t,{popstate:n,skipTransition:o});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+(this.scrollToElement||"")),this.currentPageUrl=e();const a=this.fetchPage(t);Promise.all([a,...r]).then(t=>{let[e]=t;this.renderPage(e,{popstate:n,skipTransition:o})}).catch(t=>{void 0!==t&&(this.options.skipPopStateHandling=()=>(window.location=t,!0),history.go(-1))})},U=function(t){let{blocks:e,title:n}=t;return e.forEach((t,e)=>{document.body.querySelector('[data-swup="'+e+'"]').outerHTML=t}),document.title=n,Promise.resolve()},k=function(t,e){t&&e?this._handlers[t].includes(e)?this._handlers[t]=this._handlers[t].filter(t=>t!==e):console.warn("Handler for event '"+t+"' not found."):t?this._handlers[t]=[]:Object.keys(this._handlers).forEach(t=>{this._handlers[t]=[]})},y=function(t,e){this._handlers[t]?this._handlers[t].push(e):console.warn("Unsupported event "+t+".")},C=function(t){if(t.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 L(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 T(t){return this.plugins.find(e=>e===t||e.name===t)}const H=function(t,i){let{popstate:s,skipTransition:o}=void 0===i?{popstate:null}:i;if(document.documentElement.classList.remove("is-leaving"),!this.isSameResolvedUrl(e(),t.url))return;const{url:r}=a.fromUrl(t.responseURL);this.isSameResolvedUrl(e(),r)||(this.cache.cacheUrl({...t,url:r}),this.currentPageUrl=e(),n(r)),o||document.documentElement.classList.add("is-rendering"),this.triggerEvent("willReplaceContent",s||void 0),this.replaceContent(t).then(()=>{this.triggerEvent("contentReplaced",s||void 0),this.triggerEvent("pageView",s||void 0),this.options.cache||this.cache.empty(),this.enterPage({popstate:s||void 0,skipTransition:o}),this.scrollToElement=null})},R=function(t,e){this._handlers[t].forEach(t=>{try{t(e)}catch(t){console.error(t)}});const n=new CustomEvent("swup:"+t,{detail:t});document.dispatchEvent(n)},A=function(t,e,n){this.transition={from:t,to:e,custom:n}};class _{constructor(t){void 0===t&&(t={}),this.version="3.0.0-rc.1",this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]},this.scrollToElement=null,this.options=void 0,this.plugins=[],this.transition={},this.cache=void 0,this.currentPageUrl=e(),this.delegatedListeners={},this.boundPopStateHandler=void 0,this.loadPage=b,this.leavePage=S,this.renderPage=H,this.replaceContent=U,this.enterPage=h,this.triggerEvent=R,this.delegateEvent=i,this.on=y,this.off=k,this.updateTransition=A,this.getAnimationPromises=f,this.getPageData=E,this.fetchPage=P,this.getAnchorElement=d,this.log=()=>{},this.use=C,this.unuse=L,this.findPlugin=T,this.getCurrentUrl=e,this.cleanupAnimationClasses=u,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!(null==n||!n.closest("[data-no-swup]"))},linkSelector:"a[href]",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)}},this.options={...this.defaults,...t},this.boundPopStateHandler=this.popStateHandler.bind(this),this.cache=new c(this),this.enable()}enable(){"undefined"!=typeof Promise?(this.delegatedListeners.click=i(this.options.linkSelector,"click",this.linkClickHandler.bind(this)),window.addEventListener("popstate",this.boundPopStateHandler),((t,e)=>{let n=0;this.options.containers.forEach(e=>{null==s(e,t)?console.warn("[swup] Container "+e+" not found on page."):o(e).forEach((i,s)=>{o(e,t)[s].setAttribute("data-swup",String(n)),n++})})})(document.documentElement),this.options.plugins.forEach(t=>this.use(t)),n(),this.triggerEvent("enabled"),document.documentElement.classList.add("swup-enabled"),this.triggerEvent("pageView")):console.warn("Promise is not supported")}destroy(){this.delegatedListeners.click.destroy(),window.removeEventListener("popstate",this.boundPopStateHandler),this.cache.empty(),this.options.plugins.forEach(t=>{this.unuse(t)}),o("[data-swup]").forEach(t=>{t.removeAttribute("data-swup")}),this.off(),this.triggerEvent("disabled"),document.documentElement.classList.remove("swup-enabled")}shouldIgnoreVisit(t,e){let{el:n}=void 0===e?{}:e;const{origin:i}=a.fromUrl(t);return i!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(t,{el:n})}linkClickHandler(t){const n=t.delegateTarget,{href:i,url:s,hash:o}=a.fromElement(n);if(this.shouldIgnoreVisit(i,{el:n}))return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return void this.triggerEvent("openPageInNewTab",t);if(0!==t.button)return;if(this.triggerEvent("clickLink",t),t.preventDefault(),!s||s===e())return void this.handleLinkToSamePage(s,o,t);if(this.isSameResolvedUrl(s,e()))return;this.scrollToElement=o||null;const r=n.getAttribute("data-swup-transition")||void 0;this.loadPage({url:s,customTransition:r},null)}handleLinkToSamePage(t,e,i){if(e){if(this.triggerEvent("samePageWithHash",i),!d(e))return console.warn("Element for offset not found (#"+e+")");n(t+e)}else this.triggerEvent("samePage",i)}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(t){var n,i;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(e(),this.currentPageUrl))return;const{url:s,hash:o}=a.fromUrl(null!=(n=null==(i=t.state)?void 0:i.url)?n:location.href);o?this.scrollToElement=o:t.preventDefault(),this.triggerEvent("popState",t),this.options.animateHistoryBrowsing||(document.documentElement.classList.remove("is-animating"),u()),this.loadPage({url:s},t)}resolveUrl(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)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}}export{_ as default};
import t from"delegate-it";const e=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/,"")||e||"",n=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 i={url:t=t||n({hash:!0}),random:Math.random(),source:"swup",...e};history.pushState(i,"",t)},s=function(t,e){void 0===t&&(t=null),void 0===e&&(e={}),t=t||n({hash:!0});const i={...history.state,url:t,random:Math.random(),source:"swup",...e};history.replaceState(i,"",t)},o=function(e,n,i,s){let{base:o=document,...r}=void 0===s?{}:s;const a=t(o,e,n,i,r);return{destroy:()=>a.destroy()}},r=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},a=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},l=t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})},u=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,c=t=>1e3*Number(t.slice(0,-1).replace(",",".")),h=(t,e)=>{var n,i;let s=document.createElement("html");s.innerHTML=t;let o=[];e.forEach(t=>{if(null==r(t,s))return console.warn("[swup] Container "+t+" not found on page."),null;a(t).length!==a(t,s).length&&console.warn("[swup] Mismatched number of containers found on new page."),a(t).forEach((e,n)=>{a(t,s)[n].setAttribute("data-swup",String(o.length)),o.push(a(t,s)[n].outerHTML)})});const l=(null==(n=r("title",s))?void 0:n.innerText)||"",u=null==(i=r("body",s))?void 0:i.className;return s.innerHTML="",s=null,{title:l,pageClass:u,blocks:o,originalContent:t}},d=(t,e)=>{const n={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}},{url:i,method:s,headers:o,data:r}={...n,...t},a=new XMLHttpRequest;return a.onreadystatechange=function(){4===a.readyState&&e(a)},a.open(s,i,!0),Object.entries(o).forEach(t=>{let[e,n]=t;a.setRequestHeader(e,n)}),a.send(r),a};class p 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 p(e)}static fromUrl(t){return new p(t)}}const g=(t,e)=>{let n=0;e.forEach(e=>{null==r(e,t)?console.warn("[swup] Container "+e+" not found on page."):a(e).forEach((i,s)=>{a(e,t)[s].setAttribute("data-swup",String(n)),n++})})},m=t=>/^to-/.test(t)||["is-changing","is-rendering","is-popstate"].includes(t),v=()=>{const t=document.documentElement.className.split(" ").filter(m);document.documentElement.classList.remove(...t)},f=t=>String(t).split(".").concat(["0","0"]).slice(0,3).join("."),w=(t,e)=>e.every(e=>{const[,n,i]=e.match(/^([\D]+)?(.*)$/)||[];var s,o;return((t,e)=>{const n={"":t=>0===t,">":t=>t>0,">=":t=>t>=0,"<":t=>t<0,"<=":t=>t<=0};return(n[e]||n[""])(t)})((o=i,s=f(s=t),o=f(o),s.localeCompare(o,void 0,{numeric:!0})),n||">=")});class E{constructor(t){this.pages={},this.last=null,this.swup=void 0,this.swup=t}getCacheUrl(t){return this.swup.resolveUrl(p.fromUrl(t).url)}cacheUrl(t){t.url=this.getCacheUrl(t.url),t.url in this.pages==0&&(this.pages[t.url]=t),t.responseURL=this.getCacheUrl(t.responseURL),this.last=this.pages[t.url],this.swup.log("Cache ("+Object.keys(this.pages).length+")",this.pages)}getPage(t){return t=this.getCacheUrl(t),this.pages[t]}getCurrentPage(){return this.getPage(n())}exists(t){return(t=this.getCacheUrl(t))in this.pages}empty(){this.pages={},this.last=null,this.swup.log("Cache cleared")}remove(t){delete this.pages[this.getCacheUrl(t)]}}const P=function(t){let{popstate:e,skipTransition:n}=t;if(n)return this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses(),[Promise.resolve()];l(()=>{this.triggerEvent("animationInStart"),document.documentElement.classList.remove("is-animating")});const i=this.getAnimationPromises("in");return Promise.all(i).then(()=>{this.triggerEvent("animationInDone"),this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses()}),i},S=t=>t?("#"===t.charAt(0)&&(t=t.substring(1)),t=decodeURIComponent(t),t=u(t),r("#"+t)||r("a[name='"+t+"']")):null;let b="transition",U="transitionend",k="animation",y="animationend";function C(t){const e=this.options.animationSelector;if(!1===e)return[Promise.resolve()];const n=a(e,document.body);return n.length?n.map(t=>function(t,e,n){void 0===n&&(n=null);const{type:i,timeout:s,propCount:o}=function(t,e){void 0===e&&(e=null);const n=window.getComputedStyle(t),i=b+"Duration",s=k+"Delay",o=k+"Duration",r=n[b+"Delay"].split(", "),a=(n[i]||"").split(", "),l=L(r,a),u=(n[s]||"").split(", "),c=(n[o]||"").split(", "),h=L(u,c);let d="",p=0,g=0;return"transition"===e?l>0&&(d="transition",p=l,g=a.length):"animation"===e?h>0&&(d="animation",p=h,g=c.length):(p=Math.max(l,h),d=p>0?l>h?"transition":"animation":null,g=d?"transition"===d?a.length:c.length:0),{type:d,timeout:p,propCount:g}}(t,n);return i&&s?new Promise(e=>{const n="transition"===i?U:y,r=performance.now();let a=0;const l=()=>{t.removeEventListener(n,u),e()},u=e=>{if(e.target===t){if(!(t=>!!t.elapsedTime)(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=o&&l()}};setTimeout(()=>{a<o&&l()},s+1),t.addEventListener(n,u)}):(console.warn("[swup] No CSS transition duration defined for element of selector "+e),Promise.resolve())}(t,e)):(console.warn("[swup] No animated elements found by selector "+e),[Promise.resolve()])}function L(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>c(e)+c(t[n])))}void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(b="WebkitTransition",U="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(k="WebkitAnimation",y="webkitAnimationEnd");const T=function(t){const e=h(t.responseText,this.options.containers);return e?{...e,responseURL:t.responseURL||window.location.href}:(console.warn("[swup] Received page is invalid."),null)};function H(t){const e=this.options.requestHeaders,{url:n}=t;return this.cache.exists(n)?(this.triggerEvent("pageRetrievedFromCache"),Promise.resolve(this.cache.getPage(n))):new Promise((i,s)=>{d({...t,headers:e},t=>{if(500===t.status)return this.triggerEvent("serverError"),void s(n);const e=this.getPageData(t);if(!e||!e.blocks.length)return void s(n);const o={...e,url:n};this.cache.cacheUrl(o),this.triggerEvent("pageLoaded"),i(o)})})}const R=function(t,e){let{popstate:n,skipTransition:i}=void 0===e?{popstate:null}:e;if(i)return this.triggerEvent("animationSkipped"),[Promise.resolve()];this.triggerEvent("animationOutStart"),document.documentElement.classList.add("is-changing","is-leaving","is-animating"),n&&document.documentElement.classList.add("is-popstate");const s=this.getAnimationPromises("out");return Promise.all(s).then(()=>{this.triggerEvent("animationOutDone")}),s},A=function(t,s){const{url:o,customTransition:r}=t,a=!(!s||this.options.animateHistoryBrowsing);this.triggerEvent("transitionStart",s||void 0),this.updateTransition(n(),o,r),null!=r&&document.documentElement.classList.add("to-"+e(r));const l=this.leavePage(t,{popstate:s,skipTransition:a});s||i(o+(this.scrollToElement||"")),this.currentPageUrl=n();const u=this.fetchPage(t);Promise.all([u,...l]).then(t=>{let[e]=t;this.renderPage(e,{popstate:s,skipTransition:a})}).catch(t=>{void 0!==t&&(this.options.skipPopStateHandling=()=>(window.location=t,!0),history.go(-1))})},_=function(t){let{blocks:e,title:n}=t;return e.forEach((t,e)=>{document.body.querySelector('[data-swup="'+e+'"]').outerHTML=t}),document.title=n,Promise.resolve()},x=function(t,e){t&&e?this._handlers[t].includes(e)?this._handlers[t]=this._handlers[t].filter(t=>t!==e):console.warn("Handler for event '"+t+"' not found."):t?this._handlers[t]=[]:Object.keys(this._handlers).forEach(t=>{this._handlers[t]=[]})},D=function(t,e){this._handlers[t]?this._handlers[t].push(e):console.warn("Unsupported event "+t+".")},q=function(t){if(t.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 N(t){return this.plugins.find(e=>e===t||e.name===t)}const W=function(t,e){let{popstate:i,skipTransition:o}=void 0===e?{popstate:null}:e;if(document.documentElement.classList.remove("is-leaving"),!this.isSameResolvedUrl(n(),t.url))return;const{url:r}=p.fromUrl(t.responseURL);this.isSameResolvedUrl(n(),r)||(this.cache.cacheUrl({...t,url:r}),this.currentPageUrl=n(),s(r)),o||document.documentElement.classList.add("is-rendering"),this.triggerEvent("willReplaceContent",i||void 0),this.replaceContent(t).then(()=>{this.triggerEvent("contentReplaced",i||void 0),this.triggerEvent("pageView",i||void 0),this.options.cache||this.cache.empty(),this.enterPage({popstate:i||void 0,skipTransition:o}),this.scrollToElement=null})},I=function(t,e){this._handlers[t].forEach(t=>{try{t(e)}catch(t){console.error(t)}});const n=new CustomEvent("swup:"+t,{detail:t});document.dispatchEvent(n)},O=function(t,e,n){this.transition={from:t,to:e,custom:n}};class V{constructor(t){void 0===t&&(t={}),this.version="3.0.0-rc.3",this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]},this.scrollToElement=null,this.options=void 0,this.plugins=[],this.transition={},this.cache=void 0,this.currentPageUrl=n(),this.delegatedListeners={},this.boundPopStateHandler=void 0,this.loadPage=A,this.leavePage=R,this.renderPage=W,this.replaceContent=_,this.enterPage=P,this.triggerEvent=I,this.delegateEvent=o,this.on=D,this.off=x,this.updateTransition=O,this.getAnimationPromises=C,this.getPageData=T,this.fetchPage=H,this.getAnchorElement=S,this.log=()=>{},this.use=q,this.unuse=M,this.findPlugin=N,this.getCurrentUrl=n,this.cleanupAnimationClasses=v,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!(null==n||!n.closest("[data-no-swup]"))},linkSelector:"a[href]",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)}},this.options={...this.defaults,...t},this.boundPopStateHandler=this.popStateHandler.bind(this),this.cache=new E(this),this.enable()}enable(){"undefined"!=typeof Promise?(this.delegatedListeners.click=o(this.options.linkSelector,"click",this.linkClickHandler.bind(this)),window.addEventListener("popstate",this.boundPopStateHandler),g(document.documentElement,this.options.containers),this.options.plugins.forEach(t=>this.use(t)),s(),this.triggerEvent("enabled"),document.documentElement.classList.add("swup-enabled"),this.triggerEvent("pageView")):console.warn("Promise is not supported")}destroy(){this.delegatedListeners.click.destroy(),window.removeEventListener("popstate",this.boundPopStateHandler),this.cache.empty(),this.options.plugins.forEach(t=>{this.unuse(t)}),a("[data-swup]").forEach(t=>{t.removeAttribute("data-swup")}),this.off(),this.triggerEvent("disabled"),document.documentElement.classList.remove("swup-enabled")}shouldIgnoreVisit(t,e){let{el:n}=void 0===e?{}:e;const{origin:i}=p.fromUrl(t);return i!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(t,{el:n})}linkClickHandler(t){const e=t.delegateTarget,{href:i,url:s,hash:o}=p.fromElement(e);if(this.shouldIgnoreVisit(i,{el:e}))return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return void this.triggerEvent("openPageInNewTab",t);if(0!==t.button)return;if(this.triggerEvent("clickLink",t),t.preventDefault(),!s||s===n())return void this.handleLinkToSamePage(s,o,t);if(this.isSameResolvedUrl(s,n()))return;this.scrollToElement=o||null;const r=e.getAttribute("data-swup-transition")||void 0;this.loadPage({url:s,customTransition:r},null)}handleLinkToSamePage(t,e,n){if(e){if(this.triggerEvent("samePageWithHash",n),!S(e))return console.warn("Element for offset not found (#"+e+")");s(t+e)}else this.triggerEvent("samePage",n)}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(t){var e,i;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(n(),this.currentPageUrl))return;const{url:s,hash:o}=p.fromUrl(null!=(e=null==(i=t.state)?void 0:i.url)?e:location.href);o?this.scrollToElement=o:t.preventDefault(),this.triggerEvent("popState",t),this.options.animateHistoryBrowsing||(document.documentElement.classList.remove("is-animating"),v()),this.loadPage({url:s},t)}resolveUrl(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)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}}export{p as Location,e as classify,v as cleanupAnimationClasses,i as createHistoryRecord,V as default,o as delegateEvent,u as escapeCssIdentifier,d as fetch,n as getCurrentUrl,h as getDataFromHtml,g as markSwupElements,l as nextTick,r as query,a as queryAll,c as toMs,s as updateHistoryRecord,w as versionSatisfies};
//# 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=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},e=function(e,n){void 0===e&&(e=null),void 0===n&&(n={}),e=e||t({hash:!0});const i={...history.state,url:e,random:Math.random(),source:"swup",...n};history.replaceState(i,"",e)},n=new WeakMap;function i(t,e,i,s){var o,r;if(!t&&!n.has(e))return!1;const a=null!==(o=n.get(e))&&void 0!==o?o:new WeakMap;if(n.set(e,a),!t&&!n.has(e))return!1;const l=null!==(r=a.get(i))&&void 0!==r?r:new Set;a.set(i,l);const c=l.has(s);return t?l.add(s):l.delete(s),c&&t}function s(t,e,n,o,r){if("string"==typeof t&&(t=document.querySelectorAll(t)),"function"!=typeof t.addEventListener){const i=Array.prototype.map.call(t,t=>s(t,e,n,o,r));return{destroy(){for(const t of i)t.destroy()}}}const a=t instanceof Document?t.documentElement:t,l=Boolean("object"==typeof r?r.capture:r),c=t=>{const n=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}}(t,e);n&&(t.delegateTarget=n,o.call(a,t))};"object"==typeof r&&delete r.once;const u=JSON.stringify({selector:e,type:n,capture:l}),h={destroy(){a.removeEventListener(n,c,r),i(!1,a,o,u)}};return i(!0,a,o,u)||a.addEventListener(n,c,r),h}const o=function(t,e,n,i){let{base:o=document,...r}=void 0===i?{}:i;const a=s(o,t,e,n,r);return{destroy:()=>a.destroy()}},r=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},a=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},l=t=>1e3*Number(t.slice(0,-1).replace(",","."));class c 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 c(e)}static fromUrl(t){return new c(t)}}const u=t=>/^to-/.test(t)||["is-changing","is-rendering","is-popstate"].includes(t),h=()=>{const t=document.documentElement.className.split(" ").filter(u);document.documentElement.classList.remove(...t)};class d{constructor(t){this.pages={},this.last=null,this.swup=void 0,this.swup=t}getCacheUrl(t){return this.swup.resolveUrl(c.fromUrl(t).url)}cacheUrl(t){t.url=this.getCacheUrl(t.url),t.url in this.pages==0&&(this.pages[t.url]=t),t.responseURL=this.getCacheUrl(t.responseURL),this.last=this.pages[t.url],this.swup.log("Cache ("+Object.keys(this.pages).length+")",this.pages)}getPage(t){return t=this.getCacheUrl(t),this.pages[t]}getCurrentPage(){return this.getPage(t())}exists(t){return(t=this.getCacheUrl(t))in this.pages}empty(){this.pages={},this.last=null,this.swup.log("Cache cleared")}remove(t){delete this.pages[this.getCacheUrl(t)]}}const p=function(t){let{popstate:e,skipTransition:n}=t;if(n)return this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses(),[Promise.resolve()];var i;i=()=>{this.triggerEvent("animationInStart"),document.documentElement.classList.remove("is-animating")},requestAnimationFrame(()=>{requestAnimationFrame(()=>{i()})});const s=this.getAnimationPromises("in");return Promise.all(s).then(()=>{this.triggerEvent("animationInDone"),this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses()}),s},g=t=>{return t?("#"===t.charAt(0)&&(t=t.substring(1)),e=t=decodeURIComponent(t),t=window.CSS&&window.CSS.escape?CSS.escape(e):e,r("#"+t)||r("a[name='"+t+"']")):null;var e};let m="transition",f="transitionend",v="animation",w="animationend";function E(t){const e=this.options.animationSelector;if(!1===e)return[Promise.resolve()];const n=a(e,document.body);return n.length?n.map(t=>function(t,e,n){void 0===n&&(n=null);const{type:i,timeout:s,propCount:o}=function(t,e){void 0===e&&(e=null);const n=window.getComputedStyle(t),i=m+"Duration",s=v+"Delay",o=v+"Duration",r=n[m+"Delay"].split(", "),a=(n[i]||"").split(", "),l=P(r,a),c=(n[s]||"").split(", "),u=(n[o]||"").split(", "),h=P(c,u);let d="",p=0,g=0;return"transition"===e?l>0&&(d="transition",p=l,g=a.length):"animation"===e?h>0&&(d="animation",p=h,g=u.length):(p=Math.max(l,h),d=p>0?l>h?"transition":"animation":null,g=d?"transition"===d?a.length:u.length:0),{type:d,timeout:p,propCount:g}}(t,n);return i&&s?new Promise(e=>{const n="transition"===i?f:w,r=performance.now();let a=0;const l=()=>{t.removeEventListener(n,c),e()},c=e=>{if(e.target===t){if(!(t=>!!t.elapsedTime)(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=o&&l()}};setTimeout(()=>{a<o&&l()},s+1),t.addEventListener(n,c)}):(console.warn("[swup] No CSS transition duration defined for element of selector "+e),Promise.resolve())}(t,e)):(console.warn("[swup] No animated elements found by selector "+e),[Promise.resolve()])}function P(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>l(e)+l(t[n])))}void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(m="WebkitTransition",f="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(v="WebkitAnimation",w="webkitAnimationEnd");const y=function(t){const e=((t,e)=>{var n,i;let s=document.createElement("html");s.innerHTML=t;let o=[];e.forEach(t=>{if(null==r(t,s))return console.warn("[swup] Container "+t+" not found on page."),null;a(t).length!==a(t,s).length&&console.warn("[swup] Mismatched number of containers found on new page."),a(t).forEach((e,n)=>{a(t,s)[n].setAttribute("data-swup",String(o.length)),o.push(a(t,s)[n].outerHTML)})});const l=(null==(n=r("title",s))?void 0:n.innerText)||"",c=null==(i=r("body",s))?void 0:i.className;return s.innerHTML="",s=null,{title:l,pageClass:c,blocks:o,originalContent:t}})(t.responseText,this.options.containers);return e?{...e,responseURL:t.responseURL||window.location.href}:(console.warn("[swup] Received page is invalid."),null)};function S(t){const e=this.options.requestHeaders,{url:n}=t;return this.cache.exists(n)?(this.triggerEvent("pageRetrievedFromCache"),Promise.resolve(this.cache.getPage(n))):new Promise((i,s)=>{((t,e)=>{const n={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}},{url:i,method:s,headers:o,data:r}={...n,...t},a=new XMLHttpRequest;a.onreadystatechange=function(){4===a.readyState&&e(a)},a.open(s,i,!0),Object.entries(o).forEach(t=>{let[e,n]=t;a.setRequestHeader(e,n)}),a.send(r)})({...t,headers:e},t=>{if(500===t.status)return this.triggerEvent("serverError"),void s(n);const e=this.getPageData(t);if(!e||!e.blocks.length)return void s(n);const o={...e,url:n};this.cache.cacheUrl(o),this.triggerEvent("pageLoaded"),i(o)})})}const b=function(t,e){let{popstate:n,skipTransition:i}=void 0===e?{popstate:null}:e;if(i)return this.triggerEvent("animationSkipped"),[Promise.resolve()];this.triggerEvent("animationOutStart"),document.documentElement.classList.add("is-changing","is-leaving","is-animating"),n&&document.documentElement.classList.add("is-popstate");const s=this.getAnimationPromises("out");return Promise.all(s).then(()=>{this.triggerEvent("animationOutDone")}),s},U=function(e,n){const{url:i,customTransition:s}=e,o=!(!n||this.options.animateHistoryBrowsing);this.triggerEvent("transitionStart",n||void 0),this.updateTransition(t(),i,s),null!=s&&document.documentElement.classList.add("to-"+(String(s).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/,"")||""));const r=this.leavePage(e,{popstate:n,skipTransition:o});n||function(e,n){void 0===n&&(n={});const i={url:e=e||t({hash:!0}),random:Math.random(),source:"swup",...n};history.pushState(i,"",e)}(i+(this.scrollToElement||"")),this.currentPageUrl=t();const a=this.fetchPage(e);Promise.all([a,...r]).then(t=>{let[e]=t;this.renderPage(e,{popstate:n,skipTransition:o})}).catch(t=>{void 0!==t&&(this.options.skipPopStateHandling=()=>(window.location=t,!0),history.go(-1))})},k=function(t){let{blocks:e,title:n}=t;return e.forEach((t,e)=>{document.body.querySelector('[data-swup="'+e+'"]').outerHTML=t}),document.title=n,Promise.resolve()},L=function(t,e){t&&e?this._handlers[t].includes(e)?this._handlers[t]=this._handlers[t].filter(t=>t!==e):console.warn("Handler for event '"+t+"' not found."):t?this._handlers[t]=[]:Object.keys(this._handlers).forEach(t=>{this._handlers[t]=[]})},T=function(t,e){this._handlers[t]?this._handlers[t].push(e):console.warn("Unsupported event "+t+".")},C=function(t){if(t.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 H(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 R(t){return this.plugins.find(e=>e===t||e.name===t)}const A=function(n,i){let{popstate:s,skipTransition:o}=void 0===i?{popstate:null}:i;if(document.documentElement.classList.remove("is-leaving"),!this.isSameResolvedUrl(t(),n.url))return;const{url:r}=c.fromUrl(n.responseURL);this.isSameResolvedUrl(t(),r)||(this.cache.cacheUrl({...n,url:r}),this.currentPageUrl=t(),e(r)),o||document.documentElement.classList.add("is-rendering"),this.triggerEvent("willReplaceContent",s||void 0),this.replaceContent(n).then(()=>{this.triggerEvent("contentReplaced",s||void 0),this.triggerEvent("pageView",s||void 0),this.options.cache||this.cache.empty(),this.enterPage({popstate:s||void 0,skipTransition:o}),this.scrollToElement=null})},_=function(t,e){this._handlers[t].forEach(t=>{try{t(e)}catch(t){console.error(t)}});const n=new CustomEvent("swup:"+t,{detail:t});document.dispatchEvent(n)},x=function(t,e,n){this.transition={from:t,to:e,custom:n}};return class{constructor(e){void 0===e&&(e={}),this.version="3.0.0-rc.1",this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]},this.scrollToElement=null,this.options=void 0,this.plugins=[],this.transition={},this.cache=void 0,this.currentPageUrl=t(),this.delegatedListeners={},this.boundPopStateHandler=void 0,this.loadPage=U,this.leavePage=b,this.renderPage=A,this.replaceContent=k,this.enterPage=p,this.triggerEvent=_,this.delegateEvent=o,this.on=T,this.off=L,this.updateTransition=x,this.getAnimationPromises=E,this.getPageData=y,this.fetchPage=S,this.getAnchorElement=g,this.log=()=>{},this.use=C,this.unuse=H,this.findPlugin=R,this.getCurrentUrl=t,this.cleanupAnimationClasses=h,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!(null==n||!n.closest("[data-no-swup]"))},linkSelector:"a[href]",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)}},this.options={...this.defaults,...e},this.boundPopStateHandler=this.popStateHandler.bind(this),this.cache=new d(this),this.enable()}enable(){"undefined"!=typeof Promise?(this.delegatedListeners.click=o(this.options.linkSelector,"click",this.linkClickHandler.bind(this)),window.addEventListener("popstate",this.boundPopStateHandler),((t,e)=>{let n=0;this.options.containers.forEach(e=>{null==r(e,t)?console.warn("[swup] Container "+e+" not found on page."):a(e).forEach((i,s)=>{a(e,t)[s].setAttribute("data-swup",String(n)),n++})})})(document.documentElement),this.options.plugins.forEach(t=>this.use(t)),e(),this.triggerEvent("enabled"),document.documentElement.classList.add("swup-enabled"),this.triggerEvent("pageView")):console.warn("Promise is not supported")}destroy(){this.delegatedListeners.click.destroy(),window.removeEventListener("popstate",this.boundPopStateHandler),this.cache.empty(),this.options.plugins.forEach(t=>{this.unuse(t)}),a("[data-swup]").forEach(t=>{t.removeAttribute("data-swup")}),this.off(),this.triggerEvent("disabled"),document.documentElement.classList.remove("swup-enabled")}shouldIgnoreVisit(t,e){let{el:n}=void 0===e?{}:e;const{origin:i}=c.fromUrl(t);return i!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(t,{el:n})}linkClickHandler(e){const n=e.delegateTarget,{href:i,url:s,hash:o}=c.fromElement(n);if(this.shouldIgnoreVisit(i,{el:n}))return;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return void this.triggerEvent("openPageInNewTab",e);if(0!==e.button)return;if(this.triggerEvent("clickLink",e),e.preventDefault(),!s||s===t())return void this.handleLinkToSamePage(s,o,e);if(this.isSameResolvedUrl(s,t()))return;this.scrollToElement=o||null;const r=n.getAttribute("data-swup-transition")||void 0;this.loadPage({url:s,customTransition:r},null)}handleLinkToSamePage(t,n,i){if(n){if(this.triggerEvent("samePageWithHash",i),!g(n))return console.warn("Element for offset not found (#"+n+")");e(t+n)}else this.triggerEvent("samePage",i)}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(e){var n,i;if(this.options.skipPopStateHandling(e))return;if(this.isSameResolvedUrl(t(),this.currentPageUrl))return;const{url:s,hash:o}=c.fromUrl(null!=(n=null==(i=e.state)?void 0:i.url)?n:location.href);o?this.scrollToElement=o:e.preventDefault(),this.triggerEvent("popState",e),this.options.animateHistoryBrowsing||(document.documentElement.classList.remove("is-animating"),h()),this.loadPage({url:s},e)}resolveUrl(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)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}}});
!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=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},e=function(e,n){void 0===e&&(e=null),void 0===n&&(n={}),e=e||t({hash:!0});const i={...history.state,url:e,random:Math.random(),source:"swup",...n};history.replaceState(i,"",e)},n=new WeakMap;function i(t,e,i,s){var o,r;if(!t&&!n.has(e))return!1;const a=null!==(o=n.get(e))&&void 0!==o?o:new WeakMap;if(n.set(e,a),!t&&!n.has(e))return!1;const l=null!==(r=a.get(i))&&void 0!==r?r:new Set;a.set(i,l);const c=l.has(s);return t?l.add(s):l.delete(s),c&&t}function s(t,e,n,o,r){if("string"==typeof t&&(t=document.querySelectorAll(t)),"function"!=typeof t.addEventListener){const i=Array.prototype.map.call(t,t=>s(t,e,n,o,r));return{destroy(){for(const t of i)t.destroy()}}}const a=t instanceof Document?t.documentElement:t,l=Boolean("object"==typeof r?r.capture:r),c=t=>{const n=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}}(t,e);n&&(t.delegateTarget=n,o.call(a,t))};"object"==typeof r&&delete r.once;const u=JSON.stringify({selector:e,type:n,capture:l}),h={destroy(){a.removeEventListener(n,c,r),i(!1,a,o,u)}};return i(!0,a,o,u)||a.addEventListener(n,c,r),h}const o=function(t,e,n,i){let{base:o=document,...r}=void 0===i?{}:i;const a=s(o,t,e,n,r);return{destroy:()=>a.destroy()}},r=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},a=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},l=t=>1e3*Number(t.slice(0,-1).replace(",","."));class c 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 c(e)}static fromUrl(t){return new c(t)}}const u=t=>/^to-/.test(t)||["is-changing","is-rendering","is-popstate"].includes(t),h=()=>{const t=document.documentElement.className.split(" ").filter(u);document.documentElement.classList.remove(...t)};class d{constructor(t){this.pages={},this.last=null,this.swup=void 0,this.swup=t}getCacheUrl(t){return this.swup.resolveUrl(c.fromUrl(t).url)}cacheUrl(t){t.url=this.getCacheUrl(t.url),t.url in this.pages==0&&(this.pages[t.url]=t),t.responseURL=this.getCacheUrl(t.responseURL),this.last=this.pages[t.url],this.swup.log("Cache ("+Object.keys(this.pages).length+")",this.pages)}getPage(t){return t=this.getCacheUrl(t),this.pages[t]}getCurrentPage(){return this.getPage(t())}exists(t){return(t=this.getCacheUrl(t))in this.pages}empty(){this.pages={},this.last=null,this.swup.log("Cache cleared")}remove(t){delete this.pages[this.getCacheUrl(t)]}}const p=function(t){let{popstate:e,skipTransition:n}=t;if(n)return this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses(),[Promise.resolve()];var i;i=()=>{this.triggerEvent("animationInStart"),document.documentElement.classList.remove("is-animating")},requestAnimationFrame(()=>{requestAnimationFrame(()=>{i()})});const s=this.getAnimationPromises("in");return Promise.all(s).then(()=>{this.triggerEvent("animationInDone"),this.triggerEvent("transitionEnd",e),this.cleanupAnimationClasses()}),s},g=t=>{return t?("#"===t.charAt(0)&&(t=t.substring(1)),e=t=decodeURIComponent(t),t=window.CSS&&window.CSS.escape?CSS.escape(e):e,r("#"+t)||r("a[name='"+t+"']")):null;var e};let m="transition",f="transitionend",v="animation",w="animationend";function E(t){const e=this.options.animationSelector;if(!1===e)return[Promise.resolve()];const n=a(e,document.body);return n.length?n.map(t=>function(t,e,n){void 0===n&&(n=null);const{type:i,timeout:s,propCount:o}=function(t,e){void 0===e&&(e=null);const n=window.getComputedStyle(t),i=m+"Duration",s=v+"Delay",o=v+"Duration",r=n[m+"Delay"].split(", "),a=(n[i]||"").split(", "),l=P(r,a),c=(n[s]||"").split(", "),u=(n[o]||"").split(", "),h=P(c,u);let d="",p=0,g=0;return"transition"===e?l>0&&(d="transition",p=l,g=a.length):"animation"===e?h>0&&(d="animation",p=h,g=u.length):(p=Math.max(l,h),d=p>0?l>h?"transition":"animation":null,g=d?"transition"===d?a.length:u.length:0),{type:d,timeout:p,propCount:g}}(t,n);return i&&s?new Promise(e=>{const n="transition"===i?f:w,r=performance.now();let a=0;const l=()=>{t.removeEventListener(n,c),e()},c=e=>{if(e.target===t){if(!(t=>!!t.elapsedTime)(e))throw new Error("Not a transition or animation event.");(performance.now()-r)/1e3<e.elapsedTime||++a>=o&&l()}};setTimeout(()=>{a<o&&l()},s+1),t.addEventListener(n,c)}):(console.warn("[swup] No CSS transition duration defined for element of selector "+e),Promise.resolve())}(t,e)):(console.warn("[swup] No animated elements found by selector "+e),[Promise.resolve()])}function P(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>l(e)+l(t[n])))}void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(m="WebkitTransition",f="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(v="WebkitAnimation",w="webkitAnimationEnd");const y=function(t){const e=((t,e)=>{var n,i;let s=document.createElement("html");s.innerHTML=t;let o=[];e.forEach(t=>{if(null==r(t,s))return console.warn("[swup] Container "+t+" not found on page."),null;a(t).length!==a(t,s).length&&console.warn("[swup] Mismatched number of containers found on new page."),a(t).forEach((e,n)=>{a(t,s)[n].setAttribute("data-swup",String(o.length)),o.push(a(t,s)[n].outerHTML)})});const l=(null==(n=r("title",s))?void 0:n.innerText)||"",c=null==(i=r("body",s))?void 0:i.className;return s.innerHTML="",s=null,{title:l,pageClass:c,blocks:o,originalContent:t}})(t.responseText,this.options.containers);return e?{...e,responseURL:t.responseURL||window.location.href}:(console.warn("[swup] Received page is invalid."),null)};function S(t){const e=this.options.requestHeaders,{url:n}=t;return this.cache.exists(n)?(this.triggerEvent("pageRetrievedFromCache"),Promise.resolve(this.cache.getPage(n))):new Promise((i,s)=>{((t,e)=>{const n={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}},{url:i,method:s,headers:o,data:r}={...n,...t},a=new XMLHttpRequest;a.onreadystatechange=function(){4===a.readyState&&e(a)},a.open(s,i,!0),Object.entries(o).forEach(t=>{let[e,n]=t;a.setRequestHeader(e,n)}),a.send(r)})({...t,headers:e},t=>{if(500===t.status)return this.triggerEvent("serverError"),void s(n);const e=this.getPageData(t);if(!e||!e.blocks.length)return void s(n);const o={...e,url:n};this.cache.cacheUrl(o),this.triggerEvent("pageLoaded"),i(o)})})}const b=function(t,e){let{popstate:n,skipTransition:i}=void 0===e?{popstate:null}:e;if(i)return this.triggerEvent("animationSkipped"),[Promise.resolve()];this.triggerEvent("animationOutStart"),document.documentElement.classList.add("is-changing","is-leaving","is-animating"),n&&document.documentElement.classList.add("is-popstate");const s=this.getAnimationPromises("out");return Promise.all(s).then(()=>{this.triggerEvent("animationOutDone")}),s},U=function(e,n){const{url:i,customTransition:s}=e,o=!(!n||this.options.animateHistoryBrowsing);this.triggerEvent("transitionStart",n||void 0),this.updateTransition(t(),i,s),null!=s&&document.documentElement.classList.add("to-"+(String(s).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/,"")||""));const r=this.leavePage(e,{popstate:n,skipTransition:o});n||function(e,n){void 0===n&&(n={});const i={url:e=e||t({hash:!0}),random:Math.random(),source:"swup",...n};history.pushState(i,"",e)}(i+(this.scrollToElement||"")),this.currentPageUrl=t();const a=this.fetchPage(e);Promise.all([a,...r]).then(t=>{let[e]=t;this.renderPage(e,{popstate:n,skipTransition:o})}).catch(t=>{void 0!==t&&(this.options.skipPopStateHandling=()=>(window.location=t,!0),history.go(-1))})},k=function(t){let{blocks:e,title:n}=t;return e.forEach((t,e)=>{document.body.querySelector('[data-swup="'+e+'"]').outerHTML=t}),document.title=n,Promise.resolve()},L=function(t,e){t&&e?this._handlers[t].includes(e)?this._handlers[t]=this._handlers[t].filter(t=>t!==e):console.warn("Handler for event '"+t+"' not found."):t?this._handlers[t]=[]:Object.keys(this._handlers).forEach(t=>{this._handlers[t]=[]})},T=function(t,e){this._handlers[t]?this._handlers[t].push(e):console.warn("Unsupported event "+t+".")},C=function(t){if(t.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 H(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 R(t){return this.plugins.find(e=>e===t||e.name===t)}const A=function(n,i){let{popstate:s,skipTransition:o}=void 0===i?{popstate:null}:i;if(document.documentElement.classList.remove("is-leaving"),!this.isSameResolvedUrl(t(),n.url))return;const{url:r}=c.fromUrl(n.responseURL);this.isSameResolvedUrl(t(),r)||(this.cache.cacheUrl({...n,url:r}),this.currentPageUrl=t(),e(r)),o||document.documentElement.classList.add("is-rendering"),this.triggerEvent("willReplaceContent",s||void 0),this.replaceContent(n).then(()=>{this.triggerEvent("contentReplaced",s||void 0),this.triggerEvent("pageView",s||void 0),this.options.cache||this.cache.empty(),this.enterPage({popstate:s||void 0,skipTransition:o}),this.scrollToElement=null})},_=function(t,e){this._handlers[t].forEach(t=>{try{t(e)}catch(t){console.error(t)}});const n=new CustomEvent("swup:"+t,{detail:t});document.dispatchEvent(n)},x=function(t,e,n){this.transition={from:t,to:e,custom:n}};return class{constructor(e){void 0===e&&(e={}),this.version="3.0.0-rc.3",this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]},this.scrollToElement=null,this.options=void 0,this.plugins=[],this.transition={},this.cache=void 0,this.currentPageUrl=t(),this.delegatedListeners={},this.boundPopStateHandler=void 0,this.loadPage=U,this.leavePage=b,this.renderPage=A,this.replaceContent=k,this.enterPage=p,this.triggerEvent=_,this.delegateEvent=o,this.on=T,this.off=L,this.updateTransition=x,this.getAnimationPromises=E,this.getPageData=y,this.fetchPage=S,this.getAnchorElement=g,this.log=()=>{},this.use=C,this.unuse=H,this.findPlugin=R,this.getCurrentUrl=t,this.cleanupAnimationClasses=h,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!(null==n||!n.closest("[data-no-swup]"))},linkSelector:"a[href]",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)}},this.options={...this.defaults,...e},this.boundPopStateHandler=this.popStateHandler.bind(this),this.cache=new d(this),this.enable()}enable(){"undefined"!=typeof Promise?(this.delegatedListeners.click=o(this.options.linkSelector,"click",this.linkClickHandler.bind(this)),window.addEventListener("popstate",this.boundPopStateHandler),((t,e)=>{let n=0;this.options.containers.forEach(e=>{null==r(e,t)?console.warn("[swup] Container "+e+" not found on page."):a(e).forEach((i,s)=>{a(e,t)[s].setAttribute("data-swup",String(n)),n++})})})(document.documentElement),this.options.plugins.forEach(t=>this.use(t)),e(),this.triggerEvent("enabled"),document.documentElement.classList.add("swup-enabled"),this.triggerEvent("pageView")):console.warn("Promise is not supported")}destroy(){this.delegatedListeners.click.destroy(),window.removeEventListener("popstate",this.boundPopStateHandler),this.cache.empty(),this.options.plugins.forEach(t=>{this.unuse(t)}),a("[data-swup]").forEach(t=>{t.removeAttribute("data-swup")}),this.off(),this.triggerEvent("disabled"),document.documentElement.classList.remove("swup-enabled")}shouldIgnoreVisit(t,e){let{el:n}=void 0===e?{}:e;const{origin:i}=c.fromUrl(t);return i!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(t,{el:n})}linkClickHandler(e){const n=e.delegateTarget,{href:i,url:s,hash:o}=c.fromElement(n);if(this.shouldIgnoreVisit(i,{el:n}))return;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return void this.triggerEvent("openPageInNewTab",e);if(0!==e.button)return;if(this.triggerEvent("clickLink",e),e.preventDefault(),!s||s===t())return void this.handleLinkToSamePage(s,o,e);if(this.isSameResolvedUrl(s,t()))return;this.scrollToElement=o||null;const r=n.getAttribute("data-swup-transition")||void 0;this.loadPage({url:s,customTransition:r},null)}handleLinkToSamePage(t,n,i){if(n){if(this.triggerEvent("samePageWithHash",i),!g(n))return console.warn("Element for offset not found (#"+n+")");e(t+n)}else this.triggerEvent("samePage",i)}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(e){var n,i;if(this.options.skipPopStateHandling(e))return;if(this.isSameResolvedUrl(t(),this.currentPageUrl))return;const{url:s,hash:o}=c.fromUrl(null!=(n=null==(i=e.state)?void 0:i.url)?n:location.href);o?this.scrollToElement=o:e.preventDefault(),this.triggerEvent("popState",e),this.options.animateHistoryBrowsing||(document.documentElement.classList.remove("is-animating"),h()),this.loadPage({url:s},e)}resolveUrl(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)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}}});
//# sourceMappingURL=Swup.umd.js.map

@@ -1,1 +0,11 @@

export * from './helpers/index.js';
export { classify } from './helpers/classify.js';
export { createHistoryRecord } from './helpers/createHistoryRecord.js';
export { updateHistoryRecord } from './helpers/updateHistoryRecord.js';
export { delegateEvent } from './helpers/delegateEvent.js';
export { getDataFromHtml } from './helpers/getDataFromHtml.js';
export { fetch } from './helpers/fetch.js';
export { getCurrentUrl } from './helpers/getCurrentUrl.js';
export { Location } from './helpers/Location.js';
export { markSwupElements } from './helpers/markSwupElements.js';
export { cleanupAnimationClasses } from './helpers/cleanupAnimationClasses.js';
export { versionSatisfies } from './helpers/versionSatisfies.js';

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

declare const classify: (text: string, fallback?: string) => string;
export default classify;
export declare const classify: (text: string, fallback?: string) => string;

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

declare const cleanupAnimationClasses: () => void;
export default cleanupAnimationClasses;
export declare const isSwupClass: (className: string) => boolean;
export declare const cleanupAnimationClasses: () => void;

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

declare const createHistoryRecord: (url: string, customData?: Record<string, unknown>) => void;
export default createHistoryRecord;
export declare const createHistoryRecord: (url: string, customData?: Record<string, unknown>) => void;

@@ -5,5 +5,4 @@ import delegate from 'delegate-it';

};
declare const delegateEvent: <Selector extends string, TEvent extends keyof GlobalEventHandlersEventMap>(selector: Selector, type: TEvent, callback: delegate.EventHandler<GlobalEventHandlersEventMap[TEvent], Element>, { base, ...eventOptions }?: {
export declare const delegateEvent: <Selector extends string, TEvent extends keyof GlobalEventHandlersEventMap>(selector: Selector, type: TEvent, callback: delegate.EventHandler<GlobalEventHandlersEventMap[TEvent], Element>, { base, ...eventOptions }?: {
base?: Document | undefined;
}) => Unsubscribe;
export default delegateEvent;
import { TransitionOptions } from '../modules/loadPage.js';
import { Options } from '../Swup.js';
declare const fetch: (options: TransitionOptions & {
export declare const fetch: (options: TransitionOptions & {
headers: Options['requestHeaders'];
}, callback: (request: XMLHttpRequest) => void) => XMLHttpRequest;
export default fetch;

@@ -1,4 +0,3 @@

declare const getCurrentUrl: ({ hash }?: {
export declare const getCurrentUrl: ({ hash }?: {
hash?: boolean | undefined;
}) => string;
export default getCurrentUrl;

@@ -7,3 +7,2 @@ export type PageHtmlData = {

};
declare const getDataFromHtml: (html: string, containers: string[]) => PageHtmlData;
export default getDataFromHtml;
export declare const getDataFromHtml: (html: string, containers: string[]) => PageHtmlData;

@@ -16,3 +16,3 @@ /**

*/
export default class Location extends URL {
export declare class Location extends URL {
constructor(url: string, base?: string);

@@ -19,0 +19,0 @@ get url(): string;

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

declare const markSwupElements: (element: Element, containers: string[]) => void;
export default markSwupElements;
export declare const markSwupElements: (element: Element, containers: string[]) => void;

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

declare const updateHistoryRecord: (url?: string | null, customData?: Record<string, unknown>) => void;
export default updateHistoryRecord;
export declare const updateHistoryRecord: (url?: string | null, customData?: Record<string, unknown>) => void;

@@ -12,2 +12,1 @@ /**

export declare const versionSatisfies: (installed: string, requirements: string[]) => boolean;
export default versionSatisfies;

@@ -1,8 +0,5 @@

import Swup, { Options } from './Swup';
declare const _default: {
Swup: typeof Swup;
};
export default _default;
export * from './helpers';
export * from './utils';
import Swup, { Options } from './Swup.js';
export default Swup;
export * from './helpers.js';
export * from './utils.js';
export type { Options };

@@ -20,2 +20,1 @@ import Swup from '../Swup.js';

}
export default Cache;
import Swup from '../Swup.js';
declare const enterPage: (this: Swup, { popstate, skipTransition }: {
export declare const enterPage: (this: Swup, { popstate, skipTransition }: {
popstate?: PopStateEvent | undefined;
skipTransition?: boolean | undefined;
}) => Promise<void>[];
export default enterPage;
import Swup from '../Swup.js';
import { TransitionOptions } from './loadPage.js';
import { PageRecord } from './Cache.js';
export default function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord>;
export declare function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord>;

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

declare const getAnchorElement: (hash: string) => Element | null;
export default getAnchorElement;
export declare const getAnchorElement: (hash: string) => Element | null;
import Swup from '../Swup.js';
export default function getAnimationPromises(this: Swup, animationType: 'in' | 'out'): Promise<void>[];
export declare function getAnimationPromises(this: Swup, animationType: 'in' | 'out'): Promise<void>[];
export declare function getTransitionInfo(element: Element, expectedType?: 'animation' | 'transition' | null): {

@@ -4,0 +4,0 @@ type: string | null;

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

};
declare const getPageData: (this: Swup, request: XMLHttpRequest) => PageData | null;
export default getPageData;
export declare const getPageData: (this: Swup, request: XMLHttpRequest) => PageData | null;
import Swup from '../Swup.js';
import { TransitionOptions } from './loadPage.js';
declare const leavePage: (this: Swup, data: TransitionOptions, { popstate, skipTransition }?: {
export declare const leavePage: (this: Swup, data: TransitionOptions, { popstate, skipTransition }?: {
popstate: PopStateEvent | null;
skipTransition?: boolean | undefined;
}) => Promise<void>[];
export default leavePage;

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

};
declare const loadPage: (this: Swup, data: TransitionOptions, popstate: PopStateEvent | null) => void;
export default loadPage;
export declare const loadPage: (this: Swup, data: TransitionOptions, popstate: PopStateEvent | null) => void;
import Swup from '../Swup.js';
import { EventType, Handler } from './on.js';
declare const off: (this: Swup, event?: EventType, handler?: Handler) => void;
export default off;
export declare const off: (this: Swup, event?: EventType, handler?: Handler) => void;

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

export type Handlers = Record<EventType, Handler[]>;
declare const on: (this: Swup, event: EventType, handler: Handler) => void;
export default on;
export declare const on: (this: Swup, event: EventType, handler: Handler) => void;
import Swup from '../Swup.js';
import { PageRecord } from './Cache.js';
declare const renderPage: (this: Swup, page: PageRecord, { popstate, skipTransition }?: {
export declare const renderPage: (this: Swup, page: PageRecord, { popstate, skipTransition }?: {
popstate: PopStateEvent | null;
skipTransition?: boolean | undefined;
}) => void;
export default renderPage;

@@ -13,6 +13,5 @@ /**

*/
declare const replaceContent: ({ blocks, title }: {
export declare const replaceContent: ({ blocks, title }: {
blocks: string[];
title: string;
}) => Promise<void>;
export default replaceContent;
import { EventType } from './on.js';
import Swup from '../Swup.js';
declare const triggerEvent: (this: Swup, eventName: EventType, originalEvent?: PopStateEvent | MouseEvent) => void;
export default triggerEvent;
export declare const triggerEvent: (this: Swup, eventName: EventType, originalEvent?: PopStateEvent | MouseEvent) => void;
import Swup from '../Swup.js';
declare const updateTransition: (this: Swup, from: string, to: string, custom?: string) => void;
export default updateTransition;
export declare const updateTransition: (this: Swup, from: string, to: string, custom?: string) => void;
import delegate from 'delegate-it';
import { Unsubscribe } from './helpers/delegateEvent.js';
import Cache from './modules/Cache.js';
import getAnimationPromises from './modules/getAnimationPromises.js';
import fetchPage from './modules/fetchPage.js';
import { Cache } from './modules/Cache.js';
import { getAnimationPromises } from './modules/getAnimationPromises.js';
import { fetchPage } from './modules/fetchPage.js';
import { Handlers } from './modules/on.js';

@@ -7,0 +7,0 @@ import { unuse, findPlugin, Plugin } from './modules/plugins.js';

{
"name": "swup",
"amdName": "Swup",
"version": "3.0.0-rc.2",
"version": "3.0.0-rc.3",
"description": "Complete, flexible, extensible, and easy-to-use page transition library for your server-side rendered website.",

@@ -22,3 +22,6 @@ "type": "module",

"dev": "microbundle src/*.ts -w",
"lint": "tsc --noEmit --skipLibCheck && prettier 'src/**/*.ts' --write",
"lint": "npm run lint:ts && npm run lint:prettier -- --check",
"format": "npm run lint:ts && npm run lint:prettier -- --write",
"lint:ts": "tsc --noEmit --skipLibCheck",
"lint:prettier": "prettier 'src/**/*.ts'",
"prepublish": "npm run build",

@@ -34,3 +37,4 @@ "postinstall": "opencollective-postinstall || true",

"cy:run:record": "cypress run --record",
"cy:open": "cypress open"
"cy:open": "cypress open",
"prepare": "husky install"
},

@@ -56,3 +60,3 @@ "author": "Georgy Marchuk",

"@swup/prettier-config": "^1.0.0",
"cypress": "^10.0.2",
"cypress": "^12.3.0",
"http-server": "^14.1.1",

@@ -63,3 +67,4 @@ "istanbul-lib-coverage": "^3.2.0",

"prettier": "^2.8.2",
"start-server-and-test": "^1.14.0"
"start-server-and-test": "^1.14.0",
"husky": "^8.0.0"
},

@@ -66,0 +71,0 @@ "collective": {

// Re-export all helpers to allow custom package export path
// e.g. import { getPageData } from 'swup/helpers'
export * from './helpers/index.js';
export { classify } from './helpers/classify.js';
export { createHistoryRecord } from './helpers/createHistoryRecord.js';
export { updateHistoryRecord } from './helpers/updateHistoryRecord.js';
export { delegateEvent } from './helpers/delegateEvent.js';
export { getDataFromHtml } from './helpers/getDataFromHtml.js';
export { fetch } from './helpers/fetch.js';
export { getCurrentUrl } from './helpers/getCurrentUrl.js';
export { Location } from './helpers/Location.js';
export { markSwupElements } from './helpers/markSwupElements.js';
export { cleanupAnimationClasses } from './helpers/cleanupAnimationClasses.js';
export { versionSatisfies } from './helpers/versionSatisfies.js';

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

const classify = (text: string, fallback?: string): string => {
export const classify = (text: string, fallback?: string): string => {
const output = String(text)

@@ -12,3 +12,1 @@ .toLowerCase()

};
export default classify;

@@ -1,5 +0,5 @@

const isSwupClass = (className: string): boolean =>
export const isSwupClass = (className: string): boolean =>
/^to-/.test(className) || ['is-changing', 'is-rendering', 'is-popstate'].includes(className);
const cleanupAnimationClasses = (): void => {
export const cleanupAnimationClasses = (): void => {
const htmlClasses = document.documentElement.className.split(' ');

@@ -9,3 +9,1 @@ const removeClasses = htmlClasses.filter(isSwupClass);

};
export default cleanupAnimationClasses;

@@ -1,4 +0,7 @@

import { default as getCurrentUrl } from './getCurrentUrl.js';
import { getCurrentUrl } from './getCurrentUrl.js';
const createHistoryRecord = (url: string, customData: Record<string, unknown> = {}): void => {
export const createHistoryRecord = (
url: string,
customData: Record<string, unknown> = {}
): void => {
url = url || getCurrentUrl({ hash: true });

@@ -13,3 +16,1 @@ const data = {

};
export default createHistoryRecord;

@@ -7,3 +7,3 @@ import delegate, { EventType } from 'delegate-it';

};
const delegateEvent = <Selector extends string, TEvent extends EventType>(
export const delegateEvent = <Selector extends string, TEvent extends EventType>(
selector: Selector,

@@ -23,3 +23,1 @@ type: TEvent,

};
export default delegateEvent;
import { TransitionOptions } from '../modules/loadPage.js';
import { Options } from '../Swup.js';
const fetch = (
export const fetch = (
options: TransitionOptions & { headers: Options['requestHeaders'] },

@@ -34,3 +34,1 @@ callback: (request: XMLHttpRequest) => void

};
export default fetch;

@@ -1,5 +0,3 @@

const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {
export const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {
return location.pathname + location.search + (hash ? location.hash : '');
};
export default getCurrentUrl;

@@ -10,3 +10,3 @@ import { query, queryAll } from '../utils.js';

const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {
export const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {
let fakeDom = document.createElement('html');

@@ -41,3 +41,1 @@ fakeDom.innerHTML = html;

};
export default getDataFromHtml;

@@ -17,3 +17,3 @@ /**

export default class Location extends URL {
export class Location extends URL {
constructor(url: string, base: string = document.baseURI) {

@@ -20,0 +20,0 @@ super(url.toString(), base);

import { query, queryAll } from '../utils.js';
const markSwupElements = (element: Element, containers: string[]): void => {
export const markSwupElements = (element: Element, containers: string[]): void => {
let blocks = 0;

@@ -17,3 +17,1 @@

};
export default markSwupElements;

@@ -1,4 +0,4 @@

import { default as getCurrentUrl } from './getCurrentUrl.js';
import { getCurrentUrl } from './getCurrentUrl.js';
const updateHistoryRecord = (
export const updateHistoryRecord = (
url: string | null = null,

@@ -17,3 +17,1 @@ customData: Record<string, unknown> = {}

};
export default updateHistoryRecord;

@@ -45,3 +45,1 @@ type Comparator = '>' | '>=' | '<' | '<=';

};
export default versionSatisfies;

@@ -56,3 +56,1 @@ import { getCurrentUrl, Location } from '../helpers.js';

}
export default Cache;
import { nextTick } from '../utils.js';
import Swup from '../Swup.js';
const enterPage = function (
export const enterPage = function (
this: Swup,

@@ -27,3 +27,1 @@ { popstate, skipTransition }: { popstate?: PopStateEvent; skipTransition?: boolean }

};
export default enterPage;

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

export default function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord> {
export function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord> {
const headers = this.options.requestHeaders;

@@ -9,0 +9,0 @@ const { url } = data;

import { escapeCssIdentifier, query } from '../utils.js';
const getAnchorElement = (hash: string): Element | null => {
export const getAnchorElement = (hash: string): Element | null => {
if (!hash) {

@@ -18,3 +18,1 @@ return null;

};
export default getAnchorElement;

@@ -20,3 +20,3 @@ import { queryAll, toMs } from '../utils.js';

export default function getAnimationPromises(
export function getAnimationPromises(
this: Swup,

@@ -23,0 +23,0 @@ // we don't use this argument, but JS plugin depends on it with

@@ -8,3 +8,3 @@ import { getDataFromHtml } from '../helpers.js';

};
const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | null {
export const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | null {
// this method can be replaced in case other content than html is expected to be received from server

@@ -26,3 +26,1 @@ // this function should always return { title, pageClass, originalContent, blocks, responseURL }

};
export default getPageData;
import Swup from '../Swup.js';
import { TransitionOptions } from './loadPage.js';
const leavePage = function (
export const leavePage = function (
this: Swup,

@@ -32,3 +32,1 @@ data: TransitionOptions,

};
export default leavePage;

@@ -10,3 +10,7 @@ import { classify, createHistoryRecord, getCurrentUrl } from '../helpers.js';

const loadPage = function (this: Swup, data: TransitionOptions, popstate: PopStateEvent | null) {
export const loadPage = function (
this: Swup,
data: TransitionOptions,
popstate: PopStateEvent | null
) {
const { url, customTransition } = data;

@@ -55,3 +59,1 @@ const skipTransition = !!(popstate && !this.options.animateHistoryBrowsing);

};
export default loadPage;
import Swup from '../Swup.js';
import { EventType, Handler } from './on.js';
const off = function off(this: Swup, event?: EventType, handler?: Handler) {
export const off = function off(this: Swup, event?: EventType, handler?: Handler) {
if (event && handler) {

@@ -22,3 +22,1 @@ // Remove specific handler

};
export default off;

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

const on = function on(this: Swup, event: EventType, handler: Handler) {
export const on = function on(this: Swup, event: EventType, handler: Handler) {
if (this._handlers[event]) {

@@ -35,3 +35,1 @@ this._handlers[event].push(handler);

};
export default on;

@@ -5,3 +5,3 @@ import { Location, updateHistoryRecord, getCurrentUrl } from '../helpers.js';

const renderPage = function (
export const renderPage = function (
this: Swup,

@@ -52,3 +52,1 @@ page: PageRecord,

};
export default renderPage;

@@ -13,3 +13,3 @@ /**

*/
const replaceContent = function ({ blocks, title }: { blocks: string[]; title: string }) {
export const replaceContent = function ({ blocks, title }: { blocks: string[]; title: string }) {
// Replace content blocks

@@ -28,3 +28,1 @@ blocks.forEach((html, i) => {

};
export default replaceContent;
import { EventType } from './on.js';
import Swup from '../Swup.js';
const triggerEvent = function (
export const triggerEvent = function (
this: Swup,

@@ -22,3 +22,1 @@ eventName: EventType,

};
export default triggerEvent;
import Swup from '../Swup.js';
const updateTransition = function (this: Swup, from: string, to: string, custom?: string): void {
export const updateTransition = function (
this: Swup,
from: string,
to: string,
custom?: string
): void {
this.transition = { from, to, custom };
};
export default updateTransition;

@@ -15,17 +15,17 @@ import delegate from 'delegate-it';

import Cache from './modules/Cache.js';
import enterPage from './modules/enterPage.js';
import getAnchorElement from './modules/getAnchorElement.js';
import getAnimationPromises from './modules/getAnimationPromises.js';
import getPageData from './modules/getPageData.js';
import fetchPage from './modules/fetchPage.js';
import leavePage from './modules/leavePage.js';
import loadPage from './modules/loadPage.js';
import replaceContent from './modules/replaceContent.js';
import off from './modules/off.js';
import on, { Handlers } from './modules/on.js';
import { Cache } from './modules/Cache.js';
import { enterPage } from './modules/enterPage.js';
import { getAnchorElement } from './modules/getAnchorElement.js';
import { getAnimationPromises } from './modules/getAnimationPromises.js';
import { getPageData } from './modules/getPageData.js';
import { fetchPage } from './modules/fetchPage.js';
import { leavePage } from './modules/leavePage.js';
import { loadPage } from './modules/loadPage.js';
import { replaceContent } from './modules/replaceContent.js';
import { off } from './modules/off.js';
import { on, Handlers } from './modules/on.js';
import { use, unuse, findPlugin, Plugin } from './modules/plugins.js';
import renderPage from './modules/renderPage.js';
import triggerEvent from './modules/triggerEvent.js';
import updateTransition from './modules/updateTransition.js';
import { renderPage } from './modules/renderPage.js';
import { triggerEvent } from './modules/triggerEvent.js';
import { updateTransition } from './modules/updateTransition.js';

@@ -32,0 +32,0 @@ import { queryAll } from './utils.js';

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