matterbridge 3.4.3 → 3.4.4-dev-20251214-37296cc
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 +20 -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((
|
|
3
|
-
`)},[]),
|
|
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 Fr,U as pt,V as Tr,X as Rr,Y as Ge,Z as Hr,$ as Or,I as Vr}from"./vendor_node_modules.js";import{u as Er,S as Ar}from"./vendor_notistack.js";import{D as Oe,a as Ve,b as Ee,B as se,c as Ue,F as Ke,C as qe,d as ne,A as _r,I as B,e as qr,f as zr,T as H,g as ge,M as Ur,h as rt,i as C,j as We,k as dr,l as Br,m as St,n as Qr,o as pe,K as Ut,p as Bt,q as Ot,L as ut,r as st,s as gt,t as _,W as at,u as mt,H as ht,v as X,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 Fe,J as Et,N as gr,O as Mt,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 wo,am as Co,an as So,ao as ko,ap as Wt,aq as Qe,ar as fr,as as ye,at as xr,au as Pt,av as ze,aw as Mo,ax as Io,ay as Be,az as Do,aA as $e,aB as ft,aC as Nt,aD as Po,aE as Lo}from"./vendor_mui.js";import{I as ie,m as $o,a as Zt,b as Wo,c as No,d as Yt,e as Fo,f as To,g as Ro,h as Ho,i as Oo,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 Ft,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 x of s)if(x.type==="childList")for(const g of x.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&i(g)}).observe(document,{childList:!0,subtree:!0});function a(s){const x={};return s.integrity&&(x.integrity=s.integrity),s.referrerPolicy&&(x.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?x.credentials="include":s.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function i(s){if(s.ep)return;s.ep=!0;const x=a(s);fetch(s.href,x)}})();function un({open:n,title:c,message:a,onConfirm:i,onCancel:s}){const x=v=>{o&&console.log("Confirmed"),v.preventDefault(),i()},g=v=>{o&&console.log("Canceled"),v.preventDefault(),s()};return e.jsxs(Oe,{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:a})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(se,{onClick:x,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(se,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const gn=({open:n,output:c,title:a,_command:i,_packageName:s,onInstall:x,onClose:g})=>{const{installAutoExit:v,setInstallAutoExit:t}=r.useContext(De),$=r.useRef(null),y=M=>{t(M.target.checked),localStorage.setItem("installAutoExit",M.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",M.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(Oe,{open:n,onClose:(M,w)=>{w==="backdropClick"||w==="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:a})]})}),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((M,w)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:M},w)),e.jsx("li",{ref:$,style:{padding:0,margin:0}})]})]}),e.jsxs(Ue,{sx:{justifyContent:"space-evenly"},children:[x&&e.jsx(se,{variant:"contained",onClick:x,children:"Install"}),e.jsx(se,{onClick:g,children:"Close"}),e.jsx(Ke,{control:e.jsx(qe,{checked:v,onChange:M=>y(M)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},xt=[],De=r.createContext(null);function mn({children:n}){const[c,a]=r.useState(!1),[i,s]=r.useState(null),{enqueueSnackbar:x,closeSnackbar:g}=Er(),v=r.useCallback(I=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${I}`);const F=xt.findIndex(J=>J.message===I);F!==-1&&(g(xt[F].key),xt.splice(F,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${I} removed from persistMessages`))},[g]),t=r.useCallback((I,F,J)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${I} timeout ${F}`);const de=x(I,{variant:"default",autoHideDuration:F==null||F>0?(F??5)*1e3:null,persist:F===0,content:ae=>e.jsx(ne,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(_r,{severity:J??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>g(ae),action:e.jsx(B,{size:"small",onClick:()=>g(ae),sx:{color:"#fff"},children:e.jsx(qr,{fontSize:"small"})}),children:I},ae)},ae)});F===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${I} timeout ${F} - persist key ${de}`),xt.push({message:I,key:de}))},[x,g]),[$,y]=r.useState(!1),[M,w]=r.useState(""),[O,q]=r.useState(""),[z,E]=r.useState(""),h=r.useRef(null),p=r.useRef(null),u=()=>{o&&console.log(`UiProvider handle confirm action ${z}`),y(!1),h.current&&h.current(z)},k=()=>{o&&console.log(`UiProvider handle cancel action ${z}`),y(!1),p.current&&p.current(z)},S=r.useCallback((I,F,J,de,ae)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${J}`),w(I),q(F),E(J),h.current=de,p.current=ae,y(!0)},[]),[j,Z]=r.useState(!1),[ee,d]=r.useState(""),[l,m]=r.useState(""),[b,T]=r.useState(""),[te,xe]=r.useState(""),[we,ke]=r.useState(localStorage.getItem("installAutoExit")!=="false"),R=r.useCallback((I,F,J)=>{o&&console.log(`UiProvider show install progress for package ${I}`),d(I),m(F),T(J),Z(!0)},[]),U=r.useCallback(I=>{o&&console.log(`UiProvider addInstallProgress: output ${I}`),xe(F=>F+I+`
|
|
3
|
+
`)},[]),N=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${b}`),localStorage.getItem("installAutoExit")!=="false"&&Z(!1)},[b]),Q=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${b}`)},[b]),W=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),Z(!1)},[]),L=()=>{o&&console.log("UiProvider handle install close action"),Z(!1),T(""),xe("")},P=r.useMemo(()=>({mobile:c,setMobile:a,currentPage:i,setCurrentPage:s,showSnackbarMessage:t,closeSnackbarMessage:v,closeSnackbar:g,showConfirmCancelDialog:S,showInstallProgress:R,exitInstallProgressSuccess:N,exitInstallProgressError:Q,hideInstallProgress:W,addInstallProgress:U,installAutoExit:we,setInstallAutoExit:ke}),[c,i,a,s,t,v,g,S,R,N,Q,W,U,we,ke]);return e.jsxs(De.Provider,{value:P,children:[e.jsx(un,{open:$,title:M,message:O,onConfirm:u,onCancel:k}),e.jsx(gn,{open:j,title:ee,_command:l,_packageName:b,output:te,onClose:L}),n]})}const br=r.createContext(null),me=r.createContext(null);function hn({children:n}){const[c,a]=r.useState([]),[i,s]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[x,g]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[v,t]=r.useState(!1),{showSnackbarMessage:$,closeSnackbarMessage:y,closeSnackbar:M,showInstallProgress:w,hideInstallProgress:O,exitInstallProgressSuccess:q,exitInstallProgressError:z,addInstallProgress:E}=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),Z=r.useRef(null),ee=r.useRef(i),d=r.useRef(x),l=r.useRef(0),m=r.useRef(null),b=r.useRef(Number(localStorage.getItem("logLength")??200)),T=r.useRef(localStorage.getItem("logAutoScroll")!=="false"),te=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),xe=100,we=60,ke=50,R=300,U=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),m.current=setInterval(()=>{l.current>0&&(o&&console.log(`WebSocket messages received in the last ${U} seconds: ${l.current*(60/U)} messages/minute`),l.current=0)},U*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),m.current&&clearInterval(m.current),m.current=null}),[]),r.useEffect(()=>{ee.current=i},[i]),r.useEffect(()=>{d.current=x},[x]);const N=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),Q=r.useCallback((K,f)=>{o&&console.log(`WebSocket filterLogMessages called with level "${K}" and search "${f}"...`),a(le=>le.filter(G=>!(["debug","info","notice","warn","error","fatal"].includes(G.level)&&(K==="info"&&G.level==="debug"||K==="notice"&&(G.level==="debug"||G.level==="info")||K==="warn"&&(G.level==="debug"||G.level==="info"||G.level==="notice")||K==="error"&&(G.level==="debug"||G.level==="info"||G.level==="notice"||G.level==="warn")||K==="fatal"&&(G.level==="debug"||G.level==="info"||G.level==="notice"||G.level==="warn"||G.level==="error"))||f!=="*"&&f!==""&&!f.startsWith("/")&&!f.endsWith("/")&&!G.message.toLowerCase().includes(f.toLowerCase())&&!G.name.toLowerCase().includes(f.toLowerCase())||f.startsWith("/")&&f.endsWith("/")&&(()=>{try{const D=new RegExp(f.slice(1,-1),"i");return!D.test(G.message)&&!D.test(G.name)}catch(D){return console.error(`WebSocket log search invalid regex filter "${f}":`,D),!1}})())))},[]),W=r.useCallback(K=>{if(p.current&&p.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${K.id}:`,K),K.id===void 0&&(K.id=k.current);const f=JSON.stringify(K);p.current.send(f),o&&console.log("WebSocket sent message:",K)}catch(f){o&&console.error(`WebSocket error sending message: ${f}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",K)},[]),L=r.useCallback((K,f)=>{a(le=>[...le,{level:K,time:"",name:"",message:f}])},[]),P=r.useCallback((K,f)=>{o&&console.log(`WebSocket addListener id ${f}:`,K),(f==null||isNaN(f)||f===0)&&console.error("WebSocket addListener called without id, listener not added:",K),h.current=[...h.current,{listener:K,id:f}],o&&console.log("WebSocket addListener total listeners:",h.current.length)},[]),I=r.useCallback(K=>{o&&console.log("WebSocket removeListener:",K),h.current=h.current.filter(f=>f.listener!==K),o&&console.log("WebSocket removeListener total listeners:",h.current.length)},[]),F=r.useCallback(()=>{te===""||te===null||te===void 0||(L("WebSocket",`Connecting ${ot?"with password":""} to WebSocket: ${te}`),o&&console.log(`WebSocket connecting to: ${te}${ot?"?password=[redacted]":""}`),p.current=new WebSocket(te+(ot?`?password=${encodeURIComponent(ot)}`:"")),p.current.onmessage=K=>{v||t(!0),l.current+=1;try{const f=JSON.parse(K.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"?w(f.response.message,"",""):f.response.name==="Matterbridge:spawn-exit-success"?q():f.response.name==="Matterbridge:spawn-exit-error"?z():E(f.response.message+`
|
|
4
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(f.response.level)&&(ee.current==="info"&&f.response.level==="debug"||ee.current==="notice"&&(f.response.level==="debug"||f.response.level==="info")||ee.current==="warn"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice")||ee.current==="error"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn")||ee.current==="fatal"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn"||f.response.level==="error")))||d.current!=="*"&&d.current!==""&&!d.current.startsWith("/")&&!d.current.endsWith("/")&&!f.response.message.toLowerCase().includes(d.current.toLowerCase())&&!f.response.name.toLowerCase().includes(d.current.toLowerCase())||d.current.startsWith("/")&&d.current.endsWith("/")&&(()=>{try{const G=new RegExp(d.current.slice(1,-1),"i");return!G.test(f.response.message)&&!G.test(f.response.name)}catch(G){return console.error(`WebSocket log search invalid regex filter "${d.current}":`,G),!1}})()||f.response.name==="Commissioning"&&f.response.message.includes("is uncommissioned"))return;a(G=>{const D=[...G,{level:f.response.level,time:f.response.time,name:f.response.name,message:f.response.message}];return console.log(`WebSocket new log message added (${D.length}/${b.current}):`,D[D.length-1]),D.length>b.current+b.current*10/100?(console.log(`WebSocket sliced log messages to the last ${b.current} entries`),D.slice(D.length-b.current)):D})}else{if(o&&console.log(`WebSocket received message id ${f.id} method ${f.method}:`,f),f.id===0)h.current.forEach(le=>le.listener(f));else{const le=h.current.find(G=>G.id===f.id);le?le.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: ${te}`),L("WebSocket",`Connected to WebSocket: ${te}`),t(!0),M(),u.current=1,Z.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: ${te}`),L("WebSocket",`No pong response received from WebSocket: ${te}`),t(!1)},1e3*ke)},1e3*we)},1e3*R)},p.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${ct?"with Ingress":""}: ${te}`),L("WebSocket",`Disconnected from WebSocket: ${te}`),t(!1),M(),O(),Z.current&&clearTimeout(Z.current),j.current&&clearTimeout(j.current),S.current&&clearInterval(S.current),L("WebSocket",`Reconnecting (attempt ${u.current} of ${xe}) to WebSocket${ct?" (Ingress)":""}: ${te}`),ct?setTimeout(J,5e3):u.current===1?J():u.current<xe?setTimeout(J,1e3*u.current):L("WebSocket",`Reconnect attempts exceeded limit of ${xe} retries, refresh the page to reconnect to: ${te}`),u.current=u.current+1},p.current.onerror=K=>{o&&console.error(`WebSocket: WebSocket error connecting to ${te}:`,K),L("WebSocket",`WebSocket error connecting to ${te}`)})},[te]),J=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${u.current}/${xe} to:`,te),F()},[F]);r.useEffect(()=>(F(),()=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.close()}),[F]);const de=r.useMemo(()=>({messages:c,logLength:b,logAutoScroll:T,logFilterLevel:i,logFilterSearch:x,setMessages:a,setLogFilterLevel:s,setLogFilterSearch:g,filterLogMessages:Q}),[c,b,T,i,x,a,s,g,Q]),ae=r.useMemo(()=>({logLength:b,logAutoScroll:T,logFilterLevel:i,logFilterSearch:x,setMessages:a,setLogFilterLevel:s,setLogFilterSearch:g,filterLogMessages:Q,online:v,retry:u.current,getUniqueId:N,addListener:P,removeListener:I,sendMessage:W,logMessage:L}),[b,T,a,s,g,v,u.current,P,I,W,L]);return e.jsx(br.Provider,{value:de,children:e.jsx(me.Provider,{value:ae,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 Te(){const{retry:n}=r.useContext(me),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(se,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function vr({value:n,maxChars:c}){let a=n;if(n.length>c&&c>3){const i=c-3,s=n.substring(0,Math.ceil(i/2)),x=n.substring(n.length-Math.floor(i/2),n.length);a=`${s} … ${x}`}return n!==a?e.jsx(H,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:a})}):e.jsx("span",{children:a})}function je({children:n,style:c}){const a={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:{...a,...c},children:n})}function Ie({children:n,style:c}){const a={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:{...a,...c},children:n})}function Se({children:n,style:c}){const a={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...c},children:n})}function bt({children:n,style:c}){const a={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:{...a,...c},children:n})}function vt({children:n,style:c}){const a={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...c},children:n})}function lt({children:n,style:c}){const a={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...a,...c},children:n})}function Re({children:n,style:c,onDragOver:a,onDragLeave:i,onDrop:s}){const x={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:{...x,...c},onDragOver:a,onDragLeave:i,onDrop:s,children:n})}function nt({children:n,style:c,onClose:a}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...c},children:[n,$i]})}function xn({systemInfo:n,compact:c}){const{mobile:a}=r.useContext(De),{addListener:i,removeListener:s,getUniqueId:x,sendMessage:g}=r.useContext(me),[v,t]=r.useState(n),$=r.useRef(x());if(o&&console.log("SystemInfoTable loading with systemInfo:",v,"compact:",c),n&&c&&v.totalMemory&&v.freeMemory){const h=v.totalMemory,p=v.freeMemory;v.freeMemory=`${p} / ${h}`,v.totalMemory=""}if(n&&c&&v.heapTotal&&v.heapUsed){const h=v.heapTotal,p=v.heapUsed;v.heapUsed=`${p} / ${h}`,v.heapTotal=""}if(n&&c&&v.osRelease&&v.osType){const h=v.osType,p=v.osRelease;v.osType=`${h} (${p})`,v.osRelease=""}if(n&&c&&v.osArch&&v.osPlatform){const h=v.osPlatform,p=v.osArch;v.osPlatform=`${h} (${p})`,v.osArch=""}const y=(h,p,u,k,S)=>{t(j=>({...j,totalMemory:h,freeMemory:p,heapTotal:u,heapUsed:k,rss:S}))},M=h=>{t(p=>({...p,cpuUsage:h.toFixed(2)+" %"}))},w=h=>{t(p=>({...p,processCpuUsage:h.toFixed(2)+" %"}))},O=(h,p)=>{t(u=>({...u,systemUptime:h,processUptime:p}))},q=()=>{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),M(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),O(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[z,E]=r.useState(!1);return!v||z?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(je,{style:ue&&a?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ie,{children:[e.jsx(Se,{children:"System info"}),e.jsx(nt,{onClose:()=>E(!0),children:e.jsx(B,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:q,children:e.jsx(H,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ie,{path:$o,size:"22px"})})})})]}),e.jsx(Re,{style:ue&&a?{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(([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:ue&&a?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 a=c.slice(0,4),i=c.slice(4,7),s=c.slice(7,11);return[a,i,s].filter(Boolean).join("-")};function vn({id:n}){const{online:c,sendMessage:a,addListener:i,removeListener:s,getUniqueId:x}=r.useContext(me),[g,v]=r.useState(null),t=r.useRef(null),$=r.useRef(null),y=r.useRef(x()),{mobile:M,showConfirmCancelDialog:w}=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}"`),a({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,a]),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),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()),$.current=setTimeout(()=>{$.current&&clearTimeout($.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),v(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 O=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${g?.id}"`),g&&a({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,startCommission:!0}})},q=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${g?.id}"`),g&&a({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,stopCommission:!0}})},z=()=>{o&&console.log(`QRDiv sent matter advertise for node "${g?.id}"`),g&&a({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,advertise:!0}})},E=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${g?.id}" and fabricIndex ${p}`),g&&a({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(je,{style:ue&&M?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(Ie,{children:[e.jsx(Se,{children:"QR pairing code"}),e.jsxs(nt,{children:[e.jsx(B,{"aria-label":"send advertising",size:"small",onClick:z,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(ie,{path:Zt,size:"22px"})})}),e.jsx(B,{"aria-label":"stop pairing",size:"small",onClick:q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn off pairing",arrow:!0,children:e.jsx(ie,{path:Wo,size:"22px"})})})]})]}),e.jsx(lt,{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(bt,{style:{justifyContent:"space-between"},children:[e.jsxs(vt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",bn(g.manualPairingCode)]}),e.jsx(nt,{children:e.jsx(H,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(B,{"aria-label":"copy manual pairing code",size:"small",onClick:h,sx:rr,children:e.jsx(ie,{path:No,size:.85})})})})]})]})):g.commissioned&&g.fabricInformations&&g.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(je,{style:ue&&M?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ie,{children:[e.jsx(Se,{children:"Paired fabrics"}),e.jsxs(nt,{children:[e.jsx(B,{"aria-label":"send advertising",size:"small",onClick:z,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(ie,{path:Zt,size:"22px"})})}),e.jsx(B,{"aria-label":"start pairing",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn on pairing",arrow:!0,children:e.jsx(ie,{path:Yt,size:"22px"})})})]})]}),e.jsx(lt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Re,{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(B,{"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",()=>E(p.fabricIndex),()=>{}),sx:{...rr,padding:"2px"},children:e.jsx(ie,{path:Fo,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(bt,{style:{justifyContent:"center"},children:e.jsxs(vt,{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(je,{style:ue&&M?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Ie,{children:e.jsx(Se,{children:"QR pairing code"})}),e.jsx(lt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(se,{onClick:O,endIcon:e.jsx(ie,{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(bt,{style:{justifyContent:"center"},children:e.jsxs(vt,{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(je,{style:ue&&M?{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(Se,{children:"Server node"})}),e.jsx(lt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(lt,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(bt,{style:{justifyContent:"center"},children:e.jsxs(vt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]}))}const or=r.memo(vn);function yn(){const{mobile:n}=r.useContext(De),{logMessage:c,sendMessage:a,getUniqueId:i}=r.useContext(me),[s,x]=r.useState("matterbridge-"),[g,v]=r.useState(!1),[t,$]=r.useState(null),y=r.useRef(i()),M=d=>{d.preventDefault(),v(!0)},w=()=>{v(!1)},O=d=>{d.preventDefault(),v(!1);const l=d.dataTransfer.files[0];if(l){c("Plugins",`Installing package ${l.name}. Please wait...`);const m=new FormData;m.append("file",l),m.append("filename",l.name),fetch("./api/uploadpackage",{method:"POST",body:m}).then(b=>b.text()).then(b=>{c("Plugins",`Server response: ${b}`)}).catch(b=>{console.error("Error uploading plugin file:",b),c("Plugins",`Error installing package ${b}`)})}},q=d=>{const l=d.target.files&&d.target.files[0];if(l){c("Plugins",`Uploading package ${l.name}`);const m=new FormData;m.append("file",l),m.append("filename",l.name),fetch("./api/uploadpackage",{method:"POST",body:m}).then(b=>b.text()).then(b=>{c("Plugins",`Server response: ${b}`)}).catch(b=>{console.error("Error uploading plugin file:",b),c("Plugins",`Error uploading package ${b}`)})}},z=()=>{a({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:s,restart:!1}})},E=()=>{a({id:y.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:s}})},h=()=>{document.getElementById("file-upload")?.click()},p=()=>{a({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:s}})},u=d=>{d.preventDefault(),console.log("Right-clicked Upload button")},k=d=>{d.preventDefault(),console.log("Right-clicked Add button")},S=d=>{$(d.currentTarget)},j=d=>{d!==""&&x(d),$(null)},[Z,ee]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),Z?null:e.jsxs(je,{children:[e.jsxs(Ie,{children:[e.jsx(Se,{children:"Install plugins"}),e.jsx(nt,{onClose:()=>ee(!0)})]}),e.jsxs(Re,{onDragOver:M,onDragLeave:w,onDrop:O,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(ge,{value:s,onChange:d=>{x(d.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(B,{onClick:S,children:e.jsx(Ur,{})}),e.jsxs(rt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(C,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(C,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(C,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(C,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(C,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(C,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(C,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(C,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(C,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(C,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(C,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(C,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(C,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(C,{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(se,{onClick:z,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(se,{onClick:E,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(se,{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(se,{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:q})]})]})]})}const jn=r.memo(yn);function Je({status:n,enabledText:c="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const x=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?c:a??c});return i!==void 0?e.jsx(H,{title:i,children:x}):x}}function wn(n,c,a){const i=n?.[a],s=c?.[a];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Cn({name:n,title:c,columns:a,rows:i,getRowKey:s,footerLeft:x,footerRight:g,onRowClick:v}){const t=r.useRef(new WeakMap),$=r.useRef(1),y=d=>{if(typeof s=="string"&&d&&d[s]!=null)return d[s];if(typeof s=="function"){const b=s(d);if(b!=null)return b}const l=a?.[0]?.id;if(l&&d&&d[l]!=null)return d[l];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let m=t.current.get(d);return m||(m=`rk_${$.current++}`,t.current.set(d,m)),m},[M,w]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[O,q]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[z,E]=r.useState(!1),[h,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 l of a)l.hidden||(d[l.id]=l.required?!0:h[l.id]!==!1);return d},[a,h]),k=r.useMemo(()=>{if(!M||!O)return i;const d=a.find(m=>m.id===M);if(!d||d.noSort)return i;const l=i.map((m,b)=>({el:m,index:b}));return l.sort((m,b)=>{let T;return typeof d.comparator=="function"?T=d.comparator(m.el,b.el):T=wn(m.el,b.el,M),T!==0?O==="asc"?T:-T:m.index-b.index}),l.map(m=>m.el)},[i,M,O,a]),S=d=>{if(M!==d||!M){w(d),q("asc"),localStorage.setItem(`${n}_table_order_by`,d),localStorage.setItem(`${n}_table_order`,"asc");return}if(O==="asc"){q("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}w(null),q(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{E(!z)},Z=d=>{p(l=>{const m=a.find(te=>te.id===d);if(m&&m.required)return l;const b=u[d]!==!1,T={...l};b?T[d]=!1:delete T[d];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(T))}catch{}return T})},ee=()=>{p({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}E(!1)};return o&&console.log(`Rendering table ${n}${M&&O?` ordered by ${M}:${O}`:""}`),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(Oe,{open:z,onClose:(d,l)=>{l==="backdropClick"||l==="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:a.filter(d=>!d.hidden).map(d=>e.jsx(Ke,{control:e.jsx(qe,{disabled:!!d.required,checked:d.required?!0:u[d.id]!==!1,onChange:()=>Z(d.id)}),label:d.label},d.id))})}),e.jsxs(Ue,{children:[e.jsx(se,{onClick:ee,children:"Reset"}),e.jsx(se,{variant:"contained",onClick:d=>{if(d?.currentTarget&&typeof d.currentTarget.blur=="function")try{d.currentTarget.blur()}catch{}const l=document.activeElement;if(l&&l instanceof HTMLElement&&typeof l.blur=="function")try{l.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(B,{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(H,{title:`Configure ${n} columns`,children:e.jsx(ie,{path:To,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:a.map(d=>{if(d.hidden||!d.required&&u[d.id]===!1)return null;const l=!d.noSort,m=l&&M===d.id&&!!O;return e.jsxs("th",{onClick:l?()=>S(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:l?"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":l?m?O==="asc"?"ascending":"descending":"none":void 0,children:[d.label,m&&e.jsxs("span",{style:{marginLeft:6},children:[O==="asc"&&e.jsx(ie,{path:Ro,size:"15px"}),O==="desc"&&e.jsx(ie,{path:Ho,size:"15px"})]})]},d.id)})})}),e.jsx("tbody",{children:k.map((d,l)=>{const m=y(d);return e.jsx("tr",{className:l%2===0?"table-content-even":"table-content-odd",onClick:v?b=>v(d,m,b):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:v?"pointer":void 0},children:a.map(b=>{if(b.hidden||!b.required&&u[b.id]===!1)return null;const T=d[b.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:b.align||"left",padding:"5px 10px",margin:"0",maxWidth:b.maxWidth,whiteSpace:b.maxWidth?"nowrap":void 0,overflow:b.maxWidth?"hidden":void 0,textOverflow:b.maxWidth?"ellipsis":void 0},children:typeof b.render=="function"?b.render(T,m,d,b):typeof T=="boolean"?e.jsx(qe,{checked:T,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):b.format&&typeof T=="number"?b.format(T):T!=null?String(T):null},b.id)})},m)})})]})}),(x||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:x}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}function Sn(n){return r.memo(n)}const Lt=Sn(Cn);function nr(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Ze={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Ye={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},kn={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"},In="5px 10px 5px 10px",yt={},ve={},jt={},wt={};let Xe=[],Tt=[];const Dn=({open:n,onClose:c,plugin:a})=>{const{sendMessage:i,addListener:s,removeListener:x,getUniqueId:g}=r.useContext(me),v=r.useRef(g()),[t,$]=r.useState(a.configJson),[y,M]=r.useState(null),[w,O]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[q,z]=r.useState("");let E={};r.useEffect(()=>{const L=P=>{P.src==="Matterbridge"&&P.dst==="Frontend"&&(nr(P)&&P.id===v.current&&P.method==="/api/select/devices"&&P.response&&(o&&console.log(`ConfigPluginDialog (id: ${P.id}) received ${P.response.length} /api/select/devices:`,P.response),Xe=P.response),nr(P)&&P.id===v.current&&P.method==="/api/select/entities"&&P.response&&(o&&console.log(`ConfigPluginDialog (id: ${P.id}) received ${P.response.length} /api/select/entities:`,P.response),Tt=P.response))};return s(L,v.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",v.current),t&&y&&y.properties&&(Object.keys(y.properties).forEach(P=>{Object.keys(y.properties[P]).forEach(I=>{I.startsWith("ui:")&&(w[P]={},w[P][I]=y.properties[P][I],delete y.properties[P][I])})}),O(w)),a.name&&a.configJson&&a.schemaJson&&($(a.configJson),M(a.schemaJson),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',a.name)),()=>{x(L),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,t,a,x,y,i,w]);const h=(L,P)=>{E=L.formData},p=L=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",L.formData),$(L.formData),a.configJson=L.formData,a.restartRequired=!0,i({id:v.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:I,onKeyChange:F,onDropPropertyClick:J,disabled:de,schema:ae,children:K,registry:f,readonly:le,required:G}=L,{templates:D}=f,{RemoveButton:fe}=D.ButtonTemplates;if(!(pn in ae))return e.jsx(ne,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:K});const he=({target:re})=>F(re&&re.value);return e.jsxs(ne,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(ge,{id:`${P}-key`,name:`${P}-key`,required:G,disabled:de||le,defaultValue:I,onBlur:le?void 0:he,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(ne,{sx:{flex:1},children:K}),e.jsx(fe,{disabled:de||le,onClick:J(I),registry:f})]})}function k(L){const{children:P,description:I,displayLabel:F,errors:J,help:de,hidden:ae,registry:K,uiSchema:f}=L,le=cn(f),G=dn("WrapIfAdditionalTemplate",K,le);return ae?e.jsx("div",{style:{display:"none"},children:P}):e.jsx(ne,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(G,{...L,children:[F===!0&&I,P,J,de]})})}function S(L){const{description:P}=L;return P?e.jsx(pe,{sx:Ye,children:P}):null}function j(L){const{required:P,title:I}=L;return I?e.jsx(ne,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(pe,{sx:Ze,children:["Title ",I," ",P&&e.jsx("mark",{children:"***"})]})}):null}function Z(L){const{help:P}=L;return P?e.jsx(ne,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(pe,{sx:kn,children:P})}):null}function ee(L){const{errors:P}=L;return P?e.jsxs(ne,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(pe,{color:"error",sx:Mn,children:"Please fix the following errors:"}),e.jsx(st,{children:P.map((I,F)=>e.jsxs(Kr,{children:[e.jsx(_,{children:e.jsx(Gr,{color:"error"})}),e.jsx(X,{primary:I.stack})]},F))})]}):null}function d(L){const{errors:P}=L;return P?e.jsx(ne,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:P.map((I,F)=>e.jsxs(pe,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",I]},F))}):null}function l(L){const{id:P,name:I,_schema:F,_uiSchema:J,value:de,options:ae,label:K,type:f,placeholder:le,required:G,disabled:D,readonly:fe,autofocus:Ne,onChange:he,onChangeOverride:re,onBlur:ce,onFocus:He,_rawErrors:Ce,_hideError:it,_registry:V,_formContext:be}=L,A=({target:{value:Le}})=>he(Le===""?ae.emptyValue:Le),oe=({target:Le})=>ce(P,Le&&Le.value),Pe=({target:Le})=>He(P,Le&&Le.value);return e.jsx(ne,{sx:{padding:"0px",margin:"0px"},children:e.jsx(ge,{id:P,name:P,label:le&&le!==""?K:void 0,variant:"outlined",placeholder:le&&le!==""?le:K,required:G,disabled:D||fe,autoFocus:Ne,value:de||de===0?de:"",type:f,autoComplete:f==="password"?"current-password":I,onChange:re||A,onBlur:oe,onFocus:Pe,fullWidth:!0})})}function m(L){return console.log("ArrayFieldTitleTemplate:",L),null}function b(L){return console.log("ArrayFieldDescriptionTemplate:",L),null}function T(L){return console.log("ArrayFieldItemTemplate:",L),null}function te(L){const{canAdd:P,onAddClick:I,schema:F,title:J}=L,[de,ae]=r.useState(!1),[K,f]=r.useState(!1),[le,G]=r.useState(!1),[D,fe]=r.useState(""),Ne=V=>{fe(V.target.value)},he=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",D,"selectDevices:",Xe),ae(!de)},re=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",D,"selectEntities:",Tt),f(!K)},ce=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",D,"selectDevices:",Xe),G(!le)},He=V=>{ae(!1),F.selectFrom==="serial"?F.items.default=V.serial:F.selectFrom==="name"&&(F.items.default=V.name),I()},Ce=V=>{f(!1),F.selectEntityFrom==="name"?F.items.default=V.name:F.selectEntityFrom==="description"&&(F.items.default=V.description),I()},it=V=>{G(!1),F.selectDeviceEntityFrom==="name"?F.items.default=V.name:F.selectDeviceEntityFrom==="description"&&(F.items.default=V.description),I()};return e.jsxs(ne,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[J&&e.jsxs(ne,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[J&&e.jsx(pe,{sx:Ze,children:J}),P&&e.jsxs(ne,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[F.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(B,{onClick:he,size:"small",color:"primary",sx:_e,children:e.jsx(ut,{})})}),F.selectEntityFrom&&e.jsx(H,{title:"Add an entity from the list",children:e.jsx(B,{onClick:re,size:"small",color:"primary",sx:_e,children:e.jsx(ut,{})})}),F.selectDeviceEntityFrom&&e.jsx(H,{title:"Add a device entity from the list",children:e.jsx(B,{onClick:ce,size:"small",color:"primary",sx:_e,children:e.jsx(ut,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(B,{onClick:I,size:"small",color:"primary",sx:_e,children:e.jsx(St,{})})})]})]}),F.description&&e.jsx(pe,{sx:Ye,children:F.description}),L.items.map(V=>e.jsxs(ne,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(ne,{sx:{flexGrow:1,marginRight:"10px"},children:V.children}),e.jsx(B,{disabled:!V.hasMoveUp,onClick:V.onReorderClick(V.index,V.index-1),size:"small",color:"primary",sx:_e,children:e.jsx(Bt,{})}),e.jsx(B,{disabled:!V.hasMoveDown,onClick:V.onReorderClick(V.index,V.index+1),size:"small",color:"primary",sx:_e,children:e.jsx(Ut,{})}),e.jsx(B,{onClick:V.onDropIndexClick(V.index),size:"small",color:"primary",sx:_e,children:e.jsx(Ot,{})})]},V.index)),e.jsxs(Oe,{open:de,onClose:he,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ve,{children:"Select a device"}),e.jsxs(Ee,{children:[e.jsxs(ne,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(pe,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{fullWidth:!0,variant:"outlined",value:D,onChange:Ne,placeholder:"Enter serial or name"})]}),e.jsx(st,{dense:!0,children:Xe.filter(V=>V.serial.toLowerCase().includes(D.toLowerCase())||V.name.toLowerCase().includes(D.toLowerCase())).map((V,be)=>e.jsxs(gt,{onClick:()=>He(V),sx:yt,children:[V.icon==="wifi"&&e.jsx(_,{children:e.jsx(at,{style:ve})}),V.icon==="ble"&&e.jsx(_,{children:e.jsx(mt,{style:ve})}),V.icon==="hub"&&e.jsx(_,{children:e.jsx(ht,{style:ve})}),e.jsx(X,{primary:V.name,secondary:V.serial,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:wt}})]},be))})]}),e.jsx(Ue,{children:e.jsx(se,{onClick:he,children:"Close"})})]}),e.jsxs(Oe,{open:K,onClose:re,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ve,{children:"Select an entity"}),e.jsxs(Ee,{children:[e.jsxs(ne,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(pe,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{fullWidth:!0,variant:"outlined",value:D,onChange:Ne,placeholder:"Enter name or description"})]}),e.jsx(st,{dense:!0,children:Tt.filter(V=>V.name.toLowerCase().includes(D.toLowerCase())||V.description.toLowerCase().includes(D.toLowerCase())).map((V,be)=>e.jsxs(gt,{onClick:()=>Ce(V),sx:yt,children:[V.icon==="wifi"&&e.jsx(_,{children:e.jsx(at,{style:ve})}),V.icon==="ble"&&e.jsx(_,{children:e.jsx(mt,{style:ve})}),V.icon==="hub"&&e.jsx(_,{children:e.jsx(ht,{style:ve})}),V.icon==="component"&&e.jsx(_,{children:e.jsx(Qt,{style:ve})}),V.icon==="matter"&&e.jsx(_,{children:e.jsx(Kt,{style:ve})}),e.jsx(X,{primary:V.name,secondary:V.description,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:wt}})]},be))})]}),e.jsx(Ue,{children:e.jsx(se,{onClick:re,children:"Close"})})]}),e.jsxs(Oe,{open:le,onClose:ce,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ve,{children:["Select an entity for ",J]}),e.jsx(Ee,{children:e.jsx(st,{dense:!0,children:Xe.filter(V=>V.serial===J||V.name===J).map(V=>V.entities?.map((be,A)=>e.jsxs(gt,{onClick:()=>it(be),sx:yt,children:[be.icon==="wifi"&&e.jsx(_,{children:e.jsx(at,{style:ve})}),be.icon==="ble"&&e.jsx(_,{children:e.jsx(mt,{style:ve})}),be.icon==="hub"&&e.jsx(_,{children:e.jsx(ht,{style:ve})}),be.icon==="component"&&e.jsx(_,{children:e.jsx(Qt,{style:ve})}),be.icon==="matter"&&e.jsx(_,{children:e.jsx(Kt,{style:ve})}),e.jsx(X,{primary:be.name,secondary:be.description,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:wt}})]},A)))})}),e.jsx(Ue,{children:e.jsx(se,{onClick:ce,children:"Close"})})]})]})}function xe(L){const{onAddClick:P,schema:I,properties:F,title:J,description:de}=L,[ae,K]=r.useState(!1),[f,le]=r.useState(""),G=re=>{le(re.target.value)},D=()=>{K(!ae)},fe=re=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${re.serial}" for schema "${I.selectFrom}"`),K(!1);let ce="";I.selectFrom==="serial"?ce=re.serial:I.selectFrom==="name"&&(ce=re.name),z(ce),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ce}"`),P(I)()},Ne=()=>{P(I)()},he=!I.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${he} newkey "${q}"`),!he&&q!==""&&(o&&console.log("ObjectFieldTemplate: newkey",q,"properties",F),F.forEach(re=>{if(re.name==="newKey"&&re.content.key==="newKey"&&re.content.props.name==="newKey"&&re.content.props.onKeyChange&&q!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",q);const ce=q;z(""),re.content.props.onKeyChange(ce)}})),e.jsxs(ne,{sx:{margin:"0px",padding:he?"10px":"5px 10px 0px 10px",border:he?"none":"1px solid grey"},children:[I.title&&he&&e.jsx(ne,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(pe,{sx:Ze,children:I.title})}),J&&!he&&e.jsxs(ne,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(pe,{sx:Ze,children:J}),e.jsxs(ne,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[I.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(B,{onClick:D,size:"small",color:"primary",sx:_e,children:e.jsx(ut,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(B,{onClick:Ne,size:"small",color:"primary",sx:_e,children:e.jsx(St,{})})})]})]}),I.description&&e.jsx(ne,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(pe,{sx:Ye,children:I.description})}),F.map(({content:re,name:ce,hidden:He})=>!He&&e.jsxs(ne,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(I.properties[ce].type)?"0px":In,border:["object","array","boolean"].includes(I.properties[ce].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(I.properties[ce].type)&&e.jsx(pe,{sx:Ze,children:ce}),e.jsx(ne,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:re})]},ce)),e.jsxs(Oe,{open:ae,onClose:D,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ve,{children:"Select a device"}),e.jsxs(Ee,{children:[e.jsxs(ne,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(pe,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{fullWidth:!0,variant:"outlined",value:f,onChange:G,placeholder:"Enter serial or name"})]}),e.jsx(st,{dense:!0,children:Xe.filter(re=>re.serial.toLowerCase().includes(f.toLowerCase())||re.name.toLowerCase().includes(f.toLowerCase())).map((re,ce)=>e.jsxs(gt,{onClick:()=>fe(re),sx:yt,children:[re.icon==="wifi"&&e.jsx(_,{children:e.jsx(at,{style:ve})}),re.icon==="ble"&&e.jsx(_,{children:e.jsx(mt,{style:ve})}),re.icon==="hub"&&e.jsx(_,{children:e.jsx(ht,{style:ve})}),e.jsx(X,{primary:re.name,secondary:re.serial,primaryTypographyProps:{style:jt},secondaryTypographyProps:{style:wt}})]},ce))})]}),e.jsx(Ue,{children:e.jsx(se,{onClick:D,children:"Close"})})]})]})}function we(L){const{uiSchema:P}=L,{submitText:I,norender:F}=an(P);return F?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(se,{type:"submit",variant:"contained",color:"primary",children:I}),e.jsx(se,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function ke(L){const{className:P,disabled:I,onClick:F,registry:J,style:de,uiSchema:ae,...K}=L;return e.jsx(H,{title:"Remove the item",children:e.jsx(B,{disabled:I,size:"small",color:"primary",onClick:F,children:e.jsx(Ot,{})})})}function R(L){const{className:P,disabled:I,onClick:F,registry:J,uiSchema:de,...ae}=L;return e.jsx(H,{title:"Add an item",children:e.jsx(B,{size:"small",color:"primary",onClick:F,children:e.jsx(St,{})})})}function U(L){const{disabled:P,onClick:I,registry:F,style:J,uiSchema:de,...ae}=L;return e.jsx(H,{title:"Move up the item",children:e.jsx(B,{size:"small",color:"primary",onClick:I,children:e.jsx(Bt,{})})})}function N(L){const{disabled:P,onClick:I,registry:F,style:J,uiSchema:de,...ae}=L;return e.jsx(H,{title:"Move down the item",children:e.jsx(B,{size:"small",color:"primary",onClick:I,children:e.jsx(Ut,{})})})}function Q(L){const{id:P,name:I,value:F,schema:J,readonly:de,onChange:ae}=L,[K,f]=r.useState(),le=D=>{o&&console.log(`CheckboxWidget ${I} onChangeField:`,D),f(D&&D!==""?D:void 0)},G=()=>{o&&console.log(`CheckboxWidget onClick plugin="${a.name}" action="${I}" value="${K}"`),i({id:v.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:I,value:K,formData:E,id:P}}),J.buttonClose===!0?c():J.buttonSave===!0&&p({formData:t})};return J.buttonText&&J.description?e.jsxs(ne,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(pe,{sx:Ye,children:J.description}),e.jsx(se,{variant:"contained",color:"primary",onClick:()=>G(),children:J.buttonText})]}):J.buttonField&&J.description?e.jsxs(ne,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(pe,{sx:Ye,children:J.description}),e.jsx(ge,{id:I+"-input",name:I,label:J.textLabel,placeholder:J.textPlaceholder,onChange:D=>le(D.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(se,{id:I+"-button",variant:"contained",color:"primary",disabled:K===void 0,onClick:()=>G(),children:J.buttonField})]}):e.jsxs(ne,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[I&&e.jsxs(ne,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(pe,{sx:Ze,children:I}),e.jsx(qe,{checked:F,readOnly:de,onChange:()=>ae(!F),sx:{padding:"0px",margin:"0px"}})]}),J.description&&e.jsx(pe,{sx:Ye,children:J.description})]})}function W({schema:L,id:P,name:I,options:F,label:J,hideLabel:de,required:ae,disabled:K,placeholder:f,readonly:le,value:G,multiple:D,autofocus:fe,onChange:Ne,onBlur:he,onFocus:re,errorSchema:ce,rawErrors:He=[],registry:Ce,uiSchema:it,hideError:V,formContext:be,...A}){const{enumOptions:oe,enumDisabled:Pe,emptyValue:Le}=F;D=typeof D>"u"?!1:!!D;const At=D?[]:"",_t=typeof G>"u"||D&&G.length<1||!D&&G===At,Sr=({target:{value:Ae}})=>Ne(Ft(Ae,oe,Le)),kr=({target:Ae})=>he(P,Ft(Ae&&Ae.value,oe,Le)),Mr=({target:Ae})=>re(P,Ft(Ae&&Ae.value,oe,Le)),qt=sn(G,oe,D),{InputLabelProps:Ir,SelectProps:Dr,autocomplete:Pr,...Lr}=A,$r=!D&&L.default===void 0;return e.jsxs(ge,{id:P,name:P,value:!_t&&typeof qt<"u"?qt:At,required:ae,disabled:K||le,autoFocus:fe,autoComplete:Pr,placeholder:f,error:He.length>0,onChange:Sr,onBlur:kr,onFocus:Mr,...Lr,select:!0,InputLabelProps:{...Ir,shrink:!_t},SelectProps:{...Dr,multiple:D},"aria-describedby":ln(P),children:[$r&&e.jsx(C,{value:"",children:f}),Array.isArray(oe)&&oe.map(({value:Ae,label:Wr},zt)=>{const Nr=Array.isArray(Pe)&&Pe.indexOf(Ae)!==-1;return e.jsx(C,{value:String(zt),disabled:Nr,children:Wr},zt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(Oe,{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:w,validator:nn,templates:{FieldTemplate:k,BaseInputTemplate:l,TitleFieldTemplate:j,DescriptionFieldTemplate:S,FieldHelpTemplate:Z,FieldErrorTemplate:d,ErrorListTemplate:ee,WrapIfAdditionalTemplate:u,ArrayFieldTitleTemplate:m,ArrayFieldDescriptionTemplate:b,ArrayFieldItemTemplate:T,ArrayFieldTemplate:te,ObjectFieldTemplate:xe,ButtonTemplates:{SubmitButton:we,RemoveButton:ke,AddButton:R,MoveUpButton:U,MoveDownButton:N}},widgets:{CheckboxWidget:Q,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,a=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(c===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function Pn({storeId:n,setStoreId:c}){const{online:a,sendMessage:i,addListener:s,removeListener:x,getUniqueId:g}=r.useContext(me),{showConfirmCancelDialog:v}=r.useContext(De),t=r.useRef(g()),[$,y]=r.useState(null),[M,w]=r.useState(null),[O,q]=r.useState([]),z=[{label:"Name",id:"name",required:!0,render:(N,Q,W,L)=>e.jsx(H,{title:`Plugin path ${W.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(W),children:W.name})})},{label:"Description",id:"description",render:(N,Q,W,L)=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d(W),children:W.description})})},{label:"Version",id:"version",render:(N,Q,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:(N,Q,W,L)=>e.jsx(e.Fragment,{children:W.author?W.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(N,Q,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:(N,Q,W,L)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[M&&M.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(B,{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,{})})}),M&&M.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(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>Z(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(B,{disabled:W.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ke(W),size:"small",children:e.jsx(Jr,{})})}),M&&!M.readOnly&&e.jsx(H,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{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(B,{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(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ee(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(B,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>m(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(B,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>b(W),size:"small",children:e.jsx(Vt,{})})}),W.latestVersion!==void 0&&W.latestVersion!==W.version&&M&&!M.readOnly&&e.jsx(H,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>k(W),size:"small",children:e.jsx(Fe,{})})}),W.version.includes("-dev-")&&W.devVersion!==void 0&&W.devVersion!==W.version&&M&&!M.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(B,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>S(W),size:"small",children:e.jsx(Fe,{})})}),M&&!M.readOnly&&e.jsx(H,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>l(W),size:"small",children:e.jsx(Et,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(N,Q,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(Je,{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(Je,{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(Je,{status:W.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{status:W.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Je,{status:W.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Je,{status:W.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const N=Q=>{o&&console.log("HomePlugins received WebSocket Message:",Q),Q.method==="refresh_required"&&Q.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${Q.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):Q.method==="refresh_required"&&Q.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${Q.response.changed} and setting matter id ${Q.response.matter?.id}`),q(W=>{const L=W.findIndex(I=>I.matter?.id===Q.response.matter?.id);if(L<0)return o&&console.log(`HomePlugins received refresh_required: changed=${Q.response.changed} and matter id ${Q.response.matter?.id} not found`),W;o&&console.log(`HomePlugins received refresh_required: changed=${Q.response.changed} set matter id ${Q.response.matter?.id}`);const P=[...W];return P[L]={...P[L],matter:Q.response.matter},P})):Q.method==="refresh_required"&&Q.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${Q.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Q.id===t.current&&Q.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${Q.id}) received settings:`,Q.response),y(Q.response.systemInformation),w(Q.response.matterbridgeInformation)):Q.id===t.current&&Q.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${Q.id}) received ${Q.response.length} plugins:`,Q.response),q(Q.response))};return s(N,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{x(N),o&&console.log("HomePlugins removed WebSocket listener")}},[s,x,i]),r.useEffect(()=>{a&&(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:{}}))},[a,i]);const E=r.useRef(null),h=(N,Q,W,L)=>{o&&console.log(`handleActionWithConfirmCancel ${W} ${L.name}`),E.current=L,v(N,Q,W,p,u)},p=N=>{o&&console.log(`handleConfirm action confirmed ${N} ${E.current?.name}`),N==="remove"&&E.current?j(E.current):N==="disable"&&E.current&&ee(E.current),E.current=null},u=N=>{o&&console.log(`handleCancel action canceled ${N} ${E.current?.name}`),E.current=null},k=N=>{o&&console.log("handleUpdatePlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name,restart:!1}})},S=N=>{o&&console.log("handleUpdateDevPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name+"@dev",restart:!1}})},j=N=>{o&&console.log("handleRemovePlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},Z=N=>{o&&console.log("handleRestartPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},ee=N=>{o&&console.log("handleEnableDisablePlugin plugin:",N.name,"enabled:",N.enabled),N.enabled===!0?(N.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})):(N.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}}))},d=N=>{o&&console.log(`handleHomepagePlugin plugin: ${N.name} homepage: ${N.homepage}`),N.homepage&&window.open(N.homepage,"_blank")},l=N=>{o&&console.log("handleSponsorPlugin plugin:",N.name,"funding:",N.funding),N.funding&&window.open(N.funding,"_blank")},m=N=>{o&&console.log("handleHelpPlugin plugin:",N.name,"help:",N.help),N.help&&window.open(N.help,"_blank")},b=N=>{o&&console.log("handleChangelogPlugin plugin:",N.name,"changelog:",N.changelog),N.changelog&&window.open(N.changelog,"_blank")},[T,te]=r.useState(),[xe,we]=r.useState(!1),ke=N=>{o&&console.log("handleConfigPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),te(N),R()},R=()=>{we(!0)},U=()=>{we(!1)};return o&&console.log("HomePlugins rendering..."),a?e.jsxs(je,{children:[T&&e.jsx(Dn,{open:xe,onClose:U,plugin:T}),e.jsx(Lt,{name:"Plugins",columns:z,rows:O,footerRight:"",footerLeft:""})]}):e.jsx(Te,{})}const Ln=r.memo(Pn),$n=n=>`${n.pluginName}::${n.serial}`;function Wn({storeId:n,setStoreId:c}){const{online:a,sendMessage:i,addListener:s,removeListener:x,getUniqueId:g}=r.useContext(me),[v,t]=r.useState(!1),[$,y]=r.useState(!0),[M,w]=r.useState(null),[O,q]=r.useState([]),[z,E]=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:(d,l,m,b)=>m.reachable===!0?"Online":m.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(d,l)=>{const m=d.reachable===!0?1:d.reachable===!1?0:-1,b=l.reachable===!0?1:l.reachable===!1?0:-1;return m-b}},{label:"Power",id:"powerSource",render:(d,l,m,b)=>m.powerSource==="ac"||m.powerSource==="dc"?e.jsx(gr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):m.powerSource==="ok"?e.jsx(Mt,{fontSize:"small",sx:{color:"green"}}):m.powerSource==="warning"?e.jsx(Mt,{fontSize:"small",sx:{color:"yellow"}}):m.powerSource==="critical"?e.jsx(Mt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(d,l,m,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[m.matter!==void 0?e.jsx(H,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{onClick:()=>c(n===m.matter?.id?M?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:m.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:yr(m.matter)},children:e.jsx(pr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),m.configUrl?e.jsx(H,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{onClick:()=>window.open(m.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"}}),m.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:m.selected,onChange:T=>ee(T,m),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],Z=r.useCallback(d=>{d.selected=void 0;const l=O.find(T=>T.name===d.pluginName);if(!l)return console.error(`HomeDevices isSelected: plugin ${d.pluginName} not found for device ${d.name} `),d.selected;const m=l.schemaJson?.properties?.whiteList?.selectFrom;let b=l.configJson.postfix;return b===""&&(b=void 0),l.hasWhiteList===!0&&l.hasBlackList===!0&&m&&(d.selected=!0,m==="serial"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&l.configJson.whiteList.includes(b?d.serial.replace("-"+b,""):d.serial)&&(d.selected=!0),m==="serial"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&!l.configJson.whiteList.includes(b?d.serial.replace("-"+b,""):d.serial)&&(d.selected=!1),m==="serial"&&l.configJson.blackList&&l.configJson.blackList.length>0&&l.configJson.blackList.includes(b?d.serial.replace("-"+b,""):d.serial)&&(d.selected=!1),m==="name"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&l.configJson.whiteList.includes(d.name)&&(d.selected=!0),m==="name"&&l.configJson.whiteList&&l.configJson.whiteList.length>0&&!l.configJson.whiteList.includes(d.name)&&(d.selected=!1),m==="name"&&l.configJson.blackList&&l.configJson.blackList.length>0&&l.configJson.blackList.includes(d.name)&&(d.selected=!1)),d.selected},[O]);r.useEffect(()=>{const d=l=>{if(o&&console.log("HomeDevices received WebSocket Message:",l),l.method==="refresh_required"&&l.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${l.response.changed} and sending /api/plugins request`),i({id:S.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):l.method==="refresh_required"&&l.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${l.response.changed} and setting matter id ${l.response.matter?.id}`),k(m=>{const b=m.findIndex(te=>te.name.replaceAll(" ","")===l.response.matter?.id);if(b<0)return o&&console.debug(`HomeDevices: matter id ${l.response.matter?.id} not found`),m;const T=[...m];return T[b]={...T[b],matter:l.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${l.response.changed} and set matter id ${l.response.matter?.id}`),T})):l.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):l.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):l.method==="state_update"&&l.response.plugin&&l.response.serialNumber&&l.response.cluster.includes("BasicInformation")&&l.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${l.response.plugin} serial ${l.response.serialNumber} value ${l.response.value}`),E(m=>{const b=m.findIndex(T=>T.pluginName===l.response.plugin&&T.serial===l.response.serialNumber);return b<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${l.response.plugin} serial ${l.response.serialNumber}`),m):(m[b]={...m[b],reachable:l.response.value},[...m])})),l.id===S.current&&l.method==="/api/settings")o&&console.log(`HomeDevices (id: ${l.id}) received settings:`,l.response),w(l.response),t(l.response.matterbridgeInformation.restartRequired||l.response.matterbridgeInformation.fixedRestartRequired);else if(l.id===S.current&&l.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${l.id}) received ${l.response?.length} plugins:`,l.response),l.response){let m=!0;for(const b of l.response)b.enabled===!0&&(b.loaded!==!0||b.started!==!0||b.error===!0)&&(m=!1);if(!m)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),q(l.response),E([]),p([]),i({id:S.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const b of l.response)b.enabled===!0&&b.loaded===!0&&b.started===!0&&b.error!==!0&&(i({id:S.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:b.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${b.name}`))}}else if(l.id===S.current&&l.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${l.id}) received ${l.response?.length} devices:`,l.response),l.response){for(const m of l.response)m.selected=Z(m);E(l.response)}}else l.id===S.current&&l.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${l.id}) received ${l.response?.length} selectDevices for plugin ${l.response&&l.response.length>0?l.response[0].pluginName:"without select devices"}:`,l.response),l.response&&l.response.length>0&&p(m=>{const b=m.filter(te=>te.pluginName!==l.response[0].pluginName),T=l.response.map(te=>({...te,selected:Z(te)}));return[...b,...T]}))};return s(d,S.current),o&&console.log(`HomeDevices added WebSocket listener id ${S.current}`),()=>{x(d),o&&console.log("HomeDevices removed WebSocket listener")}},[O,s,x,i,Z]),r.useEffect(()=>{if(z.length===0&&h.length===0){k([]);return}o&&console.log(`HomeDevices mixing devices (${z.length}) and selectDevices (${h.length})`);const d=[];for(const l of z)d.push(l);for(const l of h)z.find(m=>m.pluginName===l.pluginName&&m.serial.includes(l.serial))||d.push(l);d.length>0&&(k(d),o&&console.log(`HomeDevices mixed ${d.length} devices and selectDevices`))},[O,z,h,k]),r.useEffect(()=>{a&&(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:{}}))},[a,i]);const ee=(d,l)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${d.target.checked} for device ${l.name} serial ${l.serial}`),z.findIndex(m=>m.pluginName===l.pluginName&&m.serial===l.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${l.name} serial ${l.serial} not found in devices, trying in mixedDevices`),k(m=>{const b=m.findIndex(T=>T.pluginName===l.pluginName&&T.serial===l.serial);return b<0?(console.error(`handleCheckboxChange: device ${l.name} serial ${l.serial} not found in mixedDevices`),m):(m[b]={...m[b],selected:d.target.checked},[...m])})):E(m=>{const b=m.findIndex(T=>T.pluginName===l.pluginName&&T.serial===l.serial);return b<0?(console.error(`handleCheckboxChange: device ${l.name} serial ${l.serial} not found in devices`),m):(m[b]={...m[b],selected:d.target.checked},[...m])}),d.target.checked?i({id:S.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:l.pluginName,serial:l.serial,name:l.name}}):i({id:S.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:l.pluginName,serial:l.serial,name:l.name}})};return o&&console.log("HomeDevices rendering..."),a?e.jsx(je,{style:{flex:"1 1 auto"},children:e.jsx(Lt,{name:"Devices",getRowKey:$n,rows:u,columns:j,footerLeft:$?"Waiting for the plugins to fully load...":`Registered devices: ${z.length.toString()}/${u.length.toString()}`,footerRight:v?"Restart required":""})}):e.jsx(Te,{})}const Nn=r.memo(Wn);function dt({children:n,style:c,name:a}){const{setCurrentPage:i}=r.useContext(De);i(a),o&&console.log(`MbfPage: current page set to ${a}`);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 Fn=()=>"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 Tn(){const{messages:n,logAutoScroll:c}=r.useContext(br),[a,i]=r.useState(!1),s=r.useRef(null),x=r.useRef(0),g=r.useRef(null),v=r.useMemo(()=>Fn(),[]),t=w=>i(!0),$=w=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${c.current} isHovering: ${a}`),c.current&&!a&&!v){const w=Date.now();w-x.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),x.current=w,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"}),x.current=Date.now()},1e3))}},[n,c,a,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"}},M=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:$,children:[n.map((w,O)=>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:M(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})]},O)),e.jsx("div",{ref:s})]})})}const jr=r.memo(Tn);function Rn(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[a,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),{online:s,logAutoScroll:x}=r.useContext(me);return o&&console.log("HomeLogs rendering..."),s?e.jsxs(je,{style:{flex:"1 1 auto"},children:[e.jsxs(Ie,{children:[e.jsx(Se,{children:"Logs"}),e.jsxs(Se,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',a===""?"*":a,'" Scroll: ',x.current?"auto":"manual"]})]}),e.jsx(Re,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(jr,{})})]}):e.jsx(Te,{})}const Hn=r.memo(Rn);function On(){const{online:n}=r.useContext(me);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(je,{children:[e.jsx(Ie,{children:e.jsx(Se,{children:"Frontend Update"})}),e.jsxs(Re,{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(se,{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(Te,{})}const Vn=r.memo(On);function En({changelog:n}){const{online:c}=r.useContext(me);return o&&console.log("HomeShowChangelog rendering..."),c?e.jsxs(je,{children:[e.jsx(Ie,{children:e.jsx(Se,{children:"Matterbridge Update"})}),e.jsxs(Re,{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(se,{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(se,{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(se,{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(se,{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(Te,{})}const An=r.memo(En);function _n({matterbridgeInfo:n}){const{mobile:c}=r.useContext(De);o&&console.log("MatterbridgeInfoTable:",n);const a=["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(je,{style:ue&&c?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ie,{children:[e.jsx(Se,{children:"Matterbridge info"}),e.jsx(nt,{onClose:()=>s(!0)})]}),e.jsx(Re,{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(([x,g])=>!a.includes(x)&&g!==null&&g!==void 0&&g!=="").map(([x,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:x.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(vr,{value:typeof g!="string"?g.toString():g,maxChars:24})})]},x))})]})})]}))}const qn=r.memo(_n);function zn(){const[n,c]=r.useState(null),[a,i]=r.useState(null),[s,x]=r.useState([]),[g]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[v,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[$,y]=r.useState(""),[M,w]=r.useState(!1),[O,q]=r.useState(!1),[z,E]=r.useState(null),{mobile:h}=r.useContext(De),{addListener:p,removeListener:u,online:k,sendMessage:S,getUniqueId:j}=r.useContext(me),Z=r.useRef(j());return r.useEffect(()=>{const ee=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`),E(null),x([]),S({id:Z.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:Z.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===Z.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),q(!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===Z.current&&(o&&console.log("Home received plugins:",d.response),x(d.response))};return p(ee,Z.current),o&&console.log(`Home added WebSocket listener id ${Z.current}`),()=>{u(ee),o&&console.log("Home removed WebSocket listener")}},[p,u,S]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${z}`),a?.bridgeMode==="bridge"&&!z&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),E("Matterbridge")),a?.bridgeMode==="childbridge"&&!z&&s){for(const ee of s)if(ee.matter?.id){o&&console.log(`Home storeId effect set storeId to ${ee.matter.id}`),E(ee.matter.id);break}}},[a,s,z]),r.useEffect(()=>{k&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),S({id:Z.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:Z.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[k,S]),o&&console.log("Home rendering..."),!k||!n||!a?e.jsx(Te,{}):e.jsxs(dt,{name:"Home",style:ue&&h?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(ue&&!h||!ue)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(or,{id:z}),e.jsx(tr,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:ue&&h?"10px":"20px"},children:[O&&e.jsx(Vn,{}),M&&e.jsx(An,{changelog:$}),ue&&h&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(or,{id:z}),e.jsx(tr,{systemInfo:n,compact:!0}),e.jsx(qn,{matterbridgeInfo:a})]}),g&&!a.readOnly&&e.jsx(jn,{}),g&&e.jsx(Ln,{storeId:z,setStoreId:E}),v==="devices"&&e.jsx(Nn,{storeId:z,setStoreId:E}),v==="logs"&&e.jsx(Hn,{})]})]})}const Un=r.memo(zn),Ct=!1,ir={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Bn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Qn={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"},Kn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Gn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Jn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Zn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Yn={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)"},Xn=[256,257,268,269],ei=[266,267],ti=[259,260,261,271,272],ri=[256,257,268,269,266,267,259,260,261,272];function Y({icon:n,iconColor:c,cluster:a,value:i,unit:s,prefix:x}){return o&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),x=x??!1,e.jsxs(ne,{sx:ir,children:[n&&r.cloneElement(n,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...Bn,color:c??"var(--primary-color)"}}),e.jsxs(ne,{sx:{...ir,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&x===!0&&e.jsx(pe,{sx:sr,children:s},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(pe,{sx:Qn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),s&&x===!1&&e.jsx(pe,{sx:sr,children:s},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function oi({device:n,endpoint:c,id:a,deviceType:i,clusters:s}){const x=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";o&&console.log(`Device "${n.name}" endpoint "${c}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const v=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(v){let t="";v.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`),ri.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("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Y,{icon:t.attributeLocalValue===!0?e.jsx(at,{}):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(Y,{icon:e.jsx(Mt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(Y,{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(Y,{icon:e.jsx(ie,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Xn.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Y,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),ei.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Y,{icon:e.jsx(ie,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),ti.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(Gt,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Y,{icon:e.jsx(oo,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Y,{icon:e.jsx(ie,{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(Y,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{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(Y,{icon:e.jsx(ie,{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(Y,{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(Y,{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(Y,{icon:e.jsx(ie,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{icon:e.jsx(ie,{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(Y,{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(Y,{icon:e.jsx(ie,{path:en,size:"40px",color:"var(--primary-color)"}),cluster:t,value:x[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Y,{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(Y,{icon:e.jsx(ie,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{icon:e.jsx(wo,{}),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(Y,{icon:e.jsx(Co,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(ne,{sx:Kn,children:e.jsx(pe,{sx:Gn,children:g})}),e.jsx(ne,{sx:Jn,children:e.jsx(pe,{sx:Zn,children:n.name})}),e.jsxs(ne,{sx:Yn,children:[o&&e.jsx(pe,{sx:Rt,children:c}),e.jsx(pe,{sx:Rt,children:a}),o&&e.jsxs(pe,{sx:Rt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function ni({filter:n}){const{online:c,sendMessage:a,addListener:i,removeListener:s,getUniqueId:x}=r.useContext(me),[g,v]=r.useState([]),[t,$]=r.useState({}),[y,M]=r.useState({}),[w,O]=r.useState({}),q=r.useRef(x()),z=r.useCallback(p=>{(o||Ct)&&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||Ct)&&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=w[u.serial]?.find(S=>S.endpoint===p.response.number.toString()&&S.clusterName===p.response.cluster&&S.attributeName===p.response.attribute);if(!k){(o||Ct)&&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}k.attributeValue=String(p.response.value),k.attributeLocalValue=p.response.value,O({...w}),(o||Ct)&&console.log(`DevicesIcons updated "${k.clusterName}.${k.attributeName}" for device "${u.name}" serial "${u.serial}" to "${k.attributeValue}"`)},[w,g]),E=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 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)&&w[u].push(k);$({...t}),M({...y}),O({...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`),a({id:q.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)z(u);else if(u.method==="/api/devices"&&u.response){o&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),v(u.response),$({}),M({}),O({});for(const k of u.response)o&&console.log("DevicesIcons sending /api/clusters"),a({id:q.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&&E(u)};return i(p,q.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"),a({id:q.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,a]);const h=r.memo(oi);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:w[p.serial].filter(S=>S.endpoint===u.endpoint)},`${p.pluginName}-${p.uniqueId}-${u.endpoint}-${u.id}-${k.toString()}`))))})}const ii=r.memo(ni),si=[{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,a,i)=>a.configUrl?e.jsx(B,{onClick:()=>window.open(a.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(mr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],li=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,c,a,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,render:(n,c,a,i)=>e.jsx(H,{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)})})}],ai=n=>`${n.pluginName}::${n.uniqueId}`,ci=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function di({filter:n}){const{online:c,sendMessage:a,addListener:i,removeListener:s,getUniqueId:x}=r.useContext(me),[g,v]=r.useState([]),[t,$]=r.useState(g),[y,M]=r.useState([]),[w,O]=r.useState(0),[q,z]=r.useState(null),[E,h]=r.useState(null),[p,u]=r.useState(null),[k,S]=r.useState(null),j=r.useRef(x()),Z=r.useRef(t),ee=r.useCallback(l=>{o&&console.log(`DevicesTable received state_update "${l.response.cluster}.${l.response.attribute}" for "${l.response.id}:${l.response.number}": "${l.response.value}"`,l.response);const m=Z.current.find(b=>b.pluginName===l.response.plugin&&b.uniqueId===l.response.uniqueId);if(!m){o&&console.warn(`DevicesTable updater device of plugin "${l.response.plugin}" serial "${l.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(q&&E&&m.pluginName===q&&m.uniqueId===k&&l.response.number.toString()===E){const b=y.find(T=>T.endpoint===l.response.number.toString()&&T.clusterName===l.response.cluster&&T.attributeName===l.response.attribute);if(!b){o&&console.warn(`DevicesTable updater cluster ${l.response.cluster}.${l.response.attribute} for device "${m.name}" serial "${m.serial}" not found in clusters`);return}b.attributeValue=typeof l.response.value=="object"?JSON.stringify(l.response.value,void 0,1).replaceAll('"',""):String(l.response.value),b.attributeLocalValue=l.response.value,M([...y]),o&&console.log(`DevicesTable updated attribute ${b.clusterName}.${b.attributeName} for device "${m.name}" serial "${m.serial}" to "${b.attributeValue}"`)}},[y,E,q,k]);r.useEffect(()=>{const l=m=>{if(o&&console.log("DevicesTable received WebSocket Message:",m),m.method==="refresh_required"&&m.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${m.response.changed} and sending /api/devices request`),a({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(m.method==="state_update"&&m.response)ee(m);else if(m.method==="/api/devices")o&&console.log(`DevicesTable received ${m.response.length} devices:`,m.response),v(m.response);else if(m.method==="/api/clusters"){o&&console.log(`DevicesTable received ${m.response.clusters.length} clusters for plugin ${m.response.plugin}:`,m.response),M(m.response.clusters);const b={};for(const T of m.response.clusters)o&&console.log("Cluster:",T.endpoint),b[T.endpoint]?b[T.endpoint]++:b[T.endpoint]=1;O(Object.keys(b).length)}};return i(l,j.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{s(l),o&&console.log("DevicesTable removed WebSocket listener")}},[a,i,s,ee]),r.useEffect(()=>{c&&(o&&console.log("DevicesTable sending api requests with id ",j.current),a({id:j.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:j.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,a]),r.useEffect(()=>{q&&E&&(o&&console.log("DevicesTable sending /api/clusters"),a({id:j.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:q,endpoint:Number(E)}}))},[q,E,a]),r.useEffect(()=>{if(n===""){$(g),Z.current=g;return}const l=g.filter(m=>m.name.toLowerCase().includes(n)||m.serial.toLowerCase().includes(n));$(l),Z.current=l},[g,n]);const d=l=>{if(l.uniqueId===k){S(null),z(null),h(null),u(null);return}S(l.uniqueId),z(l.pluginName),h(l.endpoint?l.endpoint.toString():null),u(l.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:`${q&&E?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Lt,{name:"Registered devices",getRowKey:ai,onRowClick:d,rows:t,columns:si,footerLeft:`Total devices: ${t.length.toString()}`})}),q&&E&&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(Lt,{name:"Clusters",title:p||"",getRowKey:ci,rows:y,columns:li,footerLeft:`Total child endpoints: ${w-1}`})})]}):e.jsx(Te,{})}const pi=r.memo(di);function ui(){const{online:n}=r.useContext(me),[c,a]=r.useState(""),[i,s]=r.useState("icon");r.useEffect(()=>{const v=localStorage.getItem("devicesFilter");v&&a(v)},[]),r.useEffect(()=>{const v=localStorage.getItem("devicesViewMode");v&&s(v)},[]);const x=v=>{a(v.target.value.toLowerCase()),localStorage.setItem("devicesFilter",v.target.value.toLowerCase())},g=v=>{s(v),localStorage.setItem("devicesViewMode",v)};return o&&console.log("Devices rendering..."),n?e.jsxs(dt,{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(ne,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(pe,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{variant:"outlined",value:c,onChange:x,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(ne,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(pe,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(B,{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(B,{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(pi,{filter:c}),i==="icon"&&e.jsx(ii,{filter:c})]}):e.jsx(Te,{})}const gi=r.memo(ui);function mi(){const{logLength:n,logAutoScroll:c,setMessages:a,setLogFilterLevel:i,setLogFilterSearch:s,online:x,filterLogMessages:g}=r.useContext(me),[v,t]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[$,y]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[M,w]=r.useState(n.current.toString()),[O,q]=r.useState(c.current),z=k=>{const S=k.target.value;t(S),i(S),g(S,$),localStorage.setItem("logFilterLevel",S),o&&console.log("handleLogFilterLevelChange called with value:",S)},E=k=>{const S=k.target.value;y(S),s(S),g(v,S),localStorage.setItem("logFilterSearch",S),o&&console.log("handleLogFilterSearchChange called with value:",S)},h=k=>{const S=k.target.checked;q(S),c.current=S,g(v,$),localStorage.setItem("logAutoScroll",S?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",S)},p=k=>{const S=k.target.value;w(S),n.current=Number(S),localStorage.setItem("logLength",S),o&&console.log("handleLogLengthChange called with value:",S)},u=()=>{o&&console.log("handleClearLogsClick called"),a([])};return o&&console.log("Logs rendering..."),x?e.jsxs(dt,{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:v,onChange:z,children:[e.jsx(C,{value:"debug",children:"Debug"}),e.jsx(C,{value:"info",children:"Info"}),e.jsx(C,{value:"notice",children:"Notice"}),e.jsx(C,{value:"warn",children:"Warn"}),e.jsx(C,{value:"error",children:"Error"}),e.jsx(C,{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(ge,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:$,onChange:E,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(Ke,{control:e.jsx(qe,{checked:O,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:M,onChange:p,children:[e.jsx(C,{value:100,children:"100"}),e.jsx(C,{value:200,children:"200"}),e.jsx(C,{value:500,children:"500"}),e.jsx(C,{value:1e3,children:"1000"})]}),e.jsx(H,{title:"Clear the logs",children:e.jsx(se,{onClick:u,endIcon:e.jsx(Ot,{}),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(Te,{})}const hi=r.memo(mi),fi=({open:n,ip:c,onClose:a,onSave:i})=>{const s=c?c.split(".").slice(0,3).join(".")+".1":"",[x,g]=r.useState("dhcp"),[v,t]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:s,dns:s}),$=w=>O=>{t({...v,[w]:O.target.value})},y=()=>{a()},M=()=>{i({type:x,...v}),a()};return e.jsxs(Oe,{open:n,onClose:(w,O)=>{O==="backdropClick"||O==="escapeKeyDown"||a()},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(ye,{component:"legend",children:"Select IP Configuration"}),e.jsxs(xr,{row:!0,value:x,onChange:w=>g(w.target.value),children:[e.jsx(Ke,{value:"dhcp",control:e.jsx(Pt,{}),label:"DHCP"}),e.jsx(Ke,{value:"static",control:e.jsx(Pt,{}),label:"Static"})]})]}),x==="static"&&e.jsxs(ze,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(ze,{size:6,children:e.jsx(ge,{label:"IP Address",fullWidth:!0,value:v.ip,onChange:$("ip")})}),e.jsx(ze,{size:6,children:e.jsx(ge,{label:"Subnet Mask",fullWidth:!0,value:v.subnet,onChange:$("subnet")})}),e.jsx(ze,{size:6,children:e.jsx(ge,{label:"Gateway",fullWidth:!0,value:v.gateway,onChange:$("gateway")})}),e.jsx(ze,{size:6,children:e.jsx(ge,{label:"DNS Server",fullWidth:!0,value:v.dns,onChange:$("dns")})})]})]}),e.jsxs(Ue,{children:[e.jsx(se,{onClick:y,children:"Cancel"}),e.jsx(se,{variant:"contained",onClick:M,children:"Save"})]})]})},xi=({open:n,onClose:c,onSave:a})=>{const[i,s]=r.useState(""),[x,g]=r.useState(""),v=O=>{s(O.target.value)},t=O=>{g(O.target.value)},$=i.length>0&&i===x,y=()=>{c()},M=()=>{$&&(a(i),c())},w=()=>{a(""),c()};return e.jsxs(Oe,{open:n,onClose:(O,q)=>{q==="backdropClick"||q==="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(ge,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:v})}),e.jsx(ze,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:x,onChange:t,error:x!==""&&i!==x,helperText:x!==""&&i!==x?"Passwords do not match":""})})]})})}),e.jsxs(Ue,{children:[e.jsx(se,{onClick:y,children:"Cancel"}),e.jsx(se,{variant:"contained",onClick:M,disabled:!$,children:"Change"}),e.jsx(se,{variant:"contained",onClick:w,children:"Reset"})]})]})};function et(n=1e3){let c=null;const a=(i=>{c!==null&&window.clearTimeout(c),c=window.setTimeout(()=>{i(),c=null},n)});return a.cancel=()=>{c!==null&&(window.clearTimeout(c),c=null)},a}const $t=330;function bi(){const{mobile:n}=r.useContext(De),{online:c,addListener:a,removeListener:i,sendMessage:s,getUniqueId:x}=r.useContext(me),[g,v]=r.useState(null),[t,$]=r.useState(null),y=r.useRef(x());return r.useEffect(()=>{const M=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`),s({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),$(w.response.systemInformation))};return a(M,y.current),o&&console.log("Settings added WebSocket listener"),()=>{i(M),o&&console.log("Settings removed WebSocket listener")}},[a,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(Te,{}):e.jsx(dt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:ue&&n?"10px":"20px"},children:[e.jsx(vi,{matterbridgeInfo:g,systemInfo:t}),e.jsx(yi,{matterbridgeInfo:g}),e.jsx(ji,{matterbridgeInfo:g}),e.jsx(wi,{systemInfo:t})]})})}function vi({matterbridgeInfo:n,systemInfo:c}){const{sendMessage:a,getUniqueId:i}=r.useContext(me),[s,x]=r.useState("bridge"),[g,v]=r.useState("Info"),[t,$]=r.useState(!1),[y,M]=r.useState("dark"),[w,O]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[q,z]=r.useState(localStorage.getItem("homePageMode")??"devices"),[E,h]=r.useState(localStorage.getItem("virtualMode")??"outlet"),p=r.useRef(i()),[u,k]=r.useState(!1),S=()=>k(!1),j=R=>{o&&console.log("handleSaveNetConfig called with config:",R),a({id:p.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:R})},[Z,ee]=r.useState(!1),d=()=>ee(!1),l=R=>{o&&console.log("handleSaveChangePassword called with password:",R),a({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:R}}),Fi(R)};r.useEffect(()=>{n&&(x(n.bridgeMode==="bridge"?"bridge":"childbridge"),v(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),$(n.fileLogger),h(n.virtualMode))},[n]),r.useEffect(()=>{const R=localStorage.getItem("frontendTheme");R&&M(R)},[]);const m=R=>{o&&console.log("handleChangeBridgeMode called with value:",R.target.value),x(R.target.value),a({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:R.target.value}})},b=R=>{o&&console.log("handleChangeMbLoggerLevel called with value:",R.target.value),v(R.target.value),a({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:R.target.value}})},T=R=>{o&&console.log("handleLogOnFileMbChange called with value:",R.target.checked),$(R.target.checked),a({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:R.target.checked}})},te=R=>{const U=R.target.value;o&&console.log("handleChangeTheme called with value:",U),M(U),localStorage.setItem("frontendTheme",U),document.body.setAttribute("frontend-theme",U)},xe=R=>{const U=R.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",U),O(U),localStorage.setItem("homePagePlugins",U?"true":"false")},we=R=>{const U=R.target.value;o&&console.log("handleChangeHomePageMode called with value:",U),z(U),localStorage.setItem("homePageMode",U)},ke=R=>{const U=R.target.value;o&&console.log("handleChangeVirtualMode called with value:",U),h(U),localStorage.setItem("virtualMode",U),a({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:U}})};return!n||!c?null:e.jsxs(je,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(Se,{children:"Matterbridge settings"})}),e.jsx(fi,{open:u,ip:c.ipv4Address,onClose:S,onSave:j}),e.jsx(xi,{open:Z,onClose:d,onSave:l}),e.jsxs(Re,{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(ye,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(xr,{row:!0,name:"mode-buttons-group",value:s,onChange:m,children:[e.jsx(Ke,{value:"bridge",control:e.jsx(Pt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ke,{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(ye,{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:b,children:[e.jsx(C,{value:"Debug",children:"Debug"}),e.jsx(C,{value:"Info",children:"Info"}),e.jsx(C,{value:"Notice",children:"Notice"}),e.jsx(C,{value:"Warn",children:"Warn"}),e.jsx(C,{value:"Error",children:"Error"}),e.jsx(C,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(qe,{checked:t,onChange:T,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{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:te,children:[e.jsx(C,{value:"classic",children:"Classic"}),e.jsx(C,{value:"light",children:"Light"}),e.jsx(C,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(qe,{checked:w,onChange:xe,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ye,{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:q,onChange:we,children:[e.jsx(C,{value:"logs",children:"Logs"}),e.jsx(C,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ye,{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:E,onChange:ke,children:[e.jsx(C,{value:"disabled",children:"Disabled"}),e.jsx(C,{value:"outlet",children:"Outlet"}),e.jsx(C,{value:"light",children:"Light"}),e.jsx(C,{value:"switch",children:"Switch"}),e.jsx(C,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(se,{variant:"contained",color:"primary",onClick:()=>ee(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(se,{variant:"contained",color:"primary",onClick:()=>k(!0),children:"Configure IP"})})]})]})}function yi({matterbridgeInfo:n}){const{sendMessage:c,getUniqueId:a}=r.useContext(me),[i,s]=r.useState("Info"),[x,g]=r.useState(!1),[v,t]=r.useState(""),[$,y]=r.useState(""),[M,w]=r.useState(""),[O,q]=r.useState(""),[z,E]=r.useState(""),[h,p]=r.useState(""),u=r.useRef(a()),k=r.useMemo(()=>et(1e3),[]),S=r.useMemo(()=>et(1e3),[]),j=r.useMemo(()=>et(1e3),[]),Z=r.useMemo(()=>et(1e3),[]),ee=r.useMemo(()=>et(1e3),[]),d=r.useMemo(()=>et(1e3),[]);r.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),g(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),w(n.matterIpv6Address||""),q(n.matterPort?n.matterPort.toString():""),E(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(()=>()=>Z.cancel(),[Z]),r.useEffect(()=>()=>ee.cancel(),[ee]),r.useEffect(()=>()=>d.cancel(),[d]);const l=R=>{o&&console.log("handleChangeMjLoggerLevel called with value:",R.target.value),s(R.target.value),c({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:R.target.value}})},m=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}})},b=R=>{o&&console.log("handleChangeMdnsInterface called with value:",R.target.value);const U=R.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}})})},T=R=>{o&&console.log("handleChangeIpv4Address called with value:",R.target.value);const U=R.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}})})},te=R=>{o&&console.log("handleChangeIpv6Address called with value:",R.target.value);const U=R.target.value;w(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}})})},xe=R=>{o&&console.log("handleChangeMatterPort called with value:",R.target.value);const U=R.target.value;q(U),Z(()=>{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}})})},we=R=>{o&&console.log("handleChangeMatterDiscriminator called with value:",R.target.value);const U=R.target.value;E(U),ee(()=>{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}})})},ke=R=>{o&&console.log("handleChangemMatterPasscode called with value:",R.target.value);const U=R.target.value;p(U),d(()=>{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(je,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(Se,{children:"Matter settings"})}),e.jsxs(Re,{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(ye,{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:l,children:[e.jsx(C,{value:"Debug",children:"Debug"}),e.jsx(C,{value:"Info",children:"Info"}),e.jsx(C,{value:"Notice",children:"Notice"}),e.jsx(C,{value:"Warn",children:"Warn"}),e.jsx(C,{value:"Error",children:"Error"}),e.jsx(C,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(qe,{checked:x,onChange:m,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(ge,{value:v,onChange:b,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(ge,{value:$,onChange:T,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(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(ge,{value:M,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(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(ge,{value:O,onChange:xe,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(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(ge,{value:z,onChange:we,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(ye,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(ge,{value:h,onChange:ke,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function ji({matterbridgeInfo:n}){return n?e.jsxs(je,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(Se,{children:"Matterbridge info"})}),e.jsxs(Re,{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(je,{style:{flex:`1 1 ${$t}px`},children:[e.jsx(Ie,{children:e.jsx(Se,{children:"System info"})}),e.jsxs(Re,{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:a}){return e.jsx(ge,{focused:!0,value:n,size:"small",label:c,variant:"standard",sx:{width:a?`${a-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 Ci=r.memo(bi);function Si(){const{online:n,sendMessage:c,addListener:a,removeListener:i,getUniqueId:s}=r.useContext(me),{showSnackbarMessage:x}=r.useContext(De),[g,v]=r.useState(null),[t,$]=r.useState([]),[y,M]=r.useState([]),[w,O]=r.useState(null),[q,z]=r.useState({cpuUsage:0}),[E,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"),x("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),x("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),z(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),x("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),x("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),x("Test received /api/devices",0),M(j.response);for(const Z of j.response)o&&console.log("Test sending /api/clusters for device:",Z.pluginName,Z.name,Z.endpoint),c({id:k.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:Z.pluginName,endpoint:Z.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),x(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),O(j.response))};return a(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")}},[a,i,c,x]),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,x]),o&&console.log("Test rendering..."),n?e.jsx(dt,{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 ki=r.memo(Si);function Mi(n,c){o&&console.log("getCssVariable:",n,"defaultValue",c);const a=getComputedStyle(document.body).getPropertyValue(n).trim();return a||console.error("getCssVariable: undefined",a),a||c}function Ii(n){return Mo({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function Di(){const{mobile:n,showSnackbarMessage:c,showConfirmCancelDialog:a}=r.useContext(De),{online:i,sendMessage:s,logMessage:x,addListener:g,removeListener:v,getUniqueId:t}=r.useContext(me),[$,y]=r.useState(!1),[M,w]=r.useState(!1),[O,q]=r.useState(!1),[z,E]=r.useState(!1),[h,p]=r.useState(null),u=r.useRef(t()),[k,S]=r.useState(null),[j,Z]=r.useState(null),[ee,d]=r.useState(null),[l,m]=r.useState(null),[b,T]=r.useState(null),te=Fr(),xe=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},we=()=>{window.open("https://matterbridge.io/")},ke=()=>{window.open("https://matterbridge.io/README.html")},R=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},U=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},N=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},Q=()=>{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"),x("Matterbridge","Installing system updates..."),s({id:u.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},I=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),x("Matterbridge","Installing software updates..."),s({id:u.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},F=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),s({id:u.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},J=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),x("Matterbridge","Downloading Shelly system log..."),c("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},de=()=>{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:{}})},ae=()=>{s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},K=()=>{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:{}})},le=()=>{s({id:u.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},G=A=>{S(A.currentTarget)},D=A=>{o&&console.log("Header: handleMenuClose",A),S(null),A==="/"||A==="/devices"||A==="/log"||A==="/settings"?te(A):A==="download-mblog"?(x("Matterbridge","Downloading matterbridge log..."),c("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):A==="download-mjlog"?(x("Matterbridge","Downloading matter log..."),c("Downloading matter log...",5),window.location.href="./api/download-mjlog"):A==="view-mblog"?(x("Matterbridge","Loading matterbridge log..."),c("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):A==="view-mjlog"?(x("Matterbridge","Loading matter log..."),c("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):A==="view-diagnostic"?(x("Matterbridge","Loading diagnostic log..."),c("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):A==="download-diagnostic"?(x("Matterbridge","Downloading diagnostic log..."),c("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):A==="view-history"?s({id:u.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):A==="download-history"?s({id:u.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):A==="view-shellylog"?(x("Matterbridge","Loading shelly system log..."),c("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):A==="download-mbstorage"?(x("Matterbridge","Downloading matterbridge storage..."),c("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):A==="download-pluginstorage"?(x("Matterbridge","Downloading matterbridge plugins storage..."),c("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):A==="download-pluginconfig"?(x("Matterbridge","Downloading matterbridge plugins config..."),c("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):A==="download-mjstorage"?(x("Matterbridge","Downloading matter storage..."),c("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):A==="download-backup"?(x("Matterbridge","Downloading backup..."),c("Downloading backup...",10),window.location.href="./api/download-backup"):A==="update"?Q():A==="updatedev"?W():A==="updatecheck"?L():A==="shelly-sys-update"?P():A==="shelly-main-update"?I():A==="shelly-create-system-log"?F():A==="shelly-download-system-log"?J():A==="softreset"?f():A==="hardreset"?le():A==="restart"?de():A==="shutdown"?ae():A==="reboot"?K():A==="create-backup"?s({id:u.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):A==="unregister"?s({id:u.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):A==="reset"?s({id:u.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):A==="factoryreset"&&s({id:u.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},fe=A=>{o&&console.log("Header: handleMenuCloseCancel:",A),S(null)},Ne=A=>{Z(A.currentTarget)},he=()=>{Z(null)},re=A=>{d(A.currentTarget)},ce=()=>{d(null)},He=A=>{m(A.currentTarget)},Ce=()=>{m(null)},it=A=>{T(A.currentTarget)},V=()=>{T(null)},be=()=>{Li(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const A=oe=>{o&&console.log("Header received WebSocket Message:",oe),oe.method==="/api/settings"&&oe.id===u.current?(o&&console.log("Header received settings:",oe.response),p(oe.response),y(oe.response.matterbridgeInformation.restartRequired||oe.response.matterbridgeInformation.fixedRestartRequired),w(oe.response.matterbridgeInformation.fixedRestartRequired),q(oe.response.matterbridgeInformation.updateRequired)):oe.method==="refresh_required"&&oe.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${oe.response.changed} and sending /api/settings request`),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):oe.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${oe.response.fixed}`),y(!0),oe.response.fixed===!0&&w(!0)):oe.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),y(!1)):oe.method==="update_required"?(o&&console.log("Header received update_required"),oe.response.devVersion===!0?E(!0):q(!0),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):oe.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),p(Pe=>Pe?{matterbridgeInformation:{...Pe.matterbridgeInformation,shellySysUpdate:oe.response.available},systemInformation:Pe.systemInformation}:null)):oe.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),p(Pe=>Pe?{matterbridgeInformation:{...Pe.matterbridgeInformation,shellyMainUpdate:oe.response.available},systemInformation:Pe.systemInformation}:null)):oe.method==="/api/viewhistorypage"&&oe.id===u.current&&oe.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):oe.method==="/api/downloadhistorypage"&&oe.id===u.current&&oe.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return g(A,u.current),o&&console.log(`Header added WebSocket listener id ${u.current}`),()=>{v(A),o&&console.log("Header removed WebSocket listener")}},[g,v,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:be}),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(pt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(pt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(pt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(pt,{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 ",`${It}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(B,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:N,children:e.jsx(hr,{})})}):null,h.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Sponsor Matterbridge",children:e.jsx(B,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:xe,children:e.jsx(Et,{})})}):null,e.jsx(H,{title:"Matterbridge homepage",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:we,children:e.jsx(Io,{})})}),e.jsx(H,{title:"Matterbridge help",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ke,children:e.jsx(ur,{})})}),e.jsx(H,{title:"Matterbridge changelog",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:R,children:e.jsx(Vt,{})})}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&O&&e.jsx(H,{title:`Update matterbridge to latest version v.${h.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(B,{style:{color:O?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:Q,children:e.jsx(Fe,{})})}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&z&&e.jsx(H,{title:`Update matterbridge to latest dev version v.${h.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(B,{style:{color:z?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:W,children:e.jsx(Fe,{})})}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellySysUpdate&&e.jsx(H,{title:"Shelly system update",children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:P,children:e.jsx(Fe,{})})}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellyMainUpdate&&e.jsx(H,{title:"Shelly software update",children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:I,children:e.jsx(Fe,{})})}),e.jsx(H,{title:"Restart matterbridge",children:e.jsx(B,{style:{color:$||M?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:de,children:e.jsx(kt,{})})}),h.matterbridgeInformation.restartMode===""?e.jsx(H,{title:"Shut down matterbridge",children:e.jsx(B,{style:{color:$||M?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:ae,children:e.jsx(Be,{})})}):null,e.jsx(H,{title:"Download, backup and more",children:e.jsx(B,{onClick:G,children:e.jsx(Do,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(rt,{id:"command-menu",anchorEl:k,keepMounted:!0,open:!!k,onClose:()=>D(""),children:[ue&&n&&e.jsxs(C,{onClick:()=>D("/"),children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ue&&n&&e.jsxs(C,{onClick:()=>D("/devices"),children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ue&&n&&e.jsxs(C,{onClick:()=>D("/log"),children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),ue&&n&&e.jsxs(C,{onClick:()=>D("/settings"),children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>D("update"),children:[e.jsx(_,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>D("updatedev"),children:[e.jsx(_,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>D("updatecheck"),children:[e.jsx(_,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellySysUpdate&&e.jsxs(C,{onClick:()=>D("shelly-sys-update"),children:[e.jsx(_,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellyMainUpdate&&e.jsxs(C,{onClick:()=>D("shelly-main-update"),children:[e.jsx(_,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>D("restart"),children:[e.jsx(_,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation.restartMode===""?e.jsxs(C,{onClick:()=>D("shutdown"),children:[e.jsx(_,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{a("Reboot","Are you sure you want to reboot the Shelly board?","reboot",D,fe)},children:[e.jsx(_,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(ft,{}),e.jsxs(C,{onClick:re,children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-view",anchorEl:ee,keepMounted:!0,open:!!ee,onClose:ce,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{Ni(),ce(),fe(""),window.open("/home","_self")},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{Wi(),ce(),fe(""),window.open("/home","_self")},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-mblog"),ce()},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-mjlog"),ce()},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-diagnostic"),ce()},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-history"),ce()},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{D("view-shellylog"),ce()},children:[e.jsx(_,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ft,{}),e.jsxs(C,{onClick:He,children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-download",anchorEl:l,keepMounted:!0,open:!!l,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{D("download-mbstorage"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-pluginstorage"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-pluginconfig"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-mblog"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-mjstorage"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-mjlog"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-diagnostic"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-history"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{D("shelly-create-system-log"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{D("shelly-download-system-log"),Ce()},children:[e.jsx(_,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ft,{}),e.jsxs(C,{onClick:Ne,children:[e.jsx(_,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:he,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{D("create-backup"),he()},children:[e.jsx(_,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-backup"),he()},children:[e.jsx(_,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ft,{}),e.jsxs(C,{onClick:it,children:[e.jsx(_,{children:e.jsx(Po,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-reset",anchorEl:b,keepMounted:!0,open:!!b,onClose:V,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{V(),a("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,fe)},children:[e.jsx(_,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{V(),a("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,fe)},children:[e.jsx(_,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>{V(),a("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,fe)},children:[e.jsx(_,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{V(),a("Network reset","Are you sure you want to factory reset the network parameters?","softreset",D,fe)},children:[e.jsx(_,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{V(),a("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",D,fe)},children:[e.jsx(_,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const lr=r.memo(Di),wr=1200,Cr=900;let It,Dt;function ar(){if(typeof window<"u"){It=Math.floor(window.visualViewport?.width??window.innerWidth),Dt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=It<wr||Dt<Cr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,It,Dt,n),n}return!1}function Pi({children:n}){const{mobile:c,setMobile:a}=r.useContext(De),{logAutoScroll:i}=r.useContext(me);return r.useEffect(()=>{function s(){const x=ar();x&&(i.current=!1,localStorage.setItem("logAutoScroll","false")),a(x)}return window.addEventListener("resize",s),a(ar()),()=>window.removeEventListener("resize",s)},[i,a]),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(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?`${wr}px`:"calc(100vw - 40px)",height:c?`${Cr}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 Li=()=>{o=!o},$i=!1;let ue=localStorage.getItem("enableMobile")!=="false";const Wi=()=>{ue=!0,localStorage.setItem("enableMobile","true")},Ni=()=>{ue=!1,localStorage.setItem("enableMobile","false")};let ot;const Fi=n=>{ot=n};let ct=!1,cr="/",tt="/",Ht="/";function Ti({setLoggedIn:n}){const[c,a]=r.useState(""),[i,s]=r.useState(""),x={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 M=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(M.ok){const{valid:w}=await M.json();w?(n(!0),y!==""&&(ot=y)):y!==""&&s("Incorrect password!")}else console.error("Failed to log in:",M.statusText)}catch(M){console.error("Failed to log in:",M)}},$=y=>{y.preventDefault(),t(c)};return t(""),e.jsx("div",{style:x,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=>a(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 Ri(){const[n,c]=r.useState(!1),a=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',a),document.body.setAttribute("frontend-theme",a);const i=Mi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const s=Ii(i);return cr=window.location.href,tt=window.location.pathname,Ht=tt.includes("/matterbridge/")?"/matterbridge/":tt.includes("/api/hassio_ingress/")?tt:"/",ct=tt.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${cr}"`),console.log(`- pathname = "${tt}"`),console.log(`- baseName = "${Ht}"`),console.log(`- isIngress = "${ct}"`),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(Tr,{basename:Ht,children:e.jsx(Pi,{children:e.jsxs(Rr,{children:[e.jsx(Ge,{path:"/",element:e.jsx(Un,{})}),e.jsx(Ge,{path:"/devices",element:e.jsx(gi,{})}),e.jsx(Ge,{path:"/log",element:e.jsx(hi,{})}),e.jsx(Ge,{path:"/settings",element:e.jsx(Ci,{})}),e.jsx(Ge,{path:"/test",element:e.jsx(ki,{})}),e.jsx(Ge,{path:"*",element:e.jsx(Hr,{to:"/"})})]})})})})})})}):e.jsx(Ti,{setLoggedIn:c})}Or.createRoot(document.getElementById("root")).render(e.jsx(Vr.StrictMode,{children:e.jsx(Ri,{})}));
|