1import{n as rt,a as nt,G as it,r as l,j as e,D as at,c as Ce,d as T,q as G,w as F,o as Ee,y as ae,H as ke,g as Re,x as oe,e as H,B as Oe,C as Me,T as ot,p as lt,A as dt}from"./index-D9WyEDzj.js";import{p as J}from"./openclawDetection-kVwBiU3I.js";const Fe=["messages_storage","messages_total_count","messages_stored_count","messages_base_log_id","messages_base_count","messages_delta_count","messages_full_hash","cached_percent","messages_snapshot","messages_delta"],ct=`${dt.replace(/\/$/,"")}/openclawReview`,$={logging:!0,logLevel:"standard",cloudLogging:{logLevel:"standard",allowVerboseLogging:!0}},le=100,Te=500,mt=1e4;function gt(s){if(!C(s))return $;const r=C(s.cloudLogging)?s.cloudLogging:{},i=typeof r.allowVerboseLogging=="boolean"?r.allowVerboseLogging:!0,u=r.logLevel==="verbose"?"verbose":"standard",b=!0,p=s.logLevel==="verbose"?"verbose":"standard";return{logging:b,logLevel:i&&p==="verbose"?"verbose":"standard",cloudLogging:{logLevel:i&&u==="verbose"?"verbose":"standard",allowVerboseLogging:i}}}function C(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function W(s){if(s instanceof Date)return s;if(typeof s=="string"||typeof s=="number")return new Date(s);if(s&&typeof s=="object"){const r=s;if(typeof r.toDate=="function")return r.toDate();if(typeof r.seconds=="number")return new Date(r.seconds*1e3)}return new Date(NaN)}function de(s){const r=W(s);return Number.isNaN(r.getTime())?"-":r.toLocaleString()}function Pe(s){try{return JSON.stringify(s,null,2)}catch{return"{}"}}function N(s){if(typeof s=="number"&&Number.isFinite(s))return Math.floor(s);if(typeof s=="string"&&s.trim()!==""){const r=Number(s);if(Number.isFinite(r))return Math.floor(r)}}function ut(s){if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim()!==""){const r=Number(s);if(Number.isFinite(r))return r}}function Be(s){return typeof s=="string"&&s.trim().length>0?s.trim():"unknown"}function xt(s){return s==="low"||s==="medium"||s==="high"?s:null}function q(s){if(!C(s))return null;const r=xt(s.risk_level);if(!r)return null;const i=typeof s.findings=="string"?s.findings.trim():"",u=typeof s.recommendation=="string"?s.recommendation.trim():"";if(!i||!u)return null;const b=Array.isArray(s.excerpts)?s.excerpts.filter(p=>typeof p=="string").map(p=>p.trim()).filter(Boolean).slice(0,3):[];return{risk_level:r,findings:i,recommendation:u,excerpts:b,source:s.source==="llm"?"llm":"fallback",reviewed_at:s.reviewed_at}}function pt(s){return s==="high"?"bg-red-100 text-red-700 border-red-200":s==="medium"?"bg-amber-100 text-amber-700 border-amber-200":"bg-emerald-100 text-emerald-700 border-emerald-200"}function ft(s){let r;try{r=JSON.parse(JSON.stringify(s))}catch{r={...s}}Array.isArray(r.messages)||(Array.isArray(r.messages_snapshot)?r.messages=r.messages_snapshot:Array.isArray(r.messages_delta)&&(r.messages=r.messages_delta));for(const i of Fe)delete r[i];return r}function De(s){const r=Date.now();return s==="1h"?new Date(r-3600*1e3):s==="24h"?new Date(r-1440*60*1e3):s==="7d"?new Date(r-10080*60*1e3):s==="30d"?new Date(r-720*60*60*1e3):null}function bt(s){if(C(s.openclaw_metadata)&&Object.keys(s.openclaw_metadata).length>0)return{...s.openclaw_metadata};const r={};for(const i of Fe)i in s.details&&(r[i]=s.details[i]);return Object.keys(r).length>0?r:null}function ce(s){if(!s)return;const r=ut(s.cached_percent);if(typeof r=="number")return Number(r.toFixed(2));const i=N(s.messages_total_count),u=N(s.messages_stored_count);if(typeof i=="number"&&i>
10&&typeof u=="number"&&u>=0&&u<=i)return Number(((i-u)/i*100).toFixed(2))}function ht(s,r,i){if(s.event_type!=="prompt")return"Payload collapsed by default";const u=typeof i?.messages_storage=="string"?i.messages_storage:void 0,b=N(i?.messages_total_count??r.messageCount)??(Array.isArray(r.messages)?r.messages.length:void 0),p=N(i?.messages_stored_count)??(Array.isArray(r.messages)?r.messages.length:void 0),_=ce(i);return u==="delta"?typeof p=="number"&&typeof b=="number"?`${p} appended / ${b} total (${_??0}% cached)`:"Incremental prompt chunk stored":u==="snapshot"?typeof b=="number"?`${b} messages (snapshot storage)`:"Snapshot prompt storage":typeof b=="number"?`${b} messages`:"Prompt payload collapsed"}function yt(s,r,i){const u={event_type:s.event_type,action:s.action,level:s.level,session_id:s.session_id};if(s.event_type==="prompt"){const b=N(i?.messages_total_count??r.messageCount)??(Array.isArray(r.messages)?r.messages.length:void 0),p=N(i?.messages_stored_count)??(Array.isArray(r.messages)?r.messages.length:void 0),_=typeof i?.messages_storage=="string"?i.messages_storage:"snapshot",P=ce(i)??0;u.prompt_storage={mode:_,total_messages:b??null,stored_messages:p??null,delta_messages:N(i?.messages_delta_count)??null,base_log_id:i?.messages_base_log_id??null,cached_percent:P,version:N(i?.version)??null}}return i&&Object.keys(i).length>0&&(u.raw_metadata=i),C(s.openclaw_detection)&&(u.regex_detection=s.openclaw_detection),u}function _t(){const s=rt(),{user:r}=nt(),i=!0,[u,b]=it(),[p,_]=l.useState([]),[P,K]=l.useState(!0),[me,Y]=l.useState(null),[S,$e]=l.useState("all"),[L,Ie]=l.useState("all"),[A,ge]=l.useState("all"),[E,Ve]=l.useState("24h"),[Q,ue]=l.useState({}),[Z,xe]=l.useState({}),[I,pe]=l.useState({}),[X,ee]=l.useState({}),[Ue,V]=l.useState({}),[ze,U]=l.useState({}),[j,z]=l.useState($),[fe,be]=l.useState(!1),[he,te]=l.useState(null),[Ge,se]=l.useState(!1),[He,ye]=l.useState(!1),[ve,we]=l.useState(!1),[Je,_e]=l.useState(!1),[je,Ne]=l.useState(null),[re,ne]=l.useState([]),B=u.get("suspicious")==="1";l.useEffect(()=>{document.title="OpenClaw Cloud Logs | AgentTrust"},[]),l.useEffect(()=>{},[i,E]);const qe=t=>{const n=new URLSearchParams(u);t?n.set("suspicious","1"):n.delete("suspicious"),b(n,{replace:!0})},We=t=>{Ve(t)},ie=async(t=!0)=>{t?(K(!0),ue({}),xe({})):we(!0),Y(null);try{if(!r?.id){_([]),pe({}),ee({}),V({}),U({}),Ne(null),_e(!1);return}const n=Ce(T,"openclaw_cloud_logs"),a=G(n,F("owner_uid","==",r.id),Ee("received_at","desc")),v=t||!je?G(a,ae(le)):G(a,ke(je),ae(le)),c=await Re(v),d=c.docs.map(o=>({id:o.id,...o.data()})),x=t?d:(()=>{const o=new Map;for(const f of p)o.set(f.id,f);for(const f of d)o.set(f.id,f);return Array.from(o.values()).sort((f,y)=>W(y.received_at).getTime()-W(f.received_at).getTime())})(),m=t?{}:{...X};for(const o of d){const f=q(o.openclaw_ai_review);f&&(m[o.id]=f)}const h=Array.from(new Set(x.map(o=>o.org_id).filter(Boolean))),g={};await Promise.all(h.map(async o=>{try{const f=await oe(H(T,"orgs",o));if(f.exists()){const y=f.data(),O=typeof y.name=="string"&&y.name.trim()?y.name.trim():o;g[o]=O}else g[o]=o}catch{g[o]=o}}));const D=Array.from(new Set(x.map(o=>o.agent_id).filter(Boolean))),w=t?{}:{...I};await Promise.all(D.map(async o=>{const f=x.find(O=>O.agent_id===o),y=f?.org_id?g[f.org_id]||f.org_id:null;try{const O=await oe(H(T,"agents",o));if(O.exists()){const M=O.data(),Le=typeof M.name=="string"&&M.name.trim()?M.name.trim():o,Ae=M.org_id?g[M.org_id]||M.org_id:y;w[o]=Ae?`${Le} (${Ae})`:Le}else w[o]=y?`${o} (${y})`:o}catch{w[o]=y?`${o} (${y})`:o}}));const R=c.docs.length>0?c.docs[c.docs.length-1]:null;Ne(R),_e(c.docs.length===le),_(x),pe(w),ee(m),t&&(V({}),U({}))}catch(n){console.error("Failed to load OpenClaw logs:",n),Y(n.message||"Failed to load logs")}finally{t?K(!1):we(!1)}};l.useEffect(()=>{ie(!0).catch(t=>{console.error("Unexpected load error:",t),Y(t.message||"Failed to load logs"),K(!1)})},[r?.id]),l.useEffect(()=>{(async()=>{if(!r?.id){z($);return}try{const n=H(T,"openclaw_audit_settings",r.id),a=await oe(n);if(!a.exists()){await Oe(n,{owner_uid:r.id,...$,updated_at:Me()},{merge:!0}),z($);return}z(gt(a.data()))}catch(n){console.error("Failed to load OpenClaw audit settings:",n)}})().catch(n=>{console.error("Unexpected OpenClaw audit settings load error:",n)})},[r?.id]);const Se=async t=>
1{if(r?.id){be(!0),te(null);try{const n=H(T,"openclaw_audit_settings",r.id);await Oe(n,{owner_uid:r.id,logging:!0,logLevel:t.logLevel,cloudLogging:t.cloudLogging,updated_at:Me()},{merge:!0}),z({...t,logging:!0}),te("Audit settings saved.")}catch(n){console.error("Failed to save OpenClaw audit settings:",n),te("Failed to save settings. Please retry.")}finally{be(!1)}}},Ke=async()=>{if(!(j.cloudLogging.allowVerboseLogging&&j.cloudLogging.logLevel==="verbose")){se(!0);return}const n={...j,logLevel:"standard",cloudLogging:{...j.cloudLogging,logLevel:"standard"}};await Se(n)},Ye=async()=>{se(!1);const t={...j,logging:!0,logLevel:"verbose",cloudLogging:{logLevel:"verbose",allowVerboseLogging:!0}};await Se(t)},Qe=l.useMemo(()=>Array.from(new Set(p.map(n=>n.agent_id))).map(n=>({id:n,label:I[n]||n})).sort((n,a)=>n.label.localeCompare(a.label)),[p,I]),Ze=l.useMemo(()=>Array.from(new Set(p.map(n=>typeof n.event_type=="string"?n.event_type.trim():"").filter(Boolean))).sort((n,a)=>n.localeCompare(a)),[p]);l.useEffect(()=>{let t=!1;return(async()=>{if(!r?.id){t||ne([]);return}try{const a=[F("owner_uid","==",r.id),Ee("received_at","desc")];S!=="all"&&a.push(F("agent_id","==",S)),L!=="all"&&a.push(F("event_type","==",L));const v=De(E);v&&a.push(F("received_at",">=",ot.fromDate(v)));const c={};let d=0,x=null;for(;d<mt;){const h=[...a,ae(Te)];x&&h.push(ke(x));const g=await Re(G(Ce(T,"openclaw_cloud_logs"),...h));if(g.empty)break;for(const D of g.docs){const w=D.data();if(B&&!J(w.openclaw_detection)?.suspicious)continue;const R=Be(w.session_id);c[R]=(c[R]||0)+1}if(d+=g.docs.length,x=g.docs[g.docs.length-1],g.docs.length<Te)break}const m=Object.entries(c).map(([h,g])=>({id:h,label:h,count:g})).sort((h,g)=>g.count!==h.count?g.count-h.count:h.label.localeCompare(g.label));t||ne(m)}catch(a){console.error("Failed to load session filter options:",a),t||ne([])}})().catch(a=>{console.error("Unexpected session options load error:",a)}),()=>{t=!0}},[r?.id,S,L,E,B]),l.useEffect(()=>{if(A==="all")return;re.some(n=>n.id===A)||ge("all")},[A,re]);const k=l.useMemo(()=>{const t=De(E);return p.filter(n=>{if(S!=="all"&&n.agent_id!==S||L!=="all"&&n.event_type!==L||A!=="all"&&Be(n.session_id)!==A||B&&!J(n.openclaw_detection)?.suspicious)return!1;if(t){const a=W(n.received_at);if(Number.isNaN(a.getTime())||a<t)return!1}return!0})},[p,S,L,A,E,B]),Xe=l.useMemo(()=>k.reduce((t,n)=>J(n.openclaw_detection)?.suspicious?t+1:t,0),[k]),et=t=>{ue(n=>({...n,[t]:!n[t]}))},tt=t=>{xe(n=>({...n,[t]:!n[t]}))},st=async t=>{V(n=>({...n,[t.id]:!0})),U(n=>{const a={...n};return delete a[t.id],a});try{const n=await lt.currentUser?.getIdToken();if(!n)throw new Error("You must be signed in to run AI review.");const a=!!(X[t.id]||q(t.openclaw_ai_review)),v=await fetch(ct,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({log_id:t.id,force:a})}),c=await v.json();if(!v.ok)throw new Error(c.error||c.message||`HTTP ${v.status}`);const d=q(c.review);if(!d)throw new Error("AI review response was malformed.");ee(x=>({...x,[t.id]:d})),C(c.review)&&_(x=>x.map(m=>m.id===t.id?{...m,openclaw_ai_review:c.review,openclaw_detection:C(c.detection)?c.detection:m.openclaw_detection}:m))}catch(n){console.error("Failed to run OpenClaw AI review:",n),U(a=>({...a,[t.id]:n.message||"AI review failed"}))}finally{V(n=>({...n,[t.id]:!1}))}};return e.jsx(at,{children:e.jsxs("div",{className:"px-4 py-6 sm:px-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold text-gray-900",children:[e.jsx("span",{className:"mr-2",role:"img","aria-label":"Lobster",children:"ð¦"}),"OpenClaw Cloud Logs"]}),e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Runtime telemetry for your OpenClaw agents."})]}),e.jsx("button",{onClick:()=>{ie(!0).catch(()=>{})},className:"inline-flex items-center px-4 py-2 border border-gray-300 rounded-md bg-white text-sm font-medium text-gray-700 hover:bg-gray-50",children:"Refresh"})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Audit Logging Settings"}),e.jsx("p",{className:"text-xs text-gray-600 mb-4",children:"Configure cloud audit telemetry behavior for OpenClaw."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("label",{className:"inline-flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:j.cloudLogging.allowVerboseLogging&&j.cloudLogging.logLevel==="verbose",disabled:fe,onChange:()=>{Ke().catch(()=>{})}
1,className:"h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"}),e.jsx("span",{className:"text-sm text-gray-800",children:"Enable verbose"})]}),e.jsxs("span",{className:"inline-flex items-center rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-700 border border-gray-200",children:["Effective level: ",j.logLevel]}),fe&&e.jsx("span",{className:"text-xs text-gray-500",children:"Saving..."}),he&&e.jsx("span",{className:"text-xs text-indigo-700",children:he})]})]}),e.jsx("div",{className:"bg-white border border-gray-200 rounded-lg p-4 mb-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("label",{htmlFor:"agent-filter",className:"text-sm font-medium text-gray-700",children:"Agent"}),e.jsxs("select",{id:"agent-filter",value:S,onChange:t=>$e(t.target.value),className:"rounded-md border border-gray-300 px-3 py-2 text-sm bg-white",children:[e.jsx("option",{value:"all",children:"All agents"}),Qe.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]}),e.jsx("label",{htmlFor:"event-filter",className:"text-sm font-medium text-gray-700",children:"Event"}),e.jsxs("select",{id:"event-filter",value:L,onChange:t=>Ie(t.target.value),className:"rounded-md border border-gray-300 px-3 py-2 text-sm bg-white",children:[e.jsx("option",{value:"all",children:"All events"}),Ze.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("label",{htmlFor:"session-filter",className:"text-sm font-medium text-gray-700",children:"Session"}),e.jsxs("select",{id:"session-filter",value:A,onChange:t=>ge(t.target.value),className:"rounded-md border border-gray-300 px-3 py-2 text-sm bg-white",children:[e.jsx("option",{value:"all",children:"All sessions"}),re.map(t=>e.jsxs("option",{value:t.id,children:[t.label," (",t.count,")"]},t.id))]}),e.jsxs("label",{htmlFor:"time-filter",className:"text-sm font-medium text-gray-700",children:["Time",!i]}),e.jsxs("select",{id:"time-filter",value:E,onChange:t=>We(t.target.value),className:"rounded-md border border-gray-300 px-3 py-2 text-sm bg-white",children:[e.jsx("option",{value:"1h",children:"Last 1 hour"}),e.jsx("option",{value:"24h",children:"Last 24 hours"}),e.jsx("option",{value:"7d",children:"Last 7 days"}),e.jsx("option",{value:"30d",children:"Last 30 days"}),e.jsx("option",{value:"all",children:"All time"})]}),e.jsx("label",{htmlFor:"suspicious-filter",className:"text-sm font-medium text-gray-700",children:"Risk"}),e.jsxs("select",{id:"suspicious-filter",value:B?"suspicious":"all",onChange:t=>qe(t.target.value==="suspicious"),className:"rounded-md border border-gray-300 px-3 py-2 text-sm bg-white",children:[e.jsx("option",{value:"all",children:"All logs"}),e.jsx("option",{value:"suspicious",children:"Suspicious only"})]}),e.jsxs("span",{className:"text-sm text-gray-500",children:[k.length," logs ÷ ",Xe," suspicious"]})]})}),me&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 mb-6",children:e.jsx("p",{className:"text-sm text-red-700",children:me})}),P&&e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-12 text-center",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("p",{className:"mt-4 text-sm text-gray-600",children:"Loading logs..."})]}),!P&&k.length===0&&e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-10 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:"No logs for current filters"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Adjust agent, event, or time bracket filters."})]}),!P&&k.length>0&&e.jsxs("div",{className:"space-y-4",children:[k.map(t=>{const n=ft(t.details||{}),a=bt(t),v=yt(t,n,a),c=ce(a),d=J(t.openclaw_detection),x=d?.suspicious===!0,m=X[t.id]||q(t.openclaw_ai_review),h=ze[t.id],g=Ue[t.id]===!0,D=x?"bg-rose-100 text-rose-700":"bg-emerald-50 text-emerald-700";return e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-gray-900 text-white",children:["Event ID: ",t.id]}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-gray-100 text-gray-800",children:t.event_type}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-indigo-50 text-indigo-700",children:t.action}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-amber-50 text-amber-700",children:t.level}),typeof c=="number"&&t.event_type==="prompt"&&e.jsxs("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-50 text-emerald-700",children:["Cached: ",c,"%"]}),t.tool_name&&e.jsxs("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-blue-50 text-blue-700",children:["tool: ",t.tool_name]}),d&&e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold ${D}`,children:x?`Suspicious${d.highestSeverity?` (${d.highestSeverity})`:""}`:"Regex clean"}),x&&d&&d.totalMatches>0&&e.jsxs("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-rose-50 text-rose-700",children:[d.totalMatches," matches"]}),x&&d&&d.categories.length>0&&e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-orange-50 text-orange-700",children:d.categories.slice(0,2).join(", ")})]}),x&&e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",onClick:()=>st(t),disabled:g,className:"inline-flex items-center px-3 py-1.5 rounded border border-indigo-300 text-xs font-medium text-indigo-700 bg-indigo-50 hover:bg-indigo-100 disabled:opacity-50",children:g?"Reviewing...":m?"Re-run AI Review":"AI Review"}),!i]})]}),h&&e.jsx("div",{className:"mb-3 border border-red-200 bg-red-50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs text-red-700",children:h})}),m&&e.jsxs("div",{className:"mb-3 border border-indigo-200 bg-indigo-50 rounded-md p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[e.jsx("p",{className:"text-sm font-semibold text-indigo-900",children:"AI Review Findings"}),e.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold border ${pt(m.risk_level)}`,children:m.risk_level.toUpperCase()})]}),e.jsx("p",{className:"text-sm text-indigo-900",children:m.findings}),e.jsxs("p",{className:"text-xs text-indigo-800 mt-2",children:[e.jsx("span",{className:"font-semibold",children:"Recommendation:"})," ",m.recommendation]}),m.excerpts.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:m.excerpts.map((w,R)=>e.jsxs("p",{className:"text-xs text-indigo-800 italic border-l-2 border-indigo-300 pl-2",children:['"',w,'"']},`${t.id}::ai-review-excerpt::${R}`))}),e.jsxs("p",{className:"text-[11px] text-indigo-700 mt-2",children:["Source: ",m.source==="llm"?"LLM endpoint":"Fallback review",m.reviewed_at?` | Reviewed: ${de(m.reviewed_at)}`:""]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-sm mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Agent:"})," ",e.jsx("span",{className:"font-medium",children:I[t.agent_id]||t.agent_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Agent ID:"})," ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:t.agent_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Payload agentId:"})," ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:t.payload_agent_id||"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Session:"})," ",e.jsx("code",{className:"bg-gray-100 px-1 rounded",children:t.session_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Event time:"})," ",de(t.client_timestamp)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500",children:"Received:"})," ",de(t.received_at)]})]}),e.jsxs("div",{className:"border border-gray-200 rounded-md mb-3",children:[e.jsxs("button",{onClick:()=>
1et(t.id),className:"w-full flex items-center justify-between px-3 py-2 bg-gray-50 text-left text-sm text-gray-700 hover:bg-gray-100",children:[e.jsx("span",{className:"font-medium",children:"Event payload"}),e.jsx("span",{className:"text-xs text-gray-500",children:Q[t.id]?"Collapse":"Expand"})]}),!Q[t.id]&&e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 bg-white border-t border-gray-200",children:ht(t,n,a)}),Q[t.id]&&e.jsx("div",{className:"bg-white border-t border-gray-200 p-3 overflow-x-auto",children:e.jsx("pre",{className:"text-xs text-gray-700 whitespace-pre-wrap break-words",children:Pe(n)})})]}),e.jsxs("div",{className:"border border-gray-200 rounded-md",children:[e.jsxs("button",{onClick:()=>tt(t.id),className:"w-full flex items-center justify-between px-3 py-2 bg-gray-50 text-left text-sm text-gray-700 hover:bg-gray-100",children:[e.jsx("span",{className:"font-medium",children:"Metadata"}),e.jsx("span",{className:"text-xs text-gray-500",children:Z[t.id]?"Collapse":"Expand"})]}),!Z[t.id]&&e.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 bg-white border-t border-gray-200",children:d?x?`${d.totalMatches} regex matches${d.highestSeverity?` (${d.highestSeverity})`:""}`:"Regex scan clean":t.event_type==="prompt"&&typeof c=="number"?`Prompt cache: ${c}%`:"Metadata collapsed by default"}),Z[t.id]&&e.jsx("div",{className:"bg-white border-t border-gray-200 p-3 overflow-x-auto",children:e.jsx("pre",{className:"text-xs text-gray-700 whitespace-pre-wrap break-words",children:Pe(v)})})]})]},t.id)}),e.jsx("div",{className:"flex items-center justify-center pt-2",children:Je?e.jsx("button",{type:"button",onClick:()=>{ie(!1).catch(()=>{})},disabled:ve,className:"inline-flex items-center px-4 py-2 border border-gray-300 rounded-md bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50",children:ve?"Loading more...":"Load more logs"}):e.jsx("span",{className:"text-xs text-gray-500",children:"Showing loaded logs (no more results)."})})]}),Ge&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/45 px-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-xl border border-amber-200 bg-white shadow-2xl",children:[e.jsxs("div",{className:"px-6 pt-6 pb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Enable Verbose Telemetry?"}),e.jsx("p",{className:"mt-2 text-sm text-gray-700 leading-relaxed",children:"Verbose mode should be enabled only for targeted investigation windows. It captures materially more telemetry data than standard logging, which can increase operational overhead and include broader runtime context."}),e.jsx("p",{className:"mt-2 text-sm text-amber-800 bg-amber-50 border border-amber-200 rounded-md px-3 py-2",children:"Recommendation: enable temporarily during incident analysis, then revert to standard logging."})]}),e.jsxs("div",{className:"px-6 pb-6 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>se(!1),className:"inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>{Ye().catch(()=>{})},className:"inline-flex items-center rounded-md border border-indigo-600 bg-indigo-600 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-500",children:"OK, Enable Verbose"})]})]})}),He&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/45 backdrop-blur-[1px] px-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-xl border border-amber-200 bg-white shadow-2xl",children:[e.jsxs("div",{className:"px-6 pt-6 pb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Extended Log History Is Pro"}),e.jsx("p",{className:"mt-2 text-sm text-gray-700 leading-relaxed",children:"Starter includes Cloud Logs filtering up to the last 7 days. Upgrade to Pro or higher to unlock 30-day and all-time filtering."})]}),e.jsxs("div",{className:"px-6 pb-6 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>ye(!1),className:"inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50",children:"Keep Starter"}),e.jsx("button",{type:"button",onClick:()=>
1{ye(!1),s("/checkout?plan=pro")},className:"inline-flex items-center rounded-md border border-amber-500 bg-amber-500 px-4 py-2 text-sm font-semibold text-white hover:bg-amber-400",children:"Choose Pro"})]})]})})]})})}export{_t 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.