@matterbridge/frontend 3.4.7 → 3.4.8-dev-20260314-d28b48a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/index.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/assets/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{j as e,r,V as Qr,X as Lt,Y as Yr,Z as Zr,$ as ct,a0 as Xr,a1 as eo,G as to}from"./vendor_node_modules.js";import{u as ro,S as oo}from"./vendor_notistack.js";import{D as Be,a as Ge,b as Je,B as fe,c as Ze,F as lt,C as et,d as he,A as no,I as te,e as io,f as so,T as A,g as lo,H as Tr,h as dr,i as Kt,j as Me,k as ur,l as Ut,S as Xe,M as E,m as ao,n as Ue,o as Nr,p as co,q as qt,r as ye,K as hr,s as fr,t as ar,L as Wt,u as wt,v as Ft,w as X,W as kt,x as Tt,y as Nt,z as ae,V as mr,E as xr,G as uo,J as po,Q as Rr,R as zt,N as go,U as ho,P as fo,O as ze,X as pr,Y as Or,Z as it,_ as _r,$ as mo,a0 as Hr,a1 as xo,a2 as bo,a3 as vo,a4 as br,a5 as yo,a6 as jo,a7 as wo,a8 as Co,a9 as So,aa as ko,ab as Io,ac as vr,ad as Mo,ae as Do,af as Po,ag as $o,ah as Lo,ai as Wo,aj as Fo,ak as To,al as No,am as Ro,an as Oo,ao as _o,ap as Ho,aq as Eo,ar as Ao,as as Vo,at as Uo,au as qo,av as We,aw as Er,ax as Jt,ay as rt,az as zo,aA as tt,aB as Bo,aC as Ct,aD as Ve,aE as Rt,aF as rr,aG as Go,aH as Jo}from"./vendor_mui.js";import{I as be,m as Ko,a as yr,b as Qo,c as Yo,d as jr,e as Zo,f as Xo,g as en,h as tn,i as rn,j as on,k as nn,l as sn,n as ln,o as an,p as cn,q as dn,r as wr,s as un,t as pn,u as gn,v as hn,w as fn,x as mn,y as xn,z as bn,A as Cr,B as vn,C as yn}from"./vendor_mdi.js";import{Q as jn}from"./vendor_qrcode.js";import{F as wn,v as Cn,e as Sn,a as kn,g as In,b as Mn,c as Dn,d as or,A as Pn}from"./vendor_rjsf.js";import"./vendor_emotion.js";import"./vendor_lodash.js";(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const d of s)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&i(h)}).observe(document,{childList:!0,subtree:!0});function a(s){const d={};return s.integrity&&(d.integrity=s.integrity),s.referrerPolicy&&(d.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?d.credentials="include":s.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function i(s){if(s.ep)return;s.ep=!0;const d=a(s);fetch(s.href,d)}})();function $n({open:n,title:l,message:a,onConfirm:i,onCancel:s}){const d=y=>{o&&console.log("Confirmed"),y.preventDefault(),i()},h=y=>{o&&console.log("Canceled"),y.preventDefault(),s()};return e.jsxs(Be,{open:n,children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(Je,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:a})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(fe,{onClick:d,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(fe,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ve="",re={enableMobile:`${ve}enableMobile`,devicesFilterPlugins:`${ve}devicesFilterPlugins`,devicesFilterDevices:`${ve}devicesFilterDevices`,devicesViewMode:`${ve}devicesViewMode`,frontendVersion:`${ve}frontendVersion`,matterbridgeVersion:`${ve}matterbridgeVersion`,homePageMode:`${ve}homePageMode`,logFilterLevel:`${ve}logFilterLevel`,logFilterSearch:`${ve}logFilterSearch`,logAutoScroll:`${ve}logAutoScroll`,logLength:`${ve}logLength`,frontendTheme:`${ve}frontendTheme`,homePagePlugins:`${ve}homePagePlugins`,virtualMode:`${ve}virtualMode`,installAutoExit:`${ve}installAutoExit`,searchPluginsTotal:`${ve}searchPluginsTotal`,searchPluginsMeta:`${ve}searchPluginsMeta`,searchPluginsVersions:`${ve}searchPluginsVersions`},Ln={Devices_table_order_by:`${ve}Devices_table_order_by`,Devices_table_order:`${ve}Devices_table_order`,Devices_column_visibility:`${ve}Devices_column_visibility`,Plugins_table_order_by:`${ve}Plugins_table_order_by`,Plugins_table_order:`${ve}Plugins_table_order`,Plugins_column_visibility:`${ve}Plugins_column_visibility`,"Registered devices_table_order_by":`${ve}Registered devices_table_order_by`,"Registered devices_table_order":`${ve}Registered devices_table_order`,"Registered devices_column_visibility":`${ve}Registered devices_column_visibility`,Clusters_table_order_by:`${ve}Clusters_table_order_by`,Clusters_table_order:`${ve}Clusters_table_order`,Clusters_column_visibility:`${ve}Clusters_column_visibility`};function Wn(){Object.values(re).forEach(n=>{localStorage.removeItem(n)}),Object.values(Ln).forEach(n=>{localStorage.removeItem(n)})}const Fn=({open:n,output:l,title:a,_command:i,_packageName:s,onInstall:d,onClose:h})=>{const{installAutoExit:y,setInstallAutoExit:t}=r.useContext(Oe),P=r.useRef(null),M=I=>{t(I.target.checked),localStorage.setItem(re.installAutoExit,I.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",I.target.checked)};return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${P.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",P.current),P.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[l]),e.jsxs(Be,{open:n,onClose:(I,D)=>{D==="backdropClick"||D==="escapeKeyDown"||h()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Ge,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:a})]})}),e.jsxs(Je,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[l.split(`
|
|
2
2
|
`).map((I,D)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:I},D)),e.jsx("li",{ref:P,style:{padding:0,margin:0}})]})]}),e.jsxs(Ze,{sx:{justifyContent:"space-evenly"},children:[d&&e.jsx(fe,{variant:"contained",onClick:d,children:"Install"}),e.jsx(fe,{onClick:h,children:"Close"}),e.jsx(lt,{control:e.jsx(et,{checked:y,onChange:I=>M(I)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},Ot=[],Oe=r.createContext(null);function Tn({children:n}){const[l,a]=r.useState(!1),[i,s]=r.useState(null),{enqueueSnackbar:d,closeSnackbar:h}=ro(),y=r.useCallback(T=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${T}`);const k=Ot.findIndex(R=>R.message===T);k!==-1&&(h(Ot[k].key),Ot.splice(k,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${T} removed from persistMessages`))},[h]),t=r.useCallback((T,k,R)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${T} timeout ${k}`);const U=d(T,{variant:"default",autoHideDuration:k==null||k>0?(k??5)*1e3:null,persist:k===0,content:K=>e.jsx(he,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(no,{severity:R??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>h(K),action:e.jsx(te,{size:"small",onClick:()=>h(K),sx:{color:"#fff"},children:e.jsx(io,{fontSize:"small"})}),children:T},K)},K)});k===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${T} timeout ${k} - persist key ${U}`),Ot.push({message:T,key:U}))},[d,h]),[P,M]=r.useState(!1),[I,D]=r.useState(""),[O,ee]=r.useState(""),[G,J]=r.useState(""),f=r.useRef(null),u=r.useRef(null),b=()=>{o&&console.log(`UiProvider handle confirm action ${G}`),M(!1),f.current&&f.current(G)},z=()=>{o&&console.log(`UiProvider handle cancel action ${G}`),M(!1),u.current&&u.current(G)},v=r.useCallback((T,k,R,U,K)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${R}`),D(T),ee(k),J(R),f.current=U,u.current=K,M(!0)},[]),[j,V]=r.useState(!1),[oe,C]=r.useState(""),[p,c]=r.useState(""),[x,W]=r.useState(""),[N,ce]=r.useState(""),[Ce,q]=r.useState(localStorage.getItem(re.installAutoExit)!=="false"),m=r.useCallback((T,k,R)=>{o&&console.log(`UiProvider show install progress for package ${T}`),C(T),c(k),W(R),V(!0)},[]),w=r.useCallback(T=>{o&&console.log(`UiProvider addInstallProgress: output ${T}`),ce(k=>k+T+`
|
|
3
3
|
`)},[]),F=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${x}`),localStorage.getItem(re.installAutoExit)!=="false"&&V(!1)},[x]),L=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${x}`)},[x]),S=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),V(!1)},[]),ne=()=>{o&&console.log("UiProvider handle install close action"),V(!1),W(""),ce("")},Se=r.useMemo(()=>({mobile:l,setMobile:a,currentPage:i,setCurrentPage:s,showSnackbarMessage:t,closeSnackbarMessage:y,closeSnackbar:h,showConfirmCancelDialog:v,showInstallProgress:m,exitInstallProgressSuccess:F,exitInstallProgressError:L,hideInstallProgress:S,addInstallProgress:w,installAutoExit:Ce,setInstallAutoExit:q}),[l,i,a,s,t,y,h,v,m,F,L,S,w,Ce,q]);return e.jsxs(Oe.Provider,{value:Se,children:[e.jsx($n,{open:P,title:I,message:O,onConfirm:b,onCancel:z}),e.jsx(Fn,{open:j,title:oe,_command:p,_packageName:x,output:N,onClose:ne}),n]})}const Ar=r.createContext(null),De=r.createContext(null);function Nn({children:n}){const[l,a]=r.useState([]),[i,s]=r.useState(localStorage.getItem(re.logFilterLevel)??"info"),[d,h]=r.useState(localStorage.getItem(re.logFilterSearch)??"*"),[y,t]=r.useState(!1),{showSnackbarMessage:P,closeSnackbarMessage:M,closeSnackbar:I,showInstallProgress:D,hideInstallProgress:O,exitInstallProgressSuccess:ee,exitInstallProgressError:G,addInstallProgress:J}=r.useContext(Oe),f=r.useRef([]),u=r.useRef(null),b=r.useRef(1),z=r.useRef(Math.floor(Math.random()*999e3)+1e3),v=r.useRef(null),j=r.useRef(null),V=r.useRef(null),oe=r.useRef(i),C=r.useRef(d),p=r.useRef(0),c=r.useRef(null),x=r.useRef(Number(localStorage.getItem(re.logLength)??200)),W=r.useRef(localStorage.getItem(re.logAutoScroll)!=="false"),N=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),ce=100,Ce=60,q=50,m=300,w=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),c.current=setInterval(()=>{p.current>0&&(o&&console.log(`WebSocket messages received in the last ${w} seconds: ${p.current*(60/w)} messages/minute`),p.current=0)},w*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),c.current&&clearInterval(c.current),c.current=null}),[]),r.useEffect(()=>{oe.current=i},[i]),r.useEffect(()=>{C.current=d},[d]);const F=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),L=r.useCallback((B,g)=>{o&&console.log(`WebSocket filterLogMessages called with level "${B}" and search "${g}"...`),a(ue=>ue.filter(Y=>!(["debug","info","notice","warn","error","fatal"].includes(Y.level)&&(B==="info"&&Y.level==="debug"||B==="notice"&&(Y.level==="debug"||Y.level==="info")||B==="warn"&&(Y.level==="debug"||Y.level==="info"||Y.level==="notice")||B==="error"&&(Y.level==="debug"||Y.level==="info"||Y.level==="notice"||Y.level==="warn")||B==="fatal"&&(Y.level==="debug"||Y.level==="info"||Y.level==="notice"||Y.level==="warn"||Y.level==="error"))||g!=="*"&&g!==""&&!g.startsWith("/")&&!g.endsWith("/")&&!Y.message.toLowerCase().includes(g.toLowerCase())&&!Y.name.toLowerCase().includes(g.toLowerCase())||g.startsWith("/")&&g.endsWith("/")&&(()=>{try{const H=new RegExp(g.slice(1,-1),"i");return!H.test(Y.message)&&!H.test(Y.name)}catch(H){return console.error(`WebSocket log search invalid regex filter "${g}":`,H),!1}})())))},[]),S=r.useCallback(B=>{if(u.current&&u.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${B.id}:`,B),B.id===void 0&&(B.id=z.current);const g=JSON.stringify(B);u.current.send(g),o&&console.log("WebSocket sent message:",B)}catch(g){o&&console.error(`WebSocket error sending message: ${g}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",B)},[]),ne=r.useCallback((B,g)=>{a(ue=>[...ue,{level:B,time:"",name:"",message:g}])},[]),Se=r.useCallback((B,g)=>{o&&console.log(`WebSocket addListener id ${g}:`,B),(g==null||isNaN(g)||g===0)&&console.error("WebSocket addListener called without id, listener not added:",B),f.current=[...f.current,{listener:B,id:g}],o&&console.log("WebSocket addListener total listeners:",f.current.length)},[]),T=r.useCallback(B=>{o&&console.log("WebSocket removeListener:",B),f.current=f.current.filter(g=>g.listener!==B),o&&console.log("WebSocket removeListener total listeners:",f.current.length)},[]),k=r.useCallback(()=>{N===""||N===null||N===void 0||(ne("WebSocket",`Connecting ${xt?"with password":""} to WebSocket: ${N}`),o&&console.log(`WebSocket connecting to: ${N}${xt?"?password=[redacted]":""}`),u.current=new WebSocket(N+(xt?`?password=${encodeURIComponent(xt)}`:"")),u.current.onmessage=B=>{y||t(!0),p.current+=1;try{const g=JSON.parse(B.data);if(g.id===void 0||g.src===void 0||g.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",g);return}if(g.src!=="Matterbridge"||g.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",g);return}if(g.error){o&&console.error("WebSocket error message response:",g);return}if(g.id===z.current&&g.method==="pong"&&g.response==="pong"){o&&console.log(`WebSocket pong response message id ${g.id}:`,g),j.current&&clearTimeout(j.current),j.current=null;return}else if(g.method==="snackbar"&&g.response&&g.response.message){o&&console.log(`WebSocket message id ${g.id} method ${g.method}:`,g),P(g.response.message,g.response.timeout,g.response.severity);return}else if(g.method==="close_snackbar"&&g.response&&g.response.message){o&&console.log(`WebSocket message id ${g.id} method ${g.method}:`,g),M(g.response.message);return}else if(g.method==="log"){if(!g.response||!g.response.level||!g.response.time||!g.response.name||!g.response.message||(g.response.level==="spawn"&&(g.response.name==="Matterbridge:spawn-init"?D(g.response.message,"",""):g.response.name==="Matterbridge:spawn-exit-success"?ee():g.response.name==="Matterbridge:spawn-exit-error"?G():J(g.response.message+`
|
|
4
|
-
`)),["debug","info","notice","warn","error","fatal"].includes(g.response.level)&&(oe.current==="info"&&g.response.level==="debug"||oe.current==="notice"&&(g.response.level==="debug"||g.response.level==="info")||oe.current==="warn"&&(g.response.level==="debug"||g.response.level==="info"||g.response.level==="notice")||oe.current==="error"&&(g.response.level==="debug"||g.response.level==="info"||g.response.level==="notice"||g.response.level==="warn")||oe.current==="fatal"&&(g.response.level==="debug"||g.response.level==="info"||g.response.level==="notice"||g.response.level==="warn"||g.response.level==="error")))||C.current!=="*"&&C.current!==""&&!C.current.startsWith("/")&&!C.current.endsWith("/")&&!g.response.message.toLowerCase().includes(C.current.toLowerCase())&&!g.response.name.toLowerCase().includes(C.current.toLowerCase())||C.current.startsWith("/")&&C.current.endsWith("/")&&(()=>{try{const Y=new RegExp(C.current.slice(1,-1),"i");return!Y.test(g.response.message)&&!Y.test(g.response.name)}catch(Y){return console.error(`WebSocket log search invalid regex filter "${C.current}":`,Y),!1}})()||g.response.name==="Commissioning"&&g.response.message.includes("is uncommissioned"))return;a(Y=>{const H=[...Y,{level:g.response.level,time:g.response.time,name:g.response.name,message:g.response.message}];return o&&console.log(`WebSocket new log message added (${H.length}/${x.current}):`,H[H.length-1]),H.length>x.current+x.current*10/100?(o&&console.log(`WebSocket sliced log messages to the last ${x.current} entries`),H.slice(H.length-x.current)):H})}else{if(o&&console.log(`WebSocket received message id ${g.id} method ${g.method}:`,g),g.id===0)f.current.forEach(ue=>ue.listener(g));else{const ue=f.current.find(Y=>Y.id===g.id);ue?ue.listener(g):console.warn(`WebSocket no listener found for message id ${g.id}:`,g)}return}}catch(g){console.error(`WebSocket error parsing message: ${g}`,g instanceof Error?g.stack:null)}},u.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${N}`),ne("WebSocket",`Connected to WebSocket: ${N}`),t(!0),I(),b.current=1,V.current=setTimeout(()=>{v.current=setInterval(()=>{S({id:z.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${N}`),ne("WebSocket",`No pong response received from WebSocket: ${N}`),t(!1)},1e3*q)},1e3*Ce)},1e3*m)},u.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${Mt?"with Ingress":""}: ${N}`),ne("WebSocket",`Disconnected from WebSocket: ${N}`),t(!1),I(),O(),V.current&&clearTimeout(V.current),j.current&&clearTimeout(j.current),v.current&&clearInterval(v.current),ne("WebSocket",`Reconnecting (attempt ${b.current} of ${ce}) to WebSocket${Mt?" (Ingress)":""}: ${N}`),Mt?setTimeout(R,5e3):b.current===1?R():b.current<ce?setTimeout(R,1e3*b.current):ne("WebSocket",`Reconnect attempts exceeded limit of ${ce} retries, refresh the page to reconnect to: ${N}`),b.current=b.current+1},u.current.onerror=B=>{o&&console.error(`WebSocket: WebSocket error connecting to ${N}:`,B),ne("WebSocket",`WebSocket error connecting to ${N}`)})},[N]),R=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${b.current}/${ce} to:`,N),k()},[k]);r.useEffect(()=>(k(),()=>{u.current&&u.current.readyState===WebSocket.OPEN&&u.current.close()}),[k]);const U=r.useMemo(()=>({messages:l,logLength:x,logAutoScroll:W,logFilterLevel:i,logFilterSearch:d,setMessages:a,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:L}),[l,x,W,i,d,a,s,h,L]),K=r.useMemo(()=>({logLength:x,logAutoScroll:W,logFilterLevel:i,logFilterSearch:d,setMessages:a,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:L,online:y,retry:b.current,getUniqueId:F,addListener:Se,removeListener:T,sendMessage:S,logMessage:ne}),[x,W,a,s,h,y,b.current,Se,T,S,ne]);return e.jsx(Ar.Provider,{value:U,children:e.jsx(De.Provider,{value:K,children:n})})}function Rn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function Ke(){const{retry:n}=r.useContext(De),l=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(Rn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(so,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(fe,{variant:"contained",color:"primary",onClick:l,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Vr({value:n,maxChars:l}){let a=n;if(n.length>l&&l>3){const i=l-3,s=n.substring(0,Math.ceil(i/2)),d=n.substring(n.length-Math.floor(i/2),n.length);a=`${s} … ${d}`}return n!==a?e.jsx(A,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:a})}):e.jsx("span",{children:a})}function Pe({children:n,style:l}){const a={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...a,...l},children:n})}function Ne({children:n,style:l}){const a={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...a,...l},children:n})}function $e({children:n,style:l}){const a={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...l},children:n})}function It({children:n,style:l}){const a={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...a,...l},children:n})}function mt({children:n,style:l}){const a={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...l},children:n})}function St({children:n,style:l}){const a={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...l},children:n})}function qe({children:n,style:l,onDragOver:a,onDragLeave:i,onDrop:s}){const d={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...d,...l},onDragOver:a,onDragLeave:i,onDrop:s,children:n})}function st({children:n,style:l,close:a}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...l},children:[n,ls]})}function On({systemInfo:n,compact:l}){const{mobile:a}=r.useContext(Oe),{addListener:i,removeListener:s,getUniqueId:d,sendMessage:h}=r.useContext(De),[y,t]=r.useState(n),P=r.useRef(d());if(o&&console.log("SystemInfoTable loading with systemInfo:",y,"compact:",l),n&&l&&y.totalMemory&&y.freeMemory){const f=y.totalMemory,u=y.freeMemory;y.freeMemory=`${u} / ${f}`,y.totalMemory=""}if(n&&l&&y.heapTotal&&y.heapUsed){const f=y.heapTotal,u=y.heapUsed;y.heapUsed=`${u} / ${f}`,y.heapTotal=""}if(n&&l&&y.osRelease&&y.osType){const f=y.osType,u=y.osRelease;y.osType=`${f} (${u})`,y.osRelease=""}if(n&&l&&y.osArch&&y.osPlatform){const f=y.osPlatform,u=y.osArch;y.osPlatform=`${f} (${u})`,y.osArch=""}const M=(f,u,b,z,v)=>{t(j=>({...j,totalMemory:f,freeMemory:u,heapTotal:b,heapUsed:z,rss:v}))},I=f=>{t(u=>({...u,cpuUsage:f.toFixed(2)+" %"}))},D=f=>{t(u=>({...u,processCpuUsage:f.toFixed(2)+" %"}))},O=(f,u)=>{t(b=>({...b,systemUptime:f,processUptime:u}))},ee=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:P.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const f=u=>{o&&console.log("SystemInfoTable received WebSocket Message:",u),u.method==="memory_update"&&u.response&&u.response.totalMemory&&u.response.freeMemory&&u.response.heapTotal&&u.response.heapUsed&&u.response.rss?(o&&console.log("SystemInfoTable received memory_update",u),M(u.response.totalMemory,u.response.freeMemory,u.response.heapTotal,u.response.heapUsed,u.response.rss)):u.method==="cpu_update"&&u.response&&u.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",u),I(u.response.cpuUsage),D(u.response.processCpuUsage)):u.method==="uptime_update"&&u.response&&u.response.systemUptime&&u.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",u),O(u.response.systemUptime,u.response.processUptime)):u.method==="/api/viewhistorypage"&&u.id===P.current&&u.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(f,P.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${P.current}`),()=>{s(f),o&&console.log("SystemInfoTable removed WebSocket listener")}},[i,s]);const[G,J]=r.useState(!1);return!y||G?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(Pe,{style:ke&&a?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"System info"}),e.jsx(st,{close:()=>J(!0),children:e.jsx(te,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:ee,children:e.jsx(A,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(be,{path:Ko,size:"22px"})})})})]}),e.jsx(qe,{style:ke&&a?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(y).filter(([f,u])=>u!==void 0&&u!=="").map(([f,u],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:f.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ke&&a?typeof u!="string"?u.toString():u:e.jsx(Vr,{value:typeof u!="string"?u.toString():u,maxChars:22})})]},f))})]})})]}))}const Sr=r.memo(On),kr={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},_n=n=>{if(!n)return"";const l=n.toString().replace(/[^0-9]/g,"");if(l.length<5)return l;const a=l.slice(0,4),i=l.slice(4,7),s=l.slice(7,11);return[a,i,s].filter(Boolean).join("-")};function Hn({id:n}){const{online:l,sendMessage:a,addListener:i,removeListener:s,getUniqueId:d}=r.useContext(De),[h,y]=r.useState(null),t=r.useRef(null),P=r.useRef(null),M=r.useRef(d()),{mobile:I,showConfirmCancelDialog:D}=r.useContext(Oe);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${P.current} and matter:`,h),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,P.current&&clearTimeout(P.current),P.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),y(null))},[n,a]),r.useEffect(()=>{const u=b=>{o&&console.log("QRDiv received WebSocket Message:",b),b.method==="refresh_required"&&b.response.changed==="matter"&&b.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${b.response.changed} for storeId "${b.response.matter.id}":`,b.response.matter),t.current===b.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${b.response.matter.id}":`,b.response.matter),P.current&&clearTimeout(P.current),y(b.response.matter)))};return i(u,M.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{s(u),P.current&&clearTimeout(P.current),P.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,s]);const O=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${h?.id}"`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,startCommission:!0}})},ee=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${h?.id}"`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,stopCommission:!0}})},G=()=>{o&&console.log(`QRDiv sent matter advertise for node "${h?.id}"`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,advertise:!0}})},J=u=>{o&&console.log(`QRDiv sent matter removeFabric for node "${h?.id}" and fabricIndex ${u}`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,removeFabric:u}})},f=async()=>{if(!h||!h.manualPairingCode)return;const u=h.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(u);else{const b=document.createElement("textarea");b.value=u,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}o&&console.log("Manual pairing code copied to clipboard")}catch(b){console.error("Failed to copy manual pairing code",b)}};return!h||!l?(o&&console.log("QRDiv rendering undefined state"),null):h.online?h.advertising&&h.qrPairingCode&&h.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"QR pairing code"}),e.jsxs(st,{children:[e.jsx(te,{"aria-label":"send advertising",size:"small",onClick:G,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:yr,size:"22px"})})}),e.jsx(te,{"aria-label":"stop pairing",size:"small",onClick:ee,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Turn off pairing",arrow:!0,children:e.jsx(be,{path:Qo,size:"22px"})})})]})]}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(jn,{value:h.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(It,{style:{justifyContent:"space-between"},children:[e.jsxs(mt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",_n(h.manualPairingCode)]}),e.jsx(st,{children:e.jsx(A,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(te,{"aria-label":"copy manual pairing code",size:"small",onClick:f,sx:kr,children:e.jsx(be,{path:Yo,size:.85})})})})]})]})):h.commissioned&&h.fabricInformations&&h.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Paired fabrics"}),e.jsxs(st,{children:[e.jsx(te,{"aria-label":"send advertising",size:"small",onClick:G,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:yr,size:"22px"})})}),e.jsx(te,{"aria-label":"start pairing",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Turn on pairing",arrow:!0,children:e.jsx(be,{path:jr,size:"22px"})})})]})]}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(qe,{style:{flexDirection:"column",justifyContent:"flex-start",flex:"1 1 auto",overflow:"auto",padding:"0px 0px 10px 0px",gap:"0px"},children:h.fabricInformations.map((u,b)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",u.fabricIndex]}),e.jsx(A,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(te,{"aria-label":"remove the fabric",size:"small",onClick:()=>D("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>J(u.fabricIndex),()=>{}),sx:{...kr,padding:"2px"},children:e.jsx(be,{path:Zo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",u.rootVendorId," ",u.rootVendorName]}),u.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",u.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",h.sessionInformations?h.sessionInformations.filter(z=>z.fabric?.fabricIndex===u.fabricIndex&&z.isPeerActive===!0).length:"0"," ","subscriptions: ",h.sessionInformations?h.sessionInformations.filter(z=>z.fabric?.fabricIndex===u.fabricIndex&&z.isPeerActive===!0&&z.numberOfActiveSubscriptions>0).length:"0"]})]},b))}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):!h.commissioned&&!h.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ne,{children:e.jsx($e,{children:"QR pairing code"})}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(fe,{onClick:O,endIcon:e.jsx(be,{path:jr,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ne,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx($e,{children:"Server node"})}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(St,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]}))}const Ir=r.memo(Hn);function En({title:n,children:l}){const a=r.useRef(null),[i,s]=r.useState(!1),d=()=>{const t=a.current;if(!t){s(!1);return}s(t.scrollWidth>t.clientWidth)},h=()=>{s(!1)},y={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsx(A,{title:n,open:i,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("span",{ref:a,onMouseEnter:d,onMouseLeave:h,style:y,children:l})})}function An(n,l,a){const i=n?.[a],s=l?.[a];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Vn({name:n,title:l,columns:a,rows:i,getRowKey:s,footerLeft:d,footerRight:h,onRowClick:y}){const t=r.useRef(new WeakMap),P=r.useRef(1),M=c=>{if(typeof s=="string"&&c&&c[s]!=null)return c[s];if(typeof s=="function"){const N=s(c);if(N!=null)return N}const x=a?.[0]?.id;if(x&&c&&c[x]!=null)return c[x];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let W=t.current.get(c);return W||(W=`rk_${P.current++}`,t.current.set(c,W)),W},[I,D]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[O,ee]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[G,J]=r.useState(!1),[f,u]=r.useState(()=>{try{const c=localStorage.getItem(`${n}_column_visibility`);if(c)return JSON.parse(c)}catch{}return{}}),b=r.useMemo(()=>{const c={};for(const x of a)x.hidden||(c[x.id]=x.required?!0:f[x.id]!==!1);return c},[a,f]),z=r.useMemo(()=>{if(!I||!O)return i;const c=a.find(W=>W.id===I);if(!c||c.noSort)return i;const x=i.map((W,N)=>({el:W,index:N}));return x.sort((W,N)=>{let ce;return typeof c.comparator=="function"?ce=c.comparator(W.el,N.el):ce=An(W.el,N.el,I),ce!==0?O==="asc"?ce:-ce:W.index-N.index}),x.map(W=>W.el)},[i,I,O,a]),v=c=>{if(I!==c||!I){D(c),ee("asc"),localStorage.setItem(`${n}_table_order_by`,c),localStorage.setItem(`${n}_table_order`,"asc");return}if(O==="asc"){ee("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}D(null),ee(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{J(!G)},V=c=>{u(x=>{const W=a.find(Ce=>Ce.id===c);if(W&&W.required)return x;const N=b[c]!==!1,ce={...x};N?ce[c]=!1:delete ce[c];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(ce))}catch{}return ce})},oe=()=>{u({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}J(!1)},[C,p]=r.useState(!1);return C?null:(o&&console.log(`Rendering table ${n}${I&&O?` ordered by ${I}:${O}`:""}`),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsxs(Be,{open:G,onClose:(c,x)=>{x==="backdropClick"||x==="escapeKeyDown"||j()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Je,{children:e.jsx(lo,{children:a.filter(c=>!c.hidden).map(c=>e.jsx(lt,{control:e.jsx(et,{disabled:!!c.required,checked:c.required?!0:b[c.id]!==!1,onChange:()=>V(c.id)}),label:c.label},c.id))})}),e.jsxs(Ze,{children:[e.jsx(fe,{onClick:oe,children:"Reset"}),e.jsx(fe,{variant:"contained",onClick:c=>{if(c?.currentTarget&&typeof c.currentTarget.blur=="function")try{c.currentTarget.blur()}catch{}const x=document.activeElement;if(x&&x instanceof HTMLElement&&typeof x.blur=="function")try{x.blur()}catch{}j()},children:"Close"})]})]}),e.jsxs(Ne,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx($e,{children:n}),l&&e.jsx($e,{children:l}),e.jsx(st,{close:()=>p(!0),children:e.jsx(te,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:c=>{if(c?.currentTarget?.blur)try{c.currentTarget.blur()}catch{}j()},"aria-label":"Configure Columns",children:e.jsx(A,{title:`Configure ${n} columns`,children:e.jsx(be,{path:Xo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx(qe,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:a.map(c=>{if(c.hidden||!c.required&&b[c.id]===!1)return null;const x=!c.noSort,W=x&&I===c.id&&!!O;return e.jsxs("th",{onClick:x?()=>v(c.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:c.minWidth,maxWidth:c.maxWidth,textAlign:c.align||"left",cursor:x?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:c.maxWidth?"nowrap":void 0,overflow:c.maxWidth?"hidden":void 0,textOverflow:c.maxWidth?"ellipsis":void 0},"aria-sort":x?W?O==="asc"?"ascending":"descending":"none":void 0,children:[c.label,W&&e.jsxs("span",{style:{marginLeft:6},children:[O==="asc"&&e.jsx(be,{path:en,size:"15px"}),O==="desc"&&e.jsx(be,{path:tn,size:"15px"})]})]},c.id)})})}),e.jsx("tbody",{children:z.map((c,x)=>{const W=M(c);return e.jsx("tr",{className:x%2===0?"table-content-even":"table-content-odd",onClick:y?N=>y(c,W,N):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:y?"pointer":void 0},children:a.map(N=>{if(N.hidden||!N.required&&b[N.id]===!1)return null;const ce=c[N.id],Ce=typeof N.render=="function"?N.render(ce,W,c,N):typeof ce=="boolean"?e.jsx(et,{checked:ce,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):N.format&&typeof ce=="number"?N.format(ce):ce!=null?String(ce):null,m=!!N.tooltip&&N.maxWidth!==void 0&&N.maxWidth!==null&&ce!==void 0&&ce!==null&&Ce!==null?e.jsx(En,{title:String(ce),children:Ce}):Ce;return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:N.align||"left",padding:"5px 10px",margin:"0",maxWidth:N.maxWidth,whiteSpace:N.maxWidth?"nowrap":void 0,overflow:N.maxWidth?"hidden":void 0,textOverflow:N.maxWidth?"ellipsis":void 0},children:m},N.id)})},W)})})]})}),(d||h)&&e.jsxs(It,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx(mt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:d}),e.jsx(mt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h})]})]}))}function Un(n){return r.memo(n)}const Dt=Un(Vn),Ur=n=>n.replace("git+","").replace(".git","").trim(),qn=n=>{let l=Ur(n);return l.startsWith("git://")&&(l=`https://${l.slice(6)}`),l.startsWith("ssh://git@github.com/")&&(l=`https://github.com/${l.slice(21)}`),l.startsWith("git@github.com:")&&(l=`https://github.com/${l.slice(15).replace(":","/")}`),l},zn=n=>{if(typeof n=="string")return n.trim()||null;if(!n||typeof n!="object")return null;const l=n.url;return typeof l=="string"&&l.trim()||null},Bn=()=>{try{const n=window.localStorage.getItem(re.searchPluginsTotal);if(!n)return{};const l=JSON.parse(n);if(!l||typeof l!="object")return{};const a={};for(const[i,s]of Object.entries(l)){if(!i||!s||typeof s!="object")continue;const d=s;typeof d.total=="number"&&typeof d.asOf=="string"&&(a[i]={total:d.total,asOf:d.asOf})}return a}catch{return{}}},Gn=n=>{try{window.localStorage.setItem(re.searchPluginsTotal,JSON.stringify(n))}catch{}},Jn=()=>{try{const n=window.localStorage.getItem(re.searchPluginsMeta);if(!n)return{};const l=JSON.parse(n);if(!l||typeof l!="object")return{};const a={};for(const[i,s]of Object.entries(l)){if(!i||!s||typeof s!="object")continue;const d=s;if(typeof d.asOf!="string")continue;const h=typeof d.homepage=="string"?d.homepage:null,y=typeof d.help=="string"?d.help:null,t=typeof d.changelog=="string"?d.changelog:null;a[i]={homepage:h,help:y,changelog:t,asOf:d.asOf}}return a}catch{return{}}},Kn=n=>{try{window.localStorage.setItem(re.searchPluginsMeta,JSON.stringify(n))}catch{}},Qn=()=>{try{const n=window.localStorage.getItem(re.searchPluginsVersions);if(!n)return{};const l=JSON.parse(n);if(!l||typeof l!="object")return{};const a={};for(const[i,s]of Object.entries(l)){if(!i||!s||typeof s!="object")continue;const d=s;if(typeof d.asOf!="string"||!Array.isArray(d.versions))continue;const h=d.versions.filter(y=>typeof y=="string");a[i]={versions:h,asOf:d.asOf}}return a}catch{return{}}},Yn=n=>{try{window.localStorage.setItem(re.searchPluginsVersions,JSON.stringify(n))}catch{}},Zn=({open:n,onClose:l,onSelect:a,onVersions:i})=>{const[s,d]=r.useState(""),h=r.useRef(""),y=r.useRef(!1),t=r.useRef(null),[P,M]=r.useState([]),[I,D]=r.useState(!1),[O,ee]=r.useState(!1),[G,J]=r.useState(!1),[f,u]=r.useState({done:0,total:0}),[b,z]=r.useState(null),v=r.useRef({}),j=()=>{const q=document.activeElement;q&&q instanceof HTMLElement&&q.blur()},V=q=>{const m=q.getFullYear().toString(),w=(q.getMonth()+1).toString().padStart(2,"0"),F=q.getDate().toString().padStart(2,"0");return`${m}-${w}-${F}`},oe=r.useCallback(async(q,m)=>{const w=v.current[q];if(!!w&&w.asOf===m&&Array.isArray(w.versions)&&w.versions.length>0&&w.versions[0]==="latest")return o&&console.log(`[SearchPluginsDialog] versions cache hit for ${q} (${w.versions.length.toString()})`),w.versions;w&&w.asOf===m&&w.versions.length>0&&w.versions[0]!=="latest"&&o&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${q} (asOf=${m})`);const L=`https://registry.npmjs.org/${encodeURIComponent(q)}`;o&&console.log(`[SearchPluginsDialog] fetching versions for ${q} from: ${L}`);const S=await fetch(L,{signal:t.current?.signal});if(!S.ok)return o&&console.log(`[SearchPluginsDialog] versions fetch failed for ${q}: ${S.status.toString()} ${S.statusText}`),[];const ne=await S.json(),Se=Object.keys(ne.versions??{}),T=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});Se.sort((B,g)=>T.compare(B,g)).reverse();const k=ne["dist-tags"]??{},R=typeof k?.dev=="string"&&String(k.dev).trim().length>0,U=Se.slice(0,20),K=["latest"];return R&&K.push("dev"),K.push(...U),o&&console.log(`[SearchPluginsDialog] fetched versions for ${q} (tags: latest${R?", dev":""}; latestVersions=${U.length.toString()}; allVersions=${Se.length.toString()}):`,K),v.current[q]={versions:K,asOf:m},Yn(v.current),K},[]),C=q=>new Intl.NumberFormat().format(q),p=[{label:"Name",id:"name",required:!0,maxWidth:230,tooltip:!0},{label:"Version",id:"version",required:!0,maxWidth:110,tooltip:!0},{label:"Monthly",id:"downloads",align:"right",maxWidth:120,render:q=>typeof q=="number"?C(q):""},{label:"Total",id:"total",align:"right",maxWidth:120,render:q=>typeof q=="number"?C(q):""},{label:"Description",id:"description",required:!0,maxWidth:300,tooltip:!0},{label:"Author",id:"author",maxWidth:140,tooltip:!0},{label:"Action",id:"action",align:"center",maxWidth:100,noSort:!0,required:!0,render:(q,m,w,F)=>e.jsxs("div",{style:{margin:"0",padding:"0",gap:"4px",display:"flex",flexDirection:"row",justifyContent:"center"},children:[e.jsx(A,{title:w.homepage?"Open the plugin homepage":"No homepage available",children:e.jsx("span",{children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!w.homepage,onClick:L=>{if(L.stopPropagation(),!!w.homepage)try{const S=new URL(w.homepage);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Tr,{})})})}),e.jsx(A,{title:w.help?"Open the plugin help":"No help available",children:e.jsx("span",{children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!w.help,onClick:L=>{if(L.stopPropagation(),!!w.help)try{const S=new URL(w.help);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(dr,{})})})}),e.jsx(A,{title:w.changelog?"Open the plugin changelog":"No changelog available",children:e.jsx("span",{children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!w.changelog,onClick:L=>{if(L.stopPropagation(),!!w.changelog)try{const S=new URL(w.changelog);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Kt,{})})})})]})}];r.useEffect(()=>{if(!n){y.current=!1,h.current="",t.current?.abort(),t.current=null,M([]),D(!1),ee(!1),J(!1),u({done:0,total:0}),z(null),d("");return}if(y.current)return;y.current=!0;const q=new AbortController;return t.current=q,v.current=Qn(),(async()=>{const m="matterbridge-",F=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(m)}&size=250`,L=ne=>new Promise(Se=>setTimeout(Se,ne)),S=ne=>{if(!Array.isArray(ne.downloads))return null;let Se=0,T=!1;for(const k of ne.downloads)typeof k?.downloads=="number"&&(Se+=k.downloads,T=!0);return T?Se:null};try{D(!0),z(null);const ne=Q=>{const _=String(Q??"").trim().toLowerCase();return _?!!(_==="github actions"||_==="github-actions"||_==="github-actions[bot]"||_.includes("github-actions")||_.endsWith("[bot]")):!1},Se=Q=>{const _=(Q.maintainers??[]).map(le=>(le.username??"").trim()).filter(Boolean),ie=(Q.publisher?.username??"").trim(),ge=_.find(le=>!ne(le));return ge||(ie&&!ne(ie)?ie:_[0]??ie??"")},T=await fetch(F,{signal:q.signal});if(!T.ok)throw new Error(`npm registry request failed: ${T.status} ${T.statusText}`);const k=await T.json(),R="luligu",U=Q=>Q.publisher?.username?.toLowerCase()===R||(Q.maintainers??[]).some(_=>_.username?.toLowerCase()===R),B=(k.objects??[]).filter(Q=>!!Q?.package&&typeof Q.package.name=="string").filter(Q=>Q.package?.name?.startsWith(m)).filter(Q=>!cr.includes(Q.package?.name??"")).sort((Q,_)=>{const ie=U(Q.package??{}),ge=U(_.package??{});return ie!==ge?ie?-1:1:(Q.package?.name??"").localeCompare(_.package?.name??"")}).map(Q=>{const _=Q.package,ie=_.name??"",ge=Se(_),le=typeof Q.downloads?.monthly=="number"?Q.downloads.monthly:null,Ee=(_.links?.npm??"").trim(),yt=((_.links?.homepage??"").trim()||Ee||(ie?`https://www.npmjs.com/package/${encodeURIComponent(ie)}`:"")).trim()||null;return{name:ie,version:_.version??"",downloads:le,total:null,description:_.description??"",author:ge,official:U(_),homepage:yt,help:null,changelog:null}}),g=V(new Date),ue=Bn(),Y=Jn(),me=B.map(Q=>{const _=ue[Q.name];return!_||typeof _.total!="number"?Q:(o&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${Q.name} (asOf=${_.asOf}):`,_.total),{...Q,total:_.total})}).map(Q=>{const _=Y[Q.name];if(!_||_.asOf!==g)return Q;const ie=_.homepage??Q.homepage,ge=_.help,le=_.changelog;return o&&(ge||le||ie&&ie!==Q.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${Q.name} (asOf=${_.asOf}):`,{homepage:ie,help:ge,changelog:le}),{...Q,homepage:ie,help:ge,changelog:le}});M(me);const xe=B.map(Q=>Q.name).filter(Q=>{const _=v.current[Q];return!_||_.asOf!==g||_.versions.length===0});o&&console.log(`[SearchPluginsDialog] versions prefetch queue (${xe.length.toString()}):`,xe);const Ie=1,Ae=200;let je=0;const pe=async()=>{for(;je<xe.length;){if(q.signal.aborted)return;const Q=je;je+=1;const _=xe[Q];if(_)try{const ie=await oe(_,g);o&&ie.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${_} (${ie.length.toString()}):`,ie.slice(0,5))}catch(ie){if(ie instanceof DOMException&&ie.name==="AbortError")return}finally{q.signal.aborted||await L(Ae)}}};Promise.all(Array.from({length:Math.min(Ie,B.length)},()=>pe()));const de=B.map(Q=>Q.name).filter(Q=>{const _=Y[Q],ie=!!_&&_.asOf===g,ge=!!_&&!!_.help&&!!_.changelog,le=!ie||!ge;return!le&&o&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${Q} (asOf=${_.asOf}).`),ie&&!ge&&o&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${Q} (asOf=${_.asOf}).`),le}),Fe=new Set(de),_e=async(Q,_)=>{const ie=`https://registry.npmjs.org/${encodeURIComponent(Q)}/latest`;try{const ge=await fetch(ie,{signal:q.signal});if(!ge.ok)return null;const le=await ge.json(),Ee=typeof le.homepage=="string"&&le.homepage.includes("http")?Ur(le.homepage):null,nt=typeof le.help=="string"&&le.help.startsWith("http")?le.help.trim():null,yt=typeof le.changelog=="string"&&le.changelog.startsWith("http")?le.changelog.trim():null,gr=zn(le.repository),er=gr?qn(gr):null,jt=er&&er.includes("http")?er:null,tr=Ee||jt||_||null,Jr=nt||(jt?`${jt}/blob/main/README.md`:null)||tr||null,Kr=yt||(jt?`${jt}/blob/main/CHANGELOG.md`:null)||tr||null;return{homepage:tr,help:Jr,changelog:Kr}}catch(ge){return ge instanceof DOMException&&ge.name==="AbortError",null}},ot=1,Z=250;let $=0;const we=async()=>{for(;$<de.length;){if(q.signal.aborted)return;const Q=$;$+=1;const _=de[Q];if(!_||!Fe.has(_))continue;Fe.delete(_);const ie=B.find(le=>le.name===_)?.homepage??null,ge=await _e(_,ie);if(q.signal.aborted)return;ge&&(M(le=>le.map(Ee=>Ee.name===_?{...Ee,homepage:ge.homepage??Ee.homepage,help:ge.help,changelog:ge.changelog}:Ee)),Y[_]={homepage:ge.homepage,help:ge.help,changelog:ge.changelog,asOf:g},Kn(Y)),q.signal.aborted||await L(Z)}};Promise.all(Array.from({length:Math.min(ot,B.length)},()=>we()));const He="2020-01-01",Qe=B.map(Q=>Q.name).filter(Q=>{const _=ue[Q],ie=!_||_.asOf!==g;return ie||o&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${Q} (asOf=${_.asOf}).`),ie}),Te=new Set(Qe),at=Qe.length;u({done:0,total:at}),J(at>0);const $t=async Q=>{const _=`https://api.npmjs.org/downloads/range/${He}:${g}/${encodeURIComponent(Q)}`;for(let ie=0;ie<3;ie+=1){const ge=await fetch(_,{signal:q.signal});if(ge.ok){const le=await ge.json();return S(le)}if(ge.status===404)return null;if(ge.status===429){const le=ge.headers.get("retry-after"),Ee=le?Number(le):NaN,nt=Number.isFinite(Ee)?Ee*1e3:2e3*(ie+1);await L(nt);continue}return null}return null},Yt=1,Zt=500;let bt=0,vt=0;const Xt=async()=>{for(;bt<Qe.length;){if(q.signal.aborted)return;const Q=bt;bt+=1;const _=Qe[Q];if(_&&Te.has(_)){Te.delete(_);try{o&&console.log(`[SearchPluginsDialog] fetching total downloads for ${_} (range ${He}:${g})...`);const ie=await $t(_);if(q.signal.aborted)return;o&&console.log(`[SearchPluginsDialog] total downloads fetched for ${_}:`,ie),M(ge=>ge.map(le=>le.name===_?{...le,total:ie}:le)),typeof ie=="number"&&(ue[_]={total:ie,asOf:g},Gn(ue),o&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${_} (asOf=${g}):`,ie))}catch(ie){if(ie instanceof DOMException&&ie.name==="AbortError")return}finally{vt+=1,u({done:vt,total:at}),q.signal.aborted||await L(Zt)}}}};Promise.all(Array.from({length:Math.min(Yt,B.length)},()=>Xt())).finally(()=>{q.signal.aborted||J(!1)}),o&&console.log(`[SearchPluginsDialog] npm packages starting with "${m}" (filtered/sorted):`,B)}catch(ne){if(ne instanceof DOMException&&ne.name==="AbortError")return;console.error("[SearchPluginsDialog] npm registry fetch error:",ne),z(ne instanceof Error?ne.message:String(ne))}finally{D(!1)}})(),()=>q.abort()},[n,oe]);const c=async()=>{j();const q=h.current||s;if(!(!q||O))try{ee(!0);const m=V(new Date),w=await oe(q,m);o&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${q} (${w.length.toString()}):`,w),i(w),ee(!1),a(q)}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.error("[SearchPluginsDialog] npm versions fetch error:",m),i([]),ee(!1),a(q)}},x=()=>{j(),l(),i([])},W=P.reduce((q,m)=>q+(typeof m.downloads=="number"?m.downloads:0),0),N=P.reduce((q,m)=>(typeof m.total=="number"&&(q.total+=m.total,q.hasAny=!0),q),{total:0,hasAny:!1}),ce=G?` Totals: ${f.done.toString()}/${f.total.toString()} fetched`:"",Ce=N.hasAny?C(N.total):"...";return e.jsxs(Be,{open:n,onClose:()=>{j(),l()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:"75vw",height:"75vh",maxWidth:"75vw",maxHeight:"75vh",display:"flex",flexDirection:"column"}}},children:[e.jsx(Ge,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Search Plugins"})]})}),e.jsx(Je,{dividers:!0,sx:{padding:0,flex:"1 1 auto",minHeight:0},children:e.jsx("div",{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",minHeight:0},children:I?e.jsx("div",{style:{padding:"20px"},children:"Loading npm registry..."}):b?e.jsx("div",{style:{padding:"20px"},children:b}):e.jsx(Dt,{name:"Search plugins",rows:P,columns:p,getRowKey:"name",onRowClick:(q,m,w)=>{h.current=q.name,d(q.name),w.detail===2&&c()},footerLeft:`Total packages: ${P.length.toString()} Total downloads: ${C(W)} / ${Ce}${ce}`,footerRight:s?`Selected: ${s}`:""})})}),e.jsxs(Ze,{sx:{justifyContent:"center",gap:1.5,flexWrap:"wrap"},children:[e.jsx(A,{title:"Select the plugin and close the dialog. Double-click a row to select and close the dialog.",children:e.jsx(fe,{variant:"contained",onClick:c,disabled:!(h.current||s)||O,children:"Select"})}),e.jsx(A,{title:"Close the dialog without selecting a plugin.",children:e.jsx(fe,{onClick:x,children:"Cancel"})})]})]})},cr=["matterbridge-","matterbridge-plugin-template","matterbridge-dyson","matterbridge-irobot","matterbridge-tuya","matterbridge-mqtt","matterbridge-matter","matterbridge-security","matterbridge-automations","matterbridge-securitysystem","matterbridge-adapter"];function Xn(){const{mobile:n,showSnackbarMessage:l}=r.useContext(Oe),{logMessage:a,sendMessage:i,getUniqueId:s}=r.useContext(De),[d,h]=r.useState("matterbridge-"),[y,t]=r.useState(["latest","dev"]),[P,M]=r.useState("latest"),[I,D]=r.useState(!1),O=r.useRef(s()),ee=m=>{const w=String(m??"").trim();if(!w)return{name:"",specifier:null};if(w.startsWith("@")){const L=w.lastIndexOf("@");if(L>0){const S=w.slice(0,L),ne=w.slice(L+1);if(S.includes("/")&&ne)return{name:S,specifier:ne}}return{name:w,specifier:null}}const F=w.indexOf("@");if(F>0){const L=w.slice(0,F),S=w.slice(F+1);return S?{name:L,specifier:S}:{name:L,specifier:null}}return{name:w,specifier:null}},G=()=>{const{name:m,specifier:w}=ee(d);return m?w?`${m}@${w}`:P?`${m}@${P}`:m:""},J=m=>{m.preventDefault(),D(!0)},f=()=>{D(!1)},u=m=>{m.preventDefault(),D(!1);const w=m.dataTransfer.files[0];if(w){a("Plugins",`Installing package ${w.name}. Please wait...`);const F=new FormData;F.append("file",w),F.append("filename",w.name),fetch("./api/uploadpackage",{method:"POST",body:F}).then(L=>L.text()).then(L=>{a("Plugins",`Server response: ${L}`)}).catch(L=>{console.error("Error uploading plugin file:",L),a("Plugins",`Error installing package ${L}`)})}},b=m=>{const w=m.target.files&&m.target.files[0];if(w){a("Plugins",`Uploading package ${w.name}`);const F=new FormData;F.append("file",w),F.append("filename",w.name),fetch("./api/uploadpackage",{method:"POST",body:F}).then(L=>L.text()).then(L=>{a("Plugins",`Server response: ${L}`)}).catch(L=>{console.error("Error uploading plugin file:",L),a("Plugins",`Error uploading package ${L}`)})}},z=()=>{const m=G();if(m){if(cr.includes(m.split("@")[0])){l(`Installation of plugin "${m}" is blocked by the ignore list.`);return}i({id:O.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:m,restart:!1}})}},v=()=>{i({id:O.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:d}})},j=()=>{document.getElementById("file-upload")?.click()},V=()=>{if(cr.includes(d.split("@")[0])){l(`Addition of plugin "${d}" is blocked by the ignore list.`);return}i({id:O.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:d}})},oe=m=>{m.preventDefault(),o&&console.log("Right-clicked Upload button")},C=m=>{m.preventDefault(),o&&console.log("Right-clicked Add button")},[p,c]=r.useState(!1),x=()=>{c(!0),o&&console.log("Dialog opened for selection")},W=()=>{h("matterbridge-"),c(!1),o&&console.log("Dialog closed without selection")},N=m=>{h(m),c(!1),o&&console.log("Select plugin:",m)},ce=m=>{t(m),M(m.includes("latest")?"latest":m[0]??""),o&&console.log("Select plugin versions:",m)},[Ce,q]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),Ce?null:e.jsxs(Pe,{children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Install plugins"}),e.jsx(st,{close:()=>q(!0)})]}),e.jsxs(qe,{onDragOver:J,onDragLeave:f,onDrop:u,style:ke&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsx(Zn,{open:p,onClose:W,onSelect:N,onVersions:ce}),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(A,{title:"Provide the npm name or the local path of the plugin to install, uninstall, or add",children:e.jsx(Me,{value:d,onChange:m=>{const w=m.target.value;t(["latest","dev"]),M("latest"),h(w)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0})}),y.length>0&&e.jsx(A,{title:"Select the npm tag/version to install",children:e.jsx("span",{children:e.jsxs(ur,{size:"small",style:{minWidth:"150px"},children:[e.jsx(Ut,{id:"plugin-version-label",children:"Tag or version"}),e.jsx(Xe,{labelId:"plugin-version-label",id:"plugin-version",value:P,label:"Tag or version",onChange:m=>M(String(m.target.value??"")),sx:{"& .MuiSelect-icon":{color:"var(--main-label-color)"}},children:y.map(m=>e.jsx(E,{value:m,children:m},m))})]})})}),e.jsx(A,{title:"Search on npm the plugin to install",children:e.jsx(te,{size:"large",onClick:x,children:e.jsx(ao,{fontSize:"inherit"})})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(A,{title:"Install or update a plugin from npm",children:e.jsxs(fe,{onClick:z,endIcon:e.jsx(Ue,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(A,{title:"Uninstall and remove a plugin",children:e.jsxs(fe,{onClick:v,endIcon:e.jsx(Nr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(A,{title:"Upload and install a plugin from a tarball",children:e.jsxs(fe,{onClick:j,onContextMenu:oe,endIcon:e.jsx(co,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(A,{title:"Add an already installed plugin or a plugin from a local path",children:e.jsxs(fe,{onClick:V,onContextMenu:C,endIcon:e.jsx(qt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:b})]})]})]})}const ei=r.memo(Xn);function dt({status:n,enabledText:l="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const d=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?l:a??l});return i!==void 0?e.jsx(A,{title:i,children:d}):d}}function Mr(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const ut={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_t={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Dr={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},ti={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},ri={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ye={padding:"0px",margin:"0px"},oi="5px 10px 5px 10px",Ht={},Le={},Et={},At={};let pt=[],nr=[];function ir(n,l){const a=n?.properties;if(!a||typeof a!="object")return!1;const i=a[l];return!i||typeof i!="object"?!1:typeof i.type=="string"}function gt(n){const l=n.items;return l!==void 0&&typeof l=="object"&&!Array.isArray(l)}const ni=({open:n,onClose:l,plugin:a})=>{const{sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),y=r.useRef(h()),t=r.useRef({}),P=r.useRef({}),[M,I]=r.useState(a.configJson),[D,O]=r.useState(a.schemaJson),[ee,G]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[J,f]=r.useState("");let u={};r.useEffect(()=>{const T=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(Mr(k)&&k.id===y.current&&k.method==="/api/select/devices"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/devices:`,k.response),pt=k.response),Mr(k)&&k.id===y.current&&k.method==="/api/select/entities"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/entities:`,k.response),nr=k.response))};if(s(T,y.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",y.current),M&&D&&D.properties){const k=(R,U,K=[])=>{!R||typeof R!="object"||(R.properties&&Object.keys(R.properties).forEach(B=>{const g=R.properties?.[B],ue=[...K,B];Object.keys(g).forEach(Y=>{if(Y.startsWith("ui:")){let H=U;ue.forEach(me=>{H[me]||(H[me]={}),H=H[me]}),H[Y]=g[Y],delete g[Y]}}),k(g,U,ue)}),["oneOf","anyOf","allOf"].forEach(B=>{Array.isArray(R[B])&&R[B].forEach(g=>{k(g,U,K)})}),R.items&&typeof R.items=="object"&&k(R.items,U,K))};k(D,ee),G(ee),t.current=D,P.current=ee}return a.name&&a.configJson&&a.schemaJson&&(I(a.configJson),O(a.schemaJson),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',a.name)),()=>{d(T),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,M,a,d,D,i,ee]);const b=(T,k)=>{u=T.formData},z=T=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",T.formData),I(T.formData),a.configJson=T.formData,a.restartRequired=!0,i({id:y.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.formData.name,formData:T.formData}}),l()};function v(T){const{id:k,label:R,onKeyChange:U,onDropPropertyClick:K,disabled:B,schema:g,children:ue,registry:Y,readonly:H,required:me}=T,{templates:xe}=Y,{RemoveButton:Ie}=xe.ButtonTemplates;if(!(Pn in g))return e.jsx(he,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ue});const je=({target:pe})=>U(pe&&pe.value);return e.jsxs(he,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(Me,{id:`${k}-key`,name:`${k}-key`,required:me,disabled:B||H,defaultValue:R,onBlur:H?void 0:je,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(he,{sx:{flex:1},children:ue}),e.jsx(Ie,{disabled:B||H,onClick:K(R),registry:Y})]})}function j(T){const{children:k,description:R,displayLabel:U,errors:K,help:B,hidden:g,registry:ue,uiSchema:Y}=T,H=Mn(Y),me=Dn("WrapIfAdditionalTemplate",ue,H);return g?e.jsx("div",{style:{display:"none"},children:k}):e.jsx(he,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(me,{...T,children:[U===!0&&R,k,K,B]})})}function V(T){const{description:k}=T;return k?e.jsx(ye,{sx:_t,children:k}):null}function oe(T){const{required:k,title:R}=T;return R?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ye,{sx:ut,children:["Title ",R," ",k&&e.jsx("mark",{children:"***"})]})}):null}function C(T){const{help:k}=T;return k?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ye,{sx:ti,children:k})}):null}function p(T){const{errors:k}=T;return k?e.jsxs(he,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ye,{color:"error",sx:ri,children:"Please fix the following errors:"}),e.jsx(wt,{children:k.map((R,U)=>e.jsxs(uo,{children:[e.jsx(X,{children:e.jsx(po,{color:"error"})}),e.jsx(ae,{primary:R.stack})]},U))})]}):null}function c(T){const{errors:k}=T;return k?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((R,U)=>e.jsxs(ye,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",R]},U))}):null}function x(T){const{id:k,name:R,_schema:U,_uiSchema:K,value:B,options:g,label:ue,type:Y,placeholder:H,required:me,disabled:xe,readonly:Ie,autofocus:Ae,onChange:je,onChangeOverride:pe,onBlur:de,onFocus:Fe,_rawErrors:_e,_hideError:ot,_registry:Z,_formContext:$}=T,we=({target:{value:Te}})=>je(Te===""?g.emptyValue:Te),He=({target:Te})=>de(k,Te&&Te.value),Qe=({target:Te})=>Fe(k,Te&&Te.value);return e.jsx(he,{sx:{padding:"0px",margin:"0px"},children:e.jsx(Me,{id:k,name:k,label:H&&H!==""?ue:void 0,variant:"outlined",placeholder:H&&H!==""?H:ue,required:me,disabled:xe||Ie,autoFocus:Ae,value:B||B===0?B:"",type:Y,autoComplete:Y==="password"?"current-password":R,onChange:pe||we,onBlur:He,onFocus:Qe,fullWidth:!0})})}function W(T){return console.log("ArrayFieldTitleTemplate:",T),null}function N(T){return console.log("ArrayFieldDescriptionTemplate:",T),null}function ce(T){return console.log("ArrayFieldItemTemplate:",T),null}function Ce(T){const{canAdd:k,onAddClick:R,schema:U,title:K,formData:B}=T,[g,ue]=r.useState(!1),[Y,H]=r.useState(!1),[me,xe]=r.useState(!1),[Ie,Ae]=r.useState(""),je=$=>{Ae($.target.value)},pe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",Ie,"selectDevices:",pt),ue(!g)},de=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",Ie,"selectEntities:",nr),H(!Y)},Fe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",Ie,"selectDevices:",pt),xe(!me)},_e=$=>{ue(!1),U.selectFrom==="serial"&>(U)?U.items.default=$.serial:U.selectFrom==="name"&>(U)&&(U.items.default=$.name),R()},ot=$=>{H(!1),U.selectEntityFrom==="name"&>(U)?U.items.default=$.name:U.selectEntityFrom==="description"&>(U)&&(U.items.default=$.description),R()},Z=$=>{xe(!1),U.selectDeviceEntityFrom==="name"&>(U)?U.items.default=$.name:U.selectDeviceEntityFrom==="description"&>(U)&&(U.items.default=$.description),R()};return e.jsxs(he,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(ye,{sx:ut,children:K}),k&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[U.selectFrom&&e.jsx(A,{title:"Add a device from the list",children:e.jsx(te,{onClick:pe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),U.selectEntityFrom&&e.jsx(A,{title:"Add an entity from the list",children:e.jsx(te,{onClick:de,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),U.selectDeviceEntityFrom&&e.jsx(A,{title:"Add a device entity from the list",children:e.jsx(te,{onClick:Fe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),e.jsx(A,{title:"Add a new item",children:e.jsx(te,{onClick:R,size:"small",color:"primary",sx:Ye,children:e.jsx(qt,{})})})]})]}),U.description&&e.jsx(ye,{sx:_t,children:U.description}),T.items.map($=>e.jsxs(he,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(he,{sx:{flexGrow:1,marginRight:"10px"},children:$.children}),e.jsx(te,{disabled:!$.hasMoveUp,onClick:$.onReorderClick($.index,$.index-1),size:"small",color:"primary",sx:Ye,children:e.jsx(fr,{})}),e.jsx(te,{disabled:!$.hasMoveDown,onClick:$.onReorderClick($.index,$.index+1),size:"small",color:"primary",sx:Ye,children:e.jsx(hr,{})}),e.jsx(te,{onClick:$.onDropIndexClick($.index),size:"small",color:"primary",sx:Ye,children:e.jsx(ar,{})})]},$.index)),e.jsxs(Be,{open:g,onClose:pe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ge,{children:"Select a device"}),e.jsxs(Je,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Me,{fullWidth:!0,variant:"outlined",value:Ie,onChange:je,placeholder:"Enter serial or name"})]}),e.jsx(wt,{dense:!0,children:pt.filter($=>$.serial.toLowerCase().includes(Ie.toLowerCase())||$.name.toLowerCase().includes(Ie.toLowerCase())).filter($=>!U.uniqueItems||!B.includes(U.selectFrom==="serial"?$.serial:$.name)).map(($,we)=>e.jsxs(Ft,{onClick:()=>_e($),sx:Ht,children:[$.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),$.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),$.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),e.jsx(ae,{primary:$.name,secondary:$.serial,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},we))})]}),e.jsx(Ze,{children:e.jsx(fe,{onClick:pe,children:"Close"})})]}),e.jsxs(Be,{open:Y,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ge,{children:"Select an entity"}),e.jsxs(Je,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Me,{fullWidth:!0,variant:"outlined",value:Ie,onChange:je,placeholder:"Enter name or description"})]}),e.jsx(wt,{dense:!0,children:nr.filter($=>$.name.toLowerCase().includes(Ie.toLowerCase())||$.description.toLowerCase().includes(Ie.toLowerCase())).filter($=>!U.uniqueItems||!B.includes(U.selectEntityFrom==="name"?$.name:$.description)).map(($,we)=>e.jsxs(Ft,{onClick:()=>ot($),sx:Ht,children:[$.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),$.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),$.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),$.icon==="component"&&e.jsx(X,{children:e.jsx(mr,{style:Le})}),$.icon==="matter"&&e.jsx(X,{children:e.jsx(xr,{style:Le})}),e.jsx(ae,{primary:$.name,secondary:$.description,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},we))})]}),e.jsx(Ze,{children:e.jsx(fe,{onClick:de,children:"Close"})})]}),e.jsxs(Be,{open:me,onClose:Fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ge,{children:["Select an entity for ",K]}),e.jsx(Je,{children:e.jsx(wt,{dense:!0,children:pt.filter($=>$.serial===K||$.name===K).map($=>$.entities?.map((we,He)=>e.jsxs(Ft,{onClick:()=>Z(we),sx:Ht,children:[we.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),we.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),we.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),we.icon==="component"&&e.jsx(X,{children:e.jsx(mr,{style:Le})}),we.icon==="matter"&&e.jsx(X,{children:e.jsx(xr,{style:Le})}),e.jsx(ae,{primary:we.name,secondary:we.description,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},He)))})}),e.jsx(Ze,{children:e.jsx(fe,{onClick:Fe,children:"Close"})})]})]})}function q(T){const{onAddClick:k,schema:R,properties:U,title:K,description:B}=T,[g,ue]=r.useState(!1),[Y,H]=r.useState(""),me=pe=>{H(pe.target.value)},xe=()=>{ue(!g)},Ie=pe=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${pe.serial}" for schema "${R.selectFrom}"`),ue(!1);let de="";R.selectFrom==="serial"?de=pe.serial:R.selectFrom==="name"&&(de=pe.name),f(de),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${de}"`),k(R)()},Ae=()=>{k(R)()},je=!R.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${je} newkey "${J}"`),!je&&J!==""&&(o&&console.log("ObjectFieldTemplate: newkey",J,"properties",U),U.forEach(pe=>{if(pe.name==="newKey"&&pe.content.key==="newKey"&&pe.content.props.name==="newKey"&&pe.content.props.onKeyChange&&J!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",J);const de=J;f(""),pe.content.props.onKeyChange(de)}})),e.jsxs(he,{sx:{margin:"0px",padding:je?"10px":"5px 10px 0px 10px",border:je?"none":"1px solid grey"},children:[R.title&&je&&e.jsx(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ye,{sx:ut,children:R.title})}),K&&!je&&e.jsxs(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ye,{sx:ut,children:K}),e.jsxs(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[R.selectFrom&&e.jsx(A,{title:"Add a device from the list",children:e.jsx(te,{onClick:xe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),e.jsx(A,{title:"Add a new item",children:e.jsx(te,{onClick:Ae,size:"small",color:"primary",sx:Ye,children:e.jsx(qt,{})})})]})]}),R.description&&e.jsx(he,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ye,{sx:_t,children:R.description})}),U.map(({content:pe,name:de,hidden:Fe})=>!Fe&&e.jsxs(he,{sx:{margin:"0px",marginBottom:"10px",padding:ir(R,de)&&["object","array"].includes(R.properties[de].type)?"0px":oi,border:ir(R,de)&&["object","array"].includes(R.properties[de].type)?"none":"1px solid grey"},children:[ir(R,de)&&!["object","array","boolean"].includes(R.properties[de].type)&&e.jsx(ye,{sx:ut,children:R.properties[de].title||de}),e.jsx(he,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:pe})]},de)),e.jsxs(Be,{open:g,onClose:xe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ge,{children:"Select a device"}),e.jsxs(Je,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Me,{fullWidth:!0,variant:"outlined",value:Y,onChange:me,placeholder:"Enter serial or name"})]}),e.jsx(wt,{dense:!0,children:pt.filter(pe=>pe.serial.toLowerCase().includes(Y.toLowerCase())||pe.name.toLowerCase().includes(Y.toLowerCase())).map((pe,de)=>e.jsxs(Ft,{onClick:()=>Ie(pe),sx:Ht,children:[pe.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),pe.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),pe.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),e.jsx(ae,{primary:pe.name,secondary:pe.serial,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},de))})]}),e.jsx(Ze,{children:e.jsx(fe,{onClick:xe,children:"Close"})})]})]})}function m(T){const{uiSchema:k}=T,{submitText:R,norender:U}=In(k);return U?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(fe,{type:"submit",variant:"contained",color:"primary",children:R}),e.jsx(fe,{variant:"contained",color:"primary",onClick:l,children:"Cancel"})]})}function w(T){const{className:k,disabled:R,onClick:U,registry:K,style:B,uiSchema:g,...ue}=T;return e.jsx(A,{title:"Remove the item",children:e.jsx(te,{disabled:R,size:"small",color:"primary",onClick:U,children:e.jsx(ar,{})})})}function F(T){const{className:k,disabled:R,onClick:U,registry:K,uiSchema:B,...g}=T;return e.jsx(A,{title:"Add an item",children:e.jsx(te,{size:"small",color:"primary",onClick:U,children:e.jsx(qt,{})})})}function L(T){const{disabled:k,onClick:R,registry:U,style:K,uiSchema:B,...g}=T;return e.jsx(A,{title:"Move up the item",children:e.jsx(te,{size:"small",color:"primary",onClick:R,children:e.jsx(fr,{})})})}function S(T){const{disabled:k,onClick:R,registry:U,style:K,uiSchema:B,...g}=T;return e.jsx(A,{title:"Move down the item",children:e.jsx(te,{size:"small",color:"primary",onClick:R,children:e.jsx(hr,{})})})}function ne(T){const{id:k,name:R,value:U,schema:K,readonly:B,onChange:g}=T,[ue,Y]=r.useState(),H=xe=>{o&&console.log(`CheckboxWidget ${R} onChangeField:`,xe),Y(xe&&xe!==""?xe:void 0)},me=()=>{o&&console.log(`CheckboxWidget onClick plugin="${a.name}" action="${R}" value="${ue}"`),i({id:y.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:R,value:ue,formData:u,id:k}}),K.buttonClose===!0?l():K.buttonSave===!0&&z({formData:M})};return K.buttonText&&(K.title||K.description)?e.jsxs(he,{sx:{margin:"0px",padding:"5px 0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ye,{sx:Dr,children:K.title||K.description}),e.jsx(fe,{variant:"contained",color:"primary",onClick:()=>me(),children:K.buttonText})]}):K.buttonField&&(K.title||K.description)?e.jsxs(he,{sx:{margin:"0px",padding:"5px 0px",gap:"20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ye,{sx:Dr,children:K.title||K.description}),e.jsx(Me,{id:R+"-input",name:R,label:K.textLabel,placeholder:K.textPlaceholder,onChange:xe=>H(xe.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(fe,{id:R+"-button",variant:"contained",color:"primary",disabled:ue===void 0,onClick:()=>me(),children:K.buttonField})]}):e.jsxs(he,{sx:{margin:"0px",padding:"0px"},children:[R&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ye,{sx:ut,children:K.title||R}),e.jsx(et,{checked:U,readOnly:B,onChange:()=>g(!U),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(ye,{sx:_t,children:K.description})]})}function Se({schema:T,id:k,name:R,options:U,label:K,hideLabel:B,required:g,disabled:ue,placeholder:Y,readonly:H,value:me,multiple:xe,autofocus:Ie,onChange:Ae,onBlur:je,onFocus:pe,errorSchema:de,rawErrors:Fe=[],registry:_e,uiSchema:ot,hideError:Z,formContext:$,...we}){const{enumOptions:He,enumDisabled:Qe,emptyValue:Te}=U;xe=typeof xe>"u"?!1:!!xe;const at=xe?[]:"",$t=typeof me>"u"||xe&&me.length<1||!xe&&me===at,Yt=({target:{value:le}})=>Ae(or(le,He,Te)),Zt=({target:le})=>je(k,or(le&&le.value,He,Te)),bt=({target:le})=>pe(k,or(le&&le.value,He,Te)),vt=Sn(me,He,xe),{InputLabelProps:Xt,SelectProps:Q,autocomplete:_,...ie}=we,ge=!xe&&T.default===void 0;return e.jsxs(Me,{id:k,name:k,value:!$t&&typeof vt<"u"?vt:at,required:g,disabled:ue||H,autoFocus:Ie,autoComplete:_,placeholder:Y,error:Fe.length>0,onChange:Yt,onBlur:Zt,onFocus:bt,...ie,select:!0,InputLabelProps:{...Xt,shrink:!$t},SelectProps:{...Q,multiple:xe},"aria-describedby":kn(k),children:[ge&&e.jsx(E,{value:"",children:Y}),Array.isArray(He)&&He.map(({value:le,label:Ee},nt)=>{const yt=Array.isArray(Qe)&&Qe.indexOf(le)!==-1;return e.jsx(E,{value:String(nt),disabled:yt,children:Ee},nt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!D||!M?null:e.jsxs(Be,{open:n,onClose:l,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Je,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(wn,{schema:D,formData:M,uiSchema:ee,validator:Cn,templates:{FieldTemplate:j,BaseInputTemplate:x,TitleFieldTemplate:oe,DescriptionFieldTemplate:V,FieldHelpTemplate:C,FieldErrorTemplate:c,ErrorListTemplate:p,WrapIfAdditionalTemplate:v,ArrayFieldTitleTemplate:W,ArrayFieldDescriptionTemplate:N,ArrayFieldItemTemplate:ce,ArrayFieldTemplate:Ce,ObjectFieldTemplate:q,ButtonTemplates:{SubmitButton:m,RemoveButton:w,AddButton:F,MoveUpButton:L,MoveDownButton:S}},widgets:{CheckboxWidget:ne,SelectWidget:Se},onChange:b,onSubmit:z})})]})};function qr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let l=0,a=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&l++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(l===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function ii({storeId:n,setStoreId:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),{showConfirmCancelDialog:y}=r.useContext(Oe),t=r.useRef(h()),[P,M]=r.useState(null),[I,D]=r.useState(null),[O,ee]=r.useState([]),G=[{label:"Name",id:"name",required:!0,render:(F,L,S,ne)=>e.jsx(A,{title:`Plugin path ${S.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>C(S),children:S.name})})},{label:"Description",id:"description",render:(F,L,S,ne)=>e.jsx(A,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>C(S),children:S.description})})},{label:"Version",id:"version",render:(F,L,S,ne)=>e.jsx(e.Fragment,{children:e.jsx(A,{title:`Plugin v.${S.version}`,children:e.jsx("span",{children:S.version.split("-")[0]+(S.version.includes("-dev-")?"@dev":"")+(S.version.includes("-git-")?"@git":"")})})})},{label:"Author",id:"author",render:(F,L,S,ne)=>e.jsx(e.Fragment,{children:S.author?S.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(F,L,S,ne)=>e.jsx(e.Fragment,{children:S.type?S.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(F,L,S,ne)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[I&&I.bridgeMode==="childbridge"&&!S.error&&S.enabled&&e.jsx(A,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:qr(S.matter)},onClick:()=>{S.matter?.id&&l(S.matter?.id)},size:"small",children:e.jsx(Rr,{})})}),I&&I.bridgeMode==="childbridge"&&!S.error&&S.enabled&&e.jsx(A,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>V(S),size:"small",children:e.jsx(zt,{})})}),e.jsx(A,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{disabled:S.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>q(S),size:"small",children:e.jsx(go,{})})}),I&&!I.readOnly&&e.jsx(A,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{f("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",S)},size:"small",children:e.jsx(Nr,{})})}),S.enabled?e.jsx(A,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{f("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",S)},size:"small",children:e.jsx(ho,{})})}):e.jsx(e.Fragment,{}),S.enabled?e.jsx(e.Fragment,{}):e.jsx(A,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>oe(S),size:"small",children:e.jsx(fo,{})})}),e.jsx(A,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>c(S),size:"small",children:e.jsx(dr,{})})}),e.jsx(A,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>x(S),size:"small",children:e.jsx(Kt,{})})}),S.latestVersion!==void 0&&S.latestVersion!==S.version&&I&&!I.readOnly&&e.jsx(A,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>z(S),size:"small",children:e.jsx(ze,{})})}),(S.version.includes("-dev-")||S.version.includes("-git-"))&&S.devVersion!==void 0&&S.devVersion!==S.version&&I&&!I.readOnly&&e.jsx(A,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{color:"var(--secondary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>v(S),size:"small",children:e.jsx(ze,{})})}),I&&!I.readOnly&&e.jsx(A,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>p(S),size:"small",children:e.jsx(pr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(F,L,S,ne)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:S.error?e.jsx(e.Fragment,{children:e.jsx(dt,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:S.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(dt,{status:S.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:S.loaded&&S.started&&S.configured?e.jsx(e.Fragment,{children:e.jsx(dt,{status:S.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{status:S.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(dt,{status:S.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(dt,{status:S.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const F=L=>{o&&console.log("HomePlugins received WebSocket Message:",L),L.method==="refresh_required"&&L.response.changed==="plugins"?L.response.lock?(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} lock=${L.response.lock} and locking plugins list`),ee(S=>S.map(ne=>ne.name===L.response.lock?{...ne,restartRequired:!0}:ne))):(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} lock=${L.response.lock} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):L.method==="refresh_required"&&L.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} and setting matter id ${L.response.matter?.id}`),ee(S=>{const ne=S.findIndex(T=>T.matter?.id===L.response.matter?.id);if(ne<0)return o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} and matter id ${L.response.matter?.id} not found`),S;o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} set matter id ${L.response.matter?.id}`);const Se=[...S];return Se[ne]={...Se[ne],matter:L.response.matter},Se})):L.method==="refresh_required"&&L.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),L.id===t.current&&L.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${L.id}) received settings:`,L.response),M(L.response.systemInformation),D(L.response.matterbridgeInformation)):L.id===t.current&&L.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${L.id}) received ${L.response.length} plugins:`,L.response),ee(L.response))};return s(F,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{d(F),o&&console.log("HomePlugins removed WebSocket listener")}},[s,d,i]),r.useEffect(()=>{a&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]);const J=r.useRef(null),f=(F,L,S,ne)=>{o&&console.log(`handleActionWithConfirmCancel ${S} ${ne.name}`),J.current=ne,y(F,L,S,u,b)},u=F=>{o&&console.log(`handleConfirm action confirmed ${F} ${J.current?.name}`),F==="remove"&&J.current?j(J.current):F==="disable"&&J.current&&oe(J.current),J.current=null},b=F=>{o&&console.log(`handleCancel action canceled ${F} ${J.current?.name}`),J.current=null},z=F=>{o&&console.log("handleUpdatePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name,restart:!1}})},v=F=>{o&&console.log("handleUpdateDevPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name+"@dev",restart:!1}})},j=F=>{o&&console.log("handleRemovePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},V=F=>{o&&console.log("handleRestartPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},oe=F=>{o&&console.log("handleEnableDisablePlugin plugin:",F.name,"enabled:",F.enabled),F.enabled===!0?(F.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})):(F.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}}))},C=F=>{o&&console.log(`handleHomepagePlugin plugin: ${F.name} homepage: ${F.homepage}`),F.homepage&&window.open(F.homepage,"_blank")},p=F=>{o&&console.log("handleSponsorPlugin plugin:",F.name,"funding:",F.funding),F.funding&&window.open(F.funding,"_blank")},c=F=>{o&&console.log("handleHelpPlugin plugin:",F.name,"help:",F.help),F.help&&window.open(F.help,"_blank")},x=F=>{o&&console.log("handleChangelogPlugin plugin:",F.name,"changelog:",F.changelog),F.changelog&&window.open(F.changelog,"_blank")},[W,N]=r.useState(),[ce,Ce]=r.useState(!1),q=F=>{o&&console.log("handleConfigPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),N(F),m()},m=()=>{Ce(!0)},w=()=>{Ce(!1)};return o&&console.log("HomePlugins rendering..."),a?e.jsxs(Pe,{children:[W&&e.jsx(ni,{open:ce,onClose:w,plugin:W}),e.jsx(Dt,{name:"Plugins",columns:G,rows:O,footerRight:"",footerLeft:""})]}):e.jsx(Ke,{})}const si=r.memo(ii),li=n=>`${n.pluginName}::${n.serial}`;function ai({storeId:n,setStoreId:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),[y,t]=r.useState(!1),[P,M]=r.useState(!0),[I,D]=r.useState(null),[O,ee]=r.useState([]),[G,J]=r.useState([]),[f,u]=r.useState([]),[b,z]=r.useState([]),v=r.useRef(h()),j=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(C,p,c,x)=>c.reachable===!0?"Online":c.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(C,p)=>{const c=C.reachable===!0?1:C.reachable===!1?0:-1,x=p.reachable===!0?1:p.reachable===!1?0:-1;return c-x}},{label:"Power",id:"powerSource",render:(C,p,c,x)=>c.powerSource==="ac"||c.powerSource==="dc"?e.jsx(Or,{fontSize:"small",sx:{color:"var(--primary-color)"}}):c.powerSource==="ok"?c.batteryLevel?e.jsx(A,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"green"}})}):e.jsx(it,{fontSize:"small",sx:{color:"gray"}}):c.powerSource==="warning"?c.batteryLevel?e.jsx(A,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"yellow"}})}):e.jsx(it,{fontSize:"small",sx:{color:"yellow"}}):c.powerSource==="critical"?c.batteryLevel?e.jsx(A,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"red"}})}):e.jsx(it,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(C,p,c,x)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[c.matter!==void 0?e.jsx(A,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{onClick:()=>l(n===c.matter?.id?I?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:c.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:qr(c.matter)},children:e.jsx(Rr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.configUrl?e.jsx(A,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(_r,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.selected!==void 0?e.jsx(A,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(et,{checked:c.selected,onChange:W=>oe(W,c),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],V=r.useCallback(C=>{C.selected=void 0;const p=O.find(W=>W.name===C.pluginName);if(!p)return console.error(`HomeDevices isSelected: plugin ${C.pluginName} not found for device ${C.name} `),C.selected;const c=p.schemaJson?.properties?.whiteList?.selectFrom;let x=p.configJson.postfix;return x===""&&(x=void 0),p.hasWhiteList===!0&&p.hasBlackList===!0&&c&&(C.selected=!0,c==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(x?C.serial.replace("-"+x,""):C.serial)&&(C.selected=!0),c==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(x?C.serial.replace("-"+x,""):C.serial)&&(C.selected=!1),c==="serial"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(x?C.serial.replace("-"+x,""):C.serial)&&(C.selected=!1),c==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(C.name)&&(C.selected=!0),c==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(C.name)&&(C.selected=!1),c==="name"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(C.name)&&(C.selected=!1)),C.selected},[O]);r.useEffect(()=>{const C=p=>{if(o&&console.log("HomeDevices received WebSocket Message:",p),p.method==="refresh_required"&&p.response.changed!=="matter"?p.response.changed==="plugins"&&p.response.lock?o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} lock=${p.response.lock} skipping /api/plugins request`):(o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} and sending /api/plugins request`),i({id:v.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):p.method==="refresh_required"&&p.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} and setting matter id ${p.response.matter?.id}`),z(c=>{const x=c.findIndex(N=>N.name.replaceAll(" ","")===p.response.matter?.id);if(x<0)return o&&console.debug(`HomeDevices: matter id ${p.response.matter?.id} not found`),c;const W=[...c];return W[x]={...W[x],matter:p.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} and set matter id ${p.response.matter?.id}`),W})):p.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):p.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):p.method==="state_update"&&p.response.plugin&&p.response.serialNumber&&p.response.cluster.includes("BasicInformation")&&p.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${p.response.plugin} serial ${p.response.serialNumber} value ${p.response.value}`),J(c=>{const x=c.findIndex(W=>W.pluginName===p.response.plugin&&W.serial===p.response.serialNumber);return x<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${p.response.plugin} serial ${p.response.serialNumber}`),c):(c[x]={...c[x],reachable:p.response.value},[...c])})),p.id===v.current&&p.method==="/api/settings")o&&console.log(`HomeDevices (id: ${p.id}) received settings:`,p.response),D(p.response),t(p.response.matterbridgeInformation.restartRequired||p.response.matterbridgeInformation.fixedRestartRequired);else if(p.id===v.current&&p.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} plugins:`,p.response),p.response){let c=!0;for(const x of p.response)x.enabled===!0&&(x.loaded!==!0||x.started!==!0||x.error===!0)&&(c=!1);if(!c)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),M(!1),ee(p.response),J([]),u([]),i({id:v.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const x of p.response)x.enabled===!0&&x.loaded===!0&&x.started===!0&&x.error!==!0&&(i({id:v.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:x.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${x.name}`))}}else if(p.id===v.current&&p.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} devices:`,p.response),p.response){for(const c of p.response)c.selected=V(c);J(p.response)}}else p.id===v.current&&p.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} selectDevices for plugin ${p.response&&p.response.length>0?p.response[0].pluginName:"without select devices"}:`,p.response),p.response&&p.response.length>0&&u(c=>{const x=c.filter(N=>N.pluginName!==p.response[0].pluginName),W=p.response.map(N=>({...N,selected:V(N)}));return[...x,...W]}))};return s(C,v.current),o&&console.log(`HomeDevices added WebSocket listener id ${v.current}`),()=>{d(C),o&&console.log("HomeDevices removed WebSocket listener")}},[O,s,d,i,V]),r.useEffect(()=>{if(G.length===0&&f.length===0){z([]);return}o&&console.log(`HomeDevices mixing devices (${G.length}) and selectDevices (${f.length})`);const C=[];for(const p of G)C.push(p);for(const p of f)G.find(c=>c.pluginName===p.pluginName&&c.serial.includes(p.serial))||C.push(p);C.length>0&&(z(C),o&&console.log(`HomeDevices mixed ${C.length} devices and selectDevices`))},[O,G,f,z]),r.useEffect(()=>{a&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:v.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:v.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]);const oe=(C,p)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${C.target.checked} for device ${p.name} serial ${p.serial}`),G.findIndex(c=>c.pluginName===p.pluginName&&c.serial===p.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${p.name} serial ${p.serial} not found in devices, trying in mixedDevices`),z(c=>{const x=c.findIndex(W=>W.pluginName===p.pluginName&&W.serial===p.serial);return x<0?(console.error(`handleCheckboxChange: device ${p.name} serial ${p.serial} not found in mixedDevices`),c):(c[x]={...c[x],selected:C.target.checked},[...c])})):J(c=>{const x=c.findIndex(W=>W.pluginName===p.pluginName&&W.serial===p.serial);return x<0?(console.error(`handleCheckboxChange: device ${p.name} serial ${p.serial} not found in devices`),c):(c[x]={...c[x],selected:C.target.checked},[...c])}),C.target.checked?i({id:v.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}}):i({id:v.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}})};return o&&console.log("HomeDevices rendering..."),a?e.jsx(Pe,{style:{flex:"1 1 auto"},children:e.jsx(Dt,{name:"Devices",getRowKey:li,rows:b,columns:j,footerLeft:P?"Waiting for the plugins to fully load...":`Registered devices: ${G.length.toString()}/${b.length.toString()}`,footerRight:y?"Restart required":""})}):e.jsx(Ke,{})}const ci=r.memo(ai);function Pt({children:n,style:l,name:a}){const{setCurrentPage:i}=r.useContext(Oe);i(a),o&&console.log(`MbfPage: current page set to ${a}`);const s={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...s,...l},children:n})}const di=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function ui(){const{messages:n,logAutoScroll:l}=r.useContext(Ar),[a,i]=r.useState(!1),s=r.useRef(null),d=r.useRef(0),h=r.useRef(null),y=r.useMemo(()=>di(),[]),t=D=>i(!0),P=D=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${l.current} isHovering: ${a}`),l.current&&!a&&!y){const D=Date.now();D-d.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),d.current=D,s.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{s.current?.scrollIntoView({behavior:"smooth"}),d.current=Date.now()},1e3))}},[n,l,a,y]);const M=D=>{switch(D.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},I=D=>D.toLowerCase()==="warn"?"black":"white";return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:P,children:[n.map((D,O)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:M(D.level),color:I(D.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:D.level}),D.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+D.time+"]"}),D.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+D.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:D.message})]},O)),e.jsx("div",{ref:s})]})})}const zr=r.memo(ui);function pi(){const[n,l]=r.useState(localStorage.getItem(re.logFilterLevel)??"info"),[a,i]=r.useState(localStorage.getItem(re.logFilterSearch)??"*"),{online:s,logAutoScroll:d}=r.useContext(De);return o&&console.log("HomeLogs rendering..."),s?e.jsxs(Pe,{style:{flex:"1 1 auto"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Logs"}),e.jsxs($e,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',a===""?"*":a,'" Scroll: ',d.current?"auto":"manual"]})]}),e.jsx(qe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(zr,{})})]}):e.jsx(Ke,{})}const gi=r.memo(pi);function hi(){const{online:n}=r.useContext(De);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Pe,{children:[e.jsx(Ne,{children:e.jsx($e,{children:"Frontend Update"})}),e.jsxs(qe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(fe,{onClick:()=>window.location.reload(),endIcon:e.jsx(mo,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Ke,{})}const fi=r.memo(hi);function mi({changelog:n}){const{online:l}=r.useContext(De);return o&&console.log("HomeShowChangelog rendering..."),l?e.jsxs(Pe,{children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matterbridge Update"})}),e.jsxs(qe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(fe,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(Hr,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(fe,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(pr,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(fe,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Kt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(fe,{onClick:()=>window.location.reload(),endIcon:e.jsx(xo,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Ke,{})}const xi=r.memo(mi);function bi({matterbridgeInfo:n}){const{mobile:l}=r.useContext(Oe);o&&console.log("MatterbridgeInfoTable:",n);const a=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,s]=r.useState(!1);return!n||i?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(Pe,{style:ke&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Matterbridge info"}),e.jsx(st,{close:()=>s(!0)})]}),e.jsx(qe,{style:ke&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([d,h])=>!a.includes(d)&&h!==null&&h!==void 0&&h!=="").map(([d,h],y)=>e.jsxs("tr",{className:y%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:d.replace("matterbridgeVersion","Matterbridge version").replace("matterbridgeLatestVersion","Matterbridge latest v.").replace("matterbridgeDevVersion","Matterbridge dev v.").replace("frontendVersion","Frontend version").replace("homeDirectory","Home").replace("rootDirectory","Root").replace("matterbridgeDirectory","Storage").replace("matterbridgeCertDirectory","Cert").replace("matterbridgePluginDirectory","Plugins").replace("globalModulesDirectory","Modules").replace("bridgeMode","Bridge mode").replace("restartMode","Restart mode").replace("virtualMode","Virtual mode").replace("profile","Profile").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("matterLoggerLevel","Matter logger level").replace("matterFileLogger","Matter file logger").replace("restartRequired","Restart required").replace("updateRequired","Update required")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ke&&l?typeof h!="string"?h.toString():h:e.jsx(Vr,{value:typeof h!="string"?h.toString():h,maxChars:24})})]},d))})]})})]}))}const vi=r.memo(bi);function yi(){const[n,l]=r.useState(null),[a,i]=r.useState(null),[s,d]=r.useState([]),[h]=r.useState(localStorage.getItem(re.homePagePlugins)!=="false"),[y,t]=r.useState(localStorage.getItem(re.homePageMode)??"devices"),[P,M]=r.useState("https://matterbridge.io/CHANGELOG.html"),[I,D]=r.useState(!1),[O,ee]=r.useState(!1),[G,J]=r.useState(null),{mobile:f}=r.useContext(Oe),{addListener:u,removeListener:b,online:z,sendMessage:v,getUniqueId:j}=r.useContext(De),V=r.useRef(j());return r.useEffect(()=>{const oe=C=>{o&&console.log("Home received WebSocket Message:",C),C.method==="refresh_required"&&C.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${C.response.changed} and sending /api/settings request`),J(null),d([]),v({id:V.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),v({id:V.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),C.method==="/api/settings"&&C.id===V.current&&(o&&console.log("Home received settings:",C.response),l(C.response.systemInformation),i(C.response.matterbridgeInformation),localStorage.getItem(re.frontendVersion)===null&&C.response.matterbridgeInformation.frontendVersion?localStorage.setItem(re.frontendVersion,C.response.matterbridgeInformation.frontendVersion):C.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(re.frontendVersion)&&C.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(re.frontendVersion,C.response.matterbridgeInformation.frontendVersion),ee(!0)),localStorage.getItem(re.matterbridgeVersion)===null?localStorage.setItem(re.matterbridgeVersion,C.response.matterbridgeInformation.matterbridgeVersion):C.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(re.matterbridgeVersion)&&(localStorage.setItem(re.matterbridgeVersion,C.response.matterbridgeInformation.matterbridgeVersion),D(!0)),C.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(re.homePageMode)||(localStorage.setItem(re.homePageMode,"devices"),t("devices")))),C.method==="/api/plugins"&&C.id===V.current&&(o&&console.log("Home received plugins:",C.response),d(C.response))};return u(oe,V.current),o&&console.log(`Home added WebSocket listener id ${V.current}`),()=>{b(oe),o&&console.log("Home removed WebSocket listener")}},[u,b,v]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${G}`),a?.bridgeMode==="bridge"&&!G&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),J("Matterbridge")),a?.bridgeMode==="childbridge"&&!G&&s){for(const oe of s)if(oe.matter?.id){o&&console.log(`Home storeId effect set storeId to ${oe.matter.id}`),J(oe.matter.id);break}}},[a,s,G]),r.useEffect(()=>{z&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),v({id:V.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),v({id:V.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[z,v]),o&&console.log("Home rendering..."),!z||!n||!a?e.jsx(Ke,{}):e.jsxs(Pt,{name:"Home",style:ke&&f?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(ke&&!f||!ke)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ir,{id:G}),e.jsx(Sr,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:ke&&f?"10px":"20px"},children:[O&&e.jsx(fi,{}),I&&e.jsx(xi,{changelog:P}),ke&&f&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(Ir,{id:G}),e.jsx(Sr,{systemInfo:n,compact:!0}),e.jsx(vi,{matterbridgeInfo:a})]}),h&&!a.readOnly&&e.jsx(ei,{}),h&&e.jsx(si,{storeId:G,setStoreId:J}),y==="devices"&&e.jsx(ci,{storeId:G,setStoreId:J}),y==="logs"&&e.jsx(gi,{})]})]})}const ji=r.memo(yi),Vt=!1,Pr={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},wi={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Ci={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},$r={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Si={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},ki={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Ii={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Mi={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Di={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},sr={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Pi=[256,257,268,269],$i=[266,267],Li=[259,260,261,271,272],Wi=[256,257,268,269,266,267,259,260,261,272];function se({icon:n,iconColor:l,cluster:a,value:i,unit:s,prefix:d}){return o&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),d=d??!1,e.jsxs(he,{sx:Pr,children:[n&&r.cloneElement(n,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...wi,color:l??"var(--primary-color)"}}),e.jsxs(he,{sx:{...Pr,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&d===!0&&e.jsx(ye,{sx:$r,children:s},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(ye,{sx:Ci,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),s&&d===!1&&e.jsx(ye,{sx:$r,children:s},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function Fi({device:n,endpoint:l,id:a,deviceType:i,clusters:s}){const d=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let h="";o&&console.log(`Device "${n.name}" endpoint "${l}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const y=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(y){let t="";y.map(P=>{P.label&&(t+=P.label+" ")}),h=t.trim()}if(i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>h=`${t.attributeLocalValue} mV`),Wi.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>h=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>h=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>h=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>h=h+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>h=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>h=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>h=h+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>h=h+`${t.attributeLocalValue/1e3} W`),i===39){const t=s.find(M=>M.clusterName==="ModeSelect"&&M.attributeName==="currentMode")?.attributeLocalValue;h=s.find(M=>M.clusterName==="ModeSelect"&&M.attributeName==="supportedModes")?.attributeLocalValue?.find(M=>M.mode===t)?.label||"Unknown"}if(i===116){const t=s.find(M=>M.clusterName==="RvcRunMode"&&M.attributeName==="currentMode")?.attributeLocalValue;h=s.find(M=>M.clusterName==="RvcRunMode"&&M.attributeName==="supportedModes")?.attributeLocalValue?.find(M=>M.mode===t)?.label||"Unknown"}return e.jsxs(Pe,{style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:t.attributeLocalValue===!0?e.jsx(kt,{}):e.jsx(bo,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(se,{icon:e.jsx(it,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(se,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:rn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Pi.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(vo,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),$i.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(be,{path:on,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Li.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(be,{path:nn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:sn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:ln,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:an,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:e.jsx(br,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:e.jsx(yo,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(se,{icon:e.jsx(be,{path:cn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(br,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(se,{icon:e.jsx(be,{path:dn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:e.jsx(be,{path:wr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(se,{icon:e.jsx(be,{path:wr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(se,{icon:e.jsx(jo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(se,{icon:e.jsx(be,{path:un,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(se,{icon:t.attributeValue==="1"?e.jsx(wo,{}):e.jsx(Co,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(se,{icon:e.jsx(So,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(se,{icon:e.jsx(be,{path:pn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(se,{icon:e.jsx(ko,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(Io,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(se,{icon:e.jsx(vr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(se,{icon:e.jsx(vr,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:e.jsx(Mo,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:e.jsx(Do,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:e.jsx(Po,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&s.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(se,{icon:e.jsx(be,{path:gn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(se,{icon:e.jsx(be,{path:hn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(se,{icon:e.jsx(be,{path:fn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(se,{icon:e.jsx(be,{path:mn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(se,{icon:e.jsx(be,{path:xn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(se,{icon:e.jsx(be,{path:bn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:Cr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:Cr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(se,{icon:e.jsx($o,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(se,{icon:e.jsx(be,{path:vn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:d[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(Lo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(be,{path:yn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(Wo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(Fo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:t.attributeValue==="true"?e.jsx(To,{}):e.jsx(No,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(se,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Ro,{}):e.jsx(Oo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(_o,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(se,{icon:e.jsx(Ho,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(he,{sx:Si,children:e.jsx(ye,{sx:ki,children:h})}),e.jsx(he,{sx:Ii,children:e.jsx(ye,{sx:Mi,children:n.name})}),e.jsxs(he,{sx:Di,children:[o&&e.jsx(ye,{sx:sr,children:l}),e.jsx(ye,{sx:sr,children:a}),o&&e.jsxs(ye,{sx:sr,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Ti({filterPlugins:n,filterDevices:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),[y,t]=r.useState([]),[P,M]=r.useState({}),[I,D]=r.useState({}),[O,ee]=r.useState({}),G=r.useRef(h()),J=r.useCallback(v=>{(o||Vt)&&console.log(`DevicesIcons received state_update "${v.response.cluster}.${v.response.attribute}" for "${v.response.id}:${v.response.number}": "${v.response.value}"`,v.response);const j=y.find(oe=>oe.pluginName===v.response.plugin&&oe.serial===v.response.serialNumber);if(!j){(o||Vt)&&console.warn(`DevicesIcons updater device of plugin "${v.response.plugin}" serial "${v.response.serialNumber}" number "${v.response.number}" id "${v.response.id}" not found in devices(${y.length})`);return}const V=O[j.serial]?.find(oe=>oe.endpoint===v.response.number.toString()&&oe.clusterName===v.response.cluster&&oe.attributeName===v.response.attribute);if(!V){(o||Vt)&&console.warn(`DevicesIcons updater device "${j.name}" serial "${j.serial}" cluster "${v.response.cluster}" attribute "${v.response.attribute}" not found in clusters(${O[j.serial]?.length})`);return}V.attributeValue=String(v.response.value),V.attributeLocalValue=v.response.value,ee({...O}),(o||Vt)&&console.log(`DevicesIcons updated "${V.clusterName}.${V.attributeName}" for device "${j.name}" serial "${j.serial}" to "${V.attributeValue}"`)},[O,y]),f=r.useCallback(v=>{if(o&&console.log(`DevicesIcons received for device "${v.response.deviceName}" serial "${v.response.serialNumber}" deviceTypes (${v.response.deviceTypes.length}) "${v.response.deviceTypes.join(",")}" clusters (${v.response.clusters.length}):`,v.response),v.response.clusters.length===0)return;const j=v.response.serialNumber;P[j]=[],I[j]=v.response.deviceTypes,O[j]=[];for(const V of v.response.clusters)P[j].find(oe=>oe.endpoint===V.endpoint)||P[j].push({endpoint:V.endpoint,id:V.id,deviceTypes:V.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(V.clusterName)&&O[j].push(V);M({...P}),D({...I}),ee({...O}),o&&console.log(`DevicesIcons endpoints for "${j}":`,P[j]),o&&console.log(`DevicesIcons deviceTypes for "${j}":`,I[j]),o&&console.log(`DevicesIcons clusters for "${j}":`,O[j])},[O,I,P]);r.useEffect(()=>{const v=j=>{if(o&&console.log("DevicesIcons received WebSocket Message:",j),j.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${j.response.changed} and sending api requests`),i({id:G.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="state_update"&&j.response)J(j);else if(j.method==="/api/devices"&&j.response){o&&console.log(`DevicesIcons received ${j.response.length} devices:`,j.response),t(j.response),M({}),D({}),ee({});for(const V of j.response)o&&console.log("DevicesIcons sending /api/clusters"),i({id:G.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:V.pluginName,endpoint:V.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&f(j)};return s(v,G.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{d(v),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[y]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),a&&(o&&console.log("DevicesIcons useEffect online sending api requests"),i({id:G.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[a,i]);const u=r.memo(Fi),b=n?.trim().toLowerCase(),z=b&&b!=="all plugins";return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:y.filter(v=>z&&v.pluginName.toLowerCase()!==b?!1:l===""?!0:v.name.toLowerCase().includes(l)||v.serial.toLowerCase().includes(l)).map(v=>P[v.serial]&&P[v.serial].map(j=>j.deviceTypes.map(V=>e.jsx(u,{device:v,endpoint:j.endpoint,id:j.id,deviceType:V,clusters:O[v.serial].filter(oe=>oe.endpoint===j.endpoint)},`${v.pluginName}-${v.uniqueId}-${j.endpoint}-${j.id}-${V.toString()}`))))})}const Ni=r.memo(Ti),Ri=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,l,a,i)=>a.configUrl?e.jsx(te,{onClick:()=>window.open(a.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(_r,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Oi=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,l,a,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,maxWidth:350,tooltip:!0}],_i=n=>`${n.pluginName}::${n.uniqueId}`,Hi=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Ei({filterPlugins:n,filterDevices:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),[y,t]=r.useState([]),[P,M]=r.useState(y),[I,D]=r.useState([]),[O,ee]=r.useState(0),[G,J]=r.useState(null),[f,u]=r.useState(null),[b,z]=r.useState(null),[v,j]=r.useState(null),V=r.useRef(h()),oe=r.useRef(P),C=r.useCallback(c=>{o&&console.log(`DevicesTable received state_update "${c.response.cluster}.${c.response.attribute}" for "${c.response.id}:${c.response.number}": "${c.response.value}"`,c.response);const x=oe.current.find(W=>W.pluginName===c.response.plugin&&W.uniqueId===c.response.uniqueId);if(!x){o&&console.warn(`DevicesTable updater device of plugin "${c.response.plugin}" serial "${c.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(G&&f&&x.pluginName===G&&x.uniqueId===v&&c.response.number.toString()===f){const W=I.find(N=>N.endpoint===c.response.number.toString()&&N.clusterName===c.response.cluster&&N.attributeName===c.response.attribute);if(!W){o&&console.warn(`DevicesTable updater cluster ${c.response.cluster}.${c.response.attribute} for device "${x.name}" serial "${x.serial}" not found in clusters`);return}W.attributeValue=typeof c.response.value=="object"?JSON.stringify(c.response.value,void 0,1).replaceAll('"',""):String(c.response.value),W.attributeLocalValue=c.response.value,D([...I]),o&&console.log(`DevicesTable updated attribute ${W.clusterName}.${W.attributeName} for device "${x.name}" serial "${x.serial}" to "${W.attributeValue}"`)}},[I,f,G,v]);r.useEffect(()=>{const c=x=>{if(o&&console.log("DevicesTable received WebSocket Message:",x),x.method==="refresh_required"&&x.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${x.response.changed} and sending /api/devices request`),i({id:V.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(x.method==="state_update"&&x.response)C(x);else if(x.method==="/api/devices")o&&console.log(`DevicesTable received ${x.response.length} devices:`,x.response),t(x.response);else if(x.method==="/api/clusters"){o&&console.log(`DevicesTable received ${x.response.clusters.length} clusters for plugin ${x.response.plugin}:`,x.response),D(x.response.clusters);const W={};for(const N of x.response.clusters)o&&console.log("Cluster:",N.endpoint),W[N.endpoint]?W[N.endpoint]++:W[N.endpoint]=1;ee(Object.keys(W).length)}};return s(c,V.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{d(c),o&&console.log("DevicesTable removed WebSocket listener")}},[i,s,d,C]),r.useEffect(()=>{a&&(o&&console.log("DevicesTable sending api requests with id ",V.current),i({id:V.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:V.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:V.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),r.useEffect(()=>{G&&f&&(o&&console.log("DevicesTable sending /api/clusters"),i({id:V.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:G,endpoint:Number(f)}}))},[G,f,i]),r.useEffect(()=>{const c=n?.trim().toLowerCase(),x=c&&c!=="all plugins";let W=y;x&&(W=W.filter(N=>N.pluginName.toLowerCase()===c)),l!==""&&(W=W.filter(N=>N.name.toLowerCase().includes(l)||N.serial.toLowerCase().includes(l))),M(W),oe.current=W},[y,n,l]);const p=c=>{if(c.uniqueId===v){j(null),J(null),u(null),z(null);return}j(c.uniqueId),J(c.pluginName),u(c.endpoint?c.endpoint.toString():null),z(c.name)};return o&&console.log("DevicesTable rendering..."),a?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx(Pe,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${G&&f?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Registered devices",getRowKey:_i,onRowClick:p,rows:P,columns:Ri,footerLeft:`Total devices: ${P.length.toString()}`})}),G&&f&&e.jsx(Pe,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Clusters",title:b||"",getRowKey:Hi,rows:I,columns:Oi,footerLeft:`Total child endpoints: ${O-1}`})})]}):e.jsx(Ke,{})}const Ai=r.memo(Ei);function Vi(){const{online:n,sendMessage:l,addListener:a,removeListener:i,getUniqueId:s}=r.useContext(De),[d,h]=r.useState(["All plugins"]),[y,t]=r.useState("All plugins"),[P,M]=r.useState(""),[I,D]=r.useState("icon"),O=r.useRef(s());r.useEffect(()=>{const u=localStorage.getItem(re.devicesFilterPlugins);u&&t(u)},[]),r.useEffect(()=>{const u=localStorage.getItem(re.devicesFilterDevices);u&&M(u)},[]),r.useEffect(()=>{const u=localStorage.getItem(re.devicesViewMode);u&&D(u)},[]),r.useEffect(()=>{const u=b=>{o&&b.id&&console.log("Devices received WebSocket Message:",b),b.method==="refresh_required"&&b.response.changed==="plugins"&&!b.response.lock?(o&&console.log(`Devices received refresh_required for plugins lock=${b.response.lock}, sending /api/plugins request with id ${O.current}`),l({id:O.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):b.method==="/api/plugins"&&b.id===O.current&&b.response&&(o&&console.log(`Devices received ${b.response.length} plugins:`,b.response),h(["All plugins",...b.response.map(z=>z.name)]))};return a(u,O.current),o&&console.log("Devices added WebSocket listener"),()=>{i(u),o&&console.log("Devices removed WebSocket listener")}},[l,a,i]),r.useEffect(()=>{n&&(o&&console.log("Devices sending /api/plugins request with id ",O.current),l({id:O.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,l]);const ee=u=>{const b=u.target.value;t(b),localStorage.setItem(re.devicesFilterPlugins,b)},G=u=>{M(u.target.value),localStorage.setItem(re.devicesFilterDevices,u.target.value)},J=()=>{M(""),localStorage.removeItem(re.devicesFilterDevices)},f=u=>{D(u),localStorage.setItem(re.devicesViewMode,u)};return o&&console.log("Devices rendering..."),n?e.jsxs(Pt,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px"},children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Plugin:"}),e.jsx(A,{title:"Filter devices by plugin",children:e.jsx(Xe,{variant:"outlined",value:y,onChange:ee,sx:{width:"260px",backgroundColor:"var(--main-bg-color)","& .MuiOutlinedInput-root":{backgroundColor:"var(--main-bg-color)"},"& .MuiSelect-select":{backgroundColor:"var(--main-bg-color)"},"& .MuiSelect-icon":{color:"var(--main-label-color)"}},input:e.jsx(Eo,{sx:{backgroundColor:"var(--main-bg-color)"}}),children:d.map(u=>e.jsx(E,{value:u,children:u},u))})})]}),e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(A,{title:"Filter devices by name or serial number",children:e.jsx(Me,{variant:"outlined",value:P,onChange:G,placeholder:"Enter the device name or serial",sx:{width:"260px","& .MuiOutlinedInput-root":{backgroundColor:"var(--main-bg-color)"}},slotProps:{input:{endAdornment:P?e.jsx(Ao,{position:"end",children:e.jsx(te,{"aria-label":"Clear device filter",size:"small",onClick:J,edge:"end",children:e.jsx(Vo,{sx:{fontSize:18,color:"var(--main-label-color)"}})})}):null}}})})]})]}),e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(te,{onClick:()=>f("table"),"aria-label":"Table View",disabled:I==="table",children:e.jsx(A,{title:"Table View",children:e.jsx(Uo,{style:{color:I==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(te,{onClick:()=>f("icon"),"aria-label":"Icon View",disabled:I==="icon",children:e.jsx(A,{title:"Icon View (beta)",children:e.jsx(qo,{style:{color:I==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),I==="table"&&e.jsx(Ai,{filterPlugins:y,filterDevices:P}),I==="icon"&&e.jsx(Ni,{filterPlugins:y,filterDevices:P})]}):e.jsx(Ke,{})}const Ui=r.memo(Vi);function qi(){const{logLength:n,logAutoScroll:l,setMessages:a,setLogFilterLevel:i,setLogFilterSearch:s,online:d,filterLogMessages:h}=r.useContext(De),[y,t]=r.useState(localStorage.getItem(re.logFilterLevel)??"info"),[P,M]=r.useState(localStorage.getItem(re.logFilterSearch)??"*"),[I,D]=r.useState(n.current.toString()),[O,ee]=r.useState(l.current),G=z=>{const v=z.target.value;t(v),i(v),h(v,P),localStorage.setItem(re.logFilterLevel,v),o&&console.log("handleLogFilterLevelChange called with value:",v)},J=z=>{const v=z.target.value;M(v),s(v),h(y,v),localStorage.setItem(re.logFilterSearch,v),o&&console.log("handleLogFilterSearchChange called with value:",v)},f=z=>{const v=z.target.checked;ee(v),l.current=v,h(y,P),localStorage.setItem(re.logAutoScroll,v?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",v)},u=z=>{const v=z.target.value;D(v),n.current=Number(v),localStorage.setItem(re.logLength,v),o&&console.log("handleLogLengthChange called with value:",v)},b=()=>{o&&console.log("handleClearLogsClick called"),a([])};return o&&console.log("Logs rendering..."),d?e.jsxs(Pt,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Ut,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:y,onChange:G,children:[e.jsx(E,{value:"debug",children:"Debug"}),e.jsx(E,{value:"info",children:"Info"}),e.jsx(E,{value:"notice",children:"Notice"}),e.jsx(E,{value:"warn",children:"Warn"}),e.jsx(E,{value:"error",children:"Error"}),e.jsx(E,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Ut,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(A,{title:"Use /text/ for case-insensitive regex search",children:e.jsx(Me,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:P,onChange:J,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(lt,{control:e.jsx(et,{checked:O,onChange:f}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(Ut,{id:"select-size-label",style:{color:"var(--div-text-color)"},children:"Log length:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-size-label",id:"select-size",value:I,onChange:u,children:[e.jsx(E,{value:100,children:"100"}),e.jsx(E,{value:200,children:"200"}),e.jsx(E,{value:500,children:"500"}),e.jsx(E,{value:1e3,children:"1000"})]}),e.jsx(A,{title:"Clear the logs",children:e.jsx(fe,{onClick:b,endIcon:e.jsx(ar,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})]})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(zr,{})})]}):e.jsx(Ke,{})}const zi=r.memo(qi),Bi=({open:n,ip:l,onClose:a,onSave:i})=>{const s=l?l.split(".").slice(0,3).join(".")+".1":"",[d,h]=r.useState("dhcp"),[y,t]=r.useState({ip:l??"",subnet:"255.255.255.0",gateway:s,dns:s}),P=D=>O=>{t({...y,[D]:O.target.value})},M=()=>{a()},I=()=>{i({type:d,...y}),a()};return e.jsxs(Be,{open:n,onClose:(D,O)=>{O==="backdropClick"||O==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Je,{dividers:!0,children:[e.jsxs(ur,{component:"fieldset",fullWidth:!0,children:[e.jsx(We,{component:"legend",children:"Select IP Configuration"}),e.jsxs(Er,{row:!0,value:d,onChange:D=>h(D.target.value),children:[e.jsx(lt,{value:"dhcp",control:e.jsx(Jt,{}),label:"DHCP"}),e.jsx(lt,{value:"static",control:e.jsx(Jt,{}),label:"Static"})]})]}),d==="static"&&e.jsxs(rt,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(rt,{size:6,children:e.jsx(Me,{label:"IP Address",fullWidth:!0,value:y.ip,onChange:P("ip")})}),e.jsx(rt,{size:6,children:e.jsx(Me,{label:"Subnet Mask",fullWidth:!0,value:y.subnet,onChange:P("subnet")})}),e.jsx(rt,{size:6,children:e.jsx(Me,{label:"Gateway",fullWidth:!0,value:y.gateway,onChange:P("gateway")})}),e.jsx(rt,{size:6,children:e.jsx(Me,{label:"DNS Server",fullWidth:!0,value:y.dns,onChange:P("dns")})})]})]}),e.jsxs(Ze,{children:[e.jsx(fe,{onClick:M,children:"Cancel"}),e.jsx(fe,{variant:"contained",onClick:I,children:"Save"})]})]})},Gi=({open:n,onClose:l,onSave:a})=>{const[i,s]=r.useState(""),[d,h]=r.useState(""),y=O=>{s(O.target.value)},t=O=>{h(O.target.value)},P=i.length>0&&i===d,M=()=>{l()},I=()=>{P&&(a(i),l())},D=()=>{a(""),l()};return e.jsxs(Be,{open:n,onClose:(O,ee)=>{ee==="backdropClick"||ee==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ge,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Je,{dividers:!0,children:e.jsx(ur,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(rt,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(rt,{size:12,children:e.jsx(Me,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:y})}),e.jsx(rt,{size:12,children:e.jsx(Me,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:d,onChange:t,error:d!==""&&i!==d,helperText:d!==""&&i!==d?"Passwords do not match":""})})]})})}),e.jsxs(Ze,{children:[e.jsx(fe,{onClick:M,children:"Cancel"}),e.jsx(fe,{variant:"contained",onClick:I,disabled:!P,children:"Change"}),e.jsx(fe,{variant:"contained",onClick:D,children:"Reset"})]})]})};function ht(n=1e3){let l=null;const a=(i=>{l!==null&&window.clearTimeout(l),l=window.setTimeout(()=>{i(),l=null},n)});return a.cancel=()=>{l!==null&&(window.clearTimeout(l),l=null)},a}const Qt=330;function Ji(){const{mobile:n}=r.useContext(Oe),{online:l,addListener:a,removeListener:i,sendMessage:s,getUniqueId:d}=r.useContext(De),[h,y]=r.useState(null),[t,P]=r.useState(null),M=r.useRef(d());return r.useEffect(()=>{const I=D=>{o&&console.log("Settings received WebSocket Message:",D),D.method==="refresh_required"&&D.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${D.response.changed} and sending /api/settings request`),s({id:M.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):D.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",D.response),y(D.response.matterbridgeInformation),P(D.response.systemInformation))};return a(I,M.current),o&&console.log("Settings added WebSocket listener"),()=>{i(I),o&&console.log("Settings removed WebSocket listener")}},[a,i,s]),r.useEffect(()=>{l&&(o&&console.log("Settings received online"),s({id:M.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,s]),o&&console.log("Settings rendering..."),!l||!h||!t?e.jsx(Ke,{}):e.jsx(Pt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:ke&&n?"10px":"20px"},children:[e.jsx(Ki,{matterbridgeInfo:h,systemInfo:t}),e.jsx(Qi,{matterbridgeInfo:h}),e.jsx(Yi,{matterbridgeInfo:h}),e.jsx(Zi,{systemInfo:t})]})})}function Ki({matterbridgeInfo:n,systemInfo:l}){const{sendMessage:a,getUniqueId:i}=r.useContext(De),[s,d]=r.useState("bridge"),[h,y]=r.useState("Info"),[t,P]=r.useState(!1),[M,I]=r.useState("dark"),[D,O]=r.useState(localStorage.getItem(re.homePagePlugins)!=="false"),[ee,G]=r.useState(localStorage.getItem(re.homePageMode)??"devices"),[J,f]=r.useState(localStorage.getItem(re.virtualMode)??"outlet"),u=r.useRef(i()),[b,z]=r.useState(!1),v=()=>z(!1),j=m=>{o&&console.log("handleSaveNetConfig called with config:",m),a({id:u.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:m})},[V,oe]=r.useState(!1),C=()=>oe(!1),p=m=>{o&&console.log("handleSaveChangePassword called with password:",m),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:m}}),ds(m)};r.useEffect(()=>{n&&(d(n.bridgeMode==="bridge"?"bridge":"childbridge"),y(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),P(n.fileLogger),f(n.virtualMode))},[n]),r.useEffect(()=>{const m=localStorage.getItem(re.frontendTheme);m&&I(m)},[]);const c=m=>{o&&console.log("handleChangeBridgeMode called with value:",m.target.value),d(m.target.value),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:m.target.value}})},x=m=>{o&&console.log("handleChangeMbLoggerLevel called with value:",m.target.value),y(m.target.value),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:m.target.value}})},W=m=>{o&&console.log("handleLogOnFileMbChange called with value:",m.target.checked),P(m.target.checked),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:m.target.checked}})},N=m=>{const w=m.target.value;o&&console.log("handleChangeTheme called with value:",w),I(w),localStorage.setItem(re.frontendTheme,w),document.body.setAttribute("frontend-theme",w)},ce=m=>{const w=m.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",w),O(w),localStorage.setItem(re.homePagePlugins,w?"true":"false")},Ce=m=>{const w=m.target.value;o&&console.log("handleChangeHomePageMode called with value:",w),G(w),localStorage.setItem(re.homePageMode,w)},q=m=>{const w=m.target.value;o&&console.log("handleChangeVirtualMode called with value:",w),f(w),localStorage.setItem(re.virtualMode,w),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:w}})};return!n||!l?null:e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matterbridge settings"})}),e.jsx(Bi,{open:b,ip:l.ipv4Address,onClose:v,onSave:j}),e.jsx(Gi,{open:V,onClose:C,onSave:p}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(Er,{row:!0,name:"mode-buttons-group",value:s,onChange:c,children:[e.jsx(lt,{value:"bridge",control:e.jsx(Jt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(lt,{value:"childbridge",control:e.jsx(Jt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:h,onChange:x,children:[e.jsx(E,{value:"Debug",children:"Debug"}),e.jsx(E,{value:"Info",children:"Info"}),e.jsx(E,{value:"Notice",children:"Notice"}),e.jsx(E,{value:"Warn",children:"Warn"}),e.jsx(E,{value:"Error",children:"Error"}),e.jsx(E,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(et,{checked:t,onChange:W,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:M,onChange:N,children:[e.jsx(E,{value:"classic",children:"Classic"}),e.jsx(E,{value:"light",children:"Light"}),e.jsx(E,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(et,{checked:D,onChange:ce,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:ee,onChange:Ce,children:[e.jsx(E,{value:"logs",children:"Logs"}),e.jsx(E,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:J,onChange:q,children:[e.jsx(E,{value:"disabled",children:"Disabled"}),e.jsx(E,{value:"outlet",children:"Outlet"}),e.jsx(E,{value:"light",children:"Light"}),e.jsx(E,{value:"switch",children:"Switch"}),e.jsx(E,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(fe,{variant:"contained",color:"primary",onClick:()=>oe(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(fe,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Configure IP"})})]})]})}function Qi({matterbridgeInfo:n}){const{sendMessage:l,getUniqueId:a}=r.useContext(De),[i,s]=r.useState("Info"),[d,h]=r.useState(!1),[y,t]=r.useState(""),[P,M]=r.useState(""),[I,D]=r.useState(""),[O,ee]=r.useState(""),[G,J]=r.useState(""),[f,u]=r.useState(""),b=r.useRef(a()),z=r.useMemo(()=>ht(1e3),[]),v=r.useMemo(()=>ht(1e3),[]),j=r.useMemo(()=>ht(1e3),[]),V=r.useMemo(()=>ht(1e3),[]),oe=r.useMemo(()=>ht(1e3),[]),C=r.useMemo(()=>ht(1e3),[]);r.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),h(n.matterFileLogger),t(n.matterMdnsInterface||""),M(n.matterIpv4Address||""),D(n.matterIpv6Address||""),ee(n.matterPort?n.matterPort.toString():""),J(n.matterDiscriminator?n.matterDiscriminator.toString():""),u(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>z.cancel(),[z]),r.useEffect(()=>()=>v.cancel(),[v]),r.useEffect(()=>()=>j.cancel(),[j]),r.useEffect(()=>()=>V.cancel(),[V]),r.useEffect(()=>()=>oe.cancel(),[oe]),r.useEffect(()=>()=>C.cancel(),[C]);const p=m=>{o&&console.log("handleChangeMjLoggerLevel called with value:",m.target.value),s(m.target.value),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:m.target.value}})},c=m=>{o&&console.log("handleLogOnFileMjChange called with value:",m.target.checked),h(m.target.checked),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:m.target.checked}})},x=m=>{o&&console.log("handleChangeMdnsInterface called with value:",m.target.value);const w=m.target.value;t(w),z(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:w}})})},W=m=>{o&&console.log("handleChangeIpv4Address called with value:",m.target.value);const w=m.target.value;M(w),v(()=>{o&&console.log("debounced sendMessage setipv4address with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:w}})})},N=m=>{o&&console.log("handleChangeIpv6Address called with value:",m.target.value);const w=m.target.value;D(w),j(()=>{o&&console.log("debounced sendMessage setipv6address with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:w}})})},ce=m=>{o&&console.log("handleChangeMatterPort called with value:",m.target.value);const w=m.target.value;ee(w),V(()=>{o&&console.log("debounced sendMessage setmatterport with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:w}})})},Ce=m=>{o&&console.log("handleChangeMatterDiscriminator called with value:",m.target.value);const w=m.target.value;J(w),oe(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:w}})})},q=m=>{o&&console.log("handleChangemMatterPasscode called with value:",m.target.value);const w=m.target.value;u(w),C(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:w}})})};return n?e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matter settings"})}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:p,children:[e.jsx(E,{value:"Debug",children:"Debug"}),e.jsx(E,{value:"Info",children:"Info"}),e.jsx(E,{value:"Notice",children:"Notice"}),e.jsx(E,{value:"Warn",children:"Warn"}),e.jsx(E,{value:"Error",children:"Error"}),e.jsx(E,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(et,{checked:d,onChange:c,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(Me,{value:y,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(Me,{value:P,onChange:W,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(Me,{value:I,onChange:N,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(Me,{value:O,onChange:ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(Me,{value:G,onChange:Ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(Me,{value:f,onChange:q,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function Yi({matterbridgeInfo:n}){return n?e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matterbridge info"})}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Re,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Re,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Re,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Re,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Re,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Re,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Re,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function Zi({systemInfo:n}){return n?e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"System info"})}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Re,{value:n.interfaceName,label:"Interface name"}),e.jsx(Re,{value:n.macAddress,label:"MAC Address"}),e.jsx(Re,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Re,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Re,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Re,{value:n.hostname,label:"Hostname"}),e.jsx(Re,{value:n.user,label:"User"})]})]}):null}function Re({value:n,label:l,width:a}){return e.jsx(Me,{focused:!0,value:n,size:"small",label:l,variant:"standard",sx:{width:a?`${a-20}px`:"100%","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const Xi=r.memo(Ji);function es(){const{online:n,sendMessage:l,addListener:a,removeListener:i,getUniqueId:s}=r.useContext(De),{showSnackbarMessage:d}=r.useContext(Oe),[h,y]=r.useState(null),[t,P]=r.useState([]),[M,I]=r.useState([]),[D,O]=r.useState(null),[ee,G]=r.useState({cpuUsage:0}),[J,f]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[u,b]=r.useState({systemUptime:"",processUptime:""}),z=r.useRef(s());return o&&console.log("Test uniqueId:",z),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const v=j=>{if(j.method==="restart_required")o&&console.log("Test received restart_required"),d("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),d("Refresh required",0),l({id:z.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:z.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:z.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="memory_update")o&&console.log("Test received memory_update",j),f(j.response);else if(j.method==="cpu_update")o&&console.log("Test received cpu_update",j),G(j.response);else if(j.method==="uptime_update")o&&console.log("Test received uptime_update",j),b(j.response);else if(j.method==="/api/settings"&&j.response)o&&console.log("Test received /api/settings:",j.response),d("Test received /api/settings",0),y(j.response);else if(j.method==="/api/plugins"&&j.response)o&&console.log(`Test received ${j.response.length} plugins:`,j.response),d("Test received /api/plugins",0),P(j.response);else if(j.method==="/api/devices"&&j.response){o&&console.log(`Test received ${j.response.length} devices:`,j.response),d("Test received /api/devices",0),I(j.response);for(const V of j.response)o&&console.log("Test sending /api/clusters for device:",V.pluginName,V.name,V.endpoint),l({id:z.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:V.pluginName,endpoint:V.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&(o&&console.log(`Test received ${j.response.clusters.length} clusters for device ${j.response.deviceName} endpoint ${j.response.id}:${j.response.number}:`,j),d(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),O(j.response))};return a(v,z.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(v),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[a,i,l,d]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,l,d]),o&&console.log("Test rendering..."),n?e.jsx(Pt,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Ke,{})}const ts=r.memo(es);function rs(n,l){o&&console.log("getCssVariable:",n,"defaultValue",l);const a=getComputedStyle(document.body).getPropertyValue(n).trim();return a||console.error("getCssVariable: undefined",a),a||l}function os(n){return zo({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function ns(){const{mobile:n,showSnackbarMessage:l,showConfirmCancelDialog:a}=r.useContext(Oe),{online:i,sendMessage:s,logMessage:d,addListener:h,removeListener:y,getUniqueId:t}=r.useContext(De),[P,M]=r.useState(!1),[I,D]=r.useState(!1),[O,ee]=r.useState(!1),[G,J]=r.useState(!1),[f,u]=r.useState(null),b=r.useRef(t()),[z,v]=r.useState(null),[j,V]=r.useState(null),[oe,C]=r.useState(null),[p,c]=r.useState(null),[x,W]=r.useState(null),N=Qr(),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},Ce=()=>{window.open("https://matterbridge.io/")},q=()=>{window.open("https://matterbridge.io/README.html")},m=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},w=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},F=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},L=()=>{s({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}}),ee(!1)},S=()=>{s({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}}),J(!1)},ne=()=>{s({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Se=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),d("Matterbridge","Installing system updates..."),s({id:b.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),d("Matterbridge","Installing software updates..."),s({id:b.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),s({id:b.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},R=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),d("Matterbridge","Downloading Shelly system log..."),l("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},U=()=>{f?.matterbridgeInformation.restartMode===""?s({id:b.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):s({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},K=()=>{s({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},B=()=>{s({id:b.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},g=()=>{s({id:b.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ue=()=>{s({id:b.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},Y=Z=>{v(Z.currentTarget)},H=Z=>{o&&console.log("Header: handleMenuClose",Z),v(null),Z==="/"||Z==="/devices"||Z==="/log"||Z==="/settings"?N(Z):Z==="reset_frontend"?(d("Matterbridge","Resetting frontend UI..."),l("Resetting frontend UI...",5),Wn(),window.location.reload()):Z==="download-mblog"?(d("Matterbridge","Downloading matterbridge log..."),l("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Z==="download-mjlog"?(d("Matterbridge","Downloading matter log..."),l("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Z==="view-mblog"?(d("Matterbridge","Loading matterbridge log..."),l("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):Z==="view-mjlog"?(d("Matterbridge","Loading matter log..."),l("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):Z==="view-diagnostic"?(d("Matterbridge","Loading diagnostic log..."),l("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):Z==="download-diagnostic"?(d("Matterbridge","Downloading diagnostic log..."),l("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):Z==="view-history"?s({id:b.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="download-history"?s({id:b.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="view-shellylog"?(d("Matterbridge","Loading shelly system log..."),l("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Z==="download-mbstorage"?(d("Matterbridge","Downloading matterbridge storage..."),l("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Z==="download-pluginstorage"?(d("Matterbridge","Downloading matterbridge plugins storage..."),l("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Z==="download-pluginconfig"?(d("Matterbridge","Downloading matterbridge plugins config..."),l("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Z==="download-mjstorage"?(d("Matterbridge","Downloading matter storage..."),l("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Z==="download-backup"?(d("Matterbridge","Downloading backup..."),l("Downloading backup...",10),window.location.href="./api/download-backup"):Z==="update"?L():Z==="updatedev"?S():Z==="updatecheck"?ne():Z==="shelly-sys-update"?Se():Z==="shelly-main-update"?T():Z==="shelly-create-system-log"?k():Z==="shelly-download-system-log"?R():Z==="softreset"?g():Z==="hardreset"?ue():Z==="restart"?U():Z==="shutdown"?K():Z==="reboot"?B():Z==="create-backup"?s({id:b.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="unregister"?s({id:b.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="reset"?s({id:b.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="factoryreset"&&s({id:b.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},me=Z=>{o&&console.log("Header: handleMenuCloseCancel:",Z),v(null)},xe=Z=>{V(Z.currentTarget)},Ie=()=>{V(null)},Ae=Z=>{C(Z.currentTarget)},je=()=>{C(null)},pe=Z=>{c(Z.currentTarget)},de=()=>{c(null)},Fe=Z=>{W(Z.currentTarget)},_e=()=>{W(null)},ot=()=>{ss(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const Z=$=>{o&&console.log("Header received WebSocket Message:",$),$.method==="/api/settings"&&$.id===b.current?(o&&console.log("Header received settings:",$.response),u($.response),M($.response.matterbridgeInformation.restartRequired||$.response.matterbridgeInformation.fixedRestartRequired),D($.response.matterbridgeInformation.fixedRestartRequired),ee($.response.matterbridgeInformation.updateRequired)):$.method==="refresh_required"&&$.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${$.response.changed} and sending /api/settings request`),s({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):$.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${$.response.fixed}`),M(!0),$.response.fixed===!0&&D(!0)):$.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),M(!1)):$.method==="update_required"?(o&&console.log("Header received update_required"),$.response.devVersion===!0?J(!0):ee(!0),s({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):$.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),u(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:$.response.available},systemInformation:we.systemInformation}:null)):$.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),u(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:$.response.available},systemInformation:we.systemInformation}:null)):$.method==="/api/viewhistorypage"&&$.id===b.current&&$.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):$.method==="/api/downloadhistorypage"&&$.id===b.current&&$.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return h(Z,b.current),o&&console.log(`Header added WebSocket listener id ${b.current}`),()=>{y(Z),o&&console.log("Header removed WebSocket listener")}},[h,y,s,l]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),s({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,s]),o&&console.log("Header rendering... mobile %s",n),!i||!f?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:ot}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(Lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Lt,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!f.matterbridgeInformation.readOnly&&e.jsx(A,{title:`Matterbridge v.${f.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",f.matterbridgeInformation.matterbridgeVersion.split("-")[0]+(f.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-edge-")?"@edge":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-local-")?"@local":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-git-")?"@git":"")]})}),f.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),f.matterbridgeInformation.bridgeMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.bridgeMode})}):null,f.matterbridgeInformation.restartMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.restartMode})}):null,f.matterbridgeInformation.profile&&f.matterbridgeInformation.profile!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null,o&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${Bt}x${Gt}`,` enabled ${localStorage.getItem(re.enableMobile)!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:w})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Give a star to Matterbridge",children:e.jsx(te,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:F,children:e.jsx(Hr,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Sponsor Matterbridge",children:e.jsx(te,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(pr,{})})}):null,e.jsx(A,{title:"Matterbridge homepage",children:e.jsx(te,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:Ce,children:e.jsx(Tr,{})})}),e.jsx(A,{title:"Matterbridge help",children:e.jsx(te,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:q,children:e.jsx(dr,{})})}),e.jsx(A,{title:"Matterbridge changelog",children:e.jsx(te,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:m,children:e.jsx(Kt,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&O&&e.jsx(A,{title:`Update matterbridge to latest version v.${f.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:L,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&G&&e.jsx(A,{title:`Update matterbridge to latest dev version v.${f.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(te,{style:{color:"var(--secondary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:S,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(A,{title:"Shelly system update",children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Se,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(A,{title:"Shelly software update",children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:T,children:e.jsx(ze,{})})}),e.jsx(A,{title:"Restart matterbridge",children:e.jsx(te,{style:{color:P||I?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(zt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(A,{title:"Shut down matterbridge",children:e.jsx(te,{style:{color:P||I?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(tt,{})})}):null,e.jsx(A,{title:"Download, backup and more",children:e.jsx(te,{onClick:Y,children:e.jsx(Bo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ct,{id:"command-menu",anchorEl:z,keepMounted:!0,open:!!z,onClose:()=>H(""),children:[ke&&n&&e.jsxs(E,{onClick:()=>H("/"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ke&&n&&e.jsxs(E,{onClick:()=>H("/devices"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ke&&n&&e.jsxs(E,{onClick:()=>H("/log"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ke&&n&&e.jsxs(E,{onClick:()=>H("/settings"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>H("update"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>H("updatedev"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>H("updatecheck"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(E,{onClick:()=>H("shelly-sys-update"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(E,{onClick:()=>H("shelly-main-update"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>H("restart"),children:[e.jsx(X,{children:e.jsx(zt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(E,{onClick:()=>H("shutdown"),children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{a("Reboot","Are you sure you want to reboot the Shelly board?","reboot",H,me)},children:[e.jsx(X,{children:e.jsx(zt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:Ae,children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-view",anchorEl:oe,keepMounted:!0,open:!!oe,onClose:je,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{cs(),je(),me(""),window.open("/home","_self")},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{as(),je(),me(""),window.open("/home","_self")},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-mblog"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-mjlog"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-diagnostic"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-history"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{H("view-shellylog"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:pe,children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-download",anchorEl:p,keepMounted:!0,open:!!p,onClose:de,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{H("download-mbstorage"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-pluginstorage"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-pluginconfig"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-mblog"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-mjstorage"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-mjlog"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-diagnostic"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-history"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{H("shelly-create-system-log"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{H("shelly-download-system-log"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:xe,children:[e.jsx(X,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:Ie,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{H("create-backup"),Ie()},children:[e.jsx(X,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-backup"),Ie()},children:[e.jsx(X,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:Fe,children:[e.jsx(X,{children:e.jsx(Go,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-reset",anchorEl:x,keepMounted:!0,open:!!x,onClose:_e,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{_e(),a("Reset the frontend UI","Are you sure you want to reset the frontend UI? This will reset all local settings and reload the page.","reset_frontend",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset the frontend UI...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{_e(),a("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{_e(),a("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>{_e(),a("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{_e(),a("Network reset","Are you sure you want to factory reset the network parameters?","softreset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{_e(),a("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Lr=r.memo(ns),Br=1200,Gr=900;let Bt,Gt;function Wr(){if(typeof window<"u"){Bt=Math.floor(window.visualViewport?.width??window.innerWidth),Gt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Bt<Br||Gt<Gr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,Bt,Gt,n),n}return!1}function is({children:n}){const{mobile:l,setMobile:a}=r.useContext(Oe),{logAutoScroll:i}=r.useContext(De);return r.useEffect(()=>{function s(){const d=Wr();d&&(i.current=!1,localStorage.setItem(re.logAutoScroll,"false")),a(d)}return window.addEventListener("resize",s),a(Wr()),()=>window.removeEventListener("resize",s)},[i,a]),o&&console.log("MbfScreen rendering... mobile %s",l),ke&&l?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(Lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:l?`${Br}px`:"calc(100vw - 40px)",height:l?`${Gr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(Lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const ss=()=>{o=!o},ls=!1;let ke=localStorage.getItem(re.enableMobile)!=="false";const as=()=>{ke=!0,localStorage.setItem(re.enableMobile,"true")},cs=()=>{ke=!1,localStorage.setItem(re.enableMobile,"false")};let xt;const ds=n=>{xt=n};let Mt=!1,Fr="/",ft="/",lr="/";function us({setLoggedIn:n}){const[l,a]=r.useState(""),[i,s]=r.useState(""),d={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},h={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},y={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async M=>{try{const I=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:M})});if(I.ok){const{valid:D}=await I.json();D?(n(!0),M!==""&&(xt=M)):M!==""&&s("Incorrect password!")}else console.error("Failed to log in:",I.statusText)}catch(I){console.error("Failed to log in:",I)}},P=M=>{M.preventDefault(),t(l)};return t(""),e.jsx("div",{style:d,children:e.jsxs("form",{onSubmit:P,style:h,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:l,onChange:M=>a(M.target.value),style:y,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function ps(){const[n,l]=r.useState(!1),a=localStorage.getItem(re.frontendTheme)||"dark";o&&console.log('Setting frontend theme "%s"',a),document.body.setAttribute("frontend-theme",a);const i=rs("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const s=os(i);return Fr=window.location.href,ft=window.location.pathname,lr=ft.includes("/matterbridge/")?"/matterbridge/":ft.includes("/api/hassio_ingress/")?ft:"/",Mt=ft.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${Fr}"`),console.log(`- pathname = "${ft}"`),console.log(`- baseName = "${lr}"`),console.log(`- isIngress = "${Mt}"`),n?e.jsx(Jo,{theme:s,children:e.jsx(oo,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Tn,{children:e.jsx(Nn,{children:e.jsx(Yr,{basename:lr,children:e.jsx(is,{children:e.jsxs(Zr,{children:[e.jsx(ct,{path:"/",element:e.jsx(ji,{})}),e.jsx(ct,{path:"/devices",element:e.jsx(Ui,{})}),e.jsx(ct,{path:"/log",element:e.jsx(zi,{})}),e.jsx(ct,{path:"/settings",element:e.jsx(Xi,{})}),e.jsx(ct,{path:"/test",element:e.jsx(ts,{})}),e.jsx(ct,{path:"*",element:e.jsx(Xr,{to:"/"})})]})})})})})})}):e.jsx(us,{setLoggedIn:l})}eo.createRoot(document.getElementById("root")).render(e.jsx(to.StrictMode,{children:e.jsx(ps,{})}));
|
|
4
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(g.response.level)&&(oe.current==="info"&&g.response.level==="debug"||oe.current==="notice"&&(g.response.level==="debug"||g.response.level==="info")||oe.current==="warn"&&(g.response.level==="debug"||g.response.level==="info"||g.response.level==="notice")||oe.current==="error"&&(g.response.level==="debug"||g.response.level==="info"||g.response.level==="notice"||g.response.level==="warn")||oe.current==="fatal"&&(g.response.level==="debug"||g.response.level==="info"||g.response.level==="notice"||g.response.level==="warn"||g.response.level==="error")))||C.current!=="*"&&C.current!==""&&!C.current.startsWith("/")&&!C.current.endsWith("/")&&!g.response.message.toLowerCase().includes(C.current.toLowerCase())&&!g.response.name.toLowerCase().includes(C.current.toLowerCase())||C.current.startsWith("/")&&C.current.endsWith("/")&&(()=>{try{const Y=new RegExp(C.current.slice(1,-1),"i");return!Y.test(g.response.message)&&!Y.test(g.response.name)}catch(Y){return console.error(`WebSocket log search invalid regex filter "${C.current}":`,Y),!1}})()||g.response.name==="Commissioning"&&g.response.message.includes("is uncommissioned"))return;a(Y=>{const H=[...Y,{level:g.response.level,time:g.response.time,name:g.response.name,message:g.response.message}];return o&&console.log(`WebSocket new log message added (${H.length}/${x.current}):`,H[H.length-1]),H.length>x.current+x.current*10/100?(o&&console.log(`WebSocket sliced log messages to the last ${x.current} entries`),H.slice(H.length-x.current)):H})}else{if(o&&console.log(`WebSocket received message id ${g.id} method ${g.method}:`,g),g.id===0)f.current.forEach(ue=>ue.listener(g));else{const ue=f.current.find(Y=>Y.id===g.id);ue?ue.listener(g):console.warn(`WebSocket no listener found for message id ${g.id}:`,g)}return}}catch(g){console.error(`WebSocket error parsing message: ${g}`,g instanceof Error?g.stack:null)}},u.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${N}`),ne("WebSocket",`Connected to WebSocket: ${N}`),t(!0),I(),b.current=1,V.current=setTimeout(()=>{v.current=setInterval(()=>{S({id:z.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${N}`),ne("WebSocket",`No pong response received from WebSocket: ${N}`),t(!1)},1e3*q)},1e3*Ce)},1e3*m)},u.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${Mt?"with Ingress":""}: ${N}`),ne("WebSocket",`Disconnected from WebSocket: ${N}`),t(!1),I(),O(),V.current&&clearTimeout(V.current),j.current&&clearTimeout(j.current),v.current&&clearInterval(v.current),ne("WebSocket",`Reconnecting (attempt ${b.current} of ${ce}) to WebSocket${Mt?" (Ingress)":""}: ${N}`),Mt?setTimeout(R,5e3):b.current===1?R():b.current<ce?setTimeout(R,1e3*b.current):ne("WebSocket",`Reconnect attempts exceeded limit of ${ce} retries, refresh the page to reconnect to: ${N}`),b.current=b.current+1},u.current.onerror=B=>{o&&console.error(`WebSocket: WebSocket error connecting to ${N}:`,B),ne("WebSocket",`WebSocket error connecting to ${N}`)})},[N]),R=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${b.current}/${ce} to:`,N),k()},[k]);r.useEffect(()=>(k(),()=>{u.current&&u.current.readyState===WebSocket.OPEN&&u.current.close()}),[k]);const U=r.useMemo(()=>({messages:l,logLength:x,logAutoScroll:W,logFilterLevel:i,logFilterSearch:d,setMessages:a,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:L}),[l,x,W,i,d,a,s,h,L]),K=r.useMemo(()=>({logLength:x,logAutoScroll:W,logFilterLevel:i,logFilterSearch:d,setMessages:a,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:L,online:y,retry:b.current,getUniqueId:F,addListener:Se,removeListener:T,sendMessage:S,logMessage:ne}),[x,W,a,s,h,y,b.current,Se,T,S,ne]);return e.jsx(Ar.Provider,{value:U,children:e.jsx(De.Provider,{value:K,children:n})})}function Rn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function Ke(){const{retry:n}=r.useContext(De),l=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(Rn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(so,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(fe,{variant:"contained",color:"primary",onClick:l,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Vr({value:n,maxChars:l}){let a=n;if(n.length>l&&l>3){const i=l-3,s=n.substring(0,Math.ceil(i/2)),d=n.substring(n.length-Math.floor(i/2),n.length);a=`${s} … ${d}`}return n!==a?e.jsx(A,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:a})}):e.jsx("span",{children:a})}function Pe({children:n,style:l}){const a={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...a,...l},children:n})}function Ne({children:n,style:l}){const a={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...a,...l},children:n})}function $e({children:n,style:l}){const a={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...l},children:n})}function It({children:n,style:l}){const a={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...a,...l},children:n})}function mt({children:n,style:l}){const a={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...l},children:n})}function St({children:n,style:l}){const a={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...l},children:n})}function qe({children:n,style:l,onDragOver:a,onDragLeave:i,onDrop:s}){const d={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...d,...l},onDragOver:a,onDragLeave:i,onDrop:s,children:n})}function st({children:n,style:l,close:a}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...l},children:[n,ls]})}function On({systemInfo:n,compact:l}){const{mobile:a}=r.useContext(Oe),{addListener:i,removeListener:s,getUniqueId:d,sendMessage:h}=r.useContext(De),[y,t]=r.useState(n),P=r.useRef(d());if(o&&console.log("SystemInfoTable loading with systemInfo:",y,"compact:",l),n&&l&&y.totalMemory&&y.freeMemory){const f=y.totalMemory,u=y.freeMemory;y.freeMemory=`${u} / ${f}`,y.totalMemory=""}if(n&&l&&y.heapTotal&&y.heapUsed){const f=y.heapTotal,u=y.heapUsed;y.heapUsed=`${u} / ${f}`,y.heapTotal=""}if(n&&l&&y.osRelease&&y.osType){const f=y.osType,u=y.osRelease;y.osType=`${f} (${u})`,y.osRelease=""}if(n&&l&&y.osArch&&y.osPlatform){const f=y.osPlatform,u=y.osArch;y.osPlatform=`${f} (${u})`,y.osArch=""}const M=(f,u,b,z,v)=>{t(j=>({...j,totalMemory:f,freeMemory:u,heapTotal:b,heapUsed:z,rss:v}))},I=f=>{t(u=>({...u,cpuUsage:f.toFixed(2)+" %"}))},D=f=>{t(u=>({...u,processCpuUsage:f.toFixed(2)+" %"}))},O=(f,u)=>{t(b=>({...b,systemUptime:f,processUptime:u}))},ee=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:P.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const f=u=>{o&&console.log("SystemInfoTable received WebSocket Message:",u),u.method==="memory_update"&&u.response&&u.response.totalMemory&&u.response.freeMemory&&u.response.heapTotal&&u.response.heapUsed&&u.response.rss?(o&&console.log("SystemInfoTable received memory_update",u),M(u.response.totalMemory,u.response.freeMemory,u.response.heapTotal,u.response.heapUsed,u.response.rss)):u.method==="cpu_update"&&u.response&&u.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",u),I(u.response.cpuUsage),D(u.response.processCpuUsage)):u.method==="uptime_update"&&u.response&&u.response.systemUptime&&u.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",u),O(u.response.systemUptime,u.response.processUptime)):u.method==="/api/viewhistorypage"&&u.id===P.current&&u.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(f,P.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${P.current}`),()=>{s(f),o&&console.log("SystemInfoTable removed WebSocket listener")}},[i,s]);const[G,J]=r.useState(!1);return!y||G?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(Pe,{style:ke&&a?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"System info"}),e.jsx(st,{close:()=>J(!0),children:e.jsx(te,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:ee,children:e.jsx(A,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(be,{path:Ko,size:"22px"})})})})]}),e.jsx(qe,{style:ke&&a?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(y).filter(([f,u])=>u!==void 0&&u!=="").map(([f,u],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:f.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ke&&a?typeof u!="string"?u.toString():u:e.jsx(Vr,{value:typeof u!="string"?u.toString():u,maxChars:22})})]},f))})]})})]}))}const Sr=r.memo(On),kr={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},_n=n=>{if(!n)return"";const l=n.toString().replace(/[^0-9]/g,"");if(l.length<5)return l;const a=l.slice(0,4),i=l.slice(4,7),s=l.slice(7,11);return[a,i,s].filter(Boolean).join("-")};function Hn({id:n}){const{online:l,sendMessage:a,addListener:i,removeListener:s,getUniqueId:d}=r.useContext(De),[h,y]=r.useState(null),t=r.useRef(null),P=r.useRef(null),M=r.useRef(d()),{mobile:I,showConfirmCancelDialog:D}=r.useContext(Oe);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${P.current} and matter:`,h),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,P.current&&clearTimeout(P.current),P.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),y(null))},[n,a]),r.useEffect(()=>{const u=b=>{o&&console.log("QRDiv received WebSocket Message:",b),b.method==="refresh_required"&&b.response.changed==="matter"&&b.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${b.response.changed} for storeId "${b.response.matter.id}":`,b.response.matter),t.current===b.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${b.response.matter.id}":`,b.response.matter),P.current&&clearTimeout(P.current),y(b.response.matter)))};return i(u,M.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{s(u),P.current&&clearTimeout(P.current),P.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,s]);const O=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${h?.id}"`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,startCommission:!0}})},ee=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${h?.id}"`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,stopCommission:!0}})},G=()=>{o&&console.log(`QRDiv sent matter advertise for node "${h?.id}"`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,advertise:!0}})},J=u=>{o&&console.log(`QRDiv sent matter removeFabric for node "${h?.id}" and fabricIndex ${u}`),h&&a({id:M.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,removeFabric:u}})},f=async()=>{if(!h||!h.manualPairingCode)return;const u=h.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(u);else{const b=document.createElement("textarea");b.value=u,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}o&&console.log("Manual pairing code copied to clipboard")}catch(b){console.error("Failed to copy manual pairing code",b)}};return!h||!l?(o&&console.log("QRDiv rendering undefined state"),null):h.online?h.advertising&&h.qrPairingCode&&h.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"QR pairing code"}),e.jsxs(st,{children:[e.jsx(te,{"aria-label":"send advertising",size:"small",onClick:G,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:yr,size:"22px"})})}),e.jsx(te,{"aria-label":"stop pairing",size:"small",onClick:ee,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Turn off pairing",arrow:!0,children:e.jsx(be,{path:Qo,size:"22px"})})})]})]}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(jn,{value:h.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(It,{style:{justifyContent:"space-between"},children:[e.jsxs(mt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",_n(h.manualPairingCode)]}),e.jsx(st,{children:e.jsx(A,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(te,{"aria-label":"copy manual pairing code",size:"small",onClick:f,sx:kr,children:e.jsx(be,{path:Yo,size:.85})})})})]})]})):h.commissioned&&h.fabricInformations&&h.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Paired fabrics"}),e.jsxs(st,{children:[e.jsx(te,{"aria-label":"send advertising",size:"small",onClick:G,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:yr,size:"22px"})})}),e.jsx(te,{"aria-label":"start pairing",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(A,{title:"Turn on pairing",arrow:!0,children:e.jsx(be,{path:jr,size:"22px"})})})]})]}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(qe,{style:{flexDirection:"column",justifyContent:"flex-start",flex:"1 1 auto",overflow:"auto",padding:"0px 0px 10px 0px",gap:"0px"},children:h.fabricInformations.map((u,b)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",u.fabricIndex]}),e.jsx(A,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(te,{"aria-label":"remove the fabric",size:"small",onClick:()=>D("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>J(u.fabricIndex),()=>{}),sx:{...kr,padding:"2px"},children:e.jsx(be,{path:Zo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",u.rootVendorId," ",u.rootVendorName]}),u.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",u.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",h.sessionInformations?h.sessionInformations.filter(z=>z.fabric?.fabricIndex===u.fabricIndex&&z.isPeerActive===!0).length:"0"," ","subscriptions: ",h.sessionInformations?h.sessionInformations.filter(z=>z.fabric?.fabricIndex===u.fabricIndex&&z.isPeerActive===!0&&z.numberOfActiveSubscriptions>0).length:"0"]})]},b))}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):!h.commissioned&&!h.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ne,{children:e.jsx($e,{children:"QR pairing code"})}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(fe,{onClick:O,endIcon:e.jsx(be,{path:jr,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(Pe,{style:ke&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ne,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx($e,{children:"Server node"})}),e.jsx(St,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(St,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(It,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]}))}const Ir=r.memo(Hn);function En({title:n,children:l}){const a=r.useRef(null),[i,s]=r.useState(!1),d=()=>{const t=a.current;if(!t){s(!1);return}s(t.scrollWidth>t.clientWidth)},h=()=>{s(!1)},y={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsx(A,{title:n,open:i,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("span",{ref:a,onMouseEnter:d,onMouseLeave:h,style:y,children:l})})}function An(n,l,a){const i=n?.[a],s=l?.[a];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Vn({name:n,title:l,columns:a,rows:i,getRowKey:s,footerLeft:d,footerRight:h,onRowClick:y}){const t=r.useRef(new WeakMap),P=r.useRef(1),M=c=>{if(typeof s=="string"&&c&&c[s]!=null)return c[s];if(typeof s=="function"){const N=s(c);if(N!=null)return N}const x=a?.[0]?.id;if(x&&c&&c[x]!=null)return c[x];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let W=t.current.get(c);return W||(W=`rk_${P.current++}`,t.current.set(c,W)),W},[I,D]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[O,ee]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[G,J]=r.useState(!1),[f,u]=r.useState(()=>{try{const c=localStorage.getItem(`${n}_column_visibility`);if(c)return JSON.parse(c)}catch{}return{}}),b=r.useMemo(()=>{const c={};for(const x of a)x.hidden||(c[x.id]=x.required?!0:f[x.id]!==!1);return c},[a,f]),z=r.useMemo(()=>{if(!I||!O)return i;const c=a.find(W=>W.id===I);if(!c||c.noSort)return i;const x=i.map((W,N)=>({el:W,index:N}));return x.sort((W,N)=>{let ce;return typeof c.comparator=="function"?ce=c.comparator(W.el,N.el):ce=An(W.el,N.el,I),ce!==0?O==="asc"?ce:-ce:W.index-N.index}),x.map(W=>W.el)},[i,I,O,a]),v=c=>{if(I!==c||!I){D(c),ee("asc"),localStorage.setItem(`${n}_table_order_by`,c),localStorage.setItem(`${n}_table_order`,"asc");return}if(O==="asc"){ee("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}D(null),ee(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{J(!G)},V=c=>{u(x=>{const W=a.find(Ce=>Ce.id===c);if(W&&W.required)return x;const N=b[c]!==!1,ce={...x};N?ce[c]=!1:delete ce[c];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(ce))}catch{}return ce})},oe=()=>{u({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}J(!1)},[C,p]=r.useState(!1);return C?null:(o&&console.log(`Rendering table ${n}${I&&O?` ordered by ${I}:${O}`:""}`),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsxs(Be,{open:G,onClose:(c,x)=>{x==="backdropClick"||x==="escapeKeyDown"||j()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Je,{children:e.jsx(lo,{children:a.filter(c=>!c.hidden).map(c=>e.jsx(lt,{control:e.jsx(et,{disabled:!!c.required,checked:c.required?!0:b[c.id]!==!1,onChange:()=>V(c.id)}),label:c.label},c.id))})}),e.jsxs(Ze,{children:[e.jsx(fe,{onClick:oe,children:"Reset"}),e.jsx(fe,{variant:"contained",onClick:c=>{if(c?.currentTarget&&typeof c.currentTarget.blur=="function")try{c.currentTarget.blur()}catch{}const x=document.activeElement;if(x&&x instanceof HTMLElement&&typeof x.blur=="function")try{x.blur()}catch{}j()},children:"Close"})]})]}),e.jsxs(Ne,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx($e,{children:n}),l&&e.jsx($e,{children:l}),e.jsx(st,{close:()=>p(!0),children:e.jsx(te,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:c=>{if(c?.currentTarget?.blur)try{c.currentTarget.blur()}catch{}j()},"aria-label":"Configure Columns",children:e.jsx(A,{title:`Configure ${n} columns`,children:e.jsx(be,{path:Xo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx(qe,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:a.map(c=>{if(c.hidden||!c.required&&b[c.id]===!1)return null;const x=!c.noSort,W=x&&I===c.id&&!!O;return e.jsxs("th",{onClick:x?()=>v(c.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:c.minWidth,maxWidth:c.maxWidth,textAlign:c.align||"left",cursor:x?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:c.maxWidth?"nowrap":void 0,overflow:c.maxWidth?"hidden":void 0,textOverflow:c.maxWidth?"ellipsis":void 0},"aria-sort":x?W?O==="asc"?"ascending":"descending":"none":void 0,children:[c.label,W&&e.jsxs("span",{style:{marginLeft:6},children:[O==="asc"&&e.jsx(be,{path:en,size:"15px"}),O==="desc"&&e.jsx(be,{path:tn,size:"15px"})]})]},c.id)})})}),e.jsx("tbody",{children:z.map((c,x)=>{const W=M(c);return e.jsx("tr",{className:x%2===0?"table-content-even":"table-content-odd",onClick:y?N=>y(c,W,N):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:y?"pointer":void 0},children:a.map(N=>{if(N.hidden||!N.required&&b[N.id]===!1)return null;const ce=c[N.id],Ce=typeof N.render=="function"?N.render(ce,W,c,N):typeof ce=="boolean"?e.jsx(et,{checked:ce,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):N.format&&typeof ce=="number"?N.format(ce):ce!=null?String(ce):null,m=!!N.tooltip&&N.maxWidth!==void 0&&N.maxWidth!==null&&ce!==void 0&&ce!==null&&Ce!==null?e.jsx(En,{title:String(ce),children:Ce}):Ce;return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:N.align||"left",padding:"5px 10px",margin:"0",maxWidth:N.maxWidth,whiteSpace:N.maxWidth?"nowrap":void 0,overflow:N.maxWidth?"hidden":void 0,textOverflow:N.maxWidth?"ellipsis":void 0},children:m},N.id)})},W)})})]})}),(d||h)&&e.jsxs(It,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx(mt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:d}),e.jsx(mt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h})]})]}))}function Un(n){return r.memo(n)}const Dt=Un(Vn),Ur=n=>n.replace("git+","").replace(".git","").trim(),qn=n=>{let l=Ur(n);return l.startsWith("git://")&&(l=`https://${l.slice(6)}`),l.startsWith("ssh://git@github.com/")&&(l=`https://github.com/${l.slice(21)}`),l.startsWith("git@github.com:")&&(l=`https://github.com/${l.slice(15).replace(":","/")}`),l},zn=n=>{if(typeof n=="string")return n.trim()||null;if(!n||typeof n!="object")return null;const l=n.url;return typeof l=="string"&&l.trim()||null},Bn=()=>{try{const n=window.localStorage.getItem(re.searchPluginsTotal);if(!n)return{};const l=JSON.parse(n);if(!l||typeof l!="object")return{};const a={};for(const[i,s]of Object.entries(l)){if(!i||!s||typeof s!="object")continue;const d=s;typeof d.total=="number"&&typeof d.asOf=="string"&&(a[i]={total:d.total,asOf:d.asOf})}return a}catch{return{}}},Gn=n=>{try{window.localStorage.setItem(re.searchPluginsTotal,JSON.stringify(n))}catch{}},Jn=()=>{try{const n=window.localStorage.getItem(re.searchPluginsMeta);if(!n)return{};const l=JSON.parse(n);if(!l||typeof l!="object")return{};const a={};for(const[i,s]of Object.entries(l)){if(!i||!s||typeof s!="object")continue;const d=s;if(typeof d.asOf!="string")continue;const h=typeof d.homepage=="string"?d.homepage:null,y=typeof d.help=="string"?d.help:null,t=typeof d.changelog=="string"?d.changelog:null;a[i]={homepage:h,help:y,changelog:t,asOf:d.asOf}}return a}catch{return{}}},Kn=n=>{try{window.localStorage.setItem(re.searchPluginsMeta,JSON.stringify(n))}catch{}},Qn=()=>{try{const n=window.localStorage.getItem(re.searchPluginsVersions);if(!n)return{};const l=JSON.parse(n);if(!l||typeof l!="object")return{};const a={};for(const[i,s]of Object.entries(l)){if(!i||!s||typeof s!="object")continue;const d=s;if(typeof d.asOf!="string"||!Array.isArray(d.versions))continue;const h=d.versions.filter(y=>typeof y=="string");a[i]={versions:h,asOf:d.asOf}}return a}catch{return{}}},Yn=n=>{try{window.localStorage.setItem(re.searchPluginsVersions,JSON.stringify(n))}catch{}},Zn=({open:n,onClose:l,onSelect:a,onVersions:i})=>{const[s,d]=r.useState(""),h=r.useRef(""),y=r.useRef(!1),t=r.useRef(null),[P,M]=r.useState([]),[I,D]=r.useState(!1),[O,ee]=r.useState(!1),[G,J]=r.useState(!1),[f,u]=r.useState({done:0,total:0}),[b,z]=r.useState(null),v=r.useRef({}),j=()=>{const q=document.activeElement;q&&q instanceof HTMLElement&&q.blur()},V=q=>{const m=q.getFullYear().toString(),w=(q.getMonth()+1).toString().padStart(2,"0"),F=q.getDate().toString().padStart(2,"0");return`${m}-${w}-${F}`},oe=r.useCallback(async(q,m)=>{const w=v.current[q];if(!!w&&w.asOf===m&&Array.isArray(w.versions)&&w.versions.length>0&&w.versions[0]==="latest")return o&&console.log(`[SearchPluginsDialog] versions cache hit for ${q} (${w.versions.length.toString()})`),w.versions;w&&w.asOf===m&&w.versions.length>0&&w.versions[0]!=="latest"&&o&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${q} (asOf=${m})`);const L=`https://registry.npmjs.org/${encodeURIComponent(q)}`;o&&console.log(`[SearchPluginsDialog] fetching versions for ${q} from: ${L}`);const S=await fetch(L,{signal:t.current?.signal});if(!S.ok)return o&&console.log(`[SearchPluginsDialog] versions fetch failed for ${q}: ${S.status.toString()} ${S.statusText}`),[];const ne=await S.json(),Se=Object.keys(ne.versions??{}),T=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});Se.sort((B,g)=>T.compare(B,g)).reverse();const k=ne["dist-tags"]??{},R=typeof k?.dev=="string"&&String(k.dev).trim().length>0,U=Se.slice(0,20),K=["latest"];return R&&K.push("dev"),K.push(...U),o&&console.log(`[SearchPluginsDialog] fetched versions for ${q} (tags: latest${R?", dev":""}; latestVersions=${U.length.toString()}; allVersions=${Se.length.toString()}):`,K),v.current[q]={versions:K,asOf:m},Yn(v.current),K},[]),C=q=>new Intl.NumberFormat().format(q),p=[{label:"Name",id:"name",required:!0,maxWidth:230,tooltip:!0},{label:"Version",id:"version",required:!0,maxWidth:110,tooltip:!0},{label:"Monthly",id:"downloads",align:"right",maxWidth:120,render:q=>typeof q=="number"?C(q):""},{label:"Total",id:"total",align:"right",maxWidth:120,render:q=>typeof q=="number"?C(q):""},{label:"Description",id:"description",required:!0,maxWidth:300,tooltip:!0},{label:"Author",id:"author",maxWidth:140,tooltip:!0},{label:"Action",id:"action",align:"center",maxWidth:100,noSort:!0,required:!0,render:(q,m,w,F)=>e.jsxs("div",{style:{margin:"0",padding:"0",gap:"4px",display:"flex",flexDirection:"row",justifyContent:"center"},children:[e.jsx(A,{title:w.homepage?"Open the plugin homepage":"No homepage available",children:e.jsx("span",{children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!w.homepage,onClick:L=>{if(L.stopPropagation(),!!w.homepage)try{const S=new URL(w.homepage);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Tr,{})})})}),e.jsx(A,{title:w.help?"Open the plugin help":"No help available",children:e.jsx("span",{children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!w.help,onClick:L=>{if(L.stopPropagation(),!!w.help)try{const S=new URL(w.help);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(dr,{})})})}),e.jsx(A,{title:w.changelog?"Open the plugin changelog":"No changelog available",children:e.jsx("span",{children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!w.changelog,onClick:L=>{if(L.stopPropagation(),!!w.changelog)try{const S=new URL(w.changelog);(S.protocol==="http:"||S.protocol==="https:")&&window.open(S.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Kt,{})})})})]})}];r.useEffect(()=>{if(!n){y.current=!1,h.current="",t.current?.abort(),t.current=null,M([]),D(!1),ee(!1),J(!1),u({done:0,total:0}),z(null),d("");return}if(y.current)return;y.current=!0;const q=new AbortController;return t.current=q,v.current=Qn(),(async()=>{const m="matterbridge-",F=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(m)}&size=250`,L=ne=>new Promise(Se=>setTimeout(Se,ne)),S=ne=>{if(!Array.isArray(ne.downloads))return null;let Se=0,T=!1;for(const k of ne.downloads)typeof k?.downloads=="number"&&(Se+=k.downloads,T=!0);return T?Se:null};try{D(!0),z(null);const ne=Q=>{const _=String(Q??"").trim().toLowerCase();return _?!!(_==="github actions"||_==="github-actions"||_==="github-actions[bot]"||_.includes("github-actions")||_.endsWith("[bot]")):!1},Se=Q=>{const _=(Q.maintainers??[]).map(le=>(le.username??"").trim()).filter(Boolean),ie=(Q.publisher?.username??"").trim(),ge=_.find(le=>!ne(le));return ge||(ie&&!ne(ie)?ie:_[0]??ie??"")},T=await fetch(F,{signal:q.signal});if(!T.ok)throw new Error(`npm registry request failed: ${T.status} ${T.statusText}`);const k=await T.json(),R="luligu",U=Q=>Q.publisher?.username?.toLowerCase()===R||(Q.maintainers??[]).some(_=>_.username?.toLowerCase()===R),B=(k.objects??[]).filter(Q=>!!Q?.package&&typeof Q.package.name=="string").filter(Q=>Q.package?.name?.startsWith(m)).filter(Q=>!cr.includes(Q.package?.name??"")).sort((Q,_)=>{const ie=U(Q.package??{}),ge=U(_.package??{});return ie!==ge?ie?-1:1:(Q.package?.name??"").localeCompare(_.package?.name??"")}).map(Q=>{const _=Q.package,ie=_.name??"",ge=Se(_),le=typeof Q.downloads?.monthly=="number"?Q.downloads.monthly:null,Ee=(_.links?.npm??"").trim(),yt=((_.links?.homepage??"").trim()||Ee||(ie?`https://www.npmjs.com/package/${encodeURIComponent(ie)}`:"")).trim()||null;return{name:ie,version:_.version??"",downloads:le,total:null,description:_.description??"",author:ge,official:U(_),homepage:yt,help:null,changelog:null}}),g=V(new Date),ue=Bn(),Y=Jn(),me=B.map(Q=>{const _=ue[Q.name];return!_||typeof _.total!="number"?Q:(o&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${Q.name} (asOf=${_.asOf}):`,_.total),{...Q,total:_.total})}).map(Q=>{const _=Y[Q.name];if(!_||_.asOf!==g)return Q;const ie=_.homepage??Q.homepage,ge=_.help,le=_.changelog;return o&&(ge||le||ie&&ie!==Q.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${Q.name} (asOf=${_.asOf}):`,{homepage:ie,help:ge,changelog:le}),{...Q,homepage:ie,help:ge,changelog:le}});M(me);const xe=B.map(Q=>Q.name).filter(Q=>{const _=v.current[Q];return!_||_.asOf!==g||_.versions.length===0});o&&console.log(`[SearchPluginsDialog] versions prefetch queue (${xe.length.toString()}):`,xe);const Ie=1,Ae=200;let je=0;const pe=async()=>{for(;je<xe.length;){if(q.signal.aborted)return;const Q=je;je+=1;const _=xe[Q];if(_)try{const ie=await oe(_,g);o&&ie.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${_} (${ie.length.toString()}):`,ie.slice(0,5))}catch(ie){if(ie instanceof DOMException&&ie.name==="AbortError")return}finally{q.signal.aborted||await L(Ae)}}};Promise.all(Array.from({length:Math.min(Ie,B.length)},()=>pe()));const de=B.map(Q=>Q.name).filter(Q=>{const _=Y[Q],ie=!!_&&_.asOf===g,ge=!!_&&!!_.help&&!!_.changelog,le=!ie||!ge;return!le&&o&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${Q} (asOf=${_.asOf}).`),ie&&!ge&&o&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${Q} (asOf=${_.asOf}).`),le}),Fe=new Set(de),_e=async(Q,_)=>{const ie=`https://registry.npmjs.org/${encodeURIComponent(Q)}/latest`;try{const ge=await fetch(ie,{signal:q.signal});if(!ge.ok)return null;const le=await ge.json(),Ee=typeof le.homepage=="string"&&le.homepage.includes("http")?Ur(le.homepage):null,nt=typeof le.help=="string"&&le.help.startsWith("http")?le.help.trim():null,yt=typeof le.changelog=="string"&&le.changelog.startsWith("http")?le.changelog.trim():null,gr=zn(le.repository),er=gr?qn(gr):null,jt=er&&er.includes("http")?er:null,tr=Ee||jt||_||null,Jr=nt||(jt?`${jt}/blob/main/README.md`:null)||tr||null,Kr=yt||(jt?`${jt}/blob/main/CHANGELOG.md`:null)||tr||null;return{homepage:tr,help:Jr,changelog:Kr}}catch(ge){return ge instanceof DOMException&&ge.name==="AbortError",null}},ot=1,Z=250;let $=0;const we=async()=>{for(;$<de.length;){if(q.signal.aborted)return;const Q=$;$+=1;const _=de[Q];if(!_||!Fe.has(_))continue;Fe.delete(_);const ie=B.find(le=>le.name===_)?.homepage??null,ge=await _e(_,ie);if(q.signal.aborted)return;ge&&(M(le=>le.map(Ee=>Ee.name===_?{...Ee,homepage:ge.homepage??Ee.homepage,help:ge.help,changelog:ge.changelog}:Ee)),Y[_]={homepage:ge.homepage,help:ge.help,changelog:ge.changelog,asOf:g},Kn(Y)),q.signal.aborted||await L(Z)}};Promise.all(Array.from({length:Math.min(ot,B.length)},()=>we()));const He="2020-01-01",Qe=B.map(Q=>Q.name).filter(Q=>{const _=ue[Q],ie=!_||_.asOf!==g;return ie||o&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${Q} (asOf=${_.asOf}).`),ie}),Te=new Set(Qe),at=Qe.length;u({done:0,total:at}),J(at>0);const $t=async Q=>{const _=`https://api.npmjs.org/downloads/range/${He}:${g}/${encodeURIComponent(Q)}`;for(let ie=0;ie<3;ie+=1){const ge=await fetch(_,{signal:q.signal});if(ge.ok){const le=await ge.json();return S(le)}if(ge.status===404)return null;if(ge.status===429){const le=ge.headers.get("retry-after"),Ee=le?Number(le):NaN,nt=Number.isFinite(Ee)?Ee*1e3:2e3*(ie+1);await L(nt);continue}return null}return null},Yt=1,Zt=500;let bt=0,vt=0;const Xt=async()=>{for(;bt<Qe.length;){if(q.signal.aborted)return;const Q=bt;bt+=1;const _=Qe[Q];if(_&&Te.has(_)){Te.delete(_);try{o&&console.log(`[SearchPluginsDialog] fetching total downloads for ${_} (range ${He}:${g})...`);const ie=await $t(_);if(q.signal.aborted)return;o&&console.log(`[SearchPluginsDialog] total downloads fetched for ${_}:`,ie),M(ge=>ge.map(le=>le.name===_?{...le,total:ie}:le)),typeof ie=="number"&&(ue[_]={total:ie,asOf:g},Gn(ue),o&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${_} (asOf=${g}):`,ie))}catch(ie){if(ie instanceof DOMException&&ie.name==="AbortError")return}finally{vt+=1,u({done:vt,total:at}),q.signal.aborted||await L(Zt)}}}};Promise.all(Array.from({length:Math.min(Yt,B.length)},()=>Xt())).finally(()=>{q.signal.aborted||J(!1)}),o&&console.log(`[SearchPluginsDialog] npm packages starting with "${m}" (filtered/sorted):`,B)}catch(ne){if(ne instanceof DOMException&&ne.name==="AbortError")return;console.error("[SearchPluginsDialog] npm registry fetch error:",ne),z(ne instanceof Error?ne.message:String(ne))}finally{D(!1)}})(),()=>q.abort()},[n,oe]);const c=async()=>{j();const q=h.current||s;if(!(!q||O))try{ee(!0);const m=V(new Date),w=await oe(q,m);o&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${q} (${w.length.toString()}):`,w),i(w),ee(!1),a(q)}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.error("[SearchPluginsDialog] npm versions fetch error:",m),i([]),ee(!1),a(q)}},x=()=>{j(),l(),i([])},W=P.reduce((q,m)=>q+(typeof m.downloads=="number"?m.downloads:0),0),N=P.reduce((q,m)=>(typeof m.total=="number"&&(q.total+=m.total,q.hasAny=!0),q),{total:0,hasAny:!1}),ce=G?` Totals: ${f.done.toString()}/${f.total.toString()} fetched`:"",Ce=N.hasAny?C(N.total):"...";return e.jsxs(Be,{open:n,onClose:()=>{j(),l()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:"75vw",height:"75vh",maxWidth:"75vw",maxHeight:"75vh",display:"flex",flexDirection:"column"}}},children:[e.jsx(Ge,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Search Plugins"})]})}),e.jsx(Je,{dividers:!0,sx:{padding:0,flex:"1 1 auto",minHeight:0},children:e.jsx("div",{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",minHeight:0},children:I?e.jsx("div",{style:{padding:"20px"},children:"Loading npm registry..."}):b?e.jsx("div",{style:{padding:"20px"},children:b}):e.jsx(Dt,{name:"Search plugins",rows:P,columns:p,getRowKey:"name",onRowClick:(q,m,w)=>{h.current=q.name,d(q.name),w.detail===2&&c()},footerLeft:`Total packages: ${P.length.toString()} Total downloads: ${C(W)} / ${Ce}${ce}`,footerRight:s?`Selected: ${s}`:""})})}),e.jsxs(Ze,{sx:{justifyContent:"center",gap:1.5,flexWrap:"wrap"},children:[e.jsx(A,{title:"Select the plugin and close the dialog. Double-click a row to select and close the dialog.",children:e.jsx(fe,{variant:"contained",onClick:c,disabled:!(h.current||s)||O,children:"Select"})}),e.jsx(A,{title:"Close the dialog without selecting a plugin.",children:e.jsx(fe,{onClick:x,children:"Cancel"})})]})]})},cr=["matterbridge-","matterbridge-plugin-template","matterbridge-dyson","matterbridge-irobot","matterbridge-tuya","matterbridge-mqtt","matterbridge-matter","matterbridge-security","matterbridge-automations","matterbridge-securitysystem","matterbridge-adapter"];function Xn(){const{mobile:n,showSnackbarMessage:l}=r.useContext(Oe),{logMessage:a,sendMessage:i,getUniqueId:s}=r.useContext(De),[d,h]=r.useState("matterbridge-"),[y,t]=r.useState(["latest","dev"]),[P,M]=r.useState("latest"),[I,D]=r.useState(!1),O=r.useRef(s()),ee=m=>{const w=String(m??"").trim();if(!w)return{name:"",specifier:null};if(w.startsWith("@")){const L=w.lastIndexOf("@");if(L>0){const S=w.slice(0,L),ne=w.slice(L+1);if(S.includes("/")&&ne)return{name:S,specifier:ne}}return{name:w,specifier:null}}const F=w.indexOf("@");if(F>0){const L=w.slice(0,F),S=w.slice(F+1);return S?{name:L,specifier:S}:{name:L,specifier:null}}return{name:w,specifier:null}},G=()=>{const{name:m,specifier:w}=ee(d);return m?w?`${m}@${w}`:P?`${m}@${P}`:m:""},J=m=>{m.preventDefault(),D(!0)},f=()=>{D(!1)},u=m=>{m.preventDefault(),D(!1);const w=m.dataTransfer.files[0];if(w){a("Plugins",`Installing package ${w.name}. Please wait...`);const F=new FormData;F.append("file",w),F.append("filename",w.name),fetch("./api/uploadpackage",{method:"POST",body:F}).then(L=>L.text()).then(L=>{a("Plugins",`Server response: ${L}`)}).catch(L=>{console.error("Error uploading plugin file:",L),a("Plugins",`Error installing package ${L}`)})}},b=m=>{const w=m.target.files&&m.target.files[0];if(w){a("Plugins",`Uploading package ${w.name}`);const F=new FormData;F.append("file",w),F.append("filename",w.name),fetch("./api/uploadpackage",{method:"POST",body:F}).then(L=>L.text()).then(L=>{a("Plugins",`Server response: ${L}`)}).catch(L=>{console.error("Error uploading plugin file:",L),a("Plugins",`Error uploading package ${L}`)})}},z=()=>{const m=G();if(m){if(cr.includes(m.split("@")[0])){l(`Installation of plugin "${m}" is blocked by the ignore list.`);return}i({id:O.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:m,restart:!1}})}},v=()=>{i({id:O.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:d}})},j=()=>{document.getElementById("file-upload")?.click()},V=()=>{if(cr.includes(d.split("@")[0])){l(`Addition of plugin "${d}" is blocked by the ignore list.`);return}i({id:O.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:d}})},oe=m=>{m.preventDefault(),o&&console.log("Right-clicked Upload button")},C=m=>{m.preventDefault(),o&&console.log("Right-clicked Add button")},[p,c]=r.useState(!1),x=()=>{c(!0),o&&console.log("Dialog opened for selection")},W=()=>{h("matterbridge-"),c(!1),o&&console.log("Dialog closed without selection")},N=m=>{h(m),c(!1),o&&console.log("Select plugin:",m)},ce=m=>{t(m),M(m.includes("latest")?"latest":m[0]??""),o&&console.log("Select plugin versions:",m)},[Ce,q]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),Ce?null:e.jsxs(Pe,{children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Install plugins"}),e.jsx(st,{close:()=>q(!0)})]}),e.jsxs(qe,{onDragOver:J,onDragLeave:f,onDrop:u,style:ke&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsx(Zn,{open:p,onClose:W,onSelect:N,onVersions:ce}),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(A,{title:"Provide the npm name or the local path of the plugin to install, uninstall, or add",children:e.jsx(Me,{value:d,onChange:m=>{const w=m.target.value;t(["latest","dev"]),M("latest"),h(w)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0})}),y.length>0&&e.jsx(A,{title:"Select the npm tag/version to install",children:e.jsx("span",{children:e.jsxs(ur,{size:"small",style:{minWidth:"150px"},children:[e.jsx(Ut,{id:"plugin-version-label",children:"Tag or version"}),e.jsx(Xe,{labelId:"plugin-version-label",id:"plugin-version",value:P,label:"Tag or version",onChange:m=>M(String(m.target.value??"")),sx:{"& .MuiSelect-icon":{color:"var(--main-label-color)"}},children:y.map(m=>e.jsx(E,{value:m,children:m},m))})]})})}),e.jsx(A,{title:"Search on npm the plugin to install",children:e.jsx(te,{size:"large",onClick:x,children:e.jsx(ao,{fontSize:"inherit"})})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(A,{title:"Install or update a plugin from npm",children:e.jsxs(fe,{onClick:z,endIcon:e.jsx(Ue,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(A,{title:"Uninstall and remove a plugin",children:e.jsxs(fe,{onClick:v,endIcon:e.jsx(Nr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(A,{title:"Upload and install a plugin from a tarball",children:e.jsxs(fe,{onClick:j,onContextMenu:oe,endIcon:e.jsx(co,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(A,{title:"Add an already installed plugin or a plugin from a local path",children:e.jsxs(fe,{onClick:V,onContextMenu:C,endIcon:e.jsx(qt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:b})]})]})]})}const ei=r.memo(Xn);function dt({status:n,enabledText:l="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const d=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?l:a??l});return i!==void 0?e.jsx(A,{title:i,children:d}):d}}function Mr(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const ut={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_t={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Dr={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},ti={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},ri={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ye={padding:"0px",margin:"0px"},oi="5px 10px 5px 10px",Ht={},Le={},Et={},At={};let pt=[],nr=[];function ir(n,l){const a=n?.properties;if(!a||typeof a!="object")return!1;const i=a[l];return!i||typeof i!="object"?!1:typeof i.type=="string"}function gt(n){const l=n.items;return l!==void 0&&typeof l=="object"&&!Array.isArray(l)}const ni=({open:n,onClose:l,plugin:a})=>{const{sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),y=r.useRef(h()),t=r.useRef({}),P=r.useRef({}),[M,I]=r.useState(a.configJson),[D,O]=r.useState(a.schemaJson),[ee,G]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[J,f]=r.useState("");let u={};r.useEffect(()=>{const T=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(Mr(k)&&k.id===y.current&&k.method==="/api/select/devices"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/devices:`,k.response),pt=k.response),Mr(k)&&k.id===y.current&&k.method==="/api/select/entities"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/entities:`,k.response),nr=k.response))};if(s(T,y.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",y.current),M&&D&&D.properties){const k=(R,U,K=[])=>{!R||typeof R!="object"||(R.properties&&Object.keys(R.properties).forEach(B=>{const g=R.properties?.[B],ue=[...K,B];Object.keys(g).forEach(Y=>{if(Y.startsWith("ui:")){let H=U;ue.forEach(me=>{H[me]||(H[me]={}),H=H[me]}),H[Y]=g[Y],delete g[Y]}}),k(g,U,ue)}),["oneOf","anyOf","allOf"].forEach(B=>{Array.isArray(R[B])&&R[B].forEach(g=>{k(g,U,K)})}),R.items&&typeof R.items=="object"&&k(R.items,U,K))};k(D,ee),G(ee),t.current=D,P.current=ee}return a.name&&a.configJson&&a.schemaJson&&(I(a.configJson),O(a.schemaJson),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',a.name)),()=>{d(T),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,M,a,d,D,i,ee]);const b=(T,k)=>{u=T.formData},z=T=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",T.formData),I(T.formData),a.configJson=T.formData,a.restartRequired=!0,i({id:y.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.formData.name,formData:T.formData}}),l()};function v(T){const{id:k,label:R,onKeyChange:U,onDropPropertyClick:K,disabled:B,schema:g,children:ue,registry:Y,readonly:H,required:me}=T,{templates:xe}=Y,{RemoveButton:Ie}=xe.ButtonTemplates;if(!(Pn in g))return e.jsx(he,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ue});const je=({target:pe})=>U(pe&&pe.value);return e.jsxs(he,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(Me,{id:`${k}-key`,name:`${k}-key`,required:me,disabled:B||H,defaultValue:R,onBlur:H?void 0:je,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(he,{sx:{flex:1},children:ue}),e.jsx(Ie,{disabled:B||H,onClick:K(R),registry:Y})]})}function j(T){const{children:k,description:R,displayLabel:U,errors:K,help:B,hidden:g,registry:ue,uiSchema:Y}=T,H=Mn(Y),me=Dn("WrapIfAdditionalTemplate",ue,H);return g?e.jsx("div",{style:{display:"none"},children:k}):e.jsx(he,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(me,{...T,children:[U===!0&&R,k,K,B]})})}function V(T){const{description:k}=T;return k?e.jsx(ye,{sx:_t,children:k}):null}function oe(T){const{required:k,title:R}=T;return R?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ye,{sx:ut,children:["Title ",R," ",k&&e.jsx("mark",{children:"***"})]})}):null}function C(T){const{help:k}=T;return k?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ye,{sx:ti,children:k})}):null}function p(T){const{errors:k}=T;return k?e.jsxs(he,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ye,{color:"error",sx:ri,children:"Please fix the following errors:"}),e.jsx(wt,{children:k.map((R,U)=>e.jsxs(uo,{children:[e.jsx(X,{children:e.jsx(po,{color:"error"})}),e.jsx(ae,{primary:R.stack})]},U))})]}):null}function c(T){const{errors:k}=T;return k?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((R,U)=>e.jsxs(ye,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",R]},U))}):null}function x(T){const{id:k,name:R,_schema:U,_uiSchema:K,value:B,options:g,label:ue,type:Y,placeholder:H,required:me,disabled:xe,readonly:Ie,autofocus:Ae,onChange:je,onChangeOverride:pe,onBlur:de,onFocus:Fe,_rawErrors:_e,_hideError:ot,_registry:Z,_formContext:$}=T,we=({target:{value:Te}})=>je(Te===""?g.emptyValue:Te),He=({target:Te})=>de(k,Te&&Te.value),Qe=({target:Te})=>Fe(k,Te&&Te.value);return e.jsx(he,{sx:{padding:"0px",margin:"0px"},children:e.jsx(Me,{id:k,name:k,label:H&&H!==""?ue:void 0,variant:"outlined",placeholder:H&&H!==""?H:ue,required:me,disabled:xe||Ie,autoFocus:Ae,value:B||B===0?B:"",type:Y,autoComplete:Y==="password"?"current-password":R,onChange:pe||we,onBlur:He,onFocus:Qe,fullWidth:!0})})}function W(T){return console.log("ArrayFieldTitleTemplate:",T),null}function N(T){return console.log("ArrayFieldDescriptionTemplate:",T),null}function ce(T){return console.log("ArrayFieldItemTemplate:",T),null}function Ce(T){const{canAdd:k,onAddClick:R,schema:U,title:K,formData:B}=T,[g,ue]=r.useState(!1),[Y,H]=r.useState(!1),[me,xe]=r.useState(!1),[Ie,Ae]=r.useState(""),je=$=>{Ae($.target.value)},pe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",Ie,"selectDevices:",pt),ue(!g)},de=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",Ie,"selectEntities:",nr),H(!Y)},Fe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",Ie,"selectDevices:",pt),xe(!me)},_e=$=>{ue(!1),U.selectFrom==="serial"&>(U)?U.items.default=$.serial:U.selectFrom==="name"&>(U)&&(U.items.default=$.name),R()},ot=$=>{H(!1),U.selectEntityFrom==="name"&>(U)?U.items.default=$.name:U.selectEntityFrom==="description"&>(U)&&(U.items.default=$.description),R()},Z=$=>{xe(!1),U.selectDeviceEntityFrom==="name"&>(U)?U.items.default=$.name:U.selectDeviceEntityFrom==="description"&>(U)&&(U.items.default=$.description),R()};return e.jsxs(he,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(ye,{sx:ut,children:K}),k&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[U.selectFrom&&e.jsx(A,{title:"Add a device from the list",children:e.jsx(te,{onClick:pe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),U.selectEntityFrom&&e.jsx(A,{title:"Add an entity from the list",children:e.jsx(te,{onClick:de,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),U.selectDeviceEntityFrom&&e.jsx(A,{title:"Add a device entity from the list",children:e.jsx(te,{onClick:Fe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),e.jsx(A,{title:"Add a new item",children:e.jsx(te,{onClick:R,size:"small",color:"primary",sx:Ye,children:e.jsx(qt,{})})})]})]}),U.description&&e.jsx(ye,{sx:_t,children:U.description}),T.items.map($=>e.jsxs(he,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(he,{sx:{flexGrow:1,marginRight:"10px"},children:$.children}),e.jsx(te,{disabled:!$.hasMoveUp,onClick:$.onReorderClick($.index,$.index-1),size:"small",color:"primary",sx:Ye,children:e.jsx(fr,{})}),e.jsx(te,{disabled:!$.hasMoveDown,onClick:$.onReorderClick($.index,$.index+1),size:"small",color:"primary",sx:Ye,children:e.jsx(hr,{})}),e.jsx(te,{onClick:$.onDropIndexClick($.index),size:"small",color:"primary",sx:Ye,children:e.jsx(ar,{})})]},$.index)),e.jsxs(Be,{open:g,onClose:pe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ge,{children:"Select a device"}),e.jsxs(Je,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Me,{fullWidth:!0,variant:"outlined",value:Ie,onChange:je,placeholder:"Enter serial or name"})]}),e.jsx(wt,{dense:!0,children:pt.filter($=>$.serial.toLowerCase().includes(Ie.toLowerCase())||$.name.toLowerCase().includes(Ie.toLowerCase())).filter($=>!U.uniqueItems||!B.includes(U.selectFrom==="serial"?$.serial:$.name)).map(($,we)=>e.jsxs(Ft,{onClick:()=>_e($),sx:Ht,children:[$.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),$.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),$.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),e.jsx(ae,{primary:$.name,secondary:$.serial,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},we))})]}),e.jsx(Ze,{children:e.jsx(fe,{onClick:pe,children:"Close"})})]}),e.jsxs(Be,{open:Y,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ge,{children:"Select an entity"}),e.jsxs(Je,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Me,{fullWidth:!0,variant:"outlined",value:Ie,onChange:je,placeholder:"Enter name or description"})]}),e.jsx(wt,{dense:!0,children:nr.filter($=>$.name.toLowerCase().includes(Ie.toLowerCase())||$.description.toLowerCase().includes(Ie.toLowerCase())).filter($=>!U.uniqueItems||!B.includes(U.selectEntityFrom==="name"?$.name:$.description)).map(($,we)=>e.jsxs(Ft,{onClick:()=>ot($),sx:Ht,children:[$.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),$.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),$.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),$.icon==="component"&&e.jsx(X,{children:e.jsx(mr,{style:Le})}),$.icon==="matter"&&e.jsx(X,{children:e.jsx(xr,{style:Le})}),e.jsx(ae,{primary:$.name,secondary:$.description,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},we))})]}),e.jsx(Ze,{children:e.jsx(fe,{onClick:de,children:"Close"})})]}),e.jsxs(Be,{open:me,onClose:Fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ge,{children:["Select an entity for ",K]}),e.jsx(Je,{children:e.jsx(wt,{dense:!0,children:pt.filter($=>$.serial===K||$.name===K).map($=>$.entities?.map((we,He)=>e.jsxs(Ft,{onClick:()=>Z(we),sx:Ht,children:[we.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),we.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),we.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),we.icon==="component"&&e.jsx(X,{children:e.jsx(mr,{style:Le})}),we.icon==="matter"&&e.jsx(X,{children:e.jsx(xr,{style:Le})}),e.jsx(ae,{primary:we.name,secondary:we.description,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},He)))})}),e.jsx(Ze,{children:e.jsx(fe,{onClick:Fe,children:"Close"})})]})]})}function q(T){const{onAddClick:k,schema:R,properties:U,title:K,description:B}=T,[g,ue]=r.useState(!1),[Y,H]=r.useState(""),me=pe=>{H(pe.target.value)},xe=()=>{ue(!g)},Ie=pe=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${pe.serial}" for schema "${R.selectFrom}"`),ue(!1);let de="";R.selectFrom==="serial"?de=pe.serial:R.selectFrom==="name"&&(de=pe.name),f(de),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${de}"`),k(R)()},Ae=()=>{k(R)()},je=!R.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${je} newkey "${J}"`),!je&&J!==""&&(o&&console.log("ObjectFieldTemplate: newkey",J,"properties",U),U.forEach(pe=>{if(pe.name==="newKey"&&pe.content.key==="newKey"&&pe.content.props.name==="newKey"&&pe.content.props.onKeyChange&&J!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",J);const de=J;f(""),pe.content.props.onKeyChange(de)}})),e.jsxs(he,{sx:{margin:"0px",padding:je?"10px":"5px 10px 0px 10px",border:je?"none":"1px solid grey"},children:[R.title&&je&&e.jsx(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ye,{sx:ut,children:R.title})}),K&&!je&&e.jsxs(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ye,{sx:ut,children:K}),e.jsxs(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[R.selectFrom&&e.jsx(A,{title:"Add a device from the list",children:e.jsx(te,{onClick:xe,size:"small",color:"primary",sx:Ye,children:e.jsx(Wt,{})})}),e.jsx(A,{title:"Add a new item",children:e.jsx(te,{onClick:Ae,size:"small",color:"primary",sx:Ye,children:e.jsx(qt,{})})})]})]}),R.description&&e.jsx(he,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ye,{sx:_t,children:R.description})}),U.map(({content:pe,name:de,hidden:Fe})=>!Fe&&e.jsxs(he,{sx:{margin:"0px",marginBottom:"10px",padding:ir(R,de)&&["object","array"].includes(R.properties[de].type)?"0px":oi,border:ir(R,de)&&["object","array"].includes(R.properties[de].type)?"none":"1px solid grey"},children:[ir(R,de)&&!["object","array","boolean"].includes(R.properties[de].type)&&e.jsx(ye,{sx:ut,children:R.properties[de].title||de}),e.jsx(he,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:pe})]},de)),e.jsxs(Be,{open:g,onClose:xe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ge,{children:"Select a device"}),e.jsxs(Je,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Me,{fullWidth:!0,variant:"outlined",value:Y,onChange:me,placeholder:"Enter serial or name"})]}),e.jsx(wt,{dense:!0,children:pt.filter(pe=>pe.serial.toLowerCase().includes(Y.toLowerCase())||pe.name.toLowerCase().includes(Y.toLowerCase())).map((pe,de)=>e.jsxs(Ft,{onClick:()=>Ie(pe),sx:Ht,children:[pe.icon==="wifi"&&e.jsx(X,{children:e.jsx(kt,{style:Le})}),pe.icon==="ble"&&e.jsx(X,{children:e.jsx(Tt,{style:Le})}),pe.icon==="hub"&&e.jsx(X,{children:e.jsx(Nt,{style:Le})}),e.jsx(ae,{primary:pe.name,secondary:pe.serial,primaryTypographyProps:{style:Et},secondaryTypographyProps:{style:At}})]},de))})]}),e.jsx(Ze,{children:e.jsx(fe,{onClick:xe,children:"Close"})})]})]})}function m(T){const{uiSchema:k}=T,{submitText:R,norender:U}=In(k);return U?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(fe,{type:"submit",variant:"contained",color:"primary",children:R}),e.jsx(fe,{variant:"contained",color:"primary",onClick:l,children:"Cancel"})]})}function w(T){const{className:k,disabled:R,onClick:U,registry:K,style:B,uiSchema:g,...ue}=T;return e.jsx(A,{title:"Remove the item",children:e.jsx(te,{disabled:R,size:"small",color:"primary",onClick:U,children:e.jsx(ar,{})})})}function F(T){const{className:k,disabled:R,onClick:U,registry:K,uiSchema:B,...g}=T;return e.jsx(A,{title:"Add an item",children:e.jsx(te,{size:"small",color:"primary",onClick:U,children:e.jsx(qt,{})})})}function L(T){const{disabled:k,onClick:R,registry:U,style:K,uiSchema:B,...g}=T;return e.jsx(A,{title:"Move up the item",children:e.jsx(te,{size:"small",color:"primary",onClick:R,children:e.jsx(fr,{})})})}function S(T){const{disabled:k,onClick:R,registry:U,style:K,uiSchema:B,...g}=T;return e.jsx(A,{title:"Move down the item",children:e.jsx(te,{size:"small",color:"primary",onClick:R,children:e.jsx(hr,{})})})}function ne(T){const{id:k,name:R,value:U,schema:K,readonly:B,onChange:g}=T,[ue,Y]=r.useState(),H=xe=>{o&&console.log(`CheckboxWidget ${R} onChangeField:`,xe),Y(xe&&xe!==""?xe:void 0)},me=()=>{o&&console.log(`CheckboxWidget onClick plugin="${a.name}" action="${R}" value="${ue}"`),i({id:y.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:R,value:ue,formData:u,id:k}}),K.buttonClose===!0?l():K.buttonSave===!0&&z({formData:M})};return K.buttonText&&(K.title||K.description)?e.jsxs(he,{sx:{margin:"0px",padding:"5px 0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ye,{sx:Dr,children:K.title||K.description}),e.jsx(fe,{variant:"contained",color:"primary",onClick:()=>me(),children:K.buttonText})]}):K.buttonField&&(K.title||K.description)?e.jsxs(he,{sx:{margin:"0px",padding:"5px 0px",gap:"20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ye,{sx:Dr,children:K.title||K.description}),e.jsx(Me,{id:R+"-input",name:R,label:K.textLabel,placeholder:K.textPlaceholder,onChange:xe=>H(xe.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(fe,{id:R+"-button",variant:"contained",color:"primary",disabled:ue===void 0,onClick:()=>me(),children:K.buttonField})]}):e.jsxs(he,{sx:{margin:"0px",padding:"0px"},children:[R&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ye,{sx:ut,children:K.title||R}),e.jsx(et,{checked:U,readOnly:B,onChange:()=>g(!U),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(ye,{sx:_t,children:K.description})]})}function Se({schema:T,id:k,name:R,options:U,label:K,hideLabel:B,required:g,disabled:ue,placeholder:Y,readonly:H,value:me,multiple:xe,autofocus:Ie,onChange:Ae,onBlur:je,onFocus:pe,errorSchema:de,rawErrors:Fe=[],registry:_e,uiSchema:ot,hideError:Z,formContext:$,...we}){const{enumOptions:He,enumDisabled:Qe,emptyValue:Te}=U;xe=typeof xe>"u"?!1:!!xe;const at=xe?[]:"",$t=typeof me>"u"||xe&&me.length<1||!xe&&me===at,Yt=({target:{value:le}})=>Ae(or(le,He,Te)),Zt=({target:le})=>je(k,or(le&&le.value,He,Te)),bt=({target:le})=>pe(k,or(le&&le.value,He,Te)),vt=Sn(me,He,xe),{InputLabelProps:Xt,SelectProps:Q,autocomplete:_,...ie}=we,ge=!xe&&T.default===void 0;return e.jsxs(Me,{id:k,name:k,value:!$t&&typeof vt<"u"?vt:at,required:g,disabled:ue||H,autoFocus:Ie,autoComplete:_,placeholder:Y,error:Fe.length>0,onChange:Yt,onBlur:Zt,onFocus:bt,...ie,select:!0,InputLabelProps:{...Xt,shrink:!$t},SelectProps:{...Q,multiple:xe},"aria-describedby":kn(k),children:[ge&&e.jsx(E,{value:"",children:Y}),Array.isArray(He)&&He.map(({value:le,label:Ee},nt)=>{const yt=Array.isArray(Qe)&&Qe.indexOf(le)!==-1;return e.jsx(E,{value:String(nt),disabled:yt,children:Ee},nt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!D||!M?null:e.jsxs(Be,{open:n,onClose:l,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Je,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(wn,{schema:D,formData:M,uiSchema:ee,validator:Cn,templates:{FieldTemplate:j,BaseInputTemplate:x,TitleFieldTemplate:oe,DescriptionFieldTemplate:V,FieldHelpTemplate:C,FieldErrorTemplate:c,ErrorListTemplate:p,WrapIfAdditionalTemplate:v,ArrayFieldTitleTemplate:W,ArrayFieldDescriptionTemplate:N,ArrayFieldItemTemplate:ce,ArrayFieldTemplate:Ce,ObjectFieldTemplate:q,ButtonTemplates:{SubmitButton:m,RemoveButton:w,AddButton:F,MoveUpButton:L,MoveDownButton:S}},widgets:{CheckboxWidget:ne,SelectWidget:Se},onChange:b,onSubmit:z})})]})};function qr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let l=0,a=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&l++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(l===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function ii({storeId:n,setStoreId:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),{showConfirmCancelDialog:y}=r.useContext(Oe),t=r.useRef(h()),[P,M]=r.useState(null),[I,D]=r.useState(null),[O,ee]=r.useState([]),G=[{label:"Name",id:"name",required:!0,render:(F,L,S,ne)=>e.jsx(A,{title:`Plugin path ${S.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>C(S),children:S.name})})},{label:"Description",id:"description",render:(F,L,S,ne)=>e.jsx(A,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>C(S),children:S.description})})},{label:"Version",id:"version",render:(F,L,S,ne)=>e.jsx(e.Fragment,{children:e.jsx(A,{title:`Plugin v.${S.version}`,children:e.jsx("span",{children:S.version.split("-")[0]+(S.version.includes("-dev-")?"@dev":"")+(S.version.includes("-git-")?"@git":"")})})})},{label:"Author",id:"author",render:(F,L,S,ne)=>e.jsx(e.Fragment,{children:S.author?S.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(F,L,S,ne)=>e.jsx(e.Fragment,{children:S.type?S.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(F,L,S,ne)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[I&&I.bridgeMode==="childbridge"&&!S.error&&S.enabled&&e.jsx(A,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:qr(S.matter)},onClick:()=>{S.matter?.id&&l(S.matter?.id)},size:"small",children:e.jsx(Rr,{})})}),I&&I.bridgeMode==="childbridge"&&!S.error&&S.enabled&&e.jsx(A,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>V(S),size:"small",children:e.jsx(zt,{})})}),e.jsx(A,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{disabled:S.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>q(S),size:"small",children:e.jsx(go,{})})}),I&&!I.readOnly&&e.jsx(A,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{f("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",S)},size:"small",children:e.jsx(Nr,{})})}),S.enabled?e.jsx(A,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{f("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",S)},size:"small",children:e.jsx(ho,{})})}):e.jsx(e.Fragment,{}),S.enabled?e.jsx(e.Fragment,{}):e.jsx(A,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>oe(S),size:"small",children:e.jsx(fo,{})})}),e.jsx(A,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>c(S),size:"small",children:e.jsx(dr,{})})}),e.jsx(A,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>x(S),size:"small",children:e.jsx(Kt,{})})}),S.latestVersion!==void 0&&S.latestVersion!==S.version&&I&&!I.readOnly&&e.jsx(A,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>z(S),size:"small",children:e.jsx(ze,{})})}),(S.version.includes("-dev-")||S.version.includes("-git-"))&&S.devVersion!==void 0&&S.devVersion!==S.version&&I&&!I.readOnly&&e.jsx(A,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{color:"var(--secondary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>v(S),size:"small",children:e.jsx(ze,{})})}),I&&!I.readOnly&&e.jsx(A,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>p(S),size:"small",children:e.jsx(pr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(F,L,S,ne)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:S.error?e.jsx(e.Fragment,{children:e.jsx(dt,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:S.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(dt,{status:S.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:S.loaded&&S.started&&S.configured?e.jsx(e.Fragment,{children:e.jsx(dt,{status:S.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{status:S.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(dt,{status:S.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(dt,{status:S.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const F=L=>{o&&console.log("HomePlugins received WebSocket Message:",L),L.method==="refresh_required"&&L.response.changed==="plugins"?L.response.lock?(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} lock=${L.response.lock} and locking plugins list`),ee(S=>S.map(ne=>ne.name===L.response.lock?{...ne,restartRequired:!0}:ne))):(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} lock=${L.response.lock} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):L.method==="refresh_required"&&L.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} and setting matter id ${L.response.matter?.id}`),ee(S=>{const ne=S.findIndex(T=>T.matter?.id===L.response.matter?.id);if(ne<0)return o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} and matter id ${L.response.matter?.id} not found`),S;o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} set matter id ${L.response.matter?.id}`);const Se=[...S];return Se[ne]={...Se[ne],matter:L.response.matter},Se})):L.method==="refresh_required"&&L.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${L.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),L.id===t.current&&L.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${L.id}) received settings:`,L.response),M(L.response.systemInformation),D(L.response.matterbridgeInformation)):L.id===t.current&&L.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${L.id}) received ${L.response.length} plugins:`,L.response),ee(L.response))};return s(F,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{d(F),o&&console.log("HomePlugins removed WebSocket listener")}},[s,d,i]),r.useEffect(()=>{a&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]);const J=r.useRef(null),f=(F,L,S,ne)=>{o&&console.log(`handleActionWithConfirmCancel ${S} ${ne.name}`),J.current=ne,y(F,L,S,u,b)},u=F=>{o&&console.log(`handleConfirm action confirmed ${F} ${J.current?.name}`),F==="remove"&&J.current?j(J.current):F==="disable"&&J.current&&oe(J.current),J.current=null},b=F=>{o&&console.log(`handleCancel action canceled ${F} ${J.current?.name}`),J.current=null},z=F=>{o&&console.log("handleUpdatePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name,restart:!1}})},v=F=>{o&&console.log("handleUpdateDevPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name+"@dev",restart:!1}})},j=F=>{o&&console.log("handleRemovePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},V=F=>{o&&console.log("handleRestartPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},oe=F=>{o&&console.log("handleEnableDisablePlugin plugin:",F.name,"enabled:",F.enabled),F.enabled===!0?(F.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})):(F.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}}))},C=F=>{o&&console.log(`handleHomepagePlugin plugin: ${F.name} homepage: ${F.homepage}`),F.homepage&&window.open(F.homepage,"_blank")},p=F=>{o&&console.log("handleSponsorPlugin plugin:",F.name,"funding:",F.funding),F.funding&&window.open(F.funding,"_blank")},c=F=>{o&&console.log("handleHelpPlugin plugin:",F.name,"help:",F.help),F.help&&window.open(F.help,"_blank")},x=F=>{o&&console.log("handleChangelogPlugin plugin:",F.name,"changelog:",F.changelog),F.changelog&&window.open(F.changelog,"_blank")},[W,N]=r.useState(),[ce,Ce]=r.useState(!1),q=F=>{o&&console.log("handleConfigPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),N(F),m()},m=()=>{Ce(!0)},w=()=>{Ce(!1)};return o&&console.log("HomePlugins rendering..."),a?e.jsxs(Pe,{children:[W&&e.jsx(ni,{open:ce,onClose:w,plugin:W}),e.jsx(Dt,{name:"Plugins",columns:G,rows:O,footerRight:"",footerLeft:""})]}):e.jsx(Ke,{})}const si=r.memo(ii),li=n=>`${n.pluginName}::${n.serial}`;function ai({storeId:n,setStoreId:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),[y,t]=r.useState(!1),[P,M]=r.useState(!0),[I,D]=r.useState(null),[O,ee]=r.useState([]),[G,J]=r.useState([]),[f,u]=r.useState([]),[b,z]=r.useState([]),v=r.useRef(h()),j=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(C,p,c,x)=>c.reachable===!0?"Online":c.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(C,p)=>{const c=C.reachable===!0?1:C.reachable===!1?0:-1,x=p.reachable===!0?1:p.reachable===!1?0:-1;return c-x}},{label:"Power",id:"powerSource",render:(C,p,c,x)=>c.powerSource==="ac"||c.powerSource==="dc"?e.jsx(Or,{fontSize:"small",sx:{color:"var(--primary-color)"}}):c.powerSource==="ok"?c.batteryLevel?e.jsx(A,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"green"}})}):e.jsx(it,{fontSize:"small",sx:{color:"gray"}}):c.powerSource==="warning"?c.batteryLevel?e.jsx(A,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"yellow"}})}):e.jsx(it,{fontSize:"small",sx:{color:"yellow"}}):c.powerSource==="critical"?c.batteryLevel?e.jsx(A,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(it,{fontSize:"small",sx:{color:"red"}})}):e.jsx(it,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(C,p,c,x)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[c.matter!==void 0?e.jsx(A,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{onClick:()=>l(n===c.matter?.id?I?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:c.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:qr(c.matter)},children:e.jsx(Rr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.configUrl?e.jsx(A,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(te,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(_r,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.selected!==void 0?e.jsx(A,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(et,{checked:c.selected,onChange:W=>oe(W,c),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],V=r.useCallback(C=>{C.selected=void 0;const p=O.find(W=>W.name===C.pluginName);if(!p)return console.error(`HomeDevices isSelected: plugin ${C.pluginName} not found for device ${C.name} `),C.selected;const c=p.schemaJson?.properties?.whiteList?.selectFrom;let x=p.configJson.postfix;return x===""&&(x=void 0),p.hasWhiteList===!0&&p.hasBlackList===!0&&c&&(C.selected=!0,c==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(x?C.serial.replace("-"+x,""):C.serial)&&(C.selected=!0),c==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(x?C.serial.replace("-"+x,""):C.serial)&&(C.selected=!1),c==="serial"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(x?C.serial.replace("-"+x,""):C.serial)&&(C.selected=!1),c==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(C.name)&&(C.selected=!0),c==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(C.name)&&(C.selected=!1),c==="name"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(C.name)&&(C.selected=!1)),C.selected},[O]);r.useEffect(()=>{const C=p=>{if(o&&console.log("HomeDevices received WebSocket Message:",p),p.method==="refresh_required"&&p.response.changed!=="matter"?p.response.changed==="plugins"&&p.response.lock?o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} lock=${p.response.lock} skipping /api/plugins request`):(o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} and sending /api/plugins request`),i({id:v.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):p.method==="refresh_required"&&p.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} and setting matter id ${p.response.matter?.id}`),z(c=>{const x=c.findIndex(N=>N.name.replaceAll(" ","")===p.response.matter?.id);if(x<0)return o&&console.debug(`HomeDevices: matter id ${p.response.matter?.id} not found`),c;const W=[...c];return W[x]={...W[x],matter:p.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${p.response.changed} and set matter id ${p.response.matter?.id}`),W})):p.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):p.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):p.method==="state_update"&&p.response.plugin&&p.response.serialNumber&&p.response.cluster.includes("BasicInformation")&&p.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${p.response.plugin} serial ${p.response.serialNumber} value ${p.response.value}`),J(c=>{const x=c.findIndex(W=>W.pluginName===p.response.plugin&&W.serial===p.response.serialNumber);return x<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${p.response.plugin} serial ${p.response.serialNumber}`),c):(c[x]={...c[x],reachable:p.response.value},[...c])})),p.id===v.current&&p.method==="/api/settings")o&&console.log(`HomeDevices (id: ${p.id}) received settings:`,p.response),D(p.response),t(p.response.matterbridgeInformation.restartRequired||p.response.matterbridgeInformation.fixedRestartRequired);else if(p.id===v.current&&p.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} plugins:`,p.response),p.response){let c=!0;for(const x of p.response)x.enabled===!0&&(x.loaded!==!0||x.started!==!0||x.error===!0)&&(c=!1);if(!c)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),M(!1),ee(p.response),J([]),u([]),i({id:v.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const x of p.response)x.enabled===!0&&x.loaded===!0&&x.started===!0&&x.error!==!0&&(i({id:v.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:x.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${x.name}`))}}else if(p.id===v.current&&p.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} devices:`,p.response),p.response){for(const c of p.response)c.selected=V(c);J(p.response)}}else p.id===v.current&&p.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} selectDevices for plugin ${p.response&&p.response.length>0?p.response[0].pluginName:"without select devices"}:`,p.response),p.response&&p.response.length>0&&u(c=>{const x=c.filter(N=>N.pluginName!==p.response[0].pluginName),W=p.response.map(N=>({...N,selected:V(N)}));return[...x,...W]}))};return s(C,v.current),o&&console.log(`HomeDevices added WebSocket listener id ${v.current}`),()=>{d(C),o&&console.log("HomeDevices removed WebSocket listener")}},[O,s,d,i,V]),r.useEffect(()=>{if(G.length===0&&f.length===0){z([]);return}o&&console.log(`HomeDevices mixing devices (${G.length}) and selectDevices (${f.length})`);const C=[];for(const p of G)C.push(p);for(const p of f)G.find(c=>c.pluginName===p.pluginName&&c.serial.includes(p.serial))||C.push(p);C.length>0&&(z(C),o&&console.log(`HomeDevices mixed ${C.length} devices and selectDevices`))},[O,G,f,z]),r.useEffect(()=>{a&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:v.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:v.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]);const oe=(C,p)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${C.target.checked} for device ${p.name} serial ${p.serial}`),G.findIndex(c=>c.pluginName===p.pluginName&&c.serial===p.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${p.name} serial ${p.serial} not found in devices, trying in mixedDevices`),z(c=>{const x=c.findIndex(W=>W.pluginName===p.pluginName&&W.serial===p.serial);return x<0?(console.error(`handleCheckboxChange: device ${p.name} serial ${p.serial} not found in mixedDevices`),c):(c[x]={...c[x],selected:C.target.checked},[...c])})):J(c=>{const x=c.findIndex(W=>W.pluginName===p.pluginName&&W.serial===p.serial);return x<0?(console.error(`handleCheckboxChange: device ${p.name} serial ${p.serial} not found in devices`),c):(c[x]={...c[x],selected:C.target.checked},[...c])}),C.target.checked?i({id:v.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}}):i({id:v.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}})};return o&&console.log("HomeDevices rendering..."),a?e.jsx(Pe,{style:{flex:"1 1 auto"},children:e.jsx(Dt,{name:"Devices",getRowKey:li,rows:b,columns:j,footerLeft:P?"Waiting for the plugins to fully load...":`Registered devices: ${G.length.toString()}/${b.length.toString()}`,footerRight:y?"Restart required":""})}):e.jsx(Ke,{})}const ci=r.memo(ai);function Pt({children:n,style:l,name:a}){const{setCurrentPage:i}=r.useContext(Oe);i(a),o&&console.log(`MbfPage: current page set to ${a}`);const s={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...s,...l},children:n})}const di=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function ui(){const{messages:n,logAutoScroll:l}=r.useContext(Ar),[a,i]=r.useState(!1),s=r.useRef(null),d=r.useRef(0),h=r.useRef(null),y=r.useMemo(()=>di(),[]),t=D=>i(!0),P=D=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${l.current} isHovering: ${a}`),l.current&&!a&&!y){const D=Date.now();D-d.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),d.current=D,s.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{s.current?.scrollIntoView({behavior:"smooth"}),d.current=Date.now()},1e3))}},[n,l,a,y]);const M=D=>{switch(D.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},I=D=>D.toLowerCase()==="warn"?"black":"white";return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:P,children:[n.map((D,O)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:M(D.level),color:I(D.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:D.level}),D.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+D.time+"]"}),D.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+D.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:D.message})]},O)),e.jsx("div",{ref:s})]})})}const zr=r.memo(ui);function pi(){const[n,l]=r.useState(localStorage.getItem(re.logFilterLevel)??"info"),[a,i]=r.useState(localStorage.getItem(re.logFilterSearch)??"*"),{online:s,logAutoScroll:d}=r.useContext(De);return o&&console.log("HomeLogs rendering..."),s?e.jsxs(Pe,{style:{flex:"1 1 auto"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Logs"}),e.jsxs($e,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',a===""?"*":a,'" Scroll: ',d.current?"auto":"manual"]})]}),e.jsx(qe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(zr,{})})]}):e.jsx(Ke,{})}const gi=r.memo(pi);function hi(){const{online:n}=r.useContext(De);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Pe,{children:[e.jsx(Ne,{children:e.jsx($e,{children:"Frontend Update"})}),e.jsxs(qe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(fe,{onClick:()=>window.location.reload(),endIcon:e.jsx(mo,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Ke,{})}const fi=r.memo(hi);function mi({changelog:n}){const{online:l}=r.useContext(De);return o&&console.log("HomeShowChangelog rendering..."),l?e.jsxs(Pe,{children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matterbridge Update"})}),e.jsxs(qe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(fe,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(Hr,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(fe,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(pr,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(fe,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Kt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(fe,{onClick:()=>window.location.reload(),endIcon:e.jsx(xo,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Ke,{})}const xi=r.memo(mi);function bi({matterbridgeInfo:n}){const{mobile:l}=r.useContext(Oe);o&&console.log("MatterbridgeInfoTable:",n);const a=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,s]=r.useState(!1);return!n||i?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(Pe,{style:ke&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ne,{children:[e.jsx($e,{children:"Matterbridge info"}),e.jsx(st,{close:()=>s(!0)})]}),e.jsx(qe,{style:ke&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([d,h])=>!a.includes(d)&&h!==null&&h!==void 0&&h!=="").map(([d,h],y)=>e.jsxs("tr",{className:y%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:d.replace("matterbridgeVersion","Matterbridge version").replace("matterbridgeLatestVersion","Matterbridge latest v.").replace("matterbridgeDevVersion","Matterbridge dev v.").replace("frontendVersion","Frontend version").replace("homeDirectory","Home").replace("rootDirectory","Root").replace("matterbridgeDirectory","Storage").replace("matterbridgeCertDirectory","Cert").replace("matterbridgePluginDirectory","Plugins").replace("globalModulesDirectory","Modules").replace("bridgeMode","Bridge mode").replace("restartMode","Restart mode").replace("virtualMode","Virtual mode").replace("profile","Profile").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("matterLoggerLevel","Matter logger level").replace("matterFileLogger","Matter file logger").replace("restartRequired","Restart required").replace("updateRequired","Update required")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ke&&l?typeof h!="string"?h.toString():h:e.jsx(Vr,{value:typeof h!="string"?h.toString():h,maxChars:24})})]},d))})]})})]}))}const vi=r.memo(bi);function yi(){const[n,l]=r.useState(null),[a,i]=r.useState(null),[s,d]=r.useState([]),[h]=r.useState(localStorage.getItem(re.homePagePlugins)!=="false"),[y,t]=r.useState(localStorage.getItem(re.homePageMode)??"devices"),[P,M]=r.useState("https://matterbridge.io/CHANGELOG.html"),[I,D]=r.useState(!1),[O,ee]=r.useState(!1),[G,J]=r.useState(null),{mobile:f}=r.useContext(Oe),{addListener:u,removeListener:b,online:z,sendMessage:v,getUniqueId:j}=r.useContext(De),V=r.useRef(j());return r.useEffect(()=>{const oe=C=>{o&&console.log("Home received WebSocket Message:",C),C.method==="refresh_required"&&C.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${C.response.changed} and sending /api/settings request`),J(null),d([]),v({id:V.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),v({id:V.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),C.method==="/api/settings"&&C.id===V.current&&(o&&console.log("Home received settings:",C.response),l(C.response.systemInformation),i(C.response.matterbridgeInformation),localStorage.getItem(re.frontendVersion)===null&&C.response.matterbridgeInformation.frontendVersion?localStorage.setItem(re.frontendVersion,C.response.matterbridgeInformation.frontendVersion):C.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(re.frontendVersion)&&C.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(re.frontendVersion,C.response.matterbridgeInformation.frontendVersion),ee(!0)),localStorage.getItem(re.matterbridgeVersion)===null?localStorage.setItem(re.matterbridgeVersion,C.response.matterbridgeInformation.matterbridgeVersion):C.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(re.matterbridgeVersion)&&(localStorage.setItem(re.matterbridgeVersion,C.response.matterbridgeInformation.matterbridgeVersion),D(!0)),C.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(re.homePageMode)||(localStorage.setItem(re.homePageMode,"devices"),t("devices")))),C.method==="/api/plugins"&&C.id===V.current&&(o&&console.log("Home received plugins:",C.response),d(C.response))};return u(oe,V.current),o&&console.log(`Home added WebSocket listener id ${V.current}`),()=>{b(oe),o&&console.log("Home removed WebSocket listener")}},[u,b,v]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${G}`),a?.bridgeMode==="bridge"&&!G&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),J("Matterbridge")),a?.bridgeMode==="childbridge"&&!G&&s){for(const oe of s)if(oe.matter?.id){o&&console.log(`Home storeId effect set storeId to ${oe.matter.id}`),J(oe.matter.id);break}}},[a,s,G]),r.useEffect(()=>{z&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),v({id:V.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),v({id:V.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[z,v]),o&&console.log("Home rendering..."),!z||!n||!a?e.jsx(Ke,{}):e.jsxs(Pt,{name:"Home",style:ke&&f?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(ke&&!f||!ke)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ir,{id:G}),e.jsx(Sr,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:ke&&f?"10px":"20px"},children:[O&&e.jsx(fi,{}),I&&e.jsx(xi,{changelog:P}),ke&&f&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(Ir,{id:G}),e.jsx(Sr,{systemInfo:n,compact:!0}),e.jsx(vi,{matterbridgeInfo:a})]}),h&&!a.readOnly&&e.jsx(ei,{}),h&&e.jsx(si,{storeId:G,setStoreId:J}),y==="devices"&&e.jsx(ci,{storeId:G,setStoreId:J}),y==="logs"&&e.jsx(gi,{})]})]})}const ji=r.memo(yi),Vt=!1,Pr={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},wi={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Ci={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},$r={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Si={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},ki={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Ii={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Mi={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Di={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},sr={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Pi=[256,257,268,269],$i=[266,267],Li=[259,260,261,271,272],Wi=[256,257,268,269,266,267,259,260,261,272];function se({icon:n,iconColor:l,cluster:a,value:i,unit:s,prefix:d}){return o&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),d=d??!1,e.jsxs(he,{sx:Pr,children:[n&&r.cloneElement(n,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...wi,color:l??"var(--primary-color)"}}),e.jsxs(he,{sx:{...Pr,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&d===!0&&e.jsx(ye,{sx:$r,children:s},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(ye,{sx:Ci,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),s&&d===!1&&e.jsx(ye,{sx:$r,children:s},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function Fi({device:n,endpoint:l,id:a,deviceType:i,clusters:s}){const d=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let h="";o&&console.log(`Device "${n.name}" endpoint "${l}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const y=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(y){let t="";y.map(P=>{P.label&&(t+=P.label+" ")}),h=t.trim()}if(i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>h=`${t.attributeLocalValue} mV`),Wi.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>h=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>h=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>h=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>h=h+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>h=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>h=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>h=h+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>h=h+`${t.attributeLocalValue/1e3} W`),i===39){const t=s.find(M=>M.clusterName==="ModeSelect"&&M.attributeName==="currentMode")?.attributeLocalValue;h=s.find(M=>M.clusterName==="ModeSelect"&&M.attributeName==="supportedModes")?.attributeLocalValue?.find(M=>M.mode===t)?.label||"Unknown"}if(i===116){const t=s.find(M=>M.clusterName==="RvcRunMode"&&M.attributeName==="currentMode")?.attributeLocalValue;h=s.find(M=>M.clusterName==="RvcRunMode"&&M.attributeName==="supportedModes")?.attributeLocalValue?.find(M=>M.mode===t)?.label||"Unknown"}return e.jsxs(Pe,{style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:t.attributeLocalValue===!0?e.jsx(kt,{}):e.jsx(bo,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(se,{icon:e.jsx(it,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(se,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:rn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Pi.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(vo,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),$i.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(be,{path:on,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Li.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(be,{path:nn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:sn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:ln,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:an,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:e.jsx(br,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:e.jsx(yo,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(se,{icon:e.jsx(be,{path:cn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(se,{icon:e.jsx(br,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(se,{icon:e.jsx(be,{path:dn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(se,{icon:e.jsx(be,{path:wr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(se,{icon:e.jsx(be,{path:wr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(se,{icon:e.jsx(jo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(se,{icon:e.jsx(be,{path:un,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(se,{icon:t.attributeValue==="1"?e.jsx(wo,{}):e.jsx(Co,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(se,{icon:e.jsx(So,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(se,{icon:e.jsx(be,{path:pn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(se,{icon:e.jsx(ko,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(se,{icon:e.jsx(Io,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(se,{icon:e.jsx(vr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(se,{icon:e.jsx(vr,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:e.jsx(Mo,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:e.jsx(Do,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:e.jsx(Po,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&s.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(se,{icon:e.jsx(be,{path:gn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(se,{icon:e.jsx(be,{path:hn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(se,{icon:e.jsx(be,{path:fn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(se,{icon:e.jsx(be,{path:mn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(se,{icon:e.jsx(be,{path:xn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(se,{icon:e.jsx(be,{path:bn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:Cr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(se,{icon:e.jsx(be,{path:Cr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(se,{icon:e.jsx($o,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(se,{icon:e.jsx(be,{path:vn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:d[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(Lo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(be,{path:yn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(Wo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(Fo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(se,{icon:t.attributeValue==="true"?e.jsx(To,{}):e.jsx(No,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(se,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Ro,{}):e.jsx(Oo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(se,{icon:e.jsx(_o,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(se,{icon:e.jsx(Ho,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(he,{sx:Si,children:e.jsx(ye,{sx:ki,children:h})}),e.jsx(he,{sx:Ii,children:e.jsx(ye,{sx:Mi,children:n.name})}),e.jsxs(he,{sx:Di,children:[o&&e.jsx(ye,{sx:sr,children:l}),e.jsx(ye,{sx:sr,children:a}),o&&e.jsxs(ye,{sx:sr,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Ti({filterPlugins:n,filterDevices:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),[y,t]=r.useState([]),[P,M]=r.useState({}),[I,D]=r.useState({}),[O,ee]=r.useState({}),G=r.useRef(h()),J=r.useCallback(v=>{(o||Vt)&&console.log(`DevicesIcons received state_update "${v.response.cluster}.${v.response.attribute}" for "${v.response.id}:${v.response.number}": "${v.response.value}"`,v.response);const j=y.find(oe=>oe.pluginName===v.response.plugin&&oe.serial===v.response.serialNumber);if(!j){(o||Vt)&&console.warn(`DevicesIcons updater device of plugin "${v.response.plugin}" serial "${v.response.serialNumber}" number "${v.response.number}" id "${v.response.id}" not found in devices(${y.length})`);return}const V=O[j.serial]?.find(oe=>oe.endpoint===v.response.number.toString()&&oe.clusterName===v.response.cluster&&oe.attributeName===v.response.attribute);if(!V){(o||Vt)&&console.warn(`DevicesIcons updater device "${j.name}" serial "${j.serial}" cluster "${v.response.cluster}" attribute "${v.response.attribute}" not found in clusters(${O[j.serial]?.length})`);return}V.attributeValue=String(v.response.value),V.attributeLocalValue=v.response.value,ee({...O}),(o||Vt)&&console.log(`DevicesIcons updated "${V.clusterName}.${V.attributeName}" for device "${j.name}" serial "${j.serial}" to "${V.attributeValue}"`)},[O,y]),f=r.useCallback(v=>{if(o&&console.log(`DevicesIcons received for device "${v.response.deviceName}" serial "${v.response.serialNumber}" deviceTypes (${v.response.deviceTypes.length}) "${v.response.deviceTypes.join(",")}" clusters (${v.response.clusters.length}):`,v.response),v.response.clusters.length===0)return;const j=v.response.serialNumber;P[j]=[],I[j]=v.response.deviceTypes,O[j]=[];for(const V of v.response.clusters)P[j].find(oe=>oe.endpoint===V.endpoint)||P[j].push({endpoint:V.endpoint,id:V.id,deviceTypes:V.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(V.clusterName)&&O[j].push(V);M({...P}),D({...I}),ee({...O}),o&&console.log(`DevicesIcons endpoints for "${j}":`,P[j]),o&&console.log(`DevicesIcons deviceTypes for "${j}":`,I[j]),o&&console.log(`DevicesIcons clusters for "${j}":`,O[j])},[O,I,P]);r.useEffect(()=>{const v=j=>{if(o&&console.log("DevicesIcons received WebSocket Message:",j),j.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${j.response.changed} and sending api requests`),i({id:G.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="state_update"&&j.response)J(j);else if(j.method==="/api/devices"&&j.response){o&&console.log(`DevicesIcons received ${j.response.length} devices:`,j.response),t(j.response),M({}),D({}),ee({});for(const V of j.response)o&&console.log("DevicesIcons sending /api/clusters"),i({id:G.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:V.pluginName,endpoint:V.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&f(j)};return s(v,G.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{d(v),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[y]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),a&&(o&&console.log("DevicesIcons useEffect online sending api requests"),i({id:G.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[a,i]);const u=r.memo(Fi),b=n?.trim().toLowerCase(),z=b&&b!=="all plugins";return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:y.filter(v=>z&&v.pluginName.toLowerCase()!==b?!1:l===""?!0:v.name.toLowerCase().includes(l)||v.serial.toLowerCase().includes(l)).map(v=>P[v.serial]&&P[v.serial].map(j=>j.deviceTypes.map(V=>e.jsx(u,{device:v,endpoint:j.endpoint,id:j.id,deviceType:V,clusters:O[v.serial].filter(oe=>oe.endpoint===j.endpoint)},`${v.pluginName}-${v.uniqueId}-${j.endpoint}-${j.id}-${V.toString()}`))))})}const Ni=r.memo(Ti),Ri=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,l,a,i)=>a.configUrl?e.jsx(te,{onClick:()=>window.open(a.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(_r,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Oi=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,l,a,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,maxWidth:350,tooltip:!0}],_i=n=>`${n.pluginName}::${n.uniqueId}`,Hi=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Ei({filterPlugins:n,filterDevices:l}){const{online:a,sendMessage:i,addListener:s,removeListener:d,getUniqueId:h}=r.useContext(De),[y,t]=r.useState([]),[P,M]=r.useState(y),[I,D]=r.useState([]),[O,ee]=r.useState(0),[G,J]=r.useState(null),[f,u]=r.useState(null),[b,z]=r.useState(null),[v,j]=r.useState(null),V=r.useRef(h()),oe=r.useRef(P),C=r.useCallback(c=>{o&&console.log(`DevicesTable received state_update "${c.response.cluster}.${c.response.attribute}" for "${c.response.id}:${c.response.number}": "${c.response.value}"`,c.response);const x=oe.current.find(W=>W.pluginName===c.response.plugin&&W.uniqueId===c.response.uniqueId);if(!x){o&&console.warn(`DevicesTable updater device of plugin "${c.response.plugin}" serial "${c.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(G&&f&&x.pluginName===G&&x.uniqueId===v&&c.response.number.toString()===f){const W=I.find(N=>N.endpoint===c.response.number.toString()&&N.clusterName===c.response.cluster&&N.attributeName===c.response.attribute);if(!W){o&&console.warn(`DevicesTable updater cluster ${c.response.cluster}.${c.response.attribute} for device "${x.name}" serial "${x.serial}" not found in clusters`);return}W.attributeValue=typeof c.response.value=="object"?JSON.stringify(c.response.value,void 0,1).replaceAll('"',""):String(c.response.value),W.attributeLocalValue=c.response.value,D([...I]),o&&console.log(`DevicesTable updated attribute ${W.clusterName}.${W.attributeName} for device "${x.name}" serial "${x.serial}" to "${W.attributeValue}"`)}},[I,f,G,v]);r.useEffect(()=>{const c=x=>{if(o&&console.log("DevicesTable received WebSocket Message:",x),x.method==="refresh_required"&&x.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${x.response.changed} and sending /api/devices request`),i({id:V.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(x.method==="state_update"&&x.response)C(x);else if(x.method==="/api/devices")o&&console.log(`DevicesTable received ${x.response.length} devices:`,x.response),t(x.response);else if(x.method==="/api/clusters"){o&&console.log(`DevicesTable received ${x.response.clusters.length} clusters for plugin ${x.response.plugin}:`,x.response),D(x.response.clusters);const W={};for(const N of x.response.clusters)o&&console.log("Cluster:",N.endpoint),W[N.endpoint]?W[N.endpoint]++:W[N.endpoint]=1;ee(Object.keys(W).length)}};return s(c,V.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{d(c),o&&console.log("DevicesTable removed WebSocket listener")}},[i,s,d,C]),r.useEffect(()=>{a&&(o&&console.log("DevicesTable sending api requests with id ",V.current),i({id:V.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:V.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:V.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),r.useEffect(()=>{G&&f&&(o&&console.log("DevicesTable sending /api/clusters"),i({id:V.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:G,endpoint:Number(f)}}))},[G,f,i]),r.useEffect(()=>{const c=n?.trim().toLowerCase(),x=c&&c!=="all plugins";let W=y;x&&(W=W.filter(N=>N.pluginName.toLowerCase()===c)),l!==""&&(W=W.filter(N=>N.name.toLowerCase().includes(l)||N.serial.toLowerCase().includes(l))),M(W),oe.current=W},[y,n,l]);const p=c=>{if(c.uniqueId===v){j(null),J(null),u(null),z(null);return}j(c.uniqueId),J(c.pluginName),u(c.endpoint?c.endpoint.toString():null),z(c.name)};return o&&console.log("DevicesTable rendering..."),a?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx(Pe,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${G&&f?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Registered devices",getRowKey:_i,onRowClick:p,rows:P,columns:Ri,footerLeft:`Total devices: ${P.length.toString()}`})}),G&&f&&e.jsx(Pe,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Clusters",title:b||"",getRowKey:Hi,rows:I,columns:Oi,footerLeft:`Total child endpoints: ${O-1}`})})]}):e.jsx(Ke,{})}const Ai=r.memo(Ei);function Vi(){const{online:n,sendMessage:l,addListener:a,removeListener:i,getUniqueId:s}=r.useContext(De),[d,h]=r.useState(["All plugins"]),[y,t]=r.useState("All plugins"),[P,M]=r.useState(""),[I,D]=r.useState("icon"),O=r.useRef(s());r.useEffect(()=>{const u=localStorage.getItem(re.devicesFilterPlugins);u&&t(u)},[]),r.useEffect(()=>{const u=localStorage.getItem(re.devicesFilterDevices);u&&M(u)},[]),r.useEffect(()=>{const u=localStorage.getItem(re.devicesViewMode);u&&D(u)},[]),r.useEffect(()=>{const u=b=>{o&&b.id&&console.log("Devices received WebSocket Message:",b),b.method==="refresh_required"&&b.response.changed==="plugins"&&!b.response.lock?(o&&console.log(`Devices received refresh_required for plugins lock=${b.response.lock}, sending /api/plugins request with id ${O.current}`),l({id:O.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):b.method==="/api/plugins"&&b.id===O.current&&b.response&&(o&&console.log(`Devices received ${b.response.length} plugins:`,b.response),h(["All plugins",...b.response.map(z=>z.name)]))};return a(u,O.current),o&&console.log("Devices added WebSocket listener"),()=>{i(u),o&&console.log("Devices removed WebSocket listener")}},[l,a,i]),r.useEffect(()=>{n&&(o&&console.log("Devices sending /api/plugins request with id ",O.current),l({id:O.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,l]);const ee=u=>{const b=u.target.value;t(b),localStorage.setItem(re.devicesFilterPlugins,b)},G=u=>{M(u.target.value),localStorage.setItem(re.devicesFilterDevices,u.target.value)},J=()=>{M(""),localStorage.removeItem(re.devicesFilterDevices)},f=u=>{D(u),localStorage.setItem(re.devicesViewMode,u)};return o&&console.log("Devices rendering..."),n?e.jsxs(Pt,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px"},children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Plugin:"}),e.jsx(A,{title:"Filter devices by plugin",children:e.jsx(Xe,{variant:"outlined",value:y,onChange:ee,sx:{width:"260px",backgroundColor:"var(--main-bg-color)","& .MuiOutlinedInput-root":{backgroundColor:"var(--main-bg-color)"},"& .MuiSelect-select":{backgroundColor:"var(--main-bg-color)"},"& .MuiSelect-icon":{color:"var(--main-label-color)"}},input:e.jsx(Eo,{sx:{backgroundColor:"var(--main-bg-color)"}}),children:d.map(u=>e.jsx(E,{value:u,children:u},u))})})]}),e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(A,{title:"Filter devices by name or serial number",children:e.jsx(Me,{variant:"outlined",value:P,onChange:G,placeholder:"Enter the device name or serial",sx:{width:"260px","& .MuiOutlinedInput-root":{backgroundColor:"var(--main-bg-color)"}},slotProps:{input:{endAdornment:P?e.jsx(Ao,{position:"end",children:e.jsx(te,{"aria-label":"Clear device filter",size:"small",onClick:J,edge:"end",children:e.jsx(Vo,{sx:{fontSize:18,color:"var(--main-label-color)"}})})}):null}}})})]})]}),e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(te,{onClick:()=>f("table"),"aria-label":"Table View",disabled:I==="table",children:e.jsx(A,{title:"Table View",children:e.jsx(Uo,{style:{color:I==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(te,{onClick:()=>f("icon"),"aria-label":"Icon View",disabled:I==="icon",children:e.jsx(A,{title:"Icon View (beta)",children:e.jsx(qo,{style:{color:I==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),I==="table"&&e.jsx(Ai,{filterPlugins:y,filterDevices:P}),I==="icon"&&e.jsx(Ni,{filterPlugins:y,filterDevices:P})]}):e.jsx(Ke,{})}const Ui=r.memo(Vi);function qi(){const{logLength:n,logAutoScroll:l,setMessages:a,setLogFilterLevel:i,setLogFilterSearch:s,online:d,filterLogMessages:h}=r.useContext(De),[y,t]=r.useState(localStorage.getItem(re.logFilterLevel)??"info"),[P,M]=r.useState(localStorage.getItem(re.logFilterSearch)??"*"),[I,D]=r.useState(n.current.toString()),[O,ee]=r.useState(l.current),G=z=>{const v=z.target.value;t(v),i(v),h(v,P),localStorage.setItem(re.logFilterLevel,v),o&&console.log("handleLogFilterLevelChange called with value:",v)},J=z=>{const v=z.target.value;M(v),s(v),h(y,v),localStorage.setItem(re.logFilterSearch,v),o&&console.log("handleLogFilterSearchChange called with value:",v)},f=z=>{const v=z.target.checked;ee(v),l.current=v,h(y,P),localStorage.setItem(re.logAutoScroll,v?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",v)},u=z=>{const v=z.target.value;D(v),n.current=Number(v),localStorage.setItem(re.logLength,v),o&&console.log("handleLogLengthChange called with value:",v)},b=()=>{o&&console.log("handleClearLogsClick called"),a([])};return o&&console.log("Logs rendering..."),d?e.jsxs(Pt,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Ut,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:y,onChange:G,children:[e.jsx(E,{value:"debug",children:"Debug"}),e.jsx(E,{value:"info",children:"Info"}),e.jsx(E,{value:"notice",children:"Notice"}),e.jsx(E,{value:"warn",children:"Warn"}),e.jsx(E,{value:"error",children:"Error"}),e.jsx(E,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Ut,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(A,{title:"Use /text/ for case-insensitive regex search",children:e.jsx(Me,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:P,onChange:J,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(lt,{control:e.jsx(et,{checked:O,onChange:f}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(Ut,{id:"select-size-label",style:{color:"var(--div-text-color)"},children:"Log length:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-size-label",id:"select-size",value:I,onChange:u,children:[e.jsx(E,{value:100,children:"100"}),e.jsx(E,{value:200,children:"200"}),e.jsx(E,{value:500,children:"500"}),e.jsx(E,{value:1e3,children:"1000"})]}),e.jsx(A,{title:"Clear the logs",children:e.jsx(fe,{onClick:b,endIcon:e.jsx(ar,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})]})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(zr,{})})]}):e.jsx(Ke,{})}const zi=r.memo(qi),Bi=({open:n,ip:l,onClose:a,onSave:i})=>{const s=l?l.split(".").slice(0,3).join(".")+".1":"",[d,h]=r.useState("dhcp"),[y,t]=r.useState({ip:l??"",subnet:"255.255.255.0",gateway:s,dns:s}),P=D=>O=>{t({...y,[D]:O.target.value})},M=()=>{a()},I=()=>{i({type:d,...y}),a()};return e.jsxs(Be,{open:n,onClose:(D,O)=>{O==="backdropClick"||O==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ge,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Je,{dividers:!0,children:[e.jsxs(ur,{component:"fieldset",fullWidth:!0,children:[e.jsx(We,{component:"legend",children:"Select IP Configuration"}),e.jsxs(Er,{row:!0,value:d,onChange:D=>h(D.target.value),children:[e.jsx(lt,{value:"dhcp",control:e.jsx(Jt,{}),label:"DHCP"}),e.jsx(lt,{value:"static",control:e.jsx(Jt,{}),label:"Static"})]})]}),d==="static"&&e.jsxs(rt,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(rt,{size:6,children:e.jsx(Me,{label:"IP Address",fullWidth:!0,value:y.ip,onChange:P("ip")})}),e.jsx(rt,{size:6,children:e.jsx(Me,{label:"Subnet Mask",fullWidth:!0,value:y.subnet,onChange:P("subnet")})}),e.jsx(rt,{size:6,children:e.jsx(Me,{label:"Gateway",fullWidth:!0,value:y.gateway,onChange:P("gateway")})}),e.jsx(rt,{size:6,children:e.jsx(Me,{label:"DNS Server",fullWidth:!0,value:y.dns,onChange:P("dns")})})]})]}),e.jsxs(Ze,{children:[e.jsx(fe,{onClick:M,children:"Cancel"}),e.jsx(fe,{variant:"contained",onClick:I,children:"Save"})]})]})},Gi=({open:n,onClose:l,onSave:a})=>{const[i,s]=r.useState(""),[d,h]=r.useState(""),y=O=>{s(O.target.value)},t=O=>{h(O.target.value)},P=i.length>0&&i===d,M=()=>{l()},I=()=>{P&&(a(i),l())},D=()=>{a(""),l()};return e.jsxs(Be,{open:n,onClose:(O,ee)=>{ee==="backdropClick"||ee==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ge,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Je,{dividers:!0,children:e.jsx(ur,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(rt,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(rt,{size:12,children:e.jsx(Me,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:y})}),e.jsx(rt,{size:12,children:e.jsx(Me,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:d,onChange:t,error:d!==""&&i!==d,helperText:d!==""&&i!==d?"Passwords do not match":""})})]})})}),e.jsxs(Ze,{children:[e.jsx(fe,{onClick:M,children:"Cancel"}),e.jsx(fe,{variant:"contained",onClick:I,disabled:!P,children:"Change"}),e.jsx(fe,{variant:"contained",onClick:D,children:"Reset"})]})]})};function ht(n=1e3){let l=null;const a=(i=>{l!==null&&window.clearTimeout(l),l=window.setTimeout(()=>{i(),l=null},n)});return a.cancel=()=>{l!==null&&(window.clearTimeout(l),l=null)},a}const Qt=330;function Ji(){const{mobile:n}=r.useContext(Oe),{online:l,addListener:a,removeListener:i,sendMessage:s,getUniqueId:d}=r.useContext(De),[h,y]=r.useState(null),[t,P]=r.useState(null),M=r.useRef(d());return r.useEffect(()=>{const I=D=>{o&&console.log("Settings received WebSocket Message:",D),D.method==="refresh_required"&&D.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${D.response.changed} and sending /api/settings request`),s({id:M.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):D.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",D.response),y(D.response.matterbridgeInformation),P(D.response.systemInformation))};return a(I,M.current),o&&console.log("Settings added WebSocket listener"),()=>{i(I),o&&console.log("Settings removed WebSocket listener")}},[a,i,s]),r.useEffect(()=>{l&&(o&&console.log("Settings received online"),s({id:M.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,s]),o&&console.log("Settings rendering..."),!l||!h||!t?e.jsx(Ke,{}):e.jsx(Pt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:ke&&n?"10px":"20px"},children:[e.jsx(Ki,{matterbridgeInfo:h,systemInfo:t}),e.jsx(Qi,{matterbridgeInfo:h}),e.jsx(Yi,{matterbridgeInfo:h}),e.jsx(Zi,{systemInfo:t})]})})}function Ki({matterbridgeInfo:n,systemInfo:l}){const{sendMessage:a,getUniqueId:i}=r.useContext(De),[s,d]=r.useState("bridge"),[h,y]=r.useState("Info"),[t,P]=r.useState(!1),[M,I]=r.useState("dark"),[D,O]=r.useState(localStorage.getItem(re.homePagePlugins)!=="false"),[ee,G]=r.useState(localStorage.getItem(re.homePageMode)??"devices"),[J,f]=r.useState(localStorage.getItem(re.virtualMode)??"outlet"),u=r.useRef(i()),[b,z]=r.useState(!1),v=()=>z(!1),j=m=>{o&&console.log("handleSaveNetConfig called with config:",m),a({id:u.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:m})},[V,oe]=r.useState(!1),C=()=>oe(!1),p=m=>{o&&console.log("handleSaveChangePassword called with password:",m),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:m}}),ds(m)};r.useEffect(()=>{n&&(d(n.bridgeMode==="bridge"?"bridge":"childbridge"),y(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),P(n.fileLogger),f(n.virtualMode))},[n]),r.useEffect(()=>{const m=localStorage.getItem(re.frontendTheme);m&&I(m)},[]);const c=m=>{o&&console.log("handleChangeBridgeMode called with value:",m.target.value),d(m.target.value),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:m.target.value}})},x=m=>{o&&console.log("handleChangeMbLoggerLevel called with value:",m.target.value),y(m.target.value),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:m.target.value}})},W=m=>{o&&console.log("handleLogOnFileMbChange called with value:",m.target.checked),P(m.target.checked),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:m.target.checked}})},N=m=>{const w=m.target.value;o&&console.log("handleChangeTheme called with value:",w),I(w),localStorage.setItem(re.frontendTheme,w),document.body.setAttribute("frontend-theme",w)},ce=m=>{const w=m.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",w),O(w),localStorage.setItem(re.homePagePlugins,w?"true":"false")},Ce=m=>{const w=m.target.value;o&&console.log("handleChangeHomePageMode called with value:",w),G(w),localStorage.setItem(re.homePageMode,w)},q=m=>{const w=m.target.value;o&&console.log("handleChangeVirtualMode called with value:",w),f(w),localStorage.setItem(re.virtualMode,w),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:w}})};return!n||!l?null:e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matterbridge settings"})}),e.jsx(Bi,{open:b,ip:l.ipv4Address,onClose:v,onSave:j}),e.jsx(Gi,{open:V,onClose:C,onSave:p}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(Er,{row:!0,name:"mode-buttons-group",value:s,onChange:c,children:[e.jsx(lt,{value:"bridge",control:e.jsx(Jt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(lt,{value:"childbridge",control:e.jsx(Jt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:h,onChange:x,children:[e.jsx(E,{value:"Debug",children:"Debug"}),e.jsx(E,{value:"Info",children:"Info"}),e.jsx(E,{value:"Notice",children:"Notice"}),e.jsx(E,{value:"Warn",children:"Warn"}),e.jsx(E,{value:"Error",children:"Error"}),e.jsx(E,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(et,{checked:t,onChange:W,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:M,onChange:N,children:[e.jsx(E,{value:"classic",children:"Classic"}),e.jsx(E,{value:"light",children:"Light"}),e.jsx(E,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(et,{checked:D,onChange:ce,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:ee,onChange:Ce,children:[e.jsx(E,{value:"logs",children:"Logs"}),e.jsx(E,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:J,onChange:q,children:[e.jsx(E,{value:"disabled",children:"Disabled"}),e.jsx(E,{value:"outlet",children:"Outlet"}),e.jsx(E,{value:"light",children:"Light"}),e.jsx(E,{value:"switch",children:"Switch"}),e.jsx(E,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(fe,{variant:"contained",color:"primary",onClick:()=>oe(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(fe,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Configure IP"})})]})]})}function Qi({matterbridgeInfo:n}){const{sendMessage:l,getUniqueId:a}=r.useContext(De),[i,s]=r.useState("Info"),[d,h]=r.useState(!1),[y,t]=r.useState(""),[P,M]=r.useState(""),[I,D]=r.useState(""),[O,ee]=r.useState(""),[G,J]=r.useState(""),[f,u]=r.useState(""),b=r.useRef(a()),z=r.useMemo(()=>ht(1e3),[]),v=r.useMemo(()=>ht(1e3),[]),j=r.useMemo(()=>ht(1e3),[]),V=r.useMemo(()=>ht(1e3),[]),oe=r.useMemo(()=>ht(1e3),[]),C=r.useMemo(()=>ht(1e3),[]);r.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),h(n.matterFileLogger),t(n.matterMdnsInterface||""),M(n.matterIpv4Address||""),D(n.matterIpv6Address||""),ee(n.matterPort?n.matterPort.toString():""),J(n.matterDiscriminator?n.matterDiscriminator.toString():""),u(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>z.cancel(),[z]),r.useEffect(()=>()=>v.cancel(),[v]),r.useEffect(()=>()=>j.cancel(),[j]),r.useEffect(()=>()=>V.cancel(),[V]),r.useEffect(()=>()=>oe.cancel(),[oe]),r.useEffect(()=>()=>C.cancel(),[C]);const p=m=>{o&&console.log("handleChangeMjLoggerLevel called with value:",m.target.value),s(m.target.value),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:m.target.value}})},c=m=>{o&&console.log("handleLogOnFileMjChange called with value:",m.target.checked),h(m.target.checked),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:m.target.checked}})},x=m=>{o&&console.log("handleChangeMdnsInterface called with value:",m.target.value);const w=m.target.value;t(w),z(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:w}})})},W=m=>{o&&console.log("handleChangeIpv4Address called with value:",m.target.value);const w=m.target.value;M(w),v(()=>{o&&console.log("debounced sendMessage setipv4address with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:w}})})},N=m=>{o&&console.log("handleChangeIpv6Address called with value:",m.target.value);const w=m.target.value;D(w),j(()=>{o&&console.log("debounced sendMessage setipv6address with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:w}})})},ce=m=>{o&&console.log("handleChangeMatterPort called with value:",m.target.value);const w=m.target.value;ee(w),V(()=>{o&&console.log("debounced sendMessage setmatterport with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:w}})})},Ce=m=>{o&&console.log("handleChangeMatterDiscriminator called with value:",m.target.value);const w=m.target.value;J(w),oe(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:w}})})},q=m=>{o&&console.log("handleChangemMatterPasscode called with value:",m.target.value);const w=m.target.value;u(w),C(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",w),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:w}})})};return n?e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matter settings"})}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:p,children:[e.jsx(E,{value:"Debug",children:"Debug"}),e.jsx(E,{value:"Info",children:"Info"}),e.jsx(E,{value:"Notice",children:"Notice"}),e.jsx(E,{value:"Warn",children:"Warn"}),e.jsx(E,{value:"Error",children:"Error"}),e.jsx(E,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(et,{checked:d,onChange:c,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(Me,{value:y,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(Me,{value:P,onChange:W,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(Me,{value:I,onChange:N,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(Me,{value:O,onChange:ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(Me,{value:G,onChange:Ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(Me,{value:f,onChange:q,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function Yi({matterbridgeInfo:n}){return n?e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"Matterbridge info"})}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Re,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Re,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Re,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Re,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Re,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Re,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Re,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function Zi({systemInfo:n}){return n?e.jsxs(Pe,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Ne,{children:e.jsx($e,{children:"System info"})}),e.jsxs(qe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Re,{value:n.interfaceName,label:"Interface name"}),e.jsx(Re,{value:n.macAddress,label:"MAC Address"}),e.jsx(Re,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Re,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Re,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Re,{value:n.hostname,label:"Hostname"}),e.jsx(Re,{value:n.user,label:"User"})]})]}):null}function Re({value:n,label:l,width:a}){return e.jsx(Me,{focused:!0,value:n,size:"small",label:l,variant:"standard",sx:{width:a?`${a-20}px`:"100%","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const Xi=r.memo(Ji);function es(){const{online:n,sendMessage:l,addListener:a,removeListener:i,getUniqueId:s}=r.useContext(De),{showSnackbarMessage:d}=r.useContext(Oe),[h,y]=r.useState(null),[t,P]=r.useState([]),[M,I]=r.useState([]),[D,O]=r.useState(null),[ee,G]=r.useState({cpuUsage:0}),[J,f]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[u,b]=r.useState({systemUptime:"",processUptime:""}),z=r.useRef(s());return o&&console.log("Test uniqueId:",z),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const v=j=>{if(j.method==="restart_required")o&&console.log("Test received restart_required"),d("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),d("Refresh required",0),l({id:z.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:z.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:z.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="memory_update")o&&console.log("Test received memory_update",j),f(j.response);else if(j.method==="cpu_update")o&&console.log("Test received cpu_update",j),G(j.response);else if(j.method==="uptime_update")o&&console.log("Test received uptime_update",j),b(j.response);else if(j.method==="/api/settings"&&j.response)o&&console.log("Test received /api/settings:",j.response),d("Test received /api/settings",0),y(j.response);else if(j.method==="/api/plugins"&&j.response)o&&console.log(`Test received ${j.response.length} plugins:`,j.response),d("Test received /api/plugins",0),P(j.response);else if(j.method==="/api/devices"&&j.response){o&&console.log(`Test received ${j.response.length} devices:`,j.response),d("Test received /api/devices",0),I(j.response);for(const V of j.response)o&&console.log("Test sending /api/clusters for device:",V.pluginName,V.name,V.endpoint),l({id:z.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:V.pluginName,endpoint:V.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&(o&&console.log(`Test received ${j.response.clusters.length} clusters for device ${j.response.deviceName} endpoint ${j.response.id}:${j.response.number}:`,j),d(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),O(j.response))};return a(v,z.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(v),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[a,i,l,d]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,l,d]),o&&console.log("Test rendering..."),n?e.jsx(Pt,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Ke,{})}const ts=r.memo(es);function rs(n,l){o&&console.log("getCssVariable:",n,"defaultValue",l);const a=getComputedStyle(document.body).getPropertyValue(n).trim();return a||console.error("getCssVariable: undefined",a),a||l}function os(n){return zo({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function ns(){const{mobile:n,showSnackbarMessage:l,showConfirmCancelDialog:a}=r.useContext(Oe),{online:i,sendMessage:s,logMessage:d,addListener:h,removeListener:y,getUniqueId:t}=r.useContext(De),[P,M]=r.useState(!1),[I,D]=r.useState(!1),[O,ee]=r.useState(!1),[G,J]=r.useState(!1),[f,u]=r.useState(null),b=r.useRef(t()),[z,v]=r.useState(null),[j,V]=r.useState(null),[oe,C]=r.useState(null),[p,c]=r.useState(null),[x,W]=r.useState(null),N=Qr(),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},Ce=()=>{window.open("https://matterbridge.io/")},q=()=>{window.open("https://matterbridge.io/README.html")},m=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},w=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},F=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},L=()=>{s({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}}),ee(!1)},S=()=>{s({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}}),J(!1)},ne=()=>{s({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Se=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),d("Matterbridge","Installing system updates..."),s({id:b.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),d("Matterbridge","Installing software updates..."),s({id:b.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),s({id:b.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},R=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),d("Matterbridge","Downloading Shelly system log..."),l("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},U=()=>{f?.matterbridgeInformation.restartMode===""?s({id:b.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):s({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},K=()=>{s({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},B=()=>{s({id:b.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},g=()=>{s({id:b.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ue=()=>{s({id:b.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},Y=Z=>{v(Z.currentTarget)},H=Z=>{o&&console.log("Header: handleMenuClose",Z),v(null),Z==="/"||Z==="/devices"||Z==="/log"||Z==="/settings"?N(Z):Z==="reset_frontend"?(d("Matterbridge","Resetting frontend UI..."),l("Resetting frontend UI...",5),Wn(),window.location.reload()):Z==="download-mblog"?(d("Matterbridge","Downloading matterbridge log..."),l("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Z==="download-mjlog"?(d("Matterbridge","Downloading matter log..."),l("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Z==="view-mblog"?(d("Matterbridge","Loading matterbridge log..."),l("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):Z==="view-mjlog"?(d("Matterbridge","Loading matter log..."),l("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):Z==="view-diagnostic"?(d("Matterbridge","Loading diagnostic log..."),l("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):Z==="download-diagnostic"?(d("Matterbridge","Downloading diagnostic log..."),l("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):Z==="view-history"?s({id:b.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="download-history"?s({id:b.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="view-shellylog"?(d("Matterbridge","Loading shelly system log..."),l("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Z==="download-mbstorage"?(d("Matterbridge","Downloading matterbridge storage..."),l("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Z==="download-pluginstorage"?(d("Matterbridge","Downloading matterbridge plugins storage..."),l("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Z==="download-pluginconfig"?(d("Matterbridge","Downloading matterbridge plugins config..."),l("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Z==="download-mjstorage"?(d("Matterbridge","Downloading matter storage..."),l("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Z==="download-backup"?(d("Matterbridge","Downloading backup..."),l("Downloading backup...",10),window.location.href="./api/download-backup"):Z==="update"?L():Z==="updatedev"?S():Z==="updatecheck"?ne():Z==="shelly-sys-update"?Se():Z==="shelly-main-update"?T():Z==="shelly-create-system-log"?k():Z==="shelly-download-system-log"?R():Z==="softreset"?g():Z==="hardreset"?ue():Z==="restart"?U():Z==="shutdown"?K():Z==="reboot"?B():Z==="create-backup"?s({id:b.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="unregister"?s({id:b.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="reset"?s({id:b.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Z==="factoryreset"&&s({id:b.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},me=Z=>{o&&console.log("Header: handleMenuCloseCancel:",Z),v(null)},xe=Z=>{V(Z.currentTarget)},Ie=()=>{V(null)},Ae=Z=>{C(Z.currentTarget)},je=()=>{C(null)},pe=Z=>{c(Z.currentTarget)},de=()=>{c(null)},Fe=Z=>{W(Z.currentTarget)},_e=()=>{W(null)},ot=()=>{ss(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const Z=$=>{o&&console.log("Header received WebSocket Message:",$),$.method==="/api/settings"&&$.id===b.current?(o&&console.log("Header received settings:",$.response),u($.response),M($.response.matterbridgeInformation.restartRequired||$.response.matterbridgeInformation.fixedRestartRequired),D($.response.matterbridgeInformation.fixedRestartRequired),ee($.response.matterbridgeInformation.updateRequired)):$.method==="refresh_required"&&$.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${$.response.changed} and sending /api/settings request`),s({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):$.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${$.response.fixed}`),M(!0),$.response.fixed===!0&&D(!0)):$.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),M(!1)):$.method==="update_required"?(o&&console.log("Header received update_required"),$.response.devVersion===!0?J(!0):ee(!0),s({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):$.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),u(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:$.response.available},systemInformation:we.systemInformation}:null)):$.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),u(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:$.response.available},systemInformation:we.systemInformation}:null)):$.method==="/api/viewhistorypage"&&$.id===b.current&&$.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):$.method==="/api/downloadhistorypage"&&$.id===b.current&&$.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return h(Z,b.current),o&&console.log(`Header added WebSocket listener id ${b.current}`),()=>{y(Z),o&&console.log("Header removed WebSocket listener")}},[h,y,s,l]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),s({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,s]),o&&console.log("Header rendering... mobile %s",n),!i||!f?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:ot}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(Lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Lt,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!f.matterbridgeInformation.readOnly&&e.jsx(A,{title:`Matterbridge v.${f.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",f.matterbridgeInformation.matterbridgeVersion.split("-")[0]+(f.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-edge-")?"@edge":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-local-")?"@local":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-git-")?"@git":"")]})}),f.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),f.matterbridgeInformation.bridgeMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.bridgeMode})}):null,f.matterbridgeInformation.restartMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.restartMode})}):null,f.matterbridgeInformation.profile&&f.matterbridgeInformation.profile!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null,o&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${Bt}x${Gt}`,` enabled ${localStorage.getItem(re.enableMobile)!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:w})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Give a star to Matterbridge",children:e.jsx(te,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:F,children:e.jsx(Hr,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(A,{title:"Sponsor Matterbridge",children:e.jsx(te,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(pr,{})})}):null,e.jsx(A,{title:"Matterbridge homepage",children:e.jsx(te,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:Ce,children:e.jsx(Tr,{})})}),e.jsx(A,{title:"Matterbridge help",children:e.jsx(te,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:q,children:e.jsx(dr,{})})}),e.jsx(A,{title:"Matterbridge changelog",children:e.jsx(te,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:m,children:e.jsx(Kt,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&O&&e.jsx(A,{title:`Update matterbridge to latest version v.${f.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:L,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&G&&e.jsx(A,{title:`Update matterbridge to latest dev version v.${f.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(te,{style:{color:"var(--secondary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:S,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(A,{title:"Shelly system update",children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Se,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(A,{title:"Shelly software update",children:e.jsx(te,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:T,children:e.jsx(ze,{})})}),e.jsx(A,{title:"Restart matterbridge",children:e.jsx(te,{style:{color:P||I?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(zt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(A,{title:"Shut down matterbridge",children:e.jsx(te,{style:{color:P||I?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(tt,{})})}):null,e.jsx(A,{title:"Download, backup and more",children:e.jsx(te,{onClick:Y,children:e.jsx(Bo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ct,{id:"command-menu",anchorEl:z,keepMounted:!0,open:!!z,onClose:()=>H(""),children:[ke&&n&&e.jsxs(E,{onClick:()=>H("/"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ke&&n&&e.jsxs(E,{onClick:()=>H("/devices"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ke&&n&&e.jsxs(E,{onClick:()=>H("/log"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ke&&n&&e.jsxs(E,{onClick:()=>H("/settings"),children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>H("update"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>H("updatedev"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>H("updatecheck"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(E,{onClick:()=>H("shelly-sys-update"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(E,{onClick:()=>H("shelly-main-update"),children:[e.jsx(X,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>H("restart"),children:[e.jsx(X,{children:e.jsx(zt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(E,{onClick:()=>H("shutdown"),children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{a("Reboot","Are you sure you want to reboot the Shelly board?","reboot",H,me)},children:[e.jsx(X,{children:e.jsx(zt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:Ae,children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-view",anchorEl:oe,keepMounted:!0,open:!!oe,onClose:je,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{cs(),je(),me(""),window.open("/home","_self")},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{as(),je(),me(""),window.open("/home","_self")},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-mblog"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-mjlog"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-diagnostic"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("view-history"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{H("view-shellylog"),je()},children:[e.jsx(X,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:pe,children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-download",anchorEl:p,keepMounted:!0,open:!!p,onClose:de,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{H("download-mbstorage"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-pluginstorage"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-pluginconfig"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-mblog"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-mjstorage"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-mjlog"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-diagnostic"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-history"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{H("shelly-create-system-log"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{H("shelly-download-system-log"),de()},children:[e.jsx(X,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:xe,children:[e.jsx(X,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:Ie,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{H("create-backup"),Ie()},children:[e.jsx(X,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{H("download-backup"),Ie()},children:[e.jsx(X,{children:e.jsx(rr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Rt,{}),e.jsxs(E,{onClick:Fe,children:[e.jsx(X,{children:e.jsx(Go,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ct,{id:"sub-menu-reset",anchorEl:x,keepMounted:!0,open:!!x,onClose:_e,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(E,{onClick:()=>{_e(),a("Reset the frontend UI","Are you sure you want to reset the frontend UI? This will reset all local settings and reload the page.","reset_frontend",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset the frontend UI...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{_e(),a("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(E,{onClick:()=>{_e(),a("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(E,{onClick:()=>{_e(),a("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{_e(),a("Network reset","Are you sure you want to factory reset the network parameters?","softreset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(E,{onClick:()=>{_e(),a("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",H,me)},children:[e.jsx(X,{children:e.jsx(tt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ae,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Lr=r.memo(ns),Br=1200,Gr=900;let Bt,Gt;function Wr(){if(typeof window<"u"){Bt=Math.floor(window.visualViewport?.width??window.innerWidth),Gt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Bt<Br||Gt<Gr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,Bt,Gt,n),n}return!1}function is({children:n}){const{mobile:l,setMobile:a}=r.useContext(Oe),{logAutoScroll:i}=r.useContext(De);return r.useEffect(()=>{function s(){const d=Wr();d&&(i.current=!1,localStorage.setItem(re.logAutoScroll,"false")),a(d)}return window.addEventListener("resize",s),a(Wr()),()=>window.removeEventListener("resize",s)},[i,a]),o&&console.log("MbfScreen rendering... mobile %s",l),ke&&l?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(Lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:l?`${Br}px`:"calc(100vw - 40px)",height:l?`${Gr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(Lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const ss=()=>{o=!o},ls=!1;let ke=localStorage.getItem(re.enableMobile)!=="false";const as=()=>{ke=!0,localStorage.setItem(re.enableMobile,"true")},cs=()=>{ke=!1,localStorage.setItem(re.enableMobile,"false")};let xt;const ds=n=>{xt=n};let Mt=!1,Fr="/",ft="/",lr="/";function us({setLoggedIn:n}){const[l,a]=r.useState(""),[i,s]=r.useState(""),d={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},h={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},y={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async M=>{try{const I=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:M})});if(I.ok){const{valid:D}=await I.json();D?(n(!0),M!==""&&(xt=M)):M!==""&&s("Incorrect password!")}else console.error("Failed to log in:",I.statusText)}catch(I){console.error("Failed to log in:",I)}},P=M=>{M.preventDefault(),t(l)};return t(""),e.jsx("div",{style:d,children:e.jsxs("form",{onSubmit:P,style:h,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:l,onChange:M=>a(M.target.value),style:y,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function ps(){const[n,l]=r.useState(!1),a=localStorage.getItem(re.frontendTheme)||"dark";o&&console.log('Setting frontend theme "%s"',a),document.body.setAttribute("frontend-theme",a);const i=rs("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const s=os(i);return Fr=window.location.href,ft=window.location.pathname,lr=ft.endsWith("/")?ft:ft+"/",Mt=ft.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${Fr}"`),console.log(`- pathname = "${ft}"`),console.log(`- baseName = "${lr}"`),console.log(`- isIngress = "${Mt}"`),n?e.jsx(Jo,{theme:s,children:e.jsx(oo,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Tn,{children:e.jsx(Nn,{children:e.jsx(Yr,{basename:lr,children:e.jsx(is,{children:e.jsxs(Zr,{children:[e.jsx(ct,{path:"/",element:e.jsx(ji,{})}),e.jsx(ct,{path:"/devices",element:e.jsx(Ui,{})}),e.jsx(ct,{path:"/log",element:e.jsx(zi,{})}),e.jsx(ct,{path:"/settings",element:e.jsx(Xi,{})}),e.jsx(ct,{path:"/test",element:e.jsx(ts,{})}),e.jsx(ct,{path:"*",element:e.jsx(Xr,{to:"/"})})]})})})})})})}):e.jsx(us,{setLoggedIn:l})}eo.createRoot(document.getElementById("root")).render(e.jsx(to.StrictMode,{children:e.jsx(ps,{})}));
|