import{dD as I,dE as E,dj as T,dG as _,dB as r,dq as o,dm as s,R as A,J as M,a as G,S as D,a0 as F,l as O,o as h,cU as C,dF as v,v as B,dx as P,u as L,bO as H,B as N,aN as V,w as q}from"./index-DjbVAZHL.js";import{C as z}from"./CheckboxField-h2bgaDmU.js";import{D as R}from"./DebouncedInput-BTa39xKg.js";import{S as p}from"./SelectField-XDAy-a1R.js";import{u as U}from"./useSearch-BqnvTMUj.js";import"./envs-CRUy-_iG.js";const $={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=o.memo(({sourceIdx:l})=>{const{t:a}=_(["logs","common"]),x=r(v(e=>e.bridgeInfo[l].config.advanced.log_level)),t=r(v(e=>e.logs[l])),c=r(e=>e.logsLimit),u=r(e=>e.setLogsLimit),n=r(e=>e.clearLogs),[m,i,j]=U(),[g,w]=o.useState("all"),[f,S]=o.useState(!1),b=o.useMemo(()=>t.filter(e=>(g==="all"||e.level===g)&&(f||i.length===0||e.message.toLowerCase().includes(i))),[i,f,g,t]),y=o.useCallback((e,d)=>i.length>0&&e.toLowerCase().includes(i)?$[d]:B[d],[i]),k=o.useCallback(async e=>{await P(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:g,onChange:e=>w(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(R,{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(z,{name:"highlight_only",label:a(e=>e.highlight_only),checked:f,onChange:e=>S(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:t.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=>{u(Number.parseInt(e.target.value,10))},value:c,className:"select select-sm",children:q.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:x,onChange:e=>!e.target.validationMessage&&k(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,d)=>s.jsx("pre",{"data-prefix":d,className:y(e.message,e.level),children:s.jsxs("code",{children:["[",e.timestamp,"] ",e.message]})},`${d}-${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=I(),{sourceIdx:a}=E(),[x,t]=T(a),{t:c}=_(["logs","common"]),u=r(n=>n.clearAllLogs);return o.useEffect(()=>{(!a||!t)&&l("/logs/0",{replace:!0})},[a,t,l]),s.jsxs(s.Fragment,{children:[s.jsx(A,{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(D,{to:`/logs/${m}`,className:K,children:s.jsx(F,{idx:m,alwaysShowName:!0})})},n))}),s.jsx("div",{className:"menu menu-horizontal justify-end",children:s.jsxs(O,{onClick:u,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:x},a)]})}export{se as default};
