import{p as v,O as u,C as x,j as e,b,v as _,c as N,a as y,w as C,r as L,H as g}from"./index-a77bd902.js";import{w,T as S}from"./bootstrap-5.esm-44d3f0d4.js";import{_ as E}from"./_baseSet-2ead6744.js";var F=u,j=/[\\^$.*+?()[\]{}|]/g,R=RegExp(j.source);function T(s){return s=F(s),s&&R.test(s)?s.replace(j,"\\$&"):s}var $=T;const D=v($);var K=E;function P(s,o,a){return s==null?s:K(s,o,a)}var H=P;const I=v(H),O={"hide-description":"_hide-description_19xm6_1"},k=w(S);function z(s){const{schema:o={},schemaKey:a="",config:c={},configKey:t="",onChange:r}=s,n=x(c,t,{}),d=x(o,a,{}),l=i=>{const h={};I(h,t,i.formData),r(h)};return e.jsx(k,{schema:d,className:O["hide-description"],formData:n,onChange:l,children:e.jsx("div",{})})}const m="all",p=({text:s})=>e.jsx(e.Fragment,{children:s}),A=({text:s="",highlight:o=""})=>{if(!o.trim())return e.jsx(p,{text:s});const a=new RegExp(`(${D(o)})`,"gi"),c=s.split(a);return e.jsx(e.Fragment,{children:c.filter(t=>t).map((t,r)=>a.test(t)?e.jsx("mark",{children:t},r):e.jsx(p,{text:t},r))})};function f(s){const{logLevel:o,log:a,search:c}=s,t=o===m&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:"60px"},className:b("badge",{"bg-danger":a.level==="error","bg-warning":a.level==="warning","bg-info":a.level==="info","bg-secondary":!["error","warning","info"].includes(a.level)},"text-capitalize"),children:a.level})," "]});return e.jsxs("div",{children:[t,e.jsx("small",{className:"pe-1",children:_(a.timestamp)}),e.jsx("code",{children:e.jsx(A,{text:a.message,highlight:c})})]})}const B=[m,"debug","info","warning","error"],M=[100,200,500,1e3];class W extends L.Component{constructor(){super(...arguments),this.state={search:"",logLevel:m}}renderSearch(){const{clearLogs:o,bridgeInfo:{config_schema:a,config:c},updateBridgeConfig:t,t:r}=this.props,{search:n}=this.state,{logsLimit:d}=g.getState();return e.jsx("div",{className:"card",children:e.jsx("div",{className:"card-body",children:e.jsxs("div",{className:"row row-cols-lg-auto g-3 align-items-center",children:[e.jsxs("div",{className:"col-12 col-sm-4 col-xxl-4",children:[e.jsx("label",{htmlFor:"log-level",className:"form-label",children:r("show_only")}),e.jsx("select",{id:"log-level",className:"form-select",onChange:l=>this.setState({logLevel:l.target.value}),children:B.map(l=>e.jsx("option",{value:l,children:l},l))})]}),e.jsxs("div",{className:"col-12 col-sm-4 col-xxl-4",children:[e.jsx("label",{htmlFor:"search-filter",className:"form-label",children:r("filter_by_text")}),e.jsx("input",{id:"search-filter",className:"form-control col-10",placeholder:r("common:enter_search_criteria"),value:n,onChange:l=>this.setState({search:l.target.value}),type:"text"})]}),e.jsx("div",{className:"col-12 col-sm-4 col-xxl-4",children:e.jsx(z,{schema:a,schemaKey:"properties.advanced.properties.log_level",config:c,configKey:"advanced.log_level",onChange:t})}),e.jsxs("div",{className:"col-12 col-sm-4 col-xxl-4",children:[e.jsx("label",{htmlFor:"logs-limit",className:"form-label",children:r("logs_limit")}),e.jsx("select",{id:"logs-limit",className:"form-select",onChange:l=>{const i=parseInt(l.target.value);g.setState({logsLimit:i,logs:[...g.getState().logs.slice(-i)]})},children:M.map(l=>e.jsx("option",{value:l,selected:l==d,children:l},l))})]}),e.jsxs("div",{className:"col-12",children:[e.jsx("label",{htmlFor:"reset",children:" "}),e.jsx("input",{id:"reset",type:"button",onClick:o,className:"btn btn-primary form-control",value:r("common:clear")})]})]})})})}render(){let{logs:o}=this.props;const{t:a}=this.props,{search:c,logLevel:t}=this.state;return o=o.filter(r=>(t===m||r.level===t)&&(!c||r.message.toLowerCase().includes(c.toLowerCase()))).sort(),e.jsxs(e.Fragment,{children:[this.renderSearch(),e.jsx("div",{className:"card",children:e.jsxs("div",{className:"card-body",children:[o.length==0?e.jsx("h1",{children:a("empty_logs_message")}):null,e.jsx("div",{className:"overflow-auto",children:o.map((r,n)=>e.jsx(f,{log:r,search:c,logLevel:t},n))})]})})]})}}const q=["logs","bridgeInfo"],G=N(q,y)(C(["logs","common"])(W)),V=Object.freeze(Object.defineProperty({__proto__:null,ConnectedLogsPage:G,LogRow:f},Symbol.toStringTag,{value:"Module"}));export{m as A,f as L,V as i};
