!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).SwupFadeTheme=t()}(this,function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;tString(e).split(".").map(e=>String(parseInt(e||"0",10))).concat(["0","0"]).slice(0,3).join(".");class n{constructor(){this.isSwupPlugin=!0,this.swup=void 0,this.version=void 0,this.requires={},this.handlersToUnregister=[]}mount(){}unmount(){this.handlersToUnregister.forEach(e=>e()),this.handlersToUnregister=[]}_beforeMount(){if(!this.name)throw new Error("You must define a name of plugin when creating a class.")}_afterUnmount(){}_checkRequirements(){return"object"!=typeof this.requires||Object.entries(this.requires).forEach(([e,n])=>{if(!function(e,n,s){const o=function(e,t){var n;if("swup"===e)return null!=(n=t.version)?n:"";{var s;const n=t.findPlugin(e);return null!=(s=null==n?void 0:n.version)?s:""}}(e,s);return!!o&&((e,n)=>n.every(n=>{const[,s,o]=n.match(/^([\D]+)?(.*)$/)||[];var i,r;return((e,t)=>{const n={"":e=>0===e,">":e=>e>0,">=":e=>e>=0,"<":e=>e<0,"<=":e=>e<=0};return(n[t]||n[""])(e)})((r=o,i=t(i=e),r=t(r),i.localeCompare(r,void 0,{numeric:!0})),s||">=")}))(o,n)}(e,n=Array.isArray(n)?n:[n],this.swup)){const t=`${e} ${n.join(", ")}`;throw new Error(`Plugin version mismatch: ${this.name} requires ${t}`)}}),!0}on(e,t,n={}){var s;t=!(s=t).name.startsWith("bound ")||s.hasOwnProperty("prototype")?t.bind(this):t;const o=this.swup.hooks.on(e,t,n);return this.handlersToUnregister.push(o),o}once(t,n,s={}){return this.on(t,n,e({},s,{once:!0}))}before(t,n,s={}){return this.on(t,n,e({},s,{before:!0}))}replace(t,n,s={}){return this.on(t,n,e({},s,{replace:!0}))}off(e,t){return this.swup.hooks.off(e,t)}}class s extends n{constructor(...e){super(...e),this._originalAnimationSelectorOption="",this._addedStyleElements=[],this._addedHTMLContent=[],this._classNameAddedToElements=[],this._addClassNameToElement=()=>{this._classNameAddedToElements.forEach(e=>{Array.from(document.querySelectorAll(e.selector)).forEach(t=>{t.classList.add(`swup-transition-${e.name}`)})})}}_beforeMount(){this._originalAnimationSelectorOption=String(this.swup.options.animationSelector),this.swup.options.animationSelector='[class*="swup-transition-"]',this.swup.hooks.on("content:replace",this._addClassNameToElement)}_afterUnmount(){this.swup.options.animationSelector=this._originalAnimationSelectorOption,this._addedStyleElements.forEach(e=>{e.outerHTML=""}),this._addedStyleElements=[],this._addedHTMLContent.forEach(e=>{e.outerHTML=""}),this._addedHTMLContent=[],this._classNameAddedToElements.forEach(e=>{Array.from(document.querySelectorAll(e.selector)).forEach(e=>{e.className.split(" ").forEach(t=>{new RegExp("^swup-transition-").test(t)&&e.classList.remove(t)})})}),this.swup.hooks.off("content:replace",this._addClassNameToElement)}applyStyles(e){const t=document.createElement("style");t.setAttribute("data-swup-theme",""),t.appendChild(document.createTextNode(e)),document.head.prepend(t),this._addedStyleElements.push(t)}applyHTML(e){const t=document.createElement("div");t.innerHTML=e,document.body.appendChild(t),this._addedHTMLContent.push(t)}addClassName(e,t){this._classNameAddedToElements.push({selector:e,name:t}),this._addClassNameToElement()}}return class extends s{constructor(e={}){super(),this.name="SwupFadeTheme",this.defaults={mainElement:"#swup"},this.options=void 0,this.options={...this.defaults,...e}}mount(){this.applyStyles("html{--swup-fade-theme-duration:0.4s}html.is-changing .swup-transition-main{opacity:1;transition:opacity var(--swup-fade-theme-duration)}html.is-animating .swup-transition-main{opacity:0}"),this.addClassName(this.options.mainElement,"main")}}}); //# sourceMappingURL=index.umd.js.map