matterbridge 3.2.8-dev-20250920-1a6178d → 3.2.8
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/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 +228 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +429 -38
- package/dist/frontend.js.map +1 -0
- package/dist/frontendTypes.d.ts +572 -0
- package/dist/frontendTypes.d.ts.map +1 -0
- package/dist/frontendTypes.js +51 -3
- 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 +442 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +775 -50
- 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 +1515 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1373 -55
- 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 +380 -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 +190 -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 +172 -11
- 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 +33 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +68 -0
- 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 +1 -1
- package/frontend/build/index.html +12 -12
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
|
@@ -20,4 +20,4 @@ import{B as e,y as o,S as lt,I as Xt,U as xr,V as br,X as Xe,Y as vr,Z as yr}fro
|
|
|
20
20
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
|
-
*/var we=(r=>(r[r.Log=0]="Log",r[r.RefreshRequired=1]="RefreshRequired",r[r.RestartRequired=2]="RestartRequired",r[r.RestartNotRequired=3]="RestartNotRequired",r[r.CpuUpdate=4]="CpuUpdate",r[r.MemoryUpdate=5]="MemoryUpdate",r[r.UptimeUpdate=6]="UptimeUpdate",r[r.Snackbar=7]="Snackbar",r[r.UpdateRequired=8]="UpdateRequired",r[r.StateUpdate=9]="StateUpdate",r[r.CloseSnackbar=10]="CloseSnackbar",r[r.ShellySysUpdate=100]="ShellySysUpdate",r[r.ShellyMainUpdate=101]="ShellyMainUpdate",r))(we||{});function fe(r){return r.id>=0&&r.id<=101}function Ve(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function zo({open:r,title:c,message:a,onConfirm:i,onCancel:l}){const g=t=>{s&&console.log("Confirmed"),t.preventDefault(),i()},b=t=>{s&&console.log("Canceled"),t.preventDefault(),l()};return e.jsxs(De,{open:r,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Pe,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:a})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ne,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ne,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ht=[],nt=o.createContext(null);function qo({children:r}){const{enqueueSnackbar:c,closeSnackbar:a}=jr(),i=o.useCallback(f=>{s&&console.log(`UiProvider closeSnackbarMessage: message ${f}`);const k=ht.findIndex(R=>R.message===f);k!==-1&&(a(ht[k].key),ht.splice(k,1),s&&console.log(`UiProvider closeSnackbarMessage: message ${f} removed from persistMessages`))},[a]),l=o.useCallback((f,k,R)=>{s&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${k}`);const C=c(f,{variant:"default",autoHideDuration:k==null||k>0?(k??5)*1e3:null,persist:k===0,content:m=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Sr,{severity:R??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>a(m),action:e.jsx(J,{size:"small",onClick:()=>a(m),sx:{color:"#fff"},children:e.jsx(wr,{fontSize:"small"})}),children:f},m)},m)});k===0&&(s&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${k} - persist key ${C}`),ht.push({message:f,key:C}))},[c,a]),[g,b]=o.useState(!1),[t,d]=o.useState(""),[y,W]=o.useState(""),[h,L]=o.useState(""),V=o.useRef(null),M=o.useRef(null),O=()=>{s&&console.log(`UiProvider handle confirm action ${h}`),b(!1),V.current&&V.current(h)},u=()=>{s&&console.log(`UiProvider handle cancel action ${h}`),b(!1),M.current&&M.current(h)},z=o.useCallback((f,k,R,C,m)=>{s&&console.log(`UiProvider showConfirmCancelDialog for command ${R}`),d(f),W(k),L(R),V.current=C,M.current=m,b(!0)},[]),v=o.useMemo(()=>({showSnackbarMessage:l,closeSnackbarMessage:i,closeSnackbar:a,showConfirmCancelDialog:z}),[l,i,a,z]);return e.jsxs(nt.Provider,{value:v,children:[e.jsx(zo,{open:g,title:t,message:y,onConfirm:O,onCancel:u}),r]})}const ir=o.createContext(null),be=o.createContext(null);function Bo({children:r}){const[c,a]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,l]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[g,b]=o.useState([]),[t,d]=o.useState(1e3),[y,W]=o.useState(!0),[h,L]=o.useState(!1),{showSnackbarMessage:V,closeSnackbarMessage:M,closeSnackbar:O}=o.useContext(nt),u=o.useRef([]),z=o.useRef(null),v=o.useRef(1),f=o.useRef(Math.floor(Math.random()*999e3)+1e3),k=o.useRef(null),R=o.useRef(null),C=o.useRef(null),m=o.useRef(c),H=o.useRef(i),j=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),x=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),w=100,q=60,de=50,xe=300;o.useEffect(()=>{m.current=c},[c]),o.useEffect(()=>{H.current=i},[i]);const S=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),p=o.useCallback(N=>{if(z.current&&z.current.readyState===WebSocket.OPEN)try{N.id===void 0&&(N.id=f.current);const n=JSON.stringify(N);z.current.send(n),s&&console.log("WebSocket sent message:",N)}catch(n){s&&console.error(`WebSocket error sending message: ${n}`)}else s&&console.error("WebSocket message not sent, WebSocket not connected:",N)},[]),E=o.useCallback((N,n)=>{const T=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${N}</span>`;b(_=>[..._,T+' <span style="color: var(--main-log-color);">'+n+"</span>"])},[]),I=o.useCallback((N,n)=>{a(N),l(n),E("WebSocket",`Filtering by log level "${N}" and log search "${n}"`)},[E]),Y=o.useCallback(N=>{s&&console.log("WebSocket addListener:",N),u.current=[...u.current,N],s&&console.log("WebSocket addListener total listeners:",u.current.length)},[]),me=o.useCallback(N=>{s&&console.log("WebSocket removeListener:",N),u.current=u.current.filter(n=>n!==N),s&&console.log("WebSocket removeListener total listeners:",u.current.length)},[]),Me=o.useCallback(()=>{j===""||j===null||j===void 0||(E("WebSocket",`Connecting to WebSocket: ${j}`),z.current=new WebSocket(j),z.current.onmessage=N=>{h||L(!0);try{const n=JSON.parse(N.data);if(n.id===void 0)return;if(n.error&&s&&console.error("WebSocket error message:",n),n.id===f.current&&n.src==="Matterbridge"&&n.dst==="Frontend"&&n.response==="pong"){s&&console.log("WebSocket pong response message:",n,"listeners:",u.current.length),R.current&&clearTimeout(R.current),u.current.forEach(_=>_(n));return}if(n.id===we.RefreshRequired){s&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.RestartRequired){s&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.RestartNotRequired){s&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.CpuUpdate){s&&console.log("WebSocket WS_ID_CPU_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.MemoryUpdate){s&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.UptimeUpdate){s&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.Snackbar&&n.params&&n.params.message){s&&console.log("WebSocket WS_ID_SNACKBAR message:",n,"listeners:",u.current.length),V(n.params.message,n.params.timeout,n.params.severity);return}else if(n.id===we.CloseSnackbar&&n.params&&n.params.message){s&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",n,"listeners:",u.current.length),M(n.params.message);return}else if(n.id===we.ShellySysUpdate){s&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.ShellyMainUpdate){s&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id!==we.Log){s&&console.log("WebSocket message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}if(!n.params||!n.params.level||!n.params.time||!n.params.name||!n.params.message||["debug","info","notice","warn","error","fatal"].includes(n.params.level)&&(m.current==="info"&&n.params.level==="debug"||m.current==="notice"&&(n.params.level==="debug"||n.params.level==="info")||m.current==="warn"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice")||m.current==="error"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice"||n.params.level==="warn")||m.current==="fatal"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice"||n.params.level==="warn"||n.params.level==="error"))||H.current!=="*"&&H.current!==""&&!n.params.message.toLowerCase().includes(H.current.toLowerCase())&&!n.params.name.toLowerCase().includes(H.current.toLowerCase())||n.params.name==="Commissioning"&&n.params.message.includes("is uncommissioned"))return;b(_=>{const ae=`<span style="color: #505050;">[${n.params?.time}]</span>`,ce=ve=>{switch(ve?.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"lightblue"}},B=ve=>{switch(ve?.toLowerCase()){case"warn":return"black";default:return"white"}},ge=`${`<span style="background-color: ${ce(n.params?.level)}; color: ${B(n.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${n.params?.level}</span>`} ${ae} <span style="color: #09516d;">[${n.params?.name}]</span> <span style="color: var(--main-log-color);">${n.params?.message}</span>`,oe=[..._,ge];return oe.length>t?oe.slice(t/10):oe})}catch(n){console.error(`WebSocketUse error parsing message: ${n}`)}},z.current.onopen=()=>{s&&console.log(`WebSocket: Connected to WebSocket: ${j}`),E("WebSocket",`Connected to WebSocket: ${j}`),L(!0),O(),v.current=1,C.current=setTimeout(()=>{k.current=setInterval(()=>{p({id:f.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{s&&console.error(`WebSocketUse: No pong response received from WebSocket: ${j}`),E("WebSocket",`No pong response received from WebSocket: ${j}`),L(!1)},1e3*de)},1e3*q)},1e3*xe)},z.current.onclose=()=>{s&&console.error(`WebSocket: Disconnected from WebSocket ${x?"with Ingress":""}: ${j}`),E("WebSocket",`Disconnected from WebSocket: ${j}`),L(!1),O(),C.current&&clearTimeout(C.current),R.current&&clearTimeout(R.current),k.current&&clearInterval(k.current),E("WebSocket",`Reconnecting (attempt ${v.current} of ${w}) to WebSocket${x?" (Ingress)":""}: ${j}`),x?setTimeout(U,5e3):v.current===1?U():v.current<w?setTimeout(U,1e3*v.current):E("WebSocket",`Reconnect attempts exceeded limit of ${w} retries, refresh the page to reconnect to: ${j}`),v.current=v.current+1},z.current.onerror=N=>{s&&console.error(`WebSocket: WebSocket error connecting to ${j}:`,N),E("WebSocket",`WebSocket error connecting to ${j}`)})},[j]),U=o.useCallback(()=>{s&&console.log(`WebSocket attemptReconnect ${v.current}/${w} to:`,j),Me()},[Me]);o.useEffect(()=>(Me(),()=>{z.current&&z.current.readyState===WebSocket.OPEN&&z.current.close()}),[Me]);const D=o.useMemo(()=>({messages:g,maxMessages:t,autoScroll:y,setMessages:b,setLogFilters:I,setMaxMessages:d,setAutoScroll:W}),[g,b,I]),P=o.useMemo(()=>({maxMessages:t,autoScroll:y,logFilterLevel:c,logFilterSearch:i,setMessages:b,setLogFilters:I,setMaxMessages:d,setAutoScroll:W,online:h,retry:v.current,getUniqueId:S,addListener:Y,removeListener:me,sendMessage:p,logMessage:E}),[t,y,b,I,d,W,h,v.current,Y,me,p,E]);return e.jsx(ir.Provider,{value:D,children:e.jsx(be.Provider,{value:P,children:r})})}function Jo(){const{showSnackbarMessage:r,showConfirmCancelDialog:c}=o.useContext(nt),{online:a,sendMessage:i,logMessage:l,addListener:g,removeListener:b,getUniqueId:t}=o.useContext(be),[d,y]=o.useState(!1),[W,h]=o.useState(!1),[L,V]=o.useState(!1),[M,O]=o.useState(!1),[u,z]=o.useState(null),v=o.useRef(t()),[f,k]=o.useState(null),[R,C]=o.useState(null),[m,H]=o.useState(null),[j,x]=o.useState(null),[w,q]=o.useState(null),de=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},S=()=>{u?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},p=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},E=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},I=()=>{i({id:v.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},Y=()=>{i({id:v.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},me=()=>{i({id:v.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Me=()=>{s&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),i({id:v.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},U=()=>{s&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),i({id:v.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{s&&console.log("Header: handleShellyCreateSystemLog"),i({id:v.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{s&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},N=()=>{u?.matterbridgeInformation.restartMode===""?i({id:v.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):i({id:v.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},n=()=>{i({id:v.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{i({id:v.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},_=()=>{i({id:v.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{i({id:v.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=Q=>{k(Q.currentTarget)},B=Q=>{s&&console.log("Header: handleMenuClose",Q),k(null),Q==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),r("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),r("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),r("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(l("Matterbridge","Loading matter log..."),r("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),r("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),r("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),r("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),r("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),r("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(l("Matterbridge","Downloading backup..."),r("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?I():Q==="updatedev"?Y():Q==="updatecheck"?me():Q==="shelly-sys-update"?Me():Q==="shelly-main-update"?U():Q==="shelly-create-system-log"?D():Q==="shelly-download-system-log"?P():Q==="softreset"?_():Q==="hardreset"?ae():Q==="restart"?N():Q==="shutdown"?n():Q==="reboot"?T():Q==="create-backup"?i({id:v.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?i({id:v.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?i({id:v.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&i({id:v.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=Q=>{s&&console.log("Header: handleMenuCloseCancel:",Q),k(null)},ge=Q=>{C(Q.currentTarget)},oe=()=>{C(null)},ve=Q=>{H(Q.currentTarget)},ie=()=>{H(null)},he=Q=>{x(Q.currentTarget)},X=()=>{x(null)},ue=Q=>{q(Q.currentTarget)},ye=()=>{q(null)},Ge=()=>{ei(),s&&console.log("Matterbridge logo clicked: debug is now",s)};return o.useEffect(()=>{const Q=ee=>{ee.src==="Matterbridge"&&ee.dst==="Frontend"&&(Ve(ee)&&ee.method==="/api/settings"&&ee.id===v.current&&(s&&console.log("Header received settings:",ee.response),z(ee.response),y(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),h(ee.response.matterbridgeInformation.fixedRestartRequired),V(ee.response.matterbridgeInformation.updateRequired)),fe(ee)&&ee.method==="refresh_required"&&ee.params.changed==="settings"&&(s&&console.log(`Header received refresh_required: changed=${ee.params.changed} and sending /api/settings request`),i({id:v.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),fe(ee)&&ee.method==="restart_required"&&(s&&console.log(`Header received restart_required with fixed: ${ee.params.fixed}`),y(!0),ee.params.fixed===!0&&h(!0)),fe(ee)&&ee.method==="restart_not_required"&&(s&&console.log("Header received restart_not_required"),y(!1)),fe(ee)&&ee.method==="update_required"&&(s&&console.log("Header received update_required"),V(!0)),fe(ee)&&ee.method==="update_required_dev"&&(s&&console.log("Header received update_required_dev"),O(!0)),fe(ee)&&ee.id===we.ShellySysUpdate&&(s&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),z(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellySysUpdate:ee.params.available},systemInformation:We.systemInformation}:null)),fe(ee)&&ee.id===we.ShellyMainUpdate&&(s&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),z(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellyMainUpdate:ee.params.available},systemInformation:We.systemInformation}:null)))};return g(Q),s&&console.log(`Header added WebSocket listener id ${v.current}`),()=>{b(Q),s&&console.log("Header removed WebSocket listener")}},[g,b,i,r]),o.useEffect(()=>{a&&(s&&console.log("Header sending /api/settings requests"),i({id:v.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),s&&console.log("Header rendering..."),!a||!u?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ge}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(lt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!u.matterbridgeInformation.readOnly&&L&&e.jsx($,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:I,children:["Update to v.",u.matterbridgeInformation.matterbridgeLatestVersion]})}),!u.matterbridgeInformation.readOnly&&M&&e.jsx($,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:Y,children:["Update to new dev v.",u.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!u.matterbridgeInformation.readOnly&&e.jsx($,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:S,children:["v.",u.matterbridgeInformation.matterbridgeVersion]})}),u.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),u.matterbridgeInformation.bridgeMode!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.bridgeMode})}):null,u.matterbridgeInformation.restartMode!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.restartMode})}):null,u.matterbridgeInformation.profile&&u.matterbridgeInformation.profile!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:p})}):null,u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Give a star to Matterbridge",children:e.jsx(J,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:E,children:e.jsx(Mr,{})})}):null,u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Sponsor Matterbridge",children:e.jsx(J,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:de,children:e.jsx(Zt,{})})}):null,e.jsx($,{title:"Matterbridge help",children:e.jsx(J,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(kr,{})})}),e.jsx($,{title:"Matterbridge changelog",children:e.jsx(J,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:S,children:e.jsx(er,{})})}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsx($,{title:"Update matterbridge to latest version",children:e.jsx(J,{style:{color:L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:I,children:e.jsx(_e,{})})}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellySysUpdate&&e.jsx($,{title:"Shelly system update",children:e.jsx(J,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Me,children:e.jsx(_e,{})})}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellyMainUpdate&&e.jsx($,{title:"Shelly software update",children:e.jsx(J,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(_e,{})})}),e.jsx($,{title:"Restart matterbridge",children:e.jsx(J,{style:{color:d||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:N,children:e.jsx(yt,{})})}),u.matterbridgeInformation.restartMode===""?e.jsx($,{title:"Shut down matterbridge",children:e.jsx(J,{style:{color:d||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:n,children:e.jsx(qe,{})})}):null,e.jsx($,{title:"Download, backup and more",children:e.jsx(J,{onClick:ce,children:e.jsx(Ir,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(rt,{id:"command-menu",anchorEl:f,keepMounted:!0,open:!!f,onClose:()=>B(""),children:[u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("updatedev"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("updatecheck"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellySysUpdate&&e.jsxs(F,{onClick:()=>B("shelly-sys-update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellyMainUpdate&&e.jsxs(F,{onClick:()=>B("shelly-main-update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>B("restart"),children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation.restartMode===""?e.jsxs(F,{onClick:()=>B("shutdown"),children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",B,le)},children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ve,children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-view",anchorEl:m,keepMounted:!0,open:!!m,onClose:ie,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("view-mblog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("view-mjlog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("view-shellylog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:he,children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-download",anchorEl:j,keepMounted:!0,open:!!j,onClose:X,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("download-mbstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-pluginstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-pluginconfig"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mblog"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mjstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mjlog"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("shelly-create-system-log"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("shelly-download-system-log"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ge,children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-backup",anchorEl:R,keepMounted:!0,open:!!R,onClose:oe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("create-backup"),oe()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-backup"),oe()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ue,children:[e.jsx(K,{children:e.jsx(Dr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-reset",anchorEl:w,keepMounted:!0,open:!!w,onClose:ye,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{ye(),c("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{ye(),c("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>{ye(),c("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{ye(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{ye(),c("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Qo=o.memo(Jo),Go=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(s&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(s&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Ko(){const{messages:r,autoScroll:c}=o.useContext(ir),[a,i]=o.useState(!1),l=o.useRef(null),g=o.useMemo(()=>Go(),[]),b=d=>i(!0),t=d=>i(!1);return o.useEffect(()=>{s&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${a}`),c&&!a&&!g&&l.current?.scrollIntoView({behavior:"smooth"})},[r,a,c,g]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:b,onMouseLeave:t,children:[r.map((d,y)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:d}},y)),e.jsx("div",{ref:l})]})})}const ar=o.memo(Ko);function Qe(){const{retry:r}=o.useContext(be),c=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:r<100?e.jsxs(e.Fragment,{children:[e.jsx(Nr,{style:{color:"var(--primary-color)"}}),e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:["Reconnecting to Matterbridge ","(attempt "+r+")","..."]})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:["Unable to connect to Matterbridge after multiple attempts.",e.jsx("br",{}),"Please check your network connection.",e.jsx("br",{}),e.jsx(ne,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Yo({value:r,maxChars:c}){let a=r;if(r.length>c&&c>3){const i=c-3,l=r.substring(0,Math.ceil(i/2)),g=r.substring(r.length-Math.floor(i/2),r.length);a=`${l} … ${g}`}return r!==a?e.jsx($,{title:r,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:a})}):e.jsx("span",{children:a})}function Xo({systemInfo:r,compact:c}){const[a,i]=o.useState(r),{sendMessage:l,addListener:g,removeListener:b}=o.useContext(be);if(s&&console.log("SystemInfoTable:",a,"compact:",c),r&&c&&a.totalMemory&&a.freeMemory){const t=a.totalMemory,d=a.freeMemory;a.freeMemory=`${d} / ${t}`,a.totalMemory=""}if(r&&c&&a.heapTotal&&a.heapUsed){const t=a.heapTotal,d=a.heapUsed;a.heapUsed=`${d} / ${t}`,a.heapTotal=""}if(r&&c&&a.osRelease&&a.osType){const t=a.osType,d=a.osRelease;a.osType=`${t} (${d})`,a.osRelease=""}if(r&&c&&a.osArch&&a.osPlatform){const t=a.osPlatform,d=a.osArch;a.osPlatform=`${t} (${d})`,a.osArch=""}return o.useEffect(()=>{const t=d=>{d.src==="Matterbridge"&&d.dst==="Frontend"&&(fe(d)&&d.method==="memory_update"&&d.params&&d.params.totalMemory&&d.params.freeMemory&&d.params.heapTotal&&d.params.heapUsed&&d.params.rss&&(s&&console.log("SystemInfoTable received memory_update",d),(a.totalMemory!==d.params?.totalMemory||a.freeMemory!==d.params?.freeMemory||a.heapTotal!==d.params?.heapTotal||a.heapUsed!==d.params?.heapUsed||a.rss!==d.params?.rss)&&i(y=>({...y,totalMemory:d.params?.totalMemory?d.params.totalMemory:"",freeMemory:d.params?.freeMemory?d.params.freeMemory:"",heapTotal:d.params?.heapTotal?d.params.heapTotal:"",heapUsed:d.params?.heapUsed?d.params.heapUsed:"",rss:d.params?.rss?d.params.rss:""}))),fe(d)&&d.method==="cpu_update"&&d.params&&d.params.cpuUsage&&(s&&console.log("SystemInfoTable received cpu_update",d),a.cpuUsage!==(d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":"")&&i(y=>({...y,cpuUsage:d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":""}))),fe(d)&&d.method==="uptime_update"&&d.params&&d.params.systemUptime&&d.params.processUptime&&(s&&console.log("SystemInfoTable received uptime_update",d),(a.systemUptime!==d.params?.systemUptime||a.processUptime!==d.params?.processUptime)&&i(y=>({...y,systemUptime:d.params?.systemUptime?d.params.systemUptime:"",processUptime:d.params?.processUptime?d.params.processUptime:""}))))};return s&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),g(t),s&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),b(t),s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[g,a.cpuUsage,a.freeMemory,a.heapTotal,a.heapUsed,a.processUptime,a.rss,a.systemUptime,a.totalMemory,b,l]),a?(s&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(a).filter(([t,d])=>d!==void 0&&d!=="").map(([t,d],y)=>e.jsxs("tr",{className:y%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:t}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Yo,{value:typeof d!="string"?d.toString():d,maxChars:25})})]},t))})})})]})):null}const Zo=o.memo(Xo),Bt={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},en=r=>{if(!r)return"";const c=r.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const a=c.slice(0,4),i=c.slice(4,7),l=c.slice(7,11);return[a,i,l].filter(Boolean).join("-")};function tn({id:r}){const{online:c,sendMessage:a,addListener:i,removeListener:l,getUniqueId:g}=o.useContext(be),[b,t]=o.useState(null),[d,y]=o.useState(null),W=o.useRef(null),h=o.useRef(g()),{showConfirmCancelDialog:L}=o.useContext(nt);o.useEffect(()=>{s&&console.log(`QRDiv received storeId update "${r}"`),r&&(s&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const v=f=>{f.src==="Matterbridge"&&f.dst==="Frontend"&&fe(f)&&f.id===we.RefreshRequired&&f.params.changed==="matter"&&f.params.matter&&(s&&console.log(`QRDiv received refresh_required: changed=${f.params.changed} for storeId "${f.params.matter.id}":`,f.params.matter),b===f.params.matter.id&&(s&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${f.params.matter.id}":`,f.params.matter),W.current&&clearTimeout(W.current),f.params.matter.advertising&&f.params.matter.advertiseTime&&f.params.matter.advertiseTime+9e5<=Date.now()&&(f.params.matter.advertising=!1),y(f.params.matter),f.params.matter.advertising&&(s&&console.log(`QRDiv setting matter advertise timeout for storeId "${f.params.matter.id}":`,f.params.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),s&&console.log(`QRDiv clearing advertising state for storeId "${b}" after 15 minutes`),y(k=>k&&{...k,advertising:!1})},f.params.matter.advertiseTime+9e5-Date.now()))))};return i(v),s&&console.log("QRDiv webSocket effect mounted"),()=>{l(v),W.current&&clearTimeout(W.current),s&&console.log("QRDiv webSocket effect unmounted")}},[b]);const V=()=>{s&&console.log(`QRDiv sent matter startCommission for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,startCommission:!0}})},M=()=>{s&&console.log(`QRDiv sent matter stopCommission for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,stopCommission:!0}})},O=()=>{s&&console.log(`QRDiv sent matter advertise for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,advertise:!0}})},u=v=>{s&&console.log(`QRDiv sent matter removeFabric for node "${d?.id}" and fabricIndex ${v}`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,removeFabric:v}})},z=async()=>{if(!d||!d.manualPairingCode)return;const v=d.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(v);else{const f=document.createElement("textarea");f.value=v,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.focus(),f.select(),document.execCommand("copy"),document.body.removeChild(f)}s&&console.log("Manual pairing code copied to clipboard")}catch(f){console.error("Failed to copy manual pairing code",f)}};return!d||!c?(s&&console.log("QRDiv rendering undefined state"),null):d.online?d.advertising&&d.qrPairingCode&&d.manualPairingCode?(s&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(J,{"aria-label":"send advertising",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})}),e.jsx(J,{"aria-label":"stop pairing",size:"small",onClick:M,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn off pairing",arrow:!0,children:e.jsx(te,{path:go,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),e.jsx(mo,{value:d.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",en(d.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx($,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(J,{"aria-label":"copy manual pairing code",size:"small",onClick:z,sx:Bt,children:e.jsx(te,{path:ho,size:.85})})})})]})]})):d.commissioned&&d.fabricInformations&&d.sessionInformations?(s&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(J,{"aria-label":"send advertising",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})}),e.jsx(J,{"aria-label":"start pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn on pairing",arrow:!0,children:e.jsx(te,{path:Ut,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),d.fabricInformations.map((v,f)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",v.fabricIndex]}),e.jsx($,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(J,{"aria-label":"remove the fabric",size:"small",onClick:()=>L("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>u(v.fabricIndex),()=>{}),sx:{...Bt,padding:"2px"},children:e.jsx(te,{path:fo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",v.rootVendorId," ",v.rootVendorName]}),v.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",v.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",d.sessionInformations?d.sessionInformations.filter(k=>k.fabric?.fabricIndex===v.fabricIndex&&k.isPeerActive===!0).length:"0"," ","subscriptions: ",d.sessionInformations?d.sessionInformations.filter(k=>k.fabric?.fabricIndex===v.fabricIndex&&k.isPeerActive===!0&&k.numberOfActiveSubscriptions>0).length:"0"]})]},f))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]})):!d.commissioned&&!d.advertising?(s&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),e.jsx(ne,{onClick:V,endIcon:e.jsx(te,{path:Ut,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]})):(s&&console.log("QRDiv rendering unknown state"),null):(s&&console.log("QRDiv rendering offline state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"red"},children:"Server offline: restart to commission"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]}))}const rn=o.memo(tn);function on(){const{logMessage:r,sendMessage:c,getUniqueId:a}=o.useContext(be),[i,l]=o.useState("matterbridge-"),[g,b]=o.useState(!1),[t,d]=o.useState(null),y=o.useRef(a()),W=f=>{f.preventDefault(),b(!0)},h=()=>{b(!1)},L=f=>{f.preventDefault(),b(!1);const k=f.dataTransfer.files[0];if(k){r("Plugins",`Installing package ${k.name}. Please wait...`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(C=>C.text()).then(C=>{r("Plugins",`Server response: ${C}`)}).catch(C=>{console.error("Error uploading plugin file:",C),r("Plugins",`Error installing package ${C}`)})}},V=f=>{const k=f.target.files&&f.target.files[0];if(k){r("Plugins",`Uploading package ${k.name}`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(C=>C.text()).then(C=>{r("Plugins",`Server response: ${C}`)}).catch(C=>{console.error("Error uploading plugin file:",C),r("Plugins",`Error uploading package ${C}`)})}},M=()=>{c({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},O=()=>{document.getElementById("file-upload")?.click()},u=()=>{c({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},z=f=>{d(f.currentTarget)},v=f=>{f!==""&&l(f),d(null)};return s&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:W,onDragLeave:h,onDrop:L,children:[e.jsx(pe,{value:i,onChange:f=>{l(f.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(J,{onClick:z,children:e.jsx(Pr,{})}),e.jsxs(rt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>v(""),children:[e.jsx(F,{onClick:()=>v("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(F,{onClick:()=>v("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(F,{onClick:()=>v("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(F,{onClick:()=>v("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(F,{onClick:()=>v("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(F,{onClick:()=>v("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(F,{onClick:()=>v("matterbridge-test"),children:"matterbridge-test"}),e.jsx(F,{onClick:()=>v("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(F,{onClick:()=>v("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx($,{title:"Install or update a plugin from npm",children:e.jsx(ne,{onClick:M,endIcon:e.jsx($e,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx($,{title:"Upload and install a plugin from a tarball",children:e.jsx(ne,{onClick:O,endIcon:e.jsx(Wr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx($,{title:"Add an installed plugin",children:e.jsx(ne,{onClick:u,endIcon:e.jsx(jt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Add"})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:V})]})}const nn=o.memo(on);function Ze({status:r,enabledText:c="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:l}){if(r===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const g=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:r?c:a??c});return i!==void 0?e.jsx($,{title:i,children:g}):g}}const et={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},tt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},an={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},sn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ee={padding:"0px",margin:"0px"},ln="5px 10px 5px 10px",ft={},Ce={},xt={},bt={};let vt=[],Jt=[];const dn=({open:r,onClose:c,plugin:a})=>{const{sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),t=o.useRef(b()),[d,y]=o.useState(a.configJson),[W,h]=o.useState(a.schemaJson),[L,V]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[M,O]=o.useState("");let u={};o.useEffect(()=>{const D=P=>{P.src==="Matterbridge"&&P.dst==="Frontend"&&(P.id===t.current&&P.method==="/api/select/devices"&&(P.response&&(vt=P.response),P.error&&console.error("ConfigPluginDialog received /api/select/devices error:",P.error)),P.id===t.current&&P.method==="/api/select/entities"&&(P.response&&(Jt=P.response),P.error&&console.error("ConfigPluginDialog received /api/select/entities error:",P.error)))};return l(D),d!==void 0&&W!==void 0&&(Object.keys(W.properties).forEach(P=>{Object.keys(W.properties[P]).forEach(N=>{N.startsWith("ui:")&&(L[P]={},L[P][N]=W.properties[P][N],delete W.properties[P][N])})}),V(L)),a.name!==void 0&&a.configJson!==void 0&&a.schemaJson!==void 0&&(y(a.configJson),h(a.schemaJson),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}})),()=>{g(D)}},[l,d,a,g,W,i,L]);const z=({formData:D})=>{u=D},v=({formData:D})=>{y(D),a.configJson=D,a.restartRequired=!0,i({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:D.name,formData:D}}),c()};function f(D){const{id:P,label:N,onKeyChange:n,onDropPropertyClick:T,disabled:_,schema:ae,children:ce,registry:B,readonly:le,required:ge}=D,{templates:oe}=B,{RemoveButton:ve}=oe.ButtonTemplates;if(!(Uo in ae))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const he=({target:X})=>n(X&&X.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${P}-key`,name:`${P}-key`,required:ge,disabled:_||le,defaultValue:N,onBlur:le?void 0:he,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:ce}),e.jsx(ve,{disabled:_||le,onClick:T(N)})]})}function k(D){const{children:P,description:N,displayLabel:n,errors:T,help:_,hidden:ae,_id:ce,_label:B,registry:le,uiSchema:ge}=D,oe=_o(ge),ve=Ao("WrapIfAdditionalTemplate",le,oe);return ae?e.jsx("div",{style:{display:"none"},children:P}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(ve,{...D,children:[n===!0&&N,P,T,_]})})}function R(D){const{description:P}=D;return P?e.jsx(se,{sx:tt,children:P}):null}function C(D){const{required:P,title:N}=D;return N?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(se,{sx:et,children:["Title ",N," ",P&&e.jsx("mark",{children:"***"})]})}):null}function m(D){const{help:P,_idSchema:N}=D;return P?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(se,{sx:an,children:P})}):null}function H(D){const{errors:P}=D;return P?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(se,{color:"error",sx:sn,children:"Please fix the following errors:"}),e.jsx(it,{children:P.map((N,n)=>e.jsxs(Tr,{children:[e.jsx(K,{children:e.jsx(Fr,{color:"error"})}),e.jsx(re,{primary:N.stack})]},n))})]}):null}function j(D){const{errors:P}=D;return P?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:P.map((N,n)=>e.jsxs(se,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",N]},n))}):null}function x(D){const{id:P,name:N,_schema:n,_uiSchema:T,value:_,options:ae,label:ce,type:B,placeholder:le,required:ge,disabled:oe,readonly:ve,autofocus:ie,onChange:he,onChangeOverride:X,onBlur:ue,onFocus:ye,_rawErrors:Ge,_hideError:Q,_registry:ee,_formContext:We}=D,He=({target:{value:je}})=>he(je===""?ae.emptyValue:je),Re=({target:je})=>ue(P,je&&je.value),ze=({target:je})=>ye(P,je&&je.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:P,name:P,label:le&&le!==""?ce:void 0,variant:"outlined",placeholder:le&&le!==""?le:ce,required:ge,disabled:oe||ve,autoFocus:ie,value:_||_===0?_:"",type:B,autoComplete:B==="password"?"current-password":N,onChange:X||He,onBlur:Re,onFocus:ze,fullWidth:!0})})}function w(D){return console.log("ArrayFieldTitleTemplate:",D),null}function q(D){return console.log("ArrayFieldDescriptionTemplate:",D),null}function de(D){return console.log("ArrayFieldItemTemplate:",D),null}function xe(D){const{canAdd:P,_className:N,_disabled:n,_formContext:T,_formData:_,_idSchema:ae,_items:ce,onAddClick:B,_rawErrors:le,_readonly:ge,_registry:oe,_required:ve,schema:ie,title:he,_uiSchema:X}=D,[ue,ye]=o.useState(!1),[Ge,Q]=o.useState(!1),[ee,We]=o.useState(!1),[He,Re]=o.useState(""),ze=A=>{Re(A.target.value)},je=()=>{ye(!ue)},Ke=()=>{Q(!Ge)},Ye=()=>{We(!ee)},Mt=A=>{ye(!1),ie.selectFrom==="serial"?ie.items.default=A.serial:ie.selectFrom==="name"&&(ie.items.default=A.name),B()},kt=A=>{Q(!1),ie.selectEntityFrom==="name"?ie.items.default=A.name:ie.selectEntityFrom==="description"&&(ie.items.default=A.description),B()},It=A=>{We(!1),ie.selectDeviceEntityFrom==="name"?ie.items.default=A.name:ie.selectDeviceEntityFrom==="description"&&(ie.items.default=A.description),B()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[he&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[he&&e.jsx(se,{sx:et,children:he}),P&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(J,{onClick:je,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ie.selectEntityFrom&&e.jsx($,{title:"Add an entity from the list",children:e.jsx(J,{onClick:Ke,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ie.selectDeviceEntityFrom&&e.jsx($,{title:"Add a device entity from the list",children:e.jsx(J,{onClick:Ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(J,{onClick:B,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),ie.description&&e.jsx(se,{sx:tt,children:ie.description}),D.items.map(A=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(J,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ee,children:e.jsx(Rt,{})}),e.jsx(J,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ht,{})}),e.jsx(J,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ee,children:e.jsx(St,{})})]},A.index)),e.jsxs(De,{open:ue,onClose:je,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:He,onChange:ze,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial.toLowerCase().includes(He.toLowerCase())||A.name.toLowerCase().includes(He.toLowerCase())).map((A,ke)=>e.jsxs(ut,{onClick:()=>Mt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ke))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:je,children:"Close"})})]}),e.jsxs(De,{open:Ge,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:He,onChange:ze,placeholder:"Enter name or description"})]}),e.jsx(it,{dense:!0,children:Jt.filter(A=>A.name.toLowerCase().includes(He.toLowerCase())||A.description.toLowerCase().includes(He.toLowerCase())).map((A,ke)=>e.jsxs(ut,{onClick:()=>kt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),A.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:Ce})}),A.icon==="matter"&&e.jsx(K,{children:e.jsx(Ot,{style:Ce})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ke))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:Ke,children:"Close"})})]}),e.jsxs(De,{open:ee,onClose:Ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",he]}),e.jsx(Pe,{children:e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial===he||A.name===he).map(A=>A.entities?.map((ke,Dt)=>e.jsxs(ut,{onClick:()=>It(ke),sx:ft,children:[ke.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),ke.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),ke.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),ke.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:Ce})}),ke.icon==="matter"&&e.jsx(K,{children:e.jsx(Ot,{style:Ce})}),e.jsx(re,{primary:ke.name,secondary:ke.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Dt)))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:Ye,children:"Close"})})]})]})}function S(D){const{onAddClick:P,schema:N,properties:n,title:T,description:_}=D,[ae,ce]=o.useState(!1),[B,le]=o.useState(""),ge=X=>{le(X.target.value)},oe=()=>{ce(!ae)},ve=X=>{ce(!1);let ue="";N.selectFrom==="serial"?ue=X.serial:N.selectFrom==="name"&&(ue=X.name),O(ue),P(N)()},ie=()=>{P(N)()},he=!N.additionalProperties;return!he&&M!==""&&n.forEach(X=>{if(X.name==="newKey"&&X.content.key==="newKey"&&X.content.props.name==="newKey"&&X.content.props.onKeyChange&&M!==""){const ue=M;O(""),X.content.props.onKeyChange(ue)}}),e.jsxs(Z,{sx:{margin:"0px",padding:he?"10px":"5px 10px 0px 10px",border:he?"none":"1px solid grey"},children:[N.title&&he&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:et,children:N.title})}),T&&!he&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(se,{sx:et,children:T}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[N.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(J,{onClick:oe,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(J,{onClick:ie,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),N.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:tt,children:N.description})}),n.map(({content:X,name:ue,hidden:ye})=>!ye&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(N.properties[ue].type)?"0px":ln,border:["object","array","boolean"].includes(N.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(N.properties[ue].type)&&e.jsx(se,{sx:et,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:X})]},ue)),e.jsxs(De,{open:ae,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:B,onChange:ge,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(X=>X.serial.toLowerCase().includes(B.toLowerCase())||X.name.toLowerCase().includes(B.toLowerCase())).map((X,ue)=>e.jsxs(ut,{onClick:()=>ve(X),sx:ft,children:[X.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),X.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),X.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),e.jsx(re,{primary:X.name,secondary:X.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ue))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:oe,children:"Close"})})]})]})}function p(D){const{uiSchema:P}=D,{submitText:N,norender:n}=Vo(P);return n?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ne,{type:"submit",variant:"contained",color:"primary",children:N}),e.jsx(ne,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function E(D){const{className:P,disabled:N,onClick:n,registry:T,style:_,uiSchema:ae,...ce}=D;return e.jsx($,{title:"Remove the item",children:e.jsx(J,{disabled:N,size:"small",color:"primary",onClick:n,children:e.jsx(St,{})})})}function I(D){const{className:P,disabled:N,onClick:n,registry:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Add an item",children:e.jsx(J,{size:"small",color:"primary",onClick:n,children:e.jsx(jt,{})})})}function Y(D){const{disabled:P,onClick:N,registry:n,style:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Move up the item",children:e.jsx(J,{size:"small",color:"primary",onClick:N,children:e.jsx(Rt,{})})})}function me(D){const{disabled:P,onClick:N,registry:n,style:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Move down the item",children:e.jsx(J,{size:"small",color:"primary",onClick:N,children:e.jsx(Ht,{})})})}function Me(D){const{id:P,name:N,value:n,schema:T,readonly:_,onChange:ae}=D,[ce,B]=o.useState(void 0),le=oe=>{B(oe&&oe!==""?oe:void 0)},ge=()=>{i({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:N,value:ce,formData:u,id:P}}),T.buttonClose===!0?c():T.buttonSave===!0&&v({formData:d})};return T.buttonText&&T.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:tt,children:T.description}),e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>ge(),children:T.buttonText})]}):T.buttonField&&T.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:tt,children:T.description}),e.jsx(pe,{id:N+"-input",name:N,label:T.textLabel,placeholder:T.textPlaceholder,onChange:oe=>le(oe.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ne,{id:N+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>ge(),children:T.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[N&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(se,{sx:et,children:N}),e.jsx(Fe,{checked:n,readOnly:_,onChange:()=>ae(!n),sx:{padding:"0px",margin:"0px"}})]}),T.description&&e.jsx(se,{sx:tt,children:T.description})]})}function U({schema:D,id:P,name:N,options:n,label:T,hideLabel:_,required:ae,disabled:ce,placeholder:B,readonly:le,value:ge,multiple:oe,autofocus:ve,onChange:ie,onBlur:he,onFocus:X,errorSchema:ue,rawErrors:ye=[],registry:Ge,uiSchema:Q,hideError:ee,formContext:We,...He}){const{enumOptions:Re,enumDisabled:ze,emptyValue:je}=n;oe=typeof oe>"u"?!1:!!oe;const Ke=oe?[]:"",Ye=typeof ge>"u"||oe&&ge.length<1||!oe&&ge===Ke,Mt=({target:{value:Oe}})=>ie(Pt(Oe,Re,je)),kt=({target:Oe})=>he(P,Pt(Oe&&Oe.value,Re,je)),It=({target:Oe})=>X(P,Pt(Oe&&Oe.value,Re,je)),A=Oo(ge,Re,oe),{InputLabelProps:ke,SelectProps:Dt,autocomplete:ur,...mr}=He,gr=!oe&&D.default===void 0;return e.jsxs(pe,{id:P,name:P,value:!Ye&&typeof A<"u"?A:Ke,required:ae,disabled:ce||le,autoFocus:ve,autoComplete:ur,placeholder:B,error:ye.length>0,onChange:Mt,onBlur:kt,onFocus:It,...mr,select:!0,InputLabelProps:{...ke,shrink:!Ye},SelectProps:{...Dt,multiple:oe},"aria-describedby":Eo(P),children:[gr&&e.jsx(F,{value:"",children:B}),Array.isArray(Re)&&Re.map(({value:Oe,label:hr},Lt)=>{const fr=Array.isArray(ze)&&ze.indexOf(Oe)!==-1;return e.jsx(F,{value:String(Lt),disabled:fr,children:hr},Lt)})]})}return!r||!W||!d?null:e.jsxs(De,{open:r,onClose:c,maxWidth:"800px",children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Pe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Ro,{schema:W,formData:d,uiSchema:L,validator:$o,templates:{FieldTemplate:k,BaseInputTemplate:x,TitleFieldTemplate:C,DescriptionFieldTemplate:R,FieldHelpTemplate:m,FieldErrorTemplate:j,ErrorListTemplate:H,WrapIfAdditionalTemplate:f,ArrayFieldTitleTemplate:w,ArrayFieldDescriptionTemplate:q,ArrayFieldItemTemplate:de,ArrayFieldTemplate:xe,ObjectFieldTemplate:S,ButtonTemplates:{SubmitButton:p,RemoveButton:E,AddButton:I,MoveUpButton:Y,MoveDownButton:me}},widgets:{CheckboxWidget:Me,SelectWidget:U},onChange:z,onSubmit:v})})]})};function sr(r){if(s&&console.log(`getQRColor (id: ${r?.id}) received matter:`,r??"undefined"),r===void 0||!r.online||!r.qrPairingCode&&!r.manualPairingCode&&!r.fabricInformations&&!r.sessionInformations)return"red";if(r.commissioned===!1&&r.qrPairingCode&&r.manualPairingCode)return"var(--primary-color)";let c=0,a=0;for(const i of r.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(c===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function cn({data:r,columns:c,columnVisibility:a}){const i=Xt.useMemo(()=>c.filter(y=>a[y.accessor]),[c,a]),{getTableProps:l,getTableBodyProps:g,headerGroups:b,rows:t,prepareRow:d}=Ue.useTable({columns:i,data:r},Ue.useSortBy);return e.jsxs("table",{...l(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:b.map(y=>e.jsx("tr",{...y.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:y.headers.map(W=>e.jsx("th",{...W.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:"default"},children:W.render("Header")}))}))}),e.jsx("tbody",{...g(),style:{border:"none",borderCollapse:"collapse"},children:t.map((y,W)=>(d(y),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...y.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:y.cells.map(h=>e.jsx("td",{...h.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:h.render("Cell")}))})))})]})}function pn({_storeId:r,setStoreId:c}){const{online:a,sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),{showConfirmCancelDialog:t}=o.useContext(nt),d=o.useRef(b()),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState([]),[O,u]=o.useState(!1),[z,v]=o.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),f=[{Header:"Name",accessor:"name",Cell:({row:n})=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>S(n.original),children:n.original.name})})},{Header:"Description",accessor:"description",Cell:({row:n})=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>S(n.original),children:n.original.description})})},{Header:"Version",accessor:"version",Cell:({row:n})=>e.jsxs(e.Fragment,{children:[n.original.latestVersion!==void 0&&n.original.latestVersion!==n.original.version&&h&&!h.readOnly&&e.jsx($,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>x(n.original),children:["Update to v.",n.original.latestVersion]})}),n.original.version.includes("-dev-")&&n.original.devVersion!==void 0&&n.original.devVersion!==n.original.version&&h&&!h.readOnly&&e.jsx($,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>w(n.original),children:["Update to new dev v.",n.original.devVersion.split("-dev-")[0]]})}),e.jsx($,{title:"Plugin version",children:e.jsx("span",{children:n.original.version})})]})},{Header:"Author",accessor:"author",Cell:({row:n})=>e.jsx(e.Fragment,{children:n.original.author?n.original.author.replace("https://github.com/",""):"Unknown"})},{Header:"Type",accessor:"type",Cell:({row:n})=>e.jsx(e.Fragment,{children:n.original.type?n.original.type.replace("Platform",""):"Unknown"})},{Header:"Devices",accessor:"registeredDevices"},{Header:"Actions",accessor:"actions",Cell:({row:n})=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[h&&h.bridgeMode==="childbridge"&&!n.original.error&&n.original.enabled&&e.jsx($,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:sr(n.original.matter)},onClick:()=>{n.original?.matter?.id&&c(n.original?.matter?.id)},size:"small",children:e.jsx(tr,{})})}),h&&h.bridgeMode==="childbridge"&&!n.original.error&&n.original.enabled&&e.jsx($,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>de(n.original),size:"small",children:e.jsx(yt,{})})}),e.jsx($,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{disabled:n.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(n.original),size:"small",children:e.jsx(Je,{})})}),h&&!h.readOnly&&e.jsx($,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",n.original)},size:"small",children:e.jsx(St,{})})}),n.original.enabled?e.jsx($,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",n.original)},size:"small",children:e.jsx(Lr,{})})}):e.jsx(e.Fragment,{}),n.original.enabled?e.jsx(e.Fragment,{}):e.jsx($,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>xe(n.original),size:"small",children:e.jsx(Hr,{})})}),e.jsx($,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>E(n.original),size:"small",children:e.jsx(Rr,{})})}),e.jsx($,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(n.original),size:"small",children:e.jsx($r,{})})}),h&&!h.readOnly&&e.jsx($,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>p(n.original),size:"small",children:e.jsx(Zt,{})})})]})},{Header:"Status",accessor:"status",Cell:({row:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",gap:"5px"},children:n.original.error?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:n.original.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:n.original.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:n.original.loaded&&n.original.started&&n.original.configured?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:n.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{status:n.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ze,{status:n.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ze,{status:n.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const n=T=>{T.src==="Matterbridge"&&T.dst==="Frontend"&&(fe(T)&&T.method==="refresh_required"&&T.params.changed==="plugins"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and sending /api/plugins request`),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),fe(T)&&T.method==="refresh_required"&&T.params.changed==="matter"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and setting matter id ${T.params.matter?.id}`),M(_=>{const ae=_.findIndex(B=>B.matter?.id===T.params.matter?.id);if(ae<0)return s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and matter id ${T.params.matter?.id} not found`),_;s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} set matter id ${T.params.matter?.id}`);const ce=[..._];return ce[ae]={...ce[ae],matter:T.params.matter},ce})),fe(T)&&T.method==="refresh_required"&&T.params.changed==="settings"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and sending /api/settings request`),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Ve(T)&&T.id===d.current&&T.method==="/api/settings"&&(s&&console.log(`HomePlugins (id: ${T.id}) received settings:`,T.response),W(T.response.systemInformation),L(T.response.matterbridgeInformation)),Ve(T)&&T.id===d.current&&T.method==="/api/plugins"&&(s&&console.log(`HomePlugins (id: ${T.id}) received ${T.response.length} plugins:`,T.response),M(T.response)))};return l(n),s&&console.log("HomePlugins added WebSocket listener id:",d.current),()=>{g(n),s&&console.log("HomePlugins removed WebSocket listener")}},[l,g,i]),o.useEffect(()=>{a&&(s&&console.log("HomePlugins sending api requests"),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),o.useEffect(()=>{const n=localStorage.getItem("homePluginsColumnVisibility");n&&v(JSON.parse(n))},[]);const k=()=>{u(!O)},R=n=>{v(T=>{const _={...T,[n]:!T[n]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(_)),_})},C=o.useRef(null),m=(n,T,_,ae)=>{s&&console.log(`handleActionWithConfirmCancel ${_} ${ae.name}`),C.current=ae,t(n,T,_,H,j)},H=n=>{s&&console.log(`handleConfirm action confirmed ${n} ${C.current?.name}`),n==="remove"&&C.current?q(C.current):n==="disable"&&C.current&&xe(C.current),C.current=null},j=n=>{s&&console.log(`handleCancel action canceled ${n} ${C.current?.name}`),C.current=null},x=n=>{s&&console.log("handleUpdatePlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n.name,restart:!1}})},w=n=>{s&&console.log("handleUpdateDevPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n.name+"@dev",restart:!1}})},q=n=>{s&&console.log("handleRemovePlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})},de=n=>{s&&console.log("handleRestartPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})},xe=n=>{s&&console.log("handleEnableDisablePlugin plugin:",n.name,"enabled:",n.enabled),n.enabled===!0?(n.enabled=!1,i({id:d.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})):(n.enabled=!0,i({id:d.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}}))},S=n=>{s&&console.log(`handleHomepagePlugin plugin: ${n.name} homepage: ${n.homepage}`),n.homepage&&window.open(n.homepage,"_blank")},p=n=>{s&&console.log("handleSponsorPlugin plugin:",n.name,"funding:",n.funding),n.funding&&window.open(n.funding,"_blank")},E=n=>{s&&console.log("handleHelpPlugin plugin:",n.name,"help:",n.help),n.help&&window.open(n.help,"_blank")},I=n=>{s&&console.log("handleChangelogPlugin plugin:",n.name,"changelog:",n.changelog),n.changelog&&window.open(n.changelog,"_blank")},[Y,me]=o.useState({}),[Me,U]=o.useState(!1),D=n=>{s&&console.log("handleConfigPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:n.name}}),i({id:d.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:n.name}}),me(n),P()},P=()=>{U(!0)},N=()=>{U(!1)};return s&&console.log("HomePlugins rendering..."),a?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[e.jsx(dn,{open:Me,onClose:N,plugin:Y}),e.jsxs(De,{open:O,onClose:k,children:[e.jsx(Ne,{children:"Configure Plugins Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:f.map(n=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["description","actions","status"].includes(n.accessor),checked:z[n.accessor]??!1,onChange:()=>R(n.accessor)}),label:n.Header},n.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:k,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Plugins"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:k,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(cn,{data:V,columns:f,columnVisibility:z})})]}):e.jsx(Qe,{})}const un=o.memo(pn),mn=r=>`${r.pluginName}::${r.serial}`;function gn({data:r,columns:c,columnVisibility:a}){const i=o.useMemo(()=>{const h=localStorage.getItem("homeDevicesColumnsSortBy");return h?JSON.parse(h):[{id:"name",desc:!1}]},[c]),l=o.useMemo(()=>c.filter(h=>a[h.accessor]),[a,c]),{getTableProps:g,getTableBodyProps:b,headerGroups:t,rows:d,prepareRow:y,state:{sortBy:W}}=Ue.useTable({columns:l,data:r,getRowId:mn,initialState:{sortBy:i}},Ue.useSortBy);return o.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(W))},[W]),e.jsxs("table",{...g(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:t.map(h=>e.jsx("tr",{...h.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:h.headers.map(L=>e.jsxs("th",{...L.getHeaderProps(L.noSort?void 0:L.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:[L.render("Header"),!L.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:L.isSorted?L.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Ft,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...b(),style:{border:"none",borderCollapse:"collapse"},children:d.map((h,L)=>(y(h),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...h.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:h.cells.map(V=>e.jsx("td",{...V.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:V.render("Cell")}))})))})]})}function hn({storeId:r,setStoreId:c}){const{online:a,sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),[t,d]=o.useState(!1),[y,W]=o.useState(!0),[h,L]=o.useState(null),[V,M]=o.useState([]),[O,u]=o.useState([]),[z,v]=o.useState([]),[f,k]=o.useState([]),[R,C]=o.useState(!1),[m,H]=o.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),j=o.useRef(b()),x=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:S})=>S.original.reachable===!0?"Online":S.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(S,p)=>{const E=S.original.reachable===!0?1:S.original.reachable===!1?0:-1,I=p.original.reachable===!0?1:p.original.reachable===!1?0:-1;return E-I}},{Header:"Power",accessor:"powerSource",Cell:({row:S})=>S.original.powerSource==="ac"||S.original.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):S.original.powerSource==="ok"?e.jsx(Ct,{fontSize:"small",sx:{color:"green"}}):S.original.powerSource==="warning"?e.jsx(Ct,{fontSize:"small",sx:{color:"yellow"}}):S.original.powerSource==="critical"?e.jsx(Ct,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:S})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[S.original.matter!==void 0?e.jsx($,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{onClick:()=>c(r===S.original.matter.id?h.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:S.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:sr(S.original.matter)},children:e.jsx(tr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),S.original.configUrl?e.jsx($,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{onClick:()=>window.open(S.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),S.original.selected!==void 0?e.jsx($,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Fe,{checked:S.original.selected,onChange:p=>xe(p,S.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],w=o.useCallback(S=>{S.selected=void 0;const p=V.find(Y=>Y.name===S.pluginName);if(!p)return console.error(`HomeDevices isSelected: plugin ${S.pluginName} not found for device ${S.deviceName} `),S.selected;const E=p.schemaJson?.properties?.whiteList?.selectFrom;let I=p.configJson?.postfix;return I===""&&(I=void 0),p.hasWhiteList===!0&&p.hasBlackList===!0&&E&&(S.selected=!0,E==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!0),E==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!1),E==="serial"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!1),E==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(S.name)&&(S.selected=!0),E==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(S.name)&&(S.selected=!1),E==="name"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(S.name)&&(S.selected=!1)),S.selected},[V]);o.useEffect(()=>{const S=p=>{if(p.src==="Matterbridge"&&p.dst==="Frontend"){if(p.method==="refresh_required"&&p.params.changed!=="matter"&&(s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and sending /api/plugins request`),i({id:j.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),p.method==="refresh_required"&&p.params.changed==="matter"&&(s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and setting matter id ${p.params.matter?.id}`),k(E=>{const I=E.findIndex(me=>me.name.replaceAll(" ","")===p.params.matter?.id);if(I<0)return s&&console.debug(`HomeDevices: matter id ${p.params.matter?.id} not found`),E;const Y=[...E];return Y[I]={...Y[I],matter:p.params.matter},s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and set matter id ${p.params.matter?.id}`),Y})),p.method==="restart_required"&&(s&&console.log("HomeDevices received restart_required"),d(!0)),p.method==="restart_not_required"&&(s&&console.log("HomeDevices received restart_not_required"),d(!1)),p.method==="state_update"&&p.params.plugin&&p.params.serialNumber&&p.params.cluster.includes("BasicInformationServer")&&p.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${p.params.plugin} serial ${p.params.serialNumber} value ${p.params.value}`),u(E=>E.map(I=>I.pluginName===p.params.plugin&&I.serial===p.params.serialNumber?{...I,reachable:p.params.value}:I))),p.id===j.current&&p.method==="/api/settings"&&(s&&console.log(`HomeDevices (id: ${p.id}) received settings:`,p.response),L(p.response),d(p.response.matterbridgeInformation.restartRequired||p.response.matterbridgeInformation.fixedRestartRequired)),p.id===j.current&&p.method==="/api/plugins"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} plugins:`,p.response),p.response)){let E=!0;for(const I of p.response)I.enabled===!0&&(I.loaded!==!0||I.started!==!0||I.error===!0)&&(E=!1);if(!E)return;s&&console.log("HomeDevices reset plugins, devices and selectDevices"),W(!1),M(p.response),u([]),v([]),i({id:j.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),s&&console.log("HomeDevices sent /api/devices");for(const I of p.response)I.enabled===!0&&I.loaded===!0&&I.started===!0&&I.error!==!0&&(i({id:j.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:I.name}}),s&&console.log(`HomeDevices sent /api/select/devices for plugin: ${I.name}`))}if(p.id===j.current&&p.method==="/api/devices"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} devices:`,p.response),p.response)){for(const E of p.response)E.selected=w(E);u(p.response)}p.id===j.current&&p.method==="/api/select/devices"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} selectDevices for plugin ${p.response&&p.response.length>0?p.response[0].pluginName:"without select devices"}:`,p.response),p.response&&p.response.length>0&&v(E=>{const I=E.filter(me=>me.pluginName!==p.response[0].pluginName),Y=p.response.map(me=>({...me,selected:w(me)}));return[...I,...Y]}))}};return l(S),s&&console.log(`HomeDevices added WebSocket listener id ${j.current}`),()=>{g(S),s&&console.log("HomeDevices removed WebSocket listener")}},[V,l,g,i,w]),o.useEffect(()=>{if(O.length===0&&z.length===0){k([]);return}console.log(`HomeDevices mixing devices (${O.length}) and selectDevices (${z.length})`);const S=[];for(const p of O)S.push(p);for(const p of z)O.find(E=>E.pluginName===p.pluginName&&E.serial.includes(p.serial))||S.push(p);S.length>0&&(k(S),console.log(`HomeDevices mixed ${S.length} devices and selectDevices`))},[V,O,z,k]),o.useEffect(()=>{a&&(s&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:j.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:j.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),o.useEffect(()=>{const S=localStorage.getItem("homeDevicesColumnVisibility");if(S){const p=JSON.parse(S);p.powerSource===void 0&&(p.powerSource=!0),H(p),s&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const q=S=>{H(p=>{const E={...p,[S]:!p[S]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(E)),s&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(E),E),E})},de=()=>{C(!R)},xe=(S,p)=>{console.log(`handleCheckboxChange: checkbox changed to ${S.target.checked} for device ${p.name} serial ${p.serial}`),k(E=>{const I=E.findIndex(me=>me.pluginName===p.pluginName&&me.serial===p.serial);if(I<0)return console.error(`handleCheckboxChange: device not found ${p.name} serial ${p.serial} id ${p.id}`),E;const Y=[...E];return Y[I]={...Y[I],selected:S.target.checked},Y}),S.target.checked?i({id:j.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}}):i({id:j.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}})};return s&&console.log("HomeDevices rendering..."),a?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs(De,{open:R,onClose:de,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:x.map(S=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["name","actions"].includes(S.accessor),checked:m[S.accessor],onChange:()=>q(S.accessor)}),label:S.Header},S.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:de,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:de,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(gn,{data:f,columns:x,columnVisibility:m})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[y&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!y&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",O.length.toString(),"/",f.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Qe,{})}const fn=o.memo(hn);function xn(){const[r,c]=o.useState(null),[a,i]=o.useState(null),[l,g]=o.useState([]),[b]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,d]=o.useState(localStorage.getItem("homePageMode")??"devices"),[y,W]=o.useState(""),[h,L]=o.useState(!1),[V,M]=o.useState(!1),[O,u]=o.useState(null),{addListener:z,removeListener:v,online:f,sendMessage:k,logFilterLevel:R,logFilterSearch:C,autoScroll:m,getUniqueId:H}=o.useContext(be),j=o.useRef(H());return o.useEffect(()=>{const x=w=>{w.src==="Matterbridge"&&w.dst==="Frontend"&&(fe(w)&&w.method==="refresh_required"&&w.params.changed==="settings"&&(s&&console.log(`Home received refresh_required: changed=${w.params.changed} and sending /api/settings request`),k({id:j.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Ve(w)&&w.method==="/api/settings"&&w.id===j.current&&(s&&console.log("Home received settings:",w.response),c(w.response.systemInformation),i(w.response.matterbridgeInformation),w.response.matterbridgeInformation.bridgeMode==="bridge"&&(O||u("Matterbridge")),w.response.matterbridgeInformation.bridgeMode==="childbridge"&&l.length>0&&O===null&&!O&&l.length>0&&l[0].matter?.id&&u(l[0].matter.id),w.response.matterbridgeInformation.matterbridgeVersion&&W(`https://github.com/Luligu/matterbridge/blob/${w.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&w.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",w.response.matterbridgeInformation.frontendVersion):w.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&w.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",w.response.matterbridgeInformation.frontendVersion),M(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",w.response.matterbridgeInformation.matterbridgeVersion):w.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",w.response.matterbridgeInformation.matterbridgeVersion),L(!0)),w.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),d("devices")))),Ve(w)&&w.method==="/api/plugins"&&w.id===j.current&&(s&&console.log(`Home received plugins (${a?.bridgeMode}):`,w.response),g(w.response),a?.bridgeMode==="childbridge"&&w.response.length>0&&!O&&w.response.length>0&&w.response[0].matter?.id&&u(w.response[0].matter.id)))};return z(x),s&&console.log(`Home added WebSocket listener id ${j.current}`),()=>{v(x),s&&console.log("Home removed WebSocket listener")}},[z,v,k,a,l,O]),o.useEffect(()=>{f&&(s&&console.log("Home received online"),k({id:j.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:j.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[f,k]),s&&console.log("Home rendering..."),!f||!r||!a?e.jsx(Qe,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(rn,{id:O}),e.jsx(Zo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[V&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ne,{onClick:()=>window.location.reload(),endIcon:e.jsx(Or,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),h&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ne,{onClick:()=>window.open(y,"_blank"),endIcon:e.jsx(er,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ne,{onClick:()=>window.location.reload(),endIcon:e.jsx(Er,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),b&&!a.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(nn,{})]}),b&&e.jsx(un,{storeId:O,setStoreId:u}),t==="devices"&&e.jsx(fn,{storeId:O,setStoreId:u}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',R,'" and search "',C,'" Scroll: ',m?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(ar,{})})]})]})]})}const bn=o.memo(xn),Qt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},vn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},yn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Gt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},jn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Cn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Sn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},wn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Mn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Wt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},kn=[256,257,268,269],In=[266,267],Dn=[259,260,261,271,272],Nn=[256,257,268,269,266,267,259,260,261];function G({icon:r,iconColor:c,cluster:a,value:i,unit:l,prefix:g}){return s&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${l}"`),g=g??!1,e.jsxs(Z,{sx:Qt,children:[r&&o.cloneElement(r,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...vn,color:c??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Qt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&g===!0&&e.jsx(se,{sx:Gt,children:l},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(se,{sx:yn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),l&&g===!1&&e.jsx(se,{sx:Gt,children:l},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function Pn({device:r,endpoint:c,id:a,deviceType:i,clusters:l}){const g=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let b="";return s&&console.log(`Device "${r.name}" endpoint "${c}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>b=`${t.attributeLocalValue} mV`),Nn.includes(i)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>b=`Level ${t.attributeValue}`),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>b=`Position ${t.attributeValue/100}%`),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>b=`Heat ${t.attributeValue/100}°C `),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>b=b+`Cool ${t.attributeValue/100}°C`),i===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>b=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>b=`${t.attributeLocalValue/1e3} V, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>b=b+`${t.attributeLocalValue/1e3} A, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>b=b+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:t.attributeLocalValue===!0?e.jsx(at,{}):e.jsx(Vr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(G,{icon:e.jsx(Ct,{}),cluster:t,value:t.attributeValue/2,unit:"%"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(G,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),kn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),In.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Dn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:"Oven"})),i===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Ar,{}),cluster:t,value:"Fridge"})),i===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(G,{icon:e.jsx(te,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(G,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(G,{icon:t.attributeValue==="1"?e.jsx(zr,{}):e.jsx(qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(G,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),i===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(G,{icon:e.jsx(te,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(G,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:g[t.attributeLocalValue??0]})),i===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:t.attributeValue==="true"?e.jsx(ro,{}):e.jsx(oo,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(G,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(no,{}):e.jsx(io,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(ao,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeValue/1e4)),unit:"lx"})),i===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(G,{icon:e.jsx(so,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:jn,children:e.jsx(se,{sx:Cn,children:b})}),e.jsx(Z,{sx:Sn,children:e.jsx(se,{sx:wn,children:r.name})}),e.jsxs(Z,{sx:Mn,children:[s&&e.jsx(se,{sx:Wt,children:c}),e.jsx(se,{sx:Wt,children:a}),s&&e.jsxs(se,{sx:Wt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Wn({filter:r}){const{online:c,sendMessage:a,addListener:i,removeListener:l,getUniqueId:g}=o.useContext(be),[b,t]=o.useState({}),[d,y]=o.useState([]),[W,h]=o.useState([]),[L,V]=o.useState({}),[M,O]=o.useState({}),[u,z]=o.useState({}),[v,f]=o.useState(W),k=o.useRef(g());return o.useEffect(()=>{const R=C=>{if(C.src==="Matterbridge"&&C.dst==="Frontend"){if(C.method==="refresh_required"&&(s&&console.log(`DevicesIcons received refresh_required: changed=${C.params.changed} and sending api requests`),a({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),C.method==="/api/settings"&&C.response&&(s&&console.log("DevicesIcons received settings:",C.response),t(C.response)),C.method==="/api/plugins"&&C.response&&(s&&console.log("DevicesIcons received plugins:",C.response),y(C.response)),C.method==="/api/devices"&&C.response){s&&console.log(`DevicesIcons received ${C.response.length} devices:`,C.response),h(C.response);for(let m of C.response)s&&console.log("DevicesIcons sending /api/clusters"),a({id:k.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:m.pluginName,endpoint:m.endpoint}})}if(C.method==="/api/clusters"&&C.response){if(console.log(`DevicesIcons received for device "${C.response.deviceName}" serial "${C.response.serialNumber}" deviceType ${C.response.deviceTypes.join(" ")} clusters (${C.response.length}):`,C.response),C.response.length===0)return;const m=C.response.serialNumber;L[m]=[],M[m]=C.response.deviceTypes,u[m]=[];for(let H of C.response.clusters)L[m].find(j=>j.endpoint===H.endpoint)||L[m].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(H.clusterName)&&u[m].push(H);V({...L}),O({...M}),z({...u}),s&&console.log(`DevicesIcons endpoints for "${m}":`,L[m]),s&&console.log(`DevicesIcons deviceTypes for "${m}":`,M[m]),s&&console.log(`DevicesIcons clusters for "${m}":`,u[m])}}};return i(R),s&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(R),s&&console.log("DevicesIcons useEffect webSocket unmounted")}},[i,l,a]),o.useEffect(()=>(s&&console.log("DevicesIcons useEffect online mounting"),c&&(s&&console.log("DevicesIcons useEffect online sending api requests"),a({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),s&&console.log("DevicesIcons useEffect online mounted"),()=>{s&&console.log("DevicesIcons useEffect online unmounted")}),[c,a]),o.useEffect(()=>{if(r===""){f(W);return}const R=W.filter(C=>C.name.toLowerCase().includes(r)||C.serial.toLowerCase().includes(r));f(R)},[W,r]),s&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:v.map(R=>L[R.serial]&&L[R.serial].map(C=>C.deviceTypes.map(m=>e.jsx(Pn,{device:R,endpoint:C.endpoint,id:C.id,deviceType:m,clusters:u[R.serial].filter(H=>H.endpoint===C.endpoint)}))))})}const Tn=o.memo(Wn),lr=[{Header:"Plugin name",accessor:"pluginName"},{Header:"Device type",accessor:"type"},{Header:"Endpoint",accessor:"endpoint"},{Header:"Name",accessor:"name"},{Header:"Serial number",accessor:"serial"},{Header:"Unique ID",accessor:"uniqueId"},{Header:"Url",accessor:"configUrl"},{Header:"Config",accessor:"configButton",noSort:!0,Cell:({row:r})=>r.original.configUrl?e.jsx(J,{onClick:()=>window.open(r.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],dr=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:r})=>Array.isArray(r)?r.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):r},{Header:"Cluster Name",accessor:"clusterName"},{Header:"Cluster ID",accessor:"clusterId"},{Header:"Attribute Name",accessor:"attributeName"},{Header:"Attribute ID",accessor:"attributeId"},{Header:"Attribute Value",accessor:"attributeValue",Cell:({value:r})=>e.jsx($,{title:r,componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r})})}],Fn=r=>`${r.pluginName}::${r.uniqueId}`,Ln=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Hn({data:r,columnVisibility:c,setPlugin:a,setEndpoint:i,setDeviceName:l}){const[g,b]=o.useState(null),t=o.useMemo(()=>lr.filter(M=>c[M.accessor]),[c]),{getTableProps:d,getTableBodyProps:y,headerGroups:W,rows:h,prepareRow:L}=Ue.useTable({columns:t,data:r,getRowId:Fn},Ue.useSortBy),V=M=>{if(M.id===g){b(null),a(null),i(null),l(null),s&&console.log("Device unclicked:",M.id,"selectedDeviceIndex:",g);return}b(M.id),a(M.original.pluginName),i(M.original.endpoint),l(M.original.name),s&&console.log("Device clicked:",M.id,"selectedDeviceIndex:",g,"pluginName:",M.original.pluginName,"endpoint:",M.original.endpoint)};return e.jsxs("table",{...d(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:W.map(M=>e.jsx("tr",{...M.getHeaderGroupProps(),children:M.headers.map(O=>e.jsxs("th",{...O.getHeaderProps(O.noSort?void 0:O.getSortByToggleProps()),children:[O.render("Header"),!O.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:O.isSorted?O.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Ft,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...y(),children:h.map((M,O)=>(L(M),e.jsx("tr",{className:O%2===0?"table-content-even":"table-content-odd",...M.getRowProps(),onClick:()=>V(M),style:{backgroundColor:g===M.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:M.cells.map(u=>e.jsx("td",{...u.getCellProps(),children:u.render("Cell")}))})))})]})}function Rn({data:r,columnVisibility:c}){const a=o.useMemo(()=>dr.filter(d=>c[d.accessor]),[c]),{getTableProps:i,getTableBodyProps:l,headerGroups:g,rows:b,prepareRow:t}=Ue.useTable({columns:a,data:r,getRowId:Ln},Ue.useSortBy);return e.jsxs("table",{...i(),style:{margin:"-1px"},children:[e.jsx("thead",{children:g.map(d=>e.jsx("tr",{...d.getHeaderGroupProps(),children:d.headers.map(y=>e.jsx("th",{...y.getHeaderProps(),children:y.render("Header")}))}))}),e.jsx("tbody",{...l(),children:b.map((d,y)=>(t(d),e.jsx("tr",{className:y%2===0?"table-content-even":"table-content-odd",...d.getRowProps(),children:d.cells.map(W=>e.jsx("td",{...W.getCellProps(),children:W.render("Cell")}))})))})]})}function $n(){const{online:r,sendMessage:c,addListener:a,removeListener:i,getUniqueId:l}=o.useContext(be),[g,b]=o.useState([]),[t,d]=o.useState([]),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState(null),[O,u]=o.useState(0),[z,v]=o.useState(!1),[f,k]=o.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[R,C]=o.useState(!1),[m,H]=o.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[j,x]=o.useState(""),[w,q]=o.useState(g),[de,xe]=o.useState("icon"),S=o.useRef(l());o.useEffect(()=>{const U=D=>{if(s&&console.log("Devices received WebSocket Message:",D),D.src==="Matterbridge"&&D.dst==="Frontend"&&(D.method==="refresh_required"&&D.params.changed==="devices"&&(s&&console.log(`Devices received refresh_required: changed=${D.params.changed} and sending /api/devices request`),c({id:S.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),D.method==="/api/devices"&&(s&&console.log(`Devices received ${D.response.length} devices:`,D.response),b(D.response)),D.method==="/api/clusters")){console.log(`Devices received ${D.response.length} clusters:`,D.response),d(D.response.clusters);const P={};for(const N of D.response.clusters)s&&console.log("Cluster:",N.endpoint),P[N.endpoint]?P[N.endpoint]++:P[N.endpoint]=1;u(Object.keys(P).length)}};return a(U),s&&console.log("Devices added WebSocket listener"),()=>{i(U),s&&console.log("Devices removed WebSocket listener")}},[a,i,c]),o.useEffect(()=>{r&&(s&&console.log("Devices sending api requests"),c({id:S.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:S.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:S.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,c]),o.useEffect(()=>{y&&h&&(s&&console.log("Devices sending /api/clusters"),c({id:S.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:y,endpoint:h}}))},[y,h,c]);const p=()=>{v(!z)},E=U=>{k(D=>{const P={...D,[U]:!D[U]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(P)),P})};o.useEffect(()=>{const U=localStorage.getItem("devicesColumnVisibility");U&&k(JSON.parse(U))},[]);const I=()=>{C(!R)},Y=U=>{H(D=>{const P={...D,[U]:!D[U]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(P)),P})};o.useEffect(()=>{const U=localStorage.getItem("clustersColumnVisibility");U&&H(JSON.parse(U))},[]);const me=U=>{x(U.target.value.toLowerCase()),localStorage.setItem("devicesFilter",U.target.value.toLowerCase())},Me=U=>{xe(U),localStorage.setItem("devicesViewMode",U)};return o.useEffect(()=>{if(j===""){q(g);return}const U=g.filter(D=>D.name.toLowerCase().includes(j)||D.serial.toLowerCase().includes(j));q(U)},[g,j]),o.useEffect(()=>{const U=localStorage.getItem("devicesFilter");U&&x(U)},[]),o.useEffect(()=>{const U=localStorage.getItem("devicesViewMode");U&&xe(U)},[]),s&&console.log("Devices rendering..."),r?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:j,onChange:me,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(J,{onClick:()=>Me("table"),"aria-label":"Table View",disabled:de==="table",children:e.jsx($,{title:"Table View",children:e.jsx(lo,{style:{color:de==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(J,{onClick:()=>Me("icon"),"aria-label":"Icon View",disabled:de==="icon",children:e.jsx($,{title:"Icon View (beta)",children:e.jsx(co,{style:{color:de==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(De,{open:z,onClose:p,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:lr.map(U=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["pluginName","name","configButton"].includes(U.accessor),checked:f[U.accessor],onChange:()=>E(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:p,children:"Close"})})]}),de==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${y&&h?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Registered devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:p,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Hn,{data:w,columnVisibility:f,setPlugin:W,setEndpoint:L,setDeviceName:M})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total devices: ",w.length.toString()]})})]}),e.jsxs(De,{open:R,onClose:I,children:[e.jsx(Ne,{children:"Configure Clusters Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:dr.map(U=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["clusterName","attributeName","attributeValue"].includes(U.accessor),checked:m[U.accessor],onChange:()=>Y(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:I,children:"Close"})})]}),de==="table"&&y&&h&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsxs("div",{className:"MbfWindowHeaderText",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[e.jsxs("p",{style:{margin:"0px",padding:"0px"},children:['Clusters for device "',V,'" on endpoint ',h]}),e.jsx(J,{onClick:I,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Rn,{data:t,columnVisibility:m})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total child endpoints: ",O-1]})})]}),de==="icon"&&e.jsx(Tn,{filter:j,devices:w})]}):e.jsx(Qe,{})}const On=o.memo($n);function En(){const[r,c]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[a,i]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[l,g]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:b,setLogFilters:t,online:d,setAutoScroll:y}=o.useContext(be),W=M=>{c(M.target.value),t(M.target.value,a),localStorage.setItem("logFilterLevel",M.target.value),s&&console.log("handleChangeLevel called with value:",M.target.value)},h=M=>{i(M.target.value),t(r,M.target.value),localStorage.setItem("logFilterSearch",M.target.value),s&&console.log("handleChangeSearch called with value:",M.target.value)},L=M=>{g(M.target.checked),y(M.target.checked),localStorage.setItem("logAutoScroll",M.target.value?"true":"false"),s&&console.log("handleAutoScrollChange called with value:",M.target.checked)},V=()=>{s&&console.log("handleClearLogsClick called"),b([])};return s&&console.log("Logs rendering..."),d?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(_t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(ot,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:W,children:[e.jsx(F,{value:"debug",children:"Debug"}),e.jsx(F,{value:"info",children:"Info"}),e.jsx(F,{value:"notice",children:"Notice"}),e.jsx(F,{value:"warn",children:"Warn"}),e.jsx(F,{value:"error",children:"Error"}),e.jsx(F,{value:"fatal",children:"Fatal"})]}),e.jsx(_t,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:a,onChange:h,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Te,{control:e.jsx(Fe,{checked:l,onChange:L}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx($,{title:"Clear the logs",children:e.jsx(ne,{onClick:V,endIcon:e.jsx(St,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(ar,{})})]}):e.jsx(Qe,{})}const Vn=({open:r,ip:c,onClose:a,onSave:i})=>{const l=c?c.split(".").slice(0,3).join(".")+".1":"",[g,b]=o.useState("dhcp"),[t,d]=o.useState({ip:c??"",subnet:"255.255.255.0",gateway:l,dns:l}),y=L=>V=>{d({...t,[L]:V.target.value})},W=()=>{a()},h=()=>{const L=g==="static"?{type:g,...t}:{type:g};i(L),a()};return e.jsxs(De,{open:r,onClose:(L,V)=>{V==="backdropClick"||V==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Pe,{dividers:!0,children:[e.jsxs(or,{component:"fieldset",fullWidth:!0,children:[e.jsx(Ie,{component:"legend",children:"Select IP Configuration"}),e.jsxs(nr,{row:!0,value:g,onChange:L=>b(L.target.value),children:[e.jsx(Te,{value:"dhcp",control:e.jsx(wt,{}),label:"DHCP"}),e.jsx(Te,{value:"static",control:e.jsx(wt,{}),label:"Static"})]})]}),g==="static"&&e.jsxs(Ae,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:y("ip")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:y("subnet")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:y("gateway")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:y("dns")})})]})]}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:W,children:"Cancel"}),e.jsx(ne,{variant:"contained",onClick:h,children:"Save"})]})]})},_n=({open:r,onClose:c,onSave:a})=>{const[i,l]=o.useState(""),[g,b]=o.useState(""),t=V=>{l(V.target.value)},d=V=>{b(V.target.value)},y=i.length>0&&i===g,W=()=>{c()},h=()=>{y&&(a(i),c())},L=()=>{a(""),c()};return e.jsxs(De,{open:r,onClose:(V,M)=>{M==="backdropClick"||M==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Pe,{dividers:!0,children:e.jsx(or,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Ae,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ae,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:t})}),e.jsx(Ae,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:g,onChange:d,error:g!==""&&i!==g,helperText:g!==""&&i!==g?"Passwords do not match":""})})]})})}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:W,children:"Cancel"}),e.jsx(ne,{variant:"contained",onClick:h,disabled:!y,children:"Change"}),e.jsx(ne,{variant:"contained",onClick:L,children:"Reset"})]})]})};function An(){const{online:r,addListener:c,removeListener:a,sendMessage:i,getUniqueId:l}=o.useContext(be),[g,b]=o.useState(null),[t,d]=o.useState(null),y=o.useRef(l());return o.useEffect(()=>{const W=h=>{h.src==="Matterbridge"&&h.dst==="Frontend"&&(h.method==="refresh_required"&&h.params.changed==="settings"&&(s&&console.log(`Settings received refresh_required: changed=${h.params.changed} and sending /api/settings request`),i({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),h.method==="/api/settings"&&(s&&console.log("Settings received /api/settings:",h.response),b(h.response.matterbridgeInformation),d(h.response.systemInformation)))};return c(W),s&&console.log("Settings added WebSocket listener"),()=>{a(W),s&&console.log("Settings removed WebSocket listener")}},[c,a,i]),o.useEffect(()=>{r&&(s&&console.log("Settings received online"),i({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,i]),g?(s&&console.log("Settings rendering..."),r?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Un,{matterbridgeInfo:g,systemInfo:t}),e.jsx(zn,{matterbridgeInfo:g}),e.jsx(qn,{matterbridgeInfo:g})]})}):e.jsx(Qe,{})):null}function Un({matterbridgeInfo:r,systemInfo:c}){const{sendMessage:a,getUniqueId:i}=o.useContext(be),[l,g]=o.useState("bridge"),[b,t]=o.useState("Info"),[d,y]=o.useState(!1),[W,h]=o.useState("dark"),[L,V]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[M,O]=o.useState(localStorage.getItem("homePageMode")??"logs"),[u,z]=o.useState(localStorage.getItem("virtualMode")??"outlet"),v=o.useRef(i()),[f,k]=o.useState(!1),R=()=>k(!1),C=I=>{s&&console.log("handleSaveNetConfig called with config:",I),a({id:v.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:I})},[m,H]=o.useState(!1),j=()=>H(!1),x=I=>{s&&console.log("handleSaveChangePassword called with password:",I),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:I}})};o.useEffect(()=>{r.bridgeMode!==void 0&&(g(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),y(r.fileLogger),z(r.virtualMode))},[r]),o.useEffect(()=>{const I=localStorage.getItem("frontendTheme");I&&h(I)},[]);const w=I=>{s&&console.log("handleChangeBridgeMode called with value:",I.target.value),g(I.target.value),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:I.target.value}})},q=I=>{s&&console.log("handleChangeMbLoggerLevel called with value:",I.target.value),t(I.target.value),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:I.target.value}})},de=I=>{s&&console.log("handleLogOnFileMbChange called with value:",I.target.checked),y(I.target.checked),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:I.target.checked}})},xe=I=>{const Y=I.target.value;s&&console.log("handleChangeTheme called with value:",Y),h(Y),localStorage.setItem("frontendTheme",Y),document.body.setAttribute("frontend-theme",Y)},S=I=>{const Y=I.target.checked;s&&console.log("handleChangeHomePagePlugins called with value:",Y),V(Y),localStorage.setItem("homePagePlugins",Y?"true":"false")},p=I=>{const Y=I.target.value;s&&console.log("handleChangeHomePageMode called with value:",Y),O(Y),localStorage.setItem("homePageMode",Y)},E=I=>{const Y=I.target.value;s&&console.log("handleChangeVirtualMode called with value:",Y),z(Y),localStorage.setItem("virtualMode",Y),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:Y}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Vn,{open:f,ip:c.ipv4Address,onClose:R,onSave:C}),e.jsx(_n,{open:m,onClose:j,onSave:x}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(nr,{row:!0,name:"mode-buttons-group",value:l,onChange:w,children:[e.jsx(Te,{value:"bridge",control:e.jsx(wt,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(Te,{value:"childbridge",control:e.jsx(wt,{}),label:"Childbridge",disabled:r.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:b,onChange:q,children:[e.jsx(F,{value:"Debug",children:"Debug"}),e.jsx(F,{value:"Info",children:"Info"}),e.jsx(F,{value:"Notice",children:"Notice"}),e.jsx(F,{value:"Warn",children:"Warn"}),e.jsx(F,{value:"Error",children:"Error"}),e.jsx(F,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(Fe,{checked:d,onChange:de,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:W,onChange:xe,children:[e.jsx(F,{value:"classic",children:"Classic"}),e.jsx(F,{value:"light",children:"Light"}),e.jsx(F,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Fe,{checked:L,onChange:S,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:M,onChange:p,children:[e.jsx(F,{value:"logs",children:"Logs"}),e.jsx(F,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:u,onChange:E,children:[e.jsx(F,{value:"disabled",children:"Disabled"}),e.jsx(F,{value:"outlet",children:"Outlet"}),e.jsx(F,{value:"light",children:"Light"}),e.jsx(F,{value:"switch",children:"Switch"}),e.jsx(F,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Change password"})}),r.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>k(!0),children:"Configure IP"})})]})})]})}function zn({matterbridgeInfo:r}){const{sendMessage:c,getUniqueId:a}=o.useContext(be),[i,l]=o.useState("Info"),[g,b]=o.useState(!1),[t,d]=o.useState(""),[y,W]=o.useState(""),[h,L]=o.useState(""),[V,M]=o.useState(),[O,u]=o.useState(),[z,v]=o.useState(),f=o.useRef(a());o.useEffect(()=>{r.bridgeMode!==void 0&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),b(r.matterFileLogger),d(r.matterMdnsInterface),W(r.matterIpv4Address),L(r.matterIpv6Address),M(r.matterPort),u(r.matterDiscriminator),v(r.matterPasscode))},[r]);const k=q=>{s&&console.log("handleChangeMjLoggerLevel called with value:",q.target.value),l(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:q.target.value}})},R=q=>{s&&console.log("handleLogOnFileMjChange called with value:",q.target.checked),b(q.target.checked),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:q.target.checked}})},C=q=>{s&&console.log("handleChangeMdnsInterface called with value:",q.target.value),d(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:q.target.value}})},m=q=>{s&&console.log("handleChangeIpv4Address called with value:",q.target.value),W(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:q.target.value}})},H=q=>{s&&console.log("handleChangeIpv6Address called with value:",q.target.value),L(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:q.target.value}})},j=q=>{s&&console.log("handleChangeMatterPort called with value:",q.target.value),M(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:q.target.value}})},x=q=>{s&&console.log("handleChangeMatterDiscriminator called with value:",q.target.value),u(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:q.target.value}})},w=q=>{s&&console.log("handleChangemMatterPasscode called with value:",q.target.value),v(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:q.target.value}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:k,children:[e.jsx(F,{value:"Debug",children:"Debug"}),e.jsx(F,{value:"Info",children:"Info"}),e.jsx(F,{value:"Notice",children:"Notice"}),e.jsx(F,{value:"Warn",children:"Warn"}),e.jsx(F,{value:"Error",children:"Error"}),e.jsx(F,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(Fe,{checked:g,onChange:R,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,onChange:C,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:y,onChange:m,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:h,onChange:H,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:V,onChange:j,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:O,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:z,onChange:w,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function qn({matterbridgeInfo:r}){return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Be,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(Be,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Be,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(Be,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(Be,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Be,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Be,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function Be({value:r,label:c}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:c,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}function Bn(r,c,a){const i=r?.[a],l=c?.[a];return i==null&&l==null?0:i==null?-1:l==null?1:typeof i=="boolean"&&typeof l=="boolean"?i===l?0:i?1:-1:typeof i=="number"&&typeof l=="number"?i-l:String(i).localeCompare(String(l))}function Jn({name:r,columns:c,rows:a,getRowKey:i,footerLeft:l,footerRight:g}){const b=o.useRef(new WeakMap),t=o.useRef(1),d=m=>{if(typeof i=="string"&&m&&m[i]!=null)return m[i];if(typeof i=="function"){const x=i(m);if(x!=null)return x}const H=c?.[0]?.id;if(H&&m&&m[H]!=null)return m[H];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let j=b.current.get(m);return j||(j=`rk_${t.current++}`,b.current.set(m,j)),j},[y,W]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[h,L]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[V,M]=o.useState(!1),[O,u]=o.useState(()=>{try{const m=localStorage.getItem(`${r}_column_visibility`);if(m)return JSON.parse(m)}catch{}return{}}),z=o.useMemo(()=>{const m={};for(const H of c)H.hidden||(m[H.id]=H.required?!0:O[H.id]!==!1);return m},[c,O]),v=o.useMemo(()=>{if(!y||!h)return a;const m=c.find(j=>j.id===y);if(!m||m.nosort)return a;const H=a.map((j,x)=>({el:j,index:x}));return H.sort((j,x)=>{const w=Bn(j.el,x.el,y);return w!==0?h==="asc"?w:-w:j.index-x.index}),H.map(j=>j.el)},[a,y,h,c]),f=m=>{if(y!==m||!y){W(m),L("asc"),localStorage.setItem(`${r}_table_order_by`,m),localStorage.setItem(`${r}_table_order`,"asc");return}if(h==="asc"){L("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}W(null),L(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},k=()=>{M(!V)},R=m=>{u(H=>{const j=c.find(q=>q.id===m);if(j&&j.required)return H;const x=z[m]!==!1,w={...H};x?w[m]=!1:delete w[m];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(w))}catch{}return w})},C=()=>{const m={};u(m);try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(m))}catch{}};return console.log(`Rendering table ${r}${y&&h?` ordered by ${y}:${h}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(De,{open:V,onClose:(m,H)=>{H==="backdropClick"||H==="escapeKeyDown"||k()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${r} columns`})]})}),e.jsx(Pe,{children:e.jsx(st,{children:c.filter(m=>!m.hidden).map(m=>e.jsx(Te,{control:e.jsx(Fe,{disabled:!!m.required,checked:m.required?!0:z[m.id]!==!1,onChange:()=>R(m.id)}),label:m.label},m.id))})}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:C,children:"Reset"}),e.jsx(ne,{variant:"contained",onClick:m=>{if(m?.currentTarget&&typeof m.currentTarget.blur=="function")try{m.currentTarget.blur()}catch{}const H=document.activeElement;if(H&&H instanceof HTMLElement&&typeof H.blur=="function")try{H.blur()}catch{}k()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:r}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:m=>{if(m?.currentTarget?.blur)try{m.currentTarget.blur()}catch{}k()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:`Configure ${r} columns`,children:e.jsx(te,{path:Ho,size:"20px",style:{color:"var(--header-text-color)"}})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${r} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(m=>{if(m.hidden||!m.required&&z[m.id]===!1)return null;const H=!m.nosort,j=H&&y===m.id&&!!h;return e.jsxs("th",{onClick:H?()=>f(m.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:m.minWidth,maxWidth:m.maxWidth,textAlign:m.align||"left",cursor:H?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:m.maxWidth?"nowrap":void 0,overflow:m.maxWidth?"hidden":void 0,textOverflow:m.maxWidth?"ellipsis":void 0},"aria-sort":H?j?h==="asc"?"ascending":"descending":"none":void 0,children:[m.label,j&&e.jsxs("span",{style:{marginLeft:6},children:[h==="asc"&&e.jsx(te,{path:Ft,size:"15px"}),h==="desc"&&e.jsx(te,{path:Tt,size:"15px"})]})]},m.id)})})}),e.jsx("tbody",{children:v.map((m,H)=>{const j=d(m);return e.jsx("tr",{className:H%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:c.map(x=>{if(x.hidden||!x.required&&z[x.id]===!1)return null;const w=m[x.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:x.align||"left",padding:"4px 8px",margin:"0",maxWidth:x.maxWidth,whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},children:typeof x.render=="function"?x.render(w,j,m,x):typeof w=="boolean"?e.jsx(Fe,{checked:w,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):x.format&&typeof w=="number"?x.format(w):w!=null?String(w):null},x.id)})},j)})})]})}),e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:l}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}const Qn=o.memo(Jn);function Gn(){const{online:r,sendMessage:c,addListener:a,removeListener:i,getUniqueId:l}=o.useContext(be),{showSnackbarMessage:g,closeSnackbarMessage:b}=o.useContext(nt),[t,d]=o.useState(null),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState(null),[O,u]=o.useState({cpuUsage:0}),[z,v]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[f,k]=o.useState({systemUptime:"",processUptime:""}),R=o.useRef(-1),[C,m]=o.useState(()=>cr);R.current||(R.current=l(),console.log("Test uniqueId:",R)),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const j=x=>{if(x.src==="Matterbridge"&&x.dst==="Frontend"){if(fe(x)&&x.method==="restart_required"&&(console.log("Test received restart_required"),g("Restart required",0)),fe(x)&&x.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${x.params.changed} and sending api requests`),g("Refresh required",0),c({id:R.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),fe(x)&&x.method==="memory_update"&&(console.log("Test received memory_update",x),v(x.params)),fe(x)&&x.method==="cpu_update"&&(console.log("Test received cpu_update",x),u(x.params)),fe(x)&&x.method==="uptime_update"&&(console.log("Test received uptime_update",x),k(x.params)),Ve(x)&&x.method==="/api/settings"&&x.response&&(console.log("Test received /api/settings:",x.response),g("Test received /api/settings"),d(x.response)),Ve(x)&&x.method==="/api/plugins"&&x.response&&(console.log(`Test received ${x.response.length} plugins:`,x.response),g("Test received /api/plugins"),W(x.response)),Ve(x)&&x.method==="/api/devices"&&x.response){console.log(`Test received ${x.response.length} devices:`,x.response),g("Test received /api/devices"),L(x.response);for(const w of x.response)console.log("Test sending /api/clusters for device:",w.pluginName,w.name,w.endpoint),c({id:R.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:w.pluginName,endpoint:w.endpoint}})}Ve(x)&&x.method==="/api/clusters"&&x.response&&(console.log(`Test received ${x.response.clusters.length} clusters for device ${x.response.deviceName} endpoint ${x.response.endpoint}:`,x),g("Test received /api/clusters"),M(x.response))}};return a(j),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),i(j),console.log("Test useEffect WebSocketMessage unmounted")}},[a,i,c,g]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),c({id:R.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,c,g]);const H=o.useCallback(j=>String(j.code),[]);return console.log("Test rendering..."),r?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"}),e.jsx("div",{style:{margin:"0",padding:"0",gap:"0",width:"1200px",maxWidth:"1200px",height:"600px",maxHeight:"600px",overflow:"hidden",backgroundColor:"var(--div-bg-color)",border:"1px solid #0004ffff"},children:e.jsx(Qn,{name:"Test",columns:Yn,rows:C,getRowKey:H,footerLeft:"Left Footer",footerRight:"Right Footer"})}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>{console.log("Test button clicked"),g("Test button clicked"),b("Refresh required"),b("Restart required"),b("Test permanent message removal")},children:"Test"}),e.jsx(ne,{variant:"outlined",onClick:()=>{m(j=>{const x=j.findIndex(xe=>xe.code==="F123");if(x===-1)return j;const w=j[x],q={...w,population:(w.population||0)+1},de=j.slice();return de[x]=q,de})},children:"Update F123"})]})]})}):e.jsx(Qe,{})}const Kn=o.memo(Gn),Yn=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(r,c,a,i)=>e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",borderRadius:"8px",backgroundColor:"var(--chip-bg, #e6f4ff)",color:"var(--chip-fg, #0550ae)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"0.85em"},children:String(r)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:r=>r.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(r,c,a,i)=>a.isIsland?"🏝️":"🏞️"}];function Se(r,c,a,i,l){const g=a/i;return{name:r,code:c,population:a,size:i,density:g,isIsland:l}}const cr=[Se("India","IN",1324171354,3287263,!1),Se("China","CN",1403500365,9596961,!1),Se("Italy","IT",60483973,301340,!1),Se("United States","US",327167434,9833520,!1),Se("Canada is a truly wonderful country","CA",37602103,9984670,!1),Se("Australia","AU",25475400,7692024,!0),Se("Germany","DE",83019200,357578,!1),Se("Ireland","IE",4857e3,70273,!0),Se("Mexico","MX",126577691,1972550,!1),Se("Japan","JP",126317e3,377973,!0),Se("France","FR",67022e3,640679,!1),Se("United Kingdom","GB",67545757,242495,!0),Se("Russia","RU",146793744,17098246,!1),Se("Nigeria","NG",200962417,923768,!1),Se("Brazil","BR",210147125,8515767,!1)],Kt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Yt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let r=0;r<2e3;r++){const c=`${Kt[r%Kt.length]}${Yt[r%Yt.length]} ${r}`,a=`F${r.toString().padStart(3,"0")}`,i=Math.floor(Math.random()*1e9),l=Math.floor(Math.random()*1e7),g=Math.random()<.2;cr.push(Se(c,a,i,l,g))}function Xn(r,c){s&&console.log("getCssVariable:",r,"defaultValue",c);const a=getComputedStyle(document.body).getPropertyValue(r).trim();return a||console.error("getCssVariable: undefined",a),a||c}function Zn(r){return po({palette:{primary:{main:r},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}let s=!1;const ei=()=>{s=!s},pr=o.createContext(void 0);function ti({children:r}){const[c,a]=o.useState(!1),[i,l]=o.useState(""),g=async b=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:b})});if(t.ok){const{valid:d}=await t.json();d?a(!0):b!==""&&l("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(pr.Provider,{value:{loggedIn:c,logIn:g,errorMessage:i},children:r})}function ri(){const[r,c]=o.useState(""),a=o.useContext(pr),[i,l]=o.useState("#1976d2");if(!a)throw new Error("AuthContext not found");const{loggedIn:g,logIn:b,errorMessage:t}=a,d=M=>{M.preventDefault(),b(r)},y={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},W={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},h={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"};o.useEffect(()=>{s&&console.log("Setting frontend theme");const M=localStorage.getItem("frontendTheme");s&&console.log("Saved theme:",M),M?document.body.setAttribute("frontend-theme",M):document.body.setAttribute("frontend-theme","dark");const O=Xn("--primary-color","#1976d2");s&&console.log("Primary color from CSS:",O),l(O)},[]);const L=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";console.log(`Loading App.js with href="${window.location.href}" and pathname="${window.location.pathname}" >>> baseName="${L}"`);const V=Zn(i);return b(""),g?e.jsx(uo,{theme:V,children:e.jsx(Cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(qo,{children:e.jsx(Bo,{children:e.jsx(xr,{basename:L,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Qo,{}),e.jsxs(br,{children:[e.jsx(Xe,{path:"/",element:e.jsx(bn,{})}),e.jsx(Xe,{path:"/devices",element:e.jsx(On,{})}),e.jsx(Xe,{path:"/log",element:e.jsx(En,{})}),e.jsx(Xe,{path:"/settings",element:e.jsx(An,{})}),e.jsx(Xe,{path:"/test",element:e.jsx(Kn,{})}),e.jsx(Xe,{path:"*",element:e.jsx(vr,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:y,children:e.jsxs("form",{onSubmit:d,style:W,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:r,onChange:M=>c(M.target.value),style:h,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function oi(){return e.jsx(ti,{children:e.jsx(ri,{})})}yr.createRoot(document.getElementById("root")).render(e.jsx(Xt.StrictMode,{children:e.jsx(oi,{})}));
|
|
23
|
+
*/var we=(r=>(r[r.Log=0]="Log",r[r.RefreshRequired=1]="RefreshRequired",r[r.RestartRequired=2]="RestartRequired",r[r.RestartNotRequired=3]="RestartNotRequired",r[r.CpuUpdate=4]="CpuUpdate",r[r.MemoryUpdate=5]="MemoryUpdate",r[r.UptimeUpdate=6]="UptimeUpdate",r[r.Snackbar=7]="Snackbar",r[r.UpdateRequired=8]="UpdateRequired",r[r.StateUpdate=9]="StateUpdate",r[r.CloseSnackbar=10]="CloseSnackbar",r[r.ShellySysUpdate=100]="ShellySysUpdate",r[r.ShellyMainUpdate=101]="ShellyMainUpdate",r))(we||{});function fe(r){return r.id>=0&&r.id<=101}function Ve(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function zo({open:r,title:c,message:a,onConfirm:i,onCancel:l}){const g=t=>{s&&console.log("Confirmed"),t.preventDefault(),i()},b=t=>{s&&console.log("Canceled"),t.preventDefault(),l()};return e.jsxs(De,{open:r,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Pe,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:a})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ne,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ne,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ht=[],nt=o.createContext(null);function qo({children:r}){const{enqueueSnackbar:c,closeSnackbar:a}=jr(),i=o.useCallback(f=>{s&&console.log(`UiProvider closeSnackbarMessage: message ${f}`);const k=ht.findIndex(R=>R.message===f);k!==-1&&(a(ht[k].key),ht.splice(k,1),s&&console.log(`UiProvider closeSnackbarMessage: message ${f} removed from persistMessages`))},[a]),l=o.useCallback((f,k,R)=>{s&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${k}`);const C=c(f,{variant:"default",autoHideDuration:k==null||k>0?(k??5)*1e3:null,persist:k===0,content:m=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Sr,{severity:R??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>a(m),action:e.jsx(J,{size:"small",onClick:()=>a(m),sx:{color:"#fff"},children:e.jsx(wr,{fontSize:"small"})}),children:f},m)},m)});k===0&&(s&&console.log(`UiProvider showSnackbarMessage: message ${f} timeout ${k} - persist key ${C}`),ht.push({message:f,key:C}))},[c,a]),[g,b]=o.useState(!1),[t,d]=o.useState(""),[y,W]=o.useState(""),[h,L]=o.useState(""),V=o.useRef(null),M=o.useRef(null),O=()=>{s&&console.log(`UiProvider handle confirm action ${h}`),b(!1),V.current&&V.current(h)},u=()=>{s&&console.log(`UiProvider handle cancel action ${h}`),b(!1),M.current&&M.current(h)},z=o.useCallback((f,k,R,C,m)=>{s&&console.log(`UiProvider showConfirmCancelDialog for command ${R}`),d(f),W(k),L(R),V.current=C,M.current=m,b(!0)},[]),v=o.useMemo(()=>({showSnackbarMessage:l,closeSnackbarMessage:i,closeSnackbar:a,showConfirmCancelDialog:z}),[l,i,a,z]);return e.jsxs(nt.Provider,{value:v,children:[e.jsx(zo,{open:g,title:t,message:y,onConfirm:O,onCancel:u}),r]})}const ir=o.createContext(null),be=o.createContext(null);function Bo({children:r}){const[c,a]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,l]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[g,b]=o.useState([]),[t,d]=o.useState(1e3),[y,W]=o.useState(!0),[h,L]=o.useState(!1),{showSnackbarMessage:V,closeSnackbarMessage:M,closeSnackbar:O}=o.useContext(nt),u=o.useRef([]),z=o.useRef(null),v=o.useRef(1),f=o.useRef(Math.floor(Math.random()*999e3)+1e3),k=o.useRef(null),R=o.useRef(null),C=o.useRef(null),m=o.useRef(c),H=o.useRef(i),j=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),x=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),w=100,q=60,de=50,xe=300;o.useEffect(()=>{m.current=c},[c]),o.useEffect(()=>{H.current=i},[i]);const S=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),p=o.useCallback(N=>{if(z.current&&z.current.readyState===WebSocket.OPEN)try{N.id===void 0&&(N.id=f.current);const n=JSON.stringify(N);z.current.send(n),s&&console.log("WebSocket sent message:",N)}catch(n){s&&console.error(`WebSocket error sending message: ${n}`)}else s&&console.error("WebSocket message not sent, WebSocket not connected:",N)},[]),E=o.useCallback((N,n)=>{const T=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${N}</span>`;b(_=>[..._,T+' <span style="color: var(--main-log-color);">'+n+"</span>"])},[]),I=o.useCallback((N,n)=>{a(N),l(n),E("WebSocket",`Filtering by log level "${N}" and log search "${n}"`)},[E]),Y=o.useCallback(N=>{s&&console.log("WebSocket addListener:",N),u.current=[...u.current,N],s&&console.log("WebSocket addListener total listeners:",u.current.length)},[]),me=o.useCallback(N=>{s&&console.log("WebSocket removeListener:",N),u.current=u.current.filter(n=>n!==N),s&&console.log("WebSocket removeListener total listeners:",u.current.length)},[]),Me=o.useCallback(()=>{j===""||j===null||j===void 0||(E("WebSocket",`Connecting to WebSocket: ${j}`),z.current=new WebSocket(j),z.current.onmessage=N=>{h||L(!0);try{const n=JSON.parse(N.data);if(n.id===void 0)return;if(n.error&&s&&console.error("WebSocket error message:",n),n.id===f.current&&n.src==="Matterbridge"&&n.dst==="Frontend"&&n.response==="pong"){s&&console.log("WebSocket pong response message:",n,"listeners:",u.current.length),R.current&&clearTimeout(R.current),u.current.forEach(_=>_(n));return}if(n.id===we.RefreshRequired){s&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.RestartRequired){s&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.RestartNotRequired){s&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.CpuUpdate){s&&console.log("WebSocket WS_ID_CPU_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.MemoryUpdate){s&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.UptimeUpdate){s&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.Snackbar&&n.params&&n.params.message){s&&console.log("WebSocket WS_ID_SNACKBAR message:",n,"listeners:",u.current.length),V(n.params.message,n.params.timeout,n.params.severity);return}else if(n.id===we.CloseSnackbar&&n.params&&n.params.message){s&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",n,"listeners:",u.current.length),M(n.params.message);return}else if(n.id===we.ShellySysUpdate){s&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id===we.ShellyMainUpdate){s&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}else if(n.id!==we.Log){s&&console.log("WebSocket message:",n,"listeners:",u.current.length),u.current.forEach(_=>_(n));return}if(!n.params||!n.params.level||!n.params.time||!n.params.name||!n.params.message||["debug","info","notice","warn","error","fatal"].includes(n.params.level)&&(m.current==="info"&&n.params.level==="debug"||m.current==="notice"&&(n.params.level==="debug"||n.params.level==="info")||m.current==="warn"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice")||m.current==="error"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice"||n.params.level==="warn")||m.current==="fatal"&&(n.params.level==="debug"||n.params.level==="info"||n.params.level==="notice"||n.params.level==="warn"||n.params.level==="error"))||H.current!=="*"&&H.current!==""&&!n.params.message.toLowerCase().includes(H.current.toLowerCase())&&!n.params.name.toLowerCase().includes(H.current.toLowerCase())||n.params.name==="Commissioning"&&n.params.message.includes("is uncommissioned"))return;b(_=>{const ae=`<span style="color: #505050;">[${n.params?.time}]</span>`,ce=ve=>{switch(ve?.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"lightblue"}},B=ve=>{switch(ve?.toLowerCase()){case"warn":return"black";default:return"white"}},ge=`${`<span style="background-color: ${ce(n.params?.level)}; color: ${B(n.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${n.params?.level}</span>`} ${ae} <span style="color: #09516d;">[${n.params?.name}]</span> <span style="color: var(--main-log-color);">${n.params?.message}</span>`,oe=[..._,ge];return oe.length>t?oe.slice(t/10):oe})}catch(n){console.error(`WebSocketUse error parsing message: ${n}`)}},z.current.onopen=()=>{s&&console.log(`WebSocket: Connected to WebSocket: ${j}`),E("WebSocket",`Connected to WebSocket: ${j}`),L(!0),O(),v.current=1,C.current=setTimeout(()=>{k.current=setInterval(()=>{p({id:f.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{s&&console.error(`WebSocketUse: No pong response received from WebSocket: ${j}`),E("WebSocket",`No pong response received from WebSocket: ${j}`),L(!1)},1e3*de)},1e3*q)},1e3*xe)},z.current.onclose=()=>{s&&console.error(`WebSocket: Disconnected from WebSocket ${x?"with Ingress":""}: ${j}`),E("WebSocket",`Disconnected from WebSocket: ${j}`),L(!1),O(),C.current&&clearTimeout(C.current),R.current&&clearTimeout(R.current),k.current&&clearInterval(k.current),E("WebSocket",`Reconnecting (attempt ${v.current} of ${w}) to WebSocket${x?" (Ingress)":""}: ${j}`),x?setTimeout(U,5e3):v.current===1?U():v.current<w?setTimeout(U,1e3*v.current):E("WebSocket",`Reconnect attempts exceeded limit of ${w} retries, refresh the page to reconnect to: ${j}`),v.current=v.current+1},z.current.onerror=N=>{s&&console.error(`WebSocket: WebSocket error connecting to ${j}:`,N),E("WebSocket",`WebSocket error connecting to ${j}`)})},[j]),U=o.useCallback(()=>{s&&console.log(`WebSocket attemptReconnect ${v.current}/${w} to:`,j),Me()},[Me]);o.useEffect(()=>(Me(),()=>{z.current&&z.current.readyState===WebSocket.OPEN&&z.current.close()}),[Me]);const D=o.useMemo(()=>({messages:g,maxMessages:t,autoScroll:y,setMessages:b,setLogFilters:I,setMaxMessages:d,setAutoScroll:W}),[g,b,I]),P=o.useMemo(()=>({maxMessages:t,autoScroll:y,logFilterLevel:c,logFilterSearch:i,setMessages:b,setLogFilters:I,setMaxMessages:d,setAutoScroll:W,online:h,retry:v.current,getUniqueId:S,addListener:Y,removeListener:me,sendMessage:p,logMessage:E}),[t,y,b,I,d,W,h,v.current,Y,me,p,E]);return e.jsx(ir.Provider,{value:D,children:e.jsx(be.Provider,{value:P,children:r})})}function Jo(){const{showSnackbarMessage:r,showConfirmCancelDialog:c}=o.useContext(nt),{online:a,sendMessage:i,logMessage:l,addListener:g,removeListener:b,getUniqueId:t}=o.useContext(be),[d,y]=o.useState(!1),[W,h]=o.useState(!1),[L,V]=o.useState(!1),[M,O]=o.useState(!1),[u,z]=o.useState(null),v=o.useRef(t()),[f,k]=o.useState(null),[R,C]=o.useState(null),[m,H]=o.useState(null),[j,x]=o.useState(null),[w,q]=o.useState(null),de=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},S=()=>{u?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},p=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},E=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},I=()=>{i({id:v.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},Y=()=>{i({id:v.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},me=()=>{i({id:v.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Me=()=>{s&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),i({id:v.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},U=()=>{s&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),i({id:v.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{s&&console.log("Header: handleShellyCreateSystemLog"),i({id:v.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{s&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},N=()=>{u?.matterbridgeInformation.restartMode===""?i({id:v.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):i({id:v.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},n=()=>{i({id:v.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{i({id:v.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},_=()=>{i({id:v.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{i({id:v.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=Q=>{k(Q.currentTarget)},B=Q=>{s&&console.log("Header: handleMenuClose",Q),k(null),Q==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),r("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),r("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),r("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(l("Matterbridge","Loading matter log..."),r("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),r("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),r("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),r("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),r("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),r("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(l("Matterbridge","Downloading backup..."),r("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?I():Q==="updatedev"?Y():Q==="updatecheck"?me():Q==="shelly-sys-update"?Me():Q==="shelly-main-update"?U():Q==="shelly-create-system-log"?D():Q==="shelly-download-system-log"?P():Q==="softreset"?_():Q==="hardreset"?ae():Q==="restart"?N():Q==="shutdown"?n():Q==="reboot"?T():Q==="create-backup"?i({id:v.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?i({id:v.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?i({id:v.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&i({id:v.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=Q=>{s&&console.log("Header: handleMenuCloseCancel:",Q),k(null)},ge=Q=>{C(Q.currentTarget)},oe=()=>{C(null)},ve=Q=>{H(Q.currentTarget)},ie=()=>{H(null)},he=Q=>{x(Q.currentTarget)},X=()=>{x(null)},ue=Q=>{q(Q.currentTarget)},ye=()=>{q(null)},Ge=()=>{ei(),s&&console.log("Matterbridge logo clicked: debug is now",s)};return o.useEffect(()=>{const Q=ee=>{ee.src==="Matterbridge"&&ee.dst==="Frontend"&&(Ve(ee)&&ee.method==="/api/settings"&&ee.id===v.current&&(s&&console.log("Header received settings:",ee.response),z(ee.response),y(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),h(ee.response.matterbridgeInformation.fixedRestartRequired),V(ee.response.matterbridgeInformation.updateRequired)),fe(ee)&&ee.method==="refresh_required"&&ee.params.changed==="settings"&&(s&&console.log(`Header received refresh_required: changed=${ee.params.changed} and sending /api/settings request`),i({id:v.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),fe(ee)&&ee.method==="restart_required"&&(s&&console.log(`Header received restart_required with fixed: ${ee.params.fixed}`),y(!0),ee.params.fixed===!0&&h(!0)),fe(ee)&&ee.method==="restart_not_required"&&(s&&console.log("Header received restart_not_required"),y(!1)),fe(ee)&&ee.method==="update_required"&&(s&&console.log("Header received update_required"),V(!0)),fe(ee)&&ee.method==="update_required_dev"&&(s&&console.log("Header received update_required_dev"),O(!0)),fe(ee)&&ee.id===we.ShellySysUpdate&&(s&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),z(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellySysUpdate:ee.params.available},systemInformation:We.systemInformation}:null)),fe(ee)&&ee.id===we.ShellyMainUpdate&&(s&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),z(We=>We?{matterbridgeInformation:{...We.matterbridgeInformation,shellyMainUpdate:ee.params.available},systemInformation:We.systemInformation}:null)))};return g(Q),s&&console.log(`Header added WebSocket listener id ${v.current}`),()=>{b(Q),s&&console.log("Header removed WebSocket listener")}},[g,b,i,r]),o.useEffect(()=>{a&&(s&&console.log("Header sending /api/settings requests"),i({id:v.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),s&&console.log("Header rendering..."),!a||!u?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ge}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(lt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!u.matterbridgeInformation.readOnly&&L&&e.jsx($,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:I,children:["Update to v.",u.matterbridgeInformation.matterbridgeLatestVersion]})}),!u.matterbridgeInformation.readOnly&&M&&e.jsx($,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:Y,children:["Update to new dev v.",u.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!u.matterbridgeInformation.readOnly&&e.jsx($,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:S,children:["v.",u.matterbridgeInformation.matterbridgeVersion]})}),u.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),u.matterbridgeInformation.bridgeMode!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.bridgeMode})}):null,u.matterbridgeInformation.restartMode!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.restartMode})}):null,u.matterbridgeInformation.profile&&u.matterbridgeInformation.profile!==""&&u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:u.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:p})}):null,u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Give a star to Matterbridge",children:e.jsx(J,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:E,children:e.jsx(Mr,{})})}):null,u.matterbridgeInformation.readOnly===!1?e.jsx($,{title:"Sponsor Matterbridge",children:e.jsx(J,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:de,children:e.jsx(Zt,{})})}):null,e.jsx($,{title:"Matterbridge help",children:e.jsx(J,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(kr,{})})}),e.jsx($,{title:"Matterbridge changelog",children:e.jsx(J,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:S,children:e.jsx(er,{})})}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsx($,{title:"Update matterbridge to latest version",children:e.jsx(J,{style:{color:L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:I,children:e.jsx(_e,{})})}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellySysUpdate&&e.jsx($,{title:"Shelly system update",children:e.jsx(J,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Me,children:e.jsx(_e,{})})}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellyMainUpdate&&e.jsx($,{title:"Shelly software update",children:e.jsx(J,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx(_e,{})})}),e.jsx($,{title:"Restart matterbridge",children:e.jsx(J,{style:{color:d||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:N,children:e.jsx(yt,{})})}),u.matterbridgeInformation.restartMode===""?e.jsx($,{title:"Shut down matterbridge",children:e.jsx(J,{style:{color:d||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:n,children:e.jsx(qe,{})})}):null,e.jsx($,{title:"Download, backup and more",children:e.jsx(J,{onClick:ce,children:e.jsx(Ir,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(rt,{id:"command-menu",anchorEl:f,keepMounted:!0,open:!!f,onClose:()=>B(""),children:[u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("updatedev"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>B("updatecheck"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellySysUpdate&&e.jsxs(F,{onClick:()=>B("shelly-sys-update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&u.matterbridgeInformation.shellyMainUpdate&&e.jsxs(F,{onClick:()=>B("shelly-main-update"),children:[e.jsx(K,{children:e.jsx(_e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>B("restart"),children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation.restartMode===""?e.jsxs(F,{onClick:()=>B("shutdown"),children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",B,le)},children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ve,children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-view",anchorEl:m,keepMounted:!0,open:!!m,onClose:ie,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("view-mblog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("view-mjlog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("view-shellylog"),ie()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:he,children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-download",anchorEl:j,keepMounted:!0,open:!!j,onClose:X,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("download-mbstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-pluginstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-pluginconfig"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mblog"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mjstorage"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-mjlog"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("shelly-create-system-log"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{B("shelly-download-system-log"),X()},children:[e.jsx(K,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ge,children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-backup",anchorEl:R,keepMounted:!0,open:!!R,onClose:oe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{B("create-backup"),oe()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{B("download-backup"),oe()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(F,{onClick:ue,children:[e.jsx(K,{children:e.jsx(Dr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-reset",anchorEl:w,keepMounted:!0,open:!!w,onClose:ye,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(F,{onClick:()=>{ye(),c("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(F,{onClick:()=>{ye(),c("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!u.matterbridgeInformation.readOnly&&e.jsxs(F,{onClick:()=>{ye(),c("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{ye(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),u.matterbridgeInformation&&u.matterbridgeInformation.shellyBoard&&e.jsxs(F,{onClick:()=>{ye(),c("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",B,le)},children:[e.jsx(K,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Qo=o.memo(Jo),Go=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(s&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(s&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Ko(){const{messages:r,autoScroll:c}=o.useContext(ir),[a,i]=o.useState(!1),l=o.useRef(null),g=o.useMemo(()=>Go(),[]),b=d=>i(!0),t=d=>i(!1);return o.useEffect(()=>{s&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${a}`),c&&!a&&!g&&l.current?.scrollIntoView({behavior:"smooth"})},[r,a,c,g]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:b,onMouseLeave:t,children:[r.map((d,y)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:d}},y)),e.jsx("div",{ref:l})]})})}const ar=o.memo(Ko);function Qe(){const{retry:r}=o.useContext(be),c=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:r<100?e.jsxs(e.Fragment,{children:[e.jsx(Nr,{style:{color:"var(--primary-color)"}}),e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:["Reconnecting to Matterbridge ","(attempt "+r+")","..."]})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:["Unable to connect to Matterbridge after multiple attempts.",e.jsx("br",{}),"Please check your network connection.",e.jsx("br",{}),e.jsx(ne,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Yo({value:r,maxChars:c}){let a=r;if(r.length>c&&c>3){const i=c-3,l=r.substring(0,Math.ceil(i/2)),g=r.substring(r.length-Math.floor(i/2),r.length);a=`${l} … ${g}`}return r!==a?e.jsx($,{title:r,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:a})}):e.jsx("span",{children:a})}function Xo({systemInfo:r,compact:c}){const[a,i]=o.useState(r),{sendMessage:l,addListener:g,removeListener:b}=o.useContext(be);if(s&&console.log("SystemInfoTable:",a,"compact:",c),r&&c&&a.totalMemory&&a.freeMemory){const t=a.totalMemory,d=a.freeMemory;a.freeMemory=`${d} / ${t}`,a.totalMemory=""}if(r&&c&&a.heapTotal&&a.heapUsed){const t=a.heapTotal,d=a.heapUsed;a.heapUsed=`${d} / ${t}`,a.heapTotal=""}if(r&&c&&a.osRelease&&a.osType){const t=a.osType,d=a.osRelease;a.osType=`${t} (${d})`,a.osRelease=""}if(r&&c&&a.osArch&&a.osPlatform){const t=a.osPlatform,d=a.osArch;a.osPlatform=`${t} (${d})`,a.osArch=""}return o.useEffect(()=>{const t=d=>{d.src==="Matterbridge"&&d.dst==="Frontend"&&(fe(d)&&d.method==="memory_update"&&d.params&&d.params.totalMemory&&d.params.freeMemory&&d.params.heapTotal&&d.params.heapUsed&&d.params.rss&&(s&&console.log("SystemInfoTable received memory_update",d),(a.totalMemory!==d.params?.totalMemory||a.freeMemory!==d.params?.freeMemory||a.heapTotal!==d.params?.heapTotal||a.heapUsed!==d.params?.heapUsed||a.rss!==d.params?.rss)&&i(y=>({...y,totalMemory:d.params?.totalMemory?d.params.totalMemory:"",freeMemory:d.params?.freeMemory?d.params.freeMemory:"",heapTotal:d.params?.heapTotal?d.params.heapTotal:"",heapUsed:d.params?.heapUsed?d.params.heapUsed:"",rss:d.params?.rss?d.params.rss:""}))),fe(d)&&d.method==="cpu_update"&&d.params&&d.params.cpuUsage&&(s&&console.log("SystemInfoTable received cpu_update",d),a.cpuUsage!==(d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":"")&&i(y=>({...y,cpuUsage:d.params?.cpuUsage?d.params.cpuUsage.toFixed(2)+" %":""}))),fe(d)&&d.method==="uptime_update"&&d.params&&d.params.systemUptime&&d.params.processUptime&&(s&&console.log("SystemInfoTable received uptime_update",d),(a.systemUptime!==d.params?.systemUptime||a.processUptime!==d.params?.processUptime)&&i(y=>({...y,systemUptime:d.params?.systemUptime?d.params.systemUptime:"",processUptime:d.params?.processUptime?d.params.processUptime:""}))))};return s&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),g(t),s&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),b(t),s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[g,a.cpuUsage,a.freeMemory,a.heapTotal,a.heapUsed,a.processUptime,a.rss,a.systemUptime,a.totalMemory,b,l]),a?(s&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(a).filter(([t,d])=>d!==void 0&&d!=="").map(([t,d],y)=>e.jsxs("tr",{className:y%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:t}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Yo,{value:typeof d!="string"?d.toString():d,maxChars:25})})]},t))})})})]})):null}const Zo=o.memo(Xo),Bt={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},en=r=>{if(!r)return"";const c=r.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const a=c.slice(0,4),i=c.slice(4,7),l=c.slice(7,11);return[a,i,l].filter(Boolean).join("-")};function tn({id:r}){const{online:c,sendMessage:a,addListener:i,removeListener:l,getUniqueId:g}=o.useContext(be),[b,t]=o.useState(null),[d,y]=o.useState(null),W=o.useRef(null),h=o.useRef(g()),{showConfirmCancelDialog:L}=o.useContext(nt);o.useEffect(()=>{s&&console.log(`QRDiv received storeId update "${r}"`),r&&(s&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const v=f=>{f.src==="Matterbridge"&&f.dst==="Frontend"&&fe(f)&&f.id===we.RefreshRequired&&f.params.changed==="matter"&&f.params.matter&&(s&&console.log(`QRDiv received refresh_required: changed=${f.params.changed} for storeId "${f.params.matter.id}":`,f.params.matter),b===f.params.matter.id&&(s&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${f.params.matter.id}":`,f.params.matter),W.current&&clearTimeout(W.current),f.params.matter.advertising&&f.params.matter.advertiseTime&&f.params.matter.advertiseTime+9e5<=Date.now()&&(f.params.matter.advertising=!1),y(f.params.matter),f.params.matter.advertising&&(s&&console.log(`QRDiv setting matter advertise timeout for storeId "${f.params.matter.id}":`,f.params.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),s&&console.log(`QRDiv clearing advertising state for storeId "${b}" after 15 minutes`),y(k=>k&&{...k,advertising:!1})},f.params.matter.advertiseTime+9e5-Date.now()))))};return i(v),s&&console.log("QRDiv webSocket effect mounted"),()=>{l(v),W.current&&clearTimeout(W.current),s&&console.log("QRDiv webSocket effect unmounted")}},[b]);const V=()=>{s&&console.log(`QRDiv sent matter startCommission for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,startCommission:!0}})},M=()=>{s&&console.log(`QRDiv sent matter stopCommission for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,stopCommission:!0}})},O=()=>{s&&console.log(`QRDiv sent matter advertise for node "${d?.id}"`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,advertise:!0}})},u=v=>{s&&console.log(`QRDiv sent matter removeFabric for node "${d?.id}" and fabricIndex ${v}`),d&&a({id:h.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:d.id,removeFabric:v}})},z=async()=>{if(!d||!d.manualPairingCode)return;const v=d.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(v);else{const f=document.createElement("textarea");f.value=v,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.focus(),f.select(),document.execCommand("copy"),document.body.removeChild(f)}s&&console.log("Manual pairing code copied to clipboard")}catch(f){console.error("Failed to copy manual pairing code",f)}};return!d||!c?(s&&console.log("QRDiv rendering undefined state"),null):d.online?d.advertising&&d.qrPairingCode&&d.manualPairingCode?(s&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(J,{"aria-label":"send advertising",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})}),e.jsx(J,{"aria-label":"stop pairing",size:"small",onClick:M,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn off pairing",arrow:!0,children:e.jsx(te,{path:go,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),e.jsx(mo,{value:d.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",en(d.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx($,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(J,{"aria-label":"copy manual pairing code",size:"small",onClick:z,sx:Bt,children:e.jsx(te,{path:ho,size:.85})})})})]})]})):d.commissioned&&d.fabricInformations&&d.sessionInformations?(s&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(J,{"aria-label":"send advertising",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:At,size:"22px"})})}),e.jsx(J,{"aria-label":"start pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx($,{title:"Turn on pairing",arrow:!0,children:e.jsx(te,{path:Ut,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),d.fabricInformations.map((v,f)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",v.fabricIndex]}),e.jsx($,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(J,{"aria-label":"remove the fabric",size:"small",onClick:()=>L("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>u(v.fabricIndex),()=>{}),sx:{...Bt,padding:"2px"},children:e.jsx(te,{path:fo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",v.rootVendorId," ",v.rootVendorName]}),v.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",v.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",d.sessionInformations?d.sessionInformations.filter(k=>k.fabric?.fabricIndex===v.fabricIndex&&k.isPeerActive===!0).length:"0"," ","subscriptions: ",d.sessionInformations?d.sessionInformations.filter(k=>k.fabric?.fabricIndex===v.fabricIndex&&k.isPeerActive===!0&&k.numberOfActiveSubscriptions>0).length:"0"]})]},f))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]})):!d.commissioned&&!d.advertising?(s&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),e.jsx(ne,{onClick:V,endIcon:e.jsx(te,{path:Ut,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]})):(s&&console.log("QRDiv rendering unknown state"),null):(s&&console.log("QRDiv rendering offline state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:b}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"bold"},children:"Server offline: restart to commission"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",d.serialNumber]})})]}))}const rn=o.memo(tn);function on(){const{logMessage:r,sendMessage:c,getUniqueId:a}=o.useContext(be),[i,l]=o.useState("matterbridge-"),[g,b]=o.useState(!1),[t,d]=o.useState(null),y=o.useRef(a()),W=f=>{f.preventDefault(),b(!0)},h=()=>{b(!1)},L=f=>{f.preventDefault(),b(!1);const k=f.dataTransfer.files[0];if(k){r("Plugins",`Installing package ${k.name}. Please wait...`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(C=>C.text()).then(C=>{r("Plugins",`Server response: ${C}`)}).catch(C=>{console.error("Error uploading plugin file:",C),r("Plugins",`Error installing package ${C}`)})}},V=f=>{const k=f.target.files&&f.target.files[0];if(k){r("Plugins",`Uploading package ${k.name}`);const R=new FormData;R.append("file",k),R.append("filename",k.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(C=>C.text()).then(C=>{r("Plugins",`Server response: ${C}`)}).catch(C=>{console.error("Error uploading plugin file:",C),r("Plugins",`Error uploading package ${C}`)})}},M=()=>{c({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},O=()=>{document.getElementById("file-upload")?.click()},u=()=>{c({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},z=f=>{d(f.currentTarget)},v=f=>{f!==""&&l(f),d(null)};return s&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:W,onDragLeave:h,onDrop:L,children:[e.jsx(pe,{value:i,onChange:f=>{l(f.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(J,{onClick:z,children:e.jsx(Pr,{})}),e.jsxs(rt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>v(""),children:[e.jsx(F,{onClick:()=>v("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(F,{onClick:()=>v("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(F,{onClick:()=>v("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(F,{onClick:()=>v("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(F,{onClick:()=>v("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(F,{onClick:()=>v("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(F,{onClick:()=>v("matterbridge-test"),children:"matterbridge-test"}),e.jsx(F,{onClick:()=>v("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(F,{onClick:()=>v("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(F,{onClick:()=>v("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx($,{title:"Install or update a plugin from npm",children:e.jsx(ne,{onClick:M,endIcon:e.jsx($e,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx($,{title:"Upload and install a plugin from a tarball",children:e.jsx(ne,{onClick:O,endIcon:e.jsx(Wr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx($,{title:"Add an installed plugin",children:e.jsx(ne,{onClick:u,endIcon:e.jsx(jt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Add"})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:V})]})}const nn=o.memo(on);function Ze({status:r,enabledText:c="Enabled",disabledText:a=void 0,tooltipText:i=void 0,onClick:l}){if(r===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const g=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:r?c:a??c});return i!==void 0?e.jsx($,{title:i,children:g}):g}}const et={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},tt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},an={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},sn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ee={padding:"0px",margin:"0px"},ln="5px 10px 5px 10px",ft={},Ce={},xt={},bt={};let vt=[],Jt=[];const dn=({open:r,onClose:c,plugin:a})=>{const{sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),t=o.useRef(b()),[d,y]=o.useState(a.configJson),[W,h]=o.useState(a.schemaJson),[L,V]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[M,O]=o.useState("");let u={};o.useEffect(()=>{const D=P=>{P.src==="Matterbridge"&&P.dst==="Frontend"&&(P.id===t.current&&P.method==="/api/select/devices"&&(P.response&&(vt=P.response),P.error&&console.error("ConfigPluginDialog received /api/select/devices error:",P.error)),P.id===t.current&&P.method==="/api/select/entities"&&(P.response&&(Jt=P.response),P.error&&console.error("ConfigPluginDialog received /api/select/entities error:",P.error)))};return l(D),d!==void 0&&W!==void 0&&(Object.keys(W.properties).forEach(P=>{Object.keys(W.properties[P]).forEach(N=>{N.startsWith("ui:")&&(L[P]={},L[P][N]=W.properties[P][N],delete W.properties[P][N])})}),V(L)),a.name!==void 0&&a.configJson!==void 0&&a.schemaJson!==void 0&&(y(a.configJson),h(a.schemaJson),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}}),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name}})),()=>{g(D)}},[l,d,a,g,W,i,L]);const z=({formData:D})=>{u=D},v=({formData:D})=>{y(D),a.configJson=D,a.restartRequired=!0,i({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:D.name,formData:D}}),c()};function f(D){const{id:P,label:N,onKeyChange:n,onDropPropertyClick:T,disabled:_,schema:ae,children:ce,registry:B,readonly:le,required:ge}=D,{templates:oe}=B,{RemoveButton:ve}=oe.ButtonTemplates;if(!(Uo in ae))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const he=({target:X})=>n(X&&X.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${P}-key`,name:`${P}-key`,required:ge,disabled:_||le,defaultValue:N,onBlur:le?void 0:he,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:ce}),e.jsx(ve,{disabled:_||le,onClick:T(N)})]})}function k(D){const{children:P,description:N,displayLabel:n,errors:T,help:_,hidden:ae,_id:ce,_label:B,registry:le,uiSchema:ge}=D,oe=_o(ge),ve=Ao("WrapIfAdditionalTemplate",le,oe);return ae?e.jsx("div",{style:{display:"none"},children:P}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(ve,{...D,children:[n===!0&&N,P,T,_]})})}function R(D){const{description:P}=D;return P?e.jsx(se,{sx:tt,children:P}):null}function C(D){const{required:P,title:N}=D;return N?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(se,{sx:et,children:["Title ",N," ",P&&e.jsx("mark",{children:"***"})]})}):null}function m(D){const{help:P,_idSchema:N}=D;return P?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(se,{sx:an,children:P})}):null}function H(D){const{errors:P}=D;return P?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(se,{color:"error",sx:sn,children:"Please fix the following errors:"}),e.jsx(it,{children:P.map((N,n)=>e.jsxs(Tr,{children:[e.jsx(K,{children:e.jsx(Fr,{color:"error"})}),e.jsx(re,{primary:N.stack})]},n))})]}):null}function j(D){const{errors:P}=D;return P?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:P.map((N,n)=>e.jsxs(se,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",N]},n))}):null}function x(D){const{id:P,name:N,_schema:n,_uiSchema:T,value:_,options:ae,label:ce,type:B,placeholder:le,required:ge,disabled:oe,readonly:ve,autofocus:ie,onChange:he,onChangeOverride:X,onBlur:ue,onFocus:ye,_rawErrors:Ge,_hideError:Q,_registry:ee,_formContext:We}=D,He=({target:{value:je}})=>he(je===""?ae.emptyValue:je),Re=({target:je})=>ue(P,je&&je.value),ze=({target:je})=>ye(P,je&&je.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:P,name:P,label:le&&le!==""?ce:void 0,variant:"outlined",placeholder:le&&le!==""?le:ce,required:ge,disabled:oe||ve,autoFocus:ie,value:_||_===0?_:"",type:B,autoComplete:B==="password"?"current-password":N,onChange:X||He,onBlur:Re,onFocus:ze,fullWidth:!0})})}function w(D){return console.log("ArrayFieldTitleTemplate:",D),null}function q(D){return console.log("ArrayFieldDescriptionTemplate:",D),null}function de(D){return console.log("ArrayFieldItemTemplate:",D),null}function xe(D){const{canAdd:P,_className:N,_disabled:n,_formContext:T,_formData:_,_idSchema:ae,_items:ce,onAddClick:B,_rawErrors:le,_readonly:ge,_registry:oe,_required:ve,schema:ie,title:he,_uiSchema:X}=D,[ue,ye]=o.useState(!1),[Ge,Q]=o.useState(!1),[ee,We]=o.useState(!1),[He,Re]=o.useState(""),ze=A=>{Re(A.target.value)},je=()=>{ye(!ue)},Ke=()=>{Q(!Ge)},Ye=()=>{We(!ee)},Mt=A=>{ye(!1),ie.selectFrom==="serial"?ie.items.default=A.serial:ie.selectFrom==="name"&&(ie.items.default=A.name),B()},kt=A=>{Q(!1),ie.selectEntityFrom==="name"?ie.items.default=A.name:ie.selectEntityFrom==="description"&&(ie.items.default=A.description),B()},It=A=>{We(!1),ie.selectDeviceEntityFrom==="name"?ie.items.default=A.name:ie.selectDeviceEntityFrom==="description"&&(ie.items.default=A.description),B()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[he&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[he&&e.jsx(se,{sx:et,children:he}),P&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ie.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(J,{onClick:je,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ie.selectEntityFrom&&e.jsx($,{title:"Add an entity from the list",children:e.jsx(J,{onClick:Ke,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ie.selectDeviceEntityFrom&&e.jsx($,{title:"Add a device entity from the list",children:e.jsx(J,{onClick:Ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(J,{onClick:B,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),ie.description&&e.jsx(se,{sx:tt,children:ie.description}),D.items.map(A=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(J,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ee,children:e.jsx(Rt,{})}),e.jsx(J,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ht,{})}),e.jsx(J,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ee,children:e.jsx(St,{})})]},A.index)),e.jsxs(De,{open:ue,onClose:je,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:He,onChange:ze,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial.toLowerCase().includes(He.toLowerCase())||A.name.toLowerCase().includes(He.toLowerCase())).map((A,ke)=>e.jsxs(ut,{onClick:()=>Mt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ke))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:je,children:"Close"})})]}),e.jsxs(De,{open:Ge,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:He,onChange:ze,placeholder:"Enter name or description"})]}),e.jsx(it,{dense:!0,children:Jt.filter(A=>A.name.toLowerCase().includes(He.toLowerCase())||A.description.toLowerCase().includes(He.toLowerCase())).map((A,ke)=>e.jsxs(ut,{onClick:()=>kt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),A.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:Ce})}),A.icon==="matter"&&e.jsx(K,{children:e.jsx(Ot,{style:Ce})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ke))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:Ke,children:"Close"})})]}),e.jsxs(De,{open:ee,onClose:Ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",he]}),e.jsx(Pe,{children:e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial===he||A.name===he).map(A=>A.entities?.map((ke,Dt)=>e.jsxs(ut,{onClick:()=>It(ke),sx:ft,children:[ke.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),ke.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),ke.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),ke.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:Ce})}),ke.icon==="matter"&&e.jsx(K,{children:e.jsx(Ot,{style:Ce})}),e.jsx(re,{primary:ke.name,secondary:ke.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Dt)))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:Ye,children:"Close"})})]})]})}function S(D){const{onAddClick:P,schema:N,properties:n,title:T,description:_}=D,[ae,ce]=o.useState(!1),[B,le]=o.useState(""),ge=X=>{le(X.target.value)},oe=()=>{ce(!ae)},ve=X=>{ce(!1);let ue="";N.selectFrom==="serial"?ue=X.serial:N.selectFrom==="name"&&(ue=X.name),O(ue),P(N)()},ie=()=>{P(N)()},he=!N.additionalProperties;return!he&&M!==""&&n.forEach(X=>{if(X.name==="newKey"&&X.content.key==="newKey"&&X.content.props.name==="newKey"&&X.content.props.onKeyChange&&M!==""){const ue=M;O(""),X.content.props.onKeyChange(ue)}}),e.jsxs(Z,{sx:{margin:"0px",padding:he?"10px":"5px 10px 0px 10px",border:he?"none":"1px solid grey"},children:[N.title&&he&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:et,children:N.title})}),T&&!he&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(se,{sx:et,children:T}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[N.selectFrom&&e.jsx($,{title:"Add a device from the list",children:e.jsx(J,{onClick:oe,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx($,{title:"Add a new item",children:e.jsx(J,{onClick:ie,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),N.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:tt,children:N.description})}),n.map(({content:X,name:ue,hidden:ye})=>!ye&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(N.properties[ue].type)?"0px":ln,border:["object","array","boolean"].includes(N.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(N.properties[ue].type)&&e.jsx(se,{sx:et,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:X})]},ue)),e.jsxs(De,{open:ae,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:B,onChange:ge,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(X=>X.serial.toLowerCase().includes(B.toLowerCase())||X.name.toLowerCase().includes(B.toLowerCase())).map((X,ue)=>e.jsxs(ut,{onClick:()=>ve(X),sx:ft,children:[X.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:Ce})}),X.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:Ce})}),X.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:Ce})}),e.jsx(re,{primary:X.name,secondary:X.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ue))})]}),e.jsx(Le,{children:e.jsx(ne,{onClick:oe,children:"Close"})})]})]})}function p(D){const{uiSchema:P}=D,{submitText:N,norender:n}=Vo(P);return n?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ne,{type:"submit",variant:"contained",color:"primary",children:N}),e.jsx(ne,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function E(D){const{className:P,disabled:N,onClick:n,registry:T,style:_,uiSchema:ae,...ce}=D;return e.jsx($,{title:"Remove the item",children:e.jsx(J,{disabled:N,size:"small",color:"primary",onClick:n,children:e.jsx(St,{})})})}function I(D){const{className:P,disabled:N,onClick:n,registry:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Add an item",children:e.jsx(J,{size:"small",color:"primary",onClick:n,children:e.jsx(jt,{})})})}function Y(D){const{disabled:P,onClick:N,registry:n,style:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Move up the item",children:e.jsx(J,{size:"small",color:"primary",onClick:N,children:e.jsx(Rt,{})})})}function me(D){const{disabled:P,onClick:N,registry:n,style:T,uiSchema:_,...ae}=D;return e.jsx($,{title:"Move down the item",children:e.jsx(J,{size:"small",color:"primary",onClick:N,children:e.jsx(Ht,{})})})}function Me(D){const{id:P,name:N,value:n,schema:T,readonly:_,onChange:ae}=D,[ce,B]=o.useState(void 0),le=oe=>{B(oe&&oe!==""?oe:void 0)},ge=()=>{i({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:a.name,action:N,value:ce,formData:u,id:P}}),T.buttonClose===!0?c():T.buttonSave===!0&&v({formData:d})};return T.buttonText&&T.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:tt,children:T.description}),e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>ge(),children:T.buttonText})]}):T.buttonField&&T.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:tt,children:T.description}),e.jsx(pe,{id:N+"-input",name:N,label:T.textLabel,placeholder:T.textPlaceholder,onChange:oe=>le(oe.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ne,{id:N+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>ge(),children:T.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[N&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(se,{sx:et,children:N}),e.jsx(Fe,{checked:n,readOnly:_,onChange:()=>ae(!n),sx:{padding:"0px",margin:"0px"}})]}),T.description&&e.jsx(se,{sx:tt,children:T.description})]})}function U({schema:D,id:P,name:N,options:n,label:T,hideLabel:_,required:ae,disabled:ce,placeholder:B,readonly:le,value:ge,multiple:oe,autofocus:ve,onChange:ie,onBlur:he,onFocus:X,errorSchema:ue,rawErrors:ye=[],registry:Ge,uiSchema:Q,hideError:ee,formContext:We,...He}){const{enumOptions:Re,enumDisabled:ze,emptyValue:je}=n;oe=typeof oe>"u"?!1:!!oe;const Ke=oe?[]:"",Ye=typeof ge>"u"||oe&&ge.length<1||!oe&&ge===Ke,Mt=({target:{value:Oe}})=>ie(Pt(Oe,Re,je)),kt=({target:Oe})=>he(P,Pt(Oe&&Oe.value,Re,je)),It=({target:Oe})=>X(P,Pt(Oe&&Oe.value,Re,je)),A=Oo(ge,Re,oe),{InputLabelProps:ke,SelectProps:Dt,autocomplete:ur,...mr}=He,gr=!oe&&D.default===void 0;return e.jsxs(pe,{id:P,name:P,value:!Ye&&typeof A<"u"?A:Ke,required:ae,disabled:ce||le,autoFocus:ve,autoComplete:ur,placeholder:B,error:ye.length>0,onChange:Mt,onBlur:kt,onFocus:It,...mr,select:!0,InputLabelProps:{...ke,shrink:!Ye},SelectProps:{...Dt,multiple:oe},"aria-describedby":Eo(P),children:[gr&&e.jsx(F,{value:"",children:B}),Array.isArray(Re)&&Re.map(({value:Oe,label:hr},Lt)=>{const fr=Array.isArray(ze)&&ze.indexOf(Oe)!==-1;return e.jsx(F,{value:String(Lt),disabled:fr,children:hr},Lt)})]})}return!r||!W||!d?null:e.jsxs(De,{open:r,onClose:c,maxWidth:"800px",children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Pe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Ro,{schema:W,formData:d,uiSchema:L,validator:$o,templates:{FieldTemplate:k,BaseInputTemplate:x,TitleFieldTemplate:C,DescriptionFieldTemplate:R,FieldHelpTemplate:m,FieldErrorTemplate:j,ErrorListTemplate:H,WrapIfAdditionalTemplate:f,ArrayFieldTitleTemplate:w,ArrayFieldDescriptionTemplate:q,ArrayFieldItemTemplate:de,ArrayFieldTemplate:xe,ObjectFieldTemplate:S,ButtonTemplates:{SubmitButton:p,RemoveButton:E,AddButton:I,MoveUpButton:Y,MoveDownButton:me}},widgets:{CheckboxWidget:Me,SelectWidget:U},onChange:z,onSubmit:v})})]})};function sr(r){if(s&&console.log(`getQRColor (id: ${r?.id}) received matter:`,r??"undefined"),r===void 0||!r.online||!r.qrPairingCode&&!r.manualPairingCode&&!r.fabricInformations&&!r.sessionInformations)return"red";if(r.commissioned===!1&&r.qrPairingCode&&r.manualPairingCode)return"var(--primary-color)";let c=0,a=0;for(const i of r.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(a+=i.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(c===0||a===0)?"var(--secondary-color)":"var(--div-text-color)"}function cn({data:r,columns:c,columnVisibility:a}){const i=Xt.useMemo(()=>c.filter(y=>a[y.accessor]),[c,a]),{getTableProps:l,getTableBodyProps:g,headerGroups:b,rows:t,prepareRow:d}=Ue.useTable({columns:i,data:r},Ue.useSortBy);return e.jsxs("table",{...l(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:b.map(y=>e.jsx("tr",{...y.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:y.headers.map(W=>e.jsx("th",{...W.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:"default"},children:W.render("Header")}))}))}),e.jsx("tbody",{...g(),style:{border:"none",borderCollapse:"collapse"},children:t.map((y,W)=>(d(y),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...y.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:y.cells.map(h=>e.jsx("td",{...h.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:h.render("Cell")}))})))})]})}function pn({_storeId:r,setStoreId:c}){const{online:a,sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),{showConfirmCancelDialog:t}=o.useContext(nt),d=o.useRef(b()),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState([]),[O,u]=o.useState(!1),[z,v]=o.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),f=[{Header:"Name",accessor:"name",Cell:({row:n})=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>S(n.original),children:n.original.name})})},{Header:"Description",accessor:"description",Cell:({row:n})=>e.jsx($,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>S(n.original),children:n.original.description})})},{Header:"Version",accessor:"version",Cell:({row:n})=>e.jsxs(e.Fragment,{children:[n.original.latestVersion!==void 0&&n.original.latestVersion!==n.original.version&&h&&!h.readOnly&&e.jsx($,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>x(n.original),children:["Update to v.",n.original.latestVersion]})}),n.original.version.includes("-dev-")&&n.original.devVersion!==void 0&&n.original.devVersion!==n.original.version&&h&&!h.readOnly&&e.jsx($,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>w(n.original),children:["Update to new dev v.",n.original.devVersion.split("-dev-")[0]]})}),e.jsx($,{title:"Plugin version",children:e.jsx("span",{children:n.original.version})})]})},{Header:"Author",accessor:"author",Cell:({row:n})=>e.jsx(e.Fragment,{children:n.original.author?n.original.author.replace("https://github.com/",""):"Unknown"})},{Header:"Type",accessor:"type",Cell:({row:n})=>e.jsx(e.Fragment,{children:n.original.type?n.original.type.replace("Platform",""):"Unknown"})},{Header:"Devices",accessor:"registeredDevices"},{Header:"Actions",accessor:"actions",Cell:({row:n})=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[h&&h.bridgeMode==="childbridge"&&!n.original.error&&n.original.enabled&&e.jsx($,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:sr(n.original.matter)},onClick:()=>{n.original?.matter?.id&&c(n.original?.matter?.id)},size:"small",children:e.jsx(tr,{})})}),h&&h.bridgeMode==="childbridge"&&!n.original.error&&n.original.enabled&&e.jsx($,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>de(n.original),size:"small",children:e.jsx(yt,{})})}),e.jsx($,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{disabled:n.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(n.original),size:"small",children:e.jsx(Je,{})})}),h&&!h.readOnly&&e.jsx($,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",n.original)},size:"small",children:e.jsx(St,{})})}),n.original.enabled?e.jsx($,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{m("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",n.original)},size:"small",children:e.jsx(Lr,{})})}):e.jsx(e.Fragment,{}),n.original.enabled?e.jsx(e.Fragment,{}):e.jsx($,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>xe(n.original),size:"small",children:e.jsx(Hr,{})})}),e.jsx($,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>E(n.original),size:"small",children:e.jsx(Rr,{})})}),e.jsx($,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(n.original),size:"small",children:e.jsx($r,{})})}),h&&!h.readOnly&&e.jsx($,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>p(n.original),size:"small",children:e.jsx(Zt,{})})})]})},{Header:"Status",accessor:"status",Cell:({row:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",gap:"5px"},children:n.original.error?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:n.original.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:n.original.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:n.original.loaded&&n.original.started&&n.original.configured?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:n.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{status:n.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ze,{status:n.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ze,{status:n.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const n=T=>{T.src==="Matterbridge"&&T.dst==="Frontend"&&(fe(T)&&T.method==="refresh_required"&&T.params.changed==="plugins"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and sending /api/plugins request`),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),fe(T)&&T.method==="refresh_required"&&T.params.changed==="matter"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and setting matter id ${T.params.matter?.id}`),M(_=>{const ae=_.findIndex(B=>B.matter?.id===T.params.matter?.id);if(ae<0)return s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and matter id ${T.params.matter?.id} not found`),_;s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} set matter id ${T.params.matter?.id}`);const ce=[..._];return ce[ae]={...ce[ae],matter:T.params.matter},ce})),fe(T)&&T.method==="refresh_required"&&T.params.changed==="settings"&&(s&&console.log(`HomePlugins received refresh_required: changed=${T.params.changed} and sending /api/settings request`),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Ve(T)&&T.id===d.current&&T.method==="/api/settings"&&(s&&console.log(`HomePlugins (id: ${T.id}) received settings:`,T.response),W(T.response.systemInformation),L(T.response.matterbridgeInformation)),Ve(T)&&T.id===d.current&&T.method==="/api/plugins"&&(s&&console.log(`HomePlugins (id: ${T.id}) received ${T.response.length} plugins:`,T.response),M(T.response)))};return l(n),s&&console.log("HomePlugins added WebSocket listener id:",d.current),()=>{g(n),s&&console.log("HomePlugins removed WebSocket listener")}},[l,g,i]),o.useEffect(()=>{a&&(s&&console.log("HomePlugins sending api requests"),i({id:d.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:d.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),o.useEffect(()=>{const n=localStorage.getItem("homePluginsColumnVisibility");n&&v(JSON.parse(n))},[]);const k=()=>{u(!O)},R=n=>{v(T=>{const _={...T,[n]:!T[n]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(_)),_})},C=o.useRef(null),m=(n,T,_,ae)=>{s&&console.log(`handleActionWithConfirmCancel ${_} ${ae.name}`),C.current=ae,t(n,T,_,H,j)},H=n=>{s&&console.log(`handleConfirm action confirmed ${n} ${C.current?.name}`),n==="remove"&&C.current?q(C.current):n==="disable"&&C.current&&xe(C.current),C.current=null},j=n=>{s&&console.log(`handleCancel action canceled ${n} ${C.current?.name}`),C.current=null},x=n=>{s&&console.log("handleUpdatePlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n.name,restart:!1}})},w=n=>{s&&console.log("handleUpdateDevPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n.name+"@dev",restart:!1}})},q=n=>{s&&console.log("handleRemovePlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})},de=n=>{s&&console.log("handleRestartPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})},xe=n=>{s&&console.log("handleEnableDisablePlugin plugin:",n.name,"enabled:",n.enabled),n.enabled===!0?(n.enabled=!1,i({id:d.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}})):(n.enabled=!0,i({id:d.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:n.name}}))},S=n=>{s&&console.log(`handleHomepagePlugin plugin: ${n.name} homepage: ${n.homepage}`),n.homepage&&window.open(n.homepage,"_blank")},p=n=>{s&&console.log("handleSponsorPlugin plugin:",n.name,"funding:",n.funding),n.funding&&window.open(n.funding,"_blank")},E=n=>{s&&console.log("handleHelpPlugin plugin:",n.name,"help:",n.help),n.help&&window.open(n.help,"_blank")},I=n=>{s&&console.log("handleChangelogPlugin plugin:",n.name,"changelog:",n.changelog),n.changelog&&window.open(n.changelog,"_blank")},[Y,me]=o.useState({}),[Me,U]=o.useState(!1),D=n=>{s&&console.log("handleConfigPlugin plugin:",n.name),i({id:d.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:n.name}}),i({id:d.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:n.name}}),me(n),P()},P=()=>{U(!0)},N=()=>{U(!1)};return s&&console.log("HomePlugins rendering..."),a?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[e.jsx(dn,{open:Me,onClose:N,plugin:Y}),e.jsxs(De,{open:O,onClose:k,children:[e.jsx(Ne,{children:"Configure Plugins Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:f.map(n=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["description","actions","status"].includes(n.accessor),checked:z[n.accessor]??!1,onChange:()=>R(n.accessor)}),label:n.Header},n.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:k,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Plugins"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:k,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(cn,{data:V,columns:f,columnVisibility:z})})]}):e.jsx(Qe,{})}const un=o.memo(pn),mn=r=>`${r.pluginName}::${r.serial}`;function gn({data:r,columns:c,columnVisibility:a}){const i=o.useMemo(()=>{const h=localStorage.getItem("homeDevicesColumnsSortBy");return h?JSON.parse(h):[{id:"name",desc:!1}]},[c]),l=o.useMemo(()=>c.filter(h=>a[h.accessor]),[a,c]),{getTableProps:g,getTableBodyProps:b,headerGroups:t,rows:d,prepareRow:y,state:{sortBy:W}}=Ue.useTable({columns:l,data:r,getRowId:mn,initialState:{sortBy:i}},Ue.useSortBy);return o.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(W))},[W]),e.jsxs("table",{...g(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:t.map(h=>e.jsx("tr",{...h.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:h.headers.map(L=>e.jsxs("th",{...L.getHeaderProps(L.noSort?void 0:L.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:[L.render("Header"),!L.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:L.isSorted?L.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Ft,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...b(),style:{border:"none",borderCollapse:"collapse"},children:d.map((h,L)=>(y(h),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...h.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:h.cells.map(V=>e.jsx("td",{...V.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:V.render("Cell")}))})))})]})}function hn({storeId:r,setStoreId:c}){const{online:a,sendMessage:i,addListener:l,removeListener:g,getUniqueId:b}=o.useContext(be),[t,d]=o.useState(!1),[y,W]=o.useState(!0),[h,L]=o.useState(null),[V,M]=o.useState([]),[O,u]=o.useState([]),[z,v]=o.useState([]),[f,k]=o.useState([]),[R,C]=o.useState(!1),[m,H]=o.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),j=o.useRef(b()),x=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:S})=>S.original.reachable===!0?"Online":S.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(S,p)=>{const E=S.original.reachable===!0?1:S.original.reachable===!1?0:-1,I=p.original.reachable===!0?1:p.original.reachable===!1?0:-1;return E-I}},{Header:"Power",accessor:"powerSource",Cell:({row:S})=>S.original.powerSource==="ac"||S.original.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):S.original.powerSource==="ok"?e.jsx(Ct,{fontSize:"small",sx:{color:"green"}}):S.original.powerSource==="warning"?e.jsx(Ct,{fontSize:"small",sx:{color:"yellow"}}):S.original.powerSource==="critical"?e.jsx(Ct,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:S})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[S.original.matter!==void 0?e.jsx($,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{onClick:()=>c(r===S.original.matter.id?h.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:S.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:sr(S.original.matter)},children:e.jsx(tr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),S.original.configUrl?e.jsx($,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(J,{onClick:()=>window.open(S.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),S.original.selected!==void 0?e.jsx($,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Fe,{checked:S.original.selected,onChange:p=>xe(p,S.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],w=o.useCallback(S=>{S.selected=void 0;const p=V.find(Y=>Y.name===S.pluginName);if(!p)return console.error(`HomeDevices isSelected: plugin ${S.pluginName} not found for device ${S.deviceName} `),S.selected;const E=p.schemaJson?.properties?.whiteList?.selectFrom;let I=p.configJson?.postfix;return I===""&&(I=void 0),p.hasWhiteList===!0&&p.hasBlackList===!0&&E&&(S.selected=!0,E==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!0),E==="serial"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!1),E==="serial"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(I?S.serial.replace("-"+I,""):S.serial)&&(S.selected=!1),E==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&p.configJson.whiteList.includes(S.name)&&(S.selected=!0),E==="name"&&p.configJson.whiteList&&p.configJson.whiteList.length>0&&!p.configJson.whiteList.includes(S.name)&&(S.selected=!1),E==="name"&&p.configJson.blackList&&p.configJson.blackList.length>0&&p.configJson.blackList.includes(S.name)&&(S.selected=!1)),S.selected},[V]);o.useEffect(()=>{const S=p=>{if(p.src==="Matterbridge"&&p.dst==="Frontend"){if(p.method==="refresh_required"&&p.params.changed!=="matter"&&(s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and sending /api/plugins request`),i({id:j.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),p.method==="refresh_required"&&p.params.changed==="matter"&&(s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and setting matter id ${p.params.matter?.id}`),k(E=>{const I=E.findIndex(me=>me.name.replaceAll(" ","")===p.params.matter?.id);if(I<0)return s&&console.debug(`HomeDevices: matter id ${p.params.matter?.id} not found`),E;const Y=[...E];return Y[I]={...Y[I],matter:p.params.matter},s&&console.log(`HomeDevices received refresh_required: changed=${p.params.changed} and set matter id ${p.params.matter?.id}`),Y})),p.method==="restart_required"&&(s&&console.log("HomeDevices received restart_required"),d(!0)),p.method==="restart_not_required"&&(s&&console.log("HomeDevices received restart_not_required"),d(!1)),p.method==="state_update"&&p.params.plugin&&p.params.serialNumber&&p.params.cluster.includes("BasicInformationServer")&&p.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${p.params.plugin} serial ${p.params.serialNumber} value ${p.params.value}`),u(E=>E.map(I=>I.pluginName===p.params.plugin&&I.serial===p.params.serialNumber?{...I,reachable:p.params.value}:I))),p.id===j.current&&p.method==="/api/settings"&&(s&&console.log(`HomeDevices (id: ${p.id}) received settings:`,p.response),L(p.response),d(p.response.matterbridgeInformation.restartRequired||p.response.matterbridgeInformation.fixedRestartRequired)),p.id===j.current&&p.method==="/api/plugins"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} plugins:`,p.response),p.response)){let E=!0;for(const I of p.response)I.enabled===!0&&(I.loaded!==!0||I.started!==!0||I.error===!0)&&(E=!1);if(!E)return;s&&console.log("HomeDevices reset plugins, devices and selectDevices"),W(!1),M(p.response),u([]),v([]),i({id:j.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),s&&console.log("HomeDevices sent /api/devices");for(const I of p.response)I.enabled===!0&&I.loaded===!0&&I.started===!0&&I.error!==!0&&(i({id:j.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:I.name}}),s&&console.log(`HomeDevices sent /api/select/devices for plugin: ${I.name}`))}if(p.id===j.current&&p.method==="/api/devices"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} devices:`,p.response),p.response)){for(const E of p.response)E.selected=w(E);u(p.response)}p.id===j.current&&p.method==="/api/select/devices"&&(s&&console.log(`HomeDevices (id: ${p.id}) received ${p.response?.length} selectDevices for plugin ${p.response&&p.response.length>0?p.response[0].pluginName:"without select devices"}:`,p.response),p.response&&p.response.length>0&&v(E=>{const I=E.filter(me=>me.pluginName!==p.response[0].pluginName),Y=p.response.map(me=>({...me,selected:w(me)}));return[...I,...Y]}))}};return l(S),s&&console.log(`HomeDevices added WebSocket listener id ${j.current}`),()=>{g(S),s&&console.log("HomeDevices removed WebSocket listener")}},[V,l,g,i,w]),o.useEffect(()=>{if(O.length===0&&z.length===0){k([]);return}s&&console.log(`HomeDevices mixing devices (${O.length}) and selectDevices (${z.length})`);const S=[];for(const p of O)S.push(p);for(const p of z)O.find(E=>E.pluginName===p.pluginName&&E.serial.includes(p.serial))||S.push(p);S.length>0&&(k(S),s&&console.log(`HomeDevices mixed ${S.length} devices and selectDevices`))},[V,O,z,k]),o.useEffect(()=>{a&&(s&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:j.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:j.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,i]),o.useEffect(()=>{const S=localStorage.getItem("homeDevicesColumnVisibility");if(S){const p=JSON.parse(S);p.powerSource===void 0&&(p.powerSource=!0),H(p),s&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const q=S=>{H(p=>{const E={...p,[S]:!p[S]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(E)),s&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(E),E),E})},de=()=>{C(!R)},xe=(S,p)=>{console.log(`handleCheckboxChange: checkbox changed to ${S.target.checked} for device ${p.name} serial ${p.serial}`),k(E=>{const I=E.findIndex(me=>me.pluginName===p.pluginName&&me.serial===p.serial);if(I<0)return console.error(`handleCheckboxChange: device not found ${p.name} serial ${p.serial} id ${p.id}`),E;const Y=[...E];return Y[I]={...Y[I],selected:S.target.checked},Y}),S.target.checked?i({id:j.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}}):i({id:j.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:p.pluginName,serial:p.serial,name:p.name}})};return s&&console.log("HomeDevices rendering..."),a?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs(De,{open:R,onClose:de,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:x.map(S=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["name","actions"].includes(S.accessor),checked:m[S.accessor],onChange:()=>q(S.accessor)}),label:S.Header},S.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:de,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:de,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(gn,{data:f,columns:x,columnVisibility:m})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[y&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!y&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",O.length.toString(),"/",f.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Qe,{})}const fn=o.memo(hn);function xn(){const[r,c]=o.useState(null),[a,i]=o.useState(null),[l,g]=o.useState([]),[b]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,d]=o.useState(localStorage.getItem("homePageMode")??"devices"),[y,W]=o.useState(""),[h,L]=o.useState(!1),[V,M]=o.useState(!1),[O,u]=o.useState(null),{addListener:z,removeListener:v,online:f,sendMessage:k,logFilterLevel:R,logFilterSearch:C,autoScroll:m,getUniqueId:H}=o.useContext(be),j=o.useRef(H());return o.useEffect(()=>{const x=w=>{w.src==="Matterbridge"&&w.dst==="Frontend"&&(fe(w)&&w.method==="refresh_required"&&w.params.changed==="settings"&&(s&&console.log(`Home received refresh_required: changed=${w.params.changed} and sending /api/settings request`),u(null),g([]),k({id:j.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:j.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),Ve(w)&&w.method==="/api/settings"&&w.id===j.current&&(s&&console.log("Home received settings:",w.response),c(w.response.systemInformation),i(w.response.matterbridgeInformation),w.response.matterbridgeInformation.bridgeMode==="bridge"&&(O||u("Matterbridge")),w.response.matterbridgeInformation.bridgeMode==="childbridge"&&l.length>0&&O===null&&!O&&l.length>0&&l[0].matter?.id&&u(l[0].matter.id),w.response.matterbridgeInformation.matterbridgeVersion&&W(`https://github.com/Luligu/matterbridge/blob/${w.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&w.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",w.response.matterbridgeInformation.frontendVersion):w.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&w.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",w.response.matterbridgeInformation.frontendVersion),M(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",w.response.matterbridgeInformation.matterbridgeVersion):w.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",w.response.matterbridgeInformation.matterbridgeVersion),L(!0)),w.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),d("devices")))),Ve(w)&&w.method==="/api/plugins"&&w.id===j.current&&(s&&console.log(`Home received plugins (${a?.bridgeMode}):`,w.response),g(w.response),a?.bridgeMode==="childbridge"&&w.response.length>0&&!O&&w.response.length>0&&w.response[0].matter?.id&&u(w.response[0].matter.id)))};return z(x),s&&console.log(`Home added WebSocket listener id ${j.current}`),()=>{v(x),s&&console.log("Home removed WebSocket listener")}},[z,v,k,a,l,O]),o.useEffect(()=>{f&&(s&&console.log("Home received online"),k({id:j.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),k({id:j.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[f,k]),s&&console.log("Home rendering..."),!f||!r||!a?e.jsx(Qe,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(rn,{id:O}),e.jsx(Zo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[V&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ne,{onClick:()=>window.location.reload(),endIcon:e.jsx(Or,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),h&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ne,{onClick:()=>window.open(y,"_blank"),endIcon:e.jsx(er,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ne,{onClick:()=>window.location.reload(),endIcon:e.jsx(Er,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),b&&!a.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(nn,{})]}),b&&e.jsx(un,{storeId:O,setStoreId:u}),t==="devices"&&e.jsx(fn,{storeId:O,setStoreId:u}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',R,'" and search "',C,'" Scroll: ',m?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(ar,{})})]})]})]})}const bn=o.memo(xn),Qt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},vn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},yn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Gt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},jn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Cn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Sn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},wn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Mn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Wt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},kn=[256,257,268,269],In=[266,267],Dn=[259,260,261,271,272],Nn=[256,257,268,269,266,267,259,260,261];function G({icon:r,iconColor:c,cluster:a,value:i,unit:l,prefix:g}){return s&&console.log(`Render cluster "${a.clusterName}.${a.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${l}"`),g=g??!1,e.jsxs(Z,{sx:Qt,children:[r&&o.cloneElement(r,{key:`${a.clusterId}-${a.attributeId}-icon`,sx:{...vn,color:c??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Qt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&g===!0&&e.jsx(se,{sx:Gt,children:l},`${a.clusterId}-${a.attributeId}-unit`),e.jsx(se,{sx:yn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${a.clusterId}-${a.attributeId}-value`),l&&g===!1&&e.jsx(se,{sx:Gt,children:l},`${a.clusterId}-${a.attributeId}-unit`)]},`${a.clusterId}-${a.attributeId}-valueunitbox`)]},`${a.clusterId}-${a.attributeId}-box`)}function Pn({device:r,endpoint:c,id:a,deviceType:i,clusters:l}){const g=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let b="";return s&&console.log(`Device "${r.name}" endpoint "${c}" id "${a}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>b=`${t.attributeLocalValue} mV`),Nn.includes(i)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>b=`Level ${t.attributeValue}`),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>b=`Position ${t.attributeValue/100}%`),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>b=`Heat ${t.attributeValue/100}°C `),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>b=b+`Cool ${t.attributeValue/100}°C`),i===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>b=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>b=`${t.attributeLocalValue/1e3} V, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>b=b+`${t.attributeLocalValue/1e3} A, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>b=b+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:t.attributeLocalValue===!0?e.jsx(at,{}):e.jsx(Vr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(G,{icon:e.jsx(Ct,{}),cluster:t,value:t.attributeValue/2,unit:"%"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(G,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),kn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),In.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Dn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:"Oven"})),i===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Ar,{}),cluster:t,value:"Fridge"})),i===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(Et,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(G,{icon:e.jsx(te,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:zt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(G,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(G,{icon:t.attributeValue==="1"?e.jsx(zr,{}):e.jsx(qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(G,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),i===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(G,{icon:e.jsx(te,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(G,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:g[t.attributeLocalValue??0]})),i===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:t.attributeValue==="true"?e.jsx(ro,{}):e.jsx(oo,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(G,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(no,{}):e.jsx(io,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(ao,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeValue/1e4)),unit:"lx"})),i===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(G,{icon:e.jsx(so,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:jn,children:e.jsx(se,{sx:Cn,children:b})}),e.jsx(Z,{sx:Sn,children:e.jsx(se,{sx:wn,children:r.name})}),e.jsxs(Z,{sx:Mn,children:[s&&e.jsx(se,{sx:Wt,children:c}),e.jsx(se,{sx:Wt,children:a}),s&&e.jsxs(se,{sx:Wt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Wn({filter:r}){const{online:c,sendMessage:a,addListener:i,removeListener:l,getUniqueId:g}=o.useContext(be),[b,t]=o.useState({}),[d,y]=o.useState([]),[W,h]=o.useState([]),[L,V]=o.useState({}),[M,O]=o.useState({}),[u,z]=o.useState({}),[v,f]=o.useState(W),k=o.useRef(g());return o.useEffect(()=>{const R=C=>{if(C.src==="Matterbridge"&&C.dst==="Frontend"){if(C.method==="refresh_required"&&(s&&console.log(`DevicesIcons received refresh_required: changed=${C.params.changed} and sending api requests`),a({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),C.method==="/api/settings"&&C.response&&(s&&console.log("DevicesIcons received settings:",C.response),t(C.response)),C.method==="/api/plugins"&&C.response&&(s&&console.log("DevicesIcons received plugins:",C.response),y(C.response)),C.method==="/api/devices"&&C.response){s&&console.log(`DevicesIcons received ${C.response.length} devices:`,C.response),h(C.response);for(let m of C.response)s&&console.log("DevicesIcons sending /api/clusters"),a({id:k.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:m.pluginName,endpoint:m.endpoint}})}if(C.method==="/api/clusters"&&C.response){if(console.log(`DevicesIcons received for device "${C.response.deviceName}" serial "${C.response.serialNumber}" deviceType ${C.response.deviceTypes.join(" ")} clusters (${C.response.length}):`,C.response),C.response.length===0)return;const m=C.response.serialNumber;L[m]=[],M[m]=C.response.deviceTypes,u[m]=[];for(let H of C.response.clusters)L[m].find(j=>j.endpoint===H.endpoint)||L[m].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(H.clusterName)&&u[m].push(H);V({...L}),O({...M}),z({...u}),s&&console.log(`DevicesIcons endpoints for "${m}":`,L[m]),s&&console.log(`DevicesIcons deviceTypes for "${m}":`,M[m]),s&&console.log(`DevicesIcons clusters for "${m}":`,u[m])}}};return i(R),s&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(R),s&&console.log("DevicesIcons useEffect webSocket unmounted")}},[i,l,a]),o.useEffect(()=>(s&&console.log("DevicesIcons useEffect online mounting"),c&&(s&&console.log("DevicesIcons useEffect online sending api requests"),a({id:k.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:k.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),s&&console.log("DevicesIcons useEffect online mounted"),()=>{s&&console.log("DevicesIcons useEffect online unmounted")}),[c,a]),o.useEffect(()=>{if(r===""){f(W);return}const R=W.filter(C=>C.name.toLowerCase().includes(r)||C.serial.toLowerCase().includes(r));f(R)},[W,r]),s&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:v.map(R=>L[R.serial]&&L[R.serial].map(C=>C.deviceTypes.map(m=>e.jsx(Pn,{device:R,endpoint:C.endpoint,id:C.id,deviceType:m,clusters:u[R.serial].filter(H=>H.endpoint===C.endpoint)}))))})}const Tn=o.memo(Wn),lr=[{Header:"Plugin name",accessor:"pluginName"},{Header:"Device type",accessor:"type"},{Header:"Endpoint",accessor:"endpoint"},{Header:"Name",accessor:"name"},{Header:"Serial number",accessor:"serial"},{Header:"Unique ID",accessor:"uniqueId"},{Header:"Url",accessor:"configUrl"},{Header:"Config",accessor:"configButton",noSort:!0,Cell:({row:r})=>r.original.configUrl?e.jsx(J,{onClick:()=>window.open(r.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],dr=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:r})=>Array.isArray(r)?r.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):r},{Header:"Cluster Name",accessor:"clusterName"},{Header:"Cluster ID",accessor:"clusterId"},{Header:"Attribute Name",accessor:"attributeName"},{Header:"Attribute ID",accessor:"attributeId"},{Header:"Attribute Value",accessor:"attributeValue",Cell:({value:r})=>e.jsx($,{title:r,componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r})})}],Fn=r=>`${r.pluginName}::${r.uniqueId}`,Ln=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Hn({data:r,columnVisibility:c,setPlugin:a,setEndpoint:i,setDeviceName:l}){const[g,b]=o.useState(null),t=o.useMemo(()=>lr.filter(M=>c[M.accessor]),[c]),{getTableProps:d,getTableBodyProps:y,headerGroups:W,rows:h,prepareRow:L}=Ue.useTable({columns:t,data:r,getRowId:Fn},Ue.useSortBy),V=M=>{if(M.id===g){b(null),a(null),i(null),l(null),s&&console.log("Device unclicked:",M.id,"selectedDeviceIndex:",g);return}b(M.id),a(M.original.pluginName),i(M.original.endpoint),l(M.original.name),s&&console.log("Device clicked:",M.id,"selectedDeviceIndex:",g,"pluginName:",M.original.pluginName,"endpoint:",M.original.endpoint)};return e.jsxs("table",{...d(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:W.map(M=>e.jsx("tr",{...M.getHeaderGroupProps(),children:M.headers.map(O=>e.jsxs("th",{...O.getHeaderProps(O.noSort?void 0:O.getSortByToggleProps()),children:[O.render("Header"),!O.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:O.isSorted?O.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Ft,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...y(),children:h.map((M,O)=>(L(M),e.jsx("tr",{className:O%2===0?"table-content-even":"table-content-odd",...M.getRowProps(),onClick:()=>V(M),style:{backgroundColor:g===M.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:M.cells.map(u=>e.jsx("td",{...u.getCellProps(),children:u.render("Cell")}))})))})]})}function Rn({data:r,columnVisibility:c}){const a=o.useMemo(()=>dr.filter(d=>c[d.accessor]),[c]),{getTableProps:i,getTableBodyProps:l,headerGroups:g,rows:b,prepareRow:t}=Ue.useTable({columns:a,data:r,getRowId:Ln},Ue.useSortBy);return e.jsxs("table",{...i(),style:{margin:"-1px"},children:[e.jsx("thead",{children:g.map(d=>e.jsx("tr",{...d.getHeaderGroupProps(),children:d.headers.map(y=>e.jsx("th",{...y.getHeaderProps(),children:y.render("Header")}))}))}),e.jsx("tbody",{...l(),children:b.map((d,y)=>(t(d),e.jsx("tr",{className:y%2===0?"table-content-even":"table-content-odd",...d.getRowProps(),children:d.cells.map(W=>e.jsx("td",{...W.getCellProps(),children:W.render("Cell")}))})))})]})}function $n(){const{online:r,sendMessage:c,addListener:a,removeListener:i,getUniqueId:l}=o.useContext(be),[g,b]=o.useState([]),[t,d]=o.useState([]),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState(null),[O,u]=o.useState(0),[z,v]=o.useState(!1),[f,k]=o.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[R,C]=o.useState(!1),[m,H]=o.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[j,x]=o.useState(""),[w,q]=o.useState(g),[de,xe]=o.useState("icon"),S=o.useRef(l());o.useEffect(()=>{const U=D=>{if(s&&console.log("Devices received WebSocket Message:",D),D.src==="Matterbridge"&&D.dst==="Frontend"&&(D.method==="refresh_required"&&D.params.changed==="devices"&&(s&&console.log(`Devices received refresh_required: changed=${D.params.changed} and sending /api/devices request`),c({id:S.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),D.method==="/api/devices"&&(s&&console.log(`Devices received ${D.response.length} devices:`,D.response),b(D.response)),D.method==="/api/clusters")){console.log(`Devices received ${D.response.length} clusters:`,D.response),d(D.response.clusters);const P={};for(const N of D.response.clusters)s&&console.log("Cluster:",N.endpoint),P[N.endpoint]?P[N.endpoint]++:P[N.endpoint]=1;u(Object.keys(P).length)}};return a(U),s&&console.log("Devices added WebSocket listener"),()=>{i(U),s&&console.log("Devices removed WebSocket listener")}},[a,i,c]),o.useEffect(()=>{r&&(s&&console.log("Devices sending api requests"),c({id:S.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:S.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:S.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,c]),o.useEffect(()=>{y&&h&&(s&&console.log("Devices sending /api/clusters"),c({id:S.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:y,endpoint:h}}))},[y,h,c]);const p=()=>{v(!z)},E=U=>{k(D=>{const P={...D,[U]:!D[U]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(P)),P})};o.useEffect(()=>{const U=localStorage.getItem("devicesColumnVisibility");U&&k(JSON.parse(U))},[]);const I=()=>{C(!R)},Y=U=>{H(D=>{const P={...D,[U]:!D[U]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(P)),P})};o.useEffect(()=>{const U=localStorage.getItem("clustersColumnVisibility");U&&H(JSON.parse(U))},[]);const me=U=>{x(U.target.value.toLowerCase()),localStorage.setItem("devicesFilter",U.target.value.toLowerCase())},Me=U=>{xe(U),localStorage.setItem("devicesViewMode",U)};return o.useEffect(()=>{if(j===""){q(g);return}const U=g.filter(D=>D.name.toLowerCase().includes(j)||D.serial.toLowerCase().includes(j));q(U)},[g,j]),o.useEffect(()=>{const U=localStorage.getItem("devicesFilter");U&&x(U)},[]),o.useEffect(()=>{const U=localStorage.getItem("devicesViewMode");U&&xe(U)},[]),s&&console.log("Devices rendering..."),r?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:j,onChange:me,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(J,{onClick:()=>Me("table"),"aria-label":"Table View",disabled:de==="table",children:e.jsx($,{title:"Table View",children:e.jsx(lo,{style:{color:de==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(J,{onClick:()=>Me("icon"),"aria-label":"Icon View",disabled:de==="icon",children:e.jsx($,{title:"Icon View (beta)",children:e.jsx(co,{style:{color:de==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(De,{open:z,onClose:p,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:lr.map(U=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["pluginName","name","configButton"].includes(U.accessor),checked:f[U.accessor],onChange:()=>E(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:p,children:"Close"})})]}),de==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${y&&h?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Registered devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:p,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Hn,{data:w,columnVisibility:f,setPlugin:W,setEndpoint:L,setDeviceName:M})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total devices: ",w.length.toString()]})})]}),e.jsxs(De,{open:R,onClose:I,children:[e.jsx(Ne,{children:"Configure Clusters Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:dr.map(U=>e.jsx(Te,{control:e.jsx(Fe,{disabled:["clusterName","attributeName","attributeValue"].includes(U.accessor),checked:m[U.accessor],onChange:()=>Y(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Le,{children:e.jsx(ne,{onClick:I,children:"Close"})})]}),de==="table"&&y&&h&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsxs("div",{className:"MbfWindowHeaderText",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[e.jsxs("p",{style:{margin:"0px",padding:"0px"},children:['Clusters for device "',V,'" on endpoint ',h]}),e.jsx(J,{onClick:I,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Rn,{data:t,columnVisibility:m})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total child endpoints: ",O-1]})})]}),de==="icon"&&e.jsx(Tn,{filter:j,devices:w})]}):e.jsx(Qe,{})}const On=o.memo($n);function En(){const[r,c]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[a,i]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[l,g]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:b,setLogFilters:t,online:d,setAutoScroll:y}=o.useContext(be),W=M=>{c(M.target.value),t(M.target.value,a),localStorage.setItem("logFilterLevel",M.target.value),s&&console.log("handleChangeLevel called with value:",M.target.value)},h=M=>{i(M.target.value),t(r,M.target.value),localStorage.setItem("logFilterSearch",M.target.value),s&&console.log("handleChangeSearch called with value:",M.target.value)},L=M=>{g(M.target.checked),y(M.target.checked),localStorage.setItem("logAutoScroll",M.target.value?"true":"false"),s&&console.log("handleAutoScrollChange called with value:",M.target.checked)},V=()=>{s&&console.log("handleClearLogsClick called"),b([])};return s&&console.log("Logs rendering..."),d?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(_t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(ot,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:W,children:[e.jsx(F,{value:"debug",children:"Debug"}),e.jsx(F,{value:"info",children:"Info"}),e.jsx(F,{value:"notice",children:"Notice"}),e.jsx(F,{value:"warn",children:"Warn"}),e.jsx(F,{value:"error",children:"Error"}),e.jsx(F,{value:"fatal",children:"Fatal"})]}),e.jsx(_t,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:a,onChange:h,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Te,{control:e.jsx(Fe,{checked:l,onChange:L}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx($,{title:"Clear the logs",children:e.jsx(ne,{onClick:V,endIcon:e.jsx(St,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(ar,{})})]}):e.jsx(Qe,{})}const Vn=({open:r,ip:c,onClose:a,onSave:i})=>{const l=c?c.split(".").slice(0,3).join(".")+".1":"",[g,b]=o.useState("dhcp"),[t,d]=o.useState({ip:c??"",subnet:"255.255.255.0",gateway:l,dns:l}),y=L=>V=>{d({...t,[L]:V.target.value})},W=()=>{a()},h=()=>{const L=g==="static"?{type:g,...t}:{type:g};i(L),a()};return e.jsxs(De,{open:r,onClose:(L,V)=>{V==="backdropClick"||V==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Pe,{dividers:!0,children:[e.jsxs(or,{component:"fieldset",fullWidth:!0,children:[e.jsx(Ie,{component:"legend",children:"Select IP Configuration"}),e.jsxs(nr,{row:!0,value:g,onChange:L=>b(L.target.value),children:[e.jsx(Te,{value:"dhcp",control:e.jsx(wt,{}),label:"DHCP"}),e.jsx(Te,{value:"static",control:e.jsx(wt,{}),label:"Static"})]})]}),g==="static"&&e.jsxs(Ae,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:y("ip")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:y("subnet")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:y("gateway")})}),e.jsx(Ae,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:y("dns")})})]})]}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:W,children:"Cancel"}),e.jsx(ne,{variant:"contained",onClick:h,children:"Save"})]})]})},_n=({open:r,onClose:c,onSave:a})=>{const[i,l]=o.useState(""),[g,b]=o.useState(""),t=V=>{l(V.target.value)},d=V=>{b(V.target.value)},y=i.length>0&&i===g,W=()=>{c()},h=()=>{y&&(a(i),c())},L=()=>{a(""),c()};return e.jsxs(De,{open:r,onClose:(V,M)=>{M==="backdropClick"||M==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Pe,{dividers:!0,children:e.jsx(or,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Ae,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ae,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:t})}),e.jsx(Ae,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:g,onChange:d,error:g!==""&&i!==g,helperText:g!==""&&i!==g?"Passwords do not match":""})})]})})}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:W,children:"Cancel"}),e.jsx(ne,{variant:"contained",onClick:h,disabled:!y,children:"Change"}),e.jsx(ne,{variant:"contained",onClick:L,children:"Reset"})]})]})};function An(){const{online:r,addListener:c,removeListener:a,sendMessage:i,getUniqueId:l}=o.useContext(be),[g,b]=o.useState(null),[t,d]=o.useState(null),y=o.useRef(l());return o.useEffect(()=>{const W=h=>{h.src==="Matterbridge"&&h.dst==="Frontend"&&(h.method==="refresh_required"&&h.params.changed==="settings"&&(s&&console.log(`Settings received refresh_required: changed=${h.params.changed} and sending /api/settings request`),i({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),h.method==="/api/settings"&&(s&&console.log("Settings received /api/settings:",h.response),b(h.response.matterbridgeInformation),d(h.response.systemInformation)))};return c(W),s&&console.log("Settings added WebSocket listener"),()=>{a(W),s&&console.log("Settings removed WebSocket listener")}},[c,a,i]),o.useEffect(()=>{r&&(s&&console.log("Settings received online"),i({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,i]),g?(s&&console.log("Settings rendering..."),r?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Un,{matterbridgeInfo:g,systemInfo:t}),e.jsx(zn,{matterbridgeInfo:g}),e.jsx(qn,{matterbridgeInfo:g})]})}):e.jsx(Qe,{})):null}function Un({matterbridgeInfo:r,systemInfo:c}){const{sendMessage:a,getUniqueId:i}=o.useContext(be),[l,g]=o.useState("bridge"),[b,t]=o.useState("Info"),[d,y]=o.useState(!1),[W,h]=o.useState("dark"),[L,V]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[M,O]=o.useState(localStorage.getItem("homePageMode")??"logs"),[u,z]=o.useState(localStorage.getItem("virtualMode")??"outlet"),v=o.useRef(i()),[f,k]=o.useState(!1),R=()=>k(!1),C=I=>{s&&console.log("handleSaveNetConfig called with config:",I),a({id:v.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:I})},[m,H]=o.useState(!1),j=()=>H(!1),x=I=>{s&&console.log("handleSaveChangePassword called with password:",I),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:I}})};o.useEffect(()=>{r.bridgeMode!==void 0&&(g(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),y(r.fileLogger),z(r.virtualMode))},[r]),o.useEffect(()=>{const I=localStorage.getItem("frontendTheme");I&&h(I)},[]);const w=I=>{s&&console.log("handleChangeBridgeMode called with value:",I.target.value),g(I.target.value),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:I.target.value}})},q=I=>{s&&console.log("handleChangeMbLoggerLevel called with value:",I.target.value),t(I.target.value),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:I.target.value}})},de=I=>{s&&console.log("handleLogOnFileMbChange called with value:",I.target.checked),y(I.target.checked),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:I.target.checked}})},xe=I=>{const Y=I.target.value;s&&console.log("handleChangeTheme called with value:",Y),h(Y),localStorage.setItem("frontendTheme",Y),document.body.setAttribute("frontend-theme",Y)},S=I=>{const Y=I.target.checked;s&&console.log("handleChangeHomePagePlugins called with value:",Y),V(Y),localStorage.setItem("homePagePlugins",Y?"true":"false")},p=I=>{const Y=I.target.value;s&&console.log("handleChangeHomePageMode called with value:",Y),O(Y),localStorage.setItem("homePageMode",Y)},E=I=>{const Y=I.target.value;s&&console.log("handleChangeVirtualMode called with value:",Y),z(Y),localStorage.setItem("virtualMode",Y),a({id:v.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:Y}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Vn,{open:f,ip:c.ipv4Address,onClose:R,onSave:C}),e.jsx(_n,{open:m,onClose:j,onSave:x}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(nr,{row:!0,name:"mode-buttons-group",value:l,onChange:w,children:[e.jsx(Te,{value:"bridge",control:e.jsx(wt,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(Te,{value:"childbridge",control:e.jsx(wt,{}),label:"Childbridge",disabled:r.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:b,onChange:q,children:[e.jsx(F,{value:"Debug",children:"Debug"}),e.jsx(F,{value:"Info",children:"Info"}),e.jsx(F,{value:"Notice",children:"Notice"}),e.jsx(F,{value:"Warn",children:"Warn"}),e.jsx(F,{value:"Error",children:"Error"}),e.jsx(F,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(Fe,{checked:d,onChange:de,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:W,onChange:xe,children:[e.jsx(F,{value:"classic",children:"Classic"}),e.jsx(F,{value:"light",children:"Light"}),e.jsx(F,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Fe,{checked:L,onChange:S,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:M,onChange:p,children:[e.jsx(F,{value:"logs",children:"Logs"}),e.jsx(F,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:u,onChange:E,children:[e.jsx(F,{value:"disabled",children:"Disabled"}),e.jsx(F,{value:"outlet",children:"Outlet"}),e.jsx(F,{value:"light",children:"Light"}),e.jsx(F,{value:"switch",children:"Switch"}),e.jsx(F,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Change password"})}),r.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>k(!0),children:"Configure IP"})})]})})]})}function zn({matterbridgeInfo:r}){const{sendMessage:c,getUniqueId:a}=o.useContext(be),[i,l]=o.useState("Info"),[g,b]=o.useState(!1),[t,d]=o.useState(""),[y,W]=o.useState(""),[h,L]=o.useState(""),[V,M]=o.useState(),[O,u]=o.useState(),[z,v]=o.useState(),f=o.useRef(a());o.useEffect(()=>{r.bridgeMode!==void 0&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),b(r.matterFileLogger),d(r.matterMdnsInterface),W(r.matterIpv4Address),L(r.matterIpv6Address),M(r.matterPort),u(r.matterDiscriminator),v(r.matterPasscode))},[r]);const k=q=>{s&&console.log("handleChangeMjLoggerLevel called with value:",q.target.value),l(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:q.target.value}})},R=q=>{s&&console.log("handleLogOnFileMjChange called with value:",q.target.checked),b(q.target.checked),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:q.target.checked}})},C=q=>{s&&console.log("handleChangeMdnsInterface called with value:",q.target.value),d(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:q.target.value}})},m=q=>{s&&console.log("handleChangeIpv4Address called with value:",q.target.value),W(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:q.target.value}})},H=q=>{s&&console.log("handleChangeIpv6Address called with value:",q.target.value),L(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:q.target.value}})},j=q=>{s&&console.log("handleChangeMatterPort called with value:",q.target.value),M(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:q.target.value}})},x=q=>{s&&console.log("handleChangeMatterDiscriminator called with value:",q.target.value),u(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:q.target.value}})},w=q=>{s&&console.log("handleChangemMatterPasscode called with value:",q.target.value),v(q.target.value),c({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:q.target.value}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:k,children:[e.jsx(F,{value:"Debug",children:"Debug"}),e.jsx(F,{value:"Info",children:"Info"}),e.jsx(F,{value:"Notice",children:"Notice"}),e.jsx(F,{value:"Warn",children:"Warn"}),e.jsx(F,{value:"Error",children:"Error"}),e.jsx(F,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(Fe,{checked:g,onChange:R,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,onChange:C,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:y,onChange:m,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:h,onChange:H,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:V,onChange:j,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:O,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ie,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:z,onChange:w,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function qn({matterbridgeInfo:r}){return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Be,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(Be,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Be,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(Be,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(Be,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Be,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Be,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function Be({value:r,label:c}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:c,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}function Bn(r,c,a){const i=r?.[a],l=c?.[a];return i==null&&l==null?0:i==null?-1:l==null?1:typeof i=="boolean"&&typeof l=="boolean"?i===l?0:i?1:-1:typeof i=="number"&&typeof l=="number"?i-l:String(i).localeCompare(String(l))}function Jn({name:r,columns:c,rows:a,getRowKey:i,footerLeft:l,footerRight:g}){const b=o.useRef(new WeakMap),t=o.useRef(1),d=m=>{if(typeof i=="string"&&m&&m[i]!=null)return m[i];if(typeof i=="function"){const x=i(m);if(x!=null)return x}const H=c?.[0]?.id;if(H&&m&&m[H]!=null)return m[H];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let j=b.current.get(m);return j||(j=`rk_${t.current++}`,b.current.set(m,j)),j},[y,W]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[h,L]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[V,M]=o.useState(!1),[O,u]=o.useState(()=>{try{const m=localStorage.getItem(`${r}_column_visibility`);if(m)return JSON.parse(m)}catch{}return{}}),z=o.useMemo(()=>{const m={};for(const H of c)H.hidden||(m[H.id]=H.required?!0:O[H.id]!==!1);return m},[c,O]),v=o.useMemo(()=>{if(!y||!h)return a;const m=c.find(j=>j.id===y);if(!m||m.nosort)return a;const H=a.map((j,x)=>({el:j,index:x}));return H.sort((j,x)=>{const w=Bn(j.el,x.el,y);return w!==0?h==="asc"?w:-w:j.index-x.index}),H.map(j=>j.el)},[a,y,h,c]),f=m=>{if(y!==m||!y){W(m),L("asc"),localStorage.setItem(`${r}_table_order_by`,m),localStorage.setItem(`${r}_table_order`,"asc");return}if(h==="asc"){L("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}W(null),L(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},k=()=>{M(!V)},R=m=>{u(H=>{const j=c.find(q=>q.id===m);if(j&&j.required)return H;const x=z[m]!==!1,w={...H};x?w[m]=!1:delete w[m];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(w))}catch{}return w})},C=()=>{const m={};u(m);try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(m))}catch{}};return console.log(`Rendering table ${r}${y&&h?` ordered by ${y}:${h}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(De,{open:V,onClose:(m,H)=>{H==="backdropClick"||H==="escapeKeyDown"||k()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ne,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${r} columns`})]})}),e.jsx(Pe,{children:e.jsx(st,{children:c.filter(m=>!m.hidden).map(m=>e.jsx(Te,{control:e.jsx(Fe,{disabled:!!m.required,checked:m.required?!0:z[m.id]!==!1,onChange:()=>R(m.id)}),label:m.label},m.id))})}),e.jsxs(Le,{children:[e.jsx(ne,{onClick:C,children:"Reset"}),e.jsx(ne,{variant:"contained",onClick:m=>{if(m?.currentTarget&&typeof m.currentTarget.blur=="function")try{m.currentTarget.blur()}catch{}const H=document.activeElement;if(H&&H instanceof HTMLElement&&typeof H.blur=="function")try{H.blur()}catch{}k()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:r}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(J,{onClick:m=>{if(m?.currentTarget?.blur)try{m.currentTarget.blur()}catch{}k()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx($,{title:`Configure ${r} columns`,children:e.jsx(te,{path:Ho,size:"20px",style:{color:"var(--header-text-color)"}})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${r} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(m=>{if(m.hidden||!m.required&&z[m.id]===!1)return null;const H=!m.nosort,j=H&&y===m.id&&!!h;return e.jsxs("th",{onClick:H?()=>f(m.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:m.minWidth,maxWidth:m.maxWidth,textAlign:m.align||"left",cursor:H?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:m.maxWidth?"nowrap":void 0,overflow:m.maxWidth?"hidden":void 0,textOverflow:m.maxWidth?"ellipsis":void 0},"aria-sort":H?j?h==="asc"?"ascending":"descending":"none":void 0,children:[m.label,j&&e.jsxs("span",{style:{marginLeft:6},children:[h==="asc"&&e.jsx(te,{path:Ft,size:"15px"}),h==="desc"&&e.jsx(te,{path:Tt,size:"15px"})]})]},m.id)})})}),e.jsx("tbody",{children:v.map((m,H)=>{const j=d(m);return e.jsx("tr",{className:H%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:c.map(x=>{if(x.hidden||!x.required&&z[x.id]===!1)return null;const w=m[x.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:x.align||"left",padding:"4px 8px",margin:"0",maxWidth:x.maxWidth,whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},children:typeof x.render=="function"?x.render(w,j,m,x):typeof w=="boolean"?e.jsx(Fe,{checked:w,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):x.format&&typeof w=="number"?x.format(w):w!=null?String(w):null},x.id)})},j)})})]})}),e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:l}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}const Qn=o.memo(Jn);function Gn(){const{online:r,sendMessage:c,addListener:a,removeListener:i,getUniqueId:l}=o.useContext(be),{showSnackbarMessage:g,closeSnackbarMessage:b}=o.useContext(nt),[t,d]=o.useState(null),[y,W]=o.useState(null),[h,L]=o.useState(null),[V,M]=o.useState(null),[O,u]=o.useState({cpuUsage:0}),[z,v]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[f,k]=o.useState({systemUptime:"",processUptime:""}),R=o.useRef(-1),[C,m]=o.useState(()=>cr);R.current||(R.current=l(),console.log("Test uniqueId:",R)),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const j=x=>{if(x.src==="Matterbridge"&&x.dst==="Frontend"){if(fe(x)&&x.method==="restart_required"&&(console.log("Test received restart_required"),g("Restart required",0)),fe(x)&&x.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${x.params.changed} and sending api requests`),g("Refresh required",0),c({id:R.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),fe(x)&&x.method==="memory_update"&&(console.log("Test received memory_update",x),v(x.params)),fe(x)&&x.method==="cpu_update"&&(console.log("Test received cpu_update",x),u(x.params)),fe(x)&&x.method==="uptime_update"&&(console.log("Test received uptime_update",x),k(x.params)),Ve(x)&&x.method==="/api/settings"&&x.response&&(console.log("Test received /api/settings:",x.response),g("Test received /api/settings"),d(x.response)),Ve(x)&&x.method==="/api/plugins"&&x.response&&(console.log(`Test received ${x.response.length} plugins:`,x.response),g("Test received /api/plugins"),W(x.response)),Ve(x)&&x.method==="/api/devices"&&x.response){console.log(`Test received ${x.response.length} devices:`,x.response),g("Test received /api/devices"),L(x.response);for(const w of x.response)console.log("Test sending /api/clusters for device:",w.pluginName,w.name,w.endpoint),c({id:R.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:w.pluginName,endpoint:w.endpoint}})}Ve(x)&&x.method==="/api/clusters"&&x.response&&(console.log(`Test received ${x.response.clusters.length} clusters for device ${x.response.deviceName} endpoint ${x.response.endpoint}:`,x),g("Test received /api/clusters"),M(x.response))}};return a(j),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),i(j),console.log("Test useEffect WebSocketMessage unmounted")}},[a,i,c,g]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),c({id:R.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:R.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,c,g]);const H=o.useCallback(j=>String(j.code),[]);return console.log("Test rendering..."),r?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"}),e.jsx("div",{style:{margin:"0",padding:"0",gap:"0",width:"1200px",maxWidth:"1200px",height:"600px",maxHeight:"600px",overflow:"hidden",backgroundColor:"var(--div-bg-color)",border:"1px solid #0004ffff"},children:e.jsx(Qn,{name:"Test",columns:Yn,rows:C,getRowKey:H,footerLeft:"Left Footer",footerRight:"Right Footer"})}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx(ne,{variant:"contained",color:"primary",onClick:()=>{console.log("Test button clicked"),g("Test button clicked"),b("Refresh required"),b("Restart required"),b("Test permanent message removal")},children:"Test"}),e.jsx(ne,{variant:"outlined",onClick:()=>{m(j=>{const x=j.findIndex(xe=>xe.code==="F123");if(x===-1)return j;const w=j[x],q={...w,population:(w.population||0)+1},de=j.slice();return de[x]=q,de})},children:"Update F123"})]})]})}):e.jsx(Qe,{})}const Kn=o.memo(Gn),Yn=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(r,c,a,i)=>e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",borderRadius:"8px",backgroundColor:"var(--chip-bg, #e6f4ff)",color:"var(--chip-fg, #0550ae)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"0.85em"},children:String(r)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:r=>r.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(r,c,a,i)=>a.isIsland?"🏝️":"🏞️"}];function Se(r,c,a,i,l){const g=a/i;return{name:r,code:c,population:a,size:i,density:g,isIsland:l}}const cr=[Se("India","IN",1324171354,3287263,!1),Se("China","CN",1403500365,9596961,!1),Se("Italy","IT",60483973,301340,!1),Se("United States","US",327167434,9833520,!1),Se("Canada is a truly wonderful country","CA",37602103,9984670,!1),Se("Australia","AU",25475400,7692024,!0),Se("Germany","DE",83019200,357578,!1),Se("Ireland","IE",4857e3,70273,!0),Se("Mexico","MX",126577691,1972550,!1),Se("Japan","JP",126317e3,377973,!0),Se("France","FR",67022e3,640679,!1),Se("United Kingdom","GB",67545757,242495,!0),Se("Russia","RU",146793744,17098246,!1),Se("Nigeria","NG",200962417,923768,!1),Se("Brazil","BR",210147125,8515767,!1)],Kt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Yt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let r=0;r<2e3;r++){const c=`${Kt[r%Kt.length]}${Yt[r%Yt.length]} ${r}`,a=`F${r.toString().padStart(3,"0")}`,i=Math.floor(Math.random()*1e9),l=Math.floor(Math.random()*1e7),g=Math.random()<.2;cr.push(Se(c,a,i,l,g))}function Xn(r,c){s&&console.log("getCssVariable:",r,"defaultValue",c);const a=getComputedStyle(document.body).getPropertyValue(r).trim();return a||console.error("getCssVariable: undefined",a),a||c}function Zn(r){return po({palette:{primary:{main:r},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}let s=!1;const ei=()=>{s=!s},pr=o.createContext(void 0);function ti({children:r}){const[c,a]=o.useState(!1),[i,l]=o.useState(""),g=async b=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:b})});if(t.ok){const{valid:d}=await t.json();d?a(!0):b!==""&&l("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(pr.Provider,{value:{loggedIn:c,logIn:g,errorMessage:i},children:r})}function ri(){const[r,c]=o.useState(""),a=o.useContext(pr),[i,l]=o.useState("#1976d2");if(!a)throw new Error("AuthContext not found");const{loggedIn:g,logIn:b,errorMessage:t}=a,d=M=>{M.preventDefault(),b(r)},y={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},W={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},h={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"};o.useEffect(()=>{s&&console.log("Setting frontend theme");const M=localStorage.getItem("frontendTheme");s&&console.log("Saved theme:",M),M?document.body.setAttribute("frontend-theme",M):document.body.setAttribute("frontend-theme","dark");const O=Xn("--primary-color","#1976d2");s&&console.log("Primary color from CSS:",O),l(O)},[]);const L=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";console.log(`Loading App.js with href="${window.location.href}" and pathname="${window.location.pathname}" >>> baseName="${L}"`);const V=Zn(i);return b(""),g?e.jsx(uo,{theme:V,children:e.jsx(Cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(qo,{children:e.jsx(Bo,{children:e.jsx(xr,{basename:L,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Qo,{}),e.jsxs(br,{children:[e.jsx(Xe,{path:"/",element:e.jsx(bn,{})}),e.jsx(Xe,{path:"/devices",element:e.jsx(On,{})}),e.jsx(Xe,{path:"/log",element:e.jsx(En,{})}),e.jsx(Xe,{path:"/settings",element:e.jsx(An,{})}),e.jsx(Xe,{path:"/test",element:e.jsx(Kn,{})}),e.jsx(Xe,{path:"*",element:e.jsx(vr,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:y,children:e.jsxs("form",{onSubmit:d,style:W,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:r,onChange:M=>c(M.target.value),style:h,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function oi(){return e.jsx(ti,{children:e.jsx(ri,{})})}yr.createRoot(document.getElementById("root")).render(e.jsx(Xt.StrictMode,{children:e.jsx(oi,{})}));
|