import{r as n,j as e,a as g,R as u,b as h}from"./styles-D0iwtgt5.js";import{S as b,R as j}from"./detection-v2OMyFda.js";import{c as f}from"./index-rhsb-VlA.js";import"./_commonjsHelpers-CqkleIqs.js";function N(){const[s,i]=n.useState([]),[c,a]=n.useState(0),[d,x]=n.useState(!0),[l,m]=n.useState("all");n.useEffect(()=>{r()},[]);async function r(){try{const t=await chrome.runtime.sendMessage(f("DETECTION_LOG_QUERY",{limit:100}));t!=null&&t.payload&&(i(t.payload.entries.reverse()),a(t.payload.total))}catch(t){console.error("Failed to load logs:",t)}finally{x(!1)}}const o=l==="all"?s:s.filter(t=>l==="desensitized"?t.action==="desensitized"||t.action==="auto_desensitized":t.action==="ignored");return e.jsxs("div",{className:"min-h-screen bg-slate-900 text-slate-100",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-slate-900/95 backdrop-blur border-b border-slate-800 p-4",children:[e.jsxs("h1",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx("span",{children:"🛡️"}),e.jsx("span",{children:"检测日志"}),e.jsxs("span",{className:"text-xs text-slate-500 font-normal ml-1",children:["共 ",c," 条记录"]})]}),e.jsx("div",{className:"flex gap-2 mt-3",children:["all","desensitized","ignored"].map(t=>e.jsx("button",{onClick:()=>m(t),className:`px-3 py-1 rounded-full text-xs font-medium transition ${l===t?"bg-blue-600 text-white":"bg-slate-800 text-slate-400 hover:text-slate-300"}`,children:t==="all"?"全部":t==="desensitized"?"已脱敏":"已忽略"},t))})]}),e.jsx("div",{className:"p-2",children:d?e.jsx("div",{className:"text-center py-12 text-slate-500 text-sm",children:"加载中..."}):o.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-slate-600 text-3xl mb-2",children:"📋"}),e.jsx("div",{className:"text-slate-500 text-sm",children:"暂无检测记录"})]}):e.jsx("div",{className:"space-y-1",children:o.map(t=>e.jsx(v,{entry:t},t.id))})})]})}function v({entry:s}){const[i,c]=n.useState(!1),a=new Date(s.timestamp),d=`${a.getHours().toString().padStart(2,"0")}:${a.getMinutes().toString().padStart(2,"0")}`,x=`${a.getMonth()+1}/${a.getDate()}`,l={desensitized:{text:"已脱敏",color:"text-green-400 bg-green-500/10"},auto_desensitized:{text:"自动脱敏",color:"text-green-400 bg-green-500/10"},ignored:{text:"已忽略",color:"text-slate-400 bg-slate-500/10"},whitelisted:{text:"白名单",color:"text-blue-400 bg-blue-500/10"}}[s.action]||{text:s.action,color:"text-slate-400 bg-slate-500/10"},m=(()=>{try{return new URL(s.pageUrl).hostname}catch{return s.pageUrl}})();return e.jsxs("div",{className:"bg-slate-800/40 rounded-lg p-3 cursor-pointer hover:bg-slate-800/60 transition",onClick:()=>c(!i),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-xs text-slate-500 flex-shrink-0",children:[x," ",d]}),e.jsx("span",{className:"text-xs text-slate-400 truncate",children:m})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("span",{className:"text-xs font-medium text-amber-400",children:[s.entitiesFound," 项"]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${l.color}`,children:l.text})]})]}),i&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-slate-700/50",children:[e.jsxs("div",{className:"text-xs text-slate-500 mb-1",children:["来源: ",s.source]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.entityTypes.map((r,o)=>{const t=j[r],p={high:"bg-red-500/10 text-red-300",medium:"bg-orange-500/10 text-orange-300",low:"bg-yellow-500/10 text-yellow-300"};return e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded ${p[t]}`,children:b[r]},o)})}),s.desensitizedSummary&&e.jsx("div",{className:"mt-2 text-xs text-slate-500 bg-slate-900/50 rounded p-2 font-mono",children:s.desensitizedSummary})]})]})}g();u.createRoot(document.getElementById("root")).render(e.jsx(h.StrictMode,{children:e.jsx(N,{})}));
