import{h as g,m as L,g as e,j as a}from"./qex-fw8l.js";import{g as b}from"./B4Sratiw.js";import{s as _,a as w}from"./dc0o8kHW.js";const p=_("grav_admin_content_lang");function h(){try{const o=localStorage.getItem(p);return o?JSON.parse(o):{}}catch{return{}}}function I(){const o=h();let l=g(!1),s=g(L([])),u=g(""),n=g(L(o.activeLang??"")),i=g(!1),c=g(!1);function f(){localStorage.setItem(p,JSON.stringify({activeLang:e(n)}))}async function m(){if(!e(i)){a(i,!0);try{const t=await b();a(l,t.enabled,!0),a(s,t.languages,!0),a(u,t.default??"",!0);const r=t.languages.map(d=>d.code);(!e(n)||!r.includes(e(n)))&&a(n,e(u),!0),f(),a(c,!0)}catch{a(l,!1),a(c,!0)}finally{a(i,!1)}}}typeof window<"u"&&w.subscribe("config:update:system",()=>{m()});function y(t){a(n,t,!0),f()}function v(t){const r=e(s).find(d=>d.code===t);return r?.native_name??r?.name??t}function S(t){return e(s).find(r=>r.code===t)}return{get enabled(){return e(l)},get languages(){return e(s)},get defaultLang(){return e(u)},get activeLang(){return e(n)},get loading(){return e(i)},get loaded(){return e(c)},get isDefault(){return e(n)===e(u)},load:m,setLanguage:y,getLanguageName:v,getLanguageInfo:S}}const C=I();export{C as c};
