import{r as l,W as _,y as C,a as g,b as w,a1 as y,j as s,a2 as u,F as k,f as N,a3 as S,a4 as E,B as I,a5 as M,a6 as A}from"./index-vDL8KyrI.js";import{C as F}from"./CheckboxField-m1WCeVZk.js";import{D as G}from"./DebouncedInput-DpBqTOhq.js";import{S as d}from"./SelectField-apZm61cq.js";const D={error:"bg-error text-error-content",warning:"bg-warning text-warning-content",info:"bg-info text-info-content",debug:"bg-accent text-accent-content opacity-50"};function T(){const{sendMessage:m}=l.useContext(_),[t,c]=l.useState(""),[n,x]=l.useState("all"),[r,f]=l.useState(!1),h=C(),L=g(e=>e.logsLimit),b=g(e=>e.bridgeInfo.config.advanced.log_level),{t:a}=w("logs"),p=g(e=>e.logs),o=l.useMemo(()=>p.filter(e=>(n==="all"||e.level===n)&&(r||!t||e.message.toLowerCase().includes(t.toLowerCase()))),[t,r,n,p]),j=l.useCallback((e,i)=>t&&e.toLowerCase().includes(t.toLowerCase())?D[i]:y[i],[t]),v=l.useCallback(async e=>{await m("bridge/request/options",{options:{advanced:{log_level:e}}})},[m]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-row flex-wrap gap-3 items-top",children:[s.jsxs(d,{name:"log_level",label:a("show_only"),value:n,onChange:e=>x(e.target.value),children:[s.jsx("option",{value:"all",children:"all"},"all"),u.map(e=>s.jsx("option",{value:e,children:e},e))]}),s.jsxs("fieldset",{className:"fieldset",children:[s.jsx("legend",{className:"fieldset-legend",children:a("filter_by_text")}),s.jsxs("label",{className:"input w-64",children:[s.jsx(k,{icon:N}),s.jsx(G,{className:"",type:"search",onChange:e=>c(e.toString()),placeholder:a("common:search"),value:t,disabled:o.length===0}),s.jsx("kbd",{className:"kbd kbd-sm cursor-pointer",onClick:()=>c(""),onKeyUp:e=>{e.key==="enter"&&c("")},title:a("common:clear"),children:"x"})]})]}),s.jsx(F,{name:"highlight_only",label:a("highlight_only"),checked:r,onChange:e=>f(e.target.checked)}),s.jsx(d,{name:"log_limit",label:a("logs_limit"),onChange:e=>{h(E(Number.parseInt(e.target.value)))},value:L,children:S.map(e=>s.jsx("option",{value:e,children:e},e))}),s.jsx(I,{onClick:()=>{h(M())},className:"btn btn-primary self-center",disabled:o.length===0,children:a("common:clear")}),s.jsx("div",{className:"ml-auto",children:s.jsx(d,{name:"log_level_config",label:a("log_level_config"),value:b,onChange:e=>!e.target.validationMessage&&v(e.target.value),children:u.map(e=>s.jsx("option",{value:e,children:e},e))})})]}),s.jsx("div",{className:"mockup-code w-full mt-1",children:o.length>0?o.map((e,i)=>s.jsx("pre",{"data-prefix":i,className:j(e.message,e.level),children:s.jsxs("code",{children:["[",e.timestamp,"] ",e.message]})},`${e.timestamp}-${e.message}`)):s.jsx("pre",{"data-prefix":"~",children:s.jsxs("code",{children:["[",A(new Date),"] ",a("empty_logs_message")]})})})]})}export{T as default};
