matterbridge 3.2.8 → 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.
Files changed (296) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/README-NGINX.md +47 -23
  3. package/dist/cli.js +2 -91
  4. package/dist/cliEmitter.js +0 -30
  5. package/dist/clusters/export.js +0 -2
  6. package/dist/defaultConfigSchema.js +0 -24
  7. package/dist/deviceManager.js +1 -94
  8. package/dist/devices/airConditioner.js +0 -57
  9. package/dist/devices/batteryStorage.js +1 -48
  10. package/dist/devices/cooktop.js +0 -55
  11. package/dist/devices/dishwasher.js +0 -57
  12. package/dist/devices/evse.js +10 -74
  13. package/dist/devices/export.js +0 -5
  14. package/dist/devices/extractorHood.js +0 -42
  15. package/dist/devices/heatPump.js +2 -50
  16. package/dist/devices/laundryDryer.js +3 -62
  17. package/dist/devices/laundryWasher.js +4 -70
  18. package/dist/devices/microwaveOven.js +5 -88
  19. package/dist/devices/oven.js +0 -85
  20. package/dist/devices/refrigerator.js +0 -102
  21. package/dist/devices/roboticVacuumCleaner.js +9 -100
  22. package/dist/devices/solarPower.js +0 -38
  23. package/dist/devices/speaker.js +0 -84
  24. package/dist/devices/temperatureControl.js +3 -25
  25. package/dist/devices/waterHeater.js +2 -82
  26. package/dist/dgram/coap.js +13 -126
  27. package/dist/dgram/dgram.js +2 -114
  28. package/dist/dgram/mb_coap.js +3 -41
  29. package/dist/dgram/mb_mdns.js +15 -80
  30. package/dist/dgram/mdns.js +137 -299
  31. package/dist/dgram/multicast.js +1 -62
  32. package/dist/dgram/unicast.js +0 -54
  33. package/dist/frontend.js +45 -435
  34. package/dist/frontendTypes.js +3 -51
  35. package/dist/globalMatterbridge.js +0 -47
  36. package/dist/helpers.js +0 -53
  37. package/dist/index.js +1 -30
  38. package/dist/logger/export.js +0 -1
  39. package/dist/matter/behaviors.js +0 -2
  40. package/dist/matter/clusters.js +0 -2
  41. package/dist/matter/devices.js +0 -2
  42. package/dist/matter/endpoints.js +0 -2
  43. package/dist/matter/export.js +0 -3
  44. package/dist/matter/types.js +0 -3
  45. package/dist/matterbridge.js +57 -780
  46. package/dist/matterbridgeAccessoryPlatform.js +0 -36
  47. package/dist/matterbridgeBehaviors.js +5 -65
  48. package/dist/matterbridgeDeviceTypes.js +17 -630
  49. package/dist/matterbridgeDynamicPlatform.js +0 -36
  50. package/dist/matterbridgeEndpoint.js +55 -1373
  51. package/dist/matterbridgeEndpointHelpers.js +12 -345
  52. package/dist/matterbridgePlatform.js +0 -304
  53. package/dist/matterbridgeTypes.js +0 -25
  54. package/dist/pluginManager.js +3 -249
  55. package/dist/shelly.js +11 -172
  56. package/dist/storage/export.js +0 -1
  57. package/dist/update.js +0 -69
  58. package/dist/utils/colorUtils.js +2 -97
  59. package/dist/utils/commandLine.js +0 -54
  60. package/dist/utils/copyDirectory.js +1 -38
  61. package/dist/utils/createDirectory.js +0 -33
  62. package/dist/utils/createZip.js +2 -47
  63. package/dist/utils/deepCopy.js +0 -39
  64. package/dist/utils/deepEqual.js +1 -72
  65. package/dist/utils/error.js +0 -41
  66. package/dist/utils/export.js +0 -1
  67. package/dist/utils/hex.js +0 -124
  68. package/dist/utils/isvalid.js +0 -101
  69. package/dist/utils/jestHelpers.js +3 -153
  70. package/dist/utils/network.js +5 -91
  71. package/dist/utils/spawn.js +0 -68
  72. package/dist/utils/wait.js +8 -60
  73. package/frontend/build/assets/index.js +2 -2
  74. package/frontend/build/assets/vendor_lodash.js +1 -1
  75. package/frontend/build/assets/vendor_mdi.js +1 -1
  76. package/frontend/build/assets/vendor_mui.js +31 -23
  77. package/frontend/build/assets/vendor_node_modules.js +28 -45
  78. package/frontend/build/assets/vendor_notistack.js +2 -2
  79. package/frontend/build/assets/vendor_qrcode.js +1 -1
  80. package/frontend/build/assets/vendor_rjsf.js +12 -3
  81. package/frontend/build/index.html +0 -1
  82. package/frontend/package-lock.json +208 -283
  83. package/frontend/package.json +4 -13
  84. package/npm-shrinkwrap.json +44 -44
  85. package/package.json +2 -3
  86. package/dist/cli.d.ts +0 -26
  87. package/dist/cli.d.ts.map +0 -1
  88. package/dist/cli.js.map +0 -1
  89. package/dist/cliEmitter.d.ts +0 -34
  90. package/dist/cliEmitter.d.ts.map +0 -1
  91. package/dist/cliEmitter.js.map +0 -1
  92. package/dist/clusters/export.d.ts +0 -2
  93. package/dist/clusters/export.d.ts.map +0 -1
  94. package/dist/clusters/export.js.map +0 -1
  95. package/dist/defaultConfigSchema.d.ts +0 -28
  96. package/dist/defaultConfigSchema.d.ts.map +0 -1
  97. package/dist/defaultConfigSchema.js.map +0 -1
  98. package/dist/deviceManager.d.ts +0 -112
  99. package/dist/deviceManager.d.ts.map +0 -1
  100. package/dist/deviceManager.js.map +0 -1
  101. package/dist/devices/airConditioner.d.ts +0 -98
  102. package/dist/devices/airConditioner.d.ts.map +0 -1
  103. package/dist/devices/airConditioner.js.map +0 -1
  104. package/dist/devices/batteryStorage.d.ts +0 -48
  105. package/dist/devices/batteryStorage.d.ts.map +0 -1
  106. package/dist/devices/batteryStorage.js.map +0 -1
  107. package/dist/devices/cooktop.d.ts +0 -60
  108. package/dist/devices/cooktop.d.ts.map +0 -1
  109. package/dist/devices/cooktop.js.map +0 -1
  110. package/dist/devices/dishwasher.d.ts +0 -71
  111. package/dist/devices/dishwasher.d.ts.map +0 -1
  112. package/dist/devices/dishwasher.js.map +0 -1
  113. package/dist/devices/evse.d.ts +0 -75
  114. package/dist/devices/evse.d.ts.map +0 -1
  115. package/dist/devices/evse.js.map +0 -1
  116. package/dist/devices/export.d.ts +0 -17
  117. package/dist/devices/export.d.ts.map +0 -1
  118. package/dist/devices/export.js.map +0 -1
  119. package/dist/devices/extractorHood.d.ts +0 -46
  120. package/dist/devices/extractorHood.d.ts.map +0 -1
  121. package/dist/devices/extractorHood.js.map +0 -1
  122. package/dist/devices/heatPump.d.ts +0 -47
  123. package/dist/devices/heatPump.d.ts.map +0 -1
  124. package/dist/devices/heatPump.js.map +0 -1
  125. package/dist/devices/laundryDryer.d.ts +0 -67
  126. package/dist/devices/laundryDryer.d.ts.map +0 -1
  127. package/dist/devices/laundryDryer.js.map +0 -1
  128. package/dist/devices/laundryWasher.d.ts +0 -81
  129. package/dist/devices/laundryWasher.d.ts.map +0 -1
  130. package/dist/devices/laundryWasher.js.map +0 -1
  131. package/dist/devices/microwaveOven.d.ts +0 -168
  132. package/dist/devices/microwaveOven.d.ts.map +0 -1
  133. package/dist/devices/microwaveOven.js.map +0 -1
  134. package/dist/devices/oven.d.ts +0 -105
  135. package/dist/devices/oven.d.ts.map +0 -1
  136. package/dist/devices/oven.js.map +0 -1
  137. package/dist/devices/refrigerator.d.ts +0 -118
  138. package/dist/devices/refrigerator.d.ts.map +0 -1
  139. package/dist/devices/refrigerator.js.map +0 -1
  140. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  141. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  142. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  143. package/dist/devices/solarPower.d.ts +0 -40
  144. package/dist/devices/solarPower.d.ts.map +0 -1
  145. package/dist/devices/solarPower.js.map +0 -1
  146. package/dist/devices/speaker.d.ts +0 -87
  147. package/dist/devices/speaker.d.ts.map +0 -1
  148. package/dist/devices/speaker.js.map +0 -1
  149. package/dist/devices/temperatureControl.d.ts +0 -166
  150. package/dist/devices/temperatureControl.d.ts.map +0 -1
  151. package/dist/devices/temperatureControl.js.map +0 -1
  152. package/dist/devices/waterHeater.d.ts +0 -111
  153. package/dist/devices/waterHeater.d.ts.map +0 -1
  154. package/dist/devices/waterHeater.js.map +0 -1
  155. package/dist/dgram/coap.d.ts +0 -205
  156. package/dist/dgram/coap.d.ts.map +0 -1
  157. package/dist/dgram/coap.js.map +0 -1
  158. package/dist/dgram/dgram.d.ts +0 -141
  159. package/dist/dgram/dgram.d.ts.map +0 -1
  160. package/dist/dgram/dgram.js.map +0 -1
  161. package/dist/dgram/mb_coap.d.ts +0 -24
  162. package/dist/dgram/mb_coap.d.ts.map +0 -1
  163. package/dist/dgram/mb_coap.js.map +0 -1
  164. package/dist/dgram/mb_mdns.d.ts +0 -24
  165. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  166. package/dist/dgram/mb_mdns.js.map +0 -1
  167. package/dist/dgram/mdns.d.ts +0 -290
  168. package/dist/dgram/mdns.d.ts.map +0 -1
  169. package/dist/dgram/mdns.js.map +0 -1
  170. package/dist/dgram/multicast.d.ts +0 -67
  171. package/dist/dgram/multicast.d.ts.map +0 -1
  172. package/dist/dgram/multicast.js.map +0 -1
  173. package/dist/dgram/unicast.d.ts +0 -56
  174. package/dist/dgram/unicast.d.ts.map +0 -1
  175. package/dist/dgram/unicast.js.map +0 -1
  176. package/dist/frontend.d.ts +0 -228
  177. package/dist/frontend.d.ts.map +0 -1
  178. package/dist/frontend.js.map +0 -1
  179. package/dist/frontendTypes.d.ts +0 -572
  180. package/dist/frontendTypes.d.ts.map +0 -1
  181. package/dist/frontendTypes.js.map +0 -1
  182. package/dist/globalMatterbridge.d.ts +0 -59
  183. package/dist/globalMatterbridge.d.ts.map +0 -1
  184. package/dist/globalMatterbridge.js.map +0 -1
  185. package/dist/helpers.d.ts +0 -48
  186. package/dist/helpers.d.ts.map +0 -1
  187. package/dist/helpers.js.map +0 -1
  188. package/dist/index.d.ts +0 -33
  189. package/dist/index.d.ts.map +0 -1
  190. package/dist/index.js.map +0 -1
  191. package/dist/logger/export.d.ts +0 -2
  192. package/dist/logger/export.d.ts.map +0 -1
  193. package/dist/logger/export.js.map +0 -1
  194. package/dist/matter/behaviors.d.ts +0 -2
  195. package/dist/matter/behaviors.d.ts.map +0 -1
  196. package/dist/matter/behaviors.js.map +0 -1
  197. package/dist/matter/clusters.d.ts +0 -2
  198. package/dist/matter/clusters.d.ts.map +0 -1
  199. package/dist/matter/clusters.js.map +0 -1
  200. package/dist/matter/devices.d.ts +0 -2
  201. package/dist/matter/devices.d.ts.map +0 -1
  202. package/dist/matter/devices.js.map +0 -1
  203. package/dist/matter/endpoints.d.ts +0 -2
  204. package/dist/matter/endpoints.d.ts.map +0 -1
  205. package/dist/matter/endpoints.js.map +0 -1
  206. package/dist/matter/export.d.ts +0 -5
  207. package/dist/matter/export.d.ts.map +0 -1
  208. package/dist/matter/export.js.map +0 -1
  209. package/dist/matter/types.d.ts +0 -3
  210. package/dist/matter/types.d.ts.map +0 -1
  211. package/dist/matter/types.js.map +0 -1
  212. package/dist/matterbridge.d.ts +0 -442
  213. package/dist/matterbridge.d.ts.map +0 -1
  214. package/dist/matterbridge.js.map +0 -1
  215. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  216. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  217. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  218. package/dist/matterbridgeBehaviors.d.ts +0 -1747
  219. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  220. package/dist/matterbridgeBehaviors.js.map +0 -1
  221. package/dist/matterbridgeDeviceTypes.d.ts +0 -761
  222. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  223. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  224. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  225. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  226. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  227. package/dist/matterbridgeEndpoint.d.ts +0 -1515
  228. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  229. package/dist/matterbridgeEndpoint.js.map +0 -1
  230. package/dist/matterbridgeEndpointHelpers.d.ts +0 -407
  231. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  232. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  233. package/dist/matterbridgePlatform.d.ts +0 -380
  234. package/dist/matterbridgePlatform.d.ts.map +0 -1
  235. package/dist/matterbridgePlatform.js.map +0 -1
  236. package/dist/matterbridgeTypes.d.ts +0 -190
  237. package/dist/matterbridgeTypes.d.ts.map +0 -1
  238. package/dist/matterbridgeTypes.js.map +0 -1
  239. package/dist/pluginManager.d.ts +0 -270
  240. package/dist/pluginManager.d.ts.map +0 -1
  241. package/dist/pluginManager.js.map +0 -1
  242. package/dist/shelly.d.ts +0 -174
  243. package/dist/shelly.d.ts.map +0 -1
  244. package/dist/shelly.js.map +0 -1
  245. package/dist/storage/export.d.ts +0 -2
  246. package/dist/storage/export.d.ts.map +0 -1
  247. package/dist/storage/export.js.map +0 -1
  248. package/dist/update.d.ts +0 -75
  249. package/dist/update.d.ts.map +0 -1
  250. package/dist/update.js.map +0 -1
  251. package/dist/utils/colorUtils.d.ts +0 -99
  252. package/dist/utils/colorUtils.d.ts.map +0 -1
  253. package/dist/utils/colorUtils.js.map +0 -1
  254. package/dist/utils/commandLine.d.ts +0 -59
  255. package/dist/utils/commandLine.d.ts.map +0 -1
  256. package/dist/utils/commandLine.js.map +0 -1
  257. package/dist/utils/copyDirectory.d.ts +0 -33
  258. package/dist/utils/copyDirectory.d.ts.map +0 -1
  259. package/dist/utils/copyDirectory.js.map +0 -1
  260. package/dist/utils/createDirectory.d.ts +0 -34
  261. package/dist/utils/createDirectory.d.ts.map +0 -1
  262. package/dist/utils/createDirectory.js.map +0 -1
  263. package/dist/utils/createZip.d.ts +0 -39
  264. package/dist/utils/createZip.d.ts.map +0 -1
  265. package/dist/utils/createZip.js.map +0 -1
  266. package/dist/utils/deepCopy.d.ts +0 -32
  267. package/dist/utils/deepCopy.d.ts.map +0 -1
  268. package/dist/utils/deepCopy.js.map +0 -1
  269. package/dist/utils/deepEqual.d.ts +0 -54
  270. package/dist/utils/deepEqual.d.ts.map +0 -1
  271. package/dist/utils/deepEqual.js.map +0 -1
  272. package/dist/utils/error.d.ts +0 -44
  273. package/dist/utils/error.d.ts.map +0 -1
  274. package/dist/utils/error.js.map +0 -1
  275. package/dist/utils/export.d.ts +0 -13
  276. package/dist/utils/export.d.ts.map +0 -1
  277. package/dist/utils/export.js.map +0 -1
  278. package/dist/utils/hex.d.ts +0 -89
  279. package/dist/utils/hex.d.ts.map +0 -1
  280. package/dist/utils/hex.js.map +0 -1
  281. package/dist/utils/isvalid.d.ts +0 -103
  282. package/dist/utils/isvalid.d.ts.map +0 -1
  283. package/dist/utils/isvalid.js.map +0 -1
  284. package/dist/utils/jestHelpers.d.ts +0 -137
  285. package/dist/utils/jestHelpers.d.ts.map +0 -1
  286. package/dist/utils/jestHelpers.js.map +0 -1
  287. package/dist/utils/network.d.ts +0 -84
  288. package/dist/utils/network.d.ts.map +0 -1
  289. package/dist/utils/network.js.map +0 -1
  290. package/dist/utils/spawn.d.ts +0 -33
  291. package/dist/utils/spawn.d.ts.map +0 -1
  292. package/dist/utils/spawn.js.map +0 -1
  293. package/dist/utils/wait.d.ts +0 -54
  294. package/dist/utils/wait.d.ts.map +0 -1
  295. package/dist/utils/wait.js.map +0 -1
  296. package/frontend/build/assets/vendor_react_table.js +0 -1
@@ -1,4 +1,4 @@
1
- import{B as e,y as o,S as lt,I as Xt,U as xr,V as br,X as Xe,Y as vr,Z as yr}from"./vendor_node_modules.js";import{u as jr,S as Cr}from"./vendor_notistack.js";import{D as De,a as Ne,b as Pe,B as ne,c as Z,A as Sr,I as J,C as wr,T as $,S as Mr,F as Zt,H as kr,d as er,e as _e,R as yt,P as qe,M as Ir,f as rt,g as F,L as K,h as re,i as dt,V as ct,j as $e,k as Nt,l as Dr,m as Nr,n as pe,o as Pr,p as Wr,q as jt,r as se,s as Fe,K as Ht,t as Rt,u as St,v as pt,w as it,x as ut,W as at,y as mt,z as gt,E as Le,G as $t,J as Ot,N as Tr,O as Fr,Q as st,U as Te,X as Je,Y as tr,Z as Lr,_ as Hr,$ as Rr,a0 as $r,a1 as rr,a2 as Ct,a3 as Or,a4 as Er,a5 as Vr,a6 as _r,a7 as Et,a8 as Ar,a9 as Ur,aa as zr,ab as qr,ac as Br,ad as Jr,ae as Qr,af as Vt,ag as Gr,ah as Kr,ai as Yr,aj as Xr,ak as Zr,al as eo,am as to,an as ro,ao as oo,ap as no,aq as io,ar as ao,as as so,at as lo,au as co,av as _t,aw as ot,ax as or,ay as Ie,az as nr,aA as wt,aB as Ae,aC as po,aD as uo}from"./vendor_mui.js";import{Q as mo}from"./vendor_qrcode.js";import{I as te,m as At,a as go,b as ho,c as Ut,d as fo,e as Tt,f as Ft,g as xo,h as bo,i as vo,j as yo,k as jo,l as Co,n as So,o as wo,p as zt,q as Mo,r as ko,s as Io,t as Do,u as No,v as Po,w as Wo,x as To,y as qt,z as Fo,A as Lo,B as Ho}from"./vendor_mdi.js";import{r as Ue}from"./vendor_react_table.js";import{F as Ro,v as $o,e as Oo,a as Eo,g as Vo,b as _o,c as Ao,d as Pt,A as Uo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const g of l)if(g.type==="childList")for(const b of g.addedNodes)b.tagName==="LINK"&&b.rel==="modulepreload"&&i(b)}).observe(document,{childList:!0,subtree:!0});function a(l){const g={};return l.integrity&&(g.integrity=l.integrity),l.referrerPolicy&&(g.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?g.credentials="include":l.crossOrigin==="anonymous"?g.credentials="omit":g.credentials="same-origin",g}function i(l){if(l.ep)return;l.ep=!0;const g=a(l);fetch(l.href,g)}})();/**
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,S as lt,I as Xt,U as xr,V as br,X as Xe,Y as vr,Z as yr}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 fe(r){return r.id>=0&&r.id<=101}function Ve(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function zo({open:r,title:c,message:a,onConfirm:i,onCancel:l}){const g=t=>{s&&console.log("Confirmed"),t.preventDefault(),i()},b=t=>{s&&console.log("Canceled"),t.preventDefault(),l()};return e.jsxs(De,{open:r,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Pe,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:a})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ne,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ne,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ht=[],nt=o.createContext(null);function qo({children:r}){const{enqueueSnackbar:c,closeSnackbar:a}=jr(),i=o.useCallback(f=>{s&&console.log(`UiProvider closeSnackbarMessage: message ${f}`);const k=ht.findIndex(R=>R.message===f);k!==-1&&(a(ht[k].key),ht.splice(k,1),s&&console.log(`UiProvider closeSnackbarMessage: message ${f} removed from persistMessages`))},[a]),l=o.useCallback((f,k,R)=>{s&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${k}`);const C=c(f,{variant:"default",autoHideDuration:k==null||k>0?(k??5)*1e3:null,persist:k===0,content:m=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Sr,{severity:R??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>a(m),action:e.jsx(J,{size:"small",onClick:()=>a(m),sx:{color:"#fff"},children:e.jsx(wr,{fontSize:"small"})}),children:f},m)},m)});k===0&&(s&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${k} - persist key ${C}`),ht.push({message:f,key:C}))},[c,a]),[g,b]=o.useState(!1),[t,d]=o.useState(""),[y,W]=o.useState(""),[h,L]=o.useState(""),V=o.useRef(null),M=o.useRef(null),O=()=>{s&&console.log(`UiProvider handle confirm action ${h}`),b(!1),V.current&&V.current(h)},u=()=>{s&&console.log(`UiProvider handle cancel action ${h}`),b(!1),M.current&&M.current(h)},z=o.useCallback((f,k,R,C,m)=>{s&&console.log(`UiProvider showConfirmCancelDialog for command ${R}`),d(f),W(k),L(R),V.current=C,M.current=m,b(!0)},[]),v=o.useMemo(()=>({showSnackbarMessage:l,closeSnackbarMessage:i,closeSnackbar:a,showConfirmCancelDialog:z}),[l,i,a,z]);return e.jsxs(nt.Provider,{value:v,children:[e.jsx(zo,{open:g,title:t,message:y,onConfirm:O,onCancel:u}),r]})}const ir=o.createContext(null),be=o.createContext(null);function Bo({children:r}){const[c,a]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,l]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[g,b]=o.useState([]),[t,d]=o.useState(1e3),[y,W]=o.useState(!0),[h,L]=o.useState(!1),{showSnackbarMessage:V,closeSnackbarMessage:M,closeSnackbar:O}=o.useContext(nt),u=o.useRef([]),z=o.useRef(null),v=o.useRef(1),f=o.useRef(Math.floor(Math.random()*999e3)+1e3),k=o.useRef(null),R=o.useRef(null),C=o.useRef(null),m=o.useRef(c),H=o.useRef(i),j=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),x=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),w=100,q=60,de=50,xe=300;o.useEffect(()=>{m.current=c},[c]),o.useEffect(()=>{H.current=i},[i]);const S=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),p=o.useCallback(N=>{if(z.current&&z.current.readyState===WebSocket.OPEN)try{N.id===void 0&&(N.id=f.current);const n=JSON.stringify(N);z.current.send(n),s&&console.log("WebSocket sent message:",N)}catch(n){s&&console.error(`WebSocket error sending message: ${n}`)}else s&&console.error("WebSocket message not sent, WebSocket not connected:",N)},[]),E=o.useCallback((N,n)=>{const T=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${N}</span>`;b(_=>[..._,T+' <span style="color: var(--main-log-color);">'+n+"</span>"])},[]),I=o.useCallback((N,n)=>{a(N),l(n),E("WebSocket",`Filtering by log level "${N}" and log search "${n}"`)},[E]),Y=o.useCallback(N=>{s&&console.log("WebSocket addListener:",N),u.current=[...u.current,N],s&&console.log("WebSocket addListener total listeners:",u.current.length)},[]),me=o.useCallback(N=>{s&&console.log("WebSocket removeListener:",N),u.current=u.current.filter(n=>n!==N),s&&console.log("WebSocket removeListener total listeners:",u.current.length)},[]),Me=o.useCallback(()=>{j===""||j===null||j===void 0||(E("WebSocket",`Connecting to WebSocket: ${j}`),z.current=new WebSocket(j),z.current.onmessage=N=>{h||L(!0);try{const n=JSON.parse(N.data);if(n.id===void 0)return;if(n.error&&s&&console.error("WebSocket error message:",n),n.id===f.current&&n.src==="Matterbridge"&&n.dst==="Frontend"&&n.response==="pong"){s&&console.log("WebSocket pong response message:",n,"listeners:",u.current.length),R.current&&clearTimeout(R.current),u.current.forEach(_=>_(n));return}if(n.id===we.RefreshRequired){s&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.RestartRequired){s&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.RestartNotRequired){s&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.CpuUpdate){s&&console.log("WebSocket WS_ID_CPU_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.MemoryUpdate){s&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.UptimeUpdate){s&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.Snackbar&&n.params&&n.params.message){s&&console.log("WebSocket WS_ID_SNACKBAR message:",n,"listeners:",u.current.length),V(n.params.message,n.params.timeout,n.params.severity);return}else if(n.id===we.CloseSnackbar&&n.params&&n.params.message){s&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",n,"listeners:",u.current.length),M(n.params.message);return}else if(n.id===we.ShellySysUpdate){s&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.ShellyMainUpdate){s&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id!==we.Log){s&&console.log("WebSocket message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}if(!n.params||!n.params.level||!n.params.time||!n.params.name||!n.params.message||["debug","info","notice","warn","error","fatal"].includes(n.params.level)&&(m.current==="info"&&n.params.level==="debug"||m.current==="notice"&&(n.params.level==="debug"||n.params.level==="info")||m.current==="warn"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice")||m.current==="error"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice"||n.params.level==="warn")||m.current==="fatal"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice"||n.params.level==="warn"||n.params.level==="error"))||H.current!=="*"&&H.current!==""&&!n.params.message.toLowerCase().includes(H.current.toLowerCase())&&!n.params.name.toLowerCase().includes(H.current.toLowerCase())||n.params.name==="Commissioning"&&n.params.message.includes("is uncommissioned"))return;b(_=>{const ae=`<span style="color: #505050;">[${n.params?.time}]</span>`,ce=ve=>{switch(ve?.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"}},B=ve=>{switch(ve?.toLowerCase()){case"warn":return"black";default:return"white"}},ge=`${`<span style="background-color: ${ce(n.params?.level)}; color: ${B(n.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${n.params?.level}</span>`} ${ae} <span style="color: #09516d;">[${n.params?.name}]</span> <span style="color: var(--main-log-color);">${n.params?.message}</span>`,oe=[..._,ge];return oe.length>t?oe.slice(t/10):oe})}catch(n){console.error(`WebSocketUse error parsing message: ${n}`)}},z.current.onopen=()=>{s&&console.log(`WebSocket: Connected to WebSocket: ${j}`),E("WebSocket",`Connected to WebSocket: ${j}`),L(!0),O(),v.current=1,C.current=setTimeout(()=>{k.current=setInterval(()=>{p({id:f.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{s&&console.error(`WebSocketUse: No pong response received from WebSocket: ${j}`),E("WebSocket",`No pong response received from WebSocket: ${j}`),L(!1)},1e3*de)},1e3*q)},1e3*xe)},z.current.onclose=()=>{s&&console.error(`WebSocket: Disconnected from WebSocket ${x?"with Ingress":""}: ${j}`),E("WebSocket",`Disconnected from WebSocket: ${j}`),L(!1),O(),C.current&&clearTimeout(C.current),R.current&&clearTimeout(R.current),k.current&&clearInterval(k.current),E("WebSocket",`Reconnecting (attempt ${v.current} of ${w}) to WebSocket${x?" (Ingress)":""}: ${j}`),x?setTimeout(U,5e3):v.current===1?U():v.current<w?setTimeout(U,1e3*v.current):E("WebSocket",`Reconnect attempts exceeded limit of ${w} retries, refresh the page to reconnect to: ${j}`),v.current=v.current+1},z.current.onerror=N=>{s&&console.error(`WebSocket: WebSocket error connecting to ${j}:`,N),E("WebSocket",`WebSocket error connecting to ${j}`)})},[j]),U=o.useCallback(()=>{s&&console.log(`WebSocket attemptReconnect ${v.current}/${w} to:`,j),Me()},[Me]);o.useEffect(()=>(Me(),()=>{z.current&&z.current.readyState===WebSocket.OPEN&&z.current.close()}),[Me]);const D=o.useMemo(()=>({messages:g,maxMessages:t,autoScroll:y,setMessages:b,setLogFilters:I,setMaxMessages:d,setAutoScroll:W}),[g,b,I]),P=o.useMemo(()=>({maxMessages:t,autoScroll:y,logFilterLevel:c,logFilterSearch:i,setMessages:b,setLogFilters:I,setMaxMessages:d,setAutoScroll:W,online:h,retry:v.current,getUniqueId:S,addListener:Y,removeListener:me,sendMessage:p,logMessage:E}),[t,y,b,I,d,W,h,v.current,Y,me,p,E]);return e.jsx(ir.Provider,{value:D,children:e.jsx(be.Provider,{value:P,children:r})})}function Jo(){const{showSnackbarMessage:r,showConfirmCancelDialog:c}=o.useContext(nt),{online:a,sendMessage:i,logMessage:l,addListener:g,removeListener:b,getUniqueId:t}=o.useContext(be),[d,y]=o.useState(!1),[W,h]=o.useState(!1),[L,V]=o.useState(!1),[M,O]=o.useState(!1),[u,z]=o.useState(null),v=o.useRef(t()),[f,k]=o.useState(null),[R,C]=o.useState(null),[m,H]=o.useState(null),[j,x]=o.useState(null),[w,q]=o.useState(null),de=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},S=()=>{u?.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")},p=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},E=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},I=()=>{i({id:v.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},Y=()=>{i({id:v.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},me=()=>{i({id:v.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Me=()=>{s&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),i({id:v.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},U=()=>{s&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),i({id:v.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{s&&console.log("Header: handleShellyCreateSystemLog"),i({id:v.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{s&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},N=()=>{u?.matterbridgeInformation.restartMode===""?i({id:v.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):i({id:v.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},n=()=>{i({id:v.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{i({id:v.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},_=()=>{i({id:v.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{i({id:v.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=Q=>{k(Q.currentTarget)},B=Q=>{s&&console.log("Header: handleMenuClose",Q),k(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"?I():Q==="updatedev"?Y():Q==="updatecheck"?me():Q==="shelly-sys-update"?Me():Q==="shelly-main-update"?U():Q==="shelly-create-system-log"?D():Q==="shelly-download-system-log"?P():Q==="softreset"?_():Q==="hardreset"?ae():Q==="restart"?N():Q==="shutdown"?n():Q==="reboot"?T():Q==="create-backup"?i({id:v.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?i({id:v.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?i({id:v.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&i({id:v.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=Q=>{s&&console.log("Header: handleMenuCloseCancel:",Q),k(null)},ge=Q=>{C(Q.currentTarget)},oe=()=>{C(null)},ve=Q=>{H(Q.currentTarget)},ie=()=>{H(null)},he=Q=>{x(Q.currentTarget)},X=()=>{x(null)},ue=Q=>{q(Q.currentTarget)},ye=()=>{q(null)},Ge=()=>{ei(),s&&console.log("Matterbridge logo clicked: debug is now",s)};return o.useEffect(()=>{const Q=ee=>{ee.src==="Matterbridge"&&ee.dst==="Frontend"&&(Ve(ee)&&ee.method==="/api/settings"&&ee.id===v.current&&(s&&console.log("Header received settings:",ee.response),z(ee.response),y(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),h(ee.response.matterbridgeInformation.fixedRestartRequired),V(ee.response.matterbridgeInformation.updateRequired)),fe(ee)&&ee.method==="refresh_required"&&ee.params.changed==="settings"&&(s&&console.log(`Header received refresh_required: changed=${ee.params.changed} and sending /api/settings request`),i({id:v.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),fe(ee)&&ee.method==="restart_required"&&(s&&console.log(`Header received restart_required with fixed: ${ee.params.fixed}`),y(!0),ee.params.fixed===!0&&h(!0)),fe(ee)&&ee.method==="restart_not_required"&&(s&&console.log("Header received restart_not_required"),y(!1)),fe(ee)&&ee.method==="update_required"&&(s&&console.log("Header received update_required"),V(!0)),fe(ee)&&ee.method==="update_required_dev"&&(s&&console.log("Header received update_required_dev"),O(!0)),fe(ee)&&ee.id===we.ShellySysUpdate&&(s&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),z(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellySysUpdate:ee.params.available},systemInformation:We.systemInformation}:null)),fe(ee)&&ee.id===we.ShellyMainUpdate&&(s&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),z(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellyMainUpdate:ee.params.available},systemInformation:We.systemInformation}:null)))};return g(Q),s&&console.log(`Header added WebSocket listener id ${v.current}`),()=>{b(Q),s&&console.log("Header removed WebSocket listener")}},[g,b,i,r]),o.useEffect(()=>{a&&(s&&console.log("Header sending /api/settings requests"),i({id:v.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),s&&console.log("Header rendering..."),!a||!u?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ge}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(lt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!u.matterbridgeInformation.readOnly&&L&&e.jsx($,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:I,children:["Update to v.",u.matterbridgeInformation.matterbridgeLatestVersion]})}),!u.matterbridgeInformation.readOnly&&M&&e.jsx($,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:Y,children:["Update to new dev v.",u.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!u.matterbridgeInformation.readOnly&&e.jsx($,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:S,children:["v.",u.matterbridgeInformation.matterbridgeVersion]})}),u.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),u.matterbridgeInformation.bridgeMode!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.bridgeMode})}):null,u.matterbridgeInformation.restartMode!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.restartMode})}):null,u.matterbridgeInformation.profile&&u.matterbridgeInformation.profile!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[u.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:p})}):null,u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Give a star to Matterbridge",children:e.jsx(J,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:E,children:e.jsx(Mr,{})})}):null,u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Sponsor Matterbridge",children:e.jsx(J,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:de,children:e.jsx(Zt,{})})}):null,e.jsx($,{title:"Matterbridge help",children:e.jsx(J,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(kr,{})})}),e.jsx($,{title:"Matterbridge changelog",children:e.jsx(J,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:S,children:e.jsx(er,{})})}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsx($,{title:"Update matterbridge to latest version",children:e.jsx(J,{style:{color:L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:I,children:e.jsx(_e,{})})}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellySysUpdate&&e.jsx($,{title:"Shelly system update",children:e.jsx(J,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Me,children:e.jsx(_e,{})})}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellyMainUpdate&&e.jsx($,{title:"Shelly software update",children:e.jsx(J,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(_e,{})})}),e.jsx($,{title:"Restart matterbridge",children:e.jsx(J,{style:{color:d||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:N,children:e.jsx(yt,{})})}),u.matterbridgeInformation.restartMode===""?e.jsx($,{title:"Shut down matterbridge",children:e.jsx(J,{style:{color:d||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:n,children:e.jsx(qe,{})})}):null,e.jsx($,{title:"Download, backup and more",children:e.jsx(J,{onClick:ce,children:e.jsx(Ir,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(rt,{id:"command-menu",anchorEl:f,keepMounted:!0,open:!!f,onClose:()=>B(""),children:[u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("updatedev"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("updatecheck"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellySysUpdate&&e.jsxs(F,{onClick:()=>B("shelly-sys-update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellyMainUpdate&&e.jsxs(F,{onClick:()=>B("shelly-main-update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>B("restart"),children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation.restartMode===""?e.jsxs(F,{onClick:()=>B("shutdown"),children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",B,le)},children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ve,children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-view",anchorEl:m,keepMounted:!0,open:!!m,onClose:ie,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("view-mblog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("view-mjlog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("view-shellylog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:he,children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-download",anchorEl:j,keepMounted:!0,open:!!j,onClose:X,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("download-mbstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-pluginstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-pluginconfig"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mblog"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mjstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mjlog"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("shelly-create-system-log"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("shelly-download-system-log"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ge,children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-backup",anchorEl:R,keepMounted:!0,open:!!R,onClose:oe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("create-backup"),oe()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-backup"),oe()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ue,children:[e.jsx(K,{children:e.jsx(Dr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-reset",anchorEl:w,keepMounted:!0,open:!!w,onClose:ye,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{ye(),c("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{ye(),c("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>{ye(),c("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{ye(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{ye(),c("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Qo=o.memo(Jo),Go=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(s&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(s&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Ko(){const{messages:r,autoScroll:c}=o.useContext(ir),[a,i]=o.useState(!1),l=o.useRef(null),g=o.useMemo(()=>Go(),[]),b=d=>i(!0),t=d=>i(!1);return o.useEffect(()=>{s&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${a}`),c&&!a&&!g&&l.current?.scrollIntoView({behavior:"smooth"})},[r,a,c,g]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:b,onMouseLeave:t,children:[r.map((d,y)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:d}},y)),e.jsx("div",{ref:l})]})})}const ar=o.memo(Ko);function Qe(){const{retry:r}=o.useContext(be),c=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:r<100?e.jsxs(e.Fragment,{children:[e.jsx(Nr,{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(ne,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Yo({value:r,maxChars:c}){let a=r;if(r.length>c&&c>3){const i=c-3,l=r.substring(0,Math.ceil(i/2)),g=r.substring(r.length-Math.floor(i/2),r.length);a=`${l} … ${g}`}return r!==a?e.jsx($,{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 Xo({systemInfo:r,compact:c}){const[a,i]=o.useState(r),{sendMessage:l,addListener:g,removeListener:b}=o.useContext(be);if(s&&console.log("SystemInfoTable:",a,"compact:",c),r&&c&&a.totalMemory&&a.freeMemory){const t=a.totalMemory,d=a.freeMemory;a.freeMemory=`${d} / ${t}`,a.totalMemory=""}if(r&&c&&a.heapTotal&&a.heapUsed){const t=a.heapTotal,d=a.heapUsed;a.heapUsed=`${d} / ${t}`,a.heapTotal=""}if(r&&c&&a.osRelease&&a.osType){const t=a.osType,d=a.osRelease;a.osType=`${t} (${d})`,a.osRelease=""}if(r&&c&&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"&&(fe(d)&&d.method==="memory_update"&&d.params&&d.params.totalMemory&&d.params.freeMemory&&d.params.heapTotal&&d.params.heapUsed&&d.params.rss&&(s&&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(y=>({...y,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:""}))),fe(d)&&d.method==="cpu_update"&&d.params&&d.params.cpuUsage&&(s&&console.log("SystemInfoTable received cpu_update",d),a.cpuUsage!==(d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":"")&&i(y=>({...y,cpuUsage:d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":""}))),fe(d)&&d.method==="uptime_update"&&d.params&&d.params.systemUptime&&d.params.processUptime&&(s&&console.log("SystemInfoTable received uptime_update",d),(a.systemUptime!==d.params?.systemUptime||a.processUptime!==d.params?.processUptime)&&i(y=>({...y,systemUptime:d.params?.systemUptime?d.params.systemUptime:"",processUptime:d.params?.processUptime?d.params.processUptime:""}))))};return s&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),g(t),s&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),b(t),s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[g,a.cpuUsage,a.freeMemory,a.heapTotal,a.heapUsed,a.processUptime,a.rss,a.systemUptime,a.totalMemory,b,l]),a?(s&&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],y)=>e.jsxs("tr",{className:y%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:t}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Yo,{value:typeof d!="string"?d.toString():d,maxChars:25})})]},t))})})})]})):null}const Zo=o.memo(Xo),Bt={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"}},en=r=>{if(!r)return"";const c=r.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const a=c.slice(0,4),i=c.slice(4,7),l=c.slice(7,11);return[a,i,l].filter(Boolean).join("-")};function tn({id:r}){const{online:c,sendMessage:a,addListener:i,removeListener:l,getUniqueId:g}=o.useContext(be),[b,t]=o.useState(null),[d,y]=o.useState(null),W=o.useRef(null),h=o.useRef(g()),{showConfirmCancelDialog:L}=o.useContext(nt);o.useEffect(()=>{s&&console.log(`QRDiv received storeId update "${r}"`),r&&(s&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const v=f=>{f.src==="Matterbridge"&&f.dst==="Frontend"&&fe(f)&&f.id===we.RefreshRequired&&f.params.changed==="matter"&&f.params.matter&&(s&&console.log(`QRDiv received refresh_required: changed=${f.params.changed} for storeId "${f.params.matter.id}":`,f.params.matter),b===f.params.matter.id&&(s&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${f.params.matter.id}":`,f.params.matter),W.current&&clearTimeout(W.current),f.params.matter.advertising&&f.params.matter.advertiseTime&&f.params.matter.advertiseTime+9e5<=Date.now()&&(f.params.matter.advertising=!1),y(f.params.matter),f.params.matter.advertising&&(s&&console.log(`QRDiv setting matter advertise timeout for storeId "${f.params.matter.id}":`,f.params.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),s&&console.log(`QRDiv clearing advertising state for storeId "${b}" after 15 minutes`),y(k=>k&&{...k,advertising:!1})},f.params.matter.advertiseTime+9e5-Date.now()))))};return i(v),s&&console.log("QRDiv webSocket effect mounted"),()=>{l(v),W.current&&clearTimeout(W.current),s&&console.log("QRDiv webSocket effect unmounted")}},[b]);const V=()=>{s&&console.log(`QRDiv sent matter startCommission for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,startCommission:!0}})},M=()=>{s&&console.log(`QRDiv sent matter stopCommission for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,stopCommission:!0}})},O=()=>{s&&console.log(`QRDiv sent matter advertise for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,advertise:!0}})},u=v=>{s&&console.log(`QRDiv sent matter removeFabric for node "${d?.id}" and fabricIndex ${v}`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,removeFabric:v}})},z=async()=>{if(!d||!d.manualPairingCode)return;const v=d.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(v);else{const f=document.createElement("textarea");f.value=v,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.focus(),f.select(),document.execCommand("copy"),document.body.removeChild(f)}s&&console.log("Manual pairing code copied to clipboard")}catch(f){console.error("Failed to copy manual pairing code",f)}};return!d||!c?(s&&console.log("QRDiv rendering undefined state"),null):d.online?d.advertising&&d.qrPairingCode&&d.manualPairingCode?(s&&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(J,{"aria-label":"send advertising",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})}),e.jsx(J,{"aria-label":"stop pairing",size:"small",onClick:M,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn off pairing",arrow:!0,children:e.jsx(te,{path:go,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:b}),e.jsx(mo,{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: ",en(d.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx($,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(J,{"aria-label":"copy manual pairing code",size:"small",onClick:z,sx:Bt,children:e.jsx(te,{path:ho,size:.85})})})})]})]})):d.commissioned&&d.fabricInformations&&d.sessionInformations?(s&&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(J,{"aria-label":"send advertising",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})}),e.jsx(J,{"aria-label":"start pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn on pairing",arrow:!0,children:e.jsx(te,{path:Ut,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:b}),d.fabricInformations.map((v,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: ",v.fabricIndex]}),e.jsx($,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(J,{"aria-label":"remove the fabric",size:"small",onClick:()=>L("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>u(v.fabricIndex),()=>{}),sx:{...Bt,padding:"2px"},children:e.jsx(te,{path:fo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",v.rootVendorId," ",v.rootVendorName]}),v.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",v.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",d.sessionInformations?d.sessionInformations.filter(k=>k.fabric?.fabricIndex===v.fabricIndex&&k.isPeerActive===!0).length:"0"," ","subscriptions: ",d.sessionInformations?d.sessionInformations.filter(k=>k.fabric?.fabricIndex===v.fabricIndex&&k.isPeerActive===!0&&k.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?(s&&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:b}),e.jsx(ne,{onClick:V,endIcon:e.jsx(te,{path:Ut,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]})})]})):(s&&console.log("QRDiv rendering unknown state"),null):(s&&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:b}),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 rn=o.memo(tn);function on(){const{logMessage:r,sendMessage:c,getUniqueId:a}=o.useContext(be),[i,l]=o.useState("matterbridge-"),[g,b]=o.useState(!1),[t,d]=o.useState(null),y=o.useRef(a()),W=f=>{f.preventDefault(),b(!0)},h=()=>{b(!1)},L=f=>{f.preventDefault(),b(!1);const k=f.dataTransfer.files[0];if(k){r("Plugins",`Installing package ${k.name}. Please wait...`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(C=>C.text()).then(C=>{r("Plugins",`Server response: ${C}`)}).catch(C=>{console.error("Error uploading plugin file:",C),r("Plugins",`Error installing package ${C}`)})}},V=f=>{const k=f.target.files&&f.target.files[0];if(k){r("Plugins",`Uploading package ${k.name}`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(C=>C.text()).then(C=>{r("Plugins",`Server response: ${C}`)}).catch(C=>{console.error("Error uploading plugin file:",C),r("Plugins",`Error uploading package ${C}`)})}},M=()=>{c({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},O=()=>{document.getElementById("file-upload")?.click()},u=()=>{c({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},z=f=>{d(f.currentTarget)},v=f=>{f!==""&&l(f),d(null)};return s&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:W,onDragLeave:h,onDrop:L,children:[e.jsx(pe,{value:i,onChange:f=>{l(f.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(J,{onClick:z,children:e.jsx(Pr,{})}),e.jsxs(rt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>v(""),children:[e.jsx(F,{onClick:()=>v("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(F,{onClick:()=>v("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(F,{onClick:()=>v("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(F,{onClick:()=>v("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(F,{onClick:()=>v("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(F,{onClick:()=>v("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(F,{onClick:()=>v("matterbridge-test"),children:"matterbridge-test"}),e.jsx(F,{onClick:()=>v("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(F,{onClick:()=>v("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx($,{title:"Install or update a plugin from npm",children:e.jsx(ne,{onClick:M,endIcon:e.jsx($e,{}),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(ne,{onClick:O,endIcon:e.jsx(Wr,{}),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(ne,{onClick:u,endIcon:e.jsx(jt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Add"})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:V})]})}const nn=o.memo(on);function Ze({status:r,enabledText:c="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:l}){if(r===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const g=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:r?c:a??c});return i!==void 0?e.jsx($,{title:i,children:g}):g}}const et={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},tt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},an={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},sn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ee={padding:"0px",margin:"0px"},ln="5px 10px 5px 10px",ft={},Ce={},xt={},bt={};let vt=[],Jt=[];const dn=({open:r,onClose:c,plugin:a})=>{const{sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),t=o.useRef(b()),[d,y]=o.useState(a.configJson),[W,h]=o.useState(a.schemaJson),[L,V]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[M,O]=o.useState("");let u={};o.useEffect(()=>{const D=P=>{P.src==="Matterbridge"&&P.dst==="Frontend"&&(P.id===t.current&&P.method==="/api/select/devices"&&(P.response&&(vt=P.response),P.error&&console.error("ConfigPluginDialog received /api/select/devices error:",P.error)),P.id===t.current&&P.method==="/api/select/entities"&&(P.response&&(Jt=P.response),P.error&&console.error("ConfigPluginDialog received /api/select/entities error:",P.error)))};return l(D),d!==void 0&&W!==void 0&&(Object.keys(W.properties).forEach(P=>{Object.keys(W.properties[P]).forEach(N=>{N.startsWith("ui:")&&(L[P]={},L[P][N]=W.properties[P][N],delete W.properties[P][N])})}),V(L)),a.name!==void 0&&a.configJson!==void 0&&a.schemaJson!==void 0&&(y(a.configJson),h(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}})),()=>{g(D)}},[l,d,a,g,W,i,L]);const z=({formData:D})=>{u=D},v=({formData:D})=>{y(D),a.configJson=D,a.restartRequired=!0,i({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:D.name,formData:D}}),c()};function f(D){const{id:P,label:N,onKeyChange:n,onDropPropertyClick:T,disabled:_,schema:ae,children:ce,registry:B,readonly:le,required:ge}=D,{templates:oe}=B,{RemoveButton:ve}=oe.ButtonTemplates;if(!(Uo in ae))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const he=({target:X})=>n(X&&X.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${P}-key`,name:`${P}-key`,required:ge,disabled:_||le,defaultValue:N,onBlur:le?void 0:he,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:ce}),e.jsx(ve,{disabled:_||le,onClick:T(N)})]})}function k(D){const{children:P,description:N,displayLabel:n,errors:T,help:_,hidden:ae,_id:ce,_label:B,registry:le,uiSchema:ge}=D,oe=_o(ge),ve=Ao("WrapIfAdditionalTemplate",le,oe);return ae?e.jsx("div",{style:{display:"none"},children:P}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(ve,{...D,children:[n===!0&&N,P,T,_]})})}function R(D){const{description:P}=D;return P?e.jsx(se,{sx:tt,children:P}):null}function C(D){const{required:P,title:N}=D;return N?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(se,{sx:et,children:["Title ",N," ",P&&e.jsx("mark",{children:"***"})]})}):null}function m(D){const{help:P,_idSchema:N}=D;return P?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(se,{sx:an,children:P})}):null}function H(D){const{errors:P}=D;return P?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(se,{color:"error",sx:sn,children:"Please fix the following errors:"}),e.jsx(it,{children:P.map((N,n)=>e.jsxs(Tr,{children:[e.jsx(K,{children:e.jsx(Fr,{color:"error"})}),e.jsx(re,{primary:N.stack})]},n))})]}):null}function j(D){const{errors:P}=D;return P?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:P.map((N,n)=>e.jsxs(se,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",N]},n))}):null}function x(D){const{id:P,name:N,_schema:n,_uiSchema:T,value:_,options:ae,label:ce,type:B,placeholder:le,required:ge,disabled:oe,readonly:ve,autofocus:ie,onChange:he,onChangeOverride:X,onBlur:ue,onFocus:ye,_rawErrors:Ge,_hideError:Q,_registry:ee,_formContext:We}=D,He=({target:{value:je}})=>he(je===""?ae.emptyValue:je),Re=({target:je})=>ue(P,je&&je.value),ze=({target:je})=>ye(P,je&&je.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:P,name:P,label:le&&le!==""?ce:void 0,variant:"outlined",placeholder:le&&le!==""?le:ce,required:ge,disabled:oe||ve,autoFocus:ie,value:_||_===0?_:"",type:B,autoComplete:B==="password"?"current-password":N,onChange:X||He,onBlur:Re,onFocus:ze,fullWidth:!0})})}function w(D){return console.log("ArrayFieldTitleTemplate:",D),null}function q(D){return console.log("ArrayFieldDescriptionTemplate:",D),null}function de(D){return console.log("ArrayFieldItemTemplate:",D),null}function xe(D){const{canAdd:P,_className:N,_disabled:n,_formContext:T,_formData:_,_idSchema:ae,_items:ce,onAddClick:B,_rawErrors:le,_readonly:ge,_registry:oe,_required:ve,schema:ie,title:he,_uiSchema:X}=D,[ue,ye]=o.useState(!1),[Ge,Q]=o.useState(!1),[ee,We]=o.useState(!1),[He,Re]=o.useState(""),ze=A=>{Re(A.target.value)},je=()=>{ye(!ue)},Ke=()=>{Q(!Ge)},Ye=()=>{We(!ee)},Mt=A=>{ye(!1),ie.selectFrom==="serial"?ie.items.default=A.serial:ie.selectFrom==="name"&&(ie.items.default=A.name),B()},kt=A=>{Q(!1),ie.selectEntityFrom==="name"?ie.items.default=A.name:ie.selectEntityFrom==="description"&&(ie.items.default=A.description),B()},It=A=>{We(!1),ie.selectDeviceEntityFrom==="name"?ie.items.default=A.name:ie.selectDeviceEntityFrom==="description"&&(ie.items.default=A.description),B()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[he&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[he&&e.jsx(se,{sx:et,children:he}),P&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(J,{onClick:je,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ie.selectEntityFrom&&e.jsx($,{title:"Add an entity from the list",children:e.jsx(J,{onClick:Ke,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ie.selectDeviceEntityFrom&&e.jsx($,{title:"Add a device entity from the list",children:e.jsx(J,{onClick:Ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(J,{onClick:B,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),ie.description&&e.jsx(se,{sx:tt,children:ie.description}),D.items.map(A=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(J,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ee,children:e.jsx(Rt,{})}),e.jsx(J,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ht,{})}),e.jsx(J,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ee,children:e.jsx(St,{})})]},A.index)),e.jsxs(De,{open:ue,onClose:je,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:He,onChange:ze,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial.toLowerCase().includes(He.toLowerCase())||A.name.toLowerCase().includes(He.toLowerCase())).map((A,ke)=>e.jsxs(ut,{onClick:()=>Mt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ke))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:je,children:"Close"})})]}),e.jsxs(De,{open:Ge,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:He,onChange:ze,placeholder:"Enter name or description"})]}),e.jsx(it,{dense:!0,children:Jt.filter(A=>A.name.toLowerCase().includes(He.toLowerCase())||A.description.toLowerCase().includes(He.toLowerCase())).map((A,ke)=>e.jsxs(ut,{onClick:()=>kt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),A.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:Ce})}),A.icon==="matter"&&e.jsx(K,{children:e.jsx(Ot,{style:Ce})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ke))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:Ke,children:"Close"})})]}),e.jsxs(De,{open:ee,onClose:Ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",he]}),e.jsx(Pe,{children:e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial===he||A.name===he).map(A=>A.entities?.map((ke,Dt)=>e.jsxs(ut,{onClick:()=>It(ke),sx:ft,children:[ke.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),ke.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),ke.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),ke.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:Ce})}),ke.icon==="matter"&&e.jsx(K,{children:e.jsx(Ot,{style:Ce})}),e.jsx(re,{primary:ke.name,secondary:ke.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Dt)))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:Ye,children:"Close"})})]})]})}function S(D){const{onAddClick:P,schema:N,properties:n,title:T,description:_}=D,[ae,ce]=o.useState(!1),[B,le]=o.useState(""),ge=X=>{le(X.target.value)},oe=()=>{ce(!ae)},ve=X=>{ce(!1);let ue="";N.selectFrom==="serial"?ue=X.serial:N.selectFrom==="name"&&(ue=X.name),O(ue),P(N)()},ie=()=>{P(N)()},he=!N.additionalProperties;return!he&&M!==""&&n.forEach(X=>{if(X.name==="newKey"&&X.content.key==="newKey"&&X.content.props.name==="newKey"&&X.content.props.onKeyChange&&M!==""){const ue=M;O(""),X.content.props.onKeyChange(ue)}}),e.jsxs(Z,{sx:{margin:"0px",padding:he?"10px":"5px 10px 0px 10px",border:he?"none":"1px solid grey"},children:[N.title&&he&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:et,children:N.title})}),T&&!he&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(se,{sx:et,children:T}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[N.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(J,{onClick:oe,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(J,{onClick:ie,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),N.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:tt,children:N.description})}),n.map(({content:X,name:ue,hidden:ye})=>!ye&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(N.properties[ue].type)?"0px":ln,border:["object","array","boolean"].includes(N.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(N.properties[ue].type)&&e.jsx(se,{sx:et,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:X})]},ue)),e.jsxs(De,{open:ae,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:B,onChange:ge,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(X=>X.serial.toLowerCase().includes(B.toLowerCase())||X.name.toLowerCase().includes(B.toLowerCase())).map((X,ue)=>e.jsxs(ut,{onClick:()=>ve(X),sx:ft,children:[X.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),X.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),X.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),e.jsx(re,{primary:X.name,secondary:X.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ue))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:oe,children:"Close"})})]})]})}function p(D){const{uiSchema:P}=D,{submitText:N,norender:n}=Vo(P);return n?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ne,{type:"submit",variant:"contained",color:"primary",children:N}),e.jsx(ne,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function E(D){const{className:P,disabled:N,onClick:n,registry:T,style:_,uiSchema:ae,...ce}=D;return e.jsx($,{title:"Remove the item",children:e.jsx(J,{disabled:N,size:"small",color:"primary",onClick:n,children:e.jsx(St,{})})})}function I(D){const{className:P,disabled:N,onClick:n,registry:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Add an item",children:e.jsx(J,{size:"small",color:"primary",onClick:n,children:e.jsx(jt,{})})})}function Y(D){const{disabled:P,onClick:N,registry:n,style:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Move up the item",children:e.jsx(J,{size:"small",color:"primary",onClick:N,children:e.jsx(Rt,{})})})}function me(D){const{disabled:P,onClick:N,registry:n,style:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Move down the item",children:e.jsx(J,{size:"small",color:"primary",onClick:N,children:e.jsx(Ht,{})})})}function Me(D){const{id:P,name:N,value:n,schema:T,readonly:_,onChange:ae}=D,[ce,B]=o.useState(void 0),le=oe=>{B(oe&&oe!==""?oe:void 0)},ge=()=>{i({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:N,value:ce,formData:u,id:P}}),T.buttonClose===!0?c():T.buttonSave===!0&&v({formData:d})};return T.buttonText&&T.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:tt,children:T.description}),e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>ge(),children:T.buttonText})]}):T.buttonField&&T.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(se,{sx:tt,children:T.description}),e.jsx(pe,{id:N+"-input",name:N,label:T.textLabel,placeholder:T.textPlaceholder,onChange:oe=>le(oe.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ne,{id:N+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>ge(),children:T.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[N&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(se,{sx:et,children:N}),e.jsx(Fe,{checked:n,readOnly:_,onChange:()=>ae(!n),sx:{padding:"0px",margin:"0px"}})]}),T.description&&e.jsx(se,{sx:tt,children:T.description})]})}function U({schema:D,id:P,name:N,options:n,label:T,hideLabel:_,required:ae,disabled:ce,placeholder:B,readonly:le,value:ge,multiple:oe,autofocus:ve,onChange:ie,onBlur:he,onFocus:X,errorSchema:ue,rawErrors:ye=[],registry:Ge,uiSchema:Q,hideError:ee,formContext:We,...He}){const{enumOptions:Re,enumDisabled:ze,emptyValue:je}=n;oe=typeof oe>"u"?!1:!!oe;const Ke=oe?[]:"",Ye=typeof ge>"u"||oe&&ge.length<1||!oe&&ge===Ke,Mt=({target:{value:Oe}})=>ie(Pt(Oe,Re,je)),kt=({target:Oe})=>he(P,Pt(Oe&&Oe.value,Re,je)),It=({target:Oe})=>X(P,Pt(Oe&&Oe.value,Re,je)),A=Oo(ge,Re,oe),{InputLabelProps:ke,SelectProps:Dt,autocomplete:ur,...mr}=He,gr=!oe&&D.default===void 0;return e.jsxs(pe,{id:P,name:P,value:!Ye&&typeof A<"u"?A:Ke,required:ae,disabled:ce||le,autoFocus:ve,autoComplete:ur,placeholder:B,error:ye.length>0,onChange:Mt,onBlur:kt,onFocus:It,...mr,select:!0,InputLabelProps:{...ke,shrink:!Ye},SelectProps:{...Dt,multiple:oe},"aria-describedby":Eo(P),children:[gr&&e.jsx(F,{value:"",children:B}),Array.isArray(Re)&&Re.map(({value:Oe,label:hr},Lt)=>{const fr=Array.isArray(ze)&&ze.indexOf(Oe)!==-1;return e.jsx(F,{value:String(Lt),disabled:fr,children:hr},Lt)})]})}return!r||!W||!d?null:e.jsxs(De,{open:r,onClose:c,maxWidth:"800px",children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Pe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Ro,{schema:W,formData:d,uiSchema:L,validator:$o,templates:{FieldTemplate:k,BaseInputTemplate:x,TitleFieldTemplate:C,DescriptionFieldTemplate:R,FieldHelpTemplate:m,FieldErrorTemplate:j,ErrorListTemplate:H,WrapIfAdditionalTemplate:f,ArrayFieldTitleTemplate:w,ArrayFieldDescriptionTemplate:q,ArrayFieldItemTemplate:de,ArrayFieldTemplate:xe,ObjectFieldTemplate:S,ButtonTemplates:{SubmitButton:p,RemoveButton:E,AddButton:I,MoveUpButton:Y,MoveDownButton:me}},widgets:{CheckboxWidget:Me,SelectWidget:U},onChange:z,onSubmit:v})})]})};function sr(r){if(s&&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 c=0,a=0;for(const i of r.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(c===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function cn({data:r,columns:c,columnVisibility:a}){const i=Xt.useMemo(()=>c.filter(y=>a[y.accessor]),[c,a]),{getTableProps:l,getTableBodyProps:g,headerGroups:b,rows:t,prepareRow:d}=Ue.useTable({columns:i,data:r},Ue.useSortBy);return e.jsxs("table",{...l(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:b.map(y=>e.jsx("tr",{...y.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:y.headers.map(W=>e.jsx("th",{...W.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:"default"},children:W.render("Header")}))}))}),e.jsx("tbody",{...g(),style:{border:"none",borderCollapse:"collapse"},children:t.map((y,W)=>(d(y),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...y.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:y.cells.map(h=>e.jsx("td",{...h.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:h.render("Cell")}))})))})]})}function pn({_storeId:r,setStoreId:c}){const{online:a,sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),{showConfirmCancelDialog:t}=o.useContext(nt),d=o.useRef(b()),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState([]),[O,u]=o.useState(!1),[z,v]=o.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),f=[{Header:"Name",accessor:"name",Cell:({row:n})=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>S(n.original),children:n.original.name})})},{Header:"Description",accessor:"description",Cell:({row:n})=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>S(n.original),children:n.original.description})})},{Header:"Version",accessor:"version",Cell:({row:n})=>e.jsxs(e.Fragment,{children:[n.original.latestVersion!==void 0&&n.original.latestVersion!==n.original.version&&h&&!h.readOnly&&e.jsx($,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>x(n.original),children:["Update to v.",n.original.latestVersion]})}),n.original.version.includes("-dev-")&&n.original.devVersion!==void 0&&n.original.devVersion!==n.original.version&&h&&!h.readOnly&&e.jsx($,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>w(n.original),children:["Update to new dev v.",n.original.devVersion.split("-dev-")[0]]})}),e.jsx($,{title:"Plugin version",children:e.jsx("span",{children:n.original.version})})]})},{Header:"Author",accessor:"author",Cell:({row:n})=>e.jsx(e.Fragment,{children:n.original.author?n.original.author.replace("https://github.com/",""):"Unknown"})},{Header:"Type",accessor:"type",Cell:({row:n})=>e.jsx(e.Fragment,{children:n.original.type?n.original.type.replace("Platform",""):"Unknown"})},{Header:"Devices",accessor:"registeredDevices"},{Header:"Actions",accessor:"actions",Cell:({row:n})=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[h&&h.bridgeMode==="childbridge"&&!n.original.error&&n.original.enabled&&e.jsx($,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:sr(n.original.matter)},onClick:()=>{n.original?.matter?.id&&c(n.original?.matter?.id)},size:"small",children:e.jsx(tr,{})})}),h&&h.bridgeMode==="childbridge"&&!n.original.error&&n.original.enabled&&e.jsx($,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>de(n.original),size:"small",children:e.jsx(yt,{})})}),e.jsx($,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{disabled:n.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(n.original),size:"small",children:e.jsx(Je,{})})}),h&&!h.readOnly&&e.jsx($,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",n.original)},size:"small",children:e.jsx(St,{})})}),n.original.enabled?e.jsx($,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",n.original)},size:"small",children:e.jsx(Lr,{})})}):e.jsx(e.Fragment,{}),n.original.enabled?e.jsx(e.Fragment,{}):e.jsx($,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>xe(n.original),size:"small",children:e.jsx(Hr,{})})}),e.jsx($,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>E(n.original),size:"small",children:e.jsx(Rr,{})})}),e.jsx($,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(n.original),size:"small",children:e.jsx($r,{})})}),h&&!h.readOnly&&e.jsx($,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>p(n.original),size:"small",children:e.jsx(Zt,{})})})]})},{Header:"Status",accessor:"status",Cell:({row:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",gap:"5px"},children:n.original.error?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:n.original.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:n.original.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:n.original.loaded&&n.original.started&&n.original.configured?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:n.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{status:n.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ze,{status:n.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ze,{status:n.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const n=T=>{T.src==="Matterbridge"&&T.dst==="Frontend"&&(fe(T)&&T.method==="refresh_required"&&T.params.changed==="plugins"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and sending /api/plugins request`),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),fe(T)&&T.method==="refresh_required"&&T.params.changed==="matter"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and setting matter id ${T.params.matter?.id}`),M(_=>{const ae=_.findIndex(B=>B.matter?.id===T.params.matter?.id);if(ae<0)return s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and matter id ${T.params.matter?.id} not found`),_;s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} set matter id ${T.params.matter?.id}`);const ce=[..._];return ce[ae]={...ce[ae],matter:T.params.matter},ce})),fe(T)&&T.method==="refresh_required"&&T.params.changed==="settings"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and sending /api/settings request`),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Ve(T)&&T.id===d.current&&T.method==="/api/settings"&&(s&&console.log(`HomePlugins (id: ${T.id}) received settings:`,T.response),W(T.response.systemInformation),L(T.response.matterbridgeInformation)),Ve(T)&&T.id===d.current&&T.method==="/api/plugins"&&(s&&console.log(`HomePlugins (id: ${T.id}) received ${T.response.length} plugins:`,T.response),M(T.response)))};return l(n),s&&console.log("HomePlugins added WebSocket listener id:",d.current),()=>{g(n),s&&console.log("HomePlugins removed WebSocket listener")}},[l,g,i]),o.useEffect(()=>{a&&(s&&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]),o.useEffect(()=>{const n=localStorage.getItem("homePluginsColumnVisibility");n&&v(JSON.parse(n))},[]);const k=()=>{u(!O)},R=n=>{v(T=>{const _={...T,[n]:!T[n]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(_)),_})},C=o.useRef(null),m=(n,T,_,ae)=>{s&&console.log(`handleActionWithConfirmCancel ${_} ${ae.name}`),C.current=ae,t(n,T,_,H,j)},H=n=>{s&&console.log(`handleConfirm action confirmed ${n} ${C.current?.name}`),n==="remove"&&C.current?q(C.current):n==="disable"&&C.current&&xe(C.current),C.current=null},j=n=>{s&&console.log(`handleCancel action canceled ${n} ${C.current?.name}`),C.current=null},x=n=>{s&&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}})},w=n=>{s&&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}})},q=n=>{s&&console.log("handleRemovePlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})},de=n=>{s&&console.log("handleRestartPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})},xe=n=>{s&&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}}))},S=n=>{s&&console.log(`handleHomepagePlugin plugin: ${n.name} homepage: ${n.homepage}`),n.homepage&&window.open(n.homepage,"_blank")},p=n=>{s&&console.log("handleSponsorPlugin plugin:",n.name,"funding:",n.funding),n.funding&&window.open(n.funding,"_blank")},E=n=>{s&&console.log("handleHelpPlugin plugin:",n.name,"help:",n.help),n.help&&window.open(n.help,"_blank")},I=n=>{s&&console.log("handleChangelogPlugin plugin:",n.name,"changelog:",n.changelog),n.changelog&&window.open(n.changelog,"_blank")},[Y,me]=o.useState({}),[Me,U]=o.useState(!1),D=n=>{s&&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}}),me(n),P()},P=()=>{U(!0)},N=()=>{U(!1)};return s&&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:[e.jsx(dn,{open:Me,onClose:N,plugin:Y}),e.jsxs(De,{open:O,onClose:k,children:[e.jsx(Ne,{children:"Configure Plugins Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:f.map(n=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["description","actions","status"].includes(n.accessor),checked:z[n.accessor]??!1,onChange:()=>R(n.accessor)}),label:n.Header},n.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:k,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Plugins"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:k,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(cn,{data:V,columns:f,columnVisibility:z})})]}):e.jsx(Qe,{})}const un=o.memo(pn),mn=r=>`${r.pluginName}::${r.serial}`;function gn({data:r,columns:c,columnVisibility:a}){const i=o.useMemo(()=>{const h=localStorage.getItem("homeDevicesColumnsSortBy");return h?JSON.parse(h):[{id:"name",desc:!1}]},[c]),l=o.useMemo(()=>c.filter(h=>a[h.accessor]),[a,c]),{getTableProps:g,getTableBodyProps:b,headerGroups:t,rows:d,prepareRow:y,state:{sortBy:W}}=Ue.useTable({columns:l,data:r,getRowId:mn,initialState:{sortBy:i}},Ue.useSortBy);return o.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(W))},[W]),e.jsxs("table",{...g(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:t.map(h=>e.jsx("tr",{...h.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:h.headers.map(L=>e.jsxs("th",{...L.getHeaderProps(L.noSort?void 0:L.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:[L.render("Header"),!L.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:L.isSorted?L.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Ft,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...b(),style:{border:"none",borderCollapse:"collapse"},children:d.map((h,L)=>(y(h),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...h.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:h.cells.map(V=>e.jsx("td",{...V.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:V.render("Cell")}))})))})]})}function hn({storeId:r,setStoreId:c}){const{online:a,sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),[t,d]=o.useState(!1),[y,W]=o.useState(!0),[h,L]=o.useState(null),[V,M]=o.useState([]),[O,u]=o.useState([]),[z,v]=o.useState([]),[f,k]=o.useState([]),[R,C]=o.useState(!1),[m,H]=o.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),j=o.useRef(b()),x=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:S})=>S.original.reachable===!0?"Online":S.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(S,p)=>{const E=S.original.reachable===!0?1:S.original.reachable===!1?0:-1,I=p.original.reachable===!0?1:p.original.reachable===!1?0:-1;return E-I}},{Header:"Power",accessor:"powerSource",Cell:({row:S})=>S.original.powerSource==="ac"||S.original.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):S.original.powerSource==="ok"?e.jsx(Ct,{fontSize:"small",sx:{color:"green"}}):S.original.powerSource==="warning"?e.jsx(Ct,{fontSize:"small",sx:{color:"yellow"}}):S.original.powerSource==="critical"?e.jsx(Ct,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:S})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[S.original.matter!==void 0?e.jsx($,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{onClick:()=>c(r===S.original.matter.id?h.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:S.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:sr(S.original.matter)},children:e.jsx(tr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),S.original.configUrl?e.jsx($,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{onClick:()=>window.open(S.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),S.original.selected!==void 0?e.jsx($,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Fe,{checked:S.original.selected,onChange:p=>xe(p,S.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],w=o.useCallback(S=>{S.selected=void 0;const p=V.find(Y=>Y.name===S.pluginName);if(!p)return console.error(`HomeDevices isSelected: plugin ${S.pluginName} not found for device ${S.deviceName} `),S.selected;const E=p.schemaJson?.properties?.whiteList?.selectFrom;let I=p.configJson?.postfix;return I===""&&(I=void 0),p.hasWhiteList===!0&&p.hasBlackList===!0&&E&&(S.selected=!0,E==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!0),E==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!1),E==="serial"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!1),E==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(S.name)&&(S.selected=!0),E==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(S.name)&&(S.selected=!1),E==="name"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(S.name)&&(S.selected=!1)),S.selected},[V]);o.useEffect(()=>{const S=p=>{if(p.src==="Matterbridge"&&p.dst==="Frontend"){if(p.method==="refresh_required"&&p.params.changed!=="matter"&&(s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and sending /api/plugins request`),i({id:j.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),p.method==="refresh_required"&&p.params.changed==="matter"&&(s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and setting matter id ${p.params.matter?.id}`),k(E=>{const I=E.findIndex(me=>me.name.replaceAll(" ","")===p.params.matter?.id);if(I<0)return s&&console.debug(`HomeDevices: matter id ${p.params.matter?.id} not found`),E;const Y=[...E];return Y[I]={...Y[I],matter:p.params.matter},s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and set matter id ${p.params.matter?.id}`),Y})),p.method==="restart_required"&&(s&&console.log("HomeDevices received restart_required"),d(!0)),p.method==="restart_not_required"&&(s&&console.log("HomeDevices received restart_not_required"),d(!1)),p.method==="state_update"&&p.params.plugin&&p.params.serialNumber&&p.params.cluster.includes("BasicInformationServer")&&p.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${p.params.plugin} serial ${p.params.serialNumber} value ${p.params.value}`),u(E=>E.map(I=>I.pluginName===p.params.plugin&&I.serial===p.params.serialNumber?{...I,reachable:p.params.value}:I))),p.id===j.current&&p.method==="/api/settings"&&(s&&console.log(`HomeDevices (id: ${p.id}) received settings:`,p.response),L(p.response),d(p.response.matterbridgeInformation.restartRequired||p.response.matterbridgeInformation.fixedRestartRequired)),p.id===j.current&&p.method==="/api/plugins"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} plugins:`,p.response),p.response)){let E=!0;for(const I of p.response)I.enabled===!0&&(I.loaded!==!0||I.started!==!0||I.error===!0)&&(E=!1);if(!E)return;s&&console.log("HomeDevices reset plugins, devices and selectDevices"),W(!1),M(p.response),u([]),v([]),i({id:j.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),s&&console.log("HomeDevices sent /api/devices");for(const I of p.response)I.enabled===!0&&I.loaded===!0&&I.started===!0&&I.error!==!0&&(i({id:j.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:I.name}}),s&&console.log(`HomeDevices sent /api/select/devices for plugin: ${I.name}`))}if(p.id===j.current&&p.method==="/api/devices"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} devices:`,p.response),p.response)){for(const E of p.response)E.selected=w(E);u(p.response)}p.id===j.current&&p.method==="/api/select/devices"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} selectDevices for plugin ${p.response&&p.response.length>0?p.response[0].pluginName:"without select devices"}:`,p.response),p.response&&p.response.length>0&&v(E=>{const I=E.filter(me=>me.pluginName!==p.response[0].pluginName),Y=p.response.map(me=>({...me,selected:w(me)}));return[...I,...Y]}))}};return l(S),s&&console.log(`HomeDevices added WebSocket listener id ${j.current}`),()=>{g(S),s&&console.log("HomeDevices removed WebSocket listener")}},[V,l,g,i,w]),o.useEffect(()=>{if(O.length===0&&z.length===0){k([]);return}s&&console.log(`HomeDevices mixing devices (${O.length}) and selectDevices (${z.length})`);const S=[];for(const p of O)S.push(p);for(const p of z)O.find(E=>E.pluginName===p.pluginName&&E.serial.includes(p.serial))||S.push(p);S.length>0&&(k(S),s&&console.log(`HomeDevices mixed ${S.length} devices and selectDevices`))},[V,O,z,k]),o.useEffect(()=>{a&&(s&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:j.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:j.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),o.useEffect(()=>{const S=localStorage.getItem("homeDevicesColumnVisibility");if(S){const p=JSON.parse(S);p.powerSource===void 0&&(p.powerSource=!0),H(p),s&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const q=S=>{H(p=>{const E={...p,[S]:!p[S]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(E)),s&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(E),E),E})},de=()=>{C(!R)},xe=(S,p)=>{console.log(`handleCheckboxChange: checkbox changed to ${S.target.checked} for device ${p.name} serial ${p.serial}`),k(E=>{const I=E.findIndex(me=>me.pluginName===p.pluginName&&me.serial===p.serial);if(I<0)return console.error(`handleCheckboxChange: device not found ${p.name} serial ${p.serial} id ${p.id}`),E;const Y=[...E];return Y[I]={...Y[I],selected:S.target.checked},Y}),S.target.checked?i({id:j.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}}):i({id:j.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}})};return s&&console.log("HomeDevices rendering..."),a?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs(De,{open:R,onClose:de,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:x.map(S=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["name","actions"].includes(S.accessor),checked:m[S.accessor],onChange:()=>q(S.accessor)}),label:S.Header},S.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:de,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:de,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(gn,{data:f,columns:x,columnVisibility:m})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[y&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!y&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",O.length.toString(),"/",f.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Qe,{})}const fn=o.memo(hn);function xn(){const[r,c]=o.useState(null),[a,i]=o.useState(null),[l,g]=o.useState([]),[b]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,d]=o.useState(localStorage.getItem("homePageMode")??"devices"),[y,W]=o.useState(""),[h,L]=o.useState(!1),[V,M]=o.useState(!1),[O,u]=o.useState(null),{addListener:z,removeListener:v,online:f,sendMessage:k,logFilterLevel:R,logFilterSearch:C,autoScroll:m,getUniqueId:H}=o.useContext(be),j=o.useRef(H());return o.useEffect(()=>{const x=w=>{w.src==="Matterbridge"&&w.dst==="Frontend"&&(fe(w)&&w.method==="refresh_required"&&w.params.changed==="settings"&&(s&&console.log(`Home received refresh_required: changed=${w.params.changed} and sending /api/settings request`),u(null),g([]),k({id:j.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:j.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),Ve(w)&&w.method==="/api/settings"&&w.id===j.current&&(s&&console.log("Home received settings:",w.response),c(w.response.systemInformation),i(w.response.matterbridgeInformation),w.response.matterbridgeInformation.bridgeMode==="bridge"&&(O||u("Matterbridge")),w.response.matterbridgeInformation.bridgeMode==="childbridge"&&l.length>0&&O===null&&!O&&l.length>0&&l[0].matter?.id&&u(l[0].matter.id),w.response.matterbridgeInformation.matterbridgeVersion&&W(`https://github.com/Luligu/matterbridge/blob/${w.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&w.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",w.response.matterbridgeInformation.frontendVersion):w.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&w.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",w.response.matterbridgeInformation.frontendVersion),M(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",w.response.matterbridgeInformation.matterbridgeVersion):w.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",w.response.matterbridgeInformation.matterbridgeVersion),L(!0)),w.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),d("devices")))),Ve(w)&&w.method==="/api/plugins"&&w.id===j.current&&(s&&console.log(`Home received plugins (${a?.bridgeMode}):`,w.response),g(w.response),a?.bridgeMode==="childbridge"&&w.response.length>0&&!O&&w.response.length>0&&w.response[0].matter?.id&&u(w.response[0].matter.id)))};return z(x),s&&console.log(`Home added WebSocket listener id ${j.current}`),()=>{v(x),s&&console.log("Home removed WebSocket listener")}},[z,v,k,a,l,O]),o.useEffect(()=>{f&&(s&&console.log("Home received online"),k({id:j.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:j.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[f,k]),s&&console.log("Home rendering..."),!f||!r||!a?e.jsx(Qe,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(rn,{id:O}),e.jsx(Zo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[V&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"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(ne,{onClick:()=>window.location.reload(),endIcon:e.jsx(Or,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),h&&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(ne,{onClick:()=>window.open(y,"_blank"),endIcon:e.jsx(er,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ne,{onClick:()=>window.location.reload(),endIcon:e.jsx(Er,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),b&&!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(nn,{})]}),b&&e.jsx(un,{storeId:O,setStoreId:u}),t==="devices"&&e.jsx(fn,{storeId:O,setStoreId:u}),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 "',R,'" and search "',C,'" Scroll: ',m?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(ar,{})})]})]})]})}const bn=o.memo(xn),Qt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},vn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},yn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Gt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},jn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Cn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Sn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},wn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Mn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Wt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},kn=[256,257,268,269],In=[266,267],Dn=[259,260,261,271,272],Nn=[256,257,268,269,266,267,259,260,261];function G({icon:r,iconColor:c,cluster:a,value:i,unit:l,prefix:g}){return s&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${l}"`),g=g??!1,e.jsxs(Z,{sx:Qt,children:[r&&o.cloneElement(r,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...vn,color:c??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Qt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&g===!0&&e.jsx(se,{sx:Gt,children:l},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(se,{sx:yn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),l&&g===!1&&e.jsx(se,{sx:Gt,children:l},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function Pn({device:r,endpoint:c,id:a,deviceType:i,clusters:l}){const g=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let b="";return s&&console.log(`Device "${r.name}" endpoint "${c}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>b=`${t.attributeLocalValue} mV`),Nn.includes(i)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>b=`Level ${t.attributeValue}`),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>b=`Position ${t.attributeValue/100}%`),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>b=`Heat ${t.attributeValue/100}°C `),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>b=b+`Cool ${t.attributeValue/100}°C`),i===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>b=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>b=`${t.attributeLocalValue/1e3} V, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>b=b+`${t.attributeLocalValue/1e3} A, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>b=b+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:t.attributeLocalValue===!0?e.jsx(at,{}):e.jsx(Vr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(G,{icon:e.jsx(Ct,{}),cluster:t,value:t.attributeValue/2,unit:"%"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(G,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),kn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),In.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Dn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:"Oven"})),i===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Ar,{}),cluster:t,value:"Fridge"})),i===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(G,{icon:e.jsx(te,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(G,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(G,{icon:t.attributeValue==="1"?e.jsx(zr,{}):e.jsx(qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(G,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),i===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(G,{icon:e.jsx(te,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===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(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===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(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(G,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:g[t.attributeLocalValue??0]})),i===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:t.attributeValue==="true"?e.jsx(ro,{}):e.jsx(oo,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(G,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(no,{}):e.jsx(io,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(ao,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeValue/1e4)),unit:"lx"})),i===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(G,{icon:e.jsx(so,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:jn,children:e.jsx(se,{sx:Cn,children:b})}),e.jsx(Z,{sx:Sn,children:e.jsx(se,{sx:wn,children:r.name})}),e.jsxs(Z,{sx:Mn,children:[s&&e.jsx(se,{sx:Wt,children:c}),e.jsx(se,{sx:Wt,children:a}),s&&e.jsxs(se,{sx:Wt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Wn({filter:r}){const{online:c,sendMessage:a,addListener:i,removeListener:l,getUniqueId:g}=o.useContext(be),[b,t]=o.useState({}),[d,y]=o.useState([]),[W,h]=o.useState([]),[L,V]=o.useState({}),[M,O]=o.useState({}),[u,z]=o.useState({}),[v,f]=o.useState(W),k=o.useRef(g());return o.useEffect(()=>{const R=C=>{if(C.src==="Matterbridge"&&C.dst==="Frontend"){if(C.method==="refresh_required"&&(s&&console.log(`DevicesIcons received refresh_required: changed=${C.params.changed} and sending api requests`),a({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),C.method==="/api/settings"&&C.response&&(s&&console.log("DevicesIcons received settings:",C.response),t(C.response)),C.method==="/api/plugins"&&C.response&&(s&&console.log("DevicesIcons received plugins:",C.response),y(C.response)),C.method==="/api/devices"&&C.response){s&&console.log(`DevicesIcons received ${C.response.length} devices:`,C.response),h(C.response);for(let m of C.response)s&&console.log("DevicesIcons sending /api/clusters"),a({id:k.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:m.pluginName,endpoint:m.endpoint}})}if(C.method==="/api/clusters"&&C.response){if(console.log(`DevicesIcons received for device "${C.response.deviceName}" serial "${C.response.serialNumber}" deviceType ${C.response.deviceTypes.join(" ")} clusters (${C.response.length}):`,C.response),C.response.length===0)return;const m=C.response.serialNumber;L[m]=[],M[m]=C.response.deviceTypes,u[m]=[];for(let H of C.response.clusters)L[m].find(j=>j.endpoint===H.endpoint)||L[m].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(H.clusterName)&&u[m].push(H);V({...L}),O({...M}),z({...u}),s&&console.log(`DevicesIcons endpoints for "${m}":`,L[m]),s&&console.log(`DevicesIcons deviceTypes for "${m}":`,M[m]),s&&console.log(`DevicesIcons clusters for "${m}":`,u[m])}}};return i(R),s&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(R),s&&console.log("DevicesIcons useEffect webSocket unmounted")}},[i,l,a]),o.useEffect(()=>(s&&console.log("DevicesIcons useEffect online mounting"),c&&(s&&console.log("DevicesIcons useEffect online sending api requests"),a({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),s&&console.log("DevicesIcons useEffect online mounted"),()=>{s&&console.log("DevicesIcons useEffect online unmounted")}),[c,a]),o.useEffect(()=>{if(r===""){f(W);return}const R=W.filter(C=>C.name.toLowerCase().includes(r)||C.serial.toLowerCase().includes(r));f(R)},[W,r]),s&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:v.map(R=>L[R.serial]&&L[R.serial].map(C=>C.deviceTypes.map(m=>e.jsx(Pn,{device:R,endpoint:C.endpoint,id:C.id,deviceType:m,clusters:u[R.serial].filter(H=>H.endpoint===C.endpoint)}))))})}const Tn=o.memo(Wn),lr=[{Header:"Plugin name",accessor:"pluginName"},{Header:"Device type",accessor:"type"},{Header:"Endpoint",accessor:"endpoint"},{Header:"Name",accessor:"name"},{Header:"Serial number",accessor:"serial"},{Header:"Unique ID",accessor:"uniqueId"},{Header:"Url",accessor:"configUrl"},{Header:"Config",accessor:"configButton",noSort:!0,Cell:({row:r})=>r.original.configUrl?e.jsx(J,{onClick:()=>window.open(r.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],dr=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:r})=>Array.isArray(r)?r.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):r},{Header:"Cluster Name",accessor:"clusterName"},{Header:"Cluster ID",accessor:"clusterId"},{Header:"Attribute Name",accessor:"attributeName"},{Header:"Attribute ID",accessor:"attributeId"},{Header:"Attribute Value",accessor:"attributeValue",Cell:({value:r})=>e.jsx($,{title:r,componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r})})}],Fn=r=>`${r.pluginName}::${r.uniqueId}`,Ln=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Hn({data:r,columnVisibility:c,setPlugin:a,setEndpoint:i,setDeviceName:l}){const[g,b]=o.useState(null),t=o.useMemo(()=>lr.filter(M=>c[M.accessor]),[c]),{getTableProps:d,getTableBodyProps:y,headerGroups:W,rows:h,prepareRow:L}=Ue.useTable({columns:t,data:r,getRowId:Fn},Ue.useSortBy),V=M=>{if(M.id===g){b(null),a(null),i(null),l(null),s&&console.log("Device unclicked:",M.id,"selectedDeviceIndex:",g);return}b(M.id),a(M.original.pluginName),i(M.original.endpoint),l(M.original.name),s&&console.log("Device clicked:",M.id,"selectedDeviceIndex:",g,"pluginName:",M.original.pluginName,"endpoint:",M.original.endpoint)};return e.jsxs("table",{...d(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:W.map(M=>e.jsx("tr",{...M.getHeaderGroupProps(),children:M.headers.map(O=>e.jsxs("th",{...O.getHeaderProps(O.noSort?void 0:O.getSortByToggleProps()),children:[O.render("Header"),!O.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:O.isSorted?O.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Ft,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...y(),children:h.map((M,O)=>(L(M),e.jsx("tr",{className:O%2===0?"table-content-even":"table-content-odd",...M.getRowProps(),onClick:()=>V(M),style:{backgroundColor:g===M.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:M.cells.map(u=>e.jsx("td",{...u.getCellProps(),children:u.render("Cell")}))})))})]})}function Rn({data:r,columnVisibility:c}){const a=o.useMemo(()=>dr.filter(d=>c[d.accessor]),[c]),{getTableProps:i,getTableBodyProps:l,headerGroups:g,rows:b,prepareRow:t}=Ue.useTable({columns:a,data:r,getRowId:Ln},Ue.useSortBy);return e.jsxs("table",{...i(),style:{margin:"-1px"},children:[e.jsx("thead",{children:g.map(d=>e.jsx("tr",{...d.getHeaderGroupProps(),children:d.headers.map(y=>e.jsx("th",{...y.getHeaderProps(),children:y.render("Header")}))}))}),e.jsx("tbody",{...l(),children:b.map((d,y)=>(t(d),e.jsx("tr",{className:y%2===0?"table-content-even":"table-content-odd",...d.getRowProps(),children:d.cells.map(W=>e.jsx("td",{...W.getCellProps(),children:W.render("Cell")}))})))})]})}function $n(){const{online:r,sendMessage:c,addListener:a,removeListener:i,getUniqueId:l}=o.useContext(be),[g,b]=o.useState([]),[t,d]=o.useState([]),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState(null),[O,u]=o.useState(0),[z,v]=o.useState(!1),[f,k]=o.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[R,C]=o.useState(!1),[m,H]=o.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[j,x]=o.useState(""),[w,q]=o.useState(g),[de,xe]=o.useState("icon"),S=o.useRef(l());o.useEffect(()=>{const U=D=>{if(s&&console.log("Devices received WebSocket Message:",D),D.src==="Matterbridge"&&D.dst==="Frontend"&&(D.method==="refresh_required"&&D.params.changed==="devices"&&(s&&console.log(`Devices received refresh_required: changed=${D.params.changed} and sending /api/devices request`),c({id:S.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),D.method==="/api/devices"&&(s&&console.log(`Devices received ${D.response.length} devices:`,D.response),b(D.response)),D.method==="/api/clusters")){console.log(`Devices received ${D.response.length} clusters:`,D.response),d(D.response.clusters);const P={};for(const N of D.response.clusters)s&&console.log("Cluster:",N.endpoint),P[N.endpoint]?P[N.endpoint]++:P[N.endpoint]=1;u(Object.keys(P).length)}};return a(U),s&&console.log("Devices added WebSocket listener"),()=>{i(U),s&&console.log("Devices removed WebSocket listener")}},[a,i,c]),o.useEffect(()=>{r&&(s&&console.log("Devices sending api requests"),c({id:S.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:S.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:S.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,c]),o.useEffect(()=>{y&&h&&(s&&console.log("Devices sending /api/clusters"),c({id:S.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:y,endpoint:h}}))},[y,h,c]);const p=()=>{v(!z)},E=U=>{k(D=>{const P={...D,[U]:!D[U]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(P)),P})};o.useEffect(()=>{const U=localStorage.getItem("devicesColumnVisibility");U&&k(JSON.parse(U))},[]);const I=()=>{C(!R)},Y=U=>{H(D=>{const P={...D,[U]:!D[U]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(P)),P})};o.useEffect(()=>{const U=localStorage.getItem("clustersColumnVisibility");U&&H(JSON.parse(U))},[]);const me=U=>{x(U.target.value.toLowerCase()),localStorage.setItem("devicesFilter",U.target.value.toLowerCase())},Me=U=>{xe(U),localStorage.setItem("devicesViewMode",U)};return o.useEffect(()=>{if(j===""){q(g);return}const U=g.filter(D=>D.name.toLowerCase().includes(j)||D.serial.toLowerCase().includes(j));q(U)},[g,j]),o.useEffect(()=>{const U=localStorage.getItem("devicesFilter");U&&x(U)},[]),o.useEffect(()=>{const U=localStorage.getItem("devicesViewMode");U&&xe(U)},[]),s&&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(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:j,onChange:me,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(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(J,{onClick:()=>Me("table"),"aria-label":"Table View",disabled:de==="table",children:e.jsx($,{title:"Table View",children:e.jsx(lo,{style:{color:de==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(J,{onClick:()=>Me("icon"),"aria-label":"Icon View",disabled:de==="icon",children:e.jsx($,{title:"Icon View (beta)",children:e.jsx(co,{style:{color:de==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(De,{open:z,onClose:p,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:lr.map(U=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["pluginName","name","configButton"].includes(U.accessor),checked:f[U.accessor],onChange:()=>E(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:p,children:"Close"})})]}),de==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${y&&h?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Registered devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:p,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Hn,{data:w,columnVisibility:f,setPlugin:W,setEndpoint:L,setDeviceName:M})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total devices: ",w.length.toString()]})})]}),e.jsxs(De,{open:R,onClose:I,children:[e.jsx(Ne,{children:"Configure Clusters Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:dr.map(U=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["clusterName","attributeName","attributeValue"].includes(U.accessor),checked:m[U.accessor],onChange:()=>Y(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:I,children:"Close"})})]}),de==="table"&&y&&h&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsxs("div",{className:"MbfWindowHeaderText",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[e.jsxs("p",{style:{margin:"0px",padding:"0px"},children:['Clusters for device "',V,'" on endpoint ',h]}),e.jsx(J,{onClick:I,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Rn,{data:t,columnVisibility:m})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total child endpoints: ",O-1]})})]}),de==="icon"&&e.jsx(Tn,{filter:j,devices:w})]}):e.jsx(Qe,{})}const On=o.memo($n);function En(){const[r,c]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[a,i]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[l,g]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:b,setLogFilters:t,online:d,setAutoScroll:y}=o.useContext(be),W=M=>{c(M.target.value),t(M.target.value,a),localStorage.setItem("logFilterLevel",M.target.value),s&&console.log("handleChangeLevel called with value:",M.target.value)},h=M=>{i(M.target.value),t(r,M.target.value),localStorage.setItem("logFilterSearch",M.target.value),s&&console.log("handleChangeSearch called with value:",M.target.value)},L=M=>{g(M.target.checked),y(M.target.checked),localStorage.setItem("logAutoScroll",M.target.value?"true":"false"),s&&console.log("handleAutoScrollChange called with value:",M.target.checked)},V=()=>{s&&console.log("handleClearLogsClick called"),b([])};return s&&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(_t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(ot,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:W,children:[e.jsx(F,{value:"debug",children:"Debug"}),e.jsx(F,{value:"info",children:"Info"}),e.jsx(F,{value:"notice",children:"Notice"}),e.jsx(F,{value:"warn",children:"Warn"}),e.jsx(F,{value:"error",children:"Error"}),e.jsx(F,{value:"fatal",children:"Fatal"})]}),e.jsx(_t,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:a,onChange:h,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Te,{control:e.jsx(Fe,{checked:l,onChange:L}),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(ne,{onClick:V,endIcon:e.jsx(St,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(ar,{})})]}):e.jsx(Qe,{})}const Vn=({open:r,ip:c,onClose:a,onSave:i})=>{const l=c?c.split(".").slice(0,3).join(".")+".1":"",[g,b]=o.useState("dhcp"),[t,d]=o.useState({ip:c??"",subnet:"255.255.255.0",gateway:l,dns:l}),y=L=>V=>{d({...t,[L]:V.target.value})},W=()=>{a()},h=()=>{const L=g==="static"?{type:g,...t}:{type:g};i(L),a()};return e.jsxs(De,{open:r,onClose:(L,V)=>{V==="backdropClick"||V==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Pe,{dividers:!0,children:[e.jsxs(or,{component:"fieldset",fullWidth:!0,children:[e.jsx(Ie,{component:"legend",children:"Select IP Configuration"}),e.jsxs(nr,{row:!0,value:g,onChange:L=>b(L.target.value),children:[e.jsx(Te,{value:"dhcp",control:e.jsx(wt,{}),label:"DHCP"}),e.jsx(Te,{value:"static",control:e.jsx(wt,{}),label:"Static"})]})]}),g==="static"&&e.jsxs(Ae,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:y("ip")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:y("subnet")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:y("gateway")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:y("dns")})})]})]}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:W,children:"Cancel"}),e.jsx(ne,{variant:"contained",onClick:h,children:"Save"})]})]})},_n=({open:r,onClose:c,onSave:a})=>{const[i,l]=o.useState(""),[g,b]=o.useState(""),t=V=>{l(V.target.value)},d=V=>{b(V.target.value)},y=i.length>0&&i===g,W=()=>{c()},h=()=>{y&&(a(i),c())},L=()=>{a(""),c()};return e.jsxs(De,{open:r,onClose:(V,M)=>{M==="backdropClick"||M==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Pe,{dividers:!0,children:e.jsx(or,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Ae,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ae,{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(Ae,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:g,onChange:d,error:g!==""&&i!==g,helperText:g!==""&&i!==g?"Passwords do not match":""})})]})})}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:W,children:"Cancel"}),e.jsx(ne,{variant:"contained",onClick:h,disabled:!y,children:"Change"}),e.jsx(ne,{variant:"contained",onClick:L,children:"Reset"})]})]})};function An(){const{online:r,addListener:c,removeListener:a,sendMessage:i,getUniqueId:l}=o.useContext(be),[g,b]=o.useState(null),[t,d]=o.useState(null),y=o.useRef(l());return o.useEffect(()=>{const W=h=>{h.src==="Matterbridge"&&h.dst==="Frontend"&&(h.method==="refresh_required"&&h.params.changed==="settings"&&(s&&console.log(`Settings received refresh_required: changed=${h.params.changed} and sending /api/settings request`),i({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),h.method==="/api/settings"&&(s&&console.log("Settings received /api/settings:",h.response),b(h.response.matterbridgeInformation),d(h.response.systemInformation)))};return c(W),s&&console.log("Settings added WebSocket listener"),()=>{a(W),s&&console.log("Settings removed WebSocket listener")}},[c,a,i]),o.useEffect(()=>{r&&(s&&console.log("Settings received online"),i({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,i]),g?(s&&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(Un,{matterbridgeInfo:g,systemInfo:t}),e.jsx(zn,{matterbridgeInfo:g}),e.jsx(qn,{matterbridgeInfo:g})]})}):e.jsx(Qe,{})):null}function Un({matterbridgeInfo:r,systemInfo:c}){const{sendMessage:a,getUniqueId:i}=o.useContext(be),[l,g]=o.useState("bridge"),[b,t]=o.useState("Info"),[d,y]=o.useState(!1),[W,h]=o.useState("dark"),[L,V]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[M,O]=o.useState(localStorage.getItem("homePageMode")??"logs"),[u,z]=o.useState(localStorage.getItem("virtualMode")??"outlet"),v=o.useRef(i()),[f,k]=o.useState(!1),R=()=>k(!1),C=I=>{s&&console.log("handleSaveNetConfig called with config:",I),a({id:v.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:I})},[m,H]=o.useState(!1),j=()=>H(!1),x=I=>{s&&console.log("handleSaveChangePassword called with password:",I),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:I}})};o.useEffect(()=>{r.bridgeMode!==void 0&&(g(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),y(r.fileLogger),z(r.virtualMode))},[r]),o.useEffect(()=>{const I=localStorage.getItem("frontendTheme");I&&h(I)},[]);const w=I=>{s&&console.log("handleChangeBridgeMode called with value:",I.target.value),g(I.target.value),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:I.target.value}})},q=I=>{s&&console.log("handleChangeMbLoggerLevel called with value:",I.target.value),t(I.target.value),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:I.target.value}})},de=I=>{s&&console.log("handleLogOnFileMbChange called with value:",I.target.checked),y(I.target.checked),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:I.target.checked}})},xe=I=>{const Y=I.target.value;s&&console.log("handleChangeTheme called with value:",Y),h(Y),localStorage.setItem("frontendTheme",Y),document.body.setAttribute("frontend-theme",Y)},S=I=>{const Y=I.target.checked;s&&console.log("handleChangeHomePagePlugins called with value:",Y),V(Y),localStorage.setItem("homePagePlugins",Y?"true":"false")},p=I=>{const Y=I.target.value;s&&console.log("handleChangeHomePageMode called with value:",Y),O(Y),localStorage.setItem("homePageMode",Y)},E=I=>{const Y=I.target.value;s&&console.log("handleChangeVirtualMode called with value:",Y),z(Y),localStorage.setItem("virtualMode",Y),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:Y}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Vn,{open:f,ip:c.ipv4Address,onClose:R,onSave:C}),e.jsx(_n,{open:m,onClose:j,onSave:x}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(nr,{row:!0,name:"mode-buttons-group",value:l,onChange:w,children:[e.jsx(Te,{value:"bridge",control:e.jsx(wt,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(Te,{value:"childbridge",control:e.jsx(wt,{}),label:"Childbridge",disabled:r.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:b,onChange:q,children:[e.jsx(F,{value:"Debug",children:"Debug"}),e.jsx(F,{value:"Info",children:"Info"}),e.jsx(F,{value:"Notice",children:"Notice"}),e.jsx(F,{value:"Warn",children:"Warn"}),e.jsx(F,{value:"Error",children:"Error"}),e.jsx(F,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(Fe,{checked:d,onChange:de,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:W,onChange:xe,children:[e.jsx(F,{value:"classic",children:"Classic"}),e.jsx(F,{value:"light",children:"Light"}),e.jsx(F,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Fe,{checked:L,onChange:S,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:M,onChange:p,children:[e.jsx(F,{value:"logs",children:"Logs"}),e.jsx(F,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:u,onChange:E,children:[e.jsx(F,{value:"disabled",children:"Disabled"}),e.jsx(F,{value:"outlet",children:"Outlet"}),e.jsx(F,{value:"light",children:"Light"}),e.jsx(F,{value:"switch",children:"Switch"}),e.jsx(F,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Change password"})}),r.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>k(!0),children:"Configure IP"})})]})})]})}function zn({matterbridgeInfo:r}){const{sendMessage:c,getUniqueId:a}=o.useContext(be),[i,l]=o.useState("Info"),[g,b]=o.useState(!1),[t,d]=o.useState(""),[y,W]=o.useState(""),[h,L]=o.useState(""),[V,M]=o.useState(),[O,u]=o.useState(),[z,v]=o.useState(),f=o.useRef(a());o.useEffect(()=>{r.bridgeMode!==void 0&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),b(r.matterFileLogger),d(r.matterMdnsInterface),W(r.matterIpv4Address),L(r.matterIpv6Address),M(r.matterPort),u(r.matterDiscriminator),v(r.matterPasscode))},[r]);const k=q=>{s&&console.log("handleChangeMjLoggerLevel called with value:",q.target.value),l(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:q.target.value}})},R=q=>{s&&console.log("handleLogOnFileMjChange called with value:",q.target.checked),b(q.target.checked),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:q.target.checked}})},C=q=>{s&&console.log("handleChangeMdnsInterface called with value:",q.target.value),d(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:q.target.value}})},m=q=>{s&&console.log("handleChangeIpv4Address called with value:",q.target.value),W(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:q.target.value}})},H=q=>{s&&console.log("handleChangeIpv6Address called with value:",q.target.value),L(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:q.target.value}})},j=q=>{s&&console.log("handleChangeMatterPort called with value:",q.target.value),M(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:q.target.value}})},x=q=>{s&&console.log("handleChangeMatterDiscriminator called with value:",q.target.value),u(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:q.target.value}})},w=q=>{s&&console.log("handleChangemMatterPasscode called with value:",q.target.value),v(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:q.target.value}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:k,children:[e.jsx(F,{value:"Debug",children:"Debug"}),e.jsx(F,{value:"Info",children:"Info"}),e.jsx(F,{value:"Notice",children:"Notice"}),e.jsx(F,{value:"Warn",children:"Warn"}),e.jsx(F,{value:"Error",children:"Error"}),e.jsx(F,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(Fe,{checked:g,onChange:R,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),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(Ie,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:y,onChange:m,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(Ie,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:h,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(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:V,onChange:j,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(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:O,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(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:z,onChange:w,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function qn({matterbridgeInfo:r}){return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Be,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(Be,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Be,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(Be,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(Be,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Be,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Be,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function Be({value:r,label:c}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:c,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}function Bn(r,c,a){const i=r?.[a],l=c?.[a];return i==null&&l==null?0:i==null?-1:l==null?1:typeof i=="boolean"&&typeof l=="boolean"?i===l?0:i?1:-1:typeof i=="number"&&typeof l=="number"?i-l:String(i).localeCompare(String(l))}function Jn({name:r,columns:c,rows:a,getRowKey:i,footerLeft:l,footerRight:g}){const b=o.useRef(new WeakMap),t=o.useRef(1),d=m=>{if(typeof i=="string"&&m&&m[i]!=null)return m[i];if(typeof i=="function"){const x=i(m);if(x!=null)return x}const H=c?.[0]?.id;if(H&&m&&m[H]!=null)return m[H];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let j=b.current.get(m);return j||(j=`rk_${t.current++}`,b.current.set(m,j)),j},[y,W]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[h,L]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[V,M]=o.useState(!1),[O,u]=o.useState(()=>{try{const m=localStorage.getItem(`${r}_column_visibility`);if(m)return JSON.parse(m)}catch{}return{}}),z=o.useMemo(()=>{const m={};for(const H of c)H.hidden||(m[H.id]=H.required?!0:O[H.id]!==!1);return m},[c,O]),v=o.useMemo(()=>{if(!y||!h)return a;const m=c.find(j=>j.id===y);if(!m||m.nosort)return a;const H=a.map((j,x)=>({el:j,index:x}));return H.sort((j,x)=>{const w=Bn(j.el,x.el,y);return w!==0?h==="asc"?w:-w:j.index-x.index}),H.map(j=>j.el)},[a,y,h,c]),f=m=>{if(y!==m||!y){W(m),L("asc"),localStorage.setItem(`${r}_table_order_by`,m),localStorage.setItem(`${r}_table_order`,"asc");return}if(h==="asc"){L("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}W(null),L(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},k=()=>{M(!V)},R=m=>{u(H=>{const j=c.find(q=>q.id===m);if(j&&j.required)return H;const x=z[m]!==!1,w={...H};x?w[m]=!1:delete w[m];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(w))}catch{}return w})},C=()=>{const m={};u(m);try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(m))}catch{}};return console.log(`Rendering table ${r}${y&&h?` ordered by ${y}:${h}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(De,{open:V,onClose:(m,H)=>{H==="backdropClick"||H==="escapeKeyDown"||k()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${r} columns`})]})}),e.jsx(Pe,{children:e.jsx(st,{children:c.filter(m=>!m.hidden).map(m=>e.jsx(Te,{control:e.jsx(Fe,{disabled:!!m.required,checked:m.required?!0:z[m.id]!==!1,onChange:()=>R(m.id)}),label:m.label},m.id))})}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:C,children:"Reset"}),e.jsx(ne,{variant:"contained",onClick:m=>{if(m?.currentTarget&&typeof m.currentTarget.blur=="function")try{m.currentTarget.blur()}catch{}const H=document.activeElement;if(H&&H instanceof HTMLElement&&typeof H.blur=="function")try{H.blur()}catch{}k()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:r}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:m=>{if(m?.currentTarget?.blur)try{m.currentTarget.blur()}catch{}k()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:`Configure ${r} columns`,children:e.jsx(te,{path:Ho,size:"20px",style:{color:"var(--header-text-color)"}})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${r} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(m=>{if(m.hidden||!m.required&&z[m.id]===!1)return null;const H=!m.nosort,j=H&&y===m.id&&!!h;return e.jsxs("th",{onClick:H?()=>f(m.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:m.minWidth,maxWidth:m.maxWidth,textAlign:m.align||"left",cursor:H?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:m.maxWidth?"nowrap":void 0,overflow:m.maxWidth?"hidden":void 0,textOverflow:m.maxWidth?"ellipsis":void 0},"aria-sort":H?j?h==="asc"?"ascending":"descending":"none":void 0,children:[m.label,j&&e.jsxs("span",{style:{marginLeft:6},children:[h==="asc"&&e.jsx(te,{path:Ft,size:"15px"}),h==="desc"&&e.jsx(te,{path:Tt,size:"15px"})]})]},m.id)})})}),e.jsx("tbody",{children:v.map((m,H)=>{const j=d(m);return e.jsx("tr",{className:H%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:c.map(x=>{if(x.hidden||!x.required&&z[x.id]===!1)return null;const w=m[x.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:x.align||"left",padding:"4px 8px",margin:"0",maxWidth:x.maxWidth,whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},children:typeof x.render=="function"?x.render(w,j,m,x):typeof w=="boolean"?e.jsx(Fe,{checked:w,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):x.format&&typeof w=="number"?x.format(w):w!=null?String(w):null},x.id)})},j)})})]})}),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:l}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}const Qn=o.memo(Jn);function Gn(){const{online:r,sendMessage:c,addListener:a,removeListener:i,getUniqueId:l}=o.useContext(be),{showSnackbarMessage:g,closeSnackbarMessage:b}=o.useContext(nt),[t,d]=o.useState(null),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState(null),[O,u]=o.useState({cpuUsage:0}),[z,v]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[f,k]=o.useState({systemUptime:"",processUptime:""}),R=o.useRef(-1),[C,m]=o.useState(()=>cr);R.current||(R.current=l(),console.log("Test uniqueId:",R)),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const j=x=>{if(x.src==="Matterbridge"&&x.dst==="Frontend"){if(fe(x)&&x.method==="restart_required"&&(console.log("Test received restart_required"),g("Restart required",0)),fe(x)&&x.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${x.params.changed} and sending api requests`),g("Refresh required",0),c({id:R.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),fe(x)&&x.method==="memory_update"&&(console.log("Test received memory_update",x),v(x.params)),fe(x)&&x.method==="cpu_update"&&(console.log("Test received cpu_update",x),u(x.params)),fe(x)&&x.method==="uptime_update"&&(console.log("Test received uptime_update",x),k(x.params)),Ve(x)&&x.method==="/api/settings"&&x.response&&(console.log("Test received /api/settings:",x.response),g("Test received /api/settings"),d(x.response)),Ve(x)&&x.method==="/api/plugins"&&x.response&&(console.log(`Test received ${x.response.length} plugins:`,x.response),g("Test received /api/plugins"),W(x.response)),Ve(x)&&x.method==="/api/devices"&&x.response){console.log(`Test received ${x.response.length} devices:`,x.response),g("Test received /api/devices"),L(x.response);for(const w of x.response)console.log("Test sending /api/clusters for device:",w.pluginName,w.name,w.endpoint),c({id:R.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:w.pluginName,endpoint:w.endpoint}})}Ve(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),g("Test received /api/clusters"),M(x.response))}};return a(j),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),i(j),console.log("Test useEffect WebSocketMessage unmounted")}},[a,i,c,g]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),c({id:R.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,c,g]);const H=o.useCallback(j=>String(j.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(Qn,{name:"Test",columns:Yn,rows:C,getRowKey:H,footerLeft:"Left Footer",footerRight:"Right Footer"})}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>{console.log("Test button clicked"),g("Test button clicked"),b("Refresh required"),b("Restart required"),b("Test permanent message removal")},children:"Test"}),e.jsx(ne,{variant:"outlined",onClick:()=>{m(j=>{const x=j.findIndex(xe=>xe.code==="F123");if(x===-1)return j;const w=j[x],q={...w,population:(w.population||0)+1},de=j.slice();return de[x]=q,de})},children:"Update F123"})]})]})}):e.jsx(Qe,{})}const Kn=o.memo(Gn),Yn=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(r,c,a,i)=>e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",borderRadius:"8px",backgroundColor:"var(--chip-bg, #e6f4ff)",color:"var(--chip-fg, #0550ae)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"0.85em"},children:String(r)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:r=>r.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(r,c,a,i)=>a.isIsland?"🏝️":"🏞️"}];function Se(r,c,a,i,l){const g=a/i;return{name:r,code:c,population:a,size:i,density:g,isIsland:l}}const cr=[Se("India","IN",1324171354,3287263,!1),Se("China","CN",1403500365,9596961,!1),Se("Italy","IT",60483973,301340,!1),Se("United States","US",327167434,9833520,!1),Se("Canada is a truly wonderful country","CA",37602103,9984670,!1),Se("Australia","AU",25475400,7692024,!0),Se("Germany","DE",83019200,357578,!1),Se("Ireland","IE",4857e3,70273,!0),Se("Mexico","MX",126577691,1972550,!1),Se("Japan","JP",126317e3,377973,!0),Se("France","FR",67022e3,640679,!1),Se("United Kingdom","GB",67545757,242495,!0),Se("Russia","RU",146793744,17098246,!1),Se("Nigeria","NG",200962417,923768,!1),Se("Brazil","BR",210147125,8515767,!1)],Kt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Yt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let r=0;r<2e3;r++){const c=`${Kt[r%Kt.length]}${Yt[r%Yt.length]} ${r}`,a=`F${r.toString().padStart(3,"0")}`,i=Math.floor(Math.random()*1e9),l=Math.floor(Math.random()*1e7),g=Math.random()<.2;cr.push(Se(c,a,i,l,g))}function Xn(r,c){s&&console.log("getCssVariable:",r,"defaultValue",c);const a=getComputedStyle(document.body).getPropertyValue(r).trim();return a||console.error("getCssVariable: undefined",a),a||c}function Zn(r){return po({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 s=!1;const ei=()=>{s=!s},pr=o.createContext(void 0);function ti({children:r}){const[c,a]=o.useState(!1),[i,l]=o.useState(""),g=async b=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:b})});if(t.ok){const{valid:d}=await t.json();d?a(!0):b!==""&&l("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(pr.Provider,{value:{loggedIn:c,logIn:g,errorMessage:i},children:r})}function ri(){const[r,c]=o.useState(""),a=o.useContext(pr),[i,l]=o.useState("#1976d2");if(!a)throw new Error("AuthContext not found");const{loggedIn:g,logIn:b,errorMessage:t}=a,d=M=>{M.preventDefault(),b(r)},y={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},W={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},h={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"};o.useEffect(()=>{s&&console.log("Setting frontend theme");const M=localStorage.getItem("frontendTheme");s&&console.log("Saved theme:",M),M?document.body.setAttribute("frontend-theme",M):document.body.setAttribute("frontend-theme","dark");const O=Xn("--primary-color","#1976d2");s&&console.log("Primary color from CSS:",O),l(O)},[]);const L=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";console.log(`Loading App.js with href="${window.location.href}" and pathname="${window.location.pathname}" >>> baseName="${L}"`);const V=Zn(i);return b(""),g?e.jsx(uo,{theme:V,children:e.jsx(Cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(qo,{children:e.jsx(Bo,{children:e.jsx(xr,{basename:L,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Qo,{}),e.jsxs(br,{children:[e.jsx(Xe,{path:"/",element:e.jsx(bn,{})}),e.jsx(Xe,{path:"/devices",element:e.jsx(On,{})}),e.jsx(Xe,{path:"/log",element:e.jsx(En,{})}),e.jsx(Xe,{path:"/settings",element:e.jsx(An,{})}),e.jsx(Xe,{path:"/test",element:e.jsx(Kn,{})}),e.jsx(Xe,{path:"*",element:e.jsx(vr,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:y,children:e.jsxs("form",{onSubmit:d,style:W,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:r,onChange:M=>c(M.target.value),style:h,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function oi(){return e.jsx(ti,{children:e.jsx(ri,{})})}yr.createRoot(document.getElementById("root")).render(e.jsx(Xt.StrictMode,{children:e.jsx(oi,{})}));
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,{})}));