import{m as e}from"./CrashPanel-Di_mLyQI.js";var t=[{id:`chi_sim_eng`,code:`chi_sim+eng`,labelKey:`langZhEn`,approxMb:4},{id:`eng`,code:`eng`,labelKey:`langEn`,approxMb:2}],n=t[0].id;function r(e){return t.find(t=>t.id===e)??t[0]}var i={langId:n,preserveLineBreaks:!0},a=`ocr.settings.v1`;function o(e){let t=e&&typeof e==`object`?e:{};return{langId:r(typeof t.langId==`string`?t.langId:``).id,preserveLineBreaks:typeof t.preserveLineBreaks==`boolean`?t.preserveLineBreaks:i.preserveLineBreaks}}function s(e){let t=e&&typeof e==`object`?e:{},n=typeof t.v==`number`?t.v:0;return{settings:o(`settings`in t&&t.settings&&typeof t.settings==`object`?t.settings:t),future:n>1}}async function c(){try{let t=(await e.storage.sync.get(a))[a];return s(t).settings}catch{return i}}async function l(t){let n=(await e.storage.sync.get(a))[a],{settings:r,future:i}=s(n);if(i)throw Error(`settings were written by a newer version; refusing to overwrite`);let c=o({...r,...t});try{await e.storage.sync.set({[a]:{v:1,...c}})}catch(e){throw Error(`failed to save settings: ${e instanceof Error?e.message:String(e)}`)}return c}export{r as a,t as i,l as n,n as r,c as t};