import{C as k,E,G as A,u as _,a as r,r as t,j as s,N as T,M,A as G,J as F,S as D,a9 as O,F as h,ar as C,I as v,as as P,s as B,at as L,au as H,B as N,f as V,av as z}from"./index-VJpwYvBU.js";import{C as $}from"./CheckboxField-CBqKSuiA.js";import{D as q}from"./DebouncedInput-Bm_sFuTC.js";import{S as p}from"./SelectField-BkTP72p-.js";import{u as R}from"./useSearch-yONxWjVC.js";import"./envs-CRUy-_iG.js";const U={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"},J=t.memo(({sourceIdx:l})=>{const{t:a}=_(["logs","common"]),u=r(v(e=>e.bridgeInfo[l].config.advanced.log_level)),o=r(v(e=>e.logs[l])),c=r(e=>e.logsLimit),x=r(e=>e.setLogsLimit),n=r(e=>e.clearLogs),[m,i,j]=R(),[d,S]=t.useState("all"),[f,w]=t.useState(!1),b=t.useMemo(()=>o.filter(e=>(d==="all"||e.level===d)&&(f||i.length===0||e.message.toLowerCase().includes(i))),[i,f,d,o]),y=t.useCallback((e,g)=>i.length>0&&e.toLowerCase().includes(i)?U[g]:P[g],[i]),I=t.useCallback(async e=>{await B(l,"bridge/request/options",{options:{advanced:{log_level:e}}})},[l]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-row flex-wrap gap-3 items-top",children:[s.jsxs(p,{name:"log_level",label:a(e=>e.show_only,{ns:"common"}),value:d,onChange:e=>S(e.target.value),className:"select select-sm",children:[s.jsx("option",{value:"all",children:"all"},"all"),L.map(e=>s.jsx("option",{value:e,children:e},e))]}),s.jsxs("fieldset",{className:"fieldset",children:[s.jsx("legend",{className:"fieldset-legend",children:a(e=>e.filter_by_text)}),s.jsxs("div",{className:"join",children:[s.jsxs("label",{className:"input input-sm w-64 join-item",children:[s.jsx(h,{icon:H}),s.jsx(q,{onChange:j,placeholder:a(e=>e.search,{ns:"common"}),value:m})]}),s.jsx(N,{item:"",onClick:j,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:a(e=>e.clear,{ns:"common"}),disabled:m.length===0,children:s.jsx(h,{icon:V})})]})]}),s.jsx($,{name:"highlight_only",label:a(e=>e.highlight_only),checked:f,onChange:e=>w(e.target.checked),className:"checkbox checkbox-sm"}),s.jsx("fieldset",{className:"fieldset self-end",children:s.jsxs(N,{item:l,onClick:n,className:"btn btn-sm btn-outline btn-warning btn-primary",disabled:o.length===0,children:[s.jsx(h,{icon:C}),a(e=>e.clear,{ns:"common"})]})}),s.jsxs("div",{className:"ml-auto flex flex-row gap-3",children:[s.jsx(p,{name:"log_limit",label:a(e=>e.logs_limit),onChange:e=>{x(Number.parseInt(e.target.value,10))},value:c,className:"select select-sm",children:z.map(e=>s.jsx("option",{value:e,children:e},e))}),s.jsx(p,{name:"log_level_config",label:a(e=>e.log_level_config),value:u,onChange:e=>!e.target.validationMessage&&I(e.target.value),className:"select select-sm",children:L.map(e=>s.jsx("option",{value:e,children:e},e))})]})]}),s.jsx("div",{className:"mockup-code w-full mt-1 mb-3 before:content-none",children:b.length>0?b.map((e,g)=>s.jsx("pre",{"data-prefix":g,className:y(e.message,e.level),children:s.jsxs("code",{children:["[",e.timestamp,"] ",e.message]})},`${g}-${e.timestamp}`)):s.jsx("pre",{"data-prefix":"~",children:s.jsxs("code",{children:["[",new Date().toLocaleString(),"] ",a(e=>e.empty_logs_message)]})})})]})}),K=({isActive:l})=>l?"menu-active":void 0;function se(){const l=k(),{sourceIdx:a}=E(),[u,o]=A(a),{t:c}=_(["logs","common"]),x=r(n=>n.clearAllLogs);return t.useEffect(()=>{(!a||!o)&&l("/logs/0",{replace:!0})},[a,o,l]),s.jsxs(s.Fragment,{children:[s.jsx(T,{children:M&&s.jsxs("div",{className:"flex-1 flex flex-col",children:[s.jsx("div",{className:"menu menu-horizontal flex-1 pb-0",children:G.map((n,m)=>s.jsx("li",{children:s.jsx(F,{to:`/logs/${m}`,className:K,children:s.jsx(D,{idx:m,alwaysShowName:!0})})},n))}),s.jsx("div",{className:"menu menu-horizontal justify-end",children:s.jsxs(O,{onClick:x,className:"btn btn-sm btn-outline btn-warning btn-primary",title:c(n=>n.clear_all,{ns:"common"}),modalDescription:c(n=>n.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(n=>n.cancel,{ns:"common"}),children:[s.jsx(h,{icon:C}),c(n=>n.clear_all,{ns:"common"})]})})]})}),s.jsx(J,{sourceIdx:u},a)]})}export{se as default};
