matterbridge 3.2.8-dev-20250918-52dc90c → 3.2.8-dev-20250919-e967b55
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/dist/frontend.js +80 -77
- package/dist/matterbridge.js +15 -47
- package/dist/update.js +0 -2
- package/frontend/build/assets/index.css +1 -1
- package/frontend/build/assets/index.js +2 -2
- package/frontend/package-lock.json +222 -222
- package/frontend/package.json +2 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,y as
|
|
1
|
+
import{B as e,y as o,S as lt,I as Wt,U as fr,V as xr,X as Xe,Y as br,Z as vr}from"./vendor_node_modules.js";import{u as yr,S as jr}from"./vendor_notistack.js";import{D as De,a as Ne,b as Pe,B as oe,c as X,A as Cr,I as B,C as Sr,T as H,S as wr,F as Zt,H as Mr,d as er,e as Ve,R as yt,P as ze,M as kr,f as rt,g as T,L as K,h as re,i as dt,V as ct,j as Oe,k as Nt,l as Ir,m as Dr,n as pe,o as Nr,p as Pr,q as jt,r as le,s as Le,K as Ht,t as Ot,u as St,v as pt,w as it,x as ut,W as at,y as mt,z as gt,E as We,G as $t,J as Et,N as Tr,O as Wr,Q as st,U as Fe,X as Je,Y as tr,Z as Fr,_ as Lr,$ as Rr,a0 as Hr,a1 as rr,a2 as Ct,a3 as Or,a4 as $r,a5 as Er,a6 as Vr,a7 as Vt,a8 as _r,a9 as Ar,aa as Ur,ab as zr,ac as qr,ad as Br,ae as Jr,af as _t,ag as Qr,ah as Gr,ai as Kr,aj as Yr,ak as Xr,al as Zr,am as eo,an as to,ao as ro,ap as oo,aq as no,ar as io,as as ao,at as so,au as lo,av as At,aw as ot,ax as or,ay as ke,az as nr,aA as wt,aB as _e,aC as co,aD as po}from"./vendor_mui.js";import{Q as uo}from"./vendor_qrcode.js";import{I as te,m as Ut,a as mo,b as go,c as zt,d as ho,e as Ft,f as Lt,g as fo,h as xo,i as bo,j as vo,k as yo,l as jo,n as Co,o as So,p as qt,q as wo,r as Mo,s as ko,t as Io,u as Do,v as No,w as Po,x as To,y as Bt,z as Wo,A as Fo,B as Lo}from"./vendor_mdi.js";import{r as Ae}from"./vendor_react_table.js";import{F as Ro,v as Ho,e as Oo,a as $o,g as Eo,b as Vo,c as _o,d as Pt,A as Ao}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const f of s)if(f.type==="childList")for(const y of f.addedNodes)y.tagName==="LINK"&&y.rel==="modulepreload"&&n(y)}).observe(document,{childList:!0,subtree:!0});function i(s){const f={};return s.integrity&&(f.integrity=s.integrity),s.referrerPolicy&&(f.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?f.credentials="include":s.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function n(s){if(s.ep)return;s.ep=!0;const f=i(s);fetch(s.href,f)}})();/**
|
|
2
2
|
* This file contains the types for WebSocket messages.
|
|
3
3
|
*
|
|
4
4
|
* @file frontendTypes.ts
|
|
@@ -20,4 +20,4 @@ import{B as e,y as r,S as st,I as Ee,U as gr,V as hr,X as Ye,Y as xr,Z as fr}fro
|
|
|
20
20
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
|
-
*/var Me=(o=>(o[o.Log=0]="Log",o[o.RefreshRequired=1]="RefreshRequired",o[o.RestartRequired=2]="RestartRequired",o[o.RestartNotRequired=3]="RestartNotRequired",o[o.CpuUpdate=4]="CpuUpdate",o[o.MemoryUpdate=5]="MemoryUpdate",o[o.UptimeUpdate=6]="UptimeUpdate",o[o.Snackbar=7]="Snackbar",o[o.UpdateRequired=8]="UpdateRequired",o[o.StateUpdate=9]="StateUpdate",o[o.CloseSnackbar=10]="CloseSnackbar",o[o.ShellySysUpdate=100]="ShellySysUpdate",o[o.ShellyMainUpdate=101]="ShellyMainUpdate",o))(Me||{});function _o({open:o,title:c,message:i,onConfirm:n,onCancel:s}){const h=t=>{a&&console.log("Confirmed"),t.preventDefault(),n()},b=t=>{a&&console.log("Canceled"),t.preventDefault(),s()};return e.jsxs(Ie,{open:o,children:[e.jsx(De,{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:c})]})}),e.jsxs(Ne,{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:i})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(oe,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(oe,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const gt=[],ot=r.createContext(null);function Ao({children:o}){const{enqueueSnackbar:c,closeSnackbar:i}=br(),n=r.useCallback(F=>{a&&console.log(`UiProvider closeSnackbarMessage: message ${F}`);const O=gt.findIndex(E=>E.message===F);O!==-1&&(i(gt[O].key),gt.splice(O,1),a&&console.log(`UiProvider closeSnackbarMessage: message ${F} removed from persistMessages`))},[i]),s=r.useCallback((F,O,E)=>{a&&console.log(`UiProvider showSnackbarMessage: message ${F} timeout ${O}`);const $=c(F,{variant:"default",autoHideDuration:O==null||O>0?(O??5)*1e3:null,persist:O===0,content:B=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(yr,{severity:E??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>i(B),action:e.jsx(z,{size:"small",onClick:()=>i(B),sx:{color:"#fff"},children:e.jsx(jr,{fontSize:"small"})}),children:F},B)},B)});O===0&&(a&&console.log(`UiProvider showSnackbarMessage: message ${F} timeout ${O} - persist key ${$}`),gt.push({message:F,key:$}))},[c,i]),[h,b]=r.useState(!1),[t,u]=r.useState(""),[C,L]=r.useState(""),[v,W]=r.useState(""),R=r.useRef(null),y=r.useRef(null),T=()=>{a&&console.log(`UiProvider handle confirm action ${v}`),b(!1),R.current&&R.current(v)},p=()=>{a&&console.log(`UiProvider handle cancel action ${v}`),b(!1),y.current&&y.current(v)},V=r.useCallback((F,O,E,$,B)=>{a&&console.log(`UiProvider showConfirmCancelDialog for command ${E}`),u(F),L(O),W(E),R.current=$,y.current=B,b(!0)},[]),S=r.useMemo(()=>({showSnackbarMessage:s,closeSnackbarMessage:n,closeSnackbar:i,showConfirmCancelDialog:V}),[s,n,i,V]);return e.jsxs(ot.Provider,{value:S,children:[e.jsx(_o,{open:h,title:t,message:C,onConfirm:T,onCancel:p}),o]})}const or=r.createContext(null),fe=r.createContext(null);function Uo({children:o}){const[c,i]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[n,s]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[h,b]=r.useState([]),[t,u]=r.useState(1e3),[C,L]=r.useState(!0),[v,W]=r.useState(!1),{showSnackbarMessage:R,closeSnackbarMessage:y,closeSnackbar:T}=r.useContext(ot),p=r.useRef([]),V=r.useRef(null),S=r.useRef(1),F=r.useRef(Math.floor(Math.random()*999e3)+1e3),O=r.useRef(null),E=r.useRef(null),$=r.useRef(null),B=r.useRef(c),Y=r.useRef(n),l=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),x=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),f=100,D=60,X=50,he=300;r.useEffect(()=>{B.current=c},[c]),r.useEffect(()=>{Y.current=n},[n]);const j=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),m=r.useCallback(w=>{if(V.current&&V.current.readyState===WebSocket.OPEN)try{w.id===void 0&&(w.id=F.current);const g=JSON.stringify(w);V.current.send(g),a&&console.log("WebSocket sent message:",w)}catch(g){a&&console.error(`WebSocket error sending message: ${g}`)}else a&&console.error("WebSocket message not sent, WebSocket not connected:",w)},[]),_=r.useCallback((w,g)=>{const d=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${w}</span>`;b(N=>[...N,d+' <span style="color: var(--main-log-color);">'+g+"</span>"])},[]),I=r.useCallback((w,g)=>{i(w),s(g),_("WebSocket",`Filtering by log level "${w}" and log search "${g}"`)},[_]),ee=r.useCallback(w=>{a&&console.log("WebSocket addListener:",w),p.current=[...p.current,w],a&&console.log("WebSocket addListener total listeners:",p.current.length)},[]),xe=r.useCallback(w=>{a&&console.log("WebSocket removeListener:",w),p.current=p.current.filter(g=>g!==w),a&&console.log("WebSocket removeListener total listeners:",p.current.length)},[]),Se=r.useCallback(()=>{l===""||l===null||l===void 0||(_("WebSocket",`Connecting to WebSocket: ${l}`),V.current=new WebSocket(l),V.current.onmessage=w=>{v||W(!0);try{const g=JSON.parse(w.data);if(g.id===void 0)return;if(g.error&&a&&console.error("WebSocket error message:",g),g.id===F.current&&g.src==="Matterbridge"&&g.dst==="Frontend"&&g.response==="pong"){a&&console.log("WebSocket pong response message:",g,"listeners:",p.current.length),E.current&&clearTimeout(E.current),p.current.forEach(N=>N(g));return}if(g.id===Me.RefreshRequired){a&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.RestartRequired){a&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.RestartNotRequired){a&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.CpuUpdate){a&&console.log("WebSocket WS_ID_CPU_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.MemoryUpdate){a&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.UptimeUpdate){a&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.Snackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_SNACKBAR message:",g,"listeners:",p.current.length),R(g.params.message,g.params.timeout,g.params.severity);return}else if(g.id===Me.CloseSnackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",g,"listeners:",p.current.length),y(g.params.message);return}else if(g.id===Me.ShellySysUpdate){a&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.ShellyMainUpdate){a&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id!==Me.Log){a&&console.log("WebSocket message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}if(!g.params||!g.params.level||!g.params.time||!g.params.name||!g.params.message||["debug","info","notice","warn","error","fatal"].includes(g.params.level)&&(B.current==="info"&&g.params.level==="debug"||B.current==="notice"&&(g.params.level==="debug"||g.params.level==="info")||B.current==="warn"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice")||B.current==="error"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn")||B.current==="fatal"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn"||g.params.level==="error"))||Y.current!=="*"&&Y.current!==""&&!g.params.message.toLowerCase().includes(Y.current.toLowerCase())&&!g.params.name.toLowerCase().includes(Y.current.toLowerCase())||g.params.name==="Commissioning"&&g.params.message.includes("is uncommissioned"))return;b(N=>{const ae=`<span style="color: #505050;">[${g.params?.time}]</span>`,le=be=>{switch(be?.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"lightblue"}},q=be=>{switch(be?.toLowerCase()){case"warn":return"black";default:return"white"}},me=`${`<span style="background-color: ${le(g.params?.level)}; color: ${q(g.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${g.params?.level}</span>`} ${ae} <span style="color: #09516d;">[${g.params?.name}]</span> <span style="color: var(--main-log-color);">${g.params?.message}</span>`,ne=[...N,me];return ne.length>t?ne.slice(t/10):ne})}catch(g){console.error(`WebSocketUse error parsing message: ${g}`)}},V.current.onopen=()=>{a&&console.log(`WebSocket: Connected to WebSocket: ${l}`),_("WebSocket",`Connected to WebSocket: ${l}`),W(!0),T(),S.current=1,$.current=setTimeout(()=>{O.current=setInterval(()=>{m({id:F.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{a&&console.error(`WebSocketUse: No pong response received from WebSocket: ${l}`),_("WebSocket",`No pong response received from WebSocket: ${l}`),W(!1)},1e3*X)},1e3*D)},1e3*he)},V.current.onclose=()=>{a&&console.error(`WebSocket: Disconnected from WebSocket ${x?"with Ingress":""}: ${l}`),_("WebSocket",`Disconnected from WebSocket: ${l}`),W(!1),T(),$.current&&clearTimeout($.current),E.current&&clearTimeout(E.current),O.current&&clearInterval(O.current),_("WebSocket",`Reconnecting (attempt ${S.current} of ${f}) to WebSocket${x?" (Ingress)":""}: ${l}`),x?setTimeout(U,5e3):S.current===1?U():S.current<f?setTimeout(U,1e3*S.current):_("WebSocket",`Reconnect attempts exceeded limit of ${f} retries, refresh the page to reconnect to: ${l}`),S.current=S.current+1},V.current.onerror=w=>{a&&console.error(`WebSocket: WebSocket error connecting to ${l}:`,w),_("WebSocket",`WebSocket error connecting to ${l}`)})},[l]),U=r.useCallback(()=>{a&&console.log(`WebSocket attemptReconnect ${S.current}/${f} to:`,l),Se()},[Se]);r.useEffect(()=>(Se(),()=>{V.current&&V.current.readyState===WebSocket.OPEN&&V.current.close()}),[Se]);const M=r.useMemo(()=>({messages:h,maxMessages:t,autoScroll:C,setMessages:b,setLogFilters:I,setMaxMessages:u,setAutoScroll:L}),[h,b,I]),k=r.useMemo(()=>({maxMessages:t,autoScroll:C,logFilterLevel:c,logFilterSearch:n,setMessages:b,setLogFilters:I,setMaxMessages:u,setAutoScroll:L,online:v,retry:S.current,getUniqueId:j,addListener:ee,removeListener:xe,sendMessage:m,logMessage:_}),[t,C,b,I,u,L,v,S.current,ee,xe,m,_]);return e.jsx(or.Provider,{value:M,children:e.jsx(fe.Provider,{value:k,children:o})})}function zo(){const{showSnackbarMessage:o,showConfirmCancelDialog:c}=r.useContext(ot),{online:i,sendMessage:n,logMessage:s,addListener:h,removeListener:b,getUniqueId:t}=r.useContext(fe),[u,C]=r.useState(!1),[L,v]=r.useState(!1),[W,R]=r.useState(!1),[y,T]=r.useState(!1),[p,V]=r.useState(null),S=r.useRef(t()),[F,O]=r.useState(null),[E,$]=r.useState(null),[B,Y]=r.useState(null),[l,x]=r.useState(null),[f,D]=r.useState(null),X=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},he=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},j=()=>{p.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},m=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},_=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},I=()=>{n({id:S.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},ee=()=>{n({id:S.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},xe=()=>{n({id:S.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Se=()=>{a&&console.log("Header: handleShellySystemUpdateClick"),s("Matterbridge","Installing system updates..."),n({id:S.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},U=()=>{a&&console.log("Header: handleShellyMainUpdateClick"),s("Matterbridge","Installing software updates..."),n({id:S.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{a&&console.log("Header: handleShellyCreateSystemLog"),n({id:S.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{a&&console.log("Header: handleShellyDownloadSystemLog"),s("Matterbridge","Downloading Shelly system log..."),o("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},w=()=>{p.matterbridgeInformation.restartMode===""?n({id:S.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:S.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},g=()=>{n({id:S.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},d=()=>{n({id:S.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},N=()=>{n({id:S.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{n({id:S.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=J=>{O(J.currentTarget)},q=J=>{a&&console.log("Header: handleMenuClose",J),O(null),J==="download-mblog"?(s("Matterbridge","Downloading matterbridge log..."),o("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):J==="download-mjlog"?(s("Matterbridge","Downloading matter log..."),o("Downloading matter log...",5),window.location.href="./api/download-mjlog"):J==="view-mblog"?(s("Matterbridge","Loading matterbridge log..."),o("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):J==="view-mjlog"?(s("Matterbridge","Loading matter log..."),o("Loading matter log...",5),window.location.href="./api/view-mjlog"):J==="view-shellylog"?(s("Matterbridge","Loading shelly system log..."),o("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):J==="download-mbstorage"?(s("Matterbridge","Downloading matterbridge storage..."),o("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):J==="download-pluginstorage"?(s("Matterbridge","Downloading matterbridge plugins storage..."),o("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):J==="download-pluginconfig"?(s("Matterbridge","Downloading matterbridge plugins config..."),o("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):J==="download-mjstorage"?(s("Matterbridge","Downloading matter storage..."),o("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):J==="download-backup"?(s("Matterbridge","Downloading backup..."),o("Downloading backup...",10),window.location.href="./api/download-backup"):J==="update"?I():J==="updatedev"?ee():J==="updatecheck"?xe():J==="shelly-sys-update"?Se():J==="shelly-main-update"?U():J==="shelly-create-system-log"?M():J==="shelly-download-system-log"?k():J==="softreset"?N():J==="hardreset"?ae():J==="restart"?w():J==="shutdown"?g():J==="reboot"?d():J==="create-backup"?n({id:S.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):J==="unregister"?n({id:S.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):J==="reset"?n({id:S.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):J==="factoryreset"&&n({id:S.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=J=>{a&&console.log("Header: handleMenuCloseCancel:",J),O(null)},me=J=>{$(J.currentTarget)},ne=()=>{$(null)},be=J=>{Y(J.currentTarget)},se=()=>{Y(null)},ge=J=>{x(J.currentTarget)},K=()=>{x(null)},ue=J=>{D(J.currentTarget)},ve=()=>{D(null)},Ge=()=>{Un(),a&&console.log("Matterbridge logo clicked: debug is now",a)};return r.useEffect(()=>{const J=ie=>{ie.src==="Matterbridge"&&ie.dst==="Frontend"&&(ie.id===S.current&&ie.method==="/api/settings"&&(a&&console.log("Header received settings:",ie.response),V(ie.response),C(ie.response.matterbridgeInformation.restartRequired||ie.response.matterbridgeInformation.fixedRestartRequired),v(ie.response.matterbridgeInformation.fixedRestartRequired),R(ie.response.matterbridgeInformation.updateRequired)),ie.method==="refresh_required"&&(ie.params.changed===null||ie.params.changed==="matterbridgeLatestVersion"||ie.params.changed==="matterbridgeAdvertise"||ie.params.changed==="fabrics")&&(a&&console.log(`Header received refresh_required: changed=${ie.params.changed}`),n({id:S.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ie.method==="restart_required"&&(a&&console.log(`Header received restart_required with fixed: ${ie.params.fixed}`),C(!0),ie.params.fixed===!0&&v(!0)),ie.method==="restart_not_required"&&(a&&console.log("Header received restart_not_required"),C(!1)),ie.method==="update_required"&&(a&&console.log("Header received update_required"),R(!0)),ie.method==="update_required_dev"&&(a&&console.log("Header received update_required_dev"),T(!0)),ie.id===Me.ShellySysUpdate&&(a&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),V(Fe=>({...Fe,matterbridgeInformation:{...Fe.matterbridgeInformation,shellySysUpdate:ie.params.available}}))),ie.id===Me.ShellyMainUpdate&&(a&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),V(Fe=>({...Fe,matterbridgeInformation:{...Fe.matterbridgeInformation,shellyMainUpdate:ie.params.available}}))))};return h(J),a&&console.log(`Header added WebSocket listener id ${S.current}`),()=>{b(J),a&&console.log("Header removed WebSocket listener")}},[h,b,n,o]),r.useEffect(()=>{i&&(a&&console.log("Header sending /api/settings requests"),n({id:S.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),a&&console.log("Header rendering..."),!i||!p?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ge}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(st,{to:"/",className:"nav-link",children:"Home"}),e.jsx(st,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(st,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(st,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!p.matterbridgeInformation.readOnly&&W&&e.jsx(H,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:I,children:["Update to v.",p.matterbridgeInformation.matterbridgeLatestVersion]})}),!p.matterbridgeInformation.readOnly&&y&&e.jsx(H,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:ee,children:["Update to new dev v.",p.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:j,children:["v.",p.matterbridgeInformation.matterbridgeVersion]})}),p.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.xxxmatterbridgeVersion&&e.jsx(H,{title:"Matterbridge version",children:e.jsxs("span",{style:{fontSize:"12px",color:"var(--main-icon-color)"},onClick:j,children:["v.",p.matterbridgeInformation.matterbridgeVersion]})}),p.matterbridgeInformation.bridgeMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.bridgeMode})}):null,p.matterbridgeInformation.restartMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.restartMode})}):null,p.matterbridgeInformation.profile&&p.matterbridgeInformation.profile!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:m})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Give a star to Matterbridge",children:e.jsx(z,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:_,children:e.jsx(Cr,{})})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Sponsor Matterbridge",children:e.jsx(z,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:X,children:e.jsx(Yt,{})})}):null,e.jsx(H,{title:"Matterbridge help",children:e.jsx(z,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:he,children:e.jsx(Sr,{})})}),e.jsx(H,{title:"Matterbridge changelog",children:e.jsx(z,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:j,children:e.jsx(Xt,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Update matterbridge to latest version",children:e.jsx(z,{style:{color:W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:I,children:e.jsx($e,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsx(H,{title:"Shelly system update",children:e.jsx(z,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Se,children:e.jsx($e,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsx(H,{title:"Shelly software update",children:e.jsx(z,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx($e,{})})}),e.jsx(H,{title:"Restart matterbridge",children:e.jsx(z,{style:{color:u||L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:w,children:e.jsx(vt,{})})}),p.matterbridgeInformation.restartMode===""?e.jsx(H,{title:"Shut down matterbridge",children:e.jsx(z,{style:{color:u||L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:g,children:e.jsx(ze,{})})}):null,e.jsx(H,{title:"Download, backup and more",children:e.jsx(z,{onClick:le,children:e.jsx(wr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(tt,{id:"command-menu",anchorEl:F,keepMounted:!0,open:!!F,onClose:()=>q(""),children:[p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>q("update"),children:[e.jsx(Q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>q("updatedev"),children:[e.jsx(Q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>q("updatecheck"),children:[e.jsx(Q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsxs(P,{onClick:()=>q("shelly-sys-update"),children:[e.jsx(Q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsxs(P,{onClick:()=>q("shelly-main-update"),children:[e.jsx(Q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>q("restart"),children:[e.jsx(Q,{children:e.jsx(vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation.restartMode===""?e.jsxs(P,{onClick:()=>q("shutdown"),children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",q,ce)},children:[e.jsx(Q,{children:e.jsx(vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:be,children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-view",anchorEl:B,keepMounted:!0,open:!!B,onClose:se,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{q("view-mblog"),se()},children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("view-mjlog"),se()},children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{q("view-shellylog"),se()},children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:ge,children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-download",anchorEl:l,keepMounted:!0,open:!!l,onClose:K,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{q("download-mbstorage"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-pluginstorage"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-pluginconfig"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-mblog"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-mjstorage"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-mjlog"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{q("shelly-create-system-log"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{q("shelly-download-system-log"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:me,children:[e.jsx(Q,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-backup",anchorEl:E,keepMounted:!0,open:!!E,onClose:ne,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{q("create-backup"),ne()},children:[e.jsx(Q,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-backup"),ne()},children:[e.jsx(Q,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:ue,children:[e.jsx(Q,{children:e.jsx(Mr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-reset",anchorEl:f,keepMounted:!0,open:!!f,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{ve(),c("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",q,ce)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{ve(),c("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",q,ce)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>{ve(),c("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",q,ce)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{ve(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",q,ce)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{ve(),c("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",q,ce)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const qo=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(a&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(a&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Bo(){const{messages:o,autoScroll:c}=r.useContext(or),[i,n]=r.useState(!1),s=r.useRef(null),h=r.useMemo(()=>qo(),[]),b=u=>n(!0),t=u=>n(!1);return r.useEffect(()=>{a&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${i}`),c&&!i&&!h&&s.current?.scrollIntoView({behavior:"smooth"})},[o,i,c,h]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:b,onMouseLeave:t,children:[o.map((u,C)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:u}},C)),e.jsx("div",{ref:s})]})})}const nr=r.memo(Bo);function Je(){const{retry:o}=r.useContext(fe),c=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:o<100?e.jsxs(e.Fragment,{children:[e.jsx(kr,{style:{color:"var(--primary-color)"}}),e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:["Reconnecting to Matterbridge ","(attempt "+o+")","..."]})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:["Unable to connect to Matterbridge after multiple attempts.",e.jsx("br",{}),"Please check your network connection.",e.jsx("br",{}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Jo({value:o,maxChars:c}){let i=o;if(o.length>c&&c>3){const n=c-3,s=o.substring(0,Math.ceil(n/2)),h=o.substring(o.length-Math.floor(n/2),o.length);i=`${s} … ${h}`}return o!==i?e.jsx(H,{title:o,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:i})}):e.jsx("span",{children:i})}function Go({systemInfo:o,compact:c}){const[i,n]=r.useState(o),{sendMessage:s,addListener:h,removeListener:b}=r.useContext(fe);if(a&&console.log("SystemInfoTable:",i,"compact:",c),o&&c&&i.totalMemory&&i.freeMemory){const t=i.totalMemory,u=i.freeMemory;i.freeMemory=`${u} / ${t}`,i.totalMemory=""}if(o&&c&&i.heapTotal&&i.heapUsed){const t=i.heapTotal,u=i.heapUsed;i.heapUsed=`${u} / ${t}`,i.heapTotal=""}if(o&&c&&i.osRelease&&i.osType){const t=i.osType,u=i.osRelease;i.osType=`${t} (${u})`,i.osRelease=""}if(o&&c&&i.osArch&&i.osPlatform){const t=i.osPlatform,u=i.osArch;i.osPlatform=`${t} (${u})`,i.osArch=""}return r.useEffect(()=>{const t=u=>{u.src==="Matterbridge"&&u.dst==="Frontend"&&(u.method==="memory_update"&&u.params&&u.params.totalMemory&&u.params.freeMemory&&u.params.heapTotal&&u.params.heapUsed&&u.params.rss&&(a&&console.log("SystemInfoTable received memory_update",u),(i.totalMemory!==u.params?.totalMemory||i.freeMemory!==u.params?.freeMemory||i.heapTotal!==u.params?.heapTotal||i.heapUsed!==u.params?.heapUsed||i.rss!==u.params?.rss)&&n(C=>({...C,totalMemory:u.params?.totalMemory?u.params.totalMemory:"",freeMemory:u.params?.freeMemory?u.params.freeMemory:"",heapTotal:u.params?.heapTotal?u.params.heapTotal:"",heapUsed:u.params?.heapUsed?u.params.heapUsed:"",rss:u.params?.rss?u.params.rss:""}))),u.method==="cpu_update"&&u.params&&u.params.cpuUsage&&(a&&console.log("SystemInfoTable received cpu_update",u),i.cpuUsage!==(u.params?.cpuUsage?u.params.cpuUsage.toFixed(2)+" %":"")&&n(C=>({...C,cpuUsage:u.params?.cpuUsage?u.params.cpuUsage.toFixed(2)+" %":""}))),u.method==="uptime_update"&&u.params&&u.params.systemUptime&&u.params.processUptime&&(a&&console.log("SystemInfoTable received uptime_update",u),(i.systemUptime!==u.params?.systemUptime||i.processUptime!==u.params?.processUptime)&&n(C=>({...C,systemUptime:u.params?.systemUptime?u.params.systemUptime:"",processUptime:u.params?.processUptime?u.params.processUptime:""}))))};return a&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),h(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),b(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[h,i.cpuUsage,i.freeMemory,i.heapTotal,i.heapUsed,i.processUptime,i.rss,i.systemUptime,i.totalMemory,b,s]),i?(a&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(i).filter(([t,u])=>u!==void 0&&u!=="").map(([t,u],C)=>e.jsxs("tr",{className:C%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:t}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Jo,{value:typeof u!="string"?u.toString():u,maxChars:25})})]},t))})})})]})):null}const Qo=r.memo(Go),qt={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"}},Ko=o=>{if(!o)return"";const c=o.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const i=c.slice(0,4),n=c.slice(4,7),s=c.slice(7,11);return[i,n,s].filter(Boolean).join("-")};function Yo({id:o}){const{online:c,sendMessage:i,addListener:n,removeListener:s}=r.useContext(fe),[h,b]=r.useState(null),[t,u]=r.useState(null),C=r.useRef(null);r.useEffect(()=>{a&&console.log(`QRDiv received storeId update "${o}"`),o&&(a&&console.log(`QRDiv sending data request for storeId "${o}"`),b(o),i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:o,server:!0}}))},[o]),r.useEffect(()=>{const T=p=>{p.src==="Matterbridge"&&p.dst==="Frontend"&&p.method==="refresh_required"&&p.params.changed==="matter"&&p.params.matter&&(a&&console.log(`QRDiv received refresh_required/matter for storeId "${p.params.matter.id}":`,p.params.matter),h===p.params.matter.id&&(a&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${p.params.matter.id}":`,p.params.matter),clearTimeout(C.current),p.params.matter.advertising&&p.params.matter.advertiseTime&&p.params.matter.advertiseTime+9e5<=Date.now()&&(p.params.matter.advertising=!1),u(p.params.matter),p.params.matter.advertising&&(a&&console.log(`QRDiv setting matter advertise timeout for storeId "${p.params.matter.id}":`,p.params.matter.advertiseTime+9e5-Date.now()),C.current=setTimeout(()=>{clearTimeout(C.current),a&&console.log(`QRDiv clearing advertising state for storeId "${p.params.matter.id}" after 15 minutes`),u(V=>({...V,advertising:!1}))},p.params.matter.advertiseTime+9e5-Date.now()))))};return n(T),a&&console.log("QRDiv webSocket effect mounted"),()=>{s(T),clearTimeout(C.current),a&&console.log("QRDiv webSocket effect unmounted")}},[h]);const L=()=>{a&&console.log(`QRDiv sent matter startCommission for node "${t.id}"`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,startCommission:!0}})},v=()=>{a&&console.log(`QRDiv sent matter stopCommission for node "${t.id}"`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,stopCommission:!0}})},W=()=>{a&&console.log(`QRDiv sent matter advertise for node "${t.id}"`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,advertise:!0}})},R=T=>{a&&console.log(`QRDiv sent matter removeFabric for node "${t.id}" and fabricIndex ${T}`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,removeFabric:T}})},y=async()=>{if(!t||!t.manualPairingCode)return;const T=t.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(T);else{const p=document.createElement("textarea");p.value=T,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.focus(),p.select(),document.execCommand("copy"),document.body.removeChild(p)}a&&console.log("Manual pairing code copied to clipboard")}catch(p){console.error("Failed to copy manual pairing code",p)}};return!t||!c?(a&&console.log("QRDiv rendering undefined state"),null):t.advertising&&t.qrPairingCode&&t.manualPairingCode?(a&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(z,{"aria-label":"send advertising",size:"small",onClick:W,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:_t,size:"22px"})})}),e.jsx(z,{"aria-label":"stop pairing",size:"small",onClick:v,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn off pairing",arrow:!0,children:e.jsx(te,{path:po,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:h}),e.jsx(co,{value:t.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Ko(t.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(H,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(z,{"aria-label":"copy manual pairing code",size:"small",onClick:y,sx:qt,children:e.jsx(te,{path:uo,size:.85})})})})]})]})):t.commissioned&&t.fabricInformations&&t.sessionInformations?(a&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(z,{"aria-label":"send advertising",size:"small",onClick:W,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:_t,size:"22px"})})}),e.jsx(z,{"aria-label":"start pairing",size:"small",onClick:L,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn on pairing",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:h}),t.fabricInformations.map((T,p)=>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: ",T.fabricIndex]}),e.jsx(H,{title:"Remove the fabric. You will need to remove it also from the controller.",arrow:!0,children:e.jsx(z,{"aria-label":"remove the fabric",size:"small",onClick:()=>R(T.fabricIndex),sx:{...qt,padding:"2px"},children:e.jsx(te,{path:mo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",T.rootVendorId," ",T.rootVendorName]}),T.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",T.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",t.sessionInformations?t.sessionInformations.filter(V=>V.fabric.fabricIndex===T.fabricIndex&&V.isPeerActive===!0).length:"0"," ","subscriptions: ",t.sessionInformations?t.sessionInformations.filter(V=>V.fabric.fabricIndex===T.fabricIndex&&V.isPeerActive===!0&&V.numberOfActiveSubscriptions>0).length:"0"]})]},p))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",t.serialNumber]})})]})):!t.commissioned&&!t.advertising?(a&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:h}),e.jsx(oe,{onClick:L,endIcon:e.jsx(te,{path:At,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("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",t.serialNumber]})})]})):(a&&console.log("QRDiv rendering unknown state"),null)}const Xo=r.memo(Yo);function Zo(){const{logMessage:o,sendMessage:c,getUniqueId:i}=r.useContext(fe),[n,s]=r.useState("matterbridge-"),[h,b]=r.useState(!1),[t,u]=r.useState(null),C=r.useRef(i()),L=F=>{F.preventDefault(),b(!0)},v=()=>{b(!1)},W=F=>{F.preventDefault(),b(!1);const O=F.dataTransfer.files[0];if(O){o("Plugins",`Installing package ${O.name}. Please wait...`);const E=new FormData;E.append("file",O),E.append("filename",O.name),fetch("./api/uploadpackage",{method:"POST",body:E}).then($=>$.text()).then($=>{o("Plugins",`Server response: ${$}`)}).catch($=>{console.error("Error uploading plugin file:",$),o("Plugins",`Error installing package ${$}`)})}},R=F=>{const O=F.target.files&&F.target.files[0];if(O){o("Plugins",`Uploading package ${O.name}`);const E=new FormData;E.append("file",O),E.append("filename",O.name),fetch("./api/uploadpackage",{method:"POST",body:E}).then($=>$.text()).then($=>{o("Plugins",`Server response: ${$}`)}).catch($=>{console.error("Error uploading plugin file:",$),o("Plugins",`Error uploading package ${$}`)})}},y=()=>{c({id:C.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},T=()=>{document.getElementById("file-upload")?.click()},p=()=>{c({id:C.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},V=F=>{u(F.currentTarget)},S=F=>{F!==""&&s(F),u(null)};return a&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:L,onDragLeave:v,onDrop:W,children:[e.jsx(pe,{value:n,onChange:F=>{s(F.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(z,{onClick:V,children:e.jsx(Ir,{})}),e.jsxs(tt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>S(""),children:[e.jsx(P,{onClick:()=>S("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(P,{onClick:()=>S("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(P,{onClick:()=>S("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(P,{onClick:()=>S("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(P,{onClick:()=>S("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(P,{onClick:()=>S("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(P,{onClick:()=>S("matterbridge-test"),children:"matterbridge-test"}),e.jsx(P,{onClick:()=>S("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(P,{onClick:()=>S("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(H,{title:"Install or update a plugin from npm",children:e.jsx(oe,{onClick:y,endIcon:e.jsx(Re,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(H,{title:"Upload and install a plugin from a tarball",children:e.jsx(oe,{onClick:T,endIcon:e.jsx(Dr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(H,{title:"Add an installed plugin",children:e.jsx(oe,{onClick:p,endIcon:e.jsx(yt,{}),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:R})]})}function Xe({status:o,enabledText:c="Enabled",disabledText:i=void 0,tooltipText:n=void 0,onClick:s}){if(o===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const h=e.jsx("div",{className:o?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:o?c:i??c});return n!==void 0?e.jsx(H,{title:n,children:h}):h}}const Ze={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},et={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},en={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},tn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ve={padding:"0px",margin:"0px"},rn="5px 10px 5px 10px",ht={},je={},xt={},ft={};let bt=[],Bt=[];const on=({open:o,onClose:c,plugin:i})=>{const{sendMessage:n,addListener:s,removeListener:h,getUniqueId:b}=r.useContext(fe),t=r.useRef(b()),[u,C]=r.useState(i.configJson),[L,v]=r.useState(i.schemaJson),[W,R]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[y,T]=r.useState("");let p={};r.useEffect(()=>{const M=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(k.id===t.current&&k.method==="/api/select/devices"&&(k.response&&(bt=k.response),k.error&&console.error("ConfigPluginDialog received /api/select/devices error:",k.error)),k.id===t.current&&k.method==="/api/select/entities"&&(k.response&&(Bt=k.response),k.error&&console.error("ConfigPluginDialog received /api/select/entities error:",k.error)))};return s(M),u!==void 0&&L!==void 0&&(Object.keys(L.properties).forEach(k=>{Object.keys(L.properties[k]).forEach(w=>{w.startsWith("ui:")&&(W[k]={},W[k][w]=L.properties[k][w],delete L.properties[k][w])})}),R(W)),i.name!==void 0&&i.configJson!==void 0&&i.schemaJson!==void 0&&(C(i.configJson),v(i.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name}})),()=>{h(M)}},[s,u,i,h,L,n,W]);const V=({formData:M})=>{p=M},S=({formData:M})=>{C(M),i.configJson=M,i.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:M.name,formData:M}}),c()};function F(M){const{id:k,label:w,onKeyChange:g,onDropPropertyClick:d,disabled:N,schema:ae,children:le,registry:q,readonly:ce,required:me}=M,{templates:ne}=q,{RemoveButton:be}=ne.ButtonTemplates;if(!($o in ae))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const ge=({target:K})=>g(K&&K.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${k}-key`,name:`${k}-key`,required:me,disabled:N||ce,defaultValue:w,onBlur:ce?void 0:ge,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:le}),e.jsx(be,{disabled:N||ce,onClick:d(w)})]})}function O(M){const{children:k,description:w,displayLabel:g,errors:d,help:N,hidden:ae,_id:le,_label:q,registry:ce,uiSchema:me}=M,ne=Vo(me),be=Eo("WrapIfAdditionalTemplate",ce,ne);return ae?e.jsx("div",{style:{display:"none"},children:k}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(be,{...M,children:[g===!0&&w,k,d,N]})})}function E(M){const{description:k}=M;return k?e.jsx(de,{sx:et,children:k}):null}function $(M){const{required:k,title:w}=M;return w?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(de,{sx:Ze,children:["Title ",w," ",k&&e.jsx("mark",{children:"***"})]})}):null}function B(M){const{help:k,_idSchema:w}=M;return k?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(de,{sx:en,children:k})}):null}function Y(M){const{errors:k}=M;return k?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(de,{color:"error",sx:tn,children:"Please fix the following errors:"}),e.jsx(nt,{children:k.map((w,g)=>e.jsxs(Nr,{children:[e.jsx(Q,{children:e.jsx(Pr,{color:"error"})}),e.jsx(re,{primary:w.stack})]},g))})]}):null}function l(M){const{errors:k}=M;return k?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((w,g)=>e.jsxs(de,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",w]},g))}):null}function x(M){const{id:k,name:w,_schema:g,_uiSchema:d,value:N,options:ae,label:le,type:q,placeholder:ce,required:me,disabled:ne,readonly:be,autofocus:se,onChange:ge,onChangeOverride:K,onBlur:ue,onFocus:ve,_rawErrors:Ge,_hideError:J,_registry:ie,_formContext:Fe}=M,Le=({target:{value:ye}})=>ge(ye===""?ae.emptyValue:ye),He=({target:ye})=>ue(k,ye&&ye.value),Ue=({target:ye})=>ve(k,ye&&ye.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:k,name:k,label:ce&&ce!==""?le:void 0,variant:"outlined",placeholder:ce&&ce!==""?ce:le,required:me,disabled:ne||be,autoFocus:se,value:N||N===0?N:"",type:q,autoComplete:q==="password"?"current-password":w,onChange:K||Le,onBlur:He,onFocus:Ue,fullWidth:!0})})}function f(M){return console.log("ArrayFieldTitleTemplate:",M),null}function D(M){return console.log("ArrayFieldDescriptionTemplate:",M),null}function X(M){return console.log("ArrayFieldItemTemplate:",M),null}function he(M){const{canAdd:k,_className:w,_disabled:g,_formContext:d,_formData:N,_idSchema:ae,_items:le,onAddClick:q,_rawErrors:ce,_readonly:me,_registry:ne,_required:be,schema:se,title:ge,_uiSchema:K}=M,[ue,ve]=r.useState(!1),[Ge,J]=r.useState(!1),[ie,Fe]=r.useState(!1),[Le,He]=r.useState(""),Ue=A=>{He(A.target.value)},ye=()=>{ve(!ue)},Qe=()=>{J(!Ge)},Ke=()=>{Fe(!ie)},wt=A=>{ve(!1),se.selectFrom==="serial"?se.items.default=A.serial:se.selectFrom==="name"&&(se.items.default=A.name),q()},Mt=A=>{J(!1),se.selectEntityFrom==="name"?se.items.default=A.name:se.selectEntityFrom==="description"&&(se.items.default=A.description),q()},kt=A=>{Fe(!1),se.selectDeviceEntityFrom==="name"?se.items.default=A.name:se.selectDeviceEntityFrom==="description"&&(se.items.default=A.description),q()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ge&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ge&&e.jsx(de,{sx:Ze,children:ge}),k&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[se.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(z,{onClick:ye,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),se.selectEntityFrom&&e.jsx(H,{title:"Add an entity from the list",children:e.jsx(z,{onClick:Qe,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),se.selectDeviceEntityFrom&&e.jsx(H,{title:"Add a device entity from the list",children:e.jsx(z,{onClick:Ke,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(z,{onClick:q,size:"small",color:"primary",sx:Ve,children:e.jsx(yt,{})})})]})]}),se.description&&e.jsx(de,{sx:et,children:se.description}),M.items.map(A=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(z,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ve,children:e.jsx(Ht,{})}),e.jsx(z,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ve,children:e.jsx(Lt,{})}),e.jsx(z,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ve,children:e.jsx(Ct,{})})]},A.index)),e.jsxs(Ie,{open:ue,onClose:ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(De,{children:"Select a device"}),e.jsxs(Ne,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Le,onChange:Ue,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:bt.filter(A=>A.serial.toLowerCase().includes(Le.toLowerCase())||A.name.toLowerCase().includes(Le.toLowerCase())).map((A,we)=>e.jsxs(pt,{onClick:()=>wt(A),sx:ht,children:[A.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),A.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),A.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},we))})]}),e.jsx(Pe,{children:e.jsx(oe,{onClick:ye,children:"Close"})})]}),e.jsxs(Ie,{open:Ge,onClose:Qe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(De,{children:"Select an entity"}),e.jsxs(Ne,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Le,onChange:Ue,placeholder:"Enter name or description"})]}),e.jsx(nt,{dense:!0,children:Bt.filter(A=>A.name.toLowerCase().includes(Le.toLowerCase())||A.description.toLowerCase().includes(Le.toLowerCase())).map((A,we)=>e.jsxs(pt,{onClick:()=>Mt(A),sx:ht,children:[A.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),A.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),A.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),A.icon==="component"&&e.jsx(Q,{children:e.jsx(Rt,{style:je})}),A.icon==="matter"&&e.jsx(Q,{children:e.jsx(Ot,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},we))})]}),e.jsx(Pe,{children:e.jsx(oe,{onClick:Qe,children:"Close"})})]}),e.jsxs(Ie,{open:ie,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(De,{children:["Select an entity for ",ge]}),e.jsx(Ne,{children:e.jsx(nt,{dense:!0,children:bt.filter(A=>A.serial===ge||A.name===ge).map(A=>A.entities?.map((we,It)=>e.jsxs(pt,{onClick:()=>kt(we),sx:ht,children:[we.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),we.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),we.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),we.icon==="component"&&e.jsx(Q,{children:e.jsx(Rt,{style:je})}),we.icon==="matter"&&e.jsx(Q,{children:e.jsx(Ot,{style:je})}),e.jsx(re,{primary:we.name,secondary:we.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},It)))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:Ke,children:"Close"})})]})]})}function j(M){const{onAddClick:k,schema:w,properties:g,title:d,description:N}=M,[ae,le]=r.useState(!1),[q,ce]=r.useState(""),me=K=>{ce(K.target.value)},ne=()=>{le(!ae)},be=K=>{le(!1);let ue="";w.selectFrom==="serial"?ue=K.serial:w.selectFrom==="name"&&(ue=K.name),T(ue),k(w)()},se=()=>{k(w)()},ge=!w.additionalProperties;return!ge&&y!==""&&g.forEach(K=>{if(K.name==="newKey"&&K.content.key==="newKey"&&K.content.props.name==="newKey"&&K.content.props.onKeyChange&&y!==""){const ue=y;T(""),K.content.props.onKeyChange(ue)}}),e.jsxs(Z,{sx:{margin:"0px",padding:ge?"10px":"5px 10px 0px 10px",border:ge?"none":"1px solid grey"},children:[w.title&&ge&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(de,{sx:Ze,children:w.title})}),d&&!ge&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(de,{sx:Ze,children:d}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[w.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(z,{onClick:ne,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(z,{onClick:se,size:"small",color:"primary",sx:Ve,children:e.jsx(yt,{})})})]})]}),w.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(de,{sx:et,children:w.description})}),g.map(({content:K,name:ue,hidden:ve})=>!ve&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(w.properties[ue].type)?"0px":rn,border:["object","array","boolean"].includes(w.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(w.properties[ue].type)&&e.jsx(de,{sx:Ze,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:K})]},ue)),e.jsxs(Ie,{open:ae,onClose:ne,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(De,{children:"Select a device"}),e.jsxs(Ne,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:q,onChange:me,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:bt.filter(K=>K.serial.toLowerCase().includes(q.toLowerCase())||K.name.toLowerCase().includes(q.toLowerCase())).map((K,ue)=>e.jsxs(pt,{onClick:()=>be(K),sx:ht,children:[K.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),K.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),K.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),e.jsx(re,{primary:K.name,secondary:K.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},ue))})]}),e.jsx(Pe,{children:e.jsx(oe,{onClick:ne,children:"Close"})})]})]})}function m(M){const{uiSchema:k}=M,{submitText:w,norender:g}=Oo(k);return g?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(oe,{type:"submit",variant:"contained",color:"primary",children:w}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function _(M){const{className:k,disabled:w,onClick:g,registry:d,style:N,uiSchema:ae,...le}=M;return e.jsx(H,{title:"Remove the item",children:e.jsx(z,{disabled:w,size:"small",color:"primary",onClick:g,children:e.jsx(Ct,{})})})}function I(M){const{className:k,disabled:w,onClick:g,registry:d,uiSchema:N,...ae}=M;return e.jsx(H,{title:"Add an item",children:e.jsx(z,{size:"small",color:"primary",onClick:g,children:e.jsx(yt,{})})})}function ee(M){const{disabled:k,onClick:w,registry:g,style:d,uiSchema:N,...ae}=M;return e.jsx(H,{title:"Move up the item",children:e.jsx(z,{size:"small",color:"primary",onClick:w,children:e.jsx(Ht,{})})})}function xe(M){const{disabled:k,onClick:w,registry:g,style:d,uiSchema:N,...ae}=M;return e.jsx(H,{title:"Move down the item",children:e.jsx(z,{size:"small",color:"primary",onClick:w,children:e.jsx(Lt,{})})})}function Se(M){const{id:k,name:w,value:g,schema:d,readonly:N,onChange:ae}=M,[le,q]=r.useState(void 0),ce=ne=>{q(ne&&ne!==""?ne:void 0)},me=()=>{n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name,action:w,value:le,formData:p,id:k}}),d.buttonClose===!0?c():d.buttonSave===!0&&S({formData:u})};return d.buttonText&&d.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(de,{sx:et,children:d.description}),e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>me(),children:d.buttonText})]}):d.buttonField&&d.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(de,{sx:et,children:d.description}),e.jsx(pe,{id:w+"-input",name:w,label:d.textLabel,placeholder:d.textPlaceholder,onChange:ne=>ce(ne.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(oe,{id:w+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>me(),children:d.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[w&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(de,{sx:Ze,children:w}),e.jsx(We,{checked:g,readOnly:N,onChange:()=>ae(!g),sx:{padding:"0px",margin:"0px"}})]}),d.description&&e.jsx(de,{sx:et,children:d.description})]})}function U({schema:M,id:k,name:w,options:g,label:d,hideLabel:N,required:ae,disabled:le,placeholder:q,readonly:ce,value:me,multiple:ne,autofocus:be,onChange:se,onBlur:ge,onFocus:K,errorSchema:ue,rawErrors:ve=[],registry:Ge,uiSchema:J,hideError:ie,formContext:Fe,...Le}){const{enumOptions:He,enumDisabled:Ue,emptyValue:ye}=g;ne=typeof ne>"u"?!1:!!ne;const Qe=ne?[]:"",Ke=typeof me>"u"||ne&&me.length<1||!ne&&me===Qe,wt=({target:{value:Oe}})=>se(Nt(Oe,He,ye)),Mt=({target:Oe})=>ge(k,Nt(Oe&&Oe.value,He,ye)),kt=({target:Oe})=>K(k,Nt(Oe&&Oe.value,He,ye)),A=Ho(me,He,ne),{InputLabelProps:we,SelectProps:It,autocomplete:dr,...cr}=Le,pr=!ne&&M.default===void 0;return e.jsxs(pe,{id:k,name:k,value:!Ke&&typeof A<"u"?A:Qe,required:ae,disabled:le||ce,autoFocus:be,autoComplete:dr,placeholder:q,error:ve.length>0,onChange:wt,onBlur:Mt,onFocus:kt,...cr,select:!0,InputLabelProps:{...we,shrink:!Ke},SelectProps:{...It,multiple:ne},"aria-describedby":Ro(k),children:[pr&&e.jsx(P,{value:"",children:q}),Array.isArray(He)&&He.map(({value:Oe,label:ur},Ft)=>{const mr=Array.isArray(Ue)&&Ue.indexOf(Oe)!==-1;return e.jsx(P,{value:String(Ft),disabled:mr,children:ur},Ft)})]})}return!o||!L||!u?null:e.jsxs(Ie,{open:o,onClose:c,maxWidth:"800px",children:[e.jsx(De,{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(Ne,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Fo,{schema:L,formData:u,uiSchema:W,validator:Lo,templates:{FieldTemplate:O,BaseInputTemplate:x,TitleFieldTemplate:$,DescriptionFieldTemplate:E,FieldHelpTemplate:B,FieldErrorTemplate:l,ErrorListTemplate:Y,WrapIfAdditionalTemplate:F,ArrayFieldTitleTemplate:f,ArrayFieldDescriptionTemplate:D,ArrayFieldItemTemplate:X,ArrayFieldTemplate:he,ObjectFieldTemplate:j,ButtonTemplates:{SubmitButton:m,RemoveButton:_,AddButton:I,MoveUpButton:ee,MoveDownButton:xe}},widgets:{CheckboxWidget:Se,SelectWidget:U},onChange:V,onSubmit:S})})]})};function nn({data:o,columns:c,columnVisibility:i}){const n=Ee.useMemo(()=>c.filter(C=>i[C.accessor]),[c,i]),{getTableProps:s,getTableBodyProps:h,headerGroups:b,rows:t,prepareRow:u}=Ae.useTable({columns:n,data:o},Ae.useSortBy);return e.jsxs("table",{...s(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:b.map(C=>e.jsx("tr",{...C.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:C.headers.map(L=>e.jsx("th",{...L.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:L.render("Header")}))}))}),e.jsx("tbody",{...h(),style:{border:"none",borderCollapse:"collapse"},children:t.map((C,L)=>(u(C),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...C.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:C.cells.map(v=>e.jsx("td",{...v.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:v.render("Cell")}))},L)))})]})}function an({_storeId:o,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:h,getUniqueId:b}=r.useContext(fe),{showConfirmCancelDialog:t}=r.useContext(ot),u=r.useRef(b()),[C,L]=r.useState(null),[v,W]=r.useState(null),[R,y]=r.useState([]),[T,p]=r.useState(!1),[V,S]=r.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),F=d=>{if(d===void 0||d.matter===void 0||!d.matter.fabricInformations&&!d.matter.qrPairingCode&&!d.matter.manualPairingCode)return"red";if(d.matter.commissioned===!1&&d.matter.qrPairingCode&&d.matter.manualPairingCode)return"var(--primary-color)";var N=0,ae=0;for(const le of d.matter.sessionInformations??[])le.fabric&&le.isPeerActive===!0&&N++,le.numberOfActiveSubscriptions>0&&(ae+=le.numberOfActiveSubscriptions);return d.matter.commissioned===!0&&d.matter.fabricInformations&&d.matter.sessionInformations&&(N===0||ae===0)?"var(--secondary-color)":"var(--div-text-color)"},O=[{Header:"Name",accessor:"name",Cell:({row:d})=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>m(d.original),children:d.original.name})})},{Header:"Description",accessor:"description",Cell:({row:d})=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>m(d.original),children:d.original.description})})},{Header:"Version",accessor:"version",Cell:({row:d})=>e.jsxs(e.Fragment,{children:[d.original.latestVersion!==void 0&&d.original.latestVersion!==d.original.version&&v&&!v.readOnly&&e.jsx(H,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>f(d.original),children:["Update to v.",d.original.latestVersion]})}),d.original.version.includes("-dev-")&&d.original.devVersion!==void 0&&d.original.devVersion!==d.original.version&&v&&!v.readOnly&&e.jsx(H,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>D(d.original),children:["Update to new dev v.",d.original.devVersion.split("-dev-")[0]]})}),e.jsx(H,{title:"Plugin version",children:d.original.version})]})},{Header:"Author",accessor:"author",Cell:({row:d})=>e.jsx(e.Fragment,{children:d.original.author?d.original.author.replace("https://github.com/",""):"Unknown"})},{Header:"Type",accessor:"type",Cell:({row:d})=>e.jsx(e.Fragment,{children:d.original.type?d.original.type.replace("Platform",""):"Unknown"})},{Header:"Devices",accessor:"registeredDevices"},{Header:"Actions",accessor:"actions",Cell:({row:d})=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[v&&v.bridgeMode==="childbridge"&&!d.original.error&&d.original.enabled&&e.jsx(H,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:F(d.original)},onClick:()=>c(d.original?.matter?.id),size:"small",children:e.jsx(Zt,{})})}),v&&v.bridgeMode==="childbridge"&&!d.original.error&&d.original.enabled&&e.jsx(H,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>he(d.original),size:"small",children:e.jsx(vt,{})})}),e.jsx(H,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{disabled:d.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>k(d.original),size:"small",children:e.jsx(Be,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{Y("Remove plugin","Are you sure? This will remove also all the devices and configuration in the controller.","remove",d.original)},size:"small",children:e.jsx(Ct,{})})}),d.original.enabled?e.jsx(H,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{Y("Disable plugin","Are you sure? This will remove also all the devices and configuration in the controller.","disable",d.original)},size:"small",children:e.jsx(Tr,{})})}):e.jsx(e.Fragment,{}),d.original.enabled?e.jsx(e.Fragment,{}):e.jsx(H,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>j(d.original),size:"small",children:e.jsx(Wr,{})})}),e.jsx(H,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(d.original),size:"small",children:e.jsx(Fr,{})})}),e.jsx(H,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ee(d.original),size:"small",children:e.jsx(Lr,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>_(d.original),size:"small",children:e.jsx(Yt,{})})})]})},{Header:"Status",accessor:"status",Cell:({row:d})=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",gap:"5px"},children:d.original.error?e.jsx(e.Fragment,{children:e.jsx(Xe,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:d.original.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Xe,{status:d.original.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:d.original.loaded&&d.original.started&&d.original.configured?e.jsx(e.Fragment,{children:e.jsx(Xe,{status:d.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{status:d.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Xe,{status:d.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Xe,{status:d.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const d=N=>{N.src==="Matterbridge"&&N.dst==="Frontend"&&(N.method==="refresh_required"&&(N.params.changed==="plugins"||N.params.changed==="fabrics"||N.params.changed==="sessions"||N.params.changed==="pluginsRestart")&&(a&&console.log("HomePlugins received refresh_required for",N.params.changed),n({id:u.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),N.method==="refresh_required"&&N.params.changed==="settings"&&(a&&console.log("HomePlugins received refresh_required for",N.params.changed),n({id:u.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),N.id===u.current&&N.method==="/api/settings"&&(a&&console.log(`HomePlugins (id: ${N.id}) received settings:`,N.response),L(N.response.systemInformation),W(N.response.matterbridgeInformation)),N.id===u.current&&N.method==="/api/plugins"&&(a&&console.log(`HomePlugins (id: ${N.id}) received ${N.response.length} plugins:`,N.response),y(N.response)))};return s(d),a&&console.log("HomePlugins added WebSocket listener id:",u.current),()=>{h(d),a&&console.log("HomePlugins removed WebSocket listener")}},[s,h,n]),r.useEffect(()=>{i&&(a&&console.log("HomePlugins sending api requests"),n({id:u.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:u.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),r.useEffect(()=>{const d=localStorage.getItem("homePluginsColumnVisibility");d&&S(JSON.parse(d))},[]);const E=()=>{p(!T)},$=d=>{S(N=>{const ae={...N,[d]:!N[d]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(ae)),ae})},B=r.useRef(null),Y=(d,N,ae,le)=>{a&&console.log(`handleActionWithConfirmCancel ${ae} ${le.name}`),B.current=le,t(d,N,ae,l,x)},l=d=>{a&&console.log(`handleConfirm action confirmed ${d} ${B.current.name}`),d==="remove"&&B.current?X(B.current):d==="disable"&&B.current&&j(B.current),B.current=null},x=d=>{a&&console.log(`handleCancel action canceled ${d} ${B.current.name}`),B.current=null},f=d=>{a&&console.log("handleUpdatePlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name,restart:!1}})},D=d=>{a&&console.log("handleUpdateDevPlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name+"@dev",restart:!1}})},X=d=>{a&&console.log("handleRemovePlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},he=d=>{a&&console.log("handleRestartPlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},j=d=>{a&&console.log("handleEnableDisablePlugin plugin:",d.name,"enabled:",d.enabled),d.enabled===!0?(d.enabled=!1,n({id:u.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})):(d.enabled=!0,n({id:u.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}}))},m=d=>{a&&console.log(`handleHomepagePlugin plugin: ${d.name} homepage: ${d.homepage}`),d.homepage&&window.open(d.homepage,"_blank")},_=d=>{a&&console.log("handleSponsorPlugin plugin:",d.name,"funding:",d.funding),d.funding&&window.open(d.funding,"_blank")},I=d=>{a&&console.log("handleHelpPlugin plugin:",d.name,"help:",d.help),d.help&&window.open(d.help,"_blank")},ee=d=>{a&&console.log("handleChangelogPlugin plugin:",d.name,"changelog:",d.changelog),d.changelog&&window.open(d.changelog,"_blank")},[xe,Se]=r.useState({}),[U,M]=r.useState(!1),k=d=>{a&&console.log("handleConfigPlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),n({id:u.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),Se(d),w()},w=()=>{M(!0)},g=()=>{M(!1)};return a&&console.log("HomePlugins rendering..."),i?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[e.jsx(on,{open:U,onClose:g,plugin:xe}),e.jsxs(Ie,{open:T,onClose:E,children:[e.jsx(De,{children:"Configure Plugins Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:O.map(d=>e.jsx(Te,{control:e.jsx(We,{disabled:["description","actions","status"].includes(d.accessor),checked:V[d.accessor],onChange:()=>$(d.accessor)}),label:d.Header},d.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:E,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Plugins"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(z,{onClick:E,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(nn,{data:R,columns:O,columnVisibility:V})})]}):e.jsx(Je,{})}const sn=o=>{if(o===void 0||!o.qrPairingCode&&!o.manualPairingCode&&!o.fabricInformations&&!o.sessionInformations)return"red";if(o.commissioned===!1&&o.qrPairingCode&&o.manualPairingCode)return"var(--primary-color)";var c=0,i=0;for(const n of o.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&c++,n.numberOfActiveSubscriptions>0&&(i+=n.numberOfActiveSubscriptions);return o.commissioned===!0&&o.fabricInformations&&o.sessionInformations&&(c===0||i===0)?"var(--secondary-color)":"var(--div-text-color)"},ln=o=>`${o.pluginName}::${o.serial}`;function dn({data:o,columns:c,columnVisibility:i}){const n=Ee.useMemo(()=>{const v=localStorage.getItem("homeDevicesColumnsSortBy");return v?JSON.parse(v):[{id:"name",desc:!1}]},[c]),s=Ee.useMemo(()=>c.filter(v=>i[v.accessor]),[i,c]),{getTableProps:h,getTableBodyProps:b,headerGroups:t,rows:u,prepareRow:C,state:{sortBy:L}}=Ae.useTable({columns:s,data:o,getRowId:ln,initialState:{sortBy:n}},Ae.useSortBy);return Ee.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(L))},[L]),e.jsxs("table",{...h(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:t.map(v=>e.jsx("tr",{...v.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:v.headers.map(W=>e.jsxs("th",{...W.getHeaderProps(W.noSort?void 0:W.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:W.noSort?"default":"pointer"},children:[W.render("Header"),!W.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:W.isSorted?W.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Wt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...b(),style:{border:"none",borderCollapse:"collapse"},children:u.map((v,W)=>(C(v),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...v.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:v.cells.map(R=>e.jsx("td",{...R.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:R.render("Cell")}))})))})]})}function cn({storeId:o,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:h,getUniqueId:b}=r.useContext(fe),[t,u]=r.useState(!1),[C,L]=r.useState(!0),[v,W]=r.useState(null),[R,y]=r.useState([]),[T,p]=r.useState([]),[V,S]=r.useState([]),[F,O]=r.useState([]),[E,$]=r.useState(!1),[B,Y]=r.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),l=r.useRef(b()),x=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:j})=>j.original.reachable===!0?"Online":j.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(j,m)=>{const _=j.original.reachable===!0?1:j.original.reachable===!1?0:-1,I=m.original.reachable===!0?1:m.original.reachable===!1?0:-1;return _-I}},{Header:"Power",accessor:"powerSource",Cell:({row:j})=>j.original.powerSource==="ac"||j.original.powerSource==="dc"?e.jsx(er,{fontSize:"small",sx:{color:"var(--primary-color)"}}):j.original.powerSource==="ok"?e.jsx(jt,{fontSize:"small",sx:{color:"green"}}):j.original.powerSource==="warning"?e.jsx(jt,{fontSize:"small",sx:{color:"yellow"}}):j.original.powerSource==="critical"?e.jsx(jt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:j})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[j.original.matter!==void 0?e.jsx(H,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{onClick:()=>c(o===j.original.matter.id?v.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:j.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:sn(j.original.matter)},children:e.jsx(Zt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),j.original.configUrl?e.jsx(H,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{onClick:()=>window.open(j.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Be,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),j.original.selected!==void 0?e.jsx(H,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(We,{checked:j.original.selected,onChange:m=>he(m,j.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],f=Ee.useCallback(j=>{j.selected=void 0;const m=R.find(ee=>ee.name===j.pluginName);if(!m)return console.error(`HomeDevices isSelected: plugin ${j.pluginName} not found for device ${j.deviceName} `),j.selected;const _=m.schemaJson?.properties?.whiteList?.selectFrom;let I=m.configJson?.postfix;return I===""&&(I=void 0),m.hasWhiteList===!0&&m.hasBlackList===!0&&_&&(j.selected=!0,_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(I?j.serial.replace("-"+I,""):j.serial)&&(j.selected=!0),_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(I?j.serial.replace("-"+I,""):j.serial)&&(j.selected=!1),_==="serial"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(I?j.serial.replace("-"+I,""):j.serial)&&(j.selected=!1),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(j.name)&&(j.selected=!0),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(j.name)&&(j.selected=!1),_==="name"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(j.name)&&(j.selected=!1)),j.selected},[R]);r.useEffect(()=>{const j=m=>{if(m.src==="Matterbridge"&&m.dst==="Frontend"){if(m.method==="refresh_required"&&m.params.changed!=="matter"&&m.params.changed!=="pluginsRestart"&&m.params.changed!=="sessions"&&m.params.changed!=="matterbridgeLatestVersion"&&m.params.changed!=="reachability"&&(console.log(`HomeDevices received refresh_required: changed=${m.params.changed} > requesting /api/plugins`),n({id:l.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),m.method==="restart_required"&&(a&&console.log("HomeDevices received restart_required"),u(!0)),m.method==="restart_not_required"&&(a&&console.log("HomeDevices received restart_not_required"),u(!1)),m.method==="state_update"&&m.params.plugin&&m.params.serialNumber&&m.params.cluster.includes("BasicInformationServer")&&m.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${m.params.plugin} serial ${m.params.serialNumber} value ${m.params.value}`),p(_=>_.map(I=>I.pluginName===m.params.plugin&&I.serial===m.params.serialNumber?{...I,reachable:m.params.value}:I))),m.id===l.current&&m.method==="/api/settings"&&(a&&console.log(`HomeDevices (id: ${m.id}) received settings:`,m.response),W(m.response),u(m.response.matterbridgeInformation.restartRequired)),m.id===l.current&&m.method==="/api/plugins"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} plugins:`,m.response),m.response)){let _=!0;for(const I of m.response)I.enabled===!0&&(I.loaded!==!0||I.started!==!0||I.error===!0)&&(_=!1);if(!_)return;a&&console.log("HomeDevices reset plugins, devices and selectDevices"),L(!1),y(m.response),p([]),S([]),n({id:l.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),a&&console.log("HomeDevices sent /api/devices");for(const I of m.response)I.enabled===!0&&I.loaded===!0&&I.started===!0&&I.error!==!0&&(n({id:l.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:I.name}}),a&&console.log(`HomeDevices sent /api/select/devices for plugin: ${I.name}`))}if(m.id===l.current&&m.method==="/api/devices"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} devices:`,m.response),m.response)){for(const _ of m.response)_.selected=f(_);p(m.response)}m.id===l.current&&m.method==="/api/select/devices"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} selectDevices for plugin ${m.response&&m.response.length>0?m.response[0].pluginName:"no select devices"}:`,m.response),m.response&&m.response.length>0&&S(_=>{const I=_.filter(xe=>xe.pluginName!==m.response[0].pluginName),ee=m.response.map(xe=>({...xe,selected:f(xe)}));return[...I,...ee]}))}};return s(j),a&&console.log(`HomeDevices added WebSocket listener id ${l.current}`),()=>{h(j),a&&console.log("HomeDevices removed WebSocket listener")}},[R,s,h,n,f]),r.useEffect(()=>{if(T.length===0&&V.length===0)return;console.log(`HomeDevices mixing devices (${T.length}) and selectDevices (${V.length})`);const j=[];for(const m of T)j.push(m);for(const m of V)T.find(_=>_.pluginName===m.pluginName&&_.serial.includes(m.serial))||j.push(m);j.length>0&&(O(j),console.log(`HomeDevices mixed ${j.length} devices and selectDevices`))},[R,T,V,O]),r.useEffect(()=>{i&&(a&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:l.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:l.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),r.useEffect(()=>{const j=localStorage.getItem("homeDevicesColumnVisibility");if(j){const m=JSON.parse(j);m.powerSource===void 0&&(m.powerSource=!0),Y(m),a&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const D=j=>{Y(m=>{const _={...m,[j]:!m[j]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(_)),a&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(_),_),_})},X=()=>{$(!E)},he=(j,m)=>{console.log(`handleCheckboxChange: checkbox changed to ${j.target.checked} for device ${m.name} serial ${m.serial}`),O(_=>{const I=_.findIndex(xe=>xe.pluginName===m.pluginName&&xe.serial===m.serial);if(I<0)return console.error(`handleCheckboxChange: device not found ${m.name} serial ${m.serial} id ${m.id}`),_;const ee=[..._];return ee[I]={...ee[I],selected:j.target.checked},ee}),j.target.checked?n({id:l.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}}):n({id:l.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}})};return a&&console.log("HomeDevices rendering..."),i?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs(Ie,{open:E,onClose:X,children:[e.jsx(De,{children:"Configure Devices Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:x.map(j=>e.jsx(Te,{control:e.jsx(We,{disabled:["name","actions"].includes(j.accessor),checked:B[j.accessor],onChange:()=>D(j.accessor)}),label:j.Header},j.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:X,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(z,{onClick:X,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(dn,{data:F,columns:x,columnVisibility:B})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[C&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!C&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",T.length.toString(),"/",F.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Je,{})}function pn(){const[o,c]=r.useState(null),[i,n]=r.useState(null),[s,h]=r.useState([]),[b]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,u]=r.useState(localStorage.getItem("homePageMode")??"devices"),[C,L]=r.useState(""),[v,W]=r.useState(!1),[R,y]=r.useState(!1),[T,p]=r.useState(null),{addListener:V,removeListener:S,online:F,sendMessage:O,logFilterLevel:E,logFilterSearch:$,autoScroll:B,getUniqueId:Y}=r.useContext(fe),l=r.useRef(Y());return r.useEffect(()=>{const x=f=>{f.src==="Matterbridge"&&f.dst==="Frontend"&&(f.method==="refresh_required"&&f.params.changed!=="matterbridgeLatestVersion"&&f.params.changed!=="reachability"&&(a&&console.log(`Home received refresh_required: changed=${f.params.changed}`),O({id:l.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),f.id===l.current&&f.method==="/api/settings"&&(a&&console.log("Home received settings:",f.response),c(f.response.systemInformation),n(f.response.matterbridgeInformation),f.response.matterbridgeInformation.bridgeMode==="bridge"&&(T||p(f.response.matterbridgeInformation.matter.id)),f.response.matterbridgeInformation.bridgeMode==="childbridge"&&s.length>0&&T===null&&(T||p(s[0].matter.id)),f.response.matterbridgeInformation.matterbridgeVersion&&L(`https://github.com/Luligu/matterbridge/blob/${f.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null?localStorage.setItem("frontendVersion",f.response.matterbridgeInformation.frontendVersion):f.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&(localStorage.setItem("frontendVersion",f.response.matterbridgeInformation.frontendVersion),y(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",f.response.matterbridgeInformation.matterbridgeVersion):f.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",f.response.matterbridgeInformation.matterbridgeVersion),W(!0)),f.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),u("devices")))),f.id===l.current&&f.method==="/api/plugins"&&(a&&console.log(`Home received plugins (${i?.bridgeMode}):`,f.response),h(f.response),i?.bridgeMode==="childbridge"&&f.response.length>0&&(T||p(f.response[0].matter.id))))};return V(x),a&&console.log(`Home added WebSocket listener id ${l.current}`),()=>{S(x),a&&console.log("Home removed WebSocket listener")}},[V,S,O,i,s,T]),r.useEffect(()=>{F&&(a&&console.log("Home received online"),O({id:l.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),O({id:l.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[F,O]),a&&console.log("Home rendering..."),!F||!o||!i?e.jsx(Je,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Xo,{id:T}),e.jsx(Qo,{systemInfo:o,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[R&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},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(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx(Hr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),v&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(oe,{onClick:()=>window.open(C,"_blank"),endIcon:e.jsx(Xt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx(Rr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),b&&!i.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(Zo,{})]}),b&&e.jsx(an,{storeId:T,setStoreId:p}),t==="devices"&&e.jsx(cn,{storeId:T,setStoreId:p}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',E,'" and search "',$,'" Scroll: ',B?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(nr,{})})]})]})]})}const Jt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},un={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},mn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Gt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},gn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},hn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},xn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},fn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},bn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Pt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},vn=[256,257,268,269],yn=[266,267],jn=[259,260,261,271,272],Cn=[256,257,268,269,266,267,259,260,261];function G({icon:o,iconColor:c,cluster:i,value:n,unit:s,prefix:h}){return a&&console.log(`Render cluster "${i.clusterName}.${i.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${s}"`),h=h??!1,e.jsxs(Z,{sx:Jt,children:[o&&Ee.cloneElement(o,{key:`${i.clusterId}-${i.attributeId}-icon`,sx:{...un,color:c??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Jt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&h===!0&&e.jsx(de,{sx:Gt,children:s},`${i.clusterId}-${i.attributeId}-unit`),e.jsx(de,{sx:mn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${i.clusterId}-${i.attributeId}-value`),s&&h===!1&&e.jsx(de,{sx:Gt,children:s},`${i.clusterId}-${i.attributeId}-unit`)]},`${i.clusterId}-${i.attributeId}-valueunitbox`)]},`${i.clusterId}-${i.attributeId}-box`)}function Sn({device:o,endpoint:c,id:i,deviceType:n,clusters:s}){const h=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let b="";return a&&console.log(`Device "${o.name}" endpoint "${c}" id "${i}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${s?.length}):`,s),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>b=`${t.attributeLocalValue} mV`),Cn.includes(n)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>b=`Level ${t.attributeValue}`),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>b=`Position ${t.attributeValue/100}%`),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>b=`Heat ${t.attributeValue/100}°C `),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>b=b+`Cool ${t.attributeValue/100}°C`),n===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>b=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>b=`${t.attributeLocalValue/1e3} V, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>b=b+`${t.attributeLocalValue/1e3} A, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>b=b+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[n===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:t.attributeLocalValue===!0?e.jsx(it,{}):e.jsx(Or,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(G,{icon:e.jsx(jt,{}),cluster:t,value:t.attributeValue/2,unit:"%"})),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(G,{icon:e.jsx(er,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),vn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),yn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:"Oven"})),n===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Er,{}),cluster:t,value:"Fridge"})),n===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(G,{icon:e.jsx(te,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Ut,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Ut,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(G,{icon:e.jsx($r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(te,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(G,{icon:t.attributeValue==="1"?e.jsx(_r,{}):e.jsx(Ar,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(G,{icon:e.jsx(te,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(G,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===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(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===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(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(G,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:h[t.attributeLocalValue??0]})),n===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(te,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:t.attributeValue==="true"?e.jsx(Zr,{}):e.jsx(eo,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(G,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(to,{}):e.jsx(ro,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(oo,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeValue/1e4)),unit:"lx"})),n===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(G,{icon:e.jsx(no,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:gn,children:e.jsx(de,{sx:hn,children:b})}),e.jsx(Z,{sx:xn,children:e.jsx(de,{sx:fn,children:o.name})}),e.jsxs(Z,{sx:bn,children:[a&&e.jsx(de,{sx:Pt,children:c}),e.jsx(de,{sx:Pt,children:i}),a&&e.jsxs(de,{sx:Pt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function wn({filter:o}){const{online:c,sendMessage:i,addListener:n,removeListener:s,getUniqueId:h}=r.useContext(fe),[b,t]=r.useState(!1),[u,C]=r.useState({}),[L,v]=r.useState([]),[W,R]=r.useState([]),[y,T]=r.useState({}),[p,V]=r.useState({}),[S,F]=r.useState({}),[O,E]=r.useState(W),$=r.useRef(h()),B=()=>{t(!b)};return r.useEffect(()=>{const Y=l=>{if(l.src==="Matterbridge"&&l.dst==="Frontend"){if(l.method==="refresh_required"&&(a&&console.log("DevicesIcons received refresh_required and sending api requests"),i({id:$.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),l.method==="/api/settings"&&l.response&&(a&&console.log("DevicesIcons received settings:",l.response),C(l.response)),l.method==="/api/plugins"&&l.response&&(a&&console.log("DevicesIcons received plugins:",l.response),v(l.response)),l.method==="/api/devices"&&l.response){a&&console.log(`DevicesIcons received ${l.response.length} devices:`,l.response),R(l.response);for(let x of l.response)a&&console.log("DevicesIcons sending /api/clusters"),i({id:$.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:x.pluginName,endpoint:x.endpoint}})}if(l.method==="/api/clusters"&&l.response){if(console.log(`DevicesIcons received for device "${l.response.deviceName}" serial "${l.response.serialNumber}" deviceType ${l.response.deviceTypes.join(" ")} clusters (${l.response.length}):`,l.response),l.response.length===0)return;const x=l.response.serialNumber;y[x]=[],p[x]=l.response.deviceTypes,S[x]=[];for(let f of l.response.clusters)y[x].find(D=>D.endpoint===f.endpoint)||y[x].push({endpoint:f.endpoint,id:f.id,deviceTypes:f.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(f.clusterName)&&S[x].push(f);T({...y}),V({...p}),F({...S}),a&&console.log(`DevicesIcons endpoints for "${x}":`,y[x]),a&&console.log(`DevicesIcons deviceTypes for "${x}":`,p[x]),a&&console.log(`DevicesIcons clusters for "${x}":`,S[x])}}};return n(Y),a&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{s(Y),a&&console.log("DevicesIcons useEffect webSocket unmounted")}},[n,s,i]),r.useEffect(()=>(a&&console.log("DevicesIcons useEffect online mounting"),c&&(a&&console.log("DevicesIcons useEffect online sending api requests"),i({id:$.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),a&&console.log("DevicesIcons useEffect online mounted"),()=>{a&&console.log("DevicesIcons useEffect online unmounted")}),[c,i]),r.useEffect(()=>{if(o===""){E(W);return}const Y=W.filter(l=>l.name.toLowerCase().includes(o)||l.serial.toLowerCase().includes(o));E(Y)},[W,o]),a&&console.log("DevicesIcons rendering..."),e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{open:b,onClose:B,PaperProps:{style:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--primary-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}},children:[e.jsx(De,{children:"Configure accessories"}),e.jsx(Ne,{}),e.jsx(Pe,{children:e.jsx(oe,{onClick:B,children:"Close"})})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:O.map(Y=>y[Y.serial]&&y[Y.serial].map(l=>l.deviceTypes.map(x=>e.jsx(Sn,{device:Y,endpoint:l.endpoint,id:l.id,deviceType:x,clusters:S[Y.serial].filter(f=>f.endpoint===l.endpoint)}))))})]})}const ir=[{Header:"Plugin name",accessor:"pluginName"},{Header:"Device type",accessor:"type"},{Header:"Endpoint",accessor:"endpoint"},{Header:"Name",accessor:"name"},{Header:"Serial number",accessor:"serial"},{Header:"Unique ID",accessor:"uniqueId"},{Header:"Url",accessor:"configUrl"},{Header:"Config",accessor:"configButton",noSort:!0,Cell:({row:o})=>o.original.configUrl?e.jsx(z,{onClick:()=>window.open(o.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Be,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],ar=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:o})=>Array.isArray(o)?o.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):o},{Header:"Cluster Name",accessor:"clusterName"},{Header:"Cluster ID",accessor:"clusterId"},{Header:"Attribute Name",accessor:"attributeName"},{Header:"Attribute ID",accessor:"attributeId"},{Header:"Attribute Value",accessor:"attributeValue",Cell:({value:o})=>e.jsx(H,{title:o,componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o})})}],Mn=o=>`${o.pluginName}::${o.uniqueId}`,kn=o=>`${o.endpoint}::${o.clusterName}::${o.attributeName}`;function In({data:o,columnVisibility:c,setPlugin:i,setEndpoint:n,setDeviceName:s}){const[h,b]=r.useState(null),t=Ee.useMemo(()=>ir.filter(y=>c[y.accessor]),[c]),{getTableProps:u,getTableBodyProps:C,headerGroups:L,rows:v,prepareRow:W}=Ae.useTable({columns:t,data:o,getRowId:Mn},Ae.useSortBy),R=y=>{if(y.id===h){b(null),i(null),n(null),s(null),a&&console.log("Device unclicked:",y.id,"selectedDeviceIndex:",h);return}b(y.id),i(y.original.pluginName),n(y.original.endpoint),s(y.original.name),a&&console.log("Device clicked:",y.id,"selectedDeviceIndex:",h,"pluginName:",y.original.pluginName,"endpoint:",y.original.endpoint)};return e.jsxs("table",{...u(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:L.map(y=>e.jsx("tr",{...y.getHeaderGroupProps(),children:y.headers.map(T=>e.jsxs("th",{...T.getHeaderProps(T.noSort?void 0:T.getSortByToggleProps()),children:[T.render("Header"),!T.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:T.isSorted?T.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Wt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...C(),children:v.map((y,T)=>(W(y),e.jsx("tr",{className:T%2===0?"table-content-even":"table-content-odd",...y.getRowProps(),onClick:()=>R(y),style:{backgroundColor:h===y.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:y.cells.map(p=>e.jsx("td",{...p.getCellProps(),children:p.render("Cell")}))})))})]})}function Dn({data:o,columnVisibility:c}){const i=Ee.useMemo(()=>ar.filter(u=>c[u.accessor]),[c]),{getTableProps:n,getTableBodyProps:s,headerGroups:h,rows:b,prepareRow:t}=Ae.useTable({columns:i,data:o,getRowId:kn},Ae.useSortBy);return e.jsxs("table",{...n(),style:{margin:"-1px"},children:[e.jsx("thead",{children:h.map(u=>e.jsx("tr",{...u.getHeaderGroupProps(),children:u.headers.map(C=>e.jsx("th",{...C.getHeaderProps(),children:C.render("Header")}))}))}),e.jsx("tbody",{...s(),children:b.map((u,C)=>(t(u),e.jsx("tr",{className:C%2===0?"table-content-even":"table-content-odd",...u.getRowProps(),children:u.cells.map(L=>e.jsx("td",{...L.getCellProps(),children:L.render("Cell")}))})))})]})}function Nn(){const{online:o,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=r.useContext(fe),[h,b]=r.useState([]),[t,u]=r.useState([]),[C,L]=r.useState(null),[v,W]=r.useState(null),[R,y]=r.useState(null),[T,p]=r.useState(0),[V,S]=r.useState(!1),[F,O]=r.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[E,$]=r.useState(!1),[B,Y]=r.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[l,x]=r.useState(""),[f,D]=r.useState(h),[X,he]=r.useState("icon"),j=r.useRef(s());r.useEffect(()=>{const U=M=>{if(a&&console.log("Devices received WebSocket Message:",M),M.src==="Matterbridge"&&M.dst==="Frontend"&&(M.method==="refresh_required"&&(a&&console.log("Devices received refresh_required"),c({id:j.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),M.method==="/api/devices"&&(a&&console.log(`Devices received ${M.response.length} devices:`,M.response),b(M.response)),M.method==="/api/clusters")){console.log(`Devices received ${M.response.length} clusters:`,M.response),u(M.response.clusters);const k={};for(const w of M.response.clusters)a&&console.log("Cluster:",w.endpoint),k[w.endpoint]?k[w.endpoint]++:k[w.endpoint]=1;p(Object.keys(k).length)}};return i(U),a&&console.log("Devices added WebSocket listener"),()=>{n(U),a&&console.log("Devices removed WebSocket listener")}},[i,n,c]),r.useEffect(()=>{o&&(a&&console.log("Devices sending api requests"),c({id:j.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:j.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:j.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[o,c]),r.useEffect(()=>{C&&v&&(a&&console.log("Devices sending /api/clusters"),c({id:j.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:C,endpoint:v}}))},[C,v,c]);const m=()=>{S(!V)},_=U=>{O(M=>{const k={...M,[U]:!M[U]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(k)),k})};r.useEffect(()=>{const U=localStorage.getItem("devicesColumnVisibility");U&&O(JSON.parse(U))},[]);const I=()=>{$(!E)},ee=U=>{Y(M=>{const k={...M,[U]:!M[U]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(k)),k})};r.useEffect(()=>{const U=localStorage.getItem("clustersColumnVisibility");U&&Y(JSON.parse(U))},[]);const xe=U=>{x(U.target.value.toLowerCase()),localStorage.setItem("devicesFilter",U.target.value.toLowerCase())},Se=U=>{he(U),localStorage.setItem("devicesViewMode",U)};return r.useEffect(()=>{if(l===""){D(h);return}const U=h.filter(M=>M.name.toLowerCase().includes(l)||M.serial.toLowerCase().includes(l));D(U)},[h,l]),r.useEffect(()=>{const U=localStorage.getItem("devicesFilter");U&&x(U)},[]),r.useEffect(()=>{const U=localStorage.getItem("devicesViewMode");U&&he(U)},[]),a&&console.log("Devices rendering..."),o?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(de,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:l,onChange:xe,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(de,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(z,{onClick:()=>Se("table"),"aria-label":"Table View",disabled:X==="table",children:e.jsx(H,{title:"Table View",children:e.jsx(io,{style:{color:X==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(z,{onClick:()=>Se("icon"),"aria-label":"Icon View",disabled:X==="icon",children:e.jsx(H,{title:"Icon View (beta)",children:e.jsx(ao,{style:{color:X==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(Ie,{open:V,onClose:m,children:[e.jsx(De,{children:"Configure Devices Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:ir.map(U=>e.jsx(Te,{control:e.jsx(We,{disabled:["pluginName","name","configButton"].includes(U.accessor),checked:F[U.accessor],onChange:()=>_(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:m,children:"Close"})})]}),X==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${C&&v?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Registered devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(z,{onClick:m,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(In,{data:f,columnVisibility:F,setPlugin:L,setEndpoint:W,setDeviceName:y})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total devices: ",f.length.toString()]})})]}),e.jsxs(Ie,{open:E,onClose:I,children:[e.jsx(De,{children:"Configure Clusters Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:ar.map(U=>e.jsx(Te,{control:e.jsx(We,{disabled:["clusterName","attributeName","attributeValue"].includes(U.accessor),checked:B[U.accessor],onChange:()=>ee(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:I,children:"Close"})})]}),X==="table"&&C&&v&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsxs("div",{className:"MbfWindowHeaderText",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[e.jsxs("p",{style:{margin:"0px",padding:"0px"},children:['Clusters for device "',R,'" on endpoint ',v]}),e.jsx(z,{onClick:I,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Dn,{data:t,columnVisibility:B})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total child endpoints: ",T-1]})})]}),X==="icon"&&e.jsx(wn,{filter:l,devices:f})]}):e.jsx(Je,{})}function Pn(){const[o,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[i,n]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[s,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:b,setLogFilters:t,online:u,setAutoScroll:C}=r.useContext(fe),L=y=>{c(y.target.value),t(y.target.value,i),localStorage.setItem("logFilterLevel",y.target.value),a&&console.log("handleChangeLevel called with value:",y.target.value)},v=y=>{n(y.target.value),t(o,y.target.value),localStorage.setItem("logFilterSearch",y.target.value),a&&console.log("handleChangeSearch called with value:",y.target.value)},W=y=>{h(y.target.checked),C(y.target.checked),localStorage.setItem("logAutoScroll",y.target.value?"true":"false"),a&&console.log("handleAutoScrollChange called with value:",y.target.checked)},R=()=>{a&&console.log("handleClearLogsClick called"),b([])};return a&&console.log("Logs rendering..."),u?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx($t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(rt,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:o,onChange:L,children:[e.jsx(P,{value:"debug",children:"Debug"}),e.jsx(P,{value:"info",children:"Info"}),e.jsx(P,{value:"notice",children:"Notice"}),e.jsx(P,{value:"warn",children:"Warn"}),e.jsx(P,{value:"error",children:"Error"}),e.jsx(P,{value:"fatal",children:"Fatal"})]}),e.jsx($t,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:i,onChange:v,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Te,{control:e.jsx(We,{checked:s,onChange:W}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(H,{title:"Clear the logs",children:e.jsx(oe,{onClick:R,endIcon:e.jsx(Ct,{}),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(nr,{})})]}):e.jsx(Je,{})}const Tn=({open:o,ip:c,onClose:i,onSave:n})=>{const s=c?c.split(".").slice(0,3).join(".")+".1":"",[h,b]=r.useState("dhcp"),[t,u]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:s,dns:s}),C=W=>R=>{u({...t,[W]:R.target.value})},L=()=>{i()},v=()=>{const W=h==="static"?{type:h,...t}:{type:h};n(W),i()};return e.jsxs(Ie,{open:o,onClose:(W,R)=>{R==="backdropClick"||R==="escapeKeyDown"||i()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(De,{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(Ne,{dividers:!0,children:[e.jsxs(tr,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(rr,{row:!0,value:h,onChange:W=>b(W.target.value),children:[e.jsx(Te,{value:"dhcp",control:e.jsx(St,{}),label:"DHCP"}),e.jsx(Te,{value:"static",control:e.jsx(St,{}),label:"Static"})]})]}),h==="static"&&e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:C("ip")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:C("subnet")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:C("gateway")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:C("dns")})})]})]}),e.jsxs(Pe,{children:[e.jsx(oe,{onClick:L,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,children:"Save"})]})]})},Wn=({open:o,onClose:c,onSave:i})=>{const[n,s]=r.useState(""),[h,b]=r.useState(""),t=R=>{s(R.target.value)},u=R=>{b(R.target.value)},C=n.length>0&&n===h,L=()=>{c()},v=()=>{C&&(i(n),c())},W=()=>{i(""),c()};return e.jsxs(Ie,{open:o,onClose:(R,y)=>{y==="backdropClick"||y==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(De,{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(Ne,{dividers:!0,children:e.jsx(tr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:n,onChange:t})}),e.jsx(_e,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:h,onChange:u,error:h!==""&&n!==h,helperText:h!==""&&n!==h?"Passwords do not match":""})})]})})}),e.jsxs(Pe,{children:[e.jsx(oe,{onClick:L,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,disabled:!C,children:"Change"}),e.jsx(oe,{variant:"contained",onClick:W,children:"Reset"})]})]})};function Fn(){const{online:o,addListener:c,removeListener:i,sendMessage:n,getUniqueId:s}=r.useContext(fe),[h,b]=r.useState(null),[t,u]=r.useState(null),C=r.useRef(s());return r.useEffect(()=>{const L=v=>{v.src==="Matterbridge"&&v.dst==="Frontend"&&(v.method==="refresh_required"&&(a&&console.log("Settings received refresh_required"),n({id:C.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),v.method==="/api/settings"&&(a&&console.log("Settings received /api/settings:",v.response),b(v.response.matterbridgeInformation),u(v.response.systemInformation)))};return c(L),a&&console.log("Settings added WebSocket listener"),()=>{i(L),a&&console.log("Settings removed WebSocket listener")}},[c,i,n]),r.useEffect(()=>{o&&(a&&console.log("Settings received online"),n({id:C.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[o,n]),h?(a&&console.log("Settings rendering..."),o?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Ln,{matterbridgeInfo:h,systemInfo:t}),e.jsx(Hn,{matterbridgeInfo:h}),e.jsx(Rn,{matterbridgeInfo:h})]})}):e.jsx(Je,{})):null}function Ln({matterbridgeInfo:o,systemInfo:c}){const{sendMessage:i,getUniqueId:n}=r.useContext(fe),[s,h]=r.useState("bridge"),[b,t]=r.useState("Info"),[u,C]=r.useState(!1),[L,v]=r.useState("dark"),[W,R]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[y,T]=r.useState(localStorage.getItem("homePageMode")??"logs"),[p,V]=r.useState(localStorage.getItem("virtualMode")??"outlet"),S=r.useRef(n()),[F,O]=r.useState(!1),E=()=>O(!1),$=I=>{a&&console.log("handleSaveNetConfig called with config:",I),i({id:S.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:I})},[B,Y]=r.useState(!1),l=()=>Y(!1),x=I=>{a&&console.log("handleSaveChangePassword called with password:",I),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:I}})};r.useEffect(()=>{o.bridgeMode!==void 0&&(h(o.bridgeMode==="bridge"?"bridge":"childbridge"),t(o.loggerLevel.charAt(0).toUpperCase()+o.loggerLevel.slice(1)),C(o.fileLogger),V(o.virtualMode))},[o]),r.useEffect(()=>{const I=localStorage.getItem("frontendTheme");I&&v(I)},[]);const f=I=>{a&&console.log("handleChangeBridgeMode called with value:",I.target.value),h(I.target.value),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:I.target.value}})},D=I=>{a&&console.log("handleChangeMbLoggerLevel called with value:",I.target.value),t(I.target.value),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:I.target.value}})},X=I=>{a&&console.log("handleLogOnFileMbChange called with value:",I.target.checked),C(I.target.checked),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:I.target.checked}})},he=I=>{const ee=I.target.value;a&&console.log("handleChangeTheme called with value:",ee),v(ee),localStorage.setItem("frontendTheme",ee),document.body.setAttribute("frontend-theme",ee)},j=I=>{const ee=I.target.checked;a&&console.log("handleChangeHomePagePlugins called with value:",ee),R(ee),localStorage.setItem("homePagePlugins",ee?"true":"false")},m=I=>{const ee=I.target.value;a&&console.log("handleChangeHomePageMode called with value:",ee),T(ee),localStorage.setItem("homePageMode",ee)},_=I=>{const ee=I.target.value;a&&console.log("handleChangeVirtualMode called with value:",ee),V(ee),localStorage.setItem("virtualMode",ee),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:ee}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Tn,{open:F,ip:c.ipv4Address,onClose:E,onSave:$}),e.jsx(Wn,{open:B,onClose:l,onSave:x}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(rr,{row:!0,name:"mode-buttons-group",value:s,onChange:f,children:[e.jsx(Te,{value:"bridge",control:e.jsx(St,{}),label:"Bridge",disabled:o.readOnly===!0}),e.jsx(Te,{value:"childbridge",control:e.jsx(St,{}),label:"Childbridge",disabled:o.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:b,onChange:D,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(We,{checked:u,onChange:X,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:L,onChange:he,children:[e.jsx(P,{value:"classic",children:"Classic"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(We,{checked:W,onChange:j,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:y,onChange:m,children:[e.jsx(P,{value:"logs",children:"Logs"}),e.jsx(P,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:p,onChange:_,children:[e.jsx(P,{value:"disabled",children:"Disabled"}),e.jsx(P,{value:"outlet",children:"Outlet"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"switch",children:"Switch"}),e.jsx(P,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>Y(!0),children:"Change password"})}),o.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>O(!0),children:"Configure IP"})})]})})]})}function Hn({matterbridgeInfo:o}){const{sendMessage:c,getUniqueId:i}=r.useContext(fe),[n,s]=r.useState("Info"),[h,b]=r.useState(!1),[t,u]=r.useState(""),[C,L]=r.useState(""),[v,W]=r.useState(""),[R,y]=r.useState(),[T,p]=r.useState(),[V,S]=r.useState(),F=r.useRef(i());r.useEffect(()=>{o.bridgeMode!==void 0&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][o.matterLoggerLevel]),b(o.matterFileLogger),u(o.mattermdnsinterface),L(o.matteripv4address),W(o.matteripv6address),y(o.matterPort),p(o.matterDiscriminator),S(o.matterPasscode))},[o]);const O=D=>{a&&console.log("handleChangeMjLoggerLevel called with value:",D.target.value),s(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:D.target.value}})},E=D=>{a&&console.log("handleLogOnFileMjChange called with value:",D.target.checked),b(D.target.checked),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:D.target.checked}})},$=D=>{a&&console.log("handleChangeMdnsInterface called with value:",D.target.value),u(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:D.target.value}})},B=D=>{a&&console.log("handleChangeIpv4Address called with value:",D.target.value),L(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:D.target.value}})},Y=D=>{a&&console.log("handleChangeIpv6Address called with value:",D.target.value),W(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:D.target.value}})},l=D=>{a&&console.log("handleChangeMatterPort called with value:",D.target.value),y(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:D.target.value}})},x=D=>{a&&console.log("handleChangeMatterDiscriminator called with value:",D.target.value),p(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:D.target.value}})},f=D=>{a&&console.log("handleChangemMatterPasscode called with value:",D.target.value),S(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:D.target.value}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:O,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(We,{checked:h,onChange:E,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,onChange:$,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:C,onChange:B,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:v,onChange:Y,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:R,onChange:l,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:T,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:V,onChange:f,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function Rn({matterbridgeInfo:o}){return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(qe,{value:o.matterbridgeVersion,label:"Current Version"}),e.jsx(qe,{value:o.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(qe,{value:o.homeDirectory,label:"Home Directory"}),e.jsx(qe,{value:o.rootDirectory,label:"Root Directory"}),e.jsx(qe,{value:o.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(qe,{value:o.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(qe,{value:o.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function qe({value:o,label:c}){return e.jsx(pe,{focused:!0,value:o,size:"small",label:c,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}function On(o,c,i){const n=o?.[i],s=c?.[i];return n==null&&s==null?0:n==null?-1:s==null?1:typeof n=="boolean"&&typeof s=="boolean"?n===s?0:n?1:-1:typeof n=="number"&&typeof s=="number"?n-s:String(n).localeCompare(String(s))}const Vn=r.memo(function({name:c,columns:i,rows:n,getRowKey:s,footerLeft:h,footerRight:b}){const t=r.useRef(new WeakMap),u=r.useRef(1),C=l=>{if(typeof s=="string"&&l&&l[s]!=null)return l[s];if(typeof s=="function"){const D=s(l);if(D!=null)return D}const x=i?.[0]?.id;if(x&&l&&l[x]!=null)return l[x];console.warn(`MbfTable(${c}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let f=t.current.get(l);return f||(f=`rk_${u.current++}`,t.current.set(l,f)),f},{_showConfirmCancelDialog:L}=r.useContext(ot),[v,W]=r.useState(localStorage.getItem(`${c}_table_order_by`)||null),[R,y]=r.useState(localStorage.getItem(`${c}_table_order`)||null),[T,p]=r.useState(!1),[V,S]=r.useState(()=>{try{const l=localStorage.getItem(`${c}_column_visibility`);if(l)return JSON.parse(l)}catch{}return{}}),F=r.useMemo(()=>{const l={};for(const x of i)x.hidden||(l[x.id]=x.required?!0:V[x.id]!==!1);return l},[i,V]),O=r.useMemo(()=>{if(!v||!R)return n;const l=i.find(f=>f.id===v);if(!l||l.nosort)return n;const x=n.map((f,D)=>({el:f,index:D}));return x.sort((f,D)=>{const X=On(f.el,D.el,v);return X!==0?R==="asc"?X:-X:f.index-D.index}),x.map(f=>f.el)},[n,v,R,i]),E=l=>{if(v!==l||!v){W(l),y("asc"),localStorage.setItem(`${c}_table_order_by`,l),localStorage.setItem(`${c}_table_order`,"asc");return}if(R==="asc"){y("desc"),localStorage.setItem(`${c}_table_order`,"desc");return}W(null),y(null),localStorage.removeItem(`${c}_table_order_by`),localStorage.removeItem(`${c}_table_order`)},$=()=>{p(!T)},B=l=>{S(x=>{const f=i.find(he=>he.id===l);if(f&&f.required)return x;const D=F[l]!==!1,X={...x};D?X[l]=!1:delete X[l];try{localStorage.setItem(`${c}_column_visibility`,JSON.stringify(X))}catch{}return X})},Y=()=>{const l={};S(l);try{localStorage.setItem(`${c}_column_visibility`,JSON.stringify(l))}catch{}};return console.log(`Rendering table ${c}${v&&R?` ordered by ${v}:${R}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Ie,{open:T,onClose:(l,x)=>{x==="backdropClick"||x==="escapeKeyDown"||$()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(De,{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 ${c} columns`})]})}),e.jsx(Ne,{children:e.jsx(at,{children:i.filter(l=>!l.hidden).map(l=>e.jsx(Te,{control:e.jsx(We,{disabled:!!l.required,checked:l.required?!0:F[l.id]!==!1,onChange:()=>B(l.id)}),label:l.label},l.id))})}),e.jsxs(Pe,{children:[e.jsx(oe,{onClick:Y,children:"Reset"}),e.jsx(oe,{variant:"contained",onClick:l=>{if(l?.currentTarget&&typeof l.currentTarget.blur=="function")try{l.currentTarget.blur()}catch{}const x=document.activeElement;if(x&&x instanceof HTMLElement&&typeof x.blur=="function")try{x.blur()}catch{}$()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:c}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(z,{onClick:l=>{if(l?.currentTarget?.blur)try{l.currentTarget.blur()}catch{}$()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:`Configure ${c} columns`,children:e.jsx(te,{path:Wo,size:"20px",style:{color:"var(--header-text-color)"}})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${c} 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:i.map(l=>{if(l.hidden||!l.required&&F[l.id]===!1)return null;const x=!l.nosort,f=x&&v===l.id&&!!R;return e.jsxs("th",{onClick:x?()=>E(l.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:l.minWidth,maxWidth:l.maxWidth,textAlign:l.align||"left",cursor:x?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:l.maxWidth?"nowrap":void 0,overflow:l.maxWidth?"hidden":void 0,textOverflow:l.maxWidth?"ellipsis":void 0},"aria-sort":x?f?R==="asc"?"ascending":"descending":"none":void 0,children:[l.label,f&&e.jsxs("span",{style:{marginLeft:6},children:[R==="asc"&&e.jsx(te,{path:Wt,size:"15px"}),R==="desc"&&e.jsx(te,{path:Tt,size:"15px"})]})]},l.id)})})}),e.jsx("tbody",{children:O.map((l,x)=>{const f=C(l);return e.jsx("tr",{className:x%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:i.map(D=>{if(D.hidden||!D.required&&F[D.id]===!1)return null;const X=l[D.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:D.align||"left",padding:"4px 8px",margin:"0",maxWidth:D.maxWidth,whiteSpace:D.maxWidth?"nowrap":void 0,overflow:D.maxWidth?"hidden":void 0,textOverflow:D.maxWidth?"ellipsis":void 0},children:typeof D.render=="function"?D.render(X,f,l,D):typeof X=="boolean"?e.jsx(We,{checked:X,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):D.format&&typeof X=="number"?D.format(X):X??""},D.id)})},f)})})]})}),e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:b})]})]})});function En(){const{online:o,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=r.useContext(fe),{showSnackbarMessage:h,closeSnackbarMessage:b}=r.useContext(ot),[t,u]=r.useState(null),[C,L]=r.useState([]),[v,W]=r.useState([]),[R,y]=r.useState([]),[T,p]=r.useState(null),[V,S]=r.useState(null),[F,O]=r.useState(null),E=r.useRef(null),[$,B]=r.useState(()=>sr);E.current||(E.current=s(),console.log("Test uniqueId:",E)),r.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const l=x=>{if(x.src==="Matterbridge"&&x.dst==="Frontend"){if(x.method==="restart_required"&&(console.log("Test received restart_required"),h("Restart required",0)),x.method==="refresh_required"&&(console.log("Test received refresh_required"),h("Refresh required",0),c({id:E.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:E.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:E.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),x.method==="memory_update"&&(console.log("Test received memory_update",x),S(x.params)),x.method==="cpu_update"&&(console.log("Test received cpu_update",x),p(x.params)),x.method==="uptime_update"&&(console.log("Test received uptime_update",x),O(x.params)),x.method==="/api/settings"&&x.response&&(console.log("Test received /api/settings:",x.response),h("Test received /api/settings"),u(x.response)),x.method==="/api/plugins"&&x.response&&(console.log(`Test received ${x.response.length} plugins:`,x.response),h("Test received /api/plugins"),L(x.response)),x.method==="/api/devices"&&x.response){console.log(`Test received ${x.response.length} devices:`,x.response),h("Test received /api/devices"),W(x.response);for(let f of x.response)console.log("Test sending /api/clusters for device:",f.pluginName,f.name,f.endpoint),c({method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:f.pluginName,endpoint:f.endpoint}})}x.method==="/api/clusters"&&(console.log(`Test received ${x.response.length} clusters for device ${x.deviceName} endpoint ${x.endpoint}:`,x),h("Test received /api/clusters"),y(x.response))}else console.log("Test received WebSocketMessage:",x.method,x.src,x.dst,x.response)};return i(l),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(l),console.log("Test useEffect WebSocketMessage unmounted")}},[i,n,c,h]),r.useEffect(()=>(console.log("Test useEffect online mounting"),o&&(console.log("Test useEffect online received online"),c({method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[o,c,h]);const Y=r.useCallback(l=>l.code,[]);return console.log("Test rendering..."),o?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},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("div",{style:{margin:"0",padding:"0",gap:"0",width:"1200px",maxWidth:"1200px",height:"600px",maxHeight:"600px",overflow:"hidden",border:"1px solid #0004ffff"},children:e.jsx(Vn,{name:"Test",columns:$n,rows:$,getRowKey:Y,footerLeft:"Left Footer",footerRight:"Right Footer"})}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>{console.log("Test button clicked"),h("Test button clicked"),b("Refresh required"),b("Restart required"),b("Test permanent message removal")},children:"Test"}),e.jsx(oe,{variant:"outlined",onClick:()=>{B(l=>{const x=l.findIndex(he=>he.code==="F123");if(x===-1)return l;const f=l[x],D={...f,population:(f.population||0)+1},X=l.slice();return X[x]=D,X})},children:"Update F123"})]})]})}):e.jsx(Je,{})}const $n=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(o,c)=>e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",borderRadius:"8px",backgroundColor:"var(--chip-bg, #e6f4ff)",color:"var(--chip-fg, #0550ae)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"0.85em"},children:String(o)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:o=>o.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:o=>o.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:o=>o.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(o,c,i)=>i.isIsland?"🏝️":"🏞️"}];function Ce(o,c,i,n,s){const h=i/n;return{name:o,code:c,population:i,size:n,density:h,isIsland:s}}const sr=[Ce("India","IN",1324171354,3287263,!1),Ce("China","CN",1403500365,9596961,!1),Ce("Italy","IT",60483973,301340,!1),Ce("United States","US",327167434,9833520,!1),Ce("Canada is a truly wonderful country","CA",37602103,9984670,!1),Ce("Australia","AU",25475400,7692024,!0),Ce("Germany","DE",83019200,357578,!1),Ce("Ireland","IE",4857e3,70273,!0),Ce("Mexico","MX",126577691,1972550,!1),Ce("Japan","JP",126317e3,377973,!0),Ce("France","FR",67022e3,640679,!1),Ce("United Kingdom","GB",67545757,242495,!0),Ce("Russia","RU",146793744,17098246,!1),Ce("Nigeria","NG",200962417,923768,!1),Ce("Brazil","BR",210147125,8515767,!1)],Qt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Kt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let o=0;o<2e3;o++){const c=`${Qt[o%Qt.length]}${Kt[o%Kt.length]} ${o}`,i=`F${o.toString().padStart(3,"0")}`,n=Math.floor(Math.random()*1e9),s=Math.floor(Math.random()*1e7),h=Math.random()<.2;sr.push(Ce(c,i,n,s,h))}function _n(o,c){a&&console.log("getCssVariable:",o,"defaultValue",c);const i=getComputedStyle(document.body).getPropertyValue(o).trim();return i||console.error("getCssVariable: undefined",i),i||c}function An(o){return so({palette:{primary:{main:o},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)"}}}}})}let a=!1;const Un=()=>{a=!a},lr=r.createContext(void 0);function zn({children:o}){const[c,i]=r.useState(!1),[n,s]=r.useState(""),h=async b=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:b})});if(t.ok){const{valid:u}=await t.json();u?i(!0):b!==""&&s("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(lr.Provider,{value:{loggedIn:c,logIn:h,errorMessage:n},children:o})}function qn(){const[o,c]=r.useState(""),i=r.useContext(lr),[n,s]=r.useState("#1976d2");if(!i)throw new Error("AuthContext not found");const{loggedIn:h,logIn:b,errorMessage:t}=i,u=y=>{y.preventDefault(),b(o)},C={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},L={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)"},v={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)"};r.useEffect(()=>{a&&console.log("Setting frontend theme");const y=localStorage.getItem("frontendTheme");a&&console.log("Saved theme:",y),y?document.body.setAttribute("frontend-theme",y):document.body.setAttribute("frontend-theme","dark");const T=_n("--primary-color","#1976d2");a&&console.log("Primary color from CSS:",T),s(T)},[]);const W=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";console.log(`Loading App.js with href="${window.location.href}" and pathname="${window.location.pathname}" >>> baseName="${W}"`);const R=An(n);return b(""),h?e.jsx(lo,{theme:R,children:e.jsx(vr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ao,{children:e.jsx(Uo,{children:e.jsx(gr,{basename:W,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(zo,{}),e.jsxs(hr,{children:[e.jsx(Ye,{path:"/",element:e.jsx(pn,{})}),e.jsx(Ye,{path:"/devices",element:e.jsx(Nn,{})}),e.jsx(Ye,{path:"/log",element:e.jsx(Pn,{})}),e.jsx(Ye,{path:"/settings",element:e.jsx(Fn,{})}),e.jsx(Ye,{path:"/test",element:e.jsx(En,{})}),e.jsx(Ye,{path:"*",element:e.jsx(xr,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:C,children:e.jsxs("form",{onSubmit:u,style:L,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:"64px",width:"64px"}}),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:o,onChange:y=>c(y.target.value),style:v,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:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function Bn(){return e.jsx(zn,{children:e.jsx(qn,{})})}fr.createRoot(document.getElementById("root")).render(e.jsx(Ee.StrictMode,{children:e.jsx(Bn,{})}));
|
|
23
|
+
*/var Se=(r=>(r[r.Log=0]="Log",r[r.RefreshRequired=1]="RefreshRequired",r[r.RestartRequired=2]="RestartRequired",r[r.RestartNotRequired=3]="RestartNotRequired",r[r.CpuUpdate=4]="CpuUpdate",r[r.MemoryUpdate=5]="MemoryUpdate",r[r.UptimeUpdate=6]="UptimeUpdate",r[r.Snackbar=7]="Snackbar",r[r.UpdateRequired=8]="UpdateRequired",r[r.StateUpdate=9]="StateUpdate",r[r.CloseSnackbar=10]="CloseSnackbar",r[r.ShellySysUpdate=100]="ShellySysUpdate",r[r.ShellyMainUpdate=101]="ShellyMainUpdate",r))(Se||{});function Ie(r){return r.id>=0&&r.id<=101}function Be(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function Uo({open:r,title:c,message:i,onConfirm:n,onCancel:s}){const f=t=>{a&&console.log("Confirmed"),t.preventDefault(),n()},y=t=>{a&&console.log("Canceled"),t.preventDefault(),s()};return e.jsxs(De,{open:r,children:[e.jsx(Ne,{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:c})]})}),e.jsxs(Pe,{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:i})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(oe,{onClick:f,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(oe,{onClick:y,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ht=[],nt=o.createContext(null);function zo({children:r}){const{enqueueSnackbar:c,closeSnackbar:i}=yr(),n=o.useCallback(j=>{a&&console.log(`UiProvider closeSnackbarMessage: message ${j}`);const P=ht.findIndex(O=>O.message===j);P!==-1&&(i(ht[P].key),ht.splice(P,1),a&&console.log(`UiProvider closeSnackbarMessage: message ${j} removed from persistMessages`))},[i]),s=o.useCallback((j,P,O)=>{a&&console.log(`UiProvider showSnackbarMessage: message ${j} timeout ${P}`);const z=c(j,{variant:"default",autoHideDuration:P==null||P>0?(P??5)*1e3:null,persist:P===0,content:x=>e.jsx(X,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Cr,{severity:O??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>i(x),action:e.jsx(B,{size:"small",onClick:()=>i(x),sx:{color:"#fff"},children:e.jsx(Sr,{fontSize:"small"})}),children:j},x)},x)});P===0&&(a&&console.log(`UiProvider showSnackbarMessage: message ${j} timeout ${P} - persist key ${z}`),ht.push({message:j,key:z}))},[c,i]),[f,y]=o.useState(!1),[t,l]=o.useState(""),[S,W]=o.useState(""),[v,L]=o.useState(""),E=o.useRef(null),w=o.useRef(null),$=()=>{a&&console.log(`UiProvider handle confirm action ${v}`),y(!1),E.current&&E.current(v)},p=()=>{a&&console.log(`UiProvider handle cancel action ${v}`),y(!1),w.current&&w.current(v)},U=o.useCallback((j,P,O,z,x)=>{a&&console.log(`UiProvider showConfirmCancelDialog for command ${O}`),l(j),W(P),L(O),E.current=z,w.current=x,y(!0)},[]),b=o.useMemo(()=>({showSnackbarMessage:s,closeSnackbarMessage:n,closeSnackbar:i,showConfirmCancelDialog:U}),[s,n,i,U]);return e.jsxs(nt.Provider,{value:b,children:[e.jsx(Uo,{open:f,title:t,message:S,onConfirm:$,onCancel:p}),r]})}const ir=o.createContext(null),fe=o.createContext(null);function qo({children:r}){const[c,i]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[n,s]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[f,y]=o.useState([]),[t,l]=o.useState(1e3),[S,W]=o.useState(!0),[v,L]=o.useState(!1),{showSnackbarMessage:E,closeSnackbarMessage:w,closeSnackbar:$}=o.useContext(nt),p=o.useRef([]),U=o.useRef(null),b=o.useRef(1),j=o.useRef(Math.floor(Math.random()*999e3)+1e3),P=o.useRef(null),O=o.useRef(null),z=o.useRef(null),x=o.useRef(c),R=o.useRef(n),u=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),h=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),C=100,V=60,ce=50,xe=300;o.useEffect(()=>{x.current=c},[c]),o.useEffect(()=>{R.current=n},[n]);const M=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),m=o.useCallback(I=>{if(U.current&&U.current.readyState===WebSocket.OPEN)try{I.id===void 0&&(I.id=j.current);const g=JSON.stringify(I);U.current.send(g),a&&console.log("WebSocket sent message:",I)}catch(g){a&&console.error(`WebSocket error sending message: ${g}`)}else a&&console.error("WebSocket message not sent, WebSocket not connected:",I)},[]),_=o.useCallback((I,g)=>{const d=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${I}</span>`;y(F=>[...F,d+' <span style="color: var(--main-log-color);">'+g+"</span>"])},[]),N=o.useCallback((I,g)=>{i(I),s(g),_("WebSocket",`Filtering by log level "${I}" and log search "${g}"`)},[_]),Z=o.useCallback(I=>{a&&console.log("WebSocket addListener:",I),p.current=[...p.current,I],a&&console.log("WebSocket addListener total listeners:",p.current.length)},[]),he=o.useCallback(I=>{a&&console.log("WebSocket removeListener:",I),p.current=p.current.filter(g=>g!==I),a&&console.log("WebSocket removeListener total listeners:",p.current.length)},[]),we=o.useCallback(()=>{u===""||u===null||u===void 0||(_("WebSocket",`Connecting to WebSocket: ${u}`),U.current=new WebSocket(u),U.current.onmessage=I=>{v||L(!0);try{const g=JSON.parse(I.data);if(g.id===void 0)return;if(g.error&&a&&console.error("WebSocket error message:",g),g.id===j.current&&g.src==="Matterbridge"&&g.dst==="Frontend"&&g.response==="pong"){a&&console.log("WebSocket pong response message:",g,"listeners:",p.current.length),O.current&&clearTimeout(O.current),p.current.forEach(F=>F(g));return}if(g.id===Se.RefreshRequired){a&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.RestartRequired){a&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.RestartNotRequired){a&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.CpuUpdate){a&&console.log("WebSocket WS_ID_CPU_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.MemoryUpdate){a&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.UptimeUpdate){a&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.Snackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_SNACKBAR message:",g,"listeners:",p.current.length),E(g.params.message,g.params.timeout,g.params.severity);return}else if(g.id===Se.CloseSnackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",g,"listeners:",p.current.length),w(g.params.message);return}else if(g.id===Se.ShellySysUpdate){a&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.ShellyMainUpdate){a&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id!==Se.Log){a&&console.log("WebSocket message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}if(!g.params||!g.params.level||!g.params.time||!g.params.name||!g.params.message||["debug","info","notice","warn","error","fatal"].includes(g.params.level)&&(x.current==="info"&&g.params.level==="debug"||x.current==="notice"&&(g.params.level==="debug"||g.params.level==="info")||x.current==="warn"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice")||x.current==="error"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn")||x.current==="fatal"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn"||g.params.level==="error"))||R.current!=="*"&&R.current!==""&&!g.params.message.toLowerCase().includes(R.current.toLowerCase())&&!g.params.name.toLowerCase().includes(R.current.toLowerCase())||g.params.name==="Commissioning"&&g.params.message.includes("is uncommissioned"))return;y(F=>{const ie=`<span style="color: #505050;">[${g.params?.time}]</span>`,se=be=>{switch(be?.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"lightblue"}},J=be=>{switch(be?.toLowerCase()){case"warn":return"black";default:return"white"}},me=`${`<span style="background-color: ${se(g.params?.level)}; color: ${J(g.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${g.params?.level}</span>`} ${ie} <span style="color: #09516d;">[${g.params?.name}]</span> <span style="color: var(--main-log-color);">${g.params?.message}</span>`,ne=[...F,me];return ne.length>t?ne.slice(t/10):ne})}catch(g){console.error(`WebSocketUse error parsing message: ${g}`)}},U.current.onopen=()=>{a&&console.log(`WebSocket: Connected to WebSocket: ${u}`),_("WebSocket",`Connected to WebSocket: ${u}`),L(!0),$(),b.current=1,z.current=setTimeout(()=>{P.current=setInterval(()=>{m({id:j.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{a&&console.error(`WebSocketUse: No pong response received from WebSocket: ${u}`),_("WebSocket",`No pong response received from WebSocket: ${u}`),L(!1)},1e3*ce)},1e3*V)},1e3*xe)},U.current.onclose=()=>{a&&console.error(`WebSocket: Disconnected from WebSocket ${h?"with Ingress":""}: ${u}`),_("WebSocket",`Disconnected from WebSocket: ${u}`),L(!1),$(),z.current&&clearTimeout(z.current),O.current&&clearTimeout(O.current),P.current&&clearInterval(P.current),_("WebSocket",`Reconnecting (attempt ${b.current} of ${C}) to WebSocket${h?" (Ingress)":""}: ${u}`),h?setTimeout(q,5e3):b.current===1?q():b.current<C?setTimeout(q,1e3*b.current):_("WebSocket",`Reconnect attempts exceeded limit of ${C} retries, refresh the page to reconnect to: ${u}`),b.current=b.current+1},U.current.onerror=I=>{a&&console.error(`WebSocket: WebSocket error connecting to ${u}:`,I),_("WebSocket",`WebSocket error connecting to ${u}`)})},[u]),q=o.useCallback(()=>{a&&console.log(`WebSocket attemptReconnect ${b.current}/${C} to:`,u),we()},[we]);o.useEffect(()=>(we(),()=>{U.current&&U.current.readyState===WebSocket.OPEN&&U.current.close()}),[we]);const k=o.useMemo(()=>({messages:f,maxMessages:t,autoScroll:S,setMessages:y,setLogFilters:N,setMaxMessages:l,setAutoScroll:W}),[f,y,N]),D=o.useMemo(()=>({maxMessages:t,autoScroll:S,logFilterLevel:c,logFilterSearch:n,setMessages:y,setLogFilters:N,setMaxMessages:l,setAutoScroll:W,online:v,retry:b.current,getUniqueId:M,addListener:Z,removeListener:he,sendMessage:m,logMessage:_}),[t,S,y,N,l,W,v,b.current,Z,he,m,_]);return e.jsx(ir.Provider,{value:k,children:e.jsx(fe.Provider,{value:D,children:r})})}function Bo(){const{showSnackbarMessage:r,showConfirmCancelDialog:c}=o.useContext(nt),{online:i,sendMessage:n,logMessage:s,addListener:f,removeListener:y,getUniqueId:t}=o.useContext(fe),[l,S]=o.useState(!1),[W,v]=o.useState(!1),[L,E]=o.useState(!1),[w,$]=o.useState(!1),[p,U]=o.useState(null),b=o.useRef(t()),[j,P]=o.useState(null),[O,z]=o.useState(null),[x,R]=o.useState(null),[u,h]=o.useState(null),[C,V]=o.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},M=()=>{p?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},m=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},_=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},N=()=>{n({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},Z=()=>{n({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},he=()=>{n({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},we=()=>{a&&console.log("Header: handleShellySystemUpdateClick"),s("Matterbridge","Installing system updates..."),n({id:b.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},q=()=>{a&&console.log("Header: handleShellyMainUpdateClick"),s("Matterbridge","Installing software updates..."),n({id:b.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{a&&console.log("Header: handleShellyCreateSystemLog"),n({id:b.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{a&&console.log("Header: handleShellyDownloadSystemLog"),s("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},I=()=>{p?.matterbridgeInformation.restartMode===""?n({id:b.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},g=()=>{n({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},d=()=>{n({id:b.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},F=()=>{n({id:b.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ie=()=>{n({id:b.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},se=Q=>{P(Q.currentTarget)},J=Q=>{a&&console.log("Header: handleMenuClose",Q),P(null),Q==="download-mblog"?(s("Matterbridge","Downloading matterbridge log..."),r("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(s("Matterbridge","Downloading matter log..."),r("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(s("Matterbridge","Loading matterbridge log..."),r("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(s("Matterbridge","Loading matter log..."),r("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(s("Matterbridge","Loading shelly system log..."),r("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(s("Matterbridge","Downloading matterbridge storage..."),r("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(s("Matterbridge","Downloading matterbridge plugins storage..."),r("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(s("Matterbridge","Downloading matterbridge plugins config..."),r("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(s("Matterbridge","Downloading matter storage..."),r("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(s("Matterbridge","Downloading backup..."),r("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?N():Q==="updatedev"?Z():Q==="updatecheck"?he():Q==="shelly-sys-update"?we():Q==="shelly-main-update"?q():Q==="shelly-create-system-log"?k():Q==="shelly-download-system-log"?D():Q==="softreset"?F():Q==="hardreset"?ie():Q==="restart"?I():Q==="shutdown"?g():Q==="reboot"?d():Q==="create-backup"?n({id:b.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?n({id:b.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?n({id:b.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&n({id:b.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=Q=>{a&&console.log("Header: handleMenuCloseCancel:",Q),P(null)},me=Q=>{z(Q.currentTarget)},ne=()=>{z(null)},be=Q=>{R(Q.currentTarget)},ae=()=>{R(null)},ge=Q=>{h(Q.currentTarget)},Y=()=>{h(null)},ue=Q=>{V(Q.currentTarget)},ve=()=>{V(null)},Ge=()=>{Zn(),a&&console.log("Matterbridge logo clicked: debug is now",a)};return o.useEffect(()=>{const Q=ee=>{ee.src==="Matterbridge"&&ee.dst==="Frontend"&&(Be(ee)&&ee.method==="/api/settings"&&ee.id===b.current&&(a&&console.log("Header received settings:",ee.response),U(ee.response),S(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),v(ee.response.matterbridgeInformation.fixedRestartRequired),E(ee.response.matterbridgeInformation.updateRequired)),Ie(ee)&&ee.method==="refresh_required"&&ee.params.changed==="settings"&&(a&&console.log(`Header received refresh_required: changed=${ee.params.changed} and sending /api/settings request`),n({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Ie(ee)&&ee.method==="restart_required"&&(a&&console.log(`Header received restart_required with fixed: ${ee.params.fixed}`),S(!0),ee.params.fixed===!0&&v(!0)),Ie(ee)&&ee.method==="restart_not_required"&&(a&&console.log("Header received restart_not_required"),S(!1)),Ie(ee)&&ee.method==="update_required"&&(a&&console.log("Header received update_required"),E(!0)),Ie(ee)&&ee.method==="update_required_dev"&&(a&&console.log("Header received update_required_dev"),$(!0)),Ie(ee)&&ee.id===Se.ShellySysUpdate&&(a&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),U(Te=>Te?{matterbridgeInformation:{...Te.matterbridgeInformation,shellySysUpdate:ee.params.available},systemInformation:Te.systemInformation}:null)),Ie(ee)&&ee.id===Se.ShellyMainUpdate&&(a&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),U(Te=>Te?{matterbridgeInformation:{...Te.matterbridgeInformation,shellyMainUpdate:ee.params.available},systemInformation:Te.systemInformation}:null)))};return f(Q),a&&console.log(`Header added WebSocket listener id ${b.current}`),()=>{y(Q),a&&console.log("Header removed WebSocket listener")}},[f,y,n,r]),o.useEffect(()=>{i&&(a&&console.log("Header sending /api/settings requests"),n({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),a&&console.log("Header rendering..."),!i||!p?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ge}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),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",{className:"sub-header",children:[!p.matterbridgeInformation.readOnly&&L&&e.jsx(H,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:N,children:["Update to v.",p.matterbridgeInformation.matterbridgeLatestVersion]})}),!p.matterbridgeInformation.readOnly&&w&&e.jsx(H,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:Z,children:["Update to new dev v.",p.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:M,children:["v.",p.matterbridgeInformation.matterbridgeVersion]})}),p.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),p.matterbridgeInformation.bridgeMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.bridgeMode})}):null,p.matterbridgeInformation.restartMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.restartMode})}):null,p.matterbridgeInformation.profile&&p.matterbridgeInformation.profile!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:m})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Give a star to Matterbridge",children:e.jsx(B,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:_,children:e.jsx(wr,{})})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Sponsor Matterbridge",children:e.jsx(B,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(Zt,{})})}):null,e.jsx(H,{title:"Matterbridge help",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(Mr,{})})}),e.jsx(H,{title:"Matterbridge changelog",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:M,children:e.jsx(er,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Update matterbridge to latest version",children:e.jsx(B,{style:{color:L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:N,children:e.jsx(Ve,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsx(H,{title:"Shelly system update",children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:we,children:e.jsx(Ve,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsx(H,{title:"Shelly software update",children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:q,children:e.jsx(Ve,{})})}),e.jsx(H,{title:"Restart matterbridge",children:e.jsx(B,{style:{color:l||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:I,children:e.jsx(yt,{})})}),p.matterbridgeInformation.restartMode===""?e.jsx(H,{title:"Shut down matterbridge",children:e.jsx(B,{style:{color:l||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:g,children:e.jsx(ze,{})})}):null,e.jsx(H,{title:"Download, backup and more",children:e.jsx(B,{onClick:se,children:e.jsx(kr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(rt,{id:"command-menu",anchorEl:j,keepMounted:!0,open:!!j,onClose:()=>J(""),children:[p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>J("update"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>J("updatedev"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>J("updatecheck"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsxs(T,{onClick:()=>J("shelly-sys-update"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsxs(T,{onClick:()=>J("shelly-main-update"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>J("restart"),children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation.restartMode===""?e.jsxs(T,{onClick:()=>J("shutdown"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",J,de)},children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:be,children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-view",anchorEl:x,keepMounted:!0,open:!!x,onClose:ae,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{J("view-mblog"),ae()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("view-mjlog"),ae()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{J("view-shellylog"),ae()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:ge,children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-download",anchorEl:u,keepMounted:!0,open:!!u,onClose:Y,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{J("download-mbstorage"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-pluginstorage"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-pluginconfig"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-mblog"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-mjstorage"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-mjlog"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{J("shelly-create-system-log"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{J("shelly-download-system-log"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:me,children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-backup",anchorEl:O,keepMounted:!0,open:!!O,onClose:ne,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{J("create-backup"),ne()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-backup"),ne()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:ue,children:[e.jsx(K,{children:e.jsx(Ir,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-reset",anchorEl:C,keepMounted:!0,open:!!C,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{ve(),c("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",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{ve(),c("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>{ve(),c("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{ve(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{ve(),c("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Jo=o.memo(Bo),Qo=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(a&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(a&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Go(){const{messages:r,autoScroll:c}=o.useContext(ir),[i,n]=o.useState(!1),s=o.useRef(null),f=o.useMemo(()=>Qo(),[]),y=l=>n(!0),t=l=>n(!1);return o.useEffect(()=>{a&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${i}`),c&&!i&&!f&&s.current?.scrollIntoView({behavior:"smooth"})},[r,i,c,f]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:y,onMouseLeave:t,children:[r.map((l,S)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:l}},S)),e.jsx("div",{ref:s})]})})}const ar=o.memo(Go);function Qe(){const{retry:r}=o.useContext(fe),c=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(X,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:r<100?e.jsxs(e.Fragment,{children:[e.jsx(Dr,{style:{color:"var(--primary-color)"}}),e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:["Reconnecting to Matterbridge ","(attempt "+r+")","..."]})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:["Unable to connect to Matterbridge after multiple attempts.",e.jsx("br",{}),"Please check your network connection.",e.jsx("br",{}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Ko({value:r,maxChars:c}){let i=r;if(r.length>c&&c>3){const n=c-3,s=r.substring(0,Math.ceil(n/2)),f=r.substring(r.length-Math.floor(n/2),r.length);i=`${s} … ${f}`}return r!==i?e.jsx(H,{title:r,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:i})}):e.jsx("span",{children:i})}function Yo({systemInfo:r,compact:c}){const[i,n]=o.useState(r),{sendMessage:s,addListener:f,removeListener:y}=o.useContext(fe);if(a&&console.log("SystemInfoTable:",i,"compact:",c),r&&c&&i.totalMemory&&i.freeMemory){const t=i.totalMemory,l=i.freeMemory;i.freeMemory=`${l} / ${t}`,i.totalMemory=""}if(r&&c&&i.heapTotal&&i.heapUsed){const t=i.heapTotal,l=i.heapUsed;i.heapUsed=`${l} / ${t}`,i.heapTotal=""}if(r&&c&&i.osRelease&&i.osType){const t=i.osType,l=i.osRelease;i.osType=`${t} (${l})`,i.osRelease=""}if(r&&c&&i.osArch&&i.osPlatform){const t=i.osPlatform,l=i.osArch;i.osPlatform=`${t} (${l})`,i.osArch=""}return o.useEffect(()=>{const t=l=>{l.src==="Matterbridge"&&l.dst==="Frontend"&&(l.method==="memory_update"&&l.params&&l.params.totalMemory&&l.params.freeMemory&&l.params.heapTotal&&l.params.heapUsed&&l.params.rss&&(a&&console.log("SystemInfoTable received memory_update",l),(i.totalMemory!==l.params?.totalMemory||i.freeMemory!==l.params?.freeMemory||i.heapTotal!==l.params?.heapTotal||i.heapUsed!==l.params?.heapUsed||i.rss!==l.params?.rss)&&n(S=>({...S,totalMemory:l.params?.totalMemory?l.params.totalMemory:"",freeMemory:l.params?.freeMemory?l.params.freeMemory:"",heapTotal:l.params?.heapTotal?l.params.heapTotal:"",heapUsed:l.params?.heapUsed?l.params.heapUsed:"",rss:l.params?.rss?l.params.rss:""}))),l.method==="cpu_update"&&l.params&&l.params.cpuUsage&&(a&&console.log("SystemInfoTable received cpu_update",l),i.cpuUsage!==(l.params?.cpuUsage?l.params.cpuUsage.toFixed(2)+" %":"")&&n(S=>({...S,cpuUsage:l.params?.cpuUsage?l.params.cpuUsage.toFixed(2)+" %":""}))),l.method==="uptime_update"&&l.params&&l.params.systemUptime&&l.params.processUptime&&(a&&console.log("SystemInfoTable received uptime_update",l),(i.systemUptime!==l.params?.systemUptime||i.processUptime!==l.params?.processUptime)&&n(S=>({...S,systemUptime:l.params?.systemUptime?l.params.systemUptime:"",processUptime:l.params?.processUptime?l.params.processUptime:""}))))};return a&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),f(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),y(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[f,i.cpuUsage,i.freeMemory,i.heapTotal,i.heapUsed,i.processUptime,i.rss,i.systemUptime,i.totalMemory,y,s]),i?(a&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(i).filter(([t,l])=>l!==void 0&&l!=="").map(([t,l],S)=>e.jsxs("tr",{className:S%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:t}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Ko,{value:typeof l!="string"?l.toString():l,maxChars:25})})]},t))})})})]})):null}const Xo=o.memo(Yo),Jt={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"}},Zo=r=>{if(!r)return"";const c=r.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const i=c.slice(0,4),n=c.slice(4,7),s=c.slice(7,11);return[i,n,s].filter(Boolean).join("-")};function en({id:r}){const{online:c,sendMessage:i,addListener:n,removeListener:s,getUniqueId:f}=o.useContext(fe),[y,t]=o.useState(null),[l,S]=o.useState(null),W=o.useRef(null),v=o.useRef(f()),{showConfirmCancelDialog:L}=o.useContext(nt);o.useEffect(()=>{a&&console.log(`QRDiv received storeId update "${r}"`),r&&(a&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const b=j=>{j.src==="Matterbridge"&&j.dst==="Frontend"&&Ie(j)&&j.id===Se.RefreshRequired&&j.params.changed==="matter"&&j.params.matter&&(a&&console.log(`QRDiv received refresh_required: changed=${j.params.changed} for storeId "${j.params.matter.id}":`,j.params.matter),y===j.params.matter.id&&(a&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${j.params.matter.id}":`,j.params.matter),W.current&&clearTimeout(W.current),j.params.matter.advertising&&j.params.matter.advertiseTime&&j.params.matter.advertiseTime+9e5<=Date.now()&&(j.params.matter.advertising=!1),S(j.params.matter),j.params.matter.advertising&&(a&&console.log(`QRDiv setting matter advertise timeout for storeId "${j.params.matter.id}":`,j.params.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),a&&console.log(`QRDiv clearing advertising state for storeId "${y}" after 15 minutes`),S(P=>P&&{...P,advertising:!1})},j.params.matter.advertiseTime+9e5-Date.now()))))};return n(b),a&&console.log("QRDiv webSocket effect mounted"),()=>{s(b),W.current&&clearTimeout(W.current),a&&console.log("QRDiv webSocket effect unmounted")}},[y]);const E=()=>{a&&console.log(`QRDiv sent matter startCommission for node "${l?.id}"`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,startCommission:!0}})},w=()=>{a&&console.log(`QRDiv sent matter stopCommission for node "${l?.id}"`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,stopCommission:!0}})},$=()=>{a&&console.log(`QRDiv sent matter advertise for node "${l?.id}"`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,advertise:!0}})},p=b=>{a&&console.log(`QRDiv sent matter removeFabric for node "${l?.id}" and fabricIndex ${b}`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,removeFabric:b}})},U=async()=>{if(!l||!l.manualPairingCode)return;const b=l.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(b);else{const j=document.createElement("textarea");j.value=b,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.focus(),j.select(),document.execCommand("copy"),document.body.removeChild(j)}a&&console.log("Manual pairing code copied to clipboard")}catch(j){console.error("Failed to copy manual pairing code",j)}};return!l||!c?(a&&console.log("QRDiv rendering undefined state"),null):l.advertising&&l.qrPairingCode&&l.manualPairingCode?(a&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(B,{"aria-label":"send advertising",size:"small",onClick:$,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:Ut,size:"22px"})})}),e.jsx(B,{"aria-label":"stop pairing",size:"small",onClick:w,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn off pairing",arrow:!0,children:e.jsx(te,{path:mo,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:y}),e.jsx(uo,{value:l.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Zo(l.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(H,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(B,{"aria-label":"copy manual pairing code",size:"small",onClick:U,sx:Jt,children:e.jsx(te,{path:go,size:.85})})})})]})]})):l.commissioned&&l.fabricInformations&&l.sessionInformations?(a&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(B,{"aria-label":"send advertising",size:"small",onClick:$,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:Ut,size:"22px"})})}),e.jsx(B,{"aria-label":"start pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn on pairing",arrow:!0,children:e.jsx(te,{path:zt,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:y}),l.fabricInformations.map((b,j)=>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: ",b.fabricIndex]}),e.jsx(H,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(B,{"aria-label":"remove the fabric",size:"small",onClick:()=>L("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>p(b.fabricIndex),()=>{}),sx:{...Jt,padding:"2px"},children:e.jsx(te,{path:ho,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",b.rootVendorId," ",b.rootVendorName]}),b.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",b.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",l.sessionInformations?l.sessionInformations.filter(P=>P.fabric?.fabricIndex===b.fabricIndex&&P.isPeerActive===!0).length:"0"," ","subscriptions: ",l.sessionInformations?l.sessionInformations.filter(P=>P.fabric?.fabricIndex===b.fabricIndex&&P.isPeerActive===!0&&P.numberOfActiveSubscriptions>0).length:"0"]})]},j))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",l.serialNumber]})})]})):!l.commissioned&&!l.advertising?(a&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:y}),e.jsx(oe,{onClick:E,endIcon:e.jsx(te,{path:zt,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("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",l.serialNumber]})})]})):(a&&console.log("QRDiv rendering unknown state"),null)}const tn=o.memo(en);function rn(){const{logMessage:r,sendMessage:c,getUniqueId:i}=o.useContext(fe),[n,s]=o.useState("matterbridge-"),[f,y]=o.useState(!1),[t,l]=o.useState(null),S=o.useRef(i()),W=j=>{j.preventDefault(),y(!0)},v=()=>{y(!1)},L=j=>{j.preventDefault(),y(!1);const P=j.dataTransfer.files[0];if(P){r("Plugins",`Installing package ${P.name}. Please wait...`);const O=new FormData;O.append("file",P),O.append("filename",P.name),fetch("./api/uploadpackage",{method:"POST",body:O}).then(z=>z.text()).then(z=>{r("Plugins",`Server response: ${z}`)}).catch(z=>{console.error("Error uploading plugin file:",z),r("Plugins",`Error installing package ${z}`)})}},E=j=>{const P=j.target.files&&j.target.files[0];if(P){r("Plugins",`Uploading package ${P.name}`);const O=new FormData;O.append("file",P),O.append("filename",P.name),fetch("./api/uploadpackage",{method:"POST",body:O}).then(z=>z.text()).then(z=>{r("Plugins",`Server response: ${z}`)}).catch(z=>{console.error("Error uploading plugin file:",z),r("Plugins",`Error uploading package ${z}`)})}},w=()=>{c({id:S.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},$=()=>{document.getElementById("file-upload")?.click()},p=()=>{c({id:S.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},U=j=>{l(j.currentTarget)},b=j=>{j!==""&&s(j),l(null)};return a&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:W,onDragLeave:v,onDrop:L,children:[e.jsx(pe,{value:n,onChange:j=>{s(j.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(B,{onClick:U,children:e.jsx(Nr,{})}),e.jsxs(rt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>b(""),children:[e.jsx(T,{onClick:()=>b("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(T,{onClick:()=>b("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(T,{onClick:()=>b("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(T,{onClick:()=>b("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(T,{onClick:()=>b("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(T,{onClick:()=>b("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(T,{onClick:()=>b("matterbridge-test"),children:"matterbridge-test"}),e.jsx(T,{onClick:()=>b("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(T,{onClick:()=>b("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(H,{title:"Install or update a plugin from npm",children:e.jsx(oe,{onClick:w,endIcon:e.jsx(Oe,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(H,{title:"Upload and install a plugin from a tarball",children:e.jsx(oe,{onClick:$,endIcon:e.jsx(Pr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(H,{title:"Add an installed plugin",children:e.jsx(oe,{onClick:p,endIcon:e.jsx(jt,{}),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:E})]})}const on=o.memo(rn);function Ze({status:r,enabledText:c="Enabled",disabledText:i=void 0,tooltipText:n=void 0,onClick:s}){if(r===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const f=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:r?c:i??c});return n!==void 0?e.jsx(H,{title:n,children:f}):f}}const et={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},tt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},nn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},an={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ee={padding:"0px",margin:"0px"},sn="5px 10px 5px 10px",ft={},je={},xt={},bt={};let vt=[],Qt=[];const ln=({open:r,onClose:c,plugin:i})=>{const{sendMessage:n,addListener:s,removeListener:f,getUniqueId:y}=o.useContext(fe),t=o.useRef(y()),[l,S]=o.useState(i.configJson),[W,v]=o.useState(i.schemaJson),[L,E]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[w,$]=o.useState("");let p={};o.useEffect(()=>{const k=D=>{D.src==="Matterbridge"&&D.dst==="Frontend"&&(D.id===t.current&&D.method==="/api/select/devices"&&(D.response&&(vt=D.response),D.error&&console.error("ConfigPluginDialog received /api/select/devices error:",D.error)),D.id===t.current&&D.method==="/api/select/entities"&&(D.response&&(Qt=D.response),D.error&&console.error("ConfigPluginDialog received /api/select/entities error:",D.error)))};return s(k),l!==void 0&&W!==void 0&&(Object.keys(W.properties).forEach(D=>{Object.keys(W.properties[D]).forEach(I=>{I.startsWith("ui:")&&(L[D]={},L[D][I]=W.properties[D][I],delete W.properties[D][I])})}),E(L)),i.name!==void 0&&i.configJson!==void 0&&i.schemaJson!==void 0&&(S(i.configJson),v(i.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name}})),()=>{f(k)}},[s,l,i,f,W,n,L]);const U=({formData:k})=>{p=k},b=({formData:k})=>{S(k),i.configJson=k,i.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:k.name,formData:k}}),c()};function j(k){const{id:D,label:I,onKeyChange:g,onDropPropertyClick:d,disabled:F,schema:ie,children:se,registry:J,readonly:de,required:me}=k,{templates:ne}=J,{RemoveButton:be}=ne.ButtonTemplates;if(!(Ao in ie))return e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:se});const ge=({target:Y})=>g(Y&&Y.value);return e.jsxs(X,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${D}-key`,name:`${D}-key`,required:me,disabled:F||de,defaultValue:I,onBlur:de?void 0:ge,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(X,{sx:{flex:1},children:se}),e.jsx(be,{disabled:F||de,onClick:d(I)})]})}function P(k){const{children:D,description:I,displayLabel:g,errors:d,help:F,hidden:ie,_id:se,_label:J,registry:de,uiSchema:me}=k,ne=Vo(me),be=_o("WrapIfAdditionalTemplate",de,ne);return ie?e.jsx("div",{style:{display:"none"},children:D}):e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(be,{...k,children:[g===!0&&I,D,d,F]})})}function O(k){const{description:D}=k;return D?e.jsx(le,{sx:tt,children:D}):null}function z(k){const{required:D,title:I}=k;return I?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(le,{sx:et,children:["Title ",I," ",D&&e.jsx("mark",{children:"***"})]})}):null}function x(k){const{help:D,_idSchema:I}=k;return D?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(le,{sx:nn,children:D})}):null}function R(k){const{errors:D}=k;return D?e.jsxs(X,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(le,{color:"error",sx:an,children:"Please fix the following errors:"}),e.jsx(it,{children:D.map((I,g)=>e.jsxs(Tr,{children:[e.jsx(K,{children:e.jsx(Wr,{color:"error"})}),e.jsx(re,{primary:I.stack})]},g))})]}):null}function u(k){const{errors:D}=k;return D?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:D.map((I,g)=>e.jsxs(le,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",I]},g))}):null}function h(k){const{id:D,name:I,_schema:g,_uiSchema:d,value:F,options:ie,label:se,type:J,placeholder:de,required:me,disabled:ne,readonly:be,autofocus:ae,onChange:ge,onChangeOverride:Y,onBlur:ue,onFocus:ve,_rawErrors:Ge,_hideError:Q,_registry:ee,_formContext:Te}=k,Re=({target:{value:ye}})=>ge(ye===""?ie.emptyValue:ye),He=({target:ye})=>ue(D,ye&&ye.value),Ue=({target:ye})=>ve(D,ye&&ye.value);return e.jsx(X,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:D,name:D,label:de&&de!==""?se:void 0,variant:"outlined",placeholder:de&&de!==""?de:se,required:me,disabled:ne||be,autoFocus:ae,value:F||F===0?F:"",type:J,autoComplete:J==="password"?"current-password":I,onChange:Y||Re,onBlur:He,onFocus:Ue,fullWidth:!0})})}function C(k){return console.log("ArrayFieldTitleTemplate:",k),null}function V(k){return console.log("ArrayFieldDescriptionTemplate:",k),null}function ce(k){return console.log("ArrayFieldItemTemplate:",k),null}function xe(k){const{canAdd:D,_className:I,_disabled:g,_formContext:d,_formData:F,_idSchema:ie,_items:se,onAddClick:J,_rawErrors:de,_readonly:me,_registry:ne,_required:be,schema:ae,title:ge,_uiSchema:Y}=k,[ue,ve]=o.useState(!1),[Ge,Q]=o.useState(!1),[ee,Te]=o.useState(!1),[Re,He]=o.useState(""),Ue=A=>{He(A.target.value)},ye=()=>{ve(!ue)},Ke=()=>{Q(!Ge)},Ye=()=>{Te(!ee)},Mt=A=>{ve(!1),ae.selectFrom==="serial"?ae.items.default=A.serial:ae.selectFrom==="name"&&(ae.items.default=A.name),J()},kt=A=>{Q(!1),ae.selectEntityFrom==="name"?ae.items.default=A.name:ae.selectEntityFrom==="description"&&(ae.items.default=A.description),J()},It=A=>{Te(!1),ae.selectDeviceEntityFrom==="name"?ae.items.default=A.name:ae.selectDeviceEntityFrom==="description"&&(ae.items.default=A.description),J()};return e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ge&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ge&&e.jsx(le,{sx:et,children:ge}),D&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ae.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(B,{onClick:ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ae.selectEntityFrom&&e.jsx(H,{title:"Add an entity from the list",children:e.jsx(B,{onClick:Ke,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ae.selectDeviceEntityFrom&&e.jsx(H,{title:"Add a device entity from the list",children:e.jsx(B,{onClick:Ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(B,{onClick:J,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),ae.description&&e.jsx(le,{sx:tt,children:ae.description}),k.items.map(A=>e.jsxs(X,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(X,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(B,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ot,{})}),e.jsx(B,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ht,{})}),e.jsx(B,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ee,children:e.jsx(St,{})})]},A.index)),e.jsxs(De,{open:ue,onClose:ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Re,onChange:Ue,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial.toLowerCase().includes(Re.toLowerCase())||A.name.toLowerCase().includes(Re.toLowerCase())).map((A,Me)=>e.jsxs(ut,{onClick:()=>Mt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Me))})]}),e.jsx(We,{children:e.jsx(oe,{onClick:ye,children:"Close"})})]}),e.jsxs(De,{open:Ge,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(Pe,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Re,onChange:Ue,placeholder:"Enter name or description"})]}),e.jsx(it,{dense:!0,children:Qt.filter(A=>A.name.toLowerCase().includes(Re.toLowerCase())||A.description.toLowerCase().includes(Re.toLowerCase())).map((A,Me)=>e.jsxs(ut,{onClick:()=>kt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),A.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:je})}),A.icon==="matter"&&e.jsx(K,{children:e.jsx(Et,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Me))})]}),e.jsx(We,{children:e.jsx(oe,{onClick:Ke,children:"Close"})})]}),e.jsxs(De,{open:ee,onClose:Ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",ge]}),e.jsx(Pe,{children:e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial===ge||A.name===ge).map(A=>A.entities?.map((Me,Dt)=>e.jsxs(ut,{onClick:()=>It(Me),sx:ft,children:[Me.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),Me.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),Me.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),Me.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:je})}),Me.icon==="matter"&&e.jsx(K,{children:e.jsx(Et,{style:je})}),e.jsx(re,{primary:Me.name,secondary:Me.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Dt)))})}),e.jsx(We,{children:e.jsx(oe,{onClick:Ye,children:"Close"})})]})]})}function M(k){const{onAddClick:D,schema:I,properties:g,title:d,description:F}=k,[ie,se]=o.useState(!1),[J,de]=o.useState(""),me=Y=>{de(Y.target.value)},ne=()=>{se(!ie)},be=Y=>{se(!1);let ue="";I.selectFrom==="serial"?ue=Y.serial:I.selectFrom==="name"&&(ue=Y.name),$(ue),D(I)()},ae=()=>{D(I)()},ge=!I.additionalProperties;return!ge&&w!==""&&g.forEach(Y=>{if(Y.name==="newKey"&&Y.content.key==="newKey"&&Y.content.props.name==="newKey"&&Y.content.props.onKeyChange&&w!==""){const ue=w;$(""),Y.content.props.onKeyChange(ue)}}),e.jsxs(X,{sx:{margin:"0px",padding:ge?"10px":"5px 10px 0px 10px",border:ge?"none":"1px solid grey"},children:[I.title&&ge&&e.jsx(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:et,children:I.title})}),d&&!ge&&e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(le,{sx:et,children:d}),e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[I.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(B,{onClick:ne,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(B,{onClick:ae,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),I.description&&e.jsx(X,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:tt,children:I.description})}),g.map(({content:Y,name:ue,hidden:ve})=>!ve&&e.jsxs(X,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(I.properties[ue].type)?"0px":sn,border:["object","array","boolean"].includes(I.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(I.properties[ue].type)&&e.jsx(le,{sx:et,children:ue}),e.jsx(X,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:Y})]},ue)),e.jsxs(De,{open:ie,onClose:ne,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:J,onChange:me,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(Y=>Y.serial.toLowerCase().includes(J.toLowerCase())||Y.name.toLowerCase().includes(J.toLowerCase())).map((Y,ue)=>e.jsxs(ut,{onClick:()=>be(Y),sx:ft,children:[Y.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),Y.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),Y.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),e.jsx(re,{primary:Y.name,secondary:Y.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ue))})]}),e.jsx(We,{children:e.jsx(oe,{onClick:ne,children:"Close"})})]})]})}function m(k){const{uiSchema:D}=k,{submitText:I,norender:g}=Eo(D);return g?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(oe,{type:"submit",variant:"contained",color:"primary",children:I}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function _(k){const{className:D,disabled:I,onClick:g,registry:d,style:F,uiSchema:ie,...se}=k;return e.jsx(H,{title:"Remove the item",children:e.jsx(B,{disabled:I,size:"small",color:"primary",onClick:g,children:e.jsx(St,{})})})}function N(k){const{className:D,disabled:I,onClick:g,registry:d,uiSchema:F,...ie}=k;return e.jsx(H,{title:"Add an item",children:e.jsx(B,{size:"small",color:"primary",onClick:g,children:e.jsx(jt,{})})})}function Z(k){const{disabled:D,onClick:I,registry:g,style:d,uiSchema:F,...ie}=k;return e.jsx(H,{title:"Move up the item",children:e.jsx(B,{size:"small",color:"primary",onClick:I,children:e.jsx(Ot,{})})})}function he(k){const{disabled:D,onClick:I,registry:g,style:d,uiSchema:F,...ie}=k;return e.jsx(H,{title:"Move down the item",children:e.jsx(B,{size:"small",color:"primary",onClick:I,children:e.jsx(Ht,{})})})}function we(k){const{id:D,name:I,value:g,schema:d,readonly:F,onChange:ie}=k,[se,J]=o.useState(void 0),de=ne=>{J(ne&&ne!==""?ne:void 0)},me=()=>{n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name,action:I,value:se,formData:p,id:D}}),d.buttonClose===!0?c():d.buttonSave===!0&&b({formData:l})};return d.buttonText&&d.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:tt,children:d.description}),e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>me(),children:d.buttonText})]}):d.buttonField&&d.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:tt,children:d.description}),e.jsx(pe,{id:I+"-input",name:I,label:d.textLabel,placeholder:d.textPlaceholder,onChange:ne=>de(ne.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(oe,{id:I+"-button",variant:"contained",color:"primary",disabled:se===void 0,onClick:()=>me(),children:d.buttonField})]}):e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[I&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(le,{sx:et,children:I}),e.jsx(Le,{checked:g,readOnly:F,onChange:()=>ie(!g),sx:{padding:"0px",margin:"0px"}})]}),d.description&&e.jsx(le,{sx:tt,children:d.description})]})}function q({schema:k,id:D,name:I,options:g,label:d,hideLabel:F,required:ie,disabled:se,placeholder:J,readonly:de,value:me,multiple:ne,autofocus:be,onChange:ae,onBlur:ge,onFocus:Y,errorSchema:ue,rawErrors:ve=[],registry:Ge,uiSchema:Q,hideError:ee,formContext:Te,...Re}){const{enumOptions:He,enumDisabled:Ue,emptyValue:ye}=g;ne=typeof ne>"u"?!1:!!ne;const Ke=ne?[]:"",Ye=typeof me>"u"||ne&&me.length<1||!ne&&me===Ke,Mt=({target:{value:$e}})=>ae(Pt($e,He,ye)),kt=({target:$e})=>ge(D,Pt($e&&$e.value,He,ye)),It=({target:$e})=>Y(D,Pt($e&&$e.value,He,ye)),A=Oo(me,He,ne),{InputLabelProps:Me,SelectProps:Dt,autocomplete:pr,...ur}=Re,mr=!ne&&k.default===void 0;return e.jsxs(pe,{id:D,name:D,value:!Ye&&typeof A<"u"?A:Ke,required:ie,disabled:se||de,autoFocus:be,autoComplete:pr,placeholder:J,error:ve.length>0,onChange:Mt,onBlur:kt,onFocus:It,...ur,select:!0,InputLabelProps:{...Me,shrink:!Ye},SelectProps:{...Dt,multiple:ne},"aria-describedby":$o(D),children:[mr&&e.jsx(T,{value:"",children:J}),Array.isArray(He)&&He.map(({value:$e,label:gr},Rt)=>{const hr=Array.isArray(Ue)&&Ue.indexOf($e)!==-1;return e.jsx(T,{value:String(Rt),disabled:hr,children:gr},Rt)})]})}return!r||!W||!l?null:e.jsxs(De,{open:r,onClose:c,maxWidth:"800px",children:[e.jsx(Ne,{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(Pe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Ro,{schema:W,formData:l,uiSchema:L,validator:Ho,templates:{FieldTemplate:P,BaseInputTemplate:h,TitleFieldTemplate:z,DescriptionFieldTemplate:O,FieldHelpTemplate:x,FieldErrorTemplate:u,ErrorListTemplate:R,WrapIfAdditionalTemplate:j,ArrayFieldTitleTemplate:C,ArrayFieldDescriptionTemplate:V,ArrayFieldItemTemplate:ce,ArrayFieldTemplate:xe,ObjectFieldTemplate:M,ButtonTemplates:{SubmitButton:m,RemoveButton:_,AddButton:N,MoveUpButton:Z,MoveDownButton:he}},widgets:{CheckboxWidget:we,SelectWidget:q},onChange:U,onSubmit:b})})]})};function dn({data:r,columns:c,columnVisibility:i}){const n=Wt.useMemo(()=>c.filter(S=>i[S.accessor]),[c,i]),{getTableProps:s,getTableBodyProps:f,headerGroups:y,rows:t,prepareRow:l}=Ae.useTable({columns:n,data:r},Ae.useSortBy);return e.jsxs("table",{...s(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:y.map(S=>e.jsx("tr",{...S.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:S.headers.map(W=>e.jsx("th",{...W.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:W.noSort?"default":"pointer"},children:W.render("Header")}))}))}),e.jsx("tbody",{...f(),style:{border:"none",borderCollapse:"collapse"},children:t.map((S,W)=>(l(S),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...S.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:S.cells.map(v=>e.jsx("td",{...v.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:v.render("Cell")}))},W)))})]})}function cn({_storeId:r,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:f,getUniqueId:y}=o.useContext(fe),{showConfirmCancelDialog:t}=o.useContext(nt),l=o.useRef(y()),[S,W]=o.useState(null),[v,L]=o.useState(null),[E,w]=o.useState([]),[$,p]=o.useState(!1),[U,b]=o.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),j=d=>{if(d===void 0||d.matter===void 0||!d.matter.fabricInformations&&!d.matter.qrPairingCode&&!d.matter.manualPairingCode)return"red";if(d.matter.commissioned===!1&&d.matter.qrPairingCode&&d.matter.manualPairingCode)return"var(--primary-color)";var F=0,ie=0;for(const se of d.matter.sessionInformations??[])se.fabric&&se.isPeerActive===!0&&F++,se.numberOfActiveSubscriptions>0&&(ie+=se.numberOfActiveSubscriptions);return d.matter.commissioned===!0&&d.matter.fabricInformations&&d.matter.sessionInformations&&(F===0||ie===0)?"var(--secondary-color)":"var(--div-text-color)"},P=[{Header:"Name",accessor:"name",Cell:({row:d})=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>m(d.original),children:d.original.name})})},{Header:"Description",accessor:"description",Cell:({row:d})=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>m(d.original),children:d.original.description})})},{Header:"Version",accessor:"version",Cell:({row:d})=>e.jsxs(e.Fragment,{children:[d.original.latestVersion!==void 0&&d.original.latestVersion!==d.original.version&&v&&!v.readOnly&&e.jsx(H,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>C(d.original),children:["Update to v.",d.original.latestVersion]})}),d.original.version.includes("-dev-")&&d.original.devVersion!==void 0&&d.original.devVersion!==d.original.version&&v&&!v.readOnly&&e.jsx(H,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>V(d.original),children:["Update to new dev v.",d.original.devVersion.split("-dev-")[0]]})}),e.jsx(H,{title:"Plugin version",children:d.original.version})]})},{Header:"Author",accessor:"author",Cell:({row:d})=>e.jsx(e.Fragment,{children:d.original.author?d.original.author.replace("https://github.com/",""):"Unknown"})},{Header:"Type",accessor:"type",Cell:({row:d})=>e.jsx(e.Fragment,{children:d.original.type?d.original.type.replace("Platform",""):"Unknown"})},{Header:"Devices",accessor:"registeredDevices"},{Header:"Actions",accessor:"actions",Cell:({row:d})=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[v&&v.bridgeMode==="childbridge"&&!d.original.error&&d.original.enabled&&e.jsx(H,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:j(d.original)},onClick:()=>c(d.original?.matter?.id),size:"small",children:e.jsx(tr,{})})}),v&&v.bridgeMode==="childbridge"&&!d.original.error&&d.original.enabled&&e.jsx(H,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>xe(d.original),size:"small",children:e.jsx(yt,{})})}),e.jsx(H,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{disabled:d.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(d.original),size:"small",children:e.jsx(Je,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{R("Remove plugin","Are you sure? This will remove also all the devices and configuration in the controller.","remove",d.original)},size:"small",children:e.jsx(St,{})})}),d.original.enabled?e.jsx(H,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{R("Disable plugin","Are you sure? This will remove also all the devices and configuration in the controller.","disable",d.original)},size:"small",children:e.jsx(Fr,{})})}):e.jsx(e.Fragment,{}),d.original.enabled?e.jsx(e.Fragment,{}):e.jsx(H,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>M(d.original),size:"small",children:e.jsx(Lr,{})})}),e.jsx(H,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>N(d.original),size:"small",children:e.jsx(Rr,{})})}),e.jsx(H,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Z(d.original),size:"small",children:e.jsx(Hr,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>_(d.original),size:"small",children:e.jsx(Zt,{})})})]})},{Header:"Status",accessor:"status",Cell:({row:d})=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",gap:"5px"},children:d.original.error?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:d.original.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:d.original.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:d.original.loaded&&d.original.started&&d.original.configured?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:d.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{status:d.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ze,{status:d.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ze,{status:d.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const d=F=>{F.src==="Matterbridge"&&F.dst==="Frontend"&&(F.method==="refresh_required"&&F.params.changed==="plugins"&&(a&&console.log(`HomePlugins received refresh_required: changed=${F.params.changed} and sending /api/plugins request`),n({id:l.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),F.method==="refresh_required"&&F.params.changed==="settings"&&(a&&console.log(`HomePlugins received refresh_required: changed=${F.params.changed} and sending /api/settings request`),n({id:l.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),F.id===l.current&&F.method==="/api/settings"&&(a&&console.log(`HomePlugins (id: ${F.id}) received settings:`,F.response),W(F.response.systemInformation),L(F.response.matterbridgeInformation)),F.id===l.current&&F.method==="/api/plugins"&&(a&&console.log(`HomePlugins (id: ${F.id}) received ${F.response.length} plugins:`,F.response),w(F.response)))};return s(d),a&&console.log("HomePlugins added WebSocket listener id:",l.current),()=>{f(d),a&&console.log("HomePlugins removed WebSocket listener")}},[s,f,n]),o.useEffect(()=>{i&&(a&&console.log("HomePlugins sending api requests"),n({id:l.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:l.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),o.useEffect(()=>{const d=localStorage.getItem("homePluginsColumnVisibility");d&&b(JSON.parse(d))},[]);const O=()=>{p(!$)},z=d=>{b(F=>{const ie={...F,[d]:!F[d]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(ie)),ie})},x=o.useRef(null),R=(d,F,ie,se)=>{a&&console.log(`handleActionWithConfirmCancel ${ie} ${se.name}`),x.current=se,t(d,F,ie,u,h)},u=d=>{a&&console.log(`handleConfirm action confirmed ${d} ${x.current.name}`),d==="remove"&&x.current?ce(x.current):d==="disable"&&x.current&&M(x.current),x.current=null},h=d=>{a&&console.log(`handleCancel action canceled ${d} ${x.current.name}`),x.current=null},C=d=>{a&&console.log("handleUpdatePlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name,restart:!1}})},V=d=>{a&&console.log("handleUpdateDevPlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name+"@dev",restart:!1}})},ce=d=>{a&&console.log("handleRemovePlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},xe=d=>{a&&console.log("handleRestartPlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},M=d=>{a&&console.log("handleEnableDisablePlugin plugin:",d.name,"enabled:",d.enabled),d.enabled===!0?(d.enabled=!1,n({id:l.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})):(d.enabled=!0,n({id:l.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}}))},m=d=>{a&&console.log(`handleHomepagePlugin plugin: ${d.name} homepage: ${d.homepage}`),d.homepage&&window.open(d.homepage,"_blank")},_=d=>{a&&console.log("handleSponsorPlugin plugin:",d.name,"funding:",d.funding),d.funding&&window.open(d.funding,"_blank")},N=d=>{a&&console.log("handleHelpPlugin plugin:",d.name,"help:",d.help),d.help&&window.open(d.help,"_blank")},Z=d=>{a&&console.log("handleChangelogPlugin plugin:",d.name,"changelog:",d.changelog),d.changelog&&window.open(d.changelog,"_blank")},[he,we]=o.useState({}),[q,k]=o.useState(!1),D=d=>{a&&console.log("handleConfigPlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),n({id:l.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),we(d),I()},I=()=>{k(!0)},g=()=>{k(!1)};return a&&console.log("HomePlugins rendering..."),i?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[e.jsx(ln,{open:q,onClose:g,plugin:he}),e.jsxs(De,{open:$,onClose:O,children:[e.jsx(Ne,{children:"Configure Plugins Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:P.map(d=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["description","actions","status"].includes(d.accessor),checked:U[d.accessor],onChange:()=>z(d.accessor)}),label:d.Header},d.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:O,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Plugins"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:O,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(dn,{data:E,columns:P,columnVisibility:U})})]}):e.jsx(Qe,{})}const pn=o.memo(cn),un=r=>{if(r===void 0||!r.qrPairingCode&&!r.manualPairingCode&&!r.fabricInformations&&!r.sessionInformations)return"red";if(r.commissioned===!1&&r.qrPairingCode&&r.manualPairingCode)return"var(--primary-color)";var c=0,i=0;for(const n of r.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&c++,n.numberOfActiveSubscriptions>0&&(i+=n.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(c===0||i===0)?"var(--secondary-color)":"var(--div-text-color)"},mn=r=>`${r.pluginName}::${r.serial}`;function gn({data:r,columns:c,columnVisibility:i}){const n=o.useMemo(()=>{const v=localStorage.getItem("homeDevicesColumnsSortBy");return v?JSON.parse(v):[{id:"name",desc:!1}]},[c]),s=o.useMemo(()=>c.filter(v=>i[v.accessor]),[i,c]),{getTableProps:f,getTableBodyProps:y,headerGroups:t,rows:l,prepareRow:S,state:{sortBy:W}}=Ae.useTable({columns:s,data:r,getRowId:mn,initialState:{sortBy:n}},Ae.useSortBy);return o.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(W))},[W]),e.jsxs("table",{...f(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:t.map(v=>e.jsx("tr",{...v.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:v.headers.map(L=>e.jsxs("th",{...L.getHeaderProps(L.noSort?void 0:L.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:[L.render("Header"),!L.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:L.isSorted?L.isSortedDesc?e.jsx(te,{path:Ft,size:"15px"}):e.jsx(te,{path:Lt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...y(),style:{border:"none",borderCollapse:"collapse"},children:l.map((v,L)=>(S(v),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...v.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:v.cells.map(E=>e.jsx("td",{...E.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:E.render("Cell")}))})))})]})}function hn({storeId:r,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:f,getUniqueId:y}=o.useContext(fe),[t,l]=o.useState(!1),[S,W]=o.useState(!0),[v,L]=o.useState(null),[E,w]=o.useState([]),[$,p]=o.useState([]),[U,b]=o.useState([]),[j,P]=o.useState([]),[O,z]=o.useState(!1),[x,R]=o.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),u=o.useRef(y()),h=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:M})=>M.original.reachable===!0?"Online":M.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(M,m)=>{const _=M.original.reachable===!0?1:M.original.reachable===!1?0:-1,N=m.original.reachable===!0?1:m.original.reachable===!1?0:-1;return _-N}},{Header:"Power",accessor:"powerSource",Cell:({row:M})=>M.original.powerSource==="ac"||M.original.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):M.original.powerSource==="ok"?e.jsx(Ct,{fontSize:"small",sx:{color:"green"}}):M.original.powerSource==="warning"?e.jsx(Ct,{fontSize:"small",sx:{color:"yellow"}}):M.original.powerSource==="critical"?e.jsx(Ct,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:M})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[M.original.matter!==void 0?e.jsx(H,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{onClick:()=>c(r===M.original.matter.id?v.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:M.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:un(M.original.matter)},children:e.jsx(tr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),M.original.configUrl?e.jsx(H,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{onClick:()=>window.open(M.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),M.original.selected!==void 0?e.jsx(H,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Le,{checked:M.original.selected,onChange:m=>xe(m,M.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],C=o.useCallback(M=>{M.selected=void 0;const m=E.find(Z=>Z.name===M.pluginName);if(!m)return console.error(`HomeDevices isSelected: plugin ${M.pluginName} not found for device ${M.deviceName} `),M.selected;const _=m.schemaJson?.properties?.whiteList?.selectFrom;let N=m.configJson?.postfix;return N===""&&(N=void 0),m.hasWhiteList===!0&&m.hasBlackList===!0&&_&&(M.selected=!0,_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(N?M.serial.replace("-"+N,""):M.serial)&&(M.selected=!0),_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(N?M.serial.replace("-"+N,""):M.serial)&&(M.selected=!1),_==="serial"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(N?M.serial.replace("-"+N,""):M.serial)&&(M.selected=!1),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(M.name)&&(M.selected=!0),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(M.name)&&(M.selected=!1),_==="name"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(M.name)&&(M.selected=!1)),M.selected},[E]);o.useEffect(()=>{const M=m=>{if(m.src==="Matterbridge"&&m.dst==="Frontend"){if(m.method==="refresh_required"&&(console.log(`HomeDevices received refresh_required: changed=${m.params.changed} and sending /api/plugins request`),n({id:u.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),m.method==="restart_required"&&(a&&console.log("HomeDevices received restart_required"),l(!0)),m.method==="restart_not_required"&&(a&&console.log("HomeDevices received restart_not_required"),l(!1)),m.method==="state_update"&&m.params.plugin&&m.params.serialNumber&&m.params.cluster.includes("BasicInformationServer")&&m.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${m.params.plugin} serial ${m.params.serialNumber} value ${m.params.value}`),p(_=>_.map(N=>N.pluginName===m.params.plugin&&N.serial===m.params.serialNumber?{...N,reachable:m.params.value}:N))),m.id===u.current&&m.method==="/api/settings"&&(a&&console.log(`HomeDevices (id: ${m.id}) received settings:`,m.response),L(m.response),l(m.response.matterbridgeInformation.restartRequired||m.response.matterbridgeInformation.fixedRestartRequired)),m.id===u.current&&m.method==="/api/plugins"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} plugins:`,m.response),m.response)){let _=!0;for(const N of m.response)N.enabled===!0&&(N.loaded!==!0||N.started!==!0||N.error===!0)&&(_=!1);if(!_)return;a&&console.log("HomeDevices reset plugins, devices and selectDevices"),W(!1),w(m.response),p([]),b([]),n({id:u.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),a&&console.log("HomeDevices sent /api/devices");for(const N of m.response)N.enabled===!0&&N.loaded===!0&&N.started===!0&&N.error!==!0&&(n({id:u.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),a&&console.log(`HomeDevices sent /api/select/devices for plugin: ${N.name}`))}if(m.id===u.current&&m.method==="/api/devices"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} devices:`,m.response),m.response)){for(const _ of m.response)_.selected=C(_);p(m.response)}m.id===u.current&&m.method==="/api/select/devices"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} selectDevices for plugin ${m.response&&m.response.length>0?m.response[0].pluginName:"no select devices"}:`,m.response),m.response&&m.response.length>0&&b(_=>{const N=_.filter(he=>he.pluginName!==m.response[0].pluginName),Z=m.response.map(he=>({...he,selected:C(he)}));return[...N,...Z]}))}};return s(M),a&&console.log(`HomeDevices added WebSocket listener id ${u.current}`),()=>{f(M),a&&console.log("HomeDevices removed WebSocket listener")}},[E,s,f,n,C]),o.useEffect(()=>{if($.length===0&&U.length===0)return;console.log(`HomeDevices mixing devices (${$.length}) and selectDevices (${U.length})`);const M=[];for(const m of $)M.push(m);for(const m of U)$.find(_=>_.pluginName===m.pluginName&&_.serial.includes(m.serial))||M.push(m);M.length>0&&(P(M),console.log(`HomeDevices mixed ${M.length} devices and selectDevices`))},[E,$,U,P]),o.useEffect(()=>{i&&(a&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:u.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:u.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),o.useEffect(()=>{const M=localStorage.getItem("homeDevicesColumnVisibility");if(M){const m=JSON.parse(M);m.powerSource===void 0&&(m.powerSource=!0),R(m),a&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const V=M=>{R(m=>{const _={...m,[M]:!m[M]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(_)),a&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(_),_),_})},ce=()=>{z(!O)},xe=(M,m)=>{console.log(`handleCheckboxChange: checkbox changed to ${M.target.checked} for device ${m.name} serial ${m.serial}`),P(_=>{const N=_.findIndex(he=>he.pluginName===m.pluginName&&he.serial===m.serial);if(N<0)return console.error(`handleCheckboxChange: device not found ${m.name} serial ${m.serial} id ${m.id}`),_;const Z=[..._];return Z[N]={...Z[N],selected:M.target.checked},Z}),M.target.checked?n({id:u.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}}):n({id:u.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}})};return a&&console.log("HomeDevices rendering..."),i?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs(De,{open:O,onClose:ce,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:h.map(M=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["name","actions"].includes(M.accessor),checked:x[M.accessor],onChange:()=>V(M.accessor)}),label:M.Header},M.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:ce,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:ce,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(gn,{data:j,columns:h,columnVisibility:x})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[S&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!S&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",$.length.toString(),"/",j.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Qe,{})}const fn=o.memo(hn);function xn(){const[r,c]=o.useState(null),[i,n]=o.useState(null),[s,f]=o.useState([]),[y]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,l]=o.useState(localStorage.getItem("homePageMode")??"devices"),[S,W]=o.useState(""),[v,L]=o.useState(!1),[E,w]=o.useState(!1),[$,p]=o.useState(null),{addListener:U,removeListener:b,online:j,sendMessage:P,logFilterLevel:O,logFilterSearch:z,autoScroll:x,getUniqueId:R}=o.useContext(fe),u=o.useRef(R());return o.useEffect(()=>{const h=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(Ie(C)&&C.method==="refresh_required"&&C.params.changed==="settings"&&(a&&console.log(`Home received refresh_required: changed=${C.params.changed} and sending /api/settings request`),P({id:u.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Be(C)&&C.method==="/api/settings"&&C.id===u.current&&(a&&console.log("Home received settings:",C.response),c(C.response.systemInformation),n(C.response.matterbridgeInformation),C.response.matterbridgeInformation.bridgeMode==="bridge"&&($||p("Matterbridge")),C.response.matterbridgeInformation.bridgeMode==="childbridge"&&s.length>0&&$===null&&!$&&s.length>0&&s[0].matter?.id&&p(s[0].matter.id),C.response.matterbridgeInformation.matterbridgeVersion&&W(`https://github.com/Luligu/matterbridge/blob/${C.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&C.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",C.response.matterbridgeInformation.frontendVersion):C.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&C.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",C.response.matterbridgeInformation.frontendVersion),w(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",C.response.matterbridgeInformation.matterbridgeVersion):C.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",C.response.matterbridgeInformation.matterbridgeVersion),L(!0)),C.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),l("devices")))),Be(C)&&C.method==="/api/plugins"&&C.id===u.current&&(a&&console.log(`Home received plugins (${i?.bridgeMode}):`,C.response),f(C.response),i?.bridgeMode==="childbridge"&&C.response.length>0&&!$&&C.response.length>0&&C.response[0].matter?.id&&p(C.response[0].matter.id)))};return U(h),a&&console.log(`Home added WebSocket listener id ${u.current}`),()=>{b(h),a&&console.log("Home removed WebSocket listener")}},[U,b,P,i,s,$]),o.useEffect(()=>{j&&(a&&console.log("Home received online"),P({id:u.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),P({id:u.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[j,P]),a&&console.log("Home rendering..."),!j||!r||!i?e.jsx(Qe,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(tn,{id:$}),e.jsx(Xo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[E&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},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(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx(Or,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),v&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(oe,{onClick:()=>window.open(S,"_blank"),endIcon:e.jsx(er,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx($r,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),y&&!i.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(on,{})]}),y&&e.jsx(pn,{storeId:$,setStoreId:p}),t==="devices"&&e.jsx(fn,{storeId:$,setStoreId:p}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',O,'" and search "',z,'" Scroll: ',x?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(ar,{})})]})]})]})}const bn=o.memo(xn),Gt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},vn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},yn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Kt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},jn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Cn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Sn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},wn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Mn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Tt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},kn=[256,257,268,269],In=[266,267],Dn=[259,260,261,271,272],Nn=[256,257,268,269,266,267,259,260,261];function G({icon:r,iconColor:c,cluster:i,value:n,unit:s,prefix:f}){return a&&console.log(`Render cluster "${i.clusterName}.${i.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${s}"`),f=f??!1,e.jsxs(X,{sx:Gt,children:[r&&Wt.cloneElement(r,{key:`${i.clusterId}-${i.attributeId}-icon`,sx:{...vn,color:c??"var(--primary-color)"}}),e.jsxs(X,{sx:{...Gt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&f===!0&&e.jsx(le,{sx:Kt,children:s},`${i.clusterId}-${i.attributeId}-unit`),e.jsx(le,{sx:yn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${i.clusterId}-${i.attributeId}-value`),s&&f===!1&&e.jsx(le,{sx:Kt,children:s},`${i.clusterId}-${i.attributeId}-unit`)]},`${i.clusterId}-${i.attributeId}-valueunitbox`)]},`${i.clusterId}-${i.attributeId}-box`)}function Pn({device:r,endpoint:c,id:i,deviceType:n,clusters:s}){const f=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let y="";return a&&console.log(`Device "${r.name}" endpoint "${c}" id "${i}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${s?.length}):`,s),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>y=`${t.attributeLocalValue} mV`),Nn.includes(n)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>y=`Level ${t.attributeValue}`),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>y=`Position ${t.attributeValue/100}%`),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>y=`Heat ${t.attributeValue/100}°C `),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>y=y+`Cool ${t.attributeValue/100}°C`),n===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>y=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>y=`${t.attributeLocalValue/1e3} V, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>y=y+`${t.attributeLocalValue/1e3} A, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>y=y+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[n===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:t.attributeLocalValue===!0?e.jsx(at,{}):e.jsx(Er,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(G,{icon:e.jsx(Ct,{}),cluster:t,value:t.attributeValue/2,unit:"%"})),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(G,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),kn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),In.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Dn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:"Oven"})),n===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(_r,{}),cluster:t,value:"Fridge"})),n===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(G,{icon:e.jsx(te,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(G,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(G,{icon:t.attributeValue==="1"?e.jsx(Ur,{}):e.jsx(zr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(G,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(_t,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===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(G,{icon:e.jsx(te,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===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(G,{icon:e.jsx(te,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(G,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:f[t.attributeLocalValue??0]})),n===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:t.attributeValue==="true"?e.jsx(to,{}):e.jsx(ro,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(G,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(oo,{}):e.jsx(no,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(io,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeValue/1e4)),unit:"lx"})),n===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(G,{icon:e.jsx(ao,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(X,{sx:jn,children:e.jsx(le,{sx:Cn,children:y})}),e.jsx(X,{sx:Sn,children:e.jsx(le,{sx:wn,children:r.name})}),e.jsxs(X,{sx:Mn,children:[a&&e.jsx(le,{sx:Tt,children:c}),e.jsx(le,{sx:Tt,children:i}),a&&e.jsxs(le,{sx:Tt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function Tn({filter:r}){const{online:c,sendMessage:i,addListener:n,removeListener:s,getUniqueId:f}=o.useContext(fe),[y,t]=o.useState(!1),[l,S]=o.useState({}),[W,v]=o.useState([]),[L,E]=o.useState([]),[w,$]=o.useState({}),[p,U]=o.useState({}),[b,j]=o.useState({}),[P,O]=o.useState(L),z=o.useRef(f()),x=()=>{t(!y)};return o.useEffect(()=>{const R=u=>{if(u.src==="Matterbridge"&&u.dst==="Frontend"){if(u.method==="refresh_required"&&(a&&console.log(`DevicesIcons received refresh_required: changed=${u.params.changed} and sending api requests`),i({id:z.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),u.method==="/api/settings"&&u.response&&(a&&console.log("DevicesIcons received settings:",u.response),S(u.response)),u.method==="/api/plugins"&&u.response&&(a&&console.log("DevicesIcons received plugins:",u.response),v(u.response)),u.method==="/api/devices"&&u.response){a&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),E(u.response);for(let h of u.response)a&&console.log("DevicesIcons sending /api/clusters"),i({id:z.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:h.pluginName,endpoint:h.endpoint}})}if(u.method==="/api/clusters"&&u.response){if(console.log(`DevicesIcons received for device "${u.response.deviceName}" serial "${u.response.serialNumber}" deviceType ${u.response.deviceTypes.join(" ")} clusters (${u.response.length}):`,u.response),u.response.length===0)return;const h=u.response.serialNumber;w[h]=[],p[h]=u.response.deviceTypes,b[h]=[];for(let C of u.response.clusters)w[h].find(V=>V.endpoint===C.endpoint)||w[h].push({endpoint:C.endpoint,id:C.id,deviceTypes:C.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(C.clusterName)&&b[h].push(C);$({...w}),U({...p}),j({...b}),a&&console.log(`DevicesIcons endpoints for "${h}":`,w[h]),a&&console.log(`DevicesIcons deviceTypes for "${h}":`,p[h]),a&&console.log(`DevicesIcons clusters for "${h}":`,b[h])}}};return n(R),a&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{s(R),a&&console.log("DevicesIcons useEffect webSocket unmounted")}},[n,s,i]),o.useEffect(()=>(a&&console.log("DevicesIcons useEffect online mounting"),c&&(a&&console.log("DevicesIcons useEffect online sending api requests"),i({id:z.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),a&&console.log("DevicesIcons useEffect online mounted"),()=>{a&&console.log("DevicesIcons useEffect online unmounted")}),[c,i]),o.useEffect(()=>{if(r===""){O(L);return}const R=L.filter(u=>u.name.toLowerCase().includes(r)||u.serial.toLowerCase().includes(r));O(R)},[L,r]),a&&console.log("DevicesIcons rendering..."),e.jsxs(e.Fragment,{children:[e.jsxs(De,{open:y,onClose:x,PaperProps:{style:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--primary-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}},children:[e.jsx(Ne,{children:"Configure accessories"}),e.jsx(Pe,{}),e.jsx(We,{children:e.jsx(oe,{onClick:x,children:"Close"})})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:P.map(R=>w[R.serial]&&w[R.serial].map(u=>u.deviceTypes.map(h=>e.jsx(Pn,{device:R,endpoint:u.endpoint,id:u.id,deviceType:h,clusters:b[R.serial].filter(C=>C.endpoint===u.endpoint)}))))})]})}const sr=[{Header:"Plugin name",accessor:"pluginName"},{Header:"Device type",accessor:"type"},{Header:"Endpoint",accessor:"endpoint"},{Header:"Name",accessor:"name"},{Header:"Serial number",accessor:"serial"},{Header:"Unique ID",accessor:"uniqueId"},{Header:"Url",accessor:"configUrl"},{Header:"Config",accessor:"configButton",noSort:!0,Cell:({row:r})=>r.original.configUrl?e.jsx(B,{onClick:()=>window.open(r.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],lr=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:r})=>Array.isArray(r)?r.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):r},{Header:"Cluster Name",accessor:"clusterName"},{Header:"Cluster ID",accessor:"clusterId"},{Header:"Attribute Name",accessor:"attributeName"},{Header:"Attribute ID",accessor:"attributeId"},{Header:"Attribute Value",accessor:"attributeValue",Cell:({value:r})=>e.jsx(H,{title:r,componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r})})}],Wn=r=>`${r.pluginName}::${r.uniqueId}`,Fn=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Ln({data:r,columnVisibility:c,setPlugin:i,setEndpoint:n,setDeviceName:s}){const[f,y]=o.useState(null),t=o.useMemo(()=>sr.filter(w=>c[w.accessor]),[c]),{getTableProps:l,getTableBodyProps:S,headerGroups:W,rows:v,prepareRow:L}=Ae.useTable({columns:t,data:r,getRowId:Wn},Ae.useSortBy),E=w=>{if(w.id===f){y(null),i(null),n(null),s(null),a&&console.log("Device unclicked:",w.id,"selectedDeviceIndex:",f);return}y(w.id),i(w.original.pluginName),n(w.original.endpoint),s(w.original.name),a&&console.log("Device clicked:",w.id,"selectedDeviceIndex:",f,"pluginName:",w.original.pluginName,"endpoint:",w.original.endpoint)};return e.jsxs("table",{...l(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:W.map(w=>e.jsx("tr",{...w.getHeaderGroupProps(),children:w.headers.map($=>e.jsxs("th",{...$.getHeaderProps($.noSort?void 0:$.getSortByToggleProps()),children:[$.render("Header"),!$.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:$.isSorted?$.isSortedDesc?e.jsx(te,{path:Ft,size:"15px"}):e.jsx(te,{path:Lt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...S(),children:v.map((w,$)=>(L(w),e.jsx("tr",{className:$%2===0?"table-content-even":"table-content-odd",...w.getRowProps(),onClick:()=>E(w),style:{backgroundColor:f===w.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:w.cells.map(p=>e.jsx("td",{...p.getCellProps(),children:p.render("Cell")}))})))})]})}function Rn({data:r,columnVisibility:c}){const i=o.useMemo(()=>lr.filter(l=>c[l.accessor]),[c]),{getTableProps:n,getTableBodyProps:s,headerGroups:f,rows:y,prepareRow:t}=Ae.useTable({columns:i,data:r,getRowId:Fn},Ae.useSortBy);return e.jsxs("table",{...n(),style:{margin:"-1px"},children:[e.jsx("thead",{children:f.map(l=>e.jsx("tr",{...l.getHeaderGroupProps(),children:l.headers.map(S=>e.jsx("th",{...S.getHeaderProps(),children:S.render("Header")}))}))}),e.jsx("tbody",{...s(),children:y.map((l,S)=>(t(l),e.jsx("tr",{className:S%2===0?"table-content-even":"table-content-odd",...l.getRowProps(),children:l.cells.map(W=>e.jsx("td",{...W.getCellProps(),children:W.render("Cell")}))})))})]})}function Hn(){const{online:r,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=o.useContext(fe),[f,y]=o.useState([]),[t,l]=o.useState([]),[S,W]=o.useState(null),[v,L]=o.useState(null),[E,w]=o.useState(null),[$,p]=o.useState(0),[U,b]=o.useState(!1),[j,P]=o.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[O,z]=o.useState(!1),[x,R]=o.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[u,h]=o.useState(""),[C,V]=o.useState(f),[ce,xe]=o.useState("icon"),M=o.useRef(s());o.useEffect(()=>{const q=k=>{if(a&&console.log("Devices received WebSocket Message:",k),k.src==="Matterbridge"&&k.dst==="Frontend"&&(k.method==="refresh_required"&&k.params.changed==="devices"&&(a&&console.log(`Devices received refresh_required: changed=${k.params.changed} and sending /api/devices request`),c({id:M.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),k.method==="/api/devices"&&(a&&console.log(`Devices received ${k.response.length} devices:`,k.response),y(k.response)),k.method==="/api/clusters")){console.log(`Devices received ${k.response.length} clusters:`,k.response),l(k.response.clusters);const D={};for(const I of k.response.clusters)a&&console.log("Cluster:",I.endpoint),D[I.endpoint]?D[I.endpoint]++:D[I.endpoint]=1;p(Object.keys(D).length)}};return i(q),a&&console.log("Devices added WebSocket listener"),()=>{n(q),a&&console.log("Devices removed WebSocket listener")}},[i,n,c]),o.useEffect(()=>{r&&(a&&console.log("Devices sending api requests"),c({id:M.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:M.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:M.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,c]),o.useEffect(()=>{S&&v&&(a&&console.log("Devices sending /api/clusters"),c({id:M.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:S,endpoint:v}}))},[S,v,c]);const m=()=>{b(!U)},_=q=>{P(k=>{const D={...k,[q]:!k[q]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(D)),D})};o.useEffect(()=>{const q=localStorage.getItem("devicesColumnVisibility");q&&P(JSON.parse(q))},[]);const N=()=>{z(!O)},Z=q=>{R(k=>{const D={...k,[q]:!k[q]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(D)),D})};o.useEffect(()=>{const q=localStorage.getItem("clustersColumnVisibility");q&&R(JSON.parse(q))},[]);const he=q=>{h(q.target.value.toLowerCase()),localStorage.setItem("devicesFilter",q.target.value.toLowerCase())},we=q=>{xe(q),localStorage.setItem("devicesViewMode",q)};return o.useEffect(()=>{if(u===""){V(f);return}const q=f.filter(k=>k.name.toLowerCase().includes(u)||k.serial.toLowerCase().includes(u));V(q)},[f,u]),o.useEffect(()=>{const q=localStorage.getItem("devicesFilter");q&&h(q)},[]),o.useEffect(()=>{const q=localStorage.getItem("devicesViewMode");q&&xe(q)},[]),a&&console.log("Devices rendering..."),r?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:u,onChange:he,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(B,{onClick:()=>we("table"),"aria-label":"Table View",disabled:ce==="table",children:e.jsx(H,{title:"Table View",children:e.jsx(so,{style:{color:ce==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(B,{onClick:()=>we("icon"),"aria-label":"Icon View",disabled:ce==="icon",children:e.jsx(H,{title:"Icon View (beta)",children:e.jsx(lo,{style:{color:ce==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(De,{open:U,onClose:m,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:sr.map(q=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["pluginName","name","configButton"].includes(q.accessor),checked:j[q.accessor],onChange:()=>_(q.accessor)}),label:q.Header},q.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:m,children:"Close"})})]}),ce==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${S&&v?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Registered devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:m,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Ln,{data:C,columnVisibility:j,setPlugin:W,setEndpoint:L,setDeviceName:w})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total devices: ",C.length.toString()]})})]}),e.jsxs(De,{open:O,onClose:N,children:[e.jsx(Ne,{children:"Configure Clusters Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:lr.map(q=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["clusterName","attributeName","attributeValue"].includes(q.accessor),checked:x[q.accessor],onChange:()=>Z(q.accessor)}),label:q.Header},q.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:N,children:"Close"})})]}),ce==="table"&&S&&v&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsxs("div",{className:"MbfWindowHeaderText",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[e.jsxs("p",{style:{margin:"0px",padding:"0px"},children:['Clusters for device "',E,'" on endpoint ',v]}),e.jsx(B,{onClick:N,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Rn,{data:t,columnVisibility:x})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total child endpoints: ",$-1]})})]}),ce==="icon"&&e.jsx(Tn,{filter:u,devices:C})]}):e.jsx(Qe,{})}const On=o.memo(Hn);function $n(){const[r,c]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,n]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[s,f]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:y,setLogFilters:t,online:l,setAutoScroll:S}=o.useContext(fe),W=w=>{c(w.target.value),t(w.target.value,i),localStorage.setItem("logFilterLevel",w.target.value),a&&console.log("handleChangeLevel called with value:",w.target.value)},v=w=>{n(w.target.value),t(r,w.target.value),localStorage.setItem("logFilterSearch",w.target.value),a&&console.log("handleChangeSearch called with value:",w.target.value)},L=w=>{f(w.target.checked),S(w.target.checked),localStorage.setItem("logAutoScroll",w.target.value?"true":"false"),a&&console.log("handleAutoScrollChange called with value:",w.target.checked)},E=()=>{a&&console.log("handleClearLogsClick called"),y([])};return a&&console.log("Logs rendering..."),l?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(At,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(ot,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:W,children:[e.jsx(T,{value:"debug",children:"Debug"}),e.jsx(T,{value:"info",children:"Info"}),e.jsx(T,{value:"notice",children:"Notice"}),e.jsx(T,{value:"warn",children:"Warn"}),e.jsx(T,{value:"error",children:"Error"}),e.jsx(T,{value:"fatal",children:"Fatal"})]}),e.jsx(At,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:i,onChange:v,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Fe,{control:e.jsx(Le,{checked:s,onChange:L}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(H,{title:"Clear the logs",children:e.jsx(oe,{onClick:E,endIcon:e.jsx(St,{}),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(ar,{})})]}):e.jsx(Qe,{})}const En=({open:r,ip:c,onClose:i,onSave:n})=>{const s=c?c.split(".").slice(0,3).join(".")+".1":"",[f,y]=o.useState("dhcp"),[t,l]=o.useState({ip:c??"",subnet:"255.255.255.0",gateway:s,dns:s}),S=L=>E=>{l({...t,[L]:E.target.value})},W=()=>{i()},v=()=>{const L=f==="static"?{type:f,...t}:{type:f};n(L),i()};return e.jsxs(De,{open:r,onClose:(L,E)=>{E==="backdropClick"||E==="escapeKeyDown"||i()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ne,{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(Pe,{dividers:!0,children:[e.jsxs(or,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(nr,{row:!0,value:f,onChange:L=>y(L.target.value),children:[e.jsx(Fe,{value:"dhcp",control:e.jsx(wt,{}),label:"DHCP"}),e.jsx(Fe,{value:"static",control:e.jsx(wt,{}),label:"Static"})]})]}),f==="static"&&e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:S("ip")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:S("subnet")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:S("gateway")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:S("dns")})})]})]}),e.jsxs(We,{children:[e.jsx(oe,{onClick:W,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,children:"Save"})]})]})},Vn=({open:r,onClose:c,onSave:i})=>{const[n,s]=o.useState(""),[f,y]=o.useState(""),t=E=>{s(E.target.value)},l=E=>{y(E.target.value)},S=n.length>0&&n===f,W=()=>{c()},v=()=>{S&&(i(n),c())},L=()=>{i(""),c()};return e.jsxs(De,{open:r,onClose:(E,w)=>{w==="backdropClick"||w==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ne,{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(Pe,{dividers:!0,children:e.jsx(or,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:n,onChange:t})}),e.jsx(_e,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:f,onChange:l,error:f!==""&&n!==f,helperText:f!==""&&n!==f?"Passwords do not match":""})})]})})}),e.jsxs(We,{children:[e.jsx(oe,{onClick:W,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,disabled:!S,children:"Change"}),e.jsx(oe,{variant:"contained",onClick:L,children:"Reset"})]})]})};function _n(){const{online:r,addListener:c,removeListener:i,sendMessage:n,getUniqueId:s}=o.useContext(fe),[f,y]=o.useState(null),[t,l]=o.useState(null),S=o.useRef(s());return o.useEffect(()=>{const W=v=>{v.src==="Matterbridge"&&v.dst==="Frontend"&&(v.method==="refresh_required"&&v.params.changed==="settings"&&(a&&console.log(`Settings received refresh_required: changed=${v.params.changed} and sending /api/settings request`),n({id:S.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),v.method==="/api/settings"&&(a&&console.log("Settings received /api/settings:",v.response),y(v.response.matterbridgeInformation),l(v.response.systemInformation)))};return c(W),a&&console.log("Settings added WebSocket listener"),()=>{i(W),a&&console.log("Settings removed WebSocket listener")}},[c,i,n]),o.useEffect(()=>{r&&(a&&console.log("Settings received online"),n({id:S.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,n]),f?(a&&console.log("Settings rendering..."),r?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(An,{matterbridgeInfo:f,systemInfo:t}),e.jsx(Un,{matterbridgeInfo:f}),e.jsx(zn,{matterbridgeInfo:f})]})}):e.jsx(Qe,{})):null}function An({matterbridgeInfo:r,systemInfo:c}){const{sendMessage:i,getUniqueId:n}=o.useContext(fe),[s,f]=o.useState("bridge"),[y,t]=o.useState("Info"),[l,S]=o.useState(!1),[W,v]=o.useState("dark"),[L,E]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[w,$]=o.useState(localStorage.getItem("homePageMode")??"logs"),[p,U]=o.useState(localStorage.getItem("virtualMode")??"outlet"),b=o.useRef(n()),[j,P]=o.useState(!1),O=()=>P(!1),z=N=>{a&&console.log("handleSaveNetConfig called with config:",N),i({id:b.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:N})},[x,R]=o.useState(!1),u=()=>R(!1),h=N=>{a&&console.log("handleSaveChangePassword called with password:",N),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:N}})};o.useEffect(()=>{r.bridgeMode!==void 0&&(f(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),S(r.fileLogger),U(r.virtualMode))},[r]),o.useEffect(()=>{const N=localStorage.getItem("frontendTheme");N&&v(N)},[]);const C=N=>{a&&console.log("handleChangeBridgeMode called with value:",N.target.value),f(N.target.value),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:N.target.value}})},V=N=>{a&&console.log("handleChangeMbLoggerLevel called with value:",N.target.value),t(N.target.value),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:N.target.value}})},ce=N=>{a&&console.log("handleLogOnFileMbChange called with value:",N.target.checked),S(N.target.checked),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:N.target.checked}})},xe=N=>{const Z=N.target.value;a&&console.log("handleChangeTheme called with value:",Z),v(Z),localStorage.setItem("frontendTheme",Z),document.body.setAttribute("frontend-theme",Z)},M=N=>{const Z=N.target.checked;a&&console.log("handleChangeHomePagePlugins called with value:",Z),E(Z),localStorage.setItem("homePagePlugins",Z?"true":"false")},m=N=>{const Z=N.target.value;a&&console.log("handleChangeHomePageMode called with value:",Z),$(Z),localStorage.setItem("homePageMode",Z)},_=N=>{const Z=N.target.value;a&&console.log("handleChangeVirtualMode called with value:",Z),U(Z),localStorage.setItem("virtualMode",Z),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:Z}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(En,{open:j,ip:c.ipv4Address,onClose:O,onSave:z}),e.jsx(Vn,{open:x,onClose:u,onSave:h}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(nr,{row:!0,name:"mode-buttons-group",value:s,onChange:C,children:[e.jsx(Fe,{value:"bridge",control:e.jsx(wt,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(Fe,{value:"childbridge",control:e.jsx(wt,{}),label:"Childbridge",disabled:r.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:y,onChange:V,children:[e.jsx(T,{value:"Debug",children:"Debug"}),e.jsx(T,{value:"Info",children:"Info"}),e.jsx(T,{value:"Notice",children:"Notice"}),e.jsx(T,{value:"Warn",children:"Warn"}),e.jsx(T,{value:"Error",children:"Error"}),e.jsx(T,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Le,{checked:l,onChange:ce,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:W,onChange:xe,children:[e.jsx(T,{value:"classic",children:"Classic"}),e.jsx(T,{value:"light",children:"Light"}),e.jsx(T,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Le,{checked:L,onChange:M,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:w,onChange:m,children:[e.jsx(T,{value:"logs",children:"Logs"}),e.jsx(T,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:p,onChange:_,children:[e.jsx(T,{value:"disabled",children:"Disabled"}),e.jsx(T,{value:"outlet",children:"Outlet"}),e.jsx(T,{value:"light",children:"Light"}),e.jsx(T,{value:"switch",children:"Switch"}),e.jsx(T,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Change password"})}),r.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>P(!0),children:"Configure IP"})})]})})]})}function Un({matterbridgeInfo:r}){const{sendMessage:c,getUniqueId:i}=o.useContext(fe),[n,s]=o.useState("Info"),[f,y]=o.useState(!1),[t,l]=o.useState(""),[S,W]=o.useState(""),[v,L]=o.useState(""),[E,w]=o.useState(),[$,p]=o.useState(),[U,b]=o.useState(),j=o.useRef(i());o.useEffect(()=>{r.bridgeMode!==void 0&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),y(r.matterFileLogger),l(r.matterMdnsInterface),W(r.matterIpv4Address),L(r.matterIpv6Address),w(r.matterPort),p(r.matterDiscriminator),b(r.matterPasscode))},[r]);const P=V=>{a&&console.log("handleChangeMjLoggerLevel called with value:",V.target.value),s(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:V.target.value}})},O=V=>{a&&console.log("handleLogOnFileMjChange called with value:",V.target.checked),y(V.target.checked),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:V.target.checked}})},z=V=>{a&&console.log("handleChangeMdnsInterface called with value:",V.target.value),l(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:V.target.value}})},x=V=>{a&&console.log("handleChangeIpv4Address called with value:",V.target.value),W(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:V.target.value}})},R=V=>{a&&console.log("handleChangeIpv6Address called with value:",V.target.value),L(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:V.target.value}})},u=V=>{a&&console.log("handleChangeMatterPort called with value:",V.target.value),w(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:V.target.value}})},h=V=>{a&&console.log("handleChangeMatterDiscriminator called with value:",V.target.value),p(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:V.target.value}})},C=V=>{a&&console.log("handleChangemMatterPasscode called with value:",V.target.value),b(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:V.target.value}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:P,children:[e.jsx(T,{value:"Debug",children:"Debug"}),e.jsx(T,{value:"Info",children:"Info"}),e.jsx(T,{value:"Notice",children:"Notice"}),e.jsx(T,{value:"Warn",children:"Warn"}),e.jsx(T,{value:"Error",children:"Error"}),e.jsx(T,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Le,{checked:f,onChange:O,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,onChange:z,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:S,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:v,onChange:R,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:E,onChange:u,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:$,onChange:h,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:U,onChange:C,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function zn({matterbridgeInfo:r}){return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(qe,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(qe,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(qe,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(qe,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(qe,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(qe,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(qe,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function qe({value:r,label:c}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:c,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}function qn(r,c,i){const n=r?.[i],s=c?.[i];return n==null&&s==null?0:n==null?-1:s==null?1:typeof n=="boolean"&&typeof s=="boolean"?n===s?0:n?1:-1:typeof n=="number"&&typeof s=="number"?n-s:String(n).localeCompare(String(s))}function Bn({name:r,columns:c,rows:i,getRowKey:n,footerLeft:s,footerRight:f}){const y=o.useRef(new WeakMap),t=o.useRef(1),l=x=>{if(typeof n=="string"&&x&&x[n]!=null)return x[n];if(typeof n=="function"){const h=n(x);if(h!=null)return h}const R=c?.[0]?.id;if(R&&x&&x[R]!=null)return x[R];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let u=y.current.get(x);return u||(u=`rk_${t.current++}`,y.current.set(x,u)),u},[S,W]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[v,L]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[E,w]=o.useState(!1),[$,p]=o.useState(()=>{try{const x=localStorage.getItem(`${r}_column_visibility`);if(x)return JSON.parse(x)}catch{}return{}}),U=o.useMemo(()=>{const x={};for(const R of c)R.hidden||(x[R.id]=R.required?!0:$[R.id]!==!1);return x},[c,$]),b=o.useMemo(()=>{if(!S||!v)return i;const x=c.find(u=>u.id===S);if(!x||x.nosort)return i;const R=i.map((u,h)=>({el:u,index:h}));return R.sort((u,h)=>{const C=qn(u.el,h.el,S);return C!==0?v==="asc"?C:-C:u.index-h.index}),R.map(u=>u.el)},[i,S,v,c]),j=x=>{if(S!==x||!S){W(x),L("asc"),localStorage.setItem(`${r}_table_order_by`,x),localStorage.setItem(`${r}_table_order`,"asc");return}if(v==="asc"){L("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}W(null),L(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},P=()=>{w(!E)},O=x=>{p(R=>{const u=c.find(V=>V.id===x);if(u&&u.required)return R;const h=U[x]!==!1,C={...R};h?C[x]=!1:delete C[x];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(C))}catch{}return C})},z=()=>{const x={};p(x);try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(x))}catch{}};return console.log(`Rendering table ${r}${S&&v?` ordered by ${S}:${v}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(De,{open:E,onClose:(x,R)=>{R==="backdropClick"||R==="escapeKeyDown"||P()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ne,{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 ${r} columns`})]})}),e.jsx(Pe,{children:e.jsx(st,{children:c.filter(x=>!x.hidden).map(x=>e.jsx(Fe,{control:e.jsx(Le,{disabled:!!x.required,checked:x.required?!0:U[x.id]!==!1,onChange:()=>O(x.id)}),label:x.label},x.id))})}),e.jsxs(We,{children:[e.jsx(oe,{onClick:z,children:"Reset"}),e.jsx(oe,{variant:"contained",onClick:x=>{if(x?.currentTarget&&typeof x.currentTarget.blur=="function")try{x.currentTarget.blur()}catch{}const R=document.activeElement;if(R&&R instanceof HTMLElement&&typeof R.blur=="function")try{R.blur()}catch{}P()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:r}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:x=>{if(x?.currentTarget?.blur)try{x.currentTarget.blur()}catch{}P()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:`Configure ${r} columns`,children:e.jsx(te,{path:Lo,size:"20px",style:{color:"var(--header-text-color)"}})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${r} 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:c.map(x=>{if(x.hidden||!x.required&&U[x.id]===!1)return null;const R=!x.nosort,u=R&&S===x.id&&!!v;return e.jsxs("th",{onClick:R?()=>j(x.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:x.minWidth,maxWidth:x.maxWidth,textAlign:x.align||"left",cursor:R?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},"aria-sort":R?u?v==="asc"?"ascending":"descending":"none":void 0,children:[x.label,u&&e.jsxs("span",{style:{marginLeft:6},children:[v==="asc"&&e.jsx(te,{path:Lt,size:"15px"}),v==="desc"&&e.jsx(te,{path:Ft,size:"15px"})]})]},x.id)})})}),e.jsx("tbody",{children:b.map((x,R)=>{const u=l(x);return e.jsx("tr",{className:R%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:c.map(h=>{if(h.hidden||!h.required&&U[h.id]===!1)return null;const C=x[h.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:h.align||"left",padding:"4px 8px",margin:"0",maxWidth:h.maxWidth,whiteSpace:h.maxWidth?"nowrap":void 0,overflow:h.maxWidth?"hidden":void 0,textOverflow:h.maxWidth?"ellipsis":void 0},children:typeof h.render=="function"?h.render(C,u,x,h):typeof C=="boolean"?e.jsx(Le,{checked:C,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):h.format&&typeof C=="number"?h.format(C):C!=null?String(C):null},h.id)})},u)})})]})}),e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:s}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:f})]})]})}const Jn=o.memo(Bn);function Qn(){const{online:r,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=o.useContext(fe),{showSnackbarMessage:f,closeSnackbarMessage:y}=o.useContext(nt),[t,l]=o.useState(null),[S,W]=o.useState(null),[v,L]=o.useState(null),[E,w]=o.useState(null),[$,p]=o.useState({cpuUsage:0}),[U,b]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[j,P]=o.useState({systemUptime:"",processUptime:""}),O=o.useRef(-1),[z,x]=o.useState(()=>dr);O.current||(O.current=s(),console.log("Test uniqueId:",O)),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const u=h=>{if(h.src==="Matterbridge"&&h.dst==="Frontend"){if(Ie(h)&&h.method==="restart_required"&&(console.log("Test received restart_required"),f("Restart required",0)),Ie(h)&&h.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${h.params.changed} and sending api requests`),f("Refresh required",0),c({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),Ie(h)&&h.method==="memory_update"&&(console.log("Test received memory_update",h),b(h.params)),Ie(h)&&h.method==="cpu_update"&&(console.log("Test received cpu_update",h),p(h.params)),Ie(h)&&h.method==="uptime_update"&&(console.log("Test received uptime_update",h),P(h.params)),Be(h)&&h.method==="/api/settings"&&h.response&&(console.log("Test received /api/settings:",h.response),f("Test received /api/settings"),l(h.response)),Be(h)&&h.method==="/api/plugins"&&h.response&&(console.log(`Test received ${h.response.length} plugins:`,h.response),f("Test received /api/plugins"),W(h.response)),Be(h)&&h.method==="/api/devices"&&h.response){console.log(`Test received ${h.response.length} devices:`,h.response),f("Test received /api/devices"),L(h.response);for(const C of h.response)console.log("Test sending /api/clusters for device:",C.pluginName,C.name,C.endpoint),c({id:O.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:C.pluginName,endpoint:C.endpoint}})}Be(h)&&h.method==="/api/clusters"&&h.response&&(console.log(`Test received ${h.response.clusters.length} clusters for device ${h.response.deviceName} endpoint ${h.response.endpoint}:`,h),f("Test received /api/clusters"),w(h.response))}};return i(u),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(u),console.log("Test useEffect WebSocketMessage unmounted")}},[i,n,c,f]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),c({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,c,f]);const R=o.useCallback(u=>String(u.code),[]);return console.log("Test rendering..."),r?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},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("div",{style:{margin:"0",padding:"0",gap:"0",width:"1200px",maxWidth:"1200px",height:"600px",maxHeight:"600px",overflow:"hidden",backgroundColor:"var(--div-bg-color)",border:"1px solid #0004ffff"},children:e.jsx(Jn,{name:"Test",columns:Kn,rows:z,getRowKey:R,footerLeft:"Left Footer",footerRight:"Right Footer"})}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>{console.log("Test button clicked"),f("Test button clicked"),y("Refresh required"),y("Restart required"),y("Test permanent message removal")},children:"Test"}),e.jsx(oe,{variant:"outlined",onClick:()=>{x(u=>{const h=u.findIndex(xe=>xe.code==="F123");if(h===-1)return u;const C=u[h],V={...C,population:(C.population||0)+1},ce=u.slice();return ce[h]=V,ce})},children:"Update F123"})]})]})}):e.jsx(Qe,{})}const Gn=o.memo(Qn),Kn=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(r,c,i,n)=>e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",borderRadius:"8px",backgroundColor:"var(--chip-bg, #e6f4ff)",color:"var(--chip-fg, #0550ae)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"0.85em"},children:String(r)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:r=>r.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(r,c,i,n)=>i.isIsland?"🏝️":"🏞️"}];function Ce(r,c,i,n,s){const f=i/n;return{name:r,code:c,population:i,size:n,density:f,isIsland:s}}const dr=[Ce("India","IN",1324171354,3287263,!1),Ce("China","CN",1403500365,9596961,!1),Ce("Italy","IT",60483973,301340,!1),Ce("United States","US",327167434,9833520,!1),Ce("Canada is a truly wonderful country","CA",37602103,9984670,!1),Ce("Australia","AU",25475400,7692024,!0),Ce("Germany","DE",83019200,357578,!1),Ce("Ireland","IE",4857e3,70273,!0),Ce("Mexico","MX",126577691,1972550,!1),Ce("Japan","JP",126317e3,377973,!0),Ce("France","FR",67022e3,640679,!1),Ce("United Kingdom","GB",67545757,242495,!0),Ce("Russia","RU",146793744,17098246,!1),Ce("Nigeria","NG",200962417,923768,!1),Ce("Brazil","BR",210147125,8515767,!1)],Yt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Xt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let r=0;r<2e3;r++){const c=`${Yt[r%Yt.length]}${Xt[r%Xt.length]} ${r}`,i=`F${r.toString().padStart(3,"0")}`,n=Math.floor(Math.random()*1e9),s=Math.floor(Math.random()*1e7),f=Math.random()<.2;dr.push(Ce(c,i,n,s,f))}function Yn(r,c){a&&console.log("getCssVariable:",r,"defaultValue",c);const i=getComputedStyle(document.body).getPropertyValue(r).trim();return i||console.error("getCssVariable: undefined",i),i||c}function Xn(r){return co({palette:{primary:{main:r},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)"}}}}})}let a=!1;const Zn=()=>{a=!a},cr=o.createContext(void 0);function ei({children:r}){const[c,i]=o.useState(!1),[n,s]=o.useState(""),f=async y=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(t.ok){const{valid:l}=await t.json();l?i(!0):y!==""&&s("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(cr.Provider,{value:{loggedIn:c,logIn:f,errorMessage:n},children:r})}function ti(){const[r,c]=o.useState(""),i=o.useContext(cr),[n,s]=o.useState("#1976d2");if(!i)throw new Error("AuthContext not found");const{loggedIn:f,logIn:y,errorMessage:t}=i,l=w=>{w.preventDefault(),y(r)},S={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},W={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)"},v={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)"};o.useEffect(()=>{a&&console.log("Setting frontend theme");const w=localStorage.getItem("frontendTheme");a&&console.log("Saved theme:",w),w?document.body.setAttribute("frontend-theme",w):document.body.setAttribute("frontend-theme","dark");const $=Yn("--primary-color","#1976d2");a&&console.log("Primary color from CSS:",$),s($)},[]);const L=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";console.log(`Loading App.js with href="${window.location.href}" and pathname="${window.location.pathname}" >>> baseName="${L}"`);const E=Xn(n);return y(""),f?e.jsx(po,{theme:E,children:e.jsx(jr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(zo,{children:e.jsx(qo,{children:e.jsx(fr,{basename:L,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Jo,{}),e.jsxs(xr,{children:[e.jsx(Xe,{path:"/",element:e.jsx(bn,{})}),e.jsx(Xe,{path:"/devices",element:e.jsx(On,{})}),e.jsx(Xe,{path:"/log",element:e.jsx($n,{})}),e.jsx(Xe,{path:"/settings",element:e.jsx(_n,{})}),e.jsx(Xe,{path:"/test",element:e.jsx(Gn,{})}),e.jsx(Xe,{path:"*",element:e.jsx(br,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:S,children:e.jsxs("form",{onSubmit:l,style:W,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:"64px",width:"64px"}}),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:r,onChange:w=>c(w.target.value),style:v,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:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function ri(){return e.jsx(ei,{children:e.jsx(ti,{})})}vr.createRoot(document.getElementById("root")).render(e.jsx(Wt.StrictMode,{children:e.jsx(ri,{})}));
|