1import{a as e,j as s}from"./index-BtP4ZitF.js";import{B as r,T as t,S as n,a as o,Q as l,A as a,C as i,f as c,O as d,R as u}from"./blog-global-BNBqZpI4.js";import{B as h}from"./BlogAdminPanel-Dw7FjT2s.js";import{b as x}from"./blogApi-DFb6QasF.js";import{L as p}from"./chunk-6CSD65Y2-hEUdZ8zr.js";import{S as m,T as j,C as f,L as g,A as b}from"./App-DmIfUK_-.js";import"./useThemeProps--UrLtM9T.js";import"./defaultTheme-BCJNRUh8.js";import"./extendTheme-CMB3d7Oa.js";import"./index-CwGZYLJ_.js";/* empty css */import"./AuthContext-D9iFLlkA.js";import"./popperModifiers-D7eKjI1Z.js";const w={running:!1,startedAt:null,finishedAt:null,logs:[],progress:{index:0,total:0,pathname:null},lastError:null};function v(e){switch(e){case"ok":return s.jsx(f,{size:"sm",color:"success",variant:"soft",children:"SSG â"});case"stale":return s.jsx(f,{size:"sm",color:"warning",variant:"soft",children:"SSG ÑÑÑаÑел"});case"missing":return s.jsx(f,{size:"sm",color:"danger",variant:"soft",children:"ÐÐµÑ SSG"});case"unknown":return s.jsx(f,{size:"sm",color:"neutral",variant:"soft",children:"SSG ?"});default:return s.jsx(t,{level:"body-xs",sx:{color:"neutral.400"},children:"â"})}}function y(){const[y,S]=e.useState(null),[k,A]=e.useState(null),[C,E]=e.useState(!1),[z,$]=e.useState(null),[M,T]=e.useState(w),[D,G]=e.useState(!1),I=e.useRef(null),R=e.useCallback(async()=>{const e=await x("/admin/blog/posts");if(401===e.status||403===e.status)return void A("forbidden");if(!e.ok)throw new Error("load");const s=await e.json();S(s.items),A(null)},[]),B=e.useCallback(async()=>{try{const e=await x("/admin/prerender/status");if(!e.ok)return;const s=await e.json();T({running:!0===s.running,startedAt:s.startedAt??null,finishedAt:s.finishedAt??null,logs:Array.isArray(s.logs)?s.logs:[],progress:s.progress??w.progress,lastError:s.lastError??null})}catch{}},[]);e.useEffect(()=>{let e=!1;return(async()=>{try{e||await R()}catch{e||A("error")}})(),()=>{e=!0}},[R]),e.useEffect(()=>{if(!C)return;B();const e=window.setInterval(()=>{B()},700);return()=>window.clearInterval(e)},[C,B]),e.useEffect(()=>{var e;null==(e=I.current)||e.scrollIntoView({behavior:"smooth",block:"nearest"})},[M.logs.length,C]);const P=(null==y?void 0:y.filter(e=>"missing"===e.prerenderStatus||"stale"===e.prerenderStatus).length)??0,W=M.progress.total,F=W>0?Math.min(100,Math.round(M.progress.index/W*100)):void 0,H=W>0?`${M.progress.index} / ${W}${M.progress.pathname?` · ${M.progress.pathname}`:""}`:C?"ÐодгоÑовкаâ¦":"";return s.jsxs(h,{children:[s.jsxs(r,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:2,mb:2},children:[s.jsxs(r,{children:[s.jsx(t,{level:"h3",children:"Ðлог"}),s.jsxs(t,{level:"body-xs",sx:{color:"neutral.500"},children:["ÐÑбликаÑии и ÑеÑновики",P>0?` · ${P} без акÑÑалÑного SSG`:""]})]}),s.jsxs(n,{direction:"row",spacing:1,children:[s.jsx(o,{component:p,to:"/app/admin/blog/topics",variant:"outlined",size:"sm",startDecorator:s.jsx(l,{}),children:"ÐÑеÑÐµÐ´Ñ Ñем"}),s.jsx(o,{component:p,to:"/app/admin/blog/new",startDecorator:s.jsx(a,{}),variant:"solid",size:"sm",children:"ÐÐ¾Ð²Ð°Ñ ÑÑаÑÑÑ"})]})]}),"forbidden"===k?s.jsx(t,{color:"danger",children:"ÐÐµÑ Ð´Ð¾ÑÑÑпа."}):k?s.jsx(t,{color:"danger",children:"Ðе ÑдалоÑÑ Ð·Ð°Ð³ÑÑзиÑÑ ÑпиÑок."}):null==y?s.jsx(r,{sx:{display:"flex",justifyContent:"center",py:6},children:s.jsx(i,{})}):s.jsx(m,{variant:"outlined",sx:{borderRadius:"md",overflow:"auto"},children:s.jsxs(j,{stickyHeader:!0,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"34%"},children:"Ðаголовок"}),s.jsx("th",{children:"СÑаÑÑÑ"}),s.jsx("th",{children:"SSG"}),s.jsx("th",{children:"ÐÑоÑмоÑÑÑ"}),s.jsx("th",{children:"РеакÑии"}),s.jsx("th",{children:"Ðбновлено"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:y.map(e=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx(t,{sx:{fontWeight:600},children:e.title}),s.jsxs(t,{level:"body-xs",sx:{color:"neutral.500"},children:["/blog/",e.slug]})]}),s.jsx("td",{children:s.jsx(f,e.publishedAt?{size:"sm",color:"success",variant:"soft",children:"ÐпÑбликовано"}:{size:"sm",color:"neutral",variant:"soft",children:"ЧеÑновик"})}),s.jsx("td",{children:v(e.prerenderStatus)}),s.jsx("td",{children:e.viewCount}),s.jsx("td",{children:e.reactionCount}),s.jsx("td",{children:s.jsx(t,{level:"body-sm",children:c(e.updatedAt)})}),s.jsx("td",{children:s.jsx(o,{size:"sm",component:p,to:`/app/admin/blog/${e.id}`,variant:"plain",children:"РедакÑиÑоваÑÑ"})})]},e.id))})]})}),s.jsxs(r,{sx:{mt:2,display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[s.jsx(o,{component:"a",href:"/blog",target:"_blank",rel:"noreferrer",variant:"outlined",endDecorator:s.jsx(d,{}),children:"ÐÑкÑÑÑÑ Ð±Ð»Ð¾Ð³"}),s.jsx(o,{variant:"soft",color:"primary",startDecorator:C?s.jsx(i,{size:"sm"}):s.jsx(u,{}),disabled:C,onClick:()=>{!async function(){var e;E(!0),$(null),G(!0),T({...w,running:!0,logs:[{ts:Date.now(),level:"info",line:"ÐапÑÑкâ¦"}]}),B();try{const s=await x("/admin/prerender",{method:"POST"});let r={};try{r=await s.json()}catch{if(!s.ok)throw new Error(`ÐÑибка ÑеÑвеÑа (${s.status})`)}if(!s.ok)throw new Error(r.error||"Ðе ÑдалоÑÑ Ð²ÑполниÑÑ Ð¿ÑеÑендеÑ");await B();const t=r.pathCount??(null==(e=r.blogSlugs)?void 0:e.length)??0,n=null!=r.durationMs?` за ${Math.max(1,Math.round(r.durationMs/1e3))} Ñ`:"";$({tone:"success",text:`ÐÑеÑÐµÐ½Ð´ÐµÑ Ð²Ñполнен: обновлено ${t} ÑÑÑаниÑ${n}.`}),await R()}catch(s){await B();const e=s instanceof TypeError&&/fetch/i.test(s.message)?"Ðе ÑдалоÑÑ ÑвÑзаÑÑÑÑ Ñ ÑеÑвеÑом":s instanceof Error?s.message:"ÐÑибка пÑеÑендеÑа";$({tone:"danger",text:e})}finally{E(!1),B()}}()},children:C?"ÐÑеÑендеÑâ¦":"ÐбновиÑÑ Ð¿ÑеÑендеÑ"}),D&&M.logs.length>0&&!C?s.jsx(o,{size:"sm",variant:"plain",color:"neutral",onClick:()=>G(!1),children:"СкÑÑÑÑ Ð»Ð¾Ð³"}):null]}),D&&(C||M.logs.length>0)?s.jsxs(m,{variant:"soft",color:"neutral",sx:{mt:2,p:1.5,borderRadius:"md",bgcolor:"#0f1419",border:"1px solid",borderColor:"neutral.800"},children:[s.jsxs(r,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:1},children:[s.jsxs(t,{level:"body-sm",sx:{color:"neutral.300",fontWeight:600},children:["ÐÑеÑендеÑ",C?" · вÑполнÑеÑÑÑ":M.lastError?" · оÑибка":" · лог"]}),H?s.jsx(t,{level:"body-xs",sx:{color:"neutral.500",fontFamily:"monospace"},children:H}):null]}),C||null!=F?s.jsx(g,{determinate:null!=F,value:F??0,sx:{mb:1.5,"--LinearProgress-thickness":"6px"}}
1):null,s.jsxs(r,{component:"pre",sx:{m:0,p:1.5,maxHeight:220,overflow:"auto",borderRadius:"sm",bgcolor:"#080b10",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.75rem",lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[M.logs.map((e,t)=>{return s.jsx(r,{component:"span",sx:{display:"block",color:(n=e.level,"error"===n?"#fca5a5":"warn"===n?"#fcd34d":"#a3a3a3")},children:e.line},`${e.ts}-${t}`);var n}),s.jsx("div",{ref:I})]})]}):null,z?s.jsx(b,{sx:{mt:2},color:z.tone,variant:"soft",children:z.text}):null]})}export{y as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.