(() => {
  'use strict';
  const root=document.documentElement;
  const read=(keys)=>{try{for(const key of keys){const value=localStorage.getItem(key);if(value)return value;}}catch(_){}return null;};
  const themeSaved=read(['apu-ui-theme','apu-ui-theme-v5.6','apu-ui-theme-v5.5']);
  const langSaved=read(['apu-ui-language','apu-ui-language-v5.6','apu-ui-language-v5.5']);
  const supported=new Set(['id','en','ms','de','vi','zh','ja']);
  const browser=(navigator.language||'en').toLowerCase().split('-')[0];
  const theme=['light','dark'].includes(themeSaved)?themeSaved:(matchMedia?.('(prefers-color-scheme: dark)').matches?'dark':'light');
  const language=supported.has(langSaved)?langSaved:(supported.has(browser)?browser:'en');
  root.dataset.apuTheme=theme;root.dataset.apuEmbedded=String(window.self!==window.top);root.dataset.apuLanguage=language;root.dataset.apuMonochrome='true';root.lang=language;root.dir='ltr';root.style.colorScheme=theme;root.classList.toggle('dark',theme==='dark');
  root.classList.add('apu-theme-bootstrapped');
})();
