-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
1 lines (1 loc) · 55.3 KB
/
index.js
1
var e=Object.defineProperty,t=(t,n)=>e(t,"name",{value:n,configurable:!0}),n="undefined"!=typeof window?window:{screen:{},navigator:{}},o=(n.matchMedia||function(){return{matches:!1}}).bind(n),s={get passive(){return!0}},r=t((function(){}),"noop");n.addEventListener&&n.addEventListener("p",r,s),n.removeEventListener&&n.removeEventListener("p",r,!1);var i="ontouchstart"in n,a=i||"TouchEvent"in n&&o("(any-pointer: coarse)").matches,c=(n.navigator.maxTouchPoints||0)>0||a,l=n.navigator.userAgent||"",u=o("(pointer: coarse)").matches&&/iPad|Macintosh/.test(l)&&Math.min(n.screen.width||0,n.screen.height||0)>=768,d=(o("(pointer: coarse)").matches||!o("(pointer: fine)").matches&&i)&&!/Windows.*Firefox/.test(l),f=o("(any-pointer: fine)").matches||o("(any-hover: hover)").matches||u||!i,p=!c||!f&&d?c?"touchOnly":"mouseOnly":"hybrid",h="undefined"!=typeof window;document.createElement("template"),document.createRange&&document.createRange();var m=a?"pointer":"mouse",g=window.location.origin,{assign:y,keys:v,entries:b}=Object,$=Object.defineProperty,k=Object.defineProperties,w=Object.create,{isArray:A}=Array,x=Array.from,N="",{warn:E,info:C,error:q,debug:T}=console,S=t((()=>document.body),"d"),O=t((()=>document.head),"h"),L=t((e=>e?y(w(null),e):w(null)),"o"),P=t((e=>new Set(e)),"s"),R=t((e=>new Proxy(L(),e)),"p"),I=t((()=>new Map),"m"),j=class extends XMLHttpRequest{constructor(){super(...arguments),this.key=null}};t(j,"XHR"),j.e=I(),j.j=I(),j.f=L();var H=j,M=L({index:"",eval:!0,patched:!1,loaded:!1,logLevel:2,qs:L(),config:L({fragments:["body"],timeout:3e4,globalThis:!0,schema:"spx-",manual:!1,logLevel:2,cache:!0,components:null,maxCache:100,reverse:!0,preload:null,annotate:!1,eval:L({script:null,style:null,link:null,meta:!1}),hover:L({trigger:"href",threshold:250}),intersect:L({rootMargin:"0px 0px 0px 0px",threshold:0}),proximity:L({distance:75,threshold:250,throttle:500}),progress:L({bgColor:"#111",barHeight:"3px",minimum:.08,easing:"linear",speed:200,threshold:500,trickle:!0,trickleSpeed:200})}),fragments:I(),components:L({n:I(),h:I(),k:P(),b:I(),L:I(),l:R({get:(e,t)=>M.components.h.get(e[t])})}),events:L(),observe:L(),memory:L(),pages:L(),snaps:L(),resources:P()}),W="[96mSPX[0m ";function D(e,t,n){const o=M.logLevel;if(!(o>2&&e<=2))if(A(t)&&(t=t.join(" ")),2!==e&&1!==e||1!==o&&2!==o){if(e<=3&&3===o)n?E(W+t,n):E(W+t);else if(5===e||4===e){n?q(W+t,n):q(W+t);try{throw 4===e?new TypeError(t):new Error(t)}catch(e){}}}else C(`${W}%c${t}`,`color: ${n||"#999"};`)}t(D,"log");var X=/\b(?:append|prepend)/,F=/\s+/g,z=/^\b(?:true|false)$/i,Y=/^\d*\.?\d+$/,V=/^(?:[.-]?\d*\.?\d+|NaN)$/,U=/\b(?:intersect|hover|proximity)\b/,B=/\b(?:SCRIPT|STYLE|LINK)\b/,K=/\[(['"]?.*['"]?,?)\]/,G=/[xy]\s*|\d*\.?\d+/gi;function J(e){let t=e.replace(/\s+,/g,",").replace(/,\s+/g,",").replace(/['"]/g,N);return 91===t.charCodeAt(0)&&(/^\[\s*\[/.test(t)||/,/.test(t)&&/\]$/.test(t))&&(t=t.replace(/^\[/,N).replace(/\]$/,N)),t.split(/,|\|/)}function Z(e,t){try{const n=(t||e).replace(/\\'|'/g,(e=>"\\"===e[0]?e:'"')).replace(/\[|[^\s[\]]*|\]/g,(e=>/[[\]]/.test(e)?e:e.split(",").map((e=>e.replace(/^(\w+)$/,'"$1"').replace(/^"([\d.]+)"$/g,"$1"))).join(","))).replace(/([a-zA-Z0-9_-]+)\s*:/g,'"$1":').replace(/:\s*([$a-zA-Z_-]+)\s*([,\]}])/g,':"$1"$2').replace(/,([\]}])/g,"$1").replace(/([a-zA-Z_-]+)\s*,/g,'"$1",').replace(/([\]},\s]+)?"(true|false)"([\s,{}\]]+)/g,"$1$2$3");return JSON.parse(n)}catch(n){return D(5,"Invalid JSON expression in attribute value: "+JSON.stringify(e||t,null,2),n),t}}function _(e){return e[e.length-1]}function Q(e){return e.replace(/\s+/g," ").trim()}function ee(e){return e.replace(/\./g,"\\.").replace(/@/g,"\\@").replace(/:/g,"\\:")}function te(e){return Q(e.replace(/[\s .]+/g,".")).replace(/\s+/g," ").trim().split(/[ ,]/)}function ne(e){if(V.test(e))return"NaN"===e?NaN:+e;if(z.test(e))return"true"===e;const t=e.charCodeAt(0);return 123===t||91===t?Z(e):e}function oe(){return new Promise((e=>setTimeout((()=>e()),1)))}function se(e){return setTimeout((()=>e()),1)}function re(){return Promise.resolve()}function ie(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}function ae(){return(new Date).getTime()}function ce(e){return t=>!!t&&("string"==typeof t?t in e:t.every((t=>t in e)))}function le(e,t){return!!e&&t in e}function ue(e,n,o){return void 0!==n?($(e,n,{get:()=>o}),e):(n,o,s)=>{if(le(e,n))return;const r=t((()=>o),"get");return $(e,n,s?y(s,{get:r}):{get:r})}}function de(e){return le(e,"target")?1===e.target.length&&"body"===e.target[0]?e.target:e.target.filter(((e,t,n)=>"body"!==e&&e!==N&&-1===e.indexOf(",")&&n.indexOf(e)===t)):1===M.config.fragments.length&&"body"===M.config.fragments[0]?["body"]:[]}function fe(e){return 1===e.length&&"body"===e[0]?"body":0===e.length?null:e.join(",")}function pe(e){const t=typeof e;if("object"===t){for(const t in e)return!1;return!0}return"string"===t?void 0===e[0]:!!A(e)&&e.length>0}function he(...e){return e.join(N)}t(J,"splitAttrArrayValue"),t(Z,"attrJSON"),t(_,"last"),t(Q,"equalizeWS"),t(ee,"escSelector"),t(te,"attrValueNotation"),t(ne,"attrValueFromType"),t(oe,"onNextTickResolve"),t(se,"onNextTick"),t(re,"promiseResolve"),t(ie,"decodeEntities"),t(ae,"ts"),t(ce,"hasProps"),t(le,"hasProp"),t(ue,"defineGetter"),t(de,"targets"),t(fe,"selector"),t(pe,"isEmpty"),t(he,"glue");var me=t((function e(t=5){const n=Math.random().toString(36).slice(-t);return e.u.has(n)?e(t):(e.u.add(n),n)}),"uuid");function ge(e=2){return(t,n)=>{const o=t.length;return(o<1||t[o-1].length===e?t.push([n]):t[o-1].push(n))&&t}}function ye(e){const t=1048576,n=1073741824;return e<1024?e+" B":e<t?(e/1024).toFixed(1)+" KB":e<n?(e/t).toFixed(1)+" MB":(e/n).toFixed(1)+" GB"}function ve(e){return e[0].toLowerCase()+e.slice(1)}function be(e){return e[0].toUpperCase()+e.slice(1)}function $e(e){return/[A-Z]/.test(e)?e.replace(/(.{1})([A-Z])/g,"$1-$2").toLowerCase():e}function ke(e){return/[_-]/.test(ve(e))?e.replace(/([_-]+).{1}/g,((e,t)=>e[t.length].toUpperCase())):e}function we(e,t){const n="string"==typeof e?S().querySelectorAll(e):e,o=n.length;if(0!==o)for(let e=0;e<o&&!1!==t(n[e],e);e++);}function Ae(e,t){if(1===arguments.length)return t=>Ae(e,t);const n=t.length;if(0!==n)for(let o=0;o<n;o++)e(t[o],o,t)}function xe(e){for(const t in e)delete e[t]}function Ne(){if(M.patched)return;M.patched=!0;const e=Element.prototype.setAttribute,n=document.createElement("i");Element.prototype.setAttribute=t((function(t,o){if(t.indexOf("@")<0)return e.call(this,t,o);n.innerHTML=`<i ${t}="${o}"></i>`;const s=n.firstElementChild.getAttributeNode(t);n.firstElementChild.removeAttributeNode(s),this.setAttributeNode(s)}),"setAttribute")}function Ee(){const e=[],n=document.createElement("div");let o,s=null,r=null;const i=t((({bgColor:e,barHeight:t,speed:o,easing:s})=>{n.style.cssText=he("pointer-events:none;",`background-color:${e};`,`height:${t};`,"position:fixed;","display:block;","z-index:2147483647;","top:0;","left:0;","width:100%;","will-change:opacity,transform;",`transition:transform ${o}ms ${s};`)}),"style"),a=t((e=>100*(-1+e)),"percent"),c=t(((e,t,n)=>e<t?t:e>n?n:e),"current"),l=t((()=>r||(n.style.setProperty("transform",`translateX(${a(s||0)}%)`),r=S().appendChild(n),n)),"render"),u=t((()=>{const e=S();if(e.contains(r)){r.animate({opacity:["1","0"]},{easing:"ease-out",duration:100}).onfinish=()=>{e.removeChild(r),r=null}}else r=null}),"remove"),d=t((()=>{const t=e.shift();t&&t(d)}),"dequeue"),f=t((t=>{e.push(t),1===e.length&&d()}),"enqueue"),p=t((e=>{e=c(e,M.config.progress.minimum,1),s=1===e?null:e;const t=l();f((n=>{t.style.setProperty("transform",`translateX(${a(e)}%)`),1===e?setTimeout((()=>{u(),n()}),2*M.config.progress.speed):setTimeout(n,M.config.progress.speed)}))}),"set"),h=t((e=>{let t=s;return t?t<1?("number"!=typeof e&&(e=t>=0&&t<.2?.1:t>=.2&&t<.5?.04:t>=.5&&t<.8?.02:t>=.8&&t<.99?.005:0),t=c(t+e,0,.994),p(t)):void 0:g()}),"inc"),m=t((()=>{setTimeout((()=>{s&&(h(),m())}),M.config.progress.trickleSpeed)}),"doTrickle");function g(e){M.config.progress&&(o=setTimeout((()=>{s||p(0),M.config.progress.trickle&&m()}),e||0))}function y(e){clearTimeout(o),(e||s)&&(h(.3+.5*Math.random()),p(1))}return t(g,"start"),t(y,"done"),{start:g,done:y,style:i}}me.u=P(),t(ge,"chunk"),t(ye,"size"),t(ve,"downcase"),t(be,"upcase"),t($e,"kebabCase"),t(ke,"camelCase"),t(we,"forNode"),t(Ae,"forEach"),t(xe,"empty"),t(Ne,"patchSetAttribute"),t(Ee,"ProgressBar");var Ce,qe=Ee();function Te(e,t){const n=e.name,o=t;return t=ve(t||n),e.define=y({name:t,merge:!1,state:{},nodes:[]},e.define),t!==e.define.name&&(t=ke(e.define.name)),n!==o&&/^[A-Z]|[_-]/.test(e.define.name)&&D(3,[`Component identifer name "${e.define.name}" must use camelCase format.`,`The identifer has been converted to "${t}"`]),t}function Se(e,t=!1){const{n:n}=M.components;for(const o in e){const s=e[o],r=t?o:Te(s,o);n.has(r)||(n.set(r,s),D(1,`Component ${s.name} registered using id: ${r}`,"#F48FB1"))}M.config.components||(M.config.components=!0)}function Oe(e){for(const t of["hover","intersect","proximity","progress"])le(e,t)&&(!1===e[t]?M.config[t]=!1:"object"==typeof e[t]&&y(M.config[t],e[t]),delete e[t]);return e}function Le(e,t){const n=`:not([${e}${t}=false]):not([${e}link])`;switch(t.charCodeAt(0)){case 104:return`${n}:not([${e}proximity]):not([${e}intersect])`;case 105:return`${n}:not([${e}hover]):not([${e}proximity])`;case 112:return`${n}:not([${e}intersect]):not([${e}hover])`}}function Pe(e,t,n){if("eval"in e)if(e.eval){if("object"==typeof e.eval){const t=y(M.config.eval,e.eval);M.eval=!!(t.link||t.meta||t.script||t.style)}}else M.eval=!1;return e=>{if(!1===M.eval||!1===M.config.eval[e])return`${e}[${t}eval]:${n}`;if(!0===M.config.eval[e])return`${e}:${n}`;const o="link"===e?`${e}[rel=stylesheet]:${n}`:"script"===e?`${e}:${n}:not([${t}eval=hydrate])`:`${e}:${n}`;return null===M.config.eval[e]?o:A(M.config.eval[e])?M.config.eval[e].length>0?M.config.eval[e].map((e=>`${e}:${n}`)).join(","):(D(3,`Missing eval ${e} value, SPX will use defaults`),o):void D(4,`Invalid eval ${e} value, expected boolean or array`)}}function Re(e){const t=[];if(!("fragments"in e&&A(e.fragments)&&e.fragments.length>0))return["body"];for(const n of e.fragments){const e=n.charCodeAt(0);46!==e&&91!==e?35===e?t.push(n.trim()):t.push(`#${n.trim()}`):D(3,[`Invalid fragment selector "${n}" provided. Fragments must be id annotated values.`,"Use spx-target attributes for additional fragment selections."])}return t}function Ie(e=L()){"logLevel"in e&&(M.logLevel=e.logLevel,1===M.logLevel&&D(1,"Verbose Logging")),Ne(),k(M,{ready:{get:()=>"complete"===document.readyState},types:{get:()=>L({INITIAL:0,PREFETCH:1,FETCH:2,PRELOAD:3,REVERSE:4,POPSTATE:5,VISIT:6,HYDRATE:7,CAPTURE:8,RELOAD:9,HOVER:10,INTERSECT:11,PROXIMITY:12})}}),"components"in e&&(Se(e.components),delete e.components),y(M.config,Oe(e));const t=M.config.schema,n="spx"===t?"spx":t.endsWith("-")?t:null===t?N:`${t}-`,o=`:not([${n}disable]):not([href^=\\#])`,s=`not([${n}eval=false])`,r=Pe(e,n,s);M.config.fragments=Re(e),M.config.schema=n,M.config.index=null,M.memory.bytes=0,M.memory.visits=0,M.memory.limit=M.config.maxCache,y(M.qs,{B:new RegExp(`^href|${n}(hydrate|append|prepend|target|progress|threshold|scroll|position|proximity|hover|cache|history)$`,"i"),M:new RegExp(`${n}(?:node|bind|component)|@[a-z]|[a-z]:[a-z]`,"i"),C:new RegExp(`^${n}[a-zA-Z0-9-]+:`,"i"),r:`${n}target`,v:`${n}fragment`,w:`[${n}fragment]`,x:`[${n}target]:not([${n}target=false])`,m:`${n}morph`,D:`${n}eval`,E:`[${n}intersect]${Le(n,"intersect")}`,N:`[${n}track]:not([${n}track=false])`,s:`${n}component`,y:`${n}node`,z:`${n}bind`,a:"data-spx",F:M.config.annotate?`a[${n}link]${o}`:`a${o}`,G:r("script"),H:r("style"),I:r("link"),J:r("meta"),O:`script[${n}eval=hydrate]:${s}`,P:`link[rel=stylesheet][href*=\\.css]:${s},script[src*=\\.js]:${s}`,t:`${n}data:`,A:`a[${n}proximity]${o}${Le(n,"proximity")}`,K:`a${o}${Le(n,"intersect")}`,p:!1!==M.config.hover&&"href"===M.config.hover.trigger?`a${o}${Le(n,"hover")}`:`a[${n}hover]${o}${Le(n,"hover")}`}),qe.style(M.config.progress)}function je(e){return(new DOMParser).parseFromString(e,"text/html")}function He(e){return(e||document).documentElement.outerHTML}function Me(e){const t=e.indexOf("<title");if(-1===t)return N;if(e.slice(0,t).indexOf("<svg")>-1)return N;const n=e.indexOf(">",t)+1,o=e.indexOf("</title",n);return ie(e.slice(n,o).trim())}function We(e,...t){const n="before:cache"===e;n&&(t[1]=je(t[1]));let o=!0;return Ae((e=>{const s=e.apply(null,t);n?s instanceof Document?o=s.documentElement.outerHTML:"string"!=typeof o&&(o=!1!==s):o=!1!==s}),M.events[e]||[]),o}function De(e,t,n){return e in M.events||(M.events[e]=[]),M.events[e].push(n?t.bind(n):t)-1}function Xe(e,t){if(e in M.events){const n=M.events[e];if(n&&"number"==typeof t)n.splice(t,1),D(2,`Removed ${e} event listener (id: ${t})`),0===n.length&&delete M.events[e];else{const o=[];if(n&&t)for(let s=0,r=n.length;s<r;s++)n[s]!==t?o.push(n[s]):"x"!==e&&D(2,`Removed ${e} event listener (id: ${s})`);o.length?M.events[e]=o:delete M.events[e]}}else D(3,`There are no ${e} event listeners`);return this}function Fe(e,{method:t="GET",body:n=null,headers:o=null,type:s="text"}={}){return new Promise((function(r,i){const a=new H;if(a.key=e,a.responseType=s,a.open(t,e),a.setRequestHeader("spx-request","true"),null!==o)for(const e in o)a.setRequestHeader(e,o[e]);a.onloadstart=function(){H.e.set(this.key,a)},a.onload=function(){r(this.response)},a.onerror=function(){i(this.statusText)},a.onabort=function(){delete H.f[this.key],H.j.delete(this.key),H.e.delete(this.key)},a.onloadend=function(e){H.e.delete(this.key),M.memory.bytes=M.memory.bytes+e.loaded,M.memory.visits=M.memory.visits+1},a.send(n)}))}function ze(e){return!(e in H.f)||(clearTimeout(H.f[e]),delete H.f[e])}function Ye(e,t,n){e in H.f||_n(e)||(H.f[e]=setTimeout(t,n))}function Ve(e){for(const[t,n]of H.e)e!==t&&(n.abort(),D(3,`Pending request aborted: ${t}`))}function Ue(e){if(null!==M.config.preload){if(A(M.config.preload)){const e=M.config.preload.filter((e=>{const t=fo(e,3);return t.key!==e&&Ge(Fn(t))}));return Promise.allSettled(e)}if("object"==typeof M.config.preload&&le(M.config.preload,e.key)){const t=M.config.preload[e.key].map((e=>Ge(Fn(fo(e,3)))));return Promise.allSettled(t)}}}async function Be(e){if(e.rev===e.key)return;const t=Fn(fo(e.rev,4));await oe(),Ge(t).then((t=>{t?D(2,`Reverse fetch completed: ${t.rev}`):D(3,`Reverse fetch failed: ${e.rev}`)}))}async function Ke(e){if(!H.j.has(e.key))return e;const t=await H.j.get(e.key);return H.j.delete(e.key),delete H.f[e.key],Vn(e,t)}async function Ge(e){return H.e.has(e.key)&&7!==e.type?(4===e.type&&H.e.has(e.rev)?(H.e.get(e.rev).abort(),D(3,`Request aborted: ${e.rev}`)):D(3,`Request in transit: ${e.key}`),!1):We("fetch",e)?(H.j.set(e.key,Fe(e.key)),Ke(e)):(D(3,`Request cancelled via dispatched event: ${e.key}`),!1)}function Je(e,t){if(!1===t(e))return;let n,o;for(e.firstElementChild&&(o=0,n=e.children[o]);n;)n&&Je(n,t),n=e.children[++o]}function Ze(e,t){return`on${e}`in t||(D(5,[`Invalid event name "${e}" provided. No such event exists in the DOM API.`,"Only known event listeners can be attached."],t),!1)}function _e(e,n,o){const s=e[n.method];return t((function(t){n.params&&(le(t,"attrs")||ue(t,"attrs",L()),y(t.attrs,n.params)),s.call(e,t)}),"handle")}function Qe(e,t){t.attached&&(t.listener.abort(),t.listener=new AbortController,t.options.signal=t.listener.signal,t.attached=!1,M.components.b.delete(t.dom),D(1,[`Detached ${t.key} ${t.eventName} event from ${t.method}() method in component`,`${e.scope.define.name}: ${e.scope.key}`]))}function et(e,t,n){n.attached||(n.method in e?(bt(t.attributes,n),n.isWindow?Ze(n.eventName,window)&&addEventListener(n.eventName,_e(e,n)):Ze(n.eventName,t)&&(t.addEventListener(n.eventName,_e(e,n),n.options),M.components.b.set(n.dom,t)),n.attached=!0,D(1,[`Attached ${n.key} ${n.eventName} event to ${n.method}() method in component`,`${e.scope.define.name}: ${e.scope.key}`])):D(3,`Undefined callback method: ${e.scope.define.name}.${n.method}()`))}t(Te,"getComponentId"),t(Se,"registerComponents"),t(Oe,"observers"),t(Le,"not"),t(Pe,"evaluators"),t(Re,"fragments"),t(Ie,"configure"),t(je,"parse"),t(He,"takeSnapshot"),t(Me,"getTitle"),t(We,"emit"),t(De,"on"),t(Xe,"off"),t(Fe,"request"),t(ze,"cleanup"),t(Ye,"throttle"),t(Ve,"cancel"),t(Ue,"preload"),t(Be,"reverse"),t(Ke,"wait"),t(Ge,"fetch"),t(Je,"walkElements"),t(Ze,"isValidEvent"),t(_e,"eventAttrs"),t(Qe,"removeEvent"),t(et,"addEvent");var tt=(t(Ce=class{constructor(e){this.state=L();const{b:t}=M.components,{scope:n}=k(this,{scope:{get:()=>tt.scopes.get(e)},dom:{get:()=>t.get(n.dom)}}),o=`${M.config.schema}${n.instanceOf}`;if(this.state=new Proxy(L(),{set:(e,s,r)=>{const i=n.define.state[s],a="object"==typeof r||A(r)?JSON.stringify(r):`${r}`;if("object"==typeof i&&le(i,"persist")&&i.persist?e[s]=n.state[s]=r:e[s]=r,a.trim()!==N&&this.dom){const e=this.dom.hasAttribute(`${o}:${s}`)?`${o}:${s}`:`${o}:${$e(s)}`;a!==this.dom.getAttribute(`${o}:${s}`)&&this.dom.setAttribute(e,a)}if(s in n.binds){const{binds:e}=n;for(const n in e[s])e[s][n].value=a,t.has(e[s][n].dom)&&(t.get(e[s][n].dom).innerText=a)}return!0}}),pe(n.state))for(const e in n.define.state){const t=n.define.state[e];let o,s;"object"==typeof t?(o=t.typeof,s=t.default):o=t,o===String?this.state[e]=s||N:o===Boolean?this.state[e]="boolean"==typeof s?s:"true"===s||!1:o===Number?this.state[e]=s?Number(s):0:o===Array?this.state[e]=s||[]:o===Object&&(this.state[e]=s||{}),n.state[e]=this.state[e]}else for(const e in n.define.state){if(!(e in n.state))if("object"==typeof n.define.state[e])n.state[e]=n.define.state[e].default;else switch(n.define.state[e]){case String:n.state[e]=N;break;case Boolean:n.state[e]=!1;break;case Number:n.state[e]=0;break;case Object:n.state[e]={};break;case Array:n.state[e]=[]}const t=n.define.state[e],s=$e(e);let r,i,a=this.dom.hasAttribute(`${o}:${s}`)?this.dom.getAttribute(`${o}:${s}`):this.dom.getAttribute(`${o}:${e}`);const c=null!==a&&a!==N;"object"==typeof t?(r=t.typeof,i=c,c||(a=t.default)):r=t,`has${be(e)}`in this.state||$(this.state,`has${be(e)}`,{get:()=>c}),"string"==typeof a&&a.startsWith("window.")?this.state[e]=window[a.slice(7)]:r===String?this.state[e]=a||N:r===Boolean?this.state[e]="boolean"==typeof a?a:"true"===a||!1:r===Number?this.state[e]=a?Number(a):0:r===Array?this.state[e]=c?Z(a):i?a:[]:r===Object&&(this.state[e]=c?Z(a):i?a:{}),n.state[e]=this.state[e]}}get html(){return document.documentElement}},"Component"),Ce.scopes=I(),Ce);function nt(e,t,n,o){let s,r,i;for(e.firstElementChild&&(s=0,r=e.children[s],i=t.children[s]);r;)r&&(o.has(i)?(ot(r,n,!0),o.delete(i)):i.hasAttribute(M.qs.a)&&r.setAttribute(M.qs.a,i.getAttribute(M.qs.a)),nt(r,i,n,o)),r=e.children[++s],i=t.children[s]}function ot(e,t,n=!1){const{b:o}=M.components;Je(e,(e=>{if("false"!==e.getAttribute("spx-snapshot")&&$t(e.attributes)&&!e.hasAttribute(M.qs.a)){const s=t.shift();if(o.has(s)){const r=e.getAttribute(M.qs.a),i=o.get(s).getAttribute(M.qs.a);if(r!==i&&e.setAttribute(M.qs.a,i),0===t.length)return!1===n&&(Bn(e.ownerDocument.documentElement.outerHTML),D(1,`Snapshot ${M.page.key} updated for: ${M.page.snap}`)),!1}}}))}function st(e,t){const{page:n,dom:o}=Kn(M.page.key),s=114===e.charCodeAt(0)?"removed":"appended";o.head.contains(t)?(o.head[e](t),M.snaps[n.snap]=o.documentElement.outerHTML,D(1,`Snapshot record was updated. Node ${s} from <head>`,t)):D(3,"Node does not exists in snapshot record, no mutation applied",t)}t(nt,"patchSnap"),t(ot,"morphSnap"),t(st,"morphHead");var rt,it={};function at(){return y(L(),{page:y(L(),M.page)})}function ct(){for(const e in M.components.l)delete M.components.l[e];for(const e of M.components.h.values())for(const t in e.scope.events)Qe(e,e.scope.events[t]);M.components.b.clear(),M.components.h.clear(),M.components.k.clear(),D(2,"Component instances were disconnected")}function lt(e){const{h:n}=M.components,o=at(),s=[];for(const[r,i,a]of e){const e=n.get(r),{scope:c}=e,l=4===c.mounted?"unmount":"mount",u=t((async()=>{try{if(!c.connected&&a&&1===c.mounted)await e[i](o),await e[a](o),c.connected=!0;else if(await e[i](o),4===c.mounted&&c.define.merge){const e=Gn(M.page.rev);e.querySelector(`[${M.qs.a}="${c.ref}"]`).outerHTML=c.snapshot,Bn(e.documentElement.outerHTML,M.page.rev)}return void(e.scope.mounted=4===c.mounted?5:3)}catch(e){}return D(3,`Component to failed to ${l}: ${c.instanceOf} (${r})`),Promise.reject(r)}),"seq");s.push(re().then(u))}return Promise.race(s)}function ut(){const{k:e,h:t}=M.components,n=[];for(const o of e){const e=t.get(o),{scope:s}=e,r=4===s.mounted?"unmount":"onmount";e&&r in e&&("onmount"===r&&"connect"in e&&!1===s.connected?n.push([o,"connect",r]):3!==s.mounted&&5!==s.mounted&&n.push([o,r]))}n.length>0&<(n).catch((n=>{t.get(n).scope.mounted=5,e.delete(n)}))}function dt(){M.config.components&&(M.observe.components||(0===M.page.type?Ot():rt?ht(rt).then(ut).then(Lt):ut(),M.observe.components=!0))}function ft(){M.observe.components&&(ut(),M.observe.components=!1)}function pt(e,t){const n=L(),{b:o}=M.components;for(const e in t)t[e].schema in n||(n[t[e].schema]=[]),n[t[e].schema].push(t[e].dom);for(const t in n){if(`${t}s`in e)continue;if(t in e){e[t]=n[t];continue}let s=n[t];s.length>1?k(e,{[t]:{get:()=>o.get(s[0]),set(e){s=e}},[`${t}s`]:{get:()=>s.map((e=>o.get(e)))}}):$(e,t,{get:()=>o.get(s[0]),set(e){s=e}})}}function ht({q:e,o:t,c:n,m:o}){const s=4===M.page.type,r=!s||0===M.page.type,i=[],{b:a,k:c,h:l,n:u,l:d}=M.components;for(const n in e)for(const f of e[n]){if(null===f.instanceOf){if(!(n in t))continue;f.instanceOf=t[n]}let e,p;if(5!==f.mounted||null===o&&!s)e=u.get(f.instanceOf),tt.scopes.set(f.key,ue(f,"define",e.define)),p=new e(f.key);else{const t=Jn();if(null!==f.alias&&f.alias in t?(p=t[f.alias][0],e=p.scope.define):f.instanceOf in t&&1===t[f.instanceOf].length&&(p=t[f.instanceOf][0],e=p.scope.define),!p){D(3,"Increment component instance failed as instance was undefined",f);continue}f.key=p.scope.key,f.ref=p.scope.ref,f.connected=p.scope.connected,f.mounted=p.scope.mounted=3}if(pe(f.nodes)||pt(p,f.nodes),null===o&&"nodes"in e&&e.nodes.length>0)for(const t of e.nodes)ue(p,`has${be(t)}Node`,`${t}Node`in p);for(const e in f.events){let t;null!==o&&3===f.mounted?(t=p.scope.events[e]=f.events[e],d[e]=f.key):t=f.events[e],et(p,a.get(t.dom),t)}if(null===o||(null!==o||s)&&2===f.mounted){c.add(f.key),l.set(f.key,p),1===M.logLevel&&D(1,`Component ${f.define.name} (connect) mounted: ${f.key}`,"#6DD093");let e=-1;"connect"in p&&(i.push([f.key,"connect"]),r&&(p.scope.mounted=1,e=i.length-1)),"onmount"in p&&(e>-1?i[e].push("onmount"):i.push([f.key,"onmount"]))}}return r&&n.length>0&&(Yn("components",x(c)),se((()=>ot(M.snapDom.body,n)))),i.length>0?lt(i):Promise.resolve()}function mt(){const e=M.config.fragments,t=1===e.length&&"body"===e[0]?M.qs.w:`${e.join()},${M.qs.w}`;S().querySelectorAll(t).forEach((e=>{let t=e.getAttribute(M.qs.v);null!==t?(t=t.trim(),e.id===N||"true"!==t&&t!==N?M.fragments.set(`${e.nodeName.toLowerCase()}[${M.qs.v}="${t}"]`,e):M.fragments.set(`#${e.id}`,e)):M.fragments.set(`#${e.id}`,e)})),Yn("fragments",x(M.fragments.keys()))}function gt(e){if(6!==e.type){if("body"===e.selector||null===e.selector)return;se((()=>{const t=Gn(e.snap),n=t.body.querySelectorAll(M.qs.x),o=S().querySelectorAll(M.qs.x);we(n,((t,n)=>{if(yt(t))D(3,"The fragment or target is a decedent of an element which morphs",t);else{if(t.hasAttribute("id")){if(t.id.startsWith("t."))return}else t.setAttribute("id",`t.${me()}`),null!==o&&o[n].setAttribute("id",`t.${me()}`);e.fragments.push(t.id)}})),Bn(t.documentElement.outerHTML,e.snap)}))}}function yt(e){for(const[t,n]of M.fragments){if(t===e.id)return!0;if(n.contains(e))return!0}return!1}function vt(e){return e.trim().replace(/\s+/," ").split(/[|, ]/).map(ke)}function bt(e,t){for(let n=0,o=e.length;n<o;n++){const{name:o,value:s}=e[n];if(M.qs.C.test(o)&&(!o.startsWith(M.qs.t)&&s)){const e=o.slice(M.config.schema.length).split(":").pop();null===t.params&&(t.params=L()),e in t.params||(t.params[e]=ne(s))}}}function $t(e){if("string"==typeof e)return e.indexOf("@")>-1||e===M.qs.s||e===M.qs.y||e===M.qs.z;for(let t=e.length-1;t>=0;t--)if($t(e[t].name))return!0;return!1}function kt(e,t){$t(e.attributes)&&(e.hasAttribute(M.qs.s)?St(e,e.getAttribute(M.qs.s),t):Tt(e,t,null,null))}function wt(e=null){return L({o:L(),q:L(),d:null,c:[],m:e,Q:e?L():null})}function At(e,{q:t,o:n}){return e in t?_(e in n?t[n[e]]:t[e]):e in n?_(t[n[e]]):(t[e]=[Nt(e)],t[e][0])}function xt(e,t,n){M.components.l[n]=t;const o=e.getAttribute(M.qs.a),s=o?`${o},${n}`:n;return e.setAttribute(M.qs.a,s),n}function Nt(e,t,n){const{n:o}=M.components,s=me(),r=L({key:s,mounted:5,connected:!1,snapshot:null,ref:`c.${s}`,state:L(),nodes:L(),events:L(),binds:L()});return t&&(xt(t,s,r.ref),r.dom=n.d,r.mounted=2,r.inFragment=yt(t),t.hasAttribute("id")&&(r.alias=ke(t.id.trim()))),o.has(e)?(r.instanceOf=e,r.alias?o.has(r.alias)?D(5,[`Component alias "${r.alias}" matches a component identifer in the registry.`,"An alias reference must be unique and cannot match component names."]):n.o[r.alias]=e:r.alias=null):(r.alias=e||null,r.instanceOf=null,2===r.mounted&&(n.o[r.alias]=null)),r}function Et(e,t,n,o){const s=L(),r=n.indexOf("{"),i=t.slice(M.config.schema.length),a=new AbortController;s.key=`e.${me()}`,s.dom=`${o.d}`,s.isWindow=i.startsWith("window:"),s.eventName=s.isWindow?i.slice(7):i,s.attached=!1,s.params=null,s.options={signal:a.signal};let c=n;if(r>-1){const e=n.slice(r,n.lastIndexOf("}",r)).match(/(passive|once)/g);null!==e&&(e.indexOf("once")>-1&&(s.options.once=!0),e.indexOf("passive")>-1&&(s.options.passive=!0)),c=n.slice(0,r)}const l=te(c);l.length>1&&D(3,`No more than 1 DOM Event listener method allowed in value: ${n}`);const[u,d]=l[0].split("."),f=At(u,o);s.listener=a,s.method=d.trim(),f.events[s.key]=s,xt(e,f.key,s.key)}function Ct(e,t,n){for(const o of te(t)){const[t,s]=o.split("."),r=At(t,n),i=xt(e,r.key,`n.${me()}`);r.nodes[i]=L({key:i,keyProp:s,dom:n.d,schema:`${s}Node`,isChild:2===r.mounted||3===r.mounted})}}function qt(e,t,n){for(const o of te(t)){const[t,s]=o.split("."),r=At(t,n),i=xt(e,r.key,`b.${me()}`);s in r.binds||(r.binds[s]=L()),r.binds[s][i]=L({key:i,stateKey:s,value:e.innerText,dom:n.d,stateAttr:`${M.config.schema}${t}:${s}`,selector:`[${M.qs.a}*=${ee(i)}]`,isChild:2===r.mounted||3===r.mounted})}}function Tt(e,t,n,o){null===n&&null===o&&(t.d=me(),t.c.push(t.d),M.components.b.set(t.d,e));for(let s=e.attributes.length-1;s>=0;s--){const{name:r,value:i}=e.attributes[s];if(n){let e=`${M.config.schema}${n}:`;o&&!r.startsWith(e)&&(e=`${M.config.schema}${o}:`),r.startsWith(e)&&(At(n,t).state[ke(r.slice(e.length))]=i)}r.indexOf("@")>-1?Et(e,r,i,t):r===M.qs.z?qt(e,i,t):r===M.qs.y&&Ct(e,i,t)}}function St(e,t,n){const{n:o,b:s}=M.components,{q:r,o:i}=n,a=e.hasAttribute("id")?e.id.trim():null;n.d=me(),n.c.push(n.d),s.set(n.d,e);for(const s of vt(t))if(o.has(s)){let t;s in r?(t=_(r[s]),5===t.mounted?(xt(e,t.key,t.ref),t.dom=n.d,t.mounted=2,t.inFragment=yt(e)):r[s].push(Nt(s,e,n))):r[s]=[Nt(s,e,n)],t=_(r[s]),a&&!(a in i)&&(i[a]=s),Tt(e,n,s,t.alias)}else D(5,`Component does not exist in registry: ${s}`)}function Ot(e){const t=wt();if(e){if(e instanceof Set){for(const n of e)kt(n,t);return e.clear(),t}return kt(e,t),t}Je(S(),(e=>kt(e,t))),pe(t.q)||ht(t)}function Lt(){se((()=>{rt=void 0}))}function Pt(e,t){const{l:n,k:o,b:s}=M.components;for(const r of t){const t=n[r];if(!t)continue;const i=r.charCodeAt(0),{scope:a}=t;if(99===i)o.add(a.key),s.set(a.dom,e),a.mounted=2,1===M.logLevel&&D(1,`Component ${a.define.name} mounted: ${a.key}`,"#6DD093");else if(101===i)et(t,e,a.events[r]);else if(110===i)s.set(a.nodes[r].dom,e);else if(98===i){const{binds:t}=a;for(const n in t)if(r in t[n]){e.innerText=t[n][r].value,s.set(t[n][r].dom,e);break}}}}function Rt(e,t,n){const{l:o,b:s,k:r}=M.components;for(const i of t){const t=o[i];if(!t)continue;const a=i.charCodeAt(0),{scope:c}=t;if(99===a){r.delete(i),s.delete(t.scope.dom),c.define.merge&&(c.snapshot=e.outerHTML,D(1,`Component ${c.define.name} snapshot: ${c.key}`,"#999"));for(const e in c.nodes)s.delete(c.nodes[e].dom);for(const e in c.binds)for(const t in c.binds[e])s.delete(c.binds[e][t].dom);for(const e in c.events)Qe(t,c.events[e]);1===M.logLevel&&D(1,`Component ${c.define.name} unmounted: ${c.key}`,"#7b97ca"),c.mounted=4}else if(101===a)Qe(t,c.events[i]);else if(110===a){const t=c.nodes[i];s.delete(t.dom),n&&e.isEqualNode(n)&&(xt(e,c.key,i),rt.c.push(t.dom))}else if(98===a)for(const t in c.binds)if(i in c.binds[t]){s.delete(c.binds[t][i].dom),n&&e.isEqualNode(n)&&(xt(e,c.key,i),rt.c.push(c.binds[t][i].dom));break}}}function It(e){1!==e.nodeType&&11!==e.nodeType||e.hasAttribute(M.qs.a)&&Rt(e,e.getAttribute(M.qs.a).split(","))}function jt(e){e.hasAttribute(M.qs.a)?Pt(e,e.getAttribute(M.qs.a).split(",")):$t(e.attributes)&&(rt?rt.m=e:rt=wt(e),kt(e,rt))}function Ht(e,t,n,o){n&&(n=n.split(",")),o&&(o=o.split(",")),n&&o?(Rt(e,n),Pt(e,o)):!n&&o?Pt(e,o):(rt?rt.m=e:rt=wt(e),n&&!o&&Rt(e,n,t),$t(t.attributes)&&kt(e,rt))}function Mt(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,N):e.removeAttribute(n))}function Wt(e,t){if(11===t.nodeType||11===e.nodeType)return;const n=t.attributes,o=e.getAttribute(M.qs.a),s=t.getAttribute(M.qs.a);let r,i,a,c,l,u=!1;for(let t=n.length-1;t>=0;t--)r=n[t],i=r.name,c=r.value,a=r.namespaceURI,a?(i=r.localName||i,l=e.getAttributeNS(a,i),l!==c&&("xmlns"===r.prefix&&(i=r.name),e.setAttributeNS(a,i,c))):(l=e.getAttribute(i),l!==c&&(e.setAttribute(i,c),o||s||u||(u=$t(i))));const d=e.attributes;for(let n=d.length-1;n>=0;n--)r=d[n],i=r.name,c=r.value,a=r.namespaceURI,a?(i=r.localName||i,t.hasAttributeNS(a,i)||e.removeAttributeNS(a,i)):t.hasAttribute(i)||e.removeAttribute(i);(o||s||u)&&Ht(e,t,o,s)}function Dt(e,t){let n=e.parentNode;if(n){let o=n.nodeName.toUpperCase();"OPTGROUP"===o&&(n=n.parentNode,o=n&&n.nodeName.toUpperCase()),"SELECT"!==o||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}Mt(e,t,"selected")}function Xt(e,t){Mt(e,t,"checked"),Mt(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")}function Ft(e,t){const{value:n}=t;e.value!==n&&(e.value=n);const{firstChild:o}=e;if(o){const{nodeValue:t}=o;if(t===n||!n&&t===e.placeholder)return;o.nodeValue=n}}function zt(e,t){if(!t.hasAttribute("multiple")){let t,n,o=0,s=-1,r=e.firstElementChild;for(;r;)if(n=r.nodeName&&r.nodeName.toUpperCase(),"OPTGROUP"===n)t=r,r=t.firstElementChild;else{if("OPTION"===n){if(r.hasAttribute("selected")){s=o;break}o++}r=r.nextElementSibling,!r&&t&&(r=t.nextElementSibling,t=null)}e.selectedIndex=s}}function Yt(e,t){return t&&"http://www.w3.org/1999/xhtml"!==t?document.createElementNS(t,e):document.createElement(e)}function Vt(e,t){if(e===t)return!0;const n=e.charCodeAt(0),o=t.charCodeAt(0);return n<=90&&o>=97?e===t.toUpperCase():o<=90&&n>=97&&t===e.toUpperCase()}function Ut(e,t){switch(e.nodeName){case"INPUT":Xt(e,t);break;case"OPTION":Dt(e,t);break;case"SELECT":zt(e,t);break;case"TEXTAREA":Ft(e,t)}}function Bt(e){return e&&"getAttribute"in e?e.getAttribute("id"):void 0}function Kt(e,t){let n,o=e.firstChild;for(;o;)n=o.nextSibling,t.appendChild(o),o=n;return t}function Gt(e,t,n,o=!0){It(e),t&&t.removeChild(e),_t(e,o,n)}function Jt(e,t,n){let o,s,r,i,a,c,l=t.firstChild,u=e.firstChild;e:for(;l;){for(o=Bt(l),s=l.nextSibling;u;){if(a=u.nextSibling,l.isEqualNode(u)){l=s,u=a;continue e}let t;if(r=Bt(u),i=u.nodeType,i===l.nodeType&&(1===i?(o?o!==r&&((c=n.g.get(o))?a&&a.isEqualNode(c)?t=!1:(e.insertBefore(c,u),r?n.i.add(r):Gt(u,e,n),u=c,r=Bt(u)):t=!1):r&&(t=!1),t=!1!==t&&Vt(u.nodeName,l.nodeName),t&&Zt(u,l,n)):3!==i&&8!==i||(t=!0,u.nodeValue!==l.nodeValue&&(u.nodeValue=l.nodeValue))),t){l=s,u=a;continue e}r?n.i.add(r):Gt(u,e,n),u=a}o&&(c=n.g.get(o))&&Vt(c.nodeName,l.nodeName)?(e.appendChild(c),Zt(c,l,n)):(l.actualize&&(l=l.actualize(e.ownerDocument||document)),e.appendChild(l),Qt(l,n)),l=s,u=a}en(e,u,r,n),Ut(e,t)}function Zt(e,t,n){const o=Bt(t);if(o&&n.g.delete(o),e.isEqualNode(t))return;const s=e.getAttribute(M.qs.m);"false"!==s&&("children"!==s&&Wt(e,t),"TEXTAREA"!==e.nodeName?Jt(e,t,n):Ft(e,t))}function _t(e,t,n){if(1!==e.nodeType)return;let o=e.firstChild;for(;o;){let e;t&&(e=Bt(o))?n.i.add(e):(It(o),o.firstChild&&_t(o,t,n)),o=o.nextSibling}}function Qt(e,t){1!==e.nodeType&&11!==e.nodeType||jt(e);let n=e.firstChild;for(;n;){const e=n.nextSibling,o=Bt(n);if(o){const e=t.g.get(o);e&&Vt(n.nodeName,e.nodeName)?(n.parentNode.replaceChild(e,n),Zt(e,n,t)):Qt(n,t)}else Qt(n,t);n=e}}function en(e,t,n,o){for(;t;){const s=t.nextSibling;(n=Bt(t))?o.i.add(n):Gt(t,e,o),t=s}}function tn(e,t){if(1===e.nodeType||11===e.nodeType){let n=e.firstChild;for(;n;){const e=Bt(n);e&&t.g.set(e,n),tn(n,t),n=n.nextSibling}}}function nn(e,t){let n=t.cloneNode(!0);const o=L({i:P(),g:I()});11===n.nodeType&&(n=n.firstElementChild),tn(e,o);let s=e;const r=s.nodeType,i=n.nodeType;if(1===r)1===i?Vt(e.nodeName,n.nodeName)||(It(e),s=Kt(e,Yt(n.nodeName,n.namespaceURI))):s=n;else if(3===r||8===r){if(i===r)return s.nodeValue!==n.nodeValue&&(s.nodeValue=n.nodeValue),s;s=n}if(s.isEqualNode(n))It(e);else{if(n.isEqualNode(s))return s;if(Zt(s,n,o),o.i.size>0)for(const e of o.i)if(o.g.has(e)){const t=o.g.get(e);Gt(t,t.parentNode,o,!1)}}return s!==e&&e.parentNode&&(s.actualize&&(s=s.actualize(e.ownerDocument||document)),e.parentNode.replaceChild(s,e)),o.g.clear(),o.i.clear(),s}function on(e,t){if(!(e instanceof Element))return!1;const n=e.closest(t);return!(!n||"A"!==n.tagName)&&n}function sn(e){if("A"!==e.nodeName)return!1;const t=e.getAttribute("href");return!!t&&(!!io(t)&&!1===_n(co(t)))}function rn(e,t){const n=[];return we(e,(e=>{if("A"!==e.nodeName){we(e.querySelectorAll(t),(e=>{sn(e)&&n.push(e)}))}else if(e.hasAttribute("href")){const{href:t}=e;io(t)&&_n(co(t))&&n.push(e)}})),n}((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(it,{connect:()=>dt,disconnect:()=>ft,hook:()=>ut,hookArguments:()=>at,mount:()=>lt,teardown:()=>ct}),t(at,"hookArguments"),t(ct,"teardown"),t(lt,"mount"),t(ut,"hook"),t(dt,"connect"),t(ft,"disconnect"),t(pt,"defineNodes"),t(ht,"setInstances"),t(mt,"connect"),t(gt,"setFragmentElements"),t(yt,"contains"),t(vt,"getComponentValues"),t(bt,"getEventParams"),t($t,"isDirective"),t(kt,"walkNode"),t(wt,"getContext"),t(At,"getScope"),t(xt,"setRefs"),t(Nt,"setScope"),t(Et,"setEvent"),t(Ct,"setNodes"),t(qt,"setBinds"),t(Tt,"setAttrs"),t(St,"setComponent"),t(Ot,"getComponents"),t(Lt,"resetContext"),t(Pt,"connect"),t(Rt,"disconnect"),t(It,"removeNode"),t(jt,"addedNode"),t(Ht,"updateNode"),t(Mt,"setBooleanAttribute"),t(Wt,"morphAttributes"),t(Dt,"option"),t(Xt,"input"),t(Ft,"textarea"),t(zt,"select"),t(Yt,"createElementNS"),t(Vt,"matchName"),t(Ut,"formNodes"),t(Bt,"getKey"),t(Kt,"moveChildren"),t(Gt,"removeNode"),t(Jt,"morphChildren"),t(Zt,"morphElement"),t(_t,"walkNodes"),t(Qt,"addedNode"),t(en,"cleanNode"),t(tn,"indexNode"),t(nn,"morph"),t(on,"getLink"),t(sn,"canFetch"),t(rn,"getNodeTargets");var an,cn=t((e=>{const t=[];return we(e,(e=>{sn(e)&&t.push(e)})),t}),"getTargets");function ln(e){const t=on(e.target,M.qs.p);if(!t)return;const n=fo(t,10);if(_n(n.key))return;if(n.key in H.f)return;t.addEventListener(`${m}leave`,un,{once:!0});const o=Fn(n),s=o.threshold||M.config.hover.threshold;Ye(n.key,(function(){We("prefetch",t,n)&&Ge(o).then((function(){delete H.f[n.key],fn(t)}))}),s)}function un(e){const t=on(e.target,M.qs.p);t&&ze(co(t.href))}function dn(e){e.addEventListener(`${m}enter`,ln)}function fn(e){e.removeEventListener(`${m}enter`,ln),e.removeEventListener(`${m}leave`,un)}function pn(){M.config.hover&&!M.observe.hover&&(Ae(dn,cn(M.qs.p)),M.observe.hover=!0)}function hn(){M.observe.hover&&(Ae(fn,cn(M.qs.p)),M.observe.hover=!1)}async function mn(e){if(e.isIntersecting){const t=fo(e.target,11);if(!We("prefetch",e.target,t))return an.unobserve(e.target);await Ge(Fn(t))?an.unobserve(e.target):(D(3,`Prefetch will retry at next intersect for: ${t.key}`),an.observe(e.target))}}function gn(){if(!M.config.intersect||M.observe.intersect)return;an||(an=new IntersectionObserver(Ae(mn),M.config.intersect));Ae((e=>an.observe(e)))(rn(M.qs.E,M.qs.K)),M.observe.intersect=!0}function yn(){M.observe.intersect&&(an.disconnect(),M.observe.intersect=!1)}t(ln,"onEnter"),t(un,"onLeave"),t(dn,"addListener"),t(fn,"removeListener"),t(pn,"connect"),t(hn,"disconnect"),t(mn,"onIntersect"),t(gn,"connect"),t(yn,"disconnect");var vn,bn=new MutationObserver((function([e]){if("childList"!==e.type)return;const t=e.addedNodes.length;if(t||e.removedNodes.length>0){const n=t?e.addedNodes[0]:e.removedNodes[0];if(1!==n.nodeType)return;M.eval&&B.test(n.nodeName)?"HEAD"===n.parentNode.nodeName?st(t?"appendChild":"removeChild",n):$n(n)&&!M.resources.has(n)?M.resources.add(n):M.resources.delete(n):n instanceof HTMLElement&&t&&!n.hasAttribute(M.qs.a)&&Ot(n)}}));function $n(e){const t=S().querySelectorAll(`${M.page.target.join(",")},[${M.qs.r}]`);for(let n=0,o=t.length;n<o;n++)if(t[n].contains(e))return!1;return!0}function kn(){M.observe.mutations&&(bn.observe(document.head,{childList:!0}),bn.observe(S(),{childList:!0,subtree:!0}),M.observe.mutations=!0)}function wn(){if(M.observe.mutations){bn.takeRecords(),bn.disconnect();for(const e of M.resources)S().removeChild(e),M.resources.delete(e);M.observe.mutations=!1}}function An({clientX:e,clientY:t},n){return e<=n.right&&e>=n.left&&t<=n.bottom&&t>=n.top}function xn(e){const t=e.getBoundingClientRect(),n=e.getAttribute(M.qs.A),o=Y.test(n)?Number(n):M.config.proximity.distance;return{target:e,top:t.top-o,bottom:t.bottom+o,left:t.left-o,right:t.right+o}}function Nn(e){let t=!1;return n=>{if(t)return;t=!0;const o=e.findIndex((e=>An(n,e)));if(-1===o)setTimeout((()=>{t=!1}),M.config.proximity.throttle);else{const{target:n}=e[o],s=Fn(fo(n,12)),r=s.threshold||M.config.proximity.threshold;Ye(s.key,(async()=>{if(!We("prefetch",n,s))return Cn();await Ge(s)&&(e.splice(o,1),t=!1,0===e.length&&(Cn(),D(2,"Proximity observer disconnected")))}),r)}}}function En(){if(!M.config.proximity||M.observe.proximity)return;const e=cn(M.qs.A).map(xn);e.length>0&&(vn=Nn(e),addEventListener(`${m}move`,vn,{passive:!0}),M.observe.proximity=!0)}function Cn(){M.observe.proximity&&(removeEventListener(`${m}move`,vn),M.observe.proximity=!1)}async function qn(e,t){if(!M.eval||!e||!t)return;const n=[],o=P(),{children:s}=e;for(let e=0,n=t.length;e<n;e++)o.add(t[e].outerHTML);for(let t=0,r=s.length;t<r;t++){const r=s[t],{nodeName:i,outerHTML:a}=r;let c=!0;c="SCRIPT"===i?r.matches(M.qs.G):"STYLE"===i?r.matches(M.qs.H):"META"===i?r.matches(M.qs.J):"LINK"===i?r.matches(M.qs.I):"false"!==e.getAttribute(M.qs.D),o.has(a)?c?n.push(r):o.delete(a):n.push(r)}const r=[],i=document.createRange();for(const t of o){const n=i.createContextualFragment(t).firstChild;if(le(n,"href")||le(n,"src")){const e=new Promise((function(e){n.addEventListener("error",(t=>{D(3,`Resource <${n.nodeName.toLowerCase()}> failed:`,n),e()})),n.addEventListener("load",(()=>e()))}));r.push(e)}e.appendChild(n),o.delete(t)}for(let t=0,o=n.length;t<o;t++)e.removeChild(n[t]);await Promise.all(r)}function Tn(e,t){const n=S();if("body"===e.selector||0===e.fragments.length){const e=t.body;nn(n,e),rt&&rt.c.length>0&&se((()=>{ot(e,rt.c),Yn("type",6)}))}else if(null!==e.selector){const o=n.querySelectorAll(e.selector),s=t.body.querySelectorAll(e.selector),r=P();for(let e=0,t=o.length;e<t;e++){const t=o[e],n=s[e];n&&t&&(We("render",t,n)&&(t.isEqualNode(n)||r.add(nn(t,n))))}6!==e.type&&rt&&rt.c.length>0&&se((()=>{nt(t.body,n,rt.c,r),Yn("type",6),r.clear()}))}else{for(const n of e.fragments){const e=M.fragments.get(n),o=t.body.querySelector(n);o&&e&&(We("render",e,o)&&(e.isEqualNode(o)||(nn(e,o),rt&&rt.c.length>0&&se((()=>ot(o,rt.c))))))}Yn("type",6)}}function Sn(e,t){const n=e.hydrate;if(1===n.length&&"body"===n[0])return void nn(S(),t.body);const o=n.join(","),s=S().querySelectorAll(o),r=e.preserve&&e.preserve.length>0?e.preserve.join(","):null,i=[];if(r){const e=S().querySelectorAll(r);for(let t=0,n=e.length;t<n;t++){const n=e[t];n.setAttribute(M.qs.m,"false"),i.push(n)}}if(s.length>0){const e=t.body.querySelectorAll(o);for(let t=0,n=s.length;t<n;t++){const n=s[t],o=e[t];if(e[t]instanceof HTMLElement){if(!We("hydrate",n,o))continue;nn(o,o)}}}if(r)for(const e of i)e.removeAttribute("spx-morph");e.hydrate=void 0,e.preserve=void 0,e.type=6,On(e)}function On(e){hn(),yn(),Cn(),wn(),ft(),mt(),M.eval||(document.title=e.title);const t=Gn(e.snap);return 7===e.type?Sn(e,t):(qn(O(),t.head.children),Tn(e,t),scrollTo(e.scrollX,e.scrollY)),qe.done(),se((()=>{pn(),gn(),En(),dt(),kn()})),We("load",e),e}t($n,"nodeOutsideTarget"),t(kn,"connect"),t(wn,"disconnect"),t(An,"inRange"),t(xn,"setBounds"),t(Nn,"observer"),t(En,"connect"),t(Cn,"disconnect"),t(qn,"morphHead"),t(Tn,"morphNodes"),t(Sn,"morphHydrate"),t(On,"update");var Ln=window.history;function Pn(){return null!==Ln.state&&"rev"in Ln.state&&Ln.state.key!==Ln.state.rev}function Rn(e){if(null==Ln.state)return!1;if("object"!=typeof Ln.state)return!1;const t=ce(Ln.state)(["key","rev","scrollX","scrollY","title"]);return"string"==typeof e?t&&Ln.state.key===e:t}async function In(){await re(),M.loaded=!0}function jn(e){return Rn(e.key)?(scrollTo(Ln.state.scrollX,Ln.state.scrollY),y(e,Ln.state)):Hn(e),e}function Hn({key:e,rev:t,title:n,scrollX:o,scrollY:s}){const r={key:e,rev:t,scrollX:o,scrollY:s,title:n||document.title};return Ln.replaceState(r,r.title,r.key),D(1,`History replaceState: ${Ln.state.key}`),Ln.state}function Mn({key:e,rev:t,title:n,location:o}){const s=o.pathname+o.search,r={key:e,rev:t,title:n,scrollY:0,scrollX:0};return Ln.pushState(r,r.title,s),D(1,`History pushState: ${Ln.state.key}`),Ln.state}async function Wn(e){if(null!==e.state)if(_n(e.state.key)){_n(e.state.rev)||e.state.rev===e.state.key?(M.pages[e.state.rev].scrollX=window.scrollX,M.pages[e.state.rev].scrollY=window.scrollY):Be(e.state.rev);const t=M.pages[e.state.key];4===t.type?D(1,`History popState reverse (snapshot): ${t.key}`):D(1,`History popState session (snapshot): ${t.key}`),Yn("type",5),On(t)}else{1===M.logLevel&&D(1,`History popState fetch: ${e.state.key}`),e.state.type=5;const t=await Ge(e.state);if(!t)return location.assign(e.state.key);const n=co(location);if(t.key===n)On(t);else if(_n(n))On(M.pages[n]);else{const e=Fn(fo(n,5));await Ge(e),Mn(e)}}}function Dn(e){if(!M.observe.history)return Ln.scrollRestoration&&(Ln.scrollRestoration="manual"),addEventListener("popstate",Wn,!1),M.observe.history=!0,"object"==typeof e&&0===e.type?jn(e):e}function Xn(){M.observe.history&&(Ln.scrollRestoration&&(Ln.scrollRestoration="auto"),removeEventListener("popstate",Wn,!1),removeEventListener("load",In,!1),M.observe.history=!1)}function Fn(e){const t=ce(e);return e.ts=ae(),e.target=de(e),t("selector")||("body"===e.target[0]?e.selector="body":e.selector=fe(e.target)),M.config.cache&&(t("cache")||(e.cache=M.config.cache),t("snap")||(e.snap=me())),t("scrollY")||(e.scrollY=0),t("scrollX")||(e.scrollX=0),!1!==M.config.hover&&10===e.type&&(t("threshold")||(e.threshold=M.config.hover.threshold)),!1!==M.config.proximity&&12===e.type&&(t("proximity")||(e.proximity=M.config.proximity.distance),t("threshold")||(e.threshold=M.config.proximity.threshold)),M.config.progress&&!t("progress")&&(e.progress=M.config.progress.threshold),t("fragments")||(e.fragments=M.config.fragments),t("history")||(e.history=!0),t("visits")||(e.visits=0),t("components")||(e.components=[]),M.pages[e.key]=e,M.pages[e.key]}function zn(e){const t=y(L(e),{target:[],selector:null,cache:M.config.cache,history:!0,scrollX:0,scrollY:0,fragments:M.config.fragments});return M.config.hover&&(t.threshold=M.config.hover.threshold),M.config.proximity&&(t.proximity=M.config.proximity.distance,t.threshold=M.config.proximity.threshold),M.config.progress&&(t.progress=M.config.progress.threshold),t}function Yn(e,t,n=Ln.state.key){return"location"===e?M.pages[n][e]=y(M.pages[n][e],t):"target"===e?(M.pages[n].target=de(t),M.pages[n].selector=fe(M.pages[n].target)):"components"===e?M.pages[n].components=t:M.pages[n][e]=t,M.pages[n]}function Vn(e,t){const n=We("before:cache",e,t),o="string"==typeof n?n:t;return e.type>5&&e.type>9&&(e.type=1),e.title=Me(t),M.config.cache&&!1!==n?0===e.type||"snap"in e?(M.pages[e.key]=e,M.snaps[e.snap]=o,gt(e),We("after:cache",e),e):Un(e,o):e}function Un(e,t){const n=e.key in M.pages?M.pages[e.key]:Fn(e);return"string"==typeof t&&(M.snaps[n.snap]=t,e.title=Me(t)),y(n,e)}function Bn(e,t){const n=t=t?47===t.charCodeAt(0)?t in M.pages?M.pages[t].snap:null:t:M.page.snap;n?M.snaps[n]=e:D(3,"Snapshot record does not exist, update failed")}function Kn(e){if(!e){if(null===Ln.state)return void D(3,"Missing history state reference, page cannot be returned");e=Ln.state.key}if(e in M.pages)return k(L(),{page:{get:()=>M.pages[e]},dom:{get:()=>je(M.snaps[M.pages[e].snap])}});D(5,`No record exists: ${e}`)}function Gn(e){const t=e=e?47===e.charCodeAt(0)?M.pages[e].snap:e:M.page.snap;return je(M.snaps[t])}function Jn({mounted:e=null}={}){const t=L(),{h:n,k:o}=M.components;for(const s of n.values()){const{scope:n}=s;o.has(n.key)&&(null!==e&&n.mounted===e||(null===n.alias||n.alias in t?n.instanceOf in t?t[n.instanceOf].push(s):t[n.instanceOf]=[s]:t[n.alias]=[s]))}return t}function Zn(e){if(!e){if(null===Ln.state)return void D(3,"Missing history state reference, page cannot be returned");e=Ln.state.key}if(e in M.pages)return M.pages[e];D(5,`No page record exists for: ${e}`)}function _n(e){return le(M.pages,e)&&le(M.pages[e],"snap")&&le(M.snaps,M.pages[e].snap)&&"string"==typeof M.snaps[M.pages[e].snap]}function Qn(e){e?"string"==typeof e?(delete M.snaps[M.pages[e].snap],delete M.pages[e]):A(e)&&Ae((e=>{delete M.snaps[M.pages[e].snap],delete M.pages[e]}),e):(xe(M.pages),xe(M.snaps))}t(Pn,"reverse"),t(Rn,"has"),t(In,"load"),t(jn,"initialize"),t(Hn,"replace"),t(Mn,"push"),t(Wn,"pop"),t(Dn,"connect"),t(Xn,"disconnect"),t(Fn,"create"),t(zn,"newPage"),t(Yn,"patchPage"),t(Vn,"set"),t(Un,"update"),t(Bn,"setSnap"),t(Kn,"get"),t(Gn,"getSnapDom"),t(Jn,"getMounted"),t(Zn,"getPage"),t(_n,"has"),t(Qn,"clear");var eo=g.replace(/(?:https?:)?(?:\/\/(?:www\.)?|(?:www\.))/,N);function to(e,t){const n=t?zn(t):L(),o=e.getAttributeNames();for(let s=0,r=o.length;s<r;s++){const r=o[s];if(r.startsWith(M.qs.t)){le(n,"data")||(n.data=L());const t=ke(r.slice(M.qs.t.length)),o=e.getAttribute(r).trim();V.test(o)?n.data[t]="NaN"===o?NaN:+o:z.test(o)?n.data[t]="true"===o:123===o.charCodeAt(0)||91===o.charCodeAt(0)?n.data[t]=Z(r,o):n.data[t]=o}else{if(!M.qs.B.test(r))continue;const o=e.getAttribute(r).trim();if("href"===r)n.rev=location.pathname+location.search,t||(n.location=uo(o),n.key=n.location.pathname+n.location.search);else{const t=r.slice(r.lastIndexOf("-")+1),s=o.replace(F,N).trim();if("target"===t)n[t]="true"===s?[]:s!==N?J(s):[],n.selector=fe(n[t]);else if(K.test(s)){const e=s.match(/\[?[^,'"[\]()\s]+\]?/g);n[t]=X.test(t)?e.reduce(ge(2),[]):e}else if("position"===t)if(G.test(s)){const e=s.match(G);n[`scroll${e[0].toUpperCase()}`]=+e[1],4===e.length&&(n[`scroll${e[2].toUpperCase()}`]=+e[3])}else D(3,`Invalid attribute value on <${r}>, expected: y:number or x:number`,e);else"scroll"===t?Y.test(s)?n.scrollY=+s:D(3,`Invalid attribute value on <${r}>, expected: number`,e):z.test(s)&&!U.test(r)?n[t]="true"===s:V.test(s)?n[t]=+s:("history"===t&&"push"!==s&&"replace"!==s&&D(5,`Invalid attribute value on <${r}>, expected: false, push or replace`,e),n[t]=s)}}}return n}function no(e){const t=L();if(1===e.length&&47===e.charCodeAt(0))return t.pathname=e,t.hash=N,t.search=N,t;const n=e.indexOf("#");n>=0?(t.hash=e.slice(n),e=e.slice(0,n)):t.hash=N;const o=e.indexOf("?");return o>=0?(t.search=e.slice(o),e=e.slice(0,o)):t.search=N,t.pathname=e,t}function oo(e,t){const n=e.indexOf("/",t);if(n>t){const t=e.indexOf("#",n);return t<0?e.slice(n):e.slice(n,t)}const o=e.indexOf("?",t);if(o>t){const t=e.indexOf("#",o);return t<0?e.slice(o):e.slice(o,t)}return e.length-t===eo.length?"/":null}function so(e){const t=e.startsWith("www.")?e.slice(4):e,n=t.indexOf("/");if(n>=0){const e=t.slice(n);if(t.slice(0,n)===eo)return e.length>0?no(e):no("/")}else{const e=t.search(/[?#]/);if(e>=0){if(t.slice(0,e)===eo)return no("/"+t.slice(e))}else if(t===eo)return no("/")}return null}function ro(e){return e.startsWith("http")?1:e.startsWith("//")?2:e.startsWith("www.")?3:1}function io(e){if("string"!=typeof e||0===e.length)return!1;if(47===e.charCodeAt(0))return 47!==e.charCodeAt(1)||(e.startsWith("www.",2)?e.startsWith(eo,6):e.startsWith(eo,2));if(63===e.charCodeAt(0))return!0;if(e.startsWith("www."))return e.startsWith(eo,4);if(e.startsWith("http")){const t=e.indexOf("/",4)+2;return e.startsWith("www.",t)?e.startsWith(eo,t+4):e.startsWith(eo,t)}}function ao(e){return 47===e.charCodeAt(0)?47!==e.charCodeAt(1)?no(e):so(e.slice(2)):63===e.charCodeAt(0)?no(location.pathname+e):e.startsWith("https:")||e.startsWith("http:")?so(e.slice(e.indexOf("/",4)+2)):e.startsWith("www.")?so(e):null}function co(e){if("object"==typeof e)return e.pathname+e.search;if(e===N||"/"===e)return"/";const t=ro(e);if(1===t){const t=115===e.charCodeAt(4)?8:7,n=e.startsWith("www.",t)?t+4:t;return e.startsWith(eo,n)?oo(e,n):null}if(2===t){const t=e.startsWith("www.",2)?6:2;return e.startsWith(eo,t)?oo(e,t):null}return 3===t?e.startsWith(eo,4)?oo(e,4):null:e.startsWith(eo,0)?oo(e,0):null}function lo(){const{pathname:e,search:t,hash:n}=location;return L({hostname:eo,origin:g,pathname:e,search:t,hash:n})}function uo(e){if(e===N)return lo();const t=ao(e);return null===t&&D(5,`Invalid pathname: ${e}`),t.origin=g,t.hostname=eo,t}function fo(e,t=6){if(e instanceof Element){const n=to(e);return n.type=t||6,n}const n=L();return 0===e?(n.location=lo(),n.key=n.rev=co(n.location),n.type=e,n.visits=1,M.index=n.key):7===t?(n.location=uo(e),n.key=n.rev=co(n.location),n.type=t):(n.rev=location.pathname+location.search,n.location=uo("string"==typeof e?e:n.rev),n.key=co(n.location),n.type=t),n}function po(e){return!(e.target&&e.target.isContentEditable||e.defaultPrevented||e.button>1||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}t(to,"getAttributes"),t(no,"parsePath"),t(oo,"getPath"),t(so,"parseOrigin"),t(ro,"hasOrigin"),t(io,"validKey"),t(ao,"parseKey"),t(co,"getKey"),t(lo,"fallback"),t(uo,"getLocation"),t(fo,"getRoute"),t(po,"linkEvent");var ho=t((function(e){if(!po(e))return;const n=on(e.target,M.qs.F);if(!n)return;const o=co(n.href);if(null===o)return;const s=o===M.page.key,r=t((()=>{D(3,`Drag occurance deteced, cancelled visit: ${o}`),ho.drag=!0,n.removeEventListener(`${m}move`,r)}),"move");if(n.addEventListener(`${m}move`,r,{once:!0}),!0===ho.drag)return ho.drag=!1,ho(e);if(n.removeEventListener(`${m}move`,r),!We("visit",e))return;const i=t(((e,t=!0)=>{M.pages[e.key].ts=ae(),M.pages[e.key].visits=e.visits+1,M.pages[e.rev].scrollX=window.scrollX,M.pages[e.rev].scrollY=window.scrollY,s?D(2,`Identical pathname, page visit skipped: ${o}`):(Hn(M.pages[e.rev]),t?(Mn(e),On(e)):mo(e))}),"click");if(hn(),Cn(),yn(),_n(o)){const e=Un(to(n,M.pages[o]));n.onclick=t=>{t.preventDefault(),i(e)}}else if(H.j.has(o)){Ve(o),D(2,`Request in transit: ${o}`);const e=M.pages[o];n.onclick=t=>{t.preventDefault(),i(e,!1)}}else{Ve(),ze(o);const e=Fn(fo(n,6));Ge(e),n.onclick=t=>{t.preventDefault(),i(e,!1)}}}),"handle");async function mo(e){e.progress&&qe.start(e.progress);const t=await Ke(e);t?(Mn(t),On(t)):location.assign(e.key)}async function go(e,t){if(!t)return mo(M.pages[e]);{"string"==typeof t.cache&&("clear"===t.cache?Qn():Qn(t.key)),t.progress&&qe.start(t.progress);const e=await Ge(t);e?(Mn(e),On(e)):location.assign(t.key)}}function yo(){M.observe.hrefs||(ho.drag=!1,"mouseOnly"===p?addEventListener(`${m}down`,ho,!1):("touchOnly"===p||addEventListener(`${m}down`,ho,!1),addEventListener("touchstart",ho,!1)),M.observe.hrefs=!0)}function vo(){M.observe.hrefs&&("mouseOnly"===p?removeEventListener(`${m}down`,ho,!1):("touchOnly"===p||removeEventListener(`${m}down`,ho,!1),removeEventListener("touchstart",ho,!1)),M.observe.hrefs=!1)}function bo(){const e=Dn(Fn(fo(0)));k(M,{prev:{get:()=>M.pages[Ln.state.rev]},page:{get:()=>M.pages[Ln.state.key]},snapDom:{get:()=>je(M.snaps[M.page.snap])}});const n=t((()=>{const t=Vn(e,He());return yo(),mt(),!1===M.config.manual&&(pn(),gn(),En(),dt(),kn()),se((()=>{Yn("type",6),Be(t),Ue(t)})),We("x"),t}),"DOMReady");return new Promise((e=>{const{readyState:t}=document;if("interactive"===t||"complete"===t)return e(n());addEventListener("DOMContentLoaded",(()=>e(n())))}))}function $o(){hn(),pn(),yn(),gn(),Cn(),En(),ft(),dt(),wn(),kn()}function ko(){Xn(),vo(),wn(),hn(),yn(),Cn(),M.config.components&&(ft(),ct(),M.components.n.clear()),Qn(),M.config.globalThis&&delete window.spx,D(2,"Disconnected")}t(mo,"visit"),t(go,"navigate"),t(yo,"connect"),t(vo,"disconnect"),t(bo,"initialize"),t($o,"observe"),t(ko,"disconnect");var wo=L({get $(){return M},Component:tt,on:De,off:Xe,observe:$o,connect:Ao,component:xo,capture:So,form:Lo,render:To,session:Eo,reload:Co,fetch:qo,clear:Qn,hydrate:Po,prefetch:Oo,visit:Ro,disconnect:ko,register:No,get config(){return M.config},supported:!!(h&&window.history.pushState&&window.requestAnimationFrame&&window.DOMParser&&window.Proxy),history:L({get state(){return Ln.state},api:Ln,push:Mn,replace:Hn,has:Rn,reverse:Pn})});function Ao(e={}){if(!1===h)return D(5,"Invalid runtime environment: window is undefined.");if(!wo.supported)return D(5,"Browser does not support SPX");if(!window.location.protocol.startsWith("http"))return D(5,"Invalid protocol, SPX expects HTTPS or HTTP protocol");Ie(e),M.config.globalThis&&!1===le(window,"spx")&&ue(window,"spx",wo);const t=bo();return async function(e){const n=await t;if("AsyncFunction"===e.constructor.name)try{await e(n)}catch(e){D(3,"Connection Error",e)}else e(n);D(2,"Connection Established")}}function xo(e){return Jn()[e][0]}function No(...e){if("string"==typeof e[0])e.length>2&&D(5,[`Named component registration expects 2 parameters, recieved ${e.length}.`,'Registry should follow this structure: spx.register("identifer", YourComponent)'],e),Se({[it[0]]:e[1]});else for(const t of e)if(A(t))for(const e of t)"string"==typeof e[0]?Se({[e[0]]:e[1]}):"function"==typeof e&&Se({[Te(e)]:e},!0);else{const e=typeof t;"function"===e?Se({[Te(t)]:t},!0):"object"===e&&Se(t)}M.ready?dt():De("x",t((function e(){dt(),Xe("x",e),We("connected")}),"run"))}function Eo(){return k(L(),{config:{get:()=>M.config},snaps:{get:()=>M.snaps},pages:{get:()=>M.pages},observers:{get:()=>M.observe},components:{get:()=>M.components},fragments:{get:()=>M.fragments},memory:{get(){const e=M.memory;return e.size=ye(e.bytes),e}}})}async function Co(){const e=M.pages[Ln.state.key];e.type=9;const t=await Ge(e);return t?(D(2,"Triggered reload, page was re-cached"),On(t)):(D(3,"Reload failed, triggering refresh (cache will purge)"),location.assign(e.key))}async function qo(e){const t=fo(e,2);t.location.origin!==g&&D(5,"Cross origin fetches are not allowed");const n=await Fe(t.key);if(n)return n}async function To(e,t,n){const o=M.page,s=fo(e);s.location.origin!==g&&D(5,"Cross origin fetches are not allowed");const r=await Fe(s.key,{type:"document"});if(r||D(5,`Fetch failed for: ${s.key}`,r),await n.call(o,r),"replace"===t){o.title=r.title;const e=Un(y(o,s),He(r));return Hn(e),e}return On(Vn(s,He(r)))}function So(e){const t=Zn();if(!t)return;const n=Gn();if(1===(e=A(e)?e:t.target).length&&"body"===e[0])return nn(n.body,S()),void Un(t,He(n));const o=e.join(","),s=S().querySelectorAll(o);we(n.body.querySelectorAll(o),((e,t)=>{nn(e,s[t])})),Un(t,He(n))}async function Oo(e){const t=fo(e,1);if(_n(t.key))return void D(3,`Cache already exists for ${t.key}, prefetch skipped`);const n=await Ge(Fn(t));if(n)return n;D(5,`Prefetch failed for ${t.key}`)}async function Lo(e,t){const n=new FormData;for(const e in t.data)n.append(e,t.data[e]);return await Fe(e,{method:t.method,body:n})}async function Po(e,t){const n=fo(e,7);if(Ge(n),A(t)){n.hydrate=[],n.preserve=[];for(const e of t)33===e.charCodeAt(0)?n.preserve.push(e.slice(1)):n.hydrate.push(e)}else n.hydrate=M.config.fragments;const o=await Ke(n);if(o){const{key:e}=Ln.state;if(Hn(o),On(o),n.key!==e){M.index===e&&(M.index=n.key);for(const t in M.pages)M.pages[t].rev===e&&(M.pages[t].rev=n.key);Qn(e)}}return Gn(o.key)}async function Ro(e,t){const n=fo(e),o="object"==typeof t?y(n,t):n;return _n(n.key)?go(n.key,Un(o)):go(n.key,Fn(o))}t(Ao,"connect"),t(xo,"component"),t(No,"register"),t(Eo,"session"),t(Co,"reload"),t(qo,"fetch"),t(To,"render"),t(So,"capture"),t(Oo,"prefetch"),t(Lo,"form"),t(Po,"hydrate"),t(Ro,"visit");var Io=wo;export{Io as default};