matterbridge 3.4.3 → 3.4.4-dev-20251215-216dfc3
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/dist/broadcastServer.js +0 -119
- package/dist/broadcastServerTypes.js +0 -24
- package/dist/cli.js +1 -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 +46 -811
- 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 +54 -1445
- 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_node_modules.js +1 -1
- package/frontend/package.json +1 -1
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -2
- 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
|
|
2
|
-
`).map((C
|
|
3
|
-
`)},[]),T=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${x}`),localStorage.getItem("installAutoExit")!=="false"&&
|
|
4
|
-
`)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(x.current==="info"&&m.response.level==="debug"||x.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||x.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||x.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||x.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(ee=>{const fe=[...ee,{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)F.current.forEach(xe=>xe.listener(m));else{const xe=F.current.find(ee=>ee.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)}},j.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${se}`),L("WebSocket",`Connected to WebSocket: ${se}`),w(!0),q(),U.current=1,h.current=setTimeout(()=>{d.current=setInterval(()=>{S({id:X.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}`),L("WebSocket",`No pong response received from WebSocket: ${se}`),w(!1)},1e3*T)},1e3*B)},1e3*G)},j.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${je?"with Ingress":""}: ${se}`),L("WebSocket",`Disconnected from WebSocket: ${se}`),w(!1),q(),b(),h.current&&clearTimeout(h.current),s.current&&clearTimeout(s.current),d.current&&clearInterval(d.current),L("WebSocket",`Reconnecting (attempt ${U.current} of ${R}) to WebSocket${je?" (Ingress)":""}: ${se}`),je?setTimeout(ce,5e3):U.current===1?ce():U.current<R?setTimeout(ce,1e3*U.current):L("WebSocket",`Reconnect attempts exceeded limit of ${R} retries, refresh the page to reconnect to: ${se}`),U.current=U.current+1},j.current.onerror=D=>{o&&console.error(`WebSocket: WebSocket error connecting to ${se}:`,D),L("WebSocket",`WebSocket error connecting to ${se}`)})},[se]),ce=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${U.current}/${R} to:`,se),oe()},[oe]);r.useEffect(()=>(oe(),()=>{j.current&&j.current.readyState===WebSocket.OPEN&&j.current.close()}),[oe]);const ge=r.useMemo(()=>({messages:c,logMaxMessages:i,logAutoScroll:I,logFilterLevel:f,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:g,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:M}),[c,i,I,f,v,l,g,t,a,y,M]),pe=r.useMemo(()=>({logMaxMessages:i,logAutoScroll:I,logFilterLevel:f,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:g,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:M,online:C,retry:U.current,getUniqueId:W,addListener:K,removeListener:ae,sendMessage:S,logMessage:L}),[i,I,l,g,t,a,y,C,U.current,K,ae,S,L]);return e.jsx(mr.Provider,{value:ge,children:e.jsx(be.Provider,{value:pe,children:n})})}function pn(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 Te(){const{retry:n}=r.useContext(be),c=()=>{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(pn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Vr,{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(ie,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function hr({value:n,maxChars:c}){let l=n;if(n.length>c&&c>3){const i=c-3,a=n.substring(0,Math.ceil(i/2)),f=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${f}`}return n!==l?e.jsx(O,{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 ke({children:n,style:c}){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,...c},children:n})}function De({children:n,style:c}){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,...c},children:n})}function Me({children:n,style:c}){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,...c},children:n})}function ft({children:n,style:c}){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,...c},children:n})}function xt({children:n,style:c}){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,...c},children:n})}function it({children:n,style:c}){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,...c},children:n})}function Fe({children:n,style:c,onDragOver:l,onDragLeave:i,onDrop:a}){const f={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...f,...c},onDragOver:l,onDragLeave:i,onDrop:a,children:n})}function rt({children:n,style:c,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...c},children:[n,Mi]})}function un({systemInfo:n,compact:c}){const{mobile:l}=r.useContext(Pe),{addListener:i,removeListener:a,getUniqueId:f,sendMessage:g}=r.useContext(be),[v,t]=r.useState(n),I=r.useRef(f());if(o&&console.log("SystemInfoTable loading with systemInfo:",v,"compact:",c),n&&c&&v.totalMemory&&v.freeMemory){const b=v.totalMemory,p=v.freeMemory;v.freeMemory=`${p} / ${b}`,v.totalMemory=""}if(n&&c&&v.heapTotal&&v.heapUsed){const b=v.heapTotal,p=v.heapUsed;v.heapUsed=`${p} / ${b}`,v.heapTotal=""}if(n&&c&&v.osRelease&&v.osType){const b=v.osType,p=v.osRelease;v.osType=`${b} (${p})`,v.osRelease=""}if(n&&c&&v.osArch&&v.osPlatform){const b=v.osPlatform,p=v.osArch;v.osPlatform=`${b} (${p})`,v.osArch=""}const y=(b,p,u,P,F)=>{t(j=>({...j,totalMemory:b,freeMemory:p,heapTotal:u,heapUsed:P,rss:F}))},C=b=>{t(p=>({...p,cpuUsage:b.toFixed(2)+" %"}))},w=b=>{t(p=>({...p,processCpuUsage:b.toFixed(2)+" %"}))},V=(b,p)=>{t(u=>({...u,systemUptime:b,processUptime:p}))},_=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),g({id:I.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const b=p=>{o&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(o&&console.log("SystemInfoTable received memory_update",p),y(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",p),C(p.response.cpuUsage),w(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",p),V(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===I.current&&p.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(b,I.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${I.current}`),()=>{a(b),o&&console.log("SystemInfoTable removed WebSocket listener")}},[i,a]);const[q,N]=r.useState(!1);return!v||q?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(ke,{style:ue&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Me,{children:"System info"}),e.jsx(rt,{onClose:()=>N(!0),children:e.jsx(Q,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:_,children:e.jsx(O,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ne,{path:Mo,size:"22px"})})})})]}),e.jsx(Fe,{style:ue&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(v).filter(([b,p])=>p!==void 0&&p!=="").map(([b,p],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:b.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ue&&l?typeof p!="string"?p.toString():p:e.jsx(hr,{value:typeof p!="string"?p.toString():p,maxChars:22})})]},b))})]})})]}))}const Yt=r.memo(un),Xt={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"}},gn=n=>{if(!n)return"";const c=n.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const l=c.slice(0,4),i=c.slice(4,7),a=c.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function mn({id:n}){const{online:c,sendMessage:l,addListener:i,removeListener:a,getUniqueId:f}=r.useContext(be),[g,v]=r.useState(null),t=r.useRef(null),I=r.useRef(null),y=r.useRef(f()),{mobile:C,showConfirmCancelDialog:w}=r.useContext(Pe);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${I.current} and matter:`,g),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 p=u=>{o&&console.log("QRDiv received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="matter"&&u.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${u.response.changed} for storeId "${u.response.matter.id}":`,u.response.matter),t.current===u.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${u.response.matter.id}":`,u.response.matter),I.current&&clearTimeout(I.current),u.response.matter.advertising&&u.response.matter.advertiseTime&&u.response.matter.advertiseTime+9e5<=Date.now()&&(u.response.matter.advertising=!1),v(u.response.matter),u.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${u.response.matter.id}":`,u.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(P=>P&&{...P,advertising:!1})},u.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,y.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(p),I.current&&clearTimeout(I.current),I.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const V=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,startCommission:!0}})},_=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,stopCommission:!0}})},q=()=>{o&&console.log(`QRDiv sent matter advertise for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,advertise:!0}})},N=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${g?.id}" and fabricIndex ${p}`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,removeFabric:p}})},b=async()=>{if(!g||!g.manualPairingCode)return;const p=g.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const u=document.createElement("textarea");u.value=p,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.focus(),u.select(),document.execCommand("copy"),document.body.removeChild(u)}o&&console.log("Manual pairing code copied to clipboard")}catch(u){console.error("Failed to copy manual pairing code",u)}};return!g||!c?(o&&console.log("QRDiv rendering undefined state"),null):g.online?g.advertising&&g.qrPairingCode&&g.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(ke,{style:ue&&C?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Me,{children:"QR pairing code"}),e.jsxs(rt,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Kt,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:Io,size:"22px"})})})]})]}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Zo,{value:g.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(ft,{style:{justifyContent:"space-between"},children:[e.jsxs(xt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",gn(g.manualPairingCode)]}),e.jsx(rt,{children:e.jsx(O,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:b,sx:Xt,children:e.jsx(ne,{path:Do,size:.85})})})})]})]})):g.commissioned&&g.fabricInformations&&g.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(ke,{style:ue&&C?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(De,{children:[e.jsx(Me,{children:"Paired fabrics"}),e.jsxs(rt,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Kt,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:Gt,size:"22px"})})})]})]}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Fe,{style:{flexDirection:"column",flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px 0px 10px 0px",gap:"0px"},children:g.fabricInformations.map((p,u)=>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: ",p.fabricIndex]}),e.jsx(O,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(Q,{"aria-label":"remove the fabric",size:"small",onClick:()=>w("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>N(p.fabricIndex),()=>{}),sx:{...Xt,padding:"2px"},children:e.jsx(ne,{path:Po,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",g.sessionInformations?g.sessionInformations.filter(P=>P.fabric?.fabricIndex===p.fabricIndex&&P.isPeerActive===!0).length:"0"," ","subscriptions: ",g.sessionInformations?g.sessionInformations.filter(P=>P.fabric?.fabricIndex===p.fabricIndex&&P.isPeerActive===!0&&P.numberOfActiveSubscriptions>0).length:"0"]})]},u))}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]})):!g.commissioned&&!g.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(ke,{style:ue&&C?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(De,{children:e.jsx(Me,{children:"QR pairing code"})}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ie,{onClick:V,endIcon:e.jsx(ne,{path:Gt,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(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(ke,{style:ue&&C?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(De,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Me,{children:"Server node"})}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(it,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]}))}const er=r.memo(mn);function hn(){const{mobile:n}=r.useContext(Pe),{logMessage:c,sendMessage:l,getUniqueId:i}=r.useContext(be),[a,f]=r.useState("matterbridge-"),[g,v]=r.useState(!1),[t,I]=r.useState(null),y=r.useRef(i()),C=d=>{d.preventDefault(),v(!0)},w=()=>{v(!1)},V=d=>{d.preventDefault(),v(!1);const s=d.dataTransfer.files[0];if(s){c("Plugins",`Installing package ${s.name}. Please wait...`);const h=new FormData;h.append("file",s),h.append("filename",s.name),fetch("./api/uploadpackage",{method:"POST",body:h}).then(x=>x.text()).then(x=>{c("Plugins",`Server response: ${x}`)}).catch(x=>{console.error("Error uploading plugin file:",x),c("Plugins",`Error installing package ${x}`)})}},_=d=>{const s=d.target.files&&d.target.files[0];if(s){c("Plugins",`Uploading package ${s.name}`);const h=new FormData;h.append("file",s),h.append("filename",s.name),fetch("./api/uploadpackage",{method:"POST",body:h}).then(x=>x.text()).then(x=>{c("Plugins",`Server response: ${x}`)}).catch(x=>{console.error("Error uploading plugin file:",x),c("Plugins",`Error uploading package ${x}`)})}},q=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:a,restart:!1}})},N=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:a}})},b=()=>{document.getElementById("file-upload")?.click()},p=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:a}})},u=d=>{d.preventDefault(),console.log("Right-clicked Upload button")},P=d=>{d.preventDefault(),console.log("Right-clicked Add button")},F=d=>{I(d.currentTarget)},j=d=>{d!==""&&f(d),I(null)},[U,X]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),U?null:e.jsxs(ke,{children:[e.jsxs(De,{children:[e.jsx(Me,{children:"Install plugins"}),e.jsx(rt,{onClose:()=>X(!0)})]}),e.jsxs(Fe,{onDragOver:C,onDragLeave:w,onDrop:V,style:ue&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(he,{value:a,onChange:d=>{f(d.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:F,children:e.jsx(Er,{})}),e.jsxs(Xe,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(k,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(k,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(k,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(k,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(k,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(k,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(k,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(k,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(k,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(k,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(k,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(k,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(k,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(k,{onClick:()=>j("matterbridge-eve-room"),children:"matterbridge-eve-room"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(O,{title:"Install or update a plugin from npm",children:e.jsxs(ie,{onClick:q,endIcon:e.jsx(We,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(O,{title:"Uninstall and remove a plugin",children:e.jsxs(ie,{onClick:N,endIcon:e.jsx(sr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(O,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ie,{onClick:b,onContextMenu:u,endIcon:e.jsx(Ar,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(O,{title:"Add an installed plugin",children:e.jsxs(ie,{onClick:p,onContextMenu:P,endIcon:e.jsx(wt,{}),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:_})]})]})]})}const fn=r.memo(hn);function Ke({status:n,enabledText:c="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const f=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?c:l??c});return i!==void 0?e.jsx(O,{title:i,children:f}):f}}function xn(n,c,l){const i=n?.[l],a=c?.[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 bn({name:n,title:c,columns:l,rows:i,getRowKey:a,footerLeft:f,footerRight:g,onRowClick:v}){const t=r.useRef(new WeakMap),I=r.useRef(1),y=d=>{if(typeof a=="string"&&d&&d[a]!=null)return d[a];if(typeof a=="function"){const x=a(d);if(x!=null)return x}const s=l?.[0]?.id;if(s&&d&&d[s]!=null)return d[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let h=t.current.get(d);return h||(h=`rk_${I.current++}`,t.current.set(d,h)),h},[C,w]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[V,_]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[q,N]=r.useState(!1),[b,p]=r.useState(()=>{try{const d=localStorage.getItem(`${n}_column_visibility`);if(d)return JSON.parse(d)}catch{}return{}}),u=r.useMemo(()=>{const d={};for(const s of l)s.hidden||(d[s.id]=s.required?!0:b[s.id]!==!1);return d},[l,b]),P=r.useMemo(()=>{if(!C||!V)return i;const d=l.find(h=>h.id===C);if(!d||d.noSort)return i;const s=i.map((h,x)=>({el:h,index:x}));return s.sort((h,x)=>{let H;return typeof d.comparator=="function"?H=d.comparator(h.el,x.el):H=xn(h.el,x.el,C),H!==0?V==="asc"?H:-H:h.index-x.index}),s.map(h=>h.el)},[i,C,V,l]),F=d=>{if(C!==d||!C){w(d),_("asc"),localStorage.setItem(`${n}_table_order_by`,d),localStorage.setItem(`${n}_table_order`,"asc");return}if(V==="asc"){_("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}w(null),_(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{N(!q)},U=d=>{p(s=>{const h=l.find(de=>de.id===d);if(h&&h.required)return s;const x=u[d]!==!1,H={...s};x?H[d]=!1:delete H[d];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(H))}catch{}return H})},X=()=>{p({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}N(!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(He,{open:q,onClose:(d,s)=>{s==="backdropClick"||s==="escapeKeyDown"||j()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Oe,{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(Ve,{children:e.jsx(_r,{children:l.filter(d=>!d.hidden).map(d=>e.jsx(Be,{control:e.jsx(_e,{disabled:!!d.required,checked:d.required?!0:u[d.id]!==!1,onChange:()=>U(d.id)}),label:d.label},d.id))})}),e.jsxs(Ue,{children:[e.jsx(ie,{onClick:X,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:d=>{if(d?.currentTarget&&typeof d.currentTarget.blur=="function")try{d.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}j()},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}),c&&e.jsx("p",{className:"MbfWindowHeaderText",children:c}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(Q,{onClick:d=>{if(d?.currentTarget?.blur)try{d.currentTarget.blur()}catch{}j()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(O,{title:`Configure ${n} columns`,children:e.jsx(ne,{path:Lo,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(d=>{if(d.hidden||!d.required&&u[d.id]===!1)return null;const s=!d.noSort,h=s&&C===d.id&&!!V;return e.jsxs("th",{onClick:s?()=>F(d.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:d.minWidth,maxWidth:d.maxWidth,textAlign:d.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:d.maxWidth?"nowrap":void 0,overflow:d.maxWidth?"hidden":void 0,textOverflow:d.maxWidth?"ellipsis":void 0},"aria-sort":s?h?V==="asc"?"ascending":"descending":"none":void 0,children:[d.label,h&&e.jsxs("span",{style:{marginLeft:6},children:[V==="asc"&&e.jsx(ne,{path:$o,size:"15px"}),V==="desc"&&e.jsx(ne,{path:Wo,size:"15px"})]})]},d.id)})})}),e.jsx("tbody",{children:P.map((d,s)=>{const h=y(d);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:v?x=>v(d,h,x):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:v?"pointer":void 0},children:l.map(x=>{if(x.hidden||!x.required&&u[x.id]===!1)return null;const H=d[x.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:x.align||"left",padding:"5px 10px",margin:"0",maxWidth:x.maxWidth,whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},children:typeof x.render=="function"?x.render(H,h,d,x):typeof H=="boolean"?e.jsx(_e,{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}}}):x.format&&typeof H=="number"?x.format(H):H!=null?String(H):null},x.id)})},h)})})]})}),(f||g)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:f}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}function vn(n){return r.memo(n)}const Dt=vn(bn);function tr(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)"},Je={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},yn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},jn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ae={padding:"0px",margin:"0px"},wn="5px 10px 5px 10px",bt={},Ce={},vt={},yt={};let Ze=[],Wt=[];const Cn=({open:n,onClose:c,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:f,getUniqueId:g}=r.useContext(be),v=r.useRef(g()),[t,I]=r.useState(l.configJson),[y,C]=r.useState(null),[w,V]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[_,q]=r.useState("");let N={};r.useEffect(()=>{const W=M=>{M.src==="Matterbridge"&&M.dst==="Frontend"&&(tr(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),Ze=M.response),tr(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),Wt=M.response))};return a(W,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(S=>{S.startsWith("ui:")&&(w[M]={},w[M][S]=y.properties[M][S],delete y.properties[M][S])})}),V(w)),l.name&&l.configJson&&l.schemaJson&&(I(l.configJson),C(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)),()=>{f(W),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,f,y,i,w]);const b=(W,M)=>{N=W.formData},p=W=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",W.formData),I(W.formData),l.configJson=W.formData,l.restartRequired=!0,i({id:v.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.formData.name,formData:W.formData}}),c()};function u(W){const{id:M,label:S,onKeyChange:L,onDropPropertyClick:K,disabled:ae,schema:oe,children:ce,registry:ge,readonly:pe,required:D}=W,{templates:m}=ge,{RemoveButton:xe}=m.ButtonTemplates;if(!(sn in oe))return e.jsx(te,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const fe=({target:Y})=>L(Y&&Y.value);return e.jsxs(te,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(he,{id:`${M}-key`,name:`${M}-key`,required:D,disabled:ae||pe,defaultValue:S,onBlur:pe?void 0:fe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(te,{sx:{flex:1},children:ce}),e.jsx(xe,{disabled:ae||pe,onClick:K(S),registry:ge})]})}function P(W){const{children:M,description:S,displayLabel:L,errors:K,help:ae,hidden:oe,registry:ce,uiSchema:ge}=W,pe=on(ge),D=nn("WrapIfAdditionalTemplate",ce,pe);return oe?e.jsx("div",{style:{display:"none"},children:M}):e.jsx(te,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(D,{...W,children:[L===!0&&S,M,K,ae]})})}function F(W){const{description:M}=W;return M?e.jsx(le,{sx:Je,children:M}):null}function j(W){const{required:M,title:S}=W;return S?e.jsx(te,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(le,{sx:Ge,children:["Title ",S," ",M&&e.jsx("mark",{children:"***"})]})}):null}function U(W){const{help:M}=W;return M?e.jsx(te,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(le,{sx:yn,children:M})}):null}function X(W){const{errors:M}=W;return M?e.jsxs(te,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(le,{color:"error",sx:jn,children:"Please fix the following errors:"}),e.jsx(nt,{children:M.map((S,L)=>e.jsxs(qr,{children:[e.jsx(A,{children:e.jsx(Ur,{color:"error"})}),e.jsx(Z,{primary:S.stack})]},L))})]}):null}function d(W){const{errors:M}=W;return M?e.jsx(te,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:M.map((S,L)=>e.jsxs(le,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",S]},L))}):null}function s(W){const{id:M,name:S,_schema:L,_uiSchema:K,value:ae,options:oe,label:ce,type:ge,placeholder:pe,required:D,disabled:m,readonly:xe,autofocus:ee,onChange:fe,onChangeOverride:Y,onBlur:me,onFocus:ve,_rawErrors:ot,_hideError:Re,_registry:z,_formContext:E}=W,re=({target:{value:Le}})=>fe(Le===""?oe.emptyValue:Le),we=({target:Le})=>me(M,Le&&Le.value),lt=({target:Le})=>ve(M,Le&&Le.value);return e.jsx(te,{sx:{padding:"0px",margin:"0px"},children:e.jsx(he,{id:M,name:M,label:pe&&pe!==""?ce:void 0,variant:"outlined",placeholder:pe&&pe!==""?pe:ce,required:D,disabled:m||xe,autoFocus:ee,value:ae||ae===0?ae:"",type:ge,autoComplete:ge==="password"?"current-password":S,onChange:Y||re,onBlur:we,onFocus:lt,fullWidth:!0})})}function h(W){return console.log("ArrayFieldTitleTemplate:",W),null}function x(W){return console.log("ArrayFieldDescriptionTemplate:",W),null}function H(W){return console.log("ArrayFieldItemTemplate:",W),null}function de(W){const{canAdd:M,onAddClick:S,schema:L,title:K}=W,[ae,oe]=r.useState(!1),[ce,ge]=r.useState(!1),[pe,D]=r.useState(!1),[m,xe]=r.useState(""),ee=z=>{xe(z.target.value)},fe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Ze),oe(!ae)},Y=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Wt),ge(!ce)},me=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Ze),D(!pe)},ve=z=>{oe(!1),L.selectFrom==="serial"?L.items.default=z.serial:L.selectFrom==="name"&&(L.items.default=z.name),S()},ot=z=>{ge(!1),L.selectEntityFrom==="name"?L.items.default=z.name:L.selectEntityFrom==="description"&&(L.items.default=z.description),S()},Re=z=>{D(!1),L.selectDeviceEntityFrom==="name"?L.items.default=z.name:L.selectDeviceEntityFrom==="description"&&(L.items.default=z.description),S()};return e.jsxs(te,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(te,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(le,{sx:Ge,children:K}),M&&e.jsxs(te,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[L.selectFrom&&e.jsx(O,{title:"Add a device from the list",children:e.jsx(Q,{onClick:fe,size:"small",color:"primary",sx:Ae,children:e.jsx(dt,{})})}),L.selectEntityFrom&&e.jsx(O,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:Y,size:"small",color:"primary",sx:Ae,children:e.jsx(dt,{})})}),L.selectDeviceEntityFrom&&e.jsx(O,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:me,size:"small",color:"primary",sx:Ae,children:e.jsx(dt,{})})}),e.jsx(O,{title:"Add a new item",children:e.jsx(Q,{onClick:S,size:"small",color:"primary",sx:Ae,children:e.jsx(wt,{})})})]})]}),L.description&&e.jsx(le,{sx:Je,children:L.description}),W.items.map(z=>e.jsxs(te,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(te,{sx:{flexGrow:1,marginRight:"10px"},children:z.children}),e.jsx(Q,{disabled:!z.hasMoveUp,onClick:z.onReorderClick(z.index,z.index-1),size:"small",color:"primary",sx:Ae,children:e.jsx(_t,{})}),e.jsx(Q,{disabled:!z.hasMoveDown,onClick:z.onReorderClick(z.index,z.index+1),size:"small",color:"primary",sx:Ae,children:e.jsx(At,{})}),e.jsx(Q,{onClick:z.onDropIndexClick(z.index),size:"small",color:"primary",sx:Ae,children:e.jsx(Tt,{})})]},z.index)),e.jsxs(He,{open:ae,onClose:fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Oe,{children:"Select a device"}),e.jsxs(Ve,{children:[e.jsxs(te,{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:ee,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:Ze.filter(z=>z.serial.toLowerCase().includes(m.toLowerCase())||z.name.toLowerCase().includes(m.toLowerCase())).map((z,E)=>e.jsxs(pt,{onClick:()=>ve(z),sx:bt,children:[z.icon==="wifi"&&e.jsx(A,{children:e.jsx(st,{style:Ce})}),z.icon==="ble"&&e.jsx(A,{children:e.jsx(ut,{style:Ce})}),z.icon==="hub"&&e.jsx(A,{children:e.jsx(gt,{style:Ce})}),e.jsx(Z,{primary:z.name,secondary:z.serial,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},E))})]}),e.jsx(Ue,{children:e.jsx(ie,{onClick:fe,children:"Close"})})]}),e.jsxs(He,{open:ce,onClose:Y,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Oe,{children:"Select an entity"}),e.jsxs(Ve,{children:[e.jsxs(te,{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:ee,placeholder:"Enter name or description"})]}),e.jsx(nt,{dense:!0,children:Wt.filter(z=>z.name.toLowerCase().includes(m.toLowerCase())||z.description.toLowerCase().includes(m.toLowerCase())).map((z,E)=>e.jsxs(pt,{onClick:()=>ot(z),sx:bt,children:[z.icon==="wifi"&&e.jsx(A,{children:e.jsx(st,{style:Ce})}),z.icon==="ble"&&e.jsx(A,{children:e.jsx(ut,{style:Ce})}),z.icon==="hub"&&e.jsx(A,{children:e.jsx(gt,{style:Ce})}),z.icon==="component"&&e.jsx(A,{children:e.jsx(qt,{style:Ce})}),z.icon==="matter"&&e.jsx(A,{children:e.jsx(Ut,{style:Ce})}),e.jsx(Z,{primary:z.name,secondary:z.description,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},E))})]}),e.jsx(Ue,{children:e.jsx(ie,{onClick:Y,children:"Close"})})]}),e.jsxs(He,{open:pe,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Oe,{children:["Select an entity for ",K]}),e.jsx(Ve,{children:e.jsx(nt,{dense:!0,children:Ze.filter(z=>z.serial===K||z.name===K).map(z=>z.entities?.map((E,re)=>e.jsxs(pt,{onClick:()=>Re(E),sx:bt,children:[E.icon==="wifi"&&e.jsx(A,{children:e.jsx(st,{style:Ce})}),E.icon==="ble"&&e.jsx(A,{children:e.jsx(ut,{style:Ce})}),E.icon==="hub"&&e.jsx(A,{children:e.jsx(gt,{style:Ce})}),E.icon==="component"&&e.jsx(A,{children:e.jsx(qt,{style:Ce})}),E.icon==="matter"&&e.jsx(A,{children:e.jsx(Ut,{style:Ce})}),e.jsx(Z,{primary:E.name,secondary:E.description,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},re)))})}),e.jsx(Ue,{children:e.jsx(ie,{onClick:me,children:"Close"})})]})]})}function ye(W){const{onAddClick:M,schema:S,properties:L,title:K,description:ae}=W,[oe,ce]=r.useState(!1),[ge,pe]=r.useState(""),D=Y=>{pe(Y.target.value)},m=()=>{ce(!oe)},xe=Y=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${Y.serial}" for schema "${S.selectFrom}"`),ce(!1);let me="";S.selectFrom==="serial"?me=Y.serial:S.selectFrom==="name"&&(me=Y.name),q(me),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${me}"`),M(S)()},ee=()=>{M(S)()},fe=!S.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${fe} newkey "${_}"`),!fe&&_!==""&&(o&&console.log("ObjectFieldTemplate: newkey",_,"properties",L),L.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=_;q(""),Y.content.props.onKeyChange(me)}})),e.jsxs(te,{sx:{margin:"0px",padding:fe?"10px":"5px 10px 0px 10px",border:fe?"none":"1px solid grey"},children:[S.title&&fe&&e.jsx(te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Ge,children:S.title})}),K&&!fe&&e.jsxs(te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(le,{sx:Ge,children:K}),e.jsxs(te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[S.selectFrom&&e.jsx(O,{title:"Add a device from the list",children:e.jsx(Q,{onClick:m,size:"small",color:"primary",sx:Ae,children:e.jsx(dt,{})})}),e.jsx(O,{title:"Add a new item",children:e.jsx(Q,{onClick:ee,size:"small",color:"primary",sx:Ae,children:e.jsx(wt,{})})})]})]}),S.description&&e.jsx(te,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Je,children:S.description})}),L.map(({content:Y,name:me,hidden:ve})=>!ve&&e.jsxs(te,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(S.properties[me].type)?"0px":wn,border:["object","array","boolean"].includes(S.properties[me].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(S.properties[me].type)&&e.jsx(le,{sx:Ge,children:me}),e.jsx(te,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:Y})]},me)),e.jsxs(He,{open:oe,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Oe,{children:"Select a device"}),e.jsxs(Ve,{children:[e.jsxs(te,{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:D,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:Ze.filter(Y=>Y.serial.toLowerCase().includes(ge.toLowerCase())||Y.name.toLowerCase().includes(ge.toLowerCase())).map((Y,me)=>e.jsxs(pt,{onClick:()=>xe(Y),sx:bt,children:[Y.icon==="wifi"&&e.jsx(A,{children:e.jsx(st,{style:Ce})}),Y.icon==="ble"&&e.jsx(A,{children:e.jsx(ut,{style:Ce})}),Y.icon==="hub"&&e.jsx(A,{children:e.jsx(gt,{style:Ce})}),e.jsx(Z,{primary:Y.name,secondary:Y.serial,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},me))})]}),e.jsx(Ue,{children:e.jsx(ie,{onClick:m,children:"Close"})})]})]})}function se(W){const{uiSchema:M}=W,{submitText:S,norender:L}=rn(M);return L?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ie,{type:"submit",variant:"contained",color:"primary",children:S}),e.jsx(ie,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function je(W){const{className:M,disabled:S,onClick:L,registry:K,style:ae,uiSchema:oe,...ce}=W;return e.jsx(O,{title:"Remove the item",children:e.jsx(Q,{disabled:S,size:"small",color:"primary",onClick:L,children:e.jsx(Tt,{})})})}function R(W){const{className:M,disabled:S,onClick:L,registry:K,uiSchema:ae,...oe}=W;return e.jsx(O,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:L,children:e.jsx(wt,{})})})}function B(W){const{disabled:M,onClick:S,registry:L,style:K,uiSchema:ae,...oe}=W;return e.jsx(O,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:S,children:e.jsx(_t,{})})})}function T(W){const{disabled:M,onClick:S,registry:L,style:K,uiSchema:ae,...oe}=W;return e.jsx(O,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:S,children:e.jsx(At,{})})})}function G(W){const{id:M,name:S,value:L,schema:K,readonly:ae,onChange:oe}=W,[ce,ge]=r.useState(),pe=m=>{o&&console.log(`CheckboxWidget ${S} onChangeField:`,m),ge(m&&m!==""?m:void 0)},D=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${S}" value="${ce}"`),i({id:v.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:S,value:ce,formData:N,id:M}}),K.buttonClose===!0?c():K.buttonSave===!0&&p({formData:t})};return K.buttonText&&K.description?e.jsxs(te,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Je,children:K.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>D(),children:K.buttonText})]}):K.buttonField&&K.description?e.jsxs(te,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Je,children:K.description}),e.jsx(he,{id:S+"-input",name:S,label:K.textLabel,placeholder:K.textPlaceholder,onChange:m=>pe(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:S+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>D(),children:K.buttonField})]}):e.jsxs(te,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[S&&e.jsxs(te,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(le,{sx:Ge,children:S}),e.jsx(_e,{checked:L,readOnly:ae,onChange:()=>oe(!L),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(le,{sx:Je,children:K.description})]})}function $({schema:W,id:M,name:S,options:L,label:K,hideLabel:ae,required:oe,disabled:ce,placeholder:ge,readonly:pe,value:D,multiple:m,autofocus:xe,onChange:ee,onBlur:fe,onFocus:Y,errorSchema:me,rawErrors:ve=[],registry:ot,uiSchema:Re,hideError:z,formContext:E,...re}){const{enumOptions:we,enumDisabled:lt,emptyValue:Le}=L;m=typeof m>"u"?!1:!!m;const Ht=m?[]:"",Ot=typeof D>"u"||m&&D.length<1||!m&&D===Ht,yr=({target:{value:Ee}})=>ee($t(Ee,we,Le)),jr=({target:Ee})=>fe(M,$t(Ee&&Ee.value,we,Le)),wr=({target:Ee})=>Y(M,$t(Ee&&Ee.value,we,Le)),Vt=en(D,we,m),{InputLabelProps:Cr,SelectProps:Sr,autocomplete:kr,...Mr}=re,Ir=!m&&W.default===void 0;return e.jsxs(he,{id:M,name:M,value:!Ot&&typeof Vt<"u"?Vt:Ht,required:oe,disabled:ce||pe,autoFocus:xe,autoComplete:kr,placeholder:ge,error:ve.length>0,onChange:yr,onBlur:jr,onFocus:wr,...Mr,select:!0,InputLabelProps:{...Cr,shrink:!Ot},SelectProps:{...Sr,multiple:m},"aria-describedby":tn(M),children:[Ir&&e.jsx(k,{value:"",children:ge}),Array.isArray(we)&&we.map(({value:Ee,label:Dr},Et)=>{const Pr=Array.isArray(lt)&<.indexOf(Ee)!==-1;return e.jsx(k,{value:String(Et),disabled:Pr,children:Dr},Et)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(He,{open:n,onClose:c,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Oe,{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(Ve,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Yo,{schema:y,formData:t,uiSchema:w,validator:Xo,templates:{FieldTemplate:P,BaseInputTemplate:s,TitleFieldTemplate:j,DescriptionFieldTemplate:F,FieldHelpTemplate:U,FieldErrorTemplate:d,ErrorListTemplate:X,WrapIfAdditionalTemplate:u,ArrayFieldTitleTemplate:h,ArrayFieldDescriptionTemplate:x,ArrayFieldItemTemplate:H,ArrayFieldTemplate:de,ObjectFieldTemplate:ye,ButtonTemplates:{SubmitButton:se,RemoveButton:je,AddButton:R,MoveUpButton:B,MoveDownButton:T}},widgets:{CheckboxWidget:G,SelectWidget:$},onChange:b,onSubmit:p})})]})};function fr(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 c=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(c===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function Sn({storeId:n,setStoreId:c}){const{online:l,sendMessage:i,addListener:a,removeListener:f,getUniqueId:g}=r.useContext(be),{showConfirmCancelDialog:v}=r.useContext(Pe),t=r.useRef(g()),[I,y]=r.useState(null),[C,w]=r.useState(null),[V,_]=r.useState([]),q=[{label:"Name",id:"name",required:!0,render:(T,G,$,W)=>e.jsx(O,{title:`Plugin path ${$.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d($),children:$.name})})},{label:"Description",id:"description",render:(T,G,$,W)=>e.jsx(O,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d($),children:$.description})})},{label:"Version",id:"version",render:(T,G,$,W)=>e.jsx(e.Fragment,{children:e.jsx(O,{title:`Plugin v.${$.version}`,children:e.jsx("span",{children:$.version.split("-dev-")[0]+($.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(T,G,$,W)=>e.jsx(e.Fragment,{children:$.author?$.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(T,G,$,W)=>e.jsx(e.Fragment,{children:$.type?$.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(T,G,$,W)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(O,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:fr($.matter)},onClick:()=>{$.matter?.id&&c($.matter?.id)},size:"small",children:e.jsx(ar,{})})}),C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(O,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>U($),size:"small",children:e.jsx(Ct,{})})}),e.jsx(O,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{disabled:$.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>je($),size:"small",children:e.jsx(zr,{})})}),C&&!C.readOnly&&e.jsx(O,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{b("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",$)},size:"small",children:e.jsx(sr,{})})}),$.enabled?e.jsx(O,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{b("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",$)},size:"small",children:e.jsx(Br,{})})}):e.jsx(e.Fragment,{}),$.enabled?e.jsx(e.Fragment,{}):e.jsx(O,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>X($),size:"small",children:e.jsx(Qr,{})})}),e.jsx(O,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>h($),size:"small",children:e.jsx(lr,{})})}),e.jsx(O,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>x($),size:"small",children:e.jsx(Ft,{})})}),$.latestVersion!==void 0&&$.latestVersion!==$.version&&C&&!C.readOnly&&e.jsx(O,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>P($),size:"small",children:e.jsx(Ne,{})})}),$.version.includes("-dev-")&&$.devVersion!==void 0&&$.devVersion!==$.version&&C&&!C.readOnly&&e.jsx(O,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>F($),size:"small",children:e.jsx(Ne,{})})}),C&&!C.readOnly&&e.jsx(O,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s($),size:"small",children:e.jsx(Rt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(T,G,$,W)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:$.error?e.jsx(e.Fragment,{children:e.jsx(Ke,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:$.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ke,{status:$.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:$.loaded&&$.started&&$.configured?e.jsx(e.Fragment,{children:e.jsx(Ke,{status:$.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{status:$.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ke,{status:$.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ke,{status:$.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const T=G=>{o&&console.log("HomePlugins received WebSocket Message:",G),G.method==="refresh_required"&&G.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):G.method==="refresh_required"&&G.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and setting matter id ${G.response.matter?.id}`),_($=>{const W=$.findIndex(S=>S.matter?.id===G.response.matter?.id);if(W<0)return o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and matter id ${G.response.matter?.id} not found`),$;o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} set matter id ${G.response.matter?.id}`);const M=[...$];return M[W]={...M[W],matter:G.response.matter},M})):G.method==="refresh_required"&&G.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),G.id===t.current&&G.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${G.id}) received settings:`,G.response),y(G.response.systemInformation),w(G.response.matterbridgeInformation)):G.id===t.current&&G.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${G.id}) received ${G.response.length} plugins:`,G.response),_(G.response))};return a(T,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{f(T),o&&console.log("HomePlugins removed WebSocket listener")}},[a,f,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 N=r.useRef(null),b=(T,G,$,W)=>{o&&console.log(`handleActionWithConfirmCancel ${$} ${W.name}`),N.current=W,v(T,G,$,p,u)},p=T=>{o&&console.log(`handleConfirm action confirmed ${T} ${N.current?.name}`),T==="remove"&&N.current?j(N.current):T==="disable"&&N.current&&X(N.current),N.current=null},u=T=>{o&&console.log(`handleCancel action canceled ${T} ${N.current?.name}`),N.current=null},P=T=>{o&&console.log("handleUpdatePlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:T.name,restart:!1}})},F=T=>{o&&console.log("handleUpdateDevPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:T.name+"@dev",restart:!1}})},j=T=>{o&&console.log("handleRemovePlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})},U=T=>{o&&console.log("handleRestartPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})},X=T=>{o&&console.log("handleEnableDisablePlugin plugin:",T.name,"enabled:",T.enabled),T.enabled===!0?(T.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})):(T.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}}))},d=T=>{o&&console.log(`handleHomepagePlugin plugin: ${T.name} homepage: ${T.homepage}`),T.homepage&&window.open(T.homepage,"_blank")},s=T=>{o&&console.log("handleSponsorPlugin plugin:",T.name,"funding:",T.funding),T.funding&&window.open(T.funding,"_blank")},h=T=>{o&&console.log("handleHelpPlugin plugin:",T.name,"help:",T.help),T.help&&window.open(T.help,"_blank")},x=T=>{o&&console.log("handleChangelogPlugin plugin:",T.name,"changelog:",T.changelog),T.changelog&&window.open(T.changelog,"_blank")},[H,de]=r.useState(),[ye,se]=r.useState(!1),je=T=>{o&&console.log("handleConfigPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:T.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:T.name}}),de(T),R()},R=()=>{se(!0)},B=()=>{se(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(ke,{children:[H&&e.jsx(Cn,{open:ye,onClose:B,plugin:H}),e.jsx(Dt,{name:"Plugins",columns:q,rows:V,footerRight:"",footerLeft:""})]}):e.jsx(Te,{})}const kn=r.memo(Sn),Mn=n=>`${n.pluginName}::${n.serial}`;function In({storeId:n,setStoreId:c}){const{online:l,sendMessage:i,addListener:a,removeListener:f,getUniqueId:g}=r.useContext(be),[v,t]=r.useState(!1),[I,y]=r.useState(!0),[C,w]=r.useState(null),[V,_]=r.useState([]),[q,N]=r.useState([]),[b,p]=r.useState([]),[u,P]=r.useState([]),F=r.useRef(g()),j=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(d,s,h,x)=>h.reachable===!0?"Online":h.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(d,s)=>{const h=d.reachable===!0?1:d.reachable===!1?0:-1,x=s.reachable===!0?1:s.reachable===!1?0:-1;return h-x}},{label:"Power",id:"powerSource",render:(d,s,h,x)=>h.powerSource==="ac"||h.powerSource==="dc"?e.jsx(cr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):h.powerSource==="ok"?e.jsx(St,{fontSize:"small",sx:{color:"green"}}):h.powerSource==="warning"?e.jsx(St,{fontSize:"small",sx:{color:"yellow"}}):h.powerSource==="critical"?e.jsx(St,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(d,s,h,x)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[h.matter!==void 0?e.jsx(O,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>c(n===h.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:h.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:fr(h.matter)},children:e.jsx(ar,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),h.configUrl?e.jsx(O,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(h.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(dr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),h.selected!==void 0?e.jsx(O,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(_e,{checked:h.selected,onChange:H=>X(H,h),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],U=r.useCallback(d=>{d.selected=void 0;const s=V.find(H=>H.name===d.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${d.pluginName} not found for device ${d.name} `),d.selected;const h=s.schemaJson?.properties?.whiteList?.selectFrom;let x=s.configJson.postfix;return x===""&&(x=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&h&&(d.selected=!0,h==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(x?d.serial.replace("-"+x,""):d.serial)&&(d.selected=!0),h==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(x?d.serial.replace("-"+x,""):d.serial)&&(d.selected=!1),h==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(x?d.serial.replace("-"+x,""):d.serial)&&(d.selected=!1),h==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(d.name)&&(d.selected=!0),h==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(d.name)&&(d.selected=!1),h==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(d.name)&&(d.selected=!1)),d.selected},[V]);r.useEffect(()=>{const d=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:F.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}`),P(h=>{const x=h.findIndex(de=>de.name.replaceAll(" ","")===s.response.matter?.id);if(x<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),h;const H=[...h];return H[x]={...H[x],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}`),N(h=>{const x=h.findIndex(H=>H.pluginName===s.response.plugin&&H.serial===s.response.serialNumber);return x<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),h):(h[x]={...h[x],reachable:s.response.value},[...h])})),s.id===F.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),w(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===F.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let h=!0;for(const x of s.response)x.enabled===!0&&(x.loaded!==!0||x.started!==!0||x.error===!0)&&(h=!1);if(!h)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),_(s.response),N([]),p([]),i({id:F.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const x of s.response)x.enabled===!0&&x.loaded===!0&&x.started===!0&&x.error!==!0&&(i({id:F.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:x.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${x.name}`))}}else if(s.id===F.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const h of s.response)h.selected=U(h);N(s.response)}}else s.id===F.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&&p(h=>{const x=h.filter(de=>de.pluginName!==s.response[0].pluginName),H=s.response.map(de=>({...de,selected:U(de)}));return[...x,...H]}))};return a(d,F.current),o&&console.log(`HomeDevices added WebSocket listener id ${F.current}`),()=>{f(d),o&&console.log("HomeDevices removed WebSocket listener")}},[V,a,f,i,U]),r.useEffect(()=>{if(q.length===0&&b.length===0){P([]);return}o&&console.log(`HomeDevices mixing devices (${q.length}) and selectDevices (${b.length})`);const d=[];for(const s of q)d.push(s);for(const s of b)q.find(h=>h.pluginName===s.pluginName&&h.serial.includes(s.serial))||d.push(s);d.length>0&&(P(d),o&&console.log(`HomeDevices mixed ${d.length} devices and selectDevices`))},[V,q,b,P]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:F.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const X=(d,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${d.target.checked} for device ${s.name} serial ${s.serial}`),q.findIndex(h=>h.pluginName===s.pluginName&&h.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),P(h=>{const x=h.findIndex(H=>H.pluginName===s.pluginName&&H.serial===s.serial);return x<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),h):(h[x]={...h[x],selected:d.target.checked},[...h])})):N(h=>{const x=h.findIndex(H=>H.pluginName===s.pluginName&&H.serial===s.serial);return x<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),h):(h[x]={...h[x],selected:d.target.checked},[...h])}),d.target.checked?i({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:F.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(ke,{style:{flex:"1 1 auto"},children:e.jsx(Dt,{name:"Devices",getRowKey:Mn,rows:u,columns:j,footerLeft:I?"Waiting for the plugins to fully load...":`Registered devices: ${q.length.toString()}/${u.length.toString()}`,footerRight:v?"Restart required":""})}):e.jsx(Te,{})}const Dn=r.memo(In);function at({children:n,style:c,name:l}){const{setCurrentPage:i}=r.useContext(Pe);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,...c},children:n})}const Pn=()=>"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 Ln(){const{messages:n,logAutoScroll:c}=r.useContext(mr),[l,i]=r.useState(!1),a=r.useRef(null),f=r.useRef(0),g=r.useRef(null),v=r.useMemo(()=>Pn(),[]),t=w=>i(!0),I=w=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${c} isHovering: ${l}`),c&&!l&&!v){const w=Date.now();w-f.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),f.current=w,a.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{a.current?.scrollIntoView({behavior:"smooth"}),f.current=Date.now()},1e3))}},[n,c,l,v]);const y=w=>{switch(w.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=w=>{switch(w.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((w,V)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:y(w.level),color:C(w.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:w.level}),w.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+w.time+"]"}),w.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+w.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:w.message})]},V)),e.jsx("div",{ref:a})]})})}const xr=r.memo(Ln);function $n(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,f]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{online:g}=r.useContext(be);return o&&console.log("HomeLogs rendering..."),g?e.jsxs(ke,{style:{flex:"1 1 auto"},children:[e.jsxs(De,{children:[e.jsx(Me,{children:"Logs"}),e.jsxs(Me,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l,'" Scroll: ',a?"auto":"manual"]})]}),e.jsx(Fe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(xr,{})})]}):e.jsx(Te,{})}const Wn=r.memo($n);function Nn(){const{online:n}=r.useContext(be);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(ke,{children:[e.jsx(De,{children:e.jsx(Me,{children:"Frontend Update"})}),e.jsxs(Fe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Kr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Te,{})}const Tn=r.memo(Nn);function Fn({changelog:n}){const{online:c}=r.useContext(be);return o&&console.log("HomeShowChangelog rendering..."),c?e.jsxs(ke,{children:[e.jsx(De,{children:e.jsx(Me,{children:"Matterbridge Update"})}),e.jsxs(Fe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(ie,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(pr,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(ie,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(Rt,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(ie,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Ft,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Gr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Te,{})}const Rn=r.memo(Fn);function Hn({matterbridgeInfo:n}){const{mobile:c}=r.useContext(Pe);o&&console.log("MatterbridgeInfoTable:",n);const l=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,a]=r.useState(!1);return!n||i?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(ke,{style:ue&&c?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Me,{children:"Matterbridge info"}),e.jsx(rt,{onClose:()=>a(!0)})]}),e.jsx(Fe,{style:ue&&c?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([f,g])=>!l.includes(f)&&g!==null&&g!==void 0&&g!=="").map(([f,g],v)=>e.jsxs("tr",{className:v%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:f.replace("matterbridgeVersion","Matterbridge version").replace("matterbridgeLatestVersion","Matterbridge latest v.").replace("matterbridgeDevVersion","Matterbridge dev v.").replace("frontendVersion","Frontend version").replace("homeDirectory","Home").replace("rootDirectory","Root").replace("matterbridgeDirectory","Storage").replace("matterbridgeCertDirectory","Cert").replace("matterbridgePluginDirectory","Plugins").replace("globalModulesDirectory","Modules").replace("bridgeMode","Bridge mode").replace("restartMode","Restart mode").replace("virtualMode","Virtual mode").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("matterLoggerLevel","Matter logger level").replace("matterFileLogger","Matter file logger").replace("restartRequired","Restart required").replace("updateRequired","Update required")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ue&&c?typeof g!="string"?g.toString():g:e.jsx(hr,{value:typeof g!="string"?g.toString():g,maxChars:24})})]},f))})]})})]}))}const On=r.memo(Hn);function Vn(){const[n,c]=r.useState(null),[l,i]=r.useState(null),[a,f]=r.useState([]),[g]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[v,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[I,y]=r.useState(""),[C,w]=r.useState(!1),[V,_]=r.useState(!1),[q,N]=r.useState(null),{mobile:b}=r.useContext(Pe),{addListener:p,removeListener:u,online:P,sendMessage:F,getUniqueId:j}=r.useContext(be),U=r.useRef(j());return r.useEffect(()=>{const X=d=>{o&&console.log("Home received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${d.response.changed} and sending /api/settings request`),N(null),f([]),F({id:U.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),F({id:U.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===U.current&&(o&&console.log("Home received settings:",d.response),c(d.response.systemInformation),i(d.response.matterbridgeInformation),d.response.matterbridgeInformation.matterbridgeVersion&&y(`https://github.com/Luligu/matterbridge/blob/${d.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&d.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion):d.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&d.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion),_(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion):d.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion),w(!0)),d.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),d.method==="/api/plugins"&&d.id===U.current&&(o&&console.log("Home received plugins:",d.response),f(d.response))};return p(X,U.current),o&&console.log(`Home added WebSocket listener id ${U.current}`),()=>{u(X),o&&console.log("Home removed WebSocket listener")}},[p,u,F]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${q}`),l?.bridgeMode==="bridge"&&!q&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),N("Matterbridge")),l?.bridgeMode==="childbridge"&&!q&&a){for(const X of a)if(X.matter?.id){o&&console.log(`Home storeId effect set storeId to ${X.matter.id}`),N(X.matter.id);break}}},[l,a,q]),r.useEffect(()=>{P&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),F({id:U.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),F({id:U.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[P,F]),o&&console.log("Home rendering..."),!P||!n||!l?e.jsx(Te,{}):e.jsxs(at,{name:"Home",style:ue&&b?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(ue&&!b||!ue)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(er,{id:q}),e.jsx(Yt,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:ue&&b?"10px":"20px"},children:[V&&e.jsx(Tn,{}),C&&e.jsx(Rn,{changelog:I}),ue&&b&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(er,{id:q}),e.jsx(Yt,{systemInfo:n,compact:!0}),e.jsx(On,{matterbridgeInfo:l})]}),g&&!l.readOnly&&e.jsx(fn,{}),g&&e.jsx(kn,{storeId:q,setStoreId:N}),v==="devices"&&e.jsx(Dn,{storeId:q,setStoreId:N}),v==="logs"&&e.jsx(Wn,{})]})]})}const En=r.memo(Vn),jt=!1,rr={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},An={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},_n={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},or={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},qn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Un={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},zn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Bn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Qn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Nt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Kn=[256,257,268,269],Gn=[266,267],Jn=[259,260,261,271,272],Zn=[256,257,268,269,266,267,259,260,261,272];function J({icon:n,iconColor:c,cluster:l,value:i,unit:a,prefix:f}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),f=f??!1,e.jsxs(te,{sx:rr,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...An,color:c??"var(--primary-color)"}}),e.jsxs(te,{sx:{...rr,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&f===!0&&e.jsx(le,{sx:or,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(le,{sx:_n,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&f===!1&&e.jsx(le,{sx:or,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function Yn({device:n,endpoint:c,id:l,deviceType:i,clusters:a}){const f=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";o&&console.log(`Device "${n.name}" endpoint "${c}" 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+" ")}),g=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>g=`${t.attributeLocalValue} mV`),Zn.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>g=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>g=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>g=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>g=g+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>g=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>g=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>g=g+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>g=g+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="currentMode")?.attributeLocalValue;g=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;g=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(J,{icon:t.attributeLocalValue===!0?e.jsx(st,{}):e.jsx(Jr,{}),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(J,{icon:e.jsx(St,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(J,{icon:e.jsx(cr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Kn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Gn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Jn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Fo,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(J,{icon:e.jsx(ne,{path:Ro,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(J,{icon:e.jsx(ne,{path:Ho,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(J,{icon:e.jsx(ne,{path:Oo,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(J,{icon:e.jsx(zt,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(Yr,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Vo,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(J,{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(J,{icon:e.jsx(ne,{path:Eo,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(J,{icon:e.jsx(ne,{path:Jt,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(J,{icon:e.jsx(ne,{path:Jt,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(J,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ao,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(J,{icon:t.attributeValue==="1"?e.jsx(eo,{}):e.jsx(to,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:_o,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(J,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(no,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(Bt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(Bt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(io,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(so,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(ao,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:qo,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(J,{icon:e.jsx(ne,{path:Uo,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(J,{icon:e.jsx(ne,{path:zo,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(J,{icon:e.jsx(ne,{path:Bo,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(J,{icon:e.jsx(ne,{path:Qo,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(J,{icon:e.jsx(ne,{path:Ko,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(J,{icon:e.jsx(ne,{path:Zt,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(J,{icon:e.jsx(ne,{path:Zt,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(J,{icon:e.jsx(lo,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:f[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(co,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Jo,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(J,{icon:e.jsx(po,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(uo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:t.attributeValue==="true"?e.jsx(go,{}):e.jsx(mo,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(J,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(ho,{}):e.jsx(fo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(xo,{}),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(J,{icon:e.jsx(bo,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(te,{sx:qn,children:e.jsx(le,{sx:Un,children:g})}),e.jsx(te,{sx:zn,children:e.jsx(le,{sx:Bn,children:n.name})}),e.jsxs(te,{sx:Qn,children:[o&&e.jsx(le,{sx:Nt,children:c}),e.jsx(le,{sx:Nt,children:l}),o&&e.jsxs(le,{sx:Nt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Xn({filter:n}){const{online:c,sendMessage:l,addListener:i,removeListener:a,getUniqueId:f}=r.useContext(be),[g,v]=r.useState([]),[t,I]=r.useState({}),[y,C]=r.useState({}),[w,V]=r.useState({}),_=r.useRef(f()),q=r.useCallback(p=>{(o||jt)&&console.log(`DevicesIcons received state_update "${p.response.cluster}.${p.response.attribute}" for "${p.response.id}:${p.response.number}": "${p.response.value}"`,p.response);const u=g.find(F=>F.pluginName===p.response.plugin&&F.serial===p.response.serialNumber);if(!u){(o||jt)&&console.warn(`DevicesIcons updater device of plugin "${p.response.plugin}" serial "${p.response.serialNumber}" number "${p.response.number}" id "${p.response.id}" not found in devices(${g.length})`);return}const P=w[u.serial]?.find(F=>F.endpoint===p.response.number.toString()&&F.clusterName===p.response.cluster&&F.attributeName===p.response.attribute);if(!P){(o||jt)&&console.warn(`DevicesIcons updater device "${u.name}" serial "${u.serial}" cluster "${p.response.cluster}" attribute "${p.response.attribute}" not found in clusters(${w[u.serial]?.length})`);return}P.attributeValue=String(p.response.value),P.attributeLocalValue=p.response.value,V({...w}),(o||jt)&&console.log(`DevicesIcons updated "${P.clusterName}.${P.attributeName}" for device "${u.name}" serial "${u.serial}" to "${P.attributeValue}"`)},[w,g]),N=r.useCallback(p=>{if(o&&console.log(`DevicesIcons received for device "${p.response.deviceName}" serial "${p.response.serialNumber}" deviceTypes (${p.response.deviceTypes.length}) "${p.response.deviceTypes.join(",")}" clusters (${p.response.clusters.length}):`,p.response),p.response.clusters.length===0)return;const u=p.response.serialNumber;t[u]=[],y[u]=p.response.deviceTypes,w[u]=[];for(const P of p.response.clusters)t[u].find(F=>F.endpoint===P.endpoint)||t[u].push({endpoint:P.endpoint,id:P.id,deviceTypes:P.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(P.clusterName)&&w[u].push(P);I({...t}),C({...y}),V({...w}),o&&console.log(`DevicesIcons endpoints for "${u}":`,t[u]),o&&console.log(`DevicesIcons deviceTypes for "${u}":`,y[u]),o&&console.log(`DevicesIcons clusters for "${u}":`,w[u])},[w,y,t]);r.useEffect(()=>{const p=u=>{if(o&&console.log("DevicesIcons received WebSocket Message:",u),u.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${u.response.changed} and sending api requests`),l({id:_.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)q(u);else if(u.method==="/api/devices"&&u.response){o&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),v(u.response),I({}),C({}),V({});for(const P of u.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:_.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:P.pluginName,endpoint:P.endpoint||0}})}else u.method==="/api/clusters"&&u.response&&N(u)};return i(p,_.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(p),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[g]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),c&&(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")}),[c,l]);const b=r.memo(Yn);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:g.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n)).map(p=>t[p.serial]&&t[p.serial].map(u=>u.deviceTypes.map(P=>e.jsx(b,{device:p,endpoint:u.endpoint,id:u.id,deviceType:P,clusters:w[p.serial].filter(F=>F.endpoint===u.endpoint)},`${p.pluginName}-${p.uniqueId}-${u.endpoint}-${u.id}-${P.toString()}`))))})}const ei=r.memo(Xn),ti=[{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,c,l,i)=>l.configUrl?e.jsx(Q,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(dr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],ri=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,c,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,c,l,i)=>e.jsx(O,{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)})})}],oi=n=>`${n.pluginName}::${n.uniqueId}`,ni=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function ii({filter:n}){const{online:c,sendMessage:l,addListener:i,removeListener:a,getUniqueId:f}=r.useContext(be),[g,v]=r.useState([]),[t,I]=r.useState(g),[y,C]=r.useState([]),[w,V]=r.useState(0),[_,q]=r.useState(null),[N,b]=r.useState(null),[p,u]=r.useState(null),[P,F]=r.useState(null),j=r.useRef(f()),U=r.useRef(t),X=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 h=U.current.find(x=>x.pluginName===s.response.plugin&&x.uniqueId===s.response.uniqueId);if(!h){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(_&&N&&h.pluginName===_&&h.uniqueId===P&&s.response.number.toString()===N){const x=y.find(H=>H.endpoint===s.response.number.toString()&&H.clusterName===s.response.cluster&&H.attributeName===s.response.attribute);if(!x){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${h.name}" serial "${h.serial}" not found in clusters`);return}x.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),x.attributeLocalValue=s.response.value,C([...y]),o&&console.log(`DevicesTable updated attribute ${x.clusterName}.${x.attributeName} for device "${h.name}" serial "${h.serial}" to "${x.attributeValue}"`)}},[y,N,_,P]);r.useEffect(()=>{const s=h=>{if(o&&console.log("DevicesTable received WebSocket Message:",h),h.method==="refresh_required"&&h.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${h.response.changed} and sending /api/devices request`),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(h.method==="state_update"&&h.response)X(h);else if(h.method==="/api/devices")o&&console.log(`DevicesTable received ${h.response.length} devices:`,h.response),v(h.response);else if(h.method==="/api/clusters"){o&&console.log(`DevicesTable received ${h.response.clusters.length} clusters for plugin ${h.response.plugin}:`,h.response),C(h.response.clusters);const x={};for(const H of h.response.clusters)o&&console.log("Cluster:",H.endpoint),x[H.endpoint]?x[H.endpoint]++:x[H.endpoint]=1;V(Object.keys(x).length)}};return i(s,j.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,X]),r.useEffect(()=>{c&&(o&&console.log("DevicesTable sending api requests with id ",j.current),l({id:j.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,l]),r.useEffect(()=>{_&&N&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:j.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:_,endpoint:Number(N)}}))},[_,N,l]),r.useEffect(()=>{if(n===""){I(g),U.current=g;return}const s=g.filter(h=>h.name.toLowerCase().includes(n)||h.serial.toLowerCase().includes(n));I(s),U.current=s},[g,n]);const d=s=>{if(s.uniqueId===P){F(null),q(null),b(null),u(null);return}F(s.uniqueId),q(s.pluginName),b(s.endpoint?s.endpoint.toString():null),u(s.name)};return o&&console.log("DevicesTable rendering..."),c?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:`${_&&N?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Dt,{name:"Registered devices",getRowKey:oi,onRowClick:d,rows:t,columns:ti,footerLeft:`Total devices: ${t.length.toString()}`})}),_&&N&&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(Dt,{name:"Clusters",title:p||"",getRowKey:ni,rows:y,columns:ri,footerLeft:`Total child endpoints: ${w-1}`})})]}):e.jsx(Te,{})}const si=r.memo(ii);function ai(){const{online:n}=r.useContext(be),[c,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 f=v=>{l(v.target.value.toLowerCase()),localStorage.setItem("devicesFilter",v.target.value.toLowerCase())},g=v=>{a(v),localStorage.setItem("devicesViewMode",v)};return o&&console.log("Devices rendering..."),n?e.jsxs(at,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(te,{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:c,onChange:f,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(te,{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(Q,{onClick:()=>g("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(O,{title:"Table View",children:e.jsx(vo,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(O,{title:"Icon View (beta)",children:e.jsx(yo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(si,{filter:c}),i==="icon"&&e.jsx(ei,{filter:c})]}):e.jsx(Te,{})}const li=r.memo(ai);function ci(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,f]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:g,setLogFilterLevel:v,setLogFilterSearch:t,online:I,setLogAutoScroll:y,filterLogMessages:C}=r.useContext(be),w=N=>{c(N.target.value),v(N.target.value),C(N.target.value,l),localStorage.setItem("logFilterLevel",N.target.value),o&&console.log("handleChangeLevel called with value:",N.target.value)},V=N=>{i(N.target.value),t(N.target.value),C(n,N.target.value),localStorage.setItem("logFilterSearch",N.target.value),o&&console.log("handleChangeSearch called with value:",N.target.value)},_=N=>{f(N.target.checked),y(N.target.checked),C(n,l),localStorage.setItem("logAutoScroll",N.target.checked?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",N.target.checked)},q=()=>{o&&console.log("handleClearLogsClick called"),g([])};return o&&console.log("Logs rendering..."),I?e.jsxs(at,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Qt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(et,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:w,children:[e.jsx(k,{value:"debug",children:"Debug"}),e.jsx(k,{value:"info",children:"Info"}),e.jsx(k,{value:"notice",children:"Notice"}),e.jsx(k,{value:"warn",children:"Warn"}),e.jsx(k,{value:"error",children:"Error"}),e.jsx(k,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Qt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(he,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:V,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})]}),e.jsx(Be,{control:e.jsx(_e,{checked:a,onChange:_}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"},children:e.jsx(O,{title:"Clear the logs",children:e.jsx(ie,{onClick:q,endIcon:e.jsx(Tt,{}),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(xr,{})})]}):e.jsx(Te,{})}const di=r.memo(ci),pi=({open:n,ip:c,onClose:l,onSave:i})=>{const a=c?c.split(".").slice(0,3).join(".")+".1":"",[f,g]=r.useState("dhcp"),[v,t]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:a,dns:a}),I=w=>V=>{t({...v,[w]:V.target.value})},y=()=>{l()},C=()=>{i({type:f,...v}),l()};return e.jsxs(He,{open:n,onClose:(w,V)=>{V==="backdropClick"||V==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Oe,{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(Ve,{dividers:!0,children:[e.jsxs(ur,{component:"fieldset",fullWidth:!0,children:[e.jsx(Se,{component:"legend",children:"Select IP Configuration"}),e.jsxs(gr,{row:!0,value:f,onChange:w=>g(w.target.value),children:[e.jsx(Be,{value:"dhcp",control:e.jsx(It,{}),label:"DHCP"}),e.jsx(Be,{value:"static",control:e.jsx(It,{}),label:"Static"})]})]}),f==="static"&&e.jsxs(qe,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(qe,{size:6,children:e.jsx(he,{label:"IP Address",fullWidth:!0,value:v.ip,onChange:I("ip")})}),e.jsx(qe,{size:6,children:e.jsx(he,{label:"Subnet Mask",fullWidth:!0,value:v.subnet,onChange:I("subnet")})}),e.jsx(qe,{size:6,children:e.jsx(he,{label:"Gateway",fullWidth:!0,value:v.gateway,onChange:I("gateway")})}),e.jsx(qe,{size:6,children:e.jsx(he,{label:"DNS Server",fullWidth:!0,value:v.dns,onChange:I("dns")})})]})]}),e.jsxs(Ue,{children:[e.jsx(ie,{onClick:y,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:C,children:"Save"})]})]})},ui=({open:n,onClose:c,onSave:l})=>{const[i,a]=r.useState(""),[f,g]=r.useState(""),v=V=>{a(V.target.value)},t=V=>{g(V.target.value)},I=i.length>0&&i===f,y=()=>{c()},C=()=>{I&&(l(i),c())},w=()=>{l(""),c()};return e.jsxs(He,{open:n,onClose:(V,_)=>{_==="backdropClick"||_==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Oe,{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(Ve,{dividers:!0,children:e.jsx(ur,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(qe,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(qe,{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(qe,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:f,onChange:t,error:f!==""&&i!==f,helperText:f!==""&&i!==f?"Passwords do not match":""})})]})})}),e.jsxs(Ue,{children:[e.jsx(ie,{onClick:y,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:C,disabled:!I,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:w,children:"Reset"})]})]})};function Ye(n=1e3){let c=null;const l=(i=>{c!==null&&window.clearTimeout(c),c=window.setTimeout(()=>{i(),c=null},n)});return l.cancel=()=>{c!==null&&(window.clearTimeout(c),c=null)},l}const Pt=330;function gi(){const{mobile:n}=r.useContext(Pe),{online:c,addListener:l,removeListener:i,sendMessage:a,getUniqueId:f}=r.useContext(be),[g,v]=r.useState(null),[t,I]=r.useState(null),y=r.useRef(f());return r.useEffect(()=>{const C=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`),a({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):w.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",w.response),v(w.response.matterbridgeInformation),I(w.response.systemInformation))};return l(C,y.current),o&&console.log("Settings added WebSocket listener"),()=>{i(C),o&&console.log("Settings removed WebSocket listener")}},[l,i,a]),r.useEffect(()=>{c&&(o&&console.log("Settings received online"),a({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,a]),o&&console.log("Settings rendering..."),!c||!g||!t?e.jsx(Te,{}):e.jsx(at,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:ue&&n?"10px":"20px"},children:[e.jsx(mi,{matterbridgeInfo:g,systemInfo:t}),e.jsx(hi,{matterbridgeInfo:g}),e.jsx(fi,{matterbridgeInfo:g}),e.jsx(xi,{systemInfo:t})]})})}function mi({matterbridgeInfo:n,systemInfo:c}){const{sendMessage:l,getUniqueId:i}=r.useContext(be),[a,f]=r.useState("bridge"),[g,v]=r.useState("Info"),[t,I]=r.useState(!1),[y,C]=r.useState("dark"),[w,V]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[_,q]=r.useState(localStorage.getItem("homePageMode")??"devices"),[N,b]=r.useState(localStorage.getItem("virtualMode")??"outlet"),p=r.useRef(i()),[u,P]=r.useState(!1),F=()=>P(!1),j=R=>{o&&console.log("handleSaveNetConfig called with config:",R),l({id:p.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:R})},[U,X]=r.useState(!1),d=()=>X(!1),s=R=>{o&&console.log("handleSaveChangePassword called with password:",R),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:R}}),Pi(R)};r.useEffect(()=>{n&&(f(n.bridgeMode==="bridge"?"bridge":"childbridge"),v(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),I(n.fileLogger),b(n.virtualMode))},[n]),r.useEffect(()=>{const R=localStorage.getItem("frontendTheme");R&&C(R)},[]);const h=R=>{o&&console.log("handleChangeBridgeMode called with value:",R.target.value),f(R.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:R.target.value}})},x=R=>{o&&console.log("handleChangeMbLoggerLevel called with value:",R.target.value),v(R.target.value),l({id:p.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:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:R.target.checked}})},de=R=>{const B=R.target.value;o&&console.log("handleChangeTheme called with value:",B),C(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),V(B),localStorage.setItem("homePagePlugins",B?"true":"false")},se=R=>{const B=R.target.value;o&&console.log("handleChangeHomePageMode called with value:",B),q(B),localStorage.setItem("homePageMode",B)},je=R=>{const B=R.target.value;o&&console.log("handleChangeVirtualMode called with value:",B),b(B),localStorage.setItem("virtualMode",B),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:B}})};return!n||!c?null:e.jsxs(ke,{style:{flex:`1 1 ${Pt}px`},children:[e.jsx(De,{children:e.jsx(Me,{children:"Matterbridge settings"})}),e.jsx(pi,{open:u,ip:c.ipv4Address,onClose:F,onSave:j}),e.jsx(ui,{open:U,onClose:d,onSave:s}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(gr,{row:!0,name:"mode-buttons-group",value:a,onChange:h,children:[e.jsx(Be,{value:"bridge",control:e.jsx(It,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Be,{value:"childbridge",control:e.jsx(It,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(et,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:g,onChange:x,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(_e,{checked:t,onChange:H,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(et,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:y,onChange:de,children:[e.jsx(k,{value:"classic",children:"Classic"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(_e,{checked:w,onChange:ye,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(et,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:_,onChange:se,children:[e.jsx(k,{value:"logs",children:"Logs"}),e.jsx(k,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(et,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:N,onChange:je,children:[e.jsx(k,{value:"disabled",children:"Disabled"}),e.jsx(k,{value:"outlet",children:"Outlet"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"switch",children:"Switch"}),e.jsx(k,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>X(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>P(!0),children:"Configure IP"})})]})]})}function hi({matterbridgeInfo:n}){const{sendMessage:c,getUniqueId:l}=r.useContext(be),[i,a]=r.useState("Info"),[f,g]=r.useState(!1),[v,t]=r.useState(""),[I,y]=r.useState(""),[C,w]=r.useState(""),[V,_]=r.useState(""),[q,N]=r.useState(""),[b,p]=r.useState(""),u=r.useRef(l()),P=r.useMemo(()=>Ye(1e3),[]),F=r.useMemo(()=>Ye(1e3),[]),j=r.useMemo(()=>Ye(1e3),[]),U=r.useMemo(()=>Ye(1e3),[]),X=r.useMemo(()=>Ye(1e3),[]),d=r.useMemo(()=>Ye(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),g(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),w(n.matterIpv6Address||""),_(n.matterPort?n.matterPort.toString():""),N(n.matterDiscriminator?n.matterDiscriminator.toString():""),p(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>P.cancel(),[P]),r.useEffect(()=>()=>F.cancel(),[F]),r.useEffect(()=>()=>j.cancel(),[j]),r.useEffect(()=>()=>U.cancel(),[U]),r.useEffect(()=>()=>X.cancel(),[X]),r.useEffect(()=>()=>d.cancel(),[d]);const s=R=>{o&&console.log("handleChangeMjLoggerLevel called with value:",R.target.value),a(R.target.value),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:R.target.value}})},h=R=>{o&&console.log("handleLogOnFileMjChange called with value:",R.target.checked),g(R.target.checked),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:R.target.checked}})},x=R=>{o&&console.log("handleChangeMdnsInterface called with value:",R.target.value);const B=R.target.value;t(B),P(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",B),c({id:u.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),F(()=>{o&&console.log("debounced sendMessage setipv4address with value:",B),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:B}})})},de=R=>{o&&console.log("handleChangeIpv6Address called with value:",R.target.value);const B=R.target.value;w(B),j(()=>{o&&console.log("debounced sendMessage setipv6address with value:",B),c({id:u.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),U(()=>{o&&console.log("debounced sendMessage setmatterport with value:",B),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:B}})})},se=R=>{o&&console.log("handleChangeMatterDiscriminator called with value:",R.target.value);const B=R.target.value;N(B),X(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",B),c({id:u.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;p(B),d(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",B),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:B}})})};return n?e.jsxs(ke,{style:{flex:`1 1 ${Pt}px`},children:[e.jsx(De,{children:e.jsx(Me,{children:"Matter settings"})}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(et,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:s,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(_e,{checked:f,onChange:h,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(he,{value:v,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{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",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(he,{value:C,onChange:de,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(he,{value:V,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",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(he,{value:q,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",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(he,{value:b,onChange:je,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function fi({matterbridgeInfo:n}){return n?e.jsxs(ke,{style:{flex:`1 1 ${Pt}px`},children:[e.jsx(De,{children:e.jsx(Me,{children:"Matterbridge info"})}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Ie,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Ie,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Ie,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Ie,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Ie,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Ie,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Ie,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function xi({systemInfo:n}){return n?e.jsxs(ke,{style:{flex:`1 1 ${Pt}px`},children:[e.jsx(De,{children:e.jsx(Me,{children:"System info"})}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Ie,{value:n.interfaceName,label:"Interface name"}),e.jsx(Ie,{value:n.macAddress,label:"MAC Address"}),e.jsx(Ie,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Ie,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Ie,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Ie,{value:n.hostname,label:"Hostname"}),e.jsx(Ie,{value:n.user,label:"User"})]})]}):null}function Ie({value:n,label:c,width:l}){return e.jsx(he,{focused:!0,value:n,size:"small",label:c,variant:"standard",sx:{width:l?`${l-20}px`:"100%","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const bi=r.memo(gi);function vi(){const{online:n,sendMessage:c,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(be),{showSnackbarMessage:f}=r.useContext(Pe),[g,v]=r.useState(null),[t,I]=r.useState([]),[y,C]=r.useState([]),[w,V]=r.useState(null),[_,q]=r.useState({cpuUsage:0}),[N,b]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[p,u]=r.useState({systemUptime:"",processUptime:""}),P=r.useRef(a());return o&&console.log("Test uniqueId:",P),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const F=j=>{if(j.method==="restart_required")o&&console.log("Test received restart_required"),f("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),f("Refresh required",0),c({id:P.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:P.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:P.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="memory_update")o&&console.log("Test received memory_update",j),b(j.response);else if(j.method==="cpu_update")o&&console.log("Test received cpu_update",j),q(j.response);else if(j.method==="uptime_update")o&&console.log("Test received uptime_update",j),u(j.response);else if(j.method==="/api/settings"&&j.response)o&&console.log("Test received /api/settings:",j.response),f("Test received /api/settings",0),v(j.response);else if(j.method==="/api/plugins"&&j.response)o&&console.log(`Test received ${j.response.length} plugins:`,j.response),f("Test received /api/plugins",0),I(j.response);else if(j.method==="/api/devices"&&j.response){o&&console.log(`Test received ${j.response.length} devices:`,j.response),f("Test received /api/devices",0),C(j.response);for(const U of j.response)o&&console.log("Test sending /api/clusters for device:",U.pluginName,U.name,U.endpoint),c({id:P.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:U.pluginName,endpoint:U.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&(o&&console.log(`Test received ${j.response.clusters.length} clusters for device ${j.response.deviceName} endpoint ${j.response.id}:${j.response.number}:`,j),f(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),V(j.response))};return l(F,P.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(F),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,c,f]),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,c,f]),o&&console.log("Test rendering..."),n?e.jsx(at,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Te,{})}const yi=r.memo(vi);function ji(n,c){o&&console.log("getCssVariable:",n,"defaultValue",c);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||c}function wi(n){return jo({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 Ci(){const{mobile:n,showSnackbarMessage:c,showConfirmCancelDialog:l}=r.useContext(Pe),{online:i,sendMessage:a,logMessage:f,addListener:g,removeListener:v,getUniqueId:t}=r.useContext(be),[I,y]=r.useState(!1),[C,w]=r.useState(!1),[V,_]=r.useState(!1),[q,N]=r.useState(!1),[b,p]=r.useState(null),u=r.useRef(t()),[P,F]=r.useState(null),[j,U]=r.useState(null),[X,d]=r.useState(null),[s,h]=r.useState(null),[x,H]=r.useState(null),de=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},ye=()=>{window.open("https://matterbridge.io/")},se=()=>{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")},T=()=>{a({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},G=()=>{a({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},$=()=>{a({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},W=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),f("Matterbridge","Installing system updates..."),a({id:u.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),f("Matterbridge","Installing software updates..."),a({id:u.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},S=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:u.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),f("Matterbridge","Downloading Shelly system log..."),c("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},K=()=>{b?.matterbridgeInformation.restartMode===""?a({id:u.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{a({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},oe=()=>{a({id:u.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{a({id:u.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=()=>{a({id:u.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},pe=E=>{F(E.currentTarget)},D=E=>{o&&console.log("Header: handleMenuClose",E),F(null),E==="download-mblog"?(f("Matterbridge","Downloading matterbridge log..."),c("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):E==="download-mjlog"?(f("Matterbridge","Downloading matter log..."),c("Downloading matter log...",5),window.location.href="./api/download-mjlog"):E==="view-mblog"?(f("Matterbridge","Loading matterbridge log..."),c("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):E==="view-mjlog"?(f("Matterbridge","Loading matter log..."),c("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):E==="view-diagnostic"?(f("Matterbridge","Loading diagnostic log..."),c("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):E==="download-diagnostic"?(f("Matterbridge","Downloading diagnostic log..."),c("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):E==="view-history"?a({id:u.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):E==="download-history"?a({id:u.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):E==="view-shellylog"?(f("Matterbridge","Loading shelly system log..."),c("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):E==="download-mbstorage"?(f("Matterbridge","Downloading matterbridge storage..."),c("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):E==="download-pluginstorage"?(f("Matterbridge","Downloading matterbridge plugins storage..."),c("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):E==="download-pluginconfig"?(f("Matterbridge","Downloading matterbridge plugins config..."),c("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):E==="download-mjstorage"?(f("Matterbridge","Downloading matter storage..."),c("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):E==="download-backup"?(f("Matterbridge","Downloading backup..."),c("Downloading backup...",10),window.location.href="./api/download-backup"):E==="update"?T():E==="updatedev"?G():E==="updatecheck"?$():E==="shelly-sys-update"?W():E==="shelly-main-update"?M():E==="shelly-create-system-log"?S():E==="shelly-download-system-log"?L():E==="softreset"?ce():E==="hardreset"?ge():E==="restart"?K():E==="shutdown"?ae():E==="reboot"?oe():E==="create-backup"?a({id:u.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):E==="unregister"?a({id:u.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):E==="reset"?a({id:u.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):E==="factoryreset"&&a({id:u.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},m=E=>{o&&console.log("Header: handleMenuCloseCancel:",E),F(null)},xe=E=>{U(E.currentTarget)},ee=()=>{U(null)},fe=E=>{d(E.currentTarget)},Y=()=>{d(null)},me=E=>{h(E.currentTarget)},ve=()=>{h(null)},ot=E=>{H(E.currentTarget)},Re=()=>{H(null)},z=()=>{ki(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const E=re=>{o&&console.log("Header received WebSocket Message:",re),re.method==="/api/settings"&&re.id===u.current?(o&&console.log("Header received settings:",re.response),p(re.response),y(re.response.matterbridgeInformation.restartRequired||re.response.matterbridgeInformation.fixedRestartRequired),w(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:u.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&&w(!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?N(!0):_(!0),a({id:u.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:"),p(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:"),p(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="/api/viewhistorypage"&&re.id===u.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===u.current&&re.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return g(E,u.current),o&&console.log(`Header added WebSocket listener id ${u.current}`),()=>{v(E),o&&console.log("Header removed WebSocket listener")}},[g,v,a,c]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!b?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:z}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(ct,{to:"/",className:"nav-link",children:"Home"}),e.jsx(ct,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(ct,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(ct,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!b.matterbridgeInformation.readOnly&&e.jsx(O,{title:`Matterbridge v.${b.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",b.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(b.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),b.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),b.matterbridgeInformation.bridgeMode!==""&&b.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:b.matterbridgeInformation.bridgeMode})}):null,b.matterbridgeInformation.restartMode!==""&&b.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:b.matterbridgeInformation.restartMode})}):null,b.matterbridgeInformation.profile&&b.matterbridgeInformation.profile!==""&&b.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:b.matterbridgeInformation.profile})}):null,o&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${kt}x${Mt}`,` enabled ${localStorage.getItem("enableMobile")!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[b.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:R})}):null,b.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:B,children:e.jsx(pr,{})})}):null,b.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:de,children:e.jsx(Rt,{})})}):null,e.jsx(O,{title:"Matterbridge homepage",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ye,children:e.jsx(wo,{})})}),e.jsx(O,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:se,children:e.jsx(lr,{})})}),e.jsx(O,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:je,children:e.jsx(Ft,{})})}),b.matterbridgeInformation&&!b.matterbridgeInformation.readOnly&&V&&e.jsx(O,{title:`Update matterbridge to latest version v.${b.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(Q,{style:{color:V?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:T,children:e.jsx(Ne,{})})}),b.matterbridgeInformation&&!b.matterbridgeInformation.readOnly&&q&&e.jsx(O,{title:`Update matterbridge to latest dev version v.${b.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(Q,{style:{color:q?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:G,children:e.jsx(Ne,{})})}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&b.matterbridgeInformation.shellySysUpdate&&e.jsx(O,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:W,children:e.jsx(Ne,{})})}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&b.matterbridgeInformation.shellyMainUpdate&&e.jsx(O,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(Ne,{})})}),e.jsx(O,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:I||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(Ct,{})})}),b.matterbridgeInformation.restartMode===""?e.jsx(O,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:I||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:ae,children:e.jsx(ze,{})})}):null,e.jsx(O,{title:"Download, backup and more",children:e.jsx(Q,{onClick:pe,children:e.jsx(Co,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Xe,{id:"command-menu",anchorEl:P,keepMounted:!0,open:!!P,onClose:()=>D(""),children:[ue&&n&&e.jsxs(k,{onClick:()=>window.open("/home","_self"),children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ue&&n&&e.jsxs(k,{onClick:()=>window.open("/devices","_self"),children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ue&&n&&e.jsxs(k,{onClick:()=>window.open("/log","_self"),children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ue&&n&&e.jsxs(k,{onClick:()=>window.open("/settings","_self"),children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&!b.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>D("update"),children:[e.jsx(A,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&!b.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>D("updatedev"),children:[e.jsx(A,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&!b.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>D("updatecheck"),children:[e.jsx(A,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&b.matterbridgeInformation.shellySysUpdate&&e.jsxs(k,{onClick:()=>D("shelly-sys-update"),children:[e.jsx(A,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&b.matterbridgeInformation.shellyMainUpdate&&e.jsxs(k,{onClick:()=>D("shelly-main-update"),children:[e.jsx(A,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>D("restart"),children:[e.jsx(A,{children:e.jsx(Ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation.restartMode===""?e.jsxs(k,{onClick:()=>D("shutdown"),children:[e.jsx(A,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",D,m)},children:[e.jsx(A,{children:e.jsx(Ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(mt,{}),e.jsxs(k,{onClick:fe,children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-view",anchorEl:X,keepMounted:!0,open:!!X,onClose:Y,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{Di(),Y(),m(""),window.open("/home","_self")},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{Ii(),Y(),m(""),window.open("/home","_self")},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("view-mblog"),Y()},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("view-mjlog"),Y()},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("view-diagnostic"),Y()},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("view-history"),Y()},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{D("view-shellylog"),Y()},children:[e.jsx(A,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(k,{onClick:me,children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{D("download-mbstorage"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-pluginstorage"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-pluginconfig"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-mblog"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-mjstorage"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-mjlog"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-diagnostic"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-history"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{D("shelly-create-system-log"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{D("shelly-download-system-log"),ve()},children:[e.jsx(A,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(k,{onClick:xe,children:[e.jsx(A,{children:e.jsx(Lt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:ee,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{D("create-backup"),ee()},children:[e.jsx(A,{children:e.jsx(Lt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{D("download-backup"),ee()},children:[e.jsx(A,{children:e.jsx(Lt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(k,{onClick:ot,children:[e.jsx(A,{children:e.jsx(So,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-reset",anchorEl:x,keepMounted:!0,open:!!x,onClose:Re,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{Re(),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",D,m)},children:[e.jsx(A,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{Re(),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",D,m)},children:[e.jsx(A,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!b.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>{Re(),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",D,m)},children:[e.jsx(A,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{Re(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",D,m)},children:[e.jsx(A,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),b.matterbridgeInformation&&b.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{Re(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",D,m)},children:[e.jsx(A,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(Z,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const nr=r.memo(Ci),br=1200,vr=900;let kt,Mt;function ir(){if(typeof window<"u"){kt=Math.floor(window.visualViewport?.width??window.innerWidth),Mt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=kt<br||Mt<vr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,kt,Mt,n),n}return!1}function Si({children:n}){const{mobile:c,setMobile:l}=r.useContext(Pe);return r.useEffect(()=>{function i(){l(ir())}return window.addEventListener("resize",i),l(ir()),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",c),ue&&c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(nr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:c?`${br}px`:"calc(100vw - 40px)",height:c?`${vr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(nr,{}),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 ki=()=>{o=!o},Mi=!1;let ue=localStorage.getItem("enableMobile")!=="false";const Ii=()=>{ue=!0,localStorage.setItem("enableMobile","true")},Di=()=>{ue=!1,localStorage.setItem("enableMobile","false")};let tt;const Pi=n=>{tt=n};function Li({setLoggedIn:n}){const[c,l]=r.useState(""),[i,a]=r.useState(""),f={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},g={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 C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(C.ok){const{valid:w}=await C.json();w?(n(!0),y!==""&&(tt=y)):y!==""&&a("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},I=y=>{y.preventDefault(),t(c)};return t(""),e.jsx("div",{style:f,children:e.jsxs("form",{onSubmit:I,style:g,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:c,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 $i(){const[n,c]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=ji("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=wi(i);window.location.href.includes("/api/hassio_ingress/");const f=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 = "${f}"`)),n?e.jsx(ko,{theme:a,children:e.jsx(Rr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(cn,{children:e.jsx(dn,{children:e.jsx(Lr,{basename:f,children:e.jsx(Si,{children:e.jsxs($r,{children:[e.jsx(Qe,{path:"/",element:e.jsx(En,{})}),e.jsx(Qe,{path:"/devices",element:e.jsx(li,{})}),e.jsx(Qe,{path:"/log",element:e.jsx(di,{})}),e.jsx(Qe,{path:"/settings",element:e.jsx(bi,{})}),e.jsx(Qe,{path:"/test",element:e.jsx(yi,{})}),e.jsx(Qe,{path:"*",element:e.jsx(Wr,{to:"/"})})]})})})})})})}):e.jsx(Li,{setLoggedIn:c})}Nr.createRoot(document.getElementById("root")).render(e.jsx(Tr.StrictMode,{children:e.jsx($i,{})}));
|
|
1
|
+
import{B as e,y as r,S as Tr,U as gt,V as Nr,X as Rr,Y as Je,Z as Or,$ as Hr,I as Vr}from"./vendor_node_modules.js";import{u as Er,S as Ar}from"./vendor_notistack.js";import{D as He,a as Ve,b as Ee,B as le,c as Ue,F as Ge,C as qe,d as ie,A as _r,I as Q,e as qr,f as zr,T as H,g as me,M as Ur,h as ot,i as w,j as We,k as dr,l as Br,m as St,n as Qr,o as ue,K as Ut,p as Bt,q as Ht,L as mt,r as lt,s as ht,t as q,W as ct,u as ft,H as xt,v as ee,V as Qt,w as Kt,x as Kr,E as Gr,Q as pr,R as kt,S as Jr,U as Zr,P as Yr,y as ur,z as Vt,G as Ne,J as Et,N as gr,O as It,X as mr,Y as Xr,Z as hr,_ as eo,$ as to,a0 as ro,a1 as Gt,a2 as oo,a3 as no,a4 as io,a5 as so,a6 as lo,a7 as ao,a8 as co,a9 as Jt,aa as po,ab as uo,ac as go,ad as mo,ae as ho,af as fo,ag as xo,ah as bo,ai as vo,aj as yo,ak as jo,al as Co,am as wo,an as So,ao as ko,ap as Wt,aq as Qe,ar as fr,as as we,at as xr,au as Pt,av as ze,aw as Io,ax as Mo,ay as Be,az as Do,aA as $e,aB as bt,aC as Ft,aD as Po,aE as Lo}from"./vendor_mui.js";import{I as se,m as $o,a as Zt,b as Wo,c as Fo,d as Yt,e as To,f as No,g as Ro,h as Oo,i as Ho,j as Vo,k as Eo,l as Ao,n as _o,o as qo,p as zo,q as Uo,r as Xt,s as Bo,t as Qo,u as Ko,v as Go,w as Jo,x as Zo,y as Yo,z as Xo,A as er,B as en,C as tn}from"./vendor_mdi.js";import{Q as rn}from"./vendor_qrcode.js";import{F as on,v as nn,e as sn,a as ln,g as an,b as cn,c as dn,d as Tt,A as pn}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const m of s)if(m.type==="childList")for(const g of m.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&i(g)}).observe(document,{childList:!0,subtree:!0});function l(s){const m={};return s.integrity&&(m.integrity=s.integrity),s.referrerPolicy&&(m.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?m.credentials="include":s.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function i(s){if(s.ep)return;s.ep=!0;const m=l(s);fetch(s.href,m)}})();function un({open:n,title:c,message:l,onConfirm:i,onCancel:s}){const m=b=>{o&&console.log("Confirmed"),b.preventDefault(),i()},g=b=>{o&&console.log("Canceled"),b.preventDefault(),s()};return e.jsxs(He,{open:n,children:[e.jsx(Ve,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Ee,{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(le,{onClick:m,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(le,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const gn=({open:n,output:c,title:l,_command:i,_packageName:s,onInstall:m,onClose:g})=>{const{installAutoExit:b,setInstallAutoExit:t}=r.useContext(De),$=r.useRef(null),y=I=>{t(I.target.checked),localStorage.setItem("installAutoExit",I.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",I.target.checked)};return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${$.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",$.current),$.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[c]),e.jsxs(He,{open:n,onClose:(I,C)=>{C==="backdropClick"||C==="escapeKeyDown"||g()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Ve,{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(Ee,{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:[c.split(`
|
|
2
|
+
`).map((I,C)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:I},C)),e.jsx("li",{ref:$,style:{padding:0,margin:0}})]})]}),e.jsxs(Ue,{sx:{justifyContent:"space-evenly"},children:[m&&e.jsx(le,{variant:"contained",onClick:m,children:"Install"}),e.jsx(le,{onClick:g,children:"Close"}),e.jsx(Ge,{control:e.jsx(qe,{checked:b,onChange:I=>y(I)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},vt=[],De=r.createContext(null);function mn({children:n}){const[c,l]=r.useState(!1),[i,s]=r.useState(null),{enqueueSnackbar:m,closeSnackbar:g}=Er(),b=r.useCallback(M=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${M}`);const R=vt.findIndex(Z=>Z.message===M);R!==-1&&(g(vt[R].key),vt.splice(R,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${M} removed from persistMessages`))},[g]),t=r.useCallback((M,R,Z)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${M} timeout ${R}`);const pe=m(M,{variant:"default",autoHideDuration:R==null||R>0?(R??5)*1e3:null,persist:R===0,content:ce=>e.jsx(ie,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(_r,{severity:Z??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>g(ce),action:e.jsx(Q,{size:"small",onClick:()=>g(ce),sx:{color:"#fff"},children:e.jsx(qr,{fontSize:"small"})}),children:M},ce)},ce)});R===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${M} timeout ${R} - persist key ${pe}`),vt.push({message:M,key:pe}))},[m,g]),[$,y]=r.useState(!1),[I,C]=r.useState(""),[V,z]=r.useState(""),[B,A]=r.useState(""),h=r.useRef(null),p=r.useRef(null),u=()=>{o&&console.log(`UiProvider handle confirm action ${B}`),y(!1),h.current&&h.current(B)},k=()=>{o&&console.log(`UiProvider handle cancel action ${B}`),y(!1),p.current&&p.current(B)},S=r.useCallback((M,R,Z,pe,ce)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${Z}`),C(M),z(R),A(Z),h.current=pe,p.current=ce,y(!0)},[]),[j,Y]=r.useState(!1),[re,v]=r.useState(""),[d,a]=r.useState(""),[x,F]=r.useState(""),[N,te]=r.useState(""),[fe,Se]=r.useState(localStorage.getItem("installAutoExit")!=="false"),O=r.useCallback((M,R,Z)=>{o&&console.log(`UiProvider show install progress for package ${M}`),v(M),a(R),F(Z),Y(!0)},[]),U=r.useCallback(M=>{o&&console.log(`UiProvider addInstallProgress: output ${M}`),te(R=>R+M+`
|
|
3
|
+
`)},[]),T=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${x}`),localStorage.getItem("installAutoExit")!=="false"&&Y(!1)},[x]),K=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${x}`)},[x]),W=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),Y(!1)},[]),L=()=>{o&&console.log("UiProvider handle install close action"),Y(!1),F(""),te("")},P=r.useMemo(()=>({mobile:c,setMobile:l,currentPage:i,setCurrentPage:s,showSnackbarMessage:t,closeSnackbarMessage:b,closeSnackbar:g,showConfirmCancelDialog:S,showInstallProgress:O,exitInstallProgressSuccess:T,exitInstallProgressError:K,hideInstallProgress:W,addInstallProgress:U,installAutoExit:fe,setInstallAutoExit:Se}),[c,i,l,s,t,b,g,S,O,T,K,W,U,fe,Se]);return e.jsxs(De.Provider,{value:P,children:[e.jsx(un,{open:$,title:I,message:V,onConfirm:u,onCancel:k}),e.jsx(gn,{open:j,title:re,_command:d,_packageName:x,output:N,onClose:L}),n]})}const br=r.createContext(null),he=r.createContext(null);function hn({children:n}){const[c,l]=r.useState([]),[i,s]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[m,g]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[b,t]=r.useState(!1),{showSnackbarMessage:$,closeSnackbarMessage:y,closeSnackbar:I,showInstallProgress:C,hideInstallProgress:V,exitInstallProgressSuccess:z,exitInstallProgressError:B,addInstallProgress:A}=r.useContext(De),h=r.useRef([]),p=r.useRef(null),u=r.useRef(1),k=r.useRef(Math.floor(Math.random()*999e3)+1e3),S=r.useRef(null),j=r.useRef(null),Y=r.useRef(null),re=r.useRef(i),v=r.useRef(m),d=r.useRef(0),a=r.useRef(null),x=r.useRef(Number(localStorage.getItem("logLength")??200)),F=r.useRef(localStorage.getItem("logAutoScroll")!=="false"),N=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),te=100,fe=60,Se=50,O=300,U=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),a.current=setInterval(()=>{d.current>0&&(o&&console.log(`WebSocket messages received in the last ${U} seconds: ${d.current*(60/U)} messages/minute`),d.current=0)},U*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),a.current&&clearInterval(a.current),a.current=null}),[]),r.useEffect(()=>{re.current=i},[i]),r.useEffect(()=>{v.current=m},[m]);const T=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),K=r.useCallback((G,f)=>{o&&console.log(`WebSocket filterLogMessages called with level "${G}" and search "${f}"...`),l(ae=>ae.filter(J=>!(["debug","info","notice","warn","error","fatal"].includes(J.level)&&(G==="info"&&J.level==="debug"||G==="notice"&&(J.level==="debug"||J.level==="info")||G==="warn"&&(J.level==="debug"||J.level==="info"||J.level==="notice")||G==="error"&&(J.level==="debug"||J.level==="info"||J.level==="notice"||J.level==="warn")||G==="fatal"&&(J.level==="debug"||J.level==="info"||J.level==="notice"||J.level==="warn"||J.level==="error"))||f!=="*"&&f!==""&&!f.startsWith("/")&&!f.endsWith("/")&&!J.message.toLowerCase().includes(f.toLowerCase())&&!J.name.toLowerCase().includes(f.toLowerCase())||f.startsWith("/")&&f.endsWith("/")&&(()=>{try{const D=new RegExp(f.slice(1,-1),"i");return!D.test(J.message)&&!D.test(J.name)}catch(D){return console.error(`WebSocket log search invalid regex filter "${f}":`,D),!1}})())))},[]),W=r.useCallback(G=>{if(p.current&&p.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${G.id}:`,G),G.id===void 0&&(G.id=k.current);const f=JSON.stringify(G);p.current.send(f),o&&console.log("WebSocket sent message:",G)}catch(f){o&&console.error(`WebSocket error sending message: ${f}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",G)},[]),L=r.useCallback((G,f)=>{l(ae=>[...ae,{level:G,time:"",name:"",message:f}])},[]),P=r.useCallback((G,f)=>{o&&console.log(`WebSocket addListener id ${f}:`,G),(f==null||isNaN(f)||f===0)&&console.error("WebSocket addListener called without id, listener not added:",G),h.current=[...h.current,{listener:G,id:f}],o&&console.log("WebSocket addListener total listeners:",h.current.length)},[]),M=r.useCallback(G=>{o&&console.log("WebSocket removeListener:",G),h.current=h.current.filter(f=>f.listener!==G),o&&console.log("WebSocket removeListener total listeners:",h.current.length)},[]),R=r.useCallback(()=>{N===""||N===null||N===void 0||(L("WebSocket",`Connecting ${it?"with password":""} to WebSocket: ${N}`),o&&console.log(`WebSocket connecting to: ${N}${it?"?password=[redacted]":""}`),p.current=new WebSocket(N+(it?`?password=${encodeURIComponent(it)}`:"")),p.current.onmessage=G=>{b||t(!0),d.current+=1;try{const f=JSON.parse(G.data);if(f.id===void 0||f.src===void 0||f.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",f);return}if(f.src!=="Matterbridge"||f.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",f);return}if(f.error){o&&console.error("WebSocket error message response:",f);return}if(f.id===k.current&&f.method==="pong"&&f.response==="pong"){o&&console.log(`WebSocket pong response message id ${f.id}:`,f),j.current&&clearTimeout(j.current),j.current=null;return}else if(f.method==="snackbar"&&f.response&&f.response.message){o&&console.log(`WebSocket message id ${f.id} method ${f.method}:`,f),$(f.response.message,f.response.timeout,f.response.severity);return}else if(f.method==="close_snackbar"&&f.response&&f.response.message){o&&console.log(`WebSocket message id ${f.id} method ${f.method}:`,f),y(f.response.message);return}else if(f.method==="log"){if(!f.response||!f.response.level||!f.response.time||!f.response.name||!f.response.message||(f.response.level==="spawn"&&(f.response.name==="Matterbridge:spawn-init"?C(f.response.message,"",""):f.response.name==="Matterbridge:spawn-exit-success"?z():f.response.name==="Matterbridge:spawn-exit-error"?B():A(f.response.message+`
|
|
4
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(f.response.level)&&(re.current==="info"&&f.response.level==="debug"||re.current==="notice"&&(f.response.level==="debug"||f.response.level==="info")||re.current==="warn"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice")||re.current==="error"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn")||re.current==="fatal"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn"||f.response.level==="error")))||v.current!=="*"&&v.current!==""&&!v.current.startsWith("/")&&!v.current.endsWith("/")&&!f.response.message.toLowerCase().includes(v.current.toLowerCase())&&!f.response.name.toLowerCase().includes(v.current.toLowerCase())||v.current.startsWith("/")&&v.current.endsWith("/")&&(()=>{try{const J=new RegExp(v.current.slice(1,-1),"i");return!J.test(f.response.message)&&!J.test(f.response.name)}catch(J){return console.error(`WebSocket log search invalid regex filter "${v.current}":`,J),!1}})()||f.response.name==="Commissioning"&&f.response.message.includes("is uncommissioned"))return;l(J=>{const D=[...J,{level:f.response.level,time:f.response.time,name:f.response.name,message:f.response.message}];return o&&console.log(`WebSocket new log message added (${D.length}/${x.current}):`,D[D.length-1]),D.length>x.current+x.current*10/100?(o&&console.log(`WebSocket sliced log messages to the last ${x.current} entries`),D.slice(D.length-x.current)):D})}else{if(o&&console.log(`WebSocket received message id ${f.id} method ${f.method}:`,f),f.id===0)h.current.forEach(ae=>ae.listener(f));else{const ae=h.current.find(J=>J.id===f.id);ae?ae.listener(f):console.warn(`WebSocket no listener found for message id ${f.id}:`,f)}return}}catch(f){console.error(`WebSocket error parsing message: ${f}`,f instanceof Error?f.stack:null)}},p.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${N}`),L("WebSocket",`Connected to WebSocket: ${N}`),t(!0),I(),u.current=1,Y.current=setTimeout(()=>{S.current=setInterval(()=>{W({id:k.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${N}`),L("WebSocket",`No pong response received from WebSocket: ${N}`),t(!1)},1e3*Se)},1e3*fe)},1e3*O)},p.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${pt?"with Ingress":""}: ${N}`),L("WebSocket",`Disconnected from WebSocket: ${N}`),t(!1),I(),V(),Y.current&&clearTimeout(Y.current),j.current&&clearTimeout(j.current),S.current&&clearInterval(S.current),L("WebSocket",`Reconnecting (attempt ${u.current} of ${te}) to WebSocket${pt?" (Ingress)":""}: ${N}`),pt?setTimeout(Z,5e3):u.current===1?Z():u.current<te?setTimeout(Z,1e3*u.current):L("WebSocket",`Reconnect attempts exceeded limit of ${te} retries, refresh the page to reconnect to: ${N}`),u.current=u.current+1},p.current.onerror=G=>{o&&console.error(`WebSocket: WebSocket error connecting to ${N}:`,G),L("WebSocket",`WebSocket error connecting to ${N}`)})},[N]),Z=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${u.current}/${te} to:`,N),R()},[R]);r.useEffect(()=>(R(),()=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.close()}),[R]);const pe=r.useMemo(()=>({messages:c,logLength:x,logAutoScroll:F,logFilterLevel:i,logFilterSearch:m,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:g,filterLogMessages:K}),[c,x,F,i,m,l,s,g,K]),ce=r.useMemo(()=>({logLength:x,logAutoScroll:F,logFilterLevel:i,logFilterSearch:m,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:g,filterLogMessages:K,online:b,retry:u.current,getUniqueId:T,addListener:P,removeListener:M,sendMessage:W,logMessage:L}),[x,F,l,s,g,b,u.current,P,M,W,L]);return e.jsx(br.Provider,{value:pe,children:e.jsx(he.Provider,{value:ce,children:n})})}function fn(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 Re(){const{retry:n}=r.useContext(he),c=()=>{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(fn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(zr,{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(le,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function vr({value:n,maxChars:c}){let l=n;if(n.length>c&&c>3){const i=c-3,s=n.substring(0,Math.ceil(i/2)),m=n.substring(n.length-Math.floor(i/2),n.length);l=`${s} … ${m}`}return n!==l?e.jsx(H,{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 be({children:n,style:c}){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,...c},children:n})}function Ie({children:n,style:c}){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,...c},children:n})}function ye({children:n,style:c}){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,...c},children:n})}function dt({children:n,style:c}){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,...c},children:n})}function nt({children:n,style:c}){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,...c},children:n})}function at({children:n,style:c}){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,...c},children:n})}function Fe({children:n,style:c,onDragOver:l,onDragLeave:i,onDrop:s}){const m={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...m,...c},onDragOver:l,onDragLeave:i,onDrop:s,children:n})}function Ke({children:n,style:c,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...c},children:[n,Wi]})}function xn({systemInfo:n,compact:c}){const{mobile:l}=r.useContext(De),{addListener:i,removeListener:s,getUniqueId:m,sendMessage:g}=r.useContext(he),[b,t]=r.useState(n),$=r.useRef(m());if(o&&console.log("SystemInfoTable loading with systemInfo:",b,"compact:",c),n&&c&&b.totalMemory&&b.freeMemory){const h=b.totalMemory,p=b.freeMemory;b.freeMemory=`${p} / ${h}`,b.totalMemory=""}if(n&&c&&b.heapTotal&&b.heapUsed){const h=b.heapTotal,p=b.heapUsed;b.heapUsed=`${p} / ${h}`,b.heapTotal=""}if(n&&c&&b.osRelease&&b.osType){const h=b.osType,p=b.osRelease;b.osType=`${h} (${p})`,b.osRelease=""}if(n&&c&&b.osArch&&b.osPlatform){const h=b.osPlatform,p=b.osArch;b.osPlatform=`${h} (${p})`,b.osArch=""}const y=(h,p,u,k,S)=>{t(j=>({...j,totalMemory:h,freeMemory:p,heapTotal:u,heapUsed:k,rss:S}))},I=h=>{t(p=>({...p,cpuUsage:h.toFixed(2)+" %"}))},C=h=>{t(p=>({...p,processCpuUsage:h.toFixed(2)+" %"}))},V=(h,p)=>{t(u=>({...u,systemUptime:h,processUptime:p}))},z=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),g({id:$.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const h=p=>{o&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(o&&console.log("SystemInfoTable received memory_update",p),y(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",p),I(p.response.cpuUsage),C(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",p),V(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===$.current&&p.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(h,$.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${$.current}`),()=>{s(h),o&&console.log("SystemInfoTable removed WebSocket listener")}},[i,s]);const[B,A]=r.useState(!1);return!b||B?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(be,{style:ge&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ie,{children:[e.jsx(ye,{children:"System info"}),e.jsx(Ke,{onClose:()=>A(!0),children:e.jsx(Q,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:z,children:e.jsx(H,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(se,{path:$o,size:"22px"})})})})]}),e.jsx(Fe,{style:ge&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(b).filter(([h,p])=>p!==void 0&&p!=="").map(([h,p],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:h.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ge&&l?typeof p!="string"?p.toString():p:e.jsx(vr,{value:typeof p!="string"?p.toString():p,maxChars:22})})]},h))})]})})]}))}const tr=r.memo(xn),rr={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"}},bn=n=>{if(!n)return"";const c=n.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const l=c.slice(0,4),i=c.slice(4,7),s=c.slice(7,11);return[l,i,s].filter(Boolean).join("-")};function vn({id:n}){const{online:c,sendMessage:l,addListener:i,removeListener:s,getUniqueId:m}=r.useContext(he),[g,b]=r.useState(null),t=r.useRef(null),$=r.useRef(null),y=r.useRef(m()),{mobile:I,showConfirmCancelDialog:C}=r.useContext(De);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${$.current} and matter:`,g),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,$.current&&clearTimeout($.current),$.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"),b(null))},[n,l]),r.useEffect(()=>{const p=u=>{o&&console.log("QRDiv received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="matter"&&u.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${u.response.changed} for storeId "${u.response.matter.id}":`,u.response.matter),t.current===u.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${u.response.matter.id}":`,u.response.matter),$.current&&clearTimeout($.current),u.response.matter.advertising&&u.response.matter.advertiseTime&&u.response.matter.advertiseTime+9e5<=Date.now()&&(u.response.matter.advertising=!1),b(u.response.matter),u.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${u.response.matter.id}":`,u.response.matter.advertiseTime+9e5-Date.now()),$.current=setTimeout(()=>{$.current&&clearTimeout($.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),b(k=>k&&{...k,advertising:!1})},u.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,y.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{s(p),$.current&&clearTimeout($.current),$.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,s]);const V=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,startCommission:!0}})},z=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,stopCommission:!0}})},B=()=>{o&&console.log(`QRDiv sent matter advertise for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,advertise:!0}})},A=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${g?.id}" and fabricIndex ${p}`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,removeFabric:p}})},h=async()=>{if(!g||!g.manualPairingCode)return;const p=g.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const u=document.createElement("textarea");u.value=p,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.focus(),u.select(),document.execCommand("copy"),document.body.removeChild(u)}o&&console.log("Manual pairing code copied to clipboard")}catch(u){console.error("Failed to copy manual pairing code",u)}};return!g||!c?(o&&console.log("QRDiv rendering undefined state"),null):g.online?g.advertising&&g.qrPairingCode&&g.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(be,{style:ge&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(Ie,{children:[e.jsx(ye,{children:"QR pairing code"}),e.jsxs(Ke,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:B,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(se,{path:Zt,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:z,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn off pairing",arrow:!0,children:e.jsx(se,{path:Wo,size:"22px"})})})]})]}),e.jsx(at,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(rn,{value:g.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(dt,{style:{justifyContent:"space-between"},children:[e.jsxs(nt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",bn(g.manualPairingCode)]}),e.jsx(Ke,{children:e.jsx(H,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:h,sx:rr,children:e.jsx(se,{path:Fo,size:.85})})})})]})]})):g.commissioned&&g.fabricInformations&&g.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(be,{style:ge&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ie,{children:[e.jsx(ye,{children:"Paired fabrics"}),e.jsxs(Ke,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:B,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(se,{path:Zt,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn on pairing",arrow:!0,children:e.jsx(se,{path:Yt,size:"22px"})})})]})]}),e.jsx(at,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Fe,{style:{flexDirection:"column",flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px 0px 10px 0px",gap:"0px"},children:g.fabricInformations.map((p,u)=>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: ",p.fabricIndex]}),e.jsx(H,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(Q,{"aria-label":"remove the fabric",size:"small",onClick:()=>C("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>A(p.fabricIndex),()=>{}),sx:{...rr,padding:"2px"},children:e.jsx(se,{path:To,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",g.sessionInformations?g.sessionInformations.filter(k=>k.fabric?.fabricIndex===p.fabricIndex&&k.isPeerActive===!0).length:"0"," ","subscriptions: ",g.sessionInformations?g.sessionInformations.filter(k=>k.fabric?.fabricIndex===p.fabricIndex&&k.isPeerActive===!0&&k.numberOfActiveSubscriptions>0).length:"0"]})]},u))}),e.jsx(dt,{style:{justifyContent:"center"},children:e.jsxs(nt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]})):!g.commissioned&&!g.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(be,{style:ge&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ie,{children:e.jsx(ye,{children:"QR pairing code"})}),e.jsx(at,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(le,{onClick:V,endIcon:e.jsx(se,{path:Yt,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(dt,{style:{justifyContent:"center"},children:e.jsxs(nt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(be,{style:ge&&I?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ie,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(ye,{children:"Server node"})}),e.jsx(at,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(at,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(dt,{style:{justifyContent:"center"},children:e.jsxs(nt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]}))}const or=r.memo(vn);function yn(){const{mobile:n}=r.useContext(De),{logMessage:c,sendMessage:l,getUniqueId:i}=r.useContext(he),[s,m]=r.useState("matterbridge-"),[g,b]=r.useState(!1),[t,$]=r.useState(null),y=r.useRef(i()),I=v=>{v.preventDefault(),b(!0)},C=()=>{b(!1)},V=v=>{v.preventDefault(),b(!1);const d=v.dataTransfer.files[0];if(d){c("Plugins",`Installing package ${d.name}. Please wait...`);const a=new FormData;a.append("file",d),a.append("filename",d.name),fetch("./api/uploadpackage",{method:"POST",body:a}).then(x=>x.text()).then(x=>{c("Plugins",`Server response: ${x}`)}).catch(x=>{console.error("Error uploading plugin file:",x),c("Plugins",`Error installing package ${x}`)})}},z=v=>{const d=v.target.files&&v.target.files[0];if(d){c("Plugins",`Uploading package ${d.name}`);const a=new FormData;a.append("file",d),a.append("filename",d.name),fetch("./api/uploadpackage",{method:"POST",body:a}).then(x=>x.text()).then(x=>{c("Plugins",`Server response: ${x}`)}).catch(x=>{console.error("Error uploading plugin file:",x),c("Plugins",`Error uploading package ${x}`)})}},B=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:s,restart:!1}})},A=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:s}})},h=()=>{document.getElementById("file-upload")?.click()},p=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:s}})},u=v=>{v.preventDefault(),console.log("Right-clicked Upload button")},k=v=>{v.preventDefault(),console.log("Right-clicked Add button")},S=v=>{$(v.currentTarget)},j=v=>{v!==""&&m(v),$(null)},[Y,re]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),Y?null:e.jsxs(be,{children:[e.jsxs(Ie,{children:[e.jsx(ye,{children:"Install plugins"}),e.jsx(Ke,{onClose:()=>re(!0)})]}),e.jsxs(Fe,{onDragOver:I,onDragLeave:C,onDrop:V,style:ge&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(me,{value:s,onChange:v=>{m(v.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:S,children:e.jsx(Ur,{})}),e.jsxs(ot,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(w,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(w,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(w,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(w,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(w,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(w,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(w,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(w,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(w,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(w,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(w,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(w,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(w,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(w,{onClick:()=>j("matterbridge-eve-room"),children:"matterbridge-eve-room"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(H,{title:"Install or update a plugin from npm",children:e.jsxs(le,{onClick:B,endIcon:e.jsx(We,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(H,{title:"Uninstall and remove a plugin",children:e.jsxs(le,{onClick:A,endIcon:e.jsx(dr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(H,{title:"Upload and install a plugin from a tarball",children:e.jsxs(le,{onClick:h,onContextMenu:u,endIcon:e.jsx(Br,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(H,{title:"Add an installed plugin",children:e.jsxs(le,{onClick:p,onContextMenu:k,endIcon:e.jsx(St,{}),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:z})]})]})]})}const jn=r.memo(yn);function Ze({status:n,enabledText:c="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const m=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?c:l??c});return i!==void 0?e.jsx(H,{title:i,children:m}):m}}function Cn({title:n,children:c}){const l=r.useRef(null),[i,s]=r.useState(!1),m=()=>{const t=l.current;if(!t){s(!1);return}s(t.scrollWidth>t.clientWidth)},g=()=>{s(!1)},b={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsx(H,{title:n,open:i,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("span",{ref:l,onMouseEnter:m,onMouseLeave:g,style:b,children:c})})}function wn(n,c,l){const i=n?.[l],s=c?.[l];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Sn({name:n,title:c,columns:l,rows:i,getRowKey:s,footerLeft:m,footerRight:g,onRowClick:b}){const t=r.useRef(new WeakMap),$=r.useRef(1),y=a=>{if(typeof s=="string"&&a&&a[s]!=null)return a[s];if(typeof s=="function"){const N=s(a);if(N!=null)return N}const x=l?.[0]?.id;if(x&&a&&a[x]!=null)return a[x];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let F=t.current.get(a);return F||(F=`rk_${$.current++}`,t.current.set(a,F)),F},[I,C]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[V,z]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[B,A]=r.useState(!1),[h,p]=r.useState(()=>{try{const a=localStorage.getItem(`${n}_column_visibility`);if(a)return JSON.parse(a)}catch{}return{}}),u=r.useMemo(()=>{const a={};for(const x of l)x.hidden||(a[x.id]=x.required?!0:h[x.id]!==!1);return a},[l,h]),k=r.useMemo(()=>{if(!I||!V)return i;const a=l.find(F=>F.id===I);if(!a||a.noSort)return i;const x=i.map((F,N)=>({el:F,index:N}));return x.sort((F,N)=>{let te;return typeof a.comparator=="function"?te=a.comparator(F.el,N.el):te=wn(F.el,N.el,I),te!==0?V==="asc"?te:-te:F.index-N.index}),x.map(F=>F.el)},[i,I,V,l]),S=a=>{if(I!==a||!I){C(a),z("asc"),localStorage.setItem(`${n}_table_order_by`,a),localStorage.setItem(`${n}_table_order`,"asc");return}if(V==="asc"){z("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}C(null),z(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{A(!B)},Y=a=>{p(x=>{const F=l.find(fe=>fe.id===a);if(F&&F.required)return x;const N=u[a]!==!1,te={...x};N?te[a]=!1:delete te[a];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(te))}catch{}return te})},re=()=>{p({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}A(!1)},[v,d]=r.useState(!1);return v?null:(o&&console.log(`Rendering table ${n}${I&&V?` ordered by ${I}:${V}`:""}`),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsxs(He,{open:B,onClose:(a,x)=>{x==="backdropClick"||x==="escapeKeyDown"||j()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ve,{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(Ee,{children:e.jsx(Qr,{children:l.filter(a=>!a.hidden).map(a=>e.jsx(Ge,{control:e.jsx(qe,{disabled:!!a.required,checked:a.required?!0:u[a.id]!==!1,onChange:()=>Y(a.id)}),label:a.label},a.id))})}),e.jsxs(Ue,{children:[e.jsx(le,{onClick:re,children:"Reset"}),e.jsx(le,{variant:"contained",onClick:a=>{if(a?.currentTarget&&typeof a.currentTarget.blur=="function")try{a.currentTarget.blur()}catch{}const x=document.activeElement;if(x&&x instanceof HTMLElement&&typeof x.blur=="function")try{x.blur()}catch{}j()},children:"Close"})]})]}),e.jsxs(Ie,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx(ye,{children:n}),c&&e.jsx(ye,{children:c}),e.jsx(Ke,{onClose:()=>d(!0),children:e.jsx(Q,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:a=>{if(a?.currentTarget?.blur)try{a.currentTarget.blur()}catch{}j()},"aria-label":"Configure Columns",children:e.jsx(H,{title:`Configure ${n} columns`,children:e.jsx(se,{path:No,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx(Fe,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(a=>{if(a.hidden||!a.required&&u[a.id]===!1)return null;const x=!a.noSort,F=x&&I===a.id&&!!V;return e.jsxs("th",{onClick:x?()=>S(a.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:a.minWidth,maxWidth:a.maxWidth,textAlign:a.align||"left",cursor:x?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:a.maxWidth?"nowrap":void 0,overflow:a.maxWidth?"hidden":void 0,textOverflow:a.maxWidth?"ellipsis":void 0},"aria-sort":x?F?V==="asc"?"ascending":"descending":"none":void 0,children:[a.label,F&&e.jsxs("span",{style:{marginLeft:6},children:[V==="asc"&&e.jsx(se,{path:Ro,size:"15px"}),V==="desc"&&e.jsx(se,{path:Oo,size:"15px"})]})]},a.id)})})}),e.jsx("tbody",{children:k.map((a,x)=>{const F=y(a);return e.jsx("tr",{className:x%2===0?"table-content-even":"table-content-odd",onClick:b?N=>b(a,F,N):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:b?"pointer":void 0},children:l.map(N=>{if(N.hidden||!N.required&&u[N.id]===!1)return null;const te=a[N.id],fe=typeof N.render=="function"?N.render(te,F,a,N):typeof te=="boolean"?e.jsx(qe,{checked:te,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):N.format&&typeof te=="number"?N.format(te):te!=null?String(te):null,O=!!N.tooltip&&N.maxWidth!==void 0&&N.maxWidth!==null&&te!==void 0&&te!==null&&fe!==null?e.jsx(Cn,{title:String(te),children:fe}):fe;return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:N.align||"left",padding:"5px 10px",margin:"0",maxWidth:N.maxWidth,whiteSpace:N.maxWidth?"nowrap":void 0,overflow:N.maxWidth?"hidden":void 0,textOverflow:N.maxWidth?"ellipsis":void 0},children:O},N.id)})},F)})})]})}),(m||g)&&e.jsxs(dt,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx(nt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:m}),e.jsx(nt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]}))}function kn(n){return r.memo(n)}const Lt=kn(Sn);function nr(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Ye={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Xe={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},In={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Mn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},_e={padding:"0px",margin:"0px"},Dn="5px 10px 5px 10px",yt={},Ce={},jt={},Ct={};let et=[],Nt=[];const Pn=({open:n,onClose:c,plugin:l})=>{const{sendMessage:i,addListener:s,removeListener:m,getUniqueId:g}=r.useContext(he),b=r.useRef(g()),[t,$]=r.useState(l.configJson),[y,I]=r.useState(null),[C,V]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[z,B]=r.useState("");let A={};r.useEffect(()=>{const L=P=>{P.src==="Matterbridge"&&P.dst==="Frontend"&&(nr(P)&&P.id===b.current&&P.method==="/api/select/devices"&&P.response&&(o&&console.log(`ConfigPluginDialog (id: ${P.id}) received ${P.response.length} /api/select/devices:`,P.response),et=P.response),nr(P)&&P.id===b.current&&P.method==="/api/select/entities"&&P.response&&(o&&console.log(`ConfigPluginDialog (id: ${P.id}) received ${P.response.length} /api/select/entities:`,P.response),Nt=P.response))};return s(L,b.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",b.current),t&&y&&y.properties&&(Object.keys(y.properties).forEach(P=>{Object.keys(y.properties[P]).forEach(M=>{M.startsWith("ui:")&&(C[P]={},C[P][M]=y.properties[P][M],delete y.properties[P][M])})}),V(C)),l.name&&l.configJson&&l.schemaJson&&($(l.configJson),I(l.schemaJson),i({id:b.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:b.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)),()=>{m(L),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,t,l,m,y,i,C]);const h=(L,P)=>{A=L.formData},p=L=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",L.formData),$(L.formData),l.configJson=L.formData,l.restartRequired=!0,i({id:b.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:L.formData.name,formData:L.formData}}),c()};function u(L){const{id:P,label:M,onKeyChange:R,onDropPropertyClick:Z,disabled:pe,schema:ce,children:G,registry:f,readonly:ae,required:J}=L,{templates:D}=f,{RemoveButton:ve}=D.ButtonTemplates;if(!(pn in ce))return e.jsx(ie,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:G});const xe=({target:oe})=>R(oe&&oe.value);return e.jsxs(ie,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(me,{id:`${P}-key`,name:`${P}-key`,required:J,disabled:pe||ae,defaultValue:M,onBlur:ae?void 0:xe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(ie,{sx:{flex:1},children:G}),e.jsx(ve,{disabled:pe||ae,onClick:Z(M),registry:f})]})}function k(L){const{children:P,description:M,displayLabel:R,errors:Z,help:pe,hidden:ce,registry:G,uiSchema:f}=L,ae=cn(f),J=dn("WrapIfAdditionalTemplate",G,ae);return ce?e.jsx("div",{style:{display:"none"},children:P}):e.jsx(ie,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(J,{...L,children:[R===!0&&M,P,Z,pe]})})}function S(L){const{description:P}=L;return P?e.jsx(ue,{sx:Xe,children:P}):null}function j(L){const{required:P,title:M}=L;return M?e.jsx(ie,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ue,{sx:Ye,children:["Title ",M," ",P&&e.jsx("mark",{children:"***"})]})}):null}function Y(L){const{help:P}=L;return P?e.jsx(ie,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ue,{sx:In,children:P})}):null}function re(L){const{errors:P}=L;return P?e.jsxs(ie,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ue,{color:"error",sx:Mn,children:"Please fix the following errors:"}),e.jsx(lt,{children:P.map((M,R)=>e.jsxs(Kr,{children:[e.jsx(q,{children:e.jsx(Gr,{color:"error"})}),e.jsx(ee,{primary:M.stack})]},R))})]}):null}function v(L){const{errors:P}=L;return P?e.jsx(ie,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:P.map((M,R)=>e.jsxs(ue,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},R))}):null}function d(L){const{id:P,name:M,_schema:R,_uiSchema:Z,value:pe,options:ce,label:G,type:f,placeholder:ae,required:J,disabled:D,readonly:ve,autofocus:Te,onChange:xe,onChangeOverride:oe,onBlur:de,onFocus:Oe,_rawErrors:ke,_hideError:st,_registry:E,_formContext:je}=L,_=({target:{value:Le}})=>xe(Le===""?ce.emptyValue:Le),ne=({target:Le})=>de(P,Le&&Le.value),Pe=({target:Le})=>Oe(P,Le&&Le.value);return e.jsx(ie,{sx:{padding:"0px",margin:"0px"},children:e.jsx(me,{id:P,name:P,label:ae&&ae!==""?G:void 0,variant:"outlined",placeholder:ae&&ae!==""?ae:G,required:J,disabled:D||ve,autoFocus:Te,value:pe||pe===0?pe:"",type:f,autoComplete:f==="password"?"current-password":M,onChange:oe||_,onBlur:ne,onFocus:Pe,fullWidth:!0})})}function a(L){return console.log("ArrayFieldTitleTemplate:",L),null}function x(L){return console.log("ArrayFieldDescriptionTemplate:",L),null}function F(L){return console.log("ArrayFieldItemTemplate:",L),null}function N(L){const{canAdd:P,onAddClick:M,schema:R,title:Z}=L,[pe,ce]=r.useState(!1),[G,f]=r.useState(!1),[ae,J]=r.useState(!1),[D,ve]=r.useState(""),Te=E=>{ve(E.target.value)},xe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",D,"selectDevices:",et),ce(!pe)},oe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",D,"selectEntities:",Nt),f(!G)},de=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",D,"selectDevices:",et),J(!ae)},Oe=E=>{ce(!1),R.selectFrom==="serial"?R.items.default=E.serial:R.selectFrom==="name"&&(R.items.default=E.name),M()},ke=E=>{f(!1),R.selectEntityFrom==="name"?R.items.default=E.name:R.selectEntityFrom==="description"&&(R.items.default=E.description),M()},st=E=>{J(!1),R.selectDeviceEntityFrom==="name"?R.items.default=E.name:R.selectDeviceEntityFrom==="description"&&(R.items.default=E.description),M()};return e.jsxs(ie,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Z&&e.jsxs(ie,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Z&&e.jsx(ue,{sx:Ye,children:Z}),P&&e.jsxs(ie,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[R.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(Q,{onClick:xe,size:"small",color:"primary",sx:_e,children:e.jsx(mt,{})})}),R.selectEntityFrom&&e.jsx(H,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:oe,size:"small",color:"primary",sx:_e,children:e.jsx(mt,{})})}),R.selectDeviceEntityFrom&&e.jsx(H,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:de,size:"small",color:"primary",sx:_e,children:e.jsx(mt,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(Q,{onClick:M,size:"small",color:"primary",sx:_e,children:e.jsx(St,{})})})]})]}),R.description&&e.jsx(ue,{sx:Xe,children:R.description}),L.items.map(E=>e.jsxs(ie,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(ie,{sx:{flexGrow:1,marginRight:"10px"},children:E.children}),e.jsx(Q,{disabled:!E.hasMoveUp,onClick:E.onReorderClick(E.index,E.index-1),size:"small",color:"primary",sx:_e,children:e.jsx(Bt,{})}),e.jsx(Q,{disabled:!E.hasMoveDown,onClick:E.onReorderClick(E.index,E.index+1),size:"small",color:"primary",sx:_e,children:e.jsx(Ut,{})}),e.jsx(Q,{onClick:E.onDropIndexClick(E.index),size:"small",color:"primary",sx:_e,children:e.jsx(Ht,{})})]},E.index)),e.jsxs(He,{open:pe,onClose:xe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ve,{children:"Select a device"}),e.jsxs(Ee,{children:[e.jsxs(ie,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ue,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:D,onChange:Te,placeholder:"Enter serial or name"})]}),e.jsx(lt,{dense:!0,children:et.filter(E=>E.serial.toLowerCase().includes(D.toLowerCase())||E.name.toLowerCase().includes(D.toLowerCase())).map((E,je)=>e.jsxs(ht,{onClick:()=>Oe(E),sx:yt,children:[E.icon==="wifi"&&e.jsx(q,{children:e.jsx(ct,{style:Ce})}),E.icon==="ble"&&e.jsx(q,{children:e.jsx(ft,{style:Ce})}),E.icon==="hub"&&e.jsx(q,{children:e.jsx(xt,{style:Ce})}),e.jsx(ee,{primary:E.name,secondary:E.serial,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:Ct}})]},je))})]}),e.jsx(Ue,{children:e.jsx(le,{onClick:xe,children:"Close"})})]}),e.jsxs(He,{open:G,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ve,{children:"Select an entity"}),e.jsxs(Ee,{children:[e.jsxs(ie,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ue,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:D,onChange:Te,placeholder:"Enter name or description"})]}),e.jsx(lt,{dense:!0,children:Nt.filter(E=>E.name.toLowerCase().includes(D.toLowerCase())||E.description.toLowerCase().includes(D.toLowerCase())).map((E,je)=>e.jsxs(ht,{onClick:()=>ke(E),sx:yt,children:[E.icon==="wifi"&&e.jsx(q,{children:e.jsx(ct,{style:Ce})}),E.icon==="ble"&&e.jsx(q,{children:e.jsx(ft,{style:Ce})}),E.icon==="hub"&&e.jsx(q,{children:e.jsx(xt,{style:Ce})}),E.icon==="component"&&e.jsx(q,{children:e.jsx(Qt,{style:Ce})}),E.icon==="matter"&&e.jsx(q,{children:e.jsx(Kt,{style:Ce})}),e.jsx(ee,{primary:E.name,secondary:E.description,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:Ct}})]},je))})]}),e.jsx(Ue,{children:e.jsx(le,{onClick:oe,children:"Close"})})]}),e.jsxs(He,{open:ae,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ve,{children:["Select an entity for ",Z]}),e.jsx(Ee,{children:e.jsx(lt,{dense:!0,children:et.filter(E=>E.serial===Z||E.name===Z).map(E=>E.entities?.map((je,_)=>e.jsxs(ht,{onClick:()=>st(je),sx:yt,children:[je.icon==="wifi"&&e.jsx(q,{children:e.jsx(ct,{style:Ce})}),je.icon==="ble"&&e.jsx(q,{children:e.jsx(ft,{style:Ce})}),je.icon==="hub"&&e.jsx(q,{children:e.jsx(xt,{style:Ce})}),je.icon==="component"&&e.jsx(q,{children:e.jsx(Qt,{style:Ce})}),je.icon==="matter"&&e.jsx(q,{children:e.jsx(Kt,{style:Ce})}),e.jsx(ee,{primary:je.name,secondary:je.description,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:Ct}})]},_)))})}),e.jsx(Ue,{children:e.jsx(le,{onClick:de,children:"Close"})})]})]})}function te(L){const{onAddClick:P,schema:M,properties:R,title:Z,description:pe}=L,[ce,G]=r.useState(!1),[f,ae]=r.useState(""),J=oe=>{ae(oe.target.value)},D=()=>{G(!ce)},ve=oe=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${oe.serial}" for schema "${M.selectFrom}"`),G(!1);let de="";M.selectFrom==="serial"?de=oe.serial:M.selectFrom==="name"&&(de=oe.name),B(de),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${de}"`),P(M)()},Te=()=>{P(M)()},xe=!M.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${xe} newkey "${z}"`),!xe&&z!==""&&(o&&console.log("ObjectFieldTemplate: newkey",z,"properties",R),R.forEach(oe=>{if(oe.name==="newKey"&&oe.content.key==="newKey"&&oe.content.props.name==="newKey"&&oe.content.props.onKeyChange&&z!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",z);const de=z;B(""),oe.content.props.onKeyChange(de)}})),e.jsxs(ie,{sx:{margin:"0px",padding:xe?"10px":"5px 10px 0px 10px",border:xe?"none":"1px solid grey"},children:[M.title&&xe&&e.jsx(ie,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ue,{sx:Ye,children:M.title})}),Z&&!xe&&e.jsxs(ie,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ue,{sx:Ye,children:Z}),e.jsxs(ie,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(Q,{onClick:D,size:"small",color:"primary",sx:_e,children:e.jsx(mt,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(Q,{onClick:Te,size:"small",color:"primary",sx:_e,children:e.jsx(St,{})})})]})]}),M.description&&e.jsx(ie,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ue,{sx:Xe,children:M.description})}),R.map(({content:oe,name:de,hidden:Oe})=>!Oe&&e.jsxs(ie,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[de].type)?"0px":Dn,border:["object","array","boolean"].includes(M.properties[de].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[de].type)&&e.jsx(ue,{sx:Ye,children:de}),e.jsx(ie,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:oe})]},de)),e.jsxs(He,{open:ce,onClose:D,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ve,{children:"Select a device"}),e.jsxs(Ee,{children:[e.jsxs(ie,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ue,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:f,onChange:J,placeholder:"Enter serial or name"})]}),e.jsx(lt,{dense:!0,children:et.filter(oe=>oe.serial.toLowerCase().includes(f.toLowerCase())||oe.name.toLowerCase().includes(f.toLowerCase())).map((oe,de)=>e.jsxs(ht,{onClick:()=>ve(oe),sx:yt,children:[oe.icon==="wifi"&&e.jsx(q,{children:e.jsx(ct,{style:Ce})}),oe.icon==="ble"&&e.jsx(q,{children:e.jsx(ft,{style:Ce})}),oe.icon==="hub"&&e.jsx(q,{children:e.jsx(xt,{style:Ce})}),e.jsx(ee,{primary:oe.name,secondary:oe.serial,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:Ct}})]},de))})]}),e.jsx(Ue,{children:e.jsx(le,{onClick:D,children:"Close"})})]})]})}function fe(L){const{uiSchema:P}=L,{submitText:M,norender:R}=an(P);return R?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(le,{type:"submit",variant:"contained",color:"primary",children:M}),e.jsx(le,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function Se(L){const{className:P,disabled:M,onClick:R,registry:Z,style:pe,uiSchema:ce,...G}=L;return e.jsx(H,{title:"Remove the item",children:e.jsx(Q,{disabled:M,size:"small",color:"primary",onClick:R,children:e.jsx(Ht,{})})})}function O(L){const{className:P,disabled:M,onClick:R,registry:Z,uiSchema:pe,...ce}=L;return e.jsx(H,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:R,children:e.jsx(St,{})})})}function U(L){const{disabled:P,onClick:M,registry:R,style:Z,uiSchema:pe,...ce}=L;return e.jsx(H,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:M,children:e.jsx(Bt,{})})})}function T(L){const{disabled:P,onClick:M,registry:R,style:Z,uiSchema:pe,...ce}=L;return e.jsx(H,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:M,children:e.jsx(Ut,{})})})}function K(L){const{id:P,name:M,value:R,schema:Z,readonly:pe,onChange:ce}=L,[G,f]=r.useState(),ae=D=>{o&&console.log(`CheckboxWidget ${M} onChangeField:`,D),f(D&&D!==""?D:void 0)},J=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${M}" value="${G}"`),i({id:b.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:M,value:G,formData:A,id:P}}),Z.buttonClose===!0?c():Z.buttonSave===!0&&p({formData:t})};return Z.buttonText&&Z.description?e.jsxs(ie,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ue,{sx:Xe,children:Z.description}),e.jsx(le,{variant:"contained",color:"primary",onClick:()=>J(),children:Z.buttonText})]}):Z.buttonField&&Z.description?e.jsxs(ie,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ue,{sx:Xe,children:Z.description}),e.jsx(me,{id:M+"-input",name:M,label:Z.textLabel,placeholder:Z.textPlaceholder,onChange:D=>ae(D.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(le,{id:M+"-button",variant:"contained",color:"primary",disabled:G===void 0,onClick:()=>J(),children:Z.buttonField})]}):e.jsxs(ie,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(ie,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ue,{sx:Ye,children:M}),e.jsx(qe,{checked:R,readOnly:pe,onChange:()=>ce(!R),sx:{padding:"0px",margin:"0px"}})]}),Z.description&&e.jsx(ue,{sx:Xe,children:Z.description})]})}function W({schema:L,id:P,name:M,options:R,label:Z,hideLabel:pe,required:ce,disabled:G,placeholder:f,readonly:ae,value:J,multiple:D,autofocus:ve,onChange:Te,onBlur:xe,onFocus:oe,errorSchema:de,rawErrors:Oe=[],registry:ke,uiSchema:st,hideError:E,formContext:je,..._}){const{enumOptions:ne,enumDisabled:Pe,emptyValue:Le}=R;D=typeof D>"u"?!1:!!D;const At=D?[]:"",_t=typeof J>"u"||D&&J.length<1||!D&&J===At,Sr=({target:{value:Ae}})=>Te(Tt(Ae,ne,Le)),kr=({target:Ae})=>xe(P,Tt(Ae&&Ae.value,ne,Le)),Ir=({target:Ae})=>oe(P,Tt(Ae&&Ae.value,ne,Le)),qt=sn(J,ne,D),{InputLabelProps:Mr,SelectProps:Dr,autocomplete:Pr,...Lr}=_,$r=!D&&L.default===void 0;return e.jsxs(me,{id:P,name:P,value:!_t&&typeof qt<"u"?qt:At,required:ce,disabled:G||ae,autoFocus:ve,autoComplete:Pr,placeholder:f,error:Oe.length>0,onChange:Sr,onBlur:kr,onFocus:Ir,...Lr,select:!0,InputLabelProps:{...Mr,shrink:!_t},SelectProps:{...Dr,multiple:D},"aria-describedby":ln(P),children:[$r&&e.jsx(w,{value:"",children:f}),Array.isArray(ne)&&ne.map(({value:Ae,label:Wr},zt)=>{const Fr=Array.isArray(Pe)&&Pe.indexOf(Ae)!==-1;return e.jsx(w,{value:String(zt),disabled:Fr,children:Wr},zt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(He,{open:n,onClose:c,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Ve,{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(Ee,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(on,{schema:y,formData:t,uiSchema:C,validator:nn,templates:{FieldTemplate:k,BaseInputTemplate:d,TitleFieldTemplate:j,DescriptionFieldTemplate:S,FieldHelpTemplate:Y,FieldErrorTemplate:v,ErrorListTemplate:re,WrapIfAdditionalTemplate:u,ArrayFieldTitleTemplate:a,ArrayFieldDescriptionTemplate:x,ArrayFieldItemTemplate:F,ArrayFieldTemplate:N,ObjectFieldTemplate:te,ButtonTemplates:{SubmitButton:fe,RemoveButton:Se,AddButton:O,MoveUpButton:U,MoveDownButton:T}},widgets:{CheckboxWidget:K,SelectWidget:W},onChange:h,onSubmit:p})})]})};function yr(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 c=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(c===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function Ln({storeId:n,setStoreId:c}){const{online:l,sendMessage:i,addListener:s,removeListener:m,getUniqueId:g}=r.useContext(he),{showConfirmCancelDialog:b}=r.useContext(De),t=r.useRef(g()),[$,y]=r.useState(null),[I,C]=r.useState(null),[V,z]=r.useState([]),B=[{label:"Name",id:"name",required:!0,render:(T,K,W,L)=>e.jsx(H,{title:`Plugin path ${W.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>v(W),children:W.name})})},{label:"Description",id:"description",render:(T,K,W,L)=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>v(W),children:W.description})})},{label:"Version",id:"version",render:(T,K,W,L)=>e.jsx(e.Fragment,{children:e.jsx(H,{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:(T,K,W,L)=>e.jsx(e.Fragment,{children:W.author?W.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(T,K,W,L)=>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:(T,K,W,L)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[I&&I.bridgeMode==="childbridge"&&!W.error&&W.enabled&&e.jsx(H,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:yr(W.matter)},onClick:()=>{W.matter?.id&&c(W.matter?.id)},size:"small",children:e.jsx(pr,{})})}),I&&I.bridgeMode==="childbridge"&&!W.error&&W.enabled&&e.jsx(H,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>Y(W),size:"small",children:e.jsx(kt,{})})}),e.jsx(H,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{disabled:W.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Se(W),size:"small",children:e.jsx(Jr,{})})}),I&&!I.readOnly&&e.jsx(H,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{h("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",W)},size:"small",children:e.jsx(dr,{})})}),W.enabled?e.jsx(H,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{h("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",W)},size:"small",children:e.jsx(Zr,{})})}):e.jsx(e.Fragment,{}),W.enabled?e.jsx(e.Fragment,{}):e.jsx(H,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>re(W),size:"small",children:e.jsx(Yr,{})})}),e.jsx(H,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>a(W),size:"small",children:e.jsx(ur,{})})}),e.jsx(H,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>x(W),size:"small",children:e.jsx(Vt,{})})}),W.latestVersion!==void 0&&W.latestVersion!==W.version&&I&&!I.readOnly&&e.jsx(H,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>k(W),size:"small",children:e.jsx(Ne,{})})}),W.version.includes("-dev-")&&W.devVersion!==void 0&&W.devVersion!==W.version&&I&&!I.readOnly&&e.jsx(H,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--secondary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>S(W),size:"small",children:e.jsx(Ne,{})})}),I&&!I.readOnly&&e.jsx(H,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>d(W),size:"small",children:e.jsx(Et,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(T,K,W,L)=>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(Ze,{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(Ze,{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(Ze,{status:W.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{status:W.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ze,{status:W.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ze,{status:W.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const T=K=>{o&&console.log("HomePlugins received WebSocket Message:",K),K.method==="refresh_required"&&K.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):K.method==="refresh_required"&&K.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and setting matter id ${K.response.matter?.id}`),z(W=>{const L=W.findIndex(M=>M.matter?.id===K.response.matter?.id);if(L<0)return o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and matter id ${K.response.matter?.id} not found`),W;o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} set matter id ${K.response.matter?.id}`);const P=[...W];return P[L]={...P[L],matter:K.response.matter},P})):K.method==="refresh_required"&&K.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),K.id===t.current&&K.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${K.id}) received settings:`,K.response),y(K.response.systemInformation),C(K.response.matterbridgeInformation)):K.id===t.current&&K.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${K.id}) received ${K.response.length} plugins:`,K.response),z(K.response))};return s(T,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{m(T),o&&console.log("HomePlugins removed WebSocket listener")}},[s,m,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 A=r.useRef(null),h=(T,K,W,L)=>{o&&console.log(`handleActionWithConfirmCancel ${W} ${L.name}`),A.current=L,b(T,K,W,p,u)},p=T=>{o&&console.log(`handleConfirm action confirmed ${T} ${A.current?.name}`),T==="remove"&&A.current?j(A.current):T==="disable"&&A.current&&re(A.current),A.current=null},u=T=>{o&&console.log(`handleCancel action canceled ${T} ${A.current?.name}`),A.current=null},k=T=>{o&&console.log("handleUpdatePlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:T.name,restart:!1}})},S=T=>{o&&console.log("handleUpdateDevPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:T.name+"@dev",restart:!1}})},j=T=>{o&&console.log("handleRemovePlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})},Y=T=>{o&&console.log("handleRestartPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})},re=T=>{o&&console.log("handleEnableDisablePlugin plugin:",T.name,"enabled:",T.enabled),T.enabled===!0?(T.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})):(T.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}}))},v=T=>{o&&console.log(`handleHomepagePlugin plugin: ${T.name} homepage: ${T.homepage}`),T.homepage&&window.open(T.homepage,"_blank")},d=T=>{o&&console.log("handleSponsorPlugin plugin:",T.name,"funding:",T.funding),T.funding&&window.open(T.funding,"_blank")},a=T=>{o&&console.log("handleHelpPlugin plugin:",T.name,"help:",T.help),T.help&&window.open(T.help,"_blank")},x=T=>{o&&console.log("handleChangelogPlugin plugin:",T.name,"changelog:",T.changelog),T.changelog&&window.open(T.changelog,"_blank")},[F,N]=r.useState(),[te,fe]=r.useState(!1),Se=T=>{o&&console.log("handleConfigPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:T.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:T.name}}),N(T),O()},O=()=>{fe(!0)},U=()=>{fe(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(be,{children:[F&&e.jsx(Pn,{open:te,onClose:U,plugin:F}),e.jsx(Lt,{name:"Plugins",columns:B,rows:V,footerRight:"",footerLeft:""})]}):e.jsx(Re,{})}const $n=r.memo(Ln),Wn=n=>`${n.pluginName}::${n.serial}`;function Fn({storeId:n,setStoreId:c}){const{online:l,sendMessage:i,addListener:s,removeListener:m,getUniqueId:g}=r.useContext(he),[b,t]=r.useState(!1),[$,y]=r.useState(!0),[I,C]=r.useState(null),[V,z]=r.useState([]),[B,A]=r.useState([]),[h,p]=r.useState([]),[u,k]=r.useState([]),S=r.useRef(g()),j=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(v,d,a,x)=>a.reachable===!0?"Online":a.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(v,d)=>{const a=v.reachable===!0?1:v.reachable===!1?0:-1,x=d.reachable===!0?1:d.reachable===!1?0:-1;return a-x}},{label:"Power",id:"powerSource",render:(v,d,a,x)=>a.powerSource==="ac"||a.powerSource==="dc"?e.jsx(gr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):a.powerSource==="ok"?e.jsx(It,{fontSize:"small",sx:{color:"green"}}):a.powerSource==="warning"?e.jsx(It,{fontSize:"small",sx:{color:"yellow"}}):a.powerSource==="critical"?e.jsx(It,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(v,d,a,x)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[a.matter!==void 0?e.jsx(H,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>c(n===a.matter?.id?I?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:a.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:yr(a.matter)},children:e.jsx(pr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),a.configUrl?e.jsx(H,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(a.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(mr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),a.selected!==void 0?e.jsx(H,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(qe,{checked:a.selected,onChange:F=>re(F,a),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],Y=r.useCallback(v=>{v.selected=void 0;const d=V.find(F=>F.name===v.pluginName);if(!d)return console.error(`HomeDevices isSelected: plugin ${v.pluginName} not found for device ${v.name} `),v.selected;const a=d.schemaJson?.properties?.whiteList?.selectFrom;let x=d.configJson.postfix;return x===""&&(x=void 0),d.hasWhiteList===!0&&d.hasBlackList===!0&&a&&(v.selected=!0,a==="serial"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&d.configJson.whiteList.includes(x?v.serial.replace("-"+x,""):v.serial)&&(v.selected=!0),a==="serial"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&!d.configJson.whiteList.includes(x?v.serial.replace("-"+x,""):v.serial)&&(v.selected=!1),a==="serial"&&d.configJson.blackList&&d.configJson.blackList.length>0&&d.configJson.blackList.includes(x?v.serial.replace("-"+x,""):v.serial)&&(v.selected=!1),a==="name"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&d.configJson.whiteList.includes(v.name)&&(v.selected=!0),a==="name"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&!d.configJson.whiteList.includes(v.name)&&(v.selected=!1),a==="name"&&d.configJson.blackList&&d.configJson.blackList.length>0&&d.configJson.blackList.includes(v.name)&&(v.selected=!1)),v.selected},[V]);r.useEffect(()=>{const v=d=>{if(o&&console.log("HomeDevices received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and sending /api/plugins request`),i({id:S.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):d.method==="refresh_required"&&d.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and setting matter id ${d.response.matter?.id}`),k(a=>{const x=a.findIndex(N=>N.name.replaceAll(" ","")===d.response.matter?.id);if(x<0)return o&&console.debug(`HomeDevices: matter id ${d.response.matter?.id} not found`),a;const F=[...a];return F[x]={...F[x],matter:d.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and set matter id ${d.response.matter?.id}`),F})):d.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):d.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):d.method==="state_update"&&d.response.plugin&&d.response.serialNumber&&d.response.cluster.includes("BasicInformation")&&d.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${d.response.plugin} serial ${d.response.serialNumber} value ${d.response.value}`),A(a=>{const x=a.findIndex(F=>F.pluginName===d.response.plugin&&F.serial===d.response.serialNumber);return x<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${d.response.plugin} serial ${d.response.serialNumber}`),a):(a[x]={...a[x],reachable:d.response.value},[...a])})),d.id===S.current&&d.method==="/api/settings")o&&console.log(`HomeDevices (id: ${d.id}) received settings:`,d.response),C(d.response),t(d.response.matterbridgeInformation.restartRequired||d.response.matterbridgeInformation.fixedRestartRequired);else if(d.id===S.current&&d.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} plugins:`,d.response),d.response){let a=!0;for(const x of d.response)x.enabled===!0&&(x.loaded!==!0||x.started!==!0||x.error===!0)&&(a=!1);if(!a)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),z(d.response),A([]),p([]),i({id:S.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const x of d.response)x.enabled===!0&&x.loaded===!0&&x.started===!0&&x.error!==!0&&(i({id:S.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:x.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${x.name}`))}}else if(d.id===S.current&&d.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} devices:`,d.response),d.response){for(const a of d.response)a.selected=Y(a);A(d.response)}}else d.id===S.current&&d.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} selectDevices for plugin ${d.response&&d.response.length>0?d.response[0].pluginName:"without select devices"}:`,d.response),d.response&&d.response.length>0&&p(a=>{const x=a.filter(N=>N.pluginName!==d.response[0].pluginName),F=d.response.map(N=>({...N,selected:Y(N)}));return[...x,...F]}))};return s(v,S.current),o&&console.log(`HomeDevices added WebSocket listener id ${S.current}`),()=>{m(v),o&&console.log("HomeDevices removed WebSocket listener")}},[V,s,m,i,Y]),r.useEffect(()=>{if(B.length===0&&h.length===0){k([]);return}o&&console.log(`HomeDevices mixing devices (${B.length}) and selectDevices (${h.length})`);const v=[];for(const d of B)v.push(d);for(const d of h)B.find(a=>a.pluginName===d.pluginName&&a.serial.includes(d.serial))||v.push(d);v.length>0&&(k(v),o&&console.log(`HomeDevices mixed ${v.length} devices and selectDevices`))},[V,B,h,k]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:S.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:S.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const re=(v,d)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${v.target.checked} for device ${d.name} serial ${d.serial}`),B.findIndex(a=>a.pluginName===d.pluginName&&a.serial===d.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in devices, trying in mixedDevices`),k(a=>{const x=a.findIndex(F=>F.pluginName===d.pluginName&&F.serial===d.serial);return x<0?(console.error(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in mixedDevices`),a):(a[x]={...a[x],selected:v.target.checked},[...a])})):A(a=>{const x=a.findIndex(F=>F.pluginName===d.pluginName&&F.serial===d.serial);return x<0?(console.error(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in devices`),a):(a[x]={...a[x],selected:v.target.checked},[...a])}),v.target.checked?i({id:S.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:d.pluginName,serial:d.serial,name:d.name}}):i({id:S.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:d.pluginName,serial:d.serial,name:d.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(be,{style:{flex:"1 1 auto"},children:e.jsx(Lt,{name:"Devices",getRowKey:Wn,rows:u,columns:j,footerLeft:$?"Waiting for the plugins to fully load...":`Registered devices: ${B.length.toString()}/${u.length.toString()}`,footerRight:b?"Restart required":""})}):e.jsx(Re,{})}const Tn=r.memo(Fn);function ut({children:n,style:c,name:l}){const{setCurrentPage:i}=r.useContext(De);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const s={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...s,...c},children:n})}const Nn=()=>"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 Rn(){const{messages:n,logAutoScroll:c}=r.useContext(br),[l,i]=r.useState(!1),s=r.useRef(null),m=r.useRef(0),g=r.useRef(null),b=r.useMemo(()=>Nn(),[]),t=C=>i(!0),$=C=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${c.current} isHovering: ${l}`),c.current&&!l&&!b){const C=Date.now();C-m.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),m.current=C,s.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{s.current?.scrollIntoView({behavior:"smooth"}),m.current=Date.now()},1e3))}},[n,c,l,b]);const y=C=>{switch(C.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},I=C=>{switch(C.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:$,children:[n.map((C,V)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:y(C.level),color:I(C.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:C.level}),C.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+C.time+"]"}),C.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+C.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:C.message})]},V)),e.jsx("div",{ref:s})]})})}const jr=r.memo(Rn);function On(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),{online:s,logAutoScroll:m}=r.useContext(he);return o&&console.log("HomeLogs rendering..."),s?e.jsxs(be,{style:{flex:"1 1 auto"},children:[e.jsxs(Ie,{children:[e.jsx(ye,{children:"Logs"}),e.jsxs(ye,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l===""?"*":l,'" Scroll: ',m.current?"auto":"manual"]})]}),e.jsx(Fe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(jr,{})})]}):e.jsx(Re,{})}const Hn=r.memo(On);function Vn(){const{online:n}=r.useContext(he);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(be,{children:[e.jsx(Ie,{children:e.jsx(ye,{children:"Frontend Update"})}),e.jsxs(Fe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(le,{onClick:()=>window.location.reload(),endIcon:e.jsx(Xr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Re,{})}const En=r.memo(Vn);function An({changelog:n}){const{online:c}=r.useContext(he);return o&&console.log("HomeShowChangelog rendering..."),c?e.jsxs(be,{children:[e.jsx(Ie,{children:e.jsx(ye,{children:"Matterbridge Update"})}),e.jsxs(Fe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(le,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(hr,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(le,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(Et,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(le,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Vt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(le,{onClick:()=>window.location.reload(),endIcon:e.jsx(eo,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Re,{})}const _n=r.memo(An);function qn({matterbridgeInfo:n}){const{mobile:c}=r.useContext(De);o&&console.log("MatterbridgeInfoTable:",n);const l=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,s]=r.useState(!1);return!n||i?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(be,{style:ge&&c?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ie,{children:[e.jsx(ye,{children:"Matterbridge info"}),e.jsx(Ke,{onClose:()=>s(!0)})]}),e.jsx(Fe,{style:ge&&c?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([m,g])=>!l.includes(m)&&g!==null&&g!==void 0&&g!=="").map(([m,g],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:m.replace("matterbridgeVersion","Matterbridge version").replace("matterbridgeLatestVersion","Matterbridge latest v.").replace("matterbridgeDevVersion","Matterbridge dev v.").replace("frontendVersion","Frontend version").replace("homeDirectory","Home").replace("rootDirectory","Root").replace("matterbridgeDirectory","Storage").replace("matterbridgeCertDirectory","Cert").replace("matterbridgePluginDirectory","Plugins").replace("globalModulesDirectory","Modules").replace("bridgeMode","Bridge mode").replace("restartMode","Restart mode").replace("virtualMode","Virtual mode").replace("profile","Profile").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("matterLoggerLevel","Matter logger level").replace("matterFileLogger","Matter file logger").replace("restartRequired","Restart required").replace("updateRequired","Update required")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ge&&c?typeof g!="string"?g.toString():g:e.jsx(vr,{value:typeof g!="string"?g.toString():g,maxChars:24})})]},m))})]})})]}))}const zn=r.memo(qn);function Un(){const[n,c]=r.useState(null),[l,i]=r.useState(null),[s,m]=r.useState([]),[g]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[b,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[$,y]=r.useState(""),[I,C]=r.useState(!1),[V,z]=r.useState(!1),[B,A]=r.useState(null),{mobile:h}=r.useContext(De),{addListener:p,removeListener:u,online:k,sendMessage:S,getUniqueId:j}=r.useContext(he),Y=r.useRef(j());return r.useEffect(()=>{const re=v=>{o&&console.log("Home received WebSocket Message:",v),v.method==="refresh_required"&&v.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${v.response.changed} and sending /api/settings request`),A(null),m([]),S({id:Y.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:Y.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),v.method==="/api/settings"&&v.id===Y.current&&(o&&console.log("Home received settings:",v.response),c(v.response.systemInformation),i(v.response.matterbridgeInformation),v.response.matterbridgeInformation.matterbridgeVersion&&y(`https://github.com/Luligu/matterbridge/blob/${v.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&v.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",v.response.matterbridgeInformation.frontendVersion):v.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&v.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",v.response.matterbridgeInformation.frontendVersion),z(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",v.response.matterbridgeInformation.matterbridgeVersion):v.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",v.response.matterbridgeInformation.matterbridgeVersion),C(!0)),v.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),v.method==="/api/plugins"&&v.id===Y.current&&(o&&console.log("Home received plugins:",v.response),m(v.response))};return p(re,Y.current),o&&console.log(`Home added WebSocket listener id ${Y.current}`),()=>{u(re),o&&console.log("Home removed WebSocket listener")}},[p,u,S]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${B}`),l?.bridgeMode==="bridge"&&!B&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),A("Matterbridge")),l?.bridgeMode==="childbridge"&&!B&&s){for(const re of s)if(re.matter?.id){o&&console.log(`Home storeId effect set storeId to ${re.matter.id}`),A(re.matter.id);break}}},[l,s,B]),r.useEffect(()=>{k&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),S({id:Y.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:Y.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[k,S]),o&&console.log("Home rendering..."),!k||!n||!l?e.jsx(Re,{}):e.jsxs(ut,{name:"Home",style:ge&&h?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(ge&&!h||!ge)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(or,{id:B}),e.jsx(tr,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:ge&&h?"10px":"20px"},children:[V&&e.jsx(En,{}),I&&e.jsx(_n,{changelog:$}),ge&&h&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(or,{id:B}),e.jsx(tr,{systemInfo:n,compact:!0}),e.jsx(zn,{matterbridgeInfo:l})]}),g&&!l.readOnly&&e.jsx(jn,{}),g&&e.jsx($n,{storeId:B,setStoreId:A}),b==="devices"&&e.jsx(Tn,{storeId:B,setStoreId:A}),b==="logs"&&e.jsx(Hn,{})]})]})}const Bn=r.memo(Un),wt=!1,ir={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Qn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Kn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},sr={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Gn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Jn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Zn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Yn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Xn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Rt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},ei=[256,257,268,269],ti=[266,267],ri=[259,260,261,271,272],oi=[256,257,268,269,266,267,259,260,261,272];function X({icon:n,iconColor:c,cluster:l,value:i,unit:s,prefix:m}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),m=m??!1,e.jsxs(ie,{sx:ir,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Qn,color:c??"var(--primary-color)"}}),e.jsxs(ie,{sx:{...ir,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&m===!0&&e.jsx(ue,{sx:sr,children:s},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(ue,{sx:Kn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),s&&m===!1&&e.jsx(ue,{sx:sr,children:s},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function ni({device:n,endpoint:c,id:l,deviceType:i,clusters:s}){const m=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";o&&console.log(`Device "${n.name}" endpoint "${c}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const b=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(b){let t="";b.map($=>{$.label&&(t+=$.label+" ")}),g=t.trim()}if(i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>g=`${t.attributeLocalValue} mV`),oi.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>g=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>g=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>g=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>g=g+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>g=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>g=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>g=g+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>g=g+`${t.attributeLocalValue/1e3} W`),i===39){const t=s.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="currentMode")?.attributeLocalValue;g=s.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}if(i===116){const t=s.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="currentMode")?.attributeLocalValue;g=s.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}return e.jsxs(be,{style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:t.attributeLocalValue===!0?e.jsx(ct,{}):e.jsx(to,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(X,{icon:e.jsx(It,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(X,{icon:e.jsx(gr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),ei.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),ti.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),ri.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(se,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(se,{path:qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:e.jsx(Gt,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:e.jsx(oo,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(X,{icon:e.jsx(se,{path:zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(Gt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Xt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Xt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(X,{icon:e.jsx(no,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(X,{icon:t.attributeValue==="1"?e.jsx(io,{}):e.jsx(so,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(X,{icon:e.jsx(lo,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(X,{icon:e.jsx(ao,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(co,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(X,{icon:e.jsx(Jt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(X,{icon:e.jsx(Jt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:e.jsx(po,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:e.jsx(uo,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:e.jsx(go,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&s.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(X,{icon:e.jsx(se,{path:Xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(X,{icon:e.jsx(se,{path:er,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(X,{icon:e.jsx(se,{path:er,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(X,{icon:e.jsx(mo,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(X,{icon:e.jsx(se,{path:en,size:"40px",color:"var(--primary-color)"}),cluster:t,value:m[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(ho,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(se,{path:tn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(fo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(xo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:t.attributeValue==="true"?e.jsx(bo,{}):e.jsx(vo,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(X,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(yo,{}):e.jsx(jo,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(Co,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(X,{icon:e.jsx(wo,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(ie,{sx:Gn,children:e.jsx(ue,{sx:Jn,children:g})}),e.jsx(ie,{sx:Zn,children:e.jsx(ue,{sx:Yn,children:n.name})}),e.jsxs(ie,{sx:Xn,children:[o&&e.jsx(ue,{sx:Rt,children:c}),e.jsx(ue,{sx:Rt,children:l}),o&&e.jsxs(ue,{sx:Rt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function ii({filter:n}){const{online:c,sendMessage:l,addListener:i,removeListener:s,getUniqueId:m}=r.useContext(he),[g,b]=r.useState([]),[t,$]=r.useState({}),[y,I]=r.useState({}),[C,V]=r.useState({}),z=r.useRef(m()),B=r.useCallback(p=>{(o||wt)&&console.log(`DevicesIcons received state_update "${p.response.cluster}.${p.response.attribute}" for "${p.response.id}:${p.response.number}": "${p.response.value}"`,p.response);const u=g.find(S=>S.pluginName===p.response.plugin&&S.serial===p.response.serialNumber);if(!u){(o||wt)&&console.warn(`DevicesIcons updater device of plugin "${p.response.plugin}" serial "${p.response.serialNumber}" number "${p.response.number}" id "${p.response.id}" not found in devices(${g.length})`);return}const k=C[u.serial]?.find(S=>S.endpoint===p.response.number.toString()&&S.clusterName===p.response.cluster&&S.attributeName===p.response.attribute);if(!k){(o||wt)&&console.warn(`DevicesIcons updater device "${u.name}" serial "${u.serial}" cluster "${p.response.cluster}" attribute "${p.response.attribute}" not found in clusters(${C[u.serial]?.length})`);return}k.attributeValue=String(p.response.value),k.attributeLocalValue=p.response.value,V({...C}),(o||wt)&&console.log(`DevicesIcons updated "${k.clusterName}.${k.attributeName}" for device "${u.name}" serial "${u.serial}" to "${k.attributeValue}"`)},[C,g]),A=r.useCallback(p=>{if(o&&console.log(`DevicesIcons received for device "${p.response.deviceName}" serial "${p.response.serialNumber}" deviceTypes (${p.response.deviceTypes.length}) "${p.response.deviceTypes.join(",")}" clusters (${p.response.clusters.length}):`,p.response),p.response.clusters.length===0)return;const u=p.response.serialNumber;t[u]=[],y[u]=p.response.deviceTypes,C[u]=[];for(const k of p.response.clusters)t[u].find(S=>S.endpoint===k.endpoint)||t[u].push({endpoint:k.endpoint,id:k.id,deviceTypes:k.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(k.clusterName)&&C[u].push(k);$({...t}),I({...y}),V({...C}),o&&console.log(`DevicesIcons endpoints for "${u}":`,t[u]),o&&console.log(`DevicesIcons deviceTypes for "${u}":`,y[u]),o&&console.log(`DevicesIcons clusters for "${u}":`,C[u])},[C,y,t]);r.useEffect(()=>{const p=u=>{if(o&&console.log("DevicesIcons received WebSocket Message:",u),u.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${u.response.changed} and sending api requests`),l({id:z.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)B(u);else if(u.method==="/api/devices"&&u.response){o&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),b(u.response),$({}),I({}),V({});for(const k of u.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:z.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:k.pluginName,endpoint:k.endpoint||0}})}else u.method==="/api/clusters"&&u.response&&A(u)};return i(p,z.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{s(p),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[g]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),c&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:z.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")}),[c,l]);const h=r.memo(ni);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:g.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n)).map(p=>t[p.serial]&&t[p.serial].map(u=>u.deviceTypes.map(k=>e.jsx(h,{device:p,endpoint:u.endpoint,id:u.id,deviceType:k,clusters:C[p.serial].filter(S=>S.endpoint===u.endpoint)},`${p.pluginName}-${p.uniqueId}-${u.endpoint}-${u.id}-${k.toString()}`))))})}const si=r.memo(ii),li=[{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,c,l,i)=>l.configUrl?e.jsx(Q,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(mr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],ai=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,c,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,maxWidth:400,tooltip:!0}],ci=n=>`${n.pluginName}::${n.uniqueId}`,di=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function pi({filter:n}){const{online:c,sendMessage:l,addListener:i,removeListener:s,getUniqueId:m}=r.useContext(he),[g,b]=r.useState([]),[t,$]=r.useState(g),[y,I]=r.useState([]),[C,V]=r.useState(0),[z,B]=r.useState(null),[A,h]=r.useState(null),[p,u]=r.useState(null),[k,S]=r.useState(null),j=r.useRef(m()),Y=r.useRef(t),re=r.useCallback(d=>{o&&console.log(`DevicesTable received state_update "${d.response.cluster}.${d.response.attribute}" for "${d.response.id}:${d.response.number}": "${d.response.value}"`,d.response);const a=Y.current.find(x=>x.pluginName===d.response.plugin&&x.uniqueId===d.response.uniqueId);if(!a){o&&console.warn(`DevicesTable updater device of plugin "${d.response.plugin}" serial "${d.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(z&&A&&a.pluginName===z&&a.uniqueId===k&&d.response.number.toString()===A){const x=y.find(F=>F.endpoint===d.response.number.toString()&&F.clusterName===d.response.cluster&&F.attributeName===d.response.attribute);if(!x){o&&console.warn(`DevicesTable updater cluster ${d.response.cluster}.${d.response.attribute} for device "${a.name}" serial "${a.serial}" not found in clusters`);return}x.attributeValue=typeof d.response.value=="object"?JSON.stringify(d.response.value,void 0,1).replaceAll('"',""):String(d.response.value),x.attributeLocalValue=d.response.value,I([...y]),o&&console.log(`DevicesTable updated attribute ${x.clusterName}.${x.attributeName} for device "${a.name}" serial "${a.serial}" to "${x.attributeValue}"`)}},[y,A,z,k]);r.useEffect(()=>{const d=a=>{if(o&&console.log("DevicesTable received WebSocket Message:",a),a.method==="refresh_required"&&a.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${a.response.changed} and sending /api/devices request`),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(a.method==="state_update"&&a.response)re(a);else if(a.method==="/api/devices")o&&console.log(`DevicesTable received ${a.response.length} devices:`,a.response),b(a.response);else if(a.method==="/api/clusters"){o&&console.log(`DevicesTable received ${a.response.clusters.length} clusters for plugin ${a.response.plugin}:`,a.response),I(a.response.clusters);const x={};for(const F of a.response.clusters)o&&console.log("Cluster:",F.endpoint),x[F.endpoint]?x[F.endpoint]++:x[F.endpoint]=1;V(Object.keys(x).length)}};return i(d,j.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{s(d),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,s,re]),r.useEffect(()=>{c&&(o&&console.log("DevicesTable sending api requests with id ",j.current),l({id:j.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,l]),r.useEffect(()=>{z&&A&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:j.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:z,endpoint:Number(A)}}))},[z,A,l]),r.useEffect(()=>{if(n===""){$(g),Y.current=g;return}const d=g.filter(a=>a.name.toLowerCase().includes(n)||a.serial.toLowerCase().includes(n));$(d),Y.current=d},[g,n]);const v=d=>{if(d.uniqueId===k){S(null),B(null),h(null),u(null);return}S(d.uniqueId),B(d.pluginName),h(d.endpoint?d.endpoint.toString():null),u(d.name)};return o&&console.log("DevicesTable rendering..."),c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx(be,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${z&&A?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Lt,{name:"Registered devices",getRowKey:ci,onRowClick:v,rows:t,columns:li,footerLeft:`Total devices: ${t.length.toString()}`})}),z&&A&&e.jsx(be,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Lt,{name:"Clusters",title:p||"",getRowKey:di,rows:y,columns:ai,footerLeft:`Total child endpoints: ${C-1}`})})]}):e.jsx(Re,{})}const ui=r.memo(pi);function gi(){const{online:n}=r.useContext(he),[c,l]=r.useState(""),[i,s]=r.useState("icon");r.useEffect(()=>{const b=localStorage.getItem("devicesFilter");b&&l(b)},[]),r.useEffect(()=>{const b=localStorage.getItem("devicesViewMode");b&&s(b)},[]);const m=b=>{l(b.target.value.toLowerCase()),localStorage.setItem("devicesFilter",b.target.value.toLowerCase())},g=b=>{s(b),localStorage.setItem("devicesViewMode",b)};return o&&console.log("Devices rendering..."),n?e.jsxs(ut,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(ie,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ue,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{variant:"outlined",value:c,onChange:m,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(ie,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ue,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(Q,{onClick:()=>g("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(H,{title:"Table View",children:e.jsx(So,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(H,{title:"Icon View (beta)",children:e.jsx(ko,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(ui,{filter:c}),i==="icon"&&e.jsx(si,{filter:c})]}):e.jsx(Re,{})}const mi=r.memo(gi);function hi(){const{logLength:n,logAutoScroll:c,setMessages:l,setLogFilterLevel:i,setLogFilterSearch:s,online:m,filterLogMessages:g}=r.useContext(he),[b,t]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[$,y]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[I,C]=r.useState(n.current.toString()),[V,z]=r.useState(c.current),B=k=>{const S=k.target.value;t(S),i(S),g(S,$),localStorage.setItem("logFilterLevel",S),o&&console.log("handleLogFilterLevelChange called with value:",S)},A=k=>{const S=k.target.value;y(S),s(S),g(b,S),localStorage.setItem("logFilterSearch",S),o&&console.log("handleLogFilterSearchChange called with value:",S)},h=k=>{const S=k.target.checked;z(S),c.current=S,g(b,$),localStorage.setItem("logAutoScroll",S?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",S)},p=k=>{const S=k.target.value;C(S),n.current=Number(S),localStorage.setItem("logLength",S),o&&console.log("handleLogLengthChange called with value:",S)},u=()=>{o&&console.log("handleClearLogsClick called"),l([])};return o&&console.log("Logs rendering..."),m?e.jsxs(ut,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Wt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Qe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:b,onChange:B,children:[e.jsx(w,{value:"debug",children:"Debug"}),e.jsx(w,{value:"info",children:"Info"}),e.jsx(w,{value:"notice",children:"Notice"}),e.jsx(w,{value:"warn",children:"Warn"}),e.jsx(w,{value:"error",children:"Error"}),e.jsx(w,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Wt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(H,{title:"Use /text/ for case-insensitive regex search",children:e.jsx(me,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:$,onChange:A,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(Ge,{control:e.jsx(qe,{checked:V,onChange:h}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(Wt,{id:"select-size-label",style:{color:"var(--div-text-color)"},children:"Log length:"}),e.jsxs(Qe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-size-label",id:"select-size",value:I,onChange:p,children:[e.jsx(w,{value:100,children:"100"}),e.jsx(w,{value:200,children:"200"}),e.jsx(w,{value:500,children:"500"}),e.jsx(w,{value:1e3,children:"1000"})]}),e.jsx(H,{title:"Clear the logs",children:e.jsx(le,{onClick:u,endIcon:e.jsx(Ht,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})]})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(jr,{})})]}):e.jsx(Re,{})}const fi=r.memo(hi),xi=({open:n,ip:c,onClose:l,onSave:i})=>{const s=c?c.split(".").slice(0,3).join(".")+".1":"",[m,g]=r.useState("dhcp"),[b,t]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:s,dns:s}),$=C=>V=>{t({...b,[C]:V.target.value})},y=()=>{l()},I=()=>{i({type:m,...b}),l()};return e.jsxs(He,{open:n,onClose:(C,V)=>{V==="backdropClick"||V==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ve,{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(Ee,{dividers:!0,children:[e.jsxs(fr,{component:"fieldset",fullWidth:!0,children:[e.jsx(we,{component:"legend",children:"Select IP Configuration"}),e.jsxs(xr,{row:!0,value:m,onChange:C=>g(C.target.value),children:[e.jsx(Ge,{value:"dhcp",control:e.jsx(Pt,{}),label:"DHCP"}),e.jsx(Ge,{value:"static",control:e.jsx(Pt,{}),label:"Static"})]})]}),m==="static"&&e.jsxs(ze,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(ze,{size:6,children:e.jsx(me,{label:"IP Address",fullWidth:!0,value:b.ip,onChange:$("ip")})}),e.jsx(ze,{size:6,children:e.jsx(me,{label:"Subnet Mask",fullWidth:!0,value:b.subnet,onChange:$("subnet")})}),e.jsx(ze,{size:6,children:e.jsx(me,{label:"Gateway",fullWidth:!0,value:b.gateway,onChange:$("gateway")})}),e.jsx(ze,{size:6,children:e.jsx(me,{label:"DNS Server",fullWidth:!0,value:b.dns,onChange:$("dns")})})]})]}),e.jsxs(Ue,{children:[e.jsx(le,{onClick:y,children:"Cancel"}),e.jsx(le,{variant:"contained",onClick:I,children:"Save"})]})]})},bi=({open:n,onClose:c,onSave:l})=>{const[i,s]=r.useState(""),[m,g]=r.useState(""),b=V=>{s(V.target.value)},t=V=>{g(V.target.value)},$=i.length>0&&i===m,y=()=>{c()},I=()=>{$&&(l(i),c())},C=()=>{l(""),c()};return e.jsxs(He,{open:n,onClose:(V,z)=>{z==="backdropClick"||z==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ve,{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(Ee,{dividers:!0,children:e.jsx(fr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(ze,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(ze,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:b})}),e.jsx(ze,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:m,onChange:t,error:m!==""&&i!==m,helperText:m!==""&&i!==m?"Passwords do not match":""})})]})})}),e.jsxs(Ue,{children:[e.jsx(le,{onClick:y,children:"Cancel"}),e.jsx(le,{variant:"contained",onClick:I,disabled:!$,children:"Change"}),e.jsx(le,{variant:"contained",onClick:C,children:"Reset"})]})]})};function tt(n=1e3){let c=null;const l=(i=>{c!==null&&window.clearTimeout(c),c=window.setTimeout(()=>{i(),c=null},n)});return l.cancel=()=>{c!==null&&(window.clearTimeout(c),c=null)},l}const $t=330;function vi(){const{mobile:n}=r.useContext(De),{online:c,addListener:l,removeListener:i,sendMessage:s,getUniqueId:m}=r.useContext(he),[g,b]=r.useState(null),[t,$]=r.useState(null),y=r.useRef(m());return r.useEffect(()=>{const I=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`),s({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):C.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",C.response),b(C.response.matterbridgeInformation),$(C.response.systemInformation))};return l(I,y.current),o&&console.log("Settings added WebSocket listener"),()=>{i(I),o&&console.log("Settings removed WebSocket listener")}},[l,i,s]),r.useEffect(()=>{c&&(o&&console.log("Settings received online"),s({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,s]),o&&console.log("Settings rendering..."),!c||!g||!t?e.jsx(Re,{}):e.jsx(ut,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:ge&&n?"10px":"20px"},children:[e.jsx(yi,{matterbridgeInfo:g,systemInfo:t}),e.jsx(ji,{matterbridgeInfo:g}),e.jsx(Ci,{matterbridgeInfo:g}),e.jsx(wi,{systemInfo:t})]})})}function yi({matterbridgeInfo:n,systemInfo:c}){const{sendMessage:l,getUniqueId:i}=r.useContext(he),[s,m]=r.useState("bridge"),[g,b]=r.useState("Info"),[t,$]=r.useState(!1),[y,I]=r.useState("dark"),[C,V]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[z,B]=r.useState(localStorage.getItem("homePageMode")??"devices"),[A,h]=r.useState(localStorage.getItem("virtualMode")??"outlet"),p=r.useRef(i()),[u,k]=r.useState(!1),S=()=>k(!1),j=O=>{o&&console.log("handleSaveNetConfig called with config:",O),l({id:p.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:O})},[Y,re]=r.useState(!1),v=()=>re(!1),d=O=>{o&&console.log("handleSaveChangePassword called with password:",O),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:O}}),Ni(O)};r.useEffect(()=>{n&&(m(n.bridgeMode==="bridge"?"bridge":"childbridge"),b(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),$(n.fileLogger),h(n.virtualMode))},[n]),r.useEffect(()=>{const O=localStorage.getItem("frontendTheme");O&&I(O)},[]);const a=O=>{o&&console.log("handleChangeBridgeMode called with value:",O.target.value),m(O.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:O.target.value}})},x=O=>{o&&console.log("handleChangeMbLoggerLevel called with value:",O.target.value),b(O.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:O.target.value}})},F=O=>{o&&console.log("handleLogOnFileMbChange called with value:",O.target.checked),$(O.target.checked),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:O.target.checked}})},N=O=>{const U=O.target.value;o&&console.log("handleChangeTheme called with value:",U),I(U),localStorage.setItem("frontendTheme",U),document.body.setAttribute("frontend-theme",U)},te=O=>{const U=O.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",U),V(U),localStorage.setItem("homePagePlugins",U?"true":"false")},fe=O=>{const U=O.target.value;o&&console.log("handleChangeHomePageMode called with value:",U),B(U),localStorage.setItem("homePageMode",U)},Se=O=>{const U=O.target.value;o&&console.log("handleChangeVirtualMode called with value:",U),h(U),localStorage.setItem("virtualMode",U),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:U}})};return!n||!c?null:e.jsxs(be,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(ye,{children:"Matterbridge settings"})}),e.jsx(xi,{open:u,ip:c.ipv4Address,onClose:S,onSave:j}),e.jsx(bi,{open:Y,onClose:v,onSave:d}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(xr,{row:!0,name:"mode-buttons-group",value:s,onChange:a,children:[e.jsx(Ge,{value:"bridge",control:e.jsx(Pt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ge,{value:"childbridge",control:e.jsx(Pt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Qe,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:g,onChange:x,children:[e.jsx(w,{value:"Debug",children:"Debug"}),e.jsx(w,{value:"Info",children:"Info"}),e.jsx(w,{value:"Notice",children:"Notice"}),e.jsx(w,{value:"Warn",children:"Warn"}),e.jsx(w,{value:"Error",children:"Error"}),e.jsx(w,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(qe,{checked:t,onChange:F,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Qe,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:y,onChange:N,children:[e.jsx(w,{value:"classic",children:"Classic"}),e.jsx(w,{value:"light",children:"Light"}),e.jsx(w,{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(qe,{checked:C,onChange:te,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(Qe,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:z,onChange:fe,children:[e.jsx(w,{value:"logs",children:"Logs"}),e.jsx(w,{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(Qe,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:A,onChange:Se,children:[e.jsx(w,{value:"disabled",children:"Disabled"}),e.jsx(w,{value:"outlet",children:"Outlet"}),e.jsx(w,{value:"light",children:"Light"}),e.jsx(w,{value:"switch",children:"Switch"}),e.jsx(w,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(le,{variant:"contained",color:"primary",onClick:()=>re(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(le,{variant:"contained",color:"primary",onClick:()=>k(!0),children:"Configure IP"})})]})]})}function ji({matterbridgeInfo:n}){const{sendMessage:c,getUniqueId:l}=r.useContext(he),[i,s]=r.useState("Info"),[m,g]=r.useState(!1),[b,t]=r.useState(""),[$,y]=r.useState(""),[I,C]=r.useState(""),[V,z]=r.useState(""),[B,A]=r.useState(""),[h,p]=r.useState(""),u=r.useRef(l()),k=r.useMemo(()=>tt(1e3),[]),S=r.useMemo(()=>tt(1e3),[]),j=r.useMemo(()=>tt(1e3),[]),Y=r.useMemo(()=>tt(1e3),[]),re=r.useMemo(()=>tt(1e3),[]),v=r.useMemo(()=>tt(1e3),[]);r.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),g(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),C(n.matterIpv6Address||""),z(n.matterPort?n.matterPort.toString():""),A(n.matterDiscriminator?n.matterDiscriminator.toString():""),p(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>k.cancel(),[k]),r.useEffect(()=>()=>S.cancel(),[S]),r.useEffect(()=>()=>j.cancel(),[j]),r.useEffect(()=>()=>Y.cancel(),[Y]),r.useEffect(()=>()=>re.cancel(),[re]),r.useEffect(()=>()=>v.cancel(),[v]);const d=O=>{o&&console.log("handleChangeMjLoggerLevel called with value:",O.target.value),s(O.target.value),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:O.target.value}})},a=O=>{o&&console.log("handleLogOnFileMjChange called with value:",O.target.checked),g(O.target.checked),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:O.target.checked}})},x=O=>{o&&console.log("handleChangeMdnsInterface called with value:",O.target.value);const U=O.target.value;t(U),k(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",U),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:U}})})},F=O=>{o&&console.log("handleChangeIpv4Address called with value:",O.target.value);const U=O.target.value;y(U),S(()=>{o&&console.log("debounced sendMessage setipv4address with value:",U),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:U}})})},N=O=>{o&&console.log("handleChangeIpv6Address called with value:",O.target.value);const U=O.target.value;C(U),j(()=>{o&&console.log("debounced sendMessage setipv6address with value:",U),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:U}})})},te=O=>{o&&console.log("handleChangeMatterPort called with value:",O.target.value);const U=O.target.value;z(U),Y(()=>{o&&console.log("debounced sendMessage setmatterport with value:",U),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:U}})})},fe=O=>{o&&console.log("handleChangeMatterDiscriminator called with value:",O.target.value);const U=O.target.value;A(U),re(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",U),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:U}})})},Se=O=>{o&&console.log("handleChangemMatterPasscode called with value:",O.target.value);const U=O.target.value;p(U),v(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",U),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:U}})})};return n?e.jsxs(be,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(ye,{children:"Matter settings"})}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(Qe,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:d,children:[e.jsx(w,{value:"Debug",children:"Debug"}),e.jsx(w,{value:"Info",children:"Info"}),e.jsx(w,{value:"Notice",children:"Notice"}),e.jsx(w,{value:"Warn",children:"Warn"}),e.jsx(w,{value:"Error",children:"Error"}),e.jsx(w,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(qe,{checked:m,onChange:a,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(me,{value:b,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(me,{value:$,onChange:F,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(me,{value:I,onChange:N,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(me,{value:V,onChange:te,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(me,{value:B,onChange:fe,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(me,{value:h,onChange:Se,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(be,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(ye,{children:"Matterbridge info"})}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Me,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Me,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Me,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Me,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Me,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Me,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Me,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function wi({systemInfo:n}){return n?e.jsxs(be,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(ye,{children:"System info"})}),e.jsxs(Fe,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Me,{value:n.interfaceName,label:"Interface name"}),e.jsx(Me,{value:n.macAddress,label:"MAC Address"}),e.jsx(Me,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Me,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Me,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Me,{value:n.hostname,label:"Hostname"}),e.jsx(Me,{value:n.user,label:"User"})]})]}):null}function Me({value:n,label:c,width:l}){return e.jsx(me,{focused:!0,value:n,size:"small",label:c,variant:"standard",sx:{width:l?`${l-20}px`:"100%","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const Si=r.memo(vi);function ki(){const{online:n,sendMessage:c,addListener:l,removeListener:i,getUniqueId:s}=r.useContext(he),{showSnackbarMessage:m}=r.useContext(De),[g,b]=r.useState(null),[t,$]=r.useState([]),[y,I]=r.useState([]),[C,V]=r.useState(null),[z,B]=r.useState({cpuUsage:0}),[A,h]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[p,u]=r.useState({systemUptime:"",processUptime:""}),k=r.useRef(s());return o&&console.log("Test uniqueId:",k),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const S=j=>{if(j.method==="restart_required")o&&console.log("Test received restart_required"),m("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),m("Refresh required",0),c({id:k.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:k.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:k.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="memory_update")o&&console.log("Test received memory_update",j),h(j.response);else if(j.method==="cpu_update")o&&console.log("Test received cpu_update",j),B(j.response);else if(j.method==="uptime_update")o&&console.log("Test received uptime_update",j),u(j.response);else if(j.method==="/api/settings"&&j.response)o&&console.log("Test received /api/settings:",j.response),m("Test received /api/settings",0),b(j.response);else if(j.method==="/api/plugins"&&j.response)o&&console.log(`Test received ${j.response.length} plugins:`,j.response),m("Test received /api/plugins",0),$(j.response);else if(j.method==="/api/devices"&&j.response){o&&console.log(`Test received ${j.response.length} devices:`,j.response),m("Test received /api/devices",0),I(j.response);for(const Y of j.response)o&&console.log("Test sending /api/clusters for device:",Y.pluginName,Y.name,Y.endpoint),c({id:k.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:Y.pluginName,endpoint:Y.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&(o&&console.log(`Test received ${j.response.clusters.length} clusters for device ${j.response.deviceName} endpoint ${j.response.id}:${j.response.number}:`,j),m(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),V(j.response))};return l(S,k.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(S),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,c,m]),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,c,m]),o&&console.log("Test rendering..."),n?e.jsx(ut,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Re,{})}const Ii=r.memo(ki);function Mi(n,c){o&&console.log("getCssVariable:",n,"defaultValue",c);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||c}function Di(n){return Io({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 Pi(){const{mobile:n,showSnackbarMessage:c,showConfirmCancelDialog:l}=r.useContext(De),{online:i,sendMessage:s,logMessage:m,addListener:g,removeListener:b,getUniqueId:t}=r.useContext(he),[$,y]=r.useState(!1),[I,C]=r.useState(!1),[V,z]=r.useState(!1),[B,A]=r.useState(!1),[h,p]=r.useState(null),u=r.useRef(t()),[k,S]=r.useState(null),[j,Y]=r.useState(null),[re,v]=r.useState(null),[d,a]=r.useState(null),[x,F]=r.useState(null),N=Tr(),te=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},fe=()=>{window.open("https://matterbridge.io/")},Se=()=>{window.open("https://matterbridge.io/README.html")},O=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},U=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},T=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},K=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},W=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},L=()=>{s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),m("Matterbridge","Installing system updates..."),s({id:u.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),m("Matterbridge","Installing software updates..."),s({id:u.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},R=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),s({id:u.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},Z=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),m("Matterbridge","Downloading Shelly system log..."),c("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},pe=()=>{h?.matterbridgeInformation.restartMode===""?s({id:u.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},G=()=>{s({id:u.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},f=()=>{s({id:u.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{s({id:u.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},J=_=>{S(_.currentTarget)},D=_=>{o&&console.log("Header: handleMenuClose",_),S(null),_==="/"||_==="/devices"||_==="/log"||_==="/settings"?N(_):_==="download-mblog"?(m("Matterbridge","Downloading matterbridge log..."),c("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):_==="download-mjlog"?(m("Matterbridge","Downloading matter log..."),c("Downloading matter log...",5),window.location.href="./api/download-mjlog"):_==="view-mblog"?(m("Matterbridge","Loading matterbridge log..."),c("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):_==="view-mjlog"?(m("Matterbridge","Loading matter log..."),c("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):_==="view-diagnostic"?(m("Matterbridge","Loading diagnostic log..."),c("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):_==="download-diagnostic"?(m("Matterbridge","Downloading diagnostic log..."),c("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):_==="view-history"?s({id:u.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):_==="download-history"?s({id:u.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):_==="view-shellylog"?(m("Matterbridge","Loading shelly system log..."),c("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):_==="download-mbstorage"?(m("Matterbridge","Downloading matterbridge storage..."),c("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):_==="download-pluginstorage"?(m("Matterbridge","Downloading matterbridge plugins storage..."),c("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):_==="download-pluginconfig"?(m("Matterbridge","Downloading matterbridge plugins config..."),c("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):_==="download-mjstorage"?(m("Matterbridge","Downloading matter storage..."),c("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):_==="download-backup"?(m("Matterbridge","Downloading backup..."),c("Downloading backup...",10),window.location.href="./api/download-backup"):_==="update"?K():_==="updatedev"?W():_==="updatecheck"?L():_==="shelly-sys-update"?P():_==="shelly-main-update"?M():_==="shelly-create-system-log"?R():_==="shelly-download-system-log"?Z():_==="softreset"?f():_==="hardreset"?ae():_==="restart"?pe():_==="shutdown"?ce():_==="reboot"?G():_==="create-backup"?s({id:u.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):_==="unregister"?s({id:u.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):_==="reset"?s({id:u.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):_==="factoryreset"&&s({id:u.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},ve=_=>{o&&console.log("Header: handleMenuCloseCancel:",_),S(null)},Te=_=>{Y(_.currentTarget)},xe=()=>{Y(null)},oe=_=>{v(_.currentTarget)},de=()=>{v(null)},Oe=_=>{a(_.currentTarget)},ke=()=>{a(null)},st=_=>{F(_.currentTarget)},E=()=>{F(null)},je=()=>{$i(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const _=ne=>{o&&console.log("Header received WebSocket Message:",ne),ne.method==="/api/settings"&&ne.id===u.current?(o&&console.log("Header received settings:",ne.response),p(ne.response),y(ne.response.matterbridgeInformation.restartRequired||ne.response.matterbridgeInformation.fixedRestartRequired),C(ne.response.matterbridgeInformation.fixedRestartRequired),z(ne.response.matterbridgeInformation.updateRequired)):ne.method==="refresh_required"&&ne.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${ne.response.changed} and sending /api/settings request`),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ne.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${ne.response.fixed}`),y(!0),ne.response.fixed===!0&&C(!0)):ne.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),y(!1)):ne.method==="update_required"?(o&&console.log("Header received update_required"),ne.response.devVersion===!0?A(!0):z(!0),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ne.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),p(Pe=>Pe?{matterbridgeInformation:{...Pe.matterbridgeInformation,shellySysUpdate:ne.response.available},systemInformation:Pe.systemInformation}:null)):ne.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),p(Pe=>Pe?{matterbridgeInformation:{...Pe.matterbridgeInformation,shellyMainUpdate:ne.response.available},systemInformation:Pe.systemInformation}:null)):ne.method==="/api/viewhistorypage"&&ne.id===u.current&&ne.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):ne.method==="/api/downloadhistorypage"&&ne.id===u.current&&ne.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return g(_,u.current),o&&console.log(`Header added WebSocket listener id ${u.current}`),()=>{b(_),o&&console.log("Header removed WebSocket listener")}},[g,b,s,c]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,s]),o&&console.log("Header rendering... mobile %s",n),!i||!h?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:je}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(gt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(gt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(gt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(gt,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!h.matterbridgeInformation.readOnly&&e.jsx(H,{title:`Matterbridge v.${h.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",h.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(h.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),h.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),h.matterbridgeInformation.bridgeMode!==""&&h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:h.matterbridgeInformation.bridgeMode})}):null,h.matterbridgeInformation.restartMode!==""&&h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:h.matterbridgeInformation.restartMode})}):null,h.matterbridgeInformation.profile&&h.matterbridgeInformation.profile!==""&&h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:h.matterbridgeInformation.profile})}):null,o&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${Mt}x${Dt}`,` enabled ${localStorage.getItem("enableMobile")!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:U})}):null,h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:T,children:e.jsx(hr,{})})}):null,h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:te,children:e.jsx(Et,{})})}):null,e.jsx(H,{title:"Matterbridge homepage",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:fe,children:e.jsx(Mo,{})})}),e.jsx(H,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:Se,children:e.jsx(ur,{})})}),e.jsx(H,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:O,children:e.jsx(Vt,{})})}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&V&&e.jsx(H,{title:`Update matterbridge to latest version v.${h.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:K,children:e.jsx(Ne,{})})}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&B&&e.jsx(H,{title:`Update matterbridge to latest dev version v.${h.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(Q,{style:{color:"var(--secondary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:W,children:e.jsx(Ne,{})})}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellySysUpdate&&e.jsx(H,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:P,children:e.jsx(Ne,{})})}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellyMainUpdate&&e.jsx(H,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(Ne,{})})}),e.jsx(H,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:$||I?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:pe,children:e.jsx(kt,{})})}),h.matterbridgeInformation.restartMode===""?e.jsx(H,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:$||I?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:ce,children:e.jsx(Be,{})})}):null,e.jsx(H,{title:"Download, backup and more",children:e.jsx(Q,{onClick:J,children:e.jsx(Do,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(ot,{id:"command-menu",anchorEl:k,keepMounted:!0,open:!!k,onClose:()=>D(""),children:[ge&&n&&e.jsxs(w,{onClick:()=>D("/"),children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ge&&n&&e.jsxs(w,{onClick:()=>D("/devices"),children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ge&&n&&e.jsxs(w,{onClick:()=>D("/log"),children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ge&&n&&e.jsxs(w,{onClick:()=>D("/settings"),children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(w,{onClick:()=>D("update"),children:[e.jsx(q,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(w,{onClick:()=>D("updatedev"),children:[e.jsx(q,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(w,{onClick:()=>D("updatecheck"),children:[e.jsx(q,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellySysUpdate&&e.jsxs(w,{onClick:()=>D("shelly-sys-update"),children:[e.jsx(q,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellyMainUpdate&&e.jsxs(w,{onClick:()=>D("shelly-main-update"),children:[e.jsx(q,{children:e.jsx(Ne,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>D("restart"),children:[e.jsx(q,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation.restartMode===""?e.jsxs(w,{onClick:()=>D("shutdown"),children:[e.jsx(q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(w,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",D,ve)},children:[e.jsx(q,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(bt,{}),e.jsxs(w,{onClick:oe,children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ot,{id:"sub-menu-view",anchorEl:re,keepMounted:!0,open:!!re,onClose:de,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(w,{onClick:()=>{Ti(),de(),ve(""),window.open("/home","_self")},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{Fi(),de(),ve(""),window.open("/home","_self")},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("view-mblog"),de()},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("view-mjlog"),de()},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("view-diagnostic"),de()},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("view-history"),de()},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(w,{onClick:()=>{D("view-shellylog"),de()},children:[e.jsx(q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(bt,{}),e.jsxs(w,{onClick:Oe,children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ot,{id:"sub-menu-download",anchorEl:d,keepMounted:!0,open:!!d,onClose:ke,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(w,{onClick:()=>{D("download-mbstorage"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-pluginstorage"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-pluginconfig"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-mblog"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-mjstorage"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-mjlog"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-diagnostic"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-history"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(w,{onClick:()=>{D("shelly-create-system-log"),ke()},children:[e.jsx(q,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(w,{onClick:()=>{D("shelly-download-system-log"),ke()},children:[e.jsx(q,{children:e.jsx(We,{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(bt,{}),e.jsxs(w,{onClick:Te,children:[e.jsx(q,{children:e.jsx(Ft,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ot,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:xe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(w,{onClick:()=>{D("create-backup"),xe()},children:[e.jsx(q,{children:e.jsx(Ft,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{onClick:()=>{D("download-backup"),xe()},children:[e.jsx(q,{children:e.jsx(Ft,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(bt,{}),e.jsxs(w,{onClick:st,children:[e.jsx(q,{children:e.jsx(Po,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ot,{id:"sub-menu-reset",anchorEl:x,keepMounted:!0,open:!!x,onClose:E,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(w,{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",D,ve)},children:[e.jsx(q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(w,{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",D,ve)},children:[e.jsx(q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!h.matterbridgeInformation.readOnly&&e.jsxs(w,{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",D,ve)},children:[e.jsx(q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(w,{onClick:()=>{E(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",D,ve)},children:[e.jsx(q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(w,{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",D,ve)},children:[e.jsx(q,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const lr=r.memo(Pi),Cr=1200,wr=900;let Mt,Dt;function ar(){if(typeof window<"u"){Mt=Math.floor(window.visualViewport?.width??window.innerWidth),Dt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Mt<Cr||Dt<wr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,Mt,Dt,n),n}return!1}function Li({children:n}){const{mobile:c,setMobile:l}=r.useContext(De),{logAutoScroll:i}=r.useContext(he);return r.useEffect(()=>{function s(){const m=ar();m&&(i.current=!1,localStorage.setItem("logAutoScroll","false")),l(m)}return window.addEventListener("resize",s),l(ar()),()=>window.removeEventListener("resize",s)},[i,l]),o&&console.log("MbfScreen rendering... mobile %s",c),ge&&c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:c?`${Cr}px`:"calc(100vw - 40px)",height:c?`${wr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(lr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const $i=()=>{o=!o},Wi=!1;let ge=localStorage.getItem("enableMobile")!=="false";const Fi=()=>{ge=!0,localStorage.setItem("enableMobile","true")},Ti=()=>{ge=!1,localStorage.setItem("enableMobile","false")};let it;const Ni=n=>{it=n};let pt=!1,cr="/",rt="/",Ot="/";function Ri({setLoggedIn:n}){const[c,l]=r.useState(""),[i,s]=r.useState(""),m={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},g={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)"},b={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 I=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(I.ok){const{valid:C}=await I.json();C?(n(!0),y!==""&&(it=y)):y!==""&&s("Incorrect password!")}else console.error("Failed to log in:",I.statusText)}catch(I){console.error("Failed to log in:",I)}},$=y=>{y.preventDefault(),t(c)};return t(""),e.jsx("div",{style:m,children:e.jsxs("form",{onSubmit:$,style:g,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:c,onChange:y=>l(y.target.value),style:b,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 Oi(){const[n,c]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=Mi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const s=Di(i);return cr=window.location.href,rt=window.location.pathname,Ot=rt.includes("/matterbridge/")?"/matterbridge/":rt.includes("/api/hassio_ingress/")?rt:"/",pt=rt.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${cr}"`),console.log(`- pathname = "${rt}"`),console.log(`- baseName = "${Ot}"`),console.log(`- isIngress = "${pt}"`),n?e.jsx(Lo,{theme:s,children:e.jsx(Ar,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(mn,{children:e.jsx(hn,{children:e.jsx(Nr,{basename:Ot,children:e.jsx(Li,{children:e.jsxs(Rr,{children:[e.jsx(Je,{path:"/",element:e.jsx(Bn,{})}),e.jsx(Je,{path:"/devices",element:e.jsx(mi,{})}),e.jsx(Je,{path:"/log",element:e.jsx(fi,{})}),e.jsx(Je,{path:"/settings",element:e.jsx(Si,{})}),e.jsx(Je,{path:"/test",element:e.jsx(Ii,{})}),e.jsx(Je,{path:"*",element:e.jsx(Or,{to:"/"})})]})})})})})})}):e.jsx(Ri,{setLoggedIn:c})}Hr.createRoot(document.getElementById("root")).render(e.jsx(Vr.StrictMode,{children:e.jsx(Oi,{})}));
|