2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
var ie=Object.defineProperty,ne=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var X=(a,e,t)=>e in a?ie(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,v=(a,e)=>{for(var t in e||(e={}))G.call(e,t)&&X(a,t,e[t]);if(B)for(var t of B(e))Y.call(e,t)&&X(a,t,e[t]);return a},K=(a,e)=>ne(a,ae(e));var F=(a,e)=>{var t={};for(var i in a)G.call(a,i)&&e.indexOf(i)<0&&(t[i]=a[i]);if(a!=null&&B)for(var i of B(a))e.indexOf(i)<0&&Y.call(a,i)&&(t[i]=a[i]);return t};import{S as oe,i as le,s as ce,e as fe,c as ue,a as he,d as $,b as J,f as T,g as L,t as de,h as _e,j as pe,k as ge,l as m,m as me,n as N,o as w,p as O,q as b,r as we,u as be,v as M,w as S,x as P,y as U,z as x,A as I,B as j,C as V,D as W,E as H}from"./chunks/vendor-54c63849.js";import{_ as C}from"./chunks/preload-helper-1db36302.js";import{i as ve}from"./chunks/singletons-a6a7384f.js";import{s as ye}from"./chunks/paths-4b3c6e7e.js";function ke(a){let e,t,i;const l=[a[1]||{}];var r=a[0][0];function o(s){let n={};for(let c=0;c<l.length;c+=1)n=V(n,l[c]);return{props:n}}return r&&(e=new r(o())),{c(){e&&S(e.$$.fragment),t=m()},l(s){e&&P(e.$$.fragment,s),t=m()},m(s,n){e&&U(e,s,n),L(s,t,n),i=!0},p(s,n){const c=n&2?x(l,[I(s[1]||{})]):{};if(r!==(r=s[0][0])){if(e){N();const f=e;w(f.$$.fragment,1,0,()=>{j(f,1)}),O()}r?(e=new r(o()),S(e.$$.fragment),b(e.$$.fragment,1),U(e,t.parentNode,t)):e=null}else r&&e.$set(c)},i(s){i||(e&&b(e.$$.fragment,s),i=!0)},o(s){e&&w(e.$$.fragment,s),i=!1},d(s){s&&$(t),e&&j(e,s)}}}function $e(a){let e,t,i;const l=[a[1]||{}];var r=a[0][0];function o(s){let n={$$slots:{default:[Se]},$$scope:{ctx:s}};for(let c=0;c<l.length;c+=1)n=V(n,l[c]);return{props:n}}return r&&(e=new r(o(a))),{c(){e&&S(e.$$.fragment),t=m()},l(s){e&&P(e.$$.fragment,s),t=m()},m(s,n){e&&U(e,s,n),L(s,t,n),i=!0},p(s,n){const c=n&2?x(l,[I(s[1]||{})]):{};if(n&525&&(c.$$scope={dirty:n,ctx:s}),r!==(r=s[0][0])){if(e){N();const f=e;w(f.$$.fragment,1,0,()=>{j(f,1)}),O()}r?(e=new r(o(s)),S(e.$$.fragment),b(e.$$.fragment,1),U(e,t.parentNode,t)):e=null}else r&&e.$set(c)},i(s){i||(e&&b(e.$$.fragment,s),i=!0)},o(s){e&&w(e.$$.fragment,s),i=!1},d(s){s&&$(t),e&&j(e,s)}}}function Ee(a){let e,t,i;const l=[a[2]||{}];var r=a[0][1];function o(s){let n={};for(let c=0;c<l.length;c+=1)n=V(n,l[c]);return{props:n}}return r&&(e=new r(o())),{c(){e&&S(e.$$.fragment),t=m()},l(s){e&&P(e.$$.fragment,s),t=m()},m(s,n){e&&U(e,s,n),L(s,t,n),i=!0},p(s,n){const c=n&4?x(l,[I(s[2]||{})]):{};if(r!==(r=s[0][1])){if(e){N();const f=e;w(f.$$.fragment,1,0,()=>{j(f,1)}),O()}r?(e=new r(o()),S(e.$$.fragment),b(e.$$.fragment,1),U(e,t.parentNode,t)):e=null}else r&&e.$set(c)},i(s){i||(e&&b(e.$$.fragment,s),i=!0)},o(s){e&&w(e.$$.fragment,s),i=!1},d(s){s&&$(t),e&&j(e,s)}}}function Re(a){let e,t,i;const l=[a[2]||{}];var r=a[0][1];function o(s){let n={$$slots:{default:[Le]},$$scope:{ctx:s}};for(let c=0;c<l.length;c+=1)n=V(n,l[c]);return{props:n}}return r&&(e=new r(o(a))),{c(){e&&S(e.$$.fragment),t=m()},l(s){e&&P(e.$$.fragment,s),t=m()},m(s,n){e&&U(e,s,n),L(s,t,n),i=!0},p(s,n){const c=n&4?x(l,[I(s[2]||{})]):{};if(n&521&&(c.$$scope={dirty:n,ctx:s}),r!==(r=s[0][1])){if(e){N();const f=e;w(f.$$.fragment,1,0,()=>{j(f,1)}),O()}r?(e=new r(o(s)),S(e.$$.fragment),b(e.$$.fragment,1),U(e,t.parentNode,t)):e=null}else r&&e.$set(c)},i(s){i||(e&&b(e.$$.fragment,s),i=!0)},o(s){e&&w(e.$$.fragment,s),i=!1},d(s){s&&$(t),e&&j(e,s)}}}function Le(a){let e,t,i;const l=[a[3]||{}];var r=a[0][2];function o(s){let n={};for(let c=0;c<l.length;c+=1)n=V(n,l[c]);return{props:n}}return r&&(e=new r(o())),{c(){e&&S(e.$$.fragment),t=m()},l(s){e&&P(e.$$.fragment,s),t=m()},m(s,n){e&&U(e,s,n),L(s,t,n),i=!0},p(s,n){const c=n&8?x(l,[I(s[3]||{})]):{};if(r!==(r=s[0][2])){if(e){N();const f=e;w(f.$$.fragment,1,0,()=>{j(f,1)}),O()}r?(e=new r(o()),S(e.$$.fragment),b(e.$$.fragment,1),U(e,t.parentNode,t)):e=null}else r&&e.$set(c)},i(s){i||(e&&b(e.$$.fragment,s),i=!0)},o(s){e&&w(e.$$.fragment,s),i=!1},d(s){s&&$(t),e&&j(e,s)}}}function Se(a){let e,t,i,l;const r=[Re,Ee],o=[];function s(n,c){return n[0][2]?0:1}return e=s(a),t=o[e]=r[e](a),{c(){t.c(),i=m()},l(n){t.l(n),i=m()},m(n,c){o[e].m(n,c),L(n,i,c),l=!0},p(n,c){let f=e;e=s(n),e===f?o[e].p(n,c):(N(),w(o[f],1,1,()=>{o[f]=null}),O(),t=o[e],t?t.p(n,c):(t=o[e]=r[e](n),t.c()),b(t,1),t.m(i.parentNode,i))},i(n){l||(b(t),l=!0)},o(n){w(t),l=!1},d(n){o[e].d(n),n&&$(i)}}}function Q(a){let e,t=a[5]&&Z(a);return{c(){e=fe("div"),t&&t.c(),this.h()},l(i){e=ue(i,"DIV",{id:!0,"aria-live":!0,"aria-atomic":!0,style:!0});var l=he(e);t&&t.l(l),l.forEach($),this.h()},h(){J(e,"id","svelte-announcer"),J(e,"aria-live","assertive"),J(e,"aria-atomic","true"),T(e,"position","absolute"),T(e,"left","0"),T(e,"top","0"),T(e,"clip","rect(0 0 0 0)"),T(e,"clip-path","inset(50%)"),T(e,"overflow","hidden"),T(e,"white-space","nowrap"),T(e,"width","1px"),T(e,"height","1px")},m(i,l){L(i,e,l),t&&t.m(e,null)},p(i,l){i[5]?t?t.p(i,l):(t=Z(i),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},d(i){i&&$(e),t&&t.d()}}}function Z(a){let e;return{c(){e=de(a[6])},l(t){e=_e(t,a[6])},m(t,i){L(t,e,i)},p(t,i){i&64&&pe(e,t[6])},d(t){t&&$(e)}}}function Ue(a){let e,t,i,l,r;const o=[$e,ke],s=[];function n(f,h){return f[0][1]?0:1}e=n(a),t=s[e]=o[e](a);let c=a[4]&&Q(a);return{c(){t.c(),i=ge(),c&&c.c(),l=m()},l(f){t.l(f),i=me(f),c&&c.l(f),l=m()},m(f,h){s[e].m(f,h),L(f,i,h),c&&c.m(f,h),L(f,l,h),r=!0},p(f,[h]){let u=e;e=n(f),e===u?s[e].p(f,h):(N(),w(s[u],1,1,()=>{s[u]=null}),O(),t=s[e],t?t.p(f,h):(t=s[e]=o[e](f),t.c()),b(t,1),t.m(i.parentNode,i)),f[4]?c?c.p(f,h):(c=Q(f),c.c(),c.m(l.parentNode,l)):c&&(c.d(1),c=null)},i(f){r||(b(t),r=!0)},o(f){w(t),r=!1},d(f){s[e].d(f),f&&$(i),c&&c.d(f),f&&$(l)}}}function je(a,e,t){let{stores:i}=e,{page:l}=e,{components:r}=e,{props_0:o=null}=e,{props_1:s=null}=e,{props_2:n=null}=e;we("__svelte__",i),be(i.page.notify);let c=!1,f=!1,h=null;return M(()=>{const u=i.page.subscribe(()=>{c&&(t(5,f=!0),t(6,h=document.title||"untitled page"))});return t(4,c=!0),u}),a.$$set=u=>{"stores"in u&&t(7,i=u.stores),"page"in u&&t(8,l=u.page),"components"in u&&t(0,r=u.components),"props_0"in u&&t(1,o=u.props_0),"props_1"in u&&t(2,s=u.props_1),"props_2"in u&&t(3,n=u.props_2)},a.$$.update=()=>{a.$$.dirty&384&&i.page.set(l)},[r,o,s,n,c,f,h,i,l]}class Ae extends oe{constructor(e){super();le(this,e,je,Ue,ce,{stores:7,page:8,components:0,props_0:1,props_1:2,props_2:3})}}const E=[()=>C(()=>import("./pages/__layout.svelte-4140e478.js"),["pages/__layout.svelte-4140e478.js","assets/pages/__layout.svelte-4a018ea6.css","chunks/vendor-54c63849.js","chunks/paths-4b3c6e7e.js","chunks/state-1030977e.js","chunks/preload-helper-1db36302.js","chunks/theme-af6eb1f9.js"]),()=>C(()=>import("./error.svelte-42b18922.js"),["error.svelte-42b18922.js","chunks/vendor-54c63849.js"]),()=>C(()=>import("./pages/index.svelte-e6145252.js"),["pages/index.svelte-e6145252.js","chunks/vendor-54c63849.js","chunks/singletons-a6a7384f.js","chunks/paths-4b3c6e7e.js"]),()=>C(()=>import("./pages/edit.svelte-a9fa1e73.js"),["pages/edit.svelte-a9fa1e73.js","assets/pages/edit.svelte-3300ec7f.css","chunks/vendor-54c63849.js","chunks/state-1030977e.js","chunks/preload-helper-1db36302.js","chunks/theme-af6eb1f9.js","chunks/util-6c68073b.js","assets/util-c948b67a.css","chunks/paths-4b3c6e7e.js"]),()=>C(()=>import("./pages/view.svelte-f61e1fd0.js"),["pages/view.svelte-f61e1fd0.js","chunks/vendor-54c63849.js","chunks/util-6c68073b.js","assets/util-c948b67a.css","chunks/state-1030977e.js","chunks/preload-helper-1db36302.js"])],Te=[[/^\/$/,[E[0],E[2]],[E[1]]],[/^\/edit\/?$/,[E[0],E[3]],[E[1]]],[/^\/view\/?$/,[E[0],E[4]],[E[1]]]],Ne=[E[0](),E[1]()];function Oe(a){let e=a.baseURI;if(!e){const t=a.getElementsByTagName("base");e=t.length?t[0].href:a.URL}return e}function z(){return{x:pageXOffset,y:pageYOffset}}function ee(a){return a.composedPath().find(t=>t instanceof Node&&t.nodeName.toUpperCase()==="A")}function te(a){return a instanceof SVGAElement?new URL(a.href.baseVal,document.baseURI):new URL(a.href)}class Pe{constructor({base:e,routes:t,trailing_slash:i,renderer:l}){var r,o;this.base=e,this.routes=t,this.trailing_slash=i,this.navigating=0,this.renderer=l,l.router=this,this.enabled=!0,document.body.setAttribute("tabindex","-1"),this.current_history_index=(o=(r=history.state)==null?void 0:r["sveltekit:index"])!=null?o:0,this.current_history_index===0&&history.replaceState(K(v({},history.state),{"sveltekit:index":0}),"",location.href),this.callbacks={before_navigate:[],after_navigate:[]}}init_listeners(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),addEventListener("beforeunload",r=>{let o=!1;const s={from:this.renderer.current.url,to:null,cancel:()=>o=!0};this.callbacks.before_navigate.forEach(n=>n(s)),o?(r.preventDefault(),r.returnValue=""):history.scrollRestoration="auto"}),addEventListener("load",()=>{history.scrollRestoration="manual"});let e;addEventListener("scroll",()=>{clearTimeout(e),e=setTimeout(()=>{const r=K(v({},history.state||{}),{"sveltekit:scroll":z()});history.replaceState(r,document.title,window.location.href)},200)});const t=r=>{const o=ee(r);o&&o.href&&o.hasAttribute("sveltekit:prefetch")&&this.prefetch(te(o))};let i;const l=r=>{clearTimeout(i),i=setTimeout(()=>{var o;(o=r.target)==null||o.dispatchEvent(new CustomEvent("sveltekit:trigger_prefetch",{bubbles:!0}))},20)};addEventListener("touchstart",t),addEventListener("mousemove",l),addEventListener("sveltekit:trigger_prefetch",t),addEventListener("click",r=>{if(!this.enabled||r.button||r.which!==1||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||r.defaultPrevented)return;const o=ee(r);if(!o||!o.href)return;const s=te(o);if(s.toString()===location.href){location.hash||r.preventDefault();return}const c=(o.getAttribute("rel")||"").split(/\s+/);if(!(o.hasAttribute("download")||c&&c.includes("external"))&&!(o instanceof SVGAElement?o.target.baseVal:o.target)){if(s.href.split("#")[0]===location.href.split("#")[0]){setTimeout(()=>history.pushState({},"",s.href));const f=this.parse(s);return f?this.renderer.update(f,[],!1):void 0}this._navigate({url:s,scroll:o.hasAttribute("sveltekit:noscroll")?z():null,keepfocus:!1,chain:[],details:{state:{},replaceState:!1},accepted:()=>r.preventDefault(),blocked:()=>r.preventDefault()})}}),addEventListener("popstate",r=>{if(r.state&&this.enabled){if(r.state["sveltekit:index"]===this.current_history_index)return;this._navigate({url:new URL(location.href),scroll:r.state["sveltekit:scroll"],keepfocus:!1,chain:[],details:null,accepted:()=>{this.current_history_index=r.state["sveltekit:index"]},blocked:()=>{const o=this.current_history_index-r.state["sveltekit:index"];history.go(o)}})}})}owns(e){return e.origin===location.origin&&e.pathname.startsWith(this.base)}parse(e){if(this.owns(e)){const t=decodeURI(e.pathname.slice(this.base.length)||"/");return{id:e.pathname+e.search,routes:this.routes.filter(([i])=>i.test(t)),url:e,path:t}}}async goto(e,{noscroll:t=!1,replaceState:i=!1,keepfocus:l=!1,state:r={}}={},o){const s=new URL(e,Oe(document));return this.enabled?this._navigate({url:s,scroll:t?z():null,keepfocus:l,chain:o,details:{state:r,replaceState:i},accepted:()=>{},blocked:()=>{}}):(location.href=s.href,new Promise(()=>{}))}enable(){this.enabled=!0}disable(){this.enabled=!1}async prefetch(e){const t=this.parse(e);if(!t)throw new Error("Attempted to prefetch a URL that does not belong to this app");return this.renderer.load(t)}after_navigate(e){M(()=>(this.callbacks.after_navigate.push(e),()=>{const t=this.callbacks.after_navigate.indexOf(e);this.callbacks.after_navigate.splice(t,1)}))}before_navigate(e){M(()=>(this.callbacks.before_navigate.push(e),()=>{const t=this.callbacks.before_navigate.indexOf(e);this.callbacks.before_navigate.splice(t,1)}))}async _navigate({url:e,scroll:t,keepfocus:i,chain:l,details:r,accepted:o,blocked:s}){const n=this.renderer.current.url;let c=!1;const f={from:n,to:e,cancel:()=>c=!0};if(this.callbacks.before_navigate.forEach(d=>d(f)),c){s();return}const h=this.parse(e);if(!h)return location.href=e.href,new Promise(()=>{});o(),this.navigating||dispatchEvent(new CustomEvent("sveltekit:navigation-start")),this.navigating++;let{pathname:u}=e;if(this.trailing_slash==="never"?u!=="/"&&u.endsWith("/")&&(u=u.slice(0,-1)):this.trailing_slash==="always"&&!e.pathname.split("/").pop().includes(".")&&!u.endsWith("/")&&(u+="/"),h.url=new URL(e.origin+u+e.search+e.hash),r){const d=r.replaceState?0:1;r.state["sveltekit:index"]=this.current_history_index+=d,history[r.replaceState?"replaceState":"pushState"](r.state,"",h.url)}if(await this.renderer.handle_navigation(h,l,!1,{scroll:t,keepfocus:i}),this.navigating--,!this.navigating){dispatchEvent(new CustomEvent("sveltekit:navigation-end"));const d={from:n,to:e};this.callbacks.after_navigate.forEach(y=>y(d))}}}function se(a){return a instanceof Error||a&&a.name&&a.message?a:new Error(JSON.stringify(a))}function xe(a){let e=5381,t=a.length;if(typeof a=="string")for(;t;)e=e*33^a.charCodeAt(--t);else for(;t;)e=e*33^a[--t];return(e>>>0).toString(36)}function Ie(a){const e=a.status&&a.status>=400&&a.status<=599&&!a.redirect;if(a.error||e){const t=a.status;if(!a.error&&e)return{status:t||500,error:new Error};const i=typeof a.error=="string"?new Error(a.error):a.error;return i instanceof Error?!t||t<400||t>599?(console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500'),{status:500,error:i}):{status:t,error:i}:{status:500,error:new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof i}"`)}}if(a.redirect){if(!a.status||Math.floor(a.status/100)!==3)return{status:500,error:new Error('"redirect" property returned from load() must be accompanied by a 3xx status code')};if(typeof a.redirect!="string")return{status:500,error:new Error('"redirect" property returned from load() must be a string')}}if(a.context)throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.');return a}function re(a){const e=W(a);let t=!0;function i(){t=!0,e.update(o=>o)}function l(o){t=!1,e.set(o)}function r(o){let s;return e.subscribe(n=>{(s===void 0||t&&n!==s)&&o(s=n)})}return{notify:i,set:l,subscribe:r}}function Ve(a,e){const t=typeof a=="string"?a:a.url;let i=`script[data-type="svelte-data"][data-url=${JSON.stringify(t)}]`;e&&typeof e.body=="string"&&(i+=`[data-body="${xe(e.body)}"]`);const l=document.querySelector(i);if(l&&l.textContent){const r=JSON.parse(l.textContent),{body:o}=r,s=F(r,["body"]);return Promise.resolve(new Response(o,s))}return fetch(a,e)}class Ce{constructor({Root:e,fallback:t,target:i,session:l}){this.Root=e,this.fallback=t,this.router,this.target=i,this.started=!1,this.session_id=1,this.invalid=new Set,this.invalidating=null,this.autoscroll=!0,this.updating=!1,this.current={url:null,session_id:0,branch:[]},this.cache=new Map,this.loading={id:null,promise:null},this.stores={url:re({}),page:re({}),navigating:W(null),session:W(l)},this.$session=null,this.root=null;let r=!1;this.stores.session.subscribe(async o=>{if(this.$session=o,!r||!this.router)return;this.session_id+=1;const s=this.router.parse(new URL(location.href));s&&this.update(s,[],!0)}),r=!0}disable_scroll_handling(){(this.updating||!this.started)&&(this.autoscroll=!1)}async start({status:e,error:t,nodes:i,url:l,params:r}){const o=[];let s={},n,c;l.hash=window.location.hash;try{for(let f=0;f<i.length;f+=1){const h=f===i.length-1,u=await this._load_node({module:await i[f],url:l,params:r,stuff:s,status:h?e:void 0,error:h?t:void 0});if(o.push(u),u&&u.loaded)if(u.loaded.error){if(t)throw u.loaded.error;c={status:u.loaded.status,error:u.loaded.error,url:l}}else u.loaded.stuff&&(s=v(v({},s),u.loaded.stuff))}n=c?await this._load_error(c):await this._get_navigation_result_from_branch({url:l,params:r,stuff:s,branch:o,status:e,error:t})}catch(f){if(t)throw f;n=await this._load_error({status:500,error:se(f),url:l})}if(n.redirect){location.href=new URL(n.redirect,location.href).href;return}this._init(n)}async handle_navigation(e,t,i,l){this.started&&this.stores.navigating.set({from:this.current.url,to:e.url}),await this.update(e,t,i,l)}async update(e,t,i,l){var n;const r=this.token={};let o=await this._get_navigation_result(e,i);if(r!==this.token)return;if(this.invalid.clear(),o.redirect)if(t.length>10||t.includes(e.url.pathname))o=await this._load_error({status:500,error:new Error("Redirect loop"),url:e.url});else{this.router?this.router.goto(new URL(o.redirect,e.url).href,{replaceState:!0},[...t,e.url.pathname]):location.href=new URL(o.redirect,location.href).href;return}if(this.updating=!0,this.started?(this.current=o.state,this.root.$set(o.props),this.stores.navigating.set(null)):this._init(o),l){const{scroll:c,keepfocus:f}=l;if(f||((n=getSelection())==null||n.removeAllRanges(),document.body.focus()),await H(),this.autoscroll){const h=e.url.hash&&document.getElementById(e.url.hash.slice(1));c?scrollTo(c.x,c.y):h?h.scrollIntoView():scrollTo(0,0)}}else await H();if(this.loading.promise=null,this.loading.id=null,this.autoscroll=!0,this.updating=!1,!this.router)return;const s=o.state.branch[o.state.branch.length-1];s&&s.module.router===!1?this.router.disable():this.router.enable()}load(e){return this.loading.promise=this._get_navigation_result(e,!1),this.loading.id=e.id,this.loading.promise}invalidate(e){return this.invalid.add(e),this.invalidating||(this.invalidating=Promise.resolve().then(async()=>{const t=this.router&&this.router.parse(new URL(location.href));t&&await this.update(t,[],!0),this.invalidating=null})),this.invalidating}_init(e){this.current=e.state;const t=document.querySelector("style[data-svelte]");if(t&&t.remove(),this.root=new this.Root({target:this.target,props:v({stores:this.stores},e.props),hydrate:!0}),this.started=!0,this.router){const i={from:null,to:new URL(location.href)};this.router.callbacks.after_navigate.forEach(l=>l(i))}}async _get_navigation_result(e,t){if(this.loading.id===e.id&&this.loading.promise)return this.loading.promise;for(let i=0;i<e.routes.length;i+=1){const l=e.routes[i];let r=i+1;for(;r<e.routes.length;){const s=e.routes[r];if(s[0].toString()===l[0].toString())s[1].forEach(n=>n()),r+=1;else break}const o=await this._load({route:l,info:e},t);if(o)return o}return await this._load_error({status:404,error:new Error(`Not found: ${e.url.pathname}`),url:e.url})}async _get_navigation_result_from_branch({url:e,params:t,stuff:i,branch:l,status:r,error:o}){const s=l.filter(Boolean),n=s.find(u=>u.loaded&&u.loaded.redirect),c={redirect:n&&n.loaded?n.loaded.redirect:void 0,state:{url:e,params:t,branch:l,session_id:this.session_id},props:{components:s.map(u=>u.module.default)}};for(let u=0;u<s.length;u+=1){const d=s[u].loaded;c.props[`props_${u}`]=d?await d.props:null}if(!this.current.url||e.href!==this.current.url.href){c.props.page={url:e,params:t,status:r,error:o,stuff:i};const u=(d,y)=>{Object.defineProperty(c.props.page,d,{get:()=>{throw new Error(`$page.${d} has been replaced by $page.url.${y}`)}})};u("origin","origin"),u("path","pathname"),u("query","searchParams")}const f=s[s.length-1],h=f.loaded&&f.loaded.maxage;if(h){const u=e.pathname+e.search;let d=!1;const y=()=>{this.cache.get(u)===c&&this.cache.delete(u),R(),clearTimeout(A)},A=setTimeout(y,h*1e3),R=this.stores.session.subscribe(()=>{d&&y()});d=!0,this.cache.set(u,c)}return c}async _load_node({status:e,error:t,module:i,url:l,params:r,stuff:o}){const s={module:i,uses:{params:new Set,url:!1,session:!1,stuff:!1,dependencies:[]},loaded:null,stuff:o},n={};for(const f in r)Object.defineProperty(n,f,{get(){return s.uses.params.add(f),r[f]},enumerable:!0});const c=this.$session;if(i.load){const{started:f}=this,h={params:n,get url(){return s.uses.url=!0,l},get session(){return s.uses.session=!0,c},get stuff(){return s.uses.stuff=!0,v({},o)},fetch(d,y){const A=typeof d=="string"?d:d.url,{href:R}=new URL(A,l);return s.uses.dependencies.push(R),f?fetch(d,y):Ve(d,y)}};t&&(h.status=e,h.error=t);const u=await i.load.call(null,h);if(!u)throw new Error("load function must return a value");s.loaded=Ie(u),s.loaded.stuff&&(s.stuff=s.loaded.stuff)}return s}async _load({route:e,info:{url:t,path:i}},l){const r=t.pathname+t.search;if(!l){const _=this.cache.get(r);if(_)return _}const[o,s,n,c]=e,f=c?c(o.exec(i)):{},h=this.current.url&&{url:r!==this.current.url.pathname+this.current.url.search,params:Object.keys(f).filter(_=>this.current.params[_]!==f[_]),session:this.session_id!==this.current.session_id};let u=[],d={},y=!1,A=200,R;s.forEach(_=>_());e:for(let _=0;_<s.length;_+=1){let p;try{if(!s[_])continue;const g=await s[_](),k=this.current.branch[_];if(!k||g!==k.module||h.url&&k.uses.url||h.params.some(q=>k.uses.params.has(q))||h.session&&k.uses.session||k.uses.dependencies.some(q=>this.invalid.has(q))||y&&k.uses.stuff){if(p=await this._load_node({module:g,url:t,params:f,stuff:d}),p&&p.loaded){if(p.loaded.fallthrough)return;if(p.loaded.error&&(A=p.loaded.status,R=p.loaded.error),p.loaded.redirect)return{redirect:p.loaded.redirect,props:{},state:this.current};p.loaded.stuff&&(y=!0)}}else p=k}catch(g){A=500,R=se(g)}if(R){for(;_--;)if(n[_]){let g,k,D=_;for(;!(k=u[D]);)D-=1;try{if(g=await this._load_node({status:A,error:R,module:await n[_](),url:t,params:f,stuff:k.stuff}),g&&g.loaded&&g.loaded.error)continue;g&&g.loaded&&g.loaded.stuff&&(d=v(v({},d),g.loaded.stuff)),u=u.slice(0,D+1).concat(g);break e}catch{continue}}return await this._load_error({status:A,error:R,url:t})}else p&&p.loaded&&p.loaded.stuff&&(d=v(v({},d),p.loaded.stuff)),u.push(p)}return await this._get_navigation_result_from_branch({url:t,params:f,stuff:d,branch:u,status:A,error:R})}async _load_error({status:e,error:t,url:i}){var c,f;const l={},r=await this._load_node({module:await this.fallback[0],url:i,params:l,stuff:{}}),o=await this._load_node({status:e,error:t,module:await this.fallback[1],url:i,params:l,stuff:r&&r.loaded&&r.loaded.stuff||{}}),s=[r,o],n=v(v({},(c=r==null?void 0:r.loaded)==null?void 0:c.stuff),(f=o==null?void 0:o.loaded)==null?void 0:f.stuff);return await this._get_navigation_result_from_branch({url:i,params:l,stuff:n,branch:s,status:e,error:t})}}async function Me({paths:a,target:e,session:t,route:i,spa:l,trailing_slash:r,hydrate:o}){const s=new Ce({Root:Ae,fallback:Ne,target:e,session:t}),n=i?new Pe({base:a.base,routes:Te,trailing_slash:r,renderer:s}):null;ve({router:n,renderer:s}),ye(a),o&&await s.start(o),n&&(l&&n.goto(location.href,{replaceState:!0},[]),n.init_listeners()),dispatchEvent(new CustomEvent("sveltekit:start"))}export{Me as start};
|