text: var t=Object.defineProperty,e=Object.defineProperties,r=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,a=(e,r,s)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,i=(t,e)=>{for(var r in e||(e={}))o.call(e,r)&&a(t,r,e[r]);if(s)for(var r of s(e))n.call(e,r)&&a(t,r,e[r]);return t};import{S as l,i as c,s as u,e as h,c as d,a as p,d as f,b as g,f as m,t as y,g as _,h as v,j as b,k as $,l as w,m as E,n as x,o as q,p as R,q as S,r as L,u as k,v as O,w as U,x as j,y as P,z as A,A as T,B as C,C as I}from"./chunks/vendor-b08e9467.js";import{s as N}from"./chunks/paths-45dac81d.js";function D(t){let e,r,s;const o=[t[2]||{}];var n=t[0][1];function a(t){let e={$$slots:{default:[B]},$$scope:{ctx:t}};for(let r=0;r<o.length;r+=1)e=T(e,o[r]);return{props:e}}return n&&(e=new n(a(t))),{c(){e&&b(e.$$.fragment),r=w()},l(t){e&&E(e.$$.fragment,t),r=w()},m(t,o){e&&q(e,t,o),m(t,r,o),s=!0},p(t,s){const i=4&s?R(o,[S(t[2]||{})]):{};if(521&s&&(i.$$scope={dirty:s,ctx:t}),n!==(n=t[0][1])){if(e){C();const t=e;L(t.$$.fragment,1,0,(()=>{U(t,1)})),k()}n?(e=new n(a(t)),b(e.$$.fragment),O(e.$$.fragment,1),q(e,r.parentNode,r)):e=null}else n&&e.$set(i)},i(t){s||(e&&O(e.$$.fragment,t),s=!0)},o(t){e&&L(e.$$.fragment,t),s=!1},d(t){t&&f(r),e&&U(e,t)}}}function V(t){let e,r,s;const o=[t[3]||{}];var n=t[0][2];function a(t){let e={};for(let r=0;r<o.length;r+=1)e=T(e,o[r]);return{props:e}}return n&&(e=new n(a())),{c(){e&&b(e.$$.fragment),r=w()},l(t){e&&E(e.$$.fragment,t),r=w()},m(t,o){e&&q(e,t,o),m(t,r,o),s=!0},p(t,s){const i=8&s?R(o,[S(t[3]||{})]):{};if(n!==(n=t[0][2])){if(e){C();const t=e;L(t.$$.fragment,1,0,(()=>{U(t,1)})),k()}n?(e=new n(a()),b(e.$$.fragment),O(e.$$.fragment,1),q(e,r.parentNode,r)):e=null}else n&&e.$set(i)},i(t){s||(e&&O(e.$$.fragment,t),s=!0)},o(t){e&&L(e.$$.fragment,t),s=!1},d(t){t&&f(r),e&&U(e,t)}}}function B(t){let e,r,s=t[0][2]&&V(t);return{c(){s&&s.c(),e=w()},l(t){s&&s.l(t),e=w()},m(t,o){s&&s.m(t,o),m(t,e,o),r=!0},p(t,r){t[0][2]?s?(s.p(t,r),1&r&&O(s,1)):(s=V(t),s.c(),O(s,1),s.m(e.parentNode,e)):s&&(C(),L(s,1,1,(()=>{s=null})),k())},i(t){r||(O(s),r=!0)},o(t){L(s),r=!1},d(t){s&&s.d(t),t&&f(e)}}}function K(t){let e,r,s=t[0][1]&&D(t);return{c(){s&&s.c(),e=w()},l(t){s&&s.l(t),e=w()},m(t,o){s&&s.m(t,o),m(t,e,o),r=!0},p(t,r){t[0][1]?s?(s.p(t,r),1&r&&O(s,1)):(s=D(t),s.c(),O(s,1),s.m(e.parentNode,e)):s&&(C(),L(s,1,1,(()=>{s=null})),k())},i(t){r||(O(s),r=!0)},o(t){L(s),r=!1},d(t){s&&s.d(t),t&&f(e)}}}function W(t){let e,r=t[5]&&M(t);return{c(){e=h("div"),r&&r.c(),this.h()},l(t){e=d(t,"DIV",{id:!0,"aria-live":!0,"aria-atomic":!0,class:!0});var s=p(e);r&&r.l(s),s.forEach(f),this.h()},h(){g(e,"id","svelte-announcer"),g(e,"aria-live","assertive"),g(e,"aria-atomic","true"),g(e,"class","svelte-1pdgbjn")},m(t,s){m(t,e,s),r&&r.m(e,null)},p(t,s){t[5]?r?r.p(t,s):(r=M(t),r.c(),r.m(e,null)):r&&(r.d(1),r=null)},d(t){t&&f(e),r&&r.d()}}}function M(t){let e;return{c(){e=y(t[6])},l(r){e=_(r,t[6])},m(t,r){m(t,e,r)},p(t,r){64&r&&v(e,t[6])},d(t){t&&f(e)}}}function Y(t){let e,r,s,o;const n=[t[1]||{}];var a=t[0][0];function i(t){let e={$$slots:{default:[K]},$$scope:{ctx:t}};for(let r=0;r<n.length;r+=1)e=T(e,n[r]);return{props:e}}a&&(e=new a(i(t)));let l=t[4]&&W(t);return{c(){e&&b(e.$$.fragment),r=$(),l&&l.c(),s=w()},l(t){e&&E(e.$$.fragment,t),r=x(t),l&&l.l(t),s=w()},m(t,n){e&&q(e,t,n),m(t,r,n),l&&l.m(t,n),m(t,s,n),o=!0},p(t,[o]){const c=2&o?R(n,[S(t[1]||{})]):{};if(525&o&&(c.$$scope={dirty:o,ctx:t}),a!==(a=t[0][0])){if(e){C();const t=e;L(t.$$.fragment,1,0,(()=>{U(t,1)})),k()}a?(e=new a(i(t)),b(e.$$.fragment),O(e.$$.fragment,1),q(e,r.parentNode,r)):e=null}else a&&e.$set(c);t[4]?l?l.p(t,o):(l=W(t),l.c(),l.m(s.parentNode,s)):l&&(l.d(1),l=null)},i(t){o||(e&&O(e.$$.fragment,t),o=!0)},o(t){e&&L(e.$$.fragment,t),o=!1},d(t){e&&U(e,t),t&&f(r),l&&l.d(t),t&&f(s)}}}function z(t,e,r){let{stores:s}=e,{page:o}=e,{components:n}=e,{props_0:a=null}=e,{props_1:i=null}=e,{props_2:l=null}=e;j("__svelte__",s),P(s.page.notify);let c=!1,u=!1,h=null;return A((()=>{const t=s.page.subscribe((()=>{c&&(r(5,u=!0),r(6,h=document.title||"untitled page"))}));return r(4,c=!0),t})),t.$$set=t=>{"stores"in t&&r(7,s=t.stores),"page"in t&&r(8,o=t.page),"components"in t&&r(0,n=t.components),"props_0"in t&&r(1,a=t.props_0),"props_1"in t&&r(2,i=t.props_1),"props_2"in t&&r(3,l=t.props_2)},t.$$.update=()=>{384&t.$$.dirty&&s.page.set(o)},[n,a,i,l,c,u,h,s,o]}class G extends l{constructor(t){super(),c(this,t,z,Y,u,{stores:7,page:8,components:0,props_0:1,props_1:2,props_2:3})}}let J;const X={},F=function(t,e){if(!e)return t();if(void 0===J){const t=document.createElement("link").relList;J=t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(e.map((t=>{if(t in X)return;X[t]=!0;const e=t.endsWith(".css"),r=e?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${t}"]${r}`))return;const s=document.createElement("link");return s.rel=e?"stylesheet":J,e||(s.as="script",s.crossOrigin=""),s.href=t,document.head.appendChild(s),e?new Promise(((t,e)=>{s.addEventListener("load",t),s.addEventListener("error",e)})):void 0}))).then((()=>t()))},H=[()=>F((()=>import("./pages/__layout.svelte-6a5f2038.js")),["/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/pages/__layout.svelte-6a5f2038.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/assets/pages/__layout.svelte-4bdaa429.css","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/vendor-b08e9467.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/countriesStore-83b174d6.js"]),()=>F((()=>import("./error.svelte-479697a1.js")),["/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/error.svelte-479697a1.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/vendor-b08e9467.js"]),()=>F((()=>import("./pages/index.svelte-9e7c13f3.js")),["/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/pages/index.svelte-9e7c13f3.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/vendor-b08e9467.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/paths-45dac81d.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/countriesStore-83b174d6.js"]),()=>F((()=>import("./pages/[slug].svelte-3f6517b0.js")),["/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/pages/[slug].svelte-3f6517b0.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/vendor-b08e9467.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/paths-45dac81d.js","/frontendmentor.io/challenges/rest-countries-api-with-color-theme-switcher/build/_app/chunks/countriesStore-83b174d6.js"])],Q=decodeURIComponent,Z=[[/^\/$/,[H[0],H[2]],[H[1]]],[/^\/countriesStore\/?$/],[/^\/([^/]+?)\/?$/,[H[0],H[3]],[H[1]],t=>({slug:Q(t[1])})]],tt=[H[0](),H[1]()];function et(){return{x:pageXOffset,y:pageYOffset}}function rt(t){for(;t&&"A"!==t.nodeName.toUpperCase();)t=t.parentNode;return t}class st{constructor({base:t,routes:e,trailing_slash:r}){this.base=t,this.routes=e,this.trailing_slash=r}init(t){let s;this.renderer=t,t.router=this,this.enabled=!0,"scrollRestoration"in history&&(history.scrollRestoration="manual"),addEventListener("beforeunload",(()=>{history.scrollRestoration="auto"})),addEventListener("load",(()=>{history.scrollRestoration="manual"})),addEventListener("scroll",(()=>{clearTimeout(s),s=setTimeout((()=>{const t=(s=i({},history.state||{}),o={"sveltekit:scroll":et()},e(s,r(o)));var s,o;history.replaceState(t,document.title,window.location.href)}),50)}));const o=t=>{const e=rt(t.target);e&&e.href&&e.hasAttribute("sveltekit:prefetch")&&this.prefetch(new URL(e.href))};let n;addEventListener("touchstart",o),addEventListener("mousemove",(t=>{clearTimeout(n),n=setTimeout((()=>{o(t)}),20)})),addEventListener("click",(t=>{var e;if(!this.enabled)return;if(t.button||1!==t.which)return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;if(t.defaultPrevented)return;const r=rt(t.target);if(!r)return;if(!r.href)return;const s="object"==typeof r.href&&"SVGAnimatedString"===r.href.constructor.name,o=String(s?r.href.baseVal:r.href);if(o===location.href)return void(location.hash||t.preventDefault());const n=null==(e=r.getAttribute("rel"))?void 0:e.split(/\s+/);if(r.hasAttribute("download")||n&&n.includes("external"))return;if(s?r.target.baseVal:r.target)return;const a=new URL(o);if(!this.owns(a))return;const i=r.hasAttribute("sveltekit:noscroll");history.pushState({},"",a.href),this._navigate(a,i?et():null,[],a.hash),t.preventDefault()})),addEventListener("popstate",(t=>{if(t.state&&this.enabled){const e=new URL(location.href);this._navigate(e,t.state["sveltekit:scroll"],[])}})),document.body.setAttribute("tabindex","-1"),history.replaceState(history.state||{},"",location.href)}owns(t){return t.origin===location.origin&&t.pathname.startsWith(this.base)}parse(t){if(this.owns(t)){const e=decodeURIComponent(t.pathname.slice(this.base.length)||"/"),r=this.routes.filter((([t])=>t.test(e))),s=new URLSearchParams(t.search);return{id:`${e}?${s}`,routes:r,path:e,query:s}}}async goto(t,{noscroll:e=!1,replaceState:r=!1}={},s){const o=new URL(t,function(t){let e=t.baseURI;if(!e){const r=t.getElementsByTagName("base");e=r.length?r[0].href:t.URL}return e}(document));return this.enabled&&this.owns(o)?(history[r?"replaceState":"pushState"]({},"",t),this._navigate(o,e?et():null,s,o.hash)):(location.href=o.href,new Promise((()=>{})))}enable(){this.enabled=!0}disable(){this.enabled=!1}async prefetch(t){const e=this.parse(t);if(!e)throw new Error("Attempted to prefetch a URL that does not belong to this app");return this.renderer.load(e)}async _navigate(t,e,r,s){const o=this.parse(t);if(!o)throw new Error("Attempted to navigate to a URL that does not belong to this app");if("/"!==o.path){const t=o.path.endsWith("/");(t&&"never"===this.trailing_slash||!t&&"always"===this.trailing_slash&&!o.path.split("/").pop().includes("."))&&(o.path=t?o.path.slice(0,-1):o.path+"/",history.replaceState({},"",`${o.path}${location.search}`))}this.renderer.notify({path:o.path,query:o.query}),await this.renderer.update(o,r,!1),document.body.focus();const n=s&&document.getElementById(s.slice(1));e?scrollTo(e.x,e.y):n?scrollTo(0,n.getBoundingClientRect().top+scrollY):scrollTo(0,0)}}function ot(t){const e=I(t);let r=!0;return{notify:function(){r=!0,e.update((t=>t))},set:function(t){r=!1,e.set(t)},subscribe:function(t){let s;return e.subscribe((e=>{(void 0===s||r&&e!==s)&&t(s=e)}))}}}function nt(t,e){let r=`script[type="svelte-data"][url="${"string"==typeof t?t:t.url}"]`;e&&"string"==typeof e.body&&(r+=`[body="${function(t){let e=5381,r=t.length;if("string"==typeof t)for(;r;)e=33*e^t.charCodeAt(--r);else for(;r;)e=33*e^t[--r];return(e>>>0).toString(36)}(e.body)}"]`);const a=document.querySelector(r);if(a){const t=JSON.parse(a.textContent),{body:e}=t,r=((t,e)=>{var r={};for(var a in t)o.call(t,a)&&e.indexOf(a)<0&&(r[a]=t[a]);if(null!=t&&s)for(var a of s(t))e.indexOf(a)<0&&n.call(t,a)&&(r[a]=t[a]);return r})(t,["body"]);return Promise.resolve(new Response(e,r))}return fetch(t,e)}class at{constructor({Root:t,fallback:e,target:r,session:s,host:o}){this.Root=t,this.fallback=e,this.host=o,this.router=null,this.target=r,this.started=!1,this.session_id=1,this.invalid=new Set,this.invalidating=null,this.current={page:null,session_id:null,branch:[]},this.cache=new Map,this.loading={id:null,promise:null},this.stores={page:ot({}),navigating:I(null),session:I(s)},this.$session=null,this.root=null;let n=!1;this.stores.session.subscribe((async t=>{if(this.$session=t,!n)return;this.session_id+=1;const e=this.router.parse(new URL(location.href));this.update(e,[],!0)})),n=!0}async start({status:t,error:e,nodes:r,page:s}){const o=[];let n,a,l,c={};try{for(let n=0;n<r.length;n+=1){const u=n===r.length-1,h=await this._load_node({module:await r[n],page:s,context:c,status:u&&t,error:u&&e});if(o.push(h),h&&h.loaded)if(h.loaded.error){if(e)throw h.loaded.error;a=h.loaded.status,l=h.loaded.error}else h.loaded.context&&(c=i(i({},c),h.loaded.context))}n=await this._get_navigation_result_from_branch({page:s,branch:o})}catch(u){if(e)throw u;a=500,l=u}l&&(n=await this._load_error({status:a,error:l,path:s.path,query:s.query})),n.redirect?location.href=new URL(n.redirect,location.href).href:this._init(n)}notify({path:t,query:e}){dispatchEvent(new CustomEvent("sveltekit:navigation-start")),this.started&&this.stores.navigating.set({from:{path:this.current.page.path,query:this.current.page.query},to:{path:t,query:e}})}async update(t,e,r){const s=this.token={};let o=await this._get_navigation_result(t,r);if(s!==this.token)return;if(this.invalid.clear(),o.redirect){if(!(e.length>10||e.includes(t.path)))return void(this.router?this.router.goto(o.redirect,{replaceState:!0},[...e,t.path]):location.href=new URL(o.redirect,location.href).href);o=await this._load_error({status:500,error:new Error("Redirect loop"),path:t.path,query:t.query})}o.reload?location.reload():this.started?(this.current=o.state,this.root.$set(o.props),this.stores.navigating.set(null),await 0):this._init(o),dispatchEvent(new CustomEvent("sveltekit:navigation-end")),this.loading.promise=null,this.loading.id=null;const n=o.state.branch[o.state.branch.length-1];n&&!1===n.module.router?this.router.disable():this.router.enable()}load(t){return this.loading.promise=this._get_navigation_result(t,!1),this.loading.id=t.id,this.loading.promise}invalidate(t){return this.invalid.add(t),this.invalidating||(this.invalidating=Promise.resolve().then((async()=>{const t=this.router.parse(new URL(location.href));await this.update(t,[],!0),this.invalidating=null}))),this.invalidating}_init(t){this.current=t.state;const e=document.querySelector("style[data-svelte]");e&&e.remove(),this.root=new this.Root({target:this.target,props:i({stores:this.stores},t.props),hydrate:!0}),this.started=!0}async _get_navigation_result(t,e){if(this.loading.id===t.id)return this.loading.promise;for(let r=0;r<t.routes.length;r+=1){const s=t.routes[r];if(1===s.length)return{reload:!0};let o=r+1;for(;o<t.routes.length;){const e=t.routes[o];if(e[0].toString()!==s[0].toString())break;1!==e.length&&e[1].forEach((t=>t())),o+=1}const n=await this._load({route:s,path:t.path,query:t.query},e);if(n)return n}return await this._load_error({status:404,error:new Error(`Not found: ${t.path}`),path:t.path,query:t.query})}async _get_navigation_result_from_branch({page:t,branch:e}){const r=e.filter(Boolean),s={state:{page:t,branch:e,session_id:this.session_id},props:{components:r.map((t=>t.module.default))}};for(let a=0;a<r.length;a+=1)r[a].loaded&&(s.props[`props_${a}`]=await r[a].loaded.props);this.current.page&&t.path===this.current.page.path&&t.query.toString()===this.current.page.query.toString()||(s.props.page=t);const o=r[r.length-1],n=o.loaded&&o.loaded.maxage;if(n){const e=`${t.path}?${t.query}`;let r=!1;const o=()=>{this.cache.get(e)===s&&this.cache.delete(e),i(),clearTimeout(a)},a=setTimeout(o,1e3*n),i=this.stores.session.subscribe((()=>{r&&o()}));r=!0,this.cache.set(e,s)}return s}async _load_node({status:t,error:e,module:r,page:s,context:o}){const n={module:r,uses:{params:new Set,path:!1,query:!1,session:!1,context:!1,dependencies:[]},loaded:null,context:o},a={};for(const i in s.params)Object.defineProperty(a,i,{get:()=>(n.uses.params.add(i),s.params[i]),enumerable:!0});const l=this.$session;if(r.load){const{started:c}=this,u={page:{host:s.host,params:a,get path(){return n.uses.path=!0,s.path},get query(){return n.uses.query=!0,s.query}},get session(){return n.uses.session=!0,l},get context(){return n.uses.context=!0,i({},o)},fetch(t,e){const r="string"==typeof t?t:t.url,{href:o}=new URL(r,new URL(s.path,document.baseURI));return n.uses.dependencies.push(o),c?fetch(t,e):nt(t,e)}};e&&(u.status=t,u.error=e);const h=await r.load.call(null,u);if(!h)return;n.loaded=function(t){if(t.error){const e="string"==typeof t.error?new Error(t.error):t.error,r=t.status;return e instanceof Error?!r||r<400||r>599?(console.warn('"error" returned from load() without a valid status code — defaulting to 500'),{status:500,error:e}):{status:r,error:e}:{status:500,error:new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof e}"`)}}if(t.redirect){if(!t.status||3!==Math.floor(t.status/100))return{status:500,error:new Error('"redirect" property returned from load() must be accompanied by a 3xx status code')};if("string"!=typeof t.redirect)return{status:500,error:new Error('"redirect" property returned from load() must be a string')}}return t}(h),n.loaded.context&&(n.context=n.loaded.context)}return n}async _load({route:t,path:e,query:r},s){const o=`${e}?${r}`;if(!s&&this.cache.has(o))return this.cache.get(o);const[n,a,l,c]=t,u=c?c(n.exec(e)):{},h=this.current.page&&{path:e!==this.current.page.path,params:Object.keys(u).filter((t=>this.current.page.params[t]!==u[t])),query:r.toString()!==this.current.page.query.toString(),session:this.session_id!==this.current.session_id},d={host:this.host,path:e,query:r,params:u},p=[];let f={},g=!1,m=200,y=null;a.forEach((t=>t()));t:for(let v=0;v<a.length;v+=1){let t;try{if(!a[v])continue;const e=await a[v](),r=this.current.branch[v];if(!r||e!==r.module||h.path&&r.uses.path||h.params.some((t=>r.uses.params.has(t)))||h.query&&r.uses.query||h.session&&r.uses.session||r.uses.dependencies.some((t=>this.invalid.has(t)))||g&&r.uses.context){t=await this._load_node({module:e,page:d,context:f});const r=v===a.length-1;if(t&&t.loaded){if(t.loaded.error&&(m=t.loaded.status,y=t.loaded.error),t.loaded.redirect)return{redirect:t.loaded.redirect};t.loaded.context&&(g=!0)}else if(r&&e.load)return}else t=r}catch(_){m=500,y=_}if(y){for(;v--;)if(l[v]){let t,e,r=v;for(;!(e=p[r]);)r-=1;try{if(t=await this._load_node({status:m,error:y,module:await l[v](),page:d,context:e.context}),t.loaded.error)continue;p.push(t);break t}catch(_){continue}}return await this._load_error({status:m,error:y,path:e,query:r})}t&&t.loaded&&t.loaded.context&&(f=i(i({},f),t.loaded.context)),p.push(t)}return await this._get_navigation_result_from_branch({page:d,branch:p})}async _load_error({status:t,error:e,path:r,query:s}){const o={host:this.host,path:r,query:s,params:{}},n=await this._load_node({module:await this.fallback[0],page:o,context:{}}),a=[n,await this._load_node({status:t,error:e,module:await this.fallback[1],page:o,context:n&&n.loaded&&n.loaded.context})];return await this._get_navigation_result_from_branch({page:o,branch:a})}}async function it({paths:t,target:e,session:r,host:s,route:o,spa:n,trailing_slash:a,hydrate:i}){const l=o&&new st({base:t.base,routes:Z,trailing_slash:a}),c=new at({Root:G,fallback:tt,target:e,session:r,host:s});N(t),i&&await c.start(i),o&&l.init(c),n&&l.goto(location.href,{replaceState:!0},[]),dispatchEvent(new CustomEvent("sveltekit:start"))}export{it as start};
  