import{v as u,w as d,x as a}from"./index-DiFbo-KR.js";import{Q as c}from"./qq_manager-CAXiLpho.js";const f=r=>JSON.parse(JSON.stringify(r)),p=d.withTypes(),k=u.withTypes(),D=()=>{const r=k(n=>n.config.value),i=p();return{config:r,createNetworkConfig:async(n,t)=>{const e=Object.keys(r.network).reduce((s,w)=>{const g=w;return s.concat(r.network[g].map(C=>C.name))},[]);if(t.name&&e.includes(t.name))throw new Error("已经存在相同的配置项名");const o=f(r);return o.network[n].push(t),await c.setOB11Config(o),i(a(o)),o},refreshConfig:async()=>{const n=await c.getOB11Config();return JSON.stringify(n)===JSON.stringify(r)?r:(i(a(n)),n)},updateConfig:async n=>(await c.setOB11Config(n),i(a(n)),n),updateSingleConfig:async(n,t)=>{const e=f(r);return e[n]=t,await c.setOB11Config(e),i(a(e)),e},updateNetworkConfig:async(n,t)=>{const e=f(r),o=t.name,s=e.network[n].findIndex(w=>w.name===o);if(s===-1)throw new Error("找不到对应的配置项");return e.network[n][s]=t,await c.setOB11Config(e),i(a(e)),e},deleteNetworkConfig:async(n,t)=>{const e=f(r),o=e.network[n].findIndex(s=>s.name===t);if(o===-1)throw new Error("找不到对应的配置项");return e.network[n].splice(o,1),await c.setOB11Config(e),i(a(e)),e},enableNetworkConfig:async(n,t)=>{const e=f(r),o=e.network[n].findIndex(s=>s.name===t);if(o===-1)throw new Error("找不到对应的配置项");return e.network[n][o].enable=!e.network[n][o].enable,await c.setOB11Config(e),i(a(e)),e},enableDebugNetworkConfig:async(n,t)=>{const e=f(r),o=e.network[n].findIndex(s=>s.name===t);if(o===-1)throw new Error("找不到对应的配置项");return e.network[n][o].debug=!e.network[n][o].debug,await c.setOB11Config(e),i(a(e)),e},mergeConfig:async n=>{const t=f(r);return Object.assign(t,n),await c.setOB11Config(t),i(a(t)),t},saveConfigWithoutNetwork:async n=>(n.network=r.network,await c.setOB11Config(n),i(a(n)),n)}};export{D as u};
