1import{u as fe,j as t,n as A,b as R,B as v,F as be}from"./index-ae7ec2c.BSswS0a9.js";import{a as l}from"./monaco-ae7ec2c.DBaGHQ0n.js";import{M as ye}from"./MarkdownRenderer-ae7ec2c.DzNP55xY.js";import{F as ve,B as we}from"./BlogShareModal-ae7ec2c.DMZSLdVw.js";function je(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/!\[([^\]]*)\]\(((?:https?:\/\/|data:image\/|\/uploads\/)[^\s)]+)\)/g,(S,w,p)=>{const B=String(w).replace(/"/g,""");return`<img src="${p}" alt="${B}" style="max-width:100%;height:auto;border-radius:10px;margin:8px 0" loading="lazy">`}).replace(/\n/g,"<br>")}function Ce({user:n,blogId:c,commentId:S,onNavigate:w,onUserUpdate:p}){const{themeData:B}=fe(),i=B.isLight,[o,F]=l.useState(null),[j,f]=l.useState([]),[b,C]=l.useState(""),[g,I]=l.useState(null),[y,N]=l.useState(""),[q,P]=l.useState(null),[ie,J]=l.useState(!0),[D,E]=l.useState(!1),[le,M]=l.useState(0),[z,W]=l.useState(!1),[oe,H]=l.useState(0),[K,V]=l.useState(!1),[Y,G]=l.useState(!1),[Q,r]=l.useState(null),[X,L]=l.useState(!1),[T,Z]=l.useState(!1),[de,O]=l.useState(!1),[k,ee]=l.useState(null),ce=async()=>{J(!0);try{const e=await v.get(c);if(e?.code===200&&e.data){const s=e.data;F(s),f((s.comments?.list||[]).map(a=>({id:a.id,content:a.content,createdAt:a.createdAt,parentId:a.parentId||null,replyToUser:a.replyToUser||null,replies:(a.replies||[]).map(d=>({id:d.id,content:d.content,createdAt:d.createdAt,parentId:d.parentId,replyToUser:d.replyToUser||null,user:d.author||d.user||{nickname:"å¿å",avatar:"ð¤"}})),user:a.author||a.user||{nickname:"å¿å",avatar:"ð¤"}}))),M(s.likeCount||s._count?.likes||0),E(s.isLiked||!1),W(s.isFavorited||!1),H(s.favoriteCount||s._count?.favorites||0)}}catch{const s=JSON.parse(localStorage.getItem("oi_blogs")||"[]").find(a=>a.id===c);s&&(F(s),f((s.comments||[]).map(a=>({...a,user:a.user||{nickname:"å¿å",avatar:"ð¤"}}))))}finally{J(!1)}};l.useEffect(()=>{ce()},[c]),l.useEffect(()=>{if(!S)return;let e=0;const s=()=>{const a=document.getElementById(`comment-${S}`);if(a){a.scrollIntoView({behavior:"smooth",block:"center"}),a.classList.add("ring-2","ring-purple-400","rounded-xl","transition-shadow"),setTimeout(()=>a.classList.remove("ring-2","ring-purple-400","rounded-xl","transition-shadow"),2500);return}e++<40&&setTimeout(s,100)};s()},[S,j]);const me=async()=>{if(!n){window.dispatchEvent(new CustomEvent("oi_guest_require_login"));return}if(!D){try{const e=await v.like(c);if(e?.code===200&&e.data)if(E(e.data.liked),M(e.data.likeCount),e.data.liked){const s=JSON.parse(localStorage.getItem("oi_liked_blogs")||"[]");s.includes(c)||(s.push(c),localStorage.setItem("oi_liked_blogs",JSON.stringify(s))),r("â¤ï¸ ç¹èµæåï¼+5积åå·²å¥å±ç»ä½è
")}else{const s=JSON.parse(localStorage.getItem("oi_liked_blogs")||"[]");localStorage.setItem("oi_liked_blogs",JSON.stringify(s.filter(a=>a!==c))),r("已忶ç¹èµ")}}catch{E(!0),M(e=>e+1)}setTimeout(()=>r(null),3e3)}},_=()=>o?.isFeatured&&o?.featuredType==="auto",ue=async()=>{if(!n){window.dispatchEvent(new CustomEvent("oi_guest_require_login"));return}if(!K){V(!0);try{const e=await v.favorite(c);e?.code===200&&e.data?(W(e.data.favorited),H(e.data.favoriteCount),r(e.data.favorited?"ð å·²æ¶è":"已忶æ¶è")):r(e?.message||"æä½å¤±è´¥ï¼è¯·éè¯")}catch(e){r(e?.message||"æä½å¤±è´¥ï¼è¯·éè¯")}finally{V(!1),setTimeout(()=>r(null),3e3)}}},xe=async()=>{if(!n){window.dispatchEvent(new CustomEvent("oi_guest_require_login"));return}if(!(T||_())){Z(!0);try{const e=await v.feature(c);e?.code===200?(F(s=>s&&{...s,isFeatured:!0,featuredType:"auto",featuredAt:e.data?.featuredAt||new Date().toISOString(),featuredUntil:e.data?.featuredUntil||null}),r("â å ç²¾æåï¼å·²ç½®é¡¶å±ç¤º 24 å°æ¶ï¼æ¶è 200 积åï¼"),p?.({...n,points:Math.max(0,(n.points||0)-200)})):r(e?.message||"å 精失败ï¼è¯·éè¯")}catch(e){r(e?.message||"å 精失败ï¼è¯·éè¯")}finally{Z(!1),setTimeout(()=>r(null),3e3)}}},pe=async()=>{O(!1),await xe()},ge=async()=>{if(!n){window.dispatchEvent(new CustomEvent("oi_guest_require_login"));return}if(b.trim()){G(!0);try{const e=await v.comment(c,b.trim());if(e?.code===201&&e.data){const s=e.data.comment;f(a=>[...a,{id:s.id,content:s.content,createdAt:s.createdAt,parentId:s.parentId||null,replyToUser:s.replyToUser||null,replies:[],user:{...s.author||s.user||{},nickname:(s.author||s.user||{}).nickname||n.nickname,avatar:(s.author||s.user||{}).avatar||n.avatar,stageId:(s.author||s.user||{}).stageId||n.stageId}}]),C(""),r("ð¬ è¯è®ºæåï¼+10积å"),p({...n,points:(n.points||0)+(e.data.pointsEarned||10)})}}catch(e){r(e?.message||"è¯è®ºå¤±è´¥ï¼è¯·éè¯"),f(s=>[...s,{id:Date.now().toString(),content:b.trim(),createdAt:new Date().toISOString(),parentId:null,replyToUser:null,replies:[],user:{nickname:n.nickname,avatar:n.avatar,stageId:n.stageId}}]),C(""),p({...n,points:(n.points||0)+10})}finally{G(!1),setTimeout(()=>r(null),3e3)}}},te=async e=>{if(!n){window.dispatchEvent(new CustomEvent("oi_guest_require_login"));return}if(y.trim()){P(e);try{const s=await v.comment(c,y.trim(),e);
1if(s?.code===201&&s.data){const a=s.data.comment;f(d=>d.map(u=>u.id===e?{...u,replies:[...u.replies||[],{id:a.id,content:a.content,createdAt:a.createdAt,parentId:a.parentId,replyToUser:a.replyToUser||null,user:{...a.author||a.user||{},nickname:(a.author||a.user||{}).nickname||n.nickname,avatar:(a.author||a.user||{}).avatar||n.avatar,stageId:(a.author||a.user||{}).stageId||n.stageId}}]}:u)),N(""),I(null),r("ð¬ å夿åï¼+10积å"),p?.({...n,points:(n.points||0)+(s.data.pointsEarned||10)})}else console.error("åå¤å¤±è´¥:",s),r(s?.message||"åå¤å¤±è´¥ï¼è¯·éè¯")}catch{f(s=>s.map(a=>a.id===e?{...a,replies:[...a.replies||[],{id:Date.now().toString(),content:y.trim(),createdAt:new Date().toISOString(),parentId:e,replyToUser:g?{id:"",nickname:g.nickname}:null,user:{nickname:n.nickname,avatar:n.avatar,stageId:n.stageId}}]}:a)),N(""),I(null),p({...n,points:(n.points||0)+10})}finally{P(null),setTimeout(()=>r(null),3e3)}}},he=(e,s)=>{if(!e.type.startsWith("image/")){r("ä» æ¯æå¾çæä»¶"),setTimeout(()=>r(null),3e3);return}if(e.size>5*1024*1024){r("å¾ç大å°ä¸è½è¶ è¿ 5MB"),setTimeout(()=>r(null),3e3);return}L(!0);const a=new FileReader;a.onload=async()=>{try{const d=a.result,u=await be.uploadImage(d);if(u?.code===200&&u.data?.url){const ne=``;s(re=>re?`${re} 2${ne}`:ne)}else r(u?.message||"å¾çä¸ä¼ 失败"),setTimeout(()=>r(null),3e3)}catch{r("å¾çä¸ä¼ 失败ï¼è¯·éè¯"),setTimeout(()=>r(null),3e3)}finally{L(!1)}},a.onerror=()=>{L(!1),r("读åå¾ç失败"),setTimeout(()=>r(null),3e3)},a.readAsDataURL(e)},ae=e=>s=>{s.preventDefault(),s.stopPropagation();const a=Array.from(s.dataTransfer.files).filter(d=>d.type.startsWith("image/"));if(a.length!==0){if(a.length>1){r("䏿¬¡åªè½ä¸ä¼ ä¸å¼ å¾ç"),setTimeout(()=>r(null),3e3);return}he(a[0],e)}},U=e=>{const s=new Date(e);return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")} ${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`},$=i?"bg-white border-gray-200":"glass-card border-white/10",h=i?"text-gray-900":"text-white",m=i?"text-gray-500":"text-white/50",se=i?"bg-gray-50 border-gray-200 focus:border-purple-400":"bg-white/5 border-white/10 focus:border-purple-500";if(ie)return t.jsx("div",{className:"max-w-5xl mx-auto px-4 py-6",children:t.jsxs("div",{className:`animate-pulse p-6 rounded-xl ${$}`,children:[t.jsx("div",{className:`h-6 w-3/4 rounded mb-4 ${i?"bg-gray-200":"bg-white/10"}`}),t.jsx("div",{className:`h-4 w-full rounded mb-2 ${i?"bg-gray-100":"bg-white/5"}`}),t.jsx("div",{className:`h-4 w-2/3 rounded ${i?"bg-gray-100":"bg-white/5"}`})]})});if(!o)return t.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-20 text-center",children:[t.jsx("div",{className:"text-5xl mb-4",children:"ð"}),t.jsx("p",{className:m,children:"å客ä¸åå¨æå·²è¢«å é¤"}),t.jsx("button",{onClick:()=>w("blog"),className:"mt-4 text-purple-400 hover:text-purple-300 text-sm",children:"è¿åå客广åº"})]});const x=o.author||o.user||{nickname:"å¿å",avatar:"ð¤"};return t.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-6",children:[t.jsx("style",{children:` 3 @keyframes featuredBlink { 0%,100% { opacity: 1 } 50% { opacity: .5 } } 4 .featured-blink { animation: featuredBlink 1.1s ease-in-out infinite; } 5 `}),t.jsx("button",{onClick:()=>w("blog"),className:`mb-4 px-2 py-1 rounded-lg text-sm ${i?"hover:bg-gray-100 text-gray-600":"hover:bg-white/5 text-white/60"}`,children:"â è¿åå客广åº"}),Q&&t.jsx("div",{className:`mb-4 p-3 rounded-lg text-sm animate-in slide-in-from-top ${i?"bg-green-50 text-green-700":"bg-green-500/10 text-green-400"}`,children:Q}),t.jsxs("div",{className:`p-6 rounded-xl border ${$}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4 flex-wrap",children:[o.isFeatured&&o.featuredType==="official"&&t.jsx("span",{className:"featured-blink inline-flex items-center gap-1 px-3 py-0.5 rounded-full text-xs font-bold bg-gradient-to-r from-amber-400 to-yellow-500 text-white shadow",children:"â 宿¹ç²¾é"}),o.isFeatured&&o.featuredType==="auto"&&t.jsx("span",{className:"featured-blink inline-flex items-center gap-1 px-3 py-0.5 rounded-full text-xs font-bold bg-gradient-to-r from-orange-500 to-red-500 text-white shadow",children:"ð¥ ç²¾é"}),t.jsx("h1",{className:`text-2xl font-bold ${h}`,children:o.title}),t.jsx("button",{onClick:()=>ee(o),className:`ml-auto flex items-center gap-1 px-3 py-1 rounded-full text-xs font-medium transition-colors ${i?"bg-green-50 text-green-600 hover:bg-green-100":"bg-green-500/10 text-green-300 hover:bg-green-500/20"}`,title:"å享è¿ç¯å客",children:"ð å享"})]}),t.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b border-gray-200/10",children:[t.jsx("span",{className:"text-2xl",children:t.jsx(A,{value:x.avatar,fallback:"ð¤"})}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[x.stageId&&(()=>{const e=R(x.stageId);return t.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full ${i?"bg-gray-100":"bg-white/10"} ${e.color}`,children:[e.emoji," ",e.name]})})(),t.jsx("span",{className:`font-medium ${h}`,children:x.nickname||"å¿å"}),x.id&&t.jsx("button",{onClick:()=>w("blogMy",x.id===n?.id?void 0:{viewUserId:x.id}),className:`ml-1 px-2.5 py-0.5 rounded-full text-[11px] font-medium transition-colors ${i?"bg-purple-100 text-purple-700 hover:bg-purple-200":"bg-purple-500/20 text-purple-300 hover:bg-purple-500/30"}`,children:x.id===n?.id?"ð æçå客":"ð å»ç TA çå客"})]}),t.jsxs("div",{className:`text-xs ${m}`,children:[U(o.createdAt)," · ð ",o.viewCount||0]})]})]}),o.tags&&t.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:o.tags.split(",").filter(
5Boolean).map(e=>t.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs ${i?"bg-purple-50 text-purple-600":"bg-purple-500/10 text-purple-400"}`,children:e.trim()},e))}),o.content&&t.jsx("div",{className:`leading-relaxed text-sm ${m}`,dangerouslySetInnerHTML:{__html:je(o.content)}}),o.contentMd&&t.jsxs("div",{className:"mt-5 pt-5 border-t border-gray-200/10",children:[t.jsx("div",{className:`mb-2 text-xs font-medium ${m}`,children:"ð Markdown æ£æ"}),t.jsx(ye,{isLight:i,children:o.contentMd})]}),t.jsxs("div",{className:"flex items-center gap-4 mt-6 pt-4 border-t border-gray-200/10",children:[t.jsxs("button",{onClick:me,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-all ${D?"bg-red-500/20 text-red-400":i?"hover:bg-gray-100 text-gray-500":"hover:bg-white/5 text-white/50"}`,children:[D?"â¤ï¸":"ð¤"," ",le]}),t.jsxs("button",{onClick:ue,disabled:K,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-all disabled:opacity-50 ${z?"bg-yellow-500/20 text-yellow-400":i?"hover:bg-gray-100 text-gray-500":"hover:bg-white/5 text-white/50"}`,children:[z?"â
":"â"," ",oe]}),t.jsxs("span",{className:`flex items-center gap-1.5 text-sm ${m}`,children:["ð¬ ",j.length]}),t.jsx("button",{onClick:()=>O(!0),disabled:T||_(),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-all ${_()?"bg-amber-500/20 text-amber-400":i?"hover:bg-gray-100 text-amber-600":"hover:bg-white/5 text-amber-200/70"} disabled:opacity-50`,children:T?"å ç²¾ä¸...":_()?"â å·²å ç²¾":"â å ç²¾(â200)"})]})]}),t.jsxs("div",{className:"mt-6",children:[t.jsxs("h3",{className:`text-lg font-semibold mb-4 ${h}`,children:["ð¬ è¯è®º (",j.length,")"]}),n?t.jsxs("div",{className:`flex gap-3 mb-6 p-4 rounded-xl border ${$}`,children:[t.jsx("span",{className:"text-xl shrink-0",children:t.jsx(A,{value:n.avatar})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("textarea",{value:b,onChange:e=>C(e.target.value),onDrop:ae(C),onDragOver:e=>e.preventDefault(),placeholder:"åä¸ä½ çè¯è®º...ï¼æ¯æææ½å¾çä¸ä¼ ï¼",rows:2,maxLength:1e3,className:`w-full px-3 py-2 rounded-lg border text-sm outline-none resize-none transition-colors ${se} ${h}`}),t.jsxs("div",{className:"flex justify-between items-center mt-2",children:[t.jsxs("span",{className:`text-xs ${m}`,children:[b.length,"/1000 ",X&&"· å¾çä¸ä¼ ä¸..."]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{onClick:ge,disabled:!b.trim()||Y||X,className:"px-4 py-1.5 rounded-lg bg-purple-500 hover:bg-purple-600 text-white text-xs font-medium transition-colors disabled:opacity-40",children:Y?"åéä¸...":"å表è¯è®º"})})]})]})]}):t.jsx("div",{className:`mb-6 p-4 rounded-xl border ${$} text-center`,children:t.jsx("button",{onClick:()=>window.dispatchEvent(new CustomEvent("oi_guest_require_login")),className:"text-purple-400 hover:text-purple-300 text-sm font-medium",children:"ç»å½ / 注å ååä¸è¯è®º"})}),j.length===0?t.jsx("div",{className:`text-center py-8 text-sm ${m}`,children:"ææ è¯è®ºï¼æ¥æ¢æ²åå§~"}):t.jsx("div",{className:"space-y-4",children:j.map(e=>{const s=e.replies?.length||0;return t.jsxs("div",{id:`comment-${e.id}`,className:`rounded-xl border ${$} overflow-hidden`,children:[t.jsxs("div",{className:"flex gap-3 p-4",children:[t.jsx("span",{className:"text-lg shrink-0",children:t.jsx(A,{value:e.user?.avatar,fallback:"ð¤"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.user?.stageId&&(()=>{const a=R(e.user.stageId);return t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${i?"bg-gray-100":"bg-white/10"} ${a.color}`,children:[a.emoji," ",a.name]})})(),t.jsx("span",{className:`text-sm font-medium ${h}`,children:e.user?.nickname||"å¿å"}),t.jsx("span",{className:`text-xs ${m}`,children:U(e.createdAt)})]}),t.jsx("p",{className:`text-sm ${m}`,children:e.content}),t.jsx("button",{onClick:()=>I(g?.commentId===e.id?null:{commentId:e.id,nickname:e.user?.nickname||"å¿å"}),className:`mt-1 text-xs transition-colors ${g?.commentId===e.id?"text-purple-400":i?"text-gray-400 hover:text-gray-600":"text-white/30 hover:text-white/50"}`,children:g?.commentId===e.id?"åæ¶åå¤":"åå¤"})]})]}),g?.commentId===e.id&&t.jsx("div",{className:"px-4 pb-3 ml-10",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:y,onChange:a=>N(a.target.value),onDrop:ae(N),onDragOver:a=>a.preventDefault(),onKeyDown:a=>a.key==="Enter"&&y.trim()&&te(e.id),placeholder:`åå¤ ${g.nickname}...ï¼å¯ææ½å¾çï¼`,maxLength:500,className:`flex-1 px-3 py-2 rounded-lg border text-sm outline-none ${se} ${h}`,autoFocus:!0}),t.jsx("button",{onClick:()=>te(e.id),disabled:!y.trim()||q===e.id,className:"px-3 py-2 rounded-lg bg-purple-500 hover:bg-purple-600 text-white text-xs font-medium transition-colors disabled:opacity-40",children:q===e.id?"...":"åé"})]})}),s>0&&t.jsx("div",{className:`ml-10 border-t ${i?"border-gray-100":"border-white/5"}`,children:e.replies.map(a=>t.jsxs("div",{id:`comment-${a.id}`,className:`flex gap-3 px-4 py-3 ${i?"bg-gray-50/50":"bg-white/[0.02]"}`,children:[t.jsx("span",{className:"text-sm shrink-0 mt-0.5",children:t.jsx(A,{value:a.user?.avatar,fallback:"ð¤"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.user?.stageId&&(()=>{const d=R(a.user.stageId);return t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${i?"bg-gray-100":"bg-white/10"} ${d.color}`,children:[d.emoji," ",d.name]})})(),t.jsx("span",{className:`text-sm font-medium ${h}`,children:a.user?.nickname||"å¿å"}),a.replyToUser&&t.jsxs("span",{className:`text-xs ${m}`,children:["åå¤ ",t.jsx("span",{className:"text-purple-400",children:a.replyToUser.nickname})]}),t.jsx("span",{className:`text-xs ${m}`,children:U(a.createdAt)})]}),t.jsx("p",{className:`text-sm ${m}`,children:a.content}),t.jsx("button",{onClick:()=>{I({commentId:e.id,nickname:a.user?.nickname||"å¿å"}),N(`@${a.user?.nickname||"å¿å"} `)},className:`mt-1 text-xs transition-colors ${i?"text-gray-400 hover:text-gray-600":"text-white/30 hover:text-white/50"}`,children:"åå¤"})]})]},a.id))})]},e.id)})})]}),t.jsx(ve,{open:de,cost:200,points:n?.points||0,busy:T,onConfirm:pe,onCancel:()=>O(!1)}),k&&t.jsx(we,{open:!!k,onClose:()=>ee(null),blog:k,isMine:k.author?.id===n?.id||k.user?.id===n?.id})]})}export{Ce 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.