window.localize = function (key) {

  let language = window.language || 'en'; // Default to English

  console.log(window.language)

  // Handle language variations (e.g., en-US, en_US)

  language = language.replace(/-/g, "_").substring(0, 2); 

  if (!window.locales[language]) language = 'en'; // Fallback to English



  return window.locales[language][key] || key; // Return key if translation not found

};



$$('.switch-theme')['on']('click', function() {

  $$('.page')['toggleClass']('page-theme-transition'), $$('.page')['transitionEnd'](function() {

    $$('.page')['toggleClass']('page-theme-transition');

  }), $$('body')['hasClass']('dark') ? $$('.switch-theme i')['text']('moon_stars') : $$('.switch-theme i')['text']('sun_max'), $$('body')['toggleClass']('dark');

});

$$('.switch-theme')['on']('click', function() {

  window['parent']['postMessage']('switchTheme', window['location']['origin']);

});



$$(document)['on']('photobrowser:open photobrowser:close', function() {

  !$$('body')['hasClass']('dark') && window['parent']['postMessage']('switchTheme', window['location']['origin']);

});