const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./options-Ck3kAUGn.js","./options-CDXBc9UM.js","./i18n-BaLR3UdQ.js","./src-UeATgcQ9.js","./rolldown-runtime-DAXXjFlN.js","./preload-helper-HclGiUj8.js","./task_states-40T2foIO.js","./dayjs.min-yZk4pRyU.js","./isoWeek-DSe7EiHz.js","./server-BXh06Wz_.js","./server-BC1evlVM.js","./native_window-B_V4nijA.js","./native_window-BUR659UK.js","./app_context-DNW9JYBw.js","./content_renderer-DOj8g78V.js","./preact.module-CNakwbc9.js","./hooks.module-BrXTvcfS.js","./bootstrap.esm-DbsKxb7T.js","./purify.es-sLXpNpJ5.js","./toast-C6WyPqyA.js","./jsxRuntime.module-Cao1NCKs.js","./react_utils-Bz0ffU2Y.js","./color-name-DfaNrEqF.js","./content_renderer-Oq750FP_.css"])))=>i.map(i=>d[i]);
import{t as e}from"./preload-helper-HclGiUj8.js";function t(e,t){return new n(getComputedStyle(e).getPropertyValue(`--`+t))}var n=class e{value;constructor(e){this.value=e}asString(e){return this.value?this.value:e}asNumber(e){let t=NaN;return this.value&&(t=parseFloat(this.value)),isNaN(t.valueOf())?e:t.valueOf()}asBoolean(e){let t=this.value.toLocaleLowerCase().trim(),n;switch(t){case`true`:case`1`:n=!0;break;case`false`:case`0`:n=!1;break}return n===void 0?e:n}asEnum(e,t){let n;return n=e[this.value],n===void 0&&(n=t),n}asArray(t=` `){return this.value.split(t).map(t=>new e(t))}};function r(){let e=window.glob?.theme;if(e===`auto`||e===`next`)return`auto`;if(e===`light`||e===`dark`)return e;if(e===`next-light`)return`light`;if(e===`next-dark`)return`dark`;let t=window.getComputedStyle(document.body),n=t.getPropertyValue(`--theme-style`);return t.getPropertyValue(`--theme-style-auto`)!==`true`&&(n===`light`||n===`dark`)?n:`auto`}function i(){let e=r();return e===`auto`?window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e===`dark`?`dark`:`light`}var a=new Set([`auto`,`light`,`dark`,`next`,`next-light`,`next-dark`]),o=`data-theme-base`,s=`data-theme-stylesheet`;function c(e,t,n){return t===`auto`?[{href:`${e}/theme-dark.css`,media:`(prefers-color-scheme: dark)`}]:t===`dark`?[{href:`${e}/theme-dark.css`}]:t===`next`?[{href:`${e}/theme-next-light.css`},{href:`${e}/theme-next-dark.css`,media:`(prefers-color-scheme: dark)`}]:t===`next-light`?[{href:`${e}/theme-next-light.css`}]:t===`next-dark`?[{href:`${e}/theme-next-dark.css`}]:t!==`light`&&n?[{href:n}]:[]}function l(e,t,n){let r=`${window.glob.assetPath}/stylesheets`,i=c(r,e,t);return n&&i.push(...c(r,n)),i}function u(e,t){let n=document.createElement(`link`);return n.href=e.href,n.rel=`stylesheet`,e.media&&(n.media=e.media),t?.base&&n.setAttribute(o,`true`),t?.theme&&n.setAttribute(s,`true`),n}function d(){let e=t(document.body,`theme-style`).asString();document.body.classList.toggle(`light-theme`,e===`light`),document.body.classList.toggle(`dark-theme`,e===`dark`)}var f=!1;function p(e){f!==e&&(f=e,m())}function m(){let e=t(document.documentElement,`allow-background-effects`).asBoolean(!1);document.body.classList.toggle(`theme-supports-background-effects`,e&&!f)}async function h(){let{default:t}=await e(async()=>{let{default:e}=await import(`./options-Ck3kAUGn.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url),n=t.get(`theme`);if(a.has(n)){g(n);return}let{default:r}=await e(async()=>{let{default:e}=await import(`./server-BC1evlVM.js`);return{default:e}},__vite__mapDeps([10,9,5,2,3,4,6,7,8]),import.meta.url),i=await r.get(`options/user-themes`);if(t.get(`theme`)!==n)return;let o=i.find(e=>e.val===n);g(n,o?`api/notes/download/${o.noteId}`:void 0,o?.appThemeBase)}function g(t,n,r){let i={theme:window.glob.theme,customThemeCssUrl:window.glob.customThemeCssUrl,themeBase:window.glob.themeBase};window.glob.theme=t,window.glob.customThemeCssUrl=n,window.glob.themeBase=r;let a=l(t,n,r),c=Array.from(document.head.querySelectorAll(`link[${s}]`)),f=c.at(-1)??document.head.querySelector(`link[${o}]`),p=a.map(e=>{let t=u(e,{theme:!0});return f?f.after(t):document.head.appendChild(t),f=t,t});b(p).then(n=>{if(!n){for(let e of p)e.remove();window.glob.theme=i.theme,window.glob.customThemeCssUrl=i.customThemeCssUrl,window.glob.themeBase=i.themeBase;return}for(let e of c)e.remove();document.body.setAttribute(`data-theme-id`,t),d(),m(),v(),window.electronApi&&e(async()=>{let{syncNativeWindowWithTheme:e}=await import(`./native_window-B_V4nijA.js`);return{syncNativeWindowWithTheme:e}},__vite__mapDeps([11,12,1,2,3,4,5,6,7,8,9]),import.meta.url).then(({syncNativeWindowWithTheme:e})=>e())})}var _=null;function v(){let t=i();_=t,e(async()=>{let{default:e}=await import(`./app_context-DNW9JYBw.js`);return{default:e}},__vite__mapDeps([13,14,5,15,4,16,3,6,7,8,17,18,2,9,1,19,20,21,22,23]),import.meta.url).then(({default:e})=>{e.triggerEvent(`themeChanged`,{themeStyle:t})})}function y(){window.matchMedia&&(_=i(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{i()!==_&&v()}))}function b(e){return e.length===0?Promise.resolve(!0):new Promise(t=>{let n=e.length,r=!0,i=e=>{e.type===`error`&&(r=!1),n--,n<=0&&t(r)};for(let t of e)t.addEventListener(`load`,i,{once:!0}),t.addEventListener(`error`,i,{once:!0})})}export{r as a,d as c,i,m as l,l as n,y as o,u as r,p as s,h as t,t as u};