matterbridge 3.4.2 → 3.4.3-dev-20251206-06686b7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README-SERVICE-LOCAL.md +3 -3
- package/README-SERVICE-OPT.md +3 -5
- package/README.md +8 -14
- package/dist/broadcastServer.js +0 -119
- package/dist/broadcastServerTypes.js +0 -24
- package/dist/cli.js +3 -97
- package/dist/cliEmitter.js +0 -37
- package/dist/cliHistory.js +0 -38
- package/dist/clusters/export.js +0 -2
- package/dist/deviceManager.js +1 -113
- package/dist/devices/airConditioner.js +0 -57
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/cooktop.js +0 -56
- package/dist/devices/dishwasher.js +0 -57
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.js +0 -5
- package/dist/devices/extractorHood.js +0 -43
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.js +3 -62
- package/dist/devices/laundryWasher.js +4 -70
- package/dist/devices/microwaveOven.js +5 -88
- package/dist/devices/oven.js +0 -85
- package/dist/devices/refrigerator.js +0 -102
- package/dist/devices/roboticVacuumCleaner.js +9 -100
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/speaker.js +0 -84
- package/dist/devices/temperatureControl.js +3 -24
- package/dist/devices/waterHeater.js +2 -82
- package/dist/dgram/coap.js +13 -126
- package/dist/dgram/dgram.js +2 -114
- package/dist/dgram/mb_coap.js +3 -41
- package/dist/dgram/mb_mdns.js +15 -80
- package/dist/dgram/mdns.js +137 -299
- package/dist/dgram/multicast.js +1 -62
- package/dist/dgram/unicast.js +0 -54
- package/dist/frontend.js +35 -455
- package/dist/frontendTypes.js +0 -45
- package/dist/helpers.js +0 -53
- package/dist/index.js +0 -25
- package/dist/jestutils/export.js +0 -1
- package/dist/jestutils/jestHelpers.js +14 -371
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.js +0 -3
- package/dist/matter/types.js +0 -3
- package/dist/matterNode.js +8 -369
- package/dist/matterbridge.js +54 -817
- package/dist/matterbridgeAccessoryPlatform.js +0 -38
- package/dist/matterbridgeBehaviors.js +5 -68
- package/dist/matterbridgeDeviceTypes.js +14 -635
- package/dist/matterbridgeDynamicPlatform.js +0 -38
- package/dist/matterbridgeEndpoint.js +53 -1444
- package/dist/matterbridgeEndpointHelpers.js +20 -483
- package/dist/matterbridgeEndpointTypes.js +0 -25
- package/dist/matterbridgePlatform.js +1 -451
- package/dist/matterbridgeTypes.js +0 -26
- package/dist/pluginManager.js +5 -341
- package/dist/shelly.js +7 -178
- package/dist/storage/export.js +0 -1
- package/dist/update.js +1 -93
- package/dist/utils/colorUtils.js +2 -97
- package/dist/utils/commandLine.js +0 -60
- package/dist/utils/copyDirectory.js +0 -37
- package/dist/utils/createDirectory.js +0 -33
- package/dist/utils/createZip.js +2 -47
- package/dist/utils/deepCopy.js +0 -39
- package/dist/utils/deepEqual.js +1 -72
- package/dist/utils/error.js +0 -42
- package/dist/utils/export.js +0 -1
- package/dist/utils/format.js +0 -49
- package/dist/utils/hex.js +0 -124
- package/dist/utils/inspector.js +1 -69
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/network.js +5 -96
- package/dist/utils/spawn.js +1 -71
- package/dist/utils/tracker.js +1 -64
- package/dist/utils/wait.js +8 -60
- package/dist/workerGlobalPrefix.js +5 -37
- package/dist/workerTypes.js +0 -24
- package/dist/workers.js +4 -68
- package/frontend/build/assets/index.js +4 -4
- package/frontend/build/assets/vendor_mui.js +1 -1
- package/frontend/package.json +1 -1
- package/npm-shrinkwrap.json +8 -7
- package/package.json +3 -4
- package/scripts/marked.mjs +132 -0
- package/scripts/markedFooter.html +42 -0
- package/scripts/markedHeader.html +78 -0
- package/dist/broadcastServer.d.ts +0 -144
- package/dist/broadcastServer.d.ts.map +0 -1
- package/dist/broadcastServer.js.map +0 -1
- package/dist/broadcastServerTypes.d.ts +0 -841
- package/dist/broadcastServerTypes.d.ts.map +0 -1
- package/dist/broadcastServerTypes.js.map +0 -1
- package/dist/cli.d.ts +0 -30
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -50
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/cliHistory.d.ts +0 -48
- package/dist/cliHistory.d.ts.map +0 -1
- package/dist/cliHistory.js.map +0 -1
- package/dist/clusters/export.d.ts +0 -2
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -135
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/airConditioner.d.ts +0 -98
- package/dist/devices/airConditioner.d.ts.map +0 -1
- package/dist/devices/airConditioner.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts +0 -48
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/cooktop.d.ts +0 -61
- package/dist/devices/cooktop.d.ts.map +0 -1
- package/dist/devices/cooktop.js.map +0 -1
- package/dist/devices/dishwasher.d.ts +0 -71
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts +0 -76
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts +0 -17
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts +0 -46
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts +0 -47
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts +0 -67
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts +0 -81
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/microwaveOven.d.ts +0 -168
- package/dist/devices/microwaveOven.d.ts.map +0 -1
- package/dist/devices/microwaveOven.js.map +0 -1
- package/dist/devices/oven.d.ts +0 -105
- package/dist/devices/oven.d.ts.map +0 -1
- package/dist/devices/oven.js.map +0 -1
- package/dist/devices/refrigerator.d.ts +0 -118
- package/dist/devices/refrigerator.d.ts.map +0 -1
- package/dist/devices/refrigerator.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts +0 -40
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/speaker.d.ts +0 -87
- package/dist/devices/speaker.d.ts.map +0 -1
- package/dist/devices/speaker.js.map +0 -1
- package/dist/devices/temperatureControl.d.ts +0 -166
- package/dist/devices/temperatureControl.d.ts.map +0 -1
- package/dist/devices/temperatureControl.js.map +0 -1
- package/dist/devices/waterHeater.d.ts +0 -111
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/coap.d.ts +0 -205
- package/dist/dgram/coap.d.ts.map +0 -1
- package/dist/dgram/coap.js.map +0 -1
- package/dist/dgram/dgram.d.ts +0 -141
- package/dist/dgram/dgram.d.ts.map +0 -1
- package/dist/dgram/dgram.js.map +0 -1
- package/dist/dgram/mb_coap.d.ts +0 -24
- package/dist/dgram/mb_coap.d.ts.map +0 -1
- package/dist/dgram/mb_coap.js.map +0 -1
- package/dist/dgram/mb_mdns.d.ts +0 -24
- package/dist/dgram/mb_mdns.d.ts.map +0 -1
- package/dist/dgram/mb_mdns.js.map +0 -1
- package/dist/dgram/mdns.d.ts +0 -290
- package/dist/dgram/mdns.d.ts.map +0 -1
- package/dist/dgram/mdns.js.map +0 -1
- package/dist/dgram/multicast.d.ts +0 -67
- package/dist/dgram/multicast.d.ts.map +0 -1
- package/dist/dgram/multicast.js.map +0 -1
- package/dist/dgram/unicast.d.ts +0 -56
- package/dist/dgram/unicast.d.ts.map +0 -1
- package/dist/dgram/unicast.js.map +0 -1
- package/dist/frontend.d.ts +0 -238
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts +0 -529
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/helpers.d.ts +0 -48
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jestutils/export.d.ts +0 -2
- package/dist/jestutils/export.d.ts.map +0 -1
- package/dist/jestutils/export.js.map +0 -1
- package/dist/jestutils/jestHelpers.d.ts +0 -345
- package/dist/jestutils/jestHelpers.d.ts.map +0 -1
- package/dist/jestutils/jestHelpers.js.map +0 -1
- package/dist/logger/export.d.ts +0 -2
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/behaviors.d.ts +0 -2
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts +0 -2
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts +0 -2
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts +0 -2
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.js.map +0 -1
- package/dist/matter/export.d.ts +0 -5
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matter/types.d.ts +0 -3
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterNode.d.ts +0 -342
- package/dist/matterNode.d.ts.map +0 -1
- package/dist/matterNode.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -492
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -41
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -2404
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -698
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -41
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1507
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -787
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgeEndpointTypes.d.ts +0 -166
- package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
- package/dist/matterbridgeEndpointTypes.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -539
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -251
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -372
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts +0 -181
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.js.map +0 -1
- package/dist/storage/export.d.ts +0 -2
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/update.d.ts +0 -84
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -101
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -66
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -35
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createDirectory.d.ts +0 -34
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -39
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -32
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -54
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/error.d.ts +0 -45
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.js.map +0 -1
- package/dist/utils/export.d.ts +0 -13
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/format.d.ts +0 -53
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -89
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/inspector.d.ts +0 -87
- package/dist/utils/inspector.d.ts.map +0 -1
- package/dist/utils/inspector.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -103
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/network.d.ts +0 -111
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -33
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js.map +0 -1
- package/dist/utils/tracker.d.ts +0 -108
- package/dist/utils/tracker.d.ts.map +0 -1
- package/dist/utils/tracker.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -54
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
- package/dist/workerGlobalPrefix.d.ts +0 -25
- package/dist/workerGlobalPrefix.d.ts.map +0 -1
- package/dist/workerGlobalPrefix.js.map +0 -1
- package/dist/workerTypes.d.ts +0 -52
- package/dist/workerTypes.d.ts.map +0 -1
- package/dist/workerTypes.js.map +0 -1
- package/dist/workers.d.ts +0 -69
- package/dist/workers.d.ts.map +0 -1
- package/dist/workers.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,y as r,S as at,U as wr,V as Cr,X as qe,Y as Sr,Z as kr,I as Mr}from"./vendor_node_modules.js";import{u as Ir,S as Dr}from"./vendor_notistack.js";import{D as
|
|
2
|
-
`).map((
|
|
3
|
-
`)},[]),F=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${b}`),localStorage.getItem("installAutoExit")!=="false"&&
|
|
4
|
-
`)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(b.current==="info"&&m.response.level==="debug"||b.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||b.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||b.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||b.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||H.current!=="*"&&H.current!==""&&!m.response.message.toLowerCase().includes(H.current.toLowerCase())&&!m.response.name.toLowerCase().includes(H.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;l(re=>{const ce=[...re,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return ce.length>i*2?ce.slice(i):ce})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)P.current.forEach(he=>he.listener(m));else{const he=P.current.find(re=>re.id===m.id);he?he.listener(m):console.warn(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocket error parsing message: ${m}`,m instanceof Error?m.stack:null)}},S.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${se}`),$("WebSocket",`Connected to WebSocket: ${se}`),k(!0),z(),U.current=1,p.current=setTimeout(()=>{g.current=setInterval(()=>{M({id:W.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${se}`),$("WebSocket",`No pong response received from WebSocket: ${se}`),k(!1)},1e3*F)},1e3*q)},1e3*J)},S.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${ve?"with Ingress":""}: ${se}`),$("WebSocket",`Disconnected from WebSocket: ${se}`),k(!1),z(),c(),p.current&&clearTimeout(p.current),s.current&&clearTimeout(s.current),g.current&&clearInterval(g.current),$("WebSocket",`Reconnecting (attempt ${U.current} of ${R}) to WebSocket${ve?" (Ingress)":""}: ${se}`),ve?setTimeout(ue,5e3):U.current===1?ue():U.current<R?setTimeout(ue,1e3*U.current):$("WebSocket",`Reconnect attempts exceeded limit of ${R} retries, refresh the page to reconnect to: ${se}`),U.current=U.current+1},S.current.onerror=B=>{o&&console.error(`WebSocket: WebSocket error connecting to ${se}:`,B),$("WebSocket",`WebSocket error connecting to ${se}`)})},[se]),ue=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${U.current}/${R} to:`,se),oe()},[oe]);r.useEffect(()=>(oe(),()=>{S.current&&S.current.readyState===WebSocket.OPEN&&S.current.close()}),[oe]);const me=r.useMemo(()=>({messages:d,logMaxMessages:i,logAutoScroll:D,logFilterLevel:h,logFilterSearch:y,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:u,setLogFilterSearch:t,setLogAutoScroll:j,filterLogMessages:I}),[d,i,D,h,y,l,u,t,a,j,I]),_=r.useMemo(()=>({logMaxMessages:i,logAutoScroll:D,logFilterLevel:h,logFilterSearch:y,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:u,setLogFilterSearch:t,setLogAutoScroll:j,filterLogMessages:I,online:C,retry:U.current,getUniqueId:T,addListener:K,removeListener:le,sendMessage:M,logMessage:$}),[i,D,l,u,t,a,j,C,U.current,K,le,M,$]);return e.jsx(ar.Provider,{value:me,children:e.jsx(xe.Provider,{value:_,children:n})})}function on(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function De(){const{retry:n}=r.useContext(xe),d=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(on,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx($r,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function nn({value:n,maxChars:d}){let l=n;if(n.length>d&&d>3){const i=d-3,a=n.substring(0,Math.ceil(i/2)),h=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${h}`}return n!==l?e.jsx(E,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function je({children:n,style:d}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Ue({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function _e({children:n,style:d}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function mt({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function ht({children:n,style:d}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function ot({children:n,style:d}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function kt({children:n,style:d,onDragOver:l,onDragLeave:i,onDrop:a}){const h={display:"flex",flexDirection:"row",flex:"0 0 auto",overflow:"hidden",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...h,...d},onDragOver:l,onDragLeave:i,onDrop:a,children:n})}function it({children:n,style:d,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...d},children:[n,wi]})}function sn({systemInfo:n,compact:d}){const{addListener:l,removeListener:i,getUniqueId:a,sendMessage:h}=r.useContext(xe),[u,y]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",u,"compact:",d),n&&d&&u.totalMemory&&u.freeMemory){const w=u.totalMemory,c=u.freeMemory;u.freeMemory=`${c} / ${w}`,u.totalMemory=""}if(n&&d&&u.heapTotal&&u.heapUsed){const w=u.heapTotal,c=u.heapUsed;u.heapUsed=`${c} / ${w}`,u.heapTotal=""}if(n&&d&&u.osRelease&&u.osType){const w=u.osType,c=u.osRelease;u.osType=`${w} (${c})`,u.osRelease=""}if(n&&d&&u.osArch&&u.osPlatform){const w=u.osPlatform,c=u.osArch;u.osPlatform=`${w} (${c})`,u.osArch=""}const D=(w,c,x,f,O)=>{y(P=>({...P,totalMemory:w,freeMemory:c,heapTotal:x,heapUsed:f,rss:O}))},j=w=>{y(c=>({...c,cpuUsage:w.toFixed(2)+" %"}))},C=w=>{y(c=>({...c,processCpuUsage:w.toFixed(2)+" %"}))},k=(w,c)=>{y(x=>({...x,systemUptime:w,processUptime:c}))},V=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:t.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const w=c=>{o&&console.log("SystemInfoTable received WebSocket Message:",c),c.method==="memory_update"&&c.response&&c.response.totalMemory&&c.response.freeMemory&&c.response.heapTotal&&c.response.heapUsed&&c.response.rss?(o&&console.log("SystemInfoTable received memory_update",c),D(c.response.totalMemory,c.response.freeMemory,c.response.heapTotal,c.response.heapUsed,c.response.rss)):c.method==="cpu_update"&&c.response&&c.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",c),j(c.response.cpuUsage),C(c.response.processCpuUsage)):c.method==="uptime_update"&&c.response&&c.response.systemUptime&&c.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",c),k(c.response.systemUptime,c.response.processUptime)):c.method==="/api/viewhistorypage"&&c.id===t.current&&c.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return l(w,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{i(w),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,i]);const[A,z]=r.useState(!1);return!u||A?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(je,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"System Information"}),e.jsx(it,{onClose:()=>z(!0),children:e.jsx(G,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:V,children:e.jsx(E,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ie,{path:vo,size:"22px"})})})})]}),e.jsx(kt,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(u).filter(([w,c])=>c!==void 0&&c!=="").map(([w,c],x)=>e.jsxs("tr",{className:x%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:w.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(nn,{value:typeof c!="string"?c.toString():c,maxChars:24})})]},w))})})})]}))}const an=r.memo(sn),Jt={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},ln=n=>{if(!n)return"";const d=n.toString().replace(/[^0-9]/g,"");if(d.length<5)return d;const l=d.slice(0,4),i=d.slice(4,7),a=d.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function dn({id:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(xe),[u,y]=r.useState(null),t=r.useRef(null),D=r.useRef(null),j=r.useRef(h()),{showConfirmCancelDialog:C}=r.useContext(Oe);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${D.current} and matter:`,u),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,D.current&&clearTimeout(D.current),D.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),y(null))},[n,l]),r.useEffect(()=>{const c=x=>{o&&console.log("QRDiv received WebSocket Message:",x),x.method==="refresh_required"&&x.response.changed==="matter"&&x.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${x.response.changed} for storeId "${x.response.matter.id}":`,x.response.matter),t.current===x.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${x.response.matter.id}":`,x.response.matter),D.current&&clearTimeout(D.current),x.response.matter.advertising&&x.response.matter.advertiseTime&&x.response.matter.advertiseTime+9e5<=Date.now()&&(x.response.matter.advertising=!1),y(x.response.matter),x.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${x.response.matter.id}":`,x.response.matter.advertiseTime+9e5-Date.now()),D.current=setTimeout(()=>{D.current&&clearTimeout(D.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),y(f=>f&&{...f,advertising:!1})},x.response.matter.advertiseTime+9e5-Date.now()))))};return i(c,j.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(c),D.current&&clearTimeout(D.current),D.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const k=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${u?.id}"`),u&&l({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,startCommission:!0}})},V=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${u?.id}"`),u&&l({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,stopCommission:!0}})},A=()=>{o&&console.log(`QRDiv sent matter advertise for node "${u?.id}"`),u&&l({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,advertise:!0}})},z=c=>{o&&console.log(`QRDiv sent matter removeFabric for node "${u?.id}" and fabricIndex ${c}`),u&&l({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,removeFabric:c}})},w=async()=>{if(!u||!u.manualPairingCode)return;const c=u.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(c);else{const x=document.createElement("textarea");x.value=c,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.focus(),x.select(),document.execCommand("copy"),document.body.removeChild(x)}o&&console.log("Manual pairing code copied to clipboard")}catch(x){console.error("Failed to copy manual pairing code",x)}};return!u||!d?(o&&console.log("QRDiv rendering undefined state"),null):u.online?u.advertising&&u.qrPairingCode&&u.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(je,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"QR pairing code"}),e.jsxs(it,{children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ie,{path:Bt,size:"22px"})})}),e.jsx(G,{"aria-label":"stop pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Turn off pairing",arrow:!0,children:e.jsx(ie,{path:yo,size:"22px"})})})]})]}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Uo,{value:u.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(mt,{style:{justifyContent:"space-between"},children:[e.jsxs(ht,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",ln(u.manualPairingCode)]}),e.jsx(it,{children:e.jsx(E,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(G,{"aria-label":"copy manual pairing code",size:"small",onClick:w,sx:Jt,children:e.jsx(ie,{path:jo,size:.85})})})})]})]})):u.commissioned&&u.fabricInformations&&u.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(je,{style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"Paired fabrics"}),e.jsxs(it,{children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ie,{path:Bt,size:"22px"})})}),e.jsx(G,{"aria-label":"start pairing",size:"small",onClick:k,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Turn on pairing",arrow:!0,children:e.jsx(ie,{path:Qt,size:"22px"})})})]})]}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(kt,{style:{flexDirection:"column",flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px 0px 10px 0px",gap:"0px"},children:u.fabricInformations.map((c,x)=>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: ",c.fabricIndex]}),e.jsx(E,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(G,{"aria-label":"remove the fabric",size:"small",onClick:()=>C("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>z(c.fabricIndex),()=>{}),sx:{...Jt,padding:"2px"},children:e.jsx(ie,{path:wo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",c.rootVendorId," ",c.rootVendorName]}),c.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",c.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",u.sessionInformations?u.sessionInformations.filter(f=>f.fabric?.fabricIndex===c.fabricIndex&&f.isPeerActive===!0).length:"0"," ","subscriptions: ",u.sessionInformations?u.sessionInformations.filter(f=>f.fabric?.fabricIndex===c.fabricIndex&&f.isPeerActive===!0&&f.numberOfActiveSubscriptions>0).length:"0"]})]},x))}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]})):!u.commissioned&&!u.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(je,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ue,{children:e.jsx(_e,{children:"QR pairing code"})}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ae,{onClick:k,endIcon:e.jsx(ie,{path:Qt,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(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(je,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ue,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(_e,{children:"Server node"})}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ot,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]}))}const cn=r.memo(dn);function un(){const{logMessage:n,sendMessage:d,getUniqueId:l}=r.useContext(xe),[i,a]=r.useState("matterbridge-"),[h,u]=r.useState(!1),[y,t]=r.useState(null),D=r.useRef(l()),j=W=>{W.preventDefault(),u(!0)},C=()=>{u(!1)},k=W=>{W.preventDefault(),u(!1);const g=W.dataTransfer.files[0];if(g){n("Plugins",`Installing package ${g.name}. Please wait...`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(p=>p.text()).then(p=>{n("Plugins",`Server response: ${p}`)}).catch(p=>{console.error("Error uploading plugin file:",p),n("Plugins",`Error installing package ${p}`)})}},V=W=>{const g=W.target.files&&W.target.files[0];if(g){n("Plugins",`Uploading package ${g.name}`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(p=>p.text()).then(p=>{n("Plugins",`Server response: ${p}`)}).catch(p=>{console.error("Error uploading plugin file:",p),n("Plugins",`Error uploading package ${p}`)})}},A=()=>{d({id:D.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},z=()=>{document.getElementById("file-upload")?.click()},w=()=>{d({id:D.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},c=W=>{W.preventDefault(),d({id:D.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:i}})},x=W=>{W.preventDefault(),console.log("Right-clicked Upload button")},f=W=>{W.preventDefault(),console.log("Right-clicked Add button")},O=W=>{t(W.currentTarget)},P=W=>{W!==""&&a(W),t(null)},[S,U]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),S?null:e.jsxs(je,{children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"Install plugins"}),e.jsx(it,{onClose:()=>U(!0)})]}),e.jsxs(kt,{onDragOver:j,onDragLeave:C,onDrop:k,children:[e.jsx(fe,{value:i,onChange:W=>{a(W.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(G,{onClick:O,children:e.jsx(Nr,{})}),e.jsxs(Ye,{id:"simple-menu",anchorEl:y,keepMounted:!0,open:!!y,onClose:()=>P(""),children:[e.jsx(L,{onClick:()=>P("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(L,{onClick:()=>P("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(L,{onClick:()=>P("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(L,{onClick:()=>P("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(L,{onClick:()=>P("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(L,{onClick:()=>P("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(L,{onClick:()=>P("matterbridge-test"),children:"matterbridge-test"}),e.jsx(L,{onClick:()=>P("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(L,{onClick:()=>P("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(L,{onClick:()=>P("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(L,{onClick:()=>P("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(L,{onClick:()=>P("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(L,{onClick:()=>P("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(L,{onClick:()=>P("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(E,{title:"Install or update a plugin from npm",children:e.jsxs(ae,{onClick:A,onContextMenu:c,endIcon:e.jsx(Me,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(E,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ae,{onClick:z,onContextMenu:x,endIcon:e.jsx(Wr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(E,{title:"Add an installed plugin",children:e.jsxs(ae,{onClick:w,onContextMenu:f,endIcon:e.jsx(yt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:V})]})]})}const pn=r.memo(un);function Qe({status:n,enabledText:d="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const h=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?d:l??d});return i!==void 0?e.jsx(E,{title:i,children:h}):h}}function gn(n,d,l){const i=n?.[l],a=d?.[l];return i==null&&a==null?0:i==null?-1:a==null?1:typeof i=="boolean"&&typeof a=="boolean"?i===a?0:i?1:-1:typeof i=="number"&&typeof a=="number"?i-a:String(i).localeCompare(String(a))}function mn({name:n,title:d,columns:l,rows:i,getRowKey:a,footerLeft:h,footerRight:u,onRowClick:y}){const t=r.useRef(new WeakMap),D=r.useRef(1),j=g=>{if(typeof a=="string"&&g&&g[a]!=null)return g[a];if(typeof a=="function"){const b=a(g);if(b!=null)return b}const s=l?.[0]?.id;if(s&&g&&g[s]!=null)return g[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let p=t.current.get(g);return p||(p=`rk_${D.current++}`,t.current.set(g,p)),p},[C,k]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[V,A]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[z,w]=r.useState(!1),[c,x]=r.useState(()=>{try{const g=localStorage.getItem(`${n}_column_visibility`);if(g)return JSON.parse(g)}catch{}return{}}),f=r.useMemo(()=>{const g={};for(const s of l)s.hidden||(g[s.id]=s.required?!0:c[s.id]!==!1);return g},[l,c]),O=r.useMemo(()=>{if(!C||!V)return i;const g=l.find(p=>p.id===C);if(!g||g.noSort)return i;const s=i.map((p,b)=>({el:p,index:b}));return s.sort((p,b)=>{let H;return typeof g.comparator=="function"?H=g.comparator(p.el,b.el):H=gn(p.el,b.el,C),H!==0?V==="asc"?H:-H:p.index-b.index}),s.map(p=>p.el)},[i,C,V,l]),P=g=>{if(C!==g||!C){k(g),A("asc"),localStorage.setItem(`${n}_table_order_by`,g),localStorage.setItem(`${n}_table_order`,"asc");return}if(V==="asc"){A("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}k(null),A(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},S=()=>{w(!z)},U=g=>{x(s=>{const p=l.find(pe=>pe.id===g);if(p&&p.required)return s;const b=f[g]!==!1,H={...s};b?H[g]=!1:delete H[g];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(H))}catch{}return H})},W=()=>{x({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}w(!1)};return o&&console.log(`Rendering table ${n}${C&&V?` ordered by ${C}:${V}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs($e,{open:z,onClose:(g,s)=>{s==="backdropClick"||s==="escapeKeyDown"||S()},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 ${n} columns`})]})}),e.jsx(We,{children:e.jsx(Tr,{children:l.filter(g=>!g.hidden).map(g=>e.jsx(Re,{control:e.jsx(He,{disabled:!!g.required,checked:g.required?!0:f[g.id]!==!1,onChange:()=>U(g.id)}),label:g.label},g.id))})}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:W,children:"Reset"}),e.jsx(ae,{variant:"contained",onClick:g=>{if(g?.currentTarget&&typeof g.currentTarget.blur=="function")try{g.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}S()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),d&&e.jsx("p",{className:"MbfWindowHeaderText",children:d}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(G,{onClick:g=>{if(g?.currentTarget?.blur)try{g.currentTarget.blur()}catch{}S()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(E,{title:`Configure ${n} columns`,children:e.jsx(ie,{path:Co,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":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(g=>{if(g.hidden||!g.required&&f[g.id]===!1)return null;const s=!g.noSort,p=s&&C===g.id&&!!V;return e.jsxs("th",{onClick:s?()=>P(g.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:g.minWidth,maxWidth:g.maxWidth,textAlign:g.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:g.maxWidth?"nowrap":void 0,overflow:g.maxWidth?"hidden":void 0,textOverflow:g.maxWidth?"ellipsis":void 0},"aria-sort":s?p?V==="asc"?"ascending":"descending":"none":void 0,children:[g.label,p&&e.jsxs("span",{style:{marginLeft:6},children:[V==="asc"&&e.jsx(ie,{path:So,size:"15px"}),V==="desc"&&e.jsx(ie,{path:ko,size:"15px"})]})]},g.id)})})}),e.jsx("tbody",{children:O.map((g,s)=>{const p=j(g);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:y?b=>y(g,p,b):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:y?"pointer":void 0},children:l.map(b=>{if(b.hidden||!b.required&&f[b.id]===!1)return null;const H=g[b.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:b.align||"left",padding:"5px 10px",margin:"0",maxWidth:b.maxWidth,whiteSpace:b.maxWidth?"nowrap":void 0,overflow:b.maxWidth?"hidden":void 0,textOverflow:b.maxWidth?"ellipsis":void 0},children:typeof b.render=="function"?b.render(H,p,g,b):typeof H=="boolean"?e.jsx(He,{checked:H,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):b.format&&typeof H=="number"?b.format(H):H!=null?String(H):null},b.id)})},p)})})]})}),(h||u)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:u})]})]})}function hn(n){return r.memo(n)}const St=hn(mn);function Zt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Ge={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Ke={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},fn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},xn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Fe={padding:"0px",margin:"0px"},bn="5px 10px 5px 10px",ft={},ye={},xt={},bt={};let Je=[],Pt=[];const vn=({open:n,onClose:d,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(xe),y=r.useRef(u()),[t,D]=r.useState(l.configJson),[j,C]=r.useState(null),[k,V]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[A,z]=r.useState("");let w={};r.useEffect(()=>{const T=I=>{I.src==="Matterbridge"&&I.dst==="Frontend"&&(Zt(I)&&I.id===y.current&&I.method==="/api/select/devices"&&I.response&&(o&&console.log(`ConfigPluginDialog (id: ${I.id}) received ${I.response.length} /api/select/devices:`,I.response),Je=I.response),Zt(I)&&I.id===y.current&&I.method==="/api/select/entities"&&I.response&&(o&&console.log(`ConfigPluginDialog (id: ${I.id}) received ${I.response.length} /api/select/entities:`,I.response),Pt=I.response))};return a(T,y.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",y.current),t&&j&&j.properties&&(Object.keys(j.properties).forEach(I=>{Object.keys(j.properties[I]).forEach(M=>{M.startsWith("ui:")&&(k[I]={},k[I][M]=j.properties[I][M],delete j.properties[I][M])})}),V(k)),l.name&&l.configJson&&l.schemaJson&&(D(l.configJson),C(l.schemaJson),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{h(T),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,h,j,i,k]);const c=(T,I)=>{w=T.formData},x=T=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",T.formData),D(T.formData),l.configJson=T.formData,l.restartRequired=!0,i({id:y.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.formData.name,formData:T.formData}}),d()};function f(T){const{id:I,label:M,onKeyChange:$,onDropPropertyClick:K,disabled:le,schema:oe,children:ue,registry:me,readonly:_,required:B}=T,{templates:m}=me,{RemoveButton:he}=m.ButtonTemplates;if(!(Yo in oe))return e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ue});const ce=({target:te})=>$(te&&te.value);return e.jsxs(X,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(fe,{id:`${I}-key`,name:`${I}-key`,required:B,disabled:le||_,defaultValue:M,onBlur:_?void 0:ce,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(X,{sx:{flex:1},children:ue}),e.jsx(he,{disabled:le||_,onClick:K(M),registry:me})]})}function O(T){const{children:I,description:M,displayLabel:$,errors:K,help:le,hidden:oe,registry:ue,uiSchema:me}=T,_=Jo(me),B=Zo("WrapIfAdditionalTemplate",ue,_);return oe?e.jsx("div",{style:{display:"none"},children:I}):e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(B,{...T,children:[$===!0&&M,I,K,le]})})}function P(T){const{description:I}=T;return I?e.jsx(de,{sx:Ke,children:I}):null}function S(T){const{required:I,title:M}=T;return M?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(de,{sx:Ge,children:["Title ",M," ",I&&e.jsx("mark",{children:"***"})]})}):null}function U(T){const{help:I}=T;return I?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(de,{sx:fn,children:I})}):null}function W(T){const{errors:I}=T;return I?e.jsxs(X,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(de,{color:"error",sx:xn,children:"Please fix the following errors:"}),e.jsx(rt,{children:I.map((M,$)=>e.jsxs(Fr,{children:[e.jsx(Q,{children:e.jsx(Rr,{color:"error"})}),e.jsx(ee,{primary:M.stack})]},$))})]}):null}function g(T){const{errors:I}=T;return I?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:I.map((M,$)=>e.jsxs(de,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},$))}):null}function s(T){const{id:I,name:M,_schema:$,_uiSchema:K,value:le,options:oe,label:ue,type:me,placeholder:_,required:B,disabled:m,readonly:he,autofocus:re,onChange:ce,onChangeOverride:te,onBlur:ne,onFocus:Pe,_rawErrors:Le,_hideError:tt,_registry:v,_formContext:Y}=T,Se=({target:{value:ke}})=>ce(ke===""?oe.emptyValue:ke),Ve=({target:ke})=>ne(I,ke&&ke.value),st=({target:ke})=>Pe(I,ke&&ke.value);return e.jsx(X,{sx:{padding:"0px",margin:"0px"},children:e.jsx(fe,{id:I,name:I,label:_&&_!==""?ue:void 0,variant:"outlined",placeholder:_&&_!==""?_:ue,required:B,disabled:m||he,autoFocus:re,value:le||le===0?le:"",type:me,autoComplete:me==="password"?"current-password":M,onChange:te||Se,onBlur:Ve,onFocus:st,fullWidth:!0})})}function p(T){return console.log("ArrayFieldTitleTemplate:",T),null}function b(T){return console.log("ArrayFieldDescriptionTemplate:",T),null}function H(T){return console.log("ArrayFieldItemTemplate:",T),null}function pe(T){const{canAdd:I,onAddClick:M,schema:$,title:K}=T,[le,oe]=r.useState(!1),[ue,me]=r.useState(!1),[_,B]=r.useState(!1),[m,he]=r.useState(""),re=v=>{he(v.target.value)},ce=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Je),oe(!le)},te=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Pt),me(!ue)},ne=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Je),B(!_)},Pe=v=>{oe(!1),$.selectFrom==="serial"?$.items.default=v.serial:$.selectFrom==="name"&&($.items.default=v.name),M()},Le=v=>{me(!1),$.selectEntityFrom==="name"?$.items.default=v.name:$.selectEntityFrom==="description"&&($.items.default=v.description),M()},tt=v=>{B(!1),$.selectDeviceEntityFrom==="name"?$.items.default=v.name:$.selectDeviceEntityFrom==="description"&&($.items.default=v.description),M()};return e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(de,{sx:Ge,children:K}),I&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[$.selectFrom&&e.jsx(E,{title:"Add a device from the list",children:e.jsx(G,{onClick:ce,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),$.selectEntityFrom&&e.jsx(E,{title:"Add an entity from the list",children:e.jsx(G,{onClick:te,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),$.selectDeviceEntityFrom&&e.jsx(E,{title:"Add a device entity from the list",children:e.jsx(G,{onClick:ne,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),e.jsx(E,{title:"Add a new item",children:e.jsx(G,{onClick:M,size:"small",color:"primary",sx:Fe,children:e.jsx(yt,{})})})]})]}),$.description&&e.jsx(de,{sx:Ke,children:$.description}),T.items.map(v=>e.jsxs(X,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(X,{sx:{flexGrow:1,marginRight:"10px"},children:v.children}),e.jsx(G,{disabled:!v.hasMoveUp,onClick:v.onReorderClick(v.index,v.index-1),size:"small",color:"primary",sx:Fe,children:e.jsx(Et,{})}),e.jsx(G,{disabled:!v.hasMoveDown,onClick:v.onReorderClick(v.index,v.index+1),size:"small",color:"primary",sx:Fe,children:e.jsx(Vt,{})}),e.jsx(G,{onClick:v.onDropIndexClick(v.index),size:"small",color:"primary",sx:Fe,children:e.jsx(Wt,{})})]},v.index)),e.jsxs($e,{open:le,onClose:ce,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{fullWidth:!0,variant:"outlined",value:m,onChange:re,placeholder:"Enter serial or name"})]}),e.jsx(rt,{dense:!0,children:Je.filter(v=>v.serial.toLowerCase().includes(m.toLowerCase())||v.name.toLowerCase().includes(m.toLowerCase())).map((v,Y)=>e.jsxs(dt,{onClick:()=>Pe(v),sx:ft,children:[v.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:ye})}),v.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),v.icon==="hub"&&e.jsx(Q,{children:e.jsx(ut,{style:ye})}),e.jsx(ee,{primary:v.name,secondary:v.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Y))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:ce,children:"Close"})})]}),e.jsxs($e,{open:ue,onClose:te,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(We,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{fullWidth:!0,variant:"outlined",value:m,onChange:re,placeholder:"Enter name or description"})]}),e.jsx(rt,{dense:!0,children:Pt.filter(v=>v.name.toLowerCase().includes(m.toLowerCase())||v.description.toLowerCase().includes(m.toLowerCase())).map((v,Y)=>e.jsxs(dt,{onClick:()=>Le(v),sx:ft,children:[v.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:ye})}),v.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),v.icon==="hub"&&e.jsx(Q,{children:e.jsx(ut,{style:ye})}),v.icon==="component"&&e.jsx(Q,{children:e.jsx(At,{style:ye})}),v.icon==="matter"&&e.jsx(Q,{children:e.jsx(_t,{style:ye})}),e.jsx(ee,{primary:v.name,secondary:v.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Y))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:te,children:"Close"})})]}),e.jsxs($e,{open:_,onClose:ne,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",K]}),e.jsx(We,{children:e.jsx(rt,{dense:!0,children:Je.filter(v=>v.serial===K||v.name===K).map(v=>v.entities?.map((Y,Se)=>e.jsxs(dt,{onClick:()=>tt(Y),sx:ft,children:[Y.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:ye})}),Y.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),Y.icon==="hub"&&e.jsx(Q,{children:e.jsx(ut,{style:ye})}),Y.icon==="component"&&e.jsx(Q,{children:e.jsx(At,{style:ye})}),Y.icon==="matter"&&e.jsx(Q,{children:e.jsx(_t,{style:ye})}),e.jsx(ee,{primary:Y.name,secondary:Y.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Se)))})}),e.jsx(Ae,{children:e.jsx(ae,{onClick:ne,children:"Close"})})]})]})}function be(T){const{onAddClick:I,schema:M,properties:$,title:K,description:le}=T,[oe,ue]=r.useState(!1),[me,_]=r.useState(""),B=te=>{_(te.target.value)},m=()=>{ue(!oe)},he=te=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${te.serial}" for schema "${M.selectFrom}"`),ue(!1);let ne="";M.selectFrom==="serial"?ne=te.serial:M.selectFrom==="name"&&(ne=te.name),z(ne),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ne}"`),I(M)()},re=()=>{I(M)()},ce=!M.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${ce} newkey "${A}"`),!ce&&A!==""&&(o&&console.log("ObjectFieldTemplate: newkey",A,"properties",$),$.forEach(te=>{if(te.name==="newKey"&&te.content.key==="newKey"&&te.content.props.name==="newKey"&&te.content.props.onKeyChange&&A!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",A);const ne=A;z(""),te.content.props.onKeyChange(ne)}})),e.jsxs(X,{sx:{margin:"0px",padding:ce?"10px":"5px 10px 0px 10px",border:ce?"none":"1px solid grey"},children:[M.title&&ce&&e.jsx(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(de,{sx:Ge,children:M.title})}),K&&!ce&&e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(de,{sx:Ge,children:K}),e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(E,{title:"Add a device from the list",children:e.jsx(G,{onClick:m,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),e.jsx(E,{title:"Add a new item",children:e.jsx(G,{onClick:re,size:"small",color:"primary",sx:Fe,children:e.jsx(yt,{})})})]})]}),M.description&&e.jsx(X,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(de,{sx:Ke,children:M.description})}),$.map(({content:te,name:ne,hidden:Pe})=>!Pe&&e.jsxs(X,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[ne].type)?"0px":bn,border:["object","array","boolean"].includes(M.properties[ne].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[ne].type)&&e.jsx(de,{sx:Ge,children:ne}),e.jsx(X,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:te})]},ne)),e.jsxs($e,{open:oe,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{fullWidth:!0,variant:"outlined",value:me,onChange:B,placeholder:"Enter serial or name"})]}),e.jsx(rt,{dense:!0,children:Je.filter(te=>te.serial.toLowerCase().includes(me.toLowerCase())||te.name.toLowerCase().includes(me.toLowerCase())).map((te,ne)=>e.jsxs(dt,{onClick:()=>he(te),sx:ft,children:[te.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:ye})}),te.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),te.icon==="hub"&&e.jsx(Q,{children:e.jsx(ut,{style:ye})}),e.jsx(ee,{primary:te.name,secondary:te.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ne))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:m,children:"Close"})})]})]})}function se(T){const{uiSchema:I}=T,{submitText:M,norender:$}=Ko(I);return $?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ae,{type:"submit",variant:"contained",color:"primary",children:M}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,children:"Cancel"})]})}function ve(T){const{className:I,disabled:M,onClick:$,registry:K,style:le,uiSchema:oe,...ue}=T;return e.jsx(E,{title:"Remove the item",children:e.jsx(G,{disabled:M,size:"small",color:"primary",onClick:$,children:e.jsx(Wt,{})})})}function R(T){const{className:I,disabled:M,onClick:$,registry:K,uiSchema:le,...oe}=T;return e.jsx(E,{title:"Add an item",children:e.jsx(G,{size:"small",color:"primary",onClick:$,children:e.jsx(yt,{})})})}function q(T){const{disabled:I,onClick:M,registry:$,style:K,uiSchema:le,...oe}=T;return e.jsx(E,{title:"Move up the item",children:e.jsx(G,{size:"small",color:"primary",onClick:M,children:e.jsx(Et,{})})})}function F(T){const{disabled:I,onClick:M,registry:$,style:K,uiSchema:le,...oe}=T;return e.jsx(E,{title:"Move down the item",children:e.jsx(G,{size:"small",color:"primary",onClick:M,children:e.jsx(Vt,{})})})}function J(T){const{id:I,name:M,value:$,schema:K,readonly:le,onChange:oe}=T,[ue,me]=r.useState(),_=m=>{o&&console.log(`CheckboxWidget ${M} onChangeField:`,m),me(m&&m!==""?m:void 0)},B=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${M}" value="${ue}"`),i({id:y.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:M,value:ue,formData:w,id:I}}),K.buttonClose===!0?d():K.buttonSave===!0&&x({formData:t})};return K.buttonText&&K.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(de,{sx:Ke,children:K.description}),e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>B(),children:K.buttonText})]}):K.buttonField&&K.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(de,{sx:Ke,children:K.description}),e.jsx(fe,{id:M+"-input",name:M,label:K.textLabel,placeholder:K.textPlaceholder,onChange:m=>_(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ae,{id:M+"-button",variant:"contained",color:"primary",disabled:ue===void 0,onClick:()=>B(),children:K.buttonField})]}):e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(de,{sx:Ge,children:M}),e.jsx(He,{checked:$,readOnly:le,onChange:()=>oe(!$),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(de,{sx:Ke,children:K.description})]})}function N({schema:T,id:I,name:M,options:$,label:K,hideLabel:le,required:oe,disabled:ue,placeholder:me,readonly:_,value:B,multiple:m,autofocus:he,onChange:re,onBlur:ce,onFocus:te,errorSchema:ne,rawErrors:Pe=[],registry:Le,uiSchema:tt,hideError:v,formContext:Y,...Se}){const{enumOptions:Ve,enumDisabled:st,emptyValue:ke}=$;m=typeof m>"u"?!1:!!m;const Ft=m?[]:"",Rt=typeof B>"u"||m&&B.length<1||!m&&B===Ft,pr=({target:{value:Te}})=>re(Dt(Te,Ve,ke)),gr=({target:Te})=>ce(I,Dt(Te&&Te.value,Ve,ke)),mr=({target:Te})=>te(I,Dt(Te&&Te.value,Ve,ke)),Ht=Qo(B,Ve,m),{InputLabelProps:hr,SelectProps:fr,autocomplete:xr,...br}=Se,vr=!m&&T.default===void 0;return e.jsxs(fe,{id:I,name:I,value:!Rt&&typeof Ht<"u"?Ht:Ft,required:oe,disabled:ue||_,autoFocus:he,autoComplete:xr,placeholder:me,error:Pe.length>0,onChange:pr,onBlur:gr,onFocus:mr,...br,select:!0,InputLabelProps:{...hr,shrink:!Rt},SelectProps:{...fr,multiple:m},"aria-describedby":Go(I),children:[vr&&e.jsx(L,{value:"",children:me}),Array.isArray(Ve)&&Ve.map(({value:Te,label:yr},Ot)=>{const jr=Array.isArray(st)&&st.indexOf(Te)!==-1;return e.jsx(L,{value:String(Ot),disabled:jr,children:yr},Ot)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!j||!t?null:e.jsxs($e,{open:n,onClose:d,slotProps:{paper:{sx:{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(We,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(qo,{schema:j,formData:t,uiSchema:k,validator:Bo,templates:{FieldTemplate:O,BaseInputTemplate:s,TitleFieldTemplate:S,DescriptionFieldTemplate:P,FieldHelpTemplate:U,FieldErrorTemplate:g,ErrorListTemplate:W,WrapIfAdditionalTemplate:f,ArrayFieldTitleTemplate:p,ArrayFieldDescriptionTemplate:b,ArrayFieldItemTemplate:H,ArrayFieldTemplate:pe,ObjectFieldTemplate:be,ButtonTemplates:{SubmitButton:se,RemoveButton:ve,AddButton:R,MoveUpButton:q,MoveDownButton:F}},widgets:{CheckboxWidget:J,SelectWidget:N},onChange:c,onSubmit:x})})]})};function lr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let d=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&d++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(d===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function yn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(xe),{showConfirmCancelDialog:y}=r.useContext(Oe),t=r.useRef(u()),[D,j]=r.useState(null),[C,k]=r.useState(null),[V,A]=r.useState([]),z=[{label:"Name",id:"name",required:!0,render:(F,J,N,T)=>e.jsx(E,{title:`Plugin path ${N.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g(N),children:N.name})})},{label:"Description",id:"description",render:(F,J,N,T)=>e.jsx(E,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g(N),children:N.description})})},{label:"Version",id:"version",render:(F,J,N,T)=>e.jsx(e.Fragment,{children:e.jsx(E,{title:`Plugin v.${N.version}`,children:e.jsx("span",{children:N.version.split("-dev-")[0]+(N.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(F,J,N,T)=>e.jsx(e.Fragment,{children:N.author?N.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(F,J,N,T)=>e.jsx(e.Fragment,{children:N.type?N.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(F,J,N,T)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!N.error&&N.enabled&&e.jsx(E,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:lr(N.matter)},onClick:()=>{N.matter?.id&&d(N.matter?.id)},size:"small",children:e.jsx(er,{})})}),C&&C.bridgeMode==="childbridge"&&!N.error&&N.enabled&&e.jsx(E,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>U(N),size:"small",children:e.jsx(jt,{})})}),e.jsx(E,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{disabled:N.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ve(N),size:"small",children:e.jsx(Hr,{})})}),C&&!C.readOnly&&e.jsx(E,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",N)},size:"small",children:e.jsx(Or,{})})}),N.enabled?e.jsx(E,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",N)},size:"small",children:e.jsx(Vr,{})})}):e.jsx(e.Fragment,{}),N.enabled?e.jsx(e.Fragment,{}):e.jsx(E,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>W(N),size:"small",children:e.jsx(Er,{})})}),e.jsx(E,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>p(N),size:"small",children:e.jsx(tr,{})})}),e.jsx(E,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>b(N),size:"small",children:e.jsx(Tt,{})})}),N.latestVersion!==void 0&&N.latestVersion!==N.version&&C&&!C.readOnly&&e.jsx(E,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>O(N),size:"small",children:e.jsx(Ie,{})})}),N.version.includes("-dev-")&&N.devVersion!==void 0&&N.devVersion!==N.version&&C&&!C.readOnly&&e.jsx(E,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>P(N),size:"small",children:e.jsx(Ie,{})})}),C&&!C.readOnly&&e.jsx(E,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s(N),size:"small",children:e.jsx(rr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(F,J,N,T)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:N.error?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:N.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:N.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:N.loaded&&N.started&&N.configured?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:N.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{status:N.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Qe,{status:N.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Qe,{status:N.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const F=J=>{o&&console.log("HomePlugins received WebSocket Message:",J),J.method==="refresh_required"&&J.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):J.method==="refresh_required"&&J.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and setting matter id ${J.response.matter?.id}`),A(N=>{const T=N.findIndex(M=>M.matter?.id===J.response.matter?.id);if(T<0)return o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and matter id ${J.response.matter?.id} not found`),N;o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} set matter id ${J.response.matter?.id}`);const I=[...N];return I[T]={...I[T],matter:J.response.matter},I})):J.method==="refresh_required"&&J.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),J.id===t.current&&J.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${J.id}) received settings:`,J.response),j(J.response.systemInformation),k(J.response.matterbridgeInformation)):J.id===t.current&&J.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${J.id}) received ${J.response.length} plugins:`,J.response),A(J.response))};return a(F,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{h(F),o&&console.log("HomePlugins removed WebSocket listener")}},[a,h,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const w=r.useRef(null),c=(F,J,N,T)=>{o&&console.log(`handleActionWithConfirmCancel ${N} ${T.name}`),w.current=T,y(F,J,N,x,f)},x=F=>{o&&console.log(`handleConfirm action confirmed ${F} ${w.current?.name}`),F==="remove"&&w.current?S(w.current):F==="disable"&&w.current&&W(w.current),w.current=null},f=F=>{o&&console.log(`handleCancel action canceled ${F} ${w.current?.name}`),w.current=null},O=F=>{o&&console.log("handleUpdatePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name,restart:!1}})},P=F=>{o&&console.log("handleUpdateDevPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name+"@dev",restart:!1}})},S=F=>{o&&console.log("handleRemovePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},U=F=>{o&&console.log("handleRestartPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},W=F=>{o&&console.log("handleEnableDisablePlugin plugin:",F.name,"enabled:",F.enabled),F.enabled===!0?(F.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})):(F.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}}))},g=F=>{o&&console.log(`handleHomepagePlugin plugin: ${F.name} homepage: ${F.homepage}`),F.homepage&&window.open(F.homepage,"_blank")},s=F=>{o&&console.log("handleSponsorPlugin plugin:",F.name,"funding:",F.funding),F.funding&&window.open(F.funding,"_blank")},p=F=>{o&&console.log("handleHelpPlugin plugin:",F.name,"help:",F.help),F.help&&window.open(F.help,"_blank")},b=F=>{o&&console.log("handleChangelogPlugin plugin:",F.name,"changelog:",F.changelog),F.changelog&&window.open(F.changelog,"_blank")},[H,pe]=r.useState(),[be,se]=r.useState(!1),ve=F=>{o&&console.log("handleConfigPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),pe(F),R()},R=()=>{se(!0)},q=()=>{se(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(je,{children:[H&&e.jsx(vn,{open:be,onClose:q,plugin:H}),e.jsx(St,{name:"Plugins",columns:z,rows:V,footerRight:"",footerLeft:""})]}):e.jsx(De,{})}const jn=r.memo(yn),wn=n=>`${n.pluginName}::${n.serial}`;function Cn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(xe),[y,t]=r.useState(!1),[D,j]=r.useState(!0),[C,k]=r.useState(null),[V,A]=r.useState([]),[z,w]=r.useState([]),[c,x]=r.useState([]),[f,O]=r.useState([]),P=r.useRef(u()),S=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(g,s,p,b)=>p.reachable===!0?"Online":p.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(g,s)=>{const p=g.reachable===!0?1:g.reachable===!1?0:-1,b=s.reachable===!0?1:s.reachable===!1?0:-1;return p-b}},{label:"Power",id:"powerSource",render:(g,s,p,b)=>p.powerSource==="ac"||p.powerSource==="dc"?e.jsx(or,{fontSize:"small",sx:{color:"var(--primary-color)"}}):p.powerSource==="ok"?e.jsx(wt,{fontSize:"small",sx:{color:"green"}}):p.powerSource==="warning"?e.jsx(wt,{fontSize:"small",sx:{color:"yellow"}}):p.powerSource==="critical"?e.jsx(wt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl",maxWidth:150},{label:"Actions",id:"selected",required:!0,render:(g,s,p,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[p.matter!==void 0?e.jsx(E,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>d(n===p.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:p.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:lr(p.matter)},children:e.jsx(er,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),p.configUrl?e.jsx(E,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>window.open(p.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(nr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),p.selected!==void 0?e.jsx(E,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(He,{checked:p.selected,onChange:H=>W(H,p),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],U=r.useCallback(g=>{g.selected=void 0;const s=V.find(H=>H.name===g.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${g.pluginName} not found for device ${g.name} `),g.selected;const p=s.schemaJson?.properties?.whiteList?.selectFrom;let b=s.configJson.postfix;return b===""&&(b=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&p&&(g.selected=!0,p==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!0),p==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!1),p==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!1),p==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(g.name)&&(g.selected=!0),p==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(g.name)&&(g.selected=!1),p==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(g.name)&&(g.selected=!1)),g.selected},[V]);r.useEffect(()=>{const g=s=>{if(o&&console.log("HomeDevices received WebSocket Message:",s),s.method==="refresh_required"&&s.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and sending /api/plugins request`),i({id:P.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):s.method==="refresh_required"&&s.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and setting matter id ${s.response.matter?.id}`),O(p=>{const b=p.findIndex(pe=>pe.name.replaceAll(" ","")===s.response.matter?.id);if(b<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),p;const H=[...p];return H[b]={...H[b],matter:s.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and set matter id ${s.response.matter?.id}`),H})):s.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):s.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):s.method==="state_update"&&s.response.plugin&&s.response.serialNumber&&s.response.cluster.includes("BasicInformation")&&s.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${s.response.plugin} serial ${s.response.serialNumber} value ${s.response.value}`),w(p=>{const b=p.findIndex(H=>H.pluginName===s.response.plugin&&H.serial===s.response.serialNumber);return b<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),p):(p[b]={...p[b],reachable:s.response.value},[...p])})),s.id===P.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),k(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===P.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let p=!0;for(const b of s.response)b.enabled===!0&&(b.loaded!==!0||b.started!==!0||b.error===!0)&&(p=!1);if(!p)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),j(!1),A(s.response),w([]),x([]),i({id:P.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const b of s.response)b.enabled===!0&&b.loaded===!0&&b.started===!0&&b.error!==!0&&(i({id:P.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:b.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${b.name}`))}}else if(s.id===P.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const p of s.response)p.selected=U(p);w(s.response)}}else s.id===P.current&&s.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} selectDevices for plugin ${s.response&&s.response.length>0?s.response[0].pluginName:"without select devices"}:`,s.response),s.response&&s.response.length>0&&x(p=>{const b=p.filter(pe=>pe.pluginName!==s.response[0].pluginName),H=s.response.map(pe=>({...pe,selected:U(pe)}));return[...b,...H]}))};return a(g,P.current),o&&console.log(`HomeDevices added WebSocket listener id ${P.current}`),()=>{h(g),o&&console.log("HomeDevices removed WebSocket listener")}},[V,a,h,i,U]),r.useEffect(()=>{if(z.length===0&&c.length===0){O([]);return}o&&console.log(`HomeDevices mixing devices (${z.length}) and selectDevices (${c.length})`);const g=[];for(const s of z)g.push(s);for(const s of c)z.find(p=>p.pluginName===s.pluginName&&p.serial.includes(s.serial))||g.push(s);g.length>0&&(O(g),o&&console.log(`HomeDevices mixed ${g.length} devices and selectDevices`))},[V,z,c,O]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:P.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:P.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const W=(g,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${g.target.checked} for device ${s.name} serial ${s.serial}`),z.findIndex(p=>p.pluginName===s.pluginName&&p.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),O(p=>{const b=p.findIndex(H=>H.pluginName===s.pluginName&&H.serial===s.serial);return b<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),p):(p[b]={...p[b],selected:g.target.checked},[...p])})):w(p=>{const b=p.findIndex(H=>H.pluginName===s.pluginName&&H.serial===s.serial);return b<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),p):(p[b]={...p[b],selected:g.target.checked},[...p])}),g.target.checked?i({id:P.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:P.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(je,{style:{flex:"1 1 auto"},children:e.jsx(St,{name:"Devices",getRowKey:wn,rows:f,columns:S,footerLeft:D?"Waiting for the plugins to fully load...":`Registered devices: ${z.length.toString()}/${f.length.toString()}`,footerRight:y?"Restart required":""})}):e.jsx(De,{})}const Sn=r.memo(Cn);function Mt({children:n,style:d,name:l}){const{setCurrentPage:i}=r.useContext(Oe);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...d},children:n})}const kn=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Mn(){const{messages:n,logAutoScroll:d}=r.useContext(ar),[l,i]=r.useState(!1),a=r.useRef(null),h=r.useRef(0),u=r.useRef(null),y=r.useMemo(()=>kn(),[]),t=k=>i(!0),D=k=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${d} isHovering: ${l}`),d&&!l&&!y){const k=Date.now();k-h.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),h.current=k,a.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a.current?.scrollIntoView({behavior:"smooth"}),h.current=Date.now()},1e3))}},[n,d,l,y]);const j=k=>{switch(k.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},C=k=>{switch(k.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:D,children:[n.map((k,V)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:j(k.level),color:C(k.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:k.level}),k.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+k.time+"]"}),k.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+k.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:k.message})]},V)),e.jsx("div",{ref:a})]})})}const dr=r.memo(Mn);function In(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{online:u}=r.useContext(xe);return o&&console.log("HomeLogs rendering..."),u?e.jsxs(je,{style:{flex:"1 1 auto"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"Logs"}),e.jsxs(_e,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l,'" Scroll: ',a?"auto":"manual"]})]}),e.jsx(kt,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(dr,{})})]}):e.jsx(De,{})}const Dn=r.memo(In);function Pn(){const{online:n}=r.useContext(xe);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(je,{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(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(Ar,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(De,{})}const Ln=r.memo(Pn);function $n({changelog:n}){const{online:d}=r.useContext(xe);return o&&console.log("HomeShowChangelog rendering..."),d?e.jsxs(je,{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(ae,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Tt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(_r,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(De,{})}const Nn=r.memo($n);function Wn(){const[n,d]=r.useState(null),[l,i]=r.useState(null),[a,h]=r.useState([]),[u]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[y,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[D,j]=r.useState(""),[C,k]=r.useState(!1),[V,A]=r.useState(!1),[z,w]=r.useState(null),{addListener:c,removeListener:x,online:f,sendMessage:O,getUniqueId:P}=r.useContext(xe),S=r.useRef(P());return r.useEffect(()=>{const U=W=>{o&&console.log("Home received WebSocket Message:",W),W.method==="refresh_required"&&W.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${W.response.changed} and sending /api/settings request`),w(null),h([]),O({id:S.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),O({id:S.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),W.method==="/api/settings"&&W.id===S.current&&(o&&console.log("Home received settings:",W.response),d(W.response.systemInformation),i(W.response.matterbridgeInformation),W.response.matterbridgeInformation.matterbridgeVersion&&j(`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),A(!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),k(!0)),W.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),W.method==="/api/plugins"&&W.id===S.current&&(o&&console.log("Home received plugins:",W.response),h(W.response))};return c(U,S.current),o&&console.log(`Home added WebSocket listener id ${S.current}`),()=>{x(U),o&&console.log("Home removed WebSocket listener")}},[c,x,O]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${z}`),l?.bridgeMode==="bridge"&&!z&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),w("Matterbridge")),l?.bridgeMode==="childbridge"&&!z&&a){for(const U of a)if(U.matter?.id){o&&console.log(`Home storeId effect set storeId to ${U.matter.id}`),w(U.matter.id);break}}},[l,a,z]),r.useEffect(()=>{f&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),O({id:S.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),O({id:S.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[f,O]),o&&console.log("Home rendering..."),!f||!n||!l?e.jsx(De,{}):e.jsxs(Mt,{name:"Home",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(cn,{id:z}),e.jsx(an,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[V&&e.jsx(Ln,{}),C&&e.jsx(Nn,{changelog:D}),u&&!l.readOnly&&e.jsx(pn,{}),u&&e.jsx(jn,{storeId:z,setStoreId:w}),y==="devices"&&e.jsx(Sn,{storeId:z,setStoreId:w}),y==="logs"&&e.jsx(Dn,{})]})]})}const Tn=r.memo(Wn),vt=!1,Yt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Fn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Rn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Xt={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"},On={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Vn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},En={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},An={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Lt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},_n=[256,257,268,269],zn=[266,267],Un=[259,260,261,271,272],qn=[256,257,268,269,266,267,259,260,261,272];function Z({icon:n,iconColor:d,cluster:l,value:i,unit:a,prefix:h}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),h=h??!1,e.jsxs(X,{sx:Yt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Fn,color:d??"var(--primary-color)"}}),e.jsxs(X,{sx:{...Yt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&h===!0&&e.jsx(de,{sx:Xt,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(de,{sx:Rn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&h===!1&&e.jsx(de,{sx:Xt,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function Bn({device:n,endpoint:d,id:l,deviceType:i,clusters:a}){const h=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let u="";o&&console.log(`Device "${n.name}" endpoint "${d}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${a?.length})`);const y=a.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(y){let t="";y.map(D=>{D.label&&(t+=D.label+" ")}),u=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>u=`${t.attributeLocalValue} mV`),qn.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>u=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>u=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>u=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>u=u+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>u=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>u=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>u=u+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>u=u+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(j=>j.clusterName==="ModeSelect"&&j.attributeName==="currentMode")?.attributeLocalValue;u=a.find(j=>j.clusterName==="ModeSelect"&&j.attributeName==="supportedModes")?.attributeLocalValue?.find(j=>j.mode===t)?.label||"Unknown"}if(i===116){const t=a.find(j=>j.clusterName==="RvcRunMode"&&j.attributeName==="currentMode")?.attributeLocalValue;u=a.find(j=>j.clusterName==="RvcRunMode"&&j.attributeName==="supportedModes")?.attributeLocalValue?.find(j=>j.mode===t)?.label||"Unknown"}return 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&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:t.attributeLocalValue===!0?e.jsx(nt,{}):e.jsx(zr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(Z,{icon:e.jsx(wt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(Z,{icon:e.jsx(or,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),_n.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),zn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Un.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:$o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(zt,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(qr,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(zt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(Z,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(Z,{icon:t.attributeValue==="1"?e.jsx(Qr,{}):e.jsx(Gr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Z,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(Z,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Z,{icon:e.jsx(Ut,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Z,{icon:e.jsx(Ut,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Kt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:Kt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(Z,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:h[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(ie,{path:zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(no,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:t.attributeValue==="true"?e.jsx(io,{}):e.jsx(so,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(Z,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(ao,{}):e.jsx(lo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(co,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(Z,{icon:e.jsx(uo,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(X,{sx:Hn,children:e.jsx(de,{sx:On,children:u})}),e.jsx(X,{sx:Vn,children:e.jsx(de,{sx:En,children:n.name})}),e.jsxs(X,{sx:An,children:[o&&e.jsx(de,{sx:Lt,children:d}),e.jsx(de,{sx:Lt,children:l}),o&&e.jsxs(de,{sx:Lt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Qn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(xe),[u,y]=r.useState([]),[t,D]=r.useState({}),[j,C]=r.useState({}),[k,V]=r.useState({}),A=r.useRef(h()),z=r.useCallback(x=>{(o||vt)&&console.log(`DevicesIcons received state_update "${x.response.cluster}.${x.response.attribute}" for "${x.response.id}:${x.response.number}": "${x.response.value}"`,x.response);const f=u.find(P=>P.pluginName===x.response.plugin&&P.serial===x.response.serialNumber);if(!f){(o||vt)&&console.warn(`DevicesIcons updater device of plugin "${x.response.plugin}" serial "${x.response.serialNumber}" number "${x.response.number}" id "${x.response.id}" not found in devices(${u.length})`);return}const O=k[f.serial]?.find(P=>P.endpoint===x.response.number.toString()&&P.clusterName===x.response.cluster&&P.attributeName===x.response.attribute);if(!O){(o||vt)&&console.warn(`DevicesIcons updater device "${f.name}" serial "${f.serial}" cluster "${x.response.cluster}" attribute "${x.response.attribute}" not found in clusters(${k[f.serial]?.length})`);return}O.attributeValue=String(x.response.value),O.attributeLocalValue=x.response.value,V({...k}),(o||vt)&&console.log(`DevicesIcons updated "${O.clusterName}.${O.attributeName}" for device "${f.name}" serial "${f.serial}" to "${O.attributeValue}"`)},[k,u]),w=r.useCallback(x=>{if(o&&console.log(`DevicesIcons received for device "${x.response.deviceName}" serial "${x.response.serialNumber}" deviceTypes (${x.response.deviceTypes.length}) "${x.response.deviceTypes.join(",")}" clusters (${x.response.clusters.length}):`,x.response),x.response.clusters.length===0)return;const f=x.response.serialNumber;t[f]=[],j[f]=x.response.deviceTypes,k[f]=[];for(const O of x.response.clusters)t[f].find(P=>P.endpoint===O.endpoint)||t[f].push({endpoint:O.endpoint,id:O.id,deviceTypes:O.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(O.clusterName)&&k[f].push(O);D({...t}),C({...j}),V({...k}),o&&console.log(`DevicesIcons endpoints for "${f}":`,t[f]),o&&console.log(`DevicesIcons deviceTypes for "${f}":`,j[f]),o&&console.log(`DevicesIcons clusters for "${f}":`,k[f])},[k,j,t]);r.useEffect(()=>{const x=f=>{if(o&&console.log("DevicesIcons received WebSocket Message:",f),f.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${f.response.changed} and sending api requests`),l({id:A.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(f.method==="state_update"&&f.response)z(f);else if(f.method==="/api/devices"&&f.response){o&&console.log(`DevicesIcons received ${f.response.length} devices:`,f.response),y(f.response),D({}),C({}),V({});for(const O of f.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:A.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:O.pluginName,endpoint:O.endpoint||0}})}else f.method==="/api/clusters"&&f.response&&w(f)};return i(x,A.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(x),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[u]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),d&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:A.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[d,l]);const c=r.memo(Bn);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:u.filter(x=>x.name.toLowerCase().includes(n)||x.serial.toLowerCase().includes(n)).map(x=>t[x.serial]&&t[x.serial].map(f=>f.deviceTypes.map(O=>e.jsx(c,{device:x,endpoint:f.endpoint,id:f.id,deviceType:O,clusters:k[x.serial].filter(P=>P.endpoint===f.endpoint)},`${x.pluginName}-${x.uniqueId}-${f.endpoint}-${f.id}-${O.toString()}`))))})}const Gn=r.memo(Qn),Kn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,d,l,i)=>l.configUrl?e.jsx(G,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(nr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Jn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,d,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(n,d,l,i)=>e.jsx(E,{title:String(n),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(n)})})}],Zn=n=>`${n.pluginName}::${n.uniqueId}`,Yn=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Xn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(xe),[u,y]=r.useState([]),[t,D]=r.useState(u),[j,C]=r.useState([]),[k,V]=r.useState(0),[A,z]=r.useState(null),[w,c]=r.useState(null),[x,f]=r.useState(null),[O,P]=r.useState(null),S=r.useRef(h()),U=r.useRef(t),W=r.useCallback(s=>{o&&console.log(`DevicesTable received state_update "${s.response.cluster}.${s.response.attribute}" for "${s.response.id}:${s.response.number}": "${s.response.value}"`,s.response);const p=U.current.find(b=>b.pluginName===s.response.plugin&&b.uniqueId===s.response.uniqueId);if(!p){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(A&&w&&p.pluginName===A&&p.uniqueId===O&&s.response.number.toString()===w){const b=j.find(H=>H.endpoint===s.response.number.toString()&&H.clusterName===s.response.cluster&&H.attributeName===s.response.attribute);if(!b){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${p.name}" serial "${p.serial}" not found in clusters`);return}b.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),b.attributeLocalValue=s.response.value,C([...j]),o&&console.log(`DevicesTable updated attribute ${b.clusterName}.${b.attributeName} for device "${p.name}" serial "${p.serial}" to "${b.attributeValue}"`)}},[j,w,A,O]);r.useEffect(()=>{const s=p=>{if(o&&console.log("DevicesTable received WebSocket Message:",p),p.method==="refresh_required"&&p.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${p.response.changed} and sending /api/devices request`),l({id:S.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(p.method==="state_update"&&p.response)W(p);else if(p.method==="/api/devices")o&&console.log(`DevicesTable received ${p.response.length} devices:`,p.response),y(p.response);else if(p.method==="/api/clusters"){o&&console.log(`DevicesTable received ${p.response.clusters.length} clusters for plugin ${p.response.plugin}:`,p.response),C(p.response.clusters);const b={};for(const H of p.response.clusters)o&&console.log("Cluster:",H.endpoint),b[H.endpoint]?b[H.endpoint]++:b[H.endpoint]=1;V(Object.keys(b).length)}};return i(s,S.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,W]),r.useEffect(()=>{d&&(o&&console.log("DevicesTable sending api requests with id ",S.current),l({id:S.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:S.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:S.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,l]),r.useEffect(()=>{A&&w&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:S.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:A,endpoint:Number(w)}}))},[A,w,l]),r.useEffect(()=>{if(n===""){D(u),U.current=u;return}const s=u.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n));D(s),U.current=s},[u,n]);const g=s=>{if(s.uniqueId===O){P(null),z(null),c(null),f(null);return}P(s.uniqueId),z(s.pluginName),c(s.endpoint?s.endpoint.toString():null),f(s.name)};return o&&console.log("DevicesTable rendering..."),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${A&&w?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Registered devices",getRowKey:Zn,onRowClick:g,rows:t,columns:Kn,footerLeft:`Total devices: ${t.length.toString()}`})}),A&&w&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Clusters",title:x||"",getRowKey:Yn,rows:j,columns:Jn,footerLeft:`Total child endpoints: ${k-1}`})})]}):e.jsx(De,{})}const ei=r.memo(Xn);function ti(){const{online:n}=r.useContext(xe),[d,l]=r.useState(""),[i,a]=r.useState("icon");r.useEffect(()=>{const y=localStorage.getItem("devicesFilter");y&&l(y)},[]),r.useEffect(()=>{const y=localStorage.getItem("devicesViewMode");y&&a(y)},[]);const h=y=>{l(y.target.value.toLowerCase()),localStorage.setItem("devicesFilter",y.target.value.toLowerCase())},u=y=>{a(y),localStorage.setItem("devicesViewMode",y)};return o&&console.log("Devices rendering..."),n?e.jsxs(Mt,{name:"Devices",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(de,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{variant:"outlined",value:d,onChange:h,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(de,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(G,{onClick:()=>u("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(E,{title:"Table View",children:e.jsx(po,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(G,{onClick:()=>u("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(E,{title:"Icon View (beta)",children:e.jsx(go,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(ei,{filter:d}),i==="icon"&&e.jsx(Gn,{filter:d})]}):e.jsx(De,{})}const ri=r.memo(ti);function oi(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:u,setLogFilterLevel:y,setLogFilterSearch:t,online:D,setLogAutoScroll:j,filterLogMessages:C}=r.useContext(xe),k=w=>{d(w.target.value),y(w.target.value),C(w.target.value,l),localStorage.setItem("logFilterLevel",w.target.value),o&&console.log("handleChangeLevel called with value:",w.target.value)},V=w=>{i(w.target.value),t(w.target.value),C(n,w.target.value),localStorage.setItem("logFilterSearch",w.target.value),o&&console.log("handleChangeSearch called with value:",w.target.value)},A=w=>{h(w.target.checked),j(w.target.checked),C(n,l),localStorage.setItem("logAutoScroll",w.target.checked?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",w.target.checked)},z=()=>{o&&console.log("handleClearLogsClick called"),u([])};return o&&console.log("Logs rendering..."),D?e.jsxs(Mt,{name:"Logs",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(qt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:k,children:[e.jsx(L,{value:"debug",children:"Debug"}),e.jsx(L,{value:"info",children:"Info"}),e.jsx(L,{value:"notice",children:"Notice"}),e.jsx(L,{value:"warn",children:"Warn"}),e.jsx(L,{value:"error",children:"Error"}),e.jsx(L,{value:"fatal",children:"Fatal"})]}),e.jsx(qt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(fe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:V,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Re,{control:e.jsx(He,{checked:a,onChange:A}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(E,{title:"Clear the logs",children:e.jsx(ae,{onClick:z,endIcon:e.jsx(Wt,{}),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(dr,{})})]}):e.jsx(De,{})}const ni=r.memo(oi),ii=({open:n,ip:d,onClose:l,onSave:i})=>{const a=d?d.split(".").slice(0,3).join(".")+".1":"",[h,u]=r.useState("dhcp"),[y,t]=r.useState({ip:d??"",subnet:"255.255.255.0",gateway:a,dns:a}),D=k=>V=>{t({...y,[k]:V.target.value})},j=()=>{l()},C=()=>{i({type:h,...y}),l()};return e.jsxs($e,{open:n,onClose:(k,V)=>{V==="backdropClick"||V==="escapeKeyDown"||l()},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(We,{dividers:!0,children:[e.jsxs(ir,{component:"fieldset",fullWidth:!0,children:[e.jsx(we,{component:"legend",children:"Select IP Configuration"}),e.jsxs(sr,{row:!0,value:h,onChange:k=>u(k.target.value),children:[e.jsx(Re,{value:"dhcp",control:e.jsx(Ct,{}),label:"DHCP"}),e.jsx(Re,{value:"static",control:e.jsx(Ct,{}),label:"Static"})]})]}),h==="static"&&e.jsxs(Ee,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ee,{size:6,children:e.jsx(fe,{label:"IP Address",fullWidth:!0,value:y.ip,onChange:D("ip")})}),e.jsx(Ee,{size:6,children:e.jsx(fe,{label:"Subnet Mask",fullWidth:!0,value:y.subnet,onChange:D("subnet")})}),e.jsx(Ee,{size:6,children:e.jsx(fe,{label:"Gateway",fullWidth:!0,value:y.gateway,onChange:D("gateway")})}),e.jsx(Ee,{size:6,children:e.jsx(fe,{label:"DNS Server",fullWidth:!0,value:y.dns,onChange:D("dns")})})]})]}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:j,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:C,children:"Save"})]})]})},si=({open:n,onClose:d,onSave:l})=>{const[i,a]=r.useState(""),[h,u]=r.useState(""),y=V=>{a(V.target.value)},t=V=>{u(V.target.value)},D=i.length>0&&i===h,j=()=>{d()},C=()=>{D&&(l(i),d())},k=()=>{l(""),d()};return e.jsxs($e,{open:n,onClose:(V,A)=>{A==="backdropClick"||A==="escapeKeyDown"||d()},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(We,{dividers:!0,children:e.jsx(ir,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Ee,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ee,{size:12,children:e.jsx(fe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:y})}),e.jsx(Ee,{size:12,children:e.jsx(fe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:h,onChange:t,error:h!==""&&i!==h,helperText:h!==""&&i!==h?"Passwords do not match":""})})]})})}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:j,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:C,disabled:!D,children:"Change"}),e.jsx(ae,{variant:"contained",onClick:k,children:"Reset"})]})]})};function Ze(n=1e3){let d=null;const l=(i=>{d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{i(),d=null},n)});return l.cancel=()=>{d!==null&&(window.clearTimeout(d),d=null)},l}const ge=500;function ai(){const{online:n,addListener:d,removeListener:l,sendMessage:i,getUniqueId:a}=r.useContext(xe),[h,u]=r.useState(null),[y,t]=r.useState(null),D=r.useRef(a());return r.useEffect(()=>{const j=C=>{o&&console.log("Settings received WebSocket Message:",C),C.method==="refresh_required"&&C.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${C.response.changed} and sending /api/settings request`),i({id:D.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):C.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",C.response),u(C.response.matterbridgeInformation),t(C.response.systemInformation))};return d(j,D.current),o&&console.log("Settings added WebSocket listener"),()=>{l(j),o&&console.log("Settings removed WebSocket listener")}},[d,l,i]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),i({id:D.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,i]),o&&console.log("Settings rendering..."),!n||!h||!y?e.jsx(De,{}):e.jsx(Mt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(li,{matterbridgeInfo:h,systemInfo:y}),e.jsx(di,{matterbridgeInfo:h}),e.jsx(ci,{matterbridgeInfo:h}),e.jsx(ui,{systemInfo:y})]})})}function li({matterbridgeInfo:n,systemInfo:d}){const{sendMessage:l,getUniqueId:i}=r.useContext(xe),[a,h]=r.useState("bridge"),[u,y]=r.useState("Info"),[t,D]=r.useState(!1),[j,C]=r.useState("dark"),[k,V]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[A,z]=r.useState(localStorage.getItem("homePageMode")??"devices"),[w,c]=r.useState(localStorage.getItem("virtualMode")??"outlet"),x=r.useRef(i()),[f,O]=r.useState(!1),P=()=>O(!1),S=R=>{o&&console.log("handleSaveNetConfig called with config:",R),l({id:x.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:R})},[U,W]=r.useState(!1),g=()=>W(!1),s=R=>{o&&console.log("handleSaveChangePassword called with password:",R),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:R}}),Ci(R)};r.useEffect(()=>{n&&(h(n.bridgeMode==="bridge"?"bridge":"childbridge"),y(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),D(n.fileLogger),c(n.virtualMode))},[n]),r.useEffect(()=>{const R=localStorage.getItem("frontendTheme");R&&C(R)},[]);const p=R=>{o&&console.log("handleChangeBridgeMode called with value:",R.target.value),h(R.target.value),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:R.target.value}})},b=R=>{o&&console.log("handleChangeMbLoggerLevel called with value:",R.target.value),y(R.target.value),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:R.target.value}})},H=R=>{o&&console.log("handleLogOnFileMbChange called with value:",R.target.checked),D(R.target.checked),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:R.target.checked}})},pe=R=>{const q=R.target.value;o&&console.log("handleChangeTheme called with value:",q),C(q),localStorage.setItem("frontendTheme",q),document.body.setAttribute("frontend-theme",q)},be=R=>{const q=R.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",q),V(q),localStorage.setItem("homePagePlugins",q?"true":"false")},se=R=>{const q=R.target.value;o&&console.log("handleChangeHomePageMode called with value:",q),z(q),localStorage.setItem("homePageMode",q)},ve=R=>{const q=R.target.value;o&&console.log("handleChangeVirtualMode called with value:",q),c(q),localStorage.setItem("virtualMode",q),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:q}})};return!n||!d?null:e.jsxs(je,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(ii,{open:f,ip:d.ipv4Address,onClose:P,onSave:S}),e.jsx(si,{open:U,onClose:g,onSave:s}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ge-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(sr,{row:!0,name:"mode-buttons-group",value:a,onChange:p,children:[e.jsx(Re,{value:"bridge",control:e.jsx(Ct,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Re,{value:"childbridge",control:e.jsx(Ct,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:u,onChange:b,children:[e.jsx(L,{value:"Debug",children:"Debug"}),e.jsx(L,{value:"Info",children:"Info"}),e.jsx(L,{value:"Notice",children:"Notice"}),e.jsx(L,{value:"Warn",children:"Warn"}),e.jsx(L,{value:"Error",children:"Error"}),e.jsx(L,{value:"Fatal",children:"Fatal"})]}),e.jsx(Re,{style:{padding:"0px",margin:"0px"},control:e.jsx(He,{checked:t,onChange:H,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:j,onChange:pe,children:[e.jsx(L,{value:"classic",children:"Classic"}),e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(He,{checked:k,onChange:be,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:A,onChange:se,children:[e.jsx(L,{value:"logs",children:"Logs"}),e.jsx(L,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:w,onChange:ve,children:[e.jsx(L,{value:"disabled",children:"Disabled"}),e.jsx(L,{value:"outlet",children:"Outlet"}),e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"switch",children:"Switch"}),e.jsx(L,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>W(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>O(!0),children:"Configure IP"})})]})})]})}function di({matterbridgeInfo:n}){const{sendMessage:d,getUniqueId:l}=r.useContext(xe),[i,a]=r.useState("Info"),[h,u]=r.useState(!1),[y,t]=r.useState(""),[D,j]=r.useState(""),[C,k]=r.useState(""),[V,A]=r.useState(""),[z,w]=r.useState(""),[c,x]=r.useState(""),f=r.useRef(l()),O=r.useMemo(()=>Ze(1e3),[]),P=r.useMemo(()=>Ze(1e3),[]),S=r.useMemo(()=>Ze(1e3),[]),U=r.useMemo(()=>Ze(1e3),[]),W=r.useMemo(()=>Ze(1e3),[]),g=r.useMemo(()=>Ze(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),u(n.matterFileLogger),t(n.matterMdnsInterface||""),j(n.matterIpv4Address||""),k(n.matterIpv6Address||""),A(n.matterPort?n.matterPort.toString():""),w(n.matterDiscriminator?n.matterDiscriminator.toString():""),x(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>O.cancel(),[O]),r.useEffect(()=>()=>P.cancel(),[P]),r.useEffect(()=>()=>S.cancel(),[S]),r.useEffect(()=>()=>U.cancel(),[U]),r.useEffect(()=>()=>W.cancel(),[W]),r.useEffect(()=>()=>g.cancel(),[g]);const s=R=>{o&&console.log("handleChangeMjLoggerLevel called with value:",R.target.value),a(R.target.value),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:R.target.value}})},p=R=>{o&&console.log("handleLogOnFileMjChange called with value:",R.target.checked),u(R.target.checked),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:R.target.checked}})},b=R=>{o&&console.log("handleChangeMdnsInterface called with value:",R.target.value);const q=R.target.value;t(q),O(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",q),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:q}})})},H=R=>{o&&console.log("handleChangeIpv4Address called with value:",R.target.value);const q=R.target.value;j(q),P(()=>{o&&console.log("debounced sendMessage setipv4address with value:",q),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:q}})})},pe=R=>{o&&console.log("handleChangeIpv6Address called with value:",R.target.value);const q=R.target.value;k(q),S(()=>{o&&console.log("debounced sendMessage setipv6address with value:",q),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:q}})})},be=R=>{o&&console.log("handleChangeMatterPort called with value:",R.target.value);const q=R.target.value;A(q),U(()=>{o&&console.log("debounced sendMessage setmatterport with value:",q),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:q}})})},se=R=>{o&&console.log("handleChangeMatterDiscriminator called with value:",R.target.value);const q=R.target.value;w(q),W(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",q),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:q}})})},ve=R=>{o&&console.log("handleChangemMatterPasscode called with value:",R.target.value);const q=R.target.value;x(q),g(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",q),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:q}})})};return n?e.jsxs(je,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ge-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:s,children:[e.jsx(L,{value:"Debug",children:"Debug"}),e.jsx(L,{value:"Info",children:"Info"}),e.jsx(L,{value:"Notice",children:"Notice"}),e.jsx(L,{value:"Warn",children:"Warn"}),e.jsx(L,{value:"Error",children:"Error"}),e.jsx(L,{value:"Fatal",children:"Fatal"})]}),e.jsx(Re,{style:{padding:"0px",margin:"0px"},control:e.jsx(He,{checked:h,onChange:p,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(fe,{value:y,onChange:b,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(fe,{value:D,onChange:H,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(fe,{value:C,onChange:pe,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(fe,{value:V,onChange:be,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(fe,{value:z,onChange:se,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(fe,{value:c,onChange:ve,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function ci({matterbridgeInfo:n}){return n?e.jsxs(je,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(Ce,{value:n.matterbridgeVersion,label:"Current Version",width:ge}),e.jsx(Ce,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ge}),e.jsx(Ce,{value:n.rootDirectory,label:"Root Directory",width:ge}),e.jsx(Ce,{value:n.homeDirectory,label:"Home Directory",width:ge}),e.jsx(Ce,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ge}),e.jsx(Ce,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ge}),e.jsx(Ce,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ge})]})})]}):null}function ui({systemInfo:n}){return n?e.jsxs(je,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(Ce,{value:n.interfaceName,label:"Interface name",width:ge}),e.jsx(Ce,{value:n.macAddress,label:"MAC Address",width:ge}),e.jsx(Ce,{value:n.ipv4Address,label:"IPv4 Address",width:ge}),e.jsx(Ce,{value:n.ipv6Address,label:"IPv6 Address",width:ge}),e.jsx(Ce,{value:n.nodeVersion,label:"Node Version",width:ge}),e.jsx(Ce,{value:n.hostname,label:"Hostname",width:ge}),e.jsx(Ce,{value:n.user,label:"User",width:ge})]})})]}):null}function Ce({value:n,label:d,width:l}){return e.jsx(fe,{focused:!0,value:n,size:"small",label:d,variant:"standard",sx:{width:l?`${l-20}px`:"400px","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const pi=r.memo(ai);function gi(){const{online:n,sendMessage:d,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(xe),{showSnackbarMessage:h}=r.useContext(Oe),[u,y]=r.useState(null),[t,D]=r.useState([]),[j,C]=r.useState([]),[k,V]=r.useState(null),[A,z]=r.useState({cpuUsage:0}),[w,c]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[x,f]=r.useState({systemUptime:"",processUptime:""}),O=r.useRef(a());return o&&console.log("Test uniqueId:",O),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const P=S=>{if(S.method==="restart_required")o&&console.log("Test received restart_required"),h("Restart required",0);else if(S.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${S.response.changed} and sending api requests`),h("Refresh required",0),d({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(S.method==="memory_update")o&&console.log("Test received memory_update",S),c(S.response);else if(S.method==="cpu_update")o&&console.log("Test received cpu_update",S),z(S.response);else if(S.method==="uptime_update")o&&console.log("Test received uptime_update",S),f(S.response);else if(S.method==="/api/settings"&&S.response)o&&console.log("Test received /api/settings:",S.response),h("Test received /api/settings",0),y(S.response);else if(S.method==="/api/plugins"&&S.response)o&&console.log(`Test received ${S.response.length} plugins:`,S.response),h("Test received /api/plugins",0),D(S.response);else if(S.method==="/api/devices"&&S.response){o&&console.log(`Test received ${S.response.length} devices:`,S.response),h("Test received /api/devices",0),C(S.response);for(const U of S.response)o&&console.log("Test sending /api/clusters for device:",U.pluginName,U.name,U.endpoint),d({id:O.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:U.pluginName,endpoint:U.endpoint||0}})}else S.method==="/api/clusters"&&S.response&&(o&&console.log(`Test received ${S.response.clusters.length} clusters for device ${S.response.deviceName} endpoint ${S.response.id}:${S.response.number}:`,S),h(`Test received /api/clusters for ${S.response.plugin}::${S.response.deviceName}`,0),V(S.response))};return l(P,O.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(P),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,d,h]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,d,h]),o&&console.log("Test rendering..."),n?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(De,{})}const mi=r.memo(gi);function hi(n,d){o&&console.log("getCssVariable:",n,"defaultValue",d);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||d}function fi(n){return mo({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function xi(){const{mobile:n,showSnackbarMessage:d,showConfirmCancelDialog:l}=r.useContext(Oe),{online:i,sendMessage:a,logMessage:h,addListener:u,removeListener:y,getUniqueId:t}=r.useContext(xe),[D,j]=r.useState(!1),[C,k]=r.useState(!1),[V,A]=r.useState(!1),[z,w]=r.useState(!1),[c,x]=r.useState(null),f=r.useRef(t()),[O,P]=r.useState(null),[S,U]=r.useState(null),[W,g]=r.useState(null),[s,p]=r.useState(null),[b,H]=r.useState(null),pe=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},be=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},se=()=>{c?.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")},ve=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},R=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},q=()=>{a({id:f.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},F=()=>{a({id:f.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},J=()=>{a({id:f.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},N=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),h("Matterbridge","Installing system updates..."),a({id:f.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),h("Matterbridge","Installing software updates..."),a({id:f.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},I=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:f.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),h("Matterbridge","Downloading Shelly system log..."),d("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},$=()=>{c?.matterbridgeInformation.restartMode===""?a({id:f.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:f.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},K=()=>{a({id:f.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{a({id:f.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},oe=()=>{a({id:f.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ue=()=>{a({id:f.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},me=v=>{P(v.currentTarget)},_=v=>{o&&console.log("Header: handleMenuClose",v),P(null),v==="download-mblog"?(h("Matterbridge","Downloading matterbridge log..."),d("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):v==="download-mjlog"?(h("Matterbridge","Downloading matter log..."),d("Downloading matter log...",5),window.location.href="./api/download-mjlog"):v==="view-mblog"?(h("Matterbridge","Loading matterbridge log..."),d("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):v==="view-mjlog"?(h("Matterbridge","Loading matter log..."),d("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):v==="view-diagnostic"?(h("Matterbridge","Loading diagnostic log..."),d("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):v==="download-diagnostic"?(h("Matterbridge","Downloading diagnostic log..."),d("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):v==="view-history"?a({id:f.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):v==="download-history"?a({id:f.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):v==="view-shellylog"?(h("Matterbridge","Loading shelly system log..."),d("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):v==="download-mbstorage"?(h("Matterbridge","Downloading matterbridge storage..."),d("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):v==="download-pluginstorage"?(h("Matterbridge","Downloading matterbridge plugins storage..."),d("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):v==="download-pluginconfig"?(h("Matterbridge","Downloading matterbridge plugins config..."),d("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):v==="download-mjstorage"?(h("Matterbridge","Downloading matter storage..."),d("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):v==="download-backup"?(h("Matterbridge","Downloading backup..."),d("Downloading backup...",10),window.location.href="./api/download-backup"):v==="update"?q():v==="updatedev"?F():v==="updatecheck"?J():v==="shelly-sys-update"?N():v==="shelly-main-update"?T():v==="shelly-create-system-log"?I():v==="shelly-download-system-log"?M():v==="softreset"?oe():v==="hardreset"?ue():v==="restart"?$():v==="shutdown"?K():v==="reboot"?le():v==="create-backup"?a({id:f.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):v==="unregister"?a({id:f.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):v==="reset"?a({id:f.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):v==="factoryreset"&&a({id:f.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},B=v=>{o&&console.log("Header: handleMenuCloseCancel:",v),P(null)},m=v=>{U(v.currentTarget)},he=()=>{U(null)},re=v=>{g(v.currentTarget)},ce=()=>{g(null)},te=v=>{p(v.currentTarget)},ne=()=>{p(null)},Pe=v=>{H(v.currentTarget)},Le=()=>{H(null)},tt=()=>{ji(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const v=Y=>{o&&console.log("Header received WebSocket Message:",Y),Y.method==="/api/settings"&&Y.id===f.current?(o&&console.log("Header received settings:",Y.response),x(Y.response),j(Y.response.matterbridgeInformation.restartRequired||Y.response.matterbridgeInformation.fixedRestartRequired),k(Y.response.matterbridgeInformation.fixedRestartRequired),A(Y.response.matterbridgeInformation.updateRequired)):Y.method==="refresh_required"&&Y.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${Y.response.changed} and sending /api/settings request`),a({id:f.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):Y.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${Y.response.fixed}`),j(!0),Y.response.fixed===!0&&k(!0)):Y.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),j(!1)):Y.method==="update_required"?(o&&console.log("Header received update_required"),Y.response.devVersion===!0?w(!0):A(!0),a({id:f.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):Y.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),x(Se=>Se?{matterbridgeInformation:{...Se.matterbridgeInformation,shellySysUpdate:Y.response.available},systemInformation:Se.systemInformation}:null)):Y.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),x(Se=>Se?{matterbridgeInformation:{...Se.matterbridgeInformation,shellyMainUpdate:Y.response.available},systemInformation:Se.systemInformation}:null)):Y.method==="/api/viewhistorypage"&&Y.id===f.current&&Y.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):Y.method==="/api/downloadhistorypage"&&Y.id===f.current&&Y.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return u(v,f.current),o&&console.log(`Header added WebSocket listener id ${f.current}`),()=>{y(v),o&&console.log("Header removed WebSocket listener")}},[u,y,a,d]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:f.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:f.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!c?null:e.jsxs("div",{className:"header",style:{},children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:tt}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(at,{to:"/",className:"nav-link",children:"Home"}),e.jsx(at,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(at,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(at,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!c.matterbridgeInformation.readOnly&&e.jsx(E,{title:`Matterbridge v.${c.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",c.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(c.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),c.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),c.matterbridgeInformation.bridgeMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.bridgeMode})}):null,c.matterbridgeInformation.restartMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.restartMode})}):null,c.matterbridgeInformation.profile&&c.matterbridgeInformation.profile!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:ve})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Give a star to Matterbridge",children:e.jsx(G,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:R,children:e.jsx(ho,{})})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Sponsor Matterbridge",children:e.jsx(G,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:pe,children:e.jsx(rr,{})})}):null,e.jsx(E,{title:"Matterbridge help",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:be,children:e.jsx(tr,{})})}),e.jsx(E,{title:"Matterbridge changelog",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:se,children:e.jsx(Tt,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&V&&e.jsx(E,{title:`Update matterbridge to latest version v.${c.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(G,{style:{color:V?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:q,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&z&&e.jsx(E,{title:`Update matterbridge to latest dev version v.${c.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(G,{style:{color:z?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:F,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsx(E,{title:"Shelly system update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:N,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsx(E,{title:"Shelly software update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:T,children:e.jsx(Ie,{})})}),e.jsx(E,{title:"Restart matterbridge",children:e.jsx(G,{style:{color:D||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:$,children:e.jsx(jt,{})})}),c.matterbridgeInformation.restartMode===""?e.jsx(E,{title:"Shut down matterbridge",children:e.jsx(G,{style:{color:D||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(ze,{})})}):null,e.jsx(E,{title:"Download, backup and more",children:e.jsx(G,{onClick:me,children:e.jsx(fo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ye,{id:"command-menu",anchorEl:O,keepMounted:!0,open:!!O,onClose:()=>_(""),children:[c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>_("update"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>_("updatedev"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>_("updatecheck"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsxs(L,{onClick:()=>_("shelly-sys-update"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsxs(L,{onClick:()=>_("shelly-main-update"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>_("restart"),children:[e.jsx(Q,{children:e.jsx(jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation.restartMode===""?e.jsxs(L,{onClick:()=>_("shutdown"),children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",_,B)},children:[e.jsx(Q,{children:e.jsx(jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(pt,{}),e.jsxs(L,{onClick:re,children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-view",anchorEl:W,keepMounted:!0,open:!!W,onClose:ce,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{_("view-mblog"),ce()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("view-mjlog"),ce()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("view-diagnostic"),ce()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("view-history"),ce()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{_("view-shellylog"),ce()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(pt,{}),e.jsxs(L,{onClick:te,children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:ne,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{_("download-mbstorage"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-pluginstorage"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-pluginconfig"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-mblog"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-mjstorage"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-mjlog"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-diagnostic"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-history"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{_("shelly-create-system-log"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{_("shelly-download-system-log"),ne()},children:[e.jsx(Q,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(pt,{}),e.jsxs(L,{onClick:m,children:[e.jsx(Q,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-backup",anchorEl:S,keepMounted:!0,open:!!S,onClose:he,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{_("create-backup"),he()},children:[e.jsx(Q,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{_("download-backup"),he()},children:[e.jsx(Q,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(pt,{}),e.jsxs(L,{onClick:Pe,children:[e.jsx(Q,{children:e.jsx(xo,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-reset",anchorEl:b,keepMounted:!0,open:!!b,onClose:Le,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{Le(),l("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)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{Le(),l("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)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>{Le(),l("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)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{Le(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",_,B)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{Le(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",_,B)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const bi=r.memo(xi),cr=1300,ur=1024;let $t,Nt;function vi(){if(typeof window<"u"){$t=Math.floor(window.visualViewport?.width??window.innerWidth),Nt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=$t<cr||Nt<ur;return o&&console.log("Visual viewport width %i height %i mobile %s",$t,Nt,n),n}return!1}function yi({children:n}){const{mobile:d,setMobile:l}=r.useContext(Oe);return r.useEffect(()=>{function i(){l(vi())}return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",d),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:d?`${cr}px`:"calc(100vw - 40px)",height:d?`${ur}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(bi,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const ji=()=>{o=!o},wi=!1;let et;const Ci=n=>{et=n};function Si({setLoggedIn:n}){const[d,l]=r.useState(""),[i,a]=r.useState(""),h={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},u={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},y={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async j=>{try{const C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:j})});if(C.ok){const{valid:k}=await C.json();k?(n(!0),j!==""&&(et=j)):j!==""&&a("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},D=j=>{j.preventDefault(),t(d)};return t(""),e.jsx("div",{style:h,children:e.jsxs("form",{onSubmit:D,style:u,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:d,onChange:j=>l(j.target.value),style:y,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function ki(){const[n,d]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=hi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=fi(i);window.location.href.includes("/api/hassio_ingress/");const h=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${h}"`)),n?e.jsx(bo,{theme:a,children:e.jsx(Dr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(tn,{children:e.jsx(rn,{children:e.jsx(wr,{basename:h,children:e.jsx(yi,{children:e.jsxs(Cr,{children:[e.jsx(qe,{path:"/",element:e.jsx(Tn,{})}),e.jsx(qe,{path:"/devices",element:e.jsx(ri,{})}),e.jsx(qe,{path:"/log",element:e.jsx(ni,{})}),e.jsx(qe,{path:"/settings",element:e.jsx(pi,{})}),e.jsx(qe,{path:"/test",element:e.jsx(mi,{})}),e.jsx(qe,{path:"*",element:e.jsx(Sr,{to:"/"})})]})})})})})})}):e.jsx(Si,{setLoggedIn:d})}kr.createRoot(document.getElementById("root")).render(e.jsx(Mr.StrictMode,{children:e.jsx(ki,{})}));
|
|
1
|
+
import{B as e,y as r,S as at,U as wr,V as Cr,X as qe,Y as Sr,Z as kr,I as Mr}from"./vendor_node_modules.js";import{u as Ir,S as Dr}from"./vendor_notistack.js";import{D as Ne,a as We,b as Te,B as ae,c as Ae,F as He,C as Oe,d as X,A as Pr,I as K,e as Lr,f as $r,T as E,g as he,M as Nr,h as Ye,i as L,j as De,k as Wr,l as yt,m as Tr,n as le,K as Ot,o as Vt,p as Wt,L as lt,q as rt,r as dt,s as Q,W as nt,t as ct,H as pt,u as ee,V as Et,v as At,w as Fr,E as Rr,Q as Xt,R as jt,S as Hr,x as Or,U as Vr,P as Er,y as er,z as tr,G as Pe,J as rr,N as or,O as wt,X as nr,Y as Ar,Z as _r,_ as zr,$ as Ur,a0 as qr,a1 as _t,a2 as Br,a3 as Qr,a4 as Kr,a5 as Gr,a6 as Jr,a7 as Zr,a8 as Yr,a9 as zt,aa as Xr,ab as eo,ac as to,ad as ro,ae as oo,af as no,ag as io,ah as so,ai as ao,aj as lo,ak as co,al as po,am as uo,an as go,ao as mo,ap as Ut,aq as Xe,ar as ir,as as ke,at as sr,au as Ct,av as Ee,aw as ho,ax as fo,ay as xo,az as ze,aA as bo,aB as ut,aC as Be,aD as It,aE as vo,aF as yo}from"./vendor_mui.js";import{I as ne,m as jo,a as qt,b as wo,c as Co,d as Bt,e as So,f as ko,g as Mo,h as Io,i as Do,j as Po,k as Lo,l as $o,n as No,o as Wo,p as To,q as Fo,r as Qt,s as Ro,t as Ho,u as Oo,v as Vo,w as Eo,x as Ao,y as _o,z as zo,A as Kt,B as Uo,C as qo}from"./vendor_mdi.js";import{Q as Bo}from"./vendor_qrcode.js";import{F as Qo,v as Ko,e as Go,a as Jo,g as Zo,b as Yo,c as Xo,d as Dt,A as en}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const d=document.createElement("link").relList;if(d&&d.supports&&d.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const h of a)if(h.type==="childList")for(const p of h.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&i(p)}).observe(document,{childList:!0,subtree:!0});function l(a){const h={};return a.integrity&&(h.integrity=a.integrity),a.referrerPolicy&&(h.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?h.credentials="include":a.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function i(a){if(a.ep)return;a.ep=!0;const h=l(a);fetch(a.href,h)}})();function tn({open:n,title:d,message:l,onConfirm:i,onCancel:a}){const h=v=>{o&&console.log("Confirmed"),v.preventDefault(),i()},p=v=>{o&&console.log("Canceled"),v.preventDefault(),a()};return e.jsxs(Ne,{open:n,children:[e.jsx(We,{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:d})]})}),e.jsxs(Te,{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:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ae,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ae,{onClick:p,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const rn=({open:n,output:d,title:l,_command:i,_packageName:a,onInstall:h,onClose:p})=>{const{installAutoExit:v,setInstallAutoExit:t}=r.useContext(Ve),I=r.useRef(null),y=w=>{t(w.target.checked),localStorage.setItem("installAutoExit",w.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",w.target.checked)};return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${I.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",I.current),I.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[d]),e.jsxs(Ne,{open:n,onClose:(w,S)=>{S==="backdropClick"||S==="escapeKeyDown"||p()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(We,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(Te,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[d.split(`
|
|
2
|
+
`).map((w,S)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:w},S)),e.jsx("li",{ref:I,style:{padding:0,margin:0}})]})]}),e.jsxs(Ae,{sx:{justifyContent:"space-evenly"},children:[h&&e.jsx(ae,{variant:"contained",onClick:h,children:"Install"}),e.jsx(ae,{onClick:p,children:"Close"}),e.jsx(He,{control:e.jsx(Oe,{checked:v,onChange:w=>y(w)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},gt=[],Ve=r.createContext(null);function on({children:n}){const[d,l]=r.useState(!1),[i,a]=r.useState(null),{enqueueSnackbar:h,closeSnackbar:p}=Ir(),v=r.useCallback(k=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${k}`);const $=gt.findIndex(G=>G.message===k);$!==-1&&(p(gt[$].key),gt.splice($,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${k} removed from persistMessages`))},[p]),t=r.useCallback((k,$,G)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${k} timeout ${$}`);const se=h(k,{variant:"default",autoHideDuration:$==null||$>0?($??5)*1e3:null,persist:$===0,content:oe=>e.jsx(X,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Pr,{severity:G??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>p(oe),action:e.jsx(K,{size:"small",onClick:()=>p(oe),sx:{color:"#fff"},children:e.jsx(Lr,{fontSize:"small"})}),children:k},oe)},oe)});$===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${k} timeout ${$} - persist key ${se}`),gt.push({message:k,key:se}))},[h,p]),[I,y]=r.useState(!1),[w,S]=r.useState(""),[A,_]=r.useState(""),[U,j]=r.useState(""),c=r.useRef(null),x=r.useRef(null),f=()=>{o&&console.log(`UiProvider handle confirm action ${U}`),y(!1),c.current&&c.current(U)},O=()=>{o&&console.log(`UiProvider handle cancel action ${U}`),y(!1),x.current&&x.current(U)},D=r.useCallback((k,$,G,se,oe)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${G}`),S(k),_($),j(G),c.current=se,x.current=oe,y(!0)},[]),[C,q]=r.useState(!1),[N,g]=r.useState(""),[s,u]=r.useState(""),[b,H]=r.useState(""),[ce,ye]=r.useState(""),[ie,je]=r.useState(localStorage.getItem("installAutoExit")!=="false"),R=r.useCallback((k,$,G)=>{o&&console.log(`UiProvider show install progress for package ${k}`),g(k),u($),H(G),q(!0)},[]),B=r.useCallback(k=>{o&&console.log(`UiProvider addInstallProgress: output ${k}`),ye($=>$+k+`
|
|
3
|
+
`)},[]),F=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${b}`),localStorage.getItem("installAutoExit")!=="false"&&q(!1)},[b]),J=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${b}`)},[b]),W=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),q(!1)},[]),T=()=>{o&&console.log("UiProvider handle install close action"),q(!1),H(""),ye("")},M=r.useMemo(()=>({mobile:d,setMobile:l,currentPage:i,setCurrentPage:a,showSnackbarMessage:t,closeSnackbarMessage:v,closeSnackbar:p,showConfirmCancelDialog:D,showInstallProgress:R,exitInstallProgressSuccess:F,exitInstallProgressError:J,hideInstallProgress:W,addInstallProgress:B,installAutoExit:ie,setInstallAutoExit:je}),[d,i,l,a,t,v,p,D,R,F,J,W,B,ie,je]);return e.jsxs(Ve.Provider,{value:M,children:[e.jsx(tn,{open:I,title:w,message:A,onConfirm:f,onCancel:O}),e.jsx(rn,{open:C,title:N,_command:s,_packageName:b,output:ce,onClose:T}),n]})}const ar=r.createContext(null),be=r.createContext(null);function nn({children:n}){const[d,l]=r.useState([]),[i,a]=r.useState(1e3),[h,p]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[v,t]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[I,y]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),[w,S]=r.useState(!1),{showSnackbarMessage:A,closeSnackbarMessage:_,closeSnackbar:U,showInstallProgress:j,hideInstallProgress:c,exitInstallProgressSuccess:x,exitInstallProgressError:f,addInstallProgress:O}=r.useContext(Ve),D=r.useRef([]),C=r.useRef(null),q=r.useRef(1),N=r.useRef(Math.floor(Math.random()*999e3)+1e3),g=r.useRef(null),s=r.useRef(null),u=r.useRef(null),b=r.useRef(h),H=r.useRef(v),ce=r.useRef(0),ye=r.useRef(null),ie=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),je=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),R=100,B=60,F=50,J=300,W=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),ye.current=setInterval(()=>{ce.current>0&&(o&&console.log(`WebSocket messages received in the last ${W} seconds: ${ce.current*(60/W)} messages/minute`),ce.current=0)},W*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),ye.current&&clearInterval(ye.current),ye.current=null}),[]),r.useEffect(()=>{b.current=h},[h]),r.useEffect(()=>{H.current=v},[v]);const T=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),M=r.useCallback((P,m)=>{o&&console.log(`WebSocket filterLogMessages called with level "${P}" and search "${m}"...`),l(xe=>xe.filter(te=>!(["debug","info","notice","warn","error","fatal"].includes(te.level)&&(P==="info"&&te.level==="debug"||P==="notice"&&(te.level==="debug"||te.level==="info")||P==="warn"&&(te.level==="debug"||te.level==="info"||te.level==="notice")||P==="error"&&(te.level==="debug"||te.level==="info"||te.level==="notice"||te.level==="warn")||P==="fatal"&&(te.level==="debug"||te.level==="info"||te.level==="notice"||te.level==="warn"||te.level==="error"))||m!=="*"&&m!==""&&!te.message.toLowerCase().includes(m.toLowerCase())&&!te.name.toLowerCase().includes(m.toLowerCase()))))},[]),k=r.useCallback(P=>{if(C.current&&C.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${P.id}:`,P),P.id===void 0&&(P.id=N.current);const m=JSON.stringify(P);C.current.send(m),o&&console.log("WebSocket sent message:",P)}catch(m){o&&console.error(`WebSocket error sending message: ${m}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",P)},[]),$=r.useCallback((P,m)=>{l(xe=>[...xe,{level:P,time:"",name:"",message:m}])},[]),G=r.useCallback((P,m)=>{o&&console.log(`WebSocket addListener id ${m}:`,P),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",P),D.current=[...D.current,{listener:P,id:m}],o&&console.log("WebSocket addListener total listeners:",D.current.length)},[]),se=r.useCallback(P=>{o&&console.log("WebSocket removeListener:",P),D.current=D.current.filter(m=>m.listener!==P),o&&console.log("WebSocket removeListener total listeners:",D.current.length)},[]),oe=r.useCallback(()=>{ie===""||ie===null||ie===void 0||($("WebSocket",`Connecting ${et?"with password":""} to WebSocket: ${ie}`),o&&console.log(`WebSocket connecting to: ${ie}${et?"?password=[redacted]":""}`),C.current=new WebSocket(ie+(et?`?password=${encodeURIComponent(et)}`:"")),C.current.onmessage=P=>{w||S(!0),ce.current+=1;try{const m=JSON.parse(P.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){o&&console.error("WebSocket error message response:",m);return}if(m.id===N.current&&m.method==="pong"&&m.response==="pong"){o&&console.log(`WebSocket pong response message id ${m.id}:`,m),s.current&&clearTimeout(s.current),s.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),A(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),_(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?j(m.response.message,"",""):m.response.name==="Matterbridge:spawn-exit-success"?x():m.response.name==="Matterbridge:spawn-exit-error"?f():O(m.response.message+`
|
|
4
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(b.current==="info"&&m.response.level==="debug"||b.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||b.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||b.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||b.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||H.current!=="*"&&H.current!==""&&!m.response.message.toLowerCase().includes(H.current.toLowerCase())&&!m.response.name.toLowerCase().includes(H.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;l(te=>{const fe=[...te,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return fe.length>i*2?fe.slice(i):fe})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)D.current.forEach(xe=>xe.listener(m));else{const xe=D.current.find(te=>te.id===m.id);xe?xe.listener(m):console.warn(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocket error parsing message: ${m}`,m instanceof Error?m.stack:null)}},C.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${ie}`),$("WebSocket",`Connected to WebSocket: ${ie}`),S(!0),U(),q.current=1,u.current=setTimeout(()=>{g.current=setInterval(()=>{k({id:N.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${ie}`),$("WebSocket",`No pong response received from WebSocket: ${ie}`),S(!1)},1e3*F)},1e3*B)},1e3*J)},C.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${je?"with Ingress":""}: ${ie}`),$("WebSocket",`Disconnected from WebSocket: ${ie}`),S(!1),U(),c(),u.current&&clearTimeout(u.current),s.current&&clearTimeout(s.current),g.current&&clearInterval(g.current),$("WebSocket",`Reconnecting (attempt ${q.current} of ${R}) to WebSocket${je?" (Ingress)":""}: ${ie}`),je?setTimeout(de,5e3):q.current===1?de():q.current<R?setTimeout(de,1e3*q.current):$("WebSocket",`Reconnect attempts exceeded limit of ${R} retries, refresh the page to reconnect to: ${ie}`),q.current=q.current+1},C.current.onerror=P=>{o&&console.error(`WebSocket: WebSocket error connecting to ${ie}:`,P),$("WebSocket",`WebSocket error connecting to ${ie}`)})},[ie]),de=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${q.current}/${R} to:`,ie),oe()},[oe]);r.useEffect(()=>(oe(),()=>{C.current&&C.current.readyState===WebSocket.OPEN&&C.current.close()}),[oe]);const ge=r.useMemo(()=>({messages:d,logMaxMessages:i,logAutoScroll:I,logFilterLevel:h,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:p,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:M}),[d,i,I,h,v,l,p,t,a,y,M]),pe=r.useMemo(()=>({logMaxMessages:i,logAutoScroll:I,logFilterLevel:h,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:p,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:M,online:w,retry:q.current,getUniqueId:T,addListener:G,removeListener:se,sendMessage:k,logMessage:$}),[i,I,l,p,t,a,y,w,q.current,G,se,k,$]);return e.jsx(ar.Provider,{value:ge,children:e.jsx(be.Provider,{value:pe,children:n})})}function sn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function Le(){const{retry:n}=r.useContext(be),d=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(sn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx($r,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function an({value:n,maxChars:d}){let l=n;if(n.length>d&&d>3){const i=d-3,a=n.substring(0,Math.ceil(i/2)),h=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${h}`}return n!==l?e.jsx(E,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function Se({children:n,style:d}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Ue({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function _e({children:n,style:d}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function mt({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function ht({children:n,style:d}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function ot({children:n,style:d}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function kt({children:n,style:d,onDragOver:l,onDragLeave:i,onDrop:a}){const h={display:"flex",flexDirection:"row",flex:"0 0 auto",overflow:"hidden",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...h,...d},onDragOver:l,onDragLeave:i,onDrop:a,children:n})}function it({children:n,style:d,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...d},children:[n,Si]})}function ln({systemInfo:n,compact:d}){const{addListener:l,removeListener:i,getUniqueId:a,sendMessage:h}=r.useContext(be),[p,v]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",p,"compact:",d),n&&d&&p.totalMemory&&p.freeMemory){const j=p.totalMemory,c=p.freeMemory;p.freeMemory=`${c} / ${j}`,p.totalMemory=""}if(n&&d&&p.heapTotal&&p.heapUsed){const j=p.heapTotal,c=p.heapUsed;p.heapUsed=`${c} / ${j}`,p.heapTotal=""}if(n&&d&&p.osRelease&&p.osType){const j=p.osType,c=p.osRelease;p.osType=`${j} (${c})`,p.osRelease=""}if(n&&d&&p.osArch&&p.osPlatform){const j=p.osPlatform,c=p.osArch;p.osPlatform=`${j} (${c})`,p.osArch=""}const I=(j,c,x,f,O)=>{v(D=>({...D,totalMemory:j,freeMemory:c,heapTotal:x,heapUsed:f,rss:O}))},y=j=>{v(c=>({...c,cpuUsage:j.toFixed(2)+" %"}))},w=j=>{v(c=>({...c,processCpuUsage:j.toFixed(2)+" %"}))},S=(j,c)=>{v(x=>({...x,systemUptime:j,processUptime:c}))},A=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:t.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const j=c=>{o&&console.log("SystemInfoTable received WebSocket Message:",c),c.method==="memory_update"&&c.response&&c.response.totalMemory&&c.response.freeMemory&&c.response.heapTotal&&c.response.heapUsed&&c.response.rss?(o&&console.log("SystemInfoTable received memory_update",c),I(c.response.totalMemory,c.response.freeMemory,c.response.heapTotal,c.response.heapUsed,c.response.rss)):c.method==="cpu_update"&&c.response&&c.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",c),y(c.response.cpuUsage),w(c.response.processCpuUsage)):c.method==="uptime_update"&&c.response&&c.response.systemUptime&&c.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",c),S(c.response.systemUptime,c.response.processUptime)):c.method==="/api/viewhistorypage"&&c.id===t.current&&c.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return l(j,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{i(j),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,i]);const[_,U]=r.useState(!1);return!p||_?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(Se,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"System Information"}),e.jsx(it,{onClose:()=>U(!0),children:e.jsx(K,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:A,children:e.jsx(E,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ne,{path:jo,size:"22px"})})})})]}),e.jsx(kt,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(p).filter(([j,c])=>c!==void 0&&c!=="").map(([j,c],x)=>e.jsxs("tr",{className:x%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:j.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(an,{value:typeof c!="string"?c.toString():c,maxChars:24})})]},j))})})})]}))}const dn=r.memo(ln),Gt={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"}},cn=n=>{if(!n)return"";const d=n.toString().replace(/[^0-9]/g,"");if(d.length<5)return d;const l=d.slice(0,4),i=d.slice(4,7),a=d.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function pn({id:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[p,v]=r.useState(null),t=r.useRef(null),I=r.useRef(null),y=r.useRef(h()),{showConfirmCancelDialog:w}=r.useContext(Ve);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${I.current} and matter:`,p),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,I.current&&clearTimeout(I.current),I.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),v(null))},[n,l]),r.useEffect(()=>{const c=x=>{o&&console.log("QRDiv received WebSocket Message:",x),x.method==="refresh_required"&&x.response.changed==="matter"&&x.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${x.response.changed} for storeId "${x.response.matter.id}":`,x.response.matter),t.current===x.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${x.response.matter.id}":`,x.response.matter),I.current&&clearTimeout(I.current),x.response.matter.advertising&&x.response.matter.advertiseTime&&x.response.matter.advertiseTime+9e5<=Date.now()&&(x.response.matter.advertising=!1),v(x.response.matter),x.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${x.response.matter.id}":`,x.response.matter.advertiseTime+9e5-Date.now()),I.current=setTimeout(()=>{I.current&&clearTimeout(I.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),v(f=>f&&{...f,advertising:!1})},x.response.matter.advertiseTime+9e5-Date.now()))))};return i(c,y.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(c),I.current&&clearTimeout(I.current),I.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const S=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${p?.id}"`),p&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,startCommission:!0}})},A=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${p?.id}"`),p&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,stopCommission:!0}})},_=()=>{o&&console.log(`QRDiv sent matter advertise for node "${p?.id}"`),p&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,advertise:!0}})},U=c=>{o&&console.log(`QRDiv sent matter removeFabric for node "${p?.id}" and fabricIndex ${c}`),p&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,removeFabric:c}})},j=async()=>{if(!p||!p.manualPairingCode)return;const c=p.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(c);else{const x=document.createElement("textarea");x.value=c,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.focus(),x.select(),document.execCommand("copy"),document.body.removeChild(x)}o&&console.log("Manual pairing code copied to clipboard")}catch(x){console.error("Failed to copy manual pairing code",x)}};return!p||!d?(o&&console.log("QRDiv rendering undefined state"),null):p.online?p.advertising&&p.qrPairingCode&&p.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(Se,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"QR pairing code"}),e.jsxs(it,{children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:qt,size:"22px"})})}),e.jsx(K,{"aria-label":"stop pairing",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:wo,size:"22px"})})})]})]}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Bo,{value:p.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(mt,{style:{justifyContent:"space-between"},children:[e.jsxs(ht,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",cn(p.manualPairingCode)]}),e.jsx(it,{children:e.jsx(E,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(K,{"aria-label":"copy manual pairing code",size:"small",onClick:j,sx:Gt,children:e.jsx(ne,{path:Co,size:.85})})})})]})]})):p.commissioned&&p.fabricInformations&&p.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(Se,{style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"Paired fabrics"}),e.jsxs(it,{children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:qt,size:"22px"})})}),e.jsx(K,{"aria-label":"start pairing",size:"small",onClick:S,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:Bt,size:"22px"})})})]})]}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(kt,{style:{flexDirection:"column",flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px 0px 10px 0px",gap:"0px"},children:p.fabricInformations.map((c,x)=>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: ",c.fabricIndex]}),e.jsx(E,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(K,{"aria-label":"remove the fabric",size:"small",onClick:()=>w("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>U(c.fabricIndex),()=>{}),sx:{...Gt,padding:"2px"},children:e.jsx(ne,{path:So,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",c.rootVendorId," ",c.rootVendorName]}),c.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",c.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",p.sessionInformations?p.sessionInformations.filter(f=>f.fabric?.fabricIndex===c.fabricIndex&&f.isPeerActive===!0).length:"0"," ","subscriptions: ",p.sessionInformations?p.sessionInformations.filter(f=>f.fabric?.fabricIndex===c.fabricIndex&&f.isPeerActive===!0&&f.numberOfActiveSubscriptions>0).length:"0"]})]},x))}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]})):!p.commissioned&&!p.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Se,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ue,{children:e.jsx(_e,{children:"QR pairing code"})}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ae,{onClick:S,endIcon:e.jsx(ne,{path:Bt,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(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(Se,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ue,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(_e,{children:"Server node"})}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ot,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]}))}const un=r.memo(pn);function gn(){const{logMessage:n,sendMessage:d,getUniqueId:l}=r.useContext(be),[i,a]=r.useState("matterbridge-"),[h,p]=r.useState(!1),[v,t]=r.useState(null),I=r.useRef(l()),y=N=>{N.preventDefault(),p(!0)},w=()=>{p(!1)},S=N=>{N.preventDefault(),p(!1);const g=N.dataTransfer.files[0];if(g){n("Plugins",`Installing package ${g.name}. Please wait...`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(u=>u.text()).then(u=>{n("Plugins",`Server response: ${u}`)}).catch(u=>{console.error("Error uploading plugin file:",u),n("Plugins",`Error installing package ${u}`)})}},A=N=>{const g=N.target.files&&N.target.files[0];if(g){n("Plugins",`Uploading package ${g.name}`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(u=>u.text()).then(u=>{n("Plugins",`Server response: ${u}`)}).catch(u=>{console.error("Error uploading plugin file:",u),n("Plugins",`Error uploading package ${u}`)})}},_=()=>{d({id:I.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},U=()=>{document.getElementById("file-upload")?.click()},j=()=>{d({id:I.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},c=N=>{N.preventDefault(),d({id:I.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:i}})},x=N=>{N.preventDefault(),console.log("Right-clicked Upload button")},f=N=>{N.preventDefault(),console.log("Right-clicked Add button")},O=N=>{t(N.currentTarget)},D=N=>{N!==""&&a(N),t(null)},[C,q]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),C?null:e.jsxs(Se,{children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"Install plugins"}),e.jsx(it,{onClose:()=>q(!0)})]}),e.jsxs(kt,{onDragOver:y,onDragLeave:w,onDrop:S,children:[e.jsx(he,{value:i,onChange:N=>{a(N.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(K,{onClick:O,children:e.jsx(Nr,{})}),e.jsxs(Ye,{id:"simple-menu",anchorEl:v,keepMounted:!0,open:!!v,onClose:()=>D(""),children:[e.jsx(L,{onClick:()=>D("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(L,{onClick:()=>D("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(L,{onClick:()=>D("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(L,{onClick:()=>D("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(L,{onClick:()=>D("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(L,{onClick:()=>D("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(L,{onClick:()=>D("matterbridge-test"),children:"matterbridge-test"}),e.jsx(L,{onClick:()=>D("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(L,{onClick:()=>D("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(L,{onClick:()=>D("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(L,{onClick:()=>D("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(L,{onClick:()=>D("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(L,{onClick:()=>D("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(L,{onClick:()=>D("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(E,{title:"Install or update a plugin from npm",children:e.jsxs(ae,{onClick:_,onContextMenu:c,endIcon:e.jsx(De,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(E,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ae,{onClick:U,onContextMenu:x,endIcon:e.jsx(Wr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(E,{title:"Add an installed plugin",children:e.jsxs(ae,{onClick:j,onContextMenu:f,endIcon:e.jsx(yt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:A})]})]})}const mn=r.memo(gn);function Qe({status:n,enabledText:d="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const h=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?d:l??d});return i!==void 0?e.jsx(E,{title:i,children:h}):h}}function hn(n,d,l){const i=n?.[l],a=d?.[l];return i==null&&a==null?0:i==null?-1:a==null?1:typeof i=="boolean"&&typeof a=="boolean"?i===a?0:i?1:-1:typeof i=="number"&&typeof a=="number"?i-a:String(i).localeCompare(String(a))}function fn({name:n,title:d,columns:l,rows:i,getRowKey:a,footerLeft:h,footerRight:p,onRowClick:v}){const t=r.useRef(new WeakMap),I=r.useRef(1),y=g=>{if(typeof a=="string"&&g&&g[a]!=null)return g[a];if(typeof a=="function"){const b=a(g);if(b!=null)return b}const s=l?.[0]?.id;if(s&&g&&g[s]!=null)return g[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let u=t.current.get(g);return u||(u=`rk_${I.current++}`,t.current.set(g,u)),u},[w,S]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[A,_]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[U,j]=r.useState(!1),[c,x]=r.useState(()=>{try{const g=localStorage.getItem(`${n}_column_visibility`);if(g)return JSON.parse(g)}catch{}return{}}),f=r.useMemo(()=>{const g={};for(const s of l)s.hidden||(g[s.id]=s.required?!0:c[s.id]!==!1);return g},[l,c]),O=r.useMemo(()=>{if(!w||!A)return i;const g=l.find(u=>u.id===w);if(!g||g.noSort)return i;const s=i.map((u,b)=>({el:u,index:b}));return s.sort((u,b)=>{let H;return typeof g.comparator=="function"?H=g.comparator(u.el,b.el):H=hn(u.el,b.el,w),H!==0?A==="asc"?H:-H:u.index-b.index}),s.map(u=>u.el)},[i,w,A,l]),D=g=>{if(w!==g||!w){S(g),_("asc"),localStorage.setItem(`${n}_table_order_by`,g),localStorage.setItem(`${n}_table_order`,"asc");return}if(A==="asc"){_("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}S(null),_(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},C=()=>{j(!U)},q=g=>{x(s=>{const u=l.find(ce=>ce.id===g);if(u&&u.required)return s;const b=f[g]!==!1,H={...s};b?H[g]=!1:delete H[g];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(H))}catch{}return H})},N=()=>{x({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}j(!1)};return o&&console.log(`Rendering table ${n}${w&&A?` ordered by ${w}:${A}`:""}`),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:U,onClose:(g,s)=>{s==="backdropClick"||s==="escapeKeyDown"||C()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(We,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Te,{children:e.jsx(Tr,{children:l.filter(g=>!g.hidden).map(g=>e.jsx(He,{control:e.jsx(Oe,{disabled:!!g.required,checked:g.required?!0:f[g.id]!==!1,onChange:()=>q(g.id)}),label:g.label},g.id))})}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:N,children:"Reset"}),e.jsx(ae,{variant:"contained",onClick:g=>{if(g?.currentTarget&&typeof g.currentTarget.blur=="function")try{g.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}C()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),d&&e.jsx("p",{className:"MbfWindowHeaderText",children:d}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(K,{onClick:g=>{if(g?.currentTarget?.blur)try{g.currentTarget.blur()}catch{}C()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(E,{title:`Configure ${n} columns`,children:e.jsx(ne,{path:ko,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":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(g=>{if(g.hidden||!g.required&&f[g.id]===!1)return null;const s=!g.noSort,u=s&&w===g.id&&!!A;return e.jsxs("th",{onClick:s?()=>D(g.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:g.minWidth,maxWidth:g.maxWidth,textAlign:g.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:g.maxWidth?"nowrap":void 0,overflow:g.maxWidth?"hidden":void 0,textOverflow:g.maxWidth?"ellipsis":void 0},"aria-sort":s?u?A==="asc"?"ascending":"descending":"none":void 0,children:[g.label,u&&e.jsxs("span",{style:{marginLeft:6},children:[A==="asc"&&e.jsx(ne,{path:Mo,size:"15px"}),A==="desc"&&e.jsx(ne,{path:Io,size:"15px"})]})]},g.id)})})}),e.jsx("tbody",{children:O.map((g,s)=>{const u=y(g);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:v?b=>v(g,u,b):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:v?"pointer":void 0},children:l.map(b=>{if(b.hidden||!b.required&&f[b.id]===!1)return null;const H=g[b.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:b.align||"left",padding:"5px 10px",margin:"0",maxWidth:b.maxWidth,whiteSpace:b.maxWidth?"nowrap":void 0,overflow:b.maxWidth?"hidden":void 0,textOverflow:b.maxWidth?"ellipsis":void 0},children:typeof b.render=="function"?b.render(H,u,g,b):typeof H=="boolean"?e.jsx(Oe,{checked:H,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):b.format&&typeof H=="number"?b.format(H):H!=null?String(H):null},b.id)})},u)})})]})}),(h||p)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:p})]})]})}function xn(n){return r.memo(n)}const St=xn(fn);function Jt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Ke={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Ge={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},bn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},vn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Re={padding:"0px",margin:"0px"},yn="5px 10px 5px 10px",ft={},Ce={},xt={},bt={};let Je=[],Pt=[];const jn=({open:n,onClose:d,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:h,getUniqueId:p}=r.useContext(be),v=r.useRef(p()),[t,I]=r.useState(l.configJson),[y,w]=r.useState(null),[S,A]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[_,U]=r.useState("");let j={};r.useEffect(()=>{const T=M=>{M.src==="Matterbridge"&&M.dst==="Frontend"&&(Jt(M)&&M.id===v.current&&M.method==="/api/select/devices"&&M.response&&(o&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/devices:`,M.response),Je=M.response),Jt(M)&&M.id===v.current&&M.method==="/api/select/entities"&&M.response&&(o&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/entities:`,M.response),Pt=M.response))};return a(T,v.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",v.current),t&&y&&y.properties&&(Object.keys(y.properties).forEach(M=>{Object.keys(y.properties[M]).forEach(k=>{k.startsWith("ui:")&&(S[M]={},S[M][k]=y.properties[M][k],delete y.properties[M][k])})}),A(S)),l.name&&l.configJson&&l.schemaJson&&(I(l.configJson),w(l.schemaJson),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{h(T),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,h,y,i,S]);const c=(T,M)=>{j=T.formData},x=T=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",T.formData),I(T.formData),l.configJson=T.formData,l.restartRequired=!0,i({id:v.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.formData.name,formData:T.formData}}),d()};function f(T){const{id:M,label:k,onKeyChange:$,onDropPropertyClick:G,disabled:se,schema:oe,children:de,registry:ge,readonly:pe,required:P}=T,{templates:m}=ge,{RemoveButton:xe}=m.ButtonTemplates;if(!(en in oe))return e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:de});const fe=({target:Y})=>$(Y&&Y.value);return e.jsxs(X,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(he,{id:`${M}-key`,name:`${M}-key`,required:P,disabled:se||pe,defaultValue:k,onBlur:pe?void 0:fe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(X,{sx:{flex:1},children:de}),e.jsx(xe,{disabled:se||pe,onClick:G(k),registry:ge})]})}function O(T){const{children:M,description:k,displayLabel:$,errors:G,help:se,hidden:oe,registry:de,uiSchema:ge}=T,pe=Yo(ge),P=Xo("WrapIfAdditionalTemplate",de,pe);return oe?e.jsx("div",{style:{display:"none"},children:M}):e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(P,{...T,children:[$===!0&&k,M,G,se]})})}function D(T){const{description:M}=T;return M?e.jsx(le,{sx:Ge,children:M}):null}function C(T){const{required:M,title:k}=T;return k?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(le,{sx:Ke,children:["Title ",k," ",M&&e.jsx("mark",{children:"***"})]})}):null}function q(T){const{help:M}=T;return M?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(le,{sx:bn,children:M})}):null}function N(T){const{errors:M}=T;return M?e.jsxs(X,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(le,{color:"error",sx:vn,children:"Please fix the following errors:"}),e.jsx(rt,{children:M.map((k,$)=>e.jsxs(Fr,{children:[e.jsx(Q,{children:e.jsx(Rr,{color:"error"})}),e.jsx(ee,{primary:k.stack})]},$))})]}):null}function g(T){const{errors:M}=T;return M?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:M.map((k,$)=>e.jsxs(le,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",k]},$))}):null}function s(T){const{id:M,name:k,_schema:$,_uiSchema:G,value:se,options:oe,label:de,type:ge,placeholder:pe,required:P,disabled:m,readonly:xe,autofocus:te,onChange:fe,onChangeOverride:Y,onBlur:me,onFocus:ve,_rawErrors:tt,_hideError:$e,_registry:z,_formContext:V}=T,re=({target:{value:Ie}})=>fe(Ie===""?oe.emptyValue:Ie),we=({target:Ie})=>me(M,Ie&&Ie.value),st=({target:Ie})=>ve(M,Ie&&Ie.value);return e.jsx(X,{sx:{padding:"0px",margin:"0px"},children:e.jsx(he,{id:M,name:M,label:pe&&pe!==""?de:void 0,variant:"outlined",placeholder:pe&&pe!==""?pe:de,required:P,disabled:m||xe,autoFocus:te,value:se||se===0?se:"",type:ge,autoComplete:ge==="password"?"current-password":k,onChange:Y||re,onBlur:we,onFocus:st,fullWidth:!0})})}function u(T){return console.log("ArrayFieldTitleTemplate:",T),null}function b(T){return console.log("ArrayFieldDescriptionTemplate:",T),null}function H(T){return console.log("ArrayFieldItemTemplate:",T),null}function ce(T){const{canAdd:M,onAddClick:k,schema:$,title:G}=T,[se,oe]=r.useState(!1),[de,ge]=r.useState(!1),[pe,P]=r.useState(!1),[m,xe]=r.useState(""),te=z=>{xe(z.target.value)},fe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Je),oe(!se)},Y=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Pt),ge(!de)},me=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Je),P(!pe)},ve=z=>{oe(!1),$.selectFrom==="serial"?$.items.default=z.serial:$.selectFrom==="name"&&($.items.default=z.name),k()},tt=z=>{ge(!1),$.selectEntityFrom==="name"?$.items.default=z.name:$.selectEntityFrom==="description"&&($.items.default=z.description),k()},$e=z=>{P(!1),$.selectDeviceEntityFrom==="name"?$.items.default=z.name:$.selectDeviceEntityFrom==="description"&&($.items.default=z.description),k()};return e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[G&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G&&e.jsx(le,{sx:Ke,children:G}),M&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[$.selectFrom&&e.jsx(E,{title:"Add a device from the list",children:e.jsx(K,{onClick:fe,size:"small",color:"primary",sx:Re,children:e.jsx(lt,{})})}),$.selectEntityFrom&&e.jsx(E,{title:"Add an entity from the list",children:e.jsx(K,{onClick:Y,size:"small",color:"primary",sx:Re,children:e.jsx(lt,{})})}),$.selectDeviceEntityFrom&&e.jsx(E,{title:"Add a device entity from the list",children:e.jsx(K,{onClick:me,size:"small",color:"primary",sx:Re,children:e.jsx(lt,{})})}),e.jsx(E,{title:"Add a new item",children:e.jsx(K,{onClick:k,size:"small",color:"primary",sx:Re,children:e.jsx(yt,{})})})]})]}),$.description&&e.jsx(le,{sx:Ge,children:$.description}),T.items.map(z=>e.jsxs(X,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(X,{sx:{flexGrow:1,marginRight:"10px"},children:z.children}),e.jsx(K,{disabled:!z.hasMoveUp,onClick:z.onReorderClick(z.index,z.index-1),size:"small",color:"primary",sx:Re,children:e.jsx(Vt,{})}),e.jsx(K,{disabled:!z.hasMoveDown,onClick:z.onReorderClick(z.index,z.index+1),size:"small",color:"primary",sx:Re,children:e.jsx(Ot,{})}),e.jsx(K,{onClick:z.onDropIndexClick(z.index),size:"small",color:"primary",sx:Re,children:e.jsx(Wt,{})})]},z.index)),e.jsxs(Ne,{open:se,onClose:fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(We,{children:"Select a device"}),e.jsxs(Te,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:m,onChange:te,placeholder:"Enter serial or name"})]}),e.jsx(rt,{dense:!0,children:Je.filter(z=>z.serial.toLowerCase().includes(m.toLowerCase())||z.name.toLowerCase().includes(m.toLowerCase())).map((z,V)=>e.jsxs(dt,{onClick:()=>ve(z),sx:ft,children:[z.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:Ce})}),z.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:Ce})}),z.icon==="hub"&&e.jsx(Q,{children:e.jsx(pt,{style:Ce})}),e.jsx(ee,{primary:z.name,secondary:z.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},V))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:fe,children:"Close"})})]}),e.jsxs(Ne,{open:de,onClose:Y,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(We,{children:"Select an entity"}),e.jsxs(Te,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:m,onChange:te,placeholder:"Enter name or description"})]}),e.jsx(rt,{dense:!0,children:Pt.filter(z=>z.name.toLowerCase().includes(m.toLowerCase())||z.description.toLowerCase().includes(m.toLowerCase())).map((z,V)=>e.jsxs(dt,{onClick:()=>tt(z),sx:ft,children:[z.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:Ce})}),z.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:Ce})}),z.icon==="hub"&&e.jsx(Q,{children:e.jsx(pt,{style:Ce})}),z.icon==="component"&&e.jsx(Q,{children:e.jsx(Et,{style:Ce})}),z.icon==="matter"&&e.jsx(Q,{children:e.jsx(At,{style:Ce})}),e.jsx(ee,{primary:z.name,secondary:z.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},V))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:Y,children:"Close"})})]}),e.jsxs(Ne,{open:pe,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(We,{children:["Select an entity for ",G]}),e.jsx(Te,{children:e.jsx(rt,{dense:!0,children:Je.filter(z=>z.serial===G||z.name===G).map(z=>z.entities?.map((V,re)=>e.jsxs(dt,{onClick:()=>$e(V),sx:ft,children:[V.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:Ce})}),V.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:Ce})}),V.icon==="hub"&&e.jsx(Q,{children:e.jsx(pt,{style:Ce})}),V.icon==="component"&&e.jsx(Q,{children:e.jsx(Et,{style:Ce})}),V.icon==="matter"&&e.jsx(Q,{children:e.jsx(At,{style:Ce})}),e.jsx(ee,{primary:V.name,secondary:V.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},re)))})}),e.jsx(Ae,{children:e.jsx(ae,{onClick:me,children:"Close"})})]})]})}function ye(T){const{onAddClick:M,schema:k,properties:$,title:G,description:se}=T,[oe,de]=r.useState(!1),[ge,pe]=r.useState(""),P=Y=>{pe(Y.target.value)},m=()=>{de(!oe)},xe=Y=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${Y.serial}" for schema "${k.selectFrom}"`),de(!1);let me="";k.selectFrom==="serial"?me=Y.serial:k.selectFrom==="name"&&(me=Y.name),U(me),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${me}"`),M(k)()},te=()=>{M(k)()},fe=!k.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${fe} newkey "${_}"`),!fe&&_!==""&&(o&&console.log("ObjectFieldTemplate: newkey",_,"properties",$),$.forEach(Y=>{if(Y.name==="newKey"&&Y.content.key==="newKey"&&Y.content.props.name==="newKey"&&Y.content.props.onKeyChange&&_!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",_);const me=_;U(""),Y.content.props.onKeyChange(me)}})),e.jsxs(X,{sx:{margin:"0px",padding:fe?"10px":"5px 10px 0px 10px",border:fe?"none":"1px solid grey"},children:[k.title&&fe&&e.jsx(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Ke,children:k.title})}),G&&!fe&&e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(le,{sx:Ke,children:G}),e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[k.selectFrom&&e.jsx(E,{title:"Add a device from the list",children:e.jsx(K,{onClick:m,size:"small",color:"primary",sx:Re,children:e.jsx(lt,{})})}),e.jsx(E,{title:"Add a new item",children:e.jsx(K,{onClick:te,size:"small",color:"primary",sx:Re,children:e.jsx(yt,{})})})]})]}),k.description&&e.jsx(X,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Ge,children:k.description})}),$.map(({content:Y,name:me,hidden:ve})=>!ve&&e.jsxs(X,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(k.properties[me].type)?"0px":yn,border:["object","array","boolean"].includes(k.properties[me].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(k.properties[me].type)&&e.jsx(le,{sx:Ke,children:me}),e.jsx(X,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:Y})]},me)),e.jsxs(Ne,{open:oe,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(We,{children:"Select a device"}),e.jsxs(Te,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:ge,onChange:P,placeholder:"Enter serial or name"})]}),e.jsx(rt,{dense:!0,children:Je.filter(Y=>Y.serial.toLowerCase().includes(ge.toLowerCase())||Y.name.toLowerCase().includes(ge.toLowerCase())).map((Y,me)=>e.jsxs(dt,{onClick:()=>xe(Y),sx:ft,children:[Y.icon==="wifi"&&e.jsx(Q,{children:e.jsx(nt,{style:Ce})}),Y.icon==="ble"&&e.jsx(Q,{children:e.jsx(ct,{style:Ce})}),Y.icon==="hub"&&e.jsx(Q,{children:e.jsx(pt,{style:Ce})}),e.jsx(ee,{primary:Y.name,secondary:Y.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},me))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:m,children:"Close"})})]})]})}function ie(T){const{uiSchema:M}=T,{submitText:k,norender:$}=Zo(M);return $?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ae,{type:"submit",variant:"contained",color:"primary",children:k}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,children:"Cancel"})]})}function je(T){const{className:M,disabled:k,onClick:$,registry:G,style:se,uiSchema:oe,...de}=T;return e.jsx(E,{title:"Remove the item",children:e.jsx(K,{disabled:k,size:"small",color:"primary",onClick:$,children:e.jsx(Wt,{})})})}function R(T){const{className:M,disabled:k,onClick:$,registry:G,uiSchema:se,...oe}=T;return e.jsx(E,{title:"Add an item",children:e.jsx(K,{size:"small",color:"primary",onClick:$,children:e.jsx(yt,{})})})}function B(T){const{disabled:M,onClick:k,registry:$,style:G,uiSchema:se,...oe}=T;return e.jsx(E,{title:"Move up the item",children:e.jsx(K,{size:"small",color:"primary",onClick:k,children:e.jsx(Vt,{})})})}function F(T){const{disabled:M,onClick:k,registry:$,style:G,uiSchema:se,...oe}=T;return e.jsx(E,{title:"Move down the item",children:e.jsx(K,{size:"small",color:"primary",onClick:k,children:e.jsx(Ot,{})})})}function J(T){const{id:M,name:k,value:$,schema:G,readonly:se,onChange:oe}=T,[de,ge]=r.useState(),pe=m=>{o&&console.log(`CheckboxWidget ${k} onChangeField:`,m),ge(m&&m!==""?m:void 0)},P=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${k}" value="${de}"`),i({id:v.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:k,value:de,formData:j,id:M}}),G.buttonClose===!0?d():G.buttonSave===!0&&x({formData:t})};return G.buttonText&&G.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Ge,children:G.description}),e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>P(),children:G.buttonText})]}):G.buttonField&&G.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Ge,children:G.description}),e.jsx(he,{id:k+"-input",name:k,label:G.textLabel,placeholder:G.textPlaceholder,onChange:m=>pe(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ae,{id:k+"-button",variant:"contained",color:"primary",disabled:de===void 0,onClick:()=>P(),children:G.buttonField})]}):e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[k&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(le,{sx:Ke,children:k}),e.jsx(Oe,{checked:$,readOnly:se,onChange:()=>oe(!$),sx:{padding:"0px",margin:"0px"}})]}),G.description&&e.jsx(le,{sx:Ge,children:G.description})]})}function W({schema:T,id:M,name:k,options:$,label:G,hideLabel:se,required:oe,disabled:de,placeholder:ge,readonly:pe,value:P,multiple:m,autofocus:xe,onChange:te,onBlur:fe,onFocus:Y,errorSchema:me,rawErrors:ve=[],registry:tt,uiSchema:$e,hideError:z,formContext:V,...re}){const{enumOptions:we,enumDisabled:st,emptyValue:Ie}=$;m=typeof m>"u"?!1:!!m;const Tt=m?[]:"",Ft=typeof P>"u"||m&&P.length<1||!m&&P===Tt,ur=({target:{value:Fe}})=>te(Dt(Fe,we,Ie)),gr=({target:Fe})=>fe(M,Dt(Fe&&Fe.value,we,Ie)),mr=({target:Fe})=>Y(M,Dt(Fe&&Fe.value,we,Ie)),Rt=Go(P,we,m),{InputLabelProps:hr,SelectProps:fr,autocomplete:xr,...br}=re,vr=!m&&T.default===void 0;return e.jsxs(he,{id:M,name:M,value:!Ft&&typeof Rt<"u"?Rt:Tt,required:oe,disabled:de||pe,autoFocus:xe,autoComplete:xr,placeholder:ge,error:ve.length>0,onChange:ur,onBlur:gr,onFocus:mr,...br,select:!0,InputLabelProps:{...hr,shrink:!Ft},SelectProps:{...fr,multiple:m},"aria-describedby":Jo(M),children:[vr&&e.jsx(L,{value:"",children:ge}),Array.isArray(we)&&we.map(({value:Fe,label:yr},Ht)=>{const jr=Array.isArray(st)&&st.indexOf(Fe)!==-1;return e.jsx(L,{value:String(Ht),disabled:jr,children:yr},Ht)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(Ne,{open:n,onClose:d,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(We,{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(Te,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Qo,{schema:y,formData:t,uiSchema:S,validator:Ko,templates:{FieldTemplate:O,BaseInputTemplate:s,TitleFieldTemplate:C,DescriptionFieldTemplate:D,FieldHelpTemplate:q,FieldErrorTemplate:g,ErrorListTemplate:N,WrapIfAdditionalTemplate:f,ArrayFieldTitleTemplate:u,ArrayFieldDescriptionTemplate:b,ArrayFieldItemTemplate:H,ArrayFieldTemplate:ce,ObjectFieldTemplate:ye,ButtonTemplates:{SubmitButton:ie,RemoveButton:je,AddButton:R,MoveUpButton:B,MoveDownButton:F}},widgets:{CheckboxWidget:J,SelectWidget:W},onChange:c,onSubmit:x})})]})};function lr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let d=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&d++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(d===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function wn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:p}=r.useContext(be),{showConfirmCancelDialog:v}=r.useContext(Ve),t=r.useRef(p()),[I,y]=r.useState(null),[w,S]=r.useState(null),[A,_]=r.useState([]),U=[{label:"Name",id:"name",required:!0,render:(F,J,W,T)=>e.jsx(E,{title:`Plugin path ${W.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g(W),children:W.name})})},{label:"Description",id:"description",render:(F,J,W,T)=>e.jsx(E,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g(W),children:W.description})})},{label:"Version",id:"version",render:(F,J,W,T)=>e.jsx(e.Fragment,{children:e.jsx(E,{title:`Plugin v.${W.version}`,children:e.jsx("span",{children:W.version.split("-dev-")[0]+(W.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(F,J,W,T)=>e.jsx(e.Fragment,{children:W.author?W.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(F,J,W,T)=>e.jsx(e.Fragment,{children:W.type?W.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(F,J,W,T)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[w&&w.bridgeMode==="childbridge"&&!W.error&&W.enabled&&e.jsx(E,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:lr(W.matter)},onClick:()=>{W.matter?.id&&d(W.matter?.id)},size:"small",children:e.jsx(Xt,{})})}),w&&w.bridgeMode==="childbridge"&&!W.error&&W.enabled&&e.jsx(E,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>q(W),size:"small",children:e.jsx(jt,{})})}),e.jsx(E,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{disabled:W.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>je(W),size:"small",children:e.jsx(Hr,{})})}),w&&!w.readOnly&&e.jsx(E,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",W)},size:"small",children:e.jsx(Or,{})})}),W.enabled?e.jsx(E,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",W)},size:"small",children:e.jsx(Vr,{})})}):e.jsx(e.Fragment,{}),W.enabled?e.jsx(e.Fragment,{}):e.jsx(E,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>N(W),size:"small",children:e.jsx(Er,{})})}),e.jsx(E,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u(W),size:"small",children:e.jsx(er,{})})}),e.jsx(E,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>b(W),size:"small",children:e.jsx(tr,{})})}),W.latestVersion!==void 0&&W.latestVersion!==W.version&&w&&!w.readOnly&&e.jsx(E,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>O(W),size:"small",children:e.jsx(Pe,{})})}),W.version.includes("-dev-")&&W.devVersion!==void 0&&W.devVersion!==W.version&&w&&!w.readOnly&&e.jsx(E,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(W),size:"small",children:e.jsx(Pe,{})})}),w&&!w.readOnly&&e.jsx(E,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s(W),size:"small",children:e.jsx(rr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(F,J,W,T)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:W.error?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:W.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:W.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:W.loaded&&W.started&&W.configured?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:W.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{status:W.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Qe,{status:W.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Qe,{status:W.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const F=J=>{o&&console.log("HomePlugins received WebSocket Message:",J),J.method==="refresh_required"&&J.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):J.method==="refresh_required"&&J.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and setting matter id ${J.response.matter?.id}`),_(W=>{const T=W.findIndex(k=>k.matter?.id===J.response.matter?.id);if(T<0)return o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and matter id ${J.response.matter?.id} not found`),W;o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} set matter id ${J.response.matter?.id}`);const M=[...W];return M[T]={...M[T],matter:J.response.matter},M})):J.method==="refresh_required"&&J.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${J.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),J.id===t.current&&J.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${J.id}) received settings:`,J.response),y(J.response.systemInformation),S(J.response.matterbridgeInformation)):J.id===t.current&&J.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${J.id}) received ${J.response.length} plugins:`,J.response),_(J.response))};return a(F,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{h(F),o&&console.log("HomePlugins removed WebSocket listener")}},[a,h,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const j=r.useRef(null),c=(F,J,W,T)=>{o&&console.log(`handleActionWithConfirmCancel ${W} ${T.name}`),j.current=T,v(F,J,W,x,f)},x=F=>{o&&console.log(`handleConfirm action confirmed ${F} ${j.current?.name}`),F==="remove"&&j.current?C(j.current):F==="disable"&&j.current&&N(j.current),j.current=null},f=F=>{o&&console.log(`handleCancel action canceled ${F} ${j.current?.name}`),j.current=null},O=F=>{o&&console.log("handleUpdatePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name,restart:!1}})},D=F=>{o&&console.log("handleUpdateDevPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:F.name+"@dev",restart:!1}})},C=F=>{o&&console.log("handleRemovePlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},q=F=>{o&&console.log("handleRestartPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})},N=F=>{o&&console.log("handleEnableDisablePlugin plugin:",F.name,"enabled:",F.enabled),F.enabled===!0?(F.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}})):(F.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:F.name}}))},g=F=>{o&&console.log(`handleHomepagePlugin plugin: ${F.name} homepage: ${F.homepage}`),F.homepage&&window.open(F.homepage,"_blank")},s=F=>{o&&console.log("handleSponsorPlugin plugin:",F.name,"funding:",F.funding),F.funding&&window.open(F.funding,"_blank")},u=F=>{o&&console.log("handleHelpPlugin plugin:",F.name,"help:",F.help),F.help&&window.open(F.help,"_blank")},b=F=>{o&&console.log("handleChangelogPlugin plugin:",F.name,"changelog:",F.changelog),F.changelog&&window.open(F.changelog,"_blank")},[H,ce]=r.useState(),[ye,ie]=r.useState(!1),je=F=>{o&&console.log("handleConfigPlugin plugin:",F.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:F.name}}),ce(F),R()},R=()=>{ie(!0)},B=()=>{ie(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(Se,{children:[H&&e.jsx(jn,{open:ye,onClose:B,plugin:H}),e.jsx(St,{name:"Plugins",columns:U,rows:A,footerRight:"",footerLeft:""})]}):e.jsx(Le,{})}const Cn=r.memo(wn),Sn=n=>`${n.pluginName}::${n.serial}`;function kn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:p}=r.useContext(be),[v,t]=r.useState(!1),[I,y]=r.useState(!0),[w,S]=r.useState(null),[A,_]=r.useState([]),[U,j]=r.useState([]),[c,x]=r.useState([]),[f,O]=r.useState([]),D=r.useRef(p()),C=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(g,s,u,b)=>u.reachable===!0?"Online":u.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(g,s)=>{const u=g.reachable===!0?1:g.reachable===!1?0:-1,b=s.reachable===!0?1:s.reachable===!1?0:-1;return u-b}},{label:"Power",id:"powerSource",render:(g,s,u,b)=>u.powerSource==="ac"||u.powerSource==="dc"?e.jsx(or,{fontSize:"small",sx:{color:"var(--primary-color)"}}):u.powerSource==="ok"?e.jsx(wt,{fontSize:"small",sx:{color:"green"}}):u.powerSource==="warning"?e.jsx(wt,{fontSize:"small",sx:{color:"yellow"}}):u.powerSource==="critical"?e.jsx(wt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl",maxWidth:150},{label:"Actions",id:"selected",required:!0,render:(g,s,u,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[u.matter!==void 0?e.jsx(E,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>d(n===u.matter?.id?w?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:u.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:lr(u.matter)},children:e.jsx(Xt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.configUrl?e.jsx(E,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>window.open(u.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(nr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.selected!==void 0?e.jsx(E,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Oe,{checked:u.selected,onChange:H=>N(H,u),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],q=r.useCallback(g=>{g.selected=void 0;const s=A.find(H=>H.name===g.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${g.pluginName} not found for device ${g.name} `),g.selected;const u=s.schemaJson?.properties?.whiteList?.selectFrom;let b=s.configJson.postfix;return b===""&&(b=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&u&&(g.selected=!0,u==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!0),u==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!1),u==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!1),u==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(g.name)&&(g.selected=!0),u==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(g.name)&&(g.selected=!1),u==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(g.name)&&(g.selected=!1)),g.selected},[A]);r.useEffect(()=>{const g=s=>{if(o&&console.log("HomeDevices received WebSocket Message:",s),s.method==="refresh_required"&&s.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and sending /api/plugins request`),i({id:D.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):s.method==="refresh_required"&&s.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and setting matter id ${s.response.matter?.id}`),O(u=>{const b=u.findIndex(ce=>ce.name.replaceAll(" ","")===s.response.matter?.id);if(b<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),u;const H=[...u];return H[b]={...H[b],matter:s.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and set matter id ${s.response.matter?.id}`),H})):s.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):s.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):s.method==="state_update"&&s.response.plugin&&s.response.serialNumber&&s.response.cluster.includes("BasicInformation")&&s.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${s.response.plugin} serial ${s.response.serialNumber} value ${s.response.value}`),j(u=>{const b=u.findIndex(H=>H.pluginName===s.response.plugin&&H.serial===s.response.serialNumber);return b<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),u):(u[b]={...u[b],reachable:s.response.value},[...u])})),s.id===D.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),S(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===D.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let u=!0;for(const b of s.response)b.enabled===!0&&(b.loaded!==!0||b.started!==!0||b.error===!0)&&(u=!1);if(!u)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),_(s.response),j([]),x([]),i({id:D.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const b of s.response)b.enabled===!0&&b.loaded===!0&&b.started===!0&&b.error!==!0&&(i({id:D.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:b.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${b.name}`))}}else if(s.id===D.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const u of s.response)u.selected=q(u);j(s.response)}}else s.id===D.current&&s.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} selectDevices for plugin ${s.response&&s.response.length>0?s.response[0].pluginName:"without select devices"}:`,s.response),s.response&&s.response.length>0&&x(u=>{const b=u.filter(ce=>ce.pluginName!==s.response[0].pluginName),H=s.response.map(ce=>({...ce,selected:q(ce)}));return[...b,...H]}))};return a(g,D.current),o&&console.log(`HomeDevices added WebSocket listener id ${D.current}`),()=>{h(g),o&&console.log("HomeDevices removed WebSocket listener")}},[A,a,h,i,q]),r.useEffect(()=>{if(U.length===0&&c.length===0){O([]);return}o&&console.log(`HomeDevices mixing devices (${U.length}) and selectDevices (${c.length})`);const g=[];for(const s of U)g.push(s);for(const s of c)U.find(u=>u.pluginName===s.pluginName&&u.serial.includes(s.serial))||g.push(s);g.length>0&&(O(g),o&&console.log(`HomeDevices mixed ${g.length} devices and selectDevices`))},[A,U,c,O]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:D.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:D.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const N=(g,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${g.target.checked} for device ${s.name} serial ${s.serial}`),U.findIndex(u=>u.pluginName===s.pluginName&&u.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),O(u=>{const b=u.findIndex(H=>H.pluginName===s.pluginName&&H.serial===s.serial);return b<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),u):(u[b]={...u[b],selected:g.target.checked},[...u])})):j(u=>{const b=u.findIndex(H=>H.pluginName===s.pluginName&&H.serial===s.serial);return b<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),u):(u[b]={...u[b],selected:g.target.checked},[...u])}),g.target.checked?i({id:D.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:D.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(Se,{style:{flex:"1 1 auto"},children:e.jsx(St,{name:"Devices",getRowKey:Sn,rows:f,columns:C,footerLeft:I?"Waiting for the plugins to fully load...":`Registered devices: ${U.length.toString()}/${f.length.toString()}`,footerRight:v?"Restart required":""})}):e.jsx(Le,{})}const Mn=r.memo(kn);function Mt({children:n,style:d,name:l}){const{setCurrentPage:i}=r.useContext(Ve);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...d},children:n})}const In=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Dn(){const{messages:n,logAutoScroll:d}=r.useContext(ar),[l,i]=r.useState(!1),a=r.useRef(null),h=r.useRef(0),p=r.useRef(null),v=r.useMemo(()=>In(),[]),t=S=>i(!0),I=S=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${d} isHovering: ${l}`),d&&!l&&!v){const S=Date.now();S-h.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),h.current=S,a.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{a.current?.scrollIntoView({behavior:"smooth"}),h.current=Date.now()},1e3))}},[n,d,l,v]);const y=S=>{switch(S.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},w=S=>{switch(S.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:I,children:[n.map((S,A)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:y(S.level),color:w(S.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:S.level}),S.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+S.time+"]"}),S.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+S.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:S.message})]},A)),e.jsx("div",{ref:a})]})})}const dr=r.memo(Dn);function Pn(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{online:p}=r.useContext(be);return o&&console.log("HomeLogs rendering..."),p?e.jsxs(Se,{style:{flex:"1 1 auto"},children:[e.jsxs(Ue,{children:[e.jsx(_e,{children:"Logs"}),e.jsxs(_e,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l,'" Scroll: ',a?"auto":"manual"]})]}),e.jsx(kt,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(dr,{})})]}):e.jsx(Le,{})}const Ln=r.memo(Pn);function $n(){const{online:n}=r.useContext(be);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Se,{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(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(Ar,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Le,{})}const Nn=r.memo($n);function Wn({changelog:n}){const{online:d}=r.useContext(be);return o&&console.log("HomeShowChangelog rendering..."),d?e.jsxs(Se,{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(ae,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(_r,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(zr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Le,{})}const Tn=r.memo(Wn);function Fn(){const[n,d]=r.useState(null),[l,i]=r.useState(null),[a,h]=r.useState([]),[p]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[v,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[I,y]=r.useState(""),[w,S]=r.useState(!1),[A,_]=r.useState(!1),[U,j]=r.useState(null),{addListener:c,removeListener:x,online:f,sendMessage:O,getUniqueId:D}=r.useContext(be),C=r.useRef(D());return r.useEffect(()=>{const q=N=>{o&&console.log("Home received WebSocket Message:",N),N.method==="refresh_required"&&N.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${N.response.changed} and sending /api/settings request`),j(null),h([]),O({id:C.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),O({id:C.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),N.method==="/api/settings"&&N.id===C.current&&(o&&console.log("Home received settings:",N.response),d(N.response.systemInformation),i(N.response.matterbridgeInformation),N.response.matterbridgeInformation.matterbridgeVersion&&y(`https://github.com/Luligu/matterbridge/blob/${N.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&N.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",N.response.matterbridgeInformation.frontendVersion):N.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&N.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",N.response.matterbridgeInformation.frontendVersion),_(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",N.response.matterbridgeInformation.matterbridgeVersion):N.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",N.response.matterbridgeInformation.matterbridgeVersion),S(!0)),N.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),N.method==="/api/plugins"&&N.id===C.current&&(o&&console.log("Home received plugins:",N.response),h(N.response))};return c(q,C.current),o&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{x(q),o&&console.log("Home removed WebSocket listener")}},[c,x,O]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${U}`),l?.bridgeMode==="bridge"&&!U&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),j("Matterbridge")),l?.bridgeMode==="childbridge"&&!U&&a){for(const q of a)if(q.matter?.id){o&&console.log(`Home storeId effect set storeId to ${q.matter.id}`),j(q.matter.id);break}}},[l,a,U]),r.useEffect(()=>{f&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),O({id:C.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),O({id:C.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[f,O]),o&&console.log("Home rendering..."),!f||!n||!l?e.jsx(Le,{}):e.jsxs(Mt,{name:"Home",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(un,{id:U}),e.jsx(dn,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[A&&e.jsx(Nn,{}),w&&e.jsx(Tn,{changelog:I}),p&&!l.readOnly&&e.jsx(mn,{}),p&&e.jsx(Cn,{storeId:U,setStoreId:j}),v==="devices"&&e.jsx(Mn,{storeId:U,setStoreId:j}),v==="logs"&&e.jsx(Ln,{})]})]})}const Rn=r.memo(Fn),vt=!1,Zt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Hn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},On={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Yt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Vn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},En={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},An={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},_n={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},zn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Lt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Un=[256,257,268,269],qn=[266,267],Bn=[259,260,261,271,272],Qn=[256,257,268,269,266,267,259,260,261,272];function Z({icon:n,iconColor:d,cluster:l,value:i,unit:a,prefix:h}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),h=h??!1,e.jsxs(X,{sx:Zt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Hn,color:d??"var(--primary-color)"}}),e.jsxs(X,{sx:{...Zt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&h===!0&&e.jsx(le,{sx:Yt,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(le,{sx:On,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&h===!1&&e.jsx(le,{sx:Yt,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function Kn({device:n,endpoint:d,id:l,deviceType:i,clusters:a}){const h=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let p="";o&&console.log(`Device "${n.name}" endpoint "${d}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${a?.length})`);const v=a.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(v){let t="";v.map(I=>{I.label&&(t+=I.label+" ")}),p=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>p=`${t.attributeLocalValue} mV`),Qn.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>p=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>p=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>p=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>p=p+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>p=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>p=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>p=p+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>p=p+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="currentMode")?.attributeLocalValue;p=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}if(i===116){const t=a.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="currentMode")?.attributeLocalValue;p=a.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}return 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&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:t.attributeLocalValue===!0?e.jsx(nt,{}):e.jsx(Ur,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(Z,{icon:e.jsx(wt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(Z,{icon:e.jsx(or,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Un.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),qn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Bn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:$o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(_t,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(Br,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(Z,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(Z,{icon:t.attributeValue==="1"?e.jsx(Kr,{}):e.jsx(Gr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Z,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(Z,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Z,{icon:e.jsx(zt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Z,{icon:e.jsx(zt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Kt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Kt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(Z,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:h[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(no,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(io,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:t.attributeValue==="true"?e.jsx(so,{}):e.jsx(ao,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(Z,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(lo,{}):e.jsx(co,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(po,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(Z,{icon:e.jsx(uo,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(X,{sx:Vn,children:e.jsx(le,{sx:En,children:p})}),e.jsx(X,{sx:An,children:e.jsx(le,{sx:_n,children:n.name})}),e.jsxs(X,{sx:zn,children:[o&&e.jsx(le,{sx:Lt,children:d}),e.jsx(le,{sx:Lt,children:l}),o&&e.jsxs(le,{sx:Lt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Gn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[p,v]=r.useState([]),[t,I]=r.useState({}),[y,w]=r.useState({}),[S,A]=r.useState({}),_=r.useRef(h()),U=r.useCallback(x=>{(o||vt)&&console.log(`DevicesIcons received state_update "${x.response.cluster}.${x.response.attribute}" for "${x.response.id}:${x.response.number}": "${x.response.value}"`,x.response);const f=p.find(D=>D.pluginName===x.response.plugin&&D.serial===x.response.serialNumber);if(!f){(o||vt)&&console.warn(`DevicesIcons updater device of plugin "${x.response.plugin}" serial "${x.response.serialNumber}" number "${x.response.number}" id "${x.response.id}" not found in devices(${p.length})`);return}const O=S[f.serial]?.find(D=>D.endpoint===x.response.number.toString()&&D.clusterName===x.response.cluster&&D.attributeName===x.response.attribute);if(!O){(o||vt)&&console.warn(`DevicesIcons updater device "${f.name}" serial "${f.serial}" cluster "${x.response.cluster}" attribute "${x.response.attribute}" not found in clusters(${S[f.serial]?.length})`);return}O.attributeValue=String(x.response.value),O.attributeLocalValue=x.response.value,A({...S}),(o||vt)&&console.log(`DevicesIcons updated "${O.clusterName}.${O.attributeName}" for device "${f.name}" serial "${f.serial}" to "${O.attributeValue}"`)},[S,p]),j=r.useCallback(x=>{if(o&&console.log(`DevicesIcons received for device "${x.response.deviceName}" serial "${x.response.serialNumber}" deviceTypes (${x.response.deviceTypes.length}) "${x.response.deviceTypes.join(",")}" clusters (${x.response.clusters.length}):`,x.response),x.response.clusters.length===0)return;const f=x.response.serialNumber;t[f]=[],y[f]=x.response.deviceTypes,S[f]=[];for(const O of x.response.clusters)t[f].find(D=>D.endpoint===O.endpoint)||t[f].push({endpoint:O.endpoint,id:O.id,deviceTypes:O.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(O.clusterName)&&S[f].push(O);I({...t}),w({...y}),A({...S}),o&&console.log(`DevicesIcons endpoints for "${f}":`,t[f]),o&&console.log(`DevicesIcons deviceTypes for "${f}":`,y[f]),o&&console.log(`DevicesIcons clusters for "${f}":`,S[f])},[S,y,t]);r.useEffect(()=>{const x=f=>{if(o&&console.log("DevicesIcons received WebSocket Message:",f),f.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${f.response.changed} and sending api requests`),l({id:_.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(f.method==="state_update"&&f.response)U(f);else if(f.method==="/api/devices"&&f.response){o&&console.log(`DevicesIcons received ${f.response.length} devices:`,f.response),v(f.response),I({}),w({}),A({});for(const O of f.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:_.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:O.pluginName,endpoint:O.endpoint||0}})}else f.method==="/api/clusters"&&f.response&&j(f)};return i(x,_.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(x),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[p]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),d&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:_.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[d,l]);const c=r.memo(Kn);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:p.filter(x=>x.name.toLowerCase().includes(n)||x.serial.toLowerCase().includes(n)).map(x=>t[x.serial]&&t[x.serial].map(f=>f.deviceTypes.map(O=>e.jsx(c,{device:x,endpoint:f.endpoint,id:f.id,deviceType:O,clusters:S[x.serial].filter(D=>D.endpoint===f.endpoint)},`${x.pluginName}-${x.uniqueId}-${f.endpoint}-${f.id}-${O.toString()}`))))})}const Jn=r.memo(Gn),Zn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,d,l,i)=>l.configUrl?e.jsx(K,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(nr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Yn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,d,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(n,d,l,i)=>e.jsx(E,{title:String(n),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(n)})})}],Xn=n=>`${n.pluginName}::${n.uniqueId}`,ei=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function ti({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[p,v]=r.useState([]),[t,I]=r.useState(p),[y,w]=r.useState([]),[S,A]=r.useState(0),[_,U]=r.useState(null),[j,c]=r.useState(null),[x,f]=r.useState(null),[O,D]=r.useState(null),C=r.useRef(h()),q=r.useRef(t),N=r.useCallback(s=>{o&&console.log(`DevicesTable received state_update "${s.response.cluster}.${s.response.attribute}" for "${s.response.id}:${s.response.number}": "${s.response.value}"`,s.response);const u=q.current.find(b=>b.pluginName===s.response.plugin&&b.uniqueId===s.response.uniqueId);if(!u){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(_&&j&&u.pluginName===_&&u.uniqueId===O&&s.response.number.toString()===j){const b=y.find(H=>H.endpoint===s.response.number.toString()&&H.clusterName===s.response.cluster&&H.attributeName===s.response.attribute);if(!b){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${u.name}" serial "${u.serial}" not found in clusters`);return}b.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),b.attributeLocalValue=s.response.value,w([...y]),o&&console.log(`DevicesTable updated attribute ${b.clusterName}.${b.attributeName} for device "${u.name}" serial "${u.serial}" to "${b.attributeValue}"`)}},[y,j,_,O]);r.useEffect(()=>{const s=u=>{if(o&&console.log("DevicesTable received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${u.response.changed} and sending /api/devices request`),l({id:C.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)N(u);else if(u.method==="/api/devices")o&&console.log(`DevicesTable received ${u.response.length} devices:`,u.response),v(u.response);else if(u.method==="/api/clusters"){o&&console.log(`DevicesTable received ${u.response.clusters.length} clusters for plugin ${u.response.plugin}:`,u.response),w(u.response.clusters);const b={};for(const H of u.response.clusters)o&&console.log("Cluster:",H.endpoint),b[H.endpoint]?b[H.endpoint]++:b[H.endpoint]=1;A(Object.keys(b).length)}};return i(s,C.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,N]),r.useEffect(()=>{d&&(o&&console.log("DevicesTable sending api requests with id ",C.current),l({id:C.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:C.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:C.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,l]),r.useEffect(()=>{_&&j&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:C.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:_,endpoint:Number(j)}}))},[_,j,l]),r.useEffect(()=>{if(n===""){I(p),q.current=p;return}const s=p.filter(u=>u.name.toLowerCase().includes(n)||u.serial.toLowerCase().includes(n));I(s),q.current=s},[p,n]);const g=s=>{if(s.uniqueId===O){D(null),U(null),c(null),f(null);return}D(s.uniqueId),U(s.pluginName),c(s.endpoint?s.endpoint.toString():null),f(s.name)};return o&&console.log("DevicesTable rendering..."),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${_&&j?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Registered devices",getRowKey:Xn,onRowClick:g,rows:t,columns:Zn,footerLeft:`Total devices: ${t.length.toString()}`})}),_&&j&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Clusters",title:x||"",getRowKey:ei,rows:y,columns:Yn,footerLeft:`Total child endpoints: ${S-1}`})})]}):e.jsx(Le,{})}const ri=r.memo(ti);function oi(){const{online:n}=r.useContext(be),[d,l]=r.useState(""),[i,a]=r.useState("icon");r.useEffect(()=>{const v=localStorage.getItem("devicesFilter");v&&l(v)},[]),r.useEffect(()=>{const v=localStorage.getItem("devicesViewMode");v&&a(v)},[]);const h=v=>{l(v.target.value.toLowerCase()),localStorage.setItem("devicesFilter",v.target.value.toLowerCase())},p=v=>{a(v),localStorage.setItem("devicesViewMode",v)};return o&&console.log("Devices rendering..."),n?e.jsxs(Mt,{name:"Devices",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{variant:"outlined",value:d,onChange:h,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(K,{onClick:()=>p("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(E,{title:"Table View",children:e.jsx(go,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(K,{onClick:()=>p("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(E,{title:"Icon View (beta)",children:e.jsx(mo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(ri,{filter:d}),i==="icon"&&e.jsx(Jn,{filter:d})]}):e.jsx(Le,{})}const ni=r.memo(oi);function ii(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:p,setLogFilterLevel:v,setLogFilterSearch:t,online:I,setLogAutoScroll:y,filterLogMessages:w}=r.useContext(be),S=j=>{d(j.target.value),v(j.target.value),w(j.target.value,l),localStorage.setItem("logFilterLevel",j.target.value),o&&console.log("handleChangeLevel called with value:",j.target.value)},A=j=>{i(j.target.value),t(j.target.value),w(n,j.target.value),localStorage.setItem("logFilterSearch",j.target.value),o&&console.log("handleChangeSearch called with value:",j.target.value)},_=j=>{h(j.target.checked),y(j.target.checked),w(n,l),localStorage.setItem("logAutoScroll",j.target.checked?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",j.target.checked)},U=()=>{o&&console.log("handleClearLogsClick called"),p([])};return o&&console.log("Logs rendering..."),I?e.jsxs(Mt,{name:"Logs",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(Ut,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:S,children:[e.jsx(L,{value:"debug",children:"Debug"}),e.jsx(L,{value:"info",children:"Info"}),e.jsx(L,{value:"notice",children:"Notice"}),e.jsx(L,{value:"warn",children:"Warn"}),e.jsx(L,{value:"error",children:"Error"}),e.jsx(L,{value:"fatal",children:"Fatal"})]}),e.jsx(Ut,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(he,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:A,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(He,{control:e.jsx(Oe,{checked:a,onChange:_}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(E,{title:"Clear the logs",children:e.jsx(ae,{onClick:U,endIcon:e.jsx(Wt,{}),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(dr,{})})]}):e.jsx(Le,{})}const si=r.memo(ii),ai=({open:n,ip:d,onClose:l,onSave:i})=>{const a=d?d.split(".").slice(0,3).join(".")+".1":"",[h,p]=r.useState("dhcp"),[v,t]=r.useState({ip:d??"",subnet:"255.255.255.0",gateway:a,dns:a}),I=S=>A=>{t({...v,[S]:A.target.value})},y=()=>{l()},w=()=>{i({type:h,...v}),l()};return e.jsxs(Ne,{open:n,onClose:(S,A)=>{A==="backdropClick"||A==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(We,{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(Te,{dividers:!0,children:[e.jsxs(ir,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(sr,{row:!0,value:h,onChange:S=>p(S.target.value),children:[e.jsx(He,{value:"dhcp",control:e.jsx(Ct,{}),label:"DHCP"}),e.jsx(He,{value:"static",control:e.jsx(Ct,{}),label:"Static"})]})]}),h==="static"&&e.jsxs(Ee,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ee,{size:6,children:e.jsx(he,{label:"IP Address",fullWidth:!0,value:v.ip,onChange:I("ip")})}),e.jsx(Ee,{size:6,children:e.jsx(he,{label:"Subnet Mask",fullWidth:!0,value:v.subnet,onChange:I("subnet")})}),e.jsx(Ee,{size:6,children:e.jsx(he,{label:"Gateway",fullWidth:!0,value:v.gateway,onChange:I("gateway")})}),e.jsx(Ee,{size:6,children:e.jsx(he,{label:"DNS Server",fullWidth:!0,value:v.dns,onChange:I("dns")})})]})]}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:y,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:w,children:"Save"})]})]})},li=({open:n,onClose:d,onSave:l})=>{const[i,a]=r.useState(""),[h,p]=r.useState(""),v=A=>{a(A.target.value)},t=A=>{p(A.target.value)},I=i.length>0&&i===h,y=()=>{d()},w=()=>{I&&(l(i),d())},S=()=>{l(""),d()};return e.jsxs(Ne,{open:n,onClose:(A,_)=>{_==="backdropClick"||_==="escapeKeyDown"||d()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(We,{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(Te,{dividers:!0,children:e.jsx(ir,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Ee,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ee,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:v})}),e.jsx(Ee,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:h,onChange:t,error:h!==""&&i!==h,helperText:h!==""&&i!==h?"Passwords do not match":""})})]})})}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:y,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:w,disabled:!I,children:"Change"}),e.jsx(ae,{variant:"contained",onClick:S,children:"Reset"})]})]})};function Ze(n=1e3){let d=null;const l=(i=>{d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{i(),d=null},n)});return l.cancel=()=>{d!==null&&(window.clearTimeout(d),d=null)},l}const ue=500;function di(){const{online:n,addListener:d,removeListener:l,sendMessage:i,getUniqueId:a}=r.useContext(be),[h,p]=r.useState(null),[v,t]=r.useState(null),I=r.useRef(a());return r.useEffect(()=>{const y=w=>{o&&console.log("Settings received WebSocket Message:",w),w.method==="refresh_required"&&w.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${w.response.changed} and sending /api/settings request`),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):w.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",w.response),p(w.response.matterbridgeInformation),t(w.response.systemInformation))};return d(y,I.current),o&&console.log("Settings added WebSocket listener"),()=>{l(y),o&&console.log("Settings removed WebSocket listener")}},[d,l,i]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,i]),o&&console.log("Settings rendering..."),!n||!h||!v?e.jsx(Le,{}):e.jsx(Mt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(ci,{matterbridgeInfo:h,systemInfo:v}),e.jsx(pi,{matterbridgeInfo:h}),e.jsx(ui,{matterbridgeInfo:h}),e.jsx(gi,{systemInfo:v})]})})}function ci({matterbridgeInfo:n,systemInfo:d}){const{sendMessage:l,getUniqueId:i}=r.useContext(be),[a,h]=r.useState("bridge"),[p,v]=r.useState("Info"),[t,I]=r.useState(!1),[y,w]=r.useState("dark"),[S,A]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[_,U]=r.useState(localStorage.getItem("homePageMode")??"devices"),[j,c]=r.useState(localStorage.getItem("virtualMode")??"outlet"),x=r.useRef(i()),[f,O]=r.useState(!1),D=()=>O(!1),C=R=>{o&&console.log("handleSaveNetConfig called with config:",R),l({id:x.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:R})},[q,N]=r.useState(!1),g=()=>N(!1),s=R=>{o&&console.log("handleSaveChangePassword called with password:",R),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:R}}),ki(R)};r.useEffect(()=>{n&&(h(n.bridgeMode==="bridge"?"bridge":"childbridge"),v(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),I(n.fileLogger),c(n.virtualMode))},[n]),r.useEffect(()=>{const R=localStorage.getItem("frontendTheme");R&&w(R)},[]);const u=R=>{o&&console.log("handleChangeBridgeMode called with value:",R.target.value),h(R.target.value),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:R.target.value}})},b=R=>{o&&console.log("handleChangeMbLoggerLevel called with value:",R.target.value),v(R.target.value),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:R.target.value}})},H=R=>{o&&console.log("handleLogOnFileMbChange called with value:",R.target.checked),I(R.target.checked),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:R.target.checked}})},ce=R=>{const B=R.target.value;o&&console.log("handleChangeTheme called with value:",B),w(B),localStorage.setItem("frontendTheme",B),document.body.setAttribute("frontend-theme",B)},ye=R=>{const B=R.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",B),A(B),localStorage.setItem("homePagePlugins",B?"true":"false")},ie=R=>{const B=R.target.value;o&&console.log("handleChangeHomePageMode called with value:",B),U(B),localStorage.setItem("homePageMode",B)},je=R=>{const B=R.target.value;o&&console.log("handleChangeVirtualMode called with value:",B),c(B),localStorage.setItem("virtualMode",B),l({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:B}})};return!n||!d?null:e.jsxs(Se,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(ai,{open:f,ip:d.ipv4Address,onClose:D,onSave:C}),e.jsx(li,{open:q,onClose:g,onSave:s}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(sr,{row:!0,name:"mode-buttons-group",value:a,onChange:u,children:[e.jsx(He,{value:"bridge",control:e.jsx(Ct,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(He,{value:"childbridge",control:e.jsx(Ct,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:p,onChange:b,children:[e.jsx(L,{value:"Debug",children:"Debug"}),e.jsx(L,{value:"Info",children:"Info"}),e.jsx(L,{value:"Notice",children:"Notice"}),e.jsx(L,{value:"Warn",children:"Warn"}),e.jsx(L,{value:"Error",children:"Error"}),e.jsx(L,{value:"Fatal",children:"Fatal"})]}),e.jsx(He,{style:{padding:"0px",margin:"0px"},control:e.jsx(Oe,{checked:t,onChange:H,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:y,onChange:ce,children:[e.jsx(L,{value:"classic",children:"Classic"}),e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Oe,{checked:S,onChange:ye,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:_,onChange:ie,children:[e.jsx(L,{value:"logs",children:"Logs"}),e.jsx(L,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:j,onChange:je,children:[e.jsx(L,{value:"disabled",children:"Disabled"}),e.jsx(L,{value:"outlet",children:"Outlet"}),e.jsx(L,{value:"light",children:"Light"}),e.jsx(L,{value:"switch",children:"Switch"}),e.jsx(L,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>N(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>O(!0),children:"Configure IP"})})]})})]})}function pi({matterbridgeInfo:n}){const{sendMessage:d,getUniqueId:l}=r.useContext(be),[i,a]=r.useState("Info"),[h,p]=r.useState(!1),[v,t]=r.useState(""),[I,y]=r.useState(""),[w,S]=r.useState(""),[A,_]=r.useState(""),[U,j]=r.useState(""),[c,x]=r.useState(""),f=r.useRef(l()),O=r.useMemo(()=>Ze(1e3),[]),D=r.useMemo(()=>Ze(1e3),[]),C=r.useMemo(()=>Ze(1e3),[]),q=r.useMemo(()=>Ze(1e3),[]),N=r.useMemo(()=>Ze(1e3),[]),g=r.useMemo(()=>Ze(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),p(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),S(n.matterIpv6Address||""),_(n.matterPort?n.matterPort.toString():""),j(n.matterDiscriminator?n.matterDiscriminator.toString():""),x(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>O.cancel(),[O]),r.useEffect(()=>()=>D.cancel(),[D]),r.useEffect(()=>()=>C.cancel(),[C]),r.useEffect(()=>()=>q.cancel(),[q]),r.useEffect(()=>()=>N.cancel(),[N]),r.useEffect(()=>()=>g.cancel(),[g]);const s=R=>{o&&console.log("handleChangeMjLoggerLevel called with value:",R.target.value),a(R.target.value),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:R.target.value}})},u=R=>{o&&console.log("handleLogOnFileMjChange called with value:",R.target.checked),p(R.target.checked),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:R.target.checked}})},b=R=>{o&&console.log("handleChangeMdnsInterface called with value:",R.target.value);const B=R.target.value;t(B),O(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",B),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:B}})})},H=R=>{o&&console.log("handleChangeIpv4Address called with value:",R.target.value);const B=R.target.value;y(B),D(()=>{o&&console.log("debounced sendMessage setipv4address with value:",B),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:B}})})},ce=R=>{o&&console.log("handleChangeIpv6Address called with value:",R.target.value);const B=R.target.value;S(B),C(()=>{o&&console.log("debounced sendMessage setipv6address with value:",B),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:B}})})},ye=R=>{o&&console.log("handleChangeMatterPort called with value:",R.target.value);const B=R.target.value;_(B),q(()=>{o&&console.log("debounced sendMessage setmatterport with value:",B),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:B}})})},ie=R=>{o&&console.log("handleChangeMatterDiscriminator called with value:",R.target.value);const B=R.target.value;j(B),N(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",B),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:B}})})},je=R=>{o&&console.log("handleChangemMatterPasscode called with value:",R.target.value);const B=R.target.value;x(B),g(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",B),d({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:B}})})};return n?e.jsxs(Se,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:s,children:[e.jsx(L,{value:"Debug",children:"Debug"}),e.jsx(L,{value:"Info",children:"Info"}),e.jsx(L,{value:"Notice",children:"Notice"}),e.jsx(L,{value:"Warn",children:"Warn"}),e.jsx(L,{value:"Error",children:"Error"}),e.jsx(L,{value:"Fatal",children:"Fatal"})]}),e.jsx(He,{style:{padding:"0px",margin:"0px"},control:e.jsx(Oe,{checked:h,onChange:u,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(he,{value:v,onChange:b,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(he,{value:I,onChange:H,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(he,{value:w,onChange:ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(he,{value:A,onChange:ye,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(he,{value:U,onChange:ie,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(he,{value:c,onChange:je,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function ui({matterbridgeInfo:n}){return n?e.jsxs(Se,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(Me,{value:n.matterbridgeVersion,label:"Current Version",width:ue}),e.jsx(Me,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ue}),e.jsx(Me,{value:n.rootDirectory,label:"Root Directory",width:ue}),e.jsx(Me,{value:n.homeDirectory,label:"Home Directory",width:ue}),e.jsx(Me,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ue}),e.jsx(Me,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ue}),e.jsx(Me,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ue})]})})]}):null}function gi({systemInfo:n}){return n?e.jsxs(Se,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(Me,{value:n.interfaceName,label:"Interface name",width:ue}),e.jsx(Me,{value:n.macAddress,label:"MAC Address",width:ue}),e.jsx(Me,{value:n.ipv4Address,label:"IPv4 Address",width:ue}),e.jsx(Me,{value:n.ipv6Address,label:"IPv6 Address",width:ue}),e.jsx(Me,{value:n.nodeVersion,label:"Node Version",width:ue}),e.jsx(Me,{value:n.hostname,label:"Hostname",width:ue}),e.jsx(Me,{value:n.user,label:"User",width:ue})]})})]}):null}function Me({value:n,label:d,width:l}){return e.jsx(he,{focused:!0,value:n,size:"small",label:d,variant:"standard",sx:{width:l?`${l-20}px`:"400px","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const mi=r.memo(di);function hi(){const{online:n,sendMessage:d,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(be),{showSnackbarMessage:h}=r.useContext(Ve),[p,v]=r.useState(null),[t,I]=r.useState([]),[y,w]=r.useState([]),[S,A]=r.useState(null),[_,U]=r.useState({cpuUsage:0}),[j,c]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[x,f]=r.useState({systemUptime:"",processUptime:""}),O=r.useRef(a());return o&&console.log("Test uniqueId:",O),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const D=C=>{if(C.method==="restart_required")o&&console.log("Test received restart_required"),h("Restart required",0);else if(C.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${C.response.changed} and sending api requests`),h("Refresh required",0),d({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(C.method==="memory_update")o&&console.log("Test received memory_update",C),c(C.response);else if(C.method==="cpu_update")o&&console.log("Test received cpu_update",C),U(C.response);else if(C.method==="uptime_update")o&&console.log("Test received uptime_update",C),f(C.response);else if(C.method==="/api/settings"&&C.response)o&&console.log("Test received /api/settings:",C.response),h("Test received /api/settings",0),v(C.response);else if(C.method==="/api/plugins"&&C.response)o&&console.log(`Test received ${C.response.length} plugins:`,C.response),h("Test received /api/plugins",0),I(C.response);else if(C.method==="/api/devices"&&C.response){o&&console.log(`Test received ${C.response.length} devices:`,C.response),h("Test received /api/devices",0),w(C.response);for(const q of C.response)o&&console.log("Test sending /api/clusters for device:",q.pluginName,q.name,q.endpoint),d({id:O.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:q.pluginName,endpoint:q.endpoint||0}})}else C.method==="/api/clusters"&&C.response&&(o&&console.log(`Test received ${C.response.clusters.length} clusters for device ${C.response.deviceName} endpoint ${C.response.id}:${C.response.number}:`,C),h(`Test received /api/clusters for ${C.response.plugin}::${C.response.deviceName}`,0),A(C.response))};return l(D,O.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(D),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,d,h]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,d,h]),o&&console.log("Test rendering..."),n?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(Le,{})}const fi=r.memo(hi);function xi(n,d){o&&console.log("getCssVariable:",n,"defaultValue",d);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||d}function bi(n){return ho({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function vi(){const{mobile:n,showSnackbarMessage:d,showConfirmCancelDialog:l}=r.useContext(Ve),{online:i,sendMessage:a,logMessage:h,addListener:p,removeListener:v,getUniqueId:t}=r.useContext(be),[I,y]=r.useState(!1),[w,S]=r.useState(!1),[A,_]=r.useState(!1),[U,j]=r.useState(!1),[c,x]=r.useState(null),f=r.useRef(t()),[O,D]=r.useState(null),[C,q]=r.useState(null),[N,g]=r.useState(null),[s,u]=r.useState(null),[b,H]=r.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},ye=()=>{window.open("https://matterbridge.io/")},ie=()=>{window.open("https://matterbridge.io/README.html")},je=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},R=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},B=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},F=()=>{a({id:f.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},J=()=>{a({id:f.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},W=()=>{a({id:f.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),h("Matterbridge","Installing system updates..."),a({id:f.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),h("Matterbridge","Installing software updates..."),a({id:f.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:f.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},$=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),h("Matterbridge","Downloading Shelly system log..."),d("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},G=()=>{c?.matterbridgeInformation.restartMode===""?a({id:f.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:f.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},se=()=>{a({id:f.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},oe=()=>{a({id:f.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{a({id:f.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=()=>{a({id:f.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},pe=V=>{D(V.currentTarget)},P=V=>{o&&console.log("Header: handleMenuClose",V),D(null),V==="download-mblog"?(h("Matterbridge","Downloading matterbridge log..."),d("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):V==="download-mjlog"?(h("Matterbridge","Downloading matter log..."),d("Downloading matter log...",5),window.location.href="./api/download-mjlog"):V==="view-mblog"?(h("Matterbridge","Loading matterbridge log..."),d("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):V==="view-mjlog"?(h("Matterbridge","Loading matter log..."),d("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):V==="view-diagnostic"?(h("Matterbridge","Loading diagnostic log..."),d("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):V==="download-diagnostic"?(h("Matterbridge","Downloading diagnostic log..."),d("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):V==="view-history"?a({id:f.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):V==="download-history"?a({id:f.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):V==="view-shellylog"?(h("Matterbridge","Loading shelly system log..."),d("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):V==="download-mbstorage"?(h("Matterbridge","Downloading matterbridge storage..."),d("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):V==="download-pluginstorage"?(h("Matterbridge","Downloading matterbridge plugins storage..."),d("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):V==="download-pluginconfig"?(h("Matterbridge","Downloading matterbridge plugins config..."),d("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):V==="download-mjstorage"?(h("Matterbridge","Downloading matter storage..."),d("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):V==="download-backup"?(h("Matterbridge","Downloading backup..."),d("Downloading backup...",10),window.location.href="./api/download-backup"):V==="update"?F():V==="updatedev"?J():V==="updatecheck"?W():V==="shelly-sys-update"?T():V==="shelly-main-update"?M():V==="shelly-create-system-log"?k():V==="shelly-download-system-log"?$():V==="softreset"?de():V==="hardreset"?ge():V==="restart"?G():V==="shutdown"?se():V==="reboot"?oe():V==="create-backup"?a({id:f.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):V==="unregister"?a({id:f.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):V==="reset"?a({id:f.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):V==="factoryreset"&&a({id:f.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},m=V=>{o&&console.log("Header: handleMenuCloseCancel:",V),D(null)},xe=V=>{q(V.currentTarget)},te=()=>{q(null)},fe=V=>{g(V.currentTarget)},Y=()=>{g(null)},me=V=>{u(V.currentTarget)},ve=()=>{u(null)},tt=V=>{H(V.currentTarget)},$e=()=>{H(null)},z=()=>{Ci(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const V=re=>{o&&console.log("Header received WebSocket Message:",re),re.method==="/api/settings"&&re.id===f.current?(o&&console.log("Header received settings:",re.response),x(re.response),y(re.response.matterbridgeInformation.restartRequired||re.response.matterbridgeInformation.fixedRestartRequired),S(re.response.matterbridgeInformation.fixedRestartRequired),_(re.response.matterbridgeInformation.updateRequired)):re.method==="refresh_required"&&re.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${re.response.changed} and sending /api/settings request`),a({id:f.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${re.response.fixed}`),y(!0),re.response.fixed===!0&&S(!0)):re.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),y(!1)):re.method==="update_required"?(o&&console.log("Header received update_required"),re.response.devVersion===!0?j(!0):_(!0),a({id:f.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),x(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),x(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="/api/viewhistorypage"&&re.id===f.current&&re.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):re.method==="/api/downloadhistorypage"&&re.id===f.current&&re.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return p(V,f.current),o&&console.log(`Header added WebSocket listener id ${f.current}`),()=>{v(V),o&&console.log("Header removed WebSocket listener")}},[p,v,a,d]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:f.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:f.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!c?null:e.jsxs("div",{className:"header",style:{},children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:z}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(at,{to:"/",className:"nav-link",children:"Home"}),e.jsx(at,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(at,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(at,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!c.matterbridgeInformation.readOnly&&e.jsx(E,{title:`Matterbridge v.${c.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",c.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(c.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),c.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),c.matterbridgeInformation.bridgeMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.bridgeMode})}):null,c.matterbridgeInformation.restartMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.restartMode})}):null,c.matterbridgeInformation.profile&&c.matterbridgeInformation.profile!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:R})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Give a star to Matterbridge",children:e.jsx(K,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:B,children:e.jsx(fo,{})})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Sponsor Matterbridge",children:e.jsx(K,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(rr,{})})}):null,e.jsx(E,{title:"Matterbridge homepage",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ye,children:e.jsx(xo,{})})}),e.jsx(E,{title:"Matterbridge help",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ie,children:e.jsx(er,{})})}),e.jsx(E,{title:"Matterbridge changelog",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:je,children:e.jsx(tr,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&A&&e.jsx(E,{title:`Update matterbridge to latest version v.${c.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(K,{style:{color:A?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:F,children:e.jsx(Pe,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&U&&e.jsx(E,{title:`Update matterbridge to latest dev version v.${c.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(K,{style:{color:U?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:J,children:e.jsx(Pe,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsx(E,{title:"Shelly system update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:T,children:e.jsx(Pe,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsx(E,{title:"Shelly software update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(Pe,{})})}),e.jsx(E,{title:"Restart matterbridge",children:e.jsx(K,{style:{color:I||w?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:G,children:e.jsx(jt,{})})}),c.matterbridgeInformation.restartMode===""?e.jsx(E,{title:"Shut down matterbridge",children:e.jsx(K,{style:{color:I||w?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:se,children:e.jsx(ze,{})})}):null,e.jsx(E,{title:"Download, backup and more",children:e.jsx(K,{onClick:pe,children:e.jsx(bo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ye,{id:"command-menu",anchorEl:O,keepMounted:!0,open:!!O,onClose:()=>P(""),children:[c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>P("update"),children:[e.jsx(Q,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>P("updatedev"),children:[e.jsx(Q,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>P("updatecheck"),children:[e.jsx(Q,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsxs(L,{onClick:()=>P("shelly-sys-update"),children:[e.jsx(Q,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsxs(L,{onClick:()=>P("shelly-main-update"),children:[e.jsx(Q,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>P("restart"),children:[e.jsx(Q,{children:e.jsx(jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation.restartMode===""?e.jsxs(L,{onClick:()=>P("shutdown"),children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",P,m)},children:[e.jsx(Q,{children:e.jsx(jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(ut,{}),e.jsxs(L,{onClick:fe,children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-view",anchorEl:N,keepMounted:!0,open:!!N,onClose:Y,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{P("view-mblog"),Y()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("view-mjlog"),Y()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("view-diagnostic"),Y()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("view-history"),Y()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{P("view-shellylog"),Y()},children:[e.jsx(Q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ut,{}),e.jsxs(L,{onClick:me,children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{P("download-mbstorage"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-pluginstorage"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-pluginconfig"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-mblog"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-mjstorage"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-mjlog"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-diagnostic"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-history"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{P("shelly-create-system-log"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{P("shelly-download-system-log"),ve()},children:[e.jsx(Q,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ut,{}),e.jsxs(L,{onClick:xe,children:[e.jsx(Q,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-backup",anchorEl:C,keepMounted:!0,open:!!C,onClose:te,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{P("create-backup"),te()},children:[e.jsx(Q,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{P("download-backup"),te()},children:[e.jsx(Q,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ut,{}),e.jsxs(L,{onClick:tt,children:[e.jsx(Q,{children:e.jsx(vo,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-reset",anchorEl:b,keepMounted:!0,open:!!b,onClose:$e,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(L,{onClick:()=>{$e(),l("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",P,m)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(L,{onClick:()=>{$e(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",P,m)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!c.matterbridgeInformation.readOnly&&e.jsxs(L,{onClick:()=>{$e(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",P,m)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{$e(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",P,m)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(L,{onClick:()=>{$e(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",P,m)},children:[e.jsx(Q,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const yi=r.memo(vi),cr=1300,pr=1024;let $t,Nt;function ji(){if(typeof window<"u"){$t=Math.floor(window.visualViewport?.width??window.innerWidth),Nt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=$t<cr||Nt<pr;return o&&console.log("Visual viewport width %i height %i mobile %s",$t,Nt,n),n}return!1}function wi({children:n}){const{mobile:d,setMobile:l}=r.useContext(Ve);return r.useEffect(()=>{function i(){l(ji())}return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",d),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:d?`${cr}px`:"calc(100vw - 40px)",height:d?`${pr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(yi,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const Ci=()=>{o=!o},Si=!1;let et;const ki=n=>{et=n};function Mi({setLoggedIn:n}){const[d,l]=r.useState(""),[i,a]=r.useState(""),h={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},p={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},v={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async y=>{try{const w=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(w.ok){const{valid:S}=await w.json();S?(n(!0),y!==""&&(et=y)):y!==""&&a("Incorrect password!")}else console.error("Failed to log in:",w.statusText)}catch(w){console.error("Failed to log in:",w)}},I=y=>{y.preventDefault(),t(d)};return t(""),e.jsx("div",{style:h,children:e.jsxs("form",{onSubmit:I,style:p,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:d,onChange:y=>l(y.target.value),style:v,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function Ii(){const[n,d]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=xi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=bi(i);window.location.href.includes("/api/hassio_ingress/");const h=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${h}"`)),n?e.jsx(yo,{theme:a,children:e.jsx(Dr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(on,{children:e.jsx(nn,{children:e.jsx(wr,{basename:h,children:e.jsx(wi,{children:e.jsxs(Cr,{children:[e.jsx(qe,{path:"/",element:e.jsx(Rn,{})}),e.jsx(qe,{path:"/devices",element:e.jsx(ni,{})}),e.jsx(qe,{path:"/log",element:e.jsx(si,{})}),e.jsx(qe,{path:"/settings",element:e.jsx(mi,{})}),e.jsx(qe,{path:"/test",element:e.jsx(fi,{})}),e.jsx(qe,{path:"*",element:e.jsx(Sr,{to:"/"})})]})})})})})})}):e.jsx(Mi,{setLoggedIn:d})}kr.createRoot(document.getElementById("root")).render(e.jsx(Mr.StrictMode,{children:e.jsx(Ii,{})}));
|