import{a as e,n as t}from"./preload-helper-DxX6f4wy.js";import{$ as n,O as r,n as i,t as a}from"./Fade-Bj1YUcWe.js";import{n as o}from"./notistack.esm-Bl-G2Rx2.js";import{n as s,t as c}from"./Box-BoFhqo9n.js";import{n as l,t as u}from"./Switch-Dlo4qNYg.js";import{r as d}from"./siteStore-BLhBstND.js";import{t as f}from"./Loading-BIwVunRy.js";import{t as p}from"./FloatingSaveButton-Co5C3CHW.js";var m=e(t(),1),h=n();function g(){let{enqueueSnackbar:e}=o(),t=d(),[n,g]=(0,m.useState)(t.config.lazyLoadMedia??!1),[_,v]=(0,m.useState)(t.config.lazyLoadMedia??!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(!t.loaded);(0,m.useEffect)(()=>{t.loaded&&(S(!1),g(t.config.lazyLoadMedia??!1),v(t.config.lazyLoadMedia??!1))},[t.loaded,t.config.lazyLoadMedia]);let C=n!==_;return x?(0,h.jsx)(f,{}):(0,h.jsx)(a,{in:!0,timeout:400,children:(0,h.jsxs)(s,{elevation:0,sx:{p:{xs:2,sm:3},borderRadius:1,boxShadow:e=>e.palette.mode===`light`?`0 4px 20px ${r(e.palette.primary.main,.08)}`:`0 4px 20px ${r(e.palette.common.black,.25)}`},children:[(0,h.jsx)(i,{variant:`h6`,sx:{fontWeight:700,mb:3,overflowWrap:`break-word`},children:`高级设置`}),(0,h.jsxs)(c,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,h.jsx)(l,{control:(0,h.jsx)(u,{checked:n,onChange:e=>g(e.target.checked)}),label:`是否分次加载媒体资源`}),(0,h.jsx)(i,{variant:`body2`,color:`text.secondary`,sx:{overflowWrap:`break-word`},children:`开启后，大于 500KB 的大图片（文章封面、正文图片、主页背景、Logo 等）将在页面主要文字内容加载完成后，再按需要分批加载。这样可以加快首屏渲染速度，提升浏览体验；但图片请求会更多，可能多消耗 Worker 请求额度。媒体资源仍会通过浏览器缓存机制被缓存，重复访问时不会重复下载。`})]}),(0,h.jsx)(p,{show:C,saving:y,onClick:async()=>{b(!0);let r=await t.saveConfig({lazyLoadMedia:n});b(!1),r?(v(n),e(`高级设置已保存`,{variant:`success`})):e(`保存失败，请稍后再试`,{variant:`error`})},label:`保存设置`})]})})}export{g as AdvancedSettings};