(function(G,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(G||self).barba=I()})(this,function(){function G(i,r){for(var e=0;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Z(i,r,e){return Z=fe()?Reflect.construct.bind():function(t,n,o){var a=[null];a.push.apply(a,n);var u=new(Function.bind.apply(t,a));return o&&W(u,o.prototype),u},Z.apply(null,arguments)}function ee(i){var r=typeof Map=="function"?new Map:void 0;return ee=function(e){if(e===null||Function.toString.call(e).indexOf("[native code]")===-1)return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return Z(e,arguments,V(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),W(t,e)},ee(i)}function le(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}var M,de=function(){this.before=void 0,this.beforeLeave=void 0,this.leave=void 0,this.afterLeave=void 0,this.beforeEnter=void 0,this.enter=void 0,this.afterEnter=void 0,this.after=void 0};(function(i){i[i.off=0]="off",i[i.error=1]="error",i[i.warning=2]="warning",i[i.info=3]="info",i[i.debug=4]="debug"})(M||(M={}));var ie=M.off,U=function(){function i(e){this.t=void 0,this.t=e}i.getLevel=function(){return ie},i.setLevel=function(e){return ie=M[e]};var r=i.prototype;return r.error=function(){this.i(console.error,M.error,[].slice.call(arguments))},r.warn=function(){this.i(console.warn,M.warning,[].slice.call(arguments))},r.info=function(){this.i(console.info,M.info,[].slice.call(arguments))},r.debug=function(){this.i(console.log,M.debug,[].slice.call(arguments))},r.i=function(e,t,n){t<=i.getLevel()&&e.apply(console,["["+this.t+"] "].concat(n))},i}();function F(i){return i.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function oe(i){return i&&i.sensitive?"":"i"}var H={container:"container",history:"history",namespace:"namespace",prefix:"data-barba",prevent:"prevent",wrapper:"wrapper"},pe=function(){function i(){this.o=H,this.u=void 0,this.h={after:null,before:null,parent:null}}var r=i.prototype;return r.toString=function(e){return e.outerHTML},r.toDocument=function(e){return this.u||(this.u=new DOMParser),this.u.parseFromString(e,"text/html")},r.toElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t},r.getHtml=function(e){return e===void 0&&(e=document),this.toString(e.documentElement)},r.getWrapper=function(e){return e===void 0&&(e=document),e.querySelector("["+this.o.prefix+'="'+this.o.wrapper+'"]')},r.getContainer=function(e){return e===void 0&&(e=document),e.querySelector("["+this.o.prefix+'="'+this.o.container+'"]')},r.removeContainer=function(e){document.body.contains(e)&&(this.v(e),e.parentNode.removeChild(e))},r.addContainer=function(e,t){var n=this.getContainer()||this.h.before;n?this.l(e,n):this.h.after?this.h.after.parentNode.insertBefore(e,this.h.after):this.h.parent?this.h.parent.appendChild(e):t.appendChild(e)},r.getSibling=function(){return this.h},r.getNamespace=function(e){e===void 0&&(e=document);var t=e.querySelector("["+this.o.prefix+"-"+this.o.namespace+"]");return t?t.getAttribute(this.o.prefix+"-"+this.o.namespace):null},r.getHref=function(e){if(e.tagName&&e.tagName.toLowerCase()==="a"){if(typeof e.href=="string")return e.href;var t=e.getAttribute("href")||e.getAttribute("xlink:href");if(t)return this.resolveUrl(t.baseVal||t)}return null},r.resolveUrl=function(){var e=[].slice.call(arguments).length;if(e===0)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],e===1)return t.href;var n=document.getElementsByTagName("head")[0];n.insertBefore(t,n.firstChild);for(var o,a=document.createElement("a"),u=1;u1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"},I(i,[{key:"current",get:function(){return this.m[this.P]}},{key:"previous",get:function(){return this.P<1?null:this.m[this.P-1]}},{key:"size",get:function(){return this.m.length}}]),i}(),se=new ve,z=function(i,r){try{var e=function(){if(!r.next.html)return Promise.resolve(i).then(function(t){var n=r.next;if(t){var o=D.toElement(t.html);n.namespace=D.getNamespace(o),n.container=D.getContainer(o),n.url=t.url,n.html=t.html,se.update({ns:n.namespace});var a=D.toDocument(t.html);document.title=a.title}})}();return Promise.resolve(e&&e.then?e.then(function(){}):void 0)}catch(t){return Promise.reject(t)}},ae=function i(r,e,t){return r instanceof RegExp?function(n,o){if(!o)return n;for(var a=/\((?:\?<(.*?)>)?(?!\?)/g,u=0,s=a.exec(n.source);s;)o.push({name:s[1]||u++,prefix:"",suffix:"",modifier:"",pattern:""}),s=a.exec(n.source);return n}(r,e):Array.isArray(r)?function(n,o,a){var u=n.map(function(s){return i(s,o,a).source});return new RegExp("(?:".concat(u.join("|"),")"),oe(a))}(r,e,t):function(n,o,a){return function(u,s,c){c===void 0&&(c={});for(var g=c.strict,p=g!==void 0&&g,h=c.start,w=h===void 0||h,f=c.end,l=f===void 0||f,b=c.encode,y=b===void 0?function(Q){return Q}:b,k=c.delimiter,P=k===void 0?"/#?":k,A=c.endsWith,q="[".concat(F(A===void 0?"":A),"]|$"),S="[".concat(F(P),"]"),O=w?"^":"",L=0,T=u;L-1:m===void 0;p||(O+="(?:".concat(S,"(?=").concat(q,"))?")),j||(O+="(?=".concat(S,"|").concat(q,")"))}return new RegExp(O,oe(c))}(function(u,s){s===void 0&&(s={});for(var c=function(d){for(var E=[],m=0;m=48&&B<=57||B>=65&&B<=90||B>=97&&B<=122||B===95))break;ne+=d[x++]}if(!ne)throw new TypeError("Missing parameter name at ".concat(m));E.push({type:"NAME",index:m,value:ne}),m=x}else E.push({type:"CLOSE",index:m,value:d[m++]});else E.push({type:"OPEN",index:m,value:d[m++]});else E.push({type:"ESCAPED_CHAR",index:m++,value:d[m++]});else E.push({type:"MODIFIER",index:m,value:d[m++]})}return E.push({type:"END",index:m,value:""}),E}(u),g=s.prefixes,p=g===void 0?"./":g,h="[^".concat(F(s.delimiter||"/#?"),"]+?"),w=[],f=0,l=0,b="",y=function(d){if(l=0&&(n=o.slice(u+1),o=o.slice(0,u));var s=o.indexOf("?");return s>=0&&(a=ce(o.slice(s+1)),o=o.slice(0,s)),{hash:n,path:o,port:r,query:a}},ce=function(i){return i.split("&").reduce(function(r,e){var t=e.split("=");return r[t[0]]=t[1],r},{})},te=function(i){return i===void 0&&(i=window.location.href),i.replace(/(\/#.*|\/|#.*)$/,"")},ge={__proto__:null,getHref:function(){return window.location.href},getAbsoluteHref:function(i,r){return r===void 0&&(r=document.baseURI),new URL(i,r).href},getOrigin:ue,getPort:X,getPath:function(i){return i===void 0&&(i=window.location.href),N(i).path},getQuery:function(i,r){return r===void 0&&(r=!1),r?JSON.stringify(N(i).query):N(i).query},getHash:function(i){return N(i).hash},parse:N,parseQuery:ce,clean:te};function ye(i,r,e,t,n){return r===void 0&&(r=2e3),new Promise(function(o,a){var u=new XMLHttpRequest;u.onreadystatechange=function(){if(u.readyState===XMLHttpRequest.DONE){if(u.status===200){var s=u.responseURL!==""&&u.responseURL!==i?u.responseURL:i;o({html:u.responseText,url:C({href:s},N(s))}),t.update(i,{status:"fulfilled",target:s})}else if(u.status){var c={status:u.status,statusText:u.statusText};e(i,c),a(c),t.update(i,{status:"rejected"})}}},u.ontimeout=function(){var s=new Error("Timeout error ["+r+"]");e(i,s),a(s),t.update(i,{status:"rejected"})},u.onerror=function(){var s=new Error("Fetch error");e(i,s),a(s),t.update(i,{status:"rejected"})},u.open("GET",i),u.timeout=r,u.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml"),u.setRequestHeader("x-barba","yes"),n.all().forEach(function(s,c){u.setRequestHeader(c,s)}),u.send()})}function we(i){return!!i&&(typeof i=="object"||typeof i=="function")&&typeof i.then=="function"}function $(i,r){return r===void 0&&(r={}),function(){var e=arguments,t=!1,n=new Promise(function(o,a){r.async=function(){return t=!0,function(s,c){s?a(s):o(c)}};var u=i.apply(r,[].slice.call(e));t||(we(u)?u.then(o,a):o(u))});return n}}var be=function(i){function r(){var t;return(t=i.call(this)||this).logger=new U("@barba/core"),t.all=["ready","page","reset","currentAdded","currentRemoved","nextAdded","nextRemoved","beforeOnce","once","afterOnce","before","beforeLeave","leave","afterLeave","beforeEnter","enter","afterEnter","after"],t.registered=new Map,t.init(),t}J(r,i);var e=r.prototype;return e.init=function(){var t=this;this.registered.clear(),this.all.forEach(function(n){t[n]||(t[n]=function(o,a){t.registered.has(n)||t.registered.set(n,new Set),t.registered.get(n).add({ctx:a||{},fn:o})})})},e.do=function(t){var n=arguments,o=this;if(this.registered.has(t)){var a=Promise.resolve();return this.registered.get(t).forEach(function(u){a=a.then(function(){return $(u.fn,u.ctx).apply(void 0,[].slice.call(n,1))})}),a.catch(function(u){o.logger.debug("Hook error ["+t+"]"),o.logger.error(u)})}return Promise.resolve()},e.clear=function(){var t=this;this.all.forEach(function(n){delete t[n]}),this.init()},e.help=function(){this.logger.info("Available hooks: "+this.all.join(","));var t=[];this.registered.forEach(function(n,o){return t.push(o)}),this.logger.info("Registered hooks: "+t.join(","))},r}(de),_=new be,he=function(){function i(r){if(this.k=void 0,this.O=[],typeof r=="boolean")this.k=r;else{var e=Array.isArray(r)?r:[r];this.O=e.map(function(t){return ae(t)})}}return i.prototype.checkHref=function(r){if(typeof this.k=="boolean")return this.k;var e=N(r).path;return this.O.some(function(t){return t.exec(e)!==null})},i}(),Pe=function(i){function r(t){var n;return(n=i.call(this,t)||this).T=new Map,n}J(r,i);var e=r.prototype;return e.set=function(t,n,o,a,u){return this.T.set(t,{action:o,request:n,status:a,target:u??t}),{action:o,request:n,status:a,target:u}},e.get=function(t){return this.T.get(t)},e.getRequest=function(t){return this.T.get(t).request},e.getAction=function(t){return this.T.get(t).action},e.getStatus=function(t){return this.T.get(t).status},e.getTarget=function(t){return this.T.get(t).target},e.has=function(t){return!this.checkHref(t)&&this.T.has(t)},e.delete=function(t){return this.T.delete(t)},e.update=function(t,n){var o=C({},this.T.get(t),n);return this.T.set(t,o),o},r}(he),Ee=function(){function i(){this.A=new Map}var r=i.prototype;return r.set=function(e,t){return this.A.set(e,t),{name:t}},r.get=function(e){return this.A.get(e)},r.all=function(){return this.A},r.has=function(e){return this.A.has(e)},r.delete=function(e){return this.A.delete(e)},r.clear=function(){return this.A.clear()},i}(),xe=function(){return!window.history.pushState},Oe=function(i){return!i.el||!i.href},Ae=function(i){var r=i.event;return r.which>1||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey},Re=function(i){var r=i.el;return r.hasAttribute("target")&&r.target==="_blank"},ke=function(i){var r=i.el;return r.protocol!==void 0&&window.location.protocol!==r.protocol||r.hostname!==void 0&&window.location.hostname!==r.hostname},Le=function(i){var r=i.el;return r.port!==void 0&&X()!==X(r.href)},Te=function(i){var r=i.el;return r.getAttribute&&typeof r.getAttribute("download")=="string"},je=function(i){return i.el.hasAttribute(H.prefix+"-"+H.prevent)},Se=function(i){return Boolean(i.el.closest("["+H.prefix+"-"+H.prevent+'="all"]'))},Ce=function(i){var r=i.href;return te(r)===te()&&X(r)===X()},He=function(i){function r(t){var n;return(n=i.call(this,t)||this).suite=[],n.tests=new Map,n.init(),n}J(r,i);var e=r.prototype;return e.init=function(){this.add("pushState",xe),this.add("exists",Oe),this.add("newTab",Ae),this.add("blank",Re),this.add("corsDomain",ke),this.add("corsPort",Le),this.add("download",Te),this.add("preventSelf",je),this.add("preventAll",Se),this.add("sameUrl",Ce,!1)},e.add=function(t,n,o){o===void 0&&(o=!0),this.tests.set(t,n),o&&this.suite.push(t)},e.run=function(t,n,o,a){return this.tests.get(t)({el:n,event:o,href:a})},e.checkLink=function(t,n,o){var a=this;return this.suite.some(function(u){return a.run(u,t,n,o)})},r}(he),re=function(i){function r(e,t){var n;return t===void 0&&(t="Barba error"),(n=i.call.apply(i,[this].concat([].slice.call(arguments,2)))||this).error=void 0,n.label=void 0,n.error=e,n.label=t,Error.captureStackTrace&&Error.captureStackTrace(le(n),r),n.name="BarbaError",n}return J(r,i),r}(ee(Error)),qe=function(){function i(e){e===void 0&&(e=[]),this.logger=new U("@barba/core"),this.all=[],this.page=[],this.once=[],this.j=[{name:"namespace",type:"strings"},{name:"custom",type:"function"}],e&&(this.all=this.all.concat(e)),this.update()}var r=i.prototype;return r.add=function(e,t){e==="rule"?this.j.splice(t.position||0,0,t.value):this.all.push(t),this.update()},r.resolve=function(e,t){var n=this;t===void 0&&(t={});var o=t.once?this.once:this.page;o=o.filter(t.self?function(h){return h.name&&h.name==="self"}:function(h){return!h.name||h.name!=="self"});var a=new Map,u=o.find(function(h){var w=!0,f={};return t.self&&h.name==="self"?(a.set(h,f),!0):(n.j.reverse().forEach(function(l){w&&(w=n.M(h,l,e,f),h.from&&h.to&&(w=n.M(h,l,e,f,"from")&&n.M(h,l,e,f,"to")),h.from&&!h.to&&(w=n.M(h,l,e,f,"from")),!h.from&&h.to&&(w=n.M(h,l,e,f,"to")))}),a.set(h,f),w)}),s=a.get(u),c=[];if(c.push(t.once?"once":"page"),t.self&&c.push("self"),s){var g,p=[u];Object.keys(s).length>0&&p.push(s),(g=this.logger).info.apply(g,["Transition found ["+c.join(",")+"]"].concat(p))}else this.logger.info("No transition found ["+c.join(",")+"]");return u},r.update=function(){var e=this;this.all=this.all.map(function(t){return e.N(t)}).sort(function(t,n){return t.priority-n.priority}).reverse().map(function(t){return delete t.priority,t}),this.page=this.all.filter(function(t){return t.leave!==void 0||t.enter!==void 0}),this.once=this.all.filter(function(t){return t.once!==void 0})},r.M=function(e,t,n,o,a){var u=!0,s=!1,c=e,g=t.name,p=g,h=g,w=g,f=a?c[a]:c,l=a==="to"?n.next:n.current;if(a?f&&f[g]:f[g]){switch(t.type){case"strings":default:var b=Array.isArray(f[p])?f[p]:[f[p]];l[p]&&b.indexOf(l[p])!==-1&&(s=!0),b.indexOf(l[p])===-1&&(u=!1);break;case"object":var y=Array.isArray(f[h])?f[h]:[f[h]];l[h]?(l[h].name&&y.indexOf(l[h].name)!==-1&&(s=!0),y.indexOf(l[h].name)===-1&&(u=!1)):u=!1;break;case"function":f[w](n)?s=!0:u=!1}s&&(a?(o[a]=o[a]||{},o[a][g]=c[a][g]):o[g]=c[g])}return u},r.S=function(e,t,n){var o=0;return(e[t]||e.from&&e.from[t]||e.to&&e.to[t])&&(o+=Math.pow(10,n),e.from&&e.from[t]&&(o+=1),e.to&&e.to[t]&&(o+=2)),o},r.N=function(e){var t=this;e.priority=0;var n=0;return this.j.forEach(function(o,a){n+=t.S(e,o.name,a+1)}),e.priority=n,e},i}();function K(i,r){try{var e=i()}catch(t){return r(t)}return e&&e.then?e.then(void 0,r):e}var Me=function(){function i(e){e===void 0&&(e=[]),this.logger=new U("@barba/core"),this.store=void 0,this.C=!1,this.store=new qe(e)}var r=i.prototype;return r.get=function(e,t){return this.store.resolve(e,t)},r.doOnce=function(e){var t=e.data,n=e.transition;try{var o=function(){a.C=!1},a=this,u=n||{};a.C=!0;var s=K(function(){return Promise.resolve(a.L("beforeOnce",t,u)).then(function(){return Promise.resolve(a.once(t,u)).then(function(){return Promise.resolve(a.L("afterOnce",t,u)).then(function(){})})})},function(c){a.C=!1,a.logger.debug("Transition error [before/after/once]"),a.logger.error(c)});return Promise.resolve(s&&s.then?s.then(o):o())}catch(c){return Promise.reject(c)}},r.doPage=function(e){var t=e.data,n=e.transition,o=e.page,a=e.wrapper;try{var u=function(h){s.C=!1},s=this,c=n||{},g=c.sync===!0||!1;s.C=!0;var p=K(function(){function h(){return Promise.resolve(s.L("before",t,c)).then(function(){function f(b){return Promise.resolve(s.remove(t)).then(function(){return Promise.resolve(s.L("after",t,c)).then(function(){})})}var l=function(){if(g)return K(function(){return Promise.resolve(s.add(t,a)).then(function(){return Promise.resolve(s.L("beforeLeave",t,c)).then(function(){return Promise.resolve(s.L("beforeEnter",t,c)).then(function(){return Promise.resolve(Promise.all([s.leave(t,c),s.enter(t,c)])).then(function(){return Promise.resolve(s.L("afterLeave",t,c)).then(function(){return Promise.resolve(s.L("afterEnter",t,c)).then(function(){})})})})})})},function(P){if(s.H(P))throw new re(P,"Transition error [sync]")});var b=function(P){return K(function(){var A=function(){if(y!==!1)return Promise.resolve(s.add(t,a)).then(function(){return Promise.resolve(s.L("beforeEnter",t,c)).then(function(){return Promise.resolve(s.enter(t,c,y)).then(function(){return Promise.resolve(s.L("afterEnter",t,c)).then(function(){})})})})}();if(A&&A.then)return A.then(function(){})},function(A){if(s.H(A))throw new re(A,"Transition error [before/after/enter]")})},y=!1,k=K(function(){return Promise.resolve(s.L("beforeLeave",t,c)).then(function(){return Promise.resolve(Promise.all([s.leave(t,c),z(o,t)]).then(function(P){return P[0]})).then(function(P){return y=P,Promise.resolve(s.L("afterLeave",t,c)).then(function(){})})})},function(P){if(s.H(P))throw new re(P,"Transition error [before/after/leave]")});return k&&k.then?k.then(b):b()}();return l&&l.then?l.then(f):f()})}var w=function(){if(g)return Promise.resolve(z(o,t)).then(function(){})}();return w&&w.then?w.then(h):h()},function(h){throw s.C=!1,h.name&&h.name==="BarbaError"?(s.logger.debug(h.label),s.logger.error(h.error),h):(s.logger.debug("Transition error [page]"),s.logger.error(h),h)});return Promise.resolve(p&&p.then?p.then(u):u())}catch(h){return Promise.reject(h)}},r.once=function(e,t){try{return Promise.resolve(_.do("once",e,t)).then(function(){return t.once?$(t.once,t)(e):Promise.resolve()})}catch(n){return Promise.reject(n)}},r.leave=function(e,t){try{return Promise.resolve(_.do("leave",e,t)).then(function(){return t.leave?$(t.leave,t)(e):Promise.resolve()})}catch(n){return Promise.reject(n)}},r.enter=function(e,t,n){try{return Promise.resolve(_.do("enter",e,t)).then(function(){return t.enter?$(t.enter,t)(e,n):Promise.resolve()})}catch(o){return Promise.reject(o)}},r.add=function(e,t){try{return D.addContainer(e.next.container,t),_.do("nextAdded",e),Promise.resolve()}catch(n){return Promise.reject(n)}},r.remove=function(e){try{return D.removeContainer(e.current.container),_.do("currentRemoved",e),Promise.resolve()}catch(t){return Promise.reject(t)}},r.H=function(e){return e.message?!/Timeout error|Fetch error/.test(e.message):!e.status},r.L=function(e,t,n){try{return Promise.resolve(_.do(e,t,n)).then(function(){return n[e]?$(n[e],n)(t):Promise.resolve()})}catch(o){return Promise.reject(o)}},I(i,[{key:"isRunning",get:function(){return this.C},set:function(e){this.C=e}},{key:"hasOnce",get:function(){return this.store.once.length>0}},{key:"hasSelf",get:function(){return this.store.all.some(function(e){return e.name==="self"})}},{key:"shouldWait",get:function(){return this.store.all.some(function(e){return e.to&&!e.to.route||e.sync})}}]),i}(),Ne=function(){function i(r){var e=this;this.names=["beforeLeave","afterLeave","beforeEnter","afterEnter"],this.byNamespace=new Map,r.length!==0&&(r.forEach(function(t){e.byNamespace.set(t.namespace,t)}),this.names.forEach(function(t){_[t](e._(t))}))}return i.prototype._=function(r){var e=this;return function(t){var n=r.match(/enter/i)?t.next:t.current,o=e.byNamespace.get(n.namespace);return o&&o[r]?$(o[r],o)(t):Promise.resolve()}},i}();Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(i){var r=this;do{if(r.matches(i))return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1);return null});var _e={container:null,html:"",namespace:"",url:{hash:"",href:"",path:"",port:null,query:{}}},Ie=function(){function i(){this.version="2.10.2",this.schemaPage=_e,this.Logger=U,this.logger=new U("@barba/core"),this.plugins=[],this.timeout=void 0,this.cacheIgnore=void 0,this.cacheFirstPage=void 0,this.prefetchIgnore=void 0,this.preventRunning=void 0,this.hooks=_,this.cache=void 0,this.headers=void 0,this.prevent=void 0,this.transitions=void 0,this.views=void 0,this.dom=D,this.helpers=me,this.history=se,this.request=ye,this.url=ge,this.D=void 0,this.B=void 0,this.q=void 0,this.F=void 0}var r=i.prototype;return r.use=function(e,t){var n=this.plugins;n.indexOf(e)>-1?this.logger.warn("Plugin ["+e.name+"] already installed."):typeof e.install=="function"?(e.install(this,t),n.push(e)):this.logger.warn("Plugin ["+e.name+'] has no "install" method.')},r.init=function(e){var t=e===void 0?{}:e,n=t.transitions,o=n===void 0?[]:n,a=t.views,u=a===void 0?[]:a,s=t.schema,c=s===void 0?H:s,g=t.requestError,p=t.timeout,h=p===void 0?2e3:p,w=t.cacheIgnore,f=w!==void 0&&w,l=t.cacheFirstPage,b=l!==void 0&&l,y=t.prefetchIgnore,k=y!==void 0&&y,P=t.preventRunning,A=P!==void 0&&P,q=t.prevent,S=q===void 0?null:q,O=t.debug,L=t.logLevel;if(U.setLevel((O!==void 0&&O)===!0?"debug":L===void 0?"off":L),this.logger.info(this.version),Object.keys(c).forEach(function(R){H[R]&&(H[R]=c[R])}),this.B=g,this.timeout=h,this.cacheIgnore=f,this.cacheFirstPage=b,this.prefetchIgnore=k,this.preventRunning=A,this.q=this.dom.getWrapper(),!this.q)throw new Error("[@barba/core] No Barba wrapper found");this.I();var T=this.data.current;if(!T.container)throw new Error("[@barba/core] No Barba container found");if(this.cache=new Pe(f),this.headers=new Ee,this.prevent=new He(k),this.transitions=new Me(o),this.views=new Ne(u),S!==null){if(typeof S!="function")throw new Error("[@barba/core] Prevent should be a function");this.prevent.add("preventCustom",S)}this.history.init(T.url.href,T.namespace),b&&this.cache.set(T.url.href,Promise.resolve({html:T.html,url:T.url}),"init","fulfilled"),this.U=this.U.bind(this),this.$=this.$.bind(this),this.X=this.X.bind(this),this.G(),this.plugins.forEach(function(R){return R.init()});var v=this.data;v.trigger="barba",v.next=v.current,v.current=C({},this.schemaPage),this.hooks.do("ready",v),this.once(v),this.I()},r.destroy=function(){this.I(),this.J(),this.history.clear(),this.hooks.clear(),this.plugins=[]},r.force=function(e){window.location.assign(e)},r.go=function(e,t,n){var o;if(t===void 0&&(t="barba"),this.F=null,this.transitions.isRunning)this.force(e);else if(!(o=t==="popstate"?this.history.current&&this.url.getPath(this.history.current.url)===this.url.getPath(e)&&this.url.getQuery(this.history.current.url,!0)===this.url.getQuery(e,!0):this.prevent.run("sameUrl",null,null,e))||this.transitions.hasSelf)return t=this.history.change(this.cache.has(e)?this.cache.get(e).target:e,t,n),n&&(n.stopPropagation(),n.preventDefault()),this.page(e,t,n??void 0,o)},r.once=function(e){try{var t=this;return Promise.resolve(t.hooks.do("beforeEnter",e)).then(function(){function n(){return Promise.resolve(t.hooks.do("afterEnter",e)).then(function(){})}var o=function(){if(t.transitions.hasOnce){var a=t.transitions.get(e,{once:!0});return Promise.resolve(t.transitions.doOnce({transition:a,data:e})).then(function(){})}}();return o&&o.then?o.then(n):n()})}catch(n){return Promise.reject(n)}},r.page=function(e,t,n,o){try{var a,u=function(){var p=s.data;return Promise.resolve(s.hooks.do("page",p)).then(function(){var h=function(w,f){try{var l=(b=s.transitions.get(p,{once:!1,self:o}),Promise.resolve(s.transitions.doPage({data:p,page:a,transition:b,wrapper:s.q})).then(function(){s.I()}))}catch{return f()}var b;return l&&l.then?l.then(void 0,f):l}(0,function(){U.getLevel()===0&&s.force(p.next.url.href)});if(h&&h.then)return h.then(function(){})})},s=this;if(s.data.next.url=C({href:e},s.url.parse(e)),s.data.trigger=t,s.data.event=n,s.cache.has(e))a=s.cache.update(e,{action:"click"}).request;else{var c=s.request(e,s.timeout,s.onRequestError.bind(s,t),s.cache,s.headers);c.then(function(p){p.url.href!==e&&s.history.add(p.url.href,t,"replace")}),a=s.cache.set(e,c,"click","pending").request}var g=function(){if(s.transitions.shouldWait)return Promise.resolve(z(a,s.data)).then(function(){})}();return Promise.resolve(g&&g.then?g.then(u):u())}catch(p){return Promise.reject(p)}},r.onRequestError=function(e){this.transitions.isRunning=!1;var t=[].slice.call(arguments,1),n=t[0],o=t[1],a=this.cache.getAction(n);return this.cache.delete(n),this.B&&this.B(e,a,n,o)===!1||a==="click"&&this.force(n),!1},r.prefetch=function(e){var t=this;e=this.url.getAbsoluteHref(e),this.cache.has(e)||this.cache.set(e,this.request(e,this.timeout,this.onRequestError.bind(this,"barba"),this.cache,this.headers).catch(function(n){t.logger.error(n)}),"prefetch","pending")},r.G=function(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.U),document.addEventListener("touchstart",this.U)),document.addEventListener("click",this.$),window.addEventListener("popstate",this.X)},r.J=function(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.U),document.removeEventListener("touchstart",this.U)),document.removeEventListener("click",this.$),window.removeEventListener("popstate",this.X)},r.U=function(e){var t=this,n=this.W(e);if(n){var o=this.url.getAbsoluteHref(this.dom.getHref(n));this.prevent.checkHref(o)||this.cache.has(o)||this.cache.set(o,this.request(o,this.timeout,this.onRequestError.bind(this,n),this.cache,this.headers).catch(function(a){t.logger.error(a)}),"enter","pending")}},r.$=function(e){var t=this.W(e);if(!t||this.transitions.isRunning&&this.preventRunning)return e.preventDefault(),void e.stopPropagation();this.F=e,this.go(this.dom.getHref(t),t,e)},r.X=function(e){this.go(this.url.getHref(),"popstate",e)},r.W=function(e){for(var t=e.target;t&&!this.dom.getHref(t);)t=t.parentNode;if(t&&!this.prevent.checkLink(t,e,this.dom.getHref(t)))return t},r.I=function(){var e=this.url.getHref(),t={container:this.dom.getContainer(),html:this.dom.getHtml(),namespace:this.dom.getNamespace(),url:C({href:e},this.url.parse(e))};this.D={current:t,event:void 0,next:C({},this.schemaPage),trigger:void 0},this.hooks.do("reset",this.data)},I(i,[{key:"data",get:function(){return this.D}},{key:"wrapper",get:function(){return this.q}}]),i}();return new Ie});