matterbridge 3.2.9-dev-20250922-6e00637 → 3.2.9-dev-20250922-517cae7

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/CHANGELOG.md CHANGED
@@ -8,11 +8,11 @@ If you like this project and find it useful, please consider giving it a star on
8
8
  <img src="bmc-button.svg" alt="Buy me a coffee" width="120">
9
9
  </a>
10
10
 
11
- ## [3.2.9] - 2025-09-??
11
+ ## [3.2.9] - Not released
12
12
 
13
13
  ### Breaking Changes
14
14
 
15
- - [profiles]: Profile management has changed. Now, each profile has its own independent directory with storage, matterstorage, plugin config, and plugin directory. This means that if you are using profiles, Matterbridge will not find the old profile data.
15
+ - [profiles]: Profile management has changed. Now, each profile has its own independent directories under `profiles` with storage, matterstorage, plugin config, and plugin directory. This means that if you are using profiles, Matterbridge will not find the old profile data. This allows to run multiple instances of matterbridge (change the frontend port and the matter port for each profile) or to simply make a test of a new plugin without modifing your production setup.
16
16
 
17
17
  ### Added
18
18
 
@@ -27,6 +27,8 @@ If you like this project and find it useful, please consider giving it a star on
27
27
 
28
28
  ### Fixed
29
29
 
30
+ - [frontend]: Fix default values for homePageMode in MatterbridgeSettings
31
+
30
32
  <a href="https://www.buymeacoffee.com/luligugithub">
31
33
  <img src="bmc-button.svg" alt="Buy me a coffee" width="80">
32
34
  </a>
package/README-NGINX.md CHANGED
@@ -18,9 +18,18 @@
18
18
 
19
19
  ## Run matterbridge with nginx
20
20
 
21
- ### Create a basic nginx configuration file that redirect to http://yourhost:8283
21
+ ### Install nginx if it is not installed
22
22
 
23
+ ```bash
24
+ sudo apt update
25
+ sudo apt install nginx
23
26
  ```
27
+
28
+ ### Create a basic nginx configuration file that redirect from http://yourhost to http://yourhost:8283
29
+
30
+ Create or edit the matterbridge configuration file
31
+
32
+ ```bash
24
33
  sudo nano /etc/nginx/sites-available/matterbridge
25
34
  ```
26
35
 
@@ -33,7 +42,7 @@ server {
33
42
  server_name _;
34
43
 
35
44
  location / {
36
- # Redirect to Matterbridge frontend from http:/server_name:80
45
+ # Redirect to Matterbridge frontend from http:/yourhost:80
37
46
  proxy_pass http://localhost:8283/;
38
47
  proxy_set_header Host $host;
39
48
  proxy_set_header X-Real-IP $remote_addr;
@@ -54,7 +63,16 @@ Add matterbridge to enabled sites
54
63
  sudo ln -s /etc/nginx/sites-available/matterbridge /etc/nginx/sites-enabled/
55
64
  ```
56
65
 
57
- ### Create a basic nginx configuration file that redirect to http://yourhost:8283/matterbridge
66
+ Restart nginx and test the configuration
67
+
68
+ ```bash
69
+ sudo systemctl restart nginx
70
+ sudo nginx -t
71
+ ```
72
+
73
+ ### Create a basic nginx configuration file that redirect from http://yourhost/matterbridge to http://yourhost:8283/matterbridge
74
+
75
+ Create or edit the matterbridge configuration file
58
76
 
59
77
  ```bash
60
78
  sudo nano /etc/nginx/sites-available/matterbridge
@@ -69,7 +87,7 @@ server {
69
87
  server_name _;
70
88
 
71
89
  location /matterbridge/ {
72
- # Redirect to Matterbridge frontend from http:/server_name/matterbridge:80
90
+ # Redirect to Matterbridge frontend from http:/yourhost/matterbridge:80
73
91
  proxy_pass http://localhost:8283/;
74
92
  proxy_set_header Host $host;
75
93
  proxy_set_header X-Real-IP $remote_addr;
@@ -97,17 +115,19 @@ sudo systemctl restart nginx
97
115
  sudo nginx -t
98
116
  ```
99
117
 
100
- ### Create an advanced nginx configuration file that redirect to http://yourhost:8283 with ssl
118
+ ### Create an advanced nginx configuration file that redirect from http://yourhost or https://yourhost to http://yourhost:8283 with ssl
119
+
120
+ Add your certificates in /etc/nginx/certs: `cert.pem` and `key.pem`
121
+
122
+ Create or edit the matterbridge configuration file
101
123
 
102
124
  ```bash
103
125
  sudo nano /etc/nginx/sites-available/matterbridge
104
126
  ```
105
127
 
106
- paste this configuration adding your certificates:
128
+ paste this configuration:
107
129
 
108
130
  ```
109
- # Default server configuration
110
-
111
131
  # Redirect all HTTP requests to HTTPS
112
132
  server {
113
133
  listen 80 default_server;
@@ -134,7 +154,7 @@ server {
134
154
  ssl_prefer_server_ciphers on;
135
155
 
136
156
  location / {
137
- # Redirect to Matterbridge frontend from https:/server_name:443
157
+ # Redirect to Matterbridge frontend from https:/yourhost:443
138
158
  proxy_pass http://localhost:8283/;
139
159
  proxy_set_header Host $host;
140
160
  proxy_set_header X-Real-IP $remote_addr;
@@ -162,13 +182,17 @@ sudo systemctl restart nginx
162
182
  sudo nginx -t
163
183
  ```
164
184
 
165
- ### Create an advanced nginx configuration file that redirect to http://yourhost/matterbridge with ssl
185
+ ### Create an advanced nginx configuration file that redirect from http://yourhost/matterbridge or https://yourhost/matterbridge to http://yourhost/matterbridge with ssl
186
+
187
+ Add your certificates in /etc/nginx/certs: `cert.pem` and `key.pem`
188
+
189
+ Create or edit the matterbridge configuration file
166
190
 
167
191
  ```bash
168
192
  sudo nano /etc/nginx/sites-available/matterbridge
169
193
  ```
170
194
 
171
- paste this configuration adding your certificates:
195
+ paste this configuration:
172
196
 
173
197
  ```
174
198
  # Redirect all HTTP requests to HTTPS
@@ -205,19 +229,19 @@ server {
205
229
  try_files $uri $uri/ =404;
206
230
  }
207
231
 
208
- location /matterbridge/ {
209
- # Redirect to Matterbridge frontend from https:/server_name/matterbridge:443
210
- proxy_pass http://localhost:8283/;
211
- proxy_set_header Host $host;
212
- proxy_set_header X-Real-IP $remote_addr;
213
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
214
- proxy_set_header X-Forwarded-Proto $scheme;
232
+ location /matterbridge/ {
233
+ # Redirect to Matterbridge frontend from https:/yourhost/matterbridge:443
234
+ proxy_pass http://localhost:8283/;
235
+ proxy_set_header Host $host;
236
+ proxy_set_header X-Real-IP $remote_addr;
237
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
238
+ proxy_set_header X-Forwarded-Proto $scheme;
215
239
 
216
- # WebSocket support
217
- proxy_http_version 1.1;
218
- proxy_set_header Upgrade $http_upgrade;
219
- proxy_set_header Connection $http_connection;
220
- }
240
+ # WebSocket support
241
+ proxy_http_version 1.1;
242
+ proxy_set_header Upgrade $http_upgrade;
243
+ proxy_set_header Connection $http_connection;
244
+ }
221
245
  }
222
246
  ```
223
247
 
@@ -1,4 +1,4 @@
1
- import{B as e,y as o,Q as ot,S as cr,U as pr,V as Ue,X as ur,Y as mr,H as gr}from"./vendor_node_modules.js";import{u as hr,S as fr}from"./vendor_notistack.js";import{D as Fe,a as Le,b as We,B as oe,c as Z,A as xr,I as K,C as br,T as $,S as vr,F as qt,H as yr,d as zt,e as Re,R as gt,P as Ee,M as jr,f as Ke,g as k,L as z,h as te,i as nt,V as it,j as De,k as vt,l as Cr,m as Sr,n as pe,o as wr,p as Mr,q as ht,r as ie,s as Oe,K as Dt,t as Nt,u as xt,v as at,w as Ze,x as st,W as et,y as lt,z as dt,E as Ae,G as Pt,J as Ft,N as kr,O as Ir,Q as Dr,U as He,X as Bt,Y as St,Z as Nr,_ as Pr,$ as Fr,a0 as Lr,a1 as Qt,a2 as ft,a3 as Wr,a4 as Tr,a5 as Rr,a6 as $r,a7 as Lt,a8 as Hr,a9 as Or,aa as Er,ab as _r,ac as Ar,ad as Vr,ae as Ur,af as Wt,ag as qr,ah as zr,ai as Br,aj as Qr,ak as Kr,al as Gr,am as Jr,an as Yr,ao as Xr,ap as Zr,aq as eo,ar as to,as as ro,at as oo,au as no,av as Tt,aw as Ge,ax as Kt,ay as ke,az as Gt,aA as bt,aB as $e,aC as io,aD as ao}from"./vendor_mui.js";import{Q as so}from"./vendor_qrcode.js";import{I as re,m as Rt,a as lo,b as co,c as $t,d as po,e as uo,f as mo,g as go,h as ho,i as fo,j as xo,k as bo,l as vo,n as yo,o as jo,p as Co,q as Ht,r as So,s as wo,t as Mo,u as ko,v as Io,w as Do,x as No,y as Po,z as Ot,A as Fo,B as Lo}from"./vendor_mdi.js";import{F as Wo,v as To,e as Ro,a as $o,g as Ho,b as Oo,c as Eo,d as yt,A as _o}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const p=document.createElement("link").relList;if(p&&p.supports&&p.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))n(l);new MutationObserver(l=>{for(const f of l)if(f.type==="childList")for(const v of f.addedNodes)v.tagName==="LINK"&&v.rel==="modulepreload"&&n(v)}).observe(document,{childList:!0,subtree:!0});function s(l){const f={};return l.integrity&&(f.integrity=l.integrity),l.referrerPolicy&&(f.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?f.credentials="include":l.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function n(l){if(l.ep)return;l.ep=!0;const f=s(l);fetch(l.href,f)}})();/**
1
+ import{B as e,y as o,Q as tt,S as ar,U as sr,V as Ve,X as lr,Y as dr,H as cr}from"./vendor_node_modules.js";import{u as pr,S as ur}from"./vendor_notistack.js";import{D as Ne,a as Fe,b as Le,B as ie,c as Z,A as mr,I as Q,C as gr,T as R,S as hr,F as At,H as fr,d as Vt,e as Te,R as ut,P as Oe,M as xr,f as Qe,g as I,L as q,h as te,i as rt,V as ot,j as Ie,k as bt,l as br,m as vr,n as pe,o as yr,p as jr,q as mt,r as ne,s as He,K as It,t as Dt,u as ht,v as nt,w as Xe,x as it,W as Ze,y as at,z as st,E as _e,G as Pt,J as Nt,N as Cr,O as wr,Q as Sr,U as Re,X as Ut,Y as Ct,Z as Mr,_ as kr,$ as Ir,a0 as Dr,a1 as qt,a2 as gt,a3 as Pr,a4 as Nr,a5 as Fr,a6 as Lr,a7 as Ft,a8 as Wr,a9 as Tr,aa as $r,ab as Rr,ac as Hr,ad as Or,ae as Er,af as Lt,ag as _r,ah as Ar,ai as Vr,aj as Ur,ak as qr,al as zr,am as Br,an as Qr,ao as Kr,ap as Jr,aq as Gr,ar as Yr,as as Xr,at as Zr,au as eo,av as Wt,aw as Ke,ax as zt,ay as Me,az as Bt,aA as ft,aB as $e,aC as to,aD as ro}from"./vendor_mui.js";import{Q as oo}from"./vendor_qrcode.js";import{I as re,m as Tt,a as no,b as io,c as $t,d as ao,e as so,f as lo,g as co,h as po,i as uo,j as mo,k as go,l as ho,n as fo,o as xo,p as bo,q as Rt,r as vo,s as yo,t as jo,u as Co,v as wo,w as So,x as Mo,y as ko,z as Ht,A as Io,B as Do}from"./vendor_mdi.js";import{F as Po,v as No,e as Fo,a as Lo,g as Wo,b as To,c as $o,d as vt,A as Ro}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const u=document.createElement("link").relList;if(u&&u.supports&&u.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const v of s)if(v.type==="childList")for(const M of v.addedNodes)M.tagName==="LINK"&&M.rel==="modulepreload"&&i(M)}).observe(document,{childList:!0,subtree:!0});function a(s){const v={};return s.integrity&&(v.integrity=s.integrity),s.referrerPolicy&&(v.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?v.credentials="include":s.crossOrigin==="anonymous"?v.credentials="omit":v.credentials="same-origin",v}function i(s){if(s.ep)return;s.ep=!0;const v=a(s);fetch(s.href,v)}})();/**
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 o,Q as ot,S as cr,U as pr,V as Ue,X as ur,Y as mr,H as gr}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 we=(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))(we||{});function ae(r){return r.id>=0&&r.id<=101}function ge(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function Ao({open:r,title:p,message:s,onConfirm:n,onCancel:l}){const f=t=>{a&&console.log("Confirmed"),t.preventDefault(),n()},v=t=>{a&&console.log("Canceled"),t.preventDefault(),l()};return e.jsxs(Fe,{open:r,children:[e.jsx(Le,{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:p})]})}),e.jsxs(We,{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:s})}),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:v,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ct=[],Je=o.createContext(null);function Vo({children:r}){const{enqueueSnackbar:p,closeSnackbar:s}=hr(),n=o.useCallback(b=>{a&&console.log(`UiProvider closeSnackbarMessage: message ${b}`);const S=ct.findIndex(W=>W.message===b);S!==-1&&(s(ct[S].key),ct.splice(S,1),a&&console.log(`UiProvider closeSnackbarMessage: message ${b} removed from persistMessages`))},[s]),l=o.useCallback((b,S,W)=>{a&&console.log(`UiProvider showSnackbarMessage: message ${b} timeout ${S}`);const H=p(b,{variant:"default",autoHideDuration:S==null||S>0?(S??5)*1e3:null,persist:S===0,content:w=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(xr,{severity:W??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>s(w),action:e.jsx(K,{size:"small",onClick:()=>s(w),sx:{color:"#fff"},children:e.jsx(br,{fontSize:"small"})}),children:b},w)},w)});S===0&&(a&&console.log(`UiProvider showSnackbarMessage: message ${b} timeout ${S} - persist key ${H}`),ct.push({message:b,key:H}))},[p,s]),[f,v]=o.useState(!1),[t,c]=o.useState(""),[R,F]=o.useState(""),[C,_]=o.useState(""),T=o.useRef(null),L=o.useRef(null),A=()=>{a&&console.log(`UiProvider handle confirm action ${C}`),v(!1),T.current&&T.current(C)},g=()=>{a&&console.log(`UiProvider handle cancel action ${C}`),v(!1),L.current&&L.current(C)},E=o.useCallback((b,S,W,H,w)=>{a&&console.log(`UiProvider showConfirmCancelDialog for command ${W}`),c(b),F(S),_(W),T.current=H,L.current=w,v(!0)},[]),x=o.useMemo(()=>({showSnackbarMessage:l,closeSnackbarMessage:n,closeSnackbar:s,showConfirmCancelDialog:E}),[l,n,s,E]);return e.jsxs(Je.Provider,{value:x,children:[e.jsx(Ao,{open:f,title:t,message:R,onConfirm:A,onCancel:g}),r]})}const Jt=o.createContext(null),be=o.createContext(null);function Uo({children:r}){const[p,s]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[n,l]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[f,v]=o.useState([]),[t,c]=o.useState(1e3),[R,F]=o.useState(!0),[C,_]=o.useState(!1),{showSnackbarMessage:T,closeSnackbarMessage:L,closeSnackbar:A}=o.useContext(Je),g=o.useRef([]),E=o.useRef(null),x=o.useRef(1),b=o.useRef(Math.floor(Math.random()*999e3)+1e3),S=o.useRef(null),W=o.useRef(null),H=o.useRef(null),w=o.useRef(p),U=o.useRef(n),d=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),i=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),m=100,h=60,I=50,B=300;o.useEffect(()=>{w.current=p},[p]),o.useEffect(()=>{U.current=n},[n]);const je=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),xe=o.useCallback(j=>{if(E.current&&E.current.readyState===WebSocket.OPEN)try{j.id===void 0&&(j.id=b.current);const u=JSON.stringify(j);E.current.send(u),a&&console.log("WebSocket sent message:",j)}catch(u){a&&console.error(`WebSocket error sending message: ${u}`)}else a&&console.error("WebSocket message not sent, WebSocket not connected:",j)},[]),he=o.useCallback((j,u)=>{const ee=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${j}</span>`;v(G=>[...G,ee+' <span style="color: var(--main-log-color);">'+u+"</span>"])},[]),X=o.useCallback((j,u)=>{s(j),l(u),he("WebSocket",`Filtering by log level "${j}" and log search "${u}"`)},[he]),se=o.useCallback(j=>{a&&console.log("WebSocket addListener:",j),g.current=[...g.current,j],a&&console.log("WebSocket addListener total listeners:",g.current.length)},[]),P=o.useCallback(j=>{a&&console.log("WebSocket removeListener:",j),g.current=g.current.filter(u=>u!==j),a&&console.log("WebSocket removeListener total listeners:",g.current.length)},[]),O=o.useCallback(()=>{d===""||d===null||d===void 0||(he("WebSocket",`Connecting to WebSocket: ${d}`),E.current=new WebSocket(d),E.current.onmessage=j=>{C||_(!0);try{const u=JSON.parse(j.data);if(u.id===void 0)return;if(u.error&&a&&console.error("WebSocket error message:",u),u.id===b.current&&u.src==="Matterbridge"&&u.dst==="Frontend"&&u.response==="pong"){a&&console.log("WebSocket pong response message:",u,"listeners:",g.current.length),W.current&&clearTimeout(W.current),g.current.forEach(G=>G(u));return}if(u.id===we.RefreshRequired){a&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.RestartRequired){a&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.RestartNotRequired){a&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.CpuUpdate){a&&console.log("WebSocket WS_ID_CPU_UPDATE message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.MemoryUpdate){a&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.UptimeUpdate){a&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.Snackbar&&u.params&&u.params.message){a&&console.log("WebSocket WS_ID_SNACKBAR message:",u,"listeners:",g.current.length),T(u.params.message,u.params.timeout,u.params.severity);return}else if(u.id===we.CloseSnackbar&&u.params&&u.params.message){a&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",u,"listeners:",g.current.length),L(u.params.message);return}else if(u.id===we.ShellySysUpdate){a&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id===we.ShellyMainUpdate){a&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}else if(u.id!==we.Log){a&&console.log("WebSocket message:",u,"listeners:",g.current.length),g.current.forEach(G=>G(u));return}if(!u.params||!u.params.level||!u.params.time||!u.params.name||!u.params.message||["debug","info","notice","warn","error","fatal"].includes(u.params.level)&&(w.current==="info"&&u.params.level==="debug"||w.current==="notice"&&(u.params.level==="debug"||u.params.level==="info")||w.current==="warn"&&(u.params.level==="debug"||u.params.level==="info"||u.params.level==="notice")||w.current==="error"&&(u.params.level==="debug"||u.params.level==="info"||u.params.level==="notice"||u.params.level==="warn")||w.current==="fatal"&&(u.params.level==="debug"||u.params.level==="info"||u.params.level==="notice"||u.params.level==="warn"||u.params.level==="error"))||U.current!=="*"&&U.current!==""&&!u.params.message.toLowerCase().includes(U.current.toLowerCase())&&!u.params.name.toLowerCase().includes(U.current.toLowerCase())||u.params.name==="Commissioning"&&u.params.message.includes("is uncommissioned"))return;v(G=>{const de=`<span style="color: #505050;">[${u.params?.time}]</span>`,le=Ce=>{switch(Ce?.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"}},V=Ce=>{switch(Ce?.toLowerCase()){case"warn":return"black";default:return"white"}},ue=`${`<span style="background-color: ${le(u.params?.level)}; color: ${V(u.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${u.params?.level}</span>`} ${de} <span style="color: #09516d;">[${u.params?.name}]</span> <span style="color: var(--main-log-color);">${u.params?.message}</span>`,Y=[...G,ue];return Y.length>t?Y.slice(t/10):Y})}catch(u){console.error(`WebSocketUse error parsing message: ${u}`)}},E.current.onopen=()=>{a&&console.log(`WebSocket: Connected to WebSocket: ${d}`),he("WebSocket",`Connected to WebSocket: ${d}`),_(!0),A(),x.current=1,H.current=setTimeout(()=>{S.current=setInterval(()=>{xe({id:b.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{a&&console.error(`WebSocketUse: No pong response received from WebSocket: ${d}`),he("WebSocket",`No pong response received from WebSocket: ${d}`),_(!1)},1e3*I)},1e3*h)},1e3*B)},E.current.onclose=()=>{a&&console.error(`WebSocket: Disconnected from WebSocket ${i?"with Ingress":""}: ${d}`),he("WebSocket",`Disconnected from WebSocket: ${d}`),_(!1),A(),H.current&&clearTimeout(H.current),W.current&&clearTimeout(W.current),S.current&&clearInterval(S.current),he("WebSocket",`Reconnecting (attempt ${x.current} of ${m}) to WebSocket${i?" (Ingress)":""}: ${d}`),i?setTimeout(D,5e3):x.current===1?D():x.current<m?setTimeout(D,1e3*x.current):he("WebSocket",`Reconnect attempts exceeded limit of ${m} retries, refresh the page to reconnect to: ${d}`),x.current=x.current+1},E.current.onerror=j=>{a&&console.error(`WebSocket: WebSocket error connecting to ${d}:`,j),he("WebSocket",`WebSocket error connecting to ${d}`)})},[d]),D=o.useCallback(()=>{a&&console.log(`WebSocket attemptReconnect ${x.current}/${m} to:`,d),O()},[O]);o.useEffect(()=>(O(),()=>{E.current&&E.current.readyState===WebSocket.OPEN&&E.current.close()}),[O]);const N=o.useMemo(()=>({messages:f,maxMessages:t,autoScroll:R,setMessages:v,setLogFilters:X,setMaxMessages:c,setAutoScroll:F}),[f,v,X]),M=o.useMemo(()=>({maxMessages:t,autoScroll:R,logFilterLevel:p,logFilterSearch:n,setMessages:v,setLogFilters:X,setMaxMessages:c,setAutoScroll:F,online:C,retry:x.current,getUniqueId:je,addListener:se,removeListener:P,sendMessage:xe,logMessage:he}),[t,R,v,X,c,F,C,x.current,se,P,xe,he]);return e.jsx(Jt.Provider,{value:N,children:e.jsx(be.Provider,{value:M,children:r})})}function qo(){const{showSnackbarMessage:r,showConfirmCancelDialog:p}=o.useContext(Je),{online:s,sendMessage:n,logMessage:l,addListener:f,removeListener:v,getUniqueId:t}=o.useContext(be),[c,R]=o.useState(!1),[F,C]=o.useState(!1),[_,T]=o.useState(!1),[L,A]=o.useState(!1),[g,E]=o.useState(null),x=o.useRef(t()),[b,S]=o.useState(null),[W,H]=o.useState(null),[w,U]=o.useState(null),[d,i]=o.useState(null),[m,h]=o.useState(null),I=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},B=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},je=()=>{g?.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")},xe=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},he=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},X=()=>{n({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},se=()=>{n({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},P=()=>{n({id:x.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},O=()=>{a&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),n({id:x.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{a&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),n({id:x.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},N=()=>{a&&console.log("Header: handleShellyCreateSystemLog"),n({id:x.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{a&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},j=()=>{g?.matterbridgeInformation.restartMode===""?n({id:x.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},u=()=>{n({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ee=()=>{n({id:x.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},G=()=>{n({id:x.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{n({id:x.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=Q=>{S(Q.currentTarget)},V=Q=>{a&&console.log("Header: handleMenuClose",Q),S(null),Q==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),r("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),r("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),r("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(l("Matterbridge","Loading matter log..."),r("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),r("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),r("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),r("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),r("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),r("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(l("Matterbridge","Downloading backup..."),r("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?X():Q==="updatedev"?se():Q==="updatecheck"?P():Q==="shelly-sys-update"?O():Q==="shelly-main-update"?D():Q==="shelly-create-system-log"?N():Q==="shelly-download-system-log"?M():Q==="softreset"?G():Q==="hardreset"?de():Q==="restart"?j():Q==="shutdown"?u():Q==="reboot"?ee():Q==="create-backup"?n({id:x.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?n({id:x.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?n({id:x.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&n({id:x.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},ne=Q=>{a&&console.log("Header: handleMenuCloseCancel:",Q),S(null)},ue=Q=>{H(Q.currentTarget)},Y=()=>{H(null)},Ce=Q=>{U(Q.currentTarget)},Me=()=>{U(null)},fe=Q=>{i(Q.currentTarget)},J=()=>{i(null)},ce=Q=>{h(Q.currentTarget)},Se=()=>{h(null)},Ye=()=>{Yn(),a&&console.log("Matterbridge logo clicked: debug is now",a)};return o.useEffect(()=>{const Q=y=>{y.src==="Matterbridge"&&y.dst==="Frontend"&&(ge(y)&&y.method==="/api/settings"&&y.id===x.current&&(a&&console.log("Header received settings:",y.response),E(y.response),R(y.response.matterbridgeInformation.restartRequired||y.response.matterbridgeInformation.fixedRestartRequired),C(y.response.matterbridgeInformation.fixedRestartRequired),T(y.response.matterbridgeInformation.updateRequired)),ae(y)&&y.method==="refresh_required"&&y.params.changed==="settings"&&(a&&console.log(`Header received refresh_required: changed=${y.params.changed} and sending /api/settings request`),n({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ae(y)&&y.method==="restart_required"&&(a&&console.log(`Header received restart_required with fixed: ${y.params.fixed}`),R(!0),y.params.fixed===!0&&C(!0)),ae(y)&&y.method==="restart_not_required"&&(a&&console.log("Header received restart_not_required"),R(!1)),ae(y)&&y.method==="update_required"&&(a&&console.log("Header received update_required"),T(!0),n({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ae(y)&&y.method==="update_required_dev"&&(a&&console.log("Header received update_required_dev"),A(!0),n({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ae(y)&&y.id===we.ShellySysUpdate&&(a&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),E(me=>me?{matterbridgeInformation:{...me.matterbridgeInformation,shellySysUpdate:y.params.available},systemInformation:me.systemInformation}:null)),ae(y)&&y.id===we.ShellyMainUpdate&&(a&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),E(me=>me?{matterbridgeInformation:{...me.matterbridgeInformation,shellyMainUpdate:y.params.available},systemInformation:me.systemInformation}:null)))};return f(Q),a&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{v(Q),a&&console.log("Header removed WebSocket listener")}},[f,v,n,r]),o.useEffect(()=>{s&&(a&&console.log("Header sending /api/settings requests"),n({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[s,n]),a&&console.log("Header rendering..."),!s||!g?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:Ye}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(ot,{to:"/",className:"nav-link",children:"Home"}),e.jsx(ot,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(ot,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(ot,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!g.matterbridgeInformation.readOnly&&_&&e.jsx($,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:X,children:["Update to v.",g.matterbridgeInformation.matterbridgeLatestVersion]})}),!g.matterbridgeInformation.readOnly&&L&&e.jsx($,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:se,children:["Update to new dev v.",g.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!g.matterbridgeInformation.readOnly&&e.jsx($,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:je,children:["v.",g.matterbridgeInformation.matterbridgeVersion]})}),g.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),g.matterbridgeInformation.bridgeMode!==""&&g.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:g.matterbridgeInformation.bridgeMode})}):null,g.matterbridgeInformation.restartMode!==""&&g.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:g.matterbridgeInformation.restartMode})}):null,g.matterbridgeInformation.profile&&g.matterbridgeInformation.profile!==""&&g.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:g.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[g.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:xe})}):null,g.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Give a star to Matterbridge",children:e.jsx(K,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:he,children:e.jsx(vr,{})})}):null,g.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Sponsor Matterbridge",children:e.jsx(K,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:I,children:e.jsx(qt,{})})}):null,e.jsx($,{title:"Matterbridge help",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:B,children:e.jsx(yr,{})})}),e.jsx($,{title:"Matterbridge changelog",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:je,children:e.jsx(zt,{})})}),g.matterbridgeInformation&&!g.matterbridgeInformation.readOnly&&e.jsx($,{title:"Update matterbridge to latest version",children:e.jsx(K,{style:{color:_?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:X,children:e.jsx(Re,{})})}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&g.matterbridgeInformation.shellySysUpdate&&e.jsx($,{title:"Shelly system update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:O,children:e.jsx(Re,{})})}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&g.matterbridgeInformation.shellyMainUpdate&&e.jsx($,{title:"Shelly software update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:D,children:e.jsx(Re,{})})}),e.jsx($,{title:"Restart matterbridge",children:e.jsx(K,{style:{color:c||F?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:j,children:e.jsx(gt,{})})}),g.matterbridgeInformation.restartMode===""?e.jsx($,{title:"Shut down matterbridge",children:e.jsx(K,{style:{color:c||F?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:u,children:e.jsx(Ee,{})})}):null,e.jsx($,{title:"Download, backup and more",children:e.jsx(K,{onClick:le,children:e.jsx(jr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ke,{id:"command-menu",anchorEl:b,keepMounted:!0,open:!!b,onClose:()=>V(""),children:[g.matterbridgeInformation&&!g.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>V("update"),children:[e.jsx(z,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&!g.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>V("updatedev"),children:[e.jsx(z,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&!g.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>V("updatecheck"),children:[e.jsx(z,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&g.matterbridgeInformation.shellySysUpdate&&e.jsxs(k,{onClick:()=>V("shelly-sys-update"),children:[e.jsx(z,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&g.matterbridgeInformation.shellyMainUpdate&&e.jsxs(k,{onClick:()=>V("shelly-main-update"),children:[e.jsx(z,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>V("restart"),children:[e.jsx(z,{children:e.jsx(gt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation.restartMode===""?e.jsxs(k,{onClick:()=>V("shutdown"),children:[e.jsx(z,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{p("Reboot","Are you sure you want to reboot the Shelly board?","reboot",V,ne)},children:[e.jsx(z,{children:e.jsx(gt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(nt,{}),e.jsxs(k,{onClick:Ce,children:[e.jsx(z,{children:e.jsx(it,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ke,{id:"sub-menu-view",anchorEl:w,keepMounted:!0,open:!!w,onClose:Me,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{V("view-mblog"),Me()},children:[e.jsx(z,{children:e.jsx(it,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("view-mjlog"),Me()},children:[e.jsx(z,{children:e.jsx(it,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{V("view-shellylog"),Me()},children:[e.jsx(z,{children:e.jsx(it,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(nt,{}),e.jsxs(k,{onClick:fe,children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ke,{id:"sub-menu-download",anchorEl:d,keepMounted:!0,open:!!d,onClose:J,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{V("download-mbstorage"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("download-pluginstorage"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("download-pluginconfig"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("download-mblog"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("download-mjstorage"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("download-mjlog"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{V("shelly-create-system-log"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{V("shelly-download-system-log"),J()},children:[e.jsx(z,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(nt,{}),e.jsxs(k,{onClick:ue,children:[e.jsx(z,{children:e.jsx(vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ke,{id:"sub-menu-backup",anchorEl:W,keepMounted:!0,open:!!W,onClose:Y,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{V("create-backup"),Y()},children:[e.jsx(z,{children:e.jsx(vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{V("download-backup"),Y()},children:[e.jsx(z,{children:e.jsx(vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(nt,{}),e.jsxs(k,{onClick:ce,children:[e.jsx(z,{children:e.jsx(Cr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ke,{id:"sub-menu-reset",anchorEl:m,keepMounted:!0,open:!!m,onClose:Se,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{Se(),p("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",V,ne)},children:[e.jsx(z,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{Se(),p("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",V,ne)},children:[e.jsx(z,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!g.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>{Se(),p("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",V,ne)},children:[e.jsx(z,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{Se(),p("Network reset","Are you sure you want to factory reset the network parameters?","softreset",V,ne)},children:[e.jsx(z,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),g.matterbridgeInformation&&g.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{Se(),p("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",V,ne)},children:[e.jsx(z,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const zo=o.memo(qo),Bo=()=>"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 Qo(){const{messages:r,autoScroll:p}=o.useContext(Jt),[s,n]=o.useState(!1),l=o.useRef(null),f=o.useMemo(()=>Bo(),[]),v=c=>n(!0),t=c=>n(!1);return o.useEffect(()=>{a&&console.log(`WebSocketLogs autoScroll: ${p} isHovering: ${s}`),p&&!s&&!f&&l.current?.scrollIntoView({behavior:"smooth"})},[r,s,p,f]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:v,onMouseLeave:t,children:[r.map((c,R)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:c}},R)),e.jsx("div",{ref:l})]})})}const Yt=o.memo(Qo);function Ve(){const{retry:r}=o.useContext(be),p=()=>{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:r<100?e.jsxs(e.Fragment,{children:[e.jsx(Sr,{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:p,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Ko({value:r,maxChars:p}){let s=r;if(r.length>p&&p>3){const n=p-3,l=r.substring(0,Math.ceil(n/2)),f=r.substring(r.length-Math.floor(n/2),r.length);s=`${l} … ${f}`}return r!==s?e.jsx($,{title:r,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:s})}):e.jsx("span",{children:s})}function Go({systemInfo:r,compact:p}){const[s,n]=o.useState(r),{sendMessage:l,addListener:f,removeListener:v}=o.useContext(be);if(a&&console.log("SystemInfoTable:",s,"compact:",p),r&&p&&s.totalMemory&&s.freeMemory){const t=s.totalMemory,c=s.freeMemory;s.freeMemory=`${c} / ${t}`,s.totalMemory=""}if(r&&p&&s.heapTotal&&s.heapUsed){const t=s.heapTotal,c=s.heapUsed;s.heapUsed=`${c} / ${t}`,s.heapTotal=""}if(r&&p&&s.osRelease&&s.osType){const t=s.osType,c=s.osRelease;s.osType=`${t} (${c})`,s.osRelease=""}if(r&&p&&s.osArch&&s.osPlatform){const t=s.osPlatform,c=s.osArch;s.osPlatform=`${t} (${c})`,s.osArch=""}return o.useEffect(()=>{const t=c=>{c.src==="Matterbridge"&&c.dst==="Frontend"&&(ae(c)&&c.method==="memory_update"&&c.params&&c.params.totalMemory&&c.params.freeMemory&&c.params.heapTotal&&c.params.heapUsed&&c.params.rss&&(a&&console.log("SystemInfoTable received memory_update",c),(s.totalMemory!==c.params?.totalMemory||s.freeMemory!==c.params?.freeMemory||s.heapTotal!==c.params?.heapTotal||s.heapUsed!==c.params?.heapUsed||s.rss!==c.params?.rss)&&n(R=>({...R,totalMemory:c.params?.totalMemory?c.params.totalMemory:"",freeMemory:c.params?.freeMemory?c.params.freeMemory:"",heapTotal:c.params?.heapTotal?c.params.heapTotal:"",heapUsed:c.params?.heapUsed?c.params.heapUsed:"",rss:c.params?.rss?c.params.rss:""}))),ae(c)&&c.method==="cpu_update"&&c.params&&c.params.cpuUsage&&(a&&console.log("SystemInfoTable received cpu_update",c),s.cpuUsage!==(c.params?.cpuUsage?c.params.cpuUsage.toFixed(2)+" %":"")&&n(R=>({...R,cpuUsage:c.params?.cpuUsage?c.params.cpuUsage.toFixed(2)+" %":""}))),ae(c)&&c.method==="uptime_update"&&c.params&&c.params.systemUptime&&c.params.processUptime&&(a&&console.log("SystemInfoTable received uptime_update",c),(s.systemUptime!==c.params?.systemUptime||s.processUptime!==c.params?.processUptime)&&n(R=>({...R,systemUptime:c.params?.systemUptime?c.params.systemUptime:"",processUptime:c.params?.processUptime?c.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"),v(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[f,s.cpuUsage,s.freeMemory,s.heapTotal,s.heapUsed,s.processUptime,s.rss,s.systemUptime,s.totalMemory,v,l]),s?(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(s).filter(([t,c])=>c!==void 0&&c!=="").map(([t,c],R)=>e.jsxs("tr",{className:R%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 c!="string"?c.toString():c,maxChars:25})})]},t))})})})]})):null}const Jo=o.memo(Go),Et={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"}},Yo=r=>{if(!r)return"";const p=r.toString().replace(/[^0-9]/g,"");if(p.length<5)return p;const s=p.slice(0,4),n=p.slice(4,7),l=p.slice(7,11);return[s,n,l].filter(Boolean).join("-")};function Xo({id:r}){const{online:p,sendMessage:s,addListener:n,removeListener:l,getUniqueId:f}=o.useContext(be),[v,t]=o.useState(null),[c,R]=o.useState(null),F=o.useRef(null),C=o.useRef(f()),{showConfirmCancelDialog:_}=o.useContext(Je);o.useEffect(()=>{a&&console.log(`QRDiv received storeId update "${r}"`),r&&(a&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),s({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const x=b=>{b.src==="Matterbridge"&&b.dst==="Frontend"&&ae(b)&&b.id===we.RefreshRequired&&b.params.changed==="matter"&&b.params.matter&&(a&&console.log(`QRDiv received refresh_required: changed=${b.params.changed} for storeId "${b.params.matter.id}":`,b.params.matter),v===b.params.matter.id&&(a&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${b.params.matter.id}":`,b.params.matter),F.current&&clearTimeout(F.current),b.params.matter.advertising&&b.params.matter.advertiseTime&&b.params.matter.advertiseTime+9e5<=Date.now()&&(b.params.matter.advertising=!1),R(b.params.matter),b.params.matter.advertising&&(a&&console.log(`QRDiv setting matter advertise timeout for storeId "${b.params.matter.id}":`,b.params.matter.advertiseTime+9e5-Date.now()),F.current=setTimeout(()=>{F.current&&clearTimeout(F.current),a&&console.log(`QRDiv clearing advertising state for storeId "${v}" after 15 minutes`),R(S=>S&&{...S,advertising:!1})},b.params.matter.advertiseTime+9e5-Date.now()))))};return n(x),a&&console.log("QRDiv webSocket effect mounted"),()=>{l(x),F.current&&clearTimeout(F.current),a&&console.log("QRDiv webSocket effect unmounted")}},[v]);const T=()=>{a&&console.log(`QRDiv sent matter startCommission for node "${c?.id}"`),c&&s({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:c.id,startCommission:!0}})},L=()=>{a&&console.log(`QRDiv sent matter stopCommission for node "${c?.id}"`),c&&s({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:c.id,stopCommission:!0}})},A=()=>{a&&console.log(`QRDiv sent matter advertise for node "${c?.id}"`),c&&s({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:c.id,advertise:!0}})},g=x=>{a&&console.log(`QRDiv sent matter removeFabric for node "${c?.id}" and fabricIndex ${x}`),c&&s({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:c.id,removeFabric:x}})},E=async()=>{if(!c||!c.manualPairingCode)return;const x=c.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(x);else{const b=document.createElement("textarea");b.value=x,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}a&&console.log("Manual pairing code copied to clipboard")}catch(b){console.error("Failed to copy manual pairing code",b)}};return!c||!p?(a&&console.log("QRDiv rendering undefined state"),null):c.online?c.advertising&&c.qrPairingCode&&c.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(K,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:Rt,size:"22px"})})}),e.jsx(K,{"aria-label":"stop pairing",size:"small",onClick:L,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn off pairing",arrow:!0,children:e.jsx(re,{path:lo,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:v}),e.jsx(so,{value:c.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: ",Yo(c.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx($,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(K,{"aria-label":"copy manual pairing code",size:"small",onClick:E,sx:Et,children:e.jsx(re,{path:co,size:.85})})})})]})]})):c.commissioned&&c.fabricInformations&&c.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(K,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:Rt,size:"22px"})})}),e.jsx(K,{"aria-label":"start pairing",size:"small",onClick:T,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn on pairing",arrow:!0,children:e.jsx(re,{path:$t,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:v}),c.fabricInformations.map((x,b)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",x.fabricIndex]}),e.jsx($,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(K,{"aria-label":"remove the fabric",size:"small",onClick:()=>_("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>g(x.fabricIndex),()=>{}),sx:{...Et,padding:"2px"},children:e.jsx(re,{path:po,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",x.rootVendorId," ",x.rootVendorName]}),x.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",x.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",c.sessionInformations?c.sessionInformations.filter(S=>S.fabric?.fabricIndex===x.fabricIndex&&S.isPeerActive===!0).length:"0"," ","subscriptions: ",c.sessionInformations?c.sessionInformations.filter(S=>S.fabric?.fabricIndex===x.fabricIndex&&S.isPeerActive===!0&&S.numberOfActiveSubscriptions>0).length:"0"]})]},b))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",c.serialNumber]})})]})):!c.commissioned&&!c.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:v}),e.jsx(oe,{onClick:T,endIcon:e.jsx(re,{path:$t,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: ",c.serialNumber]})})]})):(a&&console.log("QRDiv rendering unknown state"),null):(a&&console.log("QRDiv rendering offline 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:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:v}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"bold"},children:"Server offline: restart to commission"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",c.serialNumber]})})]}))}const Zo=o.memo(Xo);function en(){const{logMessage:r,sendMessage:p,getUniqueId:s}=o.useContext(be),[n,l]=o.useState("matterbridge-"),[f,v]=o.useState(!1),[t,c]=o.useState(null),R=o.useRef(s()),F=b=>{b.preventDefault(),v(!0)},C=()=>{v(!1)},_=b=>{b.preventDefault(),v(!1);const S=b.dataTransfer.files[0];if(S){r("Plugins",`Installing package ${S.name}. Please wait...`);const W=new FormData;W.append("file",S),W.append("filename",S.name),fetch("./api/uploadpackage",{method:"POST",body:W}).then(H=>H.text()).then(H=>{r("Plugins",`Server response: ${H}`)}).catch(H=>{console.error("Error uploading plugin file:",H),r("Plugins",`Error installing package ${H}`)})}},T=b=>{const S=b.target.files&&b.target.files[0];if(S){r("Plugins",`Uploading package ${S.name}`);const W=new FormData;W.append("file",S),W.append("filename",S.name),fetch("./api/uploadpackage",{method:"POST",body:W}).then(H=>H.text()).then(H=>{r("Plugins",`Server response: ${H}`)}).catch(H=>{console.error("Error uploading plugin file:",H),r("Plugins",`Error uploading package ${H}`)})}},L=()=>{p({id:R.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},A=()=>{document.getElementById("file-upload")?.click()},g=()=>{p({id:R.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},E=b=>{c(b.currentTarget)},x=b=>{b!==""&&l(b),c(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:F,onDragLeave:C,onDrop:_,children:[e.jsx(pe,{value:n,onChange:b=>{l(b.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(K,{onClick:E,children:e.jsx(wr,{})}),e.jsxs(Ke,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>x(""),children:[e.jsx(k,{onClick:()=>x("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(k,{onClick:()=>x("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(k,{onClick:()=>x("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(k,{onClick:()=>x("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(k,{onClick:()=>x("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(k,{onClick:()=>x("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(k,{onClick:()=>x("matterbridge-test"),children:"matterbridge-test"}),e.jsx(k,{onClick:()=>x("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(k,{onClick:()=>x("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx($,{title:"Install or update a plugin from npm",children:e.jsx(oe,{onClick:L,endIcon:e.jsx(De,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx($,{title:"Upload and install a plugin from a tarball",children:e.jsx(oe,{onClick:A,endIcon:e.jsx(Mr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx($,{title:"Add an installed plugin",children:e.jsx(oe,{onClick:g,endIcon:e.jsx(ht,{}),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:T})]})}const tn=o.memo(en);function qe({status:r,enabledText:p="Enabled",disabledText:s=void 0,tooltipText:n=void 0,onClick:l}){if(r===void 0)return null;{const f=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:r?p:s??p});return n!==void 0?e.jsx($,{title:n,children:f}):f}}const ze={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Be={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},rn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},on={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Pe={padding:"0px",margin:"0px"},nn="5px 10px 5px 10px",pt={},ve={},ut={},mt={};let Qe=[],jt=[];const an=({open:r,onClose:p,plugin:s})=>{const{sendMessage:n,addListener:l,removeListener:f,getUniqueId:v}=o.useContext(be),t=o.useRef(v()),[c,R]=o.useState(s.configJson),[F,C]=o.useState(null),[_,T]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[L,A]=o.useState("");let g={};o.useEffect(()=>{const N=M=>{M.src==="Matterbridge"&&M.dst==="Frontend"&&(ge(M)&&M.id===t.current&&M.method==="/api/select/devices"&&M.response&&(a&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/devices:`,M.response),Qe=M.response),ge(M)&&M.id===t.current&&M.method==="/api/select/entities"&&M.response&&(a&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/entities:`,M.response),jt=M.response))};return l(N),a&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),c&&F&&F.properties&&(Object.keys(F.properties).forEach(M=>{Object.keys(F.properties[M]).forEach(j=>{j.startsWith("ui:")&&(_[M]={},_[M][j]=F.properties[M][j],delete F.properties[M][j])})}),T(_)),s.name&&s.configJson&&s.schemaJson&&(R(s.configJson),C(s.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:s.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:s.name}}),a&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',s.name)),()=>{f(N),a&&console.log("ConfigPluginDialog removed WebSocket listener")}},[l,c,s,f,F,n,_]);const E=(N,M)=>{g=N.formData},x=N=>{a&&console.log("ConfigPluginDialog handleSaveChanges:",N.formData),R(N.formData),s.configJson=N.formData,s.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.formData.name,formData:N.formData}}),p()};function b(N){const{id:M,label:j,onKeyChange:u,onDropPropertyClick:ee,disabled:G,schema:de,children:le,registry:V,readonly:ne,required:ue}=N,{templates:Y}=V,{RemoveButton:Ce}=Y.ButtonTemplates;if(!(_o in de))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const fe=({target:J})=>u(J&&J.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${M}-key`,name:`${M}-key`,required:ue,disabled:G||ne,defaultValue:j,onBlur:ne?void 0:fe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:le}),e.jsx(Ce,{disabled:G||ne,onClick:ee(j),registry:V})]})}function S(N){const{children:M,description:j,displayLabel:u,errors:ee,help:G,hidden:de,registry:le,uiSchema:V}=N,ne=Oo(V),ue=Eo("WrapIfAdditionalTemplate",le,ne);return de?e.jsx("div",{style:{display:"none"},children:M}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(ue,{...N,children:[u===!0&&j,M,ee,G]})})}function W(N){const{description:M}=N;return M?e.jsx(ie,{sx:Be,children:M}):null}function H(N){const{required:M,title:j}=N;return j?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ie,{sx:ze,children:["Title ",j," ",M&&e.jsx("mark",{children:"***"})]})}):null}function w(N){const{help:M}=N;return M?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ie,{sx:rn,children:M})}):null}function U(N){const{errors:M}=N;return M?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ie,{color:"error",sx:on,children:"Please fix the following errors:"}),e.jsx(Ze,{children:M.map((j,u)=>e.jsxs(kr,{children:[e.jsx(z,{children:e.jsx(Ir,{color:"error"})}),e.jsx(te,{primary:j.stack})]},u))})]}):null}function d(N){const{errors:M}=N;return M?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:M.map((j,u)=>e.jsxs(ie,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",j]},u))}):null}function i(N){const{id:M,name:j,_schema:u,_uiSchema:ee,value:G,options:de,label:le,type:V,placeholder:ne,required:ue,disabled:Y,readonly:Ce,autofocus:Me,onChange:fe,onChangeOverride:J,onBlur:ce,onFocus:Se,_rawErrors:Ye,_hideError:Q,_registry:y,_formContext:me}=N,Xe=({target:{value:Ie}})=>fe(Ie===""?de.emptyValue:Ie),Te=({target:Ie})=>ce(M,Ie&&Ie.value),rt=({target:Ie})=>Se(M,Ie&&Ie.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:M,name:M,label:ne&&ne!==""?le:void 0,variant:"outlined",placeholder:ne&&ne!==""?ne:le,required:ue,disabled:Y||Ce,autoFocus:Me,value:G||G===0?G:"",type:V,autoComplete:V==="password"?"current-password":j,onChange:J||Xe,onBlur:Te,onFocus:rt,fullWidth:!0})})}function m(N){return console.log("ArrayFieldTitleTemplate:",N),null}function h(N){return console.log("ArrayFieldDescriptionTemplate:",N),null}function I(N){return console.log("ArrayFieldItemTemplate:",N),null}function B(N){const{canAdd:M,onAddClick:j,schema:u,title:ee}=N,[G,de]=o.useState(!1),[le,V]=o.useState(!1),[ne,ue]=o.useState(!1),[Y,Ce]=o.useState(""),Me=y=>{Ce(y.target.value)},fe=()=>{a&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",Y,"selectDevices:",Qe),de(!G)},J=()=>{a&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",Y,"selectEntities:",jt),V(!le)},ce=()=>{a&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",Y,"selectDevices:",Qe),ue(!ne)},Se=y=>{de(!1),u.selectFrom==="serial"?u.items.default=y.serial:u.selectFrom==="name"&&(u.items.default=y.name),j()},Ye=y=>{V(!1),u.selectEntityFrom==="name"?u.items.default=y.name:u.selectEntityFrom==="description"&&(u.items.default=y.description),j()},Q=y=>{ue(!1),u.selectDeviceEntityFrom==="name"?u.items.default=y.name:u.selectDeviceEntityFrom==="description"&&(u.items.default=y.description),j()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ee&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ee&&e.jsx(ie,{sx:ze,children:ee}),M&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(K,{onClick:fe,size:"small",color:"primary",sx:Pe,children:e.jsx(at,{})})}),u.selectEntityFrom&&e.jsx($,{title:"Add an entity from the list",children:e.jsx(K,{onClick:J,size:"small",color:"primary",sx:Pe,children:e.jsx(at,{})})}),u.selectDeviceEntityFrom&&e.jsx($,{title:"Add a device entity from the list",children:e.jsx(K,{onClick:ce,size:"small",color:"primary",sx:Pe,children:e.jsx(at,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(K,{onClick:j,size:"small",color:"primary",sx:Pe,children:e.jsx(ht,{})})})]})]}),u.description&&e.jsx(ie,{sx:Be,children:u.description}),N.items.map(y=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:y.children}),e.jsx(K,{disabled:!y.hasMoveUp,onClick:y.onReorderClick(y.index,y.index-1),size:"small",color:"primary",sx:Pe,children:e.jsx(Nt,{})}),e.jsx(K,{disabled:!y.hasMoveDown,onClick:y.onReorderClick(y.index,y.index+1),size:"small",color:"primary",sx:Pe,children:e.jsx(Dt,{})}),e.jsx(K,{onClick:y.onDropIndexClick(y.index),size:"small",color:"primary",sx:Pe,children:e.jsx(xt,{})})]},y.index)),e.jsxs(Fe,{open:G,onClose:fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Le,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ie,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Y,onChange:Me,placeholder:"Enter serial or name"})]}),e.jsx(Ze,{dense:!0,children:Qe.filter(y=>y.serial.toLowerCase().includes(Y.toLowerCase())||y.name.toLowerCase().includes(Y.toLowerCase())).map((y,me)=>e.jsxs(st,{onClick:()=>Se(y),sx:pt,children:[y.icon==="wifi"&&e.jsx(z,{children:e.jsx(et,{style:ve})}),y.icon==="ble"&&e.jsx(z,{children:e.jsx(lt,{style:ve})}),y.icon==="hub"&&e.jsx(z,{children:e.jsx(dt,{style:ve})}),e.jsx(te,{primary:y.name,secondary:y.serial,primaryTypographyProps:{style:ut},secondaryTypographyProps:{style:mt}})]},me))})]}),e.jsx(Ae,{children:e.jsx(oe,{onClick:fe,children:"Close"})})]}),e.jsxs(Fe,{open:le,onClose:J,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Le,{children:"Select an entity"}),e.jsxs(We,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ie,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Y,onChange:Me,placeholder:"Enter name or description"})]}),e.jsx(Ze,{dense:!0,children:jt.filter(y=>y.name.toLowerCase().includes(Y.toLowerCase())||y.description.toLowerCase().includes(Y.toLowerCase())).map((y,me)=>e.jsxs(st,{onClick:()=>Ye(y),sx:pt,children:[y.icon==="wifi"&&e.jsx(z,{children:e.jsx(et,{style:ve})}),y.icon==="ble"&&e.jsx(z,{children:e.jsx(lt,{style:ve})}),y.icon==="hub"&&e.jsx(z,{children:e.jsx(dt,{style:ve})}),y.icon==="component"&&e.jsx(z,{children:e.jsx(Pt,{style:ve})}),y.icon==="matter"&&e.jsx(z,{children:e.jsx(Ft,{style:ve})}),e.jsx(te,{primary:y.name,secondary:y.description,primaryTypographyProps:{style:ut},secondaryTypographyProps:{style:mt}})]},me))})]}),e.jsx(Ae,{children:e.jsx(oe,{onClick:J,children:"Close"})})]}),e.jsxs(Fe,{open:ne,onClose:ce,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Le,{children:["Select an entity for ",ee]}),e.jsx(We,{children:e.jsx(Ze,{dense:!0,children:Qe.filter(y=>y.serial===ee||y.name===ee).map(y=>y.entities?.map((me,Xe)=>e.jsxs(st,{onClick:()=>Q(me),sx:pt,children:[me.icon==="wifi"&&e.jsx(z,{children:e.jsx(et,{style:ve})}),me.icon==="ble"&&e.jsx(z,{children:e.jsx(lt,{style:ve})}),me.icon==="hub"&&e.jsx(z,{children:e.jsx(dt,{style:ve})}),me.icon==="component"&&e.jsx(z,{children:e.jsx(Pt,{style:ve})}),me.icon==="matter"&&e.jsx(z,{children:e.jsx(Ft,{style:ve})}),e.jsx(te,{primary:me.name,secondary:me.description,primaryTypographyProps:{style:ut},secondaryTypographyProps:{style:mt}})]},Xe)))})}),e.jsx(Ae,{children:e.jsx(oe,{onClick:ce,children:"Close"})})]})]})}function je(N){const{onAddClick:M,schema:j,properties:u,title:ee,description:G}=N,[de,le]=o.useState(!1),[V,ne]=o.useState(""),ue=J=>{ne(J.target.value)},Y=()=>{le(!de)},Ce=J=>{a&&console.log(`ObjectFieldTemplate: handleSelectValue value "${J.serial}" for schema "${j.selectFrom}"`),le(!1);let ce="";j.selectFrom==="serial"?ce=J.serial:j.selectFrom==="name"&&(ce=J.name),A(ce),a&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ce}"`),M(j)()},Me=()=>{M(j)()},fe=!j.additionalProperties;return a&&console.log(`ObjectFieldTemplate: isRoot ${fe} newkey "${L}"`),!fe&&L!==""&&(a&&console.log("ObjectFieldTemplate: newkey",L,"properties",u),u.forEach(J=>{if(J.name==="newKey"&&J.content.key==="newKey"&&J.content.props.name==="newKey"&&J.content.props.onKeyChange&&L!==""){a&&console.log("ObjectFieldTemplate: newkey onKeyChange",L);const ce=L;A(""),J.content.props.onKeyChange(ce)}})),e.jsxs(Z,{sx:{margin:"0px",padding:fe?"10px":"5px 10px 0px 10px",border:fe?"none":"1px solid grey"},children:[j.title&&fe&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ie,{sx:ze,children:j.title})}),ee&&!fe&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ie,{sx:ze,children:ee}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[j.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(K,{onClick:Y,size:"small",color:"primary",sx:Pe,children:e.jsx(at,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(K,{onClick:Me,size:"small",color:"primary",sx:Pe,children:e.jsx(ht,{})})})]})]}),j.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ie,{sx:Be,children:j.description})}),u.map(({content:J,name:ce,hidden:Se})=>!Se&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(j.properties[ce].type)?"0px":nn,border:["object","array","boolean"].includes(j.properties[ce].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(j.properties[ce].type)&&e.jsx(ie,{sx:ze,children:ce}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:J})]},ce)),e.jsxs(Fe,{open:de,onClose:Y,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Le,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ie,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:V,onChange:ue,placeholder:"Enter serial or name"})]}),e.jsx(Ze,{dense:!0,children:Qe.filter(J=>J.serial.toLowerCase().includes(V.toLowerCase())||J.name.toLowerCase().includes(V.toLowerCase())).map((J,ce)=>e.jsxs(st,{onClick:()=>Ce(J),sx:pt,children:[J.icon==="wifi"&&e.jsx(z,{children:e.jsx(et,{style:ve})}),J.icon==="ble"&&e.jsx(z,{children:e.jsx(lt,{style:ve})}),J.icon==="hub"&&e.jsx(z,{children:e.jsx(dt,{style:ve})}),e.jsx(te,{primary:J.name,secondary:J.serial,primaryTypographyProps:{style:ut},secondaryTypographyProps:{style:mt}})]},ce))})]}),e.jsx(Ae,{children:e.jsx(oe,{onClick:Y,children:"Close"})})]})]})}function xe(N){const{uiSchema:M}=N,{submitText:j,norender:u}=Ho(M);return u?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:j}),e.jsx(oe,{variant:"contained",color:"primary",onClick:p,children:"Cancel"})]})}function he(N){const{className:M,disabled:j,onClick:u,registry:ee,style:G,uiSchema:de,...le}=N;return e.jsx($,{title:"Remove the item",children:e.jsx(K,{disabled:j,size:"small",color:"primary",onClick:u,children:e.jsx(xt,{})})})}function X(N){const{className:M,disabled:j,onClick:u,registry:ee,uiSchema:G,...de}=N;return e.jsx($,{title:"Add an item",children:e.jsx(K,{size:"small",color:"primary",onClick:u,children:e.jsx(ht,{})})})}function se(N){const{disabled:M,onClick:j,registry:u,style:ee,uiSchema:G,...de}=N;return e.jsx($,{title:"Move up the item",children:e.jsx(K,{size:"small",color:"primary",onClick:j,children:e.jsx(Nt,{})})})}function P(N){const{disabled:M,onClick:j,registry:u,style:ee,uiSchema:G,...de}=N;return e.jsx($,{title:"Move down the item",children:e.jsx(K,{size:"small",color:"primary",onClick:j,children:e.jsx(Dt,{})})})}function O(N){const{id:M,name:j,value:u,schema:ee,readonly:G,onChange:de}=N,[le,V]=o.useState(),ne=Y=>{a&&console.log(`CheckboxWidget ${j} onChangeField:`,Y),V(Y&&Y!==""?Y:void 0)},ue=()=>{a&&console.log(`CheckboxWidget onClick plugin="${s.name}" action="${j}" value="${le}"`),n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:s.name,action:j,value:le,formData:g,id:M}}),ee.buttonClose===!0?p():ee.buttonSave===!0&&x({formData:c})};return ee.buttonText&&ee.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ie,{sx:Be,children:ee.description}),e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>ue(),children:ee.buttonText})]}):ee.buttonField&&ee.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(ie,{sx:Be,children:ee.description}),e.jsx(pe,{id:j+"-input",name:j,label:ee.textLabel,placeholder:ee.textPlaceholder,onChange:Y=>ne(Y.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(oe,{id:j+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>ue(),children:ee.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[j&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ie,{sx:ze,children:j}),e.jsx(Oe,{checked:u,readOnly:G,onChange:()=>de(!u),sx:{padding:"0px",margin:"0px"}})]}),ee.description&&e.jsx(ie,{sx:Be,children:ee.description})]})}function D({schema:N,id:M,name:j,options:u,label:ee,hideLabel:G,required:de,disabled:le,placeholder:V,readonly:ne,value:ue,multiple:Y,autofocus:Ce,onChange:Me,onBlur:fe,onFocus:J,errorSchema:ce,rawErrors:Se=[],registry:Ye,uiSchema:Q,hideError:y,formContext:me,...Xe}){const{enumOptions:Te,enumDisabled:rt,emptyValue:Ie}=u;Y=typeof Y>"u"?!1:!!Y;const wt=Y?[]:"",Mt=typeof ue>"u"||Y&&ue.length<1||!Y&&ue===wt,er=({target:{value:Ne}})=>Me(yt(Ne,Te,Ie)),tr=({target:Ne})=>fe(M,yt(Ne&&Ne.value,Te,Ie)),rr=({target:Ne})=>J(M,yt(Ne&&Ne.value,Te,Ie)),kt=Ro(ue,Te,Y),{InputLabelProps:or,SelectProps:nr,autocomplete:ir,...ar}=Xe,sr=!Y&&N.default===void 0;return e.jsxs(pe,{id:M,name:M,value:!Mt&&typeof kt<"u"?kt:wt,required:de,disabled:le||ne,autoFocus:Ce,autoComplete:ir,placeholder:V,error:Se.length>0,onChange:er,onBlur:tr,onFocus:rr,...ar,select:!0,InputLabelProps:{...or,shrink:!Mt},SelectProps:{...nr,multiple:Y},"aria-describedby":$o(M),children:[sr&&e.jsx(k,{value:"",children:V}),Array.isArray(Te)&&Te.map(({value:Ne,label:lr},It)=>{const dr=Array.isArray(rt)&&rt.indexOf(Ne)!==-1;return e.jsx(k,{value:String(It),disabled:dr,children:lr},It)})]})}return a&&console.log("ConfigPluginDialog rendering..."),!r||!F||!c?null:e.jsxs(Fe,{open:r,onClose:p,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Le,{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(We,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Wo,{schema:F,formData:c,uiSchema:_,validator:To,templates:{FieldTemplate:S,BaseInputTemplate:i,TitleFieldTemplate:H,DescriptionFieldTemplate:W,FieldHelpTemplate:w,FieldErrorTemplate:d,ErrorListTemplate:U,WrapIfAdditionalTemplate:b,ArrayFieldTitleTemplate:m,ArrayFieldDescriptionTemplate:h,ArrayFieldItemTemplate:I,ArrayFieldTemplate:B,ObjectFieldTemplate:je,ButtonTemplates:{SubmitButton:xe,RemoveButton:he,AddButton:X,MoveUpButton:se,MoveDownButton:P}},widgets:{CheckboxWidget:O,SelectWidget:D},onChange:E,onSubmit:x})})]})};function Xt(r){if(a&&console.log(`getQRColor (id: ${r?.id}) received matter:`,r??"undefined"),r===void 0||!r.online||!r.qrPairingCode&&!r.manualPairingCode&&!r.fabricInformations&&!r.sessionInformations)return"red";if(r.commissioned===!1&&r.qrPairingCode&&r.manualPairingCode)return"var(--primary-color)";let p=0,s=0;for(const n of r.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&p++,n.numberOfActiveSubscriptions>0&&(s+=n.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(p===0||s===0)?"var(--secondary-color)":"var(--div-text-color)"}function sn(r,p,s){const n=r?.[s],l=p?.[s];return n==null&&l==null?0:n==null?-1:l==null?1:typeof n=="boolean"&&typeof l=="boolean"?n===l?0:n?1:-1:typeof n=="number"&&typeof l=="number"?n-l:String(n).localeCompare(String(l))}function ln({name:r,title:p,columns:s,rows:n,getRowKey:l,footerLeft:f,footerRight:v,onRowClick:t}){const c=o.useRef(new WeakMap),R=o.useRef(1),F=d=>{if(typeof l=="string"&&d&&d[l]!=null)return d[l];if(typeof l=="function"){const h=l(d);if(h!=null)return h}const i=s?.[0]?.id;if(i&&d&&d[i]!=null)return d[i];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let m=c.current.get(d);return m||(m=`rk_${R.current++}`,c.current.set(d,m)),m},[C,_]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[T,L]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[A,g]=o.useState(!1),[E,x]=o.useState(()=>{try{const d=localStorage.getItem(`${r}_column_visibility`);if(d)return JSON.parse(d)}catch{}return{}}),b=o.useMemo(()=>{const d={};for(const i of s)i.hidden||(d[i.id]=i.required?!0:E[i.id]!==!1);return d},[s,E]),S=o.useMemo(()=>{if(!C||!T)return n;const d=s.find(m=>m.id===C);if(!d||d.noSort)return n;const i=n.map((m,h)=>({el:m,index:h}));return i.sort((m,h)=>{let I;return typeof d.comparator=="function"?I=d.comparator(m.el,h.el):I=sn(m.el,h.el,C),I!==0?T==="asc"?I:-I:m.index-h.index}),i.map(m=>m.el)},[n,C,T,s]),W=d=>{if(C!==d||!C){_(d),L("asc"),localStorage.setItem(`${r}_table_order_by`,d),localStorage.setItem(`${r}_table_order`,"asc");return}if(T==="asc"){L("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}_(null),L(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},H=()=>{g(!A)},w=d=>{x(i=>{const m=s.find(B=>B.id===d);if(m&&m.required)return i;const h=b[d]!==!1,I={...i};h?I[d]=!1:delete I[d];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(I))}catch{}return I})},U=()=>{x({});try{localStorage.removeItem(`${r}_column_visibility`)}catch{}g(!1)};return a&&console.log(`Rendering table ${r}${C&&T?` ordered by ${C}:${T}`:""}`),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(Fe,{open:A,onClose:(d,i)=>{i==="backdropClick"||i==="escapeKeyDown"||H()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Le,{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(We,{children:e.jsx(Dr,{children:s.filter(d=>!d.hidden).map(d=>e.jsx(He,{control:e.jsx(Oe,{disabled:!!d.required,checked:d.required?!0:b[d.id]!==!1,onChange:()=>w(d.id)}),label:d.label},d.id))})}),e.jsxs(Ae,{children:[e.jsx(oe,{onClick:U,children:"Reset"}),e.jsx(oe,{variant:"contained",onClick:d=>{if(d?.currentTarget&&typeof d.currentTarget.blur=="function")try{d.currentTarget.blur()}catch{}const i=document.activeElement;if(i&&i instanceof HTMLElement&&typeof i.blur=="function")try{i.blur()}catch{}H()},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}),p&&e.jsx("p",{className:"MbfWindowHeaderText",children:p}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(K,{onClick:d=>{if(d?.currentTarget?.blur)try{d.currentTarget.blur()}catch{}H()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:`Configure ${r} columns`,children:e.jsx(re,{path:uo,size:"20px",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:s.map(d=>{if(d.hidden||!d.required&&b[d.id]===!1)return null;const i=!d.noSort,m=i&&C===d.id&&!!T;return e.jsxs("th",{onClick:i?()=>W(d.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:d.minWidth,maxWidth:d.maxWidth,textAlign:d.align||"left",cursor:i?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:d.maxWidth?"nowrap":void 0,overflow:d.maxWidth?"hidden":void 0,textOverflow:d.maxWidth?"ellipsis":void 0},"aria-sort":i?m?T==="asc"?"ascending":"descending":"none":void 0,children:[d.label,m&&e.jsxs("span",{style:{marginLeft:6},children:[T==="asc"&&e.jsx(re,{path:mo,size:"15px"}),T==="desc"&&e.jsx(re,{path:go,size:"15px"})]})]},d.id)})})}),e.jsx("tbody",{children:S.map((d,i)=>{const m=F(d);return e.jsx("tr",{className:i%2===0?"table-content-even":"table-content-odd",onClick:t?h=>t(d,m,h):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:s.map(h=>{if(h.hidden||!h.required&&b[h.id]===!1)return null;const I=d[h.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:h.align||"left",padding:"5px 10px",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(I,m,d,h):typeof I=="boolean"?e.jsx(Oe,{checked:I,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 I=="number"?h.format(I):I!=null?String(I):null},h.id)})},m)})})]})}),(f||v)&&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:f}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:v})]})]})}function dn(r){return o.memo(r)}const tt=dn(ln);function cn({storeId:r,setStoreId:p}){const{online:s,sendMessage:n,addListener:l,removeListener:f,getUniqueId:v}=o.useContext(be),{showConfirmCancelDialog:t}=o.useContext(Je),c=o.useRef(v()),[R,F]=o.useState(null),[C,_]=o.useState(null),[T,L]=o.useState([]),A=[{label:"Name",id:"name",required:!0,render:(P,O,D,N)=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(D),children:D.name})})},{label:"Description",id:"description",render:(P,O,D,N)=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(D),children:D.description})})},{label:"Version",id:"version",render:(P,O,D,N)=>e.jsxs(e.Fragment,{children:[D.latestVersion!==void 0&&D.latestVersion!==D.version&&C&&!C.readOnly&&e.jsx($,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>S(D),children:["Update to v.",D.latestVersion]})}),D.version.includes("-dev-")&&D.devVersion!==void 0&&D.devVersion!==D.version&&C&&!C.readOnly&&e.jsx($,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>W(D),children:["Update to new dev v.",D.devVersion.split("-dev-")[0]]})}),e.jsx($,{title:"Plugin version",children:e.jsx("span",{children:D.version})})]})},{label:"Author",id:"author",render:(P,O,D,N)=>e.jsx(e.Fragment,{children:D.author?D.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(P,O,D,N)=>e.jsx(e.Fragment,{children:D.type?D.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(P,O,D,N)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!D.error&&D.enabled&&e.jsx($,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:Xt(D.matter)},onClick:()=>{D.matter?.id&&p(D.matter?.id)},size:"small",children:e.jsx(Bt,{})})}),C&&C.bridgeMode==="childbridge"&&!D.error&&D.enabled&&e.jsx($,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>w(D),size:"small",children:e.jsx(gt,{})})}),e.jsx($,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{disabled:D.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>he(D),size:"small",children:e.jsx(St,{})})}),C&&!C.readOnly&&e.jsx($,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{E("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",D)},size:"small",children:e.jsx(xt,{})})}),D.enabled?e.jsx($,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{E("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",D)},size:"small",children:e.jsx(Nr,{})})}):e.jsx(e.Fragment,{}),D.enabled?e.jsx(e.Fragment,{}):e.jsx($,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>U(D),size:"small",children:e.jsx(Pr,{})})}),e.jsx($,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>m(D),size:"small",children:e.jsx(Fr,{})})}),e.jsx($,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>h(D),size:"small",children:e.jsx(Lr,{})})}),C&&!C.readOnly&&e.jsx($,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>i(D),size:"small",children:e.jsx(qt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(P,O,D,N)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:D.error?e.jsx(e.Fragment,{children:e.jsx(qe,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:D.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(qe,{status:D.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:D.loaded&&D.started&&D.configured?e.jsx(e.Fragment,{children:e.jsx(qe,{status:D.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{status:D.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(qe,{status:D.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(qe,{status:D.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const P=O=>{O.src==="Matterbridge"&&O.dst==="Frontend"&&(ae(O)&&O.method==="refresh_required"&&O.params.changed==="plugins"&&(a&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and sending /api/plugins request`),n({id:c.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),ae(O)&&O.method==="refresh_required"&&O.params.changed==="matter"&&(a&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and setting matter id ${O.params.matter?.id}`),L(D=>{const N=D.findIndex(j=>j.matter?.id===O.params.matter?.id);if(N<0)return a&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and matter id ${O.params.matter?.id} not found`),D;a&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} set matter id ${O.params.matter?.id}`);const M=[...D];return M[N]={...M[N],matter:O.params.matter},M})),ae(O)&&O.method==="refresh_required"&&O.params.changed==="settings"&&(a&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and sending /api/settings request`),n({id:c.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ge(O)&&O.id===c.current&&O.method==="/api/settings"&&(a&&console.log(`HomePlugins (id: ${O.id}) received settings:`,O.response),F(O.response.systemInformation),_(O.response.matterbridgeInformation)),ge(O)&&O.id===c.current&&O.method==="/api/plugins"&&(a&&console.log(`HomePlugins (id: ${O.id}) received ${O.response.length} plugins:`,O.response),L(O.response)))};return l(P),a&&console.log("HomePlugins added WebSocket listener id:",c.current),()=>{f(P),a&&console.log("HomePlugins removed WebSocket listener")}},[l,f,n]),o.useEffect(()=>{s&&(a&&console.log("HomePlugins sending api requests"),n({id:c.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:c.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[s,n]);const g=o.useRef(null),E=(P,O,D,N)=>{a&&console.log(`handleActionWithConfirmCancel ${D} ${N.name}`),g.current=N,t(P,O,D,x,b)},x=P=>{a&&console.log(`handleConfirm action confirmed ${P} ${g.current?.name}`),P==="remove"&&g.current?H(g.current):P==="disable"&&g.current&&U(g.current),g.current=null},b=P=>{a&&console.log(`handleCancel action canceled ${P} ${g.current?.name}`),g.current=null},S=P=>{a&&console.log("handleUpdatePlugin plugin:",P.name),n({id:c.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:P.name,restart:!1}})},W=P=>{a&&console.log("handleUpdateDevPlugin plugin:",P.name),n({id:c.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:P.name+"@dev",restart:!1}})},H=P=>{a&&console.log("handleRemovePlugin plugin:",P.name),n({id:c.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}})},w=P=>{a&&console.log("handleRestartPlugin plugin:",P.name),n({id:c.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}})},U=P=>{a&&console.log("handleEnableDisablePlugin plugin:",P.name,"enabled:",P.enabled),P.enabled===!0?(P.enabled=!1,n({id:c.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}})):(P.enabled=!0,n({id:c.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.name}}))},d=P=>{a&&console.log(`handleHomepagePlugin plugin: ${P.name} homepage: ${P.homepage}`),P.homepage&&window.open(P.homepage,"_blank")},i=P=>{a&&console.log("handleSponsorPlugin plugin:",P.name,"funding:",P.funding),P.funding&&window.open(P.funding,"_blank")},m=P=>{a&&console.log("handleHelpPlugin plugin:",P.name,"help:",P.help),P.help&&window.open(P.help,"_blank")},h=P=>{a&&console.log("handleChangelogPlugin plugin:",P.name,"changelog:",P.changelog),P.changelog&&window.open(P.changelog,"_blank")},[I,B]=o.useState(),[je,xe]=o.useState(!1),he=P=>{a&&console.log("handleConfigPlugin plugin:",P.name),n({id:c.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:P.name}}),n({id:c.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:P.name}}),B(P),X()},X=()=>{xe(!0)},se=()=>{xe(!1)};return a&&console.log("HomePlugins rendering..."),s?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[I&&e.jsx(an,{open:je,onClose:se,plugin:I}),e.jsx(tt,{name:"Plugins",columns:A,rows:T,footerRight:"",footerLeft:""})]}):e.jsx(Ve,{})}const pn=o.memo(cn),un=r=>`${r.pluginName}::${r.serial}`;function mn({storeId:r,setStoreId:p}){const{online:s,sendMessage:n,addListener:l,removeListener:f,getUniqueId:v}=o.useContext(be),[t,c]=o.useState(!1),[R,F]=o.useState(!0),[C,_]=o.useState(null),[T,L]=o.useState([]),[A,g]=o.useState([]),[E,x]=o.useState([]),[b,S]=o.useState([]),W=o.useRef(v()),H=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(d,i,m,h)=>m.reachable===!0?"Online":m.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(d,i)=>{const m=d.reachable===!0?1:d.reachable===!1?0:-1,h=i.reachable===!0?1:i.reachable===!1?0:-1;return m-h}},{label:"Power",id:"powerSource",render:(d,i,m,h)=>m.powerSource==="ac"||m.powerSource==="dc"?e.jsx(Qt,{fontSize:"small",sx:{color:"var(--primary-color)"}}):m.powerSource==="ok"?e.jsx(ft,{fontSize:"small",sx:{color:"green"}}):m.powerSource==="warning"?e.jsx(ft,{fontSize:"small",sx:{color:"yellow"}}):m.powerSource==="critical"?e.jsx(ft,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(d,i,m,h)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[m.matter!==void 0?e.jsx($,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>p(r===m.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:m.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Xt(m.matter)},children:e.jsx(Bt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),m.configUrl?e.jsx($,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>window.open(m.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(St,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),m.selected!==void 0?e.jsx($,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Oe,{checked:m.selected,onChange:I=>U(I,m),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],w=o.useCallback(d=>{d.selected=void 0;const i=T.find(I=>I.name===d.pluginName);if(!i)return console.error(`HomeDevices isSelected: plugin ${d.pluginName} not found for device ${d.name} `),d.selected;const m=i.schemaJson?.properties?.whiteList?.selectFrom;let h=i.configJson.postfix;return h===""&&(h=void 0),i.hasWhiteList===!0&&i.hasBlackList===!0&&m&&(d.selected=!0,m==="serial"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&i.configJson.whiteList.includes(h?d.serial.replace("-"+h,""):d.serial)&&(d.selected=!0),m==="serial"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&!i.configJson.whiteList.includes(h?d.serial.replace("-"+h,""):d.serial)&&(d.selected=!1),m==="serial"&&i.configJson.blackList&&i.configJson.blackList.length>0&&i.configJson.blackList.includes(h?d.serial.replace("-"+h,""):d.serial)&&(d.selected=!1),m==="name"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&i.configJson.whiteList.includes(d.name)&&(d.selected=!0),m==="name"&&i.configJson.whiteList&&i.configJson.whiteList.length>0&&!i.configJson.whiteList.includes(d.name)&&(d.selected=!1),m==="name"&&i.configJson.blackList&&i.configJson.blackList.length>0&&i.configJson.blackList.includes(d.name)&&(d.selected=!1)),d.selected},[T]);o.useEffect(()=>{const d=i=>{if(i.src==="Matterbridge"&&i.dst==="Frontend"){if(ae(i)&&i.method==="refresh_required"&&i.params.changed!=="matter"&&(a&&console.log(`HomeDevices received refresh_required: changed=${i.params.changed} and sending /api/plugins request`),n({id:W.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),ae(i)&&i.method==="refresh_required"&&i.params.changed==="matter"&&(a&&console.log(`HomeDevices received refresh_required: changed=${i.params.changed} and setting matter id ${i.params.matter?.id}`),S(m=>{const h=m.findIndex(B=>B.name.replaceAll(" ","")===i.params.matter?.id);if(h<0)return a&&console.debug(`HomeDevices: matter id ${i.params.matter?.id} not found`),m;const I=[...m];return I[h]={...I[h],matter:i.params.matter},a&&console.log(`HomeDevices received refresh_required: changed=${i.params.changed} and set matter id ${i.params.matter?.id}`),I})),ae(i)&&i.method==="restart_required"&&(a&&console.log("HomeDevices received restart_required"),c(!0)),ae(i)&&i.method==="restart_not_required"&&(a&&console.log("HomeDevices received restart_not_required"),c(!1)),ae(i)&&i.method==="state_update"&&i.params.plugin&&i.params.serialNumber&&i.params.cluster.includes("BasicInformationServer")&&i.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${i.params.plugin} serial ${i.params.serialNumber} value ${i.params.value}`),g(m=>m.map(h=>h.pluginName===i.params.plugin&&h.serial===i.params.serialNumber?{...h,reachable:i.params.value}:h))),ge(i)&&i.id===W.current&&i.method==="/api/settings"&&(a&&console.log(`HomeDevices (id: ${i.id}) received settings:`,i.response),_(i.response),c(i.response.matterbridgeInformation.restartRequired||i.response.matterbridgeInformation.fixedRestartRequired)),ge(i)&&i.id===W.current&&i.method==="/api/plugins"&&(a&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} plugins:`,i.response),i.response)){let m=!0;for(const h of i.response)h.enabled===!0&&(h.loaded!==!0||h.started!==!0||h.error===!0)&&(m=!1);if(!m)return;a&&console.log("HomeDevices reset plugins, devices and selectDevices"),F(!1),L(i.response),g([]),x([]),n({id:W.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),a&&console.log("HomeDevices sent /api/devices");for(const h of i.response)h.enabled===!0&&h.loaded===!0&&h.started===!0&&h.error!==!0&&(n({id:W.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:h.name}}),a&&console.log(`HomeDevices sent /api/select/devices for plugin: ${h.name}`))}if(ge(i)&&i.id===W.current&&i.method==="/api/devices"&&(a&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} devices:`,i.response),i.response)){for(const m of i.response)m.selected=w(m);g(i.response)}ge(i)&&i.id===W.current&&i.method==="/api/select/devices"&&(a&&console.log(`HomeDevices (id: ${i.id}) received ${i.response?.length} selectDevices for plugin ${i.response&&i.response.length>0?i.response[0].pluginName:"without select devices"}:`,i.response),i.response&&i.response.length>0&&x(m=>{const h=m.filter(B=>B.pluginName!==i.response[0].pluginName),I=i.response.map(B=>({...B,selected:w(B)}));return[...h,...I]}))}};return l(d),a&&console.log(`HomeDevices added WebSocket listener id ${W.current}`),()=>{f(d),a&&console.log("HomeDevices removed WebSocket listener")}},[T,l,f,n,w]),o.useEffect(()=>{if(A.length===0&&E.length===0){S([]);return}a&&console.log(`HomeDevices mixing devices (${A.length}) and selectDevices (${E.length})`);const d=[];for(const i of A)d.push(i);for(const i of E)A.find(m=>m.pluginName===i.pluginName&&m.serial.includes(i.serial))||d.push(i);d.length>0&&(S(d),a&&console.log(`HomeDevices mixed ${d.length} devices and selectDevices`))},[T,A,E,S]),o.useEffect(()=>{s&&(a&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:W.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:W.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[s,n]);const U=(d,i)=>{console.log(`handleCheckboxChange: checkbox changed to ${d.target.checked} for device ${i.name} serial ${i.serial}`),S(m=>{const h=m.findIndex(B=>B.pluginName===i.pluginName&&B.serial===i.serial);if(h<0)return console.error(`handleCheckboxChange: device not found ${i.name} serial ${i.serial}`),m;const I=[...m];return I[h]={...I[h],selected:d.target.checked},I}),d.target.checked?n({id:W.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:i.pluginName,serial:i.serial,name:i.name}}):n({id:W.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:i.pluginName,serial:i.serial,name:i.name}})};return a&&console.log("HomeDevices rendering..."),s?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(tt,{name:"Devices",getRowKey:un,rows:b,columns:H,footerLeft:R?"Waiting for the plugins to fully load...":`Registered devices: ${A.length.toString()}/${b.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Ve,{})}const gn=o.memo(mn);function hn(){const[r,p]=o.useState(null),[s,n]=o.useState(null),[l,f]=o.useState([]),[v]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,c]=o.useState(localStorage.getItem("homePageMode")??"devices"),[R,F]=o.useState(""),[C,_]=o.useState(!1),[T,L]=o.useState(!1),[A,g]=o.useState(null),{addListener:E,removeListener:x,online:b,sendMessage:S,logFilterLevel:W,logFilterSearch:H,autoScroll:w,getUniqueId:U}=o.useContext(be),d=o.useRef(U());return o.useEffect(()=>{const i=m=>{m.src==="Matterbridge"&&m.dst==="Frontend"&&(ae(m)&&m.method==="refresh_required"&&m.params.changed==="settings"&&(a&&console.log(`Home received refresh_required: changed=${m.params.changed} and sending /api/settings request`),g(null),f([]),S({id:d.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:d.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),ge(m)&&m.method==="/api/settings"&&m.id===d.current&&(a&&console.log("Home received settings:",m.response),p(m.response.systemInformation),n(m.response.matterbridgeInformation),m.response.matterbridgeInformation.bridgeMode==="bridge"&&(A||g("Matterbridge")),m.response.matterbridgeInformation.bridgeMode==="childbridge"&&l.length>0&&A===null&&!A&&l.length>0&&l[0].matter?.id&&g(l[0].matter.id),m.response.matterbridgeInformation.matterbridgeVersion&&F(`https://github.com/Luligu/matterbridge/blob/${m.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&m.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",m.response.matterbridgeInformation.frontendVersion):m.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&m.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",m.response.matterbridgeInformation.frontendVersion),L(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",m.response.matterbridgeInformation.matterbridgeVersion):m.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",m.response.matterbridgeInformation.matterbridgeVersion),_(!0)),m.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),c("devices")))),ge(m)&&m.method==="/api/plugins"&&m.id===d.current&&(a&&console.log(`Home received plugins (${s?.bridgeMode}):`,m.response),f(m.response),s?.bridgeMode==="childbridge"&&m.response.length>0&&!A&&m.response.length>0&&m.response[0].matter?.id&&g(m.response[0].matter.id)))};return E(i),a&&console.log(`Home added WebSocket listener id ${d.current}`),()=>{x(i),a&&console.log("Home removed WebSocket listener")}},[E,x,S,s,l,A]),o.useEffect(()=>{b&&(a&&console.log("Home received online"),S({id:d.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:d.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[b,S]),a&&console.log("Home rendering..."),!b||!r||!s?e.jsx(Ve,{}):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(Zo,{id:A}),e.jsx(Jo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[T&&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(Wr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),C&&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(R,"_blank"),endIcon:e.jsx(zt,{}),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(Tr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),v&&!s.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(tn,{})]}),v&&e.jsx(pn,{storeId:A,setStoreId:g}),t==="devices"&&e.jsx(gn,{storeId:A,setStoreId:g}),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 "',W,'" and search "',H,'" Scroll: ',w?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(Yt,{})})]})]})]})}const fn=o.memo(hn),_t={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},xn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},bn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},At={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},vn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},yn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},jn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Cn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Sn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Ct={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},wn=[256,257,268,269],Mn=[266,267],kn=[259,260,261,271,272],In=[256,257,268,269,266,267,259,260,261];function q({icon:r,iconColor:p,cluster:s,value:n,unit:l,prefix:f}){return a&&console.log(`Render cluster "${s.clusterName}.${s.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${l}"`),f=f??!1,e.jsxs(Z,{sx:_t,children:[r&&o.cloneElement(r,{key:`${s.clusterId}-${s.attributeId}-icon`,sx:{...xn,color:p??"var(--primary-color)"}}),e.jsxs(Z,{sx:{..._t,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&f===!0&&e.jsx(ie,{sx:At,children:l},`${s.clusterId}-${s.attributeId}-unit`),e.jsx(ie,{sx:bn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${s.clusterId}-${s.attributeId}-value`),l&&f===!1&&e.jsx(ie,{sx:At,children:l},`${s.clusterId}-${s.attributeId}-unit`)]},`${s.clusterId}-${s.attributeId}-valueunitbox`)]},`${s.clusterId}-${s.attributeId}-box`)}function Dn({device:r,endpoint:p,id:s,deviceType:n,clusters:l}){const f=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let v="";return a&&console.log(`Device "${r.name}" endpoint "${p}" id "${s}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>v=`${t.attributeLocalValue} mV`),In.includes(n)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>v=`Level ${t.attributeValue}`),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>v=`Position ${t.attributeLocalValue/100}%`),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>v=`Heat ${t.attributeLocalValue/100}°C `),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>v=v+`Cool ${t.attributeLocalValue/100}°C`),n===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>v=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>v=`${t.attributeLocalValue/1e3} V, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>v=v+`${t.attributeLocalValue/1e3} A, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>v=v+`${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&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:t.attributeLocalValue===!0?e.jsx(et,{}):e.jsx(Rr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(q,{icon:e.jsx(ft,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(q,{icon:e.jsx(Qt,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),wn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx($r,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Mn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(re,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),kn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(re,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Lt,{}),cluster:t,value:"Oven"})),n===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Hr,{}),cluster:t,value:"Fridge"})),n===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(re,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(Lt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Ht,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Ht,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(re,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(q,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(re,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(q,{icon:t.attributeValue==="1"?e.jsx(Er,{}):e.jsx(_r,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Wt,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(Wt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(q,{icon:e.jsx(re,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(re,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Ot,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Ot,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(q,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:f[t.attributeLocalValue??0]})),n===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:t.attributeValue==="true"?e.jsx(Yr,{}):e.jsx(Xr,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Zr,{}):e.jsx(eo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(to,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),n===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(q,{icon:e.jsx(ro,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:vn,children:e.jsx(ie,{sx:yn,children:v})}),e.jsx(Z,{sx:jn,children:e.jsx(ie,{sx:Cn,children:r.name})}),e.jsxs(Z,{sx:Sn,children:[a&&e.jsx(ie,{sx:Ct,children:p}),e.jsx(ie,{sx:Ct,children:s}),a&&e.jsxs(ie,{sx:Ct,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function Nn({filter:r}){const{online:p,sendMessage:s,addListener:n,removeListener:l,getUniqueId:f}=o.useContext(be),[v,t]=o.useState(null),[c,R]=o.useState([]),[F,C]=o.useState([]),[_,T]=o.useState(F),[L,A]=o.useState({}),[g,E]=o.useState({}),[x,b]=o.useState({}),S=o.useRef(f());o.useEffect(()=>{const H=w=>{if(w.src==="Matterbridge"&&w.dst==="Frontend"){if(ae(w)&&w.method==="refresh_required"&&(a&&console.log(`DevicesIcons received refresh_required: changed=${w.params.changed} and sending api requests`),s({id:S.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:S.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:S.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),ge(w)&&w.method==="/api/settings"&&w.response&&(a&&console.log("DevicesIcons received settings:",w.response),t(w.response)),ge(w)&&w.method==="/api/plugins"&&w.response&&(a&&console.log("DevicesIcons received plugins:",w.response),R(w.response)),ge(w)&&w.method==="/api/devices"&&w.response){a&&console.log(`DevicesIcons received ${w.response.length} devices:`,w.response),C(w.response);for(const U of w.response)a&&console.log("DevicesIcons sending /api/clusters"),s({id:S.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:U.pluginName,endpoint:U.endpoint||0}})}if(ge(w)&&w.method==="/api/clusters"&&w.response){if(a&&console.log(`DevicesIcons received for device "${w.response.deviceName}" serial "${w.response.serialNumber}" deviceType ${w.response.deviceTypes.join(" ")} clusters (${w.response.clusters.length}):`,w.response),w.response.clusters.length===0)return;const U=w.response.serialNumber;L[U]=[],g[U]=w.response.deviceTypes,x[U]=[];for(const d of w.response.clusters)L[U].find(i=>i.endpoint===d.endpoint)||L[U].push({endpoint:d.endpoint,id:d.id,deviceTypes:d.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(d.clusterName)&&x[U].push(d);A({...L}),E({...g}),b({...x}),a&&console.log(`DevicesIcons endpoints for "${U}":`,L[U]),a&&console.log(`DevicesIcons deviceTypes for "${U}":`,g[U]),a&&console.log(`DevicesIcons clusters for "${U}":`,x[U])}}};return n(H),a&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(H),a&&console.log("DevicesIcons useEffect webSocket unmounted")}},[n,l,s]),o.useEffect(()=>(a&&console.log("DevicesIcons useEffect online mounting"),p&&(a&&console.log("DevicesIcons useEffect online sending api requests"),s({id:S.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:S.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:S.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")}),[p,s]),o.useEffect(()=>{if(r===""){T(F);return}const H=F.filter(w=>w.name.toLowerCase().includes(r)||w.serial.toLowerCase().includes(r));T(H)},[F,r]);const W=o.memo(Dn);return a&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:_.map(H=>L[H.serial]&&L[H.serial].map(w=>w.deviceTypes.map(U=>e.jsx(W,{device:H,endpoint:w.endpoint,id:w.id,deviceType:U,clusters:x[H.serial].filter(d=>d.endpoint===w.endpoint)},`${H.pluginName}-${H.uniqueId}-${U}`))))})}const Pn=o.memo(Nn),Fn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(r,p,s,n)=>s.configUrl?e.jsx(K,{onClick:()=>window.open(s.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(St,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Ln=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(r,p,s,n)=>Array.isArray(r)?e.jsx(e.Fragment,{children:r.map(l=>`0x${l.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:r})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(r,p,s,n)=>e.jsx($,{title:String(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:String(r)})})}],Wn=r=>`${r.pluginName}::${r.uniqueId}`,Tn=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Rn(){const{online:r,sendMessage:p,addListener:s,removeListener:n,getUniqueId:l}=o.useContext(be),[f,v]=o.useState([]),[t,c]=o.useState(f),[R,F]=o.useState([]),[C,_]=o.useState(0),[T,L]=o.useState(""),[A,g]=o.useState("icon"),[E,x]=o.useState(null),[b,S]=o.useState(null),[W,H]=o.useState(null),[w,U]=o.useState(null),d=o.useRef(l());o.useEffect(()=>{const I=B=>{if(a&&console.log("Devices received WebSocket Message:",B),B.src==="Matterbridge"&&B.dst==="Frontend"&&(ae(B)&&B.method==="refresh_required"&&B.params.changed==="devices"&&(a&&console.log(`Devices received refresh_required: changed=${B.params.changed} and sending /api/devices request`),p({id:d.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),ge(B)&&B.method==="/api/devices"&&(a&&console.log(`Devices received ${B.response.length} devices:`,B.response),v(B.response)),ge(B)&&B.method==="/api/clusters")){a&&console.log(`Clusters received ${B.response.clusters.length} clusters for plugin ${B.response.plugin}:`,B.response),F(B.response.clusters);const je={};for(const xe of B.response.clusters)a&&console.log("Cluster:",xe.endpoint),je[xe.endpoint]?je[xe.endpoint]++:je[xe.endpoint]=1;_(Object.keys(je).length)}};return s(I),a&&console.log("Devices added WebSocket listener"),()=>{n(I),a&&console.log("Devices removed WebSocket listener")}},[s,n,p]),o.useEffect(()=>{r&&(a&&console.log("Devices sending api requests"),p({id:d.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),p({id:d.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),p({id:d.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,p]),o.useEffect(()=>{E&&b&&(a&&console.log("Devices sending /api/clusters"),p({id:d.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:E,endpoint:Number(b)}}))},[E,b,p]),o.useEffect(()=>{if(T===""){c(f);return}const I=f.filter(B=>B.name.toLowerCase().includes(T)||B.serial.toLowerCase().includes(T));c(I)},[f,T]),o.useEffect(()=>{const I=localStorage.getItem("devicesFilter");I&&L(I)},[]),o.useEffect(()=>{const I=localStorage.getItem("devicesViewMode");I&&g(I)},[]);const i=I=>{L(I.target.value.toLowerCase()),localStorage.setItem("devicesFilter",I.target.value.toLowerCase())},m=I=>{g(I),localStorage.setItem("devicesViewMode",I)},h=I=>{if(I.uniqueId===w){U(null),x(null),S(null),H(null);return}U(I.uniqueId),x(I.pluginName),S(I.endpoint?I.endpoint.toString():null),H(I.name)};return 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(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ie,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:T,onChange:i,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(ie,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(K,{onClick:()=>m("table"),"aria-label":"Table View",disabled:A==="table",children:e.jsx($,{title:"Table View",children:e.jsx(oo,{style:{color:A==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(K,{onClick:()=>m("icon"),"aria-label":"Icon View",disabled:A==="icon",children:e.jsx($,{title:"Icon View (beta)",children:e.jsx(no,{style:{color:A==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),A==="table"&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${E&&b?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(tt,{name:"Registered devices",getRowKey:Wn,onRowClick:h,rows:t,columns:Fn,footerLeft:`Total devices: ${t.length.toString()}`})}),A==="table"&&E&&b&&e.jsx("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(tt,{name:"Clusters",title:W||"",getRowKey:Tn,rows:R,columns:Ln,footerLeft:`Total child endpoints: ${C-1}`})}),A==="icon"&&e.jsx(Pn,{filter:T})]}):e.jsx(Ve,{})}const $n=o.memo(Rn);function Hn(){const[r,p]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[s,n]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[l,f]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:v,setLogFilters:t,online:c,setAutoScroll:R}=o.useContext(be),F=L=>{p(L.target.value),t(L.target.value,s),localStorage.setItem("logFilterLevel",L.target.value),a&&console.log("handleChangeLevel called with value:",L.target.value)},C=L=>{n(L.target.value),t(r,L.target.value),localStorage.setItem("logFilterSearch",L.target.value),a&&console.log("handleChangeSearch called with value:",L.target.value)},_=L=>{f(L.target.checked),R(L.target.checked),localStorage.setItem("logAutoScroll",L.target.value?"true":"false"),a&&console.log("handleAutoScrollChange called with value:",L.target.checked)},T=()=>{a&&console.log("handleClearLogsClick called"),v([])};return a&&console.log("Logs rendering..."),c?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(Tt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ge,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:F,children:[e.jsx(k,{value:"debug",children:"Debug"}),e.jsx(k,{value:"info",children:"Info"}),e.jsx(k,{value:"notice",children:"Notice"}),e.jsx(k,{value:"warn",children:"Warn"}),e.jsx(k,{value:"error",children:"Error"}),e.jsx(k,{value:"fatal",children:"Fatal"})]}),e.jsx(Tt,{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:s,onChange:C,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(He,{control:e.jsx(Oe,{checked:l,onChange:_}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx($,{title:"Clear the logs",children:e.jsx(oe,{onClick:T,endIcon:e.jsx(xt,{}),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(Yt,{})})]}):e.jsx(Ve,{})}const On=o.memo(Hn),En=({open:r,ip:p,onClose:s,onSave:n})=>{const l=p?p.split(".").slice(0,3).join(".")+".1":"",[f,v]=o.useState("dhcp"),[t,c]=o.useState({ip:p??"",subnet:"255.255.255.0",gateway:l,dns:l}),R=_=>T=>{c({...t,[_]:T.target.value})},F=()=>{s()},C=()=>{n({type:f,...t}),s()};return e.jsxs(Fe,{open:r,onClose:(_,T)=>{T==="backdropClick"||T==="escapeKeyDown"||s()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Le,{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(We,{dividers:!0,children:[e.jsxs(Kt,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(Gt,{row:!0,value:f,onChange:_=>v(_.target.value),children:[e.jsx(He,{value:"dhcp",control:e.jsx(bt,{}),label:"DHCP"}),e.jsx(He,{value:"static",control:e.jsx(bt,{}),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:R("ip")})}),e.jsx($e,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:R("subnet")})}),e.jsx($e,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:R("gateway")})}),e.jsx($e,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:R("dns")})})]})]}),e.jsxs(Ae,{children:[e.jsx(oe,{onClick:F,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:C,children:"Save"})]})]})},_n=({open:r,onClose:p,onSave:s})=>{const[n,l]=o.useState(""),[f,v]=o.useState(""),t=T=>{l(T.target.value)},c=T=>{v(T.target.value)},R=n.length>0&&n===f,F=()=>{p()},C=()=>{R&&(s(n),p())},_=()=>{s(""),p()};return e.jsxs(Fe,{open:r,onClose:(T,L)=>{L==="backdropClick"||L==="escapeKeyDown"||p()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Le,{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(We,{dividers:!0,children:e.jsx(Kt,{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:c,error:f!==""&&n!==f,helperText:f!==""&&n!==f?"Passwords do not match":""})})]})})}),e.jsxs(Ae,{children:[e.jsx(oe,{onClick:F,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:C,disabled:!R,children:"Change"}),e.jsx(oe,{variant:"contained",onClick:_,children:"Reset"})]})]})};function An(){const{online:r,addListener:p,removeListener:s,sendMessage:n,getUniqueId:l}=o.useContext(be),[f,v]=o.useState(null),[t,c]=o.useState(null),R=o.useRef(l());return o.useEffect(()=>{const F=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(ae(C)&&C.method==="refresh_required"&&C.params.changed==="settings"&&(a&&console.log(`Settings received refresh_required: changed=${C.params.changed} and sending /api/settings request`),n({id:R.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ge(C)&&C.method==="/api/settings"&&(a&&console.log("Settings received /api/settings:",C.response),v(C.response.matterbridgeInformation),c(C.response.systemInformation)))};return p(F),a&&console.log("Settings added WebSocket listener"),()=>{s(F),a&&console.log("Settings removed WebSocket listener")}},[p,s,n]),o.useEffect(()=>{r&&(a&&console.log("Settings received online"),n({id:R.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(Vn,{matterbridgeInfo:f,systemInfo:t}),e.jsx(Un,{matterbridgeInfo:f}),e.jsx(qn,{matterbridgeInfo:f})]})}):e.jsx(Ve,{})):null}function Vn({matterbridgeInfo:r,systemInfo:p}){const{sendMessage:s,getUniqueId:n}=o.useContext(be),[l,f]=o.useState("bridge"),[v,t]=o.useState("Info"),[c,R]=o.useState(!1),[F,C]=o.useState("dark"),[_,T]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[L,A]=o.useState(localStorage.getItem("homePageMode")??"logs"),[g,E]=o.useState(localStorage.getItem("virtualMode")??"outlet"),x=o.useRef(n()),[b,S]=o.useState(!1),W=()=>S(!1),H=X=>{a&&console.log("handleSaveNetConfig called with config:",X),s({id:x.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:X})},[w,U]=o.useState(!1),d=()=>U(!1),i=X=>{a&&console.log("handleSaveChangePassword called with password:",X),s({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:X}})};o.useEffect(()=>{r&&(f(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),R(r.fileLogger),E(r.virtualMode))},[r]),o.useEffect(()=>{const X=localStorage.getItem("frontendTheme");X&&C(X)},[]);const m=X=>{a&&console.log("handleChangeBridgeMode called with value:",X.target.value),f(X.target.value),s({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:X.target.value}})},h=X=>{a&&console.log("handleChangeMbLoggerLevel called with value:",X.target.value),t(X.target.value),s({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:X.target.value}})},I=X=>{a&&console.log("handleLogOnFileMbChange called with value:",X.target.checked),R(X.target.checked),s({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:X.target.checked}})},B=X=>{const se=X.target.value;a&&console.log("handleChangeTheme called with value:",se),C(se),localStorage.setItem("frontendTheme",se),document.body.setAttribute("frontend-theme",se)},je=X=>{const se=X.target.checked;a&&console.log("handleChangeHomePagePlugins called with value:",se),T(se),localStorage.setItem("homePagePlugins",se?"true":"false")},xe=X=>{const se=X.target.value;a&&console.log("handleChangeHomePageMode called with value:",se),A(se),localStorage.setItem("homePageMode",se)},he=X=>{const se=X.target.value;a&&console.log("handleChangeVirtualMode called with value:",se),E(se),localStorage.setItem("virtualMode",se),s({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:se}})};return!r||!p?null: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:b,ip:p.ipv4Address,onClose:W,onSave:H}),e.jsx(_n,{open:w,onClose:d,onSave:i}),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(Gt,{row:!0,name:"mode-buttons-group",value:l,onChange:m,children:[e.jsx(He,{value:"bridge",control:e.jsx(bt,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(He,{value:"childbridge",control:e.jsx(bt,{}),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(Ge,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:v,onChange:h,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(He,{style:{padding:"0px",margin:"0px"},control:e.jsx(Oe,{checked:c,onChange:I,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(Ge,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:F,onChange:B,children:[e.jsx(k,{value:"classic",children:"Classic"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{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(Oe,{checked:_,onChange:je,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(Ge,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:L,onChange:xe,children:[e.jsx(k,{value:"logs",children:"Logs"}),e.jsx(k,{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(Ge,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:g,onChange:he,children:[e.jsx(k,{value:"disabled",children:"Disabled"}),e.jsx(k,{value:"outlet",children:"Outlet"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"switch",children:"Switch"}),e.jsx(k,{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:()=>U(!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:()=>S(!0),children:"Configure IP"})})]})})]})}function Un({matterbridgeInfo:r}){const{sendMessage:p,getUniqueId:s}=o.useContext(be),[n,l]=o.useState("Info"),[f,v]=o.useState(!1),[t,c]=o.useState(""),[R,F]=o.useState(""),[C,_]=o.useState(""),[T,L]=o.useState(""),[A,g]=o.useState(""),[E,x]=o.useState(""),b=o.useRef(s());o.useEffect(()=>{r&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),v(r.matterFileLogger),c(r.matterMdnsInterface||""),F(r.matterIpv4Address||""),_(r.matterIpv6Address||""),L(r.matterPort?r.matterPort.toString():""),g(r.matterDiscriminator?r.matterDiscriminator.toString():""),x(r.matterPasscode?r.matterPasscode.toString():""))},[r]);const S=h=>{a&&console.log("handleChangeMjLoggerLevel called with value:",h.target.value),l(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:h.target.value}})},W=h=>{a&&console.log("handleLogOnFileMjChange called with value:",h.target.checked),v(h.target.checked),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:h.target.checked}})},H=h=>{a&&console.log("handleChangeMdnsInterface called with value:",h.target.value),c(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:h.target.value}})},w=h=>{a&&console.log("handleChangeIpv4Address called with value:",h.target.value),F(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:h.target.value}})},U=h=>{a&&console.log("handleChangeIpv6Address called with value:",h.target.value),_(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:h.target.value}})},d=h=>{a&&console.log("handleChangeMatterPort called with value:",h.target.value),L(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:h.target.value}})},i=h=>{a&&console.log("handleChangeMatterDiscriminator called with value:",h.target.value),g(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:h.target.value}})},m=h=>{a&&console.log("handleChangemMatterPasscode called with value:",h.target.value),x(h.target.value),p({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:h.target.value}})};return r?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(Ge,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:S,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(He,{style:{padding:"0px",margin:"0px"},control:e.jsx(Oe,{checked:f,onChange:W,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: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:"Ipv4 address:"}),e.jsx(pe,{value:R,onChange:w,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:C,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 port:"}),e.jsx(pe,{value:T,onChange:d,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:A,onChange:i,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:E,onChange:m,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function qn({matterbridgeInfo:r}){return r?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(_e,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(_e,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(_e,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(_e,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(_e,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(_e,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(_e,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]}):null}function _e({value:r,label:p}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:p,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)"}}}})}const zn=o.memo(An);function Bn(){const{online:r,sendMessage:p,addListener:s,removeListener:n,getUniqueId:l}=o.useContext(be),{showSnackbarMessage:f,closeSnackbarMessage:v}=o.useContext(Je),[t,c]=o.useState(null),[R,F]=o.useState([]),[C,_]=o.useState([]),[T,L]=o.useState(null),[A,g]=o.useState({cpuUsage:0}),[E,x]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[b,S]=o.useState({systemUptime:"",processUptime:""}),W=o.useRef(-1),[H,w]=o.useState(()=>Zt);W.current||(W.current=l(),console.log("Test uniqueId:",W)),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const d=i=>{if(i.src==="Matterbridge"&&i.dst==="Frontend"){if(ae(i)&&i.method==="restart_required"&&(console.log("Test received restart_required"),f("Restart required",0)),ae(i)&&i.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${i.params.changed} and sending api requests`),f("Refresh required",0),p({id:W.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),p({id:W.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),p({id:W.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),ae(i)&&i.method==="memory_update"&&(console.log("Test received memory_update",i),x(i.params)),ae(i)&&i.method==="cpu_update"&&(console.log("Test received cpu_update",i),g(i.params)),ae(i)&&i.method==="uptime_update"&&(console.log("Test received uptime_update",i),S(i.params)),ge(i)&&i.method==="/api/settings"&&i.response&&(console.log("Test received /api/settings:",i.response),f("Test received /api/settings"),c(i.response)),ge(i)&&i.method==="/api/plugins"&&i.response&&(console.log(`Test received ${i.response.length} plugins:`,i.response),f("Test received /api/plugins"),F(i.response)),ge(i)&&i.method==="/api/devices"&&i.response){console.log(`Test received ${i.response.length} devices:`,i.response),f("Test received /api/devices"),_(i.response);for(const m of i.response)console.log("Test sending /api/clusters for device:",m.pluginName,m.name,m.endpoint),p({id:W.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:m.pluginName,endpoint:m.endpoint||0}})}ge(i)&&i.method==="/api/clusters"&&i.response&&(console.log(`Test received ${i.response.clusters.length} clusters for device ${i.response.deviceName} endpoint ${i.response.endpoint}:`,i),f("Test received /api/clusters"),L(i.response))}};return s(d),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(d),console.log("Test useEffect WebSocketMessage unmounted")}},[s,n,p,f]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),p({id:W.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),p({id:W.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),p({id:W.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,p,f]);const U=o.useCallback(d=>String(d.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(tt,{name:"Test",columns:Kn,rows:H,getRowKey:U,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"),v("Refresh required"),v("Restart required"),v("Test permanent message removal")},children:"Test"}),e.jsx(oe,{variant:"outlined",onClick:()=>{w(d=>{const i=d.findIndex(B=>B.code==="F123");if(i===-1)return d;const m=d[i],h={...m,population:(m.population||0)+1},I=d.slice();return I[i]=h,I})},children:"Update F123"})]})]})}):e.jsx(Ve,{})}const Qn=o.memo(Bn),Kn=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(r,p,s,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,p,s,n)=>s.isIsland?"🏝️":"🏞️"}];function ye(r,p,s,n,l){const f=s/n;return{name:r,code:p,population:s,size:n,density:f,isIsland:l}}const Zt=[ye("India","IN",1324171354,3287263,!1),ye("China","CN",1403500365,9596961,!1),ye("Italy","IT",60483973,301340,!1),ye("United States","US",327167434,9833520,!1),ye("Canada is a truly wonderful country","CA",37602103,9984670,!1),ye("Australia","AU",25475400,7692024,!0),ye("Germany","DE",83019200,357578,!1),ye("Ireland","IE",4857e3,70273,!0),ye("Mexico","MX",126577691,1972550,!1),ye("Japan","JP",126317e3,377973,!0),ye("France","FR",67022e3,640679,!1),ye("United Kingdom","GB",67545757,242495,!0),ye("Russia","RU",146793744,17098246,!1),ye("Nigeria","NG",200962417,923768,!1),ye("Brazil","BR",210147125,8515767,!1)],Vt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Ut=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let r=0;r<2e3;r++){const p=`${Vt[r%Vt.length]}${Ut[r%Ut.length]} ${r}`,s=`F${r.toString().padStart(3,"0")}`,n=Math.floor(Math.random()*1e9),l=Math.floor(Math.random()*1e7),f=Math.random()<.2;Zt.push(ye(p,s,n,l,f))}function Gn(r,p){a&&console.log("getCssVariable:",r,"defaultValue",p);const s=getComputedStyle(document.body).getPropertyValue(r).trim();return s||console.error("getCssVariable: undefined",s),s||p}function Jn(r){return io({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 Yn=()=>{a=!a};function Xn({setLoggedIn:r}){const[p,s]=o.useState(""),[n,l]=o.useState(""),f={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},v={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)"},t={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)"},c=async F=>{try{const C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:F})});if(C.ok){const{valid:_}=await C.json();_?r(!0):F!==""&&l("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},R=F=>{F.preventDefault(),c(p)};return c(""),e.jsx("div",{style:f,children:e.jsxs("form",{onSubmit:R,style:v,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:p,onChange:F=>s(F.target.value),style:t,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:n&&e.jsx("p",{style:{color:"red"},children:n})})]})})}function Zn(){const[r,p]=o.useState(!1);a&&console.log("Setting frontend theme");const s=localStorage.getItem("frontendTheme");a&&console.log("Saved theme:",s),s?document.body.setAttribute("frontend-theme",s):document.body.setAttribute("frontend-theme","dark");const n=Gn("--primary-color","#1976d2");a&&console.log("Primary color from CSS:",n);const l=Jn(n),f=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return a&&(console.log("Loading App..."),console.log("- production mode"),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${f}"`)),r?e.jsx(ao,{theme:l,children:e.jsx(fr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Vo,{children:e.jsx(Uo,{children:e.jsx(cr,{basename:f,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(zo,{}),e.jsxs(pr,{children:[e.jsx(Ue,{path:"/",element:e.jsx(fn,{})}),e.jsx(Ue,{path:"/devices",element:e.jsx($n,{})}),e.jsx(Ue,{path:"/log",element:e.jsx(On,{})}),e.jsx(Ue,{path:"/settings",element:e.jsx(zn,{})}),e.jsx(Ue,{path:"/test",element:e.jsx(Qn,{})}),e.jsx(Ue,{path:"*",element:e.jsx(ur,{to:"/"})})]})]})})})})})}):e.jsx(Xn,{setLoggedIn:p})}mr.createRoot(document.getElementById("root")).render(e.jsx(gr.StrictMode,{children:e.jsx(Zn,{})}));
23
+ */var we=(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))(we||{});function ae(r){return r.id>=0&&r.id<=101}function ge(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function Ho({open:r,title:u,message:a,onConfirm:i,onCancel:s}){const v=t=>{n&&console.log("Confirmed"),t.preventDefault(),i()},M=t=>{n&&console.log("Canceled"),t.preventDefault(),s()};return e.jsxs(Ne,{open:r,children:[e.jsx(Fe,{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:u})]})}),e.jsxs(Le,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:a})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ie,{onClick:v,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:M,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const lt=[],Je=o.createContext(null);function Oo({children:r}){const{enqueueSnackbar:u,closeSnackbar:a}=pr(),i=o.useCallback(f=>{n&&console.log(`UiProvider closeSnackbarMessage: message ${f}`);const y=lt.findIndex(H=>H.message===f);y!==-1&&(a(lt[y].key),lt.splice(y,1),n&&console.log(`UiProvider closeSnackbarMessage: message ${f} removed from persistMessages`))},[a]),s=o.useCallback((f,y,H)=>{n&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${y}`);const x=u(f,{variant:"default",autoHideDuration:y==null||y>0?(y??5)*1e3:null,persist:y===0,content:w=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(mr,{severity:H??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>a(w),action:e.jsx(Q,{size:"small",onClick:()=>a(w),sx:{color:"#fff"},children:e.jsx(gr,{fontSize:"small"})}),children:f},w)},w)});y===0&&(n&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${y} - persist key ${x}`),lt.push({message:f,key:x}))},[u,a]),[v,M]=o.useState(!1),[t,d]=o.useState(""),[$,L]=o.useState(""),[C,A]=o.useState(""),T=o.useRef(null),W=o.useRef(null),_=()=>{n&&console.log(`UiProvider handle confirm action ${C}`),M(!1),T.current&&T.current(C)},m=()=>{n&&console.log(`UiProvider handle cancel action ${C}`),M(!1),W.current&&W.current(C)},E=o.useCallback((f,y,H,x,w)=>{n&&console.log(`UiProvider showConfirmCancelDialog for command ${H}`),d(f),L(y),A(H),T.current=x,W.current=w,M(!0)},[]),b=o.useMemo(()=>({showSnackbarMessage:s,closeSnackbarMessage:i,closeSnackbar:a,showConfirmCancelDialog:E}),[s,i,a,E]);return e.jsxs(Je.Provider,{value:b,children:[e.jsx(Ho,{open:v,title:t,message:$,onConfirm:_,onCancel:m}),r]})}const Qt=o.createContext(null),be=o.createContext(null);function Eo({children:r}){const[u,a]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,s]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[v,M]=o.useState([]),[t,d]=o.useState(1e3),[$,L]=o.useState(!0),[C,A]=o.useState(!1),{showSnackbarMessage:T,closeSnackbarMessage:W,closeSnackbar:_}=o.useContext(Je),m=o.useRef([]),E=o.useRef(null),b=o.useRef(1),f=o.useRef(Math.floor(Math.random()*999e3)+1e3),y=o.useRef(null),H=o.useRef(null),x=o.useRef(null),w=o.useRef(u),z=o.useRef(i),c=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),l=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),g=100,h=60,F=50,G=300;o.useEffect(()=>{w.current=u},[u]),o.useEffect(()=>{z.current=i},[i]);const ye=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),xe=o.useCallback(S=>{if(E.current&&E.current.readyState===WebSocket.OPEN)try{S.id===void 0&&(S.id=f.current);const p=JSON.stringify(S);E.current.send(p),n&&console.log("WebSocket sent message:",S)}catch(p){n&&console.error(`WebSocket error sending message: ${p}`)}else n&&console.error("WebSocket message not sent, WebSocket not connected:",S)},[]),he=o.useCallback((S,p)=>{const ee=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${S}</span>`;M(K=>[...K,ee+' <span style="color: var(--main-log-color);">'+p+"</span>"])},[]),X=o.useCallback((S,p)=>{a(S),s(p),he("WebSocket",`Filtering by log level "${S}" and log search "${p}"`)},[he]),se=o.useCallback(S=>{n&&console.log("WebSocket addListener:",S),m.current=[...m.current,S],n&&console.log("WebSocket addListener total listeners:",m.current.length)},[]),N=o.useCallback(S=>{n&&console.log("WebSocket removeListener:",S),m.current=m.current.filter(p=>p!==S),n&&console.log("WebSocket removeListener total listeners:",m.current.length)},[]),O=o.useCallback(()=>{c===""||c===null||c===void 0||(he("WebSocket",`Connecting to WebSocket: ${c}`),E.current=new WebSocket(c),E.current.onmessage=S=>{C||A(!0);try{const p=JSON.parse(S.data);if(p.id===void 0)return;if(p.error&&n&&console.error("WebSocket error message:",p),p.id===f.current&&p.src==="Matterbridge"&&p.dst==="Frontend"&&p.response==="pong"){n&&console.log("WebSocket pong response message:",p,"listeners:",m.current.length),H.current&&clearTimeout(H.current),m.current.forEach(K=>K(p));return}if(p.id===we.RefreshRequired){n&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.RestartRequired){n&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.RestartNotRequired){n&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.CpuUpdate){n&&console.log("WebSocket WS_ID_CPU_UPDATE message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.MemoryUpdate){n&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.UptimeUpdate){n&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.Snackbar&&p.params&&p.params.message){n&&console.log("WebSocket WS_ID_SNACKBAR message:",p,"listeners:",m.current.length),T(p.params.message,p.params.timeout,p.params.severity);return}else if(p.id===we.CloseSnackbar&&p.params&&p.params.message){n&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",p,"listeners:",m.current.length),W(p.params.message);return}else if(p.id===we.ShellySysUpdate){n&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id===we.ShellyMainUpdate){n&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}else if(p.id!==we.Log){n&&console.log("WebSocket message:",p,"listeners:",m.current.length),m.current.forEach(K=>K(p));return}if(!p.params||!p.params.level||!p.params.time||!p.params.name||!p.params.message||["debug","info","notice","warn","error","fatal"].includes(p.params.level)&&(w.current==="info"&&p.params.level==="debug"||w.current==="notice"&&(p.params.level==="debug"||p.params.level==="info")||w.current==="warn"&&(p.params.level==="debug"||p.params.level==="info"||p.params.level==="notice")||w.current==="error"&&(p.params.level==="debug"||p.params.level==="info"||p.params.level==="notice"||p.params.level==="warn")||w.current==="fatal"&&(p.params.level==="debug"||p.params.level==="info"||p.params.level==="notice"||p.params.level==="warn"||p.params.level==="error"))||z.current!=="*"&&z.current!==""&&!p.params.message.toLowerCase().includes(z.current.toLowerCase())&&!p.params.name.toLowerCase().includes(z.current.toLowerCase())||p.params.name==="Commissioning"&&p.params.message.includes("is uncommissioned"))return;M(K=>{const de=`<span style="color: #505050;">[${p.params?.time}]</span>`,le=je=>{switch(je?.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"}},V=je=>{switch(je?.toLowerCase()){case"warn":return"black";default:return"white"}},ue=`${`<span style="background-color: ${le(p.params?.level)}; color: ${V(p.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${p.params?.level}</span>`} ${de} <span style="color: #09516d;">[${p.params?.name}]</span> <span style="color: var(--main-log-color);">${p.params?.message}</span>`,Y=[...K,ue];return Y.length>t?Y.slice(t/10):Y})}catch(p){console.error(`WebSocketUse error parsing message: ${p}`)}},E.current.onopen=()=>{n&&console.log(`WebSocket: Connected to WebSocket: ${c}`),he("WebSocket",`Connected to WebSocket: ${c}`),A(!0),_(),b.current=1,x.current=setTimeout(()=>{y.current=setInterval(()=>{xe({id:f.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{n&&console.error(`WebSocketUse: No pong response received from WebSocket: ${c}`),he("WebSocket",`No pong response received from WebSocket: ${c}`),A(!1)},1e3*F)},1e3*h)},1e3*G)},E.current.onclose=()=>{n&&console.error(`WebSocket: Disconnected from WebSocket ${l?"with Ingress":""}: ${c}`),he("WebSocket",`Disconnected from WebSocket: ${c}`),A(!1),_(),x.current&&clearTimeout(x.current),H.current&&clearTimeout(H.current),y.current&&clearInterval(y.current),he("WebSocket",`Reconnecting (attempt ${b.current} of ${g}) to WebSocket${l?" (Ingress)":""}: ${c}`),l?setTimeout(D,5e3):b.current===1?D():b.current<g?setTimeout(D,1e3*b.current):he("WebSocket",`Reconnect attempts exceeded limit of ${g} retries, refresh the page to reconnect to: ${c}`),b.current=b.current+1},E.current.onerror=S=>{n&&console.error(`WebSocket: WebSocket error connecting to ${c}:`,S),he("WebSocket",`WebSocket error connecting to ${c}`)})},[c]),D=o.useCallback(()=>{n&&console.log(`WebSocket attemptReconnect ${b.current}/${g} to:`,c),O()},[O]);o.useEffect(()=>(O(),()=>{E.current&&E.current.readyState===WebSocket.OPEN&&E.current.close()}),[O]);const P=o.useMemo(()=>({messages:v,maxMessages:t,autoScroll:$,setMessages:M,setLogFilters:X,setMaxMessages:d,setAutoScroll:L}),[v,M,X]),k=o.useMemo(()=>({maxMessages:t,autoScroll:$,logFilterLevel:u,logFilterSearch:i,setMessages:M,setLogFilters:X,setMaxMessages:d,setAutoScroll:L,online:C,retry:b.current,getUniqueId:ye,addListener:se,removeListener:N,sendMessage:xe,logMessage:he}),[t,$,M,X,d,L,C,b.current,se,N,xe,he]);return e.jsx(Qt.Provider,{value:P,children:e.jsx(be.Provider,{value:k,children:r})})}function _o(){const{showSnackbarMessage:r,showConfirmCancelDialog:u}=o.useContext(Je),{online:a,sendMessage:i,logMessage:s,addListener:v,removeListener:M,getUniqueId:t}=o.useContext(be),[d,$]=o.useState(!1),[L,C]=o.useState(!1),[A,T]=o.useState(!1),[W,_]=o.useState(!1),[m,E]=o.useState(null),b=o.useRef(t()),[f,y]=o.useState(null),[H,x]=o.useState(null),[w,z]=o.useState(null),[c,l]=o.useState(null),[g,h]=o.useState(null),F=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},G=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},ye=()=>{m?.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")},xe=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},he=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},X=()=>{i({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},se=()=>{i({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},N=()=>{i({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},O=()=>{n&&console.log("Header: handleShellySystemUpdateClick"),s("Matterbridge","Installing system updates..."),i({id:b.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{n&&console.log("Header: handleShellyMainUpdateClick"),s("Matterbridge","Installing software updates..."),i({id:b.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{n&&console.log("Header: handleShellyCreateSystemLog"),i({id:b.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{n&&console.log("Header: handleShellyDownloadSystemLog"),s("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},S=()=>{m?.matterbridgeInformation.restartMode===""?i({id:b.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):i({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},p=()=>{i({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ee=()=>{i({id:b.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},K=()=>{i({id:b.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{i({id:b.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=B=>{y(B.currentTarget)},V=B=>{n&&console.log("Header: handleMenuClose",B),y(null),B==="download-mblog"?(s("Matterbridge","Downloading matterbridge log..."),r("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):B==="download-mjlog"?(s("Matterbridge","Downloading matter log..."),r("Downloading matter log...",5),window.location.href="./api/download-mjlog"):B==="view-mblog"?(s("Matterbridge","Loading matterbridge log..."),r("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):B==="view-mjlog"?(s("Matterbridge","Loading matter log..."),r("Loading matter log...",5),window.location.href="./api/view-mjlog"):B==="view-shellylog"?(s("Matterbridge","Loading shelly system log..."),r("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):B==="download-mbstorage"?(s("Matterbridge","Downloading matterbridge storage..."),r("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):B==="download-pluginstorage"?(s("Matterbridge","Downloading matterbridge plugins storage..."),r("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):B==="download-pluginconfig"?(s("Matterbridge","Downloading matterbridge plugins config..."),r("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):B==="download-mjstorage"?(s("Matterbridge","Downloading matter storage..."),r("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):B==="download-backup"?(s("Matterbridge","Downloading backup..."),r("Downloading backup...",10),window.location.href="./api/download-backup"):B==="update"?X():B==="updatedev"?se():B==="updatecheck"?N():B==="shelly-sys-update"?O():B==="shelly-main-update"?D():B==="shelly-create-system-log"?P():B==="shelly-download-system-log"?k():B==="softreset"?K():B==="hardreset"?de():B==="restart"?S():B==="shutdown"?p():B==="reboot"?ee():B==="create-backup"?i({id:b.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):B==="unregister"?i({id:b.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):B==="reset"?i({id:b.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):B==="factoryreset"&&i({id:b.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},oe=B=>{n&&console.log("Header: handleMenuCloseCancel:",B),y(null)},ue=B=>{x(B.currentTarget)},Y=()=>{x(null)},je=B=>{z(B.currentTarget)},Se=()=>{z(null)},fe=B=>{l(B.currentTarget)},J=()=>{l(null)},ce=B=>{h(B.currentTarget)},Ce=()=>{h(null)},Ge=()=>{Bn(),n&&console.log("Matterbridge logo clicked: debug is now",n)};return o.useEffect(()=>{const B=j=>{j.src==="Matterbridge"&&j.dst==="Frontend"&&(ge(j)&&j.method==="/api/settings"&&j.id===b.current&&(n&&console.log("Header received settings:",j.response),E(j.response),$(j.response.matterbridgeInformation.restartRequired||j.response.matterbridgeInformation.fixedRestartRequired),C(j.response.matterbridgeInformation.fixedRestartRequired),T(j.response.matterbridgeInformation.updateRequired)),ae(j)&&j.method==="refresh_required"&&j.params.changed==="settings"&&(n&&console.log(`Header received refresh_required: changed=${j.params.changed} and sending /api/settings request`),i({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ae(j)&&j.method==="restart_required"&&(n&&console.log(`Header received restart_required with fixed: ${j.params.fixed}`),$(!0),j.params.fixed===!0&&C(!0)),ae(j)&&j.method==="restart_not_required"&&(n&&console.log("Header received restart_not_required"),$(!1)),ae(j)&&j.method==="update_required"&&(n&&console.log("Header received update_required"),T(!0),i({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ae(j)&&j.method==="update_required_dev"&&(n&&console.log("Header received update_required_dev"),_(!0),i({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ae(j)&&j.id===we.ShellySysUpdate&&(n&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),E(me=>me?{matterbridgeInformation:{...me.matterbridgeInformation,shellySysUpdate:j.params.available},systemInformation:me.systemInformation}:null)),ae(j)&&j.id===we.ShellyMainUpdate&&(n&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),E(me=>me?{matterbridgeInformation:{...me.matterbridgeInformation,shellyMainUpdate:j.params.available},systemInformation:me.systemInformation}:null)))};return v(B),n&&console.log(`Header added WebSocket listener id ${b.current}`),()=>{M(B),n&&console.log("Header removed WebSocket listener")}},[v,M,i,r]),o.useEffect(()=>{a&&(n&&console.log("Header sending /api/settings requests"),i({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),n&&console.log("Header rendering..."),!a||!m?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(tt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(tt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(tt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(tt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!m.matterbridgeInformation.readOnly&&A&&e.jsx(R,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:X,children:["Update to v.",m.matterbridgeInformation.matterbridgeLatestVersion]})}),!m.matterbridgeInformation.readOnly&&W&&e.jsx(R,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:se,children:["Update to new dev v.",m.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!m.matterbridgeInformation.readOnly&&e.jsx(R,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:ye,children:["v.",m.matterbridgeInformation.matterbridgeVersion]})}),m.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),m.matterbridgeInformation.bridgeMode!==""&&m.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:m.matterbridgeInformation.bridgeMode})}):null,m.matterbridgeInformation.restartMode!==""&&m.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:m.matterbridgeInformation.restartMode})}):null,m.matterbridgeInformation.profile&&m.matterbridgeInformation.profile!==""&&m.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:m.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[m.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:xe})}):null,m.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:he,children:e.jsx(hr,{})})}):null,m.matterbridgeInformation.readOnly===!1?e.jsx(R,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:F,children:e.jsx(At,{})})}):null,e.jsx(R,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:G,children:e.jsx(fr,{})})}),e.jsx(R,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ye,children:e.jsx(Vt,{})})}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsx(R,{title:"Update matterbridge to latest version",children:e.jsx(Q,{style:{color:A?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:X,children:e.jsx(Te,{})})}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellySysUpdate&&e.jsx(R,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:O,children:e.jsx(Te,{})})}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellyMainUpdate&&e.jsx(R,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:D,children:e.jsx(Te,{})})}),e.jsx(R,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:d||L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:S,children:e.jsx(ut,{})})}),m.matterbridgeInformation.restartMode===""?e.jsx(R,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:d||L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:p,children:e.jsx(Oe,{})})}):null,e.jsx(R,{title:"Download, backup and more",children:e.jsx(Q,{onClick:le,children:e.jsx(xr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Qe,{id:"command-menu",anchorEl:f,keepMounted:!0,open:!!f,onClose:()=>V(""),children:[m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsxs(I,{onClick:()=>V("update"),children:[e.jsx(q,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsxs(I,{onClick:()=>V("updatedev"),children:[e.jsx(q,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&!m.matterbridgeInformation.readOnly&&e.jsxs(I,{onClick:()=>V("updatecheck"),children:[e.jsx(q,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellySysUpdate&&e.jsxs(I,{onClick:()=>V("shelly-sys-update"),children:[e.jsx(q,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&m.matterbridgeInformation.shellyMainUpdate&&e.jsxs(I,{onClick:()=>V("shelly-main-update"),children:[e.jsx(q,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>V("restart"),children:[e.jsx(q,{children:e.jsx(ut,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation.restartMode===""?e.jsxs(I,{onClick:()=>V("shutdown"),children:[e.jsx(q,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(I,{onClick:()=>{u("Reboot","Are you sure you want to reboot the Shelly board?","reboot",V,oe)},children:[e.jsx(q,{children:e.jsx(ut,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(rt,{}),e.jsxs(I,{onClick:je,children:[e.jsx(q,{children:e.jsx(ot,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Qe,{id:"sub-menu-view",anchorEl:w,keepMounted:!0,open:!!w,onClose:Se,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(I,{onClick:()=>{V("view-mblog"),Se()},children:[e.jsx(q,{children:e.jsx(ot,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("view-mjlog"),Se()},children:[e.jsx(q,{children:e.jsx(ot,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(I,{onClick:()=>{V("view-shellylog"),Se()},children:[e.jsx(q,{children:e.jsx(ot,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(rt,{}),e.jsxs(I,{onClick:fe,children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Qe,{id:"sub-menu-download",anchorEl:c,keepMounted:!0,open:!!c,onClose:J,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(I,{onClick:()=>{V("download-mbstorage"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("download-pluginstorage"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("download-pluginconfig"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("download-mblog"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("download-mjstorage"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("download-mjlog"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(I,{onClick:()=>{V("shelly-create-system-log"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(I,{onClick:()=>{V("shelly-download-system-log"),J()},children:[e.jsx(q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(rt,{}),e.jsxs(I,{onClick:ue,children:[e.jsx(q,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Qe,{id:"sub-menu-backup",anchorEl:H,keepMounted:!0,open:!!H,onClose:Y,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(I,{onClick:()=>{V("create-backup"),Y()},children:[e.jsx(q,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{V("download-backup"),Y()},children:[e.jsx(q,{children:e.jsx(bt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(rt,{}),e.jsxs(I,{onClick:ce,children:[e.jsx(q,{children:e.jsx(br,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Qe,{id:"sub-menu-reset",anchorEl:g,keepMounted:!0,open:!!g,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(I,{onClick:()=>{Ce(),u("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",V,oe)},children:[e.jsx(q,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(I,{onClick:()=>{Ce(),u("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",V,oe)},children:[e.jsx(q,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!m.matterbridgeInformation.readOnly&&e.jsxs(I,{onClick:()=>{Ce(),u("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",V,oe)},children:[e.jsx(q,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(I,{onClick:()=>{Ce(),u("Network reset","Are you sure you want to factory reset the network parameters?","softreset",V,oe)},children:[e.jsx(q,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),m.matterbridgeInformation&&m.matterbridgeInformation.shellyBoard&&e.jsxs(I,{onClick:()=>{Ce(),u("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",V,oe)},children:[e.jsx(q,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Ao=o.memo(_o),Vo=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(n&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(n&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Uo(){const{messages:r,autoScroll:u}=o.useContext(Qt),[a,i]=o.useState(!1),s=o.useRef(null),v=o.useMemo(()=>Vo(),[]),M=d=>i(!0),t=d=>i(!1);return o.useEffect(()=>{n&&console.log(`WebSocketLogs autoScroll: ${u} isHovering: ${a}`),u&&!a&&!v&&s.current?.scrollIntoView({behavior:"smooth"})},[r,a,u,v]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:M,onMouseLeave:t,children:[r.map((d,$)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:d}},$)),e.jsx("div",{ref:s})]})})}const Kt=o.memo(Uo);function Ae(){const{retry:r}=o.useContext(be),u=()=>{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:r<100?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx(vr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+r+")","..."]})})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{}),e.jsx(ie,{variant:"contained",color:"primary",onClick:u,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function qo({value:r,maxChars:u}){let a=r;if(r.length>u&&u>3){const i=u-3,s=r.substring(0,Math.ceil(i/2)),v=r.substring(r.length-Math.floor(i/2),r.length);a=`${s} … ${v}`}return r!==a?e.jsx(R,{title:r,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:a})}):e.jsx("span",{children:a})}function zo({systemInfo:r,compact:u}){const[a,i]=o.useState(r),{sendMessage:s,addListener:v,removeListener:M}=o.useContext(be);if(n&&console.log("SystemInfoTable:",a,"compact:",u),r&&u&&a.totalMemory&&a.freeMemory){const t=a.totalMemory,d=a.freeMemory;a.freeMemory=`${d} / ${t}`,a.totalMemory=""}if(r&&u&&a.heapTotal&&a.heapUsed){const t=a.heapTotal,d=a.heapUsed;a.heapUsed=`${d} / ${t}`,a.heapTotal=""}if(r&&u&&a.osRelease&&a.osType){const t=a.osType,d=a.osRelease;a.osType=`${t} (${d})`,a.osRelease=""}if(r&&u&&a.osArch&&a.osPlatform){const t=a.osPlatform,d=a.osArch;a.osPlatform=`${t} (${d})`,a.osArch=""}return o.useEffect(()=>{const t=d=>{d.src==="Matterbridge"&&d.dst==="Frontend"&&(ae(d)&&d.method==="memory_update"&&d.params&&d.params.totalMemory&&d.params.freeMemory&&d.params.heapTotal&&d.params.heapUsed&&d.params.rss&&(n&&console.log("SystemInfoTable received memory_update",d),(a.totalMemory!==d.params?.totalMemory||a.freeMemory!==d.params?.freeMemory||a.heapTotal!==d.params?.heapTotal||a.heapUsed!==d.params?.heapUsed||a.rss!==d.params?.rss)&&i($=>({...$,totalMemory:d.params?.totalMemory?d.params.totalMemory:"",freeMemory:d.params?.freeMemory?d.params.freeMemory:"",heapTotal:d.params?.heapTotal?d.params.heapTotal:"",heapUsed:d.params?.heapUsed?d.params.heapUsed:"",rss:d.params?.rss?d.params.rss:""}))),ae(d)&&d.method==="cpu_update"&&d.params&&d.params.cpuUsage&&(n&&console.log("SystemInfoTable received cpu_update",d),a.cpuUsage!==(d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":"")&&i($=>({...$,cpuUsage:d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":""}))),ae(d)&&d.method==="uptime_update"&&d.params&&d.params.systemUptime&&d.params.processUptime&&(n&&console.log("SystemInfoTable received uptime_update",d),(a.systemUptime!==d.params?.systemUptime||a.processUptime!==d.params?.processUptime)&&i($=>({...$,systemUptime:d.params?.systemUptime?d.params.systemUptime:"",processUptime:d.params?.processUptime?d.params.processUptime:""}))))};return n&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),v(t),n&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{n&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),M(t),n&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[v,a.cpuUsage,a.freeMemory,a.heapTotal,a.heapUsed,a.processUptime,a.rss,a.systemUptime,a.totalMemory,M,s]),a?(n&&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(a).filter(([t,d])=>d!==void 0&&d!=="").map(([t,d],$)=>e.jsxs("tr",{className:$%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(qo,{value:typeof d!="string"?d.toString():d,maxChars:25})})]},t))})})})]})):null}const Bo=o.memo(zo),Ot={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"}},Qo=r=>{if(!r)return"";const u=r.toString().replace(/[^0-9]/g,"");if(u.length<5)return u;const a=u.slice(0,4),i=u.slice(4,7),s=u.slice(7,11);return[a,i,s].filter(Boolean).join("-")};function Ko({id:r}){const{online:u,sendMessage:a,addListener:i,removeListener:s,getUniqueId:v}=o.useContext(be),[M,t]=o.useState(null),[d,$]=o.useState(null),L=o.useRef(null),C=o.useRef(v()),{showConfirmCancelDialog:A}=o.useContext(Je);o.useEffect(()=>{n&&console.log(`QRDiv received storeId update "${r}"`),r&&(n&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),a({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const b=f=>{f.src==="Matterbridge"&&f.dst==="Frontend"&&ae(f)&&f.id===we.RefreshRequired&&f.params.changed==="matter"&&f.params.matter&&(n&&console.log(`QRDiv received refresh_required: changed=${f.params.changed} for storeId "${f.params.matter.id}":`,f.params.matter),M===f.params.matter.id&&(n&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${f.params.matter.id}":`,f.params.matter),L.current&&clearTimeout(L.current),f.params.matter.advertising&&f.params.matter.advertiseTime&&f.params.matter.advertiseTime+9e5<=Date.now()&&(f.params.matter.advertising=!1),$(f.params.matter),f.params.matter.advertising&&(n&&console.log(`QRDiv setting matter advertise timeout for storeId "${f.params.matter.id}":`,f.params.matter.advertiseTime+9e5-Date.now()),L.current=setTimeout(()=>{L.current&&clearTimeout(L.current),n&&console.log(`QRDiv clearing advertising state for storeId "${M}" after 15 minutes`),$(y=>y&&{...y,advertising:!1})},f.params.matter.advertiseTime+9e5-Date.now()))))};return i(b),n&&console.log("QRDiv webSocket effect mounted"),()=>{s(b),L.current&&clearTimeout(L.current),n&&console.log("QRDiv webSocket effect unmounted")}},[M]);const T=()=>{n&&console.log(`QRDiv sent matter startCommission for node "${d?.id}"`),d&&a({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,startCommission:!0}})},W=()=>{n&&console.log(`QRDiv sent matter stopCommission for node "${d?.id}"`),d&&a({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,stopCommission:!0}})},_=()=>{n&&console.log(`QRDiv sent matter advertise for node "${d?.id}"`),d&&a({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,advertise:!0}})},m=b=>{n&&console.log(`QRDiv sent matter removeFabric for node "${d?.id}" and fabricIndex ${b}`),d&&a({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,removeFabric:b}})},E=async()=>{if(!d||!d.manualPairingCode)return;const b=d.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(b);else{const f=document.createElement("textarea");f.value=b,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.focus(),f.select(),document.execCommand("copy"),document.body.removeChild(f)}n&&console.log("Manual pairing code copied to clipboard")}catch(f){console.error("Failed to copy manual pairing code",f)}};return!d||!u?(n&&console.log("QRDiv rendering undefined state"),null):d.online?d.advertising&&d.qrPairingCode&&d.manualPairingCode?(n&&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(Q,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:Tt,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:W,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Turn off pairing",arrow:!0,children:e.jsx(re,{path:no,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:M}),e.jsx(oo,{value:d.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: ",Qo(d.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(R,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:E,sx:Ot,children:e.jsx(re,{path:io,size:.85})})})})]})]})):d.commissioned&&d.fabricInformations&&d.sessionInformations?(n&&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(Q,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:Tt,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:T,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(R,{title:"Turn on pairing",arrow:!0,children:e.jsx(re,{path:$t,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:M}),d.fabricInformations.map((b,f)=>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(R,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(Q,{"aria-label":"remove the fabric",size:"small",onClick:()=>A("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>m(b.fabricIndex),()=>{}),sx:{...Ot,padding:"2px"},children:e.jsx(re,{path:ao,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: ",d.sessionInformations?d.sessionInformations.filter(y=>y.fabric?.fabricIndex===b.fabricIndex&&y.isPeerActive===!0).length:"0"," ","subscriptions: ",d.sessionInformations?d.sessionInformations.filter(y=>y.fabric?.fabricIndex===b.fabricIndex&&y.isPeerActive===!0&&y.numberOfActiveSubscriptions>0).length:"0"]})]},f))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]})):!d.commissioned&&!d.advertising?(n&&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:M}),e.jsx(ie,{onClick:T,endIcon:e.jsx(re,{path:$t,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: ",d.serialNumber]})})]})):(n&&console.log("QRDiv rendering unknown state"),null):(n&&console.log("QRDiv rendering offline 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:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:M}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"bold"},children:"Server offline: restart to commission"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]}))}const Jo=o.memo(Ko);function Go(){const{logMessage:r,sendMessage:u,getUniqueId:a}=o.useContext(be),[i,s]=o.useState("matterbridge-"),[v,M]=o.useState(!1),[t,d]=o.useState(null),$=o.useRef(a()),L=f=>{f.preventDefault(),M(!0)},C=()=>{M(!1)},A=f=>{f.preventDefault(),M(!1);const y=f.dataTransfer.files[0];if(y){r("Plugins",`Installing package ${y.name}. Please wait...`);const H=new FormData;H.append("file",y),H.append("filename",y.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(x=>x.text()).then(x=>{r("Plugins",`Server response: ${x}`)}).catch(x=>{console.error("Error uploading plugin file:",x),r("Plugins",`Error installing package ${x}`)})}},T=f=>{const y=f.target.files&&f.target.files[0];if(y){r("Plugins",`Uploading package ${y.name}`);const H=new FormData;H.append("file",y),H.append("filename",y.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(x=>x.text()).then(x=>{r("Plugins",`Server response: ${x}`)}).catch(x=>{console.error("Error uploading plugin file:",x),r("Plugins",`Error uploading package ${x}`)})}},W=()=>{u({id:$.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},_=()=>{document.getElementById("file-upload")?.click()},m=()=>{u({id:$.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},E=f=>{d(f.currentTarget)},b=f=>{f!==""&&s(f),d(null)};return n&&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:C,onDrop:A,children:[e.jsx(pe,{value:i,onChange:f=>{s(f.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:E,children:e.jsx(yr,{})}),e.jsxs(Qe,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>b(""),children:[e.jsx(I,{onClick:()=>b("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(I,{onClick:()=>b("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(I,{onClick:()=>b("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(I,{onClick:()=>b("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(I,{onClick:()=>b("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(I,{onClick:()=>b("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(I,{onClick:()=>b("matterbridge-test"),children:"matterbridge-test"}),e.jsx(I,{onClick:()=>b("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(I,{onClick:()=>b("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(I,{onClick:()=>b("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(I,{onClick:()=>b("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(I,{onClick:()=>b("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(I,{onClick:()=>b("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(I,{onClick:()=>b("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(R,{title:"Install or update a plugin from npm",children:e.jsx(ie,{onClick:W,endIcon:e.jsx(Ie,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(R,{title:"Upload and install a plugin from a tarball",children:e.jsx(ie,{onClick:_,endIcon:e.jsx(jr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(R,{title:"Add an installed plugin",children:e.jsx(ie,{onClick:m,endIcon:e.jsx(mt,{}),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:T})]})}const Yo=o.memo(Go);function Ue({status:r,enabledText:u="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:s}){if(r===void 0)return null;{const v=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:r?u:a??u});return i!==void 0?e.jsx(R,{title:i,children:v}):v}}const qe={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},ze={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Xo={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Zo={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Pe={padding:"0px",margin:"0px"},en="5px 10px 5px 10px",dt={},ve={},ct={},pt={};let Be=[],yt=[];const tn=({open:r,onClose:u,plugin:a})=>{const{sendMessage:i,addListener:s,removeListener:v,getUniqueId:M}=o.useContext(be),t=o.useRef(M()),[d,$]=o.useState(a.configJson),[L,C]=o.useState(null),[A,T]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[W,_]=o.useState("");let m={};o.useEffect(()=>{const P=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(ge(k)&&k.id===t.current&&k.method==="/api/select/devices"&&k.response&&(n&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/devices:`,k.response),Be=k.response),ge(k)&&k.id===t.current&&k.method==="/api/select/entities"&&k.response&&(n&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/entities:`,k.response),yt=k.response))};return s(P),n&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),d&&L&&L.properties&&(Object.keys(L.properties).forEach(k=>{Object.keys(L.properties[k]).forEach(S=>{S.startsWith("ui:")&&(A[k]={},A[k][S]=L.properties[k][S],delete L.properties[k][S])})}),T(A)),a.name&&a.configJson&&a.schemaJson&&($(a.configJson),C(a.schemaJson),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),n&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',a.name)),()=>{v(P),n&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,d,a,v,L,i,A]);const E=(P,k)=>{m=P.formData},b=P=>{n&&console.log("ConfigPluginDialog handleSaveChanges:",P.formData),$(P.formData),a.configJson=P.formData,a.restartRequired=!0,i({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.formData.name,formData:P.formData}}),u()};function f(P){const{id:k,label:S,onKeyChange:p,onDropPropertyClick:ee,disabled:K,schema:de,children:le,registry:V,readonly:oe,required:ue}=P,{templates:Y}=V,{RemoveButton:je}=Y.ButtonTemplates;if(!(Ro in de))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const fe=({target:J})=>p(J&&J.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:ue,disabled:K||oe,defaultValue:S,onBlur:oe?void 0:fe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:le}),e.jsx(je,{disabled:K||oe,onClick:ee(S),registry:V})]})}function y(P){const{children:k,description:S,displayLabel:p,errors:ee,help:K,hidden:de,registry:le,uiSchema:V}=P,oe=To(V),ue=$o("WrapIfAdditionalTemplate",le,oe);return de?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(ue,{...P,children:[p===!0&&S,k,ee,K]})})}function H(P){const{description:k}=P;return k?e.jsx(ne,{sx:ze,children:k}):null}function x(P){const{required:k,title:S}=P;return S?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ne,{sx:qe,children:["Title ",S," ",k&&e.jsx("mark",{children:"***"})]})}):null}function w(P){const{help:k}=P;return k?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ne,{sx:Xo,children:k})}):null}function z(P){const{errors:k}=P;return k?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ne,{color:"error",sx:Zo,children:"Please fix the following errors:"}),e.jsx(Xe,{children:k.map((S,p)=>e.jsxs(Cr,{children:[e.jsx(q,{children:e.jsx(wr,{color:"error"})}),e.jsx(te,{primary:S.stack})]},p))})]}):null}function c(P){const{errors:k}=P;return k?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((S,p)=>e.jsxs(ne,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",S]},p))}):null}function l(P){const{id:k,name:S,_schema:p,_uiSchema:ee,value:K,options:de,label:le,type:V,placeholder:oe,required:ue,disabled:Y,readonly:je,autofocus:Se,onChange:fe,onChangeOverride:J,onBlur:ce,onFocus:Ce,_rawErrors:Ge,_hideError:B,_registry:j,_formContext:me}=P,Ye=({target:{value:ke}})=>fe(ke===""?de.emptyValue:ke),We=({target:ke})=>ce(k,ke&&ke.value),et=({target:ke})=>Ce(k,ke&&ke.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:k,name:k,label:oe&&oe!==""?le:void 0,variant:"outlined",placeholder:oe&&oe!==""?oe:le,required:ue,disabled:Y||je,autoFocus:Se,value:K||K===0?K:"",type:V,autoComplete:V==="password"?"current-password":S,onChange:J||Ye,onBlur:We,onFocus:et,fullWidth:!0})})}function g(P){return console.log("ArrayFieldTitleTemplate:",P),null}function h(P){return console.log("ArrayFieldDescriptionTemplate:",P),null}function F(P){return console.log("ArrayFieldItemTemplate:",P),null}function G(P){const{canAdd:k,onAddClick:S,schema:p,title:ee}=P,[K,de]=o.useState(!1),[le,V]=o.useState(!1),[oe,ue]=o.useState(!1),[Y,je]=o.useState(""),Se=j=>{je(j.target.value)},fe=()=>{n&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",Y,"selectDevices:",Be),de(!K)},J=()=>{n&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",Y,"selectEntities:",yt),V(!le)},ce=()=>{n&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",Y,"selectDevices:",Be),ue(!oe)},Ce=j=>{de(!1),p.selectFrom==="serial"?p.items.default=j.serial:p.selectFrom==="name"&&(p.items.default=j.name),S()},Ge=j=>{V(!1),p.selectEntityFrom==="name"?p.items.default=j.name:p.selectEntityFrom==="description"&&(p.items.default=j.description),S()},B=j=>{ue(!1),p.selectDeviceEntityFrom==="name"?p.items.default=j.name:p.selectDeviceEntityFrom==="description"&&(p.items.default=j.description),S()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ee&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ee&&e.jsx(ne,{sx:qe,children:ee}),k&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.selectFrom&&e.jsx(R,{title:"Add a device from the list",children:e.jsx(Q,{onClick:fe,size:"small",color:"primary",sx:Pe,children:e.jsx(nt,{})})}),p.selectEntityFrom&&e.jsx(R,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:J,size:"small",color:"primary",sx:Pe,children:e.jsx(nt,{})})}),p.selectDeviceEntityFrom&&e.jsx(R,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:ce,size:"small",color:"primary",sx:Pe,children:e.jsx(nt,{})})}),e.jsx(R,{title:"Add a new item",children:e.jsx(Q,{onClick:S,size:"small",color:"primary",sx:Pe,children:e.jsx(mt,{})})})]})]}),p.description&&e.jsx(ne,{sx:ze,children:p.description}),P.items.map(j=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:j.children}),e.jsx(Q,{disabled:!j.hasMoveUp,onClick:j.onReorderClick(j.index,j.index-1),size:"small",color:"primary",sx:Pe,children:e.jsx(Dt,{})}),e.jsx(Q,{disabled:!j.hasMoveDown,onClick:j.onReorderClick(j.index,j.index+1),size:"small",color:"primary",sx:Pe,children:e.jsx(It,{})}),e.jsx(Q,{onClick:j.onDropIndexClick(j.index),size:"small",color:"primary",sx:Pe,children:e.jsx(ht,{})})]},j.index)),e.jsxs(Ne,{open:K,onClose:fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Fe,{children:"Select a device"}),e.jsxs(Le,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ne,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Y,onChange:Se,placeholder:"Enter serial or name"})]}),e.jsx(Xe,{dense:!0,children:Be.filter(j=>j.serial.toLowerCase().includes(Y.toLowerCase())||j.name.toLowerCase().includes(Y.toLowerCase())).map((j,me)=>e.jsxs(it,{onClick:()=>Ce(j),sx:dt,children:[j.icon==="wifi"&&e.jsx(q,{children:e.jsx(Ze,{style:ve})}),j.icon==="ble"&&e.jsx(q,{children:e.jsx(at,{style:ve})}),j.icon==="hub"&&e.jsx(q,{children:e.jsx(st,{style:ve})}),e.jsx(te,{primary:j.name,secondary:j.serial,primaryTypographyProps:{style:ct},secondaryTypographyProps:{style:pt}})]},me))})]}),e.jsx(_e,{children:e.jsx(ie,{onClick:fe,children:"Close"})})]}),e.jsxs(Ne,{open:le,onClose:J,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Fe,{children:"Select an entity"}),e.jsxs(Le,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ne,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Y,onChange:Se,placeholder:"Enter name or description"})]}),e.jsx(Xe,{dense:!0,children:yt.filter(j=>j.name.toLowerCase().includes(Y.toLowerCase())||j.description.toLowerCase().includes(Y.toLowerCase())).map((j,me)=>e.jsxs(it,{onClick:()=>Ge(j),sx:dt,children:[j.icon==="wifi"&&e.jsx(q,{children:e.jsx(Ze,{style:ve})}),j.icon==="ble"&&e.jsx(q,{children:e.jsx(at,{style:ve})}),j.icon==="hub"&&e.jsx(q,{children:e.jsx(st,{style:ve})}),j.icon==="component"&&e.jsx(q,{children:e.jsx(Pt,{style:ve})}),j.icon==="matter"&&e.jsx(q,{children:e.jsx(Nt,{style:ve})}),e.jsx(te,{primary:j.name,secondary:j.description,primaryTypographyProps:{style:ct},secondaryTypographyProps:{style:pt}})]},me))})]}),e.jsx(_e,{children:e.jsx(ie,{onClick:J,children:"Close"})})]}),e.jsxs(Ne,{open:oe,onClose:ce,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Fe,{children:["Select an entity for ",ee]}),e.jsx(Le,{children:e.jsx(Xe,{dense:!0,children:Be.filter(j=>j.serial===ee||j.name===ee).map(j=>j.entities?.map((me,Ye)=>e.jsxs(it,{onClick:()=>B(me),sx:dt,children:[me.icon==="wifi"&&e.jsx(q,{children:e.jsx(Ze,{style:ve})}),me.icon==="ble"&&e.jsx(q,{children:e.jsx(at,{style:ve})}),me.icon==="hub"&&e.jsx(q,{children:e.jsx(st,{style:ve})}),me.icon==="component"&&e.jsx(q,{children:e.jsx(Pt,{style:ve})}),me.icon==="matter"&&e.jsx(q,{children:e.jsx(Nt,{style:ve})}),e.jsx(te,{primary:me.name,secondary:me.description,primaryTypographyProps:{style:ct},secondaryTypographyProps:{style:pt}})]},Ye)))})}),e.jsx(_e,{children:e.jsx(ie,{onClick:ce,children:"Close"})})]})]})}function ye(P){const{onAddClick:k,schema:S,properties:p,title:ee,description:K}=P,[de,le]=o.useState(!1),[V,oe]=o.useState(""),ue=J=>{oe(J.target.value)},Y=()=>{le(!de)},je=J=>{n&&console.log(`ObjectFieldTemplate: handleSelectValue value "${J.serial}" for schema "${S.selectFrom}"`),le(!1);let ce="";S.selectFrom==="serial"?ce=J.serial:S.selectFrom==="name"&&(ce=J.name),_(ce),n&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ce}"`),k(S)()},Se=()=>{k(S)()},fe=!S.additionalProperties;return n&&console.log(`ObjectFieldTemplate: isRoot ${fe} newkey "${W}"`),!fe&&W!==""&&(n&&console.log("ObjectFieldTemplate: newkey",W,"properties",p),p.forEach(J=>{if(J.name==="newKey"&&J.content.key==="newKey"&&J.content.props.name==="newKey"&&J.content.props.onKeyChange&&W!==""){n&&console.log("ObjectFieldTemplate: newkey onKeyChange",W);const ce=W;_(""),J.content.props.onKeyChange(ce)}})),e.jsxs(Z,{sx:{margin:"0px",padding:fe?"10px":"5px 10px 0px 10px",border:fe?"none":"1px solid grey"},children:[S.title&&fe&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ne,{sx:qe,children:S.title})}),ee&&!fe&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ne,{sx:qe,children:ee}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[S.selectFrom&&e.jsx(R,{title:"Add a device from the list",children:e.jsx(Q,{onClick:Y,size:"small",color:"primary",sx:Pe,children:e.jsx(nt,{})})}),e.jsx(R,{title:"Add a new item",children:e.jsx(Q,{onClick:Se,size:"small",color:"primary",sx:Pe,children:e.jsx(mt,{})})})]})]}),S.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ne,{sx:ze,children:S.description})}),p.map(({content:J,name:ce,hidden:Ce})=>!Ce&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(S.properties[ce].type)?"0px":en,border:["object","array","boolean"].includes(S.properties[ce].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(S.properties[ce].type)&&e.jsx(ne,{sx:qe,children:ce}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:J})]},ce)),e.jsxs(Ne,{open:de,onClose:Y,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Fe,{children:"Select a device"}),e.jsxs(Le,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ne,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:V,onChange:ue,placeholder:"Enter serial or name"})]}),e.jsx(Xe,{dense:!0,children:Be.filter(J=>J.serial.toLowerCase().includes(V.toLowerCase())||J.name.toLowerCase().includes(V.toLowerCase())).map((J,ce)=>e.jsxs(it,{onClick:()=>je(J),sx:dt,children:[J.icon==="wifi"&&e.jsx(q,{children:e.jsx(Ze,{style:ve})}),J.icon==="ble"&&e.jsx(q,{children:e.jsx(at,{style:ve})}),J.icon==="hub"&&e.jsx(q,{children:e.jsx(st,{style:ve})}),e.jsx(te,{primary:J.name,secondary:J.serial,primaryTypographyProps:{style:ct},secondaryTypographyProps:{style:pt}})]},ce))})]}),e.jsx(_e,{children:e.jsx(ie,{onClick:Y,children:"Close"})})]})]})}function xe(P){const{uiSchema:k}=P,{submitText:S,norender:p}=Wo(k);return p?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ie,{type:"submit",variant:"contained",color:"primary",children:S}),e.jsx(ie,{variant:"contained",color:"primary",onClick:u,children:"Cancel"})]})}function he(P){const{className:k,disabled:S,onClick:p,registry:ee,style:K,uiSchema:de,...le}=P;return e.jsx(R,{title:"Remove the item",children:e.jsx(Q,{disabled:S,size:"small",color:"primary",onClick:p,children:e.jsx(ht,{})})})}function X(P){const{className:k,disabled:S,onClick:p,registry:ee,uiSchema:K,...de}=P;return e.jsx(R,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:p,children:e.jsx(mt,{})})})}function se(P){const{disabled:k,onClick:S,registry:p,style:ee,uiSchema:K,...de}=P;return e.jsx(R,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:S,children:e.jsx(Dt,{})})})}function N(P){const{disabled:k,onClick:S,registry:p,style:ee,uiSchema:K,...de}=P;return e.jsx(R,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:S,children:e.jsx(It,{})})})}function O(P){const{id:k,name:S,value:p,schema:ee,readonly:K,onChange:de}=P,[le,V]=o.useState(),oe=Y=>{n&&console.log(`CheckboxWidget ${S} onChangeField:`,Y),V(Y&&Y!==""?Y:void 0)},ue=()=>{n&&console.log(`CheckboxWidget onClick plugin="${a.name}" action="${S}" value="${le}"`),i({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:S,value:le,formData:m,id:k}}),ee.buttonClose===!0?u():ee.buttonSave===!0&&b({formData:d})};return ee.buttonText&&ee.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ne,{sx:ze,children:ee.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>ue(),children:ee.buttonText})]}):ee.buttonField&&ee.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(ne,{sx:ze,children:ee.description}),e.jsx(pe,{id:S+"-input",name:S,label:ee.textLabel,placeholder:ee.textPlaceholder,onChange:Y=>oe(Y.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:S+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>ue(),children:ee.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[S&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ne,{sx:qe,children:S}),e.jsx(He,{checked:p,readOnly:K,onChange:()=>de(!p),sx:{padding:"0px",margin:"0px"}})]}),ee.description&&e.jsx(ne,{sx:ze,children:ee.description})]})}function D({schema:P,id:k,name:S,options:p,label:ee,hideLabel:K,required:de,disabled:le,placeholder:V,readonly:oe,value:ue,multiple:Y,autofocus:je,onChange:Se,onBlur:fe,onFocus:J,errorSchema:ce,rawErrors:Ce=[],registry:Ge,uiSchema:B,hideError:j,formContext:me,...Ye}){const{enumOptions:We,enumDisabled:et,emptyValue:ke}=p;Y=typeof Y>"u"?!1:!!Y;const wt=Y?[]:"",St=typeof ue>"u"||Y&&ue.length<1||!Y&&ue===wt,Gt=({target:{value:De}})=>Se(vt(De,We,ke)),Yt=({target:De})=>fe(k,vt(De&&De.value,We,ke)),Xt=({target:De})=>J(k,vt(De&&De.value,We,ke)),Mt=Fo(ue,We,Y),{InputLabelProps:Zt,SelectProps:er,autocomplete:tr,...rr}=Ye,or=!Y&&P.default===void 0;return e.jsxs(pe,{id:k,name:k,value:!St&&typeof Mt<"u"?Mt:wt,required:de,disabled:le||oe,autoFocus:je,autoComplete:tr,placeholder:V,error:Ce.length>0,onChange:Gt,onBlur:Yt,onFocus:Xt,...rr,select:!0,InputLabelProps:{...Zt,shrink:!St},SelectProps:{...er,multiple:Y},"aria-describedby":Lo(k),children:[or&&e.jsx(I,{value:"",children:V}),Array.isArray(We)&&We.map(({value:De,label:nr},kt)=>{const ir=Array.isArray(et)&&et.indexOf(De)!==-1;return e.jsx(I,{value:String(kt),disabled:ir,children:nr},kt)})]})}return n&&console.log("ConfigPluginDialog rendering..."),!r||!L||!d?null:e.jsxs(Ne,{open:r,onClose:u,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Fe,{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(Le,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Po,{schema:L,formData:d,uiSchema:A,validator:No,templates:{FieldTemplate:y,BaseInputTemplate:l,TitleFieldTemplate:x,DescriptionFieldTemplate:H,FieldHelpTemplate:w,FieldErrorTemplate:c,ErrorListTemplate:z,WrapIfAdditionalTemplate:f,ArrayFieldTitleTemplate:g,ArrayFieldDescriptionTemplate:h,ArrayFieldItemTemplate:F,ArrayFieldTemplate:G,ObjectFieldTemplate:ye,ButtonTemplates:{SubmitButton:xe,RemoveButton:he,AddButton:X,MoveUpButton:se,MoveDownButton:N}},widgets:{CheckboxWidget:O,SelectWidget:D},onChange:E,onSubmit:b})})]})};function Jt(r){if(n&&console.log(`getQRColor (id: ${r?.id}) received matter:`,r??"undefined"),r===void 0||!r.online||!r.qrPairingCode&&!r.manualPairingCode&&!r.fabricInformations&&!r.sessionInformations)return"red";if(r.commissioned===!1&&r.qrPairingCode&&r.manualPairingCode)return"var(--primary-color)";let u=0,a=0;for(const i of r.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&u++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(u===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function rn(r,u,a){const i=r?.[a],s=u?.[a];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function on({name:r,title:u,columns:a,rows:i,getRowKey:s,footerLeft:v,footerRight:M,onRowClick:t}){const d=o.useRef(new WeakMap),$=o.useRef(1),L=c=>{if(typeof s=="string"&&c&&c[s]!=null)return c[s];if(typeof s=="function"){const h=s(c);if(h!=null)return h}const l=a?.[0]?.id;if(l&&c&&c[l]!=null)return c[l];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let g=d.current.get(c);return g||(g=`rk_${$.current++}`,d.current.set(c,g)),g},[C,A]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[T,W]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[_,m]=o.useState(!1),[E,b]=o.useState(()=>{try{const c=localStorage.getItem(`${r}_column_visibility`);if(c)return JSON.parse(c)}catch{}return{}}),f=o.useMemo(()=>{const c={};for(const l of a)l.hidden||(c[l.id]=l.required?!0:E[l.id]!==!1);return c},[a,E]),y=o.useMemo(()=>{if(!C||!T)return i;const c=a.find(g=>g.id===C);if(!c||c.noSort)return i;const l=i.map((g,h)=>({el:g,index:h}));return l.sort((g,h)=>{let F;return typeof c.comparator=="function"?F=c.comparator(g.el,h.el):F=rn(g.el,h.el,C),F!==0?T==="asc"?F:-F:g.index-h.index}),l.map(g=>g.el)},[i,C,T,a]),H=c=>{if(C!==c||!C){A(c),W("asc"),localStorage.setItem(`${r}_table_order_by`,c),localStorage.setItem(`${r}_table_order`,"asc");return}if(T==="asc"){W("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}A(null),W(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},x=()=>{m(!_)},w=c=>{b(l=>{const g=a.find(G=>G.id===c);if(g&&g.required)return l;const h=f[c]!==!1,F={...l};h?F[c]=!1:delete F[c];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(F))}catch{}return F})},z=()=>{b({});try{localStorage.removeItem(`${r}_column_visibility`)}catch{}m(!1)};return n&&console.log(`Rendering table ${r}${C&&T?` ordered by ${C}:${T}`:""}`),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(Ne,{open:_,onClose:(c,l)=>{l==="backdropClick"||l==="escapeKeyDown"||x()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Fe,{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(Le,{children:e.jsx(Sr,{children:a.filter(c=>!c.hidden).map(c=>e.jsx(Re,{control:e.jsx(He,{disabled:!!c.required,checked:c.required?!0:f[c.id]!==!1,onChange:()=>w(c.id)}),label:c.label},c.id))})}),e.jsxs(_e,{children:[e.jsx(ie,{onClick:z,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:c=>{if(c?.currentTarget&&typeof c.currentTarget.blur=="function")try{c.currentTarget.blur()}catch{}const l=document.activeElement;if(l&&l instanceof HTMLElement&&typeof l.blur=="function")try{l.blur()}catch{}x()},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}),u&&e.jsx("p",{className:"MbfWindowHeaderText",children:u}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(Q,{onClick:c=>{if(c?.currentTarget?.blur)try{c.currentTarget.blur()}catch{}x()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(R,{title:`Configure ${r} columns`,children:e.jsx(re,{path:so,size:"20px",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:a.map(c=>{if(c.hidden||!c.required&&f[c.id]===!1)return null;const l=!c.noSort,g=l&&C===c.id&&!!T;return e.jsxs("th",{onClick:l?()=>H(c.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:c.minWidth,maxWidth:c.maxWidth,textAlign:c.align||"left",cursor:l?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:c.maxWidth?"nowrap":void 0,overflow:c.maxWidth?"hidden":void 0,textOverflow:c.maxWidth?"ellipsis":void 0},"aria-sort":l?g?T==="asc"?"ascending":"descending":"none":void 0,children:[c.label,g&&e.jsxs("span",{style:{marginLeft:6},children:[T==="asc"&&e.jsx(re,{path:lo,size:"15px"}),T==="desc"&&e.jsx(re,{path:co,size:"15px"})]})]},c.id)})})}),e.jsx("tbody",{children:y.map((c,l)=>{const g=L(c);return e.jsx("tr",{className:l%2===0?"table-content-even":"table-content-odd",onClick:t?h=>t(c,g,h):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:a.map(h=>{if(h.hidden||!h.required&&f[h.id]===!1)return null;const F=c[h.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:h.align||"left",padding:"5px 10px",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(F,g,c,h):typeof F=="boolean"?e.jsx(He,{checked:F,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 F=="number"?h.format(F):F!=null?String(F):null},h.id)})},g)})})]})}),(v||M)&&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:v}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:M})]})]})}function nn(r){return o.memo(r)}const xt=nn(on);function an({storeId:r,setStoreId:u}){const{online:a,sendMessage:i,addListener:s,removeListener:v,getUniqueId:M}=o.useContext(be),{showConfirmCancelDialog:t}=o.useContext(Je),d=o.useRef(M()),[$,L]=o.useState(null),[C,A]=o.useState(null),[T,W]=o.useState([]),_=[{label:"Name",id:"name",required:!0,render:(N,O,D,P)=>e.jsx(R,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>c(D),children:D.name})})},{label:"Description",id:"description",render:(N,O,D,P)=>e.jsx(R,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>c(D),children:D.description})})},{label:"Version",id:"version",render:(N,O,D,P)=>e.jsxs(e.Fragment,{children:[D.latestVersion!==void 0&&D.latestVersion!==D.version&&C&&!C.readOnly&&e.jsx(R,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>y(D),children:["Update to v.",D.latestVersion]})}),D.version.includes("-dev-")&&D.devVersion!==void 0&&D.devVersion!==D.version&&C&&!C.readOnly&&e.jsx(R,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>H(D),children:["Update to new dev v.",D.devVersion.split("-dev-")[0]]})}),e.jsx(R,{title:"Plugin version",children:e.jsx("span",{children:D.version})})]})},{label:"Author",id:"author",render:(N,O,D,P)=>e.jsx(e.Fragment,{children:D.author?D.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(N,O,D,P)=>e.jsx(e.Fragment,{children:D.type?D.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(N,O,D,P)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!D.error&&D.enabled&&e.jsx(R,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:Jt(D.matter)},onClick:()=>{D.matter?.id&&u(D.matter?.id)},size:"small",children:e.jsx(Ut,{})})}),C&&C.bridgeMode==="childbridge"&&!D.error&&D.enabled&&e.jsx(R,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>w(D),size:"small",children:e.jsx(ut,{})})}),e.jsx(R,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{disabled:D.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>he(D),size:"small",children:e.jsx(Ct,{})})}),C&&!C.readOnly&&e.jsx(R,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{E("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",D)},size:"small",children:e.jsx(ht,{})})}),D.enabled?e.jsx(R,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{E("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",D)},size:"small",children:e.jsx(Mr,{})})}):e.jsx(e.Fragment,{}),D.enabled?e.jsx(e.Fragment,{}):e.jsx(R,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>z(D),size:"small",children:e.jsx(kr,{})})}),e.jsx(R,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>g(D),size:"small",children:e.jsx(Ir,{})})}),e.jsx(R,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>h(D),size:"small",children:e.jsx(Dr,{})})}),C&&!C.readOnly&&e.jsx(R,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>l(D),size:"small",children:e.jsx(At,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(N,O,D,P)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:D.error?e.jsx(e.Fragment,{children:e.jsx(Ue,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:D.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ue,{status:D.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:D.loaded&&D.started&&D.configured?e.jsx(e.Fragment,{children:e.jsx(Ue,{status:D.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{status:D.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ue,{status:D.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ue,{status:D.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const N=O=>{O.src==="Matterbridge"&&O.dst==="Frontend"&&(ae(O)&&O.method==="refresh_required"&&O.params.changed==="plugins"&&(n&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and sending /api/plugins request`),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),ae(O)&&O.method==="refresh_required"&&O.params.changed==="matter"&&(n&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and setting matter id ${O.params.matter?.id}`),W(D=>{const P=D.findIndex(S=>S.matter?.id===O.params.matter?.id);if(P<0)return n&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and matter id ${O.params.matter?.id} not found`),D;n&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} set matter id ${O.params.matter?.id}`);const k=[...D];return k[P]={...k[P],matter:O.params.matter},k})),ae(O)&&O.method==="refresh_required"&&O.params.changed==="settings"&&(n&&console.log(`HomePlugins received refresh_required: changed=${O.params.changed} and sending /api/settings request`),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ge(O)&&O.id===d.current&&O.method==="/api/settings"&&(n&&console.log(`HomePlugins (id: ${O.id}) received settings:`,O.response),L(O.response.systemInformation),A(O.response.matterbridgeInformation)),ge(O)&&O.id===d.current&&O.method==="/api/plugins"&&(n&&console.log(`HomePlugins (id: ${O.id}) received ${O.response.length} plugins:`,O.response),W(O.response)))};return s(N),n&&console.log("HomePlugins added WebSocket listener id:",d.current),()=>{v(N),n&&console.log("HomePlugins removed WebSocket listener")}},[s,v,i]),o.useEffect(()=>{a&&(n&&console.log("HomePlugins sending api requests"),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]);const m=o.useRef(null),E=(N,O,D,P)=>{n&&console.log(`handleActionWithConfirmCancel ${D} ${P.name}`),m.current=P,t(N,O,D,b,f)},b=N=>{n&&console.log(`handleConfirm action confirmed ${N} ${m.current?.name}`),N==="remove"&&m.current?x(m.current):N==="disable"&&m.current&&z(m.current),m.current=null},f=N=>{n&&console.log(`handleCancel action canceled ${N} ${m.current?.name}`),m.current=null},y=N=>{n&&console.log("handleUpdatePlugin plugin:",N.name),i({id:d.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name,restart:!1}})},H=N=>{n&&console.log("handleUpdateDevPlugin plugin:",N.name),i({id:d.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name+"@dev",restart:!1}})},x=N=>{n&&console.log("handleRemovePlugin plugin:",N.name),i({id:d.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},w=N=>{n&&console.log("handleRestartPlugin plugin:",N.name),i({id:d.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},z=N=>{n&&console.log("handleEnableDisablePlugin plugin:",N.name,"enabled:",N.enabled),N.enabled===!0?(N.enabled=!1,i({id:d.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})):(N.enabled=!0,i({id:d.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}}))},c=N=>{n&&console.log(`handleHomepagePlugin plugin: ${N.name} homepage: ${N.homepage}`),N.homepage&&window.open(N.homepage,"_blank")},l=N=>{n&&console.log("handleSponsorPlugin plugin:",N.name,"funding:",N.funding),N.funding&&window.open(N.funding,"_blank")},g=N=>{n&&console.log("handleHelpPlugin plugin:",N.name,"help:",N.help),N.help&&window.open(N.help,"_blank")},h=N=>{n&&console.log("handleChangelogPlugin plugin:",N.name,"changelog:",N.changelog),N.changelog&&window.open(N.changelog,"_blank")},[F,G]=o.useState(),[ye,xe]=o.useState(!1),he=N=>{n&&console.log("handleConfigPlugin plugin:",N.name),i({id:d.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),i({id:d.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),G(N),X()},X=()=>{xe(!0)},se=()=>{xe(!1)};return n&&console.log("HomePlugins rendering..."),a?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[F&&e.jsx(tn,{open:ye,onClose:se,plugin:F}),e.jsx(xt,{name:"Plugins",columns:_,rows:T,footerRight:"",footerLeft:""})]}):e.jsx(Ae,{})}const sn=o.memo(an),ln=r=>`${r.pluginName}::${r.serial}`;function dn({storeId:r,setStoreId:u}){const{online:a,sendMessage:i,addListener:s,removeListener:v,getUniqueId:M}=o.useContext(be),[t,d]=o.useState(!1),[$,L]=o.useState(!0),[C,A]=o.useState(null),[T,W]=o.useState([]),[_,m]=o.useState([]),[E,b]=o.useState([]),[f,y]=o.useState([]),H=o.useRef(M()),x=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(c,l,g,h)=>g.reachable===!0?"Online":g.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(c,l)=>{const g=c.reachable===!0?1:c.reachable===!1?0:-1,h=l.reachable===!0?1:l.reachable===!1?0:-1;return g-h}},{label:"Power",id:"powerSource",render:(c,l,g,h)=>g.powerSource==="ac"||g.powerSource==="dc"?e.jsx(qt,{fontSize:"small",sx:{color:"var(--primary-color)"}}):g.powerSource==="ok"?e.jsx(gt,{fontSize:"small",sx:{color:"green"}}):g.powerSource==="warning"?e.jsx(gt,{fontSize:"small",sx:{color:"yellow"}}):g.powerSource==="critical"?e.jsx(gt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(c,l,g,h)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[g.matter!==void 0?e.jsx(R,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>u(r===g.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:g.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Jt(g.matter)},children:e.jsx(Ut,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),g.configUrl?e.jsx(R,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(g.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Ct,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),g.selected!==void 0?e.jsx(R,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(He,{checked:g.selected,onChange:F=>z(F,g),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],w=o.useCallback(c=>{c.selected=void 0;const l=T.find(F=>F.name===c.pluginName);if(!l)return console.error(`HomeDevices isSelected: plugin ${c.pluginName} not found for device ${c.name} `),c.selected;const g=l.schemaJson?.properties?.whiteList?.selectFrom;let h=l.configJson.postfix;return h===""&&(h=void 0),l.hasWhiteList===!0&&l.hasBlackList===!0&&g&&(c.selected=!0,g==="serial"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&l.configJson.whiteList.includes(h?c.serial.replace("-"+h,""):c.serial)&&(c.selected=!0),g==="serial"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&!l.configJson.whiteList.includes(h?c.serial.replace("-"+h,""):c.serial)&&(c.selected=!1),g==="serial"&&l.configJson.blackList&&l.configJson.blackList.length>0&&l.configJson.blackList.includes(h?c.serial.replace("-"+h,""):c.serial)&&(c.selected=!1),g==="name"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&l.configJson.whiteList.includes(c.name)&&(c.selected=!0),g==="name"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&!l.configJson.whiteList.includes(c.name)&&(c.selected=!1),g==="name"&&l.configJson.blackList&&l.configJson.blackList.length>0&&l.configJson.blackList.includes(c.name)&&(c.selected=!1)),c.selected},[T]);o.useEffect(()=>{const c=l=>{if(l.src==="Matterbridge"&&l.dst==="Frontend"){if(ae(l)&&l.method==="refresh_required"&&l.params.changed!=="matter"&&(n&&console.log(`HomeDevices received refresh_required: changed=${l.params.changed} and sending /api/plugins request`),i({id:H.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),ae(l)&&l.method==="refresh_required"&&l.params.changed==="matter"&&(n&&console.log(`HomeDevices received refresh_required: changed=${l.params.changed} and setting matter id ${l.params.matter?.id}`),y(g=>{const h=g.findIndex(G=>G.name.replaceAll(" ","")===l.params.matter?.id);if(h<0)return n&&console.debug(`HomeDevices: matter id ${l.params.matter?.id} not found`),g;const F=[...g];return F[h]={...F[h],matter:l.params.matter},n&&console.log(`HomeDevices received refresh_required: changed=${l.params.changed} and set matter id ${l.params.matter?.id}`),F})),ae(l)&&l.method==="restart_required"&&(n&&console.log("HomeDevices received restart_required"),d(!0)),ae(l)&&l.method==="restart_not_required"&&(n&&console.log("HomeDevices received restart_not_required"),d(!1)),ae(l)&&l.method==="state_update"&&l.params.plugin&&l.params.serialNumber&&l.params.cluster.includes("BasicInformationServer")&&l.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${l.params.plugin} serial ${l.params.serialNumber} value ${l.params.value}`),m(g=>g.map(h=>h.pluginName===l.params.plugin&&h.serial===l.params.serialNumber?{...h,reachable:l.params.value}:h))),ge(l)&&l.id===H.current&&l.method==="/api/settings"&&(n&&console.log(`HomeDevices (id: ${l.id}) received settings:`,l.response),A(l.response),d(l.response.matterbridgeInformation.restartRequired||l.response.matterbridgeInformation.fixedRestartRequired)),ge(l)&&l.id===H.current&&l.method==="/api/plugins"&&(n&&console.log(`HomeDevices (id: ${l.id}) received ${l.response?.length} plugins:`,l.response),l.response)){let g=!0;for(const h of l.response)h.enabled===!0&&(h.loaded!==!0||h.started!==!0||h.error===!0)&&(g=!1);if(!g)return;n&&console.log("HomeDevices reset plugins, devices and selectDevices"),L(!1),W(l.response),m([]),b([]),i({id:H.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),n&&console.log("HomeDevices sent /api/devices");for(const h of l.response)h.enabled===!0&&h.loaded===!0&&h.started===!0&&h.error!==!0&&(i({id:H.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:h.name}}),n&&console.log(`HomeDevices sent /api/select/devices for plugin: ${h.name}`))}if(ge(l)&&l.id===H.current&&l.method==="/api/devices"&&(n&&console.log(`HomeDevices (id: ${l.id}) received ${l.response?.length} devices:`,l.response),l.response)){for(const g of l.response)g.selected=w(g);m(l.response)}ge(l)&&l.id===H.current&&l.method==="/api/select/devices"&&(n&&console.log(`HomeDevices (id: ${l.id}) received ${l.response?.length} selectDevices for plugin ${l.response&&l.response.length>0?l.response[0].pluginName:"without select devices"}:`,l.response),l.response&&l.response.length>0&&b(g=>{const h=g.filter(G=>G.pluginName!==l.response[0].pluginName),F=l.response.map(G=>({...G,selected:w(G)}));return[...h,...F]}))}};return s(c),n&&console.log(`HomeDevices added WebSocket listener id ${H.current}`),()=>{v(c),n&&console.log("HomeDevices removed WebSocket listener")}},[T,s,v,i,w]),o.useEffect(()=>{if(_.length===0&&E.length===0){y([]);return}n&&console.log(`HomeDevices mixing devices (${_.length}) and selectDevices (${E.length})`);const c=[];for(const l of _)c.push(l);for(const l of E)_.find(g=>g.pluginName===l.pluginName&&g.serial.includes(l.serial))||c.push(l);c.length>0&&(y(c),n&&console.log(`HomeDevices mixed ${c.length} devices and selectDevices`))},[T,_,E,y]),o.useEffect(()=>{a&&(n&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:H.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:H.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]);const z=(c,l)=>{console.log(`handleCheckboxChange: checkbox changed to ${c.target.checked} for device ${l.name} serial ${l.serial}`),y(g=>{const h=g.findIndex(G=>G.pluginName===l.pluginName&&G.serial===l.serial);if(h<0)return console.error(`handleCheckboxChange: device not found ${l.name} serial ${l.serial}`),g;const F=[...g];return F[h]={...F[h],selected:c.target.checked},F}),c.target.checked?i({id:H.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:l.pluginName,serial:l.serial,name:l.name}}):i({id:H.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:l.pluginName,serial:l.serial,name:l.name}})};return n&&console.log("HomeDevices rendering..."),a?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(xt,{name:"Devices",getRowKey:ln,rows:f,columns:x,footerLeft:$?"Waiting for the plugins to fully load...":`Registered devices: ${_.length.toString()}/${f.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Ae,{})}const cn=o.memo(dn);function pn(){const[r,u]=o.useState(null),[a,i]=o.useState(null),[s,v]=o.useState([]),[M]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,d]=o.useState(localStorage.getItem("homePageMode")??"devices"),[$,L]=o.useState(""),[C,A]=o.useState(!1),[T,W]=o.useState(!1),[_,m]=o.useState(null),{addListener:E,removeListener:b,online:f,sendMessage:y,logFilterLevel:H,logFilterSearch:x,autoScroll:w,getUniqueId:z}=o.useContext(be),c=o.useRef(z());return o.useEffect(()=>{const l=g=>{g.src==="Matterbridge"&&g.dst==="Frontend"&&(ae(g)&&g.method==="refresh_required"&&g.params.changed==="settings"&&(n&&console.log(`Home received refresh_required: changed=${g.params.changed} and sending /api/settings request`),m(null),v([]),y({id:c.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),y({id:c.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),ge(g)&&g.method==="/api/settings"&&g.id===c.current&&(n&&console.log("Home received settings:",g.response),u(g.response.systemInformation),i(g.response.matterbridgeInformation),g.response.matterbridgeInformation.bridgeMode==="bridge"&&(_||m("Matterbridge")),g.response.matterbridgeInformation.bridgeMode==="childbridge"&&s.length>0&&_===null&&!_&&s.length>0&&s[0].matter?.id&&m(s[0].matter.id),g.response.matterbridgeInformation.matterbridgeVersion&&L(`https://github.com/Luligu/matterbridge/blob/${g.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&g.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",g.response.matterbridgeInformation.frontendVersion):g.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&g.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",g.response.matterbridgeInformation.frontendVersion),W(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",g.response.matterbridgeInformation.matterbridgeVersion):g.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",g.response.matterbridgeInformation.matterbridgeVersion),A(!0)),g.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),d("devices")))),ge(g)&&g.method==="/api/plugins"&&g.id===c.current&&(n&&console.log(`Home received plugins (${a?.bridgeMode}):`,g.response),v(g.response),a?.bridgeMode==="childbridge"&&g.response.length>0&&!_&&g.response.length>0&&g.response[0].matter?.id&&m(g.response[0].matter.id)))};return E(l),n&&console.log(`Home added WebSocket listener id ${c.current}`),()=>{b(l),n&&console.log("Home removed WebSocket listener")}},[E,b,y,a,s,_]),o.useEffect(()=>{f&&(n&&console.log("Home received online"),y({id:c.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),y({id:c.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[f,y]),n&&console.log("Home rendering..."),!f||!r||!a?e.jsx(Ae,{}):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(Jo,{id:_}),e.jsx(Bo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[T&&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(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Pr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),C&&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(ie,{onClick:()=>window.open($,"_blank"),endIcon:e.jsx(Vt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Nr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),M&&!a.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(Yo,{})]}),M&&e.jsx(sn,{storeId:_,setStoreId:m}),t==="devices"&&e.jsx(cn,{storeId:_,setStoreId:m}),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 "',H,'" and search "',x,'" Scroll: ',w?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(Kt,{})})]})]})]})}const un=o.memo(pn),Et={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},mn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},gn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},_t={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},hn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},fn={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"},bn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},vn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},jt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},yn=[256,257,268,269],jn=[266,267],Cn=[259,260,261,271,272],wn=[256,257,268,269,266,267,259,260,261];function U({icon:r,iconColor:u,cluster:a,value:i,unit:s,prefix:v}){return n&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),v=v??!1,e.jsxs(Z,{sx:Et,children:[r&&o.cloneElement(r,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...mn,color:u??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Et,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&v===!0&&e.jsx(ne,{sx:_t,children:s},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(ne,{sx:gn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),s&&v===!1&&e.jsx(ne,{sx:_t,children:s},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function Sn({device:r,endpoint:u,id:a,deviceType:i,clusters:s}){const v=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let M="";return n&&console.log(`Device "${r.name}" endpoint "${u}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length}):`,s),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>M=`${t.attributeLocalValue} mV`),wn.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>M=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>M=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>M=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>M=M+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>M=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>M=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>M=M+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>M=M+`${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:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(U,{icon:t.attributeLocalValue===!0?e.jsx(Ze,{}):e.jsx(Fr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(U,{icon:e.jsx(gt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(U,{icon:e.jsx(qt,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(U,{icon:e.jsx(re,{path:po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),yn.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(U,{icon:e.jsx(Lr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(U,{icon:e.jsx(re,{path:uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Cn.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(U,{icon:e.jsx(re,{path:mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(U,{icon:e.jsx(re,{path:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(U,{icon:e.jsx(re,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(U,{icon:e.jsx(re,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(U,{icon:e.jsx(Ft,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(U,{icon:e.jsx(Wr,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(U,{icon:e.jsx(re,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(U,{icon:e.jsx(Ft,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(U,{icon:e.jsx(re,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Rt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Rt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===116&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(U,{icon:e.jsx(re,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(U,{icon:e.jsx(Tr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(U,{icon:e.jsx(re,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(U,{icon:t.attributeValue==="1"?e.jsx($r,{}):e.jsx(Rr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(U,{icon:e.jsx(Hr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(U,{icon:e.jsx(re,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(U,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(U,{icon:e.jsx(Er,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(U,{icon:e.jsx(Lt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(U,{icon:e.jsx(Lt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(U,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(U,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(U,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(U,{icon:e.jsx(re,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(U,{icon:e.jsx(re,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(U,{icon:e.jsx(re,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Ht,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Ht,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(U,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:v[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(U,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(U,{icon:e.jsx(re,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(U,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(U,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(U,{icon:t.attributeValue==="true"?e.jsx(Qr,{}):e.jsx(Kr,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(U,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Jr,{}):e.jsx(Gr,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(U,{icon:e.jsx(Yr,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(U,{icon:e.jsx(Xr,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:hn,children:e.jsx(ne,{sx:fn,children:M})}),e.jsx(Z,{sx:xn,children:e.jsx(ne,{sx:bn,children:r.name})}),e.jsxs(Z,{sx:vn,children:[n&&e.jsx(ne,{sx:jt,children:u}),e.jsx(ne,{sx:jt,children:a}),n&&e.jsxs(ne,{sx:jt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Mn({filter:r}){const{online:u,sendMessage:a,addListener:i,removeListener:s,getUniqueId:v}=o.useContext(be),[M,t]=o.useState(null),[d,$]=o.useState([]),[L,C]=o.useState([]),[A,T]=o.useState(L),[W,_]=o.useState({}),[m,E]=o.useState({}),[b,f]=o.useState({}),y=o.useRef(v());o.useEffect(()=>{const x=w=>{if(w.src==="Matterbridge"&&w.dst==="Frontend"){if(ae(w)&&w.method==="refresh_required"&&(n&&console.log(`DevicesIcons received refresh_required: changed=${w.params.changed} and sending api requests`),a({id:y.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:y.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:y.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),ge(w)&&w.method==="/api/settings"&&w.response&&(n&&console.log("DevicesIcons received settings:",w.response),t(w.response)),ge(w)&&w.method==="/api/plugins"&&w.response&&(n&&console.log("DevicesIcons received plugins:",w.response),$(w.response)),ge(w)&&w.method==="/api/devices"&&w.response){n&&console.log(`DevicesIcons received ${w.response.length} devices:`,w.response),C(w.response);for(const z of w.response)n&&console.log("DevicesIcons sending /api/clusters"),a({id:y.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:z.pluginName,endpoint:z.endpoint||0}})}if(ge(w)&&w.method==="/api/clusters"&&w.response){if(n&&console.log(`DevicesIcons received for device "${w.response.deviceName}" serial "${w.response.serialNumber}" deviceType ${w.response.deviceTypes.join(" ")} clusters (${w.response.clusters.length}):`,w.response),w.response.clusters.length===0)return;const z=w.response.serialNumber;W[z]=[],m[z]=w.response.deviceTypes,b[z]=[];for(const c of w.response.clusters)W[z].find(l=>l.endpoint===c.endpoint)||W[z].push({endpoint:c.endpoint,id:c.id,deviceTypes:c.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(c.clusterName)&&b[z].push(c);_({...W}),E({...m}),f({...b}),n&&console.log(`DevicesIcons endpoints for "${z}":`,W[z]),n&&console.log(`DevicesIcons deviceTypes for "${z}":`,m[z]),n&&console.log(`DevicesIcons clusters for "${z}":`,b[z])}}};return i(x),n&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{s(x),n&&console.log("DevicesIcons useEffect webSocket unmounted")}},[i,s,a]),o.useEffect(()=>(n&&console.log("DevicesIcons useEffect online mounting"),u&&(n&&console.log("DevicesIcons useEffect online sending api requests"),a({id:y.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:y.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:y.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),n&&console.log("DevicesIcons useEffect online mounted"),()=>{n&&console.log("DevicesIcons useEffect online unmounted")}),[u,a]),o.useEffect(()=>{if(r===""){T(L);return}const x=L.filter(w=>w.name.toLowerCase().includes(r)||w.serial.toLowerCase().includes(r));T(x)},[L,r]);const H=o.memo(Sn);return n&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:A.map(x=>W[x.serial]&&W[x.serial].map(w=>w.deviceTypes.map(z=>e.jsx(H,{device:x,endpoint:w.endpoint,id:w.id,deviceType:z,clusters:b[x.serial].filter(c=>c.endpoint===w.endpoint)},`${x.pluginName}-${x.uniqueId}-${z}`))))})}const kn=o.memo(Mn),In=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(r,u,a,i)=>a.configUrl?e.jsx(Q,{onClick:()=>window.open(a.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Ct,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Dn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(r,u,a,i)=>Array.isArray(r)?e.jsx(e.Fragment,{children:r.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:r})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(r,u,a,i)=>e.jsx(R,{title:String(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:String(r)})})}],Pn=r=>`${r.pluginName}::${r.uniqueId}`,Nn=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Fn(){const{online:r,sendMessage:u,addListener:a,removeListener:i,getUniqueId:s}=o.useContext(be),[v,M]=o.useState([]),[t,d]=o.useState(v),[$,L]=o.useState([]),[C,A]=o.useState(0),[T,W]=o.useState(""),[_,m]=o.useState("icon"),[E,b]=o.useState(null),[f,y]=o.useState(null),[H,x]=o.useState(null),[w,z]=o.useState(null),c=o.useRef(s());o.useEffect(()=>{const F=G=>{if(n&&console.log("Devices received WebSocket Message:",G),G.src==="Matterbridge"&&G.dst==="Frontend"&&(ae(G)&&G.method==="refresh_required"&&G.params.changed==="devices"&&(n&&console.log(`Devices received refresh_required: changed=${G.params.changed} and sending /api/devices request`),u({id:c.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),ge(G)&&G.method==="/api/devices"&&(n&&console.log(`Devices received ${G.response.length} devices:`,G.response),M(G.response)),ge(G)&&G.method==="/api/clusters")){n&&console.log(`Clusters received ${G.response.clusters.length} clusters for plugin ${G.response.plugin}:`,G.response),L(G.response.clusters);const ye={};for(const xe of G.response.clusters)n&&console.log("Cluster:",xe.endpoint),ye[xe.endpoint]?ye[xe.endpoint]++:ye[xe.endpoint]=1;A(Object.keys(ye).length)}};return a(F),n&&console.log("Devices added WebSocket listener"),()=>{i(F),n&&console.log("Devices removed WebSocket listener")}},[a,i,u]),o.useEffect(()=>{r&&(n&&console.log("Devices sending api requests"),u({id:c.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),u({id:c.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),u({id:c.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,u]),o.useEffect(()=>{E&&f&&(n&&console.log("Devices sending /api/clusters"),u({id:c.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:E,endpoint:Number(f)}}))},[E,f,u]),o.useEffect(()=>{if(T===""){d(v);return}const F=v.filter(G=>G.name.toLowerCase().includes(T)||G.serial.toLowerCase().includes(T));d(F)},[v,T]),o.useEffect(()=>{const F=localStorage.getItem("devicesFilter");F&&W(F)},[]),o.useEffect(()=>{const F=localStorage.getItem("devicesViewMode");F&&m(F)},[]);const l=F=>{W(F.target.value.toLowerCase()),localStorage.setItem("devicesFilter",F.target.value.toLowerCase())},g=F=>{m(F),localStorage.setItem("devicesViewMode",F)},h=F=>{if(F.uniqueId===w){z(null),b(null),y(null),x(null);return}z(F.uniqueId),b(F.pluginName),y(F.endpoint?F.endpoint.toString():null),x(F.name)};return n&&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(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ne,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:T,onChange:l,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(ne,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(Q,{onClick:()=>g("table"),"aria-label":"Table View",disabled:_==="table",children:e.jsx(R,{title:"Table View",children:e.jsx(Zr,{style:{color:_==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:_==="icon",children:e.jsx(R,{title:"Icon View (beta)",children:e.jsx(eo,{style:{color:_==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),_==="table"&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${E&&f?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(xt,{name:"Registered devices",getRowKey:Pn,onRowClick:h,rows:t,columns:In,footerLeft:`Total devices: ${t.length.toString()}`})}),_==="table"&&E&&f&&e.jsx("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(xt,{name:"Clusters",title:H||"",getRowKey:Nn,rows:$,columns:Dn,footerLeft:`Total child endpoints: ${C-1}`})}),_==="icon"&&e.jsx(kn,{filter:T})]}):e.jsx(Ae,{})}const Ln=o.memo(Fn);function Wn(){const[r,u]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[a,i]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[s,v]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:M,setLogFilters:t,online:d,setAutoScroll:$}=o.useContext(be),L=W=>{u(W.target.value),t(W.target.value,a),localStorage.setItem("logFilterLevel",W.target.value),n&&console.log("handleChangeLevel called with value:",W.target.value)},C=W=>{i(W.target.value),t(r,W.target.value),localStorage.setItem("logFilterSearch",W.target.value),n&&console.log("handleChangeSearch called with value:",W.target.value)},A=W=>{v(W.target.checked),$(W.target.checked),localStorage.setItem("logAutoScroll",W.target.value?"true":"false"),n&&console.log("handleAutoScrollChange called with value:",W.target.checked)},T=()=>{n&&console.log("handleClearLogsClick called"),M([])};return n&&console.log("Logs rendering..."),d?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(Wt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ke,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:L,children:[e.jsx(I,{value:"debug",children:"Debug"}),e.jsx(I,{value:"info",children:"Info"}),e.jsx(I,{value:"notice",children:"Notice"}),e.jsx(I,{value:"warn",children:"Warn"}),e.jsx(I,{value:"error",children:"Error"}),e.jsx(I,{value:"fatal",children:"Fatal"})]}),e.jsx(Wt,{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:a,onChange:C,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Re,{control:e.jsx(He,{checked:s,onChange:A}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(R,{title:"Clear the logs",children:e.jsx(ie,{onClick:T,endIcon:e.jsx(ht,{}),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(Kt,{})})]}):e.jsx(Ae,{})}const Tn=o.memo(Wn),$n=({open:r,ip:u,onClose:a,onSave:i})=>{const s=u?u.split(".").slice(0,3).join(".")+".1":"",[v,M]=o.useState("dhcp"),[t,d]=o.useState({ip:u??"",subnet:"255.255.255.0",gateway:s,dns:s}),$=A=>T=>{d({...t,[A]:T.target.value})},L=()=>{a()},C=()=>{i({type:v,...t}),a()};return e.jsxs(Ne,{open:r,onClose:(A,T)=>{T==="backdropClick"||T==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Fe,{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(Le,{dividers:!0,children:[e.jsxs(zt,{component:"fieldset",fullWidth:!0,children:[e.jsx(Me,{component:"legend",children:"Select IP Configuration"}),e.jsxs(Bt,{row:!0,value:v,onChange:A=>M(A.target.value),children:[e.jsx(Re,{value:"dhcp",control:e.jsx(ft,{}),label:"DHCP"}),e.jsx(Re,{value:"static",control:e.jsx(ft,{}),label:"Static"})]})]}),v==="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:$("ip")})}),e.jsx($e,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:$("subnet")})}),e.jsx($e,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:$("gateway")})}),e.jsx($e,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:$("dns")})})]})]}),e.jsxs(_e,{children:[e.jsx(ie,{onClick:L,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:C,children:"Save"})]})]})},Rn=({open:r,onClose:u,onSave:a})=>{const[i,s]=o.useState(""),[v,M]=o.useState(""),t=T=>{s(T.target.value)},d=T=>{M(T.target.value)},$=i.length>0&&i===v,L=()=>{u()},C=()=>{$&&(a(i),u())},A=()=>{a(""),u()};return e.jsxs(Ne,{open:r,onClose:(T,W)=>{W==="backdropClick"||W==="escapeKeyDown"||u()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Fe,{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(Le,{dividers:!0,children:e.jsx(zt,{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:i,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:v,onChange:d,error:v!==""&&i!==v,helperText:v!==""&&i!==v?"Passwords do not match":""})})]})})}),e.jsxs(_e,{children:[e.jsx(ie,{onClick:L,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:C,disabled:!$,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:A,children:"Reset"})]})]})};function Hn(){const{online:r,addListener:u,removeListener:a,sendMessage:i,getUniqueId:s}=o.useContext(be),[v,M]=o.useState(null),[t,d]=o.useState(null),$=o.useRef(s());return o.useEffect(()=>{const L=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(ae(C)&&C.method==="refresh_required"&&C.params.changed==="settings"&&(n&&console.log(`Settings received refresh_required: changed=${C.params.changed} and sending /api/settings request`),i({id:$.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ge(C)&&C.method==="/api/settings"&&(n&&console.log("Settings received /api/settings:",C.response),M(C.response.matterbridgeInformation),d(C.response.systemInformation)))};return u(L),n&&console.log("Settings added WebSocket listener"),()=>{a(L),n&&console.log("Settings removed WebSocket listener")}},[u,a,i]),o.useEffect(()=>{r&&(n&&console.log("Settings received online"),i({id:$.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,i]),v?(n&&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(On,{matterbridgeInfo:v,systemInfo:t}),e.jsx(En,{matterbridgeInfo:v}),e.jsx(_n,{matterbridgeInfo:v})]})}):e.jsx(Ae,{})):null}function On({matterbridgeInfo:r,systemInfo:u}){const{sendMessage:a,getUniqueId:i}=o.useContext(be),[s,v]=o.useState("bridge"),[M,t]=o.useState("Info"),[d,$]=o.useState(!1),[L,C]=o.useState("dark"),[A,T]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[W,_]=o.useState(localStorage.getItem("homePageMode")??"devices"),[m,E]=o.useState(localStorage.getItem("virtualMode")??"outlet"),b=o.useRef(i()),[f,y]=o.useState(!1),H=()=>y(!1),x=X=>{n&&console.log("handleSaveNetConfig called with config:",X),a({id:b.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:X})},[w,z]=o.useState(!1),c=()=>z(!1),l=X=>{n&&console.log("handleSaveChangePassword called with password:",X),a({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:X}})};o.useEffect(()=>{r&&(v(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),$(r.fileLogger),E(r.virtualMode))},[r]),o.useEffect(()=>{const X=localStorage.getItem("frontendTheme");X&&C(X)},[]);const g=X=>{n&&console.log("handleChangeBridgeMode called with value:",X.target.value),v(X.target.value),a({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:X.target.value}})},h=X=>{n&&console.log("handleChangeMbLoggerLevel called with value:",X.target.value),t(X.target.value),a({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:X.target.value}})},F=X=>{n&&console.log("handleLogOnFileMbChange called with value:",X.target.checked),$(X.target.checked),a({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:X.target.checked}})},G=X=>{const se=X.target.value;n&&console.log("handleChangeTheme called with value:",se),C(se),localStorage.setItem("frontendTheme",se),document.body.setAttribute("frontend-theme",se)},ye=X=>{const se=X.target.checked;n&&console.log("handleChangeHomePagePlugins called with value:",se),T(se),localStorage.setItem("homePagePlugins",se?"true":"false")},xe=X=>{const se=X.target.value;n&&console.log("handleChangeHomePageMode called with value:",se),_(se),localStorage.setItem("homePageMode",se)},he=X=>{const se=X.target.value;n&&console.log("handleChangeVirtualMode called with value:",se),E(se),localStorage.setItem("virtualMode",se),a({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:se}})};return!r||!u?null: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($n,{open:f,ip:u.ipv4Address,onClose:H,onSave:x}),e.jsx(Rn,{open:w,onClose:c,onSave:l}),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(Me,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(Bt,{row:!0,name:"mode-buttons-group",value:s,onChange:g,children:[e.jsx(Re,{value:"bridge",control:e.jsx(ft,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(Re,{value:"childbridge",control:e.jsx(ft,{}),label:"Childbridge",disabled:r.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Me,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:M,onChange:h,children:[e.jsx(I,{value:"Debug",children:"Debug"}),e.jsx(I,{value:"Info",children:"Info"}),e.jsx(I,{value:"Notice",children:"Notice"}),e.jsx(I,{value:"Warn",children:"Warn"}),e.jsx(I,{value:"Error",children:"Error"}),e.jsx(I,{value:"Fatal",children:"Fatal"})]}),e.jsx(Re,{style:{padding:"0px",margin:"0px"},control:e.jsx(He,{checked:d,onChange:F,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Me,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:L,onChange:G,children:[e.jsx(I,{value:"classic",children:"Classic"}),e.jsx(I,{value:"light",children:"Light"}),e.jsx(I,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Me,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(He,{checked:A,onChange:ye,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Me,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:W,onChange:xe,children:[e.jsx(I,{value:"logs",children:"Logs"}),e.jsx(I,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Me,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:m,onChange:he,children:[e.jsx(I,{value:"disabled",children:"Disabled"}),e.jsx(I,{value:"outlet",children:"Outlet"}),e.jsx(I,{value:"light",children:"Light"}),e.jsx(I,{value:"switch",children:"Switch"}),e.jsx(I,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Change password"})}),r.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>y(!0),children:"Configure IP"})})]})})]})}function En({matterbridgeInfo:r}){const{sendMessage:u,getUniqueId:a}=o.useContext(be),[i,s]=o.useState("Info"),[v,M]=o.useState(!1),[t,d]=o.useState(""),[$,L]=o.useState(""),[C,A]=o.useState(""),[T,W]=o.useState(""),[_,m]=o.useState(""),[E,b]=o.useState(""),f=o.useRef(a());o.useEffect(()=>{r&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),M(r.matterFileLogger),d(r.matterMdnsInterface||""),L(r.matterIpv4Address||""),A(r.matterIpv6Address||""),W(r.matterPort?r.matterPort.toString():""),m(r.matterDiscriminator?r.matterDiscriminator.toString():""),b(r.matterPasscode?r.matterPasscode.toString():""))},[r]);const y=h=>{n&&console.log("handleChangeMjLoggerLevel called with value:",h.target.value),s(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:h.target.value}})},H=h=>{n&&console.log("handleLogOnFileMjChange called with value:",h.target.checked),M(h.target.checked),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:h.target.checked}})},x=h=>{n&&console.log("handleChangeMdnsInterface called with value:",h.target.value),d(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:h.target.value}})},w=h=>{n&&console.log("handleChangeIpv4Address called with value:",h.target.value),L(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:h.target.value}})},z=h=>{n&&console.log("handleChangeIpv6Address called with value:",h.target.value),A(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:h.target.value}})},c=h=>{n&&console.log("handleChangeMatterPort called with value:",h.target.value),W(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:h.target.value}})},l=h=>{n&&console.log("handleChangeMatterDiscriminator called with value:",h.target.value),m(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:h.target.value}})},g=h=>{n&&console.log("handleChangemMatterPasscode called with value:",h.target.value),b(h.target.value),u({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:h.target.value}})};return r?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(Me,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ke,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:y,children:[e.jsx(I,{value:"Debug",children:"Debug"}),e.jsx(I,{value:"Info",children:"Info"}),e.jsx(I,{value:"Notice",children:"Notice"}),e.jsx(I,{value:"Warn",children:"Warn"}),e.jsx(I,{value:"Error",children:"Error"}),e.jsx(I,{value:"Fatal",children:"Fatal"})]}),e.jsx(Re,{style:{padding:"0px",margin:"0px"},control:e.jsx(He,{checked:v,onChange:H,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Me,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,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(Me,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:$,onChange:w,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(Me,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:C,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(Me,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:T,onChange:c,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(Me,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:_,onChange:l,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(Me,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:E,onChange:g,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function _n({matterbridgeInfo:r}){return r?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(Ee,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(Ee,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Ee,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(Ee,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(Ee,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Ee,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Ee,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]}):null}function Ee({value:r,label:u}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:u,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)"}}}})}const An=o.memo(Hn);function Vn(){const{online:r,sendMessage:u,addListener:a,removeListener:i,getUniqueId:s}=o.useContext(be),{showSnackbarMessage:v}=o.useContext(Je),[M,t]=o.useState(null),[d,$]=o.useState([]),[L,C]=o.useState([]),[A,T]=o.useState(null),[W,_]=o.useState({cpuUsage:0}),[m,E]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[b,f]=o.useState({systemUptime:"",processUptime:""}),y=o.useRef(s());return console.log("Test uniqueId:",y),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const H=x=>{if(x.src==="Matterbridge"&&x.dst==="Frontend"){if(ae(x)&&x.method==="restart_required"&&(console.log("Test received restart_required"),v("Restart required",0)),ae(x)&&x.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${x.params.changed} and sending api requests`),v("Refresh required",0),u({id:y.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),u({id:y.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),u({id:y.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),ae(x)&&x.method==="memory_update"&&(console.log("Test received memory_update",x),E(x.params)),ae(x)&&x.method==="cpu_update"&&(console.log("Test received cpu_update",x),_(x.params)),ae(x)&&x.method==="uptime_update"&&(console.log("Test received uptime_update",x),f(x.params)),ge(x)&&x.method==="/api/settings"&&x.response&&(console.log("Test received /api/settings:",x.response),v("Test received /api/settings",0),t(x.response)),ge(x)&&x.method==="/api/plugins"&&x.response&&(console.log(`Test received ${x.response.length} plugins:`,x.response),v("Test received /api/plugins",0),$(x.response)),ge(x)&&x.method==="/api/devices"&&x.response){console.log(`Test received ${x.response.length} devices:`,x.response),v("Test received /api/devices",0),C(x.response);for(const w of x.response)console.log("Test sending /api/clusters for device:",w.pluginName,w.name,w.endpoint),u({id:y.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:w.pluginName,endpoint:w.endpoint||0}})}ge(x)&&x.method==="/api/clusters"&&x.response&&(console.log(`Test received ${x.response.clusters.length} clusters for device ${x.response.deviceName} endpoint ${x.response.endpoint}:`,x),v(`Test received /api/clusters for ${x.response.plugin}::${x.response.deviceName}`,0),T(x.response))}};return a(H),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),i(H),console.log("Test useEffect WebSocketMessage unmounted")}},[a,i,u,v]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),u({id:y.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),u({id:y.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),u({id:y.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,u,v]),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(Ae,{})}const Un=o.memo(Vn);function qn(r,u){n&&console.log("getCssVariable:",r,"defaultValue",u);const a=getComputedStyle(document.body).getPropertyValue(r).trim();return a||console.error("getCssVariable: undefined",a),a||u}function zn(r){return to({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 n=!1;const Bn=()=>{n=!n};function Qn({setLoggedIn:r}){const[u,a]=o.useState(""),[i,s]=o.useState(""),v={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},M={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)"},t={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)"},d=async L=>{try{const C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:L})});if(C.ok){const{valid:A}=await C.json();A?r(!0):L!==""&&s("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},$=L=>{L.preventDefault(),d(u)};return d(""),e.jsx("div",{style:v,children:e.jsxs("form",{onSubmit:$,style:M,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:u,onChange:L=>a(L.target.value),style:t,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function Kn(){const[r,u]=o.useState(!1);n&&console.log("Setting frontend theme");const a=localStorage.getItem("frontendTheme");n&&console.log("Saved theme:",a),a?document.body.setAttribute("frontend-theme",a):document.body.setAttribute("frontend-theme","dark");const i=qn("--primary-color","#1976d2");n&&console.log("Primary color from CSS:",i);const s=zn(i),v=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return n&&(console.log("Loading App..."),console.log("- production mode"),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${v}"`)),r?e.jsx(ro,{theme:s,children:e.jsx(ur,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Oo,{children:e.jsx(Eo,{children:e.jsx(ar,{basename:v,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Ao,{}),e.jsxs(sr,{children:[e.jsx(Ve,{path:"/",element:e.jsx(un,{})}),e.jsx(Ve,{path:"/devices",element:e.jsx(Ln,{})}),e.jsx(Ve,{path:"/log",element:e.jsx(Tn,{})}),e.jsx(Ve,{path:"/settings",element:e.jsx(An,{})}),e.jsx(Ve,{path:"/test",element:e.jsx(Un,{})}),e.jsx(Ve,{path:"*",element:e.jsx(lr,{to:"/"})})]})]})})})})})}):e.jsx(Qn,{setLoggedIn:u})}dr.createRoot(document.getElementById("root")).render(e.jsx(cr.StrictMode,{children:e.jsx(Kn,{})}));
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.2.9-dev-20250922-6e00637",
3
+ "version": "3.2.9-dev-20250922-517cae7",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge",
9
- "version": "3.2.9-dev-20250922-6e00637",
9
+ "version": "3.2.9-dev-20250922-517cae7",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@matter/main": "0.15.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.2.9-dev-20250922-6e00637",
3
+ "version": "3.2.9-dev-20250922-517cae7",
4
4
  "description": "Matterbridge plugin manager for Matter",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",