matterbridge 3.2.9-dev-20250926-85736bb → 3.2.9
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 +2 -2
- package/dist/cli.d.ts +26 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -2
- package/dist/cli.js.map +1 -0
- package/dist/cliEmitter.d.ts +34 -0
- package/dist/cliEmitter.d.ts.map +1 -0
- package/dist/cliEmitter.js +30 -0
- package/dist/cliEmitter.js.map +1 -0
- package/dist/clusters/export.d.ts +2 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +28 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +24 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +112 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/airConditioner.d.ts +98 -0
- package/dist/devices/airConditioner.d.ts.map +1 -0
- package/dist/devices/airConditioner.js +57 -0
- package/dist/devices/airConditioner.js.map +1 -0
- package/dist/devices/batteryStorage.d.ts +48 -0
- package/dist/devices/batteryStorage.d.ts.map +1 -0
- package/dist/devices/batteryStorage.js +48 -1
- package/dist/devices/batteryStorage.js.map +1 -0
- package/dist/devices/cooktop.d.ts +60 -0
- package/dist/devices/cooktop.d.ts.map +1 -0
- package/dist/devices/cooktop.js +55 -0
- package/dist/devices/cooktop.js.map +1 -0
- package/dist/devices/dishwasher.d.ts +71 -0
- package/dist/devices/dishwasher.d.ts.map +1 -0
- package/dist/devices/dishwasher.js +57 -0
- package/dist/devices/dishwasher.js.map +1 -0
- package/dist/devices/evse.d.ts +75 -0
- package/dist/devices/evse.d.ts.map +1 -0
- package/dist/devices/evse.js +74 -10
- package/dist/devices/evse.js.map +1 -0
- package/dist/devices/export.d.ts +17 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +5 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/devices/extractorHood.d.ts +46 -0
- package/dist/devices/extractorHood.d.ts.map +1 -0
- package/dist/devices/extractorHood.js +42 -0
- package/dist/devices/extractorHood.js.map +1 -0
- package/dist/devices/heatPump.d.ts +47 -0
- package/dist/devices/heatPump.d.ts.map +1 -0
- package/dist/devices/heatPump.js +50 -2
- package/dist/devices/heatPump.js.map +1 -0
- package/dist/devices/laundryDryer.d.ts +67 -0
- package/dist/devices/laundryDryer.d.ts.map +1 -0
- package/dist/devices/laundryDryer.js +62 -3
- package/dist/devices/laundryDryer.js.map +1 -0
- package/dist/devices/laundryWasher.d.ts +81 -0
- package/dist/devices/laundryWasher.d.ts.map +1 -0
- package/dist/devices/laundryWasher.js +70 -4
- package/dist/devices/laundryWasher.js.map +1 -0
- package/dist/devices/microwaveOven.d.ts +168 -0
- package/dist/devices/microwaveOven.d.ts.map +1 -0
- package/dist/devices/microwaveOven.js +88 -5
- package/dist/devices/microwaveOven.js.map +1 -0
- package/dist/devices/oven.d.ts +105 -0
- package/dist/devices/oven.d.ts.map +1 -0
- package/dist/devices/oven.js +85 -0
- package/dist/devices/oven.js.map +1 -0
- package/dist/devices/refrigerator.d.ts +118 -0
- package/dist/devices/refrigerator.d.ts.map +1 -0
- package/dist/devices/refrigerator.js +102 -0
- package/dist/devices/refrigerator.js.map +1 -0
- package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
- package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/devices/roboticVacuumCleaner.js +100 -9
- package/dist/devices/roboticVacuumCleaner.js.map +1 -0
- package/dist/devices/solarPower.d.ts +40 -0
- package/dist/devices/solarPower.d.ts.map +1 -0
- package/dist/devices/solarPower.js +38 -0
- package/dist/devices/solarPower.js.map +1 -0
- package/dist/devices/speaker.d.ts +87 -0
- package/dist/devices/speaker.d.ts.map +1 -0
- package/dist/devices/speaker.js +84 -0
- package/dist/devices/speaker.js.map +1 -0
- package/dist/devices/temperatureControl.d.ts +166 -0
- package/dist/devices/temperatureControl.d.ts.map +1 -0
- package/dist/devices/temperatureControl.js +25 -3
- package/dist/devices/temperatureControl.js.map +1 -0
- package/dist/devices/waterHeater.d.ts +111 -0
- package/dist/devices/waterHeater.d.ts.map +1 -0
- package/dist/devices/waterHeater.js +82 -2
- package/dist/devices/waterHeater.js.map +1 -0
- package/dist/dgram/coap.d.ts +205 -0
- package/dist/dgram/coap.d.ts.map +1 -0
- package/dist/dgram/coap.js +126 -13
- package/dist/dgram/coap.js.map +1 -0
- package/dist/dgram/dgram.d.ts +141 -0
- package/dist/dgram/dgram.d.ts.map +1 -0
- package/dist/dgram/dgram.js +114 -2
- package/dist/dgram/dgram.js.map +1 -0
- package/dist/dgram/mb_coap.d.ts +24 -0
- package/dist/dgram/mb_coap.d.ts.map +1 -0
- package/dist/dgram/mb_coap.js +41 -3
- package/dist/dgram/mb_coap.js.map +1 -0
- package/dist/dgram/mb_mdns.d.ts +24 -0
- package/dist/dgram/mb_mdns.d.ts.map +1 -0
- package/dist/dgram/mb_mdns.js +80 -15
- package/dist/dgram/mb_mdns.js.map +1 -0
- package/dist/dgram/mdns.d.ts +290 -0
- package/dist/dgram/mdns.d.ts.map +1 -0
- package/dist/dgram/mdns.js +299 -137
- package/dist/dgram/mdns.js.map +1 -0
- package/dist/dgram/multicast.d.ts +67 -0
- package/dist/dgram/multicast.d.ts.map +1 -0
- package/dist/dgram/multicast.js +62 -1
- package/dist/dgram/multicast.js.map +1 -0
- package/dist/dgram/unicast.d.ts +56 -0
- package/dist/dgram/unicast.d.ts.map +1 -0
- package/dist/dgram/unicast.js +54 -0
- package/dist/dgram/unicast.js.map +1 -0
- package/dist/frontend.d.ts +232 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +428 -34
- package/dist/frontend.js.map +1 -0
- package/dist/frontendTypes.d.ts +514 -0
- package/dist/frontendTypes.d.ts.map +1 -0
- package/dist/frontendTypes.js +45 -0
- package/dist/frontendTypes.js.map +1 -0
- package/dist/globalMatterbridge.d.ts +59 -0
- package/dist/globalMatterbridge.d.ts.map +1 -0
- package/dist/globalMatterbridge.js +47 -0
- package/dist/globalMatterbridge.js.map +1 -0
- package/dist/helpers.d.ts +48 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +53 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +3 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +444 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +784 -51
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +36 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1747 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +65 -5
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +761 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +630 -17
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +36 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1534 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1398 -58
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +407 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +345 -12
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +365 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +304 -0
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +197 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +25 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +270 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +249 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +174 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +168 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +75 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +69 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +99 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +97 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +59 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +54 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +33 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +38 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +34 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +33 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +39 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +47 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +32 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +39 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +54 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +72 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/error.d.ts +44 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +41 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/export.d.ts +13 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/hex.d.ts +89 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +124 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/isvalid.d.ts +103 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +101 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/jestHelpers.d.ts +137 -0
- package/dist/utils/jestHelpers.d.ts.map +1 -0
- package/dist/utils/jestHelpers.js +153 -3
- package/dist/utils/jestHelpers.js.map +1 -0
- package/dist/utils/network.d.ts +84 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +91 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +34 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +84 -6
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/wait.d.ts +54 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +60 -8
- package/dist/utils/wait.js.map +1 -0
- package/frontend/build/assets/index.js +7 -5
- package/npm-shrinkwrap.json +22 -16
- package/package.json +2 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import{B as e,y as r,Q as Xe,S as nr,U as ir,V as Ve,X as sr,Y as ar,H as lr}from"./vendor_node_modules.js";import{u as dr,S as cr}from"./vendor_notistack.js";import{D as Me,a as ke,b as Ie,B as
|
|
2
|
-
`).map((g,t)=>e.jsx("li",{style:{padding:0,margin:0},children:g},t)),e.jsx("li",{ref:b,style:{padding:0,margin:0}})]})]}),e.jsxs(
|
|
3
|
-
`),
|
|
4
|
-
`)},[]),
|
|
5
|
-
`)),["debug","info","notice","warn","error","fatal"].includes(h.response.level)&&(o.current==="info"&&h.response.level==="debug"||o.current==="notice"&&(h.response.level==="debug"||h.response.level==="info")||o.current==="warn"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice")||o.current==="error"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn")||o.current==="fatal"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn"||h.response.level==="error")))||d.current!=="*"&&d.current!==""&&!h.response.message.toLowerCase().includes(d.current.toLowerCase())&&!h.response.name.toLowerCase().includes(d.current.toLowerCase())||h.response.name==="Commissioning"&&h.response.message.includes("is uncommissioned"))return;g(J=>{const ve=[...J,{level:h.response.level,time:h.response.time,name:h.response.name,message:h.response.message}];return ve.length>t*2?ve.slice(t):ve})}else{if(s&&console.log(`WebSocket received message id ${h.id} method ${h.method}:`,h),h.id===0)j.current.forEach(ne=>ne.listener(h));else{const ne=j.current.find(J=>J.id===h.id);ne?ne.listener(h):s&&console.debug(`WebSocket no listener found for message id ${h.id}:`,h)}return}}catch(h){console.error(`WebSocketUse error parsing message: ${h}`)}},k.current.onopen=()=>{s&&console.log(`WebSocket: Connected to WebSocket: ${V}`),S("WebSocket",`Connected to WebSocket: ${V}`),E(!0),_(),R.current=1,a.current=setTimeout(()=>{G.current=setInterval(()=>{$({id:O.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{s&&console.error(`WebSocketUse: No pong response received from WebSocket: ${V}`),S("WebSocket",`No pong response received from WebSocket: ${V}`),E(!1)},1e3*ee)},1e3*xe)},1e3*se)},k.current.onclose=()=>{s&&console.error(`WebSocket: Disconnected from WebSocket ${ge?"with Ingress":""}: ${V}`),S("WebSocket",`Disconnected from WebSocket: ${V}`),E(!1),_(),X(),a.current&&clearTimeout(a.current),v.current&&clearTimeout(v.current),G.current&&clearInterval(G.current),S("WebSocket",`Reconnecting (attempt ${R.current} of ${me}) to WebSocket${ge?" (Ingress)":""}: ${V}`),ge?setTimeout(ae,5e3):R.current===1?ae():R.current<me?setTimeout(ae,1e3*R.current):S("WebSocket",`Reconnect attempts exceeded limit of ${me} retries, refresh the page to reconnect to: ${V}`),R.current=R.current+1},k.current.onerror=N=>{s&&console.error(`WebSocket: WebSocket error connecting to ${V}:`,N),S("WebSocket",`WebSocket error connecting to ${V}`)})},[V]),ae=r.useCallback(()=>{s&&console.log(`WebSocket attemptReconnect ${R.current}/${me} to:`,V),Y()},[Y]);r.useEffect(()=>(Y(),()=>{k.current&&k.current.readyState===WebSocket.OPEN&&k.current.close()}),[Y]);const de=r.useMemo(()=>({messages:b,maxMessages:t,autoScroll:P,setMessages:g,setLogFilters:M,setMaxMessages:x,setAutoScroll:p}),[b,g,M]),le=r.useMemo(()=>({maxMessages:t,autoScroll:P,logFilterLevel:m,logFilterSearch:n,setMessages:g,setLogFilters:M,setMaxMessages:x,setAutoScroll:p,online:C,retry:R.current,getUniqueId:U,addListener:F,removeListener:A,sendMessage:$,logMessage:S}),[t,P,g,M,x,p,C,R.current,F,A,$,S]);return e.jsx(Ut.Provider,{value:de,children:e.jsx(fe.Provider,{value:le,children:i})})}function Vo(){const{showSnackbarMessage:i,showConfirmCancelDialog:m}=r.useContext(Be),{online:c,sendMessage:n,logMessage:l,addListener:b,removeListener:g,getUniqueId:t}=r.useContext(fe),[x,P]=r.useState(!1),[p,C]=r.useState(!1),[E,H]=r.useState(!1),[W,_]=r.useState(!1),[f,X]=r.useState(null),y=r.useRef(t()),[j,k]=r.useState(null),[R,O]=r.useState(null),[G,v]=r.useState(null),[a,o]=r.useState(null),[d,u]=r.useState(null),w=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},V=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},ge=()=>{f?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},me=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},ee=()=>{n({id:y.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},se=()=>{n({id:y.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},L=()=>{n({id:y.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},U=()=>{s&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),n({id:y.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},$=()=>{s&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),n({id:y.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},S=()=>{s&&console.log("Header: handleShellyCreateSystemLog"),n({id:y.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{s&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),i("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},F=()=>{f?.matterbridgeInformation.restartMode===""?n({id:y.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:y.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},A=()=>{n({id:y.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},Y=()=>{n({id:y.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{n({id:y.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{n({id:y.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=B=>{k(B.currentTarget)},N=B=>{s&&console.log("Header: handleMenuClose",B),k(null),B==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),i("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):B==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),i("Downloading matter log...",5),window.location.href="./api/download-mjlog"):B==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),i("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):B==="view-mjlog"?(l("Matterbridge","Loading matter log..."),i("Loading matter log...",5),window.location.href="./api/view-mjlog"):B==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),i("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):B==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),i("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):B==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),i("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):B==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),i("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):B==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),i("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):B==="download-backup"?(l("Matterbridge","Downloading backup..."),i("Downloading backup...",10),window.location.href="./api/download-backup"):B==="update"?ee():B==="updatedev"?se():B==="updatecheck"?L():B==="shelly-sys-update"?U():B==="shelly-main-update"?$():B==="shelly-create-system-log"?S():B==="shelly-download-system-log"?M():B==="softreset"?ae():B==="hardreset"?de():B==="restart"?F():B==="shutdown"?A():B==="reboot"?Y():B==="create-backup"?n({id:y.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):B==="unregister"?n({id:y.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):B==="reset"?n({id:y.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):B==="factoryreset"&&n({id:y.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},h=B=>{s&&console.log("Header: handleMenuCloseCancel:",B),k(null)},ne=B=>{O(B.currentTarget)},J=()=>{O(null)},ve=B=>{v(B.currentTarget)},je=()=>{v(null)},he=B=>{o(B.currentTarget)},K=()=>{o(null)},ce=B=>{u(B.currentTarget)},ye=()=>{u(null)},Qe=()=>{Qn(),s&&console.log("Matterbridge logo clicked: debug is now",s)};return r.useEffect(()=>{const B=I=>{s&&console.log("Header received WebSocket Message:",I),I.method==="/api/settings"&&I.id===y.current?(s&&console.log("Header received settings:",I.response),X(I.response),P(I.response.matterbridgeInformation.restartRequired||I.response.matterbridgeInformation.fixedRestartRequired),C(I.response.matterbridgeInformation.fixedRestartRequired),H(I.response.matterbridgeInformation.updateRequired)):I.method==="refresh_required"&&I.response.changed==="settings"?(s&&console.log(`Header received refresh_required: changed=${I.response.changed} and sending /api/settings request`),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):I.method==="restart_required"?(s&&console.log(`Header received restart_required with fixed: ${I.response.fixed}`),P(!0),I.response.fixed===!0&&C(!0)):I.method==="restart_not_required"?(s&&console.log("Header received restart_not_required"),P(!1)):I.method==="update_required"?(s&&console.log("Header received update_required"),I.response.devVersion===!0?_(!0):H(!0),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):I.method==="shelly_sys_update"?(s&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),X(ue=>ue?{matterbridgeInformation:{...ue.matterbridgeInformation,shellySysUpdate:I.response.available},systemInformation:ue.systemInformation}:null)):I.method==="shelly_main_update"&&(s&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),X(ue=>ue?{matterbridgeInformation:{...ue.matterbridgeInformation,shellyMainUpdate:I.response.available},systemInformation:ue.systemInformation}:null))};return b(B,y.current),s&&console.log(`Header added WebSocket listener id ${y.current}`),()=>{g(B),s&&console.log("Header removed WebSocket listener")}},[b,g,n,i]),r.useEffect(()=>{c&&(s&&console.log("Header sending /api/settings requests"),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]),s&&console.log("Header rendering..."),!c||!f?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Qe}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(Xe,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Xe,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Xe,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Xe,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!f.matterbridgeInformation.readOnly&&E&&e.jsx(T,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:ee,children:["Update to v.",f.matterbridgeInformation.matterbridgeLatestVersion]})}),!f.matterbridgeInformation.readOnly&&W&&e.jsx(T,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:se,children:["Update to new dev v.",f.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!f.matterbridgeInformation.readOnly&&e.jsx(T,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:ge,children:["v.",f.matterbridgeInformation.matterbridgeVersion]})}),f.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),f.matterbridgeInformation.bridgeMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.bridgeMode})}):null,f.matterbridgeInformation.restartMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.restartMode})}):null,f.matterbridgeInformation.profile&&f.matterbridgeInformation.profile!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:me})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:xe,children:e.jsx(gr,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:w,children:e.jsx(Vt,{})})}):null,e.jsx(T,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:V,children:e.jsx(mr,{})})}),e.jsx(T,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ge,children:e.jsx(Et,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsx(T,{title:"Update matterbridge to latest version",children:e.jsx(Q,{style:{color:E?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ee,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(T,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(T,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:$,children:e.jsx(We,{})})}),e.jsx(T,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:x||p?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:F,children:e.jsx(dt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(T,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:x||p?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:A,children:e.jsx(He,{})})}):null,e.jsx(T,{title:"Download, backup and more",children:e.jsx(Q,{onClick:le,children:e.jsx(hr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(ze,{id:"command-menu",anchorEl:j,keepMounted:!0,open:!!j,onClose:()=>N(""),children:[f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(D,{onClick:()=>N("update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(D,{onClick:()=>N("updatedev"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(D,{onClick:()=>N("updatecheck"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(D,{onClick:()=>N("shelly-sys-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(D,{onClick:()=>N("shelly-main-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>N("restart"),children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(D,{onClick:()=>N("shutdown"),children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(D,{onClick:()=>{m("Reboot","Are you sure you want to reboot the Shelly board?","reboot",N,h)},children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Ze,{}),e.jsxs(D,{onClick:ve,children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-view",anchorEl:G,keepMounted:!0,open:!!G,onClose:je,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(D,{onClick:()=>{N("view-mblog"),je()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("view-mjlog"),je()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(D,{onClick:()=>{N("view-shellylog"),je()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(D,{onClick:he,children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-download",anchorEl:a,keepMounted:!0,open:!!a,onClose:K,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(D,{onClick:()=>{N("download-mbstorage"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("download-pluginstorage"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("download-pluginconfig"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("download-mblog"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("download-mjstorage"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("download-mjlog"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(D,{onClick:()=>{N("shelly-create-system-log"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(D,{onClick:()=>{N("shelly-download-system-log"),K()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(D,{onClick:ne,children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-backup",anchorEl:R,keepMounted:!0,open:!!R,onClose:J,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(D,{onClick:()=>{N("create-backup"),J()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{N("download-backup"),J()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(D,{onClick:ce,children:[e.jsx(z,{children:e.jsx(fr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-reset",anchorEl:d,keepMounted:!0,open:!!d,onClose:ye,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(D,{onClick:()=>{ye(),m("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",N,h)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(D,{onClick:()=>{ye(),m("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",N,h)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(D,{onClick:()=>{ye(),m("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",N,h)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(D,{onClick:()=>{ye(),m("Network reset","Are you sure you want to factory reset the network parameters?","softreset",N,h)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(D,{onClick:()=>{ye(),m("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",N,h)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(te,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Eo=r.memo(Vo),Ao=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(s&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(s&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function _o(){const{messages:i,autoScroll:m}=r.useContext(Ut),[c,n]=r.useState(!1),l=r.useRef(null),b=r.useMemo(()=>Ao(),[]),g=p=>n(!0),t=p=>n(!1);r.useEffect(()=>{s&&console.log(`WebSocketLogs autoScroll: ${m} isHovering: ${c}`),m&&!c&&!b&&l.current?.scrollIntoView({behavior:"smooth"})},[i,c,m,b]);const x=p=>{switch(p.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"}},P=p=>{switch(p.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:g,onMouseLeave:t,children:[i.map((p,C)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:x(p.level),color:P(p.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:p.level}),p.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+p.time+"]"}),p.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+p.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:p.message})]},C)),e.jsx("div",{ref:l})]})})}const Bt=r.memo(_o);function Re(){const{retry:i}=r.useContext(fe),m=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:i<100?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx(xr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+i+")","..."]})})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{}),e.jsx(oe,{variant:"contained",color:"primary",onClick:m,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function qo({value:i,maxChars:m}){let c=i;if(i.length>m&&m>3){const n=m-3,l=i.substring(0,Math.ceil(n/2)),b=i.substring(i.length-Math.floor(n/2),i.length);c=`${l} … ${b}`}return i!==c?e.jsx(T,{title:i,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:c})}):e.jsx("span",{children:c})}function zo({systemInfo:i,compact:m}){const{sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(fe),[g,t]=r.useState(i),x=r.useRef(b());if(s&&console.log("SystemInfoTable:",g,"compact:",m),i&&m&&g.totalMemory&&g.freeMemory){const P=g.totalMemory,p=g.freeMemory;g.freeMemory=`${p} / ${P}`,g.totalMemory=""}if(i&&m&&g.heapTotal&&g.heapUsed){const P=g.heapTotal,p=g.heapUsed;g.heapUsed=`${p} / ${P}`,g.heapTotal=""}if(i&&m&&g.osRelease&&g.osType){const P=g.osType,p=g.osRelease;g.osType=`${P} (${p})`,g.osRelease=""}if(i&&m&&g.osArch&&g.osPlatform){const P=g.osPlatform,p=g.osArch;g.osPlatform=`${P} (${p})`,g.osArch=""}return r.useEffect(()=>{const P=p=>{p.src==="Matterbridge"&&p.dst==="Frontend"&&(p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss&&(s&&console.log("SystemInfoTable received memory_update",p),(g.totalMemory!==p.response.totalMemory||g.freeMemory!==p.response.freeMemory||g.heapTotal!==p.response.heapTotal||g.heapUsed!==p.response.heapUsed||g.rss!==p.response.rss)&&t(C=>({...C,totalMemory:p.response.totalMemory,freeMemory:p.response.freeMemory,heapTotal:p.response.heapTotal,heapUsed:p.response.heapUsed,rss:p.response.rss}))),p.method==="cpu_update"&&p.response&&p.response.cpuUsage&&(s&&console.log("SystemInfoTable received cpu_update",p),g.cpuUsage!==(p.response.cpuUsage?p.response.cpuUsage.toFixed(2)+" %":"")&&t(C=>({...C,cpuUsage:p.response.cpuUsage.toFixed(2)+" %"}))),p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime&&(s&&console.log("SystemInfoTable received uptime_update",p),(g.systemUptime!==p.response.systemUptime||g.processUptime!==p.response.processUptime)&&t(C=>({...C,systemUptime:p.response.systemUptime,processUptime:p.response.processUptime}))))};return s&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),n(P,x.current),s&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),l(P),s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[n,g.cpuUsage,g.freeMemory,g.heapTotal,g.heapUsed,g.processUptime,g.rss,g.systemUptime,g.totalMemory,l,c]),g?(s&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(g).filter(([P,p])=>p!==void 0&&p!=="").map(([P,p],C)=>e.jsxs("tr",{className:C%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:P}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(qo,{value:typeof p!="string"?p.toString():p,maxChars:25})})]},P))})})})]})):null}const Uo=r.memo(zo),Tt={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"}},Bo=i=>{if(!i)return"";const m=i.toString().replace(/[^0-9]/g,"");if(m.length<5)return m;const c=m.slice(0,4),n=m.slice(4,7),l=m.slice(7,11);return[c,n,l].filter(Boolean).join("-")};function Qo({id:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(fe),[g,t]=r.useState(null),[x,P]=r.useState(null),p=r.useRef(null),C=r.useRef(b()),{showConfirmCancelDialog:E}=r.useContext(Be);s&&console.log(`QRDiv loading with id = "${i}" storeId "${g}" and matter:`,x),r.useEffect(()=>{s&&console.log(`QRDiv id effect "${i}"`),i&&(s&&console.log(`QRDiv sending data request for storeId "${i}"`),t(i),c({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:i,server:!0}}))},[i]),r.useEffect(()=>{s&&console.log(`QRDiv storeId effect "${g}"`)},[g]),r.useEffect(()=>{const y=j=>{j.method==="refresh_required"&&j.response.changed==="matter"&&j.response.matter&&(s&&console.log(`QRDiv received refresh_required: changed=${j.response.changed} for storeId "${j.response.matter.id}":`,j.response.matter),g===j.response.matter.id&&(s&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${j.response.matter.id}":`,j.response.matter),p.current&&clearTimeout(p.current),j.response.matter.advertising&&j.response.matter.advertiseTime&&j.response.matter.advertiseTime+9e5<=Date.now()&&(j.response.matter.advertising=!1),P(j.response.matter),j.response.matter.advertising&&(s&&console.log(`QRDiv setting matter advertise timeout for storeId "${j.response.matter.id}":`,j.response.matter.advertiseTime+9e5-Date.now()),p.current=setTimeout(()=>{p.current&&clearTimeout(p.current),s&&console.log(`QRDiv clearing advertising state for storeId "${g}" after 15 minutes`),P(k=>k&&{...k,advertising:!1})},j.response.matter.advertiseTime+9e5-Date.now()))))};return n(y,C.current),s&&console.log("QRDiv webSocket effect mounted"),()=>{l(y),p.current&&clearTimeout(p.current),p.current=null,s&&console.log("QRDiv webSocket effect unmounted")}},[n,l,g]);const H=()=>{s&&console.log(`QRDiv sent matter startCommission for node "${x?.id}"`),x&&c({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,startCommission:!0}})},W=()=>{s&&console.log(`QRDiv sent matter stopCommission for node "${x?.id}"`),x&&c({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,stopCommission:!0}})},_=()=>{s&&console.log(`QRDiv sent matter advertise for node "${x?.id}"`),x&&c({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,advertise:!0}})},f=y=>{s&&console.log(`QRDiv sent matter removeFabric for node "${x?.id}" and fabricIndex ${y}`),x&&c({id:C.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,removeFabric:y}})},X=async()=>{if(!x||!x.manualPairingCode)return;const y=x.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(y);else{const j=document.createElement("textarea");j.value=y,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.focus(),j.select(),document.execCommand("copy"),document.body.removeChild(j)}s&&console.log("Manual pairing code copied to clipboard")}catch(j){console.error("Failed to copy manual pairing code",j)}};return!x||!m?(s&&console.log("QRDiv rendering undefined state"),null):x.online?x.advertising&&x.qrPairingCode&&x.manualPairingCode?(s&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:Wt,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:W,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Turn off pairing",arrow:!0,children:e.jsx(re,{path:ro,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx(to,{value:x.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Bo(x.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(T,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:X,sx:Tt,children:e.jsx(re,{path:oo,size:.85})})})})]})]})):x.commissioned&&x.fabricInformations&&x.sessionInformations?(s&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(re,{path:Wt,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:H,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Turn on pairing",arrow:!0,children:e.jsx(re,{path:Lt,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),x.fabricInformations.map((y,j)=>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: ",y.fabricIndex]}),e.jsx(T,{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:()=>E("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>f(y.fabricIndex),()=>{}),sx:{...Tt,padding:"2px"},children:e.jsx(re,{path:no,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",y.rootVendorId," ",y.rootVendorName]}),y.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",y.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",x.sessionInformations?x.sessionInformations.filter(k=>k.fabric?.fabricIndex===y.fabricIndex&&k.isPeerActive===!0).length:"0"," ","subscriptions: ",x.sessionInformations?x.sessionInformations.filter(k=>k.fabric?.fabricIndex===y.fabricIndex&&k.isPeerActive===!0&&k.numberOfActiveSubscriptions>0).length:"0"]})]},j))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]})):!x.commissioned&&!x.advertising?(s&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx(oe,{onClick:H,endIcon:e.jsx(re,{path:Lt,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]})):(s&&console.log("QRDiv rendering unknown state"),null):(s&&console.log("QRDiv rendering offline state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"normal"},children:"Server offline"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]}))}const Ko=r.memo(Qo);function Jo(){const{logMessage:i,sendMessage:m,getUniqueId:c}=r.useContext(fe),[n,l]=r.useState("matterbridge-"),[b,g]=r.useState(!1),[t,x]=r.useState(null),P=r.useRef(c()),p=j=>{j.preventDefault(),g(!0)},C=()=>{g(!1)},E=j=>{j.preventDefault(),g(!1);const k=j.dataTransfer.files[0];if(k){i("Plugins",`Installing package ${k.name}. Please wait...`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(O=>O.text()).then(O=>{i("Plugins",`Server response: ${O}`)}).catch(O=>{console.error("Error uploading plugin file:",O),i("Plugins",`Error installing package ${O}`)})}},H=j=>{const k=j.target.files&&j.target.files[0];if(k){i("Plugins",`Uploading package ${k.name}`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(O=>O.text()).then(O=>{i("Plugins",`Server response: ${O}`)}).catch(O=>{console.error("Error uploading plugin file:",O),i("Plugins",`Error uploading package ${O}`)})}},W=()=>{m({id:P.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},_=()=>{document.getElementById("file-upload")?.click()},f=()=>{m({id:P.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},X=j=>{x(j.currentTarget)},y=j=>{j!==""&&l(j),x(null)};return s&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:p,onDragLeave:C,onDrop:E,children:[e.jsx(pe,{value:n,onChange:j=>{l(j.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:X,children:e.jsx(br,{})}),e.jsxs(ze,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>y(""),children:[e.jsx(D,{onClick:()=>y("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(D,{onClick:()=>y("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(D,{onClick:()=>y("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(D,{onClick:()=>y("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(D,{onClick:()=>y("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(D,{onClick:()=>y("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(D,{onClick:()=>y("matterbridge-test"),children:"matterbridge-test"}),e.jsx(D,{onClick:()=>y("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(D,{onClick:()=>y("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(D,{onClick:()=>y("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(D,{onClick:()=>y("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(D,{onClick:()=>y("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(D,{onClick:()=>y("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(D,{onClick:()=>y("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(T,{title:"Install or update a plugin from npm",children:e.jsx(oe,{onClick:W,endIcon:e.jsx(Se,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(T,{title:"Upload and install a plugin from a tarball",children:e.jsx(oe,{onClick:_,endIcon:e.jsx(vr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(T,{title:"Add an installed plugin",children:e.jsx(oe,{onClick:f,endIcon:e.jsx(ct,{}),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:H})]})}const Go=r.memo(Jo);function Ee({status:i,enabledText:m="Enabled",disabledText:c=void 0,tooltipText:n=void 0,onClick:l}){if(i===void 0)return null;{const b=e.jsx("div",{className:i?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:i?m:c??m});return n!==void 0?e.jsx(T,{title:n,children:b}):b}}function Rt(i){return i.id!==0&&i.src==="Matterbridge"&&i.dst==="Frontend"}const Ae={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_e={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Yo={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Xo={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ne={padding:"0px",margin:"0px"},Zo="5px 10px 5px 10px",st={},be={},at={},lt={};let qe=[],xt=[];const en=({open:i,onClose:m,plugin:c})=>{const{sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(fe),t=r.useRef(g()),[x,P]=r.useState(c.configJson),[p,C]=r.useState(null),[E,H]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[W,_]=r.useState("");let f={};r.useEffect(()=>{const S=M=>{M.src==="Matterbridge"&&M.dst==="Frontend"&&(Rt(M)&&M.id===t.current&&M.method==="/api/select/devices"&&M.response&&(s&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/devices:`,M.response),qe=M.response),Rt(M)&&M.id===t.current&&M.method==="/api/select/entities"&&M.response&&(s&&console.log(`ConfigPluginDialog (id: ${M.id}) received ${M.response.length} /api/select/entities:`,M.response),xt=M.response))};return l(S,t.current),s&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),x&&p&&p.properties&&(Object.keys(p.properties).forEach(M=>{Object.keys(p.properties[M]).forEach(F=>{F.startsWith("ui:")&&(E[M]={},E[M][F]=p.properties[M][F],delete p.properties[M][F])})}),H(E)),c.name&&c.configJson&&c.schemaJson&&(P(c.configJson),C(c.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),s&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',c.name)),()=>{b(S),s&&console.log("ConfigPluginDialog removed WebSocket listener")}},[l,x,c,b,p,n,E]);const X=(S,M)=>{f=S.formData},y=S=>{s&&console.log("ConfigPluginDialog handleSaveChanges:",S.formData),P(S.formData),c.configJson=S.formData,c.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:S.formData.name,formData:S.formData}}),m()};function j(S){const{id:M,label:F,onKeyChange:A,onDropPropertyClick:Y,disabled:ae,schema:de,children:le,registry:N,readonly:h,required:ne}=S,{templates:J}=N,{RemoveButton:ve}=J.ButtonTemplates;if(!(Fo in de))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const he=({target:K})=>A(K&&K.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${M}-key`,name:`${M}-key`,required:ne,disabled:ae||h,defaultValue:F,onBlur:h?void 0:he,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:le}),e.jsx(ve,{disabled:ae||h,onClick:Y(F),registry:N})]})}function k(S){const{children:M,description:F,displayLabel:A,errors:Y,help:ae,hidden:de,registry:le,uiSchema:N}=S,h=Lo(N),ne=$o("WrapIfAdditionalTemplate",le,h);return de?e.jsx("div",{style:{display:"none"},children:M}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(ne,{...S,children:[A===!0&&F,M,Y,ae]})})}function R(S){const{description:M}=S;return M?e.jsx(ie,{sx:_e,children:M}):null}function O(S){const{required:M,title:F}=S;return F?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ie,{sx:Ae,children:["Title ",F," ",M&&e.jsx("mark",{children:"***"})]})}):null}function G(S){const{help:M}=S;return M?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ie,{sx:Yo,children:M})}):null}function v(S){const{errors:M}=S;return M?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ie,{color:"error",sx:Xo,children:"Please fix the following errors:"}),e.jsx(Je,{children:M.map((F,A)=>e.jsxs(yr,{children:[e.jsx(z,{children:e.jsx(jr,{color:"error"})}),e.jsx(te,{primary:F.stack})]},A))})]}):null}function a(S){const{errors:M}=S;return M?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:M.map((F,A)=>e.jsxs(ie,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",F]},A))}):null}function o(S){const{id:M,name:F,_schema:A,_uiSchema:Y,value:ae,options:de,label:le,type:N,placeholder:h,required:ne,disabled:J,readonly:ve,autofocus:je,onChange:he,onChangeOverride:K,onBlur:ce,onFocus:ye,_rawErrors:Qe,_hideError:B,_registry:I,_formContext:ue}=S,Ke=({target:{value:we}})=>he(we===""?de.emptyValue:we),Pe=({target:we})=>ce(M,we&&we.value),Ye=({target:we})=>ye(M,we&&we.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:M,name:M,label:h&&h!==""?le:void 0,variant:"outlined",placeholder:h&&h!==""?h:le,required:ne,disabled:J||ve,autoFocus:je,value:ae||ae===0?ae:"",type:N,autoComplete:N==="password"?"current-password":F,onChange:K||Ke,onBlur:Pe,onFocus:Ye,fullWidth:!0})})}function d(S){return console.log("ArrayFieldTitleTemplate:",S),null}function u(S){return console.log("ArrayFieldDescriptionTemplate:",S),null}function w(S){return console.log("ArrayFieldItemTemplate:",S),null}function V(S){const{canAdd:M,onAddClick:F,schema:A,title:Y}=S,[ae,de]=r.useState(!1),[le,N]=r.useState(!1),[h,ne]=r.useState(!1),[J,ve]=r.useState(""),je=I=>{ve(I.target.value)},he=()=>{s&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",J,"selectDevices:",qe),de(!ae)},K=()=>{s&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",J,"selectEntities:",xt),N(!le)},ce=()=>{s&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",J,"selectDevices:",qe),ne(!h)},ye=I=>{de(!1),A.selectFrom==="serial"?A.items.default=I.serial:A.selectFrom==="name"&&(A.items.default=I.name),F()},Qe=I=>{N(!1),A.selectEntityFrom==="name"?A.items.default=I.name:A.selectEntityFrom==="description"&&(A.items.default=I.description),F()},B=I=>{ne(!1),A.selectDeviceEntityFrom==="name"?A.items.default=I.name:A.selectDeviceEntityFrom==="description"&&(A.items.default=I.description),F()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Y&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Y&&e.jsx(ie,{sx:Ae,children:Y}),M&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[A.selectFrom&&e.jsx(T,{title:"Add a device from the list",children:e.jsx(Q,{onClick:he,size:"small",color:"primary",sx:Ne,children:e.jsx(tt,{})})}),A.selectEntityFrom&&e.jsx(T,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:K,size:"small",color:"primary",sx:Ne,children:e.jsx(tt,{})})}),A.selectDeviceEntityFrom&&e.jsx(T,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:ce,size:"small",color:"primary",sx:Ne,children:e.jsx(tt,{})})}),e.jsx(T,{title:"Add a new item",children:e.jsx(Q,{onClick:F,size:"small",color:"primary",sx:Ne,children:e.jsx(ct,{})})})]})]}),A.description&&e.jsx(ie,{sx:_e,children:A.description}),S.items.map(I=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:I.children}),e.jsx(Q,{disabled:!I.hasMoveUp,onClick:I.onReorderClick(I.index,I.index-1),size:"small",color:"primary",sx:Ne,children:e.jsx(Mt,{})}),e.jsx(Q,{disabled:!I.hasMoveDown,onClick:I.onReorderClick(I.index,I.index+1),size:"small",color:"primary",sx:Ne,children:e.jsx(St,{})}),e.jsx(Q,{onClick:I.onDropIndexClick(I.index),size:"small",color:"primary",sx:Ne,children:e.jsx(ut,{})})]},I.index)),e.jsxs(Me,{open:ae,onClose:he,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ie,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:J,onChange:je,placeholder:"Enter serial or name"})]}),e.jsx(Je,{dense:!0,children:qe.filter(I=>I.serial.toLowerCase().includes(J.toLowerCase())||I.name.toLowerCase().includes(J.toLowerCase())).map((I,ue)=>e.jsxs(rt,{onClick:()=>ye(I),sx:st,children:[I.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:be})}),I.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:be})}),I.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:be})}),e.jsx(te,{primary:I.name,secondary:I.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},ue))})]}),e.jsx($e,{children:e.jsx(oe,{onClick:he,children:"Close"})})]}),e.jsxs(Me,{open:le,onClose:K,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select an entity"}),e.jsxs(Ie,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ie,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:J,onChange:je,placeholder:"Enter name or description"})]}),e.jsx(Je,{dense:!0,children:xt.filter(I=>I.name.toLowerCase().includes(J.toLowerCase())||I.description.toLowerCase().includes(J.toLowerCase())).map((I,ue)=>e.jsxs(rt,{onClick:()=>Qe(I),sx:st,children:[I.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:be})}),I.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:be})}),I.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:be})}),I.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:be})}),I.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:be})}),e.jsx(te,{primary:I.name,secondary:I.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},ue))})]}),e.jsx($e,{children:e.jsx(oe,{onClick:K,children:"Close"})})]}),e.jsxs(Me,{open:h,onClose:ce,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(ke,{children:["Select an entity for ",Y]}),e.jsx(Ie,{children:e.jsx(Je,{dense:!0,children:qe.filter(I=>I.serial===Y||I.name===Y).map(I=>I.entities?.map((ue,Ke)=>e.jsxs(rt,{onClick:()=>B(ue),sx:st,children:[ue.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:be})}),ue.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:be})}),ue.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:be})}),ue.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:be})}),ue.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:be})}),e.jsx(te,{primary:ue.name,secondary:ue.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},Ke)))})}),e.jsx($e,{children:e.jsx(oe,{onClick:ce,children:"Close"})})]})]})}function ge(S){const{onAddClick:M,schema:F,properties:A,title:Y,description:ae}=S,[de,le]=r.useState(!1),[N,h]=r.useState(""),ne=K=>{h(K.target.value)},J=()=>{le(!de)},ve=K=>{s&&console.log(`ObjectFieldTemplate: handleSelectValue value "${K.serial}" for schema "${F.selectFrom}"`),le(!1);let ce="";F.selectFrom==="serial"?ce=K.serial:F.selectFrom==="name"&&(ce=K.name),_(ce),s&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ce}"`),M(F)()},je=()=>{M(F)()},he=!F.additionalProperties;return s&&console.log(`ObjectFieldTemplate: isRoot ${he} newkey "${W}"`),!he&&W!==""&&(s&&console.log("ObjectFieldTemplate: newkey",W,"properties",A),A.forEach(K=>{if(K.name==="newKey"&&K.content.key==="newKey"&&K.content.props.name==="newKey"&&K.content.props.onKeyChange&&W!==""){s&&console.log("ObjectFieldTemplate: newkey onKeyChange",W);const ce=W;_(""),K.content.props.onKeyChange(ce)}})),e.jsxs(Z,{sx:{margin:"0px",padding:he?"10px":"5px 10px 0px 10px",border:he?"none":"1px solid grey"},children:[F.title&&he&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ie,{sx:Ae,children:F.title})}),Y&&!he&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ie,{sx:Ae,children:Y}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[F.selectFrom&&e.jsx(T,{title:"Add a device from the list",children:e.jsx(Q,{onClick:J,size:"small",color:"primary",sx:Ne,children:e.jsx(tt,{})})}),e.jsx(T,{title:"Add a new item",children:e.jsx(Q,{onClick:je,size:"small",color:"primary",sx:Ne,children:e.jsx(ct,{})})})]})]}),F.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ie,{sx:_e,children:F.description})}),A.map(({content:K,name:ce,hidden:ye})=>!ye&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(F.properties[ce].type)?"0px":Zo,border:["object","array","boolean"].includes(F.properties[ce].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(F.properties[ce].type)&&e.jsx(ie,{sx:Ae,children:ce}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:K})]},ce)),e.jsxs(Me,{open:de,onClose:J,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ie,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:N,onChange:ne,placeholder:"Enter serial or name"})]}),e.jsx(Je,{dense:!0,children:qe.filter(K=>K.serial.toLowerCase().includes(N.toLowerCase())||K.name.toLowerCase().includes(N.toLowerCase())).map((K,ce)=>e.jsxs(rt,{onClick:()=>ve(K),sx:st,children:[K.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:be})}),K.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:be})}),K.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:be})}),e.jsx(te,{primary:K.name,secondary:K.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},ce))})]}),e.jsx($e,{children:e.jsx(oe,{onClick:J,children:"Close"})})]})]})}function me(S){const{uiSchema:M}=S,{submitText:F,norender:A}=Wo(M);return A?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(oe,{type:"submit",variant:"contained",color:"primary",children:F}),e.jsx(oe,{variant:"contained",color:"primary",onClick:m,children:"Cancel"})]})}function xe(S){const{className:M,disabled:F,onClick:A,registry:Y,style:ae,uiSchema:de,...le}=S;return e.jsx(T,{title:"Remove the item",children:e.jsx(Q,{disabled:F,size:"small",color:"primary",onClick:A,children:e.jsx(ut,{})})})}function ee(S){const{className:M,disabled:F,onClick:A,registry:Y,uiSchema:ae,...de}=S;return e.jsx(T,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:A,children:e.jsx(ct,{})})})}function se(S){const{disabled:M,onClick:F,registry:A,style:Y,uiSchema:ae,...de}=S;return e.jsx(T,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:F,children:e.jsx(Mt,{})})})}function L(S){const{disabled:M,onClick:F,registry:A,style:Y,uiSchema:ae,...de}=S;return e.jsx(T,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:F,children:e.jsx(St,{})})})}function U(S){const{id:M,name:F,value:A,schema:Y,readonly:ae,onChange:de}=S,[le,N]=r.useState(),h=J=>{s&&console.log(`CheckboxWidget ${F} onChangeField:`,J),N(J&&J!==""?J:void 0)},ne=()=>{s&&console.log(`CheckboxWidget onClick plugin="${c.name}" action="${F}" value="${le}"`),n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name,action:F,value:le,formData:f,id:M}}),Y.buttonClose===!0?m():Y.buttonSave===!0&&y({formData:x})};return Y.buttonText&&Y.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ie,{sx:_e,children:Y.description}),e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>ne(),children:Y.buttonText})]}):Y.buttonField&&Y.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ie,{sx:_e,children:Y.description}),e.jsx(pe,{id:F+"-input",name:F,label:Y.textLabel,placeholder:Y.textPlaceholder,onChange:J=>h(J.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(oe,{id:F+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>ne(),children:Y.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[F&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ie,{sx:Ae,children:F}),e.jsx(Te,{checked:A,readOnly:ae,onChange:()=>de(!A),sx:{padding:"0px",margin:"0px"}})]}),Y.description&&e.jsx(ie,{sx:_e,children:Y.description})]})}function $({schema:S,id:M,name:F,options:A,label:Y,hideLabel:ae,required:de,disabled:le,placeholder:N,readonly:h,value:ne,multiple:J,autofocus:ve,onChange:je,onBlur:he,onFocus:K,errorSchema:ce,rawErrors:ye=[],registry:Qe,uiSchema:B,hideError:I,formContext:ue,...Ke}){const{enumOptions:Pe,enumDisabled:Ye,emptyValue:we}=A;J=typeof J>"u"?!1:!!J;const yt=J?[]:"",jt=typeof ne>"u"||J&&ne.length<1||!J&&ne===yt,Kt=({target:{value:De}})=>je(ft(De,Pe,we)),Jt=({target:De})=>he(M,ft(De&&De.value,Pe,we)),Gt=({target:De})=>K(M,ft(De&&De.value,Pe,we)),Ct=No(ne,Pe,J),{InputLabelProps:Yt,SelectProps:Xt,autocomplete:Zt,...er}=Ke,tr=!J&&S.default===void 0;return e.jsxs(pe,{id:M,name:M,value:!jt&&typeof Ct<"u"?Ct:yt,required:de,disabled:le||h,autoFocus:ve,autoComplete:Zt,placeholder:N,error:ye.length>0,onChange:Kt,onBlur:Jt,onFocus:Gt,...er,select:!0,InputLabelProps:{...Yt,shrink:!jt},SelectProps:{...Xt,multiple:J},"aria-describedby":Po(M),children:[tr&&e.jsx(D,{value:"",children:N}),Array.isArray(Pe)&&Pe.map(({value:De,label:rr},wt)=>{const or=Array.isArray(Ye)&&Ye.indexOf(De)!==-1;return e.jsx(D,{value:String(wt),disabled:or,children:rr},wt)})]})}return s&&console.log("ConfigPluginDialog rendering..."),!i||!p||!x?null:e.jsxs(Me,{open:i,onClose:m,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(ke,{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(Ie,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Io,{schema:p,formData:x,uiSchema:E,validator:Do,templates:{FieldTemplate:k,BaseInputTemplate:o,TitleFieldTemplate:O,DescriptionFieldTemplate:R,FieldHelpTemplate:G,FieldErrorTemplate:a,ErrorListTemplate:v,WrapIfAdditionalTemplate:j,ArrayFieldTitleTemplate:d,ArrayFieldDescriptionTemplate:u,ArrayFieldItemTemplate:w,ArrayFieldTemplate:V,ObjectFieldTemplate:ge,ButtonTemplates:{SubmitButton:me,RemoveButton:xe,AddButton:ee,MoveUpButton:se,MoveDownButton:L}},widgets:{CheckboxWidget:U,SelectWidget:$},onChange:X,onSubmit:y})})]})};function Qt(i){if(s&&console.log(`getQRColor (id: ${i?.id}) received matter:`,i??"undefined"),i===void 0||!i.online||!i.qrPairingCode&&!i.manualPairingCode&&!i.fabricInformations&&!i.sessionInformations)return"red";if(i.commissioned===!1&&i.qrPairingCode&&i.manualPairingCode)return"var(--primary-color)";let m=0,c=0;for(const n of i.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&m++,n.numberOfActiveSubscriptions>0&&(c+=n.numberOfActiveSubscriptions);return i.commissioned===!0&&i.fabricInformations&&i.sessionInformations&&(m===0||c===0)?"var(--secondary-color)":"var(--div-text-color)"}function tn(i,m,c){const n=i?.[c],l=m?.[c];return n==null&&l==null?0:n==null?-1:l==null?1:typeof n=="boolean"&&typeof l=="boolean"?n===l?0:n?1:-1:typeof n=="number"&&typeof l=="number"?n-l:String(n).localeCompare(String(l))}function rn({name:i,title:m,columns:c,rows:n,getRowKey:l,footerLeft:b,footerRight:g,onRowClick:t}){const x=r.useRef(new WeakMap),P=r.useRef(1),p=a=>{if(typeof l=="string"&&a&&a[l]!=null)return a[l];if(typeof l=="function"){const u=l(a);if(u!=null)return u}const o=c?.[0]?.id;if(o&&a&&a[o]!=null)return a[o];console.warn(`MbfTable(${i}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let d=x.current.get(a);return d||(d=`rk_${P.current++}`,x.current.set(a,d)),d},[C,E]=r.useState(localStorage.getItem(`${i}_table_order_by`)||null),[H,W]=r.useState(localStorage.getItem(`${i}_table_order`)||null),[_,f]=r.useState(!1),[X,y]=r.useState(()=>{try{const a=localStorage.getItem(`${i}_column_visibility`);if(a)return JSON.parse(a)}catch{}return{}}),j=r.useMemo(()=>{const a={};for(const o of c)o.hidden||(a[o.id]=o.required?!0:X[o.id]!==!1);return a},[c,X]),k=r.useMemo(()=>{if(!C||!H)return n;const a=c.find(d=>d.id===C);if(!a||a.noSort)return n;const o=n.map((d,u)=>({el:d,index:u}));return o.sort((d,u)=>{let w;return typeof a.comparator=="function"?w=a.comparator(d.el,u.el):w=tn(d.el,u.el,C),w!==0?H==="asc"?w:-w:d.index-u.index}),o.map(d=>d.el)},[n,C,H,c]),R=a=>{if(C!==a||!C){E(a),W("asc"),localStorage.setItem(`${i}_table_order_by`,a),localStorage.setItem(`${i}_table_order`,"asc");return}if(H==="asc"){W("desc"),localStorage.setItem(`${i}_table_order`,"desc");return}E(null),W(null),localStorage.removeItem(`${i}_table_order_by`),localStorage.removeItem(`${i}_table_order`)},O=()=>{f(!_)},G=a=>{y(o=>{const d=c.find(V=>V.id===a);if(d&&d.required)return o;const u=j[a]!==!1,w={...o};u?w[a]=!1:delete w[a];try{localStorage.setItem(`${i}_column_visibility`,JSON.stringify(w))}catch{}return w})},v=()=>{y({});try{localStorage.removeItem(`${i}_column_visibility`)}catch{}f(!1)};return s&&console.log(`Rendering table ${i}${C&&H?` ordered by ${C}:${H}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Me,{open:_,onClose:(a,o)=>{o==="backdropClick"||o==="escapeKeyDown"||O()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(ke,{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 ${i} columns`})]})}),e.jsx(Ie,{children:e.jsx(Cr,{children:c.filter(a=>!a.hidden).map(a=>e.jsx(Fe,{control:e.jsx(Te,{disabled:!!a.required,checked:a.required?!0:j[a.id]!==!1,onChange:()=>G(a.id)}),label:a.label},a.id))})}),e.jsxs($e,{children:[e.jsx(oe,{onClick:v,children:"Reset"}),e.jsx(oe,{variant:"contained",onClick:a=>{if(a?.currentTarget&&typeof a.currentTarget.blur=="function")try{a.currentTarget.blur()}catch{}const o=document.activeElement;if(o&&o instanceof HTMLElement&&typeof o.blur=="function")try{o.blur()}catch{}O()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:i}),m&&e.jsx("p",{className:"MbfWindowHeaderText",children:m}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(Q,{onClick:a=>{if(a?.currentTarget?.blur)try{a.currentTarget.blur()}catch{}O()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(T,{title:`Configure ${i} columns`,children:e.jsx(re,{path:io,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":`${i} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(a=>{if(a.hidden||!a.required&&j[a.id]===!1)return null;const o=!a.noSort,d=o&&C===a.id&&!!H;return e.jsxs("th",{onClick:o?()=>R(a.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:a.minWidth,maxWidth:a.maxWidth,textAlign:a.align||"left",cursor:o?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:a.maxWidth?"nowrap":void 0,overflow:a.maxWidth?"hidden":void 0,textOverflow:a.maxWidth?"ellipsis":void 0},"aria-sort":o?d?H==="asc"?"ascending":"descending":"none":void 0,children:[a.label,d&&e.jsxs("span",{style:{marginLeft:6},children:[H==="asc"&&e.jsx(re,{path:so,size:"15px"}),H==="desc"&&e.jsx(re,{path:ao,size:"15px"})]})]},a.id)})})}),e.jsx("tbody",{children:k.map((a,o)=>{const d=p(a);return e.jsx("tr",{className:o%2===0?"table-content-even":"table-content-odd",onClick:t?u=>t(a,d,u):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:c.map(u=>{if(u.hidden||!u.required&&j[u.id]===!1)return null;const w=a[u.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:u.align||"left",padding:"5px 10px",margin:"0",maxWidth:u.maxWidth,whiteSpace:u.maxWidth?"nowrap":void 0,overflow:u.maxWidth?"hidden":void 0,textOverflow:u.maxWidth?"ellipsis":void 0},children:typeof u.render=="function"?u.render(w,d,a,u):typeof w=="boolean"?e.jsx(Te,{checked:w,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):u.format&&typeof w=="number"?u.format(w):w!=null?String(w):null},u.id)})},d)})})]})}),(b||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:b}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}function on(i){return r.memo(i)}const mt=on(rn);function nn({storeId:i,setStoreId:m}){const{online:c,sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(fe),{showConfirmCancelDialog:t}=r.useContext(Be),x=r.useRef(g()),[P,p]=r.useState(null),[C,E]=r.useState(null),[H,W]=r.useState([]),_=[{label:"Name",id:"name",required:!0,render:(L,U,$,S)=>e.jsx(T,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a($),children:$.name})})},{label:"Description",id:"description",render:(L,U,$,S)=>e.jsx(T,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a($),children:$.description})})},{label:"Version",id:"version",render:(L,U,$,S)=>e.jsxs(e.Fragment,{children:[$.latestVersion!==void 0&&$.latestVersion!==$.version&&C&&!C.readOnly&&e.jsx(T,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>k($),children:["Update to v.",$.latestVersion]})}),$.version.includes("-dev-")&&$.devVersion!==void 0&&$.devVersion!==$.version&&C&&!C.readOnly&&e.jsx(T,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>R($),children:["Update to new dev v.",$.devVersion.split("-dev-")[0]]})}),e.jsx(T,{title:"Plugin version",children:e.jsx("span",{children:$.version})})]})},{label:"Author",id:"author",render:(L,U,$,S)=>e.jsx(e.Fragment,{children:$.author?$.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(L,U,$,S)=>e.jsx(e.Fragment,{children:$.type?$.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(L,U,$,S)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(T,{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:Qt($.matter)},onClick:()=>{$.matter?.id&&m($.matter?.id)},size:"small",children:e.jsx(At,{})})}),C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(T,{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:()=>G($),size:"small",children:e.jsx(dt,{})})}),e.jsx(T,{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:()=>xe($),size:"small",children:e.jsx(vt,{})})}),C&&!C.readOnly&&e.jsx(T,{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:()=>{X("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",$)},size:"small",children:e.jsx(ut,{})})}),$.enabled?e.jsx(T,{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:()=>{X("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",$)},size:"small",children:e.jsx(wr,{})})}):e.jsx(e.Fragment,{}),$.enabled?e.jsx(e.Fragment,{}):e.jsx(T,{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:()=>v($),size:"small",children:e.jsx(Sr,{})})}),e.jsx(T,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>d($),size:"small",children:e.jsx(Mr,{})})}),e.jsx(T,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u($),size:"small",children:e.jsx(kr,{})})}),C&&!C.readOnly&&e.jsx(T,{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:()=>o($),size:"small",children:e.jsx(Vt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(L,U,$,S)=>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(Ee,{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(Ee,{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(Ee,{status:$.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{status:$.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ee,{status:$.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ee,{status:$.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const L=U=>{U.src==="Matterbridge"&&U.dst==="Frontend"&&(U.method==="refresh_required"&&U.response.changed==="plugins"&&(s&&console.log(`HomePlugins received refresh_required: changed=${U.response.changed} and sending /api/plugins request`),n({id:x.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),U.method==="refresh_required"&&U.response.changed==="matter"&&(s&&console.log(`HomePlugins received refresh_required: changed=${U.response.changed} and setting matter id ${U.response.matter?.id}`),W($=>{const S=$.findIndex(F=>F.matter?.id===U.response.matter?.id);if(S<0)return s&&console.log(`HomePlugins received refresh_required: changed=${U.response.changed} and matter id ${U.response.matter?.id} not found`),$;s&&console.log(`HomePlugins received refresh_required: changed=${U.response.changed} set matter id ${U.response.matter?.id}`);const M=[...$];return M[S]={...M[S],matter:U.response.matter},M})),U.method==="refresh_required"&&U.response.changed==="settings"&&(s&&console.log(`HomePlugins received refresh_required: changed=${U.response.changed} and sending /api/settings request`),n({id:x.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),U.id===x.current&&U.method==="/api/settings"&&(s&&console.log(`HomePlugins (id: ${U.id}) received settings:`,U.response),p(U.response.systemInformation),E(U.response.matterbridgeInformation)),U.id===x.current&&U.method==="/api/plugins"&&(s&&console.log(`HomePlugins (id: ${U.id}) received ${U.response.length} plugins:`,U.response),W(U.response)))};return l(L,x.current),s&&console.log("HomePlugins added WebSocket listener id:",x.current),()=>{b(L),s&&console.log("HomePlugins removed WebSocket listener")}},[l,b,n]),r.useEffect(()=>{c&&(s&&console.log("HomePlugins sending api requests"),n({id:x.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:x.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]);const f=r.useRef(null),X=(L,U,$,S)=>{s&&console.log(`handleActionWithConfirmCancel ${$} ${S.name}`),f.current=S,t(L,U,$,y,j)},y=L=>{s&&console.log(`handleConfirm action confirmed ${L} ${f.current?.name}`),L==="remove"&&f.current?O(f.current):L==="disable"&&f.current&&v(f.current),f.current=null},j=L=>{s&&console.log(`handleCancel action canceled ${L} ${f.current?.name}`),f.current=null},k=L=>{s&&console.log("handleUpdatePlugin plugin:",L.name),n({id:x.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:L.name,restart:!1}})},R=L=>{s&&console.log("handleUpdateDevPlugin plugin:",L.name),n({id:x.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:L.name+"@dev",restart:!1}})},O=L=>{s&&console.log("handleRemovePlugin plugin:",L.name),n({id:x.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:L.name}})},G=L=>{s&&console.log("handleRestartPlugin plugin:",L.name),n({id:x.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:L.name}})},v=L=>{s&&console.log("handleEnableDisablePlugin plugin:",L.name,"enabled:",L.enabled),L.enabled===!0?(L.enabled=!1,n({id:x.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:L.name}})):(L.enabled=!0,n({id:x.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:L.name}}))},a=L=>{s&&console.log(`handleHomepagePlugin plugin: ${L.name} homepage: ${L.homepage}`),L.homepage&&window.open(L.homepage,"_blank")},o=L=>{s&&console.log("handleSponsorPlugin plugin:",L.name,"funding:",L.funding),L.funding&&window.open(L.funding,"_blank")},d=L=>{s&&console.log("handleHelpPlugin plugin:",L.name,"help:",L.help),L.help&&window.open(L.help,"_blank")},u=L=>{s&&console.log("handleChangelogPlugin plugin:",L.name,"changelog:",L.changelog),L.changelog&&window.open(L.changelog,"_blank")},[w,V]=r.useState(),[ge,me]=r.useState(!1),xe=L=>{s&&console.log("handleConfigPlugin plugin:",L.name),n({id:x.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:L.name}}),n({id:x.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:L.name}}),V(L),ee()},ee=()=>{me(!0)},se=()=>{me(!1)};return s&&console.log("HomePlugins rendering..."),c?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[w&&e.jsx(en,{open:ge,onClose:se,plugin:w}),e.jsx(mt,{name:"Plugins",columns:_,rows:H,footerRight:"",footerLeft:""})]}):e.jsx(Re,{})}const sn=r.memo(nn),an=i=>`${i.pluginName}::${i.serial}`;function ln({storeId:i,setStoreId:m}){const{online:c,sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(fe),[t,x]=r.useState(!1),[P,p]=r.useState(!0),[C,E]=r.useState(null),[H,W]=r.useState([]),[_,f]=r.useState([]),[X,y]=r.useState([]),[j,k]=r.useState([]),R=r.useRef(g()),O=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(a,o,d,u)=>d.reachable===!0?"Online":d.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(a,o)=>{const d=a.reachable===!0?1:a.reachable===!1?0:-1,u=o.reachable===!0?1:o.reachable===!1?0:-1;return d-u}},{label:"Power",id:"powerSource",render:(a,o,d,u)=>d.powerSource==="ac"||d.powerSource==="dc"?e.jsx(_t,{fontSize:"small",sx:{color:"var(--primary-color)"}}):d.powerSource==="ok"?e.jsx(pt,{fontSize:"small",sx:{color:"green"}}):d.powerSource==="warning"?e.jsx(pt,{fontSize:"small",sx:{color:"yellow"}}):d.powerSource==="critical"?e.jsx(pt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(a,o,d,u)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[d.matter!==void 0?e.jsx(T,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>m(i===d.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:d.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Qt(d.matter)},children:e.jsx(At,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.configUrl?e.jsx(T,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(d.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.selected!==void 0?e.jsx(T,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Te,{checked:d.selected,onChange:w=>v(w,d),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],G=r.useCallback(a=>{a.selected=void 0;const o=H.find(w=>w.name===a.pluginName);if(!o)return console.error(`HomeDevices isSelected: plugin ${a.pluginName} not found for device ${a.name} `),a.selected;const d=o.schemaJson?.properties?.whiteList?.selectFrom;let u=o.configJson.postfix;return u===""&&(u=void 0),o.hasWhiteList===!0&&o.hasBlackList===!0&&d&&(a.selected=!0,d==="serial"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&o.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!0),d==="serial"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&!o.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="serial"&&o.configJson.blackList&&o.configJson.blackList.length>0&&o.configJson.blackList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="name"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&o.configJson.whiteList.includes(a.name)&&(a.selected=!0),d==="name"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&!o.configJson.whiteList.includes(a.name)&&(a.selected=!1),d==="name"&&o.configJson.blackList&&o.configJson.blackList.length>0&&o.configJson.blackList.includes(a.name)&&(a.selected=!1)),a.selected},[H]);r.useEffect(()=>{const a=o=>{if(o.method==="refresh_required"&&o.response.changed!=="matter"?(s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and sending /api/plugins request`),n({id:R.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):o.method==="refresh_required"&&o.response.changed==="matter"?(s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and setting matter id ${o.response.matter?.id}`),k(d=>{const u=d.findIndex(V=>V.name.replaceAll(" ","")===o.response.matter?.id);if(u<0)return s&&console.debug(`HomeDevices: matter id ${o.response.matter?.id} not found`),d;const w=[...d];return w[u]={...w[u],matter:o.response.matter},s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and set matter id ${o.response.matter?.id}`),w})):o.method==="restart_required"?(s&&console.log("HomeDevices received restart_required"),x(!0)):o.method==="restart_not_required"?(s&&console.log("HomeDevices received restart_not_required"),x(!1)):o.method==="state_update"&&o.response.plugin&&o.response.serialNumber&&o.response.cluster.includes("BasicInformation")&&o.response.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${o.response.plugin} serial ${o.response.serialNumber} value ${o.response.value}`),f(d=>{const u=d.findIndex(w=>w.pluginName===o.response.plugin&&w.serial===o.response.serialNumber);return u<0?(console.warn(`HomeDevices: device to update not found for plugin ${o.response.plugin} serial ${o.response.serialNumber}`),d):(d[u]={...d[u],reachable:o.response.value},[...d])})),o.id===R.current&&o.method==="/api/settings")s&&console.log(`HomeDevices (id: ${o.id}) received settings:`,o.response),E(o.response),x(o.response.matterbridgeInformation.restartRequired||o.response.matterbridgeInformation.fixedRestartRequired);else if(o.id===R.current&&o.method==="/api/plugins"){if(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} plugins:`,o.response),o.response){let d=!0;for(const u of o.response)u.enabled===!0&&(u.loaded!==!0||u.started!==!0||u.error===!0)&&(d=!1);if(!d)return;s&&console.log("HomeDevices reset plugins, devices and selectDevices"),p(!1),W(o.response),f([]),y([]),n({id:R.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),s&&console.log("HomeDevices sent /api/devices");for(const u of o.response)u.enabled===!0&&u.loaded===!0&&u.started===!0&&u.error!==!0&&(n({id:R.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:u.name}}),s&&console.log(`HomeDevices sent /api/select/devices for plugin: ${u.name}`))}}else if(o.id===R.current&&o.method==="/api/devices"){if(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} devices:`,o.response),o.response){for(const d of o.response)d.selected=G(d);f(o.response)}}else o.id===R.current&&o.method==="/api/select/devices"&&(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} selectDevices for plugin ${o.response&&o.response.length>0?o.response[0].pluginName:"without select devices"}:`,o.response),o.response&&o.response.length>0&&y(d=>{const u=d.filter(V=>V.pluginName!==o.response[0].pluginName),w=o.response.map(V=>({...V,selected:G(V)}));return[...u,...w]}))};return l(a,R.current),s&&console.log(`HomeDevices added WebSocket listener id ${R.current}`),()=>{b(a),s&&console.log("HomeDevices removed WebSocket listener")}},[H,l,b,n,G]),r.useEffect(()=>{if(_.length===0&&X.length===0){k([]);return}s&&console.log(`HomeDevices mixing devices (${_.length}) and selectDevices (${X.length})`);const a=[];for(const o of _)a.push(o);for(const o of X)_.find(d=>d.pluginName===o.pluginName&&d.serial.includes(o.serial))||a.push(o);a.length>0&&(k(a),console.log(`HomeDevices mixed ${a.length} devices and selectDevices`))},[H,_,X,k]),r.useEffect(()=>{c&&(s&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:R.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:R.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]);const v=(a,o)=>{console.log(`handleCheckboxChange: checkbox changed to ${a.target.checked} for device ${o.name} serial ${o.serial}`),_.findIndex(d=>d.pluginName===o.pluginName&&d.serial===o.serial)<0?(s&&console.warn(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in devices, trying in mixedDevices`),k(d=>{const u=d.findIndex(w=>w.pluginName===o.pluginName&&w.serial===o.serial);return u<0?(console.error(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in mixedDevices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])})):f(d=>{const u=d.findIndex(w=>w.pluginName===o.pluginName&&w.serial===o.serial);return u<0?(console.error(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in devices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])}),a.target.checked?n({id:R.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:o.pluginName,serial:o.serial,name:o.name}}):n({id:R.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:o.pluginName,serial:o.serial,name:o.name}})};return s&&console.log("HomeDevices rendering..."),c?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Devices",getRowKey:an,rows:j,columns:O,footerLeft:P?"Waiting for the plugins to fully load...":`Registered devices: ${_.length.toString()}/${j.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Re,{})}const dn=r.memo(ln);function cn(){const[i,m]=r.useState(null),[c,n]=r.useState(null),[l,b]=r.useState([]),[g]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,x]=r.useState(localStorage.getItem("homePageMode")??"devices"),[P,p]=r.useState(""),[C,E]=r.useState(!1),[H,W]=r.useState(!1),[_,f]=r.useState(null),{addListener:X,removeListener:y,online:j,sendMessage:k,logFilterLevel:R,logFilterSearch:O,autoScroll:G,getUniqueId:v}=r.useContext(fe),a=r.useRef(v());return r.useEffect(()=>{const o=d=>{d.method==="refresh_required"&&d.response.changed==="settings"&&(console.log(`Home received refresh_required: changed=${d.response.changed} and sending /api/settings request`),f(null),b([]),k({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===a.current&&(console.log("Home received settings:",d.response),m(d.response.systemInformation),n(d.response.matterbridgeInformation),d.response.matterbridgeInformation.matterbridgeVersion&&p(`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),W(!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),E(!0)),d.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),x("devices")))),d.method==="/api/plugins"&&d.id===a.current&&(console.log("Home received plugins:",d.response),b(d.response))};return X(o,a.current),console.log(`Home added WebSocket listener id ${a.current}`),()=>{y(o),console.log("Home removed WebSocket listener")}},[X,y,k]),r.useEffect(()=>{if(console.log(`Home settings and plugins effect with storeId ${_}`),c?.bridgeMode==="bridge"&&!_&&(console.log(`Home set storeId from ${_} to Matterbridge`),f("Matterbridge")),c?.bridgeMode==="childbridge"&&!_&&l){for(const o of l)if(o.matter?.id){console.log(`Home set storeId from ${_} to ${o.matter.id}`),f(o.matter.id);break}}},[c,l,_]),r.useEffect(()=>{j&&(console.log("Home online effect, sending /api/settings and /api/plugins requests"),k({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[j,k]),console.log("Home rendering..."),!j||!i||!c?e.jsx(Re,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ko,{id:_}),e.jsx(Uo,{systemInfo:i,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[H&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx(Ir,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),C&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(oe,{onClick:()=>window.open(P,"_blank"),endIcon:e.jsx(Et,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx(Dr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),g&&!c.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(Go,{})]}),g&&e.jsx(sn,{storeId:_,setStoreId:f}),t==="devices"&&e.jsx(dn,{storeId:_,setStoreId:f}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',R,'" and search "',O,'" Scroll: ',G?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(Bt,{})})]})]})]})}const pn=r.memo(cn),Ht={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},un={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},gn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Ot={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},mn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},hn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},fn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},xn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},bn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},bt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},vn=[256,257,268,269],yn=[266,267],jn=[259,260,261,271,272],Cn=[256,257,268,269,266,267,259,260,261,272];function q({icon:i,iconColor:m,cluster:c,value:n,unit:l,prefix:b}){return s&&console.log(`Render cluster "${c.clusterName}.${c.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${l}"`),b=b??!1,e.jsxs(Z,{sx:Ht,children:[i&&r.cloneElement(i,{key:`${c.clusterId}-${c.attributeId}-icon`,sx:{...un,color:m??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Ht,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&b===!0&&e.jsx(ie,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`),e.jsx(ie,{sx:gn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${c.clusterId}-${c.attributeId}-value`),l&&b===!1&&e.jsx(ie,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`)]},`${c.clusterId}-${c.attributeId}-valueunitbox`)]},`${c.clusterId}-${c.attributeId}-box`)}function wn({device:i,endpoint:m,id:c,deviceType:n,clusters:l}){const b=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";return s&&console.log(`Device "${i.name}" endpoint "${m}" id "${c}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>g=`${t.attributeLocalValue} mV`),Cn.includes(n)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>g=`Level ${t.attributeValue}`),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>g=`Position ${t.attributeLocalValue/100}%`),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>g=`Heat ${t.attributeLocalValue/100}°C `),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>g=g+`Cool ${t.attributeLocalValue/100}°C`),n===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>g=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>g=`${t.attributeLocalValue/1e3} V, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>g=g+`${t.attributeLocalValue/1e3} A, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>g=g+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[n===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:t.attributeLocalValue===!0?e.jsx(Ge,{}):e.jsx(Nr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(q,{icon:e.jsx(pt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(q,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),vn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Pr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),yn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(re,{path:co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(re,{path:po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:"Oven"})),n===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Wr,{}),cluster:t,value:"Fridge"})),n===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(re,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(q,{icon:e.jsx(re,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(re,{path:$t,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(re,{path:$t,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(re,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(q,{icon:e.jsx(Lr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(re,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(q,{icon:t.attributeValue==="1"?e.jsx($r,{}):e.jsx(Fr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Tr,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(q,{icon:e.jsx(re,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(q,{icon:e.jsx(Rr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Hr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Nt,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(Nt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Er,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(q,{icon:e.jsx(re,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(q,{icon:e.jsx(re,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(re,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(re,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(q,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(q,{icon:e.jsx(re,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:b[t.attributeLocalValue??0]})),n===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(re,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:t.attributeValue==="true"?e.jsx(Ur,{}):e.jsx(Br,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Qr,{}):e.jsx(Kr,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Jr,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),n===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(q,{icon:e.jsx(Gr,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:mn,children:e.jsx(ie,{sx:hn,children:g})}),e.jsx(Z,{sx:fn,children:e.jsx(ie,{sx:xn,children:i.name})}),e.jsxs(Z,{sx:bn,children:[s&&e.jsx(ie,{sx:bt,children:m}),e.jsx(ie,{sx:bt,children:c}),s&&e.jsxs(ie,{sx:bt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function Sn({filter:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(fe),[g,t]=r.useState(null),[x,P]=r.useState([]),[p,C]=r.useState([]),[E,H]=r.useState(p),[W,_]=r.useState({}),[f,X]=r.useState({}),[y,j]=r.useState({}),k=r.useRef(b()),R=r.useRef(E),O=r.useCallback(v=>{console.log(`DevicesIcons received state_update "${v.response.cluster}.${v.response.attribute}" for "${v.response.id}:${v.response.number}": "${v.response.value}"`,v.response);const a=R.current.find(d=>d.pluginName===v.response.plugin&&d.uniqueId===v.response.uniqueId);if(!a){console.warn(`DevicesIcons updater device of plugin "${v.response.plugin}" serial "${v.response.serialNumber}" not found in filteredDevicesRef.current`);return}const o=y[a.serial].find(d=>d.endpoint===v.response.number.toString()&&d.clusterName===v.response.cluster&&d.attributeName===v.response.attribute);if(!o){console.warn(`DevicesIcons updater device "${a.name}" serial "${a.serial}" cluster "${v.response.cluster}" attribute "${v.response.attribute}" not found in clusters`);return}o.attributeValue=String(v.response.value),o.attributeLocalValue=v.response.value,j({...y}),console.log(`DevicesIcons updated "${o.clusterName}.${o.attributeName}" for device "${a.name}" serial "${a.serial}" to "${o.attributeValue}"`)},[y]);r.useEffect(()=>{const v=a=>{if(a.method==="refresh_required")s&&console.log(`DevicesIcons received refresh_required: changed=${a.response.changed} and sending api requests`),c({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(a.method==="state_update"&&a.response)O(a);else if(a.method==="/api/settings"&&a.response)s&&console.log("DevicesIcons received settings:",a.response),t(a.response);else if(a.method==="/api/plugins"&&a.response)s&&console.log("DevicesIcons received plugins:",a.response),P(a.response);else if(a.method==="/api/devices"&&a.response){s&&console.log(`DevicesIcons received ${a.response.length} devices:`,a.response),C(a.response);for(const o of a.response)s&&console.log("DevicesIcons sending /api/clusters"),c({id:k.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:o.pluginName,endpoint:o.endpoint||0}})}else if(a.method==="/api/clusters"&&a.response){if(s&&console.log(`DevicesIcons received for device "${a.response.deviceName}" serial "${a.response.serialNumber}" deviceTypes (${a.response.deviceTypes.length}) "${a.response.deviceTypes.join(",")}" clusters (${a.response.clusters.length}):`,a.response),a.response.clusters.length===0)return;const o=a.response.serialNumber;W[o]=[],f[o]=a.response.deviceTypes,y[o]=[];for(const d of a.response.clusters)W[o].find(u=>u.endpoint===d.endpoint)||W[o].push({endpoint:d.endpoint,id:d.id,deviceTypes:d.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(d.clusterName)&&y[o].push(d);_({...W}),X({...f}),j({...y}),s&&console.log(`DevicesIcons endpoints for "${o}":`,W[o]),s&&console.log(`DevicesIcons deviceTypes for "${o}":`,f[o]),s&&console.log(`DevicesIcons clusters for "${o}":`,y[o])}};return n(v,k.current),s&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(v),s&&console.log("DevicesIcons useEffect webSocket unmounted")}},[]),r.useEffect(()=>(s&&console.log("DevicesIcons useEffect online mounting"),m&&(s&&console.log("DevicesIcons useEffect online sending api requests"),c({id:k.current,sender:"DevicesIcons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:k.current,sender:"DevicesIcons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:k.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),s&&console.log("DevicesIcons useEffect online mounted"),()=>{s&&console.log("DevicesIcons useEffect online unmounted")}),[m,c]),r.useEffect(()=>{if(i===""){H(p),R.current=p;return}const v=p.filter(a=>a.name.toLowerCase().includes(i)||a.serial.toLowerCase().includes(i));H(v),R.current=v},[p,i]);const G=r.memo(wn);return s&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:E.map(v=>W[v.serial]&&W[v.serial].map(a=>a.deviceTypes.map(o=>e.jsx(G,{device:v,endpoint:a.endpoint,id:a.id,deviceType:o,clusters:y[v.serial].filter(d=>d.endpoint===a.endpoint)},`${v.pluginName}-${v.uniqueId}-${a.id}-${o.toString()}`))))})}const Mn=r.memo(Sn),kn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(i,m,c,n)=>c.configUrl?e.jsx(Q,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],In=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(i,m,c,n)=>Array.isArray(i)?e.jsx(e.Fragment,{children:i.map(l=>`0x${l.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:i})},{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:(i,m,c,n)=>e.jsx(T,{title:String(i),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(i)})})}],Dn=i=>`${i.pluginName}::${i.uniqueId}`,Nn=i=>`${i.endpoint}::${i.clusterName}::${i.attributeName}`;function Pn({filter:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(fe),[g,t]=r.useState([]),[x,P]=r.useState(g),[p,C]=r.useState([]),[E,H]=r.useState(0),[W,_]=r.useState(null),[f,X]=r.useState(null),[y,j]=r.useState(null),[k,R]=r.useState(null),O=r.useRef(b()),G=r.useRef(x),v=r.useCallback(o=>{console.log(`DevicesTable received state_update "${o.response.cluster}.${o.response.attribute}" for "${o.response.id}:${o.response.number}": "${o.response.value}"`,o.response);const d=G.current.find(u=>u.pluginName===o.response.plugin&&u.uniqueId===o.response.uniqueId);if(!d){console.warn(`DevicesTable updater device of plugin "${o.response.plugin}" serial "${o.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(W&&f&&d.pluginName===W&&d.uniqueId===k&&o.response.number.toString()===f){const u=p.find(w=>w.endpoint===o.response.number.toString()&&w.clusterName===o.response.cluster&&w.attributeName===o.response.attribute);if(!u){console.warn(`DevicesTable updater cluster ${o.response.cluster}.${o.response.attribute} for device "${d.name}" serial "${d.serial}" not found in clusters`);return}u.attributeValue=String(o.response.value),u.attributeLocalValue=o.response.value,C([...p]),console.log(`DevicesTable updated attribute ${u.clusterName}.${u.attributeName} for device "${d.name}" serial "${d.serial}" to "${u.attributeValue}"`)}},[p,f,W,k]);r.useEffect(()=>{const o=d=>{if(s&&console.log("DevicesTable received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed==="devices")s&&console.log(`DevicesTable received refresh_required: changed=${d.response.changed} and sending /api/devices request`),c({id:O.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(d.method==="state_update"&&d.response)v(d);else if(d.method==="/api/devices")s&&console.log(`DevicesTable received ${d.response.length} devices:`,d.response),t(d.response);else if(d.method==="/api/clusters"){s&&console.log(`DevicesTable received ${d.response.clusters.length} clusters for plugin ${d.response.plugin}:`,d.response),C(d.response.clusters);const u={};for(const w of d.response.clusters)s&&console.log("Cluster:",w.endpoint),u[w.endpoint]?u[w.endpoint]++:u[w.endpoint]=1;H(Object.keys(u).length)}};return n(o,O.current),s&&console.log("DevicesTable added WebSocket listener"),()=>{l(o),s&&console.log("DevicesTable removed WebSocket listener")}},[c,n,l,v]),r.useEffect(()=>{m&&(s&&console.log("DevicesTable sending api requests with id ",O.current),c({id:O.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[m,c]),r.useEffect(()=>{W&&f&&(s&&console.log("DevicesTable sending /api/clusters"),c({id:O.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:W,endpoint:Number(f)}}))},[W,f,c]),r.useEffect(()=>{if(i===""){P(g),G.current=g;return}const o=g.filter(d=>d.name.toLowerCase().includes(i)||d.serial.toLowerCase().includes(i));P(o),G.current=o},[g,i]);const a=o=>{if(o.uniqueId===k){R(null),_(null),X(null),j(null);return}R(o.uniqueId),_(o.pluginName),X(o.endpoint?o.endpoint.toString():null),j(o.name)};return s&&console.log("DevicesTable rendering..."),m?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${W&&f?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Registered devices",getRowKey:Dn,onRowClick:a,rows:x,columns:kn,footerLeft:`Total devices: ${x.length.toString()}`})}),W&&f&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Clusters",title:y||"",getRowKey:Nn,rows:p,columns:In,footerLeft:`Total child endpoints: ${E-1}`})})]}):e.jsx(Re,{})}const Wn=r.memo(Pn);function Ln(){const{online:i}=r.useContext(fe),[m,c]=r.useState(""),[n,l]=r.useState("icon");r.useEffect(()=>{const t=localStorage.getItem("devicesFilter");t&&c(t)},[]),r.useEffect(()=>{const t=localStorage.getItem("devicesViewMode");t&&l(t)},[]);const b=t=>{c(t.target.value.toLowerCase()),localStorage.setItem("devicesFilter",t.target.value.toLowerCase())},g=t=>{l(t),localStorage.setItem("devicesViewMode",t)};return s&&console.log("Devices rendering..."),i?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ie,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:m,onChange:b,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ie,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(Q,{onClick:()=>g("table"),"aria-label":"Table View",disabled:n==="table",children:e.jsx(T,{title:"Table View",children:e.jsx(Yr,{style:{color:n==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:n==="icon",children:e.jsx(T,{title:"Icon View (beta)",children:e.jsx(Xr,{style:{color:n==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),n==="table"&&e.jsx(Wn,{filter:m}),n==="icon"&&e.jsx(Mn,{filter:m})]}):e.jsx(Re,{})}const $n=r.memo(Ln);function Fn(){const[i,m]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[c,n]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[l,b]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:g,setLogFilters:t,online:x,setAutoScroll:P}=r.useContext(fe),p=W=>{m(W.target.value),t(W.target.value,c),localStorage.setItem("logFilterLevel",W.target.value),s&&console.log("handleChangeLevel called with value:",W.target.value)},C=W=>{n(W.target.value),t(i,W.target.value),localStorage.setItem("logFilterSearch",W.target.value),s&&console.log("handleChangeSearch called with value:",W.target.value)},E=W=>{b(W.target.checked),P(W.target.checked),localStorage.setItem("logAutoScroll",W.target.value?"true":"false"),s&&console.log("handleAutoScrollChange called with value:",W.target.checked)},H=()=>{s&&console.log("handleClearLogsClick called"),g([])};return s&&console.log("Logs rendering..."),x?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Pt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ue,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:i,onChange:p,children:[e.jsx(D,{value:"debug",children:"Debug"}),e.jsx(D,{value:"info",children:"Info"}),e.jsx(D,{value:"notice",children:"Notice"}),e.jsx(D,{value:"warn",children:"Warn"}),e.jsx(D,{value:"error",children:"Error"}),e.jsx(D,{value:"fatal",children:"Fatal"})]}),e.jsx(Pt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:c,onChange:C,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Fe,{control:e.jsx(Te,{checked:l,onChange:E}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(T,{title:"Clear the logs",children:e.jsx(oe,{onClick:H,endIcon:e.jsx(ut,{}),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(Bt,{})})]}):e.jsx(Re,{})}const Tn=r.memo(Fn),Rn=({open:i,ip:m,onClose:c,onSave:n})=>{const l=m?m.split(".").slice(0,3).join(".")+".1":"",[b,g]=r.useState("dhcp"),[t,x]=r.useState({ip:m??"",subnet:"255.255.255.0",gateway:l,dns:l}),P=E=>H=>{x({...t,[E]:H.target.value})},p=()=>{c()},C=()=>{n({type:b,...t}),c()};return e.jsxs(Me,{open:i,onClose:(E,H)=>{H==="backdropClick"||H==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(ke,{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(Ie,{dividers:!0,children:[e.jsxs(qt,{component:"fieldset",fullWidth:!0,children:[e.jsx(Ce,{component:"legend",children:"Select IP Configuration"}),e.jsxs(zt,{row:!0,value:b,onChange:E=>g(E.target.value),children:[e.jsx(Fe,{value:"dhcp",control:e.jsx(gt,{}),label:"DHCP"}),e.jsx(Fe,{value:"static",control:e.jsx(gt,{}),label:"Static"})]})]}),b==="static"&&e.jsxs(Le,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Le,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:P("ip")})}),e.jsx(Le,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:P("subnet")})}),e.jsx(Le,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:P("gateway")})}),e.jsx(Le,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:P("dns")})})]})]}),e.jsxs($e,{children:[e.jsx(oe,{onClick:p,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:C,children:"Save"})]})]})},Hn=({open:i,onClose:m,onSave:c})=>{const[n,l]=r.useState(""),[b,g]=r.useState(""),t=H=>{l(H.target.value)},x=H=>{g(H.target.value)},P=n.length>0&&n===b,p=()=>{m()},C=()=>{P&&(c(n),m())},E=()=>{c(""),m()};return e.jsxs(Me,{open:i,onClose:(H,W)=>{W==="backdropClick"||W==="escapeKeyDown"||m()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(ke,{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(Ie,{dividers:!0,children:e.jsx(qt,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Le,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Le,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:n,onChange:t})}),e.jsx(Le,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:b,onChange:x,error:b!==""&&n!==b,helperText:b!==""&&n!==b?"Passwords do not match":""})})]})})}),e.jsxs($e,{children:[e.jsx(oe,{onClick:p,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:C,disabled:!P,children:"Change"}),e.jsx(oe,{variant:"contained",onClick:E,children:"Reset"})]})]})};function On(){const{online:i,addListener:m,removeListener:c,sendMessage:n,getUniqueId:l}=r.useContext(fe),[b,g]=r.useState(null),[t,x]=r.useState(null),P=r.useRef(l());return r.useEffect(()=>{const p=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(C.method==="refresh_required"&&C.response.changed==="settings"&&(s&&console.log(`Settings received refresh_required: changed=${C.response.changed} and sending /api/settings request`),n({id:P.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),C.method==="/api/settings"&&(s&&console.log("Settings received /api/settings:",C.response),g(C.response.matterbridgeInformation),x(C.response.systemInformation)))};return m(p,P.current),s&&console.log("Settings added WebSocket listener"),()=>{c(p),s&&console.log("Settings removed WebSocket listener")}},[m,c,n]),r.useEffect(()=>{i&&(s&&console.log("Settings received online"),n({id:P.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),b?(s&&console.log("Settings rendering..."),i?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Vn,{matterbridgeInfo:b,systemInfo:t}),e.jsx(En,{matterbridgeInfo:b}),e.jsx(An,{matterbridgeInfo:b})]})}):e.jsx(Re,{})):null}function Vn({matterbridgeInfo:i,systemInfo:m}){const{sendMessage:c,getUniqueId:n}=r.useContext(fe),[l,b]=r.useState("bridge"),[g,t]=r.useState("Info"),[x,P]=r.useState(!1),[p,C]=r.useState("dark"),[E,H]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[W,_]=r.useState(localStorage.getItem("homePageMode")??"devices"),[f,X]=r.useState(localStorage.getItem("virtualMode")??"outlet"),y=r.useRef(n()),[j,k]=r.useState(!1),R=()=>k(!1),O=ee=>{s&&console.log("handleSaveNetConfig called with config:",ee),c({id:y.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:ee})},[G,v]=r.useState(!1),a=()=>v(!1),o=ee=>{s&&console.log("handleSaveChangePassword called with password:",ee),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:ee}})};r.useEffect(()=>{i&&(b(i.bridgeMode==="bridge"?"bridge":"childbridge"),t(i.loggerLevel.charAt(0).toUpperCase()+i.loggerLevel.slice(1)),P(i.fileLogger),X(i.virtualMode))},[i]),r.useEffect(()=>{const ee=localStorage.getItem("frontendTheme");ee&&C(ee)},[]);const d=ee=>{s&&console.log("handleChangeBridgeMode called with value:",ee.target.value),b(ee.target.value),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:ee.target.value}})},u=ee=>{s&&console.log("handleChangeMbLoggerLevel called with value:",ee.target.value),t(ee.target.value),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:ee.target.value}})},w=ee=>{s&&console.log("handleLogOnFileMbChange called with value:",ee.target.checked),P(ee.target.checked),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:ee.target.checked}})},V=ee=>{const se=ee.target.value;s&&console.log("handleChangeTheme called with value:",se),C(se),localStorage.setItem("frontendTheme",se),document.body.setAttribute("frontend-theme",se)},ge=ee=>{const se=ee.target.checked;s&&console.log("handleChangeHomePagePlugins called with value:",se),H(se),localStorage.setItem("homePagePlugins",se?"true":"false")},me=ee=>{const se=ee.target.value;s&&console.log("handleChangeHomePageMode called with value:",se),_(se),localStorage.setItem("homePageMode",se)},xe=ee=>{const se=ee.target.value;s&&console.log("handleChangeVirtualMode called with value:",se),X(se),localStorage.setItem("virtualMode",se),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:se}})};return!i||!m?null:e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Rn,{open:j,ip:m.ipv4Address,onClose:R,onSave:O}),e.jsx(Hn,{open:G,onClose:a,onSave:o}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(zt,{row:!0,name:"mode-buttons-group",value:l,onChange:d,children:[e.jsx(Fe,{value:"bridge",control:e.jsx(gt,{}),label:"Bridge",disabled:i.readOnly===!0}),e.jsx(Fe,{value:"childbridge",control:e.jsx(gt,{}),label:"Childbridge",disabled:i.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:g,onChange:u,children:[e.jsx(D,{value:"Debug",children:"Debug"}),e.jsx(D,{value:"Info",children:"Info"}),e.jsx(D,{value:"Notice",children:"Notice"}),e.jsx(D,{value:"Warn",children:"Warn"}),e.jsx(D,{value:"Error",children:"Error"}),e.jsx(D,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:x,onChange:w,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:p,onChange:V,children:[e.jsx(D,{value:"classic",children:"Classic"}),e.jsx(D,{value:"light",children:"Light"}),e.jsx(D,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Te,{checked:E,onChange:ge,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:W,onChange:me,children:[e.jsx(D,{value:"logs",children:"Logs"}),e.jsx(D,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:f,onChange:xe,children:[e.jsx(D,{value:"disabled",children:"Disabled"}),e.jsx(D,{value:"outlet",children:"Outlet"}),e.jsx(D,{value:"light",children:"Light"}),e.jsx(D,{value:"switch",children:"Switch"}),e.jsx(D,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>v(!0),children:"Change password"})}),i.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>k(!0),children:"Configure IP"})})]})})]})}function En({matterbridgeInfo:i}){const{sendMessage:m,getUniqueId:c}=r.useContext(fe),[n,l]=r.useState("Info"),[b,g]=r.useState(!1),[t,x]=r.useState(""),[P,p]=r.useState(""),[C,E]=r.useState(""),[H,W]=r.useState(""),[_,f]=r.useState(""),[X,y]=r.useState(""),j=r.useRef(c());r.useEffect(()=>{i&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][i.matterLoggerLevel]),g(i.matterFileLogger),x(i.matterMdnsInterface||""),p(i.matterIpv4Address||""),E(i.matterIpv6Address||""),W(i.matterPort?i.matterPort.toString():""),f(i.matterDiscriminator?i.matterDiscriminator.toString():""),y(i.matterPasscode?i.matterPasscode.toString():""))},[i]);const k=u=>{s&&console.log("handleChangeMjLoggerLevel called with value:",u.target.value),l(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:u.target.value}})},R=u=>{s&&console.log("handleLogOnFileMjChange called with value:",u.target.checked),g(u.target.checked),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:u.target.checked}})},O=u=>{s&&console.log("handleChangeMdnsInterface called with value:",u.target.value),x(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:u.target.value}})},G=u=>{s&&console.log("handleChangeIpv4Address called with value:",u.target.value),p(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:u.target.value}})},v=u=>{s&&console.log("handleChangeIpv6Address called with value:",u.target.value),E(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:u.target.value}})},a=u=>{s&&console.log("handleChangeMatterPort called with value:",u.target.value),W(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:u.target.value}})},o=u=>{s&&console.log("handleChangeMatterDiscriminator called with value:",u.target.value),f(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:u.target.value}})},d=u=>{s&&console.log("handleChangemMatterPasscode called with value:",u.target.value),y(u.target.value),m({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:u.target.value}})};return i?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:k,children:[e.jsx(D,{value:"Debug",children:"Debug"}),e.jsx(D,{value:"Info",children:"Info"}),e.jsx(D,{value:"Notice",children:"Notice"}),e.jsx(D,{value:"Warn",children:"Warn"}),e.jsx(D,{value:"Error",children:"Error"}),e.jsx(D,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:b,onChange:R,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,onChange:O,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:P,onChange:G,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:C,onChange:v,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:H,onChange:a,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:_,onChange:o,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:X,onChange:d,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function An({matterbridgeInfo:i}){return i?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Oe,{value:i.matterbridgeVersion,label:"Current Version"}),e.jsx(Oe,{value:i.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Oe,{value:i.homeDirectory,label:"Home Directory"}),e.jsx(Oe,{value:i.rootDirectory,label:"Root Directory"}),e.jsx(Oe,{value:i.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Oe,{value:i.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Oe,{value:i.globalModulesDirectory,label:"Global Module Directory"})]})})]}):null}function Oe({value:i,label:m}){return e.jsx(pe,{focused:!0,value:i,size:"small",label:m,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}const _n=r.memo(On);function qn(){const{online:i,sendMessage:m,addListener:c,removeListener:n,getUniqueId:l}=r.useContext(fe),{showSnackbarMessage:b,showInstallProgress:g,addInstallProgress:t}=r.useContext(Be),[x,P]=r.useState(null),[p,C]=r.useState([]),[E,H]=r.useState([]),[W,_]=r.useState(null),[f,X]=r.useState({cpuUsage:0}),[y,j]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[k,R]=r.useState({systemUptime:"",processUptime:""}),O=r.useRef(l());return console.log("Test uniqueId:",O),r.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const G=v=>{if(v.method==="restart_required")console.log("Test received restart_required"),b("Restart required",0);else if(v.method==="refresh_required")console.log(`Test received refresh_required: changed=${v.response.changed} and sending api requests`),b("Refresh required",0),m({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),m({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),m({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(v.method==="memory_update")console.log("Test received memory_update",v),j(v.response);else if(v.method==="cpu_update")console.log("Test received cpu_update",v),X(v.response);else if(v.method==="uptime_update")console.log("Test received uptime_update",v),R(v.response);else if(v.method==="/api/settings"&&v.response)console.log("Test received /api/settings:",v.response),b("Test received /api/settings",0),P(v.response);else if(v.method==="/api/plugins"&&v.response)console.log(`Test received ${v.response.length} plugins:`,v.response),b("Test received /api/plugins",0),C(v.response);else if(v.method==="/api/devices"&&v.response){console.log(`Test received ${v.response.length} devices:`,v.response),b("Test received /api/devices",0),H(v.response);for(const a of v.response)console.log("Test sending /api/clusters for device:",a.pluginName,a.name,a.endpoint),m({id:O.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:a.pluginName,endpoint:a.endpoint||0}})}else v.method==="/api/clusters"&&v.response&&(console.log(`Test received ${v.response.clusters.length} clusters for device ${v.response.deviceName} endpoint ${v.response.id}:${v.response.number}:`,v),b(`Test received /api/clusters for ${v.response.plugin}::${v.response.deviceName}`,0),_(v.response))};return c(G,O.current),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(G),console.log("Test useEffect WebSocketMessage unmounted")}},[c,n,m,b]),r.useEffect(()=>(console.log("Test useEffect online mounting"),i&&console.log("Test useEffect online received online"),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[i,m,b]),console.log("Test rendering..."),i?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"}),e.jsx(oe,{variant:"contained",onClick:()=>{g("example-package"),t("Starting installation...");for(const G of["Downloading package...","Extracting files...","Installing dependencies..."])t(G);for(let G=0;G<=500;G+=1)t(`Installing dependency package-dep${G}...`);t("Finalizing installation..."),t("Installation completed successfully.")},children:"Install"})]})}):e.jsx(Re,{})}const zn=r.memo(qn);function Un(i,m){s&&console.log("getCssVariable:",i,"defaultValue",m);const c=getComputedStyle(document.body).getPropertyValue(i).trim();return c||console.error("getCssVariable: undefined",c),c||m}function Bn(i){return Zr({palette:{primary:{main:i},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}let s=!1;const Qn=()=>{s=!s};function Kn({setLoggedIn:i}){const[m,c]=r.useState(""),[n,l]=r.useState(""),b={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)"},t={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},x=async p=>{try{const C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:p})});if(C.ok){const{valid:E}=await C.json();E?i(!0):p!==""&&l("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},P=p=>{p.preventDefault(),x(m)};return x(""),e.jsx("div",{style:b,children:e.jsxs("form",{onSubmit:P,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:m,onChange:p=>c(p.target.value),style:t,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:n&&e.jsx("p",{style:{color:"red"},children:n})})]})})}function Jn(){const[i,m]=r.useState(!1);s&&console.log("Setting frontend theme");const c=localStorage.getItem("frontendTheme");s&&console.log("Saved theme:",c),c?document.body.setAttribute("frontend-theme",c):document.body.setAttribute("frontend-theme","dark");const n=Un("--primary-color","#1976d2");s&&console.log("Primary color from CSS:",n);const l=Bn(n),b=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return s&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${b}"`)),i?e.jsx(eo,{theme:l,children:e.jsx(cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ho,{children:e.jsx(Oo,{children:e.jsx(nr,{basename:b,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Eo,{}),e.jsxs(ir,{children:[e.jsx(Ve,{path:"/",element:e.jsx(pn,{})}),e.jsx(Ve,{path:"/devices",element:e.jsx($n,{})}),e.jsx(Ve,{path:"/log",element:e.jsx(Tn,{})}),e.jsx(Ve,{path:"/settings",element:e.jsx(_n,{})}),e.jsx(Ve,{path:"/test",element:e.jsx(zn,{})}),e.jsx(Ve,{path:"*",element:e.jsx(sr,{to:"/"})})]})]})})})})})}):e.jsx(Kn,{setLoggedIn:m})}ar.createRoot(document.getElementById("root")).render(e.jsx(lr.StrictMode,{children:e.jsx(Jn,{})}));
|
|
1
|
+
import{B as e,y as r,Q as Xe,S as nr,U as ir,V as Ve,X as sr,Y as ar,H as lr}from"./vendor_node_modules.js";import{u as dr,S as cr}from"./vendor_notistack.js";import{D as Me,a as ke,b as Ie,B as ie,c as Le,d as Z,A as pr,I as K,C as ur,T,S as gr,F as Vt,H as mr,e as Et,f as We,R as dt,P as He,M as hr,g as ze,h as k,L as z,i as re,j as Ze,V as et,k as Se,l as ht,m as fr,n as xr,o as ge,p as br,q as vr,r as ct,s as ae,t as Te,K as St,u as Mt,v as ut,w as tt,x as Je,y as rt,W as Ge,z as ot,E as nt,G as kt,J as It,N as yr,O as jr,Q as wr,U as Fe,X as At,Y as vt,Z as Cr,_ as Sr,$ as Mr,a0 as kr,a1 as _t,a2 as pt,a3 as Ir,a4 as Dr,a5 as Pr,a6 as Nr,a7 as Dt,a8 as Wr,a9 as $r,aa as Lr,ab as Fr,ac as Tr,ad as Rr,ae as Hr,af as Pt,ag as Or,ah as Vr,ai as Er,aj as Ar,ak as _r,al as qr,am as zr,an as Ur,ao as Br,ap as Qr,aq as Kr,ar as Jr,as as Gr,at as Yr,au as Xr,av as Nt,aw as Ue,ax as qt,ay as we,az as zt,aA as gt,aB as $e,aC as Zr,aD as eo}from"./vendor_mui.js";import{Q as to}from"./vendor_qrcode.js";import{I as ne,m as Wt,a as ro,b as oo,c as $t,d as no,e as io,f as so,g as ao,h as lo,i as co,j as po,k as uo,l as go,n as mo,o as ho,p as fo,q as Lt,r as xo,s as bo,t as vo,u as yo,v as jo,w as wo,x as Co,y as So,z as Ft,A as Mo,B as ko}from"./vendor_mdi.js";import{F as Io,v as Do,e as Po,a as No,g as Wo,b as $o,c as Lo,d as ft,A as Fo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const m=document.createElement("link").relList;if(m&&m.supports&&m.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))n(l);new MutationObserver(l=>{for(const b of l)if(b.type==="childList")for(const g of b.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&n(g)}).observe(document,{childList:!0,subtree:!0});function c(l){const b={};return l.integrity&&(b.integrity=l.integrity),l.referrerPolicy&&(b.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?b.credentials="include":l.crossOrigin==="anonymous"?b.credentials="omit":b.credentials="same-origin",b}function n(l){if(l.ep)return;l.ep=!0;const b=c(l);fetch(l.href,b)}})();function To({open:i,title:m,message:c,onConfirm:n,onCancel:l}){const b=t=>{s&&console.log("Confirmed"),t.preventDefault(),n()},g=t=>{s&&console.log("Canceled"),t.preventDefault(),l()};return e.jsxs(Me,{open:i,children:[e.jsx(ke,{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:m})]})}),e.jsxs(Ie,{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:c})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ie,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const Ro=({open:i,output:m,packageName:c,onInstall:n,onClose:l})=>{const b=r.useRef(null);return r.useEffect(()=>{s&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${b.current}`),setTimeout(()=>{s&&console.log("Scrolling to bottom:",b.current),b.current?.scrollIntoView({behavior:"smooth"})},0)},[m]),e.jsxs(Me,{open:i,onClose:(g,t)=>{t==="backdropClick"||t==="escapeKeyDown"||l()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(ke,{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.jsxs("h4",{style:{margin:0},children:["Install",n?"":"ing"," package ",c]})]})}),e.jsxs(Ie,{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:"Install log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:8,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:[m.split(`
|
|
2
|
+
`).map((g,t)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:g},t)),e.jsx("li",{ref:b,style:{padding:0,margin:0}})]})]}),e.jsxs(Le,{children:[n&&e.jsx(ie,{variant:"contained",onClick:n,children:"Install"}),e.jsx(ie,{onClick:l,children:"Close"})]})]})},it=[],Be=r.createContext(null);function Ho({children:i}){const{enqueueSnackbar:m,closeSnackbar:c}=dr(),n=r.useCallback(te=>{s&&console.log(`UiProvider closeSnackbarMessage: message ${te}`);const Y=it.findIndex(xe=>xe.message===te);Y!==-1&&(c(it[Y].key),it.splice(Y,1),s&&console.log(`UiProvider closeSnackbarMessage: message ${te} removed from persistMessages`))},[c]),l=r.useCallback((te,Y,xe)=>{s&&console.log(`UiProvider showSnackbarMessage: message ${te} timeout ${Y}`);const U=m(te,{variant:"default",autoHideDuration:Y==null||Y>0?(Y??5)*1e3:null,persist:Y===0,content:oe=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(pr,{severity:xe??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>c(oe),action:e.jsx(K,{size:"small",onClick:()=>c(oe),sx:{color:"#fff"},children:e.jsx(ur,{fontSize:"small"})}),children:te},oe)},oe)});Y===0&&(s&&console.log(`UiProvider showSnackbarMessage: message ${te} timeout ${Y} - persist key ${U}`),it.push({message:te,key:U}))},[m,c]),[b,g]=r.useState(!1),[t,x]=r.useState(""),[D,p]=r.useState(""),[j,V]=r.useState(""),R=r.useRef(null),P=r.useRef(null),_=()=>{s&&console.log(`UiProvider handle confirm action ${j}`),g(!1),R.current&&R.current(j)},f=()=>{s&&console.log(`UiProvider handle cancel action ${j}`),g(!1),P.current&&P.current(j)},X=r.useCallback((te,Y,xe,U,oe)=>{s&&console.log(`UiProvider showConfirmCancelDialog for command ${xe}`),x(te),p(Y),V(xe),R.current=U,P.current=oe,g(!0)},[]),[y,w]=r.useState(!1),[I,H]=r.useState(""),[F,E]=r.useState(""),v=r.useCallback(te=>{console.log(`UiProvider show install progress for package ${te}`),H(te),E(`Starting installation of ${te}...
|
|
3
|
+
`),w(!0)},[]),a=r.useCallback(te=>{console.log(`UiProvider addInstallProgress: output ${te}`),E(Y=>Y+te+`
|
|
4
|
+
`)},[]),o=r.useCallback(()=>{console.log(`UiProvider exitInstallProgressSuccess: package ${I}`),E(te=>te+`Successfully installed ${I}
|
|
5
|
+
`)},[I]),d=r.useCallback(()=>{console.log(`UiProvider exitInstallProgressError: package ${I}`),E(te=>te+`Failed to install ${I}
|
|
6
|
+
`)},[I]),u=r.useCallback(()=>{console.log("UiProvider hide install progress"),w(!1)},[]),L=()=>{console.log("UiProvider handle install close action"),w(!1),H(""),E("")},pe=r.useMemo(()=>({showSnackbarMessage:l,closeSnackbarMessage:n,closeSnackbar:c,showConfirmCancelDialog:X,showInstallProgress:v,exitInstallProgressSuccess:o,exitInstallProgressError:d,hideInstallProgress:u,addInstallProgress:a}),[l,n,c,X,v,o,d,u,a]);return e.jsxs(Be.Provider,{value:pe,children:[e.jsx(To,{open:b,title:t,message:D,onConfirm:_,onCancel:f}),e.jsx(Ro,{open:y,packageName:I,output:F,onClose:L}),i]})}const Ut=r.createContext(null),ve=r.createContext(null);function Oo({children:i}){const[m,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[n,l]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[b,g]=r.useState([]),[t,x]=r.useState(1e3),[D,p]=r.useState(!0),[j,V]=r.useState(!1),{showSnackbarMessage:R,closeSnackbarMessage:P,closeSnackbar:_,showInstallProgress:f,hideInstallProgress:X,exitInstallProgressSuccess:y,exitInstallProgressError:w,addInstallProgress:I}=r.useContext(Be),H=r.useRef([]),F=r.useRef(null),E=r.useRef(1),v=r.useRef(Math.floor(Math.random()*999e3)+1e3),a=r.useRef(null),o=r.useRef(null),d=r.useRef(null),u=r.useRef(m),L=r.useRef(n),pe=r.useRef(0),te=r.useRef(null),Y=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),xe=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),U=100,oe=60,$=50,B=300,N=10;r.useEffect(()=>(s&&console.log("WebSocket messages started counter interval"),te.current=setInterval(()=>{pe.current>0&&(s&&console.log(`WebSocket messages received in the last ${N} seconds: ${pe.current*(60/N)} messages/minute`),pe.current=0)},N*1e3),()=>{s&&console.log("WebSocket messages stopped counter interval"),te.current&&clearInterval(te.current),te.current=null}),[]),r.useEffect(()=>{u.current=m},[m]),r.useEffect(()=>{L.current=n},[n]);const W=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),C=r.useCallback(G=>{if(F.current&&F.current.readyState===WebSocket.OPEN)try{s&&console.log(`WebSocket sending message with id ${G.id}:`,G),G.id===void 0&&(G.id=v.current);const h=JSON.stringify(G);F.current.send(h),s&&console.log("WebSocket sent message:",G)}catch(h){s&&console.error(`WebSocket error sending message: ${h}`)}else s&&console.error("WebSocket message not sent, WebSocket not connected:",G)},[]),M=r.useCallback((G,h)=>{g(fe=>[...fe,{level:G,time:"",name:"",message:h}])},[]),O=r.useCallback((G,h)=>{c(G),l(h),M("WebSocket",`Filtering by log level "${G}" and log search "${h}"`)},[M]),ee=r.useCallback((G,h)=>{s&&console.log(`WebSocket addListener id ${h}:`,G),(h==null||isNaN(h)||h===0)&&console.error("WebSocket addListener called without id, listener not added:",G),H.current=[...H.current,{listener:G,id:h}],s&&console.log("WebSocket addListener total listeners:",H.current.length)},[]),ce=r.useCallback(G=>{s&&console.log("WebSocket removeListener:",G),H.current=H.current.filter(h=>h.listener!==G),s&&console.log("WebSocket removeListener total listeners:",H.current.length)},[]),le=r.useCallback(()=>{Y===""||Y===null||Y===void 0||(M("WebSocket",`Connecting to WebSocket: ${Y}`),F.current=new WebSocket(Y),F.current.onmessage=G=>{j||V(!0),pe.current+=1;try{const h=JSON.parse(G.data);if(h.id===void 0||h.src===void 0||h.dst===void 0){s&&console.error("WebSocket undefined message id/src/dst:",h);return}if(h.src!=="Matterbridge"||h.dst!=="Frontend"){s&&console.error("WebSocket invalid message src/dst:",h);return}if(h.error){s&&console.error("WebSocket error message response:",h);return}if(h.id===v.current&&h.method==="pong"&&h.response==="pong"){s&&console.log(`WebSocket pong response message id ${h.id}:`,h),o.current&&clearTimeout(o.current),o.current=null;return}else if(h.method==="snackbar"&&h.response&&h.response.message){s&&console.log(`WebSocket message id ${h.id} method ${h.method}:`,h),R(h.response.message,h.response.timeout,h.response.severity);return}else if(h.method==="close_snackbar"&&h.response&&h.response.message){s&&console.log(`WebSocket message id ${h.id} method ${h.method}:`,h),P(h.response.message);return}else if(h.method==="log"){if(!h.response||!h.response.level||!h.response.time||!h.response.name||!h.response.message||(h.response.level==="spawn"&&(h.response.name==="Matterbridge:spawn-init"?f(h.response.message):h.response.name==="Matterbridge:spawn-exit-success"?y():h.response.name==="Matterbridge:spawn-exit-error"?w():I(h.response.message+`
|
|
7
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(h.response.level)&&(u.current==="info"&&h.response.level==="debug"||u.current==="notice"&&(h.response.level==="debug"||h.response.level==="info")||u.current==="warn"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice")||u.current==="error"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn")||u.current==="fatal"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn"||h.response.level==="error")))||L.current!=="*"&&L.current!==""&&!h.response.message.toLowerCase().includes(L.current.toLowerCase())&&!h.response.name.toLowerCase().includes(L.current.toLowerCase())||h.response.name==="Commissioning"&&h.response.message.includes("is uncommissioned"))return;g(be=>{const me=[...be,{level:h.response.level,time:h.response.time,name:h.response.name,message:h.response.message}];return me.length>t*2?me.slice(t):me})}else{if(s&&console.log(`WebSocket received message id ${h.id} method ${h.method}:`,h),h.id===0)H.current.forEach(fe=>fe.listener(h));else{const fe=H.current.find(be=>be.id===h.id);fe?fe.listener(h):s&&console.debug(`WebSocket no listener found for message id ${h.id}:`,h)}return}}catch(h){console.error(`WebSocketUse error parsing message: ${h}`)}},F.current.onopen=()=>{s&&console.log(`WebSocket: Connected to WebSocket: ${Y}`),M("WebSocket",`Connected to WebSocket: ${Y}`),V(!0),_(),E.current=1,d.current=setTimeout(()=>{a.current=setInterval(()=>{C({id:v.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{s&&console.error(`WebSocketUse: No pong response received from WebSocket: ${Y}`),M("WebSocket",`No pong response received from WebSocket: ${Y}`),V(!1)},1e3*$)},1e3*oe)},1e3*B)},F.current.onclose=()=>{s&&console.error(`WebSocket: Disconnected from WebSocket ${xe?"with Ingress":""}: ${Y}`),M("WebSocket",`Disconnected from WebSocket: ${Y}`),V(!1),_(),X(),d.current&&clearTimeout(d.current),o.current&&clearTimeout(o.current),a.current&&clearInterval(a.current),M("WebSocket",`Reconnecting (attempt ${E.current} of ${U}) to WebSocket${xe?" (Ingress)":""}: ${Y}`),xe?setTimeout(de,5e3):E.current===1?de():E.current<U?setTimeout(de,1e3*E.current):M("WebSocket",`Reconnect attempts exceeded limit of ${U} retries, refresh the page to reconnect to: ${Y}`),E.current=E.current+1},F.current.onerror=G=>{s&&console.error(`WebSocket: WebSocket error connecting to ${Y}:`,G),M("WebSocket",`WebSocket error connecting to ${Y}`)})},[Y]),de=r.useCallback(()=>{s&&console.log(`WebSocket attemptReconnect ${E.current}/${U} to:`,Y),le()},[le]);r.useEffect(()=>(le(),()=>{F.current&&F.current.readyState===WebSocket.OPEN&&F.current.close()}),[le]);const A=r.useMemo(()=>({messages:b,maxMessages:t,autoScroll:D,setMessages:g,setLogFilters:O,setMaxMessages:x,setAutoScroll:p}),[b,g,O]),se=r.useMemo(()=>({maxMessages:t,autoScroll:D,logFilterLevel:m,logFilterSearch:n,setMessages:g,setLogFilters:O,setMaxMessages:x,setAutoScroll:p,online:j,retry:E.current,getUniqueId:W,addListener:ee,removeListener:ce,sendMessage:C,logMessage:M}),[t,D,g,O,x,p,j,E.current,ee,ce,C,M]);return e.jsx(Ut.Provider,{value:A,children:e.jsx(ve.Provider,{value:se,children:i})})}function Vo(){const{showSnackbarMessage:i,showConfirmCancelDialog:m}=r.useContext(Be),{online:c,sendMessage:n,logMessage:l,addListener:b,removeListener:g,getUniqueId:t}=r.useContext(ve),[x,D]=r.useState(!1),[p,j]=r.useState(!1),[V,R]=r.useState(!1),[P,_]=r.useState(!1),[f,X]=r.useState(null),y=r.useRef(t()),[w,I]=r.useState(null),[H,F]=r.useState(null),[E,v]=r.useState(null),[a,o]=r.useState(null),[d,u]=r.useState(null),L=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},pe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},te=()=>{f?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},Y=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},U=()=>{n({id:y.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},oe=()=>{n({id:y.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},$=()=>{n({id:y.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},B=()=>{s&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),n({id:y.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},N=()=>{s&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),n({id:y.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},W=()=>{s&&console.log("Header: handleShellyCreateSystemLog"),n({id:y.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},C=()=>{s&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),i("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},M=()=>{f?.matterbridgeInformation.restartMode===""?n({id:y.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:y.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},O=()=>{n({id:y.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ee=()=>{n({id:y.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{n({id:y.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{n({id:y.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=Q=>{I(Q.currentTarget)},A=Q=>{s&&console.log("Header: handleMenuClose",Q),I(null),Q==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),i("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),i("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),i("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(l("Matterbridge","Loading matter log..."),i("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),i("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),i("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),i("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),i("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),i("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(l("Matterbridge","Downloading backup..."),i("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?U():Q==="updatedev"?oe():Q==="updatecheck"?$():Q==="shelly-sys-update"?B():Q==="shelly-main-update"?N():Q==="shelly-create-system-log"?W():Q==="shelly-download-system-log"?C():Q==="softreset"?ce():Q==="hardreset"?le():Q==="restart"?M():Q==="shutdown"?O():Q==="reboot"?ee():Q==="create-backup"?n({id:y.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?n({id:y.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?n({id:y.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&n({id:y.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},se=Q=>{s&&console.log("Header: handleMenuCloseCancel:",Q),I(null)},G=Q=>{F(Q.currentTarget)},h=()=>{F(null)},fe=Q=>{v(Q.currentTarget)},be=()=>{v(null)},me=Q=>{o(Q.currentTarget)},J=()=>{o(null)},ue=Q=>{u(Q.currentTarget)},je=()=>{u(null)},Qe=()=>{Qn(),s&&console.log("Matterbridge logo clicked: debug is now",s)};return r.useEffect(()=>{const Q=S=>{s&&console.log("Header received WebSocket Message:",S),S.method==="/api/settings"&&S.id===y.current?(s&&console.log("Header received settings:",S.response),X(S.response),D(S.response.matterbridgeInformation.restartRequired||S.response.matterbridgeInformation.fixedRestartRequired),j(S.response.matterbridgeInformation.fixedRestartRequired),R(S.response.matterbridgeInformation.updateRequired)):S.method==="refresh_required"&&S.response.changed==="settings"?(s&&console.log(`Header received refresh_required: changed=${S.response.changed} and sending /api/settings request`),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="restart_required"?(s&&console.log(`Header received restart_required with fixed: ${S.response.fixed}`),D(!0),S.response.fixed===!0&&j(!0)):S.method==="restart_not_required"?(s&&console.log("Header received restart_not_required"),D(!1)):S.method==="update_required"?(s&&console.log("Header received update_required"),S.response.devVersion===!0?_(!0):R(!0),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="shelly_sys_update"?(s&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),X(he=>he?{matterbridgeInformation:{...he.matterbridgeInformation,shellySysUpdate:S.response.available},systemInformation:he.systemInformation}:null)):S.method==="shelly_main_update"&&(s&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),X(he=>he?{matterbridgeInformation:{...he.matterbridgeInformation,shellyMainUpdate:S.response.available},systemInformation:he.systemInformation}:null))};return b(Q,y.current),s&&console.log(`Header added WebSocket listener id ${y.current}`),()=>{g(Q),s&&console.log("Header removed WebSocket listener")}},[b,g,n,i]),r.useEffect(()=>{c&&(s&&console.log("Header sending /api/settings requests"),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]),s&&console.log("Header rendering..."),!c||!f?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Qe}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(Xe,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Xe,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Xe,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Xe,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!f.matterbridgeInformation.readOnly&&V&&e.jsx(T,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:U,children:["Update to v.",f.matterbridgeInformation.matterbridgeLatestVersion]})}),!f.matterbridgeInformation.readOnly&&P&&e.jsx(T,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:oe,children:["Update to new dev v.",f.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!f.matterbridgeInformation.readOnly&&e.jsx(T,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:te,children:["v.",f.matterbridgeInformation.matterbridgeVersion]})}),f.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),f.matterbridgeInformation.bridgeMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.bridgeMode})}):null,f.matterbridgeInformation.restartMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.restartMode})}):null,f.matterbridgeInformation.profile&&f.matterbridgeInformation.profile!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:Y})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Give a star to Matterbridge",children:e.jsx(K,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:xe,children:e.jsx(gr,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Sponsor Matterbridge",children:e.jsx(K,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:L,children:e.jsx(Vt,{})})}):null,e.jsx(T,{title:"Matterbridge help",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:pe,children:e.jsx(mr,{})})}),e.jsx(T,{title:"Matterbridge changelog",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:te,children:e.jsx(Et,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsx(T,{title:"Update matterbridge to latest version",children:e.jsx(K,{style:{color:V?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:U,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(T,{title:"Shelly system update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:B,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(T,{title:"Shelly software update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:N,children:e.jsx(We,{})})}),e.jsx(T,{title:"Restart matterbridge",children:e.jsx(K,{style:{color:x||p?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(dt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(T,{title:"Shut down matterbridge",children:e.jsx(K,{style:{color:x||p?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:O,children:e.jsx(He,{})})}):null,e.jsx(T,{title:"Download, backup and more",children:e.jsx(K,{onClick:de,children:e.jsx(hr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(ze,{id:"command-menu",anchorEl:w,keepMounted:!0,open:!!w,onClose:()=>A(""),children:[f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("updatedev"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("updatecheck"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(k,{onClick:()=>A("shelly-sys-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(k,{onClick:()=>A("shelly-main-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>A("restart"),children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(k,{onClick:()=>A("shutdown"),children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{m("Reboot","Are you sure you want to reboot the Shelly board?","reboot",A,se)},children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:fe,children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-view",anchorEl:E,keepMounted:!0,open:!!E,onClose:be,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("view-mblog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("view-mjlog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("view-shellylog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:me,children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-download",anchorEl:a,keepMounted:!0,open:!!a,onClose:J,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("download-mbstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-pluginstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-pluginconfig"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mblog"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mjstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mjlog"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("shelly-create-system-log"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("shelly-download-system-log"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:G,children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-backup",anchorEl:H,keepMounted:!0,open:!!H,onClose:h,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("create-backup"),h()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-backup"),h()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:ue,children:[e.jsx(z,{children:e.jsx(fr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-reset",anchorEl:d,keepMounted:!0,open:!!d,onClose:je,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{je(),m("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",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{je(),m("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>{je(),m("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{je(),m("Network reset","Are you sure you want to factory reset the network parameters?","softreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{je(),m("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Eo=r.memo(Vo),Ao=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(s&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(s&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function _o(){const{messages:i,autoScroll:m}=r.useContext(Ut),[c,n]=r.useState(!1),l=r.useRef(null),b=r.useMemo(()=>Ao(),[]),g=p=>n(!0),t=p=>n(!1);r.useEffect(()=>{s&&console.log(`WebSocketLogs autoScroll: ${m} isHovering: ${c}`),m&&!c&&!b&&l.current?.scrollIntoView({behavior:"smooth"})},[i,c,m,b]);const x=p=>{switch(p.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"}},D=p=>{switch(p.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:g,onMouseLeave:t,children:[i.map((p,j)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:x(p.level),color:D(p.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:p.level}),p.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+p.time+"]"}),p.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+p.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:p.message})]},j)),e.jsx("div",{ref:l})]})})}const Bt=r.memo(_o);function Re(){const{retry:i}=r.useContext(ve),m=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:i<100?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx(xr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+i+")","..."]})})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{}),e.jsx(ie,{variant:"contained",color:"primary",onClick:m,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function qo({value:i,maxChars:m}){let c=i;if(i.length>m&&m>3){const n=m-3,l=i.substring(0,Math.ceil(n/2)),b=i.substring(i.length-Math.floor(n/2),i.length);c=`${l} … ${b}`}return i!==c?e.jsx(T,{title:i,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:c})}):e.jsx("span",{children:c})}function zo({systemInfo:i,compact:m}){const{sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState(i),x=r.useRef(b());if(s&&console.log("SystemInfoTable:",g,"compact:",m),i&&m&&g.totalMemory&&g.freeMemory){const D=g.totalMemory,p=g.freeMemory;g.freeMemory=`${p} / ${D}`,g.totalMemory=""}if(i&&m&&g.heapTotal&&g.heapUsed){const D=g.heapTotal,p=g.heapUsed;g.heapUsed=`${p} / ${D}`,g.heapTotal=""}if(i&&m&&g.osRelease&&g.osType){const D=g.osType,p=g.osRelease;g.osType=`${D} (${p})`,g.osRelease=""}if(i&&m&&g.osArch&&g.osPlatform){const D=g.osPlatform,p=g.osArch;g.osPlatform=`${D} (${p})`,g.osArch=""}return r.useEffect(()=>{const D=p=>{p.src==="Matterbridge"&&p.dst==="Frontend"&&(p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss&&(s&&console.log("SystemInfoTable received memory_update",p),(g.totalMemory!==p.response.totalMemory||g.freeMemory!==p.response.freeMemory||g.heapTotal!==p.response.heapTotal||g.heapUsed!==p.response.heapUsed||g.rss!==p.response.rss)&&t(j=>({...j,totalMemory:p.response.totalMemory,freeMemory:p.response.freeMemory,heapTotal:p.response.heapTotal,heapUsed:p.response.heapUsed,rss:p.response.rss}))),p.method==="cpu_update"&&p.response&&p.response.cpuUsage&&(s&&console.log("SystemInfoTable received cpu_update",p),g.cpuUsage!==(p.response.cpuUsage?p.response.cpuUsage.toFixed(2)+" %":"")&&t(j=>({...j,cpuUsage:p.response.cpuUsage.toFixed(2)+" %"}))),p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime&&(s&&console.log("SystemInfoTable received uptime_update",p),(g.systemUptime!==p.response.systemUptime||g.processUptime!==p.response.processUptime)&&t(j=>({...j,systemUptime:p.response.systemUptime,processUptime:p.response.processUptime}))))};return s&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),n(D,x.current),s&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),l(D),s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[n,g.cpuUsage,g.freeMemory,g.heapTotal,g.heapUsed,g.processUptime,g.rss,g.systemUptime,g.totalMemory,l,c]),g?(s&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(g).filter(([D,p])=>p!==void 0&&p!=="").map(([D,p],j)=>e.jsxs("tr",{className:j%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:D}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(qo,{value:typeof p!="string"?p.toString():p,maxChars:25})})]},D))})})})]})):null}const Uo=r.memo(zo),Tt={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"}},Bo=i=>{if(!i)return"";const m=i.toString().replace(/[^0-9]/g,"");if(m.length<5)return m;const c=m.slice(0,4),n=m.slice(4,7),l=m.slice(7,11);return[c,n,l].filter(Boolean).join("-")};function Qo({id:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState(null),[x,D]=r.useState(null),p=r.useRef(null),j=r.useRef(b()),{showConfirmCancelDialog:V}=r.useContext(Be);s&&console.log(`QRDiv loading with id = "${i}" storeId "${g}" and matter:`,x),r.useEffect(()=>{s&&console.log(`QRDiv id effect "${i}"`),i&&(s&&console.log(`QRDiv sending data request for storeId "${i}"`),t(i),D(null),p.current&&clearTimeout(p.current),p.current=null,c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:i,server:!0}}))},[i]),r.useEffect(()=>{s&&console.log(`QRDiv storeId effect "${g}"`)},[g]),r.useEffect(()=>{const y=w=>{w.method==="refresh_required"&&w.response.changed==="matter"&&w.response.matter&&(s&&console.log(`QRDiv received refresh_required: changed=${w.response.changed} for storeId "${w.response.matter.id}":`,w.response.matter),g===w.response.matter.id&&(s&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${w.response.matter.id}":`,w.response.matter),p.current&&clearTimeout(p.current),w.response.matter.advertising&&w.response.matter.advertiseTime&&w.response.matter.advertiseTime+9e5<=Date.now()&&(w.response.matter.advertising=!1),D(w.response.matter),w.response.matter.advertising&&(s&&console.log(`QRDiv setting matter advertise timeout for storeId "${w.response.matter.id}":`,w.response.matter.advertiseTime+9e5-Date.now()),p.current=setTimeout(()=>{p.current&&clearTimeout(p.current),s&&console.log(`QRDiv clearing advertising state for storeId "${g}" after 15 minutes`),D(I=>I&&{...I,advertising:!1})},w.response.matter.advertiseTime+9e5-Date.now()))))};return n(y,j.current),s&&console.log("QRDiv webSocket effect mounted"),()=>{l(y),p.current&&clearTimeout(p.current),p.current=null,s&&console.log("QRDiv webSocket effect unmounted")}},[n,l,g]);const R=()=>{s&&console.log(`QRDiv sent matter startCommission for node "${x?.id}"`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,startCommission:!0}})},P=()=>{s&&console.log(`QRDiv sent matter stopCommission for node "${x?.id}"`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,stopCommission:!0}})},_=()=>{s&&console.log(`QRDiv sent matter advertise for node "${x?.id}"`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,advertise:!0}})},f=y=>{s&&console.log(`QRDiv sent matter removeFabric for node "${x?.id}" and fabricIndex ${y}`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,removeFabric:y}})},X=async()=>{if(!x||!x.manualPairingCode)return;const y=x.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(y);else{const w=document.createElement("textarea");w.value=y,w.style.position="fixed",w.style.opacity="0",document.body.appendChild(w),w.focus(),w.select(),document.execCommand("copy"),document.body.removeChild(w)}s&&console.log("Manual pairing code copied to clipboard")}catch(w){console.error("Failed to copy manual pairing code",w)}};return!x||!m?(s&&console.log("QRDiv rendering undefined state"),null):x.online?x.advertising&&x.qrPairingCode&&x.manualPairingCode?(s&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Wt,size:"22px"})})}),e.jsx(K,{"aria-label":"stop pairing",size:"small",onClick:P,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:ro,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx(to,{value:x.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Bo(x.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(T,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(K,{"aria-label":"copy manual pairing code",size:"small",onClick:X,sx:Tt,children:e.jsx(ne,{path:oo,size:.85})})})})]})]})):x.commissioned&&x.fabricInformations&&x.sessionInformations?(s&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Wt,size:"22px"})})}),e.jsx(K,{"aria-label":"start pairing",size:"small",onClick:R,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:$t,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),x.fabricInformations.map((y,w)=>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: ",y.fabricIndex]}),e.jsx(T,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(K,{"aria-label":"remove the fabric",size:"small",onClick:()=>V("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>f(y.fabricIndex),()=>{}),sx:{...Tt,padding:"2px"},children:e.jsx(ne,{path:no,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",y.rootVendorId," ",y.rootVendorName]}),y.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",y.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",x.sessionInformations?x.sessionInformations.filter(I=>I.fabric?.fabricIndex===y.fabricIndex&&I.isPeerActive===!0).length:"0"," ","subscriptions: ",x.sessionInformations?x.sessionInformations.filter(I=>I.fabric?.fabricIndex===y.fabricIndex&&I.isPeerActive===!0&&I.numberOfActiveSubscriptions>0).length:"0"]})]},w))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]})):!x.commissioned&&!x.advertising?(s&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx(ie,{onClick:R,endIcon:e.jsx(ne,{path:$t,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]})):(s&&console.log("QRDiv rendering unknown state"),null):(s&&console.log("QRDiv rendering offline state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"normal"},children:"Server offline"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]}))}const Ko=r.memo(Qo);function Jo(){const{logMessage:i,sendMessage:m,getUniqueId:c}=r.useContext(ve),[n,l]=r.useState("matterbridge-"),[b,g]=r.useState(!1),[t,x]=r.useState(null),D=r.useRef(c()),p=w=>{w.preventDefault(),g(!0)},j=()=>{g(!1)},V=w=>{w.preventDefault(),g(!1);const I=w.dataTransfer.files[0];if(I){i("Plugins",`Installing package ${I.name}. Please wait...`);const H=new FormData;H.append("file",I),H.append("filename",I.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(F=>F.text()).then(F=>{i("Plugins",`Server response: ${F}`)}).catch(F=>{console.error("Error uploading plugin file:",F),i("Plugins",`Error installing package ${F}`)})}},R=w=>{const I=w.target.files&&w.target.files[0];if(I){i("Plugins",`Uploading package ${I.name}`);const H=new FormData;H.append("file",I),H.append("filename",I.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(F=>F.text()).then(F=>{i("Plugins",`Server response: ${F}`)}).catch(F=>{console.error("Error uploading plugin file:",F),i("Plugins",`Error uploading package ${F}`)})}},P=()=>{m({id:D.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},_=()=>{document.getElementById("file-upload")?.click()},f=()=>{m({id:D.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},X=w=>{x(w.currentTarget)},y=w=>{w!==""&&l(w),x(null)};return s&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:p,onDragLeave:j,onDrop:V,children:[e.jsx(ge,{value:n,onChange:w=>{l(w.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(K,{onClick:X,children:e.jsx(br,{})}),e.jsxs(ze,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>y(""),children:[e.jsx(k,{onClick:()=>y("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(k,{onClick:()=>y("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(k,{onClick:()=>y("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(k,{onClick:()=>y("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(k,{onClick:()=>y("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(k,{onClick:()=>y("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(k,{onClick:()=>y("matterbridge-test"),children:"matterbridge-test"}),e.jsx(k,{onClick:()=>y("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(k,{onClick:()=>y("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(T,{title:"Install or update a plugin from npm",children:e.jsx(ie,{onClick:P,endIcon:e.jsx(Se,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(T,{title:"Upload and install a plugin from a tarball",children:e.jsx(ie,{onClick:_,endIcon:e.jsx(vr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(T,{title:"Add an installed plugin",children:e.jsx(ie,{onClick:f,endIcon:e.jsx(ct,{}),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:R})]})}const Go=r.memo(Jo);function Ee({status:i,enabledText:m="Enabled",disabledText:c=void 0,tooltipText:n=void 0,onClick:l}){if(i===void 0)return null;{const b=e.jsx("div",{className:i?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:i?m:c??m});return n!==void 0?e.jsx(T,{title:n,children:b}):b}}function Rt(i){return i.id!==0&&i.src==="Matterbridge"&&i.dst==="Frontend"}const Ae={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_e={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Yo={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Xo={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Pe={padding:"0px",margin:"0px"},Zo="5px 10px 5px 10px",st={},ye={},at={},lt={};let qe=[],xt=[];const en=({open:i,onClose:m,plugin:c})=>{const{sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(ve),t=r.useRef(g()),[x,D]=r.useState(c.configJson),[p,j]=r.useState(null),[V,R]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[P,_]=r.useState("");let f={};r.useEffect(()=>{const W=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(Rt(C)&&C.id===t.current&&C.method==="/api/select/devices"&&C.response&&(s&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/devices:`,C.response),qe=C.response),Rt(C)&&C.id===t.current&&C.method==="/api/select/entities"&&C.response&&(s&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/entities:`,C.response),xt=C.response))};return l(W,t.current),s&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),x&&p&&p.properties&&(Object.keys(p.properties).forEach(C=>{Object.keys(p.properties[C]).forEach(M=>{M.startsWith("ui:")&&(V[C]={},V[C][M]=p.properties[C][M],delete p.properties[C][M])})}),R(V)),c.name&&c.configJson&&c.schemaJson&&(D(c.configJson),j(c.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),s&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',c.name)),()=>{b(W),s&&console.log("ConfigPluginDialog removed WebSocket listener")}},[l,x,c,b,p,n,V]);const X=(W,C)=>{f=W.formData},y=W=>{s&&console.log("ConfigPluginDialog handleSaveChanges:",W.formData),D(W.formData),c.configJson=W.formData,c.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.formData.name,formData:W.formData}}),m()};function w(W){const{id:C,label:M,onKeyChange:O,onDropPropertyClick:ee,disabled:ce,schema:le,children:de,registry:A,readonly:se,required:G}=W,{templates:h}=A,{RemoveButton:fe}=h.ButtonTemplates;if(!(Fo in le))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:de});const me=({target:J})=>O(J&&J.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(ge,{id:`${C}-key`,name:`${C}-key`,required:G,disabled:ce||se,defaultValue:M,onBlur:se?void 0:me,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:de}),e.jsx(fe,{disabled:ce||se,onClick:ee(M),registry:A})]})}function I(W){const{children:C,description:M,displayLabel:O,errors:ee,help:ce,hidden:le,registry:de,uiSchema:A}=W,se=$o(A),G=Lo("WrapIfAdditionalTemplate",de,se);return le?e.jsx("div",{style:{display:"none"},children:C}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(G,{...W,children:[O===!0&&M,C,ee,ce]})})}function H(W){const{description:C}=W;return C?e.jsx(ae,{sx:_e,children:C}):null}function F(W){const{required:C,title:M}=W;return M?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ae,{sx:Ae,children:["Title ",M," ",C&&e.jsx("mark",{children:"***"})]})}):null}function E(W){const{help:C}=W;return C?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ae,{sx:Yo,children:C})}):null}function v(W){const{errors:C}=W;return C?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ae,{color:"error",sx:Xo,children:"Please fix the following errors:"}),e.jsx(Je,{children:C.map((M,O)=>e.jsxs(yr,{children:[e.jsx(z,{children:e.jsx(jr,{color:"error"})}),e.jsx(re,{primary:M.stack})]},O))})]}):null}function a(W){const{errors:C}=W;return C?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:C.map((M,O)=>e.jsxs(ae,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},O))}):null}function o(W){const{id:C,name:M,_schema:O,_uiSchema:ee,value:ce,options:le,label:de,type:A,placeholder:se,required:G,disabled:h,readonly:fe,autofocus:be,onChange:me,onChangeOverride:J,onBlur:ue,onFocus:je,_rawErrors:Qe,_hideError:Q,_registry:S,_formContext:he}=W,Ke=({target:{value:Ce}})=>me(Ce===""?le.emptyValue:Ce),Ne=({target:Ce})=>ue(C,Ce&&Ce.value),Ye=({target:Ce})=>je(C,Ce&&Ce.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(ge,{id:C,name:C,label:se&&se!==""?de:void 0,variant:"outlined",placeholder:se&&se!==""?se:de,required:G,disabled:h||fe,autoFocus:be,value:ce||ce===0?ce:"",type:A,autoComplete:A==="password"?"current-password":M,onChange:J||Ke,onBlur:Ne,onFocus:Ye,fullWidth:!0})})}function d(W){return console.log("ArrayFieldTitleTemplate:",W),null}function u(W){return console.log("ArrayFieldDescriptionTemplate:",W),null}function L(W){return console.log("ArrayFieldItemTemplate:",W),null}function pe(W){const{canAdd:C,onAddClick:M,schema:O,title:ee}=W,[ce,le]=r.useState(!1),[de,A]=r.useState(!1),[se,G]=r.useState(!1),[h,fe]=r.useState(""),be=S=>{fe(S.target.value)},me=()=>{s&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",h,"selectDevices:",qe),le(!ce)},J=()=>{s&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",h,"selectEntities:",xt),A(!de)},ue=()=>{s&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",h,"selectDevices:",qe),G(!se)},je=S=>{le(!1),O.selectFrom==="serial"?O.items.default=S.serial:O.selectFrom==="name"&&(O.items.default=S.name),M()},Qe=S=>{A(!1),O.selectEntityFrom==="name"?O.items.default=S.name:O.selectEntityFrom==="description"&&(O.items.default=S.description),M()},Q=S=>{G(!1),O.selectDeviceEntityFrom==="name"?O.items.default=S.name:O.selectDeviceEntityFrom==="description"&&(O.items.default=S.description),M()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ee&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ee&&e.jsx(ae,{sx:Ae,children:ee}),C&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[O.selectFrom&&e.jsx(T,{title:"Add a device from the list",children:e.jsx(K,{onClick:me,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),O.selectEntityFrom&&e.jsx(T,{title:"Add an entity from the list",children:e.jsx(K,{onClick:J,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),O.selectDeviceEntityFrom&&e.jsx(T,{title:"Add a device entity from the list",children:e.jsx(K,{onClick:ue,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),e.jsx(T,{title:"Add a new item",children:e.jsx(K,{onClick:M,size:"small",color:"primary",sx:Pe,children:e.jsx(ct,{})})})]})]}),O.description&&e.jsx(ae,{sx:_e,children:O.description}),W.items.map(S=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:S.children}),e.jsx(K,{disabled:!S.hasMoveUp,onClick:S.onReorderClick(S.index,S.index-1),size:"small",color:"primary",sx:Pe,children:e.jsx(Mt,{})}),e.jsx(K,{disabled:!S.hasMoveDown,onClick:S.onReorderClick(S.index,S.index+1),size:"small",color:"primary",sx:Pe,children:e.jsx(St,{})}),e.jsx(K,{onClick:S.onDropIndexClick(S.index),size:"small",color:"primary",sx:Pe,children:e.jsx(ut,{})})]},S.index)),e.jsxs(Me,{open:ce,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ae,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{fullWidth:!0,variant:"outlined",value:h,onChange:be,placeholder:"Enter serial or name"})]}),e.jsx(Je,{dense:!0,children:qe.filter(S=>S.serial.toLowerCase().includes(h.toLowerCase())||S.name.toLowerCase().includes(h.toLowerCase())).map((S,he)=>e.jsxs(rt,{onClick:()=>je(S),sx:st,children:[S.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),S.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),S.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),e.jsx(re,{primary:S.name,secondary:S.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},he))})]}),e.jsx(Le,{children:e.jsx(ie,{onClick:me,children:"Close"})})]}),e.jsxs(Me,{open:de,onClose:J,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select an entity"}),e.jsxs(Ie,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ae,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{fullWidth:!0,variant:"outlined",value:h,onChange:be,placeholder:"Enter name or description"})]}),e.jsx(Je,{dense:!0,children:xt.filter(S=>S.name.toLowerCase().includes(h.toLowerCase())||S.description.toLowerCase().includes(h.toLowerCase())).map((S,he)=>e.jsxs(rt,{onClick:()=>Qe(S),sx:st,children:[S.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),S.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),S.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),S.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:ye})}),S.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:ye})}),e.jsx(re,{primary:S.name,secondary:S.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},he))})]}),e.jsx(Le,{children:e.jsx(ie,{onClick:J,children:"Close"})})]}),e.jsxs(Me,{open:se,onClose:ue,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(ke,{children:["Select an entity for ",ee]}),e.jsx(Ie,{children:e.jsx(Je,{dense:!0,children:qe.filter(S=>S.serial===ee||S.name===ee).map(S=>S.entities?.map((he,Ke)=>e.jsxs(rt,{onClick:()=>Q(he),sx:st,children:[he.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),he.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),he.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),he.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:ye})}),he.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:ye})}),e.jsx(re,{primary:he.name,secondary:he.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},Ke)))})}),e.jsx(Le,{children:e.jsx(ie,{onClick:ue,children:"Close"})})]})]})}function te(W){const{onAddClick:C,schema:M,properties:O,title:ee,description:ce}=W,[le,de]=r.useState(!1),[A,se]=r.useState(""),G=J=>{se(J.target.value)},h=()=>{de(!le)},fe=J=>{s&&console.log(`ObjectFieldTemplate: handleSelectValue value "${J.serial}" for schema "${M.selectFrom}"`),de(!1);let ue="";M.selectFrom==="serial"?ue=J.serial:M.selectFrom==="name"&&(ue=J.name),_(ue),s&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ue}"`),C(M)()},be=()=>{C(M)()},me=!M.additionalProperties;return s&&console.log(`ObjectFieldTemplate: isRoot ${me} newkey "${P}"`),!me&&P!==""&&(s&&console.log("ObjectFieldTemplate: newkey",P,"properties",O),O.forEach(J=>{if(J.name==="newKey"&&J.content.key==="newKey"&&J.content.props.name==="newKey"&&J.content.props.onKeyChange&&P!==""){s&&console.log("ObjectFieldTemplate: newkey onKeyChange",P);const ue=P;_(""),J.content.props.onKeyChange(ue)}})),e.jsxs(Z,{sx:{margin:"0px",padding:me?"10px":"5px 10px 0px 10px",border:me?"none":"1px solid grey"},children:[M.title&&me&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:Ae,children:M.title})}),ee&&!me&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ae,{sx:Ae,children:ee}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(T,{title:"Add a device from the list",children:e.jsx(K,{onClick:h,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),e.jsx(T,{title:"Add a new item",children:e.jsx(K,{onClick:be,size:"small",color:"primary",sx:Pe,children:e.jsx(ct,{})})})]})]}),M.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:_e,children:M.description})}),O.map(({content:J,name:ue,hidden:je})=>!je&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[ue].type)?"0px":Zo,border:["object","array","boolean"].includes(M.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[ue].type)&&e.jsx(ae,{sx:Ae,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:J})]},ue)),e.jsxs(Me,{open:le,onClose:h,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ae,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{fullWidth:!0,variant:"outlined",value:A,onChange:G,placeholder:"Enter serial or name"})]}),e.jsx(Je,{dense:!0,children:qe.filter(J=>J.serial.toLowerCase().includes(A.toLowerCase())||J.name.toLowerCase().includes(A.toLowerCase())).map((J,ue)=>e.jsxs(rt,{onClick:()=>fe(J),sx:st,children:[J.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),J.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),J.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),e.jsx(re,{primary:J.name,secondary:J.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},ue))})]}),e.jsx(Le,{children:e.jsx(ie,{onClick:h,children:"Close"})})]})]})}function Y(W){const{uiSchema:C}=W,{submitText:M,norender:O}=Wo(C);return O?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:M}),e.jsx(ie,{variant:"contained",color:"primary",onClick:m,children:"Cancel"})]})}function xe(W){const{className:C,disabled:M,onClick:O,registry:ee,style:ce,uiSchema:le,...de}=W;return e.jsx(T,{title:"Remove the item",children:e.jsx(K,{disabled:M,size:"small",color:"primary",onClick:O,children:e.jsx(ut,{})})})}function U(W){const{className:C,disabled:M,onClick:O,registry:ee,uiSchema:ce,...le}=W;return e.jsx(T,{title:"Add an item",children:e.jsx(K,{size:"small",color:"primary",onClick:O,children:e.jsx(ct,{})})})}function oe(W){const{disabled:C,onClick:M,registry:O,style:ee,uiSchema:ce,...le}=W;return e.jsx(T,{title:"Move up the item",children:e.jsx(K,{size:"small",color:"primary",onClick:M,children:e.jsx(Mt,{})})})}function $(W){const{disabled:C,onClick:M,registry:O,style:ee,uiSchema:ce,...le}=W;return e.jsx(T,{title:"Move down the item",children:e.jsx(K,{size:"small",color:"primary",onClick:M,children:e.jsx(St,{})})})}function B(W){const{id:C,name:M,value:O,schema:ee,readonly:ce,onChange:le}=W,[de,A]=r.useState(),se=h=>{s&&console.log(`CheckboxWidget ${M} onChangeField:`,h),A(h&&h!==""?h:void 0)},G=()=>{s&&console.log(`CheckboxWidget onClick plugin="${c.name}" action="${M}" value="${de}"`),n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name,action:M,value:de,formData:f,id:C}}),ee.buttonClose===!0?m():ee.buttonSave===!0&&y({formData:x})};return ee.buttonText&&ee.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:_e,children:ee.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>G(),children:ee.buttonText})]}):ee.buttonField&&ee.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:_e,children:ee.description}),e.jsx(ge,{id:M+"-input",name:M,label:ee.textLabel,placeholder:ee.textPlaceholder,onChange:h=>se(h.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:M+"-button",variant:"contained",color:"primary",disabled:de===void 0,onClick:()=>G(),children:ee.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ae,{sx:Ae,children:M}),e.jsx(Te,{checked:O,readOnly:ce,onChange:()=>le(!O),sx:{padding:"0px",margin:"0px"}})]}),ee.description&&e.jsx(ae,{sx:_e,children:ee.description})]})}function N({schema:W,id:C,name:M,options:O,label:ee,hideLabel:ce,required:le,disabled:de,placeholder:A,readonly:se,value:G,multiple:h,autofocus:fe,onChange:be,onBlur:me,onFocus:J,errorSchema:ue,rawErrors:je=[],registry:Qe,uiSchema:Q,hideError:S,formContext:he,...Ke}){const{enumOptions:Ne,enumDisabled:Ye,emptyValue:Ce}=O;h=typeof h>"u"?!1:!!h;const yt=h?[]:"",jt=typeof G>"u"||h&&G.length<1||!h&&G===yt,Kt=({target:{value:De}})=>be(ft(De,Ne,Ce)),Jt=({target:De})=>me(C,ft(De&&De.value,Ne,Ce)),Gt=({target:De})=>J(C,ft(De&&De.value,Ne,Ce)),wt=Po(G,Ne,h),{InputLabelProps:Yt,SelectProps:Xt,autocomplete:Zt,...er}=Ke,tr=!h&&W.default===void 0;return e.jsxs(ge,{id:C,name:C,value:!jt&&typeof wt<"u"?wt:yt,required:le,disabled:de||se,autoFocus:fe,autoComplete:Zt,placeholder:A,error:je.length>0,onChange:Kt,onBlur:Jt,onFocus:Gt,...er,select:!0,InputLabelProps:{...Yt,shrink:!jt},SelectProps:{...Xt,multiple:h},"aria-describedby":No(C),children:[tr&&e.jsx(k,{value:"",children:A}),Array.isArray(Ne)&&Ne.map(({value:De,label:rr},Ct)=>{const or=Array.isArray(Ye)&&Ye.indexOf(De)!==-1;return e.jsx(k,{value:String(Ct),disabled:or,children:rr},Ct)})]})}return s&&console.log("ConfigPluginDialog rendering..."),!i||!p||!x?null:e.jsxs(Me,{open:i,onClose:m,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(ke,{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(Ie,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Io,{schema:p,formData:x,uiSchema:V,validator:Do,templates:{FieldTemplate:I,BaseInputTemplate:o,TitleFieldTemplate:F,DescriptionFieldTemplate:H,FieldHelpTemplate:E,FieldErrorTemplate:a,ErrorListTemplate:v,WrapIfAdditionalTemplate:w,ArrayFieldTitleTemplate:d,ArrayFieldDescriptionTemplate:u,ArrayFieldItemTemplate:L,ArrayFieldTemplate:pe,ObjectFieldTemplate:te,ButtonTemplates:{SubmitButton:Y,RemoveButton:xe,AddButton:U,MoveUpButton:oe,MoveDownButton:$}},widgets:{CheckboxWidget:B,SelectWidget:N},onChange:X,onSubmit:y})})]})};function Qt(i){if(s&&console.log(`getQRColor (id: ${i?.id}) received matter:`,i??"undefined"),i===void 0||!i.online||!i.qrPairingCode&&!i.manualPairingCode&&!i.fabricInformations&&!i.sessionInformations)return"red";if(i.commissioned===!1&&i.qrPairingCode&&i.manualPairingCode)return"var(--primary-color)";let m=0,c=0;for(const n of i.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&m++,n.numberOfActiveSubscriptions>0&&(c+=n.numberOfActiveSubscriptions);return i.commissioned===!0&&i.fabricInformations&&i.sessionInformations&&(m===0||c===0)?"var(--secondary-color)":"var(--div-text-color)"}function tn(i,m,c){const n=i?.[c],l=m?.[c];return n==null&&l==null?0:n==null?-1:l==null?1:typeof n=="boolean"&&typeof l=="boolean"?n===l?0:n?1:-1:typeof n=="number"&&typeof l=="number"?n-l:String(n).localeCompare(String(l))}function rn({name:i,title:m,columns:c,rows:n,getRowKey:l,footerLeft:b,footerRight:g,onRowClick:t}){const x=r.useRef(new WeakMap),D=r.useRef(1),p=a=>{if(typeof l=="string"&&a&&a[l]!=null)return a[l];if(typeof l=="function"){const u=l(a);if(u!=null)return u}const o=c?.[0]?.id;if(o&&a&&a[o]!=null)return a[o];console.warn(`MbfTable(${i}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let d=x.current.get(a);return d||(d=`rk_${D.current++}`,x.current.set(a,d)),d},[j,V]=r.useState(localStorage.getItem(`${i}_table_order_by`)||null),[R,P]=r.useState(localStorage.getItem(`${i}_table_order`)||null),[_,f]=r.useState(!1),[X,y]=r.useState(()=>{try{const a=localStorage.getItem(`${i}_column_visibility`);if(a)return JSON.parse(a)}catch{}return{}}),w=r.useMemo(()=>{const a={};for(const o of c)o.hidden||(a[o.id]=o.required?!0:X[o.id]!==!1);return a},[c,X]),I=r.useMemo(()=>{if(!j||!R)return n;const a=c.find(d=>d.id===j);if(!a||a.noSort)return n;const o=n.map((d,u)=>({el:d,index:u}));return o.sort((d,u)=>{let L;return typeof a.comparator=="function"?L=a.comparator(d.el,u.el):L=tn(d.el,u.el,j),L!==0?R==="asc"?L:-L:d.index-u.index}),o.map(d=>d.el)},[n,j,R,c]),H=a=>{if(j!==a||!j){V(a),P("asc"),localStorage.setItem(`${i}_table_order_by`,a),localStorage.setItem(`${i}_table_order`,"asc");return}if(R==="asc"){P("desc"),localStorage.setItem(`${i}_table_order`,"desc");return}V(null),P(null),localStorage.removeItem(`${i}_table_order_by`),localStorage.removeItem(`${i}_table_order`)},F=()=>{f(!_)},E=a=>{y(o=>{const d=c.find(pe=>pe.id===a);if(d&&d.required)return o;const u=w[a]!==!1,L={...o};u?L[a]=!1:delete L[a];try{localStorage.setItem(`${i}_column_visibility`,JSON.stringify(L))}catch{}return L})},v=()=>{y({});try{localStorage.removeItem(`${i}_column_visibility`)}catch{}f(!1)};return s&&console.log(`Rendering table ${i}${j&&R?` ordered by ${j}:${R}`:""}`),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(Me,{open:_,onClose:(a,o)=>{o==="backdropClick"||o==="escapeKeyDown"||F()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(ke,{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 ${i} columns`})]})}),e.jsx(Ie,{children:e.jsx(wr,{children:c.filter(a=>!a.hidden).map(a=>e.jsx(Fe,{control:e.jsx(Te,{disabled:!!a.required,checked:a.required?!0:w[a.id]!==!1,onChange:()=>E(a.id)}),label:a.label},a.id))})}),e.jsxs(Le,{children:[e.jsx(ie,{onClick:v,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:a=>{if(a?.currentTarget&&typeof a.currentTarget.blur=="function")try{a.currentTarget.blur()}catch{}const o=document.activeElement;if(o&&o instanceof HTMLElement&&typeof o.blur=="function")try{o.blur()}catch{}F()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:i}),m&&e.jsx("p",{className:"MbfWindowHeaderText",children:m}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(K,{onClick:a=>{if(a?.currentTarget?.blur)try{a.currentTarget.blur()}catch{}F()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(T,{title:`Configure ${i} columns`,children:e.jsx(ne,{path:io,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":`${i} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(a=>{if(a.hidden||!a.required&&w[a.id]===!1)return null;const o=!a.noSort,d=o&&j===a.id&&!!R;return e.jsxs("th",{onClick:o?()=>H(a.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:a.minWidth,maxWidth:a.maxWidth,textAlign:a.align||"left",cursor:o?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:a.maxWidth?"nowrap":void 0,overflow:a.maxWidth?"hidden":void 0,textOverflow:a.maxWidth?"ellipsis":void 0},"aria-sort":o?d?R==="asc"?"ascending":"descending":"none":void 0,children:[a.label,d&&e.jsxs("span",{style:{marginLeft:6},children:[R==="asc"&&e.jsx(ne,{path:so,size:"15px"}),R==="desc"&&e.jsx(ne,{path:ao,size:"15px"})]})]},a.id)})})}),e.jsx("tbody",{children:I.map((a,o)=>{const d=p(a);return e.jsx("tr",{className:o%2===0?"table-content-even":"table-content-odd",onClick:t?u=>t(a,d,u):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:c.map(u=>{if(u.hidden||!u.required&&w[u.id]===!1)return null;const L=a[u.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:u.align||"left",padding:"5px 10px",margin:"0",maxWidth:u.maxWidth,whiteSpace:u.maxWidth?"nowrap":void 0,overflow:u.maxWidth?"hidden":void 0,textOverflow:u.maxWidth?"ellipsis":void 0},children:typeof u.render=="function"?u.render(L,d,a,u):typeof L=="boolean"?e.jsx(Te,{checked:L,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):u.format&&typeof L=="number"?u.format(L):L!=null?String(L):null},u.id)})},d)})})]})}),(b||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:b}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}function on(i){return r.memo(i)}const mt=on(rn);function nn({storeId:i,setStoreId:m}){const{online:c,sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(ve),{showConfirmCancelDialog:t}=r.useContext(Be),x=r.useRef(g()),[D,p]=r.useState(null),[j,V]=r.useState(null),[R,P]=r.useState([]),_=[{label:"Name",id:"name",required:!0,render:($,B,N,W)=>e.jsx(T,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a(N),children:N.name})})},{label:"Description",id:"description",render:($,B,N,W)=>e.jsx(T,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a(N),children:N.description})})},{label:"Version",id:"version",render:($,B,N,W)=>e.jsxs(e.Fragment,{children:[N.latestVersion!==void 0&&N.latestVersion!==N.version&&j&&!j.readOnly&&e.jsx(T,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>I(N),children:["Update to v.",N.latestVersion]})}),N.version.includes("-dev-")&&N.devVersion!==void 0&&N.devVersion!==N.version&&j&&!j.readOnly&&e.jsx(T,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>H(N),children:["Update to new dev v.",N.devVersion.split("-dev-")[0]]})}),e.jsx(T,{title:"Plugin version",children:e.jsx("span",{children:N.version})})]})},{label:"Author",id:"author",render:($,B,N,W)=>e.jsx(e.Fragment,{children:N.author?N.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:($,B,N,W)=>e.jsx(e.Fragment,{children:N.type?N.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:($,B,N,W)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[j&&j.bridgeMode==="childbridge"&&!N.error&&N.enabled&&e.jsx(T,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:Qt(N.matter)},onClick:()=>{N.matter?.id&&m(N.matter?.id)},size:"small",children:e.jsx(At,{})})}),j&&j.bridgeMode==="childbridge"&&!N.error&&N.enabled&&e.jsx(T,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>E(N),size:"small",children:e.jsx(dt,{})})}),e.jsx(T,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{disabled:N.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>xe(N),size:"small",children:e.jsx(vt,{})})}),j&&!j.readOnly&&e.jsx(T,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{X("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",N)},size:"small",children:e.jsx(ut,{})})}),N.enabled?e.jsx(T,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{X("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",N)},size:"small",children:e.jsx(Cr,{})})}):e.jsx(e.Fragment,{}),N.enabled?e.jsx(e.Fragment,{}):e.jsx(T,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>v(N),size:"small",children:e.jsx(Sr,{})})}),e.jsx(T,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>d(N),size:"small",children:e.jsx(Mr,{})})}),e.jsx(T,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u(N),size:"small",children:e.jsx(kr,{})})}),j&&!j.readOnly&&e.jsx(T,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>o(N),size:"small",children:e.jsx(Vt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:($,B,N,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:N.error?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:N.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:N.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:N.loaded&&N.started&&N.configured?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:N.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{status:N.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ee,{status:N.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ee,{status:N.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const $=B=>{B.src==="Matterbridge"&&B.dst==="Frontend"&&(B.method==="refresh_required"&&B.response.changed==="plugins"&&(s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and sending /api/plugins request`),n({id:x.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),B.method==="refresh_required"&&B.response.changed==="matter"&&(s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and setting matter id ${B.response.matter?.id}`),P(N=>{const W=N.findIndex(M=>M.matter?.id===B.response.matter?.id);if(W<0)return s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and matter id ${B.response.matter?.id} not found`),N;s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} set matter id ${B.response.matter?.id}`);const C=[...N];return C[W]={...C[W],matter:B.response.matter},C})),B.method==="refresh_required"&&B.response.changed==="settings"&&(s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and sending /api/settings request`),n({id:x.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),B.id===x.current&&B.method==="/api/settings"&&(s&&console.log(`HomePlugins (id: ${B.id}) received settings:`,B.response),p(B.response.systemInformation),V(B.response.matterbridgeInformation)),B.id===x.current&&B.method==="/api/plugins"&&(s&&console.log(`HomePlugins (id: ${B.id}) received ${B.response.length} plugins:`,B.response),P(B.response)))};return l($,x.current),s&&console.log("HomePlugins added WebSocket listener id:",x.current),()=>{b($),s&&console.log("HomePlugins removed WebSocket listener")}},[l,b,n]),r.useEffect(()=>{c&&(s&&console.log("HomePlugins sending api requests"),n({id:x.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:x.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]);const f=r.useRef(null),X=($,B,N,W)=>{s&&console.log(`handleActionWithConfirmCancel ${N} ${W.name}`),f.current=W,t($,B,N,y,w)},y=$=>{s&&console.log(`handleConfirm action confirmed ${$} ${f.current?.name}`),$==="remove"&&f.current?F(f.current):$==="disable"&&f.current&&v(f.current),f.current=null},w=$=>{s&&console.log(`handleCancel action canceled ${$} ${f.current?.name}`),f.current=null},I=$=>{s&&console.log("handleUpdatePlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:$.name,restart:!1}})},H=$=>{s&&console.log("handleUpdateDevPlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:$.name+"@dev",restart:!1}})},F=$=>{s&&console.log("handleRemovePlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}})},E=$=>{s&&console.log("handleRestartPlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}})},v=$=>{s&&console.log("handleEnableDisablePlugin plugin:",$.name,"enabled:",$.enabled),$.enabled===!0?($.enabled=!1,n({id:x.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}})):($.enabled=!0,n({id:x.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}}))},a=$=>{s&&console.log(`handleHomepagePlugin plugin: ${$.name} homepage: ${$.homepage}`),$.homepage&&window.open($.homepage,"_blank")},o=$=>{s&&console.log("handleSponsorPlugin plugin:",$.name,"funding:",$.funding),$.funding&&window.open($.funding,"_blank")},d=$=>{s&&console.log("handleHelpPlugin plugin:",$.name,"help:",$.help),$.help&&window.open($.help,"_blank")},u=$=>{s&&console.log("handleChangelogPlugin plugin:",$.name,"changelog:",$.changelog),$.changelog&&window.open($.changelog,"_blank")},[L,pe]=r.useState(),[te,Y]=r.useState(!1),xe=$=>{s&&console.log("handleConfigPlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:$.name}}),n({id:x.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:$.name}}),pe($),U()},U=()=>{Y(!0)},oe=()=>{Y(!1)};return s&&console.log("HomePlugins rendering..."),c?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[L&&e.jsx(en,{open:te,onClose:oe,plugin:L}),e.jsx(mt,{name:"Plugins",columns:_,rows:R,footerRight:"",footerLeft:""})]}):e.jsx(Re,{})}const sn=r.memo(nn),an=i=>`${i.pluginName}::${i.serial}`;function ln({storeId:i,setStoreId:m}){const{online:c,sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(ve),[t,x]=r.useState(!1),[D,p]=r.useState(!0),[j,V]=r.useState(null),[R,P]=r.useState([]),[_,f]=r.useState([]),[X,y]=r.useState([]),[w,I]=r.useState([]),H=r.useRef(g()),F=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(a,o,d,u)=>d.reachable===!0?"Online":d.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(a,o)=>{const d=a.reachable===!0?1:a.reachable===!1?0:-1,u=o.reachable===!0?1:o.reachable===!1?0:-1;return d-u}},{label:"Power",id:"powerSource",render:(a,o,d,u)=>d.powerSource==="ac"||d.powerSource==="dc"?e.jsx(_t,{fontSize:"small",sx:{color:"var(--primary-color)"}}):d.powerSource==="ok"?e.jsx(pt,{fontSize:"small",sx:{color:"green"}}):d.powerSource==="warning"?e.jsx(pt,{fontSize:"small",sx:{color:"yellow"}}):d.powerSource==="critical"?e.jsx(pt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(a,o,d,u)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[d.matter!==void 0?e.jsx(T,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>m(i===d.matter?.id?j?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:d.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Qt(d.matter)},children:e.jsx(At,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.configUrl?e.jsx(T,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>window.open(d.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.selected!==void 0?e.jsx(T,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Te,{checked:d.selected,onChange:L=>v(L,d),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],E=r.useCallback(a=>{a.selected=void 0;const o=R.find(L=>L.name===a.pluginName);if(!o)return console.error(`HomeDevices isSelected: plugin ${a.pluginName} not found for device ${a.name} `),a.selected;const d=o.schemaJson?.properties?.whiteList?.selectFrom;let u=o.configJson.postfix;return u===""&&(u=void 0),o.hasWhiteList===!0&&o.hasBlackList===!0&&d&&(a.selected=!0,d==="serial"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&o.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!0),d==="serial"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&!o.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="serial"&&o.configJson.blackList&&o.configJson.blackList.length>0&&o.configJson.blackList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="name"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&o.configJson.whiteList.includes(a.name)&&(a.selected=!0),d==="name"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&!o.configJson.whiteList.includes(a.name)&&(a.selected=!1),d==="name"&&o.configJson.blackList&&o.configJson.blackList.length>0&&o.configJson.blackList.includes(a.name)&&(a.selected=!1)),a.selected},[R]);r.useEffect(()=>{const a=o=>{if(o.method==="refresh_required"&&o.response.changed!=="matter"?(s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and sending /api/plugins request`),n({id:H.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):o.method==="refresh_required"&&o.response.changed==="matter"?(s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and setting matter id ${o.response.matter?.id}`),I(d=>{const u=d.findIndex(pe=>pe.name.replaceAll(" ","")===o.response.matter?.id);if(u<0)return s&&console.debug(`HomeDevices: matter id ${o.response.matter?.id} not found`),d;const L=[...d];return L[u]={...L[u],matter:o.response.matter},s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and set matter id ${o.response.matter?.id}`),L})):o.method==="restart_required"?(s&&console.log("HomeDevices received restart_required"),x(!0)):o.method==="restart_not_required"?(s&&console.log("HomeDevices received restart_not_required"),x(!1)):o.method==="state_update"&&o.response.plugin&&o.response.serialNumber&&o.response.cluster.includes("BasicInformation")&&o.response.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${o.response.plugin} serial ${o.response.serialNumber} value ${o.response.value}`),f(d=>{const u=d.findIndex(L=>L.pluginName===o.response.plugin&&L.serial===o.response.serialNumber);return u<0?(console.warn(`HomeDevices: device to update not found for plugin ${o.response.plugin} serial ${o.response.serialNumber}`),d):(d[u]={...d[u],reachable:o.response.value},[...d])})),o.id===H.current&&o.method==="/api/settings")s&&console.log(`HomeDevices (id: ${o.id}) received settings:`,o.response),V(o.response),x(o.response.matterbridgeInformation.restartRequired||o.response.matterbridgeInformation.fixedRestartRequired);else if(o.id===H.current&&o.method==="/api/plugins"){if(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} plugins:`,o.response),o.response){let d=!0;for(const u of o.response)u.enabled===!0&&(u.loaded!==!0||u.started!==!0||u.error===!0)&&(d=!1);if(!d)return;s&&console.log("HomeDevices reset plugins, devices and selectDevices"),p(!1),P(o.response),f([]),y([]),n({id:H.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),s&&console.log("HomeDevices sent /api/devices");for(const u of o.response)u.enabled===!0&&u.loaded===!0&&u.started===!0&&u.error!==!0&&(n({id:H.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:u.name}}),s&&console.log(`HomeDevices sent /api/select/devices for plugin: ${u.name}`))}}else if(o.id===H.current&&o.method==="/api/devices"){if(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} devices:`,o.response),o.response){for(const d of o.response)d.selected=E(d);f(o.response)}}else o.id===H.current&&o.method==="/api/select/devices"&&(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} selectDevices for plugin ${o.response&&o.response.length>0?o.response[0].pluginName:"without select devices"}:`,o.response),o.response&&o.response.length>0&&y(d=>{const u=d.filter(pe=>pe.pluginName!==o.response[0].pluginName),L=o.response.map(pe=>({...pe,selected:E(pe)}));return[...u,...L]}))};return l(a,H.current),s&&console.log(`HomeDevices added WebSocket listener id ${H.current}`),()=>{b(a),s&&console.log("HomeDevices removed WebSocket listener")}},[R,l,b,n,E]),r.useEffect(()=>{if(_.length===0&&X.length===0){I([]);return}s&&console.log(`HomeDevices mixing devices (${_.length}) and selectDevices (${X.length})`);const a=[];for(const o of _)a.push(o);for(const o of X)_.find(d=>d.pluginName===o.pluginName&&d.serial.includes(o.serial))||a.push(o);a.length>0&&(I(a),console.log(`HomeDevices mixed ${a.length} devices and selectDevices`))},[R,_,X,I]),r.useEffect(()=>{c&&(s&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:H.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:H.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]);const v=(a,o)=>{console.log(`handleCheckboxChange: checkbox changed to ${a.target.checked} for device ${o.name} serial ${o.serial}`),_.findIndex(d=>d.pluginName===o.pluginName&&d.serial===o.serial)<0?(s&&console.warn(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in devices, trying in mixedDevices`),I(d=>{const u=d.findIndex(L=>L.pluginName===o.pluginName&&L.serial===o.serial);return u<0?(console.error(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in mixedDevices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])})):f(d=>{const u=d.findIndex(L=>L.pluginName===o.pluginName&&L.serial===o.serial);return u<0?(console.error(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in devices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])}),a.target.checked?n({id:H.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:o.pluginName,serial:o.serial,name:o.name}}):n({id:H.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:o.pluginName,serial:o.serial,name:o.name}})};return s&&console.log("HomeDevices rendering..."),c?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Devices",getRowKey:an,rows:w,columns:F,footerLeft:D?"Waiting for the plugins to fully load...":`Registered devices: ${_.length.toString()}/${w.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Re,{})}const dn=r.memo(ln);function cn(){const[i,m]=r.useState(null),[c,n]=r.useState(null),[l,b]=r.useState([]),[g]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,x]=r.useState(localStorage.getItem("homePageMode")??"devices"),[D,p]=r.useState(""),[j,V]=r.useState(!1),[R,P]=r.useState(!1),[_,f]=r.useState(null),{addListener:X,removeListener:y,online:w,sendMessage:I,logFilterLevel:H,logFilterSearch:F,autoScroll:E,getUniqueId:v}=r.useContext(ve),a=r.useRef(v());return r.useEffect(()=>{const o=d=>{d.method==="refresh_required"&&d.response.changed==="settings"&&(console.log(`Home received refresh_required: changed=${d.response.changed} and sending /api/settings request`),f(null),b([]),I({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),I({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===a.current&&(console.log("Home received settings:",d.response),m(d.response.systemInformation),n(d.response.matterbridgeInformation),d.response.matterbridgeInformation.matterbridgeVersion&&p(`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),P(!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),V(!0)),d.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),x("devices")))),d.method==="/api/plugins"&&d.id===a.current&&(console.log("Home received plugins:",d.response),b(d.response))};return X(o,a.current),console.log(`Home added WebSocket listener id ${a.current}`),()=>{y(o),console.log("Home removed WebSocket listener")}},[X,y,I]),r.useEffect(()=>{if(console.log(`Home settings and plugins effect with storeId ${_}`),c?.bridgeMode==="bridge"&&!_&&(console.log(`Home set storeId from ${_} to Matterbridge`),f("Matterbridge")),c?.bridgeMode==="childbridge"&&!_&&l){for(const o of l)if(o.matter?.id){console.log(`Home set storeId from ${_} to ${o.matter.id}`),f(o.matter.id);break}}},[c,l,_]),r.useEffect(()=>{w&&(console.log("Home online effect, sending /api/settings and /api/plugins requests"),I({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),I({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[w,I]),console.log("Home rendering..."),!w||!i||!c?e.jsx(Re,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ko,{id:_}),e.jsx(Uo,{systemInfo:i,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[R&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Ir,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),j&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ie,{onClick:()=>window.open(D,"_blank"),endIcon:e.jsx(Et,{}),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(Dr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),g&&!c.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(Go,{})]}),g&&e.jsx(sn,{storeId:_,setStoreId:f}),t==="devices"&&e.jsx(dn,{storeId:_,setStoreId:f}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',H,'" and search "',F,'" Scroll: ',E?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(Bt,{})})]})]})]})}const pn=r.memo(cn),Ht={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},un={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},gn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Ot={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},mn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},hn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},fn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},xn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},bn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},bt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},vn=[256,257,268,269],yn=[266,267],jn=[259,260,261,271,272],wn=[256,257,268,269,266,267,259,260,261,272];function q({icon:i,iconColor:m,cluster:c,value:n,unit:l,prefix:b}){return s&&console.log(`Render cluster "${c.clusterName}.${c.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${l}"`),b=b??!1,e.jsxs(Z,{sx:Ht,children:[i&&r.cloneElement(i,{key:`${c.clusterId}-${c.attributeId}-icon`,sx:{...un,color:m??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Ht,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&b===!0&&e.jsx(ae,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`),e.jsx(ae,{sx:gn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${c.clusterId}-${c.attributeId}-value`),l&&b===!1&&e.jsx(ae,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`)]},`${c.clusterId}-${c.attributeId}-valueunitbox`)]},`${c.clusterId}-${c.attributeId}-box`)}function Cn({device:i,endpoint:m,id:c,deviceType:n,clusters:l}){const b=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";return s&&console.log(`Device "${i.name}" endpoint "${m}" id "${c}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>g=`${t.attributeLocalValue} mV`),wn.includes(n)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>g=`Level ${t.attributeValue}`),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>g=`Position ${t.attributeLocalValue/100}%`),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>g=`Heat ${t.attributeLocalValue/100}°C `),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>g=g+`Cool ${t.attributeLocalValue/100}°C`),n===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>g=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>g=`${t.attributeLocalValue/1e3} V, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>g=g+`${t.attributeLocalValue/1e3} A, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>g=g+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[n===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:t.attributeLocalValue===!0?e.jsx(Ge,{}):e.jsx(Pr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(q,{icon:e.jsx(pt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(q,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),vn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Nr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),yn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:"Oven"})),n===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Wr,{}),cluster:t,value:"Fridge"})),n===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Lt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Lt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(q,{icon:e.jsx($r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(q,{icon:t.attributeValue==="1"?e.jsx(Lr,{}):e.jsx(Fr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Tr,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(q,{icon:e.jsx(Rr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Hr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Pt,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(Pt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Er,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(q,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:b[t.attributeLocalValue??0]})),n===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:t.attributeValue==="true"?e.jsx(Ur,{}):e.jsx(Br,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Qr,{}):e.jsx(Kr,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Jr,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),n===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(q,{icon:e.jsx(Gr,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:mn,children:e.jsx(ae,{sx:hn,children:g})}),e.jsx(Z,{sx:fn,children:e.jsx(ae,{sx:xn,children:i.name})}),e.jsxs(Z,{sx:bn,children:[s&&e.jsx(ae,{sx:bt,children:m}),e.jsx(ae,{sx:bt,children:c}),s&&e.jsxs(ae,{sx:bt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function Sn({filter:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState(null),[x,D]=r.useState([]),[p,j]=r.useState([]),[V,R]=r.useState(p),[P,_]=r.useState({}),[f,X]=r.useState({}),[y,w]=r.useState({}),I=r.useRef(b()),H=r.useRef(V),F=r.useCallback(v=>{console.log(`DevicesIcons received state_update "${v.response.cluster}.${v.response.attribute}" for "${v.response.id}:${v.response.number}": "${v.response.value}"`,v.response);const a=H.current.find(d=>d.pluginName===v.response.plugin&&d.uniqueId===v.response.uniqueId);if(!a){console.warn(`DevicesIcons updater device of plugin "${v.response.plugin}" serial "${v.response.serialNumber}" not found in filteredDevicesRef.current`);return}const o=y[a.serial].find(d=>d.endpoint===v.response.number.toString()&&d.clusterName===v.response.cluster&&d.attributeName===v.response.attribute);if(!o){console.warn(`DevicesIcons updater device "${a.name}" serial "${a.serial}" cluster "${v.response.cluster}" attribute "${v.response.attribute}" not found in clusters`);return}o.attributeValue=String(v.response.value),o.attributeLocalValue=v.response.value,w({...y}),console.log(`DevicesIcons updated "${o.clusterName}.${o.attributeName}" for device "${a.name}" serial "${a.serial}" to "${o.attributeValue}"`)},[y]);r.useEffect(()=>{const v=a=>{if(a.method==="refresh_required")s&&console.log(`DevicesIcons received refresh_required: changed=${a.response.changed} and sending api requests`),c({id:I.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(a.method==="state_update"&&a.response)F(a);else if(a.method==="/api/settings"&&a.response)s&&console.log("DevicesIcons received settings:",a.response),t(a.response);else if(a.method==="/api/plugins"&&a.response)s&&console.log("DevicesIcons received plugins:",a.response),D(a.response);else if(a.method==="/api/devices"&&a.response){s&&console.log(`DevicesIcons received ${a.response.length} devices:`,a.response),j(a.response);for(const o of a.response)s&&console.log("DevicesIcons sending /api/clusters"),c({id:I.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:o.pluginName,endpoint:o.endpoint||0}})}else if(a.method==="/api/clusters"&&a.response){if(s&&console.log(`DevicesIcons received for device "${a.response.deviceName}" serial "${a.response.serialNumber}" deviceTypes (${a.response.deviceTypes.length}) "${a.response.deviceTypes.join(",")}" clusters (${a.response.clusters.length}):`,a.response),a.response.clusters.length===0)return;const o=a.response.serialNumber;P[o]=[],f[o]=a.response.deviceTypes,y[o]=[];for(const d of a.response.clusters)P[o].find(u=>u.endpoint===d.endpoint)||P[o].push({endpoint:d.endpoint,id:d.id,deviceTypes:d.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(d.clusterName)&&y[o].push(d);_({...P}),X({...f}),w({...y}),s&&console.log(`DevicesIcons endpoints for "${o}":`,P[o]),s&&console.log(`DevicesIcons deviceTypes for "${o}":`,f[o]),s&&console.log(`DevicesIcons clusters for "${o}":`,y[o])}};return n(v,I.current),s&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(v),s&&console.log("DevicesIcons useEffect webSocket unmounted")}},[]),r.useEffect(()=>(s&&console.log("DevicesIcons useEffect online mounting"),m&&(s&&console.log("DevicesIcons useEffect online sending api requests"),c({id:I.current,sender:"DevicesIcons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"DevicesIcons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),s&&console.log("DevicesIcons useEffect online mounted"),()=>{s&&console.log("DevicesIcons useEffect online unmounted")}),[m,c]),r.useEffect(()=>{if(i===""){R(p),H.current=p;return}const v=p.filter(a=>a.name.toLowerCase().includes(i)||a.serial.toLowerCase().includes(i));R(v),H.current=v},[p,i]);const E=r.memo(Cn);return s&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:V.map(v=>P[v.serial]&&P[v.serial].map(a=>a.deviceTypes.map(o=>e.jsx(E,{device:v,endpoint:a.endpoint,id:a.id,deviceType:o,clusters:y[v.serial].filter(d=>d.endpoint===a.endpoint)},`${v.pluginName}-${v.uniqueId}-${a.id}-${o.toString()}`))))})}const Mn=r.memo(Sn),kn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(i,m,c,n)=>c.configUrl?e.jsx(K,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],In=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(i,m,c,n)=>Array.isArray(i)?e.jsx(e.Fragment,{children:i.map(l=>`0x${l.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:i})},{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:(i,m,c,n)=>e.jsx(T,{title:String(i),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(i)})})}],Dn=i=>`${i.pluginName}::${i.uniqueId}`,Pn=i=>`${i.endpoint}::${i.clusterName}::${i.attributeName}`;function Nn({filter:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState([]),[x,D]=r.useState(g),[p,j]=r.useState([]),[V,R]=r.useState(0),[P,_]=r.useState(null),[f,X]=r.useState(null),[y,w]=r.useState(null),[I,H]=r.useState(null),F=r.useRef(b()),E=r.useRef(x),v=r.useCallback(o=>{console.log(`DevicesTable received state_update "${o.response.cluster}.${o.response.attribute}" for "${o.response.id}:${o.response.number}": "${o.response.value}"`,o.response);const d=E.current.find(u=>u.pluginName===o.response.plugin&&u.uniqueId===o.response.uniqueId);if(!d){console.warn(`DevicesTable updater device of plugin "${o.response.plugin}" serial "${o.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(P&&f&&d.pluginName===P&&d.uniqueId===I&&o.response.number.toString()===f){const u=p.find(L=>L.endpoint===o.response.number.toString()&&L.clusterName===o.response.cluster&&L.attributeName===o.response.attribute);if(!u){console.warn(`DevicesTable updater cluster ${o.response.cluster}.${o.response.attribute} for device "${d.name}" serial "${d.serial}" not found in clusters`);return}u.attributeValue=String(o.response.value),u.attributeLocalValue=o.response.value,j([...p]),console.log(`DevicesTable updated attribute ${u.clusterName}.${u.attributeName} for device "${d.name}" serial "${d.serial}" to "${u.attributeValue}"`)}},[p,f,P,I]);r.useEffect(()=>{const o=d=>{if(s&&console.log("DevicesTable received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed==="devices")s&&console.log(`DevicesTable received refresh_required: changed=${d.response.changed} and sending /api/devices request`),c({id:F.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(d.method==="state_update"&&d.response)v(d);else if(d.method==="/api/devices")s&&console.log(`DevicesTable received ${d.response.length} devices:`,d.response),t(d.response);else if(d.method==="/api/clusters"){s&&console.log(`DevicesTable received ${d.response.clusters.length} clusters for plugin ${d.response.plugin}:`,d.response),j(d.response.clusters);const u={};for(const L of d.response.clusters)s&&console.log("Cluster:",L.endpoint),u[L.endpoint]?u[L.endpoint]++:u[L.endpoint]=1;R(Object.keys(u).length)}};return n(o,F.current),s&&console.log("DevicesTable added WebSocket listener"),()=>{l(o),s&&console.log("DevicesTable removed WebSocket listener")}},[c,n,l,v]),r.useEffect(()=>{m&&(s&&console.log("DevicesTable sending api requests with id ",F.current),c({id:F.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:F.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:F.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[m,c]),r.useEffect(()=>{P&&f&&(s&&console.log("DevicesTable sending /api/clusters"),c({id:F.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:P,endpoint:Number(f)}}))},[P,f,c]),r.useEffect(()=>{if(i===""){D(g),E.current=g;return}const o=g.filter(d=>d.name.toLowerCase().includes(i)||d.serial.toLowerCase().includes(i));D(o),E.current=o},[g,i]);const a=o=>{if(o.uniqueId===I){H(null),_(null),X(null),w(null);return}H(o.uniqueId),_(o.pluginName),X(o.endpoint?o.endpoint.toString():null),w(o.name)};return s&&console.log("DevicesTable rendering..."),m?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${P&&f?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Registered devices",getRowKey:Dn,onRowClick:a,rows:x,columns:kn,footerLeft:`Total devices: ${x.length.toString()}`})}),P&&f&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Clusters",title:y||"",getRowKey:Pn,rows:p,columns:In,footerLeft:`Total child endpoints: ${V-1}`})})]}):e.jsx(Re,{})}const Wn=r.memo(Nn);function $n(){const{online:i}=r.useContext(ve),[m,c]=r.useState(""),[n,l]=r.useState("icon");r.useEffect(()=>{const t=localStorage.getItem("devicesFilter");t&&c(t)},[]),r.useEffect(()=>{const t=localStorage.getItem("devicesViewMode");t&&l(t)},[]);const b=t=>{c(t.target.value.toLowerCase()),localStorage.setItem("devicesFilter",t.target.value.toLowerCase())},g=t=>{l(t),localStorage.setItem("devicesViewMode",t)};return s&&console.log("Devices rendering..."),i?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{variant:"outlined",value:m,onChange:b,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(K,{onClick:()=>g("table"),"aria-label":"Table View",disabled:n==="table",children:e.jsx(T,{title:"Table View",children:e.jsx(Yr,{style:{color:n==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(K,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:n==="icon",children:e.jsx(T,{title:"Icon View (beta)",children:e.jsx(Xr,{style:{color:n==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),n==="table"&&e.jsx(Wn,{filter:m}),n==="icon"&&e.jsx(Mn,{filter:m})]}):e.jsx(Re,{})}const Ln=r.memo($n);function Fn(){const[i,m]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[c,n]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[l,b]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:g,setLogFilters:t,online:x,setAutoScroll:D}=r.useContext(ve),p=P=>{m(P.target.value),t(P.target.value,c),localStorage.setItem("logFilterLevel",P.target.value),s&&console.log("handleChangeLevel called with value:",P.target.value)},j=P=>{n(P.target.value),t(i,P.target.value),localStorage.setItem("logFilterSearch",P.target.value),s&&console.log("handleChangeSearch called with value:",P.target.value)},V=P=>{b(P.target.checked),D(P.target.checked),localStorage.setItem("logAutoScroll",P.target.value?"true":"false"),s&&console.log("handleAutoScrollChange called with value:",P.target.checked)},R=()=>{s&&console.log("handleClearLogsClick called"),g([])};return s&&console.log("Logs rendering..."),x?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Nt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ue,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:i,onChange:p,children:[e.jsx(k,{value:"debug",children:"Debug"}),e.jsx(k,{value:"info",children:"Info"}),e.jsx(k,{value:"notice",children:"Notice"}),e.jsx(k,{value:"warn",children:"Warn"}),e.jsx(k,{value:"error",children:"Error"}),e.jsx(k,{value:"fatal",children:"Fatal"})]}),e.jsx(Nt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(ge,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:c,onChange:j,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Fe,{control:e.jsx(Te,{checked:l,onChange:V}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(T,{title:"Clear the logs",children:e.jsx(ie,{onClick:R,endIcon:e.jsx(ut,{}),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(Bt,{})})]}):e.jsx(Re,{})}const Tn=r.memo(Fn),Rn=({open:i,ip:m,onClose:c,onSave:n})=>{const l=m?m.split(".").slice(0,3).join(".")+".1":"",[b,g]=r.useState("dhcp"),[t,x]=r.useState({ip:m??"",subnet:"255.255.255.0",gateway:l,dns:l}),D=V=>R=>{x({...t,[V]:R.target.value})},p=()=>{c()},j=()=>{n({type:b,...t}),c()};return e.jsxs(Me,{open:i,onClose:(V,R)=>{R==="backdropClick"||R==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(ke,{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(Ie,{dividers:!0,children:[e.jsxs(qt,{component:"fieldset",fullWidth:!0,children:[e.jsx(we,{component:"legend",children:"Select IP Configuration"}),e.jsxs(zt,{row:!0,value:b,onChange:V=>g(V.target.value),children:[e.jsx(Fe,{value:"dhcp",control:e.jsx(gt,{}),label:"DHCP"}),e.jsx(Fe,{value:"static",control:e.jsx(gt,{}),label:"Static"})]})]}),b==="static"&&e.jsxs($e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx($e,{size:6,children:e.jsx(ge,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:D("ip")})}),e.jsx($e,{size:6,children:e.jsx(ge,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:D("subnet")})}),e.jsx($e,{size:6,children:e.jsx(ge,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:D("gateway")})}),e.jsx($e,{size:6,children:e.jsx(ge,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:D("dns")})})]})]}),e.jsxs(Le,{children:[e.jsx(ie,{onClick:p,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:j,children:"Save"})]})]})},Hn=({open:i,onClose:m,onSave:c})=>{const[n,l]=r.useState(""),[b,g]=r.useState(""),t=R=>{l(R.target.value)},x=R=>{g(R.target.value)},D=n.length>0&&n===b,p=()=>{m()},j=()=>{D&&(c(n),m())},V=()=>{c(""),m()};return e.jsxs(Me,{open:i,onClose:(R,P)=>{P==="backdropClick"||P==="escapeKeyDown"||m()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(ke,{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(Ie,{dividers:!0,children:e.jsx(qt,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs($e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx($e,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:n,onChange:t})}),e.jsx($e,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:b,onChange:x,error:b!==""&&n!==b,helperText:b!==""&&n!==b?"Passwords do not match":""})})]})})}),e.jsxs(Le,{children:[e.jsx(ie,{onClick:p,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:j,disabled:!D,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:V,children:"Reset"})]})]})};function On(){const{online:i,addListener:m,removeListener:c,sendMessage:n,getUniqueId:l}=r.useContext(ve),[b,g]=r.useState(null),[t,x]=r.useState(null),D=r.useRef(l());return r.useEffect(()=>{const p=j=>{j.src==="Matterbridge"&&j.dst==="Frontend"&&(j.method==="refresh_required"&&j.response.changed==="settings"&&(s&&console.log(`Settings received refresh_required: changed=${j.response.changed} and sending /api/settings request`),n({id:D.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),j.method==="/api/settings"&&(s&&console.log("Settings received /api/settings:",j.response),g(j.response.matterbridgeInformation),x(j.response.systemInformation)))};return m(p,D.current),s&&console.log("Settings added WebSocket listener"),()=>{c(p),s&&console.log("Settings removed WebSocket listener")}},[m,c,n]),r.useEffect(()=>{i&&(s&&console.log("Settings received online"),n({id:D.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),b?(s&&console.log("Settings rendering..."),i?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Vn,{matterbridgeInfo:b,systemInfo:t}),e.jsx(En,{matterbridgeInfo:b}),e.jsx(An,{matterbridgeInfo:b})]})}):e.jsx(Re,{})):null}function Vn({matterbridgeInfo:i,systemInfo:m}){const{sendMessage:c,getUniqueId:n}=r.useContext(ve),[l,b]=r.useState("bridge"),[g,t]=r.useState("Info"),[x,D]=r.useState(!1),[p,j]=r.useState("dark"),[V,R]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[P,_]=r.useState(localStorage.getItem("homePageMode")??"devices"),[f,X]=r.useState(localStorage.getItem("virtualMode")??"outlet"),y=r.useRef(n()),[w,I]=r.useState(!1),H=()=>I(!1),F=U=>{s&&console.log("handleSaveNetConfig called with config:",U),c({id:y.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:U})},[E,v]=r.useState(!1),a=()=>v(!1),o=U=>{s&&console.log("handleSaveChangePassword called with password:",U),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:U}})};r.useEffect(()=>{i&&(b(i.bridgeMode==="bridge"?"bridge":"childbridge"),t(i.loggerLevel.charAt(0).toUpperCase()+i.loggerLevel.slice(1)),D(i.fileLogger),X(i.virtualMode))},[i]),r.useEffect(()=>{const U=localStorage.getItem("frontendTheme");U&&j(U)},[]);const d=U=>{s&&console.log("handleChangeBridgeMode called with value:",U.target.value),b(U.target.value),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:U.target.value}})},u=U=>{s&&console.log("handleChangeMbLoggerLevel called with value:",U.target.value),t(U.target.value),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:U.target.value}})},L=U=>{s&&console.log("handleLogOnFileMbChange called with value:",U.target.checked),D(U.target.checked),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:U.target.checked}})},pe=U=>{const oe=U.target.value;s&&console.log("handleChangeTheme called with value:",oe),j(oe),localStorage.setItem("frontendTheme",oe),document.body.setAttribute("frontend-theme",oe)},te=U=>{const oe=U.target.checked;s&&console.log("handleChangeHomePagePlugins called with value:",oe),R(oe),localStorage.setItem("homePagePlugins",oe?"true":"false")},Y=U=>{const oe=U.target.value;s&&console.log("handleChangeHomePageMode called with value:",oe),_(oe),localStorage.setItem("homePageMode",oe)},xe=U=>{const oe=U.target.value;s&&console.log("handleChangeVirtualMode called with value:",oe),X(oe),localStorage.setItem("virtualMode",oe),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:oe}})};return!i||!m?null:e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Rn,{open:w,ip:m.ipv4Address,onClose:H,onSave:F}),e.jsx(Hn,{open:E,onClose:a,onSave:o}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(zt,{row:!0,name:"mode-buttons-group",value:l,onChange:d,children:[e.jsx(Fe,{value:"bridge",control:e.jsx(gt,{}),label:"Bridge",disabled:i.readOnly===!0}),e.jsx(Fe,{value:"childbridge",control:e.jsx(gt,{}),label:"Childbridge",disabled:i.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:g,onChange:u,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:x,onChange:L,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:p,onChange:pe,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(we,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Te,{checked:V,onChange:te,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:P,onChange:Y,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(we,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:f,onChange:xe,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:()=>v(!0),children:"Change password"})}),i.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>I(!0),children:"Configure IP"})})]})})]})}function En({matterbridgeInfo:i}){const{sendMessage:m,getUniqueId:c}=r.useContext(ve),[n,l]=r.useState("Info"),[b,g]=r.useState(!1),[t,x]=r.useState(""),[D,p]=r.useState(""),[j,V]=r.useState(""),[R,P]=r.useState(""),[_,f]=r.useState(""),[X,y]=r.useState(""),w=r.useRef(c());r.useEffect(()=>{i&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][i.matterLoggerLevel]),g(i.matterFileLogger),x(i.matterMdnsInterface||""),p(i.matterIpv4Address||""),V(i.matterIpv6Address||""),P(i.matterPort?i.matterPort.toString():""),f(i.matterDiscriminator?i.matterDiscriminator.toString():""),y(i.matterPasscode?i.matterPasscode.toString():""))},[i]);const I=u=>{s&&console.log("handleChangeMjLoggerLevel called with value:",u.target.value),l(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:u.target.value}})},H=u=>{s&&console.log("handleLogOnFileMjChange called with value:",u.target.checked),g(u.target.checked),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:u.target.checked}})},F=u=>{s&&console.log("handleChangeMdnsInterface called with value:",u.target.value),x(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:u.target.value}})},E=u=>{s&&console.log("handleChangeIpv4Address called with value:",u.target.value),p(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:u.target.value}})},v=u=>{s&&console.log("handleChangeIpv6Address called with value:",u.target.value),V(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:u.target.value}})},a=u=>{s&&console.log("handleChangeMatterPort called with value:",u.target.value),P(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:u.target.value}})},o=u=>{s&&console.log("handleChangeMatterDiscriminator called with value:",u.target.value),f(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:u.target.value}})},d=u=>{s&&console.log("handleChangemMatterPasscode called with value:",u.target.value),y(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:u.target.value}})};return i?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:I,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:b,onChange:H,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(ge,{value:t,onChange:F,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(ge,{value:D,onChange:E,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(ge,{value:j,onChange:v,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(ge,{value:R,onChange:a,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(ge,{value:_,onChange:o,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(ge,{value:X,onChange:d,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function An({matterbridgeInfo:i}){return i?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Oe,{value:i.matterbridgeVersion,label:"Current Version"}),e.jsx(Oe,{value:i.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Oe,{value:i.homeDirectory,label:"Home Directory"}),e.jsx(Oe,{value:i.rootDirectory,label:"Root Directory"}),e.jsx(Oe,{value:i.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Oe,{value:i.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Oe,{value:i.globalModulesDirectory,label:"Global Module Directory"})]})})]}):null}function Oe({value:i,label:m}){return e.jsx(ge,{focused:!0,value:i,size:"small",label:m,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}const _n=r.memo(On);function qn(){const{online:i,sendMessage:m,addListener:c,removeListener:n,getUniqueId:l}=r.useContext(ve),{showSnackbarMessage:b,showInstallProgress:g,addInstallProgress:t}=r.useContext(Be),[x,D]=r.useState(null),[p,j]=r.useState([]),[V,R]=r.useState([]),[P,_]=r.useState(null),[f,X]=r.useState({cpuUsage:0}),[y,w]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[I,H]=r.useState({systemUptime:"",processUptime:""}),F=r.useRef(l());return console.log("Test uniqueId:",F),r.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const E=v=>{if(v.method==="restart_required")console.log("Test received restart_required"),b("Restart required",0);else if(v.method==="refresh_required")console.log(`Test received refresh_required: changed=${v.response.changed} and sending api requests`),b("Refresh required",0),m({id:F.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),m({id:F.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),m({id:F.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(v.method==="memory_update")console.log("Test received memory_update",v),w(v.response);else if(v.method==="cpu_update")console.log("Test received cpu_update",v),X(v.response);else if(v.method==="uptime_update")console.log("Test received uptime_update",v),H(v.response);else if(v.method==="/api/settings"&&v.response)console.log("Test received /api/settings:",v.response),b("Test received /api/settings",0),D(v.response);else if(v.method==="/api/plugins"&&v.response)console.log(`Test received ${v.response.length} plugins:`,v.response),b("Test received /api/plugins",0),j(v.response);else if(v.method==="/api/devices"&&v.response){console.log(`Test received ${v.response.length} devices:`,v.response),b("Test received /api/devices",0),R(v.response);for(const a of v.response)console.log("Test sending /api/clusters for device:",a.pluginName,a.name,a.endpoint),m({id:F.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:a.pluginName,endpoint:a.endpoint||0}})}else v.method==="/api/clusters"&&v.response&&(console.log(`Test received ${v.response.clusters.length} clusters for device ${v.response.deviceName} endpoint ${v.response.id}:${v.response.number}:`,v),b(`Test received /api/clusters for ${v.response.plugin}::${v.response.deviceName}`,0),_(v.response))};return c(E,F.current),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(E),console.log("Test useEffect WebSocketMessage unmounted")}},[c,n,m,b]),r.useEffect(()=>(console.log("Test useEffect online mounting"),i&&console.log("Test useEffect online received online"),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[i,m,b]),console.log("Test rendering..."),i?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"}),e.jsx(ie,{variant:"contained",onClick:()=>{g("example-package"),t("Starting installation...");for(const E of["Downloading package...","Extracting files...","Installing dependencies..."])t(E);for(let E=0;E<=500;E+=1)t(`Installing dependency package-dep${E}...`);t("Finalizing installation..."),t("Installation completed successfully.")},children:"Install"})]})}):e.jsx(Re,{})}const zn=r.memo(qn);function Un(i,m){s&&console.log("getCssVariable:",i,"defaultValue",m);const c=getComputedStyle(document.body).getPropertyValue(i).trim();return c||console.error("getCssVariable: undefined",c),c||m}function Bn(i){return Zr({palette:{primary:{main:i},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}let s=!1;const Qn=()=>{s=!s};function Kn({setLoggedIn:i}){const[m,c]=r.useState(""),[n,l]=r.useState(""),b={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)"},t={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},x=async p=>{try{const j=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:p})});if(j.ok){const{valid:V}=await j.json();V?i(!0):p!==""&&l("Incorrect password!")}else console.error("Failed to log in:",j.statusText)}catch(j){console.error("Failed to log in:",j)}},D=p=>{p.preventDefault(),x(m)};return x(""),e.jsx("div",{style:b,children:e.jsxs("form",{onSubmit:D,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:m,onChange:p=>c(p.target.value),style:t,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:n&&e.jsx("p",{style:{color:"red"},children:n})})]})})}function Jn(){const[i,m]=r.useState(!1);s&&console.log("Setting frontend theme");const c=localStorage.getItem("frontendTheme");s&&console.log("Saved theme:",c),c?document.body.setAttribute("frontend-theme",c):document.body.setAttribute("frontend-theme","dark");const n=Un("--primary-color","#1976d2");s&&console.log("Primary color from CSS:",n);const l=Bn(n),b=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return s&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${b}"`)),i?e.jsx(eo,{theme:l,children:e.jsx(cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ho,{children:e.jsx(Oo,{children:e.jsx(nr,{basename:b,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Eo,{}),e.jsxs(ir,{children:[e.jsx(Ve,{path:"/",element:e.jsx(pn,{})}),e.jsx(Ve,{path:"/devices",element:e.jsx(Ln,{})}),e.jsx(Ve,{path:"/log",element:e.jsx(Tn,{})}),e.jsx(Ve,{path:"/settings",element:e.jsx(_n,{})}),e.jsx(Ve,{path:"/test",element:e.jsx(zn,{})}),e.jsx(Ve,{path:"*",element:e.jsx(sr,{to:"/"})})]})]})})})})})}):e.jsx(Kn,{setLoggedIn:m})}ar.createRoot(document.getElementById("root")).render(e.jsx(lr.StrictMode,{children:e.jsx(Jn,{})}));
|