import{r as l,W as w,C as y,a as r,b as N,a3 as S,j as s,a4 as x,F as u,f as k,B as f,y as E,a5 as I,a6 as M,a7 as A,a8 as F}from"./index-BeDhuS24.js";import{C as G}from"./CheckboxField-BhwpagjA.js";import{D}from"./DebouncedInput-jeSVRz3c.js";import{S as g}from"./SelectField-CgXiODUe.js";import"./envs-DFlyG_dH.js";const O={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 B(){const{sendMessage:m}=l.useContext(w),[t,d]=l.useState(""),[n,j]=l.useState("all"),[i,L]=l.useState(!1),h=y(),b=r(e=>e.logsLimit),v=r(e=>e.bridgeInfo.config.advanced.log_level),{t:a}=N("logs"),c=r(e=>e.logs),p=l.useMemo(()=>c.filter(e=>(n==="all"||e.level===n)&&(i||!t||e.message.toLowerCase().includes(t.toLowerCase()))),[t,i,n,c]),C=l.useCallback((e,o)=>t&&e.toLowerCase().includes(t.toLowerCase())?O[o]:S[o],[t]),_=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(g,{name:"log_level",label:a("show_only"),value:n,onChange:e=>j(e.target.value),children:[s.jsx("option",{value:"all",children:"all"},"all"),x.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("div",{className:"join",children:[s.jsxs("label",{className:"input w-64 join-item",children:[s.jsx(u,{icon:k}),s.jsx(D,{className:"",type:"search",onChange:e=>d(e.toString()),placeholder:a("common:search"),value:t})]}),s.jsx(f,{item:"",onClick:d,className:"btn btn-square join-item",title:a("common:clear"),children:s.jsx(u,{icon:E})})]})]}),s.jsx(G,{name:"highlight_only",label:a("highlight_only"),checked:i,onChange:e=>L(e.target.checked)}),s.jsx(g,{name:"log_limit",label:a("logs_limit"),onChange:e=>{h(M(Number.parseInt(e.target.value)))},value:b,children:I.map(e=>s.jsx("option",{value:e,children:e},e))}),s.jsx(f,{onClick:()=>{h(A())},className:"btn btn-primary self-center",disabled:c.length===0,children:a("common:clear")}),s.jsx("div",{className:"ml-auto",children:s.jsx(g,{name:"log_level_config",label:a("log_level_config"),value:v,onChange:e=>!e.target.validationMessage&&_(e.target.value),children:x.map(e=>s.jsx("option",{value:e,children:e},e))})})]}),s.jsx("div",{className:"mockup-code w-full mt-1 mb-3",children:p.length>0?p.map((e,o)=>s.jsx("pre",{"data-prefix":o,className:C(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:["[",F(new Date),"] ",a("empty_logs_message")]})})})]})}export{B as default};
